@graphrefly/graphrefly 0.34.0 → 0.35.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-DKIb6Pk8.d.cts → cascading-B25wxpRa.d.cts} +3 -3
- package/dist/{cascading-Bg0a4VSf.d.ts → cascading-BsJ4GbnS.d.ts} +3 -3
- package/dist/{chunk-TZLEMGAK.js → chunk-2Y3DKIZL.js} +2 -2
- package/dist/chunk-3OT7K33Q.js +1 -0
- package/dist/chunk-53XJ2S6D.js +1 -0
- package/dist/chunk-5CPPC75H.js +1 -0
- package/dist/chunk-5KPIYVCC.js +7 -0
- package/dist/{chunk-GAOX6OPT.js → chunk-5XZRCS2M.js} +1 -1
- package/dist/{chunk-C5DINHNP.js → chunk-6G5YD37E.js} +1 -1
- package/dist/{chunk-WBWBY6LI.js → chunk-6SVKZ7VI.js} +1 -1
- package/dist/chunk-A5HZZYRK.js +1 -0
- package/dist/chunk-BGEY3PXH.js +1 -0
- package/dist/chunk-CD4CB6S7.js +1 -0
- package/dist/chunk-CE72X3WO.js +1 -0
- package/dist/chunk-CUQFO6MT.js +1 -0
- package/dist/chunk-D5RFJOZ2.js +1 -0
- package/dist/{chunk-A3GDELMY.js → chunk-E5YSBQSF.js} +7 -7
- package/dist/{chunk-SFIM774L.js → chunk-EUE7ELFQ.js} +1 -1
- package/dist/chunk-F3IGTWCQ.js +1 -0
- package/dist/chunk-F672GV32.js +1 -0
- package/dist/{chunk-GCUYSIM4.js → chunk-GWOKTENT.js} +1 -1
- package/dist/{chunk-4NYSEUKV.js → chunk-J6TGRQUP.js} +1 -1
- package/dist/{chunk-4F564IPP.js → chunk-JJTF75VS.js} +1 -1
- package/dist/{chunk-BY4WKPKM.js → chunk-JUJEPZOI.js} +1 -1
- package/dist/{chunk-65WWQ5CB.js → chunk-M5UC63ZI.js} +5 -5
- package/dist/chunk-MQZWA3DF.js +1 -0
- package/dist/chunk-MYFR67PY.js +18 -0
- package/dist/{chunk-KN2UMFT6.js → chunk-PCD2MU7X.js} +1 -1
- package/dist/{chunk-YDWTVO4E.js → chunk-PIIUJIF7.js} +1 -1
- package/dist/chunk-PVUTRA5K.js +5 -0
- package/dist/chunk-Q7EUZ6NN.js +1 -0
- package/dist/chunk-RLMYS3XZ.js +1 -0
- package/dist/chunk-RRFOCAH6.js +1 -0
- package/dist/{chunk-Q46YJCQH.js → chunk-T6RPUERH.js} +1 -1
- package/dist/{chunk-IPNJDNE7.js → chunk-T7GWBGOO.js} +1 -1
- package/dist/{chunk-U2T2XWDA.js → chunk-U347KVM4.js} +1 -1
- package/dist/chunk-UAMWD4GG.js +1 -0
- package/dist/chunk-VN6RDSK2.js +1 -0
- package/dist/{chunk-CJMFZXIZ.js → chunk-W2ZU226Q.js} +1 -1
- package/dist/{chunk-UF746BQ4.js → chunk-XINLP35X.js} +1 -1
- package/dist/{chunk-TONEKQM3.js → chunk-XMDNNSMK.js} +1 -1
- package/dist/{chunk-INXDSJRC.js → chunk-YOUAVGHJ.js} +1 -1
- package/dist/chunk-YV2A2VWG.js +1 -0
- package/dist/{chunk-PBN426RU.js → chunk-ZGVA2SR5.js} +1 -1
- package/dist/compat/index.cjs +10 -10
- package/dist/compat/index.d.cts +17 -14
- package/dist/compat/index.d.ts +17 -14
- package/dist/compat/index.js +1 -1
- package/dist/compat/jotai/index.d.cts +2 -2
- package/dist/compat/jotai/index.d.ts +2 -2
- package/dist/compat/nanostores/index.d.cts +2 -2
- package/dist/compat/nanostores/index.d.ts +2 -2
- package/dist/compat/nestjs/index.cjs +12 -12
- package/dist/compat/nestjs/index.d.cts +9 -6
- package/dist/compat/nestjs/index.d.ts +9 -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 +7 -7
- package/dist/compat/zustand/index.d.cts +5 -4
- package/dist/compat/zustand/index.d.ts +5 -4
- package/dist/compat/zustand/index.js +1 -1
- package/dist/{composite-BPDU_XV1.d.ts → composite-CT_mApQD.d.ts} +2 -2
- package/dist/{composite-CmvdhTJe.d.cts → composite-_XckYx2e.d.cts} +2 -2
- package/dist/{content-addressed-storage-DqIWCmZG.d.cts → content-addressed-storage-4-ST1tYk.d.cts} +5 -5
- package/dist/{content-addressed-storage-BUiREIuj.d.ts → content-addressed-storage-DuYMjV7o.d.ts} +5 -5
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/extra/browser.cjs +1 -1
- package/dist/extra/browser.d.cts +4 -3
- package/dist/extra/browser.d.ts +4 -3
- package/dist/extra/browser.js +1 -1
- package/dist/extra/index.cjs +19 -19
- package/dist/extra/index.d.cts +13 -12
- package/dist/extra/index.d.ts +13 -12
- package/dist/extra/index.js +1 -1
- package/dist/extra/node.cjs +2 -3
- package/dist/extra/node.d.cts +3 -3
- package/dist/extra/node.d.ts +3 -3
- package/dist/extra/node.js +2 -2
- package/dist/extra/operators.cjs +1 -1
- package/dist/extra/operators.d.cts +1 -1
- package/dist/extra/operators.d.ts +1 -1
- package/dist/extra/operators.js +1 -1
- package/dist/extra/reactive.cjs +1 -1
- package/dist/extra/reactive.d.cts +4 -3
- package/dist/extra/reactive.d.ts +4 -3
- package/dist/extra/reactive.js +1 -1
- package/dist/extra/sources.cjs +1 -1
- package/dist/extra/sources.d.cts +57 -2
- package/dist/extra/sources.d.ts +57 -2
- package/dist/extra/sources.js +1 -1
- package/dist/extra/storage-browser.cjs +1 -1
- package/dist/extra/storage-browser.d.cts +8 -42
- package/dist/extra/storage-browser.d.ts +8 -42
- package/dist/extra/storage-browser.js +1 -1
- package/dist/extra/storage-core.cjs +1 -1
- package/dist/extra/storage-core.d.cts +13 -83
- package/dist/extra/storage-core.d.ts +13 -83
- package/dist/extra/storage-core.js +1 -1
- package/dist/extra/storage-node.cjs +1 -2
- package/dist/extra/storage-node.d.cts +1 -59
- package/dist/extra/storage-node.d.ts +1 -59
- package/dist/extra/storage-node.js +0 -1
- package/dist/extra/storage-tiers-browser.cjs +1 -0
- package/dist/extra/storage-tiers-browser.d.cts +49 -0
- package/dist/extra/storage-tiers-browser.d.ts +49 -0
- package/dist/extra/storage-tiers-browser.js +1 -0
- package/dist/extra/storage-tiers-node.cjs +1 -0
- package/dist/extra/storage-tiers-node.d.cts +86 -0
- package/dist/extra/storage-tiers-node.d.ts +86 -0
- package/dist/extra/storage-tiers-node.js +1 -0
- package/dist/extra/storage-tiers.cjs +1 -0
- package/dist/extra/storage-tiers.d.cts +284 -0
- package/dist/extra/storage-tiers.d.ts +284 -0
- package/dist/extra/storage-tiers.js +1 -0
- package/dist/{fallback-mYSd8vQo.d.ts → fallback-DuEXfA4F.d.ts} +14 -14
- package/dist/{fallback-9YznPvPP.d.cts → fallback-axI2cXwt.d.cts} +14 -14
- package/dist/graph/index.cjs +3 -3
- package/dist/graph/index.d.cts +6 -5
- package/dist/graph/index.d.ts +6 -5
- package/dist/graph/index.js +1 -1
- package/dist/{graph-BROUZPG9.d.ts → graph-Cv-8x0ZI.d.ts} +28 -16
- package/dist/{graph-DaoydJ_u.d.cts → graph-kTltt95s.d.cts} +28 -16
- package/dist/imperative-audit-ahAE65a9.d.cts +28 -0
- package/dist/imperative-audit-ahAE65a9.d.ts +28 -0
- package/dist/{index-CI5fULSz.d.ts → index-8OxXae3g.d.ts} +1 -1
- package/dist/{index-CQ1gt4rn.d.cts → index-9xhIaM-w.d.cts} +1 -1
- package/dist/{index-DhWrMTI6.d.cts → index-B3D_z0Z6.d.cts} +1 -1
- package/dist/{index-Ccv_61jG.d.cts → index-B3Dfl5sS.d.cts} +110 -27
- package/dist/{index-Dia4yc2y.d.ts → index-B4s70vYf.d.ts} +4 -4
- package/dist/{index-Db21wuaD.d.ts → index-B5UR87KG.d.ts} +3 -3
- package/dist/{index-DuvQAU02.d.ts → index-BBdwz2BW.d.ts} +2 -2
- package/dist/{index-B5eS17Bz.d.ts → index-BEvsFlfH.d.ts} +47 -32
- package/dist/{index-BUtCR0k6.d.ts → index-BF-ssbJB.d.ts} +7 -7
- package/dist/{index-ClKm7CFB.d.cts → index-BFuVcqL8.d.cts} +1 -1
- package/dist/{index-BkfL5MXh.d.cts → index-BWH17rK_.d.cts} +3 -3
- package/dist/{index-CD7qmvSf.d.ts → index-BZ1V5GzX.d.ts} +3 -3
- package/dist/{index-BDEhWLF4.d.cts → index-BhkPzu-Z.d.cts} +4 -4
- package/dist/{index-CNxdDb2e.d.ts → index-Bilohojo.d.ts} +3 -3
- package/dist/{index-zA1uVtk0.d.ts → index-BiomL7AW.d.ts} +1 -1
- package/dist/{index-BWiX5foT.d.ts → index-BjWZARLy.d.ts} +1 -1
- package/dist/{index-IxinNgAH.d.cts → index-BkbawFkI.d.cts} +16 -15
- package/dist/{index-RJX4snyi.d.cts → index-BlRVj-7Q.d.cts} +21 -21
- package/dist/index-BpFwRAf9.d.cts +26 -0
- package/dist/{index-Ds3Rz9m9.d.cts → index-BsZlbHM5.d.cts} +3 -3
- package/dist/{index-BFHpNSsV.d.ts → index-BtY2QVDf.d.cts} +8 -7
- package/dist/{index-BsxqmV6u.d.ts → index-BuMzxRO2.d.ts} +2 -2
- package/dist/{index-C5uMGVJw.d.ts → index-BwYGLgmI.d.ts} +4 -4
- package/dist/{index-3L3RC3VJ.d.ts → index-C40wA8zt.d.ts} +7 -7
- package/dist/{index-Bi4ZP6Hc.d.ts → index-C9xF16gc.d.ts} +110 -27
- package/dist/index-CAIhFfws.d.ts +171 -0
- package/dist/{index-BRisOxlx.d.ts → index-CDvC1m5p.d.ts} +1 -1
- package/dist/index-CGKs5ixV.d.cts +287 -0
- package/dist/{index-ygRFoyrN.d.ts → index-CI_yjtua.d.ts} +2 -2
- package/dist/{index-DxEcY7Om.d.ts → index-CIcu6fIR.d.ts} +1 -1
- package/dist/{index-CQtnGFrZ.d.cts → index-CfOSES72.d.cts} +7 -7
- package/dist/{index-Bd2AjMQY.d.ts → index-Cot94_82.d.ts} +21 -21
- package/dist/{index-B1hFhK1K.d.cts → index-CpZKtdMw.d.cts} +1 -1
- package/dist/{index-BO6t0HjV.d.cts → index-CqSJ25A9.d.cts} +1 -1
- package/dist/{index-Jgl7ev9I.d.cts → index-CzC0G0C3.d.cts} +9 -9
- package/dist/{index-p0bkNfby.d.cts → index-D6JRP-1_.d.cts} +3 -3
- package/dist/{index-D23g00HE.d.cts → index-D7r_vd0b.d.cts} +4 -4
- package/dist/{index-Cp91Sxbo.d.cts → index-D8IyqHvT.d.cts} +3 -3
- package/dist/{index-iKsmdnq6.d.cts → index-D9qoEOj_.d.cts} +2 -2
- package/dist/index-DBmBtqAN.d.ts +461 -0
- package/dist/{index-nP13Qe6T.d.ts → index-DFe2Pk2u.d.ts} +1 -1
- package/dist/{index-Cn3taOmp.d.cts → index-DKp1CIbG.d.cts} +2 -2
- package/dist/{index-CoR-tOZA.d.cts → index-DSD6xnbT.d.ts} +8 -7
- package/dist/{index-DheNs40A.d.ts → index-DXSLMoma.d.ts} +2 -2
- package/dist/{index-ZIQaKIdY.d.cts → index-DXZsXxtU.d.cts} +47 -32
- package/dist/{index-BVTjuKeP.d.cts → index-D_QQ_dTD.d.cts} +1 -1
- package/dist/{index-ChZvMC4M.d.cts → index-DeyzuqAi.d.cts} +7 -7
- package/dist/{index-Chi9IiHJ.d.ts → index-DlccEIi3.d.ts} +3 -3
- package/dist/{index-DR3XqZlV.d.cts → index-DmtWMP0X.d.cts} +1 -1
- package/dist/{index-CbCNoogR.d.ts → index-Dp69u0ym.d.ts} +16 -15
- package/dist/{index-b4a6Sg0R.d.ts → index-DwNNufVa.d.ts} +4 -4
- package/dist/{index-D80nGRb9.d.ts → index-DzYTXMBz.d.ts} +3 -3
- package/dist/index-DzgS5uYi.d.ts +26 -0
- package/dist/{index-B-KCkW4M.d.cts → index-GaW6Welt.d.cts} +4 -4
- package/dist/{index-DupIl9wI.d.ts → index-JYtN9uqM.d.ts} +1 -1
- package/dist/{index-Ced0dphF.d.ts → index-KNAMYngu.d.ts} +9 -9
- package/dist/{index-BpjQanLs.d.cts → index-PluovH45.d.cts} +2 -2
- package/dist/index-Qq-G9B6g.d.cts +171 -0
- package/dist/{index-yJY9thRY.d.cts → index-XxSeddWP.d.cts} +2 -2
- package/dist/{index-C8_bnDBZ.d.cts → index-ZhKyR8co.d.cts} +3 -3
- package/dist/index-hXKhbfh-.d.ts +287 -0
- package/dist/index-zK_mN1D-.d.cts +461 -0
- package/dist/index.cjs +59 -59
- package/dist/index.d.cts +53 -49
- package/dist/index.d.ts +53 -49
- package/dist/index.js +1 -1
- package/dist/{meta-BdjSt8ky.d.cts → meta-BGO6C7K9.d.cts} +1 -1
- package/dist/{meta-CtDjj7cU.d.ts → meta-CC6EPdpK.d.ts} +1 -1
- package/dist/{node-8qx0kgYt.d.cts → node-fSc-hCv8.d.cts} +1 -1
- package/dist/{node-8qx0kgYt.d.ts → node-fSc-hCv8.d.ts} +1 -1
- package/dist/{observable-B6Ba-TTI.d.cts → observable-Cqty11jG.d.cts} +1 -1
- package/dist/{observable-DOniYM2B.d.ts → observable-EAV_rNfM.d.ts} +1 -1
- package/dist/patterns/ai/browser.cjs +5 -5
- package/dist/patterns/ai/browser.d.cts +4 -4
- package/dist/patterns/ai/browser.d.ts +4 -4
- package/dist/patterns/ai/browser.js +1 -1
- package/dist/patterns/ai/index.cjs +19 -19
- package/dist/patterns/ai/index.d.cts +19 -17
- package/dist/patterns/ai/index.d.ts +19 -17
- package/dist/patterns/ai/index.js +1 -1
- package/dist/patterns/ai/node.cjs +1 -2
- package/dist/patterns/ai/node.d.cts +9 -9
- package/dist/patterns/ai/node.d.ts +9 -9
- package/dist/patterns/ai/node.js +1 -1
- package/dist/patterns/audit/index.cjs +6 -6
- package/dist/patterns/audit/index.d.cts +7 -5
- package/dist/patterns/audit/index.d.ts +7 -5
- package/dist/patterns/audit/index.js +1 -1
- package/dist/patterns/cqrs/index.cjs +7 -7
- package/dist/patterns/cqrs/index.d.cts +7 -4
- package/dist/patterns/cqrs/index.d.ts +7 -4
- package/dist/patterns/cqrs/index.js +1 -1
- package/dist/patterns/demo-shell/index.cjs +8 -8
- package/dist/patterns/demo-shell/index.d.cts +6 -5
- package/dist/patterns/demo-shell/index.d.ts +6 -5
- package/dist/patterns/demo-shell/index.js +1 -1
- package/dist/patterns/domain-templates/index.cjs +5 -5
- package/dist/patterns/domain-templates/index.d.cts +5 -4
- package/dist/patterns/domain-templates/index.d.ts +5 -4
- package/dist/patterns/domain-templates/index.js +1 -1
- package/dist/patterns/graphspec/index.cjs +20 -20
- package/dist/patterns/graphspec/index.d.cts +6 -5
- package/dist/patterns/graphspec/index.d.ts +6 -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 +8 -6
- package/dist/patterns/guarded-execution/index.d.ts +8 -6
- package/dist/patterns/guarded-execution/index.js +1 -1
- package/dist/patterns/harness/index.cjs +12 -12
- package/dist/patterns/harness/index.d.cts +13 -10
- package/dist/patterns/harness/index.d.ts +13 -10
- package/dist/patterns/harness/index.js +1 -1
- package/dist/patterns/job-queue/index.cjs +7 -7
- package/dist/patterns/job-queue/index.d.cts +8 -4
- package/dist/patterns/job-queue/index.d.ts +8 -4
- package/dist/patterns/job-queue/index.js +1 -1
- package/dist/patterns/lens/index.cjs +4 -4
- package/dist/patterns/lens/index.d.cts +7 -6
- package/dist/patterns/lens/index.d.ts +7 -6
- package/dist/patterns/lens/index.js +1 -1
- package/dist/patterns/memory/index.cjs +1 -1
- package/dist/patterns/memory/index.d.cts +5 -4
- package/dist/patterns/memory/index.d.ts +5 -4
- package/dist/patterns/memory/index.js +1 -1
- package/dist/patterns/messaging/index.cjs +7 -7
- package/dist/patterns/messaging/index.d.cts +6 -4
- package/dist/patterns/messaging/index.d.ts +6 -4
- package/dist/patterns/messaging/index.js +1 -1
- package/dist/patterns/orchestration/index.cjs +7 -7
- package/dist/patterns/orchestration/index.d.cts +8 -5
- package/dist/patterns/orchestration/index.d.ts +8 -5
- package/dist/patterns/orchestration/index.js +1 -1
- package/dist/patterns/process/index.cjs +1 -0
- package/dist/patterns/process/index.d.cts +10 -0
- package/dist/patterns/process/index.d.ts +10 -0
- package/dist/patterns/process/index.js +1 -0
- package/dist/patterns/reactive-layout/index.cjs +5 -5
- package/dist/patterns/reactive-layout/index.d.cts +6 -5
- package/dist/patterns/reactive-layout/index.d.ts +6 -5
- package/dist/patterns/reactive-layout/index.js +1 -1
- package/dist/patterns/reduction/index.cjs +1 -1
- package/dist/patterns/reduction/index.d.cts +5 -4
- package/dist/patterns/reduction/index.d.ts +5 -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 +7 -5
- package/dist/patterns/refine-loop/index.d.ts +7 -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 +7 -6
- package/dist/patterns/resilient-pipeline/index.d.ts +7 -6
- package/dist/patterns/resilient-pipeline/index.js +1 -1
- package/dist/patterns/surface/index.cjs +11 -11
- package/dist/patterns/surface/index.d.cts +7 -6
- package/dist/patterns/surface/index.d.ts +7 -6
- package/dist/patterns/surface/index.js +1 -1
- package/dist/pipeline-graph-B85HUrWg.d.cts +120 -0
- package/dist/pipeline-graph-HOTU4UG0.d.ts +120 -0
- package/dist/{reactive-layout-DBJ3Vz-m.d.ts → reactive-layout-Btv0-efV.d.ts} +2 -2
- package/dist/{reactive-layout-Dk9AOQb_.d.cts → reactive-layout-D9zqqaqK.d.cts} +2 -2
- package/dist/reactive-log-ByBb8g6A.d.ts +188 -0
- package/dist/reactive-log-CgbNqksB.d.cts +188 -0
- package/dist/{reactive-map-LjwjcFaW.d.ts → reactive-map-CHyeCf4D.d.ts} +1 -1
- package/dist/{reactive-map-Cm89Hk0c.d.cts → reactive-map-DmgeADH8.d.cts} +1 -1
- package/dist/{resilience-RjDIHZNZ.d.ts → resilience-BWP2c7Af.d.cts} +27 -45
- package/dist/{resilience-N_VtLf7W.d.cts → resilience-Bys63Cpd.d.ts} +27 -45
- package/dist/resilience-OBU472D2.js +1 -0
- package/dist/{sugar-CQkn_rxB.d.ts → sugar-D13E2M_z.d.ts} +1 -1
- package/dist/{sugar-DVEYhR7a.d.cts → sugar-DgaGJcI6.d.cts} +1 -1
- package/dist/{topology-tree-BB6oJxMz.d.cts → topology-tree-C50l9ARE.d.cts} +1 -1
- package/dist/{topology-tree-CAFOG5S5.d.ts → topology-tree-CJsT24DP.d.ts} +1 -1
- package/dist/{types-Cp_4coR_.d.cts → types-BMSGPlpO.d.cts} +1 -1
- package/dist/{types-B2LfBvNc.d.ts → types-CidcBDuk.d.ts} +1 -1
- package/package.json +41 -1
- package/dist/chunk-2JO6LXFT.js +0 -7
- package/dist/chunk-2LZ6DL45.js +0 -1
- package/dist/chunk-3JXNEPCD.js +0 -2
- package/dist/chunk-3Y4BXFFR.js +0 -1
- package/dist/chunk-55T3K37W.js +0 -1
- package/dist/chunk-6HQ6HVTF.js +0 -1
- package/dist/chunk-7Q2WPFQ7.js +0 -1
- package/dist/chunk-FKRPIRE6.js +0 -1
- package/dist/chunk-HTBOCKVD.js +0 -1
- package/dist/chunk-I6VIH3VA.js +0 -1
- package/dist/chunk-IB64M7VP.js +0 -1
- package/dist/chunk-IJFSR4NU.js +0 -1
- package/dist/chunk-LOF5HSD3.js +0 -18
- package/dist/chunk-T2TB37TW.js +0 -1
- package/dist/chunk-T7EQPKOP.js +0 -1
- package/dist/chunk-Y63GWRHO.js +0 -5
- package/dist/chunk-YUBV7EEE.js +0 -1
- package/dist/index-C2Dey3L-.d.cts +0 -152
- package/dist/index-ClJUZAOr.d.cts +0 -101
- package/dist/index-Cq7Uqgu4.d.ts +0 -192
- package/dist/index-Dtpr2FIB.d.ts +0 -101
- package/dist/index-HvJ90_tX.d.ts +0 -152
- package/dist/index-wcfc7W-f.d.cts +0 -192
- package/dist/reactive-log-CWC7jO4J.d.cts +0 -190
- package/dist/reactive-log-CqaBg8nf.d.ts +0 -190
- package/dist/resilience-7UZHSSGC.js +0 -1
- /package/dist/{chunk-L3KUKDZC.js → chunk-O32GJOUJ.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-
|
|
2
|
-
import { a as CircuitBreakerOptions, e as CircuitBreaker } from './resilience-
|
|
1
|
+
import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-BMSGPlpO.cjs';
|
|
2
|
+
import { a as CircuitBreakerOptions, e as CircuitBreaker } from './resilience-BWP2c7Af.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
|
|
@@ -121,7 +121,7 @@ declare function createAdapter(opts: CreateAdapterOptions): LLMAdapter;
|
|
|
121
121
|
/**
|
|
122
122
|
* `cascadingLlmAdapter` — N-tier fallback over any mix of LLM adapters.
|
|
123
123
|
*
|
|
124
|
-
* Same structural pattern as `cascadingCache` and `Graph.
|
|
124
|
+
* Same structural pattern as `cascadingCache` and `Graph.attachSnapshotStorage`:
|
|
125
125
|
* ordered list, first-success wins, per-tier breaker optional, filter gates
|
|
126
126
|
* per request. Semantics:
|
|
127
127
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-
|
|
2
|
-
import { a as CircuitBreakerOptions, e as CircuitBreaker } from './resilience-
|
|
1
|
+
import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-CidcBDuk.js';
|
|
2
|
+
import { a as CircuitBreakerOptions, e as CircuitBreaker } from './resilience-Bys63Cpd.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
|
|
@@ -121,7 +121,7 @@ declare function createAdapter(opts: CreateAdapterOptions): LLMAdapter;
|
|
|
121
121
|
/**
|
|
122
122
|
* `cascadingLlmAdapter` — N-tier fallback over any mix of LLM adapters.
|
|
123
123
|
*
|
|
124
|
-
* Same structural pattern as `cascadingCache` and `Graph.
|
|
124
|
+
* Same structural pattern as `cascadingCache` and `Graph.attachSnapshotStorage`:
|
|
125
125
|
* ordered list, first-success wins, per-tier breaker optional, filter gates
|
|
126
126
|
* per request. Semantics:
|
|
127
127
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{e as ce}from"./chunk-CD4CB6S7.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{j as L}from"./chunk-5KPIYVCC.js";import{f as ae,h as ie}from"./chunk-MQZWA3DF.js";import{i as ne,j as U}from"./chunk-LYCLF26R.js";import{b,h as _,i as T,j as W}from"./chunk-CK2E7BTU.js";import{b as Oe,c as re,d as te,e as oe}from"./chunk-QYADASLV.js";var ke={};Oe(ke,{ACTOR_KEY:()=>F,COMMAND_HANDLERS:()=>A,CQRS_EVENT_HANDLERS:()=>S,CRON_HANDLERS:()=>D,CommandHandler:()=>me,EVENT_HANDLERS:()=>G,EventHandler:()=>ve,GRAPHREFLY_REQUEST_GRAPH:()=>R,GRAPHREFLY_ROOT_GRAPH:()=>v,GraphCron:()=>fe,GraphInterval:()=>he,GraphReflyEventExplorer:()=>x,GraphReflyGuard:()=>Re,GraphReflyGuardImpl:()=>I,GraphReflyModule:()=>Q,INTERVAL_HANDLERS:()=>O,InjectCqrsGraph:()=>de,InjectGraph:()=>ue,InjectNode:()=>pe,ObserveGateway:()=>B,OnGraphEvent:()=>le,QUERY_HANDLERS:()=>H,QueryHandler:()=>ye,SAGA_HANDLERS:()=>N,SagaHandler:()=>ge,fromHeader:()=>Ee,fromJwtPayload:()=>V,getActor:()=>we,getGraphToken:()=>m,getNodeToken:()=>y,observeSSE:()=>Me,observeSubscription:()=>Ce,toObservable:()=>se});import{Inject as j}from"@nestjs/common";var v=Symbol.for("graphrefly:root-graph");var R=Symbol.for("graphrefly:request-graph");function m(s){return Symbol.for(`graphrefly:graph:${s}`)}function y(s){return Symbol.for(`graphrefly:node:${s}`)}var G=new Map,O=new Map,D=new Map,A=new Map,S=new Map,H=new Map,N=new Map;function ue(s){return s==="request"?j(R):j(s?m(s):v)}function de(s){return j(m(s))}function pe(s){return j(y(s))}function le(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=G.get(o)??[];n.push({nodeName:s,methodKey:t}),G.set(o,n)})}}function he(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=O.get(o)??[];n.push({ms:s,methodKey:t}),O.set(o,n)})}}function fe(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=D.get(o)??[];n.push({expr:s,methodKey:t}),D.set(o,n)})}}function me(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=A.get(n)??[];a.push({cqrsName:s,commandName:e,methodKey:o}),A.set(n,a)})}}function ve(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=S.get(n)??[];a.push({cqrsName:s,eventName:e,methodKey:o}),S.set(n,a)})}}function ye(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=H.get(n)??[];a.push({cqrsName:s,projectionName:e,methodKey:o}),H.set(n,a)})}}function ge(s,e,r){return(t,o)=>{let n=o.name;o.addInitializer(function(){let a=this.constructor,c=N.get(a)??[];c.push({cqrsName:s,eventNames:r,sagaName:e,methodKey:n}),N.set(a,c)})}}var be=0,x=class{constructor(e,r){this.graph=e;this.moduleRef=r}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,r]of G){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireEventHandler(t,o)}}wireEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),a=this.observeNode(r.nodeName).subscribe(c=>{for(let l of c)l[0]===b&&o(l[1])});this.disposers.push(a)}wireIntervals(){for(let[e,r]of O){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireIntervalHandler(t,e,o)}}wireIntervalHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ae(t.ms,{period:t.ms,name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCrons(){for(let[e,r]of D){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCronHandler(t,e,o)}}wireCronHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ie(t.expr,{name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCqrsCommands(){for(let[e,r]of A){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsCommand(t,o)}}wireCqrsCommand(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.command(r.commandName,o)}wireCqrsEvents(){for(let[e,r]of S){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsEventHandler(t,o)}}wireCqrsEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;n.event(r.eventName);let c=n.resolve(r.eventName).cache,l=c&&c.length>0?c[c.length-1].seq:0,p=this.observeNodeOn(n,r.eventName).subscribe(u=>{for(let d of u)if(d[0]===b){let g=d[1];for(let i of g)i.seq>l&&(o(i),l=i.seq)}});this.disposers.push(p)}wireCqrsQueries(){for(let[e,r]of H){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsQuery(t,o)}}wireCqrsQuery(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;let c=this.observeNodeOn(n,r.projectionName).subscribe(l=>{for(let f of l)f[0]===b&&o(f[1])});this.disposers.push(c)}wireCqrsSagas(){for(let[e,r]of N){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsSaga(t,o)}}wireCqrsSaga(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.saga(r.sagaName,r.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,r){return e.observe(r)}resolveCqrsGraph(e){try{return this.moduleRef.get(m(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};function Me(s,e,r){let{actor:t,serialize:o=De,keepAliveMs:n,signal:a}=r??{},c=new TextEncoder,l,f=r?.highWaterMark!=null,p,u,d=[],g=!1;return new ReadableStream({start(i){let h,w=()=>{},M=()=>{if(!g){g=!0,h!==void 0&&clearInterval(h),a?.removeEventListener("abort",K),w(),p?.dispose(),u?.(),u=void 0;for(let k of d)i.enqueue(k.frame);d.length=0,i.close()}};l=M;let K=()=>M(),ee=s.observe(e,{actor:t});f&&(p=P(k=>ee.up(k),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)})),w=ee.subscribe(k=>{for(let $ of k){if(g)return;let q=$[0];if(q===b){let C=c.encode(Y("data",o($[1])));f?(d.push({frame:C,counted:!0}),p.onEnqueue(),u?.(),u=void 0):i.enqueue(C)}else if(q===W){let C=c.encode(Y("error",o($[1])));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C),M();return}else if(q===T||q===_){if(q===T){let C=c.encode(Y("complete"));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C)}M();return}}}),n!==void 0&&n>0&&(h=setInterval(()=>{g||(f?(d.push({frame:c.encode(`: keepalive
|
|
2
2
|
|
|
3
3
|
`),counted:!1}),u?.(),u=void 0):i.enqueue(c.encode(`: keepalive
|
|
4
4
|
|
|
@@ -6,4 +6,4 @@ import{c as ce}from"./chunk-YUBV7EEE.js";import{a as se,b as P}from"./chunk-5QDB
|
|
|
6
6
|
`;if(e!==void 0)for(let t of e.split(`
|
|
7
7
|
`))r+=`data: ${t}
|
|
8
8
|
`;return r+=`
|
|
9
|
-
`,r}function Ae(s){return JSON.parse(s)}function Se(s,e){try{s.send(JSON.stringify(e))}catch{}}function z(s,e){try{s(e)}catch{}}var F="graphReflyActor";function V(s){return e=>{let t=e.switchToHttp().getRequest()?.user;if(t!=null)return s?s(t):t}}function Ee(s="x-graphrefly-actor"){return e=>{let t=e.switchToHttp().getRequest()?.headers?.[s.toLowerCase()];if(!(typeof t!="string"||t.length===0))try{return JSON.parse(t)}catch{return}}}function we(s){let e=s?.[F];return e!=null?U(e):ne}var I=class{constructor(e){this.extractor=e}canActivate(e){let r=U(this.extractor(e)),t=e.switchToHttp().getRequest();return t!=null&&(t[F]=r),!0}};function Re(s){return new I(s??V())}import{Module as He,Scope as xe}from"@nestjs/common";import{ModuleRef as Ne}from"@nestjs/core";var X=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},Z=class{graph=new L("request");onModuleDestroy(){this.graph.destroy()}},Ge,J;Ge=[He({})];var E=class E{static forRoot(e){let r=e??{},t=r.name??"root",o=[{provide:v,useFactory:()=>{let n=new L(t);return r.build&&r.build(n),r.snapshot&&n.restore(r.snapshot),n}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:n=>new X(n),inject:[v]},{provide:x,useFactory:(n,a)=>new x(n,a),inject:[v,Ne]}];if(r.nodes)for(let n of r.nodes)o.push({provide:y(n),useFactory:a=>a.resolve(n),inject:[v]});return r.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new Z,scope:xe.REQUEST},{provide:R,useFactory:n=>n.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:xe.REQUEST}),{module:E,global:!0,providers:o,exports:[v,...(r.nodes??[]).map(y),...r.requestScope?[R]:[]]}}static forFeature(e){let r=[{provide:m(e.name),useFactory:t=>{let o=new L(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),t.mount(e.name,o),o},inject:[v]}];if(e.nodes)for(let t of e.nodes)r.push({provide:y(`${e.name}::${t}`),useFactory:o=>o.resolve(t),inject:[m(e.name)]});return{module:E,providers:r,exports:[m(e.name),...(e.nodes??[]).map(t=>y(`${e.name}::${t}`))]}}static forCqrs(e){let r=[{provide:m(e.name),useFactory:t=>{let o=ce(e.name,e.cqrs);return e.
|
|
9
|
+
`,r}function Ae(s){return JSON.parse(s)}function Se(s,e){try{s.send(JSON.stringify(e))}catch{}}function z(s,e){try{s(e)}catch{}}var F="graphReflyActor";function V(s){return e=>{let t=e.switchToHttp().getRequest()?.user;if(t!=null)return s?s(t):t}}function Ee(s="x-graphrefly-actor"){return e=>{let t=e.switchToHttp().getRequest()?.headers?.[s.toLowerCase()];if(!(typeof t!="string"||t.length===0))try{return JSON.parse(t)}catch{return}}}function we(s){let e=s?.[F];return e!=null?U(e):ne}var I=class{constructor(e){this.extractor=e}canActivate(e){let r=U(this.extractor(e)),t=e.switchToHttp().getRequest();return t!=null&&(t[F]=r),!0}};function Re(s){return new I(s??V())}import{Module as He,Scope as xe}from"@nestjs/common";import{ModuleRef as Ne}from"@nestjs/core";var X=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},Z=class{graph=new L("request");onModuleDestroy(){this.graph.destroy()}},Ge,J;Ge=[He({})];var E=class E{static forRoot(e){let r=e??{},t=r.name??"root",o=[{provide:v,useFactory:()=>{let n=new L(t);return r.build&&r.build(n),r.snapshot&&n.restore(r.snapshot),n}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:n=>new X(n),inject:[v]},{provide:x,useFactory:(n,a)=>new x(n,a),inject:[v,Ne]}];if(r.nodes)for(let n of r.nodes)o.push({provide:y(n),useFactory:a=>a.resolve(n),inject:[v]});return r.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new Z,scope:xe.REQUEST},{provide:R,useFactory:n=>n.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:xe.REQUEST}),{module:E,global:!0,providers:o,exports:[v,...(r.nodes??[]).map(y),...r.requestScope?[R]:[]]}}static forFeature(e){let r=[{provide:m(e.name),useFactory:t=>{let o=new L(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),t.mount(e.name,o),o},inject:[v]}];if(e.nodes)for(let t of e.nodes)r.push({provide:y(`${e.name}::${t}`),useFactory:o=>o.resolve(t),inject:[m(e.name)]});return{module:E,providers:r,exports:[m(e.name),...(e.nodes??[]).map(t=>y(`${e.name}::${t}`))]}}static forCqrs(e){let r=[{provide:m(e.name),useFactory:t=>{let o=ce(e.name,e.cqrs);return e.eventStorage&&o.attachEventStorage(e.eventStorage),e.build&&e.build(o),t.mount(e.name,o),o},inject:[v]}];if(e.nodes)for(let t of e.nodes)r.push({provide:y(`${e.name}::${t}`),useFactory:o=>o.resolve(t),inject:[m(e.name)]});return{module:E,providers:r,exports:[m(e.name),...(e.nodes??[]).map(t=>y(`${e.name}::${t}`))]}}};J=re(null),E=oe(J,0,"GraphReflyModule",Ge,E),te(J,1,E);var Q=E;export{v as a,R as b,m as c,y as d,G as e,O as f,D as g,A as h,S as i,H as j,N as k,ue as l,de as m,pe as n,le as o,he as p,fe as q,me as r,ve as s,ye as t,ge as u,x as v,Me as w,Ce as x,B as y,F as z,V as A,Ee as B,we as C,I as D,Re as E,Q as F,ke as G};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as L,b as _}from"./chunk-CUQFO6MT.js";import{c as z}from"./chunk-O32GJOUJ.js";import{j as F}from"./chunk-5KPIYVCC.js";import{D as j,E as G,G as D,m as E,p as B}from"./chunk-LYCLF26R.js";import{b as P,d as S,i as I,j as K}from"./chunk-CK2E7BTU.js";import{b as te}from"./chunk-QYADASLV.js";var ie={};te(ie,{PipelineGraph:()=>x,decisionKeyOf:()=>$,pipelineGraph:()=>q});function N(y,t){return z("orchestration",y,t)}var $=y=>y.action,x=class extends F{constructor(t,s){super(t,s)}task(t,s,e={}){let a=(e.deps??[]).map(c=>this._resolveStep(c)),p=D(a,s,{name:t,describeKind:"derived",meta:N("task",e.meta)});return this.add(p,{name:t}),p}classify(t,s,e,a={}){let p=this._resolveStep(s),c=D([p],([d])=>{try{return{tag:e(d),value:d}}catch(f){return{tag:"error",value:d,error:f}}},{name:t,describeKind:"derived",meta:N("classify",a.meta)});return this.add(c,{name:t}),c}combine(t,s,e={}){let a=Object.keys(s),p=a.map(d=>this._resolveStep(s[d])),c=D(p,d=>{let f={};for(let i=0;i<a.length;i++)f[a[i]]=d[i];return f},{name:t,describeKind:"derived",meta:N("combine",e.meta)});return this.add(c,{name:t}),c}gate(t,s,e={}){let a=e.maxPending??1e3;if(a<1&&a!==Number.POSITIVE_INFINITY)throw new RangeError("gate: maxPending must be >= 1");let p=e.startOpen??!1;typeof s!="string"&&this.nameOf(s)===void 0&&this.add(s,{name:`${t}/source`});let c=this._resolveStep(s),d=new F(`${t}_state`),f=G([],{name:"pending",equals:()=>!1}),i=G(p,{name:"isOpen"}),R=D([f],([n])=>n.length,{name:"count"}),h=G(0,{name:"droppedCount"}),u=L({name:"decisions",retainedLimit:1024,graph:d});d.add(f,{name:"pending"}),d.add(i,{name:"isOpen"}),d.add(R,{name:"count"}),d.add(h,{name:"droppedCount"}),this.mount(`${t}_state`,d);let l=[],v=!1,k=!1,O=p,W=i.subscribe(n=>{for(let o of n)o[0]===P&&(O=o[1])});this.addDisposer(W);function A(){f.emit([...l])}function C(n,o,r){u.append({action:n,t_ns:B(),...o!==void 0?{items:o,count:o.length}:{},...r!==void 0?{unflushed:r}:{},...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}function M(n){if(l.push(n),l.length>a){let o=l.shift();h.emit(h.cache+1),C("drop",[o])}A()}function w(n){let o=l.splice(0,n);return A(),o}let b=j([c],(n,o,r)=>{let T=r.terminalDeps[0];if(T!==void 0){v=!0;let g=l.length;l=[],A(),C("teardown",void 0,g),o.down(T===!0?[[I]]:[[K,T]]);return}let m=n[0];if(m==null||m.length===0){o.down([[S]]);return}for(let g of m)O?o.emit(g):(M(g),o.down([[S]]))},{name:t,describeKind:"derived",meta:N("gate",e.meta)});if(this.add(b,{name:t}),e.approver!=null){e.approver.cache&&(i.emit(!0),O=!0,e.onceOnly&&(k=!0));let o=e.approver.subscribe(r=>{for(let T of r){if(T[0]!==P)continue;let m=!!T[1];if(m&&!O){if(e.onceOnly){if(k)continue;k=!0}E(()=>{i.emit(!0);let g=w(l.length);C("open",g);for(let oe of g){if(v)break;b.emit(oe)}})}else if(!m&&O){if(e.onceOnly&&k)continue;E(()=>{i.emit(!1),C("close")})}}});this.addDisposer(o)}let V=n=>{if(v)throw new Error(`gate: ${n}() called after gate was torn down`)},U=(n=1)=>{V("approve");let o=w(n);for(let r of o){if(v)break;b.emit(r)}},Y=(n=1)=>{V("reject"),w(n)},H=(n,o=1)=>{V("modify");let r=[...l],T=w(o);for(let m=0;m<T.length&&!v;m++)b.emit(n(T[m],m,r))},J=()=>{V("open"),i.emit(!0);let n=w(l.length);for(let o of n){if(v)break;b.emit(o)}},Q=()=>{V("close"),!(e.onceOnly&&k)&&i.emit(!1)},X=_(U,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"approve",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),Z=_(Y,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"reject",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ee=_(H,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"modify",count:n[1]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ne=_(J,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"open",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),re=_(Q,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"close",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})});return this.addDisposer(R.subscribe(()=>{})),{node:b,pending:f,count:R,isOpen:i,droppedCount:h,decisions:u,audit:u,approve:X,reject:Z,modify:ee,open:ne,close:re}}approval(t,s,e,a={}){return this.gate(t,s,{...a,approver:e,maxPending:1})}catch(t,s,e,a={}){let p=this._resolveStep(s),c=a.on??"error",d=j([p],(f,i,R)=>{let h=R.terminalDeps[0];if(h!==void 0){let l=h===!0?{kind:"complete"}:{kind:"error",error:h};if(c==="terminal"||c===l.kind){i.emit(e(l,i));return}i.down(l.kind==="complete"?[[I]]:[[K,l.error]]);return}let u=f[0];if(u==null||u.length===0){i.down([[S]]);return}for(let l of u)i.emit(l)},{name:t,describeKind:"derived",completeWhenDepsComplete:a.completeWhenDepsComplete??!(c==="complete"||c==="terminal"),errorWhenDepsError:!(c==="error"||c==="terminal"),meta:N("catch",a.meta)});return this.add(d,{name:t}),d}_resolveStep(t){if(typeof t=="string")return this.resolve(t);if(this.nameOf(t)===void 0)throw new Error(`PipelineGraph "${this.name}": Node dep is not registered. Pass a string path or call graph.add(node) first.`);return t}};function q(y,t){return new x(y,t)}export{$ as a,x as b,q as c,ie as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as L,c as D}from"./chunk-CUQFO6MT.js";import{c as Q}from"./chunk-O32GJOUJ.js";import{j as F}from"./chunk-5KPIYVCC.js";import{b as G}from"./chunk-KGKJCHEK.js";import{b as I}from"./chunk-TZQPPQEQ.js";import{b as M}from"./chunk-RLMYS3XZ.js";import{C as v,m as C}from"./chunk-MQZWA3DF.js";import{D as x,G as P,m as _,p as m}from"./chunk-LYCLF26R.js";import{b as N,j as A}from"./chunk-CK2E7BTU.js";import{b as V}from"./chunk-QYADASLV.js";var ee={};V(ee,{JobFlowGraph:()=>w,JobQueueGraph:()=>y,jobEventKeyOf:()=>Y,jobFlow:()=>Z,jobQueue:()=>z});var X=256,H=1024;function W(i,e){if(!Number.isFinite(i)||!Number.isInteger(i)||i<0)throw new Error(`${e} must be a non-negative integer`);return i}function T(i,e){return Q("job_queue",i,e)}var Y=i=>i.action,y=class extends F{_pending;_jobs;_seqCursor;pending;jobs;depth;events;audit;constructor(e,t={}){super(e,t.graph),this._pending=G([],{name:"pending"}),this._jobs=I({name:"jobs"}),this.pending=this._pending.items,this.jobs=this._jobs.entries,this.add(this.pending,{name:"pending"}),this.add(this.jobs,{name:"jobs"}),this.depth=P([this.pending],([o])=>o.length,{name:"depth",describeKind:"derived",meta:T("queue_depth"),initial:0}),this.add(this.depth,{name:"depth"}),this.addDisposer(v(this.depth)),this.events=L({name:"events",retainedLimit:1024,graph:this}),this.audit=this.events,this._seqCursor=D(this,"seq",0)}_bumpSeq(){let t=(this._seqCursor.cache??0)+1;return this._seqCursor.emit(t),t}attachEventStorage(e){return this.events.attachStorage(e)}enqueue(e,t={}){let o=this._bumpSeq(),n=t.id??`${this.name}-${o}`;if(this._jobs.get(n)!==void 0)throw new Error(`jobQueue("${this.name}"): duplicate job id "${n}"`);let p={id:n,payload:e,attempts:0,metadata:Object.freeze({...t.metadata??{}}),state:"queued"};return this._jobs.set(n,p),this._pending.append(n),this.events.append({action:"enqueue",id:n,payload:e,t_ns:m(),seq:o}),n}claim(e=1){let t=W(e,"job queue claim limit");if(t===0)return[];let o=[];for(;o.length<t&&this.pending.cache.length!==0;){let p=this._pending.pop(0),h=this._jobs.get(p);if(!h||h.state!=="queued")continue;let l={...h,state:"inflight",attempts:h.attempts+1};this._jobs.set(p,l),o.push(l),this.events.append({action:"claim",id:p,attempts:l.attempts,t_ns:m(),seq:this._bumpSeq()})}return o}ack(e){let t=this._jobs.get(e);return!t||t.state!=="inflight"?!1:(this._jobs.delete(e),this.events.append({action:"ack",id:e,attempts:t.attempts,t_ns:m(),seq:this._bumpSeq()}),!0)}nack(e,t={}){let o=this._jobs.get(e);return!o||o.state!=="inflight"?!1:t.requeue??!0?(this._jobs.set(e,{...o,state:"queued"}),this._pending.append(e),this.events.append({action:"nack",id:e,attempts:o.attempts,t_ns:m(),seq:this._bumpSeq()}),!0):(this._jobs.delete(e),this.events.append({action:"nack",id:e,attempts:o.attempts,t_ns:m(),seq:this._bumpSeq()}),!0)}removeById(e){let t=this._jobs.get(e);if(!t)return!1;if(t.state==="queued"){let n=this.pending.cache.indexOf(e);n>=0&&this._pending.pop(n)}return this._jobs.delete(e),this.events.append({action:"remove",id:e,attempts:t.attempts,t_ns:m(),seq:this._bumpSeq()}),!0}consumeFrom(e,t){return e.subscribe(o=>{for(let n of o){if(n[0]!==N)continue;let p=n[1];this.enqueue(p,t?{metadata:t.metadata}:void 0)}})}},w=class extends F{_stageNames;_stageWorkFns;_queues=new Map;_completed;completed;completedCount;constructor(e,t={}){super(e,t.graph);let o=t.stages??["incoming","processing","done"],n=[],p=new Map;for(let s of o){let r=typeof s=="string"?s.trim():s.name.trim();typeof s!="string"&&s.work&&p.set(r,s.work),n.push(r)}if(n.length<2)throw new Error(`jobFlow("${e}"): requires at least 2 stages`);if(new Set(n).size!==n.length)throw new Error(`jobFlow("${e}"): stage names must be unique`);this._stageNames=Object.freeze([...n]),this._stageWorkFns=p;for(let s of this._stageNames){let r=z(`${e}-${s}`);this._queues.set(s,r),this.mount(s,r)}this._completed=M([],{name:"completed",maxSize:H}),this.completed=this._completed.entries,this.add(this.completed,{name:"completed"}),this.completedCount=P([this.completed],([s])=>s.length,{name:"completedCount",describeKind:"derived",meta:T("job_flow_completed_count"),initial:0}),this.add(this.completedCount,{name:"completedCount"}),this.addDisposer(v(this.completedCount));let l=Math.max(1,W(t.maxPerPump??X,"job flow maxPerPump"));for(let s=0;s<this._stageNames.length;s+=1){let r=this._stageNames[s],d=this.queue(r),q=s+1<this._stageNames.length?this.queue(this._stageNames[s+1]):null,R=this._stageWorkFns.get(r),S=q===null;if(R){let g=x([d.pending],()=>{let c=0;for(;c<l;){let b=d.claim(1);if(b.length===0)break;let a=b[0];if(!a)break;let j=[...a.metadata.job_flow_path??[],r],f;try{f=R(a)}catch{d.nack(a.id,{requeue:!1}),c+=1;continue}let k=C(f),E=!1,u;u=k.subscribe(K=>{if(!E){for(let J of K)if(J[0]===N){E=!0,u?u():Promise.resolve().then(()=>u?.());let O=J[1],$={...a.metadata,job_flow_path:j};if(S){let U={...a,payload:O,metadata:Object.freeze($)};_(()=>{d.ack(a.id),this._completed.append(U)})}else _(()=>{d.ack(a.id),q.enqueue(O,{metadata:$})});return}else if(J[0]===A){E=!0,u?u():Promise.resolve().then(()=>u?.()),d.nack(a.id,{requeue:!1});return}}}),c+=1}},{name:`pump_${r}`,describeKind:"effect",meta:T("job_flow_pump",{stage:r,has_work:!0})});this.add(g,{name:`pump_${r}`}),this.addDisposer(v(g))}else{let g=x([d.pending],()=>{let c=0;for(;c<l;){let b=d.claim(1);if(b.length===0)break;let a=b[0];if(!a)break;let j=[...a.metadata.job_flow_path??[],r],f={...a.metadata,job_flow_path:j};if(S){let k={...a,metadata:Object.freeze(f)};_(()=>{d.ack(a.id),this._completed.append(k)})}else _(()=>{d.ack(a.id),q.enqueue(a.payload,{metadata:f})});c+=1}},{name:`pump_${r}`,describeKind:"effect",meta:T("job_flow_pump",{stage:r,has_work:!1})});this.add(g,{name:`pump_${r}`}),this.addDisposer(v(g))}}}stages(){return this._stageNames}queue(e){let t=this._queues.get(e);if(!t)throw new Error(`jobFlow("${this.name}"): unknown stage "${e}"`);return t}enqueue(e,t={}){return this.queue(this._stageNames[0]).enqueue(e,t)}retainedCompleted(){return this.completed.cache}};function z(i,e){return new y(i,e)}function Z(i,e){return new w(i,e)}export{Y as a,y as b,w as c,z as d,Z as e,ee as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as D,c as j,d as V,e as $}from"./chunk-Q7EUZ6NN.js";import{a as v}from"./chunk-ESMPEKEV.js";import{i as S}from"./chunk-D5RFJOZ2.js";import{n as T}from"./chunk-JJTF75VS.js";import{m as R,x as N}from"./chunk-MQZWA3DF.js";import{G as K,o as b,p as L}from"./chunk-LYCLF26R.js";import{j as O}from"./chunk-CK2E7BTU.js";function w(){let e=new Error("aborted");return e.name="AbortError",e}function W(e,r){return e<=0?Promise.resolve():r?.aborted?Promise.reject(w()):new Promise((t,s)=>{let p=new v,u,y=()=>{p.cancel(),r&&u&&r.removeEventListener("abort",u)};p.start(e,()=>{y(),t()}),r&&(u=()=>{y(),s(w())},r.addEventListener("abort",u,{once:!0}))})}function U(e={}){let r=e.provider??"dry-run",t=e.model??"dry-run-v1",s=e.latencyMs??0,p=Math.max(1,e.streamChunkSize??16),u=e.respond??(d=>{let o=[...d].reverse().find(n=>n.role==="user");return o?`echo: ${o.content}`:"dry-run: no user message"}),y=e.usage??((d,o)=>{let n=d.reduce((a,l)=>a+l.content.length,0);return{input:{regular:Math.ceil(n/4)},output:{regular:Math.ceil(o.length/4)}}});return{provider:r,model:t,async invoke(d,o){if(await W(s,o?.signal),o?.signal?.aborted)throw w();let n=u(d,o),a=y(d,n);return{content:n,usage:a,finishReason:"stop",model:o?.model??t,provider:r,tier:o?.tier,metadata:{dryRun:!0}}},async*stream(d,o){let n=u(d,o),a=y(d,n),l=Math.ceil(n.length/p)||1,i=s>0?s/l:0;for(let c=0;c<n.length;c+=p){if(o?.signal?.aborted)throw w();await W(i,o?.signal),yield{type:"token",delta:n.slice(c,c+p)}}yield{type:"usage",usage:a},yield{type:"finish",reason:"stop"}}}}function _(e){let{storage:r,mode:t="read-write",keyFn:s,keyPrefix:p="llm-replay"}=e,y=V({storage:r,keyPrefix:p,mode:t==="read-strict"?"read":t,keyContext:({messages:o,opts:n})=>{let{signal:a,keyContext:l,...i}=n??{};return{messages:o,opts:i}}});async function d(o,n){if(s){if(s.length<=1){let l={messages:o,opts:n,context:n?.keyContext},i=await s(l);return`${p}:${i}`}let a=await s(o,n);return`${p}:${a}`}return y.keyFor({messages:o,opts:n})}return{keyFor:d,async lookup(o,n){if(t!=="write"){if(s){let a=await d(o,n),l=await r.load(a);return l===void 0?void 0:l}return y.lookup({messages:o,opts:n})}},async store(o,n,a){if(t!=="read"){if(s){let l=await d(o,n);await r.save(l,a);return}await y.store({messages:o,opts:n},a)}},async forget(o,n){if(!(t==="read"||t==="write")&&r.delete){if(s){let a=await d(o,n);await r.delete(a);return}await y.forget({messages:o,opts:n})}}}}function z(e,r,t){return{provider:t?.provider??e.provider,model:t?.model??e.model,capabilities:t?.capabilities??e.capabilities?.bind(e),invoke:r.invoke,stream:r.stream}}function ce(e,r){let{onResp:t,onError:s,name:p}=r;if(e!=null&&typeof e.then=="function"){let n=e;return s?n.then(t).catch(a=>{throw s(a),a}):n.then(t)}if(e!=null&&typeof e=="object"&&"content"in e)return t(e);let u=R(e);if(s){let n=!1;u.subscribe(a=>{for(let l of a){if(n)return;l[0]===O&&(n=!0,s(l[1]))}})}let y,d=!1,o=T(u,n=>{y=t(n),d=!0});return K([o],([n])=>n==null?null:d?y:t(n),{name:p??"adapt/invokeTap"})}function pe(e){let r=e.endNs??b();return{timestamp:r,wallClock:e.startWallClockNs??L(),provider:e.provider,model:e.model,tier:e.tier,usage:e.usage,latencyMs:Math.max(0,(r-e.startNs)/1e6),method:e.method,...e.error?{error:e.error}:{}}}function ye(){return{input:{regular:0},output:{regular:0}}}var G=Symbol.for("graphrefly.adapter.middlewareLayers");function J(e,r,t){let p=[...t?Q(t):[],r];return Object.defineProperty(e,G,{value:Object.freeze(p),enumerable:!1,writable:!1,configurable:!1}),e}function Q(e){let r=e[G];return Array.isArray(r)?r:[]}var M=class extends Error{constructor(t,s){super(`withReplayCache: no cached response for ${s} (key=${t}, mode=read-strict)`);this.key=t;this.method=s}name="ReplayCacheMissError"};function q(e,r){let t=r.mode??"read-write",s=r.cacheStreaming??!1,p=r.captureStreamCadence??!1,u=r.replaySpeed??1,y=r.keyPrefix??"llm-replay",d=t==="read"||t==="read-strict",o=_({storage:r.storage,mode:t==="write-only"?"write":t,keyFn:r.keyFn,keyPrefix:y}),n=i=>i<=0?Promise.resolve():new Promise(c=>{new v().start(i,()=>c())}),a=$(async({messages:i,invokeOpts:c})=>await N(R(e.invoke(i,c))),{keyFn:({_precomputedKey:i})=>i}),l=z(e,{async invoke(i,c){let C=await o.keyFor(i,c),f=await o.lookup(i,c);if(f?.response){let k=f.response;return{...k,metadata:{...k.metadata??{},replayCache:"hit"}}}if(t==="read-strict")throw new M(C,"invoke");let h=await a({messages:i,invokeOpts:c,_precomputedKey:C});return d||await o.store(i,c,{response:h,storedAtNs:L()}),h},async*stream(i,c){if(!s){for await(let m of e.stream(i,c))yield m;return}let C=await o.keyFor(i,c),f=await o.lookup(i,c);if(f){let m=f.response;if(f.streamChunks&&f.streamCadenceMs)for(let g=0;g<f.streamChunks.length;g++){let A=f.streamCadenceMs[g]??0,E=u>0?A/u:0;E>0&&await n(E),yield{type:"token",delta:f.streamChunks[g]?.delta??""}}else m.content&&(yield{type:"token",delta:m.content});m.usage&&(yield{type:"usage",usage:m.usage}),yield{type:"finish",reason:m.finishReason??"stop"};return}if(t==="read-strict")throw new M(C,"stream");let h="",k,P,F=[],I=[],x;for await(let m of e.stream(i,c)){if(m.type==="token"&&(h+=m.delta,p)){let g=b(),A=x===void 0?0:(g-x)/1e6;I.push(A),x=g,F.push({delta:m.delta})}m.type==="usage"&&(k=m.usage),m.type==="finish"&&(P=m.reason),yield m}if((h||k)&&!d){let g={response:{content:h,usage:k??{input:{regular:0},output:{regular:0}},finishReason:P,model:e.model??c?.model??"",provider:e.provider},storedAtNs:L(),...p?{streamChunks:F,streamCadenceMs:I}:{}};await o.store(i,c,g)}}});return J(l,"withReplayCache",e),l}var B=j;var Ae=M;function H(e,r){return{content:"[fallback: no cached response available for this request]",usage:{input:{regular:0},output:{regular:0}},finishReason:"stop",model:r,provider:e,metadata:{degraded:!0,reason:"no-fixture"}}}function Y(e,r,t){return typeof e=="string"?{content:e,usage:{input:{regular:0},output:{regular:0}},finishReason:"stop",model:t,provider:r,metadata:{degraded:!0,reason:"respond"}}:e}async function X(e,r){if("key"in e)return e.key;let t=B({messages:e.messages,opts:e.invokeOpts??{}}),s=await D(t);return`${r}:${s}`}function Z(e){let r={response:e.response,storedAtNs:L()};if("key"in e&&e.stream){let t=e.stream.chunks.filter(s=>s.type==="token");return{...r,streamChunks:t.map(s=>({delta:s.delta})),streamCadenceMs:e.stream.delaysMs??t.map(()=>0)}}return r}function ee(e,r){let t=[];if(e.fixtures!=null&&t.push("fixtures"),e.fixturesStorage!=null&&t.push("fixturesStorage"),t.length>1)throw new TypeError(`fallbackAdapter: \`fixtures\` and \`fixturesStorage\` are mutually exclusive; got both ${t.join(" and ")}. Pick one source. For filesystem directories use the node subpath's \`fallbackAdapter\`.`);if(e.fixtures){let s=S(),p=e.fixtures,u=(async()=>{for(let y of p){let d=await X(y,r);await s.save(d,Z(y))}})();return u.catch(()=>{}),{tier:s,seedReady:u}}return e.fixturesStorage?{tier:e.fixturesStorage,seedReady:Promise.resolve()}:{tier:void 0,seedReady:Promise.resolve()}}function Se(e={}){let r=e.provider??"fallback",t=e.model??"fallback",s=e.onMiss??"respond",p=e.keyPrefix??"fallback",u=e.record?e.record.adapter:s==="throw"?U({provider:r,model:t,respond:()=>"[unreachable: read-strict mode throws on miss]"}):{provider:r,model:t,async invoke(a,l){let i=e.respond?e.respond(a,l):H(r,t);return Y(i,r,t)},async*stream(a,l){let i=e.respond?e.respond(a,l):H(r,t),c=Y(i,r,t);yield{type:"token",delta:c.content},c.usage&&(yield{type:"usage",usage:c.usage}),yield{type:"finish",reason:c.finishReason??"stop"}}},y,d=Promise.resolve();if(e.record){if(!e.record.storage)throw new TypeError("fallbackAdapter: `record.storage` is required in record mode. For filesystem `record.dir` convenience, use the node subpath's `fallbackAdapter`.");y=e.record.storage}else{let a=ee(e,p);y=a.tier??S(),d=a.seedReady}let o=e.record?"read-write":s==="throw"?"read-strict":"read",n=q(u,{storage:y,mode:o,keyPrefix:p,cacheStreaming:!0,captureStreamCadence:!0,replaySpeed:e.replaySpeed,...e.keyFn?{keyFn:e.keyFn}:{}});return{provider:r,model:t,capabilities:n.capabilities?.bind(n),async invoke(a,l){return await d,n.invoke(a,l)},async*stream(a,l){await d;for await(let i of n.stream(a,l))yield i}}}export{U as a,z as b,ce as c,pe as d,ye as e,J as f,M as g,q as h,B as i,Ae as j,Se as k};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{a as Se}from"./chunk-SGS4OJGS.js";import{a as Le}from"./chunk-ESMPEKEV.js";import{a as re,b as _e}from"./chunk-533RQFF6.js";import{C as Ee}from"./chunk-MQZWA3DF.js";import{A as we,C as L,E as ne,F as Me,G as Oe,e as $e,f as Te,i as Y,k as Ne,l as xe,m as Ae,o as K,p as Pe,s as W}from"./chunk-LYCLF26R.js";import{b as Q,c as me,d as be,e as Z,f as ye,g as ve,h as z,i as ee,j as te}from"./chunk-CK2E7BTU.js";function Ie(e,t,r,n={}){let o=t in e.nodes,s=r in e.nodes;if(!o)return se(t,r,"no-such-from");if(!s)return se(t,r,"no-such-to");let i=n.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(t===r){if(n.findCycle===!0){let u=lt(e,t,n);if(u!=null)return u}let l=oe(t,e.nodes[t],0,n);return ie(t,r,[l])}if(i===0)return se(t,r,"no-path");let a=je(e,t,r,i);return a.found?ie(t,r,Be(e,a.pathOrder,n)):se(t,r,a.truncated?"max-depth-exceeded":"no-path")}function je(e,t,r,n){let o=new Map,s=[{path:r,depth:0}],i=new Set([r]),a=0,l=!1;for(;a<s.length;){let h=s[a++];if(h.path===t)break;if(n!=null&&h.depth>=n){let g=e.nodes[h.path];g?.deps&&g.deps.length>0&&(l=!0);continue}let p=e.nodes[h.path];if(p==null)continue;let f=p.deps??[],c=new Map;for(let g=0;g<f.length;g++){let b=f[g];if(!b)continue;let v=c.get(b);v==null&&(v=[],c.set(b,v)),v.push(g)}for(let[g,b]of c)i.has(g)||(i.add(g),o.set(g,{from:h.path,depIndices:b}),s.push({path:g,depth:h.depth+1}))}if(!o.has(t))return{found:!1,pathOrder:[],truncated:l};let u=[{path:t}],d=t;for(;d!==r;){let h=o.get(d);if(h==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=h.depIndices,u.push({path:h.from}),d=h.from}return{found:!0,pathOrder:u,truncated:!1}}function lt(e,t,r){let n=e.nodes[t];if(n==null)return null;let o=n.deps??[],s=[];for(let a=0;a<o.length;a++)o[a]===t&&s.push(a);if(s.length>0){let a=oe(t,n,0,r);a.dep_index=s[0];let l=oe(t,n,1,r);return ie(t,t,[a,l])}let i=null;for(let a=0;a<o.length;a++){let l=o[a];if(!l||l===t)continue;let u=je(e,l,t,r.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:t,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:ie(t,t,Be(e,i.pathOrder,r))}function Be(e,t,r){return t.map((n,o)=>{let s=e.nodes[n.path],i=oe(n.path,s,o,r);return n.depIndices!=null&&n.depIndices.length>0&&(i.dep_index=n.depIndices[0],n.depIndices.length>1&&(i.dep_indices=[...n.depIndices])),i})}function oe(e,t,r,n){let o={path:e,type:t.type,hop:r};t.status!==void 0&&(o.status=t.status),"value"in t&&(o.value=t.value),t.v!=null&&(o.v=t.v);let s=n.annotations?.get(e)??t.annotation;s!=null&&(o.annotation=s);let i=n.lastMutations?.get(e)??t.lastMutation;return i!=null&&(o.lastMutation=i),o}function ie(e,t,r){return Fe(e,t,!0,"ok",r)}function se(e,t,r){return Fe(e,t,!1,r,[])}function Fe(e,t,r,n,o){let s=ct(e,t,r,n,o);return{from:e,to:t,found:r,reason:n,steps:o,text:s,toJSON(){return{from:e,to:t,found:r,reason:n,steps:o}}}}function ct(e,t,r,n,o){if(!r)switch(n){case"no-such-from":return`explainPath: no node named "${e}"`;case"no-such-to":return`explainPath: no node named "${t}"`;case"max-depth-exceeded":return`explainPath: no path from "${e}" to "${t}" within maxDepth`;default:return`explainPath: no path from "${e}" to "${t}"`}let s=[`Causal path: ${e} \u2192 ${t} (${o.length} step(s))`];for(let i of o){let l=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(s.push(l),"value"in i&&s.push(` value: ${dt(i.value)}`),i.annotation!=null&&s.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;s.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return s.join(`
|
|
2
|
+
`)}function dt(e){if(e===void 0)return"<sentinel>";if(e===null)return"null";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);try{let t=JSON.stringify(e);return t.length>80?`${t.slice(0,77)}...`:t}catch{return String(e)}}var A={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},ft=Symbol.for("sizeof");function He(e){let t=new WeakSet,r=new WeakSet,n=[e],o=0;for(;n.length>0;){let s=n.pop();o+=pt(s,t,r,n)}return o}function pt(e,t,r,n){if(e==null)return 0;switch(typeof e){case"number":return A.number;case"boolean":return A.boolean;case"string":return A.string+e.length*2;case"bigint":return A.bigint+ht(e);case"symbol":return A.symbol;case"function":return t.has(e)?0:(t.add(e),A.function);case"undefined":return 0}let s=e;if(t.has(s))return 0;t.add(s);let i=s[ft];if(typeof i=="function")try{let u=i.call(s);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(s instanceof Date)return A.date;if(s instanceof RegExp)return A.regexp+s.source.length*2;if(s instanceof Error){let u=s.message?s.message.length*2:0,d=s.stack?s.stack.length*2:0;return A.error+u+d}if(typeof URL<"u"&&s instanceof URL)return A.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return A.promise;if(s instanceof WeakMap)return A.weakmap;if(s instanceof WeakSet)return A.weakset;if(s instanceof Map){let u=A.map;for(let[d,h]of s)u+=A.mapEntry,n.push(d),n.push(h);return u}if(s instanceof Set){let u=A.set;for(let d of s)u+=A.setEntry,n.push(d);return u}if(Array.isArray(s)){let u=A.array+s.length*8;for(let d of s)n.push(d);return u}if(s instanceof ArrayBuffer)return r.has(s)?0:(r.add(s),s.byteLength);if(ArrayBuffer.isView(s)){let u=s;return r.has(u.buffer)?48:(r.add(u.buffer),u.buffer.byteLength+48)}let a=A.object,l=Object.keys(s);for(let u of l){a+=A.string+u.length*2;try{n.push(s[u])}catch{}}return a}function ht(e){let t=e<0n?-e:e;if(t===0n)return 0;let r=t.toString(2).length;return Math.ceil(r/32)*8}function Ve(e,t){let r=t?.topN??10,n=e.describe({detail:"standard"}),o=[],s=e._collectObserveTargets;typeof s=="function"&&s.call(e,"",o);let i=new Map;for(let[p,f]of o)i.set(p,f);let a=[];for(let[p,f]of Object.entries(n.nodes)){let c=i.get(p),g=c instanceof L?c:null,b=g?He(g.cache):0,v=g?g._sinkCount:0,w=f.deps?.length??0,m=f.type==="effect"&&v===0,y=v===0?f.type==="effect"?"orphan-effect":f.type==="derived"?"idle-derived":f.type==="producer"?"idle-producer":null:null;a.push({path:p,type:f.type,status:f.status??"unknown",valueSizeBytes:b,subscriberCount:v,depCount:w,isOrphanEffect:m,orphanKind:y})}let l=a.reduce((p,f)=>p+f.valueSizeBytes,0),u=(p,f)=>[...a].sort(f??((c,g)=>g[p]-c[p])).slice(0,r),d=a.filter(p=>p.orphanKind!=null),h=a.filter(p=>p.isOrphanEffect);return{nodeCount:a.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:a,totalValueSizeBytes:l,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:d,orphanEffects:h}}function Re(e){return e>=768&&e<=879||e>=1155&&e<=1161||e>=1425&&e<=1469||e>=1552&&e<=1562||e>=1611&&e<=1631||e>=1648&&e===1648||e>=1750&&e<=1756||e>=1759&&e<=1764||e>=1767&&e<=1768||e>=1770&&e<=1773||e>=1840&&e<=1866||e>=1958&&e<=1968||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2641||e>=2672&&e<=2673||e>=2677&&e===2677||e>=3633&&e===3633||e>=3636&&e<=3642||e>=3655&&e<=3662||e>=3761&&e===3761||e>=3764&&e<=3772||e>=3784&&e<=3790||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65024&&e<=65039||e>=65056&&e<=65071||e===8205?0:e>=4352&&e<=4447||e>=8986&&e<=8987||e>=9001&&e<=9002||e>=9193&&e<=9203||e>=9208&&e<=9210||e>=9725&&e<=9726||e>=9748&&e<=9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e>=9898&&e<=9899||e>=9917&&e<=9918||e>=9924&&e<=9925||e===9934||e===9940||e===9962||e>=9970&&e<=9971||e===9973||e===9978||e===9981||e===9986||e===9989||e>=9992&&e<=9997||e===9999||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e>=10548&&e<=10549||e>=11013&&e<=11015||e>=11035&&e<=11036||e===11088||e===11093||e>=11904&&e<=12350||e>=12352&&e<=12447||e>=12448&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12784&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=40959||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65131||e>=65281&&e<=65376||e>=65504&&e<=65510||e>=126980&&e===126980||e===127183||e>=127344&&e<=127345||e===127358||e===127359||e===127374||e>=127377&&e<=127386||e>=127456&&e<=127487||e>=127488&&e<=127490||e===127514||e===127535||e>=127538&&e<=127546||e>=127568&&e<=127569||e>=127744&&e<=129535||e>=129536&&e<=129791||e>=129792&&e<=130047||e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}function ae(e){let t=0;for(let r of e)t+=Re(r.codePointAt(0));return t}function ze(e,t){if(t<=0)return"";let r=0,n="";for(let o of e){let s=Re(o.codePointAt(0));if(r+s>t){if(t<=1)return"\u2026";for(;r+1>t&&n.length>0;){let i=[...n].pop();n=n.slice(0,-i.length),r-=Re(i.codePointAt(0))}return`${n}\u2026`}n+=o,r+=s}return n}var gt={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"},mt={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function Ue(e,t){let r=t.charset==="ascii"?mt:gt,n=e.width,o=e.height,s=Array.from({length:o},()=>Array.from({length:n},()=>" ")),i=Array.from({length:o},()=>Array.from({length:n},()=>"empty"));for(let a of e.edges)yt(s,i,r,a);for(let a of e.boxes)bt(s,i,r,a,t.labelOf(a.id));return s.map(a=>Ot(a.join(""))).join(`
|
|
3
|
+
`)}function bt(e,t,r,n,o){let{x:s,y:i,w:a,h:l}=n;if(a<2||l<2){l>0&&Ke(e,t,s,i,a,o);return}V(e,t,s,i,r.boxTL);for(let d=s+1;d<s+a-1;d+=1)V(e,t,d,i,r.boxH);V(e,t,s+a-1,i,r.boxTR);for(let d=i+1;d<i+l-1;d+=1){V(e,t,s,d,r.boxV);for(let h=s+1;h<s+a-1;h+=1)Je(e,t,h,d," ","empty");V(e,t,s+a-1,d,r.boxV)}V(e,t,s,i+l-1,r.boxBL);for(let d=s+1;d<s+a-1;d+=1)V(e,t,d,i+l-1,r.boxH);V(e,t,s+a-1,i+l-1,r.boxBR);let u=i+Math.floor(l/2);Ke(e,t,s+1,u,a-2,o)}function V(e,t,r,n,o){Je(e,t,r,n,o,o===" "?"empty":o==="\u2500"||o==="-"?"boxH":o==="\u2502"||o==="|"?"boxV":"boxCorner")}function Je(e,t,r,n,o,s){if(n<0||n>=e.length)return;let i=e[n];r<0||r>=i.length||(i[r]=o,t[n][r]=s)}function Ke(e,t,r,n,o,s){if(n<0||n>=e.length)return;let i=r,a=o;for(let l of s){let u=ae(l);if(u!==0){if(a<u)break;i>=0&&i<e[n].length&&(e[n][i]=l,t[n][i]="label",u===2&&i+1<e[n].length&&(e[n][i+1]="",t[n][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<e[n].length&&(e[n][i]=" ",t[n][i]="empty"),i+=1,a-=1}function yt(e,t,r,n){let o=n.points;if(o.length<2)return;for(let l=0;l+1<o.length;l+=1)vt(e,t,r,o[l],o[l+1]);for(let l=1;l+1<o.length;l+=1){let u=o[l-1],d=o[l],h=o[l+1],p=xt(u,d,h,r);p&&qe(e,t,d.x,d.y,p,"edgeCorner")}let s=o[o.length-1],i=o[o.length-2],a=wt(i,s,r);a&&qe(e,t,s.x,s.y,a,"arrow")}function vt(e,t,r,n,o){if(!(n.x===o.x&&n.y===o.y)){if(n.y===o.y){let s=n.y,i=Math.min(n.x,o.x),a=Math.max(n.x,o.x);for(let l=i;l<=a;l+=1)We(e,t,l,s,r,"h")}else if(n.x===o.x){let s=n.x,i=Math.min(n.y,o.y),a=Math.max(n.y,o.y);for(let l=i;l<=a;l+=1)We(e,t,s,l,r,"v")}}}function We(e,t,r,n,o,s){if(n<0||n>=e.length)return;let i=e[n];if(r<0||r>=i.length)return;let a=t[n][r];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[r]=s==="h"?o.horizontal:o.vertical,t[n][r]=s==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&s==="v"){i[r]=o.cross,t[n][r]="edgeCorner";return}if(a==="edgeV"&&s==="h"){i[r]=o.cross,t[n][r]="edgeCorner";return}}}function qe(e,t,r,n,o,s){if(n<0||n>=e.length)return;let i=e[n];if(r<0||r>=i.length)return;let a=t[n][r];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[r]=o,t[n][r]=s)}function xt(e,t,r,n){let o=e.y===t.y,s=t.y===r.y;if(o===s)return;if(o){let l=e.x<t.x,u=r.y>t.y;return l&&u?n.cornerTR:l&&!u?n.cornerBR:!l&&u?n.cornerTL:n.cornerBL}let i=e.y<t.y,a=r.x>t.x;return i&&a?n.cornerBL:i&&!a?n.cornerBR:!i&&a?n.cornerTL:n.cornerTR}function wt(e,t,r){if(t.x>e.x)return r.arrowRight;if(t.x<e.x)return r.arrowLeft;if(t.y>e.y)return r.arrowDown;if(t.y<e.y)return r.arrowUp}function Ot(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===32;)t-=1;return e.slice(0,t)}function Qe(e){let t=Et(e);_t(t),St(t),Rt(t),Gt(t,e);let r=kt(t,e),{width:n,height:o}=Tt(t),s=[];for(let i of t.layers)for(let a of i)a.isVirtual||s.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:s,edges:r,width:n,height:o}}function Et(e){let t=new Map;for(let o of e.nodes)t.set(o,{id:o,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:e.widthCells(o),h:e.heightCells(o),in:[],out:[]});let r=[],n=0;for(let o of e.edges){if(o.from===o.to)continue;let s=t.get(o.from),i=t.get(o.to);if(!s||!i)continue;let a={chainId:n++,chainFrom:o.from,chainTo:o.to,fromId:o.from,toId:o.to,hopIndex:0,chainLen:1};s.out.push(a),i.in.push(a),r.push(a)}return{nodes:t,layers:[],hops:r}}function _t(e){let t=new Map;for(let s of e.nodes.values())t.set(s.id,s.in.length);let r=[];for(let s of e.nodes.values())(t.get(s.id)??0)===0&&(s.layer=0,r.push(s));let n=new Set,o=0;for(;o<r.length;){let s=r[o++];if(!n.has(s.id)){n.add(s.id);for(let i of s.out){let a=e.nodes.get(i.toId);a.layer=Math.max(a.layer,s.layer+1);let l=(t.get(a.id)??0)-1;t.set(a.id,l),l<=0&&r.push(a)}}}for(let s of e.nodes.values())s.layer<0&&(s.layer=0)}function St(e){let t=Math.max(0,...Array.from(e.nodes.values(),s=>s.layer)),r=Array.from({length:t+1},()=>[]);for(let s of e.nodes.values())r[s.layer].push(s);let n=[],o=0;for(let s of e.hops){let i=e.nodes.get(s.fromId),a=e.nodes.get(s.toId),l=a.layer-i.layer;if(l<=0){i.out=i.out.filter(h=>h!==s),a.in=a.in.filter(h=>h!==s);continue}if(l===1){s.hopIndex=0,s.chainLen=1,n.push(s);continue}i.out=i.out.filter(h=>h!==s),a.in=a.in.filter(h=>h!==s);let u=i;for(let h=1;h<l;h+=1){let p=`__virt_${o++}__`,f={id:p,isVirtual:!0,layer:i.layer+h,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};e.nodes.set(p,f),r[f.layer].push(f);let c={chainId:s.chainId,chainFrom:s.chainFrom,chainTo:s.chainTo,fromId:u.id,toId:p,hopIndex:h-1,chainLen:l};u.out.push(c),f.in.push(c),n.push(c),u=f}let d={chainId:s.chainId,chainFrom:s.chainFrom,chainTo:s.chainTo,fromId:u.id,toId:a.id,hopIndex:l-1,chainLen:l};u.out.push(d),a.in.push(d),n.push(d)}for(let s of r)for(let i=0;i<s.length;i+=1)s[i].order=i;e.layers=r,e.hops=n}function Rt(e){for(let r=0;r<4;r+=1){for(let n=1;n<e.layers.length;n+=1)Ye(e,e.layers[n],"in"),ue(e.layers[n]);for(let n=e.layers.length-2;n>=0;n-=1)Ye(e,e.layers[n],"out"),ue(e.layers[n])}for(let r=0;r<2;r+=1){let n=!1;for(let o=1;o<e.layers.length;o+=1){let s=e.layers[o];for(let i=0;i+1<s.length;i+=1){let a=Xe(e,s[i],s[i+1],"in");[s[i],s[i+1]]=[s[i+1],s[i]],ue(s),Xe(e,s[i],s[i+1],"in")<a?n=!0:([s[i],s[i+1]]=[s[i+1],s[i]],ue(s))}}if(!n)break}}function Ye(e,t,r){let n=new Map;for(let o of t){let s=r==="in"?o.in:o.out;if(s.length===0){n.set(o.id,o.order);continue}let i=0,a=0;for(let l of s){let u=e.nodes.get(r==="in"?l.fromId:l.toId);u&&(i+=u.order,a+=1)}n.set(o.id,a===0?o.order:i/a)}t.sort((o,s)=>{let i=n.get(o.id),a=n.get(s.id);return i!==a?i-a:o.order-s.order})}function ue(e){for(let t=0;t<e.length;t+=1)e[t].order=t}function Xe(e,t,r,n){let o=n==="in"?t.in:t.out,s=n==="in"?r.in:r.out,i=0;for(let a of o)for(let l of s){let u=e.nodes.get(n==="in"?a.fromId:a.toId)?.order??0,d=e.nodes.get(n==="in"?l.fromId:l.toId)?.order??0;(t.order<r.order&&u>d||t.order>r.order&&u<d)&&(i+=1)}return i}function Gt(e,t){t.direction==="LR"?Dt(e,t):Ct(e,t)}function Dt(e,t){let r=[],n=0;for(let o=0;o<e.layers.length;o+=1){r.push(n);let s=0;for(let i of e.layers[o])s=Math.max(s,i.w);n+=s+t.layerGap}for(let o=0;o<e.layers.length;o+=1)for(let s of e.layers[o])s.x=r[o];for(let o of e.layers){let s=0;for(let i of o)i.y=s,s+=i.h+t.nodeGap}Ze(e,t,"y")}function Ct(e,t){let r=[],n=0;for(let o=0;o<e.layers.length;o+=1){r.push(n);let s=0;for(let i of e.layers[o])s=Math.max(s,i.h);n+=s+t.layerGap}for(let o=0;o<e.layers.length;o+=1)for(let s of e.layers[o])s.y=r[o];for(let o of e.layers){let s=0;for(let i of o)i.x=s,s+=i.w+t.nodeGap}Ze(e,t,"x")}function Ze(e,t,r){let n=s=>r==="y"?s.h:s.w,o=t.nodeGap;for(let s=0;s<2;s+=1){let i=s===0?e.layers.slice(1):e.layers.slice(0,-1).reverse();for(let a of i){let l=new Map;for(let d of a){let h=s===0?d.in:d.out;if(h.length===0)continue;let p=[];for(let c of h){let g=e.nodes.get(s===0?c.fromId:c.toId);if(!g)continue;let b=r==="y"?g.y:g.x;p.push(b+Math.floor(n(g)/2))}if(p.length===0)continue;p.sort((c,g)=>c-g);let f=p[Math.floor(p.length/2)];l.set(d.id,f-Math.floor(n(d)/2))}let u=0;for(let d of a){let h=l.get(d.id),p=r==="y"?d.y:d.x,c=Math.max(h??p,u);r==="y"?d.y=c:d.x=c,u=c+n(d)+o}}}}function kt(e,t){let r=new Map;for(let u of e.hops){let d=r.get(u.chainId);d?d.push(u):r.set(u.chainId,[u])}for(let u of r.values())u.sort((d,h)=>d.hopIndex-h.hopIndex);let n=t.direction==="LR",o=u=>n?u.x:u.y,s=u=>n?u.w:u.h,i=u=>n?u.y+Math.floor(u.h/2):u.x+Math.floor(u.w/2),a=new Map;for(let u=0;u+1<e.layers.length;u+=1){let d=e.layers[u],h=e.layers[u+1],p=0;for(let _ of d)p=Math.max(p,o(_)+s(_));let f=Number.POSITIVE_INFINITY;for(let _ of h)f=Math.min(f,o(_));let c=Number.isFinite(f)?f-1:p,g=Math.max(1,c-p+1),b=[];for(let _ of d)for(let R of _.out)b.push(R);b.sort((_,R)=>{let k=i(e.nodes.get(_.fromId)),$=i(e.nodes.get(R.fromId));if(k!==$)return k-$;let D=i(e.nodes.get(_.toId)),G=i(e.nodes.get(R.toId));return D-G});let v=[],w=new Map;for(let _ of b){let R=i(e.nodes.get(_.fromId)),k=i(e.nodes.get(_.toId)),$=Math.min(R,k),D=Math.max(R,k),G=-1;for(let P=0;P<v.length;P+=1){let F=v[P],H=!0;for(let U of F)if(U.lo<=D&&$<=U.hi){H=!1;break}if(H){F.push({lo:$,hi:D}),G=P;break}}G<0&&(v.push([{lo:$,hi:D}]),G=v.length-1),w.set(_,G)}let m=v.length,y=g>=Math.max(3,m+2),S=y?p+1:p,x=y?c-1:c,O=Math.max(1,x-S+1);for(let _ of b){let R=w.get(_),k;if(m<=1)k=S+Math.floor(O/2);else{let $=(O-1)/(m-1);k=S+Math.floor(R*$)}a.set(_,Math.max(p,Math.min(c,k)))}}let l=[];for(let[,u]of r){let d=[];for(let p=0;p<u.length;p+=1){let f=u[p],c=e.nodes.get(f.fromId),g=e.nodes.get(f.toId),b=a.get(f),v=c.isVirtual?o(c):o(c)+s(c),w=g.isVirtual?o(g):o(g)-1,m=i(c),y=i(g);p===0&&le(d,n,v,m),m!==y&&(le(d,n,b,m),le(d,n,b,y)),le(d,n,w,y)}let h=u[0];l.push({from:h.chainFrom,to:h.chainTo,points:$t(d)})}return l}function le(e,t,r,n){e.push(t?{x:r,y:n}:{x:n,y:r})}function $t(e){let t=[];for(let r of e){let n=t[t.length-1];(!n||n.x!==r.x||n.y!==r.y)&&t.push(r)}return t}function Tt(e){let t=0,r=0;for(let n of e.layers)for(let o of n)t=Math.max(t,o.x+o.w),r=Math.max(r,o.y+o.h);return{width:t,height:r}}var Nt=24,At=4,Pt=1,Mt=3;function et(e,t){let r=Lt(t.direction),n=Math.max(3,t.maxLabelWidth??Nt),o=t.asciiCharset??"unicode",s=Object.keys(e.nodes).sort(),i=new Set(s),a=e.edges.filter(f=>i.has(f.from)&&i.has(f.to)),l=new Map,u=new Map;for(let f of s){let c=ze(f,n);l.set(f,c),u.set(f,ae(c)+4)}let d=Qe({nodes:s,edges:a,widthCells:f=>u.get(f)??3,heightCells:()=>Mt,layerGap:At,nodeGap:Pt,direction:r}),h=Ue(d,{charset:o,labelOf:f=>l.get(f)??f}),p=t.logger;return p&&p(h),h}function Lt(e){if(e===void 0||e==="LR")return"LR";if(e==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(e)}`)}var N="::",B="__meta__",q=1;function tt(e,t){let r=Math.max(16,e.size*4),n=0;for(;e.size>0;){if(n++>=r){console.error(`[Graph "${t}".destroy] disposer drain exceeded cap (${r}); ${e.size} disposer(s) discarded`),e.clear();return}let o=e.values().next();if(o.done)return;let s=o.value;e.delete(s);try{s()}catch(i){console.error(`[Graph "${t}".destroy] disposer threw:`,i)}}}function It(e){let t=[];for(let r of Object.keys(e).sort()){let n=e[r].v;n!=null&&t.push(`${r} ${n.id} ${n.version}`)}return t.join(`
|
|
4
|
+
`)}function nt(e){if(e.version!==q)throw new Error(`unsupported snapshot version ${String(e.version)} (expected ${q})`);for(let t of["name","nodes","edges","subgraphs"])if(!(t in e))throw new Error(`snapshot missing required key "${t}"`);if(typeof e.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof e.nodes!="object"||e.nodes===null||Array.isArray(e.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(e.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(e.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function jt(e,t){let r=new WeakMap,n=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=r.get(o);if(i==null&&(i=new WeakSet,r.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,l=s.constructor;if(a!==l)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let p=s;if(o.length!==p.length)return!1;for(let f=0;f<o.length;f++)if(!n(o[f],p[f]))return!1;return!0}if(o instanceof Map){let p=s;if(o.size!==p.size)return!1;for(let[f,c]of o)if(!p.has(f)||!n(c,p.get(f)))return!1;return!0}if(o instanceof Set){let p=s;if(o.size!==p.size)return!1;for(let f of o){let c=!1;for(let g of p)if(n(f,g)){c=!0;break}if(!c)return!1}return!0}if(ArrayBuffer.isView(o)){let p=o,f=s;if(p.length!==f.length)return!1;for(let c=0;c<p.length;c++)if(p[c]!==f[c])return!1;return!0}let u=Object.keys(o),d=Object.keys(s);if(u.length!==d.length)return!1;let h=new Set(d);for(let p of u)if(!h.has(p)||!n(o[p],s[p]))return!1;return!0};return n(e,t)}function De(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(De);let t=e,r=Object.keys(t).sort(),n={};for(let o of r)n[o]=De(t[o]);return n}function Bt(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Ft(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Ht(e){return e==="TD"?"down":e==="BT"?"up":e==="RL"?"left":"right"}function ot(e){let t=new Set,r=[];function n(o,s){let i=`${o}\0${s}`;t.has(i)||(t.add(i),r.push([o,s]))}for(let[o,s]of Object.entries(e.nodes)){let i=s.deps;if(i)for(let a of i)n(a,o)}for(let o of e.edges)n(o.from,o.to);return r}function it(e){if(e===void 0)return"LR";if(e==="TD"||e==="LR"||e==="BT"||e==="RL")return e;throw new Error(`invalid diagram direction ${String(e)}; expected one of: TD, LR, BT, RL`)}function Vt(e,t){let r=t.includeEdges??!0,n=t.includeSubgraphs??!0,{expand:o,...s}=e,i={...s,edges:r?e.edges:[],subgraphs:n?e.subgraphs:[]},a=JSON.stringify(De(i),null,t.indent??2);return t.logger?.(a),a}function zt(e,t){let r=t.includeEdges??!0,n=t.includeSubgraphs??!0,o=[];o.push(`Graph ${e.name}`),o.push("Nodes:");for(let i of Object.keys(e.nodes).sort()){let a=e.nodes[i];o.push(`- ${i} (${a.type}/${a.status}): ${de(a.value)}`)}if(r){o.push("Edges:");for(let i of e.edges)o.push(`- ${i.from} -> ${i.to}`)}if(n){o.push("Subgraphs:");for(let i of e.subgraphs)o.push(`- ${i}`)}let s=o.join(`
|
|
5
|
+
`);return t.logger?.(s),s}function at(e,t){let r=it(t.direction),n=Object.keys(e.nodes).sort(),o=new Map;for(let i=0;i<n.length;i+=1)o.set(n[i],`n${i}`);let s=[`flowchart ${r}`];for(let i of n){let a=o.get(i);s.push(` ${a}["${Bt(i)}"]`)}for(let[i,a]of ot(e)){let l=o.get(i),u=o.get(a);!l||!u||s.push(` ${l} --> ${u}`)}return s.join(`
|
|
6
|
+
`)}function Kt(e,t){let r=at(e,t);return Wt(r)}function Wt(e,t){let r=t?.theme??"default",n=t?.autoSync??!0,s=JSON.stringify({code:e,mermaid:{theme:r},autoSync:n}),i=new TextEncoder().encode(s),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 qt(e,t){let r=it(t.direction),n=Object.keys(e.nodes).sort(),o=new Map;for(let i=0;i<n.length;i+=1)o.set(n[i],`n${i}`);let s=[`direction: ${Ht(r)}`];for(let i of n){let a=o.get(i);s.push(`${a}: "${Ft(i)}"`)}for(let[i,a]of ot(e)){let l=o.get(i),u=o.get(a);!l||!u||s.push(`${l} -> ${u}`)}return s.join(`
|
|
7
|
+
`)}function Ut(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(e){let t="^";for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="*"){t+=".*";continue}if(n==="?"){t+=".";continue}if(n==="["){let o=e.indexOf("]",r+1);if(o<=r+1){t+="\\[";continue}let s=e.slice(r+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),t+=`[${s}]`,r=o;continue}t+=Ut(n)}return t+="$",new RegExp(t)}var Jt={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"},Yt={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function de(e){if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean"||e==null)return String(e);try{return JSON.stringify(e)}catch{return"[unserializable]"}}function Xt(e){return e==="none"?Yt:e==="ansi"||e==null?Jt:{data:e.data??"",dirty:e.dirty??"",resolved:e.resolved??"",invalidate:e.invalidate??"",pause:e.pause??"",resume:e.resume??"",complete:e.complete??"",error:e.error??"",teardown:e.teardown??"",derived:e.derived??"",path:e.path??"",reset:e.reset??""}}function rt(e){if(e==null)return{};let t=e.detail;return t==="full"?{...e,structured:e.structured??!0,timeline:e.timeline??!0,causal:e.causal??!0,derived:e.derived??!0}:t==="minimal"?{...e,structured:e.structured??!0}:e.format==="stage-log"?{...e,structured:e.structured??!0,timeline:e.timeline??!0}:e}function Qt(e,t,r){for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);if(o<32||o===127)throw new Error(`Graph "${t}": ${r} "${e}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function Ge(e,t,r){if(e==="")throw new Error(`Graph "${t}": ${r} name must be non-empty`);if(e.includes(N))throw new Error(`Graph "${t}": ${r} "${e}" must not contain '${N}' (path separator)`);if(e===B)throw new Error(`Graph "${t}": ${r} name "${B}" is reserved for meta companion paths`);Qt(e,t,r)}function Zt(e,t){if(e==="")throw new Error(`Graph "${t}": resolve path must be non-empty`);let r=e.split(N);for(let n of r)if(n==="")throw new Error(`Graph "${t}": resolve path has empty segment`);return r}function en(e,t){let r=!1;for(let o of e)if(!t.isMetaPassthrough(o[0])){r=!0;break}return r?e.filter(o=>t.isMetaPassthrough(o[0])):e}function ut(e){for(let t of e._mounts.values())ut(t);for(let t of e._nodes.values())try{t.down([[z]],{internal:!0})}catch{}}var Ce=class e{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;constructor(t,r){if(t==="")throw new Error("Graph name must be non-empty");if(t.includes(N))throw new Error(`Graph name must not contain '${N}' (got "${t}")`);if(t===B)throw new Error(`Graph name "${B}" is reserved for meta companion paths`);this.name=t,this.opts=Object.freeze({...r??{}}),this.config=r?.config??we,this._traceRing=new Se(r?.traceCapacity??1e3),r?.versioning!=null&&this.setVersioning(r.versioning)}ancestors(t=!0){let r=[],n=t?this:this._parent;for(;n!=null;)r.push(n),n=n._parent;return r}get topology(){return this._topology==null&&(this._topology=Me(t=>{let r=n=>{t.emit(n)};return this._topologyEmitters.add(r),()=>{this._topologyEmitters.delete(r)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(t){if(!(this._topology==null||this._topologyEmitters.size===0))for(let r of this._topologyEmitters)r(t)}nameOf(t){return this._nodeToName.get(t)}add(t,r){let n=t.name,o=r?.name??n;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=r?.annotation;if(Ge(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let a=this._nodeToName.get(t);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(s,t),this._nodeToName.set(t,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:K()})),t}setVersioning(t){if(t!=null)for(let r of this._nodes.values())r instanceof L&&r._applyVersioning(t)}remove(t){Ge(t,this.name,"remove");let r=this._mounts.get(t);if(r){let s={kind:"mount",nodes:[],mounts:[]},i=[];r._collectObserveTargets("",i);for(let[a,l]of i)a.includes(`${N}${B}${N}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(t),s.mounts.push(...r._collectSubgraphs(`${t}${N}`)),this._mounts.delete(t),r._parent=void 0,ut(r),this._emitTopology({kind:"removed",name:t,nodeKind:"mount",audit:s}),s}let n=this._nodes.get(t);if(!n)throw new Error(`Graph "${this.name}": unknown node or mount "${t}"`);this._nodes.delete(t),this._nodeToName.delete(n),n.down([[z]],{internal:!0});let o={kind:"node",nodes:[t],mounts:[]};return this._emitTopology({kind:"removed",name:t,nodeKind:"node",audit:o}),o}removeAll(t){let r=typeof t=="function"?t:(()=>{let s=ce(t);return i=>s.test(i)})(),n={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>r(s));for(let s of o){let i=this.remove(s);n.nodes.push(...i.nodes),n.mounts.push(...i.mounts)}return n.nodes.sort(),n.mounts.sort(),n}[Symbol.iterator](){let t=[...this._nodes.keys()].sort(),r=this._nodes,n=0;return{[Symbol.iterator](){return this},next(){if(n>=t.length)return{value:void 0,done:!0};let o=t[n++];return{value:[o,r.get(o)],done:!1}}}}node(t){if(t==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(t.includes(N))return this.resolve(t);let r=this._nodes.get(t);if(!r)throw new Error(`Graph "${this.name}": unknown node "${t}"`);return r}get(t){return this.node(t).cache}set(t,r,n){let o=n?.internal===!0;this.node(t).down([[Q,r]],{actor:n?.actor,internal:o,delivery:"write"})}setAll(t,r){let n=Symbol.iterator in t?t:Object.entries(t);Ae(()=>{for(let[o,s]of n)this.set(o,s,r)})}invalidate(t,r){let n=r?.internal===!0;this.node(t).down([[Z]],{actor:r?.actor,internal:n,delivery:"write"})}error(t,r,n){let o=n?.internal===!0;this.node(t).down([[te,r]],{actor:n?.actor,internal:o,delivery:"write"})}complete(t,r){let n=r?.internal===!0;this.node(t).down([[ee]],{actor:r?.actor,internal:n,delivery:"write"})}edges(t){let r=t?.recursive===!0,n=new Map;if(!r){for(let[l,u]of this._nodes)n.set(u,l);let a=[];for(let[l,u]of this._nodes)if(u instanceof L)for(let d of u._deps){let h=n.get(d.node);h!=null&&a.push([h,l])}return a.sort((l,u)=>l[0]<u[0]?-1:l[0]>u[0]?1:l[1]<u[1]?-1:l[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,l]of o)s.set(l,a);let i=[];for(let[a,l]of o)if(l instanceof L)for(let u of l._deps){let d=s.get(u.node);d!=null&&i.push([d,a])}return i.sort((a,l)=>a[0]<l[0]?-1:a[0]>l[0]?1:a[1]<l[1]?-1:a[1]>l[1]?1:0),i}mount(t,r){if(r===void 0){let o=new e(t);return this.mount(t,o)}if(typeof r=="function"){let o=new e(t);return r(o),this.mount(t,o)}let n=r;if(Ge(t,this.name,"mount"),this._nodes.has(t))throw new Error(`Graph "${this.name}": cannot mount at "${t}" \u2014 node with that name exists`);if(this._mounts.has(t))throw new Error(`Graph "${this.name}": mount "${t}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let o=this;o!=null;o=o._parent)if(o===n)throw new Error(`Graph "${this.name}": mount("${t}", \u2026) would create a mount cycle`);return this._mounts.set(t,n),n._parent=this,this._emitTopology({kind:"added",name:t,nodeKind:"mount"}),n}resolve(t){let r=Zt(t,this.name);return this._resolveFromSegments(r)}tryResolve(t){try{return this.resolve(t)}catch{return}}_resolveFromSegments(t){let r=t;if(r[0]===this.name&&(r=r.slice(1),r.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let n=r[0],o=r.slice(1);if(o.length===0){let a=this._nodes.get(n);if(a)return a;throw this._mounts.has(n)?new Error(`Graph "${this.name}": path ends at subgraph "${n}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${n}"`)}let s=this._nodes.get(n);if(s&&o.length>0&&o[0]===B)return this._resolveMetaChainFromNode(s,o,r.join(N));let i=this._mounts.get(n);if(!i)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${o.join(N)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(o.join(N))}_resolveMetaChainFromNode(t,r,n){let o=t,s=0,i=[...r];for(;s<i.length;){if(i[s]!==B)throw new Error(`Graph "${this.name}": expected ${B} segment in meta path "${n}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${B} in "${n}"`);let a=i[s+1],l=o.meta[a];if(!l)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${n}"`);o=l,s+=2}return o}signal(t,r){if(r?.internal!==!0){for(let o of t)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let n=[];if(this._signalDeliver(t,r??{},new Set,n),n.length>0)throw n[0]}_signalDeliver(t,r,n,o){for(let l of this._mounts.values())l._signalDeliver(t,r,n,o);let i=r.internal===!0?{internal:!0}:{actor:r.actor,delivery:"signal"},a=en(t,this.config);for(let l of[...this._nodes.keys()].sort()){let u=this._nodes.get(l);if(!n.has(u)){n.add(u);try{u.down(t,i)}catch(d){if(d instanceof W)throw d;o.push(d)}a.length!==0&&this._signalMetaSubtree(u,a,n,i,o)}}}_signalMetaSubtree(t,r,n,o,s){for(let i of Object.keys(t.meta).sort()){let a=t.meta[i];if(!n.has(a)){n.add(a);try{a.down(r,o)}catch(l){if(l instanceof W)throw l;s.push(l)}this._signalMetaSubtree(a,r,n,o,s)}}}describe(t){if(t?.reactive===!0)return this._describeReactive(t);let r=t?.actor,n=t?.filter,o=re(t?.detail,t?.fields),s=t?.format==="spec",i=s?re("minimal"):o,a=[];this._collectObserveTargets("",a);let l=new Map;for(let[x,O]of a)l.set(O,x);let u=[];{let x=a.map(([,R])=>R),O=new Set(l.values()),_=0;for(;x.length>0;){let R=x.shift();if(R instanceof L)for(let k of R._deps){let $=k.node;if(l.has($))continue;let D=$.name??"",G=D;if(!G||O.has(G))if(D){let P=2;for(;O.has(`${D}#${P}`);)P++;G=`${D}#${P}`}else for(G=`__internal__/${_++}`;O.has(G);)G=`__internal__/${_++}`;l.set($,G),O.add(G),u.push([G,$]),x.push($)}}}let d=[...a,...u],h={};for(let[x,O]of d){if(r!=null&&!O.allowsObserve(r))continue;let _=_e(O,i),R=O instanceof L?O._deps.map(G=>l.get(G.node)??G.node.name??""):[],{name:k,...$}=_,D={...$,deps:R};if(!s){let G=this._annotations.get(x);G!=null&&(D.annotation=G)}if(n!=null)if(typeof n=="function"){let G=n;if(!(G.length>=2?G(x,D):G(D)))continue}else{let G=!0;for(let[P,F]of Object.entries(n)){let H=P==="deps_includes"?"depsIncludes":P==="meta_has"?"metaHas":P;if(H==="depsIncludes"){if(!D.deps.includes(String(F))){G=!1;break}continue}if(H==="metaHas"){if(!Object.hasOwn(D.meta??{},String(F))){G=!1;break}continue}if(D[H]!==F){G=!1;break}}if(!G)continue}h[x]=D}let p=new Set(Object.keys(h)),f=[];for(let[x,O]of d)if(O instanceof L)for(let _ of O._deps){let R=l.get(_.node);R!=null&&f.push([R,x])}f.sort((x,O)=>x[0]<O[0]?-1:x[0]>O[0]?1:x[1]<O[1]?-1:x[1]>O[1]?1:0);let c=f.map(([x,O])=>({from:x,to:O}));(r!=null||n!=null)&&(c=c.filter(x=>p.has(x.from)&&p.has(x.to)));let g=this._collectSubgraphs(""),b=r!=null||n!=null?g.filter(x=>{let O=`${x}${N}`;return[...p].some(_=>_===x||_.startsWith(O))}):g,v=this,w=t,m={name:this.name,nodes:h,edges:c,subgraphs:b,expand(x){let O={...w,format:void 0};return Array.isArray(x)?(O.fields=x,O.detail=void 0):(O.detail=x,O.fields=void 0),v.describe(O)}},y=t??{},S=y.format;return S==="json"?Vt(m,y):S==="pretty"?zt(m,y):S==="mermaid"?at(m,y):S==="mermaid-url"?Kt(m,y):S==="d2"?qt(m,y):S==="ascii"?et(m,y):m}_collectSubgraphs(t){let r=[];for(let n of[...this._mounts.keys()].sort()){let o=t===""?n:`${t}${n}`;r.push(o),r.push(...this._mounts.get(n)._collectSubgraphs(`${o}${N}`))}return r}resourceProfile(t){return Ve(this,t)}reachable(t,r,n={}){return n.withDetail===!0?st(this.describe(),t,r,{...n,withDetail:!0}):st(this.describe(),t,r,n)}explain(t,r,n){return n?.reactive===!0?this._explainReactive(t,r,n):this._explainStatic(t,r,n)}_explainStatic(t,r,n){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,l]of Object.entries(o.nodes))l.lastMutation!=null&&i.set(a,l.lastMutation);return Ie(o,t,r,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(t){let r={...t,reactive:!1},n=t.reactiveName??"describe",o=0,s=ne(o,{name:`${n}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,l=!1,u=()=>{a||l||(a=!0,xe(()=>{a=!1,!l&&(o+=1,s.emit(o))}))},d=i.onEvent(b=>{let v=b.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||u()}),h=[],p=new WeakSet,f=b=>{if(p.has(b)||l)return;p.add(b);let v=b.topology.subscribe(w=>{for(let m of w){if(m[0]!==Q)continue;let y=m[1];if(u(),y.kind==="added"&&y.nodeKind==="mount"){let S=b._mounts.get(y.name);S!=null&&f(S)}}});h.push(v);for(let w of b._mounts.keys()){let m=b._mounts.get(w);m!=null&&f(m)}};f(this);let c;try{c=Oe([s],()=>this.describe(r),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,v)=>b===v})}catch(b){d();for(let v of h)v();throw i.dispose(),b}let g=Ee(c);return{node:c,dispose(){l=!0,d();for(let b of h)b();h.length=0,i.dispose(),g()}}}_explainReactive(t,r,n){let o=0,s=ne(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,l=!1,u=i.onEvent(f=>{let c=f.type;c!=="data"&&c!=="error"&&c!=="complete"&&c!=="teardown"||a||l||(a=!0,xe(()=>{a=!1,!l&&(o+=1,s.emit(o))}))}),d={...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{}},h;try{h=Oe([s],()=>this._explainStatic(t,r,d),{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:t,to:r},equals:(f,c)=>f.found===c.found&&f.reason===c.reason&&f.steps.length===c.steps.length&&nn(f.steps,c.steps)})}catch(f){throw u(),i.dispose(),f}let p=Ee(h);return{node:h,dispose(){l=!0,u(),i.dispose(),p()}}}_pathsMatching(t){let r=ce(t),n=[];return this._collectObserveTargets("",n),n.map(([o])=>o).filter(o=>r.test(o))}_collectObserveTargets(t,r){for(let n of[...this._mounts.keys()].sort()){let o=t===""?n:`${t}${N}${n}`;this._mounts.get(n)._collectObserveTargets(o,r)}for(let n of[...this._nodes.keys()].sort()){let o=this._nodes.get(n),s=t===""?n:`${t}${N}${n}`;r.push([s,o]),this._appendMetaObserveTargets(s,o,r)}}_appendMetaObserveTargets(t,r,n){for(let o of Object.keys(r.meta).sort()){let s=r.meta[o],i=`${t}${N}${B}${N}${o}`;n.push([i,s]),this._appendMetaObserveTargets(i,s,n)}}observe(t,r){let n=typeof t=="string",s=rt(n?r:t),i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(n){let d=t,h=this.resolve(d);if(a!=null&&!h.allowsObserve(a))throw new W({actor:a,action:"observe",nodeName:d});return i?this._buildStructuredObserver([[d,h]],s,"one"):{subscribe(p){return h.subscribe(p)},up(p){try{h.up?.(p)}catch(f){if(f instanceof W)return;throw f}}}}let l=[];this._collectObserveTargets("",l),l.sort((d,h)=>d[0]<h[0]?-1:d[0]>h[0]?1:0);let u=a==null?l:l.filter(([,d])=>d.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:d=>{let h=u.map(([p,f])=>f.subscribe(c=>{d(p,c)}));return()=>{for(let p of h)p()}},up:(d,h)=>{try{this.resolve(d).up?.(h)}catch(p){if(p instanceof W)return;throw p}}}}_buildStructuredObserver(t,r,n){let o=n==="one"?t[0]?.[0]:void 0,s=i=>{if(n==="one"&&o!=null){let d=this.resolve(o);return this._buildStructuredObserver([[o,d]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((d,h)=>d[0]<h[0]?-1:d[0]>h[0]?1:0);let l=i.actor,u=l==null?a:a.filter(([,d])=>d.allowsObserve(l));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(t,r,s)}_createObserveResult(t,r,n){let o=r.timeline===!0,s=r.causal===!0,i=r.derived===!0,a=r.detail==="minimal",l=this.config.inspectorEnabled,u=(s||i)&&l,d=r.maxEvents,h=d!=null&&d>0?new Se(d):null,p=[],f=new Set,c={},g=new Set,b=0,v=0,w=0,m=0,y=0,S=0,x=!1,O=!1,_=0,R=new Map,k=new Map,$=new Map,D=E=>{h?h.push(E):p.push(E);for(let T of f)T(E)},G=()=>o?{timestamp_ns:K(),in_batch:Ne(),batch_id:_}:{},P=(E,T)=>{if(!(!u||!(E instanceof L)))return E._setInspectorHook(I=>{if(I.kind==="dep_message")R.set(E,I.depIndex);else if(I.kind==="run"){let J=I.batchData.map((C,M)=>C!=null&&C.length>0?C.at(-1):I.prevData[M]);k.set(E,J);let j=I.batchData.map(C=>C!=null?[...C]:void 0);$.set(E,j),i&&D({type:"derived",path:T,dep_values:J,dep_batches:j,...G()})}})},F=E=>{let T=R.get(E),I=k.get(E);if(!s||I==null)return{};let j=(T!=null&&T>=0&&E instanceof L?E._deps[T]:void 0)?.node,C=j?.v,M=$.get(E);return{trigger_dep_index:T,trigger_dep_name:j?.name,...C!=null?{trigger_version:{id:C.id,version:C.version}}:{},dep_values:[...I],...M!=null?{dep_batches:M}:{}}},H=[],U=[];for(let[E,T]of t){let I=P(T,E);I&&H.push(I),U.push(T.subscribe(J=>{_++;for(let j of J){let C=j[0],M=G();if(C===Q){c[E]=j[1];let ge=T instanceof L?T.lastMutation?.actor??Y:Y;D({type:"data",path:E,data:j[1],actor:ge,...M,...F(T)})}else if(a)C===me?b++:C===be?v++:C===Z?w++:C===ye?m++:C===ve?y++:C===z?S++:C===ee&&!g.has(E)?x=!0:C===te&&(O=!0,g.add(E));else if(C===me)b++,D({type:"dirty",path:E,...M});else if(C===be)v++,D({type:"resolved",path:E,...M,...F(T)});else if(C===Z)w++,D({type:"invalidate",path:E,...M});else if(C===ye)m++,D({type:"pause",path:E,lockId:j[1],...M});else if(C===ve)y++,D({type:"resume",path:E,lockId:j[1],...M});else if(C===ee)g.has(E)||(x=!0),D({type:"complete",path:E,...M});else if(C===te){O=!0,g.add(E);let ge=T instanceof L?T.lastMutation?.actor??Y:Y;D({type:"error",path:E,data:j[1],actor:ge,...M})}else C===z&&(S++,D({type:"teardown",path:E,...M}))}}))}let fe=!1,pe=()=>{if(!fe){fe=!0;for(let E of U)E();for(let E of H)E();for(let E of X)E({value:void 0,done:!0});X.length=0}},he=[],X=[];f.add(E=>{let T=X.shift();T?T({value:E,done:!1}):he.push(E)});let ke={get values(){return c},get dirtyCount(){return b},get resolvedCount(){return v},get invalidateCount(){return w},get pauseCount(){return m},get resumeCount(){return y},get teardownCount(){return S},get events(){return h?h.toArray():[...p]},get anyCompletedCleanly(){return x},get anyErrored(){return O},get completedWithoutErrors(){return x&&!O},onEvent(E){return f.add(E),()=>f.delete(E)},dispose:pe,expand(E){pe();let T={...r};return typeof E=="string"?T.detail=E:Object.assign(T,E),n(rt(T))},[Symbol.asyncIterator](){return{next(){return he.length>0?Promise.resolve({value:he.shift(),done:!1}):fe?Promise.resolve({value:void 0,done:!0}):new Promise(E=>X.push(E))},return(){return pe(),Promise.resolve({value:void 0,done:!0})}}}};return r.format!=null&&this._attachFormatLogger(ke,r),ke}_attachFormatLogger(t,r){let n=r.format;if(n==null)return;let o=r.logger??(c=>console.log(c)),s=r.includeTypes?new Set(r.includeTypes):null,i=r.excludeTypes?new Set(r.excludeTypes):null,a=s==null&&i==null?()=>!0:c=>(s==null||s.has(c))&&(i==null||!i.has(c)),l=Xt(r.theme),u=n==="stage-log"?K():0,d=c=>c==null?"":r.stageLabels?.[c]??c,h=(c,g)=>c.length>g?`${c.slice(0,g-1)}\u2026`:c,p=c=>c.type==="data"||c.type==="error"?h(de(c.data),120):"",f=c=>{if(n==="stage-log"){let O=(K()-u)/1e9,_=d(c.path).padEnd(9);if(c.type==="data"){let R=p(c);return`[${O.toFixed(3)}s] ${_} \u2190${R?` ${R}`:""}`}if(c.type==="error"){let R=p(c);return`[${O.toFixed(3)}s] ${_} \u2717${R?` ${R}`:""}`}return c.type==="complete"?`[${O.toFixed(3)}s] ${_} \u25A0 complete`:`[${O.toFixed(3)}s] ${_} ${c.type}`}if(n==="json")try{return JSON.stringify(c)}catch{return JSON.stringify({type:c.type,path:c.path,data:"[unserializable]"})}let g=l[c.type]??"",b=c.path?`${l.path}${c.path}${l.reset} `:"",v=c.type==="data"||c.type==="error",w=c.type==="pause"||c.type==="resume",m=v?` ${de(c.data)}`:w?` ${de(c.lockId)}`:"",y=c.type==="data"||c.type==="resolved"||c.type==="derived"?c:void 0,S=y?.trigger_dep_name!=null?` <- ${y.trigger_dep_name}`:y?.trigger_dep_index!=null?` <- #${y.trigger_dep_index}`:"",x=c.in_batch?" [batch]":"";return`${b}${g}${c.type.toUpperCase()}${l.reset}${m}${S}${x}`};t.onEvent(c=>{a(c.type)&&o(f(c),c)})}addDisposer(t){return this._disposers.add(t),()=>{this._disposers.delete(t)}}destroy(){tt(this._disposers,this.name),this.signal([[z]],{internal:!0}),tt(this._storageDisposers,this.name);for(let t of[...this._mounts.values()])t._parent=void 0,t._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let t of[...this._mounts.values()])t._parent=void 0,t._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(t){let{expand:r,...n}=this.describe({detail:"full"}),o={};for(let a of Object.keys(n.nodes).sort()){let{lastMutation:l,guard:u,...d}=n.nodes[a];o[a]=d}let s=[...n.subgraphs].sort(),i={...n,version:1,nodes:o,subgraphs:s};if(t?.format==null)return i;if(t.format==="json-string")return JSON.stringify(i);if(t.format==="bytes"){if(t.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(t.codec);if(a==null)throw new Error(`snapshot: codec "${t.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return $e(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(t.format)}"`)}static decode(t,r){let n=r?.config??we,{codec:o,codecVersion:s,payload:i}=Te(t,n);return o.decode(i,s)}restore(t,r){if(nt(t),t.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${t.name}" does not match this graph`);let n=r?.only==null?null:(Array.isArray(r.only)?r.only:[r.only]).map(s=>ce(s)),o=r?.includeProducers===!0;for(let s of Object.keys(t.nodes).sort()){if(n!==null&&!n.some(a=>a.test(s)))continue;let i=t.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&r?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let l=this.tryResolve(s)?.v;if(l!=null&&l.id===i.v.id&&l.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){r?.onError?.(s,a)}}}}}static fromSnapshot(t,r){nt(t);let n=typeof r=="function"?r:r?.build,o=typeof r=="function"?void 0:r?.factories,s=new e(t.name);if(n)return n(s),s.restore(t),s;for(let f of[...t.subgraphs].sort((c,g)=>{let b=c.split(N).length,v=g.split(N).length;return b!==v?b-v:c<g?-1:c>g?1:0})){let c=f.split(N),g=s;for(let b of c)g._mounts.has(b)||g.mount(b,new e(b)),g=g._mounts.get(b)}let i=o?Object.entries(o).map(([f,c])=>({re:ce(f),factory:c})):[],a=f=>{for(let c of i)if(c.re.test(f))return c.factory},l=f=>{let c=f.split(N),g=c.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${f}"`);let b=s;for(let v of c){let w=b._mounts.get(v);if(!w)throw new Error(`unknown mount "${v}" in path "${f}"`);b=w}return[b,g]},u=Object.entries(t.nodes).filter(([f])=>!f.includes(`${N}${B}${N}`)).sort((f,c)=>f[0]<c[0]?-1:f[0]>c[0]?1:0),d=new Map(u),h=new Map,p=!0;for(;d.size>0&&p;){p=!1;for(let[f,c]of[...d.entries()]){let g=c?.deps??[];if(!g.every(S=>h.has(S)))continue;let[b,v]=l(f),w={...c?.meta??{}},m=a(f),y;if(c?.type==="state")y=ne(c.value,{meta:w});else{if(m==null)continue;y=m(v,{path:f,type:c.type,value:c.value,meta:w,deps:g,resolvedDeps:g.map(S=>h.get(S))})}b.add(y,{name:v}),h.set(f,y),d.delete(f),p=!0}}if(d.size>0){let f=[...d.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${f}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(t),s}toJSON(){return this.snapshot()}attachSnapshotStorage(t,r={}){let n=t.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));r.autoRestore===!0&&this._cascadeRestore(t,r.onError);let o=(u,d)=>{if(u.disposed)return;let h=It(d.nodes);if(u.lastSnapshot!=null&&h!==""&&h===u.lastFingerprint)return;let p=u.seq+1,f=Pe(),b=u.lastSnapshot==null||p%u.compactEvery===0?{name:this.name,mode:"full",snapshot:d,seq:p,timestamp_ns:f,format_version:q}:{name:this.name,mode:"diff",diff:tn(u.lastSnapshot,d),seq:p,timestamp_ns:f,format_version:q};if(u.tier.filter&&!u.tier.filter(b))return;let v;try{v=u.tier.save(b)}catch(w){r.onError?.(w,u.tier);return}if(v&&typeof v.then=="function"){let y=(u.savePending??Promise.resolve()).then(()=>v,()=>v).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=d,u.lastFingerprint=h)},S=>{r.onError?.(S,u.tier)});u.savePending=y.finally(()=>{u.savePending===y&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=d,u.lastFingerprint=h},s=(u,d)=>{try{o(u,d)}catch(h){r.onError?.(h,u.tier)}},i=(u,d)=>{if(!d.some(c=>{let g=this.config.messageTier(c[0]);return g>=3&&g<5}))return;if(r.filter){let c=this.tryResolve(u);if(c==null)return;let g=_e(c,re("standard"));if(!r.filter(u,g))return}let p,f=()=>(p==null&&(p=this.snapshot()),p);for(let c of n)c.disposed||(c.debounceMs===0?s(c,f()):(c.timer==null&&(c.timer=new Le),c.timer.start(c.debounceMs,()=>{c.disposed||s(c,this.snapshot())})))},a;if(r.paths!=null){let d=(typeof r.paths=="string"?this._pathsMatching(r.paths):r.paths).map(h=>{let p=this.tryResolve(h);return p==null?()=>{}:p.subscribe(f=>i(h,f))});a=()=>{for(let h of d)h()}}else a=this.observe().subscribe((u,d)=>i(u,d));let l=()=>{a();for(let u of n)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(l)};return this._storageDisposers.add(l),{dispose:l}}async _cascadeRestore(t,r){for(let n of t){let o;try{o=await n.load?.()}catch(i){r?.(i,n);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===q&&s.nodes!=null)return this.restore(s),!0}catch(i){r?.(i,n)}}return!1}static async fromStorage(t,r,n){for(let o of r){let s;try{s=await o.load?.()}catch(l){n?.onError?.(l,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===q&&i.nodes!=null?i:void 0;if(a!=null)try{return e.fromSnapshot(a,n)}catch(l){n?.onError?.(l,o)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${t}" across ${r.length} tier(s)`)}_annotations=new Map;_traceRing;trace(t,r,n){if(t!=null&&r!=null){if(this.tryResolve(t)==null)return;if(this._annotations.set(t,r),this.config.inspectorEnabled){let o={path:t,annotation:r,timestamp_ns:K(),...n?.actor!=null?{actor:n.actor}:{}};this._traceRing.push(o)}return}return t!=null?this.config.inspectorEnabled?this._annotations.get(t):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(t){return this._annotations.get(t)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(t){let r=this._traceRing.toArray().filter(o=>!t(o)),n=this._traceRing.size-r.length;this._traceRing.clear();for(let o of r)this._traceRing.push(o);return n}static diff(t,r){let n=new Set(Object.keys(t.nodes)),o=new Set(Object.keys(r.nodes)),s=[...o].filter(w=>!n.has(w)).sort(),i=[...n].filter(w=>!o.has(w)).sort(),a=[],l=[];for(let w of n){if(!o.has(w))continue;let m=t.nodes[w],y=r.nodes[w],S=m.v,x=y.v;S!=null&&x!=null&&S.id===x.id&&S.version!==x.version&&l.push({path:w,id:S.id,from:S.version,to:x.version});let O=S!=null&&x!=null&&S.id===x.id&&S.version===x.version;for(let _ of["type","status","sentinel"]){let R=m[_],k=y[_];R!==k&&a.push({path:w,field:_,from:R,to:k})}if(!O)for(let _ of["value","meta"]){let R=m[_],k=y[_];jt(R,k)||a.push({path:w,field:_,from:R,to:k})}}let u=w=>`${w.from} ${w.to}`,d=new Set(t.edges.map(u)),h=new Set(r.edges.map(u)),p=r.edges.filter(w=>!d.has(u(w))),f=t.edges.filter(w=>!h.has(u(w))),c=new Set(t.subgraphs),g=new Set(r.subgraphs),b=[...g].filter(w=>!c.has(w)).sort(),v=[...c].filter(w=>!g.has(w)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:l,edgesAdded:p,edgesRemoved:f,subgraphsAdded:b,subgraphsRemoved:v}}};function tn(e,t){let r=Ce.diff(e,t),n={};for(let o of r.nodesAdded){let s=t.nodes[o];s!=null&&(n[o]=s)}return{...r,nodesAddedFull:n}}function st(e,t,r,n={}){let o={paths:[],depths:new Map,truncated:!1};if(!t)return n.withDetail?o:[];if(!n.both&&r!=="upstream"&&r!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=n.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return n.withDetail?o:[];let i=new Map,a=new Map,l=new Map,u=new Map,d=new Set;for(let[m,y]of Object.entries(e.nodes)){if(!m)continue;d.add(m);let S=y.deps??[];i.set(m,S);for(let x of S)x&&(d.add(x),a.has(x)||a.set(x,new Set),a.get(x).add(m))}for(let m of e.edges){if(m==null||typeof m!="object")continue;let y=typeof m.from=="string"?m.from:"",S=typeof m.to=="string"?m.to:"";!y||!S||(d.add(y),d.add(S),u.has(y)||u.set(y,new Set),u.get(y).add(S),l.has(S)||l.set(S,new Set),l.get(S).add(y))}if(!d.has(t))return n.withDetail?o:[];let h=n.both===!0,p=m=>{if(h){let O=i.get(m)??[],_=l.get(m),R=a.get(m),k=u.get(m),$=[...O];return _&&$.push(..._),R&&$.push(...R),k&&$.push(...k),$}if(r==="upstream"){let O=i.get(m)??[],_=l.get(m);return _?[...O,..._]:O}let y=a.get(m),S=u.get(m),x=y?[...y]:[];return S&&x.push(...S),x},f=new Set([t]),c=new Map,g=[{path:t,depth:0}],b=0,v=!1;for(;b<g.length;){let m=g[b++];if(s!=null&&m.depth>=s){p(m.path).length>0&&(v=!0);continue}for(let y of p(m.path))!y||f.has(y)||(f.add(y),c.set(y,m.depth+1),g.push({path:y,depth:m.depth+1}))}let w=[...c.keys()].sort((m,y)=>m<y?-1:m>y?1:0);return n.withDetail?{paths:w,depths:c,truncated:v}:w}function nn(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){let n=e[r],o=t[r];if(n.path!==o.path||n.type!==o.type||n.status!==o.status||n.hop!==o.hop||n.dep_index!==o.dep_index||n.annotation!==o.annotation||n.value!==o.value||n.lastMutation!==o.lastMutation)return!1;let s=n.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}export{ae as a,Ie as b,A as c,ft as d,He as e,Ve as f,B as g,q as h,Wt as i,Ce as j,tn as k,st as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as G,d as F}from"./chunk-
|
|
1
|
+
import{b as G,d as F}from"./chunk-ZGVA2SR5.js";import{c as E}from"./chunk-O32GJOUJ.js";import{a as A}from"./chunk-JUJEPZOI.js";import{j as I}from"./chunk-5KPIYVCC.js";import{b as q}from"./chunk-RLMYS3XZ.js";import{C as M}from"./chunk-MQZWA3DF.js";import{E as d,G as o,H as O,m as S}from"./chunk-LYCLF26R.js";import{b as V}from"./chunk-QYADASLV.js";var $={};V($,{contentModerationGraph:()=>Q,dataQualityGraph:()=>T,issueTrackerGraph:()=>B,observabilityGraph:()=>D});function s(u,a){return E("domain_template",u,a)}function D(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=[{name:"errors",classify:e=>C(e,"error")},{name:"traces",classify:e=>C(e,"trace")},{name:"metrics",classify:e=>C(e,"metric")}],m=a.branches??h,y=m.map(e=>({name:e.name,classify:e.classify})),c=A("stratify",a.source,y);n.mount("stratify",c);let k=m.map(e=>{try{let i=n.resolve(`stratify::branch/${e.name}`);return o([i],([x])=>x,{initial:null})}catch{return d(null)}}),l=a.correlate??(e=>e),_=o(k,e=>l(e),{meta:s("observability",{stage:"correlate"})});n.add(_,{name:"correlate"});let N=a.sloCheck??(()=>({pass:!0})),w=o([_],e=>e[0],{meta:s("observability",{stage:"slo_value"})}),f=o([w],e=>N(e[0]),{meta:s("observability",{stage:"slo_verified"})});n.add(w,{name:"slo_value"}),n.add(f,{name:"slo_verified"});let v=a.weights??m.map(()=>1),b=k.map(e=>o([e],i=>i[0]!=null?1:0)),p=v.map(e=>d(e));for(let e=0;e<b.length;e++)n.add(b[e],{name:`__signal_${e}`}),n.add(p[e],{name:`__weight_${e}`});let t=F(b,p);n.add(t,{name:"alerts"});let g=o([t,f],e=>({scored:e[0],slo:e[1]}),{meta:s("observability",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("observability",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([f],e=>{let i=e[0];return i&&i.pass===!1?i:null},{meta:s("observability",{stage:"feedback_condition"})});return n.add(r,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??5}),n}function B(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=0,m=e=>({id:`issue-${++h}`,title:String(e),severity:1,source:"unknown",raw:e}),y=a.extract??m,c=o([a.source],e=>y(e[0]),{meta:s("issue_tracker",{stage:"extract"})});n.add(c,{name:"extract"});let k=a.verify??(()=>({valid:!0})),l=o([c],e=>{let i=e[0];return{issue:i,verification:k(i)}},{meta:s("issue_tracker",{stage:"verify"})});n.add(l,{name:"verify"});let _=d([],{meta:s("issue_tracker",{stage:"known_patterns"})});n.add(_,{name:"known_patterns"});let N=a.detectRegression??(()=>({regression:!1})),w=o([c,_],e=>{let i=e[0],x=e[1];return{issue:i,regression:N(i,x)}},{meta:s("issue_tracker",{stage:"regression"})});n.add(w,{name:"regression"});let f=o([c],e=>e[0]?.severity??0),v=o([w],e=>e[0]?.regression?2:0);n.add(f,{name:"__severity_signal"}),n.add(v,{name:"__regression_signal"});let b=d(1),p=d(1.5);n.add(b,{name:"__severity_weight"}),n.add(p,{name:"__regression_weight"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([l,w,t],e=>({verified:e[0],regression:e[1],priority:e[2]}),{meta:s("issue_tracker",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("issue_tracker",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([l],e=>{let i=e[0];if(i){let x=i.verification;if(x&&x.valid===!1)return i}return null},{meta:s("issue_tracker",{stage:"feedback_condition"})});return n.add(r,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??3}),n}function Q(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=r=>({label:"review",confidence:.5,original:r}),m=a.classify??h,y=o([a.source],r=>m(r[0]),{meta:s("content_moderation",{stage:"classify"})});n.add(y,{name:"classify"});let c=A("stratify",y,[{name:"safe",classify:r=>r.label==="safe"},{name:"review",classify:r=>r.label==="review"},{name:"block",classify:r=>r.label==="block"}]);n.mount("stratify",c);let k=q([],{name:"review_queue",maxSize:a.maxQueueSize});n.add(k.entries,{name:"review_queue"});let l;try{l=n.resolve("stratify::branch/review")}catch{l=d(null),n.add(l,{name:"__review_fallback"})}let _=O([l],r=>{let e=r[0];e&&k.append(e)});n.add(_,{name:"__review_accumulator"}),n.addDisposer(M(_));let N=d({},{meta:s("content_moderation",{stage:"policy",access:"both",description:"Moderation policy rules \u2014 updated via feedback"})});n.add(N,{name:"policy"});let w=a.weights??[.1,1,2],f=o([y],r=>r[0]?.confidence??0),v=o([y],r=>{let e=r[0];return e?e.label==="block"?w[2]:e.label==="review"?w[1]:w[0]:0});n.add(f,{name:"__confidence_signal"}),n.add(v,{name:"__severity_signal"});let b=d(1),p=d(1);n.add(b,{name:"__w_confidence"}),n.add(p,{name:"__w_severity"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([y,t],r=>({classification:r[0],priority:r[1]}),{meta:s("content_moderation",{stage:"output"})});n.add(g,{name:"output"});let R=o([k.entries,N],r=>{let e=r[0];if(e&&e.length>0){let i=e[e.length-1];if(i&&i.falsePositive)return i}return null},{meta:s("content_moderation",{stage:"feedback_condition"})});return n.add(R,{name:"feedback_condition"}),G(n,"feedback_condition","policy",{maxIterations:a.maxFeedbackIterations??5}),n}function T(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=a.validate??(t=>({valid:!0,errors:[],record:t})),m=o([a.source],t=>t[0]!=null?h(t[0]):void 0,{meta:s("data_quality",{stage:"validate"})});n.add(m,{name:"validate"});let y=a.detectAnomaly??(t=>({anomaly:!1,score:0,record:t})),c=o([a.source],t=>t[0]!=null?y(t[0]):void 0,{meta:s("data_quality",{stage:"anomaly"})});n.add(c,{name:"anomaly"});let k=d(null,{meta:s("data_quality",{stage:"baseline",description:"Rolling baseline for drift detection"})});n.add(k,{name:"baseline"});let l=O([m],t=>{let g=t[0];g?.valid&&S(()=>{k.emit(g.record)})});n.add(l,{name:"__baseline_updater"}),M(l);let _=a.detectDrift??(()=>({drift:!1})),N=o([a.source,k],t=>_(t[0],t[1]),{meta:s("data_quality",{stage:"drift"})});n.add(N,{name:"drift"});let w=a.suggest??(()=>null),f=o([m,c],t=>w({validation:t[0],anomaly:t[1]}),{meta:s("data_quality",{stage:"remediate"})});n.add(f,{name:"remediate"});let v=o([m,c,N,f],t=>({validation:t[0],anomaly:t[1],drift:t[2],remediation:t[3]}),{meta:s("data_quality",{stage:"output"})});n.add(v,{name:"output"});let b=d([],{meta:s("data_quality",{stage:"validation_rules"})});n.add(b,{name:"validation_rules"});let p=o([c],t=>{let g=t[0];return g?.anomaly?g:null},{meta:s("data_quality",{stage:"feedback_condition"})});return n.add(p,{name:"feedback_condition"}),G(n,"feedback_condition","validation_rules",{maxIterations:a.maxFeedbackIterations??3}),n}function C(u,a){if(u==null||typeof u!="object")return!1;let n=u;return n.type===a||n.kind===a}export{D as a,B as b,Q as c,T as d,$ as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as f}from"./chunk-
|
|
1
|
+
import{j as f}from"./chunk-5KPIYVCC.js";import{E as d}from"./chunk-LYCLF26R.js";import{b as S}from"./chunk-CK2E7BTU.js";import{b}from"./chunk-QYADASLV.js";var g={};b(g,{create:()=>v});var m=()=>!1;function v(l){let o=new f("zustand"),t=d(void 0,{name:"state",equals:m});o.add(t,{name:"state"});let r=()=>t.cache,n=(e,s)=>{let a=t.cache,i=typeof e=="function"?e(a):e;t.emit(s?i:{...a,...i})},c={getState:r,setState:n,getInitialState:()=>T,subscribe:e=>{let s=!0,a=t.cache;return t.subscribe(i=>{for(let[u,p]of i)if(u===S){if(s){s=!1;continue}e(p,a),a=p}})},destroy:o.destroy.bind(o)},T=l(n,r,c);return t.emit(T),Object.assign(o,c)}export{v as a,g as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as A,x as v}from"./chunk-JJTF75VS.js";import{b as I}from"./chunk-TZQPPQEQ.js";import{m as p,s as y}from"./chunk-MQZWA3DF.js";import{E as R,G as w,m as h}from"./chunk-LYCLF26R.js";import{b}from"./chunk-CK2E7BTU.js";function z(t){return typeof t=="object"&&t!==null&&"cache"in t&&typeof t.subscribe=="function"}function F(t,a,e){let r=p(t),i=r.v!=null,g=R(e?.initialVerified??null,{...i?{meta:{sourceVersion:null}}:{}}),x=e?.trigger!==void 0&&e.trigger!==null,s=null;if(x&&e?.autoVerify?s=A(p(e.trigger),r):x?s=p(e.trigger):e?.autoVerify&&(s=r),s!==null){let d;if(s===r)d=v(r,c=>a(c));else{let c=r.cache;r.subscribe(f=>{for(let M of f)M[0]===b&&(c=M[1])}),d=v(s,()=>a(c))}y(d,c=>{h(()=>{if(g.down([[b,c]]),i){let f=r.v;f!=null&&g.meta.sourceVersion.down([[b,{id:f.id,version:f.version}]])}})})}return{node:r,verified:g,trigger:s}}function E(t){t.subscribe(()=>{})}function k(t){return t instanceof Map?t:new Map}function B(t,a){if(!Array.isArray(a.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");h(()=>{for(let{key:e,value:r}of a.upsert)t.set(e,r);for(let e of a.remove??[])t.delete(e)})}function G(t,a,e){let r=p(t),i=I(e.mapOptions??{}),g=e.budget??2e3,s=e.context!==void 0&&e.context!==null?p(e.context):R(null),d=k(i.entries.cache);i.entries.subscribe(o=>{for(let u of o)u[0]===b&&(d=k(u[1]))});let c=v(r,o=>a(o,d));if(y(c,o=>{B(i,o)}),e.evict){let o=new Map,u=w([i.entries],([l])=>{let m=[],N=k(l);for(let n of o.keys())N.has(n)||(o.get(n)(),o.delete(n));for(let[n,T]of N){let V=e.evict(n,T);if(z(V)){if(!o.has(n)){let S=y(V,D=>{D===!0&&i.has(n)&&i.delete(n)});o.set(n,S)}continue}if(typeof V=="boolean"){V&&m.push(n);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return m});y(u,l=>{for(let m of l)i.delete(m)})}let f=e.consolidateTrigger!==void 0&&e.consolidateTrigger!==null;if(e.consolidate&&f){let o=p(e.consolidateTrigger),u=v(o,()=>e.consolidate(d));y(u,l=>{B(i,l)})}let M=w([i.entries,s],([o,u])=>{let l=[...k(o).entries()].map(([n,T])=>({key:n,value:T,score:e.score(T,u),cost:e.cost(T)}));l.sort((n,T)=>T.score-n.score);let m=[],N=g;for(let n of l)n.cost<=N&&(m.push({key:n.key,value:n.value,score:n.score}),N-=n.cost);return m}),O=w([i.entries],([o])=>k(o).size);return E(M),E(O),{store:i,compact:M,size:O}}export{F as a,G as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as E}from"./chunk-ESMPEKEV.js";import{a as g,b as B,i as L}from"./chunk-4VVTGLXJ.js";import{m as I}from"./chunk-MQZWA3DF.js";import{D as _,F as R,m as M,o as S}from"./chunk-LYCLF26R.js";import{b,c as k,d as y,h as C,i as h,j as T}from"./chunk-CK2E7BTU.js";function O(e){return{describeKind:"derived",...e}}function V(e){return e<0?0:e}function F(e){return e[1]}function W(e){if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("backoff strategy must return a finite number");return e<0?0:e}function te(e,i){return typeof e=="function"?j(e,i):U(e,i)}function U(e,i){let r=i?.count,n=i?.backoff,c=r!==void 0?r:n===void 0?0:2147483647;if(c<0)throw new RangeError("retry count must be >= 0");let u=n===void 0?null:typeof n=="string"?L(n):n;return R(t=>{let o=0,l=!1,s=null,f,a=new E;function w(){f?.(),f=void 0}function N(p){if(l)return;if(o>=c){w(),t.down([[T,p]]);return}let m=u===null?0:u(o,p,s);if(m==null){w(),t.down([[T,p]]);return}let d;try{d=W(m)}catch{w(),t.down([[T,p]]);return}s=d,o+=1,w();let x=d>0?d/1e6:1;a.start(x,()=>{l||v()})}function v(){a.cancel(),w(),f=e.subscribe(p=>{if(!l)for(let m of p){let d=m[0];if(d===k)t.down([[k]]);else if(d===b)o=0,s=null,t.emit(m[1]);else if(d===y)t.down([[y]]);else if(d===h)w(),t.down([[h]]);else if(d===T){N(F(m));return}else t.down([m])}})}return v(),()=>{l=!0,a.cancel(),w()}},{...O(),initial:e.cache})}function j(e,i){let r=i?.count,n=i?.backoff,c=r!==void 0?r:n===void 0?0:2147483647;if(c<0)throw new RangeError("retry count must be >= 0");let u=n===void 0?null:typeof n=="string"?L(n):n;return R(t=>{let o=0,l=!1,s=null,f,a=new E;function w(){f?.(),f=void 0}function N(p){if(l)return;if(o>=c){w(),t.down([[T,p]]);return}let m=u===null?0:u(o,p,s);if(m==null){w(),t.down([[T,p]]);return}let d;try{d=W(m)}catch{w(),t.down([[T,p]]);return}s=d,o+=1,w();let x=d>0?d/1e6:1;a.start(x,()=>{l||v()})}function v(){a.cancel(),w();let p;try{p=e()}catch(m){N(m);return}f=p.subscribe(m=>{if(!l)for(let d of m){let x=d[0];if(x===k)t.down([[k]]);else if(x===b)o=0,s=null,t.emit(d[1]);else if(x===y)t.down([[y]]);else if(x===h)w(),t.down([[h]]);else if(x===T){N(F(d));return}else t.down([d])}})}return v(),()=>{l=!0,a.cancel(),w()}},{...O(),initial:i?.initial})}var P=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};function ne(e){let i=Math.max(1,e?.failureThreshold??5),r=V(e?.cooldownNs??30*1e9),n=e?.cooldown??null,c=Math.max(1,e?.halfOpenMax??1),u=e?.now??S,t="closed",o=0,l=0,s=0,f=r,a=0;function w(){if(!n)return r;let p=n(l);return p!==null?p:r}function N(){t="open",f=w(),s=u(),a=0}return{canExecute(){return t==="closed"?!0:t==="open"?u()-s>=f?(t="half-open",a=1,!0):!1:a<c?(a++,!0):!1},recordSuccess(){t==="half-open"?(t="closed",o=0,l=0):t==="closed"&&(o=0)},recordFailure(p){if(t==="half-open"){l++,N();return}t==="closed"&&(o++,o>=i&&N())},get state(){return t},get failureCount(){return o},reset(){t="closed",o=0,l=0,a=0}}}function re(e,i){let r=i?.onOpen??"skip";return n=>{let c=_([],(u,t)=>{function o(){c.meta.breakerState.down([[b,e.state]])}let l=n.subscribe(s=>{for(let f of s){let a=f[0];a===k?t.down([[k]]):a===b?e.canExecute()?(o(),t.emit(f[1])):(o(),r==="error"?t.down([[T,new P]]):t.down([[y]])):a===y?t.down([[y]]):a===h?(e.recordSuccess(),o(),t.down([[h]])):a===T?(e.recordFailure(F(f)),o(),t.down([f])):t.down([f])}});return o(),l},{...O(),meta:{breakerState:e.state},completeWhenDepsComplete:!1,initial:n.cache});return{node:c,breakerState:c.meta.breakerState}}}function K(e,i){if(e<=0)throw new RangeError("capacity must be > 0");if(i<0)throw new RangeError("refillPerSecond must be >= 0");let r=e,n=S();function c(u){if(i>0){let t=u-n;r=Math.min(e,r+t/1e9*i)}n=u}return{available(){return c(S()),r},tryConsume(u=1){if(u<=0)return!0;let t=S();return c(t),r>=u?(r-=u,!0):!1},putBack(u=1){u<=0||(c(S()),r=Math.min(e,r+u))}}}var A=class extends Error{name="RateLimiterOverflowError";constructor(i){super(`rateLimiter buffer overflow (maxBuffer=${i})`)}};function oe(e,i){let{maxEvents:r,windowNs:n}=i;if(r<=0)throw new RangeError("maxEvents must be > 0");if(n<=0)throw new RangeError("windowNs must be > 0");let c=i.maxBuffer;if(c!==void 0&&c<1)throw new RangeError("maxBuffer must be >= 1");let u=i.onOverflow??"drop-newest",t=r*1e9/n;return R(o=>{let l=K(r,t),s=[],f=new E,a=!1,w=1e9/t;function N(){for(;s.length>0;)if(l.tryConsume(1))o.emit(s.shift());else{f.start(Math.max(1,w/1e6),N);return}}let v=e.subscribe(p=>{for(let m of p){if(a)return;let d=m[0];if(d===k)o.down([[k]]);else if(d===b){if(c!==void 0&&s.length>=c){if(u!=="drop-newest")if(u==="drop-oldest")s.shift(),s.push(m[1]);else{a=!0,f.cancel(),s.length=0,o.down([[T,new A(c)]]);return}}else s.push(m[1]);N()}else if(d===y)o.down([[y]]);else if(d===h)a=!0,f.cancel(),s.length=0,o.down([[h]]);else if(d===T)a=!0,f.cancel(),s.length=0,o.down([m]);else if(d===C){a=!0,f.cancel(),s.length=0,o.down([m]);return}else o.down([m])}});return()=>{a=!0,f.cancel(),v()}},{...O(),initial:e.cache})}function ie(e,i){let r=i?.initialStatus??"pending",n=_([],(c,u)=>{let t=r;return n.meta.status.down([[b,r]]),n.meta.error.down([[b,null]]),e.subscribe(l=>{for(let s of l){let f=s[0];if(f===k)u.down([[k]]);else if(f===b)t==="errored"?M(()=>{n.meta.error.down([[b,null]]),n.meta.status.down([[b,"active"]])}):n.meta.status.down([[b,"active"]]),t="active",u.emit(s[1]);else if(f===y)u.down([[y]]);else if(f===h)n.meta.status.down([[b,"completed"]]),t="completed",u.down([[h]]);else if(f===T){let a=F(s);M(()=>{n.meta.error.down([[b,a]]),n.meta.status.down([[b,"errored"]])}),t="errored",u.down([s])}else u.down([s])}})},{...O(),meta:{status:r,error:null},completeWhenDepsComplete:!1,resubscribable:!0,initial:e.cache});return{node:n,status:n.meta.status,error:n.meta.error}}var D=class extends Error{name="TimeoutError";constructor(i){super(`Timed out after ${i/1e6}ms`)}};function $(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function Y(e){return e!=null&&typeof e.then=="function"}function q(e){return e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function"}function se(e,i){return R(r=>{let n,c;function u(){c?.(),c=void 0,$(i)||Y(i)||q(i)?n=I(i).subscribe(o=>{r.down(o)}):(r.emit(i),r.down([[h]]))}return c=e.subscribe(t=>{for(let o of t){let l=o[0];if(l===k)r.down([[k]]);else if(l===b)r.emit(o[1]);else if(l===y)r.down([[y]]);else if(l===h)r.down([[h]]);else if(l===T){u();return}else if(l===C){n?.(),r.down([o]);return}else r.down([o])}}),()=>{c?.(),n?.()}},{...O(),initial:e.cache})}function ue(e,i){if(i<=0)throw new RangeError("timeoutNs must be > 0");return R(r=>{let n=!1,c=new E;function u(){let o=i/1e6;c.start(o,()=>{n||(n=!0,t(),r.down([[T,new D(i)]]))})}let t=e.subscribe(o=>{for(let l of o){if(n)return;let s=l[0];if(s===k)r.down([[k]]);else if(s===b)u(),r.emit(l[1]);else if(s===y)r.down([[y]]);else if(s===h){c.cancel(),n=!0,r.down([[h]]);return}else if(s===T){c.cancel(),n=!0,r.down([l]);return}else if(s===C){c.cancel(),n=!0,r.down([l]);return}else r.down([l])}});return u(),()=>{n=!0,c.cancel(),t()}},{...O(),initial:e.cache})}export{te as a,P as b,ne as c,re as d,K as e,A as f,oe as g,ie as h,D as i,se as j,ue as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as S}from"./chunk-O32GJOUJ.js";import{j as l}from"./chunk-5KPIYVCC.js";import{b as M}from"./chunk-RLMYS3XZ.js";import{C as o}from"./chunk-MQZWA3DF.js";import{D as P,E as v,G as _,m as N}from"./chunk-LYCLF26R.js";import{b as L,i as I}from"./chunk-CK2E7BTU.js";import{b as C}from"./chunk-QYADASLV.js";var U={};C(U,{MessagingHubGraph:()=>w,SubscriptionGraph:()=>T,TopicBridgeGraph:()=>y,TopicGraph:()=>m,TopicRegistry:()=>O,messagingHub:()=>H,subscription:()=>D,topic:()=>z,topicBridge:()=>F});var R=256;function c(i,e){if(!Number.isFinite(i)||!Number.isInteger(i)||i<0)throw new Error(`${e} must be a non-negative integer`);return i}function a(i,e){return S("messaging",i,e)}var B=1024,m=class extends l{_log;events;latest;hasLatest;constructor(e,s={}){super(e,s.graph),this._log=M([],{name:"events",maxSize:s.retainedLimit??B}),this._log.withLatest(),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=_([this.events],([t])=>{let n=t;return n.length===0?null:n[n.length-1]},{name:"latest",describeKind:"derived",meta:a("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(o(this.latest)),this.hasLatest=_([this.events],([t])=>t.length>0,{name:"hasLatest",describeKind:"derived",meta:a("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(o(this.hasLatest)),this.addDisposer(()=>{this.events.down([[I]])}),this.addDisposer(()=>this._log.disposeAllViews())}publish(e){if(e===void 0)throw new TypeError(`TopicGraph "${this.name}": publish(undefined) is not allowed (spec \xA75.12 SENTINEL).`);this._log.append(e)}attachEventStorage(e){return this._log.attachStorage(e)}retained(){return this.events.cache}get _logBundle(){return this._log}},T=class extends l{cursor;available;topic;_disposed=!1;constructor(e,s,t={}){super(e,t.graph),this.topic=s;let n;if(t.from!==void 0?t.from==="retained"?n=0:t.from==="now"?n=s.events.cache.length:n=c(t.from,"subscription from"):n=c(t.cursor??0,"subscription cursor"),this.cursor=v(n,{name:"cursor",describeKind:"state",meta:a("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=s._logBundle.view({kind:"fromCursor",cursor:this.cursor}),this.add(this.available,{name:"available"}),this.addDisposer(o(this.available)),t.advanceOn!==void 0){let r=t.advanceOn,b=!1,d=P([r],()=>{if(!b){b=!0;return}if(this._disposed)return;let p=this.available.cache;if(p.length===0)return;let g=this.cursor.cache+p.length;this.cursor.emit(g)},{name:"advancePump",describeKind:"effect",meta:a("subscription_advance_pump")});this.add(d,{name:"advancePump"}),this.addDisposer(o(d))}}ack(e){if(this._disposed)return this.cursor.cache;let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription ack count"),n=Math.min(t,s.length);if(n<=0)return this.cursor.cache;let r=this.cursor.cache+n;return this.cursor.emit(r),r}pull(e){if(this._disposed)return[];let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription pull limit");return s.slice(0,t)}pullAndAck(e){if(this._disposed)return{items:[],cursor:this.cursor.cache};let s=this.available.cache,t=e===void 0?s.length:c(e,"subscription pullAndAck limit"),n=s.slice(0,t);if(n.length===0)return{items:n,cursor:this.cursor.cache};let r=this.cursor.cache+n.length;return this.cursor.emit(r),{items:n,cursor:r}}dispose(){this._disposed||(this._disposed=!0,this.cursor.down([[I]]),this.destroy())}},y=class extends l{_sourceSub;bridgedCount;output;constructor(e,s,t,n={}){super(e,n.graph),this._sourceSub=D(`${e}-subscription`,s,{cursor:n.cursor}),this.mount("subscription",this._sourceSub);let r=Math.max(1,c(n.maxPerPump??R,"topic bridge maxPerPump")),b=n.map??(u=>u);this.output=_([this._sourceSub.available],([u])=>{let f=u,h=[],k=Math.min(f.length,r);for(let x=0;x<k;x++){let A=b(f[x]);A!==void 0&&h.push(A)}return h},{name:"output",describeKind:"derived",meta:a("topic_bridge_output",{targetRef:t.name}),initial:[]}),this.add(this.output,{name:"output"}),this.addDisposer(o(this.output)),this.bridgedCount=v(0,{name:"bridgedCount",describeKind:"state",meta:a("topic_bridge_count")}),this.add(this.bridgedCount,{name:"bridgedCount"}),this.addDisposer(o(this.bridgedCount));let d=this.output,p=this._sourceSub,g=this.bridgedCount,G=P([d],()=>{let u=d.cache;if(u.length===0)return;let f=p.available.cache.length,h=Math.min(f,r);if(h>0){p.ack(h);let k=g.cache??0;g.emit(k+u.length)}},{name:"ackPump",describeKind:"effect",meta:a("topic_bridge_ack_pump")});this.add(G,{name:"ackPump"}),this.addDisposer(o(G));let E=K(this.output,t);this.addDisposer(E)}};function K(i,e){return i.subscribe(s=>{for(let t of s){if(t[0]!==L)continue;let n=t[1];n.length!==0&&N(()=>{for(let r of n)e.publish(r)})}})}var O=class{_map=new Map;version;constructor(e){this.version=e}get size(){return this._map.size}has(e){return this._map.has(e)}get(e){return this._map.get(e)}set(e,s){this._map.set(e,s)}delete(e){return this._map.delete(e)}keys(){return this._map.keys()}},w=class extends l{_registry;version;_defaultTopicOptions;constructor(e,s={}){super(e,s.graph);let t=v(0,{name:"version",describeKind:"state",meta:a("hub_version")});this.add(t,{name:"version"}),this.version=t,this._registry=new O(t),this._defaultTopicOptions={...s.defaultTopicOptions??{}}}get size(){return this._registry.size}has(e){return this._registry.has(e)}topicNames(){return this._registry.keys()}topic(e,s){let t=this._registry.get(e);if(t===void 0){let n={...this._defaultTopicOptions,...s??{}};t=new m(e,n),this._registry.set(e,t),this.mount(e,t);let r=this.version.cache??0;this.version.emit(r+1)}return t}publish(e,s){this.topic(e).publish(s)}publishMany(e){N(()=>{for(let[s,t]of e)this.topic(s).publish(t)})}subscribe(e,s,t){let n=this.topic(s);return new T(e,n,t)}removeTopic(e){if(!this._registry.has(e))return!1;try{this.remove(e)}finally{this._registry.delete(e);let s=this.version.cache??0;this.version.emit(s+1)}return!0}};function z(i,e){return new m(i,e)}function H(i,e){return new w(i,e)}function D(i,e,s){return new T(i,e,s)}function F(i,e,s,t){return new y(i,e,s,t)}export{m as a,T as b,y as c,O as d,w as e,z as f,H as g,D as h,F as i,U as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as M,c as re,d as se}from"./chunk-CUQFO6MT.js";import{c as ae}from"./chunk-O32GJOUJ.js";import{j as ne}from"./chunk-5KPIYVCC.js";import{b as J}from"./chunk-RLMYS3XZ.js";import{C as z}from"./chunk-MQZWA3DF.js";import{D as ee,E as te,G as j,m as Y,p as R,t as D}from"./chunk-LYCLF26R.js";import{b as X}from"./chunk-CK2E7BTU.js";import{b as ge}from"./chunk-QYADASLV.js";var fe={};ge(fe,{CqrsGraph:()=>G,cqrs:()=>ve,cqrsEventKeyOf:()=>ue,dispatchKeyOf:()=>pe,sagaInvocationKeyOf:()=>he});var x=class extends Error{constructor(e,n){super(e,n),this.name=this.constructor.name}},B=class extends x{constructor(n,t){super(`Duplicate ${n} registration: "${t}"`);this.kind=n;this.registrationName=t}},N=class extends x{constructor(n,t,r){super(`Command "${n}" emitted undeclared event "${t}". Declared emits: [${r.join(", ")}]`);this.commandName=n;this.eventName=t;this.declaredEmits=r}},K=class extends x{constructor(n,t,r){super(`Optimistic concurrency conflict on aggregate "${n}": expected version ${t}, got ${r}`);this.aggregateId=n;this.expected=t;this.actual=r}},H=class extends x{constructor(n){super(`Unknown command: "${n}". Register with command() first.`);this.commandName=n}},O=class extends x{constructor(n,t){super(`Command handler "${n}" threw: ${t instanceof Error?t.message:String(t)}`,{cause:t});this.commandName=n}};var P=class extends x{constructor(n,t){super(`Projection "${n}" rebuild failed: ${t instanceof Error?t.message:String(t)}`,{cause:t});this.projectionName=n}};var ce=D((a,e)=>{a("write"),a("signal"),e("observe")}),le=D((a,e)=>{a("observe"),a("signal"),e("write")}),oe=D((a,e)=>{a("observe"),a("signal"),e("write")});function $(a,e){return ae("cqrs",a,e)}function Z(a){if(a===null||typeof a!="object"||Object.isFrozen(a))return a;for(let e of Object.keys(a))Z(a[e]);return Object.freeze(a)}var ue=a=>`${a.type}::${a.aggregateId??"__default__"}`,pe=a=>a.commandName,he=a=>a.eventType,G=class extends ne{_eventLogs=new Map;_eventLogsByAggregate=new Map;_aggregateVersions=new Map;_aggregateLru=new Map;_commandRegs=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_seq=0;_retainedLimit;_freezeCommandPayload;_freezeEventPayload;_maxAggregates;_dispatchSeqCursor;dispatches;audit;aggregateEvictions;constructor(e,n={}){super(e,n.graph),this._retainedLimit=n.retainedLimit??1024,this._freezeCommandPayload=n.freezeCommandPayload??!0,this._freezeEventPayload=n.freezeEventPayload??!0,this._maxAggregates=n.maxAggregates??1e4,this.dispatches=M({name:"dispatches",retainedLimit:this._retainedLimit,graph:this}),this.audit=this.dispatches,this.aggregateEvictions=M({name:"aggregateEvictions",retainedLimit:this._retainedLimit,graph:this}),this._dispatchSeqCursor=re(this,"dispatch_seq",0)}aggregateVersion(e,n){return this._aggregateVersions.get(`${e}::${n}`)??0}_touchAggregate(e){this._aggregateLru.delete(e),this._aggregateLru.set(e,!0)}_enforceAggregateLru(){for(;this._aggregateLru.size>this._maxAggregates;){let e=this._aggregateLru.keys().next();if(e.done)break;let n=e.value;this._aggregateLru.delete(n);let t=n.indexOf("::");if(t<0)continue;let r=n.slice(0,t),s=n.slice(t+2),o=this._aggregateVersions.get(n)??0;this._aggregateVersions.delete(n);let i=this._eventLogsByAggregate.get(r);i&&(i.delete(s),i.size===0&&this._eventLogsByAggregate.delete(r)),this.aggregateEvictions.append({aggregateId:s,type:r,lastVersion:o,t_ns:R()})}}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}_attachedEventTiers=[];_attachedTierDisposers=new Map;attachEventStorage(e){this._attachedEventTiers.push(e);for(let[n,t]of this._eventLogs){let r=t.log.attachStorage(e),s=this._attachedTierDisposers.get(n);s||(s=[],this._attachedTierDisposers.set(n,s)),s.push(r)}for(let[n,t]of this._eventLogsByAggregate)for(let[r,s]of t){let o=`${n}::${r}`,i=s.log.attachStorage(e),c=this._attachedTierDisposers.get(o);c||(c=[],this._attachedTierDisposers.set(o,c)),c.push(i)}return()=>{let n=this._attachedEventTiers.indexOf(e);n>=0&&this._attachedEventTiers.splice(n,1)}}_autoWireStreamStorage(e,n){if(this._attachedEventTiers.length===0)return;let t=this._attachedTierDisposers.get(e);t||(t=[],this._attachedTierDisposers.set(e,t));for(let r of this._attachedEventTiers)t.push(n.attachStorage(r))}_bumpDispatchSeq(){let n=(this._dispatchSeqCursor.cache??0)+1;return this._dispatchSeqCursor.emit(n),n}event(e,n){if(n!==void 0)return this._ensureAggregateStream(e,n).node;let t=this._eventLogs.get(e);if(t)return t.node;let r=J([],{name:e,versioning:0,maxSize:this._retainedLimit});r.withLatest();let s=r.entries,o=j([s],([i])=>i,{name:e,describeKind:"state",meta:$("event",{event_name:e}),guard:oe,initial:s.cache});return this.add(o,{name:e}),this._keepaliveDisposers.push(z(o)),this._eventLogs.set(e,{log:r,node:o}),this._autoWireStreamStorage(e,r),o}_ensureAggregateStream(e,n){this._eventLogs.has(e)||this.event(e);let t=this._eventLogsByAggregate.get(e);t||(t=new Map,this._eventLogsByAggregate.set(e,t));let r=`${e}::${n}`;this._touchAggregate(r);let s=t.get(n);if(s)return s;let o=`${e}_${n.replace(/[^a-zA-Z0-9_-]/g,"_")}`,i=J([],{name:o,versioning:0,maxSize:this._retainedLimit});i.withLatest();let c=i.entries,h=j([c],([p])=>p,{name:o,describeKind:"state",meta:$("event_aggregate",{event_name:e,aggregate_id:n}),guard:oe,initial:c.cache}),l=o,m=0;for(;this.nameOf(this.resolveOptional(l)??h)===l&&(m+=1,l=`${o}_${m}`,this.resolveOptional(l)!==void 0););try{this.add(h,{name:l})}catch{}this._keepaliveDisposers.push(z(h));let u={log:i,node:h};return t.set(n,u),this._autoWireStreamStorage(`${e}::${n}`,i),this._enforceAggregateLru(),u}resolveOptional(e){try{return this.resolve(e)}catch{return}}_appendEvent(e,n,t){let r=this._eventLogs.get(e);if(r||(this.event(e),r=this._eventLogs.get(e)),r.node.status==="completed"||r.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${r.node.status}).`);let s,o;if(t?.aggregateId!==void 0){let l=`${e}::${t.aggregateId}`;s=(this._aggregateVersions.get(l)??0)+1,this._aggregateVersions.set(l,s),o=this._ensureAggregateStream(e,t.aggregateId)}let i=r.log.entries.v,c=this._freezeEventPayload?Z(n):n,h={type:e,payload:c,timestampNs:R(),seq:++this._seq,...t?.aggregateId!==void 0?{aggregateId:t.aggregateId}:{},...s!==void 0?{aggregateVersion:s}:{},...t?.correlationId!==void 0?{correlationId:t.correlationId}:{},...t?.causationId!==void 0?{causationId:t.causationId}:{},...t?.metadata!==void 0?{metadata:Object.freeze({...t.metadata})}:{},...t?.handlerVersion!==void 0?{handlerVersion:t.handlerVersion}:{},...i!=null?{v0:{id:i.id,version:i.version}}:{}};return r.log.append(h),o&&o.log.append(h),h}command(e,n){if(this._commandRegs.has(e))throw new B("command",e);let t=typeof n=="function"?{handler:n}:n,r=te(void 0,{name:e,describeKind:"state",meta:{...$("command",{command_name:e}),error:null},guard:ce});if(this.add(r,{name:e}),this._commandRegs.set(e,{handler:t.handler,...t.emits!==void 0?{emits:t.emits}:{},...t.handlerVersion!==void 0?{handlerVersion:t.handlerVersion}:{}}),t.emits)for(let s of t.emits)this._eventLogs.has(s)||this.event(s);return r}dispatch(e,n,t){let r=this._commandRegs.get(e);if(!r)throw new H(e);if(t?.aggregateId!==void 0&&t.expectedAggregateVersion!==void 0&&r.emits!==void 0){let u=0;for(let p of r.emits){let _=this._aggregateVersions.get(`${p}::${t.aggregateId}`);_!==void 0&&_>u&&(u=_)}if(u!==t.expectedAggregateVersion)throw new K(t.aggregateId,t.expectedAggregateVersion,u)}let s=this.resolve(e),o=this._freezeCommandPayload?Z(n):n,i=[],c=R(),h=0,l,m=!1;try{Y(()=>{h=this._bumpDispatchSeq(),s.emit(o,{internal:!0});try{r.handler(o,{emit:(u,p)=>{if(r.emits!==void 0&&!r.emits.includes(u))throw new N(e,u,r.emits);i.push(u),this._appendEvent(u,p,{...t?.aggregateId!==void 0?{aggregateId:t.aggregateId}:{},...t?.correlationId!==void 0?{correlationId:t.correlationId}:{},...t?.causationId!==void 0?{causationId:t.causationId}:{},...t?.metadata!==void 0?{metadata:Object.freeze({...t.metadata})}:{},...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}}),s.meta.error.emit(null,{internal:!0}),this.dispatches.append({commandName:e,payload:o,status:"success",emittedEvents:[...i],t_ns:c,seq:h,...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}catch(u){throw l=u,m=!0,u}})}catch(u){if(m){s.meta.error.emit(l,{internal:!0});let p=l instanceof Error?l.name:typeof l,_=l instanceof O?l:new O(e,l);this.dispatches.append({commandName:e,payload:o,status:"failed",error:_,errorType:p,emittedEvents:[...i],t_ns:c,seq:h,...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}throw m?l:u}}projection(e){let{name:n,events:t,reducer:r,initial:s}=e,o=e.mode??"scan",i=e.freezeInputs??!0,c=e.snapshot,h=t.map(d=>(this._eventLogs.has(d)||this.event(d),this._eventLogs.get(d).node));function l(d){d.sort((g,v)=>g.timestampNs-v.timestampNs||g.seq-v.seq||(g.aggregateId??"").localeCompare(v.aggregateId??""))}function m(d){let g=[];for(let v of d)g.push(...v);return l(g),g}let u=h.map(d=>d.cache??[]),p=m(u),_=i?Object.freeze(p):p,C=0,y=s;o==="scan"&&p.length>0&&(y=r(s,_),C=p.length);let q=o==="replay"?r(s,_):y,V=c?.saveDebounceMs??1e3,A=c?.saveEvery??1e3,E,L=0;function U(d){if(c?.save){if(L+=1,L>=A){L=0,E!==void 0&&(clearTimeout(E),E=void 0);let g=c.save(d);g instanceof Promise&&g.catch(()=>{});return}E!==void 0&&clearTimeout(E),E=setTimeout(()=>{E=void 0,L=0;let g=c.save(d);g instanceof Promise&&g.catch(()=>{})},V)}}let S=j(h,d=>{let g=m(d),v;if(o==="replay"){let w=i?Object.freeze(g):g;v=r(s,w)}else{let w=g.slice(C);C=g.length;let f=i?Object.freeze(w):w;v=r(y,f),y=v}return U(v),v},{name:n,describeKind:"derived",meta:$("projection",{projection_name:n,source_events:t}),guard:le,initial:q});return this.add(S,{name:n}),this._keepaliveDisposers.push(z(S)),this._keepaliveDisposers.push(()=>{E!==void 0&&(clearTimeout(E),E=void 0)}),this._projections.add(n),{node:S,rebuild:async d=>{try{let g=d?.pageSize??1e3,v=d?.fromTier??this._attachedEventTiers[0]?.[0],w=m(h.map(T=>T.cache??[])).length,f=s;if(c?.load){let T=await c.load();T!==void 0&&(f=T)}if(!v||!v.loadEntries){let T=m(h.map(I=>I.cache??[])),b=i?Object.freeze(T):T;f=r(f,b)}else{let T=new Set(t),b,I=!1;for(;!I;){let F=await v.loadEntries({cursor:b,pageSize:g}),W=[...F.entries].filter(de=>T.has(de.type));l(W);let ie=i?Object.freeze(W):W;f=r(f,ie),b=F.cursor,I=!b||F.entries.length===0}}if(o==="scan"){let T=m(h.map(I=>I.cache??[])),b=T.slice(w);if(b.length>0){let I=i?Object.freeze(b):b;f=r(f,I)}y=f,C=T.length}return S.emit(f,{internal:!0}),f}catch(g){throw new P(n,g)}},reset:async()=>{try{let d=s;if(c?.load){let f=await c.load();f!==void 0&&(d=f)}let g=m(h.map(f=>f.cache??[])),v=i?Object.freeze(g):g,w=r(d,v);return o==="scan"&&(y=w,C=g.length),S.emit(w,{internal:!0}),w}catch(d){throw new P(n,d)}}}}saga(e,n,t,r={}){let s=n.map(p=>(this._eventLogs.has(p)||this.event(p),this._eventLogs.get(p).node)),o=se(this,`${e}_cursor`,n,0),i=M({name:`${e}_invocations`,retainedLimit:this._retainedLimit,graph:this}),c=r.aggregateId,h=r.errorPolicy??"advance",l=new Map;for(let p of n){let _=o[p];l.set(p,_.cache??0);let C=_.subscribe(y=>{for(let q of y)q[0]===X&&l.set(p,q[1])});this._keepaliveDisposers.push(C)}let m={},u=ee(s,(p,_)=>{let C=m.n.meta.error;for(let y=0;y<p.length;y++){let q=p[y];if(q==null||q.length===0)continue;let V=q.at(-1);if(!V)continue;let A=n[y],E=o[A],L=l.get(A)??0;if(V.length>L){let U=V.slice(L),S=L;for(let Q of U){let k=Q;if(c!==void 0&&k.aggregateId!==c){S+=1;continue}try{t(k),C.emit(null,{internal:!0}),i.append({eventType:A,status:"success",aggregateId:k.aggregateId,event:k,t_ns:R(),...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),S+=1}catch(d){if(C.emit(d,{internal:!0}),i.append({eventType:A,status:"failed",error:d,errorType:d instanceof Error?d.name:typeof d,aggregateId:k.aggregateId,event:k,t_ns:R(),...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),h==="hold")break;S+=1}}E.emit(S)}}},{name:e,describeKind:"effect",meta:{...$("saga",{saga_name:e,source_events:n}),error:null}});return m.n=u,this.add(u,{name:e}),this._keepaliveDisposers.push(z(u)),this._sagas.add(e),{node:u,invocations:i,audit:i,cursors:o}}};function ve(a,e){return new G(a,e)}export{ue as a,pe as b,he as c,G as d,ve as e,fe as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function o(n){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(o);let r=n,e=Object.keys(r).sort(),t={};for(let s of e)t[s]=o(r[s]);return t}function i(n){return JSON.stringify(o(n),void 0,0)}export{o as a,i as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as h}from"./chunk-5KPIYVCC.js";import{b as A}from"./chunk-RLMYS3XZ.js";import{E as p,m as b,p as y,t as T}from"./chunk-LYCLF26R.js";import{b as f,c as R}from"./chunk-CK2E7BTU.js";var L=T((e,r)=>{e("observe"),e("signal"),r("write")});function V(e){let r=A([],{name:e.name,maxSize:e.retainedLimit??1024,guard:e.guard??L,...e.versioning!=null?{versioning:e.versioning}:{}});return r.withLatest(),e.graph&&e.graph.add(r.entries,{name:e.name}),r}function x(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;for(let r of Object.keys(e))x(e[r]);return Object.freeze(e)}function k(e){let n=(e.cache??0)+1;return e.down([[R],[f,n]]),n}function z(e,r){let n=r.freeze??!0;return function(...d){let o=n?d.map(x):d,s=y(),i,u,c=!1,m;try{b(()=>{r.seq&&(m=k(r.seq));try{if(i=e(...o),r.onSuccess){let t=r.onSuccess(o,i,{t_ns:s,seq:m});if(t!==void 0){let g=r.handlerVersion!=null?{...t,handlerVersion:r.handlerVersion}:t;r.audit.append(g)}}}catch(t){throw u=t,c=!0,t}})}catch(t){if(c&&r.onFailure){let g=u instanceof Error?u.name:typeof u,l=r.onFailure(o,u,{t_ns:s,seq:m,errorType:g});if(l!==void 0){let w=r.handlerVersion!=null?{...l,handlerVersion:r.handlerVersion}:l;r.audit.append(w)}}throw c?u:t}return i}}function S(e,r,n=0){let a=p(n,{name:r,describeKind:"state"});return e.add(a,{name:r}),a}function q(e,r,n,a=0){let d={},o=new h(r);for(let s of n){let i=p(a,{name:s,describeKind:"state"});o.add(i,{name:s}),d[s]=i}return e.mount(r,o),d}export{V as a,z as b,S as c,q as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as P}from"./chunk-CE72X3WO.js";var O=new TextEncoder,M=new TextDecoder("utf-8",{fatal:!0}),h={name:"json",version:1,encode(e){return O.encode(P(e))},decode(e){return JSON.parse(M.decode(e))}};function U(){return h}function k(){let e=new Map;return{name:"memory",read(n){let o=e.get(n);return o===void 0?void 0:new Uint8Array(o)},write(n,o){e.set(n,new Uint8Array(o))},delete(n){e.delete(n)},list(n){let o=[...e.keys()];return n?o.filter(r=>r.startsWith(n)).sort():o.sort()}}}function w(e,n={}){let o=n.codec??h,r=n.name??e.name??"snapshot",d=n.keyOf??(c=>c.name??n.name??e.name??"snapshot"),a,m=0,T=n.compactEvery,l,f={name:r,debounceMs:n.debounceMs,compactEvery:T,filter:n.filter,keyOf:d,save(c){if(!(n.filter&&!n.filter(c))&&(a={snapshot:c},m+=1,T!==void 0&&m%T===0||!n.debounceMs))return s()},load(){let c=l??r,t=e.read(c);if(t!==void 0)return t instanceof Uint8Array?t.length===0?void 0:o.decode(t):Promise.resolve(t).then(i=>i===void 0||i.length===0?void 0:o.decode(i))},async flush(){await s()},async rollback(){a=void 0}};function s(){let c=a;if(!c)return;a=void 0;let t=d(c.snapshot),i=o.encode(c.snapshot),u=e.write(t,i);if(u instanceof Promise)return u.then(()=>{l=t});l=t}return f}function C(e,n={}){let o=n.codec??h,r=n.name??e.name??"append-log",d=n.keyOf??(t=>r),a=n.compactEvery,m=new Map,T=0,l,f={name:r,debounceMs:n.debounceMs,compactEvery:a,keyOf:d,appendEntries(t){if(t.length!==0){for(let i of t){let u=d(i),g=m.get(u);g||(g=[],m.set(u,g)),g.push(i)}if(T+=t.length,a!==void 0&&T%a===0||!n.debounceMs)return s()}},async loadEntries(t){let i=t?.keyFilter,u=e.list===void 0?i!==void 0?[i]:[r]:await Promise.resolve(e.list(i)),g=[];for(let v of u){let y=await Promise.resolve(e.read(v));if(y===void 0||y.length===0)continue;let p=o.decode(y);Array.isArray(p)&&g.push(...p)}return{entries:g,cursor:void 0}},async flush(){await s()},async rollback(){m=new Map}};function s(){if(m.size===0)return;let t=m;m=new Map;let i=(l??Promise.resolve()).then(()=>{let u=c(t);return u instanceof Promise?u:Promise.resolve()},()=>{let u=c(t);return u instanceof Promise?u:Promise.resolve()});return l=i.finally(()=>{l===i&&(l=void 0)}),l}function c(t){let i=[];for(let[u,g]of t){let v=e.read(u),y=p=>{let b=[...p===void 0||p.length===0?[]:o.decode(p)??[],...g],x=o.encode(b);return e.write(u,x)};if(v instanceof Promise)i.push(v.then(async p=>{let S=y(p);S instanceof Promise&&await S}));else{let p=y(v);p instanceof Promise&&i.push(p)}}if(i.length>0)return Promise.all(i).then(()=>{})}return f}function A(e,n={}){let o=n.codec??h,r=n.name??e.name??"kv",d=n.compactEvery,a=new Map,m=0,T={name:r,debounceMs:n.debounceMs,compactEvery:d,filter:n.filter,save(f,s){if(!(n.filter&&!n.filter(f,s))&&(a.set(f,s),m+=1,d!==void 0&&m%d===0||!n.debounceMs))return l()},load(f){let s=e.read(f);if(s!==void 0)return s instanceof Uint8Array?s.length===0?void 0:o.decode(s):Promise.resolve(s).then(c=>c===void 0||c.length===0?void 0:o.decode(c))},delete(f){if(a.delete(f),!!e.delete)return e.delete(f)},list(f){return e.list?e.list(f):[]},async flush(){await l()},async rollback(){a=new Map}};function l(){if(a.size===0)return;let f=a;a=new Map;let s=[];for(let[c,t]of f){let i=o.encode(t),u=e.write(c,i);u instanceof Promise&&s.push(u)}if(s.length>0)return Promise.all(s).then(()=>{})}return T}function B(e){return w(k(),e)}function K(e){return C(k(),e)}function L(e){return A(k(),e)}function R(e,n){let o={name:n?.name??"dict-kv",read(r){return e[r]},write(r,d){e[r]=new Uint8Array(d)},delete(r){delete e[r]},list(r){let d=Object.keys(e).sort();return r?d.filter(a=>a.startsWith(r)):d}};return A(o,n)}function j(e,n){return w({name:"dict",read(r){return e[r]},write(r,d){e[r]=new Uint8Array(d)},delete(r){delete e[r]},list(r){let d=Object.keys(e).sort();return r?d.filter(a=>a.startsWith(r)):d}},n)}export{h as a,U as b,k as c,w as d,C as e,A as f,B as g,K as h,L as i,R as j,j as k};
|