@graphrefly/graphrefly 0.37.0 → 0.39.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/budget-gate-CmmVtasH.d.ts +115 -0
- package/dist/budget-gate-DiP_nK0n.d.cts +115 -0
- package/dist/{cascading-BsJ4GbnS.d.ts → cascading-BzuxW0_w.d.cts} +2 -2
- package/dist/{cascading-B25wxpRa.d.cts → cascading-g2_rhhaM.d.ts} +2 -2
- package/dist/chunk-35JTVPOX.js +1 -0
- package/dist/chunk-3G5U5QNE.js +5 -0
- package/dist/chunk-4I45FVQS.js +1 -0
- package/dist/chunk-5LK7XMEV.js +1 -0
- package/dist/chunk-5XRI6RM3.js +1 -0
- package/dist/chunk-73PBQNST.js +1 -0
- package/dist/chunk-7JRF5YEK.js +3 -0
- package/dist/{chunk-YVYSO5CW.js → chunk-7NZMZJMW.js} +1 -1
- package/dist/chunk-7QFRK3N3.js +84 -0
- package/dist/{chunk-K6ZFJ473.js → chunk-7SD73DS6.js} +1 -1
- package/dist/{chunk-LOQRPP4Y.js → chunk-A6ZSKGUG.js} +1 -1
- package/dist/{chunk-KUVDFOJH.js → chunk-AU7YTQX7.js} +1 -1
- package/dist/chunk-C72GO4IZ.js +1 -0
- package/dist/{chunk-Q7EUZ6NN.js → chunk-CGDMTXSY.js} +1 -1
- package/dist/chunk-D27JNOLZ.js +1 -0
- package/dist/chunk-D47YVDR5.js +1 -0
- package/dist/chunk-EWF7KCDJ.js +61 -0
- package/dist/{chunk-PCD2MU7X.js → chunk-GEAO3TL3.js} +1 -1
- package/dist/chunk-GX5LSSRE.js +1 -0
- package/dist/{chunk-2C4NESZE.js → chunk-HAWKGIXM.js} +1 -1
- package/dist/chunk-HX3EGQ5Z.js +1 -0
- package/dist/{chunk-MQZWA3DF.js → chunk-IA7DUNGB.js} +1 -1
- package/dist/{chunk-MYFR67PY.js → chunk-INH6FS2G.js} +2 -2
- package/dist/chunk-INHC33EH.js +1 -0
- package/dist/chunk-IUB4NYI2.js +1 -0
- package/dist/{chunk-TFK4P4CX.js → chunk-JNMC2WJ6.js} +1 -1
- package/dist/{chunk-TLS7M7H4.js → chunk-KD4NHLMU.js} +1 -1
- package/dist/chunk-L6NSJVJZ.js +1 -0
- package/dist/chunk-L7WY6TZS.js +1 -0
- package/dist/chunk-LQNOXGET.js +1 -0
- package/dist/chunk-MC4UYY2X.js +1 -0
- package/dist/{chunk-U3COB5WU.js → chunk-N7UIBZCW.js} +1 -1
- package/dist/chunk-NQI2C36M.js +1 -0
- package/dist/chunk-R75BMDLA.js +1 -0
- package/dist/chunk-RF3QZP6D.js +1 -0
- package/dist/{chunk-MC5LZG3U.js → chunk-S2U57TFC.js} +1 -1
- package/dist/{chunk-QP5TH523.js → chunk-SC7BQDNP.js} +1 -1
- package/dist/{chunk-5CPPC75H.js → chunk-TFPZLQ5H.js} +1 -1
- package/dist/chunk-VJJLIEAL.js +1 -0
- package/dist/chunk-WHIZM6JV.js +1 -0
- package/dist/chunk-XEUANKBO.js +43 -0
- package/dist/chunk-XQ55HO5N.js +1 -0
- package/dist/chunk-ZJ7SM3G2.js +1 -0
- package/dist/{chunk-T4U24DXX.js → chunk-ZOX3LBRV.js} +1 -1
- package/dist/compat/index.cjs +9 -13
- package/dist/compat/index.d.cts +16 -16
- package/dist/compat/index.d.ts +16 -16
- package/dist/compat/index.js +1 -1
- package/dist/compat/jotai/index.d.cts +2 -2
- package/dist/compat/jotai/index.d.ts +2 -2
- package/dist/compat/nanostores/index.d.cts +2 -2
- package/dist/compat/nanostores/index.d.ts +2 -2
- package/dist/compat/nestjs/index.cjs +8 -12
- package/dist/compat/nestjs/index.d.cts +8 -8
- package/dist/compat/nestjs/index.d.ts +8 -8
- package/dist/compat/nestjs/index.js +1 -1
- package/dist/compat/react/index.d.cts +2 -2
- package/dist/compat/react/index.d.ts +2 -2
- package/dist/compat/solid/index.d.cts +2 -2
- package/dist/compat/solid/index.d.ts +2 -2
- package/dist/compat/svelte/index.d.cts +2 -2
- package/dist/compat/svelte/index.d.ts +2 -2
- package/dist/compat/vue/index.d.cts +2 -2
- package/dist/compat/vue/index.d.ts +2 -2
- package/dist/compat/zustand/index.cjs +3 -7
- package/dist/compat/zustand/index.d.cts +4 -4
- package/dist/compat/zustand/index.d.ts +4 -4
- package/dist/compat/zustand/index.js +1 -1
- package/dist/{composite-_XckYx2e.d.cts → composite-CKd0e2vz.d.cts} +10 -3
- package/dist/{composite-CT_mApQD.d.ts → composite-DGatA-JK.d.ts} +10 -3
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +1 -1
- package/dist/extra/browser.d.cts +1 -1
- package/dist/extra/browser.d.ts +1 -1
- package/dist/extra/index.cjs +17 -21
- package/dist/extra/index.d.cts +11 -9
- package/dist/extra/index.d.ts +11 -9
- package/dist/extra/index.js +1 -1
- package/dist/extra/node.cjs +2 -2
- package/dist/extra/node.d.cts +108 -2
- package/dist/extra/node.d.ts +108 -2
- package/dist/extra/node.js +2 -2
- package/dist/extra/operators.cjs +1 -1
- package/dist/extra/operators.d.cts +1 -1
- package/dist/extra/operators.d.ts +1 -1
- package/dist/extra/operators.js +1 -1
- package/dist/extra/reactive.cjs +1 -1
- package/dist/extra/reactive.d.cts +3 -3
- package/dist/extra/reactive.d.ts +3 -3
- package/dist/extra/reactive.js +1 -1
- package/dist/extra/render/index.cjs +5 -0
- package/dist/extra/render/index.d.cts +183 -0
- package/dist/extra/render/index.d.ts +183 -0
- package/dist/extra/render/index.js +1 -0
- package/dist/extra/sources.cjs +1 -1
- package/dist/extra/sources.d.cts +1 -1
- package/dist/extra/sources.d.ts +1 -1
- package/dist/extra/sources.js +1 -1
- package/dist/extra/storage-browser.d.cts +1 -1
- package/dist/extra/storage-browser.d.ts +1 -1
- package/dist/extra/storage-tiers-browser.d.cts +76 -5
- package/dist/extra/storage-tiers-browser.d.ts +76 -5
- package/dist/extra/storage-tiers-node.d.cts +137 -13
- package/dist/extra/storage-tiers-node.d.ts +137 -13
- package/dist/extra/storage-tiers.d.cts +151 -23
- package/dist/extra/storage-tiers.d.ts +151 -23
- package/dist/{fallback-axI2cXwt.d.cts → fallback-8JYU8tlT.d.cts} +1 -1
- package/dist/{fallback-DuEXfA4F.d.ts → fallback-CMZl39L5.d.ts} +1 -1
- package/dist/graph/index.cjs +7 -7
- package/dist/graph/index.d.cts +5 -5
- package/dist/graph/index.d.ts +5 -5
- package/dist/graph/index.js +1 -1
- package/dist/{graph-YQXDndFy.d.ts → graph-30XSgtVX.d.ts} +287 -104
- package/dist/{graph-CaNXUc3c.d.cts → graph-BUwMAxJI.d.cts} +287 -104
- package/dist/{index-CIcu6fIR.d.ts → index-2n8Eai6M.d.ts} +1 -1
- package/dist/{index-BmLkcDlj.d.ts → index-89FczVZ_.d.ts} +47 -71
- package/dist/{index-Ci358GSC.d.cts → index-8R1vzNOx.d.cts} +9 -9
- package/dist/{index-CDvC1m5p.d.ts → index-B2RUoIUz.d.ts} +1 -1
- package/dist/{index-DuhOdNyg.d.ts → index-B41Asm7D.d.ts} +10 -8
- package/dist/{index-CKcnuQ2c.d.ts → index-B9fmw5n2.d.ts} +4 -6
- package/dist/{index-0qOD-421.d.ts → index-BAlaVimV.d.ts} +9 -9
- package/dist/{index-Ae6L8liv.d.ts → index-BC9VybQs.d.ts} +41 -48
- package/dist/{index-CUTHDZ7Q.d.ts → index-BEHmxORq.d.ts} +11 -11
- package/dist/{index-C_qi0WlF.d.cts → index-BJ26eEjs.d.cts} +26 -19
- package/dist/{index-BiomL7AW.d.ts → index-BJSZxSFX.d.ts} +1 -1
- package/dist/{index-DCAuN9u5.d.cts → index-BKMdnYnk.d.ts} +75 -39
- package/dist/{index-DfAo9WKr.d.ts → index-BM9szD8n.d.cts} +14 -6
- package/dist/{index-CajEOoAN.d.ts → index-BUPVld1w.d.ts} +2 -2
- package/dist/{index-C-pFD_FV.d.ts → index-BXd6OMEy.d.ts} +3 -3
- package/dist/index-BhUaMYm_.d.ts +113 -0
- package/dist/{index-DAKm44My.d.cts → index-BndG0cpK.d.cts} +3 -3
- package/dist/{index-Bpzw8hx3.d.ts → index-Br3WnqEn.d.ts} +84 -9
- package/dist/{index-D6tRNEKz.d.cts → index-BskfDoZ_.d.ts} +14 -6
- package/dist/{index-9mbs_PIG.d.ts → index-C19qqa38.d.ts} +4 -4
- package/dist/{index-fHKHdAso.d.ts → index-C7VV_qOs.d.ts} +4 -4
- package/dist/{index-CLPQyYY5.d.cts → index-CIRG8Hxp.d.cts} +11 -11
- package/dist/{index-B3D_z0Z6.d.cts → index-CL7oilfm.d.cts} +1 -1
- package/dist/{index-BOfHwQc1.d.ts → index-CPhBvRJU.d.ts} +1 -1
- package/dist/{index-B9qJmmv3.d.cts → index-CWHtYmSh.d.cts} +1 -1
- package/dist/{index-D_d1erkR.d.ts → index-Cey6VTnX.d.ts} +8 -5
- package/dist/{resilience-BWP2c7Af.d.cts → index-CmqiJZKM.d.ts} +141 -23
- package/dist/{index-JYtN9uqM.d.ts → index-CoM4rzyB.d.ts} +1 -1
- package/dist/{index-DTYIRT_v.d.cts → index-CpLpJb6A.d.cts} +8 -5
- package/dist/{index-BjWZARLy.d.ts → index-Ctb7_2sG.d.ts} +1 -1
- package/dist/index-CusEP3Sv.d.ts +210 -0
- package/dist/{resilience-Bys63Cpd.d.ts → index-CwP_KAMS.d.cts} +141 -23
- package/dist/{index-BFuVcqL8.d.cts → index-D3ayz3hy.d.cts} +1 -1
- package/dist/{index-CrpjECS6.d.cts → index-DCbE8fFM.d.cts} +3 -3
- package/dist/{index-D_DThl_J.d.cts → index-DIHcMLr6.d.cts} +1 -1
- package/dist/index-DINuaZlJ.d.cts +210 -0
- package/dist/{index-9xhIaM-w.d.cts → index-DOBLxOti.d.cts} +1 -1
- package/dist/index-DQUVq1_d.d.ts +374 -0
- package/dist/{index-B1IcU--K.d.cts → index-DTtBpuQy.d.cts} +4 -6
- package/dist/{index-D_QQ_dTD.d.cts → index-DYTBbF8T.d.cts} +1 -1
- package/dist/{index-DqtXA3yX.d.cts → index-DlgHqQxW.d.cts} +84 -9
- package/dist/{index-D1E1tqHT.d.ts → index-DlrWu9Hs.d.cts} +75 -39
- package/dist/{index-DcWbx58m.d.cts → index-DoYc8BWK.d.cts} +41 -48
- package/dist/{index-D0ZxFXYl.d.ts → index-DszPlZzK.d.ts} +3 -3
- package/dist/{index-BECJ8M0T.d.cts → index-DyM4tFAe.d.cts} +10 -8
- package/dist/{index-D11pGlaI.d.cts → index-FVoPvhAu.d.cts} +4 -4
- package/dist/{index-BwtIbzSV.d.cts → index-H_I66pav.d.cts} +2 -2
- package/dist/{index-e1m3ZHgc.d.cts → index-IwFqHxCs.d.cts} +2 -2
- package/dist/index-K-vl_c6A.d.cts +113 -0
- package/dist/{index-C4N-dg5U.d.cts → index-KlZ_ZUip.d.cts} +2 -2
- package/dist/index-L8XI8Zql.d.cts +374 -0
- package/dist/{index-D8IyqHvT.d.cts → index-MxYuWOrf.d.cts} +6 -4
- package/dist/{index-CpZKtdMw.d.cts → index-PgwvGWa1.d.cts} +1 -1
- package/dist/{index-B46GWgk3.d.ts → index-PlJ3MraE.d.ts} +1 -1
- package/dist/{index-DPqR3wdW.d.ts → index-PqbnoScQ.d.ts} +3 -3
- package/dist/{index-CU3z8Cel.d.cts → index-PsVHpPwP.d.cts} +3 -3
- package/dist/{index-C0tga1_x.d.ts → index-WyFKER-c.d.ts} +2 -2
- package/dist/{index-B5UR87KG.d.ts → index-eaQuGJnv.d.ts} +6 -4
- package/dist/{index-CzIWlnPp.d.ts → index-iTX5IqSP.d.ts} +140 -9
- package/dist/{index-CRycrNfn.d.ts → index-jKLph6cu.d.ts} +2 -2
- package/dist/{index-BhLA9feT.d.ts → index-jr6PuSBt.d.ts} +26 -19
- package/dist/{index-4IwO4mH2.d.cts → index-mNwgxC21.d.cts} +140 -9
- package/dist/{index-CkN8CZlT.d.cts → index-pVDQcbar.d.cts} +47 -71
- package/dist/{index-D6pwWiOc.d.cts → index-xZYcDqFH.d.cts} +4 -4
- package/dist/{index-8OxXae3g.d.ts → index-yLt-aPMp.d.ts} +1 -1
- package/dist/{index-CqSJ25A9.d.cts → index-z8WFPVI8.d.cts} +1 -1
- package/dist/index.cjs +64 -60
- package/dist/index.d.cts +48 -47
- package/dist/index.d.ts +48 -47
- package/dist/index.js +1 -1
- package/dist/meta-Ct9nqQS5.d.cts +102 -0
- package/dist/meta-D8OyedKp.d.ts +102 -0
- package/dist/{node-fSc-hCv8.d.cts → node-BYInONRr.d.cts} +3 -3
- package/dist/{node-fSc-hCv8.d.ts → node-BYInONRr.d.ts} +3 -3
- package/dist/{observable-Cqty11jG.d.cts → observable-DMIlYJV1.d.cts} +1 -1
- package/dist/{observable-EAV_rNfM.d.ts → observable-DO8DDEzv.d.ts} +1 -1
- package/dist/patterns/ai/browser.cjs +5 -5
- package/dist/patterns/ai/browser.d.cts +4 -4
- package/dist/patterns/ai/browser.d.ts +4 -4
- package/dist/patterns/ai/browser.js +1 -1
- package/dist/patterns/ai/index.cjs +17 -21
- package/dist/patterns/ai/index.d.cts +17 -17
- package/dist/patterns/ai/index.d.ts +17 -17
- package/dist/patterns/ai/index.js +1 -1
- package/dist/patterns/ai/node.cjs +1 -1
- package/dist/patterns/ai/node.d.cts +4 -4
- package/dist/patterns/ai/node.d.ts +4 -4
- package/dist/patterns/ai/node.js +1 -1
- package/dist/patterns/audit/index.cjs +3 -7
- package/dist/patterns/audit/index.d.cts +6 -6
- package/dist/patterns/audit/index.d.ts +6 -6
- package/dist/patterns/audit/index.js +1 -1
- package/dist/patterns/cqrs/index.cjs +3 -7
- package/dist/patterns/cqrs/index.d.cts +6 -6
- package/dist/patterns/cqrs/index.d.ts +6 -6
- package/dist/patterns/cqrs/index.js +1 -1
- package/dist/patterns/demo-shell/index.cjs +5 -8
- package/dist/patterns/demo-shell/index.d.cts +5 -5
- package/dist/patterns/demo-shell/index.d.ts +5 -5
- package/dist/patterns/demo-shell/index.js +1 -1
- package/dist/patterns/domain-templates/index.cjs +3 -7
- package/dist/patterns/domain-templates/index.d.cts +4 -4
- package/dist/patterns/domain-templates/index.d.ts +4 -4
- package/dist/patterns/domain-templates/index.js +1 -1
- package/dist/patterns/graphspec/index.cjs +38 -38
- package/dist/patterns/graphspec/index.d.cts +5 -5
- package/dist/patterns/graphspec/index.d.ts +5 -5
- package/dist/patterns/graphspec/index.js +1 -1
- package/dist/patterns/guarded-execution/index.cjs +3 -7
- package/dist/patterns/guarded-execution/index.d.cts +7 -7
- package/dist/patterns/guarded-execution/index.d.ts +7 -7
- package/dist/patterns/guarded-execution/index.js +1 -1
- package/dist/patterns/harness/index.cjs +8 -12
- package/dist/patterns/harness/index.d.cts +12 -12
- package/dist/patterns/harness/index.d.ts +12 -12
- package/dist/patterns/harness/index.js +1 -1
- package/dist/patterns/job-queue/index.cjs +3 -7
- package/dist/patterns/job-queue/index.d.cts +6 -6
- package/dist/patterns/job-queue/index.d.ts +6 -6
- package/dist/patterns/job-queue/index.js +1 -1
- package/dist/patterns/lens/index.cjs +3 -7
- package/dist/patterns/lens/index.d.cts +6 -6
- package/dist/patterns/lens/index.d.ts +6 -6
- package/dist/patterns/lens/index.js +1 -1
- package/dist/patterns/memory/index.cjs +3 -7
- package/dist/patterns/memory/index.d.cts +7 -5
- package/dist/patterns/memory/index.d.ts +7 -5
- package/dist/patterns/memory/index.js +1 -1
- package/dist/patterns/messaging/index.cjs +3 -7
- package/dist/patterns/messaging/index.d.cts +5 -5
- package/dist/patterns/messaging/index.d.ts +5 -5
- package/dist/patterns/messaging/index.js +1 -1
- package/dist/patterns/orchestration/index.cjs +3 -7
- package/dist/patterns/orchestration/index.d.cts +8 -8
- package/dist/patterns/orchestration/index.d.ts +8 -8
- package/dist/patterns/orchestration/index.js +1 -1
- package/dist/patterns/process/index.cjs +1 -1
- package/dist/patterns/process/index.d.cts +7 -7
- package/dist/patterns/process/index.d.ts +7 -7
- package/dist/patterns/process/index.js +1 -1
- package/dist/patterns/reactive-layout/index.cjs +4 -8
- package/dist/patterns/reactive-layout/index.d.cts +5 -5
- package/dist/patterns/reactive-layout/index.d.ts +5 -5
- package/dist/patterns/reactive-layout/index.js +1 -1
- package/dist/patterns/reduction/index.cjs +3 -7
- package/dist/patterns/reduction/index.d.cts +4 -4
- package/dist/patterns/reduction/index.d.ts +4 -4
- package/dist/patterns/reduction/index.js +1 -1
- package/dist/patterns/refine-loop/index.cjs +5 -9
- package/dist/patterns/refine-loop/index.d.cts +6 -6
- package/dist/patterns/refine-loop/index.d.ts +6 -6
- package/dist/patterns/refine-loop/index.js +1 -1
- package/dist/patterns/resilient-pipeline/index.cjs +1 -1
- package/dist/patterns/resilient-pipeline/index.d.cts +4 -8
- package/dist/patterns/resilient-pipeline/index.d.ts +4 -8
- package/dist/patterns/resilient-pipeline/index.js +1 -1
- package/dist/patterns/surface/index.cjs +13 -17
- package/dist/patterns/surface/index.d.cts +6 -6
- package/dist/patterns/surface/index.d.ts +6 -6
- package/dist/patterns/surface/index.js +1 -1
- package/dist/{pipeline-graph-BrrYGjuZ.d.cts → pipeline-graph-BQPr2Lqs.d.cts} +34 -17
- package/dist/{pipeline-graph-DX2Twdj-.d.ts → pipeline-graph-D8vKcO_p.d.ts} +34 -17
- package/dist/{reactive-layout-DrGjuwyC.d.cts → reactive-layout-8CSc0tiA.d.cts} +2 -2
- package/dist/{reactive-layout-BDdngW56.d.ts → reactive-layout-DkTXxtSy.d.ts} +2 -2
- package/dist/{reactive-log-jirQsxMY.d.ts → reactive-log-BlAsPLl2.d.ts} +30 -3
- package/dist/{reactive-log-ScpWyqny.d.cts → reactive-log-_zeEnB9H.d.cts} +30 -3
- package/dist/{reactive-map-DmgeADH8.d.cts → reactive-map-B2qfD3hb.d.cts} +1 -1
- package/dist/{reactive-map-CHyeCf4D.d.ts → reactive-map-jFIsE6Kt.d.ts} +1 -1
- package/dist/resilience-HTF2LBRS.js +1 -0
- package/dist/{sugar-D13E2M_z.d.ts → sugar-BhfjgetH.d.ts} +1 -1
- package/dist/{sugar-DgaGJcI6.d.cts → sugar-DzePN5-g.d.cts} +1 -1
- package/dist/{topology-tree-BkhmMg2a.d.cts → topology-tree-B5Ngw3j0.d.cts} +1 -1
- package/dist/{topology-tree-BI665P0L.d.ts → topology-tree-BtvbgMXJ.d.ts} +1 -1
- package/dist/{types-BMSGPlpO.d.cts → types-1Dhoi7HM.d.cts} +1 -1
- package/dist/{types-CidcBDuk.d.ts → types-39jk0kaV.d.ts} +1 -1
- package/package.json +11 -1
- package/dist/chunk-4EATTNAE.js +0 -1
- package/dist/chunk-533RQFF6.js +0 -1
- package/dist/chunk-6SVKZ7VI.js +0 -1
- package/dist/chunk-A5HZZYRK.js +0 -1
- package/dist/chunk-B4L5X2QO.js +0 -7
- package/dist/chunk-C5CBVOCB.js +0 -1
- package/dist/chunk-CZIQ6JCE.js +0 -1
- package/dist/chunk-FJ6IEMOS.js +0 -1
- package/dist/chunk-FMI4CWFL.js +0 -1
- package/dist/chunk-G6Q3DUMJ.js +0 -1
- package/dist/chunk-GDDPCDLG.js +0 -1
- package/dist/chunk-GFOT6UBB.js +0 -1
- package/dist/chunk-JJTF75VS.js +0 -1
- package/dist/chunk-K2WYIVHM.js +0 -1
- package/dist/chunk-KTWBUJO5.js +0 -61
- package/dist/chunk-M27MVZCP.js +0 -1
- package/dist/chunk-NKKUUKPD.js +0 -43
- package/dist/chunk-O32GJOUJ.js +0 -1
- package/dist/chunk-QKBCTKH7.js +0 -1
- package/dist/chunk-QWVQIL3T.js +0 -1
- package/dist/chunk-UODQF4EY.js +0 -1
- package/dist/chunk-WGST56ZH.js +0 -80
- package/dist/chunk-WSLN4JFO.js +0 -1
- package/dist/chunk-XIJKEXWR.js +0 -1
- package/dist/imperative-audit-ahAE65a9.d.cts +0 -28
- package/dist/imperative-audit-ahAE65a9.d.ts +0 -28
- package/dist/index-BCq12BqB.d.ts +0 -139
- package/dist/index-BokynmA4.d.cts +0 -186
- package/dist/index-DXz9uwcs.d.ts +0 -186
- package/dist/index-DbWwMWiB.d.cts +0 -139
- package/dist/meta-BGO6C7K9.d.cts +0 -41
- package/dist/meta-CC6EPdpK.d.ts +0 -41
- package/dist/resilience-OBU472D2.js +0 -1
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
"use strict";var wt=Object.defineProperty;var Yn=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var Xn=Object.prototype.hasOwnProperty;var re=(t,e)=>()=>(t&&(e=t(t=0)),e);var Zn=(t,e)=>{for(var n in e)wt(t,n,{get:e[n],enumerable:!0})},Qn=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Jn(e))!Xn.call(t,s)&&s!==n&&wt(t,s,{get:()=>e[s],enumerable:!(r=Yn(e,s))||r.enumerable});return t};var er=t=>Qn(wt({},"__esModule",{value:!0}),t);function He(){return Ie>0||ze}function Ut(){return Ie>0}function je(t){Ie>0?Be.push(t):t()}function le(t){Ie+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(Ie-=1,Ie===0)if(e){if(!ze){let n=Be.splice(0);for(let r of n)try{r()}catch{}ke.length=0,Re.length=0,Le.length=0}}else tr()}}function tr(){let t=!ze;t&&(ze=!0);let e=[],n=0;try{for(;ke.length>0||Re.length>0||Le.length>0||t&&Be.length>0;){if(t&&Be.length>0){let o=Be.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw ke.length=0,Re.length=0,Le.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(ke.length>0?ke:Re.length>0?Re:Le).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{t&&(ze=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Ue(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!He()){t(e);return}(u>=5?Le:u===4?Re:ke).push(()=>t(e));return}let r=e.length,s=r,o=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(s=a;a<r&&n(e[a][0])===3;)a++;for(o=a;a<r&&n(e[a][0])===4;)a++;i=a;let d=He();if(s>0){let u=e.slice(0,s);t(u)}if(o>s){let u=e.slice(s,o);d?ke.push(()=>t(u)):t(u)}if(i>o){let u=e.slice(o,i);d?Re.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);d?Le.push(()=>t(u)):t(u)}}var Ie,ze,ke,Re,Le,Be,Pe=re(()=>{"use strict";Ie=0,ze=!1,ke=[],Re=[],Le=[],Be=[]});function oe(){return Math.trunc(performance.now()*1e6)}function Ze(){return Date.now()*1e6}var Qe=re(()=>{"use strict"});var fe,P,K,Y,se,de,pe,J,$,G,Se,et,Wt,tt,qt,Kt,nt,_t,xt,Nt,rt,he=re(()=>{"use strict";fe=Symbol.for("graphrefly/START"),P=Symbol.for("graphrefly/DATA"),K=Symbol.for("graphrefly/DIRTY"),Y=Symbol.for("graphrefly/RESOLVED"),se=Symbol.for("graphrefly/INVALIDATE"),de=Symbol.for("graphrefly/PAUSE"),pe=Symbol.for("graphrefly/RESUME"),J=Symbol.for("graphrefly/TEARDOWN"),$=Symbol.for("graphrefly/COMPLETE"),G=Symbol.for("graphrefly/ERROR"),Se=Object.freeze([K]),et=Object.freeze([Y]),Wt=Object.freeze([se]),tt=Object.freeze([fe]),qt=Object.freeze([$]),Kt=Object.freeze([J]),nt=Object.freeze([Se]),_t=Object.freeze([et]),xt=Object.freeze([Wt]),Nt=Object.freeze([qt]),rt=Object.freeze([Kt])});function Jt(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let s=2+n.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=Et,o[i++]=n.length,o.set(n,i),i+=n.length,o[i++]=r>>>8&255,o[i++]=r&255,o.set(e,i),o}function Xt(t,e){if(t.length<Yt)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${Yt})`);let n=0,r=t[n++];if(r!==Et)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${Et})`);let s=t[n++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+s+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+s+2} bytes, have ${t.length})`);let o=new TextDecoder().decode(t.subarray(n,n+s));n+=s;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),d=e.lookupCodec(o);if(d==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:d,codecVersion:i,payload:a}}function Zt(t){t.registerCodec(nr)}var nr,Et,Yt,Ot=re(()=>{"use strict";nr={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)}},Et=1,Yt=4});function ot(t){if(t==null)return $e;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var $e,st=re(()=>{"use strict";$e={type:"system",id:""}});function Qt(t){t.registerMessageType(fe,{tier:0,wireCrossing:!1}),t.registerMessageType(K,{tier:1,wireCrossing:!1}),t.registerMessageType(se,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(de,{tier:2,wireCrossing:!1}),t.registerMessageType(pe,{tier:2,wireCrossing:!1}),t.registerMessageType(P,{tier:3,wireCrossing:!0}),t.registerMessageType(Y,{tier:3,wireCrossing:!0}),t.registerMessageType($,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(G,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(J,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var it,en=re(()=>{"use strict";he();it=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function kt(t){let e=rr.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var ie,rr,We=re(()=>{"use strict";ie=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}},rr=["human","llm","wallet","system"]});function Rt(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(Rt);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=Rt(t[n]);return e}return null}function ir(t){let e=sr.encode(t),n=e.length,r=n*8,s=n+9+63&-64,o=new Uint8Array(s);o.set(e),o[n]=128;let i=new DataView(o.buffer);i.setUint32(s-4,r>>>0,!1),i.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,d=3144134277,u=1013904242,l=2773480762,f=1359893119,h=2600822924,p=528734635,c=1541459225,b=new Uint32Array(64),x=(T,g)=>T>>>g|T<<32-g;for(let T=0;T<s;T+=64){for(let O=0;O<16;O++)b[O]=i.getUint32(T+O*4,!1);for(let O=16;O<64;O++){let k=b[O-15],S=b[O-2],C=x(k,7)^x(k,18)^k>>>3,U=x(S,17)^x(S,19)^S>>>10;b[O]=b[O-16]+C+b[O-7]+U>>>0}let g=a,v=d,E=u,w=l,m=f,y=h,_=p,R=c;for(let O=0;O<64;O++){let k=x(m,6)^x(m,11)^x(m,25),S=m&y^~m&_,C=R+k+S+or[O]+b[O]>>>0,U=x(g,2)^x(g,13)^x(g,22),B=g&v^g&E^v&E,ue=U+B>>>0;R=_,_=y,y=m,m=w+C>>>0,w=E,E=v,v=g,g=C+ue>>>0}a=a+g>>>0,d=d+v>>>0,u=u+E>>>0,l=l+w>>>0,f=f+m>>>0,h=h+y>>>0,p=p+_>>>0,c=c+R>>>0}let N=T=>T.toString(16).padStart(8,"0");return N(a)+N(d)+N(u)+N(l)+N(f)+N(h)+N(p)+N(c)}function St(t){let e=Rt(t??null),n=JSON.stringify(e);return ir(n).slice(0,16)}function ar(){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 Dt(t,e,n){let r=n?.id??ar();if(t===0)return{id:r,version:0};let o=(n?.hash??St)(e);return{id:r,version:0,cid:o,prev:null}}function tn(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var or,sr,nn=re(()=>{"use strict";or=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]),sr=new TextEncoder});function sn(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function At(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function at(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function te(t,e,n){let r=an(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,o={};return an(t)?o=(Ct(e)?e:n)??{}:Ct(t)?o=t:o=(Ct(e)?e:n)??{},new H(r,s,o)}var rn,on,ur,dr,Fe,H,an,Ct,me=re(()=>{"use strict";Ot();st();Pe();Qe();en();We();he();nn();rn=()=>{},on=100;ur=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},dr=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[tt]:[tt,[P,o]];s._status==="dirty"&&i.push(Se),Ue(e,i,s._config.tierOf)},Fe=new it({onMessage:ur,onSubscribe:dr});Qt(Fe);Zt(Fe);H=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??Fe,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??St;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?Dt(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(sn);let o={};for(let[a,d]of Object.entries(r.meta??{})){let u={initial:d,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),o[a]=new t([],void 0,u)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[P,a]])},down(a){i._emit(at(a))},up(a){i._emitUp(at(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let s=n?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,d=i?.version??0,u=Dt(e,o,{id:a,hash:s});u.version=d,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=ot(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let s=ot(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new ie({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new ie({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Ze()}}down(e,n){let r=at(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[P,e]])}up(e,n){if(this._deps.length===0)return;let r=at(e);if(r.length===0)return;this._checkGuard(n);let s=n??{internal:!0};this._validateUpTiers(r);for(let o of this._deps)o.node.up?.(r,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let s=n(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let d=ot(n);if(!this._guard(d,"observe"))throw new ie({actor:d,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 d of this._deps)At(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(d){throw this._sinkCount-=1,d}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(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let s=r,o=this._deps[r];o.unsub=rn,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,d=!1;for(let u of i)a(u[0])>=3&&(d=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:s},this._actions);d&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let s=0;s<n;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}At(o)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let n=this._deps.length,r=sn(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(nt),r.unsub=rn;try{r.unsub=e.subscribe(s=>{if(r.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[G,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[G,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{}}At(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],s=n[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(o)}if(s!==fe){if(s===K){this._depDirtied(r);return}if(s===se){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(xt);return}if(s===de||s===pe){this._emit([n]);return}if(s===J){this._emit(rt);return}if(s===P)this._depSettledAsData(r,n[1]);else if(s===Y)this._depSettledAsResolved(r);else if(s===$)this._depSettledAsTerminal(r,!0);else if(s===G)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===P||s===Y)&&this._emit([n]),(s===$||s===G)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(nt))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(_t),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([[G,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(Nt)}_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([[G,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([[G,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[G,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>on?(this._rerunDepth=0,this._emit([[G,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${on} \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"?[Se,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let d of e){let u=n(d[0]);u<i&&(r=!1),u===3&&(s=!0),d[0]===K&&(o=!0),i=u}let a=e;if(!r){let d=e.map((u,l)=>({m:u,i:l,tier:n(u[0])}));d.sort((u,l)=>u.tier-l.tier||u.i-l.i),a=d.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let d=0;for(;d<a.length&&n(a[d][0])===0;)d++;return d===0?[Se,...a]:[...a.slice(0,d),Se,...a.slice(d)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let d=e[a];if(d[0]===G&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(d=>d[0]===J||d[0]===se);if(a.length===0)return;n=a}n=this._frameBatch(n);let s=null;for(let a=0;a<n.length;a++){let d=n[a],u=d[0];if(u!==de&&u!==pe){s?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===de?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let l=!0;if(this._pausable!==!1){let f=d[1];if(u===de)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))l=!1;else if(this._pauseLocks.delete(f),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())}}l?s?.push(d):s==null&&(s=n.slice(0,a))}if(s!=null){if(s.length===0)return;n=s}if(this._hasMeta&&n.some(a=>a[0]===J))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(rt)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(n);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,d=[];for(let u of o)a(u[0])===3?this._pauseBuffer.push(u):d.push(u);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[G,i]])}_updateState(e){let n=this._config.tierOf,r,s,o=-1,i=0;for(let l of e)n(l[0])===3&&i++;let a=i<=1,d=-1;if(this._versioning!=null&&i>1){for(let l=e.length-1;l>=0;l--)if(e[l][0]===P){d=l;break}}for(let l=0;l<e.length;l++){let f=e[l],h=f[0];if(h===P){if(f.length>=2){let p=!1;if(a&&this._cached!==void 0)try{p=this._equals(this._cached,f[1])}catch(c){s=this._wrapFnError("equals threw",c),o=l;break}if(p){r==null&&(r=e.slice(0,l)),r.push(et),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(d<0||l===d)&&tn(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),h===K)this._status="dirty";else if(h===Y)this._status="resolved";else if(h===$){this._status="completed";{let p=this._config.rigorRecorder;if(p!=null)try{p.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(h===G){this._status="errored";{let p=this._config.rigorRecorder;if(p!=null)try{p.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(h===se){if(this._cached!==void 0){let c=this._config.rigorRecorder;if(c!=null)try{c.onNonVacuousInvalidate(this,this._cached)}catch{}}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 c=p.invalidate;if(typeof c=="function")try{c()}catch{}}}else h===J&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:u,equalsError:s}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(Ut()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],je(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}Ue(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);Ue(this._deliverToSinks,n,this._config.tierOf)}},an=t=>Array.isArray(t),Ct=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function z(t,e){return te([],{...e,initial:t})}function De(t,e){return te((r,s,o)=>t(s,o)??void 0,{describeKind:"producer",...e})}function F(t,e,n){return te(t,(s,o,i)=>{let a=s.map((d,u)=>d!=null&&d.length>0?d.at(-1):i.prevData[u]);o.emit(e(a,i))},{describeKind:"derived",...n})}function _e(t,e,n){return te(t,(s,o,i)=>{let a=s.map((d,u)=>d!=null&&d.length>0?d.at(-1):i.prevData[u]);return e(a,o,i)??void 0},{describeKind:"effect",...n})}var Ve=re(()=>{"use strict";me()});function Mt(t){return{describeKind:"producer",...t}}function un(t,e){return De(n=>{let r=!1;try{for(let s of t){if(r)return;n.emit(s)}r||n.down([[$]])}catch(s){r||n.down([[G,s]])}return()=>{r=!0}},Mt(e))}function lr(t){return t!=null&&typeof t.then=="function"}function cr(t,e){let{signal:n,...r}=e??{};return De(s=>{let o=!1,i=()=>{o||(o=!0,s.down([[G,n.reason]]))};if(n?.aborted){i();return}return n?.addEventListener("abort",i,{once:!0}),Promise.resolve(t).then(a=>{o||(o=!0,n?.removeEventListener("abort",i),s.emit(a),s.down([[$]]))},a=>{o||(o=!0,n?.removeEventListener("abort",i),s.down([[G,a]]))}),()=>{o=!0,n?.removeEventListener("abort",i)}},Mt(r))}function fr(t,e){let{signal:n,...r}=e??{};return De(s=>{let o=new AbortController,i=()=>o.abort(n?.reason);n?.aborted?o.abort(n.reason):n?.addEventListener("abort",i,{once:!0});let a=n??o.signal,d=!1,u=t[Symbol.asyncIterator](),l=()=>{d||a.aborted||Promise.resolve(u.next()).then(f=>{if(!(d||a.aborted)){if(f.done){s.down([[$]]);return}s.emit(f.value),l()}},f=>{!d&&!a.aborted&&s.down([[G,f]])})};return l(),()=>{d=!0,n?.removeEventListener("abort",i),o.abort(),Promise.resolve(u.return?.()).catch(()=>{})}},Mt(r))}function pr(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function dn(t,e){if(pr(t))return t;if(lr(t))return cr(t,e);if(t!=null){let n=t;if(typeof n[Symbol.asyncIterator]=="function")return fr(t,e);if(typeof n[Symbol.iterator]=="function")return un(t,e)}return hr(t)}function hr(...t){return un(t,void 0)}function ge(t){return t.subscribe(()=>{})}var ut=re(()=>{"use strict";he();Ve()});var lt,cn=re(()=>{"use strict";lt=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var wo={};Zn(wo,{blindVariation:()=>bo,errorCritique:()=>To,refineLoop:()=>go});module.exports=er(wo);Pe();Qe();he();me();Ve();he();me();ut();function mr(t){return{describeKind:"derived",...t}}function gr(t,e,n){let r,s=!1,o=()=>{s||(s=!0,n())};return r=t.subscribe(i=>{let a=!1,d=!1;for(let u of i)u[0]!==fe&&(u[0]===P?e.emit(u[1]):u[0]===$?a=!0:u[0]===G?(d=!0,e.down([u])):(u[0]===K||u[0]===Y)&&e.down([u]));d?(r?.(),r=void 0,o()):a&&o()}),()=>{r?.(),r=void 0}}function ln(t,e,n){let r,s=!1;function o(){r?.(),r=void 0}return te([t],(i,a,d)=>{if(d.terminalDeps[0]!=null&&d.terminalDeps[0]!==!0){o();return}if(d.terminalDeps[0]===!0){s=!0,r||a.down([[$]]);return}let u=i[0];if(!(u==null||u.length===0))return o(),r=gr(dn(e(u[u.length-1])),a,()=>{o(),s&&a.down([[$]])}),{deactivate:()=>{o(),s=!1}}},{...mr(n),completeWhenDepsComplete:!1})}st();Pe();Qe();We();he();We();me();function dt(t,e){if(e!=null&&e.length>0)return new Set(e);switch(t){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;default:return new Set(["type","deps"])}}function br(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function yr(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function Gt(t,e){let n=e==null,r=!n&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,s=n||e.has("meta")||r!=null&&r.length>0,o="state",i=[];t instanceof H&&(o=br(t),i=t._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(n||e.has("status"))&&(a.status=t.status);let d=t instanceof H?t._guard:void 0;if(s){let u={...yr(t)};if(d!=null&&u.access===void 0&&(u.access=kt(d)),r!=null&&r.length>0&&!e.has("meta")){let l={};for(let f of r)f in u&&(l[f]=u[f]);a.meta=l}else a.meta=u}if(t.name!=null&&(a.name=t.name),n||e.has("value")){t.status==="sentinel"&&(a.sentinel=!0);try{a.value=t.cache}catch{}}if((n||e.has("v"))&&t.v!=null){let u={id:t.v.id,version:t.v.version};"cid"in t.v&&(u.cid=t.v.cid,u.prev=t.v.prev),a.v=u}return(n||e.has("guard"))&&d!=null&&(a.guard=kt(d)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}me();Ve();ut();cn();var qe=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let n=(this.head+this._size)%this.capacity;this.buf[n]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let n=e<0?this._size+e:e;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this.buf[(this.head+n)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};Ot();function It(t){return t>=768&&t<=879||t>=1155&&t<=1161||t>=1425&&t<=1469||t>=1552&&t<=1562||t>=1611&&t<=1631||t>=1648&&t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t>=1767&&t<=1768||t>=1770&&t<=1773||t>=1840&&t<=1866||t>=1958&&t<=1968||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2641||t>=2672&&t<=2673||t>=2677&&t===2677||t>=3633&&t===3633||t>=3636&&t<=3642||t>=3655&&t<=3662||t>=3761&&t===3761||t>=3764&&t<=3772||t>=3784&&t<=3790||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65024&&t<=65039||t>=65056&&t<=65071||t===8205?0:t>=4352&&t<=4447||t>=8986&&t<=8987||t>=9001&&t<=9002||t>=9193&&t<=9203||t>=9208&&t<=9210||t>=9725&&t<=9726||t>=9748&&t<=9749||t>=9800&&t<=9811||t===9855||t===9875||t===9889||t>=9898&&t<=9899||t>=9917&&t<=9918||t>=9924&&t<=9925||t===9934||t===9940||t===9962||t>=9970&&t<=9971||t===9973||t===9978||t===9981||t===9986||t===9989||t>=9992&&t<=9997||t===9999||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t>=10548&&t<=10549||t>=11013&&t<=11015||t>=11035&&t<=11036||t===11088||t===11093||t>=11904&&t<=12350||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12784&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=19968&&t<=40959||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65131||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126980&&t===126980||t===127183||t>=127344&&t<=127345||t===127358||t===127359||t===127374||t>=127377&&t<=127386||t>=127456&&t<=127487||t>=127488&&t<=127490||t===127514||t===127535||t>=127538&&t<=127546||t>=127568&&t<=127569||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=129792&&t<=130047||t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}function ct(t){let e=0;for(let n of t)e+=It(n.codePointAt(0));return e}function fn(t,e){if(e<=0)return"";let n=0,r="";for(let s of t){let o=It(s.codePointAt(0));if(n+o>e){if(e<=1)return"\u2026";for(;n+1>e&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=It(i.codePointAt(0))}return`${r}\u2026`}r+=s,n+=o}return r}var vr={horizontal:"\u2500",vertical:"\u2502",cornerTL:"\u250C",cornerTR:"\u2510",cornerBL:"\u2514",cornerBR:"\u2518",tDown:"\u252C",tUp:"\u2534",tRight:"\u251C",tLeft:"\u2524",cross:"\u253C",arrowRight:"\u25B6",arrowDown:"\u25BC",arrowLeft:"\u25C0",arrowUp:"\u25B2",boxTL:"\u250C",boxTR:"\u2510",boxBL:"\u2514",boxBR:"\u2518",boxH:"\u2500",boxV:"\u2502"},Tr={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function gn(t,e){let n=e.charset==="ascii"?Tr:vr,r=t.width,s=t.height,o=Array.from({length:s},()=>Array.from({length:r},()=>" ")),i=Array.from({length:s},()=>Array.from({length:r},()=>"empty"));for(let a of t.edges)_r(o,i,n,a);for(let a of t.boxes)wr(o,i,n,a,e.labelOf(a.id));return o.map(a=>Or(a.join(""))).join(`
|
|
2
|
-
`)}function wr(t,e,n,r,s){let{x:o,y:i,w:a,h:d}=r;if(a<2||d<2){d>0&&pn(t,e,o,i,a,s);return}xe(t,e,o,i,n.boxTL);for(let l=o+1;l<o+a-1;l+=1)xe(t,e,l,i,n.boxH);xe(t,e,o+a-1,i,n.boxTR);for(let l=i+1;l<i+d-1;l+=1){xe(t,e,o,l,n.boxV);for(let f=o+1;f<o+a-1;f+=1)bn(t,e,f,l," ","empty");xe(t,e,o+a-1,l,n.boxV)}xe(t,e,o,i+d-1,n.boxBL);for(let l=o+1;l<o+a-1;l+=1)xe(t,e,l,i+d-1,n.boxH);xe(t,e,o+a-1,i+d-1,n.boxBR);let u=i+Math.floor(d/2);pn(t,e,o+1,u,a-2,s)}function xe(t,e,n,r,s){bn(t,e,n,r,s,s===" "?"empty":s==="\u2500"||s==="-"?"boxH":s==="\u2502"||s==="|"?"boxV":"boxCorner")}function bn(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];n<0||n>=i.length||(i[n]=s,e[r][n]=o)}function pn(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=n,a=s;for(let d of o){let u=ct(d);if(u!==0){if(a<u)break;i>=0&&i<t[r].length&&(t[r][i]=d,e[r][i]="label",u===2&&i+1<t[r].length&&(t[r][i+1]="",e[r][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<t[r].length&&(t[r][i]=" ",e[r][i]="empty"),i+=1,a-=1}function _r(t,e,n,r){let s=r.points;if(s.length<2)return;for(let d=0;d+1<s.length;d+=1)xr(t,e,n,s[d],s[d+1]);for(let d=1;d+1<s.length;d+=1){let u=s[d-1],l=s[d],f=s[d+1],h=Nr(u,l,f,n);h&&mn(t,e,l.x,l.y,h,"edgeCorner")}let o=s[s.length-1],i=s[s.length-2],a=Er(i,o,n);a&&mn(t,e,o.x,o.y,a,"arrow")}function xr(t,e,n,r,s){if(!(r.x===s.x&&r.y===s.y)){if(r.y===s.y){let o=r.y,i=Math.min(r.x,s.x),a=Math.max(r.x,s.x);for(let d=i;d<=a;d+=1)hn(t,e,d,o,n,"h")}else if(r.x===s.x){let o=r.x,i=Math.min(r.y,s.y),a=Math.max(r.y,s.y);for(let d=i;d<=a;d+=1)hn(t,e,o,d,n,"v")}}}function hn(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[n]=o==="h"?s.horizontal:s.vertical,e[r][n]=o==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&o==="v"){i[n]=s.cross,e[r][n]="edgeCorner";return}if(a==="edgeV"&&o==="h"){i[n]=s.cross,e[r][n]="edgeCorner";return}}}function mn(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[n]=s,e[r][n]=o)}function Nr(t,e,n,r){let s=t.y===e.y,o=e.y===n.y;if(s===o)return;if(s){let d=t.x<e.x,u=n.y>e.y;return d&&u?r.cornerTR:d&&!u?r.cornerBR:!d&&u?r.cornerTL:r.cornerBL}let i=t.y<e.y,a=n.x>e.x;return i&&a?r.cornerBL:i&&!a?r.cornerBR:!i&&a?r.cornerTL:r.cornerTR}function Er(t,e,n){if(e.x>t.x)return n.arrowRight;if(e.x<t.x)return n.arrowLeft;if(e.y>t.y)return n.arrowDown;if(e.y<t.y)return n.arrowUp}function Or(t){let e=t.length;for(;e>0&&t.charCodeAt(e-1)===32;)e-=1;return t.slice(0,e)}function Tn(t){let e=kr(t);Rr(e),Sr(e),Dr(e),Ar(e,t);let n=Gr(e,t),{width:r,height:s}=Lr(e),o=[];for(let i of e.layers)for(let a of i)a.isVirtual||o.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:o,edges:n,width:r,height:s}}function kr(t){let e=new Map;for(let s of t.nodes)e.set(s,{id:s,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:t.widthCells(s),h:t.heightCells(s),in:[],out:[]});let n=[],r=0;for(let s of t.edges){if(s.from===s.to)continue;let o=e.get(s.from),i=e.get(s.to);if(!o||!i)continue;let a={chainId:r++,chainFrom:s.from,chainTo:s.to,fromId:s.from,toId:s.to,hopIndex:0,chainLen:1};o.out.push(a),i.in.push(a),n.push(a)}return{nodes:e,layers:[],hops:n}}function Rr(t){let e=new Map;for(let o of t.nodes.values())e.set(o.id,o.in.length);let n=[];for(let o of t.nodes.values())(e.get(o.id)??0)===0&&(o.layer=0,n.push(o));let r=new Set,s=0;for(;s<n.length;){let o=n[s++];if(!r.has(o.id)){r.add(o.id);for(let i of o.out){let a=t.nodes.get(i.toId);a.layer=Math.max(a.layer,o.layer+1);let d=(e.get(a.id)??0)-1;e.set(a.id,d),d<=0&&n.push(a)}}}for(let o of t.nodes.values())o.layer<0&&(o.layer=0)}function Sr(t){let e=Math.max(0,...Array.from(t.nodes.values(),o=>o.layer)),n=Array.from({length:e+1},()=>[]);for(let o of t.nodes.values())n[o.layer].push(o);let r=[],s=0;for(let o of t.hops){let i=t.nodes.get(o.fromId),a=t.nodes.get(o.toId),d=a.layer-i.layer;if(d<=0){i.out=i.out.filter(f=>f!==o),a.in=a.in.filter(f=>f!==o);continue}if(d===1){o.hopIndex=0,o.chainLen=1,r.push(o);continue}i.out=i.out.filter(f=>f!==o),a.in=a.in.filter(f=>f!==o);let u=i;for(let f=1;f<d;f+=1){let h=`__virt_${s++}__`,p={id:h,isVirtual:!0,layer:i.layer+f,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};t.nodes.set(h,p),n[p.layer].push(p);let c={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:h,hopIndex:f-1,chainLen:d};u.out.push(c),p.in.push(c),r.push(c),u=p}let l={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:a.id,hopIndex:d-1,chainLen:d};u.out.push(l),a.in.push(l),r.push(l)}for(let o of n)for(let i=0;i<o.length;i+=1)o[i].order=i;t.layers=n,t.hops=r}function Dr(t){for(let n=0;n<4;n+=1){for(let r=1;r<t.layers.length;r+=1)yn(t,t.layers[r],"in"),ft(t.layers[r]);for(let r=t.layers.length-2;r>=0;r-=1)yn(t,t.layers[r],"out"),ft(t.layers[r])}for(let n=0;n<2;n+=1){let r=!1;for(let s=1;s<t.layers.length;s+=1){let o=t.layers[s];for(let i=0;i+1<o.length;i+=1){let a=vn(t,o[i],o[i+1],"in");[o[i],o[i+1]]=[o[i+1],o[i]],ft(o),vn(t,o[i],o[i+1],"in")<a?r=!0:([o[i],o[i+1]]=[o[i+1],o[i]],ft(o))}}if(!r)break}}function yn(t,e,n){let r=new Map;for(let s of e){let o=n==="in"?s.in:s.out;if(o.length===0){r.set(s.id,s.order);continue}let i=0,a=0;for(let d of o){let u=t.nodes.get(n==="in"?d.fromId:d.toId);u&&(i+=u.order,a+=1)}r.set(s.id,a===0?s.order:i/a)}e.sort((s,o)=>{let i=r.get(s.id),a=r.get(o.id);return i!==a?i-a:s.order-o.order})}function ft(t){for(let e=0;e<t.length;e+=1)t[e].order=e}function vn(t,e,n,r){let s=r==="in"?e.in:e.out,o=r==="in"?n.in:n.out,i=0;for(let a of s)for(let d of o){let u=t.nodes.get(r==="in"?a.fromId:a.toId)?.order??0,l=t.nodes.get(r==="in"?d.fromId:d.toId)?.order??0;(e.order<n.order&&u>l||e.order>n.order&&u<l)&&(i+=1)}return i}function Ar(t,e){e.direction==="LR"?Cr(t,e):Mr(t,e)}function Cr(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.w);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.x=n[s];for(let s of t.layers){let o=0;for(let i of s)i.y=o,o+=i.h+e.nodeGap}wn(t,e,"y")}function Mr(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.h);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.y=n[s];for(let s of t.layers){let o=0;for(let i of s)i.x=o,o+=i.w+e.nodeGap}wn(t,e,"x")}function wn(t,e,n){let r=o=>n==="y"?o.h:o.w,s=e.nodeGap;for(let o=0;o<2;o+=1){let i=o===0?t.layers.slice(1):t.layers.slice(0,-1).reverse();for(let a of i){let d=new Map;for(let l of a){let f=o===0?l.in:l.out;if(f.length===0)continue;let h=[];for(let c of f){let b=t.nodes.get(o===0?c.fromId:c.toId);if(!b)continue;let x=n==="y"?b.y:b.x;h.push(x+Math.floor(r(b)/2))}if(h.length===0)continue;h.sort((c,b)=>c-b);let p=h[Math.floor(h.length/2)];d.set(l.id,p-Math.floor(r(l)/2))}let u=0;for(let l of a){let f=d.get(l.id),h=n==="y"?l.y:l.x,c=Math.max(f??h,u);n==="y"?l.y=c:l.x=c,u=c+r(l)+s}}}}function Gr(t,e){let n=new Map;for(let u of t.hops){let l=n.get(u.chainId);l?l.push(u):n.set(u.chainId,[u])}for(let u of n.values())u.sort((l,f)=>l.hopIndex-f.hopIndex);let r=e.direction==="LR",s=u=>r?u.x:u.y,o=u=>r?u.w:u.h,i=u=>r?u.y+Math.floor(u.h/2):u.x+Math.floor(u.w/2),a=new Map;for(let u=0;u+1<t.layers.length;u+=1){let l=t.layers[u],f=t.layers[u+1],h=0;for(let y of l)h=Math.max(h,s(y)+o(y));let p=Number.POSITIVE_INFINITY;for(let y of f)p=Math.min(p,s(y));let c=Number.isFinite(p)?p-1:h,b=Math.max(1,c-h+1),x=[];for(let y of l)for(let _ of y.out)x.push(_);x.sort((y,_)=>{let R=i(t.nodes.get(y.fromId)),O=i(t.nodes.get(_.fromId));if(R!==O)return R-O;let k=i(t.nodes.get(y.toId)),S=i(t.nodes.get(_.toId));return k-S});let N=[],T=new Map;for(let y of x){let _=i(t.nodes.get(y.fromId)),R=i(t.nodes.get(y.toId)),O=Math.min(_,R),k=Math.max(_,R),S=-1;for(let C=0;C<N.length;C+=1){let U=N[C],B=!0;for(let ue of U)if(ue.lo<=k&&O<=ue.hi){B=!1;break}if(B){U.push({lo:O,hi:k}),S=C;break}}S<0&&(N.push([{lo:O,hi:k}]),S=N.length-1),T.set(y,S)}let g=N.length,v=b>=Math.max(3,g+2),E=v?h+1:h,w=v?c-1:c,m=Math.max(1,w-E+1);for(let y of x){let _=T.get(y),R;if(g<=1)R=E+Math.floor(m/2);else{let O=(m-1)/(g-1);R=E+Math.floor(_*O)}a.set(y,Math.max(h,Math.min(c,R)))}}let d=[];for(let[,u]of n){let l=[];for(let h=0;h<u.length;h+=1){let p=u[h],c=t.nodes.get(p.fromId),b=t.nodes.get(p.toId),x=a.get(p),N=c.isVirtual?s(c):s(c)+o(c),T=b.isVirtual?s(b):s(b)-1,g=i(c),v=i(b);h===0&&pt(l,r,N,g),g!==v&&(pt(l,r,x,g),pt(l,r,x,v)),pt(l,r,T,v)}let f=u[0];d.push({from:f.chainFrom,to:f.chainTo,points:Ir(l)})}return d}function pt(t,e,n,r){t.push(e?{x:n,y:r}:{x:r,y:n})}function Ir(t){let e=[];for(let n of t){let r=e[e.length-1];(!r||r.x!==n.x||r.y!==n.y)&&e.push(n)}return e}function Lr(t){let e=0,n=0;for(let r of t.layers)for(let s of r)e=Math.max(e,s.x+s.w),n=Math.max(n,s.y+s.h);return{width:e,height:n}}var Pr=24,$r=4,Fr=1,Vr=3;function _n(t,e){let n=zr(e.direction),r=Math.max(3,e.maxLabelWidth??Pr),s=e.asciiCharset??"unicode",o=Object.keys(t.nodes).sort(),i=new Set(o),a=t.edges.filter(p=>i.has(p.from)&&i.has(p.to)),d=new Map,u=new Map;for(let p of o){let c=fn(p,r);d.set(p,c),u.set(p,ct(c)+4)}let l=Tn({nodes:o,edges:a,widthCells:p=>u.get(p)??3,heightCells:()=>Vr,layerGap:$r,nodeGap:Fr,direction:n}),f=gn(l,{charset:s,labelOf:p=>d.get(p)??p}),h=e.logger;return h&&h(f),f}function zr(t){if(t===void 0||t==="LR")return"LR";if(t==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(t)}`)}function xn(t,e,n,r={}){let s=e in t.nodes,o=n in t.nodes;if(!s)return ht(e,n,"no-such-from");if(!o)return ht(e,n,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===n){if(r.findCycle===!0){let u=Br(t,e,r);if(u!=null)return u}let d=mt(e,t.nodes[e],0,r);return gt(e,n,[d])}if(i===0)return ht(e,n,"no-path");let a=Nn(t,e,n,i);return a.found?gt(e,n,En(t,a.pathOrder,r)):ht(e,n,a.truncated?"max-depth-exceeded":"no-path")}function Nn(t,e,n,r){let s=new Map,o=[{path:n,depth:0}],i=new Set([n]),a=0,d=!1;for(;a<o.length;){let f=o[a++];if(f.path===e)break;if(r!=null&&f.depth>=r){let b=t.nodes[f.path];b?.deps&&b.deps.length>0&&(d=!0);continue}let h=t.nodes[f.path];if(h==null)continue;let p=h.deps??[],c=new Map;for(let b=0;b<p.length;b++){let x=p[b];if(!x)continue;let N=c.get(x);N==null&&(N=[],c.set(x,N)),N.push(b)}for(let[b,x]of c)i.has(b)||(i.add(b),s.set(b,{from:f.path,depIndices:x}),o.push({path:b,depth:f.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:d};let u=[{path:e}],l=e;for(;l!==n;){let f=s.get(l);if(f==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=f.depIndices,u.push({path:f.from}),l=f.from}return{found:!0,pathOrder:u,truncated:!1}}function Br(t,e,n){let r=t.nodes[e];if(r==null)return null;let s=r.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=mt(e,r,0,n);a.dep_index=o[0];let d=mt(e,r,1,n);return gt(e,e,[a,d])}let i=null;for(let a=0;a<s.length;a++){let d=s[a];if(!d||d===e)continue;let u=Nn(t,d,e,n.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:gt(e,e,En(t,i.pathOrder,n))}function En(t,e,n){return e.map((r,s)=>{let o=t.nodes[r.path],i=mt(r.path,o,s,n);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function mt(t,e,n,r){let s={path:t,type:e.type,hop:n};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=r.annotations?.get(t)??e.annotation;o!=null&&(s.annotation=o);let i=r.lastMutations?.get(t)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function gt(t,e,n){return On(t,e,!0,"ok",n)}function ht(t,e,n){return On(t,e,!1,n,[])}function On(t,e,n,r,s){let o=Hr(t,e,n,r,s);return{from:t,to:e,found:n,reason:r,steps:s,text:o,toJSON(){return{from:t,to:e,found:n,reason:r,steps:s}}}}function Hr(t,e,n,r,s){if(!n)switch(r){case"no-such-from":return`explainPath: no node named "${t}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${t}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${t}" to "${e}"`}let o=[`Causal path: ${t} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(d),"value"in i&&o.push(` value: ${jr(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;o.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return o.join(`
|
|
3
|
-
`)}function jr(t){if(t===void 0)return"<sentinel>";if(t===null)return"null";if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);try{let e=JSON.stringify(t);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(t)}}me();var j={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},Ur=Symbol.for("sizeof");function kn(t){let e=new WeakSet,n=new WeakSet,r=[t],s=0;for(;r.length>0;){let o=r.pop();s+=Wr(o,e,n,r)}return s}function Wr(t,e,n,r){if(t==null)return 0;switch(typeof t){case"number":return j.number;case"boolean":return j.boolean;case"string":return j.string+t.length*2;case"bigint":return j.bigint+qr(t);case"symbol":return j.symbol;case"function":return e.has(t)?0:(e.add(t),j.function);case"undefined":return 0}let o=t;if(e.has(o))return 0;e.add(o);let i=o[Ur];if(typeof i=="function")try{let u=i.call(o);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(o instanceof Date)return j.date;if(o instanceof RegExp)return j.regexp+o.source.length*2;if(o instanceof Error){let u=o.message?o.message.length*2:0,l=o.stack?o.stack.length*2:0;return j.error+u+l}if(typeof URL<"u"&&o instanceof URL)return j.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return j.promise;if(o instanceof WeakMap)return j.weakmap;if(o instanceof WeakSet)return j.weakset;if(o instanceof Map){let u=j.map;for(let[l,f]of o)u+=j.mapEntry,r.push(l),r.push(f);return u}if(o instanceof Set){let u=j.set;for(let l of o)u+=j.setEntry,r.push(l);return u}if(Array.isArray(o)){let u=j.array+o.length*8;for(let l of o)r.push(l);return u}if(o instanceof ArrayBuffer)return n.has(o)?0:(n.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let u=o;return n.has(u.buffer)?48:(n.add(u.buffer),u.buffer.byteLength+48)}let a=j.object,d=Object.keys(o);for(let u of d){a+=j.string+u.length*2;try{r.push(o[u])}catch{}}return a}function qr(t){let e=t<0n?-t:t;if(e===0n)return 0;let n=e.toString(2).length;return Math.ceil(n/32)*8}function Rn(t,e){let n=e?.topN??10,r=t.describe({detail:"standard"}),s=[],o=t._collectObserveTargets;typeof o=="function"&&o.call(t,"",s);let i=new Map;for(let[h,p]of s)i.set(h,p);let a=[];for(let[h,p]of Object.entries(r.nodes)){let c=i.get(h),b=c instanceof H?c:null,x=b?kn(b.cache):0,N=b?b._sinkCount:0,T=p.deps?.length??0,g=p.type==="effect"&&N===0,v=N===0?p.type==="effect"?"orphan-effect":p.type==="derived"?"idle-derived":p.type==="producer"?"idle-producer":null:null;a.push({path:h,type:p.type,status:p.status??"unknown",valueSizeBytes:x,subscriberCount:N,depCount:T,isOrphanEffect:g,orphanKind:v})}let d=a.reduce((h,p)=>h+p.valueSizeBytes,0),u=(h,p)=>[...a].sort(p??((c,b)=>b[h]-c[h])).slice(0,n),l=a.filter(h=>h.orphanKind!=null),f=a.filter(h=>h.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:d,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:l,orphanEffects:f}}var V="::",ae="__meta__",Ae=1;function Sn(t,e){let n=Math.max(16,t.size*4),r=0;for(;t.size>0;){if(r++>=n){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${n}); ${t.size} disposer(s) discarded`),t.clear();return}let s=t.values().next();if(s.done)return;let o=s.value;t.delete(o);try{o()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Cn(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"&&typeof t.down=="function"}function Kr(t){if(t!=null)return Cn(t)?t.cache:t}function Yr(t){let e=[];for(let n of Object.keys(t).sort()){let r=t[n].v;r!=null&&e.push(`${n} ${r.id} ${r.version}`)}return e.join(`
|
|
4
|
-
|
|
5
|
-
`)
|
|
6
|
-
`)}function no(t,e){let n=In(t,e);return Ln(n)}function Ln(t,e){let n=e?.theme??"default",r=e?.autoSync??!0,o=JSON.stringify({code:t,mermaid:{theme:n},autoSync:r}),i=new TextEncoder().encode(o),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function ro(t,e){let n=Gn(e.direction),r=Object.keys(t.nodes).sort(),s=new Map;for(let i=0;i<r.length;i+=1)s.set(r[i],`n${i}`);let o=[`direction: ${Qr(n)}`];for(let i of r){let a=s.get(i);o.push(`${a}: "${Zr(i)}"`)}for(let[i,a]of Mn(t)){let d=s.get(i),u=s.get(a);!d||!u||o.push(`${d} -> ${u}`)}return o.join(`
|
|
7
|
-
`)}function oo(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bt(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let s=t.indexOf("]",n+1);if(s<=n+1){e+="\\[";continue}let o=t.slice(n+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,n=s;continue}e+=oo(r)}return e+="$",new RegExp(e)}var so={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"},io={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function yt(t){if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||t==null)return String(t);try{return JSON.stringify(t)}catch{return"[unserializable]"}}function ao(t){return t==="none"?io:t==="ansi"||t==null?so:{data:t.data??"",dirty:t.dirty??"",resolved:t.resolved??"",invalidate:t.invalidate??"",pause:t.pause??"",resume:t.resume??"",complete:t.complete??"",error:t.error??"",teardown:t.teardown??"",derived:t.derived??"",path:t.path??"",reset:t.reset??""}}function An(t){if(t==null)return{};let e=t.detail;return e==="full"?{...t,structured:t.structured??!0,timeline:t.timeline??!0,causal:t.causal??!0,derived:t.derived??!0}:e==="minimal"?{...t,structured:t.structured??!0}:t.format==="stage-log"?{...t,structured:t.structured??!0,timeline:t.timeline??!0}:t}function uo(t,e,n){for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);if(s<32||s===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function Lt(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(V))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${V}' (path separator)`);if(t===ae)throw new Error(`Graph "${e}": ${n} name "${ae}" is reserved for meta companion paths`);uo(t,e,n)}function lo(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(V);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function co(t,e){let n=!1;for(let s of t)if(!e.isMetaPassthrough(s[0])){n=!0;break}return n?t.filter(s=>e.isMetaPassthrough(s[0])):t}function Pn(t){for(let e of t._mounts.values())Pn(e);for(let e of t._nodes.values())try{e.down([[J]],{internal:!0})}catch{}}var ce=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(V))throw new Error(`Graph name must not contain '${V}' (got "${e}")`);if(e===ae)throw new Error(`Graph name "${ae}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??Fe,this._traceRing=new qe(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=De(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}nameOf(e){return this._nodeToName.get(e)}add(e,n){let r=e.name,s=n?.name??r;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,i=n?.annotation;if(Lt(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:oe()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof H&&n._applyVersioning(e)}remove(e){Lt(e,this.name,"remove");let n=this._mounts.get(e);if(n){let o={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,d]of i)a.includes(`${V}${ae}${V}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...n._collectSubgraphs(`${e}${V}`)),this._mounts.delete(e),n._parent=void 0,Pn(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:o}),o}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[J]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let n=typeof e=="function"?e:(()=>{let o=bt(e);return i=>o.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>n(o));for(let o of s){let i=this.remove(o);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let s=e[r++];return{value:[s,n.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(V))return this.resolve(e);let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return n}get(e){return this.node(e).cache}set(e,n,r){let s=r?.internal===!0;this.node(e).down([[P,n]],{actor:r?.actor,internal:s,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);le(()=>{for(let[s,o]of r)this.set(s,o,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[se]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let s=r?.internal===!0;this.node(e).down([[G,n]],{actor:r?.actor,internal:s,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[$]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[d,u]of this._nodes)r.set(u,d);let a=[];for(let[d,u]of this._nodes)if(u instanceof H)for(let l of u._deps){let f=r.get(l.node);f!=null&&a.push([f,d])}return a.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,d]of s)o.set(d,a);let i=[];for(let[a,d]of s)if(d instanceof H)for(let u of d._deps){let l=o.get(u.node);l!=null&&i.push([l,a])}return i.sort((a,d)=>a[0]<d[0]?-1:a[0]>d[0]?1:a[1]<d[1]?-1:a[1]>d[1]?1:0),i}mount(e,n){if(n===void 0){let s=new t(e);return this.mount(e,s)}if(typeof n=="function"){let s=new t(e);return n(s),this.mount(e,s)}let r=n;if(Lt(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===r)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,r),r._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),r}resolve(e){let n=lo(e,this.name);return this._resolveFromSegments(n)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let n=e;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],s=n.slice(1);if(s.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let o=this._nodes.get(r);if(o&&s.length>0&&s[0]===ae)return this._resolveMetaChainFromNode(o,s,n.join(V));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(V)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(s.join(V))}_resolveMetaChainFromNode(e,n,r){let s=e,o=0,i=[...n];for(;o<i.length;){if(i[o]!==ae)throw new Error(`Graph "${this.name}": expected ${ae} segment in meta path "${r}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${ae} in "${r}"`);let a=i[o+1],d=s.meta[a];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);s=d,o+=2}return s}signal(e,n){if(n?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,s){for(let d of this._mounts.values())d._signalDeliver(e,n,r,s);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=co(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(l){if(l instanceof ie)throw l;s.push(l)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,s)}}}_signalMetaSubtree(e,n,r,s,o){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,s)}catch(d){if(d instanceof ie)throw d;o.push(d)}this._signalMetaSubtree(a,n,r,s,o)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=Kr(e?.actor),r=e?.filter,s=dt(e?.detail,e?.fields),o=e?.format==="spec",i=o?dt("minimal"):s,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[w,m]of a)d.set(m,w);let u=[];{let w=a.map(([,_])=>_),m=new Set(d.values()),y=0;for(;w.length>0;){let _=w.shift();if(_ instanceof H)for(let R of _._deps){let O=R.node;if(d.has(O))continue;let k=O.name??"",S=k;if(!S||m.has(S))if(k){let C=2;for(;m.has(`${k}#${C}`);)C++;S=`${k}#${C}`}else for(S=`__internal__/${y++}`;m.has(S);)S=`__internal__/${y++}`;d.set(O,S),m.add(S),u.push([S,O]),w.push(O)}}}let l=[...a,...u],f={};for(let[w,m]of l){if(n!=null&&!m.allowsObserve(n))continue;let y=Gt(m,i),_=m instanceof H?m._deps.map(S=>d.get(S.node)??S.node.name??""):[],{name:R,...O}=y,k={...O,deps:_};if(!o){let S=this._annotations.get(w);S!=null&&(k.annotation=S)}if(r!=null)if(typeof r=="function"){let S=r;if(!(S.length>=2?S(w,k):S(k)))continue}else{let S=!0;for(let[C,U]of Object.entries(r)){let B=C==="deps_includes"?"depsIncludes":C==="meta_has"?"metaHas":C;if(B==="depsIncludes"){if(!k.deps.includes(String(U))){S=!1;break}continue}if(B==="metaHas"){if(!Object.hasOwn(k.meta??{},String(U))){S=!1;break}continue}if(k[B]!==U){S=!1;break}}if(!S)continue}f[w]=k}let h=new Set(Object.keys(f)),p=[];for(let[w,m]of l)if(m instanceof H)for(let y of m._deps){let _=d.get(y.node);_!=null&&p.push([_,w])}p.sort((w,m)=>w[0]<m[0]?-1:w[0]>m[0]?1:w[1]<m[1]?-1:w[1]>m[1]?1:0);let c=p.map(([w,m])=>({from:w,to:m}));(n!=null||r!=null)&&(c=c.filter(w=>h.has(w.from)&&h.has(w.to)));let b=this._collectSubgraphs(""),x=n!=null||r!=null?b.filter(w=>{let m=`${w}${V}`;return[...h].some(y=>y===w||y.startsWith(m))}):b,N=this,T=e,g={name:this.name,nodes:f,edges:c,subgraphs:x,expand(w){let m={...T,format:void 0};return Array.isArray(w)?(m.fields=w,m.detail=void 0):(m.detail=w,m.fields=void 0),N.describe(m)}},v=e??{},E=v.format;return E==="json"?eo(g,v):E==="pretty"?to(g,v):E==="mermaid"?In(g,v):E==="mermaid-url"?no(g,v):E==="d2"?ro(g,v):E==="ascii"?_n(g,v):g}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${r}`;n.push(s),n.push(...this._mounts.get(r)._collectSubgraphs(`${s}${V}`))}return n}resourceProfile(e){return Rn(this,e)}reachable(e,n,r={}){return r.withDetail===!0?$t(this.describe(),e,n,{...r,withDetail:!0}):$t(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,d]of Object.entries(s.nodes))d.lastMutation!=null&&i.set(a,d.lastMutation);return xn(s,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",s=0,o=z(s,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,je(()=>{a=!1,!d&&(s+=1,o.emit(s))}))},l=i.onEvent(T=>{let g=T.type;g!=="data"&&g!=="error"&&g!=="complete"&&g!=="teardown"||u()}),f=[],h=new WeakSet,p=T=>{if(h.has(T)||d)return;h.add(T);let g=T.topology.subscribe(v=>{for(let E of v){if(E[0]!==P)continue;let w=E[1];if(u(),w.kind==="added"&&w.nodeKind==="mount"){let m=T._mounts.get(w.name);m!=null&&p(m)}}});f.push(g);for(let v of T._mounts.keys()){let E=T._mounts.get(v);E!=null&&p(E)}};p(this);let c,b=e.actor;Cn(b)&&(c=b.subscribe(T=>{let g=!1,v=!1;for(let E of T){let w=E[0];w===P?g=!0:(w===$||w===G||w===J)&&(v=!0)}g&&u(),v&&(c?.(),c=void 0,u())}));let x;try{x=F([o],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(T,g)=>T===g})}catch(T){l(),c?.();for(let g of f)g();throw i.dispose(),T}let N=ge(x);return{node:x,dispose(){d=!0,l(),c?.();for(let T of f)T();f.length=0,i.dispose(),N()}}}_explainReactive(e,n,r){let s=0,o=z(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(p=>{let c=p.type;c!=="data"&&c!=="error"&&c!=="complete"&&c!=="teardown"||a||d||(a=!0,je(()=>{a=!1,!d&&(s+=1,o.emit(s))}))}),l={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},f;try{f=F([o],()=>this._explainStatic(e,n,l),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(p,c)=>p.found===c.found&&p.reason===c.reason&&p.steps.length===c.steps.length&&fo(p.steps,c.steps)})}catch(p){throw u(),i.dispose(),p}let h=ge(f);return{node:f,dispose(){d=!0,u(),i.dispose(),h()}}}_pathsMatching(e){let n=bt(e),r=[];return this._collectObserveTargets("",r),r.map(([s])=>s).filter(s=>n.test(s))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${V}${r}`;this._mounts.get(r)._collectObserveTargets(s,n)}for(let r of[...this._nodes.keys()].sort()){let s=this._nodes.get(r),o=e===""?r:`${e}${V}${r}`;n.push([o,s]),this._appendMetaObserveTargets(o,s,n)}}_appendMetaObserveTargets(e,n,r){for(let s of Object.keys(n.meta).sort()){let o=n.meta[s],i=`${e}${V}${ae}${V}${s}`;r.push([i,o]),this._appendMetaObserveTargets(i,o,r)}}observe(e,n){let r=typeof e=="string",o=An(r?n:e),i=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,a=o.actor;if(r){let l=e,f=this.resolve(l);if(a!=null&&!f.allowsObserve(a))throw new ie({actor:a,action:"observe",nodeName:l});return i?this._buildStructuredObserver([[l,f]],o,"one"):{subscribe(h){return f.subscribe(h)},up(h){try{f.up?.(h)}catch(p){if(p instanceof ie)return;throw p}}}}let d=[];this._collectObserveTargets("",d),d.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let u=a==null?d:d.filter(([,l])=>l.allowsObserve(a));return i?this._buildStructuredObserver(u,o,"all"):{subscribe:l=>{let f=u.map(([h,p])=>p.subscribe(c=>{l(h,c)}));return()=>{for(let h of f)h()}},up:(l,f)=>{try{this.resolve(l).up?.(f)}catch(h){if(h instanceof ie)return;throw h}}}}_buildStructuredObserver(e,n,r){let s=r==="one"?e[0]?.[0]:void 0,o=i=>{if(r==="one"&&s!=null){let l=this.resolve(s);return this._buildStructuredObserver([[s,l]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let d=i.actor,u=d==null?a:a.filter(([,l])=>l.allowsObserve(d));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,o)}_createObserveResult(e,n,r){let s=n.timeline===!0,o=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",d=this.config.inspectorEnabled,u=(o||i)&&d,l=n.maxEvents,f=l!=null&&l>0?new qe(l):null,h=[],p=new Set,c={},b=new Set,x=0,N=0,T=0,g=0,v=0,E=0,w=!1,m=!1,y=0,_=new Map,R=new Map,O=new Map,k=D=>{f?f.push(D):h.push(D);for(let L of p)L(D)},S=()=>s?{timestamp_ns:oe(),in_batch:He(),batch_id:y}:{},C=(D,L)=>{if(!(!u||!(D instanceof H)))return D._setInspectorHook(X=>{if(X.kind==="dep_message")_.set(D,X.depIndex);else if(X.kind==="run"){let ye=X.batchData.map((I,Q)=>I!=null&&I.length>0?I.at(-1):X.prevData[Q]);R.set(D,ye);let Z=X.batchData.map(I=>I!=null?[...I]:void 0);O.set(D,Z),i&&k({type:"derived",path:L,dep_values:ye,dep_batches:Z,...S()})}})},U=D=>{let L=_.get(D),X=R.get(D);if(!o||X==null)return{};let Z=(L!=null&&L>=0&&D instanceof H?D._deps[L]:void 0)?.node,I=Z?.v,Q=O.get(D);return{trigger_dep_index:L,trigger_dep_name:Z?.name,...I!=null?{trigger_version:{id:I.id,version:I.version}}:{},dep_values:[...X],...Q!=null?{dep_batches:Q}:{}}},B=[],ue=[];for(let[D,L]of e){let X=C(L,D);X&&B.push(X),ue.push(L.subscribe(ye=>{y++;for(let Z of ye){let I=Z[0],Q=S();if(I===P){c[D]=Z[1];let A=L instanceof H?L.lastMutation?.actor??$e:$e;k({type:"data",path:D,data:Z[1],actor:A,...Q,...U(L)})}else if(a)I===K?x++:I===Y?N++:I===se?T++:I===de?g++:I===pe?v++:I===J?E++:I===$&&!b.has(D)?w=!0:I===G&&(m=!0,b.add(D));else if(I===K)x++,k({type:"dirty",path:D,...Q});else if(I===Y)N++,k({type:"resolved",path:D,...Q,...U(L)});else if(I===se)T++,k({type:"invalidate",path:D,...Q});else if(I===de)g++,k({type:"pause",path:D,lockId:Z[1],...Q});else if(I===pe)v++,k({type:"resume",path:D,lockId:Z[1],...Q});else if(I===$)b.has(D)||(w=!0),k({type:"complete",path:D,...Q});else if(I===G){m=!0,b.add(D);let A=L instanceof H?L.lastMutation?.actor??$e:$e;k({type:"error",path:D,data:Z[1],actor:A,...Q})}else I===J&&(E++,k({type:"teardown",path:D,...Q}))}}))}let Ne=!1,Ce=()=>{if(!Ne){Ne=!0;for(let D of ue)D();for(let D of B)D();for(let D of be)D({value:void 0,done:!0});be.length=0}},Ee=[],be=[];p.add(D=>{let L=be.shift();L?L({value:D,done:!1}):Ee.push(D)});let Me={get values(){return c},get dirtyCount(){return x},get resolvedCount(){return N},get invalidateCount(){return T},get pauseCount(){return g},get resumeCount(){return v},get teardownCount(){return E},get events(){return f?f.toArray():[...h]},get anyCompletedCleanly(){return w},get anyErrored(){return m},get completedWithoutErrors(){return w&&!m},onEvent(D){return p.add(D),()=>p.delete(D)},dispose:Ce,expand(D){Ce();let L={...n};return typeof D=="string"?L.detail=D:Object.assign(L,D),r(An(L))},[Symbol.asyncIterator](){return{next(){return Ee.length>0?Promise.resolve({value:Ee.shift(),done:!1}):Ne?Promise.resolve({value:void 0,done:!0}):new Promise(D=>be.push(D))},return(){return Ce(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Me,n),Me}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let s=n.logger??(c=>console.log(c)),o=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=o==null&&i==null?()=>!0:c=>(o==null||o.has(c))&&(i==null||!i.has(c)),d=ao(n.theme),u=r==="stage-log"?oe():0,l=c=>c==null?"":n.stageLabels?.[c]??c,f=(c,b)=>c.length>b?`${c.slice(0,b-1)}\u2026`:c,h=c=>c.type==="data"||c.type==="error"?f(yt(c.data),120):"",p=c=>{if(r==="stage-log"){let m=(oe()-u)/1e9,y=l(c.path).padEnd(9);if(c.type==="data"){let _=h(c);return`[${m.toFixed(3)}s] ${y} \u2190${_?` ${_}`:""}`}if(c.type==="error"){let _=h(c);return`[${m.toFixed(3)}s] ${y} \u2717${_?` ${_}`:""}`}return c.type==="complete"?`[${m.toFixed(3)}s] ${y} \u25A0 complete`:`[${m.toFixed(3)}s] ${y} ${c.type}`}if(r==="json")try{return JSON.stringify(c)}catch{return JSON.stringify({type:c.type,path:c.path,data:"[unserializable]"})}let b=d[c.type]??"",x=c.path?`${d.path}${c.path}${d.reset} `:"",N=c.type==="data"||c.type==="error",T=c.type==="pause"||c.type==="resume",g=N?` ${yt(c.data)}`:T?` ${yt(c.lockId)}`:"",v=c.type==="data"||c.type==="resolved"||c.type==="derived"?c:void 0,E=v?.trigger_dep_name!=null?` <- ${v.trigger_dep_name}`:v?.trigger_dep_index!=null?` <- #${v.trigger_dep_index}`:"",w=c.in_batch?" [batch]":"";return`${x}${b}${c.type.toUpperCase()}${d.reset}${g}${E}${w}`};e.onEvent(c=>{a(c.type)&&s(p(c),c)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){Sn(this._disposers,this.name),this.signal([[J]],{internal:!0}),Sn(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:n,...r}=this.describe({detail:"full"}),s={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:d,guard:u,...l}=r.nodes[a];s[a]=l}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 Jt(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??Fe,{codec:s,codecVersion:o,payload:i}=Xt(e,r);return s.decode(i,o)}restore(e,n){if(Dn(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(o=>bt(o)),s=n?.includeProducers===!0;for(let o of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(o)))continue;let i=e.nodes[o];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let d=this.tryResolve(o)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){n?.onError?.(o,a)}}}}}static fromSnapshot(e,n){Dn(e);let r=typeof n=="function"?n:n?.build,s=typeof n=="function"?void 0:n?.factories,o=new t(e.name);if(r)return r(o),o.restore(e),o;for(let p of[...e.subgraphs].sort((c,b)=>{let x=c.split(V).length,N=b.split(V).length;return x!==N?x-N:c<b?-1:c>b?1:0})){let c=p.split(V),b=o;for(let x of c)b._mounts.has(x)||b.mount(x,new t(x)),b=b._mounts.get(x)}let i=s?Object.entries(s).map(([p,c])=>({re:bt(p),factory:c})):[],a=p=>{for(let c of i)if(c.re.test(p))return c.factory},d=p=>{let c=p.split(V),b=c.pop();if(b==null||b.length===0)throw new Error(`invalid snapshot path "${p}"`);let x=o;for(let N of c){let T=x._mounts.get(N);if(!T)throw new Error(`unknown mount "${N}" in path "${p}"`);x=T}return[x,b]},u=Object.entries(e.nodes).filter(([p])=>!p.includes(`${V}${ae}${V}`)).sort((p,c)=>p[0]<c[0]?-1:p[0]>c[0]?1:0),l=new Map(u),f=new Map,h=!0;for(;l.size>0&&h;){h=!1;for(let[p,c]of[...l.entries()]){let b=c?.deps??[];if(!b.every(E=>f.has(E)))continue;let[x,N]=d(p),T={...c?.meta??{}},g=a(p),v;if(c?.type==="state")v=z(c.value,{meta:T});else{if(g==null)continue;v=g(N,{path:p,type:c.type,value:c.value,meta:T,deps:b,resolvedDeps:b.map(E=>f.get(E))})}x.add(v,{name:N}),f.set(p,v),l.delete(p),h=!0}}if(l.size>0){let p=[...l.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${p}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachSnapshotStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let s=(u,l)=>{if(u.disposed)return;let f=Yr(l.nodes);if(u.lastSnapshot!=null&&f!==""&&f===u.lastFingerprint)return;let h=u.seq+1,p=Ze(),x=u.lastSnapshot==null||h%u.compactEvery===0?{name:this.name,mode:"full",snapshot:l,seq:h,timestamp_ns:p,format_version:Ae}:{name:this.name,mode:"diff",diff:$n(u.lastSnapshot,l),seq:h,timestamp_ns:p,format_version:Ae};if(u.tier.filter&&!u.tier.filter(x))return;let N;try{N=u.tier.save(x)}catch(T){n.onError?.(T,u.tier);return}if(N&&typeof N.then=="function"){let v=(u.savePending??Promise.resolve()).then(()=>N,()=>N).then(()=>{u.disposed||(u.seq=h,u.lastSnapshot=l,u.lastFingerprint=f)},E=>{n.onError?.(E,u.tier)});u.savePending=v.finally(()=>{u.savePending===v&&(u.savePending=void 0)})}else u.seq=h,u.lastSnapshot=l,u.lastFingerprint=f},o=(u,l)=>{try{s(u,l)}catch(f){n.onError?.(f,u.tier)}},i=(u,l)=>{if(!l.some(c=>{let b=this.config.messageTier(c[0]);return b>=3&&b<5}))return;if(n.filter){let c=this.tryResolve(u);if(c==null)return;let b=Gt(c,dt("standard"));if(!n.filter(u,b))return}let h,p=()=>(h==null&&(h=this.snapshot()),h);for(let c of r)c.disposed||(c.debounceMs===0?o(c,p()):(c.timer==null&&(c.timer=new lt),c.timer.start(c.debounceMs,()=>{c.disposed||o(c,this.snapshot())})))},a;if(n.paths!=null){let l=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(f=>{let h=this.tryResolve(f);return h==null?()=>{}:h.subscribe(p=>i(f,p))});a=()=>{for(let f of l)f()}}else a=this.observe().subscribe((u,l)=>i(u,l));let d=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,n){for(let r of e){let s;try{s=await r.load?.()}catch(i){n?.(i,r);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===Ae&&o.nodes!=null)return this.restore(o),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let s of n){let o;try{o=await s.load?.()}catch(d){r?.onError?.(d,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===Ae&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(d){r?.onError?.(d,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,n,r){if(e!=null&&n!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,n),this.config.inspectorEnabled){let s={path:e,annotation:n,timestamp_ns:oe(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(s=>!e(s)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let s of n)this._traceRing.push(s);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(n.nodes)),o=[...s].filter(T=>!r.has(T)).sort(),i=[...r].filter(T=>!s.has(T)).sort(),a=[],d=[];for(let T of r){if(!s.has(T))continue;let g=e.nodes[T],v=n.nodes[T],E=g.v,w=v.v;E!=null&&w!=null&&E.id===w.id&&E.version!==w.version&&d.push({path:T,id:E.id,from:E.version,to:w.version});let m=E!=null&&w!=null&&E.id===w.id&&E.version===w.version;for(let y of["type","status","sentinel"]){let _=g[y],R=v[y];_!==R&&a.push({path:T,field:y,from:_,to:R})}if(!m)for(let y of["value","meta"]){let _=g[y],R=v[y];Jr(_,R)||a.push({path:T,field:y,from:_,to:R})}}let u=T=>`${T.from} ${T.to}`,l=new Set(e.edges.map(u)),f=new Set(n.edges.map(u)),h=n.edges.filter(T=>!l.has(u(T))),p=e.edges.filter(T=>!f.has(u(T))),c=new Set(e.subgraphs),b=new Set(n.subgraphs),x=[...b].filter(T=>!c.has(T)).sort(),N=[...c].filter(T=>!b.has(T)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:h,edgesRemoved:p,subgraphsAdded:x,subgraphsRemoved:N}}};function $n(t,e){let n=ce.diff(t,e),r={};for(let s of n.nodesAdded){let o=e.nodes[s];o!=null&&(r[s]=o)}return{...n,nodesAddedFull:r}}function $t(t,e,n,r={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?s:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=r.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return r.withDetail?s:[];let i=new Map,a=new Map,d=new Map,u=new Map,l=new Set;for(let[g,v]of Object.entries(t.nodes)){if(!g)continue;l.add(g);let E=v.deps??[];i.set(g,E);for(let w of E)w&&(l.add(w),a.has(w)||a.set(w,new Set),a.get(w).add(g))}for(let g of t.edges){if(g==null||typeof g!="object")continue;let v=typeof g.from=="string"?g.from:"",E=typeof g.to=="string"?g.to:"";!v||!E||(l.add(v),l.add(E),u.has(v)||u.set(v,new Set),u.get(v).add(E),d.has(E)||d.set(E,new Set),d.get(E).add(v))}if(!l.has(e))return r.withDetail?s:[];let f=r.both===!0,h=g=>{if(f){let m=i.get(g)??[],y=d.get(g),_=a.get(g),R=u.get(g),O=[...m];return y&&O.push(...y),_&&O.push(..._),R&&O.push(...R),O}if(n==="upstream"){let m=i.get(g)??[],y=d.get(g);return y?[...m,...y]:m}let v=a.get(g),E=u.get(g),w=v?[...v]:[];return E&&w.push(...E),w},p=new Set([e]),c=new Map,b=[{path:e,depth:0}],x=0,N=!1;for(;x<b.length;){let g=b[x++];if(o!=null&&g.depth>=o){h(g.path).length>0&&(N=!0);continue}for(let v of h(g.path))!v||p.has(v)||(p.add(v),c.set(v,g.depth+1),b.push({path:v,depth:g.depth+1}))}let T=[...c.keys()].sort((g,v)=>g<v?-1:g>v?1:0);return r.withDetail?{paths:T,depths:c,truncated:N}:T}function fo(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],s=e[n];if(r.path!==s.path||r.type!==s.type||r.status!==s.status||r.hop!==s.hop||r.dep_index!==s.dep_index||r.annotation!==s.annotation||r.value!==s.value||r.lastMutation!==s.lastMutation)return!1;let o=r.v,i=s.v;if(o!==i&&(o==null||i==null||o.id!==i.id||o.version!==i.version))return!1}return!0}st();Pe();We();he();Ve();me();Pe();he();me();Ve();var Ft=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,n){if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=n,n!==void 0){if(this._buf=new Array(n),e&&e.length>0){let r=Math.min(e.length,n),s=e.length-r;for(let o=0;o<r;o++)this._buf[o]=e[s+o];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._size+e;if(!(n<0||n>=this._size))return this._maxSize!==void 0?this._buf[(this._head+n)%this._maxSize]:this._buf[n]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=n;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let n=0;n<e;n++)this._buf[(this._head+n)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let n=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,n);else{for(let r=0;r<n;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+n)%this._maxSize}return this._size-=n,this._version+=1,n}slice(e,n){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(n!==void 0&&(!Number.isInteger(n)||n<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${n})`);let r=n===void 0?this._size:Math.min(Math.max(n,0),this._size),s=Math.min(e,this._size);if(s>=r)return[];let o=r-s;if(this._maxSize===void 0)return this._buf.slice(s,r);let i=new Array(o);for(let a=0;a<o;a++)i[a]=this._buf[(this._head+s+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let n=Math.min(e,this._size);return this.slice(this._size-n,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this._buf[(this._head+n)%this._maxSize];return e}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let n=0;n<e.length;n++)this._buf.push(e[n]);this._size=this._buf.length}else{let n=this._maxSize;for(let o=0;o<n;o++)this._buf[o]=void 0;this._head=0;let r=Math.min(e.length,n),s=e.length-r;for(let o=0;o<r;o++)this._buf[o]=e[s+o];this._size=r}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function Ke(t){return t.subscribe(()=>{})}var po=64;function Fn(t,e={}){let{name:n,maxSize:r,versioning:s,guard:o,backend:i}=e,a=i??new Ft(t,r),d=z(a.toArray(),{name:n,describeKind:"state",equals:(m,y)=>m===y,...s!=null?{versioning:s}:{},...o!=null?{guard:o}:{}});function u(){let m=a.toArray();le(()=>{d.down([[K]],{internal:!0}),d.down([[P,m]],{internal:!0})})}let l=new Map,f=new Map,h=new Map;function p(m,y){return`${m}:${y===void 0?"END":y}`}function c(m){if(m.size<po)return;let y=m.keys().next();if(y.done)return;let _=m.get(y.value);_!==void 0&&_.dispose(),m.delete(y.value)}function b(m){let y=a.version;try{return m()}finally{a.version!==y&&u()}}function x(m){if(!Number.isInteger(m)||m<0)throw new RangeError(`tail: n must be a non-negative integer (got ${m})`);let y=l.get(m);if(y!==void 0)return l.delete(m),l.set(m,y),y.node;c(l);let _=F([d],([O])=>{let k=O;return m===0||k.length===0?[]:k.slice(Math.max(0,k.length-m))},{initial:a.tail(m),describeKind:"derived"}),R=Ke(_);return l.set(m,{node:_,dispose:R}),_}function N(m,y){if(!Number.isInteger(m)||m<0)throw new RangeError(`slice: start must be a non-negative integer (got ${m})`);if(y!==void 0&&(!Number.isInteger(y)||y<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${y})`);let _=p(m,y),R=f.get(_);if(R!==void 0)return f.delete(_),f.set(_,R),R.node;c(f);let O=F([d],([S])=>{let C=S;return y===void 0?C.slice(m):C.slice(m,y)},{initial:a.slice(m,y),describeKind:"derived"}),k=Ke(O);return f.set(_,{node:O,dispose:k}),O}function T(m){let y=h.get(m);if(y!==void 0)return y.node;let _=F([d,m],([O,k])=>{let S=O,C=Math.max(0,Math.trunc(k??0));return S.slice(C)},{initial:[],describeKind:"derived"}),R=Ke(_);return h.set(m,{node:_,dispose:R}),_}let g,v;function E(){g===void 0&&(g=te([d],(m,y,_)=>{let R=m[0],k=R!=null&&R.length>0?R.at(-1):_.prevData[0];if(k==null||k.length===0){y.down([[Y]]);return}y.emit(k[k.length-1])},{name:n!=null?`${n}::lastValue`:"lastValue",describeKind:"derived",initial:a.size===0?void 0:a.at(a.size-1)}),v=F([d],([m])=>m.length>0,{name:n!=null?`${n}::hasLatest`:"hasLatest",describeKind:"derived",initial:a.size>0}),Ke(g),Ke(v))}let w={entries:d,get size(){return a.size},at(m){return a.at(m)},append(m){b(()=>a.append(m))},appendMany(m){m.length!==0&&b(()=>a.appendMany(m))},clear(){b(()=>a.clear())},trimHead(m){b(()=>a.trimHead(m))},withLatest(){return E(),d},get lastValue(){return E(),g},get hasLatest(){return E(),v},view(m){switch(m.kind){case"tail":return x(m.n);case"slice":return N(m.start,m.stop);case"fromCursor":return T(m.cursor)}},attach(m){let y=m.subscribe(_=>{for(let R of _)R[0]===P&&w.append(R[1])});return()=>y()},attachStorage(m){if(m.length===0)return()=>{};let y=new Map;for(let R of m)y.set(R,a.size);(async()=>{for(let R of m)if(typeof R.loadEntries=="function")try{let O=await Promise.resolve(R.loadEntries());O.entries.length>0&&a.size===0&&(a.restore(O.entries),y.set(R,O.entries.length),u());break}catch{}})();let _=d.subscribe(R=>{for(let O of R){if(O[0]!==P)continue;let k=O[1];for(let S of m){let C=y.get(S)??0;if(k.length<C){try{let B=S.appendEntries(k);B instanceof Promise&&B.catch(()=>{})}catch{}y.set(S,k.length);continue}if(k.length===C)continue;let U=k.slice(C);y.set(S,k.length);try{let B=S.appendEntries(U);B instanceof Promise&&B.catch(()=>{})}catch{}}}});return()=>_()},disposeAllViews(){for(let m of l.values())m.dispose();l.clear();for(let m of f.values())m.dispose();f.clear();for(let m of h.values())m.dispose();h.clear()},dispose(){for(let m of l.values())m.dispose();l.clear();for(let m of f.values())m.dispose();f.clear();for(let m of h.values())m.dispose();h.clear()}};return w}ut();function Vn(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}function Ye(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function Je(t,e){return Vn("messaging",t,e)}var ho=1024,Vt=class extends ce{_log;events;latest;hasLatest;constructor(e,n={}){super(e,n.graph),this._log=Fn([],{name:"events",maxSize:n.retainedLimit??ho}),this._log.withLatest(),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=F([this.events],([r])=>{let s=r;return s.length===0?null:s[s.length-1]},{name:"latest",describeKind:"derived",meta:Je("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(ge(this.latest)),this.hasLatest=F([this.events],([r])=>r.length>0,{name:"hasLatest",describeKind:"derived",meta:Je("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(ge(this.hasLatest)),this.addDisposer(()=>{this.events.down([[$]])}),this.addDisposer(()=>this._log.disposeAllViews())}publish(e){if(e===void 0)throw new TypeError(`TopicGraph "${this.name}": publish(undefined) is not allowed (spec \xA75.12 SENTINEL).`);this._log.append(e)}attachEventStorage(e){return this._log.attachStorage(e)}retained(){return this.events.cache}get _logBundle(){return this._log}},zt=class extends ce{cursor;available;topic;_disposed=!1;constructor(e,n,r={}){super(e,r.graph),this.topic=n;let s;if(r.from!==void 0?r.from==="retained"?s=0:r.from==="now"?s=n.events.cache.length:s=Ye(r.from,"subscription from"):s=Ye(r.cursor??0,"subscription cursor"),this.cursor=z(s,{name:"cursor",describeKind:"state",meta:Je("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=n._logBundle.view({kind:"fromCursor",cursor:this.cursor}),this.add(this.available,{name:"available"}),this.addDisposer(ge(this.available)),r.advanceOn!==void 0){let o=r.advanceOn,i=!1,a=te([o],()=>{if(!i){i=!0;return}if(this._disposed)return;let d=this.available.cache;if(d.length===0)return;let u=this.cursor.cache+d.length;this.cursor.emit(u)},{name:"advancePump",describeKind:"effect",meta:Je("subscription_advance_pump")});this.add(a,{name:"advancePump"}),this.addDisposer(ge(a))}}ack(e){if(this._disposed)return this.cursor.cache;let n=this.available.cache,r=e===void 0?n.length:Ye(e,"subscription ack count"),s=Math.min(r,n.length);if(s<=0)return this.cursor.cache;let o=this.cursor.cache+s;return this.cursor.emit(o),o}pull(e){if(this._disposed)return[];let n=this.available.cache,r=e===void 0?n.length:Ye(e,"subscription pull limit");return n.slice(0,r)}pullAndAck(e){if(this._disposed)return{items:[],cursor:this.cursor.cache};let n=this.available.cache,r=e===void 0?n.length:Ye(e,"subscription pullAndAck limit"),s=n.slice(0,r);if(s.length===0)return{items:s,cursor:this.cursor.cache};let o=this.cursor.cache+s.length;return this.cursor.emit(o),{items:s,cursor:o}}dispose(){this._disposed||(this._disposed=!0,this.cursor.down([[$]]),this.destroy())}};var Bt=class{_map=new Map;version;constructor(e){this.version=e}get size(){return this._map.size}has(e){return this._map.has(e)}get(e){return this._map.get(e)}set(e,n){this._map.set(e,n)}delete(e){return this._map.delete(e)}keys(){return this._map.keys()}},Ht=class extends ce{_registry;version;_defaultTopicOptions;constructor(e,n={}){super(e,n.graph);let r=z(0,{name:"version",describeKind:"state",meta:Je("hub_version")});this.add(r,{name:"version"}),this.version=r,this._registry=new Bt(r),this._defaultTopicOptions={...n.defaultTopicOptions??{}}}get size(){return this._registry.size}has(e){return this._registry.has(e)}topicNames(){return this._registry.keys()}topic(e,n){let r=this._registry.get(e);if(r===void 0){let s={...this._defaultTopicOptions,...n??{}};r=new Vt(e,s),this._registry.set(e,r),this.mount(e,r);let o=this.version.cache??0;this.version.emit(o+1)}return r}publish(e,n){this.topic(e).publish(n)}publishMany(e){le(()=>{for(let[n,r]of e)this.topic(n).publish(r)})}subscribe(e,n,r){let s=this.topic(n);return new zt(e,s,r)}removeTopic(e){if(!this._registry.has(e))return!1;try{this.remove(e)}finally{this._registry.delete(e);let n=this.version.cache??0;this.version.emit(n+1)}return!0}};function zn(t,e){return new Ht(t,e)}function mo(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.subscribe=="function"&&typeof e.down=="function"&&typeof e.emit=="function"}function Bn(t,e){if(t.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(t.length===1){let o=jt(e);return{best:t[0],bestScore:o}}if(e.some(o=>typeof o.candidateIndex=="number")){let o=new Array(t.length);for(let d=0;d<t.length;d++)o[d]={sum:0,count:0};for(let d of e){let u=d.candidateIndex;typeof u=="number"&&u>=0&&u<t.length&&(o[u].sum+=d.score,o[u].count+=1)}let i=t[0],a=o[0].count>0?o[0].sum/o[0].count:Number.NEGATIVE_INFINITY;for(let d=1;d<t.length;d++){let u=o[d].count>0?o[d].sum/o[d].count:Number.NEGATIVE_INFINITY;u>a&&(a=u,i=t[d])}return{best:i,bestScore:a}}let r=t[0],s=e[0]?.score??Number.NEGATIVE_INFINITY;for(let o=1;o<t.length;o++){let i=e[o]?.score??Number.NEGATIVE_INFINITY;i>s&&(s=i,r=t[o])}return{best:r,bestScore:s}}function jt(t){if(t.length===0)return Number.NEGATIVE_INFINITY;let e=0;for(let n of t)e+=n.score;return e/t.length}function go(t,e,n,r){let s=r.name??"refine-loop",o=new ce(s,r.graph),i=mo(r.dataset)?r.dataset:z(r.dataset,{name:"dataset"});o.add(i,{name:"dataset"});let a=z(0,{name:"iteration"});o.add(a,{name:"iteration"});let d=z(n,{name:"strategy",equals:()=>!1});o.add(d,{name:"strategy"});let u=z(null,{name:"lastFeedback"});o.add(u,{name:"lastFeedback"});let l=z([],{name:"prevCandidates"});o.add(l,{name:"prevCandidates"});let f=z(!1,{name:"paused"});o.add(f,{name:"paused"});let h=z("running",{name:"status"});o.add(h,{name:"status"});let p=z([],{name:"history",equals:()=>!1});o.add(p,{name:"history"});let c=z(null,{name:"best"});o.add(c,{name:"best"});let b=z(Number.NEGATIVE_INFINITY,{name:"score"});o.add(b,{name:"score"});let x=z(0,{name:"budget-used"});o.add(x,{name:"budget-used"});let N=zn("stages");o.mount("stages",N);let T=N.topic("generate"),g=N.topic("evaluate"),v=N.topic("analyze"),E=N.topic("decide"),w=n,m=null,y=[];o.addDisposer(d.subscribe(A=>{for(let M of A)M[0]===P&&(w=M[1])})),o.addDisposer(u.subscribe(A=>{for(let M of A)M[0]===P&&(m=M[1])})),o.addDisposer(l.subscribe(A=>{for(let M of A)M[0]===P&&(y=M[1])}));let _=ln(a,A=>{let M=w,W=A===0||m==null;return te([],(q,ee)=>{let ve=!1;try{let Te=W?M.seed(t):M.generate(m,y);if(Te instanceof Promise)return Te.then(Ge=>{ve||ee.emit(Ge)},Ge=>{ve||ee.down([[G,Ge]])}),()=>{ve=!0};ee.emit(Te)}catch(Te){ve=!0,ee.down([[G,Te]])}},{describeKind:"producer"})},{name:"candidates"});o.add(_,{name:"candidates"});let R=_e([_],(A,M,W)=>{let q=W.terminalDeps[0];q!==void 0&&q!==!0&&h.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});o.add(R,{name:"error-watcher"}),o.addDisposer(R.subscribe(()=>{}));let O=F([_,a],([A,M])=>({iteration:M,candidates:A,timestamp_ns:oe()}),{name:"generate-event"});o.add(O,{name:"generate-event"}),o.addDisposer(O.subscribe(()=>{}));let k=_e([O],([A])=>{T.publish(A)},{name:"generate-publish"});o.add(k,{name:"generate-publish"}),o.addDisposer(k.subscribe(()=>{}));let S=_e([_],([A])=>{l.emit(A)},{name:"generate-mirror"});o.add(S,{name:"generate-mirror"}),o.addDisposer(S.subscribe(()=>{}));let C=e(_,i);o.add(C,{name:"scores"});let U=F([C,_,a],([A,M,W])=>({iteration:W,candidates:M,scores:A,timestamp_ns:oe()}),{name:"evaluate-event"});o.add(U,{name:"evaluate-event"}),o.addDisposer(U.subscribe(()=>{}));let B=_e([U],([A])=>{g.publish(A)},{name:"evaluate-publish"});o.add(B,{name:"evaluate-publish"}),o.addDisposer(B.subscribe(()=>{}));let ue=F([C,_],([A,M])=>w.analyze(A,M),{name:"feedback"});o.add(ue,{name:"feedback"});let Ne=F([ue,_,a],([A,M,W])=>({iteration:W,candidates:M,feedback:A,timestamp_ns:oe()}),{name:"analyze-event"});o.add(Ne,{name:"analyze-event"}),o.addDisposer(Ne.subscribe(()=>{}));let Ce=_e([Ne],([A])=>{v.publish(A)},{name:"analyze-publish"});o.add(Ce,{name:"analyze-publish"}),o.addDisposer(Ce.subscribe(()=>{}));let Ee=F([p],([A])=>{let M=A;if(r.patience==null||M.length<=r.patience)return!1;let W=M.slice(-(r.patience+1)),q=W[0].bestScore;return W.slice(1).every(ee=>ee.bestScore<=q)},{name:"patience-check"});o.add(Ee,{name:"patience-check"});let be=F([b],([A])=>r.minScore!=null&&A>=r.minScore,{name:"min-score-check"});o.add(be,{name:"min-score-check"});let Me=F([p],([A])=>{let M=A;if(r.minDelta==null||M.length<2)return!1;let W=M[M.length-2].bestScore,q=M[M.length-1].bestScore;return Math.abs(q-W)<r.minDelta},{name:"min-delta-check"});o.add(Me,{name:"min-delta-check"});let D=F([x],([A])=>r.maxEvaluations!=null&&A>=r.maxEvaluations,{name:"max-evaluations-check"});o.add(D,{name:"max-evaluations-check"});let L=F([a],([A])=>r.maxIterations!=null&&A>=r.maxIterations,{name:"max-iterations-check"});o.add(L,{name:"max-iterations-check"});let X=F([x],([A])=>r.budget!=null&&A>=r.budget,{name:"budget-exhausted-check"});o.add(X,{name:"budget-exhausted-check"}),o.addDisposer(Ee.subscribe(()=>{})),o.addDisposer(be.subscribe(()=>{})),o.addDisposer(Me.subscribe(()=>{})),o.addDisposer(D.subscribe(()=>{})),o.addDisposer(L.subscribe(()=>{})),o.addDisposer(X.subscribe(()=>{}));let ye=F([Ee,be,Me,D,L],([A,M,W,q,ee])=>A?{converged:!0,reason:"patience"}:M?{converged:!0,reason:"min-score"}:W?{converged:!0,reason:"min-delta"}:q?{converged:!0,reason:"max-evaluations"}:ee?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});o.add(ye,{name:"converged"}),o.addDisposer(ye.subscribe(()=>{}));let Z=-1,I=_e([ue,C,_],([A,M,W])=>{let q=a.cache,ee=A,ve=W,Te=M;if(q<=Z)return;Z=q;let{best:Ge,bestScore:Hn}=Bn(ve,Te),jn=p.cache,Un={n:q,candidates:ve,scores:Te,feedback:ee,best:Ge,bestScore:Hn,timestamp_ns:oe()},we=[...jn,Un],vt=x.cache+ve.length,ne="continue",Oe,Wn=r.budget!=null&&vt>=r.budget,qn=f.cache;if(Wn)ne="budget",Oe="budget";else if(r.minScore!=null&&ee.score>=r.minScore)ne="converged",Oe="min-score";else if(r.maxIterations!=null&&q>=r.maxIterations)ne="converged",Oe="max-iterations";else if(r.maxEvaluations!=null&&vt>=r.maxEvaluations)ne="converged",Oe="max-evaluations";else if(r.minDelta!=null&&we.length>=2){let Xe=we[we.length-2].bestScore,Tt=we[we.length-1].bestScore;Math.abs(Tt-Xe)<r.minDelta&&(ne="converged",Oe="min-delta")}else if(r.patience!=null&&we.length>r.patience){let Xe=we.slice(-(r.patience+1)),Tt=Xe[0].bestScore;Xe.slice(1).every(Kn=>Kn.bestScore<=Tt)&&(ne="converged",Oe="patience")}ne==="continue"&&qn&&(ne="paused"),le(()=>{c.emit(Ge),b.emit(ee.score),p.emit(we),x.emit(vt),u.emit(ee),E.publish({iteration:q,decision:ne,reason:Oe,timestamp_ns:oe()}),ne==="continue"?a.emit(q+1):h.emit(ne==="converged"?"converged":ne==="budget"?"budget":"paused")})},{name:"decide-bridge"});return o.add(I,{name:"decide-bridge"}),o.addDisposer(I.subscribe(()=>{})),Object.assign(o,{best:c,score:b,status:h,history:p,strategy:d,iteration:a,generate:T,evaluate:g,analyze:v,decide:E,setStrategy(A){d.emit(A)},pause(){f.emit(!0)},resume(){h.cache==="paused"&&le(()=>{f.emit(!1),h.emit("running"),a.emit(a.cache+1)})}})}function bo(t){let e=t.width??4;return{name:t.name??"blindVariation",seed(r){return[r]},analyze(r,s){let o=jt(r),i=null;for(let a of r)(!i||a.score<i.score)&&(i=a);return{summary:`blindVariation iteration: mean=${o.toFixed(3)}, n=${r.length}`,score:o,weakTasks:i?[i.taskId]:[]}},async generate(r,s){if(s.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let o=s[s.length-1],i=0,d={prior:o,reportCost:u=>{i+=u}};try{if(t.parallel!==!1)return await Promise.all(Array.from({length:e},()=>t.teacher(d)));let u=[];for(let l=0;l<e;l++)u.push(await t.teacher(d));return u}finally{if(t.tokens!=null&&i>0){let u=t.tokens.cache??0;t.tokens.emit(u+i)}}}}}function yo(t){return typeof t=="object"&&t!==null&&t.kind==="errorCritique"}function vo(t,e){return t.length===0?`No task scored below the batch mean (${e.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
|
|
8
|
-
${t.map(r=>{let s=r.error!=null?` | error: ${r.error}`:"";return`- ${r.taskId} (score=${r.score.toFixed(3)})${s}`}).join(`
|
|
9
|
-
`)}`}function To(t){let e=t.width??4,n=t.name??"errorCritique",r=t.maxFailureSamples??5,s=t.formatCritique??vo;return{name:n,seed(o){return[o]},analyze(o,i){let a=jt(o),d=typeof t.failureThreshold=="function"?t.failureThreshold(o):t.failureThreshold,u=d===void 0&&!Number.isFinite(a),l=d??a,f=u?[...o].sort((g,v)=>g.score-v.score):o.filter(g=>g.score<l).slice().sort((g,v)=>g.score-v.score),h=f.slice(0,r),{best:p,bestScore:c}=Bn(i,o),b={summary:"",score:a,weakTasks:h.map(g=>g.taskId)},x=s(h,b),N={kind:"errorCritique",best:p,failures:h,critiqueText:x},T=f.length>h.length?` (top ${h.length} retained)`:"";return{summary:`errorCritique iteration: mean=${a.toFixed(3)}, failures=${f.length}${T}/${o.length}, bestScore=${c.toFixed(3)}`,critique:N,weakTasks:h.map(g=>g.taskId),score:a}},async generate(o,i){if(i.length===0)throw new Error("errorCritique.generate: empty candidate batch \u2014 cannot derive prior for teacher");let a=yo(o.critique)?o.critique:void 0,d=a!==void 0?a.best:i[i.length-1],u=a?.critiqueText??o.summary,l=a?.failures??[],f=0,p={prior:d,critique:u,failures:l,reportCost:c=>{f+=c}};try{if(t.parallel!==!1)return await Promise.all(Array.from({length:e},()=>t.teacher(p)));let c=[];for(let b=0;b<e;b++)c.push(await t.teacher(p));return c}finally{if(t.tokens!=null&&f>0){let c=t.tokens.cache??0;t.tokens.emit(c+f)}}}}}0&&(module.exports={blindVariation,errorCritique,refineLoop});
|
|
1
|
+
"use strict";var bt=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var Bn=Object.prototype.hasOwnProperty;var W=(r,e)=>()=>(r&&(e=r(r=0)),e);var jn=(r,e)=>{for(var t in e)bt(r,t,{get:e[t],enumerable:!0})},Hn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of zn(e))!Bn.call(r,o)&&o!==t&&bt(r,o,{get:()=>e[o],enumerable:!(n=Vn(e,o))||n.enumerable});return r};var Un=r=>Hn(bt({},"__esModule",{value:!0}),r);function Ue(){return Ie>0||je}function Ht(){return Ie>0}function Fe(r){Ie>0?He.push(r):r()}function ae(r){Ie+=1;let e=!1;try{r()}catch(t){throw e=!0,t}finally{if(Ie-=1,Ie===0)if(e){if(!je){let t=He.splice(0);for(let n of t)try{n()}catch{}ke.length=0,Re.length=0,Pe.length=0}}else Wn()}}function Wn(){let r=!je;r&&(je=!0);let e=[],t=0;try{for(;ke.length>0||Re.length>0||Pe.length>0||r&&He.length>0;){if(r&&He.length>0){let s=He.splice(0);for(let a of s)try{a()}catch(i){e.push(i)}continue}if(t+=1,t>1e3)throw ke.length=0,Re.length=0,Pe.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(ke.length>0?ke:Re.length>0?Re:Pe).splice(0);for(let s of o)try{s()}catch(a){e.push(a)}}}finally{r&&(je=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function We(r,e,t){if(e.length===0)return;if(e.length===1){let u=t(e[0][0]);if(u<3||!Ue()){r(e);return}(u>=5?Pe:u===4?Re:ke).push(()=>r(e));return}let n=e.length,o=n,s=n,a=n,i=0;for(;i<n&&t(e[i][0])<3;)i++;for(o=i;i<n&&t(e[i][0])===3;)i++;for(s=i;i<n&&t(e[i][0])===4;)i++;a=i;let d=Ue();if(o>0){let u=e.slice(0,o);r(u)}if(s>o){let u=e.slice(o,s);d?ke.push(()=>r(u)):r(u)}if(a>s){let u=e.slice(s,a);d?Re.push(()=>r(u)):r(u)}if(n>a){let u=e.slice(a,n);d?Pe.push(()=>r(u)):r(u)}}var Ie,je,ke,Re,Pe,He,$e=W(()=>{"use strict";Ie=0,je=!1,ke=[],Re=[],Pe=[],He=[]});function J(){return Math.trunc(performance.now()*1e6)}function et(){return Date.now()*1e6}var qe=W(()=>{"use strict"});var ue,I,q,K,re,ie,ce,H,F,G,Se,tt,Ut,nt,Wt,qt,rt,yt,vt,Tt,st,le=W(()=>{"use strict";ue=Symbol.for("graphrefly/START"),I=Symbol.for("graphrefly/DATA"),q=Symbol.for("graphrefly/DIRTY"),K=Symbol.for("graphrefly/RESOLVED"),re=Symbol.for("graphrefly/INVALIDATE"),ie=Symbol.for("graphrefly/PAUSE"),ce=Symbol.for("graphrefly/RESUME"),H=Symbol.for("graphrefly/TEARDOWN"),F=Symbol.for("graphrefly/COMPLETE"),G=Symbol.for("graphrefly/ERROR"),Se=Object.freeze([q]),tt=Object.freeze([K]),Ut=Object.freeze([re]),nt=Object.freeze([ue]),Wt=Object.freeze([F]),qt=Object.freeze([H]),rt=Object.freeze([Se]),yt=Object.freeze([tt]),vt=Object.freeze([Ut]),Tt=Object.freeze([Wt]),st=Object.freeze([qt])});function Yt(r,e){let t=new TextEncoder().encode(r.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${r.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let n=r.version;if(!Number.isInteger(n)||n<0||n>65535)throw new Error(`encodeEnvelope: codec.version ${n} out of u16 range (expected integer 0\u201365535)`);let o=2+t.length+2+e.length;if(o>4294967295)throw new Error(`encodeEnvelope: total envelope size ${o} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let s=new Uint8Array(o),a=0;return s[a++]=_t,s[a++]=t.length,s.set(t,a),a+=t.length,s[a++]=n>>>8&255,s[a++]=n&255,s.set(e,a),s}function Jt(r,e){if(r.length<Kt)throw new Error(`decodeEnvelope: bytes too short (${r.length} < ${Kt})`);let t=0,n=r[t++];if(n!==_t)throw new Error(`decodeEnvelope: unsupported envelope version ${n} (expected ${_t})`);let o=r[t++];if(o===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+o+2>r.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+o+2} bytes, have ${r.length})`);let s=new TextDecoder().decode(r.subarray(t,t+o));t+=o;let a=(r[t]<<8|r[t+1])>>>0;t+=2;let i=r.subarray(t),d=e.lookupCodec(s);if(d==null)throw new Error(`decodeEnvelope: codec "${s}" not registered (envelope codec_v=${a})`);return{codec:d,codecVersion:a,payload:i}}function Xt(r){r.registerCodec(qn)}var qn,_t,Kt,wt=W(()=>{"use strict";qn={name:"json",version:1,contentType:"application/json",encode(r){let e=JSON.stringify(r);return new TextEncoder().encode(e)},decode(r,e){let t=new TextDecoder().decode(r);return JSON.parse(t)}},_t=1,Kt=4});function ot(r){if(r==null)return Le;let{type:e,id:t,...n}=r;return{type:e??"system",id:t??"",...n}}var Le,it=W(()=>{"use strict";Le={type:"system",id:""}});function Zt(r){r.registerMessageType(ue,{tier:0,wireCrossing:!1}),r.registerMessageType(q,{tier:1,wireCrossing:!1}),r.registerMessageType(re,{tier:1,wireCrossing:!1,metaPassthrough:!1}),r.registerMessageType(ie,{tier:2,wireCrossing:!1}),r.registerMessageType(ce,{tier:2,wireCrossing:!1}),r.registerMessageType(I,{tier:3,wireCrossing:!0}),r.registerMessageType(K,{tier:3,wireCrossing:!0}),r.registerMessageType(F,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(G,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(H,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var at,Qt=W(()=>{"use strict";le();at=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let n=this._messageTypes.get(t);return n!=null?n.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=e}registerMessageType(e,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 Nt(r){let e=Kn.filter(t=>r({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 se,Kn,Ke=W(()=>{"use strict";se=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}},Kn=["human","llm","wallet","system"]});function Ot(r){if(r===void 0)return null;if(typeof r=="number"){if(!Number.isFinite(r))throw new TypeError(`Cannot hash non-finite number: ${r}`);if(Number.isInteger(r)&&!Number.isSafeInteger(r))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${r}. Cross-language cid parity is not guaranteed for unsafe integers.`);return r}if(typeof r=="string"||typeof r=="boolean"||r===null)return r;if(Array.isArray(r))return r.map(Ot);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=Ot(r[t]);return e}return null}function Xn(r){let e=Jn.encode(r),t=e.length,n=t*8,o=t+9+63&-64,s=new Uint8Array(o);s.set(e),s[t]=128;let a=new DataView(s.buffer);a.setUint32(o-4,n>>>0,!1),a.setUint32(o-8,Math.floor(n/4294967296)>>>0,!1);let i=1779033703,d=3144134277,u=1013904242,l=2773480762,f=1359893119,p=2600822924,h=528734635,c=1541459225,y=new Uint32Array(64),m=(v,b)=>v>>>b|v<<32-b;for(let v=0;v<o;v+=64){for(let x=0;x<16;x++)y[x]=a.getUint32(v+x*4,!1);for(let x=16;x<64;x++){let A=y[x-15],M=y[x-2],C=m(A,7)^m(A,18)^A>>>3,ee=m(M,17)^m(M,19)^M>>>10;y[x]=y[x-16]+C+y[x-7]+ee>>>0}let b=i,T=d,_=u,k=l,g=f,w=p,E=h,S=c;for(let x=0;x<64;x++){let A=m(g,6)^m(g,11)^m(g,25),M=g&w^~g&E,C=S+A+M+Yn[x]+y[x]>>>0,ee=m(b,2)^m(b,13)^m(b,22),te=b&T^b&_^T&_,he=ee+te>>>0;S=E,E=w,w=g,g=k+C>>>0,k=_,_=T,T=b,b=C+he>>>0}i=i+b>>>0,d=d+T>>>0,u=u+_>>>0,l=l+k>>>0,f=f+g>>>0,p=p+w>>>0,h=h+E>>>0,c=c+S>>>0}let N=v=>v.toString(16).padStart(8,"0");return N(i)+N(d)+N(u)+N(l)+N(f)+N(p)+N(h)+N(c)}function xt(r){let e=Ot(r??null),t=JSON.stringify(e);return Xn(t).slice(0,16)}function Zn(){let r=globalThis.crypto;if(r?.randomUUID)return r.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 Et(r,e,t){let n=t?.id??Zn();if(r===0)return{id:n,version:0};let s=(t?.hash??xt)(e);return{id:n,version:0,cid:s,prev:null}}function en(r,e,t){r.version+=1,"cid"in r&&(r.prev=r.cid,r.cid=t(e))}var Yn,Jn,tn=W(()=>{"use strict";Yn=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]),Jn=new TextEncoder});function sn(r){return{node:r,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function kt(r){r.prevData=void 0,r.dirty=!1,r.involvedThisWave=!1,r.dataBatch.length=0,r.terminal=void 0}function dt(r){return r.length===0?r:typeof r[0]=="symbol"?[r]:r}function Q(r,e,t){let n=on(r)?r:[],o=typeof r=="function"?r:typeof e=="function"?e:void 0,s={};return on(r)?s=(Rt(e)?e:t)??{}:Rt(r)?s=r:s=(Rt(e)?e:t)??{},new B(n,o,s)}var nn,rn,Qn,er,Ve,B,on,Rt,fe=W(()=>{"use strict";wt();it();$e();qe();Qt();Ke();le();tn();nn=()=>{},rn=100;Qn=(r,e,t,n)=>{t.direction==="down-in"&&r._onDepMessage(t.depIndex,e)},er=(r,e,t,n)=>{let o=r;if(o._status==="completed"||o._status==="errored")return;let s=o._cached,a=s===void 0?[nt]:[nt,[I,s]];o._status==="dirty"&&a.push(Se),We(e,a,o._config.tierOf)},Ve=new at({onMessage:Qn,onSubscribe:er});Zt(Ve);Xt(Ve);B=class r{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,n){this._config=n.config??Ve,this._config.onMessage,this._optsName=n.name,this._describeKind=n.describeKind,this._equals=n.equals??Object.is,this._resubscribable=n.resubscribable??!1,this._resetOnTeardown=n.resetOnTeardown??!1,this._autoComplete=n.completeWhenDepsComplete??!0,this._autoError=n.errorWhenDepsError??!0,this._pausable=n.pausable??!0,this._guard=n.guard,this._fn=t,this._partial=n.partial??!1,this._cached=n.initial!==void 0?n.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=n.versioningHash??this._config.defaultHashFn??xt;let o=n.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?Et(o,this._cached===void 0?void 0:this._cached,{id:n.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(sn);let s={};for(let[i,d]of Object.entries(n.meta??{})){let u={initial:d,name:`${n.name??"node"}:meta:${i}`,describeKind:"state",config:this._config};n.guard!=null&&(u.guard=n.guard),s[i]=new r([],void 0,u)}Object.freeze(s),this.meta=s,this._hasMeta=Object.keys(s).length>0;let a=this;this._actions={emit(i){a._emit([[I,i]])},down(i){a._emit(dt(i))},up(i){a._emitUp(dt(i))}},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 n=this._versioningLevel;if(n!=null&&e<=n)return;let o=t?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let s=this._cached===void 0?void 0:this._cached,a=this._versioning,i=a?.id??t?.id,d=a?.version??0,u=Et(e,s,{id:i,hash:o});u.version=d,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=ot(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let n of this._extraGuards)if(!n(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,n=e?.actor!=null;if(!t&&!n)return;let o=ot(e?.actor),s=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,s))throw new se({actor:o,action:s,nodeName:this.name});if(this._extraGuards!=null){for(let a of this._extraGuards)if(!a(o,s))throw new se({actor:o,action:s,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:et()}}down(e,t){let n=dt(e);n.length!==0&&(this._checkGuard(t),this._emit(n))}emit(e,t){this._checkGuard(t),this._emit([[I,e]])}up(e,t){if(this._deps.length===0)return;let n=dt(e);if(n.length===0)return;this._checkGuard(t);let o=t??{internal:!0};this._validateUpTiers(n);for(let s of this._deps)s.node.up?.(n,o)}_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 n of e){let o=t(n[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,t){if(t!=null&&this._guard!=null){let d=ot(t);if(!this._guard(d,"observe"))throw new se({actor:d,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 d of this._deps)kt(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let s;try{s=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:o},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let a=this._isTerminal;if(this._sinkCount===1&&!a)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof s=="function")try{s()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let i=!1;return()=>{i||(i=!0,this._sinkCount-=1,this._removeSink(e),typeof s=="function"&&s(),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 n=0;n<e;n++){let o=n,s=this._deps[n];s.unsub=nn,s.unsub=s.node.subscribe(a=>{if(s.unsub===null)return;let i=this._config.tierOf,d=!1;for(let u of a)i(u[0])>=3&&(d=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:o},this._actions);d&&this._maybeRunFnOnSettlement()}),t++}}catch(n){this._deps[t].unsub=null;for(let o=0;o<t;o++){let s=this._deps[o];if(s.unsub!=null){let a=s.unsub;s.unsub=null;try{a()}catch{}kt(s)}}throw this._dirtyDepCount=0,n}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let t=this._deps.length,n=sn(e);if(this._deps.push(n),this._sinks==null)return t;n.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(rt),n.unsub=nn;try{n.unsub=e.subscribe(o=>{if(n.unsub===null)return;let s=this._config.tierOf,a=!1;for(let i of o)s(i[0])>=3&&(a=!0),this._config.onMessage(this,i,{direction:"down-in",depIndex:t},this._actions);a&&this._maybeRunFnOnSettlement()})}catch(o){throw n.unsub=null,this._deps.pop(),this._dirtyDepCount--,o}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(n){this._emit([[G,this._wrapFnError("cleanup threw",n)]])}else if(t!=null&&typeof t=="object"){let n=t.deactivate;if(typeof n=="function")try{n()}catch(o){this._emit([[G,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let n of this._deps){if(n.unsub!=null){let o=n.unsub;n.unsub=null;try{o()}catch{}}kt(n)}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 n=this._deps[e],o=t[0];if(this._inspectorHooks!=null){let s={kind:"dep_message",depIndex:e,message:t};for(let a of this._inspectorHooks)a(s)}if(o!==ue){if(o===q){this._depDirtied(n);return}if(o===re){if(this._depInvalidated(n),this._cached===void 0)return;this._emit(vt);return}if(o===ie||o===ce){this._emit([t]);return}if(o===H){this._emit(st);return}if(o===I)this._depSettledAsData(n,t[1]);else if(o===K)this._depSettledAsResolved(n);else if(o===F)this._depSettledAsTerminal(n,!0);else if(o===G)this._depSettledAsTerminal(n,t[1]);else{this._emit([t]);return}if(!this._fn){(o===I||o===K)&&this._emit([t]),(o===F||o===G)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(rt))}_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._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let t=this._deps[e];if(t.dataBatch.length===0&&t.prevData===void 0&&t.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(yt),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([[G,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(Tt)}_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(a){this._emit([[G,this._wrapFnError("cleanup threw",a)]]);return}}else if(e!=null&&typeof e=="object"){let a=e.beforeRun;if(typeof a=="function"){e.beforeRun=void 0;try{a()}catch(i){this._emit([[G,this._wrapFnError("cleanup.beforeRun threw",i)]]);return}}}let t=this._deps.map(a=>a.involvedThisWave?a.dataBatch.length>0?[...a.dataBatch]:[]:void 0),n=this._deps.map(a=>a.prevData);for(let a=0;a<this._deps.length;a++){let i=t[a];i!=null&&i.length>0&&(this._deps[a].prevData=i[i.length-1])}let o=this._deps.map(a=>a.terminal),s={prevData:n,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let a={kind:"run",batchData:t,prevData:n};for(let i of this._inspectorHooks)i(a)}this._isExecutingFn=!0;try{let a=this._fn(t,this._actions,s);if(typeof a=="function")this._cleanup=a;else if(a!=null&&typeof a=="object"){let i=a;(typeof i.beforeRun=="function"||typeof i.deactivate=="function"||typeof i.invalidate=="function")&&(this._cleanup=a)}}catch(a){this._emit([[G,this._wrapFnError("fn threw",a)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>rn?(this._rerunDepth=0,this._emit([[G,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${rn} \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 n=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${n}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[Se,e[0]]:e;let n=!0,o=!1,s=!1,a=-1;for(let d of e){let u=t(d[0]);u<a&&(n=!1),u===3&&(o=!0),d[0]===q&&(s=!0),a=u}let i=e;if(!n){let d=e.map((u,l)=>({m:u,i:l,tier:t(u[0])}));d.sort((u,l)=>u.tier-l.tier||u.i-l.i),i=d.map(u=>u.m)}if(o&&!s&&this._status!=="dirty"){let d=0;for(;d<i.length&&t(i[d][0])===0;)d++;return d===0?[Se,...i]:[...i.slice(0,d),Se,...i.slice(d)]}return i}_emit(e){if(e.length===0)return;for(let i=0;i<e.length;i++){let d=e[i];if(d[0]===G&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let i=e.filter(d=>d[0]===H||d[0]===re);if(i.length===0)return;t=i}t=this._frameBatch(t);let o=null;for(let i=0;i<t.length;i++){let d=t[i],u=d[0];if(u!==ie&&u!==ce){o?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===ie?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let l=!0;if(this._pausable!==!1){let f=d[1];if(u===ie)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))l=!1;else if(this._pauseLocks.delete(f),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}l?o?.push(d):o==null&&(o=t.slice(0,i))}if(o!=null){if(o.length===0)return;t=o}if(this._hasMeta&&t.some(i=>i[0]===H))for(let i of Object.keys(this.meta))try{this.meta[i]._emit(st)}catch{}let{finalMessages:s,equalsError:a}=this._updateState(t);if(s.length>0&&this._config.inspectorEnabled){let i=this._config.globalInspector;if(i!=null)try{i({kind:"emit",node:this,messages:s})}catch{}}if(s.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let i=this._config.tierOf,d=[];for(let u of s)i(u[0])===3?this._pauseBuffer.push(u):d.push(u);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(s);a!=null&&this._emit([[G,a]])}_updateState(e){let t=this._config.tierOf,n,o,s=-1,a=0;for(let l of e)t(l[0])===3&&a++;let i=a<=1,d=-1;if(this._versioning!=null&&a>1){for(let l=e.length-1;l>=0;l--)if(e[l][0]===I){d=l;break}}for(let l=0;l<e.length;l++){let f=e[l],p=f[0];if(p===I){if(f.length>=2){let h=!1;if(i&&this._cached!==void 0)try{h=this._equals(this._cached,f[1])}catch(c){o=this._wrapFnError("equals threw",c),s=l;break}if(h){n==null&&(n=e.slice(0,l)),n.push(tt),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(d<0||l===d)&&en(this._versioning,f[1],this._hashFn)}this._status="settled",n?.push(f)}else if(n?.push(f),p===q)this._status="dirty";else if(p===K)this._status="resolved";else if(p===F){this._status="completed";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===G){this._status="errored";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===re){if(this._cached!==void 0){let c=this._config.rigorRecorder;if(c!=null)try{c.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let c=h.invalidate;if(typeof c=="function")try{c()}catch{}}}else p===H&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=s>=0?n??e.slice(0,s):n??e;return o!=null?{finalMessages:u,equalsError:o}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let n of t)n(e)};_dispatchOrAccumulate(e){if(Ht()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Fe(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}We(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);We(this._deliverToSinks,t,this._config.tierOf)}},on=r=>Array.isArray(r),Rt=r=>typeof r=="object"&&r!=null&&!Array.isArray(r)});function $(r,e){return Q([],{...e,initial:r})}function Te(r,e){return Q((n,o,s)=>r(o,s)??void 0,{describeKind:"producer",...e})}function L(r,e,t){return Q(r,(o,s,a)=>{let i=o.map((d,u)=>d!=null&&d.length>0?d.at(-1):a.prevData[u]);s.emit(e(i,a))},{describeKind:"derived",...t})}function _e(r,e,t){return Q(r,(o,s,a)=>{let i=o.map((d,u)=>d!=null&&d.length>0?d.at(-1):a.prevData[u]);return e(i,s,a)??void 0},{describeKind:"effect",...t})}var ze=W(()=>{"use strict";fe()});function St(r,e){if(e!=null&&e.length>0)return new Set(e);switch(r){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function tr(r){return r._describeKind!=null?r._describeKind:r._deps.length>0?"derived":r._fn!=null?"producer":"state"}function an(r,e){let t={factory:r};return e!==void 0&&(t.factoryArgs=e),t}function nr(r){let e={};for(let[t,n]of Object.entries(r.meta))try{e[t]=n.cache}catch{}return e}function Dt(r,e,t){let n=e==null,o=!n&&e!=null?[...e].filter(l=>l.startsWith("meta.")).map(l=>l.slice(5)):null,s=n||e.has("meta")||o!=null&&o.length>0,a="state",i=[];r instanceof B&&(a=tr(r),i=r._deps.map(l=>l.node.name??""));let d={type:a,deps:i};(n||e.has("status"))&&(d.status=r.status);let u=r instanceof B?r._guard:void 0;if(s){let l={...nr(r)};if(u!=null&&l.access===void 0&&(l.access=Nt(u)),o!=null&&o.length>0&&!e.has("meta")){let f={};for(let p of o)p in l&&(f[p]=l[p]);d.meta=f}else d.meta=l}if(r.name!=null&&(d.name=r.name),(n||e.has("value"))&&(!t||a==="state")){r.status==="sentinel"&&(d.sentinel=!0);try{d.value=r.cache}catch{}}if((n||e.has("v"))&&r.v!=null){let l={id:r.v.id,version:r.v.version};"cid"in r.v&&(l.cid=r.v.cid,l.prev=r.v.prev),d.v=l}return(n||e.has("guard"))&&u!=null&&(d.guard=Nt(u)),(n||e.has("lastMutation"))&&r.lastMutation!=null&&(d.lastMutation=r.lastMutation),d}var At=W(()=>{"use strict";Ke();fe()});function Ct(r){return{describeKind:"producer",...r}}function dn(r,e){return Te(t=>{let n=!1;try{for(let o of r){if(n)return;t.emit(o)}n||t.down([[F]])}catch(o){n||t.down([[G,o]])}return()=>{n=!0}},Ct(e))}function rr(r){return r!=null&&typeof r.then=="function"}function sr(r,e){let{signal:t,...n}=e??{};return Te(o=>{let s=!1,a=()=>{s||(s=!0,o.down([[G,t.reason]]))};if(t?.aborted){a();return}return t?.addEventListener("abort",a,{once:!0}),Promise.resolve(r).then(i=>{s||(s=!0,t?.removeEventListener("abort",a),o.emit(i),o.down([[F]]))},i=>{s||(s=!0,t?.removeEventListener("abort",a),o.down([[G,i]]))}),()=>{s=!0,t?.removeEventListener("abort",a)}},Ct(n))}function or(r,e){let{signal:t,...n}=e??{};return Te(o=>{let s=new AbortController,a=()=>s.abort(t?.reason);t?.aborted?s.abort(t.reason):t?.addEventListener("abort",a,{once:!0});let i=t??s.signal,d=!1,u=r[Symbol.asyncIterator](),l=()=>{d||i.aborted||Promise.resolve(u.next()).then(f=>{if(!(d||i.aborted)){if(f.done){o.down([[F]]);return}o.emit(f.value),l()}},f=>{!d&&!i.aborted&&o.down([[G,f]])})};return l(),()=>{d=!0,t?.removeEventListener("abort",a),s.abort(),Promise.resolve(u.return?.()).catch(()=>{})}},Ct(n))}function ir(r){return r!=null&&typeof r=="object"&&"cache"in r&&typeof r.subscribe=="function"}function un(r,e){if(ir(r))return r;if(rr(r))return sr(r,e);if(r!=null){let t=r;if(typeof t[Symbol.asyncIterator]=="function")return or(r,e);if(typeof t[Symbol.iterator]=="function")return dn(r,e)}return ar(r)}function ar(...r){return dn(r,void 0)}function pe(r){return r.subscribe(()=>{})}var cn=W(()=>{"use strict";le();ze()});var ut=W(()=>{"use strict";cn()});var ct,pn=W(()=>{"use strict";ct=class{_timer;_gen=0;start(e,t){this.cancel(),this._gen+=1;let n=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,n===this._gen&&t()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Ye,hn=W(()=>{"use strict";Ye=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}}});function Sn(r,e,t){return{[r]:!0,[`${r}_type`]:e,...t??{}}}var Dn=W(()=>{"use strict"});var Ir={};jn(Ir,{blindVariation:()=>Ar,errorCritique:()=>Gr,refineLoop:()=>Dr});module.exports=Un(Ir);$e();qe();le();fe();ze();le();At();fe();ut();function dr(r){return{describeKind:"derived",...r}}function ur(r,e,t){let n,o=!1,s=()=>{o||(o=!0,t())};return n=r.subscribe(a=>{let i=!1,d=!1;for(let u of a)u[0]!==ue&&(u[0]===I?e.emit(u[1]):u[0]===F?i=!0:u[0]===G?(d=!0,e.down([u])):(u[0]===q||u[0]===K)&&e.down([u]));d?(n?.(),n=void 0,s()):i&&s()}),()=>{n?.(),n=void 0}}function ln(r,e,t){let n,o=!1;function s(){n?.(),n=void 0}return Q([r],(a,i,d)=>{if(d.terminalDeps[0]!=null&&d.terminalDeps[0]!==!0){s();return}if(d.terminalDeps[0]===!0){o=!0,n||i.down([[F]]);return}let u=a[0];if(!(u==null||u.length===0))return s(),n=ur(un(e(u[u.length-1])),i,()=>{s(),o&&i.down([[F]])}),{deactivate:()=>{s(),o=!1}}},{...dr(t),completeWhenDepsComplete:!1,meta:{...an("switchMap"),...t?.meta??{}}})}it();$e();qe();Ke();le();At();fe();ze();qe();function Mt(r,e){if(Object.is(r,e))return!0;if(r==null||e==null||typeof r!="object"||typeof e!="object")return!1;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(let s=0;s<r.length;s++)if(!Mt(r[s],e[s]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;let o=new Set(n);for(let s of t)if(!o.has(s)||!Mt(r[s],e[s]))return!1;return!0}function fn(r,e){return`${r}\0${e}`}function Gt(r,e){let t=[],n=new Set(r.subgraphs),o=new Set(e.subgraphs),s=[];for(let m of o)n.has(m)||s.push(m);s.sort();for(let m of s)t.push({type:"subgraph-mounted",path:m});let a=new Set(Object.keys(r.nodes)),i=new Set(Object.keys(e.nodes)),d=[];for(let m of i)a.has(m)||d.push(m);d.sort();for(let m of d)t.push({type:"node-added",path:m,node:{...e.nodes[m]}});let u=[];for(let m of i){if(!a.has(m))continue;let N=r.nodes[m]?.meta,v=e.nodes[m]?.meta;N==null&&v==null||Mt(N??{},v??{})||u.push(m)}u.sort();for(let m of u)t.push({type:"node-meta-changed",path:m,prevMeta:r.nodes[m]?.meta??{},nextMeta:e.nodes[m]?.meta??{}});let l=new Map;for(let m of r.edges)l.set(fn(m.from,m.to),m);let f=new Map;for(let m of e.edges)f.set(fn(m.from,m.to),m);let p=[];for(let[m,N]of f)l.has(m)||p.push(N);p.sort((m,N)=>m.from<N.from?-1:m.from>N.from?1:m.to<N.to?-1:m.to>N.to?1:0);for(let m of p)t.push({type:"edge-added",from:m.from,to:m.to});let h=[];for(let[m,N]of l)f.has(m)||h.push(N);h.sort((m,N)=>m.from<N.from?-1:m.from>N.from?1:m.to<N.to?-1:m.to>N.to?1:0);for(let m of h)t.push({type:"edge-removed",from:m.from,to:m.to});let c=[];for(let m of a)i.has(m)||c.push(m);c.sort();for(let m of c)t.push({type:"node-removed",path:m});let y=[];for(let m of n)o.has(m)||y.push(m);y.sort();for(let m of y)t.push({type:"subgraph-unmounted",path:m});return{events:t,flushedAt_ns:J()}}ut();pn();hn();wt();function mn(r,e,t,n={}){let o=e in r.nodes,s=t in r.nodes;if(!o)return lt(e,t,"no-such-from");if(!s)return lt(e,t,"no-such-to");let a=n.maxDepth;if(a!=null&&(!Number.isInteger(a)||a<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(n.findCycle===!0){let u=cr(r,e,n);if(u!=null)return u}let d=ft(e,r.nodes[e],0,n);return pt(e,t,[d])}if(a===0)return lt(e,t,"no-path");let i=gn(r,e,t,a);return i.found?pt(e,t,bn(r,i.pathOrder,n)):lt(e,t,i.truncated?"max-depth-exceeded":"no-path")}function gn(r,e,t,n){let o=new Map,s=[{path:t,depth:0}],a=new Set([t]),i=0,d=!1;for(;i<s.length;){let f=s[i++];if(f.path===e)break;if(n!=null&&f.depth>=n){let y=r.nodes[f.path];y?.deps&&y.deps.length>0&&(d=!0);continue}let p=r.nodes[f.path];if(p==null)continue;let h=p.deps??[],c=new Map;for(let y=0;y<h.length;y++){let m=h[y];if(!m)continue;let N=c.get(m);N==null&&(N=[],c.set(m,N)),N.push(y)}for(let[y,m]of c)a.has(y)||(a.add(y),o.set(y,{from:f.path,depIndices:m}),s.push({path:y,depth:f.depth+1}))}if(!o.has(e))return{found:!1,pathOrder:[],truncated:d};let u=[{path:e}],l=e;for(;l!==t;){let f=o.get(l);if(f==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=f.depIndices,u.push({path:f.from}),l=f.from}return{found:!0,pathOrder:u,truncated:!1}}function cr(r,e,t){let n=r.nodes[e];if(n==null)return null;let o=n.deps??[],s=[];for(let i=0;i<o.length;i++)o[i]===e&&s.push(i);if(s.length>0){let i=ft(e,n,0,t);i.dep_index=s[0];let d=ft(e,n,1,t);return pt(e,e,[i,d])}let a=null;for(let i=0;i<o.length;i++){let d=o[i];if(!d||d===e)continue;let u=gn(r,d,e,t.maxDepth);u.found&&(a==null||u.pathOrder.length<a.pathOrder.length)&&(a=u,a={found:!0,pathOrder:[{path:e,depIndices:[i]},...u.pathOrder],truncated:!1})}return a==null?null:pt(e,e,bn(r,a.pathOrder,t))}function bn(r,e,t){return e.map((n,o)=>{let s=r.nodes[n.path],a=ft(n.path,s,o,t);return n.depIndices!=null&&n.depIndices.length>0&&(a.dep_index=n.depIndices[0],n.depIndices.length>1&&(a.dep_indices=[...n.depIndices])),a})}function ft(r,e,t,n){let o={path:r,type:e.type,hop:t};e.status!==void 0&&(o.status=e.status),"value"in e&&(o.value=e.value),e.v!=null&&(o.v=e.v);let s=n.annotations?.get(r)??e.annotation;s!=null&&(o.annotation=s);let a=n.lastMutations?.get(r)??e.lastMutation;return a!=null&&(o.lastMutation=a),o}function pt(r,e,t){return yn(r,e,!0,"ok",t)}function lt(r,e,t){return yn(r,e,!1,t,[])}function yn(r,e,t,n,o){let s=lr(r,e,t,n,o);return{from:r,to:e,found:t,reason:n,steps:o,text:s,toJSON(){return{from:r,to:e,found:t,reason:n,steps:o}}}}function lr(r,e,t,n,o){if(!t)switch(n){case"no-such-from":return`explainPath: no node named "${r}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${r}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${r}" to "${e}"`}let s=[`Causal path: ${r} \u2192 ${e} (${o.length} step(s))`];for(let a of o){let d=` ${a.hop===0?"\xB7":"\u2193"} ${a.path} (${a.type}${a.status?`/${a.status}`:""})`;if(s.push(d),"value"in a&&s.push(` value: ${fr(a.value)}`),a.annotation!=null&&s.push(` annotation: ${a.annotation}`),a.lastMutation!=null){let u=a.lastMutation.actor;s.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return s.join(`
|
|
2
|
+
`)}function fr(r){if(r===void 0)return"<sentinel>";if(r===null)return"null";if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean"||typeof r=="bigint")return String(r);try{let e=JSON.stringify(r);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(r)}}fe();var j={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},pr=Symbol.for("sizeof");function vn(r){let e=new WeakSet,t=new WeakSet,n=[r],o=0;for(;n.length>0;){let s=n.pop();o+=hr(s,e,t,n)}return o}function hr(r,e,t,n){if(r==null)return 0;switch(typeof r){case"number":return j.number;case"boolean":return j.boolean;case"string":return j.string+r.length*2;case"bigint":return j.bigint+mr(r);case"symbol":return j.symbol;case"function":return e.has(r)?0:(e.add(r),j.function);case"undefined":return 0}let s=r;if(e.has(s))return 0;e.add(s);let a=s[pr];if(typeof a=="function")try{let u=a.call(s);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(s instanceof Date)return j.date;if(s instanceof RegExp)return j.regexp+s.source.length*2;if(s instanceof Error){let u=s.message?s.message.length*2:0,l=s.stack?s.stack.length*2:0;return j.error+u+l}if(typeof URL<"u"&&s instanceof URL)return j.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return j.promise;if(s instanceof WeakMap)return j.weakmap;if(s instanceof WeakSet)return j.weakset;if(s instanceof Map){let u=j.map;for(let[l,f]of s)u+=j.mapEntry,n.push(l),n.push(f);return u}if(s instanceof Set){let u=j.set;for(let l of s)u+=j.setEntry,n.push(l);return u}if(Array.isArray(s)){let u=j.array+s.length*8;for(let l of s)n.push(l);return u}if(s instanceof ArrayBuffer)return t.has(s)?0:(t.add(s),s.byteLength);if(ArrayBuffer.isView(s)){let u=s;return t.has(u.buffer)?48:(t.add(u.buffer),u.buffer.byteLength+48)}let i=j.object,d=Object.keys(s);for(let u of d){i+=j.string+u.length*2;try{n.push(s[u])}catch{}}return i}function mr(r){let e=r<0n?-r:r;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}function Tn(r,e){let t=e?.topN??10,n=r.describe({detail:"standard"}),o=[],s=r._collectObserveTargets;typeof s=="function"&&s.call(r,"",o);let a=new Map;for(let[p,h]of o)a.set(p,h);let i=[];for(let[p,h]of Object.entries(n.nodes)){let c=a.get(p),y=c instanceof B?c:null,m=y?vn(y.cache):0,N=y?y._sinkCount:0,v=h.deps?.length??0,b=h.type==="effect"&&N===0,T=N===0?h.type==="effect"?"orphan-effect":h.type==="derived"?"idle-derived":h.type==="producer"?"idle-producer":null:null;i.push({path:p,type:h.type,status:h.status??"unknown",valueSizeBytes:m,subscriberCount:N,depCount:v,isOrphanEffect:b,orphanKind:T})}let d=i.reduce((p,h)=>p+h.valueSizeBytes,0),u=(p,h)=>[...i].sort(h??((c,y)=>y[p]-c[p])).slice(0,t),l=i.filter(p=>p.orphanKind!=null),f=i.filter(p=>p.isOrphanEffect);return{nodeCount:i.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:i,totalValueSizeBytes:d,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:l,orphanEffects:f}}var V="::",oe="__meta__",De=1;function _n(r,e){let t=Math.max(16,r.size*4),n=0;for(;r.size>0;){if(n++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${r.size} disposer(s) discarded`),r.clear();return}let o=r.values().next();if(o.done)return;let s=o.value;r.delete(s);try{s()}catch(a){console.error(`[Graph "${e}".destroy] disposer threw:`,a)}}}function En(r){return r!=null&&typeof r=="object"&&"cache"in r&&typeof r.subscribe=="function"&&typeof r.down=="function"}function gr(r){if(r!=null)return En(r)?r.cache:r}function Ae(r){return r!=null&&typeof r=="object"&&"cache"in r&&typeof r.subscribe=="function"&&typeof r.down=="function"}function we(r){return Ae(r)?r.cache??"":r}function wn(r){return Ae(r)?r.cache??0:r}function Nn(r){return Ae(r)?r.cache??!1:r}function br(r){let e=[];for(let t of Object.keys(r).sort()){let n=r[t].v;n!=null&&e.push(`${t} ${n.id} ${n.version}`)}return e.join(`
|
|
3
|
+
`)}function On(r){if(r.version!==De)throw new Error(`unsupported snapshot version ${String(r.version)} (expected ${De})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in r))throw new Error(`snapshot missing required key "${e}"`);if(typeof r.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof r.nodes!="object"||r.nodes===null||Array.isArray(r.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(r.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(r.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function yr(r,e){let t=new WeakMap,n=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let a=t.get(o);if(a==null&&(a=new WeakSet,t.set(o,a)),a.has(s))return!0;a.add(s);let i=o.constructor,d=s.constructor;if(i!==d)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let p=s;if(o.length!==p.length)return!1;for(let h=0;h<o.length;h++)if(!n(o[h],p[h]))return!1;return!0}if(o instanceof Map){let p=s;if(o.size!==p.size)return!1;for(let[h,c]of o)if(!p.has(h)||!n(c,p.get(h)))return!1;return!0}if(o instanceof Set){let p=s;if(o.size!==p.size)return!1;for(let h of o){let c=!1;for(let y of p)if(n(h,y)){c=!0;break}if(!c)return!1}return!0}if(ArrayBuffer.isView(o)){let p=o,h=s;if(p.length!==h.length)return!1;for(let c=0;c<p.length;c++)if(p[c]!==h[c])return!1;return!0}let u=Object.keys(o),l=Object.keys(s);if(u.length!==l.length)return!1;let f=new Set(l);for(let p of u)if(!f.has(p)||!n(o[p],s[p]))return!1;return!0};return n(r,e)}function vr(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ht(r){let e="^";for(let t=0;t<r.length;t+=1){let n=r[t];if(n==="*"){e+=".*";continue}if(n==="?"){e+=".";continue}if(n==="["){let o=r.indexOf("]",t+1);if(o<=t+1){e+="\\[";continue}let s=r.slice(t+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,t=o;continue}e+=vr(n)}return e+="$",new RegExp(e)}var Tr={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},_r={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function It(r){if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean"||r==null)return String(r);try{return JSON.stringify(r)}catch{return"[unserializable]"}}function wr(r){return r==="none"?_r:r==="ansi"||r==null?Tr:{data:r.data??"",dirty:r.dirty??"",resolved:r.resolved??"",invalidate:r.invalidate??"",pause:r.pause??"",resume:r.resume??"",complete:r.complete??"",error:r.error??"",teardown:r.teardown??"",derived:r.derived??"",path:r.path??"",reset:r.reset??""}}function xn(r){if(r==null)return{};let e=r.detail;return e==="full"?{...r,structured:r.structured??!0,timeline:r.timeline??!0,causal:r.causal??!0,derived:r.derived??!0}:e==="minimal"?{...r,structured:r.structured??!0}:r.format==="stage-log"?{...r,structured:r.structured??!0,timeline:r.timeline??!0}:r}function Nr(r,e,t){for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);if(o<32||o===127)throw new Error(`Graph "${e}": ${t} "${r}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function Pt(r,e,t){if(r==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(r.includes(V))throw new Error(`Graph "${e}": ${t} "${r}" must not contain '${V}' (path separator)`);if(r===oe)throw new Error(`Graph "${e}": ${t} name "${oe}" is reserved for meta companion paths`);Nr(r,e,t)}function Or(r,e){if(r==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=r.split(V);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function xr(r,e){let t=!1;for(let o of r)if(!e.isMetaPassthrough(o[0])){t=!0;break}return t?r.filter(o=>e.isMetaPassthrough(o[0])):r}function kn(r){for(let e of r._mounts.values())kn(e);for(let e of r._nodes.values())try{e.down([[H]],{internal:!0})}catch{}}var de=class r{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(V))throw new Error(`Graph name must not contain '${V}' (got "${e}")`);if(e===oe)throw new Error(`Graph name "${oe}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??Ve,this._traceRing=new Ye(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning),typeof t?.factory=="string"&&(this._factory=t.factory,t.factoryArgs!==void 0&&(this._factoryArgs=t.factoryArgs))}tagFactory(e,t){return this._factory=e,this._factoryArgs=t,this}ancestors(e=!0){let t=[],n=e?this:this._parent;for(;n!=null;)t.push(n),n=n._parent;return t}get topology(){return this._topology==null&&(this._topology=Te(e=>{let t=n=>{e.emit(n)};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)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let n=e.name,o=t?.name??n;if(o==null||o==="")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 s=o,a=t?.annotation;if(Pt(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let i=this._nodeToName.get(e);if(i!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${i}"`);return this._nodes.set(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),a!=null&&(this._annotations.set(s,a),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:a,timestamp_ns:J()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof B&&t._applyVersioning(e)}remove(e){Pt(e,this.name,"remove");let t=this._mounts.get(e);if(t){let s={kind:"mount",nodes:[],mounts:[]},a=[];t._collectObserveTargets("",a);for(let[i,d]of a)i.includes(`${V}${oe}${V}`)||s.nodes.push(i);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...t._collectSubgraphs(`${e}${V}`)),this._mounts.delete(e),t._parent=void 0,kn(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(n),n.down([[H]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let t=typeof e=="function"?e:(()=>{let s=ht(e);return a=>s.test(a)})(),n={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>t(s));for(let s of o){let a=this.remove(s);n.nodes.push(...a.nodes),n.mounts.push(...a.mounts)}return n.nodes.sort(),n.mounts.sort(),n}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,n=0;return{[Symbol.iterator](){return this},next(){if(n>=e.length)return{value:void 0,done:!0};let o=e[n++];return{value:[o,t.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(V))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,n){let o=n?.internal===!0;this.node(e).down([[I,t]],{actor:n?.actor,internal:o,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);ae(()=>{for(let[o,s]of n)this.set(o,s,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[re]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let o=n?.internal===!0;this.node(e).down([[G,t]],{actor:n?.actor,internal:o,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[F]],{actor:t?.actor,internal:n,delivery:"write"})}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[d,u]of this._nodes)n.set(u,d);let i=[];for(let[d,u]of this._nodes)if(u instanceof B)for(let l of u._deps){let f=n.get(l.node);f!=null&&i.push([f,d])}return i.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),i}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[i,d]of o)s.set(d,i);let a=[];for(let[i,d]of o)if(d instanceof B)for(let u of d._deps){let l=s.get(u.node);l!=null&&a.push([l,i])}return a.sort((i,d)=>i[0]<d[0]?-1:i[0]>d[0]?1:i[1]<d[1]?-1:i[1]>d[1]?1:0),a}mount(e,t){if(t===void 0){let o=new r(e);return this.mount(e,o)}if(typeof t=="function"){let o=new r(e);return t(o),this.mount(e,o)}let n=t;if(Pt(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(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let o=this;o!=null;o=o._parent)if(o===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let t=Or(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 n=t[0],o=t.slice(1);if(o.length===0){let i=this._nodes.get(n);if(i)return i;throw this._mounts.has(n)?new Error(`Graph "${this.name}": path ends at subgraph "${n}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${n}"`)}let s=this._nodes.get(n);if(s&&o.length>0&&o[0]===oe)return this._resolveMetaChainFromNode(s,o,t.join(V));let a=this._mounts.get(n);if(!a)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${o.join(V)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return a.resolve(o.join(V))}_resolveMetaChainFromNode(e,t,n){let o=e,s=0,a=[...t];for(;s<a.length;){if(a[s]!==oe)throw new Error(`Graph "${this.name}": expected ${oe} segment in meta path "${n}"`);if(s+1>=a.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${oe} in "${n}"`);let i=a[s+1],d=o.meta[i];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${i}" in path "${n}"`);o=d,s+=2}return o}signal(e,t){if(t?.internal!==!0){for(let o of e)if(this.config.messageTier(o[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 n=[];if(this._signalDeliver(e,t??{},new Set,n),n.length>0)throw n[0]}_signalDeliver(e,t,n,o){for(let d of this._mounts.values())d._signalDeliver(e,t,n,o);let a=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},i=xr(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!n.has(u)){n.add(u);try{u.down(e,a)}catch(l){if(l instanceof se)throw l;o.push(l)}i.length!==0&&this._signalMetaSubtree(u,i,n,a,o)}}}_signalMetaSubtree(e,t,n,o,s){for(let a of Object.keys(e.meta).sort()){let i=e.meta[a];if(!n.has(i)){n.add(i);try{i.down(t,o)}catch(d){if(d instanceof se)throw d;s.push(d)}this._signalMetaSubtree(i,t,n,o,s)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=gr(e?.actor),n=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let o=St(e?.detail,e?.fields),s=e?.detail==="spec",a=o,i=[];this._collectObserveTargets("",i);let d=new Map;for(let[T,_]of i)d.set(_,T);let u=[];{let T=i.map(([,g])=>g),_=new Set(d.values()),k=0;for(;T.length>0;){let g=T.shift();if(g instanceof B)for(let w of g._deps){let E=w.node;if(d.has(E))continue;let S=E.name??"",x=S;if(!x||_.has(x))if(S){let A=2;for(;_.has(`${S}#${A}`);)A++;x=`${S}#${A}`}else for(x=`__internal__/${k++}`;_.has(x);)x=`__internal__/${k++}`;d.set(E,x),_.add(x),u.push([x,E]),T.push(E)}}}let l=[...i,...u],f={};for(let[T,_]of l){if(t!=null&&!_.allowsObserve(t))continue;let k=Dt(_,a,s),g=_ instanceof B?_._deps.map(x=>d.get(x.node)??x.node.name??""):[],{name:w,...E}=k,S={...E,deps:g};if(!s){let x=this._annotations.get(T);x!=null&&(S.annotation=x)}if(n!=null)if(typeof n=="function"){let x=n;if(!(x.length>=2?x(T,S):x(S)))continue}else{let x=!0;for(let[A,M]of Object.entries(n)){let C=A==="deps_includes"?"depsIncludes":A==="meta_has"?"metaHas":A;if(C==="depsIncludes"){if(!S.deps.includes(String(M))){x=!1;break}continue}if(C==="metaHas"){if(!Object.hasOwn(S.meta??{},String(M))){x=!1;break}continue}if(S[C]!==M){x=!1;break}}if(!x)continue}f[T]=S}let p=new Set(Object.keys(f)),h=[];for(let[T,_]of l)if(_ instanceof B)for(let k of _._deps){let g=d.get(k.node);g!=null&&h.push([g,T])}h.sort((T,_)=>T[0]<_[0]?-1:T[0]>_[0]?1:T[1]<_[1]?-1:T[1]>_[1]?1:0);let c=h.map(([T,_])=>({from:T,to:_}));(t!=null||n!=null)&&(c=c.filter(T=>p.has(T.from)&&p.has(T.to)));let y=this._collectSubgraphs(""),m=t!=null||n!=null?y.filter(T=>{let _=`${T}${V}`;return[...p].some(k=>k===T||k.startsWith(_))}):y,N=this,v=e;return{name:this.name,nodes:f,edges:c,subgraphs:m,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(T){let _={...v};return Array.isArray(T)?(_.fields=T,_.detail=void 0):(_.detail=T,_.fields=void 0),N.describe(_)}}}_collectSubgraphs(e){let t=[];for(let n of[...this._mounts.keys()].sort()){let o=e===""?n:`${e}${n}`;t.push(o),t.push(...this._mounts.get(n)._collectSubgraphs(`${o}${V}`))}return t}resourceProfile(e){return Tn(this,e)}reachable(e,t,n={}){return n.withDetail===!0?Ft(this.describe(),e,t,{...n,withDetail:!0}):Ft(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(we(e),we(t),{...n?.maxDepth!==void 0?{maxDepth:wn(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:Nn(n.findCycle)}:{}})}_explainStatic(e,t,n){let o=this.describe({detail:"full"}),s=new Map(this._annotations),a=new Map;for(let[i,d]of Object.entries(o.nodes))d.lastMutation!=null&&a.set(i,d.lastMutation);return mn(o,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:a})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",o=0,s=$(o,{name:`${n}_version`}),a=this.observe({timeline:!0,structured:!0}),i=!1,d=!1,u=()=>{i||d||(i=!0,Fe(()=>{i=!1,!d&&(o+=1,s.emit(o))}))},l=a.onEvent(v=>{let b=v.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||u()}),f=[],p=new WeakSet,h=v=>{if(p.has(v)||d)return;p.add(v);let b=v.topology.subscribe(T=>{for(let _ of T){if(_[0]!==I)continue;let k=_[1];if(u(),k.kind==="added"&&k.nodeKind==="mount"){let g=v._mounts.get(k.name);g!=null&&h(g)}}});f.push(b);for(let T of v._mounts.keys()){let _=v._mounts.get(T);_!=null&&h(_)}};h(this);let c,y=e.actor;En(y)&&(c=y.subscribe(v=>{let b=!1,T=!1;for(let _ of v){let k=_[0];k===I?b=!0:(k===F||k===G||k===H)&&(T=!0)}b&&u(),T&&(c?.(),c=void 0,u())}));let m;try{m=L([s],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(v,b)=>v===b})}catch(v){l(),c?.();for(let b of f)b();throw a.dispose(),v}let N=pe(m);return{node:m,dispose(){d=!0,l(),c?.();for(let v of f)v();f.length=0,a.dispose(),N()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},n=e.reactiveName??"describe-diff",o={name:this.name,nodes:{},edges:[],subgraphs:[]},s=this.describe(t),a=Gt(o,s),i=$(a,{name:n,meta:{domain:"audit",kind:"describe-diff"},equals:(p,h)=>p===h}),d=this._describeReactive({...e,reactiveName:void 0}),u=!1,l=d.node.subscribe(p=>{if(!u)for(let h of p){if(h[0]!==I)continue;let c=h[1],y=Gt(s,c);s=c,y.events.length!==0&&i.emit(y)}}),f=pe(i);return{node:i,dispose(){u=!0,l(),d.dispose(),i.down([[H,"describe-diff disposed"]]),f()}}}_explainReactive(e,t,n){let o=0,s=$(o,{name:"explain_version"}),a=this.observe({timeline:!0,structured:!0}),i=!1,d=!1,u=()=>{i||d||(i=!0,Fe(()=>{i=!1,!d&&(o+=1,s.emit(o))}))},l=a.onEvent(v=>{let b=v.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||u()}),f=[];e!=null&&Ae(e)&&f.push(e),t!=null&&Ae(t)&&f.push(t),n?.maxDepth!=null&&Ae(n.maxDepth)&&f.push(n.maxDepth),n?.findCycle!=null&&Ae(n.findCycle)&&f.push(n.findCycle);let p=()=>{for(let v of f)if(v.cache===void 0)return!1;return!0},h=()=>{let v=we(e),b=we(t);return{from:v,to:b,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:v,to:b,found:!1,reason:"pending",steps:[]})}},c;try{c=L([s],()=>{if(!p())return h();let v=we(e),b=we(t),T={...n?.maxDepth!==void 0?{maxDepth:wn(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:Nn(n.findCycle)}:{}};return this._explainStatic(v,b,T)},{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:we(e),to:we(t)},equals:(v,b)=>v.found===b.found&&v.reason===b.reason&&v.steps.length===b.steps.length&&Er(v.steps,b.steps)})}catch(v){throw l(),a.dispose(),v}let y=pe(c),m=[],N=v=>{let b;return b=v.subscribe(T=>{let _=!1,k=!1;for(let g of T){let w=g[0];w===I?_=!0:(w===F||w===G||w===H)&&(k=!0)}(_||k)&&u(),k&&b&&(b(),b=void 0)}),()=>{b&&(b(),b=void 0)}};for(let v of f)m.push(N(v));return{node:c,dispose(){d=!0,l();for(let v of m)v?.();m.length=0,a.dispose(),y()}}}_pathsMatching(e){let t=ht(e),n=[];return this._collectObserveTargets("",n),n.map(([o])=>o).filter(o=>t.test(o))}_collectObserveTargets(e,t){for(let n of[...this._mounts.keys()].sort()){let o=e===""?n:`${e}${V}${n}`;this._mounts.get(n)._collectObserveTargets(o,t)}for(let n of[...this._nodes.keys()].sort()){let o=this._nodes.get(n),s=e===""?n:`${e}${V}${n}`;t.push([s,o]),this._appendMetaObserveTargets(s,o,t)}}_appendMetaObserveTargets(e,t,n){for(let o of Object.keys(t.meta).sort()){let s=t.meta[o],a=`${e}${V}${oe}${V}${o}`;n.push([a,s]),this._appendMetaObserveTargets(a,s,n)}}observe(e,t){let n=typeof e=="string",s=xn(n?t:e);if(s.reactive===!0)return this._observeReactive(n?e:void 0,s);let a=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,i=s.actor;if(n){let l=e,f=this.resolve(l);if(i!=null&&!f.allowsObserve(i))throw new se({actor:i,action:"observe",nodeName:l});return a?this._buildStructuredObserver([[l,f]],s,"one"):{subscribe(p){return f.subscribe(p)},up(p){try{f.up?.(p)}catch(h){if(h instanceof se)return;throw h}}}}let d=[];this._collectObserveTargets("",d),d.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let u=i==null?d:d.filter(([,l])=>l.allowsObserve(i));return a?this._buildStructuredObserver(u,s,"all"):{subscribe:l=>{let f=u.map(([p,h])=>h.subscribe(c=>{l(p,c)}));return()=>{for(let p of f)p()}},up:(l,f)=>{try{this.resolve(l).up?.(f)}catch(p){if(p instanceof se)return;throw p}}}}_observeReactive(e,t){let n=t.tiers,o=n!=null?new Set(n):null,s=t.reactiveName??"observe";return Te(a=>{let i=[],d=!1,u=!1,l=()=>{if(i.length===0||u)return;let y={events:i.slice(),flushedAt_ns:J()};i.length=0,a.emit(y)},f={...t,reactive:!1,structured:!0,timeline:!0},p=e!=null?this.observe(e,f):this.observe(f),h=y=>{u||(i.push(y),!d&&(d=!0,Fe(()=>{d=!1,l()})))};for(let y of p.events)h(y);let c=p.onEvent(h);return()=>{u=!0,c(),p.dispose()}},{name:s,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,n){let o=n==="one"?e[0]?.[0]:void 0,s=a=>{if(n==="one"&&o!=null){let l=this.resolve(o);return this._buildStructuredObserver([[o,l]],a,"one")}let i=[];this._collectObserveTargets("",i),i.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let d=a.actor,u=d==null?i:i.filter(([,l])=>l.allowsObserve(d));return this._buildStructuredObserver(u,a,"all")};return this._createObserveResult(e,t,s)}_createObserveResult(e,t,n){let o=t.timeline===!0,s=t.causal===!0,a=t.derived===!0,i=t.detail==="minimal",d=this.config.inspectorEnabled,u=(s||a)&&d,l=t.maxEvents,f=l!=null&&l>0?new Ye(l):null,p=[],h=new Set,c=t.tiers!=null?new Set(t.tiers):null,y={},m=new Set,N=0,v=0,b=0,T=0,_=0,k=0,g=!1,w=!1,E=0,S=new Map,x=new Map,A=new Map,M=R=>{if(!(c!=null&&!c.has(R.type))){f?f.push(R):p.push(R);for(let P of h)P(R)}},C=R=>c==null||c.has(R),ee=()=>o?{timestamp_ns:J(),in_batch:Ue(),batch_id:E}:{},te=(R,P)=>{if(!(!u||!(R instanceof B)))return R._setInspectorHook(Y=>{if(Y.kind==="dep_message")S.set(R,Y.depIndex);else if(Y.kind==="run"){let ge=Y.batchData.map((O,D)=>O!=null&&O.length>0?O.at(-1):Y.prevData[D]);x.set(R,ge);let X=Y.batchData.map(O=>O!=null?[...O]:void 0);A.set(R,X),a&&M({type:"derived",path:P,dep_values:ge,dep_batches:X,...ee()})}})},he=R=>{let P=S.get(R),Y=x.get(R);if(!s||Y==null)return{};let X=(P!=null&&P>=0&&R instanceof B?R._deps[P]:void 0)?.node,O=X?.v,D=A.get(R);return{trigger_dep_index:P,trigger_dep_name:X?.name,...O!=null?{trigger_version:{id:O.id,version:O.version}}:{},dep_values:[...Y],...D!=null?{dep_batches:D}:{}}},Ce=[],Be=[];for(let[R,P]of e){let Y=te(P,R);Y&&Ce.push(Y),Be.push(P.subscribe(ge=>{E++;for(let X of ge){let O=X[0],D=ee();if(O===I){y[R]=X[1];let z=P instanceof B?P.lastMutation?.actor??Le:Le;M({type:"data",path:R,data:X[1],actor:z,...D,...he(P)})}else if(i)O===q?C("dirty")&&N++:O===K?C("resolved")&&v++:O===re?C("invalidate")&&b++:O===ie?C("pause")&&T++:O===ce?C("resume")&&_++:O===H?C("teardown")&&k++:O===F&&!m.has(R)?C("complete")&&(g=!0):O===G&&C("error")&&(w=!0,m.add(R));else if(O===q)C("dirty")&&N++,M({type:"dirty",path:R,...D});else if(O===K)C("resolved")&&v++,M({type:"resolved",path:R,...D,...he(P)});else if(O===re)C("invalidate")&&b++,M({type:"invalidate",path:R,...D});else if(O===ie)C("pause")&&T++,M({type:"pause",path:R,lockId:X[1],...D});else if(O===ce)C("resume")&&_++,M({type:"resume",path:R,lockId:X[1],...D});else if(O===F)C("complete")&&!m.has(R)&&(g=!0),M({type:"complete",path:R,...D});else if(O===G){C("error")&&(w=!0,m.add(R));let z=P instanceof B?P.lastMutation?.actor??Le:Le;M({type:"error",path:R,data:X[1],actor:z,...D})}else O===H&&(C("teardown")&&k++,M({type:"teardown",path:R,...D}))}}))}let Ne=!1,Oe=()=>{if(!Ne){Ne=!0;for(let R of Be)R();for(let R of Ce)R();for(let R of me)R({value:void 0,done:!0});me.length=0}},xe=[],me=[];h.add(R=>{let P=me.shift();P?P({value:R,done:!1}):xe.push(R)});let Me={get values(){return y},get dirtyCount(){return N},get resolvedCount(){return v},get invalidateCount(){return b},get pauseCount(){return T},get resumeCount(){return _},get teardownCount(){return k},get events(){return f?f.toArray():[...p]},get anyCompletedCleanly(){return g},get anyErrored(){return w},get completedWithoutErrors(){return g&&!w},onEvent(R){return h.add(R),()=>h.delete(R)},dispose:Oe,expand(R){Oe();let P={...t};return typeof R=="string"?P.detail=R:Object.assign(P,R),n(xn(P))},[Symbol.asyncIterator](){return{next(){return xe.length>0?Promise.resolve({value:xe.shift(),done:!1}):Ne?Promise.resolve({value:void 0,done:!0}):new Promise(R=>me.push(R))},return(){return Oe(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Me,t),Me}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let o=t.logger??(c=>console.log(c)),s=t.includeTypes?new Set(t.includeTypes):null,a=t.excludeTypes?new Set(t.excludeTypes):null,i=s==null&&a==null?()=>!0:c=>(s==null||s.has(c))&&(a==null||!a.has(c)),d=wr(t.theme),u=n==="stage-log"?J():0,l=c=>c==null?"":t.stageLabels?.[c]??c,f=(c,y)=>c.length>y?`${c.slice(0,y-1)}\u2026`:c,p=c=>c.type==="data"||c.type==="error"?f(It(c.data),120):"",h=c=>{if(n==="stage-log"){let g=(J()-u)/1e9,w=l(c.path).padEnd(9);if(c.type==="data"){let E=p(c);return`[${g.toFixed(3)}s] ${w} \u2190${E?` ${E}`:""}`}if(c.type==="error"){let E=p(c);return`[${g.toFixed(3)}s] ${w} \u2717${E?` ${E}`:""}`}return c.type==="complete"?`[${g.toFixed(3)}s] ${w} \u25A0 complete`:`[${g.toFixed(3)}s] ${w} ${c.type}`}if(n==="json")try{return JSON.stringify(c)}catch{return JSON.stringify({type:c.type,path:c.path,data:"[unserializable]"})}let y=d[c.type]??"",m=c.path?`${d.path}${c.path}${d.reset} `:"",N=c.type==="data"||c.type==="error",v=c.type==="pause"||c.type==="resume",b=N?` ${It(c.data)}`:v?` ${It(c.lockId)}`:"",T=c.type==="data"||c.type==="resolved"||c.type==="derived"?c:void 0,_=T?.trigger_dep_name!=null?` <- ${T.trigger_dep_name}`:T?.trigger_dep_index!=null?` <- #${T.trigger_dep_index}`:"",k=c.in_batch?" [batch]":"";return`${m}${y}${c.type.toUpperCase()}${d.reset}${b}${_}${k}`};e.onEvent(c=>{i(c.type)&&o(h(c),c)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){_n(this._disposers,this.name),this.signal([[H]],{internal:!0}),_n(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:t,...n}=this.describe({detail:"full"}),o={};for(let i of Object.keys(n.nodes).sort()){let{lastMutation:d,guard:u,...l}=n.nodes[i];o[i]=l}let s=[...n.subgraphs].sort(),a={...n,version:1,nodes:o,subgraphs:s};if(e?.format==null)return a;if(e.format==="json-string")return JSON.stringify(a);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let i=this.config.lookupCodec(e.codec);if(i==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return Yt(i,i.encode(a))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??Ve,{codec:o,codecVersion:s,payload:a}=Jt(e,n);return o.decode(a,s)}restore(e,t){if(On(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let n=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(s=>ht(s)),o=t?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(i=>i.test(s)))continue;let a=e.nodes[s];if(a!==void 0){if(!("value"in a)||a.value===void 0){"value"in a&&a.value===void 0&&t?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(a.type==="derived"||a.type==="effect")&&!(a.type==="producer"&&!o)){if(a.v!=null){let d=this.tryResolve(s)?.v;if(d!=null&&d.id===a.v.id&&d.version===a.v.version)continue}try{this.set(s,a.value)}catch(i){t?.onError?.(s,i)}}}}}static fromSnapshot(e,t){On(e);let n=typeof t=="function"?t:t?.build,o=typeof t=="function"?void 0:t?.factories,s=new r(e.name);if(n)return n(s),s.restore(e),s;for(let h of[...e.subgraphs].sort((c,y)=>{let m=c.split(V).length,N=y.split(V).length;return m!==N?m-N:c<y?-1:c>y?1:0})){let c=h.split(V),y=s;for(let m of c)y._mounts.has(m)||y.mount(m,new r(m)),y=y._mounts.get(m)}let a=o?Object.entries(o).map(([h,c])=>({re:ht(h),factory:c})):[],i=h=>{for(let c of a)if(c.re.test(h))return c.factory},d=h=>{let c=h.split(V),y=c.pop();if(y==null||y.length===0)throw new Error(`invalid snapshot path "${h}"`);let m=s;for(let N of c){let v=m._mounts.get(N);if(!v)throw new Error(`unknown mount "${N}" in path "${h}"`);m=v}return[m,y]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${V}${oe}${V}`)).sort((h,c)=>h[0]<c[0]?-1:h[0]>c[0]?1:0),l=new Map(u),f=new Map,p=!0;for(;l.size>0&&p;){p=!1;for(let[h,c]of[...l.entries()]){let y=c?.deps??[];if(!y.every(_=>f.has(_)))continue;let[m,N]=d(h),v={...c?.meta??{}},b=i(h),T;if(c?.type==="state")T=$(c.value,{meta:v});else{if(b==null)continue;T=b(N,{path:h,type:c.type,value:c.value,meta:v,deps:y,resolvedDeps:y.map(_=>f.get(_))})}m.add(T,{name:N}),f.set(h,T),l.delete(h),p=!0}}if(l.size>0){let h=[...l.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let n=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let o=(u,l)=>{if(u.disposed)return;let f=br(l.nodes);if(u.lastSnapshot!=null&&f!==""&&f===u.lastFingerprint)return;let p=u.seq+1,h=et(),m=u.lastSnapshot==null||p%u.compactEvery===0?{name:this.name,mode:"full",snapshot:l,seq:p,timestamp_ns:h,format_version:De}:{name:this.name,mode:"diff",diff:Rn(u.lastSnapshot,l),seq:p,timestamp_ns:h,format_version:De};if(u.tier.filter&&!u.tier.filter(m))return;let N;try{N=u.tier.save(m)}catch(v){t.onError?.(v,u.tier);return}if(N&&typeof N.then=="function"){let T=(u.savePending??Promise.resolve()).then(()=>N,()=>N).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=l,u.lastFingerprint=f)},_=>{t.onError?.(_,u.tier)});u.savePending=T.finally(()=>{u.savePending===T&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=l,u.lastFingerprint=f},s=(u,l)=>{try{o(u,l)}catch(f){t.onError?.(f,u.tier)}},a=(u,l)=>{if(!l.some(c=>{let y=this.config.messageTier(c[0]);return y>=3&&y<5}))return;if(t.filter){let c=this.tryResolve(u);if(c==null)return;let y=Dt(c,St("standard"));if(!t.filter(u,y))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let c of n)c.disposed||(c.debounceMs===0?s(c,h()):(c.timer==null&&(c.timer=new ct),c.timer.start(c.debounceMs,()=>{c.disposed||s(c,this.snapshot())})))},i;if(t.paths!=null){let l=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(f=>{let p=this.tryResolve(f);return p==null?()=>{}:p.subscribe(h=>a(f,h))});i=()=>{for(let f of l)f()}}else i=this.observe().subscribe((u,l)=>a(u,l));let d=()=>{i();for(let u of n)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,t){for(let n of e){let o;try{o=await n.load?.()}catch(a){t?.(a,n);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===De&&s.nodes!=null)return this.restore(s),!0}catch(a){t?.(a,n)}}return!1}static async fromStorage(e,t,n){for(let o of t){let s;try{s=await o.load?.()}catch(d){n?.onError?.(d,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let a=s,i=a.mode==="full"&&a.snapshot!=null?a.snapshot:a.version===De&&a.nodes!=null?a:void 0;if(i!=null)try{return r.fromSnapshot(i,n)}catch(d){n?.onError?.(d,o)}}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,n){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let o={path:e,annotation:t,timestamp_ns:J(),...n?.actor!=null?{actor:n.actor}:{}};this._traceRing.push(o)}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(o=>!e(o)),n=this._traceRing.size-t.length;this._traceRing.clear();for(let o of t)this._traceRing.push(o);return n}static diff(e,t){let n=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(t.nodes)),s=[...o].filter(v=>!n.has(v)).sort(),a=[...n].filter(v=>!o.has(v)).sort(),i=[],d=[];for(let v of n){if(!o.has(v))continue;let b=e.nodes[v],T=t.nodes[v],_=b.v,k=T.v;_!=null&&k!=null&&_.id===k.id&&_.version!==k.version&&d.push({path:v,id:_.id,from:_.version,to:k.version});let g=_!=null&&k!=null&&_.id===k.id&&_.version===k.version;for(let w of["type","status","sentinel"]){let E=b[w],S=T[w];E!==S&&i.push({path:v,field:w,from:E,to:S})}if(!g)for(let w of["value","meta"]){let E=b[w],S=T[w];yr(E,S)||i.push({path:v,field:w,from:E,to:S})}}let u=v=>`${v.from} ${v.to}`,l=new Set(e.edges.map(u)),f=new Set(t.edges.map(u)),p=t.edges.filter(v=>!l.has(u(v))),h=e.edges.filter(v=>!f.has(u(v))),c=new Set(e.subgraphs),y=new Set(t.subgraphs),m=[...y].filter(v=>!c.has(v)).sort(),N=[...c].filter(v=>!y.has(v)).sort();return{nodesAdded:s,nodesRemoved:a,nodesChanged:i,versionChanges:d,edgesAdded:p,edgesRemoved:h,subgraphsAdded:m,subgraphsRemoved:N}}};function Rn(r,e){let t=de.diff(r,e),n={};for(let o of t.nodesAdded){let s=e.nodes[o];s!=null&&(n[o]=s)}return{...t,nodesAddedFull:n}}function Ft(r,e,t,n={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return n.withDetail?o:[];if(!n.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=n.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return n.withDetail?o:[];let a=new Map,i=new Map,d=new Map,u=new Map,l=new Set;for(let[b,T]of Object.entries(r.nodes)){if(!b)continue;l.add(b);let _=T.deps??[];a.set(b,_);for(let k of _)k&&(l.add(k),i.has(k)||i.set(k,new Set),i.get(k).add(b))}for(let b of r.edges){if(b==null||typeof b!="object")continue;let T=typeof b.from=="string"?b.from:"",_=typeof b.to=="string"?b.to:"";!T||!_||(l.add(T),l.add(_),u.has(T)||u.set(T,new Set),u.get(T).add(_),d.has(_)||d.set(_,new Set),d.get(_).add(T))}if(!l.has(e))return n.withDetail?o:[];let f=n.both===!0,p=b=>{if(f){let g=a.get(b)??[],w=d.get(b),E=i.get(b),S=u.get(b),x=[...g];return w&&x.push(...w),E&&x.push(...E),S&&x.push(...S),x}if(t==="upstream"){let g=a.get(b)??[],w=d.get(b);return w?[...g,...w]:g}let T=i.get(b),_=u.get(b),k=T?[...T]:[];return _&&k.push(..._),k},h=new Set([e]),c=new Map,y=[{path:e,depth:0}],m=0,N=!1;for(;m<y.length;){let b=y[m++];if(s!=null&&b.depth>=s){p(b.path).length>0&&(N=!0);continue}for(let T of p(b.path))!T||h.has(T)||(h.add(T),c.set(T,b.depth+1),y.push({path:T,depth:b.depth+1}))}let v=[...c.keys()].sort((b,T)=>b<T?-1:b>T?1:0);return n.withDetail?{paths:v,depths:c,truncated:N}:v}function Er(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++){let n=r[t],o=e[t];if(n.path!==o.path||n.type!==o.type||n.status!==o.status||n.hop!==o.hop||n.dep_index!==o.dep_index||n.annotation!==o.annotation||n.value!==o.value||n.lastMutation!==o.lastMutation)return!1;let s=n.v,a=o.v;if(s!==a&&(s==null||a==null||s.id!==a.id||s.version!==a.version))return!1}return!0}it();$e();Ke();le();ze();fe();Dn();$e();le();fe();ze();var $t=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),e&&e.length>0){let n=Math.min(e.length,t),o=e.length-n;for(let s=0;s<n;s++)this._buf[s]=e[o+s];this._size=n}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._size+e;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let n=t;n<e.length;n++)this._rawAppend(e[n]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<e;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let t=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let n=0;n<t;n++)this._buf[(this._head+n)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(e,t){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let n=t===void 0?this._size:Math.min(Math.max(t,0),this._size),o=Math.min(e,this._size);if(o>=n)return[];let s=n-o;if(this._maxSize===void 0)return this._buf.slice(o,n);let a=new Array(s);for(let i=0;i<s;i++)a[i]=this._buf[(this._head+o+i)%this._maxSize];return a}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let t=Math.min(e,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this._buf[(this._head+t)%this._maxSize];return e}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<e.length;t++)this._buf.push(e[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let s=0;s<t;s++)this._buf[s]=void 0;this._head=0;let n=Math.min(e.length,t),o=e.length-n;for(let s=0;s<n;s++)this._buf[s]=e[o+s];this._size=n}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function Je(r){return r.subscribe(()=>{})}var kr=64;function An(r,e={}){let{name:t,maxSize:n,versioning:o,guard:s,backend:a}=e,i=a??new $t(r,n),d=$(i.toArray(),{name:t,describeKind:"state",equals:(g,w)=>g===w,...o!=null?{versioning:o}:{},...s!=null?{guard:s}:{}});function u(){let g=i.toArray();ae(()=>{d.down([[q]],{internal:!0}),d.down([[I,g]],{internal:!0})})}let l=new Map,f=new Map,p=new Map;function h(g,w){return`${g}:${w===void 0?"END":w}`}function c(g){if(g.size<kr)return;let w=g.keys().next();if(w.done)return;let E=g.get(w.value);E!==void 0&&E.dispose(),g.delete(w.value)}function y(g){let w=i.version;try{return g()}finally{i.version!==w&&u()}}function m(g){if(!Number.isInteger(g)||g<0)throw new RangeError(`tail: n must be a non-negative integer (got ${g})`);let w=l.get(g);if(w!==void 0)return l.delete(g),l.set(g,w),w.node;c(l);let E=L([d],([x])=>{let A=x;return g===0||A.length===0?[]:A.slice(Math.max(0,A.length-g))},{initial:i.tail(g),describeKind:"derived"}),S=Je(E);return l.set(g,{node:E,dispose:S}),E}function N(g,w){if(!Number.isInteger(g)||g<0)throw new RangeError(`slice: start must be a non-negative integer (got ${g})`);if(w!==void 0&&(!Number.isInteger(w)||w<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${w})`);let E=h(g,w),S=f.get(E);if(S!==void 0)return f.delete(E),f.set(E,S),S.node;c(f);let x=L([d],([M])=>{let C=M;return w===void 0?C.slice(g):C.slice(g,w)},{initial:i.slice(g,w),describeKind:"derived"}),A=Je(x);return f.set(E,{node:x,dispose:A}),x}function v(g){let w=p.get(g);if(w!==void 0)return w.node;let E=L([d,g],([x,A])=>{let M=x,C=Math.max(0,Math.trunc(A??0));return M.slice(C)},{initial:[],describeKind:"derived"}),S=Je(E);return p.set(g,{node:E,dispose:S}),E}let b,T;function _(){b===void 0&&(b=Q([d],(g,w,E)=>{let S=g[0],A=S!=null&&S.length>0?S.at(-1):E.prevData[0];if(A==null||A.length===0){w.down([[K]]);return}w.emit(A[A.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:i.size===0?void 0:i.at(i.size-1)}),T=L([d],([g])=>g.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:i.size>0}),Je(b),Je(T))}let k={entries:d,get size(){return i.size},at(g){return i.at(g)},append(g){y(()=>i.append(g))},appendMany(g){g.length!==0&&y(()=>i.appendMany(g))},clear(){y(()=>i.clear())},trimHead(g){y(()=>i.trimHead(g))},withLatest(){return _(),d},get lastValue(){return _(),b},get hasLatest(){return _(),T},view(g){switch(g.kind){case"tail":return m(g.n);case"slice":return N(g.start,g.stop);case"fromCursor":return v(g.cursor)}},attach(g){let w=g.subscribe(E=>{for(let S of E)S[0]===I&&k.append(S[1])});return()=>w()},attachStorage(g){if(g.length===0)return()=>{};let w=new Map;for(let S of g)w.set(S,i.size);(async()=>{for(let S of g)if(typeof S.loadEntries=="function")try{let x=await Promise.resolve(S.loadEntries());x.entries.length>0&&i.size===0&&(i.restore(x.entries),w.set(S,x.entries.length),u());break}catch{}})();let E=d.subscribe(S=>{for(let x of S){if(x[0]!==I)continue;let A=x[1];for(let M of g){let C=w.get(M)??0;if(A.length<C){try{let te=M.appendEntries(A);te instanceof Promise&&te.catch(()=>{})}catch{}w.set(M,A.length);continue}if(A.length===C)continue;let ee=A.slice(C);w.set(M,A.length);try{let te=M.appendEntries(ee);te instanceof Promise&&te.catch(()=>{})}catch{}}}});return()=>E()},disposeAllViews(){for(let g of l.values())g.dispose();l.clear();for(let g of f.values())g.dispose();f.clear();for(let g of p.values())g.dispose();p.clear()},dispose(){for(let g of l.values())g.dispose();l.clear();for(let g of f.values())g.dispose();f.clear();for(let g of p.values())g.dispose();p.clear()}};return k}ut();function Xe(r,e){if(!Number.isFinite(r)||!Number.isInteger(r)||r<0)throw new Error(`${e} must be a non-negative integer`);return r}function Ze(r,e){return Sn("messaging",r,e)}var Rr=1024,Lt=class extends de{_log;events;latest;hasLatest;constructor(e,t={}){super(e,t.graph),this._log=An([],{name:"events",maxSize:t.retainedLimit??Rr}),this._log.withLatest(),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=L([this.events],([n])=>{let o=n;return o.length===0?null:o[o.length-1]},{name:"latest",describeKind:"derived",meta:Ze("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(pe(this.latest)),this.hasLatest=L([this.events],([n])=>n.length>0,{name:"hasLatest",describeKind:"derived",meta:Ze("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(pe(this.hasLatest)),this.addDisposer(()=>{this.events.down([[F]])}),this.addDisposer(()=>this._log.disposeAllViews())}publish(e){if(e===void 0)throw new TypeError(`TopicGraph "${this.name}": publish(undefined) is not allowed (spec \xA75.12 SENTINEL).`);this._log.append(e)}attachEventStorage(e){return this._log.attachStorage(e)}retained(){return this.events.cache}get _logBundle(){return this._log}},Vt=class extends de{cursor;available;topic;_disposed=!1;constructor(e,t,n={}){super(e,n.graph),this.topic=t;let o;if(n.from!==void 0?n.from==="retained"?o=0:n.from==="now"?o=t.events.cache.length:o=Xe(n.from,"subscription from"):o=Xe(n.cursor??0,"subscription cursor"),this.cursor=$(o,{name:"cursor",describeKind:"state",meta:Ze("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=t._logBundle.view({kind:"fromCursor",cursor:this.cursor}),this.add(this.available,{name:"available"}),this.addDisposer(pe(this.available)),n.advanceOn!==void 0){let s=n.advanceOn,a=!1,i=Q([s],()=>{if(!a){a=!0;return}if(this._disposed)return;let d=this.available.cache;if(d.length===0)return;let u=this.cursor.cache+d.length;this.cursor.emit(u)},{name:"advancePump",describeKind:"effect",meta:Ze("subscription_advance_pump")});this.add(i,{name:"advancePump"}),this.addDisposer(pe(i))}}ack(e){if(this._disposed)return this.cursor.cache;let t=this.available.cache,n=e===void 0?t.length:Xe(e,"subscription ack count"),o=Math.min(n,t.length);if(o<=0)return this.cursor.cache;let s=this.cursor.cache+o;return this.cursor.emit(s),s}pull(e){if(this._disposed)return[];let t=this.available.cache,n=e===void 0?t.length:Xe(e,"subscription pull limit");return t.slice(0,n)}pullAndAck(e){if(this._disposed)return{items:[],cursor:this.cursor.cache};let t=this.available.cache,n=e===void 0?t.length:Xe(e,"subscription pullAndAck limit"),o=t.slice(0,n);if(o.length===0)return{items:o,cursor:this.cursor.cache};let s=this.cursor.cache+o.length;return this.cursor.emit(s),{items:o,cursor:s}}dispose(){this._disposed||(this._disposed=!0,this.cursor.down([[F]]),this.destroy())}};var zt=class{_map=new Map;version;constructor(e){this.version=e}get size(){return this._map.size}has(e){return this._map.has(e)}get(e){return this._map.get(e)}set(e,t){this._map.set(e,t)}delete(e){return this._map.delete(e)}keys(){return this._map.keys()}},Bt=class extends de{_registry;version;_defaultTopicOptions;constructor(e,t={}){super(e,t.graph);let n=$(0,{name:"version",describeKind:"state",meta:Ze("hub_version")});this.add(n,{name:"version"}),this.version=n,this._registry=new zt(n),this._defaultTopicOptions={...t.defaultTopicOptions??{}}}get size(){return this._registry.size}has(e){return this._registry.has(e)}topicNames(){return this._registry.keys()}topic(e,t){let n=this._registry.get(e);if(n===void 0){let o={...this._defaultTopicOptions,...t??{}};n=new Lt(e,o),this._registry.set(e,n),this.mount(e,n);let s=this.version.cache??0;this.version.emit(s+1)}return n}publish(e,t){this.topic(e).publish(t)}publishMany(e){ae(()=>{for(let[t,n]of e)this.topic(t).publish(n)})}subscribe(e,t,n){let o=this.topic(t);return new Vt(e,o,n)}removeTopic(e){if(!this._registry.has(e))return!1;try{this.remove(e)}finally{this._registry.delete(e);let t=this.version.cache??0;this.version.emit(t+1)}return!0}};function Cn(r,e){return new Bt(r,e)}function Sr(r){if(typeof r!="object"||r===null)return!1;let e=r;return typeof e.subscribe=="function"&&typeof e.down=="function"&&typeof e.emit=="function"}function Mn(r,e){if(r.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(r.length===1){let s=jt(e);return{best:r[0],bestScore:s}}if(e.some(s=>typeof s.candidateIndex=="number")){let s=new Array(r.length);for(let d=0;d<r.length;d++)s[d]={sum:0,count:0};for(let d of e){let u=d.candidateIndex;typeof u=="number"&&u>=0&&u<r.length&&(s[u].sum+=d.score,s[u].count+=1)}let a=r[0],i=s[0].count>0?s[0].sum/s[0].count:Number.NEGATIVE_INFINITY;for(let d=1;d<r.length;d++){let u=s[d].count>0?s[d].sum/s[d].count:Number.NEGATIVE_INFINITY;u>i&&(i=u,a=r[d])}return{best:a,bestScore:i}}let n=r[0],o=e[0]?.score??Number.NEGATIVE_INFINITY;for(let s=1;s<r.length;s++){let a=e[s]?.score??Number.NEGATIVE_INFINITY;a>o&&(o=a,n=r[s])}return{best:n,bestScore:o}}function jt(r){if(r.length===0)return Number.NEGATIVE_INFINITY;let e=0;for(let t of r)e+=t.score;return e/r.length}function Dr(r,e,t,n){let o=n.name??"refine-loop",s=new de(o,n.graph),a=Sr(n.dataset)?n.dataset:$(n.dataset,{name:"dataset"});s.add(a,{name:"dataset"});let i=$(0,{name:"iteration"});s.add(i,{name:"iteration"});let d=$(t,{name:"strategy",equals:()=>!1});s.add(d,{name:"strategy"});let u=$(null,{name:"lastFeedback"});s.add(u,{name:"lastFeedback"});let l=$([],{name:"prevCandidates"});s.add(l,{name:"prevCandidates"});let f=$(!1,{name:"paused"});s.add(f,{name:"paused"});let p=$("running",{name:"status"});s.add(p,{name:"status"});let h=$([],{name:"history",equals:()=>!1});s.add(h,{name:"history"});let c=$(null,{name:"best"});s.add(c,{name:"best"});let y=$(Number.NEGATIVE_INFINITY,{name:"score"});s.add(y,{name:"score"});let m=$(0,{name:"budget-used"});s.add(m,{name:"budget-used"});let N=Cn("stages");s.mount("stages",N);let v=N.topic("generate"),b=N.topic("evaluate"),T=N.topic("analyze"),_=N.topic("decide"),k=t,g=null,w=[];s.addDisposer(d.subscribe(O=>{for(let D of O)D[0]===I&&(k=D[1])})),s.addDisposer(u.subscribe(O=>{for(let D of O)D[0]===I&&(g=D[1])})),s.addDisposer(l.subscribe(O=>{for(let D of O)D[0]===I&&(w=D[1])}));let E=ln(i,O=>{let D=k,z=O===0||g==null;return Q([],(U,Z)=>{let be=!1;try{let ye=z?D.seed(r):D.generate(g,w);if(ye instanceof Promise)return ye.then(Ge=>{be||Z.emit(Ge)},Ge=>{be||Z.down([[G,Ge]])}),()=>{be=!0};Z.emit(ye)}catch(ye){be=!0,Z.down([[G,ye]])}},{describeKind:"producer"})},{name:"candidates"});s.add(E,{name:"candidates"});let S=_e([E],(O,D,z)=>{let U=z.terminalDeps[0];U!==void 0&&U!==!0&&p.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});s.add(S,{name:"error-watcher"}),s.addDisposer(S.subscribe(()=>{}));let x=L([E,i],([O,D])=>({iteration:D,candidates:O,timestamp_ns:J()}),{name:"generate-event"});s.add(x,{name:"generate-event"}),s.addDisposer(x.subscribe(()=>{}));let A=_e([x],([O])=>{v.publish(O)},{name:"generate-publish"});s.add(A,{name:"generate-publish"}),s.addDisposer(A.subscribe(()=>{}));let M=_e([E],([O])=>{l.emit(O)},{name:"generate-mirror"});s.add(M,{name:"generate-mirror"}),s.addDisposer(M.subscribe(()=>{}));let C=e(E,a);s.add(C,{name:"scores"});let ee=L([C,E,i],([O,D,z])=>({iteration:z,candidates:D,scores:O,timestamp_ns:J()}),{name:"evaluate-event"});s.add(ee,{name:"evaluate-event"}),s.addDisposer(ee.subscribe(()=>{}));let te=_e([ee],([O])=>{b.publish(O)},{name:"evaluate-publish"});s.add(te,{name:"evaluate-publish"}),s.addDisposer(te.subscribe(()=>{}));let he=L([C,E],([O,D])=>k.analyze(O,D),{name:"feedback"});s.add(he,{name:"feedback"});let Ce=L([he,E,i],([O,D,z])=>({iteration:z,candidates:D,feedback:O,timestamp_ns:J()}),{name:"analyze-event"});s.add(Ce,{name:"analyze-event"}),s.addDisposer(Ce.subscribe(()=>{}));let Be=_e([Ce],([O])=>{T.publish(O)},{name:"analyze-publish"});s.add(Be,{name:"analyze-publish"}),s.addDisposer(Be.subscribe(()=>{}));let Ne=L([h],([O])=>{let D=O;if(n.patience==null||D.length<=n.patience)return!1;let z=D.slice(-(n.patience+1)),U=z[0].bestScore;return z.slice(1).every(Z=>Z.bestScore<=U)},{name:"patience-check"});s.add(Ne,{name:"patience-check"});let Oe=L([y],([O])=>n.minScore!=null&&O>=n.minScore,{name:"min-score-check"});s.add(Oe,{name:"min-score-check"});let xe=L([h],([O])=>{let D=O;if(n.minDelta==null||D.length<2)return!1;let z=D[D.length-2].bestScore,U=D[D.length-1].bestScore;return Math.abs(U-z)<n.minDelta},{name:"min-delta-check"});s.add(xe,{name:"min-delta-check"});let me=L([m],([O])=>n.maxEvaluations!=null&&O>=n.maxEvaluations,{name:"max-evaluations-check"});s.add(me,{name:"max-evaluations-check"});let Me=L([i],([O])=>n.maxIterations!=null&&O>=n.maxIterations,{name:"max-iterations-check"});s.add(Me,{name:"max-iterations-check"});let R=L([m],([O])=>n.budget!=null&&O>=n.budget,{name:"budget-exhausted-check"});s.add(R,{name:"budget-exhausted-check"}),s.addDisposer(Ne.subscribe(()=>{})),s.addDisposer(Oe.subscribe(()=>{})),s.addDisposer(xe.subscribe(()=>{})),s.addDisposer(me.subscribe(()=>{})),s.addDisposer(Me.subscribe(()=>{})),s.addDisposer(R.subscribe(()=>{}));let P=L([Ne,Oe,xe,me,Me],([O,D,z,U,Z])=>O?{converged:!0,reason:"patience"}:D?{converged:!0,reason:"min-score"}:z?{converged:!0,reason:"min-delta"}:U?{converged:!0,reason:"max-evaluations"}:Z?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});s.add(P,{name:"converged"}),s.addDisposer(P.subscribe(()=>{}));let Y=-1,ge=_e([he,C,E],([O,D,z])=>{let U=i.cache,Z=O,be=z,ye=D;if(U<=Y)return;Y=U;let{best:Ge,bestScore:Gn}=Mn(be,ye),In=h.cache,Pn={n:U,candidates:be,scores:ye,feedback:Z,best:Ge,bestScore:Gn,timestamp_ns:J()},ve=[...In,Pn],mt=m.cache+be.length,ne="continue",Ee,Fn=n.budget!=null&&mt>=n.budget,$n=f.cache;if(Fn)ne="budget",Ee="budget";else if(n.minScore!=null&&Z.score>=n.minScore)ne="converged",Ee="min-score";else if(n.maxIterations!=null&&U>=n.maxIterations)ne="converged",Ee="max-iterations";else if(n.maxEvaluations!=null&&mt>=n.maxEvaluations)ne="converged",Ee="max-evaluations";else if(n.minDelta!=null&&ve.length>=2){let Qe=ve[ve.length-2].bestScore,gt=ve[ve.length-1].bestScore;Math.abs(gt-Qe)<n.minDelta&&(ne="converged",Ee="min-delta")}else if(n.patience!=null&&ve.length>n.patience){let Qe=ve.slice(-(n.patience+1)),gt=Qe[0].bestScore;Qe.slice(1).every(Ln=>Ln.bestScore<=gt)&&(ne="converged",Ee="patience")}ne==="continue"&&$n&&(ne="paused"),ae(()=>{c.emit(Ge),y.emit(Z.score),h.emit(ve),m.emit(mt),u.emit(Z),_.publish({iteration:U,decision:ne,reason:Ee,timestamp_ns:J()}),ne==="continue"?i.emit(U+1):p.emit(ne==="converged"?"converged":ne==="budget"?"budget":"paused")})},{name:"decide-bridge"});return s.add(ge,{name:"decide-bridge"}),s.addDisposer(ge.subscribe(()=>{})),Object.assign(s,{best:c,score:y,status:p,history:h,strategy:d,iteration:i,generate:v,evaluate:b,analyze:T,decide:_,setStrategy(O){d.emit(O)},pause(){f.emit(!0)},resume(){p.cache==="paused"&&ae(()=>{f.emit(!1),p.emit("running"),i.emit(i.cache+1)})}})}function Ar(r){let e=r.width??4;return{name:r.name??"blindVariation",seed(n){return[n]},analyze(n,o){let s=jt(n),a=null;for(let i of n)(!a||i.score<a.score)&&(a=i);return{summary:`blindVariation iteration: mean=${s.toFixed(3)}, n=${n.length}`,score:s,weakTasks:a?[a.taskId]:[]}},async generate(n,o){if(o.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let s=o[o.length-1],a=0,d={prior:s,reportCost:u=>{a+=u}};try{if(r.parallel!==!1)return await Promise.all(Array.from({length:e},()=>r.teacher(d)));let u=[];for(let l=0;l<e;l++)u.push(await r.teacher(d));return u}finally{if(r.tokens!=null&&a>0){let u=r.tokens.cache??0;r.tokens.emit(u+a)}}}}}function Cr(r){return typeof r=="object"&&r!==null&&r.kind==="errorCritique"}function Mr(r,e){return r.length===0?`No task scored below the batch mean (${e.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
|
|
4
|
+
${r.map(n=>{let o=n.error!=null?` | error: ${n.error}`:"";return`- ${n.taskId} (score=${n.score.toFixed(3)})${o}`}).join(`
|
|
5
|
+
`)}`}function Gr(r){let e=r.width??4,t=r.name??"errorCritique",n=r.maxFailureSamples??5,o=r.formatCritique??Mr;return{name:t,seed(s){return[s]},analyze(s,a){let i=jt(s),d=typeof r.failureThreshold=="function"?r.failureThreshold(s):r.failureThreshold,u=d===void 0&&!Number.isFinite(i),l=d??i,f=u?[...s].sort((b,T)=>b.score-T.score):s.filter(b=>b.score<l).slice().sort((b,T)=>b.score-T.score),p=f.slice(0,n),{best:h,bestScore:c}=Mn(a,s),y={summary:"",score:i,weakTasks:p.map(b=>b.taskId)},m=o(p,y),N={kind:"errorCritique",best:h,failures:p,critiqueText:m},v=f.length>p.length?` (top ${p.length} retained)`:"";return{summary:`errorCritique iteration: mean=${i.toFixed(3)}, failures=${f.length}${v}/${s.length}, bestScore=${c.toFixed(3)}`,critique:N,weakTasks:p.map(b=>b.taskId),score:i}},async generate(s,a){if(a.length===0)throw new Error("errorCritique.generate: empty candidate batch \u2014 cannot derive prior for teacher");let i=Cr(s.critique)?s.critique:void 0,d=i!==void 0?i.best:a[a.length-1],u=i?.critiqueText??s.summary,l=i?.failures??[],f=0,h={prior:d,critique:u,failures:l,reportCost:c=>{f+=c}};try{if(r.parallel!==!1)return await Promise.all(Array.from({length:e},()=>r.teacher(h)));let c=[];for(let y=0;y<e;y++)c.push(await r.teacher(h));return c}finally{if(r.tokens!=null&&f>0){let c=r.tokens.cache??0;r.tokens.emit(c+f)}}}}}0&&(module.exports={blindVariation,errorCritique,refineLoop});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import '../../node-
|
|
1
|
+
import '../../node-BYInONRr.cjs';
|
|
2
2
|
import '../../extra/sources.cjs';
|
|
3
|
-
import '../../graph-
|
|
4
|
-
import '../../index-
|
|
5
|
-
export { A as AnalyzeEvent, B as BlindVariationContext, d as BlindVariationOptions, C as ConvergenceOptions, D as DatasetItem, e as DecideEvent, f as ErrorCritiqueContext, g as ErrorCritiqueOptions, a as EvalResult, h as EvaluateEvent, E as Evaluator, F as Feedback, G as GenerateEvent, I as Iteration, j as RefineLoopGraph, b as RefineLoopOptions, c as RefineStatus, R as RefineStrategy, k as blindVariation, l as errorCritique, r as refineLoop } from '../../index-
|
|
6
|
-
import '../../meta-
|
|
3
|
+
import '../../graph-BUwMAxJI.cjs';
|
|
4
|
+
import '../../index-BndG0cpK.cjs';
|
|
5
|
+
export { A as AnalyzeEvent, B as BlindVariationContext, d as BlindVariationOptions, C as ConvergenceOptions, D as DatasetItem, e as DecideEvent, f as ErrorCritiqueContext, g as ErrorCritiqueOptions, a as EvalResult, h as EvaluateEvent, E as Evaluator, F as Feedback, G as GenerateEvent, I as Iteration, j as RefineLoopGraph, b as RefineLoopOptions, c as RefineStatus, R as RefineStrategy, k as blindVariation, l as errorCritique, r as refineLoop } from '../../index-PsVHpPwP.cjs';
|
|
6
|
+
import '../../meta-Ct9nqQS5.cjs';
|
|
7
7
|
import '../../extra/storage-core.cjs';
|
|
8
8
|
import '../../extra/storage-tiers.cjs';
|
|
9
|
-
import '../../reactive-log-
|
|
9
|
+
import '../../reactive-log-_zeEnB9H.cjs';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import '../../node-
|
|
1
|
+
import '../../node-BYInONRr.js';
|
|
2
2
|
import '../../extra/sources.js';
|
|
3
|
-
import '../../graph-
|
|
4
|
-
import '../../index-
|
|
5
|
-
export { A as AnalyzeEvent, B as BlindVariationContext, d as BlindVariationOptions, C as ConvergenceOptions, D as DatasetItem, e as DecideEvent, f as ErrorCritiqueContext, g as ErrorCritiqueOptions, a as EvalResult, h as EvaluateEvent, E as Evaluator, F as Feedback, G as GenerateEvent, I as Iteration, j as RefineLoopGraph, b as RefineLoopOptions, c as RefineStatus, R as RefineStrategy, k as blindVariation, l as errorCritique, r as refineLoop } from '../../index-
|
|
6
|
-
import '../../meta-
|
|
3
|
+
import '../../graph-30XSgtVX.js';
|
|
4
|
+
import '../../index-DszPlZzK.js';
|
|
5
|
+
export { A as AnalyzeEvent, B as BlindVariationContext, d as BlindVariationOptions, C as ConvergenceOptions, D as DatasetItem, e as DecideEvent, f as ErrorCritiqueContext, g as ErrorCritiqueOptions, a as EvalResult, h as EvaluateEvent, E as Evaluator, F as Feedback, G as GenerateEvent, I as Iteration, j as RefineLoopGraph, b as RefineLoopOptions, c as RefineStatus, R as RefineStrategy, k as blindVariation, l as errorCritique, r as refineLoop } from '../../index-PqbnoScQ.js';
|
|
6
|
+
import '../../meta-D8OyedKp.js';
|
|
7
7
|
import '../../extra/storage-core.js';
|
|
8
8
|
import '../../extra/storage-tiers.js';
|
|
9
|
-
import '../../reactive-log-
|
|
9
|
+
import '../../reactive-log-BlAsPLl2.js';
|