@graphrefly/graphrefly 0.27.0 → 0.28.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/backoff-HPZMEZNF.js +1 -0
- package/dist/cascading-B-5zmAUv.d.cts +180 -0
- package/dist/cascading-D9WG1-9L.d.ts +180 -0
- package/dist/chunk-2FOAM3OR.js +1 -0
- package/dist/chunk-2PMCKKRK.js +1 -0
- package/dist/chunk-3JXNEPCD.js +2 -0
- package/dist/chunk-3R5HFPX7.js +78 -0
- package/dist/chunk-4GKB4OUJ.js +1 -0
- package/dist/chunk-4VVTGLXJ.js +1 -0
- package/dist/chunk-5QDBSZBV.js +1 -0
- package/dist/chunk-6QZNQS5B.js +1 -0
- package/dist/chunk-6V3SEX2I.js +1 -0
- package/dist/chunk-76A3HVQE.js +9 -0
- package/dist/chunk-7H6LGFUG.js +64 -0
- package/dist/chunk-CK2E7BTU.js +1 -0
- package/dist/chunk-CKCSDI7T.js +6 -0
- package/dist/chunk-CRXTH3SH.js +1 -0
- package/dist/chunk-CWLN3X3N.js +1 -0
- package/dist/chunk-D7A7DBE4.js +1 -0
- package/dist/chunk-DBGGMN3D.js +1 -0
- package/dist/chunk-DQA3UIQ2.js +1 -0
- package/dist/chunk-ERLIRFPA.js +1 -0
- package/dist/chunk-ESMPEKEV.js +1 -0
- package/dist/chunk-ETWTCCJI.js +1 -0
- package/dist/chunk-FNYWM6JC.js +1 -0
- package/dist/chunk-GHJJR5P4.js +1 -0
- package/dist/chunk-GPW2V3RE.js +1 -0
- package/dist/chunk-I6VIH3VA.js +1 -0
- package/dist/chunk-K2GNMCQT.js +1 -0
- package/dist/chunk-LBTDSCCO.js +3 -0
- package/dist/chunk-LQ3Y5NJS.js +1 -0
- package/dist/chunk-MIQTDPY4.js +5 -0
- package/dist/chunk-MTTAAPCK.js +1 -0
- package/dist/chunk-OAWLCNJJ.js +1 -0
- package/dist/chunk-OBKQQA5I.js +1 -0
- package/dist/chunk-OYHGKYQM.js +1 -0
- package/dist/chunk-PIOGHC63.js +1 -0
- package/dist/chunk-QWAPKG3O.js +2 -0
- package/dist/chunk-QYADASLV.js +1 -0
- package/dist/chunk-RHESUC3V.js +43 -0
- package/dist/chunk-S35VARIR.js +1 -0
- package/dist/chunk-SC3U7ETD.js +1 -0
- package/dist/chunk-U3AICJKU.js +1 -0
- package/dist/chunk-UMBIDLJ4.js +1 -0
- package/dist/chunk-UPHHLMHE.js +1 -0
- package/dist/chunk-UPXUCFMX.js +1 -0
- package/dist/chunk-UWJE5FQA.js +18 -0
- package/dist/chunk-V6YQICXZ.js +1 -0
- package/dist/chunk-VIMF6LGM.js +1 -0
- package/dist/chunk-VJLMUKOI.js +1 -0
- package/dist/chunk-VPYBOXVT.js +1 -0
- package/dist/chunk-VTPVOGHH.js +1 -0
- package/dist/chunk-WQ2BN6X6.js +1 -0
- package/dist/chunk-XAUNPIMX.js +1 -0
- package/dist/chunk-Y2EMPB3I.js +1 -0
- package/dist/chunk-Z4HDAS2Q.js +1 -0
- package/dist/chunk-ZB5EHBIO.js +1 -0
- package/dist/chunk-ZV2DXV5A.js +23 -0
- package/dist/compat/index.cjs +14 -7656
- package/dist/compat/index.d.cts +15 -14
- package/dist/compat/index.d.ts +15 -14
- package/dist/compat/index.js +1 -50
- package/dist/compat/jotai/index.cjs +1 -2048
- package/dist/compat/jotai/index.d.cts +2 -2
- package/dist/compat/jotai/index.d.ts +2 -2
- package/dist/compat/jotai/index.js +1 -9
- package/dist/compat/nanostores/index.cjs +1 -2175
- package/dist/compat/nanostores/index.d.cts +2 -2
- package/dist/compat/nanostores/index.d.ts +2 -2
- package/dist/compat/nanostores/index.js +1 -23
- package/dist/compat/nestjs/index.cjs +14 -6782
- package/dist/compat/nestjs/index.d.cts +7 -6
- package/dist/compat/nestjs/index.d.ts +7 -6
- package/dist/compat/nestjs/index.js +1 -83
- package/dist/compat/react/index.cjs +1 -141
- package/dist/compat/react/index.d.cts +2 -2
- package/dist/compat/react/index.d.ts +2 -2
- package/dist/compat/react/index.js +1 -12
- package/dist/compat/solid/index.cjs +1 -128
- package/dist/compat/solid/index.d.cts +2 -2
- package/dist/compat/solid/index.d.ts +2 -2
- package/dist/compat/solid/index.js +1 -12
- package/dist/compat/svelte/index.cjs +1 -131
- package/dist/compat/svelte/index.d.cts +2 -2
- package/dist/compat/svelte/index.d.ts +2 -2
- package/dist/compat/svelte/index.js +1 -12
- package/dist/compat/vue/index.cjs +1 -146
- package/dist/compat/vue/index.d.cts +2 -2
- package/dist/compat/vue/index.d.ts +2 -2
- package/dist/compat/vue/index.js +1 -12
- package/dist/compat/zustand/index.cjs +6 -4931
- package/dist/compat/zustand/index.d.cts +5 -5
- package/dist/compat/zustand/index.d.ts +5 -5
- package/dist/compat/zustand/index.js +1 -12
- package/dist/composite-B-xqw4Kk.d.cts +69 -0
- package/dist/composite-BhbKHbOS.d.ts +69 -0
- package/dist/core/index.cjs +1 -2271
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +1 -110
- package/dist/extra/browser.cjs +1 -0
- package/dist/extra/browser.d.cts +3 -0
- package/dist/extra/browser.d.ts +3 -0
- package/dist/extra/browser.js +1 -0
- package/dist/extra/index.cjs +23 -9971
- package/dist/extra/index.d.cts +13 -6
- package/dist/extra/index.d.ts +13 -6
- package/dist/extra/index.js +1 -381
- package/dist/extra/node.cjs +3 -0
- package/dist/extra/node.d.cts +81 -0
- package/dist/extra/node.d.ts +81 -0
- package/dist/extra/node.js +2 -0
- package/dist/extra/operators.cjs +1 -0
- package/dist/extra/operators.d.cts +910 -0
- package/dist/extra/operators.d.ts +910 -0
- package/dist/extra/operators.js +1 -0
- package/dist/extra/reactive.cjs +1 -0
- package/dist/extra/reactive.d.cts +352 -0
- package/dist/extra/reactive.d.ts +352 -0
- package/dist/extra/reactive.js +1 -0
- package/dist/extra/sources.cjs +1 -2486
- package/dist/extra/sources.d.cts +6 -2
- package/dist/extra/sources.d.ts +6 -2
- package/dist/extra/sources.js +1 -57
- package/dist/extra/storage-browser.cjs +1 -0
- package/dist/extra/storage-browser.d.cts +71 -0
- package/dist/extra/storage-browser.d.ts +71 -0
- package/dist/extra/storage-browser.js +1 -0
- package/dist/extra/storage-core.cjs +1 -0
- package/dist/extra/storage-core.d.cts +98 -0
- package/dist/extra/storage-core.d.ts +98 -0
- package/dist/extra/storage-core.js +1 -0
- package/dist/extra/storage-node.cjs +2 -0
- package/dist/extra/storage-node.d.cts +60 -0
- package/dist/extra/storage-node.d.ts +60 -0
- package/dist/extra/storage-node.js +1 -0
- package/dist/fallback-BaTS7vVY.d.cts +258 -0
- package/dist/fallback-eOm3LNxP.d.ts +258 -0
- package/dist/graph/index.cjs +6 -5030
- package/dist/graph/index.d.cts +6 -5
- package/dist/graph/index.d.ts +6 -5
- package/dist/graph/index.js +1 -50
- package/dist/{graph-CCwGKLCm.d.ts → graph-BZGRXwOm.d.ts} +134 -31
- package/dist/{graph-DNCrvZSn.d.cts → graph-D48Qw9Cg.d.cts} +134 -31
- package/dist/index-8FSVk4Uf.d.ts +135 -0
- package/dist/index-9oDeHH2u.d.cts +291 -0
- package/dist/{messaging-XDoYablx.d.ts → index-B0c4cmIO.d.ts} +31 -93
- package/dist/{index-VdHQMPy1.d.ts → index-B1AmmSlb.d.ts} +1 -1
- package/dist/{index-VHqptjhu.d.cts → index-B2pwesl9.d.cts} +1 -1
- package/dist/index-BHvIquRZ.d.ts +1957 -0
- package/dist/{index-Dzk2hrlR.d.ts → index-BVHOrDwO.d.ts} +1 -1
- package/dist/{index-CxFrXH4m.d.ts → index-BWJV63ti.d.ts} +1 -1
- package/dist/{index-Xi3u0HCQ.d.cts → index-B_agccPe.d.cts} +1 -1
- package/dist/index-BgyGlizc.d.ts +163 -0
- package/dist/index-BpA5c4G9.d.ts +357 -0
- package/dist/index-BpIFjILY.d.cts +357 -0
- package/dist/{index-3lsddbbS.d.ts → index-Bqachn9_.d.ts} +1 -1
- package/dist/index-Btib9rsU.d.ts +607 -0
- package/dist/{index-wEn0eFe8.d.ts → index-BwM9BEkt.d.ts} +1 -1
- package/dist/index-BxJ86YZZ.d.cts +105 -0
- package/dist/{audit-DRlSzBu9.d.ts → index-C73n7lo-.d.cts} +27 -21
- package/dist/index-CEXXwWVH.d.cts +192 -0
- package/dist/index-CHEswufn.d.cts +163 -0
- package/dist/{index-C0svESO4.d.ts → index-CMn8S8Hw.d.ts} +1 -1
- package/dist/{index-ByQxazQJ.d.cts → index-CRO83MmV.d.cts} +1 -1
- package/dist/{index-BuEoe-Qu.d.ts → index-CloUk1kY.d.ts} +9 -9
- package/dist/index-CpgYhnrG.d.ts +291 -0
- package/dist/{index-DO_6JN9Z.d.cts → index-Cyojz0AE.d.cts} +1 -1
- package/dist/{demo-shell-BDkOptd6.d.ts → index-CzobVSMr.d.ts} +14 -14
- package/dist/index-Czq6ynh8.d.ts +143 -0
- package/dist/{index-BaSM3aYt.d.ts → index-D-YB-Vl3.d.ts} +3 -3
- package/dist/index-DAlweici.d.ts +231 -0
- package/dist/index-DEwTb_fm.d.cts +1957 -0
- package/dist/{index-DYme44FM.d.cts → index-DL-rYJrx.d.cts} +1 -1
- package/dist/{memory-li6FL5RM.d.ts → index-DP4ZTkdw.d.ts} +26 -26
- package/dist/{index-BwfLUNw4.d.ts → index-DUqMOlKZ.d.cts} +173 -2040
- package/dist/{index-B1tloyhO.d.cts → index-D_NwnRYS.d.cts} +1 -1
- package/dist/index-DaLJvH8Z.d.ts +105 -0
- package/dist/index-DcXZBF5a.d.cts +135 -0
- package/dist/index-DfyOkTvs.d.ts +321 -0
- package/dist/{index-B9B7_HEY.d.ts → index-DiOXyAwt.d.ts} +1 -1
- package/dist/index-DpHe5e0Q.d.ts +186 -0
- package/dist/index-DraikLjn.d.ts +86 -0
- package/dist/{index-D8wS_PeY.d.cts → index-DxsnAMWD.d.cts} +9 -9
- package/dist/{messaging-Gt4LPbyA.d.cts → index-DyxjtScX.d.cts} +31 -93
- package/dist/{audit-ClmqGOCx.d.cts → index-HDpJe9hX.d.ts} +27 -21
- package/dist/{index-DVGiGFGT.d.cts → index-O6TgGUBV.d.cts} +3 -3
- package/dist/{index-B6EhDnjH.d.cts → index-Oi8d8w4R.d.cts} +1 -1
- package/dist/{index-C8oil6M6.d.ts → index-ROpQmGjE.d.ts} +30 -6
- package/dist/index-RukJ4DLS.d.cts +607 -0
- package/dist/{index-BHlKbUwO.d.cts → index-ZftwfxJM.d.ts} +173 -2040
- package/dist/{index-BPVt8kqc.d.ts → index-cByzxQIC.d.cts} +10 -195
- package/dist/index-dtN7YA2x.d.cts +143 -0
- package/dist/{index-CI3DprxP.d.cts → index-fM6y00vT.d.cts} +30 -6
- package/dist/{index-DlLp-2Xn.d.cts → index-m-yHof5p.d.ts} +10 -195
- package/dist/index-pXrDMpRO.d.cts +231 -0
- package/dist/index-rHJSKsU8.d.cts +186 -0
- package/dist/index-rX8HBM5h.d.cts +321 -0
- package/dist/{index-CO8uBlUh.d.cts → index-rnwQly8X.d.cts} +147 -20
- package/dist/index-sm373fsH.d.ts +192 -0
- package/dist/{memory-C6Z2tGpC.d.cts → index-tbf2gKHd.d.cts} +26 -26
- package/dist/{demo-shell-Crid1WdR.d.cts → index-u15meRxL.d.cts} +14 -14
- package/dist/{index-B6D3QNSA.d.ts → index-umtoWT8K.d.ts} +147 -20
- package/dist/index-vscRDkjW.d.cts +86 -0
- package/dist/index.cjs +150 -24142
- package/dist/index.d.cts +69 -2099
- package/dist/index.d.ts +69 -2099
- package/dist/index.js +1 -3868
- package/dist/{meta-CbznRPYJ.d.ts → meta-Cgj6zeji.d.cts} +5 -5
- package/dist/{meta-BxCA7rcr.d.cts → meta-CwesDrMD.d.ts} +5 -5
- package/dist/{node-BmerH3kS.d.cts → node-Cc1TniY8.d.cts} +36 -9
- package/dist/{node-BmerH3kS.d.ts → node-Cc1TniY8.d.ts} +36 -9
- package/dist/{observable-BgGUwcqp.d.ts → observable-Ct-gJ9jI.d.ts} +1 -1
- package/dist/{observable-DJt_AxzQ.d.cts → observable-glXQoGj2.d.cts} +1 -1
- package/dist/patterns/ai/browser.cjs +25 -0
- package/dist/patterns/ai/browser.d.cts +127 -0
- package/dist/patterns/ai/browser.d.ts +127 -0
- package/dist/patterns/ai/browser.js +3 -0
- package/dist/patterns/ai/index.cjs +91 -0
- package/dist/patterns/ai/index.d.cts +17 -0
- package/dist/patterns/ai/index.d.ts +17 -0
- package/dist/patterns/ai/index.js +1 -0
- package/dist/patterns/ai/node.cjs +2 -0
- package/dist/patterns/ai/node.d.cts +58 -0
- package/dist/patterns/ai/node.d.ts +58 -0
- package/dist/patterns/ai/node.js +1 -0
- package/dist/patterns/audit/index.cjs +6 -0
- package/dist/patterns/audit/index.d.cts +6 -0
- package/dist/patterns/audit/index.d.ts +6 -0
- package/dist/patterns/audit/index.js +1 -0
- package/dist/patterns/cqrs/index.cjs +6 -0
- package/dist/patterns/cqrs/index.d.cts +5 -0
- package/dist/patterns/cqrs/index.d.ts +5 -0
- package/dist/patterns/cqrs/index.js +1 -0
- package/dist/patterns/demo-shell/index.cjs +7 -0
- package/dist/patterns/demo-shell/index.d.cts +6 -0
- package/dist/patterns/demo-shell/index.d.ts +6 -0
- package/dist/patterns/demo-shell/index.js +1 -0
- package/dist/patterns/domain-templates/index.cjs +6 -0
- package/dist/patterns/domain-templates/index.d.cts +5 -0
- package/dist/patterns/domain-templates/index.d.ts +5 -0
- package/dist/patterns/domain-templates/index.js +1 -0
- package/dist/patterns/graphspec/index.cjs +83 -0
- package/dist/patterns/graphspec/index.d.cts +7 -0
- package/dist/patterns/graphspec/index.d.ts +7 -0
- package/dist/patterns/graphspec/index.js +1 -0
- package/dist/patterns/guarded-execution/index.cjs +6 -0
- package/dist/patterns/guarded-execution/index.d.cts +7 -0
- package/dist/patterns/guarded-execution/index.d.ts +7 -0
- package/dist/patterns/guarded-execution/index.js +1 -0
- package/dist/patterns/harness/index.cjs +48 -0
- package/dist/patterns/harness/index.d.cts +8 -0
- package/dist/patterns/harness/index.d.ts +8 -0
- package/dist/patterns/harness/index.js +1 -0
- package/dist/patterns/job-queue/index.cjs +6 -0
- package/dist/patterns/job-queue/index.d.cts +5 -0
- package/dist/patterns/job-queue/index.d.ts +5 -0
- package/dist/patterns/job-queue/index.js +1 -0
- package/dist/patterns/lens/index.cjs +6 -0
- package/dist/patterns/lens/index.d.cts +7 -0
- package/dist/patterns/lens/index.d.ts +7 -0
- package/dist/patterns/lens/index.js +1 -0
- package/dist/patterns/memory/index.cjs +6 -0
- package/dist/patterns/memory/index.d.cts +5 -0
- package/dist/patterns/memory/index.d.ts +5 -0
- package/dist/patterns/memory/index.js +1 -0
- package/dist/patterns/messaging/index.cjs +6 -0
- package/dist/patterns/messaging/index.d.cts +5 -0
- package/dist/patterns/messaging/index.d.ts +5 -0
- package/dist/patterns/messaging/index.js +1 -0
- package/dist/patterns/orchestration/index.cjs +6 -0
- package/dist/patterns/orchestration/index.d.cts +6 -0
- package/dist/patterns/orchestration/index.d.ts +6 -0
- package/dist/patterns/orchestration/index.js +1 -0
- package/dist/patterns/reactive-layout/index.cjs +7 -6444
- package/dist/patterns/reactive-layout/index.d.cts +6 -6
- package/dist/patterns/reactive-layout/index.d.ts +6 -6
- package/dist/patterns/reactive-layout/index.js +1 -56
- package/dist/patterns/reduction/index.cjs +6 -0
- package/dist/patterns/reduction/index.d.cts +5 -0
- package/dist/patterns/reduction/index.d.ts +5 -0
- package/dist/patterns/reduction/index.js +1 -0
- package/dist/patterns/refine-loop/index.cjs +8 -0
- package/dist/patterns/refine-loop/index.d.cts +7 -0
- package/dist/patterns/refine-loop/index.d.ts +7 -0
- package/dist/patterns/refine-loop/index.js +1 -0
- package/dist/patterns/resilient-pipeline/index.cjs +1 -0
- package/dist/patterns/resilient-pipeline/index.d.cts +7 -0
- package/dist/patterns/resilient-pipeline/index.d.ts +7 -0
- package/dist/patterns/resilient-pipeline/index.js +1 -0
- package/dist/patterns/surface/index.cjs +14 -0
- package/dist/patterns/surface/index.d.cts +8 -0
- package/dist/patterns/surface/index.d.ts +8 -0
- package/dist/patterns/surface/index.js +1 -0
- package/dist/{reactive-layout-MQP--J3F.d.cts → reactive-layout-CpYb5qLP.d.cts} +2 -2
- package/dist/{reactive-layout-u5Ulnqag.d.ts → reactive-layout-D8u4wuUR.d.ts} +2 -2
- package/dist/reactive-log-DPzuUDj5.d.cts +190 -0
- package/dist/reactive-log-YuH9VYN8.d.ts +190 -0
- package/dist/{composite-aUCvjZVR.d.ts → reactive-map-CdbNoSgP.d.ts} +2 -67
- package/dist/{composite-C7PcQvcs.d.cts → reactive-map-DUeRmb9d.d.cts} +2 -67
- package/dist/resilience-Ba5-b4WD.d.cts +493 -0
- package/dist/resilience-CGRzhnD3.d.ts +493 -0
- package/dist/resilience-QAHKANT5.js +1 -0
- package/dist/{sugar-D02n5JjF.d.cts → sugar-BV0htudb.d.cts} +8 -4
- package/dist/{sugar-CCOxXK1e.d.ts → sugar-Dtyrq2_q.d.ts} +8 -4
- package/dist/topology-tree-CYHOwQZ_.d.ts +25 -0
- package/dist/topology-tree-DROUdq5B.d.cts +25 -0
- package/dist/types-O3GzJY2U.d.cts +401 -0
- package/dist/types-u64Ose53.d.ts +401 -0
- package/package.json +252 -22
- package/dist/ai-CaR_912Q.d.cts +0 -1033
- package/dist/ai-WlRltJV7.d.ts +0 -1033
- package/dist/chunk-3ZWCKRHX.js +0 -117
- package/dist/chunk-3ZWCKRHX.js.map +0 -1
- package/dist/chunk-7TAQJHQV.js +0 -103
- package/dist/chunk-7TAQJHQV.js.map +0 -1
- package/dist/chunk-APFNLIRG.js +0 -62
- package/dist/chunk-APFNLIRG.js.map +0 -1
- package/dist/chunk-AT5LKYNL.js +0 -395
- package/dist/chunk-AT5LKYNL.js.map +0 -1
- package/dist/chunk-BQ6RQQFF.js +0 -5087
- package/dist/chunk-BQ6RQQFF.js.map +0 -1
- package/dist/chunk-BVZYTZ5H.js +0 -599
- package/dist/chunk-BVZYTZ5H.js.map +0 -1
- package/dist/chunk-DST5DKZS.js +0 -1371
- package/dist/chunk-DST5DKZS.js.map +0 -1
- package/dist/chunk-GTE6PWRZ.js +0 -866
- package/dist/chunk-GTE6PWRZ.js.map +0 -1
- package/dist/chunk-HXZEYDUR.js +0 -94
- package/dist/chunk-HXZEYDUR.js.map +0 -1
- package/dist/chunk-J22W6HV3.js +0 -107
- package/dist/chunk-J22W6HV3.js.map +0 -1
- package/dist/chunk-J2VBW3DZ.js +0 -302
- package/dist/chunk-J2VBW3DZ.js.map +0 -1
- package/dist/chunk-JSCT3CR4.js +0 -38
- package/dist/chunk-JSCT3CR4.js.map +0 -1
- package/dist/chunk-JWBCY4NC.js +0 -330
- package/dist/chunk-JWBCY4NC.js.map +0 -1
- package/dist/chunk-K2AUJHVP.js +0 -2251
- package/dist/chunk-K2AUJHVP.js.map +0 -1
- package/dist/chunk-MJ2NKQQL.js +0 -119
- package/dist/chunk-MJ2NKQQL.js.map +0 -1
- package/dist/chunk-N6UR7YVY.js +0 -198
- package/dist/chunk-N6UR7YVY.js.map +0 -1
- package/dist/chunk-NC6S43JJ.js +0 -456
- package/dist/chunk-NC6S43JJ.js.map +0 -1
- package/dist/chunk-OFVJBJXR.js +0 -98
- package/dist/chunk-OFVJBJXR.js.map +0 -1
- package/dist/chunk-OHISZPOJ.js +0 -97
- package/dist/chunk-OHISZPOJ.js.map +0 -1
- package/dist/chunk-OU5CQKNW.js +0 -102
- package/dist/chunk-OU5CQKNW.js.map +0 -1
- package/dist/chunk-PF7GRZMW.js +0 -2712
- package/dist/chunk-PF7GRZMW.js.map +0 -1
- package/dist/chunk-PHOUUNK7.js +0 -2291
- package/dist/chunk-PHOUUNK7.js.map +0 -1
- package/dist/chunk-RNHBMHKA.js +0 -1665
- package/dist/chunk-RNHBMHKA.js.map +0 -1
- package/dist/chunk-SX52TAR4.js +0 -110
- package/dist/chunk-SX52TAR4.js.map +0 -1
- package/dist/chunk-VYPWMZ6H.js +0 -98
- package/dist/chunk-VYPWMZ6H.js.map +0 -1
- package/dist/chunk-WBZOVTYK.js +0 -171
- package/dist/chunk-WBZOVTYK.js.map +0 -1
- package/dist/chunk-WKNUIZOY.js +0 -354
- package/dist/chunk-WKNUIZOY.js.map +0 -1
- package/dist/chunk-X3VMZYBT.js +0 -713
- package/dist/chunk-X3VMZYBT.js.map +0 -1
- package/dist/chunk-X5R3GL6H.js +0 -525
- package/dist/chunk-X5R3GL6H.js.map +0 -1
- package/dist/chunk-XGPU467M.js +0 -136
- package/dist/chunk-XGPU467M.js.map +0 -1
- package/dist/compat/index.cjs.map +0 -1
- package/dist/compat/index.js.map +0 -1
- package/dist/compat/jotai/index.cjs.map +0 -1
- package/dist/compat/jotai/index.js.map +0 -1
- package/dist/compat/nanostores/index.cjs.map +0 -1
- package/dist/compat/nanostores/index.js.map +0 -1
- package/dist/compat/nestjs/index.cjs.map +0 -1
- package/dist/compat/nestjs/index.js.map +0 -1
- package/dist/compat/react/index.cjs.map +0 -1
- package/dist/compat/react/index.js.map +0 -1
- package/dist/compat/solid/index.cjs.map +0 -1
- package/dist/compat/solid/index.js.map +0 -1
- package/dist/compat/svelte/index.cjs.map +0 -1
- package/dist/compat/svelte/index.js.map +0 -1
- package/dist/compat/vue/index.cjs.map +0 -1
- package/dist/compat/vue/index.js.map +0 -1
- package/dist/compat/zustand/index.cjs.map +0 -1
- package/dist/compat/zustand/index.js.map +0 -1
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/extra/index.cjs.map +0 -1
- package/dist/extra/index.js.map +0 -1
- package/dist/extra/sources.cjs.map +0 -1
- package/dist/extra/sources.js.map +0 -1
- package/dist/graph/index.cjs.map +0 -1
- package/dist/graph/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/patterns/ai.cjs +0 -7930
- package/dist/patterns/ai.cjs.map +0 -1
- package/dist/patterns/ai.d.cts +0 -10
- package/dist/patterns/ai.d.ts +0 -10
- package/dist/patterns/ai.js +0 -71
- package/dist/patterns/ai.js.map +0 -1
- package/dist/patterns/audit.cjs +0 -5805
- package/dist/patterns/audit.cjs.map +0 -1
- package/dist/patterns/audit.d.cts +0 -6
- package/dist/patterns/audit.d.ts +0 -6
- package/dist/patterns/audit.js +0 -29
- package/dist/patterns/audit.js.map +0 -1
- package/dist/patterns/demo-shell.cjs +0 -5604
- package/dist/patterns/demo-shell.cjs.map +0 -1
- package/dist/patterns/demo-shell.d.cts +0 -6
- package/dist/patterns/demo-shell.d.ts +0 -6
- package/dist/patterns/demo-shell.js +0 -15
- package/dist/patterns/demo-shell.js.map +0 -1
- package/dist/patterns/memory.cjs +0 -5283
- package/dist/patterns/memory.cjs.map +0 -1
- package/dist/patterns/memory.d.cts +0 -5
- package/dist/patterns/memory.d.ts +0 -5
- package/dist/patterns/memory.js +0 -20
- package/dist/patterns/memory.js.map +0 -1
- package/dist/patterns/reactive-layout/index.cjs.map +0 -1
- package/dist/patterns/reactive-layout/index.js.map +0 -1
- package/dist/storage-CMjUUuxn.d.ts +0 -190
- package/dist/storage-DdWlZo6U.d.cts +0 -190
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var fe=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var bt=Object.getOwnPropertyNames;var gt=Object.prototype.hasOwnProperty;var N=(t,e)=>()=>(t&&(e=t(t=0)),e);var yt=(t,e)=>{for(var n in e)fe(t,n,{get:e[n],enumerable:!0})},_t=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of bt(e))!gt.call(t,o)&&o!==n&&fe(t,o,{get:()=>e[o],enumerable:!(r=mt(e,o))||r.enumerable});return t};var wt=t=>_t(fe({},"__esModule",{value:!0}),t);function D(t){return t<0?0:t}function vt(t,e){return e==="none"?t:e==="full"?Math.random()*t:t/2+Math.random()*(t/2)}function Tt(t,e){return t+Math.random()*(e-t)}function xt(t){let e=D(t);return()=>e}function Nt(t,e){let n=D(t),r=e===void 0?n:D(e);return o=>n+r*Math.max(0,o)}function kt(t){let e=D(t?.baseNs??1e8),n=t?.factor!==void 0&&t.factor<1?1:t?.factor??2,r=D(t?.maxDelayNs??30*1e9),o=t?.jitter??"none";return i=>{let s;if(e===0)s=0;else if(n===1)s=e;else{let a=r/e,u=1;for(let d=0;d<Math.max(0,i);d++){if(u>=a){u=a;break}u*=n}s=e*u,s>r&&(s=r)}return vt(s,o)}}function Et(t=100*1e6,e=30*1e9){let n=D(t),r=D(e);function o(i){if(i<=0)return 1;let s=1,a=2;for(let u=1;u<i;u++){let d=s+a;s=a,a=d}return a}return i=>{let s=o(i)*n;return s<=r?s:r}}function St(t=100*1e6,e=30*1e9){return(n,r,o)=>{let s=Math.min(e,(o??t)*3);return Tt(t,s)}}function De(t){if(t==="constant")return xt(1*1e9);if(t==="linear")return Nt(1*1e9);if(t==="exponential")return kt();if(t==="fibonacci")return Et();if(t==="decorrelatedJitter")return St();throw new Error(`Unknown backoff preset: "${String(t)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var R,F,pe=N(()=>{"use strict";R=1e6,F=1e9});function Fe(){return G>0||X}function Ie(){return G>0}function Le(t){G>0?Z.push(t):t()}function he(t){G+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(G-=1,G===0)if(e){if(!X){let n=Z.splice(0);for(let r of n)try{r()}catch{}I.length=0,L.length=0,V.length=0}}else Ot()}}function Ot(){let t=!X;t&&(X=!0);let e=[],n=0;try{for(;I.length>0||L.length>0||V.length>0||t&&Z.length>0;){if(t&&Z.length>0){let i=Z.splice(0);for(let s of i)try{s()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw I.length=0,L.length=0,V.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(I.length>0?I:L.length>0?L:V).splice(0);for(let i of o)try{i()}catch(s){e.push(s)}}}finally{t&&(X=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function re(t,e,n){if(e.length===0)return;if(e.length===1){let d=n(e[0][0]);if(d<3||!Fe()){t(e);return}(d>=5?V:d===4?L:I).push(()=>t(e));return}let r=e.length,o=r,i=r,s=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(o=a;a<r&&n(e[a][0])===3;)a++;for(i=a;a<r&&n(e[a][0])===4;)a++;s=a;let u=Fe();if(o>0){let d=e.slice(0,o);t(d)}if(i>o){let d=e.slice(o,i);u?I.push(()=>t(d)):t(d)}if(s>i){let d=e.slice(i,s);u?L.push(()=>t(d)):t(d)}if(r>s){let d=e.slice(s,r);u?V.push(()=>t(d)):t(d)}}var G,X,I,L,V,Z,me=N(()=>{"use strict";G=0,X=!1,I=[],L=[],V=[],Z=[]});function H(){return Math.trunc(performance.now()*1e6)}function Pe(){return Date.now()*1e6}var be=N(()=>{"use strict"});var Q,b,v,w,P,O,C,S,_,m,U,ge,At,ye,Mt,Rt,_e,Be,Ge,Ve,we,W=N(()=>{"use strict";Q=Symbol.for("graphrefly/START"),b=Symbol.for("graphrefly/DATA"),v=Symbol.for("graphrefly/DIRTY"),w=Symbol.for("graphrefly/RESOLVED"),P=Symbol.for("graphrefly/INVALIDATE"),O=Symbol.for("graphrefly/PAUSE"),C=Symbol.for("graphrefly/RESUME"),S=Symbol.for("graphrefly/TEARDOWN"),_=Symbol.for("graphrefly/COMPLETE"),m=Symbol.for("graphrefly/ERROR"),U=Object.freeze([v]),ge=Object.freeze([w]),At=Object.freeze([P]),ye=Object.freeze([Q]),Mt=Object.freeze([_]),Rt=Object.freeze([S]),_e=Object.freeze([U]),Be=Object.freeze([ge]),Ge=Object.freeze([At]),Ve=Object.freeze([Mt]),we=Object.freeze([Rt])});function He(t){t.registerCodec(Ct)}var Ct,Ue=N(()=>{"use strict";Ct={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)}}});function oe(t){if(t==null)return Dt;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var Dt,We=N(()=>{"use strict";Dt={type:"system",id:""}});function $e(t){t.registerMessageType(Q,{tier:0,wireCrossing:!1}),t.registerMessageType(v,{tier:1,wireCrossing:!1}),t.registerMessageType(P,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(O,{tier:2,wireCrossing:!1}),t.registerMessageType(C,{tier:2,wireCrossing:!1}),t.registerMessageType(b,{tier:3,wireCrossing:!0}),t.registerMessageType(w,{tier:3,wireCrossing:!0}),t.registerMessageType(_,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(m,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(S,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var se,je=N(()=>{"use strict";W();se=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_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}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.")}}});var $,ze=N(()=>{"use strict";$=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}}});function ve(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(ve);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=ve(t[n]);return e}return null}function Lt(t){let e=It.encode(t),n=e.length,r=n*8,o=n+9+63&-64,i=new Uint8Array(o);i.set(e),i[n]=128;let s=new DataView(i.buffer);s.setUint32(o-4,r>>>0,!1),s.setUint32(o-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,u=3144134277,d=1013904242,c=2773480762,f=1359893119,y=2600822924,p=528734635,T=1541459225,h=new Uint32Array(64),l=(E,k)=>E>>>k|E<<32-k;for(let E=0;E<o;E+=64){for(let x=0;x<16;x++)h[x]=s.getUint32(E+x*4,!1);for(let x=16;x<64;x++){let Y=h[x-15],J=h[x-2],ne=l(Y,7)^l(Y,18)^Y>>>3,le=l(J,17)^l(J,19)^J>>>10;h[x]=h[x-16]+ne+h[x-7]+le>>>0}let k=a,q=u,K=d,de=c,M=f,ee=y,te=p,ce=T;for(let x=0;x<64;x++){let Y=l(M,6)^l(M,11)^l(M,25),J=M&ee^~M&te,ne=ce+Y+J+Ft[x]+h[x]>>>0,le=l(k,2)^l(k,13)^l(k,22),pt=k&q^k&K^q&K,ht=le+pt>>>0;ce=te,te=ee,ee=M,M=de+ne>>>0,de=K,K=q,q=k,k=ne+ht>>>0}a=a+k>>>0,u=u+q>>>0,d=d+K>>>0,c=c+de>>>0,f=f+M>>>0,y=y+ee>>>0,p=p+te>>>0,T=T+ce>>>0}let g=E=>E.toString(16).padStart(8,"0");return g(a)+g(u)+g(d)+g(c)+g(f)+g(y)+g(p)+g(T)}function Te(t){let e=ve(t??null),n=JSON.stringify(e);return Lt(n).slice(0,16)}function Pt(){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 xe(t,e,n){let r=n?.id??Pt();if(t===0)return{id:r,version:0};let i=(n?.hash??Te)(e);return{id:r,version:0,cid:i,prev:null}}function qe(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Ft,It,Ke=N(()=>{"use strict";Ft=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]),It=new TextEncoder});function Xe(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function Ne(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function ie(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function B(t,e,n){let r=Ze(t)?t:[],o=typeof t=="function"?t:typeof e=="function"?e:void 0,i={};return Ze(t)?i=(ke(e)?e:n)??{}:ke(t)?i=t:i=(ke(e)?e:n)??{},new ae(r,o,i)}var Ye,Je,Bt,Gt,Ee,ae,Ze,ke,ue=N(()=>{"use strict";Ue();We();me();be();je();ze();W();Ke();Ye=()=>{},Je=100;Bt=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},Gt=(t,e,n,r)=>{let o=t;if(o._status==="completed"||o._status==="errored")return;let i=o._cached,s=i===void 0?[ye]:[ye,[b,i]];o._status==="dirty"&&s.push(U),re(e,s,o._config.tierOf)},Ee=new se({onMessage:Bt,onSubscribe:Gt});$e(Ee);He(Ee);ae=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;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??Ee,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._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??Te;let o=r.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?xe(o,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Xe);let i={};for(let[a,u]of Object.entries(r.meta??{})){let d={initial:u,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(d.guard=r.guard),i[a]=new t([],void 0,d)}Object.freeze(i),this.meta=i,this._hasMeta=Object.keys(i).length>0;let s=this;this._actions={emit(a){s._emit([[b,a]])},down(a){s._emit(ie(a))},up(a){s._emitUp(ie(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 o=n?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let i=this._cached===void 0?void 0:this._cached,s=this._versioning,a=s?.id??n?.id,u=s?.version??0,d=xe(e,i,{id:a,hash:o});d.version=u,this._versioning=d,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=oe(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 o=oe(e?.actor),i=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,i))throw new $({actor:o,action:i,nodeName:this.name});if(this._extraGuards!=null){for(let s of this._extraGuards)if(!s(o,i))throw new $({actor:o,action:i,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:Pe()}}down(e,n){let r=ie(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=ie(e);if(r.length===0)return;this._checkGuard(n);let o=n??{internal:!0};this._validateUpTiers(r);for(let i of this._deps)i.node.up?.(r,o)}_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 o=n(r[0]);if(o===3||o===4)throw new Error(`Node "${this.name}": tier-${o} 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 u=oe(n);if(!this._guard(u,"observe"))throw new $({actor:u,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){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 u of this._deps)Ne(u)}this._sinkCount+=1;let i;try{i=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:o},this._actions)}catch(u){throw this._sinkCount-=1,u}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let s=this._isTerminal;if(this._sinkCount===1&&!s)try{this._activate()}catch(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof i=="function")try{i()}catch{}throw u}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof i=="function"&&i(),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 o=r,i=this._deps[r];i.unsub=Ye,i.unsub=i.node.subscribe(s=>{if(i.unsub===null)return;let a=this._config.tierOf,u=!1;for(let d of s)a(d[0])>=3&&(u=!0),this._config.onMessage(this,d,{direction:"down-in",depIndex:o},this._actions);u&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let o=0;o<n;o++){let i=this._deps[o];if(i.unsub!=null){let s=i.unsub;i.unsub=null;try{s()}catch{}Ne(i)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let n=this._deps.length,r=Xe(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(_e),r.unsub=Ye;try{r.unsub=e.subscribe(o=>{if(r.unsub===null)return;let i=this._config.tierOf,s=!1;for(let a of o)i(a[0])>=3&&(s=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);s&&this._maybeRunFnOnSettlement()})}catch(o){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,o}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[m,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(o){this._emit([[m,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let r of this._deps){if(r.unsub!=null){let o=r.unsub;r.unsub=null;try{o()}catch{}}Ne(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],o=n[0];if(this._inspectorHooks!=null){let i={kind:"dep_message",depIndex:e,message:n};for(let s of this._inspectorHooks)s(i)}if(o!==Q){if(o===v){this._depDirtied(r);return}if(o===P){this._depInvalidated(r),this._emit(Ge);return}if(o===O||o===C){this._emit([n]);return}if(o===S){this._emit(we);return}if(o===b)this._depSettledAsData(r,n[1]);else if(o===w)this._depSettledAsResolved(r);else if(o===_)this._depSettledAsTerminal(r,!0);else if(o===m)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(o===b||o===w)&&this._emit([n]),(o===_||o===m)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(_e))}_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._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Be),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([[m,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(Ve)}_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(s){this._emit([[m,this._wrapFnError("cleanup threw",s)]]);return}}else if(e!=null&&typeof e=="object"){let s=e.beforeRun;if(typeof s=="function"){e.beforeRun=void 0;try{s()}catch(a){this._emit([[m,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(s=>s.involvedThisWave?s.dataBatch.length>0?[...s.dataBatch]:[]:void 0),r=this._deps.map(s=>s.prevData);for(let s=0;s<this._deps.length;s++){let a=n[s];a!=null&&a.length>0&&(this._deps[s].prevData=a[a.length-1])}let o=this._deps.map(s=>s.terminal),i={prevData:r,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let s={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(s)}this._isExecutingFn=!0;try{let s=this._fn(n,this._actions,i);if(typeof s=="function")this._cleanup=s;else if(s!=null&&typeof s=="object"){let a=s;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=s)}}catch(s){this._emit([[m,this._wrapFnError("fn threw",s)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Je?(this._rerunDepth=0,this._emit([[m,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Je} \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"?[U,e[0]]:e;let r=!0,o=!1,i=!1,s=-1;for(let u of e){let d=n(u[0]);d<s&&(r=!1),d===3&&(o=!0),u[0]===v&&(i=!0),s=d}let a=e;if(!r){let u=e.map((d,c)=>({m:d,i:c,tier:n(d[0])}));u.sort((d,c)=>d.tier-c.tier||d.i-c.i),a=u.map(d=>d.m)}if(o&&!i&&this._status!=="dirty"){let u=0;for(;u<a.length&&n(a[u][0])===0;)u++;return u===0?[U,...a]:[...a.slice(0,u),U,...a.slice(u)]}return a}_emit(e){if(e.length===0)return;let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(u=>u[0]===S||u[0]===P);if(a.length===0)return;n=a}n=this._frameBatch(n);let o=null;for(let a=0;a<n.length;a++){let u=n[a],d=u[0];if(d!==O&&d!==C){o?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${d===O?"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=u[1];if(d===O)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 y=this._pauseBuffer;this._pauseBuffer=[],this._emit(y)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?o?.push(u):o==null&&(o=n.slice(0,a))}if(o!=null){if(o.length===0)return;n=o}if(this._hasMeta&&n.some(a=>a[0]===S))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(we)}catch{}let{finalMessages:i,equalsError:s}=this._updateState(n);if(i.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:i})}catch{}}if(i.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,u=[];for(let d of i){let c=a(d[0]);c<3||c===5?u.push(d):this._pauseBuffer.push(d)}u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(i);s!=null&&this._emit([[m,s]])}_updateState(e){let n=this._config.tierOf,r,o,i=-1,s=0;for(let c of e)n(c[0])===3&&s++;let a=s<=1,u=-1;if(this._versioning!=null&&s>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===b){u=c;break}}for(let c=0;c<e.length;c++){let f=e[c],y=f[0];if(y===b){if(f.length>=2){let p=!1;if(a&&this._cached!==void 0)try{p=this._equals(this._cached,f[1])}catch(T){o=this._wrapFnError("equals threw",T),i=c;break}if(p){r==null&&(r=e.slice(0,c)),r.push(ge),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(u<0||c===u)&&qe(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),y===v)this._status="dirty";else if(y===w)this._status="resolved";else if(y===_)this._status="completed";else if(y===m)this._status="errored";else if(y===P){this._cached=void 0,this._status="dirty";let p=this._cleanup;if(typeof p=="function"){this._cleanup=void 0;try{p()}catch{}}else if(p!=null&&typeof p=="object"){let T=p.invalidate;if(typeof T=="function")try{T()}catch{}}}else y===S&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=i>=0?r??e.slice(0,i):r??e;return o!=null?{finalMessages:d,equalsError:o}:{finalMessages:d}}_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(Ie()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Le(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}re(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);re(this._deliverToSinks,n,this._config.tierOf)}},Ze=t=>Array.isArray(t),ke=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function A(t,e){return B((r,o,i)=>t(o,i)??void 0,{describeKind:"producer",...e})}var Se=N(()=>{"use strict";ue()});function Oe(t){return{describeKind:"producer",...t}}function Qe(t,e){return A(n=>{let r=!1;try{for(let o of t){if(r)return;n.emit(o)}r||n.down([[_]])}catch(o){r||n.down([[m,o]])}return()=>{r=!0}},Oe(e))}function Vt(t){return t!=null&&typeof t.then=="function"}function Ht(t,e){let{signal:n,...r}=e??{};return A(o=>{let i=!1,s=()=>{i||(i=!0,o.down([[m,n.reason]]))};if(n?.aborted){s();return}return n?.addEventListener("abort",s,{once:!0}),Promise.resolve(t).then(a=>{i||(i=!0,n?.removeEventListener("abort",s),o.emit(a),o.down([[_]]))},a=>{i||(i=!0,n?.removeEventListener("abort",s),o.down([[m,a]]))}),()=>{i=!0,n?.removeEventListener("abort",s)}},Oe(r))}function Ut(t,e){let{signal:n,...r}=e??{};return A(o=>{let i=new AbortController,s=()=>i.abort(n?.reason);n?.aborted?i.abort(n.reason):n?.addEventListener("abort",s,{once:!0});let a=n??i.signal,u=!1,d=t[Symbol.asyncIterator](),c=()=>{u||a.aborted||Promise.resolve(d.next()).then(f=>{if(!(u||a.aborted)){if(f.done){o.down([[_]]);return}o.emit(f.value),c()}},f=>{!u&&!a.aborted&&o.down([[m,f]])})};return c(),()=>{u=!0,n?.removeEventListener("abort",s),i.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},Oe(r))}function Wt(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function et(t,e){if(Wt(t))return t;if(Vt(t))return Ht(t,e);if(t!=null){let n=t;if(typeof n[Symbol.asyncIterator]=="function")return Ut(t,e);if(typeof n[Symbol.iterator]=="function")return Qe(t,e)}return $t(t)}function $t(...t){return Qe(t,void 0)}var tt=N(()=>{"use strict";W();Se()});var j,nt=N(()=>{"use strict";j=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}}});function z(t){return{describeKind:"derived",...t}}function jt(t){return t<0?0:t}function Ce(t){return t[1]}function zt(t){if(typeof t!="number"||!Number.isFinite(t))throw new TypeError("backoff strategy must return a finite number");return t<0?0:t}function rt(t,e){let n=e?.count,r=e?.backoff,o=n!==void 0?n:r===void 0?0:2147483647;if(o<0)throw new RangeError("retry count must be >= 0");let i=r===void 0?null:typeof r=="string"?De(r):r;return A(s=>{let a=0,u=!1,d=null,c,f=new j;function y(){c?.(),c=void 0}function p(h){if(u)return;if(a>=o){y(),s.down([[m,h]]);return}let l=i===null?0:i(a,h,d);if(l==null){y(),s.down([[m,h]]);return}let g;try{g=zt(l)}catch{y(),s.down([[m,h]]);return}d=g,a+=1,y();let E=g>0?g/1e6:1;f.start(E,()=>{u||T()})}function T(){f.cancel(),y(),c=t.subscribe(h=>{if(!u)for(let l of h){let g=l[0];if(g===v)s.down([[v]]);else if(g===b)a=0,d=null,s.emit(l[1]);else if(g===w)s.down([[w]]);else if(g===_)y(),s.down([[_]]);else if(g===m){p(Ce(l));return}else s.down([l])}})}return T(),()=>{u=!0,f.cancel(),y()}},{...z(),initial:t.cache})}function ot(t){let e=Math.max(1,t?.failureThreshold??5),n=jt(t?.cooldownNs??30*1e9),r=t?.cooldown??null,o=Math.max(1,t?.halfOpenMax??1),i=t?.now??H,s="closed",a=0,u=0,d=0,c=n,f=0;function y(){if(!r)return n;let h=r(u);return h!==null?h:n}function p(){s="open",c=y(),d=i(),f=0}return{canExecute(){return s==="closed"?!0:s==="open"?i()-d>=c?(s="half-open",f=1,!0):!1:f<o?(f++,!0):!1},recordSuccess(){s==="half-open"?(s="closed",a=0,u=0):s==="closed"&&(a=0)},recordFailure(h){if(s==="half-open"){u++,p();return}s==="closed"&&(a++,a>=e&&p())},get state(){return s},get failureCount(){return a},reset(){s="closed",a=0,u=0,f=0}}}function st(t,e){let n=e?.onOpen??"skip";return r=>{let o=B([],(i,s)=>{function a(){o.meta.breakerState.down([[b,t.state]])}let u=r.subscribe(d=>{for(let c of d){let f=c[0];f===v?s.down([[v]]):f===b?t.canExecute()?(a(),s.emit(c[1])):(a(),n==="error"?s.down([[m,new Ae]]):s.down([[w]])):f===w?s.down([[w]]):f===_?(t.recordSuccess(),a(),s.down([[_]])):f===m?(t.recordFailure(Ce(c)),a(),s.down([c])):s.down([c])}});return a(),u},{...z(),meta:{breakerState:t.state},completeWhenDepsComplete:!1,initial:r.cache});return{node:o,breakerState:o.meta.breakerState}}}function qt(t,e){if(t<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let n=t,r=H();function o(i){if(e>0){let s=i-r;n=Math.min(t,n+s/1e9*e)}r=i}return{available(){return o(H()),n},tryConsume(i=1){if(i<=0)return!0;let s=H();return o(s),n>=i?(n-=i,!0):!1},putBack(i=1){i<=0||(o(H()),n=Math.min(t,n+i))}}}function it(t,e){let{maxEvents:n,windowNs:r}=e;if(n<=0)throw new RangeError("maxEvents must be > 0");if(r<=0)throw new RangeError("windowNs must be > 0");let o=e.maxBuffer;if(o!==void 0&&o<1)throw new RangeError("maxBuffer must be >= 1");let i=e.onOverflow??"drop-newest",s=n*1e9/r;return A(a=>{let u=qt(n,s),d=[],c=new j,f=!1,y=1e9/s;function p(){for(;d.length>0;)if(u.tryConsume(1))a.emit(d.shift());else{c.start(Math.max(1,y/1e6),p);return}}let T=t.subscribe(h=>{for(let l of h){if(f)return;let g=l[0];if(g===v)a.down([[v]]);else if(g===b){if(o!==void 0&&d.length>=o){if(i!=="drop-newest")if(i==="drop-oldest")d.shift(),d.push(l[1]);else{f=!0,c.cancel(),d.length=0,a.down([[m,new Me(o)]]);return}}else d.push(l[1]);p()}else if(g===w)a.down([[w]]);else if(g===_)f=!0,c.cancel(),d.length=0,a.down([[_]]);else if(g===m)f=!0,c.cancel(),d.length=0,a.down([l]);else if(g===S){f=!0,c.cancel(),d.length=0,a.down([l]);return}else a.down([l])}});return()=>{f=!0,c.cancel(),T()}},{...z(),initial:t.cache})}function at(t,e){let n=e?.initialStatus??"pending",r=B([],(o,i)=>{let s=n;return r.meta.status.down([[b,n]]),r.meta.error.down([[b,null]]),t.subscribe(u=>{for(let d of u){let c=d[0];if(c===v)i.down([[v]]);else if(c===b)s==="errored"?he(()=>{r.meta.error.down([[b,null]]),r.meta.status.down([[b,"active"]])}):r.meta.status.down([[b,"active"]]),s="active",i.emit(d[1]);else if(c===w)i.down([[w]]);else if(c===_)r.meta.status.down([[b,"completed"]]),s="completed",i.down([[_]]);else if(c===m){let f=Ce(d);he(()=>{r.meta.error.down([[b,f]]),r.meta.status.down([[b,"errored"]])}),s="errored",i.down([d])}else i.down([d])}})},{...z(),meta:{status:n,error:null},completeWhenDepsComplete:!1,resubscribable:!0,initial:t.cache});return{node:r,status:r.meta.status,error:r.meta.error}}function Kt(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function Yt(t){return t!=null&&typeof t.then=="function"}function Jt(t){return t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function"}function ut(t,e){return A(n=>{let r,o;function i(){o?.(),o=void 0,Kt(e)||Yt(e)||Jt(e)?r=et(e).subscribe(a=>{n.down(a)}):(n.emit(e),n.down([[_]]))}return o=t.subscribe(s=>{for(let a of s){let u=a[0];if(u===v)n.down([[v]]);else if(u===b)n.emit(a[1]);else if(u===w)n.down([[w]]);else if(u===_)n.down([[_]]);else if(u===m){i();return}else if(u===S){r?.(),n.down([a]);return}else n.down([a])}}),()=>{o?.(),r?.()}},{...z(),initial:t.cache})}function dt(t,e){if(e<=0)throw new RangeError("timeoutNs must be > 0");return A(n=>{let r=!1,o=new j;function i(){let a=e/1e6;o.start(a,()=>{r||(r=!0,s(),n.down([[m,new Re(e)]]))})}let s=t.subscribe(a=>{for(let u of a){if(r)return;let d=u[0];if(d===v)n.down([[v]]);else if(d===b)i(),n.emit(u[1]);else if(d===w)n.down([[w]]);else if(d===_){o.cancel(),r=!0,n.down([[_]]);return}else if(d===m){o.cancel(),r=!0,n.down([u]);return}else if(d===S){o.cancel(),r=!0,n.down([u]);return}else n.down([u])}});return i(),()=>{r=!0,o.cancel(),s()}},{...z(),initial:t.cache})}var Ae,Me,Re,ct=N(()=>{"use strict";me();be();W();ue();Se();pe();tt();nt();Ae=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};Me=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};Re=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});var Qt={};yt(Qt,{NS_PER_MS:()=>R,NS_PER_SEC:()=>F,resilientPipeline:()=>Zt});module.exports=wt(Qt);pe();ct();W();ue();function lt(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}function Xt(t,e){return lt("reduction",t,e)}function ft(t,e,n){if(e.length===0)throw new RangeError("budgetGate requires at least one constraint");let r=e.map(p=>p.node),o=[t,...r],i=[],s=!1,a=!1,u=Symbol("budget-gate"),d=new Array(e.length);function c(){return e.every((p,T)=>p.check(d[T]))}function f(p){for(;i.length>0&&c();){let T=i[0];i=i.slice(1),p.emit(T)}i.length===0&&a&&(a=!1,p.down([[w]]))}return B([],(p,T)=>{for(let l=0;l<e.length;l++)d[l]=e[l].node.cache;let h=[];for(let l=0;l<o.length;l++){let g=o[l];h.push(g.subscribe(E=>{for(let k of E)y(k,l,T)}))}return()=>{for(let l of h)l()}},{...n,describeKind:"derived",meta:Xt("budget_gate",n?.meta)});function y(p,T,h){let l=p[0];if(T===0){if(l===b)return c()&&i.length===0?h.emit(p[1]):(i.push(p[1]),s||(s=!0,h.up([[O,u]]))),!0;if(l===v)return h.down([[v]]),!0;if(l===w)return i.length===0?h.down([[w]]):a=!0,!0;if(l===_||l===m){for(let g of i)h.emit(g);return i=[],a=!1,s&&(s=!1,h.up([[C,u]])),h.down([p]),!0}return!1}return l===b&&(d[T-1]=p[1]),l===b||l===w?(c()&&i.length>0?(f(h),i.length===0&&s&&(s=!1,h.up([[C,u]]))):!c()&&!s&&i.length>0&&(s=!0,h.up([[O,u]])),!0):l===v?!0:l===m?(h.down([p]),!0):l===_}}function Zt(t,e={}){let n=t;e.rateLimit!=null&&(n=it(n,e.rateLimit)),e.budget!=null&&e.budget.length>0&&(n=ft(n,e.budget));let r;if(e.breaker!=null){let i=ot(e.breaker),s=e.breakerOnOpen??"skip",a=st(i,{onOpen:s})(n);n=a.node,r=a.breakerState}if(e.timeoutMs!=null){if(e.timeoutMs<=0)throw new RangeError("timeoutMs must be > 0");if(e.timeoutMs>9e6)throw new RangeError("timeoutMs must be <= 9_000_000 (\u22482.5h) to stay within safe ns arithmetic");n=dt(n,e.timeoutMs*1e6)}e.retry!=null&&(n=rt(n,e.retry)),e.fallback!==void 0&&(n=ut(n,e.fallback));let o=at(n,{initialStatus:e.initialStatus??"pending"});return{node:o.node,status:o.status,error:o.error,breakerState:r}}0&&(module.exports={NS_PER_MS,NS_PER_SEC,resilientPipeline});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import '../../node-Cc1TniY8.cjs';
|
|
2
|
+
export { N as NS_PER_MS, c as NS_PER_SEC } from '../../resilience-Ba5-b4WD.cjs';
|
|
3
|
+
import '../../index-rHJSKsU8.cjs';
|
|
4
|
+
export { R as ResilientPipelineBundle, a as ResilientPipelineOptions, r as resilientPipeline } from '../../index-BxJ86YZZ.cjs';
|
|
5
|
+
import '../../graph-D48Qw9Cg.cjs';
|
|
6
|
+
import '../../meta-Cgj6zeji.cjs';
|
|
7
|
+
import '../../extra/storage-core.cjs';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import '../../node-Cc1TniY8.js';
|
|
2
|
+
export { N as NS_PER_MS, c as NS_PER_SEC } from '../../resilience-CGRzhnD3.js';
|
|
3
|
+
import '../../index-DpHe5e0Q.js';
|
|
4
|
+
export { R as ResilientPipelineBundle, a as ResilientPipelineOptions, r as resilientPipeline } from '../../index-DaLJvH8Z.js';
|
|
5
|
+
import '../../graph-BZGRXwOm.js';
|
|
6
|
+
import '../../meta-CwesDrMD.js';
|
|
7
|
+
import '../../extra/storage-core.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c}from"../../chunk-S35VARIR.js";import"../../chunk-ERLIRFPA.js";import"../../chunk-ETWTCCJI.js";import"../../chunk-4GKB4OUJ.js";import"../../chunk-CKCSDI7T.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-VPYBOXVT.js";import"../../chunk-Z4HDAS2Q.js";import{a,b}from"../../chunk-4VVTGLXJ.js";import"../../chunk-OAWLCNJJ.js";import"../../chunk-2PMCKKRK.js";import"../../chunk-ZB5EHBIO.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{a as NS_PER_MS,b as NS_PER_SEC,c as resilientPipeline};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";var Qe=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var bn=Object.getOwnPropertyNames;var yn=Object.prototype.hasOwnProperty;var q=(n,e)=>()=>(n&&(e=n(n=0)),e);var vn=(n,e)=>{for(var t in e)Qe(n,t,{get:e[t],enumerable:!0})},wn=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of bn(e))!yn.call(n,s)&&s!==t&&Qe(n,s,{get:()=>e[s],enumerable:!(r=mn(e,s))||r.enumerable});return n};var _n=n=>wn(Qe({},"__esModule",{value:!0}),n);var ve,F,z,I,Y,X,Q,H,V,$,de,et,Sn,tt,On,kn,nt,Ot,kt,xt,rt,re=q(()=>{"use strict";ve=Symbol.for("graphrefly/START"),F=Symbol.for("graphrefly/DATA"),z=Symbol.for("graphrefly/DIRTY"),I=Symbol.for("graphrefly/RESOLVED"),Y=Symbol.for("graphrefly/INVALIDATE"),X=Symbol.for("graphrefly/PAUSE"),Q=Symbol.for("graphrefly/RESUME"),H=Symbol.for("graphrefly/TEARDOWN"),V=Symbol.for("graphrefly/COMPLETE"),$=Symbol.for("graphrefly/ERROR"),de=Object.freeze([z]),et=Object.freeze([I]),Sn=Object.freeze([Y]),tt=Object.freeze([ve]),On=Object.freeze([V]),kn=Object.freeze([H]),nt=Object.freeze([de]),Ot=Object.freeze([et]),kt=Object.freeze([Sn]),xt=Object.freeze([On]),rt=Object.freeze([kn])});function Tt(n,e){let t=new TextEncoder().encode(n.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${n.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let r=n.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+t.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++]=st,o[i++]=t.length,o.set(t,i),i+=t.length,o[i++]=r>>>8&255,o[i++]=r&255,o.set(e,i),o}function Et(n,e){if(n.length<Nt)throw new Error(`decodeEnvelope: bytes too short (${n.length} < ${Nt})`);let t=0,r=n[t++];if(r!==st)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${st})`);let s=n[t++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+s+2>n.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+s+2} bytes, have ${n.length})`);let o=new TextDecoder().decode(n.subarray(t,t+s));t+=s;let i=(n[t]<<8|n[t+1])>>>0;t+=2;let a=n.subarray(t),c=e.lookupCodec(o);if(c==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:c,codecVersion:i,payload:a}}function Rt(n){n.registerCodec(xn)}var xn,st,Nt,ot=q(()=>{"use strict";xn={name:"json",version:1,contentType:"application/json",encode(n){let e=JSON.stringify(n);return new TextEncoder().encode(e)},decode(n,e){let t=new TextDecoder().decode(n);return JSON.parse(t)}},st=1,Nt=4});function Re(n){if(n==null)return ue;let{type:e,id:t,...r}=n;return{type:e??"system",id:t??"",...r}}var ue,it=q(()=>{"use strict";ue={type:"system",id:""}});function Ae(){return le>0||we}function At(){return le>0}function Se(n){le>0?_e.push(n):n()}function De(n){le+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(le-=1,le===0)if(e){if(!we){let t=_e.splice(0);for(let r of t)try{r()}catch{}oe.length=0,ie.length=0,fe.length=0}}else Nn()}}function Nn(){let n=!we;n&&(we=!0);let e=[],t=0;try{for(;oe.length>0||ie.length>0||fe.length>0||n&&_e.length>0;){if(n&&_e.length>0){let o=_e.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(t+=1,t>1e3)throw oe.length=0,ie.length=0,fe.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(oe.length>0?oe:ie.length>0?ie:fe).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{n&&(we=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Ge(n,e,t){if(e.length===0)return;if(e.length===1){let d=t(e[0][0]);if(d<3||!Ae()){n(e);return}(d>=5?fe:d===4?ie:oe).push(()=>n(e));return}let r=e.length,s=r,o=r,i=r,a=0;for(;a<r&&t(e[a][0])<3;)a++;for(s=a;a<r&&t(e[a][0])===3;)a++;for(o=a;a<r&&t(e[a][0])===4;)a++;i=a;let c=Ae();if(s>0){let d=e.slice(0,s);n(d)}if(o>s){let d=e.slice(s,o);c?oe.push(()=>n(d)):n(d)}if(i>o){let d=e.slice(o,i);c?ie.push(()=>n(d)):n(d)}if(r>i){let d=e.slice(i,r);c?fe.push(()=>n(d)):n(d)}}var le,we,oe,ie,fe,_e,$e=q(()=>{"use strict";le=0,we=!1,oe=[],ie=[],fe=[],_e=[]});function pe(){return Math.trunc(performance.now()*1e6)}function he(){return Date.now()*1e6}var Ce=q(()=>{"use strict"});function Dt(n){n.registerMessageType(ve,{tier:0,wireCrossing:!1}),n.registerMessageType(z,{tier:1,wireCrossing:!1}),n.registerMessageType(Y,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(X,{tier:2,wireCrossing:!1}),n.registerMessageType(Q,{tier:2,wireCrossing:!1}),n.registerMessageType(F,{tier:3,wireCrossing:!0}),n.registerMessageType(I,{tier:3,wireCrossing:!0}),n.registerMessageType(V,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType($,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(H,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Me,Gt=q(()=>{"use strict";re();Me=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let r=this._messageTypes.get(t);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}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.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 at(n){let e=Tn.filter(t=>n({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}var K,Tn,Pe=q(()=>{"use strict";K=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`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}},Tn=["human","llm","wallet","system"]});function ct(n){if(n===void 0)return null;if(typeof n=="number"){if(!Number.isFinite(n))throw new TypeError(`Cannot hash non-finite number: ${n}`);if(Number.isInteger(n)&&!Number.isSafeInteger(n))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${n}. Cross-language cid parity is not guaranteed for unsafe integers.`);return n}if(typeof n=="string"||typeof n=="boolean"||n===null)return n;if(Array.isArray(n))return n.map(ct);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=ct(n[t]);return e}return null}function An(n){let e=Rn.encode(n),t=e.length,r=t*8,s=t+9+63&-64,o=new Uint8Array(s);o.set(e),o[t]=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,c=3144134277,d=1013904242,f=2773480762,p=1359893119,h=2600822924,l=528734635,u=1541459225,g=new Uint32Array(64),m=(b,v)=>b>>>v|b<<32-v;for(let b=0;b<s;b+=64){for(let N=0;N<16;N++)g[N]=i.getUint32(b+N*4,!1);for(let N=16;N<64;N++){let R=g[N-15],T=g[N-2],M=m(R,7)^m(R,18)^R>>>3,Z=m(T,17)^m(T,19)^T>>>10;g[N]=g[N-16]+M+g[N-7]+Z>>>0}let v=a,_=c,k=d,S=f,w=p,O=h,E=l,P=u;for(let N=0;N<64;N++){let R=m(w,6)^m(w,11)^m(w,25),T=w&O^~w&E,M=P+R+T+En[N]+g[N]>>>0,Z=m(v,2)^m(v,13)^m(v,22),ne=v&_^v&k^_&k,Te=Z+ne>>>0;P=E,E=O,O=w,w=S+M>>>0,S=k,k=_,_=v,v=M+Te>>>0}a=a+v>>>0,c=c+_>>>0,d=d+k>>>0,f=f+S>>>0,p=p+w>>>0,h=h+O>>>0,l=l+E>>>0,u=u+P>>>0}let y=b=>b.toString(16).padStart(8,"0");return y(a)+y(c)+y(d)+y(f)+y(p)+y(h)+y(l)+y(u)}function dt(n){let e=ct(n??null),t=JSON.stringify(e);return An(t).slice(0,16)}function Dn(){let n=globalThis.crypto;if(n?.randomUUID)return n.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function ut(n,e,t){let r=t?.id??Dn();if(n===0)return{id:r,version:0};let o=(t?.hash??dt)(e);return{id:r,version:0,cid:o,prev:null}}function $t(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}var En,Rn,Ct=q(()=>{"use strict";En=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]),Rn=new TextEncoder});function Ft(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function lt(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function Fe(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}function ae(n,e,t){let r=jt(n)?n:[],s=typeof n=="function"?n:typeof e=="function"?e:void 0,o={};return jt(n)?o=(ft(e)?e:t)??{}:ft(n)?o=n:o=(ft(e)?e:t)??{},new j(r,s,o)}var Mt,Pt,Gn,$n,ge,j,jt,ft,me=q(()=>{"use strict";ot();it();$e();Ce();Gt();Pe();re();Ct();Mt=()=>{},Pt=100;Gn=(n,e,t,r)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},$n=(n,e,t,r)=>{let s=n;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[tt]:[tt,[F,o]];s._status==="dirty"&&i.push(de),Ge(e,i,s._config.tierOf)},ge=new Me({onMessage:Gn,onSubscribe:$n});Dt(ge);Rt(ge);j=class n{_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;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,r){this._config=r.config??ge,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=t,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??dt;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?ut(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ft);let o={};for(let[a,c]of Object.entries(r.meta??{})){let d={initial:c,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(d.guard=r.guard),o[a]=new n([],void 0,d)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[F,a]])},down(a){i._emit(Fe(a))},up(a){i._emitUp(Fe(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,t){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=t?.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??t?.id,c=i?.version??0,d=ut(e,o,{id:a,hash:s});d.version=c,this._versioning=d,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 t=Re(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!t&&!r)return;let s=Re(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:he()}}down(e,t){let r=Fe(e);r.length!==0&&(this._checkGuard(t),this._emit(r))}emit(e,t){this._checkGuard(t),this._emit([[F,e]])}up(e,t){if(this._deps.length===0)return;let r=Fe(e);if(r.length===0)return;this._checkGuard(t);let s=t??{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 t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let r of e){let s=t(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,t){if(t!=null&&this._guard!=null){let c=Re(t);if(!this._guard(c,"observe"))throw new K({actor:c,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 c of this._deps)lt(c)}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(c){throw this._sinkCount-=1,c}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(c){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw c}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[t]=this._sinks;this._sinks=t}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,t=0;try{for(let r=0;r<e;r++){let s=r,o=this._deps[r];o.unsub=Mt,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,c=!1;for(let d of i)a(d[0])>=3&&(c=!0),this._config.onMessage(this,d,{direction:"down-in",depIndex:s},this._actions);c&&this._maybeRunFnOnSettlement()}),t++}}catch(r){this._deps[t].unsub=null;for(let s=0;s<t;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}lt(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 t=this._deps.length,r=Ft(e);if(this._deps.push(r),this._sinks==null)return t;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(nt),r.unsub=Mt;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:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(r){this._emit([[$,this._wrapFnError("cleanup threw",r)]])}else if(t!=null&&typeof t=="object"){let r=t.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{}}lt(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,t){let r=this._deps[e],s=t[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(o)}if(s!==ve){if(s===z){this._depDirtied(r);return}if(s===Y){this._depInvalidated(r),this._emit(kt);return}if(s===X||s===Q){this._emit([t]);return}if(s===H){this._emit(rt);return}if(s===F)this._depSettledAsData(r,t[1]);else if(s===I)this._depSettledAsResolved(r);else if(s===V)this._depSettledAsTerminal(r,!0);else if(s===$)this._depSettledAsTerminal(r,t[1]);else{this._emit([t]);return}if(!this._fn){(s===F||s===I)&&this._emit([t]),(s===V||s===$)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(nt))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,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._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Ot),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[$,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(xt)}_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 t=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=t[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:t,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(t,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>Pt?(this._rerunDepth=0,this._emit([[$,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Pt} \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,t){let r=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[de,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let c of e){let d=t(c[0]);d<i&&(r=!1),d===3&&(s=!0),c[0]===z&&(o=!0),i=d}let a=e;if(!r){let c=e.map((d,f)=>({m:d,i:f,tier:t(d[0])}));c.sort((d,f)=>d.tier-f.tier||d.i-f.i),a=c.map(d=>d.m)}if(s&&!o&&this._status!=="dirty"){let c=0;for(;c<a.length&&t(a[c][0])===0;)c++;return c===0?[de,...a]:[...a.slice(0,c),de,...a.slice(c)]}return a}_emit(e){if(e.length===0)return;let t=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(c=>c[0]===H||c[0]===Y);if(a.length===0)return;t=a}t=this._frameBatch(t);let s=null;for(let a=0;a<t.length;a++){let c=t[a],d=c[0];if(d!==X&&d!==Q){s?.push(c);continue}if(c.length<2)throw new Error(`Node "${this.name}": [[${d===X?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let f=!0;if(this._pausable!==!1){let p=c[1];if(d===X)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(p),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(p))f=!1;else if(this._pauseLocks.delete(p),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let h=this._pauseBuffer;this._pauseBuffer=[],this._emit(h)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}f?s?.push(c):s==null&&(s=t.slice(0,a))}if(s!=null){if(s.length===0)return;t=s}if(this._hasMeta&&t.some(a=>a[0]===H))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(rt)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(t);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,c=[];for(let d of o){let f=a(d[0]);f<3||f===5?c.push(d):this._pauseBuffer.push(d)}c.length>0&&this._dispatchOrAccumulate(c)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[$,i]])}_updateState(e){let t=this._config.tierOf,r,s,o=-1,i=0;for(let f of e)t(f[0])===3&&i++;let a=i<=1,c=-1;if(this._versioning!=null&&i>1){for(let f=e.length-1;f>=0;f--)if(e[f][0]===F){c=f;break}}for(let f=0;f<e.length;f++){let p=e[f],h=p[0];if(h===F){if(p.length>=2){let l=!1;if(a&&this._cached!==void 0)try{l=this._equals(this._cached,p[1])}catch(u){s=this._wrapFnError("equals threw",u),o=f;break}if(l){r==null&&(r=e.slice(0,f)),r.push(et),this._status="resolved";continue}this._cached=p[1],this._versioning!=null&&(c<0||f===c)&&$t(this._versioning,p[1],this._hashFn)}this._status="settled",r?.push(p)}else if(r?.push(p),h===z)this._status="dirty";else if(h===I)this._status="resolved";else if(h===V)this._status="completed";else if(h===$)this._status="errored";else if(h===Y){this._cached=void 0,this._status="dirty";let l=this._cleanup;if(typeof l=="function"){this._cleanup=void 0;try{l()}catch{}}else if(l!=null&&typeof l=="object"){let u=l.invalidate;if(typeof u=="function")try{u()}catch{}}}else h===H&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:d,equalsError:s}:{finalMessages:d}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let r of t)r(e)};_dispatchOrAccumulate(e){if(At()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Se(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}Ge(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);Ge(this._deliverToSinks,t,this._config.tierOf)}},jt=n=>Array.isArray(n),ft=n=>typeof n=="object"&&n!=null&&!Array.isArray(n)});function Lt(n,e,t){return t?!1:n.some((r,s)=>!(r!=null&&r.length>0)&&e.prevData[s]===void 0)}function ee(n,e){return ae([],{...e,initial:n})}function Oe(n,e){return ae((r,s,o)=>n(s,o)??void 0,{describeKind:"producer",...e})}function ce(n,e,t){let r=t?.partial??!1;return ae(n,(o,i,a)=>{if(Lt(o,a,r)){i.down([[I]]);return}let c=o.map((d,f)=>d!=null&&d.length>0?d.at(-1):a.prevData[f]);i.emit(e(c,a))},{describeKind:"derived",...t})}function je(n,e,t){let r=t?.partial??!1;return ae(n,(o,i,a)=>{if(Lt(o,a,r)){i.down([[I]]);return}let c=o.map((d,f)=>d!=null&&d.length>0?d.at(-1):a.prevData[f]);return e(c,i,a)??void 0},{describeKind:"effect",...t})}var Le=q(()=>{"use strict";re();me()});function be(n){return n.subscribe(()=>{})}var ht=q(()=>{"use strict"});var Ve,It=q(()=>{"use strict";Ve=class{_timer;_gen=0;start(e,t){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&t()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var gr={};vn(gr,{SNAPSHOT_WIRE_VERSION:()=>_t,SurfaceError:()=>A,asSurfaceError:()=>dn,createGraph:()=>qe,deleteSnapshot:()=>gn,diffSnapshots:()=>pn,listSnapshots:()=>hn,restoreSnapshot:()=>fn,runReduction:()=>un,saveSnapshot:()=>ln});module.exports=_n(gr);Le();it();$e();Ce();Pe();re();Pe();me();function Ie(n,e){if(e!=null&&e.length>0)return new Set(e);switch(n){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;default:return new Set(["type","deps"])}}function Cn(n){return n._describeKind!=null?n._describeKind:n._deps.length>0?"derived":n._fn!=null?"producer":"state"}function Mn(n){let e={};for(let[t,r]of Object.entries(n.meta))try{e[t]=r.cache}catch{}return e}function pt(n,e){let t=e==null,r=!t&&e!=null?[...e].filter(d=>d.startsWith("meta.")).map(d=>d.slice(5)):null,s=t||e.has("meta")||r!=null&&r.length>0,o="state",i=[];n instanceof j&&(o=Cn(n),i=n._deps.map(d=>d.node.name??""));let a={type:o,deps:i};(t||e.has("status"))&&(a.status=n.status);let c=n instanceof j?n._guard:void 0;if(s){let d={...Mn(n)};if(c!=null&&d.access===void 0&&(d.access=at(c)),r!=null&&r.length>0&&!e.has("meta")){let f={};for(let p of r)p in d&&(f[p]=d[p]);a.meta=f}else a.meta=d}if(n.name!=null&&(a.name=n.name),t||e.has("value")){n.status==="sentinel"&&(a.sentinel=!0);try{a.value=n.cache}catch{}}if((t||e.has("v"))&&n.v!=null){let d={id:n.v.id,version:n.v.version};"cid"in n.v&&(d.cid=n.v.cid,d.prev=n.v.prev),a.v=d}return(t||e.has("guard"))&&c!=null&&(a.guard=at(c)),(t||e.has("lastMutation"))&&n.lastMutation!=null&&(a.lastMutation=n.lastMutation),a}me();Le();ht();It();var ke=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 t=(this.head+this._size)%this.capacity;this.buf[t]=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 t=e<0?this._size+e:e;if(!(t<0||t>=this._size))return this.buf[(this.head+t)%this.capacity]}toArray(){let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this.buf[(this.head+t)%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}};ot();function Vt(n,e,t,r={}){let s=e in n.nodes,o=t in n.nodes;if(!s)return Be(e,t,"no-such-from");if(!o)return Be(e,t,"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===t){if(r.findCycle===!0){let d=Pn(n,e,r);if(d!=null)return d}let c=He(e,n.nodes[e],0,r);return ze(e,t,[c])}if(i===0)return Be(e,t,"no-path");let a=Bt(n,e,t,i);return a.found?ze(e,t,Ht(n,a.pathOrder,r)):Be(e,t,a.truncated?"max-depth-exceeded":"no-path")}function Bt(n,e,t,r){let s=new Map,o=[{path:t,depth:0}],i=new Set([t]),a=0,c=!1;for(;a<o.length;){let p=o[a++];if(p.path===e)break;if(r!=null&&p.depth>=r){let g=n.nodes[p.path];g?.deps&&g.deps.length>0&&(c=!0);continue}let h=n.nodes[p.path];if(h==null)continue;let l=h.deps??[],u=new Map;for(let g=0;g<l.length;g++){let m=l[g];if(!m)continue;let y=u.get(m);y==null&&(y=[],u.set(m,y)),y.push(g)}for(let[g,m]of u)i.has(g)||(i.add(g),s.set(g,{from:p.path,depIndices:m}),o.push({path:g,depth:p.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:c};let d=[{path:e}],f=e;for(;f!==t;){let p=s.get(f);if(p==null)return{found:!1,pathOrder:[],truncated:!1};d[d.length-1].depIndices=p.depIndices,d.push({path:p.from}),f=p.from}return{found:!0,pathOrder:d,truncated:!1}}function Pn(n,e,t){let r=n.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=He(e,r,0,t);a.dep_index=o[0];let c=He(e,r,1,t);return ze(e,e,[a,c])}let i=null;for(let a=0;a<s.length;a++){let c=s[a];if(!c||c===e)continue;let d=Bt(n,c,e,t.maxDepth);d.found&&(i==null||d.pathOrder.length<i.pathOrder.length)&&(i=d,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...d.pathOrder],truncated:!1})}return i==null?null:ze(e,e,Ht(n,i.pathOrder,t))}function Ht(n,e,t){return e.map((r,s)=>{let o=n.nodes[r.path],i=He(r.path,o,s,t);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 He(n,e,t,r){let s={path:n,type:e.type,hop:t};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(n)??e.annotation;o!=null&&(s.annotation=o);let i=r.lastMutations?.get(n)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function ze(n,e,t){return zt(n,e,!0,"ok",t)}function Be(n,e,t){return zt(n,e,!1,t,[])}function zt(n,e,t,r,s){let o=Fn(n,e,t,r,s);return{from:n,to:e,found:t,reason:r,steps:s,text:o,toJSON(){return{from:n,to:e,found:t,reason:r,steps:s}}}}function Fn(n,e,t,r,s){if(!t)switch(r){case"no-such-from":return`explainPath: no node named "${n}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${n}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${n}" to "${e}"`}let o=[`Causal path: ${n} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let c=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(c),"value"in i&&o.push(` value: ${jn(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let d=i.lastMutation.actor;o.push(` actor: ${d.type}${d.id?`:${d.id}`:""}`)}}return o.join(`
|
|
2
|
+
`)}function jn(n){if(n===void 0)return"<sentinel>";if(n===null)return"null";if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||typeof n=="bigint")return String(n);try{let e=JSON.stringify(n);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(n)}}me();var L={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},Ln=Symbol.for("sizeof");function Ut(n){let e=new WeakSet,t=new WeakSet,r=[n],s=0;for(;r.length>0;){let o=r.pop();s+=In(o,e,t,r)}return s}function In(n,e,t,r){if(n==null)return 0;switch(typeof n){case"number":return L.number;case"boolean":return L.boolean;case"string":return L.string+n.length*2;case"bigint":return L.bigint+Vn(n);case"symbol":return L.symbol;case"function":return e.has(n)?0:(e.add(n),L.function);case"undefined":return 0}let o=n;if(e.has(o))return 0;e.add(o);let i=o[Ln];if(typeof i=="function")try{let d=i.call(o);if(typeof d=="number"&&Number.isFinite(d))return d}catch{}if(o instanceof Date)return L.date;if(o instanceof RegExp)return L.regexp+o.source.length*2;if(o instanceof Error){let d=o.message?o.message.length*2:0,f=o.stack?o.stack.length*2:0;return L.error+d+f}if(typeof URL<"u"&&o instanceof URL)return L.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return L.promise;if(o instanceof WeakMap)return L.weakmap;if(o instanceof WeakSet)return L.weakset;if(o instanceof Map){let d=L.map;for(let[f,p]of o)d+=L.mapEntry,r.push(f),r.push(p);return d}if(o instanceof Set){let d=L.set;for(let f of o)d+=L.setEntry,r.push(f);return d}if(Array.isArray(o)){let d=L.array+o.length*8;for(let f of o)r.push(f);return d}if(o instanceof ArrayBuffer)return t.has(o)?0:(t.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let d=o;return t.has(d.buffer)?48:(t.add(d.buffer),d.buffer.byteLength+48)}let a=L.object,c=Object.keys(o);for(let d of c){a+=L.string+d.length*2;try{r.push(o[d])}catch{}}return a}function Vn(n){let e=n<0n?-n:n;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}function Wt(n,e){let t=e?.topN??10,r=n.describe({detail:"standard"}),s=[],o=n._collectObserveTargets;typeof o=="function"&&o.call(n,"",s);let i=new Map;for(let[h,l]of s)i.set(h,l);let a=[];for(let[h,l]of Object.entries(r.nodes)){let u=i.get(h),g=u instanceof j?u:null,m=g?Ut(g.cache):0,y=g?g._sinkCount:0,b=l.deps?.length??0,v=l.type==="effect"&&y===0,_=y===0?l.type==="effect"?"orphan-effect":l.type==="derived"?"idle-derived":l.type==="producer"?"idle-producer":null:null;a.push({path:h,type:l.type,status:l.status??"unknown",valueSizeBytes:m,subscriberCount:y,depCount:b,isOrphanEffect:v,orphanKind:_})}let c=a.reduce((h,l)=>h+l.valueSizeBytes,0),d=(h,l)=>[...a].sort(l??((u,g)=>g[h]-u[h])).slice(0,t),f=a.filter(h=>h.orphanKind!=null),p=a.filter(h=>h.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:c,hotspots:{byValueSize:d("valueSizeBytes"),bySubscriberCount:d("subscriberCount"),byDepCount:d("depCount")},orphans:f,orphanEffects:p}}var C="::",J="__meta__",se=1;function qt(n,e){let t=Math.max(16,n.size*4),r=0;for(;n.size>0;){if(r++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${n.size} disposer(s) discarded`),n.clear();return}let s=n.values().next();if(s.done)return;let o=s.value;n.delete(o);try{o()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Bn(n){let e=[];for(let t of Object.keys(n).sort()){let r=n[t].v;r!=null&&e.push(`${t} ${r.id} ${r.version}`)}return e.join(`
|
|
3
|
+
`)}function Kt(n){if(n.version!==se)throw new Error(`unsupported snapshot version ${String(n.version)} (expected ${se})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in n))throw new Error(`snapshot missing required key "${e}"`);if(typeof n.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof n.nodes!="object"||n.nodes===null||Array.isArray(n.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(n.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(n.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Hn(n,e){let t=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=t.get(s);if(i==null&&(i=new WeakSet,t.set(s,i)),i.has(o))return!0;i.add(o);let a=s.constructor,c=o.constructor;if(a!==c)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 h=o;if(s.length!==h.length)return!1;for(let l=0;l<s.length;l++)if(!r(s[l],h[l]))return!1;return!0}if(s instanceof Map){let h=o;if(s.size!==h.size)return!1;for(let[l,u]of s)if(!h.has(l)||!r(u,h.get(l)))return!1;return!0}if(s instanceof Set){let h=o;if(s.size!==h.size)return!1;for(let l of s){let u=!1;for(let g of h)if(r(l,g)){u=!0;break}if(!u)return!1}return!0}if(ArrayBuffer.isView(s)){let h=s,l=o;if(h.length!==l.length)return!1;for(let u=0;u<h.length;u++)if(h[u]!==l[u])return!1;return!0}let d=Object.keys(s),f=Object.keys(o);if(d.length!==f.length)return!1;let p=new Set(f);for(let h of d)if(!p.has(h)||!r(s[h],o[h]))return!1;return!0};return r(n,e)}function mt(n){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(mt);let e=n,t=Object.keys(e).sort(),r={};for(let s of t)r[s]=mt(e[s]);return r}function zn(n){return n.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Un(n){return n.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Wn(n){return n==="TD"?"down":n==="BT"?"up":n==="RL"?"left":"right"}function Xt(n){let e=new Set,t=[];function r(s,o){let i=`${s}\0${o}`;e.has(i)||(e.add(i),t.push([s,o]))}for(let[s,o]of Object.entries(n.nodes)){let i=o.deps;if(i)for(let a of i)r(a,s)}for(let s of n.edges)r(s.from,s.to);return t}function Zt(n){if(n===void 0)return"LR";if(n==="TD"||n==="LR"||n==="BT"||n==="RL")return n;throw new Error(`invalid diagram direction ${String(n)}; expected one of: TD, LR, BT, RL`)}function qn(n,e){let t=e.includeEdges??!0,r=e.includeSubgraphs??!0,{expand:s,...o}=n,i={...o,edges:t?n.edges:[],subgraphs:r?n.subgraphs:[]},a=JSON.stringify(mt(i),null,e.indent??2);return e.logger?.(a),a}function Kn(n,e){let t=e.includeEdges??!0,r=e.includeSubgraphs??!0,s=[];s.push(`Graph ${n.name}`),s.push("Nodes:");for(let i of Object.keys(n.nodes).sort()){let a=n.nodes[i];s.push(`- ${i} (${a.type}/${a.status}): ${We(a.value)}`)}if(t){s.push("Edges:");for(let i of n.edges)s.push(`- ${i.from} -> ${i.to}`)}if(r){s.push("Subgraphs:");for(let i of n.subgraphs)s.push(`- ${i}`)}let o=s.join(`
|
|
4
|
+
`);return e.logger?.(o),o}function Qt(n,e){let t=Zt(e.direction),r=Object.keys(n.nodes).sort(),s=new Map;for(let i=0;i<r.length;i+=1)s.set(r[i],`n${i}`);let o=[`flowchart ${t}`];for(let i of r){let a=s.get(i);o.push(` ${a}["${zn(i)}"]`)}for(let[i,a]of Xt(n)){let c=s.get(i),d=s.get(a);!c||!d||o.push(` ${c} --> ${d}`)}return o.join(`
|
|
5
|
+
`)}function Jn(n,e){let t=Qt(n,e);return Yn(t)}function Yn(n,e){let t=e?.theme??"default",r=e?.autoSync??!0,o=JSON.stringify({code:n,mermaid:{theme:t},autoSync:r}),i=new TextEncoder().encode(o),a="";for(let d=0;d<i.length;d++)a+=String.fromCharCode(i[d]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function Xn(n,e){let t=Zt(e.direction),r=Object.keys(n.nodes).sort(),s=new Map;for(let i=0;i<r.length;i+=1)s.set(r[i],`n${i}`);let o=[`direction: ${Wn(t)}`];for(let i of r){let a=s.get(i);o.push(`${a}: "${Un(i)}"`)}for(let[i,a]of Xt(n)){let c=s.get(i),d=s.get(a);!c||!d||o.push(`${c} -> ${d}`)}return o.join(`
|
|
6
|
+
`)}function Zn(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ue(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let s=n.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let o=n.slice(t+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,t=s;continue}e+=Zn(r)}return e+="$",new RegExp(e)}var Qn={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"},er={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function We(n){if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||n==null)return String(n);try{return JSON.stringify(n)}catch{return"[unserializable]"}}function tr(n){return n==="none"?er:n==="ansi"||n==null?Qn:{data:n.data??"",dirty:n.dirty??"",resolved:n.resolved??"",invalidate:n.invalidate??"",pause:n.pause??"",resume:n.resume??"",complete:n.complete??"",error:n.error??"",teardown:n.teardown??"",derived:n.derived??"",path:n.path??"",reset:n.reset??""}}function Jt(n){if(n==null)return{};let e=n.detail;return e==="full"?{...n,structured:n.structured??!0,timeline:n.timeline??!0,causal:n.causal??!0,derived:n.derived??!0}:e==="minimal"?{...n,structured:n.structured??!0}:n.format==="stage-log"?{...n,structured:n.structured??!0,timeline:n.timeline??!0}:n}function nr(n,e,t){for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${n}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function gt(n,e,t){if(n==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(n.includes(C))throw new Error(`Graph "${e}": ${t} "${n}" must not contain '${C}' (path separator)`);if(n===J)throw new Error(`Graph "${e}": ${t} name "${J}" is reserved for meta companion paths`);nr(n,e,t)}function rr(n,e){if(n==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=n.split(C);for(let r of t)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function sr(n,e){let t=!1;for(let s of n)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?n.filter(s=>e.isMetaPassthrough(s[0])):n}function en(n){for(let e of n._mounts.values())en(e);for(let e of n._nodes.values())try{e.down([[H]],{internal:!0})}catch{}}var te=class n{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_topology;_topologyEmitters=new Set;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(C))throw new Error(`Graph name must not contain '${C}' (got "${e}")`);if(e===J)throw new Error(`Graph name "${J}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??ge,this._traceRing=new ke(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning)}ancestors(e=!0){let t=[],r=e?this:this._parent;for(;r!=null;)t.push(r),r=r._parent;return t}get topology(){return this._topology==null&&(this._topology=Oe(e=>{let t=r=>{e.emit(r)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}add(e,t){let r=e.name,s=t?.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=t?.annotation;if(gt(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:pe()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof j&&t._applyVersioning(e)}remove(e){gt(e,this.name,"remove");let t=this._mounts.get(e);if(t){let o={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,c]of i)a.includes(`${C}${J}${C}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...t._collectSubgraphs(`${e}${C}`)),this._mounts.delete(e),t._parent=void 0,en(t),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([[H]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let t=typeof e=="function"?e:(()=>{let o=Ue(e);return i=>o.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>t(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(),t=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,t.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(C))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,r){let s=r?.internal===!0;this.node(e).down([[F,t]],{actor:r?.actor,internal:s,delivery:"write"})}setAll(e,t){let r=Symbol.iterator in e?e:Object.entries(e);De(()=>{for(let[s,o]of r)this.set(s,o,t)})}invalidate(e,t){let r=t?.internal===!0;this.node(e).down([[Y]],{actor:t?.actor,internal:r,delivery:"write"})}error(e,t,r){let s=r?.internal===!0;this.node(e).down([[$,t]],{actor:r?.actor,internal:s,delivery:"write"})}complete(e,t){let r=t?.internal===!0;this.node(e).down([[V]],{actor:t?.actor,internal:r,delivery:"write"})}edges(e){let t=e?.recursive===!0,r=new Map;if(!t){for(let[c,d]of this._nodes)r.set(d,c);let a=[];for(let[c,d]of this._nodes)if(d instanceof j)for(let f of d._deps){let p=r.get(f.node);p!=null&&a.push([p,c])}return a.sort((c,d)=>c[0]<d[0]?-1:c[0]>d[0]?1:c[1]<d[1]?-1:c[1]>d[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,c]of s)o.set(c,a);let i=[];for(let[a,c]of s)if(c instanceof j)for(let d of c._deps){let f=o.get(d.node);f!=null&&i.push([f,a])}return i.sort((a,c)=>a[0]<c[0]?-1:a[0]>c[0]?1:a[1]<c[1]?-1:a[1]>c[1]?1:0),i}mount(e,t){if(gt(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(t===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(t._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${t._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===t)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,t),t._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),t}resolve(e){let t=rr(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=t[0],s=t.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]===J)return this._resolveMetaChainFromNode(o,s,t.join(C));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(C)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(s.join(C))}_resolveMetaChainFromNode(e,t,r){let s=e,o=0,i=[...t];for(;o<i.length;){if(i[o]!==J)throw new Error(`Graph "${this.name}": expected ${J} segment in meta path "${r}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${J} in "${r}"`);let a=i[o+1],c=s.meta[a];if(!c)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);s=c,o+=2}return s}signal(e,t){if(t?.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,t??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,t,r,s){for(let c of this._mounts.values())c._signalDeliver(e,t,r,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=sr(e,this.config);for(let c of[...this._nodes.keys()].sort()){let d=this._nodes.get(c);if(!r.has(d)){r.add(d);try{d.down(e,i)}catch(f){if(f instanceof K)throw f;s.push(f)}a.length!==0&&this._signalMetaSubtree(d,a,r,i,s)}}}_signalMetaSubtree(e,t,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(t,s)}catch(c){if(c instanceof K)throw c;o.push(c)}this._signalMetaSubtree(a,t,r,s,o)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let t=e?.actor,r=e?.filter,s=Ie(e?.detail,e?.fields),o=e?.format==="spec",i=o?Ie("minimal"):s,a=[];this._collectObserveTargets("",a);let c=new Map;for(let[S,w]of a)c.set(w,S);let d=[];{let S=a.map(([,E])=>E),w=new Set(c.values()),O=0;for(;S.length>0;){let E=S.shift();if(E instanceof j)for(let P of E._deps){let N=P.node;if(c.has(N))continue;let R=N.name??"",T=R;if(!T||w.has(T))if(R){let M=2;for(;w.has(`${R}#${M}`);)M++;T=`${R}#${M}`}else for(T=`__internal__/${O++}`;w.has(T);)T=`__internal__/${O++}`;c.set(N,T),w.add(T),d.push([T,N]),S.push(N)}}}let f=[...a,...d],p={};for(let[S,w]of f){if(t!=null&&!w.allowsObserve(t))continue;let O=pt(w,i),E=w instanceof j?w._deps.map(T=>c.get(T.node)??T.node.name??""):[],{name:P,...N}=O,R={...N,deps:E};if(!o){let T=this._annotations.get(S);T!=null&&(R.annotation=T)}if(r!=null)if(typeof r=="function"){let T=r;if(!(T.length>=2?T(S,R):T(R)))continue}else{let T=!0;for(let[M,Z]of Object.entries(r)){let ne=M==="deps_includes"?"depsIncludes":M==="meta_has"?"metaHas":M;if(ne==="depsIncludes"){if(!R.deps.includes(String(Z))){T=!1;break}continue}if(ne==="metaHas"){if(!Object.hasOwn(R.meta??{},String(Z))){T=!1;break}continue}if(R[ne]!==Z){T=!1;break}}if(!T)continue}p[S]=R}let h=new Set(Object.keys(p)),l=[];for(let[S,w]of f)if(w instanceof j)for(let O of w._deps){let E=c.get(O.node);E!=null&&l.push([E,S])}l.sort((S,w)=>S[0]<w[0]?-1:S[0]>w[0]?1:S[1]<w[1]?-1:S[1]>w[1]?1:0);let u=l.map(([S,w])=>({from:S,to:w}));(t!=null||r!=null)&&(u=u.filter(S=>h.has(S.from)&&h.has(S.to)));let g=this._collectSubgraphs(""),m=t!=null||r!=null?g.filter(S=>{let w=`${S}${C}`;return[...h].some(O=>O===S||O.startsWith(w))}):g,y=this,b=e,v={name:this.name,nodes:p,edges:u,subgraphs:m,expand(S){let w={...b,format:void 0};return Array.isArray(S)?(w.fields=S,w.detail=void 0):(w.detail=S,w.fields=void 0),y.describe(w)}},_=e??{},k=_.format;return k==="json"?qn(v,_):k==="pretty"?Kn(v,_):k==="mermaid"?Qt(v,_):k==="mermaid-url"?Jn(v,_):k==="d2"?Xn(v,_):v}_collectSubgraphs(e){let t=[];for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${r}`;t.push(s),t.push(...this._mounts.get(r)._collectSubgraphs(`${s}${C}`))}return t}resourceProfile(e){return Wt(this,e)}reachable(e,t,r={}){return r.withDetail===!0?Yt(this.describe(),e,t,{...r,withDetail:!0}):Yt(this.describe(),e,t,r)}explain(e,t,r){return r?.reactive===!0?this._explainReactive(e,t,r):this._explainStatic(e,t,r)}_explainStatic(e,t,r){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,c]of Object.entries(s.nodes))c.lastMutation!=null&&i.set(a,c.lastMutation);return Vt(s,e,t,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},r=e.reactiveName??"describe",s=0,o=ee(s,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,d=()=>{a||c||(a=!0,Se(()=>{a=!1,!c&&(s+=1,o.emit(s))}))},f=i.onEvent(m=>{let y=m.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||d()}),p=[],h=new WeakSet,l=m=>{if(h.has(m)||c)return;h.add(m);let y=m.topology.subscribe(b=>{for(let v of b){if(v[0]!==F)continue;let _=v[1];if(d(),_.kind==="added"&&_.nodeKind==="mount"){let k=m._mounts.get(_.name);k!=null&&l(k)}}});p.push(y);for(let b of m._mounts.keys()){let v=m._mounts.get(b);v!=null&&l(v)}};l(this);let u;try{u=ce([o],()=>this.describe(t),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,y)=>m===y})}catch(m){f();for(let y of p)y();throw i.dispose(),m}let g=be(u);return{node:u,dispose(){c=!0,f();for(let m of p)m();p.length=0,i.dispose(),g()}}}_explainReactive(e,t,r){let s=0,o=ee(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,d=i.onEvent(l=>{let u=l.type;u!=="data"&&u!=="error"&&u!=="complete"&&u!=="teardown"||a||c||(a=!0,Se(()=>{a=!1,!c&&(s+=1,o.emit(s))}))}),f={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},p;try{p=ce([o],()=>this._explainStatic(e,t,f),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:t},equals:(l,u)=>l.found===u.found&&l.reason===u.reason&&l.steps.length===u.steps.length&&ir(l.steps,u.steps)})}catch(l){throw d(),i.dispose(),l}let h=be(p);return{node:p,dispose(){c=!0,d(),i.dispose(),h()}}}_pathsMatching(e){let t=Ue(e),r=[];return this._collectObserveTargets("",r),r.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${C}${r}`;this._mounts.get(r)._collectObserveTargets(s,t)}for(let r of[...this._nodes.keys()].sort()){let s=this._nodes.get(r),o=e===""?r:`${e}${C}${r}`;t.push([o,s]),this._appendMetaObserveTargets(o,s,t)}}_appendMetaObserveTargets(e,t,r){for(let s of Object.keys(t.meta).sort()){let o=t.meta[s],i=`${e}${C}${J}${C}${s}`;r.push([i,o]),this._appendMetaObserveTargets(i,o,r)}}observe(e,t){let r=typeof e=="string",o=Jt(r?t: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 f=e,p=this.resolve(f);if(a!=null&&!p.allowsObserve(a))throw new K({actor:a,action:"observe",nodeName:f});return i?this._buildStructuredObserver([[f,p]],o,"one"):{subscribe(h){return p.subscribe(h)},up(h){try{p.up?.(h)}catch(l){if(l instanceof K)return;throw l}}}}let c=[];this._collectObserveTargets("",c),c.sort((f,p)=>f[0]<p[0]?-1:f[0]>p[0]?1:0);let d=a==null?c:c.filter(([,f])=>f.allowsObserve(a));return i?this._buildStructuredObserver(d,o,"all"):{subscribe:f=>{let p=d.map(([h,l])=>l.subscribe(u=>{f(h,u)}));return()=>{for(let h of p)h()}},up:(f,p)=>{try{this.resolve(f).up?.(p)}catch(h){if(h instanceof K)return;throw h}}}}_buildStructuredObserver(e,t,r){let s=r==="one"?e[0]?.[0]:void 0,o=i=>{if(r==="one"&&s!=null){let f=this.resolve(s);return this._buildStructuredObserver([[s,f]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((f,p)=>f[0]<p[0]?-1:f[0]>p[0]?1:0);let c=i.actor,d=c==null?a:a.filter(([,f])=>f.allowsObserve(c));return this._buildStructuredObserver(d,i,"all")};return this._createObserveResult(e,t,o)}_createObserveResult(e,t,r){let s=t.timeline===!0,o=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",c=this.config.inspectorEnabled,d=(o||i)&&c,f=t.maxEvents,p=f!=null&&f>0?new ke(f):null,h=[],l=new Set,u={},g=new Set,m=0,y=0,b=0,v=0,_=0,k=0,S=!1,w=!1,O=0,E=new Map,P=new Map,N=new Map,R=x=>{p?p.push(x):h.push(x);for(let G of l)G(x)},T=()=>s?{timestamp_ns:pe(),in_batch:Ae(),batch_id:O}:{},M=(x,G)=>{if(!(!d||!(x instanceof j)))return x._setInspectorHook(U=>{if(U.kind==="dep_message")E.set(x,U.depIndex);else if(U.kind==="run"){let ye=U.batchData.map((D,B)=>D!=null&&D.length>0?D.at(-1):U.prevData[B]);P.set(x,ye);let W=U.batchData.map(D=>D!=null?[...D]:void 0);N.set(x,W),i&&R({type:"derived",path:G,dep_values:ye,dep_batches:W,...T()})}})},Z=x=>{let G=E.get(x),U=P.get(x);if(!o||U==null)return{};let W=(G!=null&&G>=0&&x instanceof j?x._deps[G]:void 0)?.node,D=W?.v,B=N.get(x);return{trigger_dep_index:G,trigger_dep_name:W?.name,...D!=null?{trigger_version:{id:D.id,version:D.version}}:{},dep_values:[...U],...B!=null?{dep_batches:B}:{}}},ne=[],Te=[];for(let[x,G]of e){let U=M(G,x);U&&ne.push(U),Te.push(G.subscribe(ye=>{O++;for(let W of ye){let D=W[0],B=T();if(D===F){u[x]=W[1];let Ze=G instanceof j?G.lastMutation?.actor??ue:ue;R({type:"data",path:x,data:W[1],actor:Ze,...B,...Z(G)})}else if(a)D===z?m++:D===I?y++:D===Y?b++:D===X?v++:D===Q?_++:D===H?k++:D===V&&!g.has(x)?S=!0:D===$&&(w=!0,g.add(x));else if(D===z)m++,R({type:"dirty",path:x,...B});else if(D===I)y++,R({type:"resolved",path:x,...B,...Z(G)});else if(D===Y)b++,R({type:"invalidate",path:x,...B});else if(D===X)v++,R({type:"pause",path:x,lockId:W[1],...B});else if(D===Q)_++,R({type:"resume",path:x,lockId:W[1],...B});else if(D===V)g.has(x)||(S=!0),R({type:"complete",path:x,...B});else if(D===$){w=!0,g.add(x);let Ze=G instanceof j?G.lastMutation?.actor??ue:ue;R({type:"error",path:x,data:W[1],actor:Ze,...B})}else D===H&&(k++,R({type:"teardown",path:x,...B}))}}))}let Je=!1,Ye=()=>{if(!Je){Je=!0;for(let x of Te)x();for(let x of ne)x();for(let x of Ee)x({value:void 0,done:!0});Ee.length=0}},Xe=[],Ee=[];l.add(x=>{let G=Ee.shift();G?G({value:x,done:!1}):Xe.push(x)});let St={get values(){return u},get dirtyCount(){return m},get resolvedCount(){return y},get invalidateCount(){return b},get pauseCount(){return v},get resumeCount(){return _},get teardownCount(){return k},get events(){return p?p.toArray():[...h]},get anyCompletedCleanly(){return S},get anyErrored(){return w},get completedWithoutErrors(){return S&&!w},onEvent(x){return l.add(x),()=>l.delete(x)},dispose:Ye,expand(x){Ye();let G={...t};return typeof x=="string"?G.detail=x:Object.assign(G,x),r(Jt(G))},[Symbol.asyncIterator](){return{next(){return Xe.length>0?Promise.resolve({value:Xe.shift(),done:!1}):Je?Promise.resolve({value:void 0,done:!0}):new Promise(x=>Ee.push(x))},return(){return Ye(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(St,t),St}_attachFormatLogger(e,t){let r=t.format;if(r==null)return;let s=t.logger??(u=>console.log(u)),o=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=o==null&&i==null?()=>!0:u=>(o==null||o.has(u))&&(i==null||!i.has(u)),c=tr(t.theme),d=r==="stage-log"?pe():0,f=u=>u==null?"":t.stageLabels?.[u]??u,p=(u,g)=>u.length>g?`${u.slice(0,g-1)}\u2026`:u,h=u=>u.type==="data"||u.type==="error"?p(We(u.data),120):"",l=u=>{if(r==="stage-log"){let w=(pe()-d)/1e9,O=f(u.path).padEnd(9);if(u.type==="data"){let E=h(u);return`[${w.toFixed(3)}s] ${O} \u2190${E?` ${E}`:""}`}if(u.type==="error"){let E=h(u);return`[${w.toFixed(3)}s] ${O} \u2717${E?` ${E}`:""}`}return u.type==="complete"?`[${w.toFixed(3)}s] ${O} \u25A0 complete`:`[${w.toFixed(3)}s] ${O} ${u.type}`}if(r==="json")try{return JSON.stringify(u)}catch{return JSON.stringify({type:u.type,path:u.path,data:"[unserializable]"})}let g=c[u.type]??"",m=u.path?`${c.path}${u.path}${c.reset} `:"",y=u.type==="data"||u.type==="error",b=u.type==="pause"||u.type==="resume",v=y?` ${We(u.data)}`:b?` ${We(u.lockId)}`:"",_=u.type==="data"||u.type==="resolved"||u.type==="derived"?u:void 0,k=_?.trigger_dep_name!=null?` <- ${_.trigger_dep_name}`:_?.trigger_dep_index!=null?` <- #${_.trigger_dep_index}`:"",S=u.in_batch?" [batch]":"";return`${m}${g}${u.type.toUpperCase()}${c.reset}${v}${k}${S}`};e.onEvent(u=>{a(u.type)&&s(l(u),u)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){qt(this._disposers,this.name),this.signal([[H]],{internal:!0}),qt(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}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}snapshot(e){let{expand:t,...r}=this.describe({detail:"full"}),s={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:c,guard:d,...f}=r.nodes[a];s[a]=f}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 Tt(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let r=t?.config??ge,{codec:s,codecVersion:o,payload:i}=Et(e,r);return s.decode(i,o)}restore(e,t){if(Kt(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(o=>Ue(o)),s=t?.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&&t?.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 c=this.tryResolve(o)?.v;if(c!=null&&c.id===i.v.id&&c.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){t?.onError?.(o,a)}}}}}static fromSnapshot(e,t){Kt(e);let r=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,o=new n(e.name);if(r)return r(o),o.restore(e),o;for(let l of[...e.subgraphs].sort((u,g)=>{let m=u.split(C).length,y=g.split(C).length;return m!==y?m-y:u<g?-1:u>g?1:0})){let u=l.split(C),g=o;for(let m of u)g._mounts.has(m)||g.mount(m,new n(m)),g=g._mounts.get(m)}let i=s?Object.entries(s).map(([l,u])=>({re:Ue(l),factory:u})):[],a=l=>{for(let u of i)if(u.re.test(l))return u.factory},c=l=>{let u=l.split(C),g=u.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${l}"`);let m=o;for(let y of u){let b=m._mounts.get(y);if(!b)throw new Error(`unknown mount "${y}" in path "${l}"`);m=b}return[m,g]},d=Object.entries(e.nodes).filter(([l])=>!l.includes(`${C}${J}${C}`)).sort((l,u)=>l[0]<u[0]?-1:l[0]>u[0]?1:0),f=new Map(d),p=new Map,h=!0;for(;f.size>0&&h;){h=!1;for(let[l,u]of[...f.entries()]){let g=u?.deps??[];if(!g.every(k=>p.has(k)))continue;let[m,y]=c(l),b={...u?.meta??{}},v=a(l),_;if(u?.type==="state")_=ee(u.value,{meta:b});else{if(v==null)continue;_=v(y,{path:l,type:u.type,value:u.value,meta:b,deps:g,resolvedDeps:g.map(k=>p.get(k))})}m.add(_,{name:y}),p.set(l,_),f.delete(l),h=!0}}if(f.size>0){let l=[...f.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${l}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachStorage(e,t={}){let r=e.map(d=>({tier:d,debounceMs:Math.max(0,d.debounceMs??0),compactEvery:Math.max(1,d.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let s=(d,f)=>{if(d.disposed)return;let p=Bn(f.nodes);if(d.lastSnapshot!=null&&p!==""&&p===d.lastFingerprint)return;let h=d.seq+1,l=he(),m=d.lastSnapshot==null||h%d.compactEvery===0?{mode:"full",snapshot:f,seq:h,timestamp_ns:l,format_version:se}:{mode:"diff",diff:or(d.lastSnapshot,f),seq:h,timestamp_ns:l,format_version:se};if(d.tier.filter&&!d.tier.filter(this.name,m))return;let y;try{y=d.tier.save(this.name,m)}catch(b){t.onError?.(b,d.tier);return}if(y&&typeof y.then=="function"){let _=(d.savePending??Promise.resolve()).then(()=>y,()=>y).then(()=>{d.disposed||(d.seq=h,d.lastSnapshot=f,d.lastFingerprint=p)},k=>{t.onError?.(k,d.tier)});d.savePending=_.finally(()=>{d.savePending===_&&(d.savePending=void 0)})}else d.seq=h,d.lastSnapshot=f,d.lastFingerprint=p},o=(d,f)=>{try{s(d,f)}catch(p){t.onError?.(p,d.tier)}},i=(d,f)=>{if(!f.some(u=>{let g=this.config.messageTier(u[0]);return g>=3&&g<5}))return;if(t.filter){let u=this.tryResolve(d);if(u==null)return;let g=pt(u,Ie("standard"));if(!t.filter(d,g))return}let h,l=()=>(h==null&&(h=this.snapshot()),h);for(let u of r)u.disposed||(u.debounceMs===0?o(u,l()):(u.timer==null&&(u.timer=new Ve),u.timer.start(u.debounceMs,()=>{u.disposed||o(u,this.snapshot())})))},a;if(t.paths!=null){let f=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(p=>{let h=this.tryResolve(p);return h==null?()=>{}:h.subscribe(l=>i(p,l))});a=()=>{for(let p of f)p()}}else a=this.observe().subscribe((d,f)=>i(d,f));let c=()=>{a();for(let d of r)d.disposed=!0,d.timer?.cancel();this._storageDisposers.delete(c)};return this._storageDisposers.add(c),{dispose:c}}async _cascadeRestore(e,t){for(let r of e){let s;try{s=await r.load(this.name)}catch(i){t?.(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===se&&o.nodes!=null)return this.restore(o),!0}catch(i){t?.(i,r)}}return!1}static async fromStorage(e,t,r){for(let s of t){let o;try{o=await s.load(e)}catch(c){r?.onError?.(c,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===se&&i.nodes!=null?i:void 0;if(a!=null)try{return n.fromSnapshot(a,r)}catch(c){r?.onError?.(c,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,r){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:pe(),...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 t=this._traceRing.toArray().filter(s=>!e(s)),r=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return r}static diff(e,t){let r=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),o=[...s].filter(b=>!r.has(b)).sort(),i=[...r].filter(b=>!s.has(b)).sort(),a=[],c=[];for(let b of r){if(!s.has(b))continue;let v=e.nodes[b],_=t.nodes[b],k=v.v,S=_.v;k!=null&&S!=null&&k.id===S.id&&k.version!==S.version&&c.push({path:b,id:k.id,from:k.version,to:S.version});let w=k!=null&&S!=null&&k.id===S.id&&k.version===S.version;for(let O of["type","status","sentinel"]){let E=v[O],P=_[O];E!==P&&a.push({path:b,field:O,from:E,to:P})}if(!w)for(let O of["value","meta"]){let E=v[O],P=_[O];Hn(E,P)||a.push({path:b,field:O,from:E,to:P})}}let d=b=>`${b.from} ${b.to}`,f=new Set(e.edges.map(d)),p=new Set(t.edges.map(d)),h=t.edges.filter(b=>!f.has(d(b))),l=e.edges.filter(b=>!p.has(d(b))),u=new Set(e.subgraphs),g=new Set(t.subgraphs),m=[...g].filter(b=>!u.has(b)).sort(),y=[...u].filter(b=>!g.has(b)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:c,edgesAdded:h,edgesRemoved:l,subgraphsAdded:m,subgraphsRemoved:y}}};function or(n,e){let t=te.diff(n,e),r={};for(let s of t.nodesAdded){let o=e.nodes[s];o!=null&&(r[s]=o)}return{...t,nodesAddedFull:r}}function Yt(n,e,t,r={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?s:[];if(!r.both&&t!=="upstream"&&t!=="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,c=new Map,d=new Map,f=new Set;for(let[v,_]of Object.entries(n.nodes)){if(!v)continue;f.add(v);let k=_.deps??[];i.set(v,k);for(let S of k)S&&(f.add(S),a.has(S)||a.set(S,new Set),a.get(S).add(v))}for(let v of n.edges){if(v==null||typeof v!="object")continue;let _=typeof v.from=="string"?v.from:"",k=typeof v.to=="string"?v.to:"";!_||!k||(f.add(_),f.add(k),d.has(_)||d.set(_,new Set),d.get(_).add(k),c.has(k)||c.set(k,new Set),c.get(k).add(_))}if(!f.has(e))return r.withDetail?s:[];let p=r.both===!0,h=v=>{if(p){let w=i.get(v)??[],O=c.get(v),E=a.get(v),P=d.get(v),N=[...w];return O&&N.push(...O),E&&N.push(...E),P&&N.push(...P),N}if(t==="upstream"){let w=i.get(v)??[],O=c.get(v);return O?[...w,...O]:w}let _=a.get(v),k=d.get(v),S=_?[..._]:[];return k&&S.push(...k),S},l=new Set([e]),u=new Map,g=[{path:e,depth:0}],m=0,y=!1;for(;m<g.length;){let v=g[m++];if(o!=null&&v.depth>=o){h(v.path).length>0&&(y=!0);continue}for(let _ of h(v.path))!_||l.has(_)||(l.add(_),u.set(_,v.depth+1),g.push({path:_,depth:v.depth+1}))}let b=[...u.keys()].sort((v,_)=>v<_?-1:v>_?1:0);return r.withDetail?{paths:b,depths:u,truncated:y}:b}function ir(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++){let r=n[t],s=e[t];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}$e();re();me();Le();re();ht();function tn(n,e){let t=n.cache??0;return t>=e?!1:(n.down([[z],[F,t+1]]),!0)}function nn(n,e,t){return{[n]:!0,[`${n}_type`]:e,...t??{}}}function rn(n,e){return nn("reduction",n,e)}function sn(n,e,t,r){let s=r?.maxIterations??10,o=`__feedback_${e}`,i=ee(0,{meta:rn("feedback_counter",{maxIterations:s,feedbackFrom:e,feedbackTo:t})});n.add(i,{name:o});let a=n.resolve(e),c=n.resolve(t),d=`__feedback_effect_${e}`,f=ae([],(p,h)=>{let l=a.subscribe(u=>{for(let g of u){let m=g[0];if(m===F){let y=g[1];if(y==null)return;De(()=>{tn(i,s)&&c.emit(y)})}else if(m===V||m===$){let y=m===$&&g.length>1?[$,g[1]]:[m];i.down([y])}}});return()=>l()},{name:d,describeKind:"effect",meta:{...rn("feedback_effect",{feedbackFrom:e,feedbackTo:t}),_internal:!0}});return n.add(f,{name:d}),n.addDisposer(be(f)),n}function an(n){return typeof n=="object"&&n!==null&&"factory"in n}function ar(n){return typeof n=="object"&&n!==null&&"factory"in n}function cr(n){return an(n)?n.factory:n}function dr(n){return ar(n)?n.factory:n}function yt(n,e){let t=[],r=new Set(Object.keys(e.fns??{})),s=new Set(Object.keys(e.sources??{}));for(let[o,i]of Object.entries(n.nodes)){if(i.type==="template")continue;let a=i;if(a.fn&&r.size>0&&!r.has(a.fn))if(s.has(a.fn))t.push(`Node "${o}": fn "${a.fn}" is a source, not a function. Use it as a producer source instead, or use a function from: ${[...r].join(", ")}`);else{let c=bt(a.fn,r);t.push(`Node "${o}": fn "${a.fn}" not found in catalog`+(c?`. Did you mean "${c}"?`:""))}if(a.source&&s.size>0&&!s.has(a.source))if(r.has(a.source))t.push(`Node "${o}": source "${a.source}" is a function, not a source. Use it as fn instead, or use a source from: ${[...s].join(", ")}`);else{let c=bt(a.source,s);t.push(`Node "${o}": source "${a.source}" not found in catalog`+(c?`. Did you mean "${c}"?`:""))}if(a.fn&&a.config&&e.fns?.[a.fn]){let c=e.fns[a.fn];if(an(c)&&c.configSchema){for(let[d,f]of Object.entries(c.configSchema))if(f.required!==!1&&!(d in a.config)&&t.push(`Node "${o}": config missing required field "${d}"`),d in a.config&&f.enum){let p=a.config[d];f.enum.includes(p)||t.push(`Node "${o}": config.${d} = ${JSON.stringify(p)}, expected one of: ${f.enum.join(", ")}`)}}}}if(n.templates){for(let[o,i]of Object.entries(n.templates))for(let[a,c]of Object.entries(i.nodes))if(c.fn&&r.size>0&&!r.has(c.fn)){let d=bt(c.fn,r);t.push(`Template "${o}" node "${a}": fn "${c.fn}" not found in catalog`+(d?`. Did you mean "${d}"?`:""))}}return{valid:t.length===0,errors:t}}function bt(n,e){let t=null,r=1/0,s=n.toLowerCase();for(let o of e){let i=ur(s,o.toLowerCase());i<r&&i<=Math.max(3,Math.floor(n.length/2))&&(r=i,t=o)}return t}function ur(n,e){let t=n.length,r=e.length,s=Array.from({length:t+1},(o,i)=>Array.from({length:r+1},(a,c)=>i===0?c:c===0?i:0));for(let o=1;o<=t;o++)for(let i=1;i<=r;i++)s[o][i]=n[o-1]===e[i-1]?s[o-1][i-1]:1+Math.min(s[o-1][i],s[o][i-1],s[o-1][i-1]);return s[t][r]}var on=new Set(["state","producer","derived","effect","operator","template"]),lr=new Set(["state","producer","derived","effect","operator"]);function vt(n){let e=[];if(n==null||typeof n!="object")return{valid:!1,errors:["GraphSpec must be a non-null object"]};let t=n;if((typeof t.name!="string"||t.name.length===0)&&e.push("Missing or empty 'name' field"),t.nodes==null||typeof t.nodes!="object"||Array.isArray(t.nodes))return e.push("Missing or invalid 'nodes' field (must be an object)"),{valid:!1,errors:e};let r=new Set(Object.keys(t.nodes)),s=new Map,o=new Map;if(t.templates!=null&&typeof t.templates=="object"&&!Array.isArray(t.templates)){for(let[i,a]of Object.entries(t.templates))if(a!=null&&typeof a=="object"){let c=a;o.set(i,{params:Array.isArray(c.params)?c.params:[]})}}if(t.templates!=null)if(typeof t.templates!="object"||Array.isArray(t.templates))e.push("'templates' must be an object");else for(let[i,a]of Object.entries(t.templates)){if(a==null||typeof a!="object"){e.push(`Template "${i}": must be an object`);continue}let c=a;if(Array.isArray(c.params)||e.push(`Template "${i}": missing 'params' array`),c.nodes==null||typeof c.nodes!="object"||Array.isArray(c.nodes))e.push(`Template "${i}": missing or invalid 'nodes' object`);else{let d=new Set(Array.isArray(c.params)?c.params:[]),f=new Set(Object.keys(c.nodes));for(let[p,h]of Object.entries(c.nodes)){if(h==null||typeof h!="object"){e.push(`Template "${i}" node "${p}": must be an object`);continue}let l=h;if((typeof l.type!="string"||!lr.has(l.type))&&e.push(`Template "${i}" node "${p}": invalid type`),Array.isArray(l.deps))for(let u of l.deps)!f.has(u)&&!d.has(u)&&e.push(`Template "${i}" node "${p}": dep "${u}" is not an inner node or param`)}typeof c.output!="string"?e.push(`Template "${i}": missing 'output' string`):c.nodes[c.output]||e.push(`Template "${i}": output "${c.output}" is not a declared node`)}}for(let[i,a]of Object.entries(t.nodes)){if(a==null||typeof a!="object"){e.push(`Node "${i}": must be an object`);continue}let c=a;if(typeof c.type!="string"||!on.has(c.type)){e.push(`Node "${i}": invalid type "${String(c.type)}" (expected: ${[...on].join(", ")})`);continue}if(s.set(i,c.type),c.type==="template")if(typeof c.template!="string"||!o.has(c.template))e.push(`Node "${i}": template "${String(c.template)}" not found in templates`);else if(c.bind==null||typeof c.bind!="object"||Array.isArray(c.bind))e.push(`Node "${i}": template ref requires 'bind' object`);else{let d=o.get(c.template),f=c.bind;for(let p of d.params)p in f||e.push(`Node "${i}": template param "${p}" is not bound (template "${c.template}")`);for(let[,p]of Object.entries(f))typeof p=="string"&&!r.has(p)&&e.push(`Node "${i}": bind target "${p}" does not reference an existing node`)}else{if(Array.isArray(c.deps))for(let d of c.deps)d===i?e.push(`Node "${i}": self-referencing dep`):r.has(d)||e.push(`Node "${i}": dep "${d}" does not reference an existing node`);(c.type==="derived"||c.type==="effect"||c.type==="operator")&&!Array.isArray(c.deps)&&e.push(`Node "${i}": ${c.type} node should have a 'deps' array`)}}if(t.feedback!=null)if(!Array.isArray(t.feedback))e.push("'feedback' must be an array");else for(let i=0;i<t.feedback.length;i++){let a=t.feedback[i];if(a==null||typeof a!="object"){e.push(`Feedback [${i}]: must be an object`);continue}let c=a;(typeof c.from!="string"||!r.has(c.from))&&e.push(`Feedback [${i}]: 'from' "${String(c.from)}" does not reference an existing node`),typeof c.from=="string"&&c.from===c.to&&e.push(`Feedback [${i}]: 'from' and 'to' must be different nodes`),typeof c.to!="string"||!r.has(c.to)?e.push(`Feedback [${i}]: 'to' "${String(c.to)}" does not reference an existing node`):typeof c.to=="string"&&s.get(c.to)!=="state"&&e.push(`Feedback [${i}]: 'to' node "${c.to}" must be a state node (got "${s.get(c.to)??"unknown"}")`)}return{valid:e.length===0,errors:e}}function cn(n,e){let t=vt(n);if(!t.valid)throw new Error(`compileSpec: invalid GraphSpec:
|
|
7
|
+
${t.errors.join(`
|
|
8
|
+
`)}`);let r=e?.catalog??{},s=new te(n.name),o=n.templates??{},i=yt(n,r);if(!i.valid)throw new Error(`compileSpec: catalog validation errors:
|
|
9
|
+
${i.errors.join(`
|
|
10
|
+
`)}`);let a=l=>{let u=r.fns?.[l];return u?cr(u):void 0},c=l=>{let u=r.sources?.[l];return u?dr(u):void 0},d=new Map,f=[];for(let[l,u]of Object.entries(n.nodes)){if(u.type==="template")continue;let g=u;if(g.type==="state"){let m=ee(g.initial,{name:l,meta:g.meta?{...g.meta}:void 0});s.add(m,{name:l}),d.set(l,m)}else if(g.type==="producer"){let m=g.source?c(g.source):void 0,y=g.fn?a(g.fn):void 0;if(m){let b=m(g.config??{});s.add(b,{name:l}),d.set(l,b)}else if(y){let b=y([],g.config??{});s.add(b,{name:l}),d.set(l,b)}else{let b=Oe(()=>{},{name:l,meta:{...g.meta,_specFn:g.fn,_specSource:g.source}});s.add(b,{name:l}),d.set(l,b)}}else f.push([l,g])}let p=!0,h=new Map(f);for(;h.size>0&&p;){p=!1;for(let[l,u]of[...h.entries()]){let g=u.deps??[];if(!g.every(v=>d.has(v)))continue;let m=g.map(v=>d.get(v)),y=u.fn?a(u.fn):void 0,b;y?b=y(m,u.config??{}):u.type==="effect"?b=je(m,()=>{}):b=ce(m,v=>v[0]),s.add(b,{name:l}),d.set(l,b),h.delete(l),p=!0}}if(h.size>0){let l=[...h.keys()].sort().join(", ");throw new Error(`compileSpec: unresolvable deps for nodes: ${l}`)}for(let[l,u]of Object.entries(n.nodes)){if(u.type!=="template")continue;let g=u,m=o[g.template],y=new te(l),b=new Map,v=[];for(let[w,O]of Object.entries(m.nodes)){let E=(O.deps??[]).map(N=>N.startsWith("$")&&g.bind[N]?g.bind[N]:N),P={...O,deps:E};if(O.type==="state"){let N=ee(O.initial,{name:w,meta:O.meta?{...O.meta}:void 0});y.add(N,{name:w}),b.set(w,N)}else if(O.type==="producer"){let N=O.source?c(O.source):void 0,R=O.fn?a(O.fn):void 0;if(N){let T=N(O.config??{});y.add(T,{name:w}),b.set(w,T)}else if(R){let T=R([],O.config??{});y.add(T,{name:w}),b.set(w,T)}else{let T=Oe(()=>{},{name:w,meta:{...O.meta,_specFn:O.fn,_specSource:O.source}});y.add(T,{name:w}),b.set(w,T)}}else v.push([w,P])}let _=!0,k=new Map(v);for(;k.size>0&&_;){_=!1;for(let[w,O]of[...k.entries()]){let E=O.deps??[];if(!E.every(M=>b.has(M)||d.has(M)))continue;let N=E.map(M=>b.get(M)??d.get(M)),R=O.fn?a(O.fn):void 0,T;R?T=R(N,O.config??{}):O.type==="effect"?T=je(N,()=>{}):T=ce(N,M=>M[0]),y.add(T,{name:w}),b.set(w,T),k.delete(w),_=!0}}if(k.size>0){let w=[...k.keys()].sort().join(", ");throw new Error(`compileSpec: template "${g.template}" has unresolvable deps: ${w}`)}s.mount(l,y);let S=`${l}::${m.output}`;d.set(l,s.resolve(S));try{let w=s.resolve(S);w.meta._templateName?.emit(g.template),w.meta._templateBind?.emit(g.bind)}catch{}}for(let l of n.feedback??[])sn(s,l.from,l.to,{maxIterations:l.maxIterations});return s}var A=class extends Error{code;details;constructor(e,t,r){super(t),this.name="SurfaceError",this.code=e,r!==void 0&&(this.details=r)}toJSON(){let e={code:this.code,message:this.message};if(this.details!==void 0){let t=fr(this.details);t!==void 0&&(e.details=t)}return e}};function fr(n){try{return JSON.parse(JSON.stringify(n))}catch{return}}function dn(n,e="internal-error"){if(n instanceof A)return n;let t=n instanceof Error?n.message:String(n);return new A(e,t)}function qe(n,e){let t=vt(n);if(!t.valid)throw new A("invalid-spec",`GraphSpec validation failed:
|
|
11
|
+
${t.errors.join(`
|
|
12
|
+
`)}`,{errors:t.errors});let r=e?.catalog??{},s=yt(n,r);if(!s.valid)throw new A("catalog-error",`Catalog validation failed:
|
|
13
|
+
${s.errors.join(`
|
|
14
|
+
`)}`,{errors:s.errors});try{return cn(n,e)}catch(o){let i=o instanceof Error?o.message:String(o);throw new A("catalog-error",i)}}re();var pr=3e4;async function un(n,e,t){let r=t?.inputPath??"input",s=t?.outputPath??"output",o=t?.timeoutMs??pr,i=qe(n,{catalog:t?.catalog}),a;try{a=i.resolve(s)}catch{throw i.destroy(),new A("node-not-found",`reduce: output path "${s}" is not registered`,{path:s})}try{i.resolve(r)}catch{throw i.destroy(),new A("node-not-found",`reduce: input path "${r}" is not registered`,{path:r})}try{return await new Promise((c,d)=>{let f=!1,p=!1,h,l,u=!1,g=m=>{p||(p=!0,h!==void 0&&clearTimeout(h),l!==void 0?(l(),l=void 0):u=!0,m())};l=a.subscribe(m=>{for(let y of m){if(p)return;if(f){if(y[0]===F){g(()=>c(y[1]));return}if(y[0]===I){let b=a.cache;g(()=>c(b));return}if(y[0]===$){let b=y[1],v=b instanceof Error?b.message:String(b),_=b instanceof Error?b:void 0;g(()=>d(new A("internal-error",`reduce: output emitted ERROR: ${v}`,_!=null?{cause:_}:void 0)));return}if(y[0]===V){g(()=>d(new A("internal-error","reduce: output COMPLETEd without a post-push DATA")));return}}}}),u&&(l?.(),l=void 0),f=!0;try{i.set(r,e)}catch(m){let y=m instanceof Error?m.message:String(m),b=m instanceof Error?m:void 0;g(()=>d(new A("internal-error",`reduce: failed to set input on "${r}": ${y}`,b!=null?{path:r,cause:b}:{path:r})));return}!p&&Number.isFinite(o)&&o>0&&(h=setTimeout(()=>{g(()=>d(new A("reduce-timeout",`reduce: no output emitted within ${o}ms`,{timeoutMs:o,outputPath:s})))},o),h.unref?.())})}finally{i.destroy()}}Ce();var _t=se,xe="snapshot:";function Ne(n){if(n.startsWith(xe))throw new A("snapshot-failed",`snapshot id must not start with "${xe}" (reserved); got "${n}"`,{snapshotId:n})}function Ke(n){return`${xe}${n}`}function hr(n){return n.startsWith(xe)?n.slice(xe.length):void 0}function wt(n,e){if(n==null||typeof n!="object")throw new A("snapshot-not-found",`snapshot "${e}" not found in tier`,{snapshotId:e});let t=n;if("mode"in t){if(t.mode==="full"&&"snapshot"in t)return t.snapshot;throw t.mode==="diff"?new A("restore-failed",`snapshot "${e}" is a diff record; restore the baseline and replay WAL instead`,{snapshotId:e,mode:"diff"}):new A("restore-failed",`snapshot "${e}" has unknown mode "${String(t.mode)}"`,{snapshotId:e,mode:String(t.mode)})}if("nodes"in t&&"edges"in t&&"subgraphs"in t&&"name"in t)return t;throw new A("restore-failed",`snapshot "${e}" payload is not a GraphCheckpointRecord or GraphPersistSnapshot`,{snapshotId:e})}async function ln(n,e,t){Ne(e);let r;try{r=n.snapshot()}catch(o){let i=o instanceof Error?o.message:String(o);throw new A("snapshot-failed",`snapshot "${e}" serialization failed: ${i}`,{snapshotId:e})}let s={mode:"full",seq:0,timestamp_ns:he(),format_version:_t,snapshot:r};try{await t.save(Ke(e),s)}catch(o){let i=o instanceof Error?o.message:String(o);throw new A("snapshot-failed",`snapshot "${e}" save failed: ${i}`,{snapshotId:e})}return{snapshotId:e,timestamp_ns:s.timestamp_ns}}async function fn(n,e,t){Ne(n);let r=Ke(n),s=await e.load(r);s==null&&(s=await e.load(n));let o=wt(s,n);try{return te.fromSnapshot(o,t?.factories?{factories:t.factories}:void 0)}catch(i){let a=i instanceof Error?i.message:String(i);throw new A("restore-failed",`snapshot "${n}" restore failed: ${a}`,{snapshotId:n})}}async function pn(n,e,t){Ne(n),Ne(e);let r=async c=>{let d=Ke(c),f=await t.load(d);return f==null&&(f=await t.load(c)),f},[s,o]=await Promise.all([r(n),r(e)]),i=wt(s,n),a=wt(o,e);return te.diff(i,a)}async function hn(n,e){if(typeof n.list!="function")throw new A("tier-no-list","StorageTier does not implement list(); wrap the tier with an enumerator or use a different backend");let t=await n.list(),r=[],s=e?.includeUnprefixed===!0;for(let o of t){let i=hr(o);i!==void 0?r.push(i):s&&r.push(o)}return r}async function gn(n,e){if(Ne(n),typeof e.clear!="function")throw new A("snapshot-failed",`StorageTier is append-only (no clear()); cannot delete "${n}"`,{snapshotId:n});try{await e.clear(Ke(n))}catch(t){let r=t instanceof Error?t.message:String(t);throw new A("snapshot-failed",`snapshot "${n}" delete failed: ${r}`,{snapshotId:n})}}0&&(module.exports={SNAPSHOT_WIRE_VERSION,SurfaceError,asSurfaceError,createGraph,deleteSnapshot,diffSnapshots,listSnapshots,restoreSnapshot,runReduction,saveSnapshot});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { C as CatalogFnEntry, a as CatalogSourceEntry, b as ConfigFieldSchema, F as FnFactory, G as GraphSpec, c as GraphSpecCatalog, d as GraphSpecFeedbackEdge, e as GraphSpecNode, f as GraphSpecTemplate, g as GraphSpecTemplateRef, h as GraphSpecValidation, S as SourceFactory } from '../../index-rX8HBM5h.cjs';
|
|
2
|
+
export { C as CreateGraphOptions, R as ReduceOptions, a as RestoreSnapshotOptions, S as SNAPSHOT_WIRE_VERSION, b as SaveSnapshotResult, c as SurfaceError, d as SurfaceErrorCode, e as SurfaceErrorPayload, f as asSurfaceError, g as createGraph, h as deleteSnapshot, i as diffSnapshots, l as listSnapshots, r as restoreSnapshot, j as runReduction, s as saveSnapshot } from '../../index-9oDeHH2u.cjs';
|
|
3
|
+
import '../../node-Cc1TniY8.cjs';
|
|
4
|
+
import '../../graph-D48Qw9Cg.cjs';
|
|
5
|
+
import '../../meta-Cgj6zeji.cjs';
|
|
6
|
+
import '../../extra/storage-core.cjs';
|
|
7
|
+
import '../../types-O3GzJY2U.cjs';
|
|
8
|
+
import '../../extra/sources.cjs';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { C as CatalogFnEntry, a as CatalogSourceEntry, b as ConfigFieldSchema, F as FnFactory, G as GraphSpec, c as GraphSpecCatalog, d as GraphSpecFeedbackEdge, e as GraphSpecNode, f as GraphSpecTemplate, g as GraphSpecTemplateRef, h as GraphSpecValidation, S as SourceFactory } from '../../index-DfyOkTvs.js';
|
|
2
|
+
export { C as CreateGraphOptions, R as ReduceOptions, a as RestoreSnapshotOptions, S as SNAPSHOT_WIRE_VERSION, b as SaveSnapshotResult, c as SurfaceError, d as SurfaceErrorCode, e as SurfaceErrorPayload, f as asSurfaceError, g as createGraph, h as deleteSnapshot, i as diffSnapshots, l as listSnapshots, r as restoreSnapshot, j as runReduction, s as saveSnapshot } from '../../index-CpgYhnrG.js';
|
|
3
|
+
import '../../node-Cc1TniY8.js';
|
|
4
|
+
import '../../graph-BZGRXwOm.js';
|
|
5
|
+
import '../../meta-CwesDrMD.js';
|
|
6
|
+
import '../../extra/storage-core.js';
|
|
7
|
+
import '../../types-u64Ose53.js';
|
|
8
|
+
import '../../extra/sources.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j}from"../../chunk-MIQTDPY4.js";import"../../chunk-3R5HFPX7.js";import"../../chunk-ERLIRFPA.js";import"../../chunk-ETWTCCJI.js";import"../../chunk-CKCSDI7T.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-VPYBOXVT.js";import"../../chunk-Z4HDAS2Q.js";import"../../chunk-4VVTGLXJ.js";import"../../chunk-OAWLCNJJ.js";import"../../chunk-2PMCKKRK.js";import"../../chunk-ZB5EHBIO.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{e as SNAPSHOT_WIRE_VERSION,a as SurfaceError,b as asSurfaceError,c as createGraph,j as deleteSnapshot,h as diffSnapshots,i as listSnapshots,g as restoreSnapshot,d as runReduction,f as saveSnapshot};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as Node } from './node-Cc1TniY8.cjs';
|
|
2
|
+
import { G as Graph } from './graph-D48Qw9Cg.cjs';
|
|
3
3
|
|
|
4
4
|
/** Pluggable measurement backend. */
|
|
5
5
|
interface MeasurementAdapter {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as Node } from './node-Cc1TniY8.js';
|
|
2
|
+
import { G as Graph } from './graph-BZGRXwOm.js';
|
|
3
3
|
|
|
4
4
|
/** Pluggable measurement backend. */
|
|
5
5
|
interface MeasurementAdapter {
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { a as Node, V as VersioningLevel } from './node-Cc1TniY8.cjs';
|
|
2
|
+
|
|
3
|
+
type ReactiveLogOptions<T> = {
|
|
4
|
+
name?: string;
|
|
5
|
+
maxSize?: number;
|
|
6
|
+
/**
|
|
7
|
+
* Optional versioning level for the underlying `entries` state node. Set
|
|
8
|
+
* at construction time; cannot be changed later. Pass `0` for V0 identity
|
|
9
|
+
* + monotonic version counter, or `1` for V1 + content-addressed cid.
|
|
10
|
+
*/
|
|
11
|
+
versioning?: VersioningLevel;
|
|
12
|
+
/**
|
|
13
|
+
* Storage backend. Defaults to `NativeLogBackend` (ring buffer if `maxSize` is set,
|
|
14
|
+
* flat array otherwise). Users can plug in persistent / RRB-tree backends via
|
|
15
|
+
* the {@link LogBackend} interface.
|
|
16
|
+
*/
|
|
17
|
+
backend?: LogBackend<T>;
|
|
18
|
+
};
|
|
19
|
+
type ReactiveLogBundle<T> = {
|
|
20
|
+
/** Emits `readonly T[]` on each append/clear/trim (two-phase). */
|
|
21
|
+
readonly entries: Node<readonly T[]>;
|
|
22
|
+
/** Current entry count (O(1)). */
|
|
23
|
+
readonly size: number;
|
|
24
|
+
/** Positional access (O(1)); returns `undefined` on out-of-range. Supports negative indices (Python-style). */
|
|
25
|
+
at: (index: number) => T | undefined;
|
|
26
|
+
append: (value: T) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Push all values, emit one snapshot. No-op if `values` is empty.
|
|
29
|
+
* **Iterable consumption:** `values` is a `readonly T[]` — safe to pass arrays.
|
|
30
|
+
*/
|
|
31
|
+
appendMany: (values: readonly T[]) => void;
|
|
32
|
+
clear: () => void;
|
|
33
|
+
/** Remove the first `n` entries (clamped to `size`). Throws on non-integer or negative `n`. */
|
|
34
|
+
trimHead: (n: number) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Last `n` entries (or fewer) as a derived reactive view. Memoized with
|
|
37
|
+
* an LRU cache (default cap 64) — repeat calls with the same `n` return
|
|
38
|
+
* the same node. Throws on non-integer or negative `n`.
|
|
39
|
+
*
|
|
40
|
+
* **LRU eviction contract (D3(b)):** when a 65th distinct `n` is passed,
|
|
41
|
+
* the least-recently-used cached view is evicted and its keepalive is
|
|
42
|
+
* disposed. External holders of the evicted node will NOT receive further
|
|
43
|
+
* updates — re-call `tail(n)` for a fresh node, or dispose proactively
|
|
44
|
+
* via {@link disposeTail} / {@link disposeAllViews}. To avoid surprise:
|
|
45
|
+
* resolve `tail(n)` at the point of use rather than caching the returned
|
|
46
|
+
* node across many distinct `n`s.
|
|
47
|
+
*/
|
|
48
|
+
tail: (n: number) => Node<readonly T[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Reactive view of `entries.slice(start, stop)` — non-negative integer
|
|
51
|
+
* `start`, non-negative integer `stop` (exclusive) or `undefined` (to end).
|
|
52
|
+
* Memoized with an LRU cache (default cap 64) — repeat calls with the
|
|
53
|
+
* same `(start, stop)` return the same node.
|
|
54
|
+
*
|
|
55
|
+
* Throws on non-integer `start`, negative `start`, non-integer `stop`, or
|
|
56
|
+
* negative `stop` (P4 — the backend cannot cheaply honor JS-style
|
|
57
|
+
* negative `stop` without scanning length; disallowed for a consistent
|
|
58
|
+
* contract between backend, derived recomputation, and cached initial).
|
|
59
|
+
*
|
|
60
|
+
* **LRU eviction contract (D3(b)):** same as {@link tail} — past 64
|
|
61
|
+
* distinct `(start, stop)` pairs, the oldest cached view is evicted and
|
|
62
|
+
* its keepalive disposed. External holders stop receiving updates.
|
|
63
|
+
*/
|
|
64
|
+
slice: (start: number, stop?: number) => Node<readonly T[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Releases the cached `tail(n)` view if present (disposes its keepalive
|
|
67
|
+
* subscription). Subsequent `tail(n)` calls create a fresh node. No-op if
|
|
68
|
+
* `n` was not cached. Returns `true` if a view was disposed.
|
|
69
|
+
*/
|
|
70
|
+
disposeTail: (n: number) => boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Releases the cached `slice(start, stop?)` view if present. No-op if not cached.
|
|
73
|
+
*/
|
|
74
|
+
disposeSlice: (start: number, stop?: number) => boolean;
|
|
75
|
+
/** Releases all cached tail/slice views and their keepalive subscriptions. */
|
|
76
|
+
disposeAllViews: () => void;
|
|
77
|
+
/**
|
|
78
|
+
* Releases all internal keepalive subscriptions so the bundle can be
|
|
79
|
+
* GC'd — currently equivalent to {@link disposeAllViews}, but exposed as
|
|
80
|
+
* a uniform API across all reactive data structures for lifecycle
|
|
81
|
+
* symmetry (mirrors `reactiveMap.dispose` / `reactiveList.dispose` /
|
|
82
|
+
* `reactiveIndex.dispose`). Idempotent. D6(a).
|
|
83
|
+
*/
|
|
84
|
+
dispose: () => void;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Storage contract for {@link reactiveLog}. Implementations own the mutable state and
|
|
88
|
+
* expose a monotonic `version` counter that increments on every structural change.
|
|
89
|
+
*
|
|
90
|
+
* The reactive layer reads `version` to decide when to emit; it does not inspect
|
|
91
|
+
* internal representation. Users can plug in persistent / ring-buffer / skip-list
|
|
92
|
+
* backends without touching the reactive emission logic.
|
|
93
|
+
*
|
|
94
|
+
* @remarks Post-1.0 op-log changesets will extend this interface with a
|
|
95
|
+
* `changesSince(version: number): Iterable<Change>` method. Current consumers
|
|
96
|
+
* should treat all methods here as stable.
|
|
97
|
+
*
|
|
98
|
+
* @category extra
|
|
99
|
+
*/
|
|
100
|
+
interface LogBackend<T> {
|
|
101
|
+
/** Monotonic mutation counter; increments on every append/trim/clear that changes state. */
|
|
102
|
+
readonly version: number;
|
|
103
|
+
/** Number of entries currently stored. */
|
|
104
|
+
readonly size: number;
|
|
105
|
+
/** O(1) positional access; returns `undefined` on out-of-range. */
|
|
106
|
+
at(index: number): T | undefined;
|
|
107
|
+
/** Append a value. Applies `maxSize` head-drop if configured. Advances `version`. */
|
|
108
|
+
append(value: T): void;
|
|
109
|
+
/** Append a batch; advances `version` once. No-op if `values.length === 0`. */
|
|
110
|
+
appendMany(values: readonly T[]): void;
|
|
111
|
+
/** Remove all entries. Returns count removed. Advances `version` only if non-zero. */
|
|
112
|
+
clear(): number;
|
|
113
|
+
/** Remove the first `n` entries (clamped). Returns count removed. Throws on negative `n`. */
|
|
114
|
+
trimHead(n: number): number;
|
|
115
|
+
/** Fresh snapshot array for `[start, stop)`. Throws on negative `start`. */
|
|
116
|
+
slice(start: number, stop?: number): readonly T[];
|
|
117
|
+
/** Last `n` entries as a fresh array. Throws on negative `n`. */
|
|
118
|
+
tail(n: number): readonly T[];
|
|
119
|
+
/** Full snapshot as a fresh array. */
|
|
120
|
+
toArray(): readonly T[];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Default append-only log backend.
|
|
124
|
+
*
|
|
125
|
+
* - When `maxSize` is set: uses a **ring buffer** with `_head` index and circular
|
|
126
|
+
* modular arithmetic. Append and trim become O(1); snapshot is O(size) unrolling.
|
|
127
|
+
* - When `maxSize` is unset: uses a flat array with standard push/splice.
|
|
128
|
+
*
|
|
129
|
+
* `appendMany` pre-trims oversize input: if `values.length > maxSize`, only the
|
|
130
|
+
* tail of `values` is pushed (the rest would be immediately evicted).
|
|
131
|
+
*
|
|
132
|
+
* @category extra
|
|
133
|
+
*/
|
|
134
|
+
declare class NativeLogBackend<T> implements LogBackend<T> {
|
|
135
|
+
private _version;
|
|
136
|
+
private readonly _maxSize?;
|
|
137
|
+
private readonly _buf;
|
|
138
|
+
private _head;
|
|
139
|
+
private _size;
|
|
140
|
+
constructor(initial?: readonly T[], maxSize?: number);
|
|
141
|
+
get version(): number;
|
|
142
|
+
get size(): number;
|
|
143
|
+
at(index: number): T | undefined;
|
|
144
|
+
append(value: T): void;
|
|
145
|
+
appendMany(values: readonly T[]): void;
|
|
146
|
+
clear(): number;
|
|
147
|
+
trimHead(n: number): number;
|
|
148
|
+
slice(start: number, stop?: number): readonly T[];
|
|
149
|
+
tail(n: number): readonly T[];
|
|
150
|
+
toArray(): readonly T[];
|
|
151
|
+
/** Internal append without version bump — used by `appendMany`. */
|
|
152
|
+
private _rawAppend;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Creates an append-only reactive log with immutable array snapshots.
|
|
156
|
+
*
|
|
157
|
+
* @param initial - Optional seed entries (copied; pre-trimmed to `maxSize` if set).
|
|
158
|
+
* @param options - `name`, `maxSize`, and optional pluggable `backend`.
|
|
159
|
+
* @returns Bundle with `entries` (state node), `append`/`appendMany`/`clear`/`trimHead`,
|
|
160
|
+
* `size` / `at`, and memoized derived views `tail(n)` / `slice(start, stop?)`.
|
|
161
|
+
*
|
|
162
|
+
* @remarks
|
|
163
|
+
* **Backend:** The default {@link NativeLogBackend} uses a ring buffer when `maxSize`
|
|
164
|
+
* is set (O(1) append + trim) and a flat array otherwise. For persistent/structural-
|
|
165
|
+
* sharing semantics plug in a custom {@link LogBackend}.
|
|
166
|
+
*
|
|
167
|
+
* **`initial` + custom `backend` (F5):** When you supply `options.backend`, the
|
|
168
|
+
* `initial` argument is IGNORED — seed the backend yourself before passing it in.
|
|
169
|
+
* The `initial` seed only applies to the default `NativeLogBackend`.
|
|
170
|
+
*
|
|
171
|
+
* **Memoized views:** {@link ReactiveLogBundle.tail} and {@link ReactiveLogBundle.slice}
|
|
172
|
+
* cache derived nodes per-argument. Repeat calls with the same `n` / `(start, stop)`
|
|
173
|
+
* return the same node, bounding keepalive-subscription count to one per unique argument.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* import { reactiveLog } from "@graphrefly/graphrefly-ts";
|
|
178
|
+
*
|
|
179
|
+
* const lg = reactiveLog<number>([1, 2], { name: "audit", maxSize: 100 });
|
|
180
|
+
* lg.append(3);
|
|
181
|
+
* lg.entries.subscribe((msgs) => console.log(msgs));
|
|
182
|
+
* const last5 = lg.tail(5); // derived node
|
|
183
|
+
* const window = lg.slice(10, 20); // derived node
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* @category extra
|
|
187
|
+
*/
|
|
188
|
+
declare function reactiveLog<T>(initial?: readonly T[], options?: ReactiveLogOptions<T>): ReactiveLogBundle<T>;
|
|
189
|
+
|
|
190
|
+
export { type LogBackend as L, NativeLogBackend as N, type ReactiveLogBundle as R, type ReactiveLogOptions as a, reactiveLog as r };
|