@graphrefly/graphrefly 0.34.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/dist/{cascading-DKIb6Pk8.d.cts → cascading-B25wxpRa.d.cts} +3 -3
  2. package/dist/{cascading-Bg0a4VSf.d.ts → cascading-BsJ4GbnS.d.ts} +3 -3
  3. package/dist/{chunk-TZLEMGAK.js → chunk-2Y3DKIZL.js} +2 -2
  4. package/dist/chunk-3OT7K33Q.js +1 -0
  5. package/dist/chunk-53XJ2S6D.js +1 -0
  6. package/dist/chunk-5CPPC75H.js +1 -0
  7. package/dist/chunk-5KPIYVCC.js +7 -0
  8. package/dist/{chunk-GAOX6OPT.js → chunk-5XZRCS2M.js} +1 -1
  9. package/dist/{chunk-C5DINHNP.js → chunk-6G5YD37E.js} +1 -1
  10. package/dist/{chunk-WBWBY6LI.js → chunk-6SVKZ7VI.js} +1 -1
  11. package/dist/chunk-A5HZZYRK.js +1 -0
  12. package/dist/chunk-BGEY3PXH.js +1 -0
  13. package/dist/chunk-CD4CB6S7.js +1 -0
  14. package/dist/chunk-CE72X3WO.js +1 -0
  15. package/dist/chunk-CUQFO6MT.js +1 -0
  16. package/dist/chunk-D5RFJOZ2.js +1 -0
  17. package/dist/{chunk-A3GDELMY.js → chunk-E5YSBQSF.js} +7 -7
  18. package/dist/{chunk-SFIM774L.js → chunk-EUE7ELFQ.js} +1 -1
  19. package/dist/chunk-F3IGTWCQ.js +1 -0
  20. package/dist/chunk-F672GV32.js +1 -0
  21. package/dist/{chunk-GCUYSIM4.js → chunk-GWOKTENT.js} +1 -1
  22. package/dist/{chunk-4NYSEUKV.js → chunk-J6TGRQUP.js} +1 -1
  23. package/dist/{chunk-4F564IPP.js → chunk-JJTF75VS.js} +1 -1
  24. package/dist/{chunk-BY4WKPKM.js → chunk-JUJEPZOI.js} +1 -1
  25. package/dist/{chunk-65WWQ5CB.js → chunk-M5UC63ZI.js} +5 -5
  26. package/dist/chunk-MQZWA3DF.js +1 -0
  27. package/dist/chunk-MYFR67PY.js +18 -0
  28. package/dist/{chunk-KN2UMFT6.js → chunk-PCD2MU7X.js} +1 -1
  29. package/dist/{chunk-YDWTVO4E.js → chunk-PIIUJIF7.js} +1 -1
  30. package/dist/chunk-PVUTRA5K.js +5 -0
  31. package/dist/chunk-Q7EUZ6NN.js +1 -0
  32. package/dist/chunk-RLMYS3XZ.js +1 -0
  33. package/dist/chunk-RRFOCAH6.js +1 -0
  34. package/dist/{chunk-Q46YJCQH.js → chunk-T6RPUERH.js} +1 -1
  35. package/dist/{chunk-IPNJDNE7.js → chunk-T7GWBGOO.js} +1 -1
  36. package/dist/{chunk-U2T2XWDA.js → chunk-U347KVM4.js} +1 -1
  37. package/dist/chunk-UAMWD4GG.js +1 -0
  38. package/dist/chunk-VN6RDSK2.js +1 -0
  39. package/dist/{chunk-CJMFZXIZ.js → chunk-W2ZU226Q.js} +1 -1
  40. package/dist/{chunk-UF746BQ4.js → chunk-XINLP35X.js} +1 -1
  41. package/dist/{chunk-TONEKQM3.js → chunk-XMDNNSMK.js} +1 -1
  42. package/dist/{chunk-INXDSJRC.js → chunk-YOUAVGHJ.js} +1 -1
  43. package/dist/chunk-YV2A2VWG.js +1 -0
  44. package/dist/{chunk-PBN426RU.js → chunk-ZGVA2SR5.js} +1 -1
  45. package/dist/compat/index.cjs +10 -10
  46. package/dist/compat/index.d.cts +17 -14
  47. package/dist/compat/index.d.ts +17 -14
  48. package/dist/compat/index.js +1 -1
  49. package/dist/compat/jotai/index.d.cts +2 -2
  50. package/dist/compat/jotai/index.d.ts +2 -2
  51. package/dist/compat/nanostores/index.d.cts +2 -2
  52. package/dist/compat/nanostores/index.d.ts +2 -2
  53. package/dist/compat/nestjs/index.cjs +12 -12
  54. package/dist/compat/nestjs/index.d.cts +9 -6
  55. package/dist/compat/nestjs/index.d.ts +9 -6
  56. package/dist/compat/nestjs/index.js +1 -1
  57. package/dist/compat/react/index.d.cts +2 -2
  58. package/dist/compat/react/index.d.ts +2 -2
  59. package/dist/compat/solid/index.d.cts +2 -2
  60. package/dist/compat/solid/index.d.ts +2 -2
  61. package/dist/compat/svelte/index.d.cts +2 -2
  62. package/dist/compat/svelte/index.d.ts +2 -2
  63. package/dist/compat/vue/index.d.cts +2 -2
  64. package/dist/compat/vue/index.d.ts +2 -2
  65. package/dist/compat/zustand/index.cjs +7 -7
  66. package/dist/compat/zustand/index.d.cts +5 -4
  67. package/dist/compat/zustand/index.d.ts +5 -4
  68. package/dist/compat/zustand/index.js +1 -1
  69. package/dist/{composite-BPDU_XV1.d.ts → composite-CT_mApQD.d.ts} +2 -2
  70. package/dist/{composite-CmvdhTJe.d.cts → composite-_XckYx2e.d.cts} +2 -2
  71. package/dist/{content-addressed-storage-DqIWCmZG.d.cts → content-addressed-storage-4-ST1tYk.d.cts} +5 -5
  72. package/dist/{content-addressed-storage-BUiREIuj.d.ts → content-addressed-storage-DuYMjV7o.d.ts} +5 -5
  73. package/dist/core/index.d.cts +4 -4
  74. package/dist/core/index.d.ts +4 -4
  75. package/dist/extra/browser.cjs +1 -1
  76. package/dist/extra/browser.d.cts +4 -3
  77. package/dist/extra/browser.d.ts +4 -3
  78. package/dist/extra/browser.js +1 -1
  79. package/dist/extra/index.cjs +19 -19
  80. package/dist/extra/index.d.cts +13 -12
  81. package/dist/extra/index.d.ts +13 -12
  82. package/dist/extra/index.js +1 -1
  83. package/dist/extra/node.cjs +2 -3
  84. package/dist/extra/node.d.cts +3 -3
  85. package/dist/extra/node.d.ts +3 -3
  86. package/dist/extra/node.js +2 -2
  87. package/dist/extra/operators.cjs +1 -1
  88. package/dist/extra/operators.d.cts +1 -1
  89. package/dist/extra/operators.d.ts +1 -1
  90. package/dist/extra/operators.js +1 -1
  91. package/dist/extra/reactive.cjs +1 -1
  92. package/dist/extra/reactive.d.cts +4 -3
  93. package/dist/extra/reactive.d.ts +4 -3
  94. package/dist/extra/reactive.js +1 -1
  95. package/dist/extra/sources.cjs +1 -1
  96. package/dist/extra/sources.d.cts +57 -2
  97. package/dist/extra/sources.d.ts +57 -2
  98. package/dist/extra/sources.js +1 -1
  99. package/dist/extra/storage-browser.cjs +1 -1
  100. package/dist/extra/storage-browser.d.cts +8 -42
  101. package/dist/extra/storage-browser.d.ts +8 -42
  102. package/dist/extra/storage-browser.js +1 -1
  103. package/dist/extra/storage-core.cjs +1 -1
  104. package/dist/extra/storage-core.d.cts +13 -83
  105. package/dist/extra/storage-core.d.ts +13 -83
  106. package/dist/extra/storage-core.js +1 -1
  107. package/dist/extra/storage-node.cjs +1 -2
  108. package/dist/extra/storage-node.d.cts +1 -59
  109. package/dist/extra/storage-node.d.ts +1 -59
  110. package/dist/extra/storage-node.js +0 -1
  111. package/dist/extra/storage-tiers-browser.cjs +1 -0
  112. package/dist/extra/storage-tiers-browser.d.cts +49 -0
  113. package/dist/extra/storage-tiers-browser.d.ts +49 -0
  114. package/dist/extra/storage-tiers-browser.js +1 -0
  115. package/dist/extra/storage-tiers-node.cjs +1 -0
  116. package/dist/extra/storage-tiers-node.d.cts +86 -0
  117. package/dist/extra/storage-tiers-node.d.ts +86 -0
  118. package/dist/extra/storage-tiers-node.js +1 -0
  119. package/dist/extra/storage-tiers.cjs +1 -0
  120. package/dist/extra/storage-tiers.d.cts +284 -0
  121. package/dist/extra/storage-tiers.d.ts +284 -0
  122. package/dist/extra/storage-tiers.js +1 -0
  123. package/dist/{fallback-mYSd8vQo.d.ts → fallback-DuEXfA4F.d.ts} +14 -14
  124. package/dist/{fallback-9YznPvPP.d.cts → fallback-axI2cXwt.d.cts} +14 -14
  125. package/dist/graph/index.cjs +3 -3
  126. package/dist/graph/index.d.cts +6 -5
  127. package/dist/graph/index.d.ts +6 -5
  128. package/dist/graph/index.js +1 -1
  129. package/dist/{graph-BROUZPG9.d.ts → graph-Cv-8x0ZI.d.ts} +28 -16
  130. package/dist/{graph-DaoydJ_u.d.cts → graph-kTltt95s.d.cts} +28 -16
  131. package/dist/imperative-audit-ahAE65a9.d.cts +28 -0
  132. package/dist/imperative-audit-ahAE65a9.d.ts +28 -0
  133. package/dist/{index-CI5fULSz.d.ts → index-8OxXae3g.d.ts} +1 -1
  134. package/dist/{index-CQ1gt4rn.d.cts → index-9xhIaM-w.d.cts} +1 -1
  135. package/dist/{index-DhWrMTI6.d.cts → index-B3D_z0Z6.d.cts} +1 -1
  136. package/dist/{index-Ccv_61jG.d.cts → index-B3Dfl5sS.d.cts} +110 -27
  137. package/dist/{index-Dia4yc2y.d.ts → index-B4s70vYf.d.ts} +4 -4
  138. package/dist/{index-Db21wuaD.d.ts → index-B5UR87KG.d.ts} +3 -3
  139. package/dist/{index-DuvQAU02.d.ts → index-BBdwz2BW.d.ts} +2 -2
  140. package/dist/{index-B5eS17Bz.d.ts → index-BEvsFlfH.d.ts} +47 -32
  141. package/dist/{index-BUtCR0k6.d.ts → index-BF-ssbJB.d.ts} +7 -7
  142. package/dist/{index-ClKm7CFB.d.cts → index-BFuVcqL8.d.cts} +1 -1
  143. package/dist/{index-BkfL5MXh.d.cts → index-BWH17rK_.d.cts} +3 -3
  144. package/dist/{index-CD7qmvSf.d.ts → index-BZ1V5GzX.d.ts} +3 -3
  145. package/dist/{index-BDEhWLF4.d.cts → index-BhkPzu-Z.d.cts} +4 -4
  146. package/dist/{index-CNxdDb2e.d.ts → index-Bilohojo.d.ts} +3 -3
  147. package/dist/{index-zA1uVtk0.d.ts → index-BiomL7AW.d.ts} +1 -1
  148. package/dist/{index-BWiX5foT.d.ts → index-BjWZARLy.d.ts} +1 -1
  149. package/dist/{index-IxinNgAH.d.cts → index-BkbawFkI.d.cts} +16 -15
  150. package/dist/{index-RJX4snyi.d.cts → index-BlRVj-7Q.d.cts} +21 -21
  151. package/dist/index-BpFwRAf9.d.cts +26 -0
  152. package/dist/{index-Ds3Rz9m9.d.cts → index-BsZlbHM5.d.cts} +3 -3
  153. package/dist/{index-BFHpNSsV.d.ts → index-BtY2QVDf.d.cts} +8 -7
  154. package/dist/{index-BsxqmV6u.d.ts → index-BuMzxRO2.d.ts} +2 -2
  155. package/dist/{index-C5uMGVJw.d.ts → index-BwYGLgmI.d.ts} +4 -4
  156. package/dist/{index-3L3RC3VJ.d.ts → index-C40wA8zt.d.ts} +7 -7
  157. package/dist/{index-Bi4ZP6Hc.d.ts → index-C9xF16gc.d.ts} +110 -27
  158. package/dist/index-CAIhFfws.d.ts +171 -0
  159. package/dist/{index-BRisOxlx.d.ts → index-CDvC1m5p.d.ts} +1 -1
  160. package/dist/index-CGKs5ixV.d.cts +287 -0
  161. package/dist/{index-ygRFoyrN.d.ts → index-CI_yjtua.d.ts} +2 -2
  162. package/dist/{index-DxEcY7Om.d.ts → index-CIcu6fIR.d.ts} +1 -1
  163. package/dist/{index-CQtnGFrZ.d.cts → index-CfOSES72.d.cts} +7 -7
  164. package/dist/{index-Bd2AjMQY.d.ts → index-Cot94_82.d.ts} +21 -21
  165. package/dist/{index-B1hFhK1K.d.cts → index-CpZKtdMw.d.cts} +1 -1
  166. package/dist/{index-BO6t0HjV.d.cts → index-CqSJ25A9.d.cts} +1 -1
  167. package/dist/{index-Jgl7ev9I.d.cts → index-CzC0G0C3.d.cts} +9 -9
  168. package/dist/{index-p0bkNfby.d.cts → index-D6JRP-1_.d.cts} +3 -3
  169. package/dist/{index-D23g00HE.d.cts → index-D7r_vd0b.d.cts} +4 -4
  170. package/dist/{index-Cp91Sxbo.d.cts → index-D8IyqHvT.d.cts} +3 -3
  171. package/dist/{index-iKsmdnq6.d.cts → index-D9qoEOj_.d.cts} +2 -2
  172. package/dist/index-DBmBtqAN.d.ts +461 -0
  173. package/dist/{index-nP13Qe6T.d.ts → index-DFe2Pk2u.d.ts} +1 -1
  174. package/dist/{index-Cn3taOmp.d.cts → index-DKp1CIbG.d.cts} +2 -2
  175. package/dist/{index-CoR-tOZA.d.cts → index-DSD6xnbT.d.ts} +8 -7
  176. package/dist/{index-DheNs40A.d.ts → index-DXSLMoma.d.ts} +2 -2
  177. package/dist/{index-ZIQaKIdY.d.cts → index-DXZsXxtU.d.cts} +47 -32
  178. package/dist/{index-BVTjuKeP.d.cts → index-D_QQ_dTD.d.cts} +1 -1
  179. package/dist/{index-ChZvMC4M.d.cts → index-DeyzuqAi.d.cts} +7 -7
  180. package/dist/{index-Chi9IiHJ.d.ts → index-DlccEIi3.d.ts} +3 -3
  181. package/dist/{index-DR3XqZlV.d.cts → index-DmtWMP0X.d.cts} +1 -1
  182. package/dist/{index-CbCNoogR.d.ts → index-Dp69u0ym.d.ts} +16 -15
  183. package/dist/{index-b4a6Sg0R.d.ts → index-DwNNufVa.d.ts} +4 -4
  184. package/dist/{index-D80nGRb9.d.ts → index-DzYTXMBz.d.ts} +3 -3
  185. package/dist/index-DzgS5uYi.d.ts +26 -0
  186. package/dist/{index-B-KCkW4M.d.cts → index-GaW6Welt.d.cts} +4 -4
  187. package/dist/{index-DupIl9wI.d.ts → index-JYtN9uqM.d.ts} +1 -1
  188. package/dist/{index-Ced0dphF.d.ts → index-KNAMYngu.d.ts} +9 -9
  189. package/dist/{index-BpjQanLs.d.cts → index-PluovH45.d.cts} +2 -2
  190. package/dist/index-Qq-G9B6g.d.cts +171 -0
  191. package/dist/{index-yJY9thRY.d.cts → index-XxSeddWP.d.cts} +2 -2
  192. package/dist/{index-C8_bnDBZ.d.cts → index-ZhKyR8co.d.cts} +3 -3
  193. package/dist/index-hXKhbfh-.d.ts +287 -0
  194. package/dist/index-zK_mN1D-.d.cts +461 -0
  195. package/dist/index.cjs +59 -59
  196. package/dist/index.d.cts +53 -49
  197. package/dist/index.d.ts +53 -49
  198. package/dist/index.js +1 -1
  199. package/dist/{meta-BdjSt8ky.d.cts → meta-BGO6C7K9.d.cts} +1 -1
  200. package/dist/{meta-CtDjj7cU.d.ts → meta-CC6EPdpK.d.ts} +1 -1
  201. package/dist/{node-8qx0kgYt.d.cts → node-fSc-hCv8.d.cts} +1 -1
  202. package/dist/{node-8qx0kgYt.d.ts → node-fSc-hCv8.d.ts} +1 -1
  203. package/dist/{observable-B6Ba-TTI.d.cts → observable-Cqty11jG.d.cts} +1 -1
  204. package/dist/{observable-DOniYM2B.d.ts → observable-EAV_rNfM.d.ts} +1 -1
  205. package/dist/patterns/ai/browser.cjs +5 -5
  206. package/dist/patterns/ai/browser.d.cts +4 -4
  207. package/dist/patterns/ai/browser.d.ts +4 -4
  208. package/dist/patterns/ai/browser.js +1 -1
  209. package/dist/patterns/ai/index.cjs +19 -19
  210. package/dist/patterns/ai/index.d.cts +19 -17
  211. package/dist/patterns/ai/index.d.ts +19 -17
  212. package/dist/patterns/ai/index.js +1 -1
  213. package/dist/patterns/ai/node.cjs +1 -2
  214. package/dist/patterns/ai/node.d.cts +9 -9
  215. package/dist/patterns/ai/node.d.ts +9 -9
  216. package/dist/patterns/ai/node.js +1 -1
  217. package/dist/patterns/audit/index.cjs +6 -6
  218. package/dist/patterns/audit/index.d.cts +7 -5
  219. package/dist/patterns/audit/index.d.ts +7 -5
  220. package/dist/patterns/audit/index.js +1 -1
  221. package/dist/patterns/cqrs/index.cjs +7 -7
  222. package/dist/patterns/cqrs/index.d.cts +7 -4
  223. package/dist/patterns/cqrs/index.d.ts +7 -4
  224. package/dist/patterns/cqrs/index.js +1 -1
  225. package/dist/patterns/demo-shell/index.cjs +8 -8
  226. package/dist/patterns/demo-shell/index.d.cts +6 -5
  227. package/dist/patterns/demo-shell/index.d.ts +6 -5
  228. package/dist/patterns/demo-shell/index.js +1 -1
  229. package/dist/patterns/domain-templates/index.cjs +5 -5
  230. package/dist/patterns/domain-templates/index.d.cts +5 -4
  231. package/dist/patterns/domain-templates/index.d.ts +5 -4
  232. package/dist/patterns/domain-templates/index.js +1 -1
  233. package/dist/patterns/graphspec/index.cjs +20 -20
  234. package/dist/patterns/graphspec/index.d.cts +6 -5
  235. package/dist/patterns/graphspec/index.d.ts +6 -5
  236. package/dist/patterns/graphspec/index.js +1 -1
  237. package/dist/patterns/guarded-execution/index.cjs +7 -7
  238. package/dist/patterns/guarded-execution/index.d.cts +8 -6
  239. package/dist/patterns/guarded-execution/index.d.ts +8 -6
  240. package/dist/patterns/guarded-execution/index.js +1 -1
  241. package/dist/patterns/harness/index.cjs +12 -12
  242. package/dist/patterns/harness/index.d.cts +13 -10
  243. package/dist/patterns/harness/index.d.ts +13 -10
  244. package/dist/patterns/harness/index.js +1 -1
  245. package/dist/patterns/job-queue/index.cjs +7 -7
  246. package/dist/patterns/job-queue/index.d.cts +8 -4
  247. package/dist/patterns/job-queue/index.d.ts +8 -4
  248. package/dist/patterns/job-queue/index.js +1 -1
  249. package/dist/patterns/lens/index.cjs +4 -4
  250. package/dist/patterns/lens/index.d.cts +7 -6
  251. package/dist/patterns/lens/index.d.ts +7 -6
  252. package/dist/patterns/lens/index.js +1 -1
  253. package/dist/patterns/memory/index.cjs +1 -1
  254. package/dist/patterns/memory/index.d.cts +5 -4
  255. package/dist/patterns/memory/index.d.ts +5 -4
  256. package/dist/patterns/memory/index.js +1 -1
  257. package/dist/patterns/messaging/index.cjs +7 -7
  258. package/dist/patterns/messaging/index.d.cts +6 -4
  259. package/dist/patterns/messaging/index.d.ts +6 -4
  260. package/dist/patterns/messaging/index.js +1 -1
  261. package/dist/patterns/orchestration/index.cjs +7 -7
  262. package/dist/patterns/orchestration/index.d.cts +8 -5
  263. package/dist/patterns/orchestration/index.d.ts +8 -5
  264. package/dist/patterns/orchestration/index.js +1 -1
  265. package/dist/patterns/process/index.cjs +1 -0
  266. package/dist/patterns/process/index.d.cts +10 -0
  267. package/dist/patterns/process/index.d.ts +10 -0
  268. package/dist/patterns/process/index.js +1 -0
  269. package/dist/patterns/reactive-layout/index.cjs +5 -5
  270. package/dist/patterns/reactive-layout/index.d.cts +6 -5
  271. package/dist/patterns/reactive-layout/index.d.ts +6 -5
  272. package/dist/patterns/reactive-layout/index.js +1 -1
  273. package/dist/patterns/reduction/index.cjs +1 -1
  274. package/dist/patterns/reduction/index.d.cts +5 -4
  275. package/dist/patterns/reduction/index.d.ts +5 -4
  276. package/dist/patterns/reduction/index.js +1 -1
  277. package/dist/patterns/refine-loop/index.cjs +8 -8
  278. package/dist/patterns/refine-loop/index.d.cts +7 -5
  279. package/dist/patterns/refine-loop/index.d.ts +7 -5
  280. package/dist/patterns/refine-loop/index.js +1 -1
  281. package/dist/patterns/resilient-pipeline/index.cjs +1 -1
  282. package/dist/patterns/resilient-pipeline/index.d.cts +7 -6
  283. package/dist/patterns/resilient-pipeline/index.d.ts +7 -6
  284. package/dist/patterns/resilient-pipeline/index.js +1 -1
  285. package/dist/patterns/surface/index.cjs +11 -11
  286. package/dist/patterns/surface/index.d.cts +7 -6
  287. package/dist/patterns/surface/index.d.ts +7 -6
  288. package/dist/patterns/surface/index.js +1 -1
  289. package/dist/pipeline-graph-B85HUrWg.d.cts +120 -0
  290. package/dist/pipeline-graph-HOTU4UG0.d.ts +120 -0
  291. package/dist/{reactive-layout-DBJ3Vz-m.d.ts → reactive-layout-Btv0-efV.d.ts} +2 -2
  292. package/dist/{reactive-layout-Dk9AOQb_.d.cts → reactive-layout-D9zqqaqK.d.cts} +2 -2
  293. package/dist/reactive-log-ByBb8g6A.d.ts +188 -0
  294. package/dist/reactive-log-CgbNqksB.d.cts +188 -0
  295. package/dist/{reactive-map-LjwjcFaW.d.ts → reactive-map-CHyeCf4D.d.ts} +1 -1
  296. package/dist/{reactive-map-Cm89Hk0c.d.cts → reactive-map-DmgeADH8.d.cts} +1 -1
  297. package/dist/{resilience-RjDIHZNZ.d.ts → resilience-BWP2c7Af.d.cts} +27 -45
  298. package/dist/{resilience-N_VtLf7W.d.cts → resilience-Bys63Cpd.d.ts} +27 -45
  299. package/dist/resilience-OBU472D2.js +1 -0
  300. package/dist/{sugar-CQkn_rxB.d.ts → sugar-D13E2M_z.d.ts} +1 -1
  301. package/dist/{sugar-DVEYhR7a.d.cts → sugar-DgaGJcI6.d.cts} +1 -1
  302. package/dist/{topology-tree-BB6oJxMz.d.cts → topology-tree-C50l9ARE.d.cts} +1 -1
  303. package/dist/{topology-tree-CAFOG5S5.d.ts → topology-tree-CJsT24DP.d.ts} +1 -1
  304. package/dist/{types-Cp_4coR_.d.cts → types-BMSGPlpO.d.cts} +1 -1
  305. package/dist/{types-B2LfBvNc.d.ts → types-CidcBDuk.d.ts} +1 -1
  306. package/package.json +41 -1
  307. package/dist/chunk-2JO6LXFT.js +0 -7
  308. package/dist/chunk-2LZ6DL45.js +0 -1
  309. package/dist/chunk-3JXNEPCD.js +0 -2
  310. package/dist/chunk-3Y4BXFFR.js +0 -1
  311. package/dist/chunk-55T3K37W.js +0 -1
  312. package/dist/chunk-6HQ6HVTF.js +0 -1
  313. package/dist/chunk-7Q2WPFQ7.js +0 -1
  314. package/dist/chunk-FKRPIRE6.js +0 -1
  315. package/dist/chunk-HTBOCKVD.js +0 -1
  316. package/dist/chunk-I6VIH3VA.js +0 -1
  317. package/dist/chunk-IB64M7VP.js +0 -1
  318. package/dist/chunk-IJFSR4NU.js +0 -1
  319. package/dist/chunk-LOF5HSD3.js +0 -18
  320. package/dist/chunk-T2TB37TW.js +0 -1
  321. package/dist/chunk-T7EQPKOP.js +0 -1
  322. package/dist/chunk-Y63GWRHO.js +0 -5
  323. package/dist/chunk-YUBV7EEE.js +0 -1
  324. package/dist/index-C2Dey3L-.d.cts +0 -152
  325. package/dist/index-ClJUZAOr.d.cts +0 -101
  326. package/dist/index-Cq7Uqgu4.d.ts +0 -192
  327. package/dist/index-Dtpr2FIB.d.ts +0 -101
  328. package/dist/index-HvJ90_tX.d.ts +0 -152
  329. package/dist/index-wcfc7W-f.d.cts +0 -192
  330. package/dist/reactive-log-CWC7jO4J.d.cts +0 -190
  331. package/dist/reactive-log-CqaBg8nf.d.ts +0 -190
  332. package/dist/resilience-7UZHSSGC.js +0 -1
  333. /package/dist/{chunk-L3KUKDZC.js → chunk-O32GJOUJ.js} +0 -0
