@graphrefly/graphrefly 0.38.0 → 0.40.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.
Files changed (321) hide show
  1. package/dist/budget-gate-CmmVtasH.d.ts +115 -0
  2. package/dist/budget-gate-DiP_nK0n.d.cts +115 -0
  3. package/dist/{cascading-BsJ4GbnS.d.ts → cascading-BNfxffgc.d.ts} +2 -2
  4. package/dist/{cascading-B25wxpRa.d.cts → cascading-Cxs1eztH.d.cts} +2 -2
  5. package/dist/chunk-2BX4NB34.js +3 -0
  6. package/dist/{chunk-6VFC334U.js → chunk-2DMKW2AD.js} +1 -1
  7. package/dist/{chunk-4BDQXBXE.js → chunk-2QXRYP7Q.js} +1 -1
  8. package/dist/chunk-32N3JALT.js +1 -0
  9. package/dist/chunk-35JTVPOX.js +1 -0
  10. package/dist/chunk-3G5U5QNE.js +5 -0
  11. package/dist/{chunk-PHXZRR6C.js → chunk-4I45FVQS.js} +1 -1
  12. package/dist/{chunk-B5S7KTGP.js → chunk-6I726LZU.js} +1 -1
  13. package/dist/{chunk-NV63VQHI.js → chunk-6VWBPSSY.js} +1 -1
  14. package/dist/chunk-6XVD5TZV.js +1 -0
  15. package/dist/chunk-756D5TFD.js +1 -0
  16. package/dist/{chunk-DSOVKKTI.js → chunk-7Q4ZD3YW.js} +1 -1
  17. package/dist/{chunk-TMVY7OWG.js → chunk-B7LCDQEV.js} +1 -1
  18. package/dist/chunk-C72GO4IZ.js +1 -0
  19. package/dist/{chunk-RZ5HKPGI.js → chunk-CKFQS2CJ.js} +1 -1
  20. package/dist/chunk-D27JNOLZ.js +1 -0
  21. package/dist/chunk-ECQRP2UT.js +1 -0
  22. package/dist/{chunk-6773HURD.js → chunk-FHRBBHJN.js} +1 -1
  23. package/dist/{chunk-UVLZX2OU.js → chunk-I2DEVPMU.js} +1 -1
  24. package/dist/chunk-INQFTVZA.js +61 -0
  25. package/dist/{chunk-6KZZ6XQE.js → chunk-J63M5U46.js} +1 -1
  26. package/dist/{chunk-POCWFIJ7.js → chunk-JKBOIJ22.js} +1 -1
  27. package/dist/chunk-K2Z7UENB.js +1 -0
  28. package/dist/chunk-L6NSJVJZ.js +1 -0
  29. package/dist/{chunk-K5C67OGE.js → chunk-LCGAVGGV.js} +2 -2
  30. package/dist/chunk-LYM4PBMV.js +1 -0
  31. package/dist/{chunk-O2BLVQU4.js → chunk-MNZIKXK4.js} +1 -1
  32. package/dist/chunk-N43XM7BM.js +1 -0
  33. package/dist/{chunk-FWGIZP3W.js → chunk-OSZ22J7O.js} +1 -1
  34. package/dist/{chunk-FAYEMS5M.js → chunk-PPUYQ66A.js} +1 -1
  35. package/dist/{chunk-SP5O2MIX.js → chunk-QSK3RRII.js} +1 -1
  36. package/dist/chunk-RZJDIV2G.js +1 -0
  37. package/dist/chunk-SSCGRYJ2.js +1 -0
  38. package/dist/chunk-SVFKHUCW.js +1 -0
  39. package/dist/chunk-TSOYJ743.js +1 -0
  40. package/dist/{chunk-O245YLM5.js → chunk-UWA6D7UF.js} +1 -1
  41. package/dist/chunk-VMF23LGB.js +1 -0
  42. package/dist/chunk-WL6LFPJB.js +1 -0
  43. package/dist/chunk-WUT362QV.js +1 -0
  44. package/dist/chunk-XJLYLLIJ.js +1 -0
  45. package/dist/{chunk-IBGE62GZ.js → chunk-XW4YDF6G.js} +1 -1
  46. package/dist/chunk-YKD7WUYJ.js +43 -0
  47. package/dist/{chunk-7KZZLWZ6.js → chunk-YXDRGKXP.js} +1 -1
  48. package/dist/chunk-Z4F3DOWS.js +84 -0
  49. package/dist/compat/index.cjs +9 -13
  50. package/dist/compat/index.d.cts +16 -16
  51. package/dist/compat/index.d.ts +16 -16
  52. package/dist/compat/index.js +1 -1
  53. package/dist/compat/jotai/index.d.cts +2 -2
  54. package/dist/compat/jotai/index.d.ts +2 -2
  55. package/dist/compat/nanostores/index.d.cts +2 -2
  56. package/dist/compat/nanostores/index.d.ts +2 -2
  57. package/dist/compat/nestjs/index.cjs +7 -11
  58. package/dist/compat/nestjs/index.d.cts +8 -8
  59. package/dist/compat/nestjs/index.d.ts +8 -8
  60. package/dist/compat/nestjs/index.js +1 -1
  61. package/dist/compat/react/index.d.cts +2 -2
  62. package/dist/compat/react/index.d.ts +2 -2
  63. package/dist/compat/solid/index.d.cts +2 -2
  64. package/dist/compat/solid/index.d.ts +2 -2
  65. package/dist/compat/svelte/index.d.cts +2 -2
  66. package/dist/compat/svelte/index.d.ts +2 -2
  67. package/dist/compat/vue/index.d.cts +2 -2
  68. package/dist/compat/vue/index.d.ts +2 -2
  69. package/dist/compat/zustand/index.cjs +3 -7
  70. package/dist/compat/zustand/index.d.cts +4 -4
  71. package/dist/compat/zustand/index.d.ts +4 -4
  72. package/dist/compat/zustand/index.js +1 -1
  73. package/dist/core/index.cjs +1 -1
  74. package/dist/core/index.d.cts +4 -4
  75. package/dist/core/index.d.ts +4 -4
  76. package/dist/core/index.js +1 -1
  77. package/dist/{composite-DTOlDuch.d.ts → decay-BnrlbxSv.d.ts} +39 -3
  78. package/dist/{composite-CgG0MqHm.d.cts → decay-C25AyNAj.d.cts} +39 -3
  79. package/dist/extra/browser.d.cts +1 -1
  80. package/dist/extra/browser.d.ts +1 -1
  81. package/dist/extra/index.cjs +16 -20
  82. package/dist/extra/index.d.cts +11 -9
  83. package/dist/extra/index.d.ts +11 -9
  84. package/dist/extra/index.js +1 -1
  85. package/dist/extra/node.cjs +2 -2
  86. package/dist/extra/node.d.cts +1 -1
  87. package/dist/extra/node.d.ts +1 -1
  88. package/dist/extra/node.js +1 -1
  89. package/dist/extra/operators.cjs +1 -1
  90. package/dist/extra/operators.d.cts +1 -1
  91. package/dist/extra/operators.d.ts +1 -1
  92. package/dist/extra/operators.js +1 -1
  93. package/dist/extra/reactive.cjs +1 -1
  94. package/dist/extra/reactive.d.cts +3 -3
  95. package/dist/extra/reactive.d.ts +3 -3
  96. package/dist/extra/reactive.js +1 -1
  97. package/dist/extra/render/index.cjs +5 -0
  98. package/dist/extra/render/index.d.cts +183 -0
  99. package/dist/extra/render/index.d.ts +183 -0
  100. package/dist/extra/render/index.js +1 -0
  101. package/dist/extra/sources.cjs +1 -1
  102. package/dist/extra/sources.d.cts +1 -1
  103. package/dist/extra/sources.d.ts +1 -1
  104. package/dist/extra/sources.js +1 -1
  105. package/dist/extra/storage-browser.d.cts +1 -1
  106. package/dist/extra/storage-browser.d.ts +1 -1
  107. package/dist/{fallback-axI2cXwt.d.cts → fallback-8JYU8tlT.d.cts} +1 -1
  108. package/dist/{fallback-DuEXfA4F.d.ts → fallback-CMZl39L5.d.ts} +1 -1
  109. package/dist/graph/index.cjs +7 -7
  110. package/dist/graph/index.d.cts +5 -5
  111. package/dist/graph/index.d.ts +5 -5
  112. package/dist/graph/index.js +1 -1
  113. package/dist/{graph-BjW1taJl.d.ts → graph-BkIkog4h.d.ts} +76 -100
  114. package/dist/{graph-CHsVwf9S.d.cts → graph-E6likq7w.d.cts} +76 -100
  115. package/dist/{index-CIcu6fIR.d.ts → index-2n8Eai6M.d.ts} +1 -1
  116. package/dist/{index-BwOsJfLJ.d.ts → index-3k4Gg6-n.d.ts} +3 -3
  117. package/dist/{index-BUFCHvOR.d.ts → index-40ZT4MHj.d.ts} +3 -3
  118. package/dist/index-8s-Qm-gz.d.ts +218 -0
  119. package/dist/index-A3U3CSve.d.cts +113 -0
  120. package/dist/{index-CDvC1m5p.d.ts → index-B2RUoIUz.d.ts} +1 -1
  121. package/dist/{index-Byp771zP.d.ts → index-B6iTqKtJ.d.ts} +2 -2
  122. package/dist/{index-D-B7U42V.d.cts → index-B72TQQHd.d.cts} +2 -2
  123. package/dist/{resilience-Bys63Cpd.d.ts → index-BAQrjuZF.d.ts} +202 -26
  124. package/dist/{index-BiomL7AW.d.ts → index-BJSZxSFX.d.ts} +1 -1
  125. package/dist/index-BQ1fR4li.d.ts +210 -0
  126. package/dist/{index-D7-RSD93.d.cts → index-BTHOTC0Q.d.cts} +4 -4
  127. package/dist/{index-CEVzBWeB.d.ts → index-BaA-xpSw.d.ts} +26 -19
  128. package/dist/{index-CAV-3RpJ.d.cts → index-Bd91Nmf4.d.cts} +4 -4
  129. package/dist/{index-BI1wMfyc.d.ts → index-BgjS2b8N.d.ts} +3 -3
  130. package/dist/{index-Bpr0Pwgl.d.cts → index-BiHUBEKq.d.cts} +3 -3
  131. package/dist/{index-UsU9ptzs.d.cts → index-BilOa6AE.d.cts} +55 -9
  132. package/dist/{index-DJVQ-t07.d.ts → index-BmSQLAZo.d.cts} +41 -48
  133. package/dist/{index-DTDVDzhA.d.ts → index-C-dkXOpB.d.cts} +56 -54
  134. package/dist/{index-B-ORMr3k.d.ts → index-C5cQ7Gfx.d.ts} +4 -4
  135. package/dist/{index-ML6vHKXK.d.ts → index-C6ZUaos7.d.ts} +1 -1
  136. package/dist/{index-Vz7KPfgz.d.ts → index-CAP3UGsq.d.ts} +1 -1
  137. package/dist/{index-BFaALJxR.d.ts → index-CD2dBMet.d.ts} +10 -8
  138. package/dist/index-CGhMJNHb.d.cts +128 -0
  139. package/dist/{index-B3D_z0Z6.d.cts → index-CL7oilfm.d.cts} +1 -1
  140. package/dist/{index-Bn0uZEL4.d.ts → index-CQtWm7jS.d.ts} +9 -9
  141. package/dist/{index-CM-i58FY.d.cts → index-CRm0YIzC.d.cts} +9 -9
  142. package/dist/index-CUIkE1l9.d.cts +230 -0
  143. package/dist/{index-CijfwEWx.d.ts → index-Cczxgd2D.d.ts} +2 -2
  144. package/dist/{index-CAbHN_rP.d.cts → index-CgnCFhr2.d.cts} +1 -1
  145. package/dist/{index-B2IUcH13.d.cts → index-Ck35nA-T.d.ts} +41 -48
  146. package/dist/{index-BpMZzX9P.d.cts → index-Cnr1WrlX.d.cts} +3 -3
  147. package/dist/{index-JYtN9uqM.d.ts → index-CoM4rzyB.d.ts} +1 -1
  148. package/dist/{index-Ckil6miL.d.cts → index-CtFNGe-m.d.cts} +2 -2
  149. package/dist/{index-BjWZARLy.d.ts → index-Ctb7_2sG.d.ts} +1 -1
  150. package/dist/index-CuPUehFa.d.cts +218 -0
  151. package/dist/index-D1Gc7wV5.d.ts +230 -0
  152. package/dist/{index-DqICM_I7.d.ts → index-D1IEZUsj.d.ts} +67 -9
  153. package/dist/{index-BFuVcqL8.d.cts → index-D3ayz3hy.d.cts} +1 -1
  154. package/dist/{index-CQsqqEVz.d.cts → index-D4uimgee.d.cts} +1 -1
  155. package/dist/{resilience-BWP2c7Af.d.cts → index-DGTo1yka.d.cts} +202 -26
  156. package/dist/{index-BmWuVdER.d.ts → index-DH4fm2Ck.d.ts} +2 -2
  157. package/dist/{index-BkQqf1EF.d.cts → index-DJ_MPOJ5.d.cts} +67 -9
  158. package/dist/{index-9xhIaM-w.d.cts → index-DOBLxOti.d.cts} +1 -1
  159. package/dist/{index-BqcgiSQg.d.cts → index-DQQCOIt8.d.cts} +10 -8
  160. package/dist/{index-DJNAWzcH.d.cts → index-DVAlsmEU.d.cts} +26 -19
  161. package/dist/index-DVDapw2k.d.cts +210 -0
  162. package/dist/{index-D_QQ_dTD.d.cts → index-DYTBbF8T.d.cts} +1 -1
  163. package/dist/{index-BgzPO43H.d.cts → index-DgJc8Zgc.d.cts} +6 -6
  164. package/dist/{index-Czk3r0yA.d.cts → index-DhLyOHYZ.d.ts} +56 -54
  165. package/dist/{index-CrlHFsiT.d.ts → index-DhnsQfa3.d.ts} +100 -118
  166. package/dist/{index-Bub6x_D4.d.cts → index-DktLSZOc.d.cts} +37 -90
  167. package/dist/{index-BaSy4L6w.d.cts → index-DpiGqtrs.d.cts} +100 -118
  168. package/dist/{index-D-HZ7sP4.d.ts → index-I1cCY3ZI.d.ts} +6 -6
  169. package/dist/{index-D9vBTuzo.d.ts → index-IUCY0OFN.d.ts} +4 -4
  170. package/dist/{index-DeSsvHDD.d.cts → index-MxYuWOrf.d.cts} +3 -3
  171. package/dist/index-N2MAxt7_.d.ts +128 -0
  172. package/dist/{index-CpZKtdMw.d.cts → index-PgwvGWa1.d.cts} +1 -1
  173. package/dist/{index-AUqWe_fX.d.ts → index-WSlcjhQF.d.ts} +55 -9
  174. package/dist/{index-Di7OdwlO.d.ts → index-bXXLSvor.d.ts} +37 -90
  175. package/dist/index-da2V5vPy.d.ts +113 -0
  176. package/dist/{index-DY2f2b9z.d.ts → index-eaQuGJnv.d.ts} +3 -3
  177. package/dist/{index-BsgxnHN8.d.cts → index-t6L2qpHh.d.cts} +3 -3
  178. package/dist/{index-C-3UXnHT.d.cts → index-tV3AA9hI.d.cts} +2 -2
  179. package/dist/{index-8OxXae3g.d.ts → index-yLt-aPMp.d.ts} +1 -1
  180. package/dist/{index-CqSJ25A9.d.cts → index-z8WFPVI8.d.cts} +1 -1
  181. package/dist/index.cjs +63 -59
  182. package/dist/index.d.cts +48 -47
  183. package/dist/index.d.ts +48 -47
  184. package/dist/index.js +1 -1
  185. package/dist/{meta-DreaEM_a.d.cts → meta-Ct9nqQS5.d.cts} +11 -7
  186. package/dist/{meta-BYqlATmg.d.ts → meta-D8OyedKp.d.ts} +11 -7
  187. package/dist/{node-fSc-hCv8.d.cts → node-BYInONRr.d.cts} +3 -3
  188. package/dist/{node-fSc-hCv8.d.ts → node-BYInONRr.d.ts} +3 -3
  189. package/dist/{observable-Cqty11jG.d.cts → observable-DMIlYJV1.d.cts} +1 -1
  190. package/dist/{observable-EAV_rNfM.d.ts → observable-DO8DDEzv.d.ts} +1 -1
  191. package/dist/patterns/ai/browser.cjs +5 -5
  192. package/dist/patterns/ai/browser.d.cts +4 -4
  193. package/dist/patterns/ai/browser.d.ts +4 -4
  194. package/dist/patterns/ai/browser.js +1 -1
  195. package/dist/patterns/ai/index.cjs +16 -20
  196. package/dist/patterns/ai/index.d.cts +17 -17
  197. package/dist/patterns/ai/index.d.ts +17 -17
  198. package/dist/patterns/ai/index.js +1 -1
  199. package/dist/patterns/ai/node.cjs +1 -1
  200. package/dist/patterns/ai/node.d.cts +4 -4
  201. package/dist/patterns/ai/node.d.ts +4 -4
  202. package/dist/patterns/ai/node.js +1 -1
  203. package/dist/patterns/audit/index.cjs +3 -7
  204. package/dist/patterns/audit/index.d.cts +6 -6
  205. package/dist/patterns/audit/index.d.ts +6 -6
  206. package/dist/patterns/audit/index.js +1 -1
  207. package/dist/patterns/cqrs/index.cjs +3 -7
  208. package/dist/patterns/cqrs/index.d.cts +6 -6
  209. package/dist/patterns/cqrs/index.d.ts +6 -6
  210. package/dist/patterns/cqrs/index.js +1 -1
  211. package/dist/patterns/demo-shell/index.cjs +5 -8
  212. package/dist/patterns/demo-shell/index.d.cts +5 -5
  213. package/dist/patterns/demo-shell/index.d.ts +5 -5
  214. package/dist/patterns/demo-shell/index.js +1 -1
  215. package/dist/patterns/domain-templates/index.cjs +3 -7
  216. package/dist/patterns/domain-templates/index.d.cts +4 -4
  217. package/dist/patterns/domain-templates/index.d.ts +4 -4
  218. package/dist/patterns/domain-templates/index.js +1 -1
  219. package/dist/patterns/graphspec/index.cjs +37 -37
  220. package/dist/patterns/graphspec/index.d.cts +5 -5
  221. package/dist/patterns/graphspec/index.d.ts +5 -5
  222. package/dist/patterns/graphspec/index.js +1 -1
  223. package/dist/patterns/guarded-execution/index.cjs +3 -7
  224. package/dist/patterns/guarded-execution/index.d.cts +7 -7
  225. package/dist/patterns/guarded-execution/index.d.ts +7 -7
  226. package/dist/patterns/guarded-execution/index.js +1 -1
  227. package/dist/patterns/harness/index.cjs +8 -12
  228. package/dist/patterns/harness/index.d.cts +12 -12
  229. package/dist/patterns/harness/index.d.ts +12 -12
  230. package/dist/patterns/harness/index.js +1 -1
  231. package/dist/patterns/job-queue/index.cjs +3 -7
  232. package/dist/patterns/job-queue/index.d.cts +6 -6
  233. package/dist/patterns/job-queue/index.d.ts +6 -6
  234. package/dist/patterns/job-queue/index.js +1 -1
  235. package/dist/patterns/lens/index.cjs +3 -7
  236. package/dist/patterns/lens/index.d.cts +5 -6
  237. package/dist/patterns/lens/index.d.ts +5 -6
  238. package/dist/patterns/lens/index.js +1 -1
  239. package/dist/patterns/memory/index.cjs +3 -7
  240. package/dist/patterns/memory/index.d.cts +6 -6
  241. package/dist/patterns/memory/index.d.ts +6 -6
  242. package/dist/patterns/memory/index.js +1 -1
  243. package/dist/patterns/messaging/index.cjs +3 -7
  244. package/dist/patterns/messaging/index.d.cts +5 -5
  245. package/dist/patterns/messaging/index.d.ts +5 -5
  246. package/dist/patterns/messaging/index.js +1 -1
  247. package/dist/patterns/orchestration/index.cjs +3 -7
  248. package/dist/patterns/orchestration/index.d.cts +8 -8
  249. package/dist/patterns/orchestration/index.d.ts +8 -8
  250. package/dist/patterns/orchestration/index.js +1 -1
  251. package/dist/patterns/process/index.cjs +1 -1
  252. package/dist/patterns/process/index.d.cts +7 -7
  253. package/dist/patterns/process/index.d.ts +7 -7
  254. package/dist/patterns/process/index.js +1 -1
  255. package/dist/patterns/reactive-layout/index.cjs +4 -8
  256. package/dist/patterns/reactive-layout/index.d.cts +5 -5
  257. package/dist/patterns/reactive-layout/index.d.ts +5 -5
  258. package/dist/patterns/reactive-layout/index.js +1 -1
  259. package/dist/patterns/reduction/index.cjs +3 -7
  260. package/dist/patterns/reduction/index.d.cts +4 -4
  261. package/dist/patterns/reduction/index.d.ts +4 -4
  262. package/dist/patterns/reduction/index.js +1 -1
  263. package/dist/patterns/refine-loop/index.cjs +5 -9
  264. package/dist/patterns/refine-loop/index.d.cts +6 -6
  265. package/dist/patterns/refine-loop/index.d.ts +6 -6
  266. package/dist/patterns/refine-loop/index.js +1 -1
  267. package/dist/patterns/resilient-pipeline/index.cjs +3 -1
  268. package/dist/patterns/resilient-pipeline/index.d.cts +6 -6
  269. package/dist/patterns/resilient-pipeline/index.d.ts +6 -6
  270. package/dist/patterns/resilient-pipeline/index.js +1 -1
  271. package/dist/patterns/surface/index.cjs +12 -16
  272. package/dist/patterns/surface/index.d.cts +6 -6
  273. package/dist/patterns/surface/index.d.ts +6 -6
  274. package/dist/patterns/surface/index.js +1 -1
  275. package/dist/{pipeline-graph-9JBbmRxA.d.ts → pipeline-graph-CB4La-UW.d.ts} +34 -17
  276. package/dist/{pipeline-graph-DuHpXSOn.d.cts → pipeline-graph-MWrQZXCq.d.cts} +34 -17
  277. package/dist/{reactive-layout-BMLDB4Vd.d.cts → reactive-layout-BtZfUKuL.d.cts} +2 -2
  278. package/dist/{reactive-layout-D-tRiNhg.d.ts → reactive-layout-KJj4E2dT.d.ts} +2 -2
  279. package/dist/{reactive-log-BgWSA1fg.d.ts → reactive-log-BlAsPLl2.d.ts} +2 -2
  280. package/dist/{reactive-log-C3IMAGpT.d.cts → reactive-log-_zeEnB9H.d.cts} +2 -2
  281. package/dist/{reactive-map-DmgeADH8.d.cts → reactive-map-6P_k3AQM.d.cts} +2 -2
  282. package/dist/{reactive-map-CHyeCf4D.d.ts → reactive-map-CjXByDV-.d.ts} +2 -2
  283. package/dist/resilience-S33JV6XC.js +1 -0
  284. package/dist/{sugar-D13E2M_z.d.ts → sugar-BhfjgetH.d.ts} +1 -1
  285. package/dist/{sugar-DgaGJcI6.d.cts → sugar-DzePN5-g.d.cts} +1 -1
  286. package/dist/{topology-tree-jrZue3ao.d.cts → topology-tree-3LBKFsUo.d.cts} +1 -1
  287. package/dist/{topology-tree-D47-nI6Z.d.ts → topology-tree-mF7Emqzm.d.ts} +1 -1
  288. package/dist/{types-BMSGPlpO.d.cts → types-1Dhoi7HM.d.cts} +1 -1
  289. package/dist/{types-CidcBDuk.d.ts → types-39jk0kaV.d.ts} +1 -1
  290. package/package.json +11 -1
  291. package/dist/chunk-2YFDSYEF.js +0 -1
  292. package/dist/chunk-5BGFS2XH.js +0 -1
  293. package/dist/chunk-CMTN3KPT.js +0 -80
  294. package/dist/chunk-DQJLC6YY.js +0 -1
  295. package/dist/chunk-G7JN6LCB.js +0 -1
  296. package/dist/chunk-KJEAIIIY.js +0 -43
  297. package/dist/chunk-LV3ACS5J.js +0 -1
  298. package/dist/chunk-NBGPXQSP.js +0 -1
  299. package/dist/chunk-NN3QPJ6U.js +0 -1
  300. package/dist/chunk-NSAZ6PR6.js +0 -1
  301. package/dist/chunk-O32GJOUJ.js +0 -1
  302. package/dist/chunk-QEVSIVSF.js +0 -1
  303. package/dist/chunk-QMC2PLNM.js +0 -7
  304. package/dist/chunk-QOJFR6GS.js +0 -1
  305. package/dist/chunk-SFK7MN7S.js +0 -1
  306. package/dist/chunk-TB7JKSVS.js +0 -61
  307. package/dist/chunk-UAXFKMAG.js +0 -1
  308. package/dist/chunk-XIMFHEKV.js +0 -1
  309. package/dist/chunk-XLMYQB6F.js +0 -1
  310. package/dist/chunk-XLYF4LBH.js +0 -1
  311. package/dist/imperative-audit-ahAE65a9.d.cts +0 -28
  312. package/dist/imperative-audit-ahAE65a9.d.ts +0 -28
  313. package/dist/index-5dNRlW7J.d.ts +0 -135
  314. package/dist/index-BWUMIt7J.d.cts +0 -135
  315. package/dist/index-BhzwpIJc.d.cts +0 -105
  316. package/dist/index-BsZk9T8y.d.ts +0 -105
  317. package/dist/index-C56XZiDe.d.cts +0 -163
  318. package/dist/index-CpdnP-0y.d.cts +0 -186
  319. package/dist/index-DKrIuF-r.d.ts +0 -163
  320. package/dist/index-DOU1Ee_k.d.ts +0 -186
  321. package/dist/resilience-LGBK236C.js +0 -1
