@graphrefly/graphrefly 0.43.0 → 0.45.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 (422) hide show
  1. package/README.md +21 -17
  2. package/dist/compat/index.cjs +20 -10
  3. package/dist/compat/index.cjs.map +1 -0
  4. package/dist/compat/index.d.cts +1 -22
  5. package/dist/compat/index.d.ts +1 -22
  6. package/dist/compat/index.js +3 -1
  7. package/dist/compat/index.js.map +1 -0
  8. package/dist/compat/jotai/index.cjs +21 -1
  9. package/dist/compat/jotai/index.cjs.map +1 -0
  10. package/dist/compat/jotai/index.d.cts +1 -2
  11. package/dist/compat/jotai/index.d.ts +1 -2
  12. package/dist/compat/jotai/index.js +3 -1
  13. package/dist/compat/jotai/index.js.map +1 -0
  14. package/dist/compat/nanostores/index.cjs +21 -1
  15. package/dist/compat/nanostores/index.cjs.map +1 -0
  16. package/dist/compat/nanostores/index.d.cts +1 -2
  17. package/dist/compat/nanostores/index.d.ts +1 -2
  18. package/dist/compat/nanostores/index.js +3 -1
  19. package/dist/compat/nanostores/index.js.map +1 -0
  20. package/dist/compat/nestjs/index.cjs +20 -10
  21. package/dist/compat/nestjs/index.cjs.map +1 -0
  22. package/dist/compat/nestjs/index.d.cts +1 -13
  23. package/dist/compat/nestjs/index.d.ts +1 -13
  24. package/dist/compat/nestjs/index.js +3 -1
  25. package/dist/compat/nestjs/index.js.map +1 -0
  26. package/dist/compat/react/index.cjs +21 -1
  27. package/dist/compat/react/index.cjs.map +1 -0
  28. package/dist/compat/react/index.d.cts +1 -2
  29. package/dist/compat/react/index.d.ts +1 -2
  30. package/dist/compat/react/index.js +3 -1
  31. package/dist/compat/react/index.js.map +1 -0
  32. package/dist/compat/solid/index.cjs +21 -1
  33. package/dist/compat/solid/index.cjs.map +1 -0
  34. package/dist/compat/solid/index.d.cts +1 -2
  35. package/dist/compat/solid/index.d.ts +1 -2
  36. package/dist/compat/solid/index.js +3 -1
  37. package/dist/compat/solid/index.js.map +1 -0
  38. package/dist/compat/svelte/index.cjs +21 -1
  39. package/dist/compat/svelte/index.cjs.map +1 -0
  40. package/dist/compat/svelte/index.d.cts +1 -2
  41. package/dist/compat/svelte/index.d.ts +1 -2
  42. package/dist/compat/svelte/index.js +3 -1
  43. package/dist/compat/svelte/index.js.map +1 -0
  44. package/dist/compat/vue/index.cjs +21 -1
  45. package/dist/compat/vue/index.cjs.map +1 -0
  46. package/dist/compat/vue/index.d.cts +1 -3
  47. package/dist/compat/vue/index.d.ts +1 -3
  48. package/dist/compat/vue/index.js +3 -1
  49. package/dist/compat/vue/index.js.map +1 -0
  50. package/dist/compat/zustand/index.cjs +21 -3
  51. package/dist/compat/zustand/index.cjs.map +1 -0
  52. package/dist/compat/zustand/index.d.cts +1 -6
  53. package/dist/compat/zustand/index.d.ts +1 -6
  54. package/dist/compat/zustand/index.js +3 -1
  55. package/dist/compat/zustand/index.js.map +1 -0
  56. package/dist/core/index.cjs +21 -1
  57. package/dist/core/index.cjs.map +1 -0
  58. package/dist/core/index.d.cts +1 -4
  59. package/dist/core/index.d.ts +1 -4
  60. package/dist/core/index.js +3 -1
  61. package/dist/core/index.js.map +1 -0
  62. package/dist/extra/browser.cjs +21 -1
  63. package/dist/extra/browser.cjs.map +1 -0
  64. package/dist/extra/browser.d.cts +1 -4
  65. package/dist/extra/browser.d.ts +1 -4
  66. package/dist/extra/browser.js +3 -1
  67. package/dist/extra/browser.js.map +1 -0
  68. package/dist/extra/index.cjs +20 -19
  69. package/dist/extra/index.cjs.map +1 -0
  70. package/dist/extra/index.d.cts +1 -17
  71. package/dist/extra/index.d.ts +1 -17
  72. package/dist/extra/index.js +3 -1
  73. package/dist/extra/index.js.map +1 -0
  74. package/dist/extra/node.cjs +21 -2
  75. package/dist/extra/node.cjs.map +1 -0
  76. package/dist/extra/node.d.cts +1 -187
  77. package/dist/extra/node.d.ts +1 -187
  78. package/dist/extra/node.js +3 -2
  79. package/dist/extra/node.js.map +1 -0
  80. package/dist/extra/operators.cjs +21 -1
  81. package/dist/extra/operators.cjs.map +1 -0
  82. package/dist/extra/operators.d.cts +1 -950
  83. package/dist/extra/operators.d.ts +1 -950
  84. package/dist/extra/operators.js +3 -1
  85. package/dist/extra/operators.js.map +1 -0
  86. package/dist/extra/reactive.cjs +21 -1
  87. package/dist/extra/reactive.cjs.map +1 -0
  88. package/dist/extra/reactive.d.cts +1 -353
  89. package/dist/extra/reactive.d.ts +1 -353
  90. package/dist/extra/reactive.js +3 -1
  91. package/dist/extra/reactive.js.map +1 -0
  92. package/dist/extra/render/index.cjs +21 -5
  93. package/dist/extra/render/index.cjs.map +1 -0
  94. package/dist/extra/render/index.d.cts +1 -183
  95. package/dist/extra/render/index.d.ts +1 -183
  96. package/dist/extra/render/index.js +3 -1
  97. package/dist/extra/render/index.js.map +1 -0
  98. package/dist/extra/sources.cjs +21 -3
  99. package/dist/extra/sources.cjs.map +1 -0
  100. package/dist/extra/sources.d.cts +1 -584
  101. package/dist/extra/sources.d.ts +1 -584
  102. package/dist/extra/sources.js +3 -1
  103. package/dist/extra/sources.js.map +1 -0
  104. package/dist/extra/storage-browser.cjs +21 -1
  105. package/dist/extra/storage-browser.cjs.map +1 -0
  106. package/dist/extra/storage-browser.d.cts +1 -37
  107. package/dist/extra/storage-browser.d.ts +1 -37
  108. package/dist/extra/storage-browser.js +3 -1
  109. package/dist/extra/storage-browser.js.map +1 -0
  110. package/dist/extra/storage-core.cjs +21 -1
  111. package/dist/extra/storage-core.cjs.map +1 -0
  112. package/dist/extra/storage-core.d.cts +1 -28
  113. package/dist/extra/storage-core.d.ts +1 -28
  114. package/dist/extra/storage-core.js +3 -1
  115. package/dist/extra/storage-core.js.map +1 -0
  116. package/dist/extra/storage-node.cjs +20 -0
  117. package/dist/extra/storage-node.cjs.map +1 -0
  118. package/dist/extra/storage-node.d.cts +1 -2
  119. package/dist/extra/storage-node.d.ts +1 -2
  120. package/dist/extra/storage-node.js +3 -0
  121. package/dist/extra/storage-node.js.map +1 -0
  122. package/dist/extra/storage-tiers-browser.cjs +21 -1
  123. package/dist/extra/storage-tiers-browser.cjs.map +1 -0
  124. package/dist/extra/storage-tiers-browser.d.cts +1 -120
  125. package/dist/extra/storage-tiers-browser.d.ts +1 -120
  126. package/dist/extra/storage-tiers-browser.js +3 -1
  127. package/dist/extra/storage-tiers-browser.js.map +1 -0
  128. package/dist/extra/storage-tiers-node.cjs +21 -1
  129. package/dist/extra/storage-tiers-node.cjs.map +1 -0
  130. package/dist/extra/storage-tiers-node.d.cts +1 -210
  131. package/dist/extra/storage-tiers-node.d.ts +1 -210
  132. package/dist/extra/storage-tiers-node.js +3 -1
  133. package/dist/extra/storage-tiers-node.js.map +1 -0
  134. package/dist/extra/storage-tiers.cjs +21 -1
  135. package/dist/extra/storage-tiers.cjs.map +1 -0
  136. package/dist/extra/storage-tiers.d.cts +1 -412
  137. package/dist/extra/storage-tiers.d.ts +1 -412
  138. package/dist/extra/storage-tiers.js +3 -1
  139. package/dist/extra/storage-tiers.js.map +1 -0
  140. package/dist/extra/storage-wal.cjs +21 -0
  141. package/dist/extra/storage-wal.cjs.map +1 -0
  142. package/dist/extra/storage-wal.d.cts +1 -0
  143. package/dist/extra/storage-wal.d.ts +1 -0
  144. package/dist/extra/storage-wal.js +3 -0
  145. package/dist/extra/storage-wal.js.map +1 -0
  146. package/dist/graph/index.cjs +21 -7
  147. package/dist/graph/index.cjs.map +1 -0
  148. package/dist/graph/index.d.cts +1 -7
  149. package/dist/graph/index.d.ts +1 -7
  150. package/dist/graph/index.js +3 -1
  151. package/dist/graph/index.js.map +1 -0
  152. package/dist/index.cjs +20 -227
  153. package/dist/index.cjs.map +1 -0
  154. package/dist/index.d.cts +45 -96
  155. package/dist/index.d.ts +45 -96
  156. package/dist/index.js +3 -1
  157. package/dist/index.js.map +1 -0
  158. package/dist/patterns/ai/browser.cjs +20 -7
  159. package/dist/patterns/ai/browser.cjs.map +1 -0
  160. package/dist/patterns/ai/browser.d.cts +1 -127
  161. package/dist/patterns/ai/browser.d.ts +1 -127
  162. package/dist/patterns/ai/browser.js +3 -3
  163. package/dist/patterns/ai/browser.js.map +1 -0
  164. package/dist/patterns/ai/index.cjs +20 -73
  165. package/dist/patterns/ai/index.cjs.map +1 -0
  166. package/dist/patterns/ai/index.d.cts +1 -21
  167. package/dist/patterns/ai/index.d.ts +1 -21
  168. package/dist/patterns/ai/index.js +3 -1
  169. package/dist/patterns/ai/index.js.map +1 -0
  170. package/dist/patterns/ai/node.cjs +21 -1
  171. package/dist/patterns/ai/node.cjs.map +1 -0
  172. package/dist/patterns/ai/node.d.cts +1 -59
  173. package/dist/patterns/ai/node.d.ts +1 -59
  174. package/dist/patterns/ai/node.js +3 -1
  175. package/dist/patterns/ai/node.js.map +1 -0
  176. package/dist/patterns/cqrs/index.cjs +21 -3
  177. package/dist/patterns/cqrs/index.cjs.map +1 -0
  178. package/dist/patterns/cqrs/index.d.cts +1 -8
  179. package/dist/patterns/cqrs/index.d.ts +1 -8
  180. package/dist/patterns/cqrs/index.js +3 -1
  181. package/dist/patterns/cqrs/index.js.map +1 -0
  182. package/dist/patterns/demo-shell/index.cjs +21 -5
  183. package/dist/patterns/demo-shell/index.cjs.map +1 -0
  184. package/dist/patterns/demo-shell/index.d.cts +1 -7
  185. package/dist/patterns/demo-shell/index.d.ts +1 -7
  186. package/dist/patterns/demo-shell/index.js +3 -1
  187. package/dist/patterns/demo-shell/index.js.map +1 -0
  188. package/dist/patterns/domain-templates/index.cjs +21 -3
  189. package/dist/patterns/domain-templates/index.cjs.map +1 -0
  190. package/dist/patterns/domain-templates/index.d.cts +1 -6
  191. package/dist/patterns/domain-templates/index.d.ts +1 -6
  192. package/dist/patterns/domain-templates/index.js +3 -1
  193. package/dist/patterns/domain-templates/index.js.map +1 -0
  194. package/dist/patterns/graphspec/index.cjs +21 -86
  195. package/dist/patterns/graphspec/index.cjs.map +1 -0
  196. package/dist/patterns/graphspec/index.d.cts +1 -8
  197. package/dist/patterns/graphspec/index.d.ts +1 -8
  198. package/dist/patterns/graphspec/index.js +3 -1
  199. package/dist/patterns/graphspec/index.js.map +1 -0
  200. package/dist/patterns/harness/index.cjs +21 -48
  201. package/dist/patterns/harness/index.cjs.map +1 -0
  202. package/dist/patterns/harness/index.d.cts +1 -14
  203. package/dist/patterns/harness/index.d.ts +1 -14
  204. package/dist/patterns/harness/index.js +3 -1
  205. package/dist/patterns/harness/index.js.map +1 -0
  206. package/dist/patterns/inspect/index.cjs +21 -3
  207. package/dist/patterns/inspect/index.cjs.map +1 -0
  208. package/dist/patterns/inspect/index.d.cts +1 -9
  209. package/dist/patterns/inspect/index.d.ts +1 -9
  210. package/dist/patterns/inspect/index.js +3 -1
  211. package/dist/patterns/inspect/index.js.map +1 -0
  212. package/dist/patterns/job-queue/index.cjs +21 -3
  213. package/dist/patterns/job-queue/index.cjs.map +1 -0
  214. package/dist/patterns/job-queue/index.d.cts +1 -9
  215. package/dist/patterns/job-queue/index.d.ts +1 -9
  216. package/dist/patterns/job-queue/index.js +3 -1
  217. package/dist/patterns/job-queue/index.js.map +1 -0
  218. package/dist/patterns/memory/index.cjs +21 -3
  219. package/dist/patterns/memory/index.cjs.map +1 -0
  220. package/dist/patterns/memory/index.d.cts +1 -8
  221. package/dist/patterns/memory/index.d.ts +1 -8
  222. package/dist/patterns/memory/index.js +3 -1
  223. package/dist/patterns/memory/index.js.map +1 -0
  224. package/dist/patterns/messaging/index.cjs +21 -3
  225. package/dist/patterns/messaging/index.cjs.map +1 -0
  226. package/dist/patterns/messaging/index.d.cts +1 -7
  227. package/dist/patterns/messaging/index.d.ts +1 -7
  228. package/dist/patterns/messaging/index.js +3 -1
  229. package/dist/patterns/messaging/index.js.map +1 -0
  230. package/dist/patterns/orchestration/index.cjs +21 -3
  231. package/dist/patterns/orchestration/index.cjs.map +1 -0
  232. package/dist/patterns/orchestration/index.d.cts +1 -9
  233. package/dist/patterns/orchestration/index.d.ts +1 -9
  234. package/dist/patterns/orchestration/index.js +3 -1
  235. package/dist/patterns/orchestration/index.js.map +1 -0
  236. package/dist/patterns/process/index.cjs +21 -1
  237. package/dist/patterns/process/index.cjs.map +1 -0
  238. package/dist/patterns/process/index.d.cts +1 -10
  239. package/dist/patterns/process/index.d.ts +1 -10
  240. package/dist/patterns/process/index.js +3 -1
  241. package/dist/patterns/process/index.js.map +1 -0
  242. package/dist/patterns/reactive-layout/index.cjs +21 -4
  243. package/dist/patterns/reactive-layout/index.cjs.map +1 -0
  244. package/dist/patterns/reactive-layout/index.d.cts +1 -7
  245. package/dist/patterns/reactive-layout/index.d.ts +1 -7
  246. package/dist/patterns/reactive-layout/index.js +3 -1
  247. package/dist/patterns/reactive-layout/index.js.map +1 -0
  248. package/dist/patterns/reduction/index.cjs +21 -3
  249. package/dist/patterns/reduction/index.cjs.map +1 -0
  250. package/dist/patterns/reduction/index.d.cts +1 -6
  251. package/dist/patterns/reduction/index.d.ts +1 -6
  252. package/dist/patterns/reduction/index.js +3 -1
  253. package/dist/patterns/reduction/index.js.map +1 -0
  254. package/dist/patterns/surface/index.cjs +21 -13
  255. package/dist/patterns/surface/index.cjs.map +1 -0
  256. package/dist/patterns/surface/index.d.cts +1 -9
  257. package/dist/patterns/surface/index.d.ts +1 -9
  258. package/dist/patterns/surface/index.js +3 -1
  259. package/dist/patterns/surface/index.js.map +1 -0
  260. package/dist/patterns/topology-view/index.cjs +21 -0
  261. package/dist/patterns/topology-view/index.cjs.map +1 -0
  262. package/dist/patterns/topology-view/index.d.cts +1 -0
  263. package/dist/patterns/topology-view/index.d.ts +1 -0
  264. package/dist/patterns/topology-view/index.js +3 -0
  265. package/dist/patterns/topology-view/index.js.map +1 -0
  266. package/dist/testing/index.cjs +21 -0
  267. package/dist/testing/index.cjs.map +1 -0
  268. package/dist/testing/index.d.cts +1 -0
  269. package/dist/testing/index.d.ts +1 -0
  270. package/dist/testing/index.js +3 -0
  271. package/dist/testing/index.js.map +1 -0
  272. package/package.json +608 -584
  273. package/dist/backoff-HPZMEZNF.js +0 -1
  274. package/dist/cascading-CH-_VwG9.d.cts +0 -199
  275. package/dist/cascading-OgKQZjsa.d.ts +0 -199
  276. package/dist/chunk-35JTVPOX.js +0 -1
  277. package/dist/chunk-3G5U5QNE.js +0 -5
  278. package/dist/chunk-3XDYJRYU.js +0 -1
  279. package/dist/chunk-4I45FVQS.js +0 -1
  280. package/dist/chunk-4VVTGLXJ.js +0 -1
  281. package/dist/chunk-4YAN45KM.js +0 -1
  282. package/dist/chunk-5QDBSZBV.js +0 -1
  283. package/dist/chunk-626TESAC.js +0 -3
  284. package/dist/chunk-6HOSXQKF.js +0 -1
  285. package/dist/chunk-6QZNQS5B.js +0 -1
  286. package/dist/chunk-C72GO4IZ.js +0 -1
  287. package/dist/chunk-CE72X3WO.js +0 -1
  288. package/dist/chunk-CK2E7BTU.js +0 -1
  289. package/dist/chunk-CLD3F4R5.js +0 -1
  290. package/dist/chunk-CUNIRONA.js +0 -1
  291. package/dist/chunk-D27JNOLZ.js +0 -1
  292. package/dist/chunk-D5RFJOZ2.js +0 -1
  293. package/dist/chunk-EBW4V6JN.js +0 -1
  294. package/dist/chunk-ESMPEKEV.js +0 -1
  295. package/dist/chunk-F3IGTWCQ.js +0 -1
  296. package/dist/chunk-F672GV32.js +0 -1
  297. package/dist/chunk-FDQGFWLF.js +0 -1
  298. package/dist/chunk-FG4TKHMC.js +0 -1
  299. package/dist/chunk-GPW2V3RE.js +0 -1
  300. package/dist/chunk-I7IGYPSL.js +0 -1
  301. package/dist/chunk-INQD2KRQ.js +0 -1
  302. package/dist/chunk-JNWRYDJN.js +0 -1
  303. package/dist/chunk-JQFH2DV6.js +0 -1
  304. package/dist/chunk-K2Q24F5T.js +0 -1
  305. package/dist/chunk-KGKJCHEK.js +0 -1
  306. package/dist/chunk-KRH66M4O.js +0 -1
  307. package/dist/chunk-KVV66NN2.js +0 -1
  308. package/dist/chunk-L6NSJVJZ.js +0 -1
  309. package/dist/chunk-LYCLF26R.js +0 -1
  310. package/dist/chunk-NNKJUORL.js +0 -1
  311. package/dist/chunk-NON4NLIC.js +0 -45
  312. package/dist/chunk-O2BLLH7M.js +0 -18
  313. package/dist/chunk-OCKEEPRJ.js +0 -2
  314. package/dist/chunk-OFZG3TB3.js +0 -9
  315. package/dist/chunk-OYJKFY7V.js +0 -1
  316. package/dist/chunk-P6C4WHZO.js +0 -5
  317. package/dist/chunk-PT7W5FCD.js +0 -5
  318. package/dist/chunk-Q4U3A3L5.js +0 -1
  319. package/dist/chunk-QE4IGY7I.js +0 -61
  320. package/dist/chunk-QYADASLV.js +0 -1
  321. package/dist/chunk-QYVXF7GW.js +0 -1
  322. package/dist/chunk-S3EEIPO7.js +0 -1
  323. package/dist/chunk-SUWT3ZON.js +0 -1
  324. package/dist/chunk-TPKQW72B.js +0 -1
  325. package/dist/chunk-TSOYJ743.js +0 -1
  326. package/dist/chunk-TZQPPQEQ.js +0 -1
  327. package/dist/chunk-V5A7M7RJ.js +0 -1
  328. package/dist/chunk-VIMF6LGM.js +0 -1
  329. package/dist/chunk-VJLMUKOI.js +0 -1
  330. package/dist/chunk-VN6RDSK2.js +0 -1
  331. package/dist/chunk-VNC3TMVY.js +0 -1
  332. package/dist/chunk-VOPGGIL7.js +0 -1
  333. package/dist/chunk-VQ4A6T2A.js +0 -1
  334. package/dist/chunk-XG62INFA.js +0 -1
  335. package/dist/chunk-Y4NI3X7O.js +0 -84
  336. package/dist/content-addressed-storage-4-ST1tYk.d.cts +0 -124
  337. package/dist/content-addressed-storage-DuYMjV7o.d.ts +0 -124
  338. package/dist/decay-2ZukgQ4o.d.cts +0 -112
  339. package/dist/decay-CdEBmDIs.d.ts +0 -112
  340. package/dist/fallback-CqYVLL6X.d.ts +0 -250
  341. package/dist/fallback-Ctlj2tMY.d.cts +0 -250
  342. package/dist/graph-7VguS7a4.d.ts +0 -1668
  343. package/dist/graph-C4SHb3Ly.d.cts +0 -1668
  344. package/dist/index-0rKFCVFp.d.cts +0 -557
  345. package/dist/index-B-i4_g3k.d.ts +0 -651
  346. package/dist/index-B5iz82A3.d.cts +0 -2655
  347. package/dist/index-BAOD98JD.d.cts +0 -754
  348. package/dist/index-BG0BN3PB.d.ts +0 -44
  349. package/dist/index-BJX94aud.d.cts +0 -34
  350. package/dist/index-BP8a88zx.d.ts +0 -385
  351. package/dist/index-BTQtTb_H.d.cts +0 -301
  352. package/dist/index-BVpm6noz.d.cts +0 -36
  353. package/dist/index-Bc41FuHp.d.cts +0 -291
  354. package/dist/index-BdGtBX-X.d.cts +0 -515
  355. package/dist/index-Bf7eqeSF.d.ts +0 -113
  356. package/dist/index-BiX1Nkgx.d.cts +0 -1844
  357. package/dist/index-BoLv_OfD.d.cts +0 -651
  358. package/dist/index-BojK2fwH.d.cts +0 -299
  359. package/dist/index-BsT7F2et.d.ts +0 -291
  360. package/dist/index-BwLvVVsy.d.cts +0 -189
  361. package/dist/index-C59mYFKp.d.ts +0 -121
  362. package/dist/index-C7O6r5fV.d.ts +0 -37
  363. package/dist/index-C9kSENB4.d.cts +0 -127
  364. package/dist/index-C9pjcz3l.d.cts +0 -209
  365. package/dist/index-CAC_rNzm.d.ts +0 -189
  366. package/dist/index-CCq87F7t.d.ts +0 -127
  367. package/dist/index-CDXc9zKM.d.cts +0 -26
  368. package/dist/index-CJK1JkYy.d.ts +0 -36
  369. package/dist/index-CLon-IWF.d.cts +0 -374
  370. package/dist/index-COD1kVoS.d.cts +0 -468
  371. package/dist/index-CPT7C_f1.d.ts +0 -374
  372. package/dist/index-CQG3D1cp.d.ts +0 -468
  373. package/dist/index-CZQXo5tH.d.ts +0 -209
  374. package/dist/index-CZjOhcBy.d.cts +0 -113
  375. package/dist/index-ChOyVLKm.d.cts +0 -86
  376. package/dist/index-CvrqGfNS.d.ts +0 -34
  377. package/dist/index-D-AEQVLo.d.ts +0 -2655
  378. package/dist/index-D4Y1cMG0.d.ts +0 -26
  379. package/dist/index-DBHK8O6H.d.ts +0 -301
  380. package/dist/index-DBevwHj_.d.ts +0 -515
  381. package/dist/index-DIOoAZUX.d.ts +0 -45
  382. package/dist/index-DSZ3ZCHF.d.ts +0 -3402
  383. package/dist/index-Dgs8zcj7.d.ts +0 -102
  384. package/dist/index-Dh_HJ82K.d.ts +0 -299
  385. package/dist/index-Dhc7a7Xo.d.cts +0 -102
  386. package/dist/index-Dmqp7KjD.d.ts +0 -86
  387. package/dist/index-Dn-wI9g4.d.ts +0 -231
  388. package/dist/index-Du7u1lSf.d.cts +0 -385
  389. package/dist/index-DwigL4lY.d.ts +0 -1844
  390. package/dist/index-DyR7eU5S.d.cts +0 -779
  391. package/dist/index-JZUPJIJy.d.ts +0 -779
  392. package/dist/index-K0_0eR8g.d.ts +0 -557
  393. package/dist/index-O16yXPK4.d.cts +0 -3402
  394. package/dist/index-O7fucFrU.d.cts +0 -121
  395. package/dist/index-RV_yDjOX.d.cts +0 -198
  396. package/dist/index-cm1GNcWE.d.ts +0 -754
  397. package/dist/index-f5IivDUX.d.cts +0 -37
  398. package/dist/index-hHcaFlJX.d.cts +0 -45
  399. package/dist/index-tJoTcnHh.d.cts +0 -231
  400. package/dist/index-wAzD9yVj.d.ts +0 -198
  401. package/dist/index-z96luz5O.d.cts +0 -44
  402. package/dist/meta-BgVAsg9j.d.ts +0 -102
  403. package/dist/meta-vE8bxW1E.d.cts +0 -102
  404. package/dist/node-ClS5yC-B.d.cts +0 -1347
  405. package/dist/node-ClS5yC-B.d.ts +0 -1347
  406. package/dist/observable-BsBzUrcI.d.ts +0 -36
  407. package/dist/observable-DLGPPtb8.d.cts +0 -36
  408. package/dist/pipeline-graph-DPqKDk59.d.cts +0 -137
  409. package/dist/pipeline-graph-loP57TBA.d.ts +0 -137
  410. package/dist/reactive-layout-Dsvob4zD.d.cts +0 -183
  411. package/dist/reactive-layout-v7KPvxoc.d.ts +0 -183
  412. package/dist/reactive-log-B00laMSQ.d.cts +0 -223
  413. package/dist/reactive-log-BezYsbA_.d.ts +0 -223
  414. package/dist/reactive-map-48mnZ-nu.d.cts +0 -296
  415. package/dist/reactive-map-BVVPdvmi.d.ts +0 -296
  416. package/dist/resilience-YIWPK4YC.js +0 -1
  417. package/dist/sugar-DLwvMr3F.d.ts +0 -223
  418. package/dist/sugar-DyVGtczU.d.cts +0 -223
  419. package/dist/topology-tree-BNGvuG82.d.ts +0 -25
  420. package/dist/topology-tree-BSdfSwMi.d.cts +0 -25
  421. package/dist/types-B1jDWVsM.d.cts +0 -442
  422. package/dist/types-DkzUUs0H.d.ts +0 -442
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # GraphReFly
2
2
 
