@graphrefly/graphrefly 0.42.0 → 0.44.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/{cascading-CH-_VwG9.d.cts → cascading-BglDkMdX.d.cts} +2 -2
- package/dist/{cascading-OgKQZjsa.d.ts → cascading-MFgxu7Yo.d.ts} +2 -2
- package/dist/chunk-2T7U5EU6.js +1 -0
- package/dist/chunk-5M4CCMMD.js +45 -0
- package/dist/{chunk-YGL7FPVQ.js → chunk-5XJ6B66J.js} +1 -1
- package/dist/{chunk-NWXQIOIB.js → chunk-6X7AFUJV.js} +1 -1
- package/dist/chunk-7K6PWTDQ.js +1 -0
- package/dist/{chunk-D27JNOLZ.js → chunk-7LIAPXJB.js} +1 -1
- package/dist/{chunk-CLD3F4R5.js → chunk-7WPU3UHQ.js} +1 -1
- package/dist/{chunk-NNKJUORL.js → chunk-A5WCQ5NO.js} +1 -1
- package/dist/chunk-APPIWSGD.js +84 -0
- package/dist/{chunk-TZQPPQEQ.js → chunk-BEZWM2SY.js} +1 -1
- package/dist/{chunk-5QRRKBUT.js → chunk-CB676TKJ.js} +1 -1
- package/dist/{chunk-KT5DTRBP.js → chunk-CE6TI2TL.js} +1 -1
- package/dist/{chunk-6YFZMUMR.js → chunk-CLVB32RD.js} +1 -1
- package/dist/{chunk-2K5RXLAH.js → chunk-CRVT7D2P.js} +1 -1
- package/dist/chunk-D7GPHKFH.js +1 -0
- package/dist/{chunk-FUZ6S2DY.js → chunk-DHRX7JX4.js} +1 -1
- package/dist/chunk-FZMYDOWV.js +1 -0
- package/dist/{chunk-35JTVPOX.js → chunk-GHBWHMRZ.js} +1 -1
- package/dist/{chunk-KGKJCHEK.js → chunk-GLERH466.js} +1 -1
- package/dist/{chunk-CISGGAIF.js → chunk-HIDYF36O.js} +1 -1
- package/dist/chunk-HITNVN6B.js +3 -0
- package/dist/{chunk-7ARY3Y3T.js → chunk-HY4DJBA7.js} +1 -1
- package/dist/chunk-KZIEYVXN.js +1 -0
- package/dist/{chunk-IZM3UEH3.js → chunk-N4MQX6JU.js} +1 -1
- package/dist/{chunk-FDZAZNRO.js → chunk-N7FHEL4D.js} +1 -1
- package/dist/chunk-NTEURFZH.js +1 -0
- package/dist/{chunk-4QH6VJF4.js → chunk-OIVP6KFV.js} +1 -1
- package/dist/{chunk-KCACBSJH.js → chunk-OPHBU3LG.js} +1 -1
- package/dist/{chunk-Q7QQQA3I.js → chunk-OYQOZP2F.js} +1 -1
- package/dist/{chunk-7B7ELAT2.js → chunk-PTZK576G.js} +1 -1
- package/dist/{chunk-DEJTNNQC.js → chunk-ST7UXLWR.js} +1 -1
- package/dist/chunk-SVY7VUYU.js +1 -0
- package/dist/{chunk-WHMUB5QB.js → chunk-TK3NWWD4.js} +1 -1
- package/dist/chunk-UNGSTR4X.js +61 -0
- package/dist/{chunk-VRALOYRD.js → chunk-VV4N5P64.js} +1 -1
- package/dist/chunk-W3I423PS.js +1 -0
- package/dist/{chunk-HZKW2AAB.js → chunk-WJR24TAG.js} +1 -1
- package/dist/{chunk-F3IGTWCQ.js → chunk-XTGKMHSW.js} +1 -1
- package/dist/{chunk-LDQ3IUIP.js → chunk-YBB7ZGTY.js} +1 -1
- package/dist/{chunk-G5VBJ5K6.js → chunk-Z4NPUARF.js} +1 -1
- package/dist/{chunk-KRH66M4O.js → chunk-ZGNQRPDT.js} +1 -1
- package/dist/{chunk-AGNM6RS6.js → chunk-ZKPSFFKU.js} +1 -1
- package/dist/{chunk-KY2LMAXU.js → chunk-ZLV5SQSX.js} +1 -1
- package/dist/compat/index.cjs +5 -5
- 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.cjs +1 -1
- package/dist/compat/jotai/index.d.cts +2 -2
- package/dist/compat/jotai/index.d.ts +2 -2
- package/dist/compat/jotai/index.js +1 -1
- package/dist/compat/nanostores/index.cjs +1 -1
- package/dist/compat/nanostores/index.d.cts +2 -2
- package/dist/compat/nanostores/index.d.ts +2 -2
- package/dist/compat/nanostores/index.js +1 -1
- package/dist/compat/nestjs/index.cjs +5 -5
- 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 -3
- 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/core/index.cjs +1 -1
- package/dist/core/index.d.cts +3 -4
- package/dist/core/index.d.ts +3 -4
- package/dist/core/index.js +1 -1
- package/dist/{decay-CdEBmDIs.d.ts → decay-BvOWTZ00.d.ts} +2 -2
- package/dist/{decay-2ZukgQ4o.d.cts → decay-CFlLvXUT.d.cts} +2 -2
- package/dist/extra/browser.cjs +1 -1
- package/dist/extra/browser.d.cts +1 -1
- package/dist/extra/browser.d.ts +1 -1
- package/dist/extra/browser.js +1 -1
- package/dist/extra/index.cjs +15 -15
- package/dist/extra/index.d.cts +10 -10
- package/dist/extra/index.d.ts +10 -10
- package/dist/extra/index.js +1 -1
- package/dist/extra/node.cjs +2 -2
- package/dist/extra/node.d.cts +1 -1
- package/dist/extra/node.d.ts +1 -1
- package/dist/extra/node.js +1 -1
- package/dist/extra/operators.cjs +1 -1
- package/dist/extra/operators.d.cts +9 -1
- package/dist/extra/operators.d.ts +9 -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.d.cts +3 -3
- package/dist/extra/render/index.d.ts +3 -3
- package/dist/extra/sources.cjs +3 -3
- 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.cjs +1 -1
- package/dist/extra/storage-browser.d.cts +1 -1
- package/dist/extra/storage-browser.d.ts +1 -1
- package/dist/extra/storage-browser.js +1 -1
- package/dist/{fallback-Ctlj2tMY.d.cts → fallback-74oxi34l.d.cts} +1 -1
- package/dist/{fallback-CqYVLL6X.d.ts → fallback-DUyyBTBK.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-C4SHb3Ly.d.cts → graph-CWvEUQAq.d.cts} +196 -3
- package/dist/{graph-7VguS7a4.d.ts → graph-D9LFnda9.d.ts} +196 -3
- package/dist/{index-LIpQQE9f.d.cts → index-5k1T6jl0.d.cts} +9 -9
- package/dist/{index-CPNSy-U0.d.cts → index-9770hRuQ.d.cts} +23 -4
- package/dist/{index-CEMx8n40.d.cts → index-B-_tFaqV.d.cts} +4 -4
- package/dist/{index-2B7u2pVn.d.cts → index-B17QddL1.d.cts} +4 -4
- package/dist/{index-B-i4_g3k.d.ts → index-B1F8Enjf.d.ts} +61 -8
- package/dist/{index-DBevwHj_.d.ts → index-B5S8ULbU.d.ts} +3 -3
- package/dist/{index-Dgs8zcj7.d.ts → index-B8YnZpIR.d.ts} +2 -2
- package/dist/{index-B3OTH1dV.d.ts → index-BHskSB8v.d.ts} +28 -17
- package/dist/{index-sl4NyzQx.d.cts → index-BIYAkbAi.d.cts} +1 -1
- package/dist/{index-C9kSENB4.d.cts → index-BQSKmbuG.d.cts} +1 -1
- package/dist/{index-tJoTcnHh.d.cts → index-BaQaY_IQ.d.cts} +2 -2
- package/dist/{index-CJK1JkYy.d.ts → index-BmZXHqkE.d.ts} +1 -1
- package/dist/{index-pT8sCpOJ.d.ts → index-BoJ5JHxI.d.ts} +12 -3
- package/dist/{index-BeT2r7sk.d.ts → index-BocU7pqs.d.ts} +23 -4
- package/dist/{index-ChOyVLKm.d.cts → index-BrPrLl4e.d.cts} +1 -1
- package/dist/{index-D-Xs74HZ.d.cts → index-BxNs2HB9.d.cts} +33 -9
- package/dist/{index-Bf7eqeSF.d.ts → index-Byu-OpX_.d.ts} +2 -2
- package/dist/{index-BoLv_OfD.d.cts → index-C1T3d7V-.d.cts} +61 -8
- package/dist/{index-BTQtTb_H.d.cts → index-C5ri2Axc.d.cts} +3 -3
- package/dist/{index-z96luz5O.d.cts → index-C5stwKcw.d.cts} +1 -1
- package/dist/{index-CZmcDtFn.d.ts → index-C9l6OEBL.d.ts} +1 -1
- package/dist/{index-CCq87F7t.d.ts → index-CBBLl_rc.d.ts} +1 -1
- package/dist/{index-D6egPFAL.d.ts → index-CBGUK09R.d.ts} +4 -4
- package/dist/{index-C0-Jv1kP.d.cts → index-CC-AvFTy.d.cts} +12 -3
- package/dist/{index-DQo8xBgd.d.ts → index-CJF1URuX.d.ts} +9 -9
- package/dist/{index-BJX94aud.d.cts → index-CK29LV56.d.cts} +1 -1
- package/dist/{index-BP8a88zx.d.ts → index-CMh5Rz1y.d.ts} +4 -4
- package/dist/{index-CvrqGfNS.d.ts → index-CPQlGA29.d.ts} +1 -1
- package/dist/{index-Bbkgpt5t.d.ts → index-CR8QpwX8.d.ts} +49 -24
- package/dist/{index-Du7u1lSf.d.cts → index-CS0LTlB8.d.cts} +4 -4
- package/dist/{index-Bc41FuHp.d.cts → index-CSOmP7xT.d.cts} +2 -2
- package/dist/{index-BsT7F2et.d.ts → index-CYq8vAyV.d.ts} +2 -2
- package/dist/{index-Bn4zHYLj.d.ts → index-CZ3r5Rxp.d.ts} +4 -4
- package/dist/{index-HoU88d5U.d.cts → index-CasX6Pfq.d.cts} +68 -9
- package/dist/{index-BG0BN3PB.d.ts → index-CdAlHFEt.d.ts} +1 -1
- package/dist/{index-CpyNFqkB.d.ts → index-CdTelp1M.d.ts} +8 -4
- package/dist/{index-D8l8hNXn.d.ts → index-CeFiHtAg.d.ts} +4 -4
- package/dist/{index-DmAgG5CI.d.cts → index-Cj3WohTd.d.cts} +8 -4
- package/dist/{index-BtAsBp8K.d.cts → index-Climxqsu.d.cts} +4 -4
- package/dist/{index-CJIuLu2f.d.cts → index-Co7uli2l.d.cts} +28 -17
- package/dist/{index-DIOoAZUX.d.ts → index-CviRnE4K.d.ts} +1 -1
- package/dist/{index-Dhc7a7Xo.d.cts → index-Cwv0KWcU.d.cts} +2 -2
- package/dist/{index-Dn-wI9g4.d.ts → index-CzLVrjxn.d.ts} +2 -2
- package/dist/{index-DO9XxMzS.d.ts → index-D0aciIex.d.cts} +3 -18
- package/dist/{index-4Uz-e_fL.d.ts → index-DHen9Klo.d.ts} +33 -9
- package/dist/{index-3NmAfcH0.d.cts → index-DV_1YuVk.d.cts} +40 -8
- package/dist/{index-BdGtBX-X.d.cts → index-Dc4AYqrJ.d.cts} +3 -3
- package/dist/{index-Dmqp7KjD.d.ts → index-Dgl1HpPn.d.ts} +1 -1
- package/dist/{index-CJQm0g38.d.ts → index-DisjX8a-.d.ts} +40 -8
- package/dist/{index-B11anra4.d.cts → index-UPSiS-X7.d.cts} +49 -24
- package/dist/{index-DBIqYS43.d.cts → index-Yq60JP3s.d.ts} +3 -18
- package/dist/{index-f5IivDUX.d.cts → index-ZVQhLa2i.d.cts} +1 -1
- package/dist/{index-hHcaFlJX.d.cts → index-_6ODbuOu.d.cts} +1 -1
- package/dist/{index-BVpm6noz.d.cts → index-hcDJ8PSI.d.cts} +1 -1
- package/dist/{index-DBHK8O6H.d.ts → index-nozs3fFC.d.ts} +3 -3
- package/dist/{index-BUYXac2c.d.ts → index-p09KSrTN.d.ts} +68 -9
- package/dist/{index-C7O6r5fV.d.ts → index-sqkqlb1p.d.ts} +1 -1
- package/dist/{index-CZjOhcBy.d.cts → index-tRCxuAXF.d.cts} +2 -2
- package/dist/index.cjs +48 -48
- package/dist/index.d.cts +42 -43
- package/dist/index.d.ts +42 -43
- package/dist/index.js +1 -1
- package/dist/{node-ClS5yC-B.d.cts → node-kK3CvTrR.d.cts} +1 -1
- package/dist/{node-ClS5yC-B.d.ts → node-kK3CvTrR.d.ts} +1 -1
- package/dist/{observable-BsBzUrcI.d.ts → observable-DWjNfLvC.d.ts} +1 -1
- package/dist/{observable-DLGPPtb8.d.cts → observable-e3eiPPFy.d.cts} +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 +16 -16
- package/dist/patterns/ai/index.d.cts +16 -17
- package/dist/patterns/ai/index.d.ts +16 -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/cqrs/index.cjs +3 -3
- 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 -5
- 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 -3
- 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 +16 -16
- 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/harness/index.cjs +9 -9
- package/dist/patterns/harness/index.d.cts +10 -11
- package/dist/patterns/harness/index.d.ts +10 -11
- package/dist/patterns/harness/index.js +1 -1
- package/dist/patterns/inspect/index.cjs +3 -3
- package/dist/patterns/inspect/index.d.cts +7 -7
- package/dist/patterns/inspect/index.d.ts +7 -7
- package/dist/patterns/inspect/index.js +1 -1
- package/dist/patterns/job-queue/index.cjs +3 -3
- 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/memory/index.cjs +3 -3
- package/dist/patterns/memory/index.d.cts +6 -6
- package/dist/patterns/memory/index.d.ts +6 -6
- package/dist/patterns/memory/index.js +1 -1
- package/dist/patterns/messaging/index.cjs +3 -3
- 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 -3
- package/dist/patterns/orchestration/index.d.cts +6 -7
- package/dist/patterns/orchestration/index.d.ts +6 -7
- package/dist/patterns/orchestration/index.js +1 -1
- package/dist/patterns/process/index.cjs +3 -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 -4
- 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 -3
- 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/surface/index.cjs +10 -10
- 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-WBlobVhU.d.cts → pipeline-graph-CIKhynsF.d.cts} +11 -6
- package/dist/{pipeline-graph-v8fMvqNk.d.ts → pipeline-graph-Sgj0gCwn.d.ts} +11 -6
- package/dist/{reactive-layout-v7KPvxoc.d.ts → reactive-layout-DOTs9P3X.d.ts} +2 -2
- package/dist/{reactive-layout-Dsvob4zD.d.cts → reactive-layout-DgctbqZo.d.cts} +2 -2
- package/dist/{reactive-log-BezYsbA_.d.ts → reactive-log-BKALbfal.d.ts} +1 -1
- package/dist/{reactive-log-B00laMSQ.d.cts → reactive-log-DIGdYqQ6.d.cts} +1 -1
- package/dist/{reactive-map-48mnZ-nu.d.cts → reactive-map-CEFGp8TK.d.cts} +1 -1
- package/dist/{reactive-map-BVVPdvmi.d.ts → reactive-map-DS_SIAxv.d.ts} +1 -1
- package/dist/resilience-6LYQJAC5.js +1 -0
- package/dist/sugar-DQjFmVqb.d.cts +399 -0
- package/dist/sugar-fhLIE7TT.d.ts +399 -0
- package/dist/{topology-tree-BSdfSwMi.d.cts → topology-tree-Bcz27hpF.d.cts} +1 -1
- package/dist/{topology-tree-BNGvuG82.d.ts → topology-tree-xvaD0fOX.d.ts} +1 -1
- package/dist/{types-B1jDWVsM.d.cts → types-C0_yquda.d.cts} +1 -1
- package/dist/{types-DkzUUs0H.d.ts → types-CWFysE9E.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-3ERTUW2J.js +0 -45
- package/dist/chunk-3K7HA4Y6.js +0 -1
- package/dist/chunk-3ZZX7M25.js +0 -1
- package/dist/chunk-4I45FVQS.js +0 -1
- package/dist/chunk-5ST42ESJ.js +0 -1
- package/dist/chunk-7VKFXLZQ.js +0 -84
- package/dist/chunk-ACMJ2ZPS.js +0 -3
- package/dist/chunk-AS3TV2TV.js +0 -1
- package/dist/chunk-LPRWATHB.js +0 -61
- package/dist/chunk-LYCLF26R.js +0 -1
- package/dist/chunk-VE5SIZEM.js +0 -1
- package/dist/chunk-XLQPNNIC.js +0 -1
- package/dist/meta-BgVAsg9j.d.ts +0 -102
- package/dist/meta-vE8bxW1E.d.cts +0 -102
- package/dist/resilience-445VFFXQ.js +0 -1
- package/dist/sugar-CH-2ZY90.d.ts +0 -203
- package/dist/sugar-DStZfUEK.d.cts +0 -203
package/dist/extra/sources.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var gt=Object.defineProperty;var gr=Object.getOwnPropertyDescriptor;var br=Object.getOwnPropertyNames;var yr=Object.prototype.hasOwnProperty;var G=(n,e)=>()=>(n&&(e=n(n=0)),e);var bt=(n,e)=>{for(var t in e)gt(n,t,{get:e[t],enumerable:!0})},vr=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of br(e))!yr.call(n,o)&&o!==t&>(n,o,{get:()=>e[o],enumerable:!(r=gr(e,o))||r.enumerable});return n};var wr=n=>vr(gt({},"__esModule",{value:!0}),n);function X(){return Math.trunc(performance.now()*1e6)}function ve(){return Date.now()*1e6}var we=G(()=>{"use strict"});var oe,x,M,D,te,q,ne,B,E,N,Te,yt,Tr,vt,_r,Nr,wt,rn,on,sn,Tt,ie=G(()=>{"use strict";oe=Symbol.for("graphrefly/START"),x=Symbol.for("graphrefly/DATA"),M=Symbol.for("graphrefly/DIRTY"),D=Symbol.for("graphrefly/RESOLVED"),te=Symbol.for("graphrefly/INVALIDATE"),q=Symbol.for("graphrefly/PAUSE"),ne=Symbol.for("graphrefly/RESUME"),B=Symbol.for("graphrefly/TEARDOWN"),E=Symbol.for("graphrefly/COMPLETE"),N=Symbol.for("graphrefly/ERROR"),Te=Object.freeze([M]),yt=Object.freeze([D]),Tr=Object.freeze([te]),vt=Object.freeze([oe]),_r=Object.freeze([E]),Nr=Object.freeze([B]),wt=Object.freeze([Te]),rn=Object.freeze([yt]),on=Object.freeze([Tr]),sn=Object.freeze([_r]),Tt=Object.freeze([Nr])});function un(n,e){let t=new TextEncoder().encode(n.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${n.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let r=n.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let 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),i=0;return s[i++]=_t,s[i++]=t.length,s.set(t,i),i+=t.length,s[i++]=r>>>8&255,s[i++]=r&255,s.set(e,i),s}function dn(n,e){if(n.length<an)throw new Error(`decodeEnvelope: bytes too short (${n.length} < ${an})`);let t=0,r=n[t++];if(r!==_t)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${_t})`);let o=n[t++];if(o===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+o+2>n.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+o+2} bytes, have ${n.length})`);let s=new TextDecoder().decode(n.subarray(t,t+o));t+=o;let i=(n[t]<<8|n[t+1])>>>0;t+=2;let a=n.subarray(t),u=e.lookupCodec(s);if(u==null)throw new Error(`decodeEnvelope: codec "${s}" not registered (envelope codec_v=${i})`);return{codec:u,codecVersion:i,payload:a}}function cn(n){n.registerCodec(Or)}var Or,_t,an,Nt=G(()=>{"use strict";Or={name:"json",version:1,contentType:"application/json",encode(n){let e=JSON.stringify(n);return new TextEncoder().encode(e)},decode(n,e){let t=new TextDecoder().decode(n);return JSON.parse(t)}},_t=1,an=4});function ze(n){if(n==null)return _e;let{type:e,id:t,...r}=n;return{type:e??"system",id:t??"",...r}}var _e,Ot=G(()=>{"use strict";_e={type:"system",id:""}});function Ue(){return Ne>0||De}function ln(){return Ne>0}function ke(n){Ne>0?Me.push(n):n()}function Ge(n){Ne+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(Ne-=1,Ne===0)if(e){if(!De){let t=Me.splice(0);for(let r of t)try{r()}catch{}ce.length=0,le.length=0,Oe.length=0}}else kr()}}function kr(){let n=!De;n&&(De=!0);let e=[],t=0;try{for(;ce.length>0||le.length>0||Oe.length>0||n&&Me.length>0;){if(n&&Me.length>0){let s=Me.splice(0);for(let i of s)try{i()}catch(a){e.push(a)}continue}if(t+=1,t>1e3)throw ce.length=0,le.length=0,Oe.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(ce.length>0?ce:le.length>0?le:Oe).splice(0);for(let s of o)try{s()}catch(i){e.push(i)}}}finally{n&&(De=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function We(n,e,t){if(e.length===0)return;if(e.length===1){let d=t(e[0][0]);if(d<3||!Ue()){n(e);return}(d>=5?Oe:d===4?le:ce).push(()=>n(e));return}let r=e.length,o=r,s=r,i=r,a=0;for(;a<r&&t(e[a][0])<3;)a++;for(o=a;a<r&&t(e[a][0])===3;)a++;for(s=a;a<r&&t(e[a][0])===4;)a++;i=a;let u=Ue();if(o>0){let d=e.slice(0,o);n(d)}if(s>o){let d=e.slice(o,s);u?ce.push(()=>n(d)):n(d)}if(i>s){let d=e.slice(s,i);u?le.push(()=>n(d)):n(d)}if(r>i){let d=e.slice(i,r);u?Oe.push(()=>n(d)):n(d)}}var Ne,De,ce,le,Oe,Me,He=G(()=>{"use strict";Ne=0,De=!1,ce=[],le=[],Oe=[],Me=[]});function fn(n){n.registerMessageType(oe,{tier:0,wireCrossing:!1}),n.registerMessageType(M,{tier:1,wireCrossing:!1}),n.registerMessageType(te,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(q,{tier:2,wireCrossing:!1}),n.registerMessageType(ne,{tier:2,wireCrossing:!1}),n.registerMessageType(x,{tier:3,wireCrossing:!0}),n.registerMessageType(D,{tier:3,wireCrossing:!0}),n.registerMessageType(E,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(N,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(B,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Ke,pn=G(()=>{"use strict";ie();Ke=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 r=this._messageTypes.get(t);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}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 kt(n){let e=xr.filter(t=>n({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}var Q,xr,qe=G(()=>{"use strict";Q=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}},xr=["human","llm","wallet","system"]});function xt(n){if(n===void 0)return null;if(typeof n=="number"){if(!Number.isFinite(n))throw new TypeError(`Cannot hash non-finite number: ${n}`);if(Number.isInteger(n)&&!Number.isSafeInteger(n))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${n}. Cross-language cid parity is not guaranteed for unsafe integers.`);return n}if(typeof n=="string"||typeof n=="boolean"||n===null)return n;if(Array.isArray(n))return n.map(xt);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=xt(n[t]);return e}return null}function Sr(n){let e=Rr.encode(n),t=e.length,r=t*8,o=t+9+63&-64,s=new Uint8Array(o);s.set(e),s[t]=128;let i=new DataView(s.buffer);i.setUint32(o-4,r>>>0,!1),i.setUint32(o-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,u=3144134277,d=1013904242,c=2773480762,l=1359893119,h=2600822924,p=528734635,f=1541459225,g=new Uint32Array(64),m=(b,y)=>b>>>y|b<<32-y;for(let b=0;b<o;b+=64){for(let k=0;k<16;k++)g[k]=i.getUint32(b+k*4,!1);for(let k=16;k<64;k++){let U=g[k-15],V=g[k-2],I=m(U,7)^m(U,18)^U>>>3,ye=m(V,17)^m(V,19)^V>>>10;g[k]=g[k-16]+I+g[k-7]+ye>>>0}let y=a,v=u,w=d,_=c,R=l,S=h,C=p,A=f;for(let k=0;k<64;k++){let U=m(R,6)^m(R,11)^m(R,25),V=R&S^~R&C,I=A+U+V+Er[k]+g[k]>>>0,ye=m(y,2)^m(y,13)^m(y,22),lt=y&v^y&w^v&w,Ve=ye+lt>>>0;A=C,C=S,S=R,R=_+I>>>0,_=w,w=v,v=y,y=I+Ve>>>0}a=a+y>>>0,u=u+v>>>0,d=d+w>>>0,c=c+_>>>0,l=l+R>>>0,h=h+S>>>0,p=p+C>>>0,f=f+A>>>0}let T=b=>b.toString(16).padStart(8,"0");return T(a)+T(u)+T(d)+T(c)+T(l)+T(h)+T(p)+T(f)}function Et(n){let e=xt(n??null),t=JSON.stringify(e);return Sr(t).slice(0,16)}function Cr(){let n=globalThis.crypto;if(n?.randomUUID)return n.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function Rt(n,e,t){let r=t?.id??Cr();if(n===0)return{id:r,version:0};let s=(t?.hash??Et)(e);return{id:r,version:0,cid:s,prev:null}}function hn(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}var Er,Rr,mn=G(()=>{"use strict";Er=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]),Rr=new TextEncoder});function yn(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function St(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function Ye(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}function W(n,e,t){let r=vn(n)?n:[],o=typeof n=="function"?n:typeof e=="function"?e:void 0,s={};return vn(n)?s=(Ct(e)?e:t)??{}:Ct(n)?s=n:s=(Ct(e)?e:t)??{},new j(r,o,s)}var gn,bn,Ar,Dr,xe,j,vn,Ct,se=G(()=>{"use strict";Nt();Ot();He();we();pn();qe();ie();mn();gn=()=>{},bn=100;Ar=(n,e,t,r)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},Dr=(n,e,t,r)=>{let o=n;if(o._status==="completed"||o._status==="errored")return;let s=o._cached,i=s===void 0?[vt]:[vt,[x,s]];o._status==="dirty"&&i.push(Te),We(e,i,o._config.tierOf)},xe=new Ke({onMessage:Ar,onSubscribe:Dr});fn(xe);cn(xe);j=class n{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,r){this._config=r.config??xe,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=t,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??Et;let o=r.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?Rt(o,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(yn);let s={};for(let[a,u]of Object.entries(r.meta??{})){let d={initial:u,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(d.guard=r.guard),s[a]=new n([],void 0,d)}Object.freeze(s),this.meta=s,this._hasMeta=Object.keys(s).length>0;let i=this;this._actions={emit(a){i._emit([[x,a]])},down(a){i._emit(Ye(a))},up(a){i._emitUp(Ye(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let o=t?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let s=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??t?.id,u=i?.version??0,d=Rt(e,s,{id:a,hash:o});d.version=u,this._versioning=d,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=ze(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!t&&!r)return;let o=ze(e?.actor),s=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,s))throw new Q({actor:o,action:s,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(o,s))throw new Q({actor:o,action:s,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:ve()}}down(e,t){let r=Ye(e);r.length!==0&&(this._checkGuard(t),this._emit(r))}emit(e,t){this._checkGuard(t),this._emit([[x,e]])}up(e,t){if(this._deps.length===0)return;let r=Ye(e);if(r.length===0)return;this._checkGuard(t);let o=t??{internal:!0};this._validateUpTiers(r);for(let s of this._deps)s.node.up?.(r,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 r of e){let o=t(r[0]);if(o===3||o===4)throw new Error(`Node "${this.name}": tier-${o} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let u=ze(t);if(!this._guard(u,"observe"))throw new Q({actor:u,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let u of this._deps)St(u);if(this._partial===!1){for(let u of this._deps)if(u.prevData!==void 0||u.dataBatch.length!==0||u.terminal!==void 0||u.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(u){throw this._sinkCount-=1,u}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof s=="function")try{s()}catch{}throw u}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof 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 r=0;r<e;r++){let o=r,s=this._deps[r];s.unsub=gn,s.unsub=s.node.subscribe(i=>{if(s.unsub===null)return;let a=this._config.tierOf,u=!1;for(let d of i)a(d[0])>=3&&(u=!0),this._config.onMessage(this,d,{direction:"down-in",depIndex:o},this._actions);u&&this._maybeRunFnOnSettlement()}),t++}}catch(r){this._deps[t].unsub=null;for(let o=0;o<t;o++){let s=this._deps[o];if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}St(s)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let t=this._deps.length,r=yn(e);if(this._deps.push(r),this._sinks==null)return t;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(wt),r.unsub=gn;try{r.unsub=e.subscribe(o=>{if(r.unsub===null)return;let s=this._config.tierOf,i=!1;for(let a of o)s(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(o){throw r.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(r){this._emit([[N,this._wrapFnError("cleanup threw",r)]])}else if(t!=null&&typeof t=="object"){let r=t.deactivate;if(typeof r=="function")try{r()}catch(o){this._emit([[N,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let r of this._deps){if(r.unsub!=null){let o=r.unsub;r.unsub=null;try{o()}catch{}}St(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let r=this._deps[e],o=t[0];if(this._inspectorHooks!=null){let s={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(s)}if(o!==oe){if(o===M){this._depDirtied(r);return}if(o===te){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(on);return}if(o===q||o===ne){this._emit([t]);return}if(o===B){this._emit(Tt);return}if(o===x)this._depSettledAsData(r,t[1]);else if(o===D)this._depSettledAsResolved(r);else if(o===E)this._depSettledAsTerminal(r,!0);else if(o===N)this._depSettledAsTerminal(r,t[1]);else{this._emit([t]);return}if(!this._fn){(o===x||o===D)&&this._emit([t]),(o===E||o===N)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(wt))}_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(rn),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([[N,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(sn)}_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([[N,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([[N,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let t=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=t[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let o=this._deps.map(i=>i.terminal),s={prevData:r,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,s);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([[N,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>bn?(this._rerunDepth=0,this._emit([[N,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${bn} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let r=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[Te,e[0]]:e;let r=!0,o=!1,s=!1,i=-1;for(let u of e){let d=t(u[0]);d<i&&(r=!1),d===3&&(o=!0),u[0]===M&&(s=!0),i=d}let a=e;if(!r){let u=e.map((d,c)=>({m:d,i:c,tier:t(d[0])}));u.sort((d,c)=>d.tier-c.tier||d.i-c.i),a=u.map(d=>d.m)}if(o&&!s&&this._status!=="dirty"){let u=0;for(;u<a.length&&t(a[u][0])===0;)u++;return u===0?[Te,...a]:[...a.slice(0,u),Te,...a.slice(u)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let u=e[a];if(u[0]===N&&u[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 a=e.filter(u=>u[0]===B||u[0]===te);if(a.length===0)return;t=a}t=this._frameBatch(t);let o=null;for(let a=0;a<t.length;a++){let u=t[a],d=u[0];if(d!==q&&d!==ne){o?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${d===q?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let l=u[1];if(d===q)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(l),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(l))c=!1;else if(this._pauseLocks.delete(l),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())}}c?o?.push(u):o==null&&(o=t.slice(0,a))}if(o!=null){if(o.length===0)return;t=o}if(this._hasMeta&&t.some(a=>a[0]===B))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(Tt)}catch{}let{finalMessages:s,equalsError:i}=this._updateState(t);if(s.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:s})}catch{}}if(s.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,u=[];for(let d of s)a(d[0])===3?this._pauseBuffer.push(d):u.push(d);u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(s);i!=null&&this._emit([[N,i]])}_updateState(e){let t=this._config.tierOf,r,o,s=-1,i=0;for(let c of e)t(c[0])===3&&i++;let a=i<=1,u=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===x){u=c;break}}for(let c=0;c<e.length;c++){let l=e[c],h=l[0];if(h===x){if(l.length>=2){let p=!1;if(a&&this._cached!==void 0)try{p=this._equals(this._cached,l[1])}catch(f){o=this._wrapFnError("equals threw",f),s=c;break}if(p){r==null&&(r=e.slice(0,c)),r.push(yt),this._status="resolved";continue}this._cached=l[1],this._versioning!=null&&(u<0||c===u)&&hn(this._versioning,l[1],this._hashFn)}this._status="settled",r?.push(l)}else if(r?.push(l),h===M)this._status="dirty";else if(h===D)this._status="resolved";else if(h===E){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===N){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===te){if(this._cached!==void 0){let f=this._config.rigorRecorder;if(f!=null)try{f.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 f=p.invalidate;if(typeof f=="function")try{f()}catch{}}}else h===B&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=s>=0?r??e.slice(0,s):r??e;return o!=null?{finalMessages:d,equalsError:o}:{finalMessages:d}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let r of t)r(e)};_dispatchOrAccumulate(e){if(ln()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ke(()=>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)}},vn=n=>Array.isArray(n),Ct=n=>typeof n=="object"&&n!=null&&!Array.isArray(n)});function fe(n,e){return W([],{...e,initial:n})}function F(n,e){return W((r,o,s)=>n(o,s)??void 0,{describeKind:"producer",...e})}function At(n,e,t){return W(n,(o,s,i)=>{let a=o.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);s.emit(e(a,i))},{describeKind:"derived",...t})}var Je=G(()=>{"use strict";se()});function Pe(n,e,t){let r=new Set;for(let o of n.split(",")){let[s,i]=o.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${o}`);let u,d;if(s==="*")u=e,d=t;else if(s.includes("-")){let[c,l]=s.split("-");u=Number.parseInt(c,10),d=Number.parseInt(l,10)}else u=Number.parseInt(s,10),d=u;if(Number.isNaN(u)||Number.isNaN(d))throw new Error(`Invalid cron field: ${n}`);if(u<e||d>t)throw new Error(`Cron field out of range: ${n} (${e}-${t})`);if(u>d)throw new Error(`Invalid cron range: ${u}-${d} in ${n}`);for(let c=u;c<=d;c+=a)r.add(c)}return r}function wn(n){let e=n.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:Pe(e[0],0,59),hours:Pe(e[1],0,23),daysOfMonth:Pe(e[2],1,31),months:Pe(e[3],1,12),daysOfWeek:Pe(e[4],0,6)}}function Tn(n,e){return n.minutes.has(e.getMinutes())&&n.hours.has(e.getHours())&&n.daysOfMonth.has(e.getDate())&&n.months.has(e.getMonth()+1)&&n.daysOfWeek.has(e.getDay())}var _n=G(()=>{"use strict"});function H(n,e,t){return{[n]:!0,[`${n}_type`]:e,...t??{}}}var Dt=G(()=>{"use strict"});function Ie(n,e,t){if(e.length===0)throw new RangeError("budgetGate requires at least one constraint");let r=e.map(p=>p.node),o=[n,...r],s=new Mt,i=!1,a=!1,u=Symbol("budget-gate"),d=new Array(e.length);function c(){return e.every((p,f)=>p.check(d[f]))}function l(p){for(;s.size>0&&c();){let f=s.shift();p.emit(f)}s.size===0&&a&&(a=!1,p.down([[D]]))}return W([],(p,f)=>{for(let m=0;m<e.length;m++)d[m]=e[m].node.cache;let g=[];for(let m=0;m<o.length;m++){let T=o[m];g.push(T.subscribe(b=>{for(let y of b)h(y,m,f)}))}return()=>{for(let m of g)m()}},{...t,describeKind:"derived",meta:H("resilience","budget_gate",t?.meta)});function h(p,f,g){let m=p[0];if(f===0){if(m===x)return c()&&s.size===0?g.emit(p[1]):(s.push(p[1]),i||(i=!0,g.up([[q,u]]))),!0;if(m===M)return g.down([[M]]),!0;if(m===D)return s.size===0?g.down([[D]]):a=!0,!0;if(m===E||m===N){for(;s.size>0;)g.emit(s.shift());return a=!1,i&&(i=!1,g.up([[ne,u]])),g.down([p]),!0}return!1}if(m===x&&(d[f-1]=p[1]),m===x||m===D){let T=c();return T&&s.size>0?(l(g),s.size===0&&i&&(i=!1,g.up([[ne,u]]))):!T&&!i&&s.size>0&&(i=!0,g.up([[q,u]])),!0}return m===M?!0:m===N?(g.down([p]),!0):m===E}}var Mt,Nn=G(()=>{"use strict";ie();se();Dt();Mt=class{buf=[];head=0;get size(){return this.buf.length-this.head}push(e){this.buf.push(e)}shift(){if(this.head>=this.buf.length)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head++,this.head>32&&this.head*2>this.buf.length&&(this.buf=this.buf.slice(this.head),this.head=0),e}clear(){this.buf=[],this.head=0}}});function Pt(n,e){if(e!=null&&e.length>0)return new Set(e);switch(n){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function Mr(n){return n._describeKind!=null?n._describeKind:n._deps.length>0?"derived":n._fn!=null?"producer":"state"}function On(n){let e=new WeakSet,t={};for(let[r,o]of kn(n))t[r]=Gt(o,e);return t}function Gt(n,e){if(n==null)return n;let t=typeof n;if(t==="boolean"||t==="number"||t==="string")return n;if(t==="function")return"<function>";if(Array.isArray(n))return e.has(n)?"<cycle>":(e.add(n),n.map(r=>Gt(r,e)));if(t==="object"){let r=n;if(e.has(r))return"<cycle>";e.add(r);try{if(typeof r.subscribe=="function"&&"cache"in r)return"<Node>"}catch{return"<unserializable>"}let o={};for(let[s,i]of kn(r))o[s]=Gt(i,e);return o}return"<unserializable>"}function kn(n){let e=[],t;try{t=Object.keys(n)}catch{return e}for(let r of t)try{e.push([r,n[r]])}catch{e.push([r,"<unserializable>"])}return e}function re(n,e){let t={factory:n};return e!==void 0&&(t.factoryArgs=e),t}function Gr(n){let e={};for(let[t,r]of Object.entries(n.meta))try{e[t]=r.cache}catch{}return e}function It(n,e,t){let r=e==null,o=!r&&e!=null?[...e].filter(c=>c.startsWith("meta.")).map(c=>c.slice(5)):null,s=r||e.has("meta")||o!=null&&o.length>0,i="state",a=[];n instanceof j&&(i=Mr(n),a=n._deps.map(c=>c.node.name??""));let u={type:i,deps:a};(r||e.has("status"))&&(u.status=n.status);let d=n instanceof j?n._guard:void 0;if(s){let c={...Gr(n)};if(d!=null&&c.access===void 0&&(c.access=kt(d)),o!=null&&o.length>0&&!e.has("meta")){let l={};for(let h of o)h in c&&(l[h]=c[h]);u.meta=l}else u.meta=c}if(n.name!=null&&(u.name=n.name),(r||e.has("value"))&&(!t||i==="state")){n.status==="sentinel"&&(u.sentinel=!0);try{u.value=n.cache}catch{}}if((r||e.has("v"))&&n.v!=null){let c={id:n.v.id,version:n.v.version};"cid"in n.v&&(c.cid=n.v.cid,c.prev=n.v.prev),u.v=c}return(r||e.has("guard"))&&d!=null&&(u.guard=kt(d)),(r||e.has("lastMutation"))&&n.lastMutation!=null&&(u.lastMutation=n.lastMutation),u}var $e=G(()=>{"use strict";qe();se()});function xn(n){let e=new WeakSet,t=new WeakSet,r=[n],o=0;for(;r.length>0;){let s=r.pop();o+=Ir(s,e,t,r)}return o}function Ir(n,e,t,r){if(n==null)return 0;switch(typeof n){case"number":return z.number;case"boolean":return z.boolean;case"string":return z.string+n.length*2;case"bigint":return z.bigint+$r(n);case"symbol":return z.symbol;case"function":return e.has(n)?0:(e.add(n),z.function);case"undefined":return 0}let s=n;if(e.has(s))return 0;e.add(s);let i=s[Pr];if(typeof i=="function")try{let d=i.call(s);if(typeof d=="number"&&Number.isFinite(d))return d}catch{}if(s instanceof Date)return z.date;if(s instanceof RegExp)return z.regexp+s.source.length*2;if(s instanceof Error){let d=s.message?s.message.length*2:0,c=s.stack?s.stack.length*2:0;return z.error+d+c}if(typeof URL<"u"&&s instanceof URL)return z.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return z.promise;if(s instanceof WeakMap)return z.weakmap;if(s instanceof WeakSet)return z.weakset;if(s instanceof Map){let d=z.map;for(let[c,l]of s)d+=z.mapEntry,r.push(c),r.push(l);return d}if(s instanceof Set){let d=z.set;for(let c of s)d+=z.setEntry,r.push(c);return d}if(Array.isArray(s)){let d=z.array+s.length*8;for(let c of s)r.push(c);return d}if(s instanceof ArrayBuffer)return t.has(s)?0:(t.add(s),s.byteLength);if(ArrayBuffer.isView(s)){let d=s;return t.has(d.buffer)?48:(t.add(d.buffer),d.buffer.byteLength+48)}let a=z.object,u=Object.keys(s);for(let d of u){a+=z.string+d.length*2;try{r.push(s[d])}catch{}}return a}function $r(n){let e=n<0n?-n:n;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}var z,Pr,En=G(()=>{"use strict";z={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 Rn(n,e,t,r={}){let o=e in n.nodes,s=t in n.nodes;if(!o)return Ze(e,t,"no-such-from");if(!s)return Ze(e,t,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(r.findCycle===!0){let d=Lr(n,e,r);if(d!=null)return d}let u=Xe(e,n.nodes[e],0,r);return Qe(e,t,[u])}if(i===0)return Ze(e,t,"no-path");let a=Sn(n,e,t,i);return a.found?Qe(e,t,Cn(n,a.pathOrder,r)):Ze(e,t,a.truncated?"max-depth-exceeded":"no-path")}function Sn(n,e,t,r){let o=new Map,s=[{path:t,depth:0}],i=new Set([t]),a=0,u=!1;for(;a<s.length;){let l=s[a++];if(l.path===e)break;if(r!=null&&l.depth>=r){let g=n.nodes[l.path];g?.deps&&g.deps.length>0&&(u=!0);continue}let h=n.nodes[l.path];if(h==null)continue;let p=h.deps??[],f=new Map;for(let g=0;g<p.length;g++){let m=p[g];if(!m)continue;let T=f.get(m);T==null&&(T=[],f.set(m,T)),T.push(g)}for(let[g,m]of f)i.has(g)||(i.add(g),o.set(g,{from:l.path,depIndices:m}),s.push({path:g,depth:l.depth+1}))}if(!o.has(e))return{found:!1,pathOrder:[],truncated:u};let d=[{path:e}],c=e;for(;c!==t;){let l=o.get(c);if(l==null)return{found:!1,pathOrder:[],truncated:!1};d[d.length-1].depIndices=l.depIndices,d.push({path:l.from}),c=l.from}return{found:!0,pathOrder:d,truncated:!1}}function Lr(n,e,t){let r=n.nodes[e];if(r==null)return null;let o=r.deps??[],s=[];for(let a=0;a<o.length;a++)o[a]===e&&s.push(a);if(s.length>0){let a=Xe(e,r,0,t);a.dep_index=s[0];let u=Xe(e,r,1,t);return Qe(e,e,[a,u])}let i=null;for(let a=0;a<o.length;a++){let u=o[a];if(!u||u===e)continue;let d=Sn(n,u,e,t.maxDepth);d.found&&(i==null||d.pathOrder.length<i.pathOrder.length)&&(i=d,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...d.pathOrder],truncated:!1})}return i==null?null:Qe(e,e,Cn(n,i.pathOrder,t))}function Cn(n,e,t){return e.map((r,o)=>{let s=n.nodes[r.path],i=Xe(r.path,s,o,t);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function Xe(n,e,t,r){let o={path:n,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=r.annotations?.get(n)??e.annotation;s!=null&&(o.annotation=s);let i=r.lastMutations?.get(n)??e.lastMutation;return i!=null&&(o.lastMutation=i),o}function Qe(n,e,t){return An(n,e,!0,"ok",t)}function Ze(n,e,t){return An(n,e,!1,t,[])}function An(n,e,t,r,o){let s=Fr(n,e,t,r,o);return{from:n,to:e,found:t,reason:r,steps:o,text:s,toJSON(){return{from:n,to:e,found:t,reason:r,steps:o}}}}function Fr(n,e,t,r,o){if(!t)switch(r){case"no-such-from":return`explainPath: no node named "${n}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${n}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${n}" to "${e}"`}let s=[`Causal path: ${n} \u2192 ${e} (${o.length} step(s))`];for(let i of o){let u=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(s.push(u),"value"in i&&s.push(` value: ${Br(i.value)}`),i.annotation!=null&&s.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let d=i.lastMutation.actor;s.push(` actor: ${d.type}${d.id?`:${d.id}`:""}`)}}return s.join(`
|
|
2
|
-
`)}function
|
|
3
|
-
`)}function Bn(n){if(n.version!==he)throw new Error(`unsupported snapshot version ${String(n.version)} (expected ${he})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in n))throw new Error(`snapshot missing required key "${e}"`);if(typeof n.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof n.nodes!="object"||n.nodes===null||Array.isArray(n.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(n.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(n.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function zr(n,e){let t=new WeakMap,r=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=t.get(o);if(i==null&&(i=new WeakSet,t.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,u=s.constructor;if(a!==u)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 h=s;if(o.length!==h.length)return!1;for(let p=0;p<o.length;p++)if(!r(o[p],h[p]))return!1;return!0}if(o instanceof Map){let h=s;if(o.size!==h.size)return!1;for(let[p,f]of o)if(!h.has(p)||!r(f,h.get(p)))return!1;return!0}if(o instanceof Set){let h=s;if(o.size!==h.size)return!1;for(let p of o){let f=!1;for(let g of h)if(r(p,g)){f=!0;break}if(!f)return!1}return!0}if(ArrayBuffer.isView(o)){let h=o,p=s;if(h.length!==p.length)return!1;for(let f=0;f<h.length;f++)if(h[f]!==p[f])return!1;return!0}let d=Object.keys(o),c=Object.keys(s);if(d.length!==c.length)return!1;let l=new Set(c);for(let h of d)if(!l.has(h)||!r(o[h],s[h]))return!1;return!0};return r(n,e)}function Ur(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function et(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let o=n.indexOf("]",t+1);if(o<=t+1){e+="\\[";continue}let s=n.slice(t+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,t=o;continue}e+=Ur(r)}return e+="$",new RegExp(e)}function Vt(n){if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||n==null)return String(n);try{return JSON.stringify(n)}catch{return"[unserializable]"}}function Kr(n){return n==="none"?Hr:n==="ansi"||n==null?Wr:{data:n.data??"",dirty:n.dirty??"",resolved:n.resolved??"",invalidate:n.invalidate??"",pause:n.pause??"",resume:n.resume??"",complete:n.complete??"",error:n.error??"",teardown:n.teardown??"",derived:n.derived??"",path:n.path??"",reset:n.reset??""}}function Vn(n){if(n==null)return{};let e=n.detail;return e==="full"?{...n,structured:n.structured??!0,timeline:n.timeline??!0,causal:n.causal??!0,derived:n.derived??!0}:e==="minimal"?{...n,structured:n.structured??!0}:n.format==="stage-log"?{...n,structured:n.structured??!0,timeline:n.timeline??!0}:n}function qr(n,e,t){for(let r=0;r<n.length;r++){let o=n.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${t} "${n}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function jt(n,e,t){if(n==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(n.includes(L))throw new Error(`Graph "${e}": ${t} "${n}" must not contain '${L}' (path separator)`);if(n===ee)throw new Error(`Graph "${e}": ${t} name "${ee}" is reserved for meta companion paths`);qr(n,e,t)}function Yr(n,e){if(n==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=n.split(L);for(let r of t)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function Jr(n,e){let t=!1;for(let o of n)if(!e.isMetaPassthrough(o[0])){t=!0;break}return t?n.filter(o=>e.isMetaPassthrough(o[0])):n}function zn(n){for(let e of n._mounts.values())zn(e);for(let e of n._nodes.values())try{e.down([[B]],{internal:!0})}catch{}}function Un(n,e){let t=Ee.diff(n,e),r={};for(let o of t.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...t,nodesAddedFull:r}}function zt(n,e,t,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,u=new Map,d=new Map,c=new Set;for(let[y,v]of Object.entries(n.nodes)){if(!y)continue;c.add(y);let w=v.deps??[];i.set(y,w);for(let _ of w)_&&(c.add(_),a.has(_)||a.set(_,new Set),a.get(_).add(y))}for(let y of n.edges){if(y==null||typeof y!="object")continue;let v=typeof y.from=="string"?y.from:"",w=typeof y.to=="string"?y.to:"";!v||!w||(c.add(v),c.add(w),d.has(v)||d.set(v,new Set),d.get(v).add(w),u.has(w)||u.set(w,new Set),u.get(w).add(v))}if(!c.has(e))return r.withDetail?o:[];let l=r.both===!0,h=y=>{if(l){let R=i.get(y)??[],S=u.get(y),C=a.get(y),A=d.get(y),k=[...R];return S&&k.push(...S),C&&k.push(...C),A&&k.push(...A),k}if(t==="upstream"){let R=i.get(y)??[],S=u.get(y);return S?[...R,...S]:R}let v=a.get(y),w=d.get(y),_=v?[...v]:[];return w&&_.push(...w),_},p=new Set([e]),f=new Map,g=[{path:e,depth:0}],m=0,T=!1;for(;m<g.length;){let y=g[m++];if(s!=null&&y.depth>=s){h(y.path).length>0&&(T=!0);continue}for(let v of h(y.path))!v||p.has(v)||(p.add(v),f.set(v,y.depth+1),g.push({path:v,depth:y.depth+1}))}let b=[...f.keys()].sort((y,v)=>y<v?-1:y>v?1:0);return r.withDetail?{paths:b,depths:f,truncated:T}:b}function Zr(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++){let r=n[t],o=e[t];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}var L,ee,he,Wr,Hr,Ee,Wn=G(()=>{"use strict";Ot();He();we();qe();ie();$e();se();Je();Gn();tt();Ft();Bt();Nt();Dn();In();L="::",ee="__meta__",he=1;Wr={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"},Hr={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};Ee=class n{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(L))throw new Error(`Graph name must not contain '${L}' (got "${e}")`);if(e===ee)throw new Error(`Graph name "${ee}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??xe,this._traceRing=new pe(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=[],r=e?this:this._parent;for(;r!=null;)t.push(r),r=r._parent;return t}get topology(){return this._topology==null&&(this._topology=F(e=>{let t=r=>{e.emit(r)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let r=e.name,o=t?.name??r;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,i=t?.annotation;if(jt(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 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(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:X()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof j&&t._applyVersioning(e)}remove(e){jt(e,this.name,"remove");let t=this._mounts.get(e);if(t){let s={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,u]of i)a.includes(`${L}${ee}${L}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...t._collectSubgraphs(`${e}${L}`)),this._mounts.delete(e),t._parent=void 0,zn(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}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([[B]],{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=et(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>t(s));for(let s of o){let i=this.remove(s);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let o=e[r++];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(L))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,r){let o=r?.internal===!0;this.node(e).down([[x,t]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,t){let r=Symbol.iterator in e?e:Object.entries(e);Ge(()=>{for(let[o,s]of r)this.set(o,s,t)})}invalidate(e,t){let r=t?.internal===!0;this.node(e).down([[te]],{actor:t?.actor,internal:r,delivery:"write"})}error(e,t,r){let o=r?.internal===!0;this.node(e).down([[N,t]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,t){let r=t?.internal===!0;this.node(e).down([[E]],{actor:t?.actor,internal:r,delivery:"write"})}edges(e){let t=e?.recursive===!0,r=new Map;if(!t){for(let[u,d]of this._nodes)r.set(d,u);let a=[];for(let[u,d]of this._nodes)if(d instanceof j)for(let c of d._deps){let l=r.get(c.node);l!=null&&a.push([l,u])}return a.sort((u,d)=>u[0]<d[0]?-1:u[0]>d[0]?1:u[1]<d[1]?-1:u[1]>d[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,u]of o)s.set(u,a);let i=[];for(let[a,u]of o)if(u instanceof j)for(let d of u._deps){let c=s.get(d.node);c!=null&&i.push([c,a])}return i.sort((a,u)=>a[0]<u[0]?-1:a[0]>u[0]?1:a[1]<u[1]?-1:a[1]>u[1]?1:0),i}mount(e,t){if(t===void 0){let o=new n(e);return this.mount(e,o)}if(typeof t=="function"){let o=new n(e);return t(o),this.mount(e,o)}let r=t;if(jt(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 o=this;o!=null;o=o._parent)if(o===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 t=Yr(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=t[0],o=t.slice(1);if(o.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 s=this._nodes.get(r);if(s&&o.length>0&&o[0]===ee)return this._resolveMetaChainFromNode(s,o,t.join(L));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(L)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(L))}_resolveMetaChainFromNode(e,t,r){let o=e,s=0,i=[...t];for(;s<i.length;){if(i[s]!==ee)throw new Error(`Graph "${this.name}": expected ${ee} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${ee} in "${r}"`);let a=i[s+1],u=o.meta[a];if(!u)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=u,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 r=[];if(this._signalDeliver(e,t??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,t,r,o){for(let u of this._mounts.values())u._signalDeliver(e,t,r,o);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=Jr(e,this.config);for(let u of[...this._nodes.keys()].sort()){let d=this._nodes.get(u);if(!r.has(d)){r.add(d);try{d.down(e,i)}catch(c){if(c instanceof Q)throw c;o.push(c)}a.length!==0&&this._signalMetaSubtree(d,a,r,i,o)}}}_signalMetaSubtree(e,t,r,o,s){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(t,o)}catch(u){if(u instanceof Q)throw u;s.push(u)}this._signalMetaSubtree(a,t,r,o,s)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=Vr(e?.actor),r=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=Pt(e?.detail,e?.fields),s=e?.detail==="spec",i=o,a=[];this._collectObserveTargets("",a);let u=new Map;for(let[v,w]of a)u.set(w,v);let d=[];{let v=a.map(([,R])=>R),w=new Set(u.values()),_=0;for(;v.length>0;){let R=v.shift();if(R instanceof j)for(let S of R._deps){let C=S.node;if(u.has(C))continue;let A=C.name??"",k=A;if(!k||w.has(k))if(A){let U=2;for(;w.has(`${A}#${U}`);)U++;k=`${A}#${U}`}else for(k=`__internal__/${_++}`;w.has(k);)k=`__internal__/${_++}`;u.set(C,k),w.add(k),d.push([k,C]),v.push(C)}}}let c=[...a,...d],l={};for(let[v,w]of c){if(t!=null&&!w.allowsObserve(t))continue;let _=It(w,i,s),R=w instanceof j?w._deps.map(k=>u.get(k.node)??k.node.name??""):[],{name:S,...C}=_,A={...C,deps:R};if(!s){let k=this._annotations.get(v);k!=null&&(A.annotation=k)}if(r!=null)if(typeof r=="function"){let k=r;if(!(k.length>=2?k(v,A):k(A)))continue}else{let k=!0;for(let[U,V]of Object.entries(r)){let I=U==="deps_includes"?"depsIncludes":U==="meta_has"?"metaHas":U;if(I==="depsIncludes"){if(!A.deps.includes(String(V))){k=!1;break}continue}if(I==="metaHas"){if(!Object.hasOwn(A.meta??{},String(V))){k=!1;break}continue}if(A[I]!==V){k=!1;break}}if(!k)continue}l[v]=A}let h=new Set(Object.keys(l)),p=[];for(let[v,w]of c)if(w instanceof j)for(let _ of w._deps){let R=u.get(_.node);R!=null&&p.push([R,v])}p.sort((v,w)=>v[0]<w[0]?-1:v[0]>w[0]?1:v[1]<w[1]?-1:v[1]>w[1]?1:0);let f=p.map(([v,w])=>({from:v,to:w}));(t!=null||r!=null)&&(f=f.filter(v=>h.has(v.from)&&h.has(v.to)));let g=this._collectSubgraphs(""),m=t!=null||r!=null?g.filter(v=>{let w=`${v}${L}`;return[...h].some(_=>_===v||_.startsWith(w))}):g,T=this,b=e;return{name:this.name,nodes:l,edges:f,subgraphs:m,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(v){let w={...b};return Array.isArray(v)?(w.fields=v,w.detail=void 0):(w.detail=v,w.fields=void 0),T.describe(w)}}}_collectSubgraphs(e){let t=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;t.push(o),t.push(...this._mounts.get(r)._collectSubgraphs(`${o}${L}`))}return t}resourceProfile(e){return Pn(this,e)}reachable(e,t,r={}){return r.withDetail===!0?zt(this.describe(),e,t,{...r,withDetail:!0}):zt(this.describe(),e,t,r)}explain(e,t,r){return r?.reactive===!0?this._explainReactive(e,t,r):this._explainStatic(ue(e),ue(t),{...r?.maxDepth!==void 0?{maxDepth:Ln(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:Fn(r.findCycle)}:{}})}_explainStatic(e,t,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,u]of Object.entries(o.nodes))u.lastMutation!=null&&i.set(a,u.lastMutation);return Rn(o,e,t,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=fe(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,ke(()=>{a=!1,!u&&(o+=1,s.emit(o))}))},c=i.onEvent(b=>{let y=b.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||d()}),l=[],h=new WeakSet,p=b=>{if(h.has(b)||u)return;h.add(b);let y=b.topology.subscribe(v=>{for(let w of v){if(w[0]!==x)continue;let _=w[1];if(d(),_.kind==="added"&&_.nodeKind==="mount"){let R=b._mounts.get(_.name);R!=null&&p(R)}}});l.push(y);for(let v of b._mounts.keys()){let w=b._mounts.get(v);w!=null&&p(w)}};p(this);let f,g=e.actor;jn(g)&&(f=g.subscribe(b=>{let y=!1,v=!1;for(let w of b){let _=w[0];_===x?y=!0:(_===E||_===N||_===B)&&(v=!0)}y&&d(),v&&(f?.(),f=void 0,d())}));let m;try{m=At([s],()=>this.describe(t),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,y)=>b===y})}catch(b){c(),f?.();for(let y of l)y();throw i.dispose(),b}let T=Le(m);return{node:m,dispose(){u=!0,c(),f?.();for(let b of l)b();l.length=0,i.dispose(),T()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},r=e.reactiveName??"describe-diff",o={name:this.name,nodes:{},edges:[],subgraphs:[]},s=this.describe(t),i=Lt(o,s),a=fe(i,{name:r,meta:{domain:"audit",kind:"describe-diff"},equals:(h,p)=>h===p}),u=this._describeReactive({...e,reactiveName:void 0}),d=!1,c=u.node.subscribe(h=>{if(!d)for(let p of h){if(p[0]!==x)continue;let f=p[1],g=Lt(s,f);s=f,g.events.length!==0&&a.emit(g)}}),l=Le(a);return{node:a,dispose(){d=!0,c(),u.dispose(),a.down([[B,"describe-diff disposed"]]),l()}}}_explainReactive(e,t,r){let o=0,s=fe(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,ke(()=>{a=!1,!u&&(o+=1,s.emit(o))}))},c=i.onEvent(b=>{let y=b.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||d()}),l=[];e!=null&&me(e)&&l.push(e),t!=null&&me(t)&&l.push(t),r?.maxDepth!=null&&me(r.maxDepth)&&l.push(r.maxDepth),r?.findCycle!=null&&me(r.findCycle)&&l.push(r.findCycle);let h=()=>{for(let b of l)if(b.cache===void 0)return!1;return!0},p=()=>{let b=ue(e),y=ue(t);return{from:b,to:y,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:b,to:y,found:!1,reason:"pending",steps:[]})}},f;try{f=At([s],()=>{if(!h())return p();let b=ue(e),y=ue(t),v={...r?.maxDepth!==void 0?{maxDepth:Ln(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:Fn(r.findCycle)}:{}};return this._explainStatic(b,y,v)},{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:ue(e),to:ue(t)},equals:(b,y)=>b.found===y.found&&b.reason===y.reason&&b.steps.length===y.steps.length&&Zr(b.steps,y.steps)})}catch(b){throw c(),i.dispose(),b}let g=Le(f),m=[],T=b=>{let y;return y=b.subscribe(v=>{let w=!1,_=!1;for(let R of v){let S=R[0];S===x?w=!0:(S===E||S===N||S===B)&&(_=!0)}(w||_)&&d(),_&&y&&(y(),y=void 0)}),()=>{y&&(y(),y=void 0)}};for(let b of l)m.push(T(b));return{node:f,dispose(){u=!0,c();for(let b of m)b?.();m.length=0,i.dispose(),g()}}}_pathsMatching(e){let t=et(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>t.test(o))}_collectObserveTargets(e,t){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${L}${r}`;this._mounts.get(r)._collectObserveTargets(o,t)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${L}${r}`;t.push([s,o]),this._appendMetaObserveTargets(s,o,t)}}_appendMetaObserveTargets(e,t,r){for(let o of Object.keys(t.meta).sort()){let s=t.meta[o],i=`${e}${L}${ee}${L}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,t){let r=typeof e=="string",s=Vn(r?t:e);if(s.reactive===!0)return this._observeReactive(r?e:void 0,s);let i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let c=e,l=this.resolve(c);if(a!=null&&!l.allowsObserve(a))throw new Q({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,l]],s,"one"):{subscribe(h){return l.subscribe(h)},up(h){try{l.up?.(h)}catch(p){if(p instanceof Q)return;throw p}}}}let u=[];this._collectObserveTargets("",u),u.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let d=a==null?u:u.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(d,s,"all"):{subscribe:c=>{let l=d.map(([h,p])=>p.subscribe(f=>{c(h,f)}));return()=>{for(let h of l)h()}},up:(c,l)=>{try{this.resolve(c).up?.(l)}catch(h){if(h instanceof Q)return;throw h}}}}_observeReactive(e,t){let r=t.tiers,o=r!=null?new Set(r):null,s=t.reactiveName??"observe";return F(i=>{let a=[],u=!1,d=!1,c=()=>{if(a.length===0||d)return;let g={events:a.slice(),flushedAt_ns:X()};a.length=0,i.emit(g)},l={...t,reactive:!1,structured:!0,timeline:!0},h=e!=null?this.observe(e,l):this.observe(l),p=g=>{d||(a.push(g),!u&&(u=!0,ke(()=>{u=!1,c()})))};for(let g of h.events)p(g);let f=h.onEvent(p);return()=>{d=!0,f(),h.dispose()}},{name:s,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let c=this.resolve(o);return this._buildStructuredObserver([[o,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let u=i.actor,d=u==null?a:a.filter(([,c])=>c.allowsObserve(u));return this._buildStructuredObserver(d,i,"all")};return this._createObserveResult(e,t,s)}_createObserveResult(e,t,r){let o=t.timeline===!0,s=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",u=this.config.inspectorEnabled,d=(s||i)&&u,c=t.maxEvents,l=c!=null&&c>0?new pe(c):null,h=[],p=new Set,f=t.tiers!=null?new Set(t.tiers):null,g={},m=new Set,T=0,b=0,y=0,v=0,w=0,_=0,R=!1,S=!1,C=0,A=new Map,k=new Map,U=new Map,V=O=>{if(!(f!=null&&!f.has(O.type))){l?l.push(O):h.push(O);for(let $ of p)$(O)}},I=O=>f==null||f.has(O),ye=()=>o?{timestamp_ns:X(),in_batch:Ue(),batch_id:C}:{},lt=(O,$)=>{if(!(!d||!(O instanceof j)))return O._setInspectorHook(J=>{if(J.kind==="dep_message")A.set(O,J.depIndex);else if(J.kind==="run"){let Ae=J.batchData.map((P,K)=>P!=null&&P.length>0?P.at(-1):J.prevData[K]);k.set(O,Ae);let Z=J.batchData.map(P=>P!=null?[...P]:void 0);U.set(O,Z),i&&V({type:"derived",path:$,dep_values:Ae,dep_batches:Z,...ye()})}})},Ve=O=>{let $=A.get(O),J=k.get(O);if(!s||J==null)return{};let Z=($!=null&&$>=0&&O instanceof j?O._deps[$]:void 0)?.node,P=Z?.v,K=U.get(O);return{trigger_dep_index:$,trigger_dep_name:Z?.name,...P!=null?{trigger_version:{id:P.id,version:P.version}}:{},dep_values:[...J],...K!=null?{dep_batches:K}:{}}},en=[],tn=[];for(let[O,$]of e){let J=lt($,O);J&&en.push(J),tn.push($.subscribe(Ae=>{C++;for(let Z of Ae){let P=Z[0],K=ye();if(P===x){g[O]=Z[1];let mt=$ instanceof j?$.lastMutation?.actor??_e:_e;V({type:"data",path:O,data:Z[1],actor:mt,...K,...Ve($)})}else if(a)P===M?I("dirty")&&T++:P===D?I("resolved")&&b++:P===te?I("invalidate")&&y++:P===q?I("pause")&&v++:P===ne?I("resume")&&w++:P===B?I("teardown")&&_++:P===E&&!m.has(O)?I("complete")&&(R=!0):P===N&&I("error")&&(S=!0,m.add(O));else if(P===M)I("dirty")&&T++,V({type:"dirty",path:O,...K});else if(P===D)I("resolved")&&b++,V({type:"resolved",path:O,...K,...Ve($)});else if(P===te)I("invalidate")&&y++,V({type:"invalidate",path:O,...K});else if(P===q)I("pause")&&v++,V({type:"pause",path:O,lockId:Z[1],...K});else if(P===ne)I("resume")&&w++,V({type:"resume",path:O,lockId:Z[1],...K});else if(P===E)I("complete")&&!m.has(O)&&(R=!0),V({type:"complete",path:O,...K});else if(P===N){I("error")&&(S=!0,m.add(O));let mt=$ instanceof j?$.lastMutation?.actor??_e:_e;V({type:"error",path:O,data:Z[1],actor:mt,...K})}else P===B&&(I("teardown")&&_++,V({type:"teardown",path:O,...K}))}}))}let ft=!1,pt=()=>{if(!ft){ft=!0;for(let O of tn)O();for(let O of en)O();for(let O of je)O({value:void 0,done:!0});je.length=0}},ht=[],je=[];p.add(O=>{let $=je.shift();$?$({value:O,done:!1}):ht.push(O)});let nn={get values(){return g},get dirtyCount(){return T},get resolvedCount(){return b},get invalidateCount(){return y},get pauseCount(){return v},get resumeCount(){return w},get teardownCount(){return _},get events(){return l?l.toArray():[...h]},get anyCompletedCleanly(){return R},get anyErrored(){return S},get completedWithoutErrors(){return R&&!S},onEvent(O){return p.add(O),()=>p.delete(O)},dispose:pt,expand(O){pt();let $={...t};return typeof O=="string"?$.detail=O:Object.assign($,O),r(Vn($))},[Symbol.asyncIterator](){return{next(){return ht.length>0?Promise.resolve({value:ht.shift(),done:!1}):ft?Promise.resolve({value:void 0,done:!0}):new Promise(O=>je.push(O))},return(){return pt(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(nn,t),nn}_attachFormatLogger(e,t){let r=t.format;if(r==null)return;let o=t.logger??(f=>console.log(f)),s=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=s==null&&i==null?()=>!0:f=>(s==null||s.has(f))&&(i==null||!i.has(f)),u=Kr(t.theme),d=r==="stage-log"?X():0,c=f=>f==null?"":t.stageLabels?.[f]??f,l=(f,g)=>f.length>g?`${f.slice(0,g-1)}\u2026`:f,h=f=>f.type==="data"||f.type==="error"?l(Vt(f.data),120):"",p=f=>{if(r==="stage-log"){let R=(X()-d)/1e9,S=c(f.path).padEnd(9);if(f.type==="data"){let C=h(f);return`[${R.toFixed(3)}s] ${S} \u2190${C?` ${C}`:""}`}if(f.type==="error"){let C=h(f);return`[${R.toFixed(3)}s] ${S} \u2717${C?` ${C}`:""}`}return f.type==="complete"?`[${R.toFixed(3)}s] ${S} \u25A0 complete`:`[${R.toFixed(3)}s] ${S} ${f.type}`}if(r==="json")try{return JSON.stringify(f)}catch{return JSON.stringify({type:f.type,path:f.path,data:"[unserializable]"})}let g=u[f.type]??"",m=f.path?`${u.path}${f.path}${u.reset} `:"",T=f.type==="data"||f.type==="error",b=f.type==="pause"||f.type==="resume",y=T?` ${Vt(f.data)}`:b?` ${Vt(f.lockId)}`:"",v=f.type==="data"||f.type==="resolved"||f.type==="derived"?f:void 0,w=v?.trigger_dep_name!=null?` <- ${v.trigger_dep_name}`:v?.trigger_dep_index!=null?` <- #${v.trigger_dep_index}`:"",_=f.in_batch?" [batch]":"";return`${m}${g}${f.type.toUpperCase()}${u.reset}${y}${w}${_}`};e.onEvent(f=>{a(f.type)&&o(p(f),f)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){$n(this._disposers,this.name),this.signal([[B]],{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,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:u,guard:d,...c}=r.nodes[a];o[a]=c}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};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 un(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let r=t?.config??xe,{codec:o,codecVersion:s,payload:i}=dn(e,r);return o.decode(i,s)}restore(e,t){if(Bn(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(s=>et(s)),o=t?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.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(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let u=this.tryResolve(s)?.v;if(u!=null&&u.id===i.v.id&&u.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){t?.onError?.(s,a)}}}}}static fromSnapshot(e,t){Bn(e);let r=typeof t=="function"?t:t?.build,o=typeof t=="function"?void 0:t?.factories,s=new n(e.name);if(r)return r(s),s.restore(e),s;for(let p of[...e.subgraphs].sort((f,g)=>{let m=f.split(L).length,T=g.split(L).length;return m!==T?m-T:f<g?-1:f>g?1:0})){let f=p.split(L),g=s;for(let m of f)g._mounts.has(m)||g.mount(m,new n(m)),g=g._mounts.get(m)}let i=o?Object.entries(o).map(([p,f])=>({re:et(p),factory:f})):[],a=p=>{for(let f of i)if(f.re.test(p))return f.factory},u=p=>{let f=p.split(L),g=f.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${p}"`);let m=s;for(let T of f){let b=m._mounts.get(T);if(!b)throw new Error(`unknown mount "${T}" in path "${p}"`);m=b}return[m,g]},d=Object.entries(e.nodes).filter(([p])=>!p.includes(`${L}${ee}${L}`)).sort((p,f)=>p[0]<f[0]?-1:p[0]>f[0]?1:0),c=new Map(d),l=new Map,h=!0;for(;c.size>0&&h;){h=!1;for(let[p,f]of[...c.entries()]){let g=f?.deps??[];if(!g.every(w=>l.has(w)))continue;let[m,T]=u(p),b={...f?.meta??{}},y=a(p),v;if(f?.type==="state")v=fe(f.value,{meta:b});else{if(y==null)continue;v=y(T,{path:p,type:f.type,value:f.value,meta:b,deps:g,resolvedDeps:g.map(w=>l.get(w))})}m.add(v,{name:T}),l.set(p,v),c.delete(p),h=!0}}if(c.size>0){let p=[...c.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 s.restore(e),s}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let r=e.map(d=>({tier:d,debounceMs:Math.max(0,d.debounceMs??0),compactEvery:Math.max(1,d.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let o=(d,c)=>{if(d.disposed)return;let l=jr(c.nodes);if(d.lastSnapshot!=null&&l!==""&&l===d.lastFingerprint)return;let h=d.seq+1,p=ve(),m=d.lastSnapshot==null||h%d.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:h,timestamp_ns:p,format_version:he}:{name:this.name,mode:"diff",diff:Un(d.lastSnapshot,c),seq:h,timestamp_ns:p,format_version:he};if(d.tier.filter&&!d.tier.filter(m))return;let T;try{T=d.tier.save(m)}catch(b){t.onError?.(b,d.tier);return}if(T&&typeof T.then=="function"){let v=(d.savePending??Promise.resolve()).then(()=>T,()=>T).then(()=>{d.disposed||(d.seq=h,d.lastSnapshot=c,d.lastFingerprint=l)},w=>{t.onError?.(w,d.tier)});d.savePending=v.finally(()=>{d.savePending===v&&(d.savePending=void 0)})}else d.seq=h,d.lastSnapshot=c,d.lastFingerprint=l},s=(d,c)=>{try{o(d,c)}catch(l){t.onError?.(l,d.tier)}},i=(d,c)=>{if(!c.some(f=>{let g=this.config.messageTier(f[0]);return g>=3&&g<5}))return;if(t.filter){let f=this.tryResolve(d);if(f==null)return;let g=It(f,Pt("standard"));if(!t.filter(d,g))return}let h,p=()=>(h==null&&(h=this.snapshot()),h);for(let f of r)f.disposed||(f.debounceMs===0?s(f,p()):(f.timer==null&&(f.timer=new ae),f.timer.start(f.debounceMs,()=>{f.disposed||s(f,this.snapshot())})))},a;if(t.paths!=null){let c=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(l=>{let h=this.tryResolve(l);return h==null?()=>{}:h.subscribe(p=>i(l,p))});a=()=>{for(let l of c)l()}}else a=this.observe().subscribe((d,c)=>i(d,c));let u=()=>{a();for(let d of r)d.disposed=!0,d.timer?.cancel();this._storageDisposers.delete(u)};return this._storageDisposers.add(u),{dispose:u}}async _cascadeRestore(e,t){for(let r of e){let o;try{o=await r.load?.()}catch(i){t?.(i,r);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===he&&s.nodes!=null)return this.restore(s),!0}catch(i){t?.(i,r)}}return!1}static async fromStorage(e,t,r){for(let o of t){let s;try{s=await o.load?.()}catch(u){r?.onError?.(u,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===he&&i.nodes!=null?i:void 0;if(a!=null)try{return n.fromSnapshot(a,r)}catch(u){r?.onError?.(u,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,r){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:X(),...r?.actor!=null?{actor:r.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)),r=this._traceRing.size-t.length;this._traceRing.clear();for(let o of t)this._traceRing.push(o);return r}static diff(e,t){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(t.nodes)),s=[...o].filter(b=>!r.has(b)).sort(),i=[...r].filter(b=>!o.has(b)).sort(),a=[],u=[];for(let b of r){if(!o.has(b))continue;let y=e.nodes[b],v=t.nodes[b],w=y.v,_=v.v;w!=null&&_!=null&&w.id===_.id&&w.version!==_.version&&u.push({path:b,id:w.id,from:w.version,to:_.version});let R=w!=null&&_!=null&&w.id===_.id&&w.version===_.version;for(let S of["type","status","sentinel"]){let C=y[S],A=v[S];C!==A&&a.push({path:b,field:S,from:C,to:A})}if(!R)for(let S of["value","meta"]){let C=y[S],A=v[S];zr(C,A)||a.push({path:b,field:S,from:C,to:A})}}let d=b=>`${b.from} ${b.to}`,c=new Set(e.edges.map(d)),l=new Set(t.edges.map(d)),h=t.edges.filter(b=>!c.has(d(b))),p=e.edges.filter(b=>!l.has(d(b))),f=new Set(e.subgraphs),g=new Set(t.subgraphs),m=[...g].filter(b=>!f.has(b)).sort(),T=[...f].filter(b=>!g.has(b)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:u,edgesAdded:h,edgesRemoved:p,subgraphsAdded:m,subgraphsRemoved:T}}}});var Hn=G(()=>{"use strict";Wn()});var Xn={};bt(Xn,{NS_PER_MS:()=>de,NS_PER_SEC:()=>Re,constant:()=>Kn,decorrelatedJitter:()=>Zn,exponential:()=>Yn,fibonacci:()=>Jn,linear:()=>qn,resolveBackoffPreset:()=>Ut,withMaxAttempts:()=>eo});function ge(n){return n<0?0:n}function Xr(n,e){return e==="none"?n:e==="full"?Math.random()*n:n/2+Math.random()*(n/2)}function Qr(n,e){return n+Math.random()*(e-n)}function Kn(n){let e=ge(n);return()=>e}function qn(n,e){let t=ge(n),r=e===void 0?t:ge(e);return o=>t+r*Math.max(0,o)}function Yn(n){let e=ge(n?.baseNs??1e8),t=n?.factor!==void 0&&n.factor<1?1:n?.factor??2,r=ge(n?.maxDelayNs??30*1e9),o=n?.jitter??"none";return s=>{let i;if(e===0)i=0;else if(t===1)i=e;else{let a=r/e,u=1;for(let d=0;d<Math.max(0,s);d++){if(u>=a){u=a;break}u*=t}i=e*u,i>r&&(i=r)}return Xr(i,o)}}function Jn(n=100*1e6,e=30*1e9){let t=ge(n),r=ge(e);function o(s){if(s<=0)return 1;let i=1,a=2;for(let u=1;u<s;u++){let d=i+a;i=a,a=d}return a}return s=>{let i=o(s)*t;return i<=r?i:r}}function Zn(n=100*1e6,e=30*1e9){return(t,r,o)=>{let i=Math.min(e,(o??n)*3);return Qr(n,i)}}function eo(n,e){return(t,r,o)=>t>=e?null:n(t,r,o)}function Ut(n){if(n==="constant")return Kn(1*1e9);if(n==="linear")return qn(1*1e9);if(n==="exponential")return Yn();if(n==="fibonacci")return Jn();if(n==="decorrelatedJitter")return Zn();throw new Error(`Unknown backoff preset: "${String(n)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var de,Re,Wt=G(()=>{"use strict";de=1e6,Re=1e9});function to(n){return{describeKind:"derived",...n}}function no(n,e,t){let r,o=!1,s=()=>{o||(o=!0,t())};return r=n.subscribe(i=>{let a=!1,u=!1;for(let d of i)d[0]!==oe&&(d[0]===x?e.emit(d[1]):d[0]===E?a=!0:d[0]===N?(u=!0,e.down([d])):(d[0]===M||d[0]===D)&&e.down([d]));u?(r?.(),r=void 0,s()):a&&s()}),()=>{r?.(),r=void 0}}function Se(n,e,t){let r,o=!1;function s(){r?.(),r=void 0}return W([n],(i,a,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){s();return}if(u.terminalDeps[0]===!0){o=!0,r||a.down([[E]]);return}let d=i[0];if(!(d==null||d.length===0))return s(),r=no(Ce(e(d[d.length-1])),a,()=>{s(),o&&a.down([[E]])}),{deactivate:()=>{s(),o=!1}}},{...to(t),completeWhenDepsComplete:!1,meta:{...re("switchMap"),...t?.meta??{}}})}var Qn=G(()=>{"use strict";ie();$e();se();tt()});var er=G(()=>{"use strict";Qn()});function Fe(n){return typeof n=="object"&&n!==null&&"subscribe"in n&&"down"in n}function tr(n){if(n<=0)throw new RangeError("timeoutMs must be > 0");if(n>9e6)throw new RangeError("timeoutMs must be <= 9_000_000 (\u22482.5h) to stay within safe ns arithmetic")}function nr(n,e={}){let t=new Be(n,e);return t.tagFactory("resilientPipeline",On(e)),t}var Be,rr=G(()=>{"use strict";$e();Hn();Dt();er();qt();Be=class extends Ee{output;status;lastError;breakerState;droppedCount;rateLimitState;constructor(e,t={}){super(t.name??"resilient_pipeline",t.graph);let r=e,o,s,i;if(t.rateLimit!=null)if(Fe(t.rateLimit)){let u=r,d=t.rateLimit;r=Se(d,c=>{let l={...c,maxBuffer:c.maxBuffer??1/0,meta:H("resilient","rate-limit")};return st(u,l).node}),this.add(r,{name:"rateLimited"})}else{let u={...t.rateLimit,maxBuffer:t.rateLimit.maxBuffer??1/0,meta:H("resilient","rate-limit")},d=st(r,u);r=d.node,o=d.droppedCount,s=d.rateLimitState,this.add(r,{name:"rateLimited"}),this.add(o,{name:"droppedCount"}),this.add(s,{name:"rateLimitState"})}if(t.budget!=null)if(Fe(t.budget)){let u=r,d=t.budget;r=Se(d,c=>c.length>0?Ie(u,c,{meta:H("resilient","budget")}):u),this.add(r,{name:"budgetGated"})}else t.budget.length>0&&(r=Ie(r,t.budget,{meta:H("resilient","budget")}),this.add(r,{name:"budgetGated"}));if(t.breaker!=null)if(Fe(t.breaker)){let u=r,d=t.breaker,c=t.breakerOnOpen??"skip";r=Se(d,l=>{let h=rt(l);return ot(h,{onOpen:c,meta:H("resilient","breaker")})(u).node}),this.add(r,{name:"breakerWrapped"})}else{let u=rt(t.breaker),d=t.breakerOnOpen??"skip",c=ot(u,{onOpen:d,meta:H("resilient","breaker")})(r);r=c.node,i=c.breakerState,this.add(r,{name:"breakerWrapped"}),this.add(i,{name:"breakerState"})}if(t.timeoutMs!=null)if(Fe(t.timeoutMs)){let u=r,d=t.timeoutMs;r=Se(d,c=>(tr(c),it(u,c*1e6,{meta:H("resilient","timeout")}))),this.add(r,{name:"timeoutWrapped"})}else tr(t.timeoutMs),r=it(r,t.timeoutMs*1e6,{meta:H("resilient","timeout")}),this.add(r,{name:"timeoutWrapped"});if(t.retry!=null)if(Fe(t.retry)){let u=r,d=t.retry;r=Se(d,c=>nt(u,{...c,meta:H("resilient","retry")})),this.add(r,{name:"retryWrapped"})}else r=nt(r,{...t.retry,meta:H("resilient","retry")}),this.add(r,{name:"retryWrapped"});t.fallback!==void 0&&(r=Kt(r,t.fallback,{meta:H("resilient","fallback")}),this.add(r,{name:"fallbackWrapped"}));let a=Ht(r,{initialStatus:t.initialStatus??"pending",meta:H("resilient","status")});this.output=a.node,this.status=a.status,this.lastError=a.error,this.breakerState=i,this.droppedCount=o,this.rateLimitState=s,this.add(this.output,{name:"output"}),this.add(this.status,{name:"status"}),this.add(this.lastError,{name:"lastError"})}}});function be(n){return{describeKind:"derived",...n}}function ro(n){return n<0?0:n}function Yt(n){return n[1]}function oo(n){if(typeof n!="number"||!Number.isFinite(n))throw new TypeError("backoff strategy must return a finite number");return n<0?0:n}function or(n){let e=n?.count,t=n?.backoff;if(t!==void 0&&e===void 0)throw new RangeError("retry({ backoff }) requires explicit count to prevent unbounded retries; pass { count: <n>, backoff: ... }");let r=e!==void 0?e:0;if(r<0)throw new RangeError("retry count must be >= 0");let o=t===void 0?null:typeof t=="string"?Ut(t):t;return{maxRetries:r,strategy:o}}function sr(n){let e={};return n?.count!==void 0&&(e.count=n.count),typeof n?.backoff=="string"&&(e.backoff=n.backoff),Object.keys(e).length>0?e:void 0}function ir(n,e,t){let r=0,o=!1,s=null,i,a=new ae;function u(){i?.(),i=void 0}function d(l){if(o)return;if(r>=n.maxRetries){u(),t.down([[N,l]]);return}let h=n.strategy===null?0:n.strategy(r,l,s);if(h==null){u(),t.down([[N,l]]);return}let p;try{p=oo(h)}catch{u(),t.down([[N,l]]);return}s=p,r+=1,u();let f=p>0?p/1e6:1;a.start(f,()=>{o||c()})}function c(){a.cancel(),u();let l;try{l=e()}catch(h){d(h);return}i=l.subscribe(h=>{if(!o)for(let p of h){let f=p[0];if(f===M)t.down([[M]]);else if(f===x)r=0,s=null,t.emit(p[1]);else if(f===D)t.down([[D]]);else if(f===E)u(),t.down([[E]]);else if(f===N){d(Yt(p));return}else t.down([p])}})}return c(),()=>{o=!0,a.cancel(),u()}}function nt(n,e){return typeof n=="function"?io(n,e):so(n,e)}function so(n,e){let t=or(e);return F(r=>ir(t,()=>n,r),{...be(),initial:n.cache,meta:{...e?.meta??{},...re("retry",sr(e))}})}function io(n,e){let t=or(e);return F(r=>ir(t,n,r),{...be(),initial:e?.initial,meta:{...e?.meta??{},...re("retry",sr(e))}})}function rt(n){let e=Math.max(1,n?.failureThreshold??5),t=ro(n?.cooldownNs??30*1e9),r=n?.cooldown??null,o=Math.max(1,n?.halfOpenMax??1),s=n?.now??X,i="closed",a=0,u=0,d=0,c=t,l=0;function h(){if(!r)return t;let g=r(u);return g!==null?g:t}function p(){i="open",c=h(),d=s(),l=0}return{canExecute(){return i==="closed"?!0:i==="open"?s()-d>=c?(i="half-open",l=1,!0):!1:l<o?(l++,!0):!1},recordSuccess(){i==="half-open"?(i="closed",a=0,u=0):i==="closed"&&(a=0)},recordFailure(g){if(i==="half-open"){u++,p();return}i==="closed"&&(a++,a>=e&&p())},get state(){return i},get failureCount(){return a},reset(){i="closed",a=0,u=0,l=0}}}function ot(n,e){let t=e?.onOpen??"skip",r=e?.meta;return o=>{let s=W([],(i,a)=>{function u(){s.meta.breakerState.down([[x,n.state]])}let d=o.subscribe(c=>{for(let l of c){let h=l[0];h===M?a.down([[M]]):h===x?n.canExecute()?(u(),a.emit(l[1])):(u(),t==="error"?a.down([[N,new ut]]):a.down([[D]])):h===D?a.down([[D]]):h===E?(n.recordSuccess(),u(),a.down([[E]])):h===N?(n.recordFailure(Yt(l)),u(),a.down([l])):a.down([l])}});return u(),d},{...be(),meta:{...r??{},breakerState:n.state,...re("withBreaker",{onOpen:t})},completeWhenDepsComplete:!1,initial:o.cache});return{node:s,breakerState:s.meta.breakerState}}}function ar(n,e,t){if(n<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let r=t?.clock??X,o=n,s=r();function i(a){if(e>0){let u=a-s;o=Math.min(n,o+u/1e9*e)}s=a}return{available(){return i(r()),o},tryConsume(a=1){if(a<=0)return!0;let u=r();return i(u),o>=a?(o-=a,!0):!1},putBack(a=1){a<=0||(i(r()),o=Math.min(n,o+a))}}}function ao(n,e){return n.droppedCount===e.droppedCount&&n.pendingCount===e.pendingCount&&n.paused===e.paused}function st(n,e){let{maxEvents:t,windowNs:r}=e;if(t<=0)throw new RangeError("maxEvents must be > 0");if(r<=0)throw new RangeError("windowNs must be > 0");let o=e.maxBuffer;if(o===void 0)throw new RangeError("rateLimiter requires explicit maxBuffer (use Infinity to opt in to unbounded)");let s=o===1/0;if(!s&&(!Number.isInteger(o)||o<1))throw new RangeError("maxBuffer must be a positive integer (or Infinity for unbounded)");let i=e.onOverflow??"drop-newest",a=t*1e9/r,u=F(d=>{let c=ar(t,a),l=s?co():uo(o),h=new ae,p=!1,f=0,g=1e9/a,m=u.meta.droppedCount,T=u.meta.rateLimitState,b=at;function y(){m.emit(f);let S={droppedCount:f,pendingCount:l.size,paused:l.size>0};ao(b,S)||(b=S,T.emit(S))}b=at,m.emit(0),T.emit(at);function v(){for(;l.size>0;)if(c.tryConsume(1))d.emit(l.shift()),y();else{h.start(Math.max(1,g/1e6),v);return}}function w(){f+=1,y()}function _(){for(p=!0,h.cancel();l.size>0;)l.shift();f=0}let R=n.subscribe(S=>{for(let C of S){if(p)return;let A=C[0];if(A===M)d.down([[M]]);else if(A===x){if(!s&&l.size>=o)if(i==="drop-newest")w();else if(i==="drop-oldest")l.shift(),l.push(C[1]),w();else{w(),_(),d.down([[N,new dt(o)]]);return}else l.push(C[1]),y();v()}else if(A===D)d.down([[D]]);else if(A===E)_(),d.down([[E]]);else if(A===N)_(),d.down([C]);else if(A===B){_(),d.down([C]);return}else d.down([C])}});return()=>{p=!0,h.cancel(),R()}},{...be(),initial:n.cache,meta:{...e.meta??{},droppedCount:0,rateLimitState:at,...re("rateLimiter",e)}});return{node:u,droppedCount:u.meta.droppedCount,rateLimitState:u.meta.rateLimitState}}function uo(n){let e=new pe(n);return{push:t=>e.push(t),shift:()=>e.shift(),get size(){return e.size}}}function co(){let n=[];return{push:e=>{n.push(e)},shift:()=>n.shift(),get size(){return n.length}}}function Ht(n,e){let t=e?.initialStatus??"pending",r=e?.meta,o=W([],(s,i)=>{let a=t;return o.meta.status.down([[x,t]]),o.meta.error.down([[x,null]]),n.subscribe(d=>{for(let c of d){let l=c[0];if(l===M)i.down([[M]]);else if(l===x)a==="errored"?Ge(()=>{o.meta.error.down([[x,null]]),o.meta.status.down([[x,"running"]])}):o.meta.status.down([[x,"running"]]),a="running",i.emit(c[1]);else if(l===D)i.down([[D]]);else if(l===E)o.meta.status.down([[x,"completed"]]),a="completed",i.down([[E]]);else if(l===N){let h=Yt(c);Ge(()=>{o.meta.error.down([[x,h]]),o.meta.status.down([[x,"errored"]])}),a="errored",i.down([c])}else i.down([c])}})},{...be(),meta:{...r??{},status:t,error:null,...re("withStatus",{initialStatus:t})},completeWhenDepsComplete:!1,resubscribable:!0,initial:n.cache});return{node:o,status:o.meta.status,error:o.meta.error}}function lo(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function fo(n){return n!=null&&typeof n.then=="function"}function po(n){return n!=null&&typeof n=="object"&&typeof n[Symbol.asyncIterator]=="function"}function Kt(n,e,t){let r=t?.meta;return F(o=>{let s,i;function a(){i?.(),i=void 0,lo(e)||fo(e)||po(e)?s=Ce(e).subscribe(d=>{o.down(d);for(let c of d){let l=c[0];if(l===E||l===N||l===B){s=void 0;return}}}):(o.emit(e),o.down([[E]]))}return i=n.subscribe(u=>{for(let d of u){let c=d[0];if(c===M)o.down([[M]]);else if(c===x)o.emit(d[1]);else if(c===D)o.down([[D]]);else if(c===E)o.down([[E]]);else if(c===N){a();return}else if(c===B){s?.(),o.down([d]);return}else o.down([d])}}),()=>{i?.(),s?.()}},{...be(),initial:n.cache,meta:{...r??{},...re("fallback")}})}function it(n,e,t){if(e<=0)throw new RangeError("timeoutNs must be > 0");let r=t?.meta;return F(o=>{let s=!1,i=new ae;function a(){let d=e/1e6;i.start(d,()=>{s||(s=!0,u(),o.down([[N,new ct(e)]]))})}let u=n.subscribe(d=>{for(let c of d){if(s)return;let l=c[0];if(l===M)o.down([[M]]);else if(l===x)a(),o.emit(c[1]);else if(l===D)o.down([[D]]);else if(l===E){i.cancel(),s=!0,o.down([[E]]);return}else if(l===N){i.cancel(),s=!0,o.down([c]);return}else if(l===B){i.cancel(),s=!0,o.down([c]);return}else o.down([c])}});return a(),()=>{s=!0,i.cancel(),u()}},{...be(),initial:n.cache,meta:{...r??{},...re("timeout",{timeoutNs:e})}})}var ut,dt,at,ct,qt=G(()=>{"use strict";Nn();rr();He();we();ie();$e();se();Je();Wt();tt();Ft();Bt();ut=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};dt=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};at=Object.freeze({droppedCount:0,pendingCount:0,paused:!1});ct=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});var ur={};bt(ur,{CircuitOpenError:()=>ut,RateLimiterOverflowError:()=>dt,ResilientPipelineGraph:()=>Be,TimeoutError:()=>ct,budgetGate:()=>Ie,circuitBreaker:()=>rt,fallback:()=>Kt,rateLimiter:()=>st,resilientPipeline:()=>nr,retry:()=>nt,timeout:()=>it,tokenBucket:()=>ar,withBreaker:()=>ot,withStatus:()=>Ht});var dr=G(()=>{"use strict";qt()});function Y(n){return{describeKind:"producer",...n}}function lr(n){return/[\\^$+?.()|[\]{}]/.test(n)?`\\${n}`:n}function ho(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){n[t+1]==="*"?(e+=".*",t+=1):e+="[^/]*";continue}e+=lr(r)}return e+="$",new RegExp(e)}function mo(n,e){for(let t of e)if(t.test(n))return!0;return!1}function go(n,e){let t=W([n],(o,s)=>{let i=o[0];if(i==null||i.length===0){s.down([[D]]);return}for(let a of i)s.emit(a)},{describeKind:"derived",initial:n.cache}),r=t.subscribe.bind(t);return t.subscribe=(o,s)=>(e(o),r(o,s)),t}function bo(n,e){let{signal:t,period:r,...o}=e??{};return F(s=>{let i=!1,a=0,u,d,c=()=>{i=!0,u!==void 0&&clearTimeout(u),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",h)},l=()=>{i||(r!=null?(s.emit(a++),d=setInterval(()=>{i||s.emit(a++)},r)):(i=!0,t?.removeEventListener("abort",h),s.emit(a++),s.down([[E]])))},h=()=>{i||(c(),s.down([[N,t.reason]]))};if(t?.aborted){h();return}return u=setTimeout(l,n),t?.addEventListener("abort",h,{once:!0}),c},Y(o))}function yo(n){let{signal:e,...t}=n??{};return F(r=>{let o=!1,s,i,a=!1,u=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,c=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,l=typeof document<"u"?document:void 0,h=()=>{s!==void 0&&c&&c(s),i!==void 0&&clearTimeout(i),s=void 0,i=void 0},p=()=>{o=!0,h(),a&&(e?.removeEventListener("abort",f),a=!1),u&&l&&(l.removeEventListener("visibilitychange",T),u=!1)},f=()=>{o||(p(),r.down([[N,e.reason]]))},g=b=>{o||(r.emit(b),m())},m=()=>{o||(d&&(!l||l.visibilityState!=="hidden")?s=d(g):i=setTimeout(()=>g(performance.now()),16))},T=()=>{o||(h(),m())};return e?.aborted?(f(),p):(e?.addEventListener("abort",f,{once:!0}),a=e!==void 0,l&&d&&(l.addEventListener("visibilitychange",T),u=!0),m(),p)},Y(t))}function vo(n,e){let t=wn(n),{tickMs:r,output:o,...s}=e??{},i=r??6e4,a=o==="date";return F(u=>{let d=-1,c=()=>{let h=new Date,p=h.getFullYear()*1e8+(h.getMonth()+1)*1e6+h.getDate()*1e4+h.getHours()*100+h.getMinutes();p!==d&&Tn(t,h)&&(d=p,u.emit(a?h:ve()))};c();let l=setInterval(c,i);return()=>clearInterval(l)},{...Y(s),name:s.name??`cron:${n}`})}function wo(n,e,t){let{capture:r,passive:o,once:s,...i}=t??{};return F(a=>{let u=c=>{a.emit(c)},d={capture:r,passive:o,once:s};return n.addEventListener(e,u,d),()=>n.removeEventListener(e,u,d)},Y(i))}function Xt(n,e){return F(t=>{let r=!1;try{for(let o of n){if(r)return;t.emit(o)}r||t.down([[E]])}catch(o){r||t.down([[N,o]])}return()=>{r=!0}},Y(e))}function To(n){return n!=null&&typeof n.then=="function"}function fr(n,e){let{signal:t,...r}=e??{};return F(o=>{let s=!1,i=()=>{s||(s=!0,o.down([[N,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(n).then(a=>{s||(s=!0,t?.removeEventListener("abort",i),o.emit(a),o.down([[E]]))},a=>{s||(s=!0,t?.removeEventListener("abort",i),o.down([[N,a]]))}),()=>{s=!0,t?.removeEventListener("abort",i)}},Y(r))}function pr(n,e){let{signal:t,...r}=e??{};return F(o=>{let s=new AbortController,i=()=>s.abort(t?.reason);t?.aborted?s.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let a=t??s.signal,u=!1,d=n[Symbol.asyncIterator](),c=()=>{u||a.aborted||Promise.resolve(d.next()).then(l=>{if(!(u||a.aborted)){if(l.done){o.down([[E]]);return}o.emit(l.value),c()}},l=>{!u&&!a.aborted&&o.down([[N,l]])})};return c(),()=>{u=!0,t?.removeEventListener("abort",i),s.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},Y(r))}function _o(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function Ce(n,e){if(_o(n))return n;if(To(n))return fr(n,e);if(n!=null){let t=n;if(typeof t[Symbol.asyncIterator]=="function")return pr(n,e);if(typeof t[Symbol.iterator]=="function")return Xt(n,e)}return hr(n)}function hr(...n){return Xt(n,void 0)}function No(n){return F(e=>{e.down([[E]])},Y(n))}function Oo(n){return F(()=>{},Y(n))}function ko(n,e){return F(t=>{t.down([[N,n]])},Y(e))}function xo(n,e){let{signal:t,...r}=e??{},o=Y(r),s=o.resubscribable===void 0?{...o,resubscribable:!0}:o;return F(i=>{let a,u=!1;try{let d=n();a=Ce(d,e).subscribe(l=>{if(!u)for(let h of l){let p=h[0];if(p!==oe)if(p===x)i.emit(h[1]);else if(p===E){u=!0,i.down([[E]]);break}else if(p===N){u=!0,i.down([[N,h[1]]]);break}else i.down([h])}})}catch(d){let c=d===void 0?new Error("defer: thunk threw undefined"):d;i.down([[N,c]])}return()=>{u=!0,a?.()}},s)}function Eo(n,e,t){return W([n],(o,s)=>{let i=o[0];if(i!=null&&i.length>0)for(let a of i)e(a)},{describeKind:"effect",...t}).subscribe(()=>{})}function Ro(n,e){return W([n],(t,r,o)=>{o.store.buf||(o.store.buf=[]);let s=o.store.buf,i=t[0];if(i!=null&&i.length>0)for(let a of i)s.push(a);if(o.terminalDeps[0]===!0){r.emit([...s]),r.down([[E]]);return}(i==null||i.length===0)&&r.down([[D]])},{describeKind:"derived",completeWhenDepsComplete:!1,...e})}function So(n,e){return F(t=>n.subscribe(r=>{t.down(r)}),{...Y(e),initial:n.cache})}function Qt(n,e,t){if(e<1)throw new RangeError("replay expects bufferSize >= 1");let r=[],o=F(s=>n.subscribe(i=>{for(let a of i)a[0]===x&&(r.push(a[1]),r.length>e&&r.shift());s.down(i)}),{...Y(t),initial:n.cache});return go(o,s=>{for(let i of r)s([[x,i]])})}function Co(n,e){return Qt(n,1,e)}function Ao(n){return new Promise((e,t)=>{let r=!1,o=!1,s;s=n.subscribe(i=>{for(let a of i){if(r)return;if(a[0]===x){r=!0,e(a[1]),s?(s(),s=void 0):o=!0;return}if(a[0]===N){r=!0,t(a[1]),s?(s(),s=void 0):o=!0;return}if(a[0]===E){r=!0,t(new Error("completed without DATA")),s?(s(),s=void 0):o=!0;return}}}),o&&(s?.(),s=void 0)})}function Zt(n,e,t){return new Promise((r,o)=>{let s=!1,i=!1,a,u=t?.skipCurrent===!0;a=n.subscribe(d=>{for(let c of d){if(s)return;if(!(u&&c[0]===x)){if(c[0]===x){let l=c[1];if(e(l)){s=!0,r(l),a?(a(),a=void 0):i=!0;return}}if(c[0]===N){s=!0,o(c[1]),a?(a(),a=void 0):i=!0;return}if(c[0]===E){s=!0,o(new Error("completed without matching value")),a?(a(),a=void 0):i=!0;return}}}}),u=!1,i&&(a?.(),a=void 0)})}async function Do(n,e){let t=e?.predicate??(s=>s!=null),r=e?.skipCurrent;if(e?.timeoutMs==null||e.timeoutMs<=0)return await Zt(n,t,{skipCurrent:r});if(Jt===void 0){let[s,i]=await Promise.all([Promise.resolve().then(()=>(dr(),ur)),Promise.resolve().then(()=>(Wt(),Xn))]);Jt=s.timeout,cr=i.NS_PER_MS}let o=Jt(n,e.timeoutMs*cr);return await Zt(o,t,{skipCurrent:r})}function Mo(n,e){let t=new AbortController,r=e?.reason??new Error("cancelled via nodeSignal"),o,s=!1,i=()=>{o?(o(),o=void 0):s=!0};return o=n.subscribe(a=>{if(!t.signal.aborted)for(let u of a){if(u[0]===x&&u[1]===!0){t.abort(r),i();return}if(u[0]===N){t.abort(u[1]),i();return}if(u[0]===E){i();return}}}),s&&(o?.(),o=void 0),{signal:t.signal,dispose:()=>{o&&(o(),o=void 0)}}}function Le(n){return n.subscribe(()=>{})}function Po(n){let e=fe(0);return{node:e,increment(){let t=e.cache??0;return t>=n?!1:(e.down([[M],[x,t+1]]),!0)},get(){return e.cache??0},atCap(){return(e.cache??0)>=n}}}var Jt,cr,Go,mr=G(()=>{"use strict";we();ie();se();Je();_n();Go=Qt});var Io={};bt(Io,{awaitSettled:()=>Do,cached:()=>Co,defer:()=>xo,empty:()=>No,escapeRegexChar:()=>lr,firstValueFrom:()=>Ao,firstWhere:()=>Zt,forEach:()=>Eo,fromAny:()=>Ce,fromAsyncIter:()=>pr,fromCron:()=>vo,fromEvent:()=>wo,fromIter:()=>Xt,fromPromise:()=>fr,fromRaf:()=>yo,fromTimer:()=>bo,globToRegExp:()=>ho,keepalive:()=>Le,matchesAnyPattern:()=>mo,never:()=>Oo,nodeSignal:()=>Mo,of:()=>hr,reactiveCounter:()=>Po,replay:()=>Qt,share:()=>So,shareReplay:()=>Go,throwError:()=>ko,toArray:()=>Ro});module.exports=wr(Io);var tt=G(()=>{mr()});tt();0&&(module.exports={awaitSettled,cached,defer,empty,escapeRegexChar,firstValueFrom,firstWhere,forEach,fromAny,fromAsyncIter,fromCron,fromEvent,fromIter,fromPromise,fromRaf,fromTimer,globToRegExp,keepalive,matchesAnyPattern,never,nodeSignal,of,reactiveCounter,replay,share,shareReplay,throwError,toArray});
|
|
1
|
+
"use strict";var Tt=Object.defineProperty;var wr=Object.getOwnPropertyDescriptor;var Tr=Object.getOwnPropertyNames;var _r=Object.prototype.hasOwnProperty;var L=(n,e)=>()=>(n&&(e=n(n=0)),e);var _t=(n,e)=>{for(var t in e)Tt(n,t,{get:e[t],enumerable:!0})},Nr=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Tr(e))!_r.call(n,o)&&o!==t&&Tt(n,o,{get:()=>e[o],enumerable:!(r=wr(e,o))||r.enumerable});return n};var Or=n=>Nr(Tt({},"__esModule",{value:!0}),n);function K(){return Math.trunc(performance.now()*1e6)}function _e(){return Date.now()*1e6}var Ne=L(()=>{"use strict"});var ie,x,I,M,te,Y,ne,V,E,_,Oe,Nt,kr,Ot,xr,Er,kt,dn,cn,ln,xt,ue=L(()=>{"use strict";ie=Symbol.for("graphrefly/START"),x=Symbol.for("graphrefly/DATA"),I=Symbol.for("graphrefly/DIRTY"),M=Symbol.for("graphrefly/RESOLVED"),te=Symbol.for("graphrefly/INVALIDATE"),Y=Symbol.for("graphrefly/PAUSE"),ne=Symbol.for("graphrefly/RESUME"),V=Symbol.for("graphrefly/TEARDOWN"),E=Symbol.for("graphrefly/COMPLETE"),_=Symbol.for("graphrefly/ERROR"),Oe=Object.freeze([I]),Nt=Object.freeze([M]),kr=Object.freeze([te]),Ot=Object.freeze([ie]),xr=Object.freeze([E]),Er=Object.freeze([V]),kt=Object.freeze([Oe]),dn=Object.freeze([Nt]),cn=Object.freeze([kr]),ln=Object.freeze([xr]),xt=Object.freeze([Er])});function pn(n,e){let t=new TextEncoder().encode(n.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${n.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let r=n.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let 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),i=0;return s[i++]=Et,s[i++]=t.length,s.set(t,i),i+=t.length,s[i++]=r>>>8&255,s[i++]=r&255,s.set(e,i),s}function hn(n,e){if(n.length<fn)throw new Error(`decodeEnvelope: bytes too short (${n.length} < ${fn})`);let t=0,r=n[t++];if(r!==Et)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${Et})`);let o=n[t++];if(o===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+o+2>n.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+o+2} bytes, have ${n.length})`);let s=new TextDecoder().decode(n.subarray(t,t+o));t+=o;let i=(n[t]<<8|n[t+1])>>>0;t+=2;let a=n.subarray(t),u=e.lookupCodec(s);if(u==null)throw new Error(`decodeEnvelope: codec "${s}" not registered (envelope codec_v=${i})`);return{codec:u,codecVersion:i,payload:a}}function mn(n){n.registerCodec(Rr)}var Rr,Et,fn,Rt=L(()=>{"use strict";Rr={name:"json",version:1,contentType:"application/json",encode(n){let e=JSON.stringify(n);return new TextEncoder().encode(e)},decode(n,e){let t=new TextDecoder().decode(n);return JSON.parse(t)}},Et=1,fn=4});function We(n){if(n==null)return ke;let{type:e,id:t,...r}=n;return{type:e??"system",id:t??"",...r}}var ke,St=L(()=>{"use strict";ke={type:"system",id:""}});function He(){return xe>0||Ge}function gn(){return xe>0}function Re(n){xe>0?Pe.push(n):n()}function Se(n){xe+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(xe-=1,xe===0)if(e){if(!Ge){let t=Pe.splice(0);for(let r of t)try{r()}catch{}pe.length=0,he.length=0,Ee.length=0}}else Sr()}}function Sr(){let n=!Ge;n&&(Ge=!0);let e=[],t=0;try{for(;pe.length>0||he.length>0||Ee.length>0||n&&Pe.length>0;){if(n&&Pe.length>0){let s=Pe.splice(0);for(let i of s)try{i()}catch(a){e.push(a)}continue}if(t+=1,t>1e3)throw pe.length=0,he.length=0,Ee.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(pe.length>0?pe:he.length>0?he:Ee).splice(0);for(let s of o)try{s()}catch(i){e.push(i)}}}finally{n&&(Ge=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function qe(n,e,t){if(e.length===0)return;if(e.length===1){let d=t(e[0][0]);if(d<3||!He()){n(e);return}(d>=5?Ee:d===4?he:pe).push(()=>n(e));return}let r=e.length,o=r,s=r,i=r,a=0;for(;a<r&&t(e[a][0])<3;)a++;for(o=a;a<r&&t(e[a][0])===3;)a++;for(s=a;a<r&&t(e[a][0])===4;)a++;i=a;let u=He();if(o>0){let d=e.slice(0,o);n(d)}if(s>o){let d=e.slice(o,s);u?pe.push(()=>n(d)):n(d)}if(i>s){let d=e.slice(s,i);u?he.push(()=>n(d)):n(d)}if(r>i){let d=e.slice(i,r);u?Ee.push(()=>n(d)):n(d)}}var xe,Ge,pe,he,Ee,Pe,Ke=L(()=>{"use strict";xe=0,Ge=!1,pe=[],he=[],Ee=[],Pe=[]});function bn(n){n.registerMessageType(ie,{tier:0,wireCrossing:!1}),n.registerMessageType(I,{tier:1,wireCrossing:!1}),n.registerMessageType(te,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(Y,{tier:2,wireCrossing:!1}),n.registerMessageType(ne,{tier:2,wireCrossing:!1}),n.registerMessageType(x,{tier:3,wireCrossing:!0}),n.registerMessageType(M,{tier:3,wireCrossing:!0}),n.registerMessageType(E,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(_,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(V,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Ye,yn=L(()=>{"use strict";ue();Ye=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 r=this._messageTypes.get(t);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}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 Ct(n){let e=Cr.filter(t=>n({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}var Q,Cr,Je=L(()=>{"use strict";Q=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}},Cr=["human","llm","wallet","system"]});function At(n){if(n===void 0)return null;if(typeof n=="number"){if(!Number.isFinite(n))throw new TypeError(`Cannot hash non-finite number: ${n}`);if(Number.isInteger(n)&&!Number.isSafeInteger(n))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${n}. Cross-language cid parity is not guaranteed for unsafe integers.`);return n}if(typeof n=="string"||typeof n=="boolean"||n===null)return n;if(Array.isArray(n))return n.map(At);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=At(n[t]);return e}return null}function Mr(n){let e=Dr.encode(n),t=e.length,r=t*8,o=t+9+63&-64,s=new Uint8Array(o);s.set(e),s[t]=128;let i=new DataView(s.buffer);i.setUint32(o-4,r>>>0,!1),i.setUint32(o-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,u=3144134277,d=1013904242,c=2773480762,p=1359893119,f=2600822924,h=528734635,l=1541459225,g=new Uint32Array(64),m=(b,y)=>b>>>y|b<<32-y;for(let b=0;b<o;b+=64){for(let O=0;O<16;O++)g[O]=i.getUint32(b+O*4,!1);for(let O=16;O<64;O++){let P=g[O-15],A=g[O-2],C=m(P,7)^m(P,18)^P>>>3,Te=m(A,17)^m(A,19)^A>>>10;g[O]=g[O-16]+C+g[O-7]+Te>>>0}let y=a,w=u,T=d,N=c,R=p,S=f,D=h,G=l;for(let O=0;O<64;O++){let P=m(R,6)^m(R,11)^m(R,25),A=R&S^~R&D,C=G+P+A+Ar[O]+g[O]>>>0,Te=m(y,2)^m(y,13)^m(y,22),gt=y&w^y&T^w&T,ze=Te+gt>>>0;G=D,D=S,S=R,R=N+C>>>0,N=T,T=w,w=y,y=C+ze>>>0}a=a+y>>>0,u=u+w>>>0,d=d+T>>>0,c=c+N>>>0,p=p+R>>>0,f=f+S>>>0,h=h+D>>>0,l=l+G>>>0}let v=b=>b.toString(16).padStart(8,"0");return v(a)+v(u)+v(d)+v(c)+v(p)+v(f)+v(h)+v(l)}function Dt(n){let e=At(n??null),t=JSON.stringify(e);return Mr(t).slice(0,16)}function Gr(){let n=globalThis.crypto;if(n?.randomUUID)return n.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function Mt(n,e,t){let r=t?.id??Gr();if(n===0)return{id:r,version:0};let s=(t?.hash??Dt)(e);return{id:r,version:0,cid:s,prev:null}}function vn(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}var Ar,Dr,wn=L(()=>{"use strict";Ar=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]),Dr=new TextEncoder});function Nn(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function Gt(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function Ze(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}function W(n,e,t){let r=On(n)?n:[],o=typeof n=="function"?n:typeof e=="function"?e:void 0,s={};return On(n)?s=(Pt(e)?e:t)??{}:Pt(n)?s=n:s=(Pt(e)?e:t)??{},new z(r,o,s)}var Tn,_n,Pr,Ir,Ce,z,On,Pt,ae=L(()=>{"use strict";Rt();St();Ke();Ne();yn();Je();ue();wn();Tn=()=>{},_n=100;Pr=(n,e,t,r)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},Ir=(n,e,t,r)=>{let o=n;if(o._status==="completed"||o._status==="errored")return;let s=o._cached,i=s===void 0?[Ot]:[Ot,[x,s]];o._status==="dirty"&&i.push(Oe),qe(e,i,o._config.tierOf)},Ce=new Ye({onMessage:Pr,onSubscribe:Ir});bn(Ce);mn(Ce);z=class n{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,r){this._config=r.config??Ce,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=t,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??Dt;let o=r.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?Mt(o,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Nn);let s={};for(let[a,u]of Object.entries(r.meta??{})){let d={initial:u,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(d.guard=r.guard),r.resubscribable===!0&&(d.resubscribable=!0),s[a]=new n([],void 0,d)}Object.freeze(s),this.meta=s,this._hasMeta=Object.keys(s).length>0;let i=this;this._actions={emit(a){i._emit([[x,a]])},down(a){i._emit(Ze(a))},up(a){i._emitUp(Ze(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let o=t?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let s=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??t?.id,u=i?.version??0,d=Mt(e,s,{id:a,hash:o});d.version=u,this._versioning=d,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=We(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!t&&!r)return;let o=We(e?.actor),s=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,s))throw new Q({actor:o,action:s,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(o,s))throw new Q({actor:o,action:s,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:_e()}}down(e,t){let r=Ze(e);r.length!==0&&(this._checkGuard(t),this._emit(r))}emit(e,t){this._checkGuard(t),this._emit([[x,e]])}up(e,t){if(this._deps.length===0)return;let r=Ze(e);if(r.length===0)return;this._checkGuard(t);let o=t??{internal:!0};this._validateUpTiers(r);for(let s of this._deps)s.node.up?.(r,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 r of e){let o=t(r[0]);if(o===3||o===4)throw new Error(`Node "${this.name}": tier-${o} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let u=We(t);if(!this._guard(u,"observe"))throw new Q({actor:u,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let u of this._deps)Gt(u);if(this._partial===!1){for(let u of this._deps)if(u.prevData!==void 0||u.dataBatch.length!==0||u.terminal!==void 0||u.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(u){throw this._sinkCount-=1,u}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof s=="function")try{s()}catch{}throw u}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof 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 r=0;r<e;r++){let o=r,s=this._deps[r];s.unsub=Tn,s.unsub=s.node.subscribe(i=>{if(s.unsub===null)return;let a=this._config.tierOf,u=!1;for(let d of i)a(d[0])>=3&&(u=!0),this._config.onMessage(this,d,{direction:"down-in",depIndex:o},this._actions);u&&this._maybeRunFnOnSettlement()}),t++}}catch(r){this._deps[t].unsub=null;for(let o=0;o<t;o++){let s=this._deps[o];if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}Gt(s)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let t=this._deps.length,r=Nn(e);if(this._deps.push(r),this._sinks==null)return t;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(kt),r.unsub=Tn;try{r.unsub=e.subscribe(o=>{if(r.unsub===null)return;let s=this._config.tierOf,i=!1;for(let a of o)s(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(o){throw r.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(r){this._emit([[_,this._wrapFnError("cleanup threw",r)]])}else if(t!=null&&typeof t=="object"){let r=t.deactivate;if(typeof r=="function")try{r()}catch(o){this._emit([[_,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let r of this._deps){if(r.unsub!=null){let o=r.unsub;r.unsub=null;try{o()}catch{}}Gt(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let r=this._deps[e],o=t[0];if(this._inspectorHooks!=null){let s={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(s)}if(o!==ie){if(o===I){this._depDirtied(r);return}if(o===te){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(cn);return}if(o===Y||o===ne){this._emit([t]);return}if(o===V){this._emit(xt);return}if(o===x)this._depSettledAsData(r,t[1]);else if(o===M)this._depSettledAsResolved(r);else if(o===E)this._depSettledAsTerminal(r,!0);else if(o===_)this._depSettledAsTerminal(r,t[1]);else{this._emit([t]);return}if(!this._fn){(o===x||o===M)&&this._emit([t]),(o===E||o===_)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(kt))}_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(dn),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[_,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(ln)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[_,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[_,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let t=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=t[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let o=this._deps.map(i=>i.terminal),s={prevData:r,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,s);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[_,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>_n?(this._rerunDepth=0,this._emit([[_,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${_n} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let r=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[Oe,e[0]]:e;let r=!0,o=!1,s=!1,i=-1;for(let u of e){let d=t(u[0]);d<i&&(r=!1),d===3&&(o=!0),u[0]===I&&(s=!0),i=d}let a=e;if(!r){let u=e.map((d,c)=>({m:d,i:c,tier:t(d[0])}));u.sort((d,c)=>d.tier-c.tier||d.i-c.i),a=u.map(d=>d.m)}if(o&&!s&&this._status!=="dirty"){let u=0;for(;u<a.length&&t(a[u][0])===0;)u++;return u===0?[Oe,...a]:[...a.slice(0,u),Oe,...a.slice(u)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let u=e[a];if(u[0]===_&&u[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 a=e.filter(u=>u[0]===V||u[0]===te);if(a.length===0)return;t=a}t=this._frameBatch(t);let o=null;for(let a=0;a<t.length;a++){let u=t[a],d=u[0];if(d!==Y&&d!==ne){o?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${d===Y?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let p=u[1];if(d===Y)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(p),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(p))c=!1;else if(this._pauseLocks.delete(p),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let f=this._pauseBuffer;this._pauseBuffer=[],this._emit(f)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?o?.push(u):o==null&&(o=t.slice(0,a))}if(o!=null){if(o.length===0)return;t=o}if(this._hasMeta&&t.some(a=>a[0]===V))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(xt)}catch{}let{finalMessages:s,equalsError:i}=this._updateState(t);if(s.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:s})}catch{}}if(s.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,u=[];for(let d of s)a(d[0])===3?this._pauseBuffer.push(d):u.push(d);u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(s);i!=null&&this._emit([[_,i]])}_updateState(e){let t=this._config.tierOf,r,o,s=-1,i=0;for(let c of e)t(c[0])===3&&i++;let a=i<=1,u=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===x){u=c;break}}for(let c=0;c<e.length;c++){let p=e[c],f=p[0];if(f===x){if(p.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,p[1])}catch(l){o=this._wrapFnError("equals threw",l),s=c;break}if(h){r==null&&(r=e.slice(0,c)),r.push(Nt),this._status="resolved";continue}this._cached=p[1],this._versioning!=null&&(u<0||c===u)&&vn(this._versioning,p[1],this._hashFn)}this._status="settled",r?.push(p)}else if(r?.push(p),f===I)this._status="dirty";else if(f===M)this._status="resolved";else if(f===E){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(f===_){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(f===te){if(this._cached!==void 0){let l=this._config.rigorRecorder;if(l!=null)try{l.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 l=h.invalidate;if(typeof l=="function")try{l()}catch{}}}else f===V&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=s>=0?r??e.slice(0,s):r??e;return o!=null?{finalMessages:d,equalsError:o}:{finalMessages:d}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let r of t)r(e)};_dispatchOrAccumulate(e){if(gn()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Re(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}qe(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);qe(this._deliverToSinks,t,this._config.tierOf)}},On=n=>Array.isArray(n),Pt=n=>typeof n=="object"&&n!=null&&!Array.isArray(n)});function me(n,e){return W([],{...e,initial:n})}function j(n,e){return W((r,o,s)=>n(o,s)??void 0,{describeKind:"producer",...e})}function Xe(n,e,t){return W(n,(o,s,i)=>{let a=o.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);s.emit(e(a,i))},{describeKind:"derived",...t})}function kn(n,e,t){return W(n,(o,s,i)=>{let a=o.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);return e(a,s,i)??void 0},{describeKind:"effect",...t})}var Qe=L(()=>{"use strict";ae()});function Ie(n,e,t){let r=new Set;for(let o of n.split(",")){let[s,i]=o.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${o}`);let u,d;if(s==="*")u=e,d=t;else if(s.includes("-")){let[c,p]=s.split("-");u=Number.parseInt(c,10),d=Number.parseInt(p,10)}else u=Number.parseInt(s,10),d=u;if(Number.isNaN(u)||Number.isNaN(d))throw new Error(`Invalid cron field: ${n}`);if(u<e||d>t)throw new Error(`Cron field out of range: ${n} (${e}-${t})`);if(u>d)throw new Error(`Invalid cron range: ${u}-${d} in ${n}`);for(let c=u;c<=d;c+=a)r.add(c)}return r}function xn(n){let e=n.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:Ie(e[0],0,59),hours:Ie(e[1],0,23),daysOfMonth:Ie(e[2],1,31),months:Ie(e[3],1,12),daysOfWeek:Ie(e[4],0,6)}}function En(n,e){return n.minutes.has(e.getMinutes())&&n.hours.has(e.getHours())&&n.daysOfMonth.has(e.getDate())&&n.months.has(e.getMonth()+1)&&n.daysOfWeek.has(e.getDay())}var Rn=L(()=>{"use strict"});function H(n,e,t){return{[n]:!0,[`${n}_type`]:e,...t??{}}}var It=L(()=>{"use strict"});function Le(n,e,t){if(e.length===0)throw new RangeError("budgetGate requires at least one constraint");let r=e.map(h=>h.node),o=[n,...r],s=new Lt,i=!1,a=!1,u=Symbol("budget-gate"),d=new Array(e.length);function c(){return e.every((h,l)=>h.check(d[l]))}function p(h){for(;s.size>0&&c();){let l=s.shift();h.emit(l)}s.size===0&&a&&(a=!1,h.down([[M]]))}return W([],(h,l)=>{for(let m=0;m<e.length;m++)d[m]=e[m].node.cache;let g=[];for(let m=0;m<o.length;m++){let v=o[m];g.push(v.subscribe(b=>{for(let y of b)f(y,m,l)}))}return()=>{for(let m of g)m()}},{...t,describeKind:"derived",meta:H("resilience","budget_gate",t?.meta)});function f(h,l,g){let m=h[0];if(l===0){if(m===x)return c()&&s.size===0?g.emit(h[1]):(s.push(h[1]),i||(i=!0,g.up([[Y,u]]))),!0;if(m===I)return g.down([[I]]),!0;if(m===M)return s.size===0?g.down([[M]]):a=!0,!0;if(m===E||m===_){for(;s.size>0;)g.emit(s.shift());return a=!1,i&&(i=!1,g.up([[ne,u]])),g.down([h]),!0}return!1}if(m===x&&(d[l-1]=h[1]),m===x||m===M){let v=c();return v&&s.size>0?(p(g),s.size===0&&i&&(i=!1,g.up([[ne,u]]))):!v&&!i&&s.size>0&&(i=!0,g.up([[Y,u]])),!0}return m===I?!0:m===_?(g.down([h]),!0):m===E}}var Lt,Sn=L(()=>{"use strict";ue();ae();It();Lt=class{buf=[];head=0;get size(){return this.buf.length-this.head}push(e){this.buf.push(e)}shift(){if(this.head>=this.buf.length)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head++,this.head>32&&this.head*2>this.buf.length&&(this.buf=this.buf.slice(this.head),this.head=0),e}clear(){this.buf=[],this.head=0}}});function $t(n,e){if(e!=null&&e.length>0)return new Set(e);switch(n){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function Lr(n){return n._describeKind!=null?n._describeKind:n._deps.length>0?"derived":n._fn!=null?"producer":"state"}function Cn(n){let e=new WeakSet,t={};for(let[r,o]of An(n))t[r]=Ft(o,e);return t}function Ft(n,e){if(n==null)return n;let t=typeof n;if(t==="boolean"||t==="number"||t==="string")return n;if(t==="function")return"<function>";if(Array.isArray(n))return e.has(n)?"<cycle>":(e.add(n),n.map(r=>Ft(r,e)));if(t==="object"){let r=n;if(e.has(r))return"<cycle>";e.add(r);try{if(typeof r.subscribe=="function"&&"cache"in r)return"<Node>"}catch{return"<unserializable>"}let o={};for(let[s,i]of An(r))o[s]=Ft(i,e);return o}return"<unserializable>"}function An(n){let e=[],t;try{t=Object.keys(n)}catch{return e}for(let r of t)try{e.push([r,n[r]])}catch{e.push([r,"<unserializable>"])}return e}function oe(n,e){let t={factory:n};return e!==void 0&&(t.factoryArgs=e),t}function Fr(n){let e={};for(let[t,r]of Object.entries(n.meta))try{e[t]=r.cache}catch{}return e}function Bt(n,e,t){let r=e==null,o=!r&&e!=null?[...e].filter(c=>c.startsWith("meta.")).map(c=>c.slice(5)):null,s=r||e.has("meta")||o!=null&&o.length>0,i="state",a=[];n instanceof z&&(i=Lr(n),a=n._deps.map(c=>c.node.name??""));let u={type:i,deps:a};(r||e.has("status"))&&(u.status=n.status);let d=n instanceof z?n._guard:void 0;if(s){let c={...Fr(n)};if(d!=null&&c.access===void 0&&(c.access=Ct(d)),o!=null&&o.length>0&&!e.has("meta")){let p={};for(let f of o)f in c&&(p[f]=c[f]);u.meta=p}else u.meta=c}if(n.name!=null&&(u.name=n.name),(r||e.has("value"))&&(!t||i==="state")){n.status==="sentinel"&&(u.sentinel=!0);try{u.value=n.cache}catch{}}if((r||e.has("v"))&&n.v!=null){let c={id:n.v.id,version:n.v.version};"cid"in n.v&&(c.cid=n.v.cid,c.prev=n.v.prev),u.v=c}return(r||e.has("guard"))&&d!=null&&(u.guard=Ct(d)),(r||e.has("lastMutation"))&&n.lastMutation!=null&&(u.lastMutation=n.lastMutation),u}var Fe=L(()=>{"use strict";Je();ae()});function Dn(n){let e=new WeakSet,t=new WeakSet,r=[n],o=0;for(;r.length>0;){let s=r.pop();o+=Br(s,e,t,r)}return o}function Br(n,e,t,r){if(n==null)return 0;switch(typeof n){case"number":return U.number;case"boolean":return U.boolean;case"string":return U.string+n.length*2;case"bigint":return U.bigint+Vr(n);case"symbol":return U.symbol;case"function":return e.has(n)?0:(e.add(n),U.function);case"undefined":return 0}let s=n;if(e.has(s))return 0;e.add(s);let i=s[$r];if(typeof i=="function")try{let d=i.call(s);if(typeof d=="number"&&Number.isFinite(d))return d}catch{}if(s instanceof Date)return U.date;if(s instanceof RegExp)return U.regexp+s.source.length*2;if(s instanceof Error){let d=s.message?s.message.length*2:0,c=s.stack?s.stack.length*2:0;return U.error+d+c}if(typeof URL<"u"&&s instanceof URL)return U.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return U.promise;if(s instanceof WeakMap)return U.weakmap;if(s instanceof WeakSet)return U.weakset;if(s instanceof Map){let d=U.map;for(let[c,p]of s)d+=U.mapEntry,r.push(c),r.push(p);return d}if(s instanceof Set){let d=U.set;for(let c of s)d+=U.setEntry,r.push(c);return d}if(Array.isArray(s)){let d=U.array+s.length*8;for(let c of s)r.push(c);return d}if(s instanceof ArrayBuffer)return t.has(s)?0:(t.add(s),s.byteLength);if(ArrayBuffer.isView(s)){let d=s;return t.has(d.buffer)?48:(t.add(d.buffer),d.buffer.byteLength+48)}let a=U.object,u=Object.keys(s);for(let d of u){a+=U.string+d.length*2;try{r.push(s[d])}catch{}}return a}function Vr(n){let e=n<0n?-n:n;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}var U,$r,Mn=L(()=>{"use strict";U={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},$r=Symbol.for("sizeof")});function Gn(n,e,t,r={}){let o=e in n.nodes,s=t in n.nodes;if(!o)return et(e,t,"no-such-from");if(!s)return et(e,t,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(r.findCycle===!0){let d=jr(n,e,r);if(d!=null)return d}let u=tt(e,n.nodes[e],0,r);return nt(e,t,[u])}if(i===0)return et(e,t,"no-path");let a=Pn(n,e,t,i);return a.found?nt(e,t,In(n,a.pathOrder,r)):et(e,t,a.truncated?"max-depth-exceeded":"no-path")}function Pn(n,e,t,r){let o=new Map,s=[{path:t,depth:0}],i=new Set([t]),a=0,u=!1;for(;a<s.length;){let p=s[a++];if(p.path===e)break;if(r!=null&&p.depth>=r){let g=n.nodes[p.path];g?.deps&&g.deps.length>0&&(u=!0);continue}let f=n.nodes[p.path];if(f==null)continue;let h=f.deps??[],l=new Map;for(let g=0;g<h.length;g++){let m=h[g];if(!m)continue;let v=l.get(m);v==null&&(v=[],l.set(m,v)),v.push(g)}for(let[g,m]of l)i.has(g)||(i.add(g),o.set(g,{from:p.path,depIndices:m}),s.push({path:g,depth:p.depth+1}))}if(!o.has(e))return{found:!1,pathOrder:[],truncated:u};let d=[{path:e}],c=e;for(;c!==t;){let p=o.get(c);if(p==null)return{found:!1,pathOrder:[],truncated:!1};d[d.length-1].depIndices=p.depIndices,d.push({path:p.from}),c=p.from}return{found:!0,pathOrder:d,truncated:!1}}function jr(n,e,t){let r=n.nodes[e];if(r==null)return null;let o=r.deps??[],s=[];for(let a=0;a<o.length;a++)o[a]===e&&s.push(a);if(s.length>0){let a=tt(e,r,0,t);a.dep_index=s[0];let u=tt(e,r,1,t);return nt(e,e,[a,u])}let i=null;for(let a=0;a<o.length;a++){let u=o[a];if(!u||u===e)continue;let d=Pn(n,u,e,t.maxDepth);d.found&&(i==null||d.pathOrder.length<i.pathOrder.length)&&(i=d,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...d.pathOrder],truncated:!1})}return i==null?null:nt(e,e,In(n,i.pathOrder,t))}function In(n,e,t){return e.map((r,o)=>{let s=n.nodes[r.path],i=tt(r.path,s,o,t);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function tt(n,e,t,r){let o={path:n,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=r.annotations?.get(n)??e.annotation;s!=null&&(o.annotation=s);let i=r.lastMutations?.get(n)??e.lastMutation;return i!=null&&(o.lastMutation=i),o}function nt(n,e,t){return Ln(n,e,!0,"ok",t)}function et(n,e,t){return Ln(n,e,!1,t,[])}function Ln(n,e,t,r,o){let s=zr(n,e,t,r,o);return{from:n,to:e,found:t,reason:r,steps:o,text:s,toJSON(){return{from:n,to:e,found:t,reason:r,steps:o}}}}function zr(n,e,t,r,o){if(!t)switch(r){case"no-such-from":return`explainPath: no node named "${n}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${n}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${n}" to "${e}"`}let s=[`Causal path: ${n} \u2192 ${e} (${o.length} step(s))`];for(let i of o){let u=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(s.push(u),"value"in i&&s.push(` value: ${Ur(i.value)}`),i.annotation!=null&&s.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let d=i.lastMutation.actor;s.push(` actor: ${d.type}${d.id?`:${d.id}`:""}`)}}return s.join(`
|
|
2
|
+
`)}function Ur(n){if(n===void 0)return"<sentinel>";if(n===null)return"null";if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||typeof n=="bigint")return String(n);try{let e=JSON.stringify(n);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(n)}}var Fn=L(()=>{"use strict"});function Vt(n,e){if(Object.is(n,e))return!0;if(n==null||e==null||typeof n!="object"||typeof e!="object")return!1;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let s=0;s<n.length;s++)if(!Vt(n[s],e[s]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(n),r=Object.keys(e);if(t.length!==r.length)return!1;let o=new Set(r);for(let s of t)if(!o.has(s)||!Vt(n[s],e[s]))return!1;return!0}function $n(n,e){return`${n}\0${e}`}function jt(n,e){let t=[],r=new Set(n.subgraphs),o=new Set(e.subgraphs),s=[];for(let m of o)r.has(m)||s.push(m);s.sort();for(let m of s)t.push({type:"subgraph-mounted",path:m});let i=new Set(Object.keys(n.nodes)),a=new Set(Object.keys(e.nodes)),u=[];for(let m of a)i.has(m)||u.push(m);u.sort();for(let m of u)t.push({type:"node-added",path:m,node:{...e.nodes[m]}});let d=[];for(let m of a){if(!i.has(m))continue;let v=n.nodes[m]?.meta,b=e.nodes[m]?.meta;v==null&&b==null||Vt(v??{},b??{})||d.push(m)}d.sort();for(let m of d)t.push({type:"node-meta-changed",path:m,prevMeta:n.nodes[m]?.meta??{},nextMeta:e.nodes[m]?.meta??{}});let c=new Map;for(let m of n.edges)c.set($n(m.from,m.to),m);let p=new Map;for(let m of e.edges)p.set($n(m.from,m.to),m);let f=[];for(let[m,v]of p)c.has(m)||f.push(v);f.sort((m,v)=>m.from<v.from?-1:m.from>v.from?1:m.to<v.to?-1:m.to>v.to?1:0);for(let m of f)t.push({type:"edge-added",from:m.from,to:m.to});let h=[];for(let[m,v]of c)p.has(m)||h.push(v);h.sort((m,v)=>m.from<v.from?-1:m.from>v.from?1:m.to<v.to?-1:m.to>v.to?1:0);for(let m of h)t.push({type:"edge-removed",from:m.from,to:m.to});let l=[];for(let m of i)a.has(m)||l.push(m);l.sort();for(let m of l)t.push({type:"node-removed",path:m});let g=[];for(let m of r)o.has(m)||g.push(m);g.sort();for(let m of g)t.push({type:"subgraph-unmounted",path:m});return{events:t,flushedAt_ns:K()}}var Bn=L(()=>{"use strict";Ne()});var de,zt=L(()=>{"use strict";de=class{_timer;_gen=0;start(e,t){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&t()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var ge,Ut=L(()=>{"use strict";ge=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 Vn(n,e){let t=e?.topN??10,r=n.describe({detail:"standard"}),o=[],s=n._collectObserveTargets;typeof s=="function"&&s.call(n,"",o);let i=new Map;for(let[f,h]of o)i.set(f,h);let a=[];for(let[f,h]of Object.entries(r.nodes)){let l=i.get(f),g=l instanceof z?l:null,m=g?Dn(g.cache):0,v=g?g._sinkCount:0,b=h.deps?.length??0,y=h.type==="effect"&&v===0,w=v===0?h.type==="effect"?"orphan-effect":h.type==="derived"?"idle-derived":h.type==="producer"?"idle-producer":null:null;a.push({path:f,type:h.type,status:h.status??"unknown",valueSizeBytes:m,subscriberCount:v,depCount:b,isOrphanEffect:y,orphanKind:w})}let u=a.reduce((f,h)=>f+h.valueSizeBytes,0),d=(f,h)=>[...a].sort(h??((l,g)=>g[f]-l[f])).slice(0,t),c=a.filter(f=>f.orphanKind!=null),p=a.filter(f=>f.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:u,hotspots:{byValueSize:d("valueSizeBytes"),bySubscriberCount:d("subscriberCount"),byDepCount:d("depCount")},orphans:c,orphanEffects:p}}var jn=L(()=>{"use strict";ae();Mn()});function rt(n,e){let t=Math.max(16,n.size*4),r=0;for(;n.size>0;){if(r++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${n.size} disposer(s) discarded`),n.clear();return}let o=n.values().next();if(o.done)return;let s=o.value;n.delete(s);try{s()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function qn(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"&&typeof n.down=="function"}function Wr(n){if(n!=null)return qn(n)?n.cache:n}function ye(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"&&typeof n.down=="function"}function ce(n){return ye(n)?n.cache??"":n}function zn(n){return ye(n)?n.cache??0:n}function Un(n){return ye(n)?n.cache??!1:n}function Hr(n){let e=[];for(let t of Object.keys(n).sort()){let r=n[t].v;r!=null&&e.push(`${t} ${r.id} ${r.version}`)}return e.join(`
|
|
3
|
+
`)}function Wn(n){if(n.version!==be)throw new Error(`unsupported snapshot version ${String(n.version)} (expected ${be})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in n))throw new Error(`snapshot missing required key "${e}"`);if(typeof n.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof n.nodes!="object"||n.nodes===null||Array.isArray(n.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(n.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(n.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function qr(n,e){let t=new WeakMap,r=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=t.get(o);if(i==null&&(i=new WeakSet,t.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,u=s.constructor;if(a!==u)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 f=s;if(o.length!==f.length)return!1;for(let h=0;h<o.length;h++)if(!r(o[h],f[h]))return!1;return!0}if(o instanceof Map){let f=s;if(o.size!==f.size)return!1;for(let[h,l]of o)if(!f.has(h)||!r(l,f.get(h)))return!1;return!0}if(o instanceof Set){let f=s;if(o.size!==f.size)return!1;for(let h of o){let l=!1;for(let g of f)if(r(h,g)){l=!0;break}if(!l)return!1}return!0}if(ArrayBuffer.isView(o)){let f=o,h=s;if(f.length!==h.length)return!1;for(let l=0;l<f.length;l++)if(f[l]!==h[l])return!1;return!0}let d=Object.keys(o),c=Object.keys(s);if(d.length!==c.length)return!1;let p=new Set(c);for(let f of d)if(!p.has(f)||!r(o[f],s[f]))return!1;return!0};return r(n,e)}function Kr(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ot(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let o=n.indexOf("]",t+1);if(o<=t+1){e+="\\[";continue}let s=n.slice(t+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,t=o;continue}e+=Kr(r)}return e+="$",new RegExp(e)}function Wt(n){if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||n==null)return String(n);try{return JSON.stringify(n)}catch{return"[unserializable]"}}function Zr(n){return n==="none"?Jr:n==="ansi"||n==null?Yr:{data:n.data??"",dirty:n.dirty??"",resolved:n.resolved??"",invalidate:n.invalidate??"",pause:n.pause??"",resume:n.resume??"",complete:n.complete??"",error:n.error??"",teardown:n.teardown??"",derived:n.derived??"",path:n.path??"",reset:n.reset??""}}function Hn(n){if(n==null)return{};let e=n.detail;return e==="full"?{...n,structured:n.structured??!0,timeline:n.timeline??!0,causal:n.causal??!0,derived:n.derived??!0}:e==="minimal"?{...n,structured:n.structured??!0}:n.format==="stage-log"?{...n,structured:n.structured??!0,timeline:n.timeline??!0}:n}function Xr(n,e,t){for(let r=0;r<n.length;r++){let o=n.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${t} "${n}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function Ht(n,e,t){if(n==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(n.includes(B))throw new Error(`Graph "${e}": ${t} "${n}" must not contain '${B}' (path separator)`);if(n===ee)throw new Error(`Graph "${e}": ${t} name "${ee}" is reserved for meta companion paths`);Xr(n,e,t)}function Qr(n,e){if(n==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=n.split(B);for(let r of t)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function eo(n,e){let t=!1;for(let o of n)if(!e.isMetaPassthrough(o[0])){t=!0;break}return t?n.filter(o=>e.isMetaPassthrough(o[0])):n}function Kn(n){for(let e of n._mounts.values())Kn(e);for(let e of n._nodes.values())try{e.down([[V]],{internal:!0})}catch{}}function Yn(n,e){let t=Ae.diff(n,e),r={};for(let o of t.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...t,nodesAddedFull:r}}function qt(n,e,t,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,u=new Map,d=new Map,c=new Set;for(let[y,w]of Object.entries(n.nodes)){if(!y)continue;c.add(y);let T=w.deps??[];i.set(y,T);for(let N of T)N&&(c.add(N),a.has(N)||a.set(N,new Set),a.get(N).add(y))}for(let y of n.edges){if(y==null||typeof y!="object")continue;let w=typeof y.from=="string"?y.from:"",T=typeof y.to=="string"?y.to:"";!w||!T||(c.add(w),c.add(T),d.has(w)||d.set(w,new Set),d.get(w).add(T),u.has(T)||u.set(T,new Set),u.get(T).add(w))}if(!c.has(e))return r.withDetail?o:[];let p=r.both===!0,f=y=>{if(p){let R=i.get(y)??[],S=u.get(y),D=a.get(y),G=d.get(y),O=[...R];return S&&O.push(...S),D&&O.push(...D),G&&O.push(...G),O}if(t==="upstream"){let R=i.get(y)??[],S=u.get(y);return S?[...R,...S]:R}let w=a.get(y),T=d.get(y),N=w?[...w]:[];return T&&N.push(...T),N},h=new Set([e]),l=new Map,g=[{path:e,depth:0}],m=0,v=!1;for(;m<g.length;){let y=g[m++];if(s!=null&&y.depth>=s){f(y.path).length>0&&(v=!0);continue}for(let w of f(y.path))!w||h.has(w)||(h.add(w),l.set(w,y.depth+1),g.push({path:w,depth:y.depth+1}))}let b=[...l.keys()].sort((y,w)=>y<w?-1:y>w?1:0);return r.withDetail?{paths:b,depths:l,truncated:v}:b}function to(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++){let r=n[t],o=e[t];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}var B,ee,be,Yr,Jr,Ae,Jn=L(()=>{"use strict";St();Ke();Ne();Je();ue();Fe();ae();Qe();Bn();st();zt();Ut();Rt();Fn();jn();B="::",ee="__meta__",be=1;Yr={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"},Jr={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};Ae=class n{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(B))throw new Error(`Graph name must not contain '${B}' (got "${e}")`);if(e===ee)throw new Error(`Graph name "${ee}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??Ce,this._traceRing=new ge(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=[],r=e?this:this._parent;for(;r!=null;)t.push(r),r=r._parent;return t}get topology(){return this._topology==null&&(this._topology=j(e=>{let t=r=>{e.emit(r)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let r=e.name,o=t?.name??r;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,i=t?.annotation;if(Ht(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 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(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:K()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof z&&t._applyVersioning(e)}remove(e){Ht(e,this.name,"remove");let t=this._mounts.get(e);if(t){let s={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,u]of i)a.includes(`${B}${ee}${B}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...t._collectSubgraphs(`${e}${B}`)),this._mounts.delete(e),t._parent=void 0,Kn(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}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([[V]],{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=ot(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>t(s));for(let s of o){let i=this.remove(s);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let o=e[r++];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(B))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,r){let o=r?.internal===!0;this.node(e).down([[x,t]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,t){let r=Symbol.iterator in e?e:Object.entries(e);Se(()=>{for(let[o,s]of r)this.set(o,s,t)})}invalidate(e,t){let r=t?.internal===!0;this.node(e).down([[te]],{actor:t?.actor,internal:r,delivery:"write"})}error(e,t,r){let o=r?.internal===!0;this.node(e).down([[_,t]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,t){let r=t?.internal===!0;this.node(e).down([[E]],{actor:t?.actor,internal:r,delivery:"write"})}_registerSelfPruningKeepalive(e){let t,r,o=()=>{t?.(),t=void 0,r?.(),r=void 0};t=e.subscribe(s=>{for(let i of s){let a=i[0];if(a===V||a===E||a===_){o();return}}}),r=this.addDisposer(o)}_wireSignalToRemove(e,t){if(t==null)return;let r=()=>{try{this.remove(e)}catch{}};if(t.aborted){r();return}t.addEventListener("abort",r,{once:!0}),this.addDisposer(()=>t.removeEventListener("abort",r))}derived(e,t,r,o){let s=t.map(h=>this.resolve(h)),{keepAlive:i,annotation:a,equals:u,initial:d,meta:c,signal:p}=o??{},f=Xe(s,r,{name:e,...u!=null?{equals:u}:{},...d!==void 0?{initial:d}:{},...c!=null?{meta:c}:{}});return this.add(f,{name:e,...a!=null?{annotation:a}:{}}),i===!0&&this._registerSelfPruningKeepalive(f),this._wireSignalToRemove(e,p),f}effect(e,t,r,o){let s=t.map(c=>this.resolve(c)),{annotation:i,meta:a,signal:u}=o??{},d=kn(s,r,{name:e,...a!=null?{meta:a}:{}});return this.add(d,{name:e,...i!=null?{annotation:i}:{}}),this._wireSignalToRemove(e,u),d}produce(e,t,r){if(t===void 0)throw new Error(`Graph "${this.name}".produce("${e}", \u2026): source must not be \`undefined\` \u2014 undefined is the global SENTINEL (spec \xA71.1). Pass \`null\` for nullary DATA, or a Promise/AsyncIterable/Iterable for async sources.`);if(t!==null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function")throw new Error(`Graph "${this.name}".produce("${e}", \u2026): Node sources are rejected. For Node\u2192Node, use graph.derived(name, [path], ([v]) => v, { keepAlive: true }) \u2014 fromAny passes Nodes through verbatim and silently drops opts.`);let{annotation:o,meta:s,equals:i,signal:a}=r??{},u=le(t,{name:e,...s!=null?{meta:s}:{},...i!=null?{equals:i}:{},...a!=null?{signal:a}:{}});return this.add(u,{name:e,...o!=null?{annotation:o}:{}}),this._wireSignalToRemove(e,a),u}batch(e){Se(e)}edges(e){let t=e?.recursive===!0,r=new Map;if(!t){for(let[u,d]of this._nodes)r.set(d,u);let a=[];for(let[u,d]of this._nodes)if(d instanceof z)for(let c of d._deps){let p=r.get(c.node);p!=null&&a.push([p,u])}return a.sort((u,d)=>u[0]<d[0]?-1:u[0]>d[0]?1:u[1]<d[1]?-1:u[1]>d[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,u]of o)s.set(u,a);let i=[];for(let[a,u]of o)if(u instanceof z)for(let d of u._deps){let c=s.get(d.node);c!=null&&i.push([c,a])}return i.sort((a,u)=>a[0]<u[0]?-1:a[0]>u[0]?1:a[1]<u[1]?-1:a[1]>u[1]?1:0),i}mount(e,t){if(t===void 0){let o=new n(e);return this.mount(e,o)}if(typeof t=="function"){let o=new n(e);return t(o),this.mount(e,o)}let r=t;if(Ht(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 o=this;o!=null;o=o._parent)if(o===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 t=Qr(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=t[0],o=t.slice(1);if(o.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 s=this._nodes.get(r);if(s&&o.length>0&&o[0]===ee)return this._resolveMetaChainFromNode(s,o,t.join(B));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(B)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(B))}_resolveMetaChainFromNode(e,t,r){let o=e,s=0,i=[...t];for(;s<i.length;){if(i[s]!==ee)throw new Error(`Graph "${this.name}": expected ${ee} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${ee} in "${r}"`);let a=i[s+1],u=o.meta[a];if(!u)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=u,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 r=[];if(this._signalDeliver(e,t??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,t,r,o){for(let u of this._mounts.values())u._signalDeliver(e,t,r,o);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=eo(e,this.config);for(let u of[...this._nodes.keys()].sort()){let d=this._nodes.get(u);if(!r.has(d)){r.add(d);try{d.down(e,i)}catch(c){if(c instanceof Q)throw c;o.push(c)}a.length!==0&&this._signalMetaSubtree(d,a,r,i,o)}}}_signalMetaSubtree(e,t,r,o,s){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(t,o)}catch(u){if(u instanceof Q)throw u;s.push(u)}this._signalMetaSubtree(a,t,r,o,s)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=Wr(e?.actor),r=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=$t(e?.detail,e?.fields),s=e?.detail==="spec",i=o,a=[];this._collectObserveTargets("",a);let u=new Map;for(let[w,T]of a)u.set(T,w);let d=[];{let w=a.map(([,R])=>R),T=new Set(u.values()),N=0;for(;w.length>0;){let R=w.shift();if(R instanceof z)for(let S of R._deps){let D=S.node;if(u.has(D))continue;let G=D.name??"",O=G;if(!O||T.has(O))if(G){let P=2;for(;T.has(`${G}#${P}`);)P++;O=`${G}#${P}`}else for(O=`__internal__/${N++}`;T.has(O);)O=`__internal__/${N++}`;u.set(D,O),T.add(O),d.push([O,D]),w.push(D)}}}let c=[...a,...d],p={};for(let[w,T]of c){if(t!=null&&!T.allowsObserve(t))continue;let N=Bt(T,i,s),R=T instanceof z?T._deps.map(O=>u.get(O.node)??O.node.name??""):[],{name:S,...D}=N,G={...D,deps:R};if(!s){let O=this._annotations.get(w);O!=null&&(G.annotation=O)}if(r!=null)if(typeof r=="function"){let O=r;if(!(O.length>=2?O(w,G):O(G)))continue}else{let O=!0;for(let[P,A]of Object.entries(r)){let C=P==="deps_includes"?"depsIncludes":P==="meta_has"?"metaHas":P;if(C==="depsIncludes"){if(!G.deps.includes(String(A))){O=!1;break}continue}if(C==="metaHas"){if(!Object.hasOwn(G.meta??{},String(A))){O=!1;break}continue}if(G[C]!==A){O=!1;break}}if(!O)continue}p[w]=G}let f=new Set(Object.keys(p)),h=[];for(let[w,T]of c)if(T instanceof z)for(let N of T._deps){let R=u.get(N.node);R!=null&&h.push([R,w])}h.sort((w,T)=>w[0]<T[0]?-1:w[0]>T[0]?1:w[1]<T[1]?-1:w[1]>T[1]?1:0);let l=h.map(([w,T])=>({from:w,to:T}));(t!=null||r!=null)&&(l=l.filter(w=>f.has(w.from)&&f.has(w.to)));let g=this._collectSubgraphs(""),m=t!=null||r!=null?g.filter(w=>{let T=`${w}${B}`;return[...f].some(N=>N===w||N.startsWith(T))}):g,v=this,b=e;return{name:this.name,nodes:p,edges:l,subgraphs:m,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(w){let T={...b};return Array.isArray(w)?(T.fields=w,T.detail=void 0):(T.detail=w,T.fields=void 0),v.describe(T)}}}_collectSubgraphs(e){let t=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;t.push(o),t.push(...this._mounts.get(r)._collectSubgraphs(`${o}${B}`))}return t}resourceProfile(e){return Vn(this,e)}reachable(e,t,r={}){return r.withDetail===!0?qt(this.describe(),e,t,{...r,withDetail:!0}):qt(this.describe(),e,t,r)}explain(e,t,r){return r?.reactive===!0?this._explainReactive(e,t,r):this._explainStatic(ce(e),ce(t),{...r?.maxDepth!==void 0?{maxDepth:zn(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:Un(r.findCycle)}:{}})}_explainStatic(e,t,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,u]of Object.entries(o.nodes))u.lastMutation!=null&&i.set(a,u.lastMutation);return Gn(o,e,t,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=me(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,Re(()=>{a=!1,!u&&(o+=1,s.emit(o))}))},c=i.onEvent(b=>{let y=b.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||d()}),p=[],f=new WeakSet,h=b=>{if(f.has(b)||u)return;f.add(b);let y=b.topology.subscribe(w=>{for(let T of w){if(T[0]!==x)continue;let N=T[1];if(d(),N.kind==="added"&&N.nodeKind==="mount"){let R=b._mounts.get(N.name);R!=null&&h(R)}}});p.push(y);for(let w of b._mounts.keys()){let T=b._mounts.get(w);T!=null&&h(T)}};h(this);let l,g=e.actor;qn(g)&&(l=g.subscribe(b=>{let y=!1,w=!1;for(let T of b){let N=T[0];N===x?y=!0:(N===E||N===_||N===V)&&(w=!0)}y&&d(),w&&(l?.(),l=void 0,d())}));let m;try{m=Xe([s],()=>this.describe(t),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,y)=>b===y})}catch(b){c(),l?.();for(let y of p)y();throw i.dispose(),b}let v=$e(m);return{node:m,dispose(){u=!0,c(),l?.();for(let b of p)b();p.length=0,i.dispose(),v()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},r=e.reactiveName??"describe-diff",o={name:this.name,nodes:{},edges:[],subgraphs:[]},s=this.describe(t),i=jt(o,s),a=me(i,{name:r,meta:{domain:"audit",kind:"describe-diff"},equals:(f,h)=>f===h}),u=this._describeReactive({...e,reactiveName:void 0}),d=!1,c=u.node.subscribe(f=>{if(!d)for(let h of f){if(h[0]!==x)continue;let l=h[1],g=jt(s,l);s=l,g.events.length!==0&&a.emit(g)}}),p=$e(a);return{node:a,dispose(){d=!0,c(),u.dispose(),a.down([[V,"describe-diff disposed"]]),p()}}}_explainReactive(e,t,r){let o=0,s=me(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,Re(()=>{a=!1,!u&&(o+=1,s.emit(o))}))},c=i.onEvent(b=>{let y=b.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||d()}),p=[];e!=null&&ye(e)&&p.push(e),t!=null&&ye(t)&&p.push(t),r?.maxDepth!=null&&ye(r.maxDepth)&&p.push(r.maxDepth),r?.findCycle!=null&&ye(r.findCycle)&&p.push(r.findCycle);let f=()=>{for(let b of p)if(b.cache===void 0)return!1;return!0},h=()=>{let b=ce(e),y=ce(t);return{from:b,to:y,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:b,to:y,found:!1,reason:"pending",steps:[]})}},l;try{l=Xe([s],()=>{if(!f())return h();let b=ce(e),y=ce(t),w={...r?.maxDepth!==void 0?{maxDepth:zn(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:Un(r.findCycle)}:{}};return this._explainStatic(b,y,w)},{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:ce(e),to:ce(t)},equals:(b,y)=>b.found===y.found&&b.reason===y.reason&&b.steps.length===y.steps.length&&to(b.steps,y.steps)})}catch(b){throw c(),i.dispose(),b}let g=$e(l),m=[],v=b=>{let y;return y=b.subscribe(w=>{let T=!1,N=!1;for(let R of w){let S=R[0];S===x?T=!0:(S===E||S===_||S===V)&&(N=!0)}(T||N)&&d(),N&&y&&(y(),y=void 0)}),()=>{y&&(y(),y=void 0)}};for(let b of p)m.push(v(b));return{node:l,dispose(){u=!0,c();for(let b of m)b?.();m.length=0,i.dispose(),g()}}}_pathsMatching(e){let t=ot(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>t.test(o))}_collectObserveTargets(e,t){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${B}${r}`;this._mounts.get(r)._collectObserveTargets(o,t)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${B}${r}`;t.push([s,o]),this._appendMetaObserveTargets(s,o,t)}}_appendMetaObserveTargets(e,t,r){for(let o of Object.keys(t.meta).sort()){let s=t.meta[o],i=`${e}${B}${ee}${B}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,t){let r=typeof e=="string",s=Hn(r?t:e);if(s.reactive===!0)return this._observeReactive(r?e:void 0,s);let i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let c=e,p=this.resolve(c);if(a!=null&&!p.allowsObserve(a))throw new Q({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,p]],s,"one"):{subscribe(f){return p.subscribe(f)},up(f){try{p.up?.(f)}catch(h){if(h instanceof Q)return;throw h}}}}let u=[];this._collectObserveTargets("",u),u.sort((c,p)=>c[0]<p[0]?-1:c[0]>p[0]?1:0);let d=a==null?u:u.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(d,s,"all"):{subscribe:c=>{let p=d.map(([f,h])=>h.subscribe(l=>{c(f,l)}));return()=>{for(let f of p)f()}},up:(c,p)=>{try{this.resolve(c).up?.(p)}catch(f){if(f instanceof Q)return;throw f}}}}_observeReactive(e,t){let r=t.tiers,o=r!=null?new Set(r):null,s=t.reactiveName??"observe";return j(i=>{let a=[],u=!1,d=!1,c=()=>{if(a.length===0||d)return;let g={events:a.slice(),flushedAt_ns:K()};a.length=0,i.emit(g)},p={...t,reactive:!1,structured:!0,timeline:!0},f=e!=null?this.observe(e,p):this.observe(p),h=g=>{d||(a.push(g),!u&&(u=!0,Re(()=>{u=!1,c()})))};for(let g of f.events)h(g);let l=f.onEvent(h);return()=>{d=!0,l(),f.dispose()}},{name:s,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let c=this.resolve(o);return this._buildStructuredObserver([[o,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,p)=>c[0]<p[0]?-1:c[0]>p[0]?1:0);let u=i.actor,d=u==null?a:a.filter(([,c])=>c.allowsObserve(u));return this._buildStructuredObserver(d,i,"all")};return this._createObserveResult(e,t,s)}_createObserveResult(e,t,r){let o=t.timeline===!0,s=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",u=this.config.inspectorEnabled,d=(s||i)&&u,c=t.maxEvents,p=c!=null&&c>0?new ge(c):null,f=[],h=new Set,l=t.tiers!=null?new Set(t.tiers):null,g={},m=new Set,v=0,b=0,y=0,w=0,T=0,N=0,R=!1,S=!1,D=0,G=new Map,O=new Map,P=new Map,A=k=>{if(!(l!=null&&!l.has(k.type))){p?p.push(k):f.push(k);for(let $ of h)$(k)}},C=k=>l==null||l.has(k),Te=()=>o?{timestamp_ns:K(),in_batch:He(),batch_id:D}:{},gt=(k,$)=>{if(!(!d||!(k instanceof z)))return k._setInspectorHook(Z=>{if(Z.kind==="dep_message")G.set(k,Z.depIndex);else if(Z.kind==="run"){let Me=Z.batchData.map((F,q)=>F!=null&&F.length>0?F.at(-1):Z.prevData[q]);O.set(k,Me);let X=Z.batchData.map(F=>F!=null?[...F]:void 0);P.set(k,X),i&&A({type:"derived",path:$,dep_values:Me,dep_batches:X,...Te()})}})},ze=k=>{let $=G.get(k),Z=O.get(k);if(!s||Z==null)return{};let X=($!=null&&$>=0&&k instanceof z?k._deps[$]:void 0)?.node,F=X?.v,q=P.get(k);return{trigger_dep_index:$,trigger_dep_name:X?.name,...F!=null?{trigger_version:{id:F.id,version:F.version}}:{},dep_values:[...Z],...q!=null?{dep_batches:q}:{}}},sn=[],an=[];for(let[k,$]of e){let Z=gt($,k);Z&&sn.push(Z),an.push($.subscribe(Me=>{D++;for(let X of Me){let F=X[0],q=Te();if(F===x){g[k]=X[1];let wt=$ instanceof z?$.lastMutation?.actor??ke:ke;A({type:"data",path:k,data:X[1],actor:wt,...q,...ze($)})}else if(a)F===I?C("dirty")&&v++:F===M?C("resolved")&&b++:F===te?C("invalidate")&&y++:F===Y?C("pause")&&w++:F===ne?C("resume")&&T++:F===V?C("teardown")&&N++:F===E&&!m.has(k)?C("complete")&&(R=!0):F===_&&C("error")&&(S=!0,m.add(k));else if(F===I)C("dirty")&&v++,A({type:"dirty",path:k,...q});else if(F===M)C("resolved")&&b++,A({type:"resolved",path:k,...q,...ze($)});else if(F===te)C("invalidate")&&y++,A({type:"invalidate",path:k,...q});else if(F===Y)C("pause")&&w++,A({type:"pause",path:k,lockId:X[1],...q});else if(F===ne)C("resume")&&T++,A({type:"resume",path:k,lockId:X[1],...q});else if(F===E)C("complete")&&!m.has(k)&&(R=!0),A({type:"complete",path:k,...q});else if(F===_){C("error")&&(S=!0,m.add(k));let wt=$ instanceof z?$.lastMutation?.actor??ke:ke;A({type:"error",path:k,data:X[1],actor:wt,...q})}else F===V&&(C("teardown")&&N++,A({type:"teardown",path:k,...q}))}}))}let bt=!1,yt=()=>{if(!bt){bt=!0;for(let k of an)k();for(let k of sn)k();for(let k of Ue)k({value:void 0,done:!0});Ue.length=0}},vt=[],Ue=[];h.add(k=>{let $=Ue.shift();$?$({value:k,done:!1}):vt.push(k)});let un={get values(){return g},get dirtyCount(){return v},get resolvedCount(){return b},get invalidateCount(){return y},get pauseCount(){return w},get resumeCount(){return T},get teardownCount(){return N},get events(){return p?p.toArray():[...f]},get anyCompletedCleanly(){return R},get anyErrored(){return S},get completedWithoutErrors(){return R&&!S},onEvent(k){return h.add(k),()=>h.delete(k)},dispose:yt,expand(k){yt();let $={...t};return typeof k=="string"?$.detail=k:Object.assign($,k),r(Hn($))},[Symbol.asyncIterator](){return{next(){return vt.length>0?Promise.resolve({value:vt.shift(),done:!1}):bt?Promise.resolve({value:void 0,done:!0}):new Promise(k=>Ue.push(k))},return(){return yt(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(un,t),un}_attachFormatLogger(e,t){let r=t.format;if(r==null)return;let o=t.logger??(l=>console.log(l)),s=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=s==null&&i==null?()=>!0:l=>(s==null||s.has(l))&&(i==null||!i.has(l)),u=Zr(t.theme),d=r==="stage-log"?K():0,c=l=>l==null?"":t.stageLabels?.[l]??l,p=(l,g)=>l.length>g?`${l.slice(0,g-1)}\u2026`:l,f=l=>l.type==="data"||l.type==="error"?p(Wt(l.data),120):"",h=l=>{if(r==="stage-log"){let R=(K()-d)/1e9,S=c(l.path).padEnd(9);if(l.type==="data"){let D=f(l);return`[${R.toFixed(3)}s] ${S} \u2190${D?` ${D}`:""}`}if(l.type==="error"){let D=f(l);return`[${R.toFixed(3)}s] ${S} \u2717${D?` ${D}`:""}`}return l.type==="complete"?`[${R.toFixed(3)}s] ${S} \u25A0 complete`:`[${R.toFixed(3)}s] ${S} ${l.type}`}if(r==="json")try{return JSON.stringify(l)}catch{return JSON.stringify({type:l.type,path:l.path,data:"[unserializable]"})}let g=u[l.type]??"",m=l.path?`${u.path}${l.path}${u.reset} `:"",v=l.type==="data"||l.type==="error",b=l.type==="pause"||l.type==="resume",y=v?` ${Wt(l.data)}`:b?` ${Wt(l.lockId)}`:"",w=l.type==="data"||l.type==="resolved"||l.type==="derived"?l:void 0,T=w?.trigger_dep_name!=null?` <- ${w.trigger_dep_name}`:w?.trigger_dep_index!=null?` <- #${w.trigger_dep_index}`:"",N=l.in_batch?" [batch]":"";return`${m}${g}${l.type.toUpperCase()}${u.reset}${y}${T}${N}`};e.onEvent(l=>{a(l.type)&&o(h(l),l)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){rt(this._disposers,this.name),this.signal([[V]],{internal:!0}),rt(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(){rt(this._disposers,this.name),rt(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}snapshot(e){let{expand:t,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:u,guard:d,...c}=r.nodes[a];o[a]=c}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};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 pn(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let r=t?.config??Ce,{codec:o,codecVersion:s,payload:i}=hn(e,r);return o.decode(i,s)}restore(e,t){if(Wn(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(s=>ot(s)),o=t?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.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(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let u=this.tryResolve(s)?.v;if(u!=null&&u.id===i.v.id&&u.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){t?.onError?.(s,a)}}}}}static fromSnapshot(e,t){Wn(e);let r=typeof t=="function"?t:t?.build,o=typeof t=="function"?void 0:t?.factories,s=new n(e.name);if(r)return r(s),s.restore(e),s;for(let h of[...e.subgraphs].sort((l,g)=>{let m=l.split(B).length,v=g.split(B).length;return m!==v?m-v:l<g?-1:l>g?1:0})){let l=h.split(B),g=s;for(let m of l)g._mounts.has(m)||g.mount(m,new n(m)),g=g._mounts.get(m)}let i=o?Object.entries(o).map(([h,l])=>({re:ot(h),factory:l})):[],a=h=>{for(let l of i)if(l.re.test(h))return l.factory},u=h=>{let l=h.split(B),g=l.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${h}"`);let m=s;for(let v of l){let b=m._mounts.get(v);if(!b)throw new Error(`unknown mount "${v}" in path "${h}"`);m=b}return[m,g]},d=Object.entries(e.nodes).filter(([h])=>!h.includes(`${B}${ee}${B}`)).sort((h,l)=>h[0]<l[0]?-1:h[0]>l[0]?1:0),c=new Map(d),p=new Map,f=!0;for(;c.size>0&&f;){f=!1;for(let[h,l]of[...c.entries()]){let g=l?.deps??[];if(!g.every(T=>p.has(T)))continue;let[m,v]=u(h),b={...l?.meta??{}},y=a(h),w;if(l?.type==="state")w=me(l.value,{meta:b});else{if(y==null)continue;w=y(v,{path:h,type:l.type,value:l.value,meta:b,deps:g,resolvedDeps:g.map(T=>p.get(T))})}m.add(w,{name:v}),p.set(h,w),c.delete(h),f=!0}}if(c.size>0){let h=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let r=e.map(d=>({tier:d,debounceMs:Math.max(0,d.debounceMs??0),compactEvery:Math.max(1,d.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let o=(d,c)=>{if(d.disposed)return;let p=Hr(c.nodes);if(d.lastSnapshot!=null&&p!==""&&p===d.lastFingerprint)return;let f=d.seq+1,h=_e(),m=d.lastSnapshot==null||f%d.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:f,timestamp_ns:h,format_version:be}:{name:this.name,mode:"diff",diff:Yn(d.lastSnapshot,c),seq:f,timestamp_ns:h,format_version:be};if(d.tier.filter&&!d.tier.filter(m))return;let v;try{v=d.tier.save(m)}catch(b){t.onError?.(b,d.tier);return}if(v&&typeof v.then=="function"){let w=(d.savePending??Promise.resolve()).then(()=>v,()=>v).then(()=>{d.disposed||(d.seq=f,d.lastSnapshot=c,d.lastFingerprint=p)},T=>{t.onError?.(T,d.tier)});d.savePending=w.finally(()=>{d.savePending===w&&(d.savePending=void 0)})}else d.seq=f,d.lastSnapshot=c,d.lastFingerprint=p},s=(d,c)=>{try{o(d,c)}catch(p){t.onError?.(p,d.tier)}},i=(d,c)=>{if(!c.some(l=>{let g=this.config.messageTier(l[0]);return g>=3&&g<5}))return;if(t.filter){let l=this.tryResolve(d);if(l==null)return;let g=Bt(l,$t("standard"));if(!t.filter(d,g))return}let f,h=()=>(f==null&&(f=this.snapshot()),f);for(let l of r)l.disposed||(l.debounceMs===0?s(l,h()):(l.timer==null&&(l.timer=new de),l.timer.start(l.debounceMs,()=>{l.disposed||s(l,this.snapshot())})))},a;if(t.paths!=null){let c=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(p=>{let f=this.tryResolve(p);return f==null?()=>{}:f.subscribe(h=>i(p,h))});a=()=>{for(let p of c)p()}}else a=this.observe().subscribe((d,c)=>i(d,c));let u=()=>{a();for(let d of r)d.disposed=!0,d.timer?.cancel();this._storageDisposers.delete(u)};return this._storageDisposers.add(u),{dispose:u}}async _cascadeRestore(e,t){for(let r of e){let o;try{o=await r.load?.()}catch(i){t?.(i,r);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===be&&s.nodes!=null)return this.restore(s),!0}catch(i){t?.(i,r)}}return!1}static async fromStorage(e,t,r){for(let o of t){let s;try{s=await o.load?.()}catch(u){r?.onError?.(u,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===be&&i.nodes!=null?i:void 0;if(a!=null)try{return n.fromSnapshot(a,r)}catch(u){r?.onError?.(u,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,r){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:K(),...r?.actor!=null?{actor:r.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)),r=this._traceRing.size-t.length;this._traceRing.clear();for(let o of t)this._traceRing.push(o);return r}static diff(e,t){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(t.nodes)),s=[...o].filter(b=>!r.has(b)).sort(),i=[...r].filter(b=>!o.has(b)).sort(),a=[],u=[];for(let b of r){if(!o.has(b))continue;let y=e.nodes[b],w=t.nodes[b],T=y.v,N=w.v;T!=null&&N!=null&&T.id===N.id&&T.version!==N.version&&u.push({path:b,id:T.id,from:T.version,to:N.version});let R=T!=null&&N!=null&&T.id===N.id&&T.version===N.version;for(let S of["type","status","sentinel"]){let D=y[S],G=w[S];D!==G&&a.push({path:b,field:S,from:D,to:G})}if(!R)for(let S of["value","meta"]){let D=y[S],G=w[S];qr(D,G)||a.push({path:b,field:S,from:D,to:G})}}let d=b=>`${b.from} ${b.to}`,c=new Set(e.edges.map(d)),p=new Set(t.edges.map(d)),f=t.edges.filter(b=>!c.has(d(b))),h=e.edges.filter(b=>!p.has(d(b))),l=new Set(e.subgraphs),g=new Set(t.subgraphs),m=[...g].filter(b=>!l.has(b)).sort(),v=[...l].filter(b=>!g.has(b)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:u,edgesAdded:f,edgesRemoved:h,subgraphsAdded:m,subgraphsRemoved:v}}}});var Zn=L(()=>{"use strict";Jn()});var rr={};_t(rr,{NS_PER_MS:()=>fe,NS_PER_SEC:()=>se,constant:()=>Xn,decorrelatedJitter:()=>nr,exponential:()=>er,fibonacci:()=>tr,linear:()=>Qn,resolveBackoffPreset:()=>Kt,withMaxAttempts:()=>oo});function ve(n){return n<0?0:n}function no(n,e){return e==="none"?n:e==="full"?Math.random()*n:n/2+Math.random()*(n/2)}function ro(n,e){return n+Math.random()*(e-n)}function Xn(n){let e=ve(n);return()=>e}function Qn(n,e){let t=ve(n),r=e===void 0?t:ve(e);return o=>t+r*Math.max(0,o)}function er(n){let e=ve(n?.baseNs??1e8),t=n?.factor!==void 0&&n.factor<1?1:n?.factor??2,r=ve(n?.maxDelayNs??30*1e9),o=n?.jitter??"none";return s=>{let i;if(e===0)i=0;else if(t===1)i=e;else{let a=r/e,u=1;for(let d=0;d<Math.max(0,s);d++){if(u>=a){u=a;break}u*=t}i=e*u,i>r&&(i=r)}return no(i,o)}}function tr(n=100*1e6,e=30*1e9){let t=ve(n),r=ve(e);function o(s){if(s<=0)return 1;let i=1,a=2;for(let u=1;u<s;u++){let d=i+a;i=a,a=d}return a}return s=>{let i=o(s)*t;return i<=r?i:r}}function nr(n=100*1e6,e=30*1e9){return(t,r,o)=>{let i=Math.min(e,(o??n)*3);return ro(n,i)}}function oo(n,e){return(t,r,o)=>t>=e?null:n(t,r,o)}function Kt(n){if(n==="constant")return Xn(1*1e9);if(n==="linear")return Qn(1*1e9);if(n==="exponential")return er();if(n==="fibonacci")return tr();if(n==="decorrelatedJitter")return nr();throw new Error(`Unknown backoff preset: "${String(n)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var fe,se,Yt=L(()=>{"use strict";fe=1e6,se=1e9});function so(n){return{describeKind:"derived",...n}}function io(n,e,t){let r,o=!1,s=()=>{o||(o=!0,t())};return r=n.subscribe(i=>{let a=!1,u=!1;for(let d of i)d[0]!==ie&&(d[0]===x?e.emit(d[1]):d[0]===E?a=!0:d[0]===_?(u=!0,e.down([d])):(d[0]===I||d[0]===M)&&e.down([d]));u?(r?.(),r=void 0,s()):a&&s()}),()=>{r?.(),r=void 0}}function De(n,e,t){let r,o=!1;function s(){r?.(),r=void 0}return W([n],(i,a,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){s();return}if(u.terminalDeps[0]===!0){o=!0,r||a.down([[E]]);return}let d=i[0];if(!(d==null||d.length===0))return s(),r=io(le(e(d[d.length-1])),a,()=>{s(),o&&a.down([[E]])}),{deactivate:()=>{s(),o=!1}}},{...so(t),completeWhenDepsComplete:!1,meta:{...oe("switchMap"),...t?.meta??{}}})}var or=L(()=>{"use strict";ue();Fe();ae();st()});var sr=L(()=>{"use strict";or()});function Be(n){return typeof n=="object"&&n!==null&&"subscribe"in n&&"down"in n}function ir(n){if(n<=0)throw new RangeError("timeoutMs must be > 0");if(n>9e6)throw new RangeError("timeoutMs must be <= 9_000_000 (\u22482.5h) to stay within safe ns arithmetic")}function ar(n,e={}){let t=new Ve(n,e);return t.tagFactory("resilientPipeline",Cn(e)),t}var Ve,ur=L(()=>{"use strict";Fe();Zn();It();sr();Xt();Ve=class extends Ae{output;status;lastError;breakerState;droppedCount;rateLimitState;constructor(e,t={}){super(t.name??"resilient_pipeline",t.graph);let r=e,o,s,i;if(t.rateLimit!=null)if(Be(t.rateLimit)){let u=r,d=t.rateLimit;r=De(d,c=>{let p={...c,maxBuffer:c.maxBuffer??1/0,meta:H("resilient","rate-limit")};return dt(u,p).node}),this.add(r,{name:"rateLimited"})}else{let u={...t.rateLimit,maxBuffer:t.rateLimit.maxBuffer??1/0,meta:H("resilient","rate-limit")},d=dt(r,u);r=d.node,o=d.droppedCount,s=d.rateLimitState,this.add(r,{name:"rateLimited"}),this.add(o,{name:"droppedCount"}),this.add(s,{name:"rateLimitState"})}if(t.budget!=null)if(Be(t.budget)){let u=r,d=t.budget;r=De(d,c=>c.length>0?Le(u,c,{meta:H("resilient","budget")}):u),this.add(r,{name:"budgetGated"})}else t.budget.length>0&&(r=Le(r,t.budget,{meta:H("resilient","budget")}),this.add(r,{name:"budgetGated"}));if(t.breaker!=null)if(Be(t.breaker)){let u=r,d=t.breaker,c=t.breakerOnOpen??"skip";r=De(d,p=>{let f=at(p);return ut(f,{onOpen:c,meta:H("resilient","breaker")})(u).node}),this.add(r,{name:"breakerWrapped"})}else{let u=at(t.breaker),d=t.breakerOnOpen??"skip",c=ut(u,{onOpen:d,meta:H("resilient","breaker")})(r);r=c.node,i=c.breakerState,this.add(r,{name:"breakerWrapped"}),this.add(i,{name:"breakerState"})}if(t.timeoutMs!=null)if(Be(t.timeoutMs)){let u=r,d=t.timeoutMs;r=De(d,c=>(ir(c),ct(u,c*1e6,{meta:H("resilient","timeout")}))),this.add(r,{name:"timeoutWrapped"})}else ir(t.timeoutMs),r=ct(r,t.timeoutMs*1e6,{meta:H("resilient","timeout")}),this.add(r,{name:"timeoutWrapped"});if(t.retry!=null)if(Be(t.retry)){let u=r,d=t.retry;r=De(d,c=>it(u,{...c,meta:H("resilient","retry")})),this.add(r,{name:"retryWrapped"})}else r=it(r,{...t.retry,meta:H("resilient","retry")}),this.add(r,{name:"retryWrapped"});t.fallback!==void 0&&(r=Zt(r,t.fallback,{meta:H("resilient","fallback")}),this.add(r,{name:"fallbackWrapped"}));let a=Jt(r,{initialStatus:t.initialStatus??"pending",meta:H("resilient","status")});this.output=a.node,this.status=a.status,this.lastError=a.error,this.breakerState=i,this.droppedCount=o,this.rateLimitState=s,this.add(this.output,{name:"output"}),this.add(this.status,{name:"status"}),this.add(this.lastError,{name:"lastError"})}}});function we(n){return{describeKind:"derived",...n}}function ao(n){return n<0?0:n}function en(n){return n[1]}function uo(n){if(typeof n!="number"||!Number.isFinite(n))throw new TypeError("backoff strategy must return a finite number");return n<0?0:n}function ft(n){let e=n?.count,t=n?.backoff;if(t!==void 0&&e===void 0)throw new RangeError("retry({ backoff }) requires explicit count to prevent unbounded retries; pass { count: <n>, backoff: ... }");let r=e!==void 0?e:0;if(r<0)throw new RangeError("retry count must be >= 0");let o=t===void 0?null:typeof t=="string"?Kt(t):t;return{maxRetries:r,strategy:o}}function cr(n){let e={};return n?.count!==void 0&&(e.count=n.count),typeof n?.backoff=="string"&&(e.backoff=n.backoff),Object.keys(e).length>0?e:void 0}function lr(n,e,t){let r=0,o=!1,s=null,i,a=new de;function u(){i?.(),i=void 0}function d(p){if(o)return;let f=n();if(r>=f.maxRetries){u(),t.down([[_,p]]);return}let h=f.strategy===null?0:f.strategy(r,p,s);if(h==null){u(),t.down([[_,p]]);return}let l;try{l=uo(h)}catch{u(),t.down([[_,p]]);return}s=l,r+=1,u();let g=l>0?l/1e6:1;a.start(g,()=>{o||c()})}function c(){a.cancel(),u();let p;try{p=e()}catch(f){d(f);return}i=p.subscribe(f=>{if(!o)for(let h of f){let l=h[0];if(l===I)t.down([[I]]);else if(l===x)r=0,s=null,t.emit(h[1]);else if(l===M)t.down([[M]]);else if(l===E)o=!0,u(),t.down([[E]]);else if(l===_){d(en(h));return}else t.down([h])}})}return c(),()=>{o=!0,a.cancel(),u()}}function it(n,e){return typeof n=="function"?lo(n,e):co(n,e)}function co(n,e){n._resubscribable===!1&&!dr.has(n)&&(dr.add(n),console.warn("retry(source, opts): source-mode requires `resubscribable: true` on the upstream node. Retries will be silent no-ops after the first ERROR. Either pass `resubscribable: true` to the source factory, OR use factory-mode retry `retry(() => buildSource(), opts)` so each attempt builds a fresh node."));let r=re(e)?void 0:e;return re(e)||ft(r),j(o=>{let s=je(e),a=lr(()=>ft(s.current()),()=>n,o);return()=>{a(),s.unsub()}},{...we(),initial:n.cache,meta:{...r?.meta??{},...oe("retry",re(e)?{reactiveOpts:!0}:cr(r))}})}function lo(n,e){let t=re(e)?void 0:e;return re(e)||ft(t),j(r=>{let o=je(e),i=lr(()=>ft(o.current()),n,r);return()=>{i(),o.unsub()}},{...we(),initial:t?.initial,meta:{...t?.meta??{},...oe("retry",re(e)?{reactiveOpts:!0}:cr(t))}})}function at(n){let e=5,t=30*1e9,r=null,o=1,s=K;function i(v){e=Math.max(1,v?.failureThreshold??5),t=ao(v?.cooldownNs??30*1e9),r=v?.cooldown??null,o=Math.max(1,v?.halfOpenMax??1),s=v?.now??K}let a="closed",u=0,d=0,c=0,p=t,f=0,h=je(n,v=>{i(v),a="closed",u=0,d=0,f=0,p=t});i(h.current()),p=t;function l(){if(!r)return t;let v=r(d);return v!==null?v:t}function g(){a="open",p=l(),c=s(),f=0}return{canExecute(){return a==="closed"?!0:a==="open"?s()-c>=p?(a="half-open",f=1,!0):!1:f<o?(f++,!0):!1},recordSuccess(){a==="half-open"?(a="closed",u=0,d=0):a==="closed"&&(u=0)},recordFailure(v){if(a==="half-open"){d++,g();return}a==="closed"&&(u++,u>=e&&g())},get state(){return a},get failureCount(){return u},reset(){a="closed",u=0,d=0,f=0},dispose(){h.unsub()}}}function ut(n,e){let t=e?.onOpen??"skip",r=e?.meta;return o=>{let s=W([],(i,a)=>{function u(){s.meta.breakerState.down([[x,n.state]])}let d=o.subscribe(c=>{for(let p of c){let f=p[0];f===I?a.down([[I]]):f===x?n.canExecute()?(u(),a.emit(p[1])):(u(),t==="error"?a.down([[_,new pt]]):a.down([[M]])):f===M?a.down([[M]]):f===E?(n.recordSuccess(),u(),a.down([[E]])):f===_?(n.recordFailure(en(p)),u(),a.down([p])):a.down([p])}});return u(),d},{...we(),meta:{...r??{},breakerState:n.state,...oe("withBreaker",{onOpen:t})},completeWhenDepsComplete:!1,initial:o.cache});return{node:s,breakerState:s.meta.breakerState}}}function Qt(n,e,t){if(n<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let r=t?.clock??K,o=n,s=r();function i(a){if(e>0){let u=a-s;o=Math.min(n,o+u/1e9*e)}s=a}return{available(){return i(r()),o},tryConsume(a=1){if(a<=0)return!0;let u=r();return i(u),o>=a?(o-=a,!0):!1},putBack(a=1){a<=0||(i(r()),o=Math.min(n,o+a))}}}function fo(n,e){return n.droppedCount===e.droppedCount&&n.pendingCount===e.pendingCount&&n.paused===e.paused}function dt(n,e){let t=re(e);if(!t){let a=e;if(a.maxEvents<=0)throw new RangeError("maxEvents must be > 0");if(a.windowNs<=0)throw new RangeError("windowNs must be > 0");if(a.maxBuffer===void 0)throw new RangeError("rateLimiter requires explicit maxBuffer (use Infinity to opt in to unbounded)");if(!(a.maxBuffer===1/0)&&(!Number.isInteger(a.maxBuffer)||a.maxBuffer<1))throw new RangeError("maxBuffer must be a positive integer (or Infinity for unbounded)")}let r=t?e.cache:e,o=r?.maxBuffer,s=o===1/0,i=j(a=>{let u=r?.maxEvents??1,d=r?.windowNs??1e9,c=o??1,p=r?.onOverflow??"drop-newest",f=u*1e9/d,h=1e9/f,l=Qt(u,f),g=s?ho():po(Math.max(1,c)),m=new de,v=!1,b=0,y=i.meta.droppedCount,w=i.meta.rateLimitState,T=lt;function N(){y.emit(b);let P={droppedCount:b,pendingCount:g.size,paused:g.size>0};fo(T,P)||(T=P,w.emit(P))}T=lt,y.emit(0),w.emit(lt);let R=je(e,P=>{if(v||P==null||!(P.maxEvents>0)||!(P.windowNs>0))return;let A=P.maxBuffer;if(A===void 0)return;let C=A===1/0;if(C===s&&!(!C&&(!Number.isInteger(A)||A<1))){if(!C&&A>c){console.warn(`rateLimiter: reactive maxBuffer grow (${c} \u2192 ${A}) rejected. The pending ring buffer is allocated at construction; reactive maxBuffer is monotonically non-increasing. Recreate the rateLimiter with the larger cap if growth is required.`);return}if(u=P.maxEvents,d=P.windowNs,c=A,p=P.onOverflow??"drop-newest",f=u*1e9/d,h=1e9/f,l=Qt(u,f),!C)for(;g.size>c;)g.shift(),b+=1;N()}});function S(){for(;g.size>0;)if(l.tryConsume(1))a.emit(g.shift()),N();else{m.start(Math.max(1,h/1e6),S);return}}function D(){b+=1,N()}function G(){for(v=!0,m.cancel();g.size>0;)g.shift();b=0}let O=n.subscribe(P=>{for(let A of P){if(v)return;let C=A[0];if(C===I)a.down([[I]]);else if(C===x){if(!s&&g.size>=c)if(p==="drop-newest")D();else if(p==="drop-oldest")g.shift(),g.push(A[1]),D();else{D(),G(),a.down([[_,new ht(c)]]);return}else g.push(A[1]),N();S()}else if(C===M)a.down([[M]]);else if(C===E)G(),a.down([[E]]);else if(C===_)G(),a.down([A]);else if(C===V){G(),a.down([A]);return}else a.down([A])}});return()=>{v=!0,m.cancel(),O(),R.unsub()}},{...we(),initial:n.cache,meta:{...t?{}:e.meta??{},droppedCount:0,rateLimitState:lt,...oe("rateLimiter",t?{reactiveOpts:!0}:e)}});return{node:i,droppedCount:i.meta.droppedCount,rateLimitState:i.meta.rateLimitState}}function po(n){let e=new ge(n);return{push:t=>e.push(t),shift:()=>e.shift(),get size(){return e.size}}}function ho(){let n=[];return{push:e=>{n.push(e)},shift:()=>n.shift(),get size(){return n.length}}}function Jt(n,e){let t=e?.initialStatus??"pending",r=e?.meta,o=W([],(s,i)=>{let a=t;return o.meta.status.down([[x,t]]),o.meta.error.down([[x,null]]),n.subscribe(d=>{for(let c of d){let p=c[0];if(p===I)i.down([[I]]);else if(p===x)a==="errored"?Se(()=>{o.meta.error.down([[x,null]]),o.meta.status.down([[x,"running"]])}):o.meta.status.down([[x,"running"]]),a="running",i.emit(c[1]);else if(p===M)i.down([[M]]);else if(p===E)o.meta.status.down([[x,"completed"]]),a="completed",i.down([[E]]);else if(p===_){let f=en(c);Se(()=>{o.meta.error.down([[x,f]]),o.meta.status.down([[x,"errored"]])}),a="errored",i.down([c])}else i.down([c])}})},{...we(),meta:{...r??{},status:t,error:null,...oe("withStatus",{initialStatus:t})},completeWhenDepsComplete:!1,resubscribable:!0,initial:n.cache});return{node:o,status:o.meta.status,error:o.meta.error}}function re(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function je(n,e){if(!re(n))return{current:()=>n,unsub:()=>{}};let t=n,r=t.cache,o=t.subscribe(s=>{for(let i of s)i[0]===x&&(r=i[1],e&&e(r))});return{current:()=>r,unsub:o}}function mo(n){return n!=null&&typeof n.then=="function"}function go(n){return n!=null&&typeof n=="object"&&typeof n[Symbol.asyncIterator]=="function"}function Zt(n,e,t){let r=t?.meta;return j(o=>{let s,i;function a(){i?.(),i=void 0,re(e)||mo(e)||go(e)?s=le(e).subscribe(d=>{o.down(d);for(let c of d){let p=c[0];if(p===E||p===_||p===V){s=void 0;return}}}):(o.emit(e),o.down([[E]]))}return i=n.subscribe(u=>{for(let d of u){let c=d[0];if(c===I)o.down([[I]]);else if(c===x)o.emit(d[1]);else if(c===M)o.down([[M]]);else if(c===E)o.down([[E]]);else if(c===_){a();return}else if(c===V){s?.(),o.down([d]);return}else o.down([d])}}),()=>{i?.(),s?.()}},{...we(),initial:n.cache,meta:{...r??{},...oe("fallback")}})}function ct(n,e,t){if(!re(e)&&e<=0)throw new RangeError("timeoutNs must be > 0");let r=t?.meta,o=re(e)?{timeoutNs:"Node<number>"}:{timeoutNs:e};return j(s=>{let i=!1,a=new de,u=je(e),d=()=>{let f=u.current();return typeof f=="number"&&f>0?f:0};function c(){let f=d();if(f<=0)return;let h=f/1e6;a.start(h,()=>{i||(i=!0,p(),s.down([[_,new mt(f)]]))})}let p=n.subscribe(f=>{for(let h of f){if(i)return;let l=h[0];if(l===I)s.down([[I]]);else if(l===x)c(),s.emit(h[1]);else if(l===M)s.down([[M]]);else if(l===E){a.cancel(),i=!0,s.down([[E]]);return}else if(l===_){a.cancel(),i=!0,s.down([h]);return}else if(l===V){a.cancel(),i=!0,s.down([h]);return}else s.down([h])}});return c(),()=>{i=!0,a.cancel(),p(),u.unsub()}},{...we(),initial:n.cache,meta:{...r??{},...oe("timeout",o)}})}var dr,pt,ht,lt,mt,Xt=L(()=>{"use strict";Sn();ur();Ke();Ne();ue();Fe();ae();Qe();Yt();st();zt();Ut();dr=new WeakSet;pt=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};ht=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};lt=Object.freeze({droppedCount:0,pendingCount:0,paused:!1});mt=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});var fr={};_t(fr,{CircuitOpenError:()=>pt,RateLimiterOverflowError:()=>ht,ResilientPipelineGraph:()=>Ve,TimeoutError:()=>mt,budgetGate:()=>Le,circuitBreaker:()=>at,fallback:()=>Zt,rateLimiter:()=>dt,resilientPipeline:()=>ar,retry:()=>it,timeout:()=>ct,tokenBucket:()=>Qt,withBreaker:()=>ut,withStatus:()=>Jt});var pr=L(()=>{"use strict";Xt()});function J(n){return{describeKind:"producer",...n}}function mr(n){return/[\\^$+?.()|[\]{}]/.test(n)?`\\${n}`:n}function bo(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){n[t+1]==="*"?(e+=".*",t+=1):e+="[^/]*";continue}e+=mr(r)}return e+="$",new RegExp(e)}function yo(n,e){for(let t of e)if(t.test(n))return!0;return!1}function vo(n,e){let t=W([n],(o,s)=>{let i=o[0];if(i==null||i.length===0){s.down([[M]]);return}for(let a of i)s.emit(a)},{describeKind:"derived",initial:n.cache}),r=t.subscribe.bind(t);return t.subscribe=(o,s)=>(e(o),r(o,s)),t}function wo(n,e){let{signal:t,period:r,...o}=e??{};return j(s=>{let i=!1,a=0,u,d,c=()=>{i=!0,u!==void 0&&clearTimeout(u),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",f)},p=()=>{i||(r!=null?(s.emit(a++),d=setInterval(()=>{i||s.emit(a++)},r)):(i=!0,t?.removeEventListener("abort",f),s.emit(a++),s.down([[E]])))},f=()=>{i||(c(),s.down([[_,t.reason]]))};if(t?.aborted){f();return}return u=setTimeout(p,n),t?.addEventListener("abort",f,{once:!0}),c},J(o))}function To(n){let{signal:e,...t}=n??{};return j(r=>{let o=!1,s,i,a=!1,u=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,c=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,p=typeof document<"u"?document:void 0,f=()=>{s!==void 0&&c&&c(s),i!==void 0&&clearTimeout(i),s=void 0,i=void 0},h=()=>{o=!0,f(),a&&(e?.removeEventListener("abort",l),a=!1),u&&p&&(p.removeEventListener("visibilitychange",v),u=!1)},l=()=>{o||(h(),r.down([[_,e.reason]]))},g=b=>{o||(r.emit(b),m())},m=()=>{o||(d&&(!p||p.visibilityState!=="hidden")?s=d(g):i=setTimeout(()=>g(performance.now()),16))},v=()=>{o||(f(),m())};return e?.aborted?(l(),h):(e?.addEventListener("abort",l,{once:!0}),a=e!==void 0,p&&d&&(p.addEventListener("visibilitychange",v),u=!0),m(),h)},J(t))}function _o(n,e){let t=xn(n),{tickMs:r,output:o,...s}=e??{},i=r??6e4,a=o==="date";return j(u=>{let d=-1,c=()=>{let f=new Date,h=f.getFullYear()*1e8+(f.getMonth()+1)*1e6+f.getDate()*1e4+f.getHours()*100+f.getMinutes();h!==d&&En(t,f)&&(d=h,u.emit(a?f:_e()))};c();let p=setInterval(c,i);return()=>clearInterval(p)},{...J(s),name:s.name??`cron:${n}`})}function No(n,e,t){let{capture:r,passive:o,once:s,...i}=t??{};return j(a=>{let u=c=>{a.emit(c)},d={capture:r,passive:o,once:s};return n.addEventListener(e,u,d),()=>n.removeEventListener(e,u,d)},J(i))}function rn(n,e){return j(t=>{let r=!1;try{for(let o of n){if(r)return;t.emit(o)}r||t.down([[E]])}catch(o){r||t.down([[_,o]])}return()=>{r=!0}},J(e))}function Oo(n){return n!=null&&typeof n.then=="function"}function gr(n,e){let{signal:t,...r}=e??{};return j(o=>{let s=!1,i=()=>{s||(s=!0,o.down([[_,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(n).then(a=>{s||(s=!0,t?.removeEventListener("abort",i),o.emit(a),o.down([[E]]))},a=>{s||(s=!0,t?.removeEventListener("abort",i),o.down([[_,a]]))}),()=>{s=!0,t?.removeEventListener("abort",i)}},J(r))}function br(n,e){let{signal:t,...r}=e??{};return j(o=>{let s=new AbortController,i=()=>s.abort(t?.reason);t?.aborted?s.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let a=t??s.signal,u=!1,d=n[Symbol.asyncIterator](),c=()=>{u||a.aborted||Promise.resolve(d.next()).then(p=>{if(!(u||a.aborted)){if(p.done){o.down([[E]]);return}o.emit(p.value),c()}},p=>{!u&&!a.aborted&&o.down([[_,p]])})};return c(),()=>{u=!0,t?.removeEventListener("abort",i),s.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},J(r))}function ko(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function le(n,e){if(ko(n))return n;if(Oo(n))return gr(n,e);if(n!=null){let t=n;if(typeof t[Symbol.asyncIterator]=="function")return br(n,e);if(typeof t[Symbol.iterator]=="function")return rn(n,e)}return yr(n)}function yr(...n){return rn(n,void 0)}function xo(n){return j(e=>{e.down([[E]])},J(n))}function Eo(n){return j(()=>{},J(n))}function Ro(n,e){return j(t=>{t.down([[_,n]])},J(e))}function So(n,e){let{signal:t,...r}=e??{},o=J(r),s=o.resubscribable===void 0?{...o,resubscribable:!0}:o;return j(i=>{let a,u=!1;try{let d=n();a=le(d,e).subscribe(p=>{if(!u)for(let f of p){let h=f[0];if(h!==ie)if(h===x)i.emit(f[1]);else if(h===E){u=!0,i.down([[E]]);break}else if(h===_){u=!0,i.down([[_,f[1]]]);break}else i.down([f])}})}catch(d){let c=d===void 0?new Error("defer: thunk threw undefined"):d;i.down([[_,c]])}return()=>{u=!0,a?.()}},s)}function Co(n,e,t){return W([n],(o,s)=>{let i=o[0];if(i!=null&&i.length>0)for(let a of i)e(a)},{describeKind:"effect",...t}).subscribe(()=>{})}function Ao(n,e){return W([n],(t,r,o)=>{o.store.buf||(o.store.buf=[]);let s=o.store.buf,i=t[0];if(i!=null&&i.length>0)for(let a of i)s.push(a);if(o.terminalDeps[0]===!0){r.emit([...s]),r.down([[E]]);return}(i==null||i.length===0)&&r.down([[M]])},{describeKind:"derived",completeWhenDepsComplete:!1,...e})}function Do(n,e){return j(t=>n.subscribe(r=>{t.down(r)}),{...J(e),initial:n.cache})}function on(n,e,t){if(e<1)throw new RangeError("replay expects bufferSize >= 1");let r=[],o=j(s=>n.subscribe(i=>{for(let a of i)a[0]===x&&(r.push(a[1]),r.length>e&&r.shift());s.down(i)}),{...J(t),initial:n.cache});return vo(o,s=>{for(let i of r)s([[x,i]])})}function Mo(n,e){return on(n,1,e)}function Go(n){return new Promise((e,t)=>{let r=!1,o=!1,s;s=n.subscribe(i=>{for(let a of i){if(r)return;if(a[0]===x){r=!0,e(a[1]),s?(s(),s=void 0):o=!0;return}if(a[0]===_){r=!0,t(a[1]),s?(s(),s=void 0):o=!0;return}if(a[0]===E){r=!0,t(new Error("completed without DATA")),s?(s(),s=void 0):o=!0;return}}}),o&&(s?.(),s=void 0)})}function nn(n,e,t){return new Promise((r,o)=>{let s=!1,i=!1,a,u=t?.skipCurrent===!0;a=n.subscribe(d=>{for(let c of d){if(s)return;if(!(u&&c[0]===x)){if(c[0]===x){let p=c[1];if(e(p)){s=!0,r(p),a?(a(),a=void 0):i=!0;return}}if(c[0]===_){s=!0,o(c[1]),a?(a(),a=void 0):i=!0;return}if(c[0]===E){s=!0,o(new Error("completed without matching value")),a?(a(),a=void 0):i=!0;return}}}}),u=!1,i&&(a?.(),a=void 0)})}async function Po(n,e){let t=e?.predicate??(s=>s!=null),r=e?.skipCurrent;if(e?.timeoutMs==null||e.timeoutMs<=0)return await nn(n,t,{skipCurrent:r});if(tn===void 0){let[s,i]=await Promise.all([Promise.resolve().then(()=>(pr(),fr)),Promise.resolve().then(()=>(Yt(),rr))]);tn=s.timeout,hr=i.NS_PER_MS}let o=tn(n,e.timeoutMs*hr);return await nn(o,t,{skipCurrent:r})}function Io(n,e){let t=new AbortController,r=e?.reason??new Error("cancelled via nodeSignal"),o,s=!1,i=()=>{o?(o(),o=void 0):s=!0};return o=n.subscribe(a=>{if(!t.signal.aborted)for(let u of a){if(u[0]===x&&u[1]===!0){t.abort(r),i();return}if(u[0]===_){t.abort(u[1]),i();return}if(u[0]===E){i();return}}}),s&&(o?.(),o=void 0),{signal:t.signal,dispose:()=>{o&&(o(),o=void 0)}}}function $e(n){return n.subscribe(()=>{})}function Fo(n){let e=me(0);return{node:e,increment(){let t=e.cache??0;return t>=n?!1:(e.down([[I],[x,t+1]]),!0)},get(){return e.cache??0},atCap(){return(e.cache??0)>=n}}}var tn,hr,Lo,vr=L(()=>{"use strict";Ne();ue();ae();Qe();Rn();Lo=on});var $o={};_t($o,{awaitSettled:()=>Po,cached:()=>Mo,defer:()=>So,empty:()=>xo,escapeRegexChar:()=>mr,firstValueFrom:()=>Go,firstWhere:()=>nn,forEach:()=>Co,fromAny:()=>le,fromAsyncIter:()=>br,fromCron:()=>_o,fromEvent:()=>No,fromIter:()=>rn,fromPromise:()=>gr,fromRaf:()=>To,fromTimer:()=>wo,globToRegExp:()=>bo,keepalive:()=>$e,matchesAnyPattern:()=>yo,never:()=>Eo,nodeSignal:()=>Io,of:()=>yr,reactiveCounter:()=>Fo,replay:()=>on,share:()=>Do,shareReplay:()=>Lo,throwError:()=>Ro,toArray:()=>Ao});module.exports=Or($o);var st=L(()=>{vr()});st();0&&(module.exports={awaitSettled,cached,defer,empty,escapeRegexChar,firstValueFrom,firstWhere,forEach,fromAny,fromAsyncIter,fromCron,fromEvent,fromIter,fromPromise,fromRaf,fromTimer,globToRegExp,keepalive,matchesAnyPattern,never,nodeSignal,of,reactiveCounter,replay,share,shareReplay,throwError,toArray});
|
package/dist/extra/sources.d.cts
CHANGED
package/dist/extra/sources.d.ts
CHANGED
package/dist/extra/sources.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as y,B as z,C as A,D as B,c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"../chunk-
|
|
1
|
+
import{A as y,B as z,C as A,D as B,c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l,o as m,p as n,q as o,r as p,s as q,t as r,u as s,v as t,w as u,x as v,y as w,z as x}from"../chunk-CRVT7D2P.js";import"../chunk-NTEURFZH.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{x as awaitSettled,u as cached,p as defer,m as empty,a as escapeRegexChar,v as firstValueFrom,w as firstWhere,q as forEach,k as fromAny,j as fromAsyncIter,f as fromCron,g as fromEvent,h as fromIter,i as fromPromise,e as fromRaf,d as fromTimer,b as globToRegExp,A as keepalive,c as matchesAnyPattern,n as never,y as nodeSignal,l as of,B as reactiveCounter,t as replay,s as share,z as shareReplay,o as throwError,r as toArray};
|