@_unit/unit 1.0.25 → 1.0.26
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/build/web.js +8 -8
- package/lib/API.d.ts +3 -1
- package/lib/client/makeEventListener.js +1 -1
- package/lib/client/platform/web/api/document.js +0 -16
- package/lib/client/platform/web/api/document.js.map +1 -1
- package/lib/client/platform/web/api/theme.d.ts +3 -0
- package/lib/client/platform/web/api/theme.js +26 -0
- package/lib/client/platform/web/api/theme.js.map +1 -0
- package/lib/client/platform/web/boot.js +4 -0
- package/lib/client/platform/web/boot.js.map +1 -1
- package/lib/host/none.js +5 -3
- package/lib/host/none.js.map +1 -1
- package/lib/system/_specs.js +1 -1
- package/lib/system/_specs.js.map +1 -1
- package/lib/system/platform/component/app/GUI/Component.js +1 -1
- package/lib/system/platform/component/app/GUI/Component.js.map +1 -1
- package/lib/system/platform/method/value/Write/index.js.map +1 -1
- package/package.json +1 -1
- package/public/_worker.js +1 -1
- package/public/_worker.js.map +2 -2
- package/public/build.json +1 -1
- package/public/index.js +8 -8
- package/public/index.js.map +4 -4
- package/src/API.ts +3 -1
- package/src/client/makeEventListener.ts +1 -1
- package/src/client/platform/web/api/document.ts +0 -6
- package/src/client/platform/web/api/theme.ts +19 -0
- package/src/client/platform/web/boot.ts +5 -0
- package/src/host/none.ts +5 -3
- package/src/system/platform/component/app/GUI/Component.ts +1 -1
- package/src/system/platform/method/value/Write/index.ts +0 -1
package/public/_worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{var U8=Object.defineProperty,w8=Object.defineProperties;var L8=Object.getOwnPropertyDescriptors;var Ru=Object.getOwnPropertySymbols;var Cf=Object.prototype.hasOwnProperty,Mf=Object.prototype.propertyIsEnumerable;var Af=(r,n,t)=>n in r?U8(r,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[n]=t,_=(r,n)=>{for(var t in n||={})Cf.call(n,t)&&Af(r,t,n[t]);if(Ru)for(var t of Ru(n))Mf.call(n,t)&&Af(r,t,n[t]);return r},Z=(r,n)=>w8(r,L8(n));var Pf=r=>typeof r=="symbol"?r:r+"",bt=(r,n)=>{var t={};for(var e in r)Cf.call(r,e)&&n.indexOf(e)<0&&(t[e]=r[e]);if(r!=null&&Ru)for(var e of Ru(r))n.indexOf(e)<0&&Mf.call(r,e)&&(t[e]=r[e]);return t};var b=(r,n,t)=>new Promise((e,i)=>{var o=p=>{try{s(t.next(p))}catch(d){i(d)}},a=p=>{try{s(t.throw(p))}catch(d){i(d)}},s=p=>p.done?e(p.value):Promise.resolve(p.value).then(o,a);s((t=t.apply(r,n)).next())});var gn=class extends Error{constructor(){super("listener not found")}};function $d({obj:r={}}){return{keys:Object.keys(r)}}function et(r){return Object.keys(r)}var mt=class{constructor(){this.__listeners={};this._removeListener=(n,t)=>{let e=this.__listeners[n];if(!e)throw new gn;let i=e.indexOf(t);if(i<0)throw new gn;e.splice(i,1),e.length===0&&(delete this.__listeners[n],this.emit("unlisten",{event:n}))}}prependListener(n,t){return this.__listeners[n]=this.__listeners[n]||[],this.__listeners[n].unshift(t),this.emit("listen",{event:n}),()=>{this._removeListener(n,t)}}removeListener(n,t){this._removeListener(n,t)}addListener(n,t){return this.__listeners[n]=this.__listeners[n]||[],this.__listeners[n].push(t),this.emit("listen",{event:n}),()=>{this._removeListener(n,t)}}eventNames(){return et(this.__listeners)}listenerCount(n){return(this.__listeners[n]||[]).length}emit(n,...t){let e=this.__listeners[n];if(e){for(let i of e)i.call(this,...t);this.emit("emit",{event:n})}}};function gt(){}function Tt(r,n){r.forEach(n)}function kt(r,n){r.splice(n,1)}function $t(r,n){let t=r.indexOf(n);kt(r,t)}function Ye(r,n){let t=r.indexOf(n);kt(r,t)}function jt(r,n){r.push(n)}function It(r,n,t){return r.splice(t,0,n),r}function Nd(r,...n){return r.unshift(...n)}function G8(r){return r.length-1}function ku(r,n=0){let t=G8(r);return r[t+n]}function Of(r){let n=r.length,t=r[n-1],e=r.slice(0,n-1);return[t,e]}var Ie=class{constructor(n){this._node={emitter:new mt,children:{}};this._dispatch=(n,t,e,i)=>{this._rec_dispatch(t,this._node,n,t,e,i)};this._rec_dispatch=(n,t,e,i,o,a)=>{if(n.length===0)this._end_dispatch(t,e,i,o,a);else{let[s,...p]=n,d=t.children[s];d&&this._rec_dispatch(p,d,e,i,o,a);let c=t.children["*"];c&&this._rec_dispatch(p,c,e,i,o,a)}};this._end_dispatch=(n,t,e,i,o)=>{let{emitter:a}=n;a&&(a.emit(i,t,e,i,o),a.emit("*",t,e,i,o))};this._ensure_emitter=n=>{let t=this._node;for(let e of n)t.children[e]||(t.children[e]={emitter:new mt,children:{}}),t=t.children[e];return t.emitter};this._remove_node=n=>{if(n.length>0){let[t,e]=Of(n),i=this._node_at_path(e);delete i.children[t]}};this._node_at_path=n=>{let t=this._node;for(let e of n)if(t=t.children[e],!t)return null;return t};this._set_path=(n,t)=>{let e=n.slice(0,-1),i=ku(n),o=this._obj_at_path(e);o[i]=t,this._dispatch("set",e,i,t)};this._delete=n=>b(this,null,function*(){this._delete_path([n])});this._delete_path=n=>{let t=n.slice(0,-1),e=ku(n),i=this._obj_at_path(t),o=i[e];delete i[e],this._dispatch("delete",t,e,o)};this._obj=n}_obj_at_path(n){let t=this._obj;for(let e of n)t=t[e];return t}read(){return b(this,null,function*(){return this._obj})}write(n){this._obj=n}get(n){return b(this,null,function*(){if(this._obj[n]===void 0)throw new Error("key value not found");return this._obj[n]})}set(n,t){return b(this,null,function*(){this._set_path([n],t)})}hasKey(n){return b(this,null,function*(){return this._obj[n]!==void 0})}delete(n){return b(this,null,function*(){return this._delete(n)})}deepGet(n){return b(this,null,function*(){return this._obj_at_path(n)})}deepSet(n,t){return b(this,null,function*(){this._set_path(n,t)})}deepDelete(n){return b(this,null,function*(){this._delete_path(n)})}keys(){return b(this,null,function*(){return et(this._obj)})}subscribe(n,t,e){let i=this._ensure_emitter(n);return i.addListener(t,e),()=>{i.removeListener(t,e),i.eventNames().length===0&&this._remove_node(n)}}};var Fd="untitled",pe="call",Uf="callback";var Ue="watch",$u="unwatch",we="ref",Nu="ref_exec";var Zt="init",Qt="terminate",Fu="connect",Bu="disconnect",Ot="exec";var Je=r=>typeof r=="object"&&r!==null;function Ht(r,n){let t=Array.isArray(r)?[...r]:_({},r);return R8(t,n),t}function R8(r,n){for(let t in n)if(r[t]!==void 0&&n[t]!==void 0){let e=Je(r[t]),i=Je(n[t]);e&&i?r[t]=Ht(r[t],n[t]):r[t]=n[t]}else r[t]=n[t]}var wf=(r={})=>Ht({type:"`U`&`G`",name:Fd,units:{},merges:{},inputs:{},outputs:{},metadata:{icon:null,description:""}},r);function Bd({a:r}){return{length:jd(r)}}function jd(r){return r.length}function ue(r){let n=et(r);return jd(n)}function ju(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,9)}function Xe(r){let n;do n=ju();while(r[n]);return n}function Hu(r){let n;do n=ju();while(r.has(n));return n}function Le(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let n=Math.random()*16|0;return(r=="x"?n:n&3|8).toString(16)})}function Ze(r){let n;do n=Le();while(r[n]);return n}function Hd(r,n){for(let t in r)n(r[t],t)}function Nt(r,n){for(let t in r)n(t,r[t])}function vt(r,n){let t={};for(let e in r)t[e]=n(r[e],e);return t}function Vu(r,n){let t={};for(let e in r)t[e]=n(e,r[e]);return t}function Lf(r,n){return k8(r,n)}function k8(r,n){let t=[];for(let i in r){let o=r[i],a=n(o,i);t.push([a,o])}return $8(t)}function hn(r,n){for(let t in r)if(n(r[t],t))return!0;return!1}function Vd(r,n,t){let e=t;for(let i in r)e=n(e,r[i],i);return e}function ce(r,n){let t={};for(let e in r)n(r[e],e)&&(t[e]=r[e]);return t}function Ft(r){return et(r).length===0}var at=r=>et(r)[0];function j(r){if(typeof r!="object"||r===null)return r;if(r instanceof Set)return new Set(j([...r]));let n=Array.isArray(r)?[]:{};for(let t in r)n[t]=j(r[t]);return n}function zu(r){return et(r).length}function de(r,n,t){r[n]=t}function me(r,n){return r[n]}function F(r,n,t){let e=r,i=n.length-1;if(i>=0){let o=n[i];for(let a=0;a<i;a++){let s=n[a];e[s]===void 0&&(e[s]={}),e=e[s]}e[o]=t}}function Vt(r,n){let t=r,e=n.length-1;if(e>=0){let i=n[e];for(let o=0;o<e;o++){let a=n[o];if(t[a]===void 0)return;t=t[a]}delete t[i]}}function fe(r,n){if(n.length===1){delete r[n[0]];return}let[t,...e]=n,i=r[t];fe(i,e),Ft(i)&&delete r[t]}function Wu(r,n,t){F(r,n,Ht(W(r,n,{}),t))}function W(r,n,t){let e=r;for(let i=0;i<n.length;i++){let o=n[i];if(e[o]===void 0)return t;e=e[o]}return e}function Gf(r,n){let i=r,{[n]:t}=i;return bt(i,[Pf(n)])}function $8(r){return Object.fromEntries(r)}function Rf(r,n){return r[n]!==void 0}function ht(r,n){return r[n]}function ve(r={}){return j(_(_({},wf()),r))}function Ge(r){return Ze(r)}function yn(r,n){if(n.startsWith("_"))return!0;let t=ht(r,n),{system:e}=t;return e}function F8(r){let{render:n}=r;return n}function kf(r){var n;return(n=F8(r))!=null?n:B8(r)}function B8(r){let{component:n={}}=r,{subComponents:t={}}=n;return ue(t)>0}var Ku=class{constructor(n){this.specsCount={};this.specs=n,this.specs_=new Ie(n)}newSpecId(){return Ze(this.specs)}hasSpec(n){return!!this.specs[n]}emptySpec(){let n=Ge(this.specs),t=ve({id:n});return this.newSpec(t),t}newSpec(n,t){return t=t!=null?t:Ge(this.specs),n.id=t,this.specs_.set(t,n),n}getSpec(n){return this.specs[n]}setSpec(n,t){this.specs_.set(n,t)}injectSpecs(n){let t={},e=new Set,i=(o,a)=>{if(e.has(o)||t[o])return;let s=o,p=!1;for(;this.hasSpec(s);)s=this.newSpecId(),p=!0;e.add(o);let{units:d}=a;for(let c in d){let m=d[c];if(!this.hasSpec(m.id)){let f=n[m.id];i(m.id,f)}}p?JSON.stringify(a)===JSON.stringify(this.getSpec(o))||(t[o]=s,this.specs_.set(o,a)):this.specs_.set(o,a)};for(let o in n){let a=n[o];i(o,a)}return t}shouldFork(n){var t;return((t=this.specsCount[n])!=null?t:0)>1||yn(this.specs,n)}forkSpec(n,t){if(this.shouldFork(n.id)){let e=j(n);delete e.system;let{id:i}=this.newSpec(e,t);return[i,e]}else return[n.id,n]}registerUnit(n){this.specsCount[n]===void 0&&(this.specsCount[n]=0),this.specsCount[n]+=1}unregisterUnit(n){this.specsCount[n]&&(this.specsCount[n]-=1,this.specsCount[n]===0&&(delete this.specsCount[n],yn(this.specs,n)||this.deleteSpec(n)))}deleteSpec(n){this.specs_.delete(n)}};function $f(r){let n="";for(let t in r){let e=r[t];n+=`${t}`}return n}function Nf(r,n){let{root:t,api:{document:{createElement:e}}}=r,i=e("style");i.innerHTML=n,t.shadowRoot.appendChild(i)}function Ff(r,n){let{root:t}=r,e=Array.from(t.children).find(i=>i.tagName==="STYLE"&&e.innerHTML===n);if(!e)throw new Error("style not found");t.shadowRoot.removeChild(e)}function ut(r,n){let t={};return new Proxy(t,{get(e,i){var o,a;return(a=(o=t[i])!=null?o:n[i])!=null?a:r[i]},set(e,i,o){return t[i]=o,!0},has(e,i){return i in t||i in n||i in r},deleteProperty(e,i){return t[i]!==void 0?(delete t[i],!0):n[i]!==void 0?(delete n[i],!0):r[i]!==void 0?(delete r[i],!0):!1},ownKeys(){return[...new Set([...Object.getOwnPropertyNames(r),...Object.getOwnPropertyNames(n),...Object.getOwnPropertyNames(t)])]},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0,writable:!0}}})}function Bf(r,n){let{global:{ref:t}}=r;return t[n]||null}function jf(r,n){let{global:{ref:t}}=r,e=Xe(t);return t[e]=n,e}function Hf(r,n){let{global:{ref:t}}=r;delete t[n]}var C=class extends mt{constructor(t){super();this.__=[];this.__async=!1;this.__ref_count=0;this.__system=t,this.register()}getGlobalId(){return this.__global_id}getInterface(){return this.__}refSystem(){return this.__system}register(){this.__ref_count++,this.__ref_count===1&&(this.__global_id=jf(this.__system,this)),this.emit("register")}unregister(){this.__ref_count--,this.__ref_count===0&&this.emit("unregister")}destroy(){Hf(this.__system,this.__global_id),this.emit("destroy")}raw(){throw new Error("object doens't have raw form")}};var j8=new Set(["null","string","number","boolean"]);function De(r){let n=typeof r;if(j8.has(n))return!0;if(n==="object"){if(Array.isArray(r)){for(let t of r)if(!De(t))return!1}for(let t in r){let e=r[t];if(!De(e))return!1}return!0}return!!(n==="function"&&r.__bundle)}var Ut=class extends mt{constructor({data:t,constant:e,ignored:i,ref:o}={}){super();this._constant=!1;this._ignored=!1;this._ref=!1;this._invalid=!1;this._idle=!0;this._register=void 0;t!==void 0&&(this._idle=!1),this._register=t,this._constant=e||!1,this._ignored=i||!1,this._ref=o||!1}take(){let t=this._register;return this._register!==void 0&&(this._register=void 0,this.emit("drop",t)),this.end(),t}invalidate(){this._register!==void 0&&!this._invalid&&(this._invalid=!0,this._idle=!0,this.emit("invalid"))}start(){this._idle&&(this._idle=!1,this.emit("start"))}end(){this._register===void 0&&!this._idle&&(this._idle=!0,this.emit("end"))}pull(){let t=this._register;return t!==void 0&&(this._constant?this.emit("_data",t):this.take()),t}push(t){this.invalidate(),this._invalid=!1,this.start(),this._register=t,this.emit("data",t),this._ref||this._ignored&&!this._constant&&this.take()}peak(){return this._register}empty(){return this._register===void 0}active(){return!this.empty()}ignored(t){return t!==void 0&&(this._ignored=t,this._ignored&&!this._constant&&!this._ref&&this.take(),this.emit("ignored",this._ignored)),this._ignored}ref(t){return t!==void 0&&(this._ref=t,this.emit("ref",this._ref)),this._ref}constant(t){return t!==void 0&&(this._constant=t),this._constant}invalid(){return this._invalid}snapshot(){return{_register:De(this._register)?this._register:void 0,_invalid:this._invalid,_constant:this._constant,_ignored:this._ignored,_idle:this._idle}}restore(t){let{_register:e,_invalid:i,_constant:o,_ignored:a,_idle:s}=t;this._register=e,this._invalid=i,this._constant=o,this._ignored=a,this._idle=s}read(){return b(this,null,function*(){if(this._register===void 0)throw new Error("empty");return this._register})}write(t){return b(this,null,function*(){this.push(t)})}};function qu(r,n,t){let e={};for(let i in r){let o=r[i];o!==void 0&&(e[i]=st(o,n,t))}return e}function Yu(r,n,t){for(let e in r.input){let i=r.input[e];r.input[e]=qu(i,n,t)}for(let e in r.output){let i=r.output[e];r.output[e]=qu(i,n,t)}r.memory=qu(r.memory,n,t)}function Vf(r,n,t){let e=j(r);return Yu(e,n,t),e}var zd={};function zt(r,n){let{unit:{id:t,memory:e}}=n,i=`${t}/${JSON.stringify(e)}`;if(zd[i])return zd[i];class o extends r{constructor(s){if(n.specs&&s.injectSpecs(n.specs),super(s,t),e){let p=Vf(e,s.specs,s.classes);this.restore(p)}}}return o.__bundle=n,zd[i]=o,o}var lt="_self";var Ju=class extends Error{constructor(n){super(`input with name "${n}" already exists`)}};var Xu=class extends Error{constructor(n){super(`output with name "${n}" already exists`)}};var Re=class extends Error{constructor(n){super(`input named "${n}" not found`)}};var _n=class extends Error{};var xn=class extends Error{constructor(n){super(`output named "${n}" not found`)}};function Wd(r){let n="";for(let t=0;t<r.length;t++){let e=r[t];e==='"'?n+='\\"':n+=e}return n}function Zu(r){return`unit://${r}`}function Y(r){switch(typeof r){case"string":return`"${Wd(r)}"`;case"number":case"boolean":return`${r}`;case"object":return r===null?"null":Array.isArray(r)?`[${r.map(Y).join(",")}]`:r.constructor.name==="Object"?`{${Object.entries(r).filter(([t,e])=>e!==void 0).map(([t,e])=>`${`"${Wd(t)}"`}:${Y(e)}`).join(",")}}`:Zu(r.__global_id);case"function":return r.__bundle?`$${Y(r.__bundle)}`:"null";default:throw new Error("cannot stringify value")}}function In(r){let{input:n,output:t}=r,e=Se(n),i=Se(t);return{input:e,output:i}}function Se(r){let n={};for(let t in r){let e=r[t];e!==void 0&&(e instanceof C?n[t]="null":n[t]=Y(e))}return n}function zf(r){let{spec:n}=r;Kd(n)}function Wf(r){Kf(r.unit)}function Kd(r){for(let n in r.units)Kf(r.units[n])}function Kf(r){let{memory:n}=r;n&&ke(n)}function ke(r){for(let n in r.input){let t=r.input[n];r.input[n]=Se(t)}for(let n in r.output){let t=r.output[n];r.output[n]=Se(t)}r.memory=Se(r.memory)}function A(r,n){for(let t in r){let e=r[t];n(e,t)}}var qf=(r,n)=>r.reduce((t,e)=>{var i;return Z(_({},t),{[e]:new Ut((i=n[e])!=null?i:{})})},{}),$e={ref:!1},yt=class extends C{constructor({i:t=[],o:e=[]},i={},o,a){var m,f;super(o);this.__=["U"];this._parent=null;this._input={};this._output={};this._data_input={};this._data_output={};this._ref_input={};this._ref_output={};this._i_opt={};this._o_opt={};this._i_name_set=new Set;this._o_name_set=new Set;this._d_i_name=new Set;this._d_o_name=new Set;this._r_i_name=new Set;this._r_o_name=new Set;this._o_count=0;this._i_count=0;this._d_i_count=0;this._d_o_count=0;this._r_i_count=0;this._r_o_count=0;this._err=null;this.ref=null;this._paused=!0;this._memRemoveDataInput=t=>{this._d_i_count--,this._d_i_name.delete(t),delete this._data_input[t]};this._memRemoveRefInput=t=>{this._r_i_count--,this._r_i_name.delete(t),delete this._ref_input[t]};this._memAddRefOutput=(t,e)=>{this._r_o_count++,this._r_o_name.add(t),this._memSetRefOutput(t,e)};this._memSetRefOutput=(t,e)=>{this._ref_output[t]=e};this._memAddDataOutput=(t,e)=>{this._d_o_count++,this._d_o_name.add(t),this._memSetDataOutput(t,e)};this._memSetDataOutput=(t,e)=>{this._data_output[t]=e};this._memRemoveRefPin=(t,e)=>{t==="input"?this._memRemoveRefInput(e):this._memRemoveRefOutput(e)};this._memRemoveRefOutput=t=>{this._r_o_count--,this._r_o_name.delete(t),delete this._ref_output[t]};this._memRemoveDataOutput=t=>{this._d_o_count--,this._d_o_name.delete(t),delete this._data_output[t]};this._catcherCallback=[];this._catcherDoneCount=0;this._catcherDone=[];this._catchErr=!1;this._caughtErr=null;let{input:s,output:p}=i,d=qf(t,(m=i.input)!=null?m:{}),c=qf(e,(f=i.output)!=null?f:{});this.setInputs(d,s),this.setOutputs(c,p),this._selfInput=new Ut({data:this,constant:!1,ref:!0}),this._selfOutput=new Ut({data:this,constant:!1,ref:!0}),this._selfOutput.addListener("drop",()=>{throw new Error("self output cannot be dropped")}),this.id=a,o.registerUnit(a)}isElement(){return!1}isPinIgnored(t,e){return this.getPin(t,e).ignored()}isPinConstant(t,e){return this.getPin(t,e).constant()}isPinRef(t,e){let i=t==="input";return!i&&e===lt?!0:i&&!!this._ref_input[e]||!i&&!!this._ref_output[e]}setParent(t){this._parent=t,this.emit("parent",this._parent)}setPinIgnored(t,e,i){t==="input"?this.setInputIgnored(e,i):this.setOutputIgnored(e,i)}setPinConstant(t,e,i){this.getPin(t,e).constant(i),this.emit("set_pin_constant",t,e,i)}_memSetPinOptData(t,e){t==="input"?this._memSetInputData(e):this._memSetOutputData(e)}_memSetInputData(t){let e=this._input[t];this._memRemoveRefInput(t),this._memAddDataInput(t,e)}_memSetOutputData(t){let e=this._output[t];this._memRemoveRefOutput(t),this._memAddDataOutput(t,e)}_memSetPinRef(t,e){t==="input"?this._memSetInputRef(e):this._memSetOutputRef(e)}_memSetInputRef(t){let e=this._input[t];this._memRemoveDataInput(t),this._memAddRefInput(t,e)}_memSetOutputRef(t){let e=this._output[t];this._memRemoveDataOutput(t),this._memAddRefOutput(t,e)}setPinRef(t,e,i){if(i){if(this.hasRefPinNamed(t,e))return;this._memSetPinRef(t,e)}else{if(this.hasPinNamed(t,e))return;this._memSetPinOptData(t,e)}}setInputRef(t,e){this.setPinRef("input",t,e)}setOutputRef(t,e){this.setPinRef("output",t,e)}setInputIgnored(t,e){let i=this.getInput(t);if(!this.hasRefInputNamed(t))return i.ignored(e)}setOutputIgnored(t,e){return this.getOutput(t).ignored(e)}setInputs(t,e={}){for(let i in t){let o=t[i],a=e[i];this.setInput(i,o,a)}}setPin(t,e,i,o=$e,a=!0){t==="input"?this.setInput(e,i,o,a):this.setOutput(e,i,o,a)}setInput(t,e,i=$e,o=!0){this._setInput(t,e,i),this.emit("set_input",t,e,i,o)}_setInput(t,e,i=$e){this.hasInputNamed(t)&&this.removeInput(t),this._i_count++,this._i_name_set.add(t),this._input[t]=e,this._i_opt[t]=i;let{ref:o}=i;o?this._memAddRefInput(t,e):this._memAddDataInput(t,e)}_memAddDataInput(t,e){this._d_i_count++,this._d_i_name.add(t),this._data_input[t]=e}_memAddRefInput(t,e){this._r_i_count++,this._r_i_name.add(t),this._ref_input[t]=e}_validateInputName(t){if(typeof t=="string"){if(!this.hasInputNamed(t))throw new Re(t)}else throw new _n("name should be a string")}_validateOutputName(t){if(typeof t=="string"){if(!this.hasOutputNamed(t))throw new xn(t)}else throw new _n("name should be a string")}addPin(t,e,i,o){t==="input"?this.addInput(e,i,o):this.addOutput(e,i,o)}addInput(t,e,i=$e){if(this.hasInputNamed(t))throw new Ju(t);this.setInput(t,e,i)}removeInput(t){if(!this.hasInputNamed(t))throw new Re(t);let e=this._input[t];this.emit("before_remove_input",t,e),this._i_count--,this._i_name_set.delete(t),delete this._input[t];let i=this._i_opt[t],{ref:o}=i;o?this._memRemoveRefInput(t):this._memRemoveDataInput(t),this.emit("remove_input",t,e)}setOutputs(t,e={}){for(let i in t){let o=t[i],a=e[i];this.setOutput(i,o,a)}}setOutput(t,e,i=$e,o=!0){this._setOutput(t,e,i),this.emit("set_output",t,e,i,o)}_setOutput(t,e,i=$e){this.hasOutputNamed(t)&&this.removeOutput(t),t===lt&&(this._selfOutput=e),this._o_count++,this._o_name_set.add(t),this._o_opt[t]=i;let{ref:o}=i;o?this._memAddRefOutput(t,e):this._memAddDataOutput(t,e),this._output[t]=e}addOutput(t,e,i=$e){if(this.hasOutputNamed(t))throw new Xu(t);this.setOutput(t,e,i)}removeOutput(t){if(!this.hasOutputNamed(t))throw new xn(t);let e=this._output[t];this.emit("before_remove_output",t,e),this._o_count--,this._o_name_set.delete(t);let i=this._o_opt[t],{ref:o}=i;o?this._memRemoveRefOutput(t):this._memRemoveDataOutput(t),delete this._output[t],this.emit("remove_output",t,e)}removePin(t,e){t==="input"?this.removeInput(e):this.removeOutput(e)}getPin(t,e){return t==="input"?this.getInput(e):this.getOutput(e)}getInputs(){return this._input}getDataInputs(){return this._data_input}getRefInputs(){return this._ref_input}getInput(t){return t===lt?this._selfInput:(this._validateInputName(t),this._input[t])}getOutputs(){return this._output}getDataOutputs(){return this._data_output}getRefOutputs(){return this._ref_output}getOutput(t){return t===lt?this._selfOutput:(this._validateOutputName(t),this._output[t])}push(t,e){this.pushInput(t,e)}pushInput(t,e){this._validateInputName(t),this.getInput(t).push(e)}pushAllInput(t){A(t,(e,i)=>this.pushInput(i,e))}pushOutput(t,e){this.getOutput(t).push(e)}pushAllOutput(t){A(t,(e,i)=>this.pushOutput(i,e))}pushAll(t){this.pushAllInput(t)}pullInput(t){return this.getInput(t).pull()}pullOutput(t){return this.getOutput(t).pull()}pullPin(t,e){return t==="input"?this.pullInput(e):this.pullOutput(e)}takePin(t,e){return t==="input"?this.takeInput(e):this.takeOutput(e)}takeInput(t){return this._validateInputName(t),this.getInput(t).take()}takeOutput(t){return this.getOutput(t).take()}take(t){return this.takeOutput(t)}takeAll(){return vt(this._output,t=>t.take())}peakInput(t){return this.getInput(t).peak()}peakOutput(t){return this.getOutput(t).peak()}peak(t){return this.peakOutput(t)}peakAllOutput(){return vt(this._output,t=>t.peak())}peakAll(){return this.peakAllOutput()}hasPinNamed(t,e){return t==="input"?this.hasInputNamed(e):this.hasOutputNamed(e)}hasInputNamed(t){return this._input[t]!==void 0}hasOutputNamed(t){return this._output[t]!==void 0}hasDataPinNamed(t,e){return t==="input"?this.hasDataInputNamed(e):this.hasDataOutputNamed(e)}hasDataInputNamed(t){return this._d_i_name.has(t)}hasDataOutputNamed(t){return this._d_o_name.has(t)}hasRefPinNamed(t,e){return t==="input"?this.hasRefInputNamed(e):this.hasRefOutputNamed(e)}hasRefInputNamed(t){return this._r_i_name.has(t)}renamePin(t,e,i){t==="input"?this.renameInput(e,i):this.renameOutput(e,i)}renameInput(t,e,i=!0){if(!this.hasInputNamed(t))throw new Re(t);let o=this._input[t],a=this._i_opt[t];this._i_name_set.delete(t),this._i_name_set.add(e),delete this._input[t],delete this._i_opt[t],this._input[e]=o,this._i_opt[e]=a;let{ref:s}=a;s?(this._r_i_name.delete(t),this._r_i_name.add(e),delete this._ref_input[t],this._ref_input[e]=o):(this._d_i_name.delete(t),this._d_i_name.add(e),delete this._data_input[t],this._data_input[e]=o),this.emit("rename_input",t,e)}renameOutput(t,e,i=!0){if(!this.hasOutputNamed(t))throw new Re(t);let o=this._output[t],a=this._o_opt[t];this._o_name_set.delete(t),this._o_name_set.add(e),delete this._output[t],this._output[e]=o,delete this._o_opt[t],this._o_opt[e]=a;let{ref:s}=a;s?(this._r_o_name.delete(t),this._r_o_name.add(e),delete this._ref_output[t],this._ref_output[e]=o):(this._d_o_name.delete(t),this._d_o_name.add(e),delete this._data_output[t],this._data_output[e]=o),this.emit("rename_output",t,e)}getInputOpt(t){return this._i_opt[t]}getOutputOpt(t){return this._o_opt[t]}hasRefOutputNamed(t){return this._r_o_name.has(t)}getInputCount(){return this._i_count}getOutputCount(){return this._o_count}getInputNames(){return et(this._input)}getOutputNames(){return et(this._output)}setPinData(t,e,i){this.getPin(t,e).push(i)}removePinData(t,e){this.getPin(t,e).take()}setInputConstant(t,e){this.getInput(t).constant(e)}setOutputConstant(t,e){this.getOutput(t).constant(e)}getCatchErr(){return this._catchErr}caughtErr(){return this._caughtErr}catch(t){jt(this._catcherCallback,t),jt(this._catcherDone,!1),this._catchErr=!0;let e=this._err;e&&(this._err=null,this._caughtErr=e,this.emit("catch_err",e));let i=()=>{this._catcherDoneCount===this._catcherCallback.length&&o()},o=()=>{let p=this._caughtErr;this._caughtErr=null,this._catcherDoneCount=0,this._catcherDone.fill(!1),this.emit("take_caught_err",p)};return{unlisten:()=>{let p=this._catcherCallback.indexOf(t);if(p>-1){Ye(this._catcherCallback,t);let d=this._catcherDone[p];if(kt(this._catcherDone,p),this._catcherCallback.length===0){let c=this._caughtErr;this._catchErr=!1,c!==null&&(this._caughtErr=null,this.err(c),this.emit("take_caught_err",c))}d||i()}else throw new Error("unregistered Catcher cannot call unlisten")},done:()=>{if(this._caughtErr){let p=this._catcherCallback.indexOf(t);if(p>-1){if(this._catcherDone[p])throw new Error("catcher cannot be done twice");this._catcherDone[p]=!0,this._catcherDoneCount++,i()}else throw new Error("unregistered Catcher cannot call done")}else throw new Error("catcher cannot call done when there's no caught error")}}}getConfig(){return this._opt}reset(){this.takeErr(),this.emit("reset")}pause(){this._paused||(this._paused=!0,this.emit("pause"))}play(){this._paused&&(this._paused=!1,this.emit("play"))}paused(){return this._paused}getSelfPin(){return this._selfOutput}err(t){if(t)if(t instanceof Error&&(t=t.message),this._catchErr){this._caughtErr=t;for(let e of this._catcherCallback)e(t)}else this._err=t,this.emit("err",t);return this._err}hasErr(){return this._err!==null}getErr(){return this._err}takeErr(){let t=this._err;return t&&(this._err=null,this.emit("take_err",t)),t}takeCaughtErr(){let t=this._caughtErr;if(t){this._caughtErr=null;for(let e of this._catcherCallback)e(null);this.emit("take_caught_err",t)}return t}destroy(){this.__system.unregisterUnit(this.id),super.destroy()}getPinData(t,e){return this.getPin(t,e).peak()}getPinsData(){let t={input:{},output:{}};return A(this._input,(e,i)=>{t.input[i]=e.peak()}),A(this._output,(e,i)=>{t.output[i]=e.peak()}),t}getInputData(){let t={};return A(this._input,(e,i)=>{if(!e.empty()){let o=e.peak();t[i]=o}}),t}getRefInputData(){let t={};return A(this._ref_input,(e,i)=>{if(!e.empty()){let o=e.peak();t[i]=o}}),t}getSpec(){return this.__system.getSpec(this.id)}getUnitBundleSpec(t=!1){let e;t&&(e=this.snapshot(),ke(e));let i=vt(this._input,a=>{let s=a.ignored(),p=a.constant(),d=a.peak(),c=p&&d!==void 0?Y(d):void 0;return{ignored:s,constant:p,data:c}}),o=vt(this._output,a=>{let s=a.ignored(),p=a.constant();return{ignored:s,constant:p,data:void 0}});return{unit:{id:this.id,memory:e,input:i,output:o},specs:{}}}snapshotSelf(){}snapshotInput(t){return this.getInput(t).snapshot()}snapshotInputs(){let t={};for(let e of this._d_i_name)t[e]=this.snapshotInput(e);return t}snapshotOutput(t){return this.getOutput(t).snapshot()}snapshotOutputs(){let t={};for(let e of this._d_o_name)t[e]=this.snapshotOutput(e);return t}snapshot(){return{input:this.snapshotInputs(),output:this.snapshotOutputs(),memory:this.snapshotSelf()}}restoreSelf(t){}restoreInputs(t){for(let e in t){let i=t[e];this.restoreInput(e,i)}}restoreInput(t,e){this.getInput(t).restore(e)}restoreOutputs(t){for(let e in t){let i=t[e];this.restoreOutput(e,i)}}restoreOutput(t,e){this.getOutput(t).restore(e)}restore(t){let{input:e,output:i,memory:o}=t;this.restoreInputs(e),this.restoreOutputs(i),this.restoreSelf(o!=null?o:{})}};var Q=class extends yt{constructor({i:t,o:e}={},i={},o,a){super({i:t,o:e},i,o,a);this._i={};this._o={};this._active_i_count=0;this._active_o_count=0;this._i_start_count=0;this._i_start={};this._o_invalid_count=0;this._o_invalid={};this._i_invalid_count=0;this._i_invalid={};this._forwarding=!1;this._backwarding=!1;this._forwarding_empty=!1;this._inputUnlisten={};this._outputUnlisten={};this.__buffer=[];this._setupInputs=t=>{for(let e in t){let i=t[e],o=this.getInputOpt(e);this._setupInput(e,i,o)}};this._setupDataInput=(t,e)=>{let i=this._onDataInputData.bind(this,t),o=this._onDataInputDrop.bind(this,t),a=this._onDataInputInvalid.bind(this,t),s=this._onInputStart.bind(this,t),p=this._onInputEnd.bind(this,t);e.addListener("_data",i),e.addListener("data",i),e.addListener("start",s),e.addListener("invalid",a),e.prependListener("drop",o),e.prependListener("end",p);let d=()=>{e.removeListener("data",i),e.removeListener("start",s),e.removeListener("invalid",a),e.removeListener("drop",o),e.removeListener("end",p)};this._inputUnlisten[t]=d};this._setupRefInput=(t,e)=>{let i=this._onRefInputData.bind(this,t),o=this._onRefInputDrop.bind(this,t),a=this._onRefInputInvalid.bind(this,t);e.addListener("data",i),e.addListener("invalid",a),e.prependListener("drop",o);let s=()=>{e.removeListener("data",i),e.removeListener("invalid",a),e.removeListener("drop",o)};this._inputUnlisten[t]=s};this._setupInput=(t,e,i)=>{let{ref:o}=i;o?this._setupRefInput(t,e):this._setupDataInput(t,e)};this._setupOutputs=t=>{for(let e in t){let i=t[e],o=this.getOutputOpt(e);this._setupOutput(e,i,o)}};this.__setupOutput=(t,e)=>{let i=this._onDataOutputData.bind(this,t),o=this._onDataOutputDrop.bind(this,t),a=this._onOutputInvalid.bind(this,t);e.addListener("drop",o),e.prependListener("data",i),e.prependListener("invalid",a);let s=()=>{e.removeListener("data",i),e.removeListener("drop",o),e.removeListener("invalid",a)};this._outputUnlisten[t]=s};this._setupDataOutput=(t,e)=>{if(this.__setupOutput(t,e),e.active()){let i=e.peak();this._onDataOutputData(t,i)}};this._setupRefOutput=(t,e)=>{if(this.__setupOutput(t,e),e.active()){let i=e.peak();this._onRefOutputData(t,i)}};this._setupOutput=(t,e,i)=>{let{ref:o}=i;o?this._setupRefOutput(t,e):this._setupDataOutput(t,e)};this._onDataInputData=(t,e)=>{this._activateInput(t,e),this._paused?this.__buffer.push({name:t,type:"input",event:"data",data:e,ref:!1}):this.onDataInputData(t,e)};this._input_effemeral={};this._onRefInputData=(t,e)=>{this._activateInput(t,e),this._paused?this.__buffer.push({name:t,type:"input",event:"data",data:e,ref:!0}):this.__onRefInputData(t,e)};this.__onRefInputData=(t,e)=>{e instanceof Function&&(e=new e(this.__system),this._input_effemeral[t]=e,this._i[t]=e),e instanceof C&&e.register(),this.onRefInputData(t,e)};this._activateInput=(t,e)=>{this._i[t]===void 0&&this._active_i_count++,this._i[t]=e,this._i_invalid[t]&&(delete this._i_invalid[t],this._i_invalid_count--)};this._deactivateInput=t=>{this._i[t]!==void 0&&(delete this._i[t],this._active_i_count--),this._i_invalid[t]&&(delete this._i_invalid[t],this._i_invalid_count--),this._i_start[t]&&(delete this._i_start[t],this._i_start_count--)};this._onDataInputDrop=(t,e)=>{this._deactivateInput(t),this._paused?this.__buffer.push({name:t,type:"input",event:"drop",ref:!1}):this.onDataInputDrop(t,e)};this._onRefInputDrop=(t,e)=>{this._deactivateInput(t),this._paused?this.__buffer.push({name:t,type:"input",event:"drop",ref:!0}):this.__onRefInputDrop(t,e)};this.__onRefInputDrop=(t,e)=>{if(this._input_effemeral[t]){let i=this._input_effemeral[t];delete this._input_effemeral[t],i.destroy()}this.onRefInputDrop(t,e)};this._onRefInputInvalid=t=>{this._i_invalid[t]||(this._i_invalid[t]=!0,this._i_invalid_count++),this.onRefInputInvalid(t)};this._activateOutput=t=>{this._o[t]===void 0&&this._active_o_count++,this._o_invalid[t]&&(delete this._o_invalid[t],this._o_invalid_count--)};this._deactivateOutput=t=>{this._o[t]!==void 0&&(this._active_o_count--,delete this._o[t]),this._o_invalid[t]&&(delete this._o_invalid[t],this._o_invalid_count--)};this.__onOutputData=(t,e)=>{this._activateOutput(t),this._o[t]=e};this._onDataOutputData=(t,e)=>{this.__onOutputData(t,e),this.onDataOutputData(t,e)};this._onRefOutputData=(t,e)=>{this.__onOutputData(t,e),this.onRefOutputData(t,e)};this._onDataOutputDrop=t=>{this._deactivateOutput(t),this._paused?this.__buffer.push({name:t,type:"output",event:"drop",ref:!1}):this.onDataOutputDrop(t)};this._onRefOutputDrop=t=>{this._deactivateOutput(t),this._paused?this.__buffer.push({name:t,type:"output",event:"drop",ref:!0}):this.onRefOutputDrop(t)};this._onOutputInvalid=t=>{this._o_invalid[t]||(this._o_invalid[t]=!0,this._o_invalid_count++),this.onOutputInvalid(t)};this._setupInputs(this._input),this._setupOutputs(this._output),this.addListener("set_input",this._onInputSet),this.addListener("set_output",this._onOutputSet),this.addListener("remove_input",this._onInputRemoved),this.addListener("remove_output",this._onOutputRemoved),this.addListener("rename_input",this._onInputRenamed),this.addListener("rename_output",this._onOutputRenamed),this.addListener("destroy",()=>{A(this._input,(s,p)=>{this._plunkInput(p,s)}),A(this._output,(s,p)=>{this._plunkOutput(p,s)})}),this.addListener("reset",()=>{this._backwarding=!1,this._forwarding=!1,this._forwarding_empty=!1}),this.addListener("play",()=>{for(;this.__buffer.length>0;){let{name:s,type:p,event:d,data:c}=this.__buffer.shift();if(p==="input"){let{ref:m}=this.getInputOpt(s);d==="data"?m?this.__onRefInputData(s,c):this.onDataInputData(s,c):m?this.__onRefInputDrop(s,c):this.onDataInputDrop(s,c)}else d==="drop"&&this.onDataOutputDrop(s)}})}getActiveInputCount(){return this._active_i_count}getActiveOutputCount(){return this._active_o_count}getOutputData(){return this._o}_plunkOutput(t,e){let i=this._outputUnlisten[t];i&&i(),delete this._outputUnlisten[t]}_plunkInput(t,e){let i=this._inputUnlisten[t];i&&i(),delete this._inputUnlisten[t]}_onInputSet(t,e,i,o){this._setupInput(t,e,i),this.onInputSet(t,e,i,o)}onInputSet(t,e,i,o){if(!e.empty()){let a=e.peak();this._activateInput(t,a),o&&(this._onInputStart(t),this.hasRefInputNamed(t)?this._onRefInputData(t,a):this._onDataInputData(t,a))}}_onOutputSet(t,e,i,o){this._setupOutput(t,e,i),this.onOutputSet(t,e,i,o)}onOutputSet(t,e,i,o){}_onInputRemoved(t,e){this._plunkInput(t,e),e.active()&&this._deactivateInput(t),this.onInputRemoved(t,e)}onInputRemoved(t,e){}_onOutputRemoved(t,e){this._plunkOutput(t,e),e.empty()||this._deactivateOutput(t),this.onOutputRemoved(t,e)}onOutputRemoved(t,e){e.empty()||this._onDataOutputDrop(t)}onDataInputData(t,e){}onRefInputData(t,e){}_onInputRenamed(t,e){let i=this.getInput(e),o=this.getInputOpt(e);this._plunkInput(t,i),this._setupInput(e,i,o),this.onInputRenamed(t,e,o,o)}_onOutputRenamed(t,e){let i=this._o[t]!==void 0,o=this.getOutput(e),a=this.getOutputOpt(e);this._plunkOutput(t,o),this._setupOutput(e,o,a),i&&this._active_o_count--,this.onOutputRenamed(t,e,a,a)}onInputRenamed(t,e,i,o){}onOutputRenamed(t,e,i,o){}onDataInputDrop(t,e){}onRefInputDrop(t,e){}onDataOutputData(t,e){}onDataOutputDrop(t){}onRefOutputData(t,e){}onRefOutputDrop(t){}onOutputInvalid(t){}_onInputEnd(t){this._i_start[t]&&(this._i_start[t]=!1,this._i_start_count--),this.onDataInputEnd(t)}onDataInputEnd(t){}_onInputStart(t){this._i_start[t]||(this._i_start[t]=!0,this._i_start_count++),this.onDataInputStart(t)}onDataInputStart(t){}_onDataInputInvalid(t){this._i_invalid[t]||(this._i_invalid[t]=!0,this._i_invalid_count++),this.onDataInputInvalid(t)}_start(){A(this._output,t=>t.start())}_invalidate(){A(this._output,t=>t.invalidate())}_end(){A(this._output,t=>t.end())}_forward(t,e){let i=this._output[t];this._forward_(i,e)}_forward_(t,e){this._forwarding=!0,t.push(e),this._forwarding=!1}_forward_all_empty(){this._forwarding_empty=!0,A(this._output,t=>t.take()),this._forwarding_empty=!1}_forward_empty(t){this._forwarding_empty=!0,this._output[t].take(),this._forwarding_empty=!1}_backward_all(){this._backwarding=!0,A(this._data_input,t=>t.pull()),this._backwarding=!1}_backward(t){this._backwarding=!0,this._input[t].pull(),this._backwarding=!1}onDataInputInvalid(t){}onRefInputInvalid(t){}snapshotSelf(){return Z(_({},super.snapshotSelf()),{_forwarding:this._forwarding,_backwarding:this._backwarding,_forwarding_empty:this._forwarding_empty})}restoreSelf(t){let p=t,{__buffer:e,_forwarding:i,_backwarding:o,_forwarding_empty:a}=p,s=bt(p,["__buffer","_forwarding","_backwarding","_forwarding_empty"]);super.restoreSelf(s),this._forwarding=i,this._backwarding=o,this._forwarding_empty=a,this._i={},this._o={},this._active_i_count=0,this._active_o_count=0,this._i_start_count=0,this._i_start={},this._o_invalid_count=0,this._o_invalid={},this._i_invalid_count=0,this._i_invalid={};for(let d in this._input){let c=this._input[d],m=c.peak();this._i[d]=m,m!==void 0&&(this._active_i_count++,this._i_start_count++,this._i_start[d]=!0,c.invalid()&&(this._i_invalid_count++,this._i_invalid[d]=!0))}for(let d in this._output){let c=this._output[d],m=c.peak();this._o[d]=m,m!==void 0&&(this._active_o_count++,c.invalid()&&(this._o_invalid_count++,this._o_invalid[d]=!0))}}};var H8="_d2c4b19b-aa58-438b-8541-9df478b80aa3",Wt=class extends Q{constructor(t){super({},{},t,H8);this._current=void 0;this._loop_invalid_o_count=0;this._loop_invalid_o=new Set;this._reset=()=>{this._current=void 0};this._play=()=>{this._forward_if_ready()};this.addListener("reset",this._reset),this.addListener("play",this._play),this.play()}onInputRemoved(t,e){super.onInputRemoved(t,e),t===this._current&&(this._current=void 0)}onInputRenamed(t,e,i,o){super.onInputRenamed(t,e,i,o),(!this.getInput(e).empty()||t===this._current)&&(this._current=e)}onOutputRenamed(t,e,i,o){super.onOutputRenamed(t,e,i,o)}onInputSet(t,e,i,o){super.onInputSet(t,e,i,o),e.empty()||(this._current=t)}onOutputSet(t,e,i,o){if(super.onOutputSet(t,e,i,o),this._current!==void 0){let a=this._i[this._current];o&&a!==void 0&&(this._forward_(e,a),this._backward_if_ready())}}onOutputRemoved(t){}_on_input_data(t){let e=this._current,i=this._i_invalid[e],o=e!==void 0&&t!==e&&!i;(o||this._active_o_count-this._loop_invalid_o_count>0)&&this._invalidate(),this._current=t,this._forward_if_ready(),o&&this._backward(e)}onDataInputData(t){this._on_input_data(t)}onRefInputData(t){this._on_input_data(t)}onDataInputDrop(t){t===this._current&&(this._current=void 0,!this._backwarding&&this._i_start_count===0&&this._forward_all_valid_empty())}_on_output_drop(t){this._loop_invalid_o.has(t)&&(this._loop_invalid_o.delete(t),this._loop_invalid_o_count--),this._backward_if_ready(),this._forward_if_ready()}onOutputInvalid(t){this._current!==void 0&&!this._forwarding&&(this._loop_invalid_o_count++,this._loop_invalid_o.add(t))}onDataOutputData(t){this._backward_if_ready()}onDataOutputDrop(t){this._on_output_drop(t)}onRefOutputDrop(t){this._on_output_drop(t)}onDataInputStart(t){this._i_start_count===1&&this._start()}onDataInputInvalid(t){t===this._current&&this._invalidate()}onInpuRemoved(t){t===this._current&&(this._current=void 0)}onDataInputEnd(t){this._paused||this._i_start_count===0&&(this._current!==void 0&&this._forward_all_valid_empty(),this._end())}_forward_all_valid_empty(){this._forwarding_empty=!0,A(this._output,(t,e)=>(!this._loop_invalid_o.has(e)||this._o_invalid[e])&&t.take()),this._forwarding_empty=!1,this._loop_invalid_o_count=0,this._loop_invalid_o=new Set}_forward_if_ready(){!this._backwarding&&!this._forwarding&&this._active_o_count-this._o_invalid_count===0&&this._o_count>0&&this._current!==void 0&&!this._i_invalid[this._current]&&(this._loop_invalid_o_count=0,this._loop_invalid_o=new Set,this._run())}_backward_if_ready(){!this._forwarding&&this._current!==void 0&&this._active_o_count-this._loop_invalid_o_count===0&&(this._loop_invalid_o_count=0,this._loop_invalid_o=new Set,this._backward(this._current),this._forward_if_ready())}_run(){let t=this._i[this._current],e=ce(this._output,o=>o.empty()),i=ce(this._output,o=>!o.empty());this._forwarding=!0,A(e,o=>o.push(t)),A(i,o=>o.push(t)),this._forwarding=!1,this._backward_if_ready()}snapshotSelf(){return Z(_({},super.snapshotSelf()),{_current:De(this._current)?this._current:void 0,_loop_invalided_o_count:this._loop_invalid_o_count})}restoreSelf(t){let a=t,{_current:e,_loop_invalided_o_count:i}=a,o=bt(a,["_current","_loop_invalided_o_count"]);super.restoreSelf(o),this._current=e,this._loop_invalid_o_count=i}getData(){if(this._current)return this._i[this._current]}};function qd(r,n,t={},e){let{inputs:i,outputs:o,id:a}=r;class s extends yt{constructor(c){super({i:et(i),o:et(o)},t,c,r.id);this.__=["U","G"];this.__element=!1;this._merge={input:{},output:{}};this.getSpec=()=>(this._ensure(),this.__graph.getSpec());this.getUnits=()=>(this._ensure(),this.__graph.getUnits());this.exposeOutputSets=c=>(this._ensure(),this.__graph.exposeOutputSets(c));this.exposeOutputSet=(c,m)=>(this._ensure(),this.__graph.exposePinSet("output",m,c));this.exposeOutput=(c,m,f)=>(this._ensure(),this.__graph.exposeOutput(c,m,f));this.coverOutputSet=c=>{this._ensure(),this.__graph.coverOutputSet(c)};this.coverOutput=(c,m)=>(this._ensure(),this.__graph.coverOutput(c,m));this.plugOutput=(c,m,f)=>(this._ensure(),this.__graph.plugOutput(c,m,f));this.unplugOutput=(c,m)=>(this._ensure(),this.__graph.unplugOutput(c,m));this.exposeInputSets=c=>(this._ensure(),this.__graph.exposeInputSets(c));this.exposeInputSet=(c,m)=>(this._ensure(),this.__graph.exposeInputSet(c,m));this.exposePinSet=(c,m,f)=>(this._ensure(),this.__graph.exposePinSet(c,m,f));this.exposePin=(c,m,f,g)=>(this._ensure(),this.__graph.exposePin(c,m,f,g));this.exposeInput=(c,m,f)=>(this._ensure(),this.__graph.exposeInput(c,m,f));this.coverInputSet=c=>(this._ensure(),this.__graph.coverInputSet(c));this.coverInput=(c,m)=>(this._ensure(),this.__graph.coverInput(c,m));this.coverPinSet=(c,m,f=!0)=>(this._ensure(),this.__graph.coverPinSet(c,m,f));this.plugPin=(c,m,f,g)=>(this._ensure(),this.plugPin(c,m,f,g));this.plugInput=(c,m,f)=>(this._ensure(),this.plugInput(c,m,f));this.unplugInput=(c,m)=>(this._ensure(),this.unplugInput(c,m));this.coverPin=(c,m,f)=>(this._ensure(),this.__graph.coverPin(c,m,f));this.getSubPinSpec=(c,m,f)=>(this._ensure(),this.__graph.getSubPinSpec(c,m,f));this.unplugPin=(c,m,f)=>(this._ensure(),this.__graph.unplugPin(c,m,f));this.getExposedInputPin=c=>(this._ensure(),this.__graph.getExposedInputPin(c));this.getExposedOutputPin=c=>(this._ensure(),this.__graph.getExposedOutputPin(c));this.getGraphPinData=()=>(this._ensure(),this.__graph.getGraphPinData());this.getGraphErr=()=>(this._ensure(),this.__graph.getGraphErr());this.getUnitInputData=c=>(this._ensure(),this.__graph.getUnitInputData(c));this.addUnits=c=>(this._ensure(),this.__graph.addUnitSpecs(c));this.addUnit=(c,m)=>(this._ensure(),this.__graph.addUnit(c,m));this.addMerges=c=>(this._ensure(),this.__graph.addMerges(c));this.addMerge=(c,m)=>(this._ensure(),this.__graph.addMerge(c,m));this.addPinToMerge=(c,m,f,g)=>(this._ensure(),this.__graph.addPinToMerge(c,m,f,g));for(let m in this._input)this._input[m].addListener("data",g=>{this._ensure()});this.addListener("play",()=>{this.__graph&&this.__graph.play()}),this.addListener("pause",()=>{this.__graph&&this.__graph.pause()}),this.addListener("take_err",()=>{this.__graph.takeErr()}),this.addListener("reset",()=>{this.__graph&&this.__graph.reset()})}stopPropagation(c){return this._ensure(),this.__graph.stopPropagation(c)}getSetup(){return this._ensure(),this.__graph.getSetup()}setUnitPinSetId(c,m,f,g,...h){return this._ensure(),this.__graph.setUnitPinSetId(c,m,f,g,...h)}fork(){return this._ensure(),this.__graph.fork()}startTransaction(){return this._ensure(),this.__graph.startTransaction()}endTransaction(){return this._ensure(),this.__graph.endTransaction()}getMergeData(c){return this._ensure(),this.__graph.getPlugSpecs()}getPlugSpecs(){return this._ensure(),this.__graph.getPlugSpecs()}hasMergePin(c,m,f,g){return this._ensure(),this.__graph.hasMergePin(c,m,f,g)}getMergesSpec(){return this._ensure(),this.__graph.getMergesSpec()}getUnitPinData(c,m,f){return this._ensure(),this.__graph.getUnitPinData(c,m,f)}isUnitPinConstant(c,m,f){return this._ensure(),this.__graph.isUnitPinConstant(c,m,f)}isUnitPinRef(c,m,f){return this._ensure(),this.__graph.isUnitPinRef(c,m,f)}getExposedPinSpecs(){return this._ensure(),this.__graph.getExposedPinSpecs()}getPinPlugCount(c,m){return this._ensure(),this.__graph.getPinPlugCount(c,m)}moveRoot(c,m,f,g){return this._ensure(),this.__graph.moveRoot(c,m,f,g)}hasPlug(c,m,f){return this._ensure(),this.__graph.hasPlug(c,m,f)}removePinOrMerge(c,m,f,g,...h){return this._ensure(),this.__graph.removePinOrMerge(c,m,f,g,...h)}removeMergeData(c){return this._ensure(),this.__graph.removeMergeData(c)}setUnitSize(c,m,f){return this._ensure(),this.__graph.setUnitSize(c,m,f)}setSubComponentSize(c,m,f){return this._ensure(),this.__graph.setSubComponentSize(c,m,f)}setComponentSize(c,m,f){return this._ensure(),this.__graph.setComponentSize(c,m,f)}moveSubgraphOutOf(...[c,m,f,g,h,x,y,I,v,T]){return this._ensure(),this.__graph.moveSubgraphOutOf(c,m,f,g,h,x,y,I,v,T)}removeUnitPinData(c,m,f){return this._ensure(),this.__graph.removeUnitPinData(c,m,f)}addUnitSpecs(c){return this._ensure(),this.__graph.addUnitSpecs(c)}addUnitSpec(c,m,f){return this._ensure(),this.__graph.addUnitSpec(c,m)}bulkEdit(c){return this._ensure(),this.__graph.bulkEdit(c)}setUnitId(c,m,f,g){return this._ensure(),this.__graph.setUnitId(c,m,f,g)}isElement(){return kf(r)}getMergeSpec(c){return this._ensure(),this.__graph.getMergeSpec(c)}reorderRoot(c,m){return this._ensure(),this.__graph.reorderRoot(c,m)}reorderParentRoot(c,m){return this._ensure(),this.__graph.reorderParentRoot(c,m)}reorderSubComponent(c,m,f){return this._ensure(),this.__graph.reorderSubComponent(c,m,f)}moveSubComponentRoot(c,m,f){return this._ensure(),this.__graph.moveSubComponentRoot(c,m,f)}appendParentChild(c,m){return this._ensure(),this.__graph.appendParentChild(c,m)}removeParentChild(c){return this._ensure(),this.__graph.removeParentChild(c)}removeRoot(c){return this._ensure(),this.__graph.removeRoot(c)}detach(){return this._ensure(),this.__graph.detach()}moveSubgraphInto(...[c,m,f,g,h,x,y,I,v,T]){return this._ensure(),this.__graph.moveSubgraphInto(c,m,f,g,h,x,y,I,v,T)}registerRoot(c){return this._ensure(),this.__graph.registerRoot(c)}unregisterRoot(c){return this._ensure(),this.__graph.unregisterRoot(c)}registerParentRoot(c,m){return this._ensure(),this.__graph.registerParentRoot(c,m)}unregisterParentRoot(c){return this._ensure(),this.__graph.unregisterParentRoot(c)}_load(){let c=e(r,n,this.__system.classes,t);this.__graph=new c(this.__system),this.__graph.addListener("err",m=>{this.err(m)}),this.__graph.addListener("take_err",()=>{this.takeErr()}),A(this.__graph.getOutputs(),(m,f)=>{let g=new Wt(this.__system);g.play(),this._merge.output[f]=g,g.setInput(f,m),g.setOutput(f,this._output[f])}),A(this.__graph.getInputs(),(m,f)=>{let g=new Wt(this.__system);g.play(),this._merge.input[f]=g,g.setInput(f,this._input[f]),g.setOutput(f,m)}),this.__graph.play()}_ensure(){this.__graph||this._load()}getBundleSpec(){return this._ensure(),this.__graph.getBundleSpec()}getUnitState(c){return this._ensure(),this.__graph.getUnitState(c)}getGraphState(){return this._ensure(),this.__graph.getGraphState()}getGraphChildren(){return this._ensure(),this.__graph.getGraphChildren()}pushChild(c){return this._ensure(),this.__graph.pushChild(c)}appendChild(c){return this._ensure(),this.__graph.appendChild(c)}insertChild(c,m){return this._ensure(),this.__graph.insertChild(c,m)}pullChild(c){return this._ensure(),this.__graph.pullChild(c)}removeChild(c){return this._ensure(),this.__graph.removeChild(c)}hasChild(c){return this._ensure(),this.__graph.hasChild(c)}refChild(c){return this._ensure(),this.__graph.refChild(c)}refChildren(){return this._ensure(),this.__graph.refChildren()}refSlot(c){return this._ensure(),this.__graph.refSlot(c)}animate(c,m){return this._ensure(),this.__graph.animate(c,m)}cancelAnimation(c){return this._ensure(),this.__graph.cancelAnimation(c)}getAnimations(){return this._ensure(),this.__graph.getAnimations()}isExposedOutput(c){return this._ensure(),this.__graph.isExposedOutput(c)}setPinSetId(c,m,f){return this._ensure(),this.__graph.setPinSetId(c,m,f)}setPinSetFunctional(c,m,f){return this._ensure(),this.__graph.setPinSetFunctional(c,m,f)}isExposedInput(c){return this._ensure(),this.__graph.isExposedInput(c)}getExposedPinSpec(c,m){return this._ensure(),this.__graph.getExposedPinSpec(m,c)}isExposedInputPinId(c){return this._ensure(),this.__graph.isExposedInputPinId(c)}isExposedOutputPinId(c){return this._ensure(),this.__graph.isExposedOutputPinId(c)}getExposedInputSpec(c){return this._ensure(),this.__graph.getExposedInputSpec(c)}getExposedOutputSpec(c){return this._ensure(),this.__graph.getExposedOutputSpec(c)}hasUnit(c){return this._ensure(),this.__graph.hasUnit(c)}hasMerge(c){return this._ensure(),this.__graph.hasMerge(c)}getGraphUnitSpec(c){return this._ensure(),this.__graph.getGraphUnitSpec(c)}getUnit(c){return this._ensure(),this.__graph.getUnit(c)}getUnitByPath(c){return this._ensure(),this.__graph.getUnitByPath(c)}getUnitPin(c,m,f){return this._ensure(),this.__graph.getUnitPin(c,m,f)}getUnitData(c,m,f){return this._ensure(),this.__graph.getUnitData(c,m,f)}getUnitInput(c,m){return this._ensure(),this.__graph.getUnitInput(c,m)}getUnitOutput(c,m){return this._ensure(),this.__graph.getUnitOutput(c,m)}setUnitErr(c,m){return this._ensure(),this.__graph.setUnitErr(c,m)}takeUnitErr(c){return this._ensure(),this.__graph.takeUnitErr(c)}getMerges(){return this._ensure(),this.__graph.getMerges()}getMerge(c){return this._ensure(),this.__graph.getMerge(c)}getMergeCount(){return this._ensure(),this.__graph.getMergeCount()}getMergeUnitCount(c){return this._ensure(),this.__graph.getMergeUnitCount(c)}getMergePinCount(c){return this._ensure(),this.__graph.getMergePinCount(c)}moveUnit(c,m,f){return this._ensure(),this.__graph.moveUnit(c,m,f)}removeUnit(c,...m){return this._ensure(),this.__graph.removeUnit(c,...m)}addUnitGhost(c,m,f,g){return this._ensure(),this.__graph.addUnitGhost(c,m,f,g)}removeUnitGhost(c,m,f){return this._ensure(),this.__graph.removeUnitGhost(c,m,f)}swapUnitGhost(c,m,f){this._ensure(),this.__graph.swapUnitGhost(c,m,f)}explodeUnit(c,m,f,g){return this._ensure(),this.__graph.explodeUnit(c,m,f,g)}removeMerge(c){return this._ensure(),this.__graph.removeMerge(c)}removePinFromMerge(c,m,f,g){return this._ensure(),this.__graph.removePinFromMerge(c,m,f,g)}isPinMergedTo(c,m,f,g){return this._ensure(),this.__graph.isPinMergedTo(c,m,f,g)}setUnitPinConstant(c,m,f,g){return this._ensure(),this.__graph.setUnitPinConstant(c,m,f,g)}setUnitInputConstant(c,m,f){return this._ensure(),this.__graph.setUnitInputConstant(c,m,f)}setUnitOutputConstant(c,m,f){return this._ensure(),this.__graph.setUnitOutputConstant(c,m,f)}setUnitInputIgnored(c,m,f){return this._ensure(),this.__graph.setUnitPinIgnored(c,"input",m,f)}setUnitOutputIgnored(c,m,f){return this._ensure(),this.__graph.setUnitPinIgnored(c,"output",m,f)}setUnitPinIgnored(c,m,f,g){return this._ensure(),this.__graph.setUnitPinIgnored(c,m,f,g)}setUnitPinData(c,m,f,g){return this._ensure(),this.__graph.setUnitPinData(c,m,f,g)}setUnitInputData(c,m,f){return this._ensure(),this.__graph.setUnitInputData(c,m,f)}setUnitOutputData(c,m,f){return this._ensure(),this.__graph.setUnitOutputData(c,m,f)}getGraphMergeInputData(){return this._ensure(),this.__graph.getGraphMergeInputData()}setMetadata(c,m){this._ensure(),this.__graph.setMetadata(c,m)}setGraphState(c){this._ensure(),this.__graph.setGraphState(c)}}return s.__bundle={unit:{id:a},specs:{}},s}var Qe=class extends Error{constructor(){super("Could not find spec")}};function le(r,n,t,e={}){if(!n[r])throw new Qe;let o=Yd(r,n,t,e);return zt(o,{unit:{id:r},specs:{}})}function Yd(r,n,t,e={}){let i=n[r];if(!i)throw new Qe;let o=t[r];return o===void 0&&(i=i,e[r]?o=qd(i,n,e,be):o=Jd(i,n,t,Z(_({},e),{[r]:!0}))),o}function Yf(r,n,t,e,i={}){let o=t[n];if(!o)throw new Qe;let a,s=e[n];if(s===void 0)if(o=o,i[n]){let p=qd(o,t,i,be);a=new p(r,n)}else a=Jf(r,o,t,Z(_({},i),{[n]:!0}));else a=new s(r,n);return a}function vn(r,n,t){let{unit:e,specs:i={}}=r,{id:o}=e,a=Yd(o,ut(i,n),t,{});return zt(a,r)}var O=class extends Error{constructor(){super("method not implemented")}};var V8={B:!0,IB:!0,CA:!0,CC:!0,C:!0,CS:!0,CO:!0,G:!0,GP:!0,M:!0,E:!0,EE:!0,BD:!0,BS:!0,BSE:!0,BC:!0,NO:!0,J:!0,A:!0,PP:!0,PS:!0,CH:!0,MS:!0,S:!0,U:!0,V:!0,TR:!0,RE:!0,F:!0,L:!0,AC:!0,D:!0},tx=Object.keys(V8);function Xd(r,n,t){let e=r.substring(1);return st(e,n,t)}var Xf=/^(true|false)$/;var Zf=/^(?:[$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D])(?:[$0-9A-Z_a-z\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF])*(\?)?$/;var Qf=/^-?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?$/;var z8=",",W8='"',K8="'",el="{",nl="}",il="[",rl="]";function Qd(r){return r.type==="generic"||r.type==="identifier"||r.type==="string literal"||r.type==="boolean literal"||r.type==="number literal"}function Dt(r,n=!1,t=!1){return al(r,n,t,Dt)||q8(r,n,t)||{value:r,type:"invalid",children:[]}}function q8(r,n=!1,t=!1){if(r=r.trim(),!t&&/^\((.*)\)=>\((.*)\)$/.exec(r))return{value:r,type:"class literal",children:[]};let e=/^\((.+)\)$/.exec(r);if(e){let m=[Dt(e[1])];return{value:r,type:"expression",children:m}}if(/^<[^]*>$/.exec(r))return{value:r,type:"generic",children:[]};if(!t){if(/^regex$/.exec(r))return n3;if(/^string$/.exec(r))return Z8;if(/^number$/.exec(r))return t3;if(/^boolean$/.exec(r))return Q8;if(/^object$/.exec(r))return i3;if(/^any$/.exec(r))return e3}let o=/^([^ [\]]+)(\[[^ [\]]+\]+)$/.exec(r);if(o){let m=Dt(o[1]),f=Dt(o[2]);return{value:r,type:"prop expression",children:[m,f]}}let a=/^([^ ]+)\[\]$/.exec(r);if(a){let m=Dt(a[1]);if(m.type!=="invalid")return{value:r,type:"array expression",children:[m]}}let s=/^([^|{}]+)\{\}$/.exec(r);if(s){let m=[Dt(s[1])];return{value:r,type:"object expression",children:m}}if(/^.+(\|.+)+$/.exec(r)){let m=Zd(r,!1,!1,"|",Dt);return{value:r,type:"or",children:m}}if(/^(.+)&(.+)$/.exec(r)){let m=Zd(r,!1,!1,"&",Dt);return{value:r,type:"and",children:m}}let c=/^`([A-Z]+)(.*)?`$/i.exec(r);if(c){let m=c[2];return{value:r,type:"class",children:m?[Dt(m)]:[]}}}function ol(r,n,t){let e=r.length;if(r[0]===n&&r[e-1]===t){let i=!1,o=!1,a=0,s=0;for(let p=1;p<e-1;p++){let d=r[p],c=r[p-1];if(d==="'"&&c!=="\\")o||(i=!i,i||(a+=s));else if(d==='"'&&c!=="\\")i||(o=!o,o||(a+=s));else if(!i&&!o){if(d===n)a++;else if(d===t&&(a--,a===-1))return null}else d===n?s++:d===t&&s--}return[r,r.substr(1,e-2)]}else return null}function Y8(r){return ol(r,el,nl)}function J8(r){return ol(r,il,rl)}function al(r,n=!1,t=!1,e=al){if(r=r.trim(),!t){if(/^null$/.exec(r))return X8;if(/^[+-]?Infinity$/.exec(r))return{value:r,type:"number literal",children:[]}}if(Xf.exec(r))return{value:r,type:"boolean literal",children:[]};if(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'")){let f=r[0],g=!0;for(let h=1;h<r.length-1;h++)if(r[h]===f&&r[h-1]!=="\\"){g=!1;break}if(g)return{value:r,type:"string literal",children:[]}}if(Qf.exec(r))return{value:r,type:"number literal",children:[]};if(/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?(?:[\s]*[+\-*/][\s]*-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)+$/g.exec(r))return{value:r,type:"arithmetic expression",children:[]};if(new RegExp("^\\$\\{(.*)\\}$","is").exec(r))return{value:r,type:"unit",children:[]};if(/^\/.+\/$/.exec(r))return{value:r,type:"regex literal",children:[]};if(t&&Zf.test(r))return{value:r,type:"identifier",children:[]};if(n){let f=/^("[^"]*"|'[^']*'|[^:{]*):([^]*)$/.exec(r);if(f){let g=e(f[1],!1,!0);if(!Qd(g))return{value:r,type:"invalid",children:[]};let h=f[2],x=e(h)||{value:h,type:"invalid",children:[]};return{value:r,type:"key value",children:[g,x]}}else return{value:r,type:"invalid",children:[]}}let d=Y8(r);if(d){let f=d[1],g=tl(f,!0,!0,e);return{value:r,type:"object literal",children:g}}let c=J8(r);if(c){let f=c[1],g=tl(f,!1,!1,e);return{value:r,type:"array literal",children:g}}if(/^unit:\/\/.+$/i.exec(r))return{value:r,type:"url",children:[]}}var X8={value:"null",type:"null",children:[]},Z8={value:"string",type:"string",children:[]},Q8={value:"boolean",type:"boolean",children:[]},t3={value:"number",type:"number",children:[]},e3={value:"any",type:"any",children:[]},n3={value:"regex",type:"regex",children:[]},i3={value:"object",type:"object",children:[]};function r3(r){return!!/^ *$/.exec(r)}function Zd(r,n=!1,t=!1,e,i){r=r.trim();let o=0,a=0,s=!1,p=!1,d=0,c=0,m=!1,f=[],g;for(;d<r.length;){let x=r[d];if(!p&&!s&&(x===el?o++:x===nl&&o--,x===il?a++:x===rl&&a--),s||x===W8&&g!=="\\"&&(p=!p),p||x===K8&&g!=="\\"&&(s=!s),x===e&&o===0&&a===0&&!s&&!p){let y=r.substring(c,d);f.push(i(y,n,t)),c=d+1,m=!0}g=x,d++}let h=r.substring(c,r.length);return(!r3(h)||m)&&f.push(i(h,n,t)),f}function tl(r,n=!1,t=!1,e){return Zd(r,n,t,z8,e)}var Px=Dt("");function Qu(r,n,t,e=()=>{throw new Error("cannot resolve")}){let{value:i,children:o}=r;switch(r.type){case"identifier":return i;case"null":return null;case"string literal":return i.substring(1,i.length-1).replace(/\\"/g,'"');case"boolean literal":return i==="true";case"number literal":return Number.parseFloat(i);case"array literal":{let a=[];for(let s of o)s.type!=="invalid"&&a.push(Qu(s,n,t,e));return a}case"object literal":{let a={};for(let s of o)if(s.type==="key value"){let[p,d]=s.children;a[Qu(p,n,t)]=Qu(d!=null?d:p,n,t,e)}else Qd(s)&&(a[s.value]=s.value);return a}case"unit":{let a=i.substring(1),s=st(a,n,t);return vn(s,n,t)}case"url":return e(i);default:throw new Error("invalid data string")}}function st(r,n,t,e=()=>{throw new Error("cannot resolve")}){let i=Dt(r,!1,!1);return Qu(i,n,t,e)}function ec(r,n){let{id:t}=r,e=ht(n,t),{system:i}=e;if(i)return{unit:_({id:t},r)};{let o={[t]:e};return tc(e,n,o,new Set),{unit:_({id:t},r),specs:o}}}function tn(r,n){let t={};return tc(r,n,t,new Set([])),{spec:r,specs:t}}function tc(r,n,t,e){if(!r.id)throw new Error("spec id is required");r.system||e.has(r.id)||(e.add(r.id),o3(r,n,t,e))}function o3(r,n,t,e){var o;let{units:i={}}=r;for(let a in i){let s=i[a],{id:p,input:d={}}=s;for(let m in d){let f=(o=d[m])!=null?o:{},{data:g}=f;if(g){let h=Dt(g);if(h.type==="unit"){let x=st(h.value,n,{});for(let y in x.specs){let I=x.specs[y];t[y]=I,tc(I,n,t,e)}}}}let c=ht(n,p);(!n[p]||!yn(n,p))&&(t[p]=c),tc(c,n,t,new Set(e))}}var nc=class extends Error{constructor(){super("no child at this position")}};function ic(r,n,t){let e=Dn(r,n,t),{__bundle:i}=t;return r.emit("append_child",i,[]),e}function pl(r,n){let t=r.refSystem(),e=new n(t),{input:i={},output:o={},memory:a={input:{},output:{},memory:{}}}=n.__bundle.unit;for(let s in i){let{data:p}=i[s];if(p!==void 0){let d=st(p,t.specs,t.classes);e.pushInput(s,d)}}return r.paused()&&!e.paused()?e.pause():!r.paused()&&e.paused()&&e.play(),e}function Dn(r,n,t){let e=pl(r,t);return n.push(e),n.length-1}function ul(r,n,t,e){let i=pl(r,t);It(n,i,e);let{__bundle:o}=t;r.emit("insert_child",o,e,[])}function Sn(r,n,t){return t>=0&&t<n.length}function En(r,n,t){if(!Sn(r,n,t))throw new nc;let[i]=n.splice(t,1);return i}function rc(r,n,t){let e=En(r,n,t);return r.emit("remove_child",t,[]),r.emit(`remove_child_at_${t}`,t),e}function oc(r,n,t){return n[t]}function ac(r,n){return n}function cl(r,n,t){return t[n]||r}function sc(r,n,t,e,i){i===void 0?n.push(t):It(n,t,i),r.emit("register_parent_root",t,e),r.refSlot(e).appendParentChild(r,"default")}function pc(r,n,t){let e=n.indexOf(t);n.splice(e,1),r.emit("unregister_parent_root",r)}function uc(r,n,t,e){let i=n.indexOf(t);if(i===-1)throw new Error("root not found");n.splice(i,1),It(n,t,e),r.emit("reorder_root",r,e)}function cc(r,n,t,e){let i=n.indexOf(t);if(i===-1)throw new Error("root not found");n.splice(i,1),It(n,t,e),r.emit("reorder_parent_root",r,e)}function dc(r,n,t){let e=n.indexOf(t);n.splice(e,1),r.emit("unregister_root",r)}function mc(r,n,t){n.push(t),r.emit("register_root",r)}function fc(r,n,t,e){let i=r.refSlot(e);r===i?(n.push(t),r.emit("append_parent_child",r,e)):i.appendParentChild(t,"default")}function lc(r,n,t){let e=n.indexOf(t);n.splice(e,1),r.emit("remove_parent_child",r)}function bc(r,n,t,e){n.push({keyframes:t,opt:e}),r.emit("call",{method:"animate",data:[t,e]})}function gc(r,n,t){let e=n.findIndex(i=>i.opt.id===t);n.splice(e,1),r.emit("call",{method:"cancelAnimation",data:[t]})}function hc(r,n,t){var e;return n[t]=(e=n[t])!=null?e:0,n[t]++,r.emit("call",{method:"stopPropagation",data:[t]}),()=>{n[t]--,n[t]===0&&(delete n[t],r.emit("call",{method:"cancelStopPropagation",data:[t]}))}}var wt=["fork","append_child","remove_child","insert_child","add_unit","clone_unit","remove_unit","move_unit","add_merge","remove_merge","expose_pin","cover_pin","plug_pin","unplug_pin","remove_pin_from_merge","add_pin_to_merge","move_subgraph_into","move_subgraph_into","move_sub_component_root","reorder_sub_component","expose_pin_set","cover_pin_set","set_pin_set_id","set_pin_set_functional","set_unit_pin_constant","set_unit_pin_ignored","set_unit_pin_data","remove_unit_pin_data","set_unit_id","bulk_edit"];var Ne=class extends Error{constructor(){super("code path not implemented")}};var yc=class extends Error{constructor(){super("merge not found")}};var _c=class extends Error{constructor(){super("unit not found")}};function pt(r,n){let t=r;for(let e of n)t=r[e],r=t;return t}function Jt(r,n,t){return`${r}/${n}/${t}`}function dl(r,n){return Jt(r,"output",n)}function At(r,n){return`${r}/${n}`}function _t(r){return r==="input"?"output":"input"}var ml=r=>{let n={input:{},output:{}};return ll(r,(t,e,i,o,a)=>{let s=a3(r,t,e,o);F(n,[t,e,o],s)}),n},a3=(r,n,t,e)=>W(r,[`${n}s`,t,"plug",e],null);var Kt=r=>Vd(r,(n,t)=>n+nm(t),0);var em=(r,n)=>Vd(r,(t,e)=>t+tm(e,n),0),nm=r=>tm(r,"input")+tm(r,"output"),tm=(r,n)=>{let{[n]:t={}}=r;return zu(t)},te=(r,n)=>{A(r||{},(t,e)=>{St(t,(i,o,a,s)=>n(e,i,o,a,s))})},St=(r,n)=>{A(r,({input:t,output:e},i)=>{A(t||{},(o,a)=>{n(i,"input",a,o)}),A(e||{},(o,a)=>{n(i,"output",a,o)})})},fl=(r,n)=>{A(r,({input:t},e)=>{A(t||{},(i,o)=>{n(e,"input",o,i)})})};var s3=(r,n)=>{Tn(r,"input",(t,e)=>{n("input",t,e)}),Tn(r,"output",(t,e)=>{n("output",t,e)})},ll=(r,n)=>{s3(r,(t,e,i)=>{var o;for(let a in(o=i.plug)!=null?o:{}){let s=i.plug[a];n(t,e,i,a,s)}})};var Tn=(r,n,t)=>{var e;A((e=r[`${n}s`])!=null?e:{},(i,o)=>{t(o,i)})};var bl=(r,n)=>{var t;return!!((t=r.merges)!=null&&t[n])},gl=(r,n,t,e,i)=>!!W(r,["merges",n,t,e,i],!1);var hl=(r,n,t,e)=>{let i=null;return Tn(r,t,(o,a)=>{let{plug:s={}}=a;for(let p in s){let d=s[p];d.unitId===n&&d.pinId===e&&(i={pinId:o,type:t,subPinId:p})}}),i};function im(r,n){let t={input:{},output:{}};return ll(r,(e,i,o,a,s)=>{var p;s.unitId===n&&F(t,[(p=s.kind)!=null?p:e,s.pinId],{type:e,pinId:i,subPinId:a})}),t}var p3=(r,n,t,e,i,o,a=null)=>{var s;return o||a?!1:ue((s=t.plug)!=null?s:{})>1?!0:i.pinId!==n};function yl(r,n,t,e,i,{getUnitMerges:o,getUnitPlugs:a,getMerge:s,getPinMergeId:p}){var J,q;let{units:d={},merges:c={},inputs:m={},outputs:f={}}=n,g={unit:et(d),merge:et(c),link:[],plug:[]},h=o(r),x=a(r),y={unit:t,merge:e,plug:vt(i,w=>vt(w,E=>vt(E,$=>({subPinId:$}))))},I={},v={},T={},P={};te(c,(w,E,$,G)=>{var L;let K=(L=e[w])!=null?L:w;F(P,[E,$,G],K)});let H=(w,E)=>{for(let $ in E){let G=E[$];U(w,$,G)}},U=(w,E,$)=>{var nt,M;let{plug:G,ref:K,defaultIgnored:L}=$,rt=!!p(r,w,E),N=W(x,[w,E],null);for(let k in G){let R=G[k];if(p3(w,E,$,k,R,rt,N)){g.plug.push({type:w,pinId:E,subPinId:k});let X={};R.unitId&&R.pinId?X={unitId:(nt=y.unit[R.unitId])!=null?nt:R.unitId,pinId:R.pinId}:X={mergeId:(M=y.merge[R.mergeId])!=null?M:R.mergeId},F(T,[w,E,k],X)}if(R.unitId&&R.pinId)te(h,(X,ct,ot,it)=>{var Pt;let dt=s(X),Et=j(dt);delete Et[r];let xt=(Pt=y.unit[R.unitId])!=null?Pt:R.unitId;Et[xt]={[ot]:{[R.pinId]:!0}},ct===r&&ot===w&&it===E&&F(I,[R.unitId,ot,R.pinId],{pinId:E,subPinId:k,ref:K,defaultIgnored:L,mergeId:X,merge:Et})});else if(R.mergeId){let X=c[R.mergeId];if(om(X)){let ct=p(r,w,E);if(ct){let ot=s(ct),it=j(ot);delete it[r],F(v,[R.mergeId,w],{mergeId:ct,pinId:E,subPinSpec:{mergeId:R.mergeId},oppositeMerge:it})}else F(v,[R.mergeId,w],{mergeId:null,pinId:null,subPinSpec:{},oppositeMerge:{}})}else{let ct=p(r,w,E);if(ct){let ot=s(ct),it=j(ot);delete it[r],F(v,[R.mergeId,w],{mergeId:ct,oppositeMerge:it})}}}}};H("input",m),H("output",f);for(let w in h){let E=s(w),$=j(E),G=$[r];Ft((J=G.input)!=null?J:{})&&delete G.input,Ft((q=G.output)!=null?q:{})&&delete G.output;let K=at(G),L=at(G[K]);if(delete $[r],Kt($)===1&&L!==lt){let rt=pt(n,[`${K}s`,L]),{plug:N={}}=rt,nt=!1;for(let M in N){let k=N[M];if(k.mergeId){let R=c[k.mergeId];Kt(R)===0&&(nt=!0)}}if(!nt){let M=at($),k=at($[M]),R=at($[M][k]);F(y,["link",M,k,R],{mergeId:w,oppositePinId:L})}}}return te(h,(w,E,$,G)=>{let K=s(w)}),{nodeIds:g,nextSpecId:null,nextIdMap:y,nextPinIdMap:I,nextMergePinId:v,nextPlugSpec:T,nextUnitPinMergeMap:P,nextSubComponentParentMap:{},nextSubComponentChildrenMap:{},nextSubComponentIndexMap:{}}}function rm(r,n){let{merges:t}=r,e={};for(let i in t){let o=t[i];o[n]&&(e[i]=o)}return e}function om(r){return Kt(r)===0}var u3="addUnitSpec";var c3="removeUnit";var d3="addMerge";var m3="removeMerge";var f3="exposePinSet",l3="coverPinSet";var b3="unplugPin",g3="plugPin";var h3=r=>({type:u3,data:r}),_l=(r,n,t,e,i,o,a,s)=>h3({unitId:r,bundle:n,position:t,pinPosition:e,layoutPositon:i,parentId:o,merges:a,plugs:s});var y3=r=>({type:c3,data:r}),xl=(r,n,t,e,i,o,a,s)=>y3({unitId:r,bundle:n,position:t,pinPosition:e,layoutPositon:i,parentId:o,merges:a,plugs:s});var _3=r=>({type:f3,data:r});var Il=(r,n,t,e)=>_3({type:r,pinId:n,pinSpec:t,data:e}),x3=r=>({type:l3,data:r}),vl=(r,n,t)=>x3({type:r,pinId:n,pinSpec:t}),I3=r=>({type:g3,data:r}),Dl=(r,n,t,e)=>I3({type:r,pinId:n,subPinId:t,subPinSpec:e}),v3=r=>({type:b3,data:r}),Sl=(r,n,t,e)=>v3({type:r,pinId:n,subPinId:t,subPinSpec:e});var D3=r=>({type:d3,data:r}),El=(r,n,t)=>D3({mergeId:r,mergeSpec:n,position:t}),S3=r=>({type:m3,data:r}),Tl=(r,n,t)=>S3({mergeId:r,mergeSpec:n,position:t});var Al=(r,n,t)=>{var o;let{type:e,data:i}=r;if(!n[e]&&t)throw new Error(`no method for ${e}`);((o=n[e])!=null?o:t)(i)};function Cl(r,n=!1){let{__system:t}=r,[e,i]=E3(r,n);return[new e(t),i]}function E3(r,n=!1){let{__system:t}=r,e=t.specs,i=j(r.getUnitBundleSpec(n));return[vn(i,e,t.classes),i]}function en(r,n){return _(_({},r),n)}function nn(r,n,t){return Z(_({},r),{[n]:t})}function am(r,n){r.input!==void 0&&n("input",r.input),r.output!==void 0&&n("output",r.output)}function Bt(r,n){am(r,(t,e)=>{Nt(e,(i,o)=>{n(t,i,o)})})}function sm(r,n){return Ml(r.component,n)}function Ml(r,n){let{subComponents:t}=r;for(let e in t){let i=t[e],{children:o=[]}=i;for(let a of o)if(a===n)return e}return null}function xc(r,n,t){var e;if(n.length>1){let[i,...o]=n;r[i]=(e=r[i])!=null?e:{},xc(r[i],o,t)}else{let[i]=n;r[i]=t}}var Pl=({unitId:r,unit:n},t)=>{F(t,["units",r],n)};var T3=({mergeId:r,unitId:n,type:t,pinId:e},i)=>{Vt(i,["merges",r,n,t,e]),Ft(W(i,["merges",r,n,t],{}))&&Vt(i,["merges",r,n,t]),Ft(W(i,["merges",r,n],{}))&&Vt(i,["merges",r,n])},Ol=({mergeId:r,unitId:n,type:t,pinId:e},i)=>{T3({mergeId:r,unitId:n,type:t,pinId:e},i)};var Ul=({pinId:r,type:n},t)=>Vt(t,[`${n}s`,r]),wl=({pinId:r,type:n,subPinId:t},e)=>{Vt(e,[`${n}s`,r,"plug",t])};var Ll=({type:r,pinId:n,subPinId:t,subPinSpec:e},i)=>F(i,[`${r}s`,n,"plug",t],e);var Gl=({type:r,pinId:n,subPinId:t},e)=>F(e,[`${r}s`,n,"plug",t],{});var Rl=({type:r,pinId:n,functional:t},e)=>F(e,[`${r}s`,n,"functional"],t);var kl=({unitId:r,type:n,pinId:t,data:e},i)=>F(i,["units",r,n,t,"data"],e),$l=({unitId:r,type:n,pinId:t,constant:e},i)=>F(i,["units",r,n,t,"constant"],e);var Nl=({unitId:r,width:n,height:t},e)=>{Wu(e,["units",r,"metadata","component"],{width:n,height:t})},Fl=({width:r,height:n},t)=>{Wu(t,["component"],{defaultWidth:r,defaultHeight:n})},Bl=({unitId:r,width:n,height:t},e)=>{Wu(e,["component","subComponents",r],{width:n,height:t})},jl=({unitId:r,type:n,pinId:t,newPinId:e},i)=>{let{units:o={},merges:a={}}=i;for(let s in o){let p=o[s]}te(j(a),(s,p,d,c)=>{p===r&&d===n&&c===t&&(Vt(i,["merges",s,r,n,t]),F(i,["merges",s,r,n,e],!0))})};function An(r,n,t,e={}){let{unit:{id:i,input:o,output:a}}=n,{classes:s}=r;n.specs&&r.injectSpecs(n.specs);let p=Yf(r,i,t,s,e);A(o||{},(c={},m)=>{let{constant:f,ignored:g}=c;f!=null&&p.setInputConstant(m,f),typeof g=="boolean"&&p.setInputIgnored(m,g)}),A(a||{},(c={},m)=>{let{ignored:f}=c;typeof f=="boolean"&&p.setOutputIgnored(m,f)});let{unit:{memory:d}}=n;return d&&(Yu(d,t,s),p.restore(d)),A(o||{},(c,m)=>{var g,h;let{data:f}=c!=null?c:{};if(f!==void 0){let x=p.getInput(m),y=st(f,r.specs,s),I=y instanceof Function;if(I&&r.injectSpecs((h=(g=y.__bundle)==null?void 0:g.specs)!=null?h:{}),x.ref()){if(I){let v=new y(r);v.play(),x.push(v)}}else x.push(y)}}),p}function tt(r){return()=>{r.forEach(n=>n())}}var l=class extends Q{constructor({i:t,o:e}={},i={},o,a){super({i:t,o:e},i,o,a);this._looping=!1;this._on_data_output_drop=t=>{this._backward_if_ready(),this._forward_if_ready()};this._done=(t,e=null)=>{if(e)this._forwarding=!0,this.err(e),this._forwarding=!1,this._forward_all_empty();else if(t!==void 0){let i=ce(this._output,s=>s.empty()),o=ce(this._output,s=>!s.empty()),a=(s,p)=>{let d=t[p];d===void 0?s.pull():s.push(d)};this._forwarding=!0,A(i,a),A(o,a),this._forwarding=!1}this._backward_if_ready()};this.addListener("take_err",()=>{this._looping&&this._backward_if_ready()}),this.addListener("take_caught_err",()=>{this.hasErr()||this._backward_if_ready()})}_on_input_data(t){this._i[t]!==void 0&&this._active_i_count===this._i_count&&(this._looping=!1),this._forward_if_ready()}_on_input_drop(t,e){this._active_i_count===this._i_count-1&&!this._backwarding&&!this._forwarding_empty&&(this._looping=!1,this._catchErr?this.takeCaughtErr():this.takeErr(),this.d(t,e),this._forward_all_empty())}_on_input_invalid(t){this._i_invalid_count===1&&(this.i(t),this._invalidate())}onDataInputData(t){this._on_input_data(t)}onDataInputDrop(t,e){this._on_input_drop(t,e)}onDataInputStart(t){this._i_start_count===this._i_count&&this._start()}onDataInputInvalid(t){this._on_input_invalid(t)}onDataInputEnd(t){this._i_start_count===this._i_count-1&&this._end()}onRefInputData(t){this._on_input_data(t)}onRefInputDrop(t,e){this._on_input_drop(t,e)}onRefInputInvalid(t){this._on_input_invalid(t)}onDataOutputDrop(t){this._on_data_output_drop(t)}f(t,e){}i(t){}d(t,e){}_backward_if_ready(){!this._forwarding_empty&&!this._forwarding&&!this._err&&!this._caughtErr&&this._active_o_count===0&&(this._looping=!1,this._backward_all(),this._forward_if_ready())}_forward_if_ready(){for(;this._active_o_count-this._o_invalid_count===0&&this._active_i_count-this._i_invalid_count===this._i_count&&!this._forwarding&&!this._backwarding&&!this._looping;)this._looping=!0,this._err!==null&&(this._forwarding_empty=!0,this.takeErr(),this._forwarding_empty=!1),this.f(this._i,this._done)}snapshotSelf(){return Z(_({},super.snapshotSelf()),{_looping:this._looping})}restoreSelf(t){let o=t,{_looping:e}=o,i=bt(o,["_looping"]);super.restoreSelf(i),this._looping=e}};var A3="_5d09d860-a8fe-428b-befd-7c793bc0783c",Cn=class extends l{constructor(n){super({i:[],o:[]},{},n,A3),this.play()}f(n,t){t(n)}};function Ic(r,n){let t=!1;if(Kt(n)>0){let e=at(n),i=n[e],o=at(i),a=at(i[o]);r.getUnit(e).isPinRef(o,a)&&(t=!0)}return t}function C3(r,n,t,e,i,o,a,s,p,d,c){var K;let{nextIdMap:m,nextPinIdMap:f,nextSubComponentParentMap:g,nextSubComponentChildrenMap:h}=i,x=r.getUnit(e),y=((K=m.unit)==null?void 0:K[e])||e,I=g[e]||null,v=h[e]||[],T=f[e]||{},P=s[e]||{input:new Set,output:new Set},H=r.getSpec(),{units:U,component:B={}}=H,{subComponents:J={}}=B,q=U[e],w=J[e];if(r.removeUnit(e,!1,!1,!1),n.addUnit(y,x,void 0,!1),I&&n.hasUnit(I)){let L=h[I].indexOf(y);n.moveRoot(I,y,L,"default")}if(v)for(let L=0;L<v.length;L++){let z=v[L];n.hasUnit(z)&&n.moveRoot(y,z,L,"default")}if(w){let{metadata:{component:L}={}}=q;L&&typeof L.width=="number"&&typeof L.height=="number"&&n.setUnitSize(y,L.width,L.height)}let E=(L,z)=>{var R,X;let{pinId:rt,subPinId:N,plug:nt,mergeId:M,merge:k}=W(T,[L,z],{});if(!P[L].has(z)&&!x.isPinIgnored(L,z)){let ct=M&&(!p.has(M)||c);if(c||n.hasPinNamed(L,rt)||Hd(d[L]||{},({plug:ot={}},it)=>{for(let dt in ot){let Et=ot[dt];if(Et.unitId===e&&Et.pinId===z){r.unplugPin(L,it,dt,!1,!1);break}}}),rt&&N){if(c){M&&n.hasMergePin(M,t,L,rt)&&n.removePinOrMerge(M,t,L,rt,!1,!1);let{pinId:it,subPinId:dt}=((X=(R=o.plugs)==null?void 0:R[L])==null?void 0:X[z])||{};it&&dt&&it===rt&&(n.hasPinNamed(L,it)?(n.hasPlug(L,it,dt)&&n.unplugPin(L,it,dt,!1,!1),n.plugPin(L,it,dt,{unitId:y,pinId:z},!1,!1)):n.exposePinSet(L,it,{plug:{[dt]:{unitId:y,pinId:z}}},void 0,!1,!1))}else if(n.hasPinNamed(L,rt))n.exposePin(L,rt,N,{unitId:y,pinId:z},!1,!1);else{let it=x.isPinRef(L,z),dt=x.getPinData(L,z);n.exposePinSet(L,rt,{plug:{0:{unitId:y,pinId:z}},ref:it},dt,!1,!1),A(d[L]||{},({plug:Et},xt)=>{for(let Pt in Et){let Rt=Et[Pt];if(Rt.unitId===e&&Rt.pinId===z){r.plugPin(L,xt,Pt,{unitId:t,pinId:rt},!1,!1);break}}})}x.isPinConstant(L,z)&&(c||(n.setUnitPinConstant(e,L,z,!1,!1),n.setPinConstant(L,rt,!0))),ct&&(c?(n.hasMergePin(M,t,L,z)&&n.removePinOrMerge(M,t,L,z,!1,!1),n.hasMerge(M)||n.addMerge(k!=null?k:{},M,!1,!1),n.hasMergePin(M,y,L,z)||n.addPinToMerge(M,y,L,z,!1,!1)):(r.hasMerge(M)||(r.addMerge({},M,!1,!1),St(k,(it,dt,Et)=>{r.hasUnit(it)&&r.addPinToMerge(M,it,dt,Et,!1,!1)})),r.hasMergePin(M,t,L,rt)||r.addPinToMerge(M,t,L,rt,!1,!1)))}}if(nt){let{type:ct,pinId:ot,subPinId:it,kind:dt=ct}=nt;c||n.hasPlug(ct,ot,it)&&n.plugPin(ct,ot,it,{unitId:y,pinId:ot,kind:dt})}},$=x.getInputNames();for(let L of $)E("input",L);let G=x.getOutputNames();for(let L of G)E("output",L);E("output",lt)}function Hl(r,n,t,e,i,o,a,s,p,d,c,m=new Set,f){var y,I;if(m.has(e)&&t!==e)return;let{nextPinIdMap:g}=s,{mergeId:h,merge:x}=W(g,[i,o],{pinId:void 0,subPinId:void 0});if(t===e){if(!f){let v=n.isPinConstant(i,o),T=j(n.getExposedPinSpec(i,o));if(h&&x){let P=x[e],H=Kt(x),U=nm(P);H-U>0||n.coverPinSet(i,o,!1)}else n.coverPinSet(i,o,!1);if(v){let{plug:P={}}=T;for(let H in P){let U=P[H];if(U.unitId&&U.pinId)n.setUnitPinConstant(U.unitId,i,U.pinId,!0);else if(U.mergeId){let B=n.getMergeSpec(U.mergeId);St(B,(J,q,w)=>{n.setUnitPinConstant(J,q,w,!0)})}}}}}else{if(p&&d){let v=_t(i);if(f)r.hasPinNamed(v,d)&&r.coverPinSet(v,d,!1);else{if(!n.hasPinNamed(v,d)){let T=r.getUnit(e);a=a!=null?a:r.getUnitPinData(e,i,o);let P=T.isPinRef(i,o),H={plug:{0:{}},ref:P};n.exposePinSet(v,d,H,a,!1,!1)}if(r.hasMerge(p)){let T=r.getMergeSpec(p);(I=(y=T==null?void 0:T[t])==null?void 0:y[v])!=null&&I[d]||r.addPinToMerge(p,t,v,d,!1,!1),r.addPinToMerge(p,e,i,o,!1,!1)}else{let T={[e]:{[i]:{[o]:!0}},[t]:{[v]:{[d]:!0}}};r.addMerge(T,p,!1,!1)}}}if(c){let T=t!==e?{plug:{0:{unitId:e,pinId:o}}}:{plug:{0:{}}};n.exposePinSet(i,c.pinId,T,void 0,!1,!1),r.plugPin(i,c.pinId,c.subPinId,{unitId:t,pinId:c.pinId})}}}function M3(r,n,t,e,i,o,a,s,p=new Set,d,c){var w;let{nextIdMap:m,nextMergePinId:f}=a,g=(w=m.merge[e])!=null?w:e,{input:h=null,output:x=null}=f[e]||{},y=0,I=r.getMergeSpec(e),v={},{merges:T}=s,P=Kt(i),H=em(i,"input"),U=em(i,"output"),B=r.getMergeData(e);if(r.hasMerge(e)&&r.removeMerge(e,!1,!1),St(i,(E,$,G)=>{var M,k;let K=((M=m.unit)==null?void 0:M[E])||E;if(E===t&&!p.has(E)){let R=n.getExposedPinSpec($,G),{plug:X}=R;for(let ct in X){let ot=X[ct];if(ot.unitId&&ot.pinId)F(v,[ot.unitId,$,ot.pinId],!0);else if(ot.mergeId){let it=n.getMergeSpec(ot.mergeId);St(it,(dt,Et,xt)=>{F(v,[K,Et,xt],!0)})}}y++}else p.has(E)&&n.hasUnit(K)&&(F(v,[K,$,G],!0),y++);let z=!($==="input")&&!p.has(E),{mergeId:rt,pinId:N,subPinSpec:nt}=(k=z?h:x)!=null?k:{};Hl(r,n,t,E,$,G,B,a,rt,N,null,p,c)}),c){if(P===0||y>1){let E=o;n.addMerge(v,g,!1,E)}}else if(y===0&&(P===0||H>0&&U>0)||y>1){let E=o;n.addMerge(v,g,!1,E),ue(i!=null?i:{})===1&&at(i)===t&&St(i,($,G,K)=>{n.hasPinNamed(G,K)&&n.coverPinSet(G,K)})}let q=(E,$)=>{var rt,N,nt;let{mergeId:G,pinId:K,subPinSpec:L,oppositeMerge:z}=$;if(K&&L){if(c){n.hasMergePin(G,t,E,K)&&n.removeMerge(G,!1,!1);for(let M in T){let k=T[M],R=k[t];if((rt=R==null?void 0:R.output)!=null&&rt[lt])return;for(let X in R){let ct=R[X];for(let ot in ct){if(ot!==K)continue;let it=d[X][ot],{plug:dt}=it;for(let Et in dt){let xt=dt[Et];if(xt.mergeId){let Pt=((N=m.merge)==null?void 0:N[xt.mergeId])||xt.mergeId,Rt=j(k);delete Rt[t];let xe=at(Rt),bn=at(Rt[xe]),Rd=at(Rt[xe][bn]);if(n.hasMerge(Pt))St(Rt,(Gu,kd,Tf)=>{kd!==E&&!n.hasMergePin(Pt,Gu,kd,Tf)&&n.addPinToMerge(Pt,Gu,kd,Tf,!1)});else{let Gu={[xe]:{[bn]:{[Rd]:!0}}};n.hasMerge(Pt)||n.addMerge(Gu,Pt,!1,!1)}}else if(xt.unitId&&xt.pinId){let Pt=((nt=m.unit)==null?void 0:nt[xt.unitId])||xt.unitId;if(n.hasMerge(M))n.addPinToMerge(M,Pt,X,xt.pinId,!1);else if(z){let Rt=j(z);delete Rt[xt.unitId];let xe=at(Rt);if(!xe)continue;let bn=at(Rt[xe]),Rd=at(Rt[xe][bn]);n.addMerge({[Pt]:{[X]:{[xt.pinId]:!0}},[xe]:{[bn]:{[Rd]:!0}}},e,!1,!1,void 0)}}}}}}}else if(n.hasPinNamed(E,K)?n.exposePin(E,K,"0",L,!1,!1):n.exposePinSet(E,K,{plug:{0:L}},void 0,!1,!1),!r.hasMerge(G)&&z){let M=j(z);delete M[L.unitId],St(z,R=>{p.has(R)&&delete M[R]});let k=at(M);if(k){let R=at(M[k]),X=at(M[k][R]);r.addMerge({[t]:{[E]:{[K]:!0}},[k]:{[R]:{[X]:!0}}},G,!1,!1,void 0)}}}};h&&q("input",h),x&&q("output",x),am(d,(E,$)=>{Nt($,(G,K)=>{var z,rt;if(W(a,["nextPlugSpec",E,G],void 0))return;let{plug:L}=K;for(let N in L)if(L[N].mergeId===e){let{mergeId:M,oppositeMerge:k}=(z=E==="input"?h:x)!=null?z:{};if(c){if(om(I)){let R=n.getExposedPinSpecs();if(Nt((rt=R[E])!=null?rt:{},(X,ct)=>{let{plug:ot={}}=ct;for(let it in ot){let dt=ot[it];dt.unitId===t&&dt.pinId===X&&(n.unplugPin(E,X,it,!1,!1),n.plugPin(E,X,it,{mergeId:M},!1,!1))}}),!M||!k)continue;n.hasMerge(g)?St(k,(X,ct,ot)=>{X!==t&&(n.hasMergePin(g,X,ct,ot)||n.addPinToMerge(g,X,ct,ot,!1,!1))}):n.addMerge(k,g,!1,!1)}}else if(r.hasPlug(E,G,N)){let R=M?{mergeId:M}:{unitId:t,pinId:G},X=n.hasMerge(g),ct=r.getPinData(E,G);n.hasPinNamed(E,G)?n.plugPin(E,G,N,X?{mergeId:g}:{},!1,!1):n.exposePinSet(E,G,{plug:{[N]:X?{mergeId:g}:{}}},ct,!1,!1),r.hasPinNamed(E,G)?(r.hasPlug(E,G,N)&&r.unplugPin(E,G,N,!1,!1),r.plugPin(E,G,N,R,!1,!1)):r.exposePinSet(E,G,{plug:{[N]:R}},void 0,!1,!1)}}})})}function P3(r,n,t,e,i,o,a,s,p,d,c,m){var T;let f=r.getExposedPinSpec(e,i),g;if(f){let P=ue((T=f.plug)!=null?T:{});g=r.getPinData(e,i),P===1?r.coverPinSet(e,i,!1):r.coverPin(e,i,a,!1)}let h=W(m,["plug",e,i,a,"type"],e),x=W(m,["plug",e,i,a,"subPinId"],a),y=W(p,[e,i,a],void 0);if(!s){r.exposePinSet(e,i,{plug:{[a]:{}}},void 0,!1,!1);return}if(!y)return;let{pinId:I=s.pinId}=y,v=y;if(y.unitId&&y.pinId&&n.hasUnit(y.unitId)||y.mergeId&&n.hasMerge(y.mergeId)||(v={}),n.hasPinNamed(h,i)?n.hasPlug(h,i,x)?n.plugPin(h,i,x,v,!1,!1):n.exposePin(h,i,x,v,!1,!1):n.exposePinSet(h,i,{plug:{[x]:v},ref:!!o.ref},g,!1,!1),!!s){if(s.unitId&&s.pinId){let P=W(m,["link",s.unitId,s.type,i,"mergeId"],null);P?r.addPinToMerge(P,t,h,I,!1,!1):(P=W(m,["plug",e,i,a,"mergeId"],null),P&&(r.hasMerge(P)?r.addPinToMerge(P,t,h,I,!1,!1):r.addMerge({[t]:{[h]:{[I]:!0}},[s.unitId]:{[e]:{[s.pinId]:!0}}},P,!1,!1,void 0)))}else if(s.mergeId){let P=W(c,["merge",s.mergeId,e],W(m,["plug",e,i,a,"mergeId"],null));P&&r.addPinToMerge(P,t,h,I!=null?I:i,!1,!1)}}}function pm(r,n,t,e,i,o=!0){let{nodeIds:a,nextIdMap:s,nextPinIdMap:p,nextMergePinId:d,nextPlugSpec:c,nextSubComponentParentMap:m,nextSubComponentChildrenMap:f}=e,{merge:g=[],link:h=[],unit:x=[],plug:y=[]}=a,I=j(r.getMergesSpec()),v=j(r.getExposedPinSpecs()),T=Vu(I,(w,E)=>Ic(r,E)),P={},H=new Set(x),U=new Set(g),B=(w,E,$)=>{P[w]=P[w]||{input:new Set,output:new Set},P[w][E].add($)},J=(w,E,$)=>{let G;return Bt(v,(K,L,z)=>{let{plug:rt}=z;for(let N in rt){let nt=rt[N];nt.unitId===w&&nt.pinId===$&&(G={type:K,pinId:L,subPinId:N})}}),G};for(let{unitId:w,type:E,pinId:$}of h){let G=J(w,E,$);G&&!y.find(K=>K.type===G.type&&K.pinId===G.pinId&&K.subPinId===G.subPinId)||B(w,E,$)}let q={};for(let w of g)if(r.hasMerge(w)){let E=r.getMergeSpec(w);q[w]=E,St(E,($,G,K)=>{B($,G,K)})}for(let{unitId:w,type:E,pinId:$}of h){let{mergeId:G,oppositePinId:K}=W(s,["link",w,E,$],{mergeId:null,oppositePinId:null});Hl(r,n,t,w,E,$,void 0,e,G,K,null,H,o)}for(let w of x)C3(r,n,t,w,e,i,H,P,U,v,o);for(let w of g){let E=I[w],$=T[w];M3(r,n,t,w,E,$,e,i,H,v,o)}for(let{type:w,pinId:E,subPinId:$}of y){let G=pt(v,[w,E]),K=W(v,[w,E,"plug",$],void 0);P3(r,n,t,w,E,G,$,K,c,p,d,s)}}function vc(r,n){let t=_({},r);return delete t[n],t}var Vl=(r,n,t)=>{let e={};return A(n,(i,o)=>{e[o]={},A(i,(a,s)=>{e[o][r===s?t:s]=a})}),e};var Lt=class extends Q{constructor(t,e={},i,o){super({i:[],o:[]},{},i,o!=null?o:t.id);this.__=["U","C","G","EE"];this._element=!1;this._unit={};this._merge={};this._pipedFrom={};this._pipedTo={};this._errUnitIds=[];this._pin={};this._unitPins={};this._exposedPin={};this._exposedMerge={};this._exposedEmptySubPin={input:{},output:{}};this._mergeToSelfUnit={};this._selfUniToMerge={};this._pinToMerge={};this._branch={};this._mergePinCount={};this._unitToMerge={};this._unitToMergeCount={};this._children=[];this._animations=[];this._stopPropagation={};this._stopImmediatePropagation={};this._preventDefault={};this._waitAll={};this._onPinSetRenamed=(t,e,i,o,a)=>{let s=_t(t),{functional:p}=o,d=pt(this._exposedPin,[t,e]),c=pt(this._exposedMerge,[t,e,t]),m=pt(this._exposedMerge,[t,e,s]);c.renamePin(t,e,i),m.renamePin(s,e,i),p&&this._unplugFromWaitAll(t,e),fe(this._exposedPin,[t,e]),fe(this._exposedMerge,[t,e,t]),fe(this._exposedMerge,[t,e,s]),F(this._exposedPin,[t,i],d),F(this._exposedMerge,[t,i,t],c),F(this._exposedMerge,[t,i,s],m);let f=pt(this._exposedEmptySubPin,[t,e]);for(let x in _({},f)){let y=f[x];delete f[x],F(f,[t,i,x],y)}let g=this.getExposedPinSpec(t,i),{plug:h={}}=g;for(let x in h){let y=h[x];y.unitId&&y.pinId&&F(this._pinToPlug,[y.unitId,t,y.pinId],{pinId:i,subPinId:x})}};this._refMergePin=(t,e)=>{let i=At(t,e);return this._pin[i]};this._plugToWaitAll=(t,e)=>{let i=_t(t),o=new Ut,a=this.getExposedPin(t,e),s=this._waitAll[t];s.addPin(t,e,o,{}),s.setPin(i,e,a),this.setPin(t,e,o,{})};this._unplugFromWaitAll=(t,e)=>{let i=_t(t),o=this.getExposedInputPin(e),a=this._waitAll[t];a.removePin(t,e),a.removePin(i,e),this.setPin(t,e,o,{})};this._getExposedSubPinNodeId=(t,e)=>{let{unitId:i,pinId:o,mergeId:a}=e;return a?At(a,t):Jt(i,t,o)};this._ensureMergePin=(t,e,i=!1)=>{let o=At(e,t),a=this._pin[o];if(!this._pin[o]){let s=_t(t);a=new Ut,this._pin[o]=a,this._setBranch(e,s,o,i)}return a};this._memEnsureMergePin=(t,e)=>{let i=At(e,t);if(!this._pin[i]){let o=_t(t),a=new Ut;this._pin[i]=a,this._memSetBranch(e,o,i)}};this._removeMergeOutput=t=>{this._simRemoveMergeOutput(t),this._memRemoveMergeOutput(t)};this._memRemoveMergeOutput=t=>{let e=At(t,"output");this._pin[e]&&(this._memRemoveBranch(t,"input",e),delete this._pin[e])};this._simRemoveMergeOutput=t=>{let e=At(t,"output");this._pin[e]&&this._simRemoveBranch(t,"input",e)};this._plugPinToMerge=(t,e,i,o,a,s=!0)=>{let p=At(o,t);this._ensureMergePin(t,o,s);let d=this._pin[p];this._setExposedSubPin(t,e,t,i,d,a,s)};this._simPlugPinToMerge=(t,e,i,o,a=!0)=>{let s=At(o,t);this._ensureMergePin(t,o,a);let p=this._pin[s];this._simSetExposedSubPin(t,e,t,i,p,a)};this._simUnplugPinFromMerge=(t,e,i,o)=>{this._simRemoveExposedSubPin(t,e,i)};this._simUnplugPinFromUnitPin=(t,e,i,o,a,s)=>{this._simRemoveExposedSubPin(t,e,i)};this._plugPinToUnitPin=(t,e,i,o,a,s,p,d=!1)=>{this._memPlugPinToUnitPin(t,e,i,o,a,s),this._simPlugPinToUnitPin(t,e,i,o,a,s,d)};this._memPlugPinToUnitPin=(t,e,i,o,a,s)=>{let p=this.getUnitPin(o,a,s);F(this._pinToPlug,[o,t,s],{pinId:e,subPinId:i,kind:a}),this._memSetExposedSubPin(t,e,i,p)};this._memPlugPinToMerge=(t,e,i,o)=>{};this._simPlugPinToUnitPin=(t,e,i,o,a,s,p=!0)=>{let d=this.getUnitPin(o,a,s);this._simSetExposedSubPin(t,e,a,i,d,p)};this._takeErr=()=>{if(this._errUnitIds.length>0){let t=this._errUnitIds[0];this._unit[t].takeErr()}};this._nextErr=()=>{if(this._errUnitIds.length>0){let t=this._errUnitIds[0],i=this.getUnit(t).getErr();this.err(i)}else this.takeErr()};this._destroy=()=>{A(this._unit,t=>t.destroy()),A(this._merge,t=>t.destroy())};this._reset=()=>{};this.specHasMerge=t=>!!this._spec.merges[t];this.getSpec=()=>this._spec;this.getComponentSpec=()=>this._spec.component;this.getUnits=()=>this._unit;this.exposeOutputSets=t=>{this._exposeOutputSets(t)};this._exposeOutputSets=t=>{A(t,this._exposeOutputSet)};this.exposeOutputSet=(t,e,i)=>{this.exposePinSet("output",e,t,i)};this._exposeOutputSet=(t,e,i)=>{this._exposePinSet("output",e,t,i)};this.exposeOutput=(t,e,i)=>{this.exposePin("output",i,t,e)};this.coverOutputSet=t=>{this.coverPinSet("output",t)};this.coverOutput=(t,e)=>{this.coverPin("output",e,t)};this.plugOutput=(t,e,i)=>{this.plugPin("input",i,t,e)};this.unplugOutput=(t,e)=>{this.unplugPin("output",e,t)};this._unplugOutput=(t,e)=>{this._unplugPin("output",e,t)};this.exposeInputSets=t=>{A(t,this.exposeInputSet)};this._exposeInputSets=t=>{A(t,this._exposeInputSet)};this._initInputSets=t=>{Nt(t,this._initPinSet.bind(this,"input"))};this._initOutputSets=t=>{Nt(t,this._initPinSet.bind(this,"output"))};this.exposeInputSet=(t,e,i)=>{this.exposePinSet("input",e,t,i)};this._exposeInputSet=(t,e,i)=>{this._exposePinSet("input",e,t,i)};this.exposePinSet=(t,e,i,o=void 0,a=!0,s=!0)=>{this._exposePinSet(t,e,i,o,s),o=this.getPin(t,e).peak(),a&&this.emit("expose_pin_set",t,e,i,o,[]),this._transacting&&this._transaction.push(Il(t,e,i,o))};this._exposePinSet=(t,e,i,o,a=!0)=>{let s=new Ut({data:o}),p=new Wt(this.__system),d=new Wt(this.__system);this._fork(),this._specExposePinSet(t,e,i),this._memExposePinSet(t,e,i,s,p,d),this._simExposePinSet(t,e,i,s,p,d,a)};this._initPinSet=(t,e,i,o=!0)=>{let{ref:a}=i,s=new Ut({ref:a}),p=new Wt(this.__system),d=new Wt(this.__system);this._memExposePinSet(t,e,i,s,p,d),this._simExposePinSet(t,e,i,s,p,d,o)};this._specExposePinSet=(t,e,i)=>{F(this._spec,[`${t}s`,e],i);let{plug:o}=i;A(o,(a,s)=>{this._specExposePin(t,e,s,a)})};this._memExposePinSet=(t,e,i,o,a,s)=>{let{plug:p}=i,d=_t(t);F(this._exposedPin,[t,e],o),F(this._exposedMerge,[t,e,t],a),F(this._exposedMerge,[t,e,d],s),A(p,(c,m)=>{this._memExposePin(t,e,m,c)})};this.isPinSetFunctional=(t,e)=>!!this._spec[`${t}s`][e].functional;this.exposePin=(t,e,i,o,a=!0,s=!0)=>{this._exposePin(t,e,i,o,s),a&&this.emit("expose_pin",t,e,i,o,[]),this._transacting&&this._transaction.push(Dl(t,e,i,o))};this._exposePin=(t,e,i,o,a=!0)=>{this._specExposePin(t,e,i,o),this._memExposePin(t,e,i,o),this._simExposePin(t,e,i,o,a)};this._specExposePin=(t,e,i,o)=>{this._specPlugPin(t,e,i,o)};this._memExposePin=(t,e,i,o)=>{this._memPlugPin(t,e,i,o)};this._simExposePin=(t,e,i,o,a=!0)=>{let{unitId:s,pinId:p,mergeId:d}=o;d||s&&p?this._simPlugPin(t,e,i,o,a):this._simPlugEmptyPin(t,e,i,a)};this.exposeInput=(t,e,i,o=!0)=>{this.exposePin("input",i,t,e,o)};this.coverInputSet=t=>{this.coverPinSet("input",t)};this.coverInput=(t,e)=>{this.coverPin("input",e,t)};this.coverPinSet=(t,e,i=!0)=>{let o=this.getExposedPinSpec(t,e);this._coverPinSet(t,e),i&&this.emit("cover_pin_set",t,e,o,void 0,[]),this._transacting&&this._transaction.push(vl(t,e,o))};this._coverPinSet=(t,e)=>{this._fork(),this._simCoverPinSet(t,e),this._memCoverPinSet(t,e),this._specCoverPinSet(t,e)};this._memCoverPinSet=(t,e)=>{let i=this.getExposedPinSpec(t,e),{plug:o}=i;A(o,(p,d)=>{this._memCoverPin(t,e,d)}),fe(this._exposedPin,[t,e]);let a=pt(this._exposedMerge,[t,e,"input"]),s=pt(this._exposedMerge,[t,e,"output"]);fe(this._exposedMerge,[t,e,"input"]),fe(this._exposedMerge,[t,e,"output"]),a.destroy(),s.destroy()};this._specCoverPinSet=(t,e)=>{let i=this.getExposedPinSpec(t,e),{plug:o}=i;A(o,(a,s)=>{this._specCoverPin(t,e,s)}),Ul({type:t,pinId:e},this._spec)};this._simCoverPinSet=(t,e)=>{let i=this.getExposedPinSpec(t,e),{plug:o}=i;A(o,(a,s)=>{this._simCoverPin(t,e,s)}),this.removePin(t,e)};this._specSetPinRef=(t,e,i)=>{F(this._spec,[`${t}s`,e,"ref"],i)};this._memPlugPin=(t,e,i,o)=>{let{mergeId:a,unitId:s,pinId:p,kind:d=t}=o,c;if(s&&p)(this.isUnitRefPin(s,d,p)||p===lt)&&(c=!0),this._memPlugPinToUnitPin(t,e,i,s,d,p);else if(a){let m=this.getMergeSpec(a);St(m,(f,g,h)=>{this.getUnit(f).hasRefPinNamed(g,h)&&(c=!0)}),this._mergeToSelfUnit[a]&&(c=!0),this._memPlugPinToMerge(t,e,i,a)}else this._memPlugEmptyPin(t,e,i);return c};this._specPlugPin=(t,e,i,o)=>{let{mergeId:a,unitId:s,pinId:p,kind:d=t}=o,c;if(s&&p)(this.isUnitRefPin(s,d,p)||p===lt)&&(c=!0);else if(a){let m=this.getMergeSpec(a);St(m,(f,g,h)=>{this.getUnit(f).isPinRef(g,h)&&(c=!0)}),this._mergeToSelfUnit[a]&&(c=!0)}c!==void 0&&this._specSetPinRef(t,e,c),Ll({type:t,pinId:e,subPinId:i,subPinSpec:o},this._spec)};this.plugPin=(t,e,i,o,a=!0,s=!0)=>{this._plugPin(t,e,i,o,s),a&&this.emit("plug_pin",t,e,i,o,[])};this._memRemoveEmptyPin=(t,e,i)=>{var o;delete this._exposedEmptySubPin[t][e][i],(o=this._exposedEmptySubPin[t])!=null&&o[e]&&ue(this._exposedEmptySubPin[t][e])===0&&delete this._exposedEmptySubPin[t][e]};this._simUnplugPinFromEmpty=(t,e,i)=>{this._simRemoveExposedSubPin(t,e,i)};this._plugPin=(t,e,i,o,a=!0)=>{let{mergeId:s,unitId:p,pinId:d,kind:c=t}=o;W(this._exposedEmptySubPin,[t,e,i],void 0)&&(this._simUnplugPinFromEmpty(t,e,i),this._memRemoveEmptyPin(t,e,i)),this._specPlugPin(t,e,i,o);let m=this._memPlugPin(t,e,i,o),f={ref:!!m};s?this._plugPinToMerge(t,e,i,s,f,a):p&&d&&this._plugPinToUnitPin(t,e,i,p,c,d,f,a),m!==void 0&&this.setPinRef(t,e,m)};this.isRefMerge=t=>{let e=this.getMergeSpec(t);return Ic(this,e)};this._simPlugPin=(t,e,i,o,a=!0)=>{let{mergeId:s,unitId:p,pinId:d,kind:c=t}=o;s?(a=a||this.isRefMerge(s),this._simPlugPinToMerge(t,e,i,s,a)):(a=a||this.isUnitPinRef(p,c,d),this._simPlugPinToUnitPin(t,e,i,p,c,d,a))};this.plugInput=(t,e,i)=>{this.plugPin("input",i,t,e)};this.unplugInput=(t,e)=>{this.unplugPin("input",e,t)};this._unplugInput=(t,e)=>{this._unplugPin("input",e,t)};this.coverPin=(t,e,i,o=!0)=>{let a=this.getSubPinSpec(t,e,i);this._coverPin(t,e,i),o&&this.emit("cover_pin",t,e,i,a,[]),this._transacting&&this._transaction.push(Sl(t,e,i,a))};this._coverPin=(t,e,i)=>{this._fork(),this._simCoverPin(t,e,i),this._memCoverPin(t,e,i),this._specCoverPin(t,e,i)};this._specCoverPin=(t,e,i)=>{wl({type:t,pinId:e,subPinId:i},this._spec)};this._memCoverPin=(t,e,i)=>{let a=this._spec[`${t}s`][e].plug[i],{mergeId:s}=a;t==="output"&&s&&this._memRemoveMergeOutput(s),this._memUnplugPin(t,e,i)};this._simCoverPin=(t,e,i)=>{let o=this.getSubPinSpec(t,e,i),{mergeId:a,unitId:s,pinId:p}=o;this._simUnplugPin(t,e,i),(a||s&&p)&&this._simRemoveExposedSubPin(t,e,i)};this.getSubPinSpec=(t,e,i)=>{var o,a,s;return(s=(a=(o=this._spec[`${t}s`])==null?void 0:o[e])==null?void 0:a.plug)==null?void 0:s[i]};this.unplugPin=(t,e,i,o=!0,a=!0)=>{let s=this.getSubPinSpec(t,e,i);this._unplugPin(t,e,i,a),o&&this.emit("unplug_pin",t,e,i,s,[])};this._unplugPin=(t,e,i,o=!0)=>{this._fork();let a=this.getSubPinSpec(t,e,i);this._simUnplugPin(t,e,i,o),this._memUnplugPin(t,e,i),this._specUnplugPin(t,e,i);let{mergeId:s}=a;s&&this.getMergePinCount(s)===0&&this._removeMerge(s,!1)};this._specUnplugPin=(t,e,i)=>{Gl({type:t,pinId:e,subPinId:i},this._spec)};this._memUnplugPin=(t,e,i)=>{let o=this.getSubPinSpec(t,e,i);if(o.unitId&&o.pinId&&Vt(this._pinToPlug,[o.unitId,t,o.pinId]),t==="output"){let{mergeId:s}=o;s&&this._memRemoveMergeOutput(s)}};this._ensureEmptySubPin=(t,e,i)=>{let o=W(this._exposedEmptySubPin,[t,e,i],null);return o||(o=new Ut,F(this._exposedEmptySubPin,[t,e,i],o)),o};this._memPlugEmptyPin=(t,e,i)=>{let o=this._ensureEmptySubPin(t,e,i);this._memSetExposedSubPin(t,e,i,o)};this._simUnplugPin=(t,e,i,o=!0)=>{this.__simUnplugPin(t,e,i,o),this._simPlugEmptyPin(t,e,i)};this.__simUnplugPin=(t,e,i,o=!0)=>{let a=this.getSubPinSpec(t,e,i),{mergeId:s,unitId:p,pinId:d,kind:c=t}=a,m=t==="output";m&&s&&this._simRemoveMergeOutput(s);let f=this.getPin(t,e),g=this.hasRefPinNamed(t,e);if(s)this._simUnplugPinFromMerge(t,e,i,s);else if(p&&d){let h=this.getUnit(p),x=h.isPinRef(t,d);this._simUnplugPinFromUnitPin(t,e,i,p,d,c),o&&x&&(m?f.take():h.takePin(t,d))}if(g){let h=_t(t),x=pt(this._exposedMerge,[t,e,t]),y=pt(this._exposedMerge,[t,e,h]);x.reset(),y.reset()}};this._simPlugEmptyPin=(t,e,i,o=!0)=>{let a=this._ensureEmptySubPin(t,e,i);this._simSetExposedSubPin(t,e,t,i,a,o)};this._memUnplugInput=(t,e)=>this._memUnplugPin("input",t,e);this._memUnplugOutput=(t,e)=>this._memUnplugPin("output",t,e);this._simUnplugInput=(t,e)=>this._simUnplugPin("input",t,e);this._simUnplugOutput=(t,e)=>this._simUnplugPin("output",t,e);this.getExposedPin=(t,e)=>t==="input"?this.getExposedInputPin(e):this.getExposedOutputPin(e);this.getExposedInputPin=t=>pt(this._exposedPin,["input",t]);this.getExposedOutputPin=t=>pt(this._exposedPin,["output",t]);this.getUnitOuterSpec=t=>{let e={merges:{input:{},output:{}},exposed:{input:{},output:{}}},i=this._unitToMerge[t]||new Set,o=this._unitToMergeCount[t]||0;for(let a of i){let s=o[a];this._forEachUnitPinOnMerge(t,a,(p,d)=>{if(this.getMergePinCount(a)-s<2){let m=this.getMergeSpec(a),f=at(Gf(m,t)),g=m[f],h,x;g.input?(h="input",x=at(g.input)):(h="output",x=at(g.output)),F(e.merges,[p,d],{mergeId:a,otherPin:{unitId:f,type:h,pinId:x}})}else F(e.merges,[p,d],{mergeId:a,otherPin:null})})}return e};this.getGraphPinData=()=>{let t={};return A(this._unit,(e,i)=>{let o=e.getPinsData();t[i]=o}),t};this.getGraphMergeInputData=()=>{let t={};return A(this._merge,(e,i)=>{let o=At(i,"input"),a=this._pin[o];if(a){if(this.getMergePinCount(i)===0)return;let s=a.peak();t[i]=s}}),t};this.getGraphErr=()=>{let t={};return A(this._unit,(e,i)=>{let o=e.getErr();t[i]=o}),t};this.getUnitInputData=t=>this.getUnit(t).getInputData();this.addUnit=(t,e,i,o=!0)=>{this._addUnit(t,e,i);let a=i!=null?i:e.getUnitBundleSpec();o&&this.emit("add_unit",t,a,e,[]),this._transacting&&this._transaction.push(_l(t,a))};this._addUnit=(t,e,i=null)=>{if(this._fork(),this._unit[t])throw new Error("duplicated unit id "+t);return i=i!=null?i:e.getUnitBundleSpec(!1),this.__system.injectSpecs(i.specs),this.emit("before_add_unit",t,e,[]),this._specAddUnit(t,e,i),this._memAddUnit(t,e,i),this._simAddUnit(t,i,e),e};this.addUnitSpecs=t=>{this._addUnitSpecs(t)};this._addUnitSpecs=t=>{A(t,(e,i)=>{this._addUnitBundleSpec(i,{unit:e})})};this.injectSubComponent=(t,e,i)=>{this._specInjectSubComponent(t),this._simInjectSubComponent(t,e,i)};this._simInjectSubComponent=(t,e,i)=>{let{classes:o}=this.__system,{children:a=[]}=e;for(let s of a){let{id:p}=s,d=le(p,this.__system.specs,o);i.appendChild(d)}};this._injectSubComponent=(t,e,i)=>{let{classes:o}=this.__system,{children:a=[]}=e;for(let s of a){let{id:p}=s,d=le(p,this.__system.specs,o);i.appendChild(d)}this._specInjectSubComponent(t)};this._specInjectSubComponent=t=>{F(this._spec,["component","subComponents",t],{children:[]})};this.componentAppend=(t,e)=>{this._specAppendRoot(t),this.emit("component_append",t,e,[])};this._specAppendRoot=t=>{this._spec.component.children=this._spec.component.children||[],this._spec.component.children.push(t)};this.componentRemove=t=>{this._specComponentRemoveChild(t),this.emit("component_remove",t,[])};this._specComponentRemoveChild=t=>{let e=this._spec.component.children.indexOf(t);this._spec.component.children.splice(e,1)};this.removeSubComponent=t=>{this._specRemoveSubComponent(t)};this._specRemoveSubComponent=t=>{let{subComponents:e}=this._spec.component,i=e[t],{children:o=[]}=i;for(let a of o)this._spec.component.children.push(a);delete e[t]};this._getSubComponentParentId=t=>sm(this._spec,t);this._getSubComponentSlotName=t=>{let e=this._getSubComponentParentId(t);return W(this._spec,["component","subComponents",e,"childSlot",t],"default")};this._appendSubComponentChild=(t,e,i)=>{this._fork(),this._specSubComponentAppendChild(t,e,i),this._simSubComponentAppendChild(t,e,i)};this._insertSubComponentChild=(t,e,i,o)=>{this._fork(),this._specSubComponentInsertChild(t,e,i,o),this._simSubComponentInsertChild(t,e,i,o)};this._simRemoveSubComponentFromParent=t=>{let e=this._getSubComponentParentId(t);e?this._simSubComponentRemoveChild(e,t):this._simRemoveRoot(t)};this._specRemoveSubComponentChild=(t,e)=>{let i=this._spec.component.subComponents[t],{children:o=[],childSlot:a={}}=i,s=o.indexOf(e);o.splice(s,1),delete a[e],i.children=o,i.childSlot=a};this._specRemoveSubComponentFromParent=t=>{let e=this._getSubComponentParentId(t);e?this._specRemoveSubComponentChild(e,t):this._specRemoveRoot(t)};this._simSubComponentRemoveChild=(t,e)=>{let i=this.getUnit(t),o=this.getUnit(e);i.removeParentChild(o),this.registerRoot(o)};this._specSubComponentAppendChild=(t,e,i)=>{let o=this._spec.component.subComponents[t],{children:a=[],childSlot:s={}}=o;a.push(e),s[e]=i,o.children=a,o.childSlot=s};this._specSubComponentInsertChild=(t,e,i,o)=>{let a=this._spec.component.subComponents[t],{children:s=[],childSlot:p={}}=a;s.splice(i,0,e),p[e]=o,a.children=s,a.childSlot=p};this._simSubComponentAppendChild=(t,e,i)=>{let o=this.getUnit(t),a=this.getUnit(e);o.registerParentRoot(a,i)};this._simSubComponentInsertChild=(t,e,i,o)=>{let a=this.getUnit(t),s=this.getUnit(e);a.registerParentRoot(s,o)};this._unitUnlisten={};this.addUnitBundle=(t,e)=>{this._addUnitBundle(t,e)};this._addUnitBundle=(t,e)=>{};this.setUnitPin=(t,e,i)=>{let o=this.getUnit(t),a=Jt(t,e,i),s=o.getPin(e,i);this._pin[a]=s,this._unitPins[a]=s};this.setUnitInput=(t,e)=>{this.setUnitPin(t,"input",e)};this.setUnitOutput=(t,e)=>{this.setUnitPin(t,"output",e)};this._on_unit_element=(t,e,i)=>{this.injectSubComponent(t,e,i)};this._on_unit_not_element=t=>{this._specRemoveSubComponent(t)};this._simRemoveUnit=(t,e=!0)=>{var a;let i=this.getUnit(t);i.hasErr()&&this._removeErrUnit(t);let o=this.getExposedOutput({unitId:t,pinId:lt,kind:"output"});if(this._simUnplugUnit(t,e),e&&o&&this.takeOutput(o),i.isElement()){let s=(a=this._spec.component)==null?void 0:a.subComponents[t],{children:p=[]}=s;for(let d of p)this._simSubComponentRemoveChild(t,d);this._simRemoveSubComponentFromParent(t)}};this._subComponentRemoveChild=(t,e)=>{this._simSubComponentRemoveChild(t,e),this._specRemoveSubComponentChild(t,e)};this._specUnplugUnit=t=>{let{merges:e}=this._spec,i=j(e);te(i,(o,a,s,p)=>{var c,m,f;let d=j(this.getMergeSpec(o));if(a===t&&d)if(delete d[t],Kt(d)<2){let h=this.findMergeExposedSubPin("input",o),x=this.findMergeExposedSubPin("output",o),y=j(this.getMergeSpec(o));delete y[t];let I=at(y),v=at((c=y==null?void 0:y[I])!=null?c:{}),T=at((f=(m=y==null?void 0:y[I])==null?void 0:m[v])!=null?f:{});this._specRemoveMerge(o),h&&this._specPlugPin("input",h.pinId,h.subPinId,{unitId:I,pinId:T,kind:v}),x&&this._specPlugPin("output",x.pinId,x.subPinId,{unitId:I,pinId:T,kind:v})}else this._specRemoveUnitFromMerge(t,o)}),this._forEachSpecPinPlug((o,a,s,p)=>{p.unitId===t&&this._specUnplugPin(o,a,s)})};this._unplugUnit=(t,e)=>{this._simUnplugUnit(t,e),this._memUnplugUnit(t),this._specUnplugUnit(t)};this._simUnplugUnit=(t,e)=>{var a,s,p,d;let i=this._unitToMerge[t]||new Set,o=this._unitToMergeCount[t]||{};for(let c of i){let m=o[c];if(this.getMergePinCount(c)-m<2){let g=this.findMergeExposedSubPin("input",c),h=this.findMergeExposedSubPin("output",c),x=j(this.getMergeSpec(c));delete x[t];let y=at(x),I=at((a=x==null?void 0:x[y])!=null?a:{}),v=at((p=(s=x==null?void 0:x[y])==null?void 0:s[I])!=null?p:{});this._simRemoveMerge(c,e),g&&this._simPlugPin("input",g.pinId,g.subPinId,{unitId:y,pinId:v,kind:(d=g.kind)!=null?d:"input"},!1),h&&this._simPlugPin("output",h.pinId,h.subPinId,{unitId:y,pinId:v,kind:I},!1)}else this._simRemoveUnitFromMerge(t,c,e)}this._forEachSpecPinPlug((c,m,f,g)=>{g.unitId===t&&this._simUnplugPin(c,m,f,e)})};this.addMerges=t=>{A(t,this.addMerge)};this._addUnitMerges=(t,e=!0)=>{A(t,(i,o)=>{this.hasMerge(o)?St(i,(a,s,p)=>{this.hasMergePin(o,a,s,p)||this._addPinToMerge(o,a,s,p,e)}):this._addMerge(i,o,void 0,e)})};this._addMerges=(t,e=!0)=>{A(t,(i,o)=>{this._addMerge(i,o,void 0,e)})};this._initMerges=t=>{Nt(t,this._initMerge)};this._initMerge=(t,e)=>{let i=this._createMerge(t);this._memAddMerge(t,e,i),this._simAddMerge(t,e,i)};this.addMerge=(t,e,i=!0,o=!0,a)=>{a=this._addMerge(t,e,a,o),i&&this.emit("add_merge",e,t,a,[]),this._transacting&&this._transaction.push(El(e,t))};this._createMerge=t=>{let e=new Wt(this.__system),i=At(t,"input"),o=new Ut;return e.addInput(i,o),e};this._pinToPlug={};this._addMerge=(t,e,i=null,o=!0)=>{this._fork(),i=i!=null?i:this._createMerge(e),this.emit("before_add_merge",e,t,i,[]);let a=[];return St(t,(s,p,d)=>{let c=W(this._pinToPlug,[s,p,d],void 0);c&&(a.push({type:p,pinId:c.pinId,subPinId:c.subPinId}),this._unplugPin(p,c.pinId,c.subPinId,!1))}),this._specAddMerge(e,t,i),this._memAddMerge(e,t,i),this._simAddMerge(e,t,i,o),Tt(a,s=>{this._plugPin(s.type,s.pinId,s.subPinId,{mergeId:e},o)}),i};this._specAddMerge=(t,e,i)=>{F(this._spec,["merges",t],e),A(e,({input:o,output:a},s)=>{A(o||{},(p,d)=>{this._specAddPinToMerge(t,s,"input",d)}),A(a||{},(p,d)=>{this._specAddPinToMerge(t,s,"output",d)})})};this._memAddMerge=(t,e,i)=>{this._merge[t]=i,A(e,({input:o,output:a},s)=>{A(o||{},(p,d)=>{this._memAddPinToMerge(t,s,"input",d)}),A(a||{},(p,d)=>{this._memAddPinToMerge(t,s,"output",d)})})};this.addPinToMerge=(t,e,i,o,a=!0,s=!0)=>{this._addPinToMerge(t,e,i,o,s),a&&this.emit("add_pin_to_merge",t,e,i,o,[])};this._addPinToMerge=(t,e,i,o,a=!0)=>{this._validateMergeId(t),this._validateUnitId(e);let s=W(this._pinToPlug,[e,i,o],void 0);s&&this._unplugPin(i,s.pinId,s.subPinId,a),this._specAddPinToMerge(t,e,i,o),this._memAddPinToMerge(t,e,i,o),this._simAddPinToMerge(t,e,i,o,a),s&&this._plugPin(i,s.pinId,s.subPinId,{mergeId:t},a)};this._simRemoveAllPlugsFromMerge=(t,e=!0)=>{this._forEachSpecPinPlug((i,o,a,s)=>{s.mergeId===t&&this._simUnplugPin(i,o,a,e)})};this.__simRemoveAllPlugsFromMerge=t=>{this._forEachSpecPinPlug((e,i,o,a)=>{a.mergeId===t&&this._simUnplugPin(e,i,o)})};this._forEachSpecPinPlug=t=>{this._forEachSpecPinOfType("input",(e,i,o)=>{t("input",e,i,o)}),this._forEachSpecPinOfType("output",(e,i,o)=>{t("output",e,i,o)})};this._forEachSpecPinOfType=(t,e)=>{A(this._spec[`${t}s`]||{},({plug:i},o)=>{for(let a in i){let s=i[a];e(o,a,s)}})};this._simRemoveAllPinsFromMerge=(t,e)=>{let i=j(this._spec.merges[t]);A(i,({input:o,output:a},s)=>{A(a||{},(p,d)=>{this._simRemovePinFromMerge(t,s,"output",d,e)}),A(o||{},(p,d)=>{this._simRemovePinFromMerge(t,s,"input",d,e)})})};this._settingUnitData=!1;this._getUnitPinPlug=(t,e,i)=>{let o;return Tn(this._spec,e,(a,s)=>{let{plug:p}=s;for(let d in p){let c=p[d];c.unitId===t&&c.pinId===a&&(o={type:e,pinId:a,subPinId:d})}}),o};this._newMergeId=()=>{let t=0,e=`${t}`;for(;this.hasMerge(e);)t++,e=`${t}`;return e};this._movePlugInto__inject=(t,e,i,o,a,s,p,d,c)=>{let m=this.getGraph(t),f=W(c,["plug",e,i,o,"type"],e),g=W(s,[e,i,o],{})};this._movePlugInto__reconnect=(t,e,i,o,a,s,p,d,c,m)=>{let f=_t(e),g=W(s,[e,i,o,"pinId"],i),h=pt(m,[e,i,o]),x=W(c,["plug",e,i,o,"type"],e),y=this.getGraph(t),I=W(s,[e,i,o],{});if(y.hasPinNamed(x,i)?y.exposePin(x,i,o,I,!1):(y.exposePinSet(x,i,{plug:{[o]:I}},!1),h.active()&&y.setPinData(x,i,h.peak())),a.unitId&&a.pinId){let v=W(c,["link",a.unitId,a.type,i,"mergeId"],null);v?this._addPinToMerge(v,t,x,g):(v=W(c,["plug",e,i,o,"mergeId"],null),v&&this._addMerge({[t]:{[x]:{[g]:!0}},[a.unitId]:{[e]:{[a.pinId]:!0}}},v,void 0,!1))}else if(a.mergeId){let v=W(d,["merge",a.mergeId,e],null);if(v)this._addPinToMerge(v,t,x,g,!1);else{let T=W(c,["plug",e,i,o,"mergeId"],null);T&&this._addPinToMerge(T,t,x,g)}}};this._transacting=!1;this._transaction=[];this.endTransaction=()=>{if(!this._transacting)throw new Error("transaction not started");this.emit("bulk_edit",this._transaction,!0,[]),this._transacting=!1};this._isUnitComponent=t=>this.getUnit(t).isElement();this._root=[];this._parent_root=[];this._parent_children=[];this._slot={};this._spec=t,this._spec.id||i.newSpec(this._spec);let a=ut(i.specs,{[o]:t});this._specs=a;let{inputs:s={},outputs:p={},units:d={},merges:c={},component:m={},render:f=!1}=this._spec;this._branch=e,this._initAddUnits(d),this._initMerges(c),this._initInputSets(s),this._initOutputSets(p),this._initSetComponent(m),this._element=f,this.addListener("reset",this._reset),this.addListener("play",this._play),this.addListener("pause",this._pause),this.addListener("destroy",this._destroy),this.addListener("take_err",this._takeErr),this.addListener("take_caught_err",this._takeErr);let g=ce(s,({functional:I})=>!!I),h=et(g),x=ce(p,({functional:I})=>!!I),y=et(x);this._waitAll={input:new Cn(this.__system),output:new Cn(this.__system)},Tt(h,I=>{this._plugToWaitAll("input",I)}),Tt(y,I=>{this._plugToWaitAll("output",I)})}onInputRenamed(t,e,i,o){super.onInputRenamed(t,e,i,o),this._onPinSetRenamed("input",t,e,i,o)}onOutputRenamed(t,e,i,o){super.onOutputRenamed(t,e,i,o),this._onPinSetRenamed("output",t,e,i,o)}isUnitPinConstant(t,e,i){return this.getUnit(t).isPinConstant(e,i)}isUnitPinRef(t,e,i){return this.getUnit(t).isPinRef(e,i)}getUnitPinData(t,e,i){return this.getUnit(t).getPinData(e,i)}removeUnitPinData(t,e,i){this._removeUnitPinData(t,e,i),this.emit("remove_unit_pin_data",t,e,i,[])}removeMergeData(t){this._removeMergeData(t)}setMergeData(t,e){this._setMergeData(t,e)}_setMergeData(t,e){this._ensureMergePin("input",t).push(e)}_removeMergeData(t){this._ensureMergePin("input",t).take()}_removeUnitPinData(t,e,i){this.getUnit(t).removePinData(e,i)}_setBranch(t,e,i,o){this._memSetBranch(t,e,i),this._simSetBranch(t,e,i,o)}_memSetBranch(t,e,i){e==="input"?this._pipedTo[i]=t:this._pipedFrom[i]=t}_simSetBranch(t,e,i,o){let a=this._merge[t];if(e==="input"){let s=this._pin[i];a.setOutput(i,s,{},o)}else{let s=this._pin[i];a.setInput(i,s,{},o)}}_memRemoveBranch(t,e,i){e==="input"?delete this._pipedTo[i]:delete this._pipedFrom[i]}_simRemoveBranch(t,e,i){e==="input"?this._merge[t].removeOutput(i):this._merge[t].removeInput(i)}_removeBranch(t,e,i){this._simRemoveBranch(t,e,i),this._memRemoveBranch(t,e,i)}_setExposedSubPin(t,e,i,o,a,s,p=!0){this._simSetExposedSubPin(t,e,i,o,a,p)}_memSetExposedSubPin(t,e,i,o){}_simSetExposedSubPin(t,e,i,o,a,s=!0){let p=_t(t),d=pt(this._exposedMerge,[t,e,t]),c=pt(this._exposedMerge,[t,e,p]);t===i||W(this._exposedEmptySubPin,[t,e,o],void 0)?d.setPin(p,o,a,{},s):c.setPin(t,o,a,{},s)}_simRemoveExposedSubPin(t,e,i){let o=this.getSubPinSpec(t,e,i),{kind:a=t}=o,s=_t(t),p=pt(this._exposedMerge,[t,e,t]),d=pt(this._exposedMerge,[t,e,s]);t===a||W(this._exposedEmptySubPin,[t,e,i],void 0)?p.removePin(s,i):d.removePin(t,i)}_play(){A(this._unit,t=>t.play()),Tt(this._children,t=>t.play())}_pause(){A(this._unit,t=>t.pause()),Tt(this._children,t=>t.pause())}_removeErrUnit(t){let e=this._errUnitIds.indexOf(t);this._errUnitIds.splice(e,1),e===0&&this._nextErr()}_validateMergeId(t){if(!this._spec.merges[t])throw new yc}_validateUnitId(t){if(!this._spec.units[t])throw new _c}isElement(){return!!this._element}setElement(){this._element=!0,this.emit("element",[])}setNotElement(){this._element=!1,this.emit("not_element",[])}getBundleSpec(t=!1){let{spec:e,specs:i}=tn(this._spec,this._specs),o;return t&&(o=this.snapshot(),Nt(this._unit,(a,s)=>{let p=s.snapshot();F(e,["units",a,"memory"],p)})),{spec:e,specs:i}}getUnitBundleSpec(t=!1){let{id:e}=this,i=this.getInputs(),o=this.getOutputs(),a=f=>Vu(f,(g,h)=>{let y=h.peak();return y instanceof C&&(y=null),{constant:h.constant(),ignored:h.ignored(),data:y===void 0?void 0:Y(y)}}),s=a(i),p=a(o),d;return t&&(d=this.snapshot(),ke(d)),ec({id:e,input:s,output:p,memory:d},this._specs)}snapshotSelf(){let t={unit:{},merge:{},exposedMerge:{},waitAll:null};for(let e in this._unit){let o=this._unit[e].snapshot();t.unit[e]=o}for(let e in this._merge){let o=this._merge[e].snapshot();t.merge[e]=o}return Bt(this._exposedMerge,(e,i)=>{let o=_t(e),a=pt(this._exposedMerge,[e,i,e]),s=pt(this._exposedMerge,[e,i,o]),p=a.snapshot(),d=s.snapshot();F(t.exposedMerge,[e,i,e],p),F(t.exposedMerge,[e,i,o],d)}),t.waitAll=this._waitAll.input.snapshot(),t}restoreSelf(t){var i,o;super.restoreSelf(t);for(let a in this._unit){let s=this._unit[a],p=(i=t.unit)==null?void 0:i[a];p&&s.restore(p)}for(let a in this._merge){let s=this._merge[a],p=(o=t.merge)==null?void 0:o[a];p&&s.restore(p)}Bt(this._exposedMerge,(a,s)=>{let p=_t(a);if(this.hasDataPinNamed(a,s)){let d=pt(this._exposedMerge,[a,s,a]),c=pt(this._exposedMerge,[a,s,p]),m=W(t,["exposedMerge",a,s,a],void 0),f=W(t,["exposedMerge",a,s,p],void 0);m&&d.restore(m),f&&c.restore(f)}});let e=t.waitAll;e&&this._waitAll.input.restore(e)}getGraphUnitSpec(t){return this._spec.units[t]}isExposedOutput(t){let e=this._spec.outputs||{},i=this._getExposedSubPinNodeId("output",t);return hn(e,({plug:o})=>hn(o,a=>this._getExposedSubPinNodeId("output",a)===i))}getExposedOutput(t){let e=this._spec.outputs||{},i=this._getExposedSubPinNodeId("output",t);for(let o in e){let a=e[o],{plug:s}=a;for(let p in s){let d=s[p];if(this._getExposedSubPinNodeId("output",d)===i)return o}}}setUnitSize(t,e,i,o=!0){this._setUnitSize(t,e,i)}setSubComponentSize(t,e,i,o=!0){this._setSubComponentSize(t,e,i)}setComponentSize(t,e,i,o=!0){this._setComponentSize(e,i)}_simExposePinSet(t,e,i,o,a,s,p=!0){let{plug:d,ref:c}=i,m=_t(t);a.setPin(t,e,o),s.setPin(m,e,o),this.setPin(t,e,o,{ref:c},p),A(d,(f,g)=>{this._simExposePin(t,e,g,f,p)})}setPinSetFunctional(t,e,i,o=!0){if(t==="output")throw new Error("cannot set output pin set functional");this._setPinSetFunctional(t,e,i),o&&this.emit("set_pin_set_functional",t,e,i,[])}_setPinSetFunctional(t,e,i){this._fork(),this._specSetPinSetFunctional(t,e,i),this._memSetPinSetFunctional(t,e,i),this._simSetPinSetFunctional(t,e,i)}_specSetPinSetFunctional(t,e,i){Rl({type:t,pinId:e,functional:i},this._spec)}_memSetPinSetFunctional(t,e,i){F(this._i_opt,[t,e,"functional"],i)}_simSetPinSetFunctional(t,e,i){let o=this.isPinSetFunctional(t,e);!o&&i?this._plugToWaitAll(t,e):o&&!i&&this._unplugFromWaitAll(t,e)}setPinSetId(t,e,i,o=!0){this._setPinSetId(t,e,i),this.renamePin(t,e,i),o&&this.emit("set_pin_set_id",t,e,i,[])}_setPinSetId(t,e,i){this._fork();let o=this._spec[`${t}s`][e];delete this._spec[`${t}s`][e],this._spec[`${t}s`][i]=o}isExposedInput(t){let{inputs:e={}}=this._spec,i=this._getExposedSubPinNodeId("input",t);return hn(e,({plug:o})=>hn(o,a=>this._getExposedSubPinNodeId("input",a)===i))}getExposedPinSpecs(){return{input:this.getExposedInputSpecs(),output:this.getExposedOutputSpecs()}}getExposedPinSpec(t,e){return t==="input"?this.getExposedInputSpec(e):this.getExposedOutputSpec(e)}isExposedInputPinId(t){return!!(this._spec.inputs||{})[t]}isExposedOutputPinId(t){return!!(this._spec.outputs||{})[t]}getExposedInputSpec(t){return(this._spec.inputs||{})[t]}getPlugSpec(t,e,i){return this._spec[`${t}s`][e].plug[i]}getExposedInputSpecs(){return this._spec.inputs||{}}getExposedOutputSpec(t){return(this._spec.outputs||{})[t]}getExposedOutputSpecs(){return this._spec.outputs||{}}hasUnit(t){return!!this._unit[t]}hasMerge(t){return bl(this._spec,t)}hasMergePin(t,e,i,o){return gl(this._spec,t,e,i,o)}hasPlug(t,e,i){return!!this.getSubPinSpec(t,e,i)}getUnit(t){if(!this._unit[t])throw new Error("cannot find unit");return this._unit[t]}getGraph(t){return this.getUnit(t)}removeUnitGhost(t,e,i,o=!0){let a=this._removeUnitGhost(t,e,i),{specId:s,bundle:p}=a;return o&&this.emit("remove_unit_ghost",t,e,p,[]),a}addUnitGhost(t,e,i,o,a=!0){this._addUnitGhost(t,e,i,o),a&&this.emit("add_unit_ghost",t,e,i,[])}_addUnitGhost(t,e,i,o){let{specs:a}=i;this.__system.injectSpecs(a);let s=this.getUnitOuterSpec(t);this._removeUnit(t,!1),this._addUnitBundleSpec(e,i),Bt(s.merges,(p,d,{mergeId:c,otherPin:m,exposedPin:f})=>{let g=W(o,[p,d],d);m?this._addMerge({[m.unitId]:{[m.type]:{[m.pinId]:!0}},[e]:{[p]:{[g]:!0}}},c,null):this._addPinToMerge(c,e,p,g),f&&this._plugPin(f.type,f.pinId,f.subPinId,{mergeId:c})}),Bt(s.exposed,(p,d,c)=>{let m=W(o,[p,d],d);this._plugPin(c.type,c.pinId,c.subPinId,{unitId:e,pinId:m,kind:c.type})})}_removeUnitGhost(t,e,i,o=!0){let{specs:a}=this.__system,{id:s}=this.__system.newSpec(i),p=this.getUnitOuterSpec(t),d=this.getGraphUnitSpec(t),c=this._removeUnit(t,!1),m=ec(d,a);return this._addUnitBundleSpec(e,{unit:{id:s}}),Bt(p.merges,(f,g,{mergeId:h,otherPin:x,exposedPin:y})=>{x?this._addMerge({[x.unitId]:{[x.type]:{[x.pinId]:!0}},[e]:{[f]:{[g]:!0}}},h,null):this._addPinToMerge(h,e,f,g),y&&this._plugPin(y.type,y.pinId,y.subPinId,{mergeId:h})}),Bt(p.exposed,(f,g,h)=>{this._plugPin(h.type,h.pinId,h.subPinId,{unitId:e,pinId:g,kind:h.type})}),o&&(m.unit.memory=c.snapshot()),{specId:s,bundle:m}}swapUnitGhost(t,e,i){this._removeUnit(t),this._addUnitBundleSpec(e,i);let a=this.getUnit(t).snapshot(),s=ve({}),{id:p}=this.__system.newSpec({});return{spec_id:p,state:a}}getUnitByPath(t){let e=this;for(let i of t)e=e.getUnit(i);return e}read(){return this.getGraphState()}write(t){this.setGraphState(t)}setGraphState(t){return b(this,null,function*(){for(let e in t){let i=this.getUnit(e)}})}getUnitState(t){let e=this.getUnit(t);return null}getGraphState(){return{}}getGraphChildren(){let t={};for(let e in this._unit){let i=this.getUnit(e);if(i.isElement()){let o=i.refChildren();o!==void 0&&(t[e]=o)}}return t}getUnitPin(t,e,i){return this.getUnit(t).getPin(e,i)}getUnitData(t,e,i){return this.getUnit(t).getPinsData()}getMergeData(t){let e=this.getMerge(t);return e?e.getData():void 0}getUnitInput(t,e){return this.getUnit(t).getInput(e)}getUnitOutput(t,e){return this.getUnit(t).getOutput(e)}setUnitErr(t,e){this.getUnit(t).err(e)}takeUnitErr(t){return this._takeUnitErr(t)}_takeUnitErr(t){return this.getUnit(t).takeErr()}getMerges(){return this._merge}refPins(){return{input:this._input,output:this._output}}getPlugs(){let t={input:{},output:{}};return this._forEachSpecPinPlug((e,i,o,a)=>{let s=this.getPlug(e,i,o);F(t,[e,i,o],s)}),t}getPlugSpecs(){return ml(this._spec)}getPlug(t,e,i){let o=_t(t);return pt(this._exposedMerge,[t,e,t]).getPin(o,i)}getMerge(t){return this._merge[t]}refExposedMerges(){return this._exposedMerge}getUnitCount(){return et(this._unit).length}getMergeCount(){return et(this._merge).length}findMergeExposedSubPin(t,e){let i=null;return this._forEachSpecPinOfType(t,(o,a,s)=>{var p;s.mergeId===e&&(i={pinId:o,subPinId:a,type:t,kind:(p=s.kind)!=null?p:t})}),i}getUnitsSpec(){let{units:t}=this._spec;return t}getMergesSpec(){let{merges:t={}}=this._spec;return t}getMergeSpec(t){let{merges:e}=this._spec;return e[t]}getMergeUnitCount(t){let e=this.getMergeSpec(t);return et(e).length}getMergePinCount(t){var e;return(e=this._mergePinCount[t])!=null?e:0}getPinPlugCount(t,e){let i=this.getExposedPinSpec(t,e);return zu(i.plug||{})}fork(t,e=!0){this._fork(t,e)}_fork(t,e=!0){var i;if(this._spec.system||((i=this.__system.specsCount[this.id])!=null?i:0)>1){let[o,a]=this.__system.forkSpec(this._spec,t);this.__system.unregisterUnit(this.id),this.id=o,this._spec=a,this.__system.registerUnit(o),e&&this.emit("fork",o,j(a),[])}}_initAddUnit(t,e){let i=ec(e,this.__system.specs),o=An(this.__system,i,this._specs,this._branch);this._memAddUnit(t,o),this._simAddUnit(t,{unit:e},o,!1)}_initAddUnits(t){A(t,(e,i)=>{this._initAddUnit(i,e)})}addUnitSpec(t,e,i=!0){let o=An(this.__system,e,this._specs,this._branch);return this.addUnit(t,o,e,i),o}_addUnitSpec(t,e,i=!0){let o=An(this.__system,e,this._specs,this._branch);return this._addUnit(t,o,e),o}_addUnitBundleSpec(t,e){let i=An(this.__system,e,this._specs,this._branch);return this._addUnit(t,i),i}_onUnitErr(t,e){let i=this._errUnitIds.indexOf(t);i>-1?i===0&&this.err(e):(this._errUnitIds.push(t),this._errUnitIds.length===1&&this.err(e))}_specAddUnit(t,e,i=null){i=i!=null?i:e.getUnitBundleSpec();let{unit:o}=i;F(this._spec,["units",t],o),e.isElement()&&(this._specInjectSubComponent(t),this._specAppendRoot(t))}_memAddUnit(t,e,i=null){i=i!=null?i:e.getUnitBundleSpec();let{unit:o}=i,a=[];e.setParent(this),this._unit[t]=e;let s=(U,B)=>{let J=Jt(t,U,B),q=this._pipedTo[J],w=this._pipedFrom[J],E=hl(this._spec,t,U,B);q&&this._removePinOrMerge(q,t,U,B),w&&this._removePinOrMerge(w,t,U,B),E&&this._unplugPin(U,E.pinId,E.subPinId),delete this._pipedTo[J],delete this._pipedFrom[J],delete this._pin[J],delete this._unitPins[J],Vt(this._spec,["units",t,U,B]),Vt(this._spec,["units",t,"memory",U,B])},p=U=>{s("input",U)},d=U=>{s("output",U)},c=(U,B,J)=>{let q=Jt(t,U,B),w=Jt(t,U,J),E=W(this._pinToMerge,[t,U,B],null);if(E){let $=this.getMerge(E),G=_t(U);$.renamePin(G,q,w),F(this._pinToMerge,[t,U,J],E),delete this._pinToMerge[t][U][B],this._pipedTo[q]&&(this._pipedTo[w]=this._pipedTo[q],delete this._pipedTo[q]),this._pipedFrom[q]&&(this._pipedFrom[w]=this._pipedFrom[q],delete this._pipedFrom[q]),jl({unitId:t,type:U,pinId:B,newPinId:J},this._spec)}this._pin[w]=this._pin[q],delete this._pin[q]},m=e.getInputNames(),f=e.getOutputNames(),g=this.setUnitInput.bind(this,t),h=this.setUnitOutput.bind(this,t);Tt(m,g),Tt(f,h);let x={},y=(U,B,J,q=!0)=>{if(J===void 0)return;let w=this.getUnitPin(t,U,B);q&&this._fork(),this._specSetUnitPinData(t,U,B,J);let E=w.addListener("data",$=>{this._settingUnitData||(this._specSetUnitPinData(t,U,B,$),this.emit("set_unit_pin_data",t,U,B,$,[]))});F(x,[t,U,B],E),a.push(E)};Tt(m,U=>{e.isPinConstant("input",U)&&y("input",U,e.getPinData("input",U),!1)}),Tt(f,U=>{e.isPinConstant("output",U)&&y("output",U,e.getPinData("output",U),!1)}),a.push(e.addListener("set_input",g)),a.push(e.addListener("before_remove_input",p)),a.push(e.addListener("set_output",h)),a.push(e.addListener("before_remove_output",d)),a.push(e.addListener("rename_input",c.bind(this,"input"))),a.push(e.addListener("rename_output",c.bind(this,"output"))),a.push(e.addListener("set_pin_constant",(U,B,J)=>{this._specSetUnitPinConstant(t,U,B,J);let q=this.getUnitPinData(t,U,B);if(J)y(U,B,q);else{let w=W(x,[t,U,B],void 0);w&&(w(),$t(a,w),fe(x,[t,U,B]))}}));let I=dl(t,lt),v=e.getSelfPin();this._pin[I]=v;let T=U=>{this._onUnitErr(t,U)};a.push(e.addListener("err",T));let P=()=>{let U=this._errUnitIds.indexOf(t);U>-1&&(this._errUnitIds.splice(U,1),U===0&&this._nextErr())};if(a.push(e.prependListener("take_err",P)),a.push(e.prependListener("catch_err",P)),e instanceof Lt){for(let U of wt)a.push(e.addListener(U,(...B)=>{this.emit(U,...B.slice(0,-1).concat([[t,...B[B.length-1]]]))}));a.push(e.addListener("fork",(U,B,J)=>{J.length===0&&(this._fork(),F(this._spec,["units",t,"id"],U))}))}e instanceof Lt&&e.isElement()&&(a.push(e.addListener("element",()=>{this._on_unit_element(t,o,e)})),a.push(e.addListener("not_element",()=>{this._on_unit_not_element(t)})));let H=tt(a);this._unitUnlisten[t]=H}_simAddUnit(t,e,i,o=!0){i.isElement()&&(o&&this.registerRoot(i),this._simInjectSubComponent(t,e.unit,i)),i.hasErr()&&this._onUnitErr(t,i.getErr()),this._paused||i.play()}removeUnit(t,e=!0,i=!0,o=!0){let a=this.getUnit(t),s=a.getUnitBundleSpec();return this._removeUnit(t,i,o),e&&this.emit("remove_unit",t,s,a,[]),this._transacting&&this._transaction.push(xl(t,s)),a}cloneUnit(t,e){let i=this._cloneUnit(t,e);return this.emit("clone_unit",t,e,i,[]),i}_cloneUnit(t,e){let i=this.getUnit(t),[o,a]=Cl(i,!0);return this._addUnit(e,o,a),this._paused||o.play(),o}_moveUnit(t,e,i){let o=this.getUnit(t),a=this._isUnitComponent(t);this._simRemoveUnit(t),this._memRemoveUnit(t),this._specRemoveUnit(t,a),this.getUnit(e).push(i,o)}moveUnit(t,e,i){this._moveUnit(t,e,i),this.emit("move_unit",t,e,i,[])}_memRemoveUnitFromMerges(t){let e=this._unitToMerge[t];for(let i of e)this._memRemoveUnitFromMerge(t,i)}_simRemoveUnitFromMerges(t){let e=this._unitToMerge[t];for(let i of e)this._simRemoveUnitFromMerge(t,i)}_removeUnitFromMerge(t,e){this._simRemoveUnitFromMerge(t,e),this._memRemoveUnitFromMerge(t,e)}_memRemoveUnitFromMerge(t,e){this._forEachUnitPinOnMerge(t,e,(i,o)=>{this._memRemovePinFromMerge(e,t,i,o)})}_simRemoveUnitFromMerge(t,e,i=!0){this._forEachUnitPinOnMerge(t,e,(o,a)=>{this._simRemovePinFromMerge(e,t,o,a,i)})}_specRemoveUnitFromMerge(t,e){this._forEachUnitPinOnMerge(t,e,(i,o)=>{this._specRemovePinFromMerge(e,t,i,o)})}_forEachUnitPinOnMerge(t,e,i){let a=this.getMergeSpec(e)[t];a&&Bt(a,(s,p)=>{i(s,p)})}_removeUnit(t,e=!0,i=!1){this._fork();let o=this.getUnit(t);this.emit("before_remove_unit",t,o,[]);let a=this._isUnitComponent(t);return this._simRemoveUnit(t,e),this._memRemoveUnit(t),this._specRemoveUnit(t,a),i&&o.destroy(),o}_specRemoveUnit(t,e){e&&(this._specRemoveSubComponentFromParent(t),this._specRemoveSubComponent(t)),this._specUnplugUnit(t),delete this._spec.units[t]}_memRemoveUnit(t,e=!0){let i=this.getUnit(t),o=this._unitUnlisten[t];o(),e&&this._memUnplugUnit(t),i.setParent(null),delete this._unitToMergeCount[t],delete this._unitToMerge[t],delete this._unitUnlisten[t],delete this._pinToMerge[t],delete this._unit[t]}_memUnplugUnit(t){var a;let e=j(this._unitToMerge[t]||new Set),i=j(this._unitToMergeCount[t]||{}),o=j((a=this._pinToPlug[t])!=null?a:{});Bt(o,(s,p,{pinId:d,subPinId:c})=>{this._memUnplugPin(s,d,c)});for(let s of e){let p=i[s];this.getMergePinCount(s)-p<2?this._memRemoveMerge(s):this._memRemoveUnitFromMerge(t,s)}}_simAddMerge(t,e,i,o){A(e,({input:a,output:s},p)=>{A(a||{},(d,c)=>{this._simAddPinToMerge(t,p,"input",c,o)}),A(s||{},(d,c)=>{this._simAddPinToMerge(t,p,"output",c,o)})})}_simAddPinToMerge(t,e,i,o,a=!0){let s=Jt(e,i,o);a=a||this.isUnitRefPin(e,i,o),this._simSetBranch(t,i,s,a)}_specAddPinToMerge(t,e,i,o){F(this._spec,["merges",t,e,i,o],!0)}_memAddPinToMerge(t,e,i,o){i==="output"&&o===lt&&(this._mergeToSelfUnit[t]=e,this._selfUniToMerge[e]=t),this._mergePinCount[t]=this._mergePinCount[t]||0,this._mergePinCount[t]++,this._unitToMerge[e]=this._unitToMerge[e]||new Set,this._unitToMerge[e].add(t),this._unitToMergeCount[e]=this._unitToMergeCount[e]||{},this._unitToMergeCount[e][t]=this._unitToMergeCount[e][t]||0,this._unitToMergeCount[e][t]++,F(this._pinToMerge,[e,i,o],t);let a=Jt(e,i,o);this._memSetBranch(t,i,a)}_memRemoveMerge(t){this._memRemoveAllMergePlug(t),this._memRemoveAllMergePin(t),this._memRemoveAllMergeRef(t);let e=At(t,"input"),i=At(t,"output");delete this._pin[e],delete this._pin[i],delete this._merge[t],delete this._mergePinCount[t]}_specRemoveMerge(t){this._specRemoveAllMergePlug(t),this._specRemoveAllMergePin(t),this._specRemoveAllMergeRef(t)}_memRemoveAllMergePlug(t){this._forEachSpecPinPlug((e,i,o,a)=>{a.mergeId===t&&this._memUnplugPin(e,i,o)})}_specRemoveAllMergePlug(t){this._forEachSpecPinPlug((e,i,o,a)=>{a.mergeId===t&&this._specUnplugPin(e,i,o)})}_memRemoveAllMergeRef(t){let e=this._mergeToSelfUnit[t];e&&(delete this._mergeToSelfUnit[t],delete this._selfUniToMerge[e])}_specRemoveAllMergeRef(t){delete this._spec.merges[t]}_memRemoveAllMergePin(t){let e=j(this._spec.merges[t]);A(e,({input:i,output:o},a)=>{A(i||{},(s,p)=>{this._memRemovePinFromMerge(t,a,"input",p)}),A(o||{},(s,p)=>{this._memRemovePinFromMerge(t,a,"output",p)})})}_specRemoveAllMergePin(t){let e=j(this._spec.merges[t]);A(e,({input:i,output:o},a)=>{A(i||{},(s,p)=>{this._specRemovePinFromMerge(t,a,"input",p)}),A(o||{},(s,p)=>{this._specRemovePinFromMerge(t,a,"output",p)})})}_memPostRemoveMerge(t){this._forEachSpecPinPlug((e,i,o,a)=>{a.mergeId===t&&this._memPlugEmptyPin(e,i,o)})}memIsUnitRefPin(t,e,i){return this.getUnit(t).hasRefPinNamed(e,i)}_getUnitSpec(t){let e=this.getGraphUnitSpec(t),{id:i}=e;return this.__system.getSpec(i)}getUnitSpecId(t){let e=this.getGraphUnitSpec(t),{id:i}=e;return i}getUnitSpec(t){let{getSpec:e}=this.__system,i=this.getGraphUnitSpec(t),{id:o}=i;return e(o)}isUnitRefPin(t,e,i){return this.getUnit(t).isPinRef(e,i)}isUnitRefInput(t,e){return this.getUnit(t).hasRefInputNamed(e)}removeMerge(t,e=!0,i=!0){let o=this.getMergeSpec(t),a=this._removeMerge(t,i);e&&this.emit("remove_merge",t,o,a,[]),this._transacting&&this._transaction.push(Tl(t,o))}_removeMerge(t,e){this._fork(),this._validateMergeId(t);let i=this.getMerge(t),o=this.getMergeSpec(t);return this.emit("before_remove_merge",t,o,i,[]),this._simRemoveMerge(t,e),this._memRemoveMerge(t),this._specRemoveMerge(t),i.destroy(),i}_simRemoveMerge(t,e){let i=this.getMerge(t);this._simRemoveAllPlugsFromMerge(t,e),this._simRemoveAllPinsFromMerge(t,e)}_simPostRemoveMerge(t){this._forEachSpecPinPlug((e,i,o,a)=>{a.mergeId===t&&this._simPlugEmptyPin(e,i,o)})}removePinFromMerge(t,e,i,o,a=!0,s=!0){this._removePinFromMerge(t,e,i,o,s),a&&this.emit("remove_pin_from_merge",t,e,i,o,[])}_removePinFromMerge(t,e,i,o,a=!0){this._validateMergeId(t),this._validateUnitId(e),this._simRemovePinFromMerge(t,e,i,o,a),this._memRemovePinFromMerge(t,e,i,o),this._specRemovePinFromMerge(t,e,i,o)}removePinOrMerge(t,e,i,o,a=!0,s=!0){this._mergePinCount[t]>2?this.removePinFromMerge(t,e,i,o,a,s):this.removeMerge(t,s,a)}_removePinOrMerge(t,e,i,o,a=!0){this._mergePinCount[t]>2?this._removePinFromMerge(t,e,i,o,a):this._removeMerge(t,a)}_memRemovePinFromMerge(t,e,i,o){var s,p,d,c,m,f;let a=Jt(e,i,o);this._memRemoveBranch(t,i,a),i==="input"||o===lt&&(delete this._mergeToSelfUnit[t],delete this._selfUniToMerge[e]),this._mergePinCount[t]--,this._unitToMergeCount[e][t]--,this._unitToMergeCount[e][t]===0&&(delete this._unitToMergeCount[e][t],this._unitToMerge[e].delete(t)),(p=(s=this._pinToMerge[e])==null?void 0:s[i])==null||delete p[o],Ft((c=(d=this._pinToMerge[e])==null?void 0:d[i])!=null?c:{})&&((m=this._pinToMerge[e])==null||delete m[i]),Ft((f=this._pinToMerge[e])!=null?f:{})&&delete this._pinToMerge[e]}_specRemovePinFromMerge(t,e,i,o){Ol({mergeId:t,unitId:e,type:i,pinId:o},this._spec)}_simRemovePinFromMerge(t,e,i,o,a=!0){let s=Jt(e,i,o);if(this._simRemoveBranch(t,i,s),a||i==="output"&&o===lt||this.isUnitRefPin(e,"input",o)){let p=this._pin[s],d=this.getMergeSpec(t);this.isUnitRefPin(e,"output",o)?fl(d,(c,m,f)=>{this._removeUnitPinData(c,m,f)}):p.take()}}isPinMergedTo(t,e,i,o){let a=this._spec.merges||{};return!!a[t]&&a[t][e]&&a[t][e][i]&&a[t][e][i][o]}setUnitPinSetId(t,e,i,o,a=!0){this.getUnit(t).setPinSetId(e,i,o,!1),a&&this.emit("set_unit_pin_set_id",t,e,i,o,[])}setUnitPinConstant(t,e,i,o,a=!0){this._setUnitPinConstant(t,e,i,o);let s=this.getUnitPinData(t,e,i);a&&this.emit("set_unit_pin_constant",t,e,i,o,s,[])}_setUnitPinConstant(t,e,i,o){this._specSetUnitPinConstant(t,e,i,o),this.getUnit(t).setPinConstant(e,i,o)}_specSetUnitPinConstant(t,e,i,o){$l({unitId:t,type:e,pinId:i,constant:o},this._spec)}setUnitInputConstant(t,e,i){this.setUnitPinConstant(t,"input",e,i)}setUnitOutputConstant(t,e,i){this.setUnitPinConstant(t,"output",e,i)}setUnitInputIgnored(t,e,i){this.setUnitPinIgnored(t,"input",e,i)}setUnitOutputIgnored(t,e,i){this.setUnitPinIgnored(t,"output",e,i)}setUnitPinIgnored(t,e,i,o){this._setUnitPinIgnored(t,e,i,o),this.emit("set_unit_pin_ignored",t,e,i,o,[])}_setUnitPinIgnored(t,e,i,o){this._specSetUnitPinIgnored(t,e,i,o),this._simSetUnitPinIgnored(t,e,i,o)}_specSetUnitPinIgnored(t,e,i,o){F(this._spec,["units",t,e,i,"ignored"],o)}_simSetUnitPinIgnored(t,e,i,o){var s;let a=this.getUnit(t);o&&(te((s=this._spec.merges)!=null?s:{},(p,d,c,m)=>{d===t&&c===e&&m===i&&this._removePinFromMerge(p,t,e,i)}),A(this._spec[`${e}s`]||{},({plug:p},d)=>{for(let c in p){let m=p[c];if(m.unitId===t&&m.pinId===i){this._unplugPin(e,d,c);break}}})),a.setPinIgnored(e,i,o)}setUnitId(t,e,i,o){this._setUnitId(t,e,i,o),this.emit("set_unit_id",t,e,i,o,[])}_setUnitId(t,e,i,o){let a=j(this.getUnitMergesSpec(t)),s=j(this.getUnitPlugsSpec(t)),p=Vl(t,a,e),d=this.getUnit(t);d.fork(o,!1);let c=this._getUnitSpec(t);c.name=i,d._spec.name=i,this._specs[c.id]=c,this._removeUnit(t,!1),this._addUnit(e,d),this._addUnitMerges(p,!1),this._addUnitPlugs(e,s,!1)}_addUnitPlugs(t,e,i=!0){Bt(e,(o,a,s)=>{this._plugPin(o,s.pinId,s.subPinId,{unitId:t,pinId:a,kind:o},i)})}setPlugData(t,e,i,o,a=!0){this.getPlug(t,e,i).push(o)}setUnitPinData(t,e,i,o){this._settingUnitData=!0,this._setUnitPinData(t,e,i,o),this._settingUnitData=!1,this.emit("set_unit_pin_data",t,e,i,o,[])}_setUnitPinData(t,e,i,o){let a=this.getUnit(t);a.hasInputNamed(i)&&a.isPinConstant(e,i)&&this._fork(),this._specSetUnitPinData(t,e,i,o),this._simSetUnitPinData(t,e,i,o)}_specSetUnitPinData(t,e,i,o){let a=this.getUnit(t);a.hasInputNamed(i)&&a.isPinConstant(e,i)&&kl({unitId:t,type:e,pinId:i,data:Y(o)},this._spec)}_simSetUnitPinData(t,e,i,o){this.getUnit(t).setPinData(e,i,o)}setUnitInputData(t,e,i){this.getUnit(t).setPinData("input",e,i)}setUnitOutputData(t,e,i){this.getUnit(t).setPinData("output",e,i)}setMetadata(t,e){let i=this._spec,o=0;for(;o<t.length-1;){let s=t[o];i[s]||(i[s]={}),i=i[s],o++}let a=t[o];Je(i[a])&&Je(e)?i[a]=Ht(i[a],e):i[a]=e,this.emit("metadata",{path:t,data:e},[])}getSubComponentsParentMap(t){let e={};for(let i of t){let o=this._getSubComponentParentId(i);e[i]=o}return e}getSubComponentsSlotMap(t){let e={};for(let i of t){let o=this._getSubComponentSlotName(i);e[i]=o}return e}moveSubComponentRoot(t,e,i,o=!0){let a=this.getSubComponentsParentMap(e),s=this.getSubComponentsParentMap(e);for(let p=0;p<e.length;p++){let d=e[p],c=i[d]||"default";this._moveSubComponentRoot(t,d,p,c)}o&&this.emit("move_sub_component_root",t,a,e,i,s,[])}_appendRoot(t){this._specAppendRoot(t)}removeRoot(t){this._removeRoot(t)}_removeRoot(t){this._simRemoveRoot(t),this._specRemoveRoot(t)}_specRemoveRoot(t){let e=this._spec.component.children.indexOf(t);if(e>-1)this._spec.component.children.splice(e,1);else throw new Error("root not found")}_simRemoveRoot(t){let e=this.getUnit(t);this.unregisterRoot(e)}moveSubgraphInto(...[t,e,i,o,a,s,p,d,c,m]){this._moveSubgraphInto(t,e,i,o,a,s,p,d,c,m),this.emit("move_subgraph_into",t,e,i,o,a,s,p,d,c,m,[])}_moveSubgraphInto(t,e,i,o,a,s,p,d,c,m){let f=this.getUnit(t);f.fork(i),f.startTransaction();let g=j(this.getUnitMergesSpec(t));pm(this,f,t,{nodeIds:o,nextSpecId:null,nextIdMap:a,nextPinIdMap:s,nextMergePinId:p,nextPlugSpec:d,nextSubComponentParentMap:c,nextSubComponentChildrenMap:m,nextUnitPinMergeMap:{},nextSubComponentIndexMap:{}},{merges:g},!1),f.endTransaction()}getUnitMergesSpec(t){return rm(this._spec,t)}getPinMergeId(t,e,i){return W(this._pinToMerge,[t,e,i],null)}getUnitPlugsSpec(t){return im(this._spec,t)}startTransaction(){if(this._transacting)throw new Error("transaction already started");this._transacting=!0,this._transaction=[]}explodeUnit(t,e,i,o){this._explodeUnit(t,e,i,o),this.emit("explode_unit",t,e,i,[])}moveSubgraphOutOf(...[t,e,i,o,a,s,p,d,c,m]){this._moveSubgraphOutOf(t,e,i,o,a,s,p,d,c,m),this.emit("move_subgraph_out_of",t,e,i,o,a,s,p,d,c,m,[])}_moveSubgraphOutOf(...[t,e,i,o,a,s,p,d,c,m]){let f=this.getUnit(t),g=j(this.getUnitMergesSpec(t)),h=j(this.getUnitPlugsSpec(t)),x={nodeIds:o,nextSpecId:null,nextIdMap:a,nextPinIdMap:s,nextMergePinId:p,nextPlugSpec:d,nextSubComponentParentMap:c,nextSubComponentChildrenMap:m,nextSubComponentIndexMap:{},nextUnitPinMergeMap:{}},y={merges:g,plugs:h};f.startTransaction(),f.fork(),pm(f,this,t,x,y,!0),f.endTransaction()}getGraphUnitBundleSpec(t){return this.getUnit(t).getBundleSpec()}_explodeUnit(t,e,i,o){this._fork();let a=this.getUnitSpec(t),s=yl(t,a,e,i,o,{getMerge:I=>this.getMergeSpec(I),getUnitMerges:I=>this.getUnitMergesSpec(I),getUnitPlugs:I=>this.getUnitPlugsSpec(I),getPinMergeId:(I,v,T)=>this.getPinMergeId(I,v,T)}),{nodeIds:p,nextSpecId:d,nextIdMap:c,nextPinIdMap:m,nextMergePinId:f,nextPlugSpec:g,nextSubComponentParentMap:h,nextSubComponentChildrenMap:x}=s,y=this.getGraphUnitBundleSpec(t);this._moveSubgraphOutOf(t,y,d,p,c,m,f,g,h,x),this._removeUnit(t)}_removeSubComponentFromParent(t){this._simRemoveSubComponentFromParent(t),this._specRemoveSubComponentFromParent(t)}reorderSubComponent(t,e,i,o=!0){this._reorderSubComponent(t,e,i),o&&this.emit("reorder_sub_component",t,e,i,[])}_reorderSubComponent(t,e,i){this._simReorderSubComponent(t,e,i),this._specReorderSubComponent(t,e,i)}_simReorderSubComponent(t,e,i){let o=this.getUnit(e);t?this.getUnit(t).reorderParentRoot(o,i):this.reorderRoot(o,i)}_specReorderSubComponent(t,e,i){let o=this.getUnit(e);t?($t(this._spec.component.subComponents[t].children,e),It(this._spec.component.subComponents[t].children,e,i)):($t(this._spec.component.children,e),It(this._spec.component.children,e,i))}moveRoot(t,e,i,o){this._moveSubComponentRoot(t,e,i,o)}_moveSubComponentRoot(t,e,i,o){this._removeSubComponentFromParent(e),t?this._insertSubComponentChild(t,e,i,o):this._appendRoot(e)}_initSetComponent(t){let{slots:e=[],subComponents:i={},children:o=[]}=t;for(let a in i){let s=i[a];this._initAddSubComponent(a,s)}for(let a of o){let s=this.getUnit(a);this.registerRoot(s)}for(let a=0;a<e.length;a++){let s=e[a],[p,d]=s,c=this.getUnit(p),m=a===0?"default":`${a}`;this._slot[m]=c}}_specSetComponent(t){let{slots:e=[],subComponents:i={},children:o=[]}=t;for(let a in i){let s=i[a];this._specAddSubComponent(a,s)}for(let a=0;a<e.length;a++){let s=e[a],[p,d]=s,c=this.getUnit(p),m=a===0?"default":`${a}`;this._slot[m]=c}e.length>0&&(this._spec.component.slots=e)}_initAddSubComponent(t,e){let{children:i=[],childSlot:o={}}=e;for(let a of i){let s=o[a]||"default";this._simSubComponentAppendChild(t,a,s)}}_specAddSubComponent(t,e){var a;let{children:i=[],childSlot:o={}}=e;for(let s of i){this._specComponentRemoveChild(s);let p=o[s]||"default";this._specSubComponentAppendChild(t,s,p)}this._spec.component.subComponents[t]=e,this._spec.component.children=(a=this._spec.component.children)!=null?a:[],this._spec.component.children.push(t)}appendParentChild(t,e){return fc(this,this._parent_children,t,e)}removeParentChild(t){return lc(this,this._parent_children,t)}registerRoot(t){return mc(this,this._root,t)}unregisterRoot(t){return dc(this,this._root,t)}registerParentRoot(t,e,i){return sc(this,this._parent_root,t,e,i)}unregisterParentRoot(t){return pc(this,this._parent_root,t)}reorderRoot(t,e){return uc(this,this._root,t,e)}reorderParentRoot(t,e){return cc(this,this._parent_root,t,e)}insertChild(t,e){return ul(this,this._children,t,e)}appendChild(t){return ic(this,this._children,t)}pushChild(t){return Dn(this,this._children,t)}pullChild(t){throw En(this,this._children,t)}hasChild(t){return Sn(this,this._children,t)}removeChild(t){return rc(this,this._children,t)}refChild(t){return oc(this,this._children,t)}refChildren(){return ac(this,this._children)}refSlot(t){return cl(this,t,this._slot)}getAnimations(){return this._animations}animate(t,e){return bc(this,this._animations,t,e)}cancelAnimation(t){return gc(this,this._animations,t)}stopPropagation(t){return hc(this,this._stopPropagation,t)}getSetup(){return{animations:this._animations,events:this.eventNames(),stopPropagation:Object.keys(this._stopPropagation),stopImmediatePropagation:Object.keys(this._stopImmediatePropagation),preventDefault:Object.keys(this._preventDefault)}}bulkEdit(t){this._bulkEdit(t),this.emit("bulk_edit",t,!1,[])}_bulkEdit(t){for(let e of t)Al(e,{addUnitSpec:i=>{let{unitId:o,bundle:a,parentId:s,merges:p,plugs:d}=i;this._addUnitSpec(o,a),s&&this._appendSubComponentChild(s,o,"default"),p&&this._addUnitMerges(p,!0),d&&this._addUnitPlugs(o,d)},removeUnit:i=>{let{unitId:o}=i;this._removeUnit(o,!1,!0)},exposePinSet:i=>{let{type:o,pinId:a,pinSpec:s}=i;this._exposePinSet(o,a,s)},exposePin:i=>{let{type:o,pinId:a,subPinId:s,subPinSpec:p}=i;this._exposePin(o,a,s,p)},coverPin:i=>{let{type:o,pinId:a,subPinId:s}=i;this._coverPin(o,a,s)},coverPinSet:i=>{let{type:o,pinId:a}=i;this._coverPinSet(o,a)},plugPin:i=>{let{type:o,pinId:a,subPinId:s,subPinSpec:p}=i;this._plugPin(o,a,s,p)},unplugPin:i=>{let{type:o,pinId:a,subPinId:s}=i;this._unplugPin(o,a,s)},addUnitSpecs:i=>{let{units:o}=i;this._addUnitSpecs(o)},removeMerge:i=>{let{mergeId:o}=i;this._removeMerge(o,!0)},removePinFromMerge:i=>{let{mergeId:o,unitId:a,type:s,pinId:p}=i;this._removePinFromMerge(o,a,s,p)},removeUnitGhost:i=>{let{unitId:o,nextUnitId:a,nextUnitSpec:s}=i;this._removeUnitGhost(o,a,s)},addUnitGhost:i=>{let{unitId:o,nextUnitId:a,nextUnitBundle:s,nextUnitPinMap:p}=i;this._addUnitGhost(o,a,s,p)},addMerges:i=>{let{merges:o}=i;this._addMerges(o)},addMerge:i=>{let{mergeId:o,mergeSpec:a}=i;this._addMerge(a,o)},addPinToMerge:i=>{let{mergeId:o,unitId:a,type:s,pinId:p}=i;this._addPinToMerge(o,a,s,p)},takeUnitErr:i=>{let{unitId:o}=i;this.takeUnitErr(o)},setPinSetId:i=>{let{type:o,pinId:a,nextPinId:s}=i;this._setPinSetId(o,a,s)},setPinSetFunctional:i=>{let{type:o,pinId:a,functional:s}=i;this._setPinSetFunctional(o,a,s)},setUnitPinConstant:i=>{let{unitId:o,type:a,pinId:s,constant:p}=i;this._setUnitPinConstant(o,a,s,p)},setUnitPinIgnored:i=>{let{unitId:o,type:a,pinId:s,ignored:p}=i;this._setUnitPinIgnored(o,a,s,p)},setUnitPinData:i=>{let{unitId:o,type:a,pinId:s,data:p}=i;this._setUnitPinData(o,a,s,p)},setUnitId:i=>{let{unitId:o,newUnitId:a,name:s,specId:p}=i;this._setUnitId(o,a,s,p)},removeUnitPinData:i=>{let{unitId:o,type:a,pinId:s}=i;this._removeUnitPinData(o,a,s)},removeMergeData:i=>{let{mergeId:o}=i;this._removeMergeData(o)},moveSubComponentRoot:i=>{let{parentId:o,children:a,slotMap:s}=i;for(let p=0;p<a.length;p++){let d=a[p],c=s[d]||"default";this._moveSubComponentRoot(o,d,p,c)}},moveUnit:i=>{let{}=i},moveSubgraphInto:i=>{let{graphId:o,graphBundle:a,nextSpecId:s,nodeIds:p,nextIdMap:d,nextPinIdMap:c,nextMergePinId:m,nextPlugSpec:f,nextSubComponentParentMap:g,nextSubComponentChildrenMap:h}=i;this._moveSubgraphInto(o,a,s,p,d,c,m,f,g,h)},moveSubgraphOutOf:i=>{let{graphId:o,graphBundle:a,nextSpecId:s,nodeIds:p,nextIdMap:d,nextPinIdMap:c,nextMergePinId:m,nextPlugSpec:f,nextSubComponentParentMap:g,nextSubComponentChildrenMap:h}=i;this._moveSubgraphOutOf(o,a,s,p,d,c,m,f,g,h)},reorderSubComponent:i=>{let{parentId:o,childId:a,to:s}=i;this._reorderSubComponent(o,a,s)},removePinData:i=>{let{type:o,pinId:a}=i;this.removePinData(o,a)},takeInput:i=>{let{pinId:o}=i;this.removePinData("input",o)},setUnitSize:i=>{let{unitId:o,width:a,height:s}=i;this._setUnitSize(o,a,s)},setSubComponentSize:i=>{let{unitId:o,width:a,height:s}=i;this._setSubComponentSize(o,a,s)},setComponentSize:i=>{let{width:o,height:a}=i;this._setComponentSize(o,a)},bulkEdit:i=>{let{actions:o}=i;this.bulkEdit(o)}},()=>{throw new Ne})}_setUnitSize(t,e,i){this._specSetUnitSize(t,e,i)}_specSetUnitSize(t,e,i){Nl({unitId:t,width:e,height:i},this._spec)}_setSubComponentSize(t,e,i){this._specSetSubComponentSize(t,e,i)}_specSetSubComponentSize(t,e,i){Bl({unitId:t,width:e,height:i},this._spec)}_setComponentSize(t,e){this._specSetComponentSize(t,e)}_specSetComponentSize(t,e){Fl({width:t,height:e},this._spec)}detach(){throw new O}};function um(r,n,t={},e={}){var o;t[r.id]=r;let{units:i}=r;for(let a in i){let s=i[a],{id:p,input:d}=s;for(let f in d){let g=(o=d[f])!=null?o:{},{data:h}=g;if(h){let x=Dt(h);if(x.type==="unit"){let{value:y}=x,I=Xd(y,n,e);for(let v in I.specs){let T=I.specs[v];t[v]=T}for(let v in I.specs){let T=I.specs[v];um(T,ut(n,t),t)}}}}let c=n[p];if(!c)return;let{system:m}=c;m||t[p]||(t[p]=c,um(t[p],n,t))}return t}function be(r,n,t={},e={}){let i=Jd(r,n,t,e),{id:o}=r;if(!o)throw new Error("spec id is required");let a=um(r,n,{});return zt(i,{unit:{id:o},specs:a})}function zl(r,n){let{name:t,units:e}=r;for(let o in e){let g=function(h,x){let{ignored:y}=h;if(y===void 0){let{defaultIgnored:I}=x;I===!0&&(h.ignored=!0)}};var i=g;let a=e[o];a.input=a.input||{},a.output=a.output||{};let{id:s,input:p,output:d}=a,c=n[s],{inputs:m,outputs:f}=c;for(let h in m){let x=m[h];p[h]=p[h]||{};let y=p[h];g(y,x)}for(let h in f){let x=f[h];d[h]=d[h]||{};let y=d[h];g(y,x)}}}function Jd(r,n,t,e={}){zl(r,n);let{id:i,name:o}=r;if(t[i])return t[i];class a extends Lt{constructor(p){let d=p.getSpec(i);super(d,e,p,i)}}return Object.defineProperty(a,"name",{value:o}),e[i],a}function Jf(r,n,t,e={}){return zl(n,t),new Lt(n,e,r,n.id)}function ee(r,n,t,e={}){let{spec:i={},specs:o={}}=r;return i.id||(i.id=Ze(n)),o[i.id]=i,be(i,ut(o,n),t,e)}function cm(r=null,n,t){let{path:e="",specs:i={},classes:o={},components:a={},flags:s={}}=t,p={pressed:[],repeat:!1},d=[],c={},m=new Set,f=[],g={keyboard:p,gamepads:d,pointers:c},h={iframe:[],dragAndDrop:{},pointerCapture:{},spriteSheetMap:{}},x={},y=new Ku(i),{specs_:I}=y,{specsCount:v,newSpecId:T,hasSpec:P,emptySpec:H,newSpec:U,getSpec:B,setSpec:J,forkSpec:q,injectSpecs:w,deleteSpec:E,registerUnit:$,unregisterUnit:G,shouldFork:K}=y,L=r?r.emitter:new mt,z={},rt={},N={},nt={path:e,parent:r,emitter:L,animated:!0,root:null,theme:"dark",customEvent:m,input:g,context:f,specs_:I,specs:i,classes:o,components:a,graphs:[],specsCount:v,cache:h,feature:x,foreground:{svg:void 0,app:void 0},showLongPress:void 0,captureGesture:void 0,global:r?r.global:{ref:{},component:rt,data:new Ie({}),scope:{}},api:n,flags:_({defaultInputModeNone:!1,tick:"sync"},s),tick:s.tick==="sync"?M=>{M()}:M=>nt.api.animation.requestAnimationFrame(M),boot:M=>cm(nt,n,M),stringifyBundleData:M=>zf(M),fromBundle:M=>ee(M,i,{}),newGraph:M=>new M(nt),getSpec:B.bind(y),hasSpec:P.bind(y),newSpecId:T.bind(y),emptySpec:H.bind(y),forkSpec:q.bind(y),newSpec:U.bind(y),setSpec:J.bind(y),injectSpecs:w.bind(y),deleteSpec:E.bind(y),registerUnit:$.bind(y),unregisterUnit:G.bind(y),shouldFork:K.bind(y),injectPrivateCSSClass:function(M,k,R){if(nt.root){if(!nt.global.component[M])throw new Error("component not found");let X=`${$f(R)}`;return Nf(nt,X),()=>{Ff(nt,X)}}else return gt},getLocalComponents:function(M){let k=N[M];return k?[...k].map(R=>rt[R]):[]},registerLocalComponent:function(M,k){var X;let R=Xe(z);return rt[R]=M,z[R]=k,N[k]=(X=N[k])!=null?X:new Set,N[k].add(R),L.emit(k,M),R},unregisterLocalComponent:function(M){let k=z[M];if(!k)throw new Error("local component not found");let R=N[k];R.delete(M),R.size===0&&delete N[k],delete z[M]}};return nt}function Wl(r){let{graphs:n}=r;for(let t of n)t.destroy()}var Ee=class{constructor(n,t){this._unlisten={};this._ref={};this._api=n,this._post=t}exec(n){let{type:t,data:e}=n;switch(t){case pe:{let{id:i,method:o,data:a}=e;this._api[pe][o](a,(s,p)=>{this._post({type:pe,data:{id:i,data:s,err:p}})})}break;case Ue:{let{id:i,method:o,data:a}=e,s=this._api[Ue][o](a,(p,d)=>{this._post({type:Ue,data:{id:i,data:p,err:d}})});this._unlisten[i]=s}break;case $u:{let{id:i}=e,o=this._unlisten[i];o&&(delete this._unlisten[i],o())}break;case we:{let{id:i,method:o,data:a}=e,s=this._api[we][o](a),p=new Ee(s,d=>{this._post({type:we,data:{id:i,data:d}})});this._ref[i]=p}break;case Nu:{let{id:i,data:o}=e;this._ref[i].exec(o)}break;default:throw new Error("invalid remote API data type")}}};var Mn=["appendChild","removeChild","hasChild","child","children","component"],Pn=[],On=["refChild"],XS=[...Mn,...Pn,...On];var Kl=["draw","drawImage","clear","strokePath","scale","fillPath","toBlob"],ql=[],Yl=[];var Un=["emit","eventNames"],wn=["addListener"],Ln=["refEmitter"],nE=[...Un,...wn,...Ln];var O3=["getPinData","getInputData","getUnitPinData","getUnitState","getGraphState","getGraphChildren","getGraphPinData","getGraphData","getGraphErr","getGraphMergeInputData","getUnitInputData","getSpec","getBundle"],dm=["addUnit","addUnits","removeUnit","cloneUnit","moveUnit","exposePinSet","coverPinSet","exposePin","coverPin","plugPin","unplugPin","exposeUnitPinSet","coverUnitPinSet","setPinSetFunctional","setUnitId","setUnitPinData","setUnitPinConstant","setUnitPinIgnored","setUnitPinSetId","setPinSetId","addMerge","removeMerge","addMerges","addPinToMerge","removePinFromMerge","mergeMerges","setMetadata","moveUnitInto","appendRoot","removeRoot","appendParentRoot","appendParentRootChildren","reorderSubComponent","removeUnitPinData","setMergeData","removeMergeData","takeUnitErr","setUnitId","moveSubgraphInto","bulkEdit"],Gn=[...O3,...dm],Rn=["watchGraph","watchUnit","watchGraphUnit","watchUnitPath","watchGraphUnitPath"],kn=["transcend","refSubComponent","refUnit"],oE=[...Gn,...Rn,...kn];var $n=["get","set"],Nn=[],Fn=[],pE=[...$n,...Nn,...Fn];var Dc=["stream"],Sc=[],Ec=[];var Tc=[],Ac=[],Cc=["newGraph"];var Bn=["getGlobalId","getListeners","call","play","pause","push","pullInput","takeInput","renamePin","setPinData","removePinData","getPinData","getInputData","getRefInputData","err"],jn=["watch"],Hn=["refGlobalObj"],bE=[...Bn,...jn,...Hn];var Vn=["read","write"],zn=[],Wn=[],yE=[...Vn,...zn,...Wn];var mm="/",U3="_";var Kn="@",Mc="#",w3="$",Jl="%",Xl="^";var ge=`[^${mm}${Kn}${Mc}${w3}${Jl}${Xl}]+`,qn="[^]+",L3=`^(${ge})$`,G3=`^(${ge})/(input|output)/(${qn})$`,R3=`((${ge})|(${ge})/(input|output)/(${qn})|(${Kn}/${ge}))`,k3=`^(${ge})/input/(${qn})$`,$3=`^(${ge})/output/(${qn})$`,SE=new RegExp(`^${ge}$`),EE=new RegExp(`^${R3}$`),TE=new RegExp(L3),AE=new RegExp(G3),CE=new RegExp(k3),ME=new RegExp($3),PE=new RegExp(`^${Mc}/[^#_]+$`),OE=new RegExp(`^\\$/[^]+/${ge}$`),UE=new RegExp(`^${Kn}/[^/#$]+$`),wE=new RegExp(`^${Jl}/(input|output)/[^${mm}${Mc}${Kn}]+$`),LE=new RegExp(`^\\${Xl}/(input|output)/${qn}/[^${mm}${Mc}${Kn}]+$`),GE=new RegExp(`^(.+)${U3}(.+)$`);function Zl(r){let{base:n}=r;return!!n}function Ql(r){return r.split(/(?=[A-Z])/).map(e=>e.toLowerCase()).join("_")}function t1(r){return r.split(/(?=[A-Z])/).map(e=>e.toLowerCase()).join("-")}var e1=dm.reduce((r,n)=>Z(_({},r),{[n]:Ql(n)}),{});var n1=Lf(e1,(r,n)=>`$${n}`);function i1(r){return`$${r}`}var r1=new Set(["watch","watchGraph"]);var o1=new Set([...r1].map(i1));function N3(r,n,t){let e;return new Proxy(r,{get:(o,a)=>{let s=o[a];if(n[a])e=n[a];else if(t.has(a))return(p,d)=>s.call(o,p,c=>{var f,g,h;let{event:m}=c;e===m&&((h=(g=(f=c.data)==null?void 0:f.path)==null?void 0:g.length)!=null?h:0)===0?e=void 0:d(c)});return s}})}var F3={V:{$write:"write"},J:{$set:"set"},CA:{$draw:"draw"},G:n1,B:{},IB:{},CC:{},C:{},CS:{},CO:{},GP:{},M:{},E:{},EE:{},BD:{},BS:{},BSE:{},BC:{},NO:{},A:{},PP:{},PS:{},CH:{},MS:{},S:{},U:{},TR:{},RE:{},F:{},L:{},AC:{},D:{}},B3={G:o1};function Ct(r,n=[]){let t={},e=new Set;for(let i of n){let o=F3[i]||{},a=B3[i]||new Set;t=_(_({},t),o),e=new Set([...e,...a])}return N3(r,t,e)}var fm=r=>({$draw:function(n){throw new O},$drawImage:function(n){throw new O},$clear:function(n){throw new O},$strokePath:function(n){throw new O},$scale:function(n){throw new O},$fillPath:function(n){throw new O},$toBlob:function(n,t){throw new O}}),lm=r=>({}),bm=r=>({}),a1=r=>_(_(_({},fm(r)),lm(r)),bm(r));var j3=r=>({}),H3=r=>({}),V3=r=>({}),s1=r=>_(_(_({},j3(r)),H3(r)),V3(r));function p1(r){let t=Mt(r,["EE"]);return Ct(t,["EE"])}var gm=r=>({$emit({type:n,data:t},e){r.emit(n,t),e()},$eventNames(n,t){let e=r.eventNames();t(e)}}),hm=r=>({$addListener({event:n},t){return r.addListener(n,t)}}),ym=r=>({$refEmitter({}){return p1(r)}}),Pc=r=>_(_(_({},gm(r)),hm(r)),ym(r));function _m(r){return()=>{A(r,n=>{n()})}}function u1(r,n,t){let e=(i,o,a)=>{t({type:"graph",event:r,data:{actions:i,transaction:o,path:a}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function xm(r,n,t){let e=(i,o,a,s,p)=>{t({type:"graph",event:r,data:{type:i,pinId:o,subPinId:a,subPinSpec:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function Im(r,n,t){let e=(i,o,a,s,p)=>{t({type:"graph",event:r,data:{type:i,pinId:o,pinSpec:a,data:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function c1(r,n,t){let e=(i,o,a)=>{t({type:"graph",event:r,data:{path:a,specId:i,spec:o}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function vm(r,n,t){let e=(...[i,o,a,s])=>{t({type:"graph",event:r,data:{mergeId:i,mergeSpec:o,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function d1(r,n,t){let e=(...[i,o,a,s,p,d])=>{t({type:"graph",event:r,data:{parentId:i,prevParentIdMap:o,children:a,slotMap:s,prevSlotMap:p,path:d}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function Dm(r,n,t){let e=(...[i,o,a,s,p,d,c,m,f,g,h])=>{t({type:"graph",event:r,data:{graphId:i,graphBundle:o,nodeIds:s,nextSpecId:a,nextIdMap:p,nextPinIdMap:d,nextMergePinId:c,nextPlugSpec:m,nextSubComponentParentMap:f,nextSubComponentChildrenMap:g,nextSubComponentIndexMap:{},nextUnitPinMergeMap:{},path:h}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function Sm(r,n,t){let e=(i,o,a,s,p)=>{t({type:"graph",event:r,data:{mergeId:i,unitId:o,type:a,pinId:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function Em(r,n,t){let e=(i,o,a,s,p)=>{t({type:"graph",event:r,data:{type:i,pinId:o,subPinId:a,subPinSpec:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function m1(r,n,t){let e=(...[i,o,a,s])=>{t({type:"graph",event:r,data:{unitId:i,type:o,pinId:a,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function f1(r,n,t){let e=(...[i,o,a,s])=>{t({type:"graph",event:r,data:{parentId:i,childId:o,to:a,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function l1(r,n,t){let e=(...[i,o,a,s])=>{t({type:"graph",event:r,data:{type:i,pinId:o,functional:a,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function b1(r,n,t){let e=(...[i,o,a,s])=>{t({type:"graph",event:r,data:{type:i,pinId:o,nextPinId:a,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function g1(r,n,t){let e=(i,o,a,s,p)=>{t({type:"graph",event:r,data:{unitId:i,newUnitId:o,name:a,specId:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function h1(r,n,t){let e=(...[i,o,a,s,p,d])=>{p instanceof C&&(p=null),p!==void 0&&(p=Y(p)),t({type:"graph",event:r,data:{unitId:i,type:o,pinId:a,constant:s,data:p,path:d}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function y1(r,n,t){let e=(...[i,o,a,s,p])=>{let d=Y(s);t({type:"graph",event:r,data:{unitId:i,type:o,pinId:a,data:d,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function _1(r,n,t){let e=(...[i,o,a,s,p])=>{t({type:"graph",event:r,data:{unitId:i,type:o,pinId:a,ignored:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function x1(r,n,t){let e=(...[i,o,a,s,p])=>{t({type:"graph",event:r,data:{unitId:i,type:o,pinId:a,nextPinId:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function I1(r,n,t){let e=(i,o,a)=>{t({type:"graph",event:r,data:{unitId:i,unitSpec:o,path:a}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function v1(r,n,t){let e=(i,o)=>{t({type:"graph",event:r,data:{unitId:i,path:o}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function Tm(r,n,t){let e=(i,o,a,s)=>{t({type:"graph",event:r,data:{unitId:i,bundle:o,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function D1(r,n,t){let e=(i,o,a,s)=>{t({type:"graph",event:r,data:{unitId:i,newUnitId:o,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function S1(r,n,t){let e=(i,o,a,s)=>{t({type:"graph",event:r,data:{id:i,unitId:o,inputId:a,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}var Oc={fork:c1,add_unit:Tm,remove_unit:Tm,clone_unit:D1,move_unit:S1,component_append:I1,component_remove:v1,add_merge:vm,remove_merge:vm,add_pin_to_merge:Sm,remove_pin_from_merge:Sm,expose_pin:xm,cover_pin:xm,expose_pin_set:Im,cover_pin_set:Im,plug_pin:Em,unplug_pin:Em,move_subgraph_into:Dm,move_subgraph_out_of:Dm,reorder_sub_component:f1,move_sub_component_root:d1,set_unit_pin_constant:h1,set_unit_pin_set_id:x1,set_unit_pin_ignored:_1,set_pin_set_functional:l1,set_pin_set_id:b1,set_unit_pin_data:y1,remove_unit_pin_data:m1,set_unit_id:g1,bulk_edit:u1};function E1(r,n,t){let e=[];for(let o in Oc)if(n.includes(o)){let a=Oc[o];e.push(a(o,r,t))}return tt(e)}function T1(r,n=wt,t){let e=[];if(r instanceof Lt)for(let o of n){let a=Oc[o];a&&e.push(a(o,r,t))}return tt(e)}function Am(r,n,t,e,i){let o=a=>{a instanceof C&&(a=null),a!==void 0&&(a=Y(a)),i({type:n,event:r,data:{type:n,pinId:t,data:a}})};return e.prependListener(r,o),()=>{e.removeListener(r,o)}}function rn(r,n,t,e){let i=[Am("data",r,n,t,e),Am("drop",r,n,t,e)],o=tt(i);return()=>{o()}}var A1=(r,n)=>({input:r,output:n});function C1(r,n,t){return rn("input",r,n,t)}function M1(r,n,t){return rn("output",r,n,t)}function z3(r){let n=r.getGlobalId(),t=r.getInterface();return{globalId:n,__:t,_:void 0}}function Cm(r,n,t,e,i,o){let a=s=>{let p=s instanceof Function?Y(s):z3(s);o({type:n,event:r,data:{type:t,pinId:e,data:p}})};if(r==="data"&&i.active()){let s=i.peak();a(s)}return i.prependListener(r,a),()=>{i.removeListener(r,a)}}function Uc(r,n,t,e,i){let o=[Cm("data",r,n,t,e,i),Cm("drop",r,n,t,e,i)];return tt(o)}function P1(r,n,t){return Uc("ref_input","input",r,n,t)}function O1(r,n,t){return Uc("ref_output","output",r,n,t)}function wc(r,n,t){let e=i=>{t({type:"unit",event:r,data:{err:i}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function U1(r,n,t=wt){let e=[];return t.includes("err")&&e.push(wc("err",r,n)),t.includes("take_err")&&e.push(wc("take_err",r,n)),t.includes("catch_err")&&e.push(wc("catch_err",r,n)),tt(e)}function Fe(r,n,t){let e=i=>{t({type:"unit",event:r,data:i})};return n.addListener(r,e),()=>{n.removeListener(r,e)}}function Mm(r,n,t){let e=(i,o)=>{t({type:"unit",event:r,data:{name:i,newName:o}})};return n.addListener(r,e),()=>{n.removeListener(r,e)}}function w1(r,n,t){let e=(i,o)=>{o=o!==void 0?Y(o):o,t({type:"unit",event:r,data:{name:i,data:o}})};return n.addListener(r,e),()=>{n.removeListener(r,e)}}function L1(r,n,t){let e=i=>{t({type:"unit",event:r,data:i})};return n.addListener(r,e),()=>{n.removeListener(r,e)}}function G1(r,n,t){let e=(i,o)=>{o.length>0||t({type:"unit",event:r,data:i,path:o})};return n.addListener(r,e),()=>{n.removeListener(r,e)}}function R1(r,n,t){let e=(i,o)=>{o.length>0||t({type:"unit",event:r,data:i,path:o})};return n.addListener(r,e),()=>{n.removeListener(r,e)}}var Yn=(r,n,t)=>{let e=[],i=(o,a)=>{t({type:"unit",event:r,data:{pinId:o}})};return n.addListener(r,i),()=>{tt(e)(),n.removeListener(r,i)}};function k1(r,n,t=wt){let e=[];return t.includes("set_input")&&e.push(Yn("set_input",r,n)),t.includes("set_output")&&e.push(Yn("set_output",r,n)),t.includes("remove_input")&&e.push(Yn("remove_input",r,n)),t.includes("remove_output")&&e.push(Yn("remove_output",r,n)),tt(e)}function Lc(r,n=wt,t){let e=[],i=n.includes("input"),o=n.includes("ref_input"),a=n.includes("output"),s=n.includes("ref_output"),p=n.includes("rename_input"),d=n.includes("rename_output"),c=A1({},{}),m=(y,I,v,T)=>{let P={ref:{input:P1,output:O1},data:{input:C1,output:M1}}[y][I](v,T,t);return c[I][v]=P,e.push(P),P},f=(y,I)=>(v,T)=>{m(I,y,T,v)},g=(y,I)=>{let v=c[y][I];v&&(v(),$t(e,v),delete c.input[I])},h=(y,I)=>{let v=r.getPin(y,I),T=r.isPinRef(y,I);T&&o?m("ref",y,I,v):!T&&i&&m("data",y,I,v)};return i&&A(r.getDataInputs(),f("input","data")),o&&A(r.getRefInputs(),f("input","ref")),(i||o)&&e.push(r.addListener("set_input",(y,I,{ref:v})=>{h("input",y)})),e.push(r.addListener("rename_input",(y,I)=>{g("input",y),h("input",I)})),e.push(r.addListener("rename_output",(y,I)=>{g("output",y),h("output",I)})),p&&e.push(Mm("rename_input",r,t)),e.push(r.addListener("remove_output",(y,I)=>{let v=c.output[y];v&&(v(),$t(e,v),delete c.output[y])})),a&&A(r.getDataOutputs(),f("output","data")),s&&A(r.getRefOutputs(),f("output","ref")),(a||s)&&e.push(r.addListener("set_output",(y,I,{ref:v})=>{v&&s?m("ref","output",y,I):!v&&a&&m("data","output",y,I)})),d&&e.push(Mm("rename_output",r,t)),r.isElement()&&(n.includes("append_child")&&e.push(G1("append_child",r,t)),n.includes("remove_child")&&e.push(R1("remove_child",r,t))),e.push(U1(r,t,n)),e.push(k1(r,t,n)),tt(e)}function Gc(r,n,t=wt){let e={},i={},o=(h,x)=>{let y=Lc(h,t,({type:v,event:T,data:P})=>{n({type:v,event:T,data:Z(_({},P),{unitId:x})})}),I=T1(h,t,({type:v,event:T,data:P})=>{n({type:v,event:T,data:Z(_({},P),{unitId:x})})});e[x]=tt([y,I])},a=(h,x)=>{let y=At(x,"input"),I=h.getInput(y),v=rn("merge",x,I,({type:T,event:P,data:H})=>{n({type:T,event:P,data:Z(_({},H),{mergeId:x})})});i[x]=v},s=(h,x,y)=>{y.length===0&&o(x,h)},p=(h,x,y,I)=>{I.length===0&&o(y,x)},d=(h,x,y,I)=>{I.length===0&&a(y,h)},c=(h,x,y)=>{if(y.length===0){let I=e[h];I(),delete e[h]}},m=(h,x,y,I)=>{if(I.length===0){let v=i[h];v(),delete i[h]}},f=r.getUnits(),g=r.getMerges();return A(f,o),A(g,a),r.addListener("before_add_unit",s),r.addListener("clone_unit",p),r.addListener("before_add_merge",d),r.addListener("before_remove_unit",c),r.addListener("before_remove_merge",m),()=>{r.removeListener("before_add_unit",s),r.removeListener("clone_unit",p),r.removeListener("before_add_merge",d),r.removeListener("before_remove_unit",c),r.removeListener("before_remove_merge",m),_m(e)(),_m(i)()}}var on=class extends Q{constructor({i:t=[],o:e=[]},i,o,a){super({i:t,o:e},i,o,a);this.__=["U","J","V"];this.stateful=!0;this._defaultState={};this._state={};this._set_from_input=!1}subscribe(t,e,i){throw new O}onDataInputData(t,e){this.set(t,e,!0)}onDataInputDrop(t){this._set_from_input=!1,this._backwarding||this.set(t,void 0)}onRefInputData(t,e){super.onRefInputData(t,e),this._forwarding=!0,this.set(t,e),this._forwarding=!1}onRefInputDrop(t){this._backwarding||this.set(t,void 0)}get(t){return b(this,null,function*(){var e;return(e=this._state[t])!=null?e:this._defaultState[t]})}read(){return b(this,null,function*(){return this._state})}write(t){this._state=t}set(t,e,i=!1){return b(this,null,function*(){this._set_from_input=i,this._state[t]=e,this.emit("set",t,e),this.emit(t,e)})}hasKey(t){throw new O}delete(t){delete this._state[t]}deepSet(t,e){throw new O}deepGet(t){throw new O}deepDelete(t){throw new O}keys(){throw new O}snapshotSelf(){let t={};for(let e in this._state){let i=this._state[e];i instanceof C?t[e]=null:t[e]=i}return Z(_({},super.snapshotSelf()),{_state:t})}restoreSelf(t){let o=t,{_state:e}=o,i=bt(o,["_state"]);super.restoreSelf(i),this._state=e||this._defaultState}};function Jn(r,n,t=wt){let e=[];return e.push(Lc(r,t,n)),r instanceof on&&t.includes("set")&&e.push(w1("set",r,n)),r.isElement()&&t.includes("call")&&e.push(L1("call",r,n)),t.includes("play")&&e.push(Fe("play",r,n)),t.includes("pause")&&e.push(Fe("pause",r,n)),t.includes("listen")&&e.push(Fe("listen",r,n)),t.includes("unlisten")&&e.push(Fe("unlisten",r,n)),t.includes("register")&&e.push(Fe("register",r,n)),t.includes("unregister")&&e.push(Fe("unregister",r,n)),r instanceof Lt&&e.push(E1(r,t,n)),tt(e)}var Pm=r=>({$setUnitId({unitId:t,newUnitId:e,name:i,specId:o}){r.setUnitId(t,e,i,o)},$setUnitPinData({unitId:t,pinId:e,type:i,data:o}){let a=r.__system,{specs:s,classes:p}=a,d=a.specs;o=st(o,ut(s,d),p),r.setUnitPinData(t,i,e,o)},$removeUnitPinData({unitId:t,type:e,pinId:i}){r.removeUnitPinData(t,e,i)},$addUnit({unitId:t,bundle:e}){r.addUnitSpec(t,e)},$cloneUnit({unitId:t,newUnitId:e}){r.cloneUnit(t,e)},$moveUnit({id:t,unitId:e,inputId:i}){r.moveUnit(t,e,i)},$addUnits({units:t}){let{specs:e,classes:i}=r.__system,o=vt(t,a=>Z(_({},a),{Class:le(a.id,e,i)}));r.addUnitSpecs(o)},$removeUnit({unitId:t}){r.removeUnit(t)},$exposePinSet({type:t,pinId:e,pinSpec:i,data:o}){let a=o&&st(o,r.__system.specs,r.__system.classes);r.exposePinSet(t,e,i,a)},$coverPinSet({type:t,pinId:e}){r.coverPinSet(t,e,!0)},$exposePin({type:t,pinId:e,subPinId:i,subPinSpec:o}){r.exposePin(t,e,i,o)},$coverPin({type:t,pinId:e,subPinId:i}){r.coverPin(t,e,i)},$plugPin({type:t,pinId:e,subPinId:i,subPinSpec:o}){r.plugPin(t,e,i,o)},$unplugPin({type:t,pinId:e,subPinId:i}){r.unplugPin(t,e,i)},$exposeUnitPinSet({unitId:t,type:e,pinId:i,pinSpec:o}){r.getUnit(t).exposePinSet(e,i,o)},$coverUnitPinSet({unitId:t,type:e,pinId:i}){r.getUnit(t).coverPinSet(e,i)},$setPinSetId({type:t,pinId:e,nextPinId:i}){r.setPinSetId(t,e,i)},$setPinSetFunctional({type:t,pinId:e,functional:i}){r.setPinSetFunctional(t,e,i)},$setUnitPinConstant({unitId:t,type:e,pinId:i,constant:o}){r.setUnitPinConstant(t,e,i,o)},$setUnitPinIgnored({unitId:t,type:e,pinId:i,ignored:o}){r.setUnitPinIgnored(t,e,i,o)},$setUnitPinSetId({unitId:t,type:e,pinId:i,nextPinId:o}){r.setUnitPinSetId(t,e,i,o)},$addMerge({mergeId:t,mergeSpec:e}){r.addMerge(e,t)},$removeMerge({mergeId:t}){r.removeMerge(t,!0,!1)},$addMerges({merges:t}){r.addMerges(t)},$setMergeData({mergeId:t,data:e}){let i=r.refSystem(),{specs:o,classes:a}=i,s=st(e,o,a);r.setMergeData(t,s)},$removeMergeData({mergeId:t}){r.removeMergeData(t)},$addPinToMerge({mergeId:t,unitId:e,type:i,pinId:o}){r.addPinToMerge(t,e,i,o)},$removePinFromMerge({mergeId:t,unitId:e,type:i,pinId:o}){r.removePinFromMerge(t,e,i,o)},$takeUnitErr({unitId:t}){r.takeUnitErr(t)},$removeUnitGhost({unitId:t,nextUnitId:e,nextUnitSpec:i},o){let a=r.removeUnitGhost(t,e,i);Wf(a.bundle),o(a)},$addUnitGhost({unitId:t,nextUnitId:e,nextUnitBundle:i,nextUnitPinMap:o}){r.addUnitGhost(t,e,i,o)},$getBundle({},t){let e=r.getBundleSpec(),{spec:i}=e;Kd(i),t(e)},$getUnitPinData({unitId:t,type:e,pinId:i},o){let a=r.getUnitData(t,e,i);o(a)},$getUnitState(i,o){return b(this,arguments,function*({unitId:t},e){let a=yield r.getUnitState(t);e(a)})},$getGraphData(t,e){let i=r.getGraphState(),o=r.getGraphChildren(),a=r.getGraphErr(),s=r.getUnits(),p={};A(s,(m,f)=>{let g=m.getPinsData(),h=In(g);p[f]=h});let d=r.getGraphMergeInputData(),c={};for(let m in d){let f=d[m];f===void 0?c[m]=void 0:c[m]=Y(f)}e({state:i,children:o,err:a,pinData:p,mergeData:c})},$snapshot(t,e){return b(this,null,function*(){let i=r.snapshot();e(i)})},$snapshotUnit({unitId:t},e){let o=r.getUnit(t).snapshot();ke(o),e(o)},$getGraphState(e,i){return b(this,arguments,function*({},t){let o=yield r.getGraphState();t(o)})},$getGraphChildren({},t){let e=r.getGraphChildren();t(e)},$getGraphErr({},t){let e=r.getGraphErr();t(e)},$getGraphPinData({},t){let e={},i=r.getUnits();A(i,(o,a)=>{let s=o.getPinsData(),p=In(s);e[a]=p}),t(e)},$getGraphMergeInputData({},t){let e=r.getGraphMergeInputData(),i=Se(e);t(i)},$getUnitInputData({unitId:t},e){let i=r.getUnitInputData(t);e(i)},$setMetadata({path:t,data:e}){r.setMetadata(t,e)},$reorderSubComponent({parentId:t,childId:e,to:i}){r.reorderSubComponent(t,e,i)},$moveSubComponentRoot({parentId:t,children:e,slotMap:i}){r.moveSubComponentRoot(t,e,i)},$moveSubgraphInto({graphId:t,nextSpecId:e,nodeIds:i,nextIdMap:o,nextPinIdMap:a,nextMergePinId:s,nextPlugSpec:p,nextSubComponentParentMap:d,nextSubComponentChildrenMap:c}){let m=r.getGraphUnitBundleSpec(t);r.moveSubgraphInto(t,m,e,i,o,a,s,p,d,c)},$moveSubgraphOutOf({graphId:t,nextSpecId:e,nodeIds:i,nextIdMap:o,nextPinIdMap:a,nextMergePinId:s,nextPlugSpec:p,nextSubComponentParentMap:d,nextSubComponentChildrenMap:c}){let m=r.getGraphUnitBundleSpec(t);r.moveSubgraphInto(t,m,e,i,o,a,s,p,d,c)},$bulkEdit({actions:t}){r.bulkEdit(t)}}),Om=r=>({$watchGraph({events:n},t){return Gc(r,t,n)},$watchUnit({unitId:n,events:t},e){let i=r.getUnit(n);return Jn(i,e,t)},$watchGraphUnit({unitId:n,events:t},e){let i=this.refUnit(n);return Gc(i,e,t)},$watchUnitPath({path:n,events:t},e){let i=r.getUnitByPath(n);return Jn(i,e,t)},$watchGraphUnitPath({path:n,events:t},e){let i=r.getUnitByPath(n);return Gc(i,e,t)}}),Um=r=>({$compose({id:n,unitId:t,_:e}){let i=r.refSystem(),o=r.getSpec();if(i.hasSpec(n))throw new Error(`spec with id '${n}' already exists`);o.component&&!Ft(o.component.subComponents||{})?r.setElement():r.setNotElement();let s=ve({id:n});i.setSpec(n,s);let p=new Lt(s,{},i);p.addUnit(t,r,void 0,!1),p.play();let d=Mt(p,e);return Ct(d,e)},$refUnit({unitId:n,_:t}){let e=r.getUnit(n),i=Mt(e,t);return Ct(i,t)},$refSubComponent({unitId:n,_:t}){let e=r.getUnit(n),i=Mt(e,t);return Ct(i,t)}}),Rc=r=>_(_(_({},Om(r)),Pm(r)),Um(r));var wm=r=>({$get({name:n},t){b(this,null,function*(){let e;try{e=yield r.get(n)}catch(i){t(void 0,i.message)}t(e)})},$set({name:n,data:t},e){b(this,null,function*(){try{let i=st(t,{},{});yield r.set(n,i)}catch(i){e(void 0,i.message)}e()})}}),Lm=r=>({}),Gm=r=>({}),$1=r=>_(_(_({},wm(r)),Lm(r)),Gm(r));var Rm=r=>({$get(n,t){return r.mediaStream(t)}}),km=r=>({}),$m=r=>({}),N1=r=>_(_(_({},Rm(r)),km(r)),$m(r));var W3=(r,n)=>{let t=Bf(r,n);return Mt(t,t.__)},Nm=r=>({$getGlobalId(n,t){let e=r.getGlobalId();t(e)},$play(n){r.play()},$pause(n){r.pause()},$paused(n,t){let e=r.paused();t(e)},$reset(n){r.reset()},$push({pinId:n,data:t}){let{classes:e,specs:i}=r.__system,o=st(t,i,e);r.push(n,o)},$takeInput(n){let{pinId:t}=n;r.takeInput(t)},$setPinData({type:n,pinId:t,data:e}){let{classes:i,specs:o}=r.__system,a=st(e,o,i);r.setPinData(n,t,a)},$removePinData(n){let{type:t,pinId:e}=n;r.removePinData(t,e)},$getPinData(n,t){let e=r.getPinsData(),i=In(e);t(i)},$getInputData(n,t){let e=r.getInputData();t(e)},$getRefInputData(n,t){let e=r.getRefInputData(),i=vt(e,o=>{let a=o.getInterface();return{globalId:o.getGlobalId(),__:a}});t(i)},$getUnitBundleSpec(n,t){let e=r.getUnitBundleSpec(n.deep),i=j(e);t(i)},$pullInput(n){let{pinId:t}=n;r.getInput(t).pull()}}),Fm=r=>({$watch({events:n},t){return Jn(r,t,n)}}),Bm=r=>({$refGlobalObj(n){let t=r.refSystem(),{globalId:e}=n,i=W3(t,e);return Ct(i,i.__)}}),kc=r=>_(_(_({},Nm(r)),Fm(r)),Bm(r));var F1=r=>_(_(_({},Pc(r)),kc(r)),$c(r));var B1=r=>_(_({},F1(r)),Rc(r));var jm=r=>({}),Hm=r=>({}),Vm=r=>({$newGraph({bundle:n,_:t}){let e=r.fromBundle(n),i=r.newGraph(e),o=B1(i);return Ct(o,t)}}),j1=r=>_(_(_({},jm(r)),Hm(r)),Vm(r));var zm=r=>({$read(e,i){return b(this,arguments,function*({},t){let o;try{o=yield r.read()}catch(s){return t(void 0,s.message)}let a=Y(o);t(a)})},$write(i,o){return b(this,arguments,function*({data:t},e){yield r.write(t),e()})}}),Wm=r=>({}),Km=r=>({}),H1=r=>_(_(_({},zm(r)),Wm(r)),Km(r));var K3=r=>({}),q3=r=>({}),Y3=r=>({$refChildContainer({at:n,_:t}){return z1(r,{at:n,_:t})},$refParentRootContainer({at:n,_:t}){return W1(r,{at:n,_:t})},$refParentChildContainer({at:n,_:t}){return K1(r,{at:n,_:t})}}),V1=r=>_(_(_({},K3(r)),q3(r)),Y3(r));var Nc=(r,n,t)=>{let e=r;for(let i of n){let o=t[i];if(!o)throw new Error("async wrapper is not registered");let a=o(r);for(let s in a)e[s]=a[s]}return e};var Mt=(r,n)=>r.__async?r:Nc(r,n,{C:$c,CA:a1,E:s1,G:Rc,V:H1,MS:N1,U:kc,J:$1,W:V1,EE:Pc,S:j1});function q1(r,n,t){let e=r.appendChild(n);t(e)}function Y1(r,{at:n},t){try{let o=r.removeChild(n).getUnitBundleSpec().unit.id;t({specId:o})}catch(e){t(void 0,e.message)}}function J1(r,{at:n},t){let e=r.hasChild(n);t(e)}function X1(r,{at:n},t){let i=r.refChild(n).constructor.id;t(i)}function Z1(r,{},n){let e=r.refChildren().map(i=>({bundle:i.getUnitBundleSpec()}));n(e)}function Q1(r,{at:n,_:t}){let e=r.refChild(n),i=Mt(e,t);return Ct(i,t)}function z1(r,{at:n,_:t}){let e=r.refChildContainer(n),i=Mt(e,t);return Ct(i,t)}function W1(r,{at:n,_:t}){let e=r.refParentRootContainer(n),i=Mt(e,t);return Ct(i,t)}function K1(r,{at:n,_:t}){let e=r.refParentChildContainer(n),i=Mt(e,t);return Ct(i,t)}function t0(r,n,t){let e=r.getAnimations();t(e)}function e0(r,n,t){let e=r.getSetup();t(e)}var qm=r=>({$appendChild({specs:n,classes:t,specId:e},i){let o=le(e,n,t);q1(r,o,i)},$removeChild(n,t){return Y1(r,n,t)},$hasChild(n,t){return J1(r,n,t)},$child(n,t){return X1(r,n,t)},$children(n,t){return Z1(r,n,t)},$getAnimations(n,t){return t0(r,n,t)},$getSetup(n,t){return e0(r,n,t)}}),Ym=r=>({}),Jm=r=>({$refChild(n){return Q1(r,n)}}),$c=r=>_(_(_({},qm(r)),Ym(r)),Jm(r));var J3={EE:{call:Un,watch:wn,ref:Ln},U:{call:Bn,watch:jn,ref:Hn},G:{call:Gn,watch:Rn,ref:kn},C:{call:Mn,watch:Pn,ref:On},V:{call:Vn,watch:zn,ref:Wn},J:{call:$n,watch:Nn,ref:Fn},MS:{call:Dc,watch:Sc,ref:Ec},S:{call:Tc,watch:Ac,ref:Cc},CA:{call:Kl,watch:ql,ref:Yl}};function he(r){let n={};for(let t in r){let e=r[t],i=o=>{let{_:a}=o,s=e(o),p={call:{},watch:{},ref:{}};for(let d of a){let c=J3[d];for(let m of["call","watch","ref"]){let f=c[m];for(let g of f){let h=`$${g}`;p[m][h]=(...x)=>{let y=s[h](...x);return m==="ref"?Xn(y,y.__):y}}}}return p};n[t]=i}return n}function Xn(r,n){let t={},e={},i={};for(let a of n)switch(a){case"EE":t=_(_({},t),gm(r)),e=_(_({},e),hm(r)),i=_(_({},i),he(ym(r)));break;case"U":t=_(_({},t),Nm(r)),e=_(_({},e),Fm(r)),i=_(_({},i),he(Bm(r)));break;case"C":t=_(_({},t),qm(r)),e=_(_({},e),Ym(r)),i=_(_({},i),he(Jm(r)));break;case"G":t=_(_({},t),Pm(r)),e=_(_({},e),Om(r)),i=_(_({},i),he(Um(r)));break;case"V":t=_(_({},t),zm(r)),e=_(_({},e),Wm(r)),i=_(_({},i),he(Km(r)));break;case"J":t=_(_({},t),wm(r)),e=_(_({},e),Lm(r)),i=_(_({},i),he(Gm(r)));break;case"MS":t=_(_({},t),Rm(r)),e=_(_({},e),km(r)),i=_(_({},i),he($m(r)));break;case"S":t=_(_({},t),jm(r)),e=_(_({},e),Hm(r)),i=_(_({},i),he(Vm(r)));break;case"CA":t=_(_({},t),fm(r)),e=_(_({},e),lm(r)),i=_(_({},i),he(bm(r)));break;default:throw new Error("unknown interface")}return{call:t,watch:e,ref:i}}function n0(r){let n=!1,t;onmessage=function(e){let{data:i}=e,{type:o,data:a}=i;switch(o){case Zt:n=!0,t=r(a);break;case Ot:if(!n)throw new Error("ref was not initialized");t.exec(a);break;default:throw new Error("invalid message type")}}}var V=class extends Error{constructor(n){super(`${n} API not implemented`)}};var Fc=class extends V{constructor(){super("Display Media")}};var Bc=class extends V{constructor(){super("Media Devices")}};function an(r,n){return!!r.getItem(n)}function Be(r){return et(r)}function i0(r){let n={},t=Be(r);for(let e of t)n[e]=r.getItem(e);return n}function jc(){return i0(localStorage)}function r0(){return i0(sessionStorage)}var Hc=class{constructor(n){this._storage=n}read(){return b(this,null,function*(){return jc()})}write(n){return b(this,null,function*(){})}get(n){return b(this,null,function*(){let t=this._storage.getItem(n);if(t===null)throw new Error("item not found");return t})}set(n,t){return b(this,null,function*(){this._storage.setItem(n,t)})}delete(n){return b(this,null,function*(){this._storage.removeItem(n)})}deepSet(n,t){throw new O}deepGet(n){throw new O}deepDelete(n){throw new O}keys(){return b(this,null,function*(){return Be(this._storage)})}hasKey(n){return b(this,null,function*(){return an(this._storage,n)})}subscribe(n,t,e){throw new O}};function X3(r){return{getItem(n){throw new V(r)},removeItem(n){throw new V(r)},setItem(n,t){throw new V(r)},clear(){throw new V(r)}}}function o0(){return{storage:{local:()=>new Hc(X3("Local Storage"))},selection:{containsSelection:()=>{throw new V("Selection")},removeSelection:()=>{throw new V("Selection")}},file:{isSaveFilePickerSupported:()=>!1,isOpenFilePickerSupported:()=>!1,showOpenFilePicker:()=>{throw new V("File System")},showSaveFilePicker:()=>{throw new V("File System")},fallbackShowOpenFilePicker:()=>{throw new V("File System")},downloadText:n=>{throw new V("Download")},downloadURL:n=>{throw new V("Download")}},animation:{requestAnimationFrame:()=>{throw new V("Animation Frame")},cancelAnimationFrame:()=>{throw new V("Animation Frame")}},device:{vibrate:()=>{throw new V("Vibrate")}},geolocation:{getCurrentPosition:()=>{throw new V("Geolocation")}},input:{keyboard:{},gamepad:{getGamepad:()=>{throw new V("Gamepad")},addEventListener:(n,t,e)=>{throw new V("Gamepad")}},pointer:{getPointerPosition(n){throw new V("Pointer")},setPointerCapture(n,t){throw new V("Pointer Capture")}}},media:{getUserMedia:()=>{throw new Bc},getDisplayMedia:()=>{throw new Fc},enumerateDevices:()=>{throw new V("Enumerate Media Devices")},image:{createImageBitmap:()=>{throw new V("Image Bitmap")}}},screen:{requestWakeLock:()=>{throw new V("Screen Wake Lock")}},bluetooth:{requestDevice:()=>{throw new V("Bluetooth")}},clipboard:{read:()=>{throw new V("Clipboard")},readText:()=>{throw new V("Clipboard")},writeText:()=>{throw new V("Clipboard")}},http:{fetch:()=>{throw new V("Fetch")},EventSource:void 0,listen:function(n,t){throw new V("HTTP Server")}},channel:{local:function(n){throw new V("Local Channel")}},speech:{SpeechGrammarList:function(n){throw new V("Speech Recognition")},SpeechRecognition:function(n){throw new V("Speech Recognition")},SpeechSynthesis:function(n){throw new V("Speech Synthesis")},SpeechSynthesisUtterance:function(n){throw new V("Speech Synthesis")}},document:{createElement(n,t){throw new O},createElementNS(n,t){throw new O},createTextNode(n){throw new O},elementFromPoint(n,t){throw new O},elementsFromPoint(n,t){throw new O},getSelection(){return root.shadowRoot.getSelection()||document.getSelection()},createRange(){return document.createRange()},exitPictureInPicture(){throw new O},setTheme:function(n){throw new O},MutationObserver:null,PositionObserver:null,ResizeObserver:null,IntersectionObserver:null},querystring:{stringify:function(n){throw new O},parse:function(n){throw new O}},text:{measureText:n=>{throw new V("Measure Text")}},worker:{start:()=>{throw new V("Worker")}},db:void 0,url:{createObjectURL:function(n){throw new O}},uri:{encodeURI:function(n){throw new V("URI")}},alert:{alert:function(n){throw new O},prompt:function(n){throw new O}},location:{toString:function(){throw new O}},window:{open:function(n,t,e){throw new O},AudioContext:void 0,OscillatorNode:void 0,MediaStreamAudioSourceNode:void 0,AnalyserNode:void 0,GainNode:void 0,DelayNode:void 0,ImageCapture:void 0,CompressionStream:void 0,DecompressionStream:void 0,ReadableStream:void 0,getComputedStyle:function(n){throw new O}},navigator:{share:function(n){throw new O}},layout:{reflectChildrenTrait:function(n,t,e,i,o){throw new O}},history:{pushState:function(n,t,e){throw new O},replaceState:function(n,t,e){throw new O}}}}var a0="5a7912c7-9c67-45b6-ae2b-e352405e6c16";var s0="6fe452f2-2ec1-4ee2-887d-751c3697e6bf",p0="158d85eb-28b8-4355-b637-28a7ec751233",u0="872be100-f4dc-4246-8eea-6e3da31137b7",c0="c5c05c85-f4c1-4b67-ab85-08b61fe67531",d0="fa94b179-00e3-4ed1-814e-7938324a833f",Vc="fa7721eb-1dd6-482e-8c7a-6da35b5f88bc",m0="79f01345-4ed7-47e2-8882-fa3bd282c98a",zc="e9831075-2e62-43a4-84af-0653f7e707a9",f0="f57f5318-f26f-4b9f-b9e2-dcc022ad7728",Wc="609ec474-cd6b-4646-b9b9-5ef4bbb378a7",Kc="9741cb34-bc83-4ebb-a854-edbe9eb3468f";var l0="7014b684-ce58-4b6a-989d-bd6c047daab5",b0="104777ec-afb9-4513-9974-53b5528f0d15",qc="46d98b47-0fa4-409e-bbc6-bb3165d863d8",g0="81006022-e4d0-11ea-902a-fbf9fc5c9246",h0="d9cf4224-39df-434a-85a6-2b143330cbab",y0="22622778-d64f-47e7-8ceb-d175edcc6562",_0="f69e88e3-b2c2-481b-b036-a5c0ed7ccccb",Yc="c6bf897a-4970-4284-bea2-b4a86186f828",x0="d4572f1c-83d3-4a3d-be76-fa16578286d2",I0="be6801c0-02e2-4f76-bcad-b68c80991fad",v0="62d0c3e2-cf8b-4415-acfb-cf31739adce5",D0="0d656c2e-eb10-45f0-b236-f8916492ca86",S0="3d59edf2-5fca-4475-9df0-d876e14f990d",E0="85204bf6-6692-4686-a785-23127c0594b5",T0="1651ce6b-4db0-4787-9edf-f770b72d253c",A0="c9e06816-0d2b-43ec-b7c8-d07563e19b6b",C0="82c3cf2a-0855-4c6d-a4c4-807b0ce1fd35",M0="e13f3090-62a6-4a3b-8401-c571cbf03526",P0="bda175a9-a9d2-4282-9b50-1b008ae8a807",O0="ff976ac8-c54f-4d37-8c7d-089c271cb433",U0="329920ae-7e91-11ea-988e-1b12488c8b89",w0="260d774e-bc89-4027-aa92-cb1985fb312b",L0="06bc3983-44b0-43d6-b041-2e9218ea89c8",G0="8a2b756a-25e4-11eb-860d-1f34c850b992",R0="3432494e-fab6-4e9d-a846-0c48a7c429cd",k0="49e11645-c25d-4bf7-923d-56817f67b686",$0="36329d25-218d-48a5-a06c-1e0525da504f",N0="99657eb7-fb94-474e-b03d-4b08c537c0a2",F0="6d4b8791-95f8-4979-8290-ade2adf4f192",B0="9d853ef5-3fff-474d-a951-6af4237cf4c4",j0="ba38b0af-80c0-49e4-9e39-864396964ccc",H0="69323dab-b425-4a2a-b1c7-d7efc723327a",V0="2b24877a-3221-4288-9f59-efbf29964368",z0="63605ea1-40e7-47db-9f8f-313dffa6e3c9",W0="939ed573-82b8-4385-ac62-88934e5b76c9",K0="b80d4b5a-40e9-11eb-a2bb-1777d47bf9ae",q0="73967b68-9b4b-44c1-8a19-f505551f6c53",Y0="c47d84b2-4207-11eb-a064-a3633d64f05d",J0="76e99304-aa0c-11eb-9bfa-07725a1b4287",X0="3e5c5856-c721-11ea-b7af-07a978a65cdc",Z0="58900411-ccc3-4c5a-86df-86efe6b7e30e",Q0="563e92be-ad5e-4a61-a718-9249c3eac51d",tb="ee184ea6-3c80-4119-919e-290620aafab0",eb="407640f7-f1c3-4297-a5ce-baff357a6d31",nb="7d02d638-a311-4ea8-a0c0-d45baf739e0d",ib="62a19cd6-04bd-4e46-a72e-4fa3516ad3fa",rb="fafc23ce-a259-11eb-b14e-af9d1f579af4";var ob="62af44dc-17d6-459a-b95f-3b8ce5b48856",Jc="3217edcf-2fa1-4dc4-af7c-d6fb607c888d",ab="f68b0b2a-7967-445e-86a8-99ebc1e2144c",sb="e857c770-5a98-4f8d-a0e1-b6cb126071ed",pb="4e63c320-f5a5-4f65-982e-632b5adafa29",ub="3256e26d-8495-4c9d-8998-5b026691231d",Xc="ef4c1d0a-bda1-484e-8fcb-0fdbde195778",cb="2b59f375-ef06-4ec7-80c2-71a53171ec67",Zc="1a59348c-a25a-11eb-8afe-8bedb0732a89",db="b9f90a95-1bfc-4897-9068-2560743821a3",mb="530e83d2-1d61-11eb-b472-53e545a06c92",fb="13d738b9-401d-43c9-852f-e9611545f5bc",lb="2520668c-b279-11ea-ace3-5b84eb02bd7f",bb="123f2837-76c0-4cb2-8d73-29e66879b181",gb="1520b630-93aa-11ea-ac56-7718cb2ad75d",hb="56fb9a32-ad10-11ea-b0f4-3b0ea5e3ac2c",yb="8383c41e-3f9b-4d04-8380-feb583a1404f",_b="b0c25199-c284-4f90-817c-60dc89b15b1c",xb="b2626d61-b17d-4737-bea3-627c0322f9d6",Ib="1b592040-968f-456b-bdb5-b424e08b80f1",vb="e1486d65-7d51-436b-949d-4e57d1f9e4a9",Db="57bcdd88-a4f4-49ab-92d4-ed1969895520",Sb="f9f93972-0764-4095-9ca2-d18b7d9344d4",Eb="3be8272d-310a-4aa2-84a1-71f590a8227a",Tb="ae1f7fc0-d6e7-489c-94ed-dee71c68dbb7",Ab="e547c624-d505-485d-8d78-e393c6beb1b4",Cb="b5ea15f4-9bbd-11eb-b623-37aff4a9ce60",Mb="70972046-ad11-11ea-aaea-0b9067ad19e7",Pb="94e93f42-d05e-45d9-9211-ba903e779f2d",Ob="f712793d-8ee9-4805-9d4a-8c210cae667a",Ub="f60adade-f14e-11ea-b51e-537032a90354",wb="8cd29108-95cd-4217-9721-11f7c7c1131e",Lb="2ff102a7-b469-461f-a3b1-a61b81c1b325",Gb="2af12780-698c-40ca-baa9-5f3260377e0f",Rb="419e468e-e4d4-11ea-8efb-2b9d815b1798",Qc="664b5d3c-e4cf-11ea-ab74-eb6d2f3bd6f1",kb="9414421d-3376-4438-aa03-7afcd860972c",$b="ad2ae8b9-9674-4b22-bed4-4458e0030b1a",td="45b9c329-64e9-4c4a-800b-790947c75754",Nb="60bdba6d-c670-430f-be72-6f39cf4e8453",Fb="c4784b05-1f50-44ad-b812-545b3ed77614",Bb="964d3314-75fe-4a09-8ba8-c49145f29d49",jb="02f91720-c4d5-4d66-ae91-d46ddc635722",Hb="f97f2a74-d9a9-411d-afd3-fda46ba86c3b";var Vb="eb345e08-08fd-4032-bd69-a4e9f55e7aa6",zb="779e538c-b0b9-477e-a986-30ee3abe6fe6",Wb="25d0e003-f002-45ae-a50c-6fa3bffee4eb";var Kb="065d2fc3-af3b-4704-b26e-228d71f61771",qb="b16cccf7-fe33-43a6-b208-48db494376e8",Yb="af5469c4-a09e-4b22-8133-a21e721e7639";var Jb="e1e106ad-e15d-4044-82f6-27ddd476d7c8",Xb="141eaa06-bb12-42f1-a46f-32ceefb64ddc",Zb="c2fec1e6-b370-4069-bb43-6dab5a78b9ab",Qb="adde2d16-e1e6-4599-9a64-dd0968797041",t2="d4e4d4b2-80e0-4066-8d6f-5051e9a11a10";var ed="95076599-0f2f-46b6-a9e0-b4cbfdb8dcc9",e2="ac5863fc-5156-4a27-a6ce-148dc93f34dd",n2="a85fd9ad-5aec-4ebc-9008-e22db851dfa8",i2="49517cda-b9da-4d80-b849-61fc2260317d",r2="ff84b8cd-216f-4bcf-8e29-e7c9998cae3d",o2="43b43afd-9e7d-44ba-aef7-6e9db4ed8744",a2="33434271-3533-4a4e-adb9-306e35ab6afe",s2="0b4aa055-010d-4d43-b991-f38a95cdb380",p2="fa3d97bb-060d-4671-9c18-dff81f64c1cc",u2="1df77a6e-7632-44f0-9878-2aa5e0903928",c2="b949221c-8227-4178-bde4-5e8754a7ed39",d2="d6f727ee-5158-4e2b-a2d4-a84ee712144e",m2="ee7b692f-5fe5-43c3-b636-aacca92b0bc7",f2="c7f6f43e-e8ed-11ea-92b2-0bd612272247",l2="4ad5bd0e-e11e-11ea-ad4c-83da30628333",b2="dd520754-e138-11ea-879e-3bd947893124",g2="a44b2198-e18d-11ea-be3b-77e13b78b7e3",nd="6796cd2d-2bd2-4dd3-9396-49d6bc1d2652",h2="2b0ef9e9-028b-4acc-9daf-6999e86cc2af",y2="58385055-7f06-472a-be9e-26bb5bce276a",_2="81c0f469-ab88-4bc8-89d5-98d291b1d8b2",x2="1ef77768-7394-4b83-ad11-f5905fa9d0d3",I2="288aede9-59ea-4cb4-baf9-fef9109cc2b9",v2="53018958-b686-11ea-bf53-175a3698c92d",D2="82cf909e-a78f-4f3e-b87a-976458c8e15d";var S2="be59cf84-fcf2-46ef-aa34-6f0f8e055680",E2="f5b2faf1-3a8b-489f-9d99-62d3c749ced6",T2="3ab81e83-5954-4bae-ad3e-ebf409dd23c4",A2="8e978642-b686-41fd-b2af-9a4c5db6bfa4",C2="3c47d4bc-315d-4600-a9cd-6e388b345980",M2="138d16a7-a200-4329-9b4a-17abd24943d4",P2="8f7ce559-a046-45bc-8e98-c39934ed0ae6";var O2="9a7c22e3-3de2-4c99-ac1f-b2f8ceffae99",id="c0e124ca-381a-414b-93a2-41526df02e28",U2="83d22558-2c6f-4dd4-a231-baba798d1d97",w2="c9d64ef4-35f6-44e7-a16b-1e4173f951dc",L2="b2eb49a8-7a7a-446a-ad36-e7c1efdaf61f",G2="6f79ee03-4b3f-439c-b955-5529f3bebcc9",R2="0b5a71c6-5c43-4e55-a29c-27d9ff7ed43a";var k2="ee4715e6-f479-11ea-b231-bf95a7f38a99",$2="1ba97b81-5084-49b8-8fbf-227ccd31cabc",N2="c475117a-02b9-11eb-b7c8-579fe4f6c669",F2="41a8c91e-87f8-4d96-9714-33716f329f7b",B2="1ba931d8-0226-4600-9a48-dbb1b17d8d82",j2="fb3fc7b4-3175-41ce-9546-cf3a07053cdc",H2="6dbff818-02b9-11eb-9ee7-93b57419f741";var V2="a1cd3c3c-b1fa-40a2-80d1-32f416264a3d",z2="367241d8-ad12-11ea-beed-9777f31699a8",W2="77238fd9-a968-454d-b7ce-0277bc37475d",K2="a9cba5ec-940d-42a3-b861-86197402cbe4",rd="53dd6448-f1e8-46ed-b3e8-b03b846133bb";var q2="8f72e51a-0c65-47f6-b22b-868c8a00c6dc",Y2="817c76ba-a71c-4136-af86-bd6b69106c45",J2="30f6738c-1938-4dcd-9e7f-6c10f9730021",X2="210632fc-f85b-4f13-a2a9-f689ff85da78",Z2="f5df301d-da63-492a-9e59-950289fe6ba9",Q2="71ff4fda-5878-4d4c-b55b-c2c79d8dc546",tg="5c13db99-0923-4b27-85e3-7a18dbfdd309",eg="a7dee8c6-15a3-4b7e-8f63-03f13a7d34a9",ng="9543c94b-e19e-430b-8a48-9cda8dae44c5",ig="a8d7c089-0385-4922-bb3a-6c550a8a1b3b",rg="2ec96f8b-4ea5-4ba8-ab8d-a00105c6cb71",og="e4ea5dce-10ea-434b-a93d-c874a92f2f39",ag="31408be3-cc2a-490a-b0d1-96e0028ca68e",sg="33c623e5-bce2-4f30-9a98-50218bb6c431",pg="c2738ec3-72fa-4432-96b9-74abb1a6f26a",ug="30e125ba-af81-11ea-ba6b-e70218ca7afe",cg="b5ab65ce-4306-4a46-8d3c-36b6c29b1c60",dg="c18c8f59-f3c8-49a8-9dbd-ed30fdf856e9",mg="3511f756-2a02-4346-b417-8c34502f79d4",fg="6705462c-5b47-11eb-9dfc-2f14c58b2789",lg="0bc0c4ad-d2e0-4e3e-92e8-5b9dfee1cf5e",bg="f238caff-3f71-40d9-b1a9-d992060fea04",gg="262beb5f-21bd-4848-a62d-185f6f8a78e1",hg="a57383a9-5b24-4dbb-a5d1-0e278d036f89",yg="7e1b3a4c-be6b-11eb-b098-1b6b9db93f1e",_g="3889d2f1-a0ed-4e8c-8e75-7a6683224275",xg="a6e30b43-9ab4-4206-bfba-3f2129faac30",Ig="41de8d5e-2c41-441c-ad29-cc3f5d4e6c7a",vg="c5856fdc-5154-46ab-a414-47f37af39da1",Dg="b97c0133-6c87-4b69-af4e-354c0b590ece",Sg="b8fc168e-ee2f-11ea-a42a-730934861ff1",Eg="4e14b9e8-a694-4c58-b509-fc53a279c22c",Tg="29e974cc-081b-11eb-a607-1fd4ec67a52f",Ag="bb029770-080e-11eb-9d38-f314d076f14b",Cg="5aea0bf0-0815-11eb-9304-5f90b5542620",Mg="34a36b3a-cb04-4429-bdbc-15e0c278ad7a",Pg="e8aded15-a1af-42a0-9a9d-f88fcfd03dc3",Og="b27ee28f-54fb-4737-91f5-04b52b7cf92d",Ug="2f2d5ea4-6dd2-406e-a095-5552ebc235e7";var wg="d4ec46ab-d065-4d1c-9357-fa8b95be0c36",Lg="f079a38e-fb4f-496e-8e5f-d5e03a590cda",Gg="16fa715f-fc94-43f7-831e-335037c8daea",Rg="7375aad5-50fd-403c-80ae-471b95088f04",kg="d3fc887c-9fc5-11eb-8f63-ab42b0414469",$g="c6f309c8-9ca7-459c-9dd5-c9c9f92fbe8f",Ng="eed20c86-41fe-46d4-87ba-ad2e6fb1bd4a",Fg="f9be5d07-9548-4a14-b5b9-fa954599a170",Bg="de9665db-a188-4252-99f0-ea50fc343058",jg="b296242e-8b82-11eb-ac6c-0f8d3f9948d0",Hg="04eda925-4423-40c8-83c8-2117a0d81185",Vg="416550cc-6e02-4ff2-aafa-2f0edbf121c6",zg="6db29a62-2035-4cfc-a9d3-03444a8bc2b8",Wg="c8f3faa8-09f4-11eb-a3b1-477aa3ec4193",Kg="dc513ed0-09f4-11eb-a54a-7f4d4e253ef5",qg="08ff535a-93a7-403c-a1ef-c59cdb50ccf0",Yg="0f041192-1ff3-4094-93da-9264480ad5e2";var Jg="baadad13-b70f-4310-b4aa-8c81fe5a9d69",Xg="1d5b6bb0-f18e-4428-a350-a29d8ca3ff4a",Zg="5bd48844-67c6-4fdc-b23b-f03cd561877f",Qg="27e2f302-c23a-4447-abde-8309a94b331d",t4="81ac8195-57ed-4b22-b8b8-fe3e68b11af0",e4="68992d62-d5ca-11ea-888d-97179b32b7ab",n4="81a54674-4e9c-11eb-a0e4-2b75980dbd9b",od="1baddd01-97a9-4971-b74a-e933fefdb629";var i4="72c84615-4d9c-4a82-a828-fa5d9447a4d5",r4="ccf6d0e2-6b08-11eb-9fc3-3785374109d0",o4="0e9e6cd4-67eb-11ea-995b-4b0721193361",a4="c18d7dcc-939b-11ea-90cb-77846d7504a9",s4="e8bce1fc-ae56-4f9f-9685-3cc844758855",p4="e80c912e-7508-11ea-966b-436805345ff0",u4="0f043df2-46fc-11eb-ae20-6f1fedd527ba",c4="c9b62bcc-8196-11eb-8372-9f2ac2c356d4",d4="96d5d60e-85eb-11eb-ba90-7fc42ab0a641",m4="84bfce28-2116-11eb-82ca-cfb03193bf58";var f4="e6b88d1e-8755-11ea-916e-d3995fb8986e",l4="d0672722-b1a9-11ea-a247-d736e666990e",b4="023c3762-c701-11ea-b590-57b51c2884a7",g4="deda524e-6990-11eb-9bc3-e7d55b583fa3",h4="0e1d716e-a13f-11ea-ac6a-8fd610c86910";var y4="fcccb9a4-1a30-11eb-93b0-e7d511d031f2",_4="bc34c618-1c77-11eb-9785-e39a2bf52e49",x4="6b18c608-7b5a-11ea-bb6e-2ff12a5cc3f3",I4="e39a2a34-c71a-11ea-9835-07964acf6760",v4="b61f5cc6-37e9-45e1-965b-02940820f7ce",D4="94243ec4-8967-4907-8cdd-7223fe256cf6",S4="7c27cf95-6226-4326-8619-32d82bcbe16d",E4="66698a97-15c5-4602-9925-11a1aeb03710";var T4="d7c86a2a-489f-11eb-b83e-d3767f6d49b7",A4="dd7616e2-2e64-4d9c-b13e-ca7efeacd982",C4="321f971c-b898-4ca4-9e6e-3d75d68940f7",M4="b7f043ee-4f9d-4f69-90fe-63b1357ff4c2",P4="63a417e5-d354-4b39-9ebd-05f55e70de7b",O4="32ff22b0-8221-4584-9c78-d21102dcfa6a",U4="b5286262-9f92-40d3-8545-88fb3079a0f9",w4="23b7df22-79e0-4233-8388-7e6e8f1859c6",L4="06823924-b659-4a22-8ed4-b3243121b55d",G4="059579bb-184f-435b-ace0-64ec95c9f125",R4="44968bd5-f1a5-4f81-a32f-8ee5a6e4a842",k4="ab507863-2307-40c6-982b-c45680458997",$4="7a8921eb-c1ad-400b-94fc-6c6cead8163d",N4="2a5ad480-9d38-4918-8774-41fac7b54203",ad="78b0939d-43e1-4f6c-867d-e4217a55d217",F4="7772a2f5-40c8-482e-83f4-bed9bfb364e3",B4="c711d540-9de3-437e-854a-b59491af3cf8",j4="62ca7eae-ea36-4960-a8f2-6b5978cabbab",H4="7666978e-252c-11eb-97a4-0f3e81286cae",V4="3fcb8e64-923d-11ea-bab1-43fa3b273af8",z4="e049f16e-2559-11eb-bdc4-db5b8a11164b",W4="be11165e-489f-11eb-921f-87b924eb0725",K4="38d26d76-2559-11eb-ae02-dfda9b9b137e",q4="9932f3bc-9241-11ea-89fa-0b2fdace0f08",Y4="60bc7930-8982-11ea-8b24-cf97a783bb32",J4="c0bfe832-8967-11ea-8c4c-1f2995e41b68",X4="98c279fc-7f5e-11ea-b9e4-f772f9f0bed1",Z4="49ef122e-b4d1-11ea-b45e-b73d8ee2aae8",Q4="00c828fc-9243-11ea-b897-5b0fc55820c5",th="ad12678e-6642-11eb-9fc3-9fbc75c58110",eh="096fc4ca-edd2-11ea-8266-37b634a3ee0b",nh="d8aa573f-129e-4587-9c64-674729d024e2",ih="6309ac3f-4a37-4ab0-86c6-8be70b38e31d",rh="e2109627-9783-4664-a70c-858fd8c46ea5",oh="9bc56564-ef4e-11ea-939a-27ae3feb321e",ah="c0d13c03-9b10-4a6f-a79f-66294d10aae6",sh="51c2c7b4-cb8a-42e8-95ab-14b8ac37700c",ph="6c7cd7d1-c8a0-4317-9c8c-ba781f150729",uh="e06518cf-9edf-430b-8751-74c486e407aa",ch="87f99b85-1c24-4e5b-a903-dd27230f4092",dh="83ec6688-b80b-4ef2-861f-14245ef392c0",mh="6a14988f-5f4b-4fab-af32-226b7844e41f",sd="454aaff2-cd74-4f6e-baf2-631bb32e7a6b",fh="3ffeaaf8-30dd-11eb-9dcc-836b075fc64d";var lh="8be95fbe-8f10-467b-bbdd-87311ca62594",bh="002af312-560a-11eb-807c-8769b90eb8e6",gh="f1ed986a-55df-11eb-89e3-9f7cc8490b16",hh="ef550ed4-5608-11eb-8ee3-0be8f1fce185",yh="159aa41d-fb45-4f75-836b-09a3639156e5",_h="04b06e1c-b782-40fc-bbb3-e932b56db8a2",xh="0966c9b3-2fd5-4b5b-8146-82fb08bd14c4",Ih="738a0ac4-8805-4189-a46c-b7d7fcf63456",vh="59afce80-30e7-4322-84e6-955767bb5106",Dh="d4945010-686d-431b-a884-1a4db0bfafc4",Sh="355b5332-0cc9-4a5c-989e-043d717215ec";var Eh="c320b1b2-c130-4d69-b172-0c737b72c6b5";var Th="ec482aaf-0029-4b85-b03a-de5bd361d706",Ah="04e8b64e-7fed-49a0-af48-eba025be3fbc",Ch="05b6f707-a009-40aa-aacb-a15888c2a8b3",Mh="b51db03f-4d2d-44f9-bbd9-116aa0b086d0",Ph="05169310-5447-4cf8-a90f-fda957de4891",Oh="12d1e7be-a5a6-45ba-82d7-cce3d03b96e2",Uh="d0f94e4e-43f4-4c0a-b07e-ca40c82f48f4",wh="64f8e8bc-124d-49f6-a143-625265eafe68";var Lh="bc0320e2-2eb8-11eb-a38f-a779bfe81645",Gh="b409ff98-1c9e-4990-b2c2-d7f32fda50eb";var Rh="074ef6f4-a0a1-40f9-95c0-cf0ecc3d420c",kh="610b35bc-a709-4eed-a655-9ee0baa860f8",$h="eaf5e67b-6c48-4a27-85e1-9d5a8aa72e24",Nh="bddaba6f-83c8-4d25-97e2-ef1cdecd19e4",Fh="de2d42e2-4fca-4a3f-8783-3585c546e88b",Bh="324b9c5e-5810-11eb-bf7c-634b3bb07f8c",jh="5ec9d37d-f9f4-49d0-a139-55af26fab05c",Hh="259ba71c-6315-4324-a32c-fc2277200a40",Vh="7fe5b907-e9d3-4427-96cf-1b3be39a9bba",zh="c6da6b9f-a783-4e58-a252-e543aef109fb",Wh="98ab5ee1-0997-4ad2-bc77-776208b6bb25",Kh="0c6703a1-e949-4b55-9e84-71e6c9addd64",qh="4ae69887-a087-4d37-8743-d83ca48184d1",Yh="ed78b920-3f43-47df-840c-60c5297cdb2e",Jh="c899b675-c3c4-428e-b548-b228305c0302",Xh="cd8c1d94-1471-49e2-8b43-d98ae93b70f3";var Zn=class extends l{constructor(n){super({i:["a","b"],o:["a + b"]},{},n,s0)}f({a:n,b:t},e){e({"a + b":n+t})}};var Qn=class extends l{constructor(n){super({i:["a","b"],o:["a \xF7 b"]},{},n,p0)}f({a:n,b:t},e){t===0?e(void 0,"cannot divide by 0"):e({"a \xF7 b":n/t})}};var ti=class extends l{constructor(n){super({i:["a","b"],o:["a \xD7 b"]},{},n,u0)}f({a:n,b:t},e){e({"a \xD7 b":n*t})}};var ei=class extends l{constructor(n){super({i:["a","b"],o:["a % b"]},{},n,c0)}f({a:n,b:t},e){t===0?e(void 0,"cannot divide by 0"):e({"a % b":n%t})}};function Xm({a:r,b:n}){return{"a - b":r-n}}var ni=class extends l{constructor(n){super({i:["a","b"],o:["a - b"]},{},n,d0)}f(n,t){t(Xm(n))}};var ii=class extends l{constructor(n){super({i:["a","b"],o:["a"]},{},n,Vc)}f({a:n,b:t},e){e({a:[...n,t]})}};var ri=class extends l{constructor(n){super({i:["a","i"],o:["a[i]"]},{},n,m0)}f({a:n,i:t},e){t>=0&&t<n.length?e({"a[i]":n[t]}):e(void 0,"index out of boundary")}};var oi=class extends l{constructor(n){super({i:["a"],o:["a","head"]},{},n,zc)}f({a:n},t){if(!n.length){t(void 0,"cannot behead empty array");return}let e=[...n],i=e.shift();t({a:e,head:i})}};var ai=class extends l{constructor(n){super({i:["a","b"],o:["ab"]},{},n,f0)}f({a:n,b:t},e){e({ab:n.concat(t)})}};var si=class extends l{constructor(n){super({i:["a","value","start","end"],o:["a"]},{},n,Wc)}f({a:n,value:t,start:e,end:i},o){o({a:n.fill(t,e,i)})}};var pi=class extends l{constructor(n){super({i:["a[]","a"],o:["i"]},{},n,Kc)}f({"a[]":n,a:t},e){e({i:n.indexOf(t)})}};var ui=class extends l{constructor(n){super({i:["n","a"],o:["a[]"]},{},n,a0)}f({a:n,n:t},e){e({"a[]":new Array(t).fill(n)})}};var ci=class extends l{constructor(n){super({i:["a","i","b"],o:["a"]},{},n,l0)}f({a:n,i:t,b:e},i){let o=[...n];o.splice(t,0,e),i({a:o})}};var di=class extends l{constructor(n){super({i:["a","sep"],o:["str"]},{},n,b0)}f({a:n,sep:t},e){let i=n.join(t);e({str:i})}};var mi=class extends l{constructor(n){super({i:["a"],o:["length"]},{},n,qc)}f(n,t){t(Bd(n))}};var fi=class extends l{constructor(n){super({i:["a"],o:["a","last"]},{},n,g0)}f({a:n},t){if(n.length>0){let e=[...n],i=e.pop();t({a:e,last:i})}else t(void 0,"cannot pop empty array")}};var li=class extends l{constructor(n){super({i:["a","b"],o:["a"]},{},n,h0)}f({a:n,b:t},e){e({a:[t,...n]})}};var bi=class extends l{constructor(n){super({i:["a","v","i"],o:["a"]},{},n,y0)}f({a:n,v:t,i:e},i){if(e<n.length){let o=[...n];o[e]=t,i({a:o})}else i(void 0,"index out of boundary")}};function Zm({a:r,start:n,count:t}){let e=[...r],i=e.splice(n,t);return{a:e,removed:i}}var gi=class extends l{constructor(n){super({i:["a","start","count"],o:["a","removed"]},{},n,_0)}f(n,t){t(Zm(n))}};function Qm({a:r,begin:n,end:t}){return{a:r.slice(n,t)}}var hi=class extends l{constructor(n){super({i:["a","begin","end"],o:["a"]},{},n,Yc)}f(n,t){t(Qm(n))}};var D=class extends Q{constructor({fi:t=[],fo:e=[],i=[],o=[]},a={},s,p){super({i:[...t,...i],o:[...e,...o]},a,s,p);this._done=(t,e=null)=>{this._functional._done(t,e)};let d=this,c=new class extends l{constructor(g){super({i:t,o:e},{},g,`_${p}`)}f(g,h){d.f(g,h)}d(){d.d()}i(){d.i()}}(this.__system);this._functional=c,c.play();let m=new class extends Q{constructor(g){super({i,o},{},g,`_${p}`)}onDataInputData(g,h){d.onIterDataInputData(g,h)}onRefInputData(g,h){d.onIterRefInputData(g,h)}onDataInputDrop(g){d.onIterDataInputDrop(g)}onRefInputDrop(g){d.onIterRefInputDrop(g)}onDataOutputDrop(g){d.onIterDataOutputDrop(g)}onRefOutputDrop(g){d.onIterRefOutputDrop(g)}onDataInputInvalid(g){d.onIterDataInputInvalid(g)}onRefInputInvalid(g){d.onIterRefInputInvalid(g)}}(this.__system);m.play(),this._primitive=m;for(let f of t)c.setInput(f,this.getInput(f),this.getInputOpt(f));for(let f of e)c.setOutput(f,this.getOutput(f),this.getOutputOpt(f));for(let f of i)m.setInput(f,this.getInput(f),this.getInputOpt(f));for(let f of o)m.setOutput(f,this.getOutput(f),this.getOutputOpt(f));c.addListener("err",f=>{this.err(f)}),c.addListener("take_err",()=>{this.takeErr()}),this.addListener("take_err",()=>{c.takeErr()}),this.addListener("take_caught_err",()=>{c.takeCaughtErr()}),this._f_i=new Set(t),this._f_o=new Set(e),this.addListener("set_input",(f,g,h,x)=>{this._f_i.add(f),c.addInput(f,g,h)}),this.addListener("set_output",(f,g,h,x)=>{this._f_o.add(f),c.addOutput(f,g,h)})}f(t,e){}d(){this.fd()}fd(){}i(){this.fi()}fi(){}onIterDataInputData(t,e){}onIterRefInputData(t,e){}onIterDataInputDrop(t){}onIterRefInputDrop(t){}onIterDataOutputDrop(t){}onIterRefOutputDrop(t){}onIterDataInputInvalid(t){}onIterRefInputInvalid(t){}destroy(){this._functional.destroy(),this._primitive.destroy(),super.destroy()}};function Zh(r,n,t=[]){for(t.push(r);t.length;){let e=t.shift();n(e),e.left&&t.push(e.left),e.right&&t.push(e.right)}}function Z3(r){let n=null;return Zh(r,t=>{(!t.left||!t.right)&&(n||(n=t))}),n}function Qh(r){let n=null;return Zh(r,t=>{n=t}),n}function ty(r,n){return b(this,null,function*(){let t=[];do{t.push(r.value);let e=Qh(r);r=yield ey(e,n),r&&(r.value=e.value,yield pd(r,n)),r=r&&sn(r)}while(r);return t})}function ey(r,n){return b(this,null,function*(){let{parent:t,left:e,right:i}=r,o=sn(r),a=Qh(o);return a.parent&&(a.parent.left===a?a.parent.left=null:a.parent.right=null),r.parent=null,r.left=null,r.right=null,a===o?null:a===r?t&&sn(t)||null:(a.parent=t,t?(t.left===r?t.left=a:t.right=a,yield tf(a,n)):(a!==e&&(a.left=e,e&&(e.parent=a)),a!==i&&(a.right=i,i&&(i.parent=a)),yield pd(a,n)),sn(a))})}function pd(r,n){return b(this,null,function*(){let{parent:t,value:e,left:i,right:o}=r,a=!i||(yield n(e,i.value)),s=!o||(yield n(e,o.value)),p=()=>b(this,null,function*(){r.left=o.left,o.left&&(o.left.parent=r),r.right=o.right,o.right&&(o.right.parent=r),o.left=i,i.parent=o,o.right=r,r.parent=o,o.parent=t,t&&(t.left===r?t.left=o:t.right=o),yield pd(r,n)}),d=()=>b(this,null,function*(){r.left=i.left,i.left&&(i.left.parent=r),r.right=i.right,i.right&&(i.right.parent=r),r.parent=i,i.left=r,i.right=o,i.parent=t,t&&(t.left===r?t.left=i:t.right=i),o&&(o.parent=i),yield pd(r,n)});if(i&&o)a&&s||(a?yield p():s?yield d():(yield n(i.value,o.value))?yield d():yield p());else if(i)a||(yield d());else return null})}function tf(r,n){return b(this,null,function*(){if(r.parent&&(yield n(r.value,r.parent.value))){let{parent:t,left:e,right:i}=r;r.parent=t.parent;let o=t.left===r;return t.parent&&(t.parent.left===t?t.parent.left=r:t.parent.right=r),t.parent=r,o?(r.left=t,r.right=t.right,t.right&&(t.right.parent=r)):(r.right=t,r.left=t.left,t.left&&(t.left.parent=r)),t.left=e,e&&(e.parent=t),t.right=i,i&&(i.parent=t),yield tf(r,n),t}return null})}function ny(r,n,t){return b(this,null,function*(){if(r===null)return n;for(;n;){let e=yield ey(n,t),i=Z3(r);i.left?i.right=n:i.left=n,n.parent=i,yield tf(n,t),n=e}return sn(r)})}function sn(r){return r.parent?sn(r.parent):r}var je=class{constructor(n=void 0){this._data=void 0;this._callback=[];this._data=n}set(n){this._data=n;for(let t of this._callback)t(n);this._callback=[]}clear(){this._data=void 0}once(){return b(this,null,function*(){return this._data!==void 0?this._data:new Promise((n,t)=>{let e=()=>{n(this._data)};this._callback.push(e)})})}};var yi=class extends D{constructor(t){super({fi:["a"],fo:["b"],i:["a[i] < a[j]"],o:["a[i]","a[j]"]},{},t,x0);this._forward_waiter=new je;this._backward_waiter=new je;this._predicate=(t,e)=>b(this,null,function*(){this._forwarding=!0,this._output["a[i]"].push(t),this._output["a[j]"].push(e),this._forwarding=!1;let i=yield this._forward_waiter.once();return this._forward_waiter.clear(),this._input["a[i] < a[j]"].pull(),yield this._backward_waiter.once(),this._backward_waiter.clear(),i})}f(i,o){return b(this,arguments,function*({a:t},e){let a=null;for(let p of t)a=yield ny(a,{parent:null,left:null,right:null,value:p},this._predicate);let s=a?yield ty(a,this._predicate):[];e({b:s})})}onIterDataInputData(t,e){switch(t){case"a[i] < a[j]":{this._forward_waiter.set(e);break}}}onIterDataOutputDrop(t){this._forwarding||this._output["a[i]"].empty()&&this._output["a[j]"].empty()&&this._backward_waiter.set(!0)}};var _i=class extends l{constructor(n){super({i:["a","b"],o:["a & b"]},{},n,I0)}f({a:n,b:t},e){e({"a & b":n&t})}};var xi=class extends l{constructor(n){super({i:["a"],o:["~a"]},{},n,v0)}f({a:n},t){t({"~a":~n})}};var Ii=class extends l{constructor(n){super({i:["a","b"],o:["a | b"]},{},n,D0)}f({a:n,b:t},e){e({"a | b":n||t})}};var vi=class extends l{constructor(n){super({i:["a","b"],o:["a ^ b"]},{},n,S0)}f({a:n,b:t},e){e({"a ^ b":n^t})}};function He(r,n){let t=typeof r;if(t!==typeof n)return!1;if(t==="string"||t==="number"||t==="boolean"||t==="symbol"||t==="undefined"||t==="function")return r===n;if(t==="object"){if(r===n)return!0;let i=et(r).length,o=et(n).length;if(i!==o)return!1;for(let a in r){let s=r[a],p=n[a];if(!He(s,p))return!1}}return!0}var Di=class extends l{constructor(n){super({i:["a","b"],o:["a = b"]},{},n,E0)}f({a:n,b:t},e){e({"a = b":He(n,t)})}};var Si=class extends l{constructor(n){super({i:["a","b"],o:["a > b"]},{},n,T0)}f({a:n,b:t},e){e({"a > b":n>t})}};var Ei=class extends l{constructor(n){super({i:["a","b"],o:["a \u2265 b"]},{},n,A0)}f({a:n,b:t},e){e({"a \u2265 b":n>=t})}};var Ti=class extends l{constructor(n){super({i:["a","b"],o:["a < b"]},{},n,C0)}f({a:n,b:t},e){e({"a < b":n<t})}};var Ai=class extends l{constructor(n){super({i:["a","b"],o:["a \u2264 b"]},{},n,M0)}f({a:n,b:t},e){e({"a \u2264 b":n<=t})}};var Ci=class extends l{constructor(n){super({i:["a","b"],o:["a \u2260 b"]},{},n,P0)}f({a:n,b:t},e){e({"a \u2260 b":!He(n,t)})}};var Mi=class extends Q{constructor(t){super({i:["a"],o:["a"]},{},t,O0);this._current=void 0;this.addListener("reset",()=>{this._current=void 0})}onDataInputData(t,e){this._current=e,this._output.a.push(e)}onDataInputDrop(t){this._backwarding||(this._forward_all_empty(),this._current=void 0)}onDataOutputDrop(t){this._forwarding_empty||this._output.a.push(this._current)}onDataInputInvalid(t){this._invalidate()}};var Pi=class extends Q{constructor(t){super({i:["a","d"],o:["a"]},{},t,U0);this._current=void 0;this.addListener("reset",()=>{this._current=void 0})}onDataInputData(t,e){t==="a"?(this._current=e,this._input.d.empty()||this._invalidate()):t==="d"&&this._input.a.empty()&&(this._current=e),this._forward_if_ready()}_forward_if_ready(){for(;!this._forwarding&&!this._backwarding&&this._active_o_count-this._o_invalid_count===0&&this._current!==void 0;)this._forward("a",this._current)}_done(){this._backwarding=!0,this._input.a.empty()?this._input.d.pull():this._input.a.pull(),this._backwarding=!1}onDataInputDrop(t){t==="a"?this._input.d.empty()?(this._current=void 0,this._forward_all_empty()):(this._current=this._input.d.peak(),this._invalidate(),this._forward_if_ready()):this._input.a.empty()&&(this._current=void 0,this._forward_all_empty())}onDataOutputDrop(t){this._current=void 0,this._done(),this._input.a.empty()?this._input.d.empty()||(this._current=this._input.d.peak(),this._forward_if_ready()):(this._current=this._input.d.peak(),this._forward_if_ready())}onDataInputInvalid(t){this._invalidate()}};var Oi=class extends l{constructor(n){super({i:["a"],o:["a"]},{},n,w0)}f({a:n},t){t({a:n})}};var Ui=class extends l{constructor(n){super({i:["a","b"],o:["a if b"]},{},n,L0)}f({a:n,b:t},e){e(t===!0?{"a if b":n}:{"a if b":void 0})}};var wi=class extends Q{constructor(t){super({i:["init","next"],o:["local","current"]},{},t,G0);this._current=void 0;this._next=void 0;this.addListener("reset",this._reset)}_reset(){this._current=void 0,this._next=void 0}onDataInputData(t,e){t==="init"?(this._current=e,this._output.local.push(e),this._output.current.push(e)):t==="next"&&(this._current=e,this._next=!0,this._output.current.push(e),this._input.next.pull(),this._output.local.empty()&&(this._output.local.push(this._current),this._next=void 0))}onDataInputDrop(t){if(!this._backwarding&&t==="init"){this._reset(),this._forward_all_empty();return}}onDataOutputDrop(t){this._forwarding_empty||(t==="current"?(this._output.local.pull(),this._input.init.pull()):t==="local"&&this._next===!0&&(this._next=!1,this._output.local.push(this._current)))}onDataInputInvalid(t){t==="init"&&(this._reset(),this._output.local.invalidate()),this._output.current.invalidate()}snapshotSelf(){return Z(_({},super.snapshotSelf()),{_current:this._current,_next:this._next})}restoreSelf(t){let a=t,{_current:e,_next:i}=a,o=bt(a,["_current","_next"]);super.restoreSelf(o),this._current=e,this._next=i}};var Li=class extends Q{constructor(t){super({i:["init","next","test"],o:["local","current","final"]},{},t,R0);this._current=void 0;this._next=void 0;this._test=void 0;this._looping=!1;this._nexting=!1;this.addListener("reset",this._reset)}_reset(){this._current=void 0,this._next=void 0,this._nexting=!1,this._looping=!1}onDataInputData(t,e){t==="init"?(this._current=e,this._output.local.push(e),this._forward_if_ready()):t==="next"?this._next===void 0&&this._current!==void 0&&this._input.test.peak()&&(this._next=e,this._pull_next()):t==="test"&&(this._test=e,this._current!==void 0&&this._forward_if_ready())}onDataInputDrop(t){if(!this._backwarding){if(t==="next")return;if(t==="test"){this._test=void 0,this._next=void 0,this._forward_empty("current"),this._forward_empty("final");return}if(t==="init"){this._reset(),this._forward_all_empty();return}}}onDataOutputDrop(t){this._forwarding_empty||(t==="current"?this._next!==void 0&&this._loop():t==="local"?this._current===void 0?this._done():this._looping&&(this._looping=!1,this._output.local.push(this._current),this._test!==void 0&&this._forward_if_ready()):(this._current=void 0,this._backward("test"),this._output.local.empty()&&this._done()))}onDataInputInvalid(t){t==="init"?(this._reset(),this._output.local.invalidate()):t==="test"&&(this._nexting=!1,this._next=void 0),this._output.current.invalidate(),this._output.final.invalidate()}_pull_next(){this._nexting=!1,this._input.next.pull(),this._output.current.empty()&&this._loop()}_loop(){this._looping=!0,this._current=this._next,this._next=void 0,this._backward("test"),this._looping&&this._output.local.empty()&&(this._looping=!1,this._output.local.push(this._current),this._forward_if_ready())}_iterate(){if(this._forwarding=!0,this._input.test.peak()){this._nexting=!0,this._output.current.push(this._current);let t=this._input.next.peak();this._next===void 0&&t!==void 0&&(this._next=t,this._pull_next())}else this._output.final.push(this._current),this._output.current.pull();this._forwarding=!1}_done(){this._reset(),this._backward("init")}_forward_if_ready(){for(;!this._forwarding&&!this._looping&&!this._nexting&&this._current!==void 0&&!this._input.test.empty()&&!this._input.test.invalid()&&(this._output.current.empty()||this._output.current.invalid())&&(this._output.final.empty()||this._output.final.invalid());)this._iterate()}snapshotSelf(){return Z(_({},super.snapshotSelf()),{_current:this._current,_next:this._next,_test:this._test,_nexting:this._nexting,_looping:this._looping})}restoreSelf(t){let d=t,{_current:e,_next:i,_test:o,_nexting:a,_looping:s}=d,p=bt(d,["_current","_next","_test","_nexting","_looping"]);super.restoreSelf(p),this._current=e,this._next=i,this._test=o,this._nexting=a,this._looping=s}};var Gi=class extends Q{constructor(t){super({i:["a"],o:["a"]},{},t,k0);this._current=void 0;this.addListener("reset",()=>{this._current=void 0})}onDataInputData(t,e){this._current=e,this._forward_if_ready()}_forward_if_ready(){for(;!this._forwarding&&!this._backwarding&&this._current!==void 0;)this._forward("a",this._current),this._current=void 0,this._backward_all()}onDataOutputDrop(t){this._current=void 0}onDataInputInvalid(t){this._invalidate()}};var Ri=class extends Q{constructor(t){super({i:["a"],o:["0","1"]},{},t,$0);this._current=void 0;this._looping=!1}onDataInputData(t,e){this._output[1].empty()||(this._forwarding_empty=!0,this._output[1].pull(),this._forwarding_empty=!1),this._current=e,this._forward_if_ready()}_forward_if_ready(){for(;!this._forwarding&&!this._backwarding&&!this._looping&&this._current!==void 0&&this._i_invalid_count===0;)this._looping=!0,this._forwarding=!0,this._output[0].push(this._current),this._forwarding=!1}onDataInputDrop(t){this._backwarding||(this._current=void 0,this._looping=!1,this._output[0].pull(),this._output[1].pull())}onDataInputInvalid(t){this._looping=!1,this._current=void 0,this._output[0].invalidate(),this._output[1].invalidate()}onDataOutputDrop(t){t==="0"?this._current!==void 0&&(this._forwarding=!0,this._output[1].push(this._current),this._forwarding=!1):this._looping=!1,this._backward_if_ready(),this._forward_if_ready()}_backward_if_ready(){this._current!==void 0&&!this._forwarding&&!this._forwarding_empty&&!this._looping&&(this._current=void 0,this._backward_all())}snapshotSelf(){return Z(_({},super.snapshotSelf()),{_looping:this._looping,_current:this._current})}restoreSelf(t){let a=t,{_looping:e,_current:i}=a,o=bt(a,["_looping","_current"]);super.restoreSelf(o),this._looping=e,this._current=i}};var ki=class extends l{constructor(n){super({i:["message"]},{},n,N0)}f({message:n},t){t(void 0,n)}};var $i=class extends D{constructor(n){super({fi:["a"],fo:["a"],i:["b"],o:[]},{},n,F0)}f({a:n},t){this._input.b.peak()===!0&&t({a:n})}onIterDataInputData(n,t){if(t===!0){let e=this._input.a.peak();e!==void 0&&this._done({a:e})}}};var Ni=class extends l{constructor(n){super({i:["a"]},{},n,B0)}f({},n){n()}};var Fi=class extends l{constructor(n){super({i:["a","b"],o:["a"]},{},n,j0)}f({a:n},t){t({a:n})}};var Bi=class extends l{constructor(n){super({i:["str"],o:["a"]},{},n,H0)}f({str:n},t){let{specs:e,classes:i}=this.__system,o;try{o=st(n,e,i)}catch(a){t(void 0,a.message.toLowerCase());return}t({a:o})}};var ji=class extends l{constructor(n){super({i:["a"],o:["str"]},{},n,V0)}f({a:n},t){let e;try{e=Y(n)}catch(i){t(void 0,i.message.toLowerCase());return}t({str:e})}};var Hi=class extends l{constructor(n){super({i:["a"],o:["type"]},{},n,z0)}f({a:n},t){switch(typeof n){case"number":return t({type:"number"});case"boolean":return t({type:"boolean"});case"function":return t({type:"class"});case"object":return n===null?t({type:"null"}):n instanceof yt?t({type:"unit"}):Array.isArray(n)?t({type:"array"}):t({type:"object"});case"string":return t({type:"string"});case"symbol":return t({type:"symbol"});case"undefined":return t({type:"undefined"});default:return t({type:"undefined"})}}};var Vi=class extends l{constructor(n){super({i:["any"],o:["now"]},{},n,W0)}f({any:n},t){t({now:new Date().getTime()})}};var zi=class extends l{constructor(n){super({i:["id","class","graph"],o:[]},{input:{graph:{ref:!0}}},n,K0)}f({id:n,class:t,graph:e},i){try{let{__bundle:o}=t,{unit:a}=o,{id:s,input:p={}}=a,d=ut(o.specs,this.__system.specs),c=ht(d,s),m={id:s,input:{},output:{}},{inputs:f={},outputs:g={}}=c;for(let h in f){m.input[h]=m.input[h]||{};let x=p[h];if(x){let{data:v}=x;m.input[h].data=v}let y=f[h],{defaultIgnored:I}=y;I&&(m.input[h].ignored=I)}for(let h in g){let x=g[h],{defaultIgnored:y}=x;y&&(m.output[h]=m.output[h]||{},m.output[h].ignored=y)}e.addUnitSpec(n,{unit:m})}catch(o){i(void 0,o.message);return}i()}};var Wi=class extends l{constructor(n){super({i:["id","class","graph"],o:["graph"]},{},n,q0)}f({id:n,class:t,graph:e},i){var a;let o;try{let{__bundle:s}=t,{unit:p}=s,{id:d,input:c={}}=p,m=ut((a=s.specs)!=null?a:{},this.__system.specs),f=ht(m,d),g={id:d,input:{},output:{}},{inputs:h={},outputs:x={}}=f;for(let P in h){g.input[P]=g.input[P]||{};let H=c[P];if(H){let{data:J}=H;g.input[P].data=J}let U=h[P],{defaultIgnored:B}=U;B&&(g.input[P].ignored=B)}for(let P in x){let H=x[P],{defaultIgnored:U}=H;U&&(g.output[P]=g.output[P]||{},g.output[P].ignored=U)}let y=Ge(m),I=ht(m,e.__bundle.unit.id),v=j(I);v.id=y,Pl({unitId:n,unit:g},v);let T=tn(v,m);o=ee(T,m,this.__system.classes)}catch(s){i(void 0,s.message);return}i({graph:o})}};function pn(r,n=!1){let t=r.getUnitBundleSpec(n);return zt(r.constructor,t)}var Ki=class extends l{constructor(n){super({i:["id","graph"],o:[]},{input:{graph:{ref:!0}}},n,Y0)}f({id:n,graph:t},e){let i;try{let o=t.getUnit(n);t.removeUnit(n,!0),i=pn(o)}catch(o){e(void 0,o.message);return}e({class:i})}};var qi=class extends l{constructor(n){super({i:["graph","id","type","name","data"],o:[]},{input:{graph:{ref:!0}}},n,J0)}f({graph:n,id:t,type:e,name:i,data:o},a){try{n.setUnitPinData(t,e,i,o)}catch(s){a(void 0,s.message);return}a()}};var Yi=class extends l{constructor(n){super({i:["any"],o:["uuid"]},{},n,X0)}f({any:n},t){t({uuid:Le()})}};var Ji=class extends l{constructor(n){super({i:["json","space"],o:["string"]},{},n,Z0)}f({json:n,space:t},e){let i;try{i=JSON.stringify(n,null,t)}catch(o){e(void 0,o.message.toLowerCase());return}e({string:i})}};var Xi=class extends l{constructor(n){super({i:["string"],o:["json"]},{},n,Q0)}f({string:n},t){let e;try{e=JSON.parse(n)}catch(i){t(void 0,"invalid JSON");return}t({json:e})}};var Zi=class extends l{constructor(n){super({i:["json"],o:["string"]},{},n,tb)}f({json:n},t){let e;try{e=JSON.stringify(n)}catch(i){t(void 0,i.message.toLowerCase());return}t({string:e})}};var Qi=class extends l{constructor(n){super({i:["a","b"],o:["a and b"]},{},n,eb)}f({a:n,b:t},e){e({"a and b":n&&t})}};var tr=class extends l{constructor(n){super({i:["a"],o:["!a"]},{},n,nb)}f({a:n},t){t({"!a":!n})}};var er=class extends l{constructor(n){super({i:["a","b"],o:["a or b"]},{},n,ib)}f({a:n,b:t},e){e({"a or b":n||t})}};var nr=class extends l{constructor(n){super({i:["a"],o:["|a|"]},{},n,rb)}f({a:n},t){t({"|a|":Math.abs(n)})}};var ir=class extends l{constructor(n){super({i:["a"],o:["\u2308a\u2309"]},{},n,Jc)}f({a:n},t){t({"\u2308a\u2309":Math.ceil(n)})}};var rr=class extends l{constructor(n){super({i:["a"],o:["cos(a)"]},{},n,ob)}f({a:n},t){t({"cos(a)":Math.cos(n)})}};var or=class extends l{constructor(n){super({i:["a"],o:["\u230Aa\u230B"]},{},n,Jc)}f({a:n},t){t({"\u230Aa\u230B":Math.floor(n)})}};var ar=class extends l{constructor(n){super({i:["a"],o:["ln(a)"]},{},n,Xc)}f({a:n},t){t({"ln(a)":Math.log(n)})}};var sr=class extends l{constructor(n){super({i:["a","b"],o:["max"]},{},n,sb)}f({a:n,b:t},e){e({max:Math.max(n,t)})}};var pr=class extends l{constructor(n){super({i:["a","b"],o:["min"]},{},n,pb)}f({a:n,b:t},e){e({min:Math.min(n,t)})}};var ur=class extends l{constructor(n){super({i:["any"],o:["PI"]},{},n,ub)}f({any:n},t){t({PI:Math.PI})}};var cr=class extends l{constructor(n){super({i:["a","b"],o:["a ** b"]},{},n,Xc)}f({a:n,b:t},e){e({"a ** b":Math.pow(n,t)})}};var dr=class extends l{constructor(n){super({i:["any"],o:["random"]},{},n,cb)}f({a:n},t){t({random:Math.random()})}};var mr=class extends l{constructor(n){super({i:["a"],o:["sign(a)"]},{},n,Zc)}f({a:n},t){t({"sign(a)":Math.sign(n)})}};var fr=class extends l{constructor(n){super({i:["a"],o:["sin(a)"]},{},n,db)}f({a:n},t){t({"sin(a)":Math.sin(n)})}};var lr=class extends l{constructor(n){super({i:["a"],o:["\u221Aa"]},{},n,mb)}f({a:n},t){n<0?t(void 0,"cannot square root negative number"):t({"\u221Aa":Math.sqrt(n)})}};var br=class extends l{constructor(n){super({i:["graph","opt"],o:["bundle"]},{input:{graph:{ref:!0}}},n,fb)}f({graph:n,opt:t},e){let{stringifyBundleData:i}=this.__system,{snapshot:o=!1}=t,a=n.getBundleSpec(o),s=j(a);i(s),e({bundle:s})}};var gr=class extends Q{constructor(t){super({i:["unit"],o:["err"]},{input:{unit:{ref:!0}}},t,lb)}onRefInputData(t,e){let{unlisten:i,done:o}=e.catch(s=>{s===null?this._forward_all_empty():this._output.err.push(s)});this._unlisten=i,this._done=o;let a=e.caughtErr();a!==null&&this._output.err.push(a)}onRefInputDrop(t){this._unlisten(),this._unlisten=void 0,this._done=void 0,this._forward_all_empty()}onDataOutputDrop(t){!this._backwarding&&!this._forwarding_empty&&this._done()}};var hr=class extends l{constructor(n){super({i:["unit","deep"],o:["class"]},{input:{unit:{ref:!0}}},n,bb)}f({unit:n,deep:t},e){let i=pn(n,t);e({class:i})}};var yr=class extends l{constructor(n){super({i:["class"],o:["id"]},{},n,gb)}f({class:n},t){let{__bundle:e}=n,{id:i}=e.unit;t({id:i})}};var _r=class extends l{constructor(n){super({i:["unit","method","args"],o:["return"]},{input:{unit:{ref:!0}}},n,hb)}f({unit:n,method:t,args:e},i){let o=n[t],a;if(typeof o=="function")try{a=o.call(n,...e)}catch(s){i(void 0,s.message);return}else{i(void 0,"invalid method");return}i({return:a})}};var xr=class extends yt{constructor(n){super({i:[],o:[]},{},n,yb)}subscribe(n,t,e){return this.__system.global.data.subscribe(n,t,e)}get(n){return b(this,null,function*(){return this.__system.global.data.get(n)})}set(n,t){return b(this,null,function*(){return this.__system.global.data.set(n,t)})}delete(n){return b(this,null,function*(){return this.__system.global.data.delete(n)})}deepSet(n,t){return b(this,null,function*(){return this.__system.global.data.deepSet(n,t)})}deepGet(n){return b(this,null,function*(){return this.__system.global.data.deepGet(n)})}deepDelete(n){return b(this,null,function*(){return this.__system.global.data.deepDelete(n)})}keys(){return b(this,null,function*(){return this.__system.global.data.keys()})}hasKey(n){return b(this,null,function*(){return this.__system.global.data.hasKey(n)})}};var Ir=class extends l{constructor(n){super({i:["id"],o:["class"]},{},n,_b)}f({id:n},t){let e=le(n,this.__system.specs,this.__system.classes);t({class:e})}};var vr=class extends l{constructor(n){super({i:["id"],o:["spec"]},{},n,xb)}f({id:n},t){if(this.__system){let{specs:e}=this.__system,i=e[n];i?t({spec:i}):t(void 0,"cannot find spec with this id")}else t(void 0,"not attached")}};var Dr=class extends D{constructor(n){super({fi:["class"],fo:["unit"],i:["done"]},{output:{unit:{ref:!0}}},n,Ib)}f({class:n},t){t({unit:new n(this.__system)})}onIterDataInputData(n,t){this._forward_all_empty(),this._backward("class"),this._backward("done")}};function iy(r){return De(r)?r:{}}var Sr=class extends l{constructor(t){super({i:["obj","key"],o:["value"]},{input:{obj:{ref:!0}},output:{value:{ref:!0}}},t,vb)}f(o,a){return b(this,arguments,function*({obj:t,key:e},i){let s;try{s=yield t.get(e)}catch(d){i(void 0,d.message);return}this._unlisten=t.subscribe([],e,(d,c,m)=>{d==="delete"&&(this.err("key value not found"),this._forward_empty("value"))});let p=new class extends C{read(){return b(this,null,function*(){return s=yield t.get(e),iy(s)})}write(c){return b(this,null,function*(){return t.set(e,c)})}}(this.__system);i({value:p})})}d(){this._unlisten&&(this._unlisten(),this._unlisten=void 0)}};function Q3(r,n){return Nc(r,n,{G:sy,C:ay,V:b_,J:__,U:oy,MS:D_,EE:ry,S:ef})}function Te(r,n){let t={};for(let e of n){let i=`$${e}`;t[i]=(o,a)=>r.call(i,o,a)}return t}function Ae(r,n){let t={};for(let e of n){let i=`$${e}`;t[i]=(o,a)=>r.watch(i,o,a)}return t}function Ce(r,n){let t={};for(let e of n){let i=`$${e}`;t[i]=o=>{let{_:a}=o,s=r.ref(i,o);return Q3(s,a)}}return t}function t_(r){return Te(r,Un)}function e_(r){return Ae(r,wn)}function n_(r){return Ce(r,Ln)}function ry(r){return _(_(_({},t_(r)),e_(r)),n_(r))}function i_(r){return Te(r,Bn)}function r_(r){return Ae(r,jn)}function o_(r){return Ce(r,Hn)}function oy(r){return _(_(_({},i_(r)),r_(r)),o_(r))}function a_(r){return Te(r,Mn)}function s_(r){return Ae(r,Pn)}function p_(r){return Ce(r,On)}function ay(r){return _(_(_({},a_(r)),s_(r)),p_(r))}function u_(r){return Te(r,Gn)}function c_(r){return Ae(r,Rn)}function d_(r){return Ce(r,kn)}function sy(r){return _(_(_({},u_(r)),c_(r)),d_(r))}function m_(r){return Te(r,Vn)}function f_(r){return Ae(r,zn)}function l_(r){return Ce(r,Wn)}function b_(r){return _(_(_({},m_(r)),f_(r)),l_(r))}function g_(r){return Te(r,$n)}function h_(r){return Ae(r,Nn)}function y_(r){return Ce(r,Fn)}function __(r){return _(_(_({},g_(r)),h_(r)),y_(r))}function x_(r){return Te(r,Dc)}function I_(r){return Ae(r,Sc)}function v_(r){return Ce(r,Ec)}function D_(r){return _(_(_({},x_(r)),I_(r)),v_(r))}function un(r){return _(_(_(_({},ry(r)),oy(r)),ay(r)),sy(r))}function S_(r){return Te(r,Tc)}function E_(r){return Ae(r,Ac)}function T_(r){return Ce(r,Cc)}function ef(r){return _(_(_({},S_(r)),E_(r)),T_(r))}var qt=class{constructor(n){this._call_id=new Set;this._watch_id=new Set;this._ref_id=new Set;this._ref={};this._watch_emitter=new mt;this._call_emitter=new mt;this._valid=!0;this._port=n,this._port.onmessage=t=>{let{data:e}=t;this.exec(e)},this._port.onerror=t=>{let{message:e}=t}}exec(n){let{type:t,data:e}=n,{id:i,data:o}=e;if(t===pe){if(!this._call_id.has(i))throw new Error("unexpected worker call message id");this._call_emitter.emit(i,o)}else if(t===Ue){if(!this._watch_id.has(i))throw new Error("unexpected worker watch message id");this._watch_emitter.emit(i,o)}else if(t===we)this._ref[i].exec(o);else throw new Error("unexpected worker message type")}call(n,t,e){let i=Hu(this._call_id);this._call_id.add(i);let o=s=>{this._call_emitter.removeListener(i,o),this._call_id.delete(i),e(s)};this._call_emitter.addListener(i,o);let a={type:pe,data:{id:i,method:n,data:t}};this._port.send(a)}watch(n,t,e){let i=Hu(this._watch_id);this._watch_id.add(i);let o=s=>{e(s)};this._watch_emitter.addListener(i,o);let a={type:Ue,data:{id:i,method:n,data:t}};return this._port.send(a),()=>{if(this._watch_emitter.removeListener(i,o),this._watch_id.delete(i),this._valid){let s={type:$u,data:{id:i}};this._port.send(s)}}}ref(n,t){let e=Hu(this._ref_id),i={type:we,data:{id:e,method:n,data:t}};this._port.send(i);let o={send:s=>{let p={type:Nu,data:{id:e,data:s}};this._port.send(p)},onmessage(){},onerror(){},terminate(){}},a=new qt(o);return this._ref[e]=a,a}terminate(){this._port.terminate()}close(){this._valid=!1;for(let n in this._ref)this._ref[n].close()}valid(){return this._valid}};function Gt(r,n,t=[]){return new class extends C{constructor(a){super(a);this.__async=!0;this.__=t;for(let s of Object.keys(n)){let p=n[s];this[s]=p}}}(r)}var Er=class extends D{constructor(t){super({fi:["opt"],fo:[],i:["close","message"],o:["message","graph"]},{output:{graph:{ref:!0}}},t,Db);this._close=()=>{this._remote_port&&(this._remote_port.close(),this._remote_port=void 0)};this.addListener("destroy",()=>{this._close()}),this.addListener("take_err",()=>{}),this.addListener("take_caught_err",()=>{})}f({opt:t},e){}onIterDataInputData(t,e){return b(this,null,function*(){switch(t){case"close":this._close(),this._done(),this._backward("close");break;case"message":{let{type:i,data:o}=e;switch(i){case Ot:this._port.onmessage({data:o});break;case Zt:{let a={send:c=>{this._output.message.push(c)},onmessage(c){},onerror(){},terminate(){}};this._port=a;let s=new qt(a);this._remote_port=s;let p=un(s),d=Gt(this.__system,p,["U","C","G"]);this._output.graph.push(d)}break;case Qt:this._close();break}this._backward("message")}break}})}};function ud(r,n){let t=new Ie(r);return{get(e){throw new O},set(e,i){return t.deepSet(["current",e],i)},delete(e){throw new O},hasKey(e){throw new O},keys(){throw new O},deepGet(e){throw new O},deepSet(e,i){throw new O},deepDelete(e){throw new O},subscribe(e,i,o){return t.subscribe(["current",...e],i,o)}}}var Tr=class extends l{constructor(n){super({i:["unit"],o:["obj"]},{input:{unit:{ref:!0}},output:{obj:{ref:!0}}},n,Sb)}f(e,i){return b(this,arguments,function*({unit:n},t){var m;let{global:{scope:o}}=this.__system,{__global_id:a}=n;o[a]=(m=o[a])!=null?m:{};let p={current:o[a]},d=ud(p,this.__system),c=Gt(this.__system,d,["J"]);t({obj:c})})}};var Ar=class extends Q{constructor(t){super({i:["a"],o:["a"]},{},t,Eb);this._ran=!1}onDataInputDrop(t,e){this._ran=!1}onDataInputData(t,e){this._paused||this._ran||(this._ran=!0,this._output.a.push(e))}};var Cr=class extends l{constructor(n){super({i:["unit","any"],o:["spec"]},{input:{unit:{ref:!0}}},n,Tb)}f({unit:n},t){let e=n.getSpec();t({spec:e})}};var Mr=class extends l{constructor(t){super({i:["unit"],o:["spec"]},{input:{unit:{ref:!0}},output:{spec:{ref:!0}}},t,Ab);this.__=["J"]}f({unit:t},e){let i=new class extends C{get(a){let s=t.getSpec();return Promise.resolve(s[a])}set(a,s){let p=t.getSpec();p[a]=s}delete(a){let s=t.getSpec();delete s[a]}hasKey(a){return b(this,null,function*(){let s=t.getSpec();return Rf(s,a)})}keys(){return b(this,null,function*(){let a=t.getSpec();return et(a)})}deepGet(a){let s=t.getSpec();return pt(s,a)}deepSet(a,s){let p=t.getSpec();xc(p,a,s)}deepDelete(a){throw new O}subscribe(a,s,p){throw new O}}(this.__system);e({spec:i})}};var Pr=class extends l{constructor(n){super({i:["any"],o:["specs"]},{},n,Cb)}f({any:n},t){let{specs:e}=this.__system;t({specs:e})}};var Or=class extends yt{constructor(t){super({i:[],o:["graph"]},{output:{graph:{ref:!0}}},t,Mb);this.addListener("parent",e=>{e===null?(this._unlisten&&(this._unlisten(),this._unlisten=void 0),this._output.graph.pull()):this._output.graph.push(e)})}};var Ur=class extends yt{constructor(n){super({i:[],o:[]},{},n,Pb)}};var ne=class extends l{f(n,t){let e;try{e=this.m(n)}catch(i){t(void 0,i.message);return}t(e)}m(n){}};var wr=class extends ne{constructor(n){super({i:["n","radix"],o:["str"]},{},n,Ob)}m({n,radix:t}){return{str:n.toString(t)}}};var Lr=class extends ne{constructor(n){super({i:["str"],o:["n"]},{},n,Ub)}m({str:n}){let t=Number.parseFloat(n);if(isNaN(t))throw"invalid number string";return{n:t}}};var Gr=class extends ne{constructor(n){super({i:["str","radix"],o:["n"]},{},n,wb)}m({str:n,radix:t}){let e=Number.parseInt(n,t);if(isNaN(e))throw"invalid number string";return{n:e}}};var Rr=class extends l{constructor(n){super({i:["obj","path"],o:["result"]},{},n,Lb)}f({obj:n,path:t},e){let i;try{i=pt(n,t)}catch(o){e(void 0,"key not found");return}e({result:i})}};var kr=class extends ne{constructor(n){super({i:["a","b"],o:["ab"]},{},n,Gb)}m({a:n,b:t}){return{ab:Ht(n,t)}}};var $r=class extends l{constructor(n){super({i:["obj","path","value"],o:["result"]},{},n,Rb)}f({obj:n,path:t,value:e},i){let o=j(n);try{F(o,t,e)}catch(a){i(void 0,a.message);return}i({result:o})}};var Nr=class extends l{constructor(n){super({i:["obj","key"],o:["obj"]},{},n,Qc)}f({obj:n,key:t},e){e({obj:vc(n,t)})}};var Fr=class extends l{constructor(n){super({i:["obj","key"],o:["value"]},{},n,kb)}f({obj:n,key:t},e){n.hasOwnProperty(t)?e({value:n[t]}):e(void 0,"key not found")}};var Br=class extends l{constructor(n){super({i:["obj","key"],o:["has"]},{},n,$b)}f({obj:n,key:t},e){e({has:n.hasOwnProperty(t)})}};var jr=class extends l{constructor(n){super({i:["obj"],o:["keys"]},{},n,td)}f(n,t){t($d(n))}};var Hr=class extends l{constructor(n){super({i:["a","b"],o:["ab"]},{},n,Nb)}f({a:n,b:t},e){e({ab:en(n,t)})}};var Vr=class extends l{constructor(n){super({i:["obj","key","value"],o:["obj"]},{},n,Fb)}f({obj:n,key:t,value:e},i){this.isPinRef("input","obj")&&(n[t]=e),this.isPinRef("output","obj")?i({obj:n}):i({obj:nn(n,t,e)})}};var zr=class extends l{constructor(n){super({i:["obj"],o:["values"]},{},n,Bb)}f({obj:n},t){t({values:Object.values(n)})}};var Wr=class extends l{constructor(n){super({i:["str"],o:["obj"]},{},n,jb)}f({str:n},t){let{api:{querystring:{parse:e}}}=this.__system,i;try{i=e(n)}catch(o){t(void 0,o.message);return}t({obj:i})}};var Kr=class extends l{constructor(n){super({i:["obj"],o:["str"]},{},n,Hb)}f({obj:n},t){let{api:{querystring:{stringify:e}}}=this.__system,i;try{i=e(n)}catch(o){t(void 0,o.message);return}t({str:i})}};var qr=class extends l{constructor(n){super({i:["a"],o:["tail","head"]},{},n,zc)}f({a:n},t){let e=n[0]||"",i=n.slice(1)||"";t({tail:i,head:e})}};var Yr=class extends l{constructor(n){super({i:["a","i"],o:["a[i]"]},{},n,Vb)}f({a:n,i:t},e){e({"a[i]":n.charAt(t)})}};var Jr=class extends l{constructor(n){super({i:["a","b"],o:["ab"]},{},n,zb)}f({a:n,b:t},e){e({ab:n+t})}};var Xr=class extends l{constructor(n){super({i:["code"],o:["char"]},{},n,Wb)}f({code:n},t){let e=String.fromCharCode(n);t({char:e})}};var Zr=class extends l{constructor(n){super({i:["a"],o:["length"]},{},n,qc)}f({a:n},t){t({length:n.length})}};var Qr=class extends l{constructor(n){super({i:["a","b"],o:["a < b"]},{},n,Kb)}f({a:n,b:t},e){let i=t.localeCompare(n)===1;e({"a < b":i})}};var to=class extends l{constructor(n){super({i:["str","regex"],o:["match"]},{},n,qb)}f({str:n,regex:t},e){e({match:n.match(t)})}};var eo=class extends l{constructor(n){super({i:["str","regex","flags","with"],o:["str"]},{},n,Yb)}f({str:n,regex:t,with:e,flags:i},o){o({str:n.replace(new RegExp(t,i),e)})}};function nf({a:r,begin:n,end:t}){return{a:r.slice(n,t)}}var no=class extends l{constructor(n){super({i:["a","begin","end"],o:["a"]},{},n,Yc)}f(n,t){t(nf(n))}};function rf(r,n){return r.split(n)}var io=class extends l{constructor(n){super({i:["a","sep"],o:["parts"]},{},n,Jb)}f({a:n,sep:t},e){e({parts:rf(n,t)})}};var ro=class extends l{constructor(n){super({i:["a","from","length"],o:["a"]},{},n,Xb)}f({a:n,from:t,length:e},i){i({a:n.substring(t,t+e)})}};var oo=class extends l{constructor(n){super({i:["str","regex"],o:["match"]},{},n,Zb)}f({str:n,regex:t},e){e({match:!!n.match(t)})}};var ao=class extends l{constructor(n){super({i:["A"],o:["a"]},{},n,Qb)}f({A:n},t){t({a:n.toLowerCase()})}};var so=class extends l{constructor(n){super({i:["a"],o:["A"]},{},n,t2)}f({a:n},t){t({A:n.toUpperCase()})}};var po=class extends D{constructor(t){super({fi:["ms"],o:["ms"],i:["done"]},{},t,ed);this._interval=null;this.addListener("reset",this._reset),this.addListener("destroy",this._reset)}_reset(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}f({ms:t},e){this._reset(),this._interval=setInterval(()=>{this.pushOutput("ms",t)},t)}d(){this._reset(),this._forward_all_empty()}onIterDataInputData(t,e){this._reset(),this._done({})}};var uo=class extends l{constructor(t){super({i:["ms"],o:["ms"]},{},t,ed);this._timer=null;this.addListener("reset",this._reset),this.addListener("destroy",this._reset)}_reset(){this._timer!==null&&(clearTimeout(this._timer),this._timer=null)}f({ms:t},e){this._reset(),this._timer=setTimeout(()=>{this._timer=null,e({ms:t})},t)}};var co=class extends l{constructor(n){super({i:["unit","name"],o:["test"]},{},n,e2)}f({unit:n,name:t},e){var p;let{id:i}=n.__bundle.unit,o=ht(ut(this.__system.specs,(p=n.__bundle.specs)!=null?p:{}),i),{inputs:a={}}=o,s=!!a[t];e({test:s})}};var mo=class extends l{constructor(n){super({i:["unit","opt"],o:[]},{input:{unit:{ref:!0}}},n,n2)}f({unit:n,opt:t},e){n.$pause({}),e()}};var fo=class extends l{constructor(n){super({i:["unit","any"],o:["paused"]},{input:{unit:{ref:!0}}},n,i2)}f({unit:n},t){n.$paused({},e=>{t({paused:e})})}};var lo=class extends l{constructor(n){super({i:["unit","opt"],o:[]},{input:{unit:{ref:!0}}},n,r2)}f({unit:n,opt:t},e){n.$play({}),e()}};function cd(r){let{__bundle:n}=r,t=j(n);return A_(r,t)}function A_(r,n){let t=C_(r);return zt(t,n)}function C_(r){class n extends r{}return Object.defineProperty(n,"name",{value:r.constructor.name}),n}var bo=class extends l{constructor(n){super({i:["unit","name","data"],o:["unit"]},{},n,o2)}f({unit:n,name:t,data:e},i){var c;let{__bundle:o}=n,{unit:{id:a}}=o,s=ht(ut(this.__system.specs,(c=o.specs)!=null?c:{}),a),{inputs:p={}}=s;if(!p[t]){i(void 0,"input not found");return}let d=cd(n);d.__bundle.unit.input=d.__bundle.unit.input||{},d.__bundle.unit.input[t]=d.__bundle.unit.input[t]||{},d.__bundle.unit.input[t].data=Y(e),i({unit:d})}};var go=class extends l{constructor(n){super({i:["unit","type","name","data"],o:["unit"]},{},n,a2)}f({unit:n,type:t,name:e},i){let{unit:{id:o},specs:a}=n.__bundle;if(!ht(ut(a,this.__system.specs),o)[`${t}s`][e]){i(void 0,`${t} not found`);return}let p=cd(n);p.__bundle.unit.input=p.__bundle.unit.input||{},p.__bundle.unit.input[e]=p.__bundle.unit.input[e]||{},delete p.__bundle.unit.input[e].data,i({unit:p})}};var ho=class extends l{constructor(n){super({i:["message"],o:[]},{},n,s2)}f({message:n},t){let{api:{alert:{alert:e}}}=this.__system;e(n),t()}};var yo=class extends l{constructor(n){super({i:["message"],o:["answer"]},{},n,p2)}f({message:n},t){let{api:{alert:{prompt:e}}}=this.__system,i=e(n);if(i===null){t(void 0,"user cancelled prompt");return}t({answer:i})}};var _o=class extends D{constructor(t){super({fi:["opt","keyframes","element"],fo:["animation"],i:["done"],o:[]},{input:{element:{ref:!0},done:{}},output:{animation:{ref:!0}}},t,u2);this._id=void 0;this.addListener("reset",this._cancel),this.addListener("destroy",this._cancel)}_cancel(){this._i.element&&this._id&&(this._i.element.cancelAnimation(this._id),this._id=void 0)}f({opt:t,keyframes:e,element:i},o){var d;let a=(d=t.id)!=null?d:ju();this._id=a;let s=Z(_({},t),{id:a});i.animate(e,s);let p=new class extends C{constructor(){super(...arguments);this.__=["ANI"]}stop(){i.emit("call",{method:"stopAnimation",data:[a]})}play(){i.emit("call",{method:"playAnimation",data:[a]})}cancel(){i.emit("call",{method:"cancelAnimation",data:[a]})}finish(){i.emit("call",{method:"finishAnimation",data:[a]})}commit(){i.emit("call",{method:"commitAnimation",data:[a]})}}(this.__system);o({animation:p})}fd(){this._cancel()}fi(){this._cancel()}onRefInputDrop(t,e){t==="element"&&this._cancel()}onIterDataInputData(t,e){this._cancel(),this._id=void 0,this._forward_empty("animation"),this._backward("keyframes"),this._backward("opt"),this._backward("done")}};var xo=class extends l{constructor(t){super({i:["a"],o:["a"]},{},t,c2);this._frame=void 0;this.addListener("reset",()=>{this._reset()}),this.addListener("destroy",()=>{this._reset()})}_reset(){let{api:{animation:{cancelAnimationFrame:t}}}=this.__system;this._frame&&(t(this._frame),this._frame=void 0)}f({a:t},e){let{api:{animation:{requestAnimationFrame:i}}}=this.__system;i?(this._reset(),this._frame=i(()=>{this._frame=void 0,e({a:t})})):e(void 0,"request animation frame not supported")}};var Io=class extends l{constructor(n){super({i:["b"],o:["a"]},{},n,d2)}f({b:n},t){let e;try{e=atob(n)}catch(i){t(void 0,"string not correctly enconded");return}t({a:e})}};var vo=class extends l{constructor(n){super({i:["a"],o:["b"]},{},n,m2)}f({a:n},t){let e;try{e=btoa(n)}catch(i){t(void 0,"invalid string");return}t({b:e})}};var Do=class extends l{constructor(t){super({i:["service","uuid"],o:["charac"]},{input:{service:{ref:!0}},output:{charac:{ref:!0}}},t,f2);this._started=!1;this.addListener("listen",({event:e})=>{e==="write"&&this.startNotifications()}),this.addListener("unlisten",({event:e})=>{e==="write"&&this.stopNotification()})}f(o,a){return b(this,arguments,function*({service:t,uuid:e},i){let s=yield t.getCharacteristic(e);this._charac=s;let p=new class extends C{read(){return b(this,null,function*(){return(yield s.readValue()).getUint8(0).toString()})}write(c){return b(this,null,function*(){let m=c.split("").map(g=>g.charCodeAt(0)),f=Uint8Array.from(m);yield s.writeValue(f)})}}(this.__system);i({charac:p})})}d(){}startNotifications(){return b(this,null,function*(){if(this._started)return;let t=this._charac;this._started=!0,t.startNotifications(),t.addEventListener("characteristicvaluechanged",e=>{let i=e.target.value,{byteLength:o}=i,a="";for(let s=0;s<o;s++)a+=String.fromCharCode(i.getUint8(s));e.stopImmediatePropagation(),this.emit("characteristicvaluechanged",a,!0)})})}stopNotification(){this._started||(this._started=!1,this._charac.stopNotifications())}};var So=class extends l{constructor(n){super({i:["opt"],o:["device"]},{output:{device:{ref:!0}}},n,l2)}f(e,i){return b(this,arguments,function*({opt:n},t){let{api:{bluetooth:{requestDevice:o}}}=this.__system,a;try{let s=yield o(n);a=new class extends C{getServer(){return b(this,null,function*(){return s.getServer()})}}(this.__system)}catch(s){t(void 0,s.message);return}t({device:a})})}};var Eo=class extends l{constructor(t){super({i:["device"],o:["server"]},{input:{device:{ref:!0}},output:{server:{ref:!0}}},t,b2)}f(i,o){return b(this,arguments,function*({device:t},e){let a=yield t.getServer(),s=new class extends C{getPrimaryService(d){return a.getPrimaryService(d)}}(this.__system);e({server:s})})}getPrimaryService(t){return this._server.getPrimaryService(t)}};var To=class extends l{constructor(n){super({i:["server","uuid"],o:["service"]},{input:{server:{ref:!0}},output:{service:{ref:!0}}},n,g2)}f(i,o){return b(this,arguments,function*({server:n,uuid:t},e){let a=yield n.getPrimaryService(t),s=new class extends C{getCharacteristic(d){return a.getCharacteristic(d)}}(this.__system);e({service:s})})}d(){}};var Ao=class extends l{constructor(n){super({i:["arc","d"],o:["d"]},{},n,nd)}f({d:n,arc:{x:t,y:e,r:i,start:o,end:a,anticlockwise:s=!1}},p){p({d:[...n,["arc",t,e,i,o,a,s]]})}};var Co=class extends l{constructor(n){super({i:["d","x","y"],o:["d"]},{},n,h2)}f({d:n,x:t,y:e},i){i({d:[...n,["lineTo",t,e]]})}};var Mo=class extends l{constructor(n){super({i:["rect","d"],o:["d"]},{},n,y2)}f({d:n,rect:{x:t,y:e,width:i,height:o}},a){a({d:[...n,["rect",t,e,i,o]]})}};var Po=class extends l{constructor(n){super({i:["d"],o:["d"]},{},n,_2)}f({d:n},t){t({d:[...n,["beginPath"]]})}};var Oo=class extends l{constructor(n){super({i:["any","canvas"],o:[]},{input:{canvas:{ref:!0}}},n,x2)}f({any:n,canvas:t},e){t.clear(),e()}};var Uo=class extends l{constructor(n){super({i:["d"],o:["d"]},{},n,I2)}f({d:n},t){t({d:[...n,["closePath"]]})}};var wo=class extends l{constructor(n){super({i:["canvas","step"],o:[]},{input:{canvas:{ref:!0}}},n,v2)}f({canvas:n,step:t},e){n.draw(t),e()}};var Lo=class extends l{constructor(n){super({i:["canvas","image","x","y","width","height","any"],o:[]},{input:{canvas:{ref:!0},image:{ref:!0}}},n,D2)}f(d,c){return b(this,arguments,function*({any:n,canvas:t,image:e,x:i,y:o,width:a,height:s},p){let m=yield e.image();yield t.drawImage(m,i,o,a,s),p()})}};var Go=class extends l{constructor(n){super({i:["d"],o:["d"]},{},n,Wc)}f({d:n},t){t({d:[...n,["fill"]]})}};var Ro=class extends l{constructor(n){super({i:["d","canvas","rule"]},{input:{canvas:{ref:!0}}},n,S2)}f({d:n,canvas:t,rule:e},i){t.fillPath(n,e),i()}};var ko=class extends l{constructor(n){super({i:["fillStyle","d"],o:["d"]},{},n,E2)}f({d:n,fillStyle:t},e){e({d:[...n,["fillStyle",t]]})}};var Me=class extends Error{constructor(){super("invalid key path")}};function py(r,n){return{append(t){let e=[];r.current.push(t)},put(t,e){throw new O},at(t){throw new O},length(){throw new O},indexOf(t){throw new O}}}function Pe(r,n){return new class extends C{constructor(){super(...arguments);this.__=["A"]}append(o){r[r.length]=o}put(o,a){return b(this,null,function*(){r[o]=a})}at(o){return b(this,null,function*(){return r[o]})}length(){return b(this,null,function*(){return r.length})}indexOf(o){throw new O}raw(){return r}}(n)}function dd(r,n){return new class extends C{constructor(){super(...arguments);this.__=["J","ID"]}imageData(){return r}get(o){return b(this,null,function*(){if(r[o]!==void 0)return o==="data"?Pe(r.data,n):r[o]})}set(o,a){return b(this,null,function*(){throw new Error("read only")})}delete(o){return b(this,null,function*(){throw new Error("read only")})}hasKey(o){return b(this,null,function*(){return r[o]!==void 0})}keys(){return b(this,null,function*(){return["width","height","data","colorSpace"]})}deepGet(o){if(o.length===1)return this.get(o[0]);throw new Me}deepSet(o,a){throw new Error("read only")}deepDelete(o){throw new Error("read only")}subscribe(o,a,s){throw new Error("read only")}raw(){return r}}(n)}var $o=class extends D{constructor(n){super({fi:["canvas","x","y","width","height","opt","any"],fo:["image"],i:["done"]},{input:{canvas:{ref:!0}},output:{image:{ref:!0}}},n,T2)}f(p,d){return b(this,arguments,function*({canvas:n,x:t,y:e,width:i,height:o,opt:a},s){let c;try{c=n.getImageData(t,e,i,o,a)}catch(f){if(f instanceof RangeError){s(void 0,"out of memory");return}s(void 0,f.message);return}let m=dd(c,this.__system);s({image:m})})}onIterDataInputData(n){this._forward_all_empty(),this._backward_all(),this._backward("done")}};var No=class extends D{constructor(n){super({fi:["data","width","height","opt"],fo:["image"],i:["done"]},{input:{data:{ref:!0}},output:{image:{ref:!0}}},n,A2)}f(a,s){return b(this,arguments,function*({data:n,width:t,height:e,opt:i},o){let p;try{let c=yield n.read();p=new ImageData(c,t,e,i)}catch(c){o(void 0,c.message);return}let d=dd(p,this.__system);o({image:d})})}onIterDataInputData(n){this._forward_all_empty(),this._backward_all(),this._backward("data"),this._backward("done")}};var Fo=class extends l{constructor(n){super({i:["x","y","d"],o:["d"]},{},n,C2)}f({d:n,x:t,y:e},i){i({d:[...n,["moveTo",t,e]]})}};var Bo=class extends D{constructor(n){super({fi:["any","canvas","image","dx","dy","x","y","width","height"],fo:["done"],i:[]},{input:{canvas:{ref:!0},image:{ref:!0}},output:{}},n,M2)}f(c,m){return b(this,arguments,function*({canvas:n,image:t,dx:e,dy:i,x:o,y:a,width:s,height:p},d){let f=t.imageData();n.putImageData(f,e,i,o,a,s,p),d({done:!0})})}};var jo=class extends l{constructor(n){super({i:["d","rad"],o:["d"]},{},n,P2)}f({d:n,rad:t},e){e({d:[...n,["rotate",t]]})}};var Ho=class extends l{constructor(n){super({i:["sx","sy","canvas"]},{input:{canvas:{ref:!0}}},n,id)}f({canvas:n,sx:t,sy:e},i){n.scale(t,e),i()}};var Vo=class extends l{constructor(n){super({i:["d"],o:["d"]},{},n,O2)}f({d:n},t){t({d:[...n,["stroke"]]})}};var zo=class extends l{constructor(n){super({i:["d","canvas"]},{input:{canvas:{ref:!0}}},n,id)}f({d:n,canvas:t},e){t.strokePath(n),e()}};var Wo=class extends l{constructor(n){super({i:["strokeStyle","d"],o:["d"]},{},n,U2)}f({d:n,strokeStyle:t},e){e({d:[...n,["strokeStyle",t]]})}};var Ko=class extends D{constructor(n){super({fi:["canvas","quality","type"],fo:["blob"],i:["done"]},{input:{canvas:{ref:!0}},output:{blob:{ref:!0}}},n,w2)}f(o,a){return b(this,arguments,function*({canvas:n,quality:t,type:e},i){let s;try{s=yield n.toBlob(e,t)}catch(d){i(void 0,d.message);return}let p=new class extends C{constructor(){super(...arguments);this.__=["B","IM","BO"]}image(){return b(this,null,function*(){return s})}blob(){return b(this,null,function*(){return s})}raw(){return b(this,null,function*(){return s})}}(this.__system);i({blob:p})})}onIterDataInputData(n){this._forward_empty("blob"),this._backward("done")}};var qo=class extends l{constructor(n){super({i:["canvas","bitmap","init"],o:[]},{input:{canvas:{ref:!0},bitmap:{ref:!0}}},n,L2)}f(o,a){return b(this,arguments,function*({canvas:n,bitmap:t,init:e},i){let s=yield t.imageBitmap();yield n.transferFromImageBitmap(s),i()})}};var Yo=class extends l{constructor(n){super({i:["d","x","y"],o:["d"]},{},n,G2)}f({d:n,x:t,y:e},i){i({d:[...n,["translate",t,e]]})}};var Jo=class extends l{constructor(n){super({i:["text"],o:[]},{},n,R2)}f(e,i){return b(this,arguments,function*({text:n},t){let{api:{clipboard:{writeText:o}}}=this.__system;try{yield o(n)}catch(a){t(void 0,a.message);return}t()})}};var Xo=class extends D{constructor(n){super({i:["arc","d"],o:["d"]},{},n,nd)}f({d:n,arc:{x:t,y:e,r:i,start:o,end:a,anticlockwise:s=!1}},p){p({d:[...n,["arc",t,e,i,o,a,s]]})}};var Zo=class extends l{constructor(n){super({i:["parent","child"],o:["at"]},{input:{parent:{ref:!0}}},n,k2)}f({parent:n,child:t},e){let i=n.appendChild(t);e({at:i})}};var Qo=class extends D{constructor(t){super({fi:["component","host","opt"],i:["done"],fo:[],o:[]},{input:{component:{ref:!0},host:{ref:!0}}},t,$2);this._attach=()=>{this._i.component.emit("call",{method:"attach",data:[this._i.opt]})}}f({component:t,host:e,opt:i},o){t.emit("call",{method:"register",data:[]}),e.emit("call",{method:"register",data:[]});let a=Zu(e.__global_id);t.emit("call",{method:"detach",data:[a,i]})}d(){this._attach()}onIterDataInputData(t,e){switch(t){case"done":this._functional._active_i_count===3&&(this._attach(),this._done()),this._backward("done");break}}};var ta=class extends l{constructor(n){super({i:["parent","at"],o:["test"]},{input:{parent:{ref:!0}}},n,N2)}f({parent:n,at:t},e){let i=n.hasChild(t);e({test:i})}};var ea=class extends l{constructor(n){super({i:["parent","child","at"],o:[]},{input:{parent:{ref:!0}}},n,F2)}f({parent:n,child:t,at:e},i){n.insertChild(t,e),i({at:e})}};var na=class extends D{constructor(n){super({fi:["unit","name"],i:["done"],fo:["ref"],o:[]},{input:{unit:{ref:!0}},output:{ref:{ref:!0}}},n,B2)}f({unit:n,name:t},e){let i=this.__system.global.scope[t];this.__system.emitter.addListener("register",(o,a)=>{o===t&&e({ref:a})}),i&&e({ref:i})}onIterDataInputData(n,t){switch(n){case"done":this._done(),this._backward("done");break}}};var ia=class extends D{constructor(n){super({fi:["unit","ref","name"],i:["done"],fo:[],o:[]},{input:{ref:{ref:!0},unit:{ref:!0}}},n,j2)}f({ref:n,unit:t,name:e},i){this.__system.global.scope[e]=n,this.__system.emitter.emit("register",e,n)}onIterDataInputData(n,t){switch(n){case"done":this._done(),this._backward("done");break}}};var ra=class extends l{constructor(n){super({i:["parent","at"],o:["unit"]},{input:{parent:{ref:!0}}},n,H2)}f({parent:n,at:t},e){let i;try{let o=n.removeChild(t);i=pn(o),o.destroy()}catch(o){e(void 0,o.message);return}e({unit:i})}};var oa=class extends l{constructor(n){super({i:["message"],o:[]},{},n,ab)}f({message:n},t){console.log(n),t()}};var aa=class extends l{constructor(n){super({i:["element","event","data","opt"],o:[]},{input:{element:{ref:!0}}},n,V2)}f({element:n,event:t,data:e,opt:i},o){let a=`_${t}`;n.emit("call",{method:"dispatchEvent",data:[t,e,i.bubbles]}),o()}};var sa=class extends D{constructor(t){super({fi:["emitter","event"],fo:[],i:["remove"],o:["data"]},{input:{emitter:{ref:!0}}},t,z2);this._unlisten=void 0;this._remove=()=>{this._unlisten(),this._listener=void 0,this._unlisten=void 0};this.addListener("destroy",()=>{this._listener&&(this._remove(),this._forward_empty("data"))})}f({emitter:t,event:e}){let i=(...o)=>{this._paused||this._output.data.push(o[0])};this._listener=i,this._unlisten=t.addListener(e,this._listener)}d(){this._remove(),this._forward_empty("data")}onIterDataInputData(t,e){this._listener&&(this._remove(),this._done())}};var of=16,af=4,M_=.001,pa=class extends mt{constructor(t,e){super();this.state={buttons:new Array(of).fill(!1,0,of),axes:new Array(af).fill(0,0,af)};this._frame=null;this._event_capture_tick=()=>{let{api:{input:{gamepad:{getGamepad:t}},animation:{requestAnimationFrame:e}}}=this.system;this.gamepad=t(this.gamepad.index);let i=[...this.state.buttons],o=this.gamepad.buttons.map(p=>p.pressed);this.state.buttons=o;for(let p=0;p<of;p++)o[p]&&!i[p]?this.emit("buttondown",p):!o[p]&&i[p]&&this.emit("buttonup",p);let a=this.state.axes,s=this.gamepad.axes.map(p=>p);this.state.axes=s;for(let p=0;p<af;p++)Math.abs(s[p]-a[p])>=M_&&this.emit("axischange",[p,s[p]]);this._frame=e(this._event_capture_tick)};this._start_event_capture=()=>{this._event_capture_tick()};this._stop_event_capture=()=>{let{api:{animation:{cancelAnimationFrame:t}}}=this.system;this._frame!==void 0&&(t(this._frame),this._frame=void 0)};this._listenerCount=0;this.system=t,this.gamepad=e}read(){return b(this,null,function*(){return this.state})}write(t){return b(this,null,function*(){throw new Error("cannot write to gamepad state")})}addListener(t,e){let i=super.addListener(t,e);return this._listenerCount++,this._listenerCount>=1&&this._start_event_capture(),()=>{this._listenerCount--,this._listenerCount===0&&this._stop_event_capture(),i()}}disconnect(){this._stop_event_capture()}};var ua=class extends D{constructor(t){super({fi:["i"],fo:[],i:["done"],o:["state"]},{output:{state:{ref:!0}}},t,W2)}f(i,o){return b(this,arguments,function*({i:t},e){let{api:{input:{gamepad:{getGamepad:a,addEventListener:s}}}}=this.__system;try{let f=a(t);this._gamepad=new pa(this.__system,f)}catch(f){e(void 0,f.message);return}let p=f=>{let{gamepad:g}=f,{index:h}=g;h===t&&(this._gamepad=new pa(this.__system,g),c(this._gamepad))},d=f=>{let{gamepad:g}=f,{index:h}=g;h===t&&(this._gamepad=null,m())};this._unlisten=tt([s("gamepadconnected",p),s("gamepaddisconnected",d),()=>{this._gamepad&&m()}]);let c=f=>{let g=new class extends C{read(){return b(this,null,function*(){return f.state})}write(x){return b(this,null,function*(){throw new Error("cannot write to gamepad state")})}}(this.__system);this._output.state.push(g)},m=()=>{this._output.state.pull()};this._gamepad&&c(this._gamepad)})}d(){this._unlisten(),this._unlisten=void 0}onIterDataInputData(t){this._output.state.pull(),this._done(),this._input.done.pull()}};var ca=class extends l{constructor(n){super({i:["any"],o:["position"]},{},n,K2)}f(e,i){return b(this,arguments,function*({any:n},t){let{api:{geolocation:{getCurrentPosition:o}}}=this.__system,a;try{a=yield o()}catch(s){t(void 0,s.message);return}t({position:a})})}};var da=class extends l{constructor(n){super({i:["data","title","url"],o:[]},{},n,rd)}f(o,a){return b(this,arguments,function*({data:n,title:t,url:e},i){let{api:{history:{pushState:s}}}=this.__system;s(n,t,e),i()})}};var ma=class extends l{constructor(n){super({i:["data","title","url"],o:[]},{},n,rd)}f(o,a){return b(this,arguments,function*({data:n,title:t,url:e},i){let{api:{history:{replaceState:s}}}=this.__system;s(n,t,e),i()})}};var fa=class extends D{constructor(t){super({fi:["port"],fo:[],i:["res","done"],o:["req"]},{},t,q2);this._waiter=new je}f(i,o){return b(this,arguments,function*({port:t},e){let{api:{http:{listen:a}}}=this.__system;try{this._unlisten=a(t,s=>(this._output.req.push(s),this._waiter.once()))}catch(s){e(void 0,s.message);return}})}onIterDataInputData(t,e){switch(t){case"res":this._waiter.set(e),this._input.res.pull();break;case"done":this._unlisten&&(this._unlisten(),this._done()),this._input.done.pull();break}}};var la=class extends D{constructor(t){super({fi:["channel"],fo:["port"],i:["close"],o:[]},{output:{port:{ref:!0}}},t,Y2);this._bc=null}f({channel:t},e){let{api:{channel:{local:i}}}=this.__system;this._bc=i({channel:t});let o=this._bc,a=new class extends C{constructor(d){super(d);this.__=["P"];this._unlisten=o.addListener("message",c=>{let{specs:m,classes:f}=this.__system,{data:g}=c,h=st(g,m,f);this.emit("message",h)}),this.addListener("destroy",()=>{this._unlisten(),this._unlisten=void 0})}send(d){let c=Y(d);o.postMessage(c)}}(this.__system);e({port:a})}d(){this._bc&&this._bc.close()}};var ba=class extends l{constructor(n){super({i:["any"],o:["url"]},{},n,J2)}f(e,i){return b(this,arguments,function*({any:n},t){let{api:{location:{toString:o}}}=this.__system,a=yield o();t({url:a})})}};function ie(r,n){return new class extends C{constructor(){super(...arguments);this.__=["AN"]}getContext(){return r.context}connect(i){r.connect(i)}disconnect(i){r.disconnect(i)}}(n)}function P_(r,n){return class extends C{constructor(){super(...arguments);this.__=["AN"]}getContext(){return r.context}connect(i){r.connect(i)}disconnect(){r.disconnect()}}}function uy(r,n){let t=P_(r,n);return new class extends t{constructor(){super(...arguments);this.__=["AN"]}getFFTSize(){return r.fftSize}getByteTimeDomainData(o){return r.getByteTimeDomainData(o)}getByteFrequencyData(o){return r.getByteFrequencyData(o)}}(n)}var ga=class extends l{constructor(t){super({i:["node","opt"],o:["node"]},{},t,X2);this.addListener("destroy",()=>{this._node})}f({node:t,opt:e},i){let o,{api:{window:{AnalyserNode:a}}}=this.__system;if(t.__.includes("AC"))t=t,o=t.createAnalyser(e);else{t=t;let p=t.getContext();o=new a(p,e),t.connect(o)}this._node=o;let s=uy(o,this.__system);i({node:s})}d(){}};function cy(r,n){return new class extends C{constructor(){super(...arguments);this.__=["AC"]}get(){return r}getDestination(){return r.destination}createOscilator(o){let{api:{window:{OscillatorNode:a}}}=n;return new a(r,o)}createAnalyser(o){throw new O}}(n)}var ha=class extends l{constructor(t){super({i:["opt"],o:["ctx"]},{output:{ctx:{ref:!0}}},t,Z2);this.addListener("destroy",()=>{this._ctx&&this._ctx.close()})}f({opt:t},e){let{api:{window:{AudioContext:i}}}=this.__system,o=new i(t);this._ctx=o;let a=cy(o,this.__system);e({ctx:a})}d(){}};var ya=class extends l{constructor(t){super({i:["node"],o:[]},{input:{node:{ref:!0}},output:{node:{ref:!0}}},t,Q2);this.addListener("destroy",()=>{this._destroy(this._i.node)})}f({node:t},e){let o=t.getContext().destination;this._node=o,t.connect(o)}_destroy(t){t&&(t.disconnect(this._node),this._node=void 0)}d(t,e){this._destroy(e)}};function re(r,n){return new class extends C{constructor(){super(...arguments);this.__=["MS"]}mediaStream(o){return o(r),gt}getVideoTracks(){return b(this,null,function*(){return r.getVideoTracks()})}}(n)}var _a=class extends l{constructor(t){super({i:["src"],o:["stream"]},{},t,tg);this._audio=new Audio,this._audio.volume=0,this._audio.play(),this.addListener("destroy",()=>{this._audio.srcObject=null})}f({src:t},e){this._audio.src=t;let{srcObject:i}=this._audio,o;if(i instanceof MediaStream)o=re(i,this.__system);else{e(void 0,"");return}e({stream:o})}d(){this._audio.src=null}};var xa=class extends l{constructor(t){super({i:["id","stream"],o:[]},{input:{stream:{ref:!0}}},t,eg);this._audio=new Audio}f(i){return b(this,arguments,function*({stream:t,id:e}){t.mediaStream(o=>{this._audio.srcObject=o}),this._audio.setSinkId(e).catch(o=>{this.err(o.message)}),this._audio.play()})}d(){this._audio.pause()}};function Ia(r,n){return new class extends C{constructor(){super(...arguments);this.__=["AN"]}read(){return Promise.resolve(r.value)}write(i){r.value=i}}(n)}var va=class extends l{constructor(t){super({i:["node","delay"],o:["node","delay"]},{input:{node:{ref:!0}},output:{node:{ref:!0},delay:{ref:!0}}},t,ng);this._disconnect=t=>{t&&(t.disconnect(),this._node=void 0)};this.addListener("destroy",()=>{this._node&&this._disconnect(this._i.node)})}f({node:t,delay:e},i){let o;t=t,o=t.getContext().createDelay(),o.delayTime.value=e,this._node=o,t.connect(o);let s=ie(o,this.__system),p=Ia(o.delayTime,this.__system);i({node:s,delay:p})}i(){this._disconnect(this._i.node)}d(t,e){t==="node"&&this._disconnect(this._i.node)}};var Da=class extends l{constructor(t){super({i:["node","gain"],o:["node"]},{input:{node:{ref:!0}},output:{node:{ref:!0}}},t,ig);this._disconnect=t=>{t&&(t.disconnect(),this._node=void 0)};this.addListener("destroy",()=>{this._node&&this._disconnect(this._i.node)})}f({node:t,gain:e},i){let o;t=t,o=t.getContext().createGain(),o.gain.value=e,this._node=o,t.connect(o);let s=ie(o,this.__system);i({node:s})}i(){this._disconnect(this._i.node)}d(t,e){t==="node"&&this._disconnect(this._i.node)}};var Sa=class extends D{constructor(t){super({fi:["node","opt"],fo:["data"],i:["done"]},{input:{node:{ref:!0}},output:{data:{ref:!0}}},t,rg);this._reset=()=>{this._data=void 0,this._backward_all()}}f({node:t,opt:e},i){let o=t.getFFTSize();this._data=new Uint8Array(o),t.getByteFrequencyData(this._data);let a=Pe(this._data,this.__system);i({data:a})}d(){}onIterDataInputData(t,e){this._reset()}};var Ea=class extends D{constructor(t){super({fi:["node","opt"],fo:["data"],i:["done"]},{input:{node:{ref:!0}},output:{data:{ref:!0}}},t,og);this._reset=()=>{this._data=void 0,this._backward_all()}}f({node:t,opt:e},i){let o=t.getFFTSize();this._data=new Uint8Array(o),t.getByteTimeDomainData(this._data);let a=Pe(this._data,this.__system);i({data:a})}d(){}onIterDataInputData(t,e){this._reset()}};var Ta=class extends l{constructor(t){super({i:["node","opt","stream"],o:["node"]},{input:{node:{ref:!0},stream:{ref:!0}},output:{node:{ref:!0}}},t,ag);this._destroy=()=>{this._node&&(this._node=void 0)};this.addListener("destroy",()=>{this._destroy()})}f({node:t,stream:e,opt:i},o){let a,{api:{window:{MediaStreamAudioSourceNode:s}}}=this.__system,p;t.__.includes("AC")?(t=t,p=t.get()):(t=t,p=t.getContext()),e.mediaStream(d=>{try{a=new s(p,{mediaStream:d})}catch(m){o(void 0,m.message.toLowerCase());return}this._node=a;let c=ie(a,this.__system);o({node:c})})}i(t){this._destroy()}d(){this._destroy()}};var Aa=class extends l{constructor(t){super({i:["a","b"],o:["node"]},{input:{a:{ref:!0},b:{ref:!0}},output:{node:{ref:!0}}},t,sg);this.addListener("destroy",()=>{this._node})}f({a:t,b:e},i){let o;o=t.getContext().createGain(),this._node=o,t.connect(o),e.connect(o);let s=ie(o,this.__system);i({node:s})}d(){}};var Ca=class extends l{constructor(t){super({i:["node","opt"],o:["node","frequency","detune"]},{input:{node:{ref:!0}},output:{node:{ref:!0},frequency:{ref:!0},detune:{ref:!0}}},t,pg);this._destroy=()=>{this._node&&(this._node.stop(),this._node=void 0)};this.addListener("destroy",()=>{this._destroy()})}f({node:t,opt:e},i){let o,{api:{window:{OscillatorNode:a}}}=this.__system;if(t.__.includes("AC"))o=t.createOscilator(e);else{t=t;let c=t.getContext();o=new a(c,e)}o.start(),this._node=o;let s=ie(o,this.__system),p=Ia(o.frequency,this.__system),d=Ia(o.detune,this.__system);i({node:s,frequency:p,detune:d})}i(t){this._destroy()}d(){this._destroy()}};var md=class{constructor(n=null){this._data=null;this._callback=[];this._data=n}set(n){this._data=n;for(let t of this._callback)t(n)}connect(n){return this._callback.push(n),this._data&&n(this._data),()=>{let t=this._callback.indexOf(n);if(t>-1)this._callback.splice(t,1);else throw new Error("can only unlisten once")}}};var Ma=class extends D{constructor(t){super({fi:["source","opt"],fo:["stream"],i:["stop"],o:[]},{input:{source:{ref:!0}},output:{stream:{ref:!0}}},t,ug);this.__=["U"];this._stream=new md}f(o,a){return b(this,arguments,function*({source:t,opt:e},i){let s;try{s=yield t.captureStream(e)}catch(d){i(void 0,d.message);return}let p=re(s,this.__system);i({stream:p})})}onIterDataInputData(t,e){this._stream.set(null),this._done(),this._input.stop.pull()}mediaStream(t){return this._stream.connect(t)}};var Pa=class extends l{constructor(n){super({i:["text","name","mimetype","charset"],o:[]},{},n,cg)}f(a,s){return b(this,arguments,function*({text:n,name:t,mimetype:e,charset:i},o){let{api:{file:{downloadText:p}}}=this.__system;try{yield p({text:n,name:t,mimetype:e,charset:i})}catch(d){o(void 0,d.message);return}o()})}};var Oa=class extends l{constructor(n){super({i:["url","name"],o:[]},{},n,dg)}f(i,o){return b(this,arguments,function*({url:n,name:t},e){let{api:{file:{downloadURL:a}}}=this.__system;try{yield a({url:n,name:t})}catch(s){e(void 0,s.message);return}e()})}};var Ua=class extends l{constructor(n){super({i:["any"],o:["devices"]},{},n,mg)}f(t,e){return b(this,arguments,function*({},n){let{api:{media:{enumerateDevices:i}}}=this.__system,o;try{o=yield i()}catch(a){n(void 0,a.message);return}n({devices:o})})}};function fd(r){r.getTracks().forEach(n=>n.stop())}var wa=class extends l{constructor(t){super({i:["opt"],o:["stream"]},{},t,fg);this.addListener("destroy",()=>{this._stream&&(fd(this._stream),this._stream=void 0)}),this.addListener("take_err",()=>{this._input.opt.pull()})}f(i,o){return b(this,arguments,function*({opt:t},e){let{api:{media:{getDisplayMedia:a}}}=this.__system,s;try{s=yield a(t)}catch(d){if(d.name==="NotAllowedError"){e(void 0,"permission denied");return}e(void 0,d.message);return}let p=re(s,this.__system);e({stream:p})})}};function dy(r,n){return new class extends C{constructor(){super(...arguments);this.__=["MST"]}mediaStreamTrack(){return b(this,null,function*(){return r})}}(n)}var La=class extends D{constructor(n){super({fi:["stream","init"],fo:["tracks"],i:["done"],o:[]},{input:{stream:{ref:!0}},output:{tracks:{ref:!0}}},n,lg),this.addListener("destroy",()=>{})}f(e,i){return b(this,arguments,function*({stream:n},t){let o;try{o=yield n.getVideoTracks()}catch(s){t(void 0,s)}let a=new class extends C{constructor(){super(...arguments);this.__=["A"]}append(d){return b(this,null,function*(){throw new O})}put(d,c){return b(this,null,function*(){throw new O})}at(d){return b(this,null,function*(){let c=o[d];return dy(c,this.__system)})}length(){return b(this,null,function*(){return o.length})}indexOf(d){return b(this,null,function*(){throw new O})}}(this.__system);t({tracks:a})})}onIterDataInputData(n){this._forward_all_empty(),this._backward_all(),this._backward("done")}};function my(r,n){return new class extends C{constructor(){super(...arguments);this.__=["IB"]}imageBitmap(){return b(this,null,function*(){return r})}image(){return b(this,null,function*(){return r})}}(n)}var Ga=class extends D{constructor(t){super({fi:["camera"],fo:[],i:["init","done"],o:["image"]},{input:{camera:{ref:!0}},output:{image:{ref:!0}}},t,bg);this._err_flag=!1;this._forward_if_ready=()=>b(this,null,function*(){if(this._input.camera.active()&&this._input.init.active()){let t;try{t=yield this._i.camera.grabFrame()}catch(i){this.err(i.message.toLowerCase()),this._err_flag=!0;return}let e=my(t,this.__system);this._output.image.push(e),this._input.init.pull()}});this.addListener("destroy",()=>{}),this.addListener("take_err",()=>{this._err_flag&&(this._err_flag=!1,this._input.init.pull())})}f(i,o){return b(this,arguments,function*({camera:t},e){this._forward_if_ready()})}onIterDataInputData(t){return b(this,null,function*(){t==="done"?(this._forward_empty("image"),this._done(),this._backward("done")):t==="init"&&this._forward_if_ready()})}};var Ra=class extends l{constructor(n){super({i:["opt","image","rect"],o:["bitmap"]},{input:{image:{ref:!0}},output:{bitmap:{ref:!0}}},n,gg)}f(o,a){return b(this,arguments,function*({opt:n,rect:t,image:e},i){let{api:{media:{image:{createImageBitmap:s}}}}=this.__system,p=yield e.image(),d;try{d=yield s(p,t,n)}catch(m){i(void 0,m.message);return}let c=new class extends C{constructor(){super(...arguments);this.__=["IB"]}imageBitmap(){return b(this,null,function*(){return d})}image(){return b(this,null,function*(){return d})}}(this.__system);i({bitmap:c})})}};function fy(r,n){return new class extends C{constructor(){super(...arguments);this.__=["IC"]}grabFrame(){return r.grabFrame()}}(n)}var ka=class extends D{constructor(n){super({fi:["init","track"],fo:["camera"],i:["done"],o:[]},{input:{track:{ref:!0}},output:{camera:{ref:!0}}},n,hg),this.addListener("destroy",()=>{})}f(i,o){return b(this,arguments,function*({init:n,track:t},e){let{api:{window:{ImageCapture:a}}}=this.__system;if(!a){e(void 0,"ImageCapture API is not supported");return}let s=yield t.mediaStreamTrack();s.onmute=()=>{},s.onunmute=()=>{},s.onended=()=>{};let p=new a(s),d=fy(p,this.__system);e({camera:d})})}onIterDataInputData(n,t){this._forward_all_empty(),this._backward_all(),this._backward("done")}};var $a=class extends D{constructor(t){super({fi:["opt","stream"],fo:[],i:["start","stop"],o:["blob"]},{input:{stream:{ref:!0}},output:{blob:{ref:!0}}},t,yg);this._start_recorder=t=>{this._media_recorder&&(this._media_recorder.state==="recording"&&this._media_recorder.stop(),this._media_recorder.start(t))};this.addListener("destroy",()=>{this._media_recorder.stop(),this._media_recorder.ondataavailable=null,this._media_recorder=null})}f({opt:t,stream:e}){let i=[];e.mediaStream(o=>{this._media_recorder&&(this._media_recorder.stop(),this._media_recorder.ondataavailable=null),this._media_recorder=new MediaRecorder(o,t),this._media_recorder.ondataavailable=s=>{let{data:p}=s;p.size>0&&i.push(p)},this._media_recorder.onstop=()=>{let s=new Blob(i,{type:"audio/wav"}),p=new class extends C{constructor(){super(...arguments);this.__=["B","IM"]}image(){return b(this,null,function*(){return s})}blob(){return b(this,null,function*(){return s})}}(this.__system);this._output.blob.push(p)};let a=this._input.start.peak();a!==void 0&&this._start_recorder(a)})}onIterDataInputData(t,e){t==="start"?this._media_recorder&&this._start_recorder(e):t==="stop"&&this._media_recorder&&(this._media_recorder.state==="recording"&&this._media_recorder.stop(),this._backward("start"),this._backward("stop"))}onIterDataInputDrop(t){this.hasErr()&&this.takeErr(),t==="start"&&(this._backwarding||this._media_recorder&&this._media_recorder.stop())}};function ly(r,n){let{global:{component:t}}=r;return t[n]}function ld(r,n,t){let{emitter:e}=r,i=o=>{t(o)};return e.addListener(n,i),()=>{e.removeListener(n,i)}}function cn(r,n){let{emitter:t}=r,e=r.getLocalComponents(n)[0];return e?Promise.resolve(e):new Promise(i=>{let o=a=>{setTimeout(()=>{t.removeListener(n,o)},0),i(a)};t.addListener(n,o)})}var Na=class extends D{constructor(t){super({fi:["media","opt"],i:["stop"]},{input:{media:{ref:!0}}},t,_g);this._exit_picture_in_picture_promise=Promise.resolve()}_plunk(){let{api:{document:{exitPictureInPicture:t}}}=this.__system;this._unlisten&&(this._unlisten(),this._unlisten=void 0),this._picture_in_picture&&(this._exit_picture_in_picture_promise=t(),this._picture_in_picture=void 0)}f(o,a){return b(this,arguments,function*({media:t,opt:e},i){yield this._exit_picture_in_picture_promise;let s=t.getGlobalId();ld(this.__system,s,p=>b(this,null,function*(){if(p===null)this._plunk();else if(document.pictureInPictureElement===p.$element)this.err("media is already Picture in Picture");else{let d=yield p.requestPictureInPicture(),c=m=>{this._picture_in_picture=void 0,this._plunk()};p.$element.addEventListener("leavepictureinpicture",c),this._unlisten=()=>{p.$element.removeEventListener("leavepictureinpicture",c)},this._picture_in_picture=d}}))})}onIterDataInputData(t){this._plunk(),this._backward("media"),this._backward("opt")}};var Fa=class extends l{constructor(t){super({i:["opt"],o:["stream"]},{output:{stream:{ref:!0}}},t,xg);this.addListener("destroy",()=>{this._stream&&(fd(this._stream),this._stream=void 0)})}f(i,o){return b(this,arguments,function*({opt:t},e){let{api:{media:{getUserMedia:a}}}=this.__system,s;try{let p=yield a(t);s=re(p,this.__system)}catch(p){e(void 0,p.message);return}e({stream:s})})}};var Ba=class extends D{constructor(t){super({fi:["url"],fo:["emitter"],i:["close"],o:[]},{output:{emitter:{ref:!0}}},t,Ig);this._event_source=null;this._pluck=()=>{this._event_source&&(this._event_source.close(),this._event_source=null)}}f({url:t},e){let{api:{http:{EventSource:i}}}=this.__system,o=new i(t);this._event_source=o,o.onerror=a=>{this._pluck(),e(void 0,"error connecting to server")},o.onopen=a=>{let s=new class extends C{addListener(d,c){super.addListener(d,c);let m=f=>{c(f.data)};return o.addEventListener(d,m),()=>{o.removeEventListener(d,m)}}}(this.__system);e({emitter:s})}}onIterDataInputData(t,e){t==="close"&&this._pluck()}};var ja=class extends l{constructor(t){super({i:["url","opt"],o:["response"]},{},t,vg);this._fetch_index=0}f({url:t,opt:e},i){let{api:{http:{fetch:o}}}=this.__system,a=++this._fetch_index;try{o(t,e).then(s=>{if(a===this._fetch_index)return s.text().then(p=>{a===this._fetch_index&&i({response:{status:s.status,body:p}})})}).catch(s=>{if(a===this._fetch_index){if(s.message.toLowerCase()==="failed to execute 'fetch' on 'window': request with get/head method cannot have body."){i(void 0,"request with GET/HEAD method cannot have body");return}i(void 0,s.message.toLowerCase())}})}catch(s){i(void 0,"malformed")}}};function by(r,n){return new class extends C{constructor(){super(...arguments);this.__=["RES"]}toJson(){return r.json()}}(n)}var Ha=class extends l{constructor(n){super({i:["url","opt","body"],o:["res"]},{input:{body:{ref:!0}},output:{res:{ref:!0}}},n,Dg)}f(o,a){return b(this,arguments,function*({url:n,opt:t,body:e},i){let{api:{http:{fetch:s}}}=this.__system;t.body=yield e.raw();let p;try{p=yield s(n,t)}catch(c){i(void 0,"malformed");return}let d=by(p,this.__system);i({res:d})})}};function gy(r,n){return new class extends C{constructor(){super(...arguments);this.__=["CH"]}send(o){return b(this,null,function*(){r.send(o)})}}(n)}var Va=class extends D{constructor(t){super({fi:["url"],fo:["channel"],i:["close"],o:[]},{},t,Sg);this._web_socket=null;this._plunk=()=>{this._web_socket.onopen=null,this._web_socket.onmessage=null,this._web_socket.onerror=null,this._web_socket.onclose=null,this._web_socket=null}}f({url:t},e){this._web_socket&&this._web_socket.close(),this._web_socket=new WebSocket(t),this._web_socket.onopen=()=>{},this._web_socket.onmessage=o=>{this.emit("message",o.data)},this._web_socket.onerror=o=>{this.err("error")},this._web_socket.onclose=o=>{let{code:a,reason:s}=o;this._plunk()};let i=gy(this._web_socket,this.__system);e({channel:i})}d(){this._plunk()}onIterDataInputData(t,e){this._close(),this._done()}_close(){this._web_socket&&this._web_socket.readyState===WebSocket.OPEN&&this._web_socket.close()}send(t){return b(this,null,function*(){this._web_socket&&this._web_socket.readyState===WebSocket.OPEN&&this._web_socket.send(t)})}};var za=class extends l{constructor(n){super({i:["res","any"],o:["json"]},{},n,Eg)}f(e,i){return b(this,arguments,function*({res:n},t){let o=yield n.toJson();t({json:o})})}};var Wa=class extends Q{constructor(n){super({i:["this","opt"],o:[]},{input:{notification:{ref:!0}}},n,Tg)}};var Ka=class extends Q{constructor(t){super({i:[],o:[]},{},t,Ag);this._notification=null;this._setup()}onDataInputData(t){this.hasErr()&&this.takeErr()}_setup(){if("Notification"in window){let{permission:t}=Notification;t==="default"?Notification.requestPermission().then(e=>{this.err("not authorized")}):this.err("not authorized")}else this.err("not authorized")}$show({title:t,opt:e},i){this._notification=new Notification(t,e),this._notification.onclick=()=>{this.emit("click")},this._notification.onclose=()=>{this.emit("close")},this._notification.onerror=()=>{this.emit("error")},this._notification.onshow=()=>{this.emit("show")},i()}$close({},t){this._notification&&this._notification.close(),t()}};var qa=class extends Q{constructor(n){super({i:["this"],o:[]},{input:{notification:{ref:!0}}},n,Cg)}};var Ya=class extends D{constructor(n){super({fi:["root","opt"],fo:["observer"],i:["done"],o:[]},{input:{root:{ref:!0}},output:{observer:{ref:!0}}},n,Mg)}f(e,i){return b(this,arguments,function*({root:n},t){let{api:{document:{IntersectionObserver:o}}}=this.__system,a=n.getGlobalId(),s=yield cn(this.__system,a),p=x=>{for(let y=0;y<x.length;y++){let I=x[y],v=g[y];if(!v)return;let T={isIntersecting:I.isIntersecting,time:I.time};v(T)}},d=s.getRootBase(),c=s;for(;d.length===0;)d=c.$slotParent.getRootBase(),c=c.$slotParent;let m=d[0][1],f=new o(p,{root:m.$element,threshold:.1}),g=[],h=new class extends C{constructor(){super(...arguments);this.__=["OB"]}observe(I,v){return g.push(v),f.observe(I),()=>{$t(g,v),f.unobserve(I)}}}(this.__system);t({observer:h})})}d(){}};var Ja=class extends D{constructor(n){super({fi:["component","observer"],fo:[],i:["done"],o:["entry"]},{input:{component:{ref:!0}}},n,Pg)}f(i,o){return b(this,arguments,function*({observer:n,component:t},e){let{api:{document:{}}}=this.__system,a=t.getGlobalId(),p=(yield cn(this.__system,a)).getFirstRootLeaf();if(p.$element instanceof Text){e(void 0,"cannot observe text node");return}n.observe(p.$element,d=>{this._output.entry.push(d)})})}d(){}};var Xa=class extends D{constructor(t){super({fi:["component","opt"],fo:[],i:["done"],o:["entry"]},{input:{component:{ref:!0}}},t,Og)}f(e){return b(this,arguments,function*({component:t}){let{api:{document:{PositionObserver:i}}}=this.__system,o=t.getGlobalId(),a=yield cn(this.__system,o);if(!this._observer){let d=(m,f)=>{this._output.entry.push({x:m,y:f})},c=new i(this.__system,d);this._observer=c}let s=a.getFirstRootLeaf(),{$element:p}=s;this._observer.observe(p)})}d(){}onIterDataInputData(t,e){this._observer&&this._observer.disconnect(),this._unlisten&&(this._unlisten(),this._unlisten=void 0),this._done(),this.pullInput("done")}};var Za=class extends D{constructor(t){super({fi:["component"],fo:[],i:[],o:["width","height"]},{input:{component:{ref:!0}}},t,Ug)}f({component:t},e){let{api:{document:{ResizeObserver:i}}}=this.__system,o=t.getGlobalId(),a=ly(this.__system,o),s=d=>{if(!this._observer){let m=g=>{let h=g[0],{width:x,height:y}=h.contentRect;this._output.width.push(x),this._output.height.push(y)},f=new i(m);this._observer=f}a&&this._observer.unobserve(a.$element),a=d;let{$element:c}=a};a&&s(a);let p=ld(this.__system,o,d=>{s(d)})}d(){}};function hy(r){return b(this,null,function*(){return new Promise((n,t)=>{let e=[],i=a=>b(this,[a],function*({candidate:o}){o?e.push(o):(r.removeEventListener("icecandidate",i),n(e))});r.addEventListener("icecandidate",i)})})}var oe=class extends C{constructor(t,e,i){super(t);if(this._initiator=e,this._config=i,!RTCPeerConnection)throw new V("Web RTC");let o=new RTCPeerConnection(this._config);this._setup(o),this._rtc=o;let a=this._rtc.createDataChannel("data",{negotiated:!0,id:0});if(a.onmessage=s=>{let{data:p}=s,d=JSON.parse(p),{type:c,data:m}=d;switch(c){case"message":this.emit("message",m);break;case"start":this._incoming_stream&&this.emit("start",this._incoming_stream);break;case"stop":this.emit("stop");break}},a.onopen=()=>{if(this.emit("connect"),this._stream){let s=JSON.stringify({type:"start"});this._rtc_channel.send(s)}},this._initiator){let s=new MediaStream;this._outgoing_stream=s;let p=this._rtc.addTransceiver("video",{streams:[s]});this._video_transceiver=p;let d=this._rtc.addTransceiver("audio",{streams:[s]});this._audio_transceiver=d}this._rtc_channel=a}send(t){let e=JSON.stringify({type:"message",data:t});this._rtc_channel.send(e)}offer(){return b(this,null,function*(){return this._offer(this._rtc)})}_offer(t){return b(this,null,function*(){let e=yield t.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});yield t.setLocalDescription(e);let{sdp:i}=e,o=yield hy(t);return JSON.stringify({sdp:i,candidates:o})})}_setup(t){t.onconnectionstatechange=()=>{let{connectionState:e}=t;switch(e){case"connected":break;case"disconnected":case"closed":this.emit("close");break}},this._initiator||(t.ontrack=e=>{let{streams:i}=e,o=i[0];o&&(this._incoming_stream=o)})}_plunk(t){t.oniceconnectionstatechange=null,t.onconnectionstatechange=null,t.onicegatheringstatechange=null,t.onnegotiationneeded=null,t.ondatachannel=null,t.ontrack=null}_plunk_channel(t){t.onmessage=null}acceptOffer(t){return b(this,null,function*(){return this._acceptOffer(this._rtc,t)})}_acceptOffer(t,e){return b(this,null,function*(){let{sdp:i,candidates:o}=JSON.parse(e),a=new RTCSessionDescription({type:"offer",sdp:i});yield t.setRemoteDescription(a);for(let s of o)yield t.addIceCandidate(s)})}answer(){return b(this,null,function*(){return this._answer(this._rtc)})}_answer(t){return b(this,null,function*(){let e=yield t.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});t.setLocalDescription(e);let{sdp:i}=e,o=yield hy(t);return JSON.stringify({sdp:i,candidates:o})})}acceptAnswer(t){return b(this,null,function*(){return this._acceptAnswer(this._rtc,t)})}_acceptAnswer(t,e){return b(this,null,function*(){let{sdp:i,candidates:o}=JSON.parse(e),a=new RTCSessionDescription({type:"answer",sdp:i});yield t.setRemoteDescription(a);for(let s of o)yield t.addIceCandidate(s)})}addStream(t){return b(this,null,function*(){this._stream=t;let e=t.getAudioTracks()[0];e&&(yield this._audio_transceiver.sender.replaceTrack(e));let i=t.getVideoTracks()[0];if(i&&(yield this._video_transceiver.sender.replaceTrack(i)),this._rtc_channel.readyState==="open"){let o=JSON.stringify({type:"start"});this._rtc_channel.send(o)}})}removeStream(){return b(this,null,function*(){if(this._stream=null,yield Promise.all([this._video_transceiver.sender.replaceTrack(null),this._audio_transceiver.sender.replaceTrack(null)]),this._rtc_channel.readyState==="open"){let t=JSON.stringify({type:"stop"});this._rtc_channel.send(t)}})}close(){this._plunk_channel(this._rtc_channel),this._rtc_channel.close(),this._plunk(this._rtc),this._rtc.close()}};var Qa=class extends Q{constructor(t){super({i:["opt","offer","close"],o:["graph","answer"]},{output:{graph:{ref:!0}}},t,wg);this.__=["U"];this._peer_connected=!1;this._offer_sent=!1;this._accept_offer=t=>b(this,null,function*(){yield this._peer.acceptOffer(t);let e=yield this._peer.answer();this._output.answer.push(e),this._offer_sent=!0});this.__forward_empty=()=>{this._forward_all_empty(),this._backward("offer"),this._backward("close"),this._backward("opt"),this._forwarding_empty=!0,this.hasErr()&&this.takeErr(),this._disconnect(),this._forwarding_empty=!1};this._disconnect=()=>{this._backwarding=!0,this._output.graph.pull(),this._remote_port&&(this._remote_port.close(),this._remote_port=void 0),this._peer&&(this._peer=null),this._backwarding=!1};this.addListener("destroy",()=>{this.__forward_empty()}),this.addListener("take_err",()=>{}),this.addListener("take_caught_err",()=>{})}onDataInputData(t,e){return b(this,null,function*(){if(t==="opt"){this._peer=new oe(this.__system,!1,e);let i={send:a=>{let s=Y(a);this._peer.send(s)},onmessage(a){},onerror(){},terminate(){}};this._peer.addListener("message",a=>{let s=this.__system.specs,p=this.__system.classes,d=st(a,s,p),{type:c,data:m}=d;switch(c){case Ot:i.onmessage({data:m});break;case Zt:{let f=new qt(i);this._remote_port=f;let g=un(f),h=Gt(this.__system,g,["U","C","G"]);this._output.graph.push(h)}break;case Qt:this._disconnect();break}}),this._peer.addListener("connect",()=>{this._peer_connected=!0}),this._peer.addListener("close",()=>{this._peer_connected=!1});let o=this._input.offer.peak();o!==void 0&&this._accept_offer(o)}else if(t==="offer"){if(this._peer){let i=e;this._accept_offer(i)}}else t==="close"&&this.__forward_empty()})}onDataInputDrop(t){t==="opt"&&(this._backwarding||this.__forward_empty())}};function yy(r){return new class extends C{constructor(){super(...arguments);this.__=["EE"]}}(r)}var ts=class extends D{constructor(t){super({fi:["opt"],fo:["answer"],i:["close","offer"],o:["stream","emitter"]},{input:{}},t,Lg);this._peer=null;this._unlisten=void 0;this._connected=!1;this._flag_err_invalid_offer=!1;this._output_answer=t=>b(this,null,function*(){try{yield this._peer.acceptOffer(t)}catch(i){this._flag_err_invalid_offer=!0,this.err("invalid offer");return}let e=yield this._peer.answer();this._output.answer.push(e)});this._send_data=(t,e)=>{this._send({type:"data",data:t},e)};this._send=(t,e)=>{if(this._connected){let i=Y(t);this._peer.send(i),e()}else e(void 0,"peer not connected")};this._setup_peer=()=>{let t=()=>{this._connected=!0;let p=yy(this.__system);this._output.emitter.push(p)},e=p=>{this.err(p.message)},i=()=>{this._disconnect()},o=p=>{this._output.emitter.active()&&this._output.emitter.peak().emit("message",p)},a=p=>{let d=re(p,this.__system);this._output.stream.push(d)},s=()=>{this._output.stream.pull()};return this._peer.addListener("connect",t),this._peer.addListener("error",e),this._peer.addListener("close",i),this._peer.addListener("message",o),this._peer.addListener("start",a),this._peer.addListener("stop",s),()=>{this._peer.removeListener("connect",t),this._peer.removeListener("error",e),this._peer.removeListener("close",i),this._peer.removeListener("message",o),this._peer.removeListener("start",a),this._peer.removeListener("stop",s)}};this._disconnect=()=>{this._unlisten&&(this._unlisten(),this._unlisten=void 0),this._output.emitter.pull(),this._output.stream.pull(),this._peer&&(this._peer.close(),this._peer=null),this._connected=!1,this._done({})};this.addListener("destroy",()=>{this._disconnect()}),this.addListener("take_err",()=>{this._flag_err_invalid_offer&&(this._flag_err_invalid_offer=!1,this._backward("offer"))})}f(e){return b(this,arguments,function*({opt:t}){this._peer=new oe(this.__system,!1,t),this._setup_peer(),this._input.offer.active()&&this._output_answer(this._input.offer.peak())})}onDataInputData(t,e){return b(this,null,function*(){t==="close"?(this._disconnect(),this._backward("close")):t==="offer"&&this._input.opt.active()&&this._output_answer(e)})}onDataInputDrop(t){if(t==="opt")this._backwarding||this._disconnect();else if(t==="offer"){if(this._flag_err_invalid_offer){this._flag_err_invalid_offer=!1,this.takeErr();return}this._forward_empty("emitter"),this._forward_empty("stream"),this._forward_empty("answer")}}onDataOutputDrop(t){t==="answer"&&this._input.offer.pull()}};function bd(r,n,t){let e=Xn(r,n);return new Ee(e,t)}var es=class extends D{constructor(t){super({fi:["graph","opt"],fo:["offer"],i:["answer","close"],o:[]},{input:{graph:{ref:!0}}},t,Gg);this.__=["U"];this._connected=!1;this._disconnect=()=>{this._send_terminate(),this._peer=null};this._close=()=>{this._ref=null};this._send=t=>{let e=Y(t);this._peer.send(e)};this._send_init=()=>{this._send({type:Zt})};this._send_exec=t=>{this._send({type:Ot,data:t})};this._send_terminate=()=>{this._connected&&this._send({type:Qt})};this.addListener("destroy",()=>{this._connected&&(this._disconnect(),this._close())})}f({graph:t,opt:e},i){let o=new oe(this.__system,!0,e);this._connected=!1,o.addListener("connect",()=>{this._connected=!0,this._input.graph.active()&&this._send_init()}),o.addListener("close",()=>{this._connected=!1}),o.addListener("message",s=>{if(this._ref){let p=this.__system.specs,d=this.__system.classes,c=st(s,p,d);this._ref.exec(c)}}),this._peer=o,b(this,null,function*(){let s=yield o.offer();i({offer:s})});let a=bd(t,["U","C","G","EE"],s=>{this._send_exec(s)});this._ref=a,this._connected&&this._send_init(),this._input.answer.active()&&b(this,null,function*(){yield this._peer.acceptAnswer(this._input.answer.peak())})}d(){this._disconnect()}onIterDataInputData(t,e){return b(this,null,function*(){t==="answer"?this._peer&&(yield this._peer.acceptAnswer(e)):t==="close"&&this._disconnect()})}onIterDataInputDrop(t){return b(this,null,function*(){t==="answer"&&this._disconnect()})}};var ns=class extends D{constructor(t){super({fi:["opt"],i:["answer","stream","close"],o:["offer","channel"]},{input:{stream:{ref:!0}},output:{channel:{ref:!0}}},t,Rg);this._peer=void 0;this._unlisten=void 0;this._connected=!1;this._offered=!1;this._flag_err_peer_construct=!1;this._flag_err_answer_without_offer=!1;this._stream=null;this._add_stream=t=>{this._stream=t,this._peer&&this._peer.addStream(t)};this._remove_stream=t=>{this._peer.removeStream()};this._output_port=()=>{let t=this._peer,e=new class extends C{constructor(){super(...arguments);this.__=["MS"]}send(a){return b(this,null,function*(){let s=Y(a);t.send(s)})}}(this.__system);this._output.channel.push(e)};this._setup_peer=()=>{let t=a=>{let{sdp:s}=a;this._output.offer.push(s)},e=()=>{this._connected=!0,this._output_port()},i=a=>{this.err(a.message)},o=()=>{this._disconnect()};return this._peer.addListener("connect",e),this._peer.addListener("error",i),this._peer.addListener("close",o),()=>{this._peer.removeListener("connect",e),this._peer.removeListener("error",i),this._peer.removeListener("close",o)}};this._disconnect=()=>{if(!this._connected)return;let t=this._unlisten;t(),this._unlisten=void 0,this._peer.close(),this._peer=void 0,this._connected=!1,this._forward_empty("offer"),this._forward_empty("channel"),this._done({})};this.addListener("destroy",()=>{this._connected&&this._disconnect()}),this.addListener("take_err",()=>{if(!this._backwarding)if(this._flag_err_answer_without_offer)this._flag_err_answer_without_offer=!1,this._backward("answer");else if(this._flag_err_peer_construct)this._flag_err_peer_construct=!1,this._backward("opt");else throw new Error("PeerTransmitter: invalid err state")})}f(e){return b(this,arguments,function*({opt:t}){try{this._peer=new oe(this.__system,!0,t)}catch(o){let{message:a}=o,s="Failed to construct 'RTCPeerConnection': ";if(a.startsWith(s)){let p=a.substr(0,a.length-1).replace(s,"");this.err(p);return}else{this.err(o.message);return}}this._unlisten=this._setup_peer();let i=yield this._peer.offer();this._offered=!0,this._output.offer.push(i)})}onRefInputData(t,e){e.mediaStream(i=>{i===null?(this._stream&&this._remove_stream(this._stream),this._stream=null):(this._stream&&this._remove_stream(this._stream),this._add_stream(i),this._stream=i)})}onDataInputData(t,e){return b(this,null,function*(){if(this.hasErr()&&(this._backwarding=!0,this.takeErr(),this._backwarding=!1),t==="answer"){let i=e;if(this._offered)try{yield this._peer.acceptAnswer(i)}catch(o){this.err(o.message);return}else this._flag_err_answer_without_offer=!0,this.err("cannot answer without offer")}else t==="close"&&(this._disconnect(),this._output.offer.pull(),this._output.channel.pull(),this._done({}),this._input.close.pull())})}onDataInputDrop(t){t==="answer"&&(this._flag_err_answer_without_offer&&this.takeErr(),this._connected&&this._disconnect())}onDataOutputDrop(t){this._connected&&this._output_port()}onRefInputDrop(t){this._unlisten_stream&&(this._unlisten_stream(),this._unlisten_stream=void 0),this._stream&&(this._stream=null,this._peer&&this._remove_stream(this._stream))}_send_data(t){return b(this,null,function*(){return this._send({type:"data",data:t})})}_send(t){return b(this,null,function*(){let e=Y(t);this._peer.send(e)})}send(t){return b(this,null,function*(){return this._send_data(t)})}};var is=class extends D{constructor(t){super({fi:["element","pointerId"],fo:[],i:["done"],o:[]},{input:{element:{ref:!0}}},t,kg);this._capturing=!1;this._element=null;this._release=()=>{if(this._capturing){let t=this._pointerId;this._done(),this._input.done.pull(),this._element.emit("call",{method:"releasePointerCapture",data:[t]}),this._capturing=!1,this._pointerId=void 0,this._element=null}}}f({element:t,pointerId:e}){this._capturing||(this._release(),this._capturing=!0,this._pointerId=e,this._element=t,t.emit("call",{method:"setPointerCapture",data:[e]}))}onIterDataInputData(t,e){this._release()}};var rs=class extends l{constructor(n){super({i:["component","any"],o:[]},{input:{component:{ref:!0}}},n,$g)}f(e,i){return b(this,arguments,function*({component:n},t){n.emit("call",{method:"hidePopover",data:[]}),t()})}};var os=class extends l{constructor(n){super({i:["component","any"],o:[]},{input:{component:{ref:!0}}},n,Ng)}f(e,i){return b(this,arguments,function*({component:n},t){n.emit("call",{method:"showPopover",data:[]}),t()})}};var as=class extends l{constructor(n){super({i:["component","any"],o:[]},{input:{component:{ref:!0}}},n,Fg)}f(e,i){return b(this,arguments,function*({component:n},t){n.emit("call",{method:"togglePopover",data:[]}),t()})}};var ss=class extends l{constructor(n){super({i:["component","opt"],o:[]},{input:{component:{ref:!0}}},n,Bg)}f(i,o){return b(this,arguments,function*({component:n,opt:t},e){n.emit("call",{method:"scrollIntoView",data:[t]}),e()})}};var ps=class extends l{constructor(n){super({i:["channel","data"],o:[]},{input:{channel:{ref:!0}}},n,jg)}f(i,o){return b(this,arguments,function*({channel:n,data:t},e){try{let a=t;a instanceof C&&(a=yield a.raw()),yield n.send(a)}catch(a){e(void 0,a.message);return}e()})}};var us=class extends l{constructor(n){super({i:["data"],o:[]},{input:{}},n,Hg)}f(e,i){return b(this,arguments,function*({data:n},t){let{api:{navigator:{share:o}}}=this.__system;try{yield o(n)}catch(a){t(void 0,a.message);return}t()})}};var gd=class extends mt{constructor(t,e){super();this._recording=!1;let{api:{speech:{SpeechGrammarList:i,SpeechRecognition:o}}}=t;if(o&&i){let{grammars:a,lang:s="en-US",continuous:p=!1,interimResults:d=!1,maxAlternatives:c=1}=e,m;try{m=o({grammars:void 0,lang:s,interimResults:d,maxAlternatives:c,continuous:p})}catch(f){throw f}this._unlisten=tt([m.addListener("error",f=>{}),m.addListener("end",()=>{this._recording?m.start():this.emit("end")}),m.addListener("result",f=>{let h=f[0][0],{transcript:x,confidence:y}=h;this.emit("transcript",x)})]),this._recognition=m}}start(){this._recognition&&(this._recording||(this._recording=!0,this._recognition.start()))}stop(){if(this._recognition&&this._recording){this._recording=!1;try{this._recognition.stop()}catch(t){}}}};var cs=class extends D{constructor(t){super({fi:["opt"],fo:[],i:["stop"],o:["text"]},{},t,Vg);this._recorder=null}f({opt:t},e){let i=new gd(this.__system,t);this._recorder=i,this._recorder.start(),this._recorder.addListener("transcript",o=>{this._output.text.push(o)}),this._recorder.addListener("err",o=>{e(void 0,o)}),this._recorder.addListener("end",()=>{this._recorder=null,e()})}onIterDataInputData(t,e){this._recorder.stop()}};var ds=class extends l{constructor(n){super({i:["message","voice"],o:[]},{},n,zg)}f({message:n,voice:t},e){let{api:{speech:{SpeechSynthesis:i,SpeechSynthesisUtterance:o}}}=this.__system;if(n===""){e();return}let a;try{a=i({})}catch(c){e(void 0,c.message);return}let s=[],p=()=>{s=a.getVoices(),s.length>0?d():setTimeout(()=>{p()},100)},d=()=>{if(t<0||t>s.length-1){e(void 0,"voice index out of range");return}let c=s[t],m=o({text:n,voice:c});m.addEventListener("error",f=>{e(void 0,f.error)}),m.addEventListener("end",()=>{e()}),a.speak(m)};p()}};var ms=class extends yt{constructor(t){super({i:[],o:[]},{},t,Wg);this.___emitter=new mt;this._checkAPI=()=>{if(!localStorage)throw new V("Local Storage")}}subscribe(t,e,i){let{emitter:o}=this.__system;if(t.length>0)throw new Error("local storage path length must be 0");let a=(d,c)=>{(e==="*"||d===e)&&i("set",t,d,c)},s=d=>{i("delete",t,e,d)};return o.addListener("set",a),o.addListener("delete",s),()=>{o.removeListener("set",a),o.removeListener("delete",s)}}read(){return b(this,null,function*(){return jc()})}write(t){return b(this,null,function*(){})}get(t){return b(this,null,function*(){this._checkAPI();let e=localStorage.getItem(t);if(e===null)throw new Error("item not found");return e})}set(t,e){return b(this,null,function*(){let{emitter:i}=this.__system;this._checkAPI(),localStorage.setItem(t,e),i.emit("set",t,e)})}delete(t){return b(this,null,function*(){let{emitter:e}=this.__system;this._checkAPI();let i=localStorage.getItem(t);localStorage.removeItem(t),e.emit("delete",t,i)})}deepSet(t,e){return b(this,null,function*(){throw new O})}deepGet(t){return b(this,null,function*(){throw new O})}deepDelete(t){return b(this,null,function*(){throw new O})}keys(){return b(this,null,function*(){return Be(localStorage)})}hasKey(t){return b(this,null,function*(){return an(localStorage,t)})}};var fs=class extends Q{constructor(t){super({i:[],o:[]},{},t,Kg);this._checkAPI=()=>{if(!sessionStorage)throw new Error("session Storage API not implemented")}}read(){return b(this,null,function*(){return this._checkAPI(),r0()})}write(t){return b(this,null,function*(){throw this._checkAPI(),new O})}get(t){return b(this,null,function*(){this._checkAPI();let e=sessionStorage.getItem(t);if(e===null)throw new Error("item not found");return e})}set(t,e){return b(this,null,function*(){this._checkAPI(),localStorage.setItem(t,e)})}delete(t){return b(this,null,function*(){this._checkAPI(),sessionStorage.removeItem(t)})}deepSet(t,e){throw new O}deepGet(t){throw new O}deepDelete(t){throw new O}subscribe(t,e,i){throw new O}keys(){return b(this,null,function*(){return Be(sessionStorage)})}hasKey(t){return b(this,null,function*(){return an(sessionStorage,t)})}};var ls=class extends l{constructor(n){super({i:["hash"],o:["value"]},{},n,qg)}f({hash:n},t){t()}};var bs=class extends l{constructor(n){super({i:["any"],o:["key"]},{},n,Yg)}f({any:n},t){t()}};var gs=class extends l{constructor(n){super({i:["value"],o:["hash"]},{},n,Zc)}f({value:n},t){t()}};var hs=class extends l{constructor(n){super({i:["unit","data"],o:[]},{input:{unit:{ref:!0},data:{ref:!0}}},n,Jg)}f(i,o){return b(this,arguments,function*({unit:n,data:t},e){try{yield n.send(t)}catch(a){e(void 0,a.message);return}e()})}};var ys=class extends l{constructor(n){super({i:["blob","init"],o:["url"]},{input:{blob:{ref:!0}}},n,Xg)}f(i,o){return b(this,arguments,function*({blob:n,init:t},e){let{api:{url:{createObjectURL:a}}}=this.__system,s,p=yield n.blob();try{s=yield a(p)}catch(d){e(void 0,d.message);return}e({url:s})})}};var _s=class extends l{constructor(n){super({i:["uri"],o:["UTF-8"]},{},n,Zg)}f({uri:n},t){let{api:{uri:{encodeURI:e}}}=this.__system,i;try{i=e(n)}catch(o){t(void 0,o.message);return}t({"UTF-8":i})}};var xs=class extends l{constructor(n){super({i:["text"],o:["uri"]},{},n,Qg)}f({text:n},t){let{api:{uri:{encodeURIComponent:e}}}=this.__system,i;try{i=e(n)}catch(o){t(void 0,o.message);return}t({uri:i})}};var Is=class extends l{constructor(n){super({i:["url"],o:["obj"]},{},n,t4)}f(e,i){return b(this,arguments,function*({url:n},t){let{api:{}}=this.__system,o;try{let a=new URL(n);o={protocol:a.protocol,hostname:a.hostname,pathname:a.pathname,search:a.search,hash:a.hash,host:a.host,href:a.href,origin:a.origin,port:a.port}}catch(a){t(void 0,"invalid url");return}t({obj:o})})}};var vs=class extends l{constructor(n){super({i:["pattern"],o:[]},{},n,e4)}f({pattern:n},t){let{api:{device:{vibrate:e}}}=this.__system;try{e(n)}catch(i){t(void 0,i.message);return}t()}};var Ds=class extends D{constructor(t){super({fi:["lock"],fo:[],i:["done"],o:[]},{},t,n4);this._lock=t=>b(this,null,function*(){let{api:{screen:{requestWakeLock:e}}}=this.__system,i=yield e(t);i.addListener("done",this._on_release),this._wake_lock=i});this._release=()=>{this._wake_lock&&this._wake_lock.done()};this._on_release=()=>{this._wake_lock=null}}f({lock:t},e){this._lock({type:"screen"})}d(){this._release()}onIterDataInputData(t,e){this._release()}};var Ss=class extends D{constructor(t){super({fi:["url","target","features"],fo:["window"],i:["done"],o:[]},{output:{window:{ref:!0}}},t,od);this._release=()=>{this._window&&this._window.close()};this._on_release=()=>{this._window=null}}f({url:t,target:e,features:i},o){let{api:{window:{open:a}}}=this.__system,s=Object.entries(i).map(([c,m])=>`${c}=${m}`).join(","),p=a(t,e,s);this._window=p;let d=new class extends C{constructor(){super(...arguments);this.__=["CH"]}send(f){return b(this,null,function*(){let g=Y(f);p.postMessage(g,"*")})}}(this.__system);try{window.addEventListener("message",c=>{d.emit("message",c.data)})}catch(c){o(void 0,c.message);return}o({window:d})}d(){this._release()}onIterDataInputData(t,e){this._release()}};var Es=class extends D{constructor(n){super({fi:["window","target","data"],fo:[],i:[],o:[]},{output:{window:{ref:!0}}},n,od)}f({window:n,target:t,data:e},i){let{api:{window:{open:o}}}=this.__system;i({})}};var _y=JSON.parse(`{
|
|
1
|
+
"use strict";(()=>{var U8=Object.defineProperty,w8=Object.defineProperties;var L8=Object.getOwnPropertyDescriptors;var Ru=Object.getOwnPropertySymbols;var Cf=Object.prototype.hasOwnProperty,Mf=Object.prototype.propertyIsEnumerable;var Af=(r,n,t)=>n in r?U8(r,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[n]=t,_=(r,n)=>{for(var t in n||={})Cf.call(n,t)&&Af(r,t,n[t]);if(Ru)for(var t of Ru(n))Mf.call(n,t)&&Af(r,t,n[t]);return r},Z=(r,n)=>w8(r,L8(n));var Pf=r=>typeof r=="symbol"?r:r+"",bt=(r,n)=>{var t={};for(var e in r)Cf.call(r,e)&&n.indexOf(e)<0&&(t[e]=r[e]);if(r!=null&&Ru)for(var e of Ru(r))n.indexOf(e)<0&&Mf.call(r,e)&&(t[e]=r[e]);return t};var b=(r,n,t)=>new Promise((e,i)=>{var o=p=>{try{s(t.next(p))}catch(d){i(d)}},a=p=>{try{s(t.throw(p))}catch(d){i(d)}},s=p=>p.done?e(p.value):Promise.resolve(p.value).then(o,a);s((t=t.apply(r,n)).next())});var gn=class extends Error{constructor(){super("listener not found")}};function $d({obj:r={}}){return{keys:Object.keys(r)}}function et(r){return Object.keys(r)}var mt=class{constructor(){this.__listeners={};this._removeListener=(n,t)=>{let e=this.__listeners[n];if(!e)throw new gn;let i=e.indexOf(t);if(i<0)throw new gn;e.splice(i,1),e.length===0&&(delete this.__listeners[n],this.emit("unlisten",{event:n}))}}prependListener(n,t){return this.__listeners[n]=this.__listeners[n]||[],this.__listeners[n].unshift(t),this.emit("listen",{event:n}),()=>{this._removeListener(n,t)}}removeListener(n,t){this._removeListener(n,t)}addListener(n,t){return this.__listeners[n]=this.__listeners[n]||[],this.__listeners[n].push(t),this.emit("listen",{event:n}),()=>{this._removeListener(n,t)}}eventNames(){return et(this.__listeners)}listenerCount(n){return(this.__listeners[n]||[]).length}emit(n,...t){let e=this.__listeners[n];if(e){for(let i of e)i.call(this,...t);this.emit("emit",{event:n})}}};function gt(){}function Tt(r,n){r.forEach(n)}function kt(r,n){r.splice(n,1)}function $t(r,n){let t=r.indexOf(n);kt(r,t)}function Ye(r,n){let t=r.indexOf(n);kt(r,t)}function jt(r,n){r.push(n)}function It(r,n,t){return r.splice(t,0,n),r}function Nd(r,...n){return r.unshift(...n)}function G8(r){return r.length-1}function ku(r,n=0){let t=G8(r);return r[t+n]}function Of(r){let n=r.length,t=r[n-1],e=r.slice(0,n-1);return[t,e]}var Ie=class{constructor(n){this._node={emitter:new mt,children:{}};this._dispatch=(n,t,e,i)=>{this._rec_dispatch(t,this._node,n,t,e,i)};this._rec_dispatch=(n,t,e,i,o,a)=>{if(n.length===0)this._end_dispatch(t,e,i,o,a);else{let[s,...p]=n,d=t.children[s];d&&this._rec_dispatch(p,d,e,i,o,a);let c=t.children["*"];c&&this._rec_dispatch(p,c,e,i,o,a)}};this._end_dispatch=(n,t,e,i,o)=>{let{emitter:a}=n;a&&(a.emit(i,t,e,i,o),a.emit("*",t,e,i,o))};this._ensure_emitter=n=>{let t=this._node;for(let e of n)t.children[e]||(t.children[e]={emitter:new mt,children:{}}),t=t.children[e];return t.emitter};this._remove_node=n=>{if(n.length>0){let[t,e]=Of(n),i=this._node_at_path(e);delete i.children[t]}};this._node_at_path=n=>{let t=this._node;for(let e of n)if(t=t.children[e],!t)return null;return t};this._set_path=(n,t)=>{let e=n.slice(0,-1),i=ku(n),o=this._obj_at_path(e);o[i]=t,this._dispatch("set",e,i,t)};this._delete=n=>b(this,null,function*(){this._delete_path([n])});this._delete_path=n=>{let t=n.slice(0,-1),e=ku(n),i=this._obj_at_path(t),o=i[e];delete i[e],this._dispatch("delete",t,e,o)};this._obj=n}_obj_at_path(n){let t=this._obj;for(let e of n)t=t[e];return t}read(){return b(this,null,function*(){return this._obj})}write(n){this._obj=n}get(n){return b(this,null,function*(){if(this._obj[n]===void 0)throw new Error("key value not found");return this._obj[n]})}set(n,t){return b(this,null,function*(){this._set_path([n],t)})}hasKey(n){return b(this,null,function*(){return this._obj[n]!==void 0})}delete(n){return b(this,null,function*(){return this._delete(n)})}deepGet(n){return b(this,null,function*(){return this._obj_at_path(n)})}deepSet(n,t){return b(this,null,function*(){this._set_path(n,t)})}deepDelete(n){return b(this,null,function*(){this._delete_path(n)})}keys(){return b(this,null,function*(){return et(this._obj)})}subscribe(n,t,e){let i=this._ensure_emitter(n);return i.addListener(t,e),()=>{i.removeListener(t,e),i.eventNames().length===0&&this._remove_node(n)}}};var Fd="untitled",pe="call",Uf="callback";var Ue="watch",$u="unwatch",we="ref",Nu="ref_exec";var Zt="init",Qt="terminate",Fu="connect",Bu="disconnect",Ot="exec";var Je=r=>typeof r=="object"&&r!==null;function Ht(r,n){let t=Array.isArray(r)?[...r]:_({},r);return R8(t,n),t}function R8(r,n){for(let t in n)if(r[t]!==void 0&&n[t]!==void 0){let e=Je(r[t]),i=Je(n[t]);e&&i?r[t]=Ht(r[t],n[t]):r[t]=n[t]}else r[t]=n[t]}var wf=(r={})=>Ht({type:"`U`&`G`",name:Fd,units:{},merges:{},inputs:{},outputs:{},metadata:{icon:null,description:""}},r);function Bd({a:r}){return{length:jd(r)}}function jd(r){return r.length}function ue(r){let n=et(r);return jd(n)}function ju(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,9)}function Xe(r){let n;do n=ju();while(r[n]);return n}function Hu(r){let n;do n=ju();while(r.has(n));return n}function Le(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let n=Math.random()*16|0;return(r=="x"?n:n&3|8).toString(16)})}function Ze(r){let n;do n=Le();while(r[n]);return n}function Hd(r,n){for(let t in r)n(r[t],t)}function Nt(r,n){for(let t in r)n(t,r[t])}function vt(r,n){let t={};for(let e in r)t[e]=n(r[e],e);return t}function Vu(r,n){let t={};for(let e in r)t[e]=n(e,r[e]);return t}function Lf(r,n){return k8(r,n)}function k8(r,n){let t=[];for(let i in r){let o=r[i],a=n(o,i);t.push([a,o])}return $8(t)}function hn(r,n){for(let t in r)if(n(r[t],t))return!0;return!1}function Vd(r,n,t){let e=t;for(let i in r)e=n(e,r[i],i);return e}function ce(r,n){let t={};for(let e in r)n(r[e],e)&&(t[e]=r[e]);return t}function Ft(r){return et(r).length===0}var at=r=>et(r)[0];function j(r){if(typeof r!="object"||r===null)return r;if(r instanceof Set)return new Set(j([...r]));let n=Array.isArray(r)?[]:{};for(let t in r)n[t]=j(r[t]);return n}function zu(r){return et(r).length}function de(r,n,t){r[n]=t}function me(r,n){return r[n]}function F(r,n,t){let e=r,i=n.length-1;if(i>=0){let o=n[i];for(let a=0;a<i;a++){let s=n[a];e[s]===void 0&&(e[s]={}),e=e[s]}e[o]=t}}function Vt(r,n){let t=r,e=n.length-1;if(e>=0){let i=n[e];for(let o=0;o<e;o++){let a=n[o];if(t[a]===void 0)return;t=t[a]}delete t[i]}}function fe(r,n){if(n.length===1){delete r[n[0]];return}let[t,...e]=n,i=r[t];fe(i,e),Ft(i)&&delete r[t]}function Wu(r,n,t){F(r,n,Ht(W(r,n,{}),t))}function W(r,n,t){let e=r;for(let i=0;i<n.length;i++){let o=n[i];if(e[o]===void 0)return t;e=e[o]}return e}function Gf(r,n){let i=r,{[n]:t}=i;return bt(i,[Pf(n)])}function $8(r){return Object.fromEntries(r)}function Rf(r,n){return r[n]!==void 0}function ht(r,n){return r[n]}function ve(r={}){return j(_(_({},wf()),r))}function Ge(r){return Ze(r)}function yn(r,n){if(n.startsWith("_"))return!0;let t=ht(r,n),{system:e}=t;return e}function F8(r){let{render:n}=r;return n}function kf(r){var n;return(n=F8(r))!=null?n:B8(r)}function B8(r){let{component:n={}}=r,{subComponents:t={}}=n;return ue(t)>0}var Ku=class{constructor(n){this.specsCount={};this.specs=n,this.specs_=new Ie(n)}newSpecId(){return Ze(this.specs)}hasSpec(n){return!!this.specs[n]}emptySpec(){let n=Ge(this.specs),t=ve({id:n});return this.newSpec(t),t}newSpec(n,t){return t=t!=null?t:Ge(this.specs),n.id=t,this.specs_.set(t,n),n}getSpec(n){return this.specs[n]}setSpec(n,t){this.specs_.set(n,t)}injectSpecs(n){let t={},e=new Set,i=(o,a)=>{if(e.has(o)||t[o])return;let s=o,p=!1;for(;this.hasSpec(s);)s=this.newSpecId(),p=!0;e.add(o);let{units:d}=a;for(let c in d){let m=d[c];if(!this.hasSpec(m.id)){let f=n[m.id];i(m.id,f)}}p?JSON.stringify(a)===JSON.stringify(this.getSpec(o))||(t[o]=s,this.specs_.set(o,a)):this.specs_.set(o,a)};for(let o in n){let a=n[o];i(o,a)}return t}shouldFork(n){var t;return((t=this.specsCount[n])!=null?t:0)>1||yn(this.specs,n)}forkSpec(n,t){if(this.shouldFork(n.id)){let e=j(n);delete e.system;let{id:i}=this.newSpec(e,t);return[i,e]}else return[n.id,n]}registerUnit(n){this.specsCount[n]===void 0&&(this.specsCount[n]=0),this.specsCount[n]+=1}unregisterUnit(n){this.specsCount[n]&&(this.specsCount[n]-=1,this.specsCount[n]===0&&(delete this.specsCount[n],yn(this.specs,n)||this.deleteSpec(n)))}deleteSpec(n){this.specs_.delete(n)}};function $f(r){let n="";for(let t in r){let e=r[t];n+=`${t}`}return n}function Nf(r,n){let{root:t,api:{document:{createElement:e}}}=r,i=e("style");i.innerHTML=n,t.shadowRoot.appendChild(i)}function Ff(r,n){let{root:t}=r,e=Array.from(t.children).find(i=>i.tagName==="STYLE"&&e.innerHTML===n);if(!e)throw new Error("style not found");t.shadowRoot.removeChild(e)}function ut(r,n){let t={};return new Proxy(t,{get(e,i){var o,a;return(a=(o=t[i])!=null?o:n[i])!=null?a:r[i]},set(e,i,o){return t[i]=o,!0},has(e,i){return i in t||i in n||i in r},deleteProperty(e,i){return t[i]!==void 0?(delete t[i],!0):n[i]!==void 0?(delete n[i],!0):r[i]!==void 0?(delete r[i],!0):!1},ownKeys(){return[...new Set([...Object.getOwnPropertyNames(r),...Object.getOwnPropertyNames(n),...Object.getOwnPropertyNames(t)])]},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0,writable:!0}}})}function Bf(r,n){let{global:{ref:t}}=r;return t[n]||null}function jf(r,n){let{global:{ref:t}}=r,e=Xe(t);return t[e]=n,e}function Hf(r,n){let{global:{ref:t}}=r;delete t[n]}var C=class extends mt{constructor(t){super();this.__=[];this.__async=!1;this.__ref_count=0;this.__system=t,this.register()}getGlobalId(){return this.__global_id}getInterface(){return this.__}refSystem(){return this.__system}register(){this.__ref_count++,this.__ref_count===1&&(this.__global_id=jf(this.__system,this)),this.emit("register")}unregister(){this.__ref_count--,this.__ref_count===0&&this.emit("unregister")}destroy(){Hf(this.__system,this.__global_id),this.emit("destroy")}raw(){throw new Error("object doens't have raw form")}};var j8=new Set(["null","string","number","boolean"]);function De(r){let n=typeof r;if(j8.has(n))return!0;if(n==="object"){if(Array.isArray(r)){for(let t of r)if(!De(t))return!1}for(let t in r){let e=r[t];if(!De(e))return!1}return!0}return!!(n==="function"&&r.__bundle)}var Ut=class extends mt{constructor({data:t,constant:e,ignored:i,ref:o}={}){super();this._constant=!1;this._ignored=!1;this._ref=!1;this._invalid=!1;this._idle=!0;this._register=void 0;t!==void 0&&(this._idle=!1),this._register=t,this._constant=e||!1,this._ignored=i||!1,this._ref=o||!1}take(){let t=this._register;return this._register!==void 0&&(this._register=void 0,this.emit("drop",t)),this.end(),t}invalidate(){this._register!==void 0&&!this._invalid&&(this._invalid=!0,this._idle=!0,this.emit("invalid"))}start(){this._idle&&(this._idle=!1,this.emit("start"))}end(){this._register===void 0&&!this._idle&&(this._idle=!0,this.emit("end"))}pull(){let t=this._register;return t!==void 0&&(this._constant?this.emit("_data",t):this.take()),t}push(t){this.invalidate(),this._invalid=!1,this.start(),this._register=t,this.emit("data",t),this._ref||this._ignored&&!this._constant&&this.take()}peak(){return this._register}empty(){return this._register===void 0}active(){return!this.empty()}ignored(t){return t!==void 0&&(this._ignored=t,this._ignored&&!this._constant&&!this._ref&&this.take(),this.emit("ignored",this._ignored)),this._ignored}ref(t){return t!==void 0&&(this._ref=t,this.emit("ref",this._ref)),this._ref}constant(t){return t!==void 0&&(this._constant=t),this._constant}invalid(){return this._invalid}snapshot(){return{_register:De(this._register)?this._register:void 0,_invalid:this._invalid,_constant:this._constant,_ignored:this._ignored,_idle:this._idle}}restore(t){let{_register:e,_invalid:i,_constant:o,_ignored:a,_idle:s}=t;this._register=e,this._invalid=i,this._constant=o,this._ignored=a,this._idle=s}read(){return b(this,null,function*(){if(this._register===void 0)throw new Error("empty");return this._register})}write(t){return b(this,null,function*(){this.push(t)})}};function qu(r,n,t){let e={};for(let i in r){let o=r[i];o!==void 0&&(e[i]=st(o,n,t))}return e}function Yu(r,n,t){for(let e in r.input){let i=r.input[e];r.input[e]=qu(i,n,t)}for(let e in r.output){let i=r.output[e];r.output[e]=qu(i,n,t)}r.memory=qu(r.memory,n,t)}function Vf(r,n,t){let e=j(r);return Yu(e,n,t),e}var zd={};function zt(r,n){let{unit:{id:t,memory:e}}=n,i=`${t}/${JSON.stringify(e)}`;if(zd[i])return zd[i];class o extends r{constructor(s){if(n.specs&&s.injectSpecs(n.specs),super(s,t),e){let p=Vf(e,s.specs,s.classes);this.restore(p)}}}return o.__bundle=n,zd[i]=o,o}var lt="_self";var Ju=class extends Error{constructor(n){super(`input with name "${n}" already exists`)}};var Xu=class extends Error{constructor(n){super(`output with name "${n}" already exists`)}};var Re=class extends Error{constructor(n){super(`input named "${n}" not found`)}};var _n=class extends Error{};var xn=class extends Error{constructor(n){super(`output named "${n}" not found`)}};function Wd(r){let n="";for(let t=0;t<r.length;t++){let e=r[t];e==='"'?n+='\\"':n+=e}return n}function Zu(r){return`unit://${r}`}function Y(r){switch(typeof r){case"string":return`"${Wd(r)}"`;case"number":case"boolean":return`${r}`;case"object":return r===null?"null":Array.isArray(r)?`[${r.map(Y).join(",")}]`:r.constructor.name==="Object"?`{${Object.entries(r).filter(([t,e])=>e!==void 0).map(([t,e])=>`${`"${Wd(t)}"`}:${Y(e)}`).join(",")}}`:Zu(r.__global_id);case"function":return r.__bundle?`$${Y(r.__bundle)}`:"null";default:throw new Error("cannot stringify value")}}function In(r){let{input:n,output:t}=r,e=Se(n),i=Se(t);return{input:e,output:i}}function Se(r){let n={};for(let t in r){let e=r[t];e!==void 0&&(e instanceof C?n[t]="null":n[t]=Y(e))}return n}function zf(r){let{spec:n}=r;Kd(n)}function Wf(r){Kf(r.unit)}function Kd(r){for(let n in r.units)Kf(r.units[n])}function Kf(r){let{memory:n}=r;n&&ke(n)}function ke(r){for(let n in r.input){let t=r.input[n];r.input[n]=Se(t)}for(let n in r.output){let t=r.output[n];r.output[n]=Se(t)}r.memory=Se(r.memory)}function A(r,n){for(let t in r){let e=r[t];n(e,t)}}var qf=(r,n)=>r.reduce((t,e)=>{var i;return Z(_({},t),{[e]:new Ut((i=n[e])!=null?i:{})})},{}),$e={ref:!1},yt=class extends C{constructor({i:t=[],o:e=[]},i={},o,a){var m,f;super(o);this.__=["U"];this._parent=null;this._input={};this._output={};this._data_input={};this._data_output={};this._ref_input={};this._ref_output={};this._i_opt={};this._o_opt={};this._i_name_set=new Set;this._o_name_set=new Set;this._d_i_name=new Set;this._d_o_name=new Set;this._r_i_name=new Set;this._r_o_name=new Set;this._o_count=0;this._i_count=0;this._d_i_count=0;this._d_o_count=0;this._r_i_count=0;this._r_o_count=0;this._err=null;this.ref=null;this._paused=!0;this._memRemoveDataInput=t=>{this._d_i_count--,this._d_i_name.delete(t),delete this._data_input[t]};this._memRemoveRefInput=t=>{this._r_i_count--,this._r_i_name.delete(t),delete this._ref_input[t]};this._memAddRefOutput=(t,e)=>{this._r_o_count++,this._r_o_name.add(t),this._memSetRefOutput(t,e)};this._memSetRefOutput=(t,e)=>{this._ref_output[t]=e};this._memAddDataOutput=(t,e)=>{this._d_o_count++,this._d_o_name.add(t),this._memSetDataOutput(t,e)};this._memSetDataOutput=(t,e)=>{this._data_output[t]=e};this._memRemoveRefPin=(t,e)=>{t==="input"?this._memRemoveRefInput(e):this._memRemoveRefOutput(e)};this._memRemoveRefOutput=t=>{this._r_o_count--,this._r_o_name.delete(t),delete this._ref_output[t]};this._memRemoveDataOutput=t=>{this._d_o_count--,this._d_o_name.delete(t),delete this._data_output[t]};this._catcherCallback=[];this._catcherDoneCount=0;this._catcherDone=[];this._catchErr=!1;this._caughtErr=null;let{input:s,output:p}=i,d=qf(t,(m=i.input)!=null?m:{}),c=qf(e,(f=i.output)!=null?f:{});this.setInputs(d,s),this.setOutputs(c,p),this._selfInput=new Ut({data:this,constant:!1,ref:!0}),this._selfOutput=new Ut({data:this,constant:!1,ref:!0}),this._selfOutput.addListener("drop",()=>{throw new Error("self output cannot be dropped")}),this.id=a,o.registerUnit(a)}isElement(){return!1}isPinIgnored(t,e){return this.getPin(t,e).ignored()}isPinConstant(t,e){return this.getPin(t,e).constant()}isPinRef(t,e){let i=t==="input";return!i&&e===lt?!0:i&&!!this._ref_input[e]||!i&&!!this._ref_output[e]}setParent(t){this._parent=t,this.emit("parent",this._parent)}setPinIgnored(t,e,i){t==="input"?this.setInputIgnored(e,i):this.setOutputIgnored(e,i)}setPinConstant(t,e,i){this.getPin(t,e).constant(i),this.emit("set_pin_constant",t,e,i)}_memSetPinOptData(t,e){t==="input"?this._memSetInputData(e):this._memSetOutputData(e)}_memSetInputData(t){let e=this._input[t];this._memRemoveRefInput(t),this._memAddDataInput(t,e)}_memSetOutputData(t){let e=this._output[t];this._memRemoveRefOutput(t),this._memAddDataOutput(t,e)}_memSetPinRef(t,e){t==="input"?this._memSetInputRef(e):this._memSetOutputRef(e)}_memSetInputRef(t){let e=this._input[t];this._memRemoveDataInput(t),this._memAddRefInput(t,e)}_memSetOutputRef(t){let e=this._output[t];this._memRemoveDataOutput(t),this._memAddRefOutput(t,e)}setPinRef(t,e,i){if(i){if(this.hasRefPinNamed(t,e))return;this._memSetPinRef(t,e)}else{if(this.hasPinNamed(t,e))return;this._memSetPinOptData(t,e)}}setInputRef(t,e){this.setPinRef("input",t,e)}setOutputRef(t,e){this.setPinRef("output",t,e)}setInputIgnored(t,e){let i=this.getInput(t);if(!this.hasRefInputNamed(t))return i.ignored(e)}setOutputIgnored(t,e){return this.getOutput(t).ignored(e)}setInputs(t,e={}){for(let i in t){let o=t[i],a=e[i];this.setInput(i,o,a)}}setPin(t,e,i,o=$e,a=!0){t==="input"?this.setInput(e,i,o,a):this.setOutput(e,i,o,a)}setInput(t,e,i=$e,o=!0){this._setInput(t,e,i),this.emit("set_input",t,e,i,o)}_setInput(t,e,i=$e){this.hasInputNamed(t)&&this.removeInput(t),this._i_count++,this._i_name_set.add(t),this._input[t]=e,this._i_opt[t]=i;let{ref:o}=i;o?this._memAddRefInput(t,e):this._memAddDataInput(t,e)}_memAddDataInput(t,e){this._d_i_count++,this._d_i_name.add(t),this._data_input[t]=e}_memAddRefInput(t,e){this._r_i_count++,this._r_i_name.add(t),this._ref_input[t]=e}_validateInputName(t){if(typeof t=="string"){if(!this.hasInputNamed(t))throw new Re(t)}else throw new _n("name should be a string")}_validateOutputName(t){if(typeof t=="string"){if(!this.hasOutputNamed(t))throw new xn(t)}else throw new _n("name should be a string")}addPin(t,e,i,o){t==="input"?this.addInput(e,i,o):this.addOutput(e,i,o)}addInput(t,e,i=$e){if(this.hasInputNamed(t))throw new Ju(t);this.setInput(t,e,i)}removeInput(t){if(!this.hasInputNamed(t))throw new Re(t);let e=this._input[t];this.emit("before_remove_input",t,e),this._i_count--,this._i_name_set.delete(t),delete this._input[t];let i=this._i_opt[t],{ref:o}=i;o?this._memRemoveRefInput(t):this._memRemoveDataInput(t),this.emit("remove_input",t,e)}setOutputs(t,e={}){for(let i in t){let o=t[i],a=e[i];this.setOutput(i,o,a)}}setOutput(t,e,i=$e,o=!0){this._setOutput(t,e,i),this.emit("set_output",t,e,i,o)}_setOutput(t,e,i=$e){this.hasOutputNamed(t)&&this.removeOutput(t),t===lt&&(this._selfOutput=e),this._o_count++,this._o_name_set.add(t),this._o_opt[t]=i;let{ref:o}=i;o?this._memAddRefOutput(t,e):this._memAddDataOutput(t,e),this._output[t]=e}addOutput(t,e,i=$e){if(this.hasOutputNamed(t))throw new Xu(t);this.setOutput(t,e,i)}removeOutput(t){if(!this.hasOutputNamed(t))throw new xn(t);let e=this._output[t];this.emit("before_remove_output",t,e),this._o_count--,this._o_name_set.delete(t);let i=this._o_opt[t],{ref:o}=i;o?this._memRemoveRefOutput(t):this._memRemoveDataOutput(t),delete this._output[t],this.emit("remove_output",t,e)}removePin(t,e){t==="input"?this.removeInput(e):this.removeOutput(e)}getPin(t,e){return t==="input"?this.getInput(e):this.getOutput(e)}getInputs(){return this._input}getDataInputs(){return this._data_input}getRefInputs(){return this._ref_input}getInput(t){return t===lt?this._selfInput:(this._validateInputName(t),this._input[t])}getOutputs(){return this._output}getDataOutputs(){return this._data_output}getRefOutputs(){return this._ref_output}getOutput(t){return t===lt?this._selfOutput:(this._validateOutputName(t),this._output[t])}push(t,e){this.pushInput(t,e)}pushInput(t,e){this._validateInputName(t),this.getInput(t).push(e)}pushAllInput(t){A(t,(e,i)=>this.pushInput(i,e))}pushOutput(t,e){this.getOutput(t).push(e)}pushAllOutput(t){A(t,(e,i)=>this.pushOutput(i,e))}pushAll(t){this.pushAllInput(t)}pullInput(t){return this.getInput(t).pull()}pullOutput(t){return this.getOutput(t).pull()}pullPin(t,e){return t==="input"?this.pullInput(e):this.pullOutput(e)}takePin(t,e){return t==="input"?this.takeInput(e):this.takeOutput(e)}takeInput(t){return this._validateInputName(t),this.getInput(t).take()}takeOutput(t){return this.getOutput(t).take()}take(t){return this.takeOutput(t)}takeAll(){return vt(this._output,t=>t.take())}peakInput(t){return this.getInput(t).peak()}peakOutput(t){return this.getOutput(t).peak()}peak(t){return this.peakOutput(t)}peakAllOutput(){return vt(this._output,t=>t.peak())}peakAll(){return this.peakAllOutput()}hasPinNamed(t,e){return t==="input"?this.hasInputNamed(e):this.hasOutputNamed(e)}hasInputNamed(t){return this._input[t]!==void 0}hasOutputNamed(t){return this._output[t]!==void 0}hasDataPinNamed(t,e){return t==="input"?this.hasDataInputNamed(e):this.hasDataOutputNamed(e)}hasDataInputNamed(t){return this._d_i_name.has(t)}hasDataOutputNamed(t){return this._d_o_name.has(t)}hasRefPinNamed(t,e){return t==="input"?this.hasRefInputNamed(e):this.hasRefOutputNamed(e)}hasRefInputNamed(t){return this._r_i_name.has(t)}renamePin(t,e,i){t==="input"?this.renameInput(e,i):this.renameOutput(e,i)}renameInput(t,e,i=!0){if(!this.hasInputNamed(t))throw new Re(t);let o=this._input[t],a=this._i_opt[t];this._i_name_set.delete(t),this._i_name_set.add(e),delete this._input[t],delete this._i_opt[t],this._input[e]=o,this._i_opt[e]=a;let{ref:s}=a;s?(this._r_i_name.delete(t),this._r_i_name.add(e),delete this._ref_input[t],this._ref_input[e]=o):(this._d_i_name.delete(t),this._d_i_name.add(e),delete this._data_input[t],this._data_input[e]=o),this.emit("rename_input",t,e)}renameOutput(t,e,i=!0){if(!this.hasOutputNamed(t))throw new Re(t);let o=this._output[t],a=this._o_opt[t];this._o_name_set.delete(t),this._o_name_set.add(e),delete this._output[t],this._output[e]=o,delete this._o_opt[t],this._o_opt[e]=a;let{ref:s}=a;s?(this._r_o_name.delete(t),this._r_o_name.add(e),delete this._ref_output[t],this._ref_output[e]=o):(this._d_o_name.delete(t),this._d_o_name.add(e),delete this._data_output[t],this._data_output[e]=o),this.emit("rename_output",t,e)}getInputOpt(t){return this._i_opt[t]}getOutputOpt(t){return this._o_opt[t]}hasRefOutputNamed(t){return this._r_o_name.has(t)}getInputCount(){return this._i_count}getOutputCount(){return this._o_count}getInputNames(){return et(this._input)}getOutputNames(){return et(this._output)}setPinData(t,e,i){this.getPin(t,e).push(i)}removePinData(t,e){this.getPin(t,e).take()}setInputConstant(t,e){this.getInput(t).constant(e)}setOutputConstant(t,e){this.getOutput(t).constant(e)}getCatchErr(){return this._catchErr}caughtErr(){return this._caughtErr}catch(t){jt(this._catcherCallback,t),jt(this._catcherDone,!1),this._catchErr=!0;let e=this._err;e&&(this._err=null,this._caughtErr=e,this.emit("catch_err",e));let i=()=>{this._catcherDoneCount===this._catcherCallback.length&&o()},o=()=>{let p=this._caughtErr;this._caughtErr=null,this._catcherDoneCount=0,this._catcherDone.fill(!1),this.emit("take_caught_err",p)};return{unlisten:()=>{let p=this._catcherCallback.indexOf(t);if(p>-1){Ye(this._catcherCallback,t);let d=this._catcherDone[p];if(kt(this._catcherDone,p),this._catcherCallback.length===0){let c=this._caughtErr;this._catchErr=!1,c!==null&&(this._caughtErr=null,this.err(c),this.emit("take_caught_err",c))}d||i()}else throw new Error("unregistered Catcher cannot call unlisten")},done:()=>{if(this._caughtErr){let p=this._catcherCallback.indexOf(t);if(p>-1){if(this._catcherDone[p])throw new Error("catcher cannot be done twice");this._catcherDone[p]=!0,this._catcherDoneCount++,i()}else throw new Error("unregistered Catcher cannot call done")}else throw new Error("catcher cannot call done when there's no caught error")}}}getConfig(){return this._opt}reset(){this.takeErr(),this.emit("reset")}pause(){this._paused||(this._paused=!0,this.emit("pause"))}play(){this._paused&&(this._paused=!1,this.emit("play"))}paused(){return this._paused}getSelfPin(){return this._selfOutput}err(t){if(t)if(t instanceof Error&&(t=t.message),this._catchErr){this._caughtErr=t;for(let e of this._catcherCallback)e(t)}else this._err=t,this.emit("err",t);return this._err}hasErr(){return this._err!==null}getErr(){return this._err}takeErr(){let t=this._err;return t&&(this._err=null,this.emit("take_err",t)),t}takeCaughtErr(){let t=this._caughtErr;if(t){this._caughtErr=null;for(let e of this._catcherCallback)e(null);this.emit("take_caught_err",t)}return t}destroy(){this.__system.unregisterUnit(this.id),super.destroy()}getPinData(t,e){return this.getPin(t,e).peak()}getPinsData(){let t={input:{},output:{}};return A(this._input,(e,i)=>{t.input[i]=e.peak()}),A(this._output,(e,i)=>{t.output[i]=e.peak()}),t}getInputData(){let t={};return A(this._input,(e,i)=>{if(!e.empty()){let o=e.peak();t[i]=o}}),t}getRefInputData(){let t={};return A(this._ref_input,(e,i)=>{if(!e.empty()){let o=e.peak();t[i]=o}}),t}getSpec(){return this.__system.getSpec(this.id)}getUnitBundleSpec(t=!1){let e;t&&(e=this.snapshot(),ke(e));let i=vt(this._input,a=>{let s=a.ignored(),p=a.constant(),d=a.peak(),c=p&&d!==void 0?Y(d):void 0;return{ignored:s,constant:p,data:c}}),o=vt(this._output,a=>{let s=a.ignored(),p=a.constant();return{ignored:s,constant:p,data:void 0}});return{unit:{id:this.id,memory:e,input:i,output:o},specs:{}}}snapshotSelf(){}snapshotInput(t){return this.getInput(t).snapshot()}snapshotInputs(){let t={};for(let e of this._d_i_name)t[e]=this.snapshotInput(e);return t}snapshotOutput(t){return this.getOutput(t).snapshot()}snapshotOutputs(){let t={};for(let e of this._d_o_name)t[e]=this.snapshotOutput(e);return t}snapshot(){return{input:this.snapshotInputs(),output:this.snapshotOutputs(),memory:this.snapshotSelf()}}restoreSelf(t){}restoreInputs(t){for(let e in t){let i=t[e];this.restoreInput(e,i)}}restoreInput(t,e){this.getInput(t).restore(e)}restoreOutputs(t){for(let e in t){let i=t[e];this.restoreOutput(e,i)}}restoreOutput(t,e){this.getOutput(t).restore(e)}restore(t){let{input:e,output:i,memory:o}=t;this.restoreInputs(e),this.restoreOutputs(i),this.restoreSelf(o!=null?o:{})}};var Q=class extends yt{constructor({i:t,o:e}={},i={},o,a){super({i:t,o:e},i,o,a);this._i={};this._o={};this._active_i_count=0;this._active_o_count=0;this._i_start_count=0;this._i_start={};this._o_invalid_count=0;this._o_invalid={};this._i_invalid_count=0;this._i_invalid={};this._forwarding=!1;this._backwarding=!1;this._forwarding_empty=!1;this._inputUnlisten={};this._outputUnlisten={};this.__buffer=[];this._setupInputs=t=>{for(let e in t){let i=t[e],o=this.getInputOpt(e);this._setupInput(e,i,o)}};this._setupDataInput=(t,e)=>{let i=this._onDataInputData.bind(this,t),o=this._onDataInputDrop.bind(this,t),a=this._onDataInputInvalid.bind(this,t),s=this._onInputStart.bind(this,t),p=this._onInputEnd.bind(this,t);e.addListener("_data",i),e.addListener("data",i),e.addListener("start",s),e.addListener("invalid",a),e.prependListener("drop",o),e.prependListener("end",p);let d=()=>{e.removeListener("data",i),e.removeListener("start",s),e.removeListener("invalid",a),e.removeListener("drop",o),e.removeListener("end",p)};this._inputUnlisten[t]=d};this._setupRefInput=(t,e)=>{let i=this._onRefInputData.bind(this,t),o=this._onRefInputDrop.bind(this,t),a=this._onRefInputInvalid.bind(this,t);e.addListener("data",i),e.addListener("invalid",a),e.prependListener("drop",o);let s=()=>{e.removeListener("data",i),e.removeListener("invalid",a),e.removeListener("drop",o)};this._inputUnlisten[t]=s};this._setupInput=(t,e,i)=>{let{ref:o}=i;o?this._setupRefInput(t,e):this._setupDataInput(t,e)};this._setupOutputs=t=>{for(let e in t){let i=t[e],o=this.getOutputOpt(e);this._setupOutput(e,i,o)}};this.__setupOutput=(t,e)=>{let i=this._onDataOutputData.bind(this,t),o=this._onDataOutputDrop.bind(this,t),a=this._onOutputInvalid.bind(this,t);e.addListener("drop",o),e.prependListener("data",i),e.prependListener("invalid",a);let s=()=>{e.removeListener("data",i),e.removeListener("drop",o),e.removeListener("invalid",a)};this._outputUnlisten[t]=s};this._setupDataOutput=(t,e)=>{if(this.__setupOutput(t,e),e.active()){let i=e.peak();this._onDataOutputData(t,i)}};this._setupRefOutput=(t,e)=>{if(this.__setupOutput(t,e),e.active()){let i=e.peak();this._onRefOutputData(t,i)}};this._setupOutput=(t,e,i)=>{let{ref:o}=i;o?this._setupRefOutput(t,e):this._setupDataOutput(t,e)};this._onDataInputData=(t,e)=>{this._activateInput(t,e),this._paused?this.__buffer.push({name:t,type:"input",event:"data",data:e,ref:!1}):this.onDataInputData(t,e)};this._input_effemeral={};this._onRefInputData=(t,e)=>{this._activateInput(t,e),this._paused?this.__buffer.push({name:t,type:"input",event:"data",data:e,ref:!0}):this.__onRefInputData(t,e)};this.__onRefInputData=(t,e)=>{e instanceof Function&&(e=new e(this.__system),this._input_effemeral[t]=e,this._i[t]=e),e instanceof C&&e.register(),this.onRefInputData(t,e)};this._activateInput=(t,e)=>{this._i[t]===void 0&&this._active_i_count++,this._i[t]=e,this._i_invalid[t]&&(delete this._i_invalid[t],this._i_invalid_count--)};this._deactivateInput=t=>{this._i[t]!==void 0&&(delete this._i[t],this._active_i_count--),this._i_invalid[t]&&(delete this._i_invalid[t],this._i_invalid_count--),this._i_start[t]&&(delete this._i_start[t],this._i_start_count--)};this._onDataInputDrop=(t,e)=>{this._deactivateInput(t),this._paused?this.__buffer.push({name:t,type:"input",event:"drop",ref:!1}):this.onDataInputDrop(t,e)};this._onRefInputDrop=(t,e)=>{this._deactivateInput(t),this._paused?this.__buffer.push({name:t,type:"input",event:"drop",ref:!0}):this.__onRefInputDrop(t,e)};this.__onRefInputDrop=(t,e)=>{if(this._input_effemeral[t]){let i=this._input_effemeral[t];delete this._input_effemeral[t],i.destroy()}this.onRefInputDrop(t,e)};this._onRefInputInvalid=t=>{this._i_invalid[t]||(this._i_invalid[t]=!0,this._i_invalid_count++),this.onRefInputInvalid(t)};this._activateOutput=t=>{this._o[t]===void 0&&this._active_o_count++,this._o_invalid[t]&&(delete this._o_invalid[t],this._o_invalid_count--)};this._deactivateOutput=t=>{this._o[t]!==void 0&&(this._active_o_count--,delete this._o[t]),this._o_invalid[t]&&(delete this._o_invalid[t],this._o_invalid_count--)};this.__onOutputData=(t,e)=>{this._activateOutput(t),this._o[t]=e};this._onDataOutputData=(t,e)=>{this.__onOutputData(t,e),this.onDataOutputData(t,e)};this._onRefOutputData=(t,e)=>{this.__onOutputData(t,e),this.onRefOutputData(t,e)};this._onDataOutputDrop=t=>{this._deactivateOutput(t),this._paused?this.__buffer.push({name:t,type:"output",event:"drop",ref:!1}):this.onDataOutputDrop(t)};this._onRefOutputDrop=t=>{this._deactivateOutput(t),this._paused?this.__buffer.push({name:t,type:"output",event:"drop",ref:!0}):this.onRefOutputDrop(t)};this._onOutputInvalid=t=>{this._o_invalid[t]||(this._o_invalid[t]=!0,this._o_invalid_count++),this.onOutputInvalid(t)};this._setupInputs(this._input),this._setupOutputs(this._output),this.addListener("set_input",this._onInputSet),this.addListener("set_output",this._onOutputSet),this.addListener("remove_input",this._onInputRemoved),this.addListener("remove_output",this._onOutputRemoved),this.addListener("rename_input",this._onInputRenamed),this.addListener("rename_output",this._onOutputRenamed),this.addListener("destroy",()=>{A(this._input,(s,p)=>{this._plunkInput(p,s)}),A(this._output,(s,p)=>{this._plunkOutput(p,s)})}),this.addListener("reset",()=>{this._backwarding=!1,this._forwarding=!1,this._forwarding_empty=!1}),this.addListener("play",()=>{for(;this.__buffer.length>0;){let{name:s,type:p,event:d,data:c}=this.__buffer.shift();if(p==="input"){let{ref:m}=this.getInputOpt(s);d==="data"?m?this.__onRefInputData(s,c):this.onDataInputData(s,c):m?this.__onRefInputDrop(s,c):this.onDataInputDrop(s,c)}else d==="drop"&&this.onDataOutputDrop(s)}})}getActiveInputCount(){return this._active_i_count}getActiveOutputCount(){return this._active_o_count}getOutputData(){return this._o}_plunkOutput(t,e){let i=this._outputUnlisten[t];i&&i(),delete this._outputUnlisten[t]}_plunkInput(t,e){let i=this._inputUnlisten[t];i&&i(),delete this._inputUnlisten[t]}_onInputSet(t,e,i,o){this._setupInput(t,e,i),this.onInputSet(t,e,i,o)}onInputSet(t,e,i,o){if(!e.empty()){let a=e.peak();this._activateInput(t,a),o&&(this._onInputStart(t),this.hasRefInputNamed(t)?this._onRefInputData(t,a):this._onDataInputData(t,a))}}_onOutputSet(t,e,i,o){this._setupOutput(t,e,i),this.onOutputSet(t,e,i,o)}onOutputSet(t,e,i,o){}_onInputRemoved(t,e){this._plunkInput(t,e),e.active()&&this._deactivateInput(t),this.onInputRemoved(t,e)}onInputRemoved(t,e){}_onOutputRemoved(t,e){this._plunkOutput(t,e),e.empty()||this._deactivateOutput(t),this.onOutputRemoved(t,e)}onOutputRemoved(t,e){e.empty()||this._onDataOutputDrop(t)}onDataInputData(t,e){}onRefInputData(t,e){}_onInputRenamed(t,e){let i=this.getInput(e),o=this.getInputOpt(e);this._plunkInput(t,i),this._setupInput(e,i,o),this.onInputRenamed(t,e,o,o)}_onOutputRenamed(t,e){let i=this._o[t]!==void 0,o=this.getOutput(e),a=this.getOutputOpt(e);this._plunkOutput(t,o),this._setupOutput(e,o,a),i&&this._active_o_count--,this.onOutputRenamed(t,e,a,a)}onInputRenamed(t,e,i,o){}onOutputRenamed(t,e,i,o){}onDataInputDrop(t,e){}onRefInputDrop(t,e){}onDataOutputData(t,e){}onDataOutputDrop(t){}onRefOutputData(t,e){}onRefOutputDrop(t){}onOutputInvalid(t){}_onInputEnd(t){this._i_start[t]&&(this._i_start[t]=!1,this._i_start_count--),this.onDataInputEnd(t)}onDataInputEnd(t){}_onInputStart(t){this._i_start[t]||(this._i_start[t]=!0,this._i_start_count++),this.onDataInputStart(t)}onDataInputStart(t){}_onDataInputInvalid(t){this._i_invalid[t]||(this._i_invalid[t]=!0,this._i_invalid_count++),this.onDataInputInvalid(t)}_start(){A(this._output,t=>t.start())}_invalidate(){A(this._output,t=>t.invalidate())}_end(){A(this._output,t=>t.end())}_forward(t,e){let i=this._output[t];this._forward_(i,e)}_forward_(t,e){this._forwarding=!0,t.push(e),this._forwarding=!1}_forward_all_empty(){this._forwarding_empty=!0,A(this._output,t=>t.take()),this._forwarding_empty=!1}_forward_empty(t){this._forwarding_empty=!0,this._output[t].take(),this._forwarding_empty=!1}_backward_all(){this._backwarding=!0,A(this._data_input,t=>t.pull()),this._backwarding=!1}_backward(t){this._backwarding=!0,this._input[t].pull(),this._backwarding=!1}onDataInputInvalid(t){}onRefInputInvalid(t){}snapshotSelf(){return Z(_({},super.snapshotSelf()),{_forwarding:this._forwarding,_backwarding:this._backwarding,_forwarding_empty:this._forwarding_empty})}restoreSelf(t){let p=t,{__buffer:e,_forwarding:i,_backwarding:o,_forwarding_empty:a}=p,s=bt(p,["__buffer","_forwarding","_backwarding","_forwarding_empty"]);super.restoreSelf(s),this._forwarding=i,this._backwarding=o,this._forwarding_empty=a,this._i={},this._o={},this._active_i_count=0,this._active_o_count=0,this._i_start_count=0,this._i_start={},this._o_invalid_count=0,this._o_invalid={},this._i_invalid_count=0,this._i_invalid={};for(let d in this._input){let c=this._input[d],m=c.peak();this._i[d]=m,m!==void 0&&(this._active_i_count++,this._i_start_count++,this._i_start[d]=!0,c.invalid()&&(this._i_invalid_count++,this._i_invalid[d]=!0))}for(let d in this._output){let c=this._output[d],m=c.peak();this._o[d]=m,m!==void 0&&(this._active_o_count++,c.invalid()&&(this._o_invalid_count++,this._o_invalid[d]=!0))}}};var H8="_d2c4b19b-aa58-438b-8541-9df478b80aa3",Wt=class extends Q{constructor(t){super({},{},t,H8);this._current=void 0;this._loop_invalid_o_count=0;this._loop_invalid_o=new Set;this._reset=()=>{this._current=void 0};this._play=()=>{this._forward_if_ready()};this.addListener("reset",this._reset),this.addListener("play",this._play),this.play()}onInputRemoved(t,e){super.onInputRemoved(t,e),t===this._current&&(this._current=void 0)}onInputRenamed(t,e,i,o){super.onInputRenamed(t,e,i,o),(!this.getInput(e).empty()||t===this._current)&&(this._current=e)}onOutputRenamed(t,e,i,o){super.onOutputRenamed(t,e,i,o)}onInputSet(t,e,i,o){super.onInputSet(t,e,i,o),e.empty()||(this._current=t)}onOutputSet(t,e,i,o){if(super.onOutputSet(t,e,i,o),this._current!==void 0){let a=this._i[this._current];o&&a!==void 0&&(this._forward_(e,a),this._backward_if_ready())}}onOutputRemoved(t){}_on_input_data(t){let e=this._current,i=this._i_invalid[e],o=e!==void 0&&t!==e&&!i;(o||this._active_o_count-this._loop_invalid_o_count>0)&&this._invalidate(),this._current=t,this._forward_if_ready(),o&&this._backward(e)}onDataInputData(t){this._on_input_data(t)}onRefInputData(t){this._on_input_data(t)}onDataInputDrop(t){t===this._current&&(this._current=void 0,!this._backwarding&&this._i_start_count===0&&this._forward_all_valid_empty())}_on_output_drop(t){this._loop_invalid_o.has(t)&&(this._loop_invalid_o.delete(t),this._loop_invalid_o_count--),this._backward_if_ready(),this._forward_if_ready()}onOutputInvalid(t){this._current!==void 0&&!this._forwarding&&(this._loop_invalid_o_count++,this._loop_invalid_o.add(t))}onDataOutputData(t){this._backward_if_ready()}onDataOutputDrop(t){this._on_output_drop(t)}onRefOutputDrop(t){this._on_output_drop(t)}onDataInputStart(t){this._i_start_count===1&&this._start()}onDataInputInvalid(t){t===this._current&&this._invalidate()}onInpuRemoved(t){t===this._current&&(this._current=void 0)}onDataInputEnd(t){this._paused||this._i_start_count===0&&(this._current!==void 0&&this._forward_all_valid_empty(),this._end())}_forward_all_valid_empty(){this._forwarding_empty=!0,A(this._output,(t,e)=>(!this._loop_invalid_o.has(e)||this._o_invalid[e])&&t.take()),this._forwarding_empty=!1,this._loop_invalid_o_count=0,this._loop_invalid_o=new Set}_forward_if_ready(){!this._backwarding&&!this._forwarding&&this._active_o_count-this._o_invalid_count===0&&this._o_count>0&&this._current!==void 0&&!this._i_invalid[this._current]&&(this._loop_invalid_o_count=0,this._loop_invalid_o=new Set,this._run())}_backward_if_ready(){!this._forwarding&&this._current!==void 0&&this._active_o_count-this._loop_invalid_o_count===0&&(this._loop_invalid_o_count=0,this._loop_invalid_o=new Set,this._backward(this._current),this._forward_if_ready())}_run(){let t=this._i[this._current],e=ce(this._output,o=>o.empty()),i=ce(this._output,o=>!o.empty());this._forwarding=!0,A(e,o=>o.push(t)),A(i,o=>o.push(t)),this._forwarding=!1,this._backward_if_ready()}snapshotSelf(){return Z(_({},super.snapshotSelf()),{_current:De(this._current)?this._current:void 0,_loop_invalided_o_count:this._loop_invalid_o_count})}restoreSelf(t){let a=t,{_current:e,_loop_invalided_o_count:i}=a,o=bt(a,["_current","_loop_invalided_o_count"]);super.restoreSelf(o),this._current=e,this._loop_invalid_o_count=i}getData(){if(this._current)return this._i[this._current]}};function qd(r,n,t={},e){let{inputs:i,outputs:o,id:a}=r;class s extends yt{constructor(c){super({i:et(i),o:et(o)},t,c,r.id);this.__=["U","G"];this.__element=!1;this._merge={input:{},output:{}};this.getSpec=()=>(this._ensure(),this.__graph.getSpec());this.getUnits=()=>(this._ensure(),this.__graph.getUnits());this.exposeOutputSets=c=>(this._ensure(),this.__graph.exposeOutputSets(c));this.exposeOutputSet=(c,m)=>(this._ensure(),this.__graph.exposePinSet("output",m,c));this.exposeOutput=(c,m,f)=>(this._ensure(),this.__graph.exposeOutput(c,m,f));this.coverOutputSet=c=>{this._ensure(),this.__graph.coverOutputSet(c)};this.coverOutput=(c,m)=>(this._ensure(),this.__graph.coverOutput(c,m));this.plugOutput=(c,m,f)=>(this._ensure(),this.__graph.plugOutput(c,m,f));this.unplugOutput=(c,m)=>(this._ensure(),this.__graph.unplugOutput(c,m));this.exposeInputSets=c=>(this._ensure(),this.__graph.exposeInputSets(c));this.exposeInputSet=(c,m)=>(this._ensure(),this.__graph.exposeInputSet(c,m));this.exposePinSet=(c,m,f)=>(this._ensure(),this.__graph.exposePinSet(c,m,f));this.exposePin=(c,m,f,g)=>(this._ensure(),this.__graph.exposePin(c,m,f,g));this.exposeInput=(c,m,f)=>(this._ensure(),this.__graph.exposeInput(c,m,f));this.coverInputSet=c=>(this._ensure(),this.__graph.coverInputSet(c));this.coverInput=(c,m)=>(this._ensure(),this.__graph.coverInput(c,m));this.coverPinSet=(c,m,f=!0)=>(this._ensure(),this.__graph.coverPinSet(c,m,f));this.plugPin=(c,m,f,g)=>(this._ensure(),this.plugPin(c,m,f,g));this.plugInput=(c,m,f)=>(this._ensure(),this.plugInput(c,m,f));this.unplugInput=(c,m)=>(this._ensure(),this.unplugInput(c,m));this.coverPin=(c,m,f)=>(this._ensure(),this.__graph.coverPin(c,m,f));this.getSubPinSpec=(c,m,f)=>(this._ensure(),this.__graph.getSubPinSpec(c,m,f));this.unplugPin=(c,m,f)=>(this._ensure(),this.__graph.unplugPin(c,m,f));this.getExposedInputPin=c=>(this._ensure(),this.__graph.getExposedInputPin(c));this.getExposedOutputPin=c=>(this._ensure(),this.__graph.getExposedOutputPin(c));this.getGraphPinData=()=>(this._ensure(),this.__graph.getGraphPinData());this.getGraphErr=()=>(this._ensure(),this.__graph.getGraphErr());this.getUnitInputData=c=>(this._ensure(),this.__graph.getUnitInputData(c));this.addUnits=c=>(this._ensure(),this.__graph.addUnitSpecs(c));this.addUnit=(c,m)=>(this._ensure(),this.__graph.addUnit(c,m));this.addMerges=c=>(this._ensure(),this.__graph.addMerges(c));this.addMerge=(c,m)=>(this._ensure(),this.__graph.addMerge(c,m));this.addPinToMerge=(c,m,f,g)=>(this._ensure(),this.__graph.addPinToMerge(c,m,f,g));for(let m in this._input)this._input[m].addListener("data",g=>{this._ensure()});this.addListener("play",()=>{this.__graph&&this.__graph.play()}),this.addListener("pause",()=>{this.__graph&&this.__graph.pause()}),this.addListener("take_err",()=>{this.__graph.takeErr()}),this.addListener("reset",()=>{this.__graph&&this.__graph.reset()})}stopPropagation(c){return this._ensure(),this.__graph.stopPropagation(c)}getSetup(){return this._ensure(),this.__graph.getSetup()}setUnitPinSetId(c,m,f,g,...h){return this._ensure(),this.__graph.setUnitPinSetId(c,m,f,g,...h)}fork(){return this._ensure(),this.__graph.fork()}startTransaction(){return this._ensure(),this.__graph.startTransaction()}endTransaction(){return this._ensure(),this.__graph.endTransaction()}getMergeData(c){return this._ensure(),this.__graph.getPlugSpecs()}getPlugSpecs(){return this._ensure(),this.__graph.getPlugSpecs()}hasMergePin(c,m,f,g){return this._ensure(),this.__graph.hasMergePin(c,m,f,g)}getMergesSpec(){return this._ensure(),this.__graph.getMergesSpec()}getUnitPinData(c,m,f){return this._ensure(),this.__graph.getUnitPinData(c,m,f)}isUnitPinConstant(c,m,f){return this._ensure(),this.__graph.isUnitPinConstant(c,m,f)}isUnitPinRef(c,m,f){return this._ensure(),this.__graph.isUnitPinRef(c,m,f)}getExposedPinSpecs(){return this._ensure(),this.__graph.getExposedPinSpecs()}getPinPlugCount(c,m){return this._ensure(),this.__graph.getPinPlugCount(c,m)}moveRoot(c,m,f,g){return this._ensure(),this.__graph.moveRoot(c,m,f,g)}hasPlug(c,m,f){return this._ensure(),this.__graph.hasPlug(c,m,f)}removePinOrMerge(c,m,f,g,...h){return this._ensure(),this.__graph.removePinOrMerge(c,m,f,g,...h)}removeMergeData(c){return this._ensure(),this.__graph.removeMergeData(c)}setUnitSize(c,m,f){return this._ensure(),this.__graph.setUnitSize(c,m,f)}setSubComponentSize(c,m,f){return this._ensure(),this.__graph.setSubComponentSize(c,m,f)}setComponentSize(c,m,f){return this._ensure(),this.__graph.setComponentSize(c,m,f)}moveSubgraphOutOf(...[c,m,f,g,h,x,y,I,v,T]){return this._ensure(),this.__graph.moveSubgraphOutOf(c,m,f,g,h,x,y,I,v,T)}removeUnitPinData(c,m,f){return this._ensure(),this.__graph.removeUnitPinData(c,m,f)}addUnitSpecs(c){return this._ensure(),this.__graph.addUnitSpecs(c)}addUnitSpec(c,m,f){return this._ensure(),this.__graph.addUnitSpec(c,m)}bulkEdit(c){return this._ensure(),this.__graph.bulkEdit(c)}setUnitId(c,m,f,g){return this._ensure(),this.__graph.setUnitId(c,m,f,g)}isElement(){return kf(r)}getMergeSpec(c){return this._ensure(),this.__graph.getMergeSpec(c)}reorderRoot(c,m){return this._ensure(),this.__graph.reorderRoot(c,m)}reorderParentRoot(c,m){return this._ensure(),this.__graph.reorderParentRoot(c,m)}reorderSubComponent(c,m,f){return this._ensure(),this.__graph.reorderSubComponent(c,m,f)}moveSubComponentRoot(c,m,f){return this._ensure(),this.__graph.moveSubComponentRoot(c,m,f)}appendParentChild(c,m){return this._ensure(),this.__graph.appendParentChild(c,m)}removeParentChild(c){return this._ensure(),this.__graph.removeParentChild(c)}removeRoot(c){return this._ensure(),this.__graph.removeRoot(c)}detach(){return this._ensure(),this.__graph.detach()}moveSubgraphInto(...[c,m,f,g,h,x,y,I,v,T]){return this._ensure(),this.__graph.moveSubgraphInto(c,m,f,g,h,x,y,I,v,T)}registerRoot(c){return this._ensure(),this.__graph.registerRoot(c)}unregisterRoot(c){return this._ensure(),this.__graph.unregisterRoot(c)}registerParentRoot(c,m){return this._ensure(),this.__graph.registerParentRoot(c,m)}unregisterParentRoot(c){return this._ensure(),this.__graph.unregisterParentRoot(c)}_load(){let c=e(r,n,this.__system.classes,t);this.__graph=new c(this.__system),this.__graph.addListener("err",m=>{this.err(m)}),this.__graph.addListener("take_err",()=>{this.takeErr()}),A(this.__graph.getOutputs(),(m,f)=>{let g=new Wt(this.__system);g.play(),this._merge.output[f]=g,g.setInput(f,m),g.setOutput(f,this._output[f])}),A(this.__graph.getInputs(),(m,f)=>{let g=new Wt(this.__system);g.play(),this._merge.input[f]=g,g.setInput(f,this._input[f]),g.setOutput(f,m)}),this.__graph.play()}_ensure(){this.__graph||this._load()}getBundleSpec(){return this._ensure(),this.__graph.getBundleSpec()}getUnitState(c){return this._ensure(),this.__graph.getUnitState(c)}getGraphState(){return this._ensure(),this.__graph.getGraphState()}getGraphChildren(){return this._ensure(),this.__graph.getGraphChildren()}pushChild(c){return this._ensure(),this.__graph.pushChild(c)}appendChild(c){return this._ensure(),this.__graph.appendChild(c)}insertChild(c,m){return this._ensure(),this.__graph.insertChild(c,m)}pullChild(c){return this._ensure(),this.__graph.pullChild(c)}removeChild(c){return this._ensure(),this.__graph.removeChild(c)}hasChild(c){return this._ensure(),this.__graph.hasChild(c)}refChild(c){return this._ensure(),this.__graph.refChild(c)}refChildren(){return this._ensure(),this.__graph.refChildren()}refSlot(c){return this._ensure(),this.__graph.refSlot(c)}animate(c,m){return this._ensure(),this.__graph.animate(c,m)}cancelAnimation(c){return this._ensure(),this.__graph.cancelAnimation(c)}getAnimations(){return this._ensure(),this.__graph.getAnimations()}isExposedOutput(c){return this._ensure(),this.__graph.isExposedOutput(c)}setPinSetId(c,m,f){return this._ensure(),this.__graph.setPinSetId(c,m,f)}setPinSetFunctional(c,m,f){return this._ensure(),this.__graph.setPinSetFunctional(c,m,f)}isExposedInput(c){return this._ensure(),this.__graph.isExposedInput(c)}getExposedPinSpec(c,m){return this._ensure(),this.__graph.getExposedPinSpec(m,c)}isExposedInputPinId(c){return this._ensure(),this.__graph.isExposedInputPinId(c)}isExposedOutputPinId(c){return this._ensure(),this.__graph.isExposedOutputPinId(c)}getExposedInputSpec(c){return this._ensure(),this.__graph.getExposedInputSpec(c)}getExposedOutputSpec(c){return this._ensure(),this.__graph.getExposedOutputSpec(c)}hasUnit(c){return this._ensure(),this.__graph.hasUnit(c)}hasMerge(c){return this._ensure(),this.__graph.hasMerge(c)}getGraphUnitSpec(c){return this._ensure(),this.__graph.getGraphUnitSpec(c)}getUnit(c){return this._ensure(),this.__graph.getUnit(c)}getUnitByPath(c){return this._ensure(),this.__graph.getUnitByPath(c)}getUnitPin(c,m,f){return this._ensure(),this.__graph.getUnitPin(c,m,f)}getUnitData(c,m,f){return this._ensure(),this.__graph.getUnitData(c,m,f)}getUnitInput(c,m){return this._ensure(),this.__graph.getUnitInput(c,m)}getUnitOutput(c,m){return this._ensure(),this.__graph.getUnitOutput(c,m)}setUnitErr(c,m){return this._ensure(),this.__graph.setUnitErr(c,m)}takeUnitErr(c){return this._ensure(),this.__graph.takeUnitErr(c)}getMerges(){return this._ensure(),this.__graph.getMerges()}getMerge(c){return this._ensure(),this.__graph.getMerge(c)}getMergeCount(){return this._ensure(),this.__graph.getMergeCount()}getMergeUnitCount(c){return this._ensure(),this.__graph.getMergeUnitCount(c)}getMergePinCount(c){return this._ensure(),this.__graph.getMergePinCount(c)}moveUnit(c,m,f){return this._ensure(),this.__graph.moveUnit(c,m,f)}removeUnit(c,...m){return this._ensure(),this.__graph.removeUnit(c,...m)}addUnitGhost(c,m,f,g){return this._ensure(),this.__graph.addUnitGhost(c,m,f,g)}removeUnitGhost(c,m,f){return this._ensure(),this.__graph.removeUnitGhost(c,m,f)}swapUnitGhost(c,m,f){this._ensure(),this.__graph.swapUnitGhost(c,m,f)}explodeUnit(c,m,f,g){return this._ensure(),this.__graph.explodeUnit(c,m,f,g)}removeMerge(c){return this._ensure(),this.__graph.removeMerge(c)}removePinFromMerge(c,m,f,g){return this._ensure(),this.__graph.removePinFromMerge(c,m,f,g)}isPinMergedTo(c,m,f,g){return this._ensure(),this.__graph.isPinMergedTo(c,m,f,g)}setUnitPinConstant(c,m,f,g){return this._ensure(),this.__graph.setUnitPinConstant(c,m,f,g)}setUnitInputConstant(c,m,f){return this._ensure(),this.__graph.setUnitInputConstant(c,m,f)}setUnitOutputConstant(c,m,f){return this._ensure(),this.__graph.setUnitOutputConstant(c,m,f)}setUnitInputIgnored(c,m,f){return this._ensure(),this.__graph.setUnitPinIgnored(c,"input",m,f)}setUnitOutputIgnored(c,m,f){return this._ensure(),this.__graph.setUnitPinIgnored(c,"output",m,f)}setUnitPinIgnored(c,m,f,g){return this._ensure(),this.__graph.setUnitPinIgnored(c,m,f,g)}setUnitPinData(c,m,f,g){return this._ensure(),this.__graph.setUnitPinData(c,m,f,g)}setUnitInputData(c,m,f){return this._ensure(),this.__graph.setUnitInputData(c,m,f)}setUnitOutputData(c,m,f){return this._ensure(),this.__graph.setUnitOutputData(c,m,f)}getGraphMergeInputData(){return this._ensure(),this.__graph.getGraphMergeInputData()}setMetadata(c,m){this._ensure(),this.__graph.setMetadata(c,m)}setGraphState(c){this._ensure(),this.__graph.setGraphState(c)}}return s.__bundle={unit:{id:a},specs:{}},s}var Qe=class extends Error{constructor(){super("Could not find spec")}};function le(r,n,t,e={}){if(!n[r])throw new Qe;let o=Yd(r,n,t,e);return zt(o,{unit:{id:r},specs:{}})}function Yd(r,n,t,e={}){let i=n[r];if(!i)throw new Qe;let o=t[r];return o===void 0&&(i=i,e[r]?o=qd(i,n,e,be):o=Jd(i,n,t,Z(_({},e),{[r]:!0}))),o}function Yf(r,n,t,e,i={}){let o=t[n];if(!o)throw new Qe;let a,s=e[n];if(s===void 0)if(o=o,i[n]){let p=qd(o,t,i,be);a=new p(r,n)}else a=Jf(r,o,t,Z(_({},i),{[n]:!0}));else a=new s(r,n);return a}function vn(r,n,t){let{unit:e,specs:i={}}=r,{id:o}=e,a=Yd(o,ut(i,n),t,{});return zt(a,r)}var O=class extends Error{constructor(){super("method not implemented")}};var V8={B:!0,IB:!0,CA:!0,CC:!0,C:!0,CS:!0,CO:!0,G:!0,GP:!0,M:!0,E:!0,EE:!0,BD:!0,BS:!0,BSE:!0,BC:!0,NO:!0,J:!0,A:!0,PP:!0,PS:!0,CH:!0,MS:!0,S:!0,U:!0,V:!0,TR:!0,RE:!0,F:!0,L:!0,AC:!0,D:!0},tx=Object.keys(V8);function Xd(r,n,t){let e=r.substring(1);return st(e,n,t)}var Xf=/^(true|false)$/;var Zf=/^(?:[$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D])(?:[$0-9A-Z_a-z\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF])*(\?)?$/;var Qf=/^-?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?$/;var z8=",",W8='"',K8="'",el="{",nl="}",il="[",rl="]";function Qd(r){return r.type==="generic"||r.type==="identifier"||r.type==="string literal"||r.type==="boolean literal"||r.type==="number literal"}function Dt(r,n=!1,t=!1){return al(r,n,t,Dt)||q8(r,n,t)||{value:r,type:"invalid",children:[]}}function q8(r,n=!1,t=!1){if(r=r.trim(),!t&&/^\((.*)\)=>\((.*)\)$/.exec(r))return{value:r,type:"class literal",children:[]};let e=/^\((.+)\)$/.exec(r);if(e){let m=[Dt(e[1])];return{value:r,type:"expression",children:m}}if(/^<[^]*>$/.exec(r))return{value:r,type:"generic",children:[]};if(!t){if(/^regex$/.exec(r))return n3;if(/^string$/.exec(r))return Z8;if(/^number$/.exec(r))return t3;if(/^boolean$/.exec(r))return Q8;if(/^object$/.exec(r))return i3;if(/^any$/.exec(r))return e3}let o=/^([^ [\]]+)(\[[^ [\]]+\]+)$/.exec(r);if(o){let m=Dt(o[1]),f=Dt(o[2]);return{value:r,type:"prop expression",children:[m,f]}}let a=/^([^ ]+)\[\]$/.exec(r);if(a){let m=Dt(a[1]);if(m.type!=="invalid")return{value:r,type:"array expression",children:[m]}}let s=/^([^|{}]+)\{\}$/.exec(r);if(s){let m=[Dt(s[1])];return{value:r,type:"object expression",children:m}}if(/^.+(\|.+)+$/.exec(r)){let m=Zd(r,!1,!1,"|",Dt);return{value:r,type:"or",children:m}}if(/^(.+)&(.+)$/.exec(r)){let m=Zd(r,!1,!1,"&",Dt);return{value:r,type:"and",children:m}}let c=/^`([A-Z]+)(.*)?`$/i.exec(r);if(c){let m=c[2];return{value:r,type:"class",children:m?[Dt(m)]:[]}}}function ol(r,n,t){let e=r.length;if(r[0]===n&&r[e-1]===t){let i=!1,o=!1,a=0,s=0;for(let p=1;p<e-1;p++){let d=r[p],c=r[p-1];if(d==="'"&&c!=="\\")o||(i=!i,i||(a+=s));else if(d==='"'&&c!=="\\")i||(o=!o,o||(a+=s));else if(!i&&!o){if(d===n)a++;else if(d===t&&(a--,a===-1))return null}else d===n?s++:d===t&&s--}return[r,r.substr(1,e-2)]}else return null}function Y8(r){return ol(r,el,nl)}function J8(r){return ol(r,il,rl)}function al(r,n=!1,t=!1,e=al){if(r=r.trim(),!t){if(/^null$/.exec(r))return X8;if(/^[+-]?Infinity$/.exec(r))return{value:r,type:"number literal",children:[]}}if(Xf.exec(r))return{value:r,type:"boolean literal",children:[]};if(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'")){let f=r[0],g=!0;for(let h=1;h<r.length-1;h++)if(r[h]===f&&r[h-1]!=="\\"){g=!1;break}if(g)return{value:r,type:"string literal",children:[]}}if(Qf.exec(r))return{value:r,type:"number literal",children:[]};if(/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?(?:[\s]*[+\-*/][\s]*-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)+$/g.exec(r))return{value:r,type:"arithmetic expression",children:[]};if(new RegExp("^\\$\\{(.*)\\}$","is").exec(r))return{value:r,type:"unit",children:[]};if(/^\/.+\/$/.exec(r))return{value:r,type:"regex literal",children:[]};if(t&&Zf.test(r))return{value:r,type:"identifier",children:[]};if(n){let f=/^("[^"]*"|'[^']*'|[^:{]*):([^]*)$/.exec(r);if(f){let g=e(f[1],!1,!0);if(!Qd(g))return{value:r,type:"invalid",children:[]};let h=f[2],x=e(h)||{value:h,type:"invalid",children:[]};return{value:r,type:"key value",children:[g,x]}}else return{value:r,type:"invalid",children:[]}}let d=Y8(r);if(d){let f=d[1],g=tl(f,!0,!0,e);return{value:r,type:"object literal",children:g}}let c=J8(r);if(c){let f=c[1],g=tl(f,!1,!1,e);return{value:r,type:"array literal",children:g}}if(/^unit:\/\/.+$/i.exec(r))return{value:r,type:"url",children:[]}}var X8={value:"null",type:"null",children:[]},Z8={value:"string",type:"string",children:[]},Q8={value:"boolean",type:"boolean",children:[]},t3={value:"number",type:"number",children:[]},e3={value:"any",type:"any",children:[]},n3={value:"regex",type:"regex",children:[]},i3={value:"object",type:"object",children:[]};function r3(r){return!!/^ *$/.exec(r)}function Zd(r,n=!1,t=!1,e,i){r=r.trim();let o=0,a=0,s=!1,p=!1,d=0,c=0,m=!1,f=[],g;for(;d<r.length;){let x=r[d];if(!p&&!s&&(x===el?o++:x===nl&&o--,x===il?a++:x===rl&&a--),s||x===W8&&g!=="\\"&&(p=!p),p||x===K8&&g!=="\\"&&(s=!s),x===e&&o===0&&a===0&&!s&&!p){let y=r.substring(c,d);f.push(i(y,n,t)),c=d+1,m=!0}g=x,d++}let h=r.substring(c,r.length);return(!r3(h)||m)&&f.push(i(h,n,t)),f}function tl(r,n=!1,t=!1,e){return Zd(r,n,t,z8,e)}var Px=Dt("");function Qu(r,n,t,e=()=>{throw new Error("cannot resolve")}){let{value:i,children:o}=r;switch(r.type){case"identifier":return i;case"null":return null;case"string literal":return i.substring(1,i.length-1).replace(/\\"/g,'"');case"boolean literal":return i==="true";case"number literal":return Number.parseFloat(i);case"array literal":{let a=[];for(let s of o)s.type!=="invalid"&&a.push(Qu(s,n,t,e));return a}case"object literal":{let a={};for(let s of o)if(s.type==="key value"){let[p,d]=s.children;a[Qu(p,n,t)]=Qu(d!=null?d:p,n,t,e)}else Qd(s)&&(a[s.value]=s.value);return a}case"unit":{let a=i.substring(1),s=st(a,n,t);return vn(s,n,t)}case"url":return e(i);default:throw new Error("invalid data string")}}function st(r,n,t,e=()=>{throw new Error("cannot resolve")}){let i=Dt(r,!1,!1);return Qu(i,n,t,e)}function ec(r,n){let{id:t}=r,e=ht(n,t),{system:i}=e;if(i)return{unit:_({id:t},r)};{let o={[t]:e};return tc(e,n,o,new Set),{unit:_({id:t},r),specs:o}}}function tn(r,n){let t={};return tc(r,n,t,new Set([])),{spec:r,specs:t}}function tc(r,n,t,e){if(!r.id)throw new Error("spec id is required");r.system||e.has(r.id)||(e.add(r.id),o3(r,n,t,e))}function o3(r,n,t,e){var o;let{units:i={}}=r;for(let a in i){let s=i[a],{id:p,input:d={}}=s;for(let m in d){let f=(o=d[m])!=null?o:{},{data:g}=f;if(g){let h=Dt(g);if(h.type==="unit"){let x=st(h.value,n,{});for(let y in x.specs){let I=x.specs[y];t[y]=I,tc(I,n,t,e)}}}}let c=ht(n,p);(!n[p]||!yn(n,p))&&(t[p]=c),tc(c,n,t,new Set(e))}}var nc=class extends Error{constructor(){super("no child at this position")}};function ic(r,n,t){let e=Dn(r,n,t),{__bundle:i}=t;return r.emit("append_child",i,[]),e}function pl(r,n){let t=r.refSystem(),e=new n(t),{input:i={},output:o={},memory:a={input:{},output:{},memory:{}}}=n.__bundle.unit;for(let s in i){let{data:p}=i[s];if(p!==void 0){let d=st(p,t.specs,t.classes);e.pushInput(s,d)}}return r.paused()&&!e.paused()?e.pause():!r.paused()&&e.paused()&&e.play(),e}function Dn(r,n,t){let e=pl(r,t);return n.push(e),n.length-1}function ul(r,n,t,e){let i=pl(r,t);It(n,i,e);let{__bundle:o}=t;r.emit("insert_child",o,e,[])}function Sn(r,n,t){return t>=0&&t<n.length}function En(r,n,t){if(!Sn(r,n,t))throw new nc;let[i]=n.splice(t,1);return i}function rc(r,n,t){let e=En(r,n,t);return r.emit("remove_child",t,[]),r.emit(`remove_child_at_${t}`,t),e}function oc(r,n,t){return n[t]}function ac(r,n){return n}function cl(r,n,t){return t[n]||r}function sc(r,n,t,e,i){i===void 0?n.push(t):It(n,t,i),r.emit("register_parent_root",t,e),r.refSlot(e).appendParentChild(r,"default")}function pc(r,n,t){let e=n.indexOf(t);n.splice(e,1),r.emit("unregister_parent_root",r)}function uc(r,n,t,e){let i=n.indexOf(t);if(i===-1)throw new Error("root not found");n.splice(i,1),It(n,t,e),r.emit("reorder_root",r,e)}function cc(r,n,t,e){let i=n.indexOf(t);if(i===-1)throw new Error("root not found");n.splice(i,1),It(n,t,e),r.emit("reorder_parent_root",r,e)}function dc(r,n,t){let e=n.indexOf(t);n.splice(e,1),r.emit("unregister_root",r)}function mc(r,n,t){n.push(t),r.emit("register_root",r)}function fc(r,n,t,e){let i=r.refSlot(e);r===i?(n.push(t),r.emit("append_parent_child",r,e)):i.appendParentChild(t,"default")}function lc(r,n,t){let e=n.indexOf(t);n.splice(e,1),r.emit("remove_parent_child",r)}function bc(r,n,t,e){n.push({keyframes:t,opt:e}),r.emit("call",{method:"animate",data:[t,e]})}function gc(r,n,t){let e=n.findIndex(i=>i.opt.id===t);n.splice(e,1),r.emit("call",{method:"cancelAnimation",data:[t]})}function hc(r,n,t){var e;return n[t]=(e=n[t])!=null?e:0,n[t]++,r.emit("call",{method:"stopPropagation",data:[t]}),()=>{n[t]--,n[t]===0&&(delete n[t],r.emit("call",{method:"cancelStopPropagation",data:[t]}))}}var wt=["fork","append_child","remove_child","insert_child","add_unit","clone_unit","remove_unit","move_unit","add_merge","remove_merge","expose_pin","cover_pin","plug_pin","unplug_pin","remove_pin_from_merge","add_pin_to_merge","move_subgraph_into","move_subgraph_into","move_sub_component_root","reorder_sub_component","expose_pin_set","cover_pin_set","set_pin_set_id","set_pin_set_functional","set_unit_pin_constant","set_unit_pin_ignored","set_unit_pin_data","remove_unit_pin_data","set_unit_id","bulk_edit"];var Ne=class extends Error{constructor(){super("code path not implemented")}};var yc=class extends Error{constructor(){super("merge not found")}};var _c=class extends Error{constructor(){super("unit not found")}};function pt(r,n){let t=r;for(let e of n)t=r[e],r=t;return t}function Jt(r,n,t){return`${r}/${n}/${t}`}function dl(r,n){return Jt(r,"output",n)}function At(r,n){return`${r}/${n}`}function _t(r){return r==="input"?"output":"input"}var ml=r=>{let n={input:{},output:{}};return ll(r,(t,e,i,o,a)=>{let s=a3(r,t,e,o);F(n,[t,e,o],s)}),n},a3=(r,n,t,e)=>W(r,[`${n}s`,t,"plug",e],null);var Kt=r=>Vd(r,(n,t)=>n+nm(t),0);var em=(r,n)=>Vd(r,(t,e)=>t+tm(e,n),0),nm=r=>tm(r,"input")+tm(r,"output"),tm=(r,n)=>{let{[n]:t={}}=r;return zu(t)},te=(r,n)=>{A(r||{},(t,e)=>{St(t,(i,o,a,s)=>n(e,i,o,a,s))})},St=(r,n)=>{A(r,({input:t,output:e},i)=>{A(t||{},(o,a)=>{n(i,"input",a,o)}),A(e||{},(o,a)=>{n(i,"output",a,o)})})},fl=(r,n)=>{A(r,({input:t},e)=>{A(t||{},(i,o)=>{n(e,"input",o,i)})})};var s3=(r,n)=>{Tn(r,"input",(t,e)=>{n("input",t,e)}),Tn(r,"output",(t,e)=>{n("output",t,e)})},ll=(r,n)=>{s3(r,(t,e,i)=>{var o;for(let a in(o=i.plug)!=null?o:{}){let s=i.plug[a];n(t,e,i,a,s)}})};var Tn=(r,n,t)=>{var e;A((e=r[`${n}s`])!=null?e:{},(i,o)=>{t(o,i)})};var bl=(r,n)=>{var t;return!!((t=r.merges)!=null&&t[n])},gl=(r,n,t,e,i)=>!!W(r,["merges",n,t,e,i],!1);var hl=(r,n,t,e)=>{let i=null;return Tn(r,t,(o,a)=>{let{plug:s={}}=a;for(let p in s){let d=s[p];d.unitId===n&&d.pinId===e&&(i={pinId:o,type:t,subPinId:p})}}),i};function im(r,n){let t={input:{},output:{}};return ll(r,(e,i,o,a,s)=>{var p;s.unitId===n&&F(t,[(p=s.kind)!=null?p:e,s.pinId],{type:e,pinId:i,subPinId:a})}),t}var p3=(r,n,t,e,i,o,a=null)=>{var s;return o||a?!1:ue((s=t.plug)!=null?s:{})>1?!0:i.pinId!==n};function yl(r,n,t,e,i,{getUnitMerges:o,getUnitPlugs:a,getMerge:s,getPinMergeId:p}){var J,q;let{units:d={},merges:c={},inputs:m={},outputs:f={}}=n,g={unit:et(d),merge:et(c),link:[],plug:[]},h=o(r),x=a(r),y={unit:t,merge:e,plug:vt(i,w=>vt(w,E=>vt(E,$=>({subPinId:$}))))},I={},v={},T={},P={};te(c,(w,E,$,G)=>{var L;let K=(L=e[w])!=null?L:w;F(P,[E,$,G],K)});let H=(w,E)=>{for(let $ in E){let G=E[$];U(w,$,G)}},U=(w,E,$)=>{var nt,M;let{plug:G,ref:K,defaultIgnored:L}=$,rt=!!p(r,w,E),N=W(x,[w,E],null);for(let k in G){let R=G[k];if(p3(w,E,$,k,R,rt,N)){g.plug.push({type:w,pinId:E,subPinId:k});let X={};R.unitId&&R.pinId?X={unitId:(nt=y.unit[R.unitId])!=null?nt:R.unitId,pinId:R.pinId}:X={mergeId:(M=y.merge[R.mergeId])!=null?M:R.mergeId},F(T,[w,E,k],X)}if(R.unitId&&R.pinId)te(h,(X,ct,ot,it)=>{var Pt;let dt=s(X),Et=j(dt);delete Et[r];let xt=(Pt=y.unit[R.unitId])!=null?Pt:R.unitId;Et[xt]={[ot]:{[R.pinId]:!0}},ct===r&&ot===w&&it===E&&F(I,[R.unitId,ot,R.pinId],{pinId:E,subPinId:k,ref:K,defaultIgnored:L,mergeId:X,merge:Et})});else if(R.mergeId){let X=c[R.mergeId];if(om(X)){let ct=p(r,w,E);if(ct){let ot=s(ct),it=j(ot);delete it[r],F(v,[R.mergeId,w],{mergeId:ct,pinId:E,subPinSpec:{mergeId:R.mergeId},oppositeMerge:it})}else F(v,[R.mergeId,w],{mergeId:null,pinId:null,subPinSpec:{},oppositeMerge:{}})}else{let ct=p(r,w,E);if(ct){let ot=s(ct),it=j(ot);delete it[r],F(v,[R.mergeId,w],{mergeId:ct,oppositeMerge:it})}}}}};H("input",m),H("output",f);for(let w in h){let E=s(w),$=j(E),G=$[r];Ft((J=G.input)!=null?J:{})&&delete G.input,Ft((q=G.output)!=null?q:{})&&delete G.output;let K=at(G),L=at(G[K]);if(delete $[r],Kt($)===1&&L!==lt){let rt=pt(n,[`${K}s`,L]),{plug:N={}}=rt,nt=!1;for(let M in N){let k=N[M];if(k.mergeId){let R=c[k.mergeId];Kt(R)===0&&(nt=!0)}}if(!nt){let M=at($),k=at($[M]),R=at($[M][k]);F(y,["link",M,k,R],{mergeId:w,oppositePinId:L})}}}return te(h,(w,E,$,G)=>{let K=s(w)}),{nodeIds:g,nextSpecId:null,nextIdMap:y,nextPinIdMap:I,nextMergePinId:v,nextPlugSpec:T,nextUnitPinMergeMap:P,nextSubComponentParentMap:{},nextSubComponentChildrenMap:{},nextSubComponentIndexMap:{}}}function rm(r,n){let{merges:t}=r,e={};for(let i in t){let o=t[i];o[n]&&(e[i]=o)}return e}function om(r){return Kt(r)===0}var u3="addUnitSpec";var c3="removeUnit";var d3="addMerge";var m3="removeMerge";var f3="exposePinSet",l3="coverPinSet";var b3="unplugPin",g3="plugPin";var h3=r=>({type:u3,data:r}),_l=(r,n,t,e,i,o,a,s)=>h3({unitId:r,bundle:n,position:t,pinPosition:e,layoutPositon:i,parentId:o,merges:a,plugs:s});var y3=r=>({type:c3,data:r}),xl=(r,n,t,e,i,o,a,s)=>y3({unitId:r,bundle:n,position:t,pinPosition:e,layoutPositon:i,parentId:o,merges:a,plugs:s});var _3=r=>({type:f3,data:r});var Il=(r,n,t,e)=>_3({type:r,pinId:n,pinSpec:t,data:e}),x3=r=>({type:l3,data:r}),vl=(r,n,t)=>x3({type:r,pinId:n,pinSpec:t}),I3=r=>({type:g3,data:r}),Dl=(r,n,t,e)=>I3({type:r,pinId:n,subPinId:t,subPinSpec:e}),v3=r=>({type:b3,data:r}),Sl=(r,n,t,e)=>v3({type:r,pinId:n,subPinId:t,subPinSpec:e});var D3=r=>({type:d3,data:r}),El=(r,n,t)=>D3({mergeId:r,mergeSpec:n,position:t}),S3=r=>({type:m3,data:r}),Tl=(r,n,t)=>S3({mergeId:r,mergeSpec:n,position:t});var Al=(r,n,t)=>{var o;let{type:e,data:i}=r;if(!n[e]&&t)throw new Error(`no method for ${e}`);((o=n[e])!=null?o:t)(i)};function Cl(r,n=!1){let{__system:t}=r,[e,i]=E3(r,n);return[new e(t),i]}function E3(r,n=!1){let{__system:t}=r,e=t.specs,i=j(r.getUnitBundleSpec(n));return[vn(i,e,t.classes),i]}function en(r,n){return _(_({},r),n)}function nn(r,n,t){return Z(_({},r),{[n]:t})}function am(r,n){r.input!==void 0&&n("input",r.input),r.output!==void 0&&n("output",r.output)}function Bt(r,n){am(r,(t,e)=>{Nt(e,(i,o)=>{n(t,i,o)})})}function sm(r,n){return Ml(r.component,n)}function Ml(r,n){let{subComponents:t}=r;for(let e in t){let i=t[e],{children:o=[]}=i;for(let a of o)if(a===n)return e}return null}function xc(r,n,t){var e;if(n.length>1){let[i,...o]=n;r[i]=(e=r[i])!=null?e:{},xc(r[i],o,t)}else{let[i]=n;r[i]=t}}var Pl=({unitId:r,unit:n},t)=>{F(t,["units",r],n)};var T3=({mergeId:r,unitId:n,type:t,pinId:e},i)=>{Vt(i,["merges",r,n,t,e]),Ft(W(i,["merges",r,n,t],{}))&&Vt(i,["merges",r,n,t]),Ft(W(i,["merges",r,n],{}))&&Vt(i,["merges",r,n])},Ol=({mergeId:r,unitId:n,type:t,pinId:e},i)=>{T3({mergeId:r,unitId:n,type:t,pinId:e},i)};var Ul=({pinId:r,type:n},t)=>Vt(t,[`${n}s`,r]),wl=({pinId:r,type:n,subPinId:t},e)=>{Vt(e,[`${n}s`,r,"plug",t])};var Ll=({type:r,pinId:n,subPinId:t,subPinSpec:e},i)=>F(i,[`${r}s`,n,"plug",t],e);var Gl=({type:r,pinId:n,subPinId:t},e)=>F(e,[`${r}s`,n,"plug",t],{});var Rl=({type:r,pinId:n,functional:t},e)=>F(e,[`${r}s`,n,"functional"],t);var kl=({unitId:r,type:n,pinId:t,data:e},i)=>F(i,["units",r,n,t,"data"],e),$l=({unitId:r,type:n,pinId:t,constant:e},i)=>F(i,["units",r,n,t,"constant"],e);var Nl=({unitId:r,width:n,height:t},e)=>{Wu(e,["units",r,"metadata","component"],{width:n,height:t})},Fl=({width:r,height:n},t)=>{Wu(t,["component"],{defaultWidth:r,defaultHeight:n})},Bl=({unitId:r,width:n,height:t},e)=>{Wu(e,["component","subComponents",r],{width:n,height:t})},jl=({unitId:r,type:n,pinId:t,newPinId:e},i)=>{let{units:o={},merges:a={}}=i;for(let s in o){let p=o[s]}te(j(a),(s,p,d,c)=>{p===r&&d===n&&c===t&&(Vt(i,["merges",s,r,n,t]),F(i,["merges",s,r,n,e],!0))})};function An(r,n,t,e={}){let{unit:{id:i,input:o,output:a}}=n,{classes:s}=r;n.specs&&r.injectSpecs(n.specs);let p=Yf(r,i,t,s,e);A(o||{},(c={},m)=>{let{constant:f,ignored:g}=c;f!=null&&p.setInputConstant(m,f),typeof g=="boolean"&&p.setInputIgnored(m,g)}),A(a||{},(c={},m)=>{let{ignored:f}=c;typeof f=="boolean"&&p.setOutputIgnored(m,f)});let{unit:{memory:d}}=n;return d&&(Yu(d,t,s),p.restore(d)),A(o||{},(c,m)=>{var g,h;let{data:f}=c!=null?c:{};if(f!==void 0){let x=p.getInput(m),y=st(f,r.specs,s),I=y instanceof Function;if(I&&r.injectSpecs((h=(g=y.__bundle)==null?void 0:g.specs)!=null?h:{}),x.ref()){if(I){let v=new y(r);v.play(),x.push(v)}}else x.push(y)}}),p}function tt(r){return()=>{r.forEach(n=>n())}}var l=class extends Q{constructor({i:t,o:e}={},i={},o,a){super({i:t,o:e},i,o,a);this._looping=!1;this._on_data_output_drop=t=>{this._backward_if_ready(),this._forward_if_ready()};this._done=(t,e=null)=>{if(e)this._forwarding=!0,this.err(e),this._forwarding=!1,this._forward_all_empty();else if(t!==void 0){let i=ce(this._output,s=>s.empty()),o=ce(this._output,s=>!s.empty()),a=(s,p)=>{let d=t[p];d===void 0?s.pull():s.push(d)};this._forwarding=!0,A(i,a),A(o,a),this._forwarding=!1}this._backward_if_ready()};this.addListener("take_err",()=>{this._looping&&this._backward_if_ready()}),this.addListener("take_caught_err",()=>{this.hasErr()||this._backward_if_ready()})}_on_input_data(t){this._i[t]!==void 0&&this._active_i_count===this._i_count&&(this._looping=!1),this._forward_if_ready()}_on_input_drop(t,e){this._active_i_count===this._i_count-1&&!this._backwarding&&!this._forwarding_empty&&(this._looping=!1,this._catchErr?this.takeCaughtErr():this.takeErr(),this.d(t,e),this._forward_all_empty())}_on_input_invalid(t){this._i_invalid_count===1&&(this.i(t),this._invalidate())}onDataInputData(t){this._on_input_data(t)}onDataInputDrop(t,e){this._on_input_drop(t,e)}onDataInputStart(t){this._i_start_count===this._i_count&&this._start()}onDataInputInvalid(t){this._on_input_invalid(t)}onDataInputEnd(t){this._i_start_count===this._i_count-1&&this._end()}onRefInputData(t){this._on_input_data(t)}onRefInputDrop(t,e){this._on_input_drop(t,e)}onRefInputInvalid(t){this._on_input_invalid(t)}onDataOutputDrop(t){this._on_data_output_drop(t)}f(t,e){}i(t){}d(t,e){}_backward_if_ready(){!this._forwarding_empty&&!this._forwarding&&!this._err&&!this._caughtErr&&this._active_o_count===0&&(this._looping=!1,this._backward_all(),this._forward_if_ready())}_forward_if_ready(){for(;this._active_o_count-this._o_invalid_count===0&&this._active_i_count-this._i_invalid_count===this._i_count&&!this._forwarding&&!this._backwarding&&!this._looping;)this._looping=!0,this._err!==null&&(this._forwarding_empty=!0,this.takeErr(),this._forwarding_empty=!1),this.f(this._i,this._done)}snapshotSelf(){return Z(_({},super.snapshotSelf()),{_looping:this._looping})}restoreSelf(t){let o=t,{_looping:e}=o,i=bt(o,["_looping"]);super.restoreSelf(i),this._looping=e}};var A3="_5d09d860-a8fe-428b-befd-7c793bc0783c",Cn=class extends l{constructor(n){super({i:[],o:[]},{},n,A3),this.play()}f(n,t){t(n)}};function Ic(r,n){let t=!1;if(Kt(n)>0){let e=at(n),i=n[e],o=at(i),a=at(i[o]);r.getUnit(e).isPinRef(o,a)&&(t=!0)}return t}function C3(r,n,t,e,i,o,a,s,p,d,c){var K;let{nextIdMap:m,nextPinIdMap:f,nextSubComponentParentMap:g,nextSubComponentChildrenMap:h}=i,x=r.getUnit(e),y=((K=m.unit)==null?void 0:K[e])||e,I=g[e]||null,v=h[e]||[],T=f[e]||{},P=s[e]||{input:new Set,output:new Set},H=r.getSpec(),{units:U,component:B={}}=H,{subComponents:J={}}=B,q=U[e],w=J[e];if(r.removeUnit(e,!1,!1,!1),n.addUnit(y,x,void 0,!1),I&&n.hasUnit(I)){let L=h[I].indexOf(y);n.moveRoot(I,y,L,"default")}if(v)for(let L=0;L<v.length;L++){let z=v[L];n.hasUnit(z)&&n.moveRoot(y,z,L,"default")}if(w){let{metadata:{component:L}={}}=q;L&&typeof L.width=="number"&&typeof L.height=="number"&&n.setUnitSize(y,L.width,L.height)}let E=(L,z)=>{var R,X;let{pinId:rt,subPinId:N,plug:nt,mergeId:M,merge:k}=W(T,[L,z],{});if(!P[L].has(z)&&!x.isPinIgnored(L,z)){let ct=M&&(!p.has(M)||c);if(c||n.hasPinNamed(L,rt)||Hd(d[L]||{},({plug:ot={}},it)=>{for(let dt in ot){let Et=ot[dt];if(Et.unitId===e&&Et.pinId===z){r.unplugPin(L,it,dt,!1,!1);break}}}),rt&&N){if(c){M&&n.hasMergePin(M,t,L,rt)&&n.removePinOrMerge(M,t,L,rt,!1,!1);let{pinId:it,subPinId:dt}=((X=(R=o.plugs)==null?void 0:R[L])==null?void 0:X[z])||{};it&&dt&&it===rt&&(n.hasPinNamed(L,it)?(n.hasPlug(L,it,dt)&&n.unplugPin(L,it,dt,!1,!1),n.plugPin(L,it,dt,{unitId:y,pinId:z},!1,!1)):n.exposePinSet(L,it,{plug:{[dt]:{unitId:y,pinId:z}}},void 0,!1,!1))}else if(n.hasPinNamed(L,rt))n.exposePin(L,rt,N,{unitId:y,pinId:z},!1,!1);else{let it=x.isPinRef(L,z),dt=x.getPinData(L,z);n.exposePinSet(L,rt,{plug:{0:{unitId:y,pinId:z}},ref:it},dt,!1,!1),A(d[L]||{},({plug:Et},xt)=>{for(let Pt in Et){let Rt=Et[Pt];if(Rt.unitId===e&&Rt.pinId===z){r.plugPin(L,xt,Pt,{unitId:t,pinId:rt},!1,!1);break}}})}x.isPinConstant(L,z)&&(c||(n.setUnitPinConstant(e,L,z,!1,!1),n.setPinConstant(L,rt,!0))),ct&&(c?(n.hasMergePin(M,t,L,z)&&n.removePinOrMerge(M,t,L,z,!1,!1),n.hasMerge(M)||n.addMerge(k!=null?k:{},M,!1,!1),n.hasMergePin(M,y,L,z)||n.addPinToMerge(M,y,L,z,!1,!1)):(r.hasMerge(M)||(r.addMerge({},M,!1,!1),St(k,(it,dt,Et)=>{r.hasUnit(it)&&r.addPinToMerge(M,it,dt,Et,!1,!1)})),r.hasMergePin(M,t,L,rt)||r.addPinToMerge(M,t,L,rt,!1,!1)))}}if(nt){let{type:ct,pinId:ot,subPinId:it,kind:dt=ct}=nt;c||n.hasPlug(ct,ot,it)&&n.plugPin(ct,ot,it,{unitId:y,pinId:ot,kind:dt})}},$=x.getInputNames();for(let L of $)E("input",L);let G=x.getOutputNames();for(let L of G)E("output",L);E("output",lt)}function Hl(r,n,t,e,i,o,a,s,p,d,c,m=new Set,f){var y,I;if(m.has(e)&&t!==e)return;let{nextPinIdMap:g}=s,{mergeId:h,merge:x}=W(g,[i,o],{pinId:void 0,subPinId:void 0});if(t===e){if(!f){let v=n.isPinConstant(i,o),T=j(n.getExposedPinSpec(i,o));if(h&&x){let P=x[e],H=Kt(x),U=nm(P);H-U>0||n.coverPinSet(i,o,!1)}else n.coverPinSet(i,o,!1);if(v){let{plug:P={}}=T;for(let H in P){let U=P[H];if(U.unitId&&U.pinId)n.setUnitPinConstant(U.unitId,i,U.pinId,!0);else if(U.mergeId){let B=n.getMergeSpec(U.mergeId);St(B,(J,q,w)=>{n.setUnitPinConstant(J,q,w,!0)})}}}}}else{if(p&&d){let v=_t(i);if(f)r.hasPinNamed(v,d)&&r.coverPinSet(v,d,!1);else{if(!n.hasPinNamed(v,d)){let T=r.getUnit(e);a=a!=null?a:r.getUnitPinData(e,i,o);let P=T.isPinRef(i,o),H={plug:{0:{}},ref:P};n.exposePinSet(v,d,H,a,!1,!1)}if(r.hasMerge(p)){let T=r.getMergeSpec(p);(I=(y=T==null?void 0:T[t])==null?void 0:y[v])!=null&&I[d]||r.addPinToMerge(p,t,v,d,!1,!1),r.addPinToMerge(p,e,i,o,!1,!1)}else{let T={[e]:{[i]:{[o]:!0}},[t]:{[v]:{[d]:!0}}};r.addMerge(T,p,!1,!1)}}}if(c){let T=t!==e?{plug:{0:{unitId:e,pinId:o}}}:{plug:{0:{}}};n.exposePinSet(i,c.pinId,T,void 0,!1,!1),r.plugPin(i,c.pinId,c.subPinId,{unitId:t,pinId:c.pinId})}}}function M3(r,n,t,e,i,o,a,s,p=new Set,d,c){var w;let{nextIdMap:m,nextMergePinId:f}=a,g=(w=m.merge[e])!=null?w:e,{input:h=null,output:x=null}=f[e]||{},y=0,I=r.getMergeSpec(e),v={},{merges:T}=s,P=Kt(i),H=em(i,"input"),U=em(i,"output"),B=r.getMergeData(e);if(r.hasMerge(e)&&r.removeMerge(e,!1,!1),St(i,(E,$,G)=>{var M,k;let K=((M=m.unit)==null?void 0:M[E])||E;if(E===t&&!p.has(E)){let R=n.getExposedPinSpec($,G),{plug:X}=R;for(let ct in X){let ot=X[ct];if(ot.unitId&&ot.pinId)F(v,[ot.unitId,$,ot.pinId],!0);else if(ot.mergeId){let it=n.getMergeSpec(ot.mergeId);St(it,(dt,Et,xt)=>{F(v,[K,Et,xt],!0)})}}y++}else p.has(E)&&n.hasUnit(K)&&(F(v,[K,$,G],!0),y++);let z=!($==="input")&&!p.has(E),{mergeId:rt,pinId:N,subPinSpec:nt}=(k=z?h:x)!=null?k:{};Hl(r,n,t,E,$,G,B,a,rt,N,null,p,c)}),c){if(P===0||y>1){let E=o;n.addMerge(v,g,!1,E)}}else if(y===0&&(P===0||H>0&&U>0)||y>1){let E=o;n.addMerge(v,g,!1,E),ue(i!=null?i:{})===1&&at(i)===t&&St(i,($,G,K)=>{n.hasPinNamed(G,K)&&n.coverPinSet(G,K)})}let q=(E,$)=>{var rt,N,nt;let{mergeId:G,pinId:K,subPinSpec:L,oppositeMerge:z}=$;if(K&&L){if(c){n.hasMergePin(G,t,E,K)&&n.removeMerge(G,!1,!1);for(let M in T){let k=T[M],R=k[t];if((rt=R==null?void 0:R.output)!=null&&rt[lt])return;for(let X in R){let ct=R[X];for(let ot in ct){if(ot!==K)continue;let it=d[X][ot],{plug:dt}=it;for(let Et in dt){let xt=dt[Et];if(xt.mergeId){let Pt=((N=m.merge)==null?void 0:N[xt.mergeId])||xt.mergeId,Rt=j(k);delete Rt[t];let xe=at(Rt),bn=at(Rt[xe]),Rd=at(Rt[xe][bn]);if(n.hasMerge(Pt))St(Rt,(Gu,kd,Tf)=>{kd!==E&&!n.hasMergePin(Pt,Gu,kd,Tf)&&n.addPinToMerge(Pt,Gu,kd,Tf,!1)});else{let Gu={[xe]:{[bn]:{[Rd]:!0}}};n.hasMerge(Pt)||n.addMerge(Gu,Pt,!1,!1)}}else if(xt.unitId&&xt.pinId){let Pt=((nt=m.unit)==null?void 0:nt[xt.unitId])||xt.unitId;if(n.hasMerge(M))n.addPinToMerge(M,Pt,X,xt.pinId,!1);else if(z){let Rt=j(z);delete Rt[xt.unitId];let xe=at(Rt);if(!xe)continue;let bn=at(Rt[xe]),Rd=at(Rt[xe][bn]);n.addMerge({[Pt]:{[X]:{[xt.pinId]:!0}},[xe]:{[bn]:{[Rd]:!0}}},e,!1,!1,void 0)}}}}}}}else if(n.hasPinNamed(E,K)?n.exposePin(E,K,"0",L,!1,!1):n.exposePinSet(E,K,{plug:{0:L}},void 0,!1,!1),!r.hasMerge(G)&&z){let M=j(z);delete M[L.unitId],St(z,R=>{p.has(R)&&delete M[R]});let k=at(M);if(k){let R=at(M[k]),X=at(M[k][R]);r.addMerge({[t]:{[E]:{[K]:!0}},[k]:{[R]:{[X]:!0}}},G,!1,!1,void 0)}}}};h&&q("input",h),x&&q("output",x),am(d,(E,$)=>{Nt($,(G,K)=>{var z,rt;if(W(a,["nextPlugSpec",E,G],void 0))return;let{plug:L}=K;for(let N in L)if(L[N].mergeId===e){let{mergeId:M,oppositeMerge:k}=(z=E==="input"?h:x)!=null?z:{};if(c){if(om(I)){let R=n.getExposedPinSpecs();if(Nt((rt=R[E])!=null?rt:{},(X,ct)=>{let{plug:ot={}}=ct;for(let it in ot){let dt=ot[it];dt.unitId===t&&dt.pinId===X&&(n.unplugPin(E,X,it,!1,!1),n.plugPin(E,X,it,{mergeId:M},!1,!1))}}),!M||!k)continue;n.hasMerge(g)?St(k,(X,ct,ot)=>{X!==t&&(n.hasMergePin(g,X,ct,ot)||n.addPinToMerge(g,X,ct,ot,!1,!1))}):n.addMerge(k,g,!1,!1)}}else if(r.hasPlug(E,G,N)){let R=M?{mergeId:M}:{unitId:t,pinId:G},X=n.hasMerge(g),ct=r.getPinData(E,G);n.hasPinNamed(E,G)?n.plugPin(E,G,N,X?{mergeId:g}:{},!1,!1):n.exposePinSet(E,G,{plug:{[N]:X?{mergeId:g}:{}}},ct,!1,!1),r.hasPinNamed(E,G)?(r.hasPlug(E,G,N)&&r.unplugPin(E,G,N,!1,!1),r.plugPin(E,G,N,R,!1,!1)):r.exposePinSet(E,G,{plug:{[N]:R}},void 0,!1,!1)}}})})}function P3(r,n,t,e,i,o,a,s,p,d,c,m){var T;let f=r.getExposedPinSpec(e,i),g;if(f){let P=ue((T=f.plug)!=null?T:{});g=r.getPinData(e,i),P===1?r.coverPinSet(e,i,!1):r.coverPin(e,i,a,!1)}let h=W(m,["plug",e,i,a,"type"],e),x=W(m,["plug",e,i,a,"subPinId"],a),y=W(p,[e,i,a],void 0);if(!s){r.exposePinSet(e,i,{plug:{[a]:{}}},void 0,!1,!1);return}if(!y)return;let{pinId:I=s.pinId}=y,v=y;if(y.unitId&&y.pinId&&n.hasUnit(y.unitId)||y.mergeId&&n.hasMerge(y.mergeId)||(v={}),n.hasPinNamed(h,i)?n.hasPlug(h,i,x)?n.plugPin(h,i,x,v,!1,!1):n.exposePin(h,i,x,v,!1,!1):n.exposePinSet(h,i,{plug:{[x]:v},ref:!!o.ref},g,!1,!1),!!s){if(s.unitId&&s.pinId){let P=W(m,["link",s.unitId,s.type,i,"mergeId"],null);P?r.addPinToMerge(P,t,h,I,!1,!1):(P=W(m,["plug",e,i,a,"mergeId"],null),P&&(r.hasMerge(P)?r.addPinToMerge(P,t,h,I,!1,!1):r.addMerge({[t]:{[h]:{[I]:!0}},[s.unitId]:{[e]:{[s.pinId]:!0}}},P,!1,!1,void 0)))}else if(s.mergeId){let P=W(c,["merge",s.mergeId,e],W(m,["plug",e,i,a,"mergeId"],null));P&&r.addPinToMerge(P,t,h,I!=null?I:i,!1,!1)}}}function pm(r,n,t,e,i,o=!0){let{nodeIds:a,nextIdMap:s,nextPinIdMap:p,nextMergePinId:d,nextPlugSpec:c,nextSubComponentParentMap:m,nextSubComponentChildrenMap:f}=e,{merge:g=[],link:h=[],unit:x=[],plug:y=[]}=a,I=j(r.getMergesSpec()),v=j(r.getExposedPinSpecs()),T=Vu(I,(w,E)=>Ic(r,E)),P={},H=new Set(x),U=new Set(g),B=(w,E,$)=>{P[w]=P[w]||{input:new Set,output:new Set},P[w][E].add($)},J=(w,E,$)=>{let G;return Bt(v,(K,L,z)=>{let{plug:rt}=z;for(let N in rt){let nt=rt[N];nt.unitId===w&&nt.pinId===$&&(G={type:K,pinId:L,subPinId:N})}}),G};for(let{unitId:w,type:E,pinId:$}of h){let G=J(w,E,$);G&&!y.find(K=>K.type===G.type&&K.pinId===G.pinId&&K.subPinId===G.subPinId)||B(w,E,$)}let q={};for(let w of g)if(r.hasMerge(w)){let E=r.getMergeSpec(w);q[w]=E,St(E,($,G,K)=>{B($,G,K)})}for(let{unitId:w,type:E,pinId:$}of h){let{mergeId:G,oppositePinId:K}=W(s,["link",w,E,$],{mergeId:null,oppositePinId:null});Hl(r,n,t,w,E,$,void 0,e,G,K,null,H,o)}for(let w of x)C3(r,n,t,w,e,i,H,P,U,v,o);for(let w of g){let E=I[w],$=T[w];M3(r,n,t,w,E,$,e,i,H,v,o)}for(let{type:w,pinId:E,subPinId:$}of y){let G=pt(v,[w,E]),K=W(v,[w,E,"plug",$],void 0);P3(r,n,t,w,E,G,$,K,c,p,d,s)}}function vc(r,n){let t=_({},r);return delete t[n],t}var Vl=(r,n,t)=>{let e={};return A(n,(i,o)=>{e[o]={},A(i,(a,s)=>{e[o][r===s?t:s]=a})}),e};var Lt=class extends Q{constructor(t,e={},i,o){super({i:[],o:[]},{},i,o!=null?o:t.id);this.__=["U","C","G","EE"];this._element=!1;this._unit={};this._merge={};this._pipedFrom={};this._pipedTo={};this._errUnitIds=[];this._pin={};this._unitPins={};this._exposedPin={};this._exposedMerge={};this._exposedEmptySubPin={input:{},output:{}};this._mergeToSelfUnit={};this._selfUniToMerge={};this._pinToMerge={};this._branch={};this._mergePinCount={};this._unitToMerge={};this._unitToMergeCount={};this._children=[];this._animations=[];this._stopPropagation={};this._stopImmediatePropagation={};this._preventDefault={};this._waitAll={};this._onPinSetRenamed=(t,e,i,o,a)=>{let s=_t(t),{functional:p}=o,d=pt(this._exposedPin,[t,e]),c=pt(this._exposedMerge,[t,e,t]),m=pt(this._exposedMerge,[t,e,s]);c.renamePin(t,e,i),m.renamePin(s,e,i),p&&this._unplugFromWaitAll(t,e),fe(this._exposedPin,[t,e]),fe(this._exposedMerge,[t,e,t]),fe(this._exposedMerge,[t,e,s]),F(this._exposedPin,[t,i],d),F(this._exposedMerge,[t,i,t],c),F(this._exposedMerge,[t,i,s],m);let f=pt(this._exposedEmptySubPin,[t,e]);for(let x in _({},f)){let y=f[x];delete f[x],F(f,[t,i,x],y)}let g=this.getExposedPinSpec(t,i),{plug:h={}}=g;for(let x in h){let y=h[x];y.unitId&&y.pinId&&F(this._pinToPlug,[y.unitId,t,y.pinId],{pinId:i,subPinId:x})}};this._refMergePin=(t,e)=>{let i=At(t,e);return this._pin[i]};this._plugToWaitAll=(t,e)=>{let i=_t(t),o=new Ut,a=this.getExposedPin(t,e),s=this._waitAll[t];s.addPin(t,e,o,{}),s.setPin(i,e,a),this.setPin(t,e,o,{})};this._unplugFromWaitAll=(t,e)=>{let i=_t(t),o=this.getExposedInputPin(e),a=this._waitAll[t];a.removePin(t,e),a.removePin(i,e),this.setPin(t,e,o,{})};this._getExposedSubPinNodeId=(t,e)=>{let{unitId:i,pinId:o,mergeId:a}=e;return a?At(a,t):Jt(i,t,o)};this._ensureMergePin=(t,e,i=!1)=>{let o=At(e,t),a=this._pin[o];if(!this._pin[o]){let s=_t(t);a=new Ut,this._pin[o]=a,this._setBranch(e,s,o,i)}return a};this._memEnsureMergePin=(t,e)=>{let i=At(e,t);if(!this._pin[i]){let o=_t(t),a=new Ut;this._pin[i]=a,this._memSetBranch(e,o,i)}};this._removeMergeOutput=t=>{this._simRemoveMergeOutput(t),this._memRemoveMergeOutput(t)};this._memRemoveMergeOutput=t=>{let e=At(t,"output");this._pin[e]&&(this._memRemoveBranch(t,"input",e),delete this._pin[e])};this._simRemoveMergeOutput=t=>{let e=At(t,"output");this._pin[e]&&this._simRemoveBranch(t,"input",e)};this._plugPinToMerge=(t,e,i,o,a,s=!0)=>{let p=At(o,t);this._ensureMergePin(t,o,s);let d=this._pin[p];this._setExposedSubPin(t,e,t,i,d,a,s)};this._simPlugPinToMerge=(t,e,i,o,a=!0)=>{let s=At(o,t);this._ensureMergePin(t,o,a);let p=this._pin[s];this._simSetExposedSubPin(t,e,t,i,p,a)};this._simUnplugPinFromMerge=(t,e,i,o)=>{this._simRemoveExposedSubPin(t,e,i)};this._simUnplugPinFromUnitPin=(t,e,i,o,a,s)=>{this._simRemoveExposedSubPin(t,e,i)};this._plugPinToUnitPin=(t,e,i,o,a,s,p,d=!1)=>{this._memPlugPinToUnitPin(t,e,i,o,a,s),this._simPlugPinToUnitPin(t,e,i,o,a,s,d)};this._memPlugPinToUnitPin=(t,e,i,o,a,s)=>{let p=this.getUnitPin(o,a,s);F(this._pinToPlug,[o,t,s],{pinId:e,subPinId:i,kind:a}),this._memSetExposedSubPin(t,e,i,p)};this._memPlugPinToMerge=(t,e,i,o)=>{};this._simPlugPinToUnitPin=(t,e,i,o,a,s,p=!0)=>{let d=this.getUnitPin(o,a,s);this._simSetExposedSubPin(t,e,a,i,d,p)};this._takeErr=()=>{if(this._errUnitIds.length>0){let t=this._errUnitIds[0];this._unit[t].takeErr()}};this._nextErr=()=>{if(this._errUnitIds.length>0){let t=this._errUnitIds[0],i=this.getUnit(t).getErr();this.err(i)}else this.takeErr()};this._destroy=()=>{A(this._unit,t=>t.destroy()),A(this._merge,t=>t.destroy())};this._reset=()=>{};this.specHasMerge=t=>!!this._spec.merges[t];this.getSpec=()=>this._spec;this.getComponentSpec=()=>this._spec.component;this.getUnits=()=>this._unit;this.exposeOutputSets=t=>{this._exposeOutputSets(t)};this._exposeOutputSets=t=>{A(t,this._exposeOutputSet)};this.exposeOutputSet=(t,e,i)=>{this.exposePinSet("output",e,t,i)};this._exposeOutputSet=(t,e,i)=>{this._exposePinSet("output",e,t,i)};this.exposeOutput=(t,e,i)=>{this.exposePin("output",i,t,e)};this.coverOutputSet=t=>{this.coverPinSet("output",t)};this.coverOutput=(t,e)=>{this.coverPin("output",e,t)};this.plugOutput=(t,e,i)=>{this.plugPin("input",i,t,e)};this.unplugOutput=(t,e)=>{this.unplugPin("output",e,t)};this._unplugOutput=(t,e)=>{this._unplugPin("output",e,t)};this.exposeInputSets=t=>{A(t,this.exposeInputSet)};this._exposeInputSets=t=>{A(t,this._exposeInputSet)};this._initInputSets=t=>{Nt(t,this._initPinSet.bind(this,"input"))};this._initOutputSets=t=>{Nt(t,this._initPinSet.bind(this,"output"))};this.exposeInputSet=(t,e,i)=>{this.exposePinSet("input",e,t,i)};this._exposeInputSet=(t,e,i)=>{this._exposePinSet("input",e,t,i)};this.exposePinSet=(t,e,i,o=void 0,a=!0,s=!0)=>{this._exposePinSet(t,e,i,o,s),o=this.getPin(t,e).peak(),a&&this.emit("expose_pin_set",t,e,i,o,[]),this._transacting&&this._transaction.push(Il(t,e,i,o))};this._exposePinSet=(t,e,i,o,a=!0)=>{let s=new Ut({data:o}),p=new Wt(this.__system),d=new Wt(this.__system);this._fork(),this._specExposePinSet(t,e,i),this._memExposePinSet(t,e,i,s,p,d),this._simExposePinSet(t,e,i,s,p,d,a)};this._initPinSet=(t,e,i,o=!0)=>{let{ref:a}=i,s=new Ut({ref:a}),p=new Wt(this.__system),d=new Wt(this.__system);this._memExposePinSet(t,e,i,s,p,d),this._simExposePinSet(t,e,i,s,p,d,o)};this._specExposePinSet=(t,e,i)=>{F(this._spec,[`${t}s`,e],i);let{plug:o}=i;A(o,(a,s)=>{this._specExposePin(t,e,s,a)})};this._memExposePinSet=(t,e,i,o,a,s)=>{let{plug:p}=i,d=_t(t);F(this._exposedPin,[t,e],o),F(this._exposedMerge,[t,e,t],a),F(this._exposedMerge,[t,e,d],s),A(p,(c,m)=>{this._memExposePin(t,e,m,c)})};this.isPinSetFunctional=(t,e)=>!!this._spec[`${t}s`][e].functional;this.exposePin=(t,e,i,o,a=!0,s=!0)=>{this._exposePin(t,e,i,o,s),a&&this.emit("expose_pin",t,e,i,o,[]),this._transacting&&this._transaction.push(Dl(t,e,i,o))};this._exposePin=(t,e,i,o,a=!0)=>{this._specExposePin(t,e,i,o),this._memExposePin(t,e,i,o),this._simExposePin(t,e,i,o,a)};this._specExposePin=(t,e,i,o)=>{this._specPlugPin(t,e,i,o)};this._memExposePin=(t,e,i,o)=>{this._memPlugPin(t,e,i,o)};this._simExposePin=(t,e,i,o,a=!0)=>{let{unitId:s,pinId:p,mergeId:d}=o;d||s&&p?this._simPlugPin(t,e,i,o,a):this._simPlugEmptyPin(t,e,i,a)};this.exposeInput=(t,e,i,o=!0)=>{this.exposePin("input",i,t,e,o)};this.coverInputSet=t=>{this.coverPinSet("input",t)};this.coverInput=(t,e)=>{this.coverPin("input",e,t)};this.coverPinSet=(t,e,i=!0)=>{let o=this.getExposedPinSpec(t,e);this._coverPinSet(t,e),i&&this.emit("cover_pin_set",t,e,o,void 0,[]),this._transacting&&this._transaction.push(vl(t,e,o))};this._coverPinSet=(t,e)=>{this._fork(),this._simCoverPinSet(t,e),this._memCoverPinSet(t,e),this._specCoverPinSet(t,e)};this._memCoverPinSet=(t,e)=>{let i=this.getExposedPinSpec(t,e),{plug:o}=i;A(o,(p,d)=>{this._memCoverPin(t,e,d)}),fe(this._exposedPin,[t,e]);let a=pt(this._exposedMerge,[t,e,"input"]),s=pt(this._exposedMerge,[t,e,"output"]);fe(this._exposedMerge,[t,e,"input"]),fe(this._exposedMerge,[t,e,"output"]),a.destroy(),s.destroy()};this._specCoverPinSet=(t,e)=>{let i=this.getExposedPinSpec(t,e),{plug:o}=i;A(o,(a,s)=>{this._specCoverPin(t,e,s)}),Ul({type:t,pinId:e},this._spec)};this._simCoverPinSet=(t,e)=>{let i=this.getExposedPinSpec(t,e),{plug:o}=i;A(o,(a,s)=>{this._simCoverPin(t,e,s)}),this.removePin(t,e)};this._specSetPinRef=(t,e,i)=>{F(this._spec,[`${t}s`,e,"ref"],i)};this._memPlugPin=(t,e,i,o)=>{let{mergeId:a,unitId:s,pinId:p,kind:d=t}=o,c;if(s&&p)(this.isUnitRefPin(s,d,p)||p===lt)&&(c=!0),this._memPlugPinToUnitPin(t,e,i,s,d,p);else if(a){let m=this.getMergeSpec(a);St(m,(f,g,h)=>{this.getUnit(f).hasRefPinNamed(g,h)&&(c=!0)}),this._mergeToSelfUnit[a]&&(c=!0),this._memPlugPinToMerge(t,e,i,a)}else this._memPlugEmptyPin(t,e,i);return c};this._specPlugPin=(t,e,i,o)=>{let{mergeId:a,unitId:s,pinId:p,kind:d=t}=o,c;if(s&&p)(this.isUnitRefPin(s,d,p)||p===lt)&&(c=!0);else if(a){let m=this.getMergeSpec(a);St(m,(f,g,h)=>{this.getUnit(f).isPinRef(g,h)&&(c=!0)}),this._mergeToSelfUnit[a]&&(c=!0)}c!==void 0&&this._specSetPinRef(t,e,c),Ll({type:t,pinId:e,subPinId:i,subPinSpec:o},this._spec)};this.plugPin=(t,e,i,o,a=!0,s=!0)=>{this._plugPin(t,e,i,o,s),a&&this.emit("plug_pin",t,e,i,o,[])};this._memRemoveEmptyPin=(t,e,i)=>{var o;delete this._exposedEmptySubPin[t][e][i],(o=this._exposedEmptySubPin[t])!=null&&o[e]&&ue(this._exposedEmptySubPin[t][e])===0&&delete this._exposedEmptySubPin[t][e]};this._simUnplugPinFromEmpty=(t,e,i)=>{this._simRemoveExposedSubPin(t,e,i)};this._plugPin=(t,e,i,o,a=!0)=>{let{mergeId:s,unitId:p,pinId:d,kind:c=t}=o;W(this._exposedEmptySubPin,[t,e,i],void 0)&&(this._simUnplugPinFromEmpty(t,e,i),this._memRemoveEmptyPin(t,e,i)),this._specPlugPin(t,e,i,o);let m=this._memPlugPin(t,e,i,o),f={ref:!!m};s?this._plugPinToMerge(t,e,i,s,f,a):p&&d&&this._plugPinToUnitPin(t,e,i,p,c,d,f,a),m!==void 0&&this.setPinRef(t,e,m)};this.isRefMerge=t=>{let e=this.getMergeSpec(t);return Ic(this,e)};this._simPlugPin=(t,e,i,o,a=!0)=>{let{mergeId:s,unitId:p,pinId:d,kind:c=t}=o;s?(a=a||this.isRefMerge(s),this._simPlugPinToMerge(t,e,i,s,a)):(a=a||this.isUnitPinRef(p,c,d),this._simPlugPinToUnitPin(t,e,i,p,c,d,a))};this.plugInput=(t,e,i)=>{this.plugPin("input",i,t,e)};this.unplugInput=(t,e)=>{this.unplugPin("input",e,t)};this._unplugInput=(t,e)=>{this._unplugPin("input",e,t)};this.coverPin=(t,e,i,o=!0)=>{let a=this.getSubPinSpec(t,e,i);this._coverPin(t,e,i),o&&this.emit("cover_pin",t,e,i,a,[]),this._transacting&&this._transaction.push(Sl(t,e,i,a))};this._coverPin=(t,e,i)=>{this._fork(),this._simCoverPin(t,e,i),this._memCoverPin(t,e,i),this._specCoverPin(t,e,i)};this._specCoverPin=(t,e,i)=>{wl({type:t,pinId:e,subPinId:i},this._spec)};this._memCoverPin=(t,e,i)=>{let a=this._spec[`${t}s`][e].plug[i],{mergeId:s}=a;t==="output"&&s&&this._memRemoveMergeOutput(s),this._memUnplugPin(t,e,i)};this._simCoverPin=(t,e,i)=>{let o=this.getSubPinSpec(t,e,i),{mergeId:a,unitId:s,pinId:p}=o;this._simUnplugPin(t,e,i),(a||s&&p)&&this._simRemoveExposedSubPin(t,e,i)};this.getSubPinSpec=(t,e,i)=>{var o,a,s;return(s=(a=(o=this._spec[`${t}s`])==null?void 0:o[e])==null?void 0:a.plug)==null?void 0:s[i]};this.unplugPin=(t,e,i,o=!0,a=!0)=>{let s=this.getSubPinSpec(t,e,i);this._unplugPin(t,e,i,a),o&&this.emit("unplug_pin",t,e,i,s,[])};this._unplugPin=(t,e,i,o=!0)=>{this._fork();let a=this.getSubPinSpec(t,e,i);this._simUnplugPin(t,e,i,o),this._memUnplugPin(t,e,i),this._specUnplugPin(t,e,i);let{mergeId:s}=a;s&&this.getMergePinCount(s)===0&&this._removeMerge(s,!1)};this._specUnplugPin=(t,e,i)=>{Gl({type:t,pinId:e,subPinId:i},this._spec)};this._memUnplugPin=(t,e,i)=>{let o=this.getSubPinSpec(t,e,i);if(o.unitId&&o.pinId&&Vt(this._pinToPlug,[o.unitId,t,o.pinId]),t==="output"){let{mergeId:s}=o;s&&this._memRemoveMergeOutput(s)}};this._ensureEmptySubPin=(t,e,i)=>{let o=W(this._exposedEmptySubPin,[t,e,i],null);return o||(o=new Ut,F(this._exposedEmptySubPin,[t,e,i],o)),o};this._memPlugEmptyPin=(t,e,i)=>{let o=this._ensureEmptySubPin(t,e,i);this._memSetExposedSubPin(t,e,i,o)};this._simUnplugPin=(t,e,i,o=!0)=>{this.__simUnplugPin(t,e,i,o),this._simPlugEmptyPin(t,e,i)};this.__simUnplugPin=(t,e,i,o=!0)=>{let a=this.getSubPinSpec(t,e,i),{mergeId:s,unitId:p,pinId:d,kind:c=t}=a,m=t==="output";m&&s&&this._simRemoveMergeOutput(s);let f=this.getPin(t,e),g=this.hasRefPinNamed(t,e);if(s)this._simUnplugPinFromMerge(t,e,i,s);else if(p&&d){let h=this.getUnit(p),x=h.isPinRef(t,d);this._simUnplugPinFromUnitPin(t,e,i,p,d,c),o&&x&&(m?f.take():h.takePin(t,d))}if(g){let h=_t(t),x=pt(this._exposedMerge,[t,e,t]),y=pt(this._exposedMerge,[t,e,h]);x.reset(),y.reset()}};this._simPlugEmptyPin=(t,e,i,o=!0)=>{let a=this._ensureEmptySubPin(t,e,i);this._simSetExposedSubPin(t,e,t,i,a,o)};this._memUnplugInput=(t,e)=>this._memUnplugPin("input",t,e);this._memUnplugOutput=(t,e)=>this._memUnplugPin("output",t,e);this._simUnplugInput=(t,e)=>this._simUnplugPin("input",t,e);this._simUnplugOutput=(t,e)=>this._simUnplugPin("output",t,e);this.getExposedPin=(t,e)=>t==="input"?this.getExposedInputPin(e):this.getExposedOutputPin(e);this.getExposedInputPin=t=>pt(this._exposedPin,["input",t]);this.getExposedOutputPin=t=>pt(this._exposedPin,["output",t]);this.getUnitOuterSpec=t=>{let e={merges:{input:{},output:{}},exposed:{input:{},output:{}}},i=this._unitToMerge[t]||new Set,o=this._unitToMergeCount[t]||0;for(let a of i){let s=o[a];this._forEachUnitPinOnMerge(t,a,(p,d)=>{if(this.getMergePinCount(a)-s<2){let m=this.getMergeSpec(a),f=at(Gf(m,t)),g=m[f],h,x;g.input?(h="input",x=at(g.input)):(h="output",x=at(g.output)),F(e.merges,[p,d],{mergeId:a,otherPin:{unitId:f,type:h,pinId:x}})}else F(e.merges,[p,d],{mergeId:a,otherPin:null})})}return e};this.getGraphPinData=()=>{let t={};return A(this._unit,(e,i)=>{let o=e.getPinsData();t[i]=o}),t};this.getGraphMergeInputData=()=>{let t={};return A(this._merge,(e,i)=>{let o=At(i,"input"),a=this._pin[o];if(a){if(this.getMergePinCount(i)===0)return;let s=a.peak();t[i]=s}}),t};this.getGraphErr=()=>{let t={};return A(this._unit,(e,i)=>{let o=e.getErr();t[i]=o}),t};this.getUnitInputData=t=>this.getUnit(t).getInputData();this.addUnit=(t,e,i,o=!0)=>{this._addUnit(t,e,i);let a=i!=null?i:e.getUnitBundleSpec();o&&this.emit("add_unit",t,a,e,[]),this._transacting&&this._transaction.push(_l(t,a))};this._addUnit=(t,e,i=null)=>{if(this._fork(),this._unit[t])throw new Error("duplicated unit id "+t);return i=i!=null?i:e.getUnitBundleSpec(!1),this.__system.injectSpecs(i.specs),this.emit("before_add_unit",t,e,[]),this._specAddUnit(t,e,i),this._memAddUnit(t,e,i),this._simAddUnit(t,i,e),e};this.addUnitSpecs=t=>{this._addUnitSpecs(t)};this._addUnitSpecs=t=>{A(t,(e,i)=>{this._addUnitBundleSpec(i,{unit:e})})};this.injectSubComponent=(t,e,i)=>{this._specInjectSubComponent(t),this._simInjectSubComponent(t,e,i)};this._simInjectSubComponent=(t,e,i)=>{let{classes:o}=this.__system,{children:a=[]}=e;for(let s of a){let{id:p}=s,d=le(p,this.__system.specs,o);i.appendChild(d)}};this._injectSubComponent=(t,e,i)=>{let{classes:o}=this.__system,{children:a=[]}=e;for(let s of a){let{id:p}=s,d=le(p,this.__system.specs,o);i.appendChild(d)}this._specInjectSubComponent(t)};this._specInjectSubComponent=t=>{F(this._spec,["component","subComponents",t],{children:[]})};this.componentAppend=(t,e)=>{this._specAppendRoot(t),this.emit("component_append",t,e,[])};this._specAppendRoot=t=>{this._spec.component.children=this._spec.component.children||[],this._spec.component.children.push(t)};this.componentRemove=t=>{this._specComponentRemoveChild(t),this.emit("component_remove",t,[])};this._specComponentRemoveChild=t=>{let e=this._spec.component.children.indexOf(t);this._spec.component.children.splice(e,1)};this.removeSubComponent=t=>{this._specRemoveSubComponent(t)};this._specRemoveSubComponent=t=>{let{subComponents:e}=this._spec.component,i=e[t],{children:o=[]}=i;for(let a of o)this._spec.component.children.push(a);delete e[t]};this._getSubComponentParentId=t=>sm(this._spec,t);this._getSubComponentSlotName=t=>{let e=this._getSubComponentParentId(t);return W(this._spec,["component","subComponents",e,"childSlot",t],"default")};this._appendSubComponentChild=(t,e,i)=>{this._fork(),this._specSubComponentAppendChild(t,e,i),this._simSubComponentAppendChild(t,e,i)};this._insertSubComponentChild=(t,e,i,o)=>{this._fork(),this._specSubComponentInsertChild(t,e,i,o),this._simSubComponentInsertChild(t,e,i,o)};this._simRemoveSubComponentFromParent=t=>{let e=this._getSubComponentParentId(t);e?this._simSubComponentRemoveChild(e,t):this._simRemoveRoot(t)};this._specRemoveSubComponentChild=(t,e)=>{let i=this._spec.component.subComponents[t],{children:o=[],childSlot:a={}}=i,s=o.indexOf(e);o.splice(s,1),delete a[e],i.children=o,i.childSlot=a};this._specRemoveSubComponentFromParent=t=>{let e=this._getSubComponentParentId(t);e?this._specRemoveSubComponentChild(e,t):this._specRemoveRoot(t)};this._simSubComponentRemoveChild=(t,e)=>{let i=this.getUnit(t),o=this.getUnit(e);i.removeParentChild(o),this.registerRoot(o)};this._specSubComponentAppendChild=(t,e,i)=>{let o=this._spec.component.subComponents[t],{children:a=[],childSlot:s={}}=o;a.push(e),s[e]=i,o.children=a,o.childSlot=s};this._specSubComponentInsertChild=(t,e,i,o)=>{let a=this._spec.component.subComponents[t],{children:s=[],childSlot:p={}}=a;s.splice(i,0,e),p[e]=o,a.children=s,a.childSlot=p};this._simSubComponentAppendChild=(t,e,i)=>{let o=this.getUnit(t),a=this.getUnit(e);o.registerParentRoot(a,i)};this._simSubComponentInsertChild=(t,e,i,o)=>{let a=this.getUnit(t),s=this.getUnit(e);a.registerParentRoot(s,o)};this._unitUnlisten={};this.addUnitBundle=(t,e)=>{this._addUnitBundle(t,e)};this._addUnitBundle=(t,e)=>{};this.setUnitPin=(t,e,i)=>{let o=this.getUnit(t),a=Jt(t,e,i),s=o.getPin(e,i);this._pin[a]=s,this._unitPins[a]=s};this.setUnitInput=(t,e)=>{this.setUnitPin(t,"input",e)};this.setUnitOutput=(t,e)=>{this.setUnitPin(t,"output",e)};this._on_unit_element=(t,e,i)=>{this.injectSubComponent(t,e,i)};this._on_unit_not_element=t=>{this._specRemoveSubComponent(t)};this._simRemoveUnit=(t,e=!0)=>{var a;let i=this.getUnit(t);i.hasErr()&&this._removeErrUnit(t);let o=this.getExposedOutput({unitId:t,pinId:lt,kind:"output"});if(this._simUnplugUnit(t,e),e&&o&&this.takeOutput(o),i.isElement()){let s=(a=this._spec.component)==null?void 0:a.subComponents[t],{children:p=[]}=s;for(let d of p)this._simSubComponentRemoveChild(t,d);this._simRemoveSubComponentFromParent(t)}};this._subComponentRemoveChild=(t,e)=>{this._simSubComponentRemoveChild(t,e),this._specRemoveSubComponentChild(t,e)};this._specUnplugUnit=t=>{let{merges:e}=this._spec,i=j(e);te(i,(o,a,s,p)=>{var c,m,f;let d=j(this.getMergeSpec(o));if(a===t&&d)if(delete d[t],Kt(d)<2){let h=this.findMergeExposedSubPin("input",o),x=this.findMergeExposedSubPin("output",o),y=j(this.getMergeSpec(o));delete y[t];let I=at(y),v=at((c=y==null?void 0:y[I])!=null?c:{}),T=at((f=(m=y==null?void 0:y[I])==null?void 0:m[v])!=null?f:{});this._specRemoveMerge(o),h&&this._specPlugPin("input",h.pinId,h.subPinId,{unitId:I,pinId:T,kind:v}),x&&this._specPlugPin("output",x.pinId,x.subPinId,{unitId:I,pinId:T,kind:v})}else this._specRemoveUnitFromMerge(t,o)}),this._forEachSpecPinPlug((o,a,s,p)=>{p.unitId===t&&this._specUnplugPin(o,a,s)})};this._unplugUnit=(t,e)=>{this._simUnplugUnit(t,e),this._memUnplugUnit(t),this._specUnplugUnit(t)};this._simUnplugUnit=(t,e)=>{var a,s,p,d;let i=this._unitToMerge[t]||new Set,o=this._unitToMergeCount[t]||{};for(let c of i){let m=o[c];if(this.getMergePinCount(c)-m<2){let g=this.findMergeExposedSubPin("input",c),h=this.findMergeExposedSubPin("output",c),x=j(this.getMergeSpec(c));delete x[t];let y=at(x),I=at((a=x==null?void 0:x[y])!=null?a:{}),v=at((p=(s=x==null?void 0:x[y])==null?void 0:s[I])!=null?p:{});this._simRemoveMerge(c,e),g&&this._simPlugPin("input",g.pinId,g.subPinId,{unitId:y,pinId:v,kind:(d=g.kind)!=null?d:"input"},!1),h&&this._simPlugPin("output",h.pinId,h.subPinId,{unitId:y,pinId:v,kind:I},!1)}else this._simRemoveUnitFromMerge(t,c,e)}this._forEachSpecPinPlug((c,m,f,g)=>{g.unitId===t&&this._simUnplugPin(c,m,f,e)})};this.addMerges=t=>{A(t,this.addMerge)};this._addUnitMerges=(t,e=!0)=>{A(t,(i,o)=>{this.hasMerge(o)?St(i,(a,s,p)=>{this.hasMergePin(o,a,s,p)||this._addPinToMerge(o,a,s,p,e)}):this._addMerge(i,o,void 0,e)})};this._addMerges=(t,e=!0)=>{A(t,(i,o)=>{this._addMerge(i,o,void 0,e)})};this._initMerges=t=>{Nt(t,this._initMerge)};this._initMerge=(t,e)=>{let i=this._createMerge(t);this._memAddMerge(t,e,i),this._simAddMerge(t,e,i)};this.addMerge=(t,e,i=!0,o=!0,a)=>{a=this._addMerge(t,e,a,o),i&&this.emit("add_merge",e,t,a,[]),this._transacting&&this._transaction.push(El(e,t))};this._createMerge=t=>{let e=new Wt(this.__system),i=At(t,"input"),o=new Ut;return e.addInput(i,o),e};this._pinToPlug={};this._addMerge=(t,e,i=null,o=!0)=>{this._fork(),i=i!=null?i:this._createMerge(e),this.emit("before_add_merge",e,t,i,[]);let a=[];return St(t,(s,p,d)=>{let c=W(this._pinToPlug,[s,p,d],void 0);c&&(a.push({type:p,pinId:c.pinId,subPinId:c.subPinId}),this._unplugPin(p,c.pinId,c.subPinId,!1))}),this._specAddMerge(e,t,i),this._memAddMerge(e,t,i),this._simAddMerge(e,t,i,o),Tt(a,s=>{this._plugPin(s.type,s.pinId,s.subPinId,{mergeId:e},o)}),i};this._specAddMerge=(t,e,i)=>{F(this._spec,["merges",t],e),A(e,({input:o,output:a},s)=>{A(o||{},(p,d)=>{this._specAddPinToMerge(t,s,"input",d)}),A(a||{},(p,d)=>{this._specAddPinToMerge(t,s,"output",d)})})};this._memAddMerge=(t,e,i)=>{this._merge[t]=i,A(e,({input:o,output:a},s)=>{A(o||{},(p,d)=>{this._memAddPinToMerge(t,s,"input",d)}),A(a||{},(p,d)=>{this._memAddPinToMerge(t,s,"output",d)})})};this.addPinToMerge=(t,e,i,o,a=!0,s=!0)=>{this._addPinToMerge(t,e,i,o,s),a&&this.emit("add_pin_to_merge",t,e,i,o,[])};this._addPinToMerge=(t,e,i,o,a=!0)=>{this._validateMergeId(t),this._validateUnitId(e);let s=W(this._pinToPlug,[e,i,o],void 0);s&&this._unplugPin(i,s.pinId,s.subPinId,a),this._specAddPinToMerge(t,e,i,o),this._memAddPinToMerge(t,e,i,o),this._simAddPinToMerge(t,e,i,o,a),s&&this._plugPin(i,s.pinId,s.subPinId,{mergeId:t},a)};this._simRemoveAllPlugsFromMerge=(t,e=!0)=>{this._forEachSpecPinPlug((i,o,a,s)=>{s.mergeId===t&&this._simUnplugPin(i,o,a,e)})};this.__simRemoveAllPlugsFromMerge=t=>{this._forEachSpecPinPlug((e,i,o,a)=>{a.mergeId===t&&this._simUnplugPin(e,i,o)})};this._forEachSpecPinPlug=t=>{this._forEachSpecPinOfType("input",(e,i,o)=>{t("input",e,i,o)}),this._forEachSpecPinOfType("output",(e,i,o)=>{t("output",e,i,o)})};this._forEachSpecPinOfType=(t,e)=>{A(this._spec[`${t}s`]||{},({plug:i},o)=>{for(let a in i){let s=i[a];e(o,a,s)}})};this._simRemoveAllPinsFromMerge=(t,e)=>{let i=j(this._spec.merges[t]);A(i,({input:o,output:a},s)=>{A(a||{},(p,d)=>{this._simRemovePinFromMerge(t,s,"output",d,e)}),A(o||{},(p,d)=>{this._simRemovePinFromMerge(t,s,"input",d,e)})})};this._settingUnitData=!1;this._getUnitPinPlug=(t,e,i)=>{let o;return Tn(this._spec,e,(a,s)=>{let{plug:p}=s;for(let d in p){let c=p[d];c.unitId===t&&c.pinId===a&&(o={type:e,pinId:a,subPinId:d})}}),o};this._newMergeId=()=>{let t=0,e=`${t}`;for(;this.hasMerge(e);)t++,e=`${t}`;return e};this._movePlugInto__inject=(t,e,i,o,a,s,p,d,c)=>{let m=this.getGraph(t),f=W(c,["plug",e,i,o,"type"],e),g=W(s,[e,i,o],{})};this._movePlugInto__reconnect=(t,e,i,o,a,s,p,d,c,m)=>{let f=_t(e),g=W(s,[e,i,o,"pinId"],i),h=pt(m,[e,i,o]),x=W(c,["plug",e,i,o,"type"],e),y=this.getGraph(t),I=W(s,[e,i,o],{});if(y.hasPinNamed(x,i)?y.exposePin(x,i,o,I,!1):(y.exposePinSet(x,i,{plug:{[o]:I}},!1),h.active()&&y.setPinData(x,i,h.peak())),a.unitId&&a.pinId){let v=W(c,["link",a.unitId,a.type,i,"mergeId"],null);v?this._addPinToMerge(v,t,x,g):(v=W(c,["plug",e,i,o,"mergeId"],null),v&&this._addMerge({[t]:{[x]:{[g]:!0}},[a.unitId]:{[e]:{[a.pinId]:!0}}},v,void 0,!1))}else if(a.mergeId){let v=W(d,["merge",a.mergeId,e],null);if(v)this._addPinToMerge(v,t,x,g,!1);else{let T=W(c,["plug",e,i,o,"mergeId"],null);T&&this._addPinToMerge(T,t,x,g)}}};this._transacting=!1;this._transaction=[];this.endTransaction=()=>{if(!this._transacting)throw new Error("transaction not started");this.emit("bulk_edit",this._transaction,!0,[]),this._transacting=!1};this._isUnitComponent=t=>this.getUnit(t).isElement();this._root=[];this._parent_root=[];this._parent_children=[];this._slot={};this._spec=t,this._spec.id||i.newSpec(this._spec);let a=ut(i.specs,{[o]:t});this._specs=a;let{inputs:s={},outputs:p={},units:d={},merges:c={},component:m={},render:f=!1}=this._spec;this._branch=e,this._initAddUnits(d),this._initMerges(c),this._initInputSets(s),this._initOutputSets(p),this._initSetComponent(m),this._element=f,this.addListener("reset",this._reset),this.addListener("play",this._play),this.addListener("pause",this._pause),this.addListener("destroy",this._destroy),this.addListener("take_err",this._takeErr),this.addListener("take_caught_err",this._takeErr);let g=ce(s,({functional:I})=>!!I),h=et(g),x=ce(p,({functional:I})=>!!I),y=et(x);this._waitAll={input:new Cn(this.__system),output:new Cn(this.__system)},Tt(h,I=>{this._plugToWaitAll("input",I)}),Tt(y,I=>{this._plugToWaitAll("output",I)})}onInputRenamed(t,e,i,o){super.onInputRenamed(t,e,i,o),this._onPinSetRenamed("input",t,e,i,o)}onOutputRenamed(t,e,i,o){super.onOutputRenamed(t,e,i,o),this._onPinSetRenamed("output",t,e,i,o)}isUnitPinConstant(t,e,i){return this.getUnit(t).isPinConstant(e,i)}isUnitPinRef(t,e,i){return this.getUnit(t).isPinRef(e,i)}getUnitPinData(t,e,i){return this.getUnit(t).getPinData(e,i)}removeUnitPinData(t,e,i){this._removeUnitPinData(t,e,i),this.emit("remove_unit_pin_data",t,e,i,[])}removeMergeData(t){this._removeMergeData(t)}setMergeData(t,e){this._setMergeData(t,e)}_setMergeData(t,e){this._ensureMergePin("input",t).push(e)}_removeMergeData(t){this._ensureMergePin("input",t).take()}_removeUnitPinData(t,e,i){this.getUnit(t).removePinData(e,i)}_setBranch(t,e,i,o){this._memSetBranch(t,e,i),this._simSetBranch(t,e,i,o)}_memSetBranch(t,e,i){e==="input"?this._pipedTo[i]=t:this._pipedFrom[i]=t}_simSetBranch(t,e,i,o){let a=this._merge[t];if(e==="input"){let s=this._pin[i];a.setOutput(i,s,{},o)}else{let s=this._pin[i];a.setInput(i,s,{},o)}}_memRemoveBranch(t,e,i){e==="input"?delete this._pipedTo[i]:delete this._pipedFrom[i]}_simRemoveBranch(t,e,i){e==="input"?this._merge[t].removeOutput(i):this._merge[t].removeInput(i)}_removeBranch(t,e,i){this._simRemoveBranch(t,e,i),this._memRemoveBranch(t,e,i)}_setExposedSubPin(t,e,i,o,a,s,p=!0){this._simSetExposedSubPin(t,e,i,o,a,p)}_memSetExposedSubPin(t,e,i,o){}_simSetExposedSubPin(t,e,i,o,a,s=!0){let p=_t(t),d=pt(this._exposedMerge,[t,e,t]),c=pt(this._exposedMerge,[t,e,p]);t===i||W(this._exposedEmptySubPin,[t,e,o],void 0)?d.setPin(p,o,a,{},s):c.setPin(t,o,a,{},s)}_simRemoveExposedSubPin(t,e,i){let o=this.getSubPinSpec(t,e,i),{kind:a=t}=o,s=_t(t),p=pt(this._exposedMerge,[t,e,t]),d=pt(this._exposedMerge,[t,e,s]);t===a||W(this._exposedEmptySubPin,[t,e,i],void 0)?p.removePin(s,i):d.removePin(t,i)}_play(){A(this._unit,t=>t.play()),Tt(this._children,t=>t.play())}_pause(){A(this._unit,t=>t.pause()),Tt(this._children,t=>t.pause())}_removeErrUnit(t){let e=this._errUnitIds.indexOf(t);this._errUnitIds.splice(e,1),e===0&&this._nextErr()}_validateMergeId(t){if(!this._spec.merges[t])throw new yc}_validateUnitId(t){if(!this._spec.units[t])throw new _c}isElement(){return!!this._element}setElement(){this._element=!0,this.emit("element",[])}setNotElement(){this._element=!1,this.emit("not_element",[])}getBundleSpec(t=!1){let{spec:e,specs:i}=tn(this._spec,this._specs),o;return t&&(o=this.snapshot(),Nt(this._unit,(a,s)=>{let p=s.snapshot();F(e,["units",a,"memory"],p)})),{spec:e,specs:i}}getUnitBundleSpec(t=!1){let{id:e}=this,i=this.getInputs(),o=this.getOutputs(),a=f=>Vu(f,(g,h)=>{let y=h.peak();return y instanceof C&&(y=null),{constant:h.constant(),ignored:h.ignored(),data:y===void 0?void 0:Y(y)}}),s=a(i),p=a(o),d;return t&&(d=this.snapshot(),ke(d)),ec({id:e,input:s,output:p,memory:d},this._specs)}snapshotSelf(){let t={unit:{},merge:{},exposedMerge:{},waitAll:null};for(let e in this._unit){let o=this._unit[e].snapshot();t.unit[e]=o}for(let e in this._merge){let o=this._merge[e].snapshot();t.merge[e]=o}return Bt(this._exposedMerge,(e,i)=>{let o=_t(e),a=pt(this._exposedMerge,[e,i,e]),s=pt(this._exposedMerge,[e,i,o]),p=a.snapshot(),d=s.snapshot();F(t.exposedMerge,[e,i,e],p),F(t.exposedMerge,[e,i,o],d)}),t.waitAll=this._waitAll.input.snapshot(),t}restoreSelf(t){var i,o;super.restoreSelf(t);for(let a in this._unit){let s=this._unit[a],p=(i=t.unit)==null?void 0:i[a];p&&s.restore(p)}for(let a in this._merge){let s=this._merge[a],p=(o=t.merge)==null?void 0:o[a];p&&s.restore(p)}Bt(this._exposedMerge,(a,s)=>{let p=_t(a);if(this.hasDataPinNamed(a,s)){let d=pt(this._exposedMerge,[a,s,a]),c=pt(this._exposedMerge,[a,s,p]),m=W(t,["exposedMerge",a,s,a],void 0),f=W(t,["exposedMerge",a,s,p],void 0);m&&d.restore(m),f&&c.restore(f)}});let e=t.waitAll;e&&this._waitAll.input.restore(e)}getGraphUnitSpec(t){return this._spec.units[t]}isExposedOutput(t){let e=this._spec.outputs||{},i=this._getExposedSubPinNodeId("output",t);return hn(e,({plug:o})=>hn(o,a=>this._getExposedSubPinNodeId("output",a)===i))}getExposedOutput(t){let e=this._spec.outputs||{},i=this._getExposedSubPinNodeId("output",t);for(let o in e){let a=e[o],{plug:s}=a;for(let p in s){let d=s[p];if(this._getExposedSubPinNodeId("output",d)===i)return o}}}setUnitSize(t,e,i,o=!0){this._setUnitSize(t,e,i)}setSubComponentSize(t,e,i,o=!0){this._setSubComponentSize(t,e,i)}setComponentSize(t,e,i,o=!0){this._setComponentSize(e,i)}_simExposePinSet(t,e,i,o,a,s,p=!0){let{plug:d,ref:c}=i,m=_t(t);a.setPin(t,e,o),s.setPin(m,e,o),this.setPin(t,e,o,{ref:c},p),A(d,(f,g)=>{this._simExposePin(t,e,g,f,p)})}setPinSetFunctional(t,e,i,o=!0){if(t==="output")throw new Error("cannot set output pin set functional");this._setPinSetFunctional(t,e,i),o&&this.emit("set_pin_set_functional",t,e,i,[])}_setPinSetFunctional(t,e,i){this._fork(),this._specSetPinSetFunctional(t,e,i),this._memSetPinSetFunctional(t,e,i),this._simSetPinSetFunctional(t,e,i)}_specSetPinSetFunctional(t,e,i){Rl({type:t,pinId:e,functional:i},this._spec)}_memSetPinSetFunctional(t,e,i){F(this._i_opt,[t,e,"functional"],i)}_simSetPinSetFunctional(t,e,i){let o=this.isPinSetFunctional(t,e);!o&&i?this._plugToWaitAll(t,e):o&&!i&&this._unplugFromWaitAll(t,e)}setPinSetId(t,e,i,o=!0){this._setPinSetId(t,e,i),this.renamePin(t,e,i),o&&this.emit("set_pin_set_id",t,e,i,[])}_setPinSetId(t,e,i){this._fork();let o=this._spec[`${t}s`][e];delete this._spec[`${t}s`][e],this._spec[`${t}s`][i]=o}isExposedInput(t){let{inputs:e={}}=this._spec,i=this._getExposedSubPinNodeId("input",t);return hn(e,({plug:o})=>hn(o,a=>this._getExposedSubPinNodeId("input",a)===i))}getExposedPinSpecs(){return{input:this.getExposedInputSpecs(),output:this.getExposedOutputSpecs()}}getExposedPinSpec(t,e){return t==="input"?this.getExposedInputSpec(e):this.getExposedOutputSpec(e)}isExposedInputPinId(t){return!!(this._spec.inputs||{})[t]}isExposedOutputPinId(t){return!!(this._spec.outputs||{})[t]}getExposedInputSpec(t){return(this._spec.inputs||{})[t]}getPlugSpec(t,e,i){return this._spec[`${t}s`][e].plug[i]}getExposedInputSpecs(){return this._spec.inputs||{}}getExposedOutputSpec(t){return(this._spec.outputs||{})[t]}getExposedOutputSpecs(){return this._spec.outputs||{}}hasUnit(t){return!!this._unit[t]}hasMerge(t){return bl(this._spec,t)}hasMergePin(t,e,i,o){return gl(this._spec,t,e,i,o)}hasPlug(t,e,i){return!!this.getSubPinSpec(t,e,i)}getUnit(t){if(!this._unit[t])throw new Error("cannot find unit");return this._unit[t]}getGraph(t){return this.getUnit(t)}removeUnitGhost(t,e,i,o=!0){let a=this._removeUnitGhost(t,e,i),{specId:s,bundle:p}=a;return o&&this.emit("remove_unit_ghost",t,e,p,[]),a}addUnitGhost(t,e,i,o,a=!0){this._addUnitGhost(t,e,i,o),a&&this.emit("add_unit_ghost",t,e,i,[])}_addUnitGhost(t,e,i,o){let{specs:a}=i;this.__system.injectSpecs(a);let s=this.getUnitOuterSpec(t);this._removeUnit(t,!1),this._addUnitBundleSpec(e,i),Bt(s.merges,(p,d,{mergeId:c,otherPin:m,exposedPin:f})=>{let g=W(o,[p,d],d);m?this._addMerge({[m.unitId]:{[m.type]:{[m.pinId]:!0}},[e]:{[p]:{[g]:!0}}},c,null):this._addPinToMerge(c,e,p,g),f&&this._plugPin(f.type,f.pinId,f.subPinId,{mergeId:c})}),Bt(s.exposed,(p,d,c)=>{let m=W(o,[p,d],d);this._plugPin(c.type,c.pinId,c.subPinId,{unitId:e,pinId:m,kind:c.type})})}_removeUnitGhost(t,e,i,o=!0){let{specs:a}=this.__system,{id:s}=this.__system.newSpec(i),p=this.getUnitOuterSpec(t),d=this.getGraphUnitSpec(t),c=this._removeUnit(t,!1),m=ec(d,a);return this._addUnitBundleSpec(e,{unit:{id:s}}),Bt(p.merges,(f,g,{mergeId:h,otherPin:x,exposedPin:y})=>{x?this._addMerge({[x.unitId]:{[x.type]:{[x.pinId]:!0}},[e]:{[f]:{[g]:!0}}},h,null):this._addPinToMerge(h,e,f,g),y&&this._plugPin(y.type,y.pinId,y.subPinId,{mergeId:h})}),Bt(p.exposed,(f,g,h)=>{this._plugPin(h.type,h.pinId,h.subPinId,{unitId:e,pinId:g,kind:h.type})}),o&&(m.unit.memory=c.snapshot()),{specId:s,bundle:m}}swapUnitGhost(t,e,i){this._removeUnit(t),this._addUnitBundleSpec(e,i);let a=this.getUnit(t).snapshot(),s=ve({}),{id:p}=this.__system.newSpec({});return{spec_id:p,state:a}}getUnitByPath(t){let e=this;for(let i of t)e=e.getUnit(i);return e}read(){return this.getGraphState()}write(t){this.setGraphState(t)}setGraphState(t){return b(this,null,function*(){for(let e in t){let i=this.getUnit(e)}})}getUnitState(t){let e=this.getUnit(t);return null}getGraphState(){return{}}getGraphChildren(){let t={};for(let e in this._unit){let i=this.getUnit(e);if(i.isElement()){let o=i.refChildren();o!==void 0&&(t[e]=o)}}return t}getUnitPin(t,e,i){return this.getUnit(t).getPin(e,i)}getUnitData(t,e,i){return this.getUnit(t).getPinsData()}getMergeData(t){let e=this.getMerge(t);return e?e.getData():void 0}getUnitInput(t,e){return this.getUnit(t).getInput(e)}getUnitOutput(t,e){return this.getUnit(t).getOutput(e)}setUnitErr(t,e){this.getUnit(t).err(e)}takeUnitErr(t){return this._takeUnitErr(t)}_takeUnitErr(t){return this.getUnit(t).takeErr()}getMerges(){return this._merge}refPins(){return{input:this._input,output:this._output}}getPlugs(){let t={input:{},output:{}};return this._forEachSpecPinPlug((e,i,o,a)=>{let s=this.getPlug(e,i,o);F(t,[e,i,o],s)}),t}getPlugSpecs(){return ml(this._spec)}getPlug(t,e,i){let o=_t(t);return pt(this._exposedMerge,[t,e,t]).getPin(o,i)}getMerge(t){return this._merge[t]}refExposedMerges(){return this._exposedMerge}getUnitCount(){return et(this._unit).length}getMergeCount(){return et(this._merge).length}findMergeExposedSubPin(t,e){let i=null;return this._forEachSpecPinOfType(t,(o,a,s)=>{var p;s.mergeId===e&&(i={pinId:o,subPinId:a,type:t,kind:(p=s.kind)!=null?p:t})}),i}getUnitsSpec(){let{units:t}=this._spec;return t}getMergesSpec(){let{merges:t={}}=this._spec;return t}getMergeSpec(t){let{merges:e}=this._spec;return e[t]}getMergeUnitCount(t){let e=this.getMergeSpec(t);return et(e).length}getMergePinCount(t){var e;return(e=this._mergePinCount[t])!=null?e:0}getPinPlugCount(t,e){let i=this.getExposedPinSpec(t,e);return zu(i.plug||{})}fork(t,e=!0){this._fork(t,e)}_fork(t,e=!0){var i;if(this._spec.system||((i=this.__system.specsCount[this.id])!=null?i:0)>1){let[o,a]=this.__system.forkSpec(this._spec,t);this.__system.unregisterUnit(this.id),this.id=o,this._spec=a,this.__system.registerUnit(o),e&&this.emit("fork",o,j(a),[])}}_initAddUnit(t,e){let i=ec(e,this.__system.specs),o=An(this.__system,i,this._specs,this._branch);this._memAddUnit(t,o),this._simAddUnit(t,{unit:e},o,!1)}_initAddUnits(t){A(t,(e,i)=>{this._initAddUnit(i,e)})}addUnitSpec(t,e,i=!0){let o=An(this.__system,e,this._specs,this._branch);return this.addUnit(t,o,e,i),o}_addUnitSpec(t,e,i=!0){let o=An(this.__system,e,this._specs,this._branch);return this._addUnit(t,o,e),o}_addUnitBundleSpec(t,e){let i=An(this.__system,e,this._specs,this._branch);return this._addUnit(t,i),i}_onUnitErr(t,e){let i=this._errUnitIds.indexOf(t);i>-1?i===0&&this.err(e):(this._errUnitIds.push(t),this._errUnitIds.length===1&&this.err(e))}_specAddUnit(t,e,i=null){i=i!=null?i:e.getUnitBundleSpec();let{unit:o}=i;F(this._spec,["units",t],o),e.isElement()&&(this._specInjectSubComponent(t),this._specAppendRoot(t))}_memAddUnit(t,e,i=null){i=i!=null?i:e.getUnitBundleSpec();let{unit:o}=i,a=[];e.setParent(this),this._unit[t]=e;let s=(U,B)=>{let J=Jt(t,U,B),q=this._pipedTo[J],w=this._pipedFrom[J],E=hl(this._spec,t,U,B);q&&this._removePinOrMerge(q,t,U,B),w&&this._removePinOrMerge(w,t,U,B),E&&this._unplugPin(U,E.pinId,E.subPinId),delete this._pipedTo[J],delete this._pipedFrom[J],delete this._pin[J],delete this._unitPins[J],Vt(this._spec,["units",t,U,B]),Vt(this._spec,["units",t,"memory",U,B])},p=U=>{s("input",U)},d=U=>{s("output",U)},c=(U,B,J)=>{let q=Jt(t,U,B),w=Jt(t,U,J),E=W(this._pinToMerge,[t,U,B],null);if(E){let $=this.getMerge(E),G=_t(U);$.renamePin(G,q,w),F(this._pinToMerge,[t,U,J],E),delete this._pinToMerge[t][U][B],this._pipedTo[q]&&(this._pipedTo[w]=this._pipedTo[q],delete this._pipedTo[q]),this._pipedFrom[q]&&(this._pipedFrom[w]=this._pipedFrom[q],delete this._pipedFrom[q]),jl({unitId:t,type:U,pinId:B,newPinId:J},this._spec)}this._pin[w]=this._pin[q],delete this._pin[q]},m=e.getInputNames(),f=e.getOutputNames(),g=this.setUnitInput.bind(this,t),h=this.setUnitOutput.bind(this,t);Tt(m,g),Tt(f,h);let x={},y=(U,B,J,q=!0)=>{if(J===void 0)return;let w=this.getUnitPin(t,U,B);q&&this._fork(),this._specSetUnitPinData(t,U,B,J);let E=w.addListener("data",$=>{this._settingUnitData||(this._specSetUnitPinData(t,U,B,$),this.emit("set_unit_pin_data",t,U,B,$,[]))});F(x,[t,U,B],E),a.push(E)};Tt(m,U=>{e.isPinConstant("input",U)&&y("input",U,e.getPinData("input",U),!1)}),Tt(f,U=>{e.isPinConstant("output",U)&&y("output",U,e.getPinData("output",U),!1)}),a.push(e.addListener("set_input",g)),a.push(e.addListener("before_remove_input",p)),a.push(e.addListener("set_output",h)),a.push(e.addListener("before_remove_output",d)),a.push(e.addListener("rename_input",c.bind(this,"input"))),a.push(e.addListener("rename_output",c.bind(this,"output"))),a.push(e.addListener("set_pin_constant",(U,B,J)=>{this._specSetUnitPinConstant(t,U,B,J);let q=this.getUnitPinData(t,U,B);if(J)y(U,B,q);else{let w=W(x,[t,U,B],void 0);w&&(w(),$t(a,w),fe(x,[t,U,B]))}}));let I=dl(t,lt),v=e.getSelfPin();this._pin[I]=v;let T=U=>{this._onUnitErr(t,U)};a.push(e.addListener("err",T));let P=()=>{let U=this._errUnitIds.indexOf(t);U>-1&&(this._errUnitIds.splice(U,1),U===0&&this._nextErr())};if(a.push(e.prependListener("take_err",P)),a.push(e.prependListener("catch_err",P)),e instanceof Lt){for(let U of wt)a.push(e.addListener(U,(...B)=>{this.emit(U,...B.slice(0,-1).concat([[t,...B[B.length-1]]]))}));a.push(e.addListener("fork",(U,B,J)=>{J.length===0&&(this._fork(),F(this._spec,["units",t,"id"],U))}))}e instanceof Lt&&e.isElement()&&(a.push(e.addListener("element",()=>{this._on_unit_element(t,o,e)})),a.push(e.addListener("not_element",()=>{this._on_unit_not_element(t)})));let H=tt(a);this._unitUnlisten[t]=H}_simAddUnit(t,e,i,o=!0){i.isElement()&&(o&&this.registerRoot(i),this._simInjectSubComponent(t,e.unit,i)),i.hasErr()&&this._onUnitErr(t,i.getErr()),this._paused||i.play()}removeUnit(t,e=!0,i=!0,o=!0){let a=this.getUnit(t),s=a.getUnitBundleSpec();return this._removeUnit(t,i,o),e&&this.emit("remove_unit",t,s,a,[]),this._transacting&&this._transaction.push(xl(t,s)),a}cloneUnit(t,e){let i=this._cloneUnit(t,e);return this.emit("clone_unit",t,e,i,[]),i}_cloneUnit(t,e){let i=this.getUnit(t),[o,a]=Cl(i,!0);return this._addUnit(e,o,a),this._paused||o.play(),o}_moveUnit(t,e,i){let o=this.getUnit(t),a=this._isUnitComponent(t);this._simRemoveUnit(t),this._memRemoveUnit(t),this._specRemoveUnit(t,a),this.getUnit(e).push(i,o)}moveUnit(t,e,i){this._moveUnit(t,e,i),this.emit("move_unit",t,e,i,[])}_memRemoveUnitFromMerges(t){let e=this._unitToMerge[t];for(let i of e)this._memRemoveUnitFromMerge(t,i)}_simRemoveUnitFromMerges(t){let e=this._unitToMerge[t];for(let i of e)this._simRemoveUnitFromMerge(t,i)}_removeUnitFromMerge(t,e){this._simRemoveUnitFromMerge(t,e),this._memRemoveUnitFromMerge(t,e)}_memRemoveUnitFromMerge(t,e){this._forEachUnitPinOnMerge(t,e,(i,o)=>{this._memRemovePinFromMerge(e,t,i,o)})}_simRemoveUnitFromMerge(t,e,i=!0){this._forEachUnitPinOnMerge(t,e,(o,a)=>{this._simRemovePinFromMerge(e,t,o,a,i)})}_specRemoveUnitFromMerge(t,e){this._forEachUnitPinOnMerge(t,e,(i,o)=>{this._specRemovePinFromMerge(e,t,i,o)})}_forEachUnitPinOnMerge(t,e,i){let a=this.getMergeSpec(e)[t];a&&Bt(a,(s,p)=>{i(s,p)})}_removeUnit(t,e=!0,i=!1){this._fork();let o=this.getUnit(t);this.emit("before_remove_unit",t,o,[]);let a=this._isUnitComponent(t);return this._simRemoveUnit(t,e),this._memRemoveUnit(t),this._specRemoveUnit(t,a),i&&o.destroy(),o}_specRemoveUnit(t,e){e&&(this._specRemoveSubComponentFromParent(t),this._specRemoveSubComponent(t)),this._specUnplugUnit(t),delete this._spec.units[t]}_memRemoveUnit(t,e=!0){let i=this.getUnit(t),o=this._unitUnlisten[t];o(),e&&this._memUnplugUnit(t),i.setParent(null),delete this._unitToMergeCount[t],delete this._unitToMerge[t],delete this._unitUnlisten[t],delete this._pinToMerge[t],delete this._unit[t]}_memUnplugUnit(t){var a;let e=j(this._unitToMerge[t]||new Set),i=j(this._unitToMergeCount[t]||{}),o=j((a=this._pinToPlug[t])!=null?a:{});Bt(o,(s,p,{pinId:d,subPinId:c})=>{this._memUnplugPin(s,d,c)});for(let s of e){let p=i[s];this.getMergePinCount(s)-p<2?this._memRemoveMerge(s):this._memRemoveUnitFromMerge(t,s)}}_simAddMerge(t,e,i,o){A(e,({input:a,output:s},p)=>{A(a||{},(d,c)=>{this._simAddPinToMerge(t,p,"input",c,o)}),A(s||{},(d,c)=>{this._simAddPinToMerge(t,p,"output",c,o)})})}_simAddPinToMerge(t,e,i,o,a=!0){let s=Jt(e,i,o);a=a||this.isUnitRefPin(e,i,o),this._simSetBranch(t,i,s,a)}_specAddPinToMerge(t,e,i,o){F(this._spec,["merges",t,e,i,o],!0)}_memAddPinToMerge(t,e,i,o){i==="output"&&o===lt&&(this._mergeToSelfUnit[t]=e,this._selfUniToMerge[e]=t),this._mergePinCount[t]=this._mergePinCount[t]||0,this._mergePinCount[t]++,this._unitToMerge[e]=this._unitToMerge[e]||new Set,this._unitToMerge[e].add(t),this._unitToMergeCount[e]=this._unitToMergeCount[e]||{},this._unitToMergeCount[e][t]=this._unitToMergeCount[e][t]||0,this._unitToMergeCount[e][t]++,F(this._pinToMerge,[e,i,o],t);let a=Jt(e,i,o);this._memSetBranch(t,i,a)}_memRemoveMerge(t){this._memRemoveAllMergePlug(t),this._memRemoveAllMergePin(t),this._memRemoveAllMergeRef(t);let e=At(t,"input"),i=At(t,"output");delete this._pin[e],delete this._pin[i],delete this._merge[t],delete this._mergePinCount[t]}_specRemoveMerge(t){this._specRemoveAllMergePlug(t),this._specRemoveAllMergePin(t),this._specRemoveAllMergeRef(t)}_memRemoveAllMergePlug(t){this._forEachSpecPinPlug((e,i,o,a)=>{a.mergeId===t&&this._memUnplugPin(e,i,o)})}_specRemoveAllMergePlug(t){this._forEachSpecPinPlug((e,i,o,a)=>{a.mergeId===t&&this._specUnplugPin(e,i,o)})}_memRemoveAllMergeRef(t){let e=this._mergeToSelfUnit[t];e&&(delete this._mergeToSelfUnit[t],delete this._selfUniToMerge[e])}_specRemoveAllMergeRef(t){delete this._spec.merges[t]}_memRemoveAllMergePin(t){let e=j(this._spec.merges[t]);A(e,({input:i,output:o},a)=>{A(i||{},(s,p)=>{this._memRemovePinFromMerge(t,a,"input",p)}),A(o||{},(s,p)=>{this._memRemovePinFromMerge(t,a,"output",p)})})}_specRemoveAllMergePin(t){let e=j(this._spec.merges[t]);A(e,({input:i,output:o},a)=>{A(i||{},(s,p)=>{this._specRemovePinFromMerge(t,a,"input",p)}),A(o||{},(s,p)=>{this._specRemovePinFromMerge(t,a,"output",p)})})}_memPostRemoveMerge(t){this._forEachSpecPinPlug((e,i,o,a)=>{a.mergeId===t&&this._memPlugEmptyPin(e,i,o)})}memIsUnitRefPin(t,e,i){return this.getUnit(t).hasRefPinNamed(e,i)}_getUnitSpec(t){let e=this.getGraphUnitSpec(t),{id:i}=e;return this.__system.getSpec(i)}getUnitSpecId(t){let e=this.getGraphUnitSpec(t),{id:i}=e;return i}getUnitSpec(t){let{getSpec:e}=this.__system,i=this.getGraphUnitSpec(t),{id:o}=i;return e(o)}isUnitRefPin(t,e,i){return this.getUnit(t).isPinRef(e,i)}isUnitRefInput(t,e){return this.getUnit(t).hasRefInputNamed(e)}removeMerge(t,e=!0,i=!0){let o=this.getMergeSpec(t),a=this._removeMerge(t,i);e&&this.emit("remove_merge",t,o,a,[]),this._transacting&&this._transaction.push(Tl(t,o))}_removeMerge(t,e){this._fork(),this._validateMergeId(t);let i=this.getMerge(t),o=this.getMergeSpec(t);return this.emit("before_remove_merge",t,o,i,[]),this._simRemoveMerge(t,e),this._memRemoveMerge(t),this._specRemoveMerge(t),i.destroy(),i}_simRemoveMerge(t,e){let i=this.getMerge(t);this._simRemoveAllPlugsFromMerge(t,e),this._simRemoveAllPinsFromMerge(t,e)}_simPostRemoveMerge(t){this._forEachSpecPinPlug((e,i,o,a)=>{a.mergeId===t&&this._simPlugEmptyPin(e,i,o)})}removePinFromMerge(t,e,i,o,a=!0,s=!0){this._removePinFromMerge(t,e,i,o,s),a&&this.emit("remove_pin_from_merge",t,e,i,o,[])}_removePinFromMerge(t,e,i,o,a=!0){this._validateMergeId(t),this._validateUnitId(e),this._simRemovePinFromMerge(t,e,i,o,a),this._memRemovePinFromMerge(t,e,i,o),this._specRemovePinFromMerge(t,e,i,o)}removePinOrMerge(t,e,i,o,a=!0,s=!0){this._mergePinCount[t]>2?this.removePinFromMerge(t,e,i,o,a,s):this.removeMerge(t,s,a)}_removePinOrMerge(t,e,i,o,a=!0){this._mergePinCount[t]>2?this._removePinFromMerge(t,e,i,o,a):this._removeMerge(t,a)}_memRemovePinFromMerge(t,e,i,o){var s,p,d,c,m,f;let a=Jt(e,i,o);this._memRemoveBranch(t,i,a),i==="input"||o===lt&&(delete this._mergeToSelfUnit[t],delete this._selfUniToMerge[e]),this._mergePinCount[t]--,this._unitToMergeCount[e][t]--,this._unitToMergeCount[e][t]===0&&(delete this._unitToMergeCount[e][t],this._unitToMerge[e].delete(t)),(p=(s=this._pinToMerge[e])==null?void 0:s[i])==null||delete p[o],Ft((c=(d=this._pinToMerge[e])==null?void 0:d[i])!=null?c:{})&&((m=this._pinToMerge[e])==null||delete m[i]),Ft((f=this._pinToMerge[e])!=null?f:{})&&delete this._pinToMerge[e]}_specRemovePinFromMerge(t,e,i,o){Ol({mergeId:t,unitId:e,type:i,pinId:o},this._spec)}_simRemovePinFromMerge(t,e,i,o,a=!0){let s=Jt(e,i,o);if(this._simRemoveBranch(t,i,s),a||i==="output"&&o===lt||this.isUnitRefPin(e,"input",o)){let p=this._pin[s],d=this.getMergeSpec(t);this.isUnitRefPin(e,"output",o)?fl(d,(c,m,f)=>{this._removeUnitPinData(c,m,f)}):p.take()}}isPinMergedTo(t,e,i,o){let a=this._spec.merges||{};return!!a[t]&&a[t][e]&&a[t][e][i]&&a[t][e][i][o]}setUnitPinSetId(t,e,i,o,a=!0){this.getUnit(t).setPinSetId(e,i,o,!1),a&&this.emit("set_unit_pin_set_id",t,e,i,o,[])}setUnitPinConstant(t,e,i,o,a=!0){this._setUnitPinConstant(t,e,i,o);let s=this.getUnitPinData(t,e,i);a&&this.emit("set_unit_pin_constant",t,e,i,o,s,[])}_setUnitPinConstant(t,e,i,o){this._specSetUnitPinConstant(t,e,i,o),this.getUnit(t).setPinConstant(e,i,o)}_specSetUnitPinConstant(t,e,i,o){$l({unitId:t,type:e,pinId:i,constant:o},this._spec)}setUnitInputConstant(t,e,i){this.setUnitPinConstant(t,"input",e,i)}setUnitOutputConstant(t,e,i){this.setUnitPinConstant(t,"output",e,i)}setUnitInputIgnored(t,e,i){this.setUnitPinIgnored(t,"input",e,i)}setUnitOutputIgnored(t,e,i){this.setUnitPinIgnored(t,"output",e,i)}setUnitPinIgnored(t,e,i,o){this._setUnitPinIgnored(t,e,i,o),this.emit("set_unit_pin_ignored",t,e,i,o,[])}_setUnitPinIgnored(t,e,i,o){this._specSetUnitPinIgnored(t,e,i,o),this._simSetUnitPinIgnored(t,e,i,o)}_specSetUnitPinIgnored(t,e,i,o){F(this._spec,["units",t,e,i,"ignored"],o)}_simSetUnitPinIgnored(t,e,i,o){var s;let a=this.getUnit(t);o&&(te((s=this._spec.merges)!=null?s:{},(p,d,c,m)=>{d===t&&c===e&&m===i&&this._removePinFromMerge(p,t,e,i)}),A(this._spec[`${e}s`]||{},({plug:p},d)=>{for(let c in p){let m=p[c];if(m.unitId===t&&m.pinId===i){this._unplugPin(e,d,c);break}}})),a.setPinIgnored(e,i,o)}setUnitId(t,e,i,o){this._setUnitId(t,e,i,o),this.emit("set_unit_id",t,e,i,o,[])}_setUnitId(t,e,i,o){let a=j(this.getUnitMergesSpec(t)),s=j(this.getUnitPlugsSpec(t)),p=Vl(t,a,e),d=this.getUnit(t);d.fork(o,!1);let c=this._getUnitSpec(t);c.name=i,d._spec.name=i,this._specs[c.id]=c,this._removeUnit(t,!1),this._addUnit(e,d),this._addUnitMerges(p,!1),this._addUnitPlugs(e,s,!1)}_addUnitPlugs(t,e,i=!0){Bt(e,(o,a,s)=>{this._plugPin(o,s.pinId,s.subPinId,{unitId:t,pinId:a,kind:o},i)})}setPlugData(t,e,i,o,a=!0){this.getPlug(t,e,i).push(o)}setUnitPinData(t,e,i,o){this._settingUnitData=!0,this._setUnitPinData(t,e,i,o),this._settingUnitData=!1,this.emit("set_unit_pin_data",t,e,i,o,[])}_setUnitPinData(t,e,i,o){let a=this.getUnit(t);a.hasInputNamed(i)&&a.isPinConstant(e,i)&&this._fork(),this._specSetUnitPinData(t,e,i,o),this._simSetUnitPinData(t,e,i,o)}_specSetUnitPinData(t,e,i,o){let a=this.getUnit(t);a.hasInputNamed(i)&&a.isPinConstant(e,i)&&kl({unitId:t,type:e,pinId:i,data:Y(o)},this._spec)}_simSetUnitPinData(t,e,i,o){this.getUnit(t).setPinData(e,i,o)}setUnitInputData(t,e,i){this.getUnit(t).setPinData("input",e,i)}setUnitOutputData(t,e,i){this.getUnit(t).setPinData("output",e,i)}setMetadata(t,e){let i=this._spec,o=0;for(;o<t.length-1;){let s=t[o];i[s]||(i[s]={}),i=i[s],o++}let a=t[o];Je(i[a])&&Je(e)?i[a]=Ht(i[a],e):i[a]=e,this.emit("metadata",{path:t,data:e},[])}getSubComponentsParentMap(t){let e={};for(let i of t){let o=this._getSubComponentParentId(i);e[i]=o}return e}getSubComponentsSlotMap(t){let e={};for(let i of t){let o=this._getSubComponentSlotName(i);e[i]=o}return e}moveSubComponentRoot(t,e,i,o=!0){let a=this.getSubComponentsParentMap(e),s=this.getSubComponentsParentMap(e);for(let p=0;p<e.length;p++){let d=e[p],c=i[d]||"default";this._moveSubComponentRoot(t,d,p,c)}o&&this.emit("move_sub_component_root",t,a,e,i,s,[])}_appendRoot(t){this._specAppendRoot(t)}removeRoot(t){this._removeRoot(t)}_removeRoot(t){this._simRemoveRoot(t),this._specRemoveRoot(t)}_specRemoveRoot(t){let e=this._spec.component.children.indexOf(t);if(e>-1)this._spec.component.children.splice(e,1);else throw new Error("root not found")}_simRemoveRoot(t){let e=this.getUnit(t);this.unregisterRoot(e)}moveSubgraphInto(...[t,e,i,o,a,s,p,d,c,m]){this._moveSubgraphInto(t,e,i,o,a,s,p,d,c,m),this.emit("move_subgraph_into",t,e,i,o,a,s,p,d,c,m,[])}_moveSubgraphInto(t,e,i,o,a,s,p,d,c,m){let f=this.getUnit(t);f.fork(i),f.startTransaction();let g=j(this.getUnitMergesSpec(t));pm(this,f,t,{nodeIds:o,nextSpecId:null,nextIdMap:a,nextPinIdMap:s,nextMergePinId:p,nextPlugSpec:d,nextSubComponentParentMap:c,nextSubComponentChildrenMap:m,nextUnitPinMergeMap:{},nextSubComponentIndexMap:{}},{merges:g},!1),f.endTransaction()}getUnitMergesSpec(t){return rm(this._spec,t)}getPinMergeId(t,e,i){return W(this._pinToMerge,[t,e,i],null)}getUnitPlugsSpec(t){return im(this._spec,t)}startTransaction(){if(this._transacting)throw new Error("transaction already started");this._transacting=!0,this._transaction=[]}explodeUnit(t,e,i,o){this._explodeUnit(t,e,i,o),this.emit("explode_unit",t,e,i,[])}moveSubgraphOutOf(...[t,e,i,o,a,s,p,d,c,m]){this._moveSubgraphOutOf(t,e,i,o,a,s,p,d,c,m),this.emit("move_subgraph_out_of",t,e,i,o,a,s,p,d,c,m,[])}_moveSubgraphOutOf(...[t,e,i,o,a,s,p,d,c,m]){let f=this.getUnit(t),g=j(this.getUnitMergesSpec(t)),h=j(this.getUnitPlugsSpec(t)),x={nodeIds:o,nextSpecId:null,nextIdMap:a,nextPinIdMap:s,nextMergePinId:p,nextPlugSpec:d,nextSubComponentParentMap:c,nextSubComponentChildrenMap:m,nextSubComponentIndexMap:{},nextUnitPinMergeMap:{}},y={merges:g,plugs:h};f.startTransaction(),f.fork(),pm(f,this,t,x,y,!0),f.endTransaction()}getGraphUnitBundleSpec(t){return this.getUnit(t).getBundleSpec()}_explodeUnit(t,e,i,o){this._fork();let a=this.getUnitSpec(t),s=yl(t,a,e,i,o,{getMerge:I=>this.getMergeSpec(I),getUnitMerges:I=>this.getUnitMergesSpec(I),getUnitPlugs:I=>this.getUnitPlugsSpec(I),getPinMergeId:(I,v,T)=>this.getPinMergeId(I,v,T)}),{nodeIds:p,nextSpecId:d,nextIdMap:c,nextPinIdMap:m,nextMergePinId:f,nextPlugSpec:g,nextSubComponentParentMap:h,nextSubComponentChildrenMap:x}=s,y=this.getGraphUnitBundleSpec(t);this._moveSubgraphOutOf(t,y,d,p,c,m,f,g,h,x),this._removeUnit(t)}_removeSubComponentFromParent(t){this._simRemoveSubComponentFromParent(t),this._specRemoveSubComponentFromParent(t)}reorderSubComponent(t,e,i,o=!0){this._reorderSubComponent(t,e,i),o&&this.emit("reorder_sub_component",t,e,i,[])}_reorderSubComponent(t,e,i){this._simReorderSubComponent(t,e,i),this._specReorderSubComponent(t,e,i)}_simReorderSubComponent(t,e,i){let o=this.getUnit(e);t?this.getUnit(t).reorderParentRoot(o,i):this.reorderRoot(o,i)}_specReorderSubComponent(t,e,i){let o=this.getUnit(e);t?($t(this._spec.component.subComponents[t].children,e),It(this._spec.component.subComponents[t].children,e,i)):($t(this._spec.component.children,e),It(this._spec.component.children,e,i))}moveRoot(t,e,i,o){this._moveSubComponentRoot(t,e,i,o)}_moveSubComponentRoot(t,e,i,o){this._removeSubComponentFromParent(e),t?this._insertSubComponentChild(t,e,i,o):this._appendRoot(e)}_initSetComponent(t){let{slots:e=[],subComponents:i={},children:o=[]}=t;for(let a in i){let s=i[a];this._initAddSubComponent(a,s)}for(let a of o){let s=this.getUnit(a);this.registerRoot(s)}for(let a=0;a<e.length;a++){let s=e[a],[p,d]=s,c=this.getUnit(p),m=a===0?"default":`${a}`;this._slot[m]=c}}_specSetComponent(t){let{slots:e=[],subComponents:i={},children:o=[]}=t;for(let a in i){let s=i[a];this._specAddSubComponent(a,s)}for(let a=0;a<e.length;a++){let s=e[a],[p,d]=s,c=this.getUnit(p),m=a===0?"default":`${a}`;this._slot[m]=c}e.length>0&&(this._spec.component.slots=e)}_initAddSubComponent(t,e){let{children:i=[],childSlot:o={}}=e;for(let a of i){let s=o[a]||"default";this._simSubComponentAppendChild(t,a,s)}}_specAddSubComponent(t,e){var a;let{children:i=[],childSlot:o={}}=e;for(let s of i){this._specComponentRemoveChild(s);let p=o[s]||"default";this._specSubComponentAppendChild(t,s,p)}this._spec.component.subComponents[t]=e,this._spec.component.children=(a=this._spec.component.children)!=null?a:[],this._spec.component.children.push(t)}appendParentChild(t,e){return fc(this,this._parent_children,t,e)}removeParentChild(t){return lc(this,this._parent_children,t)}registerRoot(t){return mc(this,this._root,t)}unregisterRoot(t){return dc(this,this._root,t)}registerParentRoot(t,e,i){return sc(this,this._parent_root,t,e,i)}unregisterParentRoot(t){return pc(this,this._parent_root,t)}reorderRoot(t,e){return uc(this,this._root,t,e)}reorderParentRoot(t,e){return cc(this,this._parent_root,t,e)}insertChild(t,e){return ul(this,this._children,t,e)}appendChild(t){return ic(this,this._children,t)}pushChild(t){return Dn(this,this._children,t)}pullChild(t){throw En(this,this._children,t)}hasChild(t){return Sn(this,this._children,t)}removeChild(t){return rc(this,this._children,t)}refChild(t){return oc(this,this._children,t)}refChildren(){return ac(this,this._children)}refSlot(t){return cl(this,t,this._slot)}getAnimations(){return this._animations}animate(t,e){return bc(this,this._animations,t,e)}cancelAnimation(t){return gc(this,this._animations,t)}stopPropagation(t){return hc(this,this._stopPropagation,t)}getSetup(){return{animations:this._animations,events:this.eventNames(),stopPropagation:Object.keys(this._stopPropagation),stopImmediatePropagation:Object.keys(this._stopImmediatePropagation),preventDefault:Object.keys(this._preventDefault)}}bulkEdit(t){this._bulkEdit(t),this.emit("bulk_edit",t,!1,[])}_bulkEdit(t){for(let e of t)Al(e,{addUnitSpec:i=>{let{unitId:o,bundle:a,parentId:s,merges:p,plugs:d}=i;this._addUnitSpec(o,a),s&&this._appendSubComponentChild(s,o,"default"),p&&this._addUnitMerges(p,!0),d&&this._addUnitPlugs(o,d)},removeUnit:i=>{let{unitId:o}=i;this._removeUnit(o,!1,!0)},exposePinSet:i=>{let{type:o,pinId:a,pinSpec:s}=i;this._exposePinSet(o,a,s)},exposePin:i=>{let{type:o,pinId:a,subPinId:s,subPinSpec:p}=i;this._exposePin(o,a,s,p)},coverPin:i=>{let{type:o,pinId:a,subPinId:s}=i;this._coverPin(o,a,s)},coverPinSet:i=>{let{type:o,pinId:a}=i;this._coverPinSet(o,a)},plugPin:i=>{let{type:o,pinId:a,subPinId:s,subPinSpec:p}=i;this._plugPin(o,a,s,p)},unplugPin:i=>{let{type:o,pinId:a,subPinId:s}=i;this._unplugPin(o,a,s)},addUnitSpecs:i=>{let{units:o}=i;this._addUnitSpecs(o)},removeMerge:i=>{let{mergeId:o}=i;this._removeMerge(o,!0)},removePinFromMerge:i=>{let{mergeId:o,unitId:a,type:s,pinId:p}=i;this._removePinFromMerge(o,a,s,p)},removeUnitGhost:i=>{let{unitId:o,nextUnitId:a,nextUnitSpec:s}=i;this._removeUnitGhost(o,a,s)},addUnitGhost:i=>{let{unitId:o,nextUnitId:a,nextUnitBundle:s,nextUnitPinMap:p}=i;this._addUnitGhost(o,a,s,p)},addMerges:i=>{let{merges:o}=i;this._addMerges(o)},addMerge:i=>{let{mergeId:o,mergeSpec:a}=i;this._addMerge(a,o)},addPinToMerge:i=>{let{mergeId:o,unitId:a,type:s,pinId:p}=i;this._addPinToMerge(o,a,s,p)},takeUnitErr:i=>{let{unitId:o}=i;this.takeUnitErr(o)},setPinSetId:i=>{let{type:o,pinId:a,nextPinId:s}=i;this._setPinSetId(o,a,s)},setPinSetFunctional:i=>{let{type:o,pinId:a,functional:s}=i;this._setPinSetFunctional(o,a,s)},setUnitPinConstant:i=>{let{unitId:o,type:a,pinId:s,constant:p}=i;this._setUnitPinConstant(o,a,s,p)},setUnitPinIgnored:i=>{let{unitId:o,type:a,pinId:s,ignored:p}=i;this._setUnitPinIgnored(o,a,s,p)},setUnitPinData:i=>{let{unitId:o,type:a,pinId:s,data:p}=i;this._setUnitPinData(o,a,s,p)},setUnitId:i=>{let{unitId:o,newUnitId:a,name:s,specId:p}=i;this._setUnitId(o,a,s,p)},removeUnitPinData:i=>{let{unitId:o,type:a,pinId:s}=i;this._removeUnitPinData(o,a,s)},removeMergeData:i=>{let{mergeId:o}=i;this._removeMergeData(o)},moveSubComponentRoot:i=>{let{parentId:o,children:a,slotMap:s}=i;for(let p=0;p<a.length;p++){let d=a[p],c=s[d]||"default";this._moveSubComponentRoot(o,d,p,c)}},moveUnit:i=>{let{}=i},moveSubgraphInto:i=>{let{graphId:o,graphBundle:a,nextSpecId:s,nodeIds:p,nextIdMap:d,nextPinIdMap:c,nextMergePinId:m,nextPlugSpec:f,nextSubComponentParentMap:g,nextSubComponentChildrenMap:h}=i;this._moveSubgraphInto(o,a,s,p,d,c,m,f,g,h)},moveSubgraphOutOf:i=>{let{graphId:o,graphBundle:a,nextSpecId:s,nodeIds:p,nextIdMap:d,nextPinIdMap:c,nextMergePinId:m,nextPlugSpec:f,nextSubComponentParentMap:g,nextSubComponentChildrenMap:h}=i;this._moveSubgraphOutOf(o,a,s,p,d,c,m,f,g,h)},reorderSubComponent:i=>{let{parentId:o,childId:a,to:s}=i;this._reorderSubComponent(o,a,s)},removePinData:i=>{let{type:o,pinId:a}=i;this.removePinData(o,a)},takeInput:i=>{let{pinId:o}=i;this.removePinData("input",o)},setUnitSize:i=>{let{unitId:o,width:a,height:s}=i;this._setUnitSize(o,a,s)},setSubComponentSize:i=>{let{unitId:o,width:a,height:s}=i;this._setSubComponentSize(o,a,s)},setComponentSize:i=>{let{width:o,height:a}=i;this._setComponentSize(o,a)},bulkEdit:i=>{let{actions:o}=i;this.bulkEdit(o)}},()=>{throw new Ne})}_setUnitSize(t,e,i){this._specSetUnitSize(t,e,i)}_specSetUnitSize(t,e,i){Nl({unitId:t,width:e,height:i},this._spec)}_setSubComponentSize(t,e,i){this._specSetSubComponentSize(t,e,i)}_specSetSubComponentSize(t,e,i){Bl({unitId:t,width:e,height:i},this._spec)}_setComponentSize(t,e){this._specSetComponentSize(t,e)}_specSetComponentSize(t,e){Fl({width:t,height:e},this._spec)}detach(){throw new O}};function um(r,n,t={},e={}){var o;t[r.id]=r;let{units:i}=r;for(let a in i){let s=i[a],{id:p,input:d}=s;for(let f in d){let g=(o=d[f])!=null?o:{},{data:h}=g;if(h){let x=Dt(h);if(x.type==="unit"){let{value:y}=x,I=Xd(y,n,e);for(let v in I.specs){let T=I.specs[v];t[v]=T}for(let v in I.specs){let T=I.specs[v];um(T,ut(n,t),t)}}}}let c=n[p];if(!c)return;let{system:m}=c;m||t[p]||(t[p]=c,um(t[p],n,t))}return t}function be(r,n,t={},e={}){let i=Jd(r,n,t,e),{id:o}=r;if(!o)throw new Error("spec id is required");let a=um(r,n,{});return zt(i,{unit:{id:o},specs:a})}function zl(r,n){let{name:t,units:e}=r;for(let o in e){let g=function(h,x){let{ignored:y}=h;if(y===void 0){let{defaultIgnored:I}=x;I===!0&&(h.ignored=!0)}};var i=g;let a=e[o];a.input=a.input||{},a.output=a.output||{};let{id:s,input:p,output:d}=a,c=n[s],{inputs:m,outputs:f}=c;for(let h in m){let x=m[h];p[h]=p[h]||{};let y=p[h];g(y,x)}for(let h in f){let x=f[h];d[h]=d[h]||{};let y=d[h];g(y,x)}}}function Jd(r,n,t,e={}){zl(r,n);let{id:i,name:o}=r;if(t[i])return t[i];class a extends Lt{constructor(p){let d=p.getSpec(i);super(d,e,p,i)}}return Object.defineProperty(a,"name",{value:o}),e[i],a}function Jf(r,n,t,e={}){return zl(n,t),new Lt(n,e,r,n.id)}function ee(r,n,t,e={}){let{spec:i={},specs:o={}}=r;return i.id||(i.id=Ze(n)),o[i.id]=i,be(i,ut(o,n),t,e)}function cm(r=null,n,t){let{path:e="",specs:i={},classes:o={},components:a={},flags:s={}}=t,p={pressed:[],repeat:!1},d=[],c={},m=new Set,f=[],g={keyboard:p,gamepads:d,pointers:c},h={iframe:[],dragAndDrop:{},pointerCapture:{},spriteSheetMap:{}},x={},y=new Ku(i),{specs_:I}=y,{specsCount:v,newSpecId:T,hasSpec:P,emptySpec:H,newSpec:U,getSpec:B,setSpec:J,forkSpec:q,injectSpecs:w,deleteSpec:E,registerUnit:$,unregisterUnit:G,shouldFork:K}=y,L=r?r.emitter:new mt,z={},rt={},N={},nt={path:e,parent:r,emitter:L,animated:!0,root:null,theme:"dark",customEvent:m,input:g,context:f,specs_:I,specs:i,classes:o,components:a,graphs:[],specsCount:v,cache:h,feature:x,foreground:{svg:void 0,app:void 0},showLongPress:void 0,captureGesture:void 0,global:r?r.global:{ref:{},component:rt,data:new Ie({}),scope:{}},api:n,flags:_({defaultInputModeNone:!1,tick:"sync"},s),tick:s.tick==="sync"?M=>{M()}:M=>nt.api.animation.requestAnimationFrame(M),boot:M=>cm(nt,n,M),stringifyBundleData:M=>zf(M),fromBundle:M=>ee(M,i,{}),newGraph:M=>new M(nt),getSpec:B.bind(y),hasSpec:P.bind(y),newSpecId:T.bind(y),emptySpec:H.bind(y),forkSpec:q.bind(y),newSpec:U.bind(y),setSpec:J.bind(y),injectSpecs:w.bind(y),deleteSpec:E.bind(y),registerUnit:$.bind(y),unregisterUnit:G.bind(y),shouldFork:K.bind(y),injectPrivateCSSClass:function(M,k,R){if(nt.root){if(!nt.global.component[M])throw new Error("component not found");let X=`${$f(R)}`;return Nf(nt,X),()=>{Ff(nt,X)}}else return gt},getLocalComponents:function(M){let k=N[M];return k?[...k].map(R=>rt[R]):[]},registerLocalComponent:function(M,k){var X;let R=Xe(z);return rt[R]=M,z[R]=k,N[k]=(X=N[k])!=null?X:new Set,N[k].add(R),L.emit(k,M),R},unregisterLocalComponent:function(M){let k=z[M];if(!k)throw new Error("local component not found");let R=N[k];R.delete(M),R.size===0&&delete N[k],delete z[M]}};return nt}function Wl(r){let{graphs:n}=r;for(let t of n)t.destroy()}var Ee=class{constructor(n,t){this._unlisten={};this._ref={};this._api=n,this._post=t}exec(n){let{type:t,data:e}=n;switch(t){case pe:{let{id:i,method:o,data:a}=e;this._api[pe][o](a,(s,p)=>{this._post({type:pe,data:{id:i,data:s,err:p}})})}break;case Ue:{let{id:i,method:o,data:a}=e,s=this._api[Ue][o](a,(p,d)=>{this._post({type:Ue,data:{id:i,data:p,err:d}})});this._unlisten[i]=s}break;case $u:{let{id:i}=e,o=this._unlisten[i];o&&(delete this._unlisten[i],o())}break;case we:{let{id:i,method:o,data:a}=e,s=this._api[we][o](a),p=new Ee(s,d=>{this._post({type:we,data:{id:i,data:d}})});this._ref[i]=p}break;case Nu:{let{id:i,data:o}=e;this._ref[i].exec(o)}break;default:throw new Error("invalid remote API data type")}}};var Mn=["appendChild","removeChild","hasChild","child","children","component"],Pn=[],On=["refChild"],XS=[...Mn,...Pn,...On];var Kl=["draw","drawImage","clear","strokePath","scale","fillPath","toBlob"],ql=[],Yl=[];var Un=["emit","eventNames"],wn=["addListener"],Ln=["refEmitter"],nE=[...Un,...wn,...Ln];var O3=["getPinData","getInputData","getUnitPinData","getUnitState","getGraphState","getGraphChildren","getGraphPinData","getGraphData","getGraphErr","getGraphMergeInputData","getUnitInputData","getSpec","getBundle"],dm=["addUnit","addUnits","removeUnit","cloneUnit","moveUnit","exposePinSet","coverPinSet","exposePin","coverPin","plugPin","unplugPin","exposeUnitPinSet","coverUnitPinSet","setPinSetFunctional","setUnitId","setUnitPinData","setUnitPinConstant","setUnitPinIgnored","setUnitPinSetId","setPinSetId","addMerge","removeMerge","addMerges","addPinToMerge","removePinFromMerge","mergeMerges","setMetadata","moveUnitInto","appendRoot","removeRoot","appendParentRoot","appendParentRootChildren","reorderSubComponent","removeUnitPinData","setMergeData","removeMergeData","takeUnitErr","setUnitId","moveSubgraphInto","bulkEdit"],Gn=[...O3,...dm],Rn=["watchGraph","watchUnit","watchGraphUnit","watchUnitPath","watchGraphUnitPath"],kn=["transcend","refSubComponent","refUnit"],oE=[...Gn,...Rn,...kn];var $n=["get","set"],Nn=[],Fn=[],pE=[...$n,...Nn,...Fn];var Dc=["stream"],Sc=[],Ec=[];var Tc=[],Ac=[],Cc=["newGraph"];var Bn=["getGlobalId","getListeners","call","play","pause","push","pullInput","takeInput","renamePin","setPinData","removePinData","getPinData","getInputData","getRefInputData","err"],jn=["watch"],Hn=["refGlobalObj"],bE=[...Bn,...jn,...Hn];var Vn=["read","write"],zn=[],Wn=[],yE=[...Vn,...zn,...Wn];var mm="/",U3="_";var Kn="@",Mc="#",w3="$",Jl="%",Xl="^";var ge=`[^${mm}${Kn}${Mc}${w3}${Jl}${Xl}]+`,qn="[^]+",L3=`^(${ge})$`,G3=`^(${ge})/(input|output)/(${qn})$`,R3=`((${ge})|(${ge})/(input|output)/(${qn})|(${Kn}/${ge}))`,k3=`^(${ge})/input/(${qn})$`,$3=`^(${ge})/output/(${qn})$`,SE=new RegExp(`^${ge}$`),EE=new RegExp(`^${R3}$`),TE=new RegExp(L3),AE=new RegExp(G3),CE=new RegExp(k3),ME=new RegExp($3),PE=new RegExp(`^${Mc}/[^#_]+$`),OE=new RegExp(`^\\$/[^]+/${ge}$`),UE=new RegExp(`^${Kn}/[^/#$]+$`),wE=new RegExp(`^${Jl}/(input|output)/[^${mm}${Mc}${Kn}]+$`),LE=new RegExp(`^\\${Xl}/(input|output)/${qn}/[^${mm}${Mc}${Kn}]+$`),GE=new RegExp(`^(.+)${U3}(.+)$`);function Zl(r){let{base:n}=r;return!!n}function Ql(r){return r.split(/(?=[A-Z])/).map(e=>e.toLowerCase()).join("_")}function t1(r){return r.split(/(?=[A-Z])/).map(e=>e.toLowerCase()).join("-")}var e1=dm.reduce((r,n)=>Z(_({},r),{[n]:Ql(n)}),{});var n1=Lf(e1,(r,n)=>`$${n}`);function i1(r){return`$${r}`}var r1=new Set(["watch","watchGraph"]);var o1=new Set([...r1].map(i1));function N3(r,n,t){let e;return new Proxy(r,{get:(o,a)=>{let s=o[a];if(n[a])e=n[a];else if(t.has(a))return(p,d)=>s.call(o,p,c=>{var f,g,h;let{event:m}=c;e===m&&((h=(g=(f=c.data)==null?void 0:f.path)==null?void 0:g.length)!=null?h:0)===0?e=void 0:d(c)});return s}})}var F3={V:{$write:"write"},J:{$set:"set"},CA:{$draw:"draw"},G:n1,B:{},IB:{},CC:{},C:{},CS:{},CO:{},GP:{},M:{},E:{},EE:{},BD:{},BS:{},BSE:{},BC:{},NO:{},A:{},PP:{},PS:{},CH:{},MS:{},S:{},U:{},TR:{},RE:{},F:{},L:{},AC:{},D:{}},B3={G:o1};function Ct(r,n=[]){let t={},e=new Set;for(let i of n){let o=F3[i]||{},a=B3[i]||new Set;t=_(_({},t),o),e=new Set([...e,...a])}return N3(r,t,e)}var fm=r=>({$draw:function(n){throw new O},$drawImage:function(n){throw new O},$clear:function(n){throw new O},$strokePath:function(n){throw new O},$scale:function(n){throw new O},$fillPath:function(n){throw new O},$toBlob:function(n,t){throw new O}}),lm=r=>({}),bm=r=>({}),a1=r=>_(_(_({},fm(r)),lm(r)),bm(r));var j3=r=>({}),H3=r=>({}),V3=r=>({}),s1=r=>_(_(_({},j3(r)),H3(r)),V3(r));function p1(r){let t=Mt(r,["EE"]);return Ct(t,["EE"])}var gm=r=>({$emit({type:n,data:t},e){r.emit(n,t),e()},$eventNames(n,t){let e=r.eventNames();t(e)}}),hm=r=>({$addListener({event:n},t){return r.addListener(n,t)}}),ym=r=>({$refEmitter({}){return p1(r)}}),Pc=r=>_(_(_({},gm(r)),hm(r)),ym(r));function _m(r){return()=>{A(r,n=>{n()})}}function u1(r,n,t){let e=(i,o,a)=>{t({type:"graph",event:r,data:{actions:i,transaction:o,path:a}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function xm(r,n,t){let e=(i,o,a,s,p)=>{t({type:"graph",event:r,data:{type:i,pinId:o,subPinId:a,subPinSpec:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function Im(r,n,t){let e=(i,o,a,s,p)=>{t({type:"graph",event:r,data:{type:i,pinId:o,pinSpec:a,data:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function c1(r,n,t){let e=(i,o,a)=>{t({type:"graph",event:r,data:{path:a,specId:i,spec:o}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function vm(r,n,t){let e=(...[i,o,a,s])=>{t({type:"graph",event:r,data:{mergeId:i,mergeSpec:o,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function d1(r,n,t){let e=(...[i,o,a,s,p,d])=>{t({type:"graph",event:r,data:{parentId:i,prevParentIdMap:o,children:a,slotMap:s,prevSlotMap:p,path:d}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function Dm(r,n,t){let e=(...[i,o,a,s,p,d,c,m,f,g,h])=>{t({type:"graph",event:r,data:{graphId:i,graphBundle:o,nodeIds:s,nextSpecId:a,nextIdMap:p,nextPinIdMap:d,nextMergePinId:c,nextPlugSpec:m,nextSubComponentParentMap:f,nextSubComponentChildrenMap:g,nextSubComponentIndexMap:{},nextUnitPinMergeMap:{},path:h}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function Sm(r,n,t){let e=(i,o,a,s,p)=>{t({type:"graph",event:r,data:{mergeId:i,unitId:o,type:a,pinId:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function Em(r,n,t){let e=(i,o,a,s,p)=>{t({type:"graph",event:r,data:{type:i,pinId:o,subPinId:a,subPinSpec:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function m1(r,n,t){let e=(...[i,o,a,s])=>{t({type:"graph",event:r,data:{unitId:i,type:o,pinId:a,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function f1(r,n,t){let e=(...[i,o,a,s])=>{t({type:"graph",event:r,data:{parentId:i,childId:o,to:a,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function l1(r,n,t){let e=(...[i,o,a,s])=>{t({type:"graph",event:r,data:{type:i,pinId:o,functional:a,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function b1(r,n,t){let e=(...[i,o,a,s])=>{t({type:"graph",event:r,data:{type:i,pinId:o,nextPinId:a,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function g1(r,n,t){let e=(i,o,a,s,p)=>{t({type:"graph",event:r,data:{unitId:i,newUnitId:o,name:a,specId:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function h1(r,n,t){let e=(...[i,o,a,s,p,d])=>{p instanceof C&&(p=null),p!==void 0&&(p=Y(p)),t({type:"graph",event:r,data:{unitId:i,type:o,pinId:a,constant:s,data:p,path:d}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function y1(r,n,t){let e=(...[i,o,a,s,p])=>{let d=Y(s);t({type:"graph",event:r,data:{unitId:i,type:o,pinId:a,data:d,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function _1(r,n,t){let e=(...[i,o,a,s,p])=>{t({type:"graph",event:r,data:{unitId:i,type:o,pinId:a,ignored:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function x1(r,n,t){let e=(...[i,o,a,s,p])=>{t({type:"graph",event:r,data:{unitId:i,type:o,pinId:a,nextPinId:s,path:p}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function I1(r,n,t){let e=(i,o,a)=>{t({type:"graph",event:r,data:{unitId:i,unitSpec:o,path:a}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function v1(r,n,t){let e=(i,o)=>{t({type:"graph",event:r,data:{unitId:i,path:o}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function Tm(r,n,t){let e=(i,o,a,s)=>{t({type:"graph",event:r,data:{unitId:i,bundle:o,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function D1(r,n,t){let e=(i,o,a,s)=>{t({type:"graph",event:r,data:{unitId:i,newUnitId:o,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function S1(r,n,t){let e=(i,o,a,s)=>{t({type:"graph",event:r,data:{id:i,unitId:o,inputId:a,path:s}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}var Oc={fork:c1,add_unit:Tm,remove_unit:Tm,clone_unit:D1,move_unit:S1,component_append:I1,component_remove:v1,add_merge:vm,remove_merge:vm,add_pin_to_merge:Sm,remove_pin_from_merge:Sm,expose_pin:xm,cover_pin:xm,expose_pin_set:Im,cover_pin_set:Im,plug_pin:Em,unplug_pin:Em,move_subgraph_into:Dm,move_subgraph_out_of:Dm,reorder_sub_component:f1,move_sub_component_root:d1,set_unit_pin_constant:h1,set_unit_pin_set_id:x1,set_unit_pin_ignored:_1,set_pin_set_functional:l1,set_pin_set_id:b1,set_unit_pin_data:y1,remove_unit_pin_data:m1,set_unit_id:g1,bulk_edit:u1};function E1(r,n,t){let e=[];for(let o in Oc)if(n.includes(o)){let a=Oc[o];e.push(a(o,r,t))}return tt(e)}function T1(r,n=wt,t){let e=[];if(r instanceof Lt)for(let o of n){let a=Oc[o];a&&e.push(a(o,r,t))}return tt(e)}function Am(r,n,t,e,i){let o=a=>{a instanceof C&&(a=null),a!==void 0&&(a=Y(a)),i({type:n,event:r,data:{type:n,pinId:t,data:a}})};return e.prependListener(r,o),()=>{e.removeListener(r,o)}}function rn(r,n,t,e){let i=[Am("data",r,n,t,e),Am("drop",r,n,t,e)],o=tt(i);return()=>{o()}}var A1=(r,n)=>({input:r,output:n});function C1(r,n,t){return rn("input",r,n,t)}function M1(r,n,t){return rn("output",r,n,t)}function z3(r){let n=r.getGlobalId(),t=r.getInterface();return{globalId:n,__:t,_:void 0}}function Cm(r,n,t,e,i,o){let a=s=>{let p=s instanceof Function?Y(s):z3(s);o({type:n,event:r,data:{type:t,pinId:e,data:p}})};if(r==="data"&&i.active()){let s=i.peak();a(s)}return i.prependListener(r,a),()=>{i.removeListener(r,a)}}function Uc(r,n,t,e,i){let o=[Cm("data",r,n,t,e,i),Cm("drop",r,n,t,e,i)];return tt(o)}function P1(r,n,t){return Uc("ref_input","input",r,n,t)}function O1(r,n,t){return Uc("ref_output","output",r,n,t)}function wc(r,n,t){let e=i=>{t({type:"unit",event:r,data:{err:i}})};return n.prependListener(r,e),()=>{n.removeListener(r,e)}}function U1(r,n,t=wt){let e=[];return t.includes("err")&&e.push(wc("err",r,n)),t.includes("take_err")&&e.push(wc("take_err",r,n)),t.includes("catch_err")&&e.push(wc("catch_err",r,n)),tt(e)}function Fe(r,n,t){let e=i=>{t({type:"unit",event:r,data:i})};return n.addListener(r,e),()=>{n.removeListener(r,e)}}function Mm(r,n,t){let e=(i,o)=>{t({type:"unit",event:r,data:{name:i,newName:o}})};return n.addListener(r,e),()=>{n.removeListener(r,e)}}function w1(r,n,t){let e=(i,o)=>{o=o!==void 0?Y(o):o,t({type:"unit",event:r,data:{name:i,data:o}})};return n.addListener(r,e),()=>{n.removeListener(r,e)}}function L1(r,n,t){let e=i=>{t({type:"unit",event:r,data:i})};return n.addListener(r,e),()=>{n.removeListener(r,e)}}function G1(r,n,t){let e=(i,o)=>{o.length>0||t({type:"unit",event:r,data:i,path:o})};return n.addListener(r,e),()=>{n.removeListener(r,e)}}function R1(r,n,t){let e=(i,o)=>{o.length>0||t({type:"unit",event:r,data:i,path:o})};return n.addListener(r,e),()=>{n.removeListener(r,e)}}var Yn=(r,n,t)=>{let e=[],i=(o,a)=>{t({type:"unit",event:r,data:{pinId:o}})};return n.addListener(r,i),()=>{tt(e)(),n.removeListener(r,i)}};function k1(r,n,t=wt){let e=[];return t.includes("set_input")&&e.push(Yn("set_input",r,n)),t.includes("set_output")&&e.push(Yn("set_output",r,n)),t.includes("remove_input")&&e.push(Yn("remove_input",r,n)),t.includes("remove_output")&&e.push(Yn("remove_output",r,n)),tt(e)}function Lc(r,n=wt,t){let e=[],i=n.includes("input"),o=n.includes("ref_input"),a=n.includes("output"),s=n.includes("ref_output"),p=n.includes("rename_input"),d=n.includes("rename_output"),c=A1({},{}),m=(y,I,v,T)=>{let P={ref:{input:P1,output:O1},data:{input:C1,output:M1}}[y][I](v,T,t);return c[I][v]=P,e.push(P),P},f=(y,I)=>(v,T)=>{m(I,y,T,v)},g=(y,I)=>{let v=c[y][I];v&&(v(),$t(e,v),delete c.input[I])},h=(y,I)=>{let v=r.getPin(y,I),T=r.isPinRef(y,I);T&&o?m("ref",y,I,v):!T&&i&&m("data",y,I,v)};return i&&A(r.getDataInputs(),f("input","data")),o&&A(r.getRefInputs(),f("input","ref")),(i||o)&&e.push(r.addListener("set_input",(y,I,{ref:v})=>{h("input",y)})),e.push(r.addListener("rename_input",(y,I)=>{g("input",y),h("input",I)})),e.push(r.addListener("rename_output",(y,I)=>{g("output",y),h("output",I)})),p&&e.push(Mm("rename_input",r,t)),e.push(r.addListener("remove_output",(y,I)=>{let v=c.output[y];v&&(v(),$t(e,v),delete c.output[y])})),a&&A(r.getDataOutputs(),f("output","data")),s&&A(r.getRefOutputs(),f("output","ref")),(a||s)&&e.push(r.addListener("set_output",(y,I,{ref:v})=>{v&&s?m("ref","output",y,I):!v&&a&&m("data","output",y,I)})),d&&e.push(Mm("rename_output",r,t)),r.isElement()&&(n.includes("append_child")&&e.push(G1("append_child",r,t)),n.includes("remove_child")&&e.push(R1("remove_child",r,t))),e.push(U1(r,t,n)),e.push(k1(r,t,n)),tt(e)}function Gc(r,n,t=wt){let e={},i={},o=(h,x)=>{let y=Lc(h,t,({type:v,event:T,data:P})=>{n({type:v,event:T,data:Z(_({},P),{unitId:x})})}),I=T1(h,t,({type:v,event:T,data:P})=>{n({type:v,event:T,data:Z(_({},P),{unitId:x})})});e[x]=tt([y,I])},a=(h,x)=>{let y=At(x,"input"),I=h.getInput(y),v=rn("merge",x,I,({type:T,event:P,data:H})=>{n({type:T,event:P,data:Z(_({},H),{mergeId:x})})});i[x]=v},s=(h,x,y)=>{y.length===0&&o(x,h)},p=(h,x,y,I)=>{I.length===0&&o(y,x)},d=(h,x,y,I)=>{I.length===0&&a(y,h)},c=(h,x,y)=>{if(y.length===0){let I=e[h];I(),delete e[h]}},m=(h,x,y,I)=>{if(I.length===0){let v=i[h];v(),delete i[h]}},f=r.getUnits(),g=r.getMerges();return A(f,o),A(g,a),r.addListener("before_add_unit",s),r.addListener("clone_unit",p),r.addListener("before_add_merge",d),r.addListener("before_remove_unit",c),r.addListener("before_remove_merge",m),()=>{r.removeListener("before_add_unit",s),r.removeListener("clone_unit",p),r.removeListener("before_add_merge",d),r.removeListener("before_remove_unit",c),r.removeListener("before_remove_merge",m),_m(e)(),_m(i)()}}var on=class extends Q{constructor({i:t=[],o:e=[]},i,o,a){super({i:t,o:e},i,o,a);this.__=["U","J","V"];this.stateful=!0;this._defaultState={};this._state={};this._set_from_input=!1}subscribe(t,e,i){throw new O}onDataInputData(t,e){this.set(t,e,!0)}onDataInputDrop(t){this._set_from_input=!1,this._backwarding||this.set(t,void 0)}onRefInputData(t,e){super.onRefInputData(t,e),this._forwarding=!0,this.set(t,e),this._forwarding=!1}onRefInputDrop(t){this._backwarding||this.set(t,void 0)}get(t){return b(this,null,function*(){var e;return(e=this._state[t])!=null?e:this._defaultState[t]})}read(){return b(this,null,function*(){return this._state})}write(t){this._state=t}set(t,e,i=!1){return b(this,null,function*(){this._set_from_input=i,this._state[t]=e,this.emit("set",t,e),this.emit(t,e)})}hasKey(t){throw new O}delete(t){delete this._state[t]}deepSet(t,e){throw new O}deepGet(t){throw new O}deepDelete(t){throw new O}keys(){throw new O}snapshotSelf(){let t={};for(let e in this._state){let i=this._state[e];i instanceof C?t[e]=null:t[e]=i}return Z(_({},super.snapshotSelf()),{_state:t})}restoreSelf(t){let o=t,{_state:e}=o,i=bt(o,["_state"]);super.restoreSelf(i),this._state=e||this._defaultState}};function Jn(r,n,t=wt){let e=[];return e.push(Lc(r,t,n)),r instanceof on&&t.includes("set")&&e.push(w1("set",r,n)),r.isElement()&&t.includes("call")&&e.push(L1("call",r,n)),t.includes("play")&&e.push(Fe("play",r,n)),t.includes("pause")&&e.push(Fe("pause",r,n)),t.includes("listen")&&e.push(Fe("listen",r,n)),t.includes("unlisten")&&e.push(Fe("unlisten",r,n)),t.includes("register")&&e.push(Fe("register",r,n)),t.includes("unregister")&&e.push(Fe("unregister",r,n)),r instanceof Lt&&e.push(E1(r,t,n)),tt(e)}var Pm=r=>({$setUnitId({unitId:t,newUnitId:e,name:i,specId:o}){r.setUnitId(t,e,i,o)},$setUnitPinData({unitId:t,pinId:e,type:i,data:o}){let a=r.__system,{specs:s,classes:p}=a,d=a.specs;o=st(o,ut(s,d),p),r.setUnitPinData(t,i,e,o)},$removeUnitPinData({unitId:t,type:e,pinId:i}){r.removeUnitPinData(t,e,i)},$addUnit({unitId:t,bundle:e}){r.addUnitSpec(t,e)},$cloneUnit({unitId:t,newUnitId:e}){r.cloneUnit(t,e)},$moveUnit({id:t,unitId:e,inputId:i}){r.moveUnit(t,e,i)},$addUnits({units:t}){let{specs:e,classes:i}=r.__system,o=vt(t,a=>Z(_({},a),{Class:le(a.id,e,i)}));r.addUnitSpecs(o)},$removeUnit({unitId:t}){r.removeUnit(t)},$exposePinSet({type:t,pinId:e,pinSpec:i,data:o}){let a=o&&st(o,r.__system.specs,r.__system.classes);r.exposePinSet(t,e,i,a)},$coverPinSet({type:t,pinId:e}){r.coverPinSet(t,e,!0)},$exposePin({type:t,pinId:e,subPinId:i,subPinSpec:o}){r.exposePin(t,e,i,o)},$coverPin({type:t,pinId:e,subPinId:i}){r.coverPin(t,e,i)},$plugPin({type:t,pinId:e,subPinId:i,subPinSpec:o}){r.plugPin(t,e,i,o)},$unplugPin({type:t,pinId:e,subPinId:i}){r.unplugPin(t,e,i)},$exposeUnitPinSet({unitId:t,type:e,pinId:i,pinSpec:o}){r.getUnit(t).exposePinSet(e,i,o)},$coverUnitPinSet({unitId:t,type:e,pinId:i}){r.getUnit(t).coverPinSet(e,i)},$setPinSetId({type:t,pinId:e,nextPinId:i}){r.setPinSetId(t,e,i)},$setPinSetFunctional({type:t,pinId:e,functional:i}){r.setPinSetFunctional(t,e,i)},$setUnitPinConstant({unitId:t,type:e,pinId:i,constant:o}){r.setUnitPinConstant(t,e,i,o)},$setUnitPinIgnored({unitId:t,type:e,pinId:i,ignored:o}){r.setUnitPinIgnored(t,e,i,o)},$setUnitPinSetId({unitId:t,type:e,pinId:i,nextPinId:o}){r.setUnitPinSetId(t,e,i,o)},$addMerge({mergeId:t,mergeSpec:e}){r.addMerge(e,t)},$removeMerge({mergeId:t}){r.removeMerge(t,!0,!1)},$addMerges({merges:t}){r.addMerges(t)},$setMergeData({mergeId:t,data:e}){let i=r.refSystem(),{specs:o,classes:a}=i,s=st(e,o,a);r.setMergeData(t,s)},$removeMergeData({mergeId:t}){r.removeMergeData(t)},$addPinToMerge({mergeId:t,unitId:e,type:i,pinId:o}){r.addPinToMerge(t,e,i,o)},$removePinFromMerge({mergeId:t,unitId:e,type:i,pinId:o}){r.removePinFromMerge(t,e,i,o)},$takeUnitErr({unitId:t}){r.takeUnitErr(t)},$removeUnitGhost({unitId:t,nextUnitId:e,nextUnitSpec:i},o){let a=r.removeUnitGhost(t,e,i);Wf(a.bundle),o(a)},$addUnitGhost({unitId:t,nextUnitId:e,nextUnitBundle:i,nextUnitPinMap:o}){r.addUnitGhost(t,e,i,o)},$getBundle({},t){let e=r.getBundleSpec(),{spec:i}=e;Kd(i),t(e)},$getUnitPinData({unitId:t,type:e,pinId:i},o){let a=r.getUnitData(t,e,i);o(a)},$getUnitState(i,o){return b(this,arguments,function*({unitId:t},e){let a=yield r.getUnitState(t);e(a)})},$getGraphData(t,e){let i=r.getGraphState(),o=r.getGraphChildren(),a=r.getGraphErr(),s=r.getUnits(),p={};A(s,(m,f)=>{let g=m.getPinsData(),h=In(g);p[f]=h});let d=r.getGraphMergeInputData(),c={};for(let m in d){let f=d[m];f===void 0?c[m]=void 0:c[m]=Y(f)}e({state:i,children:o,err:a,pinData:p,mergeData:c})},$snapshot(t,e){return b(this,null,function*(){let i=r.snapshot();e(i)})},$snapshotUnit({unitId:t},e){let o=r.getUnit(t).snapshot();ke(o),e(o)},$getGraphState(e,i){return b(this,arguments,function*({},t){let o=yield r.getGraphState();t(o)})},$getGraphChildren({},t){let e=r.getGraphChildren();t(e)},$getGraphErr({},t){let e=r.getGraphErr();t(e)},$getGraphPinData({},t){let e={},i=r.getUnits();A(i,(o,a)=>{let s=o.getPinsData(),p=In(s);e[a]=p}),t(e)},$getGraphMergeInputData({},t){let e=r.getGraphMergeInputData(),i=Se(e);t(i)},$getUnitInputData({unitId:t},e){let i=r.getUnitInputData(t);e(i)},$setMetadata({path:t,data:e}){r.setMetadata(t,e)},$reorderSubComponent({parentId:t,childId:e,to:i}){r.reorderSubComponent(t,e,i)},$moveSubComponentRoot({parentId:t,children:e,slotMap:i}){r.moveSubComponentRoot(t,e,i)},$moveSubgraphInto({graphId:t,nextSpecId:e,nodeIds:i,nextIdMap:o,nextPinIdMap:a,nextMergePinId:s,nextPlugSpec:p,nextSubComponentParentMap:d,nextSubComponentChildrenMap:c}){let m=r.getGraphUnitBundleSpec(t);r.moveSubgraphInto(t,m,e,i,o,a,s,p,d,c)},$moveSubgraphOutOf({graphId:t,nextSpecId:e,nodeIds:i,nextIdMap:o,nextPinIdMap:a,nextMergePinId:s,nextPlugSpec:p,nextSubComponentParentMap:d,nextSubComponentChildrenMap:c}){let m=r.getGraphUnitBundleSpec(t);r.moveSubgraphInto(t,m,e,i,o,a,s,p,d,c)},$bulkEdit({actions:t}){r.bulkEdit(t)}}),Om=r=>({$watchGraph({events:n},t){return Gc(r,t,n)},$watchUnit({unitId:n,events:t},e){let i=r.getUnit(n);return Jn(i,e,t)},$watchGraphUnit({unitId:n,events:t},e){let i=this.refUnit(n);return Gc(i,e,t)},$watchUnitPath({path:n,events:t},e){let i=r.getUnitByPath(n);return Jn(i,e,t)},$watchGraphUnitPath({path:n,events:t},e){let i=r.getUnitByPath(n);return Gc(i,e,t)}}),Um=r=>({$compose({id:n,unitId:t,_:e}){let i=r.refSystem(),o=r.getSpec();if(i.hasSpec(n))throw new Error(`spec with id '${n}' already exists`);o.component&&!Ft(o.component.subComponents||{})?r.setElement():r.setNotElement();let s=ve({id:n});i.setSpec(n,s);let p=new Lt(s,{},i);p.addUnit(t,r,void 0,!1),p.play();let d=Mt(p,e);return Ct(d,e)},$refUnit({unitId:n,_:t}){let e=r.getUnit(n),i=Mt(e,t);return Ct(i,t)},$refSubComponent({unitId:n,_:t}){let e=r.getUnit(n),i=Mt(e,t);return Ct(i,t)}}),Rc=r=>_(_(_({},Om(r)),Pm(r)),Um(r));var wm=r=>({$get({name:n},t){b(this,null,function*(){let e;try{e=yield r.get(n)}catch(i){t(void 0,i.message)}t(e)})},$set({name:n,data:t},e){b(this,null,function*(){try{let i=st(t,{},{});yield r.set(n,i)}catch(i){e(void 0,i.message)}e()})}}),Lm=r=>({}),Gm=r=>({}),$1=r=>_(_(_({},wm(r)),Lm(r)),Gm(r));var Rm=r=>({$get(n,t){return r.mediaStream(t)}}),km=r=>({}),$m=r=>({}),N1=r=>_(_(_({},Rm(r)),km(r)),$m(r));var W3=(r,n)=>{let t=Bf(r,n);return Mt(t,t.__)},Nm=r=>({$getGlobalId(n,t){let e=r.getGlobalId();t(e)},$play(n){r.play()},$pause(n){r.pause()},$paused(n,t){let e=r.paused();t(e)},$reset(n){r.reset()},$push({pinId:n,data:t}){let{classes:e,specs:i}=r.__system,o=st(t,i,e);r.push(n,o)},$takeInput(n){let{pinId:t}=n;r.takeInput(t)},$setPinData({type:n,pinId:t,data:e}){let{classes:i,specs:o}=r.__system,a=st(e,o,i);r.setPinData(n,t,a)},$removePinData(n){let{type:t,pinId:e}=n;r.removePinData(t,e)},$getPinData(n,t){let e=r.getPinsData(),i=In(e);t(i)},$getInputData(n,t){let e=r.getInputData();t(e)},$getRefInputData(n,t){let e=r.getRefInputData(),i=vt(e,o=>{let a=o.getInterface();return{globalId:o.getGlobalId(),__:a}});t(i)},$getUnitBundleSpec(n,t){let e=r.getUnitBundleSpec(n.deep),i=j(e);t(i)},$pullInput(n){let{pinId:t}=n;r.getInput(t).pull()}}),Fm=r=>({$watch({events:n},t){return Jn(r,t,n)}}),Bm=r=>({$refGlobalObj(n){let t=r.refSystem(),{globalId:e}=n,i=W3(t,e);return Ct(i,i.__)}}),kc=r=>_(_(_({},Nm(r)),Fm(r)),Bm(r));var F1=r=>_(_(_({},Pc(r)),kc(r)),$c(r));var B1=r=>_(_({},F1(r)),Rc(r));var jm=r=>({}),Hm=r=>({}),Vm=r=>({$newGraph({bundle:n,_:t}){let e=r.fromBundle(n),i=r.newGraph(e),o=B1(i);return Ct(o,t)}}),j1=r=>_(_(_({},jm(r)),Hm(r)),Vm(r));var zm=r=>({$read(e,i){return b(this,arguments,function*({},t){let o;try{o=yield r.read()}catch(s){return t(void 0,s.message)}let a=Y(o);t(a)})},$write(i,o){return b(this,arguments,function*({data:t},e){yield r.write(t),e()})}}),Wm=r=>({}),Km=r=>({}),H1=r=>_(_(_({},zm(r)),Wm(r)),Km(r));var K3=r=>({}),q3=r=>({}),Y3=r=>({$refChildContainer({at:n,_:t}){return z1(r,{at:n,_:t})},$refParentRootContainer({at:n,_:t}){return W1(r,{at:n,_:t})},$refParentChildContainer({at:n,_:t}){return K1(r,{at:n,_:t})}}),V1=r=>_(_(_({},K3(r)),q3(r)),Y3(r));var Nc=(r,n,t)=>{let e=r;for(let i of n){let o=t[i];if(!o)throw new Error("async wrapper is not registered");let a=o(r);for(let s in a)e[s]=a[s]}return e};var Mt=(r,n)=>r.__async?r:Nc(r,n,{C:$c,CA:a1,E:s1,G:Rc,V:H1,MS:N1,U:kc,J:$1,W:V1,EE:Pc,S:j1});function q1(r,n,t){let e=r.appendChild(n);t(e)}function Y1(r,{at:n},t){try{let o=r.removeChild(n).getUnitBundleSpec().unit.id;t({specId:o})}catch(e){t(void 0,e.message)}}function J1(r,{at:n},t){let e=r.hasChild(n);t(e)}function X1(r,{at:n},t){let i=r.refChild(n).constructor.id;t(i)}function Z1(r,{},n){let e=r.refChildren().map(i=>({bundle:i.getUnitBundleSpec()}));n(e)}function Q1(r,{at:n,_:t}){let e=r.refChild(n),i=Mt(e,t);return Ct(i,t)}function z1(r,{at:n,_:t}){let e=r.refChildContainer(n),i=Mt(e,t);return Ct(i,t)}function W1(r,{at:n,_:t}){let e=r.refParentRootContainer(n),i=Mt(e,t);return Ct(i,t)}function K1(r,{at:n,_:t}){let e=r.refParentChildContainer(n),i=Mt(e,t);return Ct(i,t)}function t0(r,n,t){let e=r.getAnimations();t(e)}function e0(r,n,t){let e=r.getSetup();t(e)}var qm=r=>({$appendChild({specs:n,classes:t,specId:e},i){let o=le(e,n,t);q1(r,o,i)},$removeChild(n,t){return Y1(r,n,t)},$hasChild(n,t){return J1(r,n,t)},$child(n,t){return X1(r,n,t)},$children(n,t){return Z1(r,n,t)},$getAnimations(n,t){return t0(r,n,t)},$getSetup(n,t){return e0(r,n,t)}}),Ym=r=>({}),Jm=r=>({$refChild(n){return Q1(r,n)}}),$c=r=>_(_(_({},qm(r)),Ym(r)),Jm(r));var J3={EE:{call:Un,watch:wn,ref:Ln},U:{call:Bn,watch:jn,ref:Hn},G:{call:Gn,watch:Rn,ref:kn},C:{call:Mn,watch:Pn,ref:On},V:{call:Vn,watch:zn,ref:Wn},J:{call:$n,watch:Nn,ref:Fn},MS:{call:Dc,watch:Sc,ref:Ec},S:{call:Tc,watch:Ac,ref:Cc},CA:{call:Kl,watch:ql,ref:Yl}};function he(r){let n={};for(let t in r){let e=r[t],i=o=>{let{_:a}=o,s=e(o),p={call:{},watch:{},ref:{}};for(let d of a){let c=J3[d];for(let m of["call","watch","ref"]){let f=c[m];for(let g of f){let h=`$${g}`;p[m][h]=(...x)=>{let y=s[h](...x);return m==="ref"?Xn(y,y.__):y}}}}return p};n[t]=i}return n}function Xn(r,n){let t={},e={},i={};for(let a of n)switch(a){case"EE":t=_(_({},t),gm(r)),e=_(_({},e),hm(r)),i=_(_({},i),he(ym(r)));break;case"U":t=_(_({},t),Nm(r)),e=_(_({},e),Fm(r)),i=_(_({},i),he(Bm(r)));break;case"C":t=_(_({},t),qm(r)),e=_(_({},e),Ym(r)),i=_(_({},i),he(Jm(r)));break;case"G":t=_(_({},t),Pm(r)),e=_(_({},e),Om(r)),i=_(_({},i),he(Um(r)));break;case"V":t=_(_({},t),zm(r)),e=_(_({},e),Wm(r)),i=_(_({},i),he(Km(r)));break;case"J":t=_(_({},t),wm(r)),e=_(_({},e),Lm(r)),i=_(_({},i),he(Gm(r)));break;case"MS":t=_(_({},t),Rm(r)),e=_(_({},e),km(r)),i=_(_({},i),he($m(r)));break;case"S":t=_(_({},t),jm(r)),e=_(_({},e),Hm(r)),i=_(_({},i),he(Vm(r)));break;case"CA":t=_(_({},t),fm(r)),e=_(_({},e),lm(r)),i=_(_({},i),he(bm(r)));break;default:throw new Error("unknown interface")}return{call:t,watch:e,ref:i}}function n0(r){let n=!1,t;onmessage=function(e){let{data:i}=e,{type:o,data:a}=i;switch(o){case Zt:n=!0,t=r(a);break;case Ot:if(!n)throw new Error("ref was not initialized");t.exec(a);break;default:throw new Error("invalid message type")}}}var V=class extends Error{constructor(n){super(`${n} API not implemented`)}};var Fc=class extends V{constructor(){super("Display Media")}};var Bc=class extends V{constructor(){super("Media Devices")}};function an(r,n){return!!r.getItem(n)}function Be(r){return et(r)}function i0(r){let n={},t=Be(r);for(let e of t)n[e]=r.getItem(e);return n}function jc(){return i0(localStorage)}function r0(){return i0(sessionStorage)}var Hc=class{constructor(n){this._storage=n}read(){return b(this,null,function*(){return jc()})}write(n){return b(this,null,function*(){})}get(n){return b(this,null,function*(){let t=this._storage.getItem(n);if(t===null)throw new Error("item not found");return t})}set(n,t){return b(this,null,function*(){this._storage.setItem(n,t)})}delete(n){return b(this,null,function*(){this._storage.removeItem(n)})}deepSet(n,t){throw new O}deepGet(n){throw new O}deepDelete(n){throw new O}keys(){return b(this,null,function*(){return Be(this._storage)})}hasKey(n){return b(this,null,function*(){return an(this._storage,n)})}subscribe(n,t,e){throw new O}};function X3(r){return{getItem(n){throw new V(r)},removeItem(n){throw new V(r)},setItem(n,t){throw new V(r)},clear(){throw new V(r)}}}function o0(){return{storage:{local:()=>new Hc(X3("Local Storage"))},selection:{containsSelection:()=>{throw new V("Selection")},removeSelection:()=>{throw new V("Selection")}},file:{isSaveFilePickerSupported:()=>!1,isOpenFilePickerSupported:()=>!1,showOpenFilePicker:()=>{throw new V("File System")},showSaveFilePicker:()=>{throw new V("File System")},fallbackShowOpenFilePicker:()=>{throw new V("File System")},downloadText:n=>{throw new V("Download")},downloadURL:n=>{throw new V("Download")}},animation:{requestAnimationFrame:()=>{throw new V("Animation Frame")},cancelAnimationFrame:()=>{throw new V("Animation Frame")}},device:{vibrate:()=>{throw new V("Vibrate")}},geolocation:{getCurrentPosition:()=>{throw new V("Geolocation")}},input:{keyboard:{},gamepad:{getGamepad:()=>{throw new V("Gamepad")},addEventListener:(n,t,e)=>{throw new V("Gamepad")}},pointer:{getPointerPosition(n){throw new V("Pointer")},setPointerCapture(n,t){throw new V("Pointer Capture")}}},media:{getUserMedia:()=>{throw new Bc},getDisplayMedia:()=>{throw new Fc},enumerateDevices:()=>{throw new V("Enumerate Media Devices")},image:{createImageBitmap:()=>{throw new V("Image Bitmap")}}},screen:{requestWakeLock:()=>{throw new V("Screen Wake Lock")}},bluetooth:{requestDevice:()=>{throw new V("Bluetooth")}},clipboard:{read:()=>{throw new V("Clipboard")},readText:()=>{throw new V("Clipboard")},writeText:()=>{throw new V("Clipboard")}},http:{fetch:()=>{throw new V("Fetch")},EventSource:void 0,listen:function(n,t){throw new V("HTTP Server")}},channel:{local:function(n){throw new V("Local Channel")}},speech:{SpeechGrammarList:function(n){throw new V("Speech Recognition")},SpeechRecognition:function(n){throw new V("Speech Recognition")},SpeechSynthesis:function(n){throw new V("Speech Synthesis")},SpeechSynthesisUtterance:function(n){throw new V("Speech Synthesis")}},document:{createElement(n,t){throw new O},createElementNS(n,t){throw new O},createTextNode(n){throw new O},elementFromPoint(n,t){throw new O},elementsFromPoint(n,t){throw new O},getSelection(){return root.shadowRoot.getSelection()||document.getSelection()},createRange(){return document.createRange()},exitPictureInPicture(){throw new O},MutationObserver:null,PositionObserver:null,ResizeObserver:null,IntersectionObserver:null},querystring:{stringify:function(n){throw new O},parse:function(n){throw new O}},text:{measureText:n=>{throw new V("Measure Text")}},worker:{start:()=>{throw new V("Worker")}},db:void 0,url:{createObjectURL:function(n){throw new O}},uri:{encodeURI:function(n){throw new V("URI")}},alert:{alert:function(n){throw new O},prompt:function(n){throw new O}},location:{toString:function(){throw new O}},window:{open:function(n,t,e){throw new O},AudioContext:void 0,OscillatorNode:void 0,MediaStreamAudioSourceNode:void 0,AnalyserNode:void 0,GainNode:void 0,DelayNode:void 0,ImageCapture:void 0,CompressionStream:void 0,DecompressionStream:void 0,ReadableStream:void 0,getComputedStyle:function(n){throw new O}},navigator:{share:function(n){throw new O}},layout:{reflectChildrenTrait:function(n,t,e,i,o){throw new O}},history:{pushState:function(n,t,e){throw new O},replaceState:function(n,t,e){throw new O}},theme:{setTheme:function(n){throw new O}}}}var a0="5a7912c7-9c67-45b6-ae2b-e352405e6c16";var s0="6fe452f2-2ec1-4ee2-887d-751c3697e6bf",p0="158d85eb-28b8-4355-b637-28a7ec751233",u0="872be100-f4dc-4246-8eea-6e3da31137b7",c0="c5c05c85-f4c1-4b67-ab85-08b61fe67531",d0="fa94b179-00e3-4ed1-814e-7938324a833f",Vc="fa7721eb-1dd6-482e-8c7a-6da35b5f88bc",m0="79f01345-4ed7-47e2-8882-fa3bd282c98a",zc="e9831075-2e62-43a4-84af-0653f7e707a9",f0="f57f5318-f26f-4b9f-b9e2-dcc022ad7728",Wc="609ec474-cd6b-4646-b9b9-5ef4bbb378a7",Kc="9741cb34-bc83-4ebb-a854-edbe9eb3468f";var l0="7014b684-ce58-4b6a-989d-bd6c047daab5",b0="104777ec-afb9-4513-9974-53b5528f0d15",qc="46d98b47-0fa4-409e-bbc6-bb3165d863d8",g0="81006022-e4d0-11ea-902a-fbf9fc5c9246",h0="d9cf4224-39df-434a-85a6-2b143330cbab",y0="22622778-d64f-47e7-8ceb-d175edcc6562",_0="f69e88e3-b2c2-481b-b036-a5c0ed7ccccb",Yc="c6bf897a-4970-4284-bea2-b4a86186f828",x0="d4572f1c-83d3-4a3d-be76-fa16578286d2",I0="be6801c0-02e2-4f76-bcad-b68c80991fad",v0="62d0c3e2-cf8b-4415-acfb-cf31739adce5",D0="0d656c2e-eb10-45f0-b236-f8916492ca86",S0="3d59edf2-5fca-4475-9df0-d876e14f990d",E0="85204bf6-6692-4686-a785-23127c0594b5",T0="1651ce6b-4db0-4787-9edf-f770b72d253c",A0="c9e06816-0d2b-43ec-b7c8-d07563e19b6b",C0="82c3cf2a-0855-4c6d-a4c4-807b0ce1fd35",M0="e13f3090-62a6-4a3b-8401-c571cbf03526",P0="bda175a9-a9d2-4282-9b50-1b008ae8a807",O0="ff976ac8-c54f-4d37-8c7d-089c271cb433",U0="329920ae-7e91-11ea-988e-1b12488c8b89",w0="260d774e-bc89-4027-aa92-cb1985fb312b",L0="06bc3983-44b0-43d6-b041-2e9218ea89c8",G0="8a2b756a-25e4-11eb-860d-1f34c850b992",R0="3432494e-fab6-4e9d-a846-0c48a7c429cd",k0="49e11645-c25d-4bf7-923d-56817f67b686",$0="36329d25-218d-48a5-a06c-1e0525da504f",N0="99657eb7-fb94-474e-b03d-4b08c537c0a2",F0="6d4b8791-95f8-4979-8290-ade2adf4f192",B0="9d853ef5-3fff-474d-a951-6af4237cf4c4",j0="ba38b0af-80c0-49e4-9e39-864396964ccc",H0="69323dab-b425-4a2a-b1c7-d7efc723327a",V0="2b24877a-3221-4288-9f59-efbf29964368",z0="63605ea1-40e7-47db-9f8f-313dffa6e3c9",W0="939ed573-82b8-4385-ac62-88934e5b76c9",K0="b80d4b5a-40e9-11eb-a2bb-1777d47bf9ae",q0="73967b68-9b4b-44c1-8a19-f505551f6c53",Y0="c47d84b2-4207-11eb-a064-a3633d64f05d",J0="76e99304-aa0c-11eb-9bfa-07725a1b4287",X0="3e5c5856-c721-11ea-b7af-07a978a65cdc",Z0="58900411-ccc3-4c5a-86df-86efe6b7e30e",Q0="563e92be-ad5e-4a61-a718-9249c3eac51d",tb="ee184ea6-3c80-4119-919e-290620aafab0",eb="407640f7-f1c3-4297-a5ce-baff357a6d31",nb="7d02d638-a311-4ea8-a0c0-d45baf739e0d",ib="62a19cd6-04bd-4e46-a72e-4fa3516ad3fa",rb="fafc23ce-a259-11eb-b14e-af9d1f579af4";var ob="62af44dc-17d6-459a-b95f-3b8ce5b48856",Jc="3217edcf-2fa1-4dc4-af7c-d6fb607c888d",ab="f68b0b2a-7967-445e-86a8-99ebc1e2144c",sb="e857c770-5a98-4f8d-a0e1-b6cb126071ed",pb="4e63c320-f5a5-4f65-982e-632b5adafa29",ub="3256e26d-8495-4c9d-8998-5b026691231d",Xc="ef4c1d0a-bda1-484e-8fcb-0fdbde195778",cb="2b59f375-ef06-4ec7-80c2-71a53171ec67",Zc="1a59348c-a25a-11eb-8afe-8bedb0732a89",db="b9f90a95-1bfc-4897-9068-2560743821a3",mb="530e83d2-1d61-11eb-b472-53e545a06c92",fb="13d738b9-401d-43c9-852f-e9611545f5bc",lb="2520668c-b279-11ea-ace3-5b84eb02bd7f",bb="123f2837-76c0-4cb2-8d73-29e66879b181",gb="1520b630-93aa-11ea-ac56-7718cb2ad75d",hb="56fb9a32-ad10-11ea-b0f4-3b0ea5e3ac2c",yb="8383c41e-3f9b-4d04-8380-feb583a1404f",_b="b0c25199-c284-4f90-817c-60dc89b15b1c",xb="b2626d61-b17d-4737-bea3-627c0322f9d6",Ib="1b592040-968f-456b-bdb5-b424e08b80f1",vb="e1486d65-7d51-436b-949d-4e57d1f9e4a9",Db="57bcdd88-a4f4-49ab-92d4-ed1969895520",Sb="f9f93972-0764-4095-9ca2-d18b7d9344d4",Eb="3be8272d-310a-4aa2-84a1-71f590a8227a",Tb="ae1f7fc0-d6e7-489c-94ed-dee71c68dbb7",Ab="e547c624-d505-485d-8d78-e393c6beb1b4",Cb="b5ea15f4-9bbd-11eb-b623-37aff4a9ce60",Mb="70972046-ad11-11ea-aaea-0b9067ad19e7",Pb="94e93f42-d05e-45d9-9211-ba903e779f2d",Ob="f712793d-8ee9-4805-9d4a-8c210cae667a",Ub="f60adade-f14e-11ea-b51e-537032a90354",wb="8cd29108-95cd-4217-9721-11f7c7c1131e",Lb="2ff102a7-b469-461f-a3b1-a61b81c1b325",Gb="2af12780-698c-40ca-baa9-5f3260377e0f",Rb="419e468e-e4d4-11ea-8efb-2b9d815b1798",Qc="664b5d3c-e4cf-11ea-ab74-eb6d2f3bd6f1",kb="9414421d-3376-4438-aa03-7afcd860972c",$b="ad2ae8b9-9674-4b22-bed4-4458e0030b1a",td="45b9c329-64e9-4c4a-800b-790947c75754",Nb="60bdba6d-c670-430f-be72-6f39cf4e8453",Fb="c4784b05-1f50-44ad-b812-545b3ed77614",Bb="964d3314-75fe-4a09-8ba8-c49145f29d49",jb="02f91720-c4d5-4d66-ae91-d46ddc635722",Hb="f97f2a74-d9a9-411d-afd3-fda46ba86c3b";var Vb="eb345e08-08fd-4032-bd69-a4e9f55e7aa6",zb="779e538c-b0b9-477e-a986-30ee3abe6fe6",Wb="25d0e003-f002-45ae-a50c-6fa3bffee4eb";var Kb="065d2fc3-af3b-4704-b26e-228d71f61771",qb="b16cccf7-fe33-43a6-b208-48db494376e8",Yb="af5469c4-a09e-4b22-8133-a21e721e7639";var Jb="e1e106ad-e15d-4044-82f6-27ddd476d7c8",Xb="141eaa06-bb12-42f1-a46f-32ceefb64ddc",Zb="c2fec1e6-b370-4069-bb43-6dab5a78b9ab",Qb="adde2d16-e1e6-4599-9a64-dd0968797041",t2="d4e4d4b2-80e0-4066-8d6f-5051e9a11a10";var ed="95076599-0f2f-46b6-a9e0-b4cbfdb8dcc9",e2="ac5863fc-5156-4a27-a6ce-148dc93f34dd",n2="a85fd9ad-5aec-4ebc-9008-e22db851dfa8",i2="49517cda-b9da-4d80-b849-61fc2260317d",r2="ff84b8cd-216f-4bcf-8e29-e7c9998cae3d",o2="43b43afd-9e7d-44ba-aef7-6e9db4ed8744",a2="33434271-3533-4a4e-adb9-306e35ab6afe",s2="0b4aa055-010d-4d43-b991-f38a95cdb380",p2="fa3d97bb-060d-4671-9c18-dff81f64c1cc",u2="1df77a6e-7632-44f0-9878-2aa5e0903928",c2="b949221c-8227-4178-bde4-5e8754a7ed39",d2="d6f727ee-5158-4e2b-a2d4-a84ee712144e",m2="ee7b692f-5fe5-43c3-b636-aacca92b0bc7",f2="c7f6f43e-e8ed-11ea-92b2-0bd612272247",l2="4ad5bd0e-e11e-11ea-ad4c-83da30628333",b2="dd520754-e138-11ea-879e-3bd947893124",g2="a44b2198-e18d-11ea-be3b-77e13b78b7e3",nd="6796cd2d-2bd2-4dd3-9396-49d6bc1d2652",h2="2b0ef9e9-028b-4acc-9daf-6999e86cc2af",y2="58385055-7f06-472a-be9e-26bb5bce276a",_2="81c0f469-ab88-4bc8-89d5-98d291b1d8b2",x2="1ef77768-7394-4b83-ad11-f5905fa9d0d3",I2="288aede9-59ea-4cb4-baf9-fef9109cc2b9",v2="53018958-b686-11ea-bf53-175a3698c92d",D2="82cf909e-a78f-4f3e-b87a-976458c8e15d";var S2="be59cf84-fcf2-46ef-aa34-6f0f8e055680",E2="f5b2faf1-3a8b-489f-9d99-62d3c749ced6",T2="3ab81e83-5954-4bae-ad3e-ebf409dd23c4",A2="8e978642-b686-41fd-b2af-9a4c5db6bfa4",C2="3c47d4bc-315d-4600-a9cd-6e388b345980",M2="138d16a7-a200-4329-9b4a-17abd24943d4",P2="8f7ce559-a046-45bc-8e98-c39934ed0ae6";var O2="9a7c22e3-3de2-4c99-ac1f-b2f8ceffae99",id="c0e124ca-381a-414b-93a2-41526df02e28",U2="83d22558-2c6f-4dd4-a231-baba798d1d97",w2="c9d64ef4-35f6-44e7-a16b-1e4173f951dc",L2="b2eb49a8-7a7a-446a-ad36-e7c1efdaf61f",G2="6f79ee03-4b3f-439c-b955-5529f3bebcc9",R2="0b5a71c6-5c43-4e55-a29c-27d9ff7ed43a";var k2="ee4715e6-f479-11ea-b231-bf95a7f38a99",$2="1ba97b81-5084-49b8-8fbf-227ccd31cabc",N2="c475117a-02b9-11eb-b7c8-579fe4f6c669",F2="41a8c91e-87f8-4d96-9714-33716f329f7b",B2="1ba931d8-0226-4600-9a48-dbb1b17d8d82",j2="fb3fc7b4-3175-41ce-9546-cf3a07053cdc",H2="6dbff818-02b9-11eb-9ee7-93b57419f741";var V2="a1cd3c3c-b1fa-40a2-80d1-32f416264a3d",z2="367241d8-ad12-11ea-beed-9777f31699a8",W2="77238fd9-a968-454d-b7ce-0277bc37475d",K2="a9cba5ec-940d-42a3-b861-86197402cbe4",rd="53dd6448-f1e8-46ed-b3e8-b03b846133bb";var q2="8f72e51a-0c65-47f6-b22b-868c8a00c6dc",Y2="817c76ba-a71c-4136-af86-bd6b69106c45",J2="30f6738c-1938-4dcd-9e7f-6c10f9730021",X2="210632fc-f85b-4f13-a2a9-f689ff85da78",Z2="f5df301d-da63-492a-9e59-950289fe6ba9",Q2="71ff4fda-5878-4d4c-b55b-c2c79d8dc546",tg="5c13db99-0923-4b27-85e3-7a18dbfdd309",eg="a7dee8c6-15a3-4b7e-8f63-03f13a7d34a9",ng="9543c94b-e19e-430b-8a48-9cda8dae44c5",ig="a8d7c089-0385-4922-bb3a-6c550a8a1b3b",rg="2ec96f8b-4ea5-4ba8-ab8d-a00105c6cb71",og="e4ea5dce-10ea-434b-a93d-c874a92f2f39",ag="31408be3-cc2a-490a-b0d1-96e0028ca68e",sg="33c623e5-bce2-4f30-9a98-50218bb6c431",pg="c2738ec3-72fa-4432-96b9-74abb1a6f26a",ug="30e125ba-af81-11ea-ba6b-e70218ca7afe",cg="b5ab65ce-4306-4a46-8d3c-36b6c29b1c60",dg="c18c8f59-f3c8-49a8-9dbd-ed30fdf856e9",mg="3511f756-2a02-4346-b417-8c34502f79d4",fg="6705462c-5b47-11eb-9dfc-2f14c58b2789",lg="0bc0c4ad-d2e0-4e3e-92e8-5b9dfee1cf5e",bg="f238caff-3f71-40d9-b1a9-d992060fea04",gg="262beb5f-21bd-4848-a62d-185f6f8a78e1",hg="a57383a9-5b24-4dbb-a5d1-0e278d036f89",yg="7e1b3a4c-be6b-11eb-b098-1b6b9db93f1e",_g="3889d2f1-a0ed-4e8c-8e75-7a6683224275",xg="a6e30b43-9ab4-4206-bfba-3f2129faac30",Ig="41de8d5e-2c41-441c-ad29-cc3f5d4e6c7a",vg="c5856fdc-5154-46ab-a414-47f37af39da1",Dg="b97c0133-6c87-4b69-af4e-354c0b590ece",Sg="b8fc168e-ee2f-11ea-a42a-730934861ff1",Eg="4e14b9e8-a694-4c58-b509-fc53a279c22c",Tg="29e974cc-081b-11eb-a607-1fd4ec67a52f",Ag="bb029770-080e-11eb-9d38-f314d076f14b",Cg="5aea0bf0-0815-11eb-9304-5f90b5542620",Mg="34a36b3a-cb04-4429-bdbc-15e0c278ad7a",Pg="e8aded15-a1af-42a0-9a9d-f88fcfd03dc3",Og="b27ee28f-54fb-4737-91f5-04b52b7cf92d",Ug="2f2d5ea4-6dd2-406e-a095-5552ebc235e7";var wg="d4ec46ab-d065-4d1c-9357-fa8b95be0c36",Lg="f079a38e-fb4f-496e-8e5f-d5e03a590cda",Gg="16fa715f-fc94-43f7-831e-335037c8daea",Rg="7375aad5-50fd-403c-80ae-471b95088f04",kg="d3fc887c-9fc5-11eb-8f63-ab42b0414469",$g="c6f309c8-9ca7-459c-9dd5-c9c9f92fbe8f",Ng="eed20c86-41fe-46d4-87ba-ad2e6fb1bd4a",Fg="f9be5d07-9548-4a14-b5b9-fa954599a170",Bg="de9665db-a188-4252-99f0-ea50fc343058",jg="b296242e-8b82-11eb-ac6c-0f8d3f9948d0",Hg="04eda925-4423-40c8-83c8-2117a0d81185",Vg="416550cc-6e02-4ff2-aafa-2f0edbf121c6",zg="6db29a62-2035-4cfc-a9d3-03444a8bc2b8",Wg="c8f3faa8-09f4-11eb-a3b1-477aa3ec4193",Kg="dc513ed0-09f4-11eb-a54a-7f4d4e253ef5",qg="08ff535a-93a7-403c-a1ef-c59cdb50ccf0",Yg="0f041192-1ff3-4094-93da-9264480ad5e2";var Jg="baadad13-b70f-4310-b4aa-8c81fe5a9d69",Xg="1d5b6bb0-f18e-4428-a350-a29d8ca3ff4a",Zg="5bd48844-67c6-4fdc-b23b-f03cd561877f",Qg="27e2f302-c23a-4447-abde-8309a94b331d",t4="81ac8195-57ed-4b22-b8b8-fe3e68b11af0",e4="68992d62-d5ca-11ea-888d-97179b32b7ab",n4="81a54674-4e9c-11eb-a0e4-2b75980dbd9b",od="1baddd01-97a9-4971-b74a-e933fefdb629";var i4="72c84615-4d9c-4a82-a828-fa5d9447a4d5",r4="ccf6d0e2-6b08-11eb-9fc3-3785374109d0",o4="0e9e6cd4-67eb-11ea-995b-4b0721193361",a4="c18d7dcc-939b-11ea-90cb-77846d7504a9",s4="e8bce1fc-ae56-4f9f-9685-3cc844758855",p4="e80c912e-7508-11ea-966b-436805345ff0",u4="0f043df2-46fc-11eb-ae20-6f1fedd527ba",c4="c9b62bcc-8196-11eb-8372-9f2ac2c356d4",d4="96d5d60e-85eb-11eb-ba90-7fc42ab0a641",m4="84bfce28-2116-11eb-82ca-cfb03193bf58";var f4="e6b88d1e-8755-11ea-916e-d3995fb8986e",l4="d0672722-b1a9-11ea-a247-d736e666990e",b4="023c3762-c701-11ea-b590-57b51c2884a7",g4="deda524e-6990-11eb-9bc3-e7d55b583fa3",h4="0e1d716e-a13f-11ea-ac6a-8fd610c86910";var y4="fcccb9a4-1a30-11eb-93b0-e7d511d031f2",_4="bc34c618-1c77-11eb-9785-e39a2bf52e49",x4="6b18c608-7b5a-11ea-bb6e-2ff12a5cc3f3",I4="e39a2a34-c71a-11ea-9835-07964acf6760",v4="b61f5cc6-37e9-45e1-965b-02940820f7ce",D4="94243ec4-8967-4907-8cdd-7223fe256cf6",S4="7c27cf95-6226-4326-8619-32d82bcbe16d",E4="66698a97-15c5-4602-9925-11a1aeb03710";var T4="d7c86a2a-489f-11eb-b83e-d3767f6d49b7",A4="dd7616e2-2e64-4d9c-b13e-ca7efeacd982",C4="321f971c-b898-4ca4-9e6e-3d75d68940f7",M4="b7f043ee-4f9d-4f69-90fe-63b1357ff4c2",P4="63a417e5-d354-4b39-9ebd-05f55e70de7b",O4="32ff22b0-8221-4584-9c78-d21102dcfa6a",U4="b5286262-9f92-40d3-8545-88fb3079a0f9",w4="23b7df22-79e0-4233-8388-7e6e8f1859c6",L4="06823924-b659-4a22-8ed4-b3243121b55d",G4="059579bb-184f-435b-ace0-64ec95c9f125",R4="44968bd5-f1a5-4f81-a32f-8ee5a6e4a842",k4="ab507863-2307-40c6-982b-c45680458997",$4="7a8921eb-c1ad-400b-94fc-6c6cead8163d",N4="2a5ad480-9d38-4918-8774-41fac7b54203",ad="78b0939d-43e1-4f6c-867d-e4217a55d217",F4="7772a2f5-40c8-482e-83f4-bed9bfb364e3",B4="c711d540-9de3-437e-854a-b59491af3cf8",j4="62ca7eae-ea36-4960-a8f2-6b5978cabbab",H4="7666978e-252c-11eb-97a4-0f3e81286cae",V4="3fcb8e64-923d-11ea-bab1-43fa3b273af8",z4="e049f16e-2559-11eb-bdc4-db5b8a11164b",W4="be11165e-489f-11eb-921f-87b924eb0725",K4="38d26d76-2559-11eb-ae02-dfda9b9b137e",q4="9932f3bc-9241-11ea-89fa-0b2fdace0f08",Y4="60bc7930-8982-11ea-8b24-cf97a783bb32",J4="c0bfe832-8967-11ea-8c4c-1f2995e41b68",X4="98c279fc-7f5e-11ea-b9e4-f772f9f0bed1",Z4="49ef122e-b4d1-11ea-b45e-b73d8ee2aae8",Q4="00c828fc-9243-11ea-b897-5b0fc55820c5",th="ad12678e-6642-11eb-9fc3-9fbc75c58110",eh="096fc4ca-edd2-11ea-8266-37b634a3ee0b",nh="d8aa573f-129e-4587-9c64-674729d024e2",ih="6309ac3f-4a37-4ab0-86c6-8be70b38e31d",rh="e2109627-9783-4664-a70c-858fd8c46ea5",oh="9bc56564-ef4e-11ea-939a-27ae3feb321e",ah="c0d13c03-9b10-4a6f-a79f-66294d10aae6",sh="51c2c7b4-cb8a-42e8-95ab-14b8ac37700c",ph="6c7cd7d1-c8a0-4317-9c8c-ba781f150729",uh="e06518cf-9edf-430b-8751-74c486e407aa",ch="87f99b85-1c24-4e5b-a903-dd27230f4092",dh="83ec6688-b80b-4ef2-861f-14245ef392c0",mh="6a14988f-5f4b-4fab-af32-226b7844e41f",sd="454aaff2-cd74-4f6e-baf2-631bb32e7a6b",fh="3ffeaaf8-30dd-11eb-9dcc-836b075fc64d";var lh="8be95fbe-8f10-467b-bbdd-87311ca62594",bh="002af312-560a-11eb-807c-8769b90eb8e6",gh="f1ed986a-55df-11eb-89e3-9f7cc8490b16",hh="ef550ed4-5608-11eb-8ee3-0be8f1fce185",yh="159aa41d-fb45-4f75-836b-09a3639156e5",_h="04b06e1c-b782-40fc-bbb3-e932b56db8a2",xh="0966c9b3-2fd5-4b5b-8146-82fb08bd14c4",Ih="738a0ac4-8805-4189-a46c-b7d7fcf63456",vh="59afce80-30e7-4322-84e6-955767bb5106",Dh="d4945010-686d-431b-a884-1a4db0bfafc4",Sh="355b5332-0cc9-4a5c-989e-043d717215ec";var Eh="c320b1b2-c130-4d69-b172-0c737b72c6b5";var Th="ec482aaf-0029-4b85-b03a-de5bd361d706",Ah="04e8b64e-7fed-49a0-af48-eba025be3fbc",Ch="05b6f707-a009-40aa-aacb-a15888c2a8b3",Mh="b51db03f-4d2d-44f9-bbd9-116aa0b086d0",Ph="05169310-5447-4cf8-a90f-fda957de4891",Oh="12d1e7be-a5a6-45ba-82d7-cce3d03b96e2",Uh="d0f94e4e-43f4-4c0a-b07e-ca40c82f48f4",wh="64f8e8bc-124d-49f6-a143-625265eafe68";var Lh="bc0320e2-2eb8-11eb-a38f-a779bfe81645",Gh="b409ff98-1c9e-4990-b2c2-d7f32fda50eb";var Rh="074ef6f4-a0a1-40f9-95c0-cf0ecc3d420c",kh="610b35bc-a709-4eed-a655-9ee0baa860f8",$h="eaf5e67b-6c48-4a27-85e1-9d5a8aa72e24",Nh="bddaba6f-83c8-4d25-97e2-ef1cdecd19e4",Fh="de2d42e2-4fca-4a3f-8783-3585c546e88b",Bh="324b9c5e-5810-11eb-bf7c-634b3bb07f8c",jh="5ec9d37d-f9f4-49d0-a139-55af26fab05c",Hh="259ba71c-6315-4324-a32c-fc2277200a40",Vh="7fe5b907-e9d3-4427-96cf-1b3be39a9bba",zh="c6da6b9f-a783-4e58-a252-e543aef109fb",Wh="98ab5ee1-0997-4ad2-bc77-776208b6bb25",Kh="0c6703a1-e949-4b55-9e84-71e6c9addd64",qh="4ae69887-a087-4d37-8743-d83ca48184d1",Yh="ed78b920-3f43-47df-840c-60c5297cdb2e",Jh="c899b675-c3c4-428e-b548-b228305c0302",Xh="cd8c1d94-1471-49e2-8b43-d98ae93b70f3";var Zn=class extends l{constructor(n){super({i:["a","b"],o:["a + b"]},{},n,s0)}f({a:n,b:t},e){e({"a + b":n+t})}};var Qn=class extends l{constructor(n){super({i:["a","b"],o:["a \xF7 b"]},{},n,p0)}f({a:n,b:t},e){t===0?e(void 0,"cannot divide by 0"):e({"a \xF7 b":n/t})}};var ti=class extends l{constructor(n){super({i:["a","b"],o:["a \xD7 b"]},{},n,u0)}f({a:n,b:t},e){e({"a \xD7 b":n*t})}};var ei=class extends l{constructor(n){super({i:["a","b"],o:["a % b"]},{},n,c0)}f({a:n,b:t},e){t===0?e(void 0,"cannot divide by 0"):e({"a % b":n%t})}};function Xm({a:r,b:n}){return{"a - b":r-n}}var ni=class extends l{constructor(n){super({i:["a","b"],o:["a - b"]},{},n,d0)}f(n,t){t(Xm(n))}};var ii=class extends l{constructor(n){super({i:["a","b"],o:["a"]},{},n,Vc)}f({a:n,b:t},e){e({a:[...n,t]})}};var ri=class extends l{constructor(n){super({i:["a","i"],o:["a[i]"]},{},n,m0)}f({a:n,i:t},e){t>=0&&t<n.length?e({"a[i]":n[t]}):e(void 0,"index out of boundary")}};var oi=class extends l{constructor(n){super({i:["a"],o:["a","head"]},{},n,zc)}f({a:n},t){if(!n.length){t(void 0,"cannot behead empty array");return}let e=[...n],i=e.shift();t({a:e,head:i})}};var ai=class extends l{constructor(n){super({i:["a","b"],o:["ab"]},{},n,f0)}f({a:n,b:t},e){e({ab:n.concat(t)})}};var si=class extends l{constructor(n){super({i:["a","value","start","end"],o:["a"]},{},n,Wc)}f({a:n,value:t,start:e,end:i},o){o({a:n.fill(t,e,i)})}};var pi=class extends l{constructor(n){super({i:["a[]","a"],o:["i"]},{},n,Kc)}f({"a[]":n,a:t},e){e({i:n.indexOf(t)})}};var ui=class extends l{constructor(n){super({i:["n","a"],o:["a[]"]},{},n,a0)}f({a:n,n:t},e){e({"a[]":new Array(t).fill(n)})}};var ci=class extends l{constructor(n){super({i:["a","i","b"],o:["a"]},{},n,l0)}f({a:n,i:t,b:e},i){let o=[...n];o.splice(t,0,e),i({a:o})}};var di=class extends l{constructor(n){super({i:["a","sep"],o:["str"]},{},n,b0)}f({a:n,sep:t},e){let i=n.join(t);e({str:i})}};var mi=class extends l{constructor(n){super({i:["a"],o:["length"]},{},n,qc)}f(n,t){t(Bd(n))}};var fi=class extends l{constructor(n){super({i:["a"],o:["a","last"]},{},n,g0)}f({a:n},t){if(n.length>0){let e=[...n],i=e.pop();t({a:e,last:i})}else t(void 0,"cannot pop empty array")}};var li=class extends l{constructor(n){super({i:["a","b"],o:["a"]},{},n,h0)}f({a:n,b:t},e){e({a:[t,...n]})}};var bi=class extends l{constructor(n){super({i:["a","v","i"],o:["a"]},{},n,y0)}f({a:n,v:t,i:e},i){if(e<n.length){let o=[...n];o[e]=t,i({a:o})}else i(void 0,"index out of boundary")}};function Zm({a:r,start:n,count:t}){let e=[...r],i=e.splice(n,t);return{a:e,removed:i}}var gi=class extends l{constructor(n){super({i:["a","start","count"],o:["a","removed"]},{},n,_0)}f(n,t){t(Zm(n))}};function Qm({a:r,begin:n,end:t}){return{a:r.slice(n,t)}}var hi=class extends l{constructor(n){super({i:["a","begin","end"],o:["a"]},{},n,Yc)}f(n,t){t(Qm(n))}};var D=class extends Q{constructor({fi:t=[],fo:e=[],i=[],o=[]},a={},s,p){super({i:[...t,...i],o:[...e,...o]},a,s,p);this._done=(t,e=null)=>{this._functional._done(t,e)};let d=this,c=new class extends l{constructor(g){super({i:t,o:e},{},g,`_${p}`)}f(g,h){d.f(g,h)}d(){d.d()}i(){d.i()}}(this.__system);this._functional=c,c.play();let m=new class extends Q{constructor(g){super({i,o},{},g,`_${p}`)}onDataInputData(g,h){d.onIterDataInputData(g,h)}onRefInputData(g,h){d.onIterRefInputData(g,h)}onDataInputDrop(g){d.onIterDataInputDrop(g)}onRefInputDrop(g){d.onIterRefInputDrop(g)}onDataOutputDrop(g){d.onIterDataOutputDrop(g)}onRefOutputDrop(g){d.onIterRefOutputDrop(g)}onDataInputInvalid(g){d.onIterDataInputInvalid(g)}onRefInputInvalid(g){d.onIterRefInputInvalid(g)}}(this.__system);m.play(),this._primitive=m;for(let f of t)c.setInput(f,this.getInput(f),this.getInputOpt(f));for(let f of e)c.setOutput(f,this.getOutput(f),this.getOutputOpt(f));for(let f of i)m.setInput(f,this.getInput(f),this.getInputOpt(f));for(let f of o)m.setOutput(f,this.getOutput(f),this.getOutputOpt(f));c.addListener("err",f=>{this.err(f)}),c.addListener("take_err",()=>{this.takeErr()}),this.addListener("take_err",()=>{c.takeErr()}),this.addListener("take_caught_err",()=>{c.takeCaughtErr()}),this._f_i=new Set(t),this._f_o=new Set(e),this.addListener("set_input",(f,g,h,x)=>{this._f_i.add(f),c.addInput(f,g,h)}),this.addListener("set_output",(f,g,h,x)=>{this._f_o.add(f),c.addOutput(f,g,h)})}f(t,e){}d(){this.fd()}fd(){}i(){this.fi()}fi(){}onIterDataInputData(t,e){}onIterRefInputData(t,e){}onIterDataInputDrop(t){}onIterRefInputDrop(t){}onIterDataOutputDrop(t){}onIterRefOutputDrop(t){}onIterDataInputInvalid(t){}onIterRefInputInvalid(t){}destroy(){this._functional.destroy(),this._primitive.destroy(),super.destroy()}};function Zh(r,n,t=[]){for(t.push(r);t.length;){let e=t.shift();n(e),e.left&&t.push(e.left),e.right&&t.push(e.right)}}function Z3(r){let n=null;return Zh(r,t=>{(!t.left||!t.right)&&(n||(n=t))}),n}function Qh(r){let n=null;return Zh(r,t=>{n=t}),n}function ty(r,n){return b(this,null,function*(){let t=[];do{t.push(r.value);let e=Qh(r);r=yield ey(e,n),r&&(r.value=e.value,yield pd(r,n)),r=r&&sn(r)}while(r);return t})}function ey(r,n){return b(this,null,function*(){let{parent:t,left:e,right:i}=r,o=sn(r),a=Qh(o);return a.parent&&(a.parent.left===a?a.parent.left=null:a.parent.right=null),r.parent=null,r.left=null,r.right=null,a===o?null:a===r?t&&sn(t)||null:(a.parent=t,t?(t.left===r?t.left=a:t.right=a,yield tf(a,n)):(a!==e&&(a.left=e,e&&(e.parent=a)),a!==i&&(a.right=i,i&&(i.parent=a)),yield pd(a,n)),sn(a))})}function pd(r,n){return b(this,null,function*(){let{parent:t,value:e,left:i,right:o}=r,a=!i||(yield n(e,i.value)),s=!o||(yield n(e,o.value)),p=()=>b(this,null,function*(){r.left=o.left,o.left&&(o.left.parent=r),r.right=o.right,o.right&&(o.right.parent=r),o.left=i,i.parent=o,o.right=r,r.parent=o,o.parent=t,t&&(t.left===r?t.left=o:t.right=o),yield pd(r,n)}),d=()=>b(this,null,function*(){r.left=i.left,i.left&&(i.left.parent=r),r.right=i.right,i.right&&(i.right.parent=r),r.parent=i,i.left=r,i.right=o,i.parent=t,t&&(t.left===r?t.left=i:t.right=i),o&&(o.parent=i),yield pd(r,n)});if(i&&o)a&&s||(a?yield p():s?yield d():(yield n(i.value,o.value))?yield d():yield p());else if(i)a||(yield d());else return null})}function tf(r,n){return b(this,null,function*(){if(r.parent&&(yield n(r.value,r.parent.value))){let{parent:t,left:e,right:i}=r;r.parent=t.parent;let o=t.left===r;return t.parent&&(t.parent.left===t?t.parent.left=r:t.parent.right=r),t.parent=r,o?(r.left=t,r.right=t.right,t.right&&(t.right.parent=r)):(r.right=t,r.left=t.left,t.left&&(t.left.parent=r)),t.left=e,e&&(e.parent=t),t.right=i,i&&(i.parent=t),yield tf(r,n),t}return null})}function ny(r,n,t){return b(this,null,function*(){if(r===null)return n;for(;n;){let e=yield ey(n,t),i=Z3(r);i.left?i.right=n:i.left=n,n.parent=i,yield tf(n,t),n=e}return sn(r)})}function sn(r){return r.parent?sn(r.parent):r}var je=class{constructor(n=void 0){this._data=void 0;this._callback=[];this._data=n}set(n){this._data=n;for(let t of this._callback)t(n);this._callback=[]}clear(){this._data=void 0}once(){return b(this,null,function*(){return this._data!==void 0?this._data:new Promise((n,t)=>{let e=()=>{n(this._data)};this._callback.push(e)})})}};var yi=class extends D{constructor(t){super({fi:["a"],fo:["b"],i:["a[i] < a[j]"],o:["a[i]","a[j]"]},{},t,x0);this._forward_waiter=new je;this._backward_waiter=new je;this._predicate=(t,e)=>b(this,null,function*(){this._forwarding=!0,this._output["a[i]"].push(t),this._output["a[j]"].push(e),this._forwarding=!1;let i=yield this._forward_waiter.once();return this._forward_waiter.clear(),this._input["a[i] < a[j]"].pull(),yield this._backward_waiter.once(),this._backward_waiter.clear(),i})}f(i,o){return b(this,arguments,function*({a:t},e){let a=null;for(let p of t)a=yield ny(a,{parent:null,left:null,right:null,value:p},this._predicate);let s=a?yield ty(a,this._predicate):[];e({b:s})})}onIterDataInputData(t,e){switch(t){case"a[i] < a[j]":{this._forward_waiter.set(e);break}}}onIterDataOutputDrop(t){this._forwarding||this._output["a[i]"].empty()&&this._output["a[j]"].empty()&&this._backward_waiter.set(!0)}};var _i=class extends l{constructor(n){super({i:["a","b"],o:["a & b"]},{},n,I0)}f({a:n,b:t},e){e({"a & b":n&t})}};var xi=class extends l{constructor(n){super({i:["a"],o:["~a"]},{},n,v0)}f({a:n},t){t({"~a":~n})}};var Ii=class extends l{constructor(n){super({i:["a","b"],o:["a | b"]},{},n,D0)}f({a:n,b:t},e){e({"a | b":n||t})}};var vi=class extends l{constructor(n){super({i:["a","b"],o:["a ^ b"]},{},n,S0)}f({a:n,b:t},e){e({"a ^ b":n^t})}};function He(r,n){let t=typeof r;if(t!==typeof n)return!1;if(t==="string"||t==="number"||t==="boolean"||t==="symbol"||t==="undefined"||t==="function")return r===n;if(t==="object"){if(r===n)return!0;let i=et(r).length,o=et(n).length;if(i!==o)return!1;for(let a in r){let s=r[a],p=n[a];if(!He(s,p))return!1}}return!0}var Di=class extends l{constructor(n){super({i:["a","b"],o:["a = b"]},{},n,E0)}f({a:n,b:t},e){e({"a = b":He(n,t)})}};var Si=class extends l{constructor(n){super({i:["a","b"],o:["a > b"]},{},n,T0)}f({a:n,b:t},e){e({"a > b":n>t})}};var Ei=class extends l{constructor(n){super({i:["a","b"],o:["a \u2265 b"]},{},n,A0)}f({a:n,b:t},e){e({"a \u2265 b":n>=t})}};var Ti=class extends l{constructor(n){super({i:["a","b"],o:["a < b"]},{},n,C0)}f({a:n,b:t},e){e({"a < b":n<t})}};var Ai=class extends l{constructor(n){super({i:["a","b"],o:["a \u2264 b"]},{},n,M0)}f({a:n,b:t},e){e({"a \u2264 b":n<=t})}};var Ci=class extends l{constructor(n){super({i:["a","b"],o:["a \u2260 b"]},{},n,P0)}f({a:n,b:t},e){e({"a \u2260 b":!He(n,t)})}};var Mi=class extends Q{constructor(t){super({i:["a"],o:["a"]},{},t,O0);this._current=void 0;this.addListener("reset",()=>{this._current=void 0})}onDataInputData(t,e){this._current=e,this._output.a.push(e)}onDataInputDrop(t){this._backwarding||(this._forward_all_empty(),this._current=void 0)}onDataOutputDrop(t){this._forwarding_empty||this._output.a.push(this._current)}onDataInputInvalid(t){this._invalidate()}};var Pi=class extends Q{constructor(t){super({i:["a","d"],o:["a"]},{},t,U0);this._current=void 0;this.addListener("reset",()=>{this._current=void 0})}onDataInputData(t,e){t==="a"?(this._current=e,this._input.d.empty()||this._invalidate()):t==="d"&&this._input.a.empty()&&(this._current=e),this._forward_if_ready()}_forward_if_ready(){for(;!this._forwarding&&!this._backwarding&&this._active_o_count-this._o_invalid_count===0&&this._current!==void 0;)this._forward("a",this._current)}_done(){this._backwarding=!0,this._input.a.empty()?this._input.d.pull():this._input.a.pull(),this._backwarding=!1}onDataInputDrop(t){t==="a"?this._input.d.empty()?(this._current=void 0,this._forward_all_empty()):(this._current=this._input.d.peak(),this._invalidate(),this._forward_if_ready()):this._input.a.empty()&&(this._current=void 0,this._forward_all_empty())}onDataOutputDrop(t){this._current=void 0,this._done(),this._input.a.empty()?this._input.d.empty()||(this._current=this._input.d.peak(),this._forward_if_ready()):(this._current=this._input.d.peak(),this._forward_if_ready())}onDataInputInvalid(t){this._invalidate()}};var Oi=class extends l{constructor(n){super({i:["a"],o:["a"]},{},n,w0)}f({a:n},t){t({a:n})}};var Ui=class extends l{constructor(n){super({i:["a","b"],o:["a if b"]},{},n,L0)}f({a:n,b:t},e){e(t===!0?{"a if b":n}:{"a if b":void 0})}};var wi=class extends Q{constructor(t){super({i:["init","next"],o:["local","current"]},{},t,G0);this._current=void 0;this._next=void 0;this.addListener("reset",this._reset)}_reset(){this._current=void 0,this._next=void 0}onDataInputData(t,e){t==="init"?(this._current=e,this._output.local.push(e),this._output.current.push(e)):t==="next"&&(this._current=e,this._next=!0,this._output.current.push(e),this._input.next.pull(),this._output.local.empty()&&(this._output.local.push(this._current),this._next=void 0))}onDataInputDrop(t){if(!this._backwarding&&t==="init"){this._reset(),this._forward_all_empty();return}}onDataOutputDrop(t){this._forwarding_empty||(t==="current"?(this._output.local.pull(),this._input.init.pull()):t==="local"&&this._next===!0&&(this._next=!1,this._output.local.push(this._current)))}onDataInputInvalid(t){t==="init"&&(this._reset(),this._output.local.invalidate()),this._output.current.invalidate()}snapshotSelf(){return Z(_({},super.snapshotSelf()),{_current:this._current,_next:this._next})}restoreSelf(t){let a=t,{_current:e,_next:i}=a,o=bt(a,["_current","_next"]);super.restoreSelf(o),this._current=e,this._next=i}};var Li=class extends Q{constructor(t){super({i:["init","next","test"],o:["local","current","final"]},{},t,R0);this._current=void 0;this._next=void 0;this._test=void 0;this._looping=!1;this._nexting=!1;this.addListener("reset",this._reset)}_reset(){this._current=void 0,this._next=void 0,this._nexting=!1,this._looping=!1}onDataInputData(t,e){t==="init"?(this._current=e,this._output.local.push(e),this._forward_if_ready()):t==="next"?this._next===void 0&&this._current!==void 0&&this._input.test.peak()&&(this._next=e,this._pull_next()):t==="test"&&(this._test=e,this._current!==void 0&&this._forward_if_ready())}onDataInputDrop(t){if(!this._backwarding){if(t==="next")return;if(t==="test"){this._test=void 0,this._next=void 0,this._forward_empty("current"),this._forward_empty("final");return}if(t==="init"){this._reset(),this._forward_all_empty();return}}}onDataOutputDrop(t){this._forwarding_empty||(t==="current"?this._next!==void 0&&this._loop():t==="local"?this._current===void 0?this._done():this._looping&&(this._looping=!1,this._output.local.push(this._current),this._test!==void 0&&this._forward_if_ready()):(this._current=void 0,this._backward("test"),this._output.local.empty()&&this._done()))}onDataInputInvalid(t){t==="init"?(this._reset(),this._output.local.invalidate()):t==="test"&&(this._nexting=!1,this._next=void 0),this._output.current.invalidate(),this._output.final.invalidate()}_pull_next(){this._nexting=!1,this._input.next.pull(),this._output.current.empty()&&this._loop()}_loop(){this._looping=!0,this._current=this._next,this._next=void 0,this._backward("test"),this._looping&&this._output.local.empty()&&(this._looping=!1,this._output.local.push(this._current),this._forward_if_ready())}_iterate(){if(this._forwarding=!0,this._input.test.peak()){this._nexting=!0,this._output.current.push(this._current);let t=this._input.next.peak();this._next===void 0&&t!==void 0&&(this._next=t,this._pull_next())}else this._output.final.push(this._current),this._output.current.pull();this._forwarding=!1}_done(){this._reset(),this._backward("init")}_forward_if_ready(){for(;!this._forwarding&&!this._looping&&!this._nexting&&this._current!==void 0&&!this._input.test.empty()&&!this._input.test.invalid()&&(this._output.current.empty()||this._output.current.invalid())&&(this._output.final.empty()||this._output.final.invalid());)this._iterate()}snapshotSelf(){return Z(_({},super.snapshotSelf()),{_current:this._current,_next:this._next,_test:this._test,_nexting:this._nexting,_looping:this._looping})}restoreSelf(t){let d=t,{_current:e,_next:i,_test:o,_nexting:a,_looping:s}=d,p=bt(d,["_current","_next","_test","_nexting","_looping"]);super.restoreSelf(p),this._current=e,this._next=i,this._test=o,this._nexting=a,this._looping=s}};var Gi=class extends Q{constructor(t){super({i:["a"],o:["a"]},{},t,k0);this._current=void 0;this.addListener("reset",()=>{this._current=void 0})}onDataInputData(t,e){this._current=e,this._forward_if_ready()}_forward_if_ready(){for(;!this._forwarding&&!this._backwarding&&this._current!==void 0;)this._forward("a",this._current),this._current=void 0,this._backward_all()}onDataOutputDrop(t){this._current=void 0}onDataInputInvalid(t){this._invalidate()}};var Ri=class extends Q{constructor(t){super({i:["a"],o:["0","1"]},{},t,$0);this._current=void 0;this._looping=!1}onDataInputData(t,e){this._output[1].empty()||(this._forwarding_empty=!0,this._output[1].pull(),this._forwarding_empty=!1),this._current=e,this._forward_if_ready()}_forward_if_ready(){for(;!this._forwarding&&!this._backwarding&&!this._looping&&this._current!==void 0&&this._i_invalid_count===0;)this._looping=!0,this._forwarding=!0,this._output[0].push(this._current),this._forwarding=!1}onDataInputDrop(t){this._backwarding||(this._current=void 0,this._looping=!1,this._output[0].pull(),this._output[1].pull())}onDataInputInvalid(t){this._looping=!1,this._current=void 0,this._output[0].invalidate(),this._output[1].invalidate()}onDataOutputDrop(t){t==="0"?this._current!==void 0&&(this._forwarding=!0,this._output[1].push(this._current),this._forwarding=!1):this._looping=!1,this._backward_if_ready(),this._forward_if_ready()}_backward_if_ready(){this._current!==void 0&&!this._forwarding&&!this._forwarding_empty&&!this._looping&&(this._current=void 0,this._backward_all())}snapshotSelf(){return Z(_({},super.snapshotSelf()),{_looping:this._looping,_current:this._current})}restoreSelf(t){let a=t,{_looping:e,_current:i}=a,o=bt(a,["_looping","_current"]);super.restoreSelf(o),this._looping=e,this._current=i}};var ki=class extends l{constructor(n){super({i:["message"]},{},n,N0)}f({message:n},t){t(void 0,n)}};var $i=class extends D{constructor(n){super({fi:["a"],fo:["a"],i:["b"],o:[]},{},n,F0)}f({a:n},t){this._input.b.peak()===!0&&t({a:n})}onIterDataInputData(n,t){if(t===!0){let e=this._input.a.peak();e!==void 0&&this._done({a:e})}}};var Ni=class extends l{constructor(n){super({i:["a"]},{},n,B0)}f({},n){n()}};var Fi=class extends l{constructor(n){super({i:["a","b"],o:["a"]},{},n,j0)}f({a:n},t){t({a:n})}};var Bi=class extends l{constructor(n){super({i:["str"],o:["a"]},{},n,H0)}f({str:n},t){let{specs:e,classes:i}=this.__system,o;try{o=st(n,e,i)}catch(a){t(void 0,a.message.toLowerCase());return}t({a:o})}};var ji=class extends l{constructor(n){super({i:["a"],o:["str"]},{},n,V0)}f({a:n},t){let e;try{e=Y(n)}catch(i){t(void 0,i.message.toLowerCase());return}t({str:e})}};var Hi=class extends l{constructor(n){super({i:["a"],o:["type"]},{},n,z0)}f({a:n},t){switch(typeof n){case"number":return t({type:"number"});case"boolean":return t({type:"boolean"});case"function":return t({type:"class"});case"object":return n===null?t({type:"null"}):n instanceof yt?t({type:"unit"}):Array.isArray(n)?t({type:"array"}):t({type:"object"});case"string":return t({type:"string"});case"symbol":return t({type:"symbol"});case"undefined":return t({type:"undefined"});default:return t({type:"undefined"})}}};var Vi=class extends l{constructor(n){super({i:["any"],o:["now"]},{},n,W0)}f({any:n},t){t({now:new Date().getTime()})}};var zi=class extends l{constructor(n){super({i:["id","class","graph"],o:[]},{input:{graph:{ref:!0}}},n,K0)}f({id:n,class:t,graph:e},i){try{let{__bundle:o}=t,{unit:a}=o,{id:s,input:p={}}=a,d=ut(o.specs,this.__system.specs),c=ht(d,s),m={id:s,input:{},output:{}},{inputs:f={},outputs:g={}}=c;for(let h in f){m.input[h]=m.input[h]||{};let x=p[h];if(x){let{data:v}=x;m.input[h].data=v}let y=f[h],{defaultIgnored:I}=y;I&&(m.input[h].ignored=I)}for(let h in g){let x=g[h],{defaultIgnored:y}=x;y&&(m.output[h]=m.output[h]||{},m.output[h].ignored=y)}e.addUnitSpec(n,{unit:m})}catch(o){i(void 0,o.message);return}i()}};var Wi=class extends l{constructor(n){super({i:["id","class","graph"],o:["graph"]},{},n,q0)}f({id:n,class:t,graph:e},i){var a;let o;try{let{__bundle:s}=t,{unit:p}=s,{id:d,input:c={}}=p,m=ut((a=s.specs)!=null?a:{},this.__system.specs),f=ht(m,d),g={id:d,input:{},output:{}},{inputs:h={},outputs:x={}}=f;for(let P in h){g.input[P]=g.input[P]||{};let H=c[P];if(H){let{data:J}=H;g.input[P].data=J}let U=h[P],{defaultIgnored:B}=U;B&&(g.input[P].ignored=B)}for(let P in x){let H=x[P],{defaultIgnored:U}=H;U&&(g.output[P]=g.output[P]||{},g.output[P].ignored=U)}let y=Ge(m),I=ht(m,e.__bundle.unit.id),v=j(I);v.id=y,Pl({unitId:n,unit:g},v);let T=tn(v,m);o=ee(T,m,this.__system.classes)}catch(s){i(void 0,s.message);return}i({graph:o})}};function pn(r,n=!1){let t=r.getUnitBundleSpec(n);return zt(r.constructor,t)}var Ki=class extends l{constructor(n){super({i:["id","graph"],o:[]},{input:{graph:{ref:!0}}},n,Y0)}f({id:n,graph:t},e){let i;try{let o=t.getUnit(n);t.removeUnit(n,!0),i=pn(o)}catch(o){e(void 0,o.message);return}e({class:i})}};var qi=class extends l{constructor(n){super({i:["graph","id","type","name","data"],o:[]},{input:{graph:{ref:!0}}},n,J0)}f({graph:n,id:t,type:e,name:i,data:o},a){try{n.setUnitPinData(t,e,i,o)}catch(s){a(void 0,s.message);return}a()}};var Yi=class extends l{constructor(n){super({i:["any"],o:["uuid"]},{},n,X0)}f({any:n},t){t({uuid:Le()})}};var Ji=class extends l{constructor(n){super({i:["json","space"],o:["string"]},{},n,Z0)}f({json:n,space:t},e){let i;try{i=JSON.stringify(n,null,t)}catch(o){e(void 0,o.message.toLowerCase());return}e({string:i})}};var Xi=class extends l{constructor(n){super({i:["string"],o:["json"]},{},n,Q0)}f({string:n},t){let e;try{e=JSON.parse(n)}catch(i){t(void 0,"invalid JSON");return}t({json:e})}};var Zi=class extends l{constructor(n){super({i:["json"],o:["string"]},{},n,tb)}f({json:n},t){let e;try{e=JSON.stringify(n)}catch(i){t(void 0,i.message.toLowerCase());return}t({string:e})}};var Qi=class extends l{constructor(n){super({i:["a","b"],o:["a and b"]},{},n,eb)}f({a:n,b:t},e){e({"a and b":n&&t})}};var tr=class extends l{constructor(n){super({i:["a"],o:["!a"]},{},n,nb)}f({a:n},t){t({"!a":!n})}};var er=class extends l{constructor(n){super({i:["a","b"],o:["a or b"]},{},n,ib)}f({a:n,b:t},e){e({"a or b":n||t})}};var nr=class extends l{constructor(n){super({i:["a"],o:["|a|"]},{},n,rb)}f({a:n},t){t({"|a|":Math.abs(n)})}};var ir=class extends l{constructor(n){super({i:["a"],o:["\u2308a\u2309"]},{},n,Jc)}f({a:n},t){t({"\u2308a\u2309":Math.ceil(n)})}};var rr=class extends l{constructor(n){super({i:["a"],o:["cos(a)"]},{},n,ob)}f({a:n},t){t({"cos(a)":Math.cos(n)})}};var or=class extends l{constructor(n){super({i:["a"],o:["\u230Aa\u230B"]},{},n,Jc)}f({a:n},t){t({"\u230Aa\u230B":Math.floor(n)})}};var ar=class extends l{constructor(n){super({i:["a"],o:["ln(a)"]},{},n,Xc)}f({a:n},t){t({"ln(a)":Math.log(n)})}};var sr=class extends l{constructor(n){super({i:["a","b"],o:["max"]},{},n,sb)}f({a:n,b:t},e){e({max:Math.max(n,t)})}};var pr=class extends l{constructor(n){super({i:["a","b"],o:["min"]},{},n,pb)}f({a:n,b:t},e){e({min:Math.min(n,t)})}};var ur=class extends l{constructor(n){super({i:["any"],o:["PI"]},{},n,ub)}f({any:n},t){t({PI:Math.PI})}};var cr=class extends l{constructor(n){super({i:["a","b"],o:["a ** b"]},{},n,Xc)}f({a:n,b:t},e){e({"a ** b":Math.pow(n,t)})}};var dr=class extends l{constructor(n){super({i:["any"],o:["random"]},{},n,cb)}f({a:n},t){t({random:Math.random()})}};var mr=class extends l{constructor(n){super({i:["a"],o:["sign(a)"]},{},n,Zc)}f({a:n},t){t({"sign(a)":Math.sign(n)})}};var fr=class extends l{constructor(n){super({i:["a"],o:["sin(a)"]},{},n,db)}f({a:n},t){t({"sin(a)":Math.sin(n)})}};var lr=class extends l{constructor(n){super({i:["a"],o:["\u221Aa"]},{},n,mb)}f({a:n},t){n<0?t(void 0,"cannot square root negative number"):t({"\u221Aa":Math.sqrt(n)})}};var br=class extends l{constructor(n){super({i:["graph","opt"],o:["bundle"]},{input:{graph:{ref:!0}}},n,fb)}f({graph:n,opt:t},e){let{stringifyBundleData:i}=this.__system,{snapshot:o=!1}=t,a=n.getBundleSpec(o),s=j(a);i(s),e({bundle:s})}};var gr=class extends Q{constructor(t){super({i:["unit"],o:["err"]},{input:{unit:{ref:!0}}},t,lb)}onRefInputData(t,e){let{unlisten:i,done:o}=e.catch(s=>{s===null?this._forward_all_empty():this._output.err.push(s)});this._unlisten=i,this._done=o;let a=e.caughtErr();a!==null&&this._output.err.push(a)}onRefInputDrop(t){this._unlisten(),this._unlisten=void 0,this._done=void 0,this._forward_all_empty()}onDataOutputDrop(t){!this._backwarding&&!this._forwarding_empty&&this._done()}};var hr=class extends l{constructor(n){super({i:["unit","deep"],o:["class"]},{input:{unit:{ref:!0}}},n,bb)}f({unit:n,deep:t},e){let i=pn(n,t);e({class:i})}};var yr=class extends l{constructor(n){super({i:["class"],o:["id"]},{},n,gb)}f({class:n},t){let{__bundle:e}=n,{id:i}=e.unit;t({id:i})}};var _r=class extends l{constructor(n){super({i:["unit","method","args"],o:["return"]},{input:{unit:{ref:!0}}},n,hb)}f({unit:n,method:t,args:e},i){let o=n[t],a;if(typeof o=="function")try{a=o.call(n,...e)}catch(s){i(void 0,s.message);return}else{i(void 0,"invalid method");return}i({return:a})}};var xr=class extends yt{constructor(n){super({i:[],o:[]},{},n,yb)}subscribe(n,t,e){return this.__system.global.data.subscribe(n,t,e)}get(n){return b(this,null,function*(){return this.__system.global.data.get(n)})}set(n,t){return b(this,null,function*(){return this.__system.global.data.set(n,t)})}delete(n){return b(this,null,function*(){return this.__system.global.data.delete(n)})}deepSet(n,t){return b(this,null,function*(){return this.__system.global.data.deepSet(n,t)})}deepGet(n){return b(this,null,function*(){return this.__system.global.data.deepGet(n)})}deepDelete(n){return b(this,null,function*(){return this.__system.global.data.deepDelete(n)})}keys(){return b(this,null,function*(){return this.__system.global.data.keys()})}hasKey(n){return b(this,null,function*(){return this.__system.global.data.hasKey(n)})}};var Ir=class extends l{constructor(n){super({i:["id"],o:["class"]},{},n,_b)}f({id:n},t){let e=le(n,this.__system.specs,this.__system.classes);t({class:e})}};var vr=class extends l{constructor(n){super({i:["id"],o:["spec"]},{},n,xb)}f({id:n},t){if(this.__system){let{specs:e}=this.__system,i=e[n];i?t({spec:i}):t(void 0,"cannot find spec with this id")}else t(void 0,"not attached")}};var Dr=class extends D{constructor(n){super({fi:["class"],fo:["unit"],i:["done"]},{output:{unit:{ref:!0}}},n,Ib)}f({class:n},t){t({unit:new n(this.__system)})}onIterDataInputData(n,t){this._forward_all_empty(),this._backward("class"),this._backward("done")}};function iy(r){return De(r)?r:{}}var Sr=class extends l{constructor(t){super({i:["obj","key"],o:["value"]},{input:{obj:{ref:!0}},output:{value:{ref:!0}}},t,vb)}f(o,a){return b(this,arguments,function*({obj:t,key:e},i){let s;try{s=yield t.get(e)}catch(d){i(void 0,d.message);return}this._unlisten=t.subscribe([],e,(d,c,m)=>{d==="delete"&&(this.err("key value not found"),this._forward_empty("value"))});let p=new class extends C{read(){return b(this,null,function*(){return s=yield t.get(e),iy(s)})}write(c){return b(this,null,function*(){return t.set(e,c)})}}(this.__system);i({value:p})})}d(){this._unlisten&&(this._unlisten(),this._unlisten=void 0)}};function Q3(r,n){return Nc(r,n,{G:sy,C:ay,V:b_,J:__,U:oy,MS:D_,EE:ry,S:ef})}function Te(r,n){let t={};for(let e of n){let i=`$${e}`;t[i]=(o,a)=>r.call(i,o,a)}return t}function Ae(r,n){let t={};for(let e of n){let i=`$${e}`;t[i]=(o,a)=>r.watch(i,o,a)}return t}function Ce(r,n){let t={};for(let e of n){let i=`$${e}`;t[i]=o=>{let{_:a}=o,s=r.ref(i,o);return Q3(s,a)}}return t}function t_(r){return Te(r,Un)}function e_(r){return Ae(r,wn)}function n_(r){return Ce(r,Ln)}function ry(r){return _(_(_({},t_(r)),e_(r)),n_(r))}function i_(r){return Te(r,Bn)}function r_(r){return Ae(r,jn)}function o_(r){return Ce(r,Hn)}function oy(r){return _(_(_({},i_(r)),r_(r)),o_(r))}function a_(r){return Te(r,Mn)}function s_(r){return Ae(r,Pn)}function p_(r){return Ce(r,On)}function ay(r){return _(_(_({},a_(r)),s_(r)),p_(r))}function u_(r){return Te(r,Gn)}function c_(r){return Ae(r,Rn)}function d_(r){return Ce(r,kn)}function sy(r){return _(_(_({},u_(r)),c_(r)),d_(r))}function m_(r){return Te(r,Vn)}function f_(r){return Ae(r,zn)}function l_(r){return Ce(r,Wn)}function b_(r){return _(_(_({},m_(r)),f_(r)),l_(r))}function g_(r){return Te(r,$n)}function h_(r){return Ae(r,Nn)}function y_(r){return Ce(r,Fn)}function __(r){return _(_(_({},g_(r)),h_(r)),y_(r))}function x_(r){return Te(r,Dc)}function I_(r){return Ae(r,Sc)}function v_(r){return Ce(r,Ec)}function D_(r){return _(_(_({},x_(r)),I_(r)),v_(r))}function un(r){return _(_(_(_({},ry(r)),oy(r)),ay(r)),sy(r))}function S_(r){return Te(r,Tc)}function E_(r){return Ae(r,Ac)}function T_(r){return Ce(r,Cc)}function ef(r){return _(_(_({},S_(r)),E_(r)),T_(r))}var qt=class{constructor(n){this._call_id=new Set;this._watch_id=new Set;this._ref_id=new Set;this._ref={};this._watch_emitter=new mt;this._call_emitter=new mt;this._valid=!0;this._port=n,this._port.onmessage=t=>{let{data:e}=t;this.exec(e)},this._port.onerror=t=>{let{message:e}=t}}exec(n){let{type:t,data:e}=n,{id:i,data:o}=e;if(t===pe){if(!this._call_id.has(i))throw new Error("unexpected worker call message id");this._call_emitter.emit(i,o)}else if(t===Ue){if(!this._watch_id.has(i))throw new Error("unexpected worker watch message id");this._watch_emitter.emit(i,o)}else if(t===we)this._ref[i].exec(o);else throw new Error("unexpected worker message type")}call(n,t,e){let i=Hu(this._call_id);this._call_id.add(i);let o=s=>{this._call_emitter.removeListener(i,o),this._call_id.delete(i),e(s)};this._call_emitter.addListener(i,o);let a={type:pe,data:{id:i,method:n,data:t}};this._port.send(a)}watch(n,t,e){let i=Hu(this._watch_id);this._watch_id.add(i);let o=s=>{e(s)};this._watch_emitter.addListener(i,o);let a={type:Ue,data:{id:i,method:n,data:t}};return this._port.send(a),()=>{if(this._watch_emitter.removeListener(i,o),this._watch_id.delete(i),this._valid){let s={type:$u,data:{id:i}};this._port.send(s)}}}ref(n,t){let e=Hu(this._ref_id),i={type:we,data:{id:e,method:n,data:t}};this._port.send(i);let o={send:s=>{let p={type:Nu,data:{id:e,data:s}};this._port.send(p)},onmessage(){},onerror(){},terminate(){}},a=new qt(o);return this._ref[e]=a,a}terminate(){this._port.terminate()}close(){this._valid=!1;for(let n in this._ref)this._ref[n].close()}valid(){return this._valid}};function Gt(r,n,t=[]){return new class extends C{constructor(a){super(a);this.__async=!0;this.__=t;for(let s of Object.keys(n)){let p=n[s];this[s]=p}}}(r)}var Er=class extends D{constructor(t){super({fi:["opt"],fo:[],i:["close","message"],o:["message","graph"]},{output:{graph:{ref:!0}}},t,Db);this._close=()=>{this._remote_port&&(this._remote_port.close(),this._remote_port=void 0)};this.addListener("destroy",()=>{this._close()}),this.addListener("take_err",()=>{}),this.addListener("take_caught_err",()=>{})}f({opt:t},e){}onIterDataInputData(t,e){return b(this,null,function*(){switch(t){case"close":this._close(),this._done(),this._backward("close");break;case"message":{let{type:i,data:o}=e;switch(i){case Ot:this._port.onmessage({data:o});break;case Zt:{let a={send:c=>{this._output.message.push(c)},onmessage(c){},onerror(){},terminate(){}};this._port=a;let s=new qt(a);this._remote_port=s;let p=un(s),d=Gt(this.__system,p,["U","C","G"]);this._output.graph.push(d)}break;case Qt:this._close();break}this._backward("message")}break}})}};function ud(r,n){let t=new Ie(r);return{get(e){throw new O},set(e,i){return t.deepSet(["current",e],i)},delete(e){throw new O},hasKey(e){throw new O},keys(){throw new O},deepGet(e){throw new O},deepSet(e,i){throw new O},deepDelete(e){throw new O},subscribe(e,i,o){return t.subscribe(["current",...e],i,o)}}}var Tr=class extends l{constructor(n){super({i:["unit"],o:["obj"]},{input:{unit:{ref:!0}},output:{obj:{ref:!0}}},n,Sb)}f(e,i){return b(this,arguments,function*({unit:n},t){var m;let{global:{scope:o}}=this.__system,{__global_id:a}=n;o[a]=(m=o[a])!=null?m:{};let p={current:o[a]},d=ud(p,this.__system),c=Gt(this.__system,d,["J"]);t({obj:c})})}};var Ar=class extends Q{constructor(t){super({i:["a"],o:["a"]},{},t,Eb);this._ran=!1}onDataInputDrop(t,e){this._ran=!1}onDataInputData(t,e){this._paused||this._ran||(this._ran=!0,this._output.a.push(e))}};var Cr=class extends l{constructor(n){super({i:["unit","any"],o:["spec"]},{input:{unit:{ref:!0}}},n,Tb)}f({unit:n},t){let e=n.getSpec();t({spec:e})}};var Mr=class extends l{constructor(t){super({i:["unit"],o:["spec"]},{input:{unit:{ref:!0}},output:{spec:{ref:!0}}},t,Ab);this.__=["J"]}f({unit:t},e){let i=new class extends C{get(a){let s=t.getSpec();return Promise.resolve(s[a])}set(a,s){let p=t.getSpec();p[a]=s}delete(a){let s=t.getSpec();delete s[a]}hasKey(a){return b(this,null,function*(){let s=t.getSpec();return Rf(s,a)})}keys(){return b(this,null,function*(){let a=t.getSpec();return et(a)})}deepGet(a){let s=t.getSpec();return pt(s,a)}deepSet(a,s){let p=t.getSpec();xc(p,a,s)}deepDelete(a){throw new O}subscribe(a,s,p){throw new O}}(this.__system);e({spec:i})}};var Pr=class extends l{constructor(n){super({i:["any"],o:["specs"]},{},n,Cb)}f({any:n},t){let{specs:e}=this.__system;t({specs:e})}};var Or=class extends yt{constructor(t){super({i:[],o:["graph"]},{output:{graph:{ref:!0}}},t,Mb);this.addListener("parent",e=>{e===null?(this._unlisten&&(this._unlisten(),this._unlisten=void 0),this._output.graph.pull()):this._output.graph.push(e)})}};var Ur=class extends yt{constructor(n){super({i:[],o:[]},{},n,Pb)}};var ne=class extends l{f(n,t){let e;try{e=this.m(n)}catch(i){t(void 0,i.message);return}t(e)}m(n){}};var wr=class extends ne{constructor(n){super({i:["n","radix"],o:["str"]},{},n,Ob)}m({n,radix:t}){return{str:n.toString(t)}}};var Lr=class extends ne{constructor(n){super({i:["str"],o:["n"]},{},n,Ub)}m({str:n}){let t=Number.parseFloat(n);if(isNaN(t))throw"invalid number string";return{n:t}}};var Gr=class extends ne{constructor(n){super({i:["str","radix"],o:["n"]},{},n,wb)}m({str:n,radix:t}){let e=Number.parseInt(n,t);if(isNaN(e))throw"invalid number string";return{n:e}}};var Rr=class extends l{constructor(n){super({i:["obj","path"],o:["result"]},{},n,Lb)}f({obj:n,path:t},e){let i;try{i=pt(n,t)}catch(o){e(void 0,"key not found");return}e({result:i})}};var kr=class extends ne{constructor(n){super({i:["a","b"],o:["ab"]},{},n,Gb)}m({a:n,b:t}){return{ab:Ht(n,t)}}};var $r=class extends l{constructor(n){super({i:["obj","path","value"],o:["result"]},{},n,Rb)}f({obj:n,path:t,value:e},i){let o=j(n);try{F(o,t,e)}catch(a){i(void 0,a.message);return}i({result:o})}};var Nr=class extends l{constructor(n){super({i:["obj","key"],o:["obj"]},{},n,Qc)}f({obj:n,key:t},e){e({obj:vc(n,t)})}};var Fr=class extends l{constructor(n){super({i:["obj","key"],o:["value"]},{},n,kb)}f({obj:n,key:t},e){n.hasOwnProperty(t)?e({value:n[t]}):e(void 0,"key not found")}};var Br=class extends l{constructor(n){super({i:["obj","key"],o:["has"]},{},n,$b)}f({obj:n,key:t},e){e({has:n.hasOwnProperty(t)})}};var jr=class extends l{constructor(n){super({i:["obj"],o:["keys"]},{},n,td)}f(n,t){t($d(n))}};var Hr=class extends l{constructor(n){super({i:["a","b"],o:["ab"]},{},n,Nb)}f({a:n,b:t},e){e({ab:en(n,t)})}};var Vr=class extends l{constructor(n){super({i:["obj","key","value"],o:["obj"]},{},n,Fb)}f({obj:n,key:t,value:e},i){this.isPinRef("input","obj")&&(n[t]=e),this.isPinRef("output","obj")?i({obj:n}):i({obj:nn(n,t,e)})}};var zr=class extends l{constructor(n){super({i:["obj"],o:["values"]},{},n,Bb)}f({obj:n},t){t({values:Object.values(n)})}};var Wr=class extends l{constructor(n){super({i:["str"],o:["obj"]},{},n,jb)}f({str:n},t){let{api:{querystring:{parse:e}}}=this.__system,i;try{i=e(n)}catch(o){t(void 0,o.message);return}t({obj:i})}};var Kr=class extends l{constructor(n){super({i:["obj"],o:["str"]},{},n,Hb)}f({obj:n},t){let{api:{querystring:{stringify:e}}}=this.__system,i;try{i=e(n)}catch(o){t(void 0,o.message);return}t({str:i})}};var qr=class extends l{constructor(n){super({i:["a"],o:["tail","head"]},{},n,zc)}f({a:n},t){let e=n[0]||"",i=n.slice(1)||"";t({tail:i,head:e})}};var Yr=class extends l{constructor(n){super({i:["a","i"],o:["a[i]"]},{},n,Vb)}f({a:n,i:t},e){e({"a[i]":n.charAt(t)})}};var Jr=class extends l{constructor(n){super({i:["a","b"],o:["ab"]},{},n,zb)}f({a:n,b:t},e){e({ab:n+t})}};var Xr=class extends l{constructor(n){super({i:["code"],o:["char"]},{},n,Wb)}f({code:n},t){let e=String.fromCharCode(n);t({char:e})}};var Zr=class extends l{constructor(n){super({i:["a"],o:["length"]},{},n,qc)}f({a:n},t){t({length:n.length})}};var Qr=class extends l{constructor(n){super({i:["a","b"],o:["a < b"]},{},n,Kb)}f({a:n,b:t},e){let i=t.localeCompare(n)===1;e({"a < b":i})}};var to=class extends l{constructor(n){super({i:["str","regex"],o:["match"]},{},n,qb)}f({str:n,regex:t},e){e({match:n.match(t)})}};var eo=class extends l{constructor(n){super({i:["str","regex","flags","with"],o:["str"]},{},n,Yb)}f({str:n,regex:t,with:e,flags:i},o){o({str:n.replace(new RegExp(t,i),e)})}};function nf({a:r,begin:n,end:t}){return{a:r.slice(n,t)}}var no=class extends l{constructor(n){super({i:["a","begin","end"],o:["a"]},{},n,Yc)}f(n,t){t(nf(n))}};function rf(r,n){return r.split(n)}var io=class extends l{constructor(n){super({i:["a","sep"],o:["parts"]},{},n,Jb)}f({a:n,sep:t},e){e({parts:rf(n,t)})}};var ro=class extends l{constructor(n){super({i:["a","from","length"],o:["a"]},{},n,Xb)}f({a:n,from:t,length:e},i){i({a:n.substring(t,t+e)})}};var oo=class extends l{constructor(n){super({i:["str","regex"],o:["match"]},{},n,Zb)}f({str:n,regex:t},e){e({match:!!n.match(t)})}};var ao=class extends l{constructor(n){super({i:["A"],o:["a"]},{},n,Qb)}f({A:n},t){t({a:n.toLowerCase()})}};var so=class extends l{constructor(n){super({i:["a"],o:["A"]},{},n,t2)}f({a:n},t){t({A:n.toUpperCase()})}};var po=class extends D{constructor(t){super({fi:["ms"],o:["ms"],i:["done"]},{},t,ed);this._interval=null;this.addListener("reset",this._reset),this.addListener("destroy",this._reset)}_reset(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}f({ms:t},e){this._reset(),this._interval=setInterval(()=>{this.pushOutput("ms",t)},t)}d(){this._reset(),this._forward_all_empty()}onIterDataInputData(t,e){this._reset(),this._done({})}};var uo=class extends l{constructor(t){super({i:["ms"],o:["ms"]},{},t,ed);this._timer=null;this.addListener("reset",this._reset),this.addListener("destroy",this._reset)}_reset(){this._timer!==null&&(clearTimeout(this._timer),this._timer=null)}f({ms:t},e){this._reset(),this._timer=setTimeout(()=>{this._timer=null,e({ms:t})},t)}};var co=class extends l{constructor(n){super({i:["unit","name"],o:["test"]},{},n,e2)}f({unit:n,name:t},e){var p;let{id:i}=n.__bundle.unit,o=ht(ut(this.__system.specs,(p=n.__bundle.specs)!=null?p:{}),i),{inputs:a={}}=o,s=!!a[t];e({test:s})}};var mo=class extends l{constructor(n){super({i:["unit","opt"],o:[]},{input:{unit:{ref:!0}}},n,n2)}f({unit:n,opt:t},e){n.$pause({}),e()}};var fo=class extends l{constructor(n){super({i:["unit","any"],o:["paused"]},{input:{unit:{ref:!0}}},n,i2)}f({unit:n},t){n.$paused({},e=>{t({paused:e})})}};var lo=class extends l{constructor(n){super({i:["unit","opt"],o:[]},{input:{unit:{ref:!0}}},n,r2)}f({unit:n,opt:t},e){n.$play({}),e()}};function cd(r){let{__bundle:n}=r,t=j(n);return A_(r,t)}function A_(r,n){let t=C_(r);return zt(t,n)}function C_(r){class n extends r{}return Object.defineProperty(n,"name",{value:r.constructor.name}),n}var bo=class extends l{constructor(n){super({i:["unit","name","data"],o:["unit"]},{},n,o2)}f({unit:n,name:t,data:e},i){var c;let{__bundle:o}=n,{unit:{id:a}}=o,s=ht(ut(this.__system.specs,(c=o.specs)!=null?c:{}),a),{inputs:p={}}=s;if(!p[t]){i(void 0,"input not found");return}let d=cd(n);d.__bundle.unit.input=d.__bundle.unit.input||{},d.__bundle.unit.input[t]=d.__bundle.unit.input[t]||{},d.__bundle.unit.input[t].data=Y(e),i({unit:d})}};var go=class extends l{constructor(n){super({i:["unit","type","name","data"],o:["unit"]},{},n,a2)}f({unit:n,type:t,name:e},i){let{unit:{id:o},specs:a}=n.__bundle;if(!ht(ut(a,this.__system.specs),o)[`${t}s`][e]){i(void 0,`${t} not found`);return}let p=cd(n);p.__bundle.unit.input=p.__bundle.unit.input||{},p.__bundle.unit.input[e]=p.__bundle.unit.input[e]||{},delete p.__bundle.unit.input[e].data,i({unit:p})}};var ho=class extends l{constructor(n){super({i:["message"],o:[]},{},n,s2)}f({message:n},t){let{api:{alert:{alert:e}}}=this.__system;e(n),t()}};var yo=class extends l{constructor(n){super({i:["message"],o:["answer"]},{},n,p2)}f({message:n},t){let{api:{alert:{prompt:e}}}=this.__system,i=e(n);if(i===null){t(void 0,"user cancelled prompt");return}t({answer:i})}};var _o=class extends D{constructor(t){super({fi:["opt","keyframes","element"],fo:["animation"],i:["done"],o:[]},{input:{element:{ref:!0},done:{}},output:{animation:{ref:!0}}},t,u2);this._id=void 0;this.addListener("reset",this._cancel),this.addListener("destroy",this._cancel)}_cancel(){this._i.element&&this._id&&(this._i.element.cancelAnimation(this._id),this._id=void 0)}f({opt:t,keyframes:e,element:i},o){var d;let a=(d=t.id)!=null?d:ju();this._id=a;let s=Z(_({},t),{id:a});i.animate(e,s);let p=new class extends C{constructor(){super(...arguments);this.__=["ANI"]}stop(){i.emit("call",{method:"stopAnimation",data:[a]})}play(){i.emit("call",{method:"playAnimation",data:[a]})}cancel(){i.emit("call",{method:"cancelAnimation",data:[a]})}finish(){i.emit("call",{method:"finishAnimation",data:[a]})}commit(){i.emit("call",{method:"commitAnimation",data:[a]})}}(this.__system);o({animation:p})}fd(){this._cancel()}fi(){this._cancel()}onRefInputDrop(t,e){t==="element"&&this._cancel()}onIterDataInputData(t,e){this._cancel(),this._id=void 0,this._forward_empty("animation"),this._backward("keyframes"),this._backward("opt"),this._backward("done")}};var xo=class extends l{constructor(t){super({i:["a"],o:["a"]},{},t,c2);this._frame=void 0;this.addListener("reset",()=>{this._reset()}),this.addListener("destroy",()=>{this._reset()})}_reset(){let{api:{animation:{cancelAnimationFrame:t}}}=this.__system;this._frame&&(t(this._frame),this._frame=void 0)}f({a:t},e){let{api:{animation:{requestAnimationFrame:i}}}=this.__system;i?(this._reset(),this._frame=i(()=>{this._frame=void 0,e({a:t})})):e(void 0,"request animation frame not supported")}};var Io=class extends l{constructor(n){super({i:["b"],o:["a"]},{},n,d2)}f({b:n},t){let e;try{e=atob(n)}catch(i){t(void 0,"string not correctly enconded");return}t({a:e})}};var vo=class extends l{constructor(n){super({i:["a"],o:["b"]},{},n,m2)}f({a:n},t){let e;try{e=btoa(n)}catch(i){t(void 0,"invalid string");return}t({b:e})}};var Do=class extends l{constructor(t){super({i:["service","uuid"],o:["charac"]},{input:{service:{ref:!0}},output:{charac:{ref:!0}}},t,f2);this._started=!1;this.addListener("listen",({event:e})=>{e==="write"&&this.startNotifications()}),this.addListener("unlisten",({event:e})=>{e==="write"&&this.stopNotification()})}f(o,a){return b(this,arguments,function*({service:t,uuid:e},i){let s=yield t.getCharacteristic(e);this._charac=s;let p=new class extends C{read(){return b(this,null,function*(){return(yield s.readValue()).getUint8(0).toString()})}write(c){return b(this,null,function*(){let m=c.split("").map(g=>g.charCodeAt(0)),f=Uint8Array.from(m);yield s.writeValue(f)})}}(this.__system);i({charac:p})})}d(){}startNotifications(){return b(this,null,function*(){if(this._started)return;let t=this._charac;this._started=!0,t.startNotifications(),t.addEventListener("characteristicvaluechanged",e=>{let i=e.target.value,{byteLength:o}=i,a="";for(let s=0;s<o;s++)a+=String.fromCharCode(i.getUint8(s));e.stopImmediatePropagation(),this.emit("characteristicvaluechanged",a,!0)})})}stopNotification(){this._started||(this._started=!1,this._charac.stopNotifications())}};var So=class extends l{constructor(n){super({i:["opt"],o:["device"]},{output:{device:{ref:!0}}},n,l2)}f(e,i){return b(this,arguments,function*({opt:n},t){let{api:{bluetooth:{requestDevice:o}}}=this.__system,a;try{let s=yield o(n);a=new class extends C{getServer(){return b(this,null,function*(){return s.getServer()})}}(this.__system)}catch(s){t(void 0,s.message);return}t({device:a})})}};var Eo=class extends l{constructor(t){super({i:["device"],o:["server"]},{input:{device:{ref:!0}},output:{server:{ref:!0}}},t,b2)}f(i,o){return b(this,arguments,function*({device:t},e){let a=yield t.getServer(),s=new class extends C{getPrimaryService(d){return a.getPrimaryService(d)}}(this.__system);e({server:s})})}getPrimaryService(t){return this._server.getPrimaryService(t)}};var To=class extends l{constructor(n){super({i:["server","uuid"],o:["service"]},{input:{server:{ref:!0}},output:{service:{ref:!0}}},n,g2)}f(i,o){return b(this,arguments,function*({server:n,uuid:t},e){let a=yield n.getPrimaryService(t),s=new class extends C{getCharacteristic(d){return a.getCharacteristic(d)}}(this.__system);e({service:s})})}d(){}};var Ao=class extends l{constructor(n){super({i:["arc","d"],o:["d"]},{},n,nd)}f({d:n,arc:{x:t,y:e,r:i,start:o,end:a,anticlockwise:s=!1}},p){p({d:[...n,["arc",t,e,i,o,a,s]]})}};var Co=class extends l{constructor(n){super({i:["d","x","y"],o:["d"]},{},n,h2)}f({d:n,x:t,y:e},i){i({d:[...n,["lineTo",t,e]]})}};var Mo=class extends l{constructor(n){super({i:["rect","d"],o:["d"]},{},n,y2)}f({d:n,rect:{x:t,y:e,width:i,height:o}},a){a({d:[...n,["rect",t,e,i,o]]})}};var Po=class extends l{constructor(n){super({i:["d"],o:["d"]},{},n,_2)}f({d:n},t){t({d:[...n,["beginPath"]]})}};var Oo=class extends l{constructor(n){super({i:["any","canvas"],o:[]},{input:{canvas:{ref:!0}}},n,x2)}f({any:n,canvas:t},e){t.clear(),e()}};var Uo=class extends l{constructor(n){super({i:["d"],o:["d"]},{},n,I2)}f({d:n},t){t({d:[...n,["closePath"]]})}};var wo=class extends l{constructor(n){super({i:["canvas","step"],o:[]},{input:{canvas:{ref:!0}}},n,v2)}f({canvas:n,step:t},e){n.draw(t),e()}};var Lo=class extends l{constructor(n){super({i:["canvas","image","x","y","width","height","any"],o:[]},{input:{canvas:{ref:!0},image:{ref:!0}}},n,D2)}f(d,c){return b(this,arguments,function*({any:n,canvas:t,image:e,x:i,y:o,width:a,height:s},p){let m=yield e.image();yield t.drawImage(m,i,o,a,s),p()})}};var Go=class extends l{constructor(n){super({i:["d"],o:["d"]},{},n,Wc)}f({d:n},t){t({d:[...n,["fill"]]})}};var Ro=class extends l{constructor(n){super({i:["d","canvas","rule"]},{input:{canvas:{ref:!0}}},n,S2)}f({d:n,canvas:t,rule:e},i){t.fillPath(n,e),i()}};var ko=class extends l{constructor(n){super({i:["fillStyle","d"],o:["d"]},{},n,E2)}f({d:n,fillStyle:t},e){e({d:[...n,["fillStyle",t]]})}};var Me=class extends Error{constructor(){super("invalid key path")}};function py(r,n){return{append(t){let e=[];r.current.push(t)},put(t,e){throw new O},at(t){throw new O},length(){throw new O},indexOf(t){throw new O}}}function Pe(r,n){return new class extends C{constructor(){super(...arguments);this.__=["A"]}append(o){r[r.length]=o}put(o,a){return b(this,null,function*(){r[o]=a})}at(o){return b(this,null,function*(){return r[o]})}length(){return b(this,null,function*(){return r.length})}indexOf(o){throw new O}raw(){return r}}(n)}function dd(r,n){return new class extends C{constructor(){super(...arguments);this.__=["J","ID"]}imageData(){return r}get(o){return b(this,null,function*(){if(r[o]!==void 0)return o==="data"?Pe(r.data,n):r[o]})}set(o,a){return b(this,null,function*(){throw new Error("read only")})}delete(o){return b(this,null,function*(){throw new Error("read only")})}hasKey(o){return b(this,null,function*(){return r[o]!==void 0})}keys(){return b(this,null,function*(){return["width","height","data","colorSpace"]})}deepGet(o){if(o.length===1)return this.get(o[0]);throw new Me}deepSet(o,a){throw new Error("read only")}deepDelete(o){throw new Error("read only")}subscribe(o,a,s){throw new Error("read only")}raw(){return r}}(n)}var $o=class extends D{constructor(n){super({fi:["canvas","x","y","width","height","opt","any"],fo:["image"],i:["done"]},{input:{canvas:{ref:!0}},output:{image:{ref:!0}}},n,T2)}f(p,d){return b(this,arguments,function*({canvas:n,x:t,y:e,width:i,height:o,opt:a},s){let c;try{c=n.getImageData(t,e,i,o,a)}catch(f){if(f instanceof RangeError){s(void 0,"out of memory");return}s(void 0,f.message);return}let m=dd(c,this.__system);s({image:m})})}onIterDataInputData(n){this._forward_all_empty(),this._backward_all(),this._backward("done")}};var No=class extends D{constructor(n){super({fi:["data","width","height","opt"],fo:["image"],i:["done"]},{input:{data:{ref:!0}},output:{image:{ref:!0}}},n,A2)}f(a,s){return b(this,arguments,function*({data:n,width:t,height:e,opt:i},o){let p;try{let c=yield n.read();p=new ImageData(c,t,e,i)}catch(c){o(void 0,c.message);return}let d=dd(p,this.__system);o({image:d})})}onIterDataInputData(n){this._forward_all_empty(),this._backward_all(),this._backward("data"),this._backward("done")}};var Fo=class extends l{constructor(n){super({i:["x","y","d"],o:["d"]},{},n,C2)}f({d:n,x:t,y:e},i){i({d:[...n,["moveTo",t,e]]})}};var Bo=class extends D{constructor(n){super({fi:["any","canvas","image","dx","dy","x","y","width","height"],fo:["done"],i:[]},{input:{canvas:{ref:!0},image:{ref:!0}},output:{}},n,M2)}f(c,m){return b(this,arguments,function*({canvas:n,image:t,dx:e,dy:i,x:o,y:a,width:s,height:p},d){let f=t.imageData();n.putImageData(f,e,i,o,a,s,p),d({done:!0})})}};var jo=class extends l{constructor(n){super({i:["d","rad"],o:["d"]},{},n,P2)}f({d:n,rad:t},e){e({d:[...n,["rotate",t]]})}};var Ho=class extends l{constructor(n){super({i:["sx","sy","canvas"]},{input:{canvas:{ref:!0}}},n,id)}f({canvas:n,sx:t,sy:e},i){n.scale(t,e),i()}};var Vo=class extends l{constructor(n){super({i:["d"],o:["d"]},{},n,O2)}f({d:n},t){t({d:[...n,["stroke"]]})}};var zo=class extends l{constructor(n){super({i:["d","canvas"]},{input:{canvas:{ref:!0}}},n,id)}f({d:n,canvas:t},e){t.strokePath(n),e()}};var Wo=class extends l{constructor(n){super({i:["strokeStyle","d"],o:["d"]},{},n,U2)}f({d:n,strokeStyle:t},e){e({d:[...n,["strokeStyle",t]]})}};var Ko=class extends D{constructor(n){super({fi:["canvas","quality","type"],fo:["blob"],i:["done"]},{input:{canvas:{ref:!0}},output:{blob:{ref:!0}}},n,w2)}f(o,a){return b(this,arguments,function*({canvas:n,quality:t,type:e},i){let s;try{s=yield n.toBlob(e,t)}catch(d){i(void 0,d.message);return}let p=new class extends C{constructor(){super(...arguments);this.__=["B","IM","BO"]}image(){return b(this,null,function*(){return s})}blob(){return b(this,null,function*(){return s})}raw(){return b(this,null,function*(){return s})}}(this.__system);i({blob:p})})}onIterDataInputData(n){this._forward_empty("blob"),this._backward("done")}};var qo=class extends l{constructor(n){super({i:["canvas","bitmap","init"],o:[]},{input:{canvas:{ref:!0},bitmap:{ref:!0}}},n,L2)}f(o,a){return b(this,arguments,function*({canvas:n,bitmap:t,init:e},i){let s=yield t.imageBitmap();yield n.transferFromImageBitmap(s),i()})}};var Yo=class extends l{constructor(n){super({i:["d","x","y"],o:["d"]},{},n,G2)}f({d:n,x:t,y:e},i){i({d:[...n,["translate",t,e]]})}};var Jo=class extends l{constructor(n){super({i:["text"],o:[]},{},n,R2)}f(e,i){return b(this,arguments,function*({text:n},t){let{api:{clipboard:{writeText:o}}}=this.__system;try{yield o(n)}catch(a){t(void 0,a.message);return}t()})}};var Xo=class extends D{constructor(n){super({i:["arc","d"],o:["d"]},{},n,nd)}f({d:n,arc:{x:t,y:e,r:i,start:o,end:a,anticlockwise:s=!1}},p){p({d:[...n,["arc",t,e,i,o,a,s]]})}};var Zo=class extends l{constructor(n){super({i:["parent","child"],o:["at"]},{input:{parent:{ref:!0}}},n,k2)}f({parent:n,child:t},e){let i=n.appendChild(t);e({at:i})}};var Qo=class extends D{constructor(t){super({fi:["component","host","opt"],i:["done"],fo:[],o:[]},{input:{component:{ref:!0},host:{ref:!0}}},t,$2);this._attach=()=>{this._i.component.emit("call",{method:"attach",data:[this._i.opt]})}}f({component:t,host:e,opt:i},o){t.emit("call",{method:"register",data:[]}),e.emit("call",{method:"register",data:[]});let a=Zu(e.__global_id);t.emit("call",{method:"detach",data:[a,i]})}d(){this._attach()}onIterDataInputData(t,e){switch(t){case"done":this._functional._active_i_count===3&&(this._attach(),this._done()),this._backward("done");break}}};var ta=class extends l{constructor(n){super({i:["parent","at"],o:["test"]},{input:{parent:{ref:!0}}},n,N2)}f({parent:n,at:t},e){let i=n.hasChild(t);e({test:i})}};var ea=class extends l{constructor(n){super({i:["parent","child","at"],o:[]},{input:{parent:{ref:!0}}},n,F2)}f({parent:n,child:t,at:e},i){n.insertChild(t,e),i({at:e})}};var na=class extends D{constructor(n){super({fi:["unit","name"],i:["done"],fo:["ref"],o:[]},{input:{unit:{ref:!0}},output:{ref:{ref:!0}}},n,B2)}f({unit:n,name:t},e){let i=this.__system.global.scope[t];this.__system.emitter.addListener("register",(o,a)=>{o===t&&e({ref:a})}),i&&e({ref:i})}onIterDataInputData(n,t){switch(n){case"done":this._done(),this._backward("done");break}}};var ia=class extends D{constructor(n){super({fi:["unit","ref","name"],i:["done"],fo:[],o:[]},{input:{ref:{ref:!0},unit:{ref:!0}}},n,j2)}f({ref:n,unit:t,name:e},i){this.__system.global.scope[e]=n,this.__system.emitter.emit("register",e,n)}onIterDataInputData(n,t){switch(n){case"done":this._done(),this._backward("done");break}}};var ra=class extends l{constructor(n){super({i:["parent","at"],o:["unit"]},{input:{parent:{ref:!0}}},n,H2)}f({parent:n,at:t},e){let i;try{let o=n.removeChild(t);i=pn(o),o.destroy()}catch(o){e(void 0,o.message);return}e({unit:i})}};var oa=class extends l{constructor(n){super({i:["message"],o:[]},{},n,ab)}f({message:n},t){console.log(n),t()}};var aa=class extends l{constructor(n){super({i:["element","event","data","opt"],o:[]},{input:{element:{ref:!0}}},n,V2)}f({element:n,event:t,data:e,opt:i},o){let a=`_${t}`;n.emit("call",{method:"dispatchEvent",data:[t,e,i.bubbles]}),o()}};var sa=class extends D{constructor(t){super({fi:["emitter","event"],fo:[],i:["remove"],o:["data"]},{input:{emitter:{ref:!0}}},t,z2);this._unlisten=void 0;this._remove=()=>{this._unlisten(),this._listener=void 0,this._unlisten=void 0};this.addListener("destroy",()=>{this._listener&&(this._remove(),this._forward_empty("data"))})}f({emitter:t,event:e}){let i=(...o)=>{this._paused||this._output.data.push(o[0])};this._listener=i,this._unlisten=t.addListener(e,this._listener)}d(){this._remove(),this._forward_empty("data")}onIterDataInputData(t,e){this._listener&&(this._remove(),this._done())}};var of=16,af=4,M_=.001,pa=class extends mt{constructor(t,e){super();this.state={buttons:new Array(of).fill(!1,0,of),axes:new Array(af).fill(0,0,af)};this._frame=null;this._event_capture_tick=()=>{let{api:{input:{gamepad:{getGamepad:t}},animation:{requestAnimationFrame:e}}}=this.system;this.gamepad=t(this.gamepad.index);let i=[...this.state.buttons],o=this.gamepad.buttons.map(p=>p.pressed);this.state.buttons=o;for(let p=0;p<of;p++)o[p]&&!i[p]?this.emit("buttondown",p):!o[p]&&i[p]&&this.emit("buttonup",p);let a=this.state.axes,s=this.gamepad.axes.map(p=>p);this.state.axes=s;for(let p=0;p<af;p++)Math.abs(s[p]-a[p])>=M_&&this.emit("axischange",[p,s[p]]);this._frame=e(this._event_capture_tick)};this._start_event_capture=()=>{this._event_capture_tick()};this._stop_event_capture=()=>{let{api:{animation:{cancelAnimationFrame:t}}}=this.system;this._frame!==void 0&&(t(this._frame),this._frame=void 0)};this._listenerCount=0;this.system=t,this.gamepad=e}read(){return b(this,null,function*(){return this.state})}write(t){return b(this,null,function*(){throw new Error("cannot write to gamepad state")})}addListener(t,e){let i=super.addListener(t,e);return this._listenerCount++,this._listenerCount>=1&&this._start_event_capture(),()=>{this._listenerCount--,this._listenerCount===0&&this._stop_event_capture(),i()}}disconnect(){this._stop_event_capture()}};var ua=class extends D{constructor(t){super({fi:["i"],fo:[],i:["done"],o:["state"]},{output:{state:{ref:!0}}},t,W2)}f(i,o){return b(this,arguments,function*({i:t},e){let{api:{input:{gamepad:{getGamepad:a,addEventListener:s}}}}=this.__system;try{let f=a(t);this._gamepad=new pa(this.__system,f)}catch(f){e(void 0,f.message);return}let p=f=>{let{gamepad:g}=f,{index:h}=g;h===t&&(this._gamepad=new pa(this.__system,g),c(this._gamepad))},d=f=>{let{gamepad:g}=f,{index:h}=g;h===t&&(this._gamepad=null,m())};this._unlisten=tt([s("gamepadconnected",p),s("gamepaddisconnected",d),()=>{this._gamepad&&m()}]);let c=f=>{let g=new class extends C{read(){return b(this,null,function*(){return f.state})}write(x){return b(this,null,function*(){throw new Error("cannot write to gamepad state")})}}(this.__system);this._output.state.push(g)},m=()=>{this._output.state.pull()};this._gamepad&&c(this._gamepad)})}d(){this._unlisten(),this._unlisten=void 0}onIterDataInputData(t){this._output.state.pull(),this._done(),this._input.done.pull()}};var ca=class extends l{constructor(n){super({i:["any"],o:["position"]},{},n,K2)}f(e,i){return b(this,arguments,function*({any:n},t){let{api:{geolocation:{getCurrentPosition:o}}}=this.__system,a;try{a=yield o()}catch(s){t(void 0,s.message);return}t({position:a})})}};var da=class extends l{constructor(n){super({i:["data","title","url"],o:[]},{},n,rd)}f(o,a){return b(this,arguments,function*({data:n,title:t,url:e},i){let{api:{history:{pushState:s}}}=this.__system;s(n,t,e),i()})}};var ma=class extends l{constructor(n){super({i:["data","title","url"],o:[]},{},n,rd)}f(o,a){return b(this,arguments,function*({data:n,title:t,url:e},i){let{api:{history:{replaceState:s}}}=this.__system;s(n,t,e),i()})}};var fa=class extends D{constructor(t){super({fi:["port"],fo:[],i:["res","done"],o:["req"]},{},t,q2);this._waiter=new je}f(i,o){return b(this,arguments,function*({port:t},e){let{api:{http:{listen:a}}}=this.__system;try{this._unlisten=a(t,s=>(this._output.req.push(s),this._waiter.once()))}catch(s){e(void 0,s.message);return}})}onIterDataInputData(t,e){switch(t){case"res":this._waiter.set(e),this._input.res.pull();break;case"done":this._unlisten&&(this._unlisten(),this._done()),this._input.done.pull();break}}};var la=class extends D{constructor(t){super({fi:["channel"],fo:["port"],i:["close"],o:[]},{output:{port:{ref:!0}}},t,Y2);this._bc=null}f({channel:t},e){let{api:{channel:{local:i}}}=this.__system;this._bc=i({channel:t});let o=this._bc,a=new class extends C{constructor(d){super(d);this.__=["P"];this._unlisten=o.addListener("message",c=>{let{specs:m,classes:f}=this.__system,{data:g}=c,h=st(g,m,f);this.emit("message",h)}),this.addListener("destroy",()=>{this._unlisten(),this._unlisten=void 0})}send(d){let c=Y(d);o.postMessage(c)}}(this.__system);e({port:a})}d(){this._bc&&this._bc.close()}};var ba=class extends l{constructor(n){super({i:["any"],o:["url"]},{},n,J2)}f(e,i){return b(this,arguments,function*({any:n},t){let{api:{location:{toString:o}}}=this.__system,a=yield o();t({url:a})})}};function ie(r,n){return new class extends C{constructor(){super(...arguments);this.__=["AN"]}getContext(){return r.context}connect(i){r.connect(i)}disconnect(i){r.disconnect(i)}}(n)}function P_(r,n){return class extends C{constructor(){super(...arguments);this.__=["AN"]}getContext(){return r.context}connect(i){r.connect(i)}disconnect(){r.disconnect()}}}function uy(r,n){let t=P_(r,n);return new class extends t{constructor(){super(...arguments);this.__=["AN"]}getFFTSize(){return r.fftSize}getByteTimeDomainData(o){return r.getByteTimeDomainData(o)}getByteFrequencyData(o){return r.getByteFrequencyData(o)}}(n)}var ga=class extends l{constructor(t){super({i:["node","opt"],o:["node"]},{},t,X2);this.addListener("destroy",()=>{this._node})}f({node:t,opt:e},i){let o,{api:{window:{AnalyserNode:a}}}=this.__system;if(t.__.includes("AC"))t=t,o=t.createAnalyser(e);else{t=t;let p=t.getContext();o=new a(p,e),t.connect(o)}this._node=o;let s=uy(o,this.__system);i({node:s})}d(){}};function cy(r,n){return new class extends C{constructor(){super(...arguments);this.__=["AC"]}get(){return r}getDestination(){return r.destination}createOscilator(o){let{api:{window:{OscillatorNode:a}}}=n;return new a(r,o)}createAnalyser(o){throw new O}}(n)}var ha=class extends l{constructor(t){super({i:["opt"],o:["ctx"]},{output:{ctx:{ref:!0}}},t,Z2);this.addListener("destroy",()=>{this._ctx&&this._ctx.close()})}f({opt:t},e){let{api:{window:{AudioContext:i}}}=this.__system,o=new i(t);this._ctx=o;let a=cy(o,this.__system);e({ctx:a})}d(){}};var ya=class extends l{constructor(t){super({i:["node"],o:[]},{input:{node:{ref:!0}},output:{node:{ref:!0}}},t,Q2);this.addListener("destroy",()=>{this._destroy(this._i.node)})}f({node:t},e){let o=t.getContext().destination;this._node=o,t.connect(o)}_destroy(t){t&&(t.disconnect(this._node),this._node=void 0)}d(t,e){this._destroy(e)}};function re(r,n){return new class extends C{constructor(){super(...arguments);this.__=["MS"]}mediaStream(o){return o(r),gt}getVideoTracks(){return b(this,null,function*(){return r.getVideoTracks()})}}(n)}var _a=class extends l{constructor(t){super({i:["src"],o:["stream"]},{},t,tg);this._audio=new Audio,this._audio.volume=0,this._audio.play(),this.addListener("destroy",()=>{this._audio.srcObject=null})}f({src:t},e){this._audio.src=t;let{srcObject:i}=this._audio,o;if(i instanceof MediaStream)o=re(i,this.__system);else{e(void 0,"");return}e({stream:o})}d(){this._audio.src=null}};var xa=class extends l{constructor(t){super({i:["id","stream"],o:[]},{input:{stream:{ref:!0}}},t,eg);this._audio=new Audio}f(i){return b(this,arguments,function*({stream:t,id:e}){t.mediaStream(o=>{this._audio.srcObject=o}),this._audio.setSinkId(e).catch(o=>{this.err(o.message)}),this._audio.play()})}d(){this._audio.pause()}};function Ia(r,n){return new class extends C{constructor(){super(...arguments);this.__=["AN"]}read(){return Promise.resolve(r.value)}write(i){r.value=i}}(n)}var va=class extends l{constructor(t){super({i:["node","delay"],o:["node","delay"]},{input:{node:{ref:!0}},output:{node:{ref:!0},delay:{ref:!0}}},t,ng);this._disconnect=t=>{t&&(t.disconnect(),this._node=void 0)};this.addListener("destroy",()=>{this._node&&this._disconnect(this._i.node)})}f({node:t,delay:e},i){let o;t=t,o=t.getContext().createDelay(),o.delayTime.value=e,this._node=o,t.connect(o);let s=ie(o,this.__system),p=Ia(o.delayTime,this.__system);i({node:s,delay:p})}i(){this._disconnect(this._i.node)}d(t,e){t==="node"&&this._disconnect(this._i.node)}};var Da=class extends l{constructor(t){super({i:["node","gain"],o:["node"]},{input:{node:{ref:!0}},output:{node:{ref:!0}}},t,ig);this._disconnect=t=>{t&&(t.disconnect(),this._node=void 0)};this.addListener("destroy",()=>{this._node&&this._disconnect(this._i.node)})}f({node:t,gain:e},i){let o;t=t,o=t.getContext().createGain(),o.gain.value=e,this._node=o,t.connect(o);let s=ie(o,this.__system);i({node:s})}i(){this._disconnect(this._i.node)}d(t,e){t==="node"&&this._disconnect(this._i.node)}};var Sa=class extends D{constructor(t){super({fi:["node","opt"],fo:["data"],i:["done"]},{input:{node:{ref:!0}},output:{data:{ref:!0}}},t,rg);this._reset=()=>{this._data=void 0,this._backward_all()}}f({node:t,opt:e},i){let o=t.getFFTSize();this._data=new Uint8Array(o),t.getByteFrequencyData(this._data);let a=Pe(this._data,this.__system);i({data:a})}d(){}onIterDataInputData(t,e){this._reset()}};var Ea=class extends D{constructor(t){super({fi:["node","opt"],fo:["data"],i:["done"]},{input:{node:{ref:!0}},output:{data:{ref:!0}}},t,og);this._reset=()=>{this._data=void 0,this._backward_all()}}f({node:t,opt:e},i){let o=t.getFFTSize();this._data=new Uint8Array(o),t.getByteTimeDomainData(this._data);let a=Pe(this._data,this.__system);i({data:a})}d(){}onIterDataInputData(t,e){this._reset()}};var Ta=class extends l{constructor(t){super({i:["node","opt","stream"],o:["node"]},{input:{node:{ref:!0},stream:{ref:!0}},output:{node:{ref:!0}}},t,ag);this._destroy=()=>{this._node&&(this._node=void 0)};this.addListener("destroy",()=>{this._destroy()})}f({node:t,stream:e,opt:i},o){let a,{api:{window:{MediaStreamAudioSourceNode:s}}}=this.__system,p;t.__.includes("AC")?(t=t,p=t.get()):(t=t,p=t.getContext()),e.mediaStream(d=>{try{a=new s(p,{mediaStream:d})}catch(m){o(void 0,m.message.toLowerCase());return}this._node=a;let c=ie(a,this.__system);o({node:c})})}i(t){this._destroy()}d(){this._destroy()}};var Aa=class extends l{constructor(t){super({i:["a","b"],o:["node"]},{input:{a:{ref:!0},b:{ref:!0}},output:{node:{ref:!0}}},t,sg);this.addListener("destroy",()=>{this._node})}f({a:t,b:e},i){let o;o=t.getContext().createGain(),this._node=o,t.connect(o),e.connect(o);let s=ie(o,this.__system);i({node:s})}d(){}};var Ca=class extends l{constructor(t){super({i:["node","opt"],o:["node","frequency","detune"]},{input:{node:{ref:!0}},output:{node:{ref:!0},frequency:{ref:!0},detune:{ref:!0}}},t,pg);this._destroy=()=>{this._node&&(this._node.stop(),this._node=void 0)};this.addListener("destroy",()=>{this._destroy()})}f({node:t,opt:e},i){let o,{api:{window:{OscillatorNode:a}}}=this.__system;if(t.__.includes("AC"))o=t.createOscilator(e);else{t=t;let c=t.getContext();o=new a(c,e)}o.start(),this._node=o;let s=ie(o,this.__system),p=Ia(o.frequency,this.__system),d=Ia(o.detune,this.__system);i({node:s,frequency:p,detune:d})}i(t){this._destroy()}d(){this._destroy()}};var md=class{constructor(n=null){this._data=null;this._callback=[];this._data=n}set(n){this._data=n;for(let t of this._callback)t(n)}connect(n){return this._callback.push(n),this._data&&n(this._data),()=>{let t=this._callback.indexOf(n);if(t>-1)this._callback.splice(t,1);else throw new Error("can only unlisten once")}}};var Ma=class extends D{constructor(t){super({fi:["source","opt"],fo:["stream"],i:["stop"],o:[]},{input:{source:{ref:!0}},output:{stream:{ref:!0}}},t,ug);this.__=["U"];this._stream=new md}f(o,a){return b(this,arguments,function*({source:t,opt:e},i){let s;try{s=yield t.captureStream(e)}catch(d){i(void 0,d.message);return}let p=re(s,this.__system);i({stream:p})})}onIterDataInputData(t,e){this._stream.set(null),this._done(),this._input.stop.pull()}mediaStream(t){return this._stream.connect(t)}};var Pa=class extends l{constructor(n){super({i:["text","name","mimetype","charset"],o:[]},{},n,cg)}f(a,s){return b(this,arguments,function*({text:n,name:t,mimetype:e,charset:i},o){let{api:{file:{downloadText:p}}}=this.__system;try{yield p({text:n,name:t,mimetype:e,charset:i})}catch(d){o(void 0,d.message);return}o()})}};var Oa=class extends l{constructor(n){super({i:["url","name"],o:[]},{},n,dg)}f(i,o){return b(this,arguments,function*({url:n,name:t},e){let{api:{file:{downloadURL:a}}}=this.__system;try{yield a({url:n,name:t})}catch(s){e(void 0,s.message);return}e()})}};var Ua=class extends l{constructor(n){super({i:["any"],o:["devices"]},{},n,mg)}f(t,e){return b(this,arguments,function*({},n){let{api:{media:{enumerateDevices:i}}}=this.__system,o;try{o=yield i()}catch(a){n(void 0,a.message);return}n({devices:o})})}};function fd(r){r.getTracks().forEach(n=>n.stop())}var wa=class extends l{constructor(t){super({i:["opt"],o:["stream"]},{},t,fg);this.addListener("destroy",()=>{this._stream&&(fd(this._stream),this._stream=void 0)}),this.addListener("take_err",()=>{this._input.opt.pull()})}f(i,o){return b(this,arguments,function*({opt:t},e){let{api:{media:{getDisplayMedia:a}}}=this.__system,s;try{s=yield a(t)}catch(d){if(d.name==="NotAllowedError"){e(void 0,"permission denied");return}e(void 0,d.message);return}let p=re(s,this.__system);e({stream:p})})}};function dy(r,n){return new class extends C{constructor(){super(...arguments);this.__=["MST"]}mediaStreamTrack(){return b(this,null,function*(){return r})}}(n)}var La=class extends D{constructor(n){super({fi:["stream","init"],fo:["tracks"],i:["done"],o:[]},{input:{stream:{ref:!0}},output:{tracks:{ref:!0}}},n,lg),this.addListener("destroy",()=>{})}f(e,i){return b(this,arguments,function*({stream:n},t){let o;try{o=yield n.getVideoTracks()}catch(s){t(void 0,s)}let a=new class extends C{constructor(){super(...arguments);this.__=["A"]}append(d){return b(this,null,function*(){throw new O})}put(d,c){return b(this,null,function*(){throw new O})}at(d){return b(this,null,function*(){let c=o[d];return dy(c,this.__system)})}length(){return b(this,null,function*(){return o.length})}indexOf(d){return b(this,null,function*(){throw new O})}}(this.__system);t({tracks:a})})}onIterDataInputData(n){this._forward_all_empty(),this._backward_all(),this._backward("done")}};function my(r,n){return new class extends C{constructor(){super(...arguments);this.__=["IB"]}imageBitmap(){return b(this,null,function*(){return r})}image(){return b(this,null,function*(){return r})}}(n)}var Ga=class extends D{constructor(t){super({fi:["camera"],fo:[],i:["init","done"],o:["image"]},{input:{camera:{ref:!0}},output:{image:{ref:!0}}},t,bg);this._err_flag=!1;this._forward_if_ready=()=>b(this,null,function*(){if(this._input.camera.active()&&this._input.init.active()){let t;try{t=yield this._i.camera.grabFrame()}catch(i){this.err(i.message.toLowerCase()),this._err_flag=!0;return}let e=my(t,this.__system);this._output.image.push(e),this._input.init.pull()}});this.addListener("destroy",()=>{}),this.addListener("take_err",()=>{this._err_flag&&(this._err_flag=!1,this._input.init.pull())})}f(i,o){return b(this,arguments,function*({camera:t},e){this._forward_if_ready()})}onIterDataInputData(t){return b(this,null,function*(){t==="done"?(this._forward_empty("image"),this._done(),this._backward("done")):t==="init"&&this._forward_if_ready()})}};var Ra=class extends l{constructor(n){super({i:["opt","image","rect"],o:["bitmap"]},{input:{image:{ref:!0}},output:{bitmap:{ref:!0}}},n,gg)}f(o,a){return b(this,arguments,function*({opt:n,rect:t,image:e},i){let{api:{media:{image:{createImageBitmap:s}}}}=this.__system,p=yield e.image(),d;try{d=yield s(p,t,n)}catch(m){i(void 0,m.message);return}let c=new class extends C{constructor(){super(...arguments);this.__=["IB"]}imageBitmap(){return b(this,null,function*(){return d})}image(){return b(this,null,function*(){return d})}}(this.__system);i({bitmap:c})})}};function fy(r,n){return new class extends C{constructor(){super(...arguments);this.__=["IC"]}grabFrame(){return r.grabFrame()}}(n)}var ka=class extends D{constructor(n){super({fi:["init","track"],fo:["camera"],i:["done"],o:[]},{input:{track:{ref:!0}},output:{camera:{ref:!0}}},n,hg),this.addListener("destroy",()=>{})}f(i,o){return b(this,arguments,function*({init:n,track:t},e){let{api:{window:{ImageCapture:a}}}=this.__system;if(!a){e(void 0,"ImageCapture API is not supported");return}let s=yield t.mediaStreamTrack();s.onmute=()=>{},s.onunmute=()=>{},s.onended=()=>{};let p=new a(s),d=fy(p,this.__system);e({camera:d})})}onIterDataInputData(n,t){this._forward_all_empty(),this._backward_all(),this._backward("done")}};var $a=class extends D{constructor(t){super({fi:["opt","stream"],fo:[],i:["start","stop"],o:["blob"]},{input:{stream:{ref:!0}},output:{blob:{ref:!0}}},t,yg);this._start_recorder=t=>{this._media_recorder&&(this._media_recorder.state==="recording"&&this._media_recorder.stop(),this._media_recorder.start(t))};this.addListener("destroy",()=>{this._media_recorder.stop(),this._media_recorder.ondataavailable=null,this._media_recorder=null})}f({opt:t,stream:e}){let i=[];e.mediaStream(o=>{this._media_recorder&&(this._media_recorder.stop(),this._media_recorder.ondataavailable=null),this._media_recorder=new MediaRecorder(o,t),this._media_recorder.ondataavailable=s=>{let{data:p}=s;p.size>0&&i.push(p)},this._media_recorder.onstop=()=>{let s=new Blob(i,{type:"audio/wav"}),p=new class extends C{constructor(){super(...arguments);this.__=["B","IM"]}image(){return b(this,null,function*(){return s})}blob(){return b(this,null,function*(){return s})}}(this.__system);this._output.blob.push(p)};let a=this._input.start.peak();a!==void 0&&this._start_recorder(a)})}onIterDataInputData(t,e){t==="start"?this._media_recorder&&this._start_recorder(e):t==="stop"&&this._media_recorder&&(this._media_recorder.state==="recording"&&this._media_recorder.stop(),this._backward("start"),this._backward("stop"))}onIterDataInputDrop(t){this.hasErr()&&this.takeErr(),t==="start"&&(this._backwarding||this._media_recorder&&this._media_recorder.stop())}};function ly(r,n){let{global:{component:t}}=r;return t[n]}function ld(r,n,t){let{emitter:e}=r,i=o=>{t(o)};return e.addListener(n,i),()=>{e.removeListener(n,i)}}function cn(r,n){let{emitter:t}=r,e=r.getLocalComponents(n)[0];return e?Promise.resolve(e):new Promise(i=>{let o=a=>{setTimeout(()=>{t.removeListener(n,o)},0),i(a)};t.addListener(n,o)})}var Na=class extends D{constructor(t){super({fi:["media","opt"],i:["stop"]},{input:{media:{ref:!0}}},t,_g);this._exit_picture_in_picture_promise=Promise.resolve()}_plunk(){let{api:{document:{exitPictureInPicture:t}}}=this.__system;this._unlisten&&(this._unlisten(),this._unlisten=void 0),this._picture_in_picture&&(this._exit_picture_in_picture_promise=t(),this._picture_in_picture=void 0)}f(o,a){return b(this,arguments,function*({media:t,opt:e},i){yield this._exit_picture_in_picture_promise;let s=t.getGlobalId();ld(this.__system,s,p=>b(this,null,function*(){if(p===null)this._plunk();else if(document.pictureInPictureElement===p.$element)this.err("media is already Picture in Picture");else{let d=yield p.requestPictureInPicture(),c=m=>{this._picture_in_picture=void 0,this._plunk()};p.$element.addEventListener("leavepictureinpicture",c),this._unlisten=()=>{p.$element.removeEventListener("leavepictureinpicture",c)},this._picture_in_picture=d}}))})}onIterDataInputData(t){this._plunk(),this._backward("media"),this._backward("opt")}};var Fa=class extends l{constructor(t){super({i:["opt"],o:["stream"]},{output:{stream:{ref:!0}}},t,xg);this.addListener("destroy",()=>{this._stream&&(fd(this._stream),this._stream=void 0)})}f(i,o){return b(this,arguments,function*({opt:t},e){let{api:{media:{getUserMedia:a}}}=this.__system,s;try{let p=yield a(t);s=re(p,this.__system)}catch(p){e(void 0,p.message);return}e({stream:s})})}};var Ba=class extends D{constructor(t){super({fi:["url"],fo:["emitter"],i:["close"],o:[]},{output:{emitter:{ref:!0}}},t,Ig);this._event_source=null;this._pluck=()=>{this._event_source&&(this._event_source.close(),this._event_source=null)}}f({url:t},e){let{api:{http:{EventSource:i}}}=this.__system,o=new i(t);this._event_source=o,o.onerror=a=>{this._pluck(),e(void 0,"error connecting to server")},o.onopen=a=>{let s=new class extends C{addListener(d,c){super.addListener(d,c);let m=f=>{c(f.data)};return o.addEventListener(d,m),()=>{o.removeEventListener(d,m)}}}(this.__system);e({emitter:s})}}onIterDataInputData(t,e){t==="close"&&this._pluck()}};var ja=class extends l{constructor(t){super({i:["url","opt"],o:["response"]},{},t,vg);this._fetch_index=0}f({url:t,opt:e},i){let{api:{http:{fetch:o}}}=this.__system,a=++this._fetch_index;try{o(t,e).then(s=>{if(a===this._fetch_index)return s.text().then(p=>{a===this._fetch_index&&i({response:{status:s.status,body:p}})})}).catch(s=>{if(a===this._fetch_index){if(s.message.toLowerCase()==="failed to execute 'fetch' on 'window': request with get/head method cannot have body."){i(void 0,"request with GET/HEAD method cannot have body");return}i(void 0,s.message.toLowerCase())}})}catch(s){i(void 0,"malformed")}}};function by(r,n){return new class extends C{constructor(){super(...arguments);this.__=["RES"]}toJson(){return r.json()}}(n)}var Ha=class extends l{constructor(n){super({i:["url","opt","body"],o:["res"]},{input:{body:{ref:!0}},output:{res:{ref:!0}}},n,Dg)}f(o,a){return b(this,arguments,function*({url:n,opt:t,body:e},i){let{api:{http:{fetch:s}}}=this.__system;t.body=yield e.raw();let p;try{p=yield s(n,t)}catch(c){i(void 0,"malformed");return}let d=by(p,this.__system);i({res:d})})}};function gy(r,n){return new class extends C{constructor(){super(...arguments);this.__=["CH"]}send(o){return b(this,null,function*(){r.send(o)})}}(n)}var Va=class extends D{constructor(t){super({fi:["url"],fo:["channel"],i:["close"],o:[]},{},t,Sg);this._web_socket=null;this._plunk=()=>{this._web_socket.onopen=null,this._web_socket.onmessage=null,this._web_socket.onerror=null,this._web_socket.onclose=null,this._web_socket=null}}f({url:t},e){this._web_socket&&this._web_socket.close(),this._web_socket=new WebSocket(t),this._web_socket.onopen=()=>{},this._web_socket.onmessage=o=>{this.emit("message",o.data)},this._web_socket.onerror=o=>{this.err("error")},this._web_socket.onclose=o=>{let{code:a,reason:s}=o;this._plunk()};let i=gy(this._web_socket,this.__system);e({channel:i})}d(){this._plunk()}onIterDataInputData(t,e){this._close(),this._done()}_close(){this._web_socket&&this._web_socket.readyState===WebSocket.OPEN&&this._web_socket.close()}send(t){return b(this,null,function*(){this._web_socket&&this._web_socket.readyState===WebSocket.OPEN&&this._web_socket.send(t)})}};var za=class extends l{constructor(n){super({i:["res","any"],o:["json"]},{},n,Eg)}f(e,i){return b(this,arguments,function*({res:n},t){let o=yield n.toJson();t({json:o})})}};var Wa=class extends Q{constructor(n){super({i:["this","opt"],o:[]},{input:{notification:{ref:!0}}},n,Tg)}};var Ka=class extends Q{constructor(t){super({i:[],o:[]},{},t,Ag);this._notification=null;this._setup()}onDataInputData(t){this.hasErr()&&this.takeErr()}_setup(){if("Notification"in window){let{permission:t}=Notification;t==="default"?Notification.requestPermission().then(e=>{this.err("not authorized")}):this.err("not authorized")}else this.err("not authorized")}$show({title:t,opt:e},i){this._notification=new Notification(t,e),this._notification.onclick=()=>{this.emit("click")},this._notification.onclose=()=>{this.emit("close")},this._notification.onerror=()=>{this.emit("error")},this._notification.onshow=()=>{this.emit("show")},i()}$close({},t){this._notification&&this._notification.close(),t()}};var qa=class extends Q{constructor(n){super({i:["this"],o:[]},{input:{notification:{ref:!0}}},n,Cg)}};var Ya=class extends D{constructor(n){super({fi:["root","opt"],fo:["observer"],i:["done"],o:[]},{input:{root:{ref:!0}},output:{observer:{ref:!0}}},n,Mg)}f(e,i){return b(this,arguments,function*({root:n},t){let{api:{document:{IntersectionObserver:o}}}=this.__system,a=n.getGlobalId(),s=yield cn(this.__system,a),p=x=>{for(let y=0;y<x.length;y++){let I=x[y],v=g[y];if(!v)return;let T={isIntersecting:I.isIntersecting,time:I.time};v(T)}},d=s.getRootBase(),c=s;for(;d.length===0;)d=c.$slotParent.getRootBase(),c=c.$slotParent;let m=d[0][1],f=new o(p,{root:m.$element,threshold:.1}),g=[],h=new class extends C{constructor(){super(...arguments);this.__=["OB"]}observe(I,v){return g.push(v),f.observe(I),()=>{$t(g,v),f.unobserve(I)}}}(this.__system);t({observer:h})})}d(){}};var Ja=class extends D{constructor(n){super({fi:["component","observer"],fo:[],i:["done"],o:["entry"]},{input:{component:{ref:!0}}},n,Pg)}f(i,o){return b(this,arguments,function*({observer:n,component:t},e){let{api:{document:{}}}=this.__system,a=t.getGlobalId(),p=(yield cn(this.__system,a)).getFirstRootLeaf();if(p.$element instanceof Text){e(void 0,"cannot observe text node");return}n.observe(p.$element,d=>{this._output.entry.push(d)})})}d(){}};var Xa=class extends D{constructor(t){super({fi:["component","opt"],fo:[],i:["done"],o:["entry"]},{input:{component:{ref:!0}}},t,Og)}f(e){return b(this,arguments,function*({component:t}){let{api:{document:{PositionObserver:i}}}=this.__system,o=t.getGlobalId(),a=yield cn(this.__system,o);if(!this._observer){let d=(m,f)=>{this._output.entry.push({x:m,y:f})},c=new i(this.__system,d);this._observer=c}let s=a.getFirstRootLeaf(),{$element:p}=s;this._observer.observe(p)})}d(){}onIterDataInputData(t,e){this._observer&&this._observer.disconnect(),this._unlisten&&(this._unlisten(),this._unlisten=void 0),this._done(),this.pullInput("done")}};var Za=class extends D{constructor(t){super({fi:["component"],fo:[],i:[],o:["width","height"]},{input:{component:{ref:!0}}},t,Ug)}f({component:t},e){let{api:{document:{ResizeObserver:i}}}=this.__system,o=t.getGlobalId(),a=ly(this.__system,o),s=d=>{if(!this._observer){let m=g=>{let h=g[0],{width:x,height:y}=h.contentRect;this._output.width.push(x),this._output.height.push(y)},f=new i(m);this._observer=f}a&&this._observer.unobserve(a.$element),a=d;let{$element:c}=a};a&&s(a);let p=ld(this.__system,o,d=>{s(d)})}d(){}};function hy(r){return b(this,null,function*(){return new Promise((n,t)=>{let e=[],i=a=>b(this,[a],function*({candidate:o}){o?e.push(o):(r.removeEventListener("icecandidate",i),n(e))});r.addEventListener("icecandidate",i)})})}var oe=class extends C{constructor(t,e,i){super(t);if(this._initiator=e,this._config=i,!RTCPeerConnection)throw new V("Web RTC");let o=new RTCPeerConnection(this._config);this._setup(o),this._rtc=o;let a=this._rtc.createDataChannel("data",{negotiated:!0,id:0});if(a.onmessage=s=>{let{data:p}=s,d=JSON.parse(p),{type:c,data:m}=d;switch(c){case"message":this.emit("message",m);break;case"start":this._incoming_stream&&this.emit("start",this._incoming_stream);break;case"stop":this.emit("stop");break}},a.onopen=()=>{if(this.emit("connect"),this._stream){let s=JSON.stringify({type:"start"});this._rtc_channel.send(s)}},this._initiator){let s=new MediaStream;this._outgoing_stream=s;let p=this._rtc.addTransceiver("video",{streams:[s]});this._video_transceiver=p;let d=this._rtc.addTransceiver("audio",{streams:[s]});this._audio_transceiver=d}this._rtc_channel=a}send(t){let e=JSON.stringify({type:"message",data:t});this._rtc_channel.send(e)}offer(){return b(this,null,function*(){return this._offer(this._rtc)})}_offer(t){return b(this,null,function*(){let e=yield t.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});yield t.setLocalDescription(e);let{sdp:i}=e,o=yield hy(t);return JSON.stringify({sdp:i,candidates:o})})}_setup(t){t.onconnectionstatechange=()=>{let{connectionState:e}=t;switch(e){case"connected":break;case"disconnected":case"closed":this.emit("close");break}},this._initiator||(t.ontrack=e=>{let{streams:i}=e,o=i[0];o&&(this._incoming_stream=o)})}_plunk(t){t.oniceconnectionstatechange=null,t.onconnectionstatechange=null,t.onicegatheringstatechange=null,t.onnegotiationneeded=null,t.ondatachannel=null,t.ontrack=null}_plunk_channel(t){t.onmessage=null}acceptOffer(t){return b(this,null,function*(){return this._acceptOffer(this._rtc,t)})}_acceptOffer(t,e){return b(this,null,function*(){let{sdp:i,candidates:o}=JSON.parse(e),a=new RTCSessionDescription({type:"offer",sdp:i});yield t.setRemoteDescription(a);for(let s of o)yield t.addIceCandidate(s)})}answer(){return b(this,null,function*(){return this._answer(this._rtc)})}_answer(t){return b(this,null,function*(){let e=yield t.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});t.setLocalDescription(e);let{sdp:i}=e,o=yield hy(t);return JSON.stringify({sdp:i,candidates:o})})}acceptAnswer(t){return b(this,null,function*(){return this._acceptAnswer(this._rtc,t)})}_acceptAnswer(t,e){return b(this,null,function*(){let{sdp:i,candidates:o}=JSON.parse(e),a=new RTCSessionDescription({type:"answer",sdp:i});yield t.setRemoteDescription(a);for(let s of o)yield t.addIceCandidate(s)})}addStream(t){return b(this,null,function*(){this._stream=t;let e=t.getAudioTracks()[0];e&&(yield this._audio_transceiver.sender.replaceTrack(e));let i=t.getVideoTracks()[0];if(i&&(yield this._video_transceiver.sender.replaceTrack(i)),this._rtc_channel.readyState==="open"){let o=JSON.stringify({type:"start"});this._rtc_channel.send(o)}})}removeStream(){return b(this,null,function*(){if(this._stream=null,yield Promise.all([this._video_transceiver.sender.replaceTrack(null),this._audio_transceiver.sender.replaceTrack(null)]),this._rtc_channel.readyState==="open"){let t=JSON.stringify({type:"stop"});this._rtc_channel.send(t)}})}close(){this._plunk_channel(this._rtc_channel),this._rtc_channel.close(),this._plunk(this._rtc),this._rtc.close()}};var Qa=class extends Q{constructor(t){super({i:["opt","offer","close"],o:["graph","answer"]},{output:{graph:{ref:!0}}},t,wg);this.__=["U"];this._peer_connected=!1;this._offer_sent=!1;this._accept_offer=t=>b(this,null,function*(){yield this._peer.acceptOffer(t);let e=yield this._peer.answer();this._output.answer.push(e),this._offer_sent=!0});this.__forward_empty=()=>{this._forward_all_empty(),this._backward("offer"),this._backward("close"),this._backward("opt"),this._forwarding_empty=!0,this.hasErr()&&this.takeErr(),this._disconnect(),this._forwarding_empty=!1};this._disconnect=()=>{this._backwarding=!0,this._output.graph.pull(),this._remote_port&&(this._remote_port.close(),this._remote_port=void 0),this._peer&&(this._peer=null),this._backwarding=!1};this.addListener("destroy",()=>{this.__forward_empty()}),this.addListener("take_err",()=>{}),this.addListener("take_caught_err",()=>{})}onDataInputData(t,e){return b(this,null,function*(){if(t==="opt"){this._peer=new oe(this.__system,!1,e);let i={send:a=>{let s=Y(a);this._peer.send(s)},onmessage(a){},onerror(){},terminate(){}};this._peer.addListener("message",a=>{let s=this.__system.specs,p=this.__system.classes,d=st(a,s,p),{type:c,data:m}=d;switch(c){case Ot:i.onmessage({data:m});break;case Zt:{let f=new qt(i);this._remote_port=f;let g=un(f),h=Gt(this.__system,g,["U","C","G"]);this._output.graph.push(h)}break;case Qt:this._disconnect();break}}),this._peer.addListener("connect",()=>{this._peer_connected=!0}),this._peer.addListener("close",()=>{this._peer_connected=!1});let o=this._input.offer.peak();o!==void 0&&this._accept_offer(o)}else if(t==="offer"){if(this._peer){let i=e;this._accept_offer(i)}}else t==="close"&&this.__forward_empty()})}onDataInputDrop(t){t==="opt"&&(this._backwarding||this.__forward_empty())}};function yy(r){return new class extends C{constructor(){super(...arguments);this.__=["EE"]}}(r)}var ts=class extends D{constructor(t){super({fi:["opt"],fo:["answer"],i:["close","offer"],o:["stream","emitter"]},{input:{}},t,Lg);this._peer=null;this._unlisten=void 0;this._connected=!1;this._flag_err_invalid_offer=!1;this._output_answer=t=>b(this,null,function*(){try{yield this._peer.acceptOffer(t)}catch(i){this._flag_err_invalid_offer=!0,this.err("invalid offer");return}let e=yield this._peer.answer();this._output.answer.push(e)});this._send_data=(t,e)=>{this._send({type:"data",data:t},e)};this._send=(t,e)=>{if(this._connected){let i=Y(t);this._peer.send(i),e()}else e(void 0,"peer not connected")};this._setup_peer=()=>{let t=()=>{this._connected=!0;let p=yy(this.__system);this._output.emitter.push(p)},e=p=>{this.err(p.message)},i=()=>{this._disconnect()},o=p=>{this._output.emitter.active()&&this._output.emitter.peak().emit("message",p)},a=p=>{let d=re(p,this.__system);this._output.stream.push(d)},s=()=>{this._output.stream.pull()};return this._peer.addListener("connect",t),this._peer.addListener("error",e),this._peer.addListener("close",i),this._peer.addListener("message",o),this._peer.addListener("start",a),this._peer.addListener("stop",s),()=>{this._peer.removeListener("connect",t),this._peer.removeListener("error",e),this._peer.removeListener("close",i),this._peer.removeListener("message",o),this._peer.removeListener("start",a),this._peer.removeListener("stop",s)}};this._disconnect=()=>{this._unlisten&&(this._unlisten(),this._unlisten=void 0),this._output.emitter.pull(),this._output.stream.pull(),this._peer&&(this._peer.close(),this._peer=null),this._connected=!1,this._done({})};this.addListener("destroy",()=>{this._disconnect()}),this.addListener("take_err",()=>{this._flag_err_invalid_offer&&(this._flag_err_invalid_offer=!1,this._backward("offer"))})}f(e){return b(this,arguments,function*({opt:t}){this._peer=new oe(this.__system,!1,t),this._setup_peer(),this._input.offer.active()&&this._output_answer(this._input.offer.peak())})}onDataInputData(t,e){return b(this,null,function*(){t==="close"?(this._disconnect(),this._backward("close")):t==="offer"&&this._input.opt.active()&&this._output_answer(e)})}onDataInputDrop(t){if(t==="opt")this._backwarding||this._disconnect();else if(t==="offer"){if(this._flag_err_invalid_offer){this._flag_err_invalid_offer=!1,this.takeErr();return}this._forward_empty("emitter"),this._forward_empty("stream"),this._forward_empty("answer")}}onDataOutputDrop(t){t==="answer"&&this._input.offer.pull()}};function bd(r,n,t){let e=Xn(r,n);return new Ee(e,t)}var es=class extends D{constructor(t){super({fi:["graph","opt"],fo:["offer"],i:["answer","close"],o:[]},{input:{graph:{ref:!0}}},t,Gg);this.__=["U"];this._connected=!1;this._disconnect=()=>{this._send_terminate(),this._peer=null};this._close=()=>{this._ref=null};this._send=t=>{let e=Y(t);this._peer.send(e)};this._send_init=()=>{this._send({type:Zt})};this._send_exec=t=>{this._send({type:Ot,data:t})};this._send_terminate=()=>{this._connected&&this._send({type:Qt})};this.addListener("destroy",()=>{this._connected&&(this._disconnect(),this._close())})}f({graph:t,opt:e},i){let o=new oe(this.__system,!0,e);this._connected=!1,o.addListener("connect",()=>{this._connected=!0,this._input.graph.active()&&this._send_init()}),o.addListener("close",()=>{this._connected=!1}),o.addListener("message",s=>{if(this._ref){let p=this.__system.specs,d=this.__system.classes,c=st(s,p,d);this._ref.exec(c)}}),this._peer=o,b(this,null,function*(){let s=yield o.offer();i({offer:s})});let a=bd(t,["U","C","G","EE"],s=>{this._send_exec(s)});this._ref=a,this._connected&&this._send_init(),this._input.answer.active()&&b(this,null,function*(){yield this._peer.acceptAnswer(this._input.answer.peak())})}d(){this._disconnect()}onIterDataInputData(t,e){return b(this,null,function*(){t==="answer"?this._peer&&(yield this._peer.acceptAnswer(e)):t==="close"&&this._disconnect()})}onIterDataInputDrop(t){return b(this,null,function*(){t==="answer"&&this._disconnect()})}};var ns=class extends D{constructor(t){super({fi:["opt"],i:["answer","stream","close"],o:["offer","channel"]},{input:{stream:{ref:!0}},output:{channel:{ref:!0}}},t,Rg);this._peer=void 0;this._unlisten=void 0;this._connected=!1;this._offered=!1;this._flag_err_peer_construct=!1;this._flag_err_answer_without_offer=!1;this._stream=null;this._add_stream=t=>{this._stream=t,this._peer&&this._peer.addStream(t)};this._remove_stream=t=>{this._peer.removeStream()};this._output_port=()=>{let t=this._peer,e=new class extends C{constructor(){super(...arguments);this.__=["MS"]}send(a){return b(this,null,function*(){let s=Y(a);t.send(s)})}}(this.__system);this._output.channel.push(e)};this._setup_peer=()=>{let t=a=>{let{sdp:s}=a;this._output.offer.push(s)},e=()=>{this._connected=!0,this._output_port()},i=a=>{this.err(a.message)},o=()=>{this._disconnect()};return this._peer.addListener("connect",e),this._peer.addListener("error",i),this._peer.addListener("close",o),()=>{this._peer.removeListener("connect",e),this._peer.removeListener("error",i),this._peer.removeListener("close",o)}};this._disconnect=()=>{if(!this._connected)return;let t=this._unlisten;t(),this._unlisten=void 0,this._peer.close(),this._peer=void 0,this._connected=!1,this._forward_empty("offer"),this._forward_empty("channel"),this._done({})};this.addListener("destroy",()=>{this._connected&&this._disconnect()}),this.addListener("take_err",()=>{if(!this._backwarding)if(this._flag_err_answer_without_offer)this._flag_err_answer_without_offer=!1,this._backward("answer");else if(this._flag_err_peer_construct)this._flag_err_peer_construct=!1,this._backward("opt");else throw new Error("PeerTransmitter: invalid err state")})}f(e){return b(this,arguments,function*({opt:t}){try{this._peer=new oe(this.__system,!0,t)}catch(o){let{message:a}=o,s="Failed to construct 'RTCPeerConnection': ";if(a.startsWith(s)){let p=a.substr(0,a.length-1).replace(s,"");this.err(p);return}else{this.err(o.message);return}}this._unlisten=this._setup_peer();let i=yield this._peer.offer();this._offered=!0,this._output.offer.push(i)})}onRefInputData(t,e){e.mediaStream(i=>{i===null?(this._stream&&this._remove_stream(this._stream),this._stream=null):(this._stream&&this._remove_stream(this._stream),this._add_stream(i),this._stream=i)})}onDataInputData(t,e){return b(this,null,function*(){if(this.hasErr()&&(this._backwarding=!0,this.takeErr(),this._backwarding=!1),t==="answer"){let i=e;if(this._offered)try{yield this._peer.acceptAnswer(i)}catch(o){this.err(o.message);return}else this._flag_err_answer_without_offer=!0,this.err("cannot answer without offer")}else t==="close"&&(this._disconnect(),this._output.offer.pull(),this._output.channel.pull(),this._done({}),this._input.close.pull())})}onDataInputDrop(t){t==="answer"&&(this._flag_err_answer_without_offer&&this.takeErr(),this._connected&&this._disconnect())}onDataOutputDrop(t){this._connected&&this._output_port()}onRefInputDrop(t){this._unlisten_stream&&(this._unlisten_stream(),this._unlisten_stream=void 0),this._stream&&(this._stream=null,this._peer&&this._remove_stream(this._stream))}_send_data(t){return b(this,null,function*(){return this._send({type:"data",data:t})})}_send(t){return b(this,null,function*(){let e=Y(t);this._peer.send(e)})}send(t){return b(this,null,function*(){return this._send_data(t)})}};var is=class extends D{constructor(t){super({fi:["element","pointerId"],fo:[],i:["done"],o:[]},{input:{element:{ref:!0}}},t,kg);this._capturing=!1;this._element=null;this._release=()=>{if(this._capturing){let t=this._pointerId;this._done(),this._input.done.pull(),this._element.emit("call",{method:"releasePointerCapture",data:[t]}),this._capturing=!1,this._pointerId=void 0,this._element=null}}}f({element:t,pointerId:e}){this._capturing||(this._release(),this._capturing=!0,this._pointerId=e,this._element=t,t.emit("call",{method:"setPointerCapture",data:[e]}))}onIterDataInputData(t,e){this._release()}};var rs=class extends l{constructor(n){super({i:["component","any"],o:[]},{input:{component:{ref:!0}}},n,$g)}f(e,i){return b(this,arguments,function*({component:n},t){n.emit("call",{method:"hidePopover",data:[]}),t()})}};var os=class extends l{constructor(n){super({i:["component","any"],o:[]},{input:{component:{ref:!0}}},n,Ng)}f(e,i){return b(this,arguments,function*({component:n},t){n.emit("call",{method:"showPopover",data:[]}),t()})}};var as=class extends l{constructor(n){super({i:["component","any"],o:[]},{input:{component:{ref:!0}}},n,Fg)}f(e,i){return b(this,arguments,function*({component:n},t){n.emit("call",{method:"togglePopover",data:[]}),t()})}};var ss=class extends l{constructor(n){super({i:["component","opt"],o:[]},{input:{component:{ref:!0}}},n,Bg)}f(i,o){return b(this,arguments,function*({component:n,opt:t},e){n.emit("call",{method:"scrollIntoView",data:[t]}),e()})}};var ps=class extends l{constructor(n){super({i:["channel","data"],o:[]},{input:{channel:{ref:!0}}},n,jg)}f(i,o){return b(this,arguments,function*({channel:n,data:t},e){try{let a=t;a instanceof C&&(a=yield a.raw()),yield n.send(a)}catch(a){e(void 0,a.message);return}e()})}};var us=class extends l{constructor(n){super({i:["data"],o:[]},{input:{}},n,Hg)}f(e,i){return b(this,arguments,function*({data:n},t){let{api:{navigator:{share:o}}}=this.__system;try{yield o(n)}catch(a){t(void 0,a.message);return}t()})}};var gd=class extends mt{constructor(t,e){super();this._recording=!1;let{api:{speech:{SpeechGrammarList:i,SpeechRecognition:o}}}=t;if(o&&i){let{grammars:a,lang:s="en-US",continuous:p=!1,interimResults:d=!1,maxAlternatives:c=1}=e,m;try{m=o({grammars:void 0,lang:s,interimResults:d,maxAlternatives:c,continuous:p})}catch(f){throw f}this._unlisten=tt([m.addListener("error",f=>{}),m.addListener("end",()=>{this._recording?m.start():this.emit("end")}),m.addListener("result",f=>{let h=f[0][0],{transcript:x,confidence:y}=h;this.emit("transcript",x)})]),this._recognition=m}}start(){this._recognition&&(this._recording||(this._recording=!0,this._recognition.start()))}stop(){if(this._recognition&&this._recording){this._recording=!1;try{this._recognition.stop()}catch(t){}}}};var cs=class extends D{constructor(t){super({fi:["opt"],fo:[],i:["stop"],o:["text"]},{},t,Vg);this._recorder=null}f({opt:t},e){let i=new gd(this.__system,t);this._recorder=i,this._recorder.start(),this._recorder.addListener("transcript",o=>{this._output.text.push(o)}),this._recorder.addListener("err",o=>{e(void 0,o)}),this._recorder.addListener("end",()=>{this._recorder=null,e()})}onIterDataInputData(t,e){this._recorder.stop()}};var ds=class extends l{constructor(n){super({i:["message","voice"],o:[]},{},n,zg)}f({message:n,voice:t},e){let{api:{speech:{SpeechSynthesis:i,SpeechSynthesisUtterance:o}}}=this.__system;if(n===""){e();return}let a;try{a=i({})}catch(c){e(void 0,c.message);return}let s=[],p=()=>{s=a.getVoices(),s.length>0?d():setTimeout(()=>{p()},100)},d=()=>{if(t<0||t>s.length-1){e(void 0,"voice index out of range");return}let c=s[t],m=o({text:n,voice:c});m.addEventListener("error",f=>{e(void 0,f.error)}),m.addEventListener("end",()=>{e()}),a.speak(m)};p()}};var ms=class extends yt{constructor(t){super({i:[],o:[]},{},t,Wg);this.___emitter=new mt;this._checkAPI=()=>{if(!localStorage)throw new V("Local Storage")}}subscribe(t,e,i){let{emitter:o}=this.__system;if(t.length>0)throw new Error("local storage path length must be 0");let a=(d,c)=>{(e==="*"||d===e)&&i("set",t,d,c)},s=d=>{i("delete",t,e,d)};return o.addListener("set",a),o.addListener("delete",s),()=>{o.removeListener("set",a),o.removeListener("delete",s)}}read(){return b(this,null,function*(){return jc()})}write(t){return b(this,null,function*(){})}get(t){return b(this,null,function*(){this._checkAPI();let e=localStorage.getItem(t);if(e===null)throw new Error("item not found");return e})}set(t,e){return b(this,null,function*(){let{emitter:i}=this.__system;this._checkAPI(),localStorage.setItem(t,e),i.emit("set",t,e)})}delete(t){return b(this,null,function*(){let{emitter:e}=this.__system;this._checkAPI();let i=localStorage.getItem(t);localStorage.removeItem(t),e.emit("delete",t,i)})}deepSet(t,e){return b(this,null,function*(){throw new O})}deepGet(t){return b(this,null,function*(){throw new O})}deepDelete(t){return b(this,null,function*(){throw new O})}keys(){return b(this,null,function*(){return Be(localStorage)})}hasKey(t){return b(this,null,function*(){return an(localStorage,t)})}};var fs=class extends Q{constructor(t){super({i:[],o:[]},{},t,Kg);this._checkAPI=()=>{if(!sessionStorage)throw new Error("session Storage API not implemented")}}read(){return b(this,null,function*(){return this._checkAPI(),r0()})}write(t){return b(this,null,function*(){throw this._checkAPI(),new O})}get(t){return b(this,null,function*(){this._checkAPI();let e=sessionStorage.getItem(t);if(e===null)throw new Error("item not found");return e})}set(t,e){return b(this,null,function*(){this._checkAPI(),localStorage.setItem(t,e)})}delete(t){return b(this,null,function*(){this._checkAPI(),sessionStorage.removeItem(t)})}deepSet(t,e){throw new O}deepGet(t){throw new O}deepDelete(t){throw new O}subscribe(t,e,i){throw new O}keys(){return b(this,null,function*(){return Be(sessionStorage)})}hasKey(t){return b(this,null,function*(){return an(sessionStorage,t)})}};var ls=class extends l{constructor(n){super({i:["hash"],o:["value"]},{},n,qg)}f({hash:n},t){t()}};var bs=class extends l{constructor(n){super({i:["any"],o:["key"]},{},n,Yg)}f({any:n},t){t()}};var gs=class extends l{constructor(n){super({i:["value"],o:["hash"]},{},n,Zc)}f({value:n},t){t()}};var hs=class extends l{constructor(n){super({i:["unit","data"],o:[]},{input:{unit:{ref:!0},data:{ref:!0}}},n,Jg)}f(i,o){return b(this,arguments,function*({unit:n,data:t},e){try{yield n.send(t)}catch(a){e(void 0,a.message);return}e()})}};var ys=class extends l{constructor(n){super({i:["blob","init"],o:["url"]},{input:{blob:{ref:!0}}},n,Xg)}f(i,o){return b(this,arguments,function*({blob:n,init:t},e){let{api:{url:{createObjectURL:a}}}=this.__system,s,p=yield n.blob();try{s=yield a(p)}catch(d){e(void 0,d.message);return}e({url:s})})}};var _s=class extends l{constructor(n){super({i:["uri"],o:["UTF-8"]},{},n,Zg)}f({uri:n},t){let{api:{uri:{encodeURI:e}}}=this.__system,i;try{i=e(n)}catch(o){t(void 0,o.message);return}t({"UTF-8":i})}};var xs=class extends l{constructor(n){super({i:["text"],o:["uri"]},{},n,Qg)}f({text:n},t){let{api:{uri:{encodeURIComponent:e}}}=this.__system,i;try{i=e(n)}catch(o){t(void 0,o.message);return}t({uri:i})}};var Is=class extends l{constructor(n){super({i:["url"],o:["obj"]},{},n,t4)}f(e,i){return b(this,arguments,function*({url:n},t){let{api:{}}=this.__system,o;try{let a=new URL(n);o={protocol:a.protocol,hostname:a.hostname,pathname:a.pathname,search:a.search,hash:a.hash,host:a.host,href:a.href,origin:a.origin,port:a.port}}catch(a){t(void 0,"invalid url");return}t({obj:o})})}};var vs=class extends l{constructor(n){super({i:["pattern"],o:[]},{},n,e4)}f({pattern:n},t){let{api:{device:{vibrate:e}}}=this.__system;try{e(n)}catch(i){t(void 0,i.message);return}t()}};var Ds=class extends D{constructor(t){super({fi:["lock"],fo:[],i:["done"],o:[]},{},t,n4);this._lock=t=>b(this,null,function*(){let{api:{screen:{requestWakeLock:e}}}=this.__system,i=yield e(t);i.addListener("done",this._on_release),this._wake_lock=i});this._release=()=>{this._wake_lock&&this._wake_lock.done()};this._on_release=()=>{this._wake_lock=null}}f({lock:t},e){this._lock({type:"screen"})}d(){this._release()}onIterDataInputData(t,e){this._release()}};var Ss=class extends D{constructor(t){super({fi:["url","target","features"],fo:["window"],i:["done"],o:[]},{output:{window:{ref:!0}}},t,od);this._release=()=>{this._window&&this._window.close()};this._on_release=()=>{this._window=null}}f({url:t,target:e,features:i},o){let{api:{window:{open:a}}}=this.__system,s=Object.entries(i).map(([c,m])=>`${c}=${m}`).join(","),p=a(t,e,s);this._window=p;let d=new class extends C{constructor(){super(...arguments);this.__=["CH"]}send(f){return b(this,null,function*(){let g=Y(f);p.postMessage(g,"*")})}}(this.__system);try{window.addEventListener("message",c=>{d.emit("message",c.data)})}catch(c){o(void 0,c.message);return}o({window:d})}d(){this._release()}onIterDataInputData(t,e){this._release()}};var Es=class extends D{constructor(n){super({fi:["window","target","data"],fo:[],i:[],o:[]},{output:{window:{ref:!0}}},n,od)}f({window:n,target:t,data:e},i){let{api:{window:{open:o}}}=this.__system;i({})}};var _y=JSON.parse(`{
|
|
2
2
|
"activity": "M22 12 L18 12 L15 21 L9 3 L6 12 L2 12",
|
|
3
3
|
"airplay": "M5 17H4a2 2 0 01-2-2V5a2 2 0 012-2h16a2 2 0 012 2v10a2 2 0 01-2 2h-1 M12 15 L17 21 L7 21 L12 15 Z",
|
|
4
4
|
"alarm-check": "M12 21a8 8 0 100-16 8 8 0 000 16z M5 3L2 6 M22 6l-3-3 M6 19l-2 2 M18 19l2 2 M9 13l2 2 4-4",
|