@graphrefly/graphrefly 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-EUE7ELFQ.js → chunk-2C4NESZE.js} +1 -1
- package/dist/{chunk-PIIUJIF7.js → chunk-4EATTNAE.js} +1 -1
- package/dist/chunk-B4L5X2QO.js +7 -0
- package/dist/{chunk-YV2A2VWG.js → chunk-C5CBVOCB.js} +1 -1
- package/dist/{chunk-J6TGRQUP.js → chunk-CZIQ6JCE.js} +1 -1
- package/dist/chunk-FJ6IEMOS.js +1 -0
- package/dist/{chunk-T7GWBGOO.js → chunk-FMI4CWFL.js} +1 -1
- package/dist/{chunk-RRFOCAH6.js → chunk-G6Q3DUMJ.js} +1 -1
- package/dist/{chunk-CD4CB6S7.js → chunk-GDDPCDLG.js} +1 -1
- package/dist/{chunk-3OT7K33Q.js → chunk-GFOT6UBB.js} +1 -1
- package/dist/{chunk-53XJ2S6D.js → chunk-K2WYIVHM.js} +1 -1
- package/dist/{chunk-5XZRCS2M.js → chunk-K6ZFJ473.js} +1 -1
- package/dist/{chunk-E5YSBQSF.js → chunk-KTWBUJO5.js} +1 -1
- package/dist/{chunk-RLMYS3XZ.js → chunk-KUVDFOJH.js} +1 -1
- package/dist/{chunk-XMDNNSMK.js → chunk-LOQRPP4Y.js} +1 -1
- package/dist/{chunk-2Y3DKIZL.js → chunk-MC5LZG3U.js} +1 -1
- package/dist/{chunk-M5UC63ZI.js → chunk-NKKUUKPD.js} +1 -1
- package/dist/{chunk-GWOKTENT.js → chunk-QKBCTKH7.js} +1 -1
- package/dist/{chunk-YOUAVGHJ.js → chunk-QP5TH523.js} +1 -1
- package/dist/{chunk-T6RPUERH.js → chunk-QWVQIL3T.js} +1 -1
- package/dist/{chunk-6G5YD37E.js → chunk-T4U24DXX.js} +1 -1
- package/dist/{chunk-W2ZU226Q.js → chunk-TFK4P4CX.js} +1 -1
- package/dist/{chunk-PVUTRA5K.js → chunk-TLS7M7H4.js} +1 -1
- package/dist/{chunk-BGEY3PXH.js → chunk-U3COB5WU.js} +1 -1
- package/dist/{chunk-UAMWD4GG.js → chunk-UODQF4EY.js} +1 -1
- package/dist/{chunk-U347KVM4.js → chunk-WGST56ZH.js} +1 -1
- package/dist/{chunk-XINLP35X.js → chunk-WSLN4JFO.js} +1 -1
- package/dist/{chunk-ZGVA2SR5.js → chunk-XIJKEXWR.js} +1 -1
- package/dist/{chunk-JUJEPZOI.js → chunk-YVYSO5CW.js} +1 -1
- package/dist/compat/index.cjs +9 -9
- package/dist/compat/index.d.cts +6 -6
- package/dist/compat/index.d.ts +6 -6
- package/dist/compat/index.js +1 -1
- package/dist/compat/nestjs/index.cjs +11 -11
- package/dist/compat/nestjs/index.d.cts +4 -4
- package/dist/compat/nestjs/index.d.ts +4 -4
- package/dist/compat/nestjs/index.js +1 -1
- package/dist/compat/zustand/index.cjs +7 -7
- package/dist/compat/zustand/index.d.cts +2 -2
- package/dist/compat/zustand/index.d.ts +2 -2
- package/dist/compat/zustand/index.js +1 -1
- package/dist/extra/index.cjs +17 -17
- package/dist/extra/index.d.cts +3 -3
- package/dist/extra/index.d.ts +3 -3
- package/dist/extra/index.js +1 -1
- package/dist/extra/reactive.cjs +1 -1
- package/dist/extra/reactive.d.cts +1 -1
- package/dist/extra/reactive.d.ts +1 -1
- package/dist/extra/reactive.js +1 -1
- package/dist/graph/index.cjs +7 -7
- package/dist/graph/index.d.cts +3 -3
- package/dist/graph/index.d.ts +3 -3
- package/dist/graph/index.js +1 -1
- package/dist/{graph-kTltt95s.d.cts → graph-CaNXUc3c.d.cts} +26 -1
- package/dist/{graph-Cv-8x0ZI.d.ts → graph-YQXDndFy.d.ts} +26 -1
- package/dist/{index-KNAMYngu.d.ts → index-0qOD-421.d.ts} +2 -2
- package/dist/{index-CfOSES72.d.cts → index-4IwO4mH2.d.cts} +5 -5
- package/dist/{index-CAIhFfws.d.ts → index-9mbs_PIG.d.ts} +2 -2
- package/dist/{index-Bilohojo.d.ts → index-Ae6L8liv.d.ts} +2 -2
- package/dist/{index-BhkPzu-Z.d.cts → index-B1IcU--K.d.cts} +2 -2
- package/dist/{index-DzgS5uYi.d.ts → index-B46GWgk3.d.ts} +1 -1
- package/dist/{index-BpFwRAf9.d.cts → index-B9qJmmv3.d.cts} +1 -1
- package/dist/{index-CI_yjtua.d.ts → index-BCq12BqB.d.ts} +1 -1
- package/dist/{index-zK_mN1D-.d.cts → index-BECJ8M0T.d.cts} +2 -2
- package/dist/{index-DFe2Pk2u.d.ts → index-BOfHwQc1.d.ts} +1 -1
- package/dist/{index-hXKhbfh-.d.ts → index-BhLA9feT.d.ts} +12 -7
- package/dist/{index-Dp69u0ym.d.ts → index-BmLkcDlj.d.ts} +6 -6
- package/dist/{index-XxSeddWP.d.cts → index-BokynmA4.d.cts} +1 -1
- package/dist/{index-BEvsFlfH.d.ts → index-Bpzw8hx3.d.ts} +2 -2
- package/dist/{index-PluovH45.d.cts → index-BwtIbzSV.d.cts} +2 -2
- package/dist/{index-BZ1V5GzX.d.ts → index-C-pFD_FV.d.ts} +2 -2
- package/dist/{index-Cot94_82.d.ts → index-C0tga1_x.d.ts} +2 -2
- package/dist/{index-BlRVj-7Q.d.cts → index-C4N-dg5U.d.cts} +2 -2
- package/dist/{index-B4s70vYf.d.ts → index-CKcnuQ2c.d.ts} +2 -2
- package/dist/{index-D7r_vd0b.d.cts → index-CLPQyYY5.d.cts} +3 -3
- package/dist/{index-BuMzxRO2.d.ts → index-CRycrNfn.d.ts} +1 -1
- package/dist/{index-DeyzuqAi.d.cts → index-CU3z8Cel.d.cts} +2 -2
- package/dist/{index-DwNNufVa.d.ts → index-CUTHDZ7Q.d.ts} +3 -3
- package/dist/{index-CGKs5ixV.d.cts → index-C_qi0WlF.d.cts} +12 -7
- package/dist/{index-BBdwz2BW.d.ts → index-CajEOoAN.d.ts} +2 -2
- package/dist/{index-CzC0G0C3.d.cts → index-Ci358GSC.d.cts} +2 -2
- package/dist/{index-BkbawFkI.d.cts → index-CkN8CZlT.d.cts} +6 -6
- package/dist/{index-ZhKyR8co.d.cts → index-CrpjECS6.d.cts} +2 -2
- package/dist/{index-C40wA8zt.d.ts → index-CzIWlnPp.d.ts} +5 -5
- package/dist/{index-C9xF16gc.d.ts → index-D0ZxFXYl.d.ts} +2 -2
- package/dist/{index-BtY2QVDf.d.cts → index-D11pGlaI.d.cts} +2 -2
- package/dist/{index-DlccEIi3.d.ts → index-D1E1tqHT.d.ts} +1 -1
- package/dist/{index-Qq-G9B6g.d.cts → index-D6pwWiOc.d.cts} +2 -2
- package/dist/{index-BsZlbHM5.d.cts → index-D6tRNEKz.d.cts} +1 -1
- package/dist/{index-B3Dfl5sS.d.cts → index-DAKm44My.d.cts} +2 -2
- package/dist/{index-BWH17rK_.d.cts → index-DCAuN9u5.d.cts} +1 -1
- package/dist/{index-BF-ssbJB.d.ts → index-DPqR3wdW.d.ts} +2 -2
- package/dist/{index-GaW6Welt.d.cts → index-DTYIRT_v.d.cts} +2 -2
- package/dist/{index-DXSLMoma.d.ts → index-DXz9uwcs.d.ts} +1 -1
- package/dist/{index-DmtWMP0X.d.cts → index-D_DThl_J.d.cts} +1 -1
- package/dist/{index-BwYGLgmI.d.ts → index-D_d1erkR.d.ts} +2 -2
- package/dist/{index-D9qoEOj_.d.cts → index-DbWwMWiB.d.cts} +1 -1
- package/dist/{index-D6JRP-1_.d.cts → index-DcWbx58m.d.cts} +2 -2
- package/dist/{index-DzYTXMBz.d.ts → index-DfAo9WKr.d.ts} +1 -1
- package/dist/{index-DXZsXxtU.d.cts → index-DqtXA3yX.d.cts} +2 -2
- package/dist/{index-DBmBtqAN.d.ts → index-DuhOdNyg.d.ts} +2 -2
- package/dist/{index-DKp1CIbG.d.cts → index-e1m3ZHgc.d.cts} +1 -1
- package/dist/{index-DSD6xnbT.d.ts → index-fHKHdAso.d.ts} +2 -2
- package/dist/index.cjs +41 -41
- package/dist/index.d.cts +29 -29
- package/dist/index.d.ts +29 -29
- package/dist/index.js +1 -1
- package/dist/patterns/ai/index.cjs +19 -19
- package/dist/patterns/ai/index.d.cts +7 -7
- package/dist/patterns/ai/index.d.ts +7 -7
- package/dist/patterns/ai/index.js +1 -1
- package/dist/patterns/audit/index.cjs +7 -7
- package/dist/patterns/audit/index.d.cts +4 -4
- package/dist/patterns/audit/index.d.ts +4 -4
- package/dist/patterns/audit/index.js +1 -1
- package/dist/patterns/cqrs/index.cjs +7 -7
- package/dist/patterns/cqrs/index.d.cts +3 -3
- package/dist/patterns/cqrs/index.d.ts +3 -3
- package/dist/patterns/cqrs/index.js +1 -1
- package/dist/patterns/demo-shell/index.cjs +8 -8
- package/dist/patterns/demo-shell/index.d.cts +3 -3
- package/dist/patterns/demo-shell/index.d.ts +3 -3
- package/dist/patterns/demo-shell/index.js +1 -1
- package/dist/patterns/domain-templates/index.cjs +7 -7
- package/dist/patterns/domain-templates/index.d.cts +2 -2
- package/dist/patterns/domain-templates/index.d.ts +2 -2
- package/dist/patterns/domain-templates/index.js +1 -1
- package/dist/patterns/graphspec/index.cjs +17 -17
- package/dist/patterns/graphspec/index.d.cts +2 -2
- package/dist/patterns/graphspec/index.d.ts +2 -2
- package/dist/patterns/graphspec/index.js +1 -1
- package/dist/patterns/guarded-execution/index.cjs +7 -7
- package/dist/patterns/guarded-execution/index.d.cts +5 -5
- package/dist/patterns/guarded-execution/index.d.ts +5 -5
- package/dist/patterns/guarded-execution/index.js +1 -1
- package/dist/patterns/harness/index.cjs +10 -10
- package/dist/patterns/harness/index.d.cts +7 -7
- package/dist/patterns/harness/index.d.ts +7 -7
- package/dist/patterns/harness/index.js +1 -1
- package/dist/patterns/job-queue/index.cjs +7 -7
- package/dist/patterns/job-queue/index.d.cts +3 -3
- package/dist/patterns/job-queue/index.d.ts +3 -3
- package/dist/patterns/job-queue/index.js +1 -1
- package/dist/patterns/lens/index.cjs +7 -7
- package/dist/patterns/lens/index.d.cts +3 -3
- package/dist/patterns/lens/index.d.ts +3 -3
- package/dist/patterns/lens/index.js +1 -1
- package/dist/patterns/memory/index.cjs +7 -7
- package/dist/patterns/memory/index.d.cts +2 -2
- package/dist/patterns/memory/index.d.ts +2 -2
- package/dist/patterns/memory/index.js +1 -1
- package/dist/patterns/messaging/index.cjs +7 -7
- package/dist/patterns/messaging/index.d.cts +3 -3
- package/dist/patterns/messaging/index.d.ts +3 -3
- package/dist/patterns/messaging/index.js +1 -1
- package/dist/patterns/orchestration/index.cjs +7 -7
- package/dist/patterns/orchestration/index.d.cts +3 -3
- package/dist/patterns/orchestration/index.d.ts +3 -3
- package/dist/patterns/orchestration/index.js +1 -1
- package/dist/patterns/process/index.cjs +1 -1
- package/dist/patterns/process/index.d.cts +4 -4
- package/dist/patterns/process/index.d.ts +4 -4
- package/dist/patterns/process/index.js +1 -1
- package/dist/patterns/reactive-layout/index.cjs +8 -8
- package/dist/patterns/reactive-layout/index.d.cts +3 -3
- package/dist/patterns/reactive-layout/index.d.ts +3 -3
- package/dist/patterns/reactive-layout/index.js +1 -1
- package/dist/patterns/reduction/index.cjs +7 -7
- package/dist/patterns/reduction/index.d.cts +2 -2
- package/dist/patterns/reduction/index.d.ts +2 -2
- package/dist/patterns/reduction/index.js +1 -1
- package/dist/patterns/refine-loop/index.cjs +8 -8
- package/dist/patterns/refine-loop/index.d.cts +4 -4
- package/dist/patterns/refine-loop/index.d.ts +4 -4
- package/dist/patterns/refine-loop/index.js +1 -1
- package/dist/patterns/resilient-pipeline/index.d.cts +3 -3
- package/dist/patterns/resilient-pipeline/index.d.ts +3 -3
- package/dist/patterns/resilient-pipeline/index.js +1 -1
- package/dist/patterns/surface/index.cjs +10 -10
- package/dist/patterns/surface/index.d.cts +3 -3
- package/dist/patterns/surface/index.d.ts +3 -3
- package/dist/patterns/surface/index.js +1 -1
- package/dist/{pipeline-graph-B85HUrWg.d.cts → pipeline-graph-BrrYGjuZ.d.cts} +2 -2
- package/dist/{pipeline-graph-HOTU4UG0.d.ts → pipeline-graph-DX2Twdj-.d.ts} +2 -2
- package/dist/{reactive-layout-Btv0-efV.d.ts → reactive-layout-BDdngW56.d.ts} +1 -1
- package/dist/{reactive-layout-D9zqqaqK.d.cts → reactive-layout-DrGjuwyC.d.cts} +1 -1
- package/dist/{reactive-log-CgbNqksB.d.cts → reactive-log-ScpWyqny.d.cts} +11 -3
- package/dist/{reactive-log-ByBb8g6A.d.ts → reactive-log-jirQsxMY.d.ts} +11 -3
- package/dist/{topology-tree-CJsT24DP.d.ts → topology-tree-BI665P0L.d.ts} +1 -1
- package/dist/{topology-tree-C50l9ARE.d.cts → topology-tree-BkhmMg2a.d.cts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-5KPIYVCC.js +0 -7
- package/dist/chunk-CUQFO6MT.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";var Qe=Object.defineProperty;var Mn=Object.getOwnPropertyDescriptor;var An=Object.getOwnPropertyNames;var Dn=Object.prototype.hasOwnProperty;var U=(t,e)=>()=>(t&&(e=t(t=0)),e);var Gn=(t,e)=>{for(var n in e)Qe(t,n,{get:e[n],enumerable:!0})},Ln=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of An(e))!Dn.call(t,s)&&s!==n&&Qe(t,s,{get:()=>e[s],enumerable:!(r=Mn(e,s))||r.enumerable});return t};var In=t=>Ln(Qe({},"__esModule",{value:!0}),t);function F(){return Math.trunc(performance.now()*1e6)}function Me(){return Date.now()*1e6}var pe=U(()=>{"use strict"});function At(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let s=2+n.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=ut,o[i++]=n.length,o.set(n,i),i+=n.length,o[i++]=r>>>8&255,o[i++]=r&255,o.set(e,i),o}function Dt(t,e){if(t.length<Mt)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${Mt})`);let n=0,r=t[n++];if(r!==ut)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${ut})`);let s=t[n++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+s+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+s+2} bytes, have ${t.length})`);let o=new TextDecoder().decode(t.subarray(n,n+s));n+=s;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),l=e.lookupCodec(o);if(l==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:l,codecVersion:i,payload:a}}function Gt(t){t.registerCodec(Pn)}var Pn,ut,Mt,lt=U(()=>{"use strict";Pn={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}},ut=1,Mt=4});function Ae(t){if(t==null)return ge;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var ge,ct=U(()=>{"use strict";ge={type:"system",id:""}});function De(){return me>0||ke}function Lt(){return me>0}function Se(t){me>0?Te.push(t):t()}function It(t){me+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(me-=1,me===0)if(e){if(!ke){let n=Te.splice(0);for(let r of n)try{r()}catch{}de.length=0,fe.length=0,be.length=0}}else $n()}}function $n(){let t=!ke;t&&(ke=!0);let e=[],n=0;try{for(;de.length>0||fe.length>0||be.length>0||t&&Te.length>0;){if(t&&Te.length>0){let o=Te.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw de.length=0,fe.length=0,be.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(de.length>0?de:fe.length>0?fe:be).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{t&&(ke=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function ye(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!De()){t(e);return}(u>=5?be:u===4?fe:de).push(()=>t(e));return}let r=e.length,s=r,o=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(s=a;a<r&&n(e[a][0])===3;)a++;for(o=a;a<r&&n(e[a][0])===4;)a++;i=a;let l=De();if(s>0){let u=e.slice(0,s);t(u)}if(o>s){let u=e.slice(s,o);l?de.push(()=>t(u)):t(u)}if(i>o){let u=e.slice(o,i);l?fe.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);l?be.push(()=>t(u)):t(u)}}var me,ke,de,fe,be,Te,Ge=U(()=>{"use strict";me=0,ke=!1,de=[],fe=[],be=[],Te=[]});var Oe,B,J,te,X,ne,ie,j,Z,$,ve,dt,Bn,ft,Fn,Hn,ht,Pt,$t,Bt,pt,Ne=U(()=>{"use strict";Oe=Symbol.for("graphrefly/START"),B=Symbol.for("graphrefly/DATA"),J=Symbol.for("graphrefly/DIRTY"),te=Symbol.for("graphrefly/RESOLVED"),X=Symbol.for("graphrefly/INVALIDATE"),ne=Symbol.for("graphrefly/PAUSE"),ie=Symbol.for("graphrefly/RESUME"),j=Symbol.for("graphrefly/TEARDOWN"),Z=Symbol.for("graphrefly/COMPLETE"),$=Symbol.for("graphrefly/ERROR"),ve=Object.freeze([J]),dt=Object.freeze([te]),Bn=Object.freeze([X]),ft=Object.freeze([Oe]),Fn=Object.freeze([Z]),Hn=Object.freeze([j]),ht=Object.freeze([ve]),Pt=Object.freeze([dt]),$t=Object.freeze([Bn]),Bt=Object.freeze([Fn]),pt=Object.freeze([Hn])});function Ft(t){t.registerMessageType(Oe,{tier:0,wireCrossing:!1}),t.registerMessageType(J,{tier:1,wireCrossing:!1}),t.registerMessageType(X,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(ne,{tier:2,wireCrossing:!1}),t.registerMessageType(ie,{tier:2,wireCrossing:!1}),t.registerMessageType(B,{tier:3,wireCrossing:!0}),t.registerMessageType(te,{tier:3,wireCrossing:!0}),t.registerMessageType(Z,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType($,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(j,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Le,Ht=U(()=>{"use strict";Ne();Le=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function gt(t){let e=jn.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var K,jn,Ie=U(()=>{"use strict";K=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}},jn=["human","llm","wallet","system"]});function mt(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(mt);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=mt(t[n]);return e}return null}function zn(t){let e=Wn.encode(t),n=e.length,r=n*8,s=n+9+63&-64,o=new Uint8Array(s);o.set(e),o[n]=128;let i=new DataView(o.buffer);i.setUint32(s-4,r>>>0,!1),i.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,l=3144134277,u=1013904242,c=2773480762,f=1359893119,p=2600822924,h=528734635,d=1541459225,g=new Uint32Array(64),b=(v,y)=>v>>>y|v<<32-y;for(let v=0;v<s;v+=64){for(let O=0;O<16;O++)g[O]=i.getUint32(v+O*4,!1);for(let O=16;O<64;O++){let E=g[O-15],R=g[O-2],L=b(E,7)^b(E,18)^E>>>3,V=b(R,17)^b(R,19)^R>>>10;g[O]=g[O-16]+L+g[O-7]+V>>>0}let y=a,_=l,m=u,w=c,k=f,T=p,S=h,C=d;for(let O=0;O<64;O++){let E=b(k,6)^b(k,11)^b(k,25),R=k&T^~k&S,L=C+E+R+Vn[O]+g[O]>>>0,V=b(y,2)^b(y,13)^b(y,22),Y=y&_^y&m^_&m,ce=V+Y>>>0;C=S,S=T,T=k,k=w+L>>>0,w=m,m=_,_=y,y=L+ce>>>0}a=a+y>>>0,l=l+_>>>0,u=u+m>>>0,c=c+w>>>0,f=f+k>>>0,p=p+T>>>0,h=h+S>>>0,d=d+C>>>0}let x=v=>v.toString(16).padStart(8,"0");return x(a)+x(l)+x(u)+x(c)+x(f)+x(p)+x(h)+x(d)}function bt(t){let e=mt(t??null),n=JSON.stringify(e);return zn(n).slice(0,16)}function Un(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function yt(t,e,n){let r=n?.id??Un();if(t===0)return{id:r,version:0};let o=(n?.hash??bt)(e);return{id:r,version:0,cid:o,prev:null}}function jt(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Vn,Wn,Vt=U(()=>{"use strict";Vn=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Wn=new TextEncoder});function Ut(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function vt(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Pe(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function re(t,e,n){let r=Kt(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,o={};return Kt(t)?o=(xt(e)?e:n)??{}:xt(t)?o=t:o=(xt(e)?e:n)??{},new I(r,s,o)}var Wt,zt,Kn,qn,ae,I,Kt,xt,se=U(()=>{"use strict";lt();ct();Ge();pe();Ht();Ie();Ne();Vt();Wt=()=>{},zt=100;Kn=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},qn=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[ft]:[ft,[B,o]];s._status==="dirty"&&i.push(ve),ye(e,i,s._config.tierOf)},ae=new Le({onMessage:Kn,onSubscribe:qn});Ft(ae);Gt(ae);I=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??ae,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??bt;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?yt(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ut);let o={};for(let[a,l]of Object.entries(r.meta??{})){let u={initial:l,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),o[a]=new t([],void 0,u)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[B,a]])},down(a){i._emit(Pe(a))},up(a){i._emitUp(Pe(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let s=n?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,l=i?.version??0,u=yt(e,o,{id:a,hash:s});u.version=l,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=Ae(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let s=Ae(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new K({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new K({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Me()}}down(e,n){let r=Pe(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[B,e]])}up(e,n){if(this._deps.length===0)return;let r=Pe(e);if(r.length===0)return;this._checkGuard(n);let s=n??{internal:!0};this._validateUpTiers(r);for(let o of this._deps)o.node.up?.(r,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let s=n(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let l=Ae(n);if(!this._guard(l,"observe"))throw new K({actor:l,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let l of this._deps)vt(l);if(this._partial===!1){for(let l of this._deps)if(l.prevData!==void 0||l.dataBatch.length!==0||l.terminal!==void 0||l.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(l){throw this._sinkCount-=1,l}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(l){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw l}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let s=r,o=this._deps[r];o.unsub=Wt,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,l=!1;for(let u of i)a(u[0])>=3&&(l=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:s},this._actions);l&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let s=0;s<n;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}vt(o)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let n=this._deps.length,r=Ut(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ht),r.unsub=Wt;try{r.unsub=e.subscribe(s=>{if(r.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[$,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[$,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let r of this._deps){if(r.unsub!=null){let s=r.unsub;r.unsub=null;try{s()}catch{}}vt(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],s=n[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(o)}if(s!==Oe){if(s===J){this._depDirtied(r);return}if(s===X){if(this._depInvalidated(r),this._cached===void 0)return;this._emit($t);return}if(s===ne||s===ie){this._emit([n]);return}if(s===j){this._emit(pt);return}if(s===B)this._depSettledAsData(r,n[1]);else if(s===te)this._depSettledAsResolved(r);else if(s===Z)this._depSettledAsTerminal(r,!0);else if(s===$)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===B||s===te)&&this._emit([n]),(s===Z||s===$)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ht))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Pt),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[$,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(Bt)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[$,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[$,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[$,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>zt?(this._rerunDepth=0,this._emit([[$,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${zt} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[ve,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let l of e){let u=n(l[0]);u<i&&(r=!1),u===3&&(s=!0),l[0]===J&&(o=!0),i=u}let a=e;if(!r){let l=e.map((u,c)=>({m:u,i:c,tier:n(u[0])}));l.sort((u,c)=>u.tier-c.tier||u.i-c.i),a=l.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let l=0;for(;l<a.length&&n(a[l][0])===0;)l++;return l===0?[ve,...a]:[...a.slice(0,l),ve,...a.slice(l)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let l=e[a];if(l[0]===$&&l[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(l=>l[0]===j||l[0]===X);if(a.length===0)return;n=a}n=this._frameBatch(n);let s=null;for(let a=0;a<n.length;a++){let l=n[a],u=l[0];if(u!==ne&&u!==ie){s?.push(l);continue}if(l.length<2)throw new Error(`Node "${this.name}": [[${u===ne?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let f=l[1];if(u===ne)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))c=!1;else if(this._pauseLocks.delete(f),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?s?.push(l):s==null&&(s=n.slice(0,a))}if(s!=null){if(s.length===0)return;n=s}if(this._hasMeta&&n.some(a=>a[0]===j))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(pt)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(n);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,l=[];for(let u of o)a(u[0])===3?this._pauseBuffer.push(u):l.push(u);l.length>0&&this._dispatchOrAccumulate(l)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[$,i]])}_updateState(e){let n=this._config.tierOf,r,s,o=-1,i=0;for(let c of e)n(c[0])===3&&i++;let a=i<=1,l=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===B){l=c;break}}for(let c=0;c<e.length;c++){let f=e[c],p=f[0];if(p===B){if(f.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,f[1])}catch(d){s=this._wrapFnError("equals threw",d),o=c;break}if(h){r==null&&(r=e.slice(0,c)),r.push(dt),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(l<0||c===l)&&jt(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),p===J)this._status="dirty";else if(p===te)this._status="resolved";else if(p===Z){this._status="completed";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===$){this._status="errored";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===X){if(this._cached!==void 0){let d=this._config.rigorRecorder;if(d!=null)try{d.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let d=h.invalidate;if(typeof d=="function")try{d()}catch{}}}else p===j&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:u,equalsError:s}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(Lt()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Se(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}ye(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);ye(this._deliverToSinks,n,this._config.tierOf)}},Kt=t=>Array.isArray(t),xt=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function G(t,e){return re([],{...e,initial:t})}function qt(t,e){return re((r,s,o)=>t(s,o)??void 0,{describeKind:"producer",...e})}function q(t,e,n){return re(t,(s,o,i)=>{let a=s.map((l,u)=>l!=null&&l.length>0?l.at(-1):i.prevData[u]);o.emit(e(a,i))},{describeKind:"derived",...n})}var Ee=U(()=>{"use strict";se()});function _t(t){return t.subscribe(()=>{})}var Yt=U(()=>{"use strict"});var Be,Jt=U(()=>{"use strict";Be=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var ts={};Gn(ts,{CanvasMeasureAdapter:()=>st,CliMeasureAdapter:()=>tt,ImageSizeAdapter:()=>at,NodeCanvasMeasureAdapter:()=>ot,PrecomputedAdapter:()=>rt,SvgBoundsAdapter:()=>it,analyzeAndMeasure:()=>we,carveTextLineSlots:()=>Et,circleIntervalForBand:()=>En,computeBlockFlow:()=>On,computeCharPositions:()=>qe,computeFlowLines:()=>Rn,computeLineBreaks:()=>Ke,computeTotalHeight:()=>Nn,layoutNextLine:()=>Nt,measureBlock:()=>Tn,measureBlocks:()=>Sn,reactiveBlockLayout:()=>Zr,reactiveFlowLayout:()=>es,reactiveLayout:()=>Xr,rectIntervalForBand:()=>Cn});module.exports=In(ts);function et(t){return t>=768&&t<=879||t>=1155&&t<=1161||t>=1425&&t<=1469||t>=1552&&t<=1562||t>=1611&&t<=1631||t>=1648&&t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t>=1767&&t<=1768||t>=1770&&t<=1773||t>=1840&&t<=1866||t>=1958&&t<=1968||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2641||t>=2672&&t<=2673||t>=2677&&t===2677||t>=3633&&t===3633||t>=3636&&t<=3642||t>=3655&&t<=3662||t>=3761&&t===3761||t>=3764&&t<=3772||t>=3784&&t<=3790||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65024&&t<=65039||t>=65056&&t<=65071||t===8205?0:t>=4352&&t<=4447||t>=8986&&t<=8987||t>=9001&&t<=9002||t>=9193&&t<=9203||t>=9208&&t<=9210||t>=9725&&t<=9726||t>=9748&&t<=9749||t>=9800&&t<=9811||t===9855||t===9875||t===9889||t>=9898&&t<=9899||t>=9917&&t<=9918||t>=9924&&t<=9925||t===9934||t===9940||t===9962||t>=9970&&t<=9971||t===9973||t===9978||t===9981||t===9986||t===9989||t>=9992&&t<=9997||t===9999||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t>=10548&&t<=10549||t>=11013&&t<=11015||t>=11035&&t<=11036||t===11088||t===11093||t>=11904&&t<=12350||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12784&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=19968&&t<=40959||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65131||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126980&&t===126980||t===127183||t>=127344&&t<=127345||t===127358||t===127359||t===127374||t>=127377&&t<=127386||t>=127456&&t<=127487||t>=127488&&t<=127490||t===127514||t===127535||t>=127538&&t<=127546||t>=127568&&t<=127569||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=129792&&t<=130047||t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}function he(t){let e=0;for(let n of t)e+=et(n.codePointAt(0));return e}function Rt(t,e){if(e<=0)return"";let n=0,r="";for(let s of t){let o=et(s.codePointAt(0));if(n+o>e){if(e<=1)return"\u2026";for(;n+1>e&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=et(i.codePointAt(0))}return`${r}\u2026`}r+=s,n+=o}return r}var tt=class{cellPx;constructor(e){this.cellPx=e?.cellPx??8}measureSegment(e,n){return{width:he(e)*this.cellPx}}},nt=class extends Error{name="KeyError"},rt=class{metrics;fallback;constructor(e){this.metrics=e.metrics;let n=e.fallback??"per-char";if(n!=="per-char"&&n!=="error")throw new Error(`fallback must be 'per-char' or 'error', got ${JSON.stringify(e.fallback)}`);this.fallback=n}measureSegment(e,n){let r=this.metrics[n];if(r){let o=r[e];if(o!==void 0)return{width:o}}if(this.fallback==="error")throw new nt(`PrecomputedAdapter: no metrics for segment ${JSON.stringify(e)} in font ${JSON.stringify(n)}`);let s=0;if(r)for(let o of e){let i=r[o];i!==void 0&&(s+=i)}return{width:s}}},st=class{ctx=null;currentFont="";emojiCorrection;constructor(e){this.emojiCorrection=e?.emojiCorrection??1}getContext(){if(!this.ctx){if(typeof OffscreenCanvas>"u")throw new Error("CanvasMeasureAdapter requires a browser environment with OffscreenCanvas support. Use CliMeasureAdapter or NodeCanvasMeasureAdapter for Node.js.");let n=new OffscreenCanvas(0,0).getContext("2d");if(!n)throw new Error("CanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(e,n){let r=this.getContext();n!==this.currentFont&&(r.font=n,this.currentFont=n);let s=r.measureText(e).width;return this.emojiCorrection!==1&&new RegExp("\\p{Emoji_Presentation}","u").test(e)&&(s*=this.emojiCorrection),{width:s}}clearCache(){this.currentFont=""}},ot=class{ctx=null;currentFont="";canvasModule;constructor(e){this.canvasModule=e}getContext(){if(!this.ctx){let n=this.canvasModule.createCanvas(0,0).getContext("2d");if(!n)throw new Error("NodeCanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(e,n){let r=this.getContext();return n!==this.currentFont&&(r.font=n,this.currentFont=n),{width:r.measureText(e).width}}clearCache(){this.currentFont=""}},it=class{measureSvg(e){let n=e.match(/viewBox\s*=\s*["']([^"']+)["']/);if(n){let o=n[1].trim().split(/[\s,]+/);if(o.length>=4){let i=Number.parseFloat(o[2]),a=Number.parseFloat(o[3]);if(Number.isFinite(i)&&Number.isFinite(a)&&i>0&&a>0)return{width:i,height:a};throw new Error("SvgBoundsAdapter: viewBox width/height are missing, non-finite, or not positive")}}let r=e.match(/<svg[^>]*\bwidth\s*=\s*["']?([\d.]+)/),s=e.match(/<svg[^>]*\bheight\s*=\s*["']?([\d.]+)/);if(r&&s){let o=Number.parseFloat(r[1]),i=Number.parseFloat(s[1]);if(Number.isFinite(o)&&Number.isFinite(i)&&o>0&&i>0)return{width:o,height:i};throw new Error("SvgBoundsAdapter: svg width/height attributes are non-finite or not positive")}throw new Error("SvgBoundsAdapter: cannot determine dimensions \u2014 SVG has no viewBox or width/height attributes")}},at=class{sizes;constructor(e){this.sizes=new Map(Object.entries(e))}measureImage(e){let n=this.sizes.get(e);if(!n)throw new Error(`ImageSizeAdapter: no dimensions registered for ${JSON.stringify(e)}`);return{width:n.width,height:n.height}}};pe();se();Ee();ct();Ge();pe();Ie();Ne();Ie();se();function $e(t,e){if(e!=null&&e.length>0)return new Set(e);switch(t){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;default:return new Set(["type","deps"])}}function Yn(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function Jn(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function wt(t,e){let n=e==null,r=!n&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,s=n||e.has("meta")||r!=null&&r.length>0,o="state",i=[];t instanceof I&&(o=Yn(t),i=t._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(n||e.has("status"))&&(a.status=t.status);let l=t instanceof I?t._guard:void 0;if(s){let u={...Jn(t)};if(l!=null&&u.access===void 0&&(u.access=gt(l)),r!=null&&r.length>0&&!e.has("meta")){let c={};for(let f of r)f in u&&(c[f]=u[f]);a.meta=c}else a.meta=u}if(t.name!=null&&(a.name=t.name),n||e.has("value")){t.status==="sentinel"&&(a.sentinel=!0);try{a.value=t.cache}catch{}}if((n||e.has("v"))&&t.v!=null){let u={id:t.v.id,version:t.v.version};"cid"in t.v&&(u.cid=t.v.cid,u.prev=t.v.prev),a.v=u}return(n||e.has("guard"))&&l!=null&&(a.guard=gt(l)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}se();Ee();Yt();Jt();var Ce=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let n=(this.head+this._size)%this.capacity;this.buf[n]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let n=e<0?this._size+e:e;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this.buf[(this.head+n)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};lt();var Xn={horizontal:"\u2500",vertical:"\u2502",cornerTL:"\u250C",cornerTR:"\u2510",cornerBL:"\u2514",cornerBR:"\u2518",tDown:"\u252C",tUp:"\u2534",tRight:"\u251C",tLeft:"\u2524",cross:"\u253C",arrowRight:"\u25B6",arrowDown:"\u25BC",arrowLeft:"\u25C0",arrowUp:"\u25B2",boxTL:"\u250C",boxTR:"\u2510",boxBL:"\u2514",boxBR:"\u2518",boxH:"\u2500",boxV:"\u2502"},Zn={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function en(t,e){let n=e.charset==="ascii"?Zn:Xn,r=t.width,s=t.height,o=Array.from({length:s},()=>Array.from({length:r},()=>" ")),i=Array.from({length:s},()=>Array.from({length:r},()=>"empty"));for(let a of t.edges)er(o,i,n,a);for(let a of t.boxes)Qn(o,i,n,a,e.labelOf(a.id));return o.map(a=>sr(a.join(""))).join(`
|
|
2
|
-
`)}function Qn(t,e,n,r,s){let{x:o,y:i,w:a,h:l}=r;if(a<2||l<2){l>0&&Xt(t,e,o,i,a,s);return}ue(t,e,o,i,n.boxTL);for(let c=o+1;c<o+a-1;c+=1)ue(t,e,c,i,n.boxH);ue(t,e,o+a-1,i,n.boxTR);for(let c=i+1;c<i+l-1;c+=1){ue(t,e,o,c,n.boxV);for(let f=o+1;f<o+a-1;f+=1)tn(t,e,f,c," ","empty");ue(t,e,o+a-1,c,n.boxV)}ue(t,e,o,i+l-1,n.boxBL);for(let c=o+1;c<o+a-1;c+=1)ue(t,e,c,i+l-1,n.boxH);ue(t,e,o+a-1,i+l-1,n.boxBR);let u=i+Math.floor(l/2);Xt(t,e,o+1,u,a-2,s)}function ue(t,e,n,r,s){tn(t,e,n,r,s,s===" "?"empty":s==="\u2500"||s==="-"?"boxH":s==="\u2502"||s==="|"?"boxV":"boxCorner")}function tn(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];n<0||n>=i.length||(i[n]=s,e[r][n]=o)}function Xt(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=n,a=s;for(let l of o){let u=he(l);if(u!==0){if(a<u)break;i>=0&&i<t[r].length&&(t[r][i]=l,e[r][i]="label",u===2&&i+1<t[r].length&&(t[r][i+1]="",e[r][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<t[r].length&&(t[r][i]=" ",e[r][i]="empty"),i+=1,a-=1}function er(t,e,n,r){let s=r.points;if(s.length<2)return;for(let l=0;l+1<s.length;l+=1)tr(t,e,n,s[l],s[l+1]);for(let l=1;l+1<s.length;l+=1){let u=s[l-1],c=s[l],f=s[l+1],p=nr(u,c,f,n);p&&Qt(t,e,c.x,c.y,p,"edgeCorner")}let o=s[s.length-1],i=s[s.length-2],a=rr(i,o,n);a&&Qt(t,e,o.x,o.y,a,"arrow")}function tr(t,e,n,r,s){if(!(r.x===s.x&&r.y===s.y)){if(r.y===s.y){let o=r.y,i=Math.min(r.x,s.x),a=Math.max(r.x,s.x);for(let l=i;l<=a;l+=1)Zt(t,e,l,o,n,"h")}else if(r.x===s.x){let o=r.x,i=Math.min(r.y,s.y),a=Math.max(r.y,s.y);for(let l=i;l<=a;l+=1)Zt(t,e,o,l,n,"v")}}}function Zt(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[n]=o==="h"?s.horizontal:s.vertical,e[r][n]=o==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&o==="v"){i[n]=s.cross,e[r][n]="edgeCorner";return}if(a==="edgeV"&&o==="h"){i[n]=s.cross,e[r][n]="edgeCorner";return}}}function Qt(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[n]=s,e[r][n]=o)}function nr(t,e,n,r){let s=t.y===e.y,o=e.y===n.y;if(s===o)return;if(s){let l=t.x<e.x,u=n.y>e.y;return l&&u?r.cornerTR:l&&!u?r.cornerBR:!l&&u?r.cornerTL:r.cornerBL}let i=t.y<e.y,a=n.x>e.x;return i&&a?r.cornerBL:i&&!a?r.cornerBR:!i&&a?r.cornerTL:r.cornerTR}function rr(t,e,n){if(e.x>t.x)return n.arrowRight;if(e.x<t.x)return n.arrowLeft;if(e.y>t.y)return n.arrowDown;if(e.y<t.y)return n.arrowUp}function sr(t){let e=t.length;for(;e>0&&t.charCodeAt(e-1)===32;)e-=1;return t.slice(0,e)}function sn(t){let e=or(t);ir(e),ar(e),ur(e),lr(e,t);let n=fr(e,t),{width:r,height:s}=pr(e),o=[];for(let i of e.layers)for(let a of i)a.isVirtual||o.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:o,edges:n,width:r,height:s}}function or(t){let e=new Map;for(let s of t.nodes)e.set(s,{id:s,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:t.widthCells(s),h:t.heightCells(s),in:[],out:[]});let n=[],r=0;for(let s of t.edges){if(s.from===s.to)continue;let o=e.get(s.from),i=e.get(s.to);if(!o||!i)continue;let a={chainId:r++,chainFrom:s.from,chainTo:s.to,fromId:s.from,toId:s.to,hopIndex:0,chainLen:1};o.out.push(a),i.in.push(a),n.push(a)}return{nodes:e,layers:[],hops:n}}function ir(t){let e=new Map;for(let o of t.nodes.values())e.set(o.id,o.in.length);let n=[];for(let o of t.nodes.values())(e.get(o.id)??0)===0&&(o.layer=0,n.push(o));let r=new Set,s=0;for(;s<n.length;){let o=n[s++];if(!r.has(o.id)){r.add(o.id);for(let i of o.out){let a=t.nodes.get(i.toId);a.layer=Math.max(a.layer,o.layer+1);let l=(e.get(a.id)??0)-1;e.set(a.id,l),l<=0&&n.push(a)}}}for(let o of t.nodes.values())o.layer<0&&(o.layer=0)}function ar(t){let e=Math.max(0,...Array.from(t.nodes.values(),o=>o.layer)),n=Array.from({length:e+1},()=>[]);for(let o of t.nodes.values())n[o.layer].push(o);let r=[],s=0;for(let o of t.hops){let i=t.nodes.get(o.fromId),a=t.nodes.get(o.toId),l=a.layer-i.layer;if(l<=0){i.out=i.out.filter(f=>f!==o),a.in=a.in.filter(f=>f!==o);continue}if(l===1){o.hopIndex=0,o.chainLen=1,r.push(o);continue}i.out=i.out.filter(f=>f!==o),a.in=a.in.filter(f=>f!==o);let u=i;for(let f=1;f<l;f+=1){let p=`__virt_${s++}__`,h={id:p,isVirtual:!0,layer:i.layer+f,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};t.nodes.set(p,h),n[h.layer].push(h);let d={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:p,hopIndex:f-1,chainLen:l};u.out.push(d),h.in.push(d),r.push(d),u=h}let c={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:a.id,hopIndex:l-1,chainLen:l};u.out.push(c),a.in.push(c),r.push(c)}for(let o of n)for(let i=0;i<o.length;i+=1)o[i].order=i;t.layers=n,t.hops=r}function ur(t){for(let n=0;n<4;n+=1){for(let r=1;r<t.layers.length;r+=1)nn(t,t.layers[r],"in"),Fe(t.layers[r]);for(let r=t.layers.length-2;r>=0;r-=1)nn(t,t.layers[r],"out"),Fe(t.layers[r])}for(let n=0;n<2;n+=1){let r=!1;for(let s=1;s<t.layers.length;s+=1){let o=t.layers[s];for(let i=0;i+1<o.length;i+=1){let a=rn(t,o[i],o[i+1],"in");[o[i],o[i+1]]=[o[i+1],o[i]],Fe(o),rn(t,o[i],o[i+1],"in")<a?r=!0:([o[i],o[i+1]]=[o[i+1],o[i]],Fe(o))}}if(!r)break}}function nn(t,e,n){let r=new Map;for(let s of e){let o=n==="in"?s.in:s.out;if(o.length===0){r.set(s.id,s.order);continue}let i=0,a=0;for(let l of o){let u=t.nodes.get(n==="in"?l.fromId:l.toId);u&&(i+=u.order,a+=1)}r.set(s.id,a===0?s.order:i/a)}e.sort((s,o)=>{let i=r.get(s.id),a=r.get(o.id);return i!==a?i-a:s.order-o.order})}function Fe(t){for(let e=0;e<t.length;e+=1)t[e].order=e}function rn(t,e,n,r){let s=r==="in"?e.in:e.out,o=r==="in"?n.in:n.out,i=0;for(let a of s)for(let l of o){let u=t.nodes.get(r==="in"?a.fromId:a.toId)?.order??0,c=t.nodes.get(r==="in"?l.fromId:l.toId)?.order??0;(e.order<n.order&&u>c||e.order>n.order&&u<c)&&(i+=1)}return i}function lr(t,e){e.direction==="LR"?cr(t,e):dr(t,e)}function cr(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.w);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.x=n[s];for(let s of t.layers){let o=0;for(let i of s)i.y=o,o+=i.h+e.nodeGap}on(t,e,"y")}function dr(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.h);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.y=n[s];for(let s of t.layers){let o=0;for(let i of s)i.x=o,o+=i.w+e.nodeGap}on(t,e,"x")}function on(t,e,n){let r=o=>n==="y"?o.h:o.w,s=e.nodeGap;for(let o=0;o<2;o+=1){let i=o===0?t.layers.slice(1):t.layers.slice(0,-1).reverse();for(let a of i){let l=new Map;for(let c of a){let f=o===0?c.in:c.out;if(f.length===0)continue;let p=[];for(let d of f){let g=t.nodes.get(o===0?d.fromId:d.toId);if(!g)continue;let b=n==="y"?g.y:g.x;p.push(b+Math.floor(r(g)/2))}if(p.length===0)continue;p.sort((d,g)=>d-g);let h=p[Math.floor(p.length/2)];l.set(c.id,h-Math.floor(r(c)/2))}let u=0;for(let c of a){let f=l.get(c.id),p=n==="y"?c.y:c.x,d=Math.max(f??p,u);n==="y"?c.y=d:c.x=d,u=d+r(c)+s}}}}function fr(t,e){let n=new Map;for(let u of t.hops){let c=n.get(u.chainId);c?c.push(u):n.set(u.chainId,[u])}for(let u of n.values())u.sort((c,f)=>c.hopIndex-f.hopIndex);let r=e.direction==="LR",s=u=>r?u.x:u.y,o=u=>r?u.w:u.h,i=u=>r?u.y+Math.floor(u.h/2):u.x+Math.floor(u.w/2),a=new Map;for(let u=0;u+1<t.layers.length;u+=1){let c=t.layers[u],f=t.layers[u+1],p=0;for(let T of c)p=Math.max(p,s(T)+o(T));let h=Number.POSITIVE_INFINITY;for(let T of f)h=Math.min(h,s(T));let d=Number.isFinite(h)?h-1:p,g=Math.max(1,d-p+1),b=[];for(let T of c)for(let S of T.out)b.push(S);b.sort((T,S)=>{let C=i(t.nodes.get(T.fromId)),O=i(t.nodes.get(S.fromId));if(C!==O)return C-O;let E=i(t.nodes.get(T.toId)),R=i(t.nodes.get(S.toId));return E-R});let x=[],v=new Map;for(let T of b){let S=i(t.nodes.get(T.fromId)),C=i(t.nodes.get(T.toId)),O=Math.min(S,C),E=Math.max(S,C),R=-1;for(let L=0;L<x.length;L+=1){let V=x[L],Y=!0;for(let ce of V)if(ce.lo<=E&&O<=ce.hi){Y=!1;break}if(Y){V.push({lo:O,hi:E}),R=L;break}}R<0&&(x.push([{lo:O,hi:E}]),R=x.length-1),v.set(T,R)}let y=x.length,_=g>=Math.max(3,y+2),m=_?p+1:p,w=_?d-1:d,k=Math.max(1,w-m+1);for(let T of b){let S=v.get(T),C;if(y<=1)C=m+Math.floor(k/2);else{let O=(k-1)/(y-1);C=m+Math.floor(S*O)}a.set(T,Math.max(p,Math.min(d,C)))}}let l=[];for(let[,u]of n){let c=[];for(let p=0;p<u.length;p+=1){let h=u[p],d=t.nodes.get(h.fromId),g=t.nodes.get(h.toId),b=a.get(h),x=d.isVirtual?s(d):s(d)+o(d),v=g.isVirtual?s(g):s(g)-1,y=i(d),_=i(g);p===0&&He(c,r,x,y),y!==_&&(He(c,r,b,y),He(c,r,b,_)),He(c,r,v,_)}let f=u[0];l.push({from:f.chainFrom,to:f.chainTo,points:hr(c)})}return l}function He(t,e,n,r){t.push(e?{x:n,y:r}:{x:r,y:n})}function hr(t){let e=[];for(let n of t){let r=e[e.length-1];(!r||r.x!==n.x||r.y!==n.y)&&e.push(n)}return e}function pr(t){let e=0,n=0;for(let r of t.layers)for(let s of r)e=Math.max(e,s.x+s.w),n=Math.max(n,s.y+s.h);return{width:e,height:n}}var gr=24,mr=4,br=1,yr=3;function an(t,e){let n=vr(e.direction),r=Math.max(3,e.maxLabelWidth??gr),s=e.asciiCharset??"unicode",o=Object.keys(t.nodes).sort(),i=new Set(o),a=t.edges.filter(h=>i.has(h.from)&&i.has(h.to)),l=new Map,u=new Map;for(let h of o){let d=Rt(h,r);l.set(h,d),u.set(h,he(d)+4)}let c=sn({nodes:o,edges:a,widthCells:h=>u.get(h)??3,heightCells:()=>yr,layerGap:mr,nodeGap:br,direction:n}),f=en(c,{charset:s,labelOf:h=>l.get(h)??h}),p=e.logger;return p&&p(f),f}function vr(t){if(t===void 0||t==="LR")return"LR";if(t==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(t)}`)}function un(t,e,n,r={}){let s=e in t.nodes,o=n in t.nodes;if(!s)return je(e,n,"no-such-from");if(!o)return je(e,n,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===n){if(r.findCycle===!0){let u=xr(t,e,r);if(u!=null)return u}let l=Ve(e,t.nodes[e],0,r);return We(e,n,[l])}if(i===0)return je(e,n,"no-path");let a=ln(t,e,n,i);return a.found?We(e,n,cn(t,a.pathOrder,r)):je(e,n,a.truncated?"max-depth-exceeded":"no-path")}function ln(t,e,n,r){let s=new Map,o=[{path:n,depth:0}],i=new Set([n]),a=0,l=!1;for(;a<o.length;){let f=o[a++];if(f.path===e)break;if(r!=null&&f.depth>=r){let g=t.nodes[f.path];g?.deps&&g.deps.length>0&&(l=!0);continue}let p=t.nodes[f.path];if(p==null)continue;let h=p.deps??[],d=new Map;for(let g=0;g<h.length;g++){let b=h[g];if(!b)continue;let x=d.get(b);x==null&&(x=[],d.set(b,x)),x.push(g)}for(let[g,b]of d)i.has(g)||(i.add(g),s.set(g,{from:f.path,depIndices:b}),o.push({path:g,depth:f.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:l};let u=[{path:e}],c=e;for(;c!==n;){let f=s.get(c);if(f==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=f.depIndices,u.push({path:f.from}),c=f.from}return{found:!0,pathOrder:u,truncated:!1}}function xr(t,e,n){let r=t.nodes[e];if(r==null)return null;let s=r.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=Ve(e,r,0,n);a.dep_index=o[0];let l=Ve(e,r,1,n);return We(e,e,[a,l])}let i=null;for(let a=0;a<s.length;a++){let l=s[a];if(!l||l===e)continue;let u=ln(t,l,e,n.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:We(e,e,cn(t,i.pathOrder,n))}function cn(t,e,n){return e.map((r,s)=>{let o=t.nodes[r.path],i=Ve(r.path,o,s,n);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function Ve(t,e,n,r){let s={path:t,type:e.type,hop:n};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=r.annotations?.get(t)??e.annotation;o!=null&&(s.annotation=o);let i=r.lastMutations?.get(t)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function We(t,e,n){return dn(t,e,!0,"ok",n)}function je(t,e,n){return dn(t,e,!1,n,[])}function dn(t,e,n,r,s){let o=wr(t,e,n,r,s);return{from:t,to:e,found:n,reason:r,steps:s,text:o,toJSON(){return{from:t,to:e,found:n,reason:r,steps:s}}}}function wr(t,e,n,r,s){if(!n)switch(r){case"no-such-from":return`explainPath: no node named "${t}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${t}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${t}" to "${e}"`}let o=[`Causal path: ${t} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let l=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(l),"value"in i&&o.push(` value: ${_r(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;o.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return o.join(`
|
|
3
|
-
`)}function
|
|
4
|
-
`)}function gn(
|
|
5
|
-
`);return
|
|
6
|
-
`)}function
|
|
7
|
-
`)}function Ir(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ze(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let s=t.indexOf("]",n+1);if(s<=n+1){e+="\\[";continue}let o=t.slice(n+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,n=s;continue}e+=Ir(r)}return e+="$",new RegExp(e)}var Pr={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},$r={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function Ue(t){if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||t==null)return String(t);try{return JSON.stringify(t)}catch{return"[unserializable]"}}function Br(t){return t==="none"?$r:t==="ansi"||t==null?Pr:{data:t.data??"",dirty:t.dirty??"",resolved:t.resolved??"",invalidate:t.invalidate??"",pause:t.pause??"",resume:t.resume??"",complete:t.complete??"",error:t.error??"",teardown:t.teardown??"",derived:t.derived??"",path:t.path??"",reset:t.reset??""}}function mn(t){if(t==null)return{};let e=t.detail;return e==="full"?{...t,structured:t.structured??!0,timeline:t.timeline??!0,causal:t.causal??!0,derived:t.derived??!0}:e==="minimal"?{...t,structured:t.structured??!0}:t.format==="stage-log"?{...t,structured:t.structured??!0,timeline:t.timeline??!0}:t}function Fr(t,e,n){for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);if(s<32||s===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function kt(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(D))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${D}' (path separator)`);if(t===Q)throw new Error(`Graph "${e}": ${n} name "${Q}" is reserved for meta companion paths`);Fr(t,e,n)}function Hr(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(D);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function jr(t,e){let n=!1;for(let s of t)if(!e.isMetaPassthrough(s[0])){n=!0;break}return n?t.filter(s=>e.isMetaPassthrough(s[0])):t}function wn(t){for(let e of t._mounts.values())wn(e);for(let e of t._nodes.values())try{e.down([[j]],{internal:!0})}catch{}}var oe=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(D))throw new Error(`Graph name must not contain '${D}' (got "${e}")`);if(e===Q)throw new Error(`Graph name "${Q}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??ae,this._traceRing=new Ce(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=qt(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}nameOf(e){return this._nodeToName.get(e)}add(e,n){let r=e.name,s=n?.name??r;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,i=n?.annotation;if(kt(o,this.name,"add"),this._mounts.has(o))throw new Error(`Graph "${this.name}": name "${o}" is already a mount point`);if(this._nodes.has(o))throw new Error(`Graph "${this.name}": node "${o}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(o,e),this._nodeToName.set(e,o),this._emitTopology({kind:"added",name:o,nodeKind:"node"}),i!=null&&(this._annotations.set(o,i),this.config.inspectorEnabled&&this._traceRing.push({path:o,annotation:i,timestamp_ns:F()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof I&&n._applyVersioning(e)}remove(e){kt(e,this.name,"remove");let n=this._mounts.get(e);if(n){let o={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,l]of i)a.includes(`${D}${Q}${D}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...n._collectSubgraphs(`${e}${D}`)),this._mounts.delete(e),n._parent=void 0,wn(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:o}),o}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[j]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let n=typeof e=="function"?e:(()=>{let o=ze(e);return i=>o.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>n(o));for(let o of s){let i=this.remove(o);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let s=e[r++];return{value:[s,n.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(D))return this.resolve(e);let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return n}get(e){return this.node(e).cache}set(e,n,r){let s=r?.internal===!0;this.node(e).down([[B,n]],{actor:r?.actor,internal:s,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);It(()=>{for(let[s,o]of r)this.set(s,o,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[X]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let s=r?.internal===!0;this.node(e).down([[$,n]],{actor:r?.actor,internal:s,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[Z]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[l,u]of this._nodes)r.set(u,l);let a=[];for(let[l,u]of this._nodes)if(u instanceof I)for(let c of u._deps){let f=r.get(c.node);f!=null&&a.push([f,l])}return a.sort((l,u)=>l[0]<u[0]?-1:l[0]>u[0]?1:l[1]<u[1]?-1:l[1]>u[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,l]of s)o.set(l,a);let i=[];for(let[a,l]of s)if(l instanceof I)for(let u of l._deps){let c=o.get(u.node);c!=null&&i.push([c,a])}return i.sort((a,l)=>a[0]<l[0]?-1:a[0]>l[0]?1:a[1]<l[1]?-1:a[1]>l[1]?1:0),i}mount(e,n){if(n===void 0){let s=new t(e);return this.mount(e,s)}if(typeof n=="function"){let s=new t(e);return n(s),this.mount(e,s)}let r=n;if(kt(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===r)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,r),r._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),r}resolve(e){let n=Hr(e,this.name);return this._resolveFromSegments(n)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let n=e;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],s=n.slice(1);if(s.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let o=this._nodes.get(r);if(o&&s.length>0&&s[0]===Q)return this._resolveMetaChainFromNode(o,s,n.join(D));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${s.join(D)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(s.join(D))}_resolveMetaChainFromNode(e,n,r){let s=e,o=0,i=[...n];for(;o<i.length;){if(i[o]!==Q)throw new Error(`Graph "${this.name}": expected ${Q} segment in meta path "${r}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Q} in "${r}"`);let a=i[o+1],l=s.meta[a];if(!l)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);s=l,o+=2}return s}signal(e,n){if(n?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,s){for(let l of this._mounts.values())l._signalDeliver(e,n,r,s);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=jr(e,this.config);for(let l of[...this._nodes.keys()].sort()){let u=this._nodes.get(l);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(c){if(c instanceof K)throw c;s.push(c)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,s)}}}_signalMetaSubtree(e,n,r,s,o){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,s)}catch(l){if(l instanceof K)throw l;o.push(l)}this._signalMetaSubtree(a,n,r,s,o)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,s=$e(e?.detail,e?.fields),o=e?.format==="spec",i=o?$e("minimal"):s,a=[];this._collectObserveTargets("",a);let l=new Map;for(let[w,k]of a)l.set(k,w);let u=[];{let w=a.map(([,S])=>S),k=new Set(l.values()),T=0;for(;w.length>0;){let S=w.shift();if(S instanceof I)for(let C of S._deps){let O=C.node;if(l.has(O))continue;let E=O.name??"",R=E;if(!R||k.has(R))if(E){let L=2;for(;k.has(`${E}#${L}`);)L++;R=`${E}#${L}`}else for(R=`__internal__/${T++}`;k.has(R);)R=`__internal__/${T++}`;l.set(O,R),k.add(R),u.push([R,O]),w.push(O)}}}let c=[...a,...u],f={};for(let[w,k]of c){if(n!=null&&!k.allowsObserve(n))continue;let T=wt(k,i),S=k instanceof I?k._deps.map(R=>l.get(R.node)??R.node.name??""):[],{name:C,...O}=T,E={...O,deps:S};if(!o){let R=this._annotations.get(w);R!=null&&(E.annotation=R)}if(r!=null)if(typeof r=="function"){let R=r;if(!(R.length>=2?R(w,E):R(E)))continue}else{let R=!0;for(let[L,V]of Object.entries(r)){let Y=L==="deps_includes"?"depsIncludes":L==="meta_has"?"metaHas":L;if(Y==="depsIncludes"){if(!E.deps.includes(String(V))){R=!1;break}continue}if(Y==="metaHas"){if(!Object.hasOwn(E.meta??{},String(V))){R=!1;break}continue}if(E[Y]!==V){R=!1;break}}if(!R)continue}f[w]=E}let p=new Set(Object.keys(f)),h=[];for(let[w,k]of c)if(k instanceof I)for(let T of k._deps){let S=l.get(T.node);S!=null&&h.push([S,w])}h.sort((w,k)=>w[0]<k[0]?-1:w[0]>k[0]?1:w[1]<k[1]?-1:w[1]>k[1]?1:0);let d=h.map(([w,k])=>({from:w,to:k}));(n!=null||r!=null)&&(d=d.filter(w=>p.has(w.from)&&p.has(w.to)));let g=this._collectSubgraphs(""),b=n!=null||r!=null?g.filter(w=>{let k=`${w}${D}`;return[...p].some(T=>T===w||T.startsWith(k))}):g,x=this,v=e,y={name:this.name,nodes:f,edges:d,subgraphs:b,expand(w){let k={...v,format:void 0};return Array.isArray(w)?(k.fields=w,k.detail=void 0):(k.detail=w,k.fields=void 0),x.describe(k)}},_=e??{},m=_.format;return m==="json"?Mr(y,_):m==="pretty"?Ar(y,_):m==="mermaid"?xn(y,_):m==="mermaid-url"?Dr(y,_):m==="d2"?Lr(y,_):m==="ascii"?an(y,_):y}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${r}`;n.push(s),n.push(...this._mounts.get(r)._collectSubgraphs(`${s}${D}`))}return n}resourceProfile(e){return hn(this,e)}reachable(e,n,r={}){return r.withDetail===!0?bn(this.describe(),e,n,{...r,withDetail:!0}):bn(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,l]of Object.entries(s.nodes))l.lastMutation!=null&&i.set(a,l.lastMutation);return un(s,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",s=0,o=G(s,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,l=!1,u=()=>{a||l||(a=!0,Se(()=>{a=!1,!l&&(s+=1,o.emit(s))}))},c=i.onEvent(b=>{let x=b.type;x!=="data"&&x!=="error"&&x!=="complete"&&x!=="teardown"||u()}),f=[],p=new WeakSet,h=b=>{if(p.has(b)||l)return;p.add(b);let x=b.topology.subscribe(v=>{for(let y of v){if(y[0]!==B)continue;let _=y[1];if(u(),_.kind==="added"&&_.nodeKind==="mount"){let m=b._mounts.get(_.name);m!=null&&h(m)}}});f.push(x);for(let v of b._mounts.keys()){let y=b._mounts.get(v);y!=null&&h(y)}};h(this);let d;try{d=q([o],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,x)=>b===x})}catch(b){c();for(let x of f)x();throw i.dispose(),b}let g=_t(d);return{node:d,dispose(){l=!0,c();for(let b of f)b();f.length=0,i.dispose(),g()}}}_explainReactive(e,n,r){let s=0,o=G(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,l=!1,u=i.onEvent(h=>{let d=h.type;d!=="data"&&d!=="error"&&d!=="complete"&&d!=="teardown"||a||l||(a=!0,Se(()=>{a=!1,!l&&(s+=1,o.emit(s))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},f;try{f=q([o],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(h,d)=>h.found===d.found&&h.reason===d.reason&&h.steps.length===d.steps.length&&Wr(h.steps,d.steps)})}catch(h){throw u(),i.dispose(),h}let p=_t(f);return{node:f,dispose(){l=!0,u(),i.dispose(),p()}}}_pathsMatching(e){let n=ze(e),r=[];return this._collectObserveTargets("",r),r.map(([s])=>s).filter(s=>n.test(s))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${D}${r}`;this._mounts.get(r)._collectObserveTargets(s,n)}for(let r of[...this._nodes.keys()].sort()){let s=this._nodes.get(r),o=e===""?r:`${e}${D}${r}`;n.push([o,s]),this._appendMetaObserveTargets(o,s,n)}}_appendMetaObserveTargets(e,n,r){for(let s of Object.keys(n.meta).sort()){let o=n.meta[s],i=`${e}${D}${Q}${D}${s}`;r.push([i,o]),this._appendMetaObserveTargets(i,o,r)}}observe(e,n){let r=typeof e=="string",o=mn(r?n:e),i=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,a=o.actor;if(r){let c=e,f=this.resolve(c);if(a!=null&&!f.allowsObserve(a))throw new K({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,f]],o,"one"):{subscribe(p){return f.subscribe(p)},up(p){try{f.up?.(p)}catch(h){if(h instanceof K)return;throw h}}}}let l=[];this._collectObserveTargets("",l),l.sort((c,f)=>c[0]<f[0]?-1:c[0]>f[0]?1:0);let u=a==null?l:l.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,o,"all"):{subscribe:c=>{let f=u.map(([p,h])=>h.subscribe(d=>{c(p,d)}));return()=>{for(let p of f)p()}},up:(c,f)=>{try{this.resolve(c).up?.(f)}catch(p){if(p instanceof K)return;throw p}}}}_buildStructuredObserver(e,n,r){let s=r==="one"?e[0]?.[0]:void 0,o=i=>{if(r==="one"&&s!=null){let c=this.resolve(s);return this._buildStructuredObserver([[s,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,f)=>c[0]<f[0]?-1:c[0]>f[0]?1:0);let l=i.actor,u=l==null?a:a.filter(([,c])=>c.allowsObserve(l));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,o)}_createObserveResult(e,n,r){let s=n.timeline===!0,o=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",l=this.config.inspectorEnabled,u=(o||i)&&l,c=n.maxEvents,f=c!=null&&c>0?new Ce(c):null,p=[],h=new Set,d={},g=new Set,b=0,x=0,v=0,y=0,_=0,m=0,w=!1,k=!1,T=0,S=new Map,C=new Map,O=new Map,E=N=>{f?f.push(N):p.push(N);for(let A of h)A(N)},R=()=>s?{timestamp_ns:F(),in_batch:De(),batch_id:T}:{},L=(N,A)=>{if(!(!u||!(N instanceof I)))return N._setInspectorHook(W=>{if(W.kind==="dep_message")S.set(N,W.depIndex);else if(W.kind==="run"){let _e=W.batchData.map((M,H)=>M!=null&&M.length>0?M.at(-1):W.prevData[H]);C.set(N,_e);let z=W.batchData.map(M=>M!=null?[...M]:void 0);O.set(N,z),i&&E({type:"derived",path:A,dep_values:_e,dep_batches:z,...R()})}})},V=N=>{let A=S.get(N),W=C.get(N);if(!o||W==null)return{};let z=(A!=null&&A>=0&&N instanceof I?N._deps[A]:void 0)?.node,M=z?.v,H=O.get(N);return{trigger_dep_index:A,trigger_dep_name:z?.name,...M!=null?{trigger_version:{id:M.id,version:M.version}}:{},dep_values:[...W],...H!=null?{dep_batches:H}:{}}},Y=[],ce=[];for(let[N,A]of e){let W=L(A,N);W&&Y.push(W),ce.push(A.subscribe(_e=>{T++;for(let z of _e){let M=z[0],H=R();if(M===B){d[N]=z[1];let Ze=A instanceof I?A.lastMutation?.actor??ge:ge;E({type:"data",path:N,data:z[1],actor:Ze,...H,...V(A)})}else if(a)M===J?b++:M===te?x++:M===X?v++:M===ne?y++:M===ie?_++:M===j?m++:M===Z&&!g.has(N)?w=!0:M===$&&(k=!0,g.add(N));else if(M===J)b++,E({type:"dirty",path:N,...H});else if(M===te)x++,E({type:"resolved",path:N,...H,...V(A)});else if(M===X)v++,E({type:"invalidate",path:N,...H});else if(M===ne)y++,E({type:"pause",path:N,lockId:z[1],...H});else if(M===ie)_++,E({type:"resume",path:N,lockId:z[1],...H});else if(M===Z)g.has(N)||(w=!0),E({type:"complete",path:N,...H});else if(M===$){k=!0,g.add(N);let Ze=A instanceof I?A.lastMutation?.actor??ge:ge;E({type:"error",path:N,data:z[1],actor:Ze,...H})}else M===j&&(m++,E({type:"teardown",path:N,...H}))}}))}let Ye=!1,Je=()=>{if(!Ye){Ye=!0;for(let N of ce)N();for(let N of Y)N();for(let N of Re)N({value:void 0,done:!0});Re.length=0}},Xe=[],Re=[];h.add(N=>{let A=Re.shift();A?A({value:N,done:!1}):Xe.push(N)});let Ct={get values(){return d},get dirtyCount(){return b},get resolvedCount(){return x},get invalidateCount(){return v},get pauseCount(){return y},get resumeCount(){return _},get teardownCount(){return m},get events(){return f?f.toArray():[...p]},get anyCompletedCleanly(){return w},get anyErrored(){return k},get completedWithoutErrors(){return w&&!k},onEvent(N){return h.add(N),()=>h.delete(N)},dispose:Je,expand(N){Je();let A={...n};return typeof N=="string"?A.detail=N:Object.assign(A,N),r(mn(A))},[Symbol.asyncIterator](){return{next(){return Xe.length>0?Promise.resolve({value:Xe.shift(),done:!1}):Ye?Promise.resolve({value:void 0,done:!0}):new Promise(N=>Re.push(N))},return(){return Je(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Ct,n),Ct}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let s=n.logger??(d=>console.log(d)),o=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=o==null&&i==null?()=>!0:d=>(o==null||o.has(d))&&(i==null||!i.has(d)),l=Br(n.theme),u=r==="stage-log"?F():0,c=d=>d==null?"":n.stageLabels?.[d]??d,f=(d,g)=>d.length>g?`${d.slice(0,g-1)}\u2026`:d,p=d=>d.type==="data"||d.type==="error"?f(Ue(d.data),120):"",h=d=>{if(r==="stage-log"){let k=(F()-u)/1e9,T=c(d.path).padEnd(9);if(d.type==="data"){let S=p(d);return`[${k.toFixed(3)}s] ${T} \u2190${S?` ${S}`:""}`}if(d.type==="error"){let S=p(d);return`[${k.toFixed(3)}s] ${T} \u2717${S?` ${S}`:""}`}return d.type==="complete"?`[${k.toFixed(3)}s] ${T} \u25A0 complete`:`[${k.toFixed(3)}s] ${T} ${d.type}`}if(r==="json")try{return JSON.stringify(d)}catch{return JSON.stringify({type:d.type,path:d.path,data:"[unserializable]"})}let g=l[d.type]??"",b=d.path?`${l.path}${d.path}${l.reset} `:"",x=d.type==="data"||d.type==="error",v=d.type==="pause"||d.type==="resume",y=x?` ${Ue(d.data)}`:v?` ${Ue(d.lockId)}`:"",_=d.type==="data"||d.type==="resolved"||d.type==="derived"?d:void 0,m=_?.trigger_dep_name!=null?` <- ${_.trigger_dep_name}`:_?.trigger_dep_index!=null?` <- #${_.trigger_dep_index}`:"",w=d.in_batch?" [batch]":"";return`${b}${g}${d.type.toUpperCase()}${l.reset}${y}${m}${w}`};e.onEvent(d=>{a(d.type)&&s(h(d),d)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){pn(this._disposers,this.name),this.signal([[j]],{internal:!0}),pn(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:n,...r}=this.describe({detail:"full"}),s={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:l,guard:u,...c}=r.nodes[a];s[a]=c}let o=[...r.subgraphs].sort(),i={...r,version:1,nodes:s,subgraphs:o};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return At(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??ae,{codec:s,codecVersion:o,payload:i}=Dt(e,r);return s.decode(i,o)}restore(e,n){if(gn(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(o=>ze(o)),s=n?.includeProducers===!0;for(let o of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(o)))continue;let i=e.nodes[o];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let l=this.tryResolve(o)?.v;if(l!=null&&l.id===i.v.id&&l.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){n?.onError?.(o,a)}}}}}static fromSnapshot(e,n){gn(e);let r=typeof n=="function"?n:n?.build,s=typeof n=="function"?void 0:n?.factories,o=new t(e.name);if(r)return r(o),o.restore(e),o;for(let h of[...e.subgraphs].sort((d,g)=>{let b=d.split(D).length,x=g.split(D).length;return b!==x?b-x:d<g?-1:d>g?1:0})){let d=h.split(D),g=o;for(let b of d)g._mounts.has(b)||g.mount(b,new t(b)),g=g._mounts.get(b)}let i=s?Object.entries(s).map(([h,d])=>({re:ze(h),factory:d})):[],a=h=>{for(let d of i)if(d.re.test(h))return d.factory},l=h=>{let d=h.split(D),g=d.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${h}"`);let b=o;for(let x of d){let v=b._mounts.get(x);if(!v)throw new Error(`unknown mount "${x}" in path "${h}"`);b=v}return[b,g]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${D}${Q}${D}`)).sort((h,d)=>h[0]<d[0]?-1:h[0]>d[0]?1:0),c=new Map(u),f=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[h,d]of[...c.entries()]){let g=d?.deps??[];if(!g.every(m=>f.has(m)))continue;let[b,x]=l(h),v={...d?.meta??{}},y=a(h),_;if(d?.type==="state")_=G(d.value,{meta:v});else{if(y==null)continue;_=y(x,{path:h,type:d.type,value:d.value,meta:v,deps:g,resolvedDeps:g.map(m=>f.get(m))})}b.add(_,{name:x}),f.set(h,_),c.delete(h),p=!0}}if(c.size>0){let h=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachSnapshotStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let s=(u,c)=>{if(u.disposed)return;let f=Or(c.nodes);if(u.lastSnapshot!=null&&f!==""&&f===u.lastFingerprint)return;let p=u.seq+1,h=Me(),b=u.lastSnapshot==null||p%u.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:p,timestamp_ns:h,format_version:xe}:{name:this.name,mode:"diff",diff:Vr(u.lastSnapshot,c),seq:p,timestamp_ns:h,format_version:xe};if(u.tier.filter&&!u.tier.filter(b))return;let x;try{x=u.tier.save(b)}catch(v){n.onError?.(v,u.tier);return}if(x&&typeof x.then=="function"){let _=(u.savePending??Promise.resolve()).then(()=>x,()=>x).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=c,u.lastFingerprint=f)},m=>{n.onError?.(m,u.tier)});u.savePending=_.finally(()=>{u.savePending===_&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=c,u.lastFingerprint=f},o=(u,c)=>{try{s(u,c)}catch(f){n.onError?.(f,u.tier)}},i=(u,c)=>{if(!c.some(d=>{let g=this.config.messageTier(d[0]);return g>=3&&g<5}))return;if(n.filter){let d=this.tryResolve(u);if(d==null)return;let g=wt(d,$e("standard"));if(!n.filter(u,g))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let d of r)d.disposed||(d.debounceMs===0?o(d,h()):(d.timer==null&&(d.timer=new Be),d.timer.start(d.debounceMs,()=>{d.disposed||o(d,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(f=>{let p=this.tryResolve(f);return p==null?()=>{}:p.subscribe(h=>i(f,h))});a=()=>{for(let f of c)f()}}else a=this.observe().subscribe((u,c)=>i(u,c));let l=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(l)};return this._storageDisposers.add(l),{dispose:l}}async _cascadeRestore(e,n){for(let r of e){let s;try{s=await r.load?.()}catch(i){n?.(i,r);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===xe&&o.nodes!=null)return this.restore(o),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let s of n){let o;try{o=await s.load?.()}catch(l){r?.onError?.(l,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===xe&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(l){r?.onError?.(l,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,n,r){if(e!=null&&n!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,n),this.config.inspectorEnabled){let s={path:e,annotation:n,timestamp_ns:F(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(s=>!e(s)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let s of n)this._traceRing.push(s);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(n.nodes)),o=[...s].filter(v=>!r.has(v)).sort(),i=[...r].filter(v=>!s.has(v)).sort(),a=[],l=[];for(let v of r){if(!s.has(v))continue;let y=e.nodes[v],_=n.nodes[v],m=y.v,w=_.v;m!=null&&w!=null&&m.id===w.id&&m.version!==w.version&&l.push({path:v,id:m.id,from:m.version,to:w.version});let k=m!=null&&w!=null&&m.id===w.id&&m.version===w.version;for(let T of["type","status","sentinel"]){let S=y[T],C=_[T];S!==C&&a.push({path:v,field:T,from:S,to:C})}if(!k)for(let T of["value","meta"]){let S=y[T],C=_[T];Nr(S,C)||a.push({path:v,field:T,from:S,to:C})}}let u=v=>`${v.from} ${v.to}`,c=new Set(e.edges.map(u)),f=new Set(n.edges.map(u)),p=n.edges.filter(v=>!c.has(u(v))),h=e.edges.filter(v=>!f.has(u(v))),d=new Set(e.subgraphs),g=new Set(n.subgraphs),b=[...g].filter(v=>!d.has(v)).sort(),x=[...d].filter(v=>!g.has(v)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:l,edgesAdded:p,edgesRemoved:h,subgraphsAdded:b,subgraphsRemoved:x}}};function Vr(t,e){let n=oe.diff(t,e),r={};for(let s of n.nodesAdded){let o=e.nodes[s];o!=null&&(r[s]=o)}return{...n,nodesAddedFull:r}}function bn(t,e,n,r={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?s:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=r.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return r.withDetail?s:[];let i=new Map,a=new Map,l=new Map,u=new Map,c=new Set;for(let[y,_]of Object.entries(t.nodes)){if(!y)continue;c.add(y);let m=_.deps??[];i.set(y,m);for(let w of m)w&&(c.add(w),a.has(w)||a.set(w,new Set),a.get(w).add(y))}for(let y of t.edges){if(y==null||typeof y!="object")continue;let _=typeof y.from=="string"?y.from:"",m=typeof y.to=="string"?y.to:"";!_||!m||(c.add(_),c.add(m),u.has(_)||u.set(_,new Set),u.get(_).add(m),l.has(m)||l.set(m,new Set),l.get(m).add(_))}if(!c.has(e))return r.withDetail?s:[];let f=r.both===!0,p=y=>{if(f){let k=i.get(y)??[],T=l.get(y),S=a.get(y),C=u.get(y),O=[...k];return T&&O.push(...T),S&&O.push(...S),C&&O.push(...C),O}if(n==="upstream"){let k=i.get(y)??[],T=l.get(y);return T?[...k,...T]:k}let _=a.get(y),m=u.get(y),w=_?[..._]:[];return m&&w.push(...m),w},h=new Set([e]),d=new Map,g=[{path:e,depth:0}],b=0,x=!1;for(;b<g.length;){let y=g[b++];if(o!=null&&y.depth>=o){p(y.path).length>0&&(x=!0);continue}for(let _ of p(y.path))!_||h.has(_)||(h.add(_),d.set(_,y.depth+1),g.push({path:_,depth:y.depth+1}))}let v=[...d.keys()].sort((y,_)=>y<_?-1:y>_?1:0);return r.withDetail?{paths:v,depths:d,truncated:x}:v}function Wr(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],s=e[n];if(r.path!==s.path||r.type!==s.type||r.status!==s.status||r.hop!==s.hop||r.dep_index!==s.dep_index||r.annotation!==s.annotation||r.value!==s.value||r.lastMutation!==s.lastMutation)return!1;let o=r.v,i=s.v;if(o!==i&&(o==null||i==null||o.id!==i.id||o.version!==i.version))return!1}return!0}Ge();Ne();se();function ee(t,e){t!=null&&ye(n=>t.down(n),[[B,e]],ae.tierOf)}pe();se();Ee();function zr(t){for(let e of t){let n=e.codePointAt(0);if(n>=19968&&n<=40959||n>=13312&&n<=19903||n>=12288&&n<=12351||n>=12352&&n<=12447||n>=12448&&n<=12543||n>=44032&&n<=55215||n>=65280&&n<=65519)return!0}return!1}var _n=new Set(["\uFF0C","\uFF0E","\uFF01","\uFF1A","\uFF1B","\uFF1F","\u3001","\u3002","\u30FB","\uFF09","\u3015","\u3009","\u300B","\u300D","\u300F","\u3011"]),Ur=new Set([".",",","!","?",":",";",")","]","}","%",'"',"\u201D","\u2019","\xBB","\u203A","\u2026"]);function Kr(t){return t.replace(/[\t\n\r\f ]+/g," ").replace(/^ | $/g,"")}function qr(t){let e=new Intl.Segmenter(void 0,{granularity:"word"}),n=[];for(let r of e.segment(t)){let s=r.segment,o=r.isWordLike??!1,i=[],a=[],l=[],u="",c=null;for(let f of s){let p;f===" "?p="space":f==="\u200B"?p="zero-width-break":f==="\xAD"?p="soft-hyphen":f===`
|
|
8
|
-
`?p="hard-break":p="text",c!==null&&p===c?u+=f:(c!==null&&(i.push(u),a.push(c==="text"&&o),l.push(c)),u=f,c=p)}c!==null&&(i.push(u),a.push(c==="text"&&o),l.push(c)),n.push({texts:i,isWordLike:a,kinds:l})}return n}function we(t,e,n,r,s){let o=Kr(t);if(o.length===0)return[];let i=qr(o),a=new Intl.Segmenter(void 0,{granularity:"grapheme"}),l=[],u=[],c=[];for(let x of i)for(let v=0;v<x.texts.length;v++)l.push(x.texts[v]),u.push(x.kinds[v]),c.push(x.isWordLike[v]);let f=[],p=[],h=[];for(let x=0;x<l.length;x++){let v=l[x],y=u[x],_=c[x];if(y==="text"&&!_&&f.length>0&&p[p.length-1]==="text"&&v.length===1&&(Ur.has(v)||_n.has(v))){f[f.length-1]+=v;continue}if(v==="-"&&f.length>0&&p[p.length-1]==="text"&&h[h.length-1]){f[f.length-1]+=v;continue}f.push(v),p.push(y),h.push(_)}let d=r.get(e);d||(d=new Map,r.set(e,d));function g(x){let v=d.get(x);if(v===void 0){s&&(s.misses+=1);let y=n.measureSegment(x,e).width;v=Number.isFinite(y)&&y>=0?y:0,d.set(x,v)}else s&&(s.hits+=1);return v}let b=[];for(let x=0;x<f.length;x++){let v=f[x],y=p[x];if(y!=="text"){b.push({text:v,width:y==="space"?g(" ")*v.length:0,kind:y,graphemeWidths:null});continue}if(zr(v)){let w="";for(let k of a.segment(v)){let T=k.segment;if(w.length>0&&_n.has(T)){w+=T;continue}if(w.length>0){let S=g(w);b.push({text:w,width:S,kind:"text",graphemeWidths:null})}w=T}if(w.length>0){let k=g(w);b.push({text:w,width:k,kind:"text",graphemeWidths:null})}continue}let _=g(v),m=null;if(h[x]&&v.length>1){let w=[];for(let k of a.segment(v))w.push(g(k.segment));w.length>1&&(m=w)}b.push({text:v,width:_,kind:"text",graphemeWidths:m})}return b}function Ke(t,e,n,r,s){if(t.length===0)return{lines:[],lineCount:0};let o=[],i=0,a=!1,l=0,u=0,c=0,f=0,p=-1,h=0,d=s.get(r);d||(d=new Map,s.set(r,d));let g=d.get("-");g===void 0&&(g=n.measureSegment("-",r).width,d.set("-",g));function b(m=c,w=f,k=i){let T="";for(let S=l;S<m;S++){let C=t[S];if(!(C.kind==="soft-hyphen"||C.kind==="hard-break"))if(S===l&&u>0&&C.graphemeWidths){let E=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(C.text)].map(R=>R.segment);T+=E.slice(u).join("")}else T+=C.text}if(w>0&&m<t.length){let S=t[m],O=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(S.text)].map(R=>R.segment),E=l===m?u:0;T+=O.slice(E,w).join("")}m>0&&t[m-1]?.kind==="soft-hyphen"&&!(l===m&&u>0)&&(T+="-"),o.push({text:T,width:k,startSegment:l,startGrapheme:u,endSegment:m,endGrapheme:w}),i=0,a=!1,p=-1,h=0}function x(m){return m==="space"||m==="zero-width-break"||m==="soft-hyphen"}function v(m,w,k){a=!0,l=m,u=w,c=m+1,f=0,i=k}function y(m,w,k){a=!0,l=m,u=w,c=m,f=w+1,i=k}for(let m=0;m<t.length;m++){let w=t[m];if(w.kind==="hard-break"){a?b():o.push({text:"",width:0,startSegment:m,startGrapheme:0,endSegment:m,endGrapheme:0}),l=m+1,u=0;continue}let k=w.width;if(!a){k>e&&w.graphemeWidths?_(m,0,w.graphemeWidths):v(m,0,k),x(w.kind)&&(p=m+1,h=w.kind==="space"?i-k:i);continue}let T=i+k;if(T>e+.005){if(x(w.kind)){i+=k,c=m+1,f=0,b(m+1,0,w.kind==="space"?i-k:i);continue}if(p>=0){b(p,0,h),m--;continue}if(k>e&&w.graphemeWidths){b(),_(m,0,w.graphemeWidths);continue}b(),m--;continue}i=T,c=m+1,f=0,x(w.kind)&&(p=m+1,h=w.kind==="space"?i-k:i)}return a&&b(),{lines:o,lineCount:o.length};function _(m,w,k){for(let T=w;T<k.length;T++){let S=k[T];if(!a){y(m,T,S);continue}i+S>e+.005?(b(),y(m,T,S)):(i+=S,c=m,f=T+1)}a&&c===m&&f===k.length&&(c=m+1,f=0)}}function St(t){return t==="space"||t==="zero-width-break"||t==="soft-hyphen"}var Ot=null;function Yr(){return Ot===null&&(Ot=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Ot}function kn(t,e,n){if(e===0&&n<0)return t.text;let r=[...Yr().segment(t.text)].map(o=>o.segment),s=n<0?r.length:n;return r.slice(e,s).join("")}function le(t,e,n,r,s,o){let i="";for(let a=e;a<r;a++){let l=t[a];l.kind==="soft-hyphen"||l.kind==="hard-break"||(a===e&&n>0?i+=kn(l,n,-1):i+=l.text)}if(s>0&&r<t.length){let a=t[r];i+=kn(a,e===r?n:0,s)}return o&&(i+="-"),i}function Jr(t){if(!t?.adapter||!t.font)return 0;let e=t.cache;if(e){let n=e.get(t.font);n||(n=new Map,e.set(t.font,n));let r=n.get("-");return r===void 0&&(r=t.adapter.measureSegment("-",t.font).width,n.set("-",r)),r}return t.adapter.measureSegment("-",t.font).width}function Nt(t,e,n,r){let s=e.segmentIndex,o=e.graphemeIndex;if(s>=t.length)return null;if(o===0){for(;s<t.length;){let m=t[s];if(m.kind==="hard-break")return{text:"",width:0,start:{segmentIndex:e.segmentIndex,graphemeIndex:0},end:{segmentIndex:s+1,graphemeIndex:0}};if(m.kind==="space"||m.kind==="zero-width-break"||m.kind==="soft-hyphen"){s+=1;continue}break}if(s>=t.length)return null}let i=Jr(r),a=s,l=s===e.segmentIndex?o:0,u=0,c=a,f=0,p=!1,h=-1,d=0,g=0,b=!1,x=(m,w,k,T)=>{h=m,d=w,g=k,b=T==="soft-hyphen"},v=(m,w,k)=>{for(let T=w;T<k.length;T++){let S=k[T];if(!p){u=S,c=m,f=T+1,p=!0;continue}if(u+S>n+.005)return!0;u+=S,c=m,f=T+1}return c===m&&f===k.length&&(c=m+1,f=0),!1};if(l>0&&a<t.length){let m=t[a];if(m.graphemeWidths){if(v(a,l,m.graphemeWidths))return{text:le(t,a,l,c,f,!1),width:u,start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}};s=c}}for(;s<t.length;){let m=t[s];if(m.kind==="hard-break"){if(p){let T=c>0&&t[c-1]?.kind==="soft-hyphen";return{text:le(t,a,l,c,f,T),width:u+(T?i:0),start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}}}return{text:"",width:0,start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:s+1,graphemeIndex:0}}}let w=m.width;if(!p){if(w>n&&m.graphemeWidths){if(v(s,0,m.graphemeWidths))return{text:le(t,a,l,c,f,!1),width:u,start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}};s=c;continue}u=w,c=s+1,f=0,p=!0,St(m.kind)&&x(s+1,0,m.kind==="space"?u-w:u,m.kind),s+=1;continue}let k=u+w;if(k>n+.005){if(St(m.kind)){c=s+1,f=0;let S=m.kind==="soft-hyphen",C=m.kind==="space"?u:u+(S?i:0);return{text:le(t,a,l,c,f,S),width:C,start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}}}return h>=0?{text:le(t,a,l,h,d,b),width:g+(b?i:0),start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:h,graphemeIndex:d}}:w>n&&m.graphemeWidths?{text:le(t,a,l,c,f,!1),width:u,start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}}:{text:le(t,a,l,c,f,!1),width:u,start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}}}u=k,c=s+1,f=0,St(m.kind)&&x(s+1,0,m.kind==="space"?u-w:u,m.kind),s+=1}if(!p)return null;let y=c>0&&t[c-1]?.kind==="soft-hyphen";return{text:le(t,a,l,c,f,y),width:u+(y?i:0),start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}}}function Et(t,e,n=0){let r=[t];for(let s=0;s<e.length;s++){let o=e[s],i=[];for(let a=0;a<r.length;a++){let l=r[a];if(o.right<=l.left||o.left>=l.right){i.push(l);continue}o.left>l.left&&i.push({left:l.left,right:o.left}),o.right<l.right&&i.push({left:o.right,right:l.right})}r=i}return n>0?r.filter(s=>s.right-s.left>=n):r}function qe(t,e,n){let r=[],s=new Intl.Segmenter(void 0,{granularity:"grapheme"});for(let o=0;o<t.lines.length;o++){let i=t.lines[o],a=o*n,l=0;for(let u=i.startSegment;u<e.length;u++){let c=e[u];if(c.kind==="soft-hyphen"||c.kind==="hard-break"){if(u>=i.endSegment&&i.endGrapheme===0)break;continue}let f=[...s.segment(c.text)].map(d=>d.segment);if(f.length===0)continue;let p=u===i.startSegment?i.startGrapheme:0,h;if(u<i.endSegment)h=f.length;else if(u===i.endSegment&&i.endGrapheme>0)h=i.endGrapheme;else break;for(let d=p;d<h;d++){let g=c.graphemeWidths?c.graphemeWidths[d]:c.width/f.length;r.push({x:l,y:a,width:g,height:n,line:o}),l+=g}}}return r}function Xr(t){let{adapter:e,name:n="reactive-layout"}=t,r=new oe(n),s=new Map,o=G(t.text??"",{name:"text"}),i=G(t.font??"16px sans-serif",{name:"font"}),a=G(t.lineHeight??20,{name:"line-height"}),l=G(Math.max(0,t.maxWidth??800),{name:"max-width"});function u(d,g){if(d===null||g===null)return d===g;if(d.length!==g.length)return!1;for(let b=0;b<d.length;b++)if(d[b]!==g[b])return!1;return!0}let c=re([o,i],(d,g,b)=>{let x=d[0],v=x!=null&&x.length>0?x.at(-1):b.prevData[0],y=d[1],_=y!=null&&y.length>0?y.at(-1):b.prevData[1],m=F(),w={hits:0,misses:0},k=we(v,_,e,s,w),T=F()-m,S=w.hits+w.misses,C=S===0?1:w.hits/S,O=c.meta;O&&(ee(O["cache-hit-rate"],C),ee(O["segment-count"],k.length),ee(O["layout-time-ns"],T)),g.emit(k);let E=()=>{s.clear(),e.clearCache?.()};return{deactivate:E,invalidate:E}},{name:"segments",describeKind:"derived",meta:{"cache-hit-rate":0,"segment-count":0,"layout-time-ns":0},equals:(d,g)=>{let b=d,x=g;if(b==null||x==null)return b===x;if(b.length!==x.length)return!1;for(let v=0;v<b.length;v++){let y=b[v],_=x[v];if(y.text!==_.text||y.width!==_.width||y.kind!==_.kind||!u(y.graphemeWidths??null,_.graphemeWidths??null))return!1}return!0}}),f=q([c,l,i],([d,g,b])=>Ke(d,g,e,b,s),{name:"line-breaks",equals:(d,g)=>{let b=d,x=g;if(b==null||x==null)return b===x;if(b.lineCount!==x.lineCount)return!1;for(let v=0;v<b.lines.length;v++){let y=b.lines[v],_=x.lines[v];if(y.text!==_.text||y.width!==_.width||y.startSegment!==_.startSegment||y.startGrapheme!==_.startGrapheme||y.endSegment!==_.endSegment||y.endGrapheme!==_.endGrapheme)return!1}return!0}}),p=q([f,a],([d,g])=>d.lineCount*g,{name:"height"}),h=q([f,c,a],([d,g,b])=>qe(d,g,b),{name:"char-positions",equals:(d,g)=>{let b=d,x=g;if(b==null||x==null)return b===x;if(b.length!==x.length)return!1;for(let v=0;v<b.length;v++)if(b[v].x!==x[v].x||b[v].y!==x[v].y||b[v].width!==x[v].width)return!1;return!0}});return r.add(o,{name:"text"}),r.add(i,{name:"font"}),r.add(a,{name:"line-height"}),r.add(l,{name:"max-width"}),r.add(c,{name:"segments"}),r.add(f,{name:"line-breaks"}),r.add(p,{name:"height"}),r.add(h,{name:"char-positions"}),{graph:r,setText:d=>r.set("text",d),setFont:d=>r.set("font",d),setLineHeight:d=>r.set("line-height",d),setMaxWidth:d=>r.set("max-width",Math.max(0,d)),segments:c,lineBreaks:f,height:p,charPositions:h}}function Tn(t,e,n,r,s,o,i){switch(t.type){case"text":{let a=t.font??s,l=t.lineHeight??o,u=we(t.text,a,n.text,r),c=Ke(u,e,n.text,a,r),f=qe(c,u,l),p=c.lineCount*l,h=0;for(let d of c.lines)d.width>h&&(h=d.width);return{index:i,type:"text",width:Math.min(h,e),height:p,textSegments:u,textLineBreaks:c,textCharPositions:f}}case"image":{let a,l;if(t.naturalWidth!=null&&t.naturalHeight!=null)a=t.naturalWidth,l=t.naturalHeight;else if(n.image){let u=n.image.measureImage(t.src);a=u.width,l=u.height}else throw new Error(`Image block at index ${i} has no naturalWidth/naturalHeight and no ImageMeasurer adapter`);return a>e&&(l=l*e/a,a=e),{index:i,type:"image",width:a,height:l}}case"svg":{let a,l;if(t.viewBox)a=t.viewBox.width,l=t.viewBox.height;else if(n.svg){let u=n.svg.measureSvg(t.content);a=u.width,l=u.height}else throw new Error(`SVG block at index ${i} has no viewBox and no SvgMeasurer adapter`);return a>e&&(l=l*e/a,a=e),{index:i,type:"svg",width:a,height:l}}}}function Sn(t,e,n,r,s,o){return t.map((i,a)=>Tn(i,e,n,r,s,o,a))}function On(t,e){let n=[],r=0;for(let s=0;s<t.length;s++){let o=t[s];n.push({...o,x:0,y:r}),r+=o.height+(s<t.length-1?e:0)}return n}function Nn(t){if(t.length===0)return 0;let e=t[t.length-1];return e.y+e.height}function Zr(t){let{adapters:e,name:n="reactive-block-layout",defaultFont:r="16px sans-serif",defaultLineHeight:s=20}=t,o=new oe(n),i=new Map,a=G(t.blocks??[],{name:"blocks"}),l=G(Math.max(0,t.maxWidth??800),{name:"max-width"}),u=G(t.gap??0,{name:"gap"}),c=re([a,l],(h,d,g)=>{let b=h[0]!=null&&h[0].length>0?h[0].at(-1):g.prevData[0],x=h[1]!=null&&h[1].length>0?h[1].at(-1):g.prevData[1],v=F(),y=Sn(b,x,e,i,r,s),_=F()-v,m=c.meta;m&&(ee(m["block-count"],y.length),ee(m["layout-time-ns"],_)),d.emit(y);let w=()=>{i.clear(),e.text.clearCache?.()};return{deactivate:w,invalidate:w}},{name:"measured-blocks",describeKind:"derived",meta:{"block-count":0,"layout-time-ns":0},equals:(h,d)=>{let g=h,b=d;if(g==null||b==null)return g===b;if(g.length!==b.length)return!1;for(let x=0;x<g.length;x++){let v=g[x],y=b[x];if(v.type!==y.type||v.width!==y.width||v.height!==y.height||v.index!==y.index)return!1}return!0}}),f=q([c,u],([h,d])=>On(h,d),{name:"block-flow",equals:(h,d)=>{let g=h,b=d;if(g==null||b==null)return g===b;if(g.length!==b.length)return!1;for(let x=0;x<g.length;x++){let v=g[x],y=b[x];if(v.x!==y.x||v.y!==y.y||v.width!==y.width||v.height!==y.height)return!1}return!0}}),p=q([f],([h])=>Nn(h),{name:"total-height"});return o.add(a,{name:"blocks"}),o.add(l,{name:"max-width"}),o.add(u,{name:"gap"}),o.add(c,{name:"measured-blocks"}),o.add(f,{name:"block-flow"}),o.add(p,{name:"total-height"}),{graph:o,setBlocks:h=>o.set("blocks",h),setMaxWidth:h=>o.set("max-width",Math.max(0,h)),setGap:h=>o.set("gap",h),measuredBlocks:c,blockFlow:f,totalHeight:p}}pe();se();Ee();function En(t,e,n){let r=t.hPad??0,s=t.vPad??0,o=e-s,i=n+s;if(o>=t.cy+t.r||i<=t.cy-t.r)return null;let a=t.cy>=o&&t.cy<=i?0:t.cy<o?o-t.cy:t.cy-i;if(a>=t.r)return null;let l=Math.sqrt(t.r*t.r-a*a);return{left:t.cx-l-r,right:t.cx+l+r}}function Cn(t,e,n){let r=t.hPad??0,s=t.vPad??0;return n<=t.y-s||e>=t.y+t.h+s?null:{left:t.x-r,right:t.x+t.w+r}}function Qr(t,e,n){return t.kind==="circle"?En(t,e,n):Cn(t,e,n)}function Rn(t,e,n,r,s,o,i){let a=i?.paragraphSpacing??s,l=[],u={segmentIndex:0,graphemeIndex:0};if(t.length===0||n.count<=0||s<=0)return{lines:l,cursor:u};let c=e.paddingX??0,f=e.paddingY??0,p=Math.max(0,e.width-c*2),h=Math.max(0,e.height-f*2),d=n.gap*Math.max(0,n.count-1),g=Math.max(0,(p-d)/n.count);if(g<=0)return{lines:l,cursor:u};e:for(let b=0;b<n.count;b++){let x=c+b*(g+n.gap),v=x+g,y=f;for(;y+s<=f+h;){let _=y+s,m=[];for(let T=0;T<r.length;T++){let S=Qr(r[T],y,_);S!==null&&m.push(S)}let w=Et({left:x,right:v},m,o);if(w.length===0){y+=s;continue}let k=!1;for(let T=0;T<w.length;T++){let S=w[T],C=S.right-S.left,O=Nt(t,u,C);if(O===null)return{lines:l,cursor:u};if(O.text.length===0&&O.width===0){u=O.end,k=!0;break}l.push({x:S.left,y,width:O.width,slotWidth:C,text:O.text,columnIndex:b,flushToRight:S.right<v-.5}),u=O.end}if(k){y+=a;continue}if(y+=s,u.segmentIndex>=t.length)break e}if(u.segmentIndex>=t.length)break}return{lines:l,cursor:u}}function es(t){let{adapter:e,name:n="reactive-flow-layout",minSlotWidth:r=20}=t,s=new oe(n),o=new Map,i=G(t.text??"",{name:"text"}),a=G(t.font??"16px sans-serif",{name:"font"}),l=G(t.lineHeight??20,{name:"line-height"}),u=G(t.container??{width:800,height:600,paddingX:0,paddingY:0},{name:"container"}),c=G(t.columns??{count:1,gap:0},{name:"columns"}),f=G(t.obstacles??[],{name:"obstacles"}),p=G(t.paragraphSpacing??null,{name:"paragraph-spacing"}),h=re([i,a],(g,b,x)=>{let v=g[0],y=v!=null&&v.length>0?v.at(-1):x.prevData[0],_=g[1],m=_!=null&&_.length>0?_.at(-1):x.prevData[1],w=we(y,m,e,o);b.emit(w);let k=()=>{o.clear(),e.clearCache?.()};return{deactivate:k,invalidate:k}},{name:"segments",describeKind:"derived"}),d=q([h,u,c,f,l,p],([g,b,x,v,y,_])=>{let m=g,w=F(),k=_??y,{lines:T,cursor:S}=Rn(m,b,x,v,y,r,{paragraphSpacing:k}),C=F()-w,O=Math.max(0,m.length-S.segmentIndex),E=d.meta;return E&&(ee(E["line-count"],T.length),ee(E["layout-time-ns"],C),ee(E["overflow-segments"],O)),T},{name:"flow-lines",meta:{"line-count":0,"layout-time-ns":0,"overflow-segments":0},equals:(g,b)=>{let x=g,v=b;if(x.length!==v.length)return!1;for(let y=0;y<x.length;y++){let _=x[y],m=v[y];if(_.x!==m.x||_.y!==m.y||_.width!==m.width||_.slotWidth!==m.slotWidth||_.text!==m.text||_.columnIndex!==m.columnIndex||_.flushToRight!==m.flushToRight)return!1}return!0}});return s.add(i,{name:"text"}),s.add(a,{name:"font"}),s.add(l,{name:"line-height"}),s.add(u,{name:"container"}),s.add(c,{name:"columns"}),s.add(f,{name:"obstacles"}),s.add(p,{name:"paragraph-spacing"}),s.add(h,{name:"segments"}),s.add(d,{name:"flow-lines"}),{graph:s,setText:g=>s.set("text",g),setFont:g=>s.set("font",g),setLineHeight:g=>s.set("line-height",g),setContainer:g=>s.set("container",g),setColumns:g=>s.set("columns",g),setObstacles:g=>s.set("obstacles",g),setParagraphSpacing:g=>s.set("paragraph-spacing",g),segments:h,flowLines:d}}0&&(module.exports={CanvasMeasureAdapter,CliMeasureAdapter,ImageSizeAdapter,NodeCanvasMeasureAdapter,PrecomputedAdapter,SvgBoundsAdapter,analyzeAndMeasure,carveTextLineSlots,circleIntervalForBand,computeBlockFlow,computeCharPositions,computeFlowLines,computeLineBreaks,computeTotalHeight,layoutNextLine,measureBlock,measureBlocks,reactiveBlockLayout,reactiveFlowLayout,reactiveLayout,rectIntervalForBand});
|
|
1
|
+
"use strict";var Qe=Object.defineProperty;var Mn=Object.getOwnPropertyDescriptor;var Dn=Object.getOwnPropertyNames;var Gn=Object.prototype.hasOwnProperty;var U=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ln=(e,t)=>{for(var n in t)Qe(e,n,{get:t[n],enumerable:!0})},In=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Dn(t))!Gn.call(e,s)&&s!==n&&Qe(e,s,{get:()=>t[s],enumerable:!(r=Mn(t,s))||r.enumerable});return e};var Pn=e=>In(Qe({},"__esModule",{value:!0}),e);function F(){return Math.trunc(performance.now()*1e6)}function Ae(){return Date.now()*1e6}var pe=U(()=>{"use strict"});function Mt(e,t){let n=new TextEncoder().encode(e.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${e.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=e.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let s=2+n.length+2+t.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${t.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=ut,o[i++]=n.length,o.set(n,i),i+=n.length,o[i++]=r>>>8&255,o[i++]=r&255,o.set(t,i),o}function Dt(e,t){if(e.length<At)throw new Error(`decodeEnvelope: bytes too short (${e.length} < ${At})`);let n=0,r=e[n++];if(r!==ut)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${ut})`);let s=e[n++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+s+2>e.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+s+2} bytes, have ${e.length})`);let o=new TextDecoder().decode(e.subarray(n,n+s));n+=s;let i=(e[n]<<8|e[n+1])>>>0;n+=2;let a=e.subarray(n),l=t.lookupCodec(o);if(l==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:l,codecVersion:i,payload:a}}function Gt(e){e.registerCodec($n)}var $n,ut,At,lt=U(()=>{"use strict";$n={name:"json",version:1,contentType:"application/json",encode(e){let t=JSON.stringify(e);return new TextEncoder().encode(t)},decode(e,t){let n=new TextDecoder().decode(e);return JSON.parse(n)}},ut=1,At=4});function Me(e){if(e==null)return ge;let{type:t,id:n,...r}=e;return{type:t??"system",id:n??"",...r}}var ge,ct=U(()=>{"use strict";ge={type:"system",id:""}});function De(){return me>0||ke}function Lt(){return me>0}function Se(e){me>0?Te.push(e):e()}function It(e){me+=1;let t=!1;try{e()}catch(n){throw t=!0,n}finally{if(me-=1,me===0)if(t){if(!ke){let n=Te.splice(0);for(let r of n)try{r()}catch{}de.length=0,fe.length=0,be.length=0}}else Bn()}}function Bn(){let e=!ke;e&&(ke=!0);let t=[],n=0;try{for(;de.length>0||fe.length>0||be.length>0||e&&Te.length>0;){if(e&&Te.length>0){let o=Te.splice(0);for(let i of o)try{i()}catch(a){t.push(a)}continue}if(n+=1,n>1e3)throw de.length=0,fe.length=0,be.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(de.length>0?de:fe.length>0?fe:be).splice(0);for(let o of s)try{o()}catch(i){t.push(i)}}}finally{e&&(ke=!1)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"batch drain: multiple callbacks threw")}function ye(e,t,n){if(t.length===0)return;if(t.length===1){let u=n(t[0][0]);if(u<3||!De()){e(t);return}(u>=5?be:u===4?fe:de).push(()=>e(t));return}let r=t.length,s=r,o=r,i=r,a=0;for(;a<r&&n(t[a][0])<3;)a++;for(s=a;a<r&&n(t[a][0])===3;)a++;for(o=a;a<r&&n(t[a][0])===4;)a++;i=a;let l=De();if(s>0){let u=t.slice(0,s);e(u)}if(o>s){let u=t.slice(s,o);l?de.push(()=>e(u)):e(u)}if(i>o){let u=t.slice(o,i);l?fe.push(()=>e(u)):e(u)}if(r>i){let u=t.slice(i,r);l?be.push(()=>e(u)):e(u)}}var me,ke,de,fe,be,Te,Ge=U(()=>{"use strict";me=0,ke=!1,de=[],fe=[],be=[],Te=[]});var Oe,B,X,te,Z,ne,ie,H,K,I,ve,dt,Fn,ft,Hn,jn,ht,Pt,$t,Bt,pt,Ne=U(()=>{"use strict";Oe=Symbol.for("graphrefly/START"),B=Symbol.for("graphrefly/DATA"),X=Symbol.for("graphrefly/DIRTY"),te=Symbol.for("graphrefly/RESOLVED"),Z=Symbol.for("graphrefly/INVALIDATE"),ne=Symbol.for("graphrefly/PAUSE"),ie=Symbol.for("graphrefly/RESUME"),H=Symbol.for("graphrefly/TEARDOWN"),K=Symbol.for("graphrefly/COMPLETE"),I=Symbol.for("graphrefly/ERROR"),ve=Object.freeze([X]),dt=Object.freeze([te]),Fn=Object.freeze([Z]),ft=Object.freeze([Oe]),Hn=Object.freeze([K]),jn=Object.freeze([H]),ht=Object.freeze([ve]),Pt=Object.freeze([dt]),$t=Object.freeze([Fn]),Bt=Object.freeze([Hn]),pt=Object.freeze([jn])});function Ft(e){e.registerMessageType(Oe,{tier:0,wireCrossing:!1}),e.registerMessageType(X,{tier:1,wireCrossing:!1}),e.registerMessageType(Z,{tier:1,wireCrossing:!1,metaPassthrough:!1}),e.registerMessageType(ne,{tier:2,wireCrossing:!1}),e.registerMessageType(ie,{tier:2,wireCrossing:!1}),e.registerMessageType(B,{tier:3,wireCrossing:!0}),e.registerMessageType(te,{tier:3,wireCrossing:!0}),e.registerMessageType(K,{tier:4,wireCrossing:!0,metaPassthrough:!1}),e.registerMessageType(I,{tier:4,wireCrossing:!0,metaPassthrough:!1}),e.registerMessageType(H,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Le,Ht=U(()=>{"use strict";Ne();Le=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(t){this._onMessage=t.onMessage,this._onSubscribe=t.onSubscribe,this._defaultVersioning=t.defaultVersioning,this._defaultHashFn=t.defaultHashFn,this.tierOf=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(t){this._assertUnfrozen(),this._onMessage=t}set onSubscribe(t){this._assertUnfrozen(),this._onSubscribe=t}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(t){this._assertUnfrozen(),this._defaultVersioning=t}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(t){this._assertUnfrozen(),this._defaultHashFn=t}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(t){this._inspectorEnabled=t}get globalInspector(){return this._globalInspector}set globalInspector(t){this._globalInspector=t}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(t){this._rigorRecorder=t}registerMessageType(t,n){return this._assertUnfrozen(),this._messageTypes.set(t,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(t){let n=this._messageTypes.get(t);return n!=null?n.tier:1}isWireCrossing(t){let n=this._messageTypes.get(t);return n!=null?n.wireCrossing:!0}isLocalOnly(t){return!this.isWireCrossing(t)}isMetaPassthrough(t){let n=this._messageTypes.get(t);return n!=null?n.metaPassthrough:!0}isKnownMessageType(t){return this._messageTypes.has(t)}registerCodec(t){return this._assertUnfrozen(),this._codecs.set(t.name,t),this}lookupCodec(t){return this._codecs.get(t)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function gt(e){let t=Vn.filter(n=>e({type:n,id:""},"write"));return t.length===0?"restricted":t.includes("human")&&t.includes("llm")&&t.every(n=>n==="human"||n==="llm"||n==="system")?"both":t.length===1?t[0]:t.join("+")}var q,Vn,Ie=U(()=>{"use strict";q=class extends Error{actor;action;nodeName;constructor(t,n){super(n??`GuardDenied: action "${String(t.action)}" denied for actor type "${String(t.actor.type)}"`),this.name="GuardDenied",this.actor=t.actor,this.action=t.action,this.nodeName=t.nodeName}get node(){return this.nodeName}},Vn=["human","llm","wallet","system"]});function mt(e){if(e===void 0)return null;if(typeof e=="number"){if(!Number.isFinite(e))throw new TypeError(`Cannot hash non-finite number: ${e}`);if(Number.isInteger(e)&&!Number.isSafeInteger(e))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${e}. Cross-language cid parity is not guaranteed for unsafe integers.`);return e}if(typeof e=="string"||typeof e=="boolean"||e===null)return e;if(Array.isArray(e))return e.map(mt);if(typeof e=="object"&&e!==null){let t={};for(let n of Object.keys(e).sort())t[n]=mt(e[n]);return t}return null}function Un(e){let t=zn.encode(e),n=t.length,r=n*8,s=n+9+63&-64,o=new Uint8Array(s);o.set(t),o[n]=128;let i=new DataView(o.buffer);i.setUint32(s-4,r>>>0,!1),i.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,l=3144134277,u=1013904242,c=2773480762,f=1359893119,p=2600822924,h=528734635,d=1541459225,g=new Uint32Array(64),v=(b,y)=>b>>>y|b<<32-y;for(let b=0;b<s;b+=64){for(let O=0;O<16;O++)g[O]=i.getUint32(b+O*4,!1);for(let O=16;O<64;O++){let E=g[O-15],R=g[O-2],L=v(E,7)^v(E,18)^E>>>3,V=v(R,17)^v(R,19)^R>>>10;g[O]=g[O-16]+L+g[O-7]+V>>>0}let y=a,_=l,m=u,x=c,k=f,T=p,S=h,C=d;for(let O=0;O<64;O++){let E=v(k,6)^v(k,11)^v(k,25),R=k&T^~k&S,L=C+E+R+Wn[O]+g[O]>>>0,V=v(y,2)^v(y,13)^v(y,22),J=y&_^y&m^_&m,ce=V+J>>>0;C=S,S=T,T=k,k=x+L>>>0,x=m,m=_,_=y,y=L+ce>>>0}a=a+y>>>0,l=l+_>>>0,u=u+m>>>0,c=c+x>>>0,f=f+k>>>0,p=p+T>>>0,h=h+S>>>0,d=d+C>>>0}let w=b=>b.toString(16).padStart(8,"0");return w(a)+w(l)+w(u)+w(c)+w(f)+w(p)+w(h)+w(d)}function bt(e){let t=mt(e??null),n=JSON.stringify(t);return Un(n).slice(0,16)}function Kn(){let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();let t=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=t()+t()+t()+t();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function yt(e,t,n){let r=n?.id??Kn();if(e===0)return{id:r,version:0};let o=(n?.hash??bt)(t);return{id:r,version:0,cid:o,prev:null}}function jt(e,t,n){e.version+=1,"cid"in e&&(e.prev=e.cid,e.cid=n(t))}var Wn,zn,Vt=U(()=>{"use strict";Wn=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),zn=new TextEncoder});function Ut(e){return{node:e,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function vt(e){e.prevData=void 0,e.dirty=!1,e.involvedThisWave=!1,e.dataBatch.length=0,e.terminal=void 0}function Pe(e){return e.length===0?e:typeof e[0]=="symbol"?[e]:e}function re(e,t,n){let r=Kt(e)?e:[],s=typeof e=="function"?e:typeof t=="function"?t:void 0,o={};return Kt(e)?o=(xt(t)?t:n)??{}:xt(e)?o=e:o=(xt(t)?t:n)??{},new P(r,s,o)}var Wt,zt,qn,Yn,ae,P,Kt,xt,se=U(()=>{"use strict";lt();ct();Ge();pe();Ht();Ie();Ne();Vt();Wt=()=>{},zt=100;qn=(e,t,n,r)=>{n.direction==="down-in"&&e._onDepMessage(n.depIndex,t)},Yn=(e,t,n,r)=>{let s=e;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[ft]:[ft,[B,o]];s._status==="dirty"&&i.push(ve),ye(t,i,s._config.tierOf)},ae=new Le({onMessage:qn,onSubscribe:Yn});Ft(ae);Gt(ae);P=class e{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(t,n,r){this._config=r.config??ae,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=t.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??bt;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?yt(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=t.map(Ut);let o={};for(let[a,l]of Object.entries(r.meta??{})){let u={initial:l,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),o[a]=new e([],void 0,u)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[B,a]])},down(a){i._emit(Pe(a))},up(a){i._emitUp(Pe(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(t,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&t<=r)return;let s=n?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,l=i?.version??0,u=yt(t,o,{id:a,hash:s});u.version=l,this._versioning=u,this._versioningLevel=t}_setInspectorHook(t){return t==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(t),()=>{this._inspectorHooks?.delete(t),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(t){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(t),()=>{this._extraGuards?.delete(t),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(t){if(this._guard==null&&this._extraGuards==null)return!0;let n=Me(t);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(t){if(t?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=t?.actor!=null;if(!n&&!r)return;let s=Me(t?.actor),o=t?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new q({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new q({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Ae()}}down(t,n){let r=Pe(t);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(t,n){this._checkGuard(n),this._emit([[B,t]])}up(t,n){if(this._deps.length===0)return;let r=Pe(t);if(r.length===0)return;this._checkGuard(n);let s=n??{internal:!0};this._validateUpTiers(r);for(let o of this._deps)o.node.up?.(r,s)}_emitUp(t){if(this._deps.length!==0&&t.length!==0){this._validateUpTiers(t);for(let n of this._deps)n.node.up?.(t,{internal:!0})}}_validateUpTiers(t){let n=this._config.tierOf;for(let r of t){let s=n(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(t,n){if(n!=null&&this._guard!=null){let l=Me(n);if(!this._guard(l,"observe"))throw new q({actor:l,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let l of this._deps)vt(l);if(this._partial===!1){for(let l of this._deps)if(l.prevData!==void 0||l.dataBatch.length!==0||l.terminal!==void 0||l.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,t,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(l){throw this._sinkCount-=1,l}this._sinks==null?this._sinks=t:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,t]):this._sinks.add(t);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(l){if(this._sinkCount-=1,this._removeSink(t),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw l}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(t),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(t){if(this._sinks===t)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(t),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let t=this._deps.length,n=0;try{for(let r=0;r<t;r++){let s=r,o=this._deps[r];o.unsub=Wt,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,l=!1;for(let u of i)a(u[0])>=3&&(l=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:s},this._actions);l&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let s=0;s<n;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}vt(o)}}throw this._dirtyDepCount=0,r}}_addDep(t){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===t)return s;let n=this._deps.length,r=Ut(t);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ht),r.unsub=Wt;try{r.unsub=t.subscribe(s=>{if(r.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return n}_deactivate(t=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[I,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[I,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let r of this._deps){if(r.unsub!=null){let s=r.unsub;r.unsub=null;try{s()}catch{}}vt(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),t||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(t,n){let r=this._deps[t],s=n[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:t,message:n};for(let i of this._inspectorHooks)i(o)}if(s!==Oe){if(s===X){this._depDirtied(r);return}if(s===Z){if(this._depInvalidated(r),this._cached===void 0)return;this._emit($t);return}if(s===ne||s===ie){this._emit([n]);return}if(s===H){this._emit(pt);return}if(s===B)this._depSettledAsData(r,n[1]);else if(s===te)this._depSettledAsResolved(r);else if(s===K)this._depSettledAsTerminal(r,!0);else if(s===I)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===B||s===te)&&this._emit([n]),(s===K||s===I)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(t){t.dirty||(t.dirty=!0,t.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ht))}_depSettledAsData(t,n){t.dirty&&(t.dirty=!1,this._dirtyDepCount--),t.involvedThisWave=!0,t.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(t){t.dirty&&(t.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(t,n){t.dirty&&(t.dirty=!1,this._dirtyDepCount--),t.terminal=n,t.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(t){t.prevData=void 0,t.terminal=void 0,t.dataBatch.length=0,t.dirty?t.involvedThisWave=!1:(t.dirty=!0,t.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let t=0;t<this._deps.length;t++){let n=this._deps[t];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Pt),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let t=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(t!=null){this._autoError&&this._emit([[I,t.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(Bt)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let t=this._cleanup;if(typeof t=="function"){this._cleanup=void 0;try{t()}catch(i){this._emit([[I,this._wrapFnError("cleanup threw",i)]]);return}}else if(t!=null&&typeof t=="object"){let i=t.beforeRun;if(typeof i=="function"){t.beforeRun=void 0;try{i()}catch(a){this._emit([[I,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[I,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>zt?(this._rerunDepth=0,this._emit([[I,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${zt} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let t of this._deps)t.involvedThisWave=!1,t.dataBatch.length=0}_wrapFnError(t,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${t}: ${r}`,{cause:n})}_frameBatch(t){let n=this._config.tierOf;if(t.length===1)return n(t[0][0])===3&&this._status!=="dirty"?[ve,t[0]]:t;let r=!0,s=!1,o=!1,i=-1;for(let l of t){let u=n(l[0]);u<i&&(r=!1),u===3&&(s=!0),l[0]===X&&(o=!0),i=u}let a=t;if(!r){let l=t.map((u,c)=>({m:u,i:c,tier:n(u[0])}));l.sort((u,c)=>u.tier-c.tier||u.i-c.i),a=l.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let l=0;for(;l<a.length&&n(a[l][0])===0;)l++;return l===0?[ve,...a]:[...a.slice(0,l),ve,...a.slice(l)]}return a}_emit(t){if(t.length===0)return;for(let a=0;a<t.length;a++){let l=t[a];if(l[0]===I&&l[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=t;if(this._isTerminal&&!this._resubscribable){let a=t.filter(l=>l[0]===H||l[0]===Z);if(a.length===0)return;n=a}n=this._frameBatch(n);let s=null;for(let a=0;a<n.length;a++){let l=n[a],u=l[0];if(u!==ne&&u!==ie){s?.push(l);continue}if(l.length<2)throw new Error(`Node "${this.name}": [[${u===ne?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let f=l[1];if(u===ne)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))c=!1;else if(this._pauseLocks.delete(f),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?s?.push(l):s==null&&(s=n.slice(0,a))}if(s!=null){if(s.length===0)return;n=s}if(this._hasMeta&&n.some(a=>a[0]===H))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(pt)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(n);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,l=[];for(let u of o)a(u[0])===3?this._pauseBuffer.push(u):l.push(u);l.length>0&&this._dispatchOrAccumulate(l)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[I,i]])}_updateState(t){let n=this._config.tierOf,r,s,o=-1,i=0;for(let c of t)n(c[0])===3&&i++;let a=i<=1,l=-1;if(this._versioning!=null&&i>1){for(let c=t.length-1;c>=0;c--)if(t[c][0]===B){l=c;break}}for(let c=0;c<t.length;c++){let f=t[c],p=f[0];if(p===B){if(f.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,f[1])}catch(d){s=this._wrapFnError("equals threw",d),o=c;break}if(h){r==null&&(r=t.slice(0,c)),r.push(dt),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(l<0||c===l)&&jt(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),p===X)this._status="dirty";else if(p===te)this._status="resolved";else if(p===K){this._status="completed";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===I){this._status="errored";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===Z){if(this._cached!==void 0){let d=this._config.rigorRecorder;if(d!=null)try{d.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let d=h.invalidate;if(typeof d=="function")try{d()}catch{}}}else p===H&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=o>=0?r??t.slice(0,o):r??t;return s!=null?{finalMessages:u,equalsError:s}:{finalMessages:u}}_deliverToSinks=t=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(t);return}let n=[...this._sinks];for(let r of n)r(t)};_dispatchOrAccumulate(t){if(Lt()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Se(()=>this._flushBatchPending()));for(let n of t)this._batchPendingMessages.push(n);return}ye(this._deliverToSinks,t,this._config.tierOf)}_flushBatchPending(){let t=this._batchPendingMessages;if(t===null||(this._batchPendingMessages=null,t.length===0))return;let n=this._frameBatch(t);ye(this._deliverToSinks,n,this._config.tierOf)}},Kt=e=>Array.isArray(e),xt=e=>typeof e=="object"&&e!=null&&!Array.isArray(e)});function G(e,t){return re([],{...t,initial:e})}function qt(e,t){return re((r,s,o)=>e(s,o)??void 0,{describeKind:"producer",...t})}function Y(e,t,n){return re(e,(s,o,i)=>{let a=s.map((l,u)=>l!=null&&l.length>0?l.at(-1):i.prevData[u]);o.emit(t(a,i))},{describeKind:"derived",...n})}var Ee=U(()=>{"use strict";se()});function _t(e){return e.subscribe(()=>{})}var Yt=U(()=>{"use strict"});var Be,Jt=U(()=>{"use strict";Be=class{_timer;_gen=0;start(t,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},t)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var rs={};Ln(rs,{CanvasMeasureAdapter:()=>st,CliMeasureAdapter:()=>tt,ImageSizeAdapter:()=>at,NodeCanvasMeasureAdapter:()=>ot,PrecomputedAdapter:()=>rt,SvgBoundsAdapter:()=>it,analyzeAndMeasure:()=>we,carveTextLineSlots:()=>Et,circleIntervalForBand:()=>Cn,computeBlockFlow:()=>Nn,computeCharPositions:()=>qe,computeFlowLines:()=>An,computeLineBreaks:()=>Ke,computeTotalHeight:()=>En,layoutNextLine:()=>Nt,measureBlock:()=>Sn,measureBlocks:()=>On,reactiveBlockLayout:()=>es,reactiveFlowLayout:()=>ns,reactiveLayout:()=>Qr,rectIntervalForBand:()=>Rn});module.exports=Pn(rs);function et(e){return e>=768&&e<=879||e>=1155&&e<=1161||e>=1425&&e<=1469||e>=1552&&e<=1562||e>=1611&&e<=1631||e>=1648&&e===1648||e>=1750&&e<=1756||e>=1759&&e<=1764||e>=1767&&e<=1768||e>=1770&&e<=1773||e>=1840&&e<=1866||e>=1958&&e<=1968||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2641||e>=2672&&e<=2673||e>=2677&&e===2677||e>=3633&&e===3633||e>=3636&&e<=3642||e>=3655&&e<=3662||e>=3761&&e===3761||e>=3764&&e<=3772||e>=3784&&e<=3790||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65024&&e<=65039||e>=65056&&e<=65071||e===8205?0:e>=4352&&e<=4447||e>=8986&&e<=8987||e>=9001&&e<=9002||e>=9193&&e<=9203||e>=9208&&e<=9210||e>=9725&&e<=9726||e>=9748&&e<=9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e>=9898&&e<=9899||e>=9917&&e<=9918||e>=9924&&e<=9925||e===9934||e===9940||e===9962||e>=9970&&e<=9971||e===9973||e===9978||e===9981||e===9986||e===9989||e>=9992&&e<=9997||e===9999||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e>=10548&&e<=10549||e>=11013&&e<=11015||e>=11035&&e<=11036||e===11088||e===11093||e>=11904&&e<=12350||e>=12352&&e<=12447||e>=12448&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12784&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=40959||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65131||e>=65281&&e<=65376||e>=65504&&e<=65510||e>=126980&&e===126980||e===127183||e>=127344&&e<=127345||e===127358||e===127359||e===127374||e>=127377&&e<=127386||e>=127456&&e<=127487||e>=127488&&e<=127490||e===127514||e===127535||e>=127538&&e<=127546||e>=127568&&e<=127569||e>=127744&&e<=129535||e>=129536&&e<=129791||e>=129792&&e<=130047||e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}function he(e){let t=0;for(let n of e)t+=et(n.codePointAt(0));return t}function Rt(e,t){if(t<=0)return"";let n=0,r="";for(let s of e){let o=et(s.codePointAt(0));if(n+o>t){if(t<=1)return"\u2026";for(;n+1>t&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=et(i.codePointAt(0))}return`${r}\u2026`}r+=s,n+=o}return r}var tt=class{cellPx;constructor(t){this.cellPx=t?.cellPx??8}measureSegment(t,n){return{width:he(t)*this.cellPx}}},nt=class extends Error{name="KeyError"},rt=class{metrics;fallback;constructor(t){this.metrics=t.metrics;let n=t.fallback??"per-char";if(n!=="per-char"&&n!=="error")throw new Error(`fallback must be 'per-char' or 'error', got ${JSON.stringify(t.fallback)}`);this.fallback=n}measureSegment(t,n){let r=this.metrics[n];if(r){let o=r[t];if(o!==void 0)return{width:o}}if(this.fallback==="error")throw new nt(`PrecomputedAdapter: no metrics for segment ${JSON.stringify(t)} in font ${JSON.stringify(n)}`);let s=0;if(r)for(let o of t){let i=r[o];i!==void 0&&(s+=i)}return{width:s}}},st=class{ctx=null;currentFont="";emojiCorrection;constructor(t){this.emojiCorrection=t?.emojiCorrection??1}getContext(){if(!this.ctx){if(typeof OffscreenCanvas>"u")throw new Error("CanvasMeasureAdapter requires a browser environment with OffscreenCanvas support. Use CliMeasureAdapter or NodeCanvasMeasureAdapter for Node.js.");let n=new OffscreenCanvas(0,0).getContext("2d");if(!n)throw new Error("CanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(t,n){let r=this.getContext();n!==this.currentFont&&(r.font=n,this.currentFont=n);let s=r.measureText(t).width;return this.emojiCorrection!==1&&new RegExp("\\p{Emoji_Presentation}","u").test(t)&&(s*=this.emojiCorrection),{width:s}}clearCache(){this.currentFont=""}},ot=class{ctx=null;currentFont="";canvasModule;constructor(t){this.canvasModule=t}getContext(){if(!this.ctx){let n=this.canvasModule.createCanvas(0,0).getContext("2d");if(!n)throw new Error("NodeCanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(t,n){let r=this.getContext();return n!==this.currentFont&&(r.font=n,this.currentFont=n),{width:r.measureText(t).width}}clearCache(){this.currentFont=""}},it=class{measureSvg(t){let n=t.match(/viewBox\s*=\s*["']([^"']+)["']/);if(n){let o=n[1].trim().split(/[\s,]+/);if(o.length>=4){let i=Number.parseFloat(o[2]),a=Number.parseFloat(o[3]);if(Number.isFinite(i)&&Number.isFinite(a)&&i>0&&a>0)return{width:i,height:a};throw new Error("SvgBoundsAdapter: viewBox width/height are missing, non-finite, or not positive")}}let r=t.match(/<svg[^>]*\bwidth\s*=\s*["']?([\d.]+)/),s=t.match(/<svg[^>]*\bheight\s*=\s*["']?([\d.]+)/);if(r&&s){let o=Number.parseFloat(r[1]),i=Number.parseFloat(s[1]);if(Number.isFinite(o)&&Number.isFinite(i)&&o>0&&i>0)return{width:o,height:i};throw new Error("SvgBoundsAdapter: svg width/height attributes are non-finite or not positive")}throw new Error("SvgBoundsAdapter: cannot determine dimensions \u2014 SVG has no viewBox or width/height attributes")}},at=class{sizes;constructor(t){this.sizes=new Map(Object.entries(t))}measureImage(t){let n=this.sizes.get(t);if(!n)throw new Error(`ImageSizeAdapter: no dimensions registered for ${JSON.stringify(t)}`);return{width:n.width,height:n.height}}};pe();se();Ee();ct();Ge();pe();Ie();Ne();Ie();se();function $e(e,t){if(t!=null&&t.length>0)return new Set(t);switch(e){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;default:return new Set(["type","deps"])}}function Jn(e){return e._describeKind!=null?e._describeKind:e._deps.length>0?"derived":e._fn!=null?"producer":"state"}function Xn(e){let t={};for(let[n,r]of Object.entries(e.meta))try{t[n]=r.cache}catch{}return t}function wt(e,t){let n=t==null,r=!n&&t!=null?[...t].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,s=n||t.has("meta")||r!=null&&r.length>0,o="state",i=[];e instanceof P&&(o=Jn(e),i=e._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(n||t.has("status"))&&(a.status=e.status);let l=e instanceof P?e._guard:void 0;if(s){let u={...Xn(e)};if(l!=null&&u.access===void 0&&(u.access=gt(l)),r!=null&&r.length>0&&!t.has("meta")){let c={};for(let f of r)f in u&&(c[f]=u[f]);a.meta=c}else a.meta=u}if(e.name!=null&&(a.name=e.name),n||t.has("value")){e.status==="sentinel"&&(a.sentinel=!0);try{a.value=e.cache}catch{}}if((n||t.has("v"))&&e.v!=null){let u={id:e.v.id,version:e.v.version};"cid"in e.v&&(u.cid=e.v.cid,u.prev=e.v.prev),a.v=u}return(n||t.has("guard"))&&l!=null&&(a.guard=gt(l)),(n||t.has("lastMutation"))&&e.lastMutation!=null&&(a.lastMutation=e.lastMutation),a}se();Ee();Yt();Jt();var Ce=class{constructor(t){this.capacity=t;if(!Number.isInteger(t)||t<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${t})`);this.buf=new Array(t)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(t){let n=(this.head+this._size)%this.capacity;this.buf[n]=t,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let t=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,t}at(t){if(this._size===0)return;let n=t<0?this._size+t:t;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let t=new Array(this._size);for(let n=0;n<this._size;n++)t[n]=this.buf[(this.head+n)%this.capacity];return t}clear(){for(let t=0;t<this._size;t++)this.buf[(this.head+t)%this.capacity]=void 0;this.head=0,this._size=0}};lt();var Zn={horizontal:"\u2500",vertical:"\u2502",cornerTL:"\u250C",cornerTR:"\u2510",cornerBL:"\u2514",cornerBR:"\u2518",tDown:"\u252C",tUp:"\u2534",tRight:"\u251C",tLeft:"\u2524",cross:"\u253C",arrowRight:"\u25B6",arrowDown:"\u25BC",arrowLeft:"\u25C0",arrowUp:"\u25B2",boxTL:"\u250C",boxTR:"\u2510",boxBL:"\u2514",boxBR:"\u2518",boxH:"\u2500",boxV:"\u2502"},Qn={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function en(e,t){let n=t.charset==="ascii"?Qn:Zn,r=e.width,s=e.height,o=Array.from({length:s},()=>Array.from({length:r},()=>" ")),i=Array.from({length:s},()=>Array.from({length:r},()=>"empty"));for(let a of e.edges)tr(o,i,n,a);for(let a of e.boxes)er(o,i,n,a,t.labelOf(a.id));return o.map(a=>or(a.join(""))).join(`
|
|
2
|
+
`)}function er(e,t,n,r,s){let{x:o,y:i,w:a,h:l}=r;if(a<2||l<2){l>0&&Xt(e,t,o,i,a,s);return}ue(e,t,o,i,n.boxTL);for(let c=o+1;c<o+a-1;c+=1)ue(e,t,c,i,n.boxH);ue(e,t,o+a-1,i,n.boxTR);for(let c=i+1;c<i+l-1;c+=1){ue(e,t,o,c,n.boxV);for(let f=o+1;f<o+a-1;f+=1)tn(e,t,f,c," ","empty");ue(e,t,o+a-1,c,n.boxV)}ue(e,t,o,i+l-1,n.boxBL);for(let c=o+1;c<o+a-1;c+=1)ue(e,t,c,i+l-1,n.boxH);ue(e,t,o+a-1,i+l-1,n.boxBR);let u=i+Math.floor(l/2);Xt(e,t,o+1,u,a-2,s)}function ue(e,t,n,r,s){tn(e,t,n,r,s,s===" "?"empty":s==="\u2500"||s==="-"?"boxH":s==="\u2502"||s==="|"?"boxV":"boxCorner")}function tn(e,t,n,r,s,o){if(r<0||r>=e.length)return;let i=e[r];n<0||n>=i.length||(i[n]=s,t[r][n]=o)}function Xt(e,t,n,r,s,o){if(r<0||r>=e.length)return;let i=n,a=s;for(let l of o){let u=he(l);if(u!==0){if(a<u)break;i>=0&&i<e[r].length&&(e[r][i]=l,t[r][i]="label",u===2&&i+1<e[r].length&&(e[r][i+1]="",t[r][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<e[r].length&&(e[r][i]=" ",t[r][i]="empty"),i+=1,a-=1}function tr(e,t,n,r){let s=r.points;if(s.length<2)return;for(let l=0;l+1<s.length;l+=1)nr(e,t,n,s[l],s[l+1]);for(let l=1;l+1<s.length;l+=1){let u=s[l-1],c=s[l],f=s[l+1],p=rr(u,c,f,n);p&&Qt(e,t,c.x,c.y,p,"edgeCorner")}let o=s[s.length-1],i=s[s.length-2],a=sr(i,o,n);a&&Qt(e,t,o.x,o.y,a,"arrow")}function nr(e,t,n,r,s){if(!(r.x===s.x&&r.y===s.y)){if(r.y===s.y){let o=r.y,i=Math.min(r.x,s.x),a=Math.max(r.x,s.x);for(let l=i;l<=a;l+=1)Zt(e,t,l,o,n,"h")}else if(r.x===s.x){let o=r.x,i=Math.min(r.y,s.y),a=Math.max(r.y,s.y);for(let l=i;l<=a;l+=1)Zt(e,t,o,l,n,"v")}}}function Zt(e,t,n,r,s,o){if(r<0||r>=e.length)return;let i=e[r];if(n<0||n>=i.length)return;let a=t[r][n];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[n]=o==="h"?s.horizontal:s.vertical,t[r][n]=o==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&o==="v"){i[n]=s.cross,t[r][n]="edgeCorner";return}if(a==="edgeV"&&o==="h"){i[n]=s.cross,t[r][n]="edgeCorner";return}}}function Qt(e,t,n,r,s,o){if(r<0||r>=e.length)return;let i=e[r];if(n<0||n>=i.length)return;let a=t[r][n];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[n]=s,t[r][n]=o)}function rr(e,t,n,r){let s=e.y===t.y,o=t.y===n.y;if(s===o)return;if(s){let l=e.x<t.x,u=n.y>t.y;return l&&u?r.cornerTR:l&&!u?r.cornerBR:!l&&u?r.cornerTL:r.cornerBL}let i=e.y<t.y,a=n.x>t.x;return i&&a?r.cornerBL:i&&!a?r.cornerBR:!i&&a?r.cornerTL:r.cornerTR}function sr(e,t,n){if(t.x>e.x)return n.arrowRight;if(t.x<e.x)return n.arrowLeft;if(t.y>e.y)return n.arrowDown;if(t.y<e.y)return n.arrowUp}function or(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===32;)t-=1;return e.slice(0,t)}function sn(e){let t=ir(e);ar(t),ur(t),lr(t),cr(t,e);let n=hr(t,e),{width:r,height:s}=gr(t),o=[];for(let i of t.layers)for(let a of i)a.isVirtual||o.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:o,edges:n,width:r,height:s}}function ir(e){let t=new Map;for(let s of e.nodes)t.set(s,{id:s,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:e.widthCells(s),h:e.heightCells(s),in:[],out:[]});let n=[],r=0;for(let s of e.edges){if(s.from===s.to)continue;let o=t.get(s.from),i=t.get(s.to);if(!o||!i)continue;let a={chainId:r++,chainFrom:s.from,chainTo:s.to,fromId:s.from,toId:s.to,hopIndex:0,chainLen:1};o.out.push(a),i.in.push(a),n.push(a)}return{nodes:t,layers:[],hops:n}}function ar(e){let t=new Map;for(let o of e.nodes.values())t.set(o.id,o.in.length);let n=[];for(let o of e.nodes.values())(t.get(o.id)??0)===0&&(o.layer=0,n.push(o));let r=new Set,s=0;for(;s<n.length;){let o=n[s++];if(!r.has(o.id)){r.add(o.id);for(let i of o.out){let a=e.nodes.get(i.toId);a.layer=Math.max(a.layer,o.layer+1);let l=(t.get(a.id)??0)-1;t.set(a.id,l),l<=0&&n.push(a)}}}for(let o of e.nodes.values())o.layer<0&&(o.layer=0)}function ur(e){let t=Math.max(0,...Array.from(e.nodes.values(),o=>o.layer)),n=Array.from({length:t+1},()=>[]);for(let o of e.nodes.values())n[o.layer].push(o);let r=[],s=0;for(let o of e.hops){let i=e.nodes.get(o.fromId),a=e.nodes.get(o.toId),l=a.layer-i.layer;if(l<=0){i.out=i.out.filter(f=>f!==o),a.in=a.in.filter(f=>f!==o);continue}if(l===1){o.hopIndex=0,o.chainLen=1,r.push(o);continue}i.out=i.out.filter(f=>f!==o),a.in=a.in.filter(f=>f!==o);let u=i;for(let f=1;f<l;f+=1){let p=`__virt_${s++}__`,h={id:p,isVirtual:!0,layer:i.layer+f,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};e.nodes.set(p,h),n[h.layer].push(h);let d={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:p,hopIndex:f-1,chainLen:l};u.out.push(d),h.in.push(d),r.push(d),u=h}let c={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:a.id,hopIndex:l-1,chainLen:l};u.out.push(c),a.in.push(c),r.push(c)}for(let o of n)for(let i=0;i<o.length;i+=1)o[i].order=i;e.layers=n,e.hops=r}function lr(e){for(let n=0;n<4;n+=1){for(let r=1;r<e.layers.length;r+=1)nn(e,e.layers[r],"in"),Fe(e.layers[r]);for(let r=e.layers.length-2;r>=0;r-=1)nn(e,e.layers[r],"out"),Fe(e.layers[r])}for(let n=0;n<2;n+=1){let r=!1;for(let s=1;s<e.layers.length;s+=1){let o=e.layers[s];for(let i=0;i+1<o.length;i+=1){let a=rn(e,o[i],o[i+1],"in");[o[i],o[i+1]]=[o[i+1],o[i]],Fe(o),rn(e,o[i],o[i+1],"in")<a?r=!0:([o[i],o[i+1]]=[o[i+1],o[i]],Fe(o))}}if(!r)break}}function nn(e,t,n){let r=new Map;for(let s of t){let o=n==="in"?s.in:s.out;if(o.length===0){r.set(s.id,s.order);continue}let i=0,a=0;for(let l of o){let u=e.nodes.get(n==="in"?l.fromId:l.toId);u&&(i+=u.order,a+=1)}r.set(s.id,a===0?s.order:i/a)}t.sort((s,o)=>{let i=r.get(s.id),a=r.get(o.id);return i!==a?i-a:s.order-o.order})}function Fe(e){for(let t=0;t<e.length;t+=1)e[t].order=t}function rn(e,t,n,r){let s=r==="in"?t.in:t.out,o=r==="in"?n.in:n.out,i=0;for(let a of s)for(let l of o){let u=e.nodes.get(r==="in"?a.fromId:a.toId)?.order??0,c=e.nodes.get(r==="in"?l.fromId:l.toId)?.order??0;(t.order<n.order&&u>c||t.order>n.order&&u<c)&&(i+=1)}return i}function cr(e,t){t.direction==="LR"?dr(e,t):fr(e,t)}function dr(e,t){let n=[],r=0;for(let s=0;s<e.layers.length;s+=1){n.push(r);let o=0;for(let i of e.layers[s])o=Math.max(o,i.w);r+=o+t.layerGap}for(let s=0;s<e.layers.length;s+=1)for(let o of e.layers[s])o.x=n[s];for(let s of e.layers){let o=0;for(let i of s)i.y=o,o+=i.h+t.nodeGap}on(e,t,"y")}function fr(e,t){let n=[],r=0;for(let s=0;s<e.layers.length;s+=1){n.push(r);let o=0;for(let i of e.layers[s])o=Math.max(o,i.h);r+=o+t.layerGap}for(let s=0;s<e.layers.length;s+=1)for(let o of e.layers[s])o.y=n[s];for(let s of e.layers){let o=0;for(let i of s)i.x=o,o+=i.w+t.nodeGap}on(e,t,"x")}function on(e,t,n){let r=o=>n==="y"?o.h:o.w,s=t.nodeGap;for(let o=0;o<2;o+=1){let i=o===0?e.layers.slice(1):e.layers.slice(0,-1).reverse();for(let a of i){let l=new Map;for(let c of a){let f=o===0?c.in:c.out;if(f.length===0)continue;let p=[];for(let d of f){let g=e.nodes.get(o===0?d.fromId:d.toId);if(!g)continue;let v=n==="y"?g.y:g.x;p.push(v+Math.floor(r(g)/2))}if(p.length===0)continue;p.sort((d,g)=>d-g);let h=p[Math.floor(p.length/2)];l.set(c.id,h-Math.floor(r(c)/2))}let u=0;for(let c of a){let f=l.get(c.id),p=n==="y"?c.y:c.x,d=Math.max(f??p,u);n==="y"?c.y=d:c.x=d,u=d+r(c)+s}}}}function hr(e,t){let n=new Map;for(let u of e.hops){let c=n.get(u.chainId);c?c.push(u):n.set(u.chainId,[u])}for(let u of n.values())u.sort((c,f)=>c.hopIndex-f.hopIndex);let r=t.direction==="LR",s=u=>r?u.x:u.y,o=u=>r?u.w:u.h,i=u=>r?u.y+Math.floor(u.h/2):u.x+Math.floor(u.w/2),a=new Map;for(let u=0;u+1<e.layers.length;u+=1){let c=e.layers[u],f=e.layers[u+1],p=0;for(let T of c)p=Math.max(p,s(T)+o(T));let h=Number.POSITIVE_INFINITY;for(let T of f)h=Math.min(h,s(T));let d=Number.isFinite(h)?h-1:p,g=Math.max(1,d-p+1),v=[];for(let T of c)for(let S of T.out)v.push(S);v.sort((T,S)=>{let C=i(e.nodes.get(T.fromId)),O=i(e.nodes.get(S.fromId));if(C!==O)return C-O;let E=i(e.nodes.get(T.toId)),R=i(e.nodes.get(S.toId));return E-R});let w=[],b=new Map;for(let T of v){let S=i(e.nodes.get(T.fromId)),C=i(e.nodes.get(T.toId)),O=Math.min(S,C),E=Math.max(S,C),R=-1;for(let L=0;L<w.length;L+=1){let V=w[L],J=!0;for(let ce of V)if(ce.lo<=E&&O<=ce.hi){J=!1;break}if(J){V.push({lo:O,hi:E}),R=L;break}}R<0&&(w.push([{lo:O,hi:E}]),R=w.length-1),b.set(T,R)}let y=w.length,_=g>=Math.max(3,y+2),m=_?p+1:p,x=_?d-1:d,k=Math.max(1,x-m+1);for(let T of v){let S=b.get(T),C;if(y<=1)C=m+Math.floor(k/2);else{let O=(k-1)/(y-1);C=m+Math.floor(S*O)}a.set(T,Math.max(p,Math.min(d,C)))}}let l=[];for(let[,u]of n){let c=[];for(let p=0;p<u.length;p+=1){let h=u[p],d=e.nodes.get(h.fromId),g=e.nodes.get(h.toId),v=a.get(h),w=d.isVirtual?s(d):s(d)+o(d),b=g.isVirtual?s(g):s(g)-1,y=i(d),_=i(g);p===0&&He(c,r,w,y),y!==_&&(He(c,r,v,y),He(c,r,v,_)),He(c,r,b,_)}let f=u[0];l.push({from:f.chainFrom,to:f.chainTo,points:pr(c)})}return l}function He(e,t,n,r){e.push(t?{x:n,y:r}:{x:r,y:n})}function pr(e){let t=[];for(let n of e){let r=t[t.length-1];(!r||r.x!==n.x||r.y!==n.y)&&t.push(n)}return t}function gr(e){let t=0,n=0;for(let r of e.layers)for(let s of r)t=Math.max(t,s.x+s.w),n=Math.max(n,s.y+s.h);return{width:t,height:n}}var mr=24,br=4,yr=1,vr=3;function an(e,t){let n=xr(t.direction),r=Math.max(3,t.maxLabelWidth??mr),s=t.asciiCharset??"unicode",o=Object.keys(e.nodes).sort(),i=new Set(o),a=e.edges.filter(h=>i.has(h.from)&&i.has(h.to)),l=new Map,u=new Map;for(let h of o){let d=Rt(h,r);l.set(h,d),u.set(h,he(d)+4)}let c=sn({nodes:o,edges:a,widthCells:h=>u.get(h)??3,heightCells:()=>vr,layerGap:br,nodeGap:yr,direction:n}),f=en(c,{charset:s,labelOf:h=>l.get(h)??h}),p=t.logger;return p&&p(f),f}function xr(e){if(e===void 0||e==="LR")return"LR";if(e==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(e)}`)}function un(e,t,n,r={}){let s=t in e.nodes,o=n in e.nodes;if(!s)return je(t,n,"no-such-from");if(!o)return je(t,n,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(t===n){if(r.findCycle===!0){let u=wr(e,t,r);if(u!=null)return u}let l=Ve(t,e.nodes[t],0,r);return We(t,n,[l])}if(i===0)return je(t,n,"no-path");let a=ln(e,t,n,i);return a.found?We(t,n,cn(e,a.pathOrder,r)):je(t,n,a.truncated?"max-depth-exceeded":"no-path")}function ln(e,t,n,r){let s=new Map,o=[{path:n,depth:0}],i=new Set([n]),a=0,l=!1;for(;a<o.length;){let f=o[a++];if(f.path===t)break;if(r!=null&&f.depth>=r){let g=e.nodes[f.path];g?.deps&&g.deps.length>0&&(l=!0);continue}let p=e.nodes[f.path];if(p==null)continue;let h=p.deps??[],d=new Map;for(let g=0;g<h.length;g++){let v=h[g];if(!v)continue;let w=d.get(v);w==null&&(w=[],d.set(v,w)),w.push(g)}for(let[g,v]of d)i.has(g)||(i.add(g),s.set(g,{from:f.path,depIndices:v}),o.push({path:g,depth:f.depth+1}))}if(!s.has(t))return{found:!1,pathOrder:[],truncated:l};let u=[{path:t}],c=t;for(;c!==n;){let f=s.get(c);if(f==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=f.depIndices,u.push({path:f.from}),c=f.from}return{found:!0,pathOrder:u,truncated:!1}}function wr(e,t,n){let r=e.nodes[t];if(r==null)return null;let s=r.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===t&&o.push(a);if(o.length>0){let a=Ve(t,r,0,n);a.dep_index=o[0];let l=Ve(t,r,1,n);return We(t,t,[a,l])}let i=null;for(let a=0;a<s.length;a++){let l=s[a];if(!l||l===t)continue;let u=ln(e,l,t,n.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:t,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:We(t,t,cn(e,i.pathOrder,n))}function cn(e,t,n){return t.map((r,s)=>{let o=e.nodes[r.path],i=Ve(r.path,o,s,n);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function Ve(e,t,n,r){let s={path:e,type:t.type,hop:n};t.status!==void 0&&(s.status=t.status),"value"in t&&(s.value=t.value),t.v!=null&&(s.v=t.v);let o=r.annotations?.get(e)??t.annotation;o!=null&&(s.annotation=o);let i=r.lastMutations?.get(e)??t.lastMutation;return i!=null&&(s.lastMutation=i),s}function We(e,t,n){return dn(e,t,!0,"ok",n)}function je(e,t,n){return dn(e,t,!1,n,[])}function dn(e,t,n,r,s){let o=_r(e,t,n,r,s);return{from:e,to:t,found:n,reason:r,steps:s,text:o,toJSON(){return{from:e,to:t,found:n,reason:r,steps:s}}}}function _r(e,t,n,r,s){if(!n)switch(r){case"no-such-from":return`explainPath: no node named "${e}"`;case"no-such-to":return`explainPath: no node named "${t}"`;case"max-depth-exceeded":return`explainPath: no path from "${e}" to "${t}" within maxDepth`;default:return`explainPath: no path from "${e}" to "${t}"`}let o=[`Causal path: ${e} \u2192 ${t} (${s.length} step(s))`];for(let i of s){let l=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(l),"value"in i&&o.push(` value: ${kr(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;o.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return o.join(`
|
|
3
|
+
`)}function kr(e){if(e===void 0)return"<sentinel>";if(e===null)return"null";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);try{let t=JSON.stringify(e);return t.length>80?`${t.slice(0,77)}...`:t}catch{return String(e)}}se();var $={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},Tr=Symbol.for("sizeof");function fn(e){let t=new WeakSet,n=new WeakSet,r=[e],s=0;for(;r.length>0;){let o=r.pop();s+=Sr(o,t,n,r)}return s}function Sr(e,t,n,r){if(e==null)return 0;switch(typeof e){case"number":return $.number;case"boolean":return $.boolean;case"string":return $.string+e.length*2;case"bigint":return $.bigint+Or(e);case"symbol":return $.symbol;case"function":return t.has(e)?0:(t.add(e),$.function);case"undefined":return 0}let o=e;if(t.has(o))return 0;t.add(o);let i=o[Tr];if(typeof i=="function")try{let u=i.call(o);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(o instanceof Date)return $.date;if(o instanceof RegExp)return $.regexp+o.source.length*2;if(o instanceof Error){let u=o.message?o.message.length*2:0,c=o.stack?o.stack.length*2:0;return $.error+u+c}if(typeof URL<"u"&&o instanceof URL)return $.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return $.promise;if(o instanceof WeakMap)return $.weakmap;if(o instanceof WeakSet)return $.weakset;if(o instanceof Map){let u=$.map;for(let[c,f]of o)u+=$.mapEntry,r.push(c),r.push(f);return u}if(o instanceof Set){let u=$.set;for(let c of o)u+=$.setEntry,r.push(c);return u}if(Array.isArray(o)){let u=$.array+o.length*8;for(let c of o)r.push(c);return u}if(o instanceof ArrayBuffer)return n.has(o)?0:(n.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let u=o;return n.has(u.buffer)?48:(n.add(u.buffer),u.buffer.byteLength+48)}let a=$.object,l=Object.keys(o);for(let u of l){a+=$.string+u.length*2;try{r.push(o[u])}catch{}}return a}function Or(e){let t=e<0n?-e:e;if(t===0n)return 0;let n=t.toString(2).length;return Math.ceil(n/32)*8}function hn(e,t){let n=t?.topN??10,r=e.describe({detail:"standard"}),s=[],o=e._collectObserveTargets;typeof o=="function"&&o.call(e,"",s);let i=new Map;for(let[p,h]of s)i.set(p,h);let a=[];for(let[p,h]of Object.entries(r.nodes)){let d=i.get(p),g=d instanceof P?d:null,v=g?fn(g.cache):0,w=g?g._sinkCount:0,b=h.deps?.length??0,y=h.type==="effect"&&w===0,_=w===0?h.type==="effect"?"orphan-effect":h.type==="derived"?"idle-derived":h.type==="producer"?"idle-producer":null:null;a.push({path:p,type:h.type,status:h.status??"unknown",valueSizeBytes:v,subscriberCount:w,depCount:b,isOrphanEffect:y,orphanKind:_})}let l=a.reduce((p,h)=>p+h.valueSizeBytes,0),u=(p,h)=>[...a].sort(h??((d,g)=>g[p]-d[p])).slice(0,n),c=a.filter(p=>p.orphanKind!=null),f=a.filter(p=>p.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:l,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:c,orphanEffects:f}}var D="::",Q="__meta__",xe=1;function pn(e,t){let n=Math.max(16,e.size*4),r=0;for(;e.size>0;){if(r++>=n){console.error(`[Graph "${t}".destroy] disposer drain exceeded cap (${n}); ${e.size} disposer(s) discarded`),e.clear();return}let s=e.values().next();if(s.done)return;let o=s.value;e.delete(o);try{o()}catch(i){console.error(`[Graph "${t}".destroy] disposer threw:`,i)}}}function yn(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"&&typeof e.down=="function"}function Nr(e){if(e!=null)return yn(e)?e.cache:e}function Er(e){let t=[];for(let n of Object.keys(e).sort()){let r=e[n].v;r!=null&&t.push(`${n} ${r.id} ${r.version}`)}return t.join(`
|
|
4
|
+
`)}function gn(e){if(e.version!==xe)throw new Error(`unsupported snapshot version ${String(e.version)} (expected ${xe})`);for(let t of["name","nodes","edges","subgraphs"])if(!(t in e))throw new Error(`snapshot missing required key "${t}"`);if(typeof e.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof e.nodes!="object"||e.nodes===null||Array.isArray(e.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(e.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(e.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Cr(e,t){let n=new WeakMap,r=(s,o)=>{if(Object.is(s,o))return!0;if(s==null||o==null||typeof s!="object"||typeof o!="object")return!1;let i=n.get(s);if(i==null&&(i=new WeakSet,n.set(s,i)),i.has(o))return!0;i.add(o);let a=s.constructor,l=o.constructor;if(a!==l)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let p=o;if(s.length!==p.length)return!1;for(let h=0;h<s.length;h++)if(!r(s[h],p[h]))return!1;return!0}if(s instanceof Map){let p=o;if(s.size!==p.size)return!1;for(let[h,d]of s)if(!p.has(h)||!r(d,p.get(h)))return!1;return!0}if(s instanceof Set){let p=o;if(s.size!==p.size)return!1;for(let h of s){let d=!1;for(let g of p)if(r(h,g)){d=!0;break}if(!d)return!1}return!0}if(ArrayBuffer.isView(s)){let p=s,h=o;if(p.length!==h.length)return!1;for(let d=0;d<p.length;d++)if(p[d]!==h[d])return!1;return!0}let u=Object.keys(s),c=Object.keys(o);if(u.length!==c.length)return!1;let f=new Set(c);for(let p of u)if(!f.has(p)||!r(s[p],o[p]))return!1;return!0};return r(e,t)}function Tt(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Tt);let t=e,n=Object.keys(t).sort(),r={};for(let s of n)r[s]=Tt(t[s]);return r}function Rr(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Ar(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Mr(e){return e==="TD"?"down":e==="BT"?"up":e==="RL"?"left":"right"}function vn(e){let t=new Set,n=[];function r(s,o){let i=`${s}\0${o}`;t.has(i)||(t.add(i),n.push([s,o]))}for(let[s,o]of Object.entries(e.nodes)){let i=o.deps;if(i)for(let a of i)r(a,s)}for(let s of e.edges)r(s.from,s.to);return n}function xn(e){if(e===void 0)return"LR";if(e==="TD"||e==="LR"||e==="BT"||e==="RL")return e;throw new Error(`invalid diagram direction ${String(e)}; expected one of: TD, LR, BT, RL`)}function Dr(e,t){let n=t.includeEdges??!0,r=t.includeSubgraphs??!0,{expand:s,...o}=e,i={...o,edges:n?e.edges:[],subgraphs:r?e.subgraphs:[]},a=JSON.stringify(Tt(i),null,t.indent??2);return t.logger?.(a),a}function Gr(e,t){let n=t.includeEdges??!0,r=t.includeSubgraphs??!0,s=[];s.push(`Graph ${e.name}`),s.push("Nodes:");for(let i of Object.keys(e.nodes).sort()){let a=e.nodes[i];s.push(`- ${i} (${a.type}/${a.status}): ${Ue(a.value)}`)}if(n){s.push("Edges:");for(let i of e.edges)s.push(`- ${i.from} -> ${i.to}`)}if(r){s.push("Subgraphs:");for(let i of e.subgraphs)s.push(`- ${i}`)}let o=s.join(`
|
|
5
|
+
`);return t.logger?.(o),o}function wn(e,t){let n=xn(t.direction),r=Object.keys(e.nodes).sort(),s=new Map;for(let i=0;i<r.length;i+=1)s.set(r[i],`n${i}`);let o=[`flowchart ${n}`];for(let i of r){let a=s.get(i);o.push(` ${a}["${Rr(i)}"]`)}for(let[i,a]of vn(e)){let l=s.get(i),u=s.get(a);!l||!u||o.push(` ${l} --> ${u}`)}return o.join(`
|
|
6
|
+
`)}function Lr(e,t){let n=wn(e,t);return Ir(n)}function Ir(e,t){let n=t?.theme??"default",r=t?.autoSync??!0,o=JSON.stringify({code:e,mermaid:{theme:n},autoSync:r}),i=new TextEncoder().encode(o),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function Pr(e,t){let n=xn(t.direction),r=Object.keys(e.nodes).sort(),s=new Map;for(let i=0;i<r.length;i+=1)s.set(r[i],`n${i}`);let o=[`direction: ${Mr(n)}`];for(let i of r){let a=s.get(i);o.push(`${a}: "${Ar(i)}"`)}for(let[i,a]of vn(e)){let l=s.get(i),u=s.get(a);!l||!u||o.push(`${l} -> ${u}`)}return o.join(`
|
|
7
|
+
`)}function $r(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ze(e){let t="^";for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="*"){t+=".*";continue}if(r==="?"){t+=".";continue}if(r==="["){let s=e.indexOf("]",n+1);if(s<=n+1){t+="\\[";continue}let o=e.slice(n+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),t+=`[${o}]`,n=s;continue}t+=$r(r)}return t+="$",new RegExp(t)}var Br={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},Fr={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function Ue(e){if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean"||e==null)return String(e);try{return JSON.stringify(e)}catch{return"[unserializable]"}}function Hr(e){return e==="none"?Fr:e==="ansi"||e==null?Br:{data:e.data??"",dirty:e.dirty??"",resolved:e.resolved??"",invalidate:e.invalidate??"",pause:e.pause??"",resume:e.resume??"",complete:e.complete??"",error:e.error??"",teardown:e.teardown??"",derived:e.derived??"",path:e.path??"",reset:e.reset??""}}function mn(e){if(e==null)return{};let t=e.detail;return t==="full"?{...e,structured:e.structured??!0,timeline:e.timeline??!0,causal:e.causal??!0,derived:e.derived??!0}:t==="minimal"?{...e,structured:e.structured??!0}:e.format==="stage-log"?{...e,structured:e.structured??!0,timeline:e.timeline??!0}:e}function jr(e,t,n){for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);if(s<32||s===127)throw new Error(`Graph "${t}": ${n} "${e}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function kt(e,t,n){if(e==="")throw new Error(`Graph "${t}": ${n} name must be non-empty`);if(e.includes(D))throw new Error(`Graph "${t}": ${n} "${e}" must not contain '${D}' (path separator)`);if(e===Q)throw new Error(`Graph "${t}": ${n} name "${Q}" is reserved for meta companion paths`);jr(e,t,n)}function Vr(e,t){if(e==="")throw new Error(`Graph "${t}": resolve path must be non-empty`);let n=e.split(D);for(let r of n)if(r==="")throw new Error(`Graph "${t}": resolve path has empty segment`);return n}function Wr(e,t){let n=!1;for(let s of e)if(!t.isMetaPassthrough(s[0])){n=!0;break}return n?e.filter(s=>t.isMetaPassthrough(s[0])):e}function _n(e){for(let t of e._mounts.values())_n(t);for(let t of e._nodes.values())try{t.down([[H]],{internal:!0})}catch{}}var oe=class e{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;constructor(t,n){if(t==="")throw new Error("Graph name must be non-empty");if(t.includes(D))throw new Error(`Graph name must not contain '${D}' (got "${t}")`);if(t===Q)throw new Error(`Graph name "${Q}" is reserved for meta companion paths`);this.name=t,this.opts=Object.freeze({...n??{}}),this.config=n?.config??ae,this._traceRing=new Ce(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(t=!0){let n=[],r=t?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=qt(t=>{let n=r=>{t.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(t){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(t)}nameOf(t){return this._nodeToName.get(t)}add(t,n){let r=t.name,s=n?.name??r;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,i=n?.annotation;if(kt(o,this.name,"add"),this._mounts.has(o))throw new Error(`Graph "${this.name}": name "${o}" is already a mount point`);if(this._nodes.has(o))throw new Error(`Graph "${this.name}": node "${o}" already exists`);let a=this._nodeToName.get(t);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(o,t),this._nodeToName.set(t,o),this._emitTopology({kind:"added",name:o,nodeKind:"node"}),i!=null&&(this._annotations.set(o,i),this.config.inspectorEnabled&&this._traceRing.push({path:o,annotation:i,timestamp_ns:F()})),t}setVersioning(t){if(t!=null)for(let n of this._nodes.values())n instanceof P&&n._applyVersioning(t)}remove(t){kt(t,this.name,"remove");let n=this._mounts.get(t);if(n){let o={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,l]of i)a.includes(`${D}${Q}${D}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(t),o.mounts.push(...n._collectSubgraphs(`${t}${D}`)),this._mounts.delete(t),n._parent=void 0,_n(n),this._emitTopology({kind:"removed",name:t,nodeKind:"mount",audit:o}),o}let r=this._nodes.get(t);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${t}"`);this._nodes.delete(t),this._nodeToName.delete(r),r.down([[H]],{internal:!0});let s={kind:"node",nodes:[t],mounts:[]};return this._emitTopology({kind:"removed",name:t,nodeKind:"node",audit:s}),s}removeAll(t){let n=typeof t=="function"?t:(()=>{let o=ze(t);return i=>o.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>n(o));for(let o of s){let i=this.remove(o);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let t=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=t.length)return{value:void 0,done:!0};let s=t[r++];return{value:[s,n.get(s)],done:!1}}}}node(t){if(t==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(t.includes(D))return this.resolve(t);let n=this._nodes.get(t);if(!n)throw new Error(`Graph "${this.name}": unknown node "${t}"`);return n}get(t){return this.node(t).cache}set(t,n,r){let s=r?.internal===!0;this.node(t).down([[B,n]],{actor:r?.actor,internal:s,delivery:"write"})}setAll(t,n){let r=Symbol.iterator in t?t:Object.entries(t);It(()=>{for(let[s,o]of r)this.set(s,o,n)})}invalidate(t,n){let r=n?.internal===!0;this.node(t).down([[Z]],{actor:n?.actor,internal:r,delivery:"write"})}error(t,n,r){let s=r?.internal===!0;this.node(t).down([[I,n]],{actor:r?.actor,internal:s,delivery:"write"})}complete(t,n){let r=n?.internal===!0;this.node(t).down([[K]],{actor:n?.actor,internal:r,delivery:"write"})}edges(t){let n=t?.recursive===!0,r=new Map;if(!n){for(let[l,u]of this._nodes)r.set(u,l);let a=[];for(let[l,u]of this._nodes)if(u instanceof P)for(let c of u._deps){let f=r.get(c.node);f!=null&&a.push([f,l])}return a.sort((l,u)=>l[0]<u[0]?-1:l[0]>u[0]?1:l[1]<u[1]?-1:l[1]>u[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,l]of s)o.set(l,a);let i=[];for(let[a,l]of s)if(l instanceof P)for(let u of l._deps){let c=o.get(u.node);c!=null&&i.push([c,a])}return i.sort((a,l)=>a[0]<l[0]?-1:a[0]>l[0]?1:a[1]<l[1]?-1:a[1]>l[1]?1:0),i}mount(t,n){if(n===void 0){let s=new e(t);return this.mount(t,s)}if(typeof n=="function"){let s=new e(t);return n(s),this.mount(t,s)}let r=n;if(kt(t,this.name,"mount"),this._nodes.has(t))throw new Error(`Graph "${this.name}": cannot mount at "${t}" \u2014 node with that name exists`);if(this._mounts.has(t))throw new Error(`Graph "${this.name}": mount "${t}" already exists`);if(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===r)throw new Error(`Graph "${this.name}": mount("${t}", \u2026) would create a mount cycle`);return this._mounts.set(t,r),r._parent=this,this._emitTopology({kind:"added",name:t,nodeKind:"mount"}),r}resolve(t){let n=Vr(t,this.name);return this._resolveFromSegments(n)}tryResolve(t){try{return this.resolve(t)}catch{return}}_resolveFromSegments(t){let n=t;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],s=n.slice(1);if(s.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let o=this._nodes.get(r);if(o&&s.length>0&&s[0]===Q)return this._resolveMetaChainFromNode(o,s,n.join(D));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${s.join(D)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(s.join(D))}_resolveMetaChainFromNode(t,n,r){let s=t,o=0,i=[...n];for(;o<i.length;){if(i[o]!==Q)throw new Error(`Graph "${this.name}": expected ${Q} segment in meta path "${r}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Q} in "${r}"`);let a=i[o+1],l=s.meta[a];if(!l)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);s=l,o+=2}return s}signal(t,n){if(n?.internal!==!0){for(let s of t)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(t,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(t,n,r,s){for(let l of this._mounts.values())l._signalDeliver(t,n,r,s);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=Wr(t,this.config);for(let l of[...this._nodes.keys()].sort()){let u=this._nodes.get(l);if(!r.has(u)){r.add(u);try{u.down(t,i)}catch(c){if(c instanceof q)throw c;s.push(c)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,s)}}}_signalMetaSubtree(t,n,r,s,o){for(let i of Object.keys(t.meta).sort()){let a=t.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,s)}catch(l){if(l instanceof q)throw l;o.push(l)}this._signalMetaSubtree(a,n,r,s,o)}}}describe(t){if(t?.reactive===!0)return this._describeReactive(t);let n=Nr(t?.actor),r=t?.filter,s=$e(t?.detail,t?.fields),o=t?.format==="spec",i=o?$e("minimal"):s,a=[];this._collectObserveTargets("",a);let l=new Map;for(let[x,k]of a)l.set(k,x);let u=[];{let x=a.map(([,S])=>S),k=new Set(l.values()),T=0;for(;x.length>0;){let S=x.shift();if(S instanceof P)for(let C of S._deps){let O=C.node;if(l.has(O))continue;let E=O.name??"",R=E;if(!R||k.has(R))if(E){let L=2;for(;k.has(`${E}#${L}`);)L++;R=`${E}#${L}`}else for(R=`__internal__/${T++}`;k.has(R);)R=`__internal__/${T++}`;l.set(O,R),k.add(R),u.push([R,O]),x.push(O)}}}let c=[...a,...u],f={};for(let[x,k]of c){if(n!=null&&!k.allowsObserve(n))continue;let T=wt(k,i),S=k instanceof P?k._deps.map(R=>l.get(R.node)??R.node.name??""):[],{name:C,...O}=T,E={...O,deps:S};if(!o){let R=this._annotations.get(x);R!=null&&(E.annotation=R)}if(r!=null)if(typeof r=="function"){let R=r;if(!(R.length>=2?R(x,E):R(E)))continue}else{let R=!0;for(let[L,V]of Object.entries(r)){let J=L==="deps_includes"?"depsIncludes":L==="meta_has"?"metaHas":L;if(J==="depsIncludes"){if(!E.deps.includes(String(V))){R=!1;break}continue}if(J==="metaHas"){if(!Object.hasOwn(E.meta??{},String(V))){R=!1;break}continue}if(E[J]!==V){R=!1;break}}if(!R)continue}f[x]=E}let p=new Set(Object.keys(f)),h=[];for(let[x,k]of c)if(k instanceof P)for(let T of k._deps){let S=l.get(T.node);S!=null&&h.push([S,x])}h.sort((x,k)=>x[0]<k[0]?-1:x[0]>k[0]?1:x[1]<k[1]?-1:x[1]>k[1]?1:0);let d=h.map(([x,k])=>({from:x,to:k}));(n!=null||r!=null)&&(d=d.filter(x=>p.has(x.from)&&p.has(x.to)));let g=this._collectSubgraphs(""),v=n!=null||r!=null?g.filter(x=>{let k=`${x}${D}`;return[...p].some(T=>T===x||T.startsWith(k))}):g,w=this,b=t,y={name:this.name,nodes:f,edges:d,subgraphs:v,expand(x){let k={...b,format:void 0};return Array.isArray(x)?(k.fields=x,k.detail=void 0):(k.detail=x,k.fields=void 0),w.describe(k)}},_=t??{},m=_.format;return m==="json"?Dr(y,_):m==="pretty"?Gr(y,_):m==="mermaid"?wn(y,_):m==="mermaid-url"?Lr(y,_):m==="d2"?Pr(y,_):m==="ascii"?an(y,_):y}_collectSubgraphs(t){let n=[];for(let r of[...this._mounts.keys()].sort()){let s=t===""?r:`${t}${r}`;n.push(s),n.push(...this._mounts.get(r)._collectSubgraphs(`${s}${D}`))}return n}resourceProfile(t){return hn(this,t)}reachable(t,n,r={}){return r.withDetail===!0?bn(this.describe(),t,n,{...r,withDetail:!0}):bn(this.describe(),t,n,r)}explain(t,n,r){return r?.reactive===!0?this._explainReactive(t,n,r):this._explainStatic(t,n,r)}_explainStatic(t,n,r){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,l]of Object.entries(s.nodes))l.lastMutation!=null&&i.set(a,l.lastMutation);return un(s,t,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(t){let n={...t,reactive:!1},r=t.reactiveName??"describe",s=0,o=G(s,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,l=!1,u=()=>{a||l||(a=!0,Se(()=>{a=!1,!l&&(s+=1,o.emit(s))}))},c=i.onEvent(b=>{let y=b.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||u()}),f=[],p=new WeakSet,h=b=>{if(p.has(b)||l)return;p.add(b);let y=b.topology.subscribe(_=>{for(let m of _){if(m[0]!==B)continue;let x=m[1];if(u(),x.kind==="added"&&x.nodeKind==="mount"){let k=b._mounts.get(x.name);k!=null&&h(k)}}});f.push(y);for(let _ of b._mounts.keys()){let m=b._mounts.get(_);m!=null&&h(m)}};h(this);let d,g=t.actor;yn(g)&&(d=g.subscribe(b=>{let y=!1,_=!1;for(let m of b){let x=m[0];x===B?y=!0:(x===K||x===I||x===H)&&(_=!0)}y&&u(),_&&(d?.(),d=void 0,u())}));let v;try{v=Y([o],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,y)=>b===y})}catch(b){c(),d?.();for(let y of f)y();throw i.dispose(),b}let w=_t(v);return{node:v,dispose(){l=!0,c(),d?.();for(let b of f)b();f.length=0,i.dispose(),w()}}}_explainReactive(t,n,r){let s=0,o=G(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,l=!1,u=i.onEvent(h=>{let d=h.type;d!=="data"&&d!=="error"&&d!=="complete"&&d!=="teardown"||a||l||(a=!0,Se(()=>{a=!1,!l&&(s+=1,o.emit(s))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},f;try{f=Y([o],()=>this._explainStatic(t,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:t,to:n},equals:(h,d)=>h.found===d.found&&h.reason===d.reason&&h.steps.length===d.steps.length&&Ur(h.steps,d.steps)})}catch(h){throw u(),i.dispose(),h}let p=_t(f);return{node:f,dispose(){l=!0,u(),i.dispose(),p()}}}_pathsMatching(t){let n=ze(t),r=[];return this._collectObserveTargets("",r),r.map(([s])=>s).filter(s=>n.test(s))}_collectObserveTargets(t,n){for(let r of[...this._mounts.keys()].sort()){let s=t===""?r:`${t}${D}${r}`;this._mounts.get(r)._collectObserveTargets(s,n)}for(let r of[...this._nodes.keys()].sort()){let s=this._nodes.get(r),o=t===""?r:`${t}${D}${r}`;n.push([o,s]),this._appendMetaObserveTargets(o,s,n)}}_appendMetaObserveTargets(t,n,r){for(let s of Object.keys(n.meta).sort()){let o=n.meta[s],i=`${t}${D}${Q}${D}${s}`;r.push([i,o]),this._appendMetaObserveTargets(i,o,r)}}observe(t,n){let r=typeof t=="string",o=mn(r?n:t),i=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,a=o.actor;if(r){let c=t,f=this.resolve(c);if(a!=null&&!f.allowsObserve(a))throw new q({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,f]],o,"one"):{subscribe(p){return f.subscribe(p)},up(p){try{f.up?.(p)}catch(h){if(h instanceof q)return;throw h}}}}let l=[];this._collectObserveTargets("",l),l.sort((c,f)=>c[0]<f[0]?-1:c[0]>f[0]?1:0);let u=a==null?l:l.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,o,"all"):{subscribe:c=>{let f=u.map(([p,h])=>h.subscribe(d=>{c(p,d)}));return()=>{for(let p of f)p()}},up:(c,f)=>{try{this.resolve(c).up?.(f)}catch(p){if(p instanceof q)return;throw p}}}}_buildStructuredObserver(t,n,r){let s=r==="one"?t[0]?.[0]:void 0,o=i=>{if(r==="one"&&s!=null){let c=this.resolve(s);return this._buildStructuredObserver([[s,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,f)=>c[0]<f[0]?-1:c[0]>f[0]?1:0);let l=i.actor,u=l==null?a:a.filter(([,c])=>c.allowsObserve(l));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(t,n,o)}_createObserveResult(t,n,r){let s=n.timeline===!0,o=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",l=this.config.inspectorEnabled,u=(o||i)&&l,c=n.maxEvents,f=c!=null&&c>0?new Ce(c):null,p=[],h=new Set,d={},g=new Set,v=0,w=0,b=0,y=0,_=0,m=0,x=!1,k=!1,T=0,S=new Map,C=new Map,O=new Map,E=N=>{f?f.push(N):p.push(N);for(let M of h)M(N)},R=()=>s?{timestamp_ns:F(),in_batch:De(),batch_id:T}:{},L=(N,M)=>{if(!(!u||!(N instanceof P)))return N._setInspectorHook(W=>{if(W.kind==="dep_message")S.set(N,W.depIndex);else if(W.kind==="run"){let _e=W.batchData.map((A,j)=>A!=null&&A.length>0?A.at(-1):W.prevData[j]);C.set(N,_e);let z=W.batchData.map(A=>A!=null?[...A]:void 0);O.set(N,z),i&&E({type:"derived",path:M,dep_values:_e,dep_batches:z,...R()})}})},V=N=>{let M=S.get(N),W=C.get(N);if(!o||W==null)return{};let z=(M!=null&&M>=0&&N instanceof P?N._deps[M]:void 0)?.node,A=z?.v,j=O.get(N);return{trigger_dep_index:M,trigger_dep_name:z?.name,...A!=null?{trigger_version:{id:A.id,version:A.version}}:{},dep_values:[...W],...j!=null?{dep_batches:j}:{}}},J=[],ce=[];for(let[N,M]of t){let W=L(M,N);W&&J.push(W),ce.push(M.subscribe(_e=>{T++;for(let z of _e){let A=z[0],j=R();if(A===B){d[N]=z[1];let Ze=M instanceof P?M.lastMutation?.actor??ge:ge;E({type:"data",path:N,data:z[1],actor:Ze,...j,...V(M)})}else if(a)A===X?v++:A===te?w++:A===Z?b++:A===ne?y++:A===ie?_++:A===H?m++:A===K&&!g.has(N)?x=!0:A===I&&(k=!0,g.add(N));else if(A===X)v++,E({type:"dirty",path:N,...j});else if(A===te)w++,E({type:"resolved",path:N,...j,...V(M)});else if(A===Z)b++,E({type:"invalidate",path:N,...j});else if(A===ne)y++,E({type:"pause",path:N,lockId:z[1],...j});else if(A===ie)_++,E({type:"resume",path:N,lockId:z[1],...j});else if(A===K)g.has(N)||(x=!0),E({type:"complete",path:N,...j});else if(A===I){k=!0,g.add(N);let Ze=M instanceof P?M.lastMutation?.actor??ge:ge;E({type:"error",path:N,data:z[1],actor:Ze,...j})}else A===H&&(m++,E({type:"teardown",path:N,...j}))}}))}let Ye=!1,Je=()=>{if(!Ye){Ye=!0;for(let N of ce)N();for(let N of J)N();for(let N of Re)N({value:void 0,done:!0});Re.length=0}},Xe=[],Re=[];h.add(N=>{let M=Re.shift();M?M({value:N,done:!1}):Xe.push(N)});let Ct={get values(){return d},get dirtyCount(){return v},get resolvedCount(){return w},get invalidateCount(){return b},get pauseCount(){return y},get resumeCount(){return _},get teardownCount(){return m},get events(){return f?f.toArray():[...p]},get anyCompletedCleanly(){return x},get anyErrored(){return k},get completedWithoutErrors(){return x&&!k},onEvent(N){return h.add(N),()=>h.delete(N)},dispose:Je,expand(N){Je();let M={...n};return typeof N=="string"?M.detail=N:Object.assign(M,N),r(mn(M))},[Symbol.asyncIterator](){return{next(){return Xe.length>0?Promise.resolve({value:Xe.shift(),done:!1}):Ye?Promise.resolve({value:void 0,done:!0}):new Promise(N=>Re.push(N))},return(){return Je(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Ct,n),Ct}_attachFormatLogger(t,n){let r=n.format;if(r==null)return;let s=n.logger??(d=>console.log(d)),o=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=o==null&&i==null?()=>!0:d=>(o==null||o.has(d))&&(i==null||!i.has(d)),l=Hr(n.theme),u=r==="stage-log"?F():0,c=d=>d==null?"":n.stageLabels?.[d]??d,f=(d,g)=>d.length>g?`${d.slice(0,g-1)}\u2026`:d,p=d=>d.type==="data"||d.type==="error"?f(Ue(d.data),120):"",h=d=>{if(r==="stage-log"){let k=(F()-u)/1e9,T=c(d.path).padEnd(9);if(d.type==="data"){let S=p(d);return`[${k.toFixed(3)}s] ${T} \u2190${S?` ${S}`:""}`}if(d.type==="error"){let S=p(d);return`[${k.toFixed(3)}s] ${T} \u2717${S?` ${S}`:""}`}return d.type==="complete"?`[${k.toFixed(3)}s] ${T} \u25A0 complete`:`[${k.toFixed(3)}s] ${T} ${d.type}`}if(r==="json")try{return JSON.stringify(d)}catch{return JSON.stringify({type:d.type,path:d.path,data:"[unserializable]"})}let g=l[d.type]??"",v=d.path?`${l.path}${d.path}${l.reset} `:"",w=d.type==="data"||d.type==="error",b=d.type==="pause"||d.type==="resume",y=w?` ${Ue(d.data)}`:b?` ${Ue(d.lockId)}`:"",_=d.type==="data"||d.type==="resolved"||d.type==="derived"?d:void 0,m=_?.trigger_dep_name!=null?` <- ${_.trigger_dep_name}`:_?.trigger_dep_index!=null?` <- #${_.trigger_dep_index}`:"",x=d.in_batch?" [batch]":"";return`${v}${g}${d.type.toUpperCase()}${l.reset}${y}${m}${x}`};t.onEvent(d=>{a(d.type)&&s(h(d),d)})}addDisposer(t){return this._disposers.add(t),()=>{this._disposers.delete(t)}}destroy(){pn(this._disposers,this.name),this.signal([[H]],{internal:!0}),pn(this._storageDisposers,this.name);for(let t of[...this._mounts.values()])t._parent=void 0,t._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let t of[...this._mounts.values()])t._parent=void 0,t._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(t){let{expand:n,...r}=this.describe({detail:"full"}),s={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:l,guard:u,...c}=r.nodes[a];s[a]=c}let o=[...r.subgraphs].sort(),i={...r,version:1,nodes:s,subgraphs:o};if(t?.format==null)return i;if(t.format==="json-string")return JSON.stringify(i);if(t.format==="bytes"){if(t.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(t.codec);if(a==null)throw new Error(`snapshot: codec "${t.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return Mt(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(t.format)}"`)}static decode(t,n){let r=n?.config??ae,{codec:s,codecVersion:o,payload:i}=Dt(t,r);return s.decode(i,o)}restore(t,n){if(gn(t),t.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${t.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(o=>ze(o)),s=n?.includeProducers===!0;for(let o of Object.keys(t.nodes).sort()){if(r!==null&&!r.some(a=>a.test(o)))continue;let i=t.nodes[o];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let l=this.tryResolve(o)?.v;if(l!=null&&l.id===i.v.id&&l.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){n?.onError?.(o,a)}}}}}static fromSnapshot(t,n){gn(t);let r=typeof n=="function"?n:n?.build,s=typeof n=="function"?void 0:n?.factories,o=new e(t.name);if(r)return r(o),o.restore(t),o;for(let h of[...t.subgraphs].sort((d,g)=>{let v=d.split(D).length,w=g.split(D).length;return v!==w?v-w:d<g?-1:d>g?1:0})){let d=h.split(D),g=o;for(let v of d)g._mounts.has(v)||g.mount(v,new e(v)),g=g._mounts.get(v)}let i=s?Object.entries(s).map(([h,d])=>({re:ze(h),factory:d})):[],a=h=>{for(let d of i)if(d.re.test(h))return d.factory},l=h=>{let d=h.split(D),g=d.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${h}"`);let v=o;for(let w of d){let b=v._mounts.get(w);if(!b)throw new Error(`unknown mount "${w}" in path "${h}"`);v=b}return[v,g]},u=Object.entries(t.nodes).filter(([h])=>!h.includes(`${D}${Q}${D}`)).sort((h,d)=>h[0]<d[0]?-1:h[0]>d[0]?1:0),c=new Map(u),f=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[h,d]of[...c.entries()]){let g=d?.deps??[];if(!g.every(m=>f.has(m)))continue;let[v,w]=l(h),b={...d?.meta??{}},y=a(h),_;if(d?.type==="state")_=G(d.value,{meta:b});else{if(y==null)continue;_=y(w,{path:h,type:d.type,value:d.value,meta:b,deps:g,resolvedDeps:g.map(m=>f.get(m))})}v.add(_,{name:w}),f.set(h,_),c.delete(h),p=!0}}if(c.size>0){let h=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(t),o}toJSON(){return this.snapshot()}attachSnapshotStorage(t,n={}){let r=t.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(t,n.onError);let s=(u,c)=>{if(u.disposed)return;let f=Er(c.nodes);if(u.lastSnapshot!=null&&f!==""&&f===u.lastFingerprint)return;let p=u.seq+1,h=Ae(),v=u.lastSnapshot==null||p%u.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:p,timestamp_ns:h,format_version:xe}:{name:this.name,mode:"diff",diff:zr(u.lastSnapshot,c),seq:p,timestamp_ns:h,format_version:xe};if(u.tier.filter&&!u.tier.filter(v))return;let w;try{w=u.tier.save(v)}catch(b){n.onError?.(b,u.tier);return}if(w&&typeof w.then=="function"){let _=(u.savePending??Promise.resolve()).then(()=>w,()=>w).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=c,u.lastFingerprint=f)},m=>{n.onError?.(m,u.tier)});u.savePending=_.finally(()=>{u.savePending===_&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=c,u.lastFingerprint=f},o=(u,c)=>{try{s(u,c)}catch(f){n.onError?.(f,u.tier)}},i=(u,c)=>{if(!c.some(d=>{let g=this.config.messageTier(d[0]);return g>=3&&g<5}))return;if(n.filter){let d=this.tryResolve(u);if(d==null)return;let g=wt(d,$e("standard"));if(!n.filter(u,g))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let d of r)d.disposed||(d.debounceMs===0?o(d,h()):(d.timer==null&&(d.timer=new Be),d.timer.start(d.debounceMs,()=>{d.disposed||o(d,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(f=>{let p=this.tryResolve(f);return p==null?()=>{}:p.subscribe(h=>i(f,h))});a=()=>{for(let f of c)f()}}else a=this.observe().subscribe((u,c)=>i(u,c));let l=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(l)};return this._storageDisposers.add(l),{dispose:l}}async _cascadeRestore(t,n){for(let r of t){let s;try{s=await r.load?.()}catch(i){n?.(i,r);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===xe&&o.nodes!=null)return this.restore(o),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(t,n,r){for(let s of n){let o;try{o=await s.load?.()}catch(l){r?.onError?.(l,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===xe&&i.nodes!=null?i:void 0;if(a!=null)try{return e.fromSnapshot(a,r)}catch(l){r?.onError?.(l,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${t}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(t,n,r){if(t!=null&&n!=null){if(this.tryResolve(t)==null)return;if(this._annotations.set(t,n),this.config.inspectorEnabled){let s={path:t,annotation:n,timestamp_ns:F(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(s)}return}return t!=null?this.config.inspectorEnabled?this._annotations.get(t):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(t){return this._annotations.get(t)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(t){let n=this._traceRing.toArray().filter(s=>!t(s)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let s of n)this._traceRing.push(s);return r}static diff(t,n){let r=new Set(Object.keys(t.nodes)),s=new Set(Object.keys(n.nodes)),o=[...s].filter(b=>!r.has(b)).sort(),i=[...r].filter(b=>!s.has(b)).sort(),a=[],l=[];for(let b of r){if(!s.has(b))continue;let y=t.nodes[b],_=n.nodes[b],m=y.v,x=_.v;m!=null&&x!=null&&m.id===x.id&&m.version!==x.version&&l.push({path:b,id:m.id,from:m.version,to:x.version});let k=m!=null&&x!=null&&m.id===x.id&&m.version===x.version;for(let T of["type","status","sentinel"]){let S=y[T],C=_[T];S!==C&&a.push({path:b,field:T,from:S,to:C})}if(!k)for(let T of["value","meta"]){let S=y[T],C=_[T];Cr(S,C)||a.push({path:b,field:T,from:S,to:C})}}let u=b=>`${b.from} ${b.to}`,c=new Set(t.edges.map(u)),f=new Set(n.edges.map(u)),p=n.edges.filter(b=>!c.has(u(b))),h=t.edges.filter(b=>!f.has(u(b))),d=new Set(t.subgraphs),g=new Set(n.subgraphs),v=[...g].filter(b=>!d.has(b)).sort(),w=[...d].filter(b=>!g.has(b)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:l,edgesAdded:p,edgesRemoved:h,subgraphsAdded:v,subgraphsRemoved:w}}};function zr(e,t){let n=oe.diff(e,t),r={};for(let s of n.nodesAdded){let o=t.nodes[s];o!=null&&(r[s]=o)}return{...n,nodesAddedFull:r}}function bn(e,t,n,r={}){let s={paths:[],depths:new Map,truncated:!1};if(!t)return r.withDetail?s:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=r.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return r.withDetail?s:[];let i=new Map,a=new Map,l=new Map,u=new Map,c=new Set;for(let[y,_]of Object.entries(e.nodes)){if(!y)continue;c.add(y);let m=_.deps??[];i.set(y,m);for(let x of m)x&&(c.add(x),a.has(x)||a.set(x,new Set),a.get(x).add(y))}for(let y of e.edges){if(y==null||typeof y!="object")continue;let _=typeof y.from=="string"?y.from:"",m=typeof y.to=="string"?y.to:"";!_||!m||(c.add(_),c.add(m),u.has(_)||u.set(_,new Set),u.get(_).add(m),l.has(m)||l.set(m,new Set),l.get(m).add(_))}if(!c.has(t))return r.withDetail?s:[];let f=r.both===!0,p=y=>{if(f){let k=i.get(y)??[],T=l.get(y),S=a.get(y),C=u.get(y),O=[...k];return T&&O.push(...T),S&&O.push(...S),C&&O.push(...C),O}if(n==="upstream"){let k=i.get(y)??[],T=l.get(y);return T?[...k,...T]:k}let _=a.get(y),m=u.get(y),x=_?[..._]:[];return m&&x.push(...m),x},h=new Set([t]),d=new Map,g=[{path:t,depth:0}],v=0,w=!1;for(;v<g.length;){let y=g[v++];if(o!=null&&y.depth>=o){p(y.path).length>0&&(w=!0);continue}for(let _ of p(y.path))!_||h.has(_)||(h.add(_),d.set(_,y.depth+1),g.push({path:_,depth:y.depth+1}))}let b=[...d.keys()].sort((y,_)=>y<_?-1:y>_?1:0);return r.withDetail?{paths:b,depths:d,truncated:w}:b}function Ur(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],s=t[n];if(r.path!==s.path||r.type!==s.type||r.status!==s.status||r.hop!==s.hop||r.dep_index!==s.dep_index||r.annotation!==s.annotation||r.value!==s.value||r.lastMutation!==s.lastMutation)return!1;let o=r.v,i=s.v;if(o!==i&&(o==null||i==null||o.id!==i.id||o.version!==i.version))return!1}return!0}Ge();Ne();se();function ee(e,t){e!=null&&ye(n=>e.down(n),[[B,t]],ae.tierOf)}pe();se();Ee();function Kr(e){for(let t of e){let n=t.codePointAt(0);if(n>=19968&&n<=40959||n>=13312&&n<=19903||n>=12288&&n<=12351||n>=12352&&n<=12447||n>=12448&&n<=12543||n>=44032&&n<=55215||n>=65280&&n<=65519)return!0}return!1}var kn=new Set(["\uFF0C","\uFF0E","\uFF01","\uFF1A","\uFF1B","\uFF1F","\u3001","\u3002","\u30FB","\uFF09","\u3015","\u3009","\u300B","\u300D","\u300F","\u3011"]),qr=new Set([".",",","!","?",":",";",")","]","}","%",'"',"\u201D","\u2019","\xBB","\u203A","\u2026"]);function Yr(e){return e.replace(/[\t\n\r\f ]+/g," ").replace(/^ | $/g,"")}function Jr(e){let t=new Intl.Segmenter(void 0,{granularity:"word"}),n=[];for(let r of t.segment(e)){let s=r.segment,o=r.isWordLike??!1,i=[],a=[],l=[],u="",c=null;for(let f of s){let p;f===" "?p="space":f==="\u200B"?p="zero-width-break":f==="\xAD"?p="soft-hyphen":f===`
|
|
8
|
+
`?p="hard-break":p="text",c!==null&&p===c?u+=f:(c!==null&&(i.push(u),a.push(c==="text"&&o),l.push(c)),u=f,c=p)}c!==null&&(i.push(u),a.push(c==="text"&&o),l.push(c)),n.push({texts:i,isWordLike:a,kinds:l})}return n}function we(e,t,n,r,s){let o=Yr(e);if(o.length===0)return[];let i=Jr(o),a=new Intl.Segmenter(void 0,{granularity:"grapheme"}),l=[],u=[],c=[];for(let w of i)for(let b=0;b<w.texts.length;b++)l.push(w.texts[b]),u.push(w.kinds[b]),c.push(w.isWordLike[b]);let f=[],p=[],h=[];for(let w=0;w<l.length;w++){let b=l[w],y=u[w],_=c[w];if(y==="text"&&!_&&f.length>0&&p[p.length-1]==="text"&&b.length===1&&(qr.has(b)||kn.has(b))){f[f.length-1]+=b;continue}if(b==="-"&&f.length>0&&p[p.length-1]==="text"&&h[h.length-1]){f[f.length-1]+=b;continue}f.push(b),p.push(y),h.push(_)}let d=r.get(t);d||(d=new Map,r.set(t,d));function g(w){let b=d.get(w);if(b===void 0){s&&(s.misses+=1);let y=n.measureSegment(w,t).width;b=Number.isFinite(y)&&y>=0?y:0,d.set(w,b)}else s&&(s.hits+=1);return b}let v=[];for(let w=0;w<f.length;w++){let b=f[w],y=p[w];if(y!=="text"){v.push({text:b,width:y==="space"?g(" ")*b.length:0,kind:y,graphemeWidths:null});continue}if(Kr(b)){let x="";for(let k of a.segment(b)){let T=k.segment;if(x.length>0&&kn.has(T)){x+=T;continue}if(x.length>0){let S=g(x);v.push({text:x,width:S,kind:"text",graphemeWidths:null})}x=T}if(x.length>0){let k=g(x);v.push({text:x,width:k,kind:"text",graphemeWidths:null})}continue}let _=g(b),m=null;if(h[w]&&b.length>1){let x=[];for(let k of a.segment(b))x.push(g(k.segment));x.length>1&&(m=x)}v.push({text:b,width:_,kind:"text",graphemeWidths:m})}return v}function Ke(e,t,n,r,s){if(e.length===0)return{lines:[],lineCount:0};let o=[],i=0,a=!1,l=0,u=0,c=0,f=0,p=-1,h=0,d=s.get(r);d||(d=new Map,s.set(r,d));let g=d.get("-");g===void 0&&(g=n.measureSegment("-",r).width,d.set("-",g));function v(m=c,x=f,k=i){let T="";for(let S=l;S<m;S++){let C=e[S];if(!(C.kind==="soft-hyphen"||C.kind==="hard-break"))if(S===l&&u>0&&C.graphemeWidths){let E=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(C.text)].map(R=>R.segment);T+=E.slice(u).join("")}else T+=C.text}if(x>0&&m<e.length){let S=e[m],O=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(S.text)].map(R=>R.segment),E=l===m?u:0;T+=O.slice(E,x).join("")}m>0&&e[m-1]?.kind==="soft-hyphen"&&!(l===m&&u>0)&&(T+="-"),o.push({text:T,width:k,startSegment:l,startGrapheme:u,endSegment:m,endGrapheme:x}),i=0,a=!1,p=-1,h=0}function w(m){return m==="space"||m==="zero-width-break"||m==="soft-hyphen"}function b(m,x,k){a=!0,l=m,u=x,c=m+1,f=0,i=k}function y(m,x,k){a=!0,l=m,u=x,c=m,f=x+1,i=k}for(let m=0;m<e.length;m++){let x=e[m];if(x.kind==="hard-break"){a?v():o.push({text:"",width:0,startSegment:m,startGrapheme:0,endSegment:m,endGrapheme:0}),l=m+1,u=0;continue}let k=x.width;if(!a){k>t&&x.graphemeWidths?_(m,0,x.graphemeWidths):b(m,0,k),w(x.kind)&&(p=m+1,h=x.kind==="space"?i-k:i);continue}let T=i+k;if(T>t+.005){if(w(x.kind)){i+=k,c=m+1,f=0,v(m+1,0,x.kind==="space"?i-k:i);continue}if(p>=0){v(p,0,h),m--;continue}if(k>t&&x.graphemeWidths){v(),_(m,0,x.graphemeWidths);continue}v(),m--;continue}i=T,c=m+1,f=0,w(x.kind)&&(p=m+1,h=x.kind==="space"?i-k:i)}return a&&v(),{lines:o,lineCount:o.length};function _(m,x,k){for(let T=x;T<k.length;T++){let S=k[T];if(!a){y(m,T,S);continue}i+S>t+.005?(v(),y(m,T,S)):(i+=S,c=m,f=T+1)}a&&c===m&&f===k.length&&(c=m+1,f=0)}}function St(e){return e==="space"||e==="zero-width-break"||e==="soft-hyphen"}var Ot=null;function Xr(){return Ot===null&&(Ot=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Ot}function Tn(e,t,n){if(t===0&&n<0)return e.text;let r=[...Xr().segment(e.text)].map(o=>o.segment),s=n<0?r.length:n;return r.slice(t,s).join("")}function le(e,t,n,r,s,o){let i="";for(let a=t;a<r;a++){let l=e[a];l.kind==="soft-hyphen"||l.kind==="hard-break"||(a===t&&n>0?i+=Tn(l,n,-1):i+=l.text)}if(s>0&&r<e.length){let a=e[r];i+=Tn(a,t===r?n:0,s)}return o&&(i+="-"),i}function Zr(e){if(!e?.adapter||!e.font)return 0;let t=e.cache;if(t){let n=t.get(e.font);n||(n=new Map,t.set(e.font,n));let r=n.get("-");return r===void 0&&(r=e.adapter.measureSegment("-",e.font).width,n.set("-",r)),r}return e.adapter.measureSegment("-",e.font).width}function Nt(e,t,n,r){let s=t.segmentIndex,o=t.graphemeIndex;if(s>=e.length)return null;if(o===0){for(;s<e.length;){let m=e[s];if(m.kind==="hard-break")return{text:"",width:0,start:{segmentIndex:t.segmentIndex,graphemeIndex:0},end:{segmentIndex:s+1,graphemeIndex:0}};if(m.kind==="space"||m.kind==="zero-width-break"||m.kind==="soft-hyphen"){s+=1;continue}break}if(s>=e.length)return null}let i=Zr(r),a=s,l=s===t.segmentIndex?o:0,u=0,c=a,f=0,p=!1,h=-1,d=0,g=0,v=!1,w=(m,x,k,T)=>{h=m,d=x,g=k,v=T==="soft-hyphen"},b=(m,x,k)=>{for(let T=x;T<k.length;T++){let S=k[T];if(!p){u=S,c=m,f=T+1,p=!0;continue}if(u+S>n+.005)return!0;u+=S,c=m,f=T+1}return c===m&&f===k.length&&(c=m+1,f=0),!1};if(l>0&&a<e.length){let m=e[a];if(m.graphemeWidths){if(b(a,l,m.graphemeWidths))return{text:le(e,a,l,c,f,!1),width:u,start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}};s=c}}for(;s<e.length;){let m=e[s];if(m.kind==="hard-break"){if(p){let T=c>0&&e[c-1]?.kind==="soft-hyphen";return{text:le(e,a,l,c,f,T),width:u+(T?i:0),start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}}}return{text:"",width:0,start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:s+1,graphemeIndex:0}}}let x=m.width;if(!p){if(x>n&&m.graphemeWidths){if(b(s,0,m.graphemeWidths))return{text:le(e,a,l,c,f,!1),width:u,start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}};s=c;continue}u=x,c=s+1,f=0,p=!0,St(m.kind)&&w(s+1,0,m.kind==="space"?u-x:u,m.kind),s+=1;continue}let k=u+x;if(k>n+.005){if(St(m.kind)){c=s+1,f=0;let S=m.kind==="soft-hyphen",C=m.kind==="space"?u:u+(S?i:0);return{text:le(e,a,l,c,f,S),width:C,start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}}}return h>=0?{text:le(e,a,l,h,d,v),width:g+(v?i:0),start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:h,graphemeIndex:d}}:x>n&&m.graphemeWidths?{text:le(e,a,l,c,f,!1),width:u,start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}}:{text:le(e,a,l,c,f,!1),width:u,start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}}}u=k,c=s+1,f=0,St(m.kind)&&w(s+1,0,m.kind==="space"?u-x:u,m.kind),s+=1}if(!p)return null;let y=c>0&&e[c-1]?.kind==="soft-hyphen";return{text:le(e,a,l,c,f,y),width:u+(y?i:0),start:{segmentIndex:a,graphemeIndex:l},end:{segmentIndex:c,graphemeIndex:f}}}function Et(e,t,n=0){let r=[e];for(let s=0;s<t.length;s++){let o=t[s],i=[];for(let a=0;a<r.length;a++){let l=r[a];if(o.right<=l.left||o.left>=l.right){i.push(l);continue}o.left>l.left&&i.push({left:l.left,right:o.left}),o.right<l.right&&i.push({left:o.right,right:l.right})}r=i}return n>0?r.filter(s=>s.right-s.left>=n):r}function qe(e,t,n){let r=[],s=new Intl.Segmenter(void 0,{granularity:"grapheme"});for(let o=0;o<e.lines.length;o++){let i=e.lines[o],a=o*n,l=0;for(let u=i.startSegment;u<t.length;u++){let c=t[u];if(c.kind==="soft-hyphen"||c.kind==="hard-break"){if(u>=i.endSegment&&i.endGrapheme===0)break;continue}let f=[...s.segment(c.text)].map(d=>d.segment);if(f.length===0)continue;let p=u===i.startSegment?i.startGrapheme:0,h;if(u<i.endSegment)h=f.length;else if(u===i.endSegment&&i.endGrapheme>0)h=i.endGrapheme;else break;for(let d=p;d<h;d++){let g=c.graphemeWidths?c.graphemeWidths[d]:c.width/f.length;r.push({x:l,y:a,width:g,height:n,line:o}),l+=g}}}return r}function Qr(e){let{adapter:t,name:n="reactive-layout"}=e,r=new oe(n),s=new Map,o=G(e.text??"",{name:"text"}),i=G(e.font??"16px sans-serif",{name:"font"}),a=G(e.lineHeight??20,{name:"line-height"}),l=G(Math.max(0,e.maxWidth??800),{name:"max-width"});function u(d,g){if(d===null||g===null)return d===g;if(d.length!==g.length)return!1;for(let v=0;v<d.length;v++)if(d[v]!==g[v])return!1;return!0}let c=re([o,i],(d,g,v)=>{let w=d[0],b=w!=null&&w.length>0?w.at(-1):v.prevData[0],y=d[1],_=y!=null&&y.length>0?y.at(-1):v.prevData[1],m=F(),x={hits:0,misses:0},k=we(b,_,t,s,x),T=F()-m,S=x.hits+x.misses,C=S===0?1:x.hits/S,O=c.meta;O&&(ee(O["cache-hit-rate"],C),ee(O["segment-count"],k.length),ee(O["layout-time-ns"],T)),g.emit(k);let E=()=>{s.clear(),t.clearCache?.()};return{deactivate:E,invalidate:E}},{name:"segments",describeKind:"derived",meta:{"cache-hit-rate":0,"segment-count":0,"layout-time-ns":0},equals:(d,g)=>{let v=d,w=g;if(v==null||w==null)return v===w;if(v.length!==w.length)return!1;for(let b=0;b<v.length;b++){let y=v[b],_=w[b];if(y.text!==_.text||y.width!==_.width||y.kind!==_.kind||!u(y.graphemeWidths??null,_.graphemeWidths??null))return!1}return!0}}),f=Y([c,l,i],([d,g,v])=>Ke(d,g,t,v,s),{name:"line-breaks",equals:(d,g)=>{let v=d,w=g;if(v==null||w==null)return v===w;if(v.lineCount!==w.lineCount)return!1;for(let b=0;b<v.lines.length;b++){let y=v.lines[b],_=w.lines[b];if(y.text!==_.text||y.width!==_.width||y.startSegment!==_.startSegment||y.startGrapheme!==_.startGrapheme||y.endSegment!==_.endSegment||y.endGrapheme!==_.endGrapheme)return!1}return!0}}),p=Y([f,a],([d,g])=>d.lineCount*g,{name:"height"}),h=Y([f,c,a],([d,g,v])=>qe(d,g,v),{name:"char-positions",equals:(d,g)=>{let v=d,w=g;if(v==null||w==null)return v===w;if(v.length!==w.length)return!1;for(let b=0;b<v.length;b++)if(v[b].x!==w[b].x||v[b].y!==w[b].y||v[b].width!==w[b].width)return!1;return!0}});return r.add(o,{name:"text"}),r.add(i,{name:"font"}),r.add(a,{name:"line-height"}),r.add(l,{name:"max-width"}),r.add(c,{name:"segments"}),r.add(f,{name:"line-breaks"}),r.add(p,{name:"height"}),r.add(h,{name:"char-positions"}),{graph:r,setText:d=>r.set("text",d),setFont:d=>r.set("font",d),setLineHeight:d=>r.set("line-height",d),setMaxWidth:d=>r.set("max-width",Math.max(0,d)),segments:c,lineBreaks:f,height:p,charPositions:h}}function Sn(e,t,n,r,s,o,i){switch(e.type){case"text":{let a=e.font??s,l=e.lineHeight??o,u=we(e.text,a,n.text,r),c=Ke(u,t,n.text,a,r),f=qe(c,u,l),p=c.lineCount*l,h=0;for(let d of c.lines)d.width>h&&(h=d.width);return{index:i,type:"text",width:Math.min(h,t),height:p,textSegments:u,textLineBreaks:c,textCharPositions:f}}case"image":{let a,l;if(e.naturalWidth!=null&&e.naturalHeight!=null)a=e.naturalWidth,l=e.naturalHeight;else if(n.image){let u=n.image.measureImage(e.src);a=u.width,l=u.height}else throw new Error(`Image block at index ${i} has no naturalWidth/naturalHeight and no ImageMeasurer adapter`);return a>t&&(l=l*t/a,a=t),{index:i,type:"image",width:a,height:l}}case"svg":{let a,l;if(e.viewBox)a=e.viewBox.width,l=e.viewBox.height;else if(n.svg){let u=n.svg.measureSvg(e.content);a=u.width,l=u.height}else throw new Error(`SVG block at index ${i} has no viewBox and no SvgMeasurer adapter`);return a>t&&(l=l*t/a,a=t),{index:i,type:"svg",width:a,height:l}}}}function On(e,t,n,r,s,o){return e.map((i,a)=>Sn(i,t,n,r,s,o,a))}function Nn(e,t){let n=[],r=0;for(let s=0;s<e.length;s++){let o=e[s];n.push({...o,x:0,y:r}),r+=o.height+(s<e.length-1?t:0)}return n}function En(e){if(e.length===0)return 0;let t=e[e.length-1];return t.y+t.height}function es(e){let{adapters:t,name:n="reactive-block-layout",defaultFont:r="16px sans-serif",defaultLineHeight:s=20}=e,o=new oe(n),i=new Map,a=G(e.blocks??[],{name:"blocks"}),l=G(Math.max(0,e.maxWidth??800),{name:"max-width"}),u=G(e.gap??0,{name:"gap"}),c=re([a,l],(h,d,g)=>{let v=h[0]!=null&&h[0].length>0?h[0].at(-1):g.prevData[0],w=h[1]!=null&&h[1].length>0?h[1].at(-1):g.prevData[1],b=F(),y=On(v,w,t,i,r,s),_=F()-b,m=c.meta;m&&(ee(m["block-count"],y.length),ee(m["layout-time-ns"],_)),d.emit(y);let x=()=>{i.clear(),t.text.clearCache?.()};return{deactivate:x,invalidate:x}},{name:"measured-blocks",describeKind:"derived",meta:{"block-count":0,"layout-time-ns":0},equals:(h,d)=>{let g=h,v=d;if(g==null||v==null)return g===v;if(g.length!==v.length)return!1;for(let w=0;w<g.length;w++){let b=g[w],y=v[w];if(b.type!==y.type||b.width!==y.width||b.height!==y.height||b.index!==y.index)return!1}return!0}}),f=Y([c,u],([h,d])=>Nn(h,d),{name:"block-flow",equals:(h,d)=>{let g=h,v=d;if(g==null||v==null)return g===v;if(g.length!==v.length)return!1;for(let w=0;w<g.length;w++){let b=g[w],y=v[w];if(b.x!==y.x||b.y!==y.y||b.width!==y.width||b.height!==y.height)return!1}return!0}}),p=Y([f],([h])=>En(h),{name:"total-height"});return o.add(a,{name:"blocks"}),o.add(l,{name:"max-width"}),o.add(u,{name:"gap"}),o.add(c,{name:"measured-blocks"}),o.add(f,{name:"block-flow"}),o.add(p,{name:"total-height"}),{graph:o,setBlocks:h=>o.set("blocks",h),setMaxWidth:h=>o.set("max-width",Math.max(0,h)),setGap:h=>o.set("gap",h),measuredBlocks:c,blockFlow:f,totalHeight:p}}pe();se();Ee();function Cn(e,t,n){let r=e.hPad??0,s=e.vPad??0,o=t-s,i=n+s;if(o>=e.cy+e.r||i<=e.cy-e.r)return null;let a=e.cy>=o&&e.cy<=i?0:e.cy<o?o-e.cy:e.cy-i;if(a>=e.r)return null;let l=Math.sqrt(e.r*e.r-a*a);return{left:e.cx-l-r,right:e.cx+l+r}}function Rn(e,t,n){let r=e.hPad??0,s=e.vPad??0;return n<=e.y-s||t>=e.y+e.h+s?null:{left:e.x-r,right:e.x+e.w+r}}function ts(e,t,n){return e.kind==="circle"?Cn(e,t,n):Rn(e,t,n)}function An(e,t,n,r,s,o,i){let a=i?.paragraphSpacing??s,l=[],u={segmentIndex:0,graphemeIndex:0};if(e.length===0||n.count<=0||s<=0)return{lines:l,cursor:u};let c=t.paddingX??0,f=t.paddingY??0,p=Math.max(0,t.width-c*2),h=Math.max(0,t.height-f*2),d=n.gap*Math.max(0,n.count-1),g=Math.max(0,(p-d)/n.count);if(g<=0)return{lines:l,cursor:u};e:for(let v=0;v<n.count;v++){let w=c+v*(g+n.gap),b=w+g,y=f;for(;y+s<=f+h;){let _=y+s,m=[];for(let T=0;T<r.length;T++){let S=ts(r[T],y,_);S!==null&&m.push(S)}let x=Et({left:w,right:b},m,o);if(x.length===0){y+=s;continue}let k=!1;for(let T=0;T<x.length;T++){let S=x[T],C=S.right-S.left,O=Nt(e,u,C);if(O===null)return{lines:l,cursor:u};if(O.text.length===0&&O.width===0){u=O.end,k=!0;break}l.push({x:S.left,y,width:O.width,slotWidth:C,text:O.text,columnIndex:v,flushToRight:S.right<b-.5}),u=O.end}if(k){y+=a;continue}if(y+=s,u.segmentIndex>=e.length)break e}if(u.segmentIndex>=e.length)break}return{lines:l,cursor:u}}function ns(e){let{adapter:t,name:n="reactive-flow-layout",minSlotWidth:r=20}=e,s=new oe(n),o=new Map,i=G(e.text??"",{name:"text"}),a=G(e.font??"16px sans-serif",{name:"font"}),l=G(e.lineHeight??20,{name:"line-height"}),u=G(e.container??{width:800,height:600,paddingX:0,paddingY:0},{name:"container"}),c=G(e.columns??{count:1,gap:0},{name:"columns"}),f=G(e.obstacles??[],{name:"obstacles"}),p=G(e.paragraphSpacing??null,{name:"paragraph-spacing"}),h=re([i,a],(g,v,w)=>{let b=g[0],y=b!=null&&b.length>0?b.at(-1):w.prevData[0],_=g[1],m=_!=null&&_.length>0?_.at(-1):w.prevData[1],x=we(y,m,t,o);v.emit(x);let k=()=>{o.clear(),t.clearCache?.()};return{deactivate:k,invalidate:k}},{name:"segments",describeKind:"derived"}),d=Y([h,u,c,f,l,p],([g,v,w,b,y,_])=>{let m=g,x=F(),k=_??y,{lines:T,cursor:S}=An(m,v,w,b,y,r,{paragraphSpacing:k}),C=F()-x,O=Math.max(0,m.length-S.segmentIndex),E=d.meta;return E&&(ee(E["line-count"],T.length),ee(E["layout-time-ns"],C),ee(E["overflow-segments"],O)),T},{name:"flow-lines",meta:{"line-count":0,"layout-time-ns":0,"overflow-segments":0},equals:(g,v)=>{let w=g,b=v;if(w.length!==b.length)return!1;for(let y=0;y<w.length;y++){let _=w[y],m=b[y];if(_.x!==m.x||_.y!==m.y||_.width!==m.width||_.slotWidth!==m.slotWidth||_.text!==m.text||_.columnIndex!==m.columnIndex||_.flushToRight!==m.flushToRight)return!1}return!0}});return s.add(i,{name:"text"}),s.add(a,{name:"font"}),s.add(l,{name:"line-height"}),s.add(u,{name:"container"}),s.add(c,{name:"columns"}),s.add(f,{name:"obstacles"}),s.add(p,{name:"paragraph-spacing"}),s.add(h,{name:"segments"}),s.add(d,{name:"flow-lines"}),{graph:s,setText:g=>s.set("text",g),setFont:g=>s.set("font",g),setLineHeight:g=>s.set("line-height",g),setContainer:g=>s.set("container",g),setColumns:g=>s.set("columns",g),setObstacles:g=>s.set("obstacles",g),setParagraphSpacing:g=>s.set("paragraph-spacing",g),segments:h,flowLines:d}}0&&(module.exports={CanvasMeasureAdapter,CliMeasureAdapter,ImageSizeAdapter,NodeCanvasMeasureAdapter,PrecomputedAdapter,SvgBoundsAdapter,analyzeAndMeasure,carveTextLineSlots,circleIntervalForBand,computeBlockFlow,computeCharPositions,computeFlowLines,computeLineBreaks,computeTotalHeight,layoutNextLine,measureBlock,measureBlocks,reactiveBlockLayout,reactiveFlowLayout,reactiveLayout,rectIntervalForBand});
|