@graphrefly/graphrefly 0.27.0 → 0.28.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 (428) hide show
  1. package/dist/backoff-HPZMEZNF.js +1 -0
  2. package/dist/cascading-B-5zmAUv.d.cts +180 -0
  3. package/dist/cascading-D9WG1-9L.d.ts +180 -0
  4. package/dist/chunk-2FOAM3OR.js +1 -0
  5. package/dist/chunk-2PMCKKRK.js +1 -0
  6. package/dist/chunk-3JXNEPCD.js +2 -0
  7. package/dist/chunk-3R5HFPX7.js +78 -0
  8. package/dist/chunk-4GKB4OUJ.js +1 -0
  9. package/dist/chunk-4VVTGLXJ.js +1 -0
  10. package/dist/chunk-5QDBSZBV.js +1 -0
  11. package/dist/chunk-6QZNQS5B.js +1 -0
  12. package/dist/chunk-6V3SEX2I.js +1 -0
  13. package/dist/chunk-76A3HVQE.js +9 -0
  14. package/dist/chunk-7H6LGFUG.js +64 -0
  15. package/dist/chunk-CK2E7BTU.js +1 -0
  16. package/dist/chunk-CKCSDI7T.js +6 -0
  17. package/dist/chunk-CRXTH3SH.js +1 -0
  18. package/dist/chunk-CWLN3X3N.js +1 -0
  19. package/dist/chunk-D7A7DBE4.js +1 -0
  20. package/dist/chunk-DBGGMN3D.js +1 -0
  21. package/dist/chunk-DQA3UIQ2.js +1 -0
  22. package/dist/chunk-ERLIRFPA.js +1 -0
  23. package/dist/chunk-ESMPEKEV.js +1 -0
  24. package/dist/chunk-ETWTCCJI.js +1 -0
  25. package/dist/chunk-FNYWM6JC.js +1 -0
  26. package/dist/chunk-GHJJR5P4.js +1 -0
  27. package/dist/chunk-GPW2V3RE.js +1 -0
  28. package/dist/chunk-I6VIH3VA.js +1 -0
  29. package/dist/chunk-K2GNMCQT.js +1 -0
  30. package/dist/chunk-LBTDSCCO.js +3 -0
  31. package/dist/chunk-LQ3Y5NJS.js +1 -0
  32. package/dist/chunk-MIQTDPY4.js +5 -0
  33. package/dist/chunk-MTTAAPCK.js +1 -0
  34. package/dist/chunk-OAWLCNJJ.js +1 -0
  35. package/dist/chunk-OBKQQA5I.js +1 -0
  36. package/dist/chunk-OYHGKYQM.js +1 -0
  37. package/dist/chunk-PIOGHC63.js +1 -0
  38. package/dist/chunk-QWAPKG3O.js +2 -0
  39. package/dist/chunk-QYADASLV.js +1 -0
  40. package/dist/chunk-RHESUC3V.js +43 -0
  41. package/dist/chunk-S35VARIR.js +1 -0
  42. package/dist/chunk-SC3U7ETD.js +1 -0
  43. package/dist/chunk-U3AICJKU.js +1 -0
  44. package/dist/chunk-UMBIDLJ4.js +1 -0
  45. package/dist/chunk-UPHHLMHE.js +1 -0
  46. package/dist/chunk-UPXUCFMX.js +1 -0
  47. package/dist/chunk-UWJE5FQA.js +18 -0
  48. package/dist/chunk-V6YQICXZ.js +1 -0
  49. package/dist/chunk-VIMF6LGM.js +1 -0
  50. package/dist/chunk-VJLMUKOI.js +1 -0
  51. package/dist/chunk-VPYBOXVT.js +1 -0
  52. package/dist/chunk-VTPVOGHH.js +1 -0
  53. package/dist/chunk-WQ2BN6X6.js +1 -0
  54. package/dist/chunk-XAUNPIMX.js +1 -0
  55. package/dist/chunk-Y2EMPB3I.js +1 -0
  56. package/dist/chunk-Z4HDAS2Q.js +1 -0
  57. package/dist/chunk-ZB5EHBIO.js +1 -0
  58. package/dist/chunk-ZV2DXV5A.js +23 -0
  59. package/dist/compat/index.cjs +14 -7656
  60. package/dist/compat/index.d.cts +15 -14
  61. package/dist/compat/index.d.ts +15 -14
  62. package/dist/compat/index.js +1 -50
  63. package/dist/compat/jotai/index.cjs +1 -2048
  64. package/dist/compat/jotai/index.d.cts +2 -2
  65. package/dist/compat/jotai/index.d.ts +2 -2
  66. package/dist/compat/jotai/index.js +1 -9
  67. package/dist/compat/nanostores/index.cjs +1 -2175
  68. package/dist/compat/nanostores/index.d.cts +2 -2
  69. package/dist/compat/nanostores/index.d.ts +2 -2
  70. package/dist/compat/nanostores/index.js +1 -23
  71. package/dist/compat/nestjs/index.cjs +14 -6782
  72. package/dist/compat/nestjs/index.d.cts +7 -6
  73. package/dist/compat/nestjs/index.d.ts +7 -6
  74. package/dist/compat/nestjs/index.js +1 -83
  75. package/dist/compat/react/index.cjs +1 -141
  76. package/dist/compat/react/index.d.cts +2 -2
  77. package/dist/compat/react/index.d.ts +2 -2
  78. package/dist/compat/react/index.js +1 -12
  79. package/dist/compat/solid/index.cjs +1 -128
  80. package/dist/compat/solid/index.d.cts +2 -2
  81. package/dist/compat/solid/index.d.ts +2 -2
  82. package/dist/compat/solid/index.js +1 -12
  83. package/dist/compat/svelte/index.cjs +1 -131
  84. package/dist/compat/svelte/index.d.cts +2 -2
  85. package/dist/compat/svelte/index.d.ts +2 -2
  86. package/dist/compat/svelte/index.js +1 -12
  87. package/dist/compat/vue/index.cjs +1 -146
  88. package/dist/compat/vue/index.d.cts +2 -2
  89. package/dist/compat/vue/index.d.ts +2 -2
  90. package/dist/compat/vue/index.js +1 -12
  91. package/dist/compat/zustand/index.cjs +6 -4931
  92. package/dist/compat/zustand/index.d.cts +5 -5
  93. package/dist/compat/zustand/index.d.ts +5 -5
  94. package/dist/compat/zustand/index.js +1 -12
  95. package/dist/composite-B-xqw4Kk.d.cts +69 -0
  96. package/dist/composite-BhbKHbOS.d.ts +69 -0
  97. package/dist/core/index.cjs +1 -2271
  98. package/dist/core/index.d.cts +4 -4
  99. package/dist/core/index.d.ts +4 -4
  100. package/dist/core/index.js +1 -110
  101. package/dist/extra/browser.cjs +1 -0
  102. package/dist/extra/browser.d.cts +3 -0
  103. package/dist/extra/browser.d.ts +3 -0
  104. package/dist/extra/browser.js +1 -0
  105. package/dist/extra/index.cjs +23 -9971
  106. package/dist/extra/index.d.cts +13 -6
  107. package/dist/extra/index.d.ts +13 -6
  108. package/dist/extra/index.js +1 -381
  109. package/dist/extra/node.cjs +3 -0
  110. package/dist/extra/node.d.cts +81 -0
  111. package/dist/extra/node.d.ts +81 -0
  112. package/dist/extra/node.js +2 -0
  113. package/dist/extra/operators.cjs +1 -0
  114. package/dist/extra/operators.d.cts +910 -0
  115. package/dist/extra/operators.d.ts +910 -0
  116. package/dist/extra/operators.js +1 -0
  117. package/dist/extra/reactive.cjs +1 -0
  118. package/dist/extra/reactive.d.cts +352 -0
  119. package/dist/extra/reactive.d.ts +352 -0
  120. package/dist/extra/reactive.js +1 -0
  121. package/dist/extra/sources.cjs +1 -2486
  122. package/dist/extra/sources.d.cts +6 -2
  123. package/dist/extra/sources.d.ts +6 -2
  124. package/dist/extra/sources.js +1 -57
  125. package/dist/extra/storage-browser.cjs +1 -0
  126. package/dist/extra/storage-browser.d.cts +71 -0
  127. package/dist/extra/storage-browser.d.ts +71 -0
  128. package/dist/extra/storage-browser.js +1 -0
  129. package/dist/extra/storage-core.cjs +1 -0
  130. package/dist/extra/storage-core.d.cts +98 -0
  131. package/dist/extra/storage-core.d.ts +98 -0
  132. package/dist/extra/storage-core.js +1 -0
  133. package/dist/extra/storage-node.cjs +2 -0
  134. package/dist/extra/storage-node.d.cts +60 -0
  135. package/dist/extra/storage-node.d.ts +60 -0
  136. package/dist/extra/storage-node.js +1 -0
  137. package/dist/fallback-BaTS7vVY.d.cts +258 -0
  138. package/dist/fallback-eOm3LNxP.d.ts +258 -0
  139. package/dist/graph/index.cjs +6 -5030
  140. package/dist/graph/index.d.cts +6 -5
  141. package/dist/graph/index.d.ts +6 -5
  142. package/dist/graph/index.js +1 -50
  143. package/dist/{graph-CCwGKLCm.d.ts → graph-BZGRXwOm.d.ts} +134 -31
  144. package/dist/{graph-DNCrvZSn.d.cts → graph-D48Qw9Cg.d.cts} +134 -31
  145. package/dist/index-8FSVk4Uf.d.ts +135 -0
  146. package/dist/index-9oDeHH2u.d.cts +291 -0
  147. package/dist/{messaging-XDoYablx.d.ts → index-B0c4cmIO.d.ts} +31 -93
  148. package/dist/{index-VdHQMPy1.d.ts → index-B1AmmSlb.d.ts} +1 -1
  149. package/dist/{index-VHqptjhu.d.cts → index-B2pwesl9.d.cts} +1 -1
  150. package/dist/index-BHvIquRZ.d.ts +1957 -0
  151. package/dist/{index-Dzk2hrlR.d.ts → index-BVHOrDwO.d.ts} +1 -1
  152. package/dist/{index-CxFrXH4m.d.ts → index-BWJV63ti.d.ts} +1 -1
  153. package/dist/{index-Xi3u0HCQ.d.cts → index-B_agccPe.d.cts} +1 -1
  154. package/dist/index-BgyGlizc.d.ts +163 -0
  155. package/dist/index-BpA5c4G9.d.ts +357 -0
  156. package/dist/index-BpIFjILY.d.cts +357 -0
  157. package/dist/{index-3lsddbbS.d.ts → index-Bqachn9_.d.ts} +1 -1
  158. package/dist/index-Btib9rsU.d.ts +607 -0
  159. package/dist/{index-wEn0eFe8.d.ts → index-BwM9BEkt.d.ts} +1 -1
  160. package/dist/index-BxJ86YZZ.d.cts +105 -0
  161. package/dist/{audit-DRlSzBu9.d.ts → index-C73n7lo-.d.cts} +27 -21
  162. package/dist/index-CEXXwWVH.d.cts +192 -0
  163. package/dist/index-CHEswufn.d.cts +163 -0
  164. package/dist/{index-C0svESO4.d.ts → index-CMn8S8Hw.d.ts} +1 -1
  165. package/dist/{index-ByQxazQJ.d.cts → index-CRO83MmV.d.cts} +1 -1
  166. package/dist/{index-BuEoe-Qu.d.ts → index-CloUk1kY.d.ts} +9 -9
  167. package/dist/index-CpgYhnrG.d.ts +291 -0
  168. package/dist/{index-DO_6JN9Z.d.cts → index-Cyojz0AE.d.cts} +1 -1
  169. package/dist/{demo-shell-BDkOptd6.d.ts → index-CzobVSMr.d.ts} +14 -14
  170. package/dist/index-Czq6ynh8.d.ts +143 -0
  171. package/dist/{index-BaSM3aYt.d.ts → index-D-YB-Vl3.d.ts} +3 -3
  172. package/dist/index-DAlweici.d.ts +231 -0
  173. package/dist/index-DEwTb_fm.d.cts +1957 -0
  174. package/dist/{index-DYme44FM.d.cts → index-DL-rYJrx.d.cts} +1 -1
  175. package/dist/{memory-li6FL5RM.d.ts → index-DP4ZTkdw.d.ts} +26 -26
  176. package/dist/{index-BwfLUNw4.d.ts → index-DUqMOlKZ.d.cts} +173 -2040
  177. package/dist/{index-B1tloyhO.d.cts → index-D_NwnRYS.d.cts} +1 -1
  178. package/dist/index-DaLJvH8Z.d.ts +105 -0
  179. package/dist/index-DcXZBF5a.d.cts +135 -0
  180. package/dist/index-DfyOkTvs.d.ts +321 -0
  181. package/dist/{index-B9B7_HEY.d.ts → index-DiOXyAwt.d.ts} +1 -1
  182. package/dist/index-DpHe5e0Q.d.ts +186 -0
  183. package/dist/index-DraikLjn.d.ts +86 -0
  184. package/dist/{index-D8wS_PeY.d.cts → index-DxsnAMWD.d.cts} +9 -9
  185. package/dist/{messaging-Gt4LPbyA.d.cts → index-DyxjtScX.d.cts} +31 -93
  186. package/dist/{audit-ClmqGOCx.d.cts → index-HDpJe9hX.d.ts} +27 -21
  187. package/dist/{index-DVGiGFGT.d.cts → index-O6TgGUBV.d.cts} +3 -3
  188. package/dist/{index-B6EhDnjH.d.cts → index-Oi8d8w4R.d.cts} +1 -1
  189. package/dist/{index-C8oil6M6.d.ts → index-ROpQmGjE.d.ts} +30 -6
  190. package/dist/index-RukJ4DLS.d.cts +607 -0
  191. package/dist/{index-BHlKbUwO.d.cts → index-ZftwfxJM.d.ts} +173 -2040
  192. package/dist/{index-BPVt8kqc.d.ts → index-cByzxQIC.d.cts} +10 -195
  193. package/dist/index-dtN7YA2x.d.cts +143 -0
  194. package/dist/{index-CI3DprxP.d.cts → index-fM6y00vT.d.cts} +30 -6
  195. package/dist/{index-DlLp-2Xn.d.cts → index-m-yHof5p.d.ts} +10 -195
  196. package/dist/index-pXrDMpRO.d.cts +231 -0
  197. package/dist/index-rHJSKsU8.d.cts +186 -0
  198. package/dist/index-rX8HBM5h.d.cts +321 -0
  199. package/dist/{index-CO8uBlUh.d.cts → index-rnwQly8X.d.cts} +147 -20
  200. package/dist/index-sm373fsH.d.ts +192 -0
  201. package/dist/{memory-C6Z2tGpC.d.cts → index-tbf2gKHd.d.cts} +26 -26
  202. package/dist/{demo-shell-Crid1WdR.d.cts → index-u15meRxL.d.cts} +14 -14
  203. package/dist/{index-B6D3QNSA.d.ts → index-umtoWT8K.d.ts} +147 -20
  204. package/dist/index-vscRDkjW.d.cts +86 -0
  205. package/dist/index.cjs +150 -24142
  206. package/dist/index.d.cts +69 -2099
  207. package/dist/index.d.ts +69 -2099
  208. package/dist/index.js +1 -3868
  209. package/dist/{meta-CbznRPYJ.d.ts → meta-Cgj6zeji.d.cts} +5 -5
  210. package/dist/{meta-BxCA7rcr.d.cts → meta-CwesDrMD.d.ts} +5 -5
  211. package/dist/{node-BmerH3kS.d.cts → node-Cc1TniY8.d.cts} +36 -9
  212. package/dist/{node-BmerH3kS.d.ts → node-Cc1TniY8.d.ts} +36 -9
  213. package/dist/{observable-BgGUwcqp.d.ts → observable-Ct-gJ9jI.d.ts} +1 -1
  214. package/dist/{observable-DJt_AxzQ.d.cts → observable-glXQoGj2.d.cts} +1 -1
  215. package/dist/patterns/ai/browser.cjs +25 -0
  216. package/dist/patterns/ai/browser.d.cts +127 -0
  217. package/dist/patterns/ai/browser.d.ts +127 -0
  218. package/dist/patterns/ai/browser.js +3 -0
  219. package/dist/patterns/ai/index.cjs +91 -0
  220. package/dist/patterns/ai/index.d.cts +17 -0
  221. package/dist/patterns/ai/index.d.ts +17 -0
  222. package/dist/patterns/ai/index.js +1 -0
  223. package/dist/patterns/ai/node.cjs +2 -0
  224. package/dist/patterns/ai/node.d.cts +58 -0
  225. package/dist/patterns/ai/node.d.ts +58 -0
  226. package/dist/patterns/ai/node.js +1 -0
  227. package/dist/patterns/audit/index.cjs +6 -0
  228. package/dist/patterns/audit/index.d.cts +6 -0
  229. package/dist/patterns/audit/index.d.ts +6 -0
  230. package/dist/patterns/audit/index.js +1 -0
  231. package/dist/patterns/cqrs/index.cjs +6 -0
  232. package/dist/patterns/cqrs/index.d.cts +5 -0
  233. package/dist/patterns/cqrs/index.d.ts +5 -0
  234. package/dist/patterns/cqrs/index.js +1 -0
  235. package/dist/patterns/demo-shell/index.cjs +7 -0
  236. package/dist/patterns/demo-shell/index.d.cts +6 -0
  237. package/dist/patterns/demo-shell/index.d.ts +6 -0
  238. package/dist/patterns/demo-shell/index.js +1 -0
  239. package/dist/patterns/domain-templates/index.cjs +6 -0
  240. package/dist/patterns/domain-templates/index.d.cts +5 -0
  241. package/dist/patterns/domain-templates/index.d.ts +5 -0
  242. package/dist/patterns/domain-templates/index.js +1 -0
  243. package/dist/patterns/graphspec/index.cjs +83 -0
  244. package/dist/patterns/graphspec/index.d.cts +7 -0
  245. package/dist/patterns/graphspec/index.d.ts +7 -0
  246. package/dist/patterns/graphspec/index.js +1 -0
  247. package/dist/patterns/guarded-execution/index.cjs +6 -0
  248. package/dist/patterns/guarded-execution/index.d.cts +7 -0
  249. package/dist/patterns/guarded-execution/index.d.ts +7 -0
  250. package/dist/patterns/guarded-execution/index.js +1 -0
  251. package/dist/patterns/harness/index.cjs +48 -0
  252. package/dist/patterns/harness/index.d.cts +8 -0
  253. package/dist/patterns/harness/index.d.ts +8 -0
  254. package/dist/patterns/harness/index.js +1 -0
  255. package/dist/patterns/job-queue/index.cjs +6 -0
  256. package/dist/patterns/job-queue/index.d.cts +5 -0
  257. package/dist/patterns/job-queue/index.d.ts +5 -0
  258. package/dist/patterns/job-queue/index.js +1 -0
  259. package/dist/patterns/lens/index.cjs +6 -0
  260. package/dist/patterns/lens/index.d.cts +7 -0
  261. package/dist/patterns/lens/index.d.ts +7 -0
  262. package/dist/patterns/lens/index.js +1 -0
  263. package/dist/patterns/memory/index.cjs +6 -0
  264. package/dist/patterns/memory/index.d.cts +5 -0
  265. package/dist/patterns/memory/index.d.ts +5 -0
  266. package/dist/patterns/memory/index.js +1 -0
  267. package/dist/patterns/messaging/index.cjs +6 -0
  268. package/dist/patterns/messaging/index.d.cts +5 -0
  269. package/dist/patterns/messaging/index.d.ts +5 -0
  270. package/dist/patterns/messaging/index.js +1 -0
  271. package/dist/patterns/orchestration/index.cjs +6 -0
  272. package/dist/patterns/orchestration/index.d.cts +6 -0
  273. package/dist/patterns/orchestration/index.d.ts +6 -0
  274. package/dist/patterns/orchestration/index.js +1 -0
  275. package/dist/patterns/reactive-layout/index.cjs +7 -6444
  276. package/dist/patterns/reactive-layout/index.d.cts +6 -6
  277. package/dist/patterns/reactive-layout/index.d.ts +6 -6
  278. package/dist/patterns/reactive-layout/index.js +1 -56
  279. package/dist/patterns/reduction/index.cjs +6 -0
  280. package/dist/patterns/reduction/index.d.cts +5 -0
  281. package/dist/patterns/reduction/index.d.ts +5 -0
  282. package/dist/patterns/reduction/index.js +1 -0
  283. package/dist/patterns/refine-loop/index.cjs +8 -0
  284. package/dist/patterns/refine-loop/index.d.cts +7 -0
  285. package/dist/patterns/refine-loop/index.d.ts +7 -0
  286. package/dist/patterns/refine-loop/index.js +1 -0
  287. package/dist/patterns/resilient-pipeline/index.cjs +1 -0
  288. package/dist/patterns/resilient-pipeline/index.d.cts +7 -0
  289. package/dist/patterns/resilient-pipeline/index.d.ts +7 -0
  290. package/dist/patterns/resilient-pipeline/index.js +1 -0
  291. package/dist/patterns/surface/index.cjs +14 -0
  292. package/dist/patterns/surface/index.d.cts +8 -0
  293. package/dist/patterns/surface/index.d.ts +8 -0
  294. package/dist/patterns/surface/index.js +1 -0
  295. package/dist/{reactive-layout-MQP--J3F.d.cts → reactive-layout-CpYb5qLP.d.cts} +2 -2
  296. package/dist/{reactive-layout-u5Ulnqag.d.ts → reactive-layout-D8u4wuUR.d.ts} +2 -2
  297. package/dist/reactive-log-DPzuUDj5.d.cts +190 -0
  298. package/dist/reactive-log-YuH9VYN8.d.ts +190 -0
  299. package/dist/{composite-aUCvjZVR.d.ts → reactive-map-CdbNoSgP.d.ts} +2 -67
  300. package/dist/{composite-C7PcQvcs.d.cts → reactive-map-DUeRmb9d.d.cts} +2 -67
  301. package/dist/resilience-Ba5-b4WD.d.cts +493 -0
  302. package/dist/resilience-CGRzhnD3.d.ts +493 -0
  303. package/dist/resilience-QAHKANT5.js +1 -0
  304. package/dist/{sugar-D02n5JjF.d.cts → sugar-BV0htudb.d.cts} +8 -4
  305. package/dist/{sugar-CCOxXK1e.d.ts → sugar-Dtyrq2_q.d.ts} +8 -4
  306. package/dist/topology-tree-CYHOwQZ_.d.ts +25 -0
  307. package/dist/topology-tree-DROUdq5B.d.cts +25 -0
  308. package/dist/types-O3GzJY2U.d.cts +401 -0
  309. package/dist/types-u64Ose53.d.ts +401 -0
  310. package/package.json +252 -22
  311. package/dist/ai-CaR_912Q.d.cts +0 -1033
  312. package/dist/ai-WlRltJV7.d.ts +0 -1033
  313. package/dist/chunk-3ZWCKRHX.js +0 -117
  314. package/dist/chunk-3ZWCKRHX.js.map +0 -1
  315. package/dist/chunk-7TAQJHQV.js +0 -103
  316. package/dist/chunk-7TAQJHQV.js.map +0 -1
  317. package/dist/chunk-APFNLIRG.js +0 -62
  318. package/dist/chunk-APFNLIRG.js.map +0 -1
  319. package/dist/chunk-AT5LKYNL.js +0 -395
  320. package/dist/chunk-AT5LKYNL.js.map +0 -1
  321. package/dist/chunk-BQ6RQQFF.js +0 -5087
  322. package/dist/chunk-BQ6RQQFF.js.map +0 -1
  323. package/dist/chunk-BVZYTZ5H.js +0 -599
  324. package/dist/chunk-BVZYTZ5H.js.map +0 -1
  325. package/dist/chunk-DST5DKZS.js +0 -1371
  326. package/dist/chunk-DST5DKZS.js.map +0 -1
  327. package/dist/chunk-GTE6PWRZ.js +0 -866
  328. package/dist/chunk-GTE6PWRZ.js.map +0 -1
  329. package/dist/chunk-HXZEYDUR.js +0 -94
  330. package/dist/chunk-HXZEYDUR.js.map +0 -1
  331. package/dist/chunk-J22W6HV3.js +0 -107
  332. package/dist/chunk-J22W6HV3.js.map +0 -1
  333. package/dist/chunk-J2VBW3DZ.js +0 -302
  334. package/dist/chunk-J2VBW3DZ.js.map +0 -1
  335. package/dist/chunk-JSCT3CR4.js +0 -38
  336. package/dist/chunk-JSCT3CR4.js.map +0 -1
  337. package/dist/chunk-JWBCY4NC.js +0 -330
  338. package/dist/chunk-JWBCY4NC.js.map +0 -1
  339. package/dist/chunk-K2AUJHVP.js +0 -2251
  340. package/dist/chunk-K2AUJHVP.js.map +0 -1
  341. package/dist/chunk-MJ2NKQQL.js +0 -119
  342. package/dist/chunk-MJ2NKQQL.js.map +0 -1
  343. package/dist/chunk-N6UR7YVY.js +0 -198
  344. package/dist/chunk-N6UR7YVY.js.map +0 -1
  345. package/dist/chunk-NC6S43JJ.js +0 -456
  346. package/dist/chunk-NC6S43JJ.js.map +0 -1
  347. package/dist/chunk-OFVJBJXR.js +0 -98
  348. package/dist/chunk-OFVJBJXR.js.map +0 -1
  349. package/dist/chunk-OHISZPOJ.js +0 -97
  350. package/dist/chunk-OHISZPOJ.js.map +0 -1
  351. package/dist/chunk-OU5CQKNW.js +0 -102
  352. package/dist/chunk-OU5CQKNW.js.map +0 -1
  353. package/dist/chunk-PF7GRZMW.js +0 -2712
  354. package/dist/chunk-PF7GRZMW.js.map +0 -1
  355. package/dist/chunk-PHOUUNK7.js +0 -2291
  356. package/dist/chunk-PHOUUNK7.js.map +0 -1
  357. package/dist/chunk-RNHBMHKA.js +0 -1665
  358. package/dist/chunk-RNHBMHKA.js.map +0 -1
  359. package/dist/chunk-SX52TAR4.js +0 -110
  360. package/dist/chunk-SX52TAR4.js.map +0 -1
  361. package/dist/chunk-VYPWMZ6H.js +0 -98
  362. package/dist/chunk-VYPWMZ6H.js.map +0 -1
  363. package/dist/chunk-WBZOVTYK.js +0 -171
  364. package/dist/chunk-WBZOVTYK.js.map +0 -1
  365. package/dist/chunk-WKNUIZOY.js +0 -354
  366. package/dist/chunk-WKNUIZOY.js.map +0 -1
  367. package/dist/chunk-X3VMZYBT.js +0 -713
  368. package/dist/chunk-X3VMZYBT.js.map +0 -1
  369. package/dist/chunk-X5R3GL6H.js +0 -525
  370. package/dist/chunk-X5R3GL6H.js.map +0 -1
  371. package/dist/chunk-XGPU467M.js +0 -136
  372. package/dist/chunk-XGPU467M.js.map +0 -1
  373. package/dist/compat/index.cjs.map +0 -1
  374. package/dist/compat/index.js.map +0 -1
  375. package/dist/compat/jotai/index.cjs.map +0 -1
  376. package/dist/compat/jotai/index.js.map +0 -1
  377. package/dist/compat/nanostores/index.cjs.map +0 -1
  378. package/dist/compat/nanostores/index.js.map +0 -1
  379. package/dist/compat/nestjs/index.cjs.map +0 -1
  380. package/dist/compat/nestjs/index.js.map +0 -1
  381. package/dist/compat/react/index.cjs.map +0 -1
  382. package/dist/compat/react/index.js.map +0 -1
  383. package/dist/compat/solid/index.cjs.map +0 -1
  384. package/dist/compat/solid/index.js.map +0 -1
  385. package/dist/compat/svelte/index.cjs.map +0 -1
  386. package/dist/compat/svelte/index.js.map +0 -1
  387. package/dist/compat/vue/index.cjs.map +0 -1
  388. package/dist/compat/vue/index.js.map +0 -1
  389. package/dist/compat/zustand/index.cjs.map +0 -1
  390. package/dist/compat/zustand/index.js.map +0 -1
  391. package/dist/core/index.cjs.map +0 -1
  392. package/dist/core/index.js.map +0 -1
  393. package/dist/extra/index.cjs.map +0 -1
  394. package/dist/extra/index.js.map +0 -1
  395. package/dist/extra/sources.cjs.map +0 -1
  396. package/dist/extra/sources.js.map +0 -1
  397. package/dist/graph/index.cjs.map +0 -1
  398. package/dist/graph/index.js.map +0 -1
  399. package/dist/index.cjs.map +0 -1
  400. package/dist/index.js.map +0 -1
  401. package/dist/patterns/ai.cjs +0 -7930
  402. package/dist/patterns/ai.cjs.map +0 -1
  403. package/dist/patterns/ai.d.cts +0 -10
  404. package/dist/patterns/ai.d.ts +0 -10
  405. package/dist/patterns/ai.js +0 -71
  406. package/dist/patterns/ai.js.map +0 -1
  407. package/dist/patterns/audit.cjs +0 -5805
  408. package/dist/patterns/audit.cjs.map +0 -1
  409. package/dist/patterns/audit.d.cts +0 -6
  410. package/dist/patterns/audit.d.ts +0 -6
  411. package/dist/patterns/audit.js +0 -29
  412. package/dist/patterns/audit.js.map +0 -1
  413. package/dist/patterns/demo-shell.cjs +0 -5604
  414. package/dist/patterns/demo-shell.cjs.map +0 -1
  415. package/dist/patterns/demo-shell.d.cts +0 -6
  416. package/dist/patterns/demo-shell.d.ts +0 -6
  417. package/dist/patterns/demo-shell.js +0 -15
  418. package/dist/patterns/demo-shell.js.map +0 -1
  419. package/dist/patterns/memory.cjs +0 -5283
  420. package/dist/patterns/memory.cjs.map +0 -1
  421. package/dist/patterns/memory.d.cts +0 -5
  422. package/dist/patterns/memory.d.ts +0 -5
  423. package/dist/patterns/memory.js +0 -20
  424. package/dist/patterns/memory.js.map +0 -1
  425. package/dist/patterns/reactive-layout/index.cjs.map +0 -1
  426. package/dist/patterns/reactive-layout/index.js.map +0 -1
  427. package/dist/storage-CMjUUuxn.d.ts +0 -190
  428. package/dist/storage-DdWlZo6U.d.cts +0 -190