@@ -1,15 +1,15 @@
1
- "use strict";var so=Object.create;var Se=Object.defineProperty;var Nn=Object.getOwnPropertyDescriptor;var io=Object.getOwnPropertyNames;var ao=Object.prototype.hasOwnProperty;var Sn=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ze=t=>{throw TypeError(t)};var uo=(t,e,n)=>e in t?Se(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var En=(t,e)=>Se(t,"name",{value:e,configurable:!0});var Y=(t,e)=>()=>(t&&(e=t(t=0)),e);var ue=(t,e)=>{for(var n in e)Se(t,n,{get:e[n],enumerable:!0})},co=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of io(e))!ao.call(t,o)&&o!==n&&Se(t,o,{get:()=>e[o],enumerable:!(r=Nn(e,o))||r.enumerable});return t};var lo=t=>co(Se({},"__esModule",{value:!0}),t);var kn=t=>[,,,so(t?.[Sn("metadata")]??null)],An=["class","method","getter","setter","accessor","field","value","get","set"],Be=t=>t!==void 0&&typeof t!="function"?ze("Function expected"):t,fo=(t,e,n,r,o)=>({kind:An[t],name:e,metadata:r,addInitializer:s=>n._?ze("Already initialized"):o.push(Be(s||null))}),po=(t,e)=>uo(e,Sn("metadata"),t[3]),Cn=(t,e,n,r)=>{for(var o=0,s=t[e>>1],i=s&&s.length;o<i;o++)e&1?s[o].call(n):r=s[o].call(n,r);return r},Mn=(t,e,n,r,o,s)=>{var i,a,c,u,l,f=e&7,p=!!(e&8),h=!!(e&16),d=f>3?t.length+1:f?p?1:2:0,g=An[f+5],m=f>3&&(t[d-1]=[]),v=t[d]||(t[d]=[]),_=f&&(!h&&!p&&(o=o.prototype),f<5&&(f>3||!h)&&Nn(f<4?o:{get[n](){return Rn(this,s)},set[n](y){return On(this,s,y)}},n));f?h&&f<4&&En(s,(f>2?"set ":f>1?"get ":"")+n):En(o,n);for(var b=r.length-1;b>=0;b--)u=fo(f,n,c={},t[3],v),f&&(u.static=p,u.private=h,l=u.access={has:h?y=>ho(o,y):y=>n in y},f^3&&(l.get=h?y=>(f^1?Rn:go)(y,o,f^4?s:_.get):y=>y[n]),f>2&&(l.set=h?(y,w)=>On(y,o,w,f^4?s:_.set):(y,w)=>y[n]=w)),a=(0,r[b])(f?f<4?h?s:_[g]:f>4?void 0:{get:_.get,set:_.set}:o,u),c._=1,f^4||a===void 0?Be(a)&&(f>4?m.unshift(a):f?h?s=a:_[g]=a:o=a):typeof a!="object"||a===null?ze("Object expected"):(Be(i=a.get)&&(_.get=i),Be(i=a.set)&&(_.set=i),Be(i=a.init)&&m.unshift(i));return f||po(t,o),_&&Se(o,n,_),h?f^4?s:_:o};var Lt=(t,e,n)=>e.has(t)||ze("Cannot "+n),ho=(t,e)=>Object(e)!==e?ze('Cannot use the "in" operator on this value'):t.has(e),Rn=(t,e,n)=>(Lt(t,e,"read from private field"),n?n.call(t):e.get(t));var On=(t,e,n,r)=>(Lt(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),go=(t,e,n)=>(Lt(t,e,"access private method"),n);var Ke,E,I,B,oe,X,se,q,P,C,ke,Pt,mo,$t,bo,yo,Ht,Dn,Gn,In,Ft,W=Y(()=>{"use strict";Ke=Symbol.for("graphrefly/START"),E=Symbol.for("graphrefly/DATA"),I=Symbol.for("graphrefly/DIRTY"),B=Symbol.for("graphrefly/RESOLVED"),oe=Symbol.for("graphrefly/INVALIDATE"),X=Symbol.for("graphrefly/PAUSE"),se=Symbol.for("graphrefly/RESUME"),q=Symbol.for("graphrefly/TEARDOWN"),P=Symbol.for("graphrefly/COMPLETE"),C=Symbol.for("graphrefly/ERROR"),ke=Object.freeze([I]),Pt=Object.freeze([B]),mo=Object.freeze([oe]),$t=Object.freeze([Ke]),bo=Object.freeze([P]),yo=Object.freeze([q]),Ht=Object.freeze([ke]),Dn=Object.freeze([Pt]),Gn=Object.freeze([mo]),In=Object.freeze([bo]),Ft=Object.freeze([yo])});function Pn(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let o=2+n.length+2+e.length;if(o>4294967295)throw new Error(`encodeEnvelope: total envelope size ${o} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let s=new Uint8Array(o),i=0;return s[i++]=jt,s[i++]=n.length,s.set(n,i),i+=n.length,s[i++]=r>>>8&255,s[i++]=r&255,s.set(e,i),s}function $n(t,e){if(t.length<Ln)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${Ln})`);let n=0,r=t[n++];if(r!==jt)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${jt})`);let o=t[n++];if(o===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+o+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+o+2} bytes, have ${t.length})`);let s=new TextDecoder().decode(t.subarray(n,n+o));n+=o;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),c=e.lookupCodec(s);if(c==null)throw new Error(`decodeEnvelope: codec "${s}" not registered (envelope codec_v=${i})`);return{codec:c,codecVersion:i,payload:a}}function Hn(t){t.registerCodec(vo)}var vo,jt,Ln,Vt=Y(()=>{"use strict";vo={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}},jt=1,Ln=4});function ve(t){if(t==null)return pe;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var pe,Ue=Y(()=>{"use strict";pe={type:"system",id:""}});function at(){return Ae>0||Ye}function Fn(){return Ae>0}function Qe(t){Ae>0?Je.push(t):t()}function ce(t){Ae+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(Ae-=1,Ae===0)if(e){if(!Ye){let n=Je.splice(0);for(let r of n)try{r()}catch{}_e.length=0,xe.length=0,Ce.length=0}}else _o()}}function _o(){let t=!Ye;t&&(Ye=!0);let e=[],n=0;try{for(;_e.length>0||xe.length>0||Ce.length>0||t&&Je.length>0;){if(t&&Je.length>0){let s=Je.splice(0);for(let i of s)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw _e.length=0,xe.length=0,Ce.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(_e.length>0?_e:xe.length>0?xe:Ce).splice(0);for(let s of o)try{s()}catch(i){e.push(i)}}}finally{t&&(Ye=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function ut(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!at()){t(e);return}(u>=5?Ce:u===4?xe:_e).push(()=>t(e));return}let r=e.length,o=r,s=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(o=a;a<r&&n(e[a][0])===3;)a++;for(s=a;a<r&&n(e[a][0])===4;)a++;i=a;let c=at();if(o>0){let u=e.slice(0,o);t(u)}if(s>o){let u=e.slice(o,s);c?_e.push(()=>t(u)):t(u)}if(i>s){let u=e.slice(s,i);c?xe.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);c?Ce.push(()=>t(u)):t(u)}}var Ae,Ye,_e,xe,Ce,Je,we=Y(()=>{"use strict";Ae=0,Ye=!1,_e=[],xe=[],Ce=[],Je=[]});function Me(){return Math.trunc(performance.now()*1e6)}function he(){return Date.now()*1e6}var Xe=Y(()=>{"use strict"});function jn(t){t.registerMessageType(Ke,{tier:0,wireCrossing:!1}),t.registerMessageType(I,{tier:1,wireCrossing:!1}),t.registerMessageType(oe,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(X,{tier:2,wireCrossing:!1}),t.registerMessageType(se,{tier:2,wireCrossing:!1}),t.registerMessageType(E,{tier:3,wireCrossing:!0}),t.registerMessageType(B,{tier:3,wireCrossing:!0}),t.registerMessageType(P,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(C,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(q,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var ct,Vn=Y(()=>{"use strict";W();ct=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function qn(t){return Array.isArray(t)?[...t]:[t]}function xo(t,e){return t.has(e)||t.has("*")}function dt(t){let e=[];return t((o,s)=>{e.push({kind:"allow",actions:new Set(qn(o)),where:s?.where??(()=>!0)})},(o,s)=>{e.push({kind:"deny",actions:new Set(qn(o)),where:s?.where??(()=>!0)})}),(o,s)=>{let i=!1,a=!1;for(let c of e)xo(c.actions,s)&&c.where(o)&&(c.kind==="deny"?i=!0:a=!0);return i?!1:a}}function qt(t){let e=wo.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var Z,wo,De=Y(()=>{"use strict";Z=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};wo=["human","llm","wallet","system"]});function Wt(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(Wt);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=Wt(t[n]);return e}return null}function Ro(t){let e=Eo.encode(t),n=e.length,r=n*8,o=n+9+63&-64,s=new Uint8Array(o);s.set(e),s[n]=128;let i=new DataView(s.buffer);i.setUint32(o-4,r>>>0,!1),i.setUint32(o-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,c=3144134277,u=1013904242,l=2773480762,f=1359893119,p=2600822924,h=528734635,d=1541459225,g=new Uint32Array(64),m=(_,b)=>_>>>b|_<<32-b;for(let _=0;_<o;_+=64){for(let S=0;S<16;S++)g[S]=i.getUint32(_+S*4,!1);for(let S=16;S<64;S++){let A=g[S-15],k=g[S-2],F=m(A,7)^m(A,18)^A>>>3,U=m(k,17)^m(k,19)^k>>>10;g[S]=g[S-16]+F+g[S-7]+U>>>0}let b=a,y=c,w=u,T=l,x=f,R=p,N=h,M=d;for(let S=0;S<64;S++){let A=m(x,6)^m(x,11)^m(x,25),k=x&R^~x&N,F=M+A+k+To[S]+g[S]>>>0,U=m(b,2)^m(b,13)^m(b,22),re=b&y^b&w^y&w,ye=U+re>>>0;M=N,N=R,R=x,x=T+F>>>0,T=w,w=y,y=b,b=F+ye>>>0}a=a+b>>>0,c=c+y>>>0,u=u+w>>>0,l=l+T>>>0,f=f+x>>>0,p=p+R>>>0,h=h+N>>>0,d=d+M>>>0}let v=_=>_.toString(16).padStart(8,"0");return v(a)+v(c)+v(u)+v(l)+v(f)+v(p)+v(h)+v(d)}function Bt(t){let e=Wt(t??null),n=JSON.stringify(e);return Ro(n).slice(0,16)}function Oo(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function zt(t,e,n){let r=n?.id??Oo();if(t===0)return{id:r,version:0};let s=(n?.hash??Bt)(e);return{id:r,version:0,cid:s,prev:null}}function Wn(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var To,Eo,Bn=Y(()=>{"use strict";To=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Eo=new TextEncoder});function Un(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function Kt(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function lt(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function Ee(t,e,n){let r=Yn(t)?t:[],o=typeof t=="function"?t:typeof e=="function"?e:void 0,s={};return Yn(t)?s=(Ut(e)?e:n)??{}:Ut(t)?s=t:s=(Ut(e)?e:n)??{},new $(r,o,s)}var zn,Kn,No,So,Te,$,Yn,Ut,Ge=Y(()=>{"use strict";Vt();Ue();we();Xe();Vn();De();W();Bn();zn=()=>{},Kn=100;No=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},So=(t,e,n,r)=>{let o=t;if(o._status==="completed"||o._status==="errored")return;let s=o._cached,i=s===void 0?[$t]:[$t,[E,s]];o._status==="dirty"&&i.push(ke),ut(e,i,o._config.tierOf)},Te=new ct({onMessage:No,onSubscribe:So});jn(Te);Hn(Te);$=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??Te,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??Bt;let o=r.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?zt(o,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Un);let s={};for(let[a,c]of Object.entries(r.meta??{})){let u={initial:c,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),s[a]=new t([],void 0,u)}Object.freeze(s),this.meta=s,this._hasMeta=Object.keys(s).length>0;let i=this;this._actions={emit(a){i._emit([[E,a]])},down(a){i._emit(lt(a))},up(a){i._emitUp(lt(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let o=n?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let s=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,c=i?.version??0,u=zt(e,s,{id:a,hash:o});u.version=c,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=ve(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let o=ve(e?.actor),s=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,s))throw new Z({actor:o,action:s,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(o,s))throw new Z({actor:o,action:s,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:he()}}down(e,n){let r=lt(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[E,e]])}up(e,n){if(this._deps.length===0)return;let r=lt(e);if(r.length===0)return;this._checkGuard(n);let o=n??{internal:!0};this._validateUpTiers(r);for(let s of this._deps)s.node.up?.(r,o)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let o=n(r[0]);if(o===3||o===4)throw new Error(`Node "${this.name}": tier-${o} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let c=ve(n);if(!this._guard(c,"observe"))throw new Z({actor:c,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let c of this._deps)Kt(c);if(this._partial===!1){for(let c of this._deps)if(c.prevData!==void 0||c.dataBatch.length!==0||c.terminal!==void 0||c.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let s;try{s=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:o},this._actions)}catch(c){throw this._sinkCount-=1,c}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(c){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof s=="function")try{s()}catch{}throw c}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof s=="function"&&s(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let o=r,s=this._deps[r];s.unsub=zn,s.unsub=s.node.subscribe(i=>{if(s.unsub===null)return;let a=this._config.tierOf,c=!1;for(let u of i)a(u[0])>=3&&(c=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:o},this._actions);c&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let o=0;o<n;o++){let s=this._deps[o];if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}Kt(s)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let n=this._deps.length,r=Un(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Ht),r.unsub=zn;try{r.unsub=e.subscribe(o=>{if(r.unsub===null)return;let s=this._config.tierOf,i=!1;for(let a of o)s(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(o){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,o}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[C,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(o){this._emit([[C,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let r of this._deps){if(r.unsub!=null){let o=r.unsub;r.unsub=null;try{o()}catch{}}Kt(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],o=n[0];if(this._inspectorHooks!=null){let s={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(s)}if(o!==Ke){if(o===I){this._depDirtied(r);return}if(o===oe){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(Gn);return}if(o===X||o===se){this._emit([n]);return}if(o===q){this._emit(Ft);return}if(o===E)this._depSettledAsData(r,n[1]);else if(o===B)this._depSettledAsResolved(r);else if(o===P)this._depSettledAsTerminal(r,!0);else if(o===C)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(o===E||o===B)&&this._emit([n]),(o===P||o===C)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Ht))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Dn),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[C,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(In)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[C,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[C,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let o=this._deps.map(i=>i.terminal),s={prevData:r,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,s);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[C,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Kn?(this._rerunDepth=0,this._emit([[C,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Kn} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[ke,e[0]]:e;let r=!0,o=!1,s=!1,i=-1;for(let c of e){let u=n(c[0]);u<i&&(r=!1),u===3&&(o=!0),c[0]===I&&(s=!0),i=u}let a=e;if(!r){let c=e.map((u,l)=>({m:u,i:l,tier:n(u[0])}));c.sort((u,l)=>u.tier-l.tier||u.i-l.i),a=c.map(u=>u.m)}if(o&&!s&&this._status!=="dirty"){let c=0;for(;c<a.length&&n(a[c][0])===0;)c++;return c===0?[ke,...a]:[...a.slice(0,c),ke,...a.slice(c)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let c=e[a];if(c[0]===C&&c[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(c=>c[0]===q||c[0]===oe);if(a.length===0)return;n=a}n=this._frameBatch(n);let o=null;for(let a=0;a<n.length;a++){let c=n[a],u=c[0];if(u!==X&&u!==se){o?.push(c);continue}if(c.length<2)throw new Error(`Node "${this.name}": [[${u===X?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let l=!0;if(this._pausable!==!1){let f=c[1];if(u===X)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))l=!1;else if(this._pauseLocks.delete(f),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}l?o?.push(c):o==null&&(o=n.slice(0,a))}if(o!=null){if(o.length===0)return;n=o}if(this._hasMeta&&n.some(a=>a[0]===q))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(Ft)}catch{}let{finalMessages:s,equalsError:i}=this._updateState(n);if(s.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:s})}catch{}}if(s.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,c=[];for(let u of s)a(u[0])===3?this._pauseBuffer.push(u):c.push(u);c.length>0&&this._dispatchOrAccumulate(c)}else this._dispatchOrAccumulate(s);i!=null&&this._emit([[C,i]])}_updateState(e){let n=this._config.tierOf,r,o,s=-1,i=0;for(let l of e)n(l[0])===3&&i++;let a=i<=1,c=-1;if(this._versioning!=null&&i>1){for(let l=e.length-1;l>=0;l--)if(e[l][0]===E){c=l;break}}for(let l=0;l<e.length;l++){let f=e[l],p=f[0];if(p===E){if(f.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,f[1])}catch(d){o=this._wrapFnError("equals threw",d),s=l;break}if(h){r==null&&(r=e.slice(0,l)),r.push(Pt),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(c<0||l===c)&&Wn(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),p===I)this._status="dirty";else if(p===B)this._status="resolved";else if(p===P){this._status="completed";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===C){this._status="errored";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===oe){if(this._cached!==void 0){let d=this._config.rigorRecorder;if(d!=null)try{d.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let d=h.invalidate;if(typeof d=="function")try{d()}catch{}}}else p===q&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=s>=0?r??e.slice(0,s):r??e;return o!=null?{finalMessages:u,equalsError:o}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(Fn()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Qe(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}ut(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);ut(this._deliverToSinks,n,this._config.tierOf)}},Yn=t=>Array.isArray(t),Ut=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function V(t,e){return Ee([],{...e,initial:t})}function Ie(t,e){return Ee((r,o,s)=>t(o,s)??void 0,{describeKind:"producer",...e})}function ie(t,e,n){return Ee(t,(o,s,i)=>{let a=o.map((c,u)=>c!=null&&c.length>0?c.at(-1):i.prevData[u]);s.emit(e(a,i))},{describeKind:"derived",...n})}function Yt(t,e,n){let r=new Map;return t.forEach((o,s)=>{r.set(o,s)}),ie(t,(o,s)=>e(a=>{let c=r.get(a);if(c==null)throw new Error(`dynamicNode: untracked dep "${a.name??"<unnamed>"}"`);return o[c]},s),n)}function Ze(t,e){let n,r=new Map,o=(s,i,a)=>{let c=!1,u=l=>{let f=r.get(l);if(f!==void 0){if(f<s.length){let h=s[f];return h!=null&&h.length>0?h.at(-1):a.prevData[f]}return l.cache}c=!0;let p=n._addDep(l);return r.set(l,p),l.cache};try{let l=t(u,a);c||(i.emit(l),a.store.__autoTrackLastDiscoveryError!=null&&delete a.store.__autoTrackLastDiscoveryError)}catch(l){if(!c)throw l;a.store.__autoTrackLastDiscoveryError=l}};return n=new $([],o,{describeKind:"derived",...e}),n}var de=Y(()=>{"use strict";Ge()});function nt(t,e,n){let r=new Set;for(let o of t.split(",")){let[s,i]=o.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${o}`);let c,u;if(s==="*")c=e,u=n;else if(s.includes("-")){let[l,f]=s.split("-");c=Number.parseInt(l,10),u=Number.parseInt(f,10)}else c=Number.parseInt(s,10),u=c;if(Number.isNaN(c)||Number.isNaN(u))throw new Error(`Invalid cron field: ${t}`);if(c<e||u>n)throw new Error(`Cron field out of range: ${t} (${e}-${n})`);if(c>u)throw new Error(`Invalid cron range: ${c}-${u} in ${t}`);for(let l=c;l<=u;l+=a)r.add(l)}return r}function fr(t){let e=t.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:nt(e[0],0,59),hours:nt(e[1],0,23),daysOfMonth:nt(e[2],1,31),months:nt(e[3],1,12),daysOfWeek:nt(e[4],0,6)}}function pr(t,e){return t.minutes.has(e.getMinutes())&&t.hours.has(e.getHours())&&t.daysOfMonth.has(e.getDate())&&t.months.has(e.getMonth()+1)&&t.daysOfWeek.has(e.getDay())}var hr=Y(()=>{"use strict"});function gr(t){return{describeKind:"producer",...t}}function mr(t,e){let{signal:n,period:r,...o}=e??{};return Ie(s=>{let i=!1,a=0,c,u,l=()=>{i=!0,c!==void 0&&clearTimeout(c),u!==void 0&&clearInterval(u),n?.removeEventListener("abort",p)},f=()=>{i||(r!=null?(s.emit(a++),u=setInterval(()=>{i||s.emit(a++)},r)):(i=!0,n?.removeEventListener("abort",p),s.emit(a++),s.down([[P]])))},p=()=>{i||(l(),s.down([[C,n.reason]]))};if(n?.aborted){p();return}return c=setTimeout(f,t),n?.addEventListener("abort",p,{once:!0}),l},gr(o))}function br(t,e){let n=fr(t),{tickMs:r,output:o,...s}=e??{},i=r??6e4,a=o==="date";return Ie(c=>{let u=-1,l=()=>{let p=new Date,h=p.getFullYear()*1e8+(p.getMonth()+1)*1e6+p.getDate()*1e4+p.getHours()*100+p.getMinutes();h!==u&&pr(n,p)&&(u=h,c.emit(a?p:he()))};l();let f=setInterval(l,i);return()=>clearInterval(f)},{...gr(s),name:s.name??`cron:${t}`})}function ge(t){return t.subscribe(()=>{})}var gt=Y(()=>{"use strict";Xe();W();de();hr()});var _t,Er=Y(()=>{"use strict";_t=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Xs={};ue(Xs,{jotai:()=>Jt,nanostores:()=>Xt,nestjs:()=>hn,react:()=>gn,signals:()=>yn,solid:()=>vn,svelte:()=>_n,vue:()=>xn,zustand:()=>wn});module.exports=lo(Xs);var Jt={};ue(Jt,{atom:()=>ko});W();de();function ko(t,e,n){if(typeof t=="function"){let r=t;return typeof e=="function"?Jn(r,e,n):Jn(r,void 0,e)}return Ao(t,e)}function et(t){let e=t.cache,n;if(t.subscribe(o=>{for(let[s,i]of o)s===E&&(e=i),s===C&&(n=i)})(),n)throw n;return e}function Ao(t,e){let n=V(t,{...e,resubscribable:!0,resetOnTeardown:!0});return{get:()=>n.status==="sentinel"?et(n):n.cache,set:r=>n.emit(r),update:r=>{let o=n.status==="sentinel"?et(n):n.cache;n.emit(r(o))},subscribe:r=>{let o=!0;return n.subscribe(s=>{for(let[i,a]of s)if(i===E){if(o){o=!1;continue}r(a)}})},meta:n.meta,_node:n}}function Jn(t,e,n){let r=Ze(s=>t(i=>{let a=i._node;return a.status==="sentinel"&&et(a),s(a)}),{...n,resubscribable:!0,resetOnTeardown:!0}),o={get:()=>r.status==="sentinel"?et(r):r.cache,subscribe:s=>{let i=!0;return r.subscribe(a=>{for(let[c,u]of a)if(c===E){if(i){i=!1;continue}s(u)}})},meta:r.meta,_node:r};if(e){let s=c=>c.get(),i=(c,u)=>c.set(u),a=o;return a.set=c=>e(s,i,c),a.update=c=>{let u=r.status==="sentinel"?et(r):r.cache;return e(s,i,c(u))},a}return o}var Xt={};ue(Xt,{action:()=>Lo,atom:()=>Co,computed:()=>Mo,getValue:()=>Go,map:()=>Do,onMount:()=>Io,onStart:()=>Zn,onStop:()=>er});we();W();de();var pt=new WeakMap,ht=new WeakMap;function ft(t,e){let n=e.get(t);if(n)for(let r of n)r()}function Qt(t,e={}){let n=0;return{...e,get:()=>Xn(t),subscribe:o=>{n===0&&ft(t,pt),n++;let s=t.subscribe(i=>{for(let[a,c]of i)a===E&&o(c)});return()=>{s(),n--,n===0&&ft(t,ht)}},listen:o=>{n===0&&ft(t,pt),n++;let s=!0,i=t.subscribe(a=>{for(let[c,u]of a)if(c===E){if(s){s=!1;continue}o(u)}});return()=>{i(),n--,n===0&&ft(t,ht)}},_node:t}}function Qn(t){let e=t.cache,n;if(t.subscribe(o=>{for(let[s,i]of o)s===E&&(e=i),s===C&&(n=i)})(),n)throw n;return e}function Xn(t){return t.status==="sentinel"?Qn(t):t.cache}function Co(t){let e=V(t,{resubscribable:!0,resetOnTeardown:!0});return Qt(e,{set:n=>e.emit(n)})}function Mo(t,e){let n=Array.isArray(t)?t:[t],r=n.map(s=>s._node),o=Yt(r,s=>{let i=n.map(a=>{let c=a._node;return c.status==="sentinel"&&Qn(c),s(c)});return e(...i)},{resubscribable:!0,resetOnTeardown:!0,equals:Object.is});return Qt(o)}function Do(t){let e=V(t,{resubscribable:!0,resetOnTeardown:!0,equals:()=>!1});return Qt(e,{set:n=>e.emit(n),setKey:(n,r)=>{let o=Xn(e);e.emit({...o,[n]:r})}})}function Go(t){return t.get()}function Zn(t,e){let n=t._node,r=pt.get(n);r||(r=new Set,pt.set(n,r)),r.add(e)}function er(t,e){let n=t._node,r=ht.get(n);r||(r=new Set,ht.set(n,r)),r.add(e)}function Io(t,e){Zn(t,()=>{let n=e();typeof n=="function"&&er(t,n)})}function Lo(t,e,n){return(...r)=>{let o;return ce(()=>{o=n(...r)}),o}}var hn={};ue(hn,{ACTOR_KEY:()=>yt,COMMAND_HANDLERS:()=>He,CQRS_EVENT_HANDLERS:()=>Fe,CRON_HANDLERS:()=>$e,CommandHandler:()=>ur,EVENT_HANDLERS:()=>Le,EventHandler:()=>cr,GRAPHREFLY_REQUEST_GRAPH:()=>Re,GRAPHREFLY_ROOT_GRAPH:()=>ee,GraphCron:()=>ar,GraphInterval:()=>ir,GraphReflyEventExplorer:()=>Oe,GraphReflyGuard:()=>Tr,GraphReflyGuardImpl:()=>rt,GraphReflyModule:()=>At,INTERVAL_HANDLERS:()=>Pe,InjectCqrsGraph:()=>rr,InjectGraph:()=>nr,InjectNode:()=>or,ObserveGateway:()=>bt,OnGraphEvent:()=>sr,QUERY_HANDLERS:()=>je,QueryHandler:()=>dr,SAGA_HANDLERS:()=>Ve,SagaHandler:()=>lr,fromHeader:()=>xr,fromJwtPayload:()=>nn,getActor:()=>wr,getGraphToken:()=>K,getNodeToken:()=>ae,observeSSE:()=>vr,observeSubscription:()=>_r,toObservable:()=>tr});var Zt=require("rxjs");W();function tr(t,e){return e?.raw?new Zt.Observable(n=>t.subscribe(o=>{if(!n.closed){n.next(o);for(let s of o){if(s[0]===C){n.error(s[1]);return}if(s[0]===P){n.complete();return}}}})):new Zt.Observable(n=>t.subscribe(o=>{for(let s of o){if(n.closed)return;if(s[0]===E)n.next(s[1]);else if(s[0]===C){n.error(s[1]);return}else if(s[0]===P){n.complete();return}}}))}var tt=require("@nestjs/common");var ee=Symbol.for("graphrefly:root-graph");var Re=Symbol.for("graphrefly:request-graph");function K(t){return Symbol.for(`graphrefly:graph:${t}`)}function ae(t){return Symbol.for(`graphrefly:node:${t}`)}var Le=new Map,Pe=new Map,$e=new Map,He=new Map,Fe=new Map,je=new Map,Ve=new Map;function nr(t){return t==="request"?(0,tt.Inject)(Re):(0,tt.Inject)(t?K(t):ee)}function rr(t){return(0,tt.Inject)(K(t))}function or(t){return(0,tt.Inject)(ae(t))}function sr(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=Le.get(o)??[];s.push({nodeName:t,methodKey:r}),Le.set(o,s)})}}function ir(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=Pe.get(o)??[];s.push({ms:t,methodKey:r}),Pe.set(o,s)})}}function ar(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=$e.get(o)??[];s.push({expr:t,methodKey:r}),$e.set(o,s)})}}function ur(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=He.get(s)??[];i.push({cqrsName:t,commandName:e,methodKey:o}),He.set(s,i)})}}function cr(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=Fe.get(s)??[];i.push({cqrsName:t,eventName:e,methodKey:o}),Fe.set(s,i)})}}function dr(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=je.get(s)??[];i.push({cqrsName:t,projectionName:e,methodKey:o}),je.set(s,i)})}}function lr(t,e,n){return(r,o)=>{let s=o.name;o.addInitializer(function(){let i=this.constructor,a=Ve.get(i)??[];a.push({cqrsName:t,eventNames:n,sagaName:e,methodKey:s}),Ve.set(i,a)})}}W();gt();var yr=0,Oe=class{constructor(e,n){this.graph=e;this.moduleRef=n}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,n]of Le){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireEventHandler(r,o)}}wireEventHandler(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),i=this.observeNode(n.nodeName).subscribe(a=>{for(let c of a)c[0]===E&&o(c[1])});this.disposers.push(i)}wireIntervals(){for(let[e,n]of Pe){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireIntervalHandler(r,e,o)}}wireIntervalHandler(e,n,r){let o=e[r.methodKey];if(typeof o!="function")return;let s=o.bind(e),a=`__schedule__.${n.name??"anonymous"}.${String(r.methodKey)}.${yr++}`,c=mr(r.ms,{period:r.ms,name:a});this.graph.add(c),this.scheduleNodeNames.push(a);let l=this.observeNode(a).subscribe(f=>{for(let p of f)p[0]===E&&s(p[1])});this.disposers.push(l)}wireCrons(){for(let[e,n]of $e){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCronHandler(r,e,o)}}wireCronHandler(e,n,r){let o=e[r.methodKey];if(typeof o!="function")return;let s=o.bind(e),a=`__schedule__.${n.name??"anonymous"}.${String(r.methodKey)}.${yr++}`,c=br(r.expr,{name:a});this.graph.add(c),this.scheduleNodeNames.push(a);let l=this.observeNode(a).subscribe(f=>{for(let p of f)p[0]===E&&s(p[1])});this.disposers.push(l)}wireCqrsCommands(){for(let[e,n]of He){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsCommand(r,o)}}wireCqrsCommand(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);s&&s.command(n.commandName,o)}wireCqrsEvents(){for(let[e,n]of Fe){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsEventHandler(r,o)}}wireCqrsEventHandler(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);if(!s)return;s.event(n.eventName);let a=s.resolve(n.eventName).cache,c=a&&a.length>0?a[a.length-1].seq:0,l=this.observeNodeOn(s,n.eventName).subscribe(f=>{for(let p of f)if(p[0]===E){let h=p[1];for(let d of h)d.seq>c&&(o(d),c=d.seq)}});this.disposers.push(l)}wireCqrsQueries(){for(let[e,n]of je){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsQuery(r,o)}}wireCqrsQuery(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);if(!s)return;let a=this.observeNodeOn(s,n.projectionName).subscribe(c=>{for(let u of c)u[0]===E&&o(u[1])});this.disposers.push(a)}wireCqrsSagas(){for(let[e,n]of Ve){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsSaga(r,o)}}wireCqrsSaga(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);s&&s.saga(n.sagaName,n.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,n){return e.observe(n)}resolveCqrsGraph(e){try{return this.moduleRef.get(K(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}}};W();W();var Po=0;function mt(t,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let n=Symbol(`bp-${++Po}`),r=0,o=!1;return{onEnqueue(){return r+=1,!o&&r>=e.highWaterMark?(o=!0,t([[X,n]]),!0):!1},onDequeue(){return r>0&&(r-=1),o&&r<=e.lowWaterMark?(o=!1,t([[se,n]]),!0):!1},get pending(){return r},get paused(){return o},dispose(){o&&(o=!1,t([[se,n]]))}}}function vr(t,e,n){let{actor:r,serialize:o=$o,keepAliveMs:s,signal:i}=n??{},a=new TextEncoder,c,u=n?.highWaterMark!=null,l,f,p=[],h=!1;return new ReadableStream({start(d){let g,m=()=>{},v=()=>{if(!h){h=!0,g!==void 0&&clearInterval(g),i?.removeEventListener("abort",_),m(),l?.dispose(),f?.(),f=void 0;for(let y of p)d.enqueue(y.frame);p.length=0,d.close()}};c=v;let _=()=>v(),b=t.observe(e,{actor:r});u&&(l=mt(y=>b.up(y),{highWaterMark:n.highWaterMark,lowWaterMark:n.lowWaterMark??Math.floor(n.highWaterMark/2)})),m=b.subscribe(y=>{for(let w of y){if(h)return;let T=w[0];if(T===E){let x=a.encode(en("data",o(w[1])));u?(p.push({frame:x,counted:!0}),l.onEnqueue(),f?.(),f=void 0):d.enqueue(x)}else if(T===C){let x=a.encode(en("error",o(w[1])));u?(p.push({frame:x,counted:!1}),f?.(),f=void 0):d.enqueue(x),v();return}else if(T===P||T===q){if(T===P){let x=a.encode(en("complete"));u?(p.push({frame:x,counted:!1}),f?.(),f=void 0):d.enqueue(x)}v();return}}}),s!==void 0&&s>0&&(g=setInterval(()=>{h||(u?(p.push({frame:a.encode(`: keepalive
1
+ "use strict";var To=Object.create;var Le=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var xo=Object.getOwnPropertyNames;var wo=Object.prototype.hasOwnProperty;var qn=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ze=t=>{throw TypeError(t)};var Eo=(t,e,n)=>e in t?Le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var $n=(t,e)=>Le(t,"name",{value:e,configurable:!0});var Z=(t,e)=>()=>(t&&(e=t(t=0)),e);var ce=(t,e)=>{for(var n in e)Le(t,n,{get:e[n],enumerable:!0})},Ro=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of xo(e))!wo.call(t,o)&&o!==n&&Le(t,o,{get:()=>e[o],enumerable:!(r=Vn(e,o))||r.enumerable});return t};var So=t=>Ro(Le({},"__esModule",{value:!0}),t);var jn=t=>[,,,To(t?.[qn("metadata")]??null)],zn=["class","method","getter","setter","accessor","field","value","get","set"],Xe=t=>t!==void 0&&typeof t!="function"?Ze("Function expected"):t,Oo=(t,e,n,r,o)=>({kind:zn[t],name:e,metadata:r,addInitializer:s=>n._?Ze("Already initialized"):o.push(Xe(s||null))}),No=(t,e)=>Eo(e,qn("metadata"),t[3]),Bn=(t,e,n,r)=>{for(var o=0,s=t[e>>1],i=s&&s.length;o<i;o++)e&1?s[o].call(n):r=s[o].call(n,r);return r},Wn=(t,e,n,r,o,s)=>{var i,a,d,u,c,l=e&7,p=!!(e&8),h=!!(e&16),f=l>3?t.length+1:l?p?1:2:0,m=zn[l+5],b=l>3&&(t[f-1]=[]),T=t[f]||(t[f]=[]),x=l&&(!h&&!p&&(o=o.prototype),l<5&&(l>3||!h)&&Vn(l<4?o:{get[n](){return Fn(this,s)},set[n](y){return Hn(this,s,y)}},n));l?h&&l<4&&$n(s,(l>2?"set ":l>1?"get ":"")+n):$n(o,n);for(var v=r.length-1;v>=0;v--)u=Oo(l,n,d={},t[3],T),l&&(u.static=p,u.private=h,c=u.access={has:h?y=>ko(o,y):y=>n in y},l^3&&(c.get=h?y=>(l^1?Fn:Ao)(y,o,l^4?s:x.get):y=>y[n]),l>2&&(c.set=h?(y,R)=>Hn(y,o,R,l^4?s:x.set):(y,R)=>y[n]=R)),a=(0,r[v])(l?l<4?h?s:x[m]:l>4?void 0:{get:x.get,set:x.set}:o,u),d._=1,l^4||a===void 0?Xe(a)&&(l>4?b.unshift(a):l?h?s=a:x[m]=a:o=a):typeof a!="object"||a===null?Ze("Object expected"):(Xe(i=a.get)&&(x.get=i),Xe(i=a.set)&&(x.set=i),Xe(i=a.init)&&b.unshift(i));return l||No(t,o),x&&Le(o,n,x),h?l^4?s:x:o};var Jt=(t,e,n)=>e.has(t)||Ze("Cannot "+n),ko=(t,e)=>Object(e)!==e?Ze('Cannot use the "in" operator on this value'):t.has(e),Fn=(t,e,n)=>(Jt(t,e,"read from private field"),n?n.call(t):e.get(t));var Hn=(t,e,n,r)=>(Jt(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),Ao=(t,e,n)=>(Jt(t,e,"access private method"),n);var we,A,P,z,re,ee,oe,W,$,D,Ee,yt,Kn,bt,Un,Yn,vt,Qt,Xt,Zt,_t,K=Z(()=>{"use strict";we=Symbol.for("graphrefly/START"),A=Symbol.for("graphrefly/DATA"),P=Symbol.for("graphrefly/DIRTY"),z=Symbol.for("graphrefly/RESOLVED"),re=Symbol.for("graphrefly/INVALIDATE"),ee=Symbol.for("graphrefly/PAUSE"),oe=Symbol.for("graphrefly/RESUME"),W=Symbol.for("graphrefly/TEARDOWN"),$=Symbol.for("graphrefly/COMPLETE"),D=Symbol.for("graphrefly/ERROR"),Ee=Object.freeze([P]),yt=Object.freeze([z]),Kn=Object.freeze([re]),bt=Object.freeze([we]),Un=Object.freeze([$]),Yn=Object.freeze([W]),vt=Object.freeze([Ee]),Qt=Object.freeze([yt]),Xt=Object.freeze([Kn]),Zt=Object.freeze([Un]),_t=Object.freeze([Yn])});function Qn(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let o=2+n.length+2+e.length;if(o>4294967295)throw new Error(`encodeEnvelope: total envelope size ${o} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let s=new Uint8Array(o),i=0;return s[i++]=en,s[i++]=n.length,s.set(n,i),i+=n.length,s[i++]=r>>>8&255,s[i++]=r&255,s.set(e,i),s}function Xn(t,e){if(t.length<Jn)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${Jn})`);let n=0,r=t[n++];if(r!==en)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${en})`);let o=t[n++];if(o===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+o+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+o+2} bytes, have ${t.length})`);let s=new TextDecoder().decode(t.subarray(n,n+o));n+=o;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),d=e.lookupCodec(s);if(d==null)throw new Error(`decodeEnvelope: codec "${s}" not registered (envelope codec_v=${i})`);return{codec:d,codecVersion:i,payload:a}}function Zn(t){t.registerCodec(Co)}var Co,en,Jn,tn=Z(()=>{"use strict";Co={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}},en=1,Jn=4});function Re(t){if(t==null)return ye;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var ye,et=Z(()=>{"use strict";ye={type:"system",id:""}});function Tt(){return Pe>0||tt}function er(){return Pe>0}function rt(t){Pe>0?nt.push(t):t()}function le(t){Pe+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(Pe-=1,Pe===0)if(e){if(!tt){let n=nt.splice(0);for(let r of n)try{r()}catch{}Se.length=0,Oe.length=0,$e.length=0}}else Mo()}}function Mo(){let t=!tt;t&&(tt=!0);let e=[],n=0;try{for(;Se.length>0||Oe.length>0||$e.length>0||t&&nt.length>0;){if(t&&nt.length>0){let s=nt.splice(0);for(let i of s)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw Se.length=0,Oe.length=0,$e.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(Se.length>0?Se:Oe.length>0?Oe:$e).splice(0);for(let s of o)try{s()}catch(i){e.push(i)}}}finally{t&&(tt=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function xt(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!Tt()){t(e);return}(u>=5?$e:u===4?Oe:Se).push(()=>t(e));return}let r=e.length,o=r,s=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(o=a;a<r&&n(e[a][0])===3;)a++;for(s=a;a<r&&n(e[a][0])===4;)a++;i=a;let d=Tt();if(o>0){let u=e.slice(0,o);t(u)}if(s>o){let u=e.slice(o,s);d?Se.push(()=>t(u)):t(u)}if(i>s){let u=e.slice(s,i);d?Oe.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);d?$e.push(()=>t(u)):t(u)}}var Pe,tt,Se,Oe,$e,nt,Ne=Z(()=>{"use strict";Pe=0,tt=!1,Se=[],Oe=[],$e=[],nt=[]});function Fe(){return Math.trunc(performance.now()*1e6)}function se(){return Date.now()*1e6}var ot=Z(()=>{"use strict"});function tr(t){t.registerMessageType(we,{tier:0,wireCrossing:!1}),t.registerMessageType(P,{tier:1,wireCrossing:!1}),t.registerMessageType(re,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(ee,{tier:2,wireCrossing:!1}),t.registerMessageType(oe,{tier:2,wireCrossing:!1}),t.registerMessageType(A,{tier:3,wireCrossing:!0}),t.registerMessageType(z,{tier:3,wireCrossing:!0}),t.registerMessageType($,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(D,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(W,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var wt,nr=Z(()=>{"use strict";K();wt=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function rr(t){return Array.isArray(t)?[...t]:[t]}function Do(t,e){return t.has(e)||t.has("*")}function He(t){let e=[];return t((o,s)=>{e.push({kind:"allow",actions:new Set(rr(o)),where:s?.where??(()=>!0)})},(o,s)=>{e.push({kind:"deny",actions:new Set(rr(o)),where:s?.where??(()=>!0)})}),(o,s)=>{let i=!1,a=!1;for(let d of e)Do(d.actions,s)&&d.where(o)&&(d.kind==="deny"?i=!0:a=!0);return i?!1:a}}function nn(t){let e=Go.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var ie,Go,ke=Z(()=>{"use strict";ie=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};Go=["human","llm","wallet","system"]});function rn(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(rn);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=rn(t[n]);return e}return null}function Po(t){let e=Lo.encode(t),n=e.length,r=n*8,o=n+9+63&-64,s=new Uint8Array(o);s.set(e),s[n]=128;let i=new DataView(s.buffer);i.setUint32(o-4,r>>>0,!1),i.setUint32(o-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,d=3144134277,u=1013904242,c=2773480762,l=1359893119,p=2600822924,h=528734635,f=1541459225,m=new Uint32Array(64),b=(x,v)=>x>>>v|x<<32-v;for(let x=0;x<o;x+=64){for(let w=0;w<16;w++)m[w]=i.getUint32(x+w*4,!1);for(let w=16;w<64;w++){let S=m[w-15],k=m[w-2],M=b(S,7)^b(S,18)^S>>>3,G=b(k,17)^b(k,19)^k>>>10;m[w]=m[w-16]+M+m[w-7]+G>>>0}let v=a,y=d,R=u,N=c,g=l,_=p,O=h,E=f;for(let w=0;w<64;w++){let S=b(g,6)^b(g,11)^b(g,25),k=g&_^~g&O,M=E+S+k+Io[w]+m[w]>>>0,G=b(v,2)^b(v,13)^b(v,22),L=v&y^v&R^y&R,U=G+L>>>0;E=O,O=_,_=g,g=N+M>>>0,N=R,R=y,y=v,v=M+U>>>0}a=a+v>>>0,d=d+y>>>0,u=u+R>>>0,c=c+N>>>0,l=l+g>>>0,p=p+_>>>0,h=h+O>>>0,f=f+E>>>0}let T=x=>x.toString(16).padStart(8,"0");return T(a)+T(d)+T(u)+T(c)+T(l)+T(p)+T(h)+T(f)}function on(t){let e=rn(t??null),n=JSON.stringify(e);return Po(n).slice(0,16)}function $o(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function sn(t,e,n){let r=n?.id??$o();if(t===0)return{id:r,version:0};let s=(n?.hash??on)(e);return{id:r,version:0,cid:s,prev:null}}function or(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Io,Lo,sr=Z(()=>{"use strict";Io=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Lo=new TextEncoder});function ur(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function an(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Et(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function pe(t,e,n){let r=dr(t)?t:[],o=typeof t=="function"?t:typeof e=="function"?e:void 0,s={};return dr(t)?s=(un(e)?e:n)??{}:un(t)?s=t:s=(un(e)?e:n)??{},new V(r,o,s)}var ir,ar,Fo,Ho,Ae,V,dr,un,Ce=Z(()=>{"use strict";tn();et();Ne();ot();nr();ke();K();sr();ir=()=>{},ar=100;Fo=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},Ho=(t,e,n,r)=>{let o=t;if(o._status==="completed"||o._status==="errored")return;let s=o._cached,i=s===void 0?[bt]:[bt,[A,s]];o._status==="dirty"&&i.push(Ee),xt(e,i,o._config.tierOf)},Ae=new wt({onMessage:Fo,onSubscribe:Ho});tr(Ae);Zn(Ae);V=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??Ae,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??on;let o=r.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?sn(o,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(ur);let s={};for(let[a,d]of Object.entries(r.meta??{})){let u={initial:d,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),s[a]=new t([],void 0,u)}Object.freeze(s),this.meta=s,this._hasMeta=Object.keys(s).length>0;let i=this;this._actions={emit(a){i._emit([[A,a]])},down(a){i._emit(Et(a))},up(a){i._emitUp(Et(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let o=n?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let s=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,d=i?.version??0,u=sn(e,s,{id:a,hash:o});u.version=d,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=Re(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let o=Re(e?.actor),s=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,s))throw new ie({actor:o,action:s,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(o,s))throw new ie({actor:o,action:s,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:se()}}down(e,n){let r=Et(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[A,e]])}up(e,n){if(this._deps.length===0)return;let r=Et(e);if(r.length===0)return;this._checkGuard(n);let o=n??{internal:!0};this._validateUpTiers(r);for(let s of this._deps)s.node.up?.(r,o)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let o=n(r[0]);if(o===3||o===4)throw new Error(`Node "${this.name}": tier-${o} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let d=Re(n);if(!this._guard(d,"observe"))throw new ie({actor:d,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)an(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let s;try{s=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:o},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof s=="function")try{s()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof s=="function"&&s(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let o=r,s=this._deps[r];s.unsub=ir,s.unsub=s.node.subscribe(i=>{if(s.unsub===null)return;let a=this._config.tierOf,d=!1;for(let u of i)a(u[0])>=3&&(d=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:o},this._actions);d&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let o=0;o<n;o++){let s=this._deps[o];if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}an(s)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let n=this._deps.length,r=ur(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(vt),r.unsub=ir;try{r.unsub=e.subscribe(o=>{if(r.unsub===null)return;let s=this._config.tierOf,i=!1;for(let a of o)s(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(o){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,o}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[D,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(o){this._emit([[D,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let r of this._deps){if(r.unsub!=null){let o=r.unsub;r.unsub=null;try{o()}catch{}}an(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],o=n[0];if(this._inspectorHooks!=null){let s={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(s)}if(o!==we){if(o===P){this._depDirtied(r);return}if(o===re){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(Xt);return}if(o===ee||o===oe){this._emit([n]);return}if(o===W){this._emit(_t);return}if(o===A)this._depSettledAsData(r,n[1]);else if(o===z)this._depSettledAsResolved(r);else if(o===$)this._depSettledAsTerminal(r,!0);else if(o===D)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(o===A||o===z)&&this._emit([n]),(o===$||o===D)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(vt))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Qt),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[D,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(Zt)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[D,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[D,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let o=this._deps.map(i=>i.terminal),s={prevData:r,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,s);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[D,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>ar?(this._rerunDepth=0,this._emit([[D,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${ar} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[Ee,e[0]]:e;let r=!0,o=!1,s=!1,i=-1;for(let d of e){let u=n(d[0]);u<i&&(r=!1),u===3&&(o=!0),d[0]===P&&(s=!0),i=u}let a=e;if(!r){let d=e.map((u,c)=>({m:u,i:c,tier:n(u[0])}));d.sort((u,c)=>u.tier-c.tier||u.i-c.i),a=d.map(u=>u.m)}if(o&&!s&&this._status!=="dirty"){let d=0;for(;d<a.length&&n(a[d][0])===0;)d++;return d===0?[Ee,...a]:[...a.slice(0,d),Ee,...a.slice(d)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let d=e[a];if(d[0]===D&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(d=>d[0]===W||d[0]===re);if(a.length===0)return;n=a}n=this._frameBatch(n);let o=null;for(let a=0;a<n.length;a++){let d=n[a],u=d[0];if(u!==ee&&u!==oe){o?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===ee?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let l=d[1];if(u===ee)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(l),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(l))c=!1;else if(this._pauseLocks.delete(l),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?o?.push(d):o==null&&(o=n.slice(0,a))}if(o!=null){if(o.length===0)return;n=o}if(this._hasMeta&&n.some(a=>a[0]===W))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(_t)}catch{}let{finalMessages:s,equalsError:i}=this._updateState(n);if(s.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:s})}catch{}}if(s.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,d=[];for(let u of s)a(u[0])===3?this._pauseBuffer.push(u):d.push(u);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(s);i!=null&&this._emit([[D,i]])}_updateState(e){let n=this._config.tierOf,r,o,s=-1,i=0;for(let c of e)n(c[0])===3&&i++;let a=i<=1,d=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===A){d=c;break}}for(let c=0;c<e.length;c++){let l=e[c],p=l[0];if(p===A){if(l.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,l[1])}catch(f){o=this._wrapFnError("equals threw",f),s=c;break}if(h){r==null&&(r=e.slice(0,c)),r.push(yt),this._status="resolved";continue}this._cached=l[1],this._versioning!=null&&(d<0||c===d)&&or(this._versioning,l[1],this._hashFn)}this._status="settled",r?.push(l)}else if(r?.push(l),p===P)this._status="dirty";else if(p===z)this._status="resolved";else if(p===$){this._status="completed";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===D){this._status="errored";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===re){if(this._cached!==void 0){let f=this._config.rigorRecorder;if(f!=null)try{f.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let f=h.invalidate;if(typeof f=="function")try{f()}catch{}}}else p===W&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=s>=0?r??e.slice(0,s):r??e;return o!=null?{finalMessages:u,equalsError:o}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(er()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],rt(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}xt(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);xt(this._deliverToSinks,n,this._config.tierOf)}},dr=t=>Array.isArray(t),un=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function q(t,e){return pe([],{...e,initial:t})}function Ve(t,e){return pe((r,o,s)=>t(o,s)??void 0,{describeKind:"producer",...e})}function J(t,e,n){return pe(t,(o,s,i)=>{let a=o.map((d,u)=>d!=null&&d.length>0?d.at(-1):i.prevData[u]);s.emit(e(a,i))},{describeKind:"derived",...n})}function dn(t,e,n){let r=new Map;return t.forEach((o,s)=>{r.set(o,s)}),J(t,(o,s)=>e(a=>{let d=r.get(a);if(d==null)throw new Error(`dynamicNode: untracked dep "${a.name??"<unnamed>"}"`);return o[d]},s),n)}function st(t,e){let n,r=new Map,o=(s,i,a)=>{let d=!1,u=c=>{let l=r.get(c);if(l!==void 0){if(l<s.length){let h=s[l];return h!=null&&h.length>0?h.at(-1):a.prevData[l]}return c.cache}d=!0;let p=n._addDep(c);return r.set(c,p),c.cache};try{let c=t(u,a);d||(i.emit(c),a.store.__autoTrackLastDiscoveryError!=null&&delete a.store.__autoTrackLastDiscoveryError)}catch(c){if(!d)throw c;a.store.__autoTrackLastDiscoveryError=c}};return n=new V([],o,{describeKind:"derived",...e}),n}var fe=Z(()=>{"use strict";Ce()});function ut(t,e,n){let r=new Set;for(let o of t.split(",")){let[s,i]=o.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${o}`);let d,u;if(s==="*")d=e,u=n;else if(s.includes("-")){let[c,l]=s.split("-");d=Number.parseInt(c,10),u=Number.parseInt(l,10)}else d=Number.parseInt(s,10),u=d;if(Number.isNaN(d)||Number.isNaN(u))throw new Error(`Invalid cron field: ${t}`);if(d<e||u>n)throw new Error(`Cron field out of range: ${t} (${e}-${n})`);if(d>u)throw new Error(`Invalid cron range: ${d}-${u} in ${t}`);for(let c=d;c<=u;c+=a)r.add(c)}return r}function Sr(t){let e=t.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:ut(e[0],0,59),hours:ut(e[1],0,23),daysOfMonth:ut(e[2],1,31),months:ut(e[3],1,12),daysOfWeek:ut(e[4],0,6)}}function Or(t,e){return t.minutes.has(e.getMinutes())&&t.hours.has(e.getHours())&&t.daysOfMonth.has(e.getDate())&&t.months.has(e.getMonth()+1)&&t.daysOfWeek.has(e.getDay())}var Nr=Z(()=>{"use strict"});function kr(t){return{describeKind:"producer",...t}}function Ar(t,e){let{signal:n,period:r,...o}=e??{};return Ve(s=>{let i=!1,a=0,d,u,c=()=>{i=!0,d!==void 0&&clearTimeout(d),u!==void 0&&clearInterval(u),n?.removeEventListener("abort",p)},l=()=>{i||(r!=null?(s.emit(a++),u=setInterval(()=>{i||s.emit(a++)},r)):(i=!0,n?.removeEventListener("abort",p),s.emit(a++),s.down([[$]])))},p=()=>{i||(c(),s.down([[D,n.reason]]))};if(n?.aborted){p();return}return d=setTimeout(l,t),n?.addEventListener("abort",p,{once:!0}),c},kr(o))}function Cr(t,e){let n=Sr(t),{tickMs:r,output:o,...s}=e??{},i=r??6e4,a=o==="date";return Ve(d=>{let u=-1,c=()=>{let p=new Date,h=p.getFullYear()*1e8+(p.getMonth()+1)*1e6+p.getDate()*1e4+p.getHours()*100+p.getMinutes();h!==u&&Or(n,p)&&(u=h,d.emit(a?p:se()))};c();let l=setInterval(c,i);return()=>clearInterval(l)},{...kr(s),name:s.name??`cron:${t}`})}function he(t){return t.subscribe(()=>{})}var Nt=Z(()=>{"use strict";ot();K();fe();Nr()});var Dt,$r=Z(()=>{"use strict";Dt=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var ci={};ce(ci,{jotai:()=>cn,nanostores:()=>fn,nestjs:()=>Nn,react:()=>kn,signals:()=>Mn,solid:()=>Dn,svelte:()=>Gn,vue:()=>In,zustand:()=>Ln});module.exports=So(ci);var cn={};ce(cn,{atom:()=>Vo});K();fe();function Vo(t,e,n){if(typeof t=="function"){let r=t;return typeof e=="function"?cr(r,e,n):cr(r,void 0,e)}return qo(t,e)}function it(t){let e=t.cache,n;if(t.subscribe(o=>{for(let[s,i]of o)s===A&&(e=i),s===D&&(n=i)})(),n)throw n;return e}function qo(t,e){let n=q(t,{...e,resubscribable:!0,resetOnTeardown:!0});return{get:()=>n.status==="sentinel"?it(n):n.cache,set:r=>n.emit(r),update:r=>{let o=n.status==="sentinel"?it(n):n.cache;n.emit(r(o))},subscribe:r=>{let o=!0;return n.subscribe(s=>{for(let[i,a]of s)if(i===A){if(o){o=!1;continue}r(a)}})},meta:n.meta,_node:n}}function cr(t,e,n){let r=st(s=>t(i=>{let a=i._node;return a.status==="sentinel"&&it(a),s(a)}),{...n,resubscribable:!0,resetOnTeardown:!0}),o={get:()=>r.status==="sentinel"?it(r):r.cache,subscribe:s=>{let i=!0;return r.subscribe(a=>{for(let[d,u]of a)if(d===A){if(i){i=!1;continue}s(u)}})},meta:r.meta,_node:r};if(e){let s=d=>d.get(),i=(d,u)=>d.set(u),a=o;return a.set=d=>e(s,i,d),a.update=d=>{let u=r.status==="sentinel"?it(r):r.cache;return e(s,i,d(u))},a}return o}var fn={};ce(fn,{action:()=>Uo,atom:()=>jo,computed:()=>zo,getValue:()=>Wo,map:()=>Bo,onMount:()=>Ko,onStart:()=>pr,onStop:()=>hr});Ne();K();fe();var St=new WeakMap,Ot=new WeakMap;function Rt(t,e){let n=e.get(t);if(n)for(let r of n)r()}function ln(t,e={}){let n=0;return{...e,get:()=>fr(t),subscribe:o=>{n===0&&Rt(t,St),n++;let s=t.subscribe(i=>{for(let[a,d]of i)a===A&&o(d)});return()=>{s(),n--,n===0&&Rt(t,Ot)}},listen:o=>{n===0&&Rt(t,St),n++;let s=!0,i=t.subscribe(a=>{for(let[d,u]of a)if(d===A){if(s){s=!1;continue}o(u)}});return()=>{i(),n--,n===0&&Rt(t,Ot)}},_node:t}}function lr(t){let e=t.cache,n;if(t.subscribe(o=>{for(let[s,i]of o)s===A&&(e=i),s===D&&(n=i)})(),n)throw n;return e}function fr(t){return t.status==="sentinel"?lr(t):t.cache}function jo(t){let e=q(t,{resubscribable:!0,resetOnTeardown:!0});return ln(e,{set:n=>e.emit(n)})}function zo(t,e){let n=Array.isArray(t)?t:[t],r=n.map(s=>s._node),o=dn(r,s=>{let i=n.map(a=>{let d=a._node;return d.status==="sentinel"&&lr(d),s(d)});return e(...i)},{resubscribable:!0,resetOnTeardown:!0,equals:Object.is});return ln(o)}function Bo(t){let e=q(t,{resubscribable:!0,resetOnTeardown:!0,equals:()=>!1});return ln(e,{set:n=>e.emit(n),setKey:(n,r)=>{let o=fr(e);e.emit({...o,[n]:r})}})}function Wo(t){return t.get()}function pr(t,e){let n=t._node,r=St.get(n);r||(r=new Set,St.set(n,r)),r.add(e)}function hr(t,e){let n=t._node,r=Ot.get(n);r||(r=new Set,Ot.set(n,r)),r.add(e)}function Ko(t,e){pr(t,()=>{let n=e();typeof n=="function"&&hr(t,n)})}function Uo(t,e,n){return(...r)=>{let o;return le(()=>{o=n(...r)}),o}}var Nn={};ce(Nn,{ACTOR_KEY:()=>Ct,COMMAND_HANDLERS:()=>Be,CQRS_EVENT_HANDLERS:()=>We,CRON_HANDLERS:()=>ze,CommandHandler:()=>xr,EVENT_HANDLERS:()=>qe,EventHandler:()=>wr,GRAPHREFLY_REQUEST_GRAPH:()=>Me,GRAPHREFLY_ROOT_GRAPH:()=>ae,GraphCron:()=>Tr,GraphInterval:()=>_r,GraphReflyEventExplorer:()=>De,GraphReflyGuard:()=>Pr,GraphReflyGuardImpl:()=>dt,GraphReflyModule:()=>Kt,INTERVAL_HANDLERS:()=>je,InjectCqrsGraph:()=>yr,InjectGraph:()=>mr,InjectNode:()=>br,ObserveGateway:()=>At,OnGraphEvent:()=>vr,QUERY_HANDLERS:()=>Ke,QueryHandler:()=>Er,SAGA_HANDLERS:()=>Ue,SagaHandler:()=>Rr,fromHeader:()=>Ir,fromJwtPayload:()=>mn,getActor:()=>Lr,getGraphToken:()=>Q,getNodeToken:()=>de,observeSSE:()=>Dr,observeSubscription:()=>Gr,toObservable:()=>gr});var pn=require("rxjs");K();function gr(t,e){return e?.raw?new pn.Observable(n=>t.subscribe(o=>{if(!n.closed){n.next(o);for(let s of o){if(s[0]===D){n.error(s[1]);return}if(s[0]===$){n.complete();return}}}})):new pn.Observable(n=>t.subscribe(o=>{for(let s of o){if(n.closed)return;if(s[0]===A)n.next(s[1]);else if(s[0]===D){n.error(s[1]);return}else if(s[0]===$){n.complete();return}}}))}var at=require("@nestjs/common");var ae=Symbol.for("graphrefly:root-graph");var Me=Symbol.for("graphrefly:request-graph");function Q(t){return Symbol.for(`graphrefly:graph:${t}`)}function de(t){return Symbol.for(`graphrefly:node:${t}`)}var qe=new Map,je=new Map,ze=new Map,Be=new Map,We=new Map,Ke=new Map,Ue=new Map;function mr(t){return t==="request"?(0,at.Inject)(Me):(0,at.Inject)(t?Q(t):ae)}function yr(t){return(0,at.Inject)(Q(t))}function br(t){return(0,at.Inject)(de(t))}function vr(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=qe.get(o)??[];s.push({nodeName:t,methodKey:r}),qe.set(o,s)})}}function _r(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=je.get(o)??[];s.push({ms:t,methodKey:r}),je.set(o,s)})}}function Tr(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=ze.get(o)??[];s.push({expr:t,methodKey:r}),ze.set(o,s)})}}function xr(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=Be.get(s)??[];i.push({cqrsName:t,commandName:e,methodKey:o}),Be.set(s,i)})}}function wr(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=We.get(s)??[];i.push({cqrsName:t,eventName:e,methodKey:o}),We.set(s,i)})}}function Er(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=Ke.get(s)??[];i.push({cqrsName:t,projectionName:e,methodKey:o}),Ke.set(s,i)})}}function Rr(t,e,n){return(r,o)=>{let s=o.name;o.addInitializer(function(){let i=this.constructor,a=Ue.get(i)??[];a.push({cqrsName:t,eventNames:n,sagaName:e,methodKey:s}),Ue.set(i,a)})}}K();Nt();var Mr=0,De=class{constructor(e,n){this.graph=e;this.moduleRef=n}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,n]of qe){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireEventHandler(r,o)}}wireEventHandler(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),i=this.observeNode(n.nodeName).subscribe(a=>{for(let d of a)d[0]===A&&o(d[1])});this.disposers.push(i)}wireIntervals(){for(let[e,n]of je){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireIntervalHandler(r,e,o)}}wireIntervalHandler(e,n,r){let o=e[r.methodKey];if(typeof o!="function")return;let s=o.bind(e),a=`__schedule__.${n.name??"anonymous"}.${String(r.methodKey)}.${Mr++}`,d=Ar(r.ms,{period:r.ms,name:a});this.graph.add(d),this.scheduleNodeNames.push(a);let c=this.observeNode(a).subscribe(l=>{for(let p of l)p[0]===A&&s(p[1])});this.disposers.push(c)}wireCrons(){for(let[e,n]of ze){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCronHandler(r,e,o)}}wireCronHandler(e,n,r){let o=e[r.methodKey];if(typeof o!="function")return;let s=o.bind(e),a=`__schedule__.${n.name??"anonymous"}.${String(r.methodKey)}.${Mr++}`,d=Cr(r.expr,{name:a});this.graph.add(d),this.scheduleNodeNames.push(a);let c=this.observeNode(a).subscribe(l=>{for(let p of l)p[0]===A&&s(p[1])});this.disposers.push(c)}wireCqrsCommands(){for(let[e,n]of Be){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsCommand(r,o)}}wireCqrsCommand(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);s&&s.command(n.commandName,o)}wireCqrsEvents(){for(let[e,n]of We){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsEventHandler(r,o)}}wireCqrsEventHandler(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);if(!s)return;s.event(n.eventName);let a=s.resolve(n.eventName).cache,d=a&&a.length>0?a[a.length-1].seq:0,c=this.observeNodeOn(s,n.eventName).subscribe(l=>{for(let p of l)if(p[0]===A){let h=p[1];for(let f of h)f.seq>d&&(o(f),d=f.seq)}});this.disposers.push(c)}wireCqrsQueries(){for(let[e,n]of Ke){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsQuery(r,o)}}wireCqrsQuery(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);if(!s)return;let a=this.observeNodeOn(s,n.projectionName).subscribe(d=>{for(let u of d)u[0]===A&&o(u[1])});this.disposers.push(a)}wireCqrsSagas(){for(let[e,n]of Ue){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsSaga(r,o)}}wireCqrsSaga(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);s&&s.saga(n.sagaName,n.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,n){return e.observe(n)}resolveCqrsGraph(e){try{return this.moduleRef.get(Q(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}}};K();K();var Yo=0;function kt(t,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let n=Symbol(`bp-${++Yo}`),r=0,o=!1;return{onEnqueue(){return r+=1,!o&&r>=e.highWaterMark?(o=!0,t([[ee,n]]),!0):!1},onDequeue(){return r>0&&(r-=1),o&&r<=e.lowWaterMark?(o=!1,t([[oe,n]]),!0):!1},get pending(){return r},get paused(){return o},dispose(){o&&(o=!1,t([[oe,n]]))}}}function Dr(t,e,n){let{actor:r,serialize:o=Jo,keepAliveMs:s,signal:i}=n??{},a=new TextEncoder,d,u=n?.highWaterMark!=null,c,l,p=[],h=!1;return new ReadableStream({start(f){let m,b=()=>{},T=()=>{if(!h){h=!0,m!==void 0&&clearInterval(m),i?.removeEventListener("abort",x),b(),c?.dispose(),l?.(),l=void 0;for(let y of p)f.enqueue(y.frame);p.length=0,f.close()}};d=T;let x=()=>T(),v=t.observe(e,{actor:r});u&&(c=kt(y=>v.up(y),{highWaterMark:n.highWaterMark,lowWaterMark:n.lowWaterMark??Math.floor(n.highWaterMark/2)})),b=v.subscribe(y=>{for(let R of y){if(h)return;let N=R[0];if(N===A){let g=a.encode(hn("data",o(R[1])));u?(p.push({frame:g,counted:!0}),c.onEnqueue(),l?.(),l=void 0):f.enqueue(g)}else if(N===D){let g=a.encode(hn("error",o(R[1])));u?(p.push({frame:g,counted:!1}),l?.(),l=void 0):f.enqueue(g),T();return}else if(N===$||N===W){if(N===$){let g=a.encode(hn("complete"));u?(p.push({frame:g,counted:!1}),l?.(),l=void 0):f.enqueue(g)}T();return}}}),s!==void 0&&s>0&&(m=setInterval(()=>{h||(u?(p.push({frame:a.encode(`: keepalive
2
2
 
3
- `),counted:!1}),f?.(),f=void 0):d.enqueue(a.encode(`: keepalive
3
+ `),counted:!1}),l?.(),l=void 0):f.enqueue(a.encode(`: keepalive
4
4
 
5
- `)))},s)),i?.aborted?_():i?.addEventListener("abort",_,{once:!0})},pull(d){if(u&&!h){if(p.length>0){let g=p.shift();d.enqueue(g.frame),g.counted&&l.onDequeue();return}return new Promise(g=>{f=g})}},cancel(){try{c?.()}catch{}}})}function _r(t,e,n){let{actor:r,filter:o}=n??{},s=[],i=[],a=!1,c=t.observe(e,{actor:r}),u=n?.highWaterMark!=null?mt(d=>c.up(d),{highWaterMark:n.highWaterMark,lowWaterMark:n.lowWaterMark??Math.floor(n.highWaterMark/2)}):void 0,l=()=>{a||(a=!0,u?.dispose(),p())},f=d=>{if(!a)if(i.length>0){let g=i.shift();d.done&&d.error?g.reject(d.error):d.done?g.resolve({done:!0,value:void 0}):g.resolve({done:!1,value:d.value})}else s.push(d),d.done||u?.onEnqueue()},p=c.subscribe(d=>{for(let g of d){let m=g[0];if(m===E){let v=g[1];if(o&&!o(v))continue;f({done:!1,value:v})}else if(m===C){let v=g[1]instanceof Error?g[1]:new Error(String(g[1]));f({done:!0,error:v}),l();return}else if(m===P||m===q){f({done:!0}),l();return}}});return{next(){if(s.length>0){let d=s.shift();return d.done||u?.onDequeue(),d.done&&d.error?Promise.reject(d.error):Promise.resolve(d.done?{done:!0,value:void 0}:{done:!1,value:d.value})}return a?Promise.resolve({done:!0,value:void 0}):new Promise((d,g)=>{i.push({resolve:d,reject:g})})},return(){l();for(let d of i)d.resolve({done:!0,value:void 0});return i.length=0,Promise.resolve({done:!0,value:void 0})},throw(d){return l(),Promise.reject(d)},[Symbol.asyncIterator](){return this}}}var bt=class{constructor(e,n){this.graph=e;this.extractActor=n?.extractActor??(()=>{}),this.parse=n?.parse??Ho,this.highWaterMark=n?.highWaterMark,this.lowWaterMark=n?.lowWaterMark}clients=new Map;extractActor;parse;highWaterMark;lowWaterMark;handleConnection(e){this.clients.has(e)||this.clients.set(e,new Map)}handleDisconnect(e){let n=this.clients.get(e);if(n){for(let r of n.values())r.wm?.dispose(),r.unsub();this.clients.delete(e)}}handleMessage(e,n,r){let o=r??Fo.bind(null,e),s;try{s=typeof n=="string"?this.parse(n):n}catch{o({type:"err",message:"invalid command"});return}s.type==="subscribe"?this.subscribe(e,s.path,o):s.type==="unsubscribe"?this.unsubscribe(e,s.path,o):s.type==="ack"?this.ack(e,s.path,s.count??1):o({type:"err",message:`unknown command type: ${s.type}`})}subscriptionCount(e){return this.clients.get(e)?.size??0}destroy(){for(let[e]of this.clients)this.handleDisconnect(e)}subscribe(e,n,r){let o=this.clients.get(e);if(o||(o=new Map,this.clients.set(e,o)),o.has(n)){r({type:"subscribed",path:n});return}let s=this.extractActor(e),i;try{i=this.graph.observe(n,{actor:s})}catch(l){let f=l instanceof Error?l.message:String(l);r({type:"err",message:f});return}let a=this.highWaterMark!=null?mt(l=>i.up(l),{highWaterMark:this.highWaterMark,lowWaterMark:this.lowWaterMark??Math.floor(this.highWaterMark/2)}):void 0,c=()=>{a?.dispose(),u(),o.delete(n)},u=i.subscribe(l=>{for(let f of l){let p=f[0];if(p===E)a?.onEnqueue(),tn(r,{type:"data",path:n,value:f[1]});else if(p===C){let h=f[1]instanceof Error?f[1].message:String(f[1]);tn(r,{type:"error",path:n,error:h}),c();return}else if(p===P||p===q){tn(r,{type:"complete",path:n}),c();return}}});o.set(n,{unsub:u,wm:a}),r({type:"subscribed",path:n})}unsubscribe(e,n,r){let o=this.clients.get(e),s=o?.get(n);s&&(s.wm?.dispose(),s.unsub(),o.delete(n)),r({type:"unsubscribed",path:n})}ack(e,n,r){let o=this.clients.get(e)?.get(n);if(!o?.wm)return;let s=Math.min(Math.max(0,Math.floor(r)),1024);for(let i=0;i<s;i++)o.wm.onDequeue()}};function $o(t){if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function en(t,e){let n=`event: ${t}
5
+ `)))},s)),i?.aborted?x():i?.addEventListener("abort",x,{once:!0})},pull(f){if(u&&!h){if(p.length>0){let m=p.shift();f.enqueue(m.frame),m.counted&&c.onDequeue();return}return new Promise(m=>{l=m})}},cancel(){try{d?.()}catch{}}})}function Gr(t,e,n){let{actor:r,filter:o}=n??{},s=[],i=[],a=!1,d=t.observe(e,{actor:r}),u=n?.highWaterMark!=null?kt(f=>d.up(f),{highWaterMark:n.highWaterMark,lowWaterMark:n.lowWaterMark??Math.floor(n.highWaterMark/2)}):void 0,c=()=>{a||(a=!0,u?.dispose(),p())},l=f=>{if(!a)if(i.length>0){let m=i.shift();f.done&&f.error?m.reject(f.error):f.done?m.resolve({done:!0,value:void 0}):m.resolve({done:!1,value:f.value})}else s.push(f),f.done||u?.onEnqueue()},p=d.subscribe(f=>{for(let m of f){let b=m[0];if(b===A){let T=m[1];if(o&&!o(T))continue;l({done:!1,value:T})}else if(b===D){let T=m[1]instanceof Error?m[1]:new Error(String(m[1]));l({done:!0,error:T}),c();return}else if(b===$||b===W){l({done:!0}),c();return}}});return{next(){if(s.length>0){let f=s.shift();return f.done||u?.onDequeue(),f.done&&f.error?Promise.reject(f.error):Promise.resolve(f.done?{done:!0,value:void 0}:{done:!1,value:f.value})}return a?Promise.resolve({done:!0,value:void 0}):new Promise((f,m)=>{i.push({resolve:f,reject:m})})},return(){c();for(let f of i)f.resolve({done:!0,value:void 0});return i.length=0,Promise.resolve({done:!0,value:void 0})},throw(f){return c(),Promise.reject(f)},[Symbol.asyncIterator](){return this}}}var At=class{constructor(e,n){this.graph=e;this.extractActor=n?.extractActor??(()=>{}),this.parse=n?.parse??Qo,this.highWaterMark=n?.highWaterMark,this.lowWaterMark=n?.lowWaterMark}clients=new Map;extractActor;parse;highWaterMark;lowWaterMark;handleConnection(e){this.clients.has(e)||this.clients.set(e,new Map)}handleDisconnect(e){let n=this.clients.get(e);if(n){for(let r of n.values())r.wm?.dispose(),r.unsub();this.clients.delete(e)}}handleMessage(e,n,r){let o=r??Xo.bind(null,e),s;try{s=typeof n=="string"?this.parse(n):n}catch{o({type:"err",message:"invalid command"});return}s.type==="subscribe"?this.subscribe(e,s.path,o):s.type==="unsubscribe"?this.unsubscribe(e,s.path,o):s.type==="ack"?this.ack(e,s.path,s.count??1):o({type:"err",message:`unknown command type: ${s.type}`})}subscriptionCount(e){return this.clients.get(e)?.size??0}destroy(){for(let[e]of this.clients)this.handleDisconnect(e)}subscribe(e,n,r){let o=this.clients.get(e);if(o||(o=new Map,this.clients.set(e,o)),o.has(n)){r({type:"subscribed",path:n});return}let s=this.extractActor(e),i;try{i=this.graph.observe(n,{actor:s})}catch(c){let l=c instanceof Error?c.message:String(c);r({type:"err",message:l});return}let a=this.highWaterMark!=null?kt(c=>i.up(c),{highWaterMark:this.highWaterMark,lowWaterMark:this.lowWaterMark??Math.floor(this.highWaterMark/2)}):void 0,d=()=>{a?.dispose(),u(),o.delete(n)},u=i.subscribe(c=>{for(let l of c){let p=l[0];if(p===A)a?.onEnqueue(),gn(r,{type:"data",path:n,value:l[1]});else if(p===D){let h=l[1]instanceof Error?l[1].message:String(l[1]);gn(r,{type:"error",path:n,error:h}),d();return}else if(p===$||p===W){gn(r,{type:"complete",path:n}),d();return}}});o.set(n,{unsub:u,wm:a}),r({type:"subscribed",path:n})}unsubscribe(e,n,r){let o=this.clients.get(e),s=o?.get(n);s&&(s.wm?.dispose(),s.unsub(),o.delete(n)),r({type:"unsubscribed",path:n})}ack(e,n,r){let o=this.clients.get(e)?.get(n);if(!o?.wm)return;let s=Math.min(Math.max(0,Math.floor(r)),1024);for(let i=0;i<s;i++)o.wm.onDequeue()}};function Jo(t){if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function hn(t,e){let n=`event: ${t}
6
6
  `;if(e!==void 0)for(let r of e.split(`
7
7
  `))n+=`data: ${r}
8
8
  `;return n+=`
9
- `,n}function Ho(t){return JSON.parse(t)}function Fo(t,e){try{t.send(JSON.stringify(e))}catch{}}function tn(t,e){try{t(e)}catch{}}Ue();var yt="graphReflyActor";function nn(t){return e=>{let r=e.switchToHttp().getRequest()?.user;if(r!=null)return t?t(r):r}}function xr(t="x-graphrefly-actor"){return e=>{let r=e.switchToHttp().getRequest()?.headers?.[t.toLowerCase()];if(!(typeof r!="string"||r.length===0))try{return JSON.parse(r)}catch{return}}}function wr(t){let e=t?.[yt];return e!=null?ve(e):pe}var rt=class{constructor(e){this.extractor=e}canActivate(e){let n=ve(this.extractor(e)),r=e.switchToHttp().getRequest();return r!=null&&(r[yt]=n),!0}};function Tr(t){return new rt(t??nn())}var st=require("@nestjs/common"),no=require("@nestjs/core");Ue();we();Xe();De();W();De();Ge();function vt(t,e){if(e!=null&&e.length>0)return new Set(e);switch(t){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;default:return new Set(["type","deps"])}}function jo(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function Vo(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function rn(t,e){let n=e==null,r=!n&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,o=n||e.has("meta")||r!=null&&r.length>0,s="state",i=[];t instanceof $&&(s=jo(t),i=t._deps.map(u=>u.node.name??""));let a={type:s,deps:i};(n||e.has("status"))&&(a.status=t.status);let c=t instanceof $?t._guard:void 0;if(o){let u={...Vo(t)};if(c!=null&&u.access===void 0&&(u.access=qt(c)),r!=null&&r.length>0&&!e.has("meta")){let l={};for(let f of r)f in u&&(l[f]=u[f]);a.meta=l}else a.meta=u}if(t.name!=null&&(a.name=t.name),n||e.has("value")){t.status==="sentinel"&&(a.sentinel=!0);try{a.value=t.cache}catch{}}if((n||e.has("v"))&&t.v!=null){let u={id:t.v.id,version:t.v.version};"cid"in t.v&&(u.cid=t.v.cid,u.prev=t.v.prev),a.v=u}return(n||e.has("guard"))&&c!=null&&(a.guard=qt(c)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}Ge();de();gt();Er();var ot=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let n=(this.head+this._size)%this.capacity;this.buf[n]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let n=e<0?this._size+e:e;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this.buf[(this.head+n)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};Vt();function on(t){return t>=768&&t<=879||t>=1155&&t<=1161||t>=1425&&t<=1469||t>=1552&&t<=1562||t>=1611&&t<=1631||t>=1648&&t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t>=1767&&t<=1768||t>=1770&&t<=1773||t>=1840&&t<=1866||t>=1958&&t<=1968||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2641||t>=2672&&t<=2673||t>=2677&&t===2677||t>=3633&&t===3633||t>=3636&&t<=3642||t>=3655&&t<=3662||t>=3761&&t===3761||t>=3764&&t<=3772||t>=3784&&t<=3790||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65024&&t<=65039||t>=65056&&t<=65071||t===8205?0:t>=4352&&t<=4447||t>=8986&&t<=8987||t>=9001&&t<=9002||t>=9193&&t<=9203||t>=9208&&t<=9210||t>=9725&&t<=9726||t>=9748&&t<=9749||t>=9800&&t<=9811||t===9855||t===9875||t===9889||t>=9898&&t<=9899||t>=9917&&t<=9918||t>=9924&&t<=9925||t===9934||t===9940||t===9962||t>=9970&&t<=9971||t===9973||t===9978||t===9981||t===9986||t===9989||t>=9992&&t<=9997||t===9999||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t>=10548&&t<=10549||t>=11013&&t<=11015||t>=11035&&t<=11036||t===11088||t===11093||t>=11904&&t<=12350||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12784&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=19968&&t<=40959||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65131||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126980&&t===126980||t===127183||t>=127344&&t<=127345||t===127358||t===127359||t===127374||t>=127377&&t<=127386||t>=127456&&t<=127487||t>=127488&&t<=127490||t===127514||t===127535||t>=127538&&t<=127546||t>=127568&&t<=127569||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=129792&&t<=130047||t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}function xt(t){let e=0;for(let n of t)e+=on(n.codePointAt(0));return e}function Rr(t,e){if(e<=0)return"";let n=0,r="";for(let o of t){let s=on(o.codePointAt(0));if(n+s>e){if(e<=1)return"\u2026";for(;n+1>e&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=on(i.codePointAt(0))}return`${r}\u2026`}r+=o,n+=s}return r}var qo={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"},Wo={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function kr(t,e){let n=e.charset==="ascii"?Wo:qo,r=t.width,o=t.height,s=Array.from({length:o},()=>Array.from({length:r},()=>" ")),i=Array.from({length:o},()=>Array.from({length:r},()=>"empty"));for(let a of t.edges)zo(s,i,n,a);for(let a of t.boxes)Bo(s,i,n,a,e.labelOf(a.id));return s.map(a=>Jo(a.join(""))).join(`
10
- `)}function Bo(t,e,n,r,o){let{x:s,y:i,w:a,h:c}=r;if(a<2||c<2){c>0&&Or(t,e,s,i,a,o);return}me(t,e,s,i,n.boxTL);for(let l=s+1;l<s+a-1;l+=1)me(t,e,l,i,n.boxH);me(t,e,s+a-1,i,n.boxTR);for(let l=i+1;l<i+c-1;l+=1){me(t,e,s,l,n.boxV);for(let f=s+1;f<s+a-1;f+=1)Ar(t,e,f,l," ","empty");me(t,e,s+a-1,l,n.boxV)}me(t,e,s,i+c-1,n.boxBL);for(let l=s+1;l<s+a-1;l+=1)me(t,e,l,i+c-1,n.boxH);me(t,e,s+a-1,i+c-1,n.boxBR);let u=i+Math.floor(c/2);Or(t,e,s+1,u,a-2,o)}function me(t,e,n,r,o){Ar(t,e,n,r,o,o===" "?"empty":o==="\u2500"||o==="-"?"boxH":o==="\u2502"||o==="|"?"boxV":"boxCorner")}function Ar(t,e,n,r,o,s){if(r<0||r>=t.length)return;let i=t[r];n<0||n>=i.length||(i[n]=o,e[r][n]=s)}function Or(t,e,n,r,o,s){if(r<0||r>=t.length)return;let i=n,a=o;for(let c of s){let u=xt(c);if(u!==0){if(a<u)break;i>=0&&i<t[r].length&&(t[r][i]=c,e[r][i]="label",u===2&&i+1<t[r].length&&(t[r][i+1]="",e[r][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<t[r].length&&(t[r][i]=" ",e[r][i]="empty"),i+=1,a-=1}function zo(t,e,n,r){let o=r.points;if(o.length<2)return;for(let c=0;c+1<o.length;c+=1)Ko(t,e,n,o[c],o[c+1]);for(let c=1;c+1<o.length;c+=1){let u=o[c-1],l=o[c],f=o[c+1],p=Uo(u,l,f,n);p&&Sr(t,e,l.x,l.y,p,"edgeCorner")}let s=o[o.length-1],i=o[o.length-2],a=Yo(i,s,n);a&&Sr(t,e,s.x,s.y,a,"arrow")}function Ko(t,e,n,r,o){if(!(r.x===o.x&&r.y===o.y)){if(r.y===o.y){let s=r.y,i=Math.min(r.x,o.x),a=Math.max(r.x,o.x);for(let c=i;c<=a;c+=1)Nr(t,e,c,s,n,"h")}else if(r.x===o.x){let s=r.x,i=Math.min(r.y,o.y),a=Math.max(r.y,o.y);for(let c=i;c<=a;c+=1)Nr(t,e,s,c,n,"v")}}}function Nr(t,e,n,r,o,s){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[n]=s==="h"?o.horizontal:o.vertical,e[r][n]=s==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&s==="v"){i[n]=o.cross,e[r][n]="edgeCorner";return}if(a==="edgeV"&&s==="h"){i[n]=o.cross,e[r][n]="edgeCorner";return}}}function Sr(t,e,n,r,o,s){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[n]=o,e[r][n]=s)}function Uo(t,e,n,r){let o=t.y===e.y,s=e.y===n.y;if(o===s)return;if(o){let c=t.x<e.x,u=n.y>e.y;return c&&u?r.cornerTR:c&&!u?r.cornerBR:!c&&u?r.cornerTL:r.cornerBL}let i=t.y<e.y,a=n.x>e.x;return i&&a?r.cornerBL:i&&!a?r.cornerBR:!i&&a?r.cornerTL:r.cornerTR}function Yo(t,e,n){if(e.x>t.x)return n.arrowRight;if(e.x<t.x)return n.arrowLeft;if(e.y>t.y)return n.arrowDown;if(e.y<t.y)return n.arrowUp}function Jo(t){let e=t.length;for(;e>0&&t.charCodeAt(e-1)===32;)e-=1;return t.slice(0,e)}function Dr(t){let e=Qo(t);Xo(e),Zo(e),es(e),ts(e,t);let n=os(e,t),{width:r,height:o}=is(e),s=[];for(let i of e.layers)for(let a of i)a.isVirtual||s.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:s,edges:n,width:r,height:o}}function Qo(t){let e=new Map;for(let o of t.nodes)e.set(o,{id:o,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:t.widthCells(o),h:t.heightCells(o),in:[],out:[]});let n=[],r=0;for(let o of t.edges){if(o.from===o.to)continue;let s=e.get(o.from),i=e.get(o.to);if(!s||!i)continue;let a={chainId:r++,chainFrom:o.from,chainTo:o.to,fromId:o.from,toId:o.to,hopIndex:0,chainLen:1};s.out.push(a),i.in.push(a),n.push(a)}return{nodes:e,layers:[],hops:n}}function Xo(t){let e=new Map;for(let s of t.nodes.values())e.set(s.id,s.in.length);let n=[];for(let s of t.nodes.values())(e.get(s.id)??0)===0&&(s.layer=0,n.push(s));let r=new Set,o=0;for(;o<n.length;){let s=n[o++];if(!r.has(s.id)){r.add(s.id);for(let i of s.out){let a=t.nodes.get(i.toId);a.layer=Math.max(a.layer,s.layer+1);let c=(e.get(a.id)??0)-1;e.set(a.id,c),c<=0&&n.push(a)}}}for(let s of t.nodes.values())s.layer<0&&(s.layer=0)}function Zo(t){let e=Math.max(0,...Array.from(t.nodes.values(),s=>s.layer)),n=Array.from({length:e+1},()=>[]);for(let s of t.nodes.values())n[s.layer].push(s);let r=[],o=0;for(let s of t.hops){let i=t.nodes.get(s.fromId),a=t.nodes.get(s.toId),c=a.layer-i.layer;if(c<=0){i.out=i.out.filter(f=>f!==s),a.in=a.in.filter(f=>f!==s);continue}if(c===1){s.hopIndex=0,s.chainLen=1,r.push(s);continue}i.out=i.out.filter(f=>f!==s),a.in=a.in.filter(f=>f!==s);let u=i;for(let f=1;f<c;f+=1){let p=`__virt_${o++}__`,h={id:p,isVirtual:!0,layer:i.layer+f,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};t.nodes.set(p,h),n[h.layer].push(h);let d={chainId:s.chainId,chainFrom:s.chainFrom,chainTo:s.chainTo,fromId:u.id,toId:p,hopIndex:f-1,chainLen:c};u.out.push(d),h.in.push(d),r.push(d),u=h}let l={chainId:s.chainId,chainFrom:s.chainFrom,chainTo:s.chainTo,fromId:u.id,toId:a.id,hopIndex:c-1,chainLen:c};u.out.push(l),a.in.push(l),r.push(l)}for(let s of n)for(let i=0;i<s.length;i+=1)s[i].order=i;t.layers=n,t.hops=r}function es(t){for(let n=0;n<4;n+=1){for(let r=1;r<t.layers.length;r+=1)Cr(t,t.layers[r],"in"),wt(t.layers[r]);for(let r=t.layers.length-2;r>=0;r-=1)Cr(t,t.layers[r],"out"),wt(t.layers[r])}for(let n=0;n<2;n+=1){let r=!1;for(let o=1;o<t.layers.length;o+=1){let s=t.layers[o];for(let i=0;i+1<s.length;i+=1){let a=Mr(t,s[i],s[i+1],"in");[s[i],s[i+1]]=[s[i+1],s[i]],wt(s),Mr(t,s[i],s[i+1],"in")<a?r=!0:([s[i],s[i+1]]=[s[i+1],s[i]],wt(s))}}if(!r)break}}function Cr(t,e,n){let r=new Map;for(let o of e){let s=n==="in"?o.in:o.out;if(s.length===0){r.set(o.id,o.order);continue}let i=0,a=0;for(let c of s){let u=t.nodes.get(n==="in"?c.fromId:c.toId);u&&(i+=u.order,a+=1)}r.set(o.id,a===0?o.order:i/a)}e.sort((o,s)=>{let i=r.get(o.id),a=r.get(s.id);return i!==a?i-a:o.order-s.order})}function wt(t){for(let e=0;e<t.length;e+=1)t[e].order=e}function Mr(t,e,n,r){let o=r==="in"?e.in:e.out,s=r==="in"?n.in:n.out,i=0;for(let a of o)for(let c of s){let u=t.nodes.get(r==="in"?a.fromId:a.toId)?.order??0,l=t.nodes.get(r==="in"?c.fromId:c.toId)?.order??0;(e.order<n.order&&u>l||e.order>n.order&&u<l)&&(i+=1)}return i}function ts(t,e){e.direction==="LR"?ns(t,e):rs(t,e)}function ns(t,e){let n=[],r=0;for(let o=0;o<t.layers.length;o+=1){n.push(r);let s=0;for(let i of t.layers[o])s=Math.max(s,i.w);r+=s+e.layerGap}for(let o=0;o<t.layers.length;o+=1)for(let s of t.layers[o])s.x=n[o];for(let o of t.layers){let s=0;for(let i of o)i.y=s,s+=i.h+e.nodeGap}Gr(t,e,"y")}function rs(t,e){let n=[],r=0;for(let o=0;o<t.layers.length;o+=1){n.push(r);let s=0;for(let i of t.layers[o])s=Math.max(s,i.h);r+=s+e.layerGap}for(let o=0;o<t.layers.length;o+=1)for(let s of t.layers[o])s.y=n[o];for(let o of t.layers){let s=0;for(let i of o)i.x=s,s+=i.w+e.nodeGap}Gr(t,e,"x")}function Gr(t,e,n){let r=s=>n==="y"?s.h:s.w,o=e.nodeGap;for(let s=0;s<2;s+=1){let i=s===0?t.layers.slice(1):t.layers.slice(0,-1).reverse();for(let a of i){let c=new Map;for(let l of a){let f=s===0?l.in:l.out;if(f.length===0)continue;let p=[];for(let d of f){let g=t.nodes.get(s===0?d.fromId:d.toId);if(!g)continue;let m=n==="y"?g.y:g.x;p.push(m+Math.floor(r(g)/2))}if(p.length===0)continue;p.sort((d,g)=>d-g);let h=p[Math.floor(p.length/2)];c.set(l.id,h-Math.floor(r(l)/2))}let u=0;for(let l of a){let f=c.get(l.id),p=n==="y"?l.y:l.x,d=Math.max(f??p,u);n==="y"?l.y=d:l.x=d,u=d+r(l)+o}}}}function os(t,e){let n=new Map;for(let u of t.hops){let l=n.get(u.chainId);l?l.push(u):n.set(u.chainId,[u])}for(let u of n.values())u.sort((l,f)=>l.hopIndex-f.hopIndex);let r=e.direction==="LR",o=u=>r?u.x:u.y,s=u=>r?u.w:u.h,i=u=>r?u.y+Math.floor(u.h/2):u.x+Math.floor(u.w/2),a=new Map;for(let u=0;u+1<t.layers.length;u+=1){let l=t.layers[u],f=t.layers[u+1],p=0;for(let R of l)p=Math.max(p,o(R)+s(R));let h=Number.POSITIVE_INFINITY;for(let R of f)h=Math.min(h,o(R));let d=Number.isFinite(h)?h-1:p,g=Math.max(1,d-p+1),m=[];for(let R of l)for(let N of R.out)m.push(N);m.sort((R,N)=>{let M=i(t.nodes.get(R.fromId)),S=i(t.nodes.get(N.fromId));if(M!==S)return M-S;let A=i(t.nodes.get(R.toId)),k=i(t.nodes.get(N.toId));return A-k});let v=[],_=new Map;for(let R of m){let N=i(t.nodes.get(R.fromId)),M=i(t.nodes.get(R.toId)),S=Math.min(N,M),A=Math.max(N,M),k=-1;for(let F=0;F<v.length;F+=1){let U=v[F],re=!0;for(let ye of U)if(ye.lo<=A&&S<=ye.hi){re=!1;break}if(re){U.push({lo:S,hi:A}),k=F;break}}k<0&&(v.push([{lo:S,hi:A}]),k=v.length-1),_.set(R,k)}let b=v.length,y=g>=Math.max(3,b+2),w=y?p+1:p,T=y?d-1:d,x=Math.max(1,T-w+1);for(let R of m){let N=_.get(R),M;if(b<=1)M=w+Math.floor(x/2);else{let S=(x-1)/(b-1);M=w+Math.floor(N*S)}a.set(R,Math.max(p,Math.min(d,M)))}}let c=[];for(let[,u]of n){let l=[];for(let p=0;p<u.length;p+=1){let h=u[p],d=t.nodes.get(h.fromId),g=t.nodes.get(h.toId),m=a.get(h),v=d.isVirtual?o(d):o(d)+s(d),_=g.isVirtual?o(g):o(g)-1,b=i(d),y=i(g);p===0&&Tt(l,r,v,b),b!==y&&(Tt(l,r,m,b),Tt(l,r,m,y)),Tt(l,r,_,y)}let f=u[0];c.push({from:f.chainFrom,to:f.chainTo,points:ss(l)})}return c}function Tt(t,e,n,r){t.push(e?{x:n,y:r}:{x:r,y:n})}function ss(t){let e=[];for(let n of t){let r=e[e.length-1];(!r||r.x!==n.x||r.y!==n.y)&&e.push(n)}return e}function is(t){let e=0,n=0;for(let r of t.layers)for(let o of r)e=Math.max(e,o.x+o.w),n=Math.max(n,o.y+o.h);return{width:e,height:n}}var as=24,us=4,cs=1,ds=3;function Ir(t,e){let n=ls(e.direction),r=Math.max(3,e.maxLabelWidth??as),o=e.asciiCharset??"unicode",s=Object.keys(t.nodes).sort(),i=new Set(s),a=t.edges.filter(h=>i.has(h.from)&&i.has(h.to)),c=new Map,u=new Map;for(let h of s){let d=Rr(h,r);c.set(h,d),u.set(h,xt(d)+4)}let l=Dr({nodes:s,edges:a,widthCells:h=>u.get(h)??3,heightCells:()=>ds,layerGap:us,nodeGap:cs,direction:n}),f=kr(l,{charset:o,labelOf:h=>c.get(h)??h}),p=e.logger;return p&&p(f),f}function ls(t){if(t===void 0||t==="LR")return"LR";if(t==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(t)}`)}function Lr(t,e,n,r={}){let o=e in t.nodes,s=n in t.nodes;if(!o)return Et(e,n,"no-such-from");if(!s)return Et(e,n,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===n){if(r.findCycle===!0){let u=fs(t,e,r);if(u!=null)return u}let c=Rt(e,t.nodes[e],0,r);return Ot(e,n,[c])}if(i===0)return Et(e,n,"no-path");let a=Pr(t,e,n,i);return a.found?Ot(e,n,$r(t,a.pathOrder,r)):Et(e,n,a.truncated?"max-depth-exceeded":"no-path")}function Pr(t,e,n,r){let o=new Map,s=[{path:n,depth:0}],i=new Set([n]),a=0,c=!1;for(;a<s.length;){let f=s[a++];if(f.path===e)break;if(r!=null&&f.depth>=r){let g=t.nodes[f.path];g?.deps&&g.deps.length>0&&(c=!0);continue}let p=t.nodes[f.path];if(p==null)continue;let h=p.deps??[],d=new Map;for(let g=0;g<h.length;g++){let m=h[g];if(!m)continue;let v=d.get(m);v==null&&(v=[],d.set(m,v)),v.push(g)}for(let[g,m]of d)i.has(g)||(i.add(g),o.set(g,{from:f.path,depIndices:m}),s.push({path:g,depth:f.depth+1}))}if(!o.has(e))return{found:!1,pathOrder:[],truncated:c};let u=[{path:e}],l=e;for(;l!==n;){let f=o.get(l);if(f==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=f.depIndices,u.push({path:f.from}),l=f.from}return{found:!0,pathOrder:u,truncated:!1}}function fs(t,e,n){let r=t.nodes[e];if(r==null)return null;let o=r.deps??[],s=[];for(let a=0;a<o.length;a++)o[a]===e&&s.push(a);if(s.length>0){let a=Rt(e,r,0,n);a.dep_index=s[0];let c=Rt(e,r,1,n);return Ot(e,e,[a,c])}let i=null;for(let a=0;a<o.length;a++){let c=o[a];if(!c||c===e)continue;let u=Pr(t,c,e,n.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:Ot(e,e,$r(t,i.pathOrder,n))}function $r(t,e,n){return e.map((r,o)=>{let s=t.nodes[r.path],i=Rt(r.path,s,o,n);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function Rt(t,e,n,r){let o={path:t,type:e.type,hop:n};e.status!==void 0&&(o.status=e.status),"value"in e&&(o.value=e.value),e.v!=null&&(o.v=e.v);let s=r.annotations?.get(t)??e.annotation;s!=null&&(o.annotation=s);let i=r.lastMutations?.get(t)??e.lastMutation;return i!=null&&(o.lastMutation=i),o}function Ot(t,e,n){return Hr(t,e,!0,"ok",n)}function Et(t,e,n){return Hr(t,e,!1,n,[])}function Hr(t,e,n,r,o){let s=ps(t,e,n,r,o);return{from:t,to:e,found:n,reason:r,steps:o,text:s,toJSON(){return{from:t,to:e,found:n,reason:r,steps:o}}}}function ps(t,e,n,r,o){if(!n)switch(r){case"no-such-from":return`explainPath: no node named "${t}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${t}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${t}" to "${e}"`}let s=[`Causal path: ${t} \u2192 ${e} (${o.length} step(s))`];for(let i of o){let c=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(s.push(c),"value"in i&&s.push(` value: ${hs(i.value)}`),i.annotation!=null&&s.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;s.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return s.join(`
11
- `)}function hs(t){if(t===void 0)return"<sentinel>";if(t===null)return"null";if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);try{let e=JSON.stringify(t);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(t)}}Ge();var j={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},gs=Symbol.for("sizeof");function Fr(t){let e=new WeakSet,n=new WeakSet,r=[t],o=0;for(;r.length>0;){let s=r.pop();o+=ms(s,e,n,r)}return o}function ms(t,e,n,r){if(t==null)return 0;switch(typeof t){case"number":return j.number;case"boolean":return j.boolean;case"string":return j.string+t.length*2;case"bigint":return j.bigint+bs(t);case"symbol":return j.symbol;case"function":return e.has(t)?0:(e.add(t),j.function);case"undefined":return 0}let s=t;if(e.has(s))return 0;e.add(s);let i=s[gs];if(typeof i=="function")try{let u=i.call(s);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(s instanceof Date)return j.date;if(s instanceof RegExp)return j.regexp+s.source.length*2;if(s instanceof Error){let u=s.message?s.message.length*2:0,l=s.stack?s.stack.length*2:0;return j.error+u+l}if(typeof URL<"u"&&s instanceof URL)return j.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return j.promise;if(s instanceof WeakMap)return j.weakmap;if(s instanceof WeakSet)return j.weakset;if(s instanceof Map){let u=j.map;for(let[l,f]of s)u+=j.mapEntry,r.push(l),r.push(f);return u}if(s instanceof Set){let u=j.set;for(let l of s)u+=j.setEntry,r.push(l);return u}if(Array.isArray(s)){let u=j.array+s.length*8;for(let l of s)r.push(l);return u}if(s instanceof ArrayBuffer)return n.has(s)?0:(n.add(s),s.byteLength);if(ArrayBuffer.isView(s)){let u=s;return n.has(u.buffer)?48:(n.add(u.buffer),u.buffer.byteLength+48)}let a=j.object,c=Object.keys(s);for(let u of c){a+=j.string+u.length*2;try{r.push(s[u])}catch{}}return a}function bs(t){let e=t<0n?-t:t;if(e===0n)return 0;let n=e.toString(2).length;return Math.ceil(n/32)*8}function jr(t,e){let n=e?.topN??10,r=t.describe({detail:"standard"}),o=[],s=t._collectObserveTargets;typeof s=="function"&&s.call(t,"",o);let i=new Map;for(let[p,h]of o)i.set(p,h);let a=[];for(let[p,h]of Object.entries(r.nodes)){let d=i.get(p),g=d instanceof $?d:null,m=g?Fr(g.cache):0,v=g?g._sinkCount:0,_=h.deps?.length??0,b=h.type==="effect"&&v===0,y=v===0?h.type==="effect"?"orphan-effect":h.type==="derived"?"idle-derived":h.type==="producer"?"idle-producer":null:null;a.push({path:p,type:h.type,status:h.status??"unknown",valueSizeBytes:m,subscriberCount:v,depCount:_,isOrphanEffect:b,orphanKind:y})}let c=a.reduce((p,h)=>p+h.valueSizeBytes,0),u=(p,h)=>[...a].sort(h??((d,g)=>g[p]-d[p])).slice(0,n),l=a.filter(p=>p.orphanKind!=null),f=a.filter(p=>p.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:c,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:l,orphanEffects:f}}var L="::",te="__meta__",Ne=1;function Vr(t,e){let n=Math.max(16,t.size*4),r=0;for(;t.size>0;){if(r++>=n){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${n}); ${t.size} disposer(s) discarded`),t.clear();return}let o=t.values().next();if(o.done)return;let s=o.value;t.delete(s);try{s()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function ys(t){let e=[];for(let n of Object.keys(t).sort()){let r=t[n].v;r!=null&&e.push(`${n} ${r.id} ${r.version}`)}return e.join(`
12
- `)}function qr(t){if(t.version!==Ne)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${Ne})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in t))throw new Error(`snapshot missing required key "${e}"`);if(typeof t.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof t.nodes!="object"||t.nodes===null||Array.isArray(t.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(t.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(t.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function vs(t,e){let n=new WeakMap,r=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=n.get(o);if(i==null&&(i=new WeakSet,n.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,c=s.constructor;if(a!==c)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let p=s;if(o.length!==p.length)return!1;for(let h=0;h<o.length;h++)if(!r(o[h],p[h]))return!1;return!0}if(o instanceof Map){let p=s;if(o.size!==p.size)return!1;for(let[h,d]of o)if(!p.has(h)||!r(d,p.get(h)))return!1;return!0}if(o instanceof Set){let p=s;if(o.size!==p.size)return!1;for(let h of o){let d=!1;for(let g of p)if(r(h,g)){d=!0;break}if(!d)return!1}return!0}if(ArrayBuffer.isView(o)){let p=o,h=s;if(p.length!==h.length)return!1;for(let d=0;d<p.length;d++)if(p[d]!==h[d])return!1;return!0}let u=Object.keys(o),l=Object.keys(s);if(u.length!==l.length)return!1;let f=new Set(l);for(let p of u)if(!f.has(p)||!r(o[p],s[p]))return!1;return!0};return r(t,e)}function an(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(an);let e=t,n=Object.keys(e).sort(),r={};for(let o of n)r[o]=an(e[o]);return r}function _s(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function xs(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function ws(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function Br(t){let e=new Set,n=[];function r(o,s){let i=`${o}\0${s}`;e.has(i)||(e.add(i),n.push([o,s]))}for(let[o,s]of Object.entries(t.nodes)){let i=s.deps;if(i)for(let a of i)r(a,o)}for(let o of t.edges)r(o.from,o.to);return n}function zr(t){if(t===void 0)return"LR";if(t==="TD"||t==="LR"||t==="BT"||t==="RL")return t;throw new Error(`invalid diagram direction ${String(t)}; expected one of: TD, LR, BT, RL`)}function Ts(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,{expand:o,...s}=t,i={...s,edges:n?t.edges:[],subgraphs:r?t.subgraphs:[]},a=JSON.stringify(an(i),null,e.indent??2);return e.logger?.(a),a}function Es(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,o=[];o.push(`Graph ${t.name}`),o.push("Nodes:");for(let i of Object.keys(t.nodes).sort()){let a=t.nodes[i];o.push(`- ${i} (${a.type}/${a.status}): ${St(a.value)}`)}if(n){o.push("Edges:");for(let i of t.edges)o.push(`- ${i.from} -> ${i.to}`)}if(r){o.push("Subgraphs:");for(let i of t.subgraphs)o.push(`- ${i}`)}let s=o.join(`
13
- `);return e.logger?.(s),s}function Kr(t,e){let n=zr(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`flowchart ${n}`];for(let i of r){let a=o.get(i);s.push(` ${a}["${_s(i)}"]`)}for(let[i,a]of Br(t)){let c=o.get(i),u=o.get(a);!c||!u||s.push(` ${c} --> ${u}`)}return s.join(`
14
- `)}function Rs(t,e){let n=Kr(t,e);return Ur(n)}function Ur(t,e){let n=e?.theme??"default",r=e?.autoSync??!0,s=JSON.stringify({code:t,mermaid:{theme:n},autoSync:r}),i=new TextEncoder().encode(s),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function Os(t,e){let n=zr(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`direction: ${ws(n)}`];for(let i of r){let a=o.get(i);s.push(`${a}: "${xs(i)}"`)}for(let[i,a]of Br(t)){let c=o.get(i),u=o.get(a);!c||!u||s.push(`${c} -> ${u}`)}return s.join(`
15
- `)}function Ns(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Nt(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let o=t.indexOf("]",n+1);if(o<=n+1){e+="\\[";continue}let s=t.slice(n+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,n=o;continue}e+=Ns(r)}return e+="$",new RegExp(e)}var Ss={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"},ks={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function St(t){if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||t==null)return String(t);try{return JSON.stringify(t)}catch{return"[unserializable]"}}function As(t){return t==="none"?ks:t==="ansi"||t==null?Ss:{data:t.data??"",dirty:t.dirty??"",resolved:t.resolved??"",invalidate:t.invalidate??"",pause:t.pause??"",resume:t.resume??"",complete:t.complete??"",error:t.error??"",teardown:t.teardown??"",derived:t.derived??"",path:t.path??"",reset:t.reset??""}}function Wr(t){if(t==null)return{};let e=t.detail;return e==="full"?{...t,structured:t.structured??!0,timeline:t.timeline??!0,causal:t.causal??!0,derived:t.derived??!0}:e==="minimal"?{...t,structured:t.structured??!0}:t.format==="stage-log"?{...t,structured:t.structured??!0,timeline:t.timeline??!0}:t}function Cs(t,e,n){for(let r=0;r<t.length;r++){let o=t.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function sn(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(L))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${L}' (path separator)`);if(t===te)throw new Error(`Graph "${e}": ${n} name "${te}" is reserved for meta companion paths`);Cs(t,e,n)}function Ms(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(L);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function Ds(t,e){let n=!1;for(let o of t)if(!e.isMetaPassthrough(o[0])){n=!0;break}return n?t.filter(o=>e.isMetaPassthrough(o[0])):t}function Yr(t){for(let e of t._mounts.values())Yr(e);for(let e of t._nodes.values())try{e.down([[q]],{internal:!0})}catch{}}var ne=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(L))throw new Error(`Graph name must not contain '${L}' (got "${e}")`);if(e===te)throw new Error(`Graph name "${te}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??Te,this._traceRing=new ot(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=Ie(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}add(e,n){let r=e.name,o=n?.name??r;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=n?.annotation;if(sn(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:Me()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof $&&n._applyVersioning(e)}remove(e){sn(e,this.name,"remove");let n=this._mounts.get(e);if(n){let s={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,c]of i)a.includes(`${L}${te}${L}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...n._collectSubgraphs(`${e}${L}`)),this._mounts.delete(e),n._parent=void 0,Yr(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[q]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let n=typeof e=="function"?e:(()=>{let s=Nt(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>n(s));for(let s of o){let i=this.remove(s);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let o=e[r++];return{value:[o,n.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(L))return this.resolve(e);let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return n}get(e){return this.node(e).cache}set(e,n,r){let o=r?.internal===!0;this.node(e).down([[E,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);ce(()=>{for(let[o,s]of r)this.set(o,s,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[oe]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let o=r?.internal===!0;this.node(e).down([[C,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[P]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[c,u]of this._nodes)r.set(u,c);let a=[];for(let[c,u]of this._nodes)if(u instanceof $)for(let l of u._deps){let f=r.get(l.node);f!=null&&a.push([f,c])}return a.sort((c,u)=>c[0]<u[0]?-1:c[0]>u[0]?1:c[1]<u[1]?-1:c[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,c]of o)s.set(c,a);let i=[];for(let[a,c]of o)if(c instanceof $)for(let u of c._deps){let l=s.get(u.node);l!=null&&i.push([l,a])}return i.sort((a,c)=>a[0]<c[0]?-1:a[0]>c[0]?1:a[1]<c[1]?-1:a[1]>c[1]?1:0),i}mount(e,n){if(sn(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let n=Ms(e,this.name);return this._resolveFromSegments(n)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let n=e;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],o=n.slice(1);if(o.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let s=this._nodes.get(r);if(s&&o.length>0&&o[0]===te)return this._resolveMetaChainFromNode(s,o,n.join(L));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(L)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(L))}_resolveMetaChainFromNode(e,n,r){let o=e,s=0,i=[...n];for(;s<i.length;){if(i[s]!==te)throw new Error(`Graph "${this.name}": expected ${te} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${te} in "${r}"`);let a=i[s+1],c=o.meta[a];if(!c)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=c,s+=2}return o}signal(e,n){if(n?.internal!==!0){for(let o of e)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,o){for(let c of this._mounts.values())c._signalDeliver(e,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=Ds(e,this.config);for(let c of[...this._nodes.keys()].sort()){let u=this._nodes.get(c);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(l){if(l instanceof Z)throw l;o.push(l)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,o)}}}_signalMetaSubtree(e,n,r,o,s){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,o)}catch(c){if(c instanceof Z)throw c;s.push(c)}this._signalMetaSubtree(a,n,r,o,s)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,o=vt(e?.detail,e?.fields),s=e?.format==="spec",i=s?vt("minimal"):o,a=[];this._collectObserveTargets("",a);let c=new Map;for(let[T,x]of a)c.set(x,T);let u=[];{let T=a.map(([,N])=>N),x=new Set(c.values()),R=0;for(;T.length>0;){let N=T.shift();if(N instanceof $)for(let M of N._deps){let S=M.node;if(c.has(S))continue;let A=S.name??"",k=A;if(!k||x.has(k))if(A){let F=2;for(;x.has(`${A}#${F}`);)F++;k=`${A}#${F}`}else for(k=`__internal__/${R++}`;x.has(k);)k=`__internal__/${R++}`;c.set(S,k),x.add(k),u.push([k,S]),T.push(S)}}}let l=[...a,...u],f={};for(let[T,x]of l){if(n!=null&&!x.allowsObserve(n))continue;let R=rn(x,i),N=x instanceof $?x._deps.map(k=>c.get(k.node)??k.node.name??""):[],{name:M,...S}=R,A={...S,deps:N};if(!s){let k=this._annotations.get(T);k!=null&&(A.annotation=k)}if(r!=null)if(typeof r=="function"){let k=r;if(!(k.length>=2?k(T,A):k(A)))continue}else{let k=!0;for(let[F,U]of Object.entries(r)){let re=F==="deps_includes"?"depsIncludes":F==="meta_has"?"metaHas":F;if(re==="depsIncludes"){if(!A.deps.includes(String(U))){k=!1;break}continue}if(re==="metaHas"){if(!Object.hasOwn(A.meta??{},String(U))){k=!1;break}continue}if(A[re]!==U){k=!1;break}}if(!k)continue}f[T]=A}let p=new Set(Object.keys(f)),h=[];for(let[T,x]of l)if(x instanceof $)for(let R of x._deps){let N=c.get(R.node);N!=null&&h.push([N,T])}h.sort((T,x)=>T[0]<x[0]?-1:T[0]>x[0]?1:T[1]<x[1]?-1:T[1]>x[1]?1:0);let d=h.map(([T,x])=>({from:T,to:x}));(n!=null||r!=null)&&(d=d.filter(T=>p.has(T.from)&&p.has(T.to)));let g=this._collectSubgraphs(""),m=n!=null||r!=null?g.filter(T=>{let x=`${T}${L}`;return[...p].some(R=>R===T||R.startsWith(x))}):g,v=this,_=e,b={name:this.name,nodes:f,edges:d,subgraphs:m,expand(T){let x={..._,format:void 0};return Array.isArray(T)?(x.fields=T,x.detail=void 0):(x.detail=T,x.fields=void 0),v.describe(x)}},y=e??{},w=y.format;return w==="json"?Ts(b,y):w==="pretty"?Es(b,y):w==="mermaid"?Kr(b,y):w==="mermaid-url"?Rs(b,y):w==="d2"?Os(b,y):w==="ascii"?Ir(b,y):b}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;n.push(o),n.push(...this._mounts.get(r)._collectSubgraphs(`${o}${L}`))}return n}resourceProfile(e){return jr(this,e)}reachable(e,n,r={}){return r.withDetail===!0?un(this.describe(),e,n,{...r,withDetail:!0}):un(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,c]of Object.entries(o.nodes))c.lastMutation!=null&&i.set(a,c.lastMutation);return Lr(o,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=V(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=()=>{a||c||(a=!0,Qe(()=>{a=!1,!c&&(o+=1,s.emit(o))}))},l=i.onEvent(m=>{let v=m.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||u()}),f=[],p=new WeakSet,h=m=>{if(p.has(m)||c)return;p.add(m);let v=m.topology.subscribe(_=>{for(let b of _){if(b[0]!==E)continue;let y=b[1];if(u(),y.kind==="added"&&y.nodeKind==="mount"){let w=m._mounts.get(y.name);w!=null&&h(w)}}});f.push(v);for(let _ of m._mounts.keys()){let b=m._mounts.get(_);b!=null&&h(b)}};h(this);let d;try{d=ie([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,v)=>m===v})}catch(m){l();for(let v of f)v();throw i.dispose(),m}let g=ge(d);return{node:d,dispose(){c=!0,l();for(let m of f)m();f.length=0,i.dispose(),g()}}}_explainReactive(e,n,r){let o=0,s=V(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=i.onEvent(h=>{let d=h.type;d!=="data"&&d!=="error"&&d!=="complete"&&d!=="teardown"||a||c||(a=!0,Qe(()=>{a=!1,!c&&(o+=1,s.emit(o))}))}),l={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},f;try{f=ie([s],()=>this._explainStatic(e,n,l),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(h,d)=>h.found===d.found&&h.reason===d.reason&&h.steps.length===d.steps.length&&Gs(h.steps,d.steps)})}catch(h){throw u(),i.dispose(),h}let p=ge(f);return{node:f,dispose(){c=!0,u(),i.dispose(),p()}}}_pathsMatching(e){let n=Nt(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>n.test(o))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${L}${r}`;this._mounts.get(r)._collectObserveTargets(o,n)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${L}${r}`;n.push([s,o]),this._appendMetaObserveTargets(s,o,n)}}_appendMetaObserveTargets(e,n,r){for(let o of Object.keys(n.meta).sort()){let s=n.meta[o],i=`${e}${L}${te}${L}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,n){let r=typeof e=="string",s=Wr(r?n:e),i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let l=e,f=this.resolve(l);if(a!=null&&!f.allowsObserve(a))throw new Z({actor:a,action:"observe",nodeName:l});return i?this._buildStructuredObserver([[l,f]],s,"one"):{subscribe(p){return f.subscribe(p)},up(p){try{f.up?.(p)}catch(h){if(h instanceof Z)return;throw h}}}}let c=[];this._collectObserveTargets("",c),c.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let u=a==null?c:c.filter(([,l])=>l.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:l=>{let f=u.map(([p,h])=>h.subscribe(d=>{l(p,d)}));return()=>{for(let p of f)p()}},up:(l,f)=>{try{this.resolve(l).up?.(f)}catch(p){if(p instanceof Z)return;throw p}}}}_buildStructuredObserver(e,n,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let l=this.resolve(o);return this._buildStructuredObserver([[o,l]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let c=i.actor,u=c==null?a:a.filter(([,l])=>l.allowsObserve(c));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,s)}_createObserveResult(e,n,r){let o=n.timeline===!0,s=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",c=this.config.inspectorEnabled,u=(s||i)&&c,l=n.maxEvents,f=l!=null&&l>0?new ot(l):null,p=[],h=new Set,d={},g=new Set,m=0,v=0,_=0,b=0,y=0,w=0,T=!1,x=!1,R=0,N=new Map,M=new Map,S=new Map,A=O=>{f?f.push(O):p.push(O);for(let G of h)G(O)},k=()=>o?{timestamp_ns:Me(),in_batch:at(),batch_id:R}:{},F=(O,G)=>{if(!(!u||!(O instanceof $)))return O._setInspectorHook(J=>{if(J.kind==="dep_message")N.set(O,J.depIndex);else if(J.kind==="run"){let We=J.batchData.map((D,z)=>D!=null&&D.length>0?D.at(-1):J.prevData[z]);M.set(O,We);let Q=J.batchData.map(D=>D!=null?[...D]:void 0);S.set(O,Q),i&&A({type:"derived",path:G,dep_values:We,dep_batches:Q,...k()})}})},U=O=>{let G=N.get(O),J=M.get(O);if(!s||J==null)return{};let Q=(G!=null&&G>=0&&O instanceof $?O._deps[G]:void 0)?.node,D=Q?.v,z=S.get(O);return{trigger_dep_index:G,trigger_dep_name:Q?.name,...D!=null?{trigger_version:{id:D.id,version:D.version}}:{},dep_values:[...J],...z!=null?{dep_batches:z}:{}}},re=[],ye=[];for(let[O,G]of e){let J=F(G,O);J&&re.push(J),ye.push(G.subscribe(We=>{R++;for(let Q of We){let D=Q[0],z=k();if(D===E){d[O]=Q[1];let It=G instanceof $?G.lastMutation?.actor??pe:pe;A({type:"data",path:O,data:Q[1],actor:It,...z,...U(G)})}else if(a)D===I?m++:D===B?v++:D===oe?_++:D===X?b++:D===se?y++:D===q?w++:D===P&&!g.has(O)?T=!0:D===C&&(x=!0,g.add(O));else if(D===I)m++,A({type:"dirty",path:O,...z});else if(D===B)v++,A({type:"resolved",path:O,...z,...U(G)});else if(D===oe)_++,A({type:"invalidate",path:O,...z});else if(D===X)b++,A({type:"pause",path:O,lockId:Q[1],...z});else if(D===se)y++,A({type:"resume",path:O,lockId:Q[1],...z});else if(D===P)g.has(O)||(T=!0),A({type:"complete",path:O,...z});else if(D===C){x=!0,g.add(O);let It=G instanceof $?G.lastMutation?.actor??pe:pe;A({type:"error",path:O,data:Q[1],actor:It,...z})}else D===q&&(w++,A({type:"teardown",path:O,...z}))}}))}let Mt=!1,Dt=()=>{if(!Mt){Mt=!0;for(let O of ye)O();for(let O of re)O();for(let O of it)O({value:void 0,done:!0});it.length=0}},Gt=[],it=[];h.add(O=>{let G=it.shift();G?G({value:O,done:!1}):Gt.push(O)});let Tn={get values(){return d},get dirtyCount(){return m},get resolvedCount(){return v},get invalidateCount(){return _},get pauseCount(){return b},get resumeCount(){return y},get teardownCount(){return w},get events(){return f?f.toArray():[...p]},get anyCompletedCleanly(){return T},get anyErrored(){return x},get completedWithoutErrors(){return T&&!x},onEvent(O){return h.add(O),()=>h.delete(O)},dispose:Dt,expand(O){Dt();let G={...n};return typeof O=="string"?G.detail=O:Object.assign(G,O),r(Wr(G))},[Symbol.asyncIterator](){return{next(){return Gt.length>0?Promise.resolve({value:Gt.shift(),done:!1}):Mt?Promise.resolve({value:void 0,done:!0}):new Promise(O=>it.push(O))},return(){return Dt(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Tn,n),Tn}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let o=n.logger??(d=>console.log(d)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:d=>(s==null||s.has(d))&&(i==null||!i.has(d)),c=As(n.theme),u=r==="stage-log"?Me():0,l=d=>d==null?"":n.stageLabels?.[d]??d,f=(d,g)=>d.length>g?`${d.slice(0,g-1)}\u2026`:d,p=d=>d.type==="data"||d.type==="error"?f(St(d.data),120):"",h=d=>{if(r==="stage-log"){let x=(Me()-u)/1e9,R=l(d.path).padEnd(9);if(d.type==="data"){let N=p(d);return`[${x.toFixed(3)}s] ${R} \u2190${N?` ${N}`:""}`}if(d.type==="error"){let N=p(d);return`[${x.toFixed(3)}s] ${R} \u2717${N?` ${N}`:""}`}return d.type==="complete"?`[${x.toFixed(3)}s] ${R} \u25A0 complete`:`[${x.toFixed(3)}s] ${R} ${d.type}`}if(r==="json")try{return JSON.stringify(d)}catch{return JSON.stringify({type:d.type,path:d.path,data:"[unserializable]"})}let g=c[d.type]??"",m=d.path?`${c.path}${d.path}${c.reset} `:"",v=d.type==="data"||d.type==="error",_=d.type==="pause"||d.type==="resume",b=v?` ${St(d.data)}`:_?` ${St(d.lockId)}`:"",y=d.type==="data"||d.type==="resolved"||d.type==="derived"?d:void 0,w=y?.trigger_dep_name!=null?` <- ${y.trigger_dep_name}`:y?.trigger_dep_index!=null?` <- #${y.trigger_dep_index}`:"",T=d.in_batch?" [batch]":"";return`${m}${g}${d.type.toUpperCase()}${c.reset}${b}${w}${T}`};e.onEvent(d=>{a(d.type)&&o(h(d),d)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){Vr(this._disposers,this.name),this.signal([[q]],{internal:!0}),Vr(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:n,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:c,guard:u,...l}=r.nodes[a];o[a]=l}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return Pn(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??Te,{codec:o,codecVersion:s,payload:i}=$n(e,r);return o.decode(i,s)}restore(e,n){if(qr(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(s=>Nt(s)),o=n?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let c=this.tryResolve(s)?.v;if(c!=null&&c.id===i.v.id&&c.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(e,n){qr(e);let r=typeof n=="function"?n:n?.build,o=typeof n=="function"?void 0:n?.factories,s=new t(e.name);if(r)return r(s),s.restore(e),s;for(let h of[...e.subgraphs].sort((d,g)=>{let m=d.split(L).length,v=g.split(L).length;return m!==v?m-v:d<g?-1:d>g?1:0})){let d=h.split(L),g=s;for(let m of d)g._mounts.has(m)||g.mount(m,new t(m)),g=g._mounts.get(m)}let i=o?Object.entries(o).map(([h,d])=>({re:Nt(h),factory:d})):[],a=h=>{for(let d of i)if(d.re.test(h))return d.factory},c=h=>{let d=h.split(L),g=d.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${h}"`);let m=s;for(let v of d){let _=m._mounts.get(v);if(!_)throw new Error(`unknown mount "${v}" in path "${h}"`);m=_}return[m,g]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${L}${te}${L}`)).sort((h,d)=>h[0]<d[0]?-1:h[0]>d[0]?1:0),l=new Map(u),f=new Map,p=!0;for(;l.size>0&&p;){p=!1;for(let[h,d]of[...l.entries()]){let g=d?.deps??[];if(!g.every(w=>f.has(w)))continue;let[m,v]=c(h),_={...d?.meta??{}},b=a(h),y;if(d?.type==="state")y=V(d.value,{meta:_});else{if(b==null)continue;y=b(v,{path:h,type:d.type,value:d.value,meta:_,deps:g,resolvedDeps:g.map(w=>f.get(w))})}m.add(y,{name:v}),f.set(h,y),l.delete(h),p=!0}}if(l.size>0){let h=[...l.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let o=(u,l)=>{if(u.disposed)return;let f=ys(l.nodes);if(u.lastSnapshot!=null&&f!==""&&f===u.lastFingerprint)return;let p=u.seq+1,h=he(),m=u.lastSnapshot==null||p%u.compactEvery===0?{mode:"full",snapshot:l,seq:p,timestamp_ns:h,format_version:Ne}:{mode:"diff",diff:Jr(u.lastSnapshot,l),seq:p,timestamp_ns:h,format_version:Ne};if(u.tier.filter&&!u.tier.filter(this.name,m))return;let v;try{v=u.tier.save(this.name,m)}catch(_){n.onError?.(_,u.tier);return}if(v&&typeof v.then=="function"){let y=(u.savePending??Promise.resolve()).then(()=>v,()=>v).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=l,u.lastFingerprint=f)},w=>{n.onError?.(w,u.tier)});u.savePending=y.finally(()=>{u.savePending===y&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=l,u.lastFingerprint=f},s=(u,l)=>{try{o(u,l)}catch(f){n.onError?.(f,u.tier)}},i=(u,l)=>{if(!l.some(d=>{let g=this.config.messageTier(d[0]);return g>=3&&g<5}))return;if(n.filter){let d=this.tryResolve(u);if(d==null)return;let g=rn(d,vt("standard"));if(!n.filter(u,g))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let d of r)d.disposed||(d.debounceMs===0?s(d,h()):(d.timer==null&&(d.timer=new _t),d.timer.start(d.debounceMs,()=>{d.disposed||s(d,this.snapshot())})))},a;if(n.paths!=null){let l=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(f=>{let p=this.tryResolve(f);return p==null?()=>{}:p.subscribe(h=>i(f,h))});a=()=>{for(let f of l)f()}}else a=this.observe().subscribe((u,l)=>i(u,l));let c=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(c)};return this._storageDisposers.add(c),{dispose:c}}async _cascadeRestore(e,n){for(let r of e){let o;try{o=await r.load(this.name)}catch(i){n?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===Ne&&s.nodes!=null)return this.restore(s),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let o of n){let s;try{s=await o.load(e)}catch(c){r?.onError?.(c,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===Ne&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(c){r?.onError?.(c,o)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,n,r){if(e!=null&&n!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,n),this.config.inspectorEnabled){let o={path:e,annotation:n,timestamp_ns:Me(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(o=>!e(o)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let o of n)this._traceRing.push(o);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(n.nodes)),s=[...o].filter(_=>!r.has(_)).sort(),i=[...r].filter(_=>!o.has(_)).sort(),a=[],c=[];for(let _ of r){if(!o.has(_))continue;let b=e.nodes[_],y=n.nodes[_],w=b.v,T=y.v;w!=null&&T!=null&&w.id===T.id&&w.version!==T.version&&c.push({path:_,id:w.id,from:w.version,to:T.version});let x=w!=null&&T!=null&&w.id===T.id&&w.version===T.version;for(let R of["type","status","sentinel"]){let N=b[R],M=y[R];N!==M&&a.push({path:_,field:R,from:N,to:M})}if(!x)for(let R of["value","meta"]){let N=b[R],M=y[R];vs(N,M)||a.push({path:_,field:R,from:N,to:M})}}let u=_=>`${_.from} ${_.to}`,l=new Set(e.edges.map(u)),f=new Set(n.edges.map(u)),p=n.edges.filter(_=>!l.has(u(_))),h=e.edges.filter(_=>!f.has(u(_))),d=new Set(e.subgraphs),g=new Set(n.subgraphs),m=[...g].filter(_=>!d.has(_)).sort(),v=[...d].filter(_=>!g.has(_)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:c,edgesAdded:p,edgesRemoved:h,subgraphsAdded:m,subgraphsRemoved:v}}};function Jr(t,e){let n=ne.diff(t,e),r={};for(let o of n.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...n,nodesAddedFull:r}}function un(t,e,n,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,c=new Map,u=new Map,l=new Set;for(let[b,y]of Object.entries(t.nodes)){if(!b)continue;l.add(b);let w=y.deps??[];i.set(b,w);for(let T of w)T&&(l.add(T),a.has(T)||a.set(T,new Set),a.get(T).add(b))}for(let b of t.edges){if(b==null||typeof b!="object")continue;let y=typeof b.from=="string"?b.from:"",w=typeof b.to=="string"?b.to:"";!y||!w||(l.add(y),l.add(w),u.has(y)||u.set(y,new Set),u.get(y).add(w),c.has(w)||c.set(w,new Set),c.get(w).add(y))}if(!l.has(e))return r.withDetail?o:[];let f=r.both===!0,p=b=>{if(f){let x=i.get(b)??[],R=c.get(b),N=a.get(b),M=u.get(b),S=[...x];return R&&S.push(...R),N&&S.push(...N),M&&S.push(...M),S}if(n==="upstream"){let x=i.get(b)??[],R=c.get(b);return R?[...x,...R]:x}let y=a.get(b),w=u.get(b),T=y?[...y]:[];return w&&T.push(...w),T},h=new Set([e]),d=new Map,g=[{path:e,depth:0}],m=0,v=!1;for(;m<g.length;){let b=g[m++];if(s!=null&&b.depth>=s){p(b.path).length>0&&(v=!0);continue}for(let y of p(b.path))!y||h.has(y)||(h.add(y),d.set(y,b.depth+1),g.push({path:y,depth:b.depth+1}))}let _=[...d.keys()].sort((b,y)=>b<y?-1:b>y?1:0);return r.withDetail?{paths:_,depths:d,truncated:v}:_}function Gs(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],o=e[n];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}we();Xe();De();Ue();De();Ge();de();we();W();de();var cn=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,n){if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=n,n!==void 0){if(this._buf=new Array(n),e&&e.length>0){let r=Math.min(e.length,n),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._size+e;if(!(n<0||n>=this._size))return this._maxSize!==void 0?this._buf[(this._head+n)%this._maxSize]:this._buf[n]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=n;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let n=0;n<e;n++)this._buf[(this._head+n)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let n=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,n);else{for(let r=0;r<n;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+n)%this._maxSize}return this._size-=n,this._version+=1,n}slice(e,n){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(n!==void 0&&(!Number.isInteger(n)||n<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${n})`);let r=n===void 0?this._size:Math.min(Math.max(n,0),this._size),o=Math.min(e,this._size);if(o>=r)return[];let s=r-o;if(this._maxSize===void 0)return this._buf.slice(o,r);let i=new Array(s);for(let a=0;a<s;a++)i[a]=this._buf[(this._head+o+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let n=Math.min(e,this._size);return this.slice(this._size-n,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this._buf[(this._head+n)%this._maxSize];return e}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function Qr(t){return t.subscribe(()=>{})}var Is=64;function Xr(t,e={}){let{name:n,maxSize:r,versioning:o,backend:s}=e,i=s??new cn(t,r),a=V(i.toArray(),{name:n,describeKind:"state",equals:(d,g)=>d===g,...o!=null?{versioning:o}:{}});function c(){let d=i.toArray();ce(()=>{a.down([[I]]),a.down([[E,d]])})}let u=new Map,l=new Map;function f(d,g){return`${d}:${g===void 0?"END":g}`}function p(d){if(d.size<Is)return;let g=d.keys().next();if(g.done)return;let m=d.get(g.value);m!==void 0&&m.dispose(),d.delete(g.value)}function h(d){let g=i.version;try{return d()}finally{i.version!==g&&c()}}return{entries:a,get size(){return i.size},at(d){return i.at(d)},append(d){h(()=>i.append(d))},appendMany(d){d.length!==0&&h(()=>i.appendMany(d))},clear(){h(()=>i.clear())},trimHead(d){h(()=>i.trimHead(d))},tail(d){if(!Number.isInteger(d)||d<0)throw new RangeError(`tail: n must be a non-negative integer (got ${d})`);let g=u.get(d);if(g!==void 0)return u.delete(d),u.set(d,g),g.node;p(u);let m=ie([a],([_])=>{let b=_;return d===0||b.length===0?[]:b.slice(Math.max(0,b.length-d))},{initial:i.tail(d),describeKind:"derived"}),v=Qr(m);return u.set(d,{node:m,dispose:v}),m},slice(d,g){if(!Number.isInteger(d)||d<0)throw new RangeError(`slice: start must be a non-negative integer (got ${d})`);if(g!==void 0&&(!Number.isInteger(g)||g<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${g})`);let m=f(d,g),v=l.get(m);if(v!==void 0)return l.delete(m),l.set(m,v),v.node;p(l);let _=ie([a],([y])=>{let w=y;return g===void 0?w.slice(d):w.slice(d,g)},{initial:i.slice(d,g),describeKind:"derived"}),b=Qr(_);return l.set(m,{node:_,dispose:b}),_},disposeTail(d){let g=u.get(d);return g===void 0?!1:(g.dispose(),u.delete(d),!0)},disposeSlice(d,g){let m=f(d,g),v=l.get(m);return v===void 0?!1:(v.dispose(),l.delete(m),!0)},disposeAllViews(){for(let d of u.values())d.dispose();u.clear();for(let d of l.values())d.dispose();l.clear()},dispose(){for(let d of u.values())d.dispose();u.clear();for(let d of l.values())d.dispose();l.clear()}}}gt();function Zr(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}var Ls=dt((t,e)=>{t("write"),t("signal"),e("observe")}),Ps=dt((t,e)=>{t("observe"),t("signal"),e("write")}),$s=dt((t,e)=>{t("observe"),t("signal"),e("write")});function kt(t,e){return Zr("cqrs",t,e)}var dn=class extends ne{_eventLogs=new Map;_commandHandlers=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_eventStore;_seq=0;constructor(e,n={}){super(e,n.graph)}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}event(e){let n=this._eventLogs.get(e);if(n)return n.node;let r=Xr([],{name:e,versioning:0}),o=r.entries,s=ie([o],([i])=>i,{name:e,describeKind:"state",meta:kt("event",{event_name:e}),guard:$s,initial:o.cache});return this.add(s,{name:e}),this._keepaliveDisposers.push(ge(s)),this._eventLogs.set(e,{log:r,node:s}),s}_appendEvent(e,n){let r=this._eventLogs.get(e);if(r||(this.event(e),r=this._eventLogs.get(e)),r.node.status==="completed"||r.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${r.node.status}).`);let o=r.log.entries.v,s={type:e,payload:n,timestampNs:he(),seq:++this._seq,...o!=null?{v0:{id:o.id,version:o.version}}:{}};r.log.append(s),this._eventStore&&this._eventStore.persist(s)}command(e,n){let r=V(void 0,{name:e,describeKind:"state",meta:{...kt("command",{command_name:e}),error:null},guard:Ls});return this.add(r,{name:e}),this._commandHandlers.set(e,n),r}dispatch(e,n){let r=this._commandHandlers.get(e);if(!r)throw new Error(`Unknown command: "${e}". Register with .command() first.`);let o=this.resolve(e);ce(()=>{o.emit(n,{internal:!0});try{r(n,{emit:(s,i)=>this._appendEvent(s,i)}),o.meta.error.emit(null,{internal:!0})}catch(s){throw o.meta.error.emit(s,{internal:!0}),s}})}projection(e,n,r,o){let s=n.map(a=>(this._eventLogs.has(a)||this.event(a),this._eventLogs.get(a).node)),i=ie(s,a=>{let c=[];for(let u of a){let l=u;c.push(...l)}return c.sort((u,l)=>u.timestampNs-l.timestampNs||u.seq-l.seq),r(o,c)},{name:e,describeKind:"derived",meta:kt("projection",{projection_name:e,source_events:n}),guard:Ps,initial:o});return this.add(i,{name:e}),this._keepaliveDisposers.push(ge(i)),this._projections.add(e),i}saga(e,n,r){let o=n.map(c=>(this._eventLogs.has(c)||this.event(c),this._eventLogs.get(c).node)),s=new Map,i={},a=Ee(o,(c,u)=>{let l=i.n.meta.error;for(let f=0;f<c.length;f++){let p=c[f];if(p==null||p.length===0)continue;let h=p.at(-1);if(!h)continue;let d=n[f],g=s.get(d)??0;if(h.length>g){let m=h.slice(g);for(let v of m)try{r(v),l.emit(null,{internal:!0})}catch(_){l.emit(_,{internal:!0})}s.set(d,h.length)}}},{name:e,describeKind:"effect",meta:{...kt("saga",{saga_name:e,source_events:n}),error:null}});return i.n=a,this.add(a,{name:e}),this._keepaliveDisposers.push(ge(a)),this._sagas.add(e),a}useEventStore(e){this._eventStore=e}async rebuildProjection(e,n,r){if(!this._eventStore)throw new Error("No event store wired. Call useEventStore() first.");let o=[];for(let s of e){let i=await this._eventStore.loadEvents(s);o.push(...i.events)}return o.sort((s,i)=>s.timestampNs-i.timestampNs||s.seq-i.seq),n(r,o)}};function eo(t,e){return new dn(t,e)}var fn=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},pn=class{graph=new ne("request");onModuleDestroy(){this.graph.destroy()}},to,ln;to=[(0,st.Module)({})];var be=class be{static forRoot(e){let n=e??{},r=n.name??"root",o=[{provide:ee,useFactory:()=>{let s=new ne(r);return n.build&&n.build(s),n.snapshot&&s.restore(n.snapshot),s}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:s=>new fn(s),inject:[ee]},{provide:Oe,useFactory:(s,i)=>new Oe(s,i),inject:[ee,no.ModuleRef]}];if(n.nodes)for(let s of n.nodes)o.push({provide:ae(s),useFactory:i=>i.resolve(s),inject:[ee]});return n.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new pn,scope:st.Scope.REQUEST},{provide:Re,useFactory:s=>s.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:st.Scope.REQUEST}),{module:be,global:!0,providers:o,exports:[ee,...(n.nodes??[]).map(ae),...n.requestScope?[Re]:[]]}}static forFeature(e){let n=[{provide:K(e.name),useFactory:r=>{let o=new ne(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),r.mount(e.name,o),o},inject:[ee]}];if(e.nodes)for(let r of e.nodes)n.push({provide:ae(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[K(e.name)]});return{module:be,providers:n,exports:[K(e.name),...(e.nodes??[]).map(r=>ae(`${e.name}::${r}`))]}}static forCqrs(e){let n=[{provide:K(e.name),useFactory:r=>{let o=eo(e.name,e.cqrs);return e.eventStore&&o.useEventStore(e.eventStore),e.build&&e.build(o),r.mount(e.name,o),o},inject:[ee]}];if(e.nodes)for(let r of e.nodes)n.push({provide:ae(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[K(e.name)]});return{module:be,providers:n,exports:[K(e.name),...(e.nodes??[]).map(r=>ae(`${e.name}::${r}`))]}}};ln=kn(null),be=Mn(ln,0,"GraphReflyModule",to,be),Cn(ln,1,be);var At=be;var gn={};ue(gn,{useStore:()=>Hs,useSubscribe:()=>ro,useSubscribeRecord:()=>Fs});var le=require("react");W();function ro(t){return(0,le.useSyncExternalStore)(e=>{let n=!1,r=t.subscribe(()=>{n||e()});return()=>{n=!0,r()}},()=>t.cache,()=>t.cache)}function Hs(t){let e=ro(t),n=(0,le.useCallback)(r=>{t.down([[I],[E,r]])},[t]);return[e,n]}function Fs(t,e){let n=(0,le.useRef)(e);n.current=e;let r=(0,le.useMemo)(()=>{let o=()=>{let i={},a=t.cache??[];for(let c of a){let u=n.current(c),l={};for(let f of Object.keys(u))l[f]=u[f].cache;i[c]=l}return i},s=o();return{subscribe:i=>{let a=!1,c=[],u=()=>{for(let p of c)p();c=[]},l=p=>{u();for(let h of p){let d=n.current(h);for(let g of Object.keys(d)){let m=d[g].subscribe(()=>{s=o(),a||i()});c.push(m)}}s=o(),a||i()},f=t.subscribe(p=>{let h=p.some(d=>d[0]===E||d[0]===B);!a&&h&&l(t.cache??[])});return l(t.cache??[]),()=>{a=!0,f(),u()}},getSnapshot:()=>s}},[t]);return(0,le.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot)}var yn={};ue(yn,{Signal:()=>js});we();W();de();var qe=[];function Ct(t){let e=t.cache;return t.subscribe(r=>{for(let[o,s]of r)o===E&&(e=s)})(),e}var mn=class{_node;_equals;constructor(e,n){this._equals=n?.equals??Object.is,this._node=V(e,{...n,resubscribable:!0,resetOnTeardown:!0})}get(){let e=qe[qe.length-1];return e?(this._node.status==="sentinel"&&Ct(this._node),e(this._node)):this._node.status==="sentinel"?Ct(this._node):this._node.cache}set(e){this._equals(this.get(),e)||ce(()=>{this._node.down([[I],[E,e]])})}},bn=class{_node;constructor(e,n){this._node=Ze(r=>{qe.push(r);try{return e()}finally{qe.pop()}},{...n,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=qe[qe.length-1];return e?(this._node.status==="sentinel"&&Ct(this._node),e(this._node)):this._node.status==="sentinel"?Ct(this._node):this._node.cache}},js={State:mn,Computed:bn,sub:(t,e)=>{let n=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,r=!0;return t._node.subscribe(o=>{for(let[s,i]of o){if(s===E){if(r){r=!1;continue}n.data?.(i)}s===C&&n.error?.(i),s===P&&n.complete?.()}})}};var vn={};ue(vn,{useStore:()=>Vs,useSubscribe:()=>oo,useSubscribeRecord:()=>qs});var fe=require("solid-js");W();function oo(t){let[e,n]=(0,fe.createSignal)(t.cache,{equals:!1}),r=t.subscribe(()=>{n(()=>t.cache)});return(0,fe.getOwner)()?(0,fe.onCleanup)(()=>r()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),e}function Vs(t){return[oo(t),r=>{t.down([[I],[E,r]])}]}function qs(t,e){let[n,r]=(0,fe.createSignal)({},{equals:!1}),o=[],s=()=>{for(let u of o)u();o=[]},i=()=>{let u={};for(let l of t.cache??[]){let f=e(l),p={};for(let h of Object.keys(f))p[h]=f[h].cache;u[l]=p}return u},a=u=>{s();for(let l of u){let f=e(l);for(let p of Object.keys(f)){let h=f[p].subscribe(()=>{r(()=>i())});o.push(h)}}r(()=>i())},c=t.subscribe(u=>{u.some(l=>l[0]===E||l[0]===B)&&a(t.cache??[])});return a(t.cache??[]),(0,fe.getOwner)()?(0,fe.onCleanup)(()=>{c(),s()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),n}var _n={};ue(_n,{useStore:()=>Bs,useSubscribe:()=>Ws,useSubscribeRecord:()=>zs});W();function Ws(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n}}}function Bs(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n},set(e){t.down([[I],[E,e]])},update(e){let n=e(t.cache);t.down([[I],[E,n]])}}}function zs(t,e){return{subscribe(n){let r=[],o=()=>{for(let c of r)c();r=[]},s=()=>{let c={};for(let u of t.cache??[]){let l=e(u),f={};for(let p of Object.keys(l))f[p]=l[p].cache;c[u]=f}return c},i=c=>{o();for(let u of c){let l=e(u);for(let f of Object.keys(l)){let p=l[f].subscribe(()=>{n(s())});r.push(p)}}n(s())},a=t.subscribe(c=>{c.some(u=>u[0]===E||u[0]===B)&&i(t.cache??[])});return i(t.cache??[]),()=>{a(),o()}}}}var xn={};ue(xn,{useStore:()=>Us,useSubscribe:()=>Ks,useSubscribeRecord:()=>Ys});var H=require("vue");W();function Ks(t){let e=(0,H.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,H.getCurrentScope)()?(0,H.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,H.readonly)(e)}function Us(t){let e=(0,H.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,H.getCurrentScope)()?(0,H.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useStore called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,H.computed)({get:()=>e.value,set:r=>{t.down([[I],[E,r]])}})}function Ys(t,e){let n=(0,H.shallowRef)({}),r=new Map;function o(){let a={};for(let[c,u]of r)a[c]={...u.values};n.value=a}function s(a){for(let u of r.values())for(let l of u.subs)l();r.clear();for(let u of a){let l=e(u),f=Object.keys(l),p={},h=[];for(let d of f){let g=l[d];p[d]=g.cache;let m=g.subscribe(()=>{p[d]=g.cache,o()});h.push(m)}r.set(u,{subs:h,values:p})}let c={};for(let[u,l]of r)c[u]={...l.values};n.value=c}return(0,H.watch)(()=>[...(typeof t=="function"?t():(0,H.isRef)(t)?t.value:t)??[]],a=>s(a??[]),{immediate:!0}),(0,H.getCurrentScope)()?(0,H.onScopeDispose)(()=>{for(let a of r.values())for(let c of a.subs)c();r.clear()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,H.readonly)(n)}var wn={};ue(wn,{create:()=>Qs});W();de();var Js=()=>!1;function Qs(t){let e=new ne("zustand"),n=V(void 0,{name:"state",equals:Js});e.add(n,{name:"state"});let r=()=>n.cache,o=(a,c)=>{let u=n.cache,l=typeof a=="function"?a(u):a;n.emit(c?l:{...u,...l})},s={getState:r,setState:o,getInitialState:()=>i,subscribe:a=>{let c=!0,u=n.cache;return n.subscribe(l=>{for(let[f,p]of l)if(f===E){if(c){c=!1;continue}a(p,u),u=p}})},destroy:e.destroy.bind(e)},i=t(o,r,s);return n.emit(i),Object.assign(e,s)}0&&(module.exports={jotai,nanostores,nestjs,react,signals,solid,svelte,vue,zustand});
9
+ `,n}function Qo(t){return JSON.parse(t)}function Xo(t,e){try{t.send(JSON.stringify(e))}catch{}}function gn(t,e){try{t(e)}catch{}}et();var Ct="graphReflyActor";function mn(t){return e=>{let r=e.switchToHttp().getRequest()?.user;if(r!=null)return t?t(r):r}}function Ir(t="x-graphrefly-actor"){return e=>{let r=e.switchToHttp().getRequest()?.headers?.[t.toLowerCase()];if(!(typeof r!="string"||r.length===0))try{return JSON.parse(r)}catch{return}}}function Lr(t){let e=t?.[Ct];return e!=null?Re(e):ye}var dt=class{constructor(e){this.extractor=e}canActivate(e){let n=Re(this.extractor(e)),r=e.switchToHttp().getRequest();return r!=null&&(r[Ct]=n),!0}};function Pr(t){return new dt(t??mn())}var mt=require("@nestjs/common"),bo=require("@nestjs/core");et();Ne();ot();ke();K();ke();Ce();function Mt(t,e){if(e!=null&&e.length>0)return new Set(e);switch(t){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;default:return new Set(["type","deps"])}}function Zo(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function es(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function yn(t,e){let n=e==null,r=!n&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,o=n||e.has("meta")||r!=null&&r.length>0,s="state",i=[];t instanceof V&&(s=Zo(t),i=t._deps.map(u=>u.node.name??""));let a={type:s,deps:i};(n||e.has("status"))&&(a.status=t.status);let d=t instanceof V?t._guard:void 0;if(o){let u={...es(t)};if(d!=null&&u.access===void 0&&(u.access=nn(d)),r!=null&&r.length>0&&!e.has("meta")){let c={};for(let l of r)l in u&&(c[l]=u[l]);a.meta=c}else a.meta=u}if(t.name!=null&&(a.name=t.name),n||e.has("value")){t.status==="sentinel"&&(a.sentinel=!0);try{a.value=t.cache}catch{}}if((n||e.has("v"))&&t.v!=null){let u={id:t.v.id,version:t.v.version};"cid"in t.v&&(u.cid=t.v.cid,u.prev=t.v.prev),a.v=u}return(n||e.has("guard"))&&d!=null&&(a.guard=nn(d)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}Ce();fe();Nt();$r();var ct=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let n=(this.head+this._size)%this.capacity;this.buf[n]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let n=e<0?this._size+e:e;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this.buf[(this.head+n)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};tn();function bn(t){return t>=768&&t<=879||t>=1155&&t<=1161||t>=1425&&t<=1469||t>=1552&&t<=1562||t>=1611&&t<=1631||t>=1648&&t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t>=1767&&t<=1768||t>=1770&&t<=1773||t>=1840&&t<=1866||t>=1958&&t<=1968||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2641||t>=2672&&t<=2673||t>=2677&&t===2677||t>=3633&&t===3633||t>=3636&&t<=3642||t>=3655&&t<=3662||t>=3761&&t===3761||t>=3764&&t<=3772||t>=3784&&t<=3790||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65024&&t<=65039||t>=65056&&t<=65071||t===8205?0:t>=4352&&t<=4447||t>=8986&&t<=8987||t>=9001&&t<=9002||t>=9193&&t<=9203||t>=9208&&t<=9210||t>=9725&&t<=9726||t>=9748&&t<=9749||t>=9800&&t<=9811||t===9855||t===9875||t===9889||t>=9898&&t<=9899||t>=9917&&t<=9918||t>=9924&&t<=9925||t===9934||t===9940||t===9962||t>=9970&&t<=9971||t===9973||t===9978||t===9981||t===9986||t===9989||t>=9992&&t<=9997||t===9999||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t>=10548&&t<=10549||t>=11013&&t<=11015||t>=11035&&t<=11036||t===11088||t===11093||t>=11904&&t<=12350||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12784&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=19968&&t<=40959||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65131||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126980&&t===126980||t===127183||t>=127344&&t<=127345||t===127358||t===127359||t===127374||t>=127377&&t<=127386||t>=127456&&t<=127487||t>=127488&&t<=127490||t===127514||t===127535||t>=127538&&t<=127546||t>=127568&&t<=127569||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=129792&&t<=130047||t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}function Gt(t){let e=0;for(let n of t)e+=bn(n.codePointAt(0));return e}function Fr(t,e){if(e<=0)return"";let n=0,r="";for(let o of t){let s=bn(o.codePointAt(0));if(n+s>e){if(e<=1)return"\u2026";for(;n+1>e&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=bn(i.codePointAt(0))}return`${r}\u2026`}r+=o,n+=s}return r}var ts={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"},ns={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function jr(t,e){let n=e.charset==="ascii"?ns:ts,r=t.width,o=t.height,s=Array.from({length:o},()=>Array.from({length:r},()=>" ")),i=Array.from({length:o},()=>Array.from({length:r},()=>"empty"));for(let a of t.edges)os(s,i,n,a);for(let a of t.boxes)rs(s,i,n,a,e.labelOf(a.id));return s.map(a=>us(a.join(""))).join(`
10
+ `)}function rs(t,e,n,r,o){let{x:s,y:i,w:a,h:d}=r;if(a<2||d<2){d>0&&Hr(t,e,s,i,a,o);return}be(t,e,s,i,n.boxTL);for(let c=s+1;c<s+a-1;c+=1)be(t,e,c,i,n.boxH);be(t,e,s+a-1,i,n.boxTR);for(let c=i+1;c<i+d-1;c+=1){be(t,e,s,c,n.boxV);for(let l=s+1;l<s+a-1;l+=1)zr(t,e,l,c," ","empty");be(t,e,s+a-1,c,n.boxV)}be(t,e,s,i+d-1,n.boxBL);for(let c=s+1;c<s+a-1;c+=1)be(t,e,c,i+d-1,n.boxH);be(t,e,s+a-1,i+d-1,n.boxBR);let u=i+Math.floor(d/2);Hr(t,e,s+1,u,a-2,o)}function be(t,e,n,r,o){zr(t,e,n,r,o,o===" "?"empty":o==="\u2500"||o==="-"?"boxH":o==="\u2502"||o==="|"?"boxV":"boxCorner")}function zr(t,e,n,r,o,s){if(r<0||r>=t.length)return;let i=t[r];n<0||n>=i.length||(i[n]=o,e[r][n]=s)}function Hr(t,e,n,r,o,s){if(r<0||r>=t.length)return;let i=n,a=o;for(let d of s){let u=Gt(d);if(u!==0){if(a<u)break;i>=0&&i<t[r].length&&(t[r][i]=d,e[r][i]="label",u===2&&i+1<t[r].length&&(t[r][i+1]="",e[r][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<t[r].length&&(t[r][i]=" ",e[r][i]="empty"),i+=1,a-=1}function os(t,e,n,r){let o=r.points;if(o.length<2)return;for(let d=0;d+1<o.length;d+=1)ss(t,e,n,o[d],o[d+1]);for(let d=1;d+1<o.length;d+=1){let u=o[d-1],c=o[d],l=o[d+1],p=is(u,c,l,n);p&&qr(t,e,c.x,c.y,p,"edgeCorner")}let s=o[o.length-1],i=o[o.length-2],a=as(i,s,n);a&&qr(t,e,s.x,s.y,a,"arrow")}function ss(t,e,n,r,o){if(!(r.x===o.x&&r.y===o.y)){if(r.y===o.y){let s=r.y,i=Math.min(r.x,o.x),a=Math.max(r.x,o.x);for(let d=i;d<=a;d+=1)Vr(t,e,d,s,n,"h")}else if(r.x===o.x){let s=r.x,i=Math.min(r.y,o.y),a=Math.max(r.y,o.y);for(let d=i;d<=a;d+=1)Vr(t,e,s,d,n,"v")}}}function Vr(t,e,n,r,o,s){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[n]=s==="h"?o.horizontal:o.vertical,e[r][n]=s==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&s==="v"){i[n]=o.cross,e[r][n]="edgeCorner";return}if(a==="edgeV"&&s==="h"){i[n]=o.cross,e[r][n]="edgeCorner";return}}}function qr(t,e,n,r,o,s){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[n]=o,e[r][n]=s)}function is(t,e,n,r){let o=t.y===e.y,s=e.y===n.y;if(o===s)return;if(o){let d=t.x<e.x,u=n.y>e.y;return d&&u?r.cornerTR:d&&!u?r.cornerBR:!d&&u?r.cornerTL:r.cornerBL}let i=t.y<e.y,a=n.x>e.x;return i&&a?r.cornerBL:i&&!a?r.cornerBR:!i&&a?r.cornerTL:r.cornerTR}function as(t,e,n){if(e.x>t.x)return n.arrowRight;if(e.x<t.x)return n.arrowLeft;if(e.y>t.y)return n.arrowDown;if(e.y<t.y)return n.arrowUp}function us(t){let e=t.length;for(;e>0&&t.charCodeAt(e-1)===32;)e-=1;return t.slice(0,e)}function Kr(t){let e=ds(t);cs(e),ls(e),fs(e),ps(e,t);let n=ms(e,t),{width:r,height:o}=bs(e),s=[];for(let i of e.layers)for(let a of i)a.isVirtual||s.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:s,edges:n,width:r,height:o}}function ds(t){let e=new Map;for(let o of t.nodes)e.set(o,{id:o,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:t.widthCells(o),h:t.heightCells(o),in:[],out:[]});let n=[],r=0;for(let o of t.edges){if(o.from===o.to)continue;let s=e.get(o.from),i=e.get(o.to);if(!s||!i)continue;let a={chainId:r++,chainFrom:o.from,chainTo:o.to,fromId:o.from,toId:o.to,hopIndex:0,chainLen:1};s.out.push(a),i.in.push(a),n.push(a)}return{nodes:e,layers:[],hops:n}}function cs(t){let e=new Map;for(let s of t.nodes.values())e.set(s.id,s.in.length);let n=[];for(let s of t.nodes.values())(e.get(s.id)??0)===0&&(s.layer=0,n.push(s));let r=new Set,o=0;for(;o<n.length;){let s=n[o++];if(!r.has(s.id)){r.add(s.id);for(let i of s.out){let a=t.nodes.get(i.toId);a.layer=Math.max(a.layer,s.layer+1);let d=(e.get(a.id)??0)-1;e.set(a.id,d),d<=0&&n.push(a)}}}for(let s of t.nodes.values())s.layer<0&&(s.layer=0)}function ls(t){let e=Math.max(0,...Array.from(t.nodes.values(),s=>s.layer)),n=Array.from({length:e+1},()=>[]);for(let s of t.nodes.values())n[s.layer].push(s);let r=[],o=0;for(let s of t.hops){let i=t.nodes.get(s.fromId),a=t.nodes.get(s.toId),d=a.layer-i.layer;if(d<=0){i.out=i.out.filter(l=>l!==s),a.in=a.in.filter(l=>l!==s);continue}if(d===1){s.hopIndex=0,s.chainLen=1,r.push(s);continue}i.out=i.out.filter(l=>l!==s),a.in=a.in.filter(l=>l!==s);let u=i;for(let l=1;l<d;l+=1){let p=`__virt_${o++}__`,h={id:p,isVirtual:!0,layer:i.layer+l,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};t.nodes.set(p,h),n[h.layer].push(h);let f={chainId:s.chainId,chainFrom:s.chainFrom,chainTo:s.chainTo,fromId:u.id,toId:p,hopIndex:l-1,chainLen:d};u.out.push(f),h.in.push(f),r.push(f),u=h}let c={chainId:s.chainId,chainFrom:s.chainFrom,chainTo:s.chainTo,fromId:u.id,toId:a.id,hopIndex:d-1,chainLen:d};u.out.push(c),a.in.push(c),r.push(c)}for(let s of n)for(let i=0;i<s.length;i+=1)s[i].order=i;t.layers=n,t.hops=r}function fs(t){for(let n=0;n<4;n+=1){for(let r=1;r<t.layers.length;r+=1)Br(t,t.layers[r],"in"),It(t.layers[r]);for(let r=t.layers.length-2;r>=0;r-=1)Br(t,t.layers[r],"out"),It(t.layers[r])}for(let n=0;n<2;n+=1){let r=!1;for(let o=1;o<t.layers.length;o+=1){let s=t.layers[o];for(let i=0;i+1<s.length;i+=1){let a=Wr(t,s[i],s[i+1],"in");[s[i],s[i+1]]=[s[i+1],s[i]],It(s),Wr(t,s[i],s[i+1],"in")<a?r=!0:([s[i],s[i+1]]=[s[i+1],s[i]],It(s))}}if(!r)break}}function Br(t,e,n){let r=new Map;for(let o of e){let s=n==="in"?o.in:o.out;if(s.length===0){r.set(o.id,o.order);continue}let i=0,a=0;for(let d of s){let u=t.nodes.get(n==="in"?d.fromId:d.toId);u&&(i+=u.order,a+=1)}r.set(o.id,a===0?o.order:i/a)}e.sort((o,s)=>{let i=r.get(o.id),a=r.get(s.id);return i!==a?i-a:o.order-s.order})}function It(t){for(let e=0;e<t.length;e+=1)t[e].order=e}function Wr(t,e,n,r){let o=r==="in"?e.in:e.out,s=r==="in"?n.in:n.out,i=0;for(let a of o)for(let d of s){let u=t.nodes.get(r==="in"?a.fromId:a.toId)?.order??0,c=t.nodes.get(r==="in"?d.fromId:d.toId)?.order??0;(e.order<n.order&&u>c||e.order>n.order&&u<c)&&(i+=1)}return i}function ps(t,e){e.direction==="LR"?hs(t,e):gs(t,e)}function hs(t,e){let n=[],r=0;for(let o=0;o<t.layers.length;o+=1){n.push(r);let s=0;for(let i of t.layers[o])s=Math.max(s,i.w);r+=s+e.layerGap}for(let o=0;o<t.layers.length;o+=1)for(let s of t.layers[o])s.x=n[o];for(let o of t.layers){let s=0;for(let i of o)i.y=s,s+=i.h+e.nodeGap}Ur(t,e,"y")}function gs(t,e){let n=[],r=0;for(let o=0;o<t.layers.length;o+=1){n.push(r);let s=0;for(let i of t.layers[o])s=Math.max(s,i.h);r+=s+e.layerGap}for(let o=0;o<t.layers.length;o+=1)for(let s of t.layers[o])s.y=n[o];for(let o of t.layers){let s=0;for(let i of o)i.x=s,s+=i.w+e.nodeGap}Ur(t,e,"x")}function Ur(t,e,n){let r=s=>n==="y"?s.h:s.w,o=e.nodeGap;for(let s=0;s<2;s+=1){let i=s===0?t.layers.slice(1):t.layers.slice(0,-1).reverse();for(let a of i){let d=new Map;for(let c of a){let l=s===0?c.in:c.out;if(l.length===0)continue;let p=[];for(let f of l){let m=t.nodes.get(s===0?f.fromId:f.toId);if(!m)continue;let b=n==="y"?m.y:m.x;p.push(b+Math.floor(r(m)/2))}if(p.length===0)continue;p.sort((f,m)=>f-m);let h=p[Math.floor(p.length/2)];d.set(c.id,h-Math.floor(r(c)/2))}let u=0;for(let c of a){let l=d.get(c.id),p=n==="y"?c.y:c.x,f=Math.max(l??p,u);n==="y"?c.y=f:c.x=f,u=f+r(c)+o}}}}function ms(t,e){let n=new Map;for(let u of t.hops){let c=n.get(u.chainId);c?c.push(u):n.set(u.chainId,[u])}for(let u of n.values())u.sort((c,l)=>c.hopIndex-l.hopIndex);let r=e.direction==="LR",o=u=>r?u.x:u.y,s=u=>r?u.w:u.h,i=u=>r?u.y+Math.floor(u.h/2):u.x+Math.floor(u.w/2),a=new Map;for(let u=0;u+1<t.layers.length;u+=1){let c=t.layers[u],l=t.layers[u+1],p=0;for(let _ of c)p=Math.max(p,o(_)+s(_));let h=Number.POSITIVE_INFINITY;for(let _ of l)h=Math.min(h,o(_));let f=Number.isFinite(h)?h-1:p,m=Math.max(1,f-p+1),b=[];for(let _ of c)for(let O of _.out)b.push(O);b.sort((_,O)=>{let E=i(t.nodes.get(_.fromId)),w=i(t.nodes.get(O.fromId));if(E!==w)return E-w;let S=i(t.nodes.get(_.toId)),k=i(t.nodes.get(O.toId));return S-k});let T=[],x=new Map;for(let _ of b){let O=i(t.nodes.get(_.fromId)),E=i(t.nodes.get(_.toId)),w=Math.min(O,E),S=Math.max(O,E),k=-1;for(let M=0;M<T.length;M+=1){let G=T[M],L=!0;for(let U of G)if(U.lo<=S&&w<=U.hi){L=!1;break}if(L){G.push({lo:w,hi:S}),k=M;break}}k<0&&(T.push([{lo:w,hi:S}]),k=T.length-1),x.set(_,k)}let v=T.length,y=m>=Math.max(3,v+2),R=y?p+1:p,N=y?f-1:f,g=Math.max(1,N-R+1);for(let _ of b){let O=x.get(_),E;if(v<=1)E=R+Math.floor(g/2);else{let w=(g-1)/(v-1);E=R+Math.floor(O*w)}a.set(_,Math.max(p,Math.min(f,E)))}}let d=[];for(let[,u]of n){let c=[];for(let p=0;p<u.length;p+=1){let h=u[p],f=t.nodes.get(h.fromId),m=t.nodes.get(h.toId),b=a.get(h),T=f.isVirtual?o(f):o(f)+s(f),x=m.isVirtual?o(m):o(m)-1,v=i(f),y=i(m);p===0&&Lt(c,r,T,v),v!==y&&(Lt(c,r,b,v),Lt(c,r,b,y)),Lt(c,r,x,y)}let l=u[0];d.push({from:l.chainFrom,to:l.chainTo,points:ys(c)})}return d}function Lt(t,e,n,r){t.push(e?{x:n,y:r}:{x:r,y:n})}function ys(t){let e=[];for(let n of t){let r=e[e.length-1];(!r||r.x!==n.x||r.y!==n.y)&&e.push(n)}return e}function bs(t){let e=0,n=0;for(let r of t.layers)for(let o of r)e=Math.max(e,o.x+o.w),n=Math.max(n,o.y+o.h);return{width:e,height:n}}var vs=24,_s=4,Ts=1,xs=3;function Yr(t,e){let n=ws(e.direction),r=Math.max(3,e.maxLabelWidth??vs),o=e.asciiCharset??"unicode",s=Object.keys(t.nodes).sort(),i=new Set(s),a=t.edges.filter(h=>i.has(h.from)&&i.has(h.to)),d=new Map,u=new Map;for(let h of s){let f=Fr(h,r);d.set(h,f),u.set(h,Gt(f)+4)}let c=Kr({nodes:s,edges:a,widthCells:h=>u.get(h)??3,heightCells:()=>xs,layerGap:_s,nodeGap:Ts,direction:n}),l=jr(c,{charset:o,labelOf:h=>d.get(h)??h}),p=e.logger;return p&&p(l),l}function ws(t){if(t===void 0||t==="LR")return"LR";if(t==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(t)}`)}function Jr(t,e,n,r={}){let o=e in t.nodes,s=n in t.nodes;if(!o)return Pt(e,n,"no-such-from");if(!s)return Pt(e,n,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===n){if(r.findCycle===!0){let u=Es(t,e,r);if(u!=null)return u}let d=$t(e,t.nodes[e],0,r);return Ft(e,n,[d])}if(i===0)return Pt(e,n,"no-path");let a=Qr(t,e,n,i);return a.found?Ft(e,n,Xr(t,a.pathOrder,r)):Pt(e,n,a.truncated?"max-depth-exceeded":"no-path")}function Qr(t,e,n,r){let o=new Map,s=[{path:n,depth:0}],i=new Set([n]),a=0,d=!1;for(;a<s.length;){let l=s[a++];if(l.path===e)break;if(r!=null&&l.depth>=r){let m=t.nodes[l.path];m?.deps&&m.deps.length>0&&(d=!0);continue}let p=t.nodes[l.path];if(p==null)continue;let h=p.deps??[],f=new Map;for(let m=0;m<h.length;m++){let b=h[m];if(!b)continue;let T=f.get(b);T==null&&(T=[],f.set(b,T)),T.push(m)}for(let[m,b]of f)i.has(m)||(i.add(m),o.set(m,{from:l.path,depIndices:b}),s.push({path:m,depth:l.depth+1}))}if(!o.has(e))return{found:!1,pathOrder:[],truncated:d};let u=[{path:e}],c=e;for(;c!==n;){let l=o.get(c);if(l==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=l.depIndices,u.push({path:l.from}),c=l.from}return{found:!0,pathOrder:u,truncated:!1}}function Es(t,e,n){let r=t.nodes[e];if(r==null)return null;let o=r.deps??[],s=[];for(let a=0;a<o.length;a++)o[a]===e&&s.push(a);if(s.length>0){let a=$t(e,r,0,n);a.dep_index=s[0];let d=$t(e,r,1,n);return Ft(e,e,[a,d])}let i=null;for(let a=0;a<o.length;a++){let d=o[a];if(!d||d===e)continue;let u=Qr(t,d,e,n.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:Ft(e,e,Xr(t,i.pathOrder,n))}function Xr(t,e,n){return e.map((r,o)=>{let s=t.nodes[r.path],i=$t(r.path,s,o,n);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function $t(t,e,n,r){let o={path:t,type:e.type,hop:n};e.status!==void 0&&(o.status=e.status),"value"in e&&(o.value=e.value),e.v!=null&&(o.v=e.v);let s=r.annotations?.get(t)??e.annotation;s!=null&&(o.annotation=s);let i=r.lastMutations?.get(t)??e.lastMutation;return i!=null&&(o.lastMutation=i),o}function Ft(t,e,n){return Zr(t,e,!0,"ok",n)}function Pt(t,e,n){return Zr(t,e,!1,n,[])}function Zr(t,e,n,r,o){let s=Rs(t,e,n,r,o);return{from:t,to:e,found:n,reason:r,steps:o,text:s,toJSON(){return{from:t,to:e,found:n,reason:r,steps:o}}}}function Rs(t,e,n,r,o){if(!n)switch(r){case"no-such-from":return`explainPath: no node named "${t}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${t}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${t}" to "${e}"`}let s=[`Causal path: ${t} \u2192 ${e} (${o.length} step(s))`];for(let i of o){let d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(s.push(d),"value"in i&&s.push(` value: ${Ss(i.value)}`),i.annotation!=null&&s.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;s.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return s.join(`
11
+ `)}function Ss(t){if(t===void 0)return"<sentinel>";if(t===null)return"null";if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);try{let e=JSON.stringify(t);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(t)}}Ce();var B={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},Os=Symbol.for("sizeof");function eo(t){let e=new WeakSet,n=new WeakSet,r=[t],o=0;for(;r.length>0;){let s=r.pop();o+=Ns(s,e,n,r)}return o}function Ns(t,e,n,r){if(t==null)return 0;switch(typeof t){case"number":return B.number;case"boolean":return B.boolean;case"string":return B.string+t.length*2;case"bigint":return B.bigint+ks(t);case"symbol":return B.symbol;case"function":return e.has(t)?0:(e.add(t),B.function);case"undefined":return 0}let s=t;if(e.has(s))return 0;e.add(s);let i=s[Os];if(typeof i=="function")try{let u=i.call(s);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(s instanceof Date)return B.date;if(s instanceof RegExp)return B.regexp+s.source.length*2;if(s instanceof Error){let u=s.message?s.message.length*2:0,c=s.stack?s.stack.length*2:0;return B.error+u+c}if(typeof URL<"u"&&s instanceof URL)return B.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return B.promise;if(s instanceof WeakMap)return B.weakmap;if(s instanceof WeakSet)return B.weakset;if(s instanceof Map){let u=B.map;for(let[c,l]of s)u+=B.mapEntry,r.push(c),r.push(l);return u}if(s instanceof Set){let u=B.set;for(let c of s)u+=B.setEntry,r.push(c);return u}if(Array.isArray(s)){let u=B.array+s.length*8;for(let c of s)r.push(c);return u}if(s instanceof ArrayBuffer)return n.has(s)?0:(n.add(s),s.byteLength);if(ArrayBuffer.isView(s)){let u=s;return n.has(u.buffer)?48:(n.add(u.buffer),u.buffer.byteLength+48)}let a=B.object,d=Object.keys(s);for(let u of d){a+=B.string+u.length*2;try{r.push(s[u])}catch{}}return a}function ks(t){let e=t<0n?-t:t;if(e===0n)return 0;let n=e.toString(2).length;return Math.ceil(n/32)*8}function to(t,e){let n=e?.topN??10,r=t.describe({detail:"standard"}),o=[],s=t._collectObserveTargets;typeof s=="function"&&s.call(t,"",o);let i=new Map;for(let[p,h]of o)i.set(p,h);let a=[];for(let[p,h]of Object.entries(r.nodes)){let f=i.get(p),m=f instanceof V?f:null,b=m?eo(m.cache):0,T=m?m._sinkCount:0,x=h.deps?.length??0,v=h.type==="effect"&&T===0,y=T===0?h.type==="effect"?"orphan-effect":h.type==="derived"?"idle-derived":h.type==="producer"?"idle-producer":null:null;a.push({path:p,type:h.type,status:h.status??"unknown",valueSizeBytes:b,subscriberCount:T,depCount:x,isOrphanEffect:v,orphanKind:y})}let d=a.reduce((p,h)=>p+h.valueSizeBytes,0),u=(p,h)=>[...a].sort(h??((f,m)=>m[p]-f[p])).slice(0,n),c=a.filter(p=>p.orphanKind!=null),l=a.filter(p=>p.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:d,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:c,orphanEffects:l}}var H="::",ue="__meta__",Ge=1;function no(t,e){let n=Math.max(16,t.size*4),r=0;for(;t.size>0;){if(r++>=n){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${n}); ${t.size} disposer(s) discarded`),t.clear();return}let o=t.values().next();if(o.done)return;let s=o.value;t.delete(s);try{s()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function As(t){let e=[];for(let n of Object.keys(t).sort()){let r=t[n].v;r!=null&&e.push(`${n} ${r.id} ${r.version}`)}return e.join(`
12
+ `)}function ro(t){if(t.version!==Ge)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${Ge})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in t))throw new Error(`snapshot missing required key "${e}"`);if(typeof t.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof t.nodes!="object"||t.nodes===null||Array.isArray(t.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(t.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(t.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Cs(t,e){let n=new WeakMap,r=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=n.get(o);if(i==null&&(i=new WeakSet,n.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,d=s.constructor;if(a!==d)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let p=s;if(o.length!==p.length)return!1;for(let h=0;h<o.length;h++)if(!r(o[h],p[h]))return!1;return!0}if(o instanceof Map){let p=s;if(o.size!==p.size)return!1;for(let[h,f]of o)if(!p.has(h)||!r(f,p.get(h)))return!1;return!0}if(o instanceof Set){let p=s;if(o.size!==p.size)return!1;for(let h of o){let f=!1;for(let m of p)if(r(h,m)){f=!0;break}if(!f)return!1}return!0}if(ArrayBuffer.isView(o)){let p=o,h=s;if(p.length!==h.length)return!1;for(let f=0;f<p.length;f++)if(p[f]!==h[f])return!1;return!0}let u=Object.keys(o),c=Object.keys(s);if(u.length!==c.length)return!1;let l=new Set(c);for(let p of u)if(!l.has(p)||!r(o[p],s[p]))return!1;return!0};return r(t,e)}function _n(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(_n);let e=t,n=Object.keys(e).sort(),r={};for(let o of n)r[o]=_n(e[o]);return r}function Ms(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Ds(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Gs(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function so(t){let e=new Set,n=[];function r(o,s){let i=`${o}\0${s}`;e.has(i)||(e.add(i),n.push([o,s]))}for(let[o,s]of Object.entries(t.nodes)){let i=s.deps;if(i)for(let a of i)r(a,o)}for(let o of t.edges)r(o.from,o.to);return n}function io(t){if(t===void 0)return"LR";if(t==="TD"||t==="LR"||t==="BT"||t==="RL")return t;throw new Error(`invalid diagram direction ${String(t)}; expected one of: TD, LR, BT, RL`)}function Is(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,{expand:o,...s}=t,i={...s,edges:n?t.edges:[],subgraphs:r?t.subgraphs:[]},a=JSON.stringify(_n(i),null,e.indent??2);return e.logger?.(a),a}function Ls(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,o=[];o.push(`Graph ${t.name}`),o.push("Nodes:");for(let i of Object.keys(t.nodes).sort()){let a=t.nodes[i];o.push(`- ${i} (${a.type}/${a.status}): ${Vt(a.value)}`)}if(n){o.push("Edges:");for(let i of t.edges)o.push(`- ${i.from} -> ${i.to}`)}if(r){o.push("Subgraphs:");for(let i of t.subgraphs)o.push(`- ${i}`)}let s=o.join(`
13
+ `);return e.logger?.(s),s}function ao(t,e){let n=io(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`flowchart ${n}`];for(let i of r){let a=o.get(i);s.push(` ${a}["${Ms(i)}"]`)}for(let[i,a]of so(t)){let d=o.get(i),u=o.get(a);!d||!u||s.push(` ${d} --> ${u}`)}return s.join(`
14
+ `)}function Ps(t,e){let n=ao(t,e);return uo(n)}function uo(t,e){let n=e?.theme??"default",r=e?.autoSync??!0,s=JSON.stringify({code:t,mermaid:{theme:n},autoSync:r}),i=new TextEncoder().encode(s),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function $s(t,e){let n=io(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`direction: ${Gs(n)}`];for(let i of r){let a=o.get(i);s.push(`${a}: "${Ds(i)}"`)}for(let[i,a]of so(t)){let d=o.get(i),u=o.get(a);!d||!u||s.push(`${d} -> ${u}`)}return s.join(`
15
+ `)}function Fs(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ht(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let o=t.indexOf("]",n+1);if(o<=n+1){e+="\\[";continue}let s=t.slice(n+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,n=o;continue}e+=Fs(r)}return e+="$",new RegExp(e)}var Hs={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"},Vs={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function Vt(t){if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||t==null)return String(t);try{return JSON.stringify(t)}catch{return"[unserializable]"}}function qs(t){return t==="none"?Vs:t==="ansi"||t==null?Hs:{data:t.data??"",dirty:t.dirty??"",resolved:t.resolved??"",invalidate:t.invalidate??"",pause:t.pause??"",resume:t.resume??"",complete:t.complete??"",error:t.error??"",teardown:t.teardown??"",derived:t.derived??"",path:t.path??"",reset:t.reset??""}}function oo(t){if(t==null)return{};let e=t.detail;return e==="full"?{...t,structured:t.structured??!0,timeline:t.timeline??!0,causal:t.causal??!0,derived:t.derived??!0}:e==="minimal"?{...t,structured:t.structured??!0}:t.format==="stage-log"?{...t,structured:t.structured??!0,timeline:t.timeline??!0}:t}function js(t,e,n){for(let r=0;r<t.length;r++){let o=t.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function vn(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(H))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${H}' (path separator)`);if(t===ue)throw new Error(`Graph "${e}": ${n} name "${ue}" is reserved for meta companion paths`);js(t,e,n)}function zs(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(H);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function Bs(t,e){let n=!1;for(let o of t)if(!e.isMetaPassthrough(o[0])){n=!0;break}return n?t.filter(o=>e.isMetaPassthrough(o[0])):t}function co(t){for(let e of t._mounts.values())co(e);for(let e of t._nodes.values())try{e.down([[W]],{internal:!0})}catch{}}var X=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(H))throw new Error(`Graph name must not contain '${H}' (got "${e}")`);if(e===ue)throw new Error(`Graph name "${ue}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??Ae,this._traceRing=new ct(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=Ve(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}nameOf(e){return this._nodeToName.get(e)}add(e,n){let r=e.name,o=n?.name??r;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=n?.annotation;if(vn(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:Fe()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof V&&n._applyVersioning(e)}remove(e){vn(e,this.name,"remove");let n=this._mounts.get(e);if(n){let s={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,d]of i)a.includes(`${H}${ue}${H}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...n._collectSubgraphs(`${e}${H}`)),this._mounts.delete(e),n._parent=void 0,co(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[W]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let n=typeof e=="function"?e:(()=>{let s=Ht(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>n(s));for(let s of o){let i=this.remove(s);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let o=e[r++];return{value:[o,n.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(H))return this.resolve(e);let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return n}get(e){return this.node(e).cache}set(e,n,r){let o=r?.internal===!0;this.node(e).down([[A,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);le(()=>{for(let[o,s]of r)this.set(o,s,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[re]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let o=r?.internal===!0;this.node(e).down([[D,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[$]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[d,u]of this._nodes)r.set(u,d);let a=[];for(let[d,u]of this._nodes)if(u instanceof V)for(let c of u._deps){let l=r.get(c.node);l!=null&&a.push([l,d])}return a.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,d]of o)s.set(d,a);let i=[];for(let[a,d]of o)if(d instanceof V)for(let u of d._deps){let c=s.get(u.node);c!=null&&i.push([c,a])}return i.sort((a,d)=>a[0]<d[0]?-1:a[0]>d[0]?1:a[1]<d[1]?-1:a[1]>d[1]?1:0),i}mount(e,n){if(n===void 0){let o=new t(e);return this.mount(e,o)}if(typeof n=="function"){let o=new t(e);return n(o),this.mount(e,o)}let r=n;if(vn(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let o=this;o!=null;o=o._parent)if(o===r)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,r),r._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),r}resolve(e){let n=zs(e,this.name);return this._resolveFromSegments(n)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let n=e;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],o=n.slice(1);if(o.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let s=this._nodes.get(r);if(s&&o.length>0&&o[0]===ue)return this._resolveMetaChainFromNode(s,o,n.join(H));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(H)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(H))}_resolveMetaChainFromNode(e,n,r){let o=e,s=0,i=[...n];for(;s<i.length;){if(i[s]!==ue)throw new Error(`Graph "${this.name}": expected ${ue} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${ue} in "${r}"`);let a=i[s+1],d=o.meta[a];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=d,s+=2}return o}signal(e,n){if(n?.internal!==!0){for(let o of e)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,o){for(let d of this._mounts.values())d._signalDeliver(e,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=Bs(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(c){if(c instanceof ie)throw c;o.push(c)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,o)}}}_signalMetaSubtree(e,n,r,o,s){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,o)}catch(d){if(d instanceof ie)throw d;s.push(d)}this._signalMetaSubtree(a,n,r,o,s)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,o=Mt(e?.detail,e?.fields),s=e?.format==="spec",i=s?Mt("minimal"):o,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[N,g]of a)d.set(g,N);let u=[];{let N=a.map(([,O])=>O),g=new Set(d.values()),_=0;for(;N.length>0;){let O=N.shift();if(O instanceof V)for(let E of O._deps){let w=E.node;if(d.has(w))continue;let S=w.name??"",k=S;if(!k||g.has(k))if(S){let M=2;for(;g.has(`${S}#${M}`);)M++;k=`${S}#${M}`}else for(k=`__internal__/${_++}`;g.has(k);)k=`__internal__/${_++}`;d.set(w,k),g.add(k),u.push([k,w]),N.push(w)}}}let c=[...a,...u],l={};for(let[N,g]of c){if(n!=null&&!g.allowsObserve(n))continue;let _=yn(g,i),O=g instanceof V?g._deps.map(k=>d.get(k.node)??k.node.name??""):[],{name:E,...w}=_,S={...w,deps:O};if(!s){let k=this._annotations.get(N);k!=null&&(S.annotation=k)}if(r!=null)if(typeof r=="function"){let k=r;if(!(k.length>=2?k(N,S):k(S)))continue}else{let k=!0;for(let[M,G]of Object.entries(r)){let L=M==="deps_includes"?"depsIncludes":M==="meta_has"?"metaHas":M;if(L==="depsIncludes"){if(!S.deps.includes(String(G))){k=!1;break}continue}if(L==="metaHas"){if(!Object.hasOwn(S.meta??{},String(G))){k=!1;break}continue}if(S[L]!==G){k=!1;break}}if(!k)continue}l[N]=S}let p=new Set(Object.keys(l)),h=[];for(let[N,g]of c)if(g instanceof V)for(let _ of g._deps){let O=d.get(_.node);O!=null&&h.push([O,N])}h.sort((N,g)=>N[0]<g[0]?-1:N[0]>g[0]?1:N[1]<g[1]?-1:N[1]>g[1]?1:0);let f=h.map(([N,g])=>({from:N,to:g}));(n!=null||r!=null)&&(f=f.filter(N=>p.has(N.from)&&p.has(N.to)));let m=this._collectSubgraphs(""),b=n!=null||r!=null?m.filter(N=>{let g=`${N}${H}`;return[...p].some(_=>_===N||_.startsWith(g))}):m,T=this,x=e,v={name:this.name,nodes:l,edges:f,subgraphs:b,expand(N){let g={...x,format:void 0};return Array.isArray(N)?(g.fields=N,g.detail=void 0):(g.detail=N,g.fields=void 0),T.describe(g)}},y=e??{},R=y.format;return R==="json"?Is(v,y):R==="pretty"?Ls(v,y):R==="mermaid"?ao(v,y):R==="mermaid-url"?Ps(v,y):R==="d2"?$s(v,y):R==="ascii"?Yr(v,y):v}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;n.push(o),n.push(...this._mounts.get(r)._collectSubgraphs(`${o}${H}`))}return n}resourceProfile(e){return to(this,e)}reachable(e,n,r={}){return r.withDetail===!0?Tn(this.describe(),e,n,{...r,withDetail:!0}):Tn(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,d]of Object.entries(o.nodes))d.lastMutation!=null&&i.set(a,d.lastMutation);return Jr(o,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=q(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,rt(()=>{a=!1,!d&&(o+=1,s.emit(o))}))},c=i.onEvent(b=>{let T=b.type;T!=="data"&&T!=="error"&&T!=="complete"&&T!=="teardown"||u()}),l=[],p=new WeakSet,h=b=>{if(p.has(b)||d)return;p.add(b);let T=b.topology.subscribe(x=>{for(let v of x){if(v[0]!==A)continue;let y=v[1];if(u(),y.kind==="added"&&y.nodeKind==="mount"){let R=b._mounts.get(y.name);R!=null&&h(R)}}});l.push(T);for(let x of b._mounts.keys()){let v=b._mounts.get(x);v!=null&&h(v)}};h(this);let f;try{f=J([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,T)=>b===T})}catch(b){c();for(let T of l)T();throw i.dispose(),b}let m=he(f);return{node:f,dispose(){d=!0,c();for(let b of l)b();l.length=0,i.dispose(),m()}}}_explainReactive(e,n,r){let o=0,s=q(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(h=>{let f=h.type;f!=="data"&&f!=="error"&&f!=="complete"&&f!=="teardown"||a||d||(a=!0,rt(()=>{a=!1,!d&&(o+=1,s.emit(o))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},l;try{l=J([s],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(h,f)=>h.found===f.found&&h.reason===f.reason&&h.steps.length===f.steps.length&&Ws(h.steps,f.steps)})}catch(h){throw u(),i.dispose(),h}let p=he(l);return{node:l,dispose(){d=!0,u(),i.dispose(),p()}}}_pathsMatching(e){let n=Ht(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>n.test(o))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${H}${r}`;this._mounts.get(r)._collectObserveTargets(o,n)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${H}${r}`;n.push([s,o]),this._appendMetaObserveTargets(s,o,n)}}_appendMetaObserveTargets(e,n,r){for(let o of Object.keys(n.meta).sort()){let s=n.meta[o],i=`${e}${H}${ue}${H}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,n){let r=typeof e=="string",s=oo(r?n:e),i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let c=e,l=this.resolve(c);if(a!=null&&!l.allowsObserve(a))throw new ie({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,l]],s,"one"):{subscribe(p){return l.subscribe(p)},up(p){try{l.up?.(p)}catch(h){if(h instanceof ie)return;throw h}}}}let d=[];this._collectObserveTargets("",d),d.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let u=a==null?d:d.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:c=>{let l=u.map(([p,h])=>h.subscribe(f=>{c(p,f)}));return()=>{for(let p of l)p()}},up:(c,l)=>{try{this.resolve(c).up?.(l)}catch(p){if(p instanceof ie)return;throw p}}}}_buildStructuredObserver(e,n,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let c=this.resolve(o);return this._buildStructuredObserver([[o,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let d=i.actor,u=d==null?a:a.filter(([,c])=>c.allowsObserve(d));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,s)}_createObserveResult(e,n,r){let o=n.timeline===!0,s=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",d=this.config.inspectorEnabled,u=(s||i)&&d,c=n.maxEvents,l=c!=null&&c>0?new ct(c):null,p=[],h=new Set,f={},m=new Set,b=0,T=0,x=0,v=0,y=0,R=0,N=!1,g=!1,_=0,O=new Map,E=new Map,w=new Map,S=C=>{l?l.push(C):p.push(C);for(let F of h)F(C)},k=()=>o?{timestamp_ns:Fe(),in_batch:Tt(),batch_id:_}:{},M=(C,F)=>{if(!(!u||!(C instanceof V)))return C._setInspectorHook(te=>{if(te.kind==="dep_message")O.set(C,te.depIndex);else if(te.kind==="run"){let Qe=te.batchData.map((I,Y)=>I!=null&&I.length>0?I.at(-1):te.prevData[Y]);E.set(C,Qe);let ne=te.batchData.map(I=>I!=null?[...I]:void 0);w.set(C,ne),i&&S({type:"derived",path:F,dep_values:Qe,dep_batches:ne,...k()})}})},G=C=>{let F=O.get(C),te=E.get(C);if(!s||te==null)return{};let ne=(F!=null&&F>=0&&C instanceof V?C._deps[F]:void 0)?.node,I=ne?.v,Y=w.get(C);return{trigger_dep_index:F,trigger_dep_name:ne?.name,...I!=null?{trigger_version:{id:I.id,version:I.version}}:{},dep_values:[...te],...Y!=null?{dep_batches:Y}:{}}},L=[],U=[];for(let[C,F]of e){let te=M(F,C);te&&L.push(te),U.push(F.subscribe(Qe=>{_++;for(let ne of Qe){let I=ne[0],Y=k();if(I===A){f[C]=ne[1];let Yt=F instanceof V?F.lastMutation?.actor??ye:ye;S({type:"data",path:C,data:ne[1],actor:Yt,...Y,...G(F)})}else if(a)I===P?b++:I===z?T++:I===re?x++:I===ee?v++:I===oe?y++:I===W?R++:I===$&&!m.has(C)?N=!0:I===D&&(g=!0,m.add(C));else if(I===P)b++,S({type:"dirty",path:C,...Y});else if(I===z)T++,S({type:"resolved",path:C,...Y,...G(F)});else if(I===re)x++,S({type:"invalidate",path:C,...Y});else if(I===ee)v++,S({type:"pause",path:C,lockId:ne[1],...Y});else if(I===oe)y++,S({type:"resume",path:C,lockId:ne[1],...Y});else if(I===$)m.has(C)||(N=!0),S({type:"complete",path:C,...Y});else if(I===D){g=!0,m.add(C);let Yt=F instanceof V?F.lastMutation?.actor??ye:ye;S({type:"error",path:C,data:ne[1],actor:Yt,...Y})}else I===W&&(R++,S({type:"teardown",path:C,...Y}))}}))}let Te=!1,xe=()=>{if(!Te){Te=!0;for(let C of U)C();for(let C of L)C();for(let C of Ie)C({value:void 0,done:!0});Ie.length=0}},Je=[],Ie=[];h.add(C=>{let F=Ie.shift();F?F({value:C,done:!1}):Je.push(C)});let Pn={get values(){return f},get dirtyCount(){return b},get resolvedCount(){return T},get invalidateCount(){return x},get pauseCount(){return v},get resumeCount(){return y},get teardownCount(){return R},get events(){return l?l.toArray():[...p]},get anyCompletedCleanly(){return N},get anyErrored(){return g},get completedWithoutErrors(){return N&&!g},onEvent(C){return h.add(C),()=>h.delete(C)},dispose:xe,expand(C){xe();let F={...n};return typeof C=="string"?F.detail=C:Object.assign(F,C),r(oo(F))},[Symbol.asyncIterator](){return{next(){return Je.length>0?Promise.resolve({value:Je.shift(),done:!1}):Te?Promise.resolve({value:void 0,done:!0}):new Promise(C=>Ie.push(C))},return(){return xe(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Pn,n),Pn}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let o=n.logger??(f=>console.log(f)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:f=>(s==null||s.has(f))&&(i==null||!i.has(f)),d=qs(n.theme),u=r==="stage-log"?Fe():0,c=f=>f==null?"":n.stageLabels?.[f]??f,l=(f,m)=>f.length>m?`${f.slice(0,m-1)}\u2026`:f,p=f=>f.type==="data"||f.type==="error"?l(Vt(f.data),120):"",h=f=>{if(r==="stage-log"){let g=(Fe()-u)/1e9,_=c(f.path).padEnd(9);if(f.type==="data"){let O=p(f);return`[${g.toFixed(3)}s] ${_} \u2190${O?` ${O}`:""}`}if(f.type==="error"){let O=p(f);return`[${g.toFixed(3)}s] ${_} \u2717${O?` ${O}`:""}`}return f.type==="complete"?`[${g.toFixed(3)}s] ${_} \u25A0 complete`:`[${g.toFixed(3)}s] ${_} ${f.type}`}if(r==="json")try{return JSON.stringify(f)}catch{return JSON.stringify({type:f.type,path:f.path,data:"[unserializable]"})}let m=d[f.type]??"",b=f.path?`${d.path}${f.path}${d.reset} `:"",T=f.type==="data"||f.type==="error",x=f.type==="pause"||f.type==="resume",v=T?` ${Vt(f.data)}`:x?` ${Vt(f.lockId)}`:"",y=f.type==="data"||f.type==="resolved"||f.type==="derived"?f:void 0,R=y?.trigger_dep_name!=null?` <- ${y.trigger_dep_name}`:y?.trigger_dep_index!=null?` <- #${y.trigger_dep_index}`:"",N=f.in_batch?" [batch]":"";return`${b}${m}${f.type.toUpperCase()}${d.reset}${v}${R}${N}`};e.onEvent(f=>{a(f.type)&&o(h(f),f)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){no(this._disposers,this.name),this.signal([[W]],{internal:!0}),no(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:n,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:d,guard:u,...c}=r.nodes[a];o[a]=c}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return Qn(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??Ae,{codec:o,codecVersion:s,payload:i}=Xn(e,r);return o.decode(i,s)}restore(e,n){if(ro(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(s=>Ht(s)),o=n?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let d=this.tryResolve(s)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(e,n){ro(e);let r=typeof n=="function"?n:n?.build,o=typeof n=="function"?void 0:n?.factories,s=new t(e.name);if(r)return r(s),s.restore(e),s;for(let h of[...e.subgraphs].sort((f,m)=>{let b=f.split(H).length,T=m.split(H).length;return b!==T?b-T:f<m?-1:f>m?1:0})){let f=h.split(H),m=s;for(let b of f)m._mounts.has(b)||m.mount(b,new t(b)),m=m._mounts.get(b)}let i=o?Object.entries(o).map(([h,f])=>({re:Ht(h),factory:f})):[],a=h=>{for(let f of i)if(f.re.test(h))return f.factory},d=h=>{let f=h.split(H),m=f.pop();if(m==null||m.length===0)throw new Error(`invalid snapshot path "${h}"`);let b=s;for(let T of f){let x=b._mounts.get(T);if(!x)throw new Error(`unknown mount "${T}" in path "${h}"`);b=x}return[b,m]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${H}${ue}${H}`)).sort((h,f)=>h[0]<f[0]?-1:h[0]>f[0]?1:0),c=new Map(u),l=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[h,f]of[...c.entries()]){let m=f?.deps??[];if(!m.every(R=>l.has(R)))continue;let[b,T]=d(h),x={...f?.meta??{}},v=a(h),y;if(f?.type==="state")y=q(f.value,{meta:x});else{if(v==null)continue;y=v(T,{path:h,type:f.type,value:f.value,meta:x,deps:m,resolvedDeps:m.map(R=>l.get(R))})}b.add(y,{name:T}),l.set(h,y),c.delete(h),p=!0}}if(c.size>0){let h=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachSnapshotStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let o=(u,c)=>{if(u.disposed)return;let l=As(c.nodes);if(u.lastSnapshot!=null&&l!==""&&l===u.lastFingerprint)return;let p=u.seq+1,h=se(),b=u.lastSnapshot==null||p%u.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:p,timestamp_ns:h,format_version:Ge}:{name:this.name,mode:"diff",diff:lo(u.lastSnapshot,c),seq:p,timestamp_ns:h,format_version:Ge};if(u.tier.filter&&!u.tier.filter(b))return;let T;try{T=u.tier.save(b)}catch(x){n.onError?.(x,u.tier);return}if(T&&typeof T.then=="function"){let y=(u.savePending??Promise.resolve()).then(()=>T,()=>T).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=c,u.lastFingerprint=l)},R=>{n.onError?.(R,u.tier)});u.savePending=y.finally(()=>{u.savePending===y&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=c,u.lastFingerprint=l},s=(u,c)=>{try{o(u,c)}catch(l){n.onError?.(l,u.tier)}},i=(u,c)=>{if(!c.some(f=>{let m=this.config.messageTier(f[0]);return m>=3&&m<5}))return;if(n.filter){let f=this.tryResolve(u);if(f==null)return;let m=yn(f,Mt("standard"));if(!n.filter(u,m))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let f of r)f.disposed||(f.debounceMs===0?s(f,h()):(f.timer==null&&(f.timer=new Dt),f.timer.start(f.debounceMs,()=>{f.disposed||s(f,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(l=>{let p=this.tryResolve(l);return p==null?()=>{}:p.subscribe(h=>i(l,h))});a=()=>{for(let l of c)l()}}else a=this.observe().subscribe((u,c)=>i(u,c));let d=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,n){for(let r of e){let o;try{o=await r.load?.()}catch(i){n?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===Ge&&s.nodes!=null)return this.restore(s),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let o of n){let s;try{s=await o.load?.()}catch(d){r?.onError?.(d,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===Ge&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(d){r?.onError?.(d,o)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,n,r){if(e!=null&&n!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,n),this.config.inspectorEnabled){let o={path:e,annotation:n,timestamp_ns:Fe(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(o=>!e(o)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let o of n)this._traceRing.push(o);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(n.nodes)),s=[...o].filter(x=>!r.has(x)).sort(),i=[...r].filter(x=>!o.has(x)).sort(),a=[],d=[];for(let x of r){if(!o.has(x))continue;let v=e.nodes[x],y=n.nodes[x],R=v.v,N=y.v;R!=null&&N!=null&&R.id===N.id&&R.version!==N.version&&d.push({path:x,id:R.id,from:R.version,to:N.version});let g=R!=null&&N!=null&&R.id===N.id&&R.version===N.version;for(let _ of["type","status","sentinel"]){let O=v[_],E=y[_];O!==E&&a.push({path:x,field:_,from:O,to:E})}if(!g)for(let _ of["value","meta"]){let O=v[_],E=y[_];Cs(O,E)||a.push({path:x,field:_,from:O,to:E})}}let u=x=>`${x.from} ${x.to}`,c=new Set(e.edges.map(u)),l=new Set(n.edges.map(u)),p=n.edges.filter(x=>!c.has(u(x))),h=e.edges.filter(x=>!l.has(u(x))),f=new Set(e.subgraphs),m=new Set(n.subgraphs),b=[...m].filter(x=>!f.has(x)).sort(),T=[...f].filter(x=>!m.has(x)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:p,edgesRemoved:h,subgraphsAdded:b,subgraphsRemoved:T}}};function lo(t,e){let n=X.diff(t,e),r={};for(let o of n.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...n,nodesAddedFull:r}}function Tn(t,e,n,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,d=new Map,u=new Map,c=new Set;for(let[v,y]of Object.entries(t.nodes)){if(!v)continue;c.add(v);let R=y.deps??[];i.set(v,R);for(let N of R)N&&(c.add(N),a.has(N)||a.set(N,new Set),a.get(N).add(v))}for(let v of t.edges){if(v==null||typeof v!="object")continue;let y=typeof v.from=="string"?v.from:"",R=typeof v.to=="string"?v.to:"";!y||!R||(c.add(y),c.add(R),u.has(y)||u.set(y,new Set),u.get(y).add(R),d.has(R)||d.set(R,new Set),d.get(R).add(y))}if(!c.has(e))return r.withDetail?o:[];let l=r.both===!0,p=v=>{if(l){let g=i.get(v)??[],_=d.get(v),O=a.get(v),E=u.get(v),w=[...g];return _&&w.push(..._),O&&w.push(...O),E&&w.push(...E),w}if(n==="upstream"){let g=i.get(v)??[],_=d.get(v);return _?[...g,..._]:g}let y=a.get(v),R=u.get(v),N=y?[...y]:[];return R&&N.push(...R),N},h=new Set([e]),f=new Map,m=[{path:e,depth:0}],b=0,T=!1;for(;b<m.length;){let v=m[b++];if(s!=null&&v.depth>=s){p(v.path).length>0&&(T=!0);continue}for(let y of p(v.path))!y||h.has(y)||(h.add(y),f.set(y,v.depth+1),m.push({path:y,depth:v.depth+1}))}let x=[...f.keys()].sort((v,y)=>v<y?-1:v>y?1:0);return r.withDetail?{paths:x,depths:f,truncated:T}:x}function Ws(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],o=e[n];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}Ne();ot();ke();et();ke();K();Ce();fe();Ne();K();Ce();fe();var xn=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,n){if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=n,n!==void 0){if(this._buf=new Array(n),e&&e.length>0){let r=Math.min(e.length,n),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._size+e;if(!(n<0||n>=this._size))return this._maxSize!==void 0?this._buf[(this._head+n)%this._maxSize]:this._buf[n]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=n;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let n=0;n<e;n++)this._buf[(this._head+n)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let n=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,n);else{for(let r=0;r<n;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+n)%this._maxSize}return this._size-=n,this._version+=1,n}slice(e,n){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(n!==void 0&&(!Number.isInteger(n)||n<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${n})`);let r=n===void 0?this._size:Math.min(Math.max(n,0),this._size),o=Math.min(e,this._size);if(o>=r)return[];let s=r-o;if(this._maxSize===void 0)return this._buf.slice(o,r);let i=new Array(s);for(let a=0;a<s;a++)i[a]=this._buf[(this._head+o+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let n=Math.min(e,this._size);return this.slice(this._size-n,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this._buf[(this._head+n)%this._maxSize];return e}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let n=0;n<e.length;n++)this._buf.push(e[n]);this._size=this._buf.length}else{let n=this._maxSize;for(let s=0;s<n;s++)this._buf[s]=void 0;this._head=0;let r=Math.min(e.length,n),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function lt(t){return t.subscribe(()=>{})}var Ks=64;function ft(t,e={}){let{name:n,maxSize:r,versioning:o,guard:s,backend:i}=e,a=i??new xn(t,r),d=q(a.toArray(),{name:n,describeKind:"state",equals:(g,_)=>g===_,...o!=null?{versioning:o}:{},...s!=null?{guard:s}:{}});function u(){let g=a.toArray();le(()=>{d.down([[P]],{internal:!0}),d.down([[A,g]],{internal:!0})})}let c=new Map,l=new Map,p=new Map;function h(g,_){return`${g}:${_===void 0?"END":_}`}function f(g){if(g.size<Ks)return;let _=g.keys().next();if(_.done)return;let O=g.get(_.value);O!==void 0&&O.dispose(),g.delete(_.value)}function m(g){let _=a.version;try{return g()}finally{a.version!==_&&u()}}function b(g){if(!Number.isInteger(g)||g<0)throw new RangeError(`tail: n must be a non-negative integer (got ${g})`);let _=c.get(g);if(_!==void 0)return c.delete(g),c.set(g,_),_.node;f(c);let O=J([d],([w])=>{let S=w;return g===0||S.length===0?[]:S.slice(Math.max(0,S.length-g))},{initial:a.tail(g),describeKind:"derived"}),E=lt(O);return c.set(g,{node:O,dispose:E}),O}function T(g,_){if(!Number.isInteger(g)||g<0)throw new RangeError(`slice: start must be a non-negative integer (got ${g})`);if(_!==void 0&&(!Number.isInteger(_)||_<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${_})`);let O=h(g,_),E=l.get(O);if(E!==void 0)return l.delete(O),l.set(O,E),E.node;f(l);let w=J([d],([k])=>{let M=k;return _===void 0?M.slice(g):M.slice(g,_)},{initial:a.slice(g,_),describeKind:"derived"}),S=lt(w);return l.set(O,{node:w,dispose:S}),w}function x(g){let _=p.get(g);if(_!==void 0)return _.node;let O=J([d,g],([w,S])=>{let k=w,M=Math.max(0,Math.trunc(S??0));return k.slice(M)},{initial:[],describeKind:"derived"}),E=lt(O);return p.set(g,{node:O,dispose:E}),O}let v,y;function R(){v===void 0&&(v=pe([d],(g,_,O)=>{let E=g[0],S=E!=null&&E.length>0?E.at(-1):O.prevData[0];if(S==null||S.length===0){_.down([[z]]);return}_.emit(S[S.length-1])},{name:n!=null?`${n}::lastValue`:"lastValue",describeKind:"derived",initial:a.size===0?void 0:a.at(a.size-1)}),y=J([d],([g])=>g.length>0,{name:n!=null?`${n}::hasLatest`:"hasLatest",describeKind:"derived",initial:a.size>0}),lt(v),lt(y))}let N={entries:d,get size(){return a.size},at(g){return a.at(g)},append(g){m(()=>a.append(g))},appendMany(g){g.length!==0&&m(()=>a.appendMany(g))},clear(){m(()=>a.clear())},trimHead(g){m(()=>a.trimHead(g))},withLatest(){return R(),d},get lastValue(){return R(),v},get hasLatest(){return R(),y},view(g){switch(g.kind){case"tail":return b(g.n);case"slice":return T(g.start,g.stop);case"fromCursor":return x(g.cursor)}},attach(g){let _=g.subscribe(O=>{for(let E of O)E[0]===A&&N.append(E[1])});return()=>_()},attachStorage(g){if(g.length===0)return()=>{};let _=new Map;for(let E of g)_.set(E,a.size);(async()=>{for(let E of g)if(typeof E.loadEntries=="function")try{let w=await Promise.resolve(E.loadEntries());w.entries.length>0&&a.size===0&&(a.restore(w.entries),_.set(E,w.entries.length),u());break}catch{}})();let O=d.subscribe(E=>{for(let w of E){if(w[0]!==A)continue;let S=w[1];for(let k of g){let M=_.get(k)??0;if(S.length<M){try{let L=k.appendEntries(S);L instanceof Promise&&L.catch(()=>{})}catch{}_.set(k,S.length);continue}if(S.length===M)continue;let G=S.slice(M);_.set(k,S.length);try{let L=k.appendEntries(G);L instanceof Promise&&L.catch(()=>{})}catch{}}}});return()=>O()},disposeAllViews(){for(let g of c.values())g.dispose();c.clear();for(let g of l.values())g.dispose();l.clear();for(let g of p.values())g.dispose();p.clear()},dispose(){for(let g of c.values())g.dispose();c.clear();for(let g of l.values())g.dispose();l.clear();for(let g of p.values())g.dispose();p.clear()}};return N}var ve=class extends Error{constructor(e,n){super(e,n),this.name=this.constructor.name}},qt=class extends ve{constructor(n,r){super(`Duplicate ${n} registration: "${r}"`);this.kind=n;this.registrationName=r}},jt=class extends ve{constructor(n,r,o){super(`Command "${n}" emitted undeclared event "${r}". Declared emits: [${o.join(", ")}]`);this.commandName=n;this.eventName=r;this.declaredEmits=o}},zt=class extends ve{constructor(n,r,o){super(`Optimistic concurrency conflict on aggregate "${n}": expected version ${r}, got ${o}`);this.aggregateId=n;this.expected=r;this.actual=o}},Bt=class extends ve{constructor(n){super(`Unknown command: "${n}". Register with command() first.`);this.commandName=n}},pt=class extends ve{constructor(n,r){super(`Command handler "${n}" threw: ${r instanceof Error?r.message:String(r)}`,{cause:r});this.commandName=n}};var ht=class extends ve{constructor(n,r){super(`Projection "${n}" rebuild failed: ${r instanceof Error?r.message:String(r)}`,{cause:r});this.projectionName=n}};ke();fe();var Us=He((t,e)=>{t("observe"),t("signal"),e("write")});function Wt(t){let e=ft([],{name:t.name,maxSize:t.retainedLimit??1024,guard:t.guard??Us,...t.versioning!=null?{versioning:t.versioning}:{}});return e.withLatest(),t.graph&&t.graph.add(e.entries,{name:t.name}),e}function fo(t,e,n=0){let r=q(n,{name:e,describeKind:"state"});return t.add(r,{name:e}),r}function po(t,e,n,r=0){let o={},s=new X(e);for(let i of n){let a=q(r,{name:i,describeKind:"state"});s.add(a,{name:i}),o[i]=a}return t.mount(e,s),o}Nt();function ho(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}var Ys=He((t,e)=>{t("write"),t("signal"),e("observe")}),Js=He((t,e)=>{t("observe"),t("signal"),e("write")}),go=He((t,e)=>{t("observe"),t("signal"),e("write")});function gt(t,e){return ho("cqrs",t,e)}function wn(t){if(t===null||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.keys(t))wn(t[e]);return Object.freeze(t)}var En=class extends X{_eventLogs=new Map;_eventLogsByAggregate=new Map;_aggregateVersions=new Map;_aggregateLru=new Map;_commandRegs=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_seq=0;_retainedLimit;_freezeCommandPayload;_freezeEventPayload;_maxAggregates;_dispatchSeqCursor;dispatches;audit;aggregateEvictions;constructor(e,n={}){super(e,n.graph),this._retainedLimit=n.retainedLimit??1024,this._freezeCommandPayload=n.freezeCommandPayload??!0,this._freezeEventPayload=n.freezeEventPayload??!0,this._maxAggregates=n.maxAggregates??1e4,this.dispatches=Wt({name:"dispatches",retainedLimit:this._retainedLimit,graph:this}),this.audit=this.dispatches,this.aggregateEvictions=Wt({name:"aggregateEvictions",retainedLimit:this._retainedLimit,graph:this}),this._dispatchSeqCursor=fo(this,"dispatch_seq",0)}aggregateVersion(e,n){return this._aggregateVersions.get(`${e}::${n}`)??0}_touchAggregate(e){this._aggregateLru.delete(e),this._aggregateLru.set(e,!0)}_enforceAggregateLru(){for(;this._aggregateLru.size>this._maxAggregates;){let e=this._aggregateLru.keys().next();if(e.done)break;let n=e.value;this._aggregateLru.delete(n);let r=n.indexOf("::");if(r<0)continue;let o=n.slice(0,r),s=n.slice(r+2),i=this._aggregateVersions.get(n)??0;this._aggregateVersions.delete(n);let a=this._eventLogsByAggregate.get(o);a&&(a.delete(s),a.size===0&&this._eventLogsByAggregate.delete(o)),this.aggregateEvictions.append({aggregateId:s,type:o,lastVersion:i,t_ns:se()})}}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}_attachedEventTiers=[];_attachedTierDisposers=new Map;attachEventStorage(e){this._attachedEventTiers.push(e);for(let[n,r]of this._eventLogs){let o=r.log.attachStorage(e),s=this._attachedTierDisposers.get(n);s||(s=[],this._attachedTierDisposers.set(n,s)),s.push(o)}for(let[n,r]of this._eventLogsByAggregate)for(let[o,s]of r){let i=`${n}::${o}`,a=s.log.attachStorage(e),d=this._attachedTierDisposers.get(i);d||(d=[],this._attachedTierDisposers.set(i,d)),d.push(a)}return()=>{let n=this._attachedEventTiers.indexOf(e);n>=0&&this._attachedEventTiers.splice(n,1)}}_autoWireStreamStorage(e,n){if(this._attachedEventTiers.length===0)return;let r=this._attachedTierDisposers.get(e);r||(r=[],this._attachedTierDisposers.set(e,r));for(let o of this._attachedEventTiers)r.push(n.attachStorage(o))}_bumpDispatchSeq(){let n=(this._dispatchSeqCursor.cache??0)+1;return this._dispatchSeqCursor.emit(n),n}event(e,n){if(n!==void 0)return this._ensureAggregateStream(e,n).node;let r=this._eventLogs.get(e);if(r)return r.node;let o=ft([],{name:e,versioning:0,maxSize:this._retainedLimit});o.withLatest();let s=o.entries,i=J([s],([a])=>a,{name:e,describeKind:"state",meta:gt("event",{event_name:e}),guard:go,initial:s.cache});return this.add(i,{name:e}),this._keepaliveDisposers.push(he(i)),this._eventLogs.set(e,{log:o,node:i}),this._autoWireStreamStorage(e,o),i}_ensureAggregateStream(e,n){this._eventLogs.has(e)||this.event(e);let r=this._eventLogsByAggregate.get(e);r||(r=new Map,this._eventLogsByAggregate.set(e,r));let o=`${e}::${n}`;this._touchAggregate(o);let s=r.get(n);if(s)return s;let i=`${e}_${n.replace(/[^a-zA-Z0-9_-]/g,"_")}`,a=ft([],{name:i,versioning:0,maxSize:this._retainedLimit});a.withLatest();let d=a.entries,u=J([d],([h])=>h,{name:i,describeKind:"state",meta:gt("event_aggregate",{event_name:e,aggregate_id:n}),guard:go,initial:d.cache}),c=i,l=0;for(;this.nameOf(this.resolveOptional(c)??u)===c&&(l+=1,c=`${i}_${l}`,this.resolveOptional(c)!==void 0););try{this.add(u,{name:c})}catch{}this._keepaliveDisposers.push(he(u));let p={log:a,node:u};return r.set(n,p),this._autoWireStreamStorage(`${e}::${n}`,a),this._enforceAggregateLru(),p}resolveOptional(e){try{return this.resolve(e)}catch{return}}_appendEvent(e,n,r){let o=this._eventLogs.get(e);if(o||(this.event(e),o=this._eventLogs.get(e)),o.node.status==="completed"||o.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${o.node.status}).`);let s,i;if(r?.aggregateId!==void 0){let c=`${e}::${r.aggregateId}`;s=(this._aggregateVersions.get(c)??0)+1,this._aggregateVersions.set(c,s),i=this._ensureAggregateStream(e,r.aggregateId)}let a=o.log.entries.v,d=this._freezeEventPayload?wn(n):n,u={type:e,payload:d,timestampNs:se(),seq:++this._seq,...r?.aggregateId!==void 0?{aggregateId:r.aggregateId}:{},...s!==void 0?{aggregateVersion:s}:{},...r?.correlationId!==void 0?{correlationId:r.correlationId}:{},...r?.causationId!==void 0?{causationId:r.causationId}:{},...r?.metadata!==void 0?{metadata:Object.freeze({...r.metadata})}:{},...r?.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{},...a!=null?{v0:{id:a.id,version:a.version}}:{}};return o.log.append(u),i&&i.log.append(u),u}command(e,n){if(this._commandRegs.has(e))throw new qt("command",e);let r=typeof n=="function"?{handler:n}:n,o=q(void 0,{name:e,describeKind:"state",meta:{...gt("command",{command_name:e}),error:null},guard:Ys});if(this.add(o,{name:e}),this._commandRegs.set(e,{handler:r.handler,...r.emits!==void 0?{emits:r.emits}:{},...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),r.emits)for(let s of r.emits)this._eventLogs.has(s)||this.event(s);return o}dispatch(e,n,r){let o=this._commandRegs.get(e);if(!o)throw new Bt(e);if(r?.aggregateId!==void 0&&r.expectedAggregateVersion!==void 0&&o.emits!==void 0){let p=0;for(let h of o.emits){let f=this._aggregateVersions.get(`${h}::${r.aggregateId}`);f!==void 0&&f>p&&(p=f)}if(p!==r.expectedAggregateVersion)throw new zt(r.aggregateId,r.expectedAggregateVersion,p)}let s=this.resolve(e),i=this._freezeCommandPayload?wn(n):n,a=[],d=se(),u=0,c,l=!1;try{le(()=>{u=this._bumpDispatchSeq(),s.emit(i,{internal:!0});try{o.handler(i,{emit:(p,h)=>{if(o.emits!==void 0&&!o.emits.includes(p))throw new jt(e,p,o.emits);a.push(p),this._appendEvent(p,h,{...r?.aggregateId!==void 0?{aggregateId:r.aggregateId}:{},...r?.correlationId!==void 0?{correlationId:r.correlationId}:{},...r?.causationId!==void 0?{causationId:r.causationId}:{},...r?.metadata!==void 0?{metadata:Object.freeze({...r.metadata})}:{},...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}}),s.meta.error.emit(null,{internal:!0}),this.dispatches.append({commandName:e,payload:i,status:"success",emittedEvents:[...a],t_ns:d,seq:u,...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}catch(p){throw c=p,l=!0,p}})}catch(p){if(l){s.meta.error.emit(c,{internal:!0});let h=c instanceof Error?c.name:typeof c,f=c instanceof pt?c:new pt(e,c);this.dispatches.append({commandName:e,payload:i,status:"failed",error:f,errorType:h,emittedEvents:[...a],t_ns:d,seq:u,...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}throw l?c:p}}projection(e){let{name:n,events:r,reducer:o,initial:s}=e,i=e.mode??"scan",a=e.freezeInputs??!0,d=e.snapshot,u=r.map(E=>(this._eventLogs.has(E)||this.event(E),this._eventLogs.get(E).node));function c(E){E.sort((w,S)=>w.timestampNs-S.timestampNs||w.seq-S.seq||(w.aggregateId??"").localeCompare(S.aggregateId??""))}function l(E){let w=[];for(let S of E)w.push(...S);return c(w),w}let p=u.map(E=>E.cache??[]),h=l(p),f=a?Object.freeze(h):h,m=0,b=s;i==="scan"&&h.length>0&&(b=o(s,f),m=h.length);let T=i==="replay"?o(s,f):b,x=d?.saveDebounceMs??1e3,v=d?.saveEvery??1e3,y,R=0;function N(E){if(d?.save){if(R+=1,R>=v){R=0,y!==void 0&&(clearTimeout(y),y=void 0);let w=d.save(E);w instanceof Promise&&w.catch(()=>{});return}y!==void 0&&clearTimeout(y),y=setTimeout(()=>{y=void 0,R=0;let w=d.save(E);w instanceof Promise&&w.catch(()=>{})},x)}}let g=J(u,E=>{let w=l(E),S;if(i==="replay"){let k=a?Object.freeze(w):w;S=o(s,k)}else{let k=w.slice(m);m=w.length;let M=a?Object.freeze(k):k;S=o(b,M),b=S}return N(S),S},{name:n,describeKind:"derived",meta:gt("projection",{projection_name:n,source_events:r}),guard:Js,initial:T});return this.add(g,{name:n}),this._keepaliveDisposers.push(he(g)),this._keepaliveDisposers.push(()=>{y!==void 0&&(clearTimeout(y),y=void 0)}),this._projections.add(n),{node:g,rebuild:async E=>{try{let w=E?.pageSize??1e3,S=E?.fromTier??this._attachedEventTiers[0]?.[0],k=l(u.map(G=>G.cache??[])).length,M=s;if(d?.load){let G=await d.load();G!==void 0&&(M=G)}if(!S||!S.loadEntries){let G=l(u.map(U=>U.cache??[])),L=a?Object.freeze(G):G;M=o(M,L)}else{let G=new Set(r),L,U=!1;for(;!U;){let Te=await S.loadEntries({cursor:L,pageSize:w}),xe=[...Te.entries].filter(Ie=>G.has(Ie.type));c(xe);let Je=a?Object.freeze(xe):xe;M=o(M,Je),L=Te.cursor,U=!L||Te.entries.length===0}}if(i==="scan"){let G=l(u.map(U=>U.cache??[])),L=G.slice(k);if(L.length>0){let U=a?Object.freeze(L):L;M=o(M,U)}b=M,m=G.length}return g.emit(M,{internal:!0}),M}catch(w){throw new ht(n,w)}},reset:async()=>{try{let E=s;if(d?.load){let M=await d.load();M!==void 0&&(E=M)}let w=l(u.map(M=>M.cache??[])),S=a?Object.freeze(w):w,k=o(E,S);return i==="scan"&&(b=k,m=w.length),g.emit(k,{internal:!0}),k}catch(E){throw new ht(n,E)}}}}saga(e,n,r,o={}){let s=n.map(h=>(this._eventLogs.has(h)||this.event(h),this._eventLogs.get(h).node)),i=po(this,`${e}_cursor`,n,0),a=Wt({name:`${e}_invocations`,retainedLimit:this._retainedLimit,graph:this}),d=o.aggregateId,u=o.errorPolicy??"advance",c=new Map;for(let h of n){let f=i[h];c.set(h,f.cache??0);let m=f.subscribe(b=>{for(let T of b)T[0]===A&&c.set(h,T[1])});this._keepaliveDisposers.push(m)}let l={},p=pe(s,(h,f)=>{let m=l.n.meta.error;for(let b=0;b<h.length;b++){let T=h[b];if(T==null||T.length===0)continue;let x=T.at(-1);if(!x)continue;let v=n[b],y=i[v],R=c.get(v)??0;if(x.length>R){let N=x.slice(R),g=R;for(let _ of N){let O=_;if(d!==void 0&&O.aggregateId!==d){g+=1;continue}try{r(O),m.emit(null,{internal:!0}),a.append({eventType:v,status:"success",aggregateId:O.aggregateId,event:O,t_ns:se(),...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}}),g+=1}catch(E){if(m.emit(E,{internal:!0}),a.append({eventType:v,status:"failed",error:E,errorType:E instanceof Error?E.name:typeof E,aggregateId:O.aggregateId,event:O,t_ns:se(),...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}}),u==="hold")break;g+=1}}y.emit(g)}}},{name:e,describeKind:"effect",meta:{...gt("saga",{saga_name:e,source_events:n}),error:null}});return l.n=p,this.add(p,{name:e}),this._keepaliveDisposers.push(he(p)),this._sagas.add(e),{node:p,invocations:a,audit:a,cursors:i}}};function mo(t,e){return new En(t,e)}var Sn=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},On=class{graph=new X("request");onModuleDestroy(){this.graph.destroy()}},yo,Rn;yo=[(0,mt.Module)({})];var _e=class _e{static forRoot(e){let n=e??{},r=n.name??"root",o=[{provide:ae,useFactory:()=>{let s=new X(r);return n.build&&n.build(s),n.snapshot&&s.restore(n.snapshot),s}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:s=>new Sn(s),inject:[ae]},{provide:De,useFactory:(s,i)=>new De(s,i),inject:[ae,bo.ModuleRef]}];if(n.nodes)for(let s of n.nodes)o.push({provide:de(s),useFactory:i=>i.resolve(s),inject:[ae]});return n.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new On,scope:mt.Scope.REQUEST},{provide:Me,useFactory:s=>s.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:mt.Scope.REQUEST}),{module:_e,global:!0,providers:o,exports:[ae,...(n.nodes??[]).map(de),...n.requestScope?[Me]:[]]}}static forFeature(e){let n=[{provide:Q(e.name),useFactory:r=>{let o=new X(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),r.mount(e.name,o),o},inject:[ae]}];if(e.nodes)for(let r of e.nodes)n.push({provide:de(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[Q(e.name)]});return{module:_e,providers:n,exports:[Q(e.name),...(e.nodes??[]).map(r=>de(`${e.name}::${r}`))]}}static forCqrs(e){let n=[{provide:Q(e.name),useFactory:r=>{let o=mo(e.name,e.cqrs);return e.eventStorage&&o.attachEventStorage(e.eventStorage),e.build&&e.build(o),r.mount(e.name,o),o},inject:[ae]}];if(e.nodes)for(let r of e.nodes)n.push({provide:de(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[Q(e.name)]});return{module:_e,providers:n,exports:[Q(e.name),...(e.nodes??[]).map(r=>de(`${e.name}::${r}`))]}}};Rn=jn(null),_e=Wn(Rn,0,"GraphReflyModule",yo,_e),Bn(Rn,1,_e);var Kt=_e;var kn={};ce(kn,{useStore:()=>Qs,useSubscribe:()=>vo,useSubscribeRecord:()=>Xs});var ge=require("react");K();function vo(t){return(0,ge.useSyncExternalStore)(e=>{let n=!1,r=t.subscribe(()=>{n||e()});return()=>{n=!0,r()}},()=>t.cache,()=>t.cache)}function Qs(t){let e=vo(t),n=(0,ge.useCallback)(r=>{t.down([[P],[A,r]])},[t]);return[e,n]}function Xs(t,e){let n=(0,ge.useRef)(e);n.current=e;let r=(0,ge.useMemo)(()=>{let o=()=>{let i={},a=t.cache??[];for(let d of a){let u=n.current(d),c={};for(let l of Object.keys(u))c[l]=u[l].cache;i[d]=c}return i},s=o();return{subscribe:i=>{let a=!1,d=[],u=()=>{for(let p of d)p();d=[]},c=p=>{u();for(let h of p){let f=n.current(h);for(let m of Object.keys(f)){let b=f[m].subscribe(()=>{s=o(),a||i()});d.push(b)}}s=o(),a||i()},l=t.subscribe(p=>{let h=p.some(f=>f[0]===A||f[0]===z);!a&&h&&c(t.cache??[])});return c(t.cache??[]),()=>{a=!0,l(),u()}},getSnapshot:()=>s}},[t]);return(0,ge.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot)}var Mn={};ce(Mn,{Signal:()=>Zs});Ne();K();fe();var Ye=[];function Ut(t){let e=t.cache;return t.subscribe(r=>{for(let[o,s]of r)o===A&&(e=s)})(),e}var An=class{_node;_equals;constructor(e,n){this._equals=n?.equals??Object.is,this._node=q(e,{...n,resubscribable:!0,resetOnTeardown:!0})}get(){let e=Ye[Ye.length-1];return e?(this._node.status==="sentinel"&&Ut(this._node),e(this._node)):this._node.status==="sentinel"?Ut(this._node):this._node.cache}set(e){this._equals(this.get(),e)||le(()=>{this._node.down([[P],[A,e]])})}},Cn=class{_node;constructor(e,n){this._node=st(r=>{Ye.push(r);try{return e()}finally{Ye.pop()}},{...n,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=Ye[Ye.length-1];return e?(this._node.status==="sentinel"&&Ut(this._node),e(this._node)):this._node.status==="sentinel"?Ut(this._node):this._node.cache}},Zs={State:An,Computed:Cn,sub:(t,e)=>{let n=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,r=!0;return t._node.subscribe(o=>{for(let[s,i]of o){if(s===A){if(r){r=!1;continue}n.data?.(i)}s===D&&n.error?.(i),s===$&&n.complete?.()}})}};var Dn={};ce(Dn,{useStore:()=>ei,useSubscribe:()=>_o,useSubscribeRecord:()=>ti});var me=require("solid-js");K();function _o(t){let[e,n]=(0,me.createSignal)(t.cache,{equals:!1}),r=t.subscribe(()=>{n(()=>t.cache)});return(0,me.getOwner)()?(0,me.onCleanup)(()=>r()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),e}function ei(t){return[_o(t),r=>{t.down([[P],[A,r]])}]}function ti(t,e){let[n,r]=(0,me.createSignal)({},{equals:!1}),o=[],s=()=>{for(let u of o)u();o=[]},i=()=>{let u={};for(let c of t.cache??[]){let l=e(c),p={};for(let h of Object.keys(l))p[h]=l[h].cache;u[c]=p}return u},a=u=>{s();for(let c of u){let l=e(c);for(let p of Object.keys(l)){let h=l[p].subscribe(()=>{r(()=>i())});o.push(h)}}r(()=>i())},d=t.subscribe(u=>{u.some(c=>c[0]===A||c[0]===z)&&a(t.cache??[])});return a(t.cache??[]),(0,me.getOwner)()?(0,me.onCleanup)(()=>{d(),s()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),n}var Gn={};ce(Gn,{useStore:()=>ri,useSubscribe:()=>ni,useSubscribeRecord:()=>oi});K();function ni(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n}}}function ri(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n},set(e){t.down([[P],[A,e]])},update(e){let n=e(t.cache);t.down([[P],[A,n]])}}}function oi(t,e){return{subscribe(n){let r=[],o=()=>{for(let d of r)d();r=[]},s=()=>{let d={};for(let u of t.cache??[]){let c=e(u),l={};for(let p of Object.keys(c))l[p]=c[p].cache;d[u]=l}return d},i=d=>{o();for(let u of d){let c=e(u);for(let l of Object.keys(c)){let p=c[l].subscribe(()=>{n(s())});r.push(p)}}n(s())},a=t.subscribe(d=>{d.some(u=>u[0]===A||u[0]===z)&&i(t.cache??[])});return i(t.cache??[]),()=>{a(),o()}}}}var In={};ce(In,{useStore:()=>ii,useSubscribe:()=>si,useSubscribeRecord:()=>ai});var j=require("vue");K();function si(t){let e=(0,j.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,j.getCurrentScope)()?(0,j.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,j.readonly)(e)}function ii(t){let e=(0,j.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,j.getCurrentScope)()?(0,j.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useStore called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,j.computed)({get:()=>e.value,set:r=>{t.down([[P],[A,r]])}})}function ai(t,e){let n=(0,j.shallowRef)({}),r=new Map;function o(){let a={};for(let[d,u]of r)a[d]={...u.values};n.value=a}function s(a){for(let u of r.values())for(let c of u.subs)c();r.clear();for(let u of a){let c=e(u),l=Object.keys(c),p={},h=[];for(let f of l){let m=c[f];p[f]=m.cache;let b=m.subscribe(()=>{p[f]=m.cache,o()});h.push(b)}r.set(u,{subs:h,values:p})}let d={};for(let[u,c]of r)d[u]={...c.values};n.value=d}return(0,j.watch)(()=>[...(typeof t=="function"?t():(0,j.isRef)(t)?t.value:t)??[]],a=>s(a??[]),{immediate:!0}),(0,j.getCurrentScope)()?(0,j.onScopeDispose)(()=>{for(let a of r.values())for(let d of a.subs)d();r.clear()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,j.readonly)(n)}var Ln={};ce(Ln,{create:()=>di});K();fe();var ui=()=>!1;function di(t){let e=new X("zustand"),n=q(void 0,{name:"state",equals:ui});e.add(n,{name:"state"});let r=()=>n.cache,o=(a,d)=>{let u=n.cache,c=typeof a=="function"?a(u):a;n.emit(d?c:{...u,...c})},s={getState:r,setState:o,getInitialState:()=>i,subscribe:a=>{let d=!0,u=n.cache;return n.subscribe(c=>{for(let[l,p]of c)if(l===A){if(d){d=!1;continue}a(p,u),u=p}})},destroy:e.destroy.bind(e)},i=t(o,r,s);return n.emit(i),Object.assign(e,s)}0&&(module.exports={jotai,nanostores,nestjs,react,signals,solid,svelte,vue,zustand});