@@ -0,0 +1,115 @@
1
+ import { N as Node, a as NodeOptions } from './node-BYInONRr.js';
2
+
3
+ /**
4
+ * `budgetGate` — numeric-constraint flow gate (Tier 2.2 promotion from
5
+ * `patterns/reduction/`).
6
+ *
7
+ * Lives alongside the other `extra/resilience/` flow controls (`retry`,
8
+ * `circuitBreaker`, `rateLimiter`, `tokenBucket`, `fallback`, `withStatus`).
9
+ *
10
+ * @module
11
+ */
12
+
13
+ /** A reactive constraint for {@link budgetGate}. */
14
+ type BudgetConstraint<T = unknown> = {
15
+ /** Constraint node whose value is checked. */
16
+ node: Node<T>;
17
+ /** Returns `true` when the constraint is satisfied (budget available). */
18
+ check: (value: T) => boolean;
19
+ };
20
+ /** Options for {@link budgetGate}. */
21
+ type BudgetGateOptions = Omit<NodeOptions<unknown>, "describeKind" | "name" | "meta"> & {
22
+ meta?: Record<string, unknown>;
23
+ };
24
+ /**
25
+ * Pass-through that respects reactive constraint nodes.
26
+ *
27
+ * DATA flows through when all constraints are satisfied. When any constraint
28
+ * is exceeded, `PAUSE` is sent upstream and DATA is buffered in a FIFO queue.
29
+ * When constraints relax, the queue drains in arrival order and `RESUME` is
30
+ * sent upstream.
31
+ *
32
+ * ## Invariants (do not refactor without preserving)
33
+ *
34
+ * 1. **Terminal force-flush.** On `COMPLETE` / `ERROR` arriving from `source`,
35
+ * every buffered item is emitted downstream BEFORE the terminal message is
36
+ * forwarded. The constraint is intentionally bypassed for the flush — once
37
+ * upstream is done, the caller must see the buffered work, not lose it.
38
+ * See COMPOSITION-GUIDE §19 (terminal-emission operators).
39
+ *
40
+ * 2. **PAUSE-release ordering.** When a constraint flips from saturated →
41
+ * released, the queue drains in FIFO order downstream BEFORE `RESUME` is
42
+ * sent upstream. Reversing the order (RESUME-then-drain) would let new
43
+ * upstream DATA interleave with the queue tail, breaking arrival-order
44
+ * delivery. See COMPOSITION-GUIDE §9, §9a (diamond + batch coalescing).
45
+ *
46
+ * 3. **Deferred RESOLVED.** A `RESOLVED` from `source` while the queue is
47
+ * non-empty is held until the queue drains, then forwarded — so downstream
48
+ * sees `[buffered DATA…, RESOLVED]` in causal order rather than
49
+ * `[RESOLVED, buffered DATA…]`.
50
+ *
51
+ * **Stall risk (qa D4):** if the constraint never relaxes AND no terminal
52
+ * arrives from `source`, the deferred RESOLVED is held forever. Downstream
53
+ * consumers that depend on `RESOLVED` for an `awaitSettled`-style
54
+ * coordination wait stall in this case. PAUSE is sent upstream so source
55
+ * backpressure stops further DATA, but the gate itself has no escape
56
+ * hatch — by design (the producer-pattern is fire-and-forget; recovery
57
+ * happens at the compositor level via timeout, retry, or cancellation).
58
+ *
59
+ * 4. **Constraint DIRTY suppression.** Constraint-node DIRTY does NOT
60
+ * propagate downstream — only `source`-DIRTY does. The gate's downstream
61
+ * semantics track `source`'s wave, not constraint waves.
62
+ *
63
+ * 5. **Lazy PAUSE (qa D3).** PAUSE is sent upstream ONLY when a `source` DATA
64
+ * arrives that fails the constraint check (the first blocked item). A
65
+ * constraint flipping closed BEFORE any source DATA arrives does NOT emit
66
+ * a preemptive PAUSE — upstream may push DATA freely until the first
67
+ * item is buffered. This matches the producer-pattern lazy-activation
68
+ * philosophy (don't impose backpressure for hypothetical future blocks).
69
+ * For eager-PAUSE semantics, wrap the gate in a compositor that watches
70
+ * constraints + source independently.
71
+ *
72
+ * ## Queue
73
+ *
74
+ * The internal buffer is an unbounded {@link HeadIndexQueue} (O(1) push,
75
+ * O(1) shift, opportunistic compaction). It does NOT use {@link RingBuffer}
76
+ * because RingBuffer's drop-oldest eviction would silently lose buffered
77
+ * items between PAUSE and RESUME. Backpressure (PAUSE) is the upstream
78
+ * contract for bounding the queue, not capacity-driven eviction here.
79
+ *
80
+ * ## Producer-pattern: source edge is invisible to `describe()`
81
+ *
82
+ * `budgetGate` is constructed via `node([], fn)` and subscribes to `source`
83
+ * and the constraint nodes manually inside its activation fn. Because no
84
+ * dep is declared at construction, **`describe()` shows no edge from
85
+ * `source` (or any constraint) into the returned node** — the gate looks
86
+ * like a standalone leaf source. This is intentional (see COMPOSITION-GUIDE
87
+ * §24 "Edges are derived, not declared"): if you want the constraint /
88
+ * source dependency to appear in describe output, surface it at the
89
+ * compositor level (e.g. annotate via `meta.ai.upstream`, or wrap the gate
90
+ * in a parent factory that exposes the deps as constructor args).
91
+ *
92
+ * ## Reference equality
93
+ *
94
+ * The `constraints` array reference and each `BudgetConstraint.check`
95
+ * function are captured at construction. The factory does NOT diff
96
+ * subsequent `constraints` arrays (there is no subsequent — the array is
97
+ * static for the gate's lifetime). To swap constraints reactively, build
98
+ * the swap at the compositor level above the gate (Architecture-2:
99
+ * compositor-only). Identity changes to `constraints` are observed only by
100
+ * constructing a new gate.
101
+ *
102
+ * @param source - Input node.
103
+ * @param constraints - Reactive constraint checks. MUST be non-empty.
104
+ * @param opts - Optional node options.
105
+ * @returns Gated node.
106
+ *
107
+ * @throws {RangeError} when `constraints.length === 0`. The gate has no
108
+ * meaningful identity without at least one check — degenerate to plain
109
+ * pass-through (e.g. via `derived([source], ([v]) => v)`) instead.
110
+ *
111
+ * @category resilience
112
+ */
113
+ declare function budgetGate<T>(source: Node<T>, constraints: ReadonlyArray<BudgetConstraint>, opts?: BudgetGateOptions): Node<T>;
114
+
115
+ export { type BudgetConstraint as B, type BudgetGateOptions as a, budgetGate as b };
@@ -0,0 +1,115 @@
1
+ import { N as Node, a as NodeOptions } from './node-BYInONRr.cjs';
2
+
3
+ /**
4
+ * `budgetGate` — numeric-constraint flow gate (Tier 2.2 promotion from
5
+ * `patterns/reduction/`).
6
+ *
7
+ * Lives alongside the other `extra/resilience/` flow controls (`retry`,
8
+ * `circuitBreaker`, `rateLimiter`, `tokenBucket`, `fallback`, `withStatus`).
9
+ *
10
+ * @module
11
+ */
12
+
13
+ /** A reactive constraint for {@link budgetGate}. */
14
+ type BudgetConstraint<T = unknown> = {
15
+ /** Constraint node whose value is checked. */
16
+ node: Node<T>;
17
+ /** Returns `true` when the constraint is satisfied (budget available). */
18
+ check: (value: T) => boolean;
19
+ };
20
+ /** Options for {@link budgetGate}. */
21
+ type BudgetGateOptions = Omit<NodeOptions<unknown>, "describeKind" | "name" | "meta"> & {
22
+ meta?: Record<string, unknown>;
23
+ };
24
+ /**
25
+ * Pass-through that respects reactive constraint nodes.
26
+ *
27
+ * DATA flows through when all constraints are satisfied. When any constraint
28
+ * is exceeded, `PAUSE` is sent upstream and DATA is buffered in a FIFO queue.
29
+ * When constraints relax, the queue drains in arrival order and `RESUME` is
30
+ * sent upstream.
31
+ *
32
+ * ## Invariants (do not refactor without preserving)
33
+ *
34
+ * 1. **Terminal force-flush.** On `COMPLETE` / `ERROR` arriving from `source`,
35
+ * every buffered item is emitted downstream BEFORE the terminal message is
36
+ * forwarded. The constraint is intentionally bypassed for the flush — once
37
+ * upstream is done, the caller must see the buffered work, not lose it.
38
+ * See COMPOSITION-GUIDE §19 (terminal-emission operators).
39
+ *
40
+ * 2. **PAUSE-release ordering.** When a constraint flips from saturated →
41
+ * released, the queue drains in FIFO order downstream BEFORE `RESUME` is
42
+ * sent upstream. Reversing the order (RESUME-then-drain) would let new
43
+ * upstream DATA interleave with the queue tail, breaking arrival-order
44
+ * delivery. See COMPOSITION-GUIDE §9, §9a (diamond + batch coalescing).
45
+ *
46
+ * 3. **Deferred RESOLVED.** A `RESOLVED` from `source` while the queue is
47
+ * non-empty is held until the queue drains, then forwarded — so downstream
48
+ * sees `[buffered DATA…, RESOLVED]` in causal order rather than
49
+ * `[RESOLVED, buffered DATA…]`.
50
+ *
51
+ * **Stall risk (qa D4):** if the constraint never relaxes AND no terminal
52
+ * arrives from `source`, the deferred RESOLVED is held forever. Downstream
53
+ * consumers that depend on `RESOLVED` for an `awaitSettled`-style
54
+ * coordination wait stall in this case. PAUSE is sent upstream so source
55
+ * backpressure stops further DATA, but the gate itself has no escape
56
+ * hatch — by design (the producer-pattern is fire-and-forget; recovery
57
+ * happens at the compositor level via timeout, retry, or cancellation).
58
+ *
59
+ * 4. **Constraint DIRTY suppression.** Constraint-node DIRTY does NOT
60
+ * propagate downstream — only `source`-DIRTY does. The gate's downstream
61
+ * semantics track `source`'s wave, not constraint waves.
62
+ *
63
+ * 5. **Lazy PAUSE (qa D3).** PAUSE is sent upstream ONLY when a `source` DATA
64
+ * arrives that fails the constraint check (the first blocked item). A
65
+ * constraint flipping closed BEFORE any source DATA arrives does NOT emit
66
+ * a preemptive PAUSE — upstream may push DATA freely until the first
67
+ * item is buffered. This matches the producer-pattern lazy-activation
68
+ * philosophy (don't impose backpressure for hypothetical future blocks).
69
+ * For eager-PAUSE semantics, wrap the gate in a compositor that watches
70
+ * constraints + source independently.
71
+ *
72
+ * ## Queue
73
+ *
74
+ * The internal buffer is an unbounded {@link HeadIndexQueue} (O(1) push,
75
+ * O(1) shift, opportunistic compaction). It does NOT use {@link RingBuffer}
76
+ * because RingBuffer's drop-oldest eviction would silently lose buffered
77
+ * items between PAUSE and RESUME. Backpressure (PAUSE) is the upstream
78
+ * contract for bounding the queue, not capacity-driven eviction here.
79
+ *
80
+ * ## Producer-pattern: source edge is invisible to `describe()`
81
+ *
82
+ * `budgetGate` is constructed via `node([], fn)` and subscribes to `source`
83
+ * and the constraint nodes manually inside its activation fn. Because no
84
+ * dep is declared at construction, **`describe()` shows no edge from
85
+ * `source` (or any constraint) into the returned node** — the gate looks
86
+ * like a standalone leaf source. This is intentional (see COMPOSITION-GUIDE
87
+ * §24 "Edges are derived, not declared"): if you want the constraint /
88
+ * source dependency to appear in describe output, surface it at the
89
+ * compositor level (e.g. annotate via `meta.ai.upstream`, or wrap the gate
90
+ * in a parent factory that exposes the deps as constructor args).
91
+ *
92
+ * ## Reference equality
93
+ *
94
+ * The `constraints` array reference and each `BudgetConstraint.check`
95
+ * function are captured at construction. The factory does NOT diff
96
+ * subsequent `constraints` arrays (there is no subsequent — the array is
97
+ * static for the gate's lifetime). To swap constraints reactively, build
98
+ * the swap at the compositor level above the gate (Architecture-2:
99
+ * compositor-only). Identity changes to `constraints` are observed only by
100
+ * constructing a new gate.
101
+ *
102
+ * @param source - Input node.
103
+ * @param constraints - Reactive constraint checks. MUST be non-empty.
104
+ * @param opts - Optional node options.
105
+ * @returns Gated node.
106
+ *
107
+ * @throws {RangeError} when `constraints.length === 0`. The gate has no
108
+ * meaningful identity without at least one check — degenerate to plain
109
+ * pass-through (e.g. via `derived([source], ([v]) => v)`) instead.
110
+ *
111
+ * @category resilience
112
+ */
113
+ declare function budgetGate<T>(source: Node<T>, constraints: ReadonlyArray<BudgetConstraint>, opts?: BudgetGateOptions): Node<T>;
114
+
115
+ export { type BudgetConstraint as B, type BudgetGateOptions as a, budgetGate as b };
@@ -1,5 +1,5 @@
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';
1
+ import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-39jk0kaV.js';
2
+ import { b as CircuitBreakerOptions, f as CircuitBreaker } from './index-BAQrjuZF.js';
3
3
 
