@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
@@ -1,6 +1,6 @@
1
- export { B as BlockAdapters, C as CanvasMeasureAdapter, a as CanvasMeasureAdapterOptions, b as CanvasModule, c as CircleObstacle, d as CliMeasureAdapter, e as CliMeasureAdapterOptions, f as ContentBlock, F as FlowColumns, g as FlowContainer, h as FlowLinesResult, I as ImageMeasurer, j as ImageSizeAdapter, M as MeasuredBlock, N as NodeCanvasMeasureAdapter, O as Obstacle, P as PositionedBlock, k as PositionedLine, l as PrecomputedAdapter, m as PrecomputedAdapterOptions, R as ReactiveBlockLayoutBundle, n as ReactiveBlockLayoutOptions, o as ReactiveFlowLayoutBundle, p as ReactiveFlowLayoutOptions, q as RectObstacle, S as SvgBoundsAdapter, r as SvgMeasurer, s as circleIntervalForBand, t as computeBlockFlow, u as computeFlowLines, v as computeTotalHeight, w as measureBlock, x as measureBlocks, y as reactiveBlockLayout, z as reactiveFlowLayout, A as rectIntervalForBand } from '../../index-CI3DprxP.cjs';
2
- export { C as CharPosition, I as Interval, a as LayoutCursor, b as LayoutLine, c as LayoutNextLineContext, d as LayoutNextLineResult, L as LineBreaksResult, M as MeasurementAdapter, P as PreparedSegment, R as ReactiveLayoutBundle, e as ReactiveLayoutOptions, S as SegmentBreakKind, f as SegmentMeasureStats, g as analyzeAndMeasure, h as carveTextLineSlots, i as computeCharPositions, j as computeLineBreaks, l as layoutNextLine, r as reactiveLayout } from '../../reactive-layout-MQP--J3F.cjs';
3
- import '../../node-BmerH3kS.cjs';
4
- import '../../graph-DNCrvZSn.cjs';
5
- import '../../meta-BxCA7rcr.cjs';
6
- import '../../storage-DdWlZo6U.cjs';
1
+ export { B as BlockAdapters, C as CanvasMeasureAdapter, a as CanvasMeasureAdapterOptions, b as CanvasModule, c as CircleObstacle, d as CliMeasureAdapter, e as CliMeasureAdapterOptions, f as ComputeFlowLinesOptions, g as ContentBlock, F as FlowColumns, h as FlowContainer, j as FlowLinesResult, I as ImageMeasurer, k as ImageSizeAdapter, M as MeasuredBlock, N as NodeCanvasMeasureAdapter, O as Obstacle, P as PositionedBlock, l as PositionedLine, m as PrecomputedAdapter, n as PrecomputedAdapterOptions, R as ReactiveBlockLayoutBundle, o as ReactiveBlockLayoutOptions, p as ReactiveFlowLayoutBundle, q as ReactiveFlowLayoutOptions, r as RectObstacle, S as SvgBoundsAdapter, s as SvgMeasurer, t as circleIntervalForBand, u as computeBlockFlow, v as computeFlowLines, w as computeTotalHeight, x as measureBlock, y as measureBlocks, z as reactiveBlockLayout, A as reactiveFlowLayout, D as rectIntervalForBand } from '../../index-fM6y00vT.cjs';
2
+ export { C as CharPosition, I as Interval, a as LayoutCursor, b as LayoutLine, c as LayoutNextLineContext, d as LayoutNextLineResult, L as LineBreaksResult, M as MeasurementAdapter, P as PreparedSegment, R as ReactiveLayoutBundle, e as ReactiveLayoutOptions, S as SegmentBreakKind, f as SegmentMeasureStats, g as analyzeAndMeasure, h as carveTextLineSlots, i as computeCharPositions, j as computeLineBreaks, l as layoutNextLine, r as reactiveLayout } from '../../reactive-layout-CpYb5qLP.cjs';
3
+ import '../../node-Cc1TniY8.cjs';
4
+ import '../../graph-D48Qw9Cg.cjs';
5
+ import '../../meta-Cgj6zeji.cjs';
6
+ import '../../extra/storage-core.cjs';
@@ -1,6 +1,6 @@
1
- export { B as BlockAdapters, C as CanvasMeasureAdapter, a as CanvasMeasureAdapterOptions, b as CanvasModule, c as CircleObstacle, d as CliMeasureAdapter, e as CliMeasureAdapterOptions, f as ContentBlock, F as FlowColumns, g as FlowContainer, h as FlowLinesResult, I as ImageMeasurer, j as ImageSizeAdapter, M as MeasuredBlock, N as NodeCanvasMeasureAdapter, O as Obstacle, P as PositionedBlock, k as PositionedLine, l as PrecomputedAdapter, m as PrecomputedAdapterOptions, R as ReactiveBlockLayoutBundle, n as ReactiveBlockLayoutOptions, o as ReactiveFlowLayoutBundle, p as ReactiveFlowLayoutOptions, q as RectObstacle, S as SvgBoundsAdapter, r as SvgMeasurer, s as circleIntervalForBand, t as computeBlockFlow, u as computeFlowLines, v as computeTotalHeight, w as measureBlock, x as measureBlocks, y as reactiveBlockLayout, z as reactiveFlowLayout, A as rectIntervalForBand } from '../../index-C8oil6M6.js';
2
- export { C as CharPosition, I as Interval, a as LayoutCursor, b as LayoutLine, c as LayoutNextLineContext, d as LayoutNextLineResult, L as LineBreaksResult, M as MeasurementAdapter, P as PreparedSegment, R as ReactiveLayoutBundle, e as ReactiveLayoutOptions, S as SegmentBreakKind, f as SegmentMeasureStats, g as analyzeAndMeasure, h as carveTextLineSlots, i as computeCharPositions, j as computeLineBreaks, l as layoutNextLine, r as reactiveLayout } from '../../reactive-layout-u5Ulnqag.js';
3
- import '../../node-BmerH3kS.js';
4
- import '../../graph-CCwGKLCm.js';
5
- import '../../meta-CbznRPYJ.js';
6
- import '../../storage-CMjUUuxn.js';
1
+ export { B as BlockAdapters, C as CanvasMeasureAdapter, a as CanvasMeasureAdapterOptions, b as CanvasModule, c as CircleObstacle, d as CliMeasureAdapter, e as CliMeasureAdapterOptions, f as ComputeFlowLinesOptions, g as ContentBlock, F as FlowColumns, h as FlowContainer, j as FlowLinesResult, I as ImageMeasurer, k as ImageSizeAdapter, M as MeasuredBlock, N as NodeCanvasMeasureAdapter, O as Obstacle, P as PositionedBlock, l as PositionedLine, m as PrecomputedAdapter, n as PrecomputedAdapterOptions, R as ReactiveBlockLayoutBundle, o as ReactiveBlockLayoutOptions, p as ReactiveFlowLayoutBundle, q as ReactiveFlowLayoutOptions, r as RectObstacle, S as SvgBoundsAdapter, s as SvgMeasurer, t as circleIntervalForBand, u as computeBlockFlow, v as computeFlowLines, w as computeTotalHeight, x as measureBlock, y as measureBlocks, z as reactiveBlockLayout, A as reactiveFlowLayout, D as rectIntervalForBand } from '../../index-ROpQmGjE.js';
2
+ export { C as CharPosition, I as Interval, a as LayoutCursor, b as LayoutLine, c as LayoutNextLineContext, d as LayoutNextLineResult, L as LineBreaksResult, M as MeasurementAdapter, P as PreparedSegment, R as ReactiveLayoutBundle, e as ReactiveLayoutOptions, S as SegmentBreakKind, f as SegmentMeasureStats, g as analyzeAndMeasure, h as carveTextLineSlots, i as computeCharPositions, j as computeLineBreaks, l as layoutNextLine, r as reactiveLayout } from '../../reactive-layout-D8u4wuUR.js';
3
+ import '../../node-Cc1TniY8.js';
4
+ import '../../graph-BZGRXwOm.js';
5
+ import '../../meta-CwesDrMD.js';
6
+ import '../../extra/storage-core.js';
@@ -1,56 +1 @@
1
- import {
2
- CanvasMeasureAdapter,
3
- CliMeasureAdapter,
4
- ImageSizeAdapter,
5
- NodeCanvasMeasureAdapter,
6
- PrecomputedAdapter,
7
- SvgBoundsAdapter,
8
- circleIntervalForBand,
9
- computeBlockFlow,
10
- computeFlowLines,
11
- computeTotalHeight,
12
- measureBlock,
13
- measureBlocks,
14
- reactiveBlockLayout,
15
- reactiveFlowLayout,
16
- rectIntervalForBand
17
- } from "../../chunk-X3VMZYBT.js";
18
- import {
19
- analyzeAndMeasure,
20
- carveTextLineSlots,
21
- computeCharPositions,
22
- computeLineBreaks,
23
- layoutNextLine,
24
- reactiveLayout
25
- } from "../../chunk-GTE6PWRZ.js";
26
- import "../../chunk-JSCT3CR4.js";
27
- import "../../chunk-BVZYTZ5H.js";
28
- import "../../chunk-PF7GRZMW.js";
29
- import "../../chunk-VYPWMZ6H.js";
30
- import "../../chunk-7TAQJHQV.js";
31
- import "../../chunk-PHOUUNK7.js";
32
- import "../../chunk-SX52TAR4.js";
33
- export {
34
- CanvasMeasureAdapter,
35
- CliMeasureAdapter,
36
- ImageSizeAdapter,
37
- NodeCanvasMeasureAdapter,
38
- PrecomputedAdapter,
39
- SvgBoundsAdapter,
40
- analyzeAndMeasure,
41
- carveTextLineSlots,
42
- circleIntervalForBand,
43
- computeBlockFlow,
44
- computeCharPositions,
45
- computeFlowLines,
46
- computeLineBreaks,
47
- computeTotalHeight,
48
- layoutNextLine,
49
- measureBlock,
50
- measureBlocks,
51
- reactiveBlockLayout,
52
- reactiveFlowLayout,
53
- reactiveLayout,
54
- rectIntervalForBand
55
- };
56
- //# sourceMappingURL=index.js.map
1
+ import{a as g,b as h,c as i,d as j,e as k,f as l,g as m,h as n,i as o,j as p,k as q,l as r,m as s,n as t,o as u}from"../../chunk-V6YQICXZ.js";import{a,b,c,d,e,f}from"../../chunk-QWAPKG3O.js";import"../../chunk-ETWTCCJI.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{i as CanvasMeasureAdapter,g as CliMeasureAdapter,l as ImageSizeAdapter,j as NodeCanvasMeasureAdapter,h as PrecomputedAdapter,k as SvgBoundsAdapter,a as analyzeAndMeasure,d as carveTextLineSlots,r as circleIntervalForBand,o as computeBlockFlow,e as computeCharPositions,t as computeFlowLines,b as computeLineBreaks,p as computeTotalHeight,c as layoutNextLine,m as measureBlock,n as measureBlocks,q as reactiveBlockLayout,u as reactiveFlowLayout,f as reactiveLayout,s as rectIntervalForBand};
@@ -0,0 +1,6 @@
1
+ "use strict";var qe=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var en=Object.prototype.hasOwnProperty;var W=(r,e)=>()=>(r&&(e=r(r=0)),e);var tn=(r,e)=>{for(var t in e)qe(r,t,{get:e[t],enumerable:!0})},nn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Qt(e))!en.call(r,s)&&s!==t&&qe(r,s,{get:()=>e[s],enumerable:!(n=Zt(e,s))||n.enumerable});return r};var rn=r=>nn(qe({},"__esModule",{value:!0}),r);function Re(){return ue>0||ve}function ht(){return ue>0}function _e(r){ue>0?we.push(r):r()}function ce(r){ue+=1;let e=!1;try{r()}catch(t){throw e=!0,t}finally{if(ue-=1,ue===0)if(e){if(!ve){let t=we.splice(0);for(let n of t)try{n()}catch{}oe.length=0,ie.length=0,de.length=0}}else sn()}}function sn(){let r=!ve;r&&(ve=!0);let e=[],t=0;try{for(;oe.length>0||ie.length>0||de.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 oe.length=0,ie.length=0,de.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(oe.length>0?oe:ie.length>0?ie:de).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{r&&(ve=!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||!Re()){r(e);return}(u>=5?de:u===4?ie:oe).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 d=Re();if(s>0){let u=e.slice(0,s);r(u)}if(o>s){let u=e.slice(s,o);d?oe.push(()=>r(u)):r(u)}if(i>o){let u=e.slice(o,i);d?ie.push(()=>r(u)):r(u)}if(n>i){let u=e.slice(i,n);d?de.push(()=>r(u)):r(u)}}var ue,ve,oe,ie,de,we,Te=W(()=>{"use strict";ue=0,ve=!1,oe=[],ie=[],de=[],we=[]});var le,M,P,F,Y,U,J,z,L,A,fe,Ye,on,Je,an,un,Xe,gt,mt,bt,Ze,ee=W(()=>{"use strict";le=Symbol.for("graphrefly/START"),M=Symbol.for("graphrefly/DATA"),P=Symbol.for("graphrefly/DIRTY"),F=Symbol.for("graphrefly/RESOLVED"),Y=Symbol.for("graphrefly/INVALIDATE"),U=Symbol.for("graphrefly/PAUSE"),J=Symbol.for("graphrefly/RESUME"),z=Symbol.for("graphrefly/TEARDOWN"),L=Symbol.for("graphrefly/COMPLETE"),A=Symbol.for("graphrefly/ERROR"),fe=Object.freeze([P]),Ye=Object.freeze([F]),on=Object.freeze([Y]),Je=Object.freeze([le]),an=Object.freeze([L]),un=Object.freeze([z]),Xe=Object.freeze([fe]),gt=Object.freeze([Ye]),mt=Object.freeze([on]),bt=Object.freeze([an]),Ze=Object.freeze([un])});function vt(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++]=Qe,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 wt(r,e){if(r.length<yt)throw new Error(`decodeEnvelope: bytes too short (${r.length} < ${yt})`);let t=0,n=r[t++];if(n!==Qe)throw new Error(`decodeEnvelope: unsupported envelope version ${n} (expected ${Qe})`);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),d=e.lookupCodec(o);if(d==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:d,codecVersion:i,payload:a}}function _t(r){r.registerCodec(dn)}var dn,Qe,yt,et=W(()=>{"use strict";dn={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)}},Qe=1,yt=4});function De(r){if(r==null)return pe;let{type:e,id:t,...n}=r;return{type:e??"system",id:t??"",...n}}var pe,tt=W(()=>{"use strict";pe={type:"system",id:""}});function X(){return Math.trunc(performance.now()*1e6)}function Ae(){return Date.now()*1e6}var Me=W(()=>{"use strict"});function Tt(r){r.registerMessageType(le,{tier:0,wireCrossing:!1}),r.registerMessageType(P,{tier:1,wireCrossing:!1}),r.registerMessageType(Y,{tier:1,wireCrossing:!1,metaPassthrough:!1}),r.registerMessageType(U,{tier:2,wireCrossing:!1}),r.registerMessageType(J,{tier:2,wireCrossing:!1}),r.registerMessageType(M,{tier:3,wireCrossing:!0}),r.registerMessageType(F,{tier:3,wireCrossing:!0}),r.registerMessageType(L,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(A,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(z,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Ce,Nt=W(()=>{"use strict";ee();Ce=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 nt(r){let e=cn.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,cn,Ge=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}},cn=["human","llm","wallet","system"]});function rt(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(rt);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=rt(r[t]);return e}return null}function pn(r){let e=fn.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,d=3144134277,u=1013904242,c=2773480762,p=1359893119,h=2600822924,f=528734635,l=1541459225,g=new Uint32Array(64),m=(w,b)=>w>>>b|w<<32-b;for(let w=0;w<s;w+=64){for(let E=0;E<16;E++)g[E]=i.getUint32(w+E*4,!1);for(let E=16;E<64;E++){let S=g[E-15],k=g[E-2],B=m(S,7)^m(S,18)^S>>>3,Q=m(k,17)^m(k,19)^k>>>10;g[E]=g[E-16]+B+g[E-7]+Q>>>0}let b=a,v=d,O=u,_=c,T=p,x=h,R=f,V=l;for(let E=0;E<64;E++){let S=m(T,6)^m(T,11)^m(T,25),k=T&x^~T&R,B=V+S+k+ln[E]+g[E]>>>0,Q=m(b,2)^m(b,13)^m(b,22),te=b&v^b&O^v&O,Ee=Q+te>>>0;V=R,R=x,x=T,T=_+B>>>0,_=O,O=v,v=b,b=B+Ee>>>0}a=a+b>>>0,d=d+v>>>0,u=u+O>>>0,c=c+_>>>0,p=p+T>>>0,h=h+x>>>0,f=f+R>>>0,l=l+V>>>0}let y=w=>w.toString(16).padStart(8,"0");return y(a)+y(d)+y(u)+y(c)+y(p)+y(h)+y(f)+y(l)}function st(r){let e=rt(r??null),t=JSON.stringify(e);return pn(t).slice(0,16)}function hn(){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 ot(r,e,t){let n=t?.id??hn();if(r===0)return{id:n,version:0};let o=(t?.hash??st)(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 ln,fn,xt=W(()=>{"use strict";ln=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]),fn=new TextEncoder});function Rt(r){return{node:r,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function it(r){r.prevData=void 0,r.dirty=!1,r.involvedThisWave=!1,r.dataBatch.length=0,r.terminal=void 0}function $e(r){return r.length===0?r:typeof r[0]=="symbol"?[r]:r}function ne(r,e,t){let n=St(r)?r:[],s=typeof r=="function"?r:typeof e=="function"?e:void 0,o={};return St(r)?o=(at(e)?e:t)??{}:at(r)?o=r:o=(at(e)?e:t)??{},new $(n,s,o)}var Et,kt,gn,mn,he,$,St,at,ge=W(()=>{"use strict";et();tt();Te();Me();Nt();Ge();ee();xt();Et=()=>{},kt=100;gn=(r,e,t,n)=>{t.direction==="down-in"&&r._onDepMessage(t.depIndex,e)},mn=(r,e,t,n)=>{let s=r;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[Je]:[Je,[M,o]];s._status==="dirty"&&i.push(fe),Se(e,i,s._config.tierOf)},he=new Ce({onMessage:gn,onSubscribe:mn});Tt(he);_t(he);$=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??he,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??st;let s=n.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?ot(s,this._cached===void 0?void 0:this._cached,{id:n.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Rt);let o={};for(let[a,d]of Object.entries(n.meta??{})){let u={initial:d,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([[M,a]])},down(a){i._emit($e(a))},up(a){i._emitUp($e(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,d=i?.version??0,u=ot(e,o,{id:a,hash:s});u.version=d,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=De(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=De(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:Ae()}}down(e,t){let n=$e(e);n.length!==0&&(this._checkGuard(t),this._emit(n))}emit(e,t){this._checkGuard(t),this._emit([[M,e]])}up(e,t){if(this._deps.length===0)return;let n=$e(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 d=De(t);if(!this._guard(d,"observe"))throw new q({actor:d,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)it(d)}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[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=Et,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,d=!1;for(let u of i)a(u[0])>=3&&(d=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:s},this._actions);d&&this._maybeRunFnOnSettlement()}),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{}it(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=Rt(e);if(this._deps.push(n),this._sinks==null)return t;n.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Xe),n.unsub=Et;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([[A,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([[A,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{}}it(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!==le){if(s===P){this._depDirtied(n);return}if(s===Y){this._depInvalidated(n),this._emit(mt);return}if(s===U||s===J){this._emit([t]);return}if(s===z){this._emit(Ze);return}if(s===M)this._depSettledAsData(n,t[1]);else if(s===F)this._depSettledAsResolved(n);else if(s===L)this._depSettledAsTerminal(n,!0);else if(s===A)this._depSettledAsTerminal(n,t[1]);else{this._emit([t]);return}if(!this._fn){(s===M||s===F)&&this._emit([t]),(s===L||s===A)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Xe))}_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(gt),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([[A,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(bt)}_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([[A,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([[A,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([[A,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([[A,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"?[fe,e[0]]:e;let n=!0,s=!1,o=!1,i=-1;for(let d of e){let u=t(d[0]);u<i&&(n=!1),u===3&&(s=!0),d[0]===P&&(o=!0),i=u}let a=e;if(!n){let d=e.map((u,c)=>({m:u,i:c,tier:t(u[0])}));d.sort((u,c)=>u.tier-c.tier||u.i-c.i),a=d.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let d=0;for(;d<a.length&&t(a[d][0])===0;)d++;return d===0?[fe,...a]:[...a.slice(0,d),fe,...a.slice(d)]}return a}_emit(e){if(e.length===0)return;let t=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(d=>d[0]===z||d[0]===Y);if(a.length===0)return;t=a}t=this._frameBatch(t);let s=null;for(let a=0;a<t.length;a++){let d=t[a],u=d[0];if(u!==U&&u!==J){s?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===U?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let p=d[1];if(u===U)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(p),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(p))c=!1;else if(this._pauseLocks.delete(p),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let h=this._pauseBuffer;this._pauseBuffer=[],this._emit(h)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?s?.push(d):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]===z))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(Ze)}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,d=[];for(let u of o){let c=a(u[0]);c<3||c===5?d.push(u):this._pauseBuffer.push(u)}d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[A,i]])}_updateState(e){let t=this._config.tierOf,n,s,o=-1,i=0;for(let c of e)t(c[0])===3&&i++;let a=i<=1,d=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===M){d=c;break}}for(let c=0;c<e.length;c++){let p=e[c],h=p[0];if(h===M){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=c;break}if(f){n==null&&(n=e.slice(0,c)),n.push(Ye),this._status="resolved";continue}this._cached=p[1],this._versioning!=null&&(d<0||c===d)&&Ot(this._versioning,p[1],this._hashFn)}this._status="settled",n?.push(p)}else if(n?.push(p),h===P)this._status="dirty";else if(h===F)this._status="resolved";else if(h===L)this._status="completed";else if(h===A)this._status="errored";else if(h===Y){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===z&&(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(ht()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],_e(()=>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)}},St=r=>Array.isArray(r),at=r=>typeof r=="object"&&r!=null&&!Array.isArray(r)});function Dt(r,e,t){return t?!1:r.some((n,s)=>!(n!=null&&n.length>0)&&e.prevData[s]===void 0)}function re(r,e){return ne([],{...e,initial:r})}function Ne(r,e){return ne((n,s,o)=>r(s,o)??void 0,{describeKind:"producer",...e})}function ae(r,e,t){let n=t?.partial??!1;return ne(r,(o,i,a)=>{if(Dt(o,a,n)){i.down([[F]]);return}let d=o.map((u,c)=>u!=null&&u.length>0?u.at(-1):a.prevData[c]);i.emit(e(d,a))},{describeKind:"derived",...t})}function At(r,e,t){let n=t?.partial??!1;return ne(r,(o,i,a)=>{if(Dt(o,a,n)){i.down([[F]]);return}let d=o.map((u,c)=>u!=null&&u.length>0?u.at(-1):a.prevData[c]);return e(d,i,a)??void 0},{describeKind:"effect",...t})}var Oe=W(()=>{"use strict";ee();ge()});function se(r){return r.subscribe(()=>{})}var ut=W(()=>{"use strict"});var Pe,$t=W(()=>{"use strict";Pe=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 Yn={};tn(Yn,{budgetGate:()=>Kn,effectivenessTracker:()=>qn,feedback:()=>Hn,funnel:()=>Un,scorer:()=>Wn});module.exports=rn(Yn);Te();ee();ge();Oe();ee();Oe();function Mt(r){return{describeKind:"derived",...r}}function Ct(...r){return r.length===0?Ne(e=>{e.down([[L]])},Mt()):Ne(e=>{let t=r.length,n=0,s=[];for(let o of r){let i=o.subscribe(a=>{for(let d of a)d[0]===M?e.emit(d[1]):d[0]===L?(n+=1,n>=t&&e.down([[L]])):d[0]===A&&e.down([d])});s.push(i)}return()=>{for(let o of s)o()}},Mt())}Te();Me();ee();Oe();var dt=class{_version=0;_store=new Map;_maxSize;_defaultTtl;constructor(e={}){let{maxSize:t,defaultTtl:n}=e;if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(n!==void 0&&n<=0)throw new RangeError("defaultTtl must be positive");this._maxSize=t,this._defaultTtl=n}get version(){return this._version}get size(){return this._store.size}has(e){let t=this._store.get(e);return t===void 0?!1:this._isExpired(t)?(this._store.delete(e),this._version+=1,!1):(this._touchLru(e,t),!0)}get(e){let t=this._store.get(e);if(t!==void 0){if(this._isExpired(t)){this._store.delete(e),this._version+=1;return}return this._touchLru(e,t),t.value}}set(e,t,n){let s=this._resolveExpiresAt(n);this._store.has(e)&&this._store.delete(e),this._store.set(e,{value:t,expiresAt:s}),this._evictLruWhileOver(),this._version+=1}setMany(e,t){let n=this._resolveExpiresAt(t),s=0;try{for(let[o,i]of e)this._store.has(o)&&this._store.delete(o),this._store.set(o,{value:i,expiresAt:n}),s+=1}finally{s>0&&(this._evictLruWhileOver(),this._version+=1)}}delete(e){let t=this._store.delete(e);return t&&(this._version+=1),t}deleteMany(e){let t=0;try{for(let n of e)this._store.delete(n)&&(t+=1)}finally{t>0&&(this._version+=1)}return t}clear(){let e=this._store.size;return e===0?0:(this._store.clear(),this._version+=1,e)}pruneExpired(){let e=X(),t=0;for(let[n,s]of this._store)this._isExpired(s,e)&&(this._store.delete(n),t+=1);return t>0&&(this._version+=1),t}toMap(){let e=X(),t=new Map;for(let[n,s]of this._store)this._isExpired(s,e)||t.set(n,s.value);return t}_resolveExpiresAt(e){let t=e??this._defaultTtl;if(t!==void 0){if(!Number.isFinite(t)||t<=0)throw new RangeError(`MapBackend: ttl must be a positive finite number (got ${t})`);return X()+t*1e9}}_isExpired(e,t){return e.expiresAt===void 0?!1:(t??X())>=e.expiresAt}_touchLru(e,t){this._store.delete(e),this._store.set(e,t)}_evictLruWhileOver(){if(this._maxSize!==void 0)for(;this._store.size>this._maxSize;){let e=this._store.keys().next().value;if(e===void 0)break;this._store.delete(e)}}};function Gt(r={}){let{name:e,maxSize:t,defaultTtl:n,versioning:s,backend:o}=r,i=o??new dt({maxSize:t,defaultTtl:n}),a=re(i.toMap(),{name:e,describeKind:"state",equals:(c,p)=>c===p,...s!=null?{versioning:s}:{}});function d(){let c=i.toMap();ce(()=>{a.down([[P]]),a.down([[M,c]])})}function u(c){let p=i.version;try{return c()}finally{i.version!==p&&d()}}return{entries:a,has(c){return u(()=>i.has(c))},get(c){return u(()=>i.get(c))},set(c,p,h){u(()=>i.set(c,p,h?.ttl))},setMany(c,p){u(()=>i.setMany(c,p?.ttl))},delete(c){u(()=>i.delete(c))},deleteMany(c){u(()=>i.deleteMany(c))},clear(){u(()=>i.clear())},pruneExpired(){u(()=>i.pruneExpired())},get size(){return i.size},dispose(){}}}tt();Te();Me();Ge();ee();Ge();ge();function Ie(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 bn(r){return r._describeKind!=null?r._describeKind:r._deps.length>0?"derived":r._fn!=null?"producer":"state"}function yn(r){let e={};for(let[t,n]of Object.entries(r.meta))try{e[t]=n.cache}catch{}return e}function ct(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 $&&(o=bn(r),i=r._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(t||e.has("status"))&&(a.status=r.status);let d=r instanceof $?r._guard:void 0;if(s){let u={...yn(r)};if(d!=null&&u.access===void 0&&(u.access=nt(d)),n!=null&&n.length>0&&!e.has("meta")){let c={};for(let p of n)p in u&&(c[p]=u[p]);a.meta=c}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"))&&d!=null&&(a.guard=nt(d)),(t||e.has("lastMutation"))&&r.lastMutation!=null&&(a.lastMutation=r.lastMutation),a}ge();Oe();ut();$t();var xe=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}};et();function It(r,e,t,n={}){let s=e in r.nodes,o=t in r.nodes;if(!s)return Fe(e,t,"no-such-from");if(!o)return Fe(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=vn(r,e,n);if(u!=null)return u}let d=Le(e,r.nodes[e],0,n);return Ve(e,t,[d])}if(i===0)return Fe(e,t,"no-path");let a=Pt(r,e,t,i);return a.found?Ve(e,t,Ft(r,a.pathOrder,n)):Fe(e,t,a.truncated?"max-depth-exceeded":"no-path")}function Pt(r,e,t,n){let s=new Map,o=[{path:t,depth:0}],i=new Set([t]),a=0,d=!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&&(d=!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:d};let u=[{path:e}],c=e;for(;c!==t;){let p=s.get(c);if(p==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=p.depIndices,u.push({path:p.from}),c=p.from}return{found:!0,pathOrder:u,truncated:!1}}function vn(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=Le(e,n,0,t);a.dep_index=o[0];let d=Le(e,n,1,t);return Ve(e,e,[a,d])}let i=null;for(let a=0;a<s.length;a++){let d=s[a];if(!d||d===e)continue;let u=Pt(r,d,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:Ve(e,e,Ft(r,i.pathOrder,t))}function Ft(r,e,t){return e.map((n,s)=>{let o=r.nodes[n.path],i=Le(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 Le(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 Ve(r,e,t){return Lt(r,e,!0,"ok",t)}function Fe(r,e,t){return Lt(r,e,!1,t,[])}function Lt(r,e,t,n,s){let o=wn(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 wn(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 d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(d),"value"in i&&o.push(` value: ${_n(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 _n(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)}}ge();var I={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},Tn=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 I.number;case"boolean":return I.boolean;case"string":return I.string+r.length*2;case"bigint":return I.bigint+On(r);case"symbol":return I.symbol;case"function":return e.has(r)?0:(e.add(r),I.function);case"undefined":return 0}let o=r;if(e.has(o))return 0;e.add(o);let i=o[Tn];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 I.date;if(o instanceof RegExp)return I.regexp+o.source.length*2;if(o instanceof Error){let u=o.message?o.message.length*2:0,c=o.stack?o.stack.length*2:0;return I.error+u+c}if(typeof URL<"u"&&o instanceof URL)return I.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return I.promise;if(o instanceof WeakMap)return I.weakmap;if(o instanceof WeakSet)return I.weakset;if(o instanceof Map){let u=I.map;for(let[c,p]of o)u+=I.mapEntry,n.push(c),n.push(p);return u}if(o instanceof Set){let u=I.set;for(let c of o)u+=I.setEntry,n.push(c);return u}if(Array.isArray(o)){let u=I.array+o.length*8;for(let c of o)n.push(c);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=I.object,d=Object.keys(o);for(let u of d){a+=I.string+u.length*2;try{n.push(o[u])}catch{}}return a}function On(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 Bt(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 $?l:null,m=g?Vt(g.cache):0,y=g?g._sinkCount:0,w=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:w,isOrphanEffect:b,orphanKind:v})}let d=a.reduce((h,f)=>h+f.valueSizeBytes,0),u=(h,f)=>[...a].sort(f??((l,g)=>g[h]-l[h])).slice(0,t),c=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:d,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:c,orphanEffects:p}}var G="::",Z="__meta__",me=1;function jt(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 xn(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 zt(r){if(r.version!==me)throw new Error(`unsupported snapshot version ${String(r.version)} (expected ${me})`);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 En(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,d=o.constructor;if(a!==d)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let 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),c=Object.keys(o);if(u.length!==c.length)return!1;let p=new Set(c);for(let h of u)if(!p.has(h)||!n(s[h],o[h]))return!1;return!0};return n(r,e)}function ft(r){if(r===null||typeof r!="object")return r;if(Array.isArray(r))return r.map(ft);let e=r,t=Object.keys(e).sort(),n={};for(let s of t)n[s]=ft(e[s]);return n}function kn(r){return r.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Rn(r){return r.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Sn(r){return r==="TD"?"down":r==="BT"?"up":r==="RL"?"left":"right"}function Kt(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 Wt(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 Dn(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(ft(i),null,e.indent??2);return e.logger?.(a),a}function An(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}): ${je(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=Wt(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}["${kn(i)}"]`)}for(let[i,a]of Kt(r)){let d=s.get(i),u=s.get(a);!d||!u||o.push(` ${d} --> ${u}`)}return o.join(`
5
+ `)}function Mn(r,e){let t=qt(r,e);return Cn(t)}function Cn(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 Gn(r,e){let t=Wt(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: ${Sn(t)}`];for(let i of n){let a=s.get(i);o.push(`${a}: "${Rn(i)}"`)}for(let[i,a]of Kt(r)){let d=s.get(i),u=s.get(a);!d||!u||o.push(`${d} -> ${u}`)}return o.join(`
6
+ `)}function $n(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Be(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+=$n(n)}return e+="$",new RegExp(e)}var In={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"},Pn={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function je(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 Fn(r){return r==="none"?Pn:r==="ansi"||r==null?In:{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 Ut(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 Ln(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 lt(r,e,t){if(r==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(r.includes(G))throw new Error(`Graph "${e}": ${t} "${r}" must not contain '${G}' (path separator)`);if(r===Z)throw new Error(`Graph "${e}": ${t} name "${Z}" is reserved for meta companion paths`);Ln(r,e,t)}function Vn(r,e){if(r==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=r.split(G);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function Bn(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 Yt(r){for(let e of r._mounts.values())Yt(e);for(let e of r._nodes.values())try{e.down([[z]],{internal:!0})}catch{}}var be=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(G))throw new Error(`Graph name must not contain '${G}' (got "${e}")`);if(e===Z)throw new Error(`Graph name "${Z}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??he,this._traceRing=new xe(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=Ne(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(lt(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:X()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof $&&t._applyVersioning(e)}remove(e){lt(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,d]of i)a.includes(`${G}${Z}${G}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...t._collectSubgraphs(`${e}${G}`)),this._mounts.delete(e),t._parent=void 0,Yt(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([[z]],{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=Be(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(G))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([[M,t]],{actor:n?.actor,internal:s,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);ce(()=>{for(let[s,o]of n)this.set(s,o,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[Y]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let s=n?.internal===!0;this.node(e).down([[A,t]],{actor:n?.actor,internal:s,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[L]],{actor:t?.actor,internal:n,delivery:"write"})}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[d,u]of this._nodes)n.set(u,d);let a=[];for(let[d,u]of this._nodes)if(u instanceof $)for(let c of u._deps){let p=n.get(c.node);p!=null&&a.push([p,d])}return a.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,d]of s)o.set(d,a);let i=[];for(let[a,d]of s)if(d instanceof $)for(let u of d._deps){let c=o.get(u.node);c!=null&&i.push([c,a])}return i.sort((a,d)=>a[0]<d[0]?-1:a[0]>d[0]?1:a[1]<d[1]?-1:a[1]>d[1]?1:0),i}mount(e,t){if(lt(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=Vn(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]===Z)return this._resolveMetaChainFromNode(o,s,t.join(G));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(G)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(s.join(G))}_resolveMetaChainFromNode(e,t,n){let s=e,o=0,i=[...t];for(;o<i.length;){if(i[o]!==Z)throw new Error(`Graph "${this.name}": expected ${Z} segment in meta path "${n}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Z} in "${n}"`);let a=i[o+1],d=s.meta[a];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${n}"`);s=d,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 d of this._mounts.values())d._signalDeliver(e,t,n,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=Bn(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!n.has(u)){n.add(u);try{u.down(e,i)}catch(c){if(c instanceof q)throw c;s.push(c)}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(d){if(d instanceof q)throw d;o.push(d)}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=Ie(e?.detail,e?.fields),o=e?.format==="spec",i=o?Ie("minimal"):s,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[_,T]of a)d.set(T,_);let u=[];{let _=a.map(([,R])=>R),T=new Set(d.values()),x=0;for(;_.length>0;){let R=_.shift();if(R instanceof $)for(let V of R._deps){let E=V.node;if(d.has(E))continue;let S=E.name??"",k=S;if(!k||T.has(k))if(S){let B=2;for(;T.has(`${S}#${B}`);)B++;k=`${S}#${B}`}else for(k=`__internal__/${x++}`;T.has(k);)k=`__internal__/${x++}`;d.set(E,k),T.add(k),u.push([k,E]),_.push(E)}}}let c=[...a,...u],p={};for(let[_,T]of c){if(t!=null&&!T.allowsObserve(t))continue;let x=ct(T,i),R=T instanceof $?T._deps.map(k=>d.get(k.node)??k.node.name??""):[],{name:V,...E}=x,S={...E,deps:R};if(!o){let k=this._annotations.get(_);k!=null&&(S.annotation=k)}if(n!=null)if(typeof n=="function"){let k=n;if(!(k.length>=2?k(_,S):k(S)))continue}else{let k=!0;for(let[B,Q]of Object.entries(n)){let te=B==="deps_includes"?"depsIncludes":B==="meta_has"?"metaHas":B;if(te==="depsIncludes"){if(!S.deps.includes(String(Q))){k=!1;break}continue}if(te==="metaHas"){if(!Object.hasOwn(S.meta??{},String(Q))){k=!1;break}continue}if(S[te]!==Q){k=!1;break}}if(!k)continue}p[_]=S}let h=new Set(Object.keys(p)),f=[];for(let[_,T]of c)if(T instanceof $)for(let x of T._deps){let R=d.get(x.node);R!=null&&f.push([R,_])}f.sort((_,T)=>_[0]<T[0]?-1:_[0]>T[0]?1:_[1]<T[1]?-1:_[1]>T[1]?1:0);let l=f.map(([_,T])=>({from:_,to:T}));(t!=null||n!=null)&&(l=l.filter(_=>h.has(_.from)&&h.has(_.to)));let g=this._collectSubgraphs(""),m=t!=null||n!=null?g.filter(_=>{let T=`${_}${G}`;return[...h].some(x=>x===_||x.startsWith(T))}):g,y=this,w=e,b={name:this.name,nodes:p,edges:l,subgraphs:m,expand(_){let T={...w,format:void 0};return Array.isArray(_)?(T.fields=_,T.detail=void 0):(T.detail=_,T.fields=void 0),y.describe(T)}},v=e??{},O=v.format;return O==="json"?Dn(b,v):O==="pretty"?An(b,v):O==="mermaid"?qt(b,v):O==="mermaid-url"?Mn(b,v):O==="d2"?Gn(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}${G}`))}return t}resourceProfile(e){return Bt(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,d]of Object.entries(s.nodes))d.lastMutation!=null&&i.set(a,d.lastMutation);return It(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=re(s,{name:`${n}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,_e(()=>{a=!1,!d&&(s+=1,o.emit(s))}))},c=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)||d)return;h.add(m);let y=m.topology.subscribe(w=>{for(let b of w){if(b[0]!==M)continue;let v=b[1];if(u(),v.kind==="added"&&v.nodeKind==="mount"){let O=m._mounts.get(v.name);O!=null&&f(O)}}});p.push(y);for(let w of m._mounts.keys()){let b=m._mounts.get(w);b!=null&&f(b)}};f(this);let l;try{l=ae([o],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,y)=>m===y})}catch(m){c();for(let y of p)y();throw i.dispose(),m}let g=se(l);return{node:l,dispose(){d=!0,c();for(let m of p)m();p.length=0,i.dispose(),g()}}}_explainReactive(e,t,n){let s=0,o=re(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(f=>{let l=f.type;l!=="data"&&l!=="error"&&l!=="complete"&&l!=="teardown"||a||d||(a=!0,_e(()=>{a=!1,!d&&(s+=1,o.emit(s))}))}),c={...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{}},p;try{p=ae([o],()=>this._explainStatic(e,t,c),{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&&zn(f.steps,l.steps)})}catch(f){throw u(),i.dispose(),f}let h=se(p);return{node:p,dispose(){d=!0,u(),i.dispose(),h()}}}_pathsMatching(e){let t=Be(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}${G}${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}${G}${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}${G}${Z}${G}${s}`;n.push([i,o]),this._appendMetaObserveTargets(i,o,n)}}observe(e,t){let n=typeof e=="string",o=Ut(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 c=e,p=this.resolve(c);if(a!=null&&!p.allowsObserve(a))throw new q({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,p]],o,"one"):{subscribe(h){return p.subscribe(h)},up(h){try{p.up?.(h)}catch(f){if(f instanceof q)return;throw f}}}}let d=[];this._collectObserveTargets("",d),d.sort((c,p)=>c[0]<p[0]?-1:c[0]>p[0]?1:0);let u=a==null?d:d.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,o,"all"):{subscribe:c=>{let p=u.map(([h,f])=>f.subscribe(l=>{c(h,l)}));return()=>{for(let h of p)h()}},up:(c,p)=>{try{this.resolve(c).up?.(p)}catch(h){if(h instanceof q)return;throw h}}}}_buildStructuredObserver(e,t,n){let s=n==="one"?e[0]?.[0]:void 0,o=i=>{if(n==="one"&&s!=null){let c=this.resolve(s);return this._buildStructuredObserver([[s,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,p)=>c[0]<p[0]?-1:c[0]>p[0]?1:0);let d=i.actor,u=d==null?a:a.filter(([,c])=>c.allowsObserve(d));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,t,o)}_createObserveResult(e,t,n){let s=t.timeline===!0,o=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",d=this.config.inspectorEnabled,u=(o||i)&&d,c=t.maxEvents,p=c!=null&&c>0?new xe(c):null,h=[],f=new Set,l={},g=new Set,m=0,y=0,w=0,b=0,v=0,O=0,_=!1,T=!1,x=0,R=new Map,V=new Map,E=new Map,S=N=>{p?p.push(N):h.push(N);for(let C of f)C(N)},k=()=>s?{timestamp_ns:X(),in_batch:Re(),batch_id:x}:{},B=(N,C)=>{if(!(!u||!(N instanceof $)))return N._setInspectorHook(H=>{if(H.kind==="dep_message")R.set(N,H.depIndex);else if(H.kind==="run"){let ye=H.batchData.map((D,j)=>D!=null&&D.length>0?D.at(-1):H.prevData[j]);V.set(N,ye);let K=H.batchData.map(D=>D!=null?[...D]:void 0);E.set(N,K),i&&S({type:"derived",path:C,dep_values:ye,dep_batches:K,...k()})}})},Q=N=>{let C=R.get(N),H=V.get(N);if(!o||H==null)return{};let K=(C!=null&&C>=0&&N instanceof $?N._deps[C]:void 0)?.node,D=K?.v,j=E.get(N);return{trigger_dep_index:C,trigger_dep_name:K?.name,...D!=null?{trigger_version:{id:D.id,version:D.version}}:{},dep_values:[...H],...j!=null?{dep_batches:j}:{}}},te=[],Ee=[];for(let[N,C]of e){let H=B(C,N);H&&te.push(H),Ee.push(C.subscribe(ye=>{x++;for(let K of ye){let D=K[0],j=k();if(D===M){l[N]=K[1];let We=C instanceof $?C.lastMutation?.actor??pe:pe;S({type:"data",path:N,data:K[1],actor:We,...j,...Q(C)})}else if(a)D===P?m++:D===F?y++:D===Y?w++:D===U?b++:D===J?v++:D===z?O++:D===L&&!g.has(N)?_=!0:D===A&&(T=!0,g.add(N));else if(D===P)m++,S({type:"dirty",path:N,...j});else if(D===F)y++,S({type:"resolved",path:N,...j,...Q(C)});else if(D===Y)w++,S({type:"invalidate",path:N,...j});else if(D===U)b++,S({type:"pause",path:N,lockId:K[1],...j});else if(D===J)v++,S({type:"resume",path:N,lockId:K[1],...j});else if(D===L)g.has(N)||(_=!0),S({type:"complete",path:N,...j});else if(D===A){T=!0,g.add(N);let We=C instanceof $?C.lastMutation?.actor??pe:pe;S({type:"error",path:N,data:K[1],actor:We,...j})}else D===z&&(O++,S({type:"teardown",path:N,...j}))}}))}let Ue=!1,He=()=>{if(!Ue){Ue=!0;for(let N of Ee)N();for(let N of te)N();for(let N of ke)N({value:void 0,done:!0});ke.length=0}},Ke=[],ke=[];f.add(N=>{let C=ke.shift();C?C({value:N,done:!1}):Ke.push(N)});let pt={get values(){return l},get dirtyCount(){return m},get resolvedCount(){return y},get invalidateCount(){return w},get pauseCount(){return b},get resumeCount(){return v},get teardownCount(){return O},get events(){return p?p.toArray():[...h]},get anyCompletedCleanly(){return _},get anyErrored(){return T},get completedWithoutErrors(){return _&&!T},onEvent(N){return f.add(N),()=>f.delete(N)},dispose:He,expand(N){He();let C={...t};return typeof N=="string"?C.detail=N:Object.assign(C,N),n(Ut(C))},[Symbol.asyncIterator](){return{next(){return Ke.length>0?Promise.resolve({value:Ke.shift(),done:!1}):Ue?Promise.resolve({value:void 0,done:!0}):new Promise(N=>ke.push(N))},return(){return He(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(pt,t),pt}_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)),d=Fn(t.theme),u=n==="stage-log"?X():0,c=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(je(l.data),120):"",f=l=>{if(n==="stage-log"){let T=(X()-u)/1e9,x=c(l.path).padEnd(9);if(l.type==="data"){let R=h(l);return`[${T.toFixed(3)}s] ${x} \u2190${R?` ${R}`:""}`}if(l.type==="error"){let R=h(l);return`[${T.toFixed(3)}s] ${x} \u2717${R?` ${R}`:""}`}return l.type==="complete"?`[${T.toFixed(3)}s] ${x} \u25A0 complete`:`[${T.toFixed(3)}s] ${x} ${l.type}`}if(n==="json")try{return JSON.stringify(l)}catch{return JSON.stringify({type:l.type,path:l.path,data:"[unserializable]"})}let g=d[l.type]??"",m=l.path?`${d.path}${l.path}${d.reset} `:"",y=l.type==="data"||l.type==="error",w=l.type==="pause"||l.type==="resume",b=y?` ${je(l.data)}`:w?` ${je(l.lockId)}`:"",v=l.type==="data"||l.type==="resolved"||l.type==="derived"?l:void 0,O=v?.trigger_dep_name!=null?` <- ${v.trigger_dep_name}`:v?.trigger_dep_index!=null?` <- #${v.trigger_dep_index}`:"",_=l.in_batch?" [batch]":"";return`${m}${g}${l.type.toUpperCase()}${d.reset}${b}${O}${_}`};e.onEvent(l=>{a(l.type)&&s(f(l),l)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){jt(this._disposers,this.name),this.signal([[z]],{internal:!0}),jt(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:d,guard:u,...c}=n.nodes[a];s[a]=c}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 vt(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??he,{codec:s,codecVersion:o,payload:i}=wt(e,n);return s.decode(i,o)}restore(e,t){if(zt(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=>Be(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 d=this.tryResolve(o)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){t?.onError?.(o,a)}}}}}static fromSnapshot(e,t){zt(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(G).length,y=g.split(G).length;return m!==y?m-y:l<g?-1:l>g?1:0})){let l=f.split(G),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:Be(f),factory:l})):[],a=f=>{for(let l of i)if(l.re.test(f))return l.factory},d=f=>{let l=f.split(G),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 w=m._mounts.get(y);if(!w)throw new Error(`unknown mount "${y}" in path "${f}"`);m=w}return[m,g]},u=Object.entries(e.nodes).filter(([f])=>!f.includes(`${G}${Z}${G}`)).sort((f,l)=>f[0]<l[0]?-1:f[0]>l[0]?1:0),c=new Map(u),p=new Map,h=!0;for(;c.size>0&&h;){h=!1;for(let[f,l]of[...c.entries()]){let g=l?.deps??[];if(!g.every(O=>p.has(O)))continue;let[m,y]=d(f),w={...l?.meta??{}},b=a(f),v;if(l?.type==="state")v=re(l.value,{meta:w});else{if(b==null)continue;v=b(y,{path:f,type:l.type,value:l.value,meta:w,deps:g,resolvedDeps:g.map(O=>p.get(O))})}m.add(v,{name:y}),p.set(f,v),c.delete(f),h=!0}}if(c.size>0){let f=[...c.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,c)=>{if(u.disposed)return;let p=xn(c.nodes);if(u.lastSnapshot!=null&&p!==""&&p===u.lastFingerprint)return;let h=u.seq+1,f=Ae(),m=u.lastSnapshot==null||h%u.compactEvery===0?{mode:"full",snapshot:c,seq:h,timestamp_ns:f,format_version:me}:{mode:"diff",diff:jn(u.lastSnapshot,c),seq:h,timestamp_ns:f,format_version:me};if(u.tier.filter&&!u.tier.filter(this.name,m))return;let y;try{y=u.tier.save(this.name,m)}catch(w){t.onError?.(w,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=c,u.lastFingerprint=p)},O=>{t.onError?.(O,u.tier)});u.savePending=v.finally(()=>{u.savePending===v&&(u.savePending=void 0)})}else u.seq=h,u.lastSnapshot=c,u.lastFingerprint=p},o=(u,c)=>{try{s(u,c)}catch(p){t.onError?.(p,u.tier)}},i=(u,c)=>{if(!c.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=ct(l,Ie("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 Pe),l.timer.start(l.debounceMs,()=>{l.disposed||o(l,this.snapshot())})))},a;if(t.paths!=null){let c=(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 c)p()}}else a=this.observe().subscribe((u,c)=>i(u,c));let d=()=>{a();for(let u of n)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,t){for(let n of e){let s;try{s=await n.load(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===me&&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(d){n?.onError?.(d,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===me&&i.nodes!=null?i:void 0;if(a!=null)try{return r.fromSnapshot(a,n)}catch(d){n?.onError?.(d,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,n){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:X(),...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(w=>!n.has(w)).sort(),i=[...n].filter(w=>!s.has(w)).sort(),a=[],d=[];for(let w of n){if(!s.has(w))continue;let b=e.nodes[w],v=t.nodes[w],O=b.v,_=v.v;O!=null&&_!=null&&O.id===_.id&&O.version!==_.version&&d.push({path:w,id:O.id,from:O.version,to:_.version});let T=O!=null&&_!=null&&O.id===_.id&&O.version===_.version;for(let x of["type","status","sentinel"]){let R=b[x],V=v[x];R!==V&&a.push({path:w,field:x,from:R,to:V})}if(!T)for(let x of["value","meta"]){let R=b[x],V=v[x];En(R,V)||a.push({path:w,field:x,from:R,to:V})}}let u=w=>`${w.from} ${w.to}`,c=new Set(e.edges.map(u)),p=new Set(t.edges.map(u)),h=t.edges.filter(w=>!c.has(u(w))),f=e.edges.filter(w=>!p.has(u(w))),l=new Set(e.subgraphs),g=new Set(t.subgraphs),m=[...g].filter(w=>!l.has(w)).sort(),y=[...l].filter(w=>!g.has(w)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:h,edgesRemoved:f,subgraphsAdded:m,subgraphsRemoved:y}}};function jn(r,e){let t=be.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,d=new Map,u=new Map,c=new Set;for(let[b,v]of Object.entries(r.nodes)){if(!b)continue;c.add(b);let O=v.deps??[];i.set(b,O);for(let _ of O)_&&(c.add(_),a.has(_)||a.set(_,new Set),a.get(_).add(b))}for(let b of r.edges){if(b==null||typeof b!="object")continue;let v=typeof b.from=="string"?b.from:"",O=typeof b.to=="string"?b.to:"";!v||!O||(c.add(v),c.add(O),u.has(v)||u.set(v,new Set),u.get(v).add(O),d.has(O)||d.set(O,new Set),d.get(O).add(v))}if(!c.has(e))return n.withDetail?s:[];let p=n.both===!0,h=b=>{if(p){let T=i.get(b)??[],x=d.get(b),R=a.get(b),V=u.get(b),E=[...T];return x&&E.push(...x),R&&E.push(...R),V&&E.push(...V),E}if(t==="upstream"){let T=i.get(b)??[],x=d.get(b);return x?[...T,...x]:T}let v=a.get(b),O=u.get(b),_=v?[...v]:[];return O&&_.push(...O),_},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 w=[...l.keys()].sort((b,v)=>b<v?-1:b>v?1:0);return n.withDetail?{paths:w,depths:l,truncated:y}:w}function zn(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}ee();ut();function Jt(r,e){let t=r.cache??0;return t>=e?!1:(r.down([[P],[M,t+1]]),!0)}function Xt(r,e,t){return{[r]:!0,[`${r}_type`]:e,...t??{}}}function ze(r,e){return Xt("reduction",r,e)}function Un(r,e,t,n){if(e.length===0)throw new RangeError("funnel requires at least one source");if(t.length===0)throw new RangeError("funnel requires at least one stage");let s=new be(r,n),o=e.length===1?e[0]:Ct(...e);s.add(o,{name:"merged"});let i="merged";for(let a=0;a<t.length;a++){let d=t[a],u=new be(d.name);d.build(u);try{u.resolve("input")}catch{throw new Error(`funnel stage "${d.name}" must define an "input" node`)}try{u.resolve("output")}catch{throw new Error(`funnel stage "${d.name}" must define an "output" node`)}s.mount(d.name,u);let c=s.resolve(i),p=`${d.name}::input`,h=s.resolve(p),f=`__bridge_${i}\u2192${d.name}_input`,l=At([c],([g])=>{h.emit(g)},{name:f});s.add(l,{name:f}),s.addDisposer(se(l)),i=`${d.name}::output`}return s}function Hn(r,e,t,n){let s=n?.maxIterations??10,o=`__feedback_${e}`,i=re(0,{meta:ze("feedback_counter",{maxIterations:s,feedbackFrom:e,feedbackTo:t})});r.add(i,{name:o});let a=r.resolve(e),d=r.resolve(t),u=`__feedback_effect_${e}`,c=ne([],(p,h)=>{let f=a.subscribe(l=>{for(let g of l){let m=g[0];if(m===M){let y=g[1];if(y==null)return;ce(()=>{Jt(i,s)&&d.emit(y)})}else if(m===L||m===A){let y=m===A&&g.length>1?[A,g[1]]:[m];i.down([y])}}});return()=>f()},{name:u,describeKind:"effect",meta:{...ze("feedback_effect",{feedbackFrom:e,feedbackTo:t}),_internal:!0}});return r.add(c,{name:u}),r.addDisposer(se(c)),r}function Kn(r,e,t){if(e.length===0)throw new RangeError("budgetGate requires at least one constraint");let n=e.map(f=>f.node),s=[r,...n],o=[],i=!1,a=!1,d=Symbol("budget-gate"),u=new Array(e.length);function c(){return e.every((f,l)=>f.check(u[l]))}function p(f){for(;o.length>0&&c();){let l=o[0];o=o.slice(1),f.emit(l)}o.length===0&&a&&(a=!1,f.down([[F]]))}return ne([],(f,l)=>{for(let m=0;m<e.length;m++)u[m]=e[m].node.cache;let g=[];for(let m=0;m<s.length;m++){let y=s[m];g.push(y.subscribe(w=>{for(let b of w)h(b,m,l)}))}return()=>{for(let m of g)m()}},{...t,describeKind:"derived",meta:ze("budget_gate",t?.meta)});function h(f,l,g){let m=f[0];if(l===0){if(m===M)return c()&&o.length===0?g.emit(f[1]):(o.push(f[1]),i||(i=!0,g.up([[U,d]]))),!0;if(m===P)return g.down([[P]]),!0;if(m===F)return o.length===0?g.down([[F]]):a=!0,!0;if(m===L||m===A){for(let y of o)g.emit(y);return o=[],a=!1,i&&(i=!1,g.up([[J,d]])),g.down([f]),!0}return!1}return m===M&&(u[l-1]=f[1]),m===M||m===F?(c()&&o.length>0?(p(g),o.length===0&&i&&(i=!1,g.up([[J,d]]))):!c()&&!i&&o.length>0&&(i=!0,g.up([[U,d]])),!0):m===P?!0:m===A?(g.down([f]),!0):m===L}}function Wn(r,e,t){if(r.length===0)throw new RangeError("scorer requires at least one source");if(r.length!==e.length)throw new RangeError("scorer requires the same number of sources and weights");let n=[...r,...e],s=r.length,o=t?.scoreFns;return ae(n,i=>{let a=i.slice(0,s),d=i.slice(s),u=[],c=0;for(let p=0;p<s;p++){let h=a[p]??0,f=d[p]??0,g=(o?.[p]?o[p](h):h)*f;u.push(g),c+=g}return{value:a,score:c,breakdown:u}},{...t?{equals:t.equals,resubscribable:t.resubscribable,resetOnTeardown:t.resetOnTeardown}:{},describeKind:"derived",meta:ze("scorer",t?.meta)})}function qn(r){let e=Gt({name:r?.name??"effectiveness-entries"}),t=ae([e.entries],([i])=>new Map(i),{name:`${r?.name??"effectiveness"}-snapshot`,equals:(i,a)=>{let d=i,u=a;if(d.size!==u.size)return!1;for(let[c,p]of d){let h=u.get(c);if(!h||p.attempts!==h.attempts||p.successes!==h.successes)return!1}return!0}});function n(i,a){let d=e.get(i),u=(d?.attempts??0)+1,c=(d?.successes??0)+(a?1:0);e.set(i,{key:i,attempts:u,successes:c,successRate:c/u})}function s(i){return e.get(i)}let o=se(t);return{node:t,record:n,lookup:s,dispose:()=>o()}}0&&(module.exports={budgetGate,effectivenessTracker,feedback,funnel,scorer});
@@ -0,0 +1,5 @@
1
+ import '../../node-Cc1TniY8.cjs';
2
+ import '../../graph-D48Qw9Cg.cjs';
3
+ export { B as BudgetConstraint, a as BudgetGateOptions, E as EffectivenessEntry, b as EffectivenessSnapshot, c as EffectivenessTrackerBundle, d as EffectivenessTrackerOptions, F as FeedbackOptions, e as FunnelOptions, f as FunnelStage, S as ScoredItem, g as ScorerOptions, h as StepRef, j as budgetGate, k as effectivenessTracker, l as feedback, m as funnel, s as scorer } from '../../index-rHJSKsU8.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 { B as BudgetConstraint, a as BudgetGateOptions, E as EffectivenessEntry, b as EffectivenessSnapshot, c as EffectivenessTrackerBundle, d as EffectivenessTrackerOptions, F as FeedbackOptions, e as FunnelOptions, f as FunnelStage, S as ScoredItem, g as ScorerOptions, h as StepRef, j as budgetGate, k as effectivenessTracker, l as feedback, m as funnel, s as scorer } from '../../index-DpHe5e0Q.js';
4
+ import '../../meta-CwesDrMD.js';
5
+ import '../../extra/storage-core.js';
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"../../chunk-ERLIRFPA.js";import"../../chunk-ETWTCCJI.js";import"../../chunk-CKCSDI7T.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-VPYBOXVT.js";import"../../chunk-Z4HDAS2Q.js";import"../../chunk-4VVTGLXJ.js";import"../../chunk-OAWLCNJJ.js";import"../../chunk-2PMCKKRK.js";import"../../chunk-ZB5EHBIO.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{c as budgetGate,e as effectivenessTracker,b as feedback,a as funnel,d as scorer};
@@ -0,0 +1,8 @@
1
+ "use strict";var ct=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var On=Object.getOwnPropertyNames;var En=Object.prototype.hasOwnProperty;var Q=(r,e)=>()=>(r&&(e=r(r=0)),e);var kn=(r,e)=>{for(var t in e)ct(r,t,{get:e[t],enumerable:!0})},Sn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of On(e))!En.call(r,o)&&o!==t&&ct(r,o,{get:()=>e[o],enumerable:!(n=xn(e,o))||n.enumerable});return r};var Dn=r=>Sn(ct({},"__esModule",{value:!0}),r);function Be(){return Se>0||Ge}function Rt(){return Se>0}function Pe(r){Se>0?Ie.push(r):r()}function ie(r){Se+=1;let e=!1;try{r()}catch(t){throw e=!0,t}finally{if(Se-=1,Se===0)if(e){if(!Ge){let t=Ie.splice(0);for(let n of t)try{n()}catch{}ye.length=0,ve.length=0,De.length=0}}else Rn()}}function Rn(){let r=!Ge;r&&(Ge=!0);let e=[],t=0;try{for(;ye.length>0||ve.length>0||De.length>0||r&&Ie.length>0;){if(r&&Ie.length>0){let s=Ie.splice(0);for(let i of s)try{i()}catch(a){e.push(a)}continue}if(t+=1,t>1e3)throw ye.length=0,ve.length=0,De.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(ye.length>0?ye:ve.length>0?ve:De).splice(0);for(let s of o)try{s()}catch(i){e.push(i)}}}finally{r&&(Ge=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function je(r,e,t){if(e.length===0)return;if(e.length===1){let u=t(e[0][0]);if(u<3||!Be()){r(e);return}(u>=5?De:u===4?ve:ye).push(()=>r(e));return}let n=e.length,o=n,s=n,i=n,a=0;for(;a<n&&t(e[a][0])<3;)a++;for(o=a;a<n&&t(e[a][0])===3;)a++;for(s=a;a<n&&t(e[a][0])===4;)a++;i=a;let d=Be();if(o>0){let u=e.slice(0,o);r(u)}if(s>o){let u=e.slice(o,s);d?ye.push(()=>r(u)):r(u)}if(i>s){let u=e.slice(s,i);d?ve.push(()=>r(u)):r(u)}if(n>i){let u=e.slice(i,n);d?De.push(()=>r(u)):r(u)}}var Se,Ge,ye,ve,De,Ie,$e=Q(()=>{"use strict";Se=0,Ge=!1,ye=[],ve=[],De=[],Ie=[]});function ee(){return Math.trunc(performance.now()*1e6)}function He(){return Date.now()*1e6}var Ue=Q(()=>{"use strict"});var fe,$,q,W,te,se,ae,K,L,G,Te,We,At,qe,Ct,Mt,Ke,lt,ft,pt,Ye,oe=Q(()=>{"use strict";fe=Symbol.for("graphrefly/START"),$=Symbol.for("graphrefly/DATA"),q=Symbol.for("graphrefly/DIRTY"),W=Symbol.for("graphrefly/RESOLVED"),te=Symbol.for("graphrefly/INVALIDATE"),se=Symbol.for("graphrefly/PAUSE"),ae=Symbol.for("graphrefly/RESUME"),K=Symbol.for("graphrefly/TEARDOWN"),L=Symbol.for("graphrefly/COMPLETE"),G=Symbol.for("graphrefly/ERROR"),Te=Object.freeze([q]),We=Object.freeze([W]),At=Object.freeze([te]),qe=Object.freeze([fe]),Ct=Object.freeze([L]),Mt=Object.freeze([K]),Ke=Object.freeze([Te]),lt=Object.freeze([We]),ft=Object.freeze([At]),pt=Object.freeze([Ct]),Ye=Object.freeze([Mt])});function It(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 o=2+t.length+2+e.length;if(o>4294967295)throw new Error(`encodeEnvelope: total envelope size ${o} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let s=new Uint8Array(o),i=0;return s[i++]=ht,s[i++]=t.length,s.set(t,i),i+=t.length,s[i++]=n>>>8&255,s[i++]=n&255,s.set(e,i),s}function Pt(r,e){if(r.length<Gt)throw new Error(`decodeEnvelope: bytes too short (${r.length} < ${Gt})`);let t=0,n=r[t++];if(n!==ht)throw new Error(`decodeEnvelope: unsupported envelope version ${n} (expected ${ht})`);let o=r[t++];if(o===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+o+2>r.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+o+2} bytes, have ${r.length})`);let s=new TextDecoder().decode(r.subarray(t,t+o));t+=o;let i=(r[t]<<8|r[t+1])>>>0;t+=2;let a=r.subarray(t),d=e.lookupCodec(s);if(d==null)throw new Error(`decodeEnvelope: codec "${s}" not registered (envelope codec_v=${i})`);return{codec:d,codecVersion:i,payload:a}}function $t(r){r.registerCodec(An)}var An,ht,Gt,mt=Q(()=>{"use strict";An={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)}},ht=1,Gt=4});function Je(r){if(r==null)return Re;let{type:e,id:t,...n}=r;return{type:e??"system",id:t??"",...n}}var Re,Ze=Q(()=>{"use strict";Re={type:"system",id:""}});function Ft(r){r.registerMessageType(fe,{tier:0,wireCrossing:!1}),r.registerMessageType(q,{tier:1,wireCrossing:!1}),r.registerMessageType(te,{tier:1,wireCrossing:!1,metaPassthrough:!1}),r.registerMessageType(se,{tier:2,wireCrossing:!1}),r.registerMessageType(ae,{tier:2,wireCrossing:!1}),r.registerMessageType($,{tier:3,wireCrossing:!0}),r.registerMessageType(W,{tier:3,wireCrossing:!0}),r.registerMessageType(L,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(G,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(K,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Xe,Lt=Q(()=>{"use strict";oe();Xe=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 gt(r){let e=Cn.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 ne,Cn,Fe=Q(()=>{"use strict";ne=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}},Cn=["human","llm","wallet","system"]});function bt(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(bt);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=bt(r[t]);return e}return null}function In(r){let e=Gn.encode(r),t=e.length,n=t*8,o=t+9+63&-64,s=new Uint8Array(o);s.set(e),s[t]=128;let i=new DataView(s.buffer);i.setUint32(o-4,n>>>0,!1),i.setUint32(o-8,Math.floor(n/4294967296)>>>0,!1);let a=1779033703,d=3144134277,u=1013904242,l=2773480762,p=1359893119,h=2600822924,f=528734635,c=1541459225,m=new Uint32Array(64),b=(T,g)=>T>>>g|T<<32-g;for(let T=0;T<o;T+=64){for(let D=0;D<16;D++)m[D]=i.getUint32(T+D*4,!1);for(let D=16;D<64;D++){let C=m[D-15],R=m[D-2],U=b(C,7)^b(C,18)^C>>>3,Y=b(R,17)^b(R,19)^R>>>10;m[D]=m[D-16]+U+m[D-7]+Y>>>0}let g=a,v=d,N=u,_=l,w=p,k=h,A=f,V=c;for(let D=0;D<64;D++){let C=b(w,6)^b(w,11)^b(w,25),R=w&k^~w&A,U=V+C+R+Mn[D]+m[D]>>>0,Y=b(g,2)^b(g,13)^b(g,22),J=g&v^g&N^v&N,de=Y+J>>>0;V=A,A=k,k=w,w=_+U>>>0,_=N,N=v,v=g,g=U+de>>>0}a=a+g>>>0,d=d+v>>>0,u=u+N>>>0,l=l+_>>>0,p=p+w>>>0,h=h+k>>>0,f=f+A>>>0,c=c+V>>>0}let y=T=>T.toString(16).padStart(8,"0");return y(a)+y(d)+y(u)+y(l)+y(p)+y(h)+y(f)+y(c)}function yt(r){let e=bt(r??null),t=JSON.stringify(e);return In(t).slice(0,16)}function Pn(){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 vt(r,e,t){let n=t?.id??Pn();if(r===0)return{id:n,version:0};let s=(t?.hash??yt)(e);return{id:n,version:0,cid:s,prev:null}}function Vt(r,e,t){r.version+=1,"cid"in r&&(r.prev=r.cid,r.cid=t(e))}var Mn,Gn,zt=Q(()=>{"use strict";Mn=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]),Gn=new TextEncoder});function Ht(r){return{node:r,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function Tt(r){r.prevData=void 0,r.dirty=!1,r.involvedThisWave=!1,r.dataBatch.length=0,r.terminal=void 0}function Qe(r){return r.length===0?r:typeof r[0]=="symbol"?[r]:r}function ue(r,e,t){let n=Ut(r)?r:[],o=typeof r=="function"?r:typeof e=="function"?e:void 0,s={};return Ut(r)?s=(_t(e)?e:t)??{}:_t(r)?s=r:s=(_t(e)?e:t)??{},new B(n,o,s)}var Bt,jt,$n,Fn,Ae,B,Ut,_t,_e=Q(()=>{"use strict";mt();Ze();$e();Ue();Lt();Fe();oe();zt();Bt=()=>{},jt=100;$n=(r,e,t,n)=>{t.direction==="down-in"&&r._onDepMessage(t.depIndex,e)},Fn=(r,e,t,n)=>{let o=r;if(o._status==="completed"||o._status==="errored")return;let s=o._cached,i=s===void 0?[qe]:[qe,[$,s]];o._status==="dirty"&&i.push(Te),je(e,i,o._config.tierOf)},Ae=new Xe({onMessage:$n,onSubscribe:Fn});Ft(Ae);$t(Ae);B=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??Ae,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??yt;let o=n.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?vt(o,this._cached===void 0?void 0:this._cached,{id:n.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ht);let s={};for(let[a,d]of Object.entries(n.meta??{})){let u={initial:d,name:`${n.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};n.guard!=null&&(u.guard=n.guard),s[a]=new r([],void 0,u)}Object.freeze(s),this.meta=s,this._hasMeta=Object.keys(s).length>0;let i=this;this._actions={emit(a){i._emit([[$,a]])},down(a){i._emit(Qe(a))},up(a){i._emitUp(Qe(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 o=t?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let s=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??t?.id,d=i?.version??0,u=vt(e,s,{id:a,hash:o});u.version=d,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=Je(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 o=Je(e?.actor),s=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,s))throw new ne({actor:o,action:s,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(o,s))throw new ne({actor:o,action:s,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:He()}}down(e,t){let n=Qe(e);n.length!==0&&(this._checkGuard(t),this._emit(n))}emit(e,t){this._checkGuard(t),this._emit([[$,e]])}up(e,t){if(this._deps.length===0)return;let n=Qe(e);if(n.length===0)return;this._checkGuard(t);let o=t??{internal:!0};this._validateUpTiers(n);for(let s of this._deps)s.node.up?.(n,o)}_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 o=t(n[0]);if(o===3||o===4)throw new Error(`Node "${this.name}": tier-${o} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let d=Je(t);if(!this._guard(d,"observe"))throw new ne({actor:d,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)Tt(d)}this._sinkCount+=1;let s;try{s=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:o},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof s=="function")try{s()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof s=="function"&&s(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[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 o=n,s=this._deps[n];s.unsub=Bt,s.unsub=s.node.subscribe(i=>{if(s.unsub===null)return;let a=this._config.tierOf,d=!1;for(let u of i)a(u[0])>=3&&(d=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:o},this._actions);d&&this._maybeRunFnOnSettlement()}),t++}}catch(n){this._deps[t].unsub=null;for(let o=0;o<t;o++){let s=this._deps[o];if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}Tt(s)}}throw this._dirtyDepCount=0,n}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let t=this._deps.length,n=Ht(e);if(this._deps.push(n),this._sinks==null)return t;n.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Ke),n.unsub=Bt;try{n.unsub=e.subscribe(o=>{if(n.unsub===null)return;let s=this._config.tierOf,i=!1;for(let a of o)s(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(o){throw n.unsub=null,this._deps.pop(),this._dirtyDepCount--,o}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(n){this._emit([[G,this._wrapFnError("cleanup threw",n)]])}else if(t!=null&&typeof t=="object"){let n=t.deactivate;if(typeof n=="function")try{n()}catch(o){this._emit([[G,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let n of this._deps){if(n.unsub!=null){let o=n.unsub;n.unsub=null;try{o()}catch{}}Tt(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],o=t[0];if(this._inspectorHooks!=null){let s={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(s)}if(o!==fe){if(o===q){this._depDirtied(n);return}if(o===te){this._depInvalidated(n),this._emit(ft);return}if(o===se||o===ae){this._emit([t]);return}if(o===K){this._emit(Ye);return}if(o===$)this._depSettledAsData(n,t[1]);else if(o===W)this._depSettledAsResolved(n);else if(o===L)this._depSettledAsTerminal(n,!0);else if(o===G)this._depSettledAsTerminal(n,t[1]);else{this._emit([t]);return}if(!this._fn){(o===$||o===W)&&this._emit([t]),(o===L||o===G)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Ke))}_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(lt),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([[G,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(pt)}_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([[G,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([[G,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 o=this._deps.map(i=>i.terminal),s={prevData:n,terminalDeps:o,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,s);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[G,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>jt?(this._rerunDepth=0,this._emit([[G,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${jt} \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"?[Te,e[0]]:e;let n=!0,o=!1,s=!1,i=-1;for(let d of e){let u=t(d[0]);u<i&&(n=!1),u===3&&(o=!0),d[0]===q&&(s=!0),i=u}let a=e;if(!n){let d=e.map((u,l)=>({m:u,i:l,tier:t(u[0])}));d.sort((u,l)=>u.tier-l.tier||u.i-l.i),a=d.map(u=>u.m)}if(o&&!s&&this._status!=="dirty"){let d=0;for(;d<a.length&&t(a[d][0])===0;)d++;return d===0?[Te,...a]:[...a.slice(0,d),Te,...a.slice(d)]}return a}_emit(e){if(e.length===0)return;let t=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(d=>d[0]===K||d[0]===te);if(a.length===0)return;t=a}t=this._frameBatch(t);let o=null;for(let a=0;a<t.length;a++){let d=t[a],u=d[0];if(u!==se&&u!==ae){o?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===se?"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 p=d[1];if(u===se)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))l=!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())}}l?o?.push(d):o==null&&(o=t.slice(0,a))}if(o!=null){if(o.length===0)return;t=o}if(this._hasMeta&&t.some(a=>a[0]===K))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(Ye)}catch{}let{finalMessages:s,equalsError:i}=this._updateState(t);if(s.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:s})}catch{}}if(s.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,d=[];for(let u of s){let l=a(u[0]);l<3||l===5?d.push(u):this._pauseBuffer.push(u)}d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(s);i!=null&&this._emit([[G,i]])}_updateState(e){let t=this._config.tierOf,n,o,s=-1,i=0;for(let l of e)t(l[0])===3&&i++;let a=i<=1,d=-1;if(this._versioning!=null&&i>1){for(let l=e.length-1;l>=0;l--)if(e[l][0]===$){d=l;break}}for(let l=0;l<e.length;l++){let p=e[l],h=p[0];if(h===$){if(p.length>=2){let f=!1;if(a&&this._cached!==void 0)try{f=this._equals(this._cached,p[1])}catch(c){o=this._wrapFnError("equals threw",c),s=l;break}if(f){n==null&&(n=e.slice(0,l)),n.push(We),this._status="resolved";continue}this._cached=p[1],this._versioning!=null&&(d<0||l===d)&&Vt(this._versioning,p[1],this._hashFn)}this._status="settled",n?.push(p)}else if(n?.push(p),h===q)this._status="dirty";else if(h===W)this._status="resolved";else if(h===L)this._status="completed";else if(h===G)this._status="errored";else if(h===te){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 c=f.invalidate;if(typeof c=="function")try{c()}catch{}}}else h===K&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=s>=0?n??e.slice(0,s):n??e;return o!=null?{finalMessages:u,equalsError:o}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let n of t)n(e)};_dispatchOrAccumulate(e){if(Rt()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Pe(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}je(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);je(this._deliverToSinks,t,this._config.tierOf)}},Ut=r=>Array.isArray(r),_t=r=>typeof r=="object"&&r!=null&&!Array.isArray(r)});function Wt(r,e,t){return t?!1:r.some((n,o)=>!(n!=null&&n.length>0)&&e.prevData[o]===void 0)}function z(r,e){return ue([],{...e,initial:r})}function we(r,e){return ue((n,o,s)=>r(o,s)??void 0,{describeKind:"producer",...e})}function H(r,e,t){let n=t?.partial??!1;return ue(r,(s,i,a)=>{if(Wt(s,a,n)){i.down([[W]]);return}let d=s.map((u,l)=>u!=null&&u.length>0?u.at(-1):a.prevData[l]);i.emit(e(d,a))},{describeKind:"derived",...t})}function Ne(r,e,t){let n=t?.partial??!1;return ue(r,(s,i,a)=>{if(Wt(s,a,n)){i.down([[W]]);return}let d=s.map((u,l)=>u!=null&&u.length>0?u.at(-1):a.prevData[l]);return e(d,i,a)??void 0},{describeKind:"effect",...t})}var Ce=Q(()=>{"use strict";oe();_e()});function wt(r){return{describeKind:"producer",...r}}function qt(r,e){return we(t=>{let n=!1;try{for(let o of r){if(n)return;t.emit(o)}n||t.down([[L]])}catch(o){n||t.down([[G,o]])}return()=>{n=!0}},wt(e))}function Ln(r){return r!=null&&typeof r.then=="function"}function Vn(r,e){let{signal:t,...n}=e??{};return we(o=>{let s=!1,i=()=>{s||(s=!0,o.down([[G,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(r).then(a=>{s||(s=!0,t?.removeEventListener("abort",i),o.emit(a),o.down([[L]]))},a=>{s||(s=!0,t?.removeEventListener("abort",i),o.down([[G,a]]))}),()=>{s=!0,t?.removeEventListener("abort",i)}},wt(n))}function zn(r,e){let{signal:t,...n}=e??{};return we(o=>{let s=new AbortController,i=()=>s.abort(t?.reason);t?.aborted?s.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let a=t??s.signal,d=!1,u=r[Symbol.asyncIterator](),l=()=>{d||a.aborted||Promise.resolve(u.next()).then(p=>{if(!(d||a.aborted)){if(p.done){o.down([[L]]);return}o.emit(p.value),l()}},p=>{!d&&!a.aborted&&o.down([[G,p]])})};return l(),()=>{d=!0,t?.removeEventListener("abort",i),s.abort(),Promise.resolve(u.return?.()).catch(()=>{})}},wt(n))}function Bn(r){return r!=null&&typeof r=="object"&&"cache"in r&&typeof r.subscribe=="function"}function Kt(r,e){if(Bn(r))return r;if(Ln(r))return Vn(r,e);if(r!=null){let t=r;if(typeof t[Symbol.asyncIterator]=="function")return zn(r,e);if(typeof t[Symbol.iterator]=="function")return qt(r,e)}return jn(r)}function jn(...r){return qt(r,void 0)}function xe(r){return r.subscribe(()=>{})}var et=Q(()=>{"use strict";oe();Ce()});var nt,Jt=Q(()=>{"use strict";nt=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 xr={};kn(xr,{blindVariation:()=>Tr,errorCritique:()=>Nr,refineLoop:()=>vr});module.exports=Dn(xr);$e();Ue();oe();_e();Ce();oe();_e();et();function Hn(r){return{describeKind:"derived",...r}}function Un(r,e,t){let n,o=!1,s=()=>{o||(o=!0,t())};return n=r.subscribe(i=>{let a=!1,d=!1;for(let u of i)u[0]!==fe&&(u[0]===$?e.emit(u[1]):u[0]===L?a=!0:u[0]===G?(d=!0,e.down([u])):(u[0]===q||u[0]===W)&&e.down([u]));d?(n?.(),n=void 0,s()):a&&s()}),()=>{n?.(),n=void 0}}function Yt(r,e,t){let n,o=!1;function s(){n?.(),n=void 0}return ue([r],(i,a,d)=>{if(d.terminalDeps[0]!=null&&d.terminalDeps[0]!==!0){s();return}if(d.terminalDeps[0]===!0){o=!0,n||a.down([[L]]);return}let u=i[0];if(!(u==null||u.length===0))return s(),n=Un(Kt(e(u[u.length-1])),a,()=>{s(),o&&a.down([[L]])}),{deactivate:()=>{s(),o=!1}}},{...Hn(t),completeWhenDepsComplete:!1})}Ze();$e();Ue();Fe();oe();Fe();_e();function tt(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 qn(r){let e={};for(let[t,n]of Object.entries(r.meta))try{e[t]=n.cache}catch{}return e}function Nt(r,e){let t=e==null,n=!t&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,o=t||e.has("meta")||n!=null&&n.length>0,s="state",i=[];r instanceof B&&(s=Wn(r),i=r._deps.map(u=>u.node.name??""));let a={type:s,deps:i};(t||e.has("status"))&&(a.status=r.status);let d=r instanceof B?r._guard:void 0;if(o){let u={...qn(r)};if(d!=null&&u.access===void 0&&(u.access=gt(d)),n!=null&&n.length>0&&!e.has("meta")){let l={};for(let p of n)p in u&&(l[p]=u[p]);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"))&&d!=null&&(a.guard=gt(d)),(t||e.has("lastMutation"))&&r.lastMutation!=null&&(a.lastMutation=r.lastMutation),a}_e();Ce();et();Jt();var Le=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}};mt();function Zt(r,e,t,n={}){let o=e in r.nodes,s=t in r.nodes;if(!o)return rt(e,t,"no-such-from");if(!s)return rt(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=Kn(r,e,n);if(u!=null)return u}let d=st(e,r.nodes[e],0,n);return ot(e,t,[d])}if(i===0)return rt(e,t,"no-path");let a=Xt(r,e,t,i);return a.found?ot(e,t,Qt(r,a.pathOrder,n)):rt(e,t,a.truncated?"max-depth-exceeded":"no-path")}function Xt(r,e,t,n){let o=new Map,s=[{path:t,depth:0}],i=new Set([t]),a=0,d=!1;for(;a<s.length;){let p=s[a++];if(p.path===e)break;if(n!=null&&p.depth>=n){let m=r.nodes[p.path];m?.deps&&m.deps.length>0&&(d=!0);continue}let h=r.nodes[p.path];if(h==null)continue;let f=h.deps??[],c=new Map;for(let m=0;m<f.length;m++){let b=f[m];if(!b)continue;let y=c.get(b);y==null&&(y=[],c.set(b,y)),y.push(m)}for(let[m,b]of c)i.has(m)||(i.add(m),o.set(m,{from:p.path,depIndices:b}),s.push({path:m,depth:p.depth+1}))}if(!o.has(e))return{found:!1,pathOrder:[],truncated:d};let u=[{path:e}],l=e;for(;l!==t;){let p=o.get(l);if(p==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=p.depIndices,u.push({path:p.from}),l=p.from}return{found:!0,pathOrder:u,truncated:!1}}function Kn(r,e,t){let n=r.nodes[e];if(n==null)return null;let o=n.deps??[],s=[];for(let a=0;a<o.length;a++)o[a]===e&&s.push(a);if(s.length>0){let a=st(e,n,0,t);a.dep_index=s[0];let d=st(e,n,1,t);return ot(e,e,[a,d])}let i=null;for(let a=0;a<o.length;a++){let d=o[a];if(!d||d===e)continue;let u=Xt(r,d,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:ot(e,e,Qt(r,i.pathOrder,t))}function Qt(r,e,t){return e.map((n,o)=>{let s=r.nodes[n.path],i=st(n.path,s,o,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 st(r,e,t,n){let o={path:r,type:e.type,hop:t};e.status!==void 0&&(o.status=e.status),"value"in e&&(o.value=e.value),e.v!=null&&(o.v=e.v);let s=n.annotations?.get(r)??e.annotation;s!=null&&(o.annotation=s);let i=n.lastMutations?.get(r)??e.lastMutation;return i!=null&&(o.lastMutation=i),o}function ot(r,e,t){return en(r,e,!0,"ok",t)}function rt(r,e,t){return en(r,e,!1,t,[])}function en(r,e,t,n,o){let s=Yn(r,e,t,n,o);return{from:r,to:e,found:t,reason:n,steps:o,text:s,toJSON(){return{from:r,to:e,found:t,reason:n,steps:o}}}}function Yn(r,e,t,n,o){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 s=[`Causal path: ${r} \u2192 ${e} (${o.length} step(s))`];for(let i of o){let d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(s.push(d),"value"in i&&s.push(` value: ${Jn(i.value)}`),i.annotation!=null&&s.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;s.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return s.join(`
2
+ `)}function Jn(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 j={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},Zn=Symbol.for("sizeof");function tn(r){let e=new WeakSet,t=new WeakSet,n=[r],o=0;for(;n.length>0;){let s=n.pop();o+=Xn(s,e,t,n)}return o}function Xn(r,e,t,n){if(r==null)return 0;switch(typeof r){case"number":return j.number;case"boolean":return j.boolean;case"string":return j.string+r.length*2;case"bigint":return j.bigint+Qn(r);case"symbol":return j.symbol;case"function":return e.has(r)?0:(e.add(r),j.function);case"undefined":return 0}let s=r;if(e.has(s))return 0;e.add(s);let i=s[Zn];if(typeof i=="function")try{let u=i.call(s);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(s instanceof Date)return j.date;if(s instanceof RegExp)return j.regexp+s.source.length*2;if(s instanceof Error){let u=s.message?s.message.length*2:0,l=s.stack?s.stack.length*2:0;return j.error+u+l}if(typeof URL<"u"&&s instanceof URL)return j.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return j.promise;if(s instanceof WeakMap)return j.weakmap;if(s instanceof WeakSet)return j.weakset;if(s instanceof Map){let u=j.map;for(let[l,p]of s)u+=j.mapEntry,n.push(l),n.push(p);return u}if(s instanceof Set){let u=j.set;for(let l of s)u+=j.setEntry,n.push(l);return u}if(Array.isArray(s)){let u=j.array+s.length*8;for(let l of s)n.push(l);return u}if(s instanceof ArrayBuffer)return t.has(s)?0:(t.add(s),s.byteLength);if(ArrayBuffer.isView(s)){let u=s;return t.has(u.buffer)?48:(t.add(u.buffer),u.buffer.byteLength+48)}let a=j.object,d=Object.keys(s);for(let u of d){a+=j.string+u.length*2;try{n.push(s[u])}catch{}}return a}function Qn(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 nn(r,e){let t=e?.topN??10,n=r.describe({detail:"standard"}),o=[],s=r._collectObserveTargets;typeof s=="function"&&s.call(r,"",o);let i=new Map;for(let[h,f]of o)i.set(h,f);let a=[];for(let[h,f]of Object.entries(n.nodes)){let c=i.get(h),m=c instanceof B?c:null,b=m?tn(m.cache):0,y=m?m._sinkCount:0,T=f.deps?.length??0,g=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:b,subscriberCount:y,depCount:T,isOrphanEffect:g,orphanKind:v})}let d=a.reduce((h,f)=>h+f.valueSizeBytes,0),u=(h,f)=>[...a].sort(f??((c,m)=>m[h]-c[h])).slice(0,t),l=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:d,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:l,orphanEffects:p}}var F="::",re="__meta__",Oe=1;function rn(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 o=r.values().next();if(o.done)return;let s=o.value;r.delete(s);try{s()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function er(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 sn(r){if(r.version!==Oe)throw new Error(`unsupported snapshot version ${String(r.version)} (expected ${Oe})`);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 tr(r,e){let t=new WeakMap,n=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=t.get(o);if(i==null&&(i=new WeakSet,t.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,d=s.constructor;if(a!==d)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let h=s;if(o.length!==h.length)return!1;for(let f=0;f<o.length;f++)if(!n(o[f],h[f]))return!1;return!0}if(o instanceof Map){let h=s;if(o.size!==h.size)return!1;for(let[f,c]of o)if(!h.has(f)||!n(c,h.get(f)))return!1;return!0}if(o instanceof Set){let h=s;if(o.size!==h.size)return!1;for(let f of o){let c=!1;for(let m of h)if(n(f,m)){c=!0;break}if(!c)return!1}return!0}if(ArrayBuffer.isView(o)){let h=o,f=s;if(h.length!==f.length)return!1;for(let c=0;c<h.length;c++)if(h[c]!==f[c])return!1;return!0}let u=Object.keys(o),l=Object.keys(s);if(u.length!==l.length)return!1;let p=new Set(l);for(let h of u)if(!p.has(h)||!n(o[h],s[h]))return!1;return!0};return n(r,e)}function Ot(r){if(r===null||typeof r!="object")return r;if(Array.isArray(r))return r.map(Ot);let e=r,t=Object.keys(e).sort(),n={};for(let o of t)n[o]=Ot(e[o]);return n}function nr(r){return r.replaceAll("\\","\\\\").replaceAll('"','\\"')}function rr(r){return r.replaceAll("\\","\\\\").replaceAll('"','\\"')}function sr(r){return r==="TD"?"down":r==="BT"?"up":r==="RL"?"left":"right"}function an(r){let e=new Set,t=[];function n(o,s){let i=`${o}\0${s}`;e.has(i)||(e.add(i),t.push([o,s]))}for(let[o,s]of Object.entries(r.nodes)){let i=s.deps;if(i)for(let a of i)n(a,o)}for(let o of r.edges)n(o.from,o.to);return t}function un(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 or(r,e){let t=e.includeEdges??!0,n=e.includeSubgraphs??!0,{expand:o,...s}=r,i={...s,edges:t?r.edges:[],subgraphs:n?r.subgraphs:[]},a=JSON.stringify(Ot(i),null,e.indent??2);return e.logger?.(a),a}function ir(r,e){let t=e.includeEdges??!0,n=e.includeSubgraphs??!0,o=[];o.push(`Graph ${r.name}`),o.push("Nodes:");for(let i of Object.keys(r.nodes).sort()){let a=r.nodes[i];o.push(`- ${i} (${a.type}/${a.status}): ${at(a.value)}`)}if(t){o.push("Edges:");for(let i of r.edges)o.push(`- ${i.from} -> ${i.to}`)}if(n){o.push("Subgraphs:");for(let i of r.subgraphs)o.push(`- ${i}`)}let s=o.join(`
4
+ `);return e.logger?.(s),s}function dn(r,e){let t=un(e.direction),n=Object.keys(r.nodes).sort(),o=new Map;for(let i=0;i<n.length;i+=1)o.set(n[i],`n${i}`);let s=[`flowchart ${t}`];for(let i of n){let a=o.get(i);s.push(` ${a}["${nr(i)}"]`)}for(let[i,a]of an(r)){let d=o.get(i),u=o.get(a);!d||!u||s.push(` ${d} --> ${u}`)}return s.join(`
5
+ `)}function ar(r,e){let t=dn(r,e);return cn(t)}function cn(r,e){let t=e?.theme??"default",n=e?.autoSync??!0,s=JSON.stringify({code:r,mermaid:{theme:t},autoSync:n}),i=new TextEncoder().encode(s),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function ur(r,e){let t=un(e.direction),n=Object.keys(r.nodes).sort(),o=new Map;for(let i=0;i<n.length;i+=1)o.set(n[i],`n${i}`);let s=[`direction: ${sr(t)}`];for(let i of n){let a=o.get(i);s.push(`${a}: "${rr(i)}"`)}for(let[i,a]of an(r)){let d=o.get(i),u=o.get(a);!d||!u||s.push(`${d} -> ${u}`)}return s.join(`
6
+ `)}function dr(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function it(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 o=r.indexOf("]",t+1);if(o<=t+1){e+="\\[";continue}let s=r.slice(t+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,t=o;continue}e+=dr(n)}return e+="$",new RegExp(e)}var cr={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"},lr={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function at(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 fr(r){return r==="none"?lr:r==="ansi"||r==null?cr:{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 on(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 pr(r,e,t){for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);if(o<32||o===127)throw new Error(`Graph "${e}": ${t} "${r}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function xt(r,e,t){if(r==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(r.includes(F))throw new Error(`Graph "${e}": ${t} "${r}" must not contain '${F}' (path separator)`);if(r===re)throw new Error(`Graph "${e}": ${t} name "${re}" is reserved for meta companion paths`);pr(r,e,t)}function hr(r,e){if(r==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=r.split(F);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function mr(r,e){let t=!1;for(let o of r)if(!e.isMetaPassthrough(o[0])){t=!0;break}return t?r.filter(o=>e.isMetaPassthrough(o[0])):r}function ln(r){for(let e of r._mounts.values())ln(e);for(let e of r._nodes.values())try{e.down([[K]],{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(F))throw new Error(`Graph name must not contain '${F}' (got "${e}")`);if(e===re)throw new Error(`Graph name "${re}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??Ae,this._traceRing=new Le(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=we(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,o=t?.name??n;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=t?.annotation;if(xt(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:ee()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof B&&t._applyVersioning(e)}remove(e){xt(e,this.name,"remove");let t=this._mounts.get(e);if(t){let s={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,d]of i)a.includes(`${F}${re}${F}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...t._collectSubgraphs(`${e}${F}`)),this._mounts.delete(e),t._parent=void 0,ln(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}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([[K]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let t=typeof e=="function"?e:(()=>{let s=it(e);return i=>s.test(i)})(),n={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>t(s));for(let s of o){let i=this.remove(s);n.nodes.push(...i.nodes),n.mounts.push(...i.mounts)}return n.nodes.sort(),n.mounts.sort(),n}[Symbol.iterator](){let 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 o=e[n++];return{value:[o,t.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(F))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 o=n?.internal===!0;this.node(e).down([[$,t]],{actor:n?.actor,internal:o,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);ie(()=>{for(let[o,s]of n)this.set(o,s,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[te]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let o=n?.internal===!0;this.node(e).down([[G,t]],{actor:n?.actor,internal:o,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[L]],{actor:t?.actor,internal:n,delivery:"write"})}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[d,u]of this._nodes)n.set(u,d);let a=[];for(let[d,u]of this._nodes)if(u instanceof B)for(let l of u._deps){let p=n.get(l.node);p!=null&&a.push([p,d])}return a.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,d]of o)s.set(d,a);let i=[];for(let[a,d]of o)if(d instanceof B)for(let u of d._deps){let l=s.get(u.node);l!=null&&i.push([l,a])}return i.sort((a,d)=>a[0]<d[0]?-1:a[0]>d[0]?1:a[1]<d[1]?-1:a[1]>d[1]?1:0),i}mount(e,t){if(xt(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=hr(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],o=t.slice(1);if(o.length===0){let a=this._nodes.get(n);if(a)return a;throw this._mounts.has(n)?new Error(`Graph "${this.name}": path ends at subgraph "${n}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${n}"`)}let s=this._nodes.get(n);if(s&&o.length>0&&o[0]===re)return this._resolveMetaChainFromNode(s,o,t.join(F));let i=this._mounts.get(n);if(!i)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${o.join(F)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(o.join(F))}_resolveMetaChainFromNode(e,t,n){let o=e,s=0,i=[...t];for(;s<i.length;){if(i[s]!==re)throw new Error(`Graph "${this.name}": expected ${re} segment in meta path "${n}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${re} in "${n}"`);let a=i[s+1],d=o.meta[a];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${n}"`);o=d,s+=2}return o}signal(e,t){if(t?.internal!==!0){for(let o of e)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let n=[];if(this._signalDeliver(e,t??{},new Set,n),n.length>0)throw n[0]}_signalDeliver(e,t,n,o){for(let d of this._mounts.values())d._signalDeliver(e,t,n,o);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=mr(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!n.has(u)){n.add(u);try{u.down(e,i)}catch(l){if(l instanceof ne)throw l;o.push(l)}a.length!==0&&this._signalMetaSubtree(u,a,n,i,o)}}}_signalMetaSubtree(e,t,n,o,s){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,o)}catch(d){if(d instanceof ne)throw d;s.push(d)}this._signalMetaSubtree(a,t,n,o,s)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let t=e?.actor,n=e?.filter,o=tt(e?.detail,e?.fields),s=e?.format==="spec",i=s?tt("minimal"):o,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[_,w]of a)d.set(w,_);let u=[];{let _=a.map(([,A])=>A),w=new Set(d.values()),k=0;for(;_.length>0;){let A=_.shift();if(A instanceof B)for(let V of A._deps){let D=V.node;if(d.has(D))continue;let C=D.name??"",R=C;if(!R||w.has(R))if(C){let U=2;for(;w.has(`${C}#${U}`);)U++;R=`${C}#${U}`}else for(R=`__internal__/${k++}`;w.has(R);)R=`__internal__/${k++}`;d.set(D,R),w.add(R),u.push([R,D]),_.push(D)}}}let l=[...a,...u],p={};for(let[_,w]of l){if(t!=null&&!w.allowsObserve(t))continue;let k=Nt(w,i),A=w instanceof B?w._deps.map(R=>d.get(R.node)??R.node.name??""):[],{name:V,...D}=k,C={...D,deps:A};if(!s){let R=this._annotations.get(_);R!=null&&(C.annotation=R)}if(n!=null)if(typeof n=="function"){let R=n;if(!(R.length>=2?R(_,C):R(C)))continue}else{let R=!0;for(let[U,Y]of Object.entries(n)){let J=U==="deps_includes"?"depsIncludes":U==="meta_has"?"metaHas":U;if(J==="depsIncludes"){if(!C.deps.includes(String(Y))){R=!1;break}continue}if(J==="metaHas"){if(!Object.hasOwn(C.meta??{},String(Y))){R=!1;break}continue}if(C[J]!==Y){R=!1;break}}if(!R)continue}p[_]=C}let h=new Set(Object.keys(p)),f=[];for(let[_,w]of l)if(w instanceof B)for(let k of w._deps){let A=d.get(k.node);A!=null&&f.push([A,_])}f.sort((_,w)=>_[0]<w[0]?-1:_[0]>w[0]?1:_[1]<w[1]?-1:_[1]>w[1]?1:0);let c=f.map(([_,w])=>({from:_,to:w}));(t!=null||n!=null)&&(c=c.filter(_=>h.has(_.from)&&h.has(_.to)));let m=this._collectSubgraphs(""),b=t!=null||n!=null?m.filter(_=>{let w=`${_}${F}`;return[...h].some(k=>k===_||k.startsWith(w))}):m,y=this,T=e,g={name:this.name,nodes:p,edges:c,subgraphs:b,expand(_){let w={...T,format:void 0};return Array.isArray(_)?(w.fields=_,w.detail=void 0):(w.detail=_,w.fields=void 0),y.describe(w)}},v=e??{},N=v.format;return N==="json"?or(g,v):N==="pretty"?ir(g,v):N==="mermaid"?dn(g,v):N==="mermaid-url"?ar(g,v):N==="d2"?ur(g,v):g}_collectSubgraphs(e){let t=[];for(let n of[...this._mounts.keys()].sort()){let o=e===""?n:`${e}${n}`;t.push(o),t.push(...this._mounts.get(n)._collectSubgraphs(`${o}${F}`))}return t}resourceProfile(e){return nn(this,e)}reachable(e,t,n={}){return n.withDetail===!0?Et(this.describe(),e,t,{...n,withDetail:!0}):Et(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 o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,d]of Object.entries(o.nodes))d.lastMutation!=null&&i.set(a,d.lastMutation);return Zt(o,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",o=0,s=z(o,{name:`${n}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,Pe(()=>{a=!1,!d&&(o+=1,s.emit(o))}))},l=i.onEvent(b=>{let y=b.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||u()}),p=[],h=new WeakSet,f=b=>{if(h.has(b)||d)return;h.add(b);let y=b.topology.subscribe(T=>{for(let g of T){if(g[0]!==$)continue;let v=g[1];if(u(),v.kind==="added"&&v.nodeKind==="mount"){let N=b._mounts.get(v.name);N!=null&&f(N)}}});p.push(y);for(let T of b._mounts.keys()){let g=b._mounts.get(T);g!=null&&f(g)}};f(this);let c;try{c=H([s],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,y)=>b===y})}catch(b){l();for(let y of p)y();throw i.dispose(),b}let m=xe(c);return{node:c,dispose(){d=!0,l();for(let b of p)b();p.length=0,i.dispose(),m()}}}_explainReactive(e,t,n){let o=0,s=z(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(f=>{let c=f.type;c!=="data"&&c!=="error"&&c!=="complete"&&c!=="teardown"||a||d||(a=!0,Pe(()=>{a=!1,!d&&(o+=1,s.emit(o))}))}),l={...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{}},p;try{p=H([s],()=>this._explainStatic(e,t,l),{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:t},equals:(f,c)=>f.found===c.found&&f.reason===c.reason&&f.steps.length===c.steps.length&&gr(f.steps,c.steps)})}catch(f){throw u(),i.dispose(),f}let h=xe(p);return{node:p,dispose(){d=!0,u(),i.dispose(),h()}}}_pathsMatching(e){let t=it(e),n=[];return this._collectObserveTargets("",n),n.map(([o])=>o).filter(o=>t.test(o))}_collectObserveTargets(e,t){for(let n of[...this._mounts.keys()].sort()){let o=e===""?n:`${e}${F}${n}`;this._mounts.get(n)._collectObserveTargets(o,t)}for(let n of[...this._nodes.keys()].sort()){let o=this._nodes.get(n),s=e===""?n:`${e}${F}${n}`;t.push([s,o]),this._appendMetaObserveTargets(s,o,t)}}_appendMetaObserveTargets(e,t,n){for(let o of Object.keys(t.meta).sort()){let s=t.meta[o],i=`${e}${F}${re}${F}${o}`;n.push([i,s]),this._appendMetaObserveTargets(i,s,n)}}observe(e,t){let n=typeof e=="string",s=on(n?t:e),i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(n){let l=e,p=this.resolve(l);if(a!=null&&!p.allowsObserve(a))throw new ne({actor:a,action:"observe",nodeName:l});return i?this._buildStructuredObserver([[l,p]],s,"one"):{subscribe(h){return p.subscribe(h)},up(h){try{p.up?.(h)}catch(f){if(f instanceof ne)return;throw f}}}}let d=[];this._collectObserveTargets("",d),d.sort((l,p)=>l[0]<p[0]?-1:l[0]>p[0]?1:0);let u=a==null?d:d.filter(([,l])=>l.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:l=>{let p=u.map(([h,f])=>f.subscribe(c=>{l(h,c)}));return()=>{for(let h of p)h()}},up:(l,p)=>{try{this.resolve(l).up?.(p)}catch(h){if(h instanceof ne)return;throw h}}}}_buildStructuredObserver(e,t,n){let o=n==="one"?e[0]?.[0]:void 0,s=i=>{if(n==="one"&&o!=null){let l=this.resolve(o);return this._buildStructuredObserver([[o,l]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((l,p)=>l[0]<p[0]?-1:l[0]>p[0]?1:0);let d=i.actor,u=d==null?a:a.filter(([,l])=>l.allowsObserve(d));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,t,s)}_createObserveResult(e,t,n){let o=t.timeline===!0,s=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",d=this.config.inspectorEnabled,u=(s||i)&&d,l=t.maxEvents,p=l!=null&&l>0?new Le(l):null,h=[],f=new Set,c={},m=new Set,b=0,y=0,T=0,g=0,v=0,N=0,_=!1,w=!1,k=0,A=new Map,V=new Map,D=new Map,C=x=>{p?p.push(x):h.push(x);for(let P of f)P(x)},R=()=>o?{timestamp_ns:ee(),in_batch:Be(),batch_id:k}:{},U=(x,P)=>{if(!(!u||!(x instanceof B)))return x._setInspectorHook(O=>{if(O.kind==="dep_message")A.set(x,O.depIndex);else if(O.kind==="run"){let S=O.batchData.map((E,I)=>E!=null&&E.length>0?E.at(-1):O.prevData[I]);V.set(x,S);let M=O.batchData.map(E=>E!=null?[...E]:void 0);D.set(x,M),i&&C({type:"derived",path:P,dep_values:S,dep_batches:M,...R()})}})},Y=x=>{let P=A.get(x),O=V.get(x);if(!s||O==null)return{};let M=(P!=null&&P>=0&&x instanceof B?x._deps[P]:void 0)?.node,E=M?.v,I=D.get(x);return{trigger_dep_index:P,trigger_dep_name:M?.name,...E!=null?{trigger_version:{id:E.id,version:E.version}}:{},dep_values:[...O],...I!=null?{dep_batches:I}:{}}},J=[],de=[];for(let[x,P]of e){let O=U(P,x);O&&J.push(O),de.push(P.subscribe(S=>{k++;for(let M of S){let E=M[0],I=R();if(E===$){c[x]=M[1];let Z=P instanceof B?P.lastMutation?.actor??Re:Re;C({type:"data",path:x,data:M[1],actor:Z,...I,...Y(P)})}else if(a)E===q?b++:E===W?y++:E===te?T++:E===se?g++:E===ae?v++:E===K?N++:E===L&&!m.has(x)?_=!0:E===G&&(w=!0,m.add(x));else if(E===q)b++,C({type:"dirty",path:x,...I});else if(E===W)y++,C({type:"resolved",path:x,...I,...Y(P)});else if(E===te)T++,C({type:"invalidate",path:x,...I});else if(E===se)g++,C({type:"pause",path:x,lockId:M[1],...I});else if(E===ae)v++,C({type:"resume",path:x,lockId:M[1],...I});else if(E===L)m.has(x)||(_=!0),C({type:"complete",path:x,...I});else if(E===G){w=!0,m.add(x);let Z=P instanceof B?P.lastMutation?.actor??Re:Re;C({type:"error",path:x,data:M[1],actor:Z,...I})}else E===K&&(N++,C({type:"teardown",path:x,...I}))}}))}let he=!1,me=()=>{if(!he){he=!0;for(let x of de)x();for(let x of J)x();for(let x of ge)x({value:void 0,done:!0});ge.length=0}},Ee=[],ge=[];f.add(x=>{let P=ge.shift();P?P({value:x,done:!1}):Ee.push(x)});let Me={get values(){return c},get dirtyCount(){return b},get resolvedCount(){return y},get invalidateCount(){return T},get pauseCount(){return g},get resumeCount(){return v},get teardownCount(){return N},get events(){return p?p.toArray():[...h]},get anyCompletedCleanly(){return _},get anyErrored(){return w},get completedWithoutErrors(){return _&&!w},onEvent(x){return f.add(x),()=>f.delete(x)},dispose:me,expand(x){me();let P={...t};return typeof x=="string"?P.detail=x:Object.assign(P,x),n(on(P))},[Symbol.asyncIterator](){return{next(){return Ee.length>0?Promise.resolve({value:Ee.shift(),done:!1}):he?Promise.resolve({value:void 0,done:!0}):new Promise(x=>ge.push(x))},return(){return me(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Me,t),Me}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let o=t.logger??(c=>console.log(c)),s=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=s==null&&i==null?()=>!0:c=>(s==null||s.has(c))&&(i==null||!i.has(c)),d=fr(t.theme),u=n==="stage-log"?ee():0,l=c=>c==null?"":t.stageLabels?.[c]??c,p=(c,m)=>c.length>m?`${c.slice(0,m-1)}\u2026`:c,h=c=>c.type==="data"||c.type==="error"?p(at(c.data),120):"",f=c=>{if(n==="stage-log"){let w=(ee()-u)/1e9,k=l(c.path).padEnd(9);if(c.type==="data"){let A=h(c);return`[${w.toFixed(3)}s] ${k} \u2190${A?` ${A}`:""}`}if(c.type==="error"){let A=h(c);return`[${w.toFixed(3)}s] ${k} \u2717${A?` ${A}`:""}`}return c.type==="complete"?`[${w.toFixed(3)}s] ${k} \u25A0 complete`:`[${w.toFixed(3)}s] ${k} ${c.type}`}if(n==="json")try{return JSON.stringify(c)}catch{return JSON.stringify({type:c.type,path:c.path,data:"[unserializable]"})}let m=d[c.type]??"",b=c.path?`${d.path}${c.path}${d.reset} `:"",y=c.type==="data"||c.type==="error",T=c.type==="pause"||c.type==="resume",g=y?` ${at(c.data)}`:T?` ${at(c.lockId)}`:"",v=c.type==="data"||c.type==="resolved"||c.type==="derived"?c:void 0,N=v?.trigger_dep_name!=null?` <- ${v.trigger_dep_name}`:v?.trigger_dep_index!=null?` <- #${v.trigger_dep_index}`:"",_=c.in_batch?" [batch]":"";return`${b}${m}${c.type.toUpperCase()}${d.reset}${g}${N}${_}`};e.onEvent(c=>{a(c.type)&&o(f(c),c)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){rn(this._disposers,this.name),this.signal([[K]],{internal:!0}),rn(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"}),o={};for(let a of Object.keys(n.nodes).sort()){let{lastMutation:d,guard:u,...l}=n.nodes[a];o[a]=l}let s=[...n.subgraphs].sort(),i={...n,version:1,nodes:o,subgraphs:s};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return It(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??Ae,{codec:o,codecVersion:s,payload:i}=Pt(e,n);return o.decode(i,s)}restore(e,t){if(sn(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(s=>it(s)),o=t?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let d=this.tryResolve(s)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){t?.onError?.(s,a)}}}}}static fromSnapshot(e,t){sn(e);let n=typeof t=="function"?t:t?.build,o=typeof t=="function"?void 0:t?.factories,s=new r(e.name);if(n)return n(s),s.restore(e),s;for(let f of[...e.subgraphs].sort((c,m)=>{let b=c.split(F).length,y=m.split(F).length;return b!==y?b-y:c<m?-1:c>m?1:0})){let c=f.split(F),m=s;for(let b of c)m._mounts.has(b)||m.mount(b,new r(b)),m=m._mounts.get(b)}let i=o?Object.entries(o).map(([f,c])=>({re:it(f),factory:c})):[],a=f=>{for(let c of i)if(c.re.test(f))return c.factory},d=f=>{let c=f.split(F),m=c.pop();if(m==null||m.length===0)throw new Error(`invalid snapshot path "${f}"`);let b=s;for(let y of c){let T=b._mounts.get(y);if(!T)throw new Error(`unknown mount "${y}" in path "${f}"`);b=T}return[b,m]},u=Object.entries(e.nodes).filter(([f])=>!f.includes(`${F}${re}${F}`)).sort((f,c)=>f[0]<c[0]?-1:f[0]>c[0]?1:0),l=new Map(u),p=new Map,h=!0;for(;l.size>0&&h;){h=!1;for(let[f,c]of[...l.entries()]){let m=c?.deps??[];if(!m.every(N=>p.has(N)))continue;let[b,y]=d(f),T={...c?.meta??{}},g=a(f),v;if(c?.type==="state")v=z(c.value,{meta:T});else{if(g==null)continue;v=g(y,{path:f,type:c.type,value:c.value,meta:T,deps:m,resolvedDeps:m.map(N=>p.get(N))})}b.add(v,{name:y}),p.set(f,v),l.delete(f),h=!0}}if(l.size>0){let f=[...l.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${f}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}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 o=(u,l)=>{if(u.disposed)return;let p=er(l.nodes);if(u.lastSnapshot!=null&&p!==""&&p===u.lastFingerprint)return;let h=u.seq+1,f=He(),b=u.lastSnapshot==null||h%u.compactEvery===0?{mode:"full",snapshot:l,seq:h,timestamp_ns:f,format_version:Oe}:{mode:"diff",diff:fn(u.lastSnapshot,l),seq:h,timestamp_ns:f,format_version:Oe};if(u.tier.filter&&!u.tier.filter(this.name,b))return;let y;try{y=u.tier.save(this.name,b)}catch(T){t.onError?.(T,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=l,u.lastFingerprint=p)},N=>{t.onError?.(N,u.tier)});u.savePending=v.finally(()=>{u.savePending===v&&(u.savePending=void 0)})}else u.seq=h,u.lastSnapshot=l,u.lastFingerprint=p},s=(u,l)=>{try{o(u,l)}catch(p){t.onError?.(p,u.tier)}},i=(u,l)=>{if(!l.some(c=>{let m=this.config.messageTier(c[0]);return m>=3&&m<5}))return;if(t.filter){let c=this.tryResolve(u);if(c==null)return;let m=Nt(c,tt("standard"));if(!t.filter(u,m))return}let h,f=()=>(h==null&&(h=this.snapshot()),h);for(let c of n)c.disposed||(c.debounceMs===0?s(c,f()):(c.timer==null&&(c.timer=new nt),c.timer.start(c.debounceMs,()=>{c.disposed||s(c,this.snapshot())})))},a;if(t.paths!=null){let l=(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 l)p()}}else a=this.observe().subscribe((u,l)=>i(u,l));let d=()=>{a();for(let u of n)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,t){for(let n of e){let o;try{o=await n.load(this.name)}catch(i){t?.(i,n);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===Oe&&s.nodes!=null)return this.restore(s),!0}catch(i){t?.(i,n)}}return!1}static async fromStorage(e,t,n){for(let o of t){let s;try{s=await o.load(e)}catch(d){n?.onError?.(d,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===Oe&&i.nodes!=null?i:void 0;if(a!=null)try{return r.fromSnapshot(a,n)}catch(d){n?.onError?.(d,o)}}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 o={path:e,annotation:t,timestamp_ns:ee(),...n?.actor!=null?{actor:n.actor}:{}};this._traceRing.push(o)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(o=>!e(o)),n=this._traceRing.size-t.length;this._traceRing.clear();for(let o of t)this._traceRing.push(o);return n}static diff(e,t){let n=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(t.nodes)),s=[...o].filter(T=>!n.has(T)).sort(),i=[...n].filter(T=>!o.has(T)).sort(),a=[],d=[];for(let T of n){if(!o.has(T))continue;let g=e.nodes[T],v=t.nodes[T],N=g.v,_=v.v;N!=null&&_!=null&&N.id===_.id&&N.version!==_.version&&d.push({path:T,id:N.id,from:N.version,to:_.version});let w=N!=null&&_!=null&&N.id===_.id&&N.version===_.version;for(let k of["type","status","sentinel"]){let A=g[k],V=v[k];A!==V&&a.push({path:T,field:k,from:A,to:V})}if(!w)for(let k of["value","meta"]){let A=g[k],V=v[k];tr(A,V)||a.push({path:T,field:k,from:A,to:V})}}let u=T=>`${T.from} ${T.to}`,l=new Set(e.edges.map(u)),p=new Set(t.edges.map(u)),h=t.edges.filter(T=>!l.has(u(T))),f=e.edges.filter(T=>!p.has(u(T))),c=new Set(e.subgraphs),m=new Set(t.subgraphs),b=[...m].filter(T=>!c.has(T)).sort(),y=[...c].filter(T=>!m.has(T)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:h,edgesRemoved:f,subgraphsAdded:b,subgraphsRemoved:y}}};function fn(r,e){let t=pe.diff(r,e),n={};for(let o of t.nodesAdded){let s=e.nodes[o];s!=null&&(n[o]=s)}return{...t,nodesAddedFull:n}}function Et(r,e,t,n={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return n.withDetail?o:[];if(!n.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=n.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return n.withDetail?o:[];let i=new Map,a=new Map,d=new Map,u=new Map,l=new Set;for(let[g,v]of Object.entries(r.nodes)){if(!g)continue;l.add(g);let N=v.deps??[];i.set(g,N);for(let _ of N)_&&(l.add(_),a.has(_)||a.set(_,new Set),a.get(_).add(g))}for(let g of r.edges){if(g==null||typeof g!="object")continue;let v=typeof g.from=="string"?g.from:"",N=typeof g.to=="string"?g.to:"";!v||!N||(l.add(v),l.add(N),u.has(v)||u.set(v,new Set),u.get(v).add(N),d.has(N)||d.set(N,new Set),d.get(N).add(v))}if(!l.has(e))return n.withDetail?o:[];let p=n.both===!0,h=g=>{if(p){let w=i.get(g)??[],k=d.get(g),A=a.get(g),V=u.get(g),D=[...w];return k&&D.push(...k),A&&D.push(...A),V&&D.push(...V),D}if(t==="upstream"){let w=i.get(g)??[],k=d.get(g);return k?[...w,...k]:w}let v=a.get(g),N=u.get(g),_=v?[...v]:[];return N&&_.push(...N),_},f=new Set([e]),c=new Map,m=[{path:e,depth:0}],b=0,y=!1;for(;b<m.length;){let g=m[b++];if(s!=null&&g.depth>=s){h(g.path).length>0&&(y=!0);continue}for(let v of h(g.path))!v||f.has(v)||(f.add(v),c.set(v,g.depth+1),m.push({path:v,depth:g.depth+1}))}let T=[...c.keys()].sort((g,v)=>g<v?-1:g>v?1:0);return n.withDetail?{paths:T,depths:c,truncated:y}:T}function gr(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++){let n=r[t],o=e[t];if(n.path!==o.path||n.type!==o.type||n.status!==o.status||n.hop!==o.hop||n.dep_index!==o.dep_index||n.annotation!==o.annotation||n.value!==o.value||n.lastMutation!==o.lastMutation)return!1;let s=n.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}Ze();Fe();oe();Ce();$e();oe();Ce();var kt=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),o=e.length-n;for(let s=0;s<n;s++)this._buf[s]=e[o+s];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),o=Math.min(e,this._size);if(o>=n)return[];let s=n-o;if(this._maxSize===void 0)return this._buf.slice(o,n);let i=new Array(s);for(let a=0;a<s;a++)i[a]=this._buf[(this._head+o+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let 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 pn(r){return r.subscribe(()=>{})}var br=64;function hn(r,e={}){let{name:t,maxSize:n,versioning:o,backend:s}=e,i=s??new kt(r,n),a=z(i.toArray(),{name:t,describeKind:"state",equals:(c,m)=>c===m,...o!=null?{versioning:o}:{}});function d(){let c=i.toArray();ie(()=>{a.down([[q]]),a.down([[$,c]])})}let u=new Map,l=new Map;function p(c,m){return`${c}:${m===void 0?"END":m}`}function h(c){if(c.size<br)return;let m=c.keys().next();if(m.done)return;let b=c.get(m.value);b!==void 0&&b.dispose(),c.delete(m.value)}function f(c){let m=i.version;try{return c()}finally{i.version!==m&&d()}}return{entries:a,get size(){return i.size},at(c){return i.at(c)},append(c){f(()=>i.append(c))},appendMany(c){c.length!==0&&f(()=>i.appendMany(c))},clear(){f(()=>i.clear())},trimHead(c){f(()=>i.trimHead(c))},tail(c){if(!Number.isInteger(c)||c<0)throw new RangeError(`tail: n must be a non-negative integer (got ${c})`);let m=u.get(c);if(m!==void 0)return u.delete(c),u.set(c,m),m.node;h(u);let b=H([a],([T])=>{let g=T;return c===0||g.length===0?[]:g.slice(Math.max(0,g.length-c))},{initial:i.tail(c),describeKind:"derived"}),y=pn(b);return u.set(c,{node:b,dispose:y}),b},slice(c,m){if(!Number.isInteger(c)||c<0)throw new RangeError(`slice: start must be a non-negative integer (got ${c})`);if(m!==void 0&&(!Number.isInteger(m)||m<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${m})`);let b=p(c,m),y=l.get(b);if(y!==void 0)return l.delete(b),l.set(b,y),y.node;h(l);let T=H([a],([v])=>{let N=v;return m===void 0?N.slice(c):N.slice(c,m)},{initial:i.slice(c,m),describeKind:"derived"}),g=pn(T);return l.set(b,{node:T,dispose:g}),T},disposeTail(c){let m=u.get(c);return m===void 0?!1:(m.dispose(),u.delete(c),!0)},disposeSlice(c,m){let b=p(c,m),y=l.get(b);return y===void 0?!1:(y.dispose(),l.delete(b),!0)},disposeAllViews(){for(let c of u.values())c.dispose();u.clear();for(let c of l.values())c.dispose();l.clear()},dispose(){for(let c of u.values())c.dispose();u.clear();for(let c of l.values())c.dispose();l.clear()}}}et();function mn(r,e,t){return{[r]:!0,[`${r}_type`]:e,...t??{}}}function gn(r,e){return mn("messaging",r,e)}var St=class extends pe{_log;events;latest;hasLatest;constructor(e,t={}){super(e,t.graph),this._log=hn([],{name:"events",maxSize:t.retainedLimit}),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=H([this.events],([n])=>{let o=n;return o.length===0?null:o[o.length-1]},{name:"latest",describeKind:"derived",meta:gn("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(xe(this.latest)),this.hasLatest=H([this.events],([n])=>n.length>0,{name:"hasLatest",describeKind:"derived",meta:gn("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(xe(this.hasLatest)),this.addDisposer(()=>{this.events.down([[L]])}),this.addDisposer(()=>this._log.disposeAllViews())}publish(e){this._log.append(e)}retained(){return this.events.cache}};function Ve(r,e){return new St(r,e)}function yr(r){if(typeof r!="object"||r===null)return!1;let e=r;return typeof e.subscribe=="function"&&typeof e.down=="function"&&typeof e.emit=="function"}function bn(r,e){if(r.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(r.length===1){let s=Dt(e);return{best:r[0],bestScore:s}}if(e.some(s=>typeof s.candidateIndex=="number")){let s=new Array(r.length);for(let d=0;d<r.length;d++)s[d]={sum:0,count:0};for(let d of e){let u=d.candidateIndex;typeof u=="number"&&u>=0&&u<r.length&&(s[u].sum+=d.score,s[u].count+=1)}let i=r[0],a=s[0].count>0?s[0].sum/s[0].count:Number.NEGATIVE_INFINITY;for(let d=1;d<r.length;d++){let u=s[d].count>0?s[d].sum/s[d].count:Number.NEGATIVE_INFINITY;u>a&&(a=u,i=r[d])}return{best:i,bestScore:a}}let n=r[0],o=e[0]?.score??Number.NEGATIVE_INFINITY;for(let s=1;s<r.length;s++){let i=e[s]?.score??Number.NEGATIVE_INFINITY;i>o&&(o=i,n=r[s])}return{best:n,bestScore:o}}function Dt(r){if(r.length===0)return Number.NEGATIVE_INFINITY;let e=0;for(let t of r)e+=t.score;return e/r.length}function vr(r,e,t,n){let o=n.name??"refine-loop",s=new pe(o,n.graph),i=yr(n.dataset)?n.dataset:z(n.dataset,{name:"dataset"});s.add(i,{name:"dataset"});let a=z(0,{name:"iteration"});s.add(a,{name:"iteration"});let d=z(t,{name:"strategy",equals:()=>!1});s.add(d,{name:"strategy"});let u=z(null,{name:"lastFeedback"});s.add(u,{name:"lastFeedback"});let l=z([],{name:"prevCandidates"});s.add(l,{name:"prevCandidates"});let p=z(!1,{name:"paused"});s.add(p,{name:"paused"});let h=z("running",{name:"status"});s.add(h,{name:"status"});let f=z([],{name:"history",equals:()=>!1});s.add(f,{name:"history"});let c=z(null,{name:"best"});s.add(c,{name:"best"});let m=z(Number.NEGATIVE_INFINITY,{name:"score"});s.add(m,{name:"score"});let b=z(0,{name:"budget-used"});s.add(b,{name:"budget-used"});let y=Ve("GENERATE"),T=Ve("EVALUATE"),g=Ve("ANALYZE"),v=Ve("DECIDE");s.mount("GENERATE",y),s.mount("EVALUATE",T),s.mount("ANALYZE",g),s.mount("DECIDE",v);let N=t,_=null,w=[];s.addDisposer(d.subscribe(O=>{for(let S of O)S[0]===$&&(N=S[1])})),s.addDisposer(u.subscribe(O=>{for(let S of O)S[0]===$&&(_=S[1])})),s.addDisposer(l.subscribe(O=>{for(let S of O)S[0]===$&&(w=S[1])}));let k=Yt(a,O=>{let S=N,M=O===0||_==null;return ue([],(E,I)=>{let Z=!1;try{let ce=M?S.seed(r):S.generate(_,w);if(ce instanceof Promise)return ce.then(ke=>{Z||I.emit(ke)},ke=>{Z||I.down([[G,ke]])}),()=>{Z=!0};I.emit(ce)}catch(ce){Z=!0,I.down([[G,ce]])}},{describeKind:"producer"})},{name:"candidates"});s.add(k,{name:"candidates"});let A=Ne([k],(O,S,M)=>{let E=M.terminalDeps[0];E!==void 0&&E!==!0&&h.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});s.add(A,{name:"error-watcher"}),s.addDisposer(A.subscribe(()=>{}));let V=Ne([k,a],([O,S])=>{let M=O,E=S;ie(()=>{y.publish({iteration:E,candidates:M,timestamp_ns:ee()}),l.emit(M)})},{name:"generate-bridge"});s.add(V,{name:"generate-bridge"}),s.addDisposer(V.subscribe(()=>{}));let D=e(k,i);s.add(D,{name:"scores"});let C=Ne([D,k,a],([O,S,M])=>{T.publish({iteration:M,candidates:S,scores:O,timestamp_ns:ee()})},{name:"evaluate-bridge"});s.add(C,{name:"evaluate-bridge"}),s.addDisposer(C.subscribe(()=>{}));let R=H([D,k],([O,S])=>N.analyze(O,S),{name:"feedback"});s.add(R,{name:"feedback"});let U=Ne([R,k,a],([O,S,M])=>{g.publish({iteration:M,candidates:S,feedback:O,timestamp_ns:ee()})},{name:"analyze-bridge"});s.add(U,{name:"analyze-bridge"}),s.addDisposer(U.subscribe(()=>{}));let Y=H([f],([O])=>{let S=O;if(n.patience==null||S.length<=n.patience)return!1;let M=S.slice(-(n.patience+1)),E=M[0].bestScore;return M.slice(1).every(I=>I.bestScore<=E)},{name:"patience-check"});s.add(Y,{name:"patience-check"});let J=H([m],([O])=>n.minScore!=null&&O>=n.minScore,{name:"min-score-check"});s.add(J,{name:"min-score-check"});let de=H([f],([O])=>{let S=O;if(n.minDelta==null||S.length<2)return!1;let M=S[S.length-2].bestScore,E=S[S.length-1].bestScore;return Math.abs(E-M)<n.minDelta},{name:"min-delta-check"});s.add(de,{name:"min-delta-check"});let he=H([b],([O])=>n.maxEvaluations!=null&&O>=n.maxEvaluations,{name:"max-evaluations-check"});s.add(he,{name:"max-evaluations-check"});let me=H([a],([O])=>n.maxIterations!=null&&O>=n.maxIterations,{name:"max-iterations-check"});s.add(me,{name:"max-iterations-check"});let Ee=H([b],([O])=>n.budget!=null&&O>=n.budget,{name:"budget-exhausted-check"});s.add(Ee,{name:"budget-exhausted-check"}),s.addDisposer(Y.subscribe(()=>{})),s.addDisposer(J.subscribe(()=>{})),s.addDisposer(de.subscribe(()=>{})),s.addDisposer(he.subscribe(()=>{})),s.addDisposer(me.subscribe(()=>{})),s.addDisposer(Ee.subscribe(()=>{}));let ge=H([Y,J,de,he,me],([O,S,M,E,I])=>O?{converged:!0,reason:"patience"}:S?{converged:!0,reason:"min-score"}:M?{converged:!0,reason:"min-delta"}:E?{converged:!0,reason:"max-evaluations"}:I?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});s.add(ge,{name:"converged"}),s.addDisposer(ge.subscribe(()=>{}));let Me=-1,x=Ne([R,D,k],([O,S,M])=>{let E=a.cache,I=O,Z=M,ce=S;if(E<=Me)return;Me=E;let{best:ke,bestScore:yn}=bn(Z,ce),vn=f.cache,Tn={n:E,candidates:Z,scores:ce,feedback:I,best:ke,bestScore:yn,timestamp_ns:ee()},le=[...vn,Tn],ut=b.cache+Z.length,X="continue",be,_n=n.budget!=null&&ut>=n.budget,wn=p.cache;if(_n)X="budget",be="budget";else if(n.minScore!=null&&I.score>=n.minScore)X="converged",be="min-score";else if(n.maxIterations!=null&&E>=n.maxIterations)X="converged",be="max-iterations";else if(n.maxEvaluations!=null&&ut>=n.maxEvaluations)X="converged",be="max-evaluations";else if(n.minDelta!=null&&le.length>=2){let ze=le[le.length-2].bestScore,dt=le[le.length-1].bestScore;Math.abs(dt-ze)<n.minDelta&&(X="converged",be="min-delta")}else if(n.patience!=null&&le.length>n.patience){let ze=le.slice(-(n.patience+1)),dt=ze[0].bestScore;ze.slice(1).every(Nn=>Nn.bestScore<=dt)&&(X="converged",be="patience")}X==="continue"&&wn&&(X="paused"),ie(()=>{c.emit(ke),m.emit(I.score),f.emit(le),b.emit(ut),u.emit(I),v.publish({iteration:E,decision:X,reason:be,timestamp_ns:ee()}),X==="continue"?a.emit(E+1):h.emit(X==="converged"?"converged":X==="budget"?"budget":"paused")})},{name:"decide-bridge"});return s.add(x,{name:"decide-bridge"}),s.addDisposer(x.subscribe(()=>{})),Object.assign(s,{best:c,score:m,status:h,history:f,strategy:d,iteration:a,generate:y,evaluate:T,analyze:g,decide:v,setStrategy(O){d.emit(O)},pause(){p.emit(!0)},resume(){h.cache==="paused"&&ie(()=>{p.emit(!1),h.emit("running"),a.emit(a.cache+1)})}})}function Tr(r){let e=r.width??4;return{name:r.name??"blindVariation",seed(n){return[n]},analyze(n,o){let s=Dt(n),i=null;for(let a of n)(!i||a.score<i.score)&&(i=a);return{summary:`blindVariation iteration: mean=${s.toFixed(3)}, n=${n.length}`,score:s,weakTasks:i?[i.taskId]:[]}},async generate(n,o){if(o.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let s=o[o.length-1],i=0,d={prior:s,reportCost:u=>{i+=u}};try{if(r.parallel!==!1)return await Promise.all(Array.from({length:e},()=>r.teacher(d)));let u=[];for(let l=0;l<e;l++)u.push(await r.teacher(d));return u}finally{if(r.tokens!=null&&i>0){let u=r.tokens.cache??0;r.tokens.emit(u+i)}}}}}function _r(r){return typeof r=="object"&&r!==null&&r.kind==="errorCritique"}function wr(r,e){return r.length===0?`No task scored below the batch mean (${e.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
7
+ ${r.map(n=>{let o=n.error!=null?` | error: ${n.error}`:"";return`- ${n.taskId} (score=${n.score.toFixed(3)})${o}`}).join(`
8
+ `)}`}function Nr(r){let e=r.width??4,t=r.name??"errorCritique",n=r.maxFailureSamples??5,o=r.formatCritique??wr;return{name:t,seed(s){return[s]},analyze(s,i){let a=Dt(s),d=typeof r.failureThreshold=="function"?r.failureThreshold(s):r.failureThreshold,u=d===void 0&&!Number.isFinite(a),l=d??a,p=u?[...s].sort((g,v)=>g.score-v.score):s.filter(g=>g.score<l).slice().sort((g,v)=>g.score-v.score),h=p.slice(0,n),{best:f,bestScore:c}=bn(i,s),m={summary:"",score:a,weakTasks:h.map(g=>g.taskId)},b=o(h,m),y={kind:"errorCritique",best:f,failures:h,critiqueText:b},T=p.length>h.length?` (top ${h.length} retained)`:"";return{summary:`errorCritique iteration: mean=${a.toFixed(3)}, failures=${p.length}${T}/${s.length}, bestScore=${c.toFixed(3)}`,critique:y,weakTasks:h.map(g=>g.taskId),score:a}},async generate(s,i){if(i.length===0)throw new Error("errorCritique.generate: empty candidate batch \u2014 cannot derive prior for teacher");let a=_r(s.critique)?s.critique:void 0,d=a!==void 0?a.best:i[i.length-1],u=a?.critiqueText??s.summary,l=a?.failures??[],p=0,f={prior:d,critique:u,failures:l,reportCost:c=>{p+=c}};try{if(r.parallel!==!1)return await Promise.all(Array.from({length:e},()=>r.teacher(f)));let c=[];for(let m=0;m<e;m++)c.push(await r.teacher(f));return c}finally{if(r.tokens!=null&&p>0){let c=r.tokens.cache??0;r.tokens.emit(c+p)}}}}}0&&(module.exports={blindVariation,errorCritique,refineLoop});
@@ -0,0 +1,7 @@
1
+ import '../../node-Cc1TniY8.cjs';
2
+ import '../../extra/sources.cjs';
3
+ import '../../graph-D48Qw9Cg.cjs';
4
+ import '../../index-DyxjtScX.cjs';
5
+ export { A as AnalyzeEvent, B as BlindVariationContext, a as BlindVariationOptions, C as ConvergenceOptions, D as DatasetItem, b as DecideEvent, E as ErrorCritiqueContext, c as ErrorCritiqueOptions, d as EvalResult, e as EvaluateEvent, f as Evaluator, F as Feedback, G as GenerateEvent, I as Iteration, R as RefineLoopGraph, g as RefineLoopOptions, h as RefineStatus, j as RefineStrategy, k as blindVariation, l as errorCritique, r as refineLoop } from '../../index-BpIFjILY.cjs';
6
+ import '../../meta-Cgj6zeji.cjs';
7
+ import '../../extra/storage-core.cjs';
@@ -0,0 +1,7 @@
1
+ import '../../node-Cc1TniY8.js';
2
+ import '../../extra/sources.js';
3
+ import '../../graph-BZGRXwOm.js';
4
+ import '../../index-B0c4cmIO.js';
5
+ export { A as AnalyzeEvent, B as BlindVariationContext, a as BlindVariationOptions, C as ConvergenceOptions, D as DatasetItem, b as DecideEvent, E as ErrorCritiqueContext, c as ErrorCritiqueOptions, d as EvalResult, e as EvaluateEvent, f as Evaluator, F as Feedback, G as GenerateEvent, I as Iteration, R as RefineLoopGraph, g as RefineLoopOptions, h as RefineStatus, j as RefineStrategy, k as blindVariation, l as errorCritique, r as refineLoop } from '../../index-BpA5c4G9.js';
6
+ import '../../meta-CwesDrMD.js';
7
+ import '../../extra/storage-core.js';
@@ -0,0 +1 @@
1
+ import{a,b,c}from"../../chunk-LBTDSCCO.js";import"../../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-Z4HDAS2Q.js";import"../../chunk-4VVTGLXJ.js";import"../../chunk-D7A7DBE4.js";import"../../chunk-2PMCKKRK.js";import"../../chunk-ZB5EHBIO.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{b as blindVariation,c as errorCritique,a as refineLoop};