3
- **The reactive harness layer for agent workflows.** Describe in plain language, review visually, run persistently, trace every decision.
3
+ **The reactive graph your code, your agents, and your humans share as a blueprint.** Compose in code, review the projected spec, co-edit across agents without colliding, trace every decision.
4
4
 
5
- GraphReFly makes long-running human + LLM co-operation reactive, resumable, and causally explainable. State pushes downstream on change (no re-reading), nodes have lifecycles (not infinite append), and every decision has a traceable causal chain — the substrate underneath tools, agents, and personal automations.
5
+ GraphReFly is a reactive graph protocol for human + LLM co-operation. Code is the source of truth — `factoryTag`-stamped factories project automatically into a `GraphSpec` blueprint that humans and agents read, diff, and review together. Multi-agent worktrees claim subgraph ownership through a structural protocol (TTL → heartbeat → supervisor) so concurrent edits don't corrupt shared topology. Every decision has a causal chain — `graph.explain()` walks back through dependencies and tells you exactly why a value is what it is.
6
6
 
7
7
  [![npm](https://img.shields.io/npm/v/@graphrefly/graphrefly?color=blue)](https://www.npmjs.com/package/@graphrefly/graphrefly)
8
8
  [![license](https://img.shields.io/github/license/graphrefly/graphrefly-ts)](./LICENSE)
@@ -52,11 +52,13 @@ count.set(3);
52
52
 
53
53
  ## How it works
54
54
 
55
- You describe what you need an LLM composes a reactive graph (like SQL for data flows). The graph runs persistently, checkpoints its state, and traces every decision through a causal chain. Ask "why?" at any point and get a human-readable explanation from source to conclusion.
55
+ Code is the source of truth. You compose a reactive graph using primitives (`state`, `derived`, `effect`, `producer`) and factories (`agentLoop`, `harnessLoop`, `agentMemory`, …). `factoryTag`-stamped factories carry self-description into the live graph. `graph.describe({ detail: "spec" })` projects the topology into a JSON `GraphSpec` blueprint — the same shape the original spec was written from, but always in sync with what's actually running. Spec is what your agents read to understand the topology. Code is what they (and you) actually edit.
56
56
 
57
- ## Harness engineering coverage
57
+ The graph runs persistently, checkpoints state on `messageTier ≥ 3` and topology on `_topologyVersion` bump, and traces every decision through a causal chain. Ask "why?" at any point — `graph.explain(from, to)` walks backward through dependencies and returns a structured chain that's both human-readable and LLM-parseable.
58
58
 
59
- The eight requirements of a production agent harness cluster into a handful of composed blocks that sit on top of the reactive graph primitives:
59
+ ## Substrate coverage
60
+
61
+ The eight requirements of a production agent system cluster into a handful of composed blocks that sit on top of the reactive graph primitives:
60
62
 
61
63
  | Need | GraphReFly |
62
64
  |---|---|
@@ -68,23 +70,25 @@ The eight requirements of a production agent harness cluster into a handful of c
68
70
  | Human governance | `gate` — reactive `pending` / `isOpen` with `approve` / `reject` / `modify(fn, n)` |
69
71
  | Verification | Multi-model eval harness with regression gates |
70
72
  | Continuous improvement | Strategy model: `rootCause × intervention → successRate` |
73
+ | Multi-agent coordination | `ownershipController()` — L0 static / L1 TTL / L2 heartbeat / L3 supervisor staircase; `Actor / Guard ABAC` enforces claims at write time; `validateOwnership` lints PR diffs |
71
74
 
72
75
  The library computes structured facts reactively; LLMs and UIs render them. Natural language is never the library's job — which keeps the whole stack model-agnostic and testable.
73
76
 
74
77
  ## Why GraphReFly?
75
78
 
76
- | | Zustand / Jotai | RxJS | XState | LangGraph | TC39 Signals | **GraphReFly** |
77
- |--|-----------------|------|--------|-----------|-------------|---------------|
78
- | Simple store API | yes | no | no | no | yes | **yes** |
79
- | Streaming operators | no | yes | no | no | no | **yes** |
80
- | Diamond resolution | no | n/a | n/a | n/a | partial | **glitch-free** |
81
- | Graph introspection | no | no | visual | checkpoints | no | **describe / observe / diagram** |
82
- | Causal tracing | no | no | no | no | no | **explain every decision** |
83
- | Durable checkpoints | no | no | persistence | yes | no | **file / SQLite / IndexedDB** |
84
- | LLM orchestration | no | no | no | yes | no | **agentLoop / chatStream / toolRegistry** |
85
- | NLgraph composition | no | no | no | no | no | **graphFromSpec / llmCompose** |
86
- | Framework adapters | React | Angular | React / Vue | n/a | varies | **React / Vue / Svelte / Solid / NestJS** |
87
- | Dependencies | 0 | 0 | 0 | many | n/a | **0** |
79
+ | | Zustand / Jotai | RxJS | XState | LangGraph | Archon | Hermes | **GraphReFly** |
80
+ |--|-----------------|------|--------|-----------|--------|--------|---------------|
81
+ | Simple store API | yes | no | no | no | n/a | n/a | **yes** |
82
+ | Streaming operators | no | yes | no | no | no | no | **yes** |
83
+ | Diamond resolution | no | n/a | n/a | n/a | n/a | n/a | **glitch-free** |
84
+ | Graph introspection | no | no | visual | checkpoints | YAML view | no | **describe / observe / diagram** |
85
+ | Causal tracing | no | no | no | no | no | no (black-box) | **explain every decision** |
86
+ | Durable checkpoints | no | no | persistence | yes | sqlite | yes | **file / SQLite / IndexedDB** |
87
+ | LLM orchestration | no | no | no | yes | yes (workflow) | yes (skills) | **agentLoop / chatStream / toolRegistry** |
88
+ | Auto-projection: code spec | no | no | no | no | no (manual YAML) | partial (skill emit) | **factoryTag round-trip** |
89
+ | Multi-agent on shared topology | no | no | no | no | no (worktree-isolated) | no (skill-isolated) | **L0–L3 ownership protocol** |
90
+ | Framework adapters | React | Angular | React / Vue | n/a | n/a | n/a | **React / Vue / Svelte / Solid / NestJS** |
91
+ | Dependencies | 0 | 0 | 0 | many | many | many | **0** |
88
92
 
89
93
  ## One primitive
90
94
 
@@ -1,11 +1,21 @@
1
- "use strict";var ko=Object.create;var Fe=Object.defineProperty;var Bn=Object.getOwnPropertyDescriptor;var Ao=Object.getOwnPropertyNames;var Co=Object.prototype.hasOwnProperty;var Kn=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),nt=r=>{throw TypeError(r)};var Mo=(r,e,t)=>e in r?Fe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var jn=(r,e)=>Fe(r,"name",{value:e,configurable:!0});var F=(r,e)=>()=>(r&&(e=r(r=0)),e);var ce=(r,e)=>{for(var t in e)Fe(r,t,{get:e[t],enumerable:!0})},Do=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ao(e))!Co.call(r,o)&&o!==t&&Fe(r,o,{get:()=>e[o],enumerable:!(n=Bn(e,o))||n.enumerable});return r};var Go=r=>Do(Fe({},"__esModule",{value:!0}),r);var Un=r=>[,,,ko(r?.[Kn("metadata")]??null)],Yn=["class","method","getter","setter","accessor","field","value","get","set"],tt=r=>r!==void 0&&typeof r!="function"?nt("Function expected"):r,Io=(r,e,t,n,o)=>({kind:Yn[r],name:e,metadata:n,addInitializer:s=>t._?nt("Already initialized"):o.push(tt(s||null))}),Po=(r,e)=>Mo(e,Kn("metadata"),r[3]),Jn=(r,e,t,n)=>{for(var o=0,s=r[e>>1],a=s&&s.length;o<a;o++)e&1?s[o].call(t):n=s[o].call(t,n);return n},Qn=(r,e,t,n,o,s)=>{var a,i,d,u,c,l=e&7,p=!!(e&8),h=!!(e&16),f=l>3?r.length+1:l?p?1:2:0,m=Yn[l+5],g=l>3&&(r[f-1]=[]),R=r[f]||(r[f]=[]),v=l&&(!h&&!p&&(o=o.prototype),l<5&&(l>3||!h)&&Bn(l<4?o:{get[t](){return zn(this,s)},set[t](b){return Wn(this,s,b)}},t));l?h&&l<4&&jn(s,(l>2?"set ":l>1?"get ":"")+t):jn(o,t);for(var _=n.length-1;_>=0;_--)u=Io(l,t,d={},r[3],R),l&&(u.static=p,u.private=h,c=u.access={has:h?b=>Lo(o,b):b=>t in b},l^3&&(c.get=h?b=>(l^1?zn:$o)(b,o,l^4?s:v.get):b=>b[t]),l>2&&(c.set=h?(b,T)=>Wn(b,o,T,l^4?s:v.set):(b,T)=>b[t]=T)),i=(0,n[_])(l?l<4?h?s:v[m]:l>4?void 0:{get:v.get,set:v.set}:o,u),d._=1,l^4||i===void 0?tt(i)&&(l>4?g.unshift(i):l?h?s=i:v[m]=i:o=i):typeof i!="object"||i===null?nt("Object expected"):(tt(a=i.get)&&(v.get=a),tt(a=i.set)&&(v.set=a),tt(a=i.init)&&g.unshift(a));return l||Po(r,o),v&&Fe(o,t,v),h?l^4?s:v:o};var Qt=(r,e,t)=>e.has(r)||nt("Cannot "+t),Lo=(r,e)=>Object(e)!==e?nt('Cannot use the "in" operator on this value'):r.has(e),zn=(r,e,t)=>(Qt(r,e,"read from private field"),t?t.call(r):e.get(r));var Wn=(r,e,t,n)=>(Qt(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),$o=(r,e,t)=>(Qt(r,e,"access private method"),t);var we,N,I,W,re,ee,oe,H,P,D,Re,_t,Zn,Tt,Xn,er,wt,Zt,Xt,en,Rt,B=F(()=>{"use strict";we=Symbol.for("graphrefly/START"),N=Symbol.for("graphrefly/DATA"),I=Symbol.for("graphrefly/DIRTY"),W=Symbol.for("graphrefly/RESOLVED"),re=Symbol.for("graphrefly/INVALIDATE"),ee=Symbol.for("graphrefly/PAUSE"),oe=Symbol.for("graphrefly/RESUME"),H=Symbol.for("graphrefly/TEARDOWN"),P=Symbol.for("graphrefly/COMPLETE"),D=Symbol.for("graphrefly/ERROR"),Re=Object.freeze([I]),_t=Object.freeze([W]),Zn=Object.freeze([re]),Tt=Object.freeze([we]),Xn=Object.freeze([P]),er=Object.freeze([H]),wt=Object.freeze([Re]),Zt=Object.freeze([_t]),Xt=Object.freeze([Zn]),en=Object.freeze([Xn]),Rt=Object.freeze([er])});function nr(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),a=0;return s[a++]=tn,s[a++]=t.length,s.set(t,a),a+=t.length,s[a++]=n>>>8&255,s[a++]=n&255,s.set(e,a),s}function rr(r,e){if(r.length<tr)throw new Error(`decodeEnvelope: bytes too short (${r.length} < ${tr})`);let t=0,n=r[t++];if(n!==tn)throw new Error(`decodeEnvelope: unsupported envelope version ${n} (expected ${tn})`);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 a=(r[t]<<8|r[t+1])>>>0;t+=2;let i=r.subarray(t),d=e.lookupCodec(s);if(d==null)throw new Error(`decodeEnvelope: codec "${s}" not registered (envelope codec_v=${a})`);return{codec:d,codecVersion:a,payload:i}}function or(r){r.registerCodec(Fo)}var Fo,tn,tr,nn=F(()=>{"use strict";Fo={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)}},tn=1,tr=4});function xe(r){if(r==null)return be;let{type:e,id:t,...n}=r;return{type:e??"system",id:t??"",...n}}var be,rt=F(()=>{"use strict";be={type:"system",id:""}});function xt(){return Ve>0||ot}function sr(){return Ve>0}function qe(r){Ve>0?st.push(r):r()}function le(r){Ve+=1;let e=!1;try{r()}catch(t){throw e=!0,t}finally{if(Ve-=1,Ve===0)if(e){if(!ot){let t=st.splice(0);for(let n of t)try{n()}catch{}Ee.length=0,Ne.length=0,He.length=0}}else Vo()}}function Vo(){let r=!ot;r&&(ot=!0);let e=[],t=0;try{for(;Ee.length>0||Ne.length>0||He.length>0||r&&st.length>0;){if(r&&st.length>0){let s=st.splice(0);for(let a of s)try{a()}catch(i){e.push(i)}continue}if(t+=1,t>1e3)throw Ee.length=0,Ne.length=0,He.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(Ee.length>0?Ee:Ne.length>0?Ne:He).splice(0);for(let s of o)try{s()}catch(a){e.push(a)}}}finally{r&&(ot=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Et(r,e,t){if(e.length===0)return;if(e.length===1){let u=t(e[0][0]);if(u<3||!xt()){r(e);return}(u>=5?He:u===4?Ne:Ee).push(()=>r(e));return}let n=e.length,o=n,s=n,a=n,i=0;for(;i<n&&t(e[i][0])<3;)i++;for(o=i;i<n&&t(e[i][0])===3;)i++;for(s=i;i<n&&t(e[i][0])===4;)i++;a=i;let d=xt();if(o>0){let u=e.slice(0,o);r(u)}if(s>o){let u=e.slice(o,s);d?Ee.push(()=>r(u)):r(u)}if(a>s){let u=e.slice(s,a);d?Ne.push(()=>r(u)):r(u)}if(n>a){let u=e.slice(a,n);d?He.push(()=>r(u)):r(u)}}var Ve,ot,Ee,Ne,He,st,Oe=F(()=>{"use strict";Ve=0,ot=!1,Ee=[],Ne=[],He=[],st=[]});function pe(){return Math.trunc(performance.now()*1e6)}function se(){return Date.now()*1e6}var Se=F(()=>{"use strict"});function ir(r){r.registerMessageType(we,{tier:0,wireCrossing:!1}),r.registerMessageType(I,{tier:1,wireCrossing:!1}),r.registerMessageType(re,{tier:1,wireCrossing:!1,metaPassthrough:!1}),r.registerMessageType(ee,{tier:2,wireCrossing:!1}),r.registerMessageType(oe,{tier:2,wireCrossing:!1}),r.registerMessageType(N,{tier:3,wireCrossing:!0}),r.registerMessageType(W,{tier:3,wireCrossing:!0}),r.registerMessageType(P,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(D,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(H,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Nt,ar=F(()=>{"use strict";B();Nt=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=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}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=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 dr(r){return Array.isArray(r)?[...r]:[r]}function Ho(r,e){return r.has(e)||r.has("*")}function je(r){let e=[];return r((o,s)=>{e.push({kind:"allow",actions:new Set(dr(o)),where:s?.where??(()=>!0)})},(o,s)=>{e.push({kind:"deny",actions:new Set(dr(o)),where:s?.where??(()=>!0)})}),(o,s)=>{let a=!1,i=!1;for(let d of e)Ho(d.actions,s)&&d.where(o)&&(d.kind==="deny"?a=!0:i=!0);return a?!1:i}}function rn(r){let e=qo.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 ie,qo,ke=F(()=>{"use strict";ie=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}};qo=["human","llm","wallet","system"]});function on(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(on);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=on(r[t]);return e}return null}function Wo(r){let e=zo.encode(r),t=e.length,n=t*8,o=t+9+63&-64,s=new Uint8Array(o);s.set(e),s[t]=128;let a=new DataView(s.buffer);a.setUint32(o-4,n>>>0,!1),a.setUint32(o-8,Math.floor(n/4294967296)>>>0,!1);let i=1779033703,d=3144134277,u=1013904242,c=2773480762,l=1359893119,p=2600822924,h=528734635,f=1541459225,m=new Uint32Array(64),g=(v,_)=>v>>>_|v<<32-_;for(let v=0;v<o;v+=64){for(let w=0;w<16;w++)m[w]=a.getUint32(v+w*4,!1);for(let w=16;w<64;w++){let k=m[w-15],M=m[w-2],A=g(k,7)^g(k,18)^k>>>3,j=g(M,17)^g(M,19)^M>>>10;m[w]=m[w-16]+A+m[w-7]+j>>>0}let _=i,b=d,T=u,O=c,y=l,x=p,S=h,E=f;for(let w=0;w<64;w++){let k=g(y,6)^g(y,11)^g(y,25),M=y&x^~y&S,A=E+k+M+jo[w]+m[w]>>>0,j=g(_,2)^g(_,13)^g(_,22),U=_&b^_&T^b&T,X=j+U>>>0;E=S,S=x,x=y,y=O+A>>>0,O=T,T=b,b=_,_=A+X>>>0}i=i+_>>>0,d=d+b>>>0,u=u+T>>>0,c=c+O>>>0,l=l+y>>>0,p=p+x>>>0,h=h+S>>>0,f=f+E>>>0}let R=v=>v.toString(16).padStart(8,"0");return R(i)+R(d)+R(u)+R(c)+R(l)+R(p)+R(h)+R(f)}function sn(r){let e=on(r??null),t=JSON.stringify(e);return Wo(t).slice(0,16)}function Bo(){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 an(r,e,t){let n=t?.id??Bo();if(r===0)return{id:n,version:0};let s=(t?.hash??sn)(e);return{id:n,version:0,cid:s,prev:null}}function ur(r,e,t){r.version+=1,"cid"in r&&(r.prev=r.cid,r.cid=t(e))}var jo,zo,cr=F(()=>{"use strict";jo=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]),zo=new TextEncoder});function pr(r){return{node:r,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function dn(r){r.prevData=void 0,r.dirty=!1,r.involvedThisWave=!1,r.dataBatch.length=0,r.terminal=void 0}function Ot(r){return r.length===0?r:typeof r[0]=="symbol"?[r]:r}function he(r,e,t){let n=hr(r)?r:[],o=typeof r=="function"?r:typeof e=="function"?e:void 0,s={};return hr(r)?s=(un(e)?e:t)??{}:un(r)?s=r:s=(un(e)?e:t)??{},new q(n,o,s)}var lr,fr,Ko,Uo,Ae,q,hr,un,Ce=F(()=>{"use strict";nn();rt();Oe();Se();ar();ke();B();cr();lr=()=>{},fr=100;Ko=(r,e,t,n)=>{t.direction==="down-in"&&r._onDepMessage(t.depIndex,e)},Uo=(r,e,t,n)=>{let o=r;if(o._status==="completed"||o._status==="errored")return;let s=o._cached,a=s===void 0?[Tt]:[Tt,[N,s]];o._status==="dirty"&&a.push(Re),Et(e,a,o._config.tierOf)},Ae=new Nt({onMessage:Ko,onSubscribe:Uo});ir(Ae);or(Ae);q=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;_partial;_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._partial=n.partial??!1,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??sn;let o=n.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?an(o,this._cached===void 0?void 0:this._cached,{id:n.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(pr);let s={};for(let[i,d]of Object.entries(n.meta??{})){let u={initial:d,name:`${n.name??"node"}:meta:${i}`,describeKind:"state",config:this._config};n.guard!=null&&(u.guard=n.guard),s[i]=new r([],void 0,u)}Object.freeze(s),this.meta=s,this._hasMeta=Object.keys(s).length>0;let a=this;this._actions={emit(i){a._emit([[N,i]])},down(i){a._emit(Ot(i))},up(i){a._emitUp(Ot(i))}},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,a=this._versioning,i=a?.id??t?.id,d=a?.version??0,u=an(e,s,{id:i,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=xe(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=xe(e?.actor),s=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,s))throw new ie({actor:o,action:s,nodeName:this.name});if(this._extraGuards!=null){for(let a of this._extraGuards)if(!a(o,s))throw new ie({actor:o,action:s,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:se()}}down(e,t){let n=Ot(e);n.length!==0&&(this._checkGuard(t),this._emit(n))}emit(e,t){this._checkGuard(t),this._emit([[N,e]])}up(e,t){if(this._deps.length===0)return;let n=Ot(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=xe(t);if(!this._guard(d,"observe"))throw new ie({actor:d,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)dn(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let s;try{s=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:o},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let a=this._isTerminal;if(this._sinkCount===1&&!a)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 i=!1;return()=>{i||(i=!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=lr,s.unsub=s.node.subscribe(a=>{if(s.unsub===null)return;let i=this._config.tierOf,d=!1;for(let u of a)i(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 a=s.unsub;s.unsub=null;try{a()}catch{}dn(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=pr(e);if(this._deps.push(n),this._sinks==null)return t;n.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(wt),n.unsub=lr;try{n.unsub=e.subscribe(o=>{if(n.unsub===null)return;let s=this._config.tierOf,a=!1;for(let i of o)s(i[0])>=3&&(a=!0),this._config.onMessage(this,i,{direction:"down-in",depIndex:t},this._actions);a&&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([[D,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([[D,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{}}dn(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 a of this._inspectorHooks)a(s)}if(o!==we){if(o===I){this._depDirtied(n);return}if(o===re){if(this._depInvalidated(n),this._cached===void 0)return;this._emit(Xt);return}if(o===ee||o===oe){this._emit([t]);return}if(o===H){this._emit(Rt);return}if(o===N)this._depSettledAsData(n,t[1]);else if(o===W)this._depSettledAsResolved(n);else if(o===P)this._depSettledAsTerminal(n,!0);else if(o===D)this._depSettledAsTerminal(n,t[1]);else{this._emit([t]);return}if(!this._fn){(o===N||o===W)&&this._emit([t]),(o===P||o===D)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(wt))}_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._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let t=this._deps[e];if(t.dataBatch.length===0&&t.prevData===void 0&&t.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Zt),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([[D,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(en)}_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(a){this._emit([[D,this._wrapFnError("cleanup threw",a)]]);return}}else if(e!=null&&typeof e=="object"){let a=e.beforeRun;if(typeof a=="function"){e.beforeRun=void 0;try{a()}catch(i){this._emit([[D,this._wrapFnError("cleanup.beforeRun threw",i)]]);return}}}let t=this._deps.map(a=>a.involvedThisWave?a.dataBatch.length>0?[...a.dataBatch]:[]:void 0),n=this._deps.map(a=>a.prevData);for(let a=0;a<this._deps.length;a++){let i=t[a];i!=null&&i.length>0&&(this._deps[a].prevData=i[i.length-1])}let o=this._deps.map(a=>a.terminal),s={prevData:n,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let a={kind:"run",batchData:t,prevData:n};for(let i of this._inspectorHooks)i(a)}this._isExecutingFn=!0;try{let a=this._fn(t,this._actions,s);if(typeof a=="function")this._cleanup=a;else if(a!=null&&typeof a=="object"){let i=a;(typeof i.beforeRun=="function"||typeof i.deactivate=="function"||typeof i.invalidate=="function")&&(this._cleanup=a)}}catch(a){this._emit([[D,this._wrapFnError("fn threw",a)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>fr?(this._rerunDepth=0,this._emit([[D,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${fr} \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"?[Re,e[0]]:e;let n=!0,o=!1,s=!1,a=-1;for(let d of e){let u=t(d[0]);u<a&&(n=!1),u===3&&(o=!0),d[0]===I&&(s=!0),a=u}let i=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),i=d.map(u=>u.m)}if(o&&!s&&this._status!=="dirty"){let d=0;for(;d<i.length&&t(i[d][0])===0;)d++;return d===0?[Re,...i]:[...i.slice(0,d),Re,...i.slice(d)]}return i}_emit(e){if(e.length===0)return;for(let i=0;i<e.length;i++){let d=e[i];if(d[0]===D&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let i=e.filter(d=>d[0]===H||d[0]===re);if(i.length===0)return;t=i}t=this._frameBatch(t);let o=null;for(let i=0;i<t.length;i++){let d=t[i],u=d[0];if(u!==ee&&u!==oe){o?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===ee?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let l=d[1];if(u===ee)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(l),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(l))c=!1;else if(this._pauseLocks.delete(l),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?o?.push(d):o==null&&(o=t.slice(0,i))}if(o!=null){if(o.length===0)return;t=o}if(this._hasMeta&&t.some(i=>i[0]===H))for(let i of Object.keys(this.meta))try{this.meta[i]._emit(Rt)}catch{}let{finalMessages:s,equalsError:a}=this._updateState(t);if(s.length>0&&this._config.inspectorEnabled){let i=this._config.globalInspector;if(i!=null)try{i({kind:"emit",node:this,messages:s})}catch{}}if(s.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let i=this._config.tierOf,d=[];for(let u of s)i(u[0])===3?this._pauseBuffer.push(u):d.push(u);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(s);a!=null&&this._emit([[D,a]])}_updateState(e){let t=this._config.tierOf,n,o,s=-1,a=0;for(let c of e)t(c[0])===3&&a++;let i=a<=1,d=-1;if(this._versioning!=null&&a>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===N){d=c;break}}for(let c=0;c<e.length;c++){let l=e[c],p=l[0];if(p===N){if(l.length>=2){let h=!1;if(i&&this._cached!==void 0)try{h=this._equals(this._cached,l[1])}catch(f){o=this._wrapFnError("equals threw",f),s=c;break}if(h){n==null&&(n=e.slice(0,c)),n.push(_t),this._status="resolved";continue}this._cached=l[1],this._versioning!=null&&(d<0||c===d)&&ur(this._versioning,l[1],this._hashFn)}this._status="settled",n?.push(l)}else if(n?.push(l),p===I)this._status="dirty";else if(p===W)this._status="resolved";else if(p===P){this._status="completed";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===D){this._status="errored";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===re){if(this._cached!==void 0){let f=this._config.rigorRecorder;if(f!=null)try{f.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let f=h.invalidate;if(typeof f=="function")try{f()}catch{}}}else p===H&&(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(sr()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],qe(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}Et(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);Et(this._deliverToSinks,t,this._config.tierOf)}},hr=r=>Array.isArray(r),un=r=>typeof r=="object"&&r!=null&&!Array.isArray(r)});function V(r,e){return he([],{...e,initial:r})}function Me(r,e){return he((n,o,s)=>r(o,s)??void 0,{describeKind:"producer",...e})}function J(r,e,t){return he(r,(o,s,a)=>{let i=o.map((d,u)=>d!=null&&d.length>0?d.at(-1):a.prevData[u]);s.emit(e(i,a))},{describeKind:"derived",...t})}function cn(r,e,t){let n=new Map;return r.forEach((o,s)=>{n.set(o,s)}),J(r,(o,s)=>e(i=>{let d=n.get(i);if(d==null)throw new Error(`dynamicNode: untracked dep "${i.name??"<unnamed>"}"`);return o[d]},s),t)}function it(r,e){let t,n=new Map,o=(s,a,i)=>{let d=!1,u=c=>{let l=n.get(c);if(l!==void 0){if(l<s.length){let h=s[l];return h!=null&&h.length>0?h.at(-1):i.prevData[l]}return c.cache}d=!0;let p=t._addDep(c);return n.set(c,p),c.cache};try{let c=r(u,i);d||(a.emit(c),i.store.__autoTrackLastDiscoveryError!=null&&delete i.store.__autoTrackLastDiscoveryError)}catch(c){if(!d)throw c;i.store.__autoTrackLastDiscoveryError=c}};return t=new q([],o,{describeKind:"derived",...e}),t}var fe=F(()=>{"use strict";Ce()});function ut(r,e,t){let n=new Set;for(let o of r.split(",")){let[s,a]=o.split("/"),i=a?Number.parseInt(a,10):1;if(Number.isNaN(i)||i<1)throw new Error(`Invalid cron step: ${o}`);let d,u;if(s==="*")d=e,u=t;else if(s.includes("-")){let[c,l]=s.split("-");d=Number.parseInt(c,10),u=Number.parseInt(l,10)}else d=Number.parseInt(s,10),u=d;if(Number.isNaN(d)||Number.isNaN(u))throw new Error(`Invalid cron field: ${r}`);if(d<e||u>t)throw new Error(`Cron field out of range: ${r} (${e}-${t})`);if(d>u)throw new Error(`Invalid cron range: ${d}-${u} in ${r}`);for(let c=d;c<=u;c+=i)n.add(c)}return n}function Cr(r){let e=r.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:ut(e[0],0,59),hours:ut(e[1],0,23),daysOfMonth:ut(e[2],1,31),months:ut(e[3],1,12),daysOfWeek:ut(e[4],0,6)}}function Mr(r,e){return r.minutes.has(e.getMinutes())&&r.hours.has(e.getHours())&&r.daysOfMonth.has(e.getDate())&&r.months.has(e.getMonth()+1)&&r.daysOfWeek.has(e.getDay())}var Dr=F(()=>{"use strict"});function Gr(r){return{describeKind:"producer",...r}}function Ir(r,e){let{signal:t,period:n,...o}=e??{};return Me(s=>{let a=!1,i=0,d,u,c=()=>{a=!0,d!==void 0&&clearTimeout(d),u!==void 0&&clearInterval(u),t?.removeEventListener("abort",p)},l=()=>{a||(n!=null?(s.emit(i++),u=setInterval(()=>{a||s.emit(i++)},n)):(a=!0,t?.removeEventListener("abort",p),s.emit(i++),s.down([[P]])))},p=()=>{a||(c(),s.down([[D,t.reason]]))};if(t?.aborted){p();return}return d=setTimeout(l,r),t?.addEventListener("abort",p,{once:!0}),c},Gr(o))}function Pr(r,e){let t=Cr(r),{tickMs:n,output:o,...s}=e??{},a=n??6e4,i=o==="date";return Me(d=>{let u=-1,c=()=>{let p=new Date,h=p.getFullYear()*1e8+(p.getMonth()+1)*1e6+p.getDate()*1e4+p.getHours()*100+p.getMinutes();h!==u&&Mr(t,p)&&(u=h,d.emit(i?p:se()))};c();let l=setInterval(c,a);return()=>clearInterval(l)},{...Gr(s),name:s.name??`cron:${r}`})}function ge(r){return r.subscribe(()=>{})}var Lr=F(()=>{"use strict";Se();B();fe();Dr()});var Ct=F(()=>{"use strict";Lr()});function It(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;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function as(r){return r._describeKind!=null?r._describeKind:r._deps.length>0?"derived":r._fn!=null?"producer":"state"}function vn(r){let e=new WeakSet,t={};for(let[n,o]of zr(r))t[n]=bn(o,e);return t}function bn(r,e){if(r==null)return r;let t=typeof r;if(t==="boolean"||t==="number"||t==="string")return r;if(t==="function")return"<function>";if(Array.isArray(r))return e.has(r)?"<cycle>":(e.add(r),r.map(n=>bn(n,e)));if(t==="object"){let n=r;if(e.has(n))return"<cycle>";e.add(n);try{if(typeof n.subscribe=="function"&&"cache"in n)return"<Node>"}catch{return"<unserializable>"}let o={};for(let[s,a]of zr(n))o[s]=bn(a,e);return o}return"<unserializable>"}function zr(r){let e=[],t;try{t=Object.keys(r)}catch{return e}for(let n of t)try{e.push([n,r[n]])}catch{e.push([n,"<unserializable>"])}return e}function ds(r){let e={};for(let[t,n]of Object.entries(r.meta))try{e[t]=n.cache}catch{}return e}function _n(r,e,t){let n=e==null,o=!n&&e!=null?[...e].filter(c=>c.startsWith("meta.")).map(c=>c.slice(5)):null,s=n||e.has("meta")||o!=null&&o.length>0,a="state",i=[];r instanceof q&&(a=as(r),i=r._deps.map(c=>c.node.name??""));let d={type:a,deps:i};(n||e.has("status"))&&(d.status=r.status);let u=r instanceof q?r._guard:void 0;if(s){let c={...ds(r)};if(u!=null&&c.access===void 0&&(c.access=rn(u)),o!=null&&o.length>0&&!e.has("meta")){let l={};for(let p of o)p in c&&(l[p]=c[p]);d.meta=l}else d.meta=c}if(r.name!=null&&(d.name=r.name),(n||e.has("value"))&&(!t||a==="state")){r.status==="sentinel"&&(d.sentinel=!0);try{d.value=r.cache}catch{}}if((n||e.has("v"))&&r.v!=null){let c={id:r.v.id,version:r.v.version};"cid"in r.v&&(c.cid=r.v.cid,c.prev=r.v.prev),d.v=c}return(n||e.has("guard"))&&u!=null&&(d.guard=rn(u)),(n||e.has("lastMutation"))&&r.lastMutation!=null&&(d.lastMutation=r.lastMutation),d}var Tn=F(()=>{"use strict";ke();Ce()});function wn(r,e){if(Object.is(r,e))return!0;if(r==null||e==null||typeof r!="object"||typeof e!="object")return!1;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(let s=0;s<r.length;s++)if(!wn(r[s],e[s]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;let o=new Set(n);for(let s of t)if(!o.has(s)||!wn(r[s],e[s]))return!1;return!0}function Wr(r,e){return`${r}\0${e}`}function Rn(r,e){let t=[],n=new Set(r.subgraphs),o=new Set(e.subgraphs),s=[];for(let g of o)n.has(g)||s.push(g);s.sort();for(let g of s)t.push({type:"subgraph-mounted",path:g});let a=new Set(Object.keys(r.nodes)),i=new Set(Object.keys(e.nodes)),d=[];for(let g of i)a.has(g)||d.push(g);d.sort();for(let g of d)t.push({type:"node-added",path:g,node:{...e.nodes[g]}});let u=[];for(let g of i){if(!a.has(g))continue;let R=r.nodes[g]?.meta,v=e.nodes[g]?.meta;R==null&&v==null||wn(R??{},v??{})||u.push(g)}u.sort();for(let g of u)t.push({type:"node-meta-changed",path:g,prevMeta:r.nodes[g]?.meta??{},nextMeta:e.nodes[g]?.meta??{}});let c=new Map;for(let g of r.edges)c.set(Wr(g.from,g.to),g);let l=new Map;for(let g of e.edges)l.set(Wr(g.from,g.to),g);let p=[];for(let[g,R]of l)c.has(g)||p.push(R);p.sort((g,R)=>g.from<R.from?-1:g.from>R.from?1:g.to<R.to?-1:g.to>R.to?1:0);for(let g of p)t.push({type:"edge-added",from:g.from,to:g.to});let h=[];for(let[g,R]of c)l.has(g)||h.push(R);h.sort((g,R)=>g.from<R.from?-1:g.from>R.from?1:g.to<R.to?-1:g.to>R.to?1:0);for(let g of h)t.push({type:"edge-removed",from:g.from,to:g.to});let f=[];for(let g of a)i.has(g)||f.push(g);f.sort();for(let g of f)t.push({type:"node-removed",path:g});let m=[];for(let g of n)o.has(g)||m.push(g);m.sort();for(let g of m)t.push({type:"subgraph-unmounted",path:g});return{events:t,flushedAt_ns:pe()}}var Br=F(()=>{"use strict";Se()});var Pt,Kr=F(()=>{"use strict";Pt=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 lt,Ur=F(()=>{"use strict";lt=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}}});function Yr(r,e,t,n={}){let o=e in r.nodes,s=t in r.nodes;if(!o)return Lt(e,t,"no-such-from");if(!s)return Lt(e,t,"no-such-to");let a=n.maxDepth;if(a!=null&&(!Number.isInteger(a)||a<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(n.findCycle===!0){let u=us(r,e,n);if(u!=null)return u}let d=$t(e,r.nodes[e],0,n);return Ft(e,t,[d])}if(a===0)return Lt(e,t,"no-path");let i=Jr(r,e,t,a);return i.found?Ft(e,t,Qr(r,i.pathOrder,n)):Lt(e,t,i.truncated?"max-depth-exceeded":"no-path")}function Jr(r,e,t,n){let o=new Map,s=[{path:t,depth:0}],a=new Set([t]),i=0,d=!1;for(;i<s.length;){let l=s[i++];if(l.path===e)break;if(n!=null&&l.depth>=n){let m=r.nodes[l.path];m?.deps&&m.deps.length>0&&(d=!0);continue}let p=r.nodes[l.path];if(p==null)continue;let h=p.deps??[],f=new Map;for(let m=0;m<h.length;m++){let g=h[m];if(!g)continue;let R=f.get(g);R==null&&(R=[],f.set(g,R)),R.push(m)}for(let[m,g]of f)a.has(m)||(a.add(m),o.set(m,{from:l.path,depIndices:g}),s.push({path:m,depth:l.depth+1}))}if(!o.has(e))return{found:!1,pathOrder:[],truncated:d};let u=[{path:e}],c=e;for(;c!==t;){let l=o.get(c);if(l==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=l.depIndices,u.push({path:l.from}),c=l.from}return{found:!0,pathOrder:u,truncated:!1}}function us(r,e,t){let n=r.nodes[e];if(n==null)return null;let o=n.deps??[],s=[];for(let i=0;i<o.length;i++)o[i]===e&&s.push(i);if(s.length>0){let i=$t(e,n,0,t);i.dep_index=s[0];let d=$t(e,n,1,t);return Ft(e,e,[i,d])}let a=null;for(let i=0;i<o.length;i++){let d=o[i];if(!d||d===e)continue;let u=Jr(r,d,e,t.maxDepth);u.found&&(a==null||u.pathOrder.length<a.pathOrder.length)&&(a=u,a={found:!0,pathOrder:[{path:e,depIndices:[i]},...u.pathOrder],truncated:!1})}return a==null?null:Ft(e,e,Qr(r,a.pathOrder,t))}function Qr(r,e,t){return e.map((n,o)=>{let s=r.nodes[n.path],a=$t(n.path,s,o,t);return n.depIndices!=null&&n.depIndices.length>0&&(a.dep_index=n.depIndices[0],n.depIndices.length>1&&(a.dep_indices=[...n.depIndices])),a})}function $t(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 a=n.lastMutations?.get(r)??e.lastMutation;return a!=null&&(o.lastMutation=a),o}function Ft(r,e,t){return Zr(r,e,!0,"ok",t)}function Lt(r,e,t){return Zr(r,e,!1,t,[])}function Zr(r,e,t,n,o){let s=cs(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 cs(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 a of o){let d=` ${a.hop===0?"\xB7":"\u2193"} ${a.path} (${a.type}${a.status?`/${a.status}`:""})`;if(s.push(d),"value"in a&&s.push(` value: ${ls(a.value)}`),a.annotation!=null&&s.push(` annotation: ${a.annotation}`),a.lastMutation!=null){let u=a.lastMutation.actor;s.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return s.join(`
2
- `)}function ls(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)}}var Xr=F(()=>{"use strict"});function eo(r){let e=new WeakSet,t=new WeakSet,n=[r],o=0;for(;n.length>0;){let s=n.pop();o+=ps(s,e,t,n)}return o}function ps(r,e,t,n){if(r==null)return 0;switch(typeof r){case"number":return K.number;case"boolean":return K.boolean;case"string":return K.string+r.length*2;case"bigint":return K.bigint+hs(r);case"symbol":return K.symbol;case"function":return e.has(r)?0:(e.add(r),K.function);case"undefined":return 0}let s=r;if(e.has(s))return 0;e.add(s);let a=s[fs];if(typeof a=="function")try{let u=a.call(s);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(s instanceof Date)return K.date;if(s instanceof RegExp)return K.regexp+s.source.length*2;if(s instanceof Error){let u=s.message?s.message.length*2:0,c=s.stack?s.stack.length*2:0;return K.error+u+c}if(typeof URL<"u"&&s instanceof URL)return K.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return K.promise;if(s instanceof WeakMap)return K.weakmap;if(s instanceof WeakSet)return K.weakset;if(s instanceof Map){let u=K.map;for(let[c,l]of s)u+=K.mapEntry,n.push(c),n.push(l);return u}if(s instanceof Set){let u=K.set;for(let c of s)u+=K.setEntry,n.push(c);return u}if(Array.isArray(s)){let u=K.array+s.length*8;for(let c of s)n.push(c);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 i=K.object,d=Object.keys(s);for(let u of d){i+=K.string+u.length*2;try{n.push(s[u])}catch{}}return i}function hs(r){let e=r<0n?-r:r;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}var K,fs,to=F(()=>{"use strict";K={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},fs=Symbol.for("sizeof")});function no(r,e){let t=e?.topN??10,n=r.describe({detail:"standard"}),o=[],s=r._collectObserveTargets;typeof s=="function"&&s.call(r,"",o);let a=new Map;for(let[p,h]of o)a.set(p,h);let i=[];for(let[p,h]of Object.entries(n.nodes)){let f=a.get(p),m=f instanceof q?f:null,g=m?eo(m.cache):0,R=m?m._sinkCount:0,v=h.deps?.length??0,_=h.type==="effect"&&R===0,b=R===0?h.type==="effect"?"orphan-effect":h.type==="derived"?"idle-derived":h.type==="producer"?"idle-producer":null:null;i.push({path:p,type:h.type,status:h.status??"unknown",valueSizeBytes:g,subscriberCount:R,depCount:v,isOrphanEffect:_,orphanKind:b})}let d=i.reduce((p,h)=>p+h.valueSizeBytes,0),u=(p,h)=>[...i].sort(h??((f,m)=>m[p]-f[p])).slice(0,t),c=i.filter(p=>p.orphanKind!=null),l=i.filter(p=>p.isOrphanEffect);return{nodeCount:i.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:i,totalValueSizeBytes:d,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:c,orphanEffects:l}}var ro=F(()=>{"use strict";Ce();to()});function oo(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(a){console.error(`[Graph "${e}".destroy] disposer threw:`,a)}}}function co(r){return r!=null&&typeof r=="object"&&"cache"in r&&typeof r.subscribe=="function"&&typeof r.down=="function"}function gs(r){if(r!=null)return co(r)?r.cache:r}function Pe(r){return r!=null&&typeof r=="object"&&"cache"in r&&typeof r.subscribe=="function"&&typeof r.down=="function"}function ve(r){return Pe(r)?r.cache??"":r}function so(r){return Pe(r)?r.cache??0:r}function io(r){return Pe(r)?r.cache??!1:r}function ms(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 ao(r){if(r.version!==Ie)throw new Error(`unsupported snapshot version ${String(r.version)} (expected ${Ie})`);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 ys(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 a=t.get(o);if(a==null&&(a=new WeakSet,t.set(o,a)),a.has(s))return!0;a.add(s);let i=o.constructor,d=s.constructor;if(i!==d)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let p=s;if(o.length!==p.length)return!1;for(let h=0;h<o.length;h++)if(!n(o[h],p[h]))return!1;return!0}if(o instanceof Map){let p=s;if(o.size!==p.size)return!1;for(let[h,f]of o)if(!p.has(h)||!n(f,p.get(h)))return!1;return!0}if(o instanceof Set){let p=s;if(o.size!==p.size)return!1;for(let h of o){let f=!1;for(let m of p)if(n(h,m)){f=!0;break}if(!f)return!1}return!0}if(ArrayBuffer.isView(o)){let p=o,h=s;if(p.length!==h.length)return!1;for(let f=0;f<p.length;f++)if(p[f]!==h[f])return!1;return!0}let u=Object.keys(o),c=Object.keys(s);if(u.length!==c.length)return!1;let l=new Set(c);for(let p of u)if(!l.has(p)||!n(o[p],s[p]))return!1;return!0};return n(r,e)}function bs(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Vt(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+=bs(n)}return e+="$",new RegExp(e)}function xn(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 Ts(r){return r==="none"?_s:r==="ansi"||r==null?vs:{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 uo(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 ws(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 En(r,e,t){if(r==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(r.includes($))throw new Error(`Graph "${e}": ${t} "${r}" must not contain '${$}' (path separator)`);if(r===de)throw new Error(`Graph "${e}": ${t} name "${de}" is reserved for meta companion paths`);ws(r,e,t)}function Rs(r,e){if(r==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=r.split($);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function xs(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 lo(r){for(let e of r._mounts.values())lo(e);for(let e of r._nodes.values())try{e.down([[H]],{internal:!0})}catch{}}function fo(r,e){let t=Z.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 Nn(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 a=new Map,i=new Map,d=new Map,u=new Map,c=new Set;for(let[_,b]of Object.entries(r.nodes)){if(!_)continue;c.add(_);let T=b.deps??[];a.set(_,T);for(let O of T)O&&(c.add(O),i.has(O)||i.set(O,new Set),i.get(O).add(_))}for(let _ of r.edges){if(_==null||typeof _!="object")continue;let b=typeof _.from=="string"?_.from:"",T=typeof _.to=="string"?_.to:"";!b||!T||(c.add(b),c.add(T),u.has(b)||u.set(b,new Set),u.get(b).add(T),d.has(T)||d.set(T,new Set),d.get(T).add(b))}if(!c.has(e))return n.withDetail?o:[];let l=n.both===!0,p=_=>{if(l){let y=a.get(_)??[],x=d.get(_),S=i.get(_),E=u.get(_),w=[...y];return x&&w.push(...x),S&&w.push(...S),E&&w.push(...E),w}if(t==="upstream"){let y=a.get(_)??[],x=d.get(_);return x?[...y,...x]:y}let b=i.get(_),T=u.get(_),O=b?[...b]:[];return T&&O.push(...T),O},h=new Set([e]),f=new Map,m=[{path:e,depth:0}],g=0,R=!1;for(;g<m.length;){let _=m[g++];if(s!=null&&_.depth>=s){p(_.path).length>0&&(R=!0);continue}for(let b of p(_.path))!b||h.has(b)||(h.add(b),f.set(b,_.depth+1),m.push({path:b,depth:_.depth+1}))}let v=[...f.keys()].sort((_,b)=>_<b?-1:_>b?1:0);return n.withDetail?{paths:v,depths:f,truncated:R}:v}function Es(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,a=o.v;if(s!==a&&(s==null||a==null||s.id!==a.id||s.version!==a.version))return!1}return!0}var $,de,Ie,vs,_s,Z,ft=F(()=>{"use strict";rt();Oe();Se();ke();B();Tn();Ce();fe();Br();Ct();Kr();Ur();nn();Xr();ro();$="::",de="__meta__",Ie=1;vs={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"},_s={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};Z=class r{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes($))throw new Error(`Graph name must not contain '${$}' (got "${e}")`);if(e===de)throw new Error(`Graph name "${de}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??Ae,this._traceRing=new lt(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning),typeof t?.factory=="string"&&(this._factory=t.factory,t.factoryArgs!==void 0&&(this._factoryArgs=t.factoryArgs))}tagFactory(e,t){return this._factory=e,this._factoryArgs=t,this}ancestors(e=!0){let t=[],n=e?this:this._parent;for(;n!=null;)t.push(n),n=n._parent;return t}get topology(){return this._topology==null&&(this._topology=Me(e=>{let t=n=>{e.emit(n)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let n=e.name,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,a=t?.annotation;if(En(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 i=this._nodeToName.get(e);if(i!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${i}"`);return this._nodes.set(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),a!=null&&(this._annotations.set(s,a),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:a,timestamp_ns:pe()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof q&&t._applyVersioning(e)}remove(e){En(e,this.name,"remove");let t=this._mounts.get(e);if(t){let s={kind:"mount",nodes:[],mounts:[]},a=[];t._collectObserveTargets("",a);for(let[i,d]of a)i.includes(`${$}${de}${$}`)||s.nodes.push(i);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...t._collectSubgraphs(`${e}${$}`)),this._mounts.delete(e),t._parent=void 0,lo(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([[H]],{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=Vt(e);return a=>s.test(a)})(),n={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>t(s));for(let s of o){let a=this.remove(s);n.nodes.push(...a.nodes),n.mounts.push(...a.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($))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([[N,t]],{actor:n?.actor,internal:o,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);le(()=>{for(let[o,s]of n)this.set(o,s,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[re]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let o=n?.internal===!0;this.node(e).down([[D,t]],{actor:n?.actor,internal:o,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[P]],{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 i=[];for(let[d,u]of this._nodes)if(u instanceof q)for(let c of u._deps){let l=n.get(c.node);l!=null&&i.push([l,d])}return i.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),i}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[i,d]of o)s.set(d,i);let a=[];for(let[i,d]of o)if(d instanceof q)for(let u of d._deps){let c=s.get(u.node);c!=null&&a.push([c,i])}return a.sort((i,d)=>i[0]<d[0]?-1:i[0]>d[0]?1:i[1]<d[1]?-1:i[1]>d[1]?1:0),a}mount(e,t){if(t===void 0){let o=new r(e);return this.mount(e,o)}if(typeof t=="function"){let o=new r(e);return t(o),this.mount(e,o)}let n=t;if(En(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let o=this;o!=null;o=o._parent)if(o===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let t=Rs(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 i=this._nodes.get(n);if(i)return i;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]===de)return this._resolveMetaChainFromNode(s,o,t.join($));let a=this._mounts.get(n);if(!a)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${o.join($)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return a.resolve(o.join($))}_resolveMetaChainFromNode(e,t,n){let o=e,s=0,a=[...t];for(;s<a.length;){if(a[s]!==de)throw new Error(`Graph "${this.name}": expected ${de} segment in meta path "${n}"`);if(s+1>=a.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${de} in "${n}"`);let i=a[s+1],d=o.meta[i];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${i}" 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 a=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},i=xs(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,a)}catch(c){if(c instanceof ie)throw c;o.push(c)}i.length!==0&&this._signalMetaSubtree(u,i,n,a,o)}}}_signalMetaSubtree(e,t,n,o,s){for(let a of Object.keys(e.meta).sort()){let i=e.meta[a];if(!n.has(i)){n.add(i);try{i.down(t,o)}catch(d){if(d instanceof ie)throw d;s.push(d)}this._signalMetaSubtree(i,t,n,o,s)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=gs(e?.actor),n=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let o=It(e?.detail,e?.fields),s=e?.detail==="spec",a=o,i=[];this._collectObserveTargets("",i);let d=new Map;for(let[b,T]of i)d.set(T,b);let u=[];{let b=i.map(([,y])=>y),T=new Set(d.values()),O=0;for(;b.length>0;){let y=b.shift();if(y instanceof q)for(let x of y._deps){let S=x.node;if(d.has(S))continue;let E=S.name??"",w=E;if(!w||T.has(w))if(E){let k=2;for(;T.has(`${E}#${k}`);)k++;w=`${E}#${k}`}else for(w=`__internal__/${O++}`;T.has(w);)w=`__internal__/${O++}`;d.set(S,w),T.add(w),u.push([w,S]),b.push(S)}}}let c=[...i,...u],l={};for(let[b,T]of c){if(t!=null&&!T.allowsObserve(t))continue;let O=_n(T,a,s),y=T instanceof q?T._deps.map(w=>d.get(w.node)??w.node.name??""):[],{name:x,...S}=O,E={...S,deps:y};if(!s){let w=this._annotations.get(b);w!=null&&(E.annotation=w)}if(n!=null)if(typeof n=="function"){let w=n;if(!(w.length>=2?w(b,E):w(E)))continue}else{let w=!0;for(let[k,M]of Object.entries(n)){let A=k==="deps_includes"?"depsIncludes":k==="meta_has"?"metaHas":k;if(A==="depsIncludes"){if(!E.deps.includes(String(M))){w=!1;break}continue}if(A==="metaHas"){if(!Object.hasOwn(E.meta??{},String(M))){w=!1;break}continue}if(E[A]!==M){w=!1;break}}if(!w)continue}l[b]=E}let p=new Set(Object.keys(l)),h=[];for(let[b,T]of c)if(T instanceof q)for(let O of T._deps){let y=d.get(O.node);y!=null&&h.push([y,b])}h.sort((b,T)=>b[0]<T[0]?-1:b[0]>T[0]?1:b[1]<T[1]?-1:b[1]>T[1]?1:0);let f=h.map(([b,T])=>({from:b,to:T}));(t!=null||n!=null)&&(f=f.filter(b=>p.has(b.from)&&p.has(b.to)));let m=this._collectSubgraphs(""),g=t!=null||n!=null?m.filter(b=>{let T=`${b}${$}`;return[...p].some(O=>O===b||O.startsWith(T))}):m,R=this,v=e;return{name:this.name,nodes:l,edges:f,subgraphs:g,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(b){let T={...v};return Array.isArray(b)?(T.fields=b,T.detail=void 0):(T.detail=b,T.fields=void 0),R.describe(T)}}}_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}${$}`))}return t}resourceProfile(e){return no(this,e)}reachable(e,t,n={}){return n.withDetail===!0?Nn(this.describe(),e,t,{...n,withDetail:!0}):Nn(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(ve(e),ve(t),{...n?.maxDepth!==void 0?{maxDepth:so(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:io(n.findCycle)}:{}})}_explainStatic(e,t,n){let o=this.describe({detail:"full"}),s=new Map(this._annotations),a=new Map;for(let[i,d]of Object.entries(o.nodes))d.lastMutation!=null&&a.set(i,d.lastMutation);return Yr(o,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:a})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",o=0,s=V(o,{name:`${n}_version`}),a=this.observe({timeline:!0,structured:!0}),i=!1,d=!1,u=()=>{i||d||(i=!0,qe(()=>{i=!1,!d&&(o+=1,s.emit(o))}))},c=a.onEvent(v=>{let _=v.type;_!=="data"&&_!=="error"&&_!=="complete"&&_!=="teardown"||u()}),l=[],p=new WeakSet,h=v=>{if(p.has(v)||d)return;p.add(v);let _=v.topology.subscribe(b=>{for(let T of b){if(T[0]!==N)continue;let O=T[1];if(u(),O.kind==="added"&&O.nodeKind==="mount"){let y=v._mounts.get(O.name);y!=null&&h(y)}}});l.push(_);for(let b of v._mounts.keys()){let T=v._mounts.get(b);T!=null&&h(T)}};h(this);let f,m=e.actor;co(m)&&(f=m.subscribe(v=>{let _=!1,b=!1;for(let T of v){let O=T[0];O===N?_=!0:(O===P||O===D||O===H)&&(b=!0)}_&&u(),b&&(f?.(),f=void 0,u())}));let g;try{g=J([s],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(v,_)=>v===_})}catch(v){c(),f?.();for(let _ of l)_();throw a.dispose(),v}let R=ge(g);return{node:g,dispose(){d=!0,c(),f?.();for(let v of l)v();l.length=0,a.dispose(),R()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},n=e.reactiveName??"describe-diff",o={name:this.name,nodes:{},edges:[],subgraphs:[]},s=this.describe(t),a=Rn(o,s),i=V(a,{name:n,meta:{domain:"audit",kind:"describe-diff"},equals:(p,h)=>p===h}),d=this._describeReactive({...e,reactiveName:void 0}),u=!1,c=d.node.subscribe(p=>{if(!u)for(let h of p){if(h[0]!==N)continue;let f=h[1],m=Rn(s,f);s=f,m.events.length!==0&&i.emit(m)}}),l=ge(i);return{node:i,dispose(){u=!0,c(),d.dispose(),i.down([[H,"describe-diff disposed"]]),l()}}}_explainReactive(e,t,n){let o=0,s=V(o,{name:"explain_version"}),a=this.observe({timeline:!0,structured:!0}),i=!1,d=!1,u=()=>{i||d||(i=!0,qe(()=>{i=!1,!d&&(o+=1,s.emit(o))}))},c=a.onEvent(v=>{let _=v.type;_!=="data"&&_!=="error"&&_!=="complete"&&_!=="teardown"||u()}),l=[];e!=null&&Pe(e)&&l.push(e),t!=null&&Pe(t)&&l.push(t),n?.maxDepth!=null&&Pe(n.maxDepth)&&l.push(n.maxDepth),n?.findCycle!=null&&Pe(n.findCycle)&&l.push(n.findCycle);let p=()=>{for(let v of l)if(v.cache===void 0)return!1;return!0},h=()=>{let v=ve(e),_=ve(t);return{from:v,to:_,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:v,to:_,found:!1,reason:"pending",steps:[]})}},f;try{f=J([s],()=>{if(!p())return h();let v=ve(e),_=ve(t),b={...n?.maxDepth!==void 0?{maxDepth:so(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:io(n.findCycle)}:{}};return this._explainStatic(v,_,b)},{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:ve(e),to:ve(t)},equals:(v,_)=>v.found===_.found&&v.reason===_.reason&&v.steps.length===_.steps.length&&Es(v.steps,_.steps)})}catch(v){throw c(),a.dispose(),v}let m=ge(f),g=[],R=v=>{let _;return _=v.subscribe(b=>{let T=!1,O=!1;for(let y of b){let x=y[0];x===N?T=!0:(x===P||x===D||x===H)&&(O=!0)}(T||O)&&u(),O&&_&&(_(),_=void 0)}),()=>{_&&(_(),_=void 0)}};for(let v of l)g.push(R(v));return{node:f,dispose(){d=!0,c();for(let v of g)v?.();g.length=0,a.dispose(),m()}}}_pathsMatching(e){let t=Vt(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}${$}${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}${$}${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],a=`${e}${$}${de}${$}${o}`;n.push([a,s]),this._appendMetaObserveTargets(a,s,n)}}observe(e,t){let n=typeof e=="string",s=uo(n?t:e);if(s.reactive===!0)return this._observeReactive(n?e:void 0,s);let a=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,i=s.actor;if(n){let c=e,l=this.resolve(c);if(i!=null&&!l.allowsObserve(i))throw new ie({actor:i,action:"observe",nodeName:c});return a?this._buildStructuredObserver([[c,l]],s,"one"):{subscribe(p){return l.subscribe(p)},up(p){try{l.up?.(p)}catch(h){if(h instanceof ie)return;throw h}}}}let d=[];this._collectObserveTargets("",d),d.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let u=i==null?d:d.filter(([,c])=>c.allowsObserve(i));return a?this._buildStructuredObserver(u,s,"all"):{subscribe:c=>{let l=u.map(([p,h])=>h.subscribe(f=>{c(p,f)}));return()=>{for(let p of l)p()}},up:(c,l)=>{try{this.resolve(c).up?.(l)}catch(p){if(p instanceof ie)return;throw p}}}}_observeReactive(e,t){let n=t.tiers,o=n!=null?new Set(n):null,s=t.reactiveName??"observe";return Me(a=>{let i=[],d=!1,u=!1,c=()=>{if(i.length===0||u)return;let m={events:i.slice(),flushedAt_ns:pe()};i.length=0,a.emit(m)},l={...t,reactive:!1,structured:!0,timeline:!0},p=e!=null?this.observe(e,l):this.observe(l),h=m=>{u||(i.push(m),!d&&(d=!0,qe(()=>{d=!1,c()})))};for(let m of p.events)h(m);let f=p.onEvent(h);return()=>{u=!0,f(),p.dispose()}},{name:s,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,n){let o=n==="one"?e[0]?.[0]:void 0,s=a=>{if(n==="one"&&o!=null){let c=this.resolve(o);return this._buildStructuredObserver([[o,c]],a,"one")}let i=[];this._collectObserveTargets("",i),i.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let d=a.actor,u=d==null?i:i.filter(([,c])=>c.allowsObserve(d));return this._buildStructuredObserver(u,a,"all")};return this._createObserveResult(e,t,s)}_createObserveResult(e,t,n){let o=t.timeline===!0,s=t.causal===!0,a=t.derived===!0,i=t.detail==="minimal",d=this.config.inspectorEnabled,u=(s||a)&&d,c=t.maxEvents,l=c!=null&&c>0?new lt(c):null,p=[],h=new Set,f=t.tiers!=null?new Set(t.tiers):null,m={},g=new Set,R=0,v=0,_=0,b=0,T=0,O=0,y=!1,x=!1,S=0,E=new Map,w=new Map,k=new Map,M=C=>{if(!(f!=null&&!f.has(C.type))){l?l.push(C):p.push(C);for(let L of h)L(C)}},A=C=>f==null||f.has(C),j=()=>o?{timestamp_ns:pe(),in_batch:xt(),batch_id:S}:{},U=(C,L)=>{if(!(!u||!(C instanceof q)))return C._setInspectorHook(te=>{if(te.kind==="dep_message")E.set(C,te.depIndex);else if(te.kind==="run"){let et=te.batchData.map((G,Y)=>G!=null&&G.length>0?G.at(-1):te.prevData[Y]);w.set(C,et);let ne=te.batchData.map(G=>G!=null?[...G]:void 0);k.set(C,ne),a&&M({type:"derived",path:L,dep_values:et,dep_batches:ne,...j()})}})},X=C=>{let L=E.get(C),te=w.get(C);if(!s||te==null)return{};let ne=(L!=null&&L>=0&&C instanceof q?C._deps[L]:void 0)?.node,G=ne?.v,Y=k.get(C);return{trigger_dep_index:L,trigger_dep_name:ne?.name,...G!=null?{trigger_version:{id:G.id,version:G.version}}:{},dep_values:[...te],...Y!=null?{dep_batches:Y}:{}}},Le=[],$e=[];for(let[C,L]of e){let te=U(L,C);te&&Le.push(te),$e.push(L.subscribe(et=>{S++;for(let ne of et){let G=ne[0],Y=j();if(G===N){m[C]=ne[1];let Jt=L instanceof q?L.lastMutation?.actor??be:be;M({type:"data",path:C,data:ne[1],actor:Jt,...Y,...X(L)})}else if(i)G===I?A("dirty")&&R++:G===W?A("resolved")&&v++:G===re?A("invalidate")&&_++:G===ee?A("pause")&&b++:G===oe?A("resume")&&T++:G===H?A("teardown")&&O++:G===P&&!g.has(C)?A("complete")&&(y=!0):G===D&&A("error")&&(x=!0,g.add(C));else if(G===I)A("dirty")&&R++,M({type:"dirty",path:C,...Y});else if(G===W)A("resolved")&&v++,M({type:"resolved",path:C,...Y,...X(L)});else if(G===re)A("invalidate")&&_++,M({type:"invalidate",path:C,...Y});else if(G===ee)A("pause")&&b++,M({type:"pause",path:C,lockId:ne[1],...Y});else if(G===oe)A("resume")&&T++,M({type:"resume",path:C,lockId:ne[1],...Y});else if(G===P)A("complete")&&!g.has(C)&&(y=!0),M({type:"complete",path:C,...Y});else if(G===D){A("error")&&(x=!0,g.add(C));let Jt=L instanceof q?L.lastMutation?.actor??be:be;M({type:"error",path:C,data:ne[1],actor:Jt,...Y})}else G===H&&(A("teardown")&&O++,M({type:"teardown",path:C,...Y}))}}))}let Ze=!1,Xe=()=>{if(!Ze){Ze=!0;for(let C of $e)C();for(let C of Le)C();for(let C of vt)C({value:void 0,done:!0});vt.length=0}},Yt=[],vt=[];h.add(C=>{let L=vt.shift();L?L({value:C,done:!1}):Yt.push(C)});let qn={get values(){return m},get dirtyCount(){return R},get resolvedCount(){return v},get invalidateCount(){return _},get pauseCount(){return b},get resumeCount(){return T},get teardownCount(){return O},get events(){return l?l.toArray():[...p]},get anyCompletedCleanly(){return y},get anyErrored(){return x},get completedWithoutErrors(){return y&&!x},onEvent(C){return h.add(C),()=>h.delete(C)},dispose:Xe,expand(C){Xe();let L={...t};return typeof C=="string"?L.detail=C:Object.assign(L,C),n(uo(L))},[Symbol.asyncIterator](){return{next(){return Yt.length>0?Promise.resolve({value:Yt.shift(),done:!1}):Ze?Promise.resolve({value:void 0,done:!0}):new Promise(C=>vt.push(C))},return(){return Xe(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(qn,t),qn}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let o=t.logger??(f=>console.log(f)),s=t.includeTypes?new Set(t.includeTypes):null,a=t.excludeTypes?new Set(t.excludeTypes):null,i=s==null&&a==null?()=>!0:f=>(s==null||s.has(f))&&(a==null||!a.has(f)),d=Ts(t.theme),u=n==="stage-log"?pe():0,c=f=>f==null?"":t.stageLabels?.[f]??f,l=(f,m)=>f.length>m?`${f.slice(0,m-1)}\u2026`:f,p=f=>f.type==="data"||f.type==="error"?l(xn(f.data),120):"",h=f=>{if(n==="stage-log"){let y=(pe()-u)/1e9,x=c(f.path).padEnd(9);if(f.type==="data"){let S=p(f);return`[${y.toFixed(3)}s] ${x} \u2190${S?` ${S}`:""}`}if(f.type==="error"){let S=p(f);return`[${y.toFixed(3)}s] ${x} \u2717${S?` ${S}`:""}`}return f.type==="complete"?`[${y.toFixed(3)}s] ${x} \u25A0 complete`:`[${y.toFixed(3)}s] ${x} ${f.type}`}if(n==="json")try{return JSON.stringify(f)}catch{return JSON.stringify({type:f.type,path:f.path,data:"[unserializable]"})}let m=d[f.type]??"",g=f.path?`${d.path}${f.path}${d.reset} `:"",R=f.type==="data"||f.type==="error",v=f.type==="pause"||f.type==="resume",_=R?` ${xn(f.data)}`:v?` ${xn(f.lockId)}`:"",b=f.type==="data"||f.type==="resolved"||f.type==="derived"?f:void 0,T=b?.trigger_dep_name!=null?` <- ${b.trigger_dep_name}`:b?.trigger_dep_index!=null?` <- #${b.trigger_dep_index}`:"",O=f.in_batch?" [batch]":"";return`${g}${m}${f.type.toUpperCase()}${d.reset}${_}${T}${O}`};e.onEvent(f=>{i(f.type)&&o(h(f),f)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){oo(this._disposers,this.name),this.signal([[H]],{internal:!0}),oo(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:t,...n}=this.describe({detail:"full"}),o={};for(let i of Object.keys(n.nodes).sort()){let{lastMutation:d,guard:u,...c}=n.nodes[i];o[i]=c}let s=[...n.subgraphs].sort(),a={...n,version:1,nodes:o,subgraphs:s};if(e?.format==null)return a;if(e.format==="json-string")return JSON.stringify(a);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let i=this.config.lookupCodec(e.codec);if(i==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return nr(i,i.encode(a))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??Ae,{codec:o,codecVersion:s,payload:a}=rr(e,n);return o.decode(a,s)}restore(e,t){if(ao(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=>Vt(s)),o=t?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(i=>i.test(s)))continue;let a=e.nodes[s];if(a!==void 0){if(!("value"in a)||a.value===void 0){"value"in a&&a.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(!(a.type==="derived"||a.type==="effect")&&!(a.type==="producer"&&!o)){if(a.v!=null){let d=this.tryResolve(s)?.v;if(d!=null&&d.id===a.v.id&&d.version===a.v.version)continue}try{this.set(s,a.value)}catch(i){t?.onError?.(s,i)}}}}}static fromSnapshot(e,t){ao(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 h of[...e.subgraphs].sort((f,m)=>{let g=f.split($).length,R=m.split($).length;return g!==R?g-R:f<m?-1:f>m?1:0})){let f=h.split($),m=s;for(let g of f)m._mounts.has(g)||m.mount(g,new r(g)),m=m._mounts.get(g)}let a=o?Object.entries(o).map(([h,f])=>({re:Vt(h),factory:f})):[],i=h=>{for(let f of a)if(f.re.test(h))return f.factory},d=h=>{let f=h.split($),m=f.pop();if(m==null||m.length===0)throw new Error(`invalid snapshot path "${h}"`);let g=s;for(let R of f){let v=g._mounts.get(R);if(!v)throw new Error(`unknown mount "${R}" in path "${h}"`);g=v}return[g,m]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${$}${de}${$}`)).sort((h,f)=>h[0]<f[0]?-1:h[0]>f[0]?1:0),c=new Map(u),l=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[h,f]of[...c.entries()]){let m=f?.deps??[];if(!m.every(T=>l.has(T)))continue;let[g,R]=d(h),v={...f?.meta??{}},_=i(h),b;if(f?.type==="state")b=V(f.value,{meta:v});else{if(_==null)continue;b=_(R,{path:h,type:f.type,value:f.value,meta:v,deps:m,resolvedDeps:m.map(T=>l.get(T))})}g.add(b,{name:R}),l.set(h,b),c.delete(h),p=!0}}if(c.size>0){let h=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachSnapshotStorage(e,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,c)=>{if(u.disposed)return;let l=ms(c.nodes);if(u.lastSnapshot!=null&&l!==""&&l===u.lastFingerprint)return;let p=u.seq+1,h=se(),g=u.lastSnapshot==null||p%u.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:p,timestamp_ns:h,format_version:Ie}:{name:this.name,mode:"diff",diff:fo(u.lastSnapshot,c),seq:p,timestamp_ns:h,format_version:Ie};if(u.tier.filter&&!u.tier.filter(g))return;let R;try{R=u.tier.save(g)}catch(v){t.onError?.(v,u.tier);return}if(R&&typeof R.then=="function"){let b=(u.savePending??Promise.resolve()).then(()=>R,()=>R).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=c,u.lastFingerprint=l)},T=>{t.onError?.(T,u.tier)});u.savePending=b.finally(()=>{u.savePending===b&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=c,u.lastFingerprint=l},s=(u,c)=>{try{o(u,c)}catch(l){t.onError?.(l,u.tier)}},a=(u,c)=>{if(!c.some(f=>{let m=this.config.messageTier(f[0]);return m>=3&&m<5}))return;if(t.filter){let f=this.tryResolve(u);if(f==null)return;let m=_n(f,It("standard"));if(!t.filter(u,m))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let f of n)f.disposed||(f.debounceMs===0?s(f,h()):(f.timer==null&&(f.timer=new Pt),f.timer.start(f.debounceMs,()=>{f.disposed||s(f,this.snapshot())})))},i;if(t.paths!=null){let c=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(l=>{let p=this.tryResolve(l);return p==null?()=>{}:p.subscribe(h=>a(l,h))});i=()=>{for(let l of c)l()}}else i=this.observe().subscribe((u,c)=>a(u,c));let d=()=>{i();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?.()}catch(a){t?.(a,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===Ie&&s.nodes!=null)return this.restore(s),!0}catch(a){t?.(a,n)}}return!1}static async fromStorage(e,t,n){for(let o of t){let s;try{s=await o.load?.()}catch(d){n?.onError?.(d,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let a=s,i=a.mode==="full"&&a.snapshot!=null?a.snapshot:a.version===Ie&&a.nodes!=null?a:void 0;if(i!=null)try{return r.fromSnapshot(i,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:pe(),...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(v=>!n.has(v)).sort(),a=[...n].filter(v=>!o.has(v)).sort(),i=[],d=[];for(let v of n){if(!o.has(v))continue;let _=e.nodes[v],b=t.nodes[v],T=_.v,O=b.v;T!=null&&O!=null&&T.id===O.id&&T.version!==O.version&&d.push({path:v,id:T.id,from:T.version,to:O.version});let y=T!=null&&O!=null&&T.id===O.id&&T.version===O.version;for(let x of["type","status","sentinel"]){let S=_[x],E=b[x];S!==E&&i.push({path:v,field:x,from:S,to:E})}if(!y)for(let x of["value","meta"]){let S=_[x],E=b[x];ys(S,E)||i.push({path:v,field:x,from:S,to:E})}}let u=v=>`${v.from} ${v.to}`,c=new Set(e.edges.map(u)),l=new Set(t.edges.map(u)),p=t.edges.filter(v=>!c.has(u(v))),h=e.edges.filter(v=>!l.has(u(v))),f=new Set(e.subgraphs),m=new Set(t.subgraphs),g=[...m].filter(v=>!f.has(v)).sort(),R=[...f].filter(v=>!m.has(v)).sort();return{nodesAdded:s,nodesRemoved:a,nodesChanged:i,versionChanges:d,edgesAdded:p,edgesRemoved:h,subgraphsAdded:g,subgraphsRemoved:R}}}});var vo=F(()=>{"use strict";ft()});function _o(r,e,t){return{[r]:!0,[`${r}_type`]:e,...t??{}}}var To=F(()=>{"use strict"});var js={};ce(js,{jotai:()=>ln,nanostores:()=>pn,nestjs:()=>Dn,react:()=>Gn,signals:()=>Ln,solid:()=>$n,svelte:()=>Fn,vue:()=>Vn,zustand:()=>Hn});module.exports=Go(js);var ln={};ce(ln,{atom:()=>Yo});B();fe();function Yo(r,e,t){if(typeof r=="function"){let n=r;return typeof e=="function"?gr(n,e,t):gr(n,void 0,e)}return Jo(r,e)}function at(r){let e=r.cache,t;if(r.subscribe(o=>{for(let[s,a]of o)s===N&&(e=a),s===D&&(t=a)})(),t)throw t;return e}function Jo(r,e){let t=V(r,{...e,resubscribable:!0,resetOnTeardown:!0});return{get:()=>t.status==="sentinel"?at(t):t.cache,set:n=>t.emit(n),update:n=>{let o=t.status==="sentinel"?at(t):t.cache;t.emit(n(o))},subscribe:n=>{let o=!0;return t.subscribe(s=>{for(let[a,i]of s)if(a===N){if(o){o=!1;continue}n(i)}})},meta:t.meta,_node:t}}function gr(r,e,t){let n=it(s=>r(a=>{let i=a._node;return i.status==="sentinel"&&at(i),s(i)}),{...t,resubscribable:!0,resetOnTeardown:!0}),o={get:()=>n.status==="sentinel"?at(n):n.cache,subscribe:s=>{let a=!0;return n.subscribe(i=>{for(let[d,u]of i)if(d===N){if(a){a=!1;continue}s(u)}})},meta:n.meta,_node:n};if(e){let s=d=>d.get(),a=(d,u)=>d.set(u),i=o;return i.set=d=>e(s,a,d),i.update=d=>{let u=n.status==="sentinel"?at(n):n.cache;return e(s,a,d(u))},i}return o}var pn={};ce(pn,{action:()=>ns,atom:()=>Qo,computed:()=>Zo,getValue:()=>es,map:()=>Xo,onMount:()=>ts,onStart:()=>br,onStop:()=>vr});Oe();B();fe();var kt=new WeakMap,At=new WeakMap;function St(r,e){let t=e.get(r);if(t)for(let n of t)n()}function fn(r,e={}){let t=0;return{...e,get:()=>yr(r),subscribe:o=>{t===0&&St(r,kt),t++;let s=r.subscribe(a=>{for(let[i,d]of a)i===N&&o(d)});return()=>{s(),t--,t===0&&St(r,At)}},listen:o=>{t===0&&St(r,kt),t++;let s=!0,a=r.subscribe(i=>{for(let[d,u]of i)if(d===N){if(s){s=!1;continue}o(u)}});return()=>{a(),t--,t===0&&St(r,At)}},_node:r}}function mr(r){let e=r.cache,t;if(r.subscribe(o=>{for(let[s,a]of o)s===N&&(e=a),s===D&&(t=a)})(),t)throw t;return e}function yr(r){return r.status==="sentinel"?mr(r):r.cache}function Qo(r){let e=V(r,{resubscribable:!0,resetOnTeardown:!0});return fn(e,{set:t=>e.emit(t)})}function Zo(r,e){let t=Array.isArray(r)?r:[r],n=t.map(s=>s._node),o=cn(n,s=>{let a=t.map(i=>{let d=i._node;return d.status==="sentinel"&&mr(d),s(d)});return e(...a)},{resubscribable:!0,resetOnTeardown:!0,equals:Object.is});return fn(o)}function Xo(r){let e=V(r,{resubscribable:!0,resetOnTeardown:!0,equals:()=>!1});return fn(e,{set:t=>e.emit(t),setKey:(t,n)=>{let o=yr(e);e.emit({...o,[t]:n})}})}function es(r){return r.get()}function br(r,e){let t=r._node,n=kt.get(t);n||(n=new Set,kt.set(t,n)),n.add(e)}function vr(r,e){let t=r._node,n=At.get(t);n||(n=new Set,At.set(t,n)),n.add(e)}function ts(r,e){br(r,()=>{let t=e();typeof t=="function"&&vr(r,t)})}function ns(r,e,t){return(...n)=>{let o;return le(()=>{o=t(...n)}),o}}var Dn={};ce(Dn,{ACTOR_KEY:()=>Gt,COMMAND_HANDLERS:()=>Ke,CQRS_EVENT_HANDLERS:()=>Ue,CRON_HANDLERS:()=>Be,CommandHandler:()=>Or,EVENT_HANDLERS:()=>ze,EventHandler:()=>Sr,GRAPHREFLY_REQUEST_GRAPH:()=>De,GRAPHREFLY_ROOT_GRAPH:()=>ae,GraphCron:()=>Nr,GraphInterval:()=>Er,GraphReflyEventExplorer:()=>Ge,GraphReflyGuard:()=>jr,GraphReflyGuardImpl:()=>ct,GraphReflyModule:()=>Kt,INTERVAL_HANDLERS:()=>We,InjectCqrsGraph:()=>wr,InjectGraph:()=>Tr,InjectNode:()=>Rr,ObserveGateway:()=>Dt,OnGraphEvent:()=>xr,QUERY_HANDLERS:()=>Ye,QueryHandler:()=>kr,SAGA_HANDLERS:()=>Je,SagaHandler:()=>Ar,fromHeader:()=>Hr,fromJwtPayload:()=>yn,getActor:()=>qr,getGraphToken:()=>Q,getNodeToken:()=>ue,observeSSE:()=>Fr,observeSubscription:()=>Vr,toObservable:()=>_r});var hn=require("rxjs");B();function _r(r,e){return e?.raw?new hn.Observable(t=>r.subscribe(o=>{if(!t.closed){t.next(o);for(let s of o){if(s[0]===D){t.error(s[1]);return}if(s[0]===P){t.complete();return}}}})):new hn.Observable(t=>r.subscribe(o=>{for(let s of o){if(t.closed)return;if(s[0]===N)t.next(s[1]);else if(s[0]===D){t.error(s[1]);return}else if(s[0]===P){t.complete();return}}}))}var dt=require("@nestjs/common");var ae=Symbol.for("graphrefly:root-graph");var De=Symbol.for("graphrefly:request-graph");function Q(r){return Symbol.for(`graphrefly:graph:${r}`)}function ue(r){return Symbol.for(`graphrefly:node:${r}`)}var ze=new Map,We=new Map,Be=new Map,Ke=new Map,Ue=new Map,Ye=new Map,Je=new Map;function Tr(r){return r==="request"?(0,dt.Inject)(De):(0,dt.Inject)(r?Q(r):ae)}function wr(r){return(0,dt.Inject)(Q(r))}function Rr(r){return(0,dt.Inject)(ue(r))}function xr(r){return(e,t)=>{let n=t.name;t.addInitializer(function(){let o=this.constructor,s=ze.get(o)??[];s.push({nodeName:r,methodKey:n}),ze.set(o,s)})}}function Er(r){return(e,t)=>{let n=t.name;t.addInitializer(function(){let o=this.constructor,s=We.get(o)??[];s.push({ms:r,methodKey:n}),We.set(o,s)})}}function Nr(r){return(e,t)=>{let n=t.name;t.addInitializer(function(){let o=this.constructor,s=Be.get(o)??[];s.push({expr:r,methodKey:n}),Be.set(o,s)})}}function Or(r,e){return(t,n)=>{let o=n.name;n.addInitializer(function(){let s=this.constructor,a=Ke.get(s)??[];a.push({cqrsName:r,commandName:e,methodKey:o}),Ke.set(s,a)})}}function Sr(r,e){return(t,n)=>{let o=n.name;n.addInitializer(function(){let s=this.constructor,a=Ue.get(s)??[];a.push({cqrsName:r,eventName:e,methodKey:o}),Ue.set(s,a)})}}function kr(r,e){return(t,n)=>{let o=n.name;n.addInitializer(function(){let s=this.constructor,a=Ye.get(s)??[];a.push({cqrsName:r,projectionName:e,methodKey:o}),Ye.set(s,a)})}}function Ar(r,e,t){return(n,o)=>{let s=o.name;o.addInitializer(function(){let a=this.constructor,i=Je.get(a)??[];i.push({cqrsName:r,eventNames:t,sagaName:e,methodKey:s}),Je.set(a,i)})}}B();Ct();var $r=0,Ge=class{constructor(e,t){this.graph=e;this.moduleRef=t}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,t]of ze){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireEventHandler(n,o)}}wireEventHandler(e,t){let n=e[t.methodKey];if(typeof n!="function")return;let o=n.bind(e),a=this.observeNode(t.nodeName).subscribe(i=>{for(let d of i)d[0]===N&&o(d[1])});this.disposers.push(a)}wireIntervals(){for(let[e,t]of We){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireIntervalHandler(n,e,o)}}wireIntervalHandler(e,t,n){let o=e[n.methodKey];if(typeof o!="function")return;let s=o.bind(e),i=`__schedule__.${t.name??"anonymous"}.${String(n.methodKey)}.${$r++}`,d=Ir(n.ms,{period:n.ms,name:i});this.graph.add(d),this.scheduleNodeNames.push(i);let c=this.observeNode(i).subscribe(l=>{for(let p of l)p[0]===N&&s(p[1])});this.disposers.push(c)}wireCrons(){for(let[e,t]of Be){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireCronHandler(n,e,o)}}wireCronHandler(e,t,n){let o=e[n.methodKey];if(typeof o!="function")return;let s=o.bind(e),i=`__schedule__.${t.name??"anonymous"}.${String(n.methodKey)}.${$r++}`,d=Pr(n.expr,{name:i});this.graph.add(d),this.scheduleNodeNames.push(i);let c=this.observeNode(i).subscribe(l=>{for(let p of l)p[0]===N&&s(p[1])});this.disposers.push(c)}wireCqrsCommands(){for(let[e,t]of Ke){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireCqrsCommand(n,o)}}wireCqrsCommand(e,t){let n=e[t.methodKey];if(typeof n!="function")return;let o=n.bind(e),s=this.resolveCqrsGraph(t.cqrsName);s&&s.command(t.commandName,o)}wireCqrsEvents(){for(let[e,t]of Ue){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireCqrsEventHandler(n,o)}}wireCqrsEventHandler(e,t){let n=e[t.methodKey];if(typeof n!="function")return;let o=n.bind(e),s=this.resolveCqrsGraph(t.cqrsName);if(!s)return;s.event(t.eventName);let i=s.resolve(t.eventName).cache,d=i&&i.length>0?i[i.length-1].seq:0,c=this.observeNodeOn(s,t.eventName).subscribe(l=>{for(let p of l)if(p[0]===N){let h=p[1];for(let f of h)f.seq>d&&(o(f),d=f.seq)}});this.disposers.push(c)}wireCqrsQueries(){for(let[e,t]of Ye){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireCqrsQuery(n,o)}}wireCqrsQuery(e,t){let n=e[t.methodKey];if(typeof n!="function")return;let o=n.bind(e),s=this.resolveCqrsGraph(t.cqrsName);if(!s)return;let i=this.observeNodeOn(s,t.projectionName).subscribe(d=>{for(let u of d)u[0]===N&&o(u[1])});this.disposers.push(i)}wireCqrsSagas(){for(let[e,t]of Je){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireCqrsSaga(n,o)}}wireCqrsSaga(e,t){let n=e[t.methodKey];if(typeof n!="function")return;let o=n.bind(e),s=this.resolveCqrsGraph(t.cqrsName);s&&s.saga(t.sagaName,t.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,t){return e.observe(t)}resolveCqrsGraph(e){try{return this.moduleRef.get(Q(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};B();B();var rs=0;function Mt(r,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let t=Symbol(`bp-${++rs}`),n=0,o=!1;return{onEnqueue(){return n+=1,!o&&n>=e.highWaterMark?(o=!0,r([[ee,t]]),!0):!1},onDequeue(){return n>0&&(n-=1),o&&n<=e.lowWaterMark?(o=!1,r([[oe,t]]),!0):!1},get pending(){return n},get paused(){return o},dispose(){o&&(o=!1,r([[oe,t]]))}}}function Fr(r,e,t){let{actor:n,serialize:o=os,keepAliveMs:s,signal:a}=t??{},i=new TextEncoder,d,u=t?.highWaterMark!=null,c,l,p=[],h=!1;return new ReadableStream({start(f){let m,g=()=>{},R=()=>{if(!h){h=!0,m!==void 0&&clearInterval(m),a?.removeEventListener("abort",v),g(),c?.dispose(),l?.(),l=void 0;for(let b of p)f.enqueue(b.frame);p.length=0,f.close()}};d=R;let v=()=>R(),_=r.observe(e,{actor:n});u&&(c=Mt(b=>_.up(b),{highWaterMark:t.highWaterMark,lowWaterMark:t.lowWaterMark??Math.floor(t.highWaterMark/2)})),g=_.subscribe(b=>{for(let T of b){if(h)return;let O=T[0];if(O===N){let y=i.encode(gn("data",o(T[1])));u?(p.push({frame:y,counted:!0}),c.onEnqueue(),l?.(),l=void 0):f.enqueue(y)}else if(O===D){let y=i.encode(gn("error",o(T[1])));u?(p.push({frame:y,counted:!1}),l?.(),l=void 0):f.enqueue(y),R();return}else if(O===P||O===H){if(O===P){let y=i.encode(gn("complete"));u?(p.push({frame:y,counted:!1}),l?.(),l=void 0):f.enqueue(y)}R();return}}}),s!==void 0&&s>0&&(m=setInterval(()=>{h||(u?(p.push({frame:i.encode(`: keepalive
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
4
16
 
5
- `),counted:!1}),l?.(),l=void 0):f.enqueue(i.encode(`: keepalive
6
-
7
- `)))},s)),a?.aborted?v():a?.addEventListener("abort",v,{once:!0})},pull(f){if(u&&!h){if(p.length>0){let m=p.shift();f.enqueue(m.frame),m.counted&&c.onDequeue();return}return new Promise(m=>{l=m})}},cancel(){try{d?.()}catch{}}})}function Vr(r,e,t){let{actor:n,filter:o}=t??{},s=[],a=[],i=!1,d=r.observe(e,{actor:n}),u=t?.highWaterMark!=null?Mt(f=>d.up(f),{highWaterMark:t.highWaterMark,lowWaterMark:t.lowWaterMark??Math.floor(t.highWaterMark/2)}):void 0,c=()=>{i||(i=!0,u?.dispose(),p())},l=f=>{if(!i)if(a.length>0){let m=a.shift();f.done&&f.error?m.reject(f.error):f.done?m.resolve({done:!0,value:void 0}):m.resolve({done:!1,value:f.value})}else s.push(f),f.done||u?.onEnqueue()},p=d.subscribe(f=>{for(let m of f){let g=m[0];if(g===N){let R=m[1];if(o&&!o(R))continue;l({done:!1,value:R})}else if(g===D){let R=m[1]instanceof Error?m[1]:new Error(String(m[1]));l({done:!0,error:R}),c();return}else if(g===P||g===H){l({done:!0}),c();return}}});return{next(){if(s.length>0){let f=s.shift();return f.done||u?.onDequeue(),f.done&&f.error?Promise.reject(f.error):Promise.resolve(f.done?{done:!0,value:void 0}:{done:!1,value:f.value})}return i?Promise.resolve({done:!0,value:void 0}):new Promise((f,m)=>{a.push({resolve:f,reject:m})})},return(){c();for(let f of a)f.resolve({done:!0,value:void 0});return a.length=0,Promise.resolve({done:!0,value:void 0})},throw(f){return c(),Promise.reject(f)},[Symbol.asyncIterator](){return this}}}var Dt=class{constructor(e,t){this.graph=e;this.extractActor=t?.extractActor??(()=>{}),this.parse=t?.parse??ss,this.highWaterMark=t?.highWaterMark,this.lowWaterMark=t?.lowWaterMark}clients=new Map;extractActor;parse;highWaterMark;lowWaterMark;handleConnection(e){this.clients.has(e)||this.clients.set(e,new Map)}handleDisconnect(e){let t=this.clients.get(e);if(t){for(let n of t.values())n.wm?.dispose(),n.unsub();this.clients.delete(e)}}handleMessage(e,t,n){let o=n??is.bind(null,e),s;try{s=typeof t=="string"?this.parse(t):t}catch{o({type:"err",message:"invalid command"});return}s.type==="subscribe"?this.subscribe(e,s.path,o):s.type==="unsubscribe"?this.unsubscribe(e,s.path,o):s.type==="ack"?this.ack(e,s.path,s.count??1):o({type:"err",message:`unknown command type: ${s.type}`})}subscriptionCount(e){return this.clients.get(e)?.size??0}destroy(){for(let[e]of this.clients)this.handleDisconnect(e)}subscribe(e,t,n){let o=this.clients.get(e);if(o||(o=new Map,this.clients.set(e,o)),o.has(t)){n({type:"subscribed",path:t});return}let s=this.extractActor(e),a;try{a=this.graph.observe(t,{actor:s})}catch(c){let l=c instanceof Error?c.message:String(c);n({type:"err",message:l});return}let i=this.highWaterMark!=null?Mt(c=>a.up(c),{highWaterMark:this.highWaterMark,lowWaterMark:this.lowWaterMark??Math.floor(this.highWaterMark/2)}):void 0,d=()=>{i?.dispose(),u(),o.delete(t)},u=a.subscribe(c=>{for(let l of c){let p=l[0];if(p===N)i?.onEnqueue(),mn(n,{type:"data",path:t,value:l[1]});else if(p===D){let h=l[1]instanceof Error?l[1].message:String(l[1]);mn(n,{type:"error",path:t,error:h}),d();return}else if(p===P||p===H){mn(n,{type:"complete",path:t}),d();return}}});o.set(t,{unsub:u,wm:i}),n({type:"subscribed",path:t})}unsubscribe(e,t,n){let o=this.clients.get(e),s=o?.get(t);s&&(s.wm?.dispose(),s.unsub(),o.delete(t)),n({type:"unsubscribed",path:t})}ack(e,t,n){let o=this.clients.get(e)?.get(t);if(!o?.wm)return;let s=Math.min(Math.max(0,Math.floor(n)),1024);for(let a=0;a<s;a++)o.wm.onDequeue()}};function os(r){if(r instanceof Error)return r.message;try{return JSON.stringify(r)}catch{return String(r)}}function gn(r,e){let t=`event: ${r}
8
- `;if(e!==void 0)for(let n of e.split(`
9
- `))t+=`data: ${n}
10
- `;return t+=`
11
- `,t}function ss(r){return JSON.parse(r)}function is(r,e){try{r.send(JSON.stringify(e))}catch{}}function mn(r,e){try{r(e)}catch{}}rt();var Gt="graphReflyActor";function yn(r){return e=>{let n=e.switchToHttp().getRequest()?.user;if(n!=null)return r?r(n):n}}function Hr(r="x-graphrefly-actor"){return e=>{let n=e.switchToHttp().getRequest()?.headers?.[r.toLowerCase()];if(!(typeof n!="string"||n.length===0))try{return JSON.parse(n)}catch{return}}}function qr(r){let e=r?.[Gt];return e!=null?xe(e):be}var ct=class{constructor(e){this.extractor=e}canActivate(e){let t=xe(this.extractor(e)),n=e.switchToHttp().getRequest();return n!=null&&(n[Gt]=t),!0}};function jr(r){return new ct(r??yn())}var bt=require("@nestjs/common"),No=require("@nestjs/core");ft();Se();ke();rt();ke();B();Tn();Ce();fe();Oe();Se();ke();B();fe();ft();Oe();B();Ce();fe();var On=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 a=new Array(s);for(let i=0;i<s;i++)a[i]=this._buf[(this._head+o+i)%this._maxSize];return a}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}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<e.length;t++)this._buf.push(e[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let s=0;s<t;s++)this._buf[s]=void 0;this._head=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}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function pt(r){return r.subscribe(()=>{})}var Ns=64;function ht(r,e={}){let{name:t,maxSize:n,versioning:o,guard:s,backend:a}=e,i=a??new On(r,n),d=V(i.toArray(),{name:t,describeKind:"state",equals:(y,x)=>y===x,...o!=null?{versioning:o}:{},...s!=null?{guard:s}:{}});function u(){let y=i.toArray();le(()=>{d.down([[I]],{internal:!0}),d.down([[N,y]],{internal:!0})})}let c=new Map,l=new Map,p=new Map;function h(y,x){return`${y}:${x===void 0?"END":x}`}function f(y){if(y.size<Ns)return;let x=y.keys().next();if(x.done)return;let S=y.get(x.value);S!==void 0&&S.dispose(),y.delete(x.value)}function m(y){let x=i.version;try{return y()}finally{i.version!==x&&u()}}function g(y){if(!Number.isInteger(y)||y<0)throw new RangeError(`tail: n must be a non-negative integer (got ${y})`);let x=c.get(y);if(x!==void 0)return c.delete(y),c.set(y,x),x.node;f(c);let S=J([d],([w])=>{let k=w;return y===0||k.length===0?[]:k.slice(Math.max(0,k.length-y))},{initial:i.tail(y),describeKind:"derived"}),E=pt(S);return c.set(y,{node:S,dispose:E}),S}function R(y,x){if(!Number.isInteger(y)||y<0)throw new RangeError(`slice: start must be a non-negative integer (got ${y})`);if(x!==void 0&&(!Number.isInteger(x)||x<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${x})`);let S=h(y,x),E=l.get(S);if(E!==void 0)return l.delete(S),l.set(S,E),E.node;f(l);let w=J([d],([M])=>{let A=M;return x===void 0?A.slice(y):A.slice(y,x)},{initial:i.slice(y,x),describeKind:"derived"}),k=pt(w);return l.set(S,{node:w,dispose:k}),w}function v(y){let x=p.get(y);if(x!==void 0)return x.node;let S=J([d,y],([w,k])=>{let M=w,A=Math.max(0,Math.trunc(k??0));return M.slice(A)},{initial:[],describeKind:"derived"}),E=pt(S);return p.set(y,{node:S,dispose:E}),S}let _,b;function T(){_===void 0&&(_=he([d],(y,x,S)=>{let E=y[0],k=E!=null&&E.length>0?E.at(-1):S.prevData[0];if(k==null||k.length===0){x.down([[W]]);return}x.emit(k[k.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:i.size===0?void 0:i.at(i.size-1)}),b=J([d],([y])=>y.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:i.size>0}),pt(_),pt(b))}let O={entries:d,get size(){return i.size},at(y){return i.at(y)},append(y){m(()=>i.append(y))},appendMany(y){y.length!==0&&m(()=>i.appendMany(y))},clear(){m(()=>i.clear())},trimHead(y){m(()=>i.trimHead(y))},withLatest(){return T(),d},get lastValue(){return T(),_},get hasLatest(){return T(),b},view(y){switch(y.kind){case"tail":return g(y.n);case"slice":return R(y.start,y.stop);case"fromCursor":return v(y.cursor)}},attach(y){let x=y.subscribe(S=>{for(let E of S)E[0]===N&&O.append(E[1])});return()=>x()},attachStorage(y){if(y.length===0)return()=>{};let x=new Map;for(let E of y)x.set(E,i.size);(async()=>{for(let E of y)if(typeof E.loadEntries=="function")try{let w=await Promise.resolve(E.loadEntries());w.entries.length>0&&i.size===0&&(i.restore(w.entries),x.set(E,w.entries.length),u());break}catch{}})();let S=d.subscribe(E=>{for(let w of E){if(w[0]!==N)continue;let k=w[1];for(let M of y){let A=x.get(M)??0;if(k.length<A){try{let U=M.appendEntries(k);U instanceof Promise&&U.catch(()=>{})}catch{}x.set(M,k.length);continue}if(k.length===A)continue;let j=k.slice(A);x.set(M,k.length);try{let U=M.appendEntries(j);U instanceof Promise&&U.catch(()=>{})}catch{}}}});return()=>S()},disposeAllViews(){for(let y of c.values())y.dispose();c.clear();for(let y of l.values())y.dispose();l.clear();for(let y of p.values())y.dispose();p.clear()},dispose(){for(let y of c.values())y.dispose();c.clear();for(let y of l.values())y.dispose();l.clear();for(let y of p.values())y.dispose();p.clear()}};return O}var Os=je((r,e)=>{r("observe"),r("signal"),e("write")});function qt(r){let e=ht([],{name:r.name,maxSize:r.retainedLimit??1024,guard:r.guard??Os,...r.versioning!=null?{versioning:r.versioning}:{}});return e.withLatest(),r.graph&&r.graph.add(e.entries,{name:r.name}),e}function Sn(r){if(r===null||typeof r!="object"||Object.isFrozen(r))return r;for(let e of Object.keys(r))Sn(r[e]);return Object.freeze(r)}var po=new WeakSet;function ho(r){let e=r.cache,t=typeof e=="number"&&Number.isFinite(e);!t&&e!==void 0&&!po.has(r)&&(po.add(r),console.warn(`bumpCursor: cursor cache held a non-numeric value (${String(e)}); resetting to 0. Causes include: a snapshot codec round-tripping the cursor as a string / null / NaN, OR a malformed initial seed (e.g. state<number>(NaN)). Audit consumers may see colliding seq values after this point.`));let o=(t?e:0)+1;return r.down([[I],[N,o]]),o}function Ht(r,e,t,n,o,s){let a=e(t,n,o);if(a===void 0)return;let i=s!=null?{...a,handlerVersion:s}:a;r.append(i)}function go(r,e){let t=e.freeze??!0;return function(...o){let s=t?o.map(Sn):o,a=se(),i=e.seq?ho(e.seq):void 0;try{let d=r(...s);return e.audit&&e.onSuccess&&Ht(e.audit,e.onSuccess,s,d,{t_ns:a,seq:i},e.handlerVersion),d}catch(d){if(e.audit&&e.onFailure){let u=d instanceof Error?d.name:typeof d;Ht(e.audit,e.onFailure,s,d,{t_ns:a,seq:i,errorType:u},e.handlerVersion)}throw d}}}function mo(r,e){let t=e.freeze??!0;return function(...o){let s=t?o.map(Sn):o,a=se(),i,d,u=!1,c;try{le(()=>{e.seq&&(c=ho(e.seq));try{i=r(...s),e.audit&&e.onSuccess&&Ht(e.audit,e.onSuccess,s,i,{t_ns:a,seq:c},e.handlerVersion)}catch(l){throw d=l,u=!0,l}})}catch(l){if(u&&e.audit&&e.onFailure){let p=d instanceof Error?d.name:typeof d;Ht(e.audit,e.onFailure,s,d,{t_ns:a,seq:c,errorType:p},e.handlerVersion)}throw u?d:l}return i}}function yo(r,e,t=0){let n=V(t,{name:e,describeKind:"state"});return r.add(n,{name:e}),n}function bo(r,e,t,n=0){let o={},s=new Z(e);for(let a of t){let i=V(n,{name:a,describeKind:"state"});s.add(i,{name:a}),o[a]=i}return r.mount(e,s),o}vo();var _e=class extends Error{constructor(e,t){super(e,t),this.name=this.constructor.name}},jt=class extends _e{constructor(t,n){super(`Duplicate ${t} registration: "${n}"`);this.kind=t;this.registrationName=n}},zt=class extends _e{constructor(t,n,o){super(`Command "${t}" emitted undeclared event "${n}". Declared emits: [${o.join(", ")}]`);this.commandName=t;this.eventName=n;this.declaredEmits=o}},Wt=class extends _e{constructor(t,n,o){super(`Optimistic concurrency conflict on aggregate "${t}": expected version ${n}, got ${o}`);this.aggregateId=t;this.expected=n;this.actual=o}},Bt=class extends _e{constructor(t){super(`Unknown command: "${t}". Register with command() first.`);this.commandName=t}},gt=class extends _e{constructor(t,n){super(`Command handler "${t}" threw: ${n instanceof Error?n.message:String(n)}`,{cause:n});this.commandName=t}};var mt=class extends _e{constructor(t,n){super(`Projection "${t}" rebuild failed: ${n instanceof Error?n.message:String(n)}`,{cause:n});this.projectionName=t}};To();Ct();var Ss=je((r,e)=>{r("write"),r("signal"),e("observe")}),ks=je((r,e)=>{r("observe"),r("signal"),e("write")}),wo=je((r,e)=>{r("observe"),r("signal"),e("write")});function yt(r,e){return _o("cqrs",r,e)}function Ro(r){if(r===null||typeof r!="object"||Object.isFrozen(r))return r;for(let e of Object.keys(r))Ro(r[e]);return Object.freeze(r)}var kn=class extends Z{_eventLogs=new Map;_eventLogsByAggregate=new Map;_aggregateVersions=new Map;_aggregateLru=new Map;_commandRegs=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_seq=0;_retainedLimit;_freezeCommandPayload;_freezeEventPayload;_maxAggregates;_dispatchSeqCursor;dispatches;audit;aggregateEvictions;constructor(e,t={}){super(e,t.graph),this._retainedLimit=t.retainedLimit??1024,this._freezeCommandPayload=t.freezeCommandPayload??!0,this._freezeEventPayload=t.freezeEventPayload??!0,this._maxAggregates=t.maxAggregates??1e4,this.dispatches=qt({name:"dispatches",retainedLimit:this._retainedLimit,graph:this}),this.audit=this.dispatches,this.aggregateEvictions=qt({name:"aggregateEvictions",retainedLimit:this._retainedLimit,graph:this}),this._dispatchSeqCursor=yo(this,"dispatch_seq",0)}aggregateVersion(e,t){return this._aggregateVersions.get(`${e}::${t}`)??0}_touchAggregate(e){this._aggregateLru.delete(e),this._aggregateLru.set(e,!0)}_enforceAggregateLru(){for(;this._aggregateLru.size>this._maxAggregates;){let e=this._aggregateLru.keys().next();if(e.done)break;let t=e.value;this._aggregateLru.delete(t);let n=t.indexOf("::");if(n<0)continue;let o=t.slice(0,n),s=t.slice(n+2),a=this._aggregateVersions.get(t)??0;this._aggregateVersions.delete(t);let i=this._eventLogsByAggregate.get(o);i&&(i.delete(s),i.size===0&&this._eventLogsByAggregate.delete(o)),this.aggregateEvictions.append({aggregateId:s,type:o,lastVersion:a,t_ns:se()})}}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}_attachedEventTiers=[];_attachedTierDisposers=new Map;attachEventStorage(e){this._attachedEventTiers.push(e);for(let[t,n]of this._eventLogs){let o=n.log.attachStorage(e),s=this._attachedTierDisposers.get(t);s||(s=[],this._attachedTierDisposers.set(t,s)),s.push(o)}for(let[t,n]of this._eventLogsByAggregate)for(let[o,s]of n){let a=`${t}::${o}`,i=s.log.attachStorage(e),d=this._attachedTierDisposers.get(a);d||(d=[],this._attachedTierDisposers.set(a,d)),d.push(i)}return()=>{let t=this._attachedEventTiers.indexOf(e);t>=0&&this._attachedEventTiers.splice(t,1)}}_autoWireStreamStorage(e,t){if(this._attachedEventTiers.length===0)return;let n=this._attachedTierDisposers.get(e);n||(n=[],this._attachedTierDisposers.set(e,n));for(let o of this._attachedEventTiers)n.push(t.attachStorage(o))}event(e,t){if(t!==void 0)return this._ensureAggregateStream(e,t).node;let n=this._eventLogs.get(e);if(n)return n.node;let o=ht([],{name:e,versioning:0,maxSize:this._retainedLimit});o.withLatest();let s=o.entries,a=J([s],([i])=>i,{name:e,describeKind:"state",meta:yt("event",{event_name:e}),guard:wo,initial:s.cache});return this.add(a,{name:e}),this._keepaliveDisposers.push(ge(a)),this._eventLogs.set(e,{log:o,node:a}),this._autoWireStreamStorage(e,o),a}_ensureAggregateStream(e,t){this._eventLogs.has(e)||this.event(e);let n=this._eventLogsByAggregate.get(e);n||(n=new Map,this._eventLogsByAggregate.set(e,n));let o=`${e}::${t}`;this._touchAggregate(o);let s=n.get(t);if(s)return s;let a=`${e}_${t.replace(/[^a-zA-Z0-9_-]/g,"_")}`,i=ht([],{name:a,versioning:0,maxSize:this._retainedLimit});i.withLatest();let d=i.entries,u=J([d],([h])=>h,{name:a,describeKind:"state",meta:yt("event_aggregate",{event_name:e,aggregate_id:t}),guard:wo,initial:d.cache}),c=a,l=0;for(;this.nameOf(this.resolveOptional(c)??u)===c&&(l+=1,c=`${a}_${l}`,this.resolveOptional(c)!==void 0););try{this.add(u,{name:c})}catch{}this._keepaliveDisposers.push(ge(u));let p={log:i,node:u};return n.set(t,p),this._autoWireStreamStorage(`${e}::${t}`,i),this._enforceAggregateLru(),p}resolveOptional(e){try{return this.resolve(e)}catch{return}}_appendEvent(e,t,n){let o=this._eventLogs.get(e);if(o||(this.event(e),o=this._eventLogs.get(e)),o.node.status==="completed"||o.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${o.node.status}).`);let s,a;if(n?.aggregateId!==void 0){let c=`${e}::${n.aggregateId}`;s=(this._aggregateVersions.get(c)??0)+1,this._aggregateVersions.set(c,s),a=this._ensureAggregateStream(e,n.aggregateId)}let i=o.log.entries.v,d=this._freezeEventPayload?Ro(t):t,u={type:e,payload:d,timestampNs:se(),seq:++this._seq,...n?.aggregateId!==void 0?{aggregateId:n.aggregateId}:{},...s!==void 0?{aggregateVersion:s}:{},...n?.correlationId!==void 0?{correlationId:n.correlationId}:{},...n?.causationId!==void 0?{causationId:n.causationId}:{},...n?.metadata!==void 0?{metadata:Object.freeze({...n.metadata})}:{},...n?.handlerVersion!==void 0?{handlerVersion:n.handlerVersion}:{},...i!=null?{v0:{id:i.id,version:i.version}}:{}};return o.log.append(u),a&&a.log.append(u),u}command(e,t){if(this._commandRegs.has(e))throw new jt("command",e);let n=typeof t=="function"?{handler:t}:t,o=V(void 0,{name:e,describeKind:"state",meta:{...yt("command",{command_name:e}),error:null},guard:Ss});if(this.add(o,{name:e}),this._commandRegs.set(e,{handler:n.handler,...n.emits!==void 0?{emits:n.emits}:{},...n.handlerVersion!==void 0?{handlerVersion:n.handlerVersion}:{}}),n.emits)for(let s of n.emits)this._eventLogs.has(s)||this.event(s);return o}dispatch(e,t,n){let o=this._commandRegs.get(e);if(!o)throw new Bt(e);if(n?.aggregateId!==void 0&&n.expectedAggregateVersion!==void 0&&o.emits!==void 0){let u=0;for(let c of o.emits){let l=this._aggregateVersions.get(`${c}::${n.aggregateId}`);l!==void 0&&l>u&&(u=l)}if(u!==n.expectedAggregateVersion)throw new Wt(n.aggregateId,n.expectedAggregateVersion,u)}let s=this.resolve(e),a=[],i=!1,d=u=>{s.emit(u,{internal:!0});try{o.handler(u,{emit:(c,l)=>{if(o.emits!==void 0&&!o.emits.includes(c))throw new zt(e,c,o.emits);a.push(c),this._appendEvent(c,l,{...n?.aggregateId!==void 0?{aggregateId:n.aggregateId}:{},...n?.correlationId!==void 0?{correlationId:n.correlationId}:{},...n?.causationId!==void 0?{causationId:n.causationId}:{},...n?.metadata!==void 0?{metadata:Object.freeze({...n.metadata})}:{},...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}}),s.meta.error.emit(null,{internal:!0})}catch(c){throw i=!0,c}};try{mo(d,{audit:this.dispatches,seq:this._dispatchSeqCursor,freeze:this._freezeCommandPayload,onSuccess:([u],c,{t_ns:l,seq:p})=>({commandName:e,payload:u,outcome:"success",emittedEvents:[...a],t_ns:l,seq:p??0,...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}}),onFailure:([u],c,{t_ns:l,seq:p,errorType:h})=>{let f=c instanceof gt?c:new gt(e,c);return{commandName:e,payload:u,outcome:"failure",error:f,errorType:h,emittedEvents:[...a],t_ns:l,seq:p??0,...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}}}})(t)}catch(u){throw i&&s.meta.error.emit(u,{internal:!0}),u}}projection(e){let{name:t,events:n,reducer:o,initial:s}=e,a=e.mode??"scan",i=e.freezeInputs??!0,d=e.snapshot,u=n.map(E=>(this._eventLogs.has(E)||this.event(E),this._eventLogs.get(E).node));function c(E){E.sort((w,k)=>w.timestampNs-k.timestampNs||w.seq-k.seq||(w.aggregateId??"").localeCompare(k.aggregateId??""))}function l(E){let w=[];for(let k of E)w.push(...k);return c(w),w}let p=u.map(E=>E.cache??[]),h=l(p),f=i?Object.freeze(h):h,m=0,g=s;a==="scan"&&h.length>0&&(g=o(s,f),m=h.length);let R=a==="replay"?o(s,f):g,v=d?.saveDebounceMs??1e3,_=d?.saveEvery??1e3,b,T=0;function O(E){if(d?.save){if(T+=1,T>=_){T=0,b!==void 0&&(clearTimeout(b),b=void 0);let w=d.save(E);w instanceof Promise&&w.catch(()=>{});return}b!==void 0&&clearTimeout(b),b=setTimeout(()=>{b=void 0,T=0;let w=d.save(E);w instanceof Promise&&w.catch(()=>{})},v)}}let y=J(u,E=>{let w=l(E),k;if(a==="replay"){let M=i?Object.freeze(w):w;k=o(s,M)}else{let M=w.slice(m);m=w.length;let A=i?Object.freeze(M):M;k=o(g,A),g=k}return O(k),k},{name:t,describeKind:"derived",meta:yt("projection",{projection_name:t,source_events:n}),guard:ks,initial:R});return this.add(y,{name:t}),this._keepaliveDisposers.push(ge(y)),this._keepaliveDisposers.push(()=>{b!==void 0&&(clearTimeout(b),b=void 0)}),this._projections.add(t),{node:y,rebuild:async E=>{try{let w=E?.pageSize??1e3,k=E?.fromTier??this._attachedEventTiers[0]?.[0],M=l(u.map(j=>j.cache??[])).length,A=s;if(d?.load){let j=await d.load();j!==void 0&&(A=j)}if(!k||!k.loadEntries){let j=l(u.map(X=>X.cache??[])),U=i?Object.freeze(j):j;A=o(A,U)}else{let j=new Set(n),U,X=!1;for(;!X;){let Le=await k.loadEntries({cursor:U,pageSize:w}),$e=[...Le.entries].filter(Xe=>j.has(Xe.type));c($e);let Ze=i?Object.freeze($e):$e;A=o(A,Ze),U=Le.cursor,X=!U||Le.entries.length===0}}if(a==="scan"){let j=l(u.map(X=>X.cache??[])),U=j.slice(M);if(U.length>0){let X=i?Object.freeze(U):U;A=o(A,X)}g=A,m=j.length}return y.emit(A,{internal:!0}),A}catch(w){throw new mt(t,w)}},reset:async()=>{try{let E=s;if(d?.load){let A=await d.load();A!==void 0&&(E=A)}let w=l(u.map(A=>A.cache??[])),k=i?Object.freeze(w):w,M=o(E,k);return a==="scan"&&(g=M,m=w.length),y.emit(M,{internal:!0}),M}catch(E){throw new mt(t,E)}}}}saga(e,t,n,o={}){let s=t.map(f=>(this._eventLogs.has(f)||this.event(f),this._eventLogs.get(f).node)),a=bo(this,`${e}_cursor`,t,0),i=qt({name:`${e}_invocations`,retainedLimit:this._retainedLimit,graph:this}),d=o.aggregateId,u=o.errorPolicy??"advance",c=new Map;for(let f of t){let m=a[f];c.set(f,m.cache??0);let g=m.subscribe(R=>{for(let v of R)v[0]===N&&c.set(f,v[1])});this._keepaliveDisposers.push(g)}let l=go((f,m)=>{n(f)},{audit:i,freeze:!1,...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{},onSuccess:([f,m],g,{t_ns:R})=>({eventType:m,outcome:"success",aggregateId:f.aggregateId,event:f,t_ns:R}),onFailure:([f,m],g,{t_ns:R,errorType:v})=>({eventType:m,outcome:"failure",error:g,errorType:v,aggregateId:f.aggregateId,event:f,t_ns:R})}),p={},h=he(s,(f,m)=>{let g=p.n.meta.error;for(let R=0;R<f.length;R++){let v=f[R];if(v==null||v.length===0)continue;let _=v.at(-1);if(!_)continue;let b=t[R],T=a[b],O=c.get(b)??0;if(_.length>O){let y=_.slice(O),x=O;for(let S of y){let E=S;if(d!==void 0&&E.aggregateId!==d){x+=1;continue}try{l(E,b),g.emit(null,{internal:!0}),x+=1}catch(w){if(g.emit(w,{internal:!0}),u==="hold")break;x+=1}}T.emit(x)}}},{name:e,describeKind:"effect",meta:{...yt("saga",{saga_name:e,source_events:t}),error:null}});return p.n=h,this.add(h,{name:e}),this._keepaliveDisposers.push(ge(h)),this._sagas.add(e),{node:h,invocations:i,audit:i,cursors:a}}};function xo(r,e){let t=new kn(r,e),{factory:n,factoryArgs:o,...s}=e??{};return t.tagFactory("cqrs",vn(s)),t}var Cn=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},Mn=class{graph=new Z("request");onModuleDestroy(){this.graph.destroy()}},Eo,An;Eo=[(0,bt.Module)({})];var Te=class Te{static forRoot(e){let t=e??{},n=t.name??"root",o=[{provide:ae,useFactory:()=>{let s=new Z(n);return t.build&&t.build(s),t.snapshot&&s.restore(t.snapshot),s}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:s=>new Cn(s),inject:[ae]},{provide:Ge,useFactory:(s,a)=>new Ge(s,a),inject:[ae,No.ModuleRef]}];if(t.nodes)for(let s of t.nodes)o.push({provide:ue(s),useFactory:a=>a.resolve(s),inject:[ae]});return t.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new Mn,scope:bt.Scope.REQUEST},{provide:De,useFactory:s=>s.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:bt.Scope.REQUEST}),{module:Te,global:!0,providers:o,exports:[ae,...(t.nodes??[]).map(ue),...t.requestScope?[De]:[]]}}static forFeature(e){let t=[{provide:Q(e.name),useFactory:n=>{let o=new Z(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),n.mount(e.name,o),o},inject:[ae]}];if(e.nodes)for(let n of e.nodes)t.push({provide:ue(`${e.name}::${n}`),useFactory:o=>o.resolve(n),inject:[Q(e.name)]});return{module:Te,providers:t,exports:[Q(e.name),...(e.nodes??[]).map(n=>ue(`${e.name}::${n}`))]}}static forCqrs(e){let t=[{provide:Q(e.name),useFactory:n=>{let o=xo(e.name,e.cqrs);return e.eventStorage&&o.attachEventStorage(e.eventStorage),e.build&&e.build(o),n.mount(e.name,o),o},inject:[ae]}];if(e.nodes)for(let n of e.nodes)t.push({provide:ue(`${e.name}::${n}`),useFactory:o=>o.resolve(n),inject:[Q(e.name)]});return{module:Te,providers:t,exports:[Q(e.name),...(e.nodes??[]).map(n=>ue(`${e.name}::${n}`))]}}};An=Un(null),Te=Qn(An,0,"GraphReflyModule",Eo,Te),Jn(An,1,Te);var Kt=Te;var Gn={};ce(Gn,{useStore:()=>As,useSubscribe:()=>Oo,useSubscribeRecord:()=>Cs});var me=require("react");B();function Oo(r){return(0,me.useSyncExternalStore)(e=>{let t=!1,n=r.subscribe(()=>{t||e()});return()=>{t=!0,n()}},()=>r.cache,()=>r.cache)}function As(r){let e=Oo(r),t=(0,me.useCallback)(n=>{r.down([[I],[N,n]])},[r]);return[e,t]}function Cs(r,e){let t=(0,me.useRef)(e);t.current=e;let n=(0,me.useMemo)(()=>{let o=()=>{let a={},i=r.cache??[];for(let d of i){let u=t.current(d),c={};for(let l of Object.keys(u))c[l]=u[l].cache;a[d]=c}return a},s=o();return{subscribe:a=>{let i=!1,d=[],u=()=>{for(let p of d)p();d=[]},c=p=>{u();for(let h of p){let f=t.current(h);for(let m of Object.keys(f)){let g=f[m].subscribe(()=>{s=o(),i||a()});d.push(g)}}s=o(),i||a()},l=r.subscribe(p=>{let h=p.some(f=>f[0]===N||f[0]===W);!i&&h&&c(r.cache??[])});return c(r.cache??[]),()=>{i=!0,l(),u()}},getSnapshot:()=>s}},[r]);return(0,me.useSyncExternalStore)(n.subscribe,n.getSnapshot,n.getSnapshot)}var Ln={};ce(Ln,{Signal:()=>Ms});Oe();B();fe();var Qe=[];function Ut(r){let e=r.cache;return r.subscribe(n=>{for(let[o,s]of n)o===N&&(e=s)})(),e}var In=class{_node;_equals;constructor(e,t){this._equals=t?.equals??Object.is,this._node=V(e,{...t,resubscribable:!0,resetOnTeardown:!0})}get(){let e=Qe[Qe.length-1];return e?(this._node.status==="sentinel"&&Ut(this._node),e(this._node)):this._node.status==="sentinel"?Ut(this._node):this._node.cache}set(e){this._equals(this.get(),e)||le(()=>{this._node.down([[I],[N,e]])})}},Pn=class{_node;constructor(e,t){this._node=it(n=>{Qe.push(n);try{return e()}finally{Qe.pop()}},{...t,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=Qe[Qe.length-1];return e?(this._node.status==="sentinel"&&Ut(this._node),e(this._node)):this._node.status==="sentinel"?Ut(this._node):this._node.cache}},Ms={State:In,Computed:Pn,sub:(r,e)=>{let t=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,n=!0;return r._node.subscribe(o=>{for(let[s,a]of o){if(s===N){if(n){n=!1;continue}t.data?.(a)}s===D&&t.error?.(a),s===P&&t.complete?.()}})}};var $n={};ce($n,{useStore:()=>Ds,useSubscribe:()=>So,useSubscribeRecord:()=>Gs});var ye=require("solid-js");B();function So(r){let[e,t]=(0,ye.createSignal)(r.cache,{equals:!1}),n=r.subscribe(()=>{t(()=>r.cache)});return(0,ye.getOwner)()?(0,ye.onCleanup)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),e}function Ds(r){return[So(r),n=>{r.down([[I],[N,n]])}]}function Gs(r,e){let[t,n]=(0,ye.createSignal)({},{equals:!1}),o=[],s=()=>{for(let u of o)u();o=[]},a=()=>{let u={};for(let c of r.cache??[]){let l=e(c),p={};for(let h of Object.keys(l))p[h]=l[h].cache;u[c]=p}return u},i=u=>{s();for(let c of u){let l=e(c);for(let p of Object.keys(l)){let h=l[p].subscribe(()=>{n(()=>a())});o.push(h)}}n(()=>a())},d=r.subscribe(u=>{u.some(c=>c[0]===N||c[0]===W)&&i(r.cache??[])});return i(r.cache??[]),(0,ye.getOwner)()?(0,ye.onCleanup)(()=>{d(),s()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),t}var Fn={};ce(Fn,{useStore:()=>Ps,useSubscribe:()=>Is,useSubscribeRecord:()=>Ls});B();function Is(r){return{subscribe(e){let t=r.subscribe(()=>{e(r.cache)});return e(r.cache),t}}}function Ps(r){return{subscribe(e){let t=r.subscribe(()=>{e(r.cache)});return e(r.cache),t},set(e){r.down([[I],[N,e]])},update(e){let t=e(r.cache);r.down([[I],[N,t]])}}}function Ls(r,e){return{subscribe(t){let n=[],o=()=>{for(let d of n)d();n=[]},s=()=>{let d={};for(let u of r.cache??[]){let c=e(u),l={};for(let p of Object.keys(c))l[p]=c[p].cache;d[u]=l}return d},a=d=>{o();for(let u of d){let c=e(u);for(let l of Object.keys(c)){let p=c[l].subscribe(()=>{t(s())});n.push(p)}}t(s())},i=r.subscribe(d=>{d.some(u=>u[0]===N||u[0]===W)&&a(r.cache??[])});return a(r.cache??[]),()=>{i(),o()}}}}var Vn={};ce(Vn,{useStore:()=>Fs,useSubscribe:()=>$s,useSubscribeRecord:()=>Vs});var z=require("vue");B();function $s(r){let e=(0,z.shallowRef)(r.cache),t=r.subscribe(()=>{e.value=r.cache});return(0,z.getCurrentScope)()?(0,z.onScopeDispose)(()=>t()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,z.readonly)(e)}function Fs(r){let e=(0,z.shallowRef)(r.cache),t=r.subscribe(()=>{e.value=r.cache});return(0,z.getCurrentScope)()?(0,z.onScopeDispose)(()=>t()):typeof console<"u"&&console.warn("[graphrefly-ts] useStore called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,z.computed)({get:()=>e.value,set:n=>{r.down([[I],[N,n]])}})}function Vs(r,e){let t=(0,z.shallowRef)({}),n=new Map;function o(){let i={};for(let[d,u]of n)i[d]={...u.values};t.value=i}function s(i){for(let u of n.values())for(let c of u.subs)c();n.clear();for(let u of i){let c=e(u),l=Object.keys(c),p={},h=[];for(let f of l){let m=c[f];p[f]=m.cache;let g=m.subscribe(()=>{p[f]=m.cache,o()});h.push(g)}n.set(u,{subs:h,values:p})}let d={};for(let[u,c]of n)d[u]={...c.values};t.value=d}return(0,z.watch)(()=>[...(typeof r=="function"?r():(0,z.isRef)(r)?r.value:r)??[]],i=>s(i??[]),{immediate:!0}),(0,z.getCurrentScope)()?(0,z.onScopeDispose)(()=>{for(let i of n.values())for(let d of i.subs)d();n.clear()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,z.readonly)(t)}var Hn={};ce(Hn,{create:()=>qs});B();fe();ft();var Hs=()=>!1;function qs(r){let e=new Z("zustand"),t=V(void 0,{name:"state",equals:Hs});e.add(t,{name:"state"});let n=()=>t.cache,o=(i,d)=>{let u=t.cache,c=typeof i=="function"?i(u):i;t.emit(d?c:{...u,...c})},s={getState:n,setState:o,getInitialState:()=>a,subscribe:i=>{let d=!0,u=t.cache;return t.subscribe(c=>{for(let[l,p]of c)if(l===N){if(d){d=!1;continue}i(p,u),u=p}})},destroy:e.destroy.bind(e)},a=r(o,n,s);return t.emit(a),Object.assign(e,s)}0&&(module.exports={jotai,nanostores,nestjs,react,signals,solid,svelte,vue,zustand});
17
+ // src/compat/index.ts
18
+ var compat_exports = {};
19
+ module.exports = __toCommonJS(compat_exports);
20
+ __reExport(compat_exports, require("@graphrefly/pure-ts/compat"), module.exports);
21
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/compat/index.ts"],"sourcesContent":["// Phase 13.9.A shim — re-export from pure-TS sibling until\n// @graphrefly/native (napi binding) and per-milestone swap-overs land.\nexport * from \"@graphrefly/pure-ts/compat\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAEA,2BAAc,uCAFd;","names":[]}
@@ -1,22 +1 @@
1
- export { i as jotai } from '../index-ChOyVLKm.cjs';
2
- export { i as nanostores } from '../index-C9kSENB4.cjs';
3
- export { i as nestjs } from '../index-BAOD98JD.cjs';
4
- export { i as react } from '../index-z96luz5O.cjs';
5
- export { a as signals } from '../index-O7fucFrU.cjs';
6
- export { i as solid } from '../index-BVpm6noz.cjs';
7
- export { i as svelte } from '../index-hHcaFlJX.cjs';
8
- export { i as vue } from '../index-BJX94aud.cjs';
9
- export { i as zustand } from '../index-f5IivDUX.cjs';
10
- import '../node-ClS5yC-B.cjs';
11
- import '../observable-DLGPPtb8.cjs';
12
- import 'rxjs';
13
- import '@nestjs/common';
14
- import '@nestjs/core';
15
- import '../graph-C4SHb3Ly.cjs';
16
- import '../meta-vE8bxW1E.cjs';
17
- import '../extra/storage-core.cjs';
18
- import '../extra/storage-tiers.cjs';
19
- import '../index-COD1kVoS.cjs';
20
- import '../index-C9pjcz3l.cjs';
21
- import '../reactive-log-B00laMSQ.cjs';
22
- import 'vue';
1
+ export * from '@graphrefly/pure-ts/compat';
@@ -1,22 +1 @@
1
- export { i as jotai } from '../index-Dmqp7KjD.js';
2
- export { i as nanostores } from '../index-CCq87F7t.js';
3
- export { i as nestjs } from '../index-cm1GNcWE.js';
4
- export { i as react } from '../index-BG0BN3PB.js';
5
- export { a as signals } from '../index-C59mYFKp.js';
6
- export { i as solid } from '../index-CJK1JkYy.js';
7
- export { i as svelte } from '../index-DIOoAZUX.js';
8
- export { i as vue } from '../index-CvrqGfNS.js';
9
- export { i as zustand } from '../index-C7O6r5fV.js';
10
- import '../node-ClS5yC-B.js';
11
- import '../observable-BsBzUrcI.js';
12
- import 'rxjs';
13
- import '@nestjs/common';
14
- import '@nestjs/core';
15
- import '../graph-7VguS7a4.js';
16
- import '../meta-BgVAsg9j.js';
17
- import '../extra/storage-core.js';
18
- import '../extra/storage-tiers.js';
19
- import '../index-CQG3D1cp.js';
20
- import '../index-CZQXo5tH.js';
21
- import '../reactive-log-BezYsbA_.js';
22
- import 'vue';
1
+ export * from '@graphrefly/pure-ts/compat';
@@ -1 +1,3 @@
1
- import{a as e}from"../chunk-K2Q24F5T.js";import{b as a}from"../chunk-KRH66M4O.js";import{i as b}from"../chunk-CLD3F4R5.js";import{G as c}from"../chunk-OFZG3TB3.js";import"../chunk-VQ4A6T2A.js";import{d}from"../chunk-VJLMUKOI.js";import{d as f}from"../chunk-VIMF6LGM.js";import{d as g}from"../chunk-6QZNQS5B.js";import{d as h}from"../chunk-GPW2V3RE.js";import{b as i}from"../chunk-TPKQW72B.js";import"../chunk-4I45FVQS.js";import"../chunk-5QDBSZBV.js";import"../chunk-FDQGFWLF.js";import"../chunk-L6NSJVJZ.js";import"../chunk-KVV66NN2.js";import"../chunk-3G5U5QNE.js";import"../chunk-C72GO4IZ.js";import"../chunk-626TESAC.js";import"../chunk-ESMPEKEV.js";import"../chunk-35JTVPOX.js";import"../chunk-JQFH2DV6.js";import"../chunk-V5A7M7RJ.js";import"../chunk-LYCLF26R.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{a as jotai,b as nanostores,c as nestjs,d as react,e as signals,f as solid,g as svelte,h as vue,i as zustand};
1
+ // src/compat/index.ts
2
+ export * from "@graphrefly/pure-ts/compat";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/compat/index.ts"],"sourcesContent":["// Phase 13.9.A shim — re-export from pure-TS sibling until\n// @graphrefly/native (napi binding) and per-milestone swap-overs land.\nexport * from \"@graphrefly/pure-ts/compat\";\n"],"mappings":";AAEA,cAAc;","names":[]}
@@ -1 +1,21 @@
1
- "use strict";var J=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var Fe=(s,e)=>{for(var t in e)J(s,t,{get:e[t],enumerable:!0})},Ie=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ce(e))!De.call(s,r)&&r!==t&&J(s,r,{get:()=>e[r],enumerable:!(n=Oe(e,r))||n.enumerable});return s};var Ge=s=>Ie(J({},"__esModule",{value:!0}),s);var Ze={};Fe(Ze,{atom:()=>Je});module.exports=Ge(Ze);var G=Symbol.for("graphrefly/START"),_=Symbol.for("graphrefly/DATA"),A=Symbol.for("graphrefly/DIRTY"),k=Symbol.for("graphrefly/RESOLVED"),M=Symbol.for("graphrefly/INVALIDATE"),E=Symbol.for("graphrefly/PAUSE"),V=Symbol.for("graphrefly/RESUME"),w=Symbol.for("graphrefly/TEARDOWN"),R=Symbol.for("graphrefly/COMPLETE"),p=Symbol.for("graphrefly/ERROR"),S=Object.freeze([A]),X=Object.freeze([k]),Ve=Object.freeze([M]),Z=Object.freeze([G]),He=Object.freeze([R]),Le=Object.freeze([w]),Q=Object.freeze([S]),de=Object.freeze([X]),le=Object.freeze([Ve]),ce=Object.freeze([He]),ee=Object.freeze([Le]);var Pe={name:"json",version:1,contentType:"application/json",encode(s){let e=JSON.stringify(s);return new TextEncoder().encode(e)},decode(s,e){let t=new TextDecoder().decode(s);return JSON.parse(t)}};function ue(s){s.registerCodec(Pe)}var We={type:"system",id:""};function B(s){if(s==null)return We;let{type:e,id:t,...n}=s;return{type:e??"system",id:t??"",...n}}var te=0,Ue=!1,he=[],fe=[],pe=[],Be=[];function ge(){return te>0||Ue}function _e(){return te>0}function ye(s){te>0?Be.push(s):s()}function j(s,e,t){if(e.length===0)return;if(e.length===1){let l=t(e[0][0]);if(l<3||!ge()){s(e);return}(l>=5?pe:l===4?fe:he).push(()=>s(e));return}let n=e.length,r=n,a=n,i=n,o=0;for(;o<n&&t(e[o][0])<3;)o++;for(r=o;o<n&&t(e[o][0])===3;)o++;for(a=o;o<n&&t(e[o][0])===4;)o++;i=o;let d=ge();if(r>0){let l=e.slice(0,r);s(l)}if(a>r){let l=e.slice(r,a);d?he.push(()=>s(l)):s(l)}if(i>a){let l=e.slice(a,i);d?fe.push(()=>s(l)):s(l)}if(n>i){let l=e.slice(i,n);d?pe.push(()=>s(l)):s(l)}}function me(){return Date.now()*1e6}var z=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=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}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=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 be(s){s.registerMessageType(G,{tier:0,wireCrossing:!1}),s.registerMessageType(A,{tier:1,wireCrossing:!1}),s.registerMessageType(M,{tier:1,wireCrossing:!1,metaPassthrough:!1}),s.registerMessageType(E,{tier:2,wireCrossing:!1}),s.registerMessageType(V,{tier:2,wireCrossing:!1}),s.registerMessageType(_,{tier:3,wireCrossing:!0}),s.registerMessageType(k,{tier:3,wireCrossing:!0}),s.registerMessageType(R,{tier:4,wireCrossing:!0,metaPassthrough:!1}),s.registerMessageType(p,{tier:4,wireCrossing:!0,metaPassthrough:!1}),s.registerMessageType(w,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var O=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}};function ne(s){if(s===void 0)return null;if(typeof s=="number"){if(!Number.isFinite(s))throw new TypeError(`Cannot hash non-finite number: ${s}`);if(Number.isInteger(s)&&!Number.isSafeInteger(s))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${s}. Cross-language cid parity is not guaranteed for unsafe integers.`);return s}if(typeof s=="string"||typeof s=="boolean"||s===null)return s;if(Array.isArray(s))return s.map(ne);if(typeof s=="object"&&s!==null){let e={};for(let t of Object.keys(s).sort())e[t]=ne(s[t]);return e}return null}var je=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]),ze=new TextEncoder;function $e(s){let e=ze.encode(s),t=e.length,n=t*8,r=t+9+63&-64,a=new Uint8Array(r);a.set(e),a[t]=128;let i=new DataView(a.buffer);i.setUint32(r-4,n>>>0,!1),i.setUint32(r-8,Math.floor(n/4294967296)>>>0,!1);let o=1779033703,d=3144134277,l=1013904242,c=2773480762,h=1359893119,g=2600822924,u=528734635,y=1541459225,N=new Uint32Array(64),b=(T,m)=>T>>>m|T<<32-m;for(let T=0;T<r;T+=64){for(let f=0;f<16;f++)N[f]=i.getUint32(T+f*4,!1);for(let f=16;f<64;f++){let F=N[f-15],I=N[f-2],U=b(F,7)^b(F,18)^F>>>3,K=b(I,17)^b(I,19)^I>>>10;N[f]=N[f-16]+U+N[f-7]+K>>>0}let m=o,C=d,D=l,q=c,x=h,P=g,W=u,Y=y;for(let f=0;f<64;f++){let F=b(x,6)^b(x,11)^b(x,25),I=x&P^~x&W,U=Y+F+I+je[f]+N[f]>>>0,K=b(m,2)^b(m,13)^b(m,22),Re=m&C^m&D^C&D,Se=K+Re>>>0;Y=W,W=P,P=x,x=q+U>>>0,q=D,D=C,C=m,m=U+Se>>>0}o=o+m>>>0,d=d+C>>>0,l=l+D>>>0,c=c+q>>>0,h=h+x>>>0,g=g+P>>>0,u=u+W>>>0,y=y+Y>>>0}let v=T=>T.toString(16).padStart(8,"0");return v(o)+v(d)+v(l)+v(c)+v(h)+v(g)+v(u)+v(y)}function se(s){let e=ne(s??null),t=JSON.stringify(e);return $e(t).slice(0,16)}function qe(){let s=globalThis.crypto;if(s?.randomUUID)return s.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 re(s,e,t){let n=t?.id??qe();if(s===0)return{id:n,version:0};let a=(t?.hash??se)(e);return{id:n,version:0,cid:a,prev:null}}function ve(s,e,t){s.version+=1,"cid"in s&&(s.prev=s.cid,s.cid=t(e))}var Te=()=>{},xe=100;function we(s){return{node:s,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function oe(s){s.prevData=void 0,s.dirty=!1,s.involvedThisWave=!1,s.dataBatch.length=0,s.terminal=void 0}function $(s){return s.length===0?s:typeof s[0]=="symbol"?[s]:s}var Ye=(s,e,t,n)=>{t.direction==="down-in"&&s._onDepMessage(t.depIndex,e)},Ke=(s,e,t,n)=>{let r=s;if(r._status==="completed"||r._status==="errored")return;let a=r._cached,i=a===void 0?[Z]:[Z,[_,a]];r._status==="dirty"&&i.push(S),j(e,i,r._config.tierOf)},ae=new z({onMessage:Ye,onSubscribe:Ke});be(ae);ue(ae);var H=class s{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,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._partial=n.partial??!1,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??se;let r=n.versioning??this._config.defaultVersioning;this._versioningLevel=r,this._versioning=r!=null?re(r,this._cached===void 0?void 0:this._cached,{id:n.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(we);let a={};for(let[o,d]of Object.entries(n.meta??{})){let l={initial:d,name:`${n.name??"node"}:meta:${o}`,describeKind:"state",config:this._config};n.guard!=null&&(l.guard=n.guard),a[o]=new s([],void 0,l)}Object.freeze(a),this.meta=a,this._hasMeta=Object.keys(a).length>0;let i=this;this._actions={emit(o){i._emit([[_,o]])},down(o){i._emit($(o))},up(o){i._emitUp($(o))}},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 r=t?.hash??this._hashFn;r!==this._hashFn&&(this._hashFn=r);let a=this._cached===void 0?void 0:this._cached,i=this._versioning,o=i?.id??t?.id,d=i?.version??0,l=re(e,a,{id:o,hash:r});l.version=d,this._versioning=l,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=B(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 r=B(e?.actor),a=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(r,a))throw new O({actor:r,action:a,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(r,a))throw new O({actor:r,action:a,nodeName:this.name})}this._lastMutation={actor:r,timestamp_ns:me()}}down(e,t){let n=$(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=$(e);if(n.length===0)return;this._checkGuard(t);let r=t??{internal:!0};this._validateUpTiers(n);for(let a of this._deps)a.node.up?.(n,r)}_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 r=t(n[0]);if(r===3||r===4)throw new Error(`Node "${this.name}": tier-${r} 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=B(t);if(!this._guard(d,"observe"))throw new O({actor:d,action:"observe",nodeName:this.name})}let r=this._isTerminal&&this._resubscribable;if(r){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)oe(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let a;try{a=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:r},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 a=="function")try{a()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let o=!1;return()=>{o||(o=!0,this._sinkCount-=1,this._removeSink(e),typeof a=="function"&&a(),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 r=n,a=this._deps[n];a.unsub=Te,a.unsub=a.node.subscribe(i=>{if(a.unsub===null)return;let o=this._config.tierOf,d=!1;for(let l of i)o(l[0])>=3&&(d=!0),this._config.onMessage(this,l,{direction:"down-in",depIndex:r},this._actions);d&&this._maybeRunFnOnSettlement()}),t++}}catch(n){this._deps[t].unsub=null;for(let r=0;r<t;r++){let a=this._deps[r];if(a.unsub!=null){let i=a.unsub;a.unsub=null;try{i()}catch{}oe(a)}}throw this._dirtyDepCount=0,n}}_addDep(e){for(let r=0;r<this._deps.length;r++)if(this._deps[r].node===e)return r;let t=this._deps.length,n=we(e);if(this._deps.push(n),this._sinks==null)return t;n.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Q),n.unsub=Te;try{n.unsub=e.subscribe(r=>{if(n.unsub===null)return;let a=this._config.tierOf,i=!1;for(let o of r)a(o[0])>=3&&(i=!0),this._config.onMessage(this,o,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(r){throw n.unsub=null,this._deps.pop(),this._dirtyDepCount--,r}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(n){this._emit([[p,this._wrapFnError("cleanup threw",n)]])}else if(t!=null&&typeof t=="object"){let n=t.deactivate;if(typeof n=="function")try{n()}catch(r){this._emit([[p,this._wrapFnError("cleanup.deactivate threw",r)]])}}for(let n of this._deps){if(n.unsub!=null){let r=n.unsub;n.unsub=null;try{r()}catch{}}oe(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],r=t[0];if(this._inspectorHooks!=null){let a={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(a)}if(r!==G){if(r===A){this._depDirtied(n);return}if(r===M){if(this._depInvalidated(n),this._cached===void 0)return;this._emit(le);return}if(r===E||r===V){this._emit([t]);return}if(r===w){this._emit(ee);return}if(r===_)this._depSettledAsData(n,t[1]);else if(r===k)this._depSettledAsResolved(n);else if(r===R)this._depSettledAsTerminal(n,!0);else if(r===p)this._depSettledAsTerminal(n,t[1]);else{this._emit([t]);return}if(!this._fn){(r===_||r===k)&&this._emit([t]),(r===R||r===p)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Q))}_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._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let t=this._deps[e];if(t.dataBatch.length===0&&t.prevData===void 0&&t.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(de),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[p,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(ce)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[p,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(o){this._emit([[p,this._wrapFnError("cleanup.beforeRun threw",o)]]);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 o=t[i];o!=null&&o.length>0&&(this._deps[i].prevData=o[o.length-1])}let r=this._deps.map(i=>i.terminal),a={prevData:n,terminalDeps:r,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:n};for(let o of this._inspectorHooks)o(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,a);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let o=i;(typeof o.beforeRun=="function"||typeof o.deactivate=="function"||typeof o.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[p,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>xe?(this._rerunDepth=0,this._emit([[p,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${xe} \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"?[S,e[0]]:e;let n=!0,r=!1,a=!1,i=-1;for(let d of e){let l=t(d[0]);l<i&&(n=!1),l===3&&(r=!0),d[0]===A&&(a=!0),i=l}let o=e;if(!n){let d=e.map((l,c)=>({m:l,i:c,tier:t(l[0])}));d.sort((l,c)=>l.tier-c.tier||l.i-c.i),o=d.map(l=>l.m)}if(r&&!a&&this._status!=="dirty"){let d=0;for(;d<o.length&&t(o[d][0])===0;)d++;return d===0?[S,...o]:[...o.slice(0,d),S,...o.slice(d)]}return o}_emit(e){if(e.length===0)return;for(let o=0;o<e.length;o++){let d=e[o];if(d[0]===p&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let o=e.filter(d=>d[0]===w||d[0]===M);if(o.length===0)return;t=o}t=this._frameBatch(t);let r=null;for(let o=0;o<t.length;o++){let d=t[o],l=d[0];if(l!==E&&l!==V){r?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${l===E?"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 h=d[1];if(l===E)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(h),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(h))c=!1;else if(this._pauseLocks.delete(h),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let g=this._pauseBuffer;this._pauseBuffer=[],this._emit(g)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?r?.push(d):r==null&&(r=t.slice(0,o))}if(r!=null){if(r.length===0)return;t=r}if(this._hasMeta&&t.some(o=>o[0]===w))for(let o of Object.keys(this.meta))try{this.meta[o]._emit(ee)}catch{}let{finalMessages:a,equalsError:i}=this._updateState(t);if(a.length>0&&this._config.inspectorEnabled){let o=this._config.globalInspector;if(o!=null)try{o({kind:"emit",node:this,messages:a})}catch{}}if(a.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let o=this._config.tierOf,d=[];for(let l of a)o(l[0])===3?this._pauseBuffer.push(l):d.push(l);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(a);i!=null&&this._emit([[p,i]])}_updateState(e){let t=this._config.tierOf,n,r,a=-1,i=0;for(let c of e)t(c[0])===3&&i++;let o=i<=1,d=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===_){d=c;break}}for(let c=0;c<e.length;c++){let h=e[c],g=h[0];if(g===_){if(h.length>=2){let u=!1;if(o&&this._cached!==void 0)try{u=this._equals(this._cached,h[1])}catch(y){r=this._wrapFnError("equals threw",y),a=c;break}if(u){n==null&&(n=e.slice(0,c)),n.push(X),this._status="resolved";continue}this._cached=h[1],this._versioning!=null&&(d<0||c===d)&&ve(this._versioning,h[1],this._hashFn)}this._status="settled",n?.push(h)}else if(n?.push(h),g===A)this._status="dirty";else if(g===k)this._status="resolved";else if(g===R){this._status="completed";{let u=this._config.rigorRecorder;if(u!=null)try{u.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(g===p){this._status="errored";{let u=this._config.rigorRecorder;if(u!=null)try{u.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(g===M){if(this._cached!==void 0){let y=this._config.rigorRecorder;if(y!=null)try{y.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let u=this._cleanup;if(typeof u=="function"){this._cleanup=void 0;try{u()}catch{}}else if(u!=null&&typeof u=="object"){let y=u.invalidate;if(typeof y=="function")try{y()}catch{}}}else g===w&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let l=a>=0?n??e.slice(0,a):n??e;return r!=null?{finalMessages:l,equalsError:r}:{finalMessages:l}}_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(_e()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ye(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}j(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);j(this._deliverToSinks,t,this._config.tierOf)}},Ne=s=>Array.isArray(s),ie=s=>typeof s=="object"&&s!=null&&!Array.isArray(s);function Ae(s,e,t){let n=Ne(s)?s:[],r=typeof s=="function"?s:typeof e=="function"?e:void 0,a={};return Ne(s)?a=(ie(e)?e:t)??{}:ie(s)?a=s:a=(ie(e)?e:t)??{},new H(n,r,a)}function ke(s,e){return Ae([],{...e,initial:s})}function Me(s,e){let t,n=new Map,r=(a,i,o)=>{let d=!1,l=c=>{let h=n.get(c);if(h!==void 0){if(h<a.length){let u=a[h];return u!=null&&u.length>0?u.at(-1):o.prevData[h]}return c.cache}d=!0;let g=t._addDep(c);return n.set(c,g),c.cache};try{let c=s(l,o);d||(i.emit(c),o.store.__autoTrackLastDiscoveryError!=null&&delete o.store.__autoTrackLastDiscoveryError)}catch(c){if(!d)throw c;o.store.__autoTrackLastDiscoveryError=c}};return t=new H([],r,{describeKind:"derived",...e}),t}function Je(s,e,t){if(typeof s=="function"){let n=s;return typeof e=="function"?Ee(n,e,t):Ee(n,void 0,e)}return Xe(s,e)}function L(s){let e=s.cache,t;if(s.subscribe(r=>{for(let[a,i]of r)a===_&&(e=i),a===p&&(t=i)})(),t)throw t;return e}function Xe(s,e){let t=ke(s,{...e,resubscribable:!0,resetOnTeardown:!0});return{get:()=>t.status==="sentinel"?L(t):t.cache,set:n=>t.emit(n),update:n=>{let r=t.status==="sentinel"?L(t):t.cache;t.emit(n(r))},subscribe:n=>{let r=!0;return t.subscribe(a=>{for(let[i,o]of a)if(i===_){if(r){r=!1;continue}n(o)}})},meta:t.meta,_node:t}}function Ee(s,e,t){let n=Me(a=>s(i=>{let o=i._node;return o.status==="sentinel"&&L(o),a(o)}),{...t,resubscribable:!0,resetOnTeardown:!0}),r={get:()=>n.status==="sentinel"?L(n):n.cache,subscribe:a=>{let i=!0;return n.subscribe(o=>{for(let[d,l]of o)if(d===_){if(i){i=!1;continue}a(l)}})},meta:n.meta,_node:n};if(e){let a=d=>d.get(),i=(d,l)=>d.set(l),o=r;return o.set=d=>e(a,i,d),o.update=d=>{let l=n.status==="sentinel"?L(n):n.cache;return e(a,i,d(l))},o}return r}0&&(module.exports={atom});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+
17
+ // src/compat/jotai/index.ts
18
+ var jotai_exports = {};
19
+ module.exports = __toCommonJS(jotai_exports);
20
+ __reExport(jotai_exports, require("@graphrefly/pure-ts/compat/jotai"), module.exports);
21
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/compat/jotai/index.ts"],"sourcesContent":["// Phase 13.9.A shim — re-export from pure-TS sibling until\n// @graphrefly/native (napi binding) and per-milestone swap-overs land.\nexport * from \"@graphrefly/pure-ts/compat/jotai\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAEA,0BAAc,6CAFd;","names":[]}
@@ -1,2 +1 @@
1
- import '../../node-ClS5yC-B.cjs';
2
- export { A as AtomOptions, G as GetFn, R as ReadFn, a as ReadableAtom, S as SetFn, W as WritableAtom, b as WriteFn, c as atom } from '../../index-ChOyVLKm.cjs';
1
+ export * from '@graphrefly/pure-ts/compat/jotai';
@@ -1,2 +1 @@
1
- import '../../node-ClS5yC-B.js';
2
- export { A as AtomOptions, G as GetFn, R as ReadFn, a as ReadableAtom, S as SetFn, W as WritableAtom, b as WriteFn, c as atom } from '../../index-Dmqp7KjD.js';
1
+ export * from '@graphrefly/pure-ts/compat/jotai';