4
4
  /**
5
5
  * OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
@@ -1,5 +1,5 @@
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';
1
+ import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-1Dhoi7HM.cjs';
2
+ import { b as CircuitBreakerOptions, f as CircuitBreaker } from './index-DGTo1yka.cjs';
3
3
 
4
4
  /**
5
5
  * OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
@@ -0,0 +1,3 @@
1
+ import{a as we}from"./chunk-SGS4OJGS.js";import{a as Me}from"./chunk-ESMPEKEV.js";import{a as ve,d as ye}from"./chunk-35JTVPOX.js";import{C as ne}from"./chunk-CKFQS2CJ.js";import{A as ge,C as M,E as Z,F as me,G as be,e as $e,f as xe,i as Q,k as Ae,l as te,m as Te,o as z,p as Pe,s as U}from"./chunk-LYCLF26R.js";import{b as q,c as le,d as pe,e as ee,f as fe,g as he,h as L,i as H,j as W}from"./chunk-CK2E7BTU.js";function Oe(o,e){if(Object.is(o,e))return!0;if(o==null||e==null||typeof o!="object"||typeof e!="object")return!1;if(Array.isArray(o)){if(!Array.isArray(e)||o.length!==e.length)return!1;for(let r=0;r<o.length;r++)if(!Oe(o[r],e[r]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(o),n=Object.keys(e);if(t.length!==n.length)return!1;let s=new Set(n);for(let r of t)if(!s.has(r)||!Oe(o[r],e[r]))return!1;return!0}function je(o,e){return`${o}\0${e}`}function _e(o,e){let t=[],n=new Set(o.subgraphs),s=new Set(e.subgraphs),r=[];for(let l of s)n.has(l)||r.push(l);r.sort();for(let l of r)t.push({type:"subgraph-mounted",path:l});let i=new Set(Object.keys(o.nodes)),c=new Set(Object.keys(e.nodes)),d=[];for(let l of c)i.has(l)||d.push(l);d.sort();for(let l of d)t.push({type:"node-added",path:l,node:{...e.nodes[l]}});let a=[];for(let l of c){if(!i.has(l))continue;let O=o.nodes[l]?.meta,m=e.nodes[l]?.meta;O==null&&m==null||Oe(O??{},m??{})||a.push(l)}a.sort();for(let l of a)t.push({type:"node-meta-changed",path:l,prevMeta:o.nodes[l]?.meta??{},nextMeta:e.nodes[l]?.meta??{}});let p=new Map;for(let l of o.edges)p.set(je(l.from,l.to),l);let g=new Map;for(let l of e.edges)g.set(je(l.from,l.to),l);let h=[];for(let[l,O]of g)p.has(l)||h.push(O);h.sort((l,O)=>l.from<O.from?-1:l.from>O.from?1:l.to<O.to?-1:l.to>O.to?1:0);for(let l of h)t.push({type:"edge-added",from:l.from,to:l.to});let f=[];for(let[l,O]of p)g.has(l)||f.push(O);f.sort((l,O)=>l.from<O.from?-1:l.from>O.from?1:l.to<O.to?-1:l.to>O.to?1:0);for(let l of f)t.push({type:"edge-removed",from:l.from,to:l.to});let u=[];for(let l of i)c.has(l)||u.push(l);u.sort();for(let l of u)t.push({type:"node-removed",path:l});let y=[];for(let l of n)s.has(l)||y.push(l);y.sort();for(let l of y)t.push({type:"subgraph-unmounted",path:l});return{events:t,flushedAt_ns:z()}}function Fe(o,e,t,n={}){let s=e in o.nodes,r=t in o.nodes;if(!s)return re(e,t,"no-such-from");if(!r)return re(e,t,"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(e===t){if(n.findCycle===!0){let a=Xe(o,e,n);if(a!=null)return a}let d=se(e,o.nodes[e],0,n);return oe(e,t,[d])}if(i===0)return re(e,t,"no-path");let c=Ie(o,e,t,i);return c.found?oe(e,t,Be(o,c.pathOrder,n)):re(e,t,c.truncated?"max-depth-exceeded":"no-path")}function Ie(o,e,t,n){let s=new Map,r=[{path:t,depth:0}],i=new Set([t]),c=0,d=!1;for(;c<r.length;){let g=r[c++];if(g.path===e)break;if(n!=null&&g.depth>=n){let y=o.nodes[g.path];y?.deps&&y.deps.length>0&&(d=!0);continue}let h=o.nodes[g.path];if(h==null)continue;let f=h.deps??[],u=new Map;for(let y=0;y<f.length;y++){let l=f[y];if(!l)continue;let O=u.get(l);O==null&&(O=[],u.set(l,O)),O.push(y)}for(let[y,l]of u)i.has(y)||(i.add(y),s.set(y,{from:g.path,depIndices:l}),r.push({path:y,depth:g.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:d};let a=[{path:e}],p=e;for(;p!==t;){let g=s.get(p);if(g==null)return{found:!1,pathOrder:[],truncated:!1};a[a.length-1].depIndices=g.depIndices,a.push({path:g.from}),p=g.from}return{found:!0,pathOrder:a,truncated:!1}}function Xe(o,e,t){let n=o.nodes[e];if(n==null)return null;let s=n.deps??[],r=[];for(let c=0;c<s.length;c++)s[c]===e&&r.push(c);if(r.length>0){let c=se(e,n,0,t);c.dep_index=r[0];let d=se(e,n,1,t);return oe(e,e,[c,d])}let i=null;for(let c=0;c<s.length;c++){let d=s[c];if(!d||d===e)continue;let a=Ie(o,d,e,t.maxDepth);a.found&&(i==null||a.pathOrder.length<i.pathOrder.length)&&(i=a,i={found:!0,pathOrder:[{path:e,depIndices:[c]},...a.pathOrder],truncated:!1})}return i==null?null:oe(e,e,Be(o,i.pathOrder,t))}function Be(o,e,t){return e.map((n,s)=>{let r=o.nodes[n.path],i=se(n.path,r,s,t);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 se(o,e,t,n){let s={path:o,type:e.type,hop:t};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let r=n.annotations?.get(o)??e.annotation;r!=null&&(s.annotation=r);let i=n.lastMutations?.get(o)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function oe(o,e,t){return Le(o,e,!0,"ok",t)}function re(o,e,t){return Le(o,e,!1,t,[])}function Le(o,e,t,n,s){let r=et(o,e,t,n,s);return{from:o,to:e,found:t,reason:n,steps:s,text:r,toJSON(){return{from:o,to:e,found:t,reason:n,steps:s}}}}function et(o,e,t,n,s){if(!t)switch(n){case"no-such-from":return`explainPath: no node named "${o}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${o}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${o}" to "${e}"`}let r=[`Causal path: ${o} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(r.push(d),"value"in i&&r.push(` value: ${tt(i.value)}`),i.annotation!=null&&r.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let a=i.lastMutation.actor;r.push(` actor: ${a.type}${a.id?`:${a.id}`:""}`)}}return r.join(`
2
+ `)}function tt(o){if(o===void 0)return"<sentinel>";if(o===null)return"null";if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean"||typeof o=="bigint")return String(o);try{let e=JSON.stringify(o);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(o)}}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},nt=Symbol.for("sizeof");function ze(o){let e=new WeakSet,t=new WeakSet,n=[o],s=0;for(;n.length>0;){let r=n.pop();s+=rt(r,e,t,n)}return s}function rt(o,e,t,n){if(o==null)return 0;switch(typeof o){case"number":return A.number;case"boolean":return A.boolean;case"string":return A.string+o.length*2;case"bigint":return A.bigint+st(o);case"symbol":return A.symbol;case"function":return e.has(o)?0:(e.add(o),A.function);case"undefined":return 0}let r=o;if(e.has(r))return 0;e.add(r);let i=r[nt];if(typeof i=="function")try{let a=i.call(r);if(typeof a=="number"&&Number.isFinite(a))return a}catch{}if(r instanceof Date)return A.date;if(r instanceof RegExp)return A.regexp+r.source.length*2;if(r instanceof Error){let a=r.message?r.message.length*2:0,p=r.stack?r.stack.length*2:0;return A.error+a+p}if(typeof URL<"u"&&r instanceof URL)return A.url+r.href.length*2;if(typeof Promise<"u"&&r instanceof Promise)return A.promise;if(r instanceof WeakMap)return A.weakmap;if(r instanceof WeakSet)return A.weakset;if(r instanceof Map){let a=A.map;for(let[p,g]of r)a+=A.mapEntry,n.push(p),n.push(g);return a}if(r instanceof Set){let a=A.set;for(let p of r)a+=A.setEntry,n.push(p);return a}if(Array.isArray(r)){let a=A.array+r.length*8;for(let p of r)n.push(p);return a}if(r instanceof ArrayBuffer)return t.has(r)?0:(t.add(r),r.byteLength);if(ArrayBuffer.isView(r)){let a=r;return t.has(a.buffer)?48:(t.add(a.buffer),a.buffer.byteLength+48)}let c=A.object,d=Object.keys(r);for(let a of d){c+=A.string+a.length*2;try{n.push(r[a])}catch{}}return c}function st(o){let e=o<0n?-o:o;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}function Ve(o,e){let t=e?.topN??10,n=o.describe({detail:"standard"}),s=[],r=o._collectObserveTargets;typeof r=="function"&&r.call(o,"",s);let i=new Map;for(let[h,f]of s)i.set(h,f);let c=[];for(let[h,f]of Object.entries(n.nodes)){let u=i.get(h),y=u instanceof M?u:null,l=y?ze(y.cache):0,O=y?y._sinkCount:0,m=f.deps?.length??0,b=f.type==="effect"&&O===0,v=O===0?f.type==="effect"?"orphan-effect":f.type==="derived"?"idle-derived":f.type==="producer"?"idle-producer":null:null;c.push({path:h,type:f.type,status:f.status??"unknown",valueSizeBytes:l,subscriberCount:O,depCount:m,isOrphanEffect:b,orphanKind:v})}let d=c.reduce((h,f)=>h+f.valueSizeBytes,0),a=(h,f)=>[...c].sort(f??((u,y)=>y[h]-u[h])).slice(0,t),p=c.filter(h=>h.orphanKind!=null),g=c.filter(h=>h.isOrphanEffect);return{nodeCount:c.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:c,totalValueSizeBytes:d,hotspots:{byValueSize:a("valueSizeBytes"),bySubscriberCount:a("subscriberCount"),byDepCount:a("depCount")},orphans:p,orphanEffects:g}}var $="::",B="__meta__",J=1;function qe(o,e){let t=Math.max(16,o.size*4),n=0;for(;o.size>0;){if(n++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${o.size} disposer(s) discarded`),o.clear();return}let s=o.values().next();if(s.done)return;let r=s.value;o.delete(r);try{r()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Ye(o){return o!=null&&typeof o=="object"&&"cache"in o&&typeof o.subscribe=="function"&&typeof o.down=="function"}function ot(o){if(o!=null)return Ye(o)?o.cache:o}function K(o){return o!=null&&typeof o=="object"&&"cache"in o&&typeof o.subscribe=="function"&&typeof o.down=="function"}function V(o){return K(o)?o.cache??"":o}function Ke(o){return K(o)?o.cache??0:o}function He(o){return K(o)?o.cache??!1:o}function it(o){let e=[];for(let t of Object.keys(o).sort()){let n=o[t].v;n!=null&&e.push(`${t} ${n.id} ${n.version}`)}return e.join(`
3
+ `)}function We(o){if(o.version!==J)throw new Error(`unsupported snapshot version ${String(o.version)} (expected ${J})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in o))throw new Error(`snapshot missing required key "${e}"`);if(typeof o.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof o.nodes!="object"||o.nodes===null||Array.isArray(o.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(o.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(o.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function at(o,e){let t=new WeakMap,n=(s,r)=>{if(Object.is(s,r))return!0;if(s==null||r==null||typeof s!="object"||typeof r!="object")return!1;let i=t.get(s);if(i==null&&(i=new WeakSet,t.set(s,i)),i.has(r))return!0;i.add(r);let c=s.constructor,d=r.constructor;if(c!==d)return!1;if(s instanceof Date)return s.getTime()===r.getTime();if(s instanceof RegExp)return s.source===r.source&&s.flags===r.flags;if(Array.isArray(s)){let h=r;if(s.length!==h.length)return!1;for(let f=0;f<s.length;f++)if(!n(s[f],h[f]))return!1;return!0}if(s instanceof Map){let h=r;if(s.size!==h.size)return!1;for(let[f,u]of s)if(!h.has(f)||!n(u,h.get(f)))return!1;return!0}if(s instanceof Set){let h=r;if(s.size!==h.size)return!1;for(let f of s){let u=!1;for(let y of h)if(n(f,y)){u=!0;break}if(!u)return!1}return!0}if(ArrayBuffer.isView(s)){let h=s,f=r;if(h.length!==f.length)return!1;for(let u=0;u<h.length;u++)if(h[u]!==f[u])return!1;return!0}let a=Object.keys(s),p=Object.keys(r);if(a.length!==p.length)return!1;let g=new Set(p);for(let h of a)if(!g.has(h)||!n(s[h],r[h]))return!1;return!0};return n(o,e)}function ut(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ie(o){let e="^";for(let t=0;t<o.length;t+=1){let n=o[t];if(n==="*"){e+=".*";continue}if(n==="?"){e+=".";continue}if(n==="["){let s=o.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let r=o.slice(t+1,s);r.startsWith("!")&&(r=`^${r.slice(1)}`),r=r.replace(/\\/g,"\\\\"),e+=`[${r}]`,t=s;continue}e+=ut(n)}return e+="$",new RegExp(e)}var ct={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"},dt={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function Ee(o){if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean"||o==null)return String(o);try{return JSON.stringify(o)}catch{return"[unserializable]"}}function lt(o){return o==="none"?dt:o==="ansi"||o==null?ct:{data:o.data??"",dirty:o.dirty??"",resolved:o.resolved??"",invalidate:o.invalidate??"",pause:o.pause??"",resume:o.resume??"",complete:o.complete??"",error:o.error??"",teardown:o.teardown??"",derived:o.derived??"",path:o.path??"",reset:o.reset??""}}function Ue(o){if(o==null)return{};let e=o.detail;return e==="full"?{...o,structured:o.structured??!0,timeline:o.timeline??!0,causal:o.causal??!0,derived:o.derived??!0}:e==="minimal"?{...o,structured:o.structured??!0}:o.format==="stage-log"?{...o,structured:o.structured??!0,timeline:o.timeline??!0}:o}function pt(o,e,t){for(let n=0;n<o.length;n++){let s=o.charCodeAt(n);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${o}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function ke(o,e,t){if(o==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(o.includes($))throw new Error(`Graph "${e}": ${t} "${o}" must not contain '${$}' (path separator)`);if(o===B)throw new Error(`Graph "${e}": ${t} name "${B}" is reserved for meta companion paths`);pt(o,e,t)}function ft(o,e){if(o==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=o.split($);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function ht(o,e){let t=!1;for(let s of o)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?o.filter(s=>e.isMetaPassthrough(s[0])):o}function Qe(o){for(let e of o._mounts.values())Qe(e);for(let e of o._nodes.values())try{e.down([[L]],{internal:!0})}catch{}}var Se=class o{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes($))throw new Error(`Graph name must not contain '${$}' (got "${e}")`);if(e===B)throw new Error(`Graph name "${B}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??ge,this._traceRing=new we(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning),typeof t?.factory=="string"&&(this._factory=t.factory,t.factoryArgs!==void 0&&(this._factoryArgs=t.factoryArgs))}tagFactory(e,t){return this._factory=e,this._factoryArgs=t,this}ancestors(e=!0){let t=[],n=e?this:this._parent;for(;n!=null;)t.push(n),n=n._parent;return t}get topology(){return this._topology==null&&(this._topology=me(e=>{let t=n=>{e.emit(n)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let n=e.name,s=t?.name??n;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let r=s,i=t?.annotation;if(ke(r,this.name,"add"),this._mounts.has(r))throw new Error(`Graph "${this.name}": name "${r}" is already a mount point`);if(this._nodes.has(r))throw new Error(`Graph "${this.name}": node "${r}" already exists`);let c=this._nodeToName.get(e);if(c!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${c}"`);return this._nodes.set(r,e),this._nodeToName.set(e,r),this._emitTopology({kind:"added",name:r,nodeKind:"node"}),i!=null&&(this._annotations.set(r,i),this.config.inspectorEnabled&&this._traceRing.push({path:r,annotation:i,timestamp_ns:z()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof M&&t._applyVersioning(e)}remove(e){ke(e,this.name,"remove");let t=this._mounts.get(e);if(t){let r={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[c,d]of i)c.includes(`${$}${B}${$}`)||r.nodes.push(c);return r.nodes.sort(),r.mounts.push(e),r.mounts.push(...t._collectSubgraphs(`${e}${$}`)),this._mounts.delete(e),t._parent=void 0,Qe(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:r}),r}let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(n),n.down([[L]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let t=typeof e=="function"?e:(()=>{let r=ie(e);return i=>r.test(i)})(),n={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(r=>t(r));for(let r of s){let i=this.remove(r);n.nodes.push(...i.nodes),n.mounts.push(...i.mounts)}return n.nodes.sort(),n.mounts.sort(),n}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,n=0;return{[Symbol.iterator](){return this},next(){if(n>=e.length)return{value:void 0,done:!0};let s=e[n++];return{value:[s,t.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes($))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,n){let s=n?.internal===!0;this.node(e).down([[q,t]],{actor:n?.actor,internal:s,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);Te(()=>{for(let[s,r]of n)this.set(s,r,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[ee]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let s=n?.internal===!0;this.node(e).down([[W,t]],{actor:n?.actor,internal:s,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[H]],{actor:t?.actor,internal:n,delivery:"write"})}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[d,a]of this._nodes)n.set(a,d);let c=[];for(let[d,a]of this._nodes)if(a instanceof M)for(let p of a._deps){let g=n.get(p.node);g!=null&&c.push([g,d])}return c.sort((d,a)=>d[0]<a[0]?-1:d[0]>a[0]?1:d[1]<a[1]?-1:d[1]>a[1]?1:0),c}let s=[];this._collectObserveTargets("",s);let r=new Map;for(let[c,d]of s)r.set(d,c);let i=[];for(let[c,d]of s)if(d instanceof M)for(let a of d._deps){let p=r.get(a.node);p!=null&&i.push([p,c])}return i.sort((c,d)=>c[0]<d[0]?-1:c[0]>d[0]?1:c[1]<d[1]?-1:c[1]>d[1]?1:0),i}mount(e,t){if(t===void 0){let s=new o(e);return this.mount(e,s)}if(typeof t=="function"){let s=new o(e);return t(s),this.mount(e,s)}let n=t;if(ke(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let t=ft(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let n=t[0],s=t.slice(1);if(s.length===0){let c=this._nodes.get(n);if(c)return c;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 r=this._nodes.get(n);if(r&&s.length>0&&s[0]===B)return this._resolveMetaChainFromNode(r,s,t.join($));let i=this._mounts.get(n);if(!i)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${s.join($)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(s.join($))}_resolveMetaChainFromNode(e,t,n){let s=e,r=0,i=[...t];for(;r<i.length;){if(i[r]!==B)throw new Error(`Graph "${this.name}": expected ${B} segment in meta path "${n}"`);if(r+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${B} in "${n}"`);let c=i[r+1],d=s.meta[c];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${c}" in path "${n}"`);s=d,r+=2}return s}signal(e,t){if(t?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let n=[];if(this._signalDeliver(e,t??{},new Set,n),n.length>0)throw n[0]}_signalDeliver(e,t,n,s){for(let d of this._mounts.values())d._signalDeliver(e,t,n,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},c=ht(e,this.config);for(let d of[...this._nodes.keys()].sort()){let a=this._nodes.get(d);if(!n.has(a)){n.add(a);try{a.down(e,i)}catch(p){if(p instanceof U)throw p;s.push(p)}c.length!==0&&this._signalMetaSubtree(a,c,n,i,s)}}}_signalMetaSubtree(e,t,n,s,r){for(let i of Object.keys(e.meta).sort()){let c=e.meta[i];if(!n.has(c)){n.add(c);try{c.down(t,s)}catch(d){if(d instanceof U)throw d;r.push(d)}this._signalMetaSubtree(c,t,n,s,r)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=ot(e?.actor),n=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let s=ve(e?.detail,e?.fields),r=e?.detail==="spec",i=s,c=[];this._collectObserveTargets("",c);let d=new Map;for(let[v,w]of c)d.set(w,v);let a=[];{let v=c.map(([,S])=>S),w=new Set(d.values()),E=0;for(;v.length>0;){let S=v.shift();if(S instanceof M)for(let R of S._deps){let G=R.node;if(d.has(G))continue;let D=G.name??"",k=D;if(!k||w.has(k))if(D){let I=2;for(;w.has(`${D}#${I}`);)I++;k=`${D}#${I}`}else for(k=`__internal__/${E++}`;w.has(k);)k=`__internal__/${E++}`;d.set(G,k),w.add(k),a.push([k,G]),v.push(G)}}}let p=[...c,...a],g={};for(let[v,w]of p){if(t!=null&&!w.allowsObserve(t))continue;let E=ye(w,i,r),S=w instanceof M?w._deps.map(k=>d.get(k.node)??k.node.name??""):[],{name:R,...G}=E,D={...G,deps:S};if(!r){let k=this._annotations.get(v);k!=null&&(D.annotation=k)}if(n!=null)if(typeof n=="function"){let k=n;if(!(k.length>=2?k(v,D):k(D)))continue}else{let k=!0;for(let[I,T]of Object.entries(n)){let x=I==="deps_includes"?"depsIncludes":I==="meta_has"?"metaHas":I;if(x==="depsIncludes"){if(!D.deps.includes(String(T))){k=!1;break}continue}if(x==="metaHas"){if(!Object.hasOwn(D.meta??{},String(T))){k=!1;break}continue}if(D[x]!==T){k=!1;break}}if(!k)continue}g[v]=D}let h=new Set(Object.keys(g)),f=[];for(let[v,w]of p)if(w instanceof M)for(let E of w._deps){let S=d.get(E.node);S!=null&&f.push([S,v])}f.sort((v,w)=>v[0]<w[0]?-1:v[0]>w[0]?1:v[1]<w[1]?-1:v[1]>w[1]?1:0);let u=f.map(([v,w])=>({from:v,to:w}));(t!=null||n!=null)&&(u=u.filter(v=>h.has(v.from)&&h.has(v.to)));let y=this._collectSubgraphs(""),l=t!=null||n!=null?y.filter(v=>{let w=`${v}${$}`;return[...h].some(E=>E===v||E.startsWith(w))}):y,O=this,m=e;return{name:this.name,nodes:g,edges:u,subgraphs:l,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(v){let w={...m};return Array.isArray(v)?(w.fields=v,w.detail=void 0):(w.detail=v,w.fields=void 0),O.describe(w)}}}_collectSubgraphs(e){let t=[];for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${n}`;t.push(s),t.push(...this._mounts.get(n)._collectSubgraphs(`${s}${$}`))}return t}resourceProfile(e){return Ve(this,e)}reachable(e,t,n={}){return n.withDetail===!0?Je(this.describe(),e,t,{...n,withDetail:!0}):Je(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(V(e),V(t),{...n?.maxDepth!==void 0?{maxDepth:Ke(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:He(n.findCycle)}:{}})}_explainStatic(e,t,n){let s=this.describe({detail:"full"}),r=new Map(this._annotations),i=new Map;for(let[c,d]of Object.entries(s.nodes))d.lastMutation!=null&&i.set(c,d.lastMutation);return Fe(s,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:r,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",s=0,r=Z(s,{name:`${n}_version`}),i=this.observe({timeline:!0,structured:!0}),c=!1,d=!1,a=()=>{c||d||(c=!0,te(()=>{c=!1,!d&&(s+=1,r.emit(s))}))},p=i.onEvent(m=>{let b=m.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||a()}),g=[],h=new WeakSet,f=m=>{if(h.has(m)||d)return;h.add(m);let b=m.topology.subscribe(v=>{for(let w of v){if(w[0]!==q)continue;let E=w[1];if(a(),E.kind==="added"&&E.nodeKind==="mount"){let S=m._mounts.get(E.name);S!=null&&f(S)}}});g.push(b);for(let v of m._mounts.keys()){let w=m._mounts.get(v);w!=null&&f(w)}};f(this);let u,y=e.actor;Ye(y)&&(u=y.subscribe(m=>{let b=!1,v=!1;for(let w of m){let E=w[0];E===q?b=!0:(E===H||E===W||E===L)&&(v=!0)}b&&a(),v&&(u?.(),u=void 0,a())}));let l;try{l=be([r],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,b)=>m===b})}catch(m){p(),u?.();for(let b of g)b();throw i.dispose(),m}let O=ne(l);return{node:l,dispose(){d=!0,p(),u?.();for(let m of g)m();g.length=0,i.dispose(),O()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},n=e.reactiveName??"describe-diff",s={name:this.name,nodes:{},edges:[],subgraphs:[]},r=this.describe(t),i=_e(s,r),c=Z(i,{name:n,meta:{domain:"audit",kind:"describe-diff"},equals:(h,f)=>h===f}),d=this._describeReactive({...e,reactiveName:void 0}),a=!1,p=d.node.subscribe(h=>{if(!a)for(let f of h){if(f[0]!==q)continue;let u=f[1],y=_e(r,u);r=u,y.events.length!==0&&c.emit(y)}}),g=ne(c);return{node:c,dispose(){a=!0,p(),d.dispose(),c.down([[L,"describe-diff disposed"]]),g()}}}_explainReactive(e,t,n){let s=0,r=Z(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),c=!1,d=!1,a=()=>{c||d||(c=!0,te(()=>{c=!1,!d&&(s+=1,r.emit(s))}))},p=i.onEvent(m=>{let b=m.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||a()}),g=[];e!=null&&K(e)&&g.push(e),t!=null&&K(t)&&g.push(t),n?.maxDepth!=null&&K(n.maxDepth)&&g.push(n.maxDepth),n?.findCycle!=null&&K(n.findCycle)&&g.push(n.findCycle);let h=()=>{for(let m of g)if(m.cache===void 0)return!1;return!0},f=()=>{let m=V(e),b=V(t);return{from:m,to:b,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:m,to:b,found:!1,reason:"pending",steps:[]})}},u;try{u=be([r],()=>{if(!h())return f();let m=V(e),b=V(t),v={...n?.maxDepth!==void 0?{maxDepth:Ke(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:He(n.findCycle)}:{}};return this._explainStatic(m,b,v)},{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:V(e),to:V(t)},equals:(m,b)=>m.found===b.found&&m.reason===b.reason&&m.steps.length===b.steps.length&&mt(m.steps,b.steps)})}catch(m){throw p(),i.dispose(),m}let y=ne(u),l=[],O=m=>{let b;return b=m.subscribe(v=>{let w=!1,E=!1;for(let S of v){let R=S[0];R===q?w=!0:(R===H||R===W||R===L)&&(E=!0)}(w||E)&&a(),E&&b&&(b(),b=void 0)}),()=>{b&&(b(),b=void 0)}};for(let m of g)l.push(O(m));return{node:u,dispose(){d=!0,p();for(let m of l)m?.();l.length=0,i.dispose(),y()}}}_pathsMatching(e){let t=ie(e),n=[];return this._collectObserveTargets("",n),n.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${$}${n}`;this._mounts.get(n)._collectObserveTargets(s,t)}for(let n of[...this._nodes.keys()].sort()){let s=this._nodes.get(n),r=e===""?n:`${e}${$}${n}`;t.push([r,s]),this._appendMetaObserveTargets(r,s,t)}}_appendMetaObserveTargets(e,t,n){for(let s of Object.keys(t.meta).sort()){let r=t.meta[s],i=`${e}${$}${B}${$}${s}`;n.push([i,r]),this._appendMetaObserveTargets(i,r,n)}}observe(e,t){let n=typeof e=="string",r=Ue(n?t:e);if(r.reactive===!0)return this._observeReactive(n?e:void 0,r);let i=r.structured===!0||r.timeline===!0||r.causal===!0||r.derived===!0||r.detail==="minimal"||r.detail==="full"||r.format!=null,c=r.actor;if(n){let p=e,g=this.resolve(p);if(c!=null&&!g.allowsObserve(c))throw new U({actor:c,action:"observe",nodeName:p});return i?this._buildStructuredObserver([[p,g]],r,"one"):{subscribe(h){return g.subscribe(h)},up(h){try{g.up?.(h)}catch(f){if(f instanceof U)return;throw f}}}}let d=[];this._collectObserveTargets("",d),d.sort((p,g)=>p[0]<g[0]?-1:p[0]>g[0]?1:0);let a=c==null?d:d.filter(([,p])=>p.allowsObserve(c));return i?this._buildStructuredObserver(a,r,"all"):{subscribe:p=>{let g=a.map(([h,f])=>f.subscribe(u=>{p(h,u)}));return()=>{for(let h of g)h()}},up:(p,g)=>{try{this.resolve(p).up?.(g)}catch(h){if(h instanceof U)return;throw h}}}}_observeReactive(e,t){let n=t.tiers,s=n!=null?new Set(n):null,r=t.reactiveName??"observe";return me(i=>{let c=[],d=!1,a=!1,p=()=>{if(c.length===0||a)return;let y={events:c.slice(),flushedAt_ns:z()};c.length=0,i.emit(y)},g={...t,reactive:!1,structured:!0,timeline:!0},h=e!=null?this.observe(e,g):this.observe(g),f=y=>{a||(c.push(y),!d&&(d=!0,te(()=>{d=!1,p()})))};for(let y of h.events)f(y);let u=h.onEvent(f);return()=>{a=!0,u(),h.dispose()}},{name:r,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,n){let s=n==="one"?e[0]?.[0]:void 0,r=i=>{if(n==="one"&&s!=null){let p=this.resolve(s);return this._buildStructuredObserver([[s,p]],i,"one")}let c=[];this._collectObserveTargets("",c),c.sort((p,g)=>p[0]<g[0]?-1:p[0]>g[0]?1:0);let d=i.actor,a=d==null?c:c.filter(([,p])=>p.allowsObserve(d));return this._buildStructuredObserver(a,i,"all")};return this._createObserveResult(e,t,r)}_createObserveResult(e,t,n){let s=t.timeline===!0,r=t.causal===!0,i=t.derived===!0,c=t.detail==="minimal",d=this.config.inspectorEnabled,a=(r||i)&&d,p=t.maxEvents,g=p!=null&&p>0?new we(p):null,h=[],f=new Set,u=t.tiers!=null?new Set(t.tiers):null,y={},l=new Set,O=0,m=0,b=0,v=0,w=0,E=0,S=!1,R=!1,G=0,D=new Map,k=new Map,I=new Map,T=_=>{if(!(u!=null&&!u.has(_.type))){g?g.push(_):h.push(_);for(let C of f)C(_)}},x=_=>u==null||u.has(_),Re=()=>s?{timestamp_ns:z(),in_batch:Ae(),batch_id:G}:{},Ze=(_,C)=>{if(!(!a||!(_ instanceof M)))return _._setInspectorHook(j=>{if(j.kind==="dep_message")D.set(_,j.depIndex);else if(j.kind==="run"){let Y=j.batchData.map((N,P)=>N!=null&&N.length>0?N.at(-1):j.prevData[P]);k.set(_,Y);let F=j.batchData.map(N=>N!=null?[...N]:void 0);I.set(_,F),i&&T({type:"derived",path:C,dep_values:Y,dep_batches:F,...Re()})}})},Ne=_=>{let C=D.get(_),j=k.get(_);if(!r||j==null)return{};let F=(C!=null&&C>=0&&_ instanceof M?_._deps[C]:void 0)?.node,N=F?.v,P=I.get(_);return{trigger_dep_index:C,trigger_dep_name:F?.name,...N!=null?{trigger_version:{id:N.id,version:N.version}}:{},dep_values:[...j],...P!=null?{dep_batches:P}:{}}},Ge=[],De=[];for(let[_,C]of e){let j=Ze(C,_);j&&Ge.push(j),De.push(C.subscribe(Y=>{G++;for(let F of Y){let N=F[0],P=Re();if(N===q){y[_]=F[1];let de=C instanceof M?C.lastMutation?.actor??Q:Q;T({type:"data",path:_,data:F[1],actor:de,...P,...Ne(C)})}else if(c)N===le?x("dirty")&&O++:N===pe?x("resolved")&&m++:N===ee?x("invalidate")&&b++:N===fe?x("pause")&&v++:N===he?x("resume")&&w++:N===L?x("teardown")&&E++:N===H&&!l.has(_)?x("complete")&&(S=!0):N===W&&x("error")&&(R=!0,l.add(_));else if(N===le)x("dirty")&&O++,T({type:"dirty",path:_,...P});else if(N===pe)x("resolved")&&m++,T({type:"resolved",path:_,...P,...Ne(C)});else if(N===ee)x("invalidate")&&b++,T({type:"invalidate",path:_,...P});else if(N===fe)x("pause")&&v++,T({type:"pause",path:_,lockId:F[1],...P});else if(N===he)x("resume")&&w++,T({type:"resume",path:_,lockId:F[1],...P});else if(N===H)x("complete")&&!l.has(_)&&(S=!0),T({type:"complete",path:_,...P});else if(N===W){x("error")&&(R=!0,l.add(_));let de=C instanceof M?C.lastMutation?.actor??Q:Q;T({type:"error",path:_,data:F[1],actor:de,...P})}else N===L&&(x("teardown")&&E++,T({type:"teardown",path:_,...P}))}}))}let ae=!1,ue=()=>{if(!ae){ae=!0;for(let _ of De)_();for(let _ of Ge)_();for(let _ of X)_({value:void 0,done:!0});X.length=0}},ce=[],X=[];f.add(_=>{let C=X.shift();C?C({value:_,done:!1}):ce.push(_)});let Ce={get values(){return y},get dirtyCount(){return O},get resolvedCount(){return m},get invalidateCount(){return b},get pauseCount(){return v},get resumeCount(){return w},get teardownCount(){return E},get events(){return g?g.toArray():[...h]},get anyCompletedCleanly(){return S},get anyErrored(){return R},get completedWithoutErrors(){return S&&!R},onEvent(_){return f.add(_),()=>f.delete(_)},dispose:ue,expand(_){ue();let C={...t};return typeof _=="string"?C.detail=_:Object.assign(C,_),n(Ue(C))},[Symbol.asyncIterator](){return{next(){return ce.length>0?Promise.resolve({value:ce.shift(),done:!1}):ae?Promise.resolve({value:void 0,done:!0}):new Promise(_=>X.push(_))},return(){return ue(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Ce,t),Ce}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let s=t.logger??(u=>console.log(u)),r=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,c=r==null&&i==null?()=>!0:u=>(r==null||r.has(u))&&(i==null||!i.has(u)),d=lt(t.theme),a=n==="stage-log"?z():0,p=u=>u==null?"":t.stageLabels?.[u]??u,g=(u,y)=>u.length>y?`${u.slice(0,y-1)}\u2026`:u,h=u=>u.type==="data"||u.type==="error"?g(Ee(u.data),120):"",f=u=>{if(n==="stage-log"){let S=(z()-a)/1e9,R=p(u.path).padEnd(9);if(u.type==="data"){let G=h(u);return`[${S.toFixed(3)}s] ${R} \u2190${G?` ${G}`:""}`}if(u.type==="error"){let G=h(u);return`[${S.toFixed(3)}s] ${R} \u2717${G?` ${G}`:""}`}return u.type==="complete"?`[${S.toFixed(3)}s] ${R} \u25A0 complete`:`[${S.toFixed(3)}s] ${R} ${u.type}`}if(n==="json")try{return JSON.stringify(u)}catch{return JSON.stringify({type:u.type,path:u.path,data:"[unserializable]"})}let y=d[u.type]??"",l=u.path?`${d.path}${u.path}${d.reset} `:"",O=u.type==="data"||u.type==="error",m=u.type==="pause"||u.type==="resume",b=O?` ${Ee(u.data)}`:m?` ${Ee(u.lockId)}`:"",v=u.type==="data"||u.type==="resolved"||u.type==="derived"?u:void 0,w=v?.trigger_dep_name!=null?` <- ${v.trigger_dep_name}`:v?.trigger_dep_index!=null?` <- #${v.trigger_dep_index}`:"",E=u.in_batch?" [batch]":"";return`${l}${y}${u.type.toUpperCase()}${d.reset}${b}${w}${E}`};e.onEvent(u=>{c(u.type)&&s(f(u),u)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){qe(this._disposers,this.name),this.signal([[L]],{internal:!0}),qe(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:t,...n}=this.describe({detail:"full"}),s={};for(let c of Object.keys(n.nodes).sort()){let{lastMutation:d,guard:a,...p}=n.nodes[c];s[c]=p}let r=[...n.subgraphs].sort(),i={...n,version:1,nodes:s,subgraphs:r};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let c=this.config.lookupCodec(e.codec);if(c==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return $e(c,c.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??ge,{codec:s,codecVersion:r,payload:i}=xe(e,n);return s.decode(i,r)}restore(e,t){if(We(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let n=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(r=>ie(r)),s=t?.includeProducers===!0;for(let r of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(c=>c.test(r)))continue;let i=e.nodes[r];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(r,new Error(`restore: slice.value is undefined for "${r}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let d=this.tryResolve(r)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(r,i.value)}catch(c){t?.onError?.(r,c)}}}}}static fromSnapshot(e,t){We(e);let n=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,r=new o(e.name);if(n)return n(r),r.restore(e),r;for(let f of[...e.subgraphs].sort((u,y)=>{let l=u.split($).length,O=y.split($).length;return l!==O?l-O:u<y?-1:u>y?1:0})){let u=f.split($),y=r;for(let l of u)y._mounts.has(l)||y.mount(l,new o(l)),y=y._mounts.get(l)}let i=s?Object.entries(s).map(([f,u])=>({re:ie(f),factory:u})):[],c=f=>{for(let u of i)if(u.re.test(f))return u.factory},d=f=>{let u=f.split($),y=u.pop();if(y==null||y.length===0)throw new Error(`invalid snapshot path "${f}"`);let l=r;for(let O of u){let m=l._mounts.get(O);if(!m)throw new Error(`unknown mount "${O}" in path "${f}"`);l=m}return[l,y]},a=Object.entries(e.nodes).filter(([f])=>!f.includes(`${$}${B}${$}`)).sort((f,u)=>f[0]<u[0]?-1:f[0]>u[0]?1:0),p=new Map(a),g=new Map,h=!0;for(;p.size>0&&h;){h=!1;for(let[f,u]of[...p.entries()]){let y=u?.deps??[];if(!y.every(w=>g.has(w)))continue;let[l,O]=d(f),m={...u?.meta??{}},b=c(f),v;if(u?.type==="state")v=Z(u.value,{meta:m});else{if(b==null)continue;v=b(O,{path:f,type:u.type,value:u.value,meta:m,deps:y,resolvedDeps:y.map(w=>g.get(w))})}l.add(v,{name:O}),g.set(f,v),p.delete(f),h=!0}}if(p.size>0){let f=[...p.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 r.restore(e),r}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let n=e.map(a=>({tier:a,debounceMs:Math.max(0,a.debounceMs??0),compactEvery:Math.max(1,a.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let s=(a,p)=>{if(a.disposed)return;let g=it(p.nodes);if(a.lastSnapshot!=null&&g!==""&&g===a.lastFingerprint)return;let h=a.seq+1,f=Pe(),l=a.lastSnapshot==null||h%a.compactEvery===0?{name:this.name,mode:"full",snapshot:p,seq:h,timestamp_ns:f,format_version:J}:{name:this.name,mode:"diff",diff:gt(a.lastSnapshot,p),seq:h,timestamp_ns:f,format_version:J};if(a.tier.filter&&!a.tier.filter(l))return;let O;try{O=a.tier.save(l)}catch(m){t.onError?.(m,a.tier);return}if(O&&typeof O.then=="function"){let v=(a.savePending??Promise.resolve()).then(()=>O,()=>O).then(()=>{a.disposed||(a.seq=h,a.lastSnapshot=p,a.lastFingerprint=g)},w=>{t.onError?.(w,a.tier)});a.savePending=v.finally(()=>{a.savePending===v&&(a.savePending=void 0)})}else a.seq=h,a.lastSnapshot=p,a.lastFingerprint=g},r=(a,p)=>{try{s(a,p)}catch(g){t.onError?.(g,a.tier)}},i=(a,p)=>{if(!p.some(u=>{let y=this.config.messageTier(u[0]);return y>=3&&y<5}))return;if(t.filter){let u=this.tryResolve(a);if(u==null)return;let y=ye(u,ve("standard"));if(!t.filter(a,y))return}let h,f=()=>(h==null&&(h=this.snapshot()),h);for(let u of n)u.disposed||(u.debounceMs===0?r(u,f()):(u.timer==null&&(u.timer=new Me),u.timer.start(u.debounceMs,()=>{u.disposed||r(u,this.snapshot())})))},c;if(t.paths!=null){let p=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(g=>{let h=this.tryResolve(g);return h==null?()=>{}:h.subscribe(f=>i(g,f))});c=()=>{for(let g of p)g()}}else c=this.observe().subscribe((a,p)=>i(a,p));let d=()=>{c();for(let a of n)a.disposed=!0,a.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,t){for(let n of e){let s;try{s=await n.load?.()}catch(i){t?.(i,n);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let r=s;try{if(r.mode==="full"&&r.snapshot!=null)return this.restore(r.snapshot),!0;if(r.version===J&&r.nodes!=null)return this.restore(r),!0}catch(i){t?.(i,n)}}return!1}static async fromStorage(e,t,n){for(let s of t){let r;try{r=await s.load?.()}catch(d){n?.onError?.(d,s);continue}if(r==null||typeof r!="object"||Array.isArray(r))continue;let i=r,c=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===J&&i.nodes!=null?i:void 0;if(c!=null)try{return o.fromSnapshot(c,n)}catch(d){n?.onError?.(d,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,n){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:z(),...n?.actor!=null?{actor:n.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(s=>!e(s)),n=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return n}static diff(e,t){let n=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),r=[...s].filter(m=>!n.has(m)).sort(),i=[...n].filter(m=>!s.has(m)).sort(),c=[],d=[];for(let m of n){if(!s.has(m))continue;let b=e.nodes[m],v=t.nodes[m],w=b.v,E=v.v;w!=null&&E!=null&&w.id===E.id&&w.version!==E.version&&d.push({path:m,id:w.id,from:w.version,to:E.version});let S=w!=null&&E!=null&&w.id===E.id&&w.version===E.version;for(let R of["type","status","sentinel"]){let G=b[R],D=v[R];G!==D&&c.push({path:m,field:R,from:G,to:D})}if(!S)for(let R of["value","meta"]){let G=b[R],D=v[R];at(G,D)||c.push({path:m,field:R,from:G,to:D})}}let a=m=>`${m.from} ${m.to}`,p=new Set(e.edges.map(a)),g=new Set(t.edges.map(a)),h=t.edges.filter(m=>!p.has(a(m))),f=e.edges.filter(m=>!g.has(a(m))),u=new Set(e.subgraphs),y=new Set(t.subgraphs),l=[...y].filter(m=>!u.has(m)).sort(),O=[...u].filter(m=>!y.has(m)).sort();return{nodesAdded:r,nodesRemoved:i,nodesChanged:c,versionChanges:d,edgesAdded:h,edgesRemoved:f,subgraphsAdded:l,subgraphsRemoved:O}}};function gt(o,e){let t=Se.diff(o,e),n={};for(let s of t.nodesAdded){let r=e.nodes[s];r!=null&&(n[s]=r)}return{...t,nodesAddedFull:n}}function Je(o,e,t,n={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return n.withDetail?s:[];if(!n.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let r=n.maxDepth;if(r!=null&&(!Number.isInteger(r)||r<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(r===0)return n.withDetail?s:[];let i=new Map,c=new Map,d=new Map,a=new Map,p=new Set;for(let[b,v]of Object.entries(o.nodes)){if(!b)continue;p.add(b);let w=v.deps??[];i.set(b,w);for(let E of w)E&&(p.add(E),c.has(E)||c.set(E,new Set),c.get(E).add(b))}for(let b of o.edges){if(b==null||typeof b!="object")continue;let v=typeof b.from=="string"?b.from:"",w=typeof b.to=="string"?b.to:"";!v||!w||(p.add(v),p.add(w),a.has(v)||a.set(v,new Set),a.get(v).add(w),d.has(w)||d.set(w,new Set),d.get(w).add(v))}if(!p.has(e))return n.withDetail?s:[];let g=n.both===!0,h=b=>{if(g){let S=i.get(b)??[],R=d.get(b),G=c.get(b),D=a.get(b),k=[...S];return R&&k.push(...R),G&&k.push(...G),D&&k.push(...D),k}if(t==="upstream"){let S=i.get(b)??[],R=d.get(b);return R?[...S,...R]:S}let v=c.get(b),w=a.get(b),E=v?[...v]:[];return w&&E.push(...w),E},f=new Set([e]),u=new Map,y=[{path:e,depth:0}],l=0,O=!1;for(;l<y.length;){let b=y[l++];if(r!=null&&b.depth>=r){h(b.path).length>0&&(O=!0);continue}for(let v of h(b.path))!v||f.has(v)||(f.add(v),u.set(v,b.depth+1),y.push({path:v,depth:b.depth+1}))}let m=[...u.keys()].sort((b,v)=>b<v?-1:b>v?1:0);return n.withDetail?{paths:m,depths:u,truncated:O}:m}function mt(o,e){if(o.length!==e.length)return!1;for(let t=0;t<o.length;t++){let n=o[t],s=e[t];if(n.path!==s.path||n.type!==s.type||n.status!==s.status||n.hop!==s.hop||n.dep_index!==s.dep_index||n.annotation!==s.annotation||n.value!==s.value||n.lastMutation!==s.lastMutation)return!1;let r=n.v,i=s.v;if(r!==i&&(r==null||i==null||r.id!==i.id||r.version!==i.version))return!1}return!0}export{_e as a,Fe as b,A as c,nt as d,ze as e,Ve as f,B as g,J as h,Se as i,gt as j,Je as k};
@@ -1 +1 @@
1
- import{a as D,c as j,d as V,e as $}from"./chunk-B5S7KTGP.js";import{a as v}from"./chunk-ESMPEKEV.js";import{i as S}from"./chunk-D5RFJOZ2.js";import{n as T}from"./chunk-6773HURD.js";import{m as R,x as N}from"./chunk-RZ5HKPGI.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};
1
+ import{a as D,c as j,d as V,e as $}from"./chunk-6I726LZU.js";import{a as v}from"./chunk-ESMPEKEV.js";import{i as S}from"./chunk-D5RFJOZ2.js";import{n as T}from"./chunk-FHRBBHJN.js";import{m as R,x as N}from"./chunk-CKFQS2CJ.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};
@@ -1 +1 @@
1
- import{k as _}from"./chunk-QMC2PLNM.js";import{D as g,E as k}from"./chunk-LYCLF26R.js";import{b as R,c as T,d,h as A,i as O,j as D}from"./chunk-CK2E7BTU.js";function L(c,y,l,a){let s=new _(c,a);s.add(y,{name:"source"});let n=k(l,{meta:{kind:"stratify_rules"}});s.add(n,{name:"rules"});for(let f of l)E(s,y,n,f);return s}function E(c,y,l,a){let s=`branch/${a.name}`,n=Symbol("noValue"),f=!1,m=!1,p=!1,N=n,r=!1,h=l.cache??[];function v(o){if(p){p=!1;let t=N;if(N=n,t!==n){let i=h.find(u=>u.name===a.name),e=!1;try{e=i?.classify(t)??!1}catch{e=!1}e?(r=!1,o.emit(t)):r&&(r=!1,o.down([[T],[d]]))}else r?(r=!1,o.down([[T],[d]])):o.down([[d]])}}let S=g([],(o,t)=>{let i=y.subscribe(u=>{for(let b of u)w(b,0,t)}),e=l.subscribe(u=>{for(let b of u)w(b,1,t)});return()=>{i(),e()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:a.name},completeWhenDepsComplete:!1});function w(o,t,i){let e=o[0];return e===T?(t===0?(f=!0,r=!0):m=!0,!0):e===R||e===d?(t===0?(f=!1,p=!0,N=e===R?o[1]:n):(e===R&&(h=o[1]),m=!1),f||m||v(i),!0):e===O||e===D||e===A?(f=!1,m=!1,p=!1,N=n,r=!1,t===0&&i.down([o]),!0):t===1}if(c.add(S,{name:s}),a.ops){let o=a.ops(S),t=`branch/${a.name}/out`;c.add(o,{name:t})}}export{L as a};
1
+ import{i as _}from"./chunk-2BX4NB34.js";import{D as g,E as k}from"./chunk-LYCLF26R.js";import{b as R,c as T,d,h as A,i as O,j as D}from"./chunk-CK2E7BTU.js";function L(c,y,l,a){let s=new _(c,a);s.add(y,{name:"source"});let n=k(l,{meta:{kind:"stratify_rules"}});s.add(n,{name:"rules"});for(let f of l)E(s,y,n,f);return s}function E(c,y,l,a){let s=`branch/${a.name}`,n=Symbol("noValue"),f=!1,m=!1,p=!1,N=n,r=!1,h=l.cache??[];function v(o){if(p){p=!1;let t=N;if(N=n,t!==n){let i=h.find(u=>u.name===a.name),e=!1;try{e=i?.classify(t)??!1}catch{e=!1}e?(r=!1,o.emit(t)):r&&(r=!1,o.down([[T],[d]]))}else r?(r=!1,o.down([[T],[d]])):o.down([[d]])}}let S=g([],(o,t)=>{let i=y.subscribe(u=>{for(let b of u)w(b,0,t)}),e=l.subscribe(u=>{for(let b of u)w(b,1,t)});return()=>{i(),e()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:a.name},completeWhenDepsComplete:!1});function w(o,t,i){let e=o[0];return e===T?(t===0?(f=!0,r=!0):m=!0,!0):e===R||e===d?(t===0?(f=!1,p=!0,N=e===R?o[1]:n):(e===R&&(h=o[1]),m=!1),f||m||v(i),!0):e===O||e===D||e===A?(f=!1,m=!1,p=!1,N=n,r=!1,t===0&&i.down([o]),!0):t===1}if(c.add(S,{name:s}),a.ops){let o=a.ops(S),t=`branch/${a.name}/out`;c.add(o,{name:t})}}export{L as a};
@@ -0,0 +1 @@
1
+ import{c as $,g as _}from"./chunk-756D5TFD.js";import{a as L}from"./chunk-L6NSJVJZ.js";import{i as F}from"./chunk-2BX4NB34.js";import{b as z}from"./chunk-35JTVPOX.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 ie}from"./chunk-QYADASLV.js";var se={};ie(se,{PipelineGraph:()=>x,decisionKeyOf:()=>q,pipelineGraph:()=>W});function N(y,t){return L("orchestration",y,t)}var q=y=>y.action,x=class extends F{constructor(t,i){super(t,i)}task(t,i,e={}){let a=(e.deps??[]).map(c=>this._resolveStep(c)),p=D(a,i,{name:t,describeKind:"derived",meta:N("task",e.meta)});return this.add(p,{name:t}),p}classify(t,i,e,a={}){let p=this._resolveStep(i),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,i,e={}){let a=Object.keys(i),p=a.map(d=>this._resolveStep(i[d])),c=D(p,d=>{let f={};for(let s=0;s<a.length;s++)f[a[s]]=d[s];return f},{name:t,describeKind:"derived",meta:N("combine",e.meta)});return this.add(c,{name:t}),c}approvalGate(t,i,e={}){let a=e.maxPending??1e3;if(a<1&&a!==Number.POSITIVE_INFINITY)throw new RangeError("approvalGate: maxPending must be >= 1");let p=e.startOpen??!1;typeof i!="string"&&this.nameOf(i)===void 0&&this.add(i,{name:`${t}/source`});let c=this._resolveStep(i),d=new F(`${t}_state`),f=G([],{name:"pending",equals:()=>!1}),s=G(p,{name:"isOpen"}),R=D([f],([n])=>n.length,{name:"count"}),T=G(0,{name:"droppedCount"}),u=$({name:"decisions",retainedLimit:1024,graph:d});d.add(f,{name:"pending"}),d.add(s,{name:"isOpen"}),d.add(R,{name:"count"}),d.add(T,{name:"droppedCount"}),this.mount(`${t}_state`,d);let l=[],v=!1,k=!1,w=p,M=s.subscribe(n=>{for(let o of n)o[0]===P&&(w=o[1])});this.addDisposer(M);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 U(n){if(l.push(n),l.length>a){let o=l.shift();T.emit(T.cache+1),C("drop",[o])}A()}function O(n){let o=l.splice(0,n);return A(),o}let b=j([c],(n,o,r)=>{let h=r.terminalDeps[0];if(h!==void 0){v=!0;let g=l.length;l=[],A(),C("teardown",void 0,g),o.down(h===!0?[[I]]:[[K,h]]);return}let m=n[0];if(m==null||m.length===0){o.down([[S]]);return}for(let g of m)w?o.emit(g):(U(g),o.down([[S]]))},{name:t,describeKind:"derived",meta:N("approval_gate",e.meta)});if(this.add(b,{name:t}),e.approver!=null){e.approver.cache&&(s.emit(!0),w=!0,e.onceOnly&&(k=!0));let o=e.approver.subscribe(r=>{for(let h of r){if(h[0]!==P)continue;let m=!!h[1];if(m&&!w){if(e.onceOnly){if(k)continue;k=!0}E(()=>{s.emit(!0);let g=O(l.length);C("open",g);for(let te of g){if(v)break;b.emit(te)}})}else if(!m&&w){if(e.onceOnly&&k)continue;E(()=>{s.emit(!1),C("close")})}}});this.addDisposer(o)}let V=n=>{if(v)throw new Error(`approvalGate: ${n}() called after the gate was torn down`)},Y=(n=1)=>{V("approve");let o=O(n);for(let r of o){if(v)break;b.emit(r)}},H=(n=1)=>{V("reject"),O(n)},J=(n,o=1)=>{V("modify");let r=[...l],h=O(o);for(let m=0;m<h.length&&!v;m++)b.emit(n(h[m],m,r))},Q=()=>{V("open"),s.emit(!0);let n=O(l.length);for(let o of n){if(v)break;b.emit(o)}},X=()=>{V("close"),!(e.onceOnly&&k)&&s.emit(!1)},Z=_(Y,{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}:{}})}),ee=_(H,{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}:{}})}),ne=_(J,{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}:{}})}),re=_(Q,{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}:{}})}),oe=_(X,{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:s,droppedCount:T,decisions:u,audit:u,approve:Z,reject:ee,modify:ne,open:re,close:oe}}approval(t,i,e,a={}){return this.approvalGate(t,i,{...a,approver:e,maxPending:1})}catch(t,i,e,a={}){let p=this._resolveStep(i),c=a.on??"errored",d=j([p],(f,s,R)=>{let T=R.terminalDeps[0];if(T!==void 0){let l=T===!0?{kind:"completed"}:{kind:"errored",error:T};if(c==="terminal"||c===l.kind){s.emit(e(l,s));return}s.down(l.kind==="completed"?[[I]]:[[K,l.error]]);return}let u=f[0];if(u==null||u.length===0){s.down([[S]]);return}for(let l of u)s.emit(l)},{name:t,describeKind:"derived",completeWhenDepsComplete:a.completeWhenDepsComplete??!(c==="completed"||c==="terminal"),errorWhenDepsError:!(c==="errored"||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 W(y,t){let i=new x(y,t),{factory:e,factoryArgs:a,...p}=t??{};return i.tagFactory("pipelineGraph",z(p)),i}export{q as a,x as b,W as c,se as d};
@@ -0,0 +1 @@
1
+ import{C as p,v as f}from"./chunk-LYCLF26R.js";function v(t,n){if(n!=null&&n.length>0)return new Set(n);switch(t){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function b(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function D(t){let n=new WeakSet,r={};for(let[e,a]of m(t))r[e]=d(a,n);return r}function d(t,n){if(t==null)return t;let r=typeof t;if(r==="boolean"||r==="number"||r==="string")return t;if(r==="function")return"<function>";if(Array.isArray(t))return n.has(t)?"<cycle>":(n.add(t),t.map(e=>d(e,n)));if(r==="object"){let e=t;if(n.has(e))return"<cycle>";n.add(e);try{if(typeof e.subscribe=="function"&&"cache"in e)return"<Node>"}catch{return"<unserializable>"}let a={};for(let[c,i]of m(e))a[c]=d(i,n);return a}return"<unserializable>"}function m(t){let n=[],r;try{r=Object.keys(t)}catch{return n}for(let e of r)try{n.push([e,t[e]])}catch{n.push([e,"<unserializable>"])}return n}function N(t,n){let r={factory:t};return n!==void 0&&(r.factoryArgs=n),r}function h(t){let n={};for(let[r,e]of Object.entries(t.meta))try{n[r]=e.cache}catch{}return n}function R(t,n,r){let e=n==null,a=!e&&n!=null?[...n].filter(s=>s.startsWith("meta.")).map(s=>s.slice(5)):null,c=e||n.has("meta")||a!=null&&a.length>0,i="state",g=[];t instanceof p&&(i=b(t),g=t._deps.map(s=>s.node.name??""));let o={type:i,deps:g};(e||n.has("status"))&&(o.status=t.status);let u=t instanceof p?t._guard:void 0;if(c){let s={...h(t)};if(u!=null&&s.access===void 0&&(s.access=f(u)),a!=null&&a.length>0&&!n.has("meta")){let y={};for(let l of a)l in s&&(y[l]=s[l]);o.meta=y}else o.meta=s}if(t.name!=null&&(o.name=t.name),(e||n.has("value"))&&(!r||i==="state")){t.status==="sentinel"&&(o.sentinel=!0);try{o.value=t.cache}catch{}}if((e||n.has("v"))&&t.v!=null){let s={id:t.v.id,version:t.v.version};"cid"in t.v&&(s.cid=t.v.cid,s.prev=t.v.prev),o.v=s}return(e||n.has("guard"))&&u!=null&&(o.guard=f(u)),(e||n.has("lastMutation"))&&t.lastMutation!=null&&(o.lastMutation=t.lastMutation),o}export{v as a,D as b,N as c,R as d};
@@ -0,0 +1,5 @@
1
+ import{a as S,b as _}from"./chunk-C72GO4IZ.js";var no={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"},to={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function F(o,t){let s=t.charset==="ascii"?to:no,i=o.width,r=o.height,e=Array.from({length:r},()=>Array.from({length:i},()=>" ")),n=Array.from({length:r},()=>Array.from({length:i},()=>"empty"));for(let a of o.edges)so(e,n,s,a);for(let a of o.boxes)io(e,n,s,a,t.labelOf(a.id));return e.map(a=>uo(a.join(""))).join(`
2
+ `)}function io(o,t,s,i,r){let{x:e,y:n,w:a,h:l}=i;if(a<2||l<2){l>0&&U(o,t,e,n,a,r);return}w(o,t,e,n,s.boxTL);for(let u=e+1;u<e+a-1;u+=1)w(o,t,u,n,s.boxH);w(o,t,e+a-1,n,s.boxTR);for(let u=n+1;u<n+l-1;u+=1){w(o,t,e,u,s.boxV);for(let f=e+1;f<e+a-1;f+=1)k(o,t,f,u," ","empty");w(o,t,e+a-1,u,s.boxV)}w(o,t,e,n+l-1,s.boxBL);for(let u=e+1;u<e+a-1;u+=1)w(o,t,u,n+l-1,s.boxH);w(o,t,e+a-1,n+l-1,s.boxBR);let c=n+Math.floor(l/2);U(o,t,e+1,c,a-2,r)}function w(o,t,s,i,r){k(o,t,s,i,r,r===" "?"empty":r==="\u2500"||r==="-"?"boxH":r==="\u2502"||r==="|"?"boxV":"boxCorner")}function k(o,t,s,i,r,e){if(i<0||i>=o.length)return;let n=o[i];s<0||s>=n.length||(n[s]=r,t[i][s]=e)}function U(o,t,s,i,r,e){if(i<0||i>=o.length)return;let n=s,a=r;for(let l of e){let c=S(l);if(c!==0){if(a<c)break;n>=0&&n<o[i].length&&(o[i][n]=l,t[i][n]="label",c===2&&n+1<o[i].length&&(o[i][n+1]="",t[i][n+1]="label")),n+=c,a-=c}}for(;a>0;)n>=0&&n<o[i].length&&(o[i][n]=" ",t[i][n]="empty"),n+=1,a-=1}function so(o,t,s,i){let r=i.points;if(r.length<2)return;for(let l=0;l+1<r.length;l+=1)ao(o,t,s,r[l],r[l+1]);for(let l=1;l+1<r.length;l+=1){let c=r[l-1],u=r[l],f=r[l+1],d=co(c,u,f,s);d&&K(o,t,u.x,u.y,d,"edgeCorner")}let e=r[r.length-1],n=r[r.length-2],a=lo(n,e,s);a&&K(o,t,e.x,e.y,a,"arrow")}function ao(o,t,s,i,r){if(!(i.x===r.x&&i.y===r.y)){if(i.y===r.y){let e=i.y,n=Math.min(i.x,r.x),a=Math.max(i.x,r.x);for(let l=n;l<=a;l+=1)z(o,t,l,e,s,"h")}else if(i.x===r.x){let e=i.x,n=Math.min(i.y,r.y),a=Math.max(i.y,r.y);for(let l=n;l<=a;l+=1)z(o,t,e,l,s,"v")}}}function z(o,t,s,i,r,e){if(i<0||i>=o.length)return;let n=o[i];if(s<0||s>=n.length)return;let a=t[i][s];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){n[s]=e==="h"?r.horizontal:r.vertical,t[i][s]=e==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&e==="v"){n[s]=r.cross,t[i][s]="edgeCorner";return}if(a==="edgeV"&&e==="h"){n[s]=r.cross,t[i][s]="edgeCorner";return}}}function K(o,t,s,i,r,e){if(i<0||i>=o.length)return;let n=o[i];if(s<0||s>=n.length)return;let a=t[i][s];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(n[s]=r,t[i][s]=e)}function co(o,t,s,i){let r=o.y===t.y,e=t.y===s.y;if(r===e)return;if(r){let l=o.x<t.x,c=s.y>t.y;return l&&c?i.cornerTR:l&&!c?i.cornerBR:!l&&c?i.cornerTL:i.cornerBL}let n=o.y<t.y,a=s.x>t.x;return n&&a?i.cornerBL:n&&!a?i.cornerBR:!n&&a?i.cornerTL:i.cornerTR}function lo(o,t,s){if(t.x>o.x)return s.arrowRight;if(t.x<o.x)return s.arrowLeft;if(t.y>o.y)return s.arrowDown;if(t.y<o.y)return s.arrowUp}function uo(o){let t=o.length;for(;t>0&&o.charCodeAt(t-1)===32;)t-=1;return o.slice(0,t)}function Y(o){let t=fo(o);po(t),ho(t),go(t),yo(t,o);let s=xo(t,o),{width:i,height:r}=wo(t),e=[];for(let n of t.layers)for(let a of n)a.isVirtual||e.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:e,edges:s,width:i,height:r}}function fo(o){let t=new Map;for(let r of o.nodes)t.set(r,{id:r,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:o.widthCells(r),h:o.heightCells(r),in:[],out:[]});let s=[],i=0;for(let r of o.edges){if(r.from===r.to)continue;let e=t.get(r.from),n=t.get(r.to);if(!e||!n)continue;let a={chainId:i++,chainFrom:r.from,chainTo:r.to,fromId:r.from,toId:r.to,hopIndex:0,chainLen:1};e.out.push(a),n.in.push(a),s.push(a)}return{nodes:t,layers:[],hops:s}}function po(o){let t=new Map;for(let e of o.nodes.values())t.set(e.id,e.in.length);let s=[];for(let e of o.nodes.values())(t.get(e.id)??0)===0&&(e.layer=0,s.push(e));let i=new Set,r=0;for(;r<s.length;){let e=s[r++];if(!i.has(e.id)){i.add(e.id);for(let n of e.out){let a=o.nodes.get(n.toId);a.layer=Math.max(a.layer,e.layer+1);let l=(t.get(a.id)??0)-1;t.set(a.id,l),l<=0&&s.push(a)}}}for(let e of o.nodes.values())e.layer<0&&(e.layer=0)}function ho(o){let t=Math.max(0,...Array.from(o.nodes.values(),e=>e.layer)),s=Array.from({length:t+1},()=>[]);for(let e of o.nodes.values())s[e.layer].push(e);let i=[],r=0;for(let e of o.hops){let n=o.nodes.get(e.fromId),a=o.nodes.get(e.toId),l=a.layer-n.layer;if(l<=0){n.out=n.out.filter(f=>f!==e),a.in=a.in.filter(f=>f!==e);continue}if(l===1){e.hopIndex=0,e.chainLen=1,i.push(e);continue}n.out=n.out.filter(f=>f!==e),a.in=a.in.filter(f=>f!==e);let c=n;for(let f=1;f<l;f+=1){let d=`__virt_${r++}__`,h={id:d,isVirtual:!0,layer:n.layer+f,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};o.nodes.set(d,h),s[h.layer].push(h);let p={chainId:e.chainId,chainFrom:e.chainFrom,chainTo:e.chainTo,fromId:c.id,toId:d,hopIndex:f-1,chainLen:l};c.out.push(p),h.in.push(p),i.push(p),c=h}let u={chainId:e.chainId,chainFrom:e.chainFrom,chainTo:e.chainTo,fromId:c.id,toId:a.id,hopIndex:l-1,chainLen:l};c.out.push(u),a.in.push(u),i.push(u)}for(let e of s)for(let n=0;n<e.length;n+=1)e[n].order=n;o.layers=s,o.hops=i}function go(o){for(let s=0;s<4;s+=1){for(let i=1;i<o.layers.length;i+=1)J(o,o.layers[i],"in"),G(o.layers[i]);for(let i=o.layers.length-2;i>=0;i-=1)J(o,o.layers[i],"out"),G(o.layers[i])}for(let s=0;s<2;s+=1){let i=!1;for(let r=1;r<o.layers.length;r+=1){let e=o.layers[r];for(let n=0;n+1<e.length;n+=1){let a=W(o,e[n],e[n+1],"in");[e[n],e[n+1]]=[e[n+1],e[n]],G(e),W(o,e[n],e[n+1],"in")<a?i=!0:([e[n],e[n+1]]=[e[n+1],e[n]],G(e))}}if(!i)break}}function J(o,t,s){let i=new Map;for(let r of t){let e=s==="in"?r.in:r.out;if(e.length===0){i.set(r.id,r.order);continue}let n=0,a=0;for(let l of e){let c=o.nodes.get(s==="in"?l.fromId:l.toId);c&&(n+=c.order,a+=1)}i.set(r.id,a===0?r.order:n/a)}t.sort((r,e)=>{let n=i.get(r.id),a=i.get(e.id);return n!==a?n-a:r.order-e.order})}function G(o){for(let t=0;t<o.length;t+=1)o[t].order=t}function W(o,t,s,i){let r=i==="in"?t.in:t.out,e=i==="in"?s.in:s.out,n=0;for(let a of r)for(let l of e){let c=o.nodes.get(i==="in"?a.fromId:a.toId)?.order??0,u=o.nodes.get(i==="in"?l.fromId:l.toId)?.order??0;(t.order<s.order&&c>u||t.order>s.order&&c<u)&&(n+=1)}return n}function yo(o,t){t.direction==="LR"?mo(o,t):bo(o,t)}function mo(o,t){let s=[],i=0;for(let r=0;r<o.layers.length;r+=1){s.push(i);let e=0;for(let n of o.layers[r])e=Math.max(e,n.w);i+=e+t.layerGap}for(let r=0;r<o.layers.length;r+=1)for(let e of o.layers[r])e.x=s[r];for(let r of o.layers){let e=0;for(let n of r)n.y=e,e+=n.h+t.nodeGap}X(o,t,"y")}function bo(o,t){let s=[],i=0;for(let r=0;r<o.layers.length;r+=1){s.push(i);let e=0;for(let n of o.layers[r])e=Math.max(e,n.h);i+=e+t.layerGap}for(let r=0;r<o.layers.length;r+=1)for(let e of o.layers[r])e.y=s[r];for(let r of o.layers){let e=0;for(let n of r)n.x=e,e+=n.w+t.nodeGap}X(o,t,"x")}function X(o,t,s){let i=e=>s==="y"?e.h:e.w,r=t.nodeGap;for(let e=0;e<2;e+=1){let n=e===0?o.layers.slice(1):o.layers.slice(0,-1).reverse();for(let a of n){let l=new Map;for(let u of a){let f=e===0?u.in:u.out;if(f.length===0)continue;let d=[];for(let p of f){let y=o.nodes.get(e===0?p.fromId:p.toId);if(!y)continue;let m=s==="y"?y.y:y.x;d.push(m+Math.floor(i(y)/2))}if(d.length===0)continue;d.sort((p,y)=>p-y);let h=d[Math.floor(d.length/2)];l.set(u.id,h-Math.floor(i(u)/2))}let c=0;for(let u of a){let f=l.get(u.id),d=s==="y"?u.y:u.x,p=Math.max(f??d,c);s==="y"?u.y=p:u.x=p,c=p+i(u)+r}}}}function xo(o,t){let s=new Map;for(let c of o.hops){let u=s.get(c.chainId);u?u.push(c):s.set(c.chainId,[c])}for(let c of s.values())c.sort((u,f)=>u.hopIndex-f.hopIndex);let i=t.direction==="LR",r=c=>i?c.x:c.y,e=c=>i?c.w:c.h,n=c=>i?c.y+Math.floor(c.h/2):c.x+Math.floor(c.w/2),a=new Map;for(let c=0;c+1<o.layers.length;c+=1){let u=o.layers[c],f=o.layers[c+1],d=0;for(let g of u)d=Math.max(d,r(g)+e(g));let h=Number.POSITIVE_INFINITY;for(let g of f)h=Math.min(h,r(g));let p=Number.isFinite(h)?h-1:d,y=Math.max(1,p-d+1),m=[];for(let g of u)for(let b of g.out)m.push(b);m.sort((g,b)=>{let x=n(o.nodes.get(g.fromId)),L=n(o.nodes.get(b.fromId));if(x!==L)return x-L;let O=n(o.nodes.get(g.toId)),M=n(o.nodes.get(b.toId));return O-M});let D=[],C=new Map;for(let g of m){let b=n(o.nodes.get(g.fromId)),x=n(o.nodes.get(g.toId)),L=Math.min(b,x),O=Math.max(b,x),M=-1;for(let R=0;R<D.length;R+=1){let j=D[R],N=!0;for(let V of j)if(V.lo<=O&&L<=V.hi){N=!1;break}if(N){j.push({lo:L,hi:O}),M=R;break}}M<0&&(D.push([{lo:L,hi:O}]),M=D.length-1),C.set(g,M)}let I=D.length,T=y>=Math.max(3,I+2),P=T?d+1:d,ro=T?p-1:p,$=Math.max(1,ro-P+1);for(let g of m){let b=C.get(g),x;if(I<=1)x=P+Math.floor($/2);else{let L=($-1)/(I-1);x=P+Math.floor(b*L)}a.set(g,Math.max(d,Math.min(p,x)))}}let l=[];for(let[,c]of s){let u=[];for(let d=0;d<c.length;d+=1){let h=c[d],p=o.nodes.get(h.fromId),y=o.nodes.get(h.toId),m=a.get(h),D=p.isVirtual?r(p):r(p)+e(p),C=y.isVirtual?r(y):r(y)-1,I=n(p),T=n(y);d===0&&v(u,i,D,I),I!==T&&(v(u,i,m,I),v(u,i,m,T)),v(u,i,C,T)}let f=c[0];l.push({from:f.chainFrom,to:f.chainTo,points:Lo(u)})}return l}function v(o,t,s,i){o.push(t?{x:s,y:i}:{x:i,y:s})}function Lo(o){let t=[];for(let s of o){let i=t[t.length-1];(!i||i.x!==s.x||i.y!==s.y)&&t.push(s)}return t}function wo(o){let t=0,s=0;for(let i of o.layers)for(let r of i)t=Math.max(t,r.x+r.w),s=Math.max(s,r.y+r.h);return{width:t,height:s}}var Do=24,Io=4,To=1,Mo=3;function Oo(o,t){let s=Co(t?.direction),i=Math.max(3,t?.maxLabelWidth??Do),r=t?.asciiCharset??"unicode",e=Object.keys(o.nodes).sort(),n=new Set(e),a=o.edges.filter(d=>n.has(d.from)&&n.has(d.to)),l=new Map,c=new Map;for(let d of e){let h=_(d,i);l.set(d,h),c.set(d,S(h)+4)}let u=Y({nodes:e,edges:a,widthCells:d=>c.get(d)??3,heightCells:()=>Mo,layerGap:Io,nodeGap:To,direction:s}),f=F(u,{charset:r,labelOf:d=>l.get(d)??d});return t?.logger?.(f),f}function Co(o){if(o===void 0||o==="LR")return"LR";if(o==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(o)}`)}function E(o){if(o===null||typeof o!="object")return o;if(Array.isArray(o))return o.map(E);let t=o,s=Object.keys(t).sort(),i={};for(let r of s)i[r]=E(t[r]);return i}function q(o){return o.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Q(o){return o.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Z(o){return o==="TD"?"down":o==="BT"?"up":o==="RL"?"left":"right"}function A(o){let t=new Set,s=[];function i(r,e){let n=`${r}\0${e}`;t.has(n)||(t.add(n),s.push([r,e]))}for(let[r,e]of Object.entries(o.nodes)){let n=e.deps;if(n)for(let a of n)i(a,r)}for(let r of o.edges)i(r.from,r.to);return s}function B(o){if(o===void 0)return"LR";if(o==="TD"||o==="LR"||o==="BT"||o==="RL")return o;throw new Error(`invalid diagram direction ${String(o)}; expected one of: TD, LR, BT, RL`)}function oo(o){if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean"||o==null)return String(o);try{return JSON.stringify(o)}catch{return"[unserializable]"}}function Ro(o,t){let s=B(t?.direction),i=Object.keys(o.nodes).sort(),r=new Map;for(let n=0;n<i.length;n+=1)r.set(i[n],`n${n}`);let e=[`direction: ${Z(s)}`];for(let n of i){let a=r.get(n);e.push(`${a}: "${Q(n)}"`)}for(let[n,a]of A(o)){let l=r.get(n),c=r.get(a);!l||!c||e.push(`${l} -> ${c}`)}return e.join(`
3
+ `)}function So(o,t){let s=t?.includeEdges??!0,i=t?.includeSubgraphs??!0,{expand:r,...e}=o,n={...e,edges:s?o.edges:[],subgraphs:i?o.subgraphs:[]},a=JSON.stringify(E(n),null,t?.indent??2);return t?.logger?.(a),a}function H(o,t){let s=B(t?.direction),i=Object.keys(o.nodes).sort(),r=new Map;for(let n=0;n<i.length;n+=1)r.set(i[n],`n${n}`);let e=[`flowchart ${s}`];for(let n of i){let a=r.get(n);e.push(` ${a}["${q(n)}"]`)}for(let[n,a]of A(o)){let l=r.get(n),c=r.get(a);!l||!c||e.push(` ${l} --> ${c}`)}return e.join(`
4
+ `)}function eo(o,t){let s=t?.theme??"default",i=t?.autoSync??!0,e=JSON.stringify({code:o,mermaid:{theme:s},autoSync:i}),n=new TextEncoder().encode(e),a="";for(let c=0;c<n.length;c++)a+=String.fromCharCode(n[c]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function Go(o,t){let s=H(o,t);return eo(s,t)}function vo(o,t){let s=t?.includeEdges??!0,i=t?.includeSubgraphs??!0,r=[];r.push(`Graph ${o.name}`),r.push("Nodes:");for(let n of Object.keys(o.nodes).sort()){let a=o.nodes[n];r.push(`- ${n} (${a.type}/${a.status}): ${oo(a.value)}`)}if(s){r.push("Edges:");for(let n of o.edges)r.push(`- ${n.from} -> ${n.to}`)}if(i){r.push("Subgraphs:");for(let n of o.subgraphs)r.push(`- ${n}`)}let e=r.join(`
5
+ `);return t?.logger?.(e),e}export{Oo as a,Ro as b,So as c,H as d,eo as e,Go as f,vo as g};
@@ -1 +1 @@
1
- import{a as w,b as U,c as K}from"./chunk-DQJLC6YY.js";import{A as b,B as F,C as H,D as G,E as h,F as k,G as B,H as Y,I as v,J as P,K as W,i as q,j as z,k as g,m as S,n as C,o as I,p as M,q as _,r as u,s as J,t as Q,u as X,v as Z,w as L,x as m,y as x,z as V}from"./chunk-LYCLF26R.js";import{a as e,b as t,c as o,d as p,e as r,f as n,g as s,h as i,i as y,j as a,k as d,l as c,m as N,n as T,o as E,p as O,q as l,r as A,s as D,t as f,u as R}from"./chunk-CK2E7BTU.js";import{b as j}from"./chunk-QYADASLV.js";var $={};j($,{COMPLETE:()=>y,COMPLETE_MSG:()=>E,COMPLETE_ONLY_BATCH:()=>f,DATA:()=>t,DEFAULT_ACTOR:()=>q,DIRTY:()=>o,DIRTY_MSG:()=>d,DIRTY_ONLY_BATCH:()=>l,ERROR:()=>a,GraphReFlyConfig:()=>_,GuardDenied:()=>J,INVALIDATE:()=>r,INVALIDATE_MSG:()=>N,INVALIDATE_ONLY_BATCH:()=>D,NodeImpl:()=>H,PAUSE:()=>n,RESOLVED:()=>p,RESOLVED_MSG:()=>c,RESOLVED_ONLY_BATCH:()=>A,RESUME:()=>s,START:()=>e,START_MSG:()=>T,TEARDOWN:()=>i,TEARDOWN_MSG:()=>O,TEARDOWN_ONLY_BATCH:()=>R,accessHintForGuard:()=>Z,advanceVersion:()=>x,autoTrackNode:()=>P,batch:()=>S,configure:()=>F,createVersioning:()=>m,defaultConfig:()=>b,defaultHash:()=>L,derived:()=>B,downWithBatch:()=>C,dynamicNode:()=>v,effect:()=>Y,factoryTag:()=>K,isBatching:()=>g,isV1:()=>V,monotonicNs:()=>I,node:()=>G,normalizeActor:()=>z,pipe:()=>W,placeholderArgs:()=>U,policy:()=>Q,policyFromRules:()=>X,producer:()=>k,registerBuiltins:()=>u,resolveDescribeFields:()=>w,state:()=>h,wallClockNs:()=>M});export{$ as a};
1
+ import{a as w,b as U,c as K}from"./chunk-35JTVPOX.js";import{A as b,B as F,C as H,D as G,E as h,F as k,G as B,H as Y,I as v,J as P,K as W,i as q,j as z,k as g,m as S,n as C,o as I,p as M,q as _,r as u,s as J,t as Q,u as X,v as Z,w as L,x as m,y as x,z as V}from"./chunk-LYCLF26R.js";import{a as e,b as t,c as o,d as p,e as r,f as n,g as s,h as i,i as y,j as a,k as d,l as c,m as N,n as T,o as E,p as O,q as l,r as A,s as D,t as f,u as R}from"./chunk-CK2E7BTU.js";import{b as j}from"./chunk-QYADASLV.js";var $={};j($,{COMPLETE:()=>y,COMPLETE_MSG:()=>E,COMPLETE_ONLY_BATCH:()=>f,DATA:()=>t,DEFAULT_ACTOR:()=>q,DIRTY:()=>o,DIRTY_MSG:()=>d,DIRTY_ONLY_BATCH:()=>l,ERROR:()=>a,GraphReFlyConfig:()=>_,GuardDenied:()=>J,INVALIDATE:()=>r,INVALIDATE_MSG:()=>N,INVALIDATE_ONLY_BATCH:()=>D,NodeImpl:()=>H,PAUSE:()=>n,RESOLVED:()=>p,RESOLVED_MSG:()=>c,RESOLVED_ONLY_BATCH:()=>A,RESUME:()=>s,START:()=>e,START_MSG:()=>T,TEARDOWN:()=>i,TEARDOWN_MSG:()=>O,TEARDOWN_ONLY_BATCH:()=>R,accessHintForGuard:()=>Z,advanceVersion:()=>x,autoTrackNode:()=>P,batch:()=>S,configure:()=>F,createVersioning:()=>m,defaultConfig:()=>b,defaultHash:()=>L,derived:()=>B,downWithBatch:()=>C,dynamicNode:()=>v,effect:()=>Y,factoryTag:()=>K,isBatching:()=>g,isV1:()=>V,monotonicNs:()=>I,node:()=>G,normalizeActor:()=>z,pipe:()=>W,placeholderArgs:()=>U,policy:()=>Q,policyFromRules:()=>X,producer:()=>k,registerBuiltins:()=>u,resolveDescribeFields:()=>w,state:()=>h,wallClockNs:()=>M});export{$ as a};
@@ -1 +1 @@
1
- import{m as x,x as w}from"./chunk-RZ5HKPGI.js";import{i as g,j as p}from"./chunk-CK2E7BTU.js";async function k(o){let i=typeof o=="string"?new TextEncoder().encode(o):o,c=await globalThis.crypto.subtle.digest("SHA-256",i),t=new Uint8Array(c),n="";for(let r=0;r<t.length;r++)n+=b[t[r]];return n}var b=new Array(256);for(let o=0;o<256;o++)b[o]=o.toString(16).padStart(2,"0");var m=class extends Error{constructor(c,t){super(`content-addressed lookup miss in read-strict mode: ${c}`);this.key=c;this.context=t;this.name="ContentAddressedMissError"}};function T(o){let i=new Set,c=t=>{if(t===null||typeof t!="object")return t;let n=t;if(i.has(n))return{__cycle:!0};i.add(n);try{if(Array.isArray(t))return t.map(c);let r={};for(let d of Object.keys(t).sort())r[d]=c(t[d]);return r}finally{i.delete(n)}};return JSON.stringify(c(o))}function P(o){let{storage:i,keyContext:c,keyPrefix:t,mode:n="read-write"}=o,r=c??(e=>e);async function d(e){let s=T(r(e)),a=await k(s);return t?`${t}:${a}`:a}return{keyFor:d,async lookup(e){if(n==="write")return;let s=await d(e),a=await i.load(s);if(a===void 0){if(n==="read-strict")throw new m(s,e);return}return a},async store(e,s){if(n==="read")return;let a=await d(e);await i.save(a,s)},async forget(e){if(n==="read"||n==="write"||!i.delete)return;let s=await d(e);await i.delete(s)}}}function K(o,i={}){let c=i.keyFn??(n=>String(n)),t=new Map;return n=>{let r=c(n),d=t.get(r);if(d)return d;let e=o(n),s;e!=null&&typeof e.then=="function"?s=Promise.resolve(e):e!=null&&typeof e=="object"&&"subscribe"in e&&"cache"in e?s=w(e):e!=null&&typeof e=="object"&&Symbol.asyncIterator in e?s=(async()=>{let u=e[Symbol.asyncIterator]();try{let{value:l,done:f}=await u.next();if(f)throw new Error("singleFromAny: factory returned empty async iterable");return l}finally{await u.return?.()}})():e!=null&&typeof e=="object"&&Symbol.iterator in e?s=(async()=>{let u=e[Symbol.iterator]();try{let{value:l,done:f}=u.next();if(f)throw new Error("singleFromAny: factory returned empty iterable");return l}finally{u.return?.()}})():s=Promise.resolve(e);let a,y=()=>{t.get(r)===a&&t.delete(r)};return a=s.then(u=>(y(),u),u=>{throw y(),u}),t.set(r,a),a}}function j(o,i={}){let c=i.keyFn??(n=>String(n)),t=new Map;return n=>{let r=c(n),d=t.get(r);if(d)return d;let e=x(o(n));t.set(r,e);let s=e.subscribe(a=>{for(let y of a)if(y[0]===p||y[0]===g){t.get(r)===e&&t.delete(r),s();return}});return e}}export{k as a,m as b,T as c,P as d,K as e,j as f};
1
+ import{m as x,x as w}from"./chunk-CKFQS2CJ.js";import{i as g,j as p}from"./chunk-CK2E7BTU.js";async function k(o){let i=typeof o=="string"?new TextEncoder().encode(o):o,c=await globalThis.crypto.subtle.digest("SHA-256",i),t=new Uint8Array(c),n="";for(let r=0;r<t.length;r++)n+=b[t[r]];return n}var b=new Array(256);for(let o=0;o<256;o++)b[o]=o.toString(16).padStart(2,"0");var m=class extends Error{constructor(c,t){super(`content-addressed lookup miss in read-strict mode: ${c}`);this.key=c;this.context=t;this.name="ContentAddressedMissError"}};function T(o){let i=new Set,c=t=>{if(t===null||typeof t!="object")return t;let n=t;if(i.has(n))return{__cycle:!0};i.add(n);try{if(Array.isArray(t))return t.map(c);let r={};for(let d of Object.keys(t).sort())r[d]=c(t[d]);return r}finally{i.delete(n)}};return JSON.stringify(c(o))}function P(o){let{storage:i,keyContext:c,keyPrefix:t,mode:n="read-write"}=o,r=c??(e=>e);async function d(e){let s=T(r(e)),a=await k(s);return t?`${t}:${a}`:a}return{keyFor:d,async lookup(e){if(n==="write")return;let s=await d(e),a=await i.load(s);if(a===void 0){if(n==="read-strict")throw new m(s,e);return}return a},async store(e,s){if(n==="read")return;let a=await d(e);await i.save(a,s)},async forget(e){if(n==="read"||n==="write"||!i.delete)return;let s=await d(e);await i.delete(s)}}}function K(o,i={}){let c=i.keyFn??(n=>String(n)),t=new Map;return n=>{let r=c(n),d=t.get(r);if(d)return d;let e=o(n),s;e!=null&&typeof e.then=="function"?s=Promise.resolve(e):e!=null&&typeof e=="object"&&"subscribe"in e&&"cache"in e?s=w(e):e!=null&&typeof e=="object"&&Symbol.asyncIterator in e?s=(async()=>{let u=e[Symbol.asyncIterator]();try{let{value:l,done:f}=await u.next();if(f)throw new Error("singleFromAny: factory returned empty async iterable");return l}finally{await u.return?.()}})():e!=null&&typeof e=="object"&&Symbol.iterator in e?s=(async()=>{let u=e[Symbol.iterator]();try{let{value:l,done:f}=u.next();if(f)throw new Error("singleFromAny: factory returned empty iterable");return l}finally{u.return?.()}})():s=Promise.resolve(e);let a,y=()=>{t.get(r)===a&&t.delete(r)};return a=s.then(u=>(y(),u),u=>{throw y(),u}),t.set(r,a),a}}function j(o,i={}){let c=i.keyFn??(n=>String(n)),t=new Map;return n=>{let r=c(n),d=t.get(r);if(d)return d;let e=x(o(n));t.set(r,e);let s=e.subscribe(a=>{for(let y of a)if(y[0]===p||y[0]===g){t.get(r)===e&&t.delete(r),s();return}});return e}}export{k as a,m as b,T as c,P as d,K as e,j as f};
@@ -1,4 +1,4 @@
1
- import{e as ce}from"./chunk-DSOVKKTI.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{k as L}from"./chunk-QMC2PLNM.js";import{f as ae,h as ie}from"./chunk-RZ5HKPGI.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
1
+ import{e as ce}from"./chunk-7Q4ZD3YW.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{i as L}from"./chunk-2BX4NB34.js";import{f as ae,h as ie}from"./chunk-CKFQS2CJ.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
 
@@ -0,0 +1 @@
1
+ import{d as g}from"./chunk-VMF23LGB.js";import{a as v}from"./chunk-J63M5U46.js";import{a as N}from"./chunk-L6NSJVJZ.js";import{i as _}from"./chunk-2BX4NB34.js";import{C as D}from"./chunk-CKFQS2CJ.js";import{E as c,G as p,o as G}from"./chunk-LYCLF26R.js";import{b}from"./chunk-CK2E7BTU.js";import{b as L}from"./chunk-QYADASLV.js";var P={};L(P,{GuardedExecutionGraph:()=>d,guardedExecution:()=>x});function u(o){return typeof o=="object"&&o!==null&&"subscribe"in o&&"down"in o}function w(o){return N("guarded",o)}var d=class extends _{enforcer;violations;lints;scope;scopedDescribe;_target;_actorNode;_mode;_firedLintKinds=new Set;constructor(e,i){super(i.name??`${e.name}_guarded`,i.graph),this._target=e,this._mode=i.mode??"enforce";let n=i.policies,r=u(n);if(!r&&this._mode==="enforce"&&n.length===0)throw new RangeError('guardedExecution: empty `policies` in `mode: "enforce"` denies every action. Pass at least `{ effect: "allow", action: "*" }` and layer deny rules on top.');this.lints=new v("lints",{retainedLimit:i.lintsLimit??64}),this.mount("lints",this.lints);let a=i.actor;a==null?this._actorNode=c(null,{name:"actor"}):u(a)?this._actorNode=p([a],([t])=>t??null,{name:"actor",initial:null}):this._actorNode=c(a,{name:"actor"});let m={mode:this._mode,name:"enforcer"};if(i.violationsLimit!=null&&(m.violationsLimit=i.violationsLimit),this.enforcer=g(e,i.policies,m),this.violations=this.enforcer.violations,this.mount("enforcer",this.enforcer),r&&this._mode==="enforce"){let t=n,s=t.cache;s!=null&&s.length===0&&this._fireLint("empty-policies",'`policies` Node cached an empty array in `mode: "enforce"` \u2014 every action will be denied. Add at least one allow rule.');let l=t.subscribe(A=>{for(let h of A){if(h[0]!==b)continue;let y=h[1];(y==null||y.length===0)&&this._fireLint("empty-policies",'`policies` Node emitted an empty array in `mode: "enforce"` \u2014 every action will be denied. Add at least one allow rule.')}});this.addDisposer(l)}if(this._mode==="audit"){let t=e.describe({detail:"full"});Object.values(t.nodes).some(l=>l.guard!=null)||this._fireLint("audit-no-effect",'`mode: "audit"` + target has no per-node guards \u2014 `scopedDescribeNode` filters by per-node guards only, so policy rules will not affect describe() visibility. Policies still populate the `violations` topic on writes.')}a==null&&this._fireLint("no-actor","no actor configured \u2014 `wrapper.scopedDescribe` and `scopedDescribeNode()` will return an unscoped describe (full visibility) unless a per-call actor is supplied."),this.scope=p([this._actorNode,this.enforcer.policies],([t,s])=>({actor:t??null,mode:this._mode,policiesCount:s.length}),{name:"scope",describeKind:"derived",meta:w("scope")}),this.add(this.scope,{name:"scope"}),this.addDisposer(D(this.scope));let f=e.describe({reactive:!0,actor:this._actorNode,reactiveName:"scopedDescribe"});this.scopedDescribe=f.node,this.add(this.scopedDescribe,{name:"scopedDescribe"}),this.addDisposer(f.dispose)}_fireLint(e,i){this._firedLintKinds.has(e)||(this._firedLintKinds.add(e),this.lints.publish({kind:e,message:i,timestamp_ns:G()}))}scopedDescribeNode(e,i){let n=e==null?this._actorNode:u(e)?e:c(e,{name:"actor_override"}),r=this._target.describe({reactive:!0,actor:n,...i??{}});return this.addDisposer(r.dispose),{node:r.node,dispose:r.dispose}}get target(){return this._target}};function x(o,e){return new d(o,e)}export{d as a,x as b,P as c};
@@ -0,0 +1 @@
1
+ import{i as x}from"./chunk-2BX4NB34.js";import{b as y}from"./chunk-YXDRGKXP.js";import{E as T,m as A,p as f,t as b}from"./chunk-LYCLF26R.js";import{b as m,c as R}from"./chunk-CK2E7BTU.js";function N(r,e){let t=r.cache??0;return t>=e?!1:(r.down([[R],[m,t+1]]),!0)}var M=b((r,e)=>{r("observe"),r("signal"),e("write")});function q(r){let e=y([],{name:r.name,maxSize:r.retainedLimit??1024,guard:r.guard??M,...r.versioning!=null?{versioning:r.versioning}:{}});return e.withLatest(),r.graph&&r.graph.add(e.entries,{name:r.name}),e}function p(r){if(r===null||typeof r!="object"||Object.isFrozen(r))return r;for(let e of Object.keys(r))p(r[e]);return Object.freeze(r)}function w(r){let e=r.cache,u=(typeof e=="number"&&Number.isFinite(e)?e:0)+1;return r.down([[R],[m,u]]),u}function g(r,e,t,u,i,s){let o=e(t,u,i);if(o===void 0)return;let a=s!=null?{...o,handlerVersion:s}:o;r.append(a)}function z(r,e){let t=e.freeze??!0;return function(...i){let s=t?i.map(p):i,o=f(),a=e.seq?w(e.seq):void 0;try{let n=r(...s);return e.onSuccess&&g(e.audit,e.onSuccess,s,n,{t_ns:o,seq:a},e.handlerVersion),n}catch(n){if(e.onFailure){let d=n instanceof Error?n.name:typeof n;g(e.audit,e.onFailure,s,n,{t_ns:o,seq:a,errorType:d},e.handlerVersion)}throw n}}}function G(r,e){let t=e.freeze??!0;return function(...i){let s=t?i.map(p):i,o=f(),a,n,d=!1,l;try{A(()=>{e.seq&&(l=w(e.seq));try{a=r(...s),e.onSuccess&&g(e.audit,e.onSuccess,s,a,{t_ns:o,seq:l},e.handlerVersion)}catch(c){throw n=c,d=!0,c}})}catch(c){if(d&&e.onFailure){let h=n instanceof Error?n.name:typeof n;g(e.audit,e.onFailure,s,n,{t_ns:o,seq:l,errorType:h},e.handlerVersion)}throw d?n:c}return a}}function V(r,e,t=0){let u=T(t,{name:e,describeKind:"state"});return r.add(u,{name:e}),u}function _(r,e,t,u=0){let i={},s=new x(e);for(let o of t){let a=T(u,{name:o,describeKind:"state"});s.add(a,{name:o}),i[o]=a}return r.mount(e,s),i}export{N as a,M as b,q as c,w as d,g as e,z as f,G as g,V as h,_ as i};