@graphrefly/graphrefly 0.29.0 → 0.31.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-CcAgRacD.d.cts → cascading-BfQmSmjU.d.cts} +22 -3
- package/dist/{cascading-Bp99ckMJ.d.ts → cascading-D3sapjue.d.ts} +22 -3
- package/dist/{chunk-JYOUF6UQ.js → chunk-3JRKP4BH.js} +1 -1
- package/dist/{chunk-GJR3P6JG.js → chunk-3Q2WXM6X.js} +1 -1
- package/dist/chunk-4KAUNEKV.js +3 -0
- package/dist/{chunk-SLMYTGTU.js → chunk-4UUDNFYG.js} +1 -1
- package/dist/chunk-4VXL3UZK.js +1 -0
- package/dist/{chunk-AV3PIDFQ.js → chunk-4ZPO2EL5.js} +1 -1
- package/dist/{chunk-VWPRPPKR.js → chunk-5LJAQTSS.js} +1 -1
- package/dist/{chunk-W4TSQ6RJ.js → chunk-7AJKUA36.js} +1 -1
- package/dist/{chunk-RD52SNH2.js → chunk-7EJTWGKW.js} +1 -1
- package/dist/{chunk-GNCBXARM.js → chunk-7EQPXQ7H.js} +1 -1
- package/dist/chunk-7QMVU3IX.js +1 -0
- package/dist/{chunk-BA5URFYW.js → chunk-A4JT4SAD.js} +1 -1
- package/dist/chunk-ASDKRNOJ.js +60 -0
- package/dist/{chunk-Y32RJO24.js → chunk-CZVYLXFK.js} +1 -1
- package/dist/{chunk-567NWZ3T.js → chunk-DWIAG62L.js} +1 -1
- package/dist/{chunk-Y53B6NS4.js → chunk-EBQ6FXKW.js} +1 -1
- package/dist/chunk-FTA5TB2A.js +1 -0
- package/dist/{chunk-E3AXATVZ.js → chunk-GF5T7PGC.js} +1 -1
- package/dist/{chunk-HSIEYSDY.js → chunk-I4U3TPK2.js} +1 -1
- package/dist/{chunk-AMG5VBHW.js → chunk-JMGGCSIC.js} +1 -1
- package/dist/chunk-JXRZXP3N.js +1 -0
- package/dist/{chunk-5Z4HDCO6.js → chunk-K54OKWNY.js} +1 -1
- package/dist/{chunk-63FFOHLA.js → chunk-KN4Q5MQO.js} +1 -1
- package/dist/chunk-LWGLBCMU.js +1 -0
- package/dist/{chunk-TWMEGG45.js → chunk-N2KKISCE.js} +1 -1
- package/dist/{chunk-4OFIQ66T.js → chunk-OKQUPJRY.js} +1 -1
- package/dist/chunk-PNTBXOQ6.js +5 -0
- package/dist/chunk-PSQNYY72.js +7 -0
- package/dist/{chunk-22F4K3G7.js → chunk-PZP4MEXK.js} +1 -1
- package/dist/{chunk-7TDOES3L.js → chunk-Q2SY7M7K.js} +1 -1
- package/dist/{chunk-OL33ZI6R.js → chunk-RWGJQQLT.js} +1 -1
- package/dist/chunk-SGS4OJGS.js +1 -0
- package/dist/chunk-UMH3HSP7.js +1 -0
- package/dist/{chunk-BZP5T4X6.js → chunk-W6FQIFVE.js} +1 -1
- package/dist/{chunk-A7IAQQ63.js → chunk-WLPVGXQ6.js} +1 -1
- package/dist/chunk-WQ7I7JVU.js +1 -0
- package/dist/{chunk-LGSNR4LU.js → chunk-WYJTXYWX.js} +1 -1
- package/dist/{chunk-PGMUCUHG.js → chunk-X2VHDT26.js} +1 -1
- package/dist/{chunk-PCZ35NXD.js → chunk-XEFAMCEA.js} +1 -1
- package/dist/{chunk-AUY2YKCO.js → chunk-XRSHMHEG.js} +1 -1
- package/dist/chunk-Y26UN6J5.js +18 -0
- package/dist/{chunk-BKPLTBL5.js → chunk-YQJPYEAL.js} +1 -1
- package/dist/{chunk-UVJQ35G2.js → chunk-YZ6VYLFD.js} +1 -1
- package/dist/{chunk-4JJCCD5S.js → chunk-YZKGGMPT.js} +1 -1
- package/dist/chunk-Z3UWIJ3A.js +1 -0
- package/dist/{chunk-CSJE2EKV.js → chunk-ZM7C2FUM.js} +1 -1
- package/dist/compat/index.cjs +1 -1
- package/dist/compat/index.d.cts +14 -14
- package/dist/compat/index.d.ts +14 -14
- 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 +6 -6
- package/dist/compat/nestjs/index.d.ts +6 -6
- 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 +1 -1
- package/dist/compat/zustand/index.d.cts +4 -4
- package/dist/compat/zustand/index.d.ts +4 -4
- package/dist/compat/zustand/index.js +1 -1
- package/dist/{composite-BL-llbnE.d.ts → composite-BY9hMxN7.d.ts} +2 -2
- package/dist/{composite-Dze--DaA.d.cts → composite-CH0S8DFn.d.cts} +2 -2
- package/dist/content-addressed-storage-BUiREIuj.d.ts +124 -0
- package/dist/content-addressed-storage-DqIWCmZG.d.cts +124 -0
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +1 -1
- package/dist/extra/browser.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 +18 -18
- package/dist/extra/index.d.cts +12 -11
- package/dist/extra/index.d.ts +12 -11
- 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 +42 -2
- package/dist/extra/operators.d.ts +42 -2
- 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/sources.cjs +1 -1
- package/dist/extra/sources.d.cts +63 -3
- package/dist/extra/sources.d.ts +63 -3
- 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-BaTS7vVY.d.cts → fallback-Cb3GH1O7.d.cts} +6 -14
- package/dist/{fallback-eOm3LNxP.d.ts → fallback-DRjJ_ZM8.d.ts} +6 -14
- package/dist/graph/index.cjs +4 -4
- 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-DgohqXK-.d.cts → graph-C4Uxwv0T.d.cts} +2 -2
- package/dist/{graph-Qjg9gWHI.d.ts → graph-CWeI0aHd.d.ts} +2 -2
- package/dist/{index-DX8xS-yB.d.cts → index-9iguV3bF.d.cts} +2 -2
- package/dist/{index-BanNUILp.d.cts → index-B-z8WaSd.d.cts} +2 -2
- package/dist/{index-C66RJiX8.d.ts → index-B5iVOD7w.d.ts} +2 -2
- package/dist/{index-CcWOJ6F0.d.ts → index-BANwzwBV.d.ts} +3 -3
- package/dist/{index-CiaVoZGo.d.ts → index-BBINVimG.d.ts} +3 -3
- package/dist/{index-B-gqvYel.d.ts → index-BEpRsvhg.d.ts} +4 -4
- package/dist/{index-C8RfjffH.d.ts → index-BMe3pCom.d.cts} +3 -3
- package/dist/{index-gsT79Xu9.d.ts → index-BX22kvjh.d.ts} +1 -1
- package/dist/{index-CA1Cu7Ud.d.ts → index-BXzl1NDD.d.ts} +6 -6
- package/dist/{index-BqZ6vB2A.d.ts → index-Bd6oFZqO.d.ts} +230 -122
- package/dist/{index-kykKWwV-.d.cts → index-BpFWP7Bq.d.cts} +3 -3
- package/dist/{index-iKkyJosF.d.cts → index-Bs3-LC83.d.cts} +3 -3
- package/dist/{index-CJ45TW-h.d.ts → index-Bvi5uJxX.d.ts} +1 -1
- package/dist/{index-IMAHq-ia.d.ts → index-ByPnK85n.d.ts} +1 -1
- package/dist/{index-CABbltIu.d.cts → index-BydMDMf7.d.cts} +1 -1
- package/dist/{index-D5XJ2tSx.d.ts → index-C5Ghnp5B.d.ts} +3 -3
- package/dist/{index-BiyjsZ0m.d.ts → index-C6NBfXj-.d.ts} +3 -3
- package/dist/{index-D9HKAH_-.d.cts → index-C98oJsEs.d.cts} +2 -2
- package/dist/{index-CHEBsnYv.d.cts → index-CDK5RsV5.d.cts} +1 -1
- package/dist/{index-DJ5oNBc8.d.ts → index-CFW32Dy1.d.ts} +3 -3
- package/dist/{index-D80do5jX.d.cts → index-CIXaiYDE.d.cts} +1 -1
- package/dist/{index-2BVuRCI4.d.ts → index-CJymKyzT.d.ts} +86 -11
- package/dist/{index-H_oxVec5.d.cts → index-CRAkoq-y.d.cts} +1 -1
- package/dist/{index-DiZejfCI.d.cts → index-CZChc85Q.d.cts} +230 -122
- package/dist/{index-DDy8eeXS.d.ts → index-CcS0t-l2.d.ts} +3 -3
- package/dist/{index-B2PRuolf.d.cts → index-CcpEvuPl.d.cts} +2 -2
- package/dist/{index-DwjJGKxV.d.ts → index-CfFYyLR8.d.ts} +3 -3
- package/dist/{index-A65LZhoM.d.ts → index-CotRMjtJ.d.ts} +2 -2
- package/dist/{index-BQaEnxBf.d.ts → index-CrC7urhX.d.ts} +1 -1
- package/dist/{index-DuB5aO4-.d.ts → index-CvS9IuTG.d.ts} +2 -2
- package/dist/{index-BUi57v_p.d.ts → index-CwhcFzTA.d.ts} +4 -4
- package/dist/{index-BUVtw1Ay.d.cts → index-Cy7eFeIX.d.cts} +2 -2
- package/dist/{index-C08QPDcV.d.cts → index-D-kHVedZ.d.cts} +3 -3
- package/dist/{index-Ct5CWc4E.d.ts → index-D0C_USMR.d.ts} +1 -1
- package/dist/{index-y1RllPn4.d.cts → index-D7XxY1Ff.d.cts} +1 -1
- package/dist/{index-BJqt9EwW.d.ts → index-D9HrBx2J.d.ts} +2 -2
- package/dist/{index-DP0_O3ls.d.cts → index-D9Y_u6BG.d.cts} +3 -3
- package/dist/{index-DoWMs-Kk.d.cts → index-DBQUKh59.d.cts} +4 -4
- package/dist/{index-dig-r2tQ.d.cts → index-DD7RhHNJ.d.cts} +6 -6
- package/dist/{index-U1nir7MX.d.cts → index-DDo-eqQ4.d.cts} +1 -1
- package/dist/{index-2NvguqQA.d.ts → index-DGb1awva.d.ts} +4 -4
- package/dist/{index-i99Ka8s7.d.cts → index-DR3gf_DG.d.cts} +9 -9
- package/dist/{index-DBe_8XW5.d.cts → index-DVNLe3pS.d.cts} +3 -3
- package/dist/{index-DknyJ2Fu.d.cts → index-Dm3_D5Ta.d.cts} +4 -4
- package/dist/{index-DCeTyFlB.d.ts → index-DnrZghBB.d.ts} +2 -2
- package/dist/{index-Byh-xTyp.d.ts → index-Docdiu9a.d.ts} +3 -3
- package/dist/{index-BTSkeCZs.d.cts → index-DxMS0cHM.d.ts} +3 -3
- package/dist/{index-D38duMCv.d.cts → index-DylQCKEL.d.cts} +3 -3
- package/dist/{index-jleeotBT.d.cts → index-FBqTfL_S.d.cts} +1 -1
- package/dist/{index-Vg7tORgk.d.ts → index-FrYrV-Vf.d.ts} +2 -2
- package/dist/{index-BSfwiy5B.d.ts → index-IZ3l_vQ9.d.ts} +2 -2
- package/dist/{index-CX2tFJL1.d.ts → index-Ip3q9T9x.d.ts} +1 -1
- package/dist/{index-CI0yDnLp.d.ts → index-RQg6lTrN.d.ts} +9 -9
- package/dist/{index-vgcLF5TH.d.cts → index-SSGqF8mI.d.cts} +2 -2
- package/dist/{index-CJZKZoo4.d.cts → index-UZO988ox.d.cts} +3 -3
- package/dist/{index-BKjT5DiZ.d.cts → index-gJQqJTKx.d.cts} +86 -11
- package/dist/{index-BayHDRx6.d.cts → index-iBp74eGU.d.cts} +3 -3
- package/dist/{index-BuVidq3D.d.cts → index-lKuLYmHO.d.cts} +2 -2
- package/dist/{index-BM8BU4q6.d.ts → index-wIx1Jisk.d.ts} +1 -1
- package/dist/{index-B-8FCEua.d.cts → index-yIdWFo2b.d.cts} +4 -4
- package/dist/index.cjs +99 -121
- package/dist/index.d.cts +47 -46
- package/dist/index.d.ts +47 -46
- package/dist/index.js +1 -1
- package/dist/{meta-CckhhFRd.d.ts → meta-BMwx3ExI.d.ts} +1 -1
- package/dist/{meta-CX7YsOzp.d.cts → meta-COtmHLwT.d.cts} +1 -1
- package/dist/{node-Dd6wHSib.d.cts → node-BVV7G1bq.d.cts} +24 -0
- package/dist/{node-Dd6wHSib.d.ts → node-BVV7G1bq.d.ts} +24 -0
- package/dist/{observable-kwzpLvbi.d.cts → observable-BrUAPeH_.d.cts} +1 -1
- package/dist/{observable-BZJgo616.d.ts → observable-ITikPXz3.d.ts} +1 -1
- package/dist/patterns/ai/browser.cjs +5 -22
- 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 +27 -44
- package/dist/patterns/ai/index.d.cts +17 -15
- package/dist/patterns/ai/index.d.ts +17 -15
- package/dist/patterns/ai/index.js +1 -1
- package/dist/patterns/ai/node.cjs +2 -2
- package/dist/patterns/ai/node.d.cts +5 -4
- package/dist/patterns/ai/node.d.ts +5 -4
- package/dist/patterns/ai/node.js +1 -1
- package/dist/patterns/audit/index.cjs +3 -3
- package/dist/patterns/audit/index.d.cts +5 -5
- package/dist/patterns/audit/index.d.ts +5 -5
- package/dist/patterns/audit/index.js +1 -1
- package/dist/patterns/cqrs/index.cjs +6 -6
- package/dist/patterns/cqrs/index.d.cts +4 -4
- package/dist/patterns/cqrs/index.d.ts +4 -4
- package/dist/patterns/cqrs/index.js +1 -1
- package/dist/patterns/demo-shell/index.cjs +1 -1
- 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 +4 -4
- 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 +6 -6
- package/dist/patterns/graphspec/index.d.cts +5 -5
- package/dist/patterns/graphspec/index.d.ts +5 -5
- package/dist/patterns/graphspec/index.js +1 -1
- package/dist/patterns/guarded-execution/index.cjs +7 -7
- package/dist/patterns/guarded-execution/index.d.cts +6 -6
- package/dist/patterns/guarded-execution/index.d.ts +6 -6
- package/dist/patterns/guarded-execution/index.js +1 -1
- package/dist/patterns/harness/index.cjs +11 -11
- package/dist/patterns/harness/index.d.cts +9 -9
- package/dist/patterns/harness/index.d.ts +9 -9
- package/dist/patterns/harness/index.js +1 -1
- package/dist/patterns/job-queue/index.cjs +5 -5
- package/dist/patterns/job-queue/index.d.cts +4 -4
- package/dist/patterns/job-queue/index.d.ts +4 -4
- package/dist/patterns/job-queue/index.js +1 -1
- package/dist/patterns/lens/index.cjs +5 -5
- package/dist/patterns/lens/index.d.cts +6 -6
- package/dist/patterns/lens/index.d.ts +6 -6
- package/dist/patterns/lens/index.js +1 -1
- package/dist/patterns/memory/index.cjs +4 -4
- package/dist/patterns/memory/index.d.cts +4 -4
- package/dist/patterns/memory/index.d.ts +4 -4
- package/dist/patterns/memory/index.js +1 -1
- package/dist/patterns/messaging/index.cjs +5 -5
- package/dist/patterns/messaging/index.d.cts +4 -4
- package/dist/patterns/messaging/index.d.ts +4 -4
- package/dist/patterns/messaging/index.js +1 -1
- package/dist/patterns/orchestration/index.cjs +1 -1
- package/dist/patterns/orchestration/index.d.cts +5 -5
- package/dist/patterns/orchestration/index.d.ts +5 -5
- package/dist/patterns/orchestration/index.js +1 -1
- package/dist/patterns/reactive-layout/index.cjs +1 -1
- 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 +5 -5
- package/dist/patterns/reduction/index.d.cts +4 -4
- package/dist/patterns/reduction/index.d.ts +4 -4
- package/dist/patterns/reduction/index.js +1 -1
- package/dist/patterns/refine-loop/index.cjs +8 -8
- package/dist/patterns/refine-loop/index.d.cts +5 -5
- package/dist/patterns/refine-loop/index.d.ts +5 -5
- package/dist/patterns/refine-loop/index.js +1 -1
- package/dist/patterns/resilient-pipeline/index.cjs +1 -1
- package/dist/patterns/resilient-pipeline/index.d.cts +6 -6
- package/dist/patterns/resilient-pipeline/index.d.ts +6 -6
- package/dist/patterns/resilient-pipeline/index.js +1 -1
- package/dist/patterns/surface/index.cjs +7 -7
- 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/{reactive-layout-PiFwVaWS.d.cts → reactive-layout-5oEn8lHM.d.cts} +2 -2
- package/dist/{reactive-layout-BkBwVvwm.d.ts → reactive-layout-BAr6-_o5.d.ts} +2 -2
- package/dist/{reactive-log-BiVoSxke.d.cts → reactive-log-5jFeNRmd.d.cts} +1 -1
- package/dist/{reactive-log-1QTyx10a.d.ts → reactive-log-BOJDCI5x.d.ts} +1 -1
- package/dist/{reactive-map-CwO_COHy.d.cts → reactive-map-CtRaCddO.d.ts} +60 -2
- package/dist/{reactive-map-FeuTVAJb.d.ts → reactive-map-IJIfZxoh.d.cts} +60 -2
- package/dist/{resilience-CBfYJW5C.d.ts → resilience-CludlzcP.d.ts} +1 -1
- package/dist/{resilience-XRUF267O.js → resilience-IVNDYORD.js} +1 -1
- package/dist/{resilience-uBz4yvYB.d.cts → resilience-Q6Bt_7y0.d.cts} +1 -1
- package/dist/{sugar-CY-MCfZ9.d.ts → sugar-BHbAACDG.d.ts} +1 -1
- package/dist/{sugar-DHttV0LX.d.cts → sugar-CqR6DJ7v.d.cts} +1 -1
- package/dist/{topology-tree-CVjt2gp7.d.cts → topology-tree-CVREibAc.d.cts} +1 -1
- package/dist/{topology-tree-one6oSKY.d.ts → topology-tree-CkjojcB6.d.ts} +1 -1
- package/dist/{types-O3GzJY2U.d.cts → types-BgMqbc7N.d.cts} +41 -14
- package/dist/{types-u64Ose53.d.ts → types-CdfO2QTt.d.ts} +41 -14
- package/package.json +1 -1
- package/dist/chunk-22SVXUPB.js +0 -64
- package/dist/chunk-2GQREQ6C.js +0 -1
- package/dist/chunk-4V4C7K56.js +0 -1
- package/dist/chunk-5JDE5JHE.js +0 -1
- package/dist/chunk-7JDLFI6N.js +0 -1
- package/dist/chunk-ISCENNXS.js +0 -1
- package/dist/chunk-KASHOCF5.js +0 -1
- package/dist/chunk-LVGBLZM2.js +0 -1
- package/dist/chunk-MGKAO4EK.js +0 -7
- package/dist/chunk-NSG4C6BF.js +0 -23
- package/dist/chunk-VGTCGNRX.js +0 -18
- package/dist/chunk-WM7H7WTY.js +0 -3
package/dist/extra/index.cjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";var rn=Object.defineProperty;var To=Object.getOwnPropertyDescriptor;var wo=Object.getOwnPropertyNames;var xo=Object.prototype.hasOwnProperty;var he=(t,e)=>()=>(t&&(e=t(t=0)),e);var on=(t,e)=>{for(var n in e)rn(t,n,{get:e[n],enumerable:!0})},ko=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of wo(e))!xo.call(t,s)&&s!==n&&rn(t,s,{get:()=>e[s],enumerable:!(r=To(e,s))||r.enumerable});return t};var _o=t=>ko(rn({},"__esModule",{value:!0}),t);function _t(){return Qe>0||ft}function Qn(){return Qe>0}function ht(t){Qe>0?pt.push(t):t()}function j(t){Qe+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(Qe-=1,Qe===0)if(e){if(!ft){let n=pt.splice(0);for(let r of n)try{r()}catch{}Fe.length=0,$e.length=0,Xe.length=0}}else No()}}function No(){let t=!ft;t&&(ft=!0);let e=[],n=0;try{for(;Fe.length>0||$e.length>0||Xe.length>0||t&&pt.length>0;){if(t&&pt.length>0){let o=pt.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw Fe.length=0,$e.length=0,Xe.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(Fe.length>0?Fe:$e.length>0?$e:Xe).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{t&&(ft=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Nt(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!_t()){t(e);return}(u>=5?Xe:u===4?$e:Fe).push(()=>t(e));return}let r=e.length,s=r,o=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(s=a;a<r&&n(e[a][0])===3;)a++;for(o=a;a<r&&n(e[a][0])===4;)a++;i=a;let d=_t();if(s>0){let u=e.slice(0,s);t(u)}if(o>s){let u=e.slice(s,o);d?Fe.push(()=>t(u)):t(u)}if(i>o){let u=e.slice(o,i);d?$e.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);d?Xe.push(()=>t(u)):t(u)}}var Qe,ft,Fe,$e,Xe,pt,ye=he(()=>{"use strict";Qe=0,ft=!1,Fe=[],$e=[],Xe=[],pt=[]});function ne(){return Math.trunc(performance.now()*1e6)}function re(){return Date.now()*1e6}var Le=he(()=>{"use strict"});var Ke,w,G,M,ve,me,Te,K,x,N,Ze,sn,Eo,an,So,Oo,un,Xn,Zn,er,dn,X=he(()=>{"use strict";Ke=Symbol.for("graphrefly/START"),w=Symbol.for("graphrefly/DATA"),G=Symbol.for("graphrefly/DIRTY"),M=Symbol.for("graphrefly/RESOLVED"),ve=Symbol.for("graphrefly/INVALIDATE"),me=Symbol.for("graphrefly/PAUSE"),Te=Symbol.for("graphrefly/RESUME"),K=Symbol.for("graphrefly/TEARDOWN"),x=Symbol.for("graphrefly/COMPLETE"),N=Symbol.for("graphrefly/ERROR"),Ze=Object.freeze([G]),sn=Object.freeze([M]),Eo=Object.freeze([ve]),an=Object.freeze([Ke]),So=Object.freeze([x]),Oo=Object.freeze([K]),un=Object.freeze([Ze]),Xn=Object.freeze([sn]),Zn=Object.freeze([Eo]),er=Object.freeze([So]),dn=Object.freeze([Oo])});function nr(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let s=2+n.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=cn,o[i++]=n.length,o.set(n,i),i+=n.length,o[i++]=r>>>8&255,o[i++]=r&255,o.set(e,i),o}function rr(t,e){if(t.length<tr)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${tr})`);let n=0,r=t[n++];if(r!==cn)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${cn})`);let s=t[n++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+s+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+s+2} bytes, have ${t.length})`);let o=new TextDecoder().decode(t.subarray(n,n+s));n+=s;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),d=e.lookupCodec(o);if(d==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:d,codecVersion:i,payload:a}}function or(t){t.registerCodec(Ro)}var Ro,cn,tr,ln=he(()=>{"use strict";Ro={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}},cn=1,tr=4});function Et(t){if(t==null)return et;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var et,fn=he(()=>{"use strict";et={type:"system",id:""}});function sr(t){t.registerMessageType(Ke,{tier:0,wireCrossing:!1}),t.registerMessageType(G,{tier:1,wireCrossing:!1}),t.registerMessageType(ve,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(me,{tier:2,wireCrossing:!1}),t.registerMessageType(Te,{tier:2,wireCrossing:!1}),t.registerMessageType(w,{tier:3,wireCrossing:!0}),t.registerMessageType(M,{tier:3,wireCrossing:!0}),t.registerMessageType(x,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(N,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(K,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var St,ir=he(()=>{"use strict";X();St=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function pn(t){let e=Mo.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var Ne,Mo,Ot=he(()=>{"use strict";Ne=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}},Mo=["human","llm","wallet","system"]});function hn(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(hn);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=hn(t[n]);return e}return null}function Do(t){let e=Co.encode(t),n=e.length,r=n*8,s=n+9+63&-64,o=new Uint8Array(s);o.set(e),o[n]=128;let i=new DataView(o.buffer);i.setUint32(s-4,r>>>0,!1),i.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,d=3144134277,u=1013904242,c=2773480762,f=1359893119,p=2600822924,h=528734635,l=1541459225,m=new Uint32Array(64),g=(y,v)=>y>>>v|y<<32-v;for(let y=0;y<s;y+=64){for(let D=0;D<16;D++)m[D]=i.getUint32(y+D*4,!1);for(let D=16;D<64;D++){let L=m[D-15],O=m[D-2],$=g(L,7)^g(L,18)^L>>>3,ee=g(O,17)^g(O,19)^O>>>10;m[D]=m[D-16]+$+m[D-7]+ee>>>0}let v=a,T=d,k=u,_=c,E=f,S=p,A=h,I=l;for(let D=0;D<64;D++){let L=g(E,6)^g(E,11)^g(E,25),O=E&S^~E&A,$=I+L+O+Ao[D]+m[D]>>>0,ee=g(v,2)^g(v,13)^g(v,22),z=v&T^v&k^T&k,te=ee+z>>>0;I=A,A=S,S=E,E=_+$>>>0,_=k,k=T,T=v,v=$+te>>>0}a=a+v>>>0,d=d+T>>>0,u=u+k>>>0,c=c+_>>>0,f=f+E>>>0,p=p+S>>>0,h=h+A>>>0,l=l+I>>>0}let b=y=>y.toString(16).padStart(8,"0");return b(a)+b(d)+b(u)+b(c)+b(f)+b(p)+b(h)+b(l)}function mn(t){let e=hn(t??null),n=JSON.stringify(e);return Do(n).slice(0,16)}function Po(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function gn(t,e,n){let r=n?.id??Po();if(t===0)return{id:r,version:0};let o=(n?.hash??mn)(e);return{id:r,version:0,cid:o,prev:null}}function ar(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Ao,Co,ur=he(()=>{"use strict";Ao=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]),Co=new TextEncoder});function lr(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function bn(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Rt(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function B(t,e,n){let r=fr(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,o={};return fr(t)?o=(yn(e)?e:n)??{}:yn(t)?o=t:o=(yn(e)?e:n)??{},new oe(r,s,o)}var dr,cr,Io,Lo,le,oe,fr,yn,we=he(()=>{"use strict";ln();fn();ye();Le();ir();Ot();X();ur();dr=()=>{},cr=100;Io=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},Lo=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[an]:[an,[w,o]];s._status==="dirty"&&i.push(Ze),Nt(e,i,s._config.tierOf)},le=new St({onMessage:Io,onSubscribe:Lo});sr(le);or(le);oe=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??le,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??mn;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?gn(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(lr);let o={};for(let[a,d]of Object.entries(r.meta??{})){let u={initial:d,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),o[a]=new t([],void 0,u)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[w,a]])},down(a){i._emit(Rt(a))},up(a){i._emitUp(Rt(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let s=n?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,d=i?.version??0,u=gn(e,o,{id:a,hash:s});u.version=d,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=Et(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let s=Et(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new Ne({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new Ne({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:re()}}down(e,n){let r=Rt(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[w,e]])}up(e,n){if(this._deps.length===0)return;let r=Rt(e);if(r.length===0)return;this._checkGuard(n);let s=n??{internal:!0};this._validateUpTiers(r);for(let o of this._deps)o.node.up?.(r,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let s=n(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let d=Et(n);if(!this._guard(d,"observe"))throw new Ne({actor:d,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)bn(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let s=r,o=this._deps[r];o.unsub=dr,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,d=!1;for(let u of i)a(u[0])>=3&&(d=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:s},this._actions);d&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let s=0;s<n;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}bn(o)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let n=this._deps.length,r=lr(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(un),r.unsub=dr;try{r.unsub=e.subscribe(s=>{if(r.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[N,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[N,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let r of this._deps){if(r.unsub!=null){let s=r.unsub;r.unsub=null;try{s()}catch{}}bn(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],s=n[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(o)}if(s!==Ke){if(s===G){this._depDirtied(r);return}if(s===ve){this._depInvalidated(r),this._emit(Zn);return}if(s===me||s===Te){this._emit([n]);return}if(s===K){this._emit(dn);return}if(s===w)this._depSettledAsData(r,n[1]);else if(s===M)this._depSettledAsResolved(r);else if(s===x)this._depSettledAsTerminal(r,!0);else if(s===N)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===w||s===M)&&this._emit([n]),(s===x||s===N)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(un))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Xn),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[N,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(er)}_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 n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[N,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>cr?(this._rerunDepth=0,this._emit([[N,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${cr} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[Ze,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let d of e){let u=n(d[0]);u<i&&(r=!1),u===3&&(s=!0),d[0]===G&&(o=!0),i=u}let a=e;if(!r){let d=e.map((u,c)=>({m:u,i:c,tier:n(u[0])}));d.sort((u,c)=>u.tier-c.tier||u.i-c.i),a=d.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let d=0;for(;d<a.length&&n(a[d][0])===0;)d++;return d===0?[Ze,...a]:[...a.slice(0,d),Ze,...a.slice(d)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let d=e[a];if(d[0]===N&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(d=>d[0]===K||d[0]===ve);if(a.length===0)return;n=a}n=this._frameBatch(n);let s=null;for(let a=0;a<n.length;a++){let d=n[a],u=d[0];if(u!==me&&u!==Te){s?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===me?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let f=d[1];if(u===me)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))c=!1;else if(this._pauseLocks.delete(f),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?s?.push(d):s==null&&(s=n.slice(0,a))}if(s!=null){if(s.length===0)return;n=s}if(this._hasMeta&&n.some(a=>a[0]===K))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(dn)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(n);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,d=[];for(let u of o)a(u[0])===3?this._pauseBuffer.push(u):d.push(u);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[N,i]])}_updateState(e){let n=this._config.tierOf,r,s,o=-1,i=0;for(let c of e)n(c[0])===3&&i++;let a=i<=1,d=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===w){d=c;break}}for(let c=0;c<e.length;c++){let f=e[c],p=f[0];if(p===w){if(f.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,f[1])}catch(l){s=this._wrapFnError("equals threw",l),o=c;break}if(h){r==null&&(r=e.slice(0,c)),r.push(sn),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(d<0||c===d)&&ar(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),p===G)this._status="dirty";else if(p===M)this._status="resolved";else if(p===x)this._status="completed";else if(p===N)this._status="errored";else if(p===ve){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 p===K&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:u,equalsError:s}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(Qn()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ht(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}Nt(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);Nt(this._deliverToSinks,n,this._config.tierOf)}},fr=t=>Array.isArray(t),yn=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function F(t,e){return B([],{...e,initial:t})}function R(t,e){return B((r,s,o)=>t(s,o)??void 0,{describeKind:"producer",...e})}function xe(t,e,n){return B(t,(s,o,i)=>{let a=s.map((d,u)=>d!=null&&d.length>0?d.at(-1):i.prevData[u]);o.emit(e(a,i))},{describeKind:"derived",...n})}function Mt(t,e,n){return B(t,(s,o,i)=>{let a=s.map((d,u)=>d!=null&&d.length>0?d.at(-1):i.prevData[u]);return e(a,o,i)??void 0},{describeKind:"effect",...n})}var ue=he(()=>{"use strict";we()});var hr={};on(hr,{NS_PER_MS:()=>fe,NS_PER_SEC:()=>Ae,constant:()=>vn,decorrelatedJitter:()=>kn,exponential:()=>wn,fibonacci:()=>xn,linear:()=>Tn,resolveBackoffPreset:()=>je,withMaxAttempts:()=>pr});function ze(t){return t<0?0:t}function Bo(t,e){return e==="none"?t:e==="full"?Math.random()*t:t/2+Math.random()*(t/2)}function Vo(t,e){return t+Math.random()*(e-t)}function vn(t){let e=ze(t);return()=>e}function Tn(t,e){let n=ze(t),r=e===void 0?n:ze(e);return s=>n+r*Math.max(0,s)}function wn(t){let e=ze(t?.baseNs??1e8),n=t?.factor!==void 0&&t.factor<1?1:t?.factor??2,r=ze(t?.maxDelayNs??30*1e9),s=t?.jitter??"none";return o=>{let i;if(e===0)i=0;else if(n===1)i=e;else{let a=r/e,d=1;for(let u=0;u<Math.max(0,o);u++){if(d>=a){d=a;break}d*=n}i=e*d,i>r&&(i=r)}return Bo(i,s)}}function xn(t=100*1e6,e=30*1e9){let n=ze(t),r=ze(e);function s(o){if(o<=0)return 1;let i=1,a=2;for(let d=1;d<o;d++){let u=i+a;i=a,a=u}return a}return o=>{let i=s(o)*n;return i<=r?i:r}}function kn(t=100*1e6,e=30*1e9){return(n,r,s)=>{let i=Math.min(e,(s??t)*3);return Vo(t,i)}}function pr(t,e){return(n,r,s)=>n>=e?null:t(n,r,s)}function je(t){if(t==="constant")return vn(1*1e9);if(t==="linear")return Tn(1*1e9);if(t==="exponential")return wn();if(t==="fibonacci")return xn();if(t==="decorrelatedJitter")return kn();throw new Error(`Unknown backoff preset: "${String(t)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var fe,Ae,mt=he(()=>{"use strict";fe=1e6,Ae=1e9});function gt(t,e,n){let r=new Set;for(let s of t.split(",")){let[o,i]=s.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${s}`);let d,u;if(o==="*")d=e,u=n;else if(o.includes("-")){let[c,f]=o.split("-");d=Number.parseInt(c,10),u=Number.parseInt(f,10)}else d=Number.parseInt(o,10),u=d;if(Number.isNaN(d)||Number.isNaN(u))throw new Error(`Invalid cron field: ${t}`);if(d<e||u>n)throw new Error(`Cron field out of range: ${t} (${e}-${n})`);if(d>u)throw new Error(`Invalid cron range: ${d}-${u} in ${t}`);for(let c=d;c<=u;c+=a)r.add(c)}return r}function Nn(t){let e=t.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:gt(e[0],0,59),hours:gt(e[1],0,23),daysOfMonth:gt(e[2],1,31),months:gt(e[3],1,12),daysOfWeek:gt(e[4],0,6)}}function En(t,e){return t.minutes.has(e.getMinutes())&&t.hours.has(e.getHours())&&t.daysOfMonth.has(e.getDate())&&t.months.has(e.getMonth()+1)&&t.daysOfWeek.has(e.getDay())}var Sn=he(()=>{"use strict"});var Oe,At=he(()=>{"use strict";Oe=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var br={};on(br,{CircuitOpenError:()=>nt,RateLimiterOverflowError:()=>rt,TimeoutError:()=>ot,circuitBreaker:()=>Rn,fallback:()=>Cn,rateLimiter:()=>An,retry:()=>On,retrySource:()=>bt,timeout:()=>Dn,tokenBucket:()=>Dt,withBreaker:()=>Mn,withStatus:()=>yt});function We(t){return{describeKind:"derived",...t}}function Go(t){return t<0?0:t}function Ct(t){return t[1]}function gr(t){if(typeof t!="number"||!Number.isFinite(t))throw new TypeError("backoff strategy must return a finite number");return t<0?0:t}function On(t,e){let n=e?.count,r=e?.backoff,s=n!==void 0?n:r===void 0?0:2147483647;if(s<0)throw new RangeError("retry count must be >= 0");let o=r===void 0?null:typeof r=="string"?je(r):r;return R(i=>{let a=0,d=!1,u=null,c,f=new Oe;function p(){c?.(),c=void 0}function h(m){if(d)return;if(a>=s){p(),i.down([[N,m]]);return}let g=o===null?0:o(a,m,u);if(g==null){p(),i.down([[N,m]]);return}let b;try{b=gr(g)}catch{p(),i.down([[N,m]]);return}u=b,a+=1,p();let y=b>0?b/1e6:1;f.start(y,()=>{d||l()})}function l(){f.cancel(),p(),c=t.subscribe(m=>{if(!d)for(let g of m){let b=g[0];if(b===G)i.down([[G]]);else if(b===w)a=0,u=null,i.emit(g[1]);else if(b===M)i.down([[M]]);else if(b===x)p(),i.down([[x]]);else if(b===N){h(Ct(g));return}else i.down([g])}})}return l(),()=>{d=!0,f.cancel(),p()}},{...We(),initial:t.cache})}function bt(t,e){let n=e?.count,r=e?.backoff,s=n!==void 0?n:r===void 0?0:2147483647;if(s<0)throw new RangeError("retry count must be >= 0");let o=r===void 0?null:typeof r=="string"?je(r):r;return R(i=>{let a=0,d=!1,u=null,c,f=new Oe;function p(){c?.(),c=void 0}function h(m){if(d)return;if(a>=s){p(),i.down([[N,m]]);return}let g=o===null?0:o(a,m,u);if(g==null){p(),i.down([[N,m]]);return}let b;try{b=gr(g)}catch{p(),i.down([[N,m]]);return}u=b,a+=1,p();let y=b>0?b/1e6:1;f.start(y,()=>{d||l()})}function l(){f.cancel(),p();let m;try{m=t()}catch(g){h(g);return}c=m.subscribe(g=>{if(!d)for(let b of g){let y=b[0];if(y===G)i.down([[G]]);else if(y===w)a=0,u=null,i.emit(b[1]);else if(y===M)i.down([[M]]);else if(y===x)p(),i.down([[x]]);else if(y===N){h(Ct(b));return}else i.down([b])}})}return l(),()=>{d=!0,f.cancel(),p()}},{...We(),initial:e?.initial})}function Rn(t){let e=Math.max(1,t?.failureThreshold??5),n=Go(t?.cooldownNs??30*1e9),r=t?.cooldown??null,s=Math.max(1,t?.halfOpenMax??1),o=t?.now??ne,i="closed",a=0,d=0,u=0,c=n,f=0;function p(){if(!r)return n;let m=r(d);return m!==null?m:n}function h(){i="open",c=p(),u=o(),f=0}return{canExecute(){return i==="closed"?!0:i==="open"?o()-u>=c?(i="half-open",f=1,!0):!1:f<s?(f++,!0):!1},recordSuccess(){i==="half-open"?(i="closed",a=0,d=0):i==="closed"&&(a=0)},recordFailure(m){if(i==="half-open"){d++,h();return}i==="closed"&&(a++,a>=e&&h())},get state(){return i},get failureCount(){return a},reset(){i="closed",a=0,d=0,f=0}}}function Mn(t,e){let n=e?.onOpen??"skip";return r=>{let s=B([],(o,i)=>{function a(){s.meta.breakerState.down([[w,t.state]])}let d=r.subscribe(u=>{for(let c of u){let f=c[0];f===G?i.down([[G]]):f===w?t.canExecute()?(a(),i.emit(c[1])):(a(),n==="error"?i.down([[N,new nt]]):i.down([[M]])):f===M?i.down([[M]]):f===x?(t.recordSuccess(),a(),i.down([[x]])):f===N?(t.recordFailure(Ct(c)),a(),i.down([c])):i.down([c])}});return a(),d},{...We(),meta:{breakerState:t.state},completeWhenDepsComplete:!1,initial:r.cache});return{node:s,breakerState:s.meta.breakerState}}}function Dt(t,e){if(t<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let n=t,r=ne();function s(o){if(e>0){let i=o-r;n=Math.min(t,n+i/1e9*e)}r=o}return{available(){return s(ne()),n},tryConsume(o=1){if(o<=0)return!0;let i=ne();return s(i),n>=o?(n-=o,!0):!1},putBack(o=1){o<=0||(s(ne()),n=Math.min(t,n+o))}}}function An(t,e){let{maxEvents:n,windowNs:r}=e;if(n<=0)throw new RangeError("maxEvents must be > 0");if(r<=0)throw new RangeError("windowNs must be > 0");let s=e.maxBuffer;if(s!==void 0&&s<1)throw new RangeError("maxBuffer must be >= 1");let o=e.onOverflow??"drop-newest",i=n*1e9/r;return R(a=>{let d=Dt(n,i),u=[],c=new Oe,f=!1,p=1e9/i;function h(){for(;u.length>0;)if(d.tryConsume(1))a.emit(u.shift());else{c.start(Math.max(1,p/1e6),h);return}}let l=t.subscribe(m=>{for(let g of m){if(f)return;let b=g[0];if(b===G)a.down([[G]]);else if(b===w){if(s!==void 0&&u.length>=s){if(o!=="drop-newest")if(o==="drop-oldest")u.shift(),u.push(g[1]);else{f=!0,c.cancel(),u.length=0,a.down([[N,new rt(s)]]);return}}else u.push(g[1]);h()}else if(b===M)a.down([[M]]);else if(b===x)f=!0,c.cancel(),u.length=0,a.down([[x]]);else if(b===N)f=!0,c.cancel(),u.length=0,a.down([g]);else if(b===K){f=!0,c.cancel(),u.length=0,a.down([g]);return}else a.down([g])}});return()=>{f=!0,c.cancel(),l()}},{...We(),initial:t.cache})}function yt(t,e){let n=e?.initialStatus??"pending",r=B([],(s,o)=>{let i=n;return r.meta.status.down([[w,n]]),r.meta.error.down([[w,null]]),t.subscribe(d=>{for(let u of d){let c=u[0];if(c===G)o.down([[G]]);else if(c===w)i==="errored"?j(()=>{r.meta.error.down([[w,null]]),r.meta.status.down([[w,"active"]])}):r.meta.status.down([[w,"active"]]),i="active",o.emit(u[1]);else if(c===M)o.down([[M]]);else if(c===x)r.meta.status.down([[w,"completed"]]),i="completed",o.down([[x]]);else if(c===N){let f=Ct(u);j(()=>{r.meta.error.down([[w,f]]),r.meta.status.down([[w,"errored"]])}),i="errored",o.down([u])}else o.down([u])}})},{...We(),meta:{status:n,error:null},completeWhenDepsComplete:!1,resubscribable:!0,initial:t.cache});return{node:r,status:r.meta.status,error:r.meta.error}}function Fo(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function $o(t){return t!=null&&typeof t.then=="function"}function Ko(t){return t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function"}function Cn(t,e){return R(n=>{let r,s;function o(){s?.(),s=void 0,Fo(e)||$o(e)||Ko(e)?r=de(e).subscribe(a=>{n.down(a)}):(n.emit(e),n.down([[x]]))}return s=t.subscribe(i=>{for(let a of i){let d=a[0];if(d===G)n.down([[G]]);else if(d===w)n.emit(a[1]);else if(d===M)n.down([[M]]);else if(d===x)n.down([[x]]);else if(d===N){o();return}else if(d===K){r?.(),n.down([a]);return}else n.down([a])}}),()=>{s?.(),r?.()}},{...We(),initial:t.cache})}function Dn(t,e){if(e<=0)throw new RangeError("timeoutNs must be > 0");return R(n=>{let r=!1,s=new Oe;function o(){let a=e/1e6;s.start(a,()=>{r||(r=!0,i(),n.down([[N,new ot(e)]]))})}let i=t.subscribe(a=>{for(let d of a){if(r)return;let u=d[0];if(u===G)n.down([[G]]);else if(u===w)o(),n.emit(d[1]);else if(u===M)n.down([[M]]);else if(u===x){s.cancel(),r=!0,n.down([[x]]);return}else if(u===N){s.cancel(),r=!0,n.down([d]);return}else if(u===K){s.cancel(),r=!0,n.down([d]);return}else n.down([d])}});return o(),()=>{r=!0,s.cancel(),i()}},{...We(),initial:t.cache})}var nt,rt,ot,Pt=he(()=>{"use strict";ye();Le();X();we();ue();mt();Ie();At();nt=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};rt=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};ot=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});function Ee(t){return{describeKind:"producer",...t}}function vr(t){return/[\\^$+?.()|[\]{}]/.test(t)?`\\${t}`:t}function zo(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){t[n+1]==="*"?(e+=".*",n+=1):e+="[^/]*";continue}e+=vr(r)}return e+="$",new RegExp(e)}function jo(t,e){for(let n of e)if(n.test(t))return!0;return!1}function Wo(t,e){let n=B([t],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[M]]);return}for(let a of i)o.emit(a)},{describeKind:"derived",initial:t.cache}),r=n.subscribe.bind(n);return n.subscribe=(s,o)=>(e(s),r(s,o)),n}function He(t,e){let{signal:n,period:r,...s}=e??{};return R(o=>{let i=!1,a=0,d,u,c=()=>{i=!0,d!==void 0&&clearTimeout(d),u!==void 0&&clearInterval(u),n?.removeEventListener("abort",p)},f=()=>{i||(r!=null?(o.emit(a++),u=setInterval(()=>{i||o.emit(a++)},r)):(i=!0,n?.removeEventListener("abort",p),o.emit(a++),o.down([[x]])))},p=()=>{i||(c(),o.down([[N,n.reason]]))};if(n?.aborted){p();return}return d=setTimeout(f,t),n?.addEventListener("abort",p,{once:!0}),c},Ee(s))}function Ho(t){let{signal:e,...n}=t??{};return R(r=>{let s=!1,o,i,a=!1,d=!1,u=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,c=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,f=typeof document<"u"?document:void 0,p=()=>{o!==void 0&&c&&c(o),i!==void 0&&clearTimeout(i),o=void 0,i=void 0},h=()=>{s=!0,p(),a&&(e?.removeEventListener("abort",l),a=!1),d&&f&&(f.removeEventListener("visibilitychange",b),d=!1)},l=()=>{s||(h(),r.down([[N,e.reason]]))},m=y=>{s||(r.emit(y),g())},g=()=>{s||(u&&(!f||f.visibilityState!=="hidden")?o=u(m):i=setTimeout(()=>m(performance.now()),16))},b=()=>{s||(p(),g())};return e?.aborted?(l(),h):(e?.addEventListener("abort",l,{once:!0}),a=e!==void 0,f&&u&&(f.addEventListener("visibilitychange",b),d=!0),g(),h)},Ee(n))}function Uo(t,e){let n=Nn(t),{tickMs:r,output:s,...o}=e??{},i=r??6e4,a=s==="date";return R(d=>{let u=-1,c=()=>{let p=new Date,h=p.getFullYear()*1e8+(p.getMonth()+1)*1e6+p.getDate()*1e4+p.getHours()*100+p.getMinutes();h!==u&&En(n,p)&&(u=h,d.emit(a?p:re()))};c();let f=setInterval(c,i);return()=>clearInterval(f)},{...Ee(o),name:o.name??`cron:${t}`})}function qo(t,e,n){let{capture:r,passive:s,once:o,...i}=n??{};return R(a=>{let d=c=>{a.emit(c)},u={capture:r,passive:s,once:o};return t.addEventListener(e,d,u),()=>t.removeEventListener(e,d,u)},Ee(i))}function Ln(t,e){return R(n=>{let r=!1;try{for(let s of t){if(r)return;n.emit(s)}r||n.down([[x]])}catch(s){r||n.down([[N,s]])}return()=>{r=!0}},Ee(e))}function Jo(t){return t!=null&&typeof t.then=="function"}function Tr(t,e){let{signal:n,...r}=e??{};return R(s=>{let o=!1,i=()=>{o||(o=!0,s.down([[N,n.reason]]))};if(n?.aborted){i();return}return n?.addEventListener("abort",i,{once:!0}),Promise.resolve(t).then(a=>{o||(o=!0,n?.removeEventListener("abort",i),s.emit(a),s.down([[x]]))},a=>{o||(o=!0,n?.removeEventListener("abort",i),s.down([[N,a]]))}),()=>{o=!0,n?.removeEventListener("abort",i)}},Ee(r))}function wr(t,e){let{signal:n,...r}=e??{};return R(s=>{let o=new AbortController,i=()=>o.abort(n?.reason);n?.aborted?o.abort(n.reason):n?.addEventListener("abort",i,{once:!0});let a=n??o.signal,d=!1,u=t[Symbol.asyncIterator](),c=()=>{d||a.aborted||Promise.resolve(u.next()).then(f=>{if(!(d||a.aborted)){if(f.done){s.down([[x]]);return}s.emit(f.value),c()}},f=>{!d&&!a.aborted&&s.down([[N,f]])})};return c(),()=>{d=!0,n?.removeEventListener("abort",i),o.abort(),Promise.resolve(u.return?.()).catch(()=>{})}},Ee(r))}function Yo(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function de(t,e){if(Yo(t))return t;if(Jo(t))return Tr(t,e);if(t!=null){let n=t;if(typeof n[Symbol.asyncIterator]=="function")return wr(t,e);if(typeof n[Symbol.iterator]=="function")return Ln(t,e)}return xr(t)}function xr(...t){return Ln(t,void 0)}function Qo(t){return R(e=>{e.down([[x]])},Ee(t))}function Xo(t){return R(()=>{},Ee(t))}function Zo(t,e){return R(n=>{n.down([[N,t]])},Ee(e))}function Ue(t,e,n){return B([t],(s,o)=>{let i=s[0];if(i!=null&&i.length>0)for(let a of i)e(a)},{describeKind:"effect",...n}).subscribe(()=>{})}function es(t,e){return B([t],(n,r,s)=>{s.store.buf||(s.store.buf=[]);let o=s.store.buf,i=n[0];if(i!=null&&i.length>0)for(let a of i)o.push(a);if(s.terminalDeps[0]===!0){r.emit([...o]),r.down([[x]]);return}(i==null||i.length===0)&&r.down([[M]])},{describeKind:"derived",completeWhenDepsComplete:!1,...e})}function ts(t,e){return R(n=>t.subscribe(r=>{n.down(r)}),{...Ee(e),initial:t.cache})}function Bn(t,e,n){if(e<1)throw new RangeError("replay expects bufferSize >= 1");let r=[],s=R(o=>t.subscribe(i=>{for(let a of i)a[0]===w&&(r.push(a[1]),r.length>e&&r.shift());o.down(i)}),{...Ee(n),initial:t.cache});return Wo(s,o=>{for(let i of r)o([[w,i]])})}function ns(t,e){return Bn(t,1,e)}function Vn(t){return new Promise((e,n)=>{let r=!1,s=!1,o;o=t.subscribe(i=>{for(let a of i){if(r)return;if(a[0]===w){r=!0,e(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===N){r=!0,n(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===x){r=!0,n(new Error("completed without DATA")),o?(o(),o=void 0):s=!0;return}}}),s&&(o?.(),o=void 0)})}function In(t,e){return new Promise((n,r)=>{let s=!1,o=!1,i;i=t.subscribe(a=>{for(let d of a){if(s)return;if(d[0]===w){let u=d[1];if(e(u)){s=!0,n(u),i?(i(),i=void 0):o=!0;return}}if(d[0]===N){s=!0,r(d[1]),i?(i(),i=void 0):o=!0;return}if(d[0]===x){s=!0,r(new Error("completed without matching value")),i?(i(),i=void 0):o=!0;return}}}),o&&(i?.(),i=void 0)})}async function rs(t,e){let n=e?.predicate??(s=>s!=null);if(e?.timeoutMs==null||e.timeoutMs<=0)return await In(t,n);if(Pn===void 0){let[s,o]=await Promise.all([Promise.resolve().then(()=>(Pt(),br)),Promise.resolve().then(()=>(mt(),hr))]);Pn=s.timeout,yr=o.NS_PER_MS}let r=Pn(t,e.timeoutMs*yr);return await In(r,n)}function It(t){return t.subscribe(()=>{})}function ss(t){let e=F(0);return{node:e,increment(){let n=e.cache??0;return n>=t?!1:(e.down([[G],[w,n+1]]),!0)},get(){return e.cache??0},atCap(){return(e.cache??0)>=t}}}var Pn,yr,os,Ie=he(()=>{"use strict";Le();X();we();ue();Sn();os=Bn});var ru={};on(ru,{CircuitOpenError:()=>nt,NS_PER_MS:()=>fe,NS_PER_SEC:()=>Ae,NativeIndexBackend:()=>Kt,NativeListBackend:()=>zt,NativeLogBackend:()=>jt,NativeMapBackend:()=>Ft,NativePubSubBackend:()=>$t,RateLimiterOverflowError:()=>rt,ResettableTimer:()=>Oe,TimeoutError:()=>ot,audit:()=>Ns,awaitSettled:()=>rs,buffer:()=>Es,bufferCount:()=>Ss,bufferTime:()=>Rs,cached:()=>ns,cascadingCache:()=>Vi,catchError:()=>Gs,checkpointToRedis:()=>Ri,checkpointToS3:()=>Oi,circuitBreaker:()=>Rn,combine:()=>Nr,combineLatest:()=>Ls,concat:()=>ys,concatMap:()=>ws,constant:()=>vn,createTransport:()=>Ye,createWatermarkController:()=>Bi,csvRows:()=>li,debounce:()=>Sr,debounceTime:()=>Bs,decorrelatedJitter:()=>kn,delay:()=>ks,deserializeError:()=>lt,dictStorage:()=>ea,distill:()=>$i,distinctUntilChanged:()=>hs,elementAt:()=>fs,empty:()=>Qo,escapeRegexChar:()=>vr,exhaustMap:()=>Ts,exponential:()=>wn,externalBundle:()=>_n,externalProducer:()=>tt,fallback:()=>Cn,fibonacci:()=>xn,filter:()=>Bt,find:()=>ls,first:()=>Gn,firstValueFrom:()=>Vn,firstWhere:()=>In,flatMap:()=>xs,forEach:()=>Ue,fromAny:()=>de,fromAsyncIter:()=>wr,fromCSV:()=>ci,fromClickHouseWatch:()=>hi,fromCron:()=>Uo,fromDrizzle:()=>Pi,fromEvent:()=>qo,fromHTTP:()=>Ar,fromHTTPPoll:()=>qs,fromHTTPStream:()=>Us,fromIter:()=>Ln,fromKafka:()=>ii,fromKysely:()=>Ii,fromMCP:()=>Qs,fromNATS:()=>bi,fromNDJSON:()=>pi,fromOTel:()=>Xs,fromPrisma:()=>Di,fromPrometheus:()=>oi,fromPromise:()=>Tr,fromPulsar:()=>mi,fromRabbitMQ:()=>vi,fromRaf:()=>Ho,fromRedisStream:()=>ui,fromSSE:()=>Hs,fromSqlite:()=>Mi,fromSqliteCursor:()=>Ai,fromStatsD:()=>ti,fromSyslog:()=>Zs,fromTimer:()=>He,fromWebSocket:()=>Mr,fromWebSocketReconnect:()=>Ys,fromWebhook:()=>$s,globToRegExp:()=>zo,interval:()=>Cs,keepalive:()=>It,last:()=>cs,linear:()=>Tn,lru:()=>Br,map:()=>Lt,matchesAnyPattern:()=>jo,matchesCron:()=>En,memoryStorage:()=>Zi,merge:()=>vt,mergeMap:()=>Er,nameToSignal:()=>dt,ndjsonRows:()=>fi,never:()=>Xo,of:()=>xr,pairwise:()=>ms,parseCron:()=>Nn,parsePrometheusText:()=>Pr,parseStatsD:()=>ri,parseSyslog:()=>ei,pausable:()=>Ps,pubsub:()=>zi,race:()=>vs,rateLimiter:()=>An,reactiveCounter:()=>ss,reactiveIndex:()=>Hi,reactiveList:()=>Ui,reactiveLog:()=>Ji,reactiveMap:()=>Kn,reactiveSink:()=>ie,reduce:()=>as,repeat:()=>Ds,replay:()=>Bn,rescue:()=>Rr,resolveBackoffPreset:()=>je,retry:()=>On,retrySource:()=>bt,sample:()=>_s,scan:()=>is,serializeError:()=>ct,share:()=>ts,shareReplay:()=>os,signalToName:()=>Je,singleFromAny:()=>Yi,singleNodeFromAny:()=>Qi,skip:()=>_r,sortJsonValue:()=>Wt,stableJsonString:()=>Xi,stratify:()=>Qa,switchMap:()=>Ce,take:()=>Vt,takeUntil:()=>ds,takeWhile:()=>us,tap:()=>ps,throttle:()=>Or,throttleTime:()=>Vs,throwError:()=>Zo,timeout:()=>Dn,toArray:()=>es,toCSV:()=>wi,toClickHouse:()=>xi,toFile:()=>Lr,toHTTP:()=>Ks,toKafka:()=>ai,toLoki:()=>Ei,toMongo:()=>Ni,toNATS:()=>yi,toObservable:()=>Ki,toPostgres:()=>_i,toPulsar:()=>gi,toRabbitMQ:()=>Ti,toReadableStream:()=>Ws,toRedisStream:()=>di,toS3:()=>ki,toSSE:()=>zs,toSSEBytes:()=>js,toSqlite:()=>Ci,toTempo:()=>Si,toWebSocket:()=>Js,tokenBucket:()=>Dt,valve:()=>Is,verifiable:()=>Fi,window:()=>As,windowCount:()=>Os,windowTime:()=>Ms,withBreaker:()=>Mn,withLatestFrom:()=>gs,withMaxAttempts:()=>pr,withStatus:()=>yt,workerBridge:()=>go,workerSelf:()=>bo,zip:()=>bs});module.exports=_o(ru);ye();Le();X();we();ue();ye();X();ue();function mr(t){return{describeKind:"producer",...t}}function tt(t,e){return R(n=>{let r=!0,s={emit(i){r&&n.emit(i)},error(i){r&&(r=!1,n.down([[N,i]]))},complete(){r&&(r=!1,n.down([[x]]))}},o;try{let i=t(s);o=typeof i=="function"?i:void 0}catch(i){return s.error(i),()=>{r=!1}}return()=>{r=!1;try{o?.()}catch{}}},mr(e))}function _n(t,e,n){let r=!0,s,o=0,i=0,a={},d=[],u=()=>{let h=s;s=void 0;try{h?.()}catch{}};for(let h of e){let l=n?.name?`${n.name}::${h}`:h,m=n?.channelOpts?.[h],g=R(b=>(o++,()=>{i++,o>0&&i>=o&&i>=e.length&&u()}),mr({...m,name:l}));a[h]=g,d.push(g)}let c={};for(let h of e)c[h]=l=>{r&&a[h].down([[w,l]])};c.error=h=>{r&&(r=!1,j(()=>{for(let l of d)l.down([[N,h]])}),u())},c.complete=()=>{r&&(r=!1,j(()=>{for(let h of d)h.down([[x]])}),u())};let f=t(c);return s=typeof f=="function"?f:void 0,Object.assign(a,{dispose:()=>{r&&(r=!1,j(()=>{for(let h of d)try{h.down([[x]])}catch{}}),u())}})}Le();X();we();ue();Ie();function V(t){return{describeKind:"derived",...t}}function kr(t){return{describeKind:"derived",partial:!0,...t}}function Lt(t,e,n){return B([t],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[M]]);return}for(let i of o)s.emit(e(i))},V(n))}function Bt(t,e,n){return B([t],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[M]]);return}let i=!1;for(let a of o)e(a)&&(s.emit(a),i=!0);i||s.down([[M]])},V(n))}function is(t,e,n,r){return B([t],(s,o,i)=>{"acc"in i.store||(i.store.acc=n);let a=s[0];if(a==null||a.length===0){o.down([[M]]);return}for(let d of a)i.store.acc=e(i.store.acc,d),o.emit(i.store.acc)},{...V(r),initial:n,resetOnTeardown:!0})}function as(t,e,n,r){return B([t],(s,o,i)=>{if("acc"in i.store||(i.store.acc=n),i.terminalDeps[0]===!0){o.emit(i.store.acc),o.down([[x]]);return}let a=s[0];if(a==null||a.length===0){o.down([[M]]);return}for(let d of a)i.store.acc=e(i.store.acc,d)},{...V(r),completeWhenDepsComplete:!1})}function Vt(t,e,n){return e<=0?B([t],(r,s,o)=>{o.store.completed||(o.store.completed=!0,s.down([[x]]))},{...V(n),completeWhenDepsComplete:!1}):B([t],(r,s,o)=>{if("taken"in o.store||(o.store.taken=0),o.store.done){s.down([[M]]);return}if(o.terminalDeps[0]===!0){o.store.done=!0,s.down([[x]]);return}let i=r[0];if(i==null||i.length===0){s.down([[M]]);return}for(let a of i)if(o.store.taken++,s.emit(a),o.store.taken>=e){o.store.done=!0,s.down([[x]]);return}},{...V(n),completeWhenDepsComplete:!1})}function _r(t,e,n){return B([t],(r,s,o)=>{"skipped"in o.store||(o.store.skipped=0);let i=r[0];if(i==null||i.length===0){s.down([[M]]);return}let a=!1;for(let d of i)o.store.skipped++,o.store.skipped<=e||(s.emit(d),a=!0);a||s.down([[M]])},V(n))}function us(t,e,n){return B([t],(r,s,o)=>{if(o.store.done){s.down([[M]]);return}let i=r[0];if(i==null||i.length===0){s.down([[M]]);return}for(let a of i){if(!e(a)){o.store.done=!0,s.down([[x]]);return}s.emit(a)}},{...V(n),completeWhenDepsComplete:!1})}function ds(t,e,n){let r=n?.predicate??(i=>i[0]===w),{predicate:s,...o}=n??{};return R(i=>{let a=!1,d=t.subscribe(c=>{if(!a)for(let f of c){if(a)return;f[0]===w?i.emit(f[1]):(f[0]===x||f[0]===N)&&(a=!0,i.down([f]))}}),u=e.subscribe(c=>{if(!a)for(let f of c){if(a)return;if(r(f)){a=!0,i.down([[x]]);return}}});return()=>{d(),u()}},V(o))}function Gn(t,e){return Vt(t,1,e)}function cs(t,e){let{defaultValue:n,...r}=e??{},s=e!=null&&Object.hasOwn(e,"defaultValue");return B([t],(o,i,a)=>{if(a.terminalDeps[0]===!0){a.store.has?i.emit(a.store.latest):s&&i.emit(n),i.down([[x]]);return}let d=o[0];if(d==null||d.length===0){i.down([[M]]);return}a.store.latest=d.at(-1),a.store.has=!0},{...V(r),completeWhenDepsComplete:!1})}function ls(t,e,n){return Vt(Bt(t,e,n),1,n)}function fs(t,e,n){return Vt(_r(t,e,n),1,n)}function ps(t,e,n){if(typeof e=="function")return B([t],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[M]]);return}for(let a of i)e(a),o.emit(a)},V(n));let r=e;return B([t],(s,o,i)=>{if(i.terminalDeps[0]!==void 0){i.terminalDeps[0]===!0?(r.complete?.(),o.down([[x]])):(r.error?.(i.terminalDeps[0]),o.down([[N,i.terminalDeps[0]]]));return}let a=s[0];if(a==null||a.length===0){o.down([[M]]);return}for(let d of a)r.data?.(d),o.emit(d)},{...V(n),completeWhenDepsComplete:!1})}function hs(t,e=Object.is,n){return B([t],(r,s,o)=>{let i=r[0];if(i==null||i.length===0){s.down([[M]]);return}let a=!1;for(let d of i)o.store.hasPrev&&e(o.store.prev,d)||(o.store.prev=d,o.store.hasPrev=!0,s.emit(d),a=!0);a||s.down([[M]])},V(n))}function ms(t,e){return B([t],(n,r,s)=>{let o=n[0];if(o==null||o.length===0){r.down([[M]]);return}let i=!1;for(let a of o)if(!s.store.hasPrev)s.store.prev=a,s.store.hasPrev=!0;else{let d=[s.store.prev,a];s.store.prev=a,r.emit(d),i=!0}i||r.down([[M]])},V(e))}function Nr(...t){let e=[...t];return xe(e,n=>n,{...V(),equals:(n,r)=>{if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++)if(!Object.is(n[s],r[s]))return!1;return!0}})}function gs(t,e,n){return B([t,e],(r,s,o)=>{let i=r[0],a=r[1],d=a!=null&&a.length>0?a.at(-1):o.prevData[1];if(i!=null&&i.length>0){if(!(a!=null&&a.length>0)&&o.prevData[1]===void 0){s.down([[M]]);return}for(let u of i)s.emit([u,d])}else s.down([[M]])},kr(n))}function vt(...t){return t.length===0?R(e=>{e.down([[x]])},V()):R(e=>{let n=t.length,r=0,s=[];for(let o of t){let i=o.subscribe(a=>{for(let d of a)d[0]===w?e.emit(d[1]):d[0]===x?(r+=1,r>=n&&e.down([[x]])):d[0]===N&&e.down([d])});s.push(i)}return()=>{for(let o of s)o()}},V())}function bs(...t){let e=t.length;return e===0?R(n=>{n.emit([]),n.down([[x]])},V()):R(n=>{let r=Array.from({length:e},()=>[]),s=e;function o(){for(;r.every(a=>a.length>0);){let a=r.map(d=>d.shift());n.emit(a)}}let i=[];for(let a=0;a<e;a++){let d=a,u=t[a].subscribe(c=>{for(let f of c)f[0]===w?(r[d].push(f[1]),o()):f[0]===x?(s-=1,(s===0||r[d].length===0)&&n.down([[x]])):f[0]===N&&n.down([f])});i.push(u)}return()=>{for(let a of i)a()}},V())}function ys(t,e,n){return R(r=>{let s=0,o=[],i,a;return a=e.subscribe(d=>{for(let u of d)s===0?u[0]===w?o.push(u[1]):u[0]===N&&r.down([u]):u[0]===w?r.emit(u[1]):(u[0]===x||u[0]===N)&&r.down([u])}),i=t.subscribe(d=>{for(let u of d)if(s===0)if(u[0]===w)r.emit(u[1]);else if(u[0]===x){s=1;for(let c of o)r.emit(c);o.length=0}else u[0]===N&&r.down([u])}),()=>{i?.(),a?.()}},V(n))}function vs(...t){return t.length===0?R(e=>{e.down([[x]])},V()):t.length===1?B([t[0]],(e,n)=>{let r=e[0];if(r==null||r.length===0){n.down([[M]]);return}for(let s of r)n.emit(s)},V()):R(e=>{let n=null,r=[];for(let s=0;s<t.length;s++){let o=s,i=t[s].subscribe(a=>{for(let d of a){if(n!==null&&o!==n)return;d[0]===w?(n===null&&(n=o),e.emit(d[1])):(d[0]===x||d[0]===N)&&(n===null||o===n)&&e.down([d])}});r.push(i)}return()=>{for(let s of r)s()}},V())}function Gt(t,e,n){let r,s=!1,o=()=>{s||(s=!0,n())};return r=t.subscribe(i=>{let a=!1,d=!1;for(let u of i)u[0]!==Ke&&(u[0]===w?e.emit(u[1]):u[0]===x?a=!0:u[0]===N?(d=!0,e.down([u])):(u[0]===G||u[0]===M)&&e.down([u]));d?(r?.(),r=void 0,o()):a&&o()}),()=>{r?.(),r=void 0}}function Ce(t,e,n){let r,s=!1;function o(){r?.(),r=void 0}return B([t],(i,a,d)=>{if(d.terminalDeps[0]!=null&&d.terminalDeps[0]!==!0){o();return}if(d.terminalDeps[0]===!0){s=!0,r||a.down([[x]]);return}let u=i[0];if(!(u==null||u.length===0))return o(),r=Gt(de(e(u[u.length-1])),a,()=>{o(),s&&a.down([[x]])}),{deactivate:()=>{o(),s=!1}}},{...V(n),completeWhenDepsComplete:!1})}function Ts(t,e,n){let r,s=!1;function o(){r?.(),r=void 0}return B([t],(i,a,d)=>{if(d.terminalDeps[0]!=null&&d.terminalDeps[0]!==!0){o();return}if(d.terminalDeps[0]===!0){s=!0,r||a.down([[x]]);return}let u=i[0];if(!(u==null||u.length===0))return r===void 0?r=Gt(de(e(u[0])),a,()=>{o(),s&&a.down([[x]])}):a.down([[M]]),{deactivate:()=>{o(),s=!1}}},{...V(n),completeWhenDepsComplete:!1})}function ws(t,e,n){let{maxBuffer:r,...s}=n??{},o=[],i,a=!1,d;function u(){i?.(),i=void 0}function c(){if(!d||i!==void 0)return;if(o.length===0){a&&d.down([[x]]);return}let p=o.shift();i=Gt(de(e(p)),d,()=>{u(),c()})}function f(p){r&&r>0&&o.length>=r&&o.shift(),o.push(p),c()}return B([t],(p,h,l)=>{if(d=h,l.terminalDeps[0]!=null&&l.terminalDeps[0]!==!0){u(),o.length=0;return}if(l.terminalDeps[0]===!0){a=!0,c();return}let m=p[0];if(!(m==null||m.length===0)){for(let g of m)f(g);return{deactivate:()=>{u(),o.length=0,a=!1}}}},{...V(s),completeWhenDepsComplete:!1})}function Er(t,e,n){let{concurrent:r,...s}=n??{},o=r!=null&&r>0?r:Number.POSITIVE_INFINITY,i=0,a=!1,d=new Set,u=[],c;function f(){a&&i===0&&u.length===0&&c&&c.down([[x]])}function p(g){if(!c)return;i++;let b;b=Gt(de(e(g)),c,()=>{b&&d.delete(b),i--,h(),f()}),d.add(b)}function h(){for(;u.length>0&&i<o;)p(u.shift())}function l(g){i<o?p(g):u.push(g)}function m(){for(let g of d)g();d.clear(),i=0,u.length=0}return B([t],(g,b,y)=>{if(c=b,y.terminalDeps[0]!=null&&y.terminalDeps[0]!==!0){m();return}if(y.terminalDeps[0]===!0){a=!0,f();return}let v=g[0];if(!(v==null||v.length===0)){for(let T of v)l(T);return{deactivate:()=>{m(),a=!1}}}},{...V(s),completeWhenDepsComplete:!1})}var xs=Er;function ks(t,e,n){return R(r=>{let s=new Set;function o(){for(let a of s)clearTimeout(a);s.clear()}let i=t.subscribe(a=>{for(let d of a)if(d[0]===w){let u=setTimeout(()=>{s.delete(u),r.emit(d[1])},e);s.add(u)}else if(d[0]===x){let u=setTimeout(()=>{s.delete(u),r.down([[x]])},e);s.add(u)}else d[0]===N&&(o(),r.down([d]))});return()=>{i(),o()}},V(n))}function Sr(t,e,n){return R(r=>{let s,o;function i(){s!==void 0&&(clearTimeout(s),s=void 0)}let a=t.subscribe(d=>{for(let u of d)u[0]===w?(i(),o=u[1],s=setTimeout(()=>{s=void 0,r.emit(o)},e)):u[0]===x?(s!==void 0&&(i(),r.emit(o)),r.down([[x]])):u[0]===N&&(i(),r.down([u]))});return()=>{a(),i()}},V(n))}function Or(t,e,n){let{leading:r,trailing:s,...o}=n??{},i=r!==!1,a=s===!0,d=e*1e6;return R(u=>{let c,f=-1/0,p,h=!1;function l(){c!==void 0&&(clearTimeout(c),c=void 0)}let m=t.subscribe(g=>{for(let b of g)if(b[0]===w){let y=b[1],v=ne();if(i&&v-f>=d)f=v,u.emit(y),l(),a&&(c=setTimeout(()=>{c=void 0,h&&(f=ne(),u.emit(p),h=!1)},e));else if(a&&(p=y,h=!0,c===void 0)){let T=(v-f)/1e6;c=setTimeout(()=>{c=void 0,h&&(f=ne(),u.emit(p),h=!1)},Math.max(0,e-T))}}else(b[0]===x||b[0]===N)&&(l(),u.down([b]))});return()=>{m(),l()}},V(o))}function _s(t,e,n){return R(r=>{let s,o=!1,i=!1,a=t.subscribe(u=>{if(!o)for(let c of u){if(o)return;c[0]===w?s={v:c[1]}:c[0]===N?(o=!0,r.down([c])):c[0]===x&&(i=!0,s=void 0)}}),d=e.subscribe(u=>{if(!o)for(let c of u){if(o)return;c[0]===w?s!==void 0&&!i&&r.emit(s.v):c[0]===N?(o=!0,r.down([c])):c[0]===x&&(o=!0,r.down([[x]]))}});return()=>{a(),d()}},V(n))}function Ns(t,e,n){return R(r=>{let s,o,i=!1;function a(){s!==void 0&&(clearTimeout(s),s=void 0)}let d=t.subscribe(u=>{for(let c of u)c[0]===w?(o=c[1],i=!0,a(),s=setTimeout(()=>{s=void 0,i&&(i=!1,r.emit(o))},e)):(c[0]===x||c[0]===N)&&(a(),r.down([c]))});return()=>{d(),a()}},V(n))}function Es(t,e,n){return R(r=>{let s=[],o=t.subscribe(a=>{for(let d of a)d[0]===w?s.push(d[1]):d[0]===x?(s.length>0&&r.emit([...s]),s.length=0,r.down([[x]])):d[0]===N&&r.down([d])}),i=e.subscribe(a=>{for(let d of a)d[0]===w?s.length>0&&(r.emit([...s]),s.length=0):d[0]===x?r.down([[x]]):d[0]===N&&r.down([d])});return()=>{o(),i(),s.length=0}},V(n))}function Ss(t,e,n){if(e<=0)throw new RangeError("bufferCount expects count > 0");return R(r=>{let s=[],o=t.subscribe(i=>{for(let a of i)a[0]===w?(s.push(a[1]),s.length>=e&&r.emit(s.splice(0,s.length))):a[0]===x?(s.length>0&&r.emit([...s]),s.length=0,r.down([[x]])):a[0]===N&&r.down([a])});return()=>{o(),s.length=0}},V(n))}function Os(t,e,n){if(e<=0)throw new RangeError("windowCount expects count > 0");return R(r=>{let s,o=0;function i(){let d=R(u=>(s=u.down.bind(u),()=>{s=void 0}),V());o=0,r.emit(d)}let a=t.subscribe(d=>{for(let u of d)u[0]===w?(s||i(),s?.([[w,u[1]]]),o+=1,o>=e&&(s?.([[x]]),s=void 0)):u[0]===x?(s?.([[x]]),s=void 0,r.down([[x]])):u[0]===N&&(s?.([u]),s=void 0,r.down([u]))});return()=>{a(),s?.([[x]]),s=void 0}},V(n))}function Rs(t,e,n){return R(r=>{let s=[],o=setInterval(()=>{s.length>0&&(r.emit([...s]),s.length=0)},e),i=t.subscribe(a=>{for(let d of a)d[0]===w?s.push(d[1]):d[0]===x?(clearInterval(o),s.length>0&&r.emit([...s]),s.length=0,r.down([[x]])):d[0]===N&&(clearInterval(o),r.down([d]))});return()=>{i(),clearInterval(o),s.length=0}},V(n))}function Ms(t,e,n){return R(r=>{let s;function o(){s?.([[x]]),s=void 0}function i(){let u=R(c=>(s=c.down.bind(c),()=>{s=void 0}),V());r.emit(u)}i();let a=setInterval(()=>{o(),i()},e),d=t.subscribe(u=>{for(let c of u)c[0]===w?s?.([[w,c[1]]]):c[0]===x?(clearInterval(a),o(),r.down([[x]])):c[0]===N&&(clearInterval(a),s?.([c]),o(),r.down([c]))});return()=>{d(),clearInterval(a),o()}},V(n))}function As(t,e,n){return R(r=>{let s;function o(){s?.([[x]]),s=void 0}function i(){let u=R(c=>(s=c.down.bind(c),()=>{s=void 0}),V());r.emit(u)}let a=t.subscribe(u=>{for(let c of u)c[0]===w?(s||i(),s?.([[w,c[1]]])):c[0]===x?(o(),r.down([[x]])):c[0]===N&&(s?.([c]),s=void 0,r.down([c]))}),d=e.subscribe(u=>{for(let c of u)c[0]===w&&(o(),i())});return()=>{a(),d(),o()}},V(n))}function Cs(t,e){return R((n,r)=>{"n"in r.store||(r.store.n=0);let s=setInterval(()=>{n.emit(r.store.n),r.store.n=r.store.n+1},t);return()=>clearInterval(s)},V(e))}function Ds(t,e,n){if(e<=0)throw new RangeError("repeat expects count > 0");return R(r=>{let s=e,o,i=()=>{o?.(),o=t.subscribe(a=>{let d=!1,u=[];for(let c of a)c[0]===x?d=!0:u.push(c);u.length>0&&r.down(u),d&&(o?.(),o=void 0,s-=1,s>0?i():r.down([[x]]))})};return i(),()=>{o?.()}},V(n))}function Ps(t,e){return B([t],(n,r)=>{let s=n[0];if(s==null||s.length===0){r.down([[M]]);return}for(let o of s)r.emit(o)},V(e))}function Rr(t,e,n){return R(r=>{let s=t.subscribe(o=>{for(let i of o)if(i[0]===w)r.emit(i[1]);else if(i[0]===N)try{r.emit(e(i[1]))}catch(a){r.down([[N,a]])}else i[0]===x&&r.down([[x]])});return()=>{s()}},V(n))}function Is(t,e,n){return B([t,e],(r,s,o)=>{let i=r[1];if(!(i!=null&&i.length>0?i.at(-1):o.prevData[1])){s.down([[M]]);return}let d=r[0];if(d!=null&&d.length>0){for(let u of d)s.emit(u);return}if(i!=null&&i.length>0&&o.prevData[0]!==void 0){s.emit(o.prevData[0]);return}s.down([[M]])},kr(n))}var Ls=Nr,Bs=Sr,Vs=Or,Gs=Rr;X();we();ue();mt();var qe=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let n=(this.head+this._size)%this.capacity;this.buf[n]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let n=e<0?this._size+e:e;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this.buf[(this.head+n)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};var Fn=class{ring;arr;constructor(e){e===Number.POSITIVE_INFINITY||e<=0?(this.arr=[],this.ring=null):(this.ring=new qe(e),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(e){this.ring!=null?this.ring.push(e):this.arr.push(e)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let n=this.ring.toArray();return this.ring.clear(),n}let e=this.arr;return this.arr=[],e}};function Tt(t){return t instanceof Error?t:new Error(String(t))}function Fs(t){return t===void 0?null:typeof t=="string"?je(t):t}function ie(t,e){let{name:n,onTransportError:r,retry:s,backpressure:o,batchSize:i=Number.POSITIVE_INFINITY,flushIntervalMs:a=0,serialize:d,stopOn:u,onUpstreamMessage:c,onDispose:f,send:p,sendBatch:h,ctx:l}=e;if(!p&&!h)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let m=l,g=Math.max(1,s?.maxAttempts??1),b=Fs(s?.backoff??(g>1?"exponential":void 0)),y=s?.shouldRetry??(()=>!0),v=h!==void 0||i<Number.POSITIVE_INFINITY||a>0,T=C=>n?`${n}::${C}`:void 0,k=F(void 0,{equals:()=>!1,name:T("sent")}),_=F(null,{name:T("failed")}),E=F(0,{name:T("inFlight")}),S=F(null,{name:T("errors")}),A=v?F(0,{name:T("buffered")}):void 0,I=o?F(!1,{name:T("paused")}):void 0,D=0,L=C=>{D+=C,E.down([[w,D]])},O=C=>{try{r?.(C)}catch{}try{S.down([[w,C]])}catch{}},$=new Set,ee=C=>{$.add(C);let W=()=>$.delete(C);C.then(W,W)},z=(C,W,J)=>{let Q=b?b(W-1,J,null):0,ae=Q==null?0:typeof Q=="number"&&Q>0?Q:0,Se=Math.max(1,Math.ceil(ae/1e6));return new Promise(Y=>{setTimeout(()=>Y(C()),Se)})},te=C=>C!=null&&typeof C=="object"&&typeof C.then=="function",ke=C=>{let W;try{W=d?d(C):C}catch(Y){let H=Tt(Y);return O({stage:"serialize",error:H,value:C}),_.down([[w,{value:C,error:H,attempts:0}]]),Promise.resolve()}let J=0,Q=Y=>{L(-1);let H=Tt(Y);if(O({stage:"send",error:H,value:C,attempt:J}),!(J<g&&y(H,J))){_.down([[w,{value:C,error:H,attempts:J}]]);return}return z(Se,J,H)},ae=()=>{L(-1),k.down([[w,C]])};function Se(){J+=1,L(1);let Y;try{Y=p(W,m)}catch(H){return Q(H)??Promise.resolve()}return te(Y)?Y.then(ae,H=>Q(H)):(ae(),Promise.resolve())}return Se()},De=o?.maxBuffer??Number.POSITIVE_INFINITY,_e=new Fn(De),ge,Ve=!1,P=()=>{A?.down([[w,_e.length]])},q=C=>{I&&I.down([[w,C]])},pe=o?.strategy??"drop-oldest",Ge=(C,W)=>{let J={value:C,payload:W};if(_e.length<De)return _e.push(J),P(),!0;if(pe==="drop-oldest"){let ae=_e.shift();return _e.push(J),P(),q(!0),_.down([[w,{value:ae.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(pe==="drop-newest")return q(!0),_.down([[w,{value:C,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let Q=new Error("backpressure: buffer overflow");return O({stage:"send",error:Q,value:C}),_.down([[w,{value:C,error:Q,attempts:0}]]),q(!0),!1},be=C=>{let W=0,J=C.map(Y=>Y.payload),Q=Y=>{L(-1);let H=Tt(Y);if(O({stage:"send",error:H,value:C.map(nn=>nn.value),attempt:W}),!(W<g&&y(H,W))){for(let{value:nn}of C)_.down([[w,{value:nn,error:H,attempts:W}]]);return}return z(Se,W,H)},ae=()=>{L(-1);for(let{value:Y}of C)k.down([[w,Y]])};function Se(){W+=1,L(1);let Y;try{Y=h(J,m)}catch(H){return Q(H)??Promise.resolve()}return te(Y)?Y.then(ae,H=>Q(H)):(ae(),Promise.resolve())}return Se()},U=async C=>{for(let W of C)await ce(W.value,W.payload)},ce=(C,W)=>{let J=0,Q=Y=>{L(-1);let H=Tt(Y);if(O({stage:"send",error:H,value:C,attempt:J}),!(J<g&&y(H,J))){_.down([[w,{value:C,error:H,attempts:J}]]);return}return z(Se,J,H)},ae=()=>{L(-1),k.down([[w,C]])};function Se(){J+=1,L(1);let Y;try{Y=p(W,m)}catch(H){return Q(H)??Promise.resolve()}return te(Y)?Y.then(ae,H=>Q(H)):(ae(),Promise.resolve())}return Se()},Pe=()=>{if(Ve||_e.length===0)return Promise.resolve();let C=_e.drain();if(P(),q(!1),h!==void 0){let J=be(C);return ee(J),J}let W=U(C);return ee(W),W},yo=()=>{ge!==void 0||Ve||a<=0||(ge=setTimeout(()=>{ge=void 0,Pe()},a))},vo=t.subscribe(C=>{for(let W of C){let J=W[0];if(J!==w)try{c?.(W)}catch{}if(J===w){let Q=W[1];if(v){let ae;if(d)try{ae=d(Q)}catch(Y){let H=Tt(Y);O({stage:"serialize",error:H,value:Q}),_.down([[w,{value:Q,error:H,attempts:0}]]);continue}else ae=Q;if(!Ge(Q,ae))continue;_e.length>=i?Pe():yo()}else{let ae=ke(Q);ee(ae)}}else le.messageTier(J)>=3&&v&&(ge!==void 0&&(clearTimeout(ge),ge=void 0),Pe())}}),qn;if(u){let C=!1;qn=u.subscribe(W=>{if(!C){C=!0;return}W.length>0&&!tn&&Jn()})}let tn=!1,Jn=()=>{if(tn)return;tn=!0,ge!==void 0&&(clearTimeout(ge),ge=void 0),v&&Pe(),Ve=!0,qn?.(),vo();let C=W=>{try{W.down([[K]])}catch{}};C(S),C(_),C(k),C(E),A&&C(A),I&&C(I);try{f?.()}catch{}},kt={dispose:Jn,sent:k,failed:_,inFlight:E,errors:S};return v&&(kt.buffered=A,kt.flush=async()=>{Ve||(await Pe(),await Promise.all($))}),I&&(kt.paused=I),kt}Pt();Ie();function Re(t){return{describeKind:"producer",...t}}function Mr(t,e){let{parse:n,closeOnTeardown:r=!1,...s}=e??{};return R(o=>{let i=!0,a,d=()=>{let b=a;a=void 0,b?.()},u=b=>{i&&(i=!1,o.down([b]),d())},c=(b,y=b)=>{if(i)try{let v=b!==null&&typeof b=="object"&&"data"in b?b.data:b,T=n?n(v,y):v;o.emit(T)}catch(v){u([N,v])}},f=b=>{u([N,b])},p=()=>{u([x])};if(typeof t=="function"){try{if(a=t(c,f,p),typeof a!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(b){u([N,b])}return()=>{i=!1,d()}}let h=t,l=b=>c(b,b),m=b=>f(b),g=()=>p();return h.addEventListener("message",l),h.addEventListener("error",m),h.addEventListener("close",g),a=()=>{h.removeEventListener("message",l),h.removeEventListener("error",m),h.removeEventListener("close",g),r&&h.close()},()=>{i=!1,d()}},Re(s))}function $s(t,e){return tt(t,e)}function Ar(t,e){let{method:n="GET",headers:r,body:s,transform:o=v=>v.json(),timeoutNs:i=30*1e9,signal:a,completeAfterFetch:d=!1,refetchOnSubscribe:u=!1,...c}=e??{},f=F(0,{name:`${c.name??"http"}/fetchCount`}),p=F(0,{name:`${c.name??"http"}/lastUpdated`}),h=F(!1,{name:`${c.name??"http"}/fetched`}),l=0,m=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0,g=v=>{let T=new AbortController,k=!0;if(a?.aborted)return k=!1,v.down([[N,a.reason??new Error("Aborted")]]),()=>{};a?.addEventListener("abort",()=>T.abort(a.reason),{once:!0});let _=setTimeout(()=>T.abort(new Error("Request timeout")),Math.ceil(i/1e6));return fetch(t,{method:n,headers:r,body:m,signal:T.signal}).then(async E=>{if(clearTimeout(_),!k)return;if(!E.ok)throw new Error(`HTTP ${E.status}: ${E.statusText}`);let S=await o(E);k&&(j(()=>{l+=1,f.down([[w,l]]),p.down([[w,re()]]),h.down([[w,!0]]),v.emit(S)}),d&&v.down([[x]]))}).catch(E=>{clearTimeout(_),k&&(E&&E.name==="AbortError"||v.down([[N,E]]))}),()=>{k=!1,T.abort()}},b=R(v=>g({emit:T=>v.emit(T),down:T=>v.down(T)}),{...Re(c),resubscribable:u});return{...yt(b),fetchCount:f,lastUpdated:p,fetched:h}}function Ks(t,e,n){let{method:r="POST",headers:s={"Content-Type":"application/json"},serialize:o=l=>JSON.stringify(l),timeoutNs:i,batchFormat:a="json-array",batchSize:d,flushIntervalMs:u,retry:c,onTransportError:f}=n??{},p=async l=>{let m=i!==void 0?new AbortController:void 0,g;m&&i!==void 0&&(g=setTimeout(()=>m.abort(new Error("Request timeout")),Math.ceil(i/1e6)));try{let b=await fetch(e,{method:r,headers:s,body:l,signal:m?.signal}),y=async()=>{try{await b.arrayBuffer?.()}catch{}};if(!b.ok)throw await y(),new Error(`HTTP ${b.status}: ${b.statusText}`);await y()}finally{g!==void 0&&clearTimeout(g)}};return d!==void 0||u!==void 0?ie(t,{onTransportError:f,retry:c,batchSize:d,flushIntervalMs:u,sendBatch:async l=>{let m;a==="ndjson"?m=l.map(g=>{let b=o(g);return typeof b=="string"?b:new TextDecoder().decode(b)}).join(`
|
|
2
|
-
`):m=JSON.stringify(l),await
|
|
1
|
+
"use strict";var on=Object.defineProperty;var Eo=Object.getOwnPropertyDescriptor;var So=Object.getOwnPropertyNames;var Oo=Object.prototype.hasOwnProperty;var he=(t,e)=>()=>(t&&(e=t(t=0)),e);var sn=(t,e)=>{for(var n in e)on(t,n,{get:e[n],enumerable:!0})},Ro=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of So(e))!Oo.call(t,s)&&s!==n&&on(t,s,{get:()=>e[s],enumerable:!(r=Eo(e,s))||r.enumerable});return t};var Mo=t=>Ro(on({},"__esModule",{value:!0}),t);function _t(){return Qe>0||ft}function Xn(){return Qe>0}function ht(t){Qe>0?pt.push(t):t()}function j(t){Qe+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(Qe-=1,Qe===0)if(e){if(!ft){let n=pt.splice(0);for(let r of n)try{r()}catch{}Fe.length=0,$e.length=0,Xe.length=0}}else Ao()}}function Ao(){let t=!ft;t&&(ft=!0);let e=[],n=0;try{for(;Fe.length>0||$e.length>0||Xe.length>0||t&&pt.length>0;){if(t&&pt.length>0){let o=pt.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw Fe.length=0,$e.length=0,Xe.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(Fe.length>0?Fe:$e.length>0?$e:Xe).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{t&&(ft=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Nt(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!_t()){t(e);return}(u>=5?Xe:u===4?$e:Fe).push(()=>t(e));return}let r=e.length,s=r,o=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(s=a;a<r&&n(e[a][0])===3;)a++;for(o=a;a<r&&n(e[a][0])===4;)a++;i=a;let d=_t();if(s>0){let u=e.slice(0,s);t(u)}if(o>s){let u=e.slice(s,o);d?Fe.push(()=>t(u)):t(u)}if(i>o){let u=e.slice(o,i);d?$e.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);d?Xe.push(()=>t(u)):t(u)}}var Qe,ft,Fe,$e,Xe,pt,ye=he(()=>{"use strict";Qe=0,ft=!1,Fe=[],$e=[],Xe=[],pt=[]});function ne(){return Math.trunc(performance.now()*1e6)}function re(){return Date.now()*1e6}var Le=he(()=>{"use strict"});var Ke,w,G,A,ve,me,Te,K,_,N,Ze,an,Co,un,Do,Po,dn,Zn,er,tr,cn,X=he(()=>{"use strict";Ke=Symbol.for("graphrefly/START"),w=Symbol.for("graphrefly/DATA"),G=Symbol.for("graphrefly/DIRTY"),A=Symbol.for("graphrefly/RESOLVED"),ve=Symbol.for("graphrefly/INVALIDATE"),me=Symbol.for("graphrefly/PAUSE"),Te=Symbol.for("graphrefly/RESUME"),K=Symbol.for("graphrefly/TEARDOWN"),_=Symbol.for("graphrefly/COMPLETE"),N=Symbol.for("graphrefly/ERROR"),Ze=Object.freeze([G]),an=Object.freeze([A]),Co=Object.freeze([ve]),un=Object.freeze([Ke]),Do=Object.freeze([_]),Po=Object.freeze([K]),dn=Object.freeze([Ze]),Zn=Object.freeze([an]),er=Object.freeze([Co]),tr=Object.freeze([Do]),cn=Object.freeze([Po])});function rr(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let s=2+n.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=ln,o[i++]=n.length,o.set(n,i),i+=n.length,o[i++]=r>>>8&255,o[i++]=r&255,o.set(e,i),o}function or(t,e){if(t.length<nr)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${nr})`);let n=0,r=t[n++];if(r!==ln)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${ln})`);let s=t[n++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+s+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+s+2} bytes, have ${t.length})`);let o=new TextDecoder().decode(t.subarray(n,n+s));n+=s;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),d=e.lookupCodec(o);if(d==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:d,codecVersion:i,payload:a}}function sr(t){t.registerCodec(Io)}var Io,ln,nr,fn=he(()=>{"use strict";Io={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}},ln=1,nr=4});function Et(t){if(t==null)return et;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var et,pn=he(()=>{"use strict";et={type:"system",id:""}});function ir(t){t.registerMessageType(Ke,{tier:0,wireCrossing:!1}),t.registerMessageType(G,{tier:1,wireCrossing:!1}),t.registerMessageType(ve,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(me,{tier:2,wireCrossing:!1}),t.registerMessageType(Te,{tier:2,wireCrossing:!1}),t.registerMessageType(w,{tier:3,wireCrossing:!0}),t.registerMessageType(A,{tier:3,wireCrossing:!0}),t.registerMessageType(_,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(N,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(K,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var St,ar=he(()=>{"use strict";X();St=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function hn(t){let e=Lo.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var Ne,Lo,Ot=he(()=>{"use strict";Ne=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}},Lo=["human","llm","wallet","system"]});function mn(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(mn);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=mn(t[n]);return e}return null}function Go(t){let e=Vo.encode(t),n=e.length,r=n*8,s=n+9+63&-64,o=new Uint8Array(s);o.set(e),o[n]=128;let i=new DataView(o.buffer);i.setUint32(s-4,r>>>0,!1),i.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,d=3144134277,u=1013904242,c=2773480762,p=1359893119,f=2600822924,h=528734635,l=1541459225,m=new Uint32Array(64),b=(y,v)=>y>>>v|y<<32-v;for(let y=0;y<s;y+=64){for(let D=0;D<16;D++)m[D]=i.getUint32(y+D*4,!1);for(let D=16;D<64;D++){let L=m[D-15],O=m[D-2],$=b(L,7)^b(L,18)^L>>>3,ee=b(O,17)^b(O,19)^O>>>10;m[D]=m[D-16]+$+m[D-7]+ee>>>0}let v=a,T=d,k=u,x=c,E=p,S=f,M=h,I=l;for(let D=0;D<64;D++){let L=b(E,6)^b(E,11)^b(E,25),O=E&S^~E&M,$=I+L+O+Bo[D]+m[D]>>>0,ee=b(v,2)^b(v,13)^b(v,22),z=v&T^v&k^T&k,te=ee+z>>>0;I=M,M=S,S=E,E=x+$>>>0,x=k,k=T,T=v,v=$+te>>>0}a=a+v>>>0,d=d+T>>>0,u=u+k>>>0,c=c+x>>>0,p=p+E>>>0,f=f+S>>>0,h=h+M>>>0,l=l+I>>>0}let g=y=>y.toString(16).padStart(8,"0");return g(a)+g(d)+g(u)+g(c)+g(p)+g(f)+g(h)+g(l)}function gn(t){let e=mn(t??null),n=JSON.stringify(e);return Go(n).slice(0,16)}function Fo(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function bn(t,e,n){let r=n?.id??Fo();if(t===0)return{id:r,version:0};let o=(n?.hash??gn)(e);return{id:r,version:0,cid:o,prev:null}}function ur(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Bo,Vo,dr=he(()=>{"use strict";Bo=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]),Vo=new TextEncoder});function fr(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function yn(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Rt(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function B(t,e,n){let r=pr(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,o={};return pr(t)?o=(vn(e)?e:n)??{}:vn(t)?o=t:o=(vn(e)?e:n)??{},new oe(r,s,o)}var cr,lr,$o,Ko,le,oe,pr,vn,we=he(()=>{"use strict";fn();pn();ye();Le();ar();Ot();X();dr();cr=()=>{},lr=100;$o=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},Ko=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[un]:[un,[w,o]];s._status==="dirty"&&i.push(Ze),Nt(e,i,s._config.tierOf)},le=new St({onMessage:$o,onSubscribe:Ko});ir(le);sr(le);oe=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??le,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??gn;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?bn(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(fr);let o={};for(let[a,d]of Object.entries(r.meta??{})){let u={initial:d,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),o[a]=new t([],void 0,u)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[w,a]])},down(a){i._emit(Rt(a))},up(a){i._emitUp(Rt(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let s=n?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,d=i?.version??0,u=bn(e,o,{id:a,hash:s});u.version=d,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=Et(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let s=Et(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new Ne({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new Ne({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:re()}}down(e,n){let r=Rt(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[w,e]])}up(e,n){if(this._deps.length===0)return;let r=Rt(e);if(r.length===0)return;this._checkGuard(n);let s=n??{internal:!0};this._validateUpTiers(r);for(let o of this._deps)o.node.up?.(r,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let s=n(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let d=Et(n);if(!this._guard(d,"observe"))throw new Ne({actor:d,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)yn(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let s=r,o=this._deps[r];o.unsub=cr,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,d=!1;for(let u of i)a(u[0])>=3&&(d=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:s},this._actions);d&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let s=0;s<n;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}yn(o)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let n=this._deps.length,r=fr(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(dn),r.unsub=cr;try{r.unsub=e.subscribe(s=>{if(r.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[N,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[N,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let r of this._deps){if(r.unsub!=null){let s=r.unsub;r.unsub=null;try{s()}catch{}}yn(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],s=n[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(o)}if(s!==Ke){if(s===G){this._depDirtied(r);return}if(s===ve){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(er);return}if(s===me||s===Te){this._emit([n]);return}if(s===K){this._emit(cn);return}if(s===w)this._depSettledAsData(r,n[1]);else if(s===A)this._depSettledAsResolved(r);else if(s===_)this._depSettledAsTerminal(r,!0);else if(s===N)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===w||s===A)&&this._emit([n]),(s===_||s===N)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(dn))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Zn),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[N,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(tr)}_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 n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[N,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>lr?(this._rerunDepth=0,this._emit([[N,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${lr} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[Ze,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let d of e){let u=n(d[0]);u<i&&(r=!1),u===3&&(s=!0),d[0]===G&&(o=!0),i=u}let a=e;if(!r){let d=e.map((u,c)=>({m:u,i:c,tier:n(u[0])}));d.sort((u,c)=>u.tier-c.tier||u.i-c.i),a=d.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let d=0;for(;d<a.length&&n(a[d][0])===0;)d++;return d===0?[Ze,...a]:[...a.slice(0,d),Ze,...a.slice(d)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let d=e[a];if(d[0]===N&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(d=>d[0]===K||d[0]===ve);if(a.length===0)return;n=a}n=this._frameBatch(n);let s=null;for(let a=0;a<n.length;a++){let d=n[a],u=d[0];if(u!==me&&u!==Te){s?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===me?"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=d[1];if(u===me)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?s?.push(d):s==null&&(s=n.slice(0,a))}if(s!=null){if(s.length===0)return;n=s}if(this._hasMeta&&n.some(a=>a[0]===K))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(cn)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(n);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,d=[];for(let u of o)a(u[0])===3?this._pauseBuffer.push(u):d.push(u);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[N,i]])}_updateState(e){let n=this._config.tierOf,r,s,o=-1,i=0;for(let c of e)n(c[0])===3&&i++;let a=i<=1,d=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===w){d=c;break}}for(let c=0;c<e.length;c++){let p=e[c],f=p[0];if(f===w){if(p.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,p[1])}catch(l){s=this._wrapFnError("equals threw",l),o=c;break}if(h){r==null&&(r=e.slice(0,c)),r.push(an),this._status="resolved";continue}this._cached=p[1],this._versioning!=null&&(d<0||c===d)&&ur(this._versioning,p[1],this._hashFn)}this._status="settled",r?.push(p)}else if(r?.push(p),f===G)this._status="dirty";else if(f===A)this._status="resolved";else if(f===_)this._status="completed";else if(f===N)this._status="errored";else if(f===ve){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===K&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:u,equalsError:s}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(Xn()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ht(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}Nt(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);Nt(this._deliverToSinks,n,this._config.tierOf)}},pr=t=>Array.isArray(t),vn=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function F(t,e){return B([],{...e,initial:t})}function R(t,e){return B((r,s,o)=>t(s,o)??void 0,{describeKind:"producer",...e})}function xe(t,e,n){return B(t,(s,o,i)=>{let a=s.map((d,u)=>d!=null&&d.length>0?d.at(-1):i.prevData[u]);o.emit(e(a,i))},{describeKind:"derived",...n})}function Mt(t,e,n){return B(t,(s,o,i)=>{let a=s.map((d,u)=>d!=null&&d.length>0?d.at(-1):i.prevData[u]);return e(a,o,i)??void 0},{describeKind:"effect",...n})}var ue=he(()=>{"use strict";we()});var mr={};sn(mr,{NS_PER_MS:()=>fe,NS_PER_SEC:()=>Ae,constant:()=>Tn,decorrelatedJitter:()=>_n,exponential:()=>xn,fibonacci:()=>kn,linear:()=>wn,resolveBackoffPreset:()=>je,withMaxAttempts:()=>hr});function ze(t){return t<0?0:t}function zo(t,e){return e==="none"?t:e==="full"?Math.random()*t:t/2+Math.random()*(t/2)}function jo(t,e){return t+Math.random()*(e-t)}function Tn(t){let e=ze(t);return()=>e}function wn(t,e){let n=ze(t),r=e===void 0?n:ze(e);return s=>n+r*Math.max(0,s)}function xn(t){let e=ze(t?.baseNs??1e8),n=t?.factor!==void 0&&t.factor<1?1:t?.factor??2,r=ze(t?.maxDelayNs??30*1e9),s=t?.jitter??"none";return o=>{let i;if(e===0)i=0;else if(n===1)i=e;else{let a=r/e,d=1;for(let u=0;u<Math.max(0,o);u++){if(d>=a){d=a;break}d*=n}i=e*d,i>r&&(i=r)}return zo(i,s)}}function kn(t=100*1e6,e=30*1e9){let n=ze(t),r=ze(e);function s(o){if(o<=0)return 1;let i=1,a=2;for(let d=1;d<o;d++){let u=i+a;i=a,a=u}return a}return o=>{let i=s(o)*n;return i<=r?i:r}}function _n(t=100*1e6,e=30*1e9){return(n,r,s)=>{let i=Math.min(e,(s??t)*3);return jo(t,i)}}function hr(t,e){return(n,r,s)=>n>=e?null:t(n,r,s)}function je(t){if(t==="constant")return Tn(1*1e9);if(t==="linear")return wn(1*1e9);if(t==="exponential")return xn();if(t==="fibonacci")return kn();if(t==="decorrelatedJitter")return _n();throw new Error(`Unknown backoff preset: "${String(t)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var fe,Ae,mt=he(()=>{"use strict";fe=1e6,Ae=1e9});function gt(t,e,n){let r=new Set;for(let s of t.split(",")){let[o,i]=s.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${s}`);let d,u;if(o==="*")d=e,u=n;else if(o.includes("-")){let[c,p]=o.split("-");d=Number.parseInt(c,10),u=Number.parseInt(p,10)}else d=Number.parseInt(o,10),u=d;if(Number.isNaN(d)||Number.isNaN(u))throw new Error(`Invalid cron field: ${t}`);if(d<e||u>n)throw new Error(`Cron field out of range: ${t} (${e}-${n})`);if(d>u)throw new Error(`Invalid cron range: ${d}-${u} in ${t}`);for(let c=d;c<=u;c+=a)r.add(c)}return r}function En(t){let e=t.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:gt(e[0],0,59),hours:gt(e[1],0,23),daysOfMonth:gt(e[2],1,31),months:gt(e[3],1,12),daysOfWeek:gt(e[4],0,6)}}function Sn(t,e){return t.minutes.has(e.getMinutes())&&t.hours.has(e.getHours())&&t.daysOfMonth.has(e.getDate())&&t.months.has(e.getMonth()+1)&&t.daysOfWeek.has(e.getDay())}var On=he(()=>{"use strict"});var Oe,At=he(()=>{"use strict";Oe=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var yr={};sn(yr,{CircuitOpenError:()=>nt,RateLimiterOverflowError:()=>rt,TimeoutError:()=>ot,circuitBreaker:()=>Mn,fallback:()=>Dn,rateLimiter:()=>Cn,retry:()=>Rn,retrySource:()=>bt,timeout:()=>Pn,tokenBucket:()=>Dt,withBreaker:()=>An,withStatus:()=>yt});function He(t){return{describeKind:"derived",...t}}function Ho(t){return t<0?0:t}function Ct(t){return t[1]}function br(t){if(typeof t!="number"||!Number.isFinite(t))throw new TypeError("backoff strategy must return a finite number");return t<0?0:t}function Rn(t,e){let n=e?.count,r=e?.backoff,s=n!==void 0?n:r===void 0?0:2147483647;if(s<0)throw new RangeError("retry count must be >= 0");let o=r===void 0?null:typeof r=="string"?je(r):r;return R(i=>{let a=0,d=!1,u=null,c,p=new Oe;function f(){c?.(),c=void 0}function h(m){if(d)return;if(a>=s){f(),i.down([[N,m]]);return}let b=o===null?0:o(a,m,u);if(b==null){f(),i.down([[N,m]]);return}let g;try{g=br(b)}catch{f(),i.down([[N,m]]);return}u=g,a+=1,f();let y=g>0?g/1e6:1;p.start(y,()=>{d||l()})}function l(){p.cancel(),f(),c=t.subscribe(m=>{if(!d)for(let b of m){let g=b[0];if(g===G)i.down([[G]]);else if(g===w)a=0,u=null,i.emit(b[1]);else if(g===A)i.down([[A]]);else if(g===_)f(),i.down([[_]]);else if(g===N){h(Ct(b));return}else i.down([b])}})}return l(),()=>{d=!0,p.cancel(),f()}},{...He(),initial:t.cache})}function bt(t,e){let n=e?.count,r=e?.backoff,s=n!==void 0?n:r===void 0?0:2147483647;if(s<0)throw new RangeError("retry count must be >= 0");let o=r===void 0?null:typeof r=="string"?je(r):r;return R(i=>{let a=0,d=!1,u=null,c,p=new Oe;function f(){c?.(),c=void 0}function h(m){if(d)return;if(a>=s){f(),i.down([[N,m]]);return}let b=o===null?0:o(a,m,u);if(b==null){f(),i.down([[N,m]]);return}let g;try{g=br(b)}catch{f(),i.down([[N,m]]);return}u=g,a+=1,f();let y=g>0?g/1e6:1;p.start(y,()=>{d||l()})}function l(){p.cancel(),f();let m;try{m=t()}catch(b){h(b);return}c=m.subscribe(b=>{if(!d)for(let g of b){let y=g[0];if(y===G)i.down([[G]]);else if(y===w)a=0,u=null,i.emit(g[1]);else if(y===A)i.down([[A]]);else if(y===_)f(),i.down([[_]]);else if(y===N){h(Ct(g));return}else i.down([g])}})}return l(),()=>{d=!0,p.cancel(),f()}},{...He(),initial:e?.initial})}function Mn(t){let e=Math.max(1,t?.failureThreshold??5),n=Ho(t?.cooldownNs??30*1e9),r=t?.cooldown??null,s=Math.max(1,t?.halfOpenMax??1),o=t?.now??ne,i="closed",a=0,d=0,u=0,c=n,p=0;function f(){if(!r)return n;let m=r(d);return m!==null?m:n}function h(){i="open",c=f(),u=o(),p=0}return{canExecute(){return i==="closed"?!0:i==="open"?o()-u>=c?(i="half-open",p=1,!0):!1:p<s?(p++,!0):!1},recordSuccess(){i==="half-open"?(i="closed",a=0,d=0):i==="closed"&&(a=0)},recordFailure(m){if(i==="half-open"){d++,h();return}i==="closed"&&(a++,a>=e&&h())},get state(){return i},get failureCount(){return a},reset(){i="closed",a=0,d=0,p=0}}}function An(t,e){let n=e?.onOpen??"skip";return r=>{let s=B([],(o,i)=>{function a(){s.meta.breakerState.down([[w,t.state]])}let d=r.subscribe(u=>{for(let c of u){let p=c[0];p===G?i.down([[G]]):p===w?t.canExecute()?(a(),i.emit(c[1])):(a(),n==="error"?i.down([[N,new nt]]):i.down([[A]])):p===A?i.down([[A]]):p===_?(t.recordSuccess(),a(),i.down([[_]])):p===N?(t.recordFailure(Ct(c)),a(),i.down([c])):i.down([c])}});return a(),d},{...He(),meta:{breakerState:t.state},completeWhenDepsComplete:!1,initial:r.cache});return{node:s,breakerState:s.meta.breakerState}}}function Dt(t,e){if(t<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let n=t,r=ne();function s(o){if(e>0){let i=o-r;n=Math.min(t,n+i/1e9*e)}r=o}return{available(){return s(ne()),n},tryConsume(o=1){if(o<=0)return!0;let i=ne();return s(i),n>=o?(n-=o,!0):!1},putBack(o=1){o<=0||(s(ne()),n=Math.min(t,n+o))}}}function Cn(t,e){let{maxEvents:n,windowNs:r}=e;if(n<=0)throw new RangeError("maxEvents must be > 0");if(r<=0)throw new RangeError("windowNs must be > 0");let s=e.maxBuffer;if(s!==void 0&&s<1)throw new RangeError("maxBuffer must be >= 1");let o=e.onOverflow??"drop-newest",i=n*1e9/r;return R(a=>{let d=Dt(n,i),u=[],c=new Oe,p=!1,f=1e9/i;function h(){for(;u.length>0;)if(d.tryConsume(1))a.emit(u.shift());else{c.start(Math.max(1,f/1e6),h);return}}let l=t.subscribe(m=>{for(let b of m){if(p)return;let g=b[0];if(g===G)a.down([[G]]);else if(g===w){if(s!==void 0&&u.length>=s){if(o!=="drop-newest")if(o==="drop-oldest")u.shift(),u.push(b[1]);else{p=!0,c.cancel(),u.length=0,a.down([[N,new rt(s)]]);return}}else u.push(b[1]);h()}else if(g===A)a.down([[A]]);else if(g===_)p=!0,c.cancel(),u.length=0,a.down([[_]]);else if(g===N)p=!0,c.cancel(),u.length=0,a.down([b]);else if(g===K){p=!0,c.cancel(),u.length=0,a.down([b]);return}else a.down([b])}});return()=>{p=!0,c.cancel(),l()}},{...He(),initial:t.cache})}function yt(t,e){let n=e?.initialStatus??"pending",r=B([],(s,o)=>{let i=n;return r.meta.status.down([[w,n]]),r.meta.error.down([[w,null]]),t.subscribe(d=>{for(let u of d){let c=u[0];if(c===G)o.down([[G]]);else if(c===w)i==="errored"?j(()=>{r.meta.error.down([[w,null]]),r.meta.status.down([[w,"active"]])}):r.meta.status.down([[w,"active"]]),i="active",o.emit(u[1]);else if(c===A)o.down([[A]]);else if(c===_)r.meta.status.down([[w,"completed"]]),i="completed",o.down([[_]]);else if(c===N){let p=Ct(u);j(()=>{r.meta.error.down([[w,p]]),r.meta.status.down([[w,"errored"]])}),i="errored",o.down([u])}else o.down([u])}})},{...He(),meta:{status:n,error:null},completeWhenDepsComplete:!1,resubscribable:!0,initial:t.cache});return{node:r,status:r.meta.status,error:r.meta.error}}function Wo(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function Uo(t){return t!=null&&typeof t.then=="function"}function qo(t){return t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function"}function Dn(t,e){return R(n=>{let r,s;function o(){s?.(),s=void 0,Wo(e)||Uo(e)||qo(e)?r=de(e).subscribe(a=>{n.down(a)}):(n.emit(e),n.down([[_]]))}return s=t.subscribe(i=>{for(let a of i){let d=a[0];if(d===G)n.down([[G]]);else if(d===w)n.emit(a[1]);else if(d===A)n.down([[A]]);else if(d===_)n.down([[_]]);else if(d===N){o();return}else if(d===K){r?.(),n.down([a]);return}else n.down([a])}}),()=>{s?.(),r?.()}},{...He(),initial:t.cache})}function Pn(t,e){if(e<=0)throw new RangeError("timeoutNs must be > 0");return R(n=>{let r=!1,s=new Oe;function o(){let a=e/1e6;s.start(a,()=>{r||(r=!0,i(),n.down([[N,new ot(e)]]))})}let i=t.subscribe(a=>{for(let d of a){if(r)return;let u=d[0];if(u===G)n.down([[G]]);else if(u===w)o(),n.emit(d[1]);else if(u===A)n.down([[A]]);else if(u===_){s.cancel(),r=!0,n.down([[_]]);return}else if(u===N){s.cancel(),r=!0,n.down([d]);return}else if(u===K){s.cancel(),r=!0,n.down([d]);return}else n.down([d])}});return o(),()=>{r=!0,s.cancel(),i()}},{...He(),initial:t.cache})}var nt,rt,ot,Pt=he(()=>{"use strict";ye();Le();X();we();ue();mt();Ie();At();nt=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};rt=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};ot=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});function Ee(t){return{describeKind:"producer",...t}}function Tr(t){return/[\\^$+?.()|[\]{}]/.test(t)?`\\${t}`:t}function Jo(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){t[n+1]==="*"?(e+=".*",n+=1):e+="[^/]*";continue}e+=Tr(r)}return e+="$",new RegExp(e)}function Yo(t,e){for(let n of e)if(n.test(t))return!0;return!1}function Qo(t,e){let n=B([t],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[A]]);return}for(let a of i)o.emit(a)},{describeKind:"derived",initial:t.cache}),r=n.subscribe.bind(n);return n.subscribe=(s,o)=>(e(s),r(s,o)),n}function We(t,e){let{signal:n,period:r,...s}=e??{};return R(o=>{let i=!1,a=0,d,u,c=()=>{i=!0,d!==void 0&&clearTimeout(d),u!==void 0&&clearInterval(u),n?.removeEventListener("abort",f)},p=()=>{i||(r!=null?(o.emit(a++),u=setInterval(()=>{i||o.emit(a++)},r)):(i=!0,n?.removeEventListener("abort",f),o.emit(a++),o.down([[_]])))},f=()=>{i||(c(),o.down([[N,n.reason]]))};if(n?.aborted){f();return}return d=setTimeout(p,t),n?.addEventListener("abort",f,{once:!0}),c},Ee(s))}function Xo(t){let{signal:e,...n}=t??{};return R(r=>{let s=!1,o,i,a=!1,d=!1,u=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,c=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,p=typeof document<"u"?document:void 0,f=()=>{o!==void 0&&c&&c(o),i!==void 0&&clearTimeout(i),o=void 0,i=void 0},h=()=>{s=!0,f(),a&&(e?.removeEventListener("abort",l),a=!1),d&&p&&(p.removeEventListener("visibilitychange",g),d=!1)},l=()=>{s||(h(),r.down([[N,e.reason]]))},m=y=>{s||(r.emit(y),b())},b=()=>{s||(u&&(!p||p.visibilityState!=="hidden")?o=u(m):i=setTimeout(()=>m(performance.now()),16))},g=()=>{s||(f(),b())};return e?.aborted?(l(),h):(e?.addEventListener("abort",l,{once:!0}),a=e!==void 0,p&&u&&(p.addEventListener("visibilitychange",g),d=!0),b(),h)},Ee(n))}function Zo(t,e){let n=En(t),{tickMs:r,output:s,...o}=e??{},i=r??6e4,a=s==="date";return R(d=>{let u=-1,c=()=>{let f=new Date,h=f.getFullYear()*1e8+(f.getMonth()+1)*1e6+f.getDate()*1e4+f.getHours()*100+f.getMinutes();h!==u&&Sn(n,f)&&(u=h,d.emit(a?f:re()))};c();let p=setInterval(c,i);return()=>clearInterval(p)},{...Ee(o),name:o.name??`cron:${t}`})}function es(t,e,n){let{capture:r,passive:s,once:o,...i}=n??{};return R(a=>{let d=c=>{a.emit(c)},u={capture:r,passive:s,once:o};return t.addEventListener(e,d,u),()=>t.removeEventListener(e,d,u)},Ee(i))}function Bn(t,e){return R(n=>{let r=!1;try{for(let s of t){if(r)return;n.emit(s)}r||n.down([[_]])}catch(s){r||n.down([[N,s]])}return()=>{r=!0}},Ee(e))}function ts(t){return t!=null&&typeof t.then=="function"}function wr(t,e){let{signal:n,...r}=e??{};return R(s=>{let o=!1,i=()=>{o||(o=!0,s.down([[N,n.reason]]))};if(n?.aborted){i();return}return n?.addEventListener("abort",i,{once:!0}),Promise.resolve(t).then(a=>{o||(o=!0,n?.removeEventListener("abort",i),s.emit(a),s.down([[_]]))},a=>{o||(o=!0,n?.removeEventListener("abort",i),s.down([[N,a]]))}),()=>{o=!0,n?.removeEventListener("abort",i)}},Ee(r))}function xr(t,e){let{signal:n,...r}=e??{};return R(s=>{let o=new AbortController,i=()=>o.abort(n?.reason);n?.aborted?o.abort(n.reason):n?.addEventListener("abort",i,{once:!0});let a=n??o.signal,d=!1,u=t[Symbol.asyncIterator](),c=()=>{d||a.aborted||Promise.resolve(u.next()).then(p=>{if(!(d||a.aborted)){if(p.done){s.down([[_]]);return}s.emit(p.value),c()}},p=>{!d&&!a.aborted&&s.down([[N,p]])})};return c(),()=>{d=!0,n?.removeEventListener("abort",i),o.abort(),Promise.resolve(u.return?.()).catch(()=>{})}},Ee(r))}function ns(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function de(t,e){if(ns(t))return t;if(ts(t))return wr(t,e);if(t!=null){let n=t;if(typeof n[Symbol.asyncIterator]=="function")return xr(t,e);if(typeof n[Symbol.iterator]=="function")return Bn(t,e)}return kr(t)}function kr(...t){return Bn(t,void 0)}function rs(t){return R(e=>{e.down([[_]])},Ee(t))}function os(t){return R(()=>{},Ee(t))}function ss(t,e){return R(n=>{n.down([[N,t]])},Ee(e))}function Ue(t,e,n){return B([t],(s,o)=>{let i=s[0];if(i!=null&&i.length>0)for(let a of i)e(a)},{describeKind:"effect",...n}).subscribe(()=>{})}function is(t,e){return B([t],(n,r,s)=>{s.store.buf||(s.store.buf=[]);let o=s.store.buf,i=n[0];if(i!=null&&i.length>0)for(let a of i)o.push(a);if(s.terminalDeps[0]===!0){r.emit([...o]),r.down([[_]]);return}(i==null||i.length===0)&&r.down([[A]])},{describeKind:"derived",completeWhenDepsComplete:!1,...e})}function as(t,e){return R(n=>t.subscribe(r=>{n.down(r)}),{...Ee(e),initial:t.cache})}function Vn(t,e,n){if(e<1)throw new RangeError("replay expects bufferSize >= 1");let r=[],s=R(o=>t.subscribe(i=>{for(let a of i)a[0]===w&&(r.push(a[1]),r.length>e&&r.shift());o.down(i)}),{...Ee(n),initial:t.cache});return Qo(s,o=>{for(let i of r)o([[w,i]])})}function us(t,e){return Vn(t,1,e)}function Gn(t){return new Promise((e,n)=>{let r=!1,s=!1,o;o=t.subscribe(i=>{for(let a of i){if(r)return;if(a[0]===w){r=!0,e(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===N){r=!0,n(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===_){r=!0,n(new Error("completed without DATA")),o?(o(),o=void 0):s=!0;return}}}),s&&(o?.(),o=void 0)})}function Ln(t,e,n){return new Promise((r,s)=>{let o=!1,i=!1,a,d=n?.skipCurrent===!0;a=t.subscribe(u=>{for(let c of u){if(o)return;if(!(d&&c[0]===w)){if(c[0]===w){let p=c[1];if(e(p)){o=!0,r(p),a?(a(),a=void 0):i=!0;return}}if(c[0]===N){o=!0,s(c[1]),a?(a(),a=void 0):i=!0;return}if(c[0]===_){o=!0,s(new Error("completed without matching value")),a?(a(),a=void 0):i=!0;return}}}}),d=!1,i&&(a?.(),a=void 0)})}async function ds(t,e){let n=e?.predicate??(o=>o!=null),r=e?.skipCurrent;if(e?.timeoutMs==null||e.timeoutMs<=0)return await Ln(t,n,{skipCurrent:r});if(In===void 0){let[o,i]=await Promise.all([Promise.resolve().then(()=>(Pt(),yr)),Promise.resolve().then(()=>(mt(),mr))]);In=o.timeout,vr=i.NS_PER_MS}let s=In(t,e.timeoutMs*vr);return await Ln(s,n,{skipCurrent:r})}function cs(t,e){let n=new AbortController,r=e?.reason??new Error("cancelled via nodeSignal"),s,o=!1,i=()=>{s?(s(),s=void 0):o=!0};return s=t.subscribe(a=>{if(!n.signal.aborted)for(let d of a){if(d[0]===w&&d[1]===!0){n.abort(r),i();return}if(d[0]===N){n.abort(d[1]),i();return}if(d[0]===_){i();return}}}),o&&(s?.(),s=void 0),{signal:n.signal,dispose:()=>{s&&(s(),s=void 0)}}}function It(t){return t.subscribe(()=>{})}function fs(t){let e=F(0);return{node:e,increment(){let n=e.cache??0;return n>=t?!1:(e.down([[G],[w,n+1]]),!0)},get(){return e.cache??0},atCap(){return(e.cache??0)>=t}}}var In,vr,ls,Ie=he(()=>{"use strict";Le();X();we();ue();On();ls=Vn});var pu={};sn(pu,{CircuitOpenError:()=>nt,ContentAddressedMissError:()=>$t,NS_PER_MS:()=>fe,NS_PER_SEC:()=>Ae,NativeIndexBackend:()=>zt,NativeListBackend:()=>jt,NativeLogBackend:()=>Ht,NativeMapBackend:()=>Ft,NativePubSubBackend:()=>Kt,RateLimiterOverflowError:()=>rt,ResettableTimer:()=>Oe,TimeoutError:()=>ot,audit:()=>Ds,awaitSettled:()=>ds,buffer:()=>Ps,bufferCount:()=>Is,bufferTime:()=>Bs,cached:()=>us,canonicalJson:()=>Wr,cascadingCache:()=>Wi,catchError:()=>Us,checkpointToRedis:()=>Bi,checkpointToS3:()=>Li,circuitBreaker:()=>Mn,combine:()=>Sr,combineLatest:()=>js,concat:()=>Es,concatMap:()=>Rs,constant:()=>Tn,contentAddressedStorage:()=>Yi,createTransport:()=>Ye,createWatermarkController:()=>Hi,csvRows:()=>vi,debounce:()=>Rr,debounceTime:()=>Hs,decorrelatedJitter:()=>_n,delay:()=>As,deserializeError:()=>lt,dictStorage:()=>ca,distill:()=>Ji,distinctUntilChanged:()=>xs,elementAt:()=>vs,empty:()=>rs,escapeRegexChar:()=>Tr,exhaustMap:()=>Os,exponential:()=>xn,externalBundle:()=>Nn,externalProducer:()=>tt,fallback:()=>Dn,fibonacci:()=>kn,filter:()=>Bt,find:()=>ys,first:()=>Fn,firstValueFrom:()=>Gn,firstWhere:()=>Ln,flatMap:()=>Ms,forEach:()=>Ue,fromAny:()=>de,fromAsyncIter:()=>xr,fromCSV:()=>yi,fromClickHouseWatch:()=>xi,fromCron:()=>Zo,fromDrizzle:()=>Ki,fromEvent:()=>es,fromHTTP:()=>Dr,fromHTTPPoll:()=>ni,fromHTTPStream:()=>ti,fromIter:()=>Bn,fromKafka:()=>hi,fromKysely:()=>zi,fromMCP:()=>si,fromNATS:()=>Ni,fromNDJSON:()=>wi,fromOTel:()=>ii,fromPrisma:()=>$i,fromPrometheus:()=>fi,fromPromise:()=>wr,fromPulsar:()=>ki,fromRabbitMQ:()=>Si,fromRaf:()=>Xo,fromRedisStream:()=>gi,fromSSE:()=>ei,fromSqlite:()=>Vi,fromSqliteCursor:()=>Gi,fromStatsD:()=>di,fromSyslog:()=>ai,fromTimer:()=>We,fromWebSocket:()=>Cr,fromWebSocketReconnect:()=>oi,fromWebhook:()=>Js,globToRegExp:()=>Jo,interval:()=>Fs,keepalive:()=>It,last:()=>bs,linear:()=>wn,lru:()=>Fr,makeHttpError:()=>Qi,map:()=>Lt,matchesAnyPattern:()=>Yo,matchesCron:()=>Sn,memoryStorage:()=>da,merge:()=>vt,mergeMap:()=>Or,nameToSignal:()=>dt,ndjsonRows:()=>Ti,never:()=>os,nodeSignal:()=>cs,of:()=>kr,onFirstData:()=>Er,pairwise:()=>ks,parseCron:()=>En,parsePrometheusText:()=>Br,parseSSEStream:()=>Lr,parseStatsD:()=>li,parseSyslog:()=>ui,pausable:()=>Ks,pubsub:()=>Zi,race:()=>Ss,rateLimiter:()=>Cn,reactiveCounter:()=>fs,reactiveIndex:()=>na,reactiveList:()=>ra,reactiveLog:()=>sa,reactiveMap:()=>zn,reactiveSink:()=>ie,reduce:()=>hs,repeat:()=>$s,replay:()=>Vn,rescue:()=>Ar,resolveBackoffPreset:()=>je,retry:()=>Rn,retrySource:()=>bt,sample:()=>Cs,scan:()=>ps,serializeError:()=>ct,share:()=>as,shareReplay:()=>ls,signalToName:()=>Je,singleFromAny:()=>ia,singleNodeFromAny:()=>aa,skip:()=>Nr,sortJsonValue:()=>Wt,stableJsonString:()=>ua,stratify:()=>au,switchMap:()=>Ce,take:()=>Vt,takeUntil:()=>gs,takeWhile:()=>ms,tap:()=>Ts,tapFirst:()=>ws,throttle:()=>Mr,throttleTime:()=>Ws,throwError:()=>ss,timeout:()=>Pn,toArray:()=>is,toCSV:()=>Ri,toClickHouse:()=>Mi,toFile:()=>Gr,toHTTP:()=>Ys,toKafka:()=>mi,toLoki:()=>Pi,toMongo:()=>Di,toNATS:()=>Ei,toObservable:()=>Xi,toPostgres:()=>Ci,toPulsar:()=>_i,toRabbitMQ:()=>Oi,toReadableStream:()=>Zs,toRedisStream:()=>bi,toS3:()=>Ai,toSSE:()=>Qs,toSSEBytes:()=>Xs,toSqlite:()=>Fi,toTempo:()=>Ii,toWebSocket:()=>ri,tokenBucket:()=>Dt,valve:()=>zs,verifiable:()=>qi,window:()=>Gs,windowCount:()=>Ls,windowTime:()=>Vs,withBreaker:()=>An,withLatestFrom:()=>_s,withMaxAttempts:()=>hr,withStatus:()=>yt,workerBridge:()=>xo,workerSelf:()=>ko,zip:()=>Ns});module.exports=Mo(pu);ye();Le();X();we();ue();ye();X();ue();function gr(t){return{describeKind:"producer",...t}}function tt(t,e){return R(n=>{let r=!0,s={emit(i){r&&n.emit(i)},error(i){r&&(r=!1,n.down([[N,i]]))},complete(){r&&(r=!1,n.down([[_]]))}},o;try{let i=t(s);o=typeof i=="function"?i:void 0}catch(i){return s.error(i),()=>{r=!1}}return()=>{r=!1;try{o?.()}catch{}}},gr(e))}function Nn(t,e,n){let r=!0,s,o=0,i=0,a={},d=[],u=()=>{let h=s;s=void 0;try{h?.()}catch{}};for(let h of e){let l=n?.name?`${n.name}::${h}`:h,m=n?.channelOpts?.[h],b=R(g=>(o++,()=>{i++,o>0&&i>=o&&i>=e.length&&u()}),gr({...m,name:l}));a[h]=b,d.push(b)}let c={};for(let h of e)c[h]=l=>{r&&a[h].down([[w,l]])};c.error=h=>{r&&(r=!1,j(()=>{for(let l of d)l.down([[N,h]])}),u())},c.complete=()=>{r&&(r=!1,j(()=>{for(let h of d)h.down([[_]])}),u())};let p=t(c);return s=typeof p=="function"?p:void 0,Object.assign(a,{dispose:()=>{r&&(r=!1,j(()=>{for(let h of d)try{h.down([[_]])}catch{}}),u())}})}Le();X();we();ue();Ie();function V(t){return{describeKind:"derived",...t}}function _r(t){return{describeKind:"derived",partial:!0,...t}}function Lt(t,e,n){return B([t],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[A]]);return}for(let i of o)s.emit(e(i))},V(n))}function Bt(t,e,n){return B([t],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[A]]);return}let i=!1;for(let a of o)e(a)&&(s.emit(a),i=!0);i||s.down([[A]])},V(n))}function ps(t,e,n,r){return B([t],(s,o,i)=>{"acc"in i.store||(i.store.acc=n);let a=s[0];if(a==null||a.length===0){o.down([[A]]);return}for(let d of a)i.store.acc=e(i.store.acc,d),o.emit(i.store.acc)},{...V(r),initial:n,resetOnTeardown:!0})}function hs(t,e,n,r){return B([t],(s,o,i)=>{if("acc"in i.store||(i.store.acc=n),i.terminalDeps[0]===!0){o.emit(i.store.acc),o.down([[_]]);return}let a=s[0];if(a==null||a.length===0){o.down([[A]]);return}for(let d of a)i.store.acc=e(i.store.acc,d)},{...V(r),completeWhenDepsComplete:!1})}function Vt(t,e,n){return e<=0?B([t],(r,s,o)=>{o.store.completed||(o.store.completed=!0,s.down([[_]]))},{...V(n),completeWhenDepsComplete:!1}):B([t],(r,s,o)=>{if("taken"in o.store||(o.store.taken=0),o.store.done){s.down([[A]]);return}if(o.terminalDeps[0]===!0){o.store.done=!0,s.down([[_]]);return}let i=r[0];if(i==null||i.length===0){s.down([[A]]);return}for(let a of i)if(o.store.taken++,s.emit(a),o.store.taken>=e){o.store.done=!0,s.down([[_]]);return}},{...V(n),completeWhenDepsComplete:!1})}function Nr(t,e,n){return B([t],(r,s,o)=>{"skipped"in o.store||(o.store.skipped=0);let i=r[0];if(i==null||i.length===0){s.down([[A]]);return}let a=!1;for(let d of i)o.store.skipped++,o.store.skipped<=e||(s.emit(d),a=!0);a||s.down([[A]])},V(n))}function ms(t,e,n){return B([t],(r,s,o)=>{if(o.store.done){s.down([[A]]);return}let i=r[0];if(i==null||i.length===0){s.down([[A]]);return}for(let a of i){if(!e(a)){o.store.done=!0,s.down([[_]]);return}s.emit(a)}},{...V(n),completeWhenDepsComplete:!1})}function gs(t,e,n){let r=n?.predicate??(i=>i[0]===w),{predicate:s,...o}=n??{};return R(i=>{let a=!1,d=t.subscribe(c=>{if(!a)for(let p of c){if(a)return;p[0]===w?i.emit(p[1]):(p[0]===_||p[0]===N)&&(a=!0,i.down([p]))}}),u=e.subscribe(c=>{if(!a)for(let p of c){if(a)return;if(r(p)){a=!0,i.down([[_]]);return}}});return()=>{d(),u()}},V(o))}function Fn(t,e){return Vt(t,1,e)}function bs(t,e){let{defaultValue:n,...r}=e??{},s=e!=null&&Object.hasOwn(e,"defaultValue");return B([t],(o,i,a)=>{if(a.terminalDeps[0]===!0){a.store.has?i.emit(a.store.latest):s&&i.emit(n),i.down([[_]]);return}let d=o[0];if(d==null||d.length===0){i.down([[A]]);return}a.store.latest=d.at(-1),a.store.has=!0},{...V(r),completeWhenDepsComplete:!1})}function ys(t,e,n){return Vt(Bt(t,e,n),1,n)}function vs(t,e,n){return Vt(Nr(t,e,n),1,n)}function Ts(t,e,n){if(typeof e=="function")return B([t],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[A]]);return}for(let a of i)e(a),o.emit(a)},V(n));let r=e;return B([t],(s,o,i)=>{if(i.terminalDeps[0]!==void 0){i.terminalDeps[0]===!0?(r.complete?.(),o.down([[_]])):(r.error?.(i.terminalDeps[0]),o.down([[N,i.terminalDeps[0]]]));return}let a=s[0];if(a==null||a.length===0){o.down([[A]]);return}for(let d of a)r.data?.(d),o.emit(d)},{...V(n),completeWhenDepsComplete:!1})}function Er(t,e,n){let r=n?.where??(o=>o!=null),s=!1;return B([t],(o,i)=>{let a=o[0];if(a==null||a.length===0){i.down([[A]]);return}for(let d of a)!s&&r(d)&&(s=!0,e(d)),i.emit(d)},V(n))}var ws=Er;function xs(t,e=Object.is,n){return B([t],(r,s,o)=>{let i=r[0];if(i==null||i.length===0){s.down([[A]]);return}let a=!1;for(let d of i)o.store.hasPrev&&e(o.store.prev,d)||(o.store.prev=d,o.store.hasPrev=!0,s.emit(d),a=!0);a||s.down([[A]])},V(n))}function ks(t,e){return B([t],(n,r,s)=>{let o=n[0];if(o==null||o.length===0){r.down([[A]]);return}let i=!1;for(let a of o)if(!s.store.hasPrev)s.store.prev=a,s.store.hasPrev=!0;else{let d=[s.store.prev,a];s.store.prev=a,r.emit(d),i=!0}i||r.down([[A]])},V(e))}function Sr(...t){let e=[...t];return xe(e,n=>n,{...V(),equals:(n,r)=>{if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++)if(!Object.is(n[s],r[s]))return!1;return!0}})}function _s(t,e,n){return B([t,e],(r,s,o)=>{let i=r[0],a=r[1],d=a!=null&&a.length>0?a.at(-1):o.prevData[1];if(i!=null&&i.length>0){if(!(a!=null&&a.length>0)&&o.prevData[1]===void 0){s.down([[A]]);return}for(let u of i)s.emit([u,d])}else s.down([[A]])},_r(n))}function vt(...t){return t.length===0?R(e=>{e.down([[_]])},V()):R(e=>{let n=t.length,r=0,s=[];for(let o of t){let i=o.subscribe(a=>{for(let d of a)d[0]===w?e.emit(d[1]):d[0]===_?(r+=1,r>=n&&e.down([[_]])):d[0]===N&&e.down([d])});s.push(i)}return()=>{for(let o of s)o()}},V())}function Ns(...t){let e=t.length;return e===0?R(n=>{n.emit([]),n.down([[_]])},V()):R(n=>{let r=Array.from({length:e},()=>[]),s=e;function o(){for(;r.every(a=>a.length>0);){let a=r.map(d=>d.shift());n.emit(a)}}let i=[];for(let a=0;a<e;a++){let d=a,u=t[a].subscribe(c=>{for(let p of c)p[0]===w?(r[d].push(p[1]),o()):p[0]===_?(s-=1,(s===0||r[d].length===0)&&n.down([[_]])):p[0]===N&&n.down([p])});i.push(u)}return()=>{for(let a of i)a()}},V())}function Es(t,e,n){return R(r=>{let s=0,o=[],i,a;return a=e.subscribe(d=>{for(let u of d)s===0?u[0]===w?o.push(u[1]):u[0]===N&&r.down([u]):u[0]===w?r.emit(u[1]):(u[0]===_||u[0]===N)&&r.down([u])}),i=t.subscribe(d=>{for(let u of d)if(s===0)if(u[0]===w)r.emit(u[1]);else if(u[0]===_){s=1;for(let c of o)r.emit(c);o.length=0}else u[0]===N&&r.down([u])}),()=>{i?.(),a?.()}},V(n))}function Ss(...t){return t.length===0?R(e=>{e.down([[_]])},V()):t.length===1?B([t[0]],(e,n)=>{let r=e[0];if(r==null||r.length===0){n.down([[A]]);return}for(let s of r)n.emit(s)},V()):R(e=>{let n=null,r=[];for(let s=0;s<t.length;s++){let o=s,i=t[s].subscribe(a=>{for(let d of a){if(n!==null&&o!==n)return;d[0]===w?(n===null&&(n=o),e.emit(d[1])):(d[0]===_||d[0]===N)&&(n===null||o===n)&&e.down([d])}});r.push(i)}return()=>{for(let s of r)s()}},V())}function Gt(t,e,n){let r,s=!1,o=()=>{s||(s=!0,n())};return r=t.subscribe(i=>{let a=!1,d=!1;for(let u of i)u[0]!==Ke&&(u[0]===w?e.emit(u[1]):u[0]===_?a=!0:u[0]===N?(d=!0,e.down([u])):(u[0]===G||u[0]===A)&&e.down([u]));d?(r?.(),r=void 0,o()):a&&o()}),()=>{r?.(),r=void 0}}function Ce(t,e,n){let r,s=!1;function o(){r?.(),r=void 0}return B([t],(i,a,d)=>{if(d.terminalDeps[0]!=null&&d.terminalDeps[0]!==!0){o();return}if(d.terminalDeps[0]===!0){s=!0,r||a.down([[_]]);return}let u=i[0];if(!(u==null||u.length===0))return o(),r=Gt(de(e(u[u.length-1])),a,()=>{o(),s&&a.down([[_]])}),{deactivate:()=>{o(),s=!1}}},{...V(n),completeWhenDepsComplete:!1})}function Os(t,e,n){let r,s=!1;function o(){r?.(),r=void 0}return B([t],(i,a,d)=>{if(d.terminalDeps[0]!=null&&d.terminalDeps[0]!==!0){o();return}if(d.terminalDeps[0]===!0){s=!0,r||a.down([[_]]);return}let u=i[0];if(!(u==null||u.length===0))return r===void 0?r=Gt(de(e(u[0])),a,()=>{o(),s&&a.down([[_]])}):a.down([[A]]),{deactivate:()=>{o(),s=!1}}},{...V(n),completeWhenDepsComplete:!1})}function Rs(t,e,n){let{maxBuffer:r,...s}=n??{},o=[],i,a=!1,d;function u(){i?.(),i=void 0}function c(){if(!d||i!==void 0)return;if(o.length===0){a&&d.down([[_]]);return}let f=o.shift();i=Gt(de(e(f)),d,()=>{u(),c()})}function p(f){r&&r>0&&o.length>=r&&o.shift(),o.push(f),c()}return B([t],(f,h,l)=>{if(d=h,l.terminalDeps[0]!=null&&l.terminalDeps[0]!==!0){u(),o.length=0;return}if(l.terminalDeps[0]===!0){a=!0,c();return}let m=f[0];if(!(m==null||m.length===0)){for(let b of m)p(b);return{deactivate:()=>{u(),o.length=0,a=!1}}}},{...V(s),completeWhenDepsComplete:!1})}function Or(t,e,n){let{concurrent:r,...s}=n??{},o=r!=null&&r>0?r:Number.POSITIVE_INFINITY,i=0,a=!1,d=new Set,u=[],c;function p(){a&&i===0&&u.length===0&&c&&c.down([[_]])}function f(b){if(!c)return;i++;let g;g=Gt(de(e(b)),c,()=>{g&&d.delete(g),i--,h(),p()}),d.add(g)}function h(){for(;u.length>0&&i<o;)f(u.shift())}function l(b){i<o?f(b):u.push(b)}function m(){for(let b of d)b();d.clear(),i=0,u.length=0}return B([t],(b,g,y)=>{if(c=g,y.terminalDeps[0]!=null&&y.terminalDeps[0]!==!0){m();return}if(y.terminalDeps[0]===!0){a=!0,p();return}let v=b[0];if(!(v==null||v.length===0)){for(let T of v)l(T);return{deactivate:()=>{m(),a=!1}}}},{...V(s),completeWhenDepsComplete:!1})}var Ms=Or;function As(t,e,n){return R(r=>{let s=new Set;function o(){for(let a of s)clearTimeout(a);s.clear()}let i=t.subscribe(a=>{for(let d of a)if(d[0]===w){let u=setTimeout(()=>{s.delete(u),r.emit(d[1])},e);s.add(u)}else if(d[0]===_){let u=setTimeout(()=>{s.delete(u),r.down([[_]])},e);s.add(u)}else d[0]===N&&(o(),r.down([d]))});return()=>{i(),o()}},V(n))}function Rr(t,e,n){return R(r=>{let s,o;function i(){s!==void 0&&(clearTimeout(s),s=void 0)}let a=t.subscribe(d=>{for(let u of d)u[0]===w?(i(),o=u[1],s=setTimeout(()=>{s=void 0,r.emit(o)},e)):u[0]===_?(s!==void 0&&(i(),r.emit(o)),r.down([[_]])):u[0]===N&&(i(),r.down([u]))});return()=>{a(),i()}},V(n))}function Mr(t,e,n){let{leading:r,trailing:s,...o}=n??{},i=r!==!1,a=s===!0,d=e*1e6;return R(u=>{let c,p=-1/0,f,h=!1;function l(){c!==void 0&&(clearTimeout(c),c=void 0)}let m=t.subscribe(b=>{for(let g of b)if(g[0]===w){let y=g[1],v=ne();if(i&&v-p>=d)p=v,u.emit(y),l(),a&&(c=setTimeout(()=>{c=void 0,h&&(p=ne(),u.emit(f),h=!1)},e));else if(a&&(f=y,h=!0,c===void 0)){let T=(v-p)/1e6;c=setTimeout(()=>{c=void 0,h&&(p=ne(),u.emit(f),h=!1)},Math.max(0,e-T))}}else(g[0]===_||g[0]===N)&&(l(),u.down([g]))});return()=>{m(),l()}},V(o))}function Cs(t,e,n){return R(r=>{let s,o=!1,i=!1,a=t.subscribe(u=>{if(!o)for(let c of u){if(o)return;c[0]===w?s={v:c[1]}:c[0]===N?(o=!0,r.down([c])):c[0]===_&&(i=!0,s=void 0)}}),d=e.subscribe(u=>{if(!o)for(let c of u){if(o)return;c[0]===w?s!==void 0&&!i&&r.emit(s.v):c[0]===N?(o=!0,r.down([c])):c[0]===_&&(o=!0,r.down([[_]]))}});return()=>{a(),d()}},V(n))}function Ds(t,e,n){return R(r=>{let s,o,i=!1;function a(){s!==void 0&&(clearTimeout(s),s=void 0)}let d=t.subscribe(u=>{for(let c of u)c[0]===w?(o=c[1],i=!0,a(),s=setTimeout(()=>{s=void 0,i&&(i=!1,r.emit(o))},e)):(c[0]===_||c[0]===N)&&(a(),r.down([c]))});return()=>{d(),a()}},V(n))}function Ps(t,e,n){return R(r=>{let s=[],o=t.subscribe(a=>{for(let d of a)d[0]===w?s.push(d[1]):d[0]===_?(s.length>0&&r.emit([...s]),s.length=0,r.down([[_]])):d[0]===N&&r.down([d])}),i=e.subscribe(a=>{for(let d of a)d[0]===w?s.length>0&&(r.emit([...s]),s.length=0):d[0]===_?r.down([[_]]):d[0]===N&&r.down([d])});return()=>{o(),i(),s.length=0}},V(n))}function Is(t,e,n){if(e<=0)throw new RangeError("bufferCount expects count > 0");return R(r=>{let s=[],o=t.subscribe(i=>{for(let a of i)a[0]===w?(s.push(a[1]),s.length>=e&&r.emit(s.splice(0,s.length))):a[0]===_?(s.length>0&&r.emit([...s]),s.length=0,r.down([[_]])):a[0]===N&&r.down([a])});return()=>{o(),s.length=0}},V(n))}function Ls(t,e,n){if(e<=0)throw new RangeError("windowCount expects count > 0");return R(r=>{let s,o=0;function i(){let d=R(u=>(s=u.down.bind(u),()=>{s=void 0}),V());o=0,r.emit(d)}let a=t.subscribe(d=>{for(let u of d)u[0]===w?(s||i(),s?.([[w,u[1]]]),o+=1,o>=e&&(s?.([[_]]),s=void 0)):u[0]===_?(s?.([[_]]),s=void 0,r.down([[_]])):u[0]===N&&(s?.([u]),s=void 0,r.down([u]))});return()=>{a(),s?.([[_]]),s=void 0}},V(n))}function Bs(t,e,n){return R(r=>{let s=[],o=setInterval(()=>{s.length>0&&(r.emit([...s]),s.length=0)},e),i=t.subscribe(a=>{for(let d of a)d[0]===w?s.push(d[1]):d[0]===_?(clearInterval(o),s.length>0&&r.emit([...s]),s.length=0,r.down([[_]])):d[0]===N&&(clearInterval(o),r.down([d]))});return()=>{i(),clearInterval(o),s.length=0}},V(n))}function Vs(t,e,n){return R(r=>{let s;function o(){s?.([[_]]),s=void 0}function i(){let u=R(c=>(s=c.down.bind(c),()=>{s=void 0}),V());r.emit(u)}i();let a=setInterval(()=>{o(),i()},e),d=t.subscribe(u=>{for(let c of u)c[0]===w?s?.([[w,c[1]]]):c[0]===_?(clearInterval(a),o(),r.down([[_]])):c[0]===N&&(clearInterval(a),s?.([c]),o(),r.down([c]))});return()=>{d(),clearInterval(a),o()}},V(n))}function Gs(t,e,n){return R(r=>{let s;function o(){s?.([[_]]),s=void 0}function i(){let u=R(c=>(s=c.down.bind(c),()=>{s=void 0}),V());r.emit(u)}let a=t.subscribe(u=>{for(let c of u)c[0]===w?(s||i(),s?.([[w,c[1]]])):c[0]===_?(o(),r.down([[_]])):c[0]===N&&(s?.([c]),s=void 0,r.down([c]))}),d=e.subscribe(u=>{for(let c of u)c[0]===w&&(o(),i())});return()=>{a(),d(),o()}},V(n))}function Fs(t,e){return R((n,r)=>{"n"in r.store||(r.store.n=0);let s=setInterval(()=>{n.emit(r.store.n),r.store.n=r.store.n+1},t);return()=>clearInterval(s)},V(e))}function $s(t,e,n){if(e<=0)throw new RangeError("repeat expects count > 0");return R(r=>{let s=e,o,i=()=>{o?.(),o=t.subscribe(a=>{let d=!1,u=[];for(let c of a)c[0]===_?d=!0:u.push(c);u.length>0&&r.down(u),d&&(o?.(),o=void 0,s-=1,s>0?i():r.down([[_]]))})};return i(),()=>{o?.()}},V(n))}function Ks(t,e){return B([t],(n,r)=>{let s=n[0];if(s==null||s.length===0){r.down([[A]]);return}for(let o of s)r.emit(o)},V(e))}function Ar(t,e,n){return R(r=>{let s=t.subscribe(o=>{for(let i of o)if(i[0]===w)r.emit(i[1]);else if(i[0]===N)try{r.emit(e(i[1]))}catch(a){r.down([[N,a]])}else i[0]===_&&r.down([[_]])});return()=>{s()}},V(n))}function zs(t,e,n){return B([t,e],(r,s,o)=>{let i=r[1];if(!(i!=null&&i.length>0?i.at(-1):o.prevData[1])){s.down([[A]]);return}let d=r[0];if(d!=null&&d.length>0){for(let u of d)s.emit(u);return}if(i!=null&&i.length>0&&o.prevData[0]!==void 0){s.emit(o.prevData[0]);return}s.down([[A]])},_r(n))}var js=Sr,Hs=Rr,Ws=Mr,Us=Ar;X();we();ue();mt();var qe=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let n=(this.head+this._size)%this.capacity;this.buf[n]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let n=e<0?this._size+e:e;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this.buf[(this.head+n)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};var $n=class{ring;arr;constructor(e){e===Number.POSITIVE_INFINITY||e<=0?(this.arr=[],this.ring=null):(this.ring=new qe(e),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(e){this.ring!=null?this.ring.push(e):this.arr.push(e)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let n=this.ring.toArray();return this.ring.clear(),n}let e=this.arr;return this.arr=[],e}};function Tt(t){return t instanceof Error?t:new Error(String(t))}function qs(t){return t===void 0?null:typeof t=="string"?je(t):t}function ie(t,e){let{name:n,onTransportError:r,retry:s,backpressure:o,batchSize:i=Number.POSITIVE_INFINITY,flushIntervalMs:a=0,serialize:d,stopOn:u,onUpstreamMessage:c,onDispose:p,send:f,sendBatch:h,ctx:l}=e;if(!f&&!h)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let m=l,b=Math.max(1,s?.maxAttempts??1),g=qs(s?.backoff??(b>1?"exponential":void 0)),y=s?.shouldRetry??(()=>!0),v=h!==void 0||i<Number.POSITIVE_INFINITY||a>0,T=C=>n?`${n}::${C}`:void 0,k=F(void 0,{equals:()=>!1,name:T("sent")}),x=F(null,{name:T("failed")}),E=F(0,{name:T("inFlight")}),S=F(null,{name:T("errors")}),M=v?F(0,{name:T("buffered")}):void 0,I=o?F(!1,{name:T("paused")}):void 0,D=0,L=C=>{D+=C,E.down([[w,D]])},O=C=>{try{r?.(C)}catch{}try{S.down([[w,C]])}catch{}},$=new Set,ee=C=>{$.add(C);let H=()=>$.delete(C);C.then(H,H)},z=(C,H,J)=>{let Q=g?g(H-1,J,null):0,ae=Q==null?0:typeof Q=="number"&&Q>0?Q:0,Se=Math.max(1,Math.ceil(ae/1e6));return new Promise(Y=>{setTimeout(()=>Y(C()),Se)})},te=C=>C!=null&&typeof C=="object"&&typeof C.then=="function",ke=C=>{let H;try{H=d?d(C):C}catch(Y){let W=Tt(Y);return O({stage:"serialize",error:W,value:C}),x.down([[w,{value:C,error:W,attempts:0}]]),Promise.resolve()}let J=0,Q=Y=>{L(-1);let W=Tt(Y);if(O({stage:"send",error:W,value:C,attempt:J}),!(J<b&&y(W,J))){x.down([[w,{value:C,error:W,attempts:J}]]);return}return z(Se,J,W)},ae=()=>{L(-1),k.down([[w,C]])};function Se(){J+=1,L(1);let Y;try{Y=f(H,m)}catch(W){return Q(W)??Promise.resolve()}return te(Y)?Y.then(ae,W=>Q(W)):(ae(),Promise.resolve())}return Se()},De=o?.maxBuffer??Number.POSITIVE_INFINITY,_e=new $n(De),ge,Ve=!1,P=()=>{M?.down([[w,_e.length]])},q=C=>{I&&I.down([[w,C]])},pe=o?.strategy??"drop-oldest",Ge=(C,H)=>{let J={value:C,payload:H};if(_e.length<De)return _e.push(J),P(),!0;if(pe==="drop-oldest"){let ae=_e.shift();return _e.push(J),P(),q(!0),x.down([[w,{value:ae.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(pe==="drop-newest")return q(!0),x.down([[w,{value:C,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let Q=new Error("backpressure: buffer overflow");return O({stage:"send",error:Q,value:C}),x.down([[w,{value:C,error:Q,attempts:0}]]),q(!0),!1},be=C=>{let H=0,J=C.map(Y=>Y.payload),Q=Y=>{L(-1);let W=Tt(Y);if(O({stage:"send",error:W,value:C.map(rn=>rn.value),attempt:H}),!(H<b&&y(W,H))){for(let{value:rn}of C)x.down([[w,{value:rn,error:W,attempts:H}]]);return}return z(Se,H,W)},ae=()=>{L(-1);for(let{value:Y}of C)k.down([[w,Y]])};function Se(){H+=1,L(1);let Y;try{Y=h(J,m)}catch(W){return Q(W)??Promise.resolve()}return te(Y)?Y.then(ae,W=>Q(W)):(ae(),Promise.resolve())}return Se()},U=async C=>{for(let H of C)await ce(H.value,H.payload)},ce=(C,H)=>{let J=0,Q=Y=>{L(-1);let W=Tt(Y);if(O({stage:"send",error:W,value:C,attempt:J}),!(J<b&&y(W,J))){x.down([[w,{value:C,error:W,attempts:J}]]);return}return z(Se,J,W)},ae=()=>{L(-1),k.down([[w,C]])};function Se(){J+=1,L(1);let Y;try{Y=f(H,m)}catch(W){return Q(W)??Promise.resolve()}return te(Y)?Y.then(ae,W=>Q(W)):(ae(),Promise.resolve())}return Se()},Pe=()=>{if(Ve||_e.length===0)return Promise.resolve();let C=_e.drain();if(P(),q(!1),h!==void 0){let J=be(C);return ee(J),J}let H=U(C);return ee(H),H},_o=()=>{ge!==void 0||Ve||a<=0||(ge=setTimeout(()=>{ge=void 0,Pe()},a))},No=t.subscribe(C=>{for(let H of C){let J=H[0];if(J!==w)try{c?.(H)}catch{}if(J===w){let Q=H[1];if(v){let ae;if(d)try{ae=d(Q)}catch(Y){let W=Tt(Y);O({stage:"serialize",error:W,value:Q}),x.down([[w,{value:Q,error:W,attempts:0}]]);continue}else ae=Q;if(!Ge(Q,ae))continue;_e.length>=i?Pe():_o()}else{let ae=ke(Q);ee(ae)}}else le.messageTier(J)>=3&&v&&(ge!==void 0&&(clearTimeout(ge),ge=void 0),Pe())}}),Jn;if(u){let C=!1;Jn=u.subscribe(H=>{if(!C){C=!0;return}H.length>0&&!nn&&Yn()})}let nn=!1,Yn=()=>{if(nn)return;nn=!0,ge!==void 0&&(clearTimeout(ge),ge=void 0),v&&Pe(),Ve=!0,Jn?.(),No();let C=H=>{try{H.down([[K]])}catch{}};C(S),C(x),C(k),C(E),M&&C(M),I&&C(I);try{p?.()}catch{}},kt={dispose:Yn,sent:k,failed:x,inFlight:E,errors:S};return v&&(kt.buffered=M,kt.flush=async()=>{Ve||(await Pe(),await Promise.all($))}),I&&(kt.paused=I),kt}Pt();Ie();function Re(t){return{describeKind:"producer",...t}}function Cr(t,e){let{parse:n,closeOnTeardown:r=!1,...s}=e??{};return R(o=>{let i=!0,a,d=()=>{let g=a;a=void 0,g?.()},u=g=>{i&&(i=!1,o.down([g]),d())},c=(g,y=g)=>{if(i)try{let v=g!==null&&typeof g=="object"&&"data"in g?g.data:g,T=n?n(v,y):v;o.emit(T)}catch(v){u([N,v])}},p=g=>{u([N,g])},f=()=>{u([_])};if(typeof t=="function"){try{if(a=t(c,p,f),typeof a!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(g){u([N,g])}return()=>{i=!1,d()}}let h=t,l=g=>c(g,g),m=g=>p(g),b=()=>f();return h.addEventListener("message",l),h.addEventListener("error",m),h.addEventListener("close",b),a=()=>{h.removeEventListener("message",l),h.removeEventListener("error",m),h.removeEventListener("close",b),r&&h.close()},()=>{i=!1,d()}},Re(s))}function Js(t,e){return tt(t,e)}function Dr(t,e){let{method:n="GET",headers:r,body:s,transform:o=v=>v.json(),timeoutNs:i=30*1e9,signal:a,completeAfterFetch:d=!1,refetchOnSubscribe:u=!1,...c}=e??{},p=F(0,{name:`${c.name??"http"}/fetchCount`}),f=F(0,{name:`${c.name??"http"}/lastUpdated`}),h=F(!1,{name:`${c.name??"http"}/fetched`}),l=0,m=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0,b=v=>{let T=new AbortController,k=!0;if(a?.aborted)return k=!1,v.down([[N,a.reason??new Error("Aborted")]]),()=>{};a?.addEventListener("abort",()=>T.abort(a.reason),{once:!0});let x=setTimeout(()=>T.abort(new Error("Request timeout")),Math.ceil(i/1e6));return fetch(t,{method:n,headers:r,body:m,signal:T.signal}).then(async E=>{if(clearTimeout(x),!k)return;if(!E.ok)throw new Error(`HTTP ${E.status}: ${E.statusText}`);let S=await o(E);k&&(j(()=>{l+=1,p.down([[w,l]]),f.down([[w,re()]]),h.down([[w,!0]]),v.emit(S)}),d&&v.down([[_]]))}).catch(E=>{clearTimeout(x),k&&(E&&E.name==="AbortError"||v.down([[N,E]]))}),()=>{k=!1,T.abort()}},g=R(v=>b({emit:T=>v.emit(T),down:T=>v.down(T)}),{...Re(c),resubscribable:u});return{...yt(g),fetchCount:p,lastUpdated:f,fetched:h}}function Ys(t,e,n){let{method:r="POST",headers:s={"Content-Type":"application/json"},serialize:o=l=>JSON.stringify(l),timeoutNs:i,batchFormat:a="json-array",batchSize:d,flushIntervalMs:u,retry:c,onTransportError:p}=n??{},f=async l=>{let m=i!==void 0?new AbortController:void 0,b;m&&i!==void 0&&(b=setTimeout(()=>m.abort(new Error("Request timeout")),Math.ceil(i/1e6)));try{let g=await fetch(e,{method:r,headers:s,body:l,signal:m?.signal}),y=async()=>{try{await g.arrayBuffer?.()}catch{}};if(!g.ok)throw await y(),new Error(`HTTP ${g.status}: ${g.statusText}`);await y()}finally{b!==void 0&&clearTimeout(b)}};return d!==void 0||u!==void 0?ie(t,{onTransportError:p,retry:c,batchSize:d,flushIntervalMs:u,sendBatch:async l=>{let m;a==="ndjson"?m=l.map(b=>{let g=o(b);return typeof g=="string"?g:new TextDecoder().decode(g)}).join(`
|
|
2
|
+
`):m=JSON.stringify(l),await f(m)}}):ie(t,{onTransportError:p,retry:c,serialize:o,send:async l=>{await f(l)}})}function Pr(t){return Symbol.keyFor(t)??t.description??"message"}function st(t,e){return typeof t=="string"?t:e(t)}function Ir(t,e){let n=`event: ${t}
|
|
3
3
|
`;if(e!==void 0){let r=e.split(/\r?\n/);for(let s of r)n+=`data: ${s}
|
|
4
4
|
`}return`${n}
|
|
5
|
-
`}function
|
|
5
|
+
`}function Qs(t,e){let{serialize:n=h=>{if(h instanceof Error)return h.message;try{return JSON.stringify(h)}catch{return String(h)}},dataEvent:r="data",errorEvent:s="error",completeEvent:o="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:d,signal:u,eventNameResolver:c=Pr}=e??{},p=new TextEncoder,f;return new ReadableStream({start(h){let l=!1,m,b=()=>{},g=()=>{l||(l=!0,m!==void 0&&clearInterval(m),u?.removeEventListener("abort",v),b(),h.close())};f=g;let y=(T,k)=>{l||h.enqueue(p.encode(Ir(T,k)))},v=()=>{l||g()};b=t.subscribe(T=>{for(let k of T){let x=k[0];if(!(le.isLocalOnly(x)&&!(x===G&&a))){if(x===w){y(r,st(k[1],n));continue}if(x===N){y(s,st(k[1],n)),g();return}if(x===_){y(o),g();return}!i&&x===A||y(c(x),k.length>1?st(k[1],n):void 0)}}}),d!==void 0&&d>0&&(m=setInterval(()=>{l||h.enqueue(p.encode(`: keepalive
|
|
6
6
|
|
|
7
|
-
`))},d)),u?.aborted?v():u?.addEventListener("abort",v,{once:!0})},cancel(){
|
|
7
|
+
`))},d)),u?.aborted?v():u?.addEventListener("abort",v,{once:!0})},cancel(){f?.()}})}function Xs(t,e){let{serialize:n=f=>{if(f instanceof Error)return f.message;try{return JSON.stringify(f)}catch{return String(f)}},dataEvent:r="data",errorEvent:s="error",completeEvent:o="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:d,signal:u,eventNameResolver:c=Pr}=e??{},p=new TextEncoder;return R(f=>{let h=!0,l,m=(y,v)=>{h&&f.emit(p.encode(Ir(y,v)))},b=()=>{h&&(h=!1,f.down([[_]]))},g=t.subscribe(y=>{if(h)for(let v of y){let T=v[0];if(!(le.isLocalOnly(T)&&!(T===G&&a))){if(T===w){m(r,st(v[1],n));continue}if(T===N){m(s,st(v[1],n)),h=!1,f.down([[_]]);return}if(T===_){m(o),h=!1,f.down([[_]]);return}!i&&T===A||m(c(T),v.length>1?st(v[1],n):void 0)}}});return d!==void 0&&d>0&&(l=setInterval(()=>{h&&f.emit(p.encode(`: keepalive
|
|
8
8
|
|
|
9
|
-
`))},d)),u?.aborted?
|
|
10
|
-
`);
|
|
11
|
-
`)){let o=s.trim();if(!o)continue;if(o.startsWith("# TYPE ")){let
|
|
12
|
-
`,flushIntervalMs:s=0,batchSize:o=Number.POSITIVE_INFINITY,onTransportError:i,mode:a}=n??{},u=s>0||o<Number.POSITIVE_INFINITY?ie(t,{onTransportError:i,batchSize:o,flushIntervalMs:s,serialize:r,sendBatch:
|
|
13
|
-
`)?`"${t.replace(/"/g,'""')}"`:t}function
|
|
9
|
+
`))},d)),u?.aborted?b():u?.addEventListener("abort",b,{once:!0}),()=>{h=!1,l!==void 0&&clearInterval(l),u?.removeEventListener("abort",b),g()}})}function Zs(t){let e,n=!1;return new ReadableStream({start(r){e=t.subscribe(s=>{for(let o of s){let i=o[0];if(n)return;if(i===w)try{r.enqueue(o[1])}catch{n=!0,e?.()}else if(i===N){n=!0;try{r.error(o[1])}catch{}return}else if(i===_){n=!0;try{r.close()}catch{}return}}})},cancel(){n=!0,e?.()}})}async function*Lr(t,e){let n=e?.parse??(k=>k),r=e?.signal,s=new TextDecoder,o="",i="message",a=[],d,u,c=[],p=()=>{if(a.length===0&&i==="message"&&d===void 0){a=[];return}let k=a.join(`
|
|
10
|
+
`);c.push({event:i,data:n(k),id:d,retry:u}),i="message",a=[],d=void 0,u=void 0},f=k=>{if(k===""){p();return}if(k.startsWith(":"))return;let x=k.indexOf(":"),E=x<0?k:k.slice(0,x),S=x<0?"":k.slice(x+1);switch(S.startsWith(" ")&&(S=S.slice(1)),E){case"event":i=S;break;case"data":a.push(S);break;case"id":S.includes("\0")||(d=S);break;case"retry":{let M=Number(S);Number.isFinite(M)&&(u=M);break}}},h=(k,x)=>{o+=s.decode(k,{stream:!x});let E=o.split(/\r?\n/);o=E.pop()??"";for(let S of E)f(S)},l=t,m=t instanceof ReadableStream?t:l&&typeof l=="object"&&l.body instanceof ReadableStream?l.body:null,b,g,y=!1,v=()=>{y||(y=!0,b&&b.cancel().catch(()=>{}),g&&typeof g.return=="function"&&Promise.resolve(g.return()).catch(()=>{}))},T=()=>{v()};if(r){if(r.aborted)return;r.addEventListener("abort",T,{once:!0})}try{if(m){for(b=m.getReader();!r?.aborted;){let{value:k,done:x}=await b.read();if(x)break;for(h(k,!1);c.length>0;)yield c.shift()}h(new Uint8Array,!0)}else{for(g=t[Symbol.asyncIterator]();!r?.aborted;){let x=await g.next();if(x.done)break;for(h(x.value,!1);c.length>0;)yield c.shift()}h(new Uint8Array,!0)}if(o.trim()){for(let k of o.split(/\r?\n/))f(k);p()}for(;c.length>0;)yield c.shift()}finally{r&&r.removeEventListener("abort",T),v()}}function ei(t,e){let{parse:n,...r}=e??{};return R(s=>{let o=!0,i=new AbortController;return(async()=>{try{for await(let d of Lr(t,{parse:n,signal:i.signal})){if(!o)return;s.emit(d)}o&&s.down([[_]])}catch(d){o&&s.down([[N,d]])}})(),()=>{o=!1,i.abort()}},Re(r))}function ti(t,e){let{method:n="GET",headers:r,body:s,signal:o,...i}=e??{};return R(a=>{let d=!0,u=new AbortController;if(o?.aborted)return a.down([[N,o.reason??new Error("Aborted")]]),()=>{};o?.addEventListener("abort",()=>u.abort(o.reason),{once:!0});let c=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0;return(async()=>{try{let f=await fetch(t,{method:n,headers:r,body:c,signal:u.signal});if(!d)return;if(!f.ok)throw new Error(`HTTP ${f.status}: ${f.statusText}`);if(!f.body)throw new Error("HTTP response has no body");let h=f.body.getReader();for(;d;){let{value:l,done:m}=await h.read();if(m)break;l&&a.emit(l)}d&&a.down([[_]])}catch(f){if(!d||f&&f.name==="AbortError")return;a.down([[N,f]])}})(),()=>{d=!1,u.abort()}},Re(i))}function ni(t,e){let{intervalMs:n=5e3,...r}=e??{};return Ce(We(n,{period:n}),()=>Dr(t,{...r,completeAfterFetch:!0}).node)}function ri(t,e,n){let{serialize:r=g=>{if(typeof g=="string"||g instanceof Blob||g instanceof ArrayBuffer||ArrayBuffer.isView(g))return g;try{return JSON.stringify(g)}catch{return String(g)}},closeOnComplete:s=!0,closeOnError:o=!0,closeCode:i,closeReason:a,onTransportError:d,retry:u,backpressure:c,stopOn:p}=n??{},f=!1,h=g=>{if(!f){f=!0;try{e.close(i,a)}catch(y){let v=y instanceof Error?y:new Error(String(y));try{d?.({stage:"close",error:v,value:void 0,message:g})}catch{}}}},l=null,b=ie(t,{onTransportError:d,serialize:g=>{let y=r(g);if(y===void 0)throw new Error("serialize returned undefined");return y},retry:u,backpressure:c,stopOn:p,onDispose:()=>{if(l){try{e.removeEventListener("close",l)}catch{}l=null}},send:g=>{e.send(g)},onUpstreamMessage:g=>{(g[0]===_&&s||g[0]===N&&o)&&h(g)}});return l=()=>{f=!0,b.dispose()},e.addEventListener("close",l),b}function oi(t,e){let{parse:n,maxRetries:r,backoff:s="exponential",closeOnTeardown:o=!0,...i}=e??{};return bt(()=>Cr(t(),{parse:n,closeOnTeardown:o,...i}),{count:r,backoff:s})}function si(t,e){let{method:n="notifications/message",onDisconnect:r,...s}=e??{};return tt(({emit:o,error:i})=>(t.setNotificationHandler(n,a=>o(a)),r?.(a=>i(a??new Error("MCP client disconnected"))),()=>t.setNotificationHandler(n,()=>{})),s)}function ii(t,e){return Nn(({traces:r,metrics:s,logs:o,error:i})=>t({onTraces:a=>{j(()=>{for(let d of a)r(d)})},onMetrics:a=>{j(()=>{for(let d of a)s(d)})},onLogs:a=>{j(()=>{for(let d of a)o(d)})},onError:i})??void 0,["traces","metrics","logs"],e?.name?{name:e.name}:void 0)}function ai(t,e){return tt(t,e)}function ui(t){let e=t.match(/^<(\d{1,3})>\d?\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*)/s);if(!e){let r=re();return{facility:1,severity:6,timestamp:new Date(Math.floor(r/1e6)).toISOString(),hostname:"-",appName:"-",procId:"-",msgId:"-",message:t.trim(),timestampNs:r}}let n=Number(e[1]);return{facility:n>>3,severity:n&7,timestamp:e[2],hostname:e[3],appName:e[4],procId:e[5],msgId:e[6],message:(e[7]??"").trim(),timestampNs:re()}}function di(t,e){return tt(t,e)}var ci={c:"counter",g:"gauge",ms:"timer",h:"histogram",s:"set",d:"distribution"};function li(t){let e=t.split("|"),[n,r]=(e[0]??"").split(":");if(!n||r===void 0)throw new Error(`Invalid StatsD line: ${t}`);let s=e[1]?.trim()??"c",o=ci[s]??"counter",i=o==="set"?0:Number(r),a,d={};for(let u=2;u<e.length;u++){let c=e[u].trim();if(c.startsWith("@"))a=Number(c.slice(1));else if(c.startsWith("#"))for(let p of c.slice(1).split(",")){let[f,h]=p.split(":");f&&(d[f]=h??"")}}return{name:n.trim(),value:i,type:o,sampleRate:a,tags:d,timestampNs:re()}}function fi(t,e){let{intervalNs:n=15*1e9,headers:r,timeoutNs:s=10*1e9,signal:o,maxConsecutiveErrors:i=1}=e??{},a=Math.ceil(n/1e6),d=0;return Ce(We(0,{period:a,signal:o}),()=>R(u=>{let c=!0,p=new AbortController,f=setTimeout(()=>p.abort(new Error("Scrape timeout")),Math.ceil(s/1e6));return(async()=>{try{let l=await fetch(t,{headers:{Accept:"text/plain",...r},signal:p.signal});if(clearTimeout(f),!c)return;if(!l.ok)throw new Error(`Prometheus scrape ${l.status}: ${l.statusText}`);let m=await l.text();if(!c)return;let b=Br(m);for(let g of b)u.emit(g);d=0,u.down([[_]])}catch(l){if(clearTimeout(f),!c||l instanceof Error&&l.name==="AbortError")return;d+=1,d>=i&&u.down([[N,l]])}})(),()=>{c=!1,clearTimeout(f),p.abort()}}))}function Br(t){let e=[],n=new Map,r=new Map;for(let s of t.split(`
|
|
11
|
+
`)){let o=s.trim();if(!o)continue;if(o.startsWith("# TYPE ")){let f=o.slice(7),h=f.indexOf(" ");h>0&&n.set(f.slice(0,h),f.slice(h+1).trim());continue}if(o.startsWith("# HELP ")){let f=o.slice(7),h=f.indexOf(" ");h>0&&r.set(f.slice(0,h),f.slice(h+1).trim());continue}if(o.startsWith("#"))continue;let i,a={},d,u,c=o.indexOf("{");if(c>=0){i=o.slice(0,c);let f=o.indexOf("}",c);if(f<0)continue;let h=o.slice(c+1,f);a=pi(h);let l=o.slice(f+1).trim().split(/\s+/);d=l[0]??"",u=l[1]}else{let f=o.split(/\s+/);i=f[0]??"",d=f[1]??"",u=f[2]}if(!i||!d)continue;let p=i.replace(/(_total|_count|_sum|_bucket|_created|_info)$/,"");e.push({name:i,labels:a,value:Number(d),timestampMs:u?Number(u):void 0,type:n.get(p)??n.get(i),help:r.get(p)??r.get(i),timestampNs:re()})}return e}function pi(t){let e={},n=/(\w+)="((?:[^"\\]|\\.)*)"/g,r=n.exec(t);for(;r!==null;)e[r[1]]=r[2].replace(/\\(.)/g,"$1"),r=n.exec(t);return e}function hi(t,e,n){let{fromBeginning:r=!1,deserialize:s=i=>{if(i===null)return null;try{return JSON.parse(i.toString())}catch{return i.toString()}},...o}=n??{};return R(i=>{let a=!0;return(async()=>{try{await t.subscribe({topic:e,fromBeginning:r}),await t.run({eachMessage:async({topic:u,partition:c,message:p})=>{if(!a)return;let f={};if(p.headers)for(let[h,l]of Object.entries(p.headers))l!==void 0&&(f[h]=typeof l=="string"?l:l.toString());i.emit({topic:u,partition:c,key:p.key?.toString()??null,value:s(p.value),headers:f,offset:p.offset,timestamp:p.timestamp,timestampNs:re()})}})}catch(u){a&&i.down([[N,u]])}})(),()=>{a=!1}},Re(o))}function mi(t,e,n,r){let{serialize:s=a=>JSON.stringify(a),keyExtractor:o,onTransportError:i}=r??{};return ie(t,{onTransportError:i,send:async a=>{let d=o?.(a)??null,u=s(a);await e.send({topic:n,messages:[{key:d,value:Buffer.from(u)}]})}})}function gi(t,e,n){let{blockMs:r=5e3,startId:s="$",parse:o=a=>{for(let u=0;u<a.length;u+=2)if(a[u]==="data")try{return JSON.parse(a[u+1])}catch{return a[u+1]}let d={};for(let u=0;u<a.length;u+=2)d[a[u]]=a[u+1];return d},...i}=n??{};return R(a=>{let d=!0,u=s;return(async()=>{for(;d;)try{let p=await t.xread("BLOCK",r,"STREAMS",e,u);if(!d)return;if(p)for(let[f,h]of p)for(let[l,m]of h)u=l,a.emit({id:l,key:e,data:o(m),timestampNs:re()})}catch(p){if(!d)return;a.down([[N,p]]);return}})(),()=>{d=!1}},Re(i))}function bi(t,e,n,r){let{serialize:s=a=>["data",JSON.stringify(a)],maxLen:o,onTransportError:i}=r??{};return ie(t,{onTransportError:i,send:async a=>{let d=s(a);await(o!==void 0?e.xadd(n,"MAXLEN","~",String(o),"*",...d):e.xadd(n,"*",...d))}})}function yi(t,e){let{delimiter:n=",",hasHeader:r=!0,columns:s,parseLine:o,...i}=e??{},a=o??(d=>Vr(d,n));return R(d=>{let u=!1;return(async()=>{try{let p=s,f="";for await(let h of t){if(u)return;f+=h;let l=f.split(/\r?\n/);f=l.pop()??"";for(let m of l){if(u)return;if(!m.trim())continue;let b=a(m);if(!p&&r){p=b;continue}p||(p=b.map((y,v)=>`col${v}`));let g={};for(let y=0;y<p.length;y++)g[p[y]]=b[y]??"";d.emit(g)}}if(!u&&f.trim()){let h=a(f);if(p){let l={};for(let m=0;m<p.length;m++)l[p[m]]=h[m]??"";d.emit(l)}}u||d.down([[_]])}catch(p){u||d.down([[N,p]])}})(),()=>{u=!0}},Re(i))}function vi(t,e){let{delimiter:n=",",hasHeader:r=!0,columns:s,parseLine:o,...i}=e??{},a=o??(d=>Vr(d,n));return B([t],(d,u,c)=>{let p=d[0];if(p==null||p.length===0)return;let f=c.store;typeof f.buffer!="string"&&(f.buffer=""),f.headers===void 0&&s&&(f.headers=s.slice());for(let h of p){f.buffer=f.buffer+h;let l=f.buffer.split(/\r?\n/);f.buffer=l.pop()??"";for(let m of l){if(!m.trim())continue;let b=a(m);if(!f.headers&&r){f.headers=b;continue}f.headers||(f.headers=b.map((y,v)=>`col${v}`));let g={};for(let y=0;y<f.headers.length;y++)g[f.headers[y]]=b[y]??"";u.emit(g)}}},{describeKind:"derived",...i})}function Ti(t,e){return B([t],(n,r,s)=>{let o=n[0];if(o==null||o.length===0)return;let i=s.store;typeof i.buffer!="string"&&(i.buffer="");for(let a of o){i.buffer=i.buffer+a;let d=i.buffer.split(/\r?\n/);i.buffer=d.pop()??"";for(let u of d)if(u.trim())try{r.emit(JSON.parse(u))}catch(c){r.down([[N,c]]);return}}},{describeKind:"derived",...e??{}})}function Vr(t,e){let n=[],r="",s=!1;for(let o=0;o<t.length;o++){let i=t[o];s?i==='"'?t[o+1]==='"'?(r+='"',o++):s=!1:r+=i:i==='"'?s=!0:i===e?(n.push(r),r=""):r+=i}return n.push(r),n}function wi(t,e){return R(n=>{let r=!1;return(async()=>{try{let o="";for await(let i of t){if(r)return;o+=i;let a=o.split(/\r?\n/);o=a.pop()??"";for(let d of a){if(r)return;let u=d.trim();u&&n.emit(JSON.parse(u))}}!r&&o.trim()&&n.emit(JSON.parse(o.trim())),r||n.down([[_]])}catch(o){r||n.down([[N,o]])}})(),()=>{r=!0}},Re(e))}function xi(t,e,n){let{intervalNs:r=5*1e9,format:s="JSONEachRow",signal:o,maxConsecutiveErrors:i=1}=n??{},a=Math.ceil(r/1e6),d=0;return Ce(We(0,{period:a,signal:o}),()=>R(u=>{let c=!0;return(async()=>{try{let f=await t.query({query:e,format:s});if(!c)return;let h=await f.json();if(!c)return;for(let l of h)u.emit(l);d=0,u.down([[_]])}catch(f){if(!c)return;d+=1,d>=i&&u.down([[N,f]])}})(),()=>{c=!1}}))}function ki(t,e){let{autoAck:n=!0,deserialize:r=a=>{try{return JSON.parse(a.toString())}catch{return a.toString()}},onAckError:s,...o}=e??{},i=a=>{if(s)try{s(a instanceof Error?a:new Error(String(a)))}catch{}};return R(a=>{let d=!0;return(async()=>{for(;d;)try{let c=await t.receive();if(!d)return;let p={topic:c.getTopicName(),messageId:c.getMessageId().toString(),key:c.getPartitionKey(),value:r(c.getData()),properties:c.getProperties(),publishTime:c.getPublishTimestamp(),eventTime:c.getEventTimestamp(),timestampNs:re()};if(n)a.emit(p),t.acknowledge(c).catch(i);else{let f=!1,h={value:p,ack(){f||(f=!0,t.acknowledge(c).catch(i))},nack(l){if(f)return;f=!0;let m=t;try{let b=m.negativeAcknowledge?.(c);b&&typeof b.then=="function"&&b.catch(i)}catch(b){i(b)}}};a.emit(h)}}catch(c){d&&a.down([[N,c]]);return}})(),()=>{d=!1}},Re(o))}function _i(t,e,n){let{serialize:r=a=>Buffer.from(JSON.stringify(a)),keyExtractor:s,propertiesExtractor:o,onTransportError:i}=n??{};return ie(t,{onTransportError:i,send:async a=>{await e.send({data:r(a),partitionKey:s?.(a),properties:o?.(a)})}})}function Ni(t,e,n){let r=new TextDecoder,{queue:s,deserialize:o=a=>{let d=r.decode(a);try{return JSON.parse(d)}catch{return d}},...i}=n??{};return R(a=>{let d=!0,u=t.subscribe(e,s?{queue:s}:void 0);return(async()=>{try{for await(let p of u){if(!d)return;let f={};if(p.headers)for(let h of p.headers.keys())f[h]=p.headers.get(h);a.emit({subject:p.subject,data:o(p.data),headers:f,reply:p.reply,sid:p.sid,timestampNs:re()})}d&&a.down([[_]])}catch(p){d&&a.down([[N,p]])}})(),()=>{d=!1}},Re(i))}function Ei(t,e,n,r){let s=new TextEncoder,{serialize:o=a=>s.encode(JSON.stringify(a)),onTransportError:i}=r??{};return ie(t,{onTransportError:i,send:a=>{e.publish(n,o(a))}})}function Si(t,e,n){let{autoAck:r=!0,deserialize:s=d=>{try{return JSON.parse(d.toString())}catch{return d.toString()}},onAckError:o,...i}=n??{},a=d=>{if(o)try{o(d instanceof Error?d:new Error(String(d)))}catch{}};return R(d=>{let u=!0,c;return(async()=>{try{c=(await t.consume(e,h=>{if(!u)return;if(h===null){u&&d.down([[N,new Error("Consumer cancelled by broker")]]);return}let l={queue:e,routingKey:h.fields.routingKey,exchange:h.fields.exchange,content:s(h.content),properties:h.properties,deliveryTag:h.fields.deliveryTag,redelivered:h.fields.redelivered,timestampNs:re()};if(r){d.emit(l);try{t.ack(h)}catch(m){a(m)}}else{let m=!1,b=t,g={value:l,ack(){if(!m){m=!0;try{t.ack(h)}catch(y){a(y)}}},nack(y){if(m)return;m=!0;let v=y?.requeue;if(!b.nack){a(new Error("RabbitMQ channel does not expose `nack`; cannot negative-ack"));return}try{b.nack(h,!1,v)}catch(T){a(T)}}};d.emit(g)}},{noAck:!1})).consumerTag}catch(f){u&&d.down([[N,f]])}})(),()=>{u=!1,c!==void 0&&t.cancel(c)}},Re(i))}function Oi(t,e,n,r){let{serialize:s=a=>Buffer.from(JSON.stringify(a)),routingKeyExtractor:o=()=>"",onTransportError:i}=r??{};return ie(t,{onTransportError:i,send:a=>{let d=o(a),u=s(a);e.publish(n,d,u)}})}function Gr(t,e,n){let{serialize:r=p=>`${JSON.stringify(p)}
|
|
12
|
+
`,flushIntervalMs:s=0,batchSize:o=Number.POSITIVE_INFINITY,onTransportError:i,mode:a}=n??{},u=s>0||o<Number.POSITIVE_INFINITY?ie(t,{onTransportError:i,batchSize:o,flushIntervalMs:s,serialize:r,sendBatch:p=>{e.write(p.join(""))}}):ie(t,{onTransportError:i,serialize:r,send:p=>{e.write(p)}}),c=u.dispose;return u.dispose=()=>{c();try{e.end()}catch{}},u}function Kn(t,e){return t.includes(e)||t.includes('"')||t.includes(`
|
|
13
|
+
`)?`"${t.replace(/"/g,'""')}"`:t}function Ri(t,e,n){let{columns:r,delimiter:s=",",writeHeader:o=!0,cellExtractor:i=(h,l)=>String(h[l]??""),flushIntervalMs:a=0,batchSize:d=Number.POSITIVE_INFINITY,onTransportError:u,...c}=n,p=!1;return Gr(t,e,{serialize:h=>{if(!p&&o){p=!0;let l=r.map(b=>Kn(b,s)).join(s),m=r.map(b=>Kn(i(h,b),s)).join(s);return`${l}
|
|
14
14
|
${m}
|
|
15
|
-
`}return`${r.map(l
|
|
16
|
-
`},flushIntervalMs:a,batchSize:d,onTransportError:u,...c})}function
|
|
15
|
+
`}return`${r.map(l=>Kn(i(h,l),s)).join(s)}
|
|
16
|
+
`},flushIntervalMs:a,batchSize:d,onTransportError:u,...c})}function Mi(t,e,n,r){let{batchSize:s=1e3,flushIntervalMs:o=5e3,format:i="JSONEachRow",transform:a=u=>u,onTransportError:d}=r??{};return ie(t,{onTransportError:d,batchSize:s,flushIntervalMs:o,serialize:a,sendBatch:async u=>{await e.insert({table:n,values:u,format:i})}})}function Ai(t,e,n,r){let{format:s="ndjson",keyGenerator:o=(f,h)=>{let l=Math.floor(h/1e6);return`data/${new Date(l).toISOString().replace(/[:.]/g,"-")}-${f}.${s==="ndjson"?"ndjson":"json"}`},batchSize:i=1e3,flushIntervalMs:a=1e4,transform:d=f=>f,onTransportError:u}=r??{},c=s==="ndjson"?"application/x-ndjson":"application/json",p=0;return ie(t,{onTransportError:u,batchSize:i,flushIntervalMs:a,serialize:d,sendBatch:async f=>{p+=1;let h=s==="ndjson"?`${f.map(m=>JSON.stringify(m)).join(`
|
|
17
17
|
`)}
|
|
18
|
-
`:JSON.stringify(p),l=o(f,re());await e.putObject({Bucket:n,Key:l,Body:h,ContentType:c})}})}function _i(t,e,n,r){let{toSQL:s=(i,a)=>({sql:`INSERT INTO "${a.replace(/"/g,'""')}" (data) VALUES ($1)`,params:[JSON.stringify(i)]}),onTransportError:o}=r??{};return ie(t,{onTransportError:o,serialize:i=>s(i,n),send:async i=>{let a=i;await e.query(a.sql,a.params)}})}function Ni(t,e,n){let{toDocument:r=o=>o,onTransportError:s}=n??{};return ie(t,{onTransportError:s,serialize:r,send:async o=>{await e.insertOne(o)}})}function Ei(t,e,n){let{labels:r={},toLine:s=a=>JSON.stringify(a),toLabels:o,onTransportError:i}=n??{};return ie(t,{onTransportError:i,serialize:a=>({line:s(a),labels:o?{...r,...o(a)}:r}),send:async a=>{let{line:d,labels:u}=a,c=`${re()}`;await e.push({streams:[{stream:u,values:[[c,d]]}]})}})}function Si(t,e,n){let{toResourceSpans:r=o=>[o],onTransportError:s}=n??{};return ie(t,{onTransportError:s,serialize:r,send:async o=>{await e.push({resourceSpans:o})}})}function Oi(t,e,n,r){let{prefix:s="checkpoints/",debounceMs:o=500,compactEvery:i=10,onError:a}=r??{},d={debounceMs:o,compactEvery:i,save(u,c){let f=Math.floor(re()/1e6),p=`${s}${t.name}/checkpoint-${f}.json`,h;try{h=JSON.stringify(c)}catch(l){a?.(l);return}e.putObject({Bucket:n,Key:p,Body:h,ContentType:"application/json"}).catch(l=>a?.(l))},load(){return null}};return t.attachStorage([d],{onError:u=>a?.(u)})}function Ri(t,e,n){let{prefix:r="graphrefly:checkpoint:",debounceMs:s=500,compactEvery:o=10,onError:i}=n??{},a=`${r}${t.name}`,d={debounceMs:s,compactEvery:o,save(u,c){let f;try{f=JSON.stringify(c)}catch(p){i?.(p);return}e.set(a,f).catch(p=>i?.(p))},async load(){let u=await e.get(a);if(u==null)return null;try{return JSON.parse(u)}catch{return null}}};return t.attachStorage([d],{onError:u=>i?.(u)})}function Mi(t,e,n){let{mapRow:r=i=>i,params:s,...o}=n??{};return R(i=>{try{let d=t.query(e,s).map(r);i.emit(d),i.down([[x]])}catch(a){i.down([[N,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function Ai(t,e,n){let{mapRow:r=i=>i,params:s,...o}=n??{};return R(i=>{try{let a=t.iterate(e,s);j(()=>{for(let d of a)i.emit(r(d));i.down([[x]])})}catch(a){i.down([[N,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function Ci(t,e,n,r){if(n.includes("\0")||n.length===0)throw new Error(`toSqlite: invalid table name: ${JSON.stringify(n)}`);let{toSQL:s=(O,$)=>({sql:`INSERT INTO "${$.replace(/"/g,'""')}" (data) VALUES (?)`,params:[JSON.stringify(O)]}),onTransportError:o,batchInsert:i=!1,maxBatchSize:a=1e3,flushIntervalMs:d=0}=r??{},u=O=>s(O,n);if(!i)return ie(t,{onTransportError:o,serialize:u,send:O=>{let $=O;e.query($.sql,$.params)}});let c=F(null),f=F(void 0,{equals:()=>!1}),p=F(null),h=F(0),l=F(0),m=O=>{try{o?.(O)}catch{}try{c.down([[w,O]])}catch{}},g=[],b=!1,y,v=!1,T=()=>l.down([[w,g.length]]),k=O=>{v||f.down([[w,O]])},_=O=>{v||p.down([[w,O]])},E=O=>{v||h.down([[w,O]])},S=O=>{v||m(O)},A=()=>{if(g.length===0||b)return;b=!0,E(1);try{e.query("BEGIN",[])}catch(z){b=!1,E(0),S({stage:"send",error:z instanceof Error?z:new Error(String(z)),value:void 0});return}let O=g;g=[],T();let $,ee=0;for(let z of O)try{e.query(z.query.sql,z.query.params),ee+=1}catch(te){$=te instanceof Error?te:new Error(String(te));break}if($){try{e.query("ROLLBACK",[])}catch{}S({stage:"send",error:$,value:void 0});for(let z of O)_({value:z.value,error:$,attempts:1})}else try{e.query("COMMIT",[]);for(let z of O)k(z.value)}catch(z){let te=z instanceof Error?z:new Error(String(z));S({stage:"send",error:te,value:void 0});for(let ke=0;ke<ee;ke++)_({value:O[ke].value,error:te,attempts:1})}b=!1,E(0)},I=()=>{d>0&&y===void 0&&!v&&(y=setTimeout(()=>{y=void 0,A()},d))},D=t.subscribe(O=>{for(let $ of O){let ee=$[0];if(ee===w){let z=$[1],te;try{te=u(z)}catch(ke){let De=ke instanceof Error?ke:new Error(String(ke));m({stage:"serialize",error:De,value:z}),p.down([[w,{value:z,error:De,attempts:0}]]);continue}g.push({value:z,query:te}),T(),g.length>=a?A():I()}else le.messageTier(ee)>=3&&A()}});return{dispose:()=>{if(!v){y!==void 0&&(clearTimeout(y),y=void 0),A(),v=!0,D();for(let O of[c,f,p,h,l])try{O.down([[K]])}catch{}}},sent:f,failed:p,inFlight:h,errors:c,buffered:l,flush:async()=>{v||A()}}}function Di(t,e){let{args:n,mapRow:r=o=>o,...s}=e??{};return R(o=>{let i=!0;return t.findMany(n).then(a=>{i&&(o.emit(a.map(r)),o.down([[x]]))}).catch(a=>{if(i)try{o.down([[N,a instanceof Error?a:new Error(String(a))]])}catch{}}),()=>{i=!1}},{...s,describeKind:"producer",completeWhenDepsComplete:!1})}function Pi(t,e){let{mapRow:n=s=>s,...r}=e??{};return R(s=>{let o=!0;return t.execute().then(i=>{o&&(s.emit(i.map(n)),s.down([[x]]))}).catch(i=>{if(o)try{s.down([[N,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}function Ii(t,e){let{mapRow:n=s=>s,...r}=e??{};return R(s=>{let o=!0;return t.execute().then(i=>{o&&(s.emit(i.map(n)),s.down([[x]]))}).catch(i=>{if(o)try{s.down([[N,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}mt();X();var Li=0;function Bi(t,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let n=Symbol(`bp-${++Li}`),r=0,s=!1;return{onEnqueue(){return r+=1,!s&&r>=e.highWaterMark?(s=!0,t([[me,n]]),!0):!1},onDequeue(){return r>0&&(r-=1),s&&r<=e.lowWaterMark?(s=!1,t([[Te,n]]),!0):!1},get pending(){return r},get paused(){return s},dispose(){s&&(s=!1,t([[Te,n]]))}}}X();ue();function Br(){let t=new Map,e=null,n=null;function r(o){o.prev?o.prev.next=o.next:e=o.next,o.next?o.next.prev=o.prev:n=o.prev,o.prev=null,o.next=null}function s(o){o.next=e,o.prev=null,e&&(e.prev=o),e=o,n===null&&(n=o)}return{insert(o){if(t.has(o)){this.touch(o);return}let i={key:o,prev:null,next:null};t.set(o,i),s(i)},touch(o){let i=t.get(o);i&&(r(i),s(i))},delete(o){let i=t.get(o);i&&(r(i),t.delete(o))},evict(o){let i=[];for(let a=0;a<o&&n!==null;a++){let d=n;i.push(d.key),r(d),t.delete(d.key)}return i},size(){return t.size}}}function Vr(t){return t!=null&&typeof t.then=="function"}function it(t){Vr(t)&&t.catch(()=>{})}function Vi(t,e){let n=new Map,r=e?.maxSize??0,s=r>0?e?.eviction??Br():null,o=e?.writeThrough??!1;function i(u,c,f){for(let p=0;p<f;p++)try{it(t[p].save(u,c))}catch{}}function a(u,c,f=0){for(let p=f;p<t.length;p++){let h;try{h=t[p].load(u)}catch{continue}if(Vr(h)){let l=p;h.then(m=>{m!=null?(c.down([[w,m]]),i(u,m,l)):a(u,c,l+1)},()=>{a(u,c,l+1)});return}if(h!=null){c.down([[w,h]]),i(u,h,p);return}}}function d(){if(!(!s||r<=0))for(;s.size()>=r;){let u=s.evict(1);if(u.length===0)break;for(let c of u){let f=n.get(c);if(f){let p=f.cache;if(f.status!=="sentinel"&&t.length>0){let h=t.length-1;try{it(t[h].save(c,p))}catch{}for(let l=0;l<h;l++)try{let m=t[l].clear;m&&it(m.call(t[l],c))}catch{}}f.down([[K]])}n.delete(c)}}}return{load(u){let c=n.get(u);if(c)return s?.touch(u),c;s&&r>0&&s.size()>=r&&d();let f=F(void 0);return n.set(u,f),s?.insert(u),a(u,f),f},save(u,c){if(o)for(let p of t)try{it(p.save(u,c))}catch{}else if(t[0])try{it(t[0].save(u,c))}catch{}let f=n.get(u);if(f)f.down([[w,c]]),s?.touch(u);else{s&&r>0&&s.size()>=r&&d();let p=F(c);n.set(u,p),s?.insert(u)}},invalidate(u){let c=n.get(u);c&&a(u,c)},delete(u){s?.delete(u);let c=n.get(u);c&&c.down([[K]]),n.delete(u);for(let f of t)try{let p=f.clear;p&&it(p.call(f,u))}catch{}},has(u){return n.has(u)},get size(){return n.size}}}ye();X();ue();ye();Le();X();ue();var Ft=class{_version=0;_store=new Map;_maxSize;_defaultTtl;constructor(e={}){let{maxSize:n,defaultTtl:r}=e;if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(r!==void 0&&r<=0)throw new RangeError("defaultTtl must be positive");this._maxSize=n,this._defaultTtl=r}get version(){return this._version}get size(){return this._store.size}has(e){let n=this._store.get(e);return n===void 0?!1:this._isExpired(n)?(this._store.delete(e),this._version+=1,!1):(this._touchLru(e,n),!0)}get(e){let n=this._store.get(e);if(n!==void 0){if(this._isExpired(n)){this._store.delete(e),this._version+=1;return}return this._touchLru(e,n),n.value}}set(e,n,r){let s=this._resolveExpiresAt(r);this._store.has(e)&&this._store.delete(e),this._store.set(e,{value:n,expiresAt:s}),this._evictLruWhileOver(),this._version+=1}setMany(e,n){let r=this._resolveExpiresAt(n),s=0;try{for(let[o,i]of e)this._store.has(o)&&this._store.delete(o),this._store.set(o,{value:i,expiresAt:r}),s+=1}finally{s>0&&(this._evictLruWhileOver(),this._version+=1)}}delete(e){let n=this._store.delete(e);return n&&(this._version+=1),n}deleteMany(e){let n=0;try{for(let r of e)this._store.delete(r)&&(n+=1)}finally{n>0&&(this._version+=1)}return n}clear(){let e=this._store.size;return e===0?0:(this._store.clear(),this._version+=1,e)}pruneExpired(){let e=ne(),n=0;for(let[r,s]of this._store)this._isExpired(s,e)&&(this._store.delete(r),n+=1);return n>0&&(this._version+=1),n}toMap(){let e=ne(),n=new Map;for(let[r,s]of this._store)this._isExpired(s,e)||n.set(r,s.value);return n}_resolveExpiresAt(e){let n=e??this._defaultTtl;if(n!==void 0){if(!Number.isFinite(n)||n<=0)throw new RangeError(`MapBackend: ttl must be a positive finite number (got ${n})`);return ne()+n*1e9}}_isExpired(e,n){return e.expiresAt===void 0?!1:(n??ne())>=e.expiresAt}_touchLru(e,n){this._store.delete(e),this._store.set(e,n)}_evictLruWhileOver(){if(this._maxSize!==void 0)for(;this._store.size>this._maxSize;){let e=this._store.keys().next().value;if(e===void 0)break;this._store.delete(e)}}};function Kn(t={}){let{name:e,maxSize:n,defaultTtl:r,versioning:s,backend:o}=t,i=o??new Ft({maxSize:n,defaultTtl:r}),a=F(i.toMap(),{name:e,describeKind:"state",equals:(c,f)=>c===f,...s!=null?{versioning:s}:{}});function d(){let c=i.toMap();j(()=>{a.down([[G]]),a.down([[w,c]])})}function u(c){let f=i.version;try{return c()}finally{i.version!==f&&d()}}return{entries:a,has(c){return u(()=>i.has(c))},get(c){return u(()=>i.get(c))},set(c,f,p){u(()=>i.set(c,f,p?.ttl))},setMany(c,f){u(()=>i.setMany(c,f?.ttl))},delete(c){u(()=>i.delete(c))},deleteMany(c){u(()=>i.deleteMany(c))},clear(){u(()=>i.clear())},pruneExpired(){u(()=>i.pruneExpired())},get size(){return i.size},dispose(){}}}Ie();function Gi(t){return typeof t=="object"&&t!==null&&"cache"in t&&typeof t.subscribe=="function"}function Fi(t,e,n){let r=de(t),s=r.v!=null,o=F(n?.initialVerified??null,{...s?{meta:{sourceVersion:null}}:{}}),i=n?.trigger!==void 0&&n.trigger!==null,a=null;if(i&&n?.autoVerify?a=vt(de(n.trigger),r):i?a=de(n.trigger):n?.autoVerify&&(a=r),a!==null){let d;if(a===r)d=Ce(r,u=>e(u));else{let u=r.cache;r.subscribe(c=>{for(let f of c)f[0]===w&&(u=f[1])}),d=Ce(a,()=>e(u))}Ue(d,u=>{j(()=>{if(o.down([[w,u]]),s){let c=r.v;c!=null&&o.meta.sourceVersion.down([[w,{id:c.id,version:c.version}]])}})})}return{node:r,verified:o,trigger:a}}function Gr(t){t.subscribe(()=>{})}function wt(t){return t instanceof Map?t:new Map}function Fr(t,e){if(!Array.isArray(e.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");j(()=>{for(let{key:n,value:r}of e.upsert)t.set(n,r);for(let n of e.remove??[])t.delete(n)})}function $i(t,e,n){let r=de(t),s=Kn(n.mapOptions??{}),o=n.budget??2e3,a=n.context!==void 0&&n.context!==null?de(n.context):F(null),d=wt(s.entries.cache);s.entries.subscribe(h=>{for(let l of h)l[0]===w&&(d=wt(l[1]))});let u=Ce(r,h=>e(h,d));if(Ue(u,h=>{Fr(s,h)}),n.evict){let h=new Map,l=xe([s.entries],([m])=>{let g=[],b=wt(m);for(let y of h.keys())b.has(y)||(h.get(y)(),h.delete(y));for(let[y,v]of b){let T=n.evict(y,v);if(Gi(T)){if(!h.has(y)){let k=Ue(T,_=>{_===!0&&s.has(y)&&s.delete(y)});h.set(y,k)}continue}if(typeof T=="boolean"){T&&g.push(y);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return g});Ue(l,m=>{for(let g of m)s.delete(g)})}let c=n.consolidateTrigger!==void 0&&n.consolidateTrigger!==null;if(n.consolidate&&c){let h=de(n.consolidateTrigger),l=Ce(h,()=>n.consolidate(d));Ue(l,m=>{Fr(s,m)})}let f=xe([s.entries,a],([h,l])=>{let m=[...wt(h).entries()].map(([y,v])=>({key:y,value:v,score:n.score(v,l),cost:n.cost(v)}));m.sort((y,v)=>v.score-y.score);let g=[],b=o;for(let y of m)y.cost<=b&&(g.push({key:y.key,value:y.value,score:y.score}),b-=y.cost);return g}),p=xe([s.entries],([h])=>wt(h).size);return Gr(f),Gr(p),{store:s,compact:f,size:p}}Sn();var zn=require("rxjs");X();function Ki(t,e){return e?.raw?new zn.Observable(n=>t.subscribe(s=>{if(!n.closed){n.next(s);for(let o of s){if(o[0]===N){n.error(o[1]);return}if(o[0]===x){n.complete();return}}}})):new zn.Observable(n=>t.subscribe(s=>{for(let o of s){if(n.closed)return;if(o[0]===w)n.next(o[1]);else if(o[0]===N){n.error(o[1]);return}else if(o[0]===x){n.complete();return}}}))}ye();X();we();var $t=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(e){return this._topics.has(e)}topicNames(){return this._topics.values()}createTopic(e){return this._topics.has(e)?!1:(this._topics.add(e),this._version+=1,!0)}removeTopic(e){let n=this._topics.delete(e);return n&&(this._version+=1),n}};function zi(t={}){let{backend:e}=t,n=e??new $t,r=new Map;function s(o){let i=r.get(o);return i===void 0&&(i=B({describeKind:"state"}),r.set(o,i),n.createTopic(o)),i}return{topic(o){return s(o)},publish(o,i){s(o).emit(i)},publishMany(o){j(()=>{for(let[i,a]of o)s(i).emit(a)})},removeTopic(o){let i=r.get(o);return i===void 0?!1:(r.delete(o),n.removeTopic(o),i.down([[K]]),!0)},has(o){return n.hasTopic(o)},get size(){return n.topicCount},topicNames(){return n.topicNames()}}}ye();X();ue();function $r(t,e){if(t===e)return 0;let n=typeof t;if(n===typeof e&&(n==="number"||n==="string"||n==="boolean"||n==="bigint")){let s=t,o=e;return s<o?-1:s>o?1:0}return String(t).localeCompare(String(e))}function ji(t,e){let n=$r(t[0],e[0]);return n!==0?n:$r(t[1],e[1])}function Kr(t){return[t.secondary,t.primary]}function at(t,e){let n=Kr(e),r=0,s=t.length;for(;r<s;){let o=r+s>>1;ji(n,Kr(t[o]))>0?r=o+1:s=o}return r}var Kt=class{_version=0;_buf=[];_byPrimary=new Map;get version(){return this._version}get size(){return this._buf.length}has(e){return this._byPrimary.has(e)}get(e){return this._byPrimary.get(e)?.value}upsert(e,n,r,s){let o=this._byPrimary.get(e),i={primary:e,secondary:n,value:r};if(o!==void 0&&s?.equals?.(o,i))return!1;if(o!==void 0){let d=at(this._buf,o);this._buf.splice(d,1)}let a=at(this._buf,i);return this._buf.splice(a,0,i),this._byPrimary.set(e,i),this._version+=1,o===void 0}upsertMany(e,n){let r=0;try{for(let s of e){let o=this._byPrimary.get(s.primary),i={primary:s.primary,secondary:s.secondary,value:s.value};if(o!==void 0&&n?.equals?.(o,i))continue;if(o!==void 0){let d=at(this._buf,o);this._buf.splice(d,1)}let a=at(this._buf,i);this._buf.splice(a,0,i),this._byPrimary.set(s.primary,i),r+=1}}finally{r>0&&(this._version+=1)}return r}delete(e){let n=this._byPrimary.get(e);if(n===void 0)return!1;let r=at(this._buf,n);return this._buf.splice(r,1),this._byPrimary.delete(e),this._version+=1,!0}deleteMany(e){let n=0;try{for(let r of e){let s=this._byPrimary.get(r);if(s===void 0)continue;let o=at(this._buf,s);this._buf.splice(o,1),this._byPrimary.delete(r),n+=1}}finally{n>0&&(this._version+=1)}return n}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._byPrimary.clear(),this._version+=1,e)}toArray(){return[...this._buf]}toPrimaryMap(){let e=new Map;for(let n of this._buf)e.set(n.primary,n.value);return e}};function Wi(t){return t.subscribe(()=>{})}function Hi(t={}){let{name:e,versioning:n,equals:r,backend:s}=t,o=s??new Kt;function i(h){return h?.equals!==void 0||r===void 0?h:{...h,equals:r}}let a=F([],{name:e,describeKind:"state",equals:(h,l)=>h===l,...n!=null?{versioning:n}:{}}),d=xe([a],([h])=>{let l=h,m=new Map;for(let g of l)m.set(g.primary,g.value);return m},{initial:o.toPrimaryMap(),describeKind:"derived"}),u=Wi(d),c=!1;function f(){let h=o.toArray();j(()=>{a.down([[G]]),a.down([[w,h]])})}function p(h){let l=o.version;try{return h()}finally{o.version!==l&&f()}}return{ordered:a,byPrimary:d,has(h){return o.has(h)},get(h){return o.get(h)},get size(){return o.size},upsert(h,l,m,g){return p(()=>o.upsert(h,l,m,i(g)))},upsertMany(h,l){let m=[...h];m.length!==0&&p(()=>o.upsertMany(m,i(l)))},delete(h){p(()=>o.delete(h))},deleteMany(h){let l=[...h];l.length!==0&&p(()=>o.deleteMany(l))},clear(){p(()=>o.clear())},dispose(){c||(c=!0,u())}}}ye();X();ue();var zt=class{_version=0;_buf;constructor(e){this._buf=e?[...e]:[]}get version(){return this._version}get size(){return this._buf.length}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._buf.length+e;if(!(n<0||n>=this._buf.length))return this._buf[n]}append(e){this._buf.push(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._buf.length;this._buf.length=n+e.length;for(let r=0;r<e.length;r++)this._buf[n+r]=e[r];this._version+=1}insert(e,n){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insert: index ${e} out of range [0, ${this._buf.length}]`);this._buf.splice(e,0,n),this._version+=1}insertMany(e,n){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insertMany: index ${e} out of range [0, ${this._buf.length}]`);n.length!==0&&(this._buf.splice(e,0,...n),this._version+=1)}pop(e){if(this._buf.length===0)throw new RangeError("pop from empty list");if(!Number.isInteger(e))throw new RangeError(`pop: index ${e} must be an integer`);let n=e>=0?e:this._buf.length+e;if(n<0||n>=this._buf.length)throw new RangeError(`pop: index ${e} out of range`);let[r]=this._buf.splice(n,1);return this._version+=1,r}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function Ui(t,e={}){let{name:n,versioning:r,backend:s}=e,o=s??new zt(t),i=F(o.toArray(),{name:n,describeKind:"state",equals:(u,c)=>u===c,...r!=null?{versioning:r}:{}});function a(){let u=o.toArray();j(()=>{i.down([[G]]),i.down([[w,u]])})}function d(u){let c=o.version;try{return u()}finally{o.version!==c&&a()}}return{items:i,get size(){return o.size},at(u){return o.at(u)},append(u){d(()=>o.append(u))},appendMany(u){d(()=>o.appendMany(u))},insert(u,c){d(()=>o.insert(u,c))},insertMany(u,c){d(()=>o.insertMany(u,c))},pop(u=-1){return d(()=>o.pop(u))},clear(){d(()=>o.clear())},dispose(){}}}ye();X();ue();var jt=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,n){if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=n,n!==void 0){if(this._buf=new Array(n),e&&e.length>0){let r=Math.min(e.length,n),s=e.length-r;for(let o=0;o<r;o++)this._buf[o]=e[s+o];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._size+e;if(!(n<0||n>=this._size))return this._maxSize!==void 0?this._buf[(this._head+n)%this._maxSize]:this._buf[n]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=n;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let n=0;n<e;n++)this._buf[(this._head+n)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let n=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,n);else{for(let r=0;r<n;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+n)%this._maxSize}return this._size-=n,this._version+=1,n}slice(e,n){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(n!==void 0&&(!Number.isInteger(n)||n<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${n})`);let r=n===void 0?this._size:Math.min(Math.max(n,0),this._size),s=Math.min(e,this._size);if(s>=r)return[];let o=r-s;if(this._maxSize===void 0)return this._buf.slice(s,r);let i=new Array(o);for(let a=0;a<o;a++)i[a]=this._buf[(this._head+s+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let n=Math.min(e,this._size);return this.slice(this._size-n,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this._buf[(this._head+n)%this._maxSize];return e}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function zr(t){return t.subscribe(()=>{})}var qi=64;function Ji(t,e={}){let{name:n,maxSize:r,versioning:s,backend:o}=e,i=o??new jt(t,r),a=F(i.toArray(),{name:n,describeKind:"state",equals:(l,m)=>l===m,...s!=null?{versioning:s}:{}});function d(){let l=i.toArray();j(()=>{a.down([[G]]),a.down([[w,l]])})}let u=new Map,c=new Map;function f(l,m){return`${l}:${m===void 0?"END":m}`}function p(l){if(l.size<qi)return;let m=l.keys().next();if(m.done)return;let g=l.get(m.value);g!==void 0&&g.dispose(),l.delete(m.value)}function h(l){let m=i.version;try{return l()}finally{i.version!==m&&d()}}return{entries:a,get size(){return i.size},at(l){return i.at(l)},append(l){h(()=>i.append(l))},appendMany(l){l.length!==0&&h(()=>i.appendMany(l))},clear(){h(()=>i.clear())},trimHead(l){h(()=>i.trimHead(l))},tail(l){if(!Number.isInteger(l)||l<0)throw new RangeError(`tail: n must be a non-negative integer (got ${l})`);let m=u.get(l);if(m!==void 0)return u.delete(l),u.set(l,m),m.node;p(u);let g=xe([a],([y])=>{let v=y;return l===0||v.length===0?[]:v.slice(Math.max(0,v.length-l))},{initial:i.tail(l),describeKind:"derived"}),b=zr(g);return u.set(l,{node:g,dispose:b}),g},slice(l,m){if(!Number.isInteger(l)||l<0)throw new RangeError(`slice: start must be a non-negative integer (got ${l})`);if(m!==void 0&&(!Number.isInteger(m)||m<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${m})`);let g=f(l,m),b=c.get(g);if(b!==void 0)return c.delete(g),c.set(g,b),b.node;p(c);let y=xe([a],([T])=>{let k=T;return m===void 0?k.slice(l):k.slice(l,m)},{initial:i.slice(l,m),describeKind:"derived"}),v=zr(y);return c.set(g,{node:y,dispose:v}),y},disposeTail(l){let m=u.get(l);return m===void 0?!1:(m.dispose(),u.delete(l),!0)},disposeSlice(l,m){let g=f(l,m),b=c.get(g);return b===void 0?!1:(b.dispose(),c.delete(g),!0)},disposeAllViews(){for(let l of u.values())l.dispose();u.clear();for(let l of c.values())l.dispose();c.clear()},dispose(){for(let l of u.values())l.dispose();u.clear();for(let l of c.values())l.dispose();c.clear()}}}Pt();X();Ie();function Yi(t,e={}){let n=e.keyFn??(s=>String(s)),r=new Map;return s=>{let o=n(s),i=r.get(o);if(i)return i;let a=t(s),d;a!=null&&typeof a.then=="function"?d=Promise.resolve(a):a!=null&&typeof a=="object"&&"subscribe"in a&&"cache"in a?d=Vn(a):a!=null&&typeof a=="object"&&Symbol.asyncIterator in a?d=(async()=>{let f=a[Symbol.asyncIterator]();try{let{value:p,done:h}=await f.next();if(h)throw new Error("singleFromAny: factory returned empty async iterable");return p}finally{await f.return?.()}})():a!=null&&typeof a=="object"&&Symbol.iterator in a?d=(async()=>{let f=a[Symbol.iterator]();try{let{value:p,done:h}=f.next();if(h)throw new Error("singleFromAny: factory returned empty iterable");return p}finally{f.return?.()}})():d=Promise.resolve(a);let u,c=()=>{r.get(o)===u&&r.delete(o)};return u=d.then(f=>(c(),f),f=>{throw c(),f}),r.set(o,u),u}}function Qi(t,e={}){let n=e.keyFn??(s=>String(s)),r=new Map;return s=>{let o=n(s),i=r.get(o);if(i)return i;let a=de(t(s));r.set(o,a);let d=a.subscribe(u=>{for(let c of u)if(c[0]===N||c[0]===x){r.get(o)===a&&r.delete(o),d();return}});return a}}Ie();function Wt(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Wt);let e=t,n=Object.keys(e).sort(),r={};for(let s of n)r[s]=Wt(e[s]);return r}function Xi(t){return JSON.stringify(Wt(t),void 0,0)}function Zi(){let t=new Map;return{save(e,n){t.set(e,JSON.parse(JSON.stringify(n)))},load(e){let n=t.get(e);return n===void 0?null:JSON.parse(JSON.stringify(n))},clear(e){t.delete(e)},list(){return[...t.keys()].sort()}}}function ea(t){return{save(e,n){t[e]=JSON.parse(JSON.stringify(n))},load(e){let n=t[e];return n===void 0?null:JSON.parse(JSON.stringify(n))},clear(e){delete t[e]},list(){return Object.keys(t).sort()}}}X();we();ue();fn();ye();Le();Ot();X();Ot();we();function Ht(t,e){if(e!=null&&e.length>0)return new Set(e);switch(t){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;default:return new Set(["type","deps"])}}function ta(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function na(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function jn(t,e){let n=e==null,r=!n&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,s=n||e.has("meta")||r!=null&&r.length>0,o="state",i=[];t instanceof oe&&(o=ta(t),i=t._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(n||e.has("status"))&&(a.status=t.status);let d=t instanceof oe?t._guard:void 0;if(s){let u={...na(t)};if(d!=null&&u.access===void 0&&(u.access=pn(d)),r!=null&&r.length>0&&!e.has("meta")){let c={};for(let f of r)f in u&&(c[f]=u[f]);a.meta=c}else a.meta=u}if(t.name!=null&&(a.name=t.name),n||e.has("value")){t.status==="sentinel"&&(a.sentinel=!0);try{a.value=t.cache}catch{}}if((n||e.has("v"))&&t.v!=null){let u={id:t.v.id,version:t.v.version};"cid"in t.v&&(u.cid=t.v.cid,u.prev=t.v.prev),a.v=u}return(n||e.has("guard"))&&d!=null&&(a.guard=pn(d)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}we();ue();Ie();At();ln();function Wn(t){return t>=768&&t<=879||t>=1155&&t<=1161||t>=1425&&t<=1469||t>=1552&&t<=1562||t>=1611&&t<=1631||t>=1648&&t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t>=1767&&t<=1768||t>=1770&&t<=1773||t>=1840&&t<=1866||t>=1958&&t<=1968||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2641||t>=2672&&t<=2673||t>=2677&&t===2677||t>=3633&&t===3633||t>=3636&&t<=3642||t>=3655&&t<=3662||t>=3761&&t===3761||t>=3764&&t<=3772||t>=3784&&t<=3790||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65024&&t<=65039||t>=65056&&t<=65071||t===8205?0:t>=4352&&t<=4447||t>=8986&&t<=8987||t>=9001&&t<=9002||t>=9193&&t<=9203||t>=9208&&t<=9210||t>=9725&&t<=9726||t>=9748&&t<=9749||t>=9800&&t<=9811||t===9855||t===9875||t===9889||t>=9898&&t<=9899||t>=9917&&t<=9918||t>=9924&&t<=9925||t===9934||t===9940||t===9962||t>=9970&&t<=9971||t===9973||t===9978||t===9981||t===9986||t===9989||t>=9992&&t<=9997||t===9999||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t>=10548&&t<=10549||t>=11013&&t<=11015||t>=11035&&t<=11036||t===11088||t===11093||t>=11904&&t<=12350||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12784&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=19968&&t<=40959||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65131||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126980&&t===126980||t===127183||t>=127344&&t<=127345||t===127358||t===127359||t===127374||t>=127377&&t<=127386||t>=127456&&t<=127487||t>=127488&&t<=127490||t===127514||t===127535||t>=127538&&t<=127546||t>=127568&&t<=127569||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=129792&&t<=130047||t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}function Ut(t){let e=0;for(let n of t)e+=Wn(n.codePointAt(0));return e}function jr(t,e){if(e<=0)return"";let n=0,r="";for(let s of t){let o=Wn(s.codePointAt(0));if(n+o>e){if(e<=1)return"\u2026";for(;n+1>e&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=Wn(i.codePointAt(0))}return`${r}\u2026`}r+=s,n+=o}return r}var ra={horizontal:"\u2500",vertical:"\u2502",cornerTL:"\u250C",cornerTR:"\u2510",cornerBL:"\u2514",cornerBR:"\u2518",tDown:"\u252C",tUp:"\u2534",tRight:"\u251C",tLeft:"\u2524",cross:"\u253C",arrowRight:"\u25B6",arrowDown:"\u25BC",arrowLeft:"\u25C0",arrowUp:"\u25B2",boxTL:"\u250C",boxTR:"\u2510",boxBL:"\u2514",boxBR:"\u2518",boxH:"\u2500",boxV:"\u2502"},oa={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function qr(t,e){let n=e.charset==="ascii"?oa:ra,r=t.width,s=t.height,o=Array.from({length:s},()=>Array.from({length:r},()=>" ")),i=Array.from({length:s},()=>Array.from({length:r},()=>"empty"));for(let a of t.edges)ia(o,i,n,a);for(let a of t.boxes)sa(o,i,n,a,e.labelOf(a.id));return o.map(a=>ca(a.join(""))).join(`
|
|
19
|
-
`)}function sa(t,e,n,r,s){let{x:o,y:i,w:a,h:d}=r;if(a<2||d<2){d>0&&Wr(t,e,o,i,a,s);return}Be(t,e,o,i,n.boxTL);for(let c=o+1;c<o+a-1;c+=1)Be(t,e,c,i,n.boxH);Be(t,e,o+a-1,i,n.boxTR);for(let c=i+1;c<i+d-1;c+=1){Be(t,e,o,c,n.boxV);for(let f=o+1;f<o+a-1;f+=1)Jr(t,e,f,c," ","empty");Be(t,e,o+a-1,c,n.boxV)}Be(t,e,o,i+d-1,n.boxBL);for(let c=o+1;c<o+a-1;c+=1)Be(t,e,c,i+d-1,n.boxH);Be(t,e,o+a-1,i+d-1,n.boxBR);let u=i+Math.floor(d/2);Wr(t,e,o+1,u,a-2,s)}function Be(t,e,n,r,s){Jr(t,e,n,r,s,s===" "?"empty":s==="\u2500"||s==="-"?"boxH":s==="\u2502"||s==="|"?"boxV":"boxCorner")}function Jr(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];n<0||n>=i.length||(i[n]=s,e[r][n]=o)}function Wr(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=n,a=s;for(let d of o){let u=Ut(d);if(u!==0){if(a<u)break;i>=0&&i<t[r].length&&(t[r][i]=d,e[r][i]="label",u===2&&i+1<t[r].length&&(t[r][i+1]="",e[r][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<t[r].length&&(t[r][i]=" ",e[r][i]="empty"),i+=1,a-=1}function ia(t,e,n,r){let s=r.points;if(s.length<2)return;for(let d=0;d+1<s.length;d+=1)aa(t,e,n,s[d],s[d+1]);for(let d=1;d+1<s.length;d+=1){let u=s[d-1],c=s[d],f=s[d+1],p=ua(u,c,f,n);p&&Ur(t,e,c.x,c.y,p,"edgeCorner")}let o=s[s.length-1],i=s[s.length-2],a=da(i,o,n);a&&Ur(t,e,o.x,o.y,a,"arrow")}function aa(t,e,n,r,s){if(!(r.x===s.x&&r.y===s.y)){if(r.y===s.y){let o=r.y,i=Math.min(r.x,s.x),a=Math.max(r.x,s.x);for(let d=i;d<=a;d+=1)Hr(t,e,d,o,n,"h")}else if(r.x===s.x){let o=r.x,i=Math.min(r.y,s.y),a=Math.max(r.y,s.y);for(let d=i;d<=a;d+=1)Hr(t,e,o,d,n,"v")}}}function Hr(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[n]=o==="h"?s.horizontal:s.vertical,e[r][n]=o==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&o==="v"){i[n]=s.cross,e[r][n]="edgeCorner";return}if(a==="edgeV"&&o==="h"){i[n]=s.cross,e[r][n]="edgeCorner";return}}}function Ur(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[n]=s,e[r][n]=o)}function ua(t,e,n,r){let s=t.y===e.y,o=e.y===n.y;if(s===o)return;if(s){let d=t.x<e.x,u=n.y>e.y;return d&&u?r.cornerTR:d&&!u?r.cornerBR:!d&&u?r.cornerTL:r.cornerBL}let i=t.y<e.y,a=n.x>e.x;return i&&a?r.cornerBL:i&&!a?r.cornerBR:!i&&a?r.cornerTL:r.cornerTR}function da(t,e,n){if(e.x>t.x)return n.arrowRight;if(e.x<t.x)return n.arrowLeft;if(e.y>t.y)return n.arrowDown;if(e.y<t.y)return n.arrowUp}function ca(t){let e=t.length;for(;e>0&&t.charCodeAt(e-1)===32;)e-=1;return t.slice(0,e)}function Xr(t){let e=la(t);fa(e),pa(e),ha(e),ma(e,t);let n=ya(e,t),{width:r,height:s}=Ta(e),o=[];for(let i of e.layers)for(let a of i)a.isVirtual||o.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:o,edges:n,width:r,height:s}}function la(t){let e=new Map;for(let s of t.nodes)e.set(s,{id:s,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:t.widthCells(s),h:t.heightCells(s),in:[],out:[]});let n=[],r=0;for(let s of t.edges){if(s.from===s.to)continue;let o=e.get(s.from),i=e.get(s.to);if(!o||!i)continue;let a={chainId:r++,chainFrom:s.from,chainTo:s.to,fromId:s.from,toId:s.to,hopIndex:0,chainLen:1};o.out.push(a),i.in.push(a),n.push(a)}return{nodes:e,layers:[],hops:n}}function fa(t){let e=new Map;for(let o of t.nodes.values())e.set(o.id,o.in.length);let n=[];for(let o of t.nodes.values())(e.get(o.id)??0)===0&&(o.layer=0,n.push(o));let r=new Set,s=0;for(;s<n.length;){let o=n[s++];if(!r.has(o.id)){r.add(o.id);for(let i of o.out){let a=t.nodes.get(i.toId);a.layer=Math.max(a.layer,o.layer+1);let d=(e.get(a.id)??0)-1;e.set(a.id,d),d<=0&&n.push(a)}}}for(let o of t.nodes.values())o.layer<0&&(o.layer=0)}function pa(t){let e=Math.max(0,...Array.from(t.nodes.values(),o=>o.layer)),n=Array.from({length:e+1},()=>[]);for(let o of t.nodes.values())n[o.layer].push(o);let r=[],s=0;for(let o of t.hops){let i=t.nodes.get(o.fromId),a=t.nodes.get(o.toId),d=a.layer-i.layer;if(d<=0){i.out=i.out.filter(f=>f!==o),a.in=a.in.filter(f=>f!==o);continue}if(d===1){o.hopIndex=0,o.chainLen=1,r.push(o);continue}i.out=i.out.filter(f=>f!==o),a.in=a.in.filter(f=>f!==o);let u=i;for(let f=1;f<d;f+=1){let p=`__virt_${s++}__`,h={id:p,isVirtual:!0,layer:i.layer+f,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};t.nodes.set(p,h),n[h.layer].push(h);let l={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:p,hopIndex:f-1,chainLen:d};u.out.push(l),h.in.push(l),r.push(l),u=h}let c={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:a.id,hopIndex:d-1,chainLen:d};u.out.push(c),a.in.push(c),r.push(c)}for(let o of n)for(let i=0;i<o.length;i+=1)o[i].order=i;t.layers=n,t.hops=r}function ha(t){for(let n=0;n<4;n+=1){for(let r=1;r<t.layers.length;r+=1)Yr(t,t.layers[r],"in"),qt(t.layers[r]);for(let r=t.layers.length-2;r>=0;r-=1)Yr(t,t.layers[r],"out"),qt(t.layers[r])}for(let n=0;n<2;n+=1){let r=!1;for(let s=1;s<t.layers.length;s+=1){let o=t.layers[s];for(let i=0;i+1<o.length;i+=1){let a=Qr(t,o[i],o[i+1],"in");[o[i],o[i+1]]=[o[i+1],o[i]],qt(o),Qr(t,o[i],o[i+1],"in")<a?r=!0:([o[i],o[i+1]]=[o[i+1],o[i]],qt(o))}}if(!r)break}}function Yr(t,e,n){let r=new Map;for(let s of e){let o=n==="in"?s.in:s.out;if(o.length===0){r.set(s.id,s.order);continue}let i=0,a=0;for(let d of o){let u=t.nodes.get(n==="in"?d.fromId:d.toId);u&&(i+=u.order,a+=1)}r.set(s.id,a===0?s.order:i/a)}e.sort((s,o)=>{let i=r.get(s.id),a=r.get(o.id);return i!==a?i-a:s.order-o.order})}function qt(t){for(let e=0;e<t.length;e+=1)t[e].order=e}function Qr(t,e,n,r){let s=r==="in"?e.in:e.out,o=r==="in"?n.in:n.out,i=0;for(let a of s)for(let d of o){let u=t.nodes.get(r==="in"?a.fromId:a.toId)?.order??0,c=t.nodes.get(r==="in"?d.fromId:d.toId)?.order??0;(e.order<n.order&&u>c||e.order>n.order&&u<c)&&(i+=1)}return i}function ma(t,e){e.direction==="LR"?ga(t,e):ba(t,e)}function ga(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.w);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.x=n[s];for(let s of t.layers){let o=0;for(let i of s)i.y=o,o+=i.h+e.nodeGap}Zr(t,e,"y")}function ba(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.h);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.y=n[s];for(let s of t.layers){let o=0;for(let i of s)i.x=o,o+=i.w+e.nodeGap}Zr(t,e,"x")}function Zr(t,e,n){let r=o=>n==="y"?o.h:o.w,s=e.nodeGap;for(let o=0;o<2;o+=1){let i=o===0?t.layers.slice(1):t.layers.slice(0,-1).reverse();for(let a of i){let d=new Map;for(let c of a){let f=o===0?c.in:c.out;if(f.length===0)continue;let p=[];for(let l of f){let m=t.nodes.get(o===0?l.fromId:l.toId);if(!m)continue;let g=n==="y"?m.y:m.x;p.push(g+Math.floor(r(m)/2))}if(p.length===0)continue;p.sort((l,m)=>l-m);let h=p[Math.floor(p.length/2)];d.set(c.id,h-Math.floor(r(c)/2))}let u=0;for(let c of a){let f=d.get(c.id),p=n==="y"?c.y:c.x,l=Math.max(f??p,u);n==="y"?c.y=l:c.x=l,u=l+r(c)+s}}}}function ya(t,e){let n=new Map;for(let u of t.hops){let c=n.get(u.chainId);c?c.push(u):n.set(u.chainId,[u])}for(let u of n.values())u.sort((c,f)=>c.hopIndex-f.hopIndex);let r=e.direction==="LR",s=u=>r?u.x:u.y,o=u=>r?u.w:u.h,i=u=>r?u.y+Math.floor(u.h/2):u.x+Math.floor(u.w/2),a=new Map;for(let u=0;u+1<t.layers.length;u+=1){let c=t.layers[u],f=t.layers[u+1],p=0;for(let S of c)p=Math.max(p,s(S)+o(S));let h=Number.POSITIVE_INFINITY;for(let S of f)h=Math.min(h,s(S));let l=Number.isFinite(h)?h-1:p,m=Math.max(1,l-p+1),g=[];for(let S of c)for(let A of S.out)g.push(A);g.sort((S,A)=>{let I=i(t.nodes.get(S.fromId)),D=i(t.nodes.get(A.fromId));if(I!==D)return I-D;let L=i(t.nodes.get(S.toId)),O=i(t.nodes.get(A.toId));return L-O});let b=[],y=new Map;for(let S of g){let A=i(t.nodes.get(S.fromId)),I=i(t.nodes.get(S.toId)),D=Math.min(A,I),L=Math.max(A,I),O=-1;for(let $=0;$<b.length;$+=1){let ee=b[$],z=!0;for(let te of ee)if(te.lo<=L&&D<=te.hi){z=!1;break}if(z){ee.push({lo:D,hi:L}),O=$;break}}O<0&&(b.push([{lo:D,hi:L}]),O=b.length-1),y.set(S,O)}let v=b.length,T=m>=Math.max(3,v+2),k=T?p+1:p,_=T?l-1:l,E=Math.max(1,_-k+1);for(let S of g){let A=y.get(S),I;if(v<=1)I=k+Math.floor(E/2);else{let D=(E-1)/(v-1);I=k+Math.floor(A*D)}a.set(S,Math.max(p,Math.min(l,I)))}}let d=[];for(let[,u]of n){let c=[];for(let p=0;p<u.length;p+=1){let h=u[p],l=t.nodes.get(h.fromId),m=t.nodes.get(h.toId),g=a.get(h),b=l.isVirtual?s(l):s(l)+o(l),y=m.isVirtual?s(m):s(m)-1,v=i(l),T=i(m);p===0&&Jt(c,r,b,v),v!==T&&(Jt(c,r,g,v),Jt(c,r,g,T)),Jt(c,r,y,T)}let f=u[0];d.push({from:f.chainFrom,to:f.chainTo,points:va(c)})}return d}function Jt(t,e,n,r){t.push(e?{x:n,y:r}:{x:r,y:n})}function va(t){let e=[];for(let n of t){let r=e[e.length-1];(!r||r.x!==n.x||r.y!==n.y)&&e.push(n)}return e}function Ta(t){let e=0,n=0;for(let r of t.layers)for(let s of r)e=Math.max(e,s.x+s.w),n=Math.max(n,s.y+s.h);return{width:e,height:n}}var wa=24,xa=4,ka=1,_a=3;function eo(t,e){let n=Na(e.direction),r=Math.max(3,e.maxLabelWidth??wa),s=e.asciiCharset??"unicode",o=Object.keys(t.nodes).sort(),i=new Set(o),a=t.edges.filter(h=>i.has(h.from)&&i.has(h.to)),d=new Map,u=new Map;for(let h of o){let l=jr(h,r);d.set(h,l),u.set(h,Ut(l)+4)}let c=Xr({nodes:o,edges:a,widthCells:h=>u.get(h)??3,heightCells:()=>_a,layerGap:xa,nodeGap:ka,direction:n}),f=qr(c,{charset:s,labelOf:h=>d.get(h)??h}),p=e.logger;return p&&p(f),f}function Na(t){if(t===void 0||t==="LR")return"LR";if(t==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(t)}`)}function to(t,e,n,r={}){let s=e in t.nodes,o=n in t.nodes;if(!s)return Yt(e,n,"no-such-from");if(!o)return Yt(e,n,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===n){if(r.findCycle===!0){let u=Ea(t,e,r);if(u!=null)return u}let d=Qt(e,t.nodes[e],0,r);return Xt(e,n,[d])}if(i===0)return Yt(e,n,"no-path");let a=no(t,e,n,i);return a.found?Xt(e,n,ro(t,a.pathOrder,r)):Yt(e,n,a.truncated?"max-depth-exceeded":"no-path")}function no(t,e,n,r){let s=new Map,o=[{path:n,depth:0}],i=new Set([n]),a=0,d=!1;for(;a<o.length;){let f=o[a++];if(f.path===e)break;if(r!=null&&f.depth>=r){let m=t.nodes[f.path];m?.deps&&m.deps.length>0&&(d=!0);continue}let p=t.nodes[f.path];if(p==null)continue;let h=p.deps??[],l=new Map;for(let m=0;m<h.length;m++){let g=h[m];if(!g)continue;let b=l.get(g);b==null&&(b=[],l.set(g,b)),b.push(m)}for(let[m,g]of l)i.has(m)||(i.add(m),s.set(m,{from:f.path,depIndices:g}),o.push({path:m,depth:f.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:d};let u=[{path:e}],c=e;for(;c!==n;){let f=s.get(c);if(f==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=f.depIndices,u.push({path:f.from}),c=f.from}return{found:!0,pathOrder:u,truncated:!1}}function Ea(t,e,n){let r=t.nodes[e];if(r==null)return null;let s=r.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=Qt(e,r,0,n);a.dep_index=o[0];let d=Qt(e,r,1,n);return Xt(e,e,[a,d])}let i=null;for(let a=0;a<s.length;a++){let d=s[a];if(!d||d===e)continue;let u=no(t,d,e,n.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:Xt(e,e,ro(t,i.pathOrder,n))}function ro(t,e,n){return e.map((r,s)=>{let o=t.nodes[r.path],i=Qt(r.path,o,s,n);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function Qt(t,e,n,r){let s={path:t,type:e.type,hop:n};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=r.annotations?.get(t)??e.annotation;o!=null&&(s.annotation=o);let i=r.lastMutations?.get(t)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function Xt(t,e,n){return oo(t,e,!0,"ok",n)}function Yt(t,e,n){return oo(t,e,!1,n,[])}function oo(t,e,n,r,s){let o=Sa(t,e,n,r,s);return{from:t,to:e,found:n,reason:r,steps:s,text:o,toJSON(){return{from:t,to:e,found:n,reason:r,steps:s}}}}function Sa(t,e,n,r,s){if(!n)switch(r){case"no-such-from":return`explainPath: no node named "${t}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${t}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${t}" to "${e}"`}let o=[`Causal path: ${t} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(d),"value"in i&&o.push(` value: ${Oa(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;o.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return o.join(`
|
|
20
|
-
`)}function
|
|
21
|
-
`)}function
|
|
22
|
-
`);return e.logger?.(o),o}function
|
|
23
|
-
`)}function
|
|
24
|
-
`)}function Ka(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Zt(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let s=t.indexOf("]",n+1);if(s<=n+1){e+="\\[";continue}let o=t.slice(n+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,n=s;continue}e+=Ka(r)}return e+="$",new RegExp(e)}var za={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"},ja={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function en(t){if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||t==null)return String(t);try{return JSON.stringify(t)}catch{return"[unserializable]"}}function Wa(t){return t==="none"?ja:t==="ansi"||t==null?za:{data:t.data??"",dirty:t.dirty??"",resolved:t.resolved??"",invalidate:t.invalidate??"",pause:t.pause??"",resume:t.resume??"",complete:t.complete??"",error:t.error??"",teardown:t.teardown??"",derived:t.derived??"",path:t.path??"",reset:t.reset??""}}function co(t){if(t==null)return{};let e=t.detail;return e==="full"?{...t,structured:t.structured??!0,timeline:t.timeline??!0,causal:t.causal??!0,derived:t.derived??!0}:e==="minimal"?{...t,structured:t.structured??!0}:t.format==="stage-log"?{...t,structured:t.structured??!0,timeline:t.timeline??!0}:t}function Ha(t,e,n){for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);if(s<32||s===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function Hn(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(Z))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${Z}' (path separator)`);if(t===Me)throw new Error(`Graph "${e}": ${n} name "${Me}" is reserved for meta companion paths`);Ha(t,e,n)}function Ua(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(Z);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function qa(t,e){let n=!1;for(let s of t)if(!e.isMetaPassthrough(s[0])){n=!0;break}return n?t.filter(s=>e.isMetaPassthrough(s[0])):t}function mo(t){for(let e of t._mounts.values())mo(e);for(let e of t._nodes.values())try{e.down([[K]],{internal:!0})}catch{}}var xt=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(Z))throw new Error(`Graph name must not contain '${Z}' (got "${e}")`);if(e===Me)throw new Error(`Graph name "${Me}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??le,this._traceRing=new qe(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=R(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}add(e,n){let r=e.name,s=n?.name??r;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,i=n?.annotation;if(Hn(o,this.name,"add"),this._mounts.has(o))throw new Error(`Graph "${this.name}": name "${o}" is already a mount point`);if(this._nodes.has(o))throw new Error(`Graph "${this.name}": node "${o}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(o,e),this._nodeToName.set(e,o),this._emitTopology({kind:"added",name:o,nodeKind:"node"}),i!=null&&(this._annotations.set(o,i),this.config.inspectorEnabled&&this._traceRing.push({path:o,annotation:i,timestamp_ns:ne()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof oe&&n._applyVersioning(e)}remove(e){Hn(e,this.name,"remove");let n=this._mounts.get(e);if(n){let o={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,d]of i)a.includes(`${Z}${Me}${Z}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...n._collectSubgraphs(`${e}${Z}`)),this._mounts.delete(e),n._parent=void 0,mo(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:o}),o}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[K]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let n=typeof e=="function"?e:(()=>{let o=Zt(e);return i=>o.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>n(o));for(let o of s){let i=this.remove(o);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let s=e[r++];return{value:[s,n.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(Z))return this.resolve(e);let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return n}get(e){return this.node(e).cache}set(e,n,r){let s=r?.internal===!0;this.node(e).down([[w,n]],{actor:r?.actor,internal:s,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);j(()=>{for(let[s,o]of r)this.set(s,o,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[ve]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let s=r?.internal===!0;this.node(e).down([[N,n]],{actor:r?.actor,internal:s,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[x]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[d,u]of this._nodes)r.set(u,d);let a=[];for(let[d,u]of this._nodes)if(u instanceof oe)for(let c of u._deps){let f=r.get(c.node);f!=null&&a.push([f,d])}return a.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,d]of s)o.set(d,a);let i=[];for(let[a,d]of s)if(d instanceof oe)for(let u of d._deps){let c=o.get(u.node);c!=null&&i.push([c,a])}return i.sort((a,d)=>a[0]<d[0]?-1:a[0]>d[0]?1:a[1]<d[1]?-1:a[1]>d[1]?1:0),i}mount(e,n){if(Hn(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let n=Ua(e,this.name);return this._resolveFromSegments(n)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let n=e;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],s=n.slice(1);if(s.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let o=this._nodes.get(r);if(o&&s.length>0&&s[0]===Me)return this._resolveMetaChainFromNode(o,s,n.join(Z));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${s.join(Z)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(s.join(Z))}_resolveMetaChainFromNode(e,n,r){let s=e,o=0,i=[...n];for(;o<i.length;){if(i[o]!==Me)throw new Error(`Graph "${this.name}": expected ${Me} segment in meta path "${r}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Me} in "${r}"`);let a=i[o+1],d=s.meta[a];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);s=d,o+=2}return s}signal(e,n){if(n?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,s){for(let d of this._mounts.values())d._signalDeliver(e,n,r,s);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=qa(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(c){if(c instanceof Ne)throw c;s.push(c)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,s)}}}_signalMetaSubtree(e,n,r,s,o){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,s)}catch(d){if(d instanceof Ne)throw d;o.push(d)}this._signalMetaSubtree(a,n,r,s,o)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,s=Ht(e?.detail,e?.fields),o=e?.format==="spec",i=o?Ht("minimal"):s,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[_,E]of a)d.set(E,_);let u=[];{let _=a.map(([,A])=>A),E=new Set(d.values()),S=0;for(;_.length>0;){let A=_.shift();if(A instanceof oe)for(let I of A._deps){let D=I.node;if(d.has(D))continue;let L=D.name??"",O=L;if(!O||E.has(O))if(L){let $=2;for(;E.has(`${L}#${$}`);)$++;O=`${L}#${$}`}else for(O=`__internal__/${S++}`;E.has(O);)O=`__internal__/${S++}`;d.set(D,O),E.add(O),u.push([O,D]),_.push(D)}}}let c=[...a,...u],f={};for(let[_,E]of c){if(n!=null&&!E.allowsObserve(n))continue;let S=jn(E,i),A=E instanceof oe?E._deps.map(O=>d.get(O.node)??O.node.name??""):[],{name:I,...D}=S,L={...D,deps:A};if(!o){let O=this._annotations.get(_);O!=null&&(L.annotation=O)}if(r!=null)if(typeof r=="function"){let O=r;if(!(O.length>=2?O(_,L):O(L)))continue}else{let O=!0;for(let[$,ee]of Object.entries(r)){let z=$==="deps_includes"?"depsIncludes":$==="meta_has"?"metaHas":$;if(z==="depsIncludes"){if(!L.deps.includes(String(ee))){O=!1;break}continue}if(z==="metaHas"){if(!Object.hasOwn(L.meta??{},String(ee))){O=!1;break}continue}if(L[z]!==ee){O=!1;break}}if(!O)continue}f[_]=L}let p=new Set(Object.keys(f)),h=[];for(let[_,E]of c)if(E instanceof oe)for(let S of E._deps){let A=d.get(S.node);A!=null&&h.push([A,_])}h.sort((_,E)=>_[0]<E[0]?-1:_[0]>E[0]?1:_[1]<E[1]?-1:_[1]>E[1]?1:0);let l=h.map(([_,E])=>({from:_,to:E}));(n!=null||r!=null)&&(l=l.filter(_=>p.has(_.from)&&p.has(_.to)));let m=this._collectSubgraphs(""),g=n!=null||r!=null?m.filter(_=>{let E=`${_}${Z}`;return[...p].some(S=>S===_||S.startsWith(E))}):m,b=this,y=e,v={name:this.name,nodes:f,edges:l,subgraphs:g,expand(_){let E={...y,format:void 0};return Array.isArray(_)?(E.fields=_,E.detail=void 0):(E.detail=_,E.fields=void 0),b.describe(E)}},T=e??{},k=T.format;return k==="json"?Ba(v,T):k==="pretty"?Va(v,T):k==="mermaid"?ho(v,T):k==="mermaid-url"?Ga(v,T):k==="d2"?$a(v,T):k==="ascii"?eo(v,T):v}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${r}`;n.push(s),n.push(...this._mounts.get(r)._collectSubgraphs(`${s}${Z}`))}return n}resourceProfile(e){return io(this,e)}reachable(e,n,r={}){return r.withDetail===!0?lo(this.describe(),e,n,{...r,withDetail:!0}):lo(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,d]of Object.entries(s.nodes))d.lastMutation!=null&&i.set(a,d.lastMutation);return to(s,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",s=0,o=F(s,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,ht(()=>{a=!1,!d&&(s+=1,o.emit(s))}))},c=i.onEvent(g=>{let b=g.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||u()}),f=[],p=new WeakSet,h=g=>{if(p.has(g)||d)return;p.add(g);let b=g.topology.subscribe(y=>{for(let v of y){if(v[0]!==w)continue;let T=v[1];if(u(),T.kind==="added"&&T.nodeKind==="mount"){let k=g._mounts.get(T.name);k!=null&&h(k)}}});f.push(b);for(let y of g._mounts.keys()){let v=g._mounts.get(y);v!=null&&h(v)}};h(this);let l;try{l=xe([o],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(g,b)=>g===b})}catch(g){c();for(let b of f)b();throw i.dispose(),g}let m=It(l);return{node:l,dispose(){d=!0,c();for(let g of f)g();f.length=0,i.dispose(),m()}}}_explainReactive(e,n,r){let s=0,o=F(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(h=>{let l=h.type;l!=="data"&&l!=="error"&&l!=="complete"&&l!=="teardown"||a||d||(a=!0,ht(()=>{a=!1,!d&&(s+=1,o.emit(s))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},f;try{f=xe([o],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(h,l)=>h.found===l.found&&h.reason===l.reason&&h.steps.length===l.steps.length&&Ya(h.steps,l.steps)})}catch(h){throw u(),i.dispose(),h}let p=It(f);return{node:f,dispose(){d=!0,u(),i.dispose(),p()}}}_pathsMatching(e){let n=Zt(e),r=[];return this._collectObserveTargets("",r),r.map(([s])=>s).filter(s=>n.test(s))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${Z}${r}`;this._mounts.get(r)._collectObserveTargets(s,n)}for(let r of[...this._nodes.keys()].sort()){let s=this._nodes.get(r),o=e===""?r:`${e}${Z}${r}`;n.push([o,s]),this._appendMetaObserveTargets(o,s,n)}}_appendMetaObserveTargets(e,n,r){for(let s of Object.keys(n.meta).sort()){let o=n.meta[s],i=`${e}${Z}${Me}${Z}${s}`;r.push([i,o]),this._appendMetaObserveTargets(i,o,r)}}observe(e,n){let r=typeof e=="string",o=co(r?n:e),i=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,a=o.actor;if(r){let c=e,f=this.resolve(c);if(a!=null&&!f.allowsObserve(a))throw new Ne({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,f]],o,"one"):{subscribe(p){return f.subscribe(p)},up(p){try{f.up?.(p)}catch(h){if(h instanceof Ne)return;throw h}}}}let d=[];this._collectObserveTargets("",d),d.sort((c,f)=>c[0]<f[0]?-1:c[0]>f[0]?1:0);let u=a==null?d:d.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,o,"all"):{subscribe:c=>{let f=u.map(([p,h])=>h.subscribe(l=>{c(p,l)}));return()=>{for(let p of f)p()}},up:(c,f)=>{try{this.resolve(c).up?.(f)}catch(p){if(p instanceof Ne)return;throw p}}}}_buildStructuredObserver(e,n,r){let s=r==="one"?e[0]?.[0]:void 0,o=i=>{if(r==="one"&&s!=null){let c=this.resolve(s);return this._buildStructuredObserver([[s,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,f)=>c[0]<f[0]?-1:c[0]>f[0]?1:0);let d=i.actor,u=d==null?a:a.filter(([,c])=>c.allowsObserve(d));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,o)}_createObserveResult(e,n,r){let s=n.timeline===!0,o=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",d=this.config.inspectorEnabled,u=(o||i)&&d,c=n.maxEvents,f=c!=null&&c>0?new qe(c):null,p=[],h=new Set,l={},m=new Set,g=0,b=0,y=0,v=0,T=0,k=0,_=!1,E=!1,S=0,A=new Map,I=new Map,D=new Map,L=P=>{f?f.push(P):p.push(P);for(let q of h)q(P)},O=()=>s?{timestamp_ns:ne(),in_batch:_t(),batch_id:S}:{},$=(P,q)=>{if(!(!u||!(P instanceof oe)))return P._setInspectorHook(pe=>{if(pe.kind==="dep_message")A.set(P,pe.depIndex);else if(pe.kind==="run"){let Ge=pe.batchData.map((U,ce)=>U!=null&&U.length>0?U.at(-1):pe.prevData[ce]);I.set(P,Ge);let be=pe.batchData.map(U=>U!=null?[...U]:void 0);D.set(P,be),i&&L({type:"derived",path:q,dep_values:Ge,dep_batches:be,...O()})}})},ee=P=>{let q=A.get(P),pe=I.get(P);if(!o||pe==null)return{};let be=(q!=null&&q>=0&&P instanceof oe?P._deps[q]:void 0)?.node,U=be?.v,ce=D.get(P);return{trigger_dep_index:q,trigger_dep_name:be?.name,...U!=null?{trigger_version:{id:U.id,version:U.version}}:{},dep_values:[...pe],...ce!=null?{dep_batches:ce}:{}}},z=[],te=[];for(let[P,q]of e){let pe=$(q,P);pe&&z.push(pe),te.push(q.subscribe(Ge=>{S++;for(let be of Ge){let U=be[0],ce=O();if(U===w){l[P]=be[1];let Pe=q instanceof oe?q.lastMutation?.actor??et:et;L({type:"data",path:P,data:be[1],actor:Pe,...ce,...ee(q)})}else if(a)U===G?g++:U===M?b++:U===ve?y++:U===me?v++:U===Te?T++:U===K?k++:U===x&&!m.has(P)?_=!0:U===N&&(E=!0,m.add(P));else if(U===G)g++,L({type:"dirty",path:P,...ce});else if(U===M)b++,L({type:"resolved",path:P,...ce,...ee(q)});else if(U===ve)y++,L({type:"invalidate",path:P,...ce});else if(U===me)v++,L({type:"pause",path:P,lockId:be[1],...ce});else if(U===Te)T++,L({type:"resume",path:P,lockId:be[1],...ce});else if(U===x)m.has(P)||(_=!0),L({type:"complete",path:P,...ce});else if(U===N){E=!0,m.add(P);let Pe=q instanceof oe?q.lastMutation?.actor??et:et;L({type:"error",path:P,data:be[1],actor:Pe,...ce})}else U===K&&(k++,L({type:"teardown",path:P,...ce}))}}))}let ke=!1,De=()=>{if(!ke){ke=!0;for(let P of te)P();for(let P of z)P();for(let P of ge)P({value:void 0,done:!0});ge.length=0}},_e=[],ge=[];h.add(P=>{let q=ge.shift();q?q({value:P,done:!1}):_e.push(P)});let Ve={get values(){return l},get dirtyCount(){return g},get resolvedCount(){return b},get invalidateCount(){return y},get pauseCount(){return v},get resumeCount(){return T},get teardownCount(){return k},get events(){return f?f.toArray():[...p]},get anyCompletedCleanly(){return _},get anyErrored(){return E},get completedWithoutErrors(){return _&&!E},onEvent(P){return h.add(P),()=>h.delete(P)},dispose:De,expand(P){De();let q={...n};return typeof P=="string"?q.detail=P:Object.assign(q,P),r(co(q))},[Symbol.asyncIterator](){return{next(){return _e.length>0?Promise.resolve({value:_e.shift(),done:!1}):ke?Promise.resolve({value:void 0,done:!0}):new Promise(P=>ge.push(P))},return(){return De(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Ve,n),Ve}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let s=n.logger??(l=>console.log(l)),o=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=o==null&&i==null?()=>!0:l=>(o==null||o.has(l))&&(i==null||!i.has(l)),d=Wa(n.theme),u=r==="stage-log"?ne():0,c=l=>l==null?"":n.stageLabels?.[l]??l,f=(l,m)=>l.length>m?`${l.slice(0,m-1)}\u2026`:l,p=l=>l.type==="data"||l.type==="error"?f(en(l.data),120):"",h=l=>{if(r==="stage-log"){let E=(ne()-u)/1e9,S=c(l.path).padEnd(9);if(l.type==="data"){let A=p(l);return`[${E.toFixed(3)}s] ${S} \u2190${A?` ${A}`:""}`}if(l.type==="error"){let A=p(l);return`[${E.toFixed(3)}s] ${S} \u2717${A?` ${A}`:""}`}return l.type==="complete"?`[${E.toFixed(3)}s] ${S} \u25A0 complete`:`[${E.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 m=d[l.type]??"",g=l.path?`${d.path}${l.path}${d.reset} `:"",b=l.type==="data"||l.type==="error",y=l.type==="pause"||l.type==="resume",v=b?` ${en(l.data)}`:y?` ${en(l.lockId)}`:"",T=l.type==="data"||l.type==="resolved"||l.type==="derived"?l:void 0,k=T?.trigger_dep_name!=null?` <- ${T.trigger_dep_name}`:T?.trigger_dep_index!=null?` <- #${T.trigger_dep_index}`:"",_=l.in_batch?" [batch]":"";return`${g}${m}${l.type.toUpperCase()}${d.reset}${v}${k}${_}`};e.onEvent(l=>{a(l.type)&&s(h(l),l)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){ao(this._disposers,this.name),this.signal([[K]],{internal:!0}),ao(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}snapshot(e){let{expand:n,...r}=this.describe({detail:"full"}),s={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:d,guard:u,...c}=r.nodes[a];s[a]=c}let o=[...r.subgraphs].sort(),i={...r,version:1,nodes:s,subgraphs:o};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return nr(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??le,{codec:s,codecVersion:o,payload:i}=rr(e,r);return s.decode(i,o)}restore(e,n){if(uo(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(o=>Zt(o)),s=n?.includeProducers===!0;for(let o of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(o)))continue;let i=e.nodes[o];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let d=this.tryResolve(o)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){n?.onError?.(o,a)}}}}}static fromSnapshot(e,n){uo(e);let r=typeof n=="function"?n:n?.build,s=typeof n=="function"?void 0:n?.factories,o=new t(e.name);if(r)return r(o),o.restore(e),o;for(let h of[...e.subgraphs].sort((l,m)=>{let g=l.split(Z).length,b=m.split(Z).length;return g!==b?g-b:l<m?-1:l>m?1:0})){let l=h.split(Z),m=o;for(let g of l)m._mounts.has(g)||m.mount(g,new t(g)),m=m._mounts.get(g)}let i=s?Object.entries(s).map(([h,l])=>({re:Zt(h),factory:l})):[],a=h=>{for(let l of i)if(l.re.test(h))return l.factory},d=h=>{let l=h.split(Z),m=l.pop();if(m==null||m.length===0)throw new Error(`invalid snapshot path "${h}"`);let g=o;for(let b of l){let y=g._mounts.get(b);if(!y)throw new Error(`unknown mount "${b}" in path "${h}"`);g=y}return[g,m]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${Z}${Me}${Z}`)).sort((h,l)=>h[0]<l[0]?-1:h[0]>l[0]?1:0),c=new Map(u),f=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[h,l]of[...c.entries()]){let m=l?.deps??[];if(!m.every(k=>f.has(k)))continue;let[g,b]=d(h),y={...l?.meta??{}},v=a(h),T;if(l?.type==="state")T=F(l.value,{meta:y});else{if(v==null)continue;T=v(b,{path:h,type:l.type,value:l.value,meta:y,deps:m,resolvedDeps:m.map(k=>f.get(k))})}g.add(T,{name:b}),f.set(h,T),c.delete(h),p=!0}}if(c.size>0){let h=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let s=(u,c)=>{if(u.disposed)return;let f=Ca(c.nodes);if(u.lastSnapshot!=null&&f!==""&&f===u.lastFingerprint)return;let p=u.seq+1,h=re(),g=u.lastSnapshot==null||p%u.compactEvery===0?{mode:"full",snapshot:c,seq:p,timestamp_ns:h,format_version:ut}:{mode:"diff",diff:Ja(u.lastSnapshot,c),seq:p,timestamp_ns:h,format_version:ut};if(u.tier.filter&&!u.tier.filter(this.name,g))return;let b;try{b=u.tier.save(this.name,g)}catch(y){n.onError?.(y,u.tier);return}if(b&&typeof b.then=="function"){let T=(u.savePending??Promise.resolve()).then(()=>b,()=>b).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=c,u.lastFingerprint=f)},k=>{n.onError?.(k,u.tier)});u.savePending=T.finally(()=>{u.savePending===T&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=c,u.lastFingerprint=f},o=(u,c)=>{try{s(u,c)}catch(f){n.onError?.(f,u.tier)}},i=(u,c)=>{if(!c.some(l=>{let m=this.config.messageTier(l[0]);return m>=3&&m<5}))return;if(n.filter){let l=this.tryResolve(u);if(l==null)return;let m=jn(l,Ht("standard"));if(!n.filter(u,m))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let l of r)l.disposed||(l.debounceMs===0?o(l,h()):(l.timer==null&&(l.timer=new Oe),l.timer.start(l.debounceMs,()=>{l.disposed||o(l,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(f=>{let p=this.tryResolve(f);return p==null?()=>{}:p.subscribe(h=>i(f,h))});a=()=>{for(let f of c)f()}}else a=this.observe().subscribe((u,c)=>i(u,c));let d=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,n){for(let r of e){let s;try{s=await r.load(this.name)}catch(i){n?.(i,r);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===ut&&o.nodes!=null)return this.restore(o),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let s of n){let o;try{o=await s.load(e)}catch(d){r?.onError?.(d,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===ut&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(d){r?.onError?.(d,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,n,r){if(e!=null&&n!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,n),this.config.inspectorEnabled){let s={path:e,annotation:n,timestamp_ns:ne(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(s=>!e(s)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let s of n)this._traceRing.push(s);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(n.nodes)),o=[...s].filter(y=>!r.has(y)).sort(),i=[...r].filter(y=>!s.has(y)).sort(),a=[],d=[];for(let y of r){if(!s.has(y))continue;let v=e.nodes[y],T=n.nodes[y],k=v.v,_=T.v;k!=null&&_!=null&&k.id===_.id&&k.version!==_.version&&d.push({path:y,id:k.id,from:k.version,to:_.version});let E=k!=null&&_!=null&&k.id===_.id&&k.version===_.version;for(let S of["type","status","sentinel"]){let A=v[S],I=T[S];A!==I&&a.push({path:y,field:S,from:A,to:I})}if(!E)for(let S of["value","meta"]){let A=v[S],I=T[S];Da(A,I)||a.push({path:y,field:S,from:A,to:I})}}let u=y=>`${y.from} ${y.to}`,c=new Set(e.edges.map(u)),f=new Set(n.edges.map(u)),p=n.edges.filter(y=>!c.has(u(y))),h=e.edges.filter(y=>!f.has(u(y))),l=new Set(e.subgraphs),m=new Set(n.subgraphs),g=[...m].filter(y=>!l.has(y)).sort(),b=[...l].filter(y=>!m.has(y)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:p,edgesRemoved:h,subgraphsAdded:g,subgraphsRemoved:b}}};function Ja(t,e){let n=xt.diff(t,e),r={};for(let s of n.nodesAdded){let o=e.nodes[s];o!=null&&(r[s]=o)}return{...n,nodesAddedFull:r}}function lo(t,e,n,r={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?s:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=r.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return r.withDetail?s:[];let i=new Map,a=new Map,d=new Map,u=new Map,c=new Set;for(let[v,T]of Object.entries(t.nodes)){if(!v)continue;c.add(v);let k=T.deps??[];i.set(v,k);for(let _ of k)_&&(c.add(_),a.has(_)||a.set(_,new Set),a.get(_).add(v))}for(let v of t.edges){if(v==null||typeof v!="object")continue;let T=typeof v.from=="string"?v.from:"",k=typeof v.to=="string"?v.to:"";!T||!k||(c.add(T),c.add(k),u.has(T)||u.set(T,new Set),u.get(T).add(k),d.has(k)||d.set(k,new Set),d.get(k).add(T))}if(!c.has(e))return r.withDetail?s:[];let f=r.both===!0,p=v=>{if(f){let E=i.get(v)??[],S=d.get(v),A=a.get(v),I=u.get(v),D=[...E];return S&&D.push(...S),A&&D.push(...A),I&&D.push(...I),D}if(n==="upstream"){let E=i.get(v)??[],S=d.get(v);return S?[...E,...S]:E}let T=a.get(v),k=u.get(v),_=T?[...T]:[];return k&&_.push(...k),_},h=new Set([e]),l=new Map,m=[{path:e,depth:0}],g=0,b=!1;for(;g<m.length;){let v=m[g++];if(o!=null&&v.depth>=o){p(v.path).length>0&&(b=!0);continue}for(let T of p(v.path))!T||h.has(T)||(h.add(T),l.set(T,v.depth+1),m.push({path:T,depth:v.depth+1}))}let y=[...l.keys()].sort((v,T)=>v<T?-1:v>T?1:0);return r.withDetail?{paths:y,depths:l,truncated:b}:y}function Ya(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],s=e[n];if(r.path!==s.path||r.type!==s.type||r.status!==s.status||r.hop!==s.hop||r.dep_index!==s.dep_index||r.annotation!==s.annotation||r.value!==s.value||r.lastMutation!==s.lastMutation)return!1;let o=r.v,i=s.v;if(o!==i&&(o==null||i==null||o.id!==i.id||o.version!==i.version))return!1}return!0}function Qa(t,e,n,r){let s=new xt(t,r);s.add(e,{name:"source"});let o=F(n,{meta:{kind:"stratify_rules"}});s.add(o,{name:"rules"});for(let i of n)Xa(s,e,o,i);return s}function Xa(t,e,n,r){let s=`branch/${r.name}`,o=Symbol("noValue"),i=!1,a=!1,d=!1,u=o,c=!1,f=n.cache??[];function p(m){if(d){d=!1;let g=u;if(u=o,g!==o){let b=f.find(v=>v.name===r.name),y=!1;try{y=b?.classify(g)??!1}catch{y=!1}y?(c=!1,m.emit(g)):c&&(c=!1,m.down([[G],[M]]))}else c?(c=!1,m.down([[G],[M]])):m.down([[M]])}}let h=B([],(m,g)=>{let b=e.subscribe(v=>{for(let T of v)l(T,0,g)}),y=n.subscribe(v=>{for(let T of v)l(T,1,g)});return()=>{b(),y()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:r.name},completeWhenDepsComplete:!1});function l(m,g,b){let y=m[0];return y===G?(g===0?(i=!0,c=!0):a=!0,!0):y===w||y===M?(g===0?(i=!1,d=!0,u=y===w?m[1]:o):(y===w&&(f=m[1]),a=!1),i||a||p(b),!0):y===x||y===N||y===K?(i=!1,a=!1,d=!1,u=o,c=!1,g===0&&b.down([m]),!0):g===1}if(t.add(h,{name:s}),r.ops){let m=r.ops(h),g=`branch/${r.name}/out`;t.add(m,{name:g})}}At();ye();X();we();ue();Ie();X();var Za=new Map([[ve,"INVALIDATE"],[me,"PAUSE"],[Te,"RESUME"],[K,"TEARDOWN"],[x,"COMPLETE"],[N,"ERROR"]]),eu=new Map([["INVALIDATE",ve],["PAUSE",me],["RESUME",Te],["TEARDOWN",K],["COMPLETE",x],["ERROR",N]]);function Je(t){let e=Za.get(t);return e||(Symbol.keyFor(t)??"UNKNOWN")}function dt(t){let e=eu.get(t);if(e)return e;if(t&&t!=="UNKNOWN")return Symbol.for(t)}function ct(t){return t instanceof Error?{message:t.message,name:t.name,stack:t.stack}:{message:String(t),name:"Error"}}function lt(t){let e=new Error(t.message);return e.name=t.name,t.stack&&(e.stack=t.stack),e}function Ye(t){if(typeof MessagePort<"u"&&t instanceof MessagePort)return{post(e,n){t.postMessage(e,n??[])},listen(e){let n=r=>e(r.data);return t.addEventListener("message",n),t.start(),()=>t.removeEventListener("message",n)},terminate(){t.close()}};if(typeof SharedWorker<"u"&&t instanceof SharedWorker)return Ye(t.port);if(typeof Worker<"u"&&t instanceof Worker)return{post(e,n){t.postMessage(e,n??[])},listen(e){let n=r=>e(r.data);return t.addEventListener("message",n),()=>t.removeEventListener("message",n)},terminate(){t.terminate()}};if(typeof BroadcastChannel<"u"&&t instanceof BroadcastChannel)return{post(e,n){n&&n.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),t.postMessage(e)},listen(e){let n=r=>e(r.data);return t.addEventListener("message",n),()=>t.removeEventListener("message",n)},terminate(){t.close()}};if(typeof ServiceWorker<"u"&&t instanceof ServiceWorker)return{post(e,n){t.postMessage(e,n??[])},listen(e){let n=r=>{r.source===t&&e(r.data)};return navigator.serviceWorker.addEventListener("message",n),()=>navigator.serviceWorker.removeEventListener("message",n)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function tu(t){return typeof t=="object"&&t!==null&&typeof t.post=="function"&&typeof t.listen=="function"}function go(t,e){let n=tu(t)?t:Ye(t),r=e.name??"workerBridge",s=Object.entries(e.expose??{}),o=e.import??[],i=e.transfer??{},a=F("connecting",{name:`${r}::meta::status`}),d=F(null,{name:`${r}::meta::error`}),u=new Map,c=new Map;for(let y of o){let v=F(void 0,{name:`${r}::${y}`});u.set(y,v)}let f;if(s.length>0){let y=s.map(([,k])=>k),v=B(y,(k,_)=>{let E={};for(let S=0;S<s.length;S++){let[A]=s[S],I=k[S];I!=null&&I.length>0&&(E[A]=I.at(-1))}Object.keys(E).length!==0&&_.emit(E)},{name:`${r}::aggregated`,partial:!0});f=Mt([v],k=>{let _=k[0];if(_==null||Object.keys(_).length===0)return;let E=[];for(let I of Object.keys(_)){let D=i[I];D&&E.push(...D(_[I]))}let S;for(let[I,D]of s)I in _&&D.v!=null&&(S==null&&(S={}),S[I]=D.v.version);let A={t:"b",u:_,...S?{v:S}:{}};try{n.post(A,E.length>0?E:void 0)}catch(I){d.down([[w,I instanceof Error?I:new Error(String(I))]])}}).subscribe(()=>{})}let p=!1,h=n.listen(y=>{if(p)return;let v=y;switch(v.t){case"r":{j(()=>{for(let[k,_]of Object.entries(v.stores)){let E=u.get(k);E&&E.down([[w,_]])}}),a.down([[w,"connected"]]);let T={};for(let[k,_]of s)T[k]=_.cache;n.post({t:"i",stores:T});break}case"v":{let T=u.get(v.s);T&&T.down([[w,v.d]]);break}case"b":{j(()=>{for(let[T,k]of Object.entries(v.u)){let _=v.v?.[T];if(_!=null){let S=c.get(T);if(S!=null&&_<=S)continue;c.set(T,_)}let E=u.get(T);E&&E.down([[w,k]])}});break}case"e":{let T=u.get(v.s);T&&T.down([[N,lt(v.err)]]);break}case"s":{let T=dt(v.sig);if(!T)break;let k=v.s==="*"?[...u.values()]:u.has(v.s)?[u.get(v.s)]:[];for(let _ of k)_.down(v.d===void 0?[[T]]:[[T,v.d]]);break}}}),l=[];for(let[y,v]of s){let T=v.subscribe((k=>{if(!p)for(let _ of k){let E=_[0];E!==w&&(le.isLocalOnly(E)||(E===N?n.post({t:"e",s:y,err:ct(_[1])}):n.post({t:"s",s:y,sig:Je(E),d:_.length>1?_[1]:void 0})))}}));l.push(T)}let m;if(e.timeoutMs!=null&&e.timeoutMs>0){let y=He(e.timeoutMs),v=Bt(a,k=>k==="connected");m=Gn(vt(Lt(y,()=>"timeout"),Lt(v,()=>"ready"))).subscribe(k=>{for(let _ of k)_[0]===w&&_[1]==="timeout"&&(d.down([[w,new Error("Worker bridge handshake timeout")]]),g())})}function g(){if(!p){p=!0,m?.(),n.post({t:"s",s:"*",sig:Je(K)}),f&&f();for(let y of l)y();l.length=0,h(),a.down([[w,"closed"]]),c.clear(),u.clear()}}let b={meta:{status:a,error:d},destroy:g};for(let[y,v]of u)b[y]=v;return b}ye();X();we();ue();function nu(t){return typeof t=="object"&&t!==null&&typeof t.post=="function"&&typeof t.listen=="function"}function bo(t,e){let n=nu(t)?t:Ye(t),r=e.import??[],s=e.transfer??{},o=new Map,i=new Map,a={};for(let g of r){let b=F(void 0,{name:`worker::${g}`});o.set(g,b),a[g]=b}let d=e.expose(a),u=Object.entries(d),c,f=!1;if(u.length>0){let g=u.map(([,v])=>v),b=B(g,(v,T)=>{let k={};for(let _=0;_<u.length;_++){let[E]=u[_],S=v[_];S!=null&&S.length>0&&(k[E]=S.at(-1))}Object.keys(k).length!==0&&T.emit(k)},{name:"workerSelf::aggregated",partial:!0});c=Mt([b],v=>{if(f)return;let T=v[0];if(T==null||Object.keys(T).length===0)return;let k=[];for(let S of Object.keys(T)){let A=s[S];A&&k.push(...A(T[S]))}let _;for(let[S,A]of u)S in T&&A.v!=null&&(_==null&&(_={}),_[S]=A.v.version);let E={t:"b",u:T,..._?{v:_}:{}};try{n.post(E,k.length>0?k:void 0)}catch{}}).subscribe(()=>{})}let p=[];for(let[g,b]of u){let y=b.subscribe((v=>{if(!f)for(let T of v){let k=T[0];k!==w&&(le.isLocalOnly(k)||(k===N?n.post({t:"e",s:g,err:ct(T[1])}):n.post({t:"s",s:g,sig:Je(k),d:T.length>1?T[1]:void 0})))}}));p.push(y)}let h=n.listen(g=>{if(f)return;let b=g;switch(b.t){case"i":{j(()=>{for(let[y,v]of Object.entries(b.stores)){let T=o.get(y);T&&T.down([[w,v]])}});break}case"v":{let y=o.get(b.s);y&&y.down([[w,b.d]]);break}case"b":{j(()=>{for(let[y,v]of Object.entries(b.u)){let T=b.v?.[y];if(T!=null){let _=i.get(y);if(_!=null&&T<=_)continue;i.set(y,T)}let k=o.get(y);k&&k.down([[w,v]])}});break}case"e":{let y=o.get(b.s);y&&y.down([[N,lt(b.err)]]);break}case"s":{let y=dt(b.sig);if(!y)break;if(y===K&&b.s==="*"){m();return}let v=b.s==="*"?[...o.values()]:o.has(b.s)?[o.get(b.s)]:[];for(let T of v)T.down(b.d===void 0?[[y]]:[[y,b.d]]);break}}}),l={};for(let[g,b]of u)l[g]=b.cache;n.post({t:"r",stores:l});function m(){if(!f){f=!0,c&&c();for(let g of p)g();p.length=0,h(),n.terminate?.(),i.clear(),o.clear()}}return{destroy:m}}0&&(module.exports={CircuitOpenError,NS_PER_MS,NS_PER_SEC,NativeIndexBackend,NativeListBackend,NativeLogBackend,NativeMapBackend,NativePubSubBackend,RateLimiterOverflowError,ResettableTimer,TimeoutError,audit,awaitSettled,buffer,bufferCount,bufferTime,cached,cascadingCache,catchError,checkpointToRedis,checkpointToS3,circuitBreaker,combine,combineLatest,concat,concatMap,constant,createTransport,createWatermarkController,csvRows,debounce,debounceTime,decorrelatedJitter,delay,deserializeError,dictStorage,distill,distinctUntilChanged,elementAt,empty,escapeRegexChar,exhaustMap,exponential,externalBundle,externalProducer,fallback,fibonacci,filter,find,first,firstValueFrom,firstWhere,flatMap,forEach,fromAny,fromAsyncIter,fromCSV,fromClickHouseWatch,fromCron,fromDrizzle,fromEvent,fromHTTP,fromHTTPPoll,fromHTTPStream,fromIter,fromKafka,fromKysely,fromMCP,fromNATS,fromNDJSON,fromOTel,fromPrisma,fromPrometheus,fromPromise,fromPulsar,fromRabbitMQ,fromRaf,fromRedisStream,fromSSE,fromSqlite,fromSqliteCursor,fromStatsD,fromSyslog,fromTimer,fromWebSocket,fromWebSocketReconnect,fromWebhook,globToRegExp,interval,keepalive,last,linear,lru,map,matchesAnyPattern,matchesCron,memoryStorage,merge,mergeMap,nameToSignal,ndjsonRows,never,of,pairwise,parseCron,parsePrometheusText,parseStatsD,parseSyslog,pausable,pubsub,race,rateLimiter,reactiveCounter,reactiveIndex,reactiveList,reactiveLog,reactiveMap,reactiveSink,reduce,repeat,replay,rescue,resolveBackoffPreset,retry,retrySource,sample,scan,serializeError,share,shareReplay,signalToName,singleFromAny,singleNodeFromAny,skip,sortJsonValue,stableJsonString,stratify,switchMap,take,takeUntil,takeWhile,tap,throttle,throttleTime,throwError,timeout,toArray,toCSV,toClickHouse,toFile,toHTTP,toKafka,toLoki,toMongo,toNATS,toObservable,toPostgres,toPulsar,toRabbitMQ,toReadableStream,toRedisStream,toS3,toSSE,toSSEBytes,toSqlite,toTempo,toWebSocket,tokenBucket,valve,verifiable,window,windowCount,windowTime,withBreaker,withLatestFrom,withMaxAttempts,withStatus,workerBridge,workerSelf,zip});
|
|
18
|
+
`:JSON.stringify(f),l=o(p,re());await e.putObject({Bucket:n,Key:l,Body:h,ContentType:c})}})}function Ci(t,e,n,r){let{toSQL:s=(i,a)=>({sql:`INSERT INTO "${a.replace(/"/g,'""')}" (data) VALUES ($1)`,params:[JSON.stringify(i)]}),onTransportError:o}=r??{};return ie(t,{onTransportError:o,serialize:i=>s(i,n),send:async i=>{let a=i;await e.query(a.sql,a.params)}})}function Di(t,e,n){let{toDocument:r=o=>o,onTransportError:s}=n??{};return ie(t,{onTransportError:s,serialize:r,send:async o=>{await e.insertOne(o)}})}function Pi(t,e,n){let{labels:r={},toLine:s=a=>JSON.stringify(a),toLabels:o,onTransportError:i}=n??{};return ie(t,{onTransportError:i,serialize:a=>({line:s(a),labels:o?{...r,...o(a)}:r}),send:async a=>{let{line:d,labels:u}=a,c=`${re()}`;await e.push({streams:[{stream:u,values:[[c,d]]}]})}})}function Ii(t,e,n){let{toResourceSpans:r=o=>[o],onTransportError:s}=n??{};return ie(t,{onTransportError:s,serialize:r,send:async o=>{await e.push({resourceSpans:o})}})}function Li(t,e,n,r){let{prefix:s="checkpoints/",debounceMs:o=500,compactEvery:i=10,onError:a}=r??{},d={debounceMs:o,compactEvery:i,save(u,c){let p=Math.floor(re()/1e6),f=`${s}${t.name}/checkpoint-${p}.json`,h;try{h=JSON.stringify(c)}catch(l){a?.(l);return}e.putObject({Bucket:n,Key:f,Body:h,ContentType:"application/json"}).catch(l=>a?.(l))},load(){return null}};return t.attachStorage([d],{onError:u=>a?.(u)})}function Bi(t,e,n){let{prefix:r="graphrefly:checkpoint:",debounceMs:s=500,compactEvery:o=10,onError:i}=n??{},a=`${r}${t.name}`,d={debounceMs:s,compactEvery:o,save(u,c){let p;try{p=JSON.stringify(c)}catch(f){i?.(f);return}e.set(a,p).catch(f=>i?.(f))},async load(){let u=await e.get(a);if(u==null)return null;try{return JSON.parse(u)}catch{return null}}};return t.attachStorage([d],{onError:u=>i?.(u)})}function Vi(t,e,n){let{mapRow:r=i=>i,params:s,...o}=n??{};return R(i=>{try{let d=t.query(e,s).map(r);i.emit(d),i.down([[_]])}catch(a){i.down([[N,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function Gi(t,e,n){let{mapRow:r=i=>i,params:s,...o}=n??{};return R(i=>{try{let a=t.iterate(e,s);j(()=>{for(let d of a)i.emit(r(d));i.down([[_]])})}catch(a){i.down([[N,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function Fi(t,e,n,r){if(n.includes("\0")||n.length===0)throw new Error(`toSqlite: invalid table name: ${JSON.stringify(n)}`);let{toSQL:s=(O,$)=>({sql:`INSERT INTO "${$.replace(/"/g,'""')}" (data) VALUES (?)`,params:[JSON.stringify(O)]}),onTransportError:o,batchInsert:i=!1,maxBatchSize:a=1e3,flushIntervalMs:d=0}=r??{},u=O=>s(O,n);if(!i)return ie(t,{onTransportError:o,serialize:u,send:O=>{let $=O;e.query($.sql,$.params)}});let c=F(null),p=F(void 0,{equals:()=>!1}),f=F(null),h=F(0),l=F(0),m=O=>{try{o?.(O)}catch{}try{c.down([[w,O]])}catch{}},b=[],g=!1,y,v=!1,T=()=>l.down([[w,b.length]]),k=O=>{v||p.down([[w,O]])},x=O=>{v||f.down([[w,O]])},E=O=>{v||h.down([[w,O]])},S=O=>{v||m(O)},M=()=>{if(b.length===0||g)return;g=!0,E(1);try{e.query("BEGIN",[])}catch(z){g=!1,E(0),S({stage:"send",error:z instanceof Error?z:new Error(String(z)),value:void 0});return}let O=b;b=[],T();let $,ee=0;for(let z of O)try{e.query(z.query.sql,z.query.params),ee+=1}catch(te){$=te instanceof Error?te:new Error(String(te));break}if($){try{e.query("ROLLBACK",[])}catch{}S({stage:"send",error:$,value:void 0});for(let z of O)x({value:z.value,error:$,attempts:1})}else try{e.query("COMMIT",[]);for(let z of O)k(z.value)}catch(z){let te=z instanceof Error?z:new Error(String(z));S({stage:"send",error:te,value:void 0});for(let ke=0;ke<ee;ke++)x({value:O[ke].value,error:te,attempts:1})}g=!1,E(0)},I=()=>{d>0&&y===void 0&&!v&&(y=setTimeout(()=>{y=void 0,M()},d))},D=t.subscribe(O=>{for(let $ of O){let ee=$[0];if(ee===w){let z=$[1],te;try{te=u(z)}catch(ke){let De=ke instanceof Error?ke:new Error(String(ke));m({stage:"serialize",error:De,value:z}),f.down([[w,{value:z,error:De,attempts:0}]]);continue}b.push({value:z,query:te}),T(),b.length>=a?M():I()}else le.messageTier(ee)>=3&&M()}});return{dispose:()=>{if(!v){y!==void 0&&(clearTimeout(y),y=void 0),M(),v=!0,D();for(let O of[c,p,f,h,l])try{O.down([[K]])}catch{}}},sent:p,failed:f,inFlight:h,errors:c,buffered:l,flush:async()=>{v||M()}}}function $i(t,e){let{args:n,mapRow:r=o=>o,...s}=e??{};return R(o=>{let i=!0;return t.findMany(n).then(a=>{i&&(o.emit(a.map(r)),o.down([[_]]))}).catch(a=>{if(i)try{o.down([[N,a instanceof Error?a:new Error(String(a))]])}catch{}}),()=>{i=!1}},{...s,describeKind:"producer",completeWhenDepsComplete:!1})}function Ki(t,e){let{mapRow:n=s=>s,...r}=e??{};return R(s=>{let o=!0;return t.execute().then(i=>{o&&(s.emit(i.map(n)),s.down([[_]]))}).catch(i=>{if(o)try{s.down([[N,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}function zi(t,e){let{mapRow:n=s=>s,...r}=e??{};return R(s=>{let o=!0;return t.execute().then(i=>{o&&(s.emit(i.map(n)),s.down([[_]]))}).catch(i=>{if(o)try{s.down([[N,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}mt();X();var ji=0;function Hi(t,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let n=Symbol(`bp-${++ji}`),r=0,s=!1;return{onEnqueue(){return r+=1,!s&&r>=e.highWaterMark?(s=!0,t([[me,n]]),!0):!1},onDequeue(){return r>0&&(r-=1),s&&r<=e.lowWaterMark?(s=!1,t([[Te,n]]),!0):!1},get pending(){return r},get paused(){return s},dispose(){s&&(s=!1,t([[Te,n]]))}}}X();ue();function Fr(){let t=new Map,e=null,n=null;function r(o){o.prev?o.prev.next=o.next:e=o.next,o.next?o.next.prev=o.prev:n=o.prev,o.prev=null,o.next=null}function s(o){o.next=e,o.prev=null,e&&(e.prev=o),e=o,n===null&&(n=o)}return{insert(o){if(t.has(o)){this.touch(o);return}let i={key:o,prev:null,next:null};t.set(o,i),s(i)},touch(o){let i=t.get(o);i&&(r(i),s(i))},delete(o){let i=t.get(o);i&&(r(i),t.delete(o))},evict(o){let i=[];for(let a=0;a<o&&n!==null;a++){let d=n;i.push(d.key),r(d),t.delete(d.key)}return i},size(){return t.size}}}function $r(t){return t!=null&&typeof t.then=="function"}function it(t){$r(t)&&t.catch(()=>{})}function Wi(t,e){let n=new Map,r=e?.maxSize??0,s=r>0?e?.eviction??Fr():null,o=e?.writeThrough??!1;function i(u,c,p){for(let f=0;f<p;f++)try{it(t[f].save(u,c))}catch{}}function a(u,c,p=0){for(let f=p;f<t.length;f++){let h;try{h=t[f].load(u)}catch{continue}if($r(h)){let l=f;h.then(m=>{m!=null?(c.down([[w,m]]),i(u,m,l)):a(u,c,l+1)},()=>{a(u,c,l+1)});return}if(h!=null){c.down([[w,h]]),i(u,h,f);return}}}function d(){if(!(!s||r<=0))for(;s.size()>=r;){let u=s.evict(1);if(u.length===0)break;for(let c of u){let p=n.get(c);if(p){let f=p.cache;if(p.status!=="sentinel"&&t.length>0){let h=t.length-1;try{it(t[h].save(c,f))}catch{}for(let l=0;l<h;l++)try{let m=t[l].clear;m&&it(m.call(t[l],c))}catch{}}p.down([[K]])}n.delete(c)}}}return{load(u){let c=n.get(u);if(c)return s?.touch(u),c;s&&r>0&&s.size()>=r&&d();let p=F(void 0);return n.set(u,p),s?.insert(u),a(u,p),p},save(u,c){if(o)for(let f of t)try{it(f.save(u,c))}catch{}else if(t[0])try{it(t[0].save(u,c))}catch{}let p=n.get(u);if(p)p.down([[w,c]]),s?.touch(u);else{s&&r>0&&s.size()>=r&&d();let f=F(c);n.set(u,f),s?.insert(u)}},invalidate(u){let c=n.get(u);c&&a(u,c)},delete(u){s?.delete(u);let c=n.get(u);c&&c.down([[K]]),n.delete(u);for(let p of t)try{let f=p.clear;f&&it(f.call(p,u))}catch{}},has(u){return n.has(u)},get size(){return n.size}}}ye();X();ue();ye();Le();X();ue();var Ft=class{_version=0;_store=new Map;_maxSize;_defaultTtl;constructor(e={}){let{maxSize:n,defaultTtl:r}=e;if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(r!==void 0&&r<=0)throw new RangeError("defaultTtl must be positive");this._maxSize=n,this._defaultTtl=r}get version(){return this._version}get size(){return this._store.size}has(e){let n=this._store.get(e);return n===void 0?!1:this._isExpired(n)?(this._store.delete(e),this._version+=1,!1):(this._touchLru(e,n),!0)}get(e){let n=this._store.get(e);if(n!==void 0){if(this._isExpired(n)){this._store.delete(e),this._version+=1;return}return this._touchLru(e,n),n.value}}set(e,n,r){let s=this._resolveExpiresAt(r);this._store.has(e)&&this._store.delete(e),this._store.set(e,{value:n,expiresAt:s}),this._evictLruWhileOver(),this._version+=1}setMany(e,n){let r=this._resolveExpiresAt(n),s=0;try{for(let[o,i]of e)this._store.has(o)&&this._store.delete(o),this._store.set(o,{value:i,expiresAt:r}),s+=1}finally{s>0&&(this._evictLruWhileOver(),this._version+=1)}}delete(e){let n=this._store.delete(e);return n&&(this._version+=1),n}deleteMany(e){let n=0;try{for(let r of e)this._store.delete(r)&&(n+=1)}finally{n>0&&(this._version+=1)}return n}clear(){let e=this._store.size;return e===0?0:(this._store.clear(),this._version+=1,e)}pruneExpired(){let e=ne(),n=0;for(let[r,s]of this._store)this._isExpired(s,e)&&(this._store.delete(r),n+=1);return n>0&&(this._version+=1),n}toMap(){let e=ne(),n=new Map;for(let[r,s]of this._store)this._isExpired(s,e)||n.set(r,s.value);return n}_resolveExpiresAt(e){let n=e??this._defaultTtl;if(n!==void 0){if(!Number.isFinite(n)||n<=0)throw new RangeError(`MapBackend: ttl must be a positive finite number (got ${n})`);return ne()+n*1e9}}_isExpired(e,n){return e.expiresAt===void 0?!1:(n??ne())>=e.expiresAt}_touchLru(e,n){this._store.delete(e),this._store.set(e,n)}_evictLruWhileOver(){if(this._maxSize!==void 0)for(;this._store.size>this._maxSize;){let e=this._store.keys().next().value;if(e===void 0)break;this._store.delete(e)}}};function zn(t={}){let{name:e,maxSize:n,defaultTtl:r,versioning:s,backend:o,retention:i}=t;if(i&&n!==void 0)throw new RangeError("reactiveMap: `maxSize` (LRU) and `retention` (score-based) are mutually exclusive. Pick one eviction policy.");if(i&&i.archiveThreshold===void 0&&i.maxSize===void 0)throw new RangeError("reactiveMap: `retention` requires at least one of `archiveThreshold` or `maxSize` to trigger archival.");let a=o??new Ft({maxSize:n,defaultTtl:r}),d=F(a.toMap(),{name:e,describeKind:"state",equals:(f,h)=>f===h,...s!=null?{versioning:s}:{}});function u(){let f=a.toMap();j(()=>{d.down([[G]]),d.down([[w,f]])})}function c(){if(!i)return;let f=a.toMap(),h=i.archiveThreshold,l=i.maxSize,m=[];for(let[g,y]of f)m.push({key:g,value:y,score:i.score(g,y)});m.sort((g,y)=>g.score-y.score);let b=new Set;if(h!==void 0)for(let g of m)if(g.score<h)b.add(g.key);else break;if(l!==void 0&&m.length-b.size>l)for(let g of m){if(m.length-b.size<=l)break;b.has(g.key)||b.add(g.key)}if(b.size!==0)for(let g of m)b.has(g.key)&&(i.onArchive?.(g.key,g.value,g.score),a.delete(g.key))}function p(f,h="mutation"){let l=a.version;try{return f()}finally{a.version!==l&&(h==="mutation"&&c(),u())}}return{entries:d,has(f){return p(()=>a.has(f),"read")},get(f){return p(()=>a.get(f),"read")},set(f,h,l){p(()=>a.set(f,h,l?.ttl))},setMany(f,h){p(()=>a.setMany(f,h?.ttl))},delete(f){p(()=>a.delete(f))},deleteMany(f){p(()=>a.deleteMany(f))},clear(){p(()=>a.clear())},pruneExpired(){p(()=>a.pruneExpired())},get size(){return a.size},dispose(){}}}Ie();function Ui(t){return typeof t=="object"&&t!==null&&"cache"in t&&typeof t.subscribe=="function"}function qi(t,e,n){let r=de(t),s=r.v!=null,o=F(n?.initialVerified??null,{...s?{meta:{sourceVersion:null}}:{}}),i=n?.trigger!==void 0&&n.trigger!==null,a=null;if(i&&n?.autoVerify?a=vt(de(n.trigger),r):i?a=de(n.trigger):n?.autoVerify&&(a=r),a!==null){let d;if(a===r)d=Ce(r,u=>e(u));else{let u=r.cache;r.subscribe(c=>{for(let p of c)p[0]===w&&(u=p[1])}),d=Ce(a,()=>e(u))}Ue(d,u=>{j(()=>{if(o.down([[w,u]]),s){let c=r.v;c!=null&&o.meta.sourceVersion.down([[w,{id:c.id,version:c.version}]])}})})}return{node:r,verified:o,trigger:a}}function Kr(t){t.subscribe(()=>{})}function wt(t){return t instanceof Map?t:new Map}function zr(t,e){if(!Array.isArray(e.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");j(()=>{for(let{key:n,value:r}of e.upsert)t.set(n,r);for(let n of e.remove??[])t.delete(n)})}function Ji(t,e,n){let r=de(t),s=zn(n.mapOptions??{}),o=n.budget??2e3,a=n.context!==void 0&&n.context!==null?de(n.context):F(null),d=wt(s.entries.cache);s.entries.subscribe(h=>{for(let l of h)l[0]===w&&(d=wt(l[1]))});let u=Ce(r,h=>e(h,d));if(Ue(u,h=>{zr(s,h)}),n.evict){let h=new Map,l=xe([s.entries],([m])=>{let b=[],g=wt(m);for(let y of h.keys())g.has(y)||(h.get(y)(),h.delete(y));for(let[y,v]of g){let T=n.evict(y,v);if(Ui(T)){if(!h.has(y)){let k=Ue(T,x=>{x===!0&&s.has(y)&&s.delete(y)});h.set(y,k)}continue}if(typeof T=="boolean"){T&&b.push(y);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return b});Ue(l,m=>{for(let b of m)s.delete(b)})}let c=n.consolidateTrigger!==void 0&&n.consolidateTrigger!==null;if(n.consolidate&&c){let h=de(n.consolidateTrigger),l=Ce(h,()=>n.consolidate(d));Ue(l,m=>{zr(s,m)})}let p=xe([s.entries,a],([h,l])=>{let m=[...wt(h).entries()].map(([y,v])=>({key:y,value:v,score:n.score(v,l),cost:n.cost(v)}));m.sort((y,v)=>v.score-y.score);let b=[],g=o;for(let y of m)y.cost<=g&&(b.push({key:y.key,value:y.value,score:y.score}),g-=y.cost);return b}),f=xe([s.entries],([h])=>wt(h).size);return Kr(p),Kr(f),{store:s,compact:p,size:f}}async function jr(t){let e=typeof t=="string"?new TextEncoder().encode(t):t,n=await globalThis.crypto.subtle.digest("SHA-256",e),r=new Uint8Array(n),s="";for(let o=0;o<r.length;o++)s+=Hr[r[o]];return s}var Hr=new Array(256);for(let t=0;t<256;t++)Hr[t]=t.toString(16).padStart(2,"0");var $t=class extends Error{constructor(n,r){super(`content-addressed lookup miss in read-strict mode: ${n}`);this.key=n;this.context=r;this.name="ContentAddressedMissError"}};function Wr(t){let e=new Set,n=r=>{if(r===null||typeof r!="object")return r;let s=r;if(e.has(s))return{__cycle:!0};e.add(s);try{if(Array.isArray(r))return r.map(n);let o={};for(let i of Object.keys(r).sort())o[i]=n(r[i]);return o}finally{e.delete(s)}};return JSON.stringify(n(t))}function Yi(t){let{storage:e,keyContext:n,keyPrefix:r,mode:s="read-write"}=t,o=n??(a=>a);async function i(a){let d=Wr(o(a)),u=await jr(d);return r?`${r}:${u}`:u}return{keyFor:i,async lookup(a){if(s==="write")return;let d=await i(a),u=await e.load(d);if(u==null){if(s==="read-strict")throw new $t(d,a);return}return u},async store(a,d){if(s==="read")return;let u=await i(a);await e.save(u,d)},async forget(a){if(s==="read"||s==="write"||!e.clear)return;let d=await i(a);await e.clear(d)}}}On();async function Qi(t,e){let n;try{n=await t.text()}catch{n=""}let r=e??"HTTP",s=new Error(`${r} API ${t.status}: ${t.statusText}${n?` \u2014 ${n}`:""}`);return s.status=t.status,s.headers=t.headers,s}var jn=require("rxjs");X();function Xi(t,e){return e?.raw?new jn.Observable(n=>t.subscribe(s=>{if(!n.closed){n.next(s);for(let o of s){if(o[0]===N){n.error(o[1]);return}if(o[0]===_){n.complete();return}}}})):new jn.Observable(n=>t.subscribe(s=>{for(let o of s){if(n.closed)return;if(o[0]===w)n.next(o[1]);else if(o[0]===N){n.error(o[1]);return}else if(o[0]===_){n.complete();return}}}))}ye();X();we();var Kt=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(e){return this._topics.has(e)}topicNames(){return this._topics.values()}createTopic(e){return this._topics.has(e)?!1:(this._topics.add(e),this._version+=1,!0)}removeTopic(e){let n=this._topics.delete(e);return n&&(this._version+=1),n}};function Zi(t={}){let{backend:e}=t,n=e??new Kt,r=new Map;function s(o){let i=r.get(o);return i===void 0&&(i=B({describeKind:"state"}),r.set(o,i),n.createTopic(o)),i}return{topic(o){return s(o)},publish(o,i){s(o).emit(i)},publishMany(o){j(()=>{for(let[i,a]of o)s(i).emit(a)})},removeTopic(o){let i=r.get(o);return i===void 0?!1:(r.delete(o),n.removeTopic(o),i.down([[K]]),!0)},has(o){return n.hasTopic(o)},get size(){return n.topicCount},topicNames(){return n.topicNames()}}}ye();X();ue();function Ur(t,e){if(t===e)return 0;let n=typeof t;if(n===typeof e&&(n==="number"||n==="string"||n==="boolean"||n==="bigint")){let s=t,o=e;return s<o?-1:s>o?1:0}return String(t).localeCompare(String(e))}function ea(t,e){let n=Ur(t[0],e[0]);return n!==0?n:Ur(t[1],e[1])}function qr(t){return[t.secondary,t.primary]}function at(t,e){let n=qr(e),r=0,s=t.length;for(;r<s;){let o=r+s>>1;ea(n,qr(t[o]))>0?r=o+1:s=o}return r}var zt=class{_version=0;_buf=[];_byPrimary=new Map;get version(){return this._version}get size(){return this._buf.length}has(e){return this._byPrimary.has(e)}get(e){return this._byPrimary.get(e)?.value}upsert(e,n,r,s){let o=this._byPrimary.get(e),i={primary:e,secondary:n,value:r};if(o!==void 0&&s?.equals?.(o,i))return!1;if(o!==void 0){let d=at(this._buf,o);this._buf.splice(d,1)}let a=at(this._buf,i);return this._buf.splice(a,0,i),this._byPrimary.set(e,i),this._version+=1,o===void 0}upsertMany(e,n){let r=0;try{for(let s of e){let o=this._byPrimary.get(s.primary),i={primary:s.primary,secondary:s.secondary,value:s.value};if(o!==void 0&&n?.equals?.(o,i))continue;if(o!==void 0){let d=at(this._buf,o);this._buf.splice(d,1)}let a=at(this._buf,i);this._buf.splice(a,0,i),this._byPrimary.set(s.primary,i),r+=1}}finally{r>0&&(this._version+=1)}return r}delete(e){let n=this._byPrimary.get(e);if(n===void 0)return!1;let r=at(this._buf,n);return this._buf.splice(r,1),this._byPrimary.delete(e),this._version+=1,!0}deleteMany(e){let n=0;try{for(let r of e){let s=this._byPrimary.get(r);if(s===void 0)continue;let o=at(this._buf,s);this._buf.splice(o,1),this._byPrimary.delete(r),n+=1}}finally{n>0&&(this._version+=1)}return n}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._byPrimary.clear(),this._version+=1,e)}toArray(){return[...this._buf]}toPrimaryMap(){let e=new Map;for(let n of this._buf)e.set(n.primary,n.value);return e}};function ta(t){return t.subscribe(()=>{})}function na(t={}){let{name:e,versioning:n,equals:r,backend:s}=t,o=s??new zt;function i(h){return h?.equals!==void 0||r===void 0?h:{...h,equals:r}}let a=F([],{name:e,describeKind:"state",equals:(h,l)=>h===l,...n!=null?{versioning:n}:{}}),d=xe([a],([h])=>{let l=h,m=new Map;for(let b of l)m.set(b.primary,b.value);return m},{initial:o.toPrimaryMap(),describeKind:"derived"}),u=ta(d),c=!1;function p(){let h=o.toArray();j(()=>{a.down([[G]]),a.down([[w,h]])})}function f(h){let l=o.version;try{return h()}finally{o.version!==l&&p()}}return{ordered:a,byPrimary:d,has(h){return o.has(h)},get(h){return o.get(h)},get size(){return o.size},upsert(h,l,m,b){return f(()=>o.upsert(h,l,m,i(b)))},upsertMany(h,l){let m=[...h];m.length!==0&&f(()=>o.upsertMany(m,i(l)))},delete(h){f(()=>o.delete(h))},deleteMany(h){let l=[...h];l.length!==0&&f(()=>o.deleteMany(l))},clear(){f(()=>o.clear())},dispose(){c||(c=!0,u())}}}ye();X();ue();var jt=class{_version=0;_buf;constructor(e){this._buf=e?[...e]:[]}get version(){return this._version}get size(){return this._buf.length}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._buf.length+e;if(!(n<0||n>=this._buf.length))return this._buf[n]}append(e){this._buf.push(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._buf.length;this._buf.length=n+e.length;for(let r=0;r<e.length;r++)this._buf[n+r]=e[r];this._version+=1}insert(e,n){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insert: index ${e} out of range [0, ${this._buf.length}]`);this._buf.splice(e,0,n),this._version+=1}insertMany(e,n){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insertMany: index ${e} out of range [0, ${this._buf.length}]`);n.length!==0&&(this._buf.splice(e,0,...n),this._version+=1)}pop(e){if(this._buf.length===0)throw new RangeError("pop from empty list");if(!Number.isInteger(e))throw new RangeError(`pop: index ${e} must be an integer`);let n=e>=0?e:this._buf.length+e;if(n<0||n>=this._buf.length)throw new RangeError(`pop: index ${e} out of range`);let[r]=this._buf.splice(n,1);return this._version+=1,r}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function ra(t,e={}){let{name:n,versioning:r,backend:s}=e,o=s??new jt(t),i=F(o.toArray(),{name:n,describeKind:"state",equals:(u,c)=>u===c,...r!=null?{versioning:r}:{}});function a(){let u=o.toArray();j(()=>{i.down([[G]]),i.down([[w,u]])})}function d(u){let c=o.version;try{return u()}finally{o.version!==c&&a()}}return{items:i,get size(){return o.size},at(u){return o.at(u)},append(u){d(()=>o.append(u))},appendMany(u){d(()=>o.appendMany(u))},insert(u,c){d(()=>o.insert(u,c))},insertMany(u,c){d(()=>o.insertMany(u,c))},pop(u=-1){return d(()=>o.pop(u))},clear(){d(()=>o.clear())},dispose(){}}}ye();X();ue();var Ht=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,n){if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=n,n!==void 0){if(this._buf=new Array(n),e&&e.length>0){let r=Math.min(e.length,n),s=e.length-r;for(let o=0;o<r;o++)this._buf[o]=e[s+o];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._size+e;if(!(n<0||n>=this._size))return this._maxSize!==void 0?this._buf[(this._head+n)%this._maxSize]:this._buf[n]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=n;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let n=0;n<e;n++)this._buf[(this._head+n)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let n=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,n);else{for(let r=0;r<n;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+n)%this._maxSize}return this._size-=n,this._version+=1,n}slice(e,n){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(n!==void 0&&(!Number.isInteger(n)||n<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${n})`);let r=n===void 0?this._size:Math.min(Math.max(n,0),this._size),s=Math.min(e,this._size);if(s>=r)return[];let o=r-s;if(this._maxSize===void 0)return this._buf.slice(s,r);let i=new Array(o);for(let a=0;a<o;a++)i[a]=this._buf[(this._head+s+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let n=Math.min(e,this._size);return this.slice(this._size-n,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this._buf[(this._head+n)%this._maxSize];return e}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function Jr(t){return t.subscribe(()=>{})}var oa=64;function sa(t,e={}){let{name:n,maxSize:r,versioning:s,backend:o}=e,i=o??new Ht(t,r),a=F(i.toArray(),{name:n,describeKind:"state",equals:(l,m)=>l===m,...s!=null?{versioning:s}:{}});function d(){let l=i.toArray();j(()=>{a.down([[G]]),a.down([[w,l]])})}let u=new Map,c=new Map;function p(l,m){return`${l}:${m===void 0?"END":m}`}function f(l){if(l.size<oa)return;let m=l.keys().next();if(m.done)return;let b=l.get(m.value);b!==void 0&&b.dispose(),l.delete(m.value)}function h(l){let m=i.version;try{return l()}finally{i.version!==m&&d()}}return{entries:a,get size(){return i.size},at(l){return i.at(l)},append(l){h(()=>i.append(l))},appendMany(l){l.length!==0&&h(()=>i.appendMany(l))},clear(){h(()=>i.clear())},trimHead(l){h(()=>i.trimHead(l))},tail(l){if(!Number.isInteger(l)||l<0)throw new RangeError(`tail: n must be a non-negative integer (got ${l})`);let m=u.get(l);if(m!==void 0)return u.delete(l),u.set(l,m),m.node;f(u);let b=xe([a],([y])=>{let v=y;return l===0||v.length===0?[]:v.slice(Math.max(0,v.length-l))},{initial:i.tail(l),describeKind:"derived"}),g=Jr(b);return u.set(l,{node:b,dispose:g}),b},slice(l,m){if(!Number.isInteger(l)||l<0)throw new RangeError(`slice: start must be a non-negative integer (got ${l})`);if(m!==void 0&&(!Number.isInteger(m)||m<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${m})`);let b=p(l,m),g=c.get(b);if(g!==void 0)return c.delete(b),c.set(b,g),g.node;f(c);let y=xe([a],([T])=>{let k=T;return m===void 0?k.slice(l):k.slice(l,m)},{initial:i.slice(l,m),describeKind:"derived"}),v=Jr(y);return c.set(b,{node:y,dispose:v}),y},disposeTail(l){let m=u.get(l);return m===void 0?!1:(m.dispose(),u.delete(l),!0)},disposeSlice(l,m){let b=p(l,m),g=c.get(b);return g===void 0?!1:(g.dispose(),c.delete(b),!0)},disposeAllViews(){for(let l of u.values())l.dispose();u.clear();for(let l of c.values())l.dispose();c.clear()},dispose(){for(let l of u.values())l.dispose();u.clear();for(let l of c.values())l.dispose();c.clear()}}}Pt();X();Ie();function ia(t,e={}){let n=e.keyFn??(s=>String(s)),r=new Map;return s=>{let o=n(s),i=r.get(o);if(i)return i;let a=t(s),d;a!=null&&typeof a.then=="function"?d=Promise.resolve(a):a!=null&&typeof a=="object"&&"subscribe"in a&&"cache"in a?d=Gn(a):a!=null&&typeof a=="object"&&Symbol.asyncIterator in a?d=(async()=>{let p=a[Symbol.asyncIterator]();try{let{value:f,done:h}=await p.next();if(h)throw new Error("singleFromAny: factory returned empty async iterable");return f}finally{await p.return?.()}})():a!=null&&typeof a=="object"&&Symbol.iterator in a?d=(async()=>{let p=a[Symbol.iterator]();try{let{value:f,done:h}=p.next();if(h)throw new Error("singleFromAny: factory returned empty iterable");return f}finally{p.return?.()}})():d=Promise.resolve(a);let u,c=()=>{r.get(o)===u&&r.delete(o)};return u=d.then(p=>(c(),p),p=>{throw c(),p}),r.set(o,u),u}}function aa(t,e={}){let n=e.keyFn??(s=>String(s)),r=new Map;return s=>{let o=n(s),i=r.get(o);if(i)return i;let a=de(t(s));r.set(o,a);let d=a.subscribe(u=>{for(let c of u)if(c[0]===N||c[0]===_){r.get(o)===a&&r.delete(o),d();return}});return a}}Ie();function Wt(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Wt);let e=t,n=Object.keys(e).sort(),r={};for(let s of n)r[s]=Wt(e[s]);return r}function ua(t){return JSON.stringify(Wt(t),void 0,0)}function da(){let t=new Map;return{save(e,n){t.set(e,JSON.parse(JSON.stringify(n)))},load(e){let n=t.get(e);return n===void 0?null:JSON.parse(JSON.stringify(n))},clear(e){t.delete(e)},list(){return[...t.keys()].sort()}}}function ca(t){return{save(e,n){t[e]=JSON.parse(JSON.stringify(n))},load(e){let n=t[e];return n===void 0?null:JSON.parse(JSON.stringify(n))},clear(e){delete t[e]},list(){return Object.keys(t).sort()}}}X();we();ue();pn();ye();Le();Ot();X();Ot();we();function Ut(t,e){if(e!=null&&e.length>0)return new Set(e);switch(t){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;default:return new Set(["type","deps"])}}function la(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function fa(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function Hn(t,e){let n=e==null,r=!n&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,s=n||e.has("meta")||r!=null&&r.length>0,o="state",i=[];t instanceof oe&&(o=la(t),i=t._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(n||e.has("status"))&&(a.status=t.status);let d=t instanceof oe?t._guard:void 0;if(s){let u={...fa(t)};if(d!=null&&u.access===void 0&&(u.access=hn(d)),r!=null&&r.length>0&&!e.has("meta")){let c={};for(let p of r)p in u&&(c[p]=u[p]);a.meta=c}else a.meta=u}if(t.name!=null&&(a.name=t.name),n||e.has("value")){t.status==="sentinel"&&(a.sentinel=!0);try{a.value=t.cache}catch{}}if((n||e.has("v"))&&t.v!=null){let u={id:t.v.id,version:t.v.version};"cid"in t.v&&(u.cid=t.v.cid,u.prev=t.v.prev),a.v=u}return(n||e.has("guard"))&&d!=null&&(a.guard=hn(d)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}we();ue();Ie();At();fn();function Wn(t){return t>=768&&t<=879||t>=1155&&t<=1161||t>=1425&&t<=1469||t>=1552&&t<=1562||t>=1611&&t<=1631||t>=1648&&t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t>=1767&&t<=1768||t>=1770&&t<=1773||t>=1840&&t<=1866||t>=1958&&t<=1968||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2641||t>=2672&&t<=2673||t>=2677&&t===2677||t>=3633&&t===3633||t>=3636&&t<=3642||t>=3655&&t<=3662||t>=3761&&t===3761||t>=3764&&t<=3772||t>=3784&&t<=3790||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65024&&t<=65039||t>=65056&&t<=65071||t===8205?0:t>=4352&&t<=4447||t>=8986&&t<=8987||t>=9001&&t<=9002||t>=9193&&t<=9203||t>=9208&&t<=9210||t>=9725&&t<=9726||t>=9748&&t<=9749||t>=9800&&t<=9811||t===9855||t===9875||t===9889||t>=9898&&t<=9899||t>=9917&&t<=9918||t>=9924&&t<=9925||t===9934||t===9940||t===9962||t>=9970&&t<=9971||t===9973||t===9978||t===9981||t===9986||t===9989||t>=9992&&t<=9997||t===9999||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t>=10548&&t<=10549||t>=11013&&t<=11015||t>=11035&&t<=11036||t===11088||t===11093||t>=11904&&t<=12350||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12784&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=19968&&t<=40959||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65131||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126980&&t===126980||t===127183||t>=127344&&t<=127345||t===127358||t===127359||t===127374||t>=127377&&t<=127386||t>=127456&&t<=127487||t>=127488&&t<=127490||t===127514||t===127535||t>=127538&&t<=127546||t>=127568&&t<=127569||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=129792&&t<=130047||t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}function qt(t){let e=0;for(let n of t)e+=Wn(n.codePointAt(0));return e}function Yr(t,e){if(e<=0)return"";let n=0,r="";for(let s of t){let o=Wn(s.codePointAt(0));if(n+o>e){if(e<=1)return"\u2026";for(;n+1>e&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=Wn(i.codePointAt(0))}return`${r}\u2026`}r+=s,n+=o}return r}var pa={horizontal:"\u2500",vertical:"\u2502",cornerTL:"\u250C",cornerTR:"\u2510",cornerBL:"\u2514",cornerBR:"\u2518",tDown:"\u252C",tUp:"\u2534",tRight:"\u251C",tLeft:"\u2524",cross:"\u253C",arrowRight:"\u25B6",arrowDown:"\u25BC",arrowLeft:"\u25C0",arrowUp:"\u25B2",boxTL:"\u250C",boxTR:"\u2510",boxBL:"\u2514",boxBR:"\u2518",boxH:"\u2500",boxV:"\u2502"},ha={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function eo(t,e){let n=e.charset==="ascii"?ha:pa,r=t.width,s=t.height,o=Array.from({length:s},()=>Array.from({length:r},()=>" ")),i=Array.from({length:s},()=>Array.from({length:r},()=>"empty"));for(let a of t.edges)ga(o,i,n,a);for(let a of t.boxes)ma(o,i,n,a,e.labelOf(a.id));return o.map(a=>Ta(a.join(""))).join(`
|
|
19
|
+
`)}function ma(t,e,n,r,s){let{x:o,y:i,w:a,h:d}=r;if(a<2||d<2){d>0&&Qr(t,e,o,i,a,s);return}Be(t,e,o,i,n.boxTL);for(let c=o+1;c<o+a-1;c+=1)Be(t,e,c,i,n.boxH);Be(t,e,o+a-1,i,n.boxTR);for(let c=i+1;c<i+d-1;c+=1){Be(t,e,o,c,n.boxV);for(let p=o+1;p<o+a-1;p+=1)to(t,e,p,c," ","empty");Be(t,e,o+a-1,c,n.boxV)}Be(t,e,o,i+d-1,n.boxBL);for(let c=o+1;c<o+a-1;c+=1)Be(t,e,c,i+d-1,n.boxH);Be(t,e,o+a-1,i+d-1,n.boxBR);let u=i+Math.floor(d/2);Qr(t,e,o+1,u,a-2,s)}function Be(t,e,n,r,s){to(t,e,n,r,s,s===" "?"empty":s==="\u2500"||s==="-"?"boxH":s==="\u2502"||s==="|"?"boxV":"boxCorner")}function to(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];n<0||n>=i.length||(i[n]=s,e[r][n]=o)}function Qr(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=n,a=s;for(let d of o){let u=qt(d);if(u!==0){if(a<u)break;i>=0&&i<t[r].length&&(t[r][i]=d,e[r][i]="label",u===2&&i+1<t[r].length&&(t[r][i+1]="",e[r][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<t[r].length&&(t[r][i]=" ",e[r][i]="empty"),i+=1,a-=1}function ga(t,e,n,r){let s=r.points;if(s.length<2)return;for(let d=0;d+1<s.length;d+=1)ba(t,e,n,s[d],s[d+1]);for(let d=1;d+1<s.length;d+=1){let u=s[d-1],c=s[d],p=s[d+1],f=ya(u,c,p,n);f&&Zr(t,e,c.x,c.y,f,"edgeCorner")}let o=s[s.length-1],i=s[s.length-2],a=va(i,o,n);a&&Zr(t,e,o.x,o.y,a,"arrow")}function ba(t,e,n,r,s){if(!(r.x===s.x&&r.y===s.y)){if(r.y===s.y){let o=r.y,i=Math.min(r.x,s.x),a=Math.max(r.x,s.x);for(let d=i;d<=a;d+=1)Xr(t,e,d,o,n,"h")}else if(r.x===s.x){let o=r.x,i=Math.min(r.y,s.y),a=Math.max(r.y,s.y);for(let d=i;d<=a;d+=1)Xr(t,e,o,d,n,"v")}}}function Xr(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[n]=o==="h"?s.horizontal:s.vertical,e[r][n]=o==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&o==="v"){i[n]=s.cross,e[r][n]="edgeCorner";return}if(a==="edgeV"&&o==="h"){i[n]=s.cross,e[r][n]="edgeCorner";return}}}function Zr(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[n]=s,e[r][n]=o)}function ya(t,e,n,r){let s=t.y===e.y,o=e.y===n.y;if(s===o)return;if(s){let d=t.x<e.x,u=n.y>e.y;return d&&u?r.cornerTR:d&&!u?r.cornerBR:!d&&u?r.cornerTL:r.cornerBL}let i=t.y<e.y,a=n.x>e.x;return i&&a?r.cornerBL:i&&!a?r.cornerBR:!i&&a?r.cornerTL:r.cornerTR}function va(t,e,n){if(e.x>t.x)return n.arrowRight;if(e.x<t.x)return n.arrowLeft;if(e.y>t.y)return n.arrowDown;if(e.y<t.y)return n.arrowUp}function Ta(t){let e=t.length;for(;e>0&&t.charCodeAt(e-1)===32;)e-=1;return t.slice(0,e)}function oo(t){let e=wa(t);xa(e),ka(e),_a(e),Na(e,t);let n=Oa(e,t),{width:r,height:s}=Ma(e),o=[];for(let i of e.layers)for(let a of i)a.isVirtual||o.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:o,edges:n,width:r,height:s}}function wa(t){let e=new Map;for(let s of t.nodes)e.set(s,{id:s,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:t.widthCells(s),h:t.heightCells(s),in:[],out:[]});let n=[],r=0;for(let s of t.edges){if(s.from===s.to)continue;let o=e.get(s.from),i=e.get(s.to);if(!o||!i)continue;let a={chainId:r++,chainFrom:s.from,chainTo:s.to,fromId:s.from,toId:s.to,hopIndex:0,chainLen:1};o.out.push(a),i.in.push(a),n.push(a)}return{nodes:e,layers:[],hops:n}}function xa(t){let e=new Map;for(let o of t.nodes.values())e.set(o.id,o.in.length);let n=[];for(let o of t.nodes.values())(e.get(o.id)??0)===0&&(o.layer=0,n.push(o));let r=new Set,s=0;for(;s<n.length;){let o=n[s++];if(!r.has(o.id)){r.add(o.id);for(let i of o.out){let a=t.nodes.get(i.toId);a.layer=Math.max(a.layer,o.layer+1);let d=(e.get(a.id)??0)-1;e.set(a.id,d),d<=0&&n.push(a)}}}for(let o of t.nodes.values())o.layer<0&&(o.layer=0)}function ka(t){let e=Math.max(0,...Array.from(t.nodes.values(),o=>o.layer)),n=Array.from({length:e+1},()=>[]);for(let o of t.nodes.values())n[o.layer].push(o);let r=[],s=0;for(let o of t.hops){let i=t.nodes.get(o.fromId),a=t.nodes.get(o.toId),d=a.layer-i.layer;if(d<=0){i.out=i.out.filter(p=>p!==o),a.in=a.in.filter(p=>p!==o);continue}if(d===1){o.hopIndex=0,o.chainLen=1,r.push(o);continue}i.out=i.out.filter(p=>p!==o),a.in=a.in.filter(p=>p!==o);let u=i;for(let p=1;p<d;p+=1){let f=`__virt_${s++}__`,h={id:f,isVirtual:!0,layer:i.layer+p,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};t.nodes.set(f,h),n[h.layer].push(h);let l={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:f,hopIndex:p-1,chainLen:d};u.out.push(l),h.in.push(l),r.push(l),u=h}let c={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:a.id,hopIndex:d-1,chainLen:d};u.out.push(c),a.in.push(c),r.push(c)}for(let o of n)for(let i=0;i<o.length;i+=1)o[i].order=i;t.layers=n,t.hops=r}function _a(t){for(let n=0;n<4;n+=1){for(let r=1;r<t.layers.length;r+=1)no(t,t.layers[r],"in"),Jt(t.layers[r]);for(let r=t.layers.length-2;r>=0;r-=1)no(t,t.layers[r],"out"),Jt(t.layers[r])}for(let n=0;n<2;n+=1){let r=!1;for(let s=1;s<t.layers.length;s+=1){let o=t.layers[s];for(let i=0;i+1<o.length;i+=1){let a=ro(t,o[i],o[i+1],"in");[o[i],o[i+1]]=[o[i+1],o[i]],Jt(o),ro(t,o[i],o[i+1],"in")<a?r=!0:([o[i],o[i+1]]=[o[i+1],o[i]],Jt(o))}}if(!r)break}}function no(t,e,n){let r=new Map;for(let s of e){let o=n==="in"?s.in:s.out;if(o.length===0){r.set(s.id,s.order);continue}let i=0,a=0;for(let d of o){let u=t.nodes.get(n==="in"?d.fromId:d.toId);u&&(i+=u.order,a+=1)}r.set(s.id,a===0?s.order:i/a)}e.sort((s,o)=>{let i=r.get(s.id),a=r.get(o.id);return i!==a?i-a:s.order-o.order})}function Jt(t){for(let e=0;e<t.length;e+=1)t[e].order=e}function ro(t,e,n,r){let s=r==="in"?e.in:e.out,o=r==="in"?n.in:n.out,i=0;for(let a of s)for(let d of o){let u=t.nodes.get(r==="in"?a.fromId:a.toId)?.order??0,c=t.nodes.get(r==="in"?d.fromId:d.toId)?.order??0;(e.order<n.order&&u>c||e.order>n.order&&u<c)&&(i+=1)}return i}function Na(t,e){e.direction==="LR"?Ea(t,e):Sa(t,e)}function Ea(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.w);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.x=n[s];for(let s of t.layers){let o=0;for(let i of s)i.y=o,o+=i.h+e.nodeGap}so(t,e,"y")}function Sa(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.h);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.y=n[s];for(let s of t.layers){let o=0;for(let i of s)i.x=o,o+=i.w+e.nodeGap}so(t,e,"x")}function so(t,e,n){let r=o=>n==="y"?o.h:o.w,s=e.nodeGap;for(let o=0;o<2;o+=1){let i=o===0?t.layers.slice(1):t.layers.slice(0,-1).reverse();for(let a of i){let d=new Map;for(let c of a){let p=o===0?c.in:c.out;if(p.length===0)continue;let f=[];for(let l of p){let m=t.nodes.get(o===0?l.fromId:l.toId);if(!m)continue;let b=n==="y"?m.y:m.x;f.push(b+Math.floor(r(m)/2))}if(f.length===0)continue;f.sort((l,m)=>l-m);let h=f[Math.floor(f.length/2)];d.set(c.id,h-Math.floor(r(c)/2))}let u=0;for(let c of a){let p=d.get(c.id),f=n==="y"?c.y:c.x,l=Math.max(p??f,u);n==="y"?c.y=l:c.x=l,u=l+r(c)+s}}}}function Oa(t,e){let n=new Map;for(let u of t.hops){let c=n.get(u.chainId);c?c.push(u):n.set(u.chainId,[u])}for(let u of n.values())u.sort((c,p)=>c.hopIndex-p.hopIndex);let r=e.direction==="LR",s=u=>r?u.x:u.y,o=u=>r?u.w:u.h,i=u=>r?u.y+Math.floor(u.h/2):u.x+Math.floor(u.w/2),a=new Map;for(let u=0;u+1<t.layers.length;u+=1){let c=t.layers[u],p=t.layers[u+1],f=0;for(let S of c)f=Math.max(f,s(S)+o(S));let h=Number.POSITIVE_INFINITY;for(let S of p)h=Math.min(h,s(S));let l=Number.isFinite(h)?h-1:f,m=Math.max(1,l-f+1),b=[];for(let S of c)for(let M of S.out)b.push(M);b.sort((S,M)=>{let I=i(t.nodes.get(S.fromId)),D=i(t.nodes.get(M.fromId));if(I!==D)return I-D;let L=i(t.nodes.get(S.toId)),O=i(t.nodes.get(M.toId));return L-O});let g=[],y=new Map;for(let S of b){let M=i(t.nodes.get(S.fromId)),I=i(t.nodes.get(S.toId)),D=Math.min(M,I),L=Math.max(M,I),O=-1;for(let $=0;$<g.length;$+=1){let ee=g[$],z=!0;for(let te of ee)if(te.lo<=L&&D<=te.hi){z=!1;break}if(z){ee.push({lo:D,hi:L}),O=$;break}}O<0&&(g.push([{lo:D,hi:L}]),O=g.length-1),y.set(S,O)}let v=g.length,T=m>=Math.max(3,v+2),k=T?f+1:f,x=T?l-1:l,E=Math.max(1,x-k+1);for(let S of b){let M=y.get(S),I;if(v<=1)I=k+Math.floor(E/2);else{let D=(E-1)/(v-1);I=k+Math.floor(M*D)}a.set(S,Math.max(f,Math.min(l,I)))}}let d=[];for(let[,u]of n){let c=[];for(let f=0;f<u.length;f+=1){let h=u[f],l=t.nodes.get(h.fromId),m=t.nodes.get(h.toId),b=a.get(h),g=l.isVirtual?s(l):s(l)+o(l),y=m.isVirtual?s(m):s(m)-1,v=i(l),T=i(m);f===0&&Yt(c,r,g,v),v!==T&&(Yt(c,r,b,v),Yt(c,r,b,T)),Yt(c,r,y,T)}let p=u[0];d.push({from:p.chainFrom,to:p.chainTo,points:Ra(c)})}return d}function Yt(t,e,n,r){t.push(e?{x:n,y:r}:{x:r,y:n})}function Ra(t){let e=[];for(let n of t){let r=e[e.length-1];(!r||r.x!==n.x||r.y!==n.y)&&e.push(n)}return e}function Ma(t){let e=0,n=0;for(let r of t.layers)for(let s of r)e=Math.max(e,s.x+s.w),n=Math.max(n,s.y+s.h);return{width:e,height:n}}var Aa=24,Ca=4,Da=1,Pa=3;function io(t,e){let n=Ia(e.direction),r=Math.max(3,e.maxLabelWidth??Aa),s=e.asciiCharset??"unicode",o=Object.keys(t.nodes).sort(),i=new Set(o),a=t.edges.filter(h=>i.has(h.from)&&i.has(h.to)),d=new Map,u=new Map;for(let h of o){let l=Yr(h,r);d.set(h,l),u.set(h,qt(l)+4)}let c=oo({nodes:o,edges:a,widthCells:h=>u.get(h)??3,heightCells:()=>Pa,layerGap:Ca,nodeGap:Da,direction:n}),p=eo(c,{charset:s,labelOf:h=>d.get(h)??h}),f=e.logger;return f&&f(p),p}function Ia(t){if(t===void 0||t==="LR")return"LR";if(t==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(t)}`)}function ao(t,e,n,r={}){let s=e in t.nodes,o=n in t.nodes;if(!s)return Qt(e,n,"no-such-from");if(!o)return Qt(e,n,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===n){if(r.findCycle===!0){let u=La(t,e,r);if(u!=null)return u}let d=Xt(e,t.nodes[e],0,r);return Zt(e,n,[d])}if(i===0)return Qt(e,n,"no-path");let a=uo(t,e,n,i);return a.found?Zt(e,n,co(t,a.pathOrder,r)):Qt(e,n,a.truncated?"max-depth-exceeded":"no-path")}function uo(t,e,n,r){let s=new Map,o=[{path:n,depth:0}],i=new Set([n]),a=0,d=!1;for(;a<o.length;){let p=o[a++];if(p.path===e)break;if(r!=null&&p.depth>=r){let m=t.nodes[p.path];m?.deps&&m.deps.length>0&&(d=!0);continue}let f=t.nodes[p.path];if(f==null)continue;let h=f.deps??[],l=new Map;for(let m=0;m<h.length;m++){let b=h[m];if(!b)continue;let g=l.get(b);g==null&&(g=[],l.set(b,g)),g.push(m)}for(let[m,b]of l)i.has(m)||(i.add(m),s.set(m,{from:p.path,depIndices:b}),o.push({path:m,depth:p.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:d};let u=[{path:e}],c=e;for(;c!==n;){let p=s.get(c);if(p==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=p.depIndices,u.push({path:p.from}),c=p.from}return{found:!0,pathOrder:u,truncated:!1}}function La(t,e,n){let r=t.nodes[e];if(r==null)return null;let s=r.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=Xt(e,r,0,n);a.dep_index=o[0];let d=Xt(e,r,1,n);return Zt(e,e,[a,d])}let i=null;for(let a=0;a<s.length;a++){let d=s[a];if(!d||d===e)continue;let u=uo(t,d,e,n.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:Zt(e,e,co(t,i.pathOrder,n))}function co(t,e,n){return e.map((r,s)=>{let o=t.nodes[r.path],i=Xt(r.path,o,s,n);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function Xt(t,e,n,r){let s={path:t,type:e.type,hop:n};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=r.annotations?.get(t)??e.annotation;o!=null&&(s.annotation=o);let i=r.lastMutations?.get(t)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function Zt(t,e,n){return lo(t,e,!0,"ok",n)}function Qt(t,e,n){return lo(t,e,!1,n,[])}function lo(t,e,n,r,s){let o=Ba(t,e,n,r,s);return{from:t,to:e,found:n,reason:r,steps:s,text:o,toJSON(){return{from:t,to:e,found:n,reason:r,steps:s}}}}function Ba(t,e,n,r,s){if(!n)switch(r){case"no-such-from":return`explainPath: no node named "${t}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${t}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${t}" to "${e}"`}let o=[`Causal path: ${t} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(d),"value"in i&&o.push(` value: ${Va(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;o.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return o.join(`
|
|
20
|
+
`)}function Va(t){if(t===void 0)return"<sentinel>";if(t===null)return"null";if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);try{let e=JSON.stringify(t);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(t)}}we();var se={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},Ga=Symbol.for("sizeof");function fo(t){let e=new WeakSet,n=new WeakSet,r=[t],s=0;for(;r.length>0;){let o=r.pop();s+=Fa(o,e,n,r)}return s}function Fa(t,e,n,r){if(t==null)return 0;switch(typeof t){case"number":return se.number;case"boolean":return se.boolean;case"string":return se.string+t.length*2;case"bigint":return se.bigint+$a(t);case"symbol":return se.symbol;case"function":return e.has(t)?0:(e.add(t),se.function);case"undefined":return 0}let o=t;if(e.has(o))return 0;e.add(o);let i=o[Ga];if(typeof i=="function")try{let u=i.call(o);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(o instanceof Date)return se.date;if(o instanceof RegExp)return se.regexp+o.source.length*2;if(o instanceof Error){let u=o.message?o.message.length*2:0,c=o.stack?o.stack.length*2:0;return se.error+u+c}if(typeof URL<"u"&&o instanceof URL)return se.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return se.promise;if(o instanceof WeakMap)return se.weakmap;if(o instanceof WeakSet)return se.weakset;if(o instanceof Map){let u=se.map;for(let[c,p]of o)u+=se.mapEntry,r.push(c),r.push(p);return u}if(o instanceof Set){let u=se.set;for(let c of o)u+=se.setEntry,r.push(c);return u}if(Array.isArray(o)){let u=se.array+o.length*8;for(let c of o)r.push(c);return u}if(o instanceof ArrayBuffer)return n.has(o)?0:(n.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let u=o;return n.has(u.buffer)?48:(n.add(u.buffer),u.buffer.byteLength+48)}let a=se.object,d=Object.keys(o);for(let u of d){a+=se.string+u.length*2;try{r.push(o[u])}catch{}}return a}function $a(t){let e=t<0n?-t:t;if(e===0n)return 0;let n=e.toString(2).length;return Math.ceil(n/32)*8}function po(t,e){let n=e?.topN??10,r=t.describe({detail:"standard"}),s=[],o=t._collectObserveTargets;typeof o=="function"&&o.call(t,"",s);let i=new Map;for(let[f,h]of s)i.set(f,h);let a=[];for(let[f,h]of Object.entries(r.nodes)){let l=i.get(f),m=l instanceof oe?l:null,b=m?fo(m.cache):0,g=m?m._sinkCount:0,y=h.deps?.length??0,v=h.type==="effect"&&g===0,T=g===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:b,subscriberCount:g,depCount:y,isOrphanEffect:v,orphanKind:T})}let d=a.reduce((f,h)=>f+h.valueSizeBytes,0),u=(f,h)=>[...a].sort(h??((l,m)=>m[f]-l[f])).slice(0,n),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:d,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:c,orphanEffects:p}}var Z="::",Me="__meta__",ut=1;function ho(t,e){let n=Math.max(16,t.size*4),r=0;for(;t.size>0;){if(r++>=n){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${n}); ${t.size} disposer(s) discarded`),t.clear();return}let s=t.values().next();if(s.done)return;let o=s.value;t.delete(o);try{o()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Ka(t){let e=[];for(let n of Object.keys(t).sort()){let r=t[n].v;r!=null&&e.push(`${n} ${r.id} ${r.version}`)}return e.join(`
|
|
21
|
+
`)}function mo(t){if(t.version!==ut)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${ut})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in t))throw new Error(`snapshot missing required key "${e}"`);if(typeof t.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof t.nodes!="object"||t.nodes===null||Array.isArray(t.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(t.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(t.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function za(t,e){let n=new WeakMap,r=(s,o)=>{if(Object.is(s,o))return!0;if(s==null||o==null||typeof s!="object"||typeof o!="object")return!1;let i=n.get(s);if(i==null&&(i=new WeakSet,n.set(s,i)),i.has(o))return!0;i.add(o);let a=s.constructor,d=o.constructor;if(a!==d)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let f=o;if(s.length!==f.length)return!1;for(let h=0;h<s.length;h++)if(!r(s[h],f[h]))return!1;return!0}if(s instanceof Map){let f=o;if(s.size!==f.size)return!1;for(let[h,l]of s)if(!f.has(h)||!r(l,f.get(h)))return!1;return!0}if(s instanceof Set){let f=o;if(s.size!==f.size)return!1;for(let h of s){let l=!1;for(let m of f)if(r(h,m)){l=!0;break}if(!l)return!1}return!0}if(ArrayBuffer.isView(s)){let f=s,h=o;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 u=Object.keys(s),c=Object.keys(o);if(u.length!==c.length)return!1;let p=new Set(c);for(let f of u)if(!p.has(f)||!r(s[f],o[f]))return!1;return!0};return r(t,e)}function qn(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(qn);let e=t,n=Object.keys(e).sort(),r={};for(let s of n)r[s]=qn(e[s]);return r}function ja(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Ha(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Wa(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function yo(t){let e=new Set,n=[];function r(s,o){let i=`${s}\0${o}`;e.has(i)||(e.add(i),n.push([s,o]))}for(let[s,o]of Object.entries(t.nodes)){let i=o.deps;if(i)for(let a of i)r(a,s)}for(let s of t.edges)r(s.from,s.to);return n}function vo(t){if(t===void 0)return"LR";if(t==="TD"||t==="LR"||t==="BT"||t==="RL")return t;throw new Error(`invalid diagram direction ${String(t)}; expected one of: TD, LR, BT, RL`)}function Ua(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,{expand:s,...o}=t,i={...o,edges:n?t.edges:[],subgraphs:r?t.subgraphs:[]},a=JSON.stringify(qn(i),null,e.indent??2);return e.logger?.(a),a}function qa(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,s=[];s.push(`Graph ${t.name}`),s.push("Nodes:");for(let i of Object.keys(t.nodes).sort()){let a=t.nodes[i];s.push(`- ${i} (${a.type}/${a.status}): ${tn(a.value)}`)}if(n){s.push("Edges:");for(let i of t.edges)s.push(`- ${i.from} -> ${i.to}`)}if(r){s.push("Subgraphs:");for(let i of t.subgraphs)s.push(`- ${i}`)}let o=s.join(`
|
|
22
|
+
`);return e.logger?.(o),o}function To(t,e){let n=vo(e.direction),r=Object.keys(t.nodes).sort(),s=new Map;for(let i=0;i<r.length;i+=1)s.set(r[i],`n${i}`);let o=[`flowchart ${n}`];for(let i of r){let a=s.get(i);o.push(` ${a}["${ja(i)}"]`)}for(let[i,a]of yo(t)){let d=s.get(i),u=s.get(a);!d||!u||o.push(` ${d} --> ${u}`)}return o.join(`
|
|
23
|
+
`)}function Ja(t,e){let n=To(t,e);return Ya(n)}function Ya(t,e){let n=e?.theme??"default",r=e?.autoSync??!0,o=JSON.stringify({code:t,mermaid:{theme:n},autoSync:r}),i=new TextEncoder().encode(o),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function Qa(t,e){let n=vo(e.direction),r=Object.keys(t.nodes).sort(),s=new Map;for(let i=0;i<r.length;i+=1)s.set(r[i],`n${i}`);let o=[`direction: ${Wa(n)}`];for(let i of r){let a=s.get(i);o.push(`${a}: "${Ha(i)}"`)}for(let[i,a]of yo(t)){let d=s.get(i),u=s.get(a);!d||!u||o.push(`${d} -> ${u}`)}return o.join(`
|
|
24
|
+
`)}function Xa(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function en(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let s=t.indexOf("]",n+1);if(s<=n+1){e+="\\[";continue}let o=t.slice(n+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,n=s;continue}e+=Xa(r)}return e+="$",new RegExp(e)}var Za={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"},eu={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function tn(t){if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||t==null)return String(t);try{return JSON.stringify(t)}catch{return"[unserializable]"}}function tu(t){return t==="none"?eu:t==="ansi"||t==null?Za:{data:t.data??"",dirty:t.dirty??"",resolved:t.resolved??"",invalidate:t.invalidate??"",pause:t.pause??"",resume:t.resume??"",complete:t.complete??"",error:t.error??"",teardown:t.teardown??"",derived:t.derived??"",path:t.path??"",reset:t.reset??""}}function go(t){if(t==null)return{};let e=t.detail;return e==="full"?{...t,structured:t.structured??!0,timeline:t.timeline??!0,causal:t.causal??!0,derived:t.derived??!0}:e==="minimal"?{...t,structured:t.structured??!0}:t.format==="stage-log"?{...t,structured:t.structured??!0,timeline:t.timeline??!0}:t}function nu(t,e,n){for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);if(s<32||s===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function Un(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(Z))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${Z}' (path separator)`);if(t===Me)throw new Error(`Graph "${e}": ${n} name "${Me}" is reserved for meta companion paths`);nu(t,e,n)}function ru(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(Z);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function ou(t,e){let n=!1;for(let s of t)if(!e.isMetaPassthrough(s[0])){n=!0;break}return n?t.filter(s=>e.isMetaPassthrough(s[0])):t}function wo(t){for(let e of t._mounts.values())wo(e);for(let e of t._nodes.values())try{e.down([[K]],{internal:!0})}catch{}}var xt=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(Z))throw new Error(`Graph name must not contain '${Z}' (got "${e}")`);if(e===Me)throw new Error(`Graph name "${Me}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??le,this._traceRing=new qe(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=R(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}add(e,n){let r=e.name,s=n?.name??r;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,i=n?.annotation;if(Un(o,this.name,"add"),this._mounts.has(o))throw new Error(`Graph "${this.name}": name "${o}" is already a mount point`);if(this._nodes.has(o))throw new Error(`Graph "${this.name}": node "${o}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(o,e),this._nodeToName.set(e,o),this._emitTopology({kind:"added",name:o,nodeKind:"node"}),i!=null&&(this._annotations.set(o,i),this.config.inspectorEnabled&&this._traceRing.push({path:o,annotation:i,timestamp_ns:ne()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof oe&&n._applyVersioning(e)}remove(e){Un(e,this.name,"remove");let n=this._mounts.get(e);if(n){let o={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,d]of i)a.includes(`${Z}${Me}${Z}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...n._collectSubgraphs(`${e}${Z}`)),this._mounts.delete(e),n._parent=void 0,wo(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:o}),o}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[K]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let n=typeof e=="function"?e:(()=>{let o=en(e);return i=>o.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>n(o));for(let o of s){let i=this.remove(o);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let s=e[r++];return{value:[s,n.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(Z))return this.resolve(e);let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return n}get(e){return this.node(e).cache}set(e,n,r){let s=r?.internal===!0;this.node(e).down([[w,n]],{actor:r?.actor,internal:s,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);j(()=>{for(let[s,o]of r)this.set(s,o,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[ve]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let s=r?.internal===!0;this.node(e).down([[N,n]],{actor:r?.actor,internal:s,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[_]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[d,u]of this._nodes)r.set(u,d);let a=[];for(let[d,u]of this._nodes)if(u instanceof oe)for(let c of u._deps){let p=r.get(c.node);p!=null&&a.push([p,d])}return a.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,d]of s)o.set(d,a);let i=[];for(let[a,d]of s)if(d instanceof oe)for(let u of d._deps){let c=o.get(u.node);c!=null&&i.push([c,a])}return i.sort((a,d)=>a[0]<d[0]?-1:a[0]>d[0]?1:a[1]<d[1]?-1:a[1]>d[1]?1:0),i}mount(e,n){if(Un(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let n=ru(e,this.name);return this._resolveFromSegments(n)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let n=e;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],s=n.slice(1);if(s.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let o=this._nodes.get(r);if(o&&s.length>0&&s[0]===Me)return this._resolveMetaChainFromNode(o,s,n.join(Z));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${s.join(Z)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(s.join(Z))}_resolveMetaChainFromNode(e,n,r){let s=e,o=0,i=[...n];for(;o<i.length;){if(i[o]!==Me)throw new Error(`Graph "${this.name}": expected ${Me} segment in meta path "${r}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Me} in "${r}"`);let a=i[o+1],d=s.meta[a];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);s=d,o+=2}return s}signal(e,n){if(n?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,s){for(let d of this._mounts.values())d._signalDeliver(e,n,r,s);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=ou(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(c){if(c instanceof Ne)throw c;s.push(c)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,s)}}}_signalMetaSubtree(e,n,r,s,o){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,s)}catch(d){if(d instanceof Ne)throw d;o.push(d)}this._signalMetaSubtree(a,n,r,s,o)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,s=Ut(e?.detail,e?.fields),o=e?.format==="spec",i=o?Ut("minimal"):s,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[x,E]of a)d.set(E,x);let u=[];{let x=a.map(([,M])=>M),E=new Set(d.values()),S=0;for(;x.length>0;){let M=x.shift();if(M instanceof oe)for(let I of M._deps){let D=I.node;if(d.has(D))continue;let L=D.name??"",O=L;if(!O||E.has(O))if(L){let $=2;for(;E.has(`${L}#${$}`);)$++;O=`${L}#${$}`}else for(O=`__internal__/${S++}`;E.has(O);)O=`__internal__/${S++}`;d.set(D,O),E.add(O),u.push([O,D]),x.push(D)}}}let c=[...a,...u],p={};for(let[x,E]of c){if(n!=null&&!E.allowsObserve(n))continue;let S=Hn(E,i),M=E instanceof oe?E._deps.map(O=>d.get(O.node)??O.node.name??""):[],{name:I,...D}=S,L={...D,deps:M};if(!o){let O=this._annotations.get(x);O!=null&&(L.annotation=O)}if(r!=null)if(typeof r=="function"){let O=r;if(!(O.length>=2?O(x,L):O(L)))continue}else{let O=!0;for(let[$,ee]of Object.entries(r)){let z=$==="deps_includes"?"depsIncludes":$==="meta_has"?"metaHas":$;if(z==="depsIncludes"){if(!L.deps.includes(String(ee))){O=!1;break}continue}if(z==="metaHas"){if(!Object.hasOwn(L.meta??{},String(ee))){O=!1;break}continue}if(L[z]!==ee){O=!1;break}}if(!O)continue}p[x]=L}let f=new Set(Object.keys(p)),h=[];for(let[x,E]of c)if(E instanceof oe)for(let S of E._deps){let M=d.get(S.node);M!=null&&h.push([M,x])}h.sort((x,E)=>x[0]<E[0]?-1:x[0]>E[0]?1:x[1]<E[1]?-1:x[1]>E[1]?1:0);let l=h.map(([x,E])=>({from:x,to:E}));(n!=null||r!=null)&&(l=l.filter(x=>f.has(x.from)&&f.has(x.to)));let m=this._collectSubgraphs(""),b=n!=null||r!=null?m.filter(x=>{let E=`${x}${Z}`;return[...f].some(S=>S===x||S.startsWith(E))}):m,g=this,y=e,v={name:this.name,nodes:p,edges:l,subgraphs:b,expand(x){let E={...y,format:void 0};return Array.isArray(x)?(E.fields=x,E.detail=void 0):(E.detail=x,E.fields=void 0),g.describe(E)}},T=e??{},k=T.format;return k==="json"?Ua(v,T):k==="pretty"?qa(v,T):k==="mermaid"?To(v,T):k==="mermaid-url"?Ja(v,T):k==="d2"?Qa(v,T):k==="ascii"?io(v,T):v}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${r}`;n.push(s),n.push(...this._mounts.get(r)._collectSubgraphs(`${s}${Z}`))}return n}resourceProfile(e){return po(this,e)}reachable(e,n,r={}){return r.withDetail===!0?bo(this.describe(),e,n,{...r,withDetail:!0}):bo(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,d]of Object.entries(s.nodes))d.lastMutation!=null&&i.set(a,d.lastMutation);return ao(s,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",s=0,o=F(s,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,ht(()=>{a=!1,!d&&(s+=1,o.emit(s))}))},c=i.onEvent(b=>{let g=b.type;g!=="data"&&g!=="error"&&g!=="complete"&&g!=="teardown"||u()}),p=[],f=new WeakSet,h=b=>{if(f.has(b)||d)return;f.add(b);let g=b.topology.subscribe(y=>{for(let v of y){if(v[0]!==w)continue;let T=v[1];if(u(),T.kind==="added"&&T.nodeKind==="mount"){let k=b._mounts.get(T.name);k!=null&&h(k)}}});p.push(g);for(let y of b._mounts.keys()){let v=b._mounts.get(y);v!=null&&h(v)}};h(this);let l;try{l=xe([o],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,g)=>b===g})}catch(b){c();for(let g of p)g();throw i.dispose(),b}let m=It(l);return{node:l,dispose(){d=!0,c();for(let b of p)b();p.length=0,i.dispose(),m()}}}_explainReactive(e,n,r){let s=0,o=F(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(h=>{let l=h.type;l!=="data"&&l!=="error"&&l!=="complete"&&l!=="teardown"||a||d||(a=!0,ht(()=>{a=!1,!d&&(s+=1,o.emit(s))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},p;try{p=xe([o],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(h,l)=>h.found===l.found&&h.reason===l.reason&&h.steps.length===l.steps.length&&iu(h.steps,l.steps)})}catch(h){throw u(),i.dispose(),h}let f=It(p);return{node:p,dispose(){d=!0,u(),i.dispose(),f()}}}_pathsMatching(e){let n=en(e),r=[];return this._collectObserveTargets("",r),r.map(([s])=>s).filter(s=>n.test(s))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${Z}${r}`;this._mounts.get(r)._collectObserveTargets(s,n)}for(let r of[...this._nodes.keys()].sort()){let s=this._nodes.get(r),o=e===""?r:`${e}${Z}${r}`;n.push([o,s]),this._appendMetaObserveTargets(o,s,n)}}_appendMetaObserveTargets(e,n,r){for(let s of Object.keys(n.meta).sort()){let o=n.meta[s],i=`${e}${Z}${Me}${Z}${s}`;r.push([i,o]),this._appendMetaObserveTargets(i,o,r)}}observe(e,n){let r=typeof e=="string",o=go(r?n:e),i=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,a=o.actor;if(r){let c=e,p=this.resolve(c);if(a!=null&&!p.allowsObserve(a))throw new Ne({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,p]],o,"one"):{subscribe(f){return p.subscribe(f)},up(f){try{p.up?.(f)}catch(h){if(h instanceof Ne)return;throw h}}}}let d=[];this._collectObserveTargets("",d),d.sort((c,p)=>c[0]<p[0]?-1:c[0]>p[0]?1:0);let u=a==null?d:d.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,o,"all"):{subscribe:c=>{let p=u.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 Ne)return;throw f}}}}_buildStructuredObserver(e,n,r){let s=r==="one"?e[0]?.[0]:void 0,o=i=>{if(r==="one"&&s!=null){let c=this.resolve(s);return this._buildStructuredObserver([[s,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,p)=>c[0]<p[0]?-1:c[0]>p[0]?1:0);let d=i.actor,u=d==null?a:a.filter(([,c])=>c.allowsObserve(d));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,o)}_createObserveResult(e,n,r){let s=n.timeline===!0,o=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",d=this.config.inspectorEnabled,u=(o||i)&&d,c=n.maxEvents,p=c!=null&&c>0?new qe(c):null,f=[],h=new Set,l={},m=new Set,b=0,g=0,y=0,v=0,T=0,k=0,x=!1,E=!1,S=0,M=new Map,I=new Map,D=new Map,L=P=>{p?p.push(P):f.push(P);for(let q of h)q(P)},O=()=>s?{timestamp_ns:ne(),in_batch:_t(),batch_id:S}:{},$=(P,q)=>{if(!(!u||!(P instanceof oe)))return P._setInspectorHook(pe=>{if(pe.kind==="dep_message")M.set(P,pe.depIndex);else if(pe.kind==="run"){let Ge=pe.batchData.map((U,ce)=>U!=null&&U.length>0?U.at(-1):pe.prevData[ce]);I.set(P,Ge);let be=pe.batchData.map(U=>U!=null?[...U]:void 0);D.set(P,be),i&&L({type:"derived",path:q,dep_values:Ge,dep_batches:be,...O()})}})},ee=P=>{let q=M.get(P),pe=I.get(P);if(!o||pe==null)return{};let be=(q!=null&&q>=0&&P instanceof oe?P._deps[q]:void 0)?.node,U=be?.v,ce=D.get(P);return{trigger_dep_index:q,trigger_dep_name:be?.name,...U!=null?{trigger_version:{id:U.id,version:U.version}}:{},dep_values:[...pe],...ce!=null?{dep_batches:ce}:{}}},z=[],te=[];for(let[P,q]of e){let pe=$(q,P);pe&&z.push(pe),te.push(q.subscribe(Ge=>{S++;for(let be of Ge){let U=be[0],ce=O();if(U===w){l[P]=be[1];let Pe=q instanceof oe?q.lastMutation?.actor??et:et;L({type:"data",path:P,data:be[1],actor:Pe,...ce,...ee(q)})}else if(a)U===G?b++:U===A?g++:U===ve?y++:U===me?v++:U===Te?T++:U===K?k++:U===_&&!m.has(P)?x=!0:U===N&&(E=!0,m.add(P));else if(U===G)b++,L({type:"dirty",path:P,...ce});else if(U===A)g++,L({type:"resolved",path:P,...ce,...ee(q)});else if(U===ve)y++,L({type:"invalidate",path:P,...ce});else if(U===me)v++,L({type:"pause",path:P,lockId:be[1],...ce});else if(U===Te)T++,L({type:"resume",path:P,lockId:be[1],...ce});else if(U===_)m.has(P)||(x=!0),L({type:"complete",path:P,...ce});else if(U===N){E=!0,m.add(P);let Pe=q instanceof oe?q.lastMutation?.actor??et:et;L({type:"error",path:P,data:be[1],actor:Pe,...ce})}else U===K&&(k++,L({type:"teardown",path:P,...ce}))}}))}let ke=!1,De=()=>{if(!ke){ke=!0;for(let P of te)P();for(let P of z)P();for(let P of ge)P({value:void 0,done:!0});ge.length=0}},_e=[],ge=[];h.add(P=>{let q=ge.shift();q?q({value:P,done:!1}):_e.push(P)});let Ve={get values(){return l},get dirtyCount(){return b},get resolvedCount(){return g},get invalidateCount(){return y},get pauseCount(){return v},get resumeCount(){return T},get teardownCount(){return k},get events(){return p?p.toArray():[...f]},get anyCompletedCleanly(){return x},get anyErrored(){return E},get completedWithoutErrors(){return x&&!E},onEvent(P){return h.add(P),()=>h.delete(P)},dispose:De,expand(P){De();let q={...n};return typeof P=="string"?q.detail=P:Object.assign(q,P),r(go(q))},[Symbol.asyncIterator](){return{next(){return _e.length>0?Promise.resolve({value:_e.shift(),done:!1}):ke?Promise.resolve({value:void 0,done:!0}):new Promise(P=>ge.push(P))},return(){return De(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Ve,n),Ve}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let s=n.logger??(l=>console.log(l)),o=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=o==null&&i==null?()=>!0:l=>(o==null||o.has(l))&&(i==null||!i.has(l)),d=tu(n.theme),u=r==="stage-log"?ne():0,c=l=>l==null?"":n.stageLabels?.[l]??l,p=(l,m)=>l.length>m?`${l.slice(0,m-1)}\u2026`:l,f=l=>l.type==="data"||l.type==="error"?p(tn(l.data),120):"",h=l=>{if(r==="stage-log"){let E=(ne()-u)/1e9,S=c(l.path).padEnd(9);if(l.type==="data"){let M=f(l);return`[${E.toFixed(3)}s] ${S} \u2190${M?` ${M}`:""}`}if(l.type==="error"){let M=f(l);return`[${E.toFixed(3)}s] ${S} \u2717${M?` ${M}`:""}`}return l.type==="complete"?`[${E.toFixed(3)}s] ${S} \u25A0 complete`:`[${E.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 m=d[l.type]??"",b=l.path?`${d.path}${l.path}${d.reset} `:"",g=l.type==="data"||l.type==="error",y=l.type==="pause"||l.type==="resume",v=g?` ${tn(l.data)}`:y?` ${tn(l.lockId)}`:"",T=l.type==="data"||l.type==="resolved"||l.type==="derived"?l:void 0,k=T?.trigger_dep_name!=null?` <- ${T.trigger_dep_name}`:T?.trigger_dep_index!=null?` <- #${T.trigger_dep_index}`:"",x=l.in_batch?" [batch]":"";return`${b}${m}${l.type.toUpperCase()}${d.reset}${v}${k}${x}`};e.onEvent(l=>{a(l.type)&&s(h(l),l)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){ho(this._disposers,this.name),this.signal([[K]],{internal:!0}),ho(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}snapshot(e){let{expand:n,...r}=this.describe({detail:"full"}),s={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:d,guard:u,...c}=r.nodes[a];s[a]=c}let o=[...r.subgraphs].sort(),i={...r,version:1,nodes:s,subgraphs:o};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return rr(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??le,{codec:s,codecVersion:o,payload:i}=or(e,r);return s.decode(i,o)}restore(e,n){if(mo(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(o=>en(o)),s=n?.includeProducers===!0;for(let o of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(o)))continue;let i=e.nodes[o];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let d=this.tryResolve(o)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){n?.onError?.(o,a)}}}}}static fromSnapshot(e,n){mo(e);let r=typeof n=="function"?n:n?.build,s=typeof n=="function"?void 0:n?.factories,o=new t(e.name);if(r)return r(o),o.restore(e),o;for(let h of[...e.subgraphs].sort((l,m)=>{let b=l.split(Z).length,g=m.split(Z).length;return b!==g?b-g:l<m?-1:l>m?1:0})){let l=h.split(Z),m=o;for(let b of l)m._mounts.has(b)||m.mount(b,new t(b)),m=m._mounts.get(b)}let i=s?Object.entries(s).map(([h,l])=>({re:en(h),factory:l})):[],a=h=>{for(let l of i)if(l.re.test(h))return l.factory},d=h=>{let l=h.split(Z),m=l.pop();if(m==null||m.length===0)throw new Error(`invalid snapshot path "${h}"`);let b=o;for(let g of l){let y=b._mounts.get(g);if(!y)throw new Error(`unknown mount "${g}" in path "${h}"`);b=y}return[b,m]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${Z}${Me}${Z}`)).sort((h,l)=>h[0]<l[0]?-1:h[0]>l[0]?1:0),c=new Map(u),p=new Map,f=!0;for(;c.size>0&&f;){f=!1;for(let[h,l]of[...c.entries()]){let m=l?.deps??[];if(!m.every(k=>p.has(k)))continue;let[b,g]=d(h),y={...l?.meta??{}},v=a(h),T;if(l?.type==="state")T=F(l.value,{meta:y});else{if(v==null)continue;T=v(g,{path:h,type:l.type,value:l.value,meta:y,deps:m,resolvedDeps:m.map(k=>p.get(k))})}b.add(T,{name:g}),p.set(h,T),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 o.restore(e),o}toJSON(){return this.snapshot()}attachStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let s=(u,c)=>{if(u.disposed)return;let p=Ka(c.nodes);if(u.lastSnapshot!=null&&p!==""&&p===u.lastFingerprint)return;let f=u.seq+1,h=re(),b=u.lastSnapshot==null||f%u.compactEvery===0?{mode:"full",snapshot:c,seq:f,timestamp_ns:h,format_version:ut}:{mode:"diff",diff:su(u.lastSnapshot,c),seq:f,timestamp_ns:h,format_version:ut};if(u.tier.filter&&!u.tier.filter(this.name,b))return;let g;try{g=u.tier.save(this.name,b)}catch(y){n.onError?.(y,u.tier);return}if(g&&typeof g.then=="function"){let T=(u.savePending??Promise.resolve()).then(()=>g,()=>g).then(()=>{u.disposed||(u.seq=f,u.lastSnapshot=c,u.lastFingerprint=p)},k=>{n.onError?.(k,u.tier)});u.savePending=T.finally(()=>{u.savePending===T&&(u.savePending=void 0)})}else u.seq=f,u.lastSnapshot=c,u.lastFingerprint=p},o=(u,c)=>{try{s(u,c)}catch(p){n.onError?.(p,u.tier)}},i=(u,c)=>{if(!c.some(l=>{let m=this.config.messageTier(l[0]);return m>=3&&m<5}))return;if(n.filter){let l=this.tryResolve(u);if(l==null)return;let m=Hn(l,Ut("standard"));if(!n.filter(u,m))return}let f,h=()=>(f==null&&(f=this.snapshot()),f);for(let l of r)l.disposed||(l.debounceMs===0?o(l,h()):(l.timer==null&&(l.timer=new Oe),l.timer.start(l.debounceMs,()=>{l.disposed||o(l,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.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((u,c)=>i(u,c));let d=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,n){for(let r of e){let s;try{s=await r.load(this.name)}catch(i){n?.(i,r);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===ut&&o.nodes!=null)return this.restore(o),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let s of n){let o;try{o=await s.load(e)}catch(d){r?.onError?.(d,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===ut&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(d){r?.onError?.(d,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,n,r){if(e!=null&&n!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,n),this.config.inspectorEnabled){let s={path:e,annotation:n,timestamp_ns:ne(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(s=>!e(s)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let s of n)this._traceRing.push(s);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(n.nodes)),o=[...s].filter(y=>!r.has(y)).sort(),i=[...r].filter(y=>!s.has(y)).sort(),a=[],d=[];for(let y of r){if(!s.has(y))continue;let v=e.nodes[y],T=n.nodes[y],k=v.v,x=T.v;k!=null&&x!=null&&k.id===x.id&&k.version!==x.version&&d.push({path:y,id:k.id,from:k.version,to:x.version});let E=k!=null&&x!=null&&k.id===x.id&&k.version===x.version;for(let S of["type","status","sentinel"]){let M=v[S],I=T[S];M!==I&&a.push({path:y,field:S,from:M,to:I})}if(!E)for(let S of["value","meta"]){let M=v[S],I=T[S];za(M,I)||a.push({path:y,field:S,from:M,to:I})}}let u=y=>`${y.from} ${y.to}`,c=new Set(e.edges.map(u)),p=new Set(n.edges.map(u)),f=n.edges.filter(y=>!c.has(u(y))),h=e.edges.filter(y=>!p.has(u(y))),l=new Set(e.subgraphs),m=new Set(n.subgraphs),b=[...m].filter(y=>!l.has(y)).sort(),g=[...l].filter(y=>!m.has(y)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:f,edgesRemoved:h,subgraphsAdded:b,subgraphsRemoved:g}}};function su(t,e){let n=xt.diff(t,e),r={};for(let s of n.nodesAdded){let o=e.nodes[s];o!=null&&(r[s]=o)}return{...n,nodesAddedFull:r}}function bo(t,e,n,r={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?s:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=r.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return r.withDetail?s:[];let i=new Map,a=new Map,d=new Map,u=new Map,c=new Set;for(let[v,T]of Object.entries(t.nodes)){if(!v)continue;c.add(v);let k=T.deps??[];i.set(v,k);for(let x of k)x&&(c.add(x),a.has(x)||a.set(x,new Set),a.get(x).add(v))}for(let v of t.edges){if(v==null||typeof v!="object")continue;let T=typeof v.from=="string"?v.from:"",k=typeof v.to=="string"?v.to:"";!T||!k||(c.add(T),c.add(k),u.has(T)||u.set(T,new Set),u.get(T).add(k),d.has(k)||d.set(k,new Set),d.get(k).add(T))}if(!c.has(e))return r.withDetail?s:[];let p=r.both===!0,f=v=>{if(p){let E=i.get(v)??[],S=d.get(v),M=a.get(v),I=u.get(v),D=[...E];return S&&D.push(...S),M&&D.push(...M),I&&D.push(...I),D}if(n==="upstream"){let E=i.get(v)??[],S=d.get(v);return S?[...E,...S]:E}let T=a.get(v),k=u.get(v),x=T?[...T]:[];return k&&x.push(...k),x},h=new Set([e]),l=new Map,m=[{path:e,depth:0}],b=0,g=!1;for(;b<m.length;){let v=m[b++];if(o!=null&&v.depth>=o){f(v.path).length>0&&(g=!0);continue}for(let T of f(v.path))!T||h.has(T)||(h.add(T),l.set(T,v.depth+1),m.push({path:T,depth:v.depth+1}))}let y=[...l.keys()].sort((v,T)=>v<T?-1:v>T?1:0);return r.withDetail?{paths:y,depths:l,truncated:g}:y}function iu(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],s=e[n];if(r.path!==s.path||r.type!==s.type||r.status!==s.status||r.hop!==s.hop||r.dep_index!==s.dep_index||r.annotation!==s.annotation||r.value!==s.value||r.lastMutation!==s.lastMutation)return!1;let o=r.v,i=s.v;if(o!==i&&(o==null||i==null||o.id!==i.id||o.version!==i.version))return!1}return!0}function au(t,e,n,r){let s=new xt(t,r);s.add(e,{name:"source"});let o=F(n,{meta:{kind:"stratify_rules"}});s.add(o,{name:"rules"});for(let i of n)uu(s,e,o,i);return s}function uu(t,e,n,r){let s=`branch/${r.name}`,o=Symbol("noValue"),i=!1,a=!1,d=!1,u=o,c=!1,p=n.cache??[];function f(m){if(d){d=!1;let b=u;if(u=o,b!==o){let g=p.find(v=>v.name===r.name),y=!1;try{y=g?.classify(b)??!1}catch{y=!1}y?(c=!1,m.emit(b)):c&&(c=!1,m.down([[G],[A]]))}else c?(c=!1,m.down([[G],[A]])):m.down([[A]])}}let h=B([],(m,b)=>{let g=e.subscribe(v=>{for(let T of v)l(T,0,b)}),y=n.subscribe(v=>{for(let T of v)l(T,1,b)});return()=>{g(),y()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:r.name},completeWhenDepsComplete:!1});function l(m,b,g){let y=m[0];return y===G?(b===0?(i=!0,c=!0):a=!0,!0):y===w||y===A?(b===0?(i=!1,d=!0,u=y===w?m[1]:o):(y===w&&(p=m[1]),a=!1),i||a||f(g),!0):y===_||y===N||y===K?(i=!1,a=!1,d=!1,u=o,c=!1,b===0&&g.down([m]),!0):b===1}if(t.add(h,{name:s}),r.ops){let m=r.ops(h),b=`branch/${r.name}/out`;t.add(m,{name:b})}}At();ye();X();we();ue();Ie();X();var du=new Map([[ve,"INVALIDATE"],[me,"PAUSE"],[Te,"RESUME"],[K,"TEARDOWN"],[_,"COMPLETE"],[N,"ERROR"]]),cu=new Map([["INVALIDATE",ve],["PAUSE",me],["RESUME",Te],["TEARDOWN",K],["COMPLETE",_],["ERROR",N]]);function Je(t){let e=du.get(t);return e||(Symbol.keyFor(t)??"UNKNOWN")}function dt(t){let e=cu.get(t);if(e)return e;if(t&&t!=="UNKNOWN")return Symbol.for(t)}function ct(t){return t instanceof Error?{message:t.message,name:t.name,stack:t.stack}:{message:String(t),name:"Error"}}function lt(t){let e=new Error(t.message);return e.name=t.name,t.stack&&(e.stack=t.stack),e}function Ye(t){if(typeof MessagePort<"u"&&t instanceof MessagePort)return{post(e,n){t.postMessage(e,n??[])},listen(e){let n=r=>e(r.data);return t.addEventListener("message",n),t.start(),()=>t.removeEventListener("message",n)},terminate(){t.close()}};if(typeof SharedWorker<"u"&&t instanceof SharedWorker)return Ye(t.port);if(typeof Worker<"u"&&t instanceof Worker)return{post(e,n){t.postMessage(e,n??[])},listen(e){let n=r=>e(r.data);return t.addEventListener("message",n),()=>t.removeEventListener("message",n)},terminate(){t.terminate()}};if(typeof BroadcastChannel<"u"&&t instanceof BroadcastChannel)return{post(e,n){n&&n.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),t.postMessage(e)},listen(e){let n=r=>e(r.data);return t.addEventListener("message",n),()=>t.removeEventListener("message",n)},terminate(){t.close()}};if(typeof ServiceWorker<"u"&&t instanceof ServiceWorker)return{post(e,n){t.postMessage(e,n??[])},listen(e){let n=r=>{r.source===t&&e(r.data)};return navigator.serviceWorker.addEventListener("message",n),()=>navigator.serviceWorker.removeEventListener("message",n)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function lu(t){return typeof t=="object"&&t!==null&&typeof t.post=="function"&&typeof t.listen=="function"}function xo(t,e){let n=lu(t)?t:Ye(t),r=e.name??"workerBridge",s=Object.entries(e.expose??{}),o=e.import??[],i=e.transfer??{},a=F("connecting",{name:`${r}::meta::status`}),d=F(null,{name:`${r}::meta::error`}),u=new Map,c=new Map;for(let y of o){let v=F(void 0,{name:`${r}::${y}`});u.set(y,v)}let p;if(s.length>0){let y=s.map(([,k])=>k),v=B(y,(k,x)=>{let E={};for(let S=0;S<s.length;S++){let[M]=s[S],I=k[S];I!=null&&I.length>0&&(E[M]=I.at(-1))}Object.keys(E).length!==0&&x.emit(E)},{name:`${r}::aggregated`,partial:!0});p=Mt([v],k=>{let x=k[0];if(x==null||Object.keys(x).length===0)return;let E=[];for(let I of Object.keys(x)){let D=i[I];D&&E.push(...D(x[I]))}let S;for(let[I,D]of s)I in x&&D.v!=null&&(S==null&&(S={}),S[I]=D.v.version);let M={t:"b",u:x,...S?{v:S}:{}};try{n.post(M,E.length>0?E:void 0)}catch(I){d.down([[w,I instanceof Error?I:new Error(String(I))]])}}).subscribe(()=>{})}let f=!1,h=n.listen(y=>{if(f)return;let v=y;switch(v.t){case"r":{j(()=>{for(let[k,x]of Object.entries(v.stores)){let E=u.get(k);E&&E.down([[w,x]])}}),a.down([[w,"connected"]]);let T={};for(let[k,x]of s)T[k]=x.cache;n.post({t:"i",stores:T});break}case"v":{let T=u.get(v.s);T&&T.down([[w,v.d]]);break}case"b":{j(()=>{for(let[T,k]of Object.entries(v.u)){let x=v.v?.[T];if(x!=null){let S=c.get(T);if(S!=null&&x<=S)continue;c.set(T,x)}let E=u.get(T);E&&E.down([[w,k]])}});break}case"e":{let T=u.get(v.s);T&&T.down([[N,lt(v.err)]]);break}case"s":{let T=dt(v.sig);if(!T)break;let k=v.s==="*"?[...u.values()]:u.has(v.s)?[u.get(v.s)]:[];for(let x of k)x.down(v.d===void 0?[[T]]:[[T,v.d]]);break}}}),l=[];for(let[y,v]of s){let T=v.subscribe((k=>{if(!f)for(let x of k){let E=x[0];E!==w&&(le.isLocalOnly(E)||(E===N?n.post({t:"e",s:y,err:ct(x[1])}):n.post({t:"s",s:y,sig:Je(E),d:x.length>1?x[1]:void 0})))}}));l.push(T)}let m;if(e.timeoutMs!=null&&e.timeoutMs>0){let y=We(e.timeoutMs),v=Bt(a,k=>k==="connected");m=Fn(vt(Lt(y,()=>"timeout"),Lt(v,()=>"ready"))).subscribe(k=>{for(let x of k)x[0]===w&&x[1]==="timeout"&&(d.down([[w,new Error("Worker bridge handshake timeout")]]),b())})}function b(){if(!f){f=!0,m?.(),n.post({t:"s",s:"*",sig:Je(K)}),p&&p();for(let y of l)y();l.length=0,h(),a.down([[w,"closed"]]),c.clear(),u.clear()}}let g={meta:{status:a,error:d},destroy:b};for(let[y,v]of u)g[y]=v;return g}ye();X();we();ue();function fu(t){return typeof t=="object"&&t!==null&&typeof t.post=="function"&&typeof t.listen=="function"}function ko(t,e){let n=fu(t)?t:Ye(t),r=e.import??[],s=e.transfer??{},o=new Map,i=new Map,a={};for(let b of r){let g=F(void 0,{name:`worker::${b}`});o.set(b,g),a[b]=g}let d=e.expose(a),u=Object.entries(d),c,p=!1;if(u.length>0){let b=u.map(([,v])=>v),g=B(b,(v,T)=>{let k={};for(let x=0;x<u.length;x++){let[E]=u[x],S=v[x];S!=null&&S.length>0&&(k[E]=S.at(-1))}Object.keys(k).length!==0&&T.emit(k)},{name:"workerSelf::aggregated",partial:!0});c=Mt([g],v=>{if(p)return;let T=v[0];if(T==null||Object.keys(T).length===0)return;let k=[];for(let S of Object.keys(T)){let M=s[S];M&&k.push(...M(T[S]))}let x;for(let[S,M]of u)S in T&&M.v!=null&&(x==null&&(x={}),x[S]=M.v.version);let E={t:"b",u:T,...x?{v:x}:{}};try{n.post(E,k.length>0?k:void 0)}catch{}}).subscribe(()=>{})}let f=[];for(let[b,g]of u){let y=g.subscribe((v=>{if(!p)for(let T of v){let k=T[0];k!==w&&(le.isLocalOnly(k)||(k===N?n.post({t:"e",s:b,err:ct(T[1])}):n.post({t:"s",s:b,sig:Je(k),d:T.length>1?T[1]:void 0})))}}));f.push(y)}let h=n.listen(b=>{if(p)return;let g=b;switch(g.t){case"i":{j(()=>{for(let[y,v]of Object.entries(g.stores)){let T=o.get(y);T&&T.down([[w,v]])}});break}case"v":{let y=o.get(g.s);y&&y.down([[w,g.d]]);break}case"b":{j(()=>{for(let[y,v]of Object.entries(g.u)){let T=g.v?.[y];if(T!=null){let x=i.get(y);if(x!=null&&T<=x)continue;i.set(y,T)}let k=o.get(y);k&&k.down([[w,v]])}});break}case"e":{let y=o.get(g.s);y&&y.down([[N,lt(g.err)]]);break}case"s":{let y=dt(g.sig);if(!y)break;if(y===K&&g.s==="*"){m();return}let v=g.s==="*"?[...o.values()]:o.has(g.s)?[o.get(g.s)]:[];for(let T of v)T.down(g.d===void 0?[[y]]:[[y,g.d]]);break}}}),l={};for(let[b,g]of u)l[b]=g.cache;n.post({t:"r",stores:l});function m(){if(!p){p=!0,c&&c();for(let b of f)b();f.length=0,h(),n.terminate?.(),i.clear(),o.clear()}}return{destroy:m}}0&&(module.exports={CircuitOpenError,ContentAddressedMissError,NS_PER_MS,NS_PER_SEC,NativeIndexBackend,NativeListBackend,NativeLogBackend,NativeMapBackend,NativePubSubBackend,RateLimiterOverflowError,ResettableTimer,TimeoutError,audit,awaitSettled,buffer,bufferCount,bufferTime,cached,canonicalJson,cascadingCache,catchError,checkpointToRedis,checkpointToS3,circuitBreaker,combine,combineLatest,concat,concatMap,constant,contentAddressedStorage,createTransport,createWatermarkController,csvRows,debounce,debounceTime,decorrelatedJitter,delay,deserializeError,dictStorage,distill,distinctUntilChanged,elementAt,empty,escapeRegexChar,exhaustMap,exponential,externalBundle,externalProducer,fallback,fibonacci,filter,find,first,firstValueFrom,firstWhere,flatMap,forEach,fromAny,fromAsyncIter,fromCSV,fromClickHouseWatch,fromCron,fromDrizzle,fromEvent,fromHTTP,fromHTTPPoll,fromHTTPStream,fromIter,fromKafka,fromKysely,fromMCP,fromNATS,fromNDJSON,fromOTel,fromPrisma,fromPrometheus,fromPromise,fromPulsar,fromRabbitMQ,fromRaf,fromRedisStream,fromSSE,fromSqlite,fromSqliteCursor,fromStatsD,fromSyslog,fromTimer,fromWebSocket,fromWebSocketReconnect,fromWebhook,globToRegExp,interval,keepalive,last,linear,lru,makeHttpError,map,matchesAnyPattern,matchesCron,memoryStorage,merge,mergeMap,nameToSignal,ndjsonRows,never,nodeSignal,of,onFirstData,pairwise,parseCron,parsePrometheusText,parseSSEStream,parseStatsD,parseSyslog,pausable,pubsub,race,rateLimiter,reactiveCounter,reactiveIndex,reactiveList,reactiveLog,reactiveMap,reactiveSink,reduce,repeat,replay,rescue,resolveBackoffPreset,retry,retrySource,sample,scan,serializeError,share,shareReplay,signalToName,singleFromAny,singleNodeFromAny,skip,sortJsonValue,stableJsonString,stratify,switchMap,take,takeUntil,takeWhile,tap,tapFirst,throttle,throttleTime,throwError,timeout,toArray,toCSV,toClickHouse,toFile,toHTTP,toKafka,toLoki,toMongo,toNATS,toObservable,toPostgres,toPulsar,toRabbitMQ,toReadableStream,toRedisStream,toS3,toSSE,toSSEBytes,toSqlite,toTempo,toWebSocket,tokenBucket,valve,verifiable,window,windowCount,windowTime,withBreaker,withLatestFrom,withMaxAttempts,withStatus,workerBridge,workerSelf,zip});
|