@@ -0,0 +1,6 @@
1
+ "use strict";var Ue=Object.defineProperty;var qt=Object.getOwnPropertyDescriptor;var Yt=Object.getOwnPropertyNames;var Jt=Object.prototype.hasOwnProperty;var U=(r,e)=>()=>(r&&(e=r(r=0)),e);var Xt=(r,e)=>{for(var t in e)Ue(r,t,{get:e[t],enumerable:!0})},Zt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Yt(e))!Jt.call(r,s)&&s!==t&&Ue(r,s,{get:()=>e[s],enumerable:!(n=qt(e,s))||n.enumerable});return r};var Qt=r=>Zt(Ue({},"__esModule",{value:!0}),r);function H(){return Math.trunc(performance.now()*1e6)}function Oe(){return Date.now()*1e6}var Ee=U(()=>{"use strict"});var ge,V,Z,W,q,Q,re,j,Y,P,ae,We,en,Ke,tn,nn,qe,pt,ht,gt,Ye,me=U(()=>{"use strict";ge=Symbol.for("graphrefly/START"),V=Symbol.for("graphrefly/DATA"),Z=Symbol.for("graphrefly/DIRTY"),W=Symbol.for("graphrefly/RESOLVED"),q=Symbol.for("graphrefly/INVALIDATE"),Q=Symbol.for("graphrefly/PAUSE"),re=Symbol.for("graphrefly/RESUME"),j=Symbol.for("graphrefly/TEARDOWN"),Y=Symbol.for("graphrefly/COMPLETE"),P=Symbol.for("graphrefly/ERROR"),ae=Object.freeze([Z]),We=Object.freeze([W]),en=Object.freeze([q]),Ke=Object.freeze([ge]),tn=Object.freeze([Y]),nn=Object.freeze([j]),qe=Object.freeze([ae]),pt=Object.freeze([We]),ht=Object.freeze([en]),gt=Object.freeze([tn]),Ye=Object.freeze([nn])});function bt(r,e){let t=new TextEncoder().encode(r.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${r.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let n=r.version;if(!Number.isInteger(n)||n<0||n>65535)throw new Error(`encodeEnvelope: codec.version ${n} out of u16 range (expected integer 0\u201365535)`);let s=2+t.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=Je,o[i++]=t.length,o.set(t,i),i+=t.length,o[i++]=n>>>8&255,o[i++]=n&255,o.set(e,i),o}function yt(r,e){if(r.length<mt)throw new Error(`decodeEnvelope: bytes too short (${r.length} < ${mt})`);let t=0,n=r[t++];if(n!==Je)throw new Error(`decodeEnvelope: unsupported envelope version ${n} (expected ${Je})`);let s=r[t++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+s+2>r.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+s+2} bytes, have ${r.length})`);let o=new TextDecoder().decode(r.subarray(t,t+s));t+=s;let i=(r[t]<<8|r[t+1])>>>0;t+=2;let a=r.subarray(t),c=e.lookupCodec(o);if(c==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:c,codecVersion:i,payload:a}}function vt(r){r.registerCodec(rn)}var rn,Je,mt,Xe=U(()=>{"use strict";rn={name:"json",version:1,contentType:"application/json",encode(r){let e=JSON.stringify(r);return new TextEncoder().encode(e)},decode(r,e){let t=new TextDecoder().decode(r);return JSON.parse(t)}},Je=1,mt=4});function Ne(r){if(r==null)return ue;let{type:e,id:t,...n}=r;return{type:e??"system",id:t??"",...n}}var ue,Ze=U(()=>{"use strict";ue={type:"system",id:""}});function ke(){return ce>0||be}function _t(){return ce>0}function ve(r){ce>0?ye.push(r):r()}function wt(r){ce+=1;let e=!1;try{r()}catch(t){throw e=!0,t}finally{if(ce-=1,ce===0)if(e){if(!be){let t=ye.splice(0);for(let n of t)try{n()}catch{}se.length=0,oe.length=0,de.length=0}}else sn()}}function sn(){let r=!be;r&&(be=!0);let e=[],t=0;try{for(;se.length>0||oe.length>0||de.length>0||r&&ye.length>0;){if(r&&ye.length>0){let o=ye.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(t+=1,t>1e3)throw se.length=0,oe.length=0,de.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(se.length>0?se:oe.length>0?oe:de).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{r&&(be=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Se(r,e,t){if(e.length===0)return;if(e.length===1){let u=t(e[0][0]);if(u<3||!ke()){r(e);return}(u>=5?de:u===4?oe:se).push(()=>r(e));return}let n=e.length,s=n,o=n,i=n,a=0;for(;a<n&&t(e[a][0])<3;)a++;for(s=a;a<n&&t(e[a][0])===3;)a++;for(o=a;a<n&&t(e[a][0])===4;)a++;i=a;let c=ke();if(s>0){let u=e.slice(0,s);r(u)}if(o>s){let u=e.slice(s,o);c?se.push(()=>r(u)):r(u)}if(i>o){let u=e.slice(o,i);c?oe.push(()=>r(u)):r(u)}if(n>i){let u=e.slice(i,n);c?de.push(()=>r(u)):r(u)}}var ce,be,se,oe,de,ye,Qe=U(()=>{"use strict";ce=0,be=!1,se=[],oe=[],de=[],ye=[]});function Tt(r){r.registerMessageType(ge,{tier:0,wireCrossing:!1}),r.registerMessageType(Z,{tier:1,wireCrossing:!1}),r.registerMessageType(q,{tier:1,wireCrossing:!1,metaPassthrough:!1}),r.registerMessageType(Q,{tier:2,wireCrossing:!1}),r.registerMessageType(re,{tier:2,wireCrossing:!1}),r.registerMessageType(V,{tier:3,wireCrossing:!0}),r.registerMessageType(W,{tier:3,wireCrossing:!0}),r.registerMessageType(Y,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(P,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(j,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Re,xt=U(()=>{"use strict";me();Re=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let n=this._messageTypes.get(t);return n!=null?n.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function et(r){let e=on.filter(t=>r({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}var K,on,Ae=U(()=>{"use strict";K=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}},on=["human","llm","wallet","system"]});function tt(r){if(r===void 0)return null;if(typeof r=="number"){if(!Number.isFinite(r))throw new TypeError(`Cannot hash non-finite number: ${r}`);if(Number.isInteger(r)&&!Number.isSafeInteger(r))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${r}. Cross-language cid parity is not guaranteed for unsafe integers.`);return r}if(typeof r=="string"||typeof r=="boolean"||r===null)return r;if(Array.isArray(r))return r.map(tt);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=tt(r[t]);return e}return null}function cn(r){let e=un.encode(r),t=e.length,n=t*8,s=t+9+63&-64,o=new Uint8Array(s);o.set(e),o[t]=128;let i=new DataView(o.buffer);i.setUint32(s-4,n>>>0,!1),i.setUint32(s-8,Math.floor(n/4294967296)>>>0,!1);let a=1779033703,c=3144134277,u=1013904242,d=2773480762,p=1359893119,h=2600822924,f=528734635,l=1541459225,g=new Uint32Array(64),m=(_,b)=>_>>>b|_<<32-b;for(let _=0;_<s;_+=64){for(let N=0;N<16;N++)g[N]=i.getUint32(_+N*4,!1);for(let N=16;N<64;N++){let R=g[N-15],k=g[N-2],I=m(R,7)^m(R,18)^R>>>3,X=m(k,17)^m(k,19)^k>>>10;g[N]=g[N-16]+I+g[N-7]+X>>>0}let b=a,v=c,x=u,w=d,T=p,E=h,S=f,$=l;for(let N=0;N<64;N++){let R=m(T,6)^m(T,11)^m(T,25),k=T&E^~T&S,I=$+R+k+an[N]+g[N]>>>0,X=m(b,2)^m(b,13)^m(b,22),ne=b&v^b&x^v&x,Te=X+ne>>>0;$=S,S=E,E=T,T=w+I>>>0,w=x,x=v,v=b,b=I+Te>>>0}a=a+b>>>0,c=c+v>>>0,u=u+x>>>0,d=d+w>>>0,p=p+T>>>0,h=h+E>>>0,f=f+S>>>0,l=l+$>>>0}let y=_=>_.toString(16).padStart(8,"0");return y(a)+y(c)+y(u)+y(d)+y(p)+y(h)+y(f)+y(l)}function nt(r){let e=tt(r??null),t=JSON.stringify(e);return cn(t).slice(0,16)}function dn(){let r=globalThis.crypto;if(r?.randomUUID)return r.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function rt(r,e,t){let n=t?.id??dn();if(r===0)return{id:n,version:0};let o=(t?.hash??nt)(e);return{id:n,version:0,cid:o,prev:null}}function Ot(r,e,t){r.version+=1,"cid"in r&&(r.prev=r.cid,r.cid=t(e))}var an,un,Et=U(()=>{"use strict";an=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]),un=new TextEncoder});function St(r){return{node:r,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function st(r){r.prevData=void 0,r.dirty=!1,r.involvedThisWave=!1,r.dataBatch.length=0,r.terminal=void 0}function De(r){return r.length===0?r:typeof r[0]=="symbol"?[r]:r}function Me(r,e,t){let n=Rt(r)?r:[],s=typeof r=="function"?r:typeof e=="function"?e:void 0,o={};return Rt(r)?o=(ot(e)?e:t)??{}:ot(r)?o=r:o=(ot(e)?e:t)??{},new C(n,s,o)}var Nt,kt,ln,fn,le,C,Rt,ot,_e=U(()=>{"use strict";Xe();Ze();Qe();Ee();xt();Ae();me();Et();Nt=()=>{},kt=100;ln=(r,e,t,n)=>{t.direction==="down-in"&&r._onDepMessage(t.depIndex,e)},fn=(r,e,t,n)=>{let s=r;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[Ke]:[Ke,[V,o]];s._status==="dirty"&&i.push(ae),Se(e,i,s._config.tierOf)},le=new Re({onMessage:ln,onSubscribe:fn});Tt(le);vt(le);C=class r{_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;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,n){this._config=n.config??le,this._config.onMessage,this._optsName=n.name,this._describeKind=n.describeKind,this._equals=n.equals??Object.is,this._resubscribable=n.resubscribable??!1,this._resetOnTeardown=n.resetOnTeardown??!1,this._autoComplete=n.completeWhenDepsComplete??!0,this._autoError=n.errorWhenDepsError??!0,this._pausable=n.pausable??!0,this._guard=n.guard,this._fn=t,this._cached=n.initial!==void 0?n.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=n.versioningHash??this._config.defaultHashFn??nt;let s=n.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?rt(s,this._cached===void 0?void 0:this._cached,{id:n.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(St);let o={};for(let[a,c]of Object.entries(n.meta??{})){let u={initial:c,name:`${n.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};n.guard!=null&&(u.guard=n.guard),o[a]=new r([],void 0,u)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[V,a]])},down(a){i._emit(De(a))},up(a){i._emitUp(De(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let n=this._versioningLevel;if(n!=null&&e<=n)return;let s=t?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??t?.id,c=i?.version??0,u=rt(e,o,{id:a,hash:s});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 t=Ne(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let n of this._extraGuards)if(!n(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,n=e?.actor!=null;if(!t&&!n)return;let s=Ne(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new K({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new K({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Oe()}}down(e,t){let n=De(e);n.length!==0&&(this._checkGuard(t),this._emit(n))}emit(e,t){this._checkGuard(t),this._emit([[V,e]])}up(e,t){if(this._deps.length===0)return;let n=De(e);if(n.length===0)return;this._checkGuard(t);let s=t??{internal:!0};this._validateUpTiers(n);for(let o of this._deps)o.node.up?.(n,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let n of e){let s=t(n[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let c=Ne(t);if(!this._guard(c,"observe"))throw new K({actor:c,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let c of this._deps)st(c)}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},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 o=="function")try{o()}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 o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let n=0;n<e;n++){let s=n,o=this._deps[n];o.unsub=Nt,o.unsub=o.node.subscribe(i=>{if(o.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:s},this._actions);c&&this._maybeRunFnOnSettlement()}),t++}}catch(n){this._deps[t].unsub=null;for(let s=0;s<t;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}st(o)}}throw this._dirtyDepCount=0,n}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let t=this._deps.length,n=St(e);if(this._deps.push(n),this._sinks==null)return t;n.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(qe),n.unsub=Nt;try{n.unsub=e.subscribe(s=>{if(n.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw n.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(n){this._emit([[P,this._wrapFnError("cleanup threw",n)]])}else if(t!=null&&typeof t=="object"){let n=t.deactivate;if(typeof n=="function")try{n()}catch(s){this._emit([[P,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let n of this._deps){if(n.unsub!=null){let s=n.unsub;n.unsub=null;try{s()}catch{}}st(n)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let n=this._deps[e],s=t[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(o)}if(s!==ge){if(s===Z){this._depDirtied(n);return}if(s===q){this._depInvalidated(n),this._emit(ht);return}if(s===Q||s===re){this._emit([t]);return}if(s===j){this._emit(Ye);return}if(s===V)this._depSettledAsData(n,t[1]);else if(s===W)this._depSettledAsResolved(n);else if(s===Y)this._depSettledAsTerminal(n,!0);else if(s===P)this._depSettledAsTerminal(n,t[1]);else{this._emit([t]);return}if(!this._fn){(s===V||s===W)&&this._emit([t]),(s===Y||s===P)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(qe))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(pt),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[P,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(gt)}_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([[P,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([[P,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let t=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),n=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=t[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:n,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:n};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[P,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>kt?(this._rerunDepth=0,this._emit([[P,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${kt} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let n=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${n}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[ae,e[0]]:e;let n=!0,s=!1,o=!1,i=-1;for(let c of e){let u=t(c[0]);u<i&&(n=!1),u===3&&(s=!0),c[0]===Z&&(o=!0),i=u}let a=e;if(!n){let c=e.map((u,d)=>({m:u,i:d,tier:t(u[0])}));c.sort((u,d)=>u.tier-d.tier||u.i-d.i),a=c.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let c=0;for(;c<a.length&&t(a[c][0])===0;)c++;return c===0?[ae,...a]:[...a.slice(0,c),ae,...a.slice(c)]}return a}_emit(e){if(e.length===0)return;let t=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(c=>c[0]===j||c[0]===q);if(a.length===0)return;t=a}t=this._frameBatch(t);let s=null;for(let a=0;a<t.length;a++){let c=t[a],u=c[0];if(u!==Q&&u!==re){s?.push(c);continue}if(c.length<2)throw new Error(`Node "${this.name}": [[${u===Q?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let d=!0;if(this._pausable!==!1){let p=c[1];if(u===Q)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(p),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(p))d=!1;else if(this._pauseLocks.delete(p),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let h=this._pauseBuffer;this._pauseBuffer=[],this._emit(h)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}d?s?.push(c):s==null&&(s=t.slice(0,a))}if(s!=null){if(s.length===0)return;t=s}if(this._hasMeta&&t.some(a=>a[0]===j))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(Ye)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(t);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,c=[];for(let u of o){let d=a(u[0]);d<3||d===5?c.push(u):this._pauseBuffer.push(u)}c.length>0&&this._dispatchOrAccumulate(c)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[P,i]])}_updateState(e){let t=this._config.tierOf,n,s,o=-1,i=0;for(let d of e)t(d[0])===3&&i++;let a=i<=1,c=-1;if(this._versioning!=null&&i>1){for(let d=e.length-1;d>=0;d--)if(e[d][0]===V){c=d;break}}for(let d=0;d<e.length;d++){let p=e[d],h=p[0];if(h===V){if(p.length>=2){let f=!1;if(a&&this._cached!==void 0)try{f=this._equals(this._cached,p[1])}catch(l){s=this._wrapFnError("equals threw",l),o=d;break}if(f){n==null&&(n=e.slice(0,d)),n.push(We),this._status="resolved";continue}this._cached=p[1],this._versioning!=null&&(c<0||d===c)&&Ot(this._versioning,p[1],this._hashFn)}this._status="settled",n?.push(p)}else if(n?.push(p),h===Z)this._status="dirty";else if(h===W)this._status="resolved";else if(h===Y)this._status="completed";else if(h===P)this._status="errored";else if(h===q){this._cached=void 0,this._status="dirty";let f=this._cleanup;if(typeof f=="function"){this._cleanup=void 0;try{f()}catch{}}else if(f!=null&&typeof f=="object"){let l=f.invalidate;if(typeof l=="function")try{l()}catch{}}}else h===j&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=o>=0?n??e.slice(0,o):n??e;return s!=null?{finalMessages:u,equalsError:s}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let n of t)n(e)};_dispatchOrAccumulate(e){if(_t()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ve(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}Se(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);Se(this._deliverToSinks,t,this._config.tierOf)}},Rt=r=>Array.isArray(r),ot=r=>typeof r=="object"&&r!=null&&!Array.isArray(r)});function pn(r,e,t){return t?!1:r.some((n,s)=>!(n!=null&&n.length>0)&&e.prevData[s]===void 0)}function ee(r,e){return Me([],{...e,initial:r})}function At(r,e){return Me((n,s,o)=>r(s,o)??void 0,{describeKind:"producer",...e})}function ie(r,e,t){let n=t?.partial??!1;return Me(r,(o,i,a)=>{if(pn(o,a,n)){i.down([[W]]);return}let c=o.map((u,d)=>u!=null&&u.length>0?u.at(-1):a.prevData[d]);i.emit(e(c,a))},{describeKind:"derived",...t})}var it=U(()=>{"use strict";me();_e()});function ut(r){return r.subscribe(()=>{})}var Dt=U(()=>{"use strict"});var Ge,Mt=U(()=>{"use strict";Ge=class{_timer;_gen=0;start(e,t){this.cancel(),this._gen+=1;let n=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,n===this._gen&&t()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Wn={};Xt(Wn,{collection:()=>zn,decay:()=>lt,knowledgeGraph:()=>Un,lightCollection:()=>Hn,vectorIndex:()=>Bn});module.exports=Qt(Wn);Ee();it();Ze();Qe();Ee();Ae();me();Ae();_e();function Ce(r,e){if(e!=null&&e.length>0)return new Set(e);switch(r){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;default:return new Set(["type","deps"])}}function hn(r){return r._describeKind!=null?r._describeKind:r._deps.length>0?"derived":r._fn!=null?"producer":"state"}function gn(r){let e={};for(let[t,n]of Object.entries(r.meta))try{e[t]=n.cache}catch{}return e}function at(r,e){let t=e==null,n=!t&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,s=t||e.has("meta")||n!=null&&n.length>0,o="state",i=[];r instanceof C&&(o=hn(r),i=r._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(t||e.has("status"))&&(a.status=r.status);let c=r instanceof C?r._guard:void 0;if(s){let u={...gn(r)};if(c!=null&&u.access===void 0&&(u.access=et(c)),n!=null&&n.length>0&&!e.has("meta")){let d={};for(let p of n)p in u&&(d[p]=u[p]);a.meta=d}else a.meta=u}if(r.name!=null&&(a.name=r.name),t||e.has("value")){r.status==="sentinel"&&(a.sentinel=!0);try{a.value=r.cache}catch{}}if((t||e.has("v"))&&r.v!=null){let u={id:r.v.id,version:r.v.version};"cid"in r.v&&(u.cid=r.v.cid,u.prev=r.v.prev),a.v=u}return(t||e.has("guard"))&&c!=null&&(a.guard=et(c)),(t||e.has("lastMutation"))&&r.lastMutation!=null&&(a.lastMutation=r.lastMutation),a}_e();it();Dt();Mt();var we=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let t=(this.head+this._size)%this.capacity;this.buf[t]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let t=e<0?this._size+e:e;if(!(t<0||t>=this._size))return this.buf[(this.head+t)%this.capacity]}toArray(){let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this.buf[(this.head+t)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};Xe();function Ct(r,e,t,n={}){let s=e in r.nodes,o=t in r.nodes;if(!s)return $e(e,t,"no-such-from");if(!o)return $e(e,t,"no-such-to");let i=n.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(n.findCycle===!0){let u=mn(r,e,n);if(u!=null)return u}let c=Pe(e,r.nodes[e],0,n);return Ie(e,t,[c])}if(i===0)return $e(e,t,"no-path");let a=Gt(r,e,t,i);return a.found?Ie(e,t,$t(r,a.pathOrder,n)):$e(e,t,a.truncated?"max-depth-exceeded":"no-path")}function Gt(r,e,t,n){let s=new Map,o=[{path:t,depth:0}],i=new Set([t]),a=0,c=!1;for(;a<o.length;){let p=o[a++];if(p.path===e)break;if(n!=null&&p.depth>=n){let g=r.nodes[p.path];g?.deps&&g.deps.length>0&&(c=!0);continue}let h=r.nodes[p.path];if(h==null)continue;let f=h.deps??[],l=new Map;for(let g=0;g<f.length;g++){let m=f[g];if(!m)continue;let y=l.get(m);y==null&&(y=[],l.set(m,y)),y.push(g)}for(let[g,m]of l)i.has(g)||(i.add(g),s.set(g,{from:p.path,depIndices:m}),o.push({path:g,depth:p.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:c};let u=[{path:e}],d=e;for(;d!==t;){let p=s.get(d);if(p==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=p.depIndices,u.push({path:p.from}),d=p.from}return{found:!0,pathOrder:u,truncated:!1}}function mn(r,e,t){let n=r.nodes[e];if(n==null)return null;let s=n.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=Pe(e,n,0,t);a.dep_index=o[0];let c=Pe(e,n,1,t);return Ie(e,e,[a,c])}let i=null;for(let a=0;a<s.length;a++){let c=s[a];if(!c||c===e)continue;let u=Gt(r,c,e,t.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:Ie(e,e,$t(r,i.pathOrder,t))}function $t(r,e,t){return e.map((n,s)=>{let o=r.nodes[n.path],i=Pe(n.path,o,s,t);return n.depIndices!=null&&n.depIndices.length>0&&(i.dep_index=n.depIndices[0],n.depIndices.length>1&&(i.dep_indices=[...n.depIndices])),i})}function Pe(r,e,t,n){let s={path:r,type:e.type,hop:t};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=n.annotations?.get(r)??e.annotation;o!=null&&(s.annotation=o);let i=n.lastMutations?.get(r)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function Ie(r,e,t){return Pt(r,e,!0,"ok",t)}function $e(r,e,t){return Pt(r,e,!1,t,[])}function Pt(r,e,t,n,s){let o=bn(r,e,t,n,s);return{from:r,to:e,found:t,reason:n,steps:s,text:o,toJSON(){return{from:r,to:e,found:t,reason:n,steps:s}}}}function bn(r,e,t,n,s){if(!t)switch(n){case"no-such-from":return`explainPath: no node named "${r}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${r}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${r}" to "${e}"`}let o=[`Causal path: ${r} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let c=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(c),"value"in i&&o.push(` value: ${yn(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;o.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return o.join(`
2
+ `)}function yn(r){if(r===void 0)return"<sentinel>";if(r===null)return"null";if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean"||typeof r=="bigint")return String(r);try{let e=JSON.stringify(r);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(r)}}_e();var G={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},vn=Symbol.for("sizeof");function It(r){let e=new WeakSet,t=new WeakSet,n=[r],s=0;for(;n.length>0;){let o=n.pop();s+=_n(o,e,t,n)}return s}function _n(r,e,t,n){if(r==null)return 0;switch(typeof r){case"number":return G.number;case"boolean":return G.boolean;case"string":return G.string+r.length*2;case"bigint":return G.bigint+wn(r);case"symbol":return G.symbol;case"function":return e.has(r)?0:(e.add(r),G.function);case"undefined":return 0}let o=r;if(e.has(o))return 0;e.add(o);let i=o[vn];if(typeof i=="function")try{let u=i.call(o);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(o instanceof Date)return G.date;if(o instanceof RegExp)return G.regexp+o.source.length*2;if(o instanceof Error){let u=o.message?o.message.length*2:0,d=o.stack?o.stack.length*2:0;return G.error+u+d}if(typeof URL<"u"&&o instanceof URL)return G.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return G.promise;if(o instanceof WeakMap)return G.weakmap;if(o instanceof WeakSet)return G.weakset;if(o instanceof Map){let u=G.map;for(let[d,p]of o)u+=G.mapEntry,n.push(d),n.push(p);return u}if(o instanceof Set){let u=G.set;for(let d of o)u+=G.setEntry,n.push(d);return u}if(Array.isArray(o)){let u=G.array+o.length*8;for(let d of o)n.push(d);return u}if(o instanceof ArrayBuffer)return t.has(o)?0:(t.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let u=o;return t.has(u.buffer)?48:(t.add(u.buffer),u.buffer.byteLength+48)}let a=G.object,c=Object.keys(o);for(let u of c){a+=G.string+u.length*2;try{n.push(o[u])}catch{}}return a}function wn(r){let e=r<0n?-r:r;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}function Ft(r,e){let t=e?.topN??10,n=r.describe({detail:"standard"}),s=[],o=r._collectObserveTargets;typeof o=="function"&&o.call(r,"",s);let i=new Map;for(let[h,f]of s)i.set(h,f);let a=[];for(let[h,f]of Object.entries(n.nodes)){let l=i.get(h),g=l instanceof C?l:null,m=g?It(g.cache):0,y=g?g._sinkCount:0,_=f.deps?.length??0,b=f.type==="effect"&&y===0,v=y===0?f.type==="effect"?"orphan-effect":f.type==="derived"?"idle-derived":f.type==="producer"?"idle-producer":null:null;a.push({path:h,type:f.type,status:f.status??"unknown",valueSizeBytes:m,subscriberCount:y,depCount:_,isOrphanEffect:b,orphanKind:v})}let c=a.reduce((h,f)=>h+f.valueSizeBytes,0),u=(h,f)=>[...a].sort(f??((l,g)=>g[h]-l[h])).slice(0,t),d=a.filter(h=>h.orphanKind!=null),p=a.filter(h=>h.isOrphanEffect);return{nodeCount:a.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:a,totalValueSizeBytes:c,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:d,orphanEffects:p}}var M="::",J="__meta__",fe=1;function Lt(r,e){let t=Math.max(16,r.size*4),n=0;for(;r.size>0;){if(n++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${r.size} disposer(s) discarded`),r.clear();return}let s=r.values().next();if(s.done)return;let o=s.value;r.delete(o);try{o()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Tn(r){let e=[];for(let t of Object.keys(r).sort()){let n=r[t].v;n!=null&&e.push(`${t} ${n.id} ${n.version}`)}return e.join(`
3
+ `)}function Vt(r){if(r.version!==fe)throw new Error(`unsupported snapshot version ${String(r.version)} (expected ${fe})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in r))throw new Error(`snapshot missing required key "${e}"`);if(typeof r.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof r.nodes!="object"||r.nodes===null||Array.isArray(r.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(r.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(r.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function xn(r,e){let t=new WeakMap,n=(s,o)=>{if(Object.is(s,o))return!0;if(s==null||o==null||typeof s!="object"||typeof o!="object")return!1;let i=t.get(s);if(i==null&&(i=new WeakSet,t.set(s,i)),i.has(o))return!0;i.add(o);let a=s.constructor,c=o.constructor;if(a!==c)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let h=o;if(s.length!==h.length)return!1;for(let f=0;f<s.length;f++)if(!n(s[f],h[f]))return!1;return!0}if(s instanceof Map){let h=o;if(s.size!==h.size)return!1;for(let[f,l]of s)if(!h.has(f)||!n(l,h.get(f)))return!1;return!0}if(s instanceof Set){let h=o;if(s.size!==h.size)return!1;for(let f of s){let l=!1;for(let g of h)if(n(f,g)){l=!0;break}if(!l)return!1}return!0}if(ArrayBuffer.isView(s)){let h=s,f=o;if(h.length!==f.length)return!1;for(let l=0;l<h.length;l++)if(h[l]!==f[l])return!1;return!0}let u=Object.keys(s),d=Object.keys(o);if(u.length!==d.length)return!1;let p=new Set(d);for(let h of u)if(!p.has(h)||!n(s[h],o[h]))return!1;return!0};return n(r,e)}function dt(r){if(r===null||typeof r!="object")return r;if(Array.isArray(r))return r.map(dt);let e=r,t=Object.keys(e).sort(),n={};for(let s of t)n[s]=dt(e[s]);return n}function On(r){return r.replaceAll("\\","\\\\").replaceAll('"','\\"')}function En(r){return r.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Nn(r){return r==="TD"?"down":r==="BT"?"up":r==="RL"?"left":"right"}function zt(r){let e=new Set,t=[];function n(s,o){let i=`${s}\0${o}`;e.has(i)||(e.add(i),t.push([s,o]))}for(let[s,o]of Object.entries(r.nodes)){let i=o.deps;if(i)for(let a of i)n(a,s)}for(let s of r.edges)n(s.from,s.to);return t}function Bt(r){if(r===void 0)return"LR";if(r==="TD"||r==="LR"||r==="BT"||r==="RL")return r;throw new Error(`invalid diagram direction ${String(r)}; expected one of: TD, LR, BT, RL`)}function kn(r,e){let t=e.includeEdges??!0,n=e.includeSubgraphs??!0,{expand:s,...o}=r,i={...o,edges:t?r.edges:[],subgraphs:n?r.subgraphs:[]},a=JSON.stringify(dt(i),null,e.indent??2);return e.logger?.(a),a}function Sn(r,e){let t=e.includeEdges??!0,n=e.includeSubgraphs??!0,s=[];s.push(`Graph ${r.name}`),s.push("Nodes:");for(let i of Object.keys(r.nodes).sort()){let a=r.nodes[i];s.push(`- ${i} (${a.type}/${a.status}): ${Le(a.value)}`)}if(t){s.push("Edges:");for(let i of r.edges)s.push(`- ${i.from} -> ${i.to}`)}if(n){s.push("Subgraphs:");for(let i of r.subgraphs)s.push(`- ${i}`)}let o=s.join(`
4
+ `);return e.logger?.(o),o}function Ut(r,e){let t=Bt(e.direction),n=Object.keys(r.nodes).sort(),s=new Map;for(let i=0;i<n.length;i+=1)s.set(n[i],`n${i}`);let o=[`flowchart ${t}`];for(let i of n){let a=s.get(i);o.push(` ${a}["${On(i)}"]`)}for(let[i,a]of zt(r)){let c=s.get(i),u=s.get(a);!c||!u||o.push(` ${c} --> ${u}`)}return o.join(`
5
+ `)}function Rn(r,e){let t=Ut(r,e);return An(t)}function An(r,e){let t=e?.theme??"default",n=e?.autoSync??!0,o=JSON.stringify({code:r,mermaid:{theme:t},autoSync:n}),i=new TextEncoder().encode(o),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function Dn(r,e){let t=Bt(e.direction),n=Object.keys(r.nodes).sort(),s=new Map;for(let i=0;i<n.length;i+=1)s.set(n[i],`n${i}`);let o=[`direction: ${Nn(t)}`];for(let i of n){let a=s.get(i);o.push(`${a}: "${En(i)}"`)}for(let[i,a]of zt(r)){let c=s.get(i),u=s.get(a);!c||!u||o.push(`${c} -> ${u}`)}return o.join(`
6
+ `)}function Mn(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fe(r){let e="^";for(let t=0;t<r.length;t+=1){let n=r[t];if(n==="*"){e+=".*";continue}if(n==="?"){e+=".";continue}if(n==="["){let s=r.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let o=r.slice(t+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,t=s;continue}e+=Mn(n)}return e+="$",new RegExp(e)}var Cn={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"},Gn={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function Le(r){if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean"||r==null)return String(r);try{return JSON.stringify(r)}catch{return"[unserializable]"}}function $n(r){return r==="none"?Gn:r==="ansi"||r==null?Cn:{data:r.data??"",dirty:r.dirty??"",resolved:r.resolved??"",invalidate:r.invalidate??"",pause:r.pause??"",resume:r.resume??"",complete:r.complete??"",error:r.error??"",teardown:r.teardown??"",derived:r.derived??"",path:r.path??"",reset:r.reset??""}}function jt(r){if(r==null)return{};let e=r.detail;return e==="full"?{...r,structured:r.structured??!0,timeline:r.timeline??!0,causal:r.causal??!0,derived:r.derived??!0}:e==="minimal"?{...r,structured:r.structured??!0}:r.format==="stage-log"?{...r,structured:r.structured??!0,timeline:r.timeline??!0}:r}function Pn(r,e,t){for(let n=0;n<r.length;n++){let s=r.charCodeAt(n);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${r}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function ct(r,e,t){if(r==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(r.includes(M))throw new Error(`Graph "${e}": ${t} "${r}" must not contain '${M}' (path separator)`);if(r===J)throw new Error(`Graph "${e}": ${t} name "${J}" is reserved for meta companion paths`);Pn(r,e,t)}function In(r,e){if(r==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=r.split(M);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function Fn(r,e){let t=!1;for(let s of r)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?r.filter(s=>e.isMetaPassthrough(s[0])):r}function Wt(r){for(let e of r._mounts.values())Wt(e);for(let e of r._nodes.values())try{e.down([[j]],{internal:!0})}catch{}}var pe=class r{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_topology;_topologyEmitters=new Set;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(M))throw new Error(`Graph name must not contain '${M}' (got "${e}")`);if(e===J)throw new Error(`Graph name "${J}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??le,this._traceRing=new we(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning)}ancestors(e=!0){let t=[],n=e?this:this._parent;for(;n!=null;)t.push(n),n=n._parent;return t}get topology(){return this._topology==null&&(this._topology=At(e=>{let t=n=>{e.emit(n)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}add(e,t){let n=e.name,s=t?.name??n;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,i=t?.annotation;if(ct(o,this.name,"add"),this._mounts.has(o))throw new Error(`Graph "${this.name}": name "${o}" is already a mount point`);if(this._nodes.has(o))throw new Error(`Graph "${this.name}": node "${o}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(o,e),this._nodeToName.set(e,o),this._emitTopology({kind:"added",name:o,nodeKind:"node"}),i!=null&&(this._annotations.set(o,i),this.config.inspectorEnabled&&this._traceRing.push({path:o,annotation:i,timestamp_ns:H()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof C&&t._applyVersioning(e)}remove(e){ct(e,this.name,"remove");let t=this._mounts.get(e);if(t){let o={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,c]of i)a.includes(`${M}${J}${M}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...t._collectSubgraphs(`${e}${M}`)),this._mounts.delete(e),t._parent=void 0,Wt(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:o}),o}let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(n),n.down([[j]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let t=typeof e=="function"?e:(()=>{let o=Fe(e);return i=>o.test(i)})(),n={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>t(o));for(let o of s){let i=this.remove(o);n.nodes.push(...i.nodes),n.mounts.push(...i.mounts)}return n.nodes.sort(),n.mounts.sort(),n}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,n=0;return{[Symbol.iterator](){return this},next(){if(n>=e.length)return{value:void 0,done:!0};let s=e[n++];return{value:[s,t.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(M))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,n){let s=n?.internal===!0;this.node(e).down([[V,t]],{actor:n?.actor,internal:s,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);wt(()=>{for(let[s,o]of n)this.set(s,o,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[q]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let s=n?.internal===!0;this.node(e).down([[P,t]],{actor:n?.actor,internal:s,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[Y]],{actor:t?.actor,internal:n,delivery:"write"})}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[c,u]of this._nodes)n.set(u,c);let a=[];for(let[c,u]of this._nodes)if(u instanceof C)for(let d of u._deps){let p=n.get(d.node);p!=null&&a.push([p,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 s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,c]of s)o.set(c,a);let i=[];for(let[a,c]of s)if(c instanceof C)for(let u of c._deps){let d=o.get(u.node);d!=null&&i.push([d,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,t){if(ct(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(t===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(t._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${t._parent.name}"`);for(let n=this;n!=null;n=n._parent)if(n===t)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,t),t._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),t}resolve(e){let t=In(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let n=t[0],s=t.slice(1);if(s.length===0){let a=this._nodes.get(n);if(a)return a;throw this._mounts.has(n)?new Error(`Graph "${this.name}": path ends at subgraph "${n}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${n}"`)}let o=this._nodes.get(n);if(o&&s.length>0&&s[0]===J)return this._resolveMetaChainFromNode(o,s,t.join(M));let i=this._mounts.get(n);if(!i)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${s.join(M)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(s.join(M))}_resolveMetaChainFromNode(e,t,n){let s=e,o=0,i=[...t];for(;o<i.length;){if(i[o]!==J)throw new Error(`Graph "${this.name}": expected ${J} segment in meta path "${n}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${J} in "${n}"`);let a=i[o+1],c=s.meta[a];if(!c)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${n}"`);s=c,o+=2}return s}signal(e,t){if(t?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let n=[];if(this._signalDeliver(e,t??{},new Set,n),n.length>0)throw n[0]}_signalDeliver(e,t,n,s){for(let c of this._mounts.values())c._signalDeliver(e,t,n,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=Fn(e,this.config);for(let c of[...this._nodes.keys()].sort()){let u=this._nodes.get(c);if(!n.has(u)){n.add(u);try{u.down(e,i)}catch(d){if(d instanceof K)throw d;s.push(d)}a.length!==0&&this._signalMetaSubtree(u,a,n,i,s)}}}_signalMetaSubtree(e,t,n,s,o){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!n.has(a)){n.add(a);try{a.down(t,s)}catch(c){if(c instanceof K)throw c;o.push(c)}this._signalMetaSubtree(a,t,n,s,o)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let t=e?.actor,n=e?.filter,s=Ce(e?.detail,e?.fields),o=e?.format==="spec",i=o?Ce("minimal"):s,a=[];this._collectObserveTargets("",a);let c=new Map;for(let[w,T]of a)c.set(T,w);let u=[];{let w=a.map(([,S])=>S),T=new Set(c.values()),E=0;for(;w.length>0;){let S=w.shift();if(S instanceof C)for(let $ of S._deps){let N=$.node;if(c.has(N))continue;let R=N.name??"",k=R;if(!k||T.has(k))if(R){let I=2;for(;T.has(`${R}#${I}`);)I++;k=`${R}#${I}`}else for(k=`__internal__/${E++}`;T.has(k);)k=`__internal__/${E++}`;c.set(N,k),T.add(k),u.push([k,N]),w.push(N)}}}let d=[...a,...u],p={};for(let[w,T]of d){if(t!=null&&!T.allowsObserve(t))continue;let E=at(T,i),S=T instanceof C?T._deps.map(k=>c.get(k.node)??k.node.name??""):[],{name:$,...N}=E,R={...N,deps:S};if(!o){let k=this._annotations.get(w);k!=null&&(R.annotation=k)}if(n!=null)if(typeof n=="function"){let k=n;if(!(k.length>=2?k(w,R):k(R)))continue}else{let k=!0;for(let[I,X]of Object.entries(n)){let ne=I==="deps_includes"?"depsIncludes":I==="meta_has"?"metaHas":I;if(ne==="depsIncludes"){if(!R.deps.includes(String(X))){k=!1;break}continue}if(ne==="metaHas"){if(!Object.hasOwn(R.meta??{},String(X))){k=!1;break}continue}if(R[ne]!==X){k=!1;break}}if(!k)continue}p[w]=R}let h=new Set(Object.keys(p)),f=[];for(let[w,T]of d)if(T instanceof C)for(let E of T._deps){let S=c.get(E.node);S!=null&&f.push([S,w])}f.sort((w,T)=>w[0]<T[0]?-1:w[0]>T[0]?1:w[1]<T[1]?-1:w[1]>T[1]?1:0);let l=f.map(([w,T])=>({from:w,to:T}));(t!=null||n!=null)&&(l=l.filter(w=>h.has(w.from)&&h.has(w.to)));let g=this._collectSubgraphs(""),m=t!=null||n!=null?g.filter(w=>{let T=`${w}${M}`;return[...h].some(E=>E===w||E.startsWith(T))}):g,y=this,_=e,b={name:this.name,nodes:p,edges:l,subgraphs:m,expand(w){let T={..._,format:void 0};return Array.isArray(w)?(T.fields=w,T.detail=void 0):(T.detail=w,T.fields=void 0),y.describe(T)}},v=e??{},x=v.format;return x==="json"?kn(b,v):x==="pretty"?Sn(b,v):x==="mermaid"?Ut(b,v):x==="mermaid-url"?Rn(b,v):x==="d2"?Dn(b,v):b}_collectSubgraphs(e){let t=[];for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${n}`;t.push(s),t.push(...this._mounts.get(n)._collectSubgraphs(`${s}${M}`))}return t}resourceProfile(e){return Ft(this,e)}reachable(e,t,n={}){return n.withDetail===!0?Ht(this.describe(),e,t,{...n,withDetail:!0}):Ht(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(e,t,n)}_explainStatic(e,t,n){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,c]of Object.entries(s.nodes))c.lastMutation!=null&&i.set(a,c.lastMutation);return Ct(s,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",s=0,o=ee(s,{name:`${n}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=()=>{a||c||(a=!0,ve(()=>{a=!1,!c&&(s+=1,o.emit(s))}))},d=i.onEvent(m=>{let y=m.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||u()}),p=[],h=new WeakSet,f=m=>{if(h.has(m)||c)return;h.add(m);let y=m.topology.subscribe(_=>{for(let b of _){if(b[0]!==V)continue;let v=b[1];if(u(),v.kind==="added"&&v.nodeKind==="mount"){let x=m._mounts.get(v.name);x!=null&&f(x)}}});p.push(y);for(let _ of m._mounts.keys()){let b=m._mounts.get(_);b!=null&&f(b)}};f(this);let l;try{l=ie([o],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,y)=>m===y})}catch(m){d();for(let y of p)y();throw i.dispose(),m}let g=ut(l);return{node:l,dispose(){c=!0,d();for(let m of p)m();p.length=0,i.dispose(),g()}}}_explainReactive(e,t,n){let s=0,o=ee(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=i.onEvent(f=>{let l=f.type;l!=="data"&&l!=="error"&&l!=="complete"&&l!=="teardown"||a||c||(a=!0,ve(()=>{a=!1,!c&&(s+=1,o.emit(s))}))}),d={...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{}},p;try{p=ie([o],()=>this._explainStatic(e,t,d),{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:t},equals:(f,l)=>f.found===l.found&&f.reason===l.reason&&f.steps.length===l.steps.length&&Vn(f.steps,l.steps)})}catch(f){throw u(),i.dispose(),f}let h=ut(p);return{node:p,dispose(){c=!0,u(),i.dispose(),h()}}}_pathsMatching(e){let t=Fe(e),n=[];return this._collectObserveTargets("",n),n.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${M}${n}`;this._mounts.get(n)._collectObserveTargets(s,t)}for(let n of[...this._nodes.keys()].sort()){let s=this._nodes.get(n),o=e===""?n:`${e}${M}${n}`;t.push([o,s]),this._appendMetaObserveTargets(o,s,t)}}_appendMetaObserveTargets(e,t,n){for(let s of Object.keys(t.meta).sort()){let o=t.meta[s],i=`${e}${M}${J}${M}${s}`;n.push([i,o]),this._appendMetaObserveTargets(i,o,n)}}observe(e,t){let n=typeof e=="string",o=jt(n?t:e),i=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,a=o.actor;if(n){let d=e,p=this.resolve(d);if(a!=null&&!p.allowsObserve(a))throw new K({actor:a,action:"observe",nodeName:d});return i?this._buildStructuredObserver([[d,p]],o,"one"):{subscribe(h){return p.subscribe(h)},up(h){try{p.up?.(h)}catch(f){if(f instanceof K)return;throw f}}}}let c=[];this._collectObserveTargets("",c),c.sort((d,p)=>d[0]<p[0]?-1:d[0]>p[0]?1:0);let u=a==null?c:c.filter(([,d])=>d.allowsObserve(a));return i?this._buildStructuredObserver(u,o,"all"):{subscribe:d=>{let p=u.map(([h,f])=>f.subscribe(l=>{d(h,l)}));return()=>{for(let h of p)h()}},up:(d,p)=>{try{this.resolve(d).up?.(p)}catch(h){if(h instanceof K)return;throw h}}}}_buildStructuredObserver(e,t,n){let s=n==="one"?e[0]?.[0]:void 0,o=i=>{if(n==="one"&&s!=null){let d=this.resolve(s);return this._buildStructuredObserver([[s,d]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((d,p)=>d[0]<p[0]?-1:d[0]>p[0]?1:0);let c=i.actor,u=c==null?a:a.filter(([,d])=>d.allowsObserve(c));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,t,o)}_createObserveResult(e,t,n){let s=t.timeline===!0,o=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",c=this.config.inspectorEnabled,u=(o||i)&&c,d=t.maxEvents,p=d!=null&&d>0?new we(d):null,h=[],f=new Set,l={},g=new Set,m=0,y=0,_=0,b=0,v=0,x=0,w=!1,T=!1,E=0,S=new Map,$=new Map,N=new Map,R=O=>{p?p.push(O):h.push(O);for(let D of f)D(O)},k=()=>s?{timestamp_ns:H(),in_batch:ke(),batch_id:E}:{},I=(O,D)=>{if(!(!u||!(O instanceof C)))return O._setInspectorHook(z=>{if(z.kind==="dep_message")S.set(O,z.depIndex);else if(z.kind==="run"){let he=z.batchData.map((A,L)=>A!=null&&A.length>0?A.at(-1):z.prevData[L]);$.set(O,he);let B=z.batchData.map(A=>A!=null?[...A]:void 0);N.set(O,B),i&&R({type:"derived",path:D,dep_values:he,dep_batches:B,...k()})}})},X=O=>{let D=S.get(O),z=$.get(O);if(!o||z==null)return{};let B=(D!=null&&D>=0&&O instanceof C?O._deps[D]:void 0)?.node,A=B?.v,L=N.get(O);return{trigger_dep_index:D,trigger_dep_name:B?.name,...A!=null?{trigger_version:{id:A.id,version:A.version}}:{},dep_values:[...z],...L!=null?{dep_batches:L}:{}}},ne=[],Te=[];for(let[O,D]of e){let z=I(D,O);z&&ne.push(z),Te.push(D.subscribe(he=>{E++;for(let B of he){let A=B[0],L=k();if(A===V){l[O]=B[1];let Be=D instanceof C?D.lastMutation?.actor??ue:ue;R({type:"data",path:O,data:B[1],actor:Be,...L,...X(D)})}else if(a)A===Z?m++:A===W?y++:A===q?_++:A===Q?b++:A===re?v++:A===j?x++:A===Y&&!g.has(O)?w=!0:A===P&&(T=!0,g.add(O));else if(A===Z)m++,R({type:"dirty",path:O,...L});else if(A===W)y++,R({type:"resolved",path:O,...L,...X(D)});else if(A===q)_++,R({type:"invalidate",path:O,...L});else if(A===Q)b++,R({type:"pause",path:O,lockId:B[1],...L});else if(A===re)v++,R({type:"resume",path:O,lockId:B[1],...L});else if(A===Y)g.has(O)||(w=!0),R({type:"complete",path:O,...L});else if(A===P){T=!0,g.add(O);let Be=D instanceof C?D.lastMutation?.actor??ue:ue;R({type:"error",path:O,data:B[1],actor:Be,...L})}else A===j&&(x++,R({type:"teardown",path:O,...L}))}}))}let je=!1,He=()=>{if(!je){je=!0;for(let O of Te)O();for(let O of ne)O();for(let O of xe)O({value:void 0,done:!0});xe.length=0}},ze=[],xe=[];f.add(O=>{let D=xe.shift();D?D({value:O,done:!1}):ze.push(O)});let ft={get values(){return l},get dirtyCount(){return m},get resolvedCount(){return y},get invalidateCount(){return _},get pauseCount(){return b},get resumeCount(){return v},get teardownCount(){return x},get events(){return p?p.toArray():[...h]},get anyCompletedCleanly(){return w},get anyErrored(){return T},get completedWithoutErrors(){return w&&!T},onEvent(O){return f.add(O),()=>f.delete(O)},dispose:He,expand(O){He();let D={...t};return typeof O=="string"?D.detail=O:Object.assign(D,O),n(jt(D))},[Symbol.asyncIterator](){return{next(){return ze.length>0?Promise.resolve({value:ze.shift(),done:!1}):je?Promise.resolve({value:void 0,done:!0}):new Promise(O=>xe.push(O))},return(){return He(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(ft,t),ft}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let s=t.logger??(l=>console.log(l)),o=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=o==null&&i==null?()=>!0:l=>(o==null||o.has(l))&&(i==null||!i.has(l)),c=$n(t.theme),u=n==="stage-log"?H():0,d=l=>l==null?"":t.stageLabels?.[l]??l,p=(l,g)=>l.length>g?`${l.slice(0,g-1)}\u2026`:l,h=l=>l.type==="data"||l.type==="error"?p(Le(l.data),120):"",f=l=>{if(n==="stage-log"){let T=(H()-u)/1e9,E=d(l.path).padEnd(9);if(l.type==="data"){let S=h(l);return`[${T.toFixed(3)}s] ${E} \u2190${S?` ${S}`:""}`}if(l.type==="error"){let S=h(l);return`[${T.toFixed(3)}s] ${E} \u2717${S?` ${S}`:""}`}return l.type==="complete"?`[${T.toFixed(3)}s] ${E} \u25A0 complete`:`[${T.toFixed(3)}s] ${E} ${l.type}`}if(n==="json")try{return JSON.stringify(l)}catch{return JSON.stringify({type:l.type,path:l.path,data:"[unserializable]"})}let g=c[l.type]??"",m=l.path?`${c.path}${l.path}${c.reset} `:"",y=l.type==="data"||l.type==="error",_=l.type==="pause"||l.type==="resume",b=y?` ${Le(l.data)}`:_?` ${Le(l.lockId)}`:"",v=l.type==="data"||l.type==="resolved"||l.type==="derived"?l:void 0,x=v?.trigger_dep_name!=null?` <- ${v.trigger_dep_name}`:v?.trigger_dep_index!=null?` <- #${v.trigger_dep_index}`:"",w=l.in_batch?" [batch]":"";return`${m}${g}${l.type.toUpperCase()}${c.reset}${b}${x}${w}`};e.onEvent(l=>{a(l.type)&&s(f(l),l)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){Lt(this._disposers,this.name),this.signal([[j]],{internal:!0}),Lt(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}snapshot(e){let{expand:t,...n}=this.describe({detail:"full"}),s={};for(let a of Object.keys(n.nodes).sort()){let{lastMutation:c,guard:u,...d}=n.nodes[a];s[a]=d}let o=[...n.subgraphs].sort(),i={...n,version:1,nodes:s,subgraphs:o};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return bt(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??le,{codec:s,codecVersion:o,payload:i}=yt(e,n);return s.decode(i,o)}restore(e,t){if(Vt(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let n=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(o=>Fe(o)),s=t?.includeProducers===!0;for(let o of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(a=>a.test(o)))continue;let i=e.nodes[o];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let c=this.tryResolve(o)?.v;if(c!=null&&c.id===i.v.id&&c.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){t?.onError?.(o,a)}}}}}static fromSnapshot(e,t){Vt(e);let n=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,o=new r(e.name);if(n)return n(o),o.restore(e),o;for(let f of[...e.subgraphs].sort((l,g)=>{let m=l.split(M).length,y=g.split(M).length;return m!==y?m-y:l<g?-1:l>g?1:0})){let l=f.split(M),g=o;for(let m of l)g._mounts.has(m)||g.mount(m,new r(m)),g=g._mounts.get(m)}let i=s?Object.entries(s).map(([f,l])=>({re:Fe(f),factory:l})):[],a=f=>{for(let l of i)if(l.re.test(f))return l.factory},c=f=>{let l=f.split(M),g=l.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${f}"`);let m=o;for(let y of l){let _=m._mounts.get(y);if(!_)throw new Error(`unknown mount "${y}" in path "${f}"`);m=_}return[m,g]},u=Object.entries(e.nodes).filter(([f])=>!f.includes(`${M}${J}${M}`)).sort((f,l)=>f[0]<l[0]?-1:f[0]>l[0]?1:0),d=new Map(u),p=new Map,h=!0;for(;d.size>0&&h;){h=!1;for(let[f,l]of[...d.entries()]){let g=l?.deps??[];if(!g.every(x=>p.has(x)))continue;let[m,y]=c(f),_={...l?.meta??{}},b=a(f),v;if(l?.type==="state")v=ee(l.value,{meta:_});else{if(b==null)continue;v=b(y,{path:f,type:l.type,value:l.value,meta:_,deps:g,resolvedDeps:g.map(x=>p.get(x))})}m.add(v,{name:y}),p.set(f,v),d.delete(f),h=!0}}if(d.size>0){let f=[...d.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${f}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachStorage(e,t={}){let n=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}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let s=(u,d)=>{if(u.disposed)return;let p=Tn(d.nodes);if(u.lastSnapshot!=null&&p!==""&&p===u.lastFingerprint)return;let h=u.seq+1,f=Oe(),m=u.lastSnapshot==null||h%u.compactEvery===0?{mode:"full",snapshot:d,seq:h,timestamp_ns:f,format_version:fe}:{mode:"diff",diff:Ln(u.lastSnapshot,d),seq:h,timestamp_ns:f,format_version:fe};if(u.tier.filter&&!u.tier.filter(this.name,m))return;let y;try{y=u.tier.save(this.name,m)}catch(_){t.onError?.(_,u.tier);return}if(y&&typeof y.then=="function"){let v=(u.savePending??Promise.resolve()).then(()=>y,()=>y).then(()=>{u.disposed||(u.seq=h,u.lastSnapshot=d,u.lastFingerprint=p)},x=>{t.onError?.(x,u.tier)});u.savePending=v.finally(()=>{u.savePending===v&&(u.savePending=void 0)})}else u.seq=h,u.lastSnapshot=d,u.lastFingerprint=p},o=(u,d)=>{try{s(u,d)}catch(p){t.onError?.(p,u.tier)}},i=(u,d)=>{if(!d.some(l=>{let g=this.config.messageTier(l[0]);return g>=3&&g<5}))return;if(t.filter){let l=this.tryResolve(u);if(l==null)return;let g=at(l,Ce("standard"));if(!t.filter(u,g))return}let h,f=()=>(h==null&&(h=this.snapshot()),h);for(let l of n)l.disposed||(l.debounceMs===0?o(l,f()):(l.timer==null&&(l.timer=new Ge),l.timer.start(l.debounceMs,()=>{l.disposed||o(l,this.snapshot())})))},a;if(t.paths!=null){let d=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(p=>{let h=this.tryResolve(p);return h==null?()=>{}:h.subscribe(f=>i(p,f))});a=()=>{for(let p of d)p()}}else a=this.observe().subscribe((u,d)=>i(u,d));let c=()=>{a();for(let u of n)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(c)};return this._storageDisposers.add(c),{dispose:c}}async _cascadeRestore(e,t){for(let n of e){let s;try{s=await n.load(this.name)}catch(i){t?.(i,n);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===fe&&o.nodes!=null)return this.restore(o),!0}catch(i){t?.(i,n)}}return!1}static async fromStorage(e,t,n){for(let s of t){let o;try{o=await s.load(e)}catch(c){n?.onError?.(c,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===fe&&i.nodes!=null?i:void 0;if(a!=null)try{return r.fromSnapshot(a,n)}catch(c){n?.onError?.(c,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,n){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:H(),...n?.actor!=null?{actor:n.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(s=>!e(s)),n=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return n}static diff(e,t){let n=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),o=[...s].filter(_=>!n.has(_)).sort(),i=[...n].filter(_=>!s.has(_)).sort(),a=[],c=[];for(let _ of n){if(!s.has(_))continue;let b=e.nodes[_],v=t.nodes[_],x=b.v,w=v.v;x!=null&&w!=null&&x.id===w.id&&x.version!==w.version&&c.push({path:_,id:x.id,from:x.version,to:w.version});let T=x!=null&&w!=null&&x.id===w.id&&x.version===w.version;for(let E of["type","status","sentinel"]){let S=b[E],$=v[E];S!==$&&a.push({path:_,field:E,from:S,to:$})}if(!T)for(let E of["value","meta"]){let S=b[E],$=v[E];xn(S,$)||a.push({path:_,field:E,from:S,to:$})}}let u=_=>`${_.from} ${_.to}`,d=new Set(e.edges.map(u)),p=new Set(t.edges.map(u)),h=t.edges.filter(_=>!d.has(u(_))),f=e.edges.filter(_=>!p.has(u(_))),l=new Set(e.subgraphs),g=new Set(t.subgraphs),m=[...g].filter(_=>!l.has(_)).sort(),y=[...l].filter(_=>!g.has(_)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:c,edgesAdded:h,edgesRemoved:f,subgraphsAdded:m,subgraphsRemoved:y}}};function Ln(r,e){let t=pe.diff(r,e),n={};for(let s of t.nodesAdded){let o=e.nodes[s];o!=null&&(n[s]=o)}return{...t,nodesAddedFull:n}}function Ht(r,e,t,n={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return n.withDetail?s:[];if(!n.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=n.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return n.withDetail?s:[];let i=new Map,a=new Map,c=new Map,u=new Map,d=new Set;for(let[b,v]of Object.entries(r.nodes)){if(!b)continue;d.add(b);let x=v.deps??[];i.set(b,x);for(let w of x)w&&(d.add(w),a.has(w)||a.set(w,new Set),a.get(w).add(b))}for(let b of r.edges){if(b==null||typeof b!="object")continue;let v=typeof b.from=="string"?b.from:"",x=typeof b.to=="string"?b.to:"";!v||!x||(d.add(v),d.add(x),u.has(v)||u.set(v,new Set),u.get(v).add(x),c.has(x)||c.set(x,new Set),c.get(x).add(v))}if(!d.has(e))return n.withDetail?s:[];let p=n.both===!0,h=b=>{if(p){let T=i.get(b)??[],E=c.get(b),S=a.get(b),$=u.get(b),N=[...T];return E&&N.push(...E),S&&N.push(...S),$&&N.push(...$),N}if(t==="upstream"){let T=i.get(b)??[],E=c.get(b);return E?[...T,...E]:T}let v=a.get(b),x=u.get(b),w=v?[...v]:[];return x&&w.push(...x),w},f=new Set([e]),l=new Map,g=[{path:e,depth:0}],m=0,y=!1;for(;m<g.length;){let b=g[m++];if(o!=null&&b.depth>=o){h(b.path).length>0&&(y=!0);continue}for(let v of h(b.path))!v||f.has(v)||(f.add(v),l.set(v,b.depth+1),g.push({path:v,depth:b.depth+1}))}let _=[...l.keys()].sort((b,v)=>b<v?-1:b>v?1:0);return n.withDetail?{paths:_,depths:l,truncated:y}:_}function Vn(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++){let n=r[t],s=e[t];if(n.path!==s.path||n.type!==s.type||n.status!==s.status||n.hop!==s.hop||n.dep_index!==s.dep_index||n.annotation!==s.annotation||n.value!==s.value||n.lastMutation!==s.lastMutation)return!1;let o=n.v,i=s.v;if(o!==i&&(o==null||i==null||o.id!==i.id||o.version!==i.version))return!1}return!0}function lt(r,e,t,n=0){if(!Number.isFinite(r))return n;if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0)return Math.max(n,r);let s=r*Math.exp(-t*e);return Math.max(n,s)}function Kt(r){if(r!==void 0&&r<1)throw new RangeError("maxSize must be >= 1")}function te(r){return new Map(r)}function F(r){return r.cache??new Map}function Ve(r){return r.cache??[]}function jn(r,e){let t=Math.max(r.length,e.length),n=0,s=0,o=0;for(let i=0;i<t;i+=1){let a=r[i]??0,c=e[i]??0;n+=a*c,s+=a*a,o+=c*c}return s===0||o===0?0:n/Math.sqrt(s*o)}function Hn(r={}){let e=r.maxSize,t=r.policy??"fifo";Kt(e);let n=ee(new Map,{name:r.name,describeKind:"state"});function s(i){if(e!==void 0)for(;i.size>e;){let a;for(let c of i.values()){if(!a){a=c;continue}let u=t==="lru"?c.lastAccessNs:c.createdAtNs,d=t==="lru"?a.lastAccessNs:a.createdAtNs;u<d&&(a=c)}if(!a)break;i.delete(a.id)}}function o(i){n.emit(i)}return{entries:n,upsert(i,a){let c=H(),u=F(n),d=u.get(i),p=te(u);p.set(i,{id:i,value:a,createdAtNs:d?.createdAtNs??c,lastAccessNs:c}),s(p),o(p)},remove(i){let a=te(F(n));a.delete(i)&&o(a)},clear(){F(n).size!==0&&o(new Map)},get(i){let a=F(n),c=a.get(i);if(c){if(t==="lru"){let u=H(),d=te(a);d.set(i,{...c,lastAccessNs:u}),o(d)}return c.value}},has(i){return F(n).has(i)}}}function zn(r,e={}){let t=e.maxSize,n=e.policy??"lru",s=e.decayRate??0,o=e.minScore??0,i=e.score??(()=>1);Kt(t);let a=new pe(r),c=ee(new Map,{name:"items",describeKind:"state"}),u=ie([c],([g])=>{let m=g??new Map,y=H(),_=[...m.values()].map(b=>{let v=(y-b.lastAccessNs)/1e9;return{...b,score:lt(b.baseScore,v,s,o)}});return _.sort((b,v)=>v.score-b.score||v.lastAccessNs-b.lastAccessNs),_},{name:"ranked",describeKind:"derived"}),d=ie([c],([g])=>(g??new Map).size,{name:"size",describeKind:"derived",initial:0});u.subscribe(()=>{}),d.subscribe(()=>{}),a.add(c,{name:"items"}),a.add(u,{name:"ranked"}),a.add(d,{name:"size"});function p(g,m){let y=(m-g.lastAccessNs)/1e9;return lt(g.baseScore,y,s,o)}function h(g){if(t!==void 0)for(;g.size>t;){let m=H(),y,_=Number.POSITIVE_INFINITY;for(let b of g.values()){let v=p(b,m);if(v<_){y=b,_=v;continue}if(v===_&&y){let x=n==="lru"?b.lastAccessNs:b.createdAtNs,w=n==="lru"?y.lastAccessNs:y.createdAtNs;x<w&&(y=b)}}if(!y)break;g.delete(y.id)}}function f(g){c.emit(g)}return Object.assign(a,{upsert(g,m,y){let _=H(),b=F(c),v=b.get(g),x=y?.score??i(m),w=te(b);w.set(g,{id:g,value:m,baseScore:x,createdAtNs:v?.createdAtNs??_,lastAccessNs:_}),h(w),f(w)},remove(g){let m=te(F(c));m.delete(g)&&f(m)},clear(){F(c).size!==0&&f(new Map)},getItem(g){let m=F(c),y=m.get(g);if(y){if(n==="lru"){let _=te(m);_.set(g,{...y,lastAccessNs:H()}),f(_)}return y}}})}function Bn(r={}){let e=r.backend??"flat",t=r.dimension,n;if(e==="hnsw"&&(n=r.hnswFactory?.(),!n))throw new Error('vectorIndex backend "hnsw" requires an optional dependency adapter; install your HNSW package and provide `hnswFactory`.');let s=ee(new Map,{describeKind:"state",name:"vector-index"});function o(a){if(t!==void 0&&a.length!==t)throw new RangeError(`vector dimension mismatch: expected ${t}, got ${a.length}`)}function i(a){s.emit(a)}return{backend:e,entries:s,upsert(a,c,u){o(c);let d=te(F(s));d.set(a,{id:a,vector:[...c],meta:u}),e==="hnsw"&&n.upsert(a,c,u),i(d)},remove(a){let c=te(F(s));c.delete(a)&&(e==="hnsw"&&n.remove(a),i(c))},clear(){F(s).size!==0&&(e==="hnsw"&&n.clear(),i(new Map))},search(a,c=5){return o(a),c<=0?[]:e==="hnsw"?n.search(a,c):[...F(s).values()].map(d=>({id:d.id,score:jn(a,d.vector),meta:d.meta})).sort((d,p)=>p.score-d.score).slice(0,c)}}}function Un(r){let e=new pe(r),t=ee(new Map,{name:"entities",describeKind:"state"}),n=ee([],{name:"edges",describeKind:"state"}),s=ie([n],([c])=>{let u=c??[],d=new Map;for(let p of u){let h=d.get(p.from)??[];d.set(p.from,Object.freeze([...h,p]))}return d},{name:"adjacency",describeKind:"derived",initial:new Map});s.subscribe(()=>{}),e.add(t,{name:"entities"}),e.add(n,{name:"edges"}),e.add(s,{name:"adjacency"});function o(c){t.emit(c)}function i(c){n.emit(c)}return Object.assign(e,{upsertEntity(c,u){let d=te(F(t));d.set(c,u),o(d)},removeEntity(c){let u=te(F(t)),d=u.delete(c),p=Ve(n),h=p.filter(f=>f.from!==c&&f.to!==c);!d&&h.length===p.length||(o(u),i(h))},link(c,u,d,p=1){let h=`${c}\0${u}\0${d}`,f=Ve(n),l=new Set(f.map(m=>`${m.from}\0${m.to}\0${m.relation}`)),g=[...f];if(l.has(h))for(let m=0;m<g.length;m+=1){let y=g[m];if(y.from===c&&y.to===u&&y.relation===d){g[m]={...y,weight:p};break}}else g.push({from:c,to:u,relation:d,weight:p});i(g)},unlink(c,u,d){let p=Ve(n),h=p.filter(f=>d===void 0?!(f.from===c&&f.to===u):!(f.from===c&&f.to===u&&f.relation===d));h.length!==p.length&&i(h)},related(c,u){return Ve(n).filter(d=>(d.from===c||d.to===c)&&(u===void 0||d.relation===u))}})}0&&(module.exports={collection,decay,knowledgeGraph,lightCollection,vectorIndex});
@@ -0,0 +1,5 @@
1
+ import '../../node-Cc1TniY8.cjs';
2
+ import '../../graph-D48Qw9Cg.cjs';
3
+ export { C as CollectionEntry, b as CollectionGraph, c as CollectionOptions, d as CollectionPolicy, H as HnswAdapter, e as KnowledgeEdge, K as KnowledgeGraphGraph, L as LightCollectionBundle, f as LightCollectionEntry, g as LightCollectionOptions, R as RankedCollectionEntry, h as VectorBackend, V as VectorIndexBundle, j as VectorIndexOptions, k as VectorRecord, a as VectorSearchResult, l as collection, m as decay, n as knowledgeGraph, o as lightCollection, v as vectorIndex } from '../../index-tbf2gKHd.cjs';
4
+ import '../../meta-Cgj6zeji.cjs';
5
+ import '../../extra/storage-core.cjs';
@@ -0,0 +1,5 @@
1
+ import '../../node-Cc1TniY8.js';
2
+ import '../../graph-BZGRXwOm.js';
3
+ export { C as CollectionEntry, b as CollectionGraph, c as CollectionOptions, d as CollectionPolicy, H as HnswAdapter, e as KnowledgeEdge, K as KnowledgeGraphGraph, L as LightCollectionBundle, f as LightCollectionEntry, g as LightCollectionOptions, R as RankedCollectionEntry, h as VectorBackend, V as VectorIndexBundle, j as VectorIndexOptions, k as VectorRecord, a as VectorSearchResult, l as collection, m as decay, n as knowledgeGraph, o as lightCollection, v as vectorIndex } from '../../index-DP4ZTkdw.js';
4
+ import '../../meta-CwesDrMD.js';
5
+ import '../../extra/storage-core.js';
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"../../chunk-GHJJR5P4.js";import"../../chunk-CKCSDI7T.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-VPYBOXVT.js";import"../../chunk-2PMCKKRK.js";import"../../chunk-ZB5EHBIO.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{c as collection,a as decay,e as knowledgeGraph,b as lightCollection,d as vectorIndex};
@@ -0,0 +1,6 @@
1
+ "use strict";var nt=Object.defineProperty;var on=Object.getOwnPropertyDescriptor;var an=Object.getOwnPropertyNames;var un=Object.prototype.hasOwnProperty;var W=(r,e)=>()=>(r&&(e=r(r=0)),e);var dn=(r,e)=>{for(var t in e)nt(r,t,{get:e[t],enumerable:!0})},cn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of an(e))!un.call(r,s)&&s!==t&&nt(r,s,{get:()=>e[s],enumerable:!(n=on(e,s))||n.enumerable});return r};var ln=r=>cn(nt({},"__esModule",{value:!0}),r);function Ce(r){if(r==null)return le;let{type:e,id:t,...n}=r;return{type:e??"system",id:t??"",...n}}var le,Me=W(()=>{"use strict";le={type:"system",id:""}});function Te(){return pe>0||_e}function Ot(){return pe>0}function Oe(r){pe>0?we.push(r):r()}function ie(r){pe+=1;let e=!1;try{r()}catch(t){throw e=!0,t}finally{if(pe-=1,pe===0)if(e){if(!_e){let t=we.splice(0);for(let n of t)try{n()}catch{}se.length=0,oe.length=0,fe.length=0}}else pn()}}function pn(){let r=!_e;r&&(_e=!0);let e=[],t=0;try{for(;se.length>0||oe.length>0||fe.length>0||r&&we.length>0;){if(r&&we.length>0){let o=we.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(t+=1,t>1e3)throw se.length=0,oe.length=0,fe.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(se.length>0?se:oe.length>0?oe:fe).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{r&&(_e=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function xe(r,e,t){if(e.length===0)return;if(e.length===1){let u=t(e[0][0]);if(u<3||!Te()){r(e);return}(u>=5?fe:u===4?oe:se).push(()=>r(e));return}let n=e.length,s=n,o=n,i=n,a=0;for(;a<n&&t(e[a][0])<3;)a++;for(s=a;a<n&&t(e[a][0])===3;)a++;for(o=a;a<n&&t(e[a][0])===4;)a++;i=a;let c=Te();if(s>0){let u=e.slice(0,s);r(u)}if(o>s){let u=e.slice(s,o);c?se.push(()=>r(u)):r(u)}if(i>o){let u=e.slice(o,i);c?oe.push(()=>r(u)):r(u)}if(n>i){let u=e.slice(i,n);c?fe.push(()=>r(u)):r(u)}}var pe,_e,se,oe,fe,we,Ee=W(()=>{"use strict";pe=0,_e=!1,se=[],oe=[],fe=[],we=[]});function he(){return Math.trunc(performance.now()*1e6)}function Ge(){return Date.now()*1e6}var rt=W(()=>{"use strict"});var ge,I,H,j,K,X,te,F,V,$,ae,$e,xt,Pe,Et,Nt,Ie,st,ot,it,Le,ue=W(()=>{"use strict";ge=Symbol.for("graphrefly/START"),I=Symbol.for("graphrefly/DATA"),H=Symbol.for("graphrefly/DIRTY"),j=Symbol.for("graphrefly/RESOLVED"),K=Symbol.for("graphrefly/INVALIDATE"),X=Symbol.for("graphrefly/PAUSE"),te=Symbol.for("graphrefly/RESUME"),F=Symbol.for("graphrefly/TEARDOWN"),V=Symbol.for("graphrefly/COMPLETE"),$=Symbol.for("graphrefly/ERROR"),ae=Object.freeze([H]),$e=Object.freeze([j]),xt=Object.freeze([K]),Pe=Object.freeze([ge]),Et=Object.freeze([V]),Nt=Object.freeze([F]),Ie=Object.freeze([ae]),st=Object.freeze([$e]),ot=Object.freeze([xt]),it=Object.freeze([Et]),Le=Object.freeze([Nt])});function kt(r){r.registerMessageType(ge,{tier:0,wireCrossing:!1}),r.registerMessageType(H,{tier:1,wireCrossing:!1}),r.registerMessageType(K,{tier:1,wireCrossing:!1,metaPassthrough:!1}),r.registerMessageType(X,{tier:2,wireCrossing:!1}),r.registerMessageType(te,{tier:2,wireCrossing:!1}),r.registerMessageType(I,{tier:3,wireCrossing:!0}),r.registerMessageType(j,{tier:3,wireCrossing:!0}),r.registerMessageType(V,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType($,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(F,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Fe,St=W(()=>{"use strict";ue();Fe=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let n=this._messageTypes.get(t);return n!=null?n.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function at(r){let e=fn.filter(t=>r({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}var q,fn,Ne=W(()=>{"use strict";q=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}},fn=["human","llm","wallet","system"]});function At(r,e){let t=new TextEncoder().encode(r.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${r.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let n=r.version;if(!Number.isInteger(n)||n<0||n>65535)throw new Error(`encodeEnvelope: codec.version ${n} out of u16 range (expected integer 0\u201365535)`);let s=2+t.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=ut,o[i++]=t.length,o.set(t,i),i+=t.length,o[i++]=n>>>8&255,o[i++]=n&255,o.set(e,i),o}function Rt(r,e){if(r.length<Dt)throw new Error(`decodeEnvelope: bytes too short (${r.length} < ${Dt})`);let t=0,n=r[t++];if(n!==ut)throw new Error(`decodeEnvelope: unsupported envelope version ${n} (expected ${ut})`);let s=r[t++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+s+2>r.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+s+2} bytes, have ${r.length})`);let o=new TextDecoder().decode(r.subarray(t,t+s));t+=s;let i=(r[t]<<8|r[t+1])>>>0;t+=2;let a=r.subarray(t),c=e.lookupCodec(o);if(c==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:c,codecVersion:i,payload:a}}function Ct(r){r.registerCodec(hn)}var hn,ut,Dt,dt=W(()=>{"use strict";hn={name:"json",version:1,contentType:"application/json",encode(r){let e=JSON.stringify(r);return new TextEncoder().encode(e)},decode(r,e){let t=new TextDecoder().decode(r);return JSON.parse(t)}},ut=1,Dt=4});function ct(r){if(r===void 0)return null;if(typeof r=="number"){if(!Number.isFinite(r))throw new TypeError(`Cannot hash non-finite number: ${r}`);if(Number.isInteger(r)&&!Number.isSafeInteger(r))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${r}. Cross-language cid parity is not guaranteed for unsafe integers.`);return r}if(typeof r=="string"||typeof r=="boolean"||r===null)return r;if(Array.isArray(r))return r.map(ct);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=ct(r[t]);return e}return null}function bn(r){let e=mn.encode(r),t=e.length,n=t*8,s=t+9+63&-64,o=new Uint8Array(s);o.set(e),o[t]=128;let i=new DataView(o.buffer);i.setUint32(s-4,n>>>0,!1),i.setUint32(s-8,Math.floor(n/4294967296)>>>0,!1);let a=1779033703,c=3144134277,u=1013904242,l=2773480762,f=1359893119,g=2600822924,p=528734635,d=1541459225,h=new Uint32Array(64),m=(v,b)=>v>>>b|v<<32-b;for(let v=0;v<s;v+=64){for(let N=0;N<16;N++)h[N]=i.getUint32(v+N*4,!1);for(let N=16;N<64;N++){let D=h[N-15],k=h[N-2],L=m(D,7)^m(D,18)^D>>>3,Z=m(k,17)^m(k,19)^k>>>10;h[N]=h[N-16]+L+h[N-7]+Z>>>0}let b=a,_=c,O=u,w=l,T=f,E=g,S=p,P=d;for(let N=0;N<64;N++){let D=m(T,6)^m(T,11)^m(T,25),k=T&E^~T&S,L=P+D+k+gn[N]+h[N]>>>0,Z=m(b,2)^m(b,13)^m(b,22),re=b&_^b&O^_&O,Ae=Z+re>>>0;P=S,S=E,E=T,T=w+L>>>0,w=O,O=_,_=b,b=L+Ae>>>0}a=a+b>>>0,c=c+_>>>0,u=u+O>>>0,l=l+w>>>0,f=f+T>>>0,g=g+E>>>0,p=p+S>>>0,d=d+P>>>0}let y=v=>v.toString(16).padStart(8,"0");return y(a)+y(c)+y(u)+y(l)+y(f)+y(g)+y(p)+y(d)}function lt(r){let e=ct(r??null),t=JSON.stringify(e);return bn(t).slice(0,16)}function yn(){let r=globalThis.crypto;if(r?.randomUUID)return r.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function pt(r,e,t){let n=t?.id??yn();if(r===0)return{id:n,version:0};let o=(t?.hash??lt)(e);return{id:n,version:0,cid:o,prev:null}}function Mt(r,e,t){r.version+=1,"cid"in r&&(r.prev=r.cid,r.cid=t(e))}var gn,mn,Gt=W(()=>{"use strict";gn=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]),mn=new TextEncoder});function It(r){return{node:r,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function ft(r){r.prevData=void 0,r.dirty=!1,r.involvedThisWave=!1,r.dataBatch.length=0,r.terminal=void 0}function ze(r){return r.length===0?r:typeof r[0]=="symbol"?[r]:r}function be(r,e,t){let n=Lt(r)?r:[],s=typeof r=="function"?r:typeof e=="function"?e:void 0,o={};return Lt(r)?o=(ht(e)?e:t)??{}:ht(r)?o=r:o=(ht(e)?e:t)??{},new M(n,s,o)}var $t,Pt,vn,_n,me,M,Lt,ht,ye=W(()=>{"use strict";dt();Me();Ee();rt();St();Ne();ue();Gt();$t=()=>{},Pt=100;vn=(r,e,t,n)=>{t.direction==="down-in"&&r._onDepMessage(t.depIndex,e)},_n=(r,e,t,n)=>{let s=r;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[Pe]:[Pe,[I,o]];s._status==="dirty"&&i.push(ae),xe(e,i,s._config.tierOf)},me=new Fe({onMessage:vn,onSubscribe:_n});kt(me);Ct(me);M=class r{_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;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,n){this._config=n.config??me,this._config.onMessage,this._optsName=n.name,this._describeKind=n.describeKind,this._equals=n.equals??Object.is,this._resubscribable=n.resubscribable??!1,this._resetOnTeardown=n.resetOnTeardown??!1,this._autoComplete=n.completeWhenDepsComplete??!0,this._autoError=n.errorWhenDepsError??!0,this._pausable=n.pausable??!0,this._guard=n.guard,this._fn=t,this._cached=n.initial!==void 0?n.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=n.versioningHash??this._config.defaultHashFn??lt;let s=n.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?pt(s,this._cached===void 0?void 0:this._cached,{id:n.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(It);let o={};for(let[a,c]of Object.entries(n.meta??{})){let u={initial:c,name:`${n.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};n.guard!=null&&(u.guard=n.guard),o[a]=new r([],void 0,u)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[I,a]])},down(a){i._emit(ze(a))},up(a){i._emitUp(ze(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let n=this._versioningLevel;if(n!=null&&e<=n)return;let s=t?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??t?.id,c=i?.version??0,u=pt(e,o,{id:a,hash:s});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 t=Ce(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let n of this._extraGuards)if(!n(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,n=e?.actor!=null;if(!t&&!n)return;let s=Ce(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new q({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new q({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Ge()}}down(e,t){let n=ze(e);n.length!==0&&(this._checkGuard(t),this._emit(n))}emit(e,t){this._checkGuard(t),this._emit([[I,e]])}up(e,t){if(this._deps.length===0)return;let n=ze(e);if(n.length===0)return;this._checkGuard(t);let s=t??{internal:!0};this._validateUpTiers(n);for(let o of this._deps)o.node.up?.(n,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let n of e){let s=t(n[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let c=Ce(t);if(!this._guard(c,"observe"))throw new q({actor:c,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let c of this._deps)ft(c)}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},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 o=="function")try{o()}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 o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let n=0;n<e;n++){let s=n,o=this._deps[n];o.unsub=$t,o.unsub=o.node.subscribe(i=>{if(o.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:s},this._actions);c&&this._maybeRunFnOnSettlement()}),t++}}catch(n){this._deps[t].unsub=null;for(let s=0;s<t;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}ft(o)}}throw this._dirtyDepCount=0,n}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let t=this._deps.length,n=It(e);if(this._deps.push(n),this._sinks==null)return t;n.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Ie),n.unsub=$t;try{n.unsub=e.subscribe(s=>{if(n.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw n.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(n){this._emit([[$,this._wrapFnError("cleanup threw",n)]])}else if(t!=null&&typeof t=="object"){let n=t.deactivate;if(typeof n=="function")try{n()}catch(s){this._emit([[$,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let n of this._deps){if(n.unsub!=null){let s=n.unsub;n.unsub=null;try{s()}catch{}}ft(n)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let n=this._deps[e],s=t[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(o)}if(s!==ge){if(s===H){this._depDirtied(n);return}if(s===K){this._depInvalidated(n),this._emit(ot);return}if(s===X||s===te){this._emit([t]);return}if(s===F){this._emit(Le);return}if(s===I)this._depSettledAsData(n,t[1]);else if(s===j)this._depSettledAsResolved(n);else if(s===V)this._depSettledAsTerminal(n,!0);else if(s===$)this._depSettledAsTerminal(n,t[1]);else{this._emit([t]);return}if(!this._fn){(s===I||s===j)&&this._emit([t]),(s===V||s===$)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Ie))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(st),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[$,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(it)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[$,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[$,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let t=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),n=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=t[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:n,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:n};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[$,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Pt?(this._rerunDepth=0,this._emit([[$,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Pt} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let n=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${n}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[ae,e[0]]:e;let n=!0,s=!1,o=!1,i=-1;for(let c of e){let u=t(c[0]);u<i&&(n=!1),u===3&&(s=!0),c[0]===H&&(o=!0),i=u}let a=e;if(!n){let c=e.map((u,l)=>({m:u,i:l,tier:t(u[0])}));c.sort((u,l)=>u.tier-l.tier||u.i-l.i),a=c.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let c=0;for(;c<a.length&&t(a[c][0])===0;)c++;return c===0?[ae,...a]:[...a.slice(0,c),ae,...a.slice(c)]}return a}_emit(e){if(e.length===0)return;let t=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(c=>c[0]===F||c[0]===K);if(a.length===0)return;t=a}t=this._frameBatch(t);let s=null;for(let a=0;a<t.length;a++){let c=t[a],u=c[0];if(u!==X&&u!==te){s?.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 g=this._pauseBuffer;this._pauseBuffer=[],this._emit(g)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}l?s?.push(c):s==null&&(s=t.slice(0,a))}if(s!=null){if(s.length===0)return;t=s}if(this._hasMeta&&t.some(a=>a[0]===F))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(Le)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(t);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,c=[];for(let u of o){let l=a(u[0]);l<3||l===5?c.push(u):this._pauseBuffer.push(u)}c.length>0&&this._dispatchOrAccumulate(c)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[$,i]])}_updateState(e){let t=this._config.tierOf,n,s,o=-1,i=0;for(let l of e)t(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]===I){c=l;break}}for(let l=0;l<e.length;l++){let f=e[l],g=f[0];if(g===I){if(f.length>=2){let p=!1;if(a&&this._cached!==void 0)try{p=this._equals(this._cached,f[1])}catch(d){s=this._wrapFnError("equals threw",d),o=l;break}if(p){n==null&&(n=e.slice(0,l)),n.push($e),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(c<0||l===c)&&Mt(this._versioning,f[1],this._hashFn)}this._status="settled",n?.push(f)}else if(n?.push(f),g===H)this._status="dirty";else if(g===j)this._status="resolved";else if(g===V)this._status="completed";else if(g===$)this._status="errored";else if(g===K){this._cached=void 0,this._status="dirty";let p=this._cleanup;if(typeof p=="function"){this._cleanup=void 0;try{p()}catch{}}else if(p!=null&&typeof p=="object"){let d=p.invalidate;if(typeof d=="function")try{d()}catch{}}}else g===F&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=o>=0?n??e.slice(0,o):n??e;return s!=null?{finalMessages:u,equalsError:s}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let n of t)n(e)};_dispatchOrAccumulate(e){if(Ot()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Oe(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}xe(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);xe(this._deliverToSinks,t,this._config.tierOf)}},Lt=r=>Array.isArray(r),ht=r=>typeof r=="object"&&r!=null&&!Array.isArray(r)});function On(r,e,t){return t?!1:r.some((n,s)=>!(n!=null&&n.length>0)&&e.prevData[s]===void 0)}function Q(r,e){return be([],{...e,initial:r})}function mt(r,e){return be((n,s,o)=>r(s,o)??void 0,{describeKind:"producer",...e})}function Y(r,e,t){let n=t?.partial??!1;return be(r,(o,i,a)=>{if(On(o,a,n)){i.down([[j]]);return}let c=o.map((u,l)=>u!=null&&u.length>0?u.at(-1):a.prevData[l]);i.emit(e(c,a))},{describeKind:"derived",...t})}var He=W(()=>{"use strict";ue();ye()});function ee(r){return r.subscribe(()=>{})}var yt=W(()=>{"use strict"});var We,Wt=W(()=>{"use strict";We=class{_timer;_gen=0;start(e,t){this.cancel(),this._gen+=1;let n=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,n===this._gen&&t()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Zn={};dn(Zn,{MessagingHubGraph:()=>Xe,SubscriptionGraph:()=>De,TopicBridgeGraph:()=>Je,TopicGraph:()=>Se,messagingHub:()=>Jn,subscription:()=>sn,topic:()=>Yn,topicBridge:()=>Xn});module.exports=ln(Zn);Me();Ee();Ne();ue();Ne();ye();function Ve(r,e){if(e!=null&&e.length>0)return new Set(e);switch(r){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;default:return new Set(["type","deps"])}}function wn(r){return r._describeKind!=null?r._describeKind:r._deps.length>0?"derived":r._fn!=null?"producer":"state"}function Tn(r){let e={};for(let[t,n]of Object.entries(r.meta))try{e[t]=n.cache}catch{}return e}function gt(r,e){let t=e==null,n=!t&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,s=t||e.has("meta")||n!=null&&n.length>0,o="state",i=[];r instanceof M&&(o=wn(r),i=r._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(t||e.has("status"))&&(a.status=r.status);let c=r instanceof M?r._guard:void 0;if(s){let u={...Tn(r)};if(c!=null&&u.access===void 0&&(u.access=at(c)),n!=null&&n.length>0&&!e.has("meta")){let l={};for(let f of n)f in u&&(l[f]=u[f]);a.meta=l}else a.meta=u}if(r.name!=null&&(a.name=r.name),t||e.has("value")){r.status==="sentinel"&&(a.sentinel=!0);try{a.value=r.cache}catch{}}if((t||e.has("v"))&&r.v!=null){let u={id:r.v.id,version:r.v.version};"cid"in r.v&&(u.cid=r.v.cid,u.prev=r.v.prev),a.v=u}return(t||e.has("guard"))&&c!=null&&(a.guard=at(c)),(t||e.has("lastMutation"))&&r.lastMutation!=null&&(a.lastMutation=r.lastMutation),a}He();ye();Ee();ue();He();var bt=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),e&&e.length>0){let n=Math.min(e.length,t),s=e.length-n;for(let o=0;o<n;o++)this._buf[o]=e[s+o];this._size=n}}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 t=e>=0?e:this._size+e;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let n=t;n<e.length;n++)this._rawAppend(e[n]);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 t=0;t<e;t++)this._buf[(this._head+t)%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 t=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let n=0;n<t;n++)this._buf[(this._head+n)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(e,t){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let n=t===void 0?this._size:Math.min(Math.max(t,0),this._size),s=Math.min(e,this._size);if(s>=n)return[];let o=n-s;if(this._maxSize===void 0)return this._buf.slice(s,n);let i=new Array(o);for(let a=0;a<o;a++)i[a]=this._buf[(this._head+s+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let t=Math.min(e,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this._buf[(this._head+t)%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 Ft(r){return r.subscribe(()=>{})}var xn=64;function zt(r,e={}){let{name:t,maxSize:n,versioning:s,backend:o}=e,i=o??new bt(r,n),a=Q(i.toArray(),{name:t,describeKind:"state",equals:(d,h)=>d===h,...s!=null?{versioning:s}:{}});function c(){let d=i.toArray();ie(()=>{a.down([[H]]),a.down([[I,d]])})}let u=new Map,l=new Map;function f(d,h){return`${d}:${h===void 0?"END":h}`}function g(d){if(d.size<xn)return;let h=d.keys().next();if(h.done)return;let m=d.get(h.value);m!==void 0&&m.dispose(),d.delete(h.value)}function p(d){let h=i.version;try{return d()}finally{i.version!==h&&c()}}return{entries:a,get size(){return i.size},at(d){return i.at(d)},append(d){p(()=>i.append(d))},appendMany(d){d.length!==0&&p(()=>i.appendMany(d))},clear(){p(()=>i.clear())},trimHead(d){p(()=>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 h=u.get(d);if(h!==void 0)return u.delete(d),u.set(d,h),h.node;g(u);let m=Y([a],([v])=>{let b=v;return d===0||b.length===0?[]:b.slice(Math.max(0,b.length-d))},{initial:i.tail(d),describeKind:"derived"}),y=Ft(m);return u.set(d,{node:m,dispose:y}),m},slice(d,h){if(!Number.isInteger(d)||d<0)throw new RangeError(`slice: start must be a non-negative integer (got ${d})`);if(h!==void 0&&(!Number.isInteger(h)||h<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${h})`);let m=f(d,h),y=l.get(m);if(y!==void 0)return l.delete(m),l.set(m,y),y.node;g(l);let v=Y([a],([_])=>{let O=_;return h===void 0?O.slice(d):O.slice(d,h)},{initial:i.slice(d,h),describeKind:"derived"}),b=Ft(v);return l.set(m,{node:v,dispose:b}),v},disposeTail(d){let h=u.get(d);return h===void 0?!1:(h.dispose(),u.delete(d),!0)},disposeSlice(d,h){let m=f(d,h),y=l.get(m);return y===void 0?!1:(y.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()}}}var G={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},En=Symbol.for("sizeof");function Vt(r){let e=new WeakSet,t=new WeakSet,n=[r],s=0;for(;n.length>0;){let o=n.pop();s+=Nn(o,e,t,n)}return s}function Nn(r,e,t,n){if(r==null)return 0;switch(typeof r){case"number":return G.number;case"boolean":return G.boolean;case"string":return G.string+r.length*2;case"bigint":return G.bigint+kn(r);case"symbol":return G.symbol;case"function":return e.has(r)?0:(e.add(r),G.function);case"undefined":return 0}let o=r;if(e.has(o))return 0;e.add(o);let i=o[En];if(typeof i=="function")try{let u=i.call(o);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(o instanceof Date)return G.date;if(o instanceof RegExp)return G.regexp+o.source.length*2;if(o instanceof Error){let u=o.message?o.message.length*2:0,l=o.stack?o.stack.length*2:0;return G.error+u+l}if(typeof URL<"u"&&o instanceof URL)return G.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return G.promise;if(o instanceof WeakMap)return G.weakmap;if(o instanceof WeakSet)return G.weakset;if(o instanceof Map){let u=G.map;for(let[l,f]of o)u+=G.mapEntry,n.push(l),n.push(f);return u}if(o instanceof Set){let u=G.set;for(let l of o)u+=G.setEntry,n.push(l);return u}if(Array.isArray(o)){let u=G.array+o.length*8;for(let l of o)n.push(l);return u}if(o instanceof ArrayBuffer)return t.has(o)?0:(t.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let u=o;return t.has(u.buffer)?48:(t.add(u.buffer),u.buffer.byteLength+48)}let a=G.object,c=Object.keys(o);for(let u of c){a+=G.string+u.length*2;try{n.push(o[u])}catch{}}return a}function kn(r){let e=r<0n?-r:r;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}function Ht(r,e,t,n={}){let s=e in r.nodes,o=t in r.nodes;if(!s)return je(e,t,"no-such-from");if(!o)return je(e,t,"no-such-to");let i=n.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(n.findCycle===!0){let u=Sn(r,e,n);if(u!=null)return u}let c=Be(e,r.nodes[e],0,n);return Ue(e,t,[c])}if(i===0)return je(e,t,"no-path");let a=jt(r,e,t,i);return a.found?Ue(e,t,Bt(r,a.pathOrder,n)):je(e,t,a.truncated?"max-depth-exceeded":"no-path")}function jt(r,e,t,n){let s=new Map,o=[{path:t,depth:0}],i=new Set([t]),a=0,c=!1;for(;a<o.length;){let f=o[a++];if(f.path===e)break;if(n!=null&&f.depth>=n){let h=r.nodes[f.path];h?.deps&&h.deps.length>0&&(c=!0);continue}let g=r.nodes[f.path];if(g==null)continue;let p=g.deps??[],d=new Map;for(let h=0;h<p.length;h++){let m=p[h];if(!m)continue;let y=d.get(m);y==null&&(y=[],d.set(m,y)),y.push(h)}for(let[h,m]of d)i.has(h)||(i.add(h),s.set(h,{from:f.path,depIndices:m}),o.push({path:h,depth:f.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:c};let u=[{path:e}],l=e;for(;l!==t;){let f=s.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 Sn(r,e,t){let n=r.nodes[e];if(n==null)return null;let s=n.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=Be(e,n,0,t);a.dep_index=o[0];let c=Be(e,n,1,t);return Ue(e,e,[a,c])}let i=null;for(let a=0;a<s.length;a++){let c=s[a];if(!c||c===e)continue;let u=jt(r,c,e,t.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:Ue(e,e,Bt(r,i.pathOrder,t))}function Bt(r,e,t){return e.map((n,s)=>{let o=r.nodes[n.path],i=Be(n.path,o,s,t);return n.depIndices!=null&&n.depIndices.length>0&&(i.dep_index=n.depIndices[0],n.depIndices.length>1&&(i.dep_indices=[...n.depIndices])),i})}function Be(r,e,t,n){let s={path:r,type:e.type,hop:t};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=n.annotations?.get(r)??e.annotation;o!=null&&(s.annotation=o);let i=n.lastMutations?.get(r)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function Ue(r,e,t){return Ut(r,e,!0,"ok",t)}function je(r,e,t){return Ut(r,e,!1,t,[])}function Ut(r,e,t,n,s){let o=Dn(r,e,t,n,s);return{from:r,to:e,found:t,reason:n,steps:s,text:o,toJSON(){return{from:r,to:e,found:t,reason:n,steps:s}}}}function Dn(r,e,t,n,s){if(!t)switch(n){case"no-such-from":return`explainPath: no node named "${r}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${r}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${r}" to "${e}"`}let o=[`Causal path: ${r} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let c=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(c),"value"in i&&o.push(` value: ${An(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;o.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return o.join(`
2
+ `)}function An(r){if(r===void 0)return"<sentinel>";if(r===null)return"null";if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean"||typeof r=="bigint")return String(r);try{let e=JSON.stringify(r);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(r)}}Me();Ee();rt();Ne();ue();ye();He();yt();Wt();var ke=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let t=(this.head+this._size)%this.capacity;this.buf[t]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let t=e<0?this._size+e:e;if(!(t<0||t>=this._size))return this.buf[(this.head+t)%this.capacity]}toArray(){let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this.buf[(this.head+t)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};dt();ye();function Kt(r,e){let t=e?.topN??10,n=r.describe({detail:"standard"}),s=[],o=r._collectObserveTargets;typeof o=="function"&&o.call(r,"",s);let i=new Map;for(let[g,p]of s)i.set(g,p);let a=[];for(let[g,p]of Object.entries(n.nodes)){let d=i.get(g),h=d instanceof M?d:null,m=h?Vt(h.cache):0,y=h?h._sinkCount:0,v=p.deps?.length??0,b=p.type==="effect"&&y===0,_=y===0?p.type==="effect"?"orphan-effect":p.type==="derived"?"idle-derived":p.type==="producer"?"idle-producer":null:null;a.push({path:g,type:p.type,status:p.status??"unknown",valueSizeBytes:m,subscriberCount:y,depCount:v,isOrphanEffect:b,orphanKind:_})}let c=a.reduce((g,p)=>g+p.valueSizeBytes,0),u=(g,p)=>[...a].sort(p??((d,h)=>h[g]-d[g])).slice(0,t),l=a.filter(g=>g.orphanKind!=null),f=a.filter(g=>g.isOrphanEffect);return{nodeCount:a.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:a,totalValueSizeBytes:c,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:l,orphanEffects:f}}var C="::",J="__meta__",de=1;function qt(r,e){let t=Math.max(16,r.size*4),n=0;for(;r.size>0;){if(n++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${r.size} disposer(s) discarded`),r.clear();return}let s=r.values().next();if(s.done)return;let o=s.value;r.delete(o);try{o()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Rn(r){let e=[];for(let t of Object.keys(r).sort()){let n=r[t].v;n!=null&&e.push(`${t} ${n.id} ${n.version}`)}return e.join(`
3
+ `)}function Yt(r){if(r.version!==de)throw new Error(`unsupported snapshot version ${String(r.version)} (expected ${de})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in r))throw new Error(`snapshot missing required key "${e}"`);if(typeof r.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof r.nodes!="object"||r.nodes===null||Array.isArray(r.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(r.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(r.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Cn(r,e){let t=new WeakMap,n=(s,o)=>{if(Object.is(s,o))return!0;if(s==null||o==null||typeof s!="object"||typeof o!="object")return!1;let i=t.get(s);if(i==null&&(i=new WeakSet,t.set(s,i)),i.has(o))return!0;i.add(o);let a=s.constructor,c=o.constructor;if(a!==c)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let g=o;if(s.length!==g.length)return!1;for(let p=0;p<s.length;p++)if(!n(s[p],g[p]))return!1;return!0}if(s instanceof Map){let g=o;if(s.size!==g.size)return!1;for(let[p,d]of s)if(!g.has(p)||!n(d,g.get(p)))return!1;return!0}if(s instanceof Set){let g=o;if(s.size!==g.size)return!1;for(let p of s){let d=!1;for(let h of g)if(n(p,h)){d=!0;break}if(!d)return!1}return!0}if(ArrayBuffer.isView(s)){let g=s,p=o;if(g.length!==p.length)return!1;for(let d=0;d<g.length;d++)if(g[d]!==p[d])return!1;return!0}let u=Object.keys(s),l=Object.keys(o);if(u.length!==l.length)return!1;let f=new Set(l);for(let g of u)if(!f.has(g)||!n(s[g],o[g]))return!1;return!0};return n(r,e)}function _t(r){if(r===null||typeof r!="object")return r;if(Array.isArray(r))return r.map(_t);let e=r,t=Object.keys(e).sort(),n={};for(let s of t)n[s]=_t(e[s]);return n}function Mn(r){return r.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Gn(r){return r.replaceAll("\\","\\\\").replaceAll('"','\\"')}function $n(r){return r==="TD"?"down":r==="BT"?"up":r==="RL"?"left":"right"}function Xt(r){let e=new Set,t=[];function n(s,o){let i=`${s}\0${o}`;e.has(i)||(e.add(i),t.push([s,o]))}for(let[s,o]of Object.entries(r.nodes)){let i=o.deps;if(i)for(let a of i)n(a,s)}for(let s of r.edges)n(s.from,s.to);return t}function Zt(r){if(r===void 0)return"LR";if(r==="TD"||r==="LR"||r==="BT"||r==="RL")return r;throw new Error(`invalid diagram direction ${String(r)}; expected one of: TD, LR, BT, RL`)}function Pn(r,e){let t=e.includeEdges??!0,n=e.includeSubgraphs??!0,{expand:s,...o}=r,i={...o,edges:t?r.edges:[],subgraphs:n?r.subgraphs:[]},a=JSON.stringify(_t(i),null,e.indent??2);return e.logger?.(a),a}function In(r,e){let t=e.includeEdges??!0,n=e.includeSubgraphs??!0,s=[];s.push(`Graph ${r.name}`),s.push("Nodes:");for(let i of Object.keys(r.nodes).sort()){let a=r.nodes[i];s.push(`- ${i} (${a.type}/${a.status}): ${qe(a.value)}`)}if(t){s.push("Edges:");for(let i of r.edges)s.push(`- ${i.from} -> ${i.to}`)}if(n){s.push("Subgraphs:");for(let i of r.subgraphs)s.push(`- ${i}`)}let o=s.join(`
4
+ `);return e.logger?.(o),o}function Qt(r,e){let t=Zt(e.direction),n=Object.keys(r.nodes).sort(),s=new Map;for(let i=0;i<n.length;i+=1)s.set(n[i],`n${i}`);let o=[`flowchart ${t}`];for(let i of n){let a=s.get(i);o.push(` ${a}["${Mn(i)}"]`)}for(let[i,a]of Xt(r)){let c=s.get(i),u=s.get(a);!c||!u||o.push(` ${c} --> ${u}`)}return o.join(`
5
+ `)}function Ln(r,e){let t=Qt(r,e);return en(t)}function en(r,e){let t=e?.theme??"default",n=e?.autoSync??!0,o=JSON.stringify({code:r,mermaid:{theme:t},autoSync:n}),i=new TextEncoder().encode(o),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function Fn(r,e){let t=Zt(e.direction),n=Object.keys(r.nodes).sort(),s=new Map;for(let i=0;i<n.length;i+=1)s.set(n[i],`n${i}`);let o=[`direction: ${$n(t)}`];for(let i of n){let a=s.get(i);o.push(`${a}: "${Gn(i)}"`)}for(let[i,a]of Xt(r)){let c=s.get(i),u=s.get(a);!c||!u||o.push(`${c} -> ${u}`)}return o.join(`
6
+ `)}function zn(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ke(r){let e="^";for(let t=0;t<r.length;t+=1){let n=r[t];if(n==="*"){e+=".*";continue}if(n==="?"){e+=".";continue}if(n==="["){let s=r.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let o=r.slice(t+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,t=s;continue}e+=zn(n)}return e+="$",new RegExp(e)}var Vn={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"},Hn={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function qe(r){if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean"||r==null)return String(r);try{return JSON.stringify(r)}catch{return"[unserializable]"}}function jn(r){return r==="none"?Hn:r==="ansi"||r==null?Vn:{data:r.data??"",dirty:r.dirty??"",resolved:r.resolved??"",invalidate:r.invalidate??"",pause:r.pause??"",resume:r.resume??"",complete:r.complete??"",error:r.error??"",teardown:r.teardown??"",derived:r.derived??"",path:r.path??"",reset:r.reset??""}}function Jt(r){if(r==null)return{};let e=r.detail;return e==="full"?{...r,structured:r.structured??!0,timeline:r.timeline??!0,causal:r.causal??!0,derived:r.derived??!0}:e==="minimal"?{...r,structured:r.structured??!0}:r.format==="stage-log"?{...r,structured:r.structured??!0,timeline:r.timeline??!0}:r}function Bn(r,e,t){for(let n=0;n<r.length;n++){let s=r.charCodeAt(n);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${r}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function vt(r,e,t){if(r==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(r.includes(C))throw new Error(`Graph "${e}": ${t} "${r}" must not contain '${C}' (path separator)`);if(r===J)throw new Error(`Graph "${e}": ${t} name "${J}" is reserved for meta companion paths`);Bn(r,e,t)}function Un(r,e){if(r==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=r.split(C);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function Wn(r,e){let t=!1;for(let s of r)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?r.filter(s=>e.isMetaPassthrough(s[0])):r}function tn(r){for(let e of r._mounts.values())tn(e);for(let e of r._nodes.values())try{e.down([[F]],{internal:!0})}catch{}}var ne=class r{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_topology;_topologyEmitters=new Set;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(C))throw new Error(`Graph name must not contain '${C}' (got "${e}")`);if(e===J)throw new Error(`Graph name "${J}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??me,this._traceRing=new ke(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning)}ancestors(e=!0){let t=[],n=e?this:this._parent;for(;n!=null;)t.push(n),n=n._parent;return t}get topology(){return this._topology==null&&(this._topology=mt(e=>{let t=n=>{e.emit(n)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}add(e,t){let n=e.name,s=t?.name??n;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,i=t?.annotation;if(vt(o,this.name,"add"),this._mounts.has(o))throw new Error(`Graph "${this.name}": name "${o}" is already a mount point`);if(this._nodes.has(o))throw new Error(`Graph "${this.name}": node "${o}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(o,e),this._nodeToName.set(e,o),this._emitTopology({kind:"added",name:o,nodeKind:"node"}),i!=null&&(this._annotations.set(o,i),this.config.inspectorEnabled&&this._traceRing.push({path:o,annotation:i,timestamp_ns:he()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof M&&t._applyVersioning(e)}remove(e){vt(e,this.name,"remove");let t=this._mounts.get(e);if(t){let o={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,c]of i)a.includes(`${C}${J}${C}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...t._collectSubgraphs(`${e}${C}`)),this._mounts.delete(e),t._parent=void 0,tn(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:o}),o}let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(n),n.down([[F]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let t=typeof e=="function"?e:(()=>{let o=Ke(e);return i=>o.test(i)})(),n={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>t(o));for(let o of s){let i=this.remove(o);n.nodes.push(...i.nodes),n.mounts.push(...i.mounts)}return n.nodes.sort(),n.mounts.sort(),n}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,n=0;return{[Symbol.iterator](){return this},next(){if(n>=e.length)return{value:void 0,done:!0};let s=e[n++];return{value:[s,t.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(C))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,n){let s=n?.internal===!0;this.node(e).down([[I,t]],{actor:n?.actor,internal:s,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);ie(()=>{for(let[s,o]of n)this.set(s,o,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[K]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let s=n?.internal===!0;this.node(e).down([[$,t]],{actor:n?.actor,internal:s,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[V]],{actor:t?.actor,internal:n,delivery:"write"})}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[c,u]of this._nodes)n.set(u,c);let a=[];for(let[c,u]of this._nodes)if(u instanceof M)for(let l of u._deps){let f=n.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 s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,c]of s)o.set(c,a);let i=[];for(let[a,c]of s)if(c instanceof M)for(let u of c._deps){let l=o.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,t){if(vt(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(t===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(t._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${t._parent.name}"`);for(let n=this;n!=null;n=n._parent)if(n===t)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,t),t._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),t}resolve(e){let t=Un(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let n=t[0],s=t.slice(1);if(s.length===0){let a=this._nodes.get(n);if(a)return a;throw this._mounts.has(n)?new Error(`Graph "${this.name}": path ends at subgraph "${n}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${n}"`)}let o=this._nodes.get(n);if(o&&s.length>0&&s[0]===J)return this._resolveMetaChainFromNode(o,s,t.join(C));let i=this._mounts.get(n);if(!i)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${s.join(C)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(s.join(C))}_resolveMetaChainFromNode(e,t,n){let s=e,o=0,i=[...t];for(;o<i.length;){if(i[o]!==J)throw new Error(`Graph "${this.name}": expected ${J} segment in meta path "${n}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${J} in "${n}"`);let a=i[o+1],c=s.meta[a];if(!c)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${n}"`);s=c,o+=2}return s}signal(e,t){if(t?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let n=[];if(this._signalDeliver(e,t??{},new Set,n),n.length>0)throw n[0]}_signalDeliver(e,t,n,s){for(let c of this._mounts.values())c._signalDeliver(e,t,n,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=Wn(e,this.config);for(let c of[...this._nodes.keys()].sort()){let u=this._nodes.get(c);if(!n.has(u)){n.add(u);try{u.down(e,i)}catch(l){if(l instanceof q)throw l;s.push(l)}a.length!==0&&this._signalMetaSubtree(u,a,n,i,s)}}}_signalMetaSubtree(e,t,n,s,o){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!n.has(a)){n.add(a);try{a.down(t,s)}catch(c){if(c instanceof q)throw c;o.push(c)}this._signalMetaSubtree(a,t,n,s,o)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let t=e?.actor,n=e?.filter,s=Ve(e?.detail,e?.fields),o=e?.format==="spec",i=o?Ve("minimal"):s,a=[];this._collectObserveTargets("",a);let c=new Map;for(let[w,T]of a)c.set(T,w);let u=[];{let w=a.map(([,S])=>S),T=new Set(c.values()),E=0;for(;w.length>0;){let S=w.shift();if(S instanceof M)for(let P of S._deps){let N=P.node;if(c.has(N))continue;let D=N.name??"",k=D;if(!k||T.has(k))if(D){let L=2;for(;T.has(`${D}#${L}`);)L++;k=`${D}#${L}`}else for(k=`__internal__/${E++}`;T.has(k);)k=`__internal__/${E++}`;c.set(N,k),T.add(k),u.push([k,N]),w.push(N)}}}let l=[...a,...u],f={};for(let[w,T]of l){if(t!=null&&!T.allowsObserve(t))continue;let E=gt(T,i),S=T instanceof M?T._deps.map(k=>c.get(k.node)??k.node.name??""):[],{name:P,...N}=E,D={...N,deps:S};if(!o){let k=this._annotations.get(w);k!=null&&(D.annotation=k)}if(n!=null)if(typeof n=="function"){let k=n;if(!(k.length>=2?k(w,D):k(D)))continue}else{let k=!0;for(let[L,Z]of Object.entries(n)){let re=L==="deps_includes"?"depsIncludes":L==="meta_has"?"metaHas":L;if(re==="depsIncludes"){if(!D.deps.includes(String(Z))){k=!1;break}continue}if(re==="metaHas"){if(!Object.hasOwn(D.meta??{},String(Z))){k=!1;break}continue}if(D[re]!==Z){k=!1;break}}if(!k)continue}f[w]=D}let g=new Set(Object.keys(f)),p=[];for(let[w,T]of l)if(T instanceof M)for(let E of T._deps){let S=c.get(E.node);S!=null&&p.push([S,w])}p.sort((w,T)=>w[0]<T[0]?-1:w[0]>T[0]?1:w[1]<T[1]?-1:w[1]>T[1]?1:0);let d=p.map(([w,T])=>({from:w,to:T}));(t!=null||n!=null)&&(d=d.filter(w=>g.has(w.from)&&g.has(w.to)));let h=this._collectSubgraphs(""),m=t!=null||n!=null?h.filter(w=>{let T=`${w}${C}`;return[...g].some(E=>E===w||E.startsWith(T))}):h,y=this,v=e,b={name:this.name,nodes:f,edges:d,subgraphs:m,expand(w){let T={...v,format:void 0};return Array.isArray(w)?(T.fields=w,T.detail=void 0):(T.detail=w,T.fields=void 0),y.describe(T)}},_=e??{},O=_.format;return O==="json"?Pn(b,_):O==="pretty"?In(b,_):O==="mermaid"?Qt(b,_):O==="mermaid-url"?Ln(b,_):O==="d2"?Fn(b,_):b}_collectSubgraphs(e){let t=[];for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${n}`;t.push(s),t.push(...this._mounts.get(n)._collectSubgraphs(`${s}${C}`))}return t}resourceProfile(e){return Kt(this,e)}reachable(e,t,n={}){return n.withDetail===!0?wt(this.describe(),e,t,{...n,withDetail:!0}):wt(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(e,t,n)}_explainStatic(e,t,n){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,c]of Object.entries(s.nodes))c.lastMutation!=null&&i.set(a,c.lastMutation);return Ht(s,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",s=0,o=Q(s,{name:`${n}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=()=>{a||c||(a=!0,Oe(()=>{a=!1,!c&&(s+=1,o.emit(s))}))},l=i.onEvent(m=>{let y=m.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||u()}),f=[],g=new WeakSet,p=m=>{if(g.has(m)||c)return;g.add(m);let y=m.topology.subscribe(v=>{for(let b of v){if(b[0]!==I)continue;let _=b[1];if(u(),_.kind==="added"&&_.nodeKind==="mount"){let O=m._mounts.get(_.name);O!=null&&p(O)}}});f.push(y);for(let v of m._mounts.keys()){let b=m._mounts.get(v);b!=null&&p(b)}};p(this);let d;try{d=Y([o],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,y)=>m===y})}catch(m){l();for(let y of f)y();throw i.dispose(),m}let h=ee(d);return{node:d,dispose(){c=!0,l();for(let m of f)m();f.length=0,i.dispose(),h()}}}_explainReactive(e,t,n){let s=0,o=Q(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=i.onEvent(p=>{let d=p.type;d!=="data"&&d!=="error"&&d!=="complete"&&d!=="teardown"||a||c||(a=!0,Oe(()=>{a=!1,!c&&(s+=1,o.emit(s))}))}),l={...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{}},f;try{f=Y([o],()=>this._explainStatic(e,t,l),{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:t},equals:(p,d)=>p.found===d.found&&p.reason===d.reason&&p.steps.length===d.steps.length&&Kn(p.steps,d.steps)})}catch(p){throw u(),i.dispose(),p}let g=ee(f);return{node:f,dispose(){c=!0,u(),i.dispose(),g()}}}_pathsMatching(e){let t=Ke(e),n=[];return this._collectObserveTargets("",n),n.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${C}${n}`;this._mounts.get(n)._collectObserveTargets(s,t)}for(let n of[...this._nodes.keys()].sort()){let s=this._nodes.get(n),o=e===""?n:`${e}${C}${n}`;t.push([o,s]),this._appendMetaObserveTargets(o,s,t)}}_appendMetaObserveTargets(e,t,n){for(let s of Object.keys(t.meta).sort()){let o=t.meta[s],i=`${e}${C}${J}${C}${s}`;n.push([i,o]),this._appendMetaObserveTargets(i,o,n)}}observe(e,t){let n=typeof e=="string",o=Jt(n?t:e),i=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,a=o.actor;if(n){let l=e,f=this.resolve(l);if(a!=null&&!f.allowsObserve(a))throw new q({actor:a,action:"observe",nodeName:l});return i?this._buildStructuredObserver([[l,f]],o,"one"):{subscribe(g){return f.subscribe(g)},up(g){try{f.up?.(g)}catch(p){if(p instanceof q)return;throw p}}}}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,o,"all"):{subscribe:l=>{let f=u.map(([g,p])=>p.subscribe(d=>{l(g,d)}));return()=>{for(let g of f)g()}},up:(l,f)=>{try{this.resolve(l).up?.(f)}catch(g){if(g instanceof q)return;throw g}}}}_buildStructuredObserver(e,t,n){let s=n==="one"?e[0]?.[0]:void 0,o=i=>{if(n==="one"&&s!=null){let l=this.resolve(s);return this._buildStructuredObserver([[s,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,t,o)}_createObserveResult(e,t,n){let s=t.timeline===!0,o=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",c=this.config.inspectorEnabled,u=(o||i)&&c,l=t.maxEvents,f=l!=null&&l>0?new ke(l):null,g=[],p=new Set,d={},h=new Set,m=0,y=0,v=0,b=0,_=0,O=0,w=!1,T=!1,E=0,S=new Map,P=new Map,N=new Map,D=x=>{f?f.push(x):g.push(x);for(let R of p)R(x)},k=()=>s?{timestamp_ns:he(),in_batch:Te(),batch_id:E}:{},L=(x,R)=>{if(!(!u||!(x instanceof M)))return x._setInspectorHook(B=>{if(B.kind==="dep_message")S.set(x,B.depIndex);else if(B.kind==="run"){let ve=B.batchData.map((A,z)=>A!=null&&A.length>0?A.at(-1):B.prevData[z]);P.set(x,ve);let U=B.batchData.map(A=>A!=null?[...A]:void 0);N.set(x,U),i&&D({type:"derived",path:R,dep_values:ve,dep_batches:U,...k()})}})},Z=x=>{let R=S.get(x),B=P.get(x);if(!o||B==null)return{};let U=(R!=null&&R>=0&&x instanceof M?x._deps[R]:void 0)?.node,A=U?.v,z=N.get(x);return{trigger_dep_index:R,trigger_dep_name:U?.name,...A!=null?{trigger_version:{id:A.id,version:A.version}}:{},dep_values:[...B],...z!=null?{dep_batches:z}:{}}},re=[],Ae=[];for(let[x,R]of e){let B=L(R,x);B&&re.push(B),Ae.push(R.subscribe(ve=>{E++;for(let U of ve){let A=U[0],z=k();if(A===I){d[x]=U[1];let tt=R instanceof M?R.lastMutation?.actor??le:le;D({type:"data",path:x,data:U[1],actor:tt,...z,...Z(R)})}else if(a)A===H?m++:A===j?y++:A===K?v++:A===X?b++:A===te?_++:A===F?O++:A===V&&!h.has(x)?w=!0:A===$&&(T=!0,h.add(x));else if(A===H)m++,D({type:"dirty",path:x,...z});else if(A===j)y++,D({type:"resolved",path:x,...z,...Z(R)});else if(A===K)v++,D({type:"invalidate",path:x,...z});else if(A===X)b++,D({type:"pause",path:x,lockId:U[1],...z});else if(A===te)_++,D({type:"resume",path:x,lockId:U[1],...z});else if(A===V)h.has(x)||(w=!0),D({type:"complete",path:x,...z});else if(A===$){T=!0,h.add(x);let tt=R instanceof M?R.lastMutation?.actor??le:le;D({type:"error",path:x,data:U[1],actor:tt,...z})}else A===F&&(O++,D({type:"teardown",path:x,...z}))}}))}let Ze=!1,Qe=()=>{if(!Ze){Ze=!0;for(let x of Ae)x();for(let x of re)x();for(let x of Re)x({value:void 0,done:!0});Re.length=0}},et=[],Re=[];p.add(x=>{let R=Re.shift();R?R({value:x,done:!1}):et.push(x)});let Tt={get values(){return d},get dirtyCount(){return m},get resolvedCount(){return y},get invalidateCount(){return v},get pauseCount(){return b},get resumeCount(){return _},get teardownCount(){return O},get events(){return f?f.toArray():[...g]},get anyCompletedCleanly(){return w},get anyErrored(){return T},get completedWithoutErrors(){return w&&!T},onEvent(x){return p.add(x),()=>p.delete(x)},dispose:Qe,expand(x){Qe();let R={...t};return typeof x=="string"?R.detail=x:Object.assign(R,x),n(Jt(R))},[Symbol.asyncIterator](){return{next(){return et.length>0?Promise.resolve({value:et.shift(),done:!1}):Ze?Promise.resolve({value:void 0,done:!0}):new Promise(x=>Re.push(x))},return(){return Qe(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Tt,t),Tt}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let s=t.logger??(d=>console.log(d)),o=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=o==null&&i==null?()=>!0:d=>(o==null||o.has(d))&&(i==null||!i.has(d)),c=jn(t.theme),u=n==="stage-log"?he():0,l=d=>d==null?"":t.stageLabels?.[d]??d,f=(d,h)=>d.length>h?`${d.slice(0,h-1)}\u2026`:d,g=d=>d.type==="data"||d.type==="error"?f(qe(d.data),120):"",p=d=>{if(n==="stage-log"){let T=(he()-u)/1e9,E=l(d.path).padEnd(9);if(d.type==="data"){let S=g(d);return`[${T.toFixed(3)}s] ${E} \u2190${S?` ${S}`:""}`}if(d.type==="error"){let S=g(d);return`[${T.toFixed(3)}s] ${E} \u2717${S?` ${S}`:""}`}return d.type==="complete"?`[${T.toFixed(3)}s] ${E} \u25A0 complete`:`[${T.toFixed(3)}s] ${E} ${d.type}`}if(n==="json")try{return JSON.stringify(d)}catch{return JSON.stringify({type:d.type,path:d.path,data:"[unserializable]"})}let h=c[d.type]??"",m=d.path?`${c.path}${d.path}${c.reset} `:"",y=d.type==="data"||d.type==="error",v=d.type==="pause"||d.type==="resume",b=y?` ${qe(d.data)}`:v?` ${qe(d.lockId)}`:"",_=d.type==="data"||d.type==="resolved"||d.type==="derived"?d:void 0,O=_?.trigger_dep_name!=null?` <- ${_.trigger_dep_name}`:_?.trigger_dep_index!=null?` <- #${_.trigger_dep_index}`:"",w=d.in_batch?" [batch]":"";return`${m}${h}${d.type.toUpperCase()}${c.reset}${b}${O}${w}`};e.onEvent(d=>{a(d.type)&&s(p(d),d)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){qt(this._disposers,this.name),this.signal([[F]],{internal:!0}),qt(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}snapshot(e){let{expand:t,...n}=this.describe({detail:"full"}),s={};for(let a of Object.keys(n.nodes).sort()){let{lastMutation:c,guard:u,...l}=n.nodes[a];s[a]=l}let o=[...n.subgraphs].sort(),i={...n,version:1,nodes:s,subgraphs:o};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return At(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??me,{codec:s,codecVersion:o,payload:i}=Rt(e,n);return s.decode(i,o)}restore(e,t){if(Yt(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let n=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(o=>Ke(o)),s=t?.includeProducers===!0;for(let o of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(a=>a.test(o)))continue;let i=e.nodes[o];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let c=this.tryResolve(o)?.v;if(c!=null&&c.id===i.v.id&&c.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){t?.onError?.(o,a)}}}}}static fromSnapshot(e,t){Yt(e);let n=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,o=new r(e.name);if(n)return n(o),o.restore(e),o;for(let p of[...e.subgraphs].sort((d,h)=>{let m=d.split(C).length,y=h.split(C).length;return m!==y?m-y:d<h?-1:d>h?1:0})){let d=p.split(C),h=o;for(let m of d)h._mounts.has(m)||h.mount(m,new r(m)),h=h._mounts.get(m)}let i=s?Object.entries(s).map(([p,d])=>({re:Ke(p),factory:d})):[],a=p=>{for(let d of i)if(d.re.test(p))return d.factory},c=p=>{let d=p.split(C),h=d.pop();if(h==null||h.length===0)throw new Error(`invalid snapshot path "${p}"`);let m=o;for(let y of d){let v=m._mounts.get(y);if(!v)throw new Error(`unknown mount "${y}" in path "${p}"`);m=v}return[m,h]},u=Object.entries(e.nodes).filter(([p])=>!p.includes(`${C}${J}${C}`)).sort((p,d)=>p[0]<d[0]?-1:p[0]>d[0]?1:0),l=new Map(u),f=new Map,g=!0;for(;l.size>0&&g;){g=!1;for(let[p,d]of[...l.entries()]){let h=d?.deps??[];if(!h.every(O=>f.has(O)))continue;let[m,y]=c(p),v={...d?.meta??{}},b=a(p),_;if(d?.type==="state")_=Q(d.value,{meta:v});else{if(b==null)continue;_=b(y,{path:p,type:d.type,value:d.value,meta:v,deps:h,resolvedDeps:h.map(O=>f.get(O))})}m.add(_,{name:y}),f.set(p,_),l.delete(p),g=!0}}if(l.size>0){let p=[...l.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${p}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachStorage(e,t={}){let n=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}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let s=(u,l)=>{if(u.disposed)return;let f=Rn(l.nodes);if(u.lastSnapshot!=null&&f!==""&&f===u.lastFingerprint)return;let g=u.seq+1,p=Ge(),m=u.lastSnapshot==null||g%u.compactEvery===0?{mode:"full",snapshot:l,seq:g,timestamp_ns:p,format_version:de}:{mode:"diff",diff:nn(u.lastSnapshot,l),seq:g,timestamp_ns:p,format_version:de};if(u.tier.filter&&!u.tier.filter(this.name,m))return;let y;try{y=u.tier.save(this.name,m)}catch(v){t.onError?.(v,u.tier);return}if(y&&typeof y.then=="function"){let _=(u.savePending??Promise.resolve()).then(()=>y,()=>y).then(()=>{u.disposed||(u.seq=g,u.lastSnapshot=l,u.lastFingerprint=f)},O=>{t.onError?.(O,u.tier)});u.savePending=_.finally(()=>{u.savePending===_&&(u.savePending=void 0)})}else u.seq=g,u.lastSnapshot=l,u.lastFingerprint=f},o=(u,l)=>{try{s(u,l)}catch(f){t.onError?.(f,u.tier)}},i=(u,l)=>{if(!l.some(d=>{let h=this.config.messageTier(d[0]);return h>=3&&h<5}))return;if(t.filter){let d=this.tryResolve(u);if(d==null)return;let h=gt(d,Ve("standard"));if(!t.filter(u,h))return}let g,p=()=>(g==null&&(g=this.snapshot()),g);for(let d of n)d.disposed||(d.debounceMs===0?o(d,p()):(d.timer==null&&(d.timer=new We),d.timer.start(d.debounceMs,()=>{d.disposed||o(d,this.snapshot())})))},a;if(t.paths!=null){let l=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(f=>{let g=this.tryResolve(f);return g==null?()=>{}:g.subscribe(p=>i(f,p))});a=()=>{for(let f of l)f()}}else a=this.observe().subscribe((u,l)=>i(u,l));let c=()=>{a();for(let u of n)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(c)};return this._storageDisposers.add(c),{dispose:c}}async _cascadeRestore(e,t){for(let n of e){let s;try{s=await n.load(this.name)}catch(i){t?.(i,n);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===de&&o.nodes!=null)return this.restore(o),!0}catch(i){t?.(i,n)}}return!1}static async fromStorage(e,t,n){for(let s of t){let o;try{o=await s.load(e)}catch(c){n?.onError?.(c,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===de&&i.nodes!=null?i:void 0;if(a!=null)try{return r.fromSnapshot(a,n)}catch(c){n?.onError?.(c,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,n){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:he(),...n?.actor!=null?{actor:n.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(s=>!e(s)),n=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return n}static diff(e,t){let n=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),o=[...s].filter(v=>!n.has(v)).sort(),i=[...n].filter(v=>!s.has(v)).sort(),a=[],c=[];for(let v of n){if(!s.has(v))continue;let b=e.nodes[v],_=t.nodes[v],O=b.v,w=_.v;O!=null&&w!=null&&O.id===w.id&&O.version!==w.version&&c.push({path:v,id:O.id,from:O.version,to:w.version});let T=O!=null&&w!=null&&O.id===w.id&&O.version===w.version;for(let E of["type","status","sentinel"]){let S=b[E],P=_[E];S!==P&&a.push({path:v,field:E,from:S,to:P})}if(!T)for(let E of["value","meta"]){let S=b[E],P=_[E];Cn(S,P)||a.push({path:v,field:E,from:S,to:P})}}let u=v=>`${v.from} ${v.to}`,l=new Set(e.edges.map(u)),f=new Set(t.edges.map(u)),g=t.edges.filter(v=>!l.has(u(v))),p=e.edges.filter(v=>!f.has(u(v))),d=new Set(e.subgraphs),h=new Set(t.subgraphs),m=[...h].filter(v=>!d.has(v)).sort(),y=[...d].filter(v=>!h.has(v)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:c,edgesAdded:g,edgesRemoved:p,subgraphsAdded:m,subgraphsRemoved:y}}};function nn(r,e){let t=ne.diff(r,e),n={};for(let s of t.nodesAdded){let o=e.nodes[s];o!=null&&(n[s]=o)}return{...t,nodesAddedFull:n}}function wt(r,e,t,n={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return n.withDetail?s:[];if(!n.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=n.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return n.withDetail?s:[];let i=new Map,a=new Map,c=new Map,u=new Map,l=new Set;for(let[b,_]of Object.entries(r.nodes)){if(!b)continue;l.add(b);let O=_.deps??[];i.set(b,O);for(let w of O)w&&(l.add(w),a.has(w)||a.set(w,new Set),a.get(w).add(b))}for(let b of r.edges){if(b==null||typeof b!="object")continue;let _=typeof b.from=="string"?b.from:"",O=typeof b.to=="string"?b.to:"";!_||!O||(l.add(_),l.add(O),u.has(_)||u.set(_,new Set),u.get(_).add(O),c.has(O)||c.set(O,new Set),c.get(O).add(_))}if(!l.has(e))return n.withDetail?s:[];let f=n.both===!0,g=b=>{if(f){let T=i.get(b)??[],E=c.get(b),S=a.get(b),P=u.get(b),N=[...T];return E&&N.push(...E),S&&N.push(...S),P&&N.push(...P),N}if(t==="upstream"){let T=i.get(b)??[],E=c.get(b);return E?[...T,...E]:T}let _=a.get(b),O=u.get(b),w=_?[..._]:[];return O&&w.push(...O),w},p=new Set([e]),d=new Map,h=[{path:e,depth:0}],m=0,y=!1;for(;m<h.length;){let b=h[m++];if(o!=null&&b.depth>=o){g(b.path).length>0&&(y=!0);continue}for(let _ of g(b.path))!_||p.has(_)||(p.add(_),d.set(_,b.depth+1),h.push({path:_,depth:b.depth+1}))}let v=[...d.keys()].sort((b,_)=>b<_?-1:b>_?1:0);return n.withDetail?{paths:v,depths:d,truncated:y}:v}function Kn(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++){let n=r[t],s=e[t];if(n.path!==s.path||n.type!==s.type||n.status!==s.status||n.hop!==s.hop||n.dep_index!==s.dep_index||n.annotation!==s.annotation||n.value!==s.value||n.lastMutation!==s.lastMutation)return!1;let o=n.v,i=s.v;if(o!==i&&(o==null||i==null||o.id!==i.id||o.version!==i.version))return!1}return!0}yt();function rn(r,e,t){return{[r]:!0,[`${r}_type`]:e,...t??{}}}var qn=2147483647;function Ye(r,e){if(!Number.isFinite(r)||!Number.isInteger(r)||r<0)throw new Error(`${e} must be a non-negative integer`);return r}function ce(r,e){return rn("messaging",r,e)}var Se=class extends ne{_log;events;latest;hasLatest;constructor(e,t={}){super(e,t.graph),this._log=zt([],{name:"events",maxSize:t.retainedLimit}),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=Y([this.events],([n])=>{let s=n;return s.length===0?null:s[s.length-1]},{name:"latest",describeKind:"derived",meta:ce("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(ee(this.latest)),this.hasLatest=Y([this.events],([n])=>n.length>0,{name:"hasLatest",describeKind:"derived",meta:ce("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(ee(this.hasLatest)),this.addDisposer(()=>{this.events.down([[V]])}),this.addDisposer(()=>this._log.disposeAllViews())}publish(e){this._log.append(e)}retained(){return this.events.cache}},De=class extends ne{source;cursor;available;topic;constructor(e,t,n={}){super(e,n.graph);let s=Ye(n.cursor??0,"subscription cursor");this.topic=t;let o=t.events;this.source=Y([o],([i])=>i,{name:"source",describeKind:"derived",meta:ce("subscription_source"),initial:o.cache}),this.add(this.source,{name:"source"}),this.cursor=Q(s,{name:"cursor",describeKind:"state",meta:ce("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=Y([this.source,this.cursor],([i,a])=>{let c=i,u=Math.max(0,Math.trunc(a??0));return c.slice(u)},{name:"available",describeKind:"derived",meta:ce("subscription_available"),initial:[]}),this.add(this.available,{name:"available"}),this.addDisposer(ee(this.source)),this.addDisposer(ee(this.available))}ack(e){let t=this.available.cache,n=e===void 0?t.length:Ye(e,"subscription ack count"),s=Math.min(n,t.length);if(s<=0)return this.cursor.cache;let o=this.cursor.cache+s;return this.cursor.emit(o),o}pull(e,t={}){let n=this.available.cache,s=e===void 0?n.length:Ye(e,"subscription pull limit"),o=n.slice(0,s);return t.ack&&o.length>0&&this.ack(o.length),o}},Je=class extends ne{_sourceSub;_target;bridgedCount;constructor(e,t,n,s={}){super(e,s.graph),this._sourceSub=sn(`${e}-subscription`,t,{cursor:s.cursor}),this._target=n,this.mount("subscription",this._sourceSub),this.bridgedCount=Q(0,{name:"bridgedCount",describeKind:"state",meta:ce("topic_bridge_count")}),this.add(this.bridgedCount,{name:"bridgedCount"});let o=Math.max(1,Ye(s.maxPerPump??qn,"topic bridge maxPerPump")),i=s.map??(c=>c),a=be([this._sourceSub.available],()=>{let c=this._sourceSub.pull(o,{ack:!0});if(c.length===0)return;let u=0;for(let l of c){let f=i(l);f!==void 0&&(this._target.publish(f),u+=1)}if(u>0){let l=this.bridgedCount.cache;this.bridgedCount.emit(l+u)}},{name:"pump",describeKind:"effect",meta:ce("topic_bridge_pump")});this.add(a,{name:"pump"}),this.addDisposer(ee(a))}},Xe=class extends ne{_topics=new Map;_version=0;_defaultTopicOptions;constructor(e,t={}){super(e,t.graph),this._defaultTopicOptions={...t.defaultTopicOptions??{}}}get version(){return this._version}get size(){return this._topics.size}has(e){return this._topics.has(e)}topicNames(){return this._topics.keys()}topic(e,t){let n=this._topics.get(e);if(n===void 0){let s={...this._defaultTopicOptions,...t??{}};n=new Se(e,s),this._topics.set(e,n),this.mount(e,n),this._version+=1}return n}publish(e,t){this.topic(e).publish(t)}publishMany(e){ie(()=>{for(let[t,n]of e)this.topic(t).publish(n)})}subscribe(e,t,n){let s=this.topic(t);return new De(e,s,n)}removeTopic(e){if(!this._topics.has(e))return!1;try{this.remove(e)}finally{this._topics.delete(e),this._version+=1}return!0}};function Yn(r,e){return new Se(r,e)}function Jn(r,e){return new Xe(r,e)}function sn(r,e,t){return new De(r,e,t)}function Xn(r,e,t,n){return new Je(r,e,t,n)}0&&(module.exports={MessagingHubGraph,SubscriptionGraph,TopicBridgeGraph,TopicGraph,messagingHub,subscription,topic,topicBridge});
@@ -0,0 +1,5 @@
1
+ import '../../node-Cc1TniY8.cjs';
2
+ import '../../graph-D48Qw9Cg.cjs';
3
+ export { M as MessagingHubGraph, a as MessagingHubOptions, S as SubscriptionGraph, b as SubscriptionOptions, c as TopicBridgeGraph, d as TopicBridgeOptions, T as TopicGraph, e as TopicOptions, m as messagingHub, s as subscription, t as topic, f as topicBridge } from '../../index-DyxjtScX.cjs';
4
+ import '../../meta-Cgj6zeji.cjs';
5
+ import '../../extra/storage-core.cjs';
@@ -0,0 +1,5 @@
1
+ import '../../node-Cc1TniY8.js';
2
+ import '../../graph-BZGRXwOm.js';
3
+ export { M as MessagingHubGraph, a as MessagingHubOptions, S as SubscriptionGraph, b as SubscriptionOptions, c as TopicBridgeGraph, d as TopicBridgeOptions, T as TopicGraph, e as TopicOptions, m as messagingHub, s as subscription, t as topic, f as topicBridge } from '../../index-B0c4cmIO.js';
4
+ import '../../meta-CwesDrMD.js';
5
+ import '../../extra/storage-core.js';
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h}from"../../chunk-DBGGMN3D.js";import"../../chunk-ETWTCCJI.js";import"../../chunk-2FOAM3OR.js";import"../../chunk-MTTAAPCK.js";import"../../chunk-CKCSDI7T.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-VPYBOXVT.js";import"../../chunk-D7A7DBE4.js";import"../../chunk-2PMCKKRK.js";import"../../chunk-ZB5EHBIO.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{d as MessagingHubGraph,b as SubscriptionGraph,c as TopicBridgeGraph,a as TopicGraph,f as messagingHub,g as subscription,e as topic,h as topicBridge};