@graphrefly/graphrefly 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (396) hide show
  1. package/dist/backoff-HPZMEZNF.js +1 -0
  2. package/dist/cascading-B-5zmAUv.d.cts +180 -0
  3. package/dist/cascading-D9WG1-9L.d.ts +180 -0
  4. package/dist/chunk-2FOAM3OR.js +1 -0
  5. package/dist/chunk-2PMCKKRK.js +1 -0
  6. package/dist/chunk-3JXNEPCD.js +2 -0
  7. package/dist/chunk-3R5HFPX7.js +78 -0
  8. package/dist/chunk-4GKB4OUJ.js +1 -0
  9. package/dist/chunk-4VVTGLXJ.js +1 -0
  10. package/dist/chunk-5QDBSZBV.js +1 -0
  11. package/dist/chunk-6QZNQS5B.js +1 -0
  12. package/dist/chunk-6V3SEX2I.js +1 -0
  13. package/dist/chunk-76A3HVQE.js +9 -0
  14. package/dist/chunk-7H6LGFUG.js +64 -0
  15. package/dist/chunk-CK2E7BTU.js +1 -0
  16. package/dist/chunk-CKCSDI7T.js +6 -0
  17. package/dist/chunk-CRXTH3SH.js +1 -0
  18. package/dist/chunk-CWLN3X3N.js +1 -0
  19. package/dist/chunk-D7A7DBE4.js +1 -0
  20. package/dist/chunk-DBGGMN3D.js +1 -0
  21. package/dist/chunk-DQA3UIQ2.js +1 -0
  22. package/dist/chunk-ERLIRFPA.js +1 -0
  23. package/dist/chunk-ESMPEKEV.js +1 -0
  24. package/dist/chunk-ETWTCCJI.js +1 -0
  25. package/dist/chunk-FNYWM6JC.js +1 -0
  26. package/dist/chunk-GHJJR5P4.js +1 -0
  27. package/dist/chunk-GPW2V3RE.js +1 -0
  28. package/dist/chunk-I6VIH3VA.js +1 -0
  29. package/dist/chunk-K2GNMCQT.js +1 -0
  30. package/dist/chunk-LBTDSCCO.js +3 -0
  31. package/dist/chunk-LQ3Y5NJS.js +1 -0
  32. package/dist/chunk-MIQTDPY4.js +5 -0
  33. package/dist/chunk-MTTAAPCK.js +1 -0
  34. package/dist/chunk-OAWLCNJJ.js +1 -0
  35. package/dist/chunk-OBKQQA5I.js +1 -0
  36. package/dist/chunk-OYHGKYQM.js +1 -0
  37. package/dist/chunk-PIOGHC63.js +1 -0
  38. package/dist/chunk-QWAPKG3O.js +2 -0
  39. package/dist/chunk-QYADASLV.js +1 -0
  40. package/dist/chunk-RHESUC3V.js +43 -0
  41. package/dist/chunk-S35VARIR.js +1 -0
  42. package/dist/chunk-SC3U7ETD.js +1 -0
  43. package/dist/chunk-U3AICJKU.js +1 -0
  44. package/dist/chunk-UMBIDLJ4.js +1 -0
  45. package/dist/chunk-UPHHLMHE.js +1 -0
  46. package/dist/chunk-UPXUCFMX.js +1 -0
  47. package/dist/chunk-UWJE5FQA.js +18 -0
  48. package/dist/chunk-V6YQICXZ.js +1 -0
  49. package/dist/chunk-VIMF6LGM.js +1 -0
  50. package/dist/chunk-VJLMUKOI.js +1 -0
  51. package/dist/chunk-VPYBOXVT.js +1 -0
  52. package/dist/chunk-VTPVOGHH.js +1 -0
  53. package/dist/chunk-WQ2BN6X6.js +1 -0
  54. package/dist/chunk-XAUNPIMX.js +1 -0
  55. package/dist/chunk-Y2EMPB3I.js +1 -0
  56. package/dist/chunk-Z4HDAS2Q.js +1 -0
  57. package/dist/chunk-ZB5EHBIO.js +1 -0
  58. package/dist/chunk-ZV2DXV5A.js +23 -0
  59. package/dist/compat/index.cjs +14 -7656
  60. package/dist/compat/index.d.cts +15 -14
  61. package/dist/compat/index.d.ts +15 -14
  62. package/dist/compat/index.js +1 -49
  63. package/dist/compat/jotai/index.cjs +1 -2048
  64. package/dist/compat/jotai/index.d.cts +2 -2
  65. package/dist/compat/jotai/index.d.ts +2 -2
  66. package/dist/compat/jotai/index.js +1 -9
  67. package/dist/compat/nanostores/index.cjs +1 -2175
  68. package/dist/compat/nanostores/index.d.cts +2 -2
  69. package/dist/compat/nanostores/index.d.ts +2 -2
  70. package/dist/compat/nanostores/index.js +1 -23
  71. package/dist/compat/nestjs/index.cjs +14 -6782
  72. package/dist/compat/nestjs/index.d.cts +7 -6
  73. package/dist/compat/nestjs/index.d.ts +7 -6
  74. package/dist/compat/nestjs/index.js +1 -82
  75. package/dist/compat/react/index.cjs +1 -141
  76. package/dist/compat/react/index.d.cts +2 -2
  77. package/dist/compat/react/index.d.ts +2 -2
  78. package/dist/compat/react/index.js +1 -12
  79. package/dist/compat/solid/index.cjs +1 -128
  80. package/dist/compat/solid/index.d.cts +2 -2
  81. package/dist/compat/solid/index.d.ts +2 -2
  82. package/dist/compat/solid/index.js +1 -12
  83. package/dist/compat/svelte/index.cjs +1 -131
  84. package/dist/compat/svelte/index.d.cts +2 -2
  85. package/dist/compat/svelte/index.d.ts +2 -2
  86. package/dist/compat/svelte/index.js +1 -12
  87. package/dist/compat/vue/index.cjs +1 -146
  88. package/dist/compat/vue/index.d.cts +2 -2
  89. package/dist/compat/vue/index.d.ts +2 -2
  90. package/dist/compat/vue/index.js +1 -12
  91. package/dist/compat/zustand/index.cjs +6 -4931
  92. package/dist/compat/zustand/index.d.cts +5 -5
  93. package/dist/compat/zustand/index.d.ts +5 -5
  94. package/dist/compat/zustand/index.js +1 -12
  95. package/dist/composite-B-xqw4Kk.d.cts +69 -0
  96. package/dist/composite-BhbKHbOS.d.ts +69 -0
  97. package/dist/core/index.cjs +1 -2271
  98. package/dist/core/index.d.cts +4 -3
  99. package/dist/core/index.d.ts +4 -3
  100. package/dist/core/index.js +1 -110
  101. package/dist/extra/browser.cjs +1 -0
  102. package/dist/extra/browser.d.cts +3 -0
  103. package/dist/extra/browser.d.ts +3 -0
  104. package/dist/extra/browser.js +1 -0
  105. package/dist/extra/index.cjs +23 -9971
  106. package/dist/extra/index.d.cts +13 -5
  107. package/dist/extra/index.d.ts +13 -5
  108. package/dist/extra/index.js +1 -375
  109. package/dist/extra/node.cjs +3 -0
  110. package/dist/extra/node.d.cts +81 -0
  111. package/dist/extra/node.d.ts +81 -0
  112. package/dist/extra/node.js +2 -0
  113. package/dist/extra/operators.cjs +1 -0
  114. package/dist/extra/operators.d.cts +910 -0
  115. package/dist/extra/operators.d.ts +910 -0
  116. package/dist/extra/operators.js +1 -0
  117. package/dist/extra/reactive.cjs +1 -0
  118. package/dist/extra/reactive.d.cts +352 -0
  119. package/dist/extra/reactive.d.ts +352 -0
  120. package/dist/extra/reactive.js +1 -0
  121. package/dist/extra/sources.cjs +1 -2486
  122. package/dist/extra/sources.d.cts +6 -2
  123. package/dist/extra/sources.d.ts +6 -2
  124. package/dist/extra/sources.js +1 -57
  125. package/dist/extra/storage-browser.cjs +1 -0
  126. package/dist/extra/storage-browser.d.cts +71 -0
  127. package/dist/extra/storage-browser.d.ts +71 -0
  128. package/dist/extra/storage-browser.js +1 -0
  129. package/dist/extra/storage-core.cjs +1 -0
  130. package/dist/extra/storage-core.d.cts +98 -0
  131. package/dist/extra/storage-core.d.ts +98 -0
  132. package/dist/extra/storage-core.js +1 -0
  133. package/dist/extra/storage-node.cjs +2 -0
  134. package/dist/extra/storage-node.d.cts +60 -0
  135. package/dist/extra/storage-node.d.ts +60 -0
  136. package/dist/extra/storage-node.js +1 -0
  137. package/dist/fallback-BaTS7vVY.d.cts +258 -0
  138. package/dist/fallback-eOm3LNxP.d.ts +258 -0
  139. package/dist/graph/index.cjs +6 -5030
  140. package/dist/graph/index.d.cts +6 -5
  141. package/dist/graph/index.d.ts +6 -5
  142. package/dist/graph/index.js +1 -50
  143. package/dist/{graph-6tZ5jEzr.d.cts → graph-BZGRXwOm.d.ts} +134 -31
  144. package/dist/{graph-DQ69XU0g.d.ts → graph-D48Qw9Cg.d.cts} +134 -31
  145. package/dist/index-8FSVk4Uf.d.ts +135 -0
  146. package/dist/index-9oDeHH2u.d.cts +291 -0
  147. package/dist/index-B0c4cmIO.d.ts +207 -0
  148. package/dist/{index-CDAjUFIv.d.ts → index-B1AmmSlb.d.ts} +1 -1
  149. package/dist/{index-Bd_fwmLf.d.cts → index-B2pwesl9.d.cts} +1 -1
  150. package/dist/index-BHvIquRZ.d.ts +1957 -0
  151. package/dist/{index-CPgZ5wRl.d.ts → index-BVHOrDwO.d.ts} +1 -1
  152. package/dist/{index-DrISNAOm.d.ts → index-BWJV63ti.d.ts} +1 -1
  153. package/dist/{index-B_IP40nB.d.cts → index-B_agccPe.d.cts} +1 -1
  154. package/dist/index-BgyGlizc.d.ts +163 -0
  155. package/dist/index-BpA5c4G9.d.ts +357 -0
  156. package/dist/index-BpIFjILY.d.cts +357 -0
  157. package/dist/{index-qldRdbQw.d.ts → index-Bqachn9_.d.ts} +1 -1
  158. package/dist/index-Btib9rsU.d.ts +607 -0
  159. package/dist/{index-BYOHF0zP.d.ts → index-BwM9BEkt.d.ts} +1 -1
  160. package/dist/index-BxJ86YZZ.d.cts +105 -0
  161. package/dist/index-C73n7lo-.d.cts +251 -0
  162. package/dist/index-CEXXwWVH.d.cts +192 -0
  163. package/dist/index-CHEswufn.d.cts +163 -0
  164. package/dist/{index-xdGjv0nO.d.ts → index-CMn8S8Hw.d.ts} +1 -1
  165. package/dist/{index-QBpffFW-.d.cts → index-CRO83MmV.d.cts} +1 -1
  166. package/dist/{index-BjI6ty9z.d.ts → index-CloUk1kY.d.ts} +9 -9
  167. package/dist/index-CpgYhnrG.d.ts +291 -0
  168. package/dist/{index-CUyrtuOf.d.cts → index-Cyojz0AE.d.cts} +1 -1
  169. package/dist/{demo-shell-DEp-nMTl.d.ts → index-CzobVSMr.d.ts} +14 -14
  170. package/dist/index-Czq6ynh8.d.ts +143 -0
  171. package/dist/index-D-YB-Vl3.d.ts +195 -0
  172. package/dist/index-DAlweici.d.ts +231 -0
  173. package/dist/index-DEwTb_fm.d.cts +1957 -0
  174. package/dist/{index-DFhjO4Gg.d.cts → index-DL-rYJrx.d.cts} +1 -1
  175. package/dist/index-DP4ZTkdw.d.ts +139 -0
  176. package/dist/{index-BeIdBfcb.d.cts → index-DUqMOlKZ.d.cts} +200 -2366
  177. package/dist/{index-Bxb5ZYc9.d.cts → index-D_NwnRYS.d.cts} +1 -1
  178. package/dist/index-DaLJvH8Z.d.ts +105 -0
  179. package/dist/index-DcXZBF5a.d.cts +135 -0
  180. package/dist/index-DfyOkTvs.d.ts +321 -0
  181. package/dist/{index-CmnuOibw.d.ts → index-DiOXyAwt.d.ts} +1 -1
  182. package/dist/index-DpHe5e0Q.d.ts +186 -0
  183. package/dist/index-DraikLjn.d.ts +86 -0
  184. package/dist/{index-BEfE8H_G.d.cts → index-DxsnAMWD.d.cts} +9 -9
  185. package/dist/index-DyxjtScX.d.cts +207 -0
  186. package/dist/index-HDpJe9hX.d.ts +251 -0
  187. package/dist/index-O6TgGUBV.d.cts +195 -0
  188. package/dist/{index-B4MP_8V_.d.cts → index-Oi8d8w4R.d.cts} +1 -1
  189. package/dist/{index-BW1z3BN9.d.ts → index-ROpQmGjE.d.ts} +30 -6
  190. package/dist/index-RukJ4DLS.d.cts +607 -0
  191. package/dist/{index-DdD5MVDL.d.ts → index-ZftwfxJM.d.ts} +200 -2366
  192. package/dist/{index-CuYwdKO-.d.ts → index-cByzxQIC.d.cts} +10 -195
  193. package/dist/index-dtN7YA2x.d.cts +143 -0
  194. package/dist/{index-C8mdwMXc.d.cts → index-fM6y00vT.d.cts} +30 -6
  195. package/dist/{index-_oMEWlDq.d.cts → index-m-yHof5p.d.ts} +10 -195
  196. package/dist/index-pXrDMpRO.d.cts +231 -0
  197. package/dist/index-rHJSKsU8.d.cts +186 -0
  198. package/dist/index-rX8HBM5h.d.cts +321 -0
  199. package/dist/{index-CUwyr1Kk.d.cts → index-rnwQly8X.d.cts} +147 -20
  200. package/dist/index-sm373fsH.d.ts +192 -0
  201. package/dist/index-tbf2gKHd.d.cts +139 -0
  202. package/dist/{demo-shell-26p5fVxn.d.cts → index-u15meRxL.d.cts} +14 -14
  203. package/dist/{index-eJ6T_qGM.d.ts → index-umtoWT8K.d.ts} +147 -20
  204. package/dist/index-vscRDkjW.d.cts +86 -0
  205. package/dist/index.cjs +150 -24142
  206. package/dist/index.d.cts +69 -3756
  207. package/dist/index.d.ts +69 -3756
  208. package/dist/index.js +1 -7292
  209. package/dist/{meta-C0-8XW6Q.d.cts → meta-Cgj6zeji.d.cts} +5 -5
  210. package/dist/{meta-BGqSZ7mt.d.ts → meta-CwesDrMD.d.ts} +5 -5
  211. package/dist/{node-C_IBuvX2.d.cts → node-Cc1TniY8.d.cts} +36 -9
  212. package/dist/{node-C_IBuvX2.d.ts → node-Cc1TniY8.d.ts} +36 -9
  213. package/dist/{observable-DCk45RH5.d.ts → observable-Ct-gJ9jI.d.ts} +1 -1
  214. package/dist/{observable-Crr1jgzx.d.cts → observable-glXQoGj2.d.cts} +1 -1
  215. package/dist/patterns/ai/browser.cjs +25 -0
  216. package/dist/patterns/ai/browser.d.cts +127 -0
  217. package/dist/patterns/ai/browser.d.ts +127 -0
  218. package/dist/patterns/ai/browser.js +3 -0
  219. package/dist/patterns/ai/index.cjs +91 -0
  220. package/dist/patterns/ai/index.d.cts +17 -0
  221. package/dist/patterns/ai/index.d.ts +17 -0
  222. package/dist/patterns/ai/index.js +1 -0
  223. package/dist/patterns/ai/node.cjs +2 -0
  224. package/dist/patterns/ai/node.d.cts +58 -0
  225. package/dist/patterns/ai/node.d.ts +58 -0
  226. package/dist/patterns/ai/node.js +1 -0
  227. package/dist/patterns/audit/index.cjs +6 -0
  228. package/dist/patterns/audit/index.d.cts +6 -0
  229. package/dist/patterns/audit/index.d.ts +6 -0
  230. package/dist/patterns/audit/index.js +1 -0
  231. package/dist/patterns/cqrs/index.cjs +6 -0
  232. package/dist/patterns/cqrs/index.d.cts +5 -0
  233. package/dist/patterns/cqrs/index.d.ts +5 -0
  234. package/dist/patterns/cqrs/index.js +1 -0
  235. package/dist/patterns/demo-shell/index.cjs +7 -0
  236. package/dist/patterns/demo-shell/index.d.cts +6 -0
  237. package/dist/patterns/demo-shell/index.d.ts +6 -0
  238. package/dist/patterns/demo-shell/index.js +1 -0
  239. package/dist/patterns/domain-templates/index.cjs +6 -0
  240. package/dist/patterns/domain-templates/index.d.cts +5 -0
  241. package/dist/patterns/domain-templates/index.d.ts +5 -0
  242. package/dist/patterns/domain-templates/index.js +1 -0
  243. package/dist/patterns/graphspec/index.cjs +83 -0
  244. package/dist/patterns/graphspec/index.d.cts +7 -0
  245. package/dist/patterns/graphspec/index.d.ts +7 -0
  246. package/dist/patterns/graphspec/index.js +1 -0
  247. package/dist/patterns/guarded-execution/index.cjs +6 -0
  248. package/dist/patterns/guarded-execution/index.d.cts +7 -0
  249. package/dist/patterns/guarded-execution/index.d.ts +7 -0
  250. package/dist/patterns/guarded-execution/index.js +1 -0
  251. package/dist/patterns/harness/index.cjs +48 -0
  252. package/dist/patterns/harness/index.d.cts +8 -0
  253. package/dist/patterns/harness/index.d.ts +8 -0
  254. package/dist/patterns/harness/index.js +1 -0
  255. package/dist/patterns/job-queue/index.cjs +6 -0
  256. package/dist/patterns/job-queue/index.d.cts +5 -0
  257. package/dist/patterns/job-queue/index.d.ts +5 -0
  258. package/dist/patterns/job-queue/index.js +1 -0
  259. package/dist/patterns/lens/index.cjs +6 -0
  260. package/dist/patterns/lens/index.d.cts +7 -0
  261. package/dist/patterns/lens/index.d.ts +7 -0
  262. package/dist/patterns/lens/index.js +1 -0
  263. package/dist/patterns/memory/index.cjs +6 -0
  264. package/dist/patterns/memory/index.d.cts +5 -0
  265. package/dist/patterns/memory/index.d.ts +5 -0
  266. package/dist/patterns/memory/index.js +1 -0
  267. package/dist/patterns/messaging/index.cjs +6 -0
  268. package/dist/patterns/messaging/index.d.cts +5 -0
  269. package/dist/patterns/messaging/index.d.ts +5 -0
  270. package/dist/patterns/messaging/index.js +1 -0
  271. package/dist/patterns/orchestration/index.cjs +6 -0
  272. package/dist/patterns/orchestration/index.d.cts +6 -0
  273. package/dist/patterns/orchestration/index.d.ts +6 -0
  274. package/dist/patterns/orchestration/index.js +1 -0
  275. package/dist/patterns/reactive-layout/index.cjs +7 -6444
  276. package/dist/patterns/reactive-layout/index.d.cts +6 -6
  277. package/dist/patterns/reactive-layout/index.d.ts +6 -6
  278. package/dist/patterns/reactive-layout/index.js +1 -56
  279. package/dist/patterns/reduction/index.cjs +6 -0
  280. package/dist/patterns/reduction/index.d.cts +5 -0
  281. package/dist/patterns/reduction/index.d.ts +5 -0
  282. package/dist/patterns/reduction/index.js +1 -0
  283. package/dist/patterns/refine-loop/index.cjs +8 -0
  284. package/dist/patterns/refine-loop/index.d.cts +7 -0
  285. package/dist/patterns/refine-loop/index.d.ts +7 -0
  286. package/dist/patterns/refine-loop/index.js +1 -0
  287. package/dist/patterns/resilient-pipeline/index.cjs +1 -0
  288. package/dist/patterns/resilient-pipeline/index.d.cts +7 -0
  289. package/dist/patterns/resilient-pipeline/index.d.ts +7 -0
  290. package/dist/patterns/resilient-pipeline/index.js +1 -0
  291. package/dist/patterns/surface/index.cjs +14 -0
  292. package/dist/patterns/surface/index.d.cts +8 -0
  293. package/dist/patterns/surface/index.d.ts +8 -0
  294. package/dist/patterns/surface/index.js +1 -0
  295. package/dist/{reactive-layout-BaOQefHu.d.cts → reactive-layout-CpYb5qLP.d.cts} +2 -2
  296. package/dist/{reactive-layout-D9gejYXE.d.ts → reactive-layout-D8u4wuUR.d.ts} +2 -2
  297. package/dist/reactive-log-DPzuUDj5.d.cts +190 -0
  298. package/dist/reactive-log-YuH9VYN8.d.ts +190 -0
  299. package/dist/reactive-map-CdbNoSgP.d.ts +238 -0
  300. package/dist/reactive-map-DUeRmb9d.d.cts +238 -0
  301. package/dist/resilience-Ba5-b4WD.d.cts +493 -0
  302. package/dist/resilience-CGRzhnD3.d.ts +493 -0
  303. package/dist/resilience-QAHKANT5.js +1 -0
  304. package/dist/sugar-BV0htudb.d.cts +205 -0
  305. package/dist/sugar-Dtyrq2_q.d.ts +205 -0
  306. package/dist/topology-tree-CYHOwQZ_.d.ts +25 -0
  307. package/dist/topology-tree-DROUdq5B.d.cts +25 -0
  308. package/dist/types-O3GzJY2U.d.cts +401 -0
  309. package/dist/types-u64Ose53.d.ts +401 -0
  310. package/package.json +267 -7
  311. package/dist/chunk-3ZWCKRHX.js +0 -117
  312. package/dist/chunk-3ZWCKRHX.js.map +0 -1
  313. package/dist/chunk-6LDQFTYS.js +0 -102
  314. package/dist/chunk-6LDQFTYS.js.map +0 -1
  315. package/dist/chunk-7TAQJHQV.js +0 -103
  316. package/dist/chunk-7TAQJHQV.js.map +0 -1
  317. package/dist/chunk-AMCG74RZ.js +0 -7000
  318. package/dist/chunk-AMCG74RZ.js.map +0 -1
  319. package/dist/chunk-BVZYTZ5H.js +0 -599
  320. package/dist/chunk-BVZYTZ5H.js.map +0 -1
  321. package/dist/chunk-FQMKGR6L.js +0 -330
  322. package/dist/chunk-FQMKGR6L.js.map +0 -1
  323. package/dist/chunk-HXZEYDUR.js +0 -94
  324. package/dist/chunk-HXZEYDUR.js.map +0 -1
  325. package/dist/chunk-IZYUSJC7.js +0 -1369
  326. package/dist/chunk-IZYUSJC7.js.map +0 -1
  327. package/dist/chunk-J22W6HV3.js +0 -107
  328. package/dist/chunk-J22W6HV3.js.map +0 -1
  329. package/dist/chunk-JSCT3CR4.js +0 -38
  330. package/dist/chunk-JSCT3CR4.js.map +0 -1
  331. package/dist/chunk-JYXEWPH4.js +0 -62
  332. package/dist/chunk-JYXEWPH4.js.map +0 -1
  333. package/dist/chunk-LCE3GF5P.js +0 -866
  334. package/dist/chunk-LCE3GF5P.js.map +0 -1
  335. package/dist/chunk-MJ2NKQQL.js +0 -119
  336. package/dist/chunk-MJ2NKQQL.js.map +0 -1
  337. package/dist/chunk-N6UR7YVY.js +0 -198
  338. package/dist/chunk-N6UR7YVY.js.map +0 -1
  339. package/dist/chunk-OHISZPOJ.js +0 -97
  340. package/dist/chunk-OHISZPOJ.js.map +0 -1
  341. package/dist/chunk-PHOUUNK7.js +0 -2291
  342. package/dist/chunk-PHOUUNK7.js.map +0 -1
  343. package/dist/chunk-RB6QPHJ7.js +0 -393
  344. package/dist/chunk-RB6QPHJ7.js.map +0 -1
  345. package/dist/chunk-SN4YWWYO.js +0 -171
  346. package/dist/chunk-SN4YWWYO.js.map +0 -1
  347. package/dist/chunk-SX52TAR4.js +0 -110
  348. package/dist/chunk-SX52TAR4.js.map +0 -1
  349. package/dist/chunk-THTWHNU4.js +0 -2712
  350. package/dist/chunk-THTWHNU4.js.map +0 -1
  351. package/dist/chunk-VYPWMZ6H.js +0 -98
  352. package/dist/chunk-VYPWMZ6H.js.map +0 -1
  353. package/dist/chunk-XGPU467M.js +0 -136
  354. package/dist/chunk-XGPU467M.js.map +0 -1
  355. package/dist/chunk-ZQMEI34O.js +0 -713
  356. package/dist/chunk-ZQMEI34O.js.map +0 -1
  357. package/dist/compat/index.cjs.map +0 -1
  358. package/dist/compat/index.js.map +0 -1
  359. package/dist/compat/jotai/index.cjs.map +0 -1
  360. package/dist/compat/jotai/index.js.map +0 -1
  361. package/dist/compat/nanostores/index.cjs.map +0 -1
  362. package/dist/compat/nanostores/index.js.map +0 -1
  363. package/dist/compat/nestjs/index.cjs.map +0 -1
  364. package/dist/compat/nestjs/index.js.map +0 -1
  365. package/dist/compat/react/index.cjs.map +0 -1
  366. package/dist/compat/react/index.js.map +0 -1
  367. package/dist/compat/solid/index.cjs.map +0 -1
  368. package/dist/compat/solid/index.js.map +0 -1
  369. package/dist/compat/svelte/index.cjs.map +0 -1
  370. package/dist/compat/svelte/index.js.map +0 -1
  371. package/dist/compat/vue/index.cjs.map +0 -1
  372. package/dist/compat/vue/index.js.map +0 -1
  373. package/dist/compat/zustand/index.cjs.map +0 -1
  374. package/dist/compat/zustand/index.js.map +0 -1
  375. package/dist/core/index.cjs.map +0 -1
  376. package/dist/core/index.js.map +0 -1
  377. package/dist/extra/index.cjs.map +0 -1
  378. package/dist/extra/index.js.map +0 -1
  379. package/dist/extra/sources.cjs.map +0 -1
  380. package/dist/extra/sources.js.map +0 -1
  381. package/dist/graph/index.cjs.map +0 -1
  382. package/dist/graph/index.js.map +0 -1
  383. package/dist/index-C0ZXMaXO.d.cts +0 -392
  384. package/dist/index-CY2TljO4.d.ts +0 -392
  385. package/dist/index.cjs.map +0 -1
  386. package/dist/index.js.map +0 -1
  387. package/dist/patterns/demo-shell.cjs +0 -5604
  388. package/dist/patterns/demo-shell.cjs.map +0 -1
  389. package/dist/patterns/demo-shell.d.cts +0 -6
  390. package/dist/patterns/demo-shell.d.ts +0 -6
  391. package/dist/patterns/demo-shell.js +0 -15
  392. package/dist/patterns/demo-shell.js.map +0 -1
  393. package/dist/patterns/reactive-layout/index.cjs.map +0 -1
  394. package/dist/patterns/reactive-layout/index.js.map +0 -1
  395. package/dist/storage-BMycWEh2.d.ts +0 -190
  396. package/dist/storage-DiqWHzVI.d.cts +0 -190
@@ -0,0 +1,43 @@
1
+ import{C as U}from"./chunk-7H6LGFUG.js";import{a as le}from"./chunk-GHJJR5P4.js";import{e as de}from"./chunk-SC3U7ETD.js";import{a as $}from"./chunk-DBGGMN3D.js";import{b as V,d as q}from"./chunk-ETWTCCJI.js";import{f as ae,j as H}from"./chunk-CKCSDI7T.js";import{q as P,r as ie,v as ue}from"./chunk-Z4HDAS2Q.js";import{b as ce}from"./chunk-OAWLCNJJ.js";import{m as se}from"./chunk-2PMCKKRK.js";import{D as oe,E as M,G as O,H as w,o as A}from"./chunk-ZB5EHBIO.js";import{b as Te}from"./chunk-QYADASLV.js";var $e={};Te($e,{DEFAULT_DECAY_RATE:()=>K,DEFAULT_QUEUE_CONFIGS:()=>W,DEFAULT_SEVERITY_WEIGHTS:()=>Y,HarnessGraph:()=>F,QUEUE_NAMES:()=>x,affectedTaskFilter:()=>be,beforeAfterCompare:()=>xe,codeChangeBridge:()=>Ie,createIntakeBridge:()=>Ee,defaultErrorClassifier:()=>J,evalIntakeBridge:()=>ke,evalSource:()=>Re,harnessLoop:()=>_e,harnessProfile:()=>Ge,harnessTrace:()=>Me,notifyEffect:()=>Ne,priorityScore:()=>Se,strategyKey:()=>j,strategyModel:()=>z});function Ee(t,e,n,a){return w([t],([i])=>{if(i==null)return;let f=n(i);for(let o of f)e.publish(o)},{name:a?.name??"intake-bridge"})}function ke(t,e,n){let a=n?.defaultSeverity??"medium";return w([t],([i])=>{if(i==null)return;let f=Array.isArray(i)?i:[i];for(let o of f)for(let r of o.tasks)if(!(r.valid&&r.judge_scores?.every(s=>s.pass))){if(!r.valid&&(!r.judge_scores||r.judge_scores.length===0)){e.publish({source:"eval",summary:`Task ${r.task_id} invalid (model: ${o.model})`,evidence:`Run ${o.run_id}: task produced invalid output`,affectsAreas:["graphspec"],affectsEvalTasks:[r.task_id],severity:a});continue}if(r.judge_scores)for(let s of r.judge_scores)s.pass||e.publish({source:"eval",summary:`${r.task_id}: ${s.claim} (model: ${o.model})`,evidence:s.reasoning,affectsAreas:["graphspec"],affectsEvalTasks:[r.task_id],severity:a})}},{name:n?.name??"eval-intake-bridge"})}function Re(t,e){return ue(t,()=>se(e()))}function xe(t,e){return O([t,e],([n,a])=>{let i=n,f=a,o=new Map(i.tasks.map(c=>[c.task_id,c])),r=new Map(f.tasks.map(c=>[c.task_id,c])),s=new Set([...o.keys(),...r.keys()]),u=[],p=[],d=[];for(let c of s){let g=o.get(c),b=r.get(c),k=g?.valid??!1,T=b?.valid??!1,E=g?.judge_scores?g.judge_scores.filter(C=>C.pass).length:void 0,R=b?.judge_scores?b.judge_scores.filter(C=>C.pass).length:void 0,I=E!==void 0&&R!==void 0?R-E:void 0;u.push({taskId:c,before:k,after:T,scoreDiff:I}),k&&!T&&p.push(c),!k&&T&&d.push(c)}return{newFailures:p,resolved:d,taskDeltas:u,overallImproved:d.length>p.length}},{name:"eval-delta"})}function be(t,e){let n=e==null?null:Array.isArray(e)?M(e):e,a=[t];return n&&a.push(n),O(a,i=>{let f=i[0],o=n?new Set(i[1]):null,r=new Set;for(let s of f)for(let u of s.affectsEvalTasks??[])(o==null||o.has(u))&&r.add(u);return[...r].sort()},{name:"affected-task-filter"})}function Ie(t,e,n,a){let i=a?.defaultSeverity??"high";function f(r){let s=[];for(let u of r.lintErrors??[])s.push({source:"code-change",summary:`Lint: ${u.rule} in ${u.file}:${u.line}`,evidence:u.message,affectsAreas:[u.file],severity:i});for(let u of r.testFailures??[])s.push({source:"test",summary:`Test failure: ${u.testId}`,evidence:u.message,affectsAreas:[u.file],affectsEvalTasks:[u.testId],severity:i});return s}let o=n??f;return w([t],([r])=>{if(r!=null)for(let s of o(r))e.publish(s)},{name:a?.name??"code-change-bridge"})}function Ne(t,e,n){return w([t.latest],([a])=>{a!=null&&e(a)},{name:n?.name??"notify-effect"})}var x=["auto-fix","needs-decision","investigation","backlog"];function j(t,e){return`${t}\u2192${e}`}function J(t){let e=t.detail.toLowerCase();return e.includes("parse")||e.includes("json")||e.includes("config")||e.includes("validation")||e.includes("syntax")?"self-correctable":"structural"}var Y={critical:100,high:70,medium:40,low:10},K=Math.LN2/(168*3600),W={"auto-fix":{gated:!1},"needs-decision":{gated:!0},investigation:{gated:!0},backlog:{gated:!1,startOpen:!1}};function z(){let t=ce({name:"strategy-entries"}),e=O([t.entries],([o])=>{let r=o;return new Map(r)},{name:"strategy-model",equals:(o,r)=>{let s=o,u=r;if(s.size!==u.size)return!1;for(let[p,d]of s){let c=u.get(p);if(!c||d.attempts!==c.attempts||d.successes!==c.successes)return!1}return!0}});function n(o,r,s){let u=j(o,r),p=t.get(u),d=(p?.attempts??0)+1,c=(p?.successes??0)+(s?1:0);t.set(u,{rootCause:o,intervention:r,attempts:d,successes:c,successRate:c/d})}function a(o,r){return t.get(j(o,r))}let i=e.subscribe(()=>{});function f(){i()}return{node:e,record:n,lookup:a,dispose:f}}function Se(t,e,n,a,i){let f={...Y,...i?.severityWeights},o=i?.decayRate??K,r=i?.effectivenessThreshold??.7,s=i?.effectivenessBoost??15,u=[t,e,n];return a&&u.push(a),O(u,p=>{let d=p[0],c=p[1],g=p[2],b=a?p[3]:0,k=f[d.severity??"medium"],T=(A()-g)/1e9,E=le(k,T,o,0),R=j(d.rootCause,d.intervention),I=c.get(R);return I&&I.successRate>=r&&(E+=s),E+=b*20,E},{name:"priority-score"})}var we=`You are a triage classifier for a reactive collaboration harness.
2
+
3
+ Given an intake item, classify it and output JSON:
4
+ {
5
+ "rootCause": "composition" | "missing-fn" | "bad-docs" | "schema-gap" | "regression" | "unknown",
6
+ "intervention": "template" | "catalog-fn" | "docs" | "wrapper" | "schema-change" | "investigate",
7
+ "route": "auto-fix" | "needs-decision" | "investigation" | "backlog",
8
+ "priority": <number 0-100>,
9
+ "triageReasoning": "<one sentence>"
10
+ }
11
+
12
+ Strategy model (past effectiveness):
13
+ {{strategy}}
14
+
15
+ Intake item:
16
+ {{item}}`,Ce=`You are an implementation agent.
17
+
18
+ Given a triaged issue with root cause and intervention type, produce a fix.
19
+
20
+ Issue:
21
+ {{item}}
22
+
23
+ Output JSON:
24
+ {
25
+ "outcome": "success" | "failure" | "partial",
26
+ "detail": "<description of what was done or what failed>"
27
+ }`,Oe=`You are a QA reviewer.
28
+
29
+ Given an execution result, verify whether the fix is correct.
30
+
31
+ Execution:
32
+ {{execution}}
33
+
34
+ Original issue:
35
+ {{item}}
36
+
37
+ Output JSON:
38
+ {
39
+ "verified": true/false,
40
+ "findings": ["<finding1>", ...],
41
+ "errorClass": "self-correctable" | "structural" // only if verified=false
42
+ }`,F=class extends H{intake;queues;gates;strategy;verifyResults;totalRetries;totalReingestions;constructor(e,n,a,i,f,o,r,s){super(e),this.intake=n,this.queues=a,this.gates=i,this.strategy=f,this.verifyResults=o,this.totalRetries=r,this.totalReingestions=s}};function _e(t,e){let n=e.adapter,a=e.maxRetries??2,i=e.retainedLimit??1e3,f=e.errorClassifier??J,o=new Map;for(let l of x)o.set(l,{...W[l],...e.queues?.[l]});let r=new $("intake",{retainedLimit:i}),s=z(),u=P(r.latest,s.node),p=U(n,[u],e.triagePrompt??(l=>{let[m,h]=l;return m?we.replace("{{strategy}}",JSON.stringify(Array.from(h.entries()))).replace("{{item}}",JSON.stringify(m)):""}),{name:"triage",format:"json",retries:1}),d=new Map;for(let l of x)d.set(l,new $(`queue/${l}`,{retainedLimit:i}));let c=P(p,u),b=w([c],([l])=>{if(l==null)return;let[m,h]=l;if(!m||!m.route)return;let N={...h?.[0],...m},L=d.get(N.route);L&&L.publish(N)}).subscribe(()=>{}),k=new H("gates"),T=new Map;for(let l of x){let m=o.get(l),h=d.get(l);if(m.gated){k.add(h.latest,{name:`${l}/source`});let _=de(k,`${l}/gate`,`${l}/source`,{maxPending:m.maxPending,startOpen:m.startOpen});T.set(l,_)}}let E=new $("retry-input",{retainedLimit:i}),R=[];for(let l of x)o.get(l).gated&&T.has(l)?R.push(T.get(l).node):R.push(d.get(l).latest);R.push(E.latest);let I=ie(...R),C=U(n,[I],e.executePrompt??(l=>Ce.replace("{{item}}",JSON.stringify(l))),{name:"execute",format:"json",retries:1}),X=P(C,I),D=new $("verify-results",{retainedLimit:i}),Z=U(n,[X],e.verifyPrompt??(l=>{let[m,h]=l;return Oe.replace("{{execution}}",JSON.stringify(m)).replace("{{item}}",JSON.stringify(h))}),{name:"verify",format:"json",retries:1}),pe=P(Z,X),ee=e.maxReingestions??1,ge=Math.min(e.maxTotalRetries??a*10,100),me=Math.min(e.maxTotalReingestions??ee*10,100),te=M(0),re=M(0),ye=oe([pe],(l,m)=>{let h=l[0];if(h==null||h.length===0)return;let _=h[h.length-1];if(_==null)return;let[N,L]=_,[ne,y]=L??[null,null];if(!N||!y)return;let ve={item:y,outcome:ne?.outcome??"failure",detail:ne?.detail??"unknown"},S={item:y,execution:ve,verified:N.verified,findings:N.findings??[],errorClass:N.errorClass};if(S.verified){s.record(y.rootCause,y.intervention,!0),D.publish(S);return}let he=S.errorClass??f({item:y,outcome:"failure",detail:S.findings.join("; ")}),B=y._retries??0;if(he==="self-correctable"&&B<a&&V(te,ge)){let G=q(y),Q={...y,_retries:B+1,summary:`[RETRY ${B+1}/${a}] ${G} \u2014 Previous attempt failed: ${S.findings.join("; ")}`,relatedTo:[G]};E.publish(Q)}else{s.record(y.rootCause,y.intervention,!1),D.publish(S);let G=q(y),Q=y._reingestions??0;Q<ee&&V(re,me)&&r.publish({source:"eval",summary:`Verification failed for: ${G}`,evidence:S.findings.join(`
43
+ `),affectsAreas:y.affectsAreas,affectsEvalTasks:y.affectsEvalTasks,severity:"high",relatedTo:[G],_reingestions:Q+1})}}).subscribe(()=>{}),v=new F(t,r,d,T,s,D,te,re);v.addDisposer(b),v.addDisposer(ye),v.addDisposer(s.dispose),v.add(p,{name:"triage"}),v.add(C,{name:"execute"}),v.add(Z,{name:"verify"}),v.add(s.node,{name:"strategy"}),v.mount("intake",r);for(let[l,m]of d)v.mount(`queue/${l}`,m);return v.mount("gates",k),v.mount("retry-input",E),v.mount("verify-results",D),v}function Ge(t,e){let n=ae(t,e),a={};for(let[i,f]of t.queues)a[i]=f.retained().length;return{...n,queueDepths:a,strategyEntries:t.strategy.node.cache?.size??0,totalRetries:t.totalRetries.cache??0,totalReingestions:t.totalReingestions.cache??0}}function Ae(t){let e={"intake::latest":"INTAKE",triage:"TRIAGE",execute:"EXECUTE","verify-results::latest":"VERIFY",strategy:"STRATEGY"};for(let n of x)e[`queue/${n}::latest`]="QUEUE";for(let[n]of t.gates)e[`gates::${n}/gate`]="GATE";return e}function Me(t,e){let n=e?.logger===null?null:e?.logger??console.log,a=e?.detail??"summary",i=A(),f=[],o=[],r=Ae(t);function s(){return(A()-i)/1e9}function u(p,d,c){let g={elapsed:s(),stage:p,type:d};a!=="summary"&&(g.summary=Pe(c)),a==="full"&&(g.data=c),o.push(g)}for(let[p,d]of Object.entries(r))try{let c=t.observe(p,{format:"stage-log",stageLabels:r,logger:n?g=>n(g):()=>{},includeTypes:["data","error","complete"]});c.onEvent(g=>{g.type==="data"?u(d,"data",g.data):g.type==="error"?u(d,"error",g.data):g.type==="complete"&&u(d,"complete",void 0)}),f.push(c)}catch(c){let g=c instanceof Error?c.message:String(c);u(d,"error",`observe-unavailable: ${p} \u2014 ${g}`),n&&n(`[${s().toFixed(3)}s] ${d.padEnd(9)} \u2717 observe-unavailable: ${g}`)}return{get events(){return o},dispose(){for(let p of f)p.dispose();f.length=0}}}function Pe(t){if(t==null)return"null";if(typeof t=="string")return fe(t,80);if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);try{let e=JSON.stringify(t);return fe(e,120)}catch{return String(t)}}function fe(t,e){return t.length>e?`${t.slice(0,e-1)}\u2026`:t}export{Ee as a,ke as b,Re as c,xe as d,be as e,Ie as f,Ne as g,x as h,j as i,J as j,Y as k,K as l,W as m,z as n,Se as o,F as p,_e as q,Ge as r,Me as s,$e as t};
@@ -0,0 +1 @@
1
+ import{c as f}from"./chunk-ERLIRFPA.js";import{a as l,d as o,e as d,h as s,i as m,k as b,l as c}from"./chunk-4GKB4OUJ.js";import{a as r,b as u}from"./chunk-4VVTGLXJ.js";import{b as y}from"./chunk-QYADASLV.js";var R={};y(R,{NS_PER_MS:()=>r,NS_PER_SEC:()=>u,resilientPipeline:()=>O});function O(p,e={}){let t=p;e.rateLimit!=null&&(t=s(t,e.rateLimit)),e.budget!=null&&e.budget.length>0&&(t=f(t,e.budget));let n;if(e.breaker!=null){let k=o(e.breaker),S=e.breakerOnOpen??"skip",a=d(k,{onOpen:S})(t);t=a.node,n=a.breakerState}if(e.timeoutMs!=null){if(e.timeoutMs<=0)throw new RangeError("timeoutMs must be > 0");if(e.timeoutMs>9e6)throw new RangeError("timeoutMs must be <= 9_000_000 (\u22482.5h) to stay within safe ns arithmetic");t=c(t,e.timeoutMs*1e6)}e.retry!=null&&(t=l(t,e.retry)),e.fallback!==void 0&&(t=b(t,e.fallback));let i=m(t,{initialStatus:e.initialStatus??"pending"});return{node:i.node,status:i.status,error:i.error,breakerState:n}}export{O as a,R as b};
@@ -0,0 +1 @@
1
+ import{c as I}from"./chunk-ETWTCCJI.js";import{g as _,j as P}from"./chunk-CKCSDI7T.js";import{D as y,E as K,G as E,m as F}from"./chunk-ZB5EHBIO.js";import{b as j,d as x,i as A,j as D}from"./chunk-CK2E7BTU.js";import{b as B}from"./chunk-QYADASLV.js";var ee={};B(ee,{approval:()=>V,branch:()=>U,gate:()=>z,join:()=>J,loop:()=>Q,onFailure:()=>Z,pipeline:()=>L,sensor:()=>Y,subPipeline:()=>X,task:()=>H});function O(e,n){if(typeof n=="string")return{node:e.resolve(n),path:n};let o=$(e,n);if(!o)throw new Error("orchestration dep node must already be registered in the graph so explicit edges can be recorded; pass a string path or register the node first");return{node:n,path:o}}function $(e,n){let o=e.describe(),r=`::${_}::`;for(let t of Object.keys(o.nodes).sort())if(!t.includes(r))try{if(e.resolve(t)===n)return t}catch{}}function w(e,n,o,r){e.add(o,{name:n})}function N(e,n){return I("orchestration",e,n)}function W(e){let n=r=>{let t=r.trim();return t.length===0?0:Number(t)},o;return typeof e=="string"?o=n(e):e===null?o=0:o=Number(e),Number.isFinite(o)?Math.max(0,Math.trunc(o)):1}function L(e,n){return new P(e,n)}function H(e,n,o,r){let a=(r?.deps??[]).map(i=>O(e,i)),{deps:s,...p}=r??{},T=(i,f,c)=>{let l=i.map((h,g)=>h!=null&&h.length>0?h.at(-1):c.prevData[g]);f.emit(o(l,c))},d=y(a.map(i=>i.node),T,{...p,name:n,describeKind:"derived",meta:N("task",r?.meta)});return w(e,n,d,a.flatMap(i=>i.path?[i.path]:[])),d}function U(e,n,o,r,t){let a=O(e,o),s=E([a.node],([p])=>({branch:r(p)?"then":"else",value:p}),{...t,name:n,meta:N("branch",t?.meta)});return w(e,n,s,a.path?[a.path]:[]),s}function V(e,n,o,r,t){let a=O(e,o),s=O(e,r),p=t?.isApproved??(d=>!!d),T=y([a.node,s.node],(d,i,f)=>{let c=d[0],l=d[1],h=l!=null&&l.length>0?l.at(-1):f.prevData[1];if(h===void 0||!p(h)){i.down([[x]]);return}if(c==null||c.length===0){l!=null&&l.length>0&&f.prevData[0]!==void 0?i.emit(f.prevData[0]):i.down([[x]]);return}for(let g of c)i.emit(g)},{...t,name:n,describeKind:"derived",meta:N("approval",t?.meta)});return w(e,n,T,[a.path,s.path].filter(d=>typeof d=="string")),T}function z(e,n,o,r){let t=r?.maxPending??1/0;if(t<1&&t!==1/0)throw new RangeError("gate: maxPending must be >= 1");let a=r?.startOpen??!1,s=O(e,o),p=K([],{name:"pending",equals:()=>!1}),T=K(a,{name:"isOpen"}),d=E([p],([u])=>u.length,{name:"count"}),i=[],f=!1,c=a,l=T.subscribe(u=>{for(let m of u)m[0]===j&&(c=m[1])});function h(){p.emit([...i])}function g(u){i.push(u),i.length>t&&i.shift(),h()}function R(u){let m=i.splice(0,u);return h(),m}function k(u){if(f)throw new Error(`gate: ${u}() called after gate was torn down`)}let b=y([s.node],(u,m,S)=>{let G=S.terminalDeps[0];if(G!==void 0){f=!0,i=[],h(),m.down(G===!0?[[A]]:[[D,G]]);return}let v=u[0];if(v==null||v.length===0){m.down([[x]]);return}for(let C of v)c?m.emit(C):(g(C),m.down([[x]]))},{name:n,describeKind:"derived",meta:N("gate",r?.meta)}),q={node:b,pending:p,count:d,isOpen:T,approve(u=1){k("approve");let m=R(u);for(let S of m){if(f)break;b.emit(S)}},reject(u=1){k("reject"),R(u)},modify(u,m=1){k("modify");let S=[...i],G=R(m);for(let v=0;v<G.length&&!f;v++)b.emit(u(G[v],v,S))},open(){k("open"),F(()=>{T.emit(!0);let u=R(i.length);for(let m of u){if(f)break;b.emit(m)}})},close(){k("close"),T.emit(!1)}};e.addDisposer(d.subscribe(()=>{})),e.addDisposer(l),w(e,n,b,s.path?[s.path]:[]);let M=new P(`${n}_state`);return M.add(p,{name:"pending"}),M.add(T,{name:"isOpen"}),M.add(d,{name:"count"}),e.mount(`${n}_state`,M),q}function J(e,n,o,r){let t=o.map(s=>O(e,s)),a=E(t.map(s=>s.node),s=>s,{...r,name:n,meta:N("join",r?.meta)});return w(e,n,a,t.flatMap(s=>s.path?[s.path]:[])),a}function Q(e,n,o,r,t){let a=O(e,o),s=t?.iterations,p=typeof s=="number"||s===void 0?void 0:O(e,s),T=typeof s=="number"?s:void 0,d=y(p?[a.node,p.node]:[a.node],(i,f,c)=>{let l=i[0],h=l!=null&&l.length>0?l.at(-1):c.prevData[0],g=p?i[1]:void 0,R=T??(p?g!=null&&g.length>0?g.at(-1):c.prevData[1]:1),k=W(R);for(let b=0;b<k;b+=1)h=r(h,b,f);f.emit(h)},{...t,name:n,describeKind:"derived",meta:N("loop",t?.meta)});return w(e,n,d,[a.path,p?.path].filter(i=>typeof i=="string")),d}function X(e,n,o,r){let t=o instanceof P?o:L(n,r);return typeof o=="function"&&o(t),e.mount(n,t),t}function Y(e,n,o,r){let t=y([],()=>{},{...r,name:n,initial:o,describeKind:"producer",meta:N("sensor",r?.meta)});return w(e,n,t,[]),{node:t,push(a){t.emit(a)},error(a){t.down([[D,a]])},complete(){t.down([[A]])}}}function Z(e,n,o,r,t){let a=O(e,o),s=!1,p=y([],(T,d)=>{let i=a.node.subscribe(f=>{for(let c of f){if(s)return;if(c[0]===D)try{d.emit(r(c[1],d))}catch(l){s=!0,d.down([[D,l]])}else d.down([c]),c[0]===A&&(s=!0)}});return()=>i()},{...t,name:n,describeKind:"derived",completeWhenDepsComplete:!1,errorWhenDepsError:!1,meta:N("onFailure",t?.meta)});return w(e,n,p,a.path?[a.path]:[]),p}export{L as a,H as b,U as c,V as d,z as e,J as f,Q as g,X as h,Y as i,Z as j,ee as k};
@@ -0,0 +1 @@
1
+ import{a as H,b as T}from"./chunk-QWAPKG3O.js";import{j as q}from"./chunk-CKCSDI7T.js";import{a as O,b as j}from"./chunk-VPYBOXVT.js";import{E as d,G as o,H as x,m as A}from"./chunk-ZB5EHBIO.js";import{b as ae}from"./chunk-QYADASLV.js";var ie={};ae(ie,{demoShell:()=>re});function w(h){return Math.max(0,Math.min(1,h))}function re(h){let B=w(h?.mainRatio??.65),E=w(h?.sideSplit??.5),J=Math.max(0,h?.viewportWidth??1280),k=h?.nodeRegistry??new Map,p=h?.adapter??null,S=h?.layoutFont??"14px monospace",u=h?.onHighlight,t=new q("demo-shell"),F=d(B,{name:"pane/main-ratio"}),D=d(E,{name:"pane/side-split"}),g=d(null,{name:"pane/fullscreen"}),G=d(J,{name:"viewport/width"});t.add(F,{name:"pane/main-ratio"}),t.add(D,{name:"pane/side-split"}),t.add(g,{name:"pane/fullscreen"}),t.add(G,{name:"viewport/width"});let L=o([F,G,g],([e,a,n])=>{let l=e,r=a,i=n;return i==="main"?r:i==="graph"||i==="code"?0:Math.round(r*l)},{name:"pane/main-width"}),R=o([L,G,g],([e,a,n])=>{let l=n,r=a;return l==="main"?0:l==="graph"||l==="code"?r:r-e},{name:"pane/side-width"}),C=o([D,g],([e,a])=>{let n=a;return n==="graph"?1:n==="code"||n==="main"?0:w(e)},{name:"pane/graph-height-ratio"}),K=o([C,g],([e,a])=>{let n=a;return n==="code"?1:n==="graph"||n==="main"?0:1-e},{name:"pane/code-height-ratio"});t.add(L,{name:"pane/main-width"}),t.add(R,{name:"pane/side-width"}),t.add(C,{name:"pane/graph-height-ratio"}),t.add(K,{name:"pane/code-height-ratio"});let b=d(null,{name:"demo/graph-ref"}),m=d(0,{name:"demo/graph-tick"});t.add(b,{name:"demo/graph-ref"}),t.add(m,{name:"demo/graph-tick"});let Q=o([b,m],([e,a])=>{let n=e;return n?n.describe({format:"mermaid"}):""},{name:"graph/mermaid"}),z=o([b,m],([e,a])=>{let n=e;if(!n)return null;let{expand:l,...r}=n.describe({detail:"standard"});return r},{name:"graph/describe"});t.add(Q,{name:"graph/mermaid"}),t.add(z,{name:"graph/describe"});let M=d(null,{name:"hover/target"});t.add(M,{name:"hover/target"});let P=o([M],([e])=>{let a=e;if(!a)return null;let n=k.get(a.id);return n?n.codeLine:null},{name:"highlight/code-scroll"}),W=o([M],([e])=>{let a=e;if(!a)return null;let n=k.get(a.id);return n?n.visualSelector:null},{name:"highlight/visual"}),N=o([M],([e])=>{let a=e;return a?a.id:null},{name:"highlight/graph"});if(t.add(P,{name:"highlight/code-scroll"}),t.add(W,{name:"highlight/visual"}),t.add(N,{name:"highlight/graph"}),u?.codeScroll){let e=u.codeScroll,a=x([P],([n])=>{e(n)});t.add(a,{name:"highlight/apply-code-scroll"})}if(u?.visual){let e=u.visual,a=x([W],([n])=>{e(n)});t.add(a,{name:"highlight/apply-visual"})}if(u?.graph){let e=u.graph,a=x([N],([n])=>{e(n)});t.add(a,{name:"highlight/apply-graph"})}let _=d(null,{name:"inspect/selected-node"});t.add(_,{name:"inspect/selected-node"});let U=O("standard"),X=o([_,b,m],([e,a,n])=>{let l=a,r=e;if(!l||!r)return null;try{let i=l.resolve(r),s=j(i,U);return{path:r,...s,value:i.cache}}catch{return null}},{name:"inspect/node-detail"}),Y=o([b,m],([e,a])=>{let n=e;return n?n.trace():[]},{name:"inspect/trace-log"});t.add(X,{name:"inspect/node-detail"}),t.add(Y,{name:"inspect/trace-log"});let I=d(!1,{name:"meta/debug"});t.add(I,{name:"meta/debug"});let Z=o([I,m],([e,a])=>e?t.describe({format:"mermaid"}):"",{name:"meta/shell-mermaid"});t.add(Z,{name:"meta/shell-mermaid"});let V=d("",{name:"layout/code-text"});if(t.add(V,{name:"layout/code-text"}),p){let e=new Map,a=o([z],([r])=>{let i=r;if(!i)return new Map;let s=new Map;for(let[c]of Object.entries(i.nodes)){let f=H(c,S,p,e),v=T(f,1/0,p,S,e),y=v.lines.reduce((te,ne)=>Math.max(te,ne.width),0),ee=v.lineCount*20;s.set(c,{width:y,height:ee})}return s},{name:"layout/graph-labels",equals:(r,i)=>{if(r===i)return!0;let s=r,c=i;if(s.size!==c.size)return!1;for(let[f,v]of s){let y=c.get(f);if(!y||y.width!==v.width||y.height!==v.height)return!1}return!0}}),n=o([V,R],([r,i])=>{let s=r;if(!s)return{lineCount:0,lines:[]};let c=H(s,S,p,e),f=i-40;return T(c,Math.max(100,f),p,S,e)},{name:"layout/code-lines"}),l=o([a],([r])=>{let i=r;if(i.size===0)return 200;let s=0;for(let{width:c}of i.values())c>s&&(s=c);return Math.max(200,Math.round(s+80))},{name:"layout/side-width-hint"});t.add(a,{name:"layout/graph-labels"}),t.add(n,{name:"layout/code-lines"}),t.add(l,{name:"layout/side-width-hint"})}let $=0;return{graph:t,setMainRatio(e){t.set("pane/main-ratio",w(e))},setSideSplit(e){t.set("pane/side-split",w(e))},setFullscreen(e){t.set("pane/fullscreen",e)},setViewportWidth(e){t.set("viewport/width",Math.max(0,e))},setHoverTarget(e){t.set("hover/target",e)},setDemoGraph(e){t.set("demo/graph-ref",e)},bumpGraphTick(){t.set("demo/graph-tick",++$)},selectNode(e){t.set("inspect/selected-node",e)},setMetaDebug(e){t.set("meta/debug",e)},setCodeText(e){t.set("layout/code-text",e)},batch(e){A(e)},destroy(){t.destroy()}}}export{re as a,ie as b};
@@ -0,0 +1 @@
1
+ import{E as l,J as f}from"./chunk-ZB5EHBIO.js";import{b as m,j as d}from"./chunk-CK2E7BTU.js";import{b as p}from"./chunk-QYADASLV.js";var F={};p(F,{atom:()=>A});function A(s,n,e){if(typeof s=="function"){let t=s;return typeof n=="function"?b(t,n,e):b(t,void 0,n)}return v(s,n)}function c(s){let n=s.cache,e;if(s.subscribe(i=>{for(let[r,o]of i)r===m&&(n=o),r===d&&(e=o)})(),e)throw e;return n}function v(s,n){let e=l(s,{...n,resubscribable:!0,resetOnTeardown:!0});return{get:()=>e.status==="sentinel"?c(e):e.cache,set:t=>e.emit(t),update:t=>{let i=e.status==="sentinel"?c(e):e.cache;e.emit(t(i))},subscribe:t=>{let i=!0;return e.subscribe(r=>{for(let[o,a]of r)if(o===m){if(i){i=!1;continue}t(a)}})},meta:e.meta,_node:e}}function b(s,n,e){let t=f(r=>s(o=>{let a=o._node;return a.status==="sentinel"&&c(a),r(a)}),{...e,resubscribable:!0,resetOnTeardown:!0}),i={get:()=>t.status==="sentinel"?c(t):t.cache,subscribe:r=>{let o=!0;return t.subscribe(a=>{for(let[u,T]of a)if(u===m){if(o){o=!1;continue}r(T)}})},meta:t.meta,_node:t};if(n){let r=u=>u.get(),o=(u,T)=>u.set(T),a=i;return a.set=u=>n(r,o,u),a.update=u=>{let T=t.status==="sentinel"?c(t):t.cache;return n(r,o,u(T))},a}return i}export{A as a,F as b};
@@ -0,0 +1 @@
1
+ import{r as A,v}from"./chunk-Z4HDAS2Q.js";import{b as I}from"./chunk-OAWLCNJJ.js";import{m as p,r as y}from"./chunk-2PMCKKRK.js";import{E as R,G as w,m as h}from"./chunk-ZB5EHBIO.js";import{b}from"./chunk-CK2E7BTU.js";function z(t){return typeof t=="object"&&t!==null&&"cache"in t&&typeof t.subscribe=="function"}function F(t,a,e){let r=p(t),i=r.v!=null,g=R(e?.initialVerified??null,{...i?{meta:{sourceVersion:null}}:{}}),x=e?.trigger!==void 0&&e.trigger!==null,s=null;if(x&&e?.autoVerify?s=A(p(e.trigger),r):x?s=p(e.trigger):e?.autoVerify&&(s=r),s!==null){let d;if(s===r)d=v(r,c=>a(c));else{let c=r.cache;r.subscribe(f=>{for(let M of f)M[0]===b&&(c=M[1])}),d=v(s,()=>a(c))}y(d,c=>{h(()=>{if(g.down([[b,c]]),i){let f=r.v;f!=null&&g.meta.sourceVersion.down([[b,{id:f.id,version:f.version}]])}})})}return{node:r,verified:g,trigger:s}}function E(t){t.subscribe(()=>{})}function k(t){return t instanceof Map?t:new Map}function B(t,a){if(!Array.isArray(a.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");h(()=>{for(let{key:e,value:r}of a.upsert)t.set(e,r);for(let e of a.remove??[])t.delete(e)})}function G(t,a,e){let r=p(t),i=I(e.mapOptions??{}),g=e.budget??2e3,s=e.context!==void 0&&e.context!==null?p(e.context):R(null),d=k(i.entries.cache);i.entries.subscribe(o=>{for(let u of o)u[0]===b&&(d=k(u[1]))});let c=v(r,o=>a(o,d));if(y(c,o=>{B(i,o)}),e.evict){let o=new Map,u=w([i.entries],([l])=>{let m=[],N=k(l);for(let n of o.keys())N.has(n)||(o.get(n)(),o.delete(n));for(let[n,T]of N){let V=e.evict(n,T);if(z(V)){if(!o.has(n)){let S=y(V,D=>{D===!0&&i.has(n)&&i.delete(n)});o.set(n,S)}continue}if(typeof V=="boolean"){V&&m.push(n);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return m});y(u,l=>{for(let m of l)i.delete(m)})}let f=e.consolidateTrigger!==void 0&&e.consolidateTrigger!==null;if(e.consolidate&&f){let o=p(e.consolidateTrigger),u=v(o,()=>e.consolidate(d));y(u,l=>{B(i,l)})}let M=w([i.entries,s],([o,u])=>{let l=[...k(o).entries()].map(([n,T])=>({key:n,value:T,score:e.score(T,u),cost:e.cost(T)}));l.sort((n,T)=>T.score-n.score);let m=[],N=g;for(let n of l)n.cost<=N&&(m.push({key:n.key,value:n.value,score:n.score}),N-=n.cost);return m}),O=w([i.entries],([o])=>k(o).size);return E(M),E(O),{store:i,compact:M,size:O}}export{F as a,G as b};
@@ -0,0 +1 @@
1
+ import{E as p,I as A,m as l}from"./chunk-ZB5EHBIO.js";import{b as c,j as N}from"./chunk-CK2E7BTU.js";import{b as x}from"./chunk-QYADASLV.js";var B={};x(B,{action:()=>M,atom:()=>S,computed:()=>k,getValue:()=>_,map:()=>R,onMount:()=>w,onStart:()=>v,onStop:()=>g});var T=new WeakMap,f=new WeakMap;function d(e,t){let o=t.get(e);if(o)for(let n of o)n()}function m(e,t={}){let o=0;return{...t,get:()=>b(e),subscribe:a=>{o===0&&d(e,T),o++;let r=e.subscribe(s=>{for(let[i,u]of s)i===c&&a(u)});return()=>{r(),o--,o===0&&d(e,f)}},listen:a=>{o===0&&d(e,T),o++;let r=!0,s=e.subscribe(i=>{for(let[u,C]of i)if(u===c){if(r){r=!1;continue}a(C)}});return()=>{s(),o--,o===0&&d(e,f)}},_node:e}}function y(e){let t=e.cache,o;if(e.subscribe(a=>{for(let[r,s]of a)r===c&&(t=s),r===N&&(o=s)})(),o)throw o;return t}function b(e){return e.status==="sentinel"?y(e):e.cache}function S(e){let t=p(e,{resubscribable:!0,resetOnTeardown:!0});return m(t,{set:o=>t.emit(o)})}function k(e,t){let o=Array.isArray(e)?e:[e],n=o.map(r=>r._node),a=A(n,r=>{let s=o.map(i=>{let u=i._node;return u.status==="sentinel"&&y(u),r(u)});return t(...s)},{resubscribable:!0,resetOnTeardown:!0,equals:Object.is});return m(a)}function R(e){let t=p(e,{resubscribable:!0,resetOnTeardown:!0,equals:()=>!1});return m(t,{set:o=>t.emit(o),setKey:(o,n)=>{let a=b(t);t.emit({...a,[o]:n})}})}function _(e){return e.get()}function v(e,t){let o=e._node,n=T.get(o);n||(n=new Set,T.set(o,n)),n.add(t)}function g(e,t){let o=e._node,n=f.get(o);n||(n=new Set,f.set(o,n)),n.add(t)}function w(e,t){v(e,()=>{let o=t();typeof o=="function"&&g(e,o)})}function M(e,t,o){return(...n)=>{let a;return l(()=>{a=o(...n)}),a}}export{S as a,k as b,R as c,_ as d,v as e,g as f,w as g,M as h,B as i};
@@ -0,0 +1,18 @@
1
+ import{a as an}from"./chunk-LQ3Y5NJS.js";import{a as Qt,b as Jt}from"./chunk-UPHHLMHE.js";import{a as $e,b as we,c as _e,d as Qe,e as Je,f as Ye,g as Ge,h as Xe,i as Se,j as Ze,k as er,l as rr}from"./chunk-4GKB4OUJ.js";import{a as en,b as rn}from"./chunk-K2GNMCQT.js";import{a as wr,b as tt}from"./chunk-5QDBSZBV.js";import{a as tr}from"./chunk-CKCSDI7T.js";import{a as Ve}from"./chunk-ESMPEKEV.js";import{a as tn,b as nn,c as on,d as sn}from"./chunk-I6VIH3VA.js";import{A as Nt,B as Ot,C as Rt,D as Mt,E as Pt,G as Ct,H as Lt,I as At,J as Bt,K as It,L as Ft,M as Wt,N as zt,O as Ht,P as Ut,Q as Kt,R as jt,S as Dt,T as qt,U as Vt,a as xe,b as Ie,c as st,d as it,e as at,f as ct,g as ut,h as dt,i as Fe,j as lt,k as ft,l as pt,m as mt,n as gt,o as Tt,p as yt,q as kt,r as We,s as bt,t as ht,u as vt,v as ge,w as wt,x as St,y as xt,z as Et}from"./chunk-Z4HDAS2Q.js";import{a as ne,b as ve,c as Er,d as Nr,e as Or,f as Rr,g as Mr,h as Pr,i as Be}from"./chunk-4VVTGLXJ.js";import{a as Yt,b as Gt}from"./chunk-PIOGHC63.js";import{a as Xt,b as Zt}from"./chunk-VTPVOGHH.js";import{a as $t,b as _t}from"./chunk-OAWLCNJJ.js";import{a as nt,b as ot}from"./chunk-D7A7DBE4.js";import{A as et,B as rt,a as Sr,b as xr,c as Cr,d as Lr,e as Ar,f as oe,g as Br,h as Ir,i as Fr,j as Wr,k as zr,l as Hr,m as Ur,n as Kr,o as jr,p as Dr,q as qr,r as Vr,s as $r,t as _r,u as Qr,v as Jr,w as Yr,x as Gr,y as Xr,z as Zr}from"./chunk-2PMCKKRK.js";import{A as G,D as re,E as B,F as W,H as he,m as j,p as V}from"./chunk-ZB5EHBIO.js";import{b as x,c as Me,d as Pe,e as Ce,f as Le,g as Ae,h as q,i as C,j as E}from"./chunk-CK2E7BTU.js";import{b as vr}from"./chunk-QYADASLV.js";var lo={};vr(lo,{CircuitOpenError:()=>_e,NS_PER_MS:()=>ne,NS_PER_SEC:()=>ve,NativeIndexBackend:()=>Yt,NativeListBackend:()=>Xt,NativeLogBackend:()=>nt,NativeMapBackend:()=>$t,NativePubSubBackend:()=>Ee,RateLimiterOverflowError:()=>Ge,ResettableTimer:()=>Ve,TimeoutError:()=>Ze,audit:()=>Pt,awaitSettled:()=>Xr,buffer:()=>Ct,bufferCount:()=>Lt,bufferTime:()=>Bt,cached:()=>Jr,cascadingCache:()=>oo,catchError:()=>Vt,checkpointToRedis:()=>Gn,checkpointToS3:()=>Yn,circuitBreaker:()=>Qe,combine:()=>yt,combineLatest:()=>jt,concat:()=>ht,concatMap:()=>St,constant:()=>Er,createTransport:()=>ie,createWatermarkController:()=>tt,csvRows:()=>An,debounce:()=>Ot,debounceTime:()=>Dt,decorrelatedJitter:()=>Mr,delay:()=>Nt,deserializeError:()=>fe,dictStorage:()=>sn,distill:()=>Jt,distinctUntilChanged:()=>gt,elementAt:()=>pt,empty:()=>jr,escapeRegexChar:()=>Cr,exhaustMap:()=>wt,exponential:()=>Or,externalBundle:()=>ze,externalProducer:()=>ae,fallback:()=>er,fibonacci:()=>Rr,filter:()=>Ie,find:()=>ft,first:()=>Fe,firstValueFrom:()=>Yr,firstWhere:()=>Gr,flatMap:()=>Et,forEach:()=>Vr,fromAny:()=>Ur,fromAsyncIter:()=>Hr,fromCSV:()=>Ln,fromClickHouseWatch:()=>Fn,fromCron:()=>Ir,fromDrizzle:()=>to,fromEvent:()=>Fr,fromHTTP:()=>sr,fromHTTPPoll:()=>Tn,fromHTTPStream:()=>gn,fromIter:()=>Wr,fromKafka:()=>Rn,fromKysely:()=>no,fromMCP:()=>bn,fromNATS:()=>Hn,fromNDJSON:()=>In,fromOTel:()=>hn,fromPrisma:()=>ro,fromPrometheus:()=>Nn,fromPromise:()=>zr,fromPulsar:()=>Wn,fromRabbitMQ:()=>Kn,fromRaf:()=>Br,fromRedisStream:()=>Pn,fromSSE:()=>mn,fromSqlite:()=>Xn,fromSqliteCursor:()=>Zn,fromStatsD:()=>Sn,fromSyslog:()=>vn,fromTimer:()=>oe,fromWebSocket:()=>or,fromWebSocketReconnect:()=>kn,fromWebhook:()=>un,globToRegExp:()=>Lr,interval:()=>Wt,keepalive:()=>et,last:()=>lt,linear:()=>Nr,lru:()=>lr,map:()=>xe,matchesAnyPattern:()=>Ar,matchesCron:()=>xr,memoryStorage:()=>on,merge:()=>We,mergeMap:()=>xt,nameToSignal:()=>de,ndjsonRows:()=>Bn,never:()=>Dr,of:()=>Kr,pairwise:()=>Tt,parseCron:()=>Sr,parsePrometheusText:()=>cr,parseStatsD:()=>En,parseSyslog:()=>wn,pausable:()=>Ht,pubsub:()=>so,race:()=>vt,rateLimiter:()=>Xe,reactiveCounter:()=>rt,reactiveIndex:()=>Gt,reactiveList:()=>Zt,reactiveLog:()=>ot,reactiveMap:()=>_t,reactiveSink:()=>U,reduce:()=>it,repeat:()=>zt,replay:()=>Qr,rescue:()=>Ut,resolveBackoffPreset:()=>Be,retry:()=>$e,retrySource:()=>we,sample:()=>Mt,scan:()=>st,serializeError:()=>le,share:()=>_r,shareReplay:()=>Zr,signalToName:()=>se,singleFromAny:()=>en,singleNodeFromAny:()=>rn,skip:()=>ct,sortJsonValue:()=>tn,stableJsonString:()=>nn,stratify:()=>an,switchMap:()=>ge,take:()=>at,takeUntil:()=>dt,takeWhile:()=>ut,tap:()=>mt,throttle:()=>Rt,throttleTime:()=>qt,throwError:()=>qr,timeout:()=>rr,toArray:()=>$r,toCSV:()=>Dn,toClickHouse:()=>qn,toFile:()=>dr,toHTTP:()=>dn,toKafka:()=>Mn,toLoki:()=>Qn,toMongo:()=>_n,toNATS:()=>Un,toObservable:()=>wr,toPostgres:()=>$n,toPulsar:()=>zn,toRabbitMQ:()=>jn,toReadableStream:()=>pn,toRedisStream:()=>Cn,toS3:()=>Vn,toSSE:()=>ln,toSSEBytes:()=>fn,toSqlite:()=>eo,toTempo:()=>Jn,toWebSocket:()=>yn,tokenBucket:()=>Ye,valve:()=>Kt,verifiable:()=>Qt,window:()=>Ft,windowCount:()=>At,windowTime:()=>It,withBreaker:()=>Je,withLatestFrom:()=>kt,withMaxAttempts:()=>Pr,withStatus:()=>Se,workerBridge:()=>pr,workerSelf:()=>mr,zip:()=>bt});function nr(e){return{describeKind:"producer",...e}}function ae(e,t){return W(n=>{let a=!0,c={emit(o){a&&n.emit(o)},error(o){a&&(a=!1,n.down([[E,o]]))},complete(){a&&(a=!1,n.down([[C]]))}},r;try{let o=e(c);r=typeof o=="function"?o:void 0}catch(o){return c.error(o),()=>{a=!1}}return()=>{a=!1;try{r?.()}catch{}}},nr(t))}function ze(e,t,n){let a=!0,c,r=0,o=0,s={},d=[],i=()=>{let l=c;c=void 0;try{l?.()}catch{}};for(let l of t){let m=n?.name?`${n.name}::${l}`:l,h=n?.channelOpts?.[l],b=W(g=>(r++,()=>{o++,r>0&&o>=r&&o>=t.length&&i()}),nr({...h,name:m}));s[l]=b,d.push(b)}let p={};for(let l of t)p[l]=m=>{a&&s[l].down([[x,m]])};p.error=l=>{a&&(a=!1,j(()=>{for(let m of d)m.down([[E,l]])}),i())},p.complete=()=>{a&&(a=!1,j(()=>{for(let l of d)l.down([[C]])}),i())};let f=e(p);return c=typeof f=="function"?f:void 0,Object.assign(s,{dispose:()=>{a&&(a=!1,j(()=>{for(let l of d)try{l.down([[C]])}catch{}}),i())}})}var He=class{ring;arr;constructor(t){t===Number.POSITIVE_INFINITY||t<=0?(this.arr=[],this.ring=null):(this.ring=new tr(t),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(t){this.ring!=null?this.ring.push(t):this.arr.push(t)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let n=this.ring.toArray();return this.ring.clear(),n}let t=this.arr;return this.arr=[],t}};function Te(e){return e instanceof Error?e:new Error(String(e))}function cn(e){return e===void 0?null:typeof e=="string"?Be(e):e}function U(e,t){let{name:n,onTransportError:a,retry:c,backpressure:r,batchSize:o=Number.POSITIVE_INFINITY,flushIntervalMs:s=0,serialize:d,stopOn:i,onUpstreamMessage:p,onDispose:f,send:u,sendBatch:l,ctx:m}=t;if(!u&&!l)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let h=m,b=Math.max(1,c?.maxAttempts??1),g=cn(c?.backoff??(b>1?"exponential":void 0)),T=c?.shouldRetry??(()=>!0),y=l!==void 0||o<Number.POSITIVE_INFINITY||s>0,k=S=>n?`${n}::${S}`:void 0,v=B(void 0,{equals:()=>!1,name:k("sent")}),w=B(null,{name:k("failed")}),N=B(0,{name:k("inFlight")}),O=B(null,{name:k("errors")}),H=y?B(0,{name:k("buffered")}):void 0,z=r?B(!1,{name:k("paused")}):void 0,J=0,Y=S=>{J+=S,N.down([[x,J]])},R=S=>{try{a?.(S)}catch{}try{O.down([[x,S]])}catch{}},D=new Set,X=S=>{D.add(S);let M=()=>D.delete(S);S.then(M,M)},F=(S,M,L)=>{let I=g?g(M-1,L,null):0,K=I==null?0:typeof I=="number"&&I>0?I:0,_=Math.max(1,Math.ceil(K/1e6));return new Promise(A=>{setTimeout(()=>A(S()),_)})},$=S=>S!=null&&typeof S=="object"&&typeof S.then=="function",Z=S=>{let M;try{M=d?d(S):S}catch(A){let P=Te(A);return R({stage:"serialize",error:P,value:S}),w.down([[x,{value:S,error:P,attempts:0}]]),Promise.resolve()}let L=0,I=A=>{Y(-1);let P=Te(A);if(R({stage:"send",error:P,value:S,attempt:L}),!(L<b&&T(P,L))){w.down([[x,{value:S,error:P,attempts:L}]]);return}return F(_,L,P)},K=()=>{Y(-1),v.down([[x,S]])};function _(){L+=1,Y(1);let A;try{A=u(M,h)}catch(P){return I(P)??Promise.resolve()}return $(A)?A.then(K,P=>I(P)):(K(),Promise.resolve())}return _()},pe=r?.maxBuffer??Number.POSITIVE_INFINITY,te=new He(pe),ee,ye=!1,Ne=()=>{H?.down([[x,te.length]])},ke=S=>{z&&z.down([[x,S]])},Ke=r?.strategy??"drop-oldest",gr=(S,M)=>{let L={value:S,payload:M};if(te.length<pe)return te.push(L),Ne(),!0;if(Ke==="drop-oldest"){let K=te.shift();return te.push(L),Ne(),ke(!0),w.down([[x,{value:K.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(Ke==="drop-newest")return ke(!0),w.down([[x,{value:S,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let I=new Error("backpressure: buffer overflow");return R({stage:"send",error:I,value:S}),w.down([[x,{value:S,error:I,attempts:0}]]),ke(!0),!1},Tr=S=>{let M=0,L=S.map(A=>A.payload),I=A=>{Y(-1);let P=Te(A);if(R({stage:"send",error:P,value:S.map(Re=>Re.value),attempt:M}),!(M<b&&T(P,M))){for(let{value:Re}of S)w.down([[x,{value:Re,error:P,attempts:M}]]);return}return F(_,M,P)},K=()=>{Y(-1);for(let{value:A}of S)v.down([[x,A]])};function _(){M+=1,Y(1);let A;try{A=l(L,h)}catch(P){return I(P)??Promise.resolve()}return $(A)?A.then(K,P=>I(P)):(K(),Promise.resolve())}return _()},yr=async S=>{for(let M of S)await kr(M.value,M.payload)},kr=(S,M)=>{let L=0,I=A=>{Y(-1);let P=Te(A);if(R({stage:"send",error:P,value:S,attempt:L}),!(L<b&&T(P,L))){w.down([[x,{value:S,error:P,attempts:L}]]);return}return F(_,L,P)},K=()=>{Y(-1),v.down([[x,S]])};function _(){L+=1,Y(1);let A;try{A=u(M,h)}catch(P){return I(P)??Promise.resolve()}return $(A)?A.then(K,P=>I(P)):(K(),Promise.resolve())}return _()},me=()=>{if(ye||te.length===0)return Promise.resolve();let S=te.drain();if(Ne(),ke(!1),l!==void 0){let L=Tr(S);return X(L),L}let M=yr(S);return X(M),M},br=()=>{ee!==void 0||ye||s<=0||(ee=setTimeout(()=>{ee=void 0,me()},s))},hr=e.subscribe(S=>{for(let M of S){let L=M[0];if(L!==x)try{p?.(M)}catch{}if(L===x){let I=M[1];if(y){let K;if(d)try{K=d(I)}catch(A){let P=Te(A);R({stage:"serialize",error:P,value:I}),w.down([[x,{value:I,error:P,attempts:0}]]);continue}else K=I;if(!gr(I,K))continue;te.length>=o?me():br()}else{let K=Z(I);X(K)}}else G.messageTier(L)>=3&&y&&(ee!==void 0&&(clearTimeout(ee),ee=void 0),me())}}),je;if(i){let S=!1;je=i.subscribe(M=>{if(!S){S=!0;return}M.length>0&&!Oe&&De()})}let Oe=!1,De=()=>{if(Oe)return;Oe=!0,ee!==void 0&&(clearTimeout(ee),ee=void 0),y&&me(),ye=!0,je?.(),hr();let S=M=>{try{M.down([[q]])}catch{}};S(O),S(w),S(v),S(N),H&&S(H),z&&S(z);try{f?.()}catch{}},be={dispose:De,sent:v,failed:w,inFlight:N,errors:O};return y&&(be.buffered=H,be.flush=async()=>{ye||(await me(),await Promise.all(D))}),z&&(be.paused=z),be}function Q(e){return{describeKind:"producer",...e}}function or(e,t){let{parse:n,closeOnTeardown:a=!1,...c}=t??{};return W(r=>{let o=!0,s,d=()=>{let g=s;s=void 0,g?.()},i=g=>{o&&(o=!1,r.down([g]),d())},p=(g,T=g)=>{if(o)try{let y=g!==null&&typeof g=="object"&&"data"in g?g.data:g,k=n?n(y,T):y;r.emit(k)}catch(y){i([E,y])}},f=g=>{i([E,g])},u=()=>{i([C])};if(typeof e=="function"){try{if(s=e(p,f,u),typeof s!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(g){i([E,g])}return()=>{o=!1,d()}}let l=e,m=g=>p(g,g),h=g=>f(g),b=()=>u();return l.addEventListener("message",m),l.addEventListener("error",h),l.addEventListener("close",b),s=()=>{l.removeEventListener("message",m),l.removeEventListener("error",h),l.removeEventListener("close",b),a&&l.close()},()=>{o=!1,d()}},Q(c))}function un(e,t){return ae(e,t)}function sr(e,t){let{method:n="GET",headers:a,body:c,transform:r=y=>y.json(),timeoutNs:o=30*1e9,signal:s,completeAfterFetch:d=!1,refetchOnSubscribe:i=!1,...p}=t??{},f=B(0,{name:`${p.name??"http"}/fetchCount`}),u=B(0,{name:`${p.name??"http"}/lastUpdated`}),l=B(!1,{name:`${p.name??"http"}/fetched`}),m=0,h=c!==void 0?typeof c=="string"?c:JSON.stringify(c):void 0,b=y=>{let k=new AbortController,v=!0;if(s?.aborted)return v=!1,y.down([[E,s.reason??new Error("Aborted")]]),()=>{};s?.addEventListener("abort",()=>k.abort(s.reason),{once:!0});let w=setTimeout(()=>k.abort(new Error("Request timeout")),Math.ceil(o/1e6));return fetch(e,{method:n,headers:a,body:h,signal:k.signal}).then(async N=>{if(clearTimeout(w),!v)return;if(!N.ok)throw new Error(`HTTP ${N.status}: ${N.statusText}`);let O=await r(N);v&&(j(()=>{m+=1,f.down([[x,m]]),u.down([[x,V()]]),l.down([[x,!0]]),y.emit(O)}),d&&y.down([[C]]))}).catch(N=>{clearTimeout(w),v&&(N&&N.name==="AbortError"||y.down([[E,N]]))}),()=>{v=!1,k.abort()}},g=W(y=>b({emit:k=>y.emit(k),down:k=>y.down(k)}),{...Q(p),resubscribable:i});return{...Se(g),fetchCount:f,lastUpdated:u,fetched:l}}function dn(e,t,n){let{method:a="POST",headers:c={"Content-Type":"application/json"},serialize:r=m=>JSON.stringify(m),timeoutNs:o,batchFormat:s="json-array",batchSize:d,flushIntervalMs:i,retry:p,onTransportError:f}=n??{},u=async m=>{let h=o!==void 0?new AbortController:void 0,b;h&&o!==void 0&&(b=setTimeout(()=>h.abort(new Error("Request timeout")),Math.ceil(o/1e6)));try{let g=await fetch(t,{method:a,headers:c,body:m,signal:h?.signal}),T=async()=>{try{await g.arrayBuffer?.()}catch{}};if(!g.ok)throw await T(),new Error(`HTTP ${g.status}: ${g.statusText}`);await T()}finally{b!==void 0&&clearTimeout(b)}};return d!==void 0||i!==void 0?U(e,{onTransportError:f,retry:p,batchSize:d,flushIntervalMs:i,sendBatch:async m=>{let h;s==="ndjson"?h=m.map(b=>{let g=r(b);return typeof g=="string"?g:new TextDecoder().decode(g)}).join(`
2
+ `):h=JSON.stringify(m),await u(h)}}):U(e,{onTransportError:f,retry:p,serialize:r,send:async m=>{await u(m)}})}function ir(e){return Symbol.keyFor(e)??e.description??"message"}function ce(e,t){return typeof e=="string"?e:t(e)}function ar(e,t){let n=`event: ${e}
3
+ `;if(t!==void 0){let a=t.split(/\r?\n/);for(let c of a)n+=`data: ${c}
4
+ `}return`${n}
5
+ `}function ln(e,t){let{serialize:n=l=>{if(l instanceof Error)return l.message;try{return JSON.stringify(l)}catch{return String(l)}},dataEvent:a="data",errorEvent:c="error",completeEvent:r="complete",includeResolved:o=!1,includeDirty:s=!1,keepAliveMs:d,signal:i,eventNameResolver:p=ir}=t??{},f=new TextEncoder,u;return new ReadableStream({start(l){let m=!1,h,b=()=>{},g=()=>{m||(m=!0,h!==void 0&&clearInterval(h),i?.removeEventListener("abort",y),b(),l.close())};u=g;let T=(k,v)=>{m||l.enqueue(f.encode(ar(k,v)))},y=()=>{m||g()};b=e.subscribe(k=>{for(let v of k){let w=v[0];if(!(G.isLocalOnly(w)&&!(w===Me&&s))){if(w===x){T(a,ce(v[1],n));continue}if(w===E){T(c,ce(v[1],n)),g();return}if(w===C){T(r),g();return}!o&&w===Pe||T(p(w),v.length>1?ce(v[1],n):void 0)}}}),d!==void 0&&d>0&&(h=setInterval(()=>{m||l.enqueue(f.encode(`: keepalive
6
+
7
+ `))},d)),i?.aborted?y():i?.addEventListener("abort",y,{once:!0})},cancel(){u?.()}})}function fn(e,t){let{serialize:n=u=>{if(u instanceof Error)return u.message;try{return JSON.stringify(u)}catch{return String(u)}},dataEvent:a="data",errorEvent:c="error",completeEvent:r="complete",includeResolved:o=!1,includeDirty:s=!1,keepAliveMs:d,signal:i,eventNameResolver:p=ir}=t??{},f=new TextEncoder;return W(u=>{let l=!0,m,h=(T,y)=>{l&&u.emit(f.encode(ar(T,y)))},b=()=>{l&&(l=!1,u.down([[C]]))},g=e.subscribe(T=>{if(l)for(let y of T){let k=y[0];if(!(G.isLocalOnly(k)&&!(k===Me&&s))){if(k===x){h(a,ce(y[1],n));continue}if(k===E){h(c,ce(y[1],n)),l=!1,u.down([[C]]);return}if(k===C){h(r),l=!1,u.down([[C]]);return}!o&&k===Pe||h(p(k),y.length>1?ce(y[1],n):void 0)}}});return d!==void 0&&d>0&&(m=setInterval(()=>{l&&u.emit(f.encode(`: keepalive
8
+
9
+ `))},d)),i?.aborted?b():i?.addEventListener("abort",b,{once:!0}),()=>{l=!1,m!==void 0&&clearInterval(m),i?.removeEventListener("abort",b),g()}})}function pn(e){let t,n=!1;return new ReadableStream({start(a){t=e.subscribe(c=>{for(let r of c){let o=r[0];if(n)return;if(o===x)try{a.enqueue(r[1])}catch{n=!0,t?.()}else if(o===E){n=!0;try{a.error(r[1])}catch{}return}else if(o===C){n=!0;try{a.close()}catch{}return}}})},cancel(){n=!0,t?.()}})}function mn(e,t){let{parse:n=c=>c,...a}=t??{};return W(c=>{let r=!0,o=new TextDecoder,s="",d="message",i=[],p,f,u=()=>{if(i.length===0&&d==="message"&&p===void 0){i=[];return}let T=i.join(`
10
+ `);c.emit({event:d,data:n(T),id:p,retry:f}),d="message",i=[],p=void 0,f=void 0},l=T=>{if(T===""){u();return}if(T.startsWith(":"))return;let y=T.indexOf(":"),k=y<0?T:T.slice(0,y),v=y<0?"":T.slice(y+1);switch(v.startsWith(" ")&&(v=v.slice(1)),k){case"event":d=v;break;case"data":i.push(v);break;case"id":v.includes("\0")||(p=v);break;case"retry":{let w=Number(v);Number.isFinite(w)&&(f=w);break}}},m=(T,y)=>{if(!r)return;s+=o.decode(T,{stream:!y});let k=s.split(/\r?\n/);s=k.pop()??"";for(let v of k)l(v)},h,b;return(async()=>{try{let T=e,y=e instanceof ReadableStream?e:T&&typeof T=="object"&&T.body instanceof ReadableStream?T.body:null;if(y){for(h=y.getReader();r;){let{value:k,done:v}=await h.read();if(v)break;m(k,!1)}m(new Uint8Array,!0)}else{for(b=e[Symbol.asyncIterator]();r;){let v=await b.next();if(v.done)break;m(v.value,!1)}m(new Uint8Array,!0)}if(s.trim()){for(let k of s.split(/\r?\n/))l(k);u()}r&&c.down([[C]])}catch(T){r&&c.down([[E,T]])}})(),()=>{r=!1,h&&h.cancel().catch(()=>{}),b&&typeof b.return=="function"&&Promise.resolve(b.return()).catch(()=>{})}},Q(a))}function gn(e,t){let{method:n="GET",headers:a,body:c,signal:r,...o}=t??{};return W(s=>{let d=!0,i=new AbortController;if(r?.aborted)return s.down([[E,r.reason??new Error("Aborted")]]),()=>{};r?.addEventListener("abort",()=>i.abort(r.reason),{once:!0});let p=c!==void 0?typeof c=="string"?c:JSON.stringify(c):void 0;return(async()=>{try{let u=await fetch(e,{method:n,headers:a,body:p,signal:i.signal});if(!d)return;if(!u.ok)throw new Error(`HTTP ${u.status}: ${u.statusText}`);if(!u.body)throw new Error("HTTP response has no body");let l=u.body.getReader();for(;d;){let{value:m,done:h}=await l.read();if(h)break;m&&s.emit(m)}d&&s.down([[C]])}catch(u){if(!d||u&&u.name==="AbortError")return;s.down([[E,u]])}})(),()=>{d=!1,i.abort()}},Q(o))}function Tn(e,t){let{intervalMs:n=5e3,...a}=t??{};return ge(oe(n,{period:n}),()=>sr(e,{...a,completeAfterFetch:!0}).node)}function yn(e,t,n){let{serialize:a=g=>{if(typeof g=="string"||g instanceof Blob||g instanceof ArrayBuffer||ArrayBuffer.isView(g))return g;try{return JSON.stringify(g)}catch{return String(g)}},closeOnComplete:c=!0,closeOnError:r=!0,closeCode:o,closeReason:s,onTransportError:d,retry:i,backpressure:p,stopOn:f}=n??{},u=!1,l=g=>{if(!u){u=!0;try{t.close(o,s)}catch(T){let y=T instanceof Error?T:new Error(String(T));try{d?.({stage:"close",error:y,value:void 0,message:g})}catch{}}}},m=null,b=U(e,{onTransportError:d,serialize:g=>{let T=a(g);if(T===void 0)throw new Error("serialize returned undefined");return T},retry:i,backpressure:p,stopOn:f,onDispose:()=>{if(m){try{t.removeEventListener("close",m)}catch{}m=null}},send:g=>{t.send(g)},onUpstreamMessage:g=>{(g[0]===C&&c||g[0]===E&&r)&&l(g)}});return m=()=>{u=!0,b.dispose()},t.addEventListener("close",m),b}function kn(e,t){let{parse:n,maxRetries:a,backoff:c="exponential",closeOnTeardown:r=!0,...o}=t??{};return we(()=>or(e(),{parse:n,closeOnTeardown:r,...o}),{count:a,backoff:c})}function bn(e,t){let{method:n="notifications/message",onDisconnect:a,...c}=t??{};return ae(({emit:r,error:o})=>(e.setNotificationHandler(n,s=>r(s)),a?.(s=>o(s??new Error("MCP client disconnected"))),()=>e.setNotificationHandler(n,()=>{})),c)}function hn(e,t){return ze(({traces:a,metrics:c,logs:r,error:o})=>e({onTraces:s=>{j(()=>{for(let d of s)a(d)})},onMetrics:s=>{j(()=>{for(let d of s)c(d)})},onLogs:s=>{j(()=>{for(let d of s)r(d)})},onError:o})??void 0,["traces","metrics","logs"],t?.name?{name:t.name}:void 0)}function vn(e,t){return ae(e,t)}function wn(e){let t=e.match(/^<(\d{1,3})>\d?\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*)/s);if(!t){let a=V();return{facility:1,severity:6,timestamp:new Date(Math.floor(a/1e6)).toISOString(),hostname:"-",appName:"-",procId:"-",msgId:"-",message:e.trim(),timestampNs:a}}let n=Number(t[1]);return{facility:n>>3,severity:n&7,timestamp:t[2],hostname:t[3],appName:t[4],procId:t[5],msgId:t[6],message:(t[7]??"").trim(),timestampNs:V()}}function Sn(e,t){return ae(e,t)}var xn={c:"counter",g:"gauge",ms:"timer",h:"histogram",s:"set",d:"distribution"};function En(e){let t=e.split("|"),[n,a]=(t[0]??"").split(":");if(!n||a===void 0)throw new Error(`Invalid StatsD line: ${e}`);let c=t[1]?.trim()??"c",r=xn[c]??"counter",o=r==="set"?0:Number(a),s,d={};for(let i=2;i<t.length;i++){let p=t[i].trim();if(p.startsWith("@"))s=Number(p.slice(1));else if(p.startsWith("#"))for(let f of p.slice(1).split(",")){let[u,l]=f.split(":");u&&(d[u]=l??"")}}return{name:n.trim(),value:o,type:r,sampleRate:s,tags:d,timestampNs:V()}}function Nn(e,t){let{intervalNs:n=15*1e9,headers:a,timeoutNs:c=10*1e9,signal:r,maxConsecutiveErrors:o=1}=t??{},s=Math.ceil(n/1e6),d=0;return ge(oe(0,{period:s,signal:r}),()=>W(i=>{let p=!0,f=new AbortController,u=setTimeout(()=>f.abort(new Error("Scrape timeout")),Math.ceil(c/1e6));return(async()=>{try{let m=await fetch(e,{headers:{Accept:"text/plain",...a},signal:f.signal});if(clearTimeout(u),!p)return;if(!m.ok)throw new Error(`Prometheus scrape ${m.status}: ${m.statusText}`);let h=await m.text();if(!p)return;let b=cr(h);for(let g of b)i.emit(g);d=0,i.down([[C]])}catch(m){if(clearTimeout(u),!p||m instanceof Error&&m.name==="AbortError")return;d+=1,d>=o&&i.down([[E,m]])}})(),()=>{p=!1,clearTimeout(u),f.abort()}}))}function cr(e){let t=[],n=new Map,a=new Map;for(let c of e.split(`
11
+ `)){let r=c.trim();if(!r)continue;if(r.startsWith("# TYPE ")){let u=r.slice(7),l=u.indexOf(" ");l>0&&n.set(u.slice(0,l),u.slice(l+1).trim());continue}if(r.startsWith("# HELP ")){let u=r.slice(7),l=u.indexOf(" ");l>0&&a.set(u.slice(0,l),u.slice(l+1).trim());continue}if(r.startsWith("#"))continue;let o,s={},d,i,p=r.indexOf("{");if(p>=0){o=r.slice(0,p);let u=r.indexOf("}",p);if(u<0)continue;let l=r.slice(p+1,u);s=On(l);let m=r.slice(u+1).trim().split(/\s+/);d=m[0]??"",i=m[1]}else{let u=r.split(/\s+/);o=u[0]??"",d=u[1]??"",i=u[2]}if(!o||!d)continue;let f=o.replace(/(_total|_count|_sum|_bucket|_created|_info)$/,"");t.push({name:o,labels:s,value:Number(d),timestampMs:i?Number(i):void 0,type:n.get(f)??n.get(o),help:a.get(f)??a.get(o),timestampNs:V()})}return t}function On(e){let t={},n=/(\w+)="((?:[^"\\]|\\.)*)"/g,a=n.exec(e);for(;a!==null;)t[a[1]]=a[2].replace(/\\(.)/g,"$1"),a=n.exec(e);return t}function Rn(e,t,n){let{fromBeginning:a=!1,deserialize:c=o=>{if(o===null)return null;try{return JSON.parse(o.toString())}catch{return o.toString()}},...r}=n??{};return W(o=>{let s=!0;return(async()=>{try{await e.subscribe({topic:t,fromBeginning:a}),await e.run({eachMessage:async({topic:i,partition:p,message:f})=>{if(!s)return;let u={};if(f.headers)for(let[l,m]of Object.entries(f.headers))m!==void 0&&(u[l]=typeof m=="string"?m:m.toString());o.emit({topic:i,partition:p,key:f.key?.toString()??null,value:c(f.value),headers:u,offset:f.offset,timestamp:f.timestamp,timestampNs:V()})}})}catch(i){s&&o.down([[E,i]])}})(),()=>{s=!1}},Q(r))}function Mn(e,t,n,a){let{serialize:c=s=>JSON.stringify(s),keyExtractor:r,onTransportError:o}=a??{};return U(e,{onTransportError:o,send:async s=>{let d=r?.(s)??null,i=c(s);await t.send({topic:n,messages:[{key:d,value:Buffer.from(i)}]})}})}function Pn(e,t,n){let{blockMs:a=5e3,startId:c="$",parse:r=s=>{for(let i=0;i<s.length;i+=2)if(s[i]==="data")try{return JSON.parse(s[i+1])}catch{return s[i+1]}let d={};for(let i=0;i<s.length;i+=2)d[s[i]]=s[i+1];return d},...o}=n??{};return W(s=>{let d=!0,i=c;return(async()=>{for(;d;)try{let f=await e.xread("BLOCK",a,"STREAMS",t,i);if(!d)return;if(f)for(let[u,l]of f)for(let[m,h]of l)i=m,s.emit({id:m,key:t,data:r(h),timestampNs:V()})}catch(f){if(!d)return;s.down([[E,f]]);return}})(),()=>{d=!1}},Q(o))}function Cn(e,t,n,a){let{serialize:c=s=>["data",JSON.stringify(s)],maxLen:r,onTransportError:o}=a??{};return U(e,{onTransportError:o,send:async s=>{let d=c(s);await(r!==void 0?t.xadd(n,"MAXLEN","~",String(r),"*",...d):t.xadd(n,"*",...d))}})}function Ln(e,t){let{delimiter:n=",",hasHeader:a=!0,columns:c,parseLine:r,...o}=t??{},s=r??(d=>ur(d,n));return W(d=>{let i=!1;return(async()=>{try{let f=c,u="";for await(let l of e){if(i)return;u+=l;let m=u.split(/\r?\n/);u=m.pop()??"";for(let h of m){if(i)return;if(!h.trim())continue;let b=s(h);if(!f&&a){f=b;continue}f||(f=b.map((T,y)=>`col${y}`));let g={};for(let T=0;T<f.length;T++)g[f[T]]=b[T]??"";d.emit(g)}}if(!i&&u.trim()){let l=s(u);if(f){let m={};for(let h=0;h<f.length;h++)m[f[h]]=l[h]??"";d.emit(m)}}i||d.down([[C]])}catch(f){i||d.down([[E,f]])}})(),()=>{i=!0}},Q(o))}function An(e,t){let{delimiter:n=",",hasHeader:a=!0,columns:c,parseLine:r,...o}=t??{},s=r??(d=>ur(d,n));return re([e],(d,i,p)=>{let f=d[0];if(f==null||f.length===0)return;let u=p.store;typeof u.buffer!="string"&&(u.buffer=""),u.headers===void 0&&c&&(u.headers=c.slice());for(let l of f){u.buffer=u.buffer+l;let m=u.buffer.split(/\r?\n/);u.buffer=m.pop()??"";for(let h of m){if(!h.trim())continue;let b=s(h);if(!u.headers&&a){u.headers=b;continue}u.headers||(u.headers=b.map((T,y)=>`col${y}`));let g={};for(let T=0;T<u.headers.length;T++)g[u.headers[T]]=b[T]??"";i.emit(g)}}},{describeKind:"derived",...o})}function Bn(e,t){return re([e],(n,a,c)=>{let r=n[0];if(r==null||r.length===0)return;let o=c.store;typeof o.buffer!="string"&&(o.buffer="");for(let s of r){o.buffer=o.buffer+s;let d=o.buffer.split(/\r?\n/);o.buffer=d.pop()??"";for(let i of d)if(i.trim())try{a.emit(JSON.parse(i))}catch(p){a.down([[E,p]]);return}}},{describeKind:"derived",...t??{}})}function ur(e,t){let n=[],a="",c=!1;for(let r=0;r<e.length;r++){let o=e[r];c?o==='"'?e[r+1]==='"'?(a+='"',r++):c=!1:a+=o:o==='"'?c=!0:o===t?(n.push(a),a=""):a+=o}return n.push(a),n}function In(e,t){return W(n=>{let a=!1;return(async()=>{try{let r="";for await(let o of e){if(a)return;r+=o;let s=r.split(/\r?\n/);r=s.pop()??"";for(let d of s){if(a)return;let i=d.trim();i&&n.emit(JSON.parse(i))}}!a&&r.trim()&&n.emit(JSON.parse(r.trim())),a||n.down([[C]])}catch(r){a||n.down([[E,r]])}})(),()=>{a=!0}},Q(t))}function Fn(e,t,n){let{intervalNs:a=5*1e9,format:c="JSONEachRow",signal:r,maxConsecutiveErrors:o=1}=n??{},s=Math.ceil(a/1e6),d=0;return ge(oe(0,{period:s,signal:r}),()=>W(i=>{let p=!0;return(async()=>{try{let u=await e.query({query:t,format:c});if(!p)return;let l=await u.json();if(!p)return;for(let m of l)i.emit(m);d=0,i.down([[C]])}catch(u){if(!p)return;d+=1,d>=o&&i.down([[E,u]])}})(),()=>{p=!1}}))}function Wn(e,t){let{autoAck:n=!0,deserialize:a=s=>{try{return JSON.parse(s.toString())}catch{return s.toString()}},onAckError:c,...r}=t??{},o=s=>{if(c)try{c(s instanceof Error?s:new Error(String(s)))}catch{}};return W(s=>{let d=!0;return(async()=>{for(;d;)try{let p=await e.receive();if(!d)return;let f={topic:p.getTopicName(),messageId:p.getMessageId().toString(),key:p.getPartitionKey(),value:a(p.getData()),properties:p.getProperties(),publishTime:p.getPublishTimestamp(),eventTime:p.getEventTimestamp(),timestampNs:V()};if(n)s.emit(f),e.acknowledge(p).catch(o);else{let u=!1,l={value:f,ack(){u||(u=!0,e.acknowledge(p).catch(o))},nack(m){if(u)return;u=!0;let h=e;try{let b=h.negativeAcknowledge?.(p);b&&typeof b.then=="function"&&b.catch(o)}catch(b){o(b)}}};s.emit(l)}}catch(p){d&&s.down([[E,p]]);return}})(),()=>{d=!1}},Q(r))}function zn(e,t,n){let{serialize:a=s=>Buffer.from(JSON.stringify(s)),keyExtractor:c,propertiesExtractor:r,onTransportError:o}=n??{};return U(e,{onTransportError:o,send:async s=>{await t.send({data:a(s),partitionKey:c?.(s),properties:r?.(s)})}})}function Hn(e,t,n){let a=new TextDecoder,{queue:c,deserialize:r=s=>{let d=a.decode(s);try{return JSON.parse(d)}catch{return d}},...o}=n??{};return W(s=>{let d=!0,i=e.subscribe(t,c?{queue:c}:void 0);return(async()=>{try{for await(let f of i){if(!d)return;let u={};if(f.headers)for(let l of f.headers.keys())u[l]=f.headers.get(l);s.emit({subject:f.subject,data:r(f.data),headers:u,reply:f.reply,sid:f.sid,timestampNs:V()})}d&&s.down([[C]])}catch(f){d&&s.down([[E,f]])}})(),()=>{d=!1}},Q(o))}function Un(e,t,n,a){let c=new TextEncoder,{serialize:r=s=>c.encode(JSON.stringify(s)),onTransportError:o}=a??{};return U(e,{onTransportError:o,send:s=>{t.publish(n,r(s))}})}function Kn(e,t,n){let{autoAck:a=!0,deserialize:c=d=>{try{return JSON.parse(d.toString())}catch{return d.toString()}},onAckError:r,...o}=n??{},s=d=>{if(r)try{r(d instanceof Error?d:new Error(String(d)))}catch{}};return W(d=>{let i=!0,p;return(async()=>{try{p=(await e.consume(t,l=>{if(!i)return;if(l===null){i&&d.down([[E,new Error("Consumer cancelled by broker")]]);return}let m={queue:t,routingKey:l.fields.routingKey,exchange:l.fields.exchange,content:c(l.content),properties:l.properties,deliveryTag:l.fields.deliveryTag,redelivered:l.fields.redelivered,timestampNs:V()};if(a){d.emit(m);try{e.ack(l)}catch(h){s(h)}}else{let h=!1,b=e,g={value:m,ack(){if(!h){h=!0;try{e.ack(l)}catch(T){s(T)}}},nack(T){if(h)return;h=!0;let y=T?.requeue;if(!b.nack){s(new Error("RabbitMQ channel does not expose `nack`; cannot negative-ack"));return}try{b.nack(l,!1,y)}catch(k){s(k)}}};d.emit(g)}},{noAck:!1})).consumerTag}catch(u){i&&d.down([[E,u]])}})(),()=>{i=!1,p!==void 0&&e.cancel(p)}},Q(o))}function jn(e,t,n,a){let{serialize:c=s=>Buffer.from(JSON.stringify(s)),routingKeyExtractor:r=()=>"",onTransportError:o}=a??{};return U(e,{onTransportError:o,send:s=>{let d=r(s),i=c(s);t.publish(n,d,i)}})}function dr(e,t,n){let{serialize:a=f=>`${JSON.stringify(f)}
12
+ `,flushIntervalMs:c=0,batchSize:r=Number.POSITIVE_INFINITY,onTransportError:o,mode:s}=n??{},i=c>0||r<Number.POSITIVE_INFINITY?U(e,{onTransportError:o,batchSize:r,flushIntervalMs:c,serialize:a,sendBatch:f=>{t.write(f.join(""))}}):U(e,{onTransportError:o,serialize:a,send:f=>{t.write(f)}}),p=i.dispose;return i.dispose=()=>{p();try{t.end()}catch{}},i}function Ue(e,t){return e.includes(t)||e.includes('"')||e.includes(`
13
+ `)?`"${e.replace(/"/g,'""')}"`:e}function Dn(e,t,n){let{columns:a,delimiter:c=",",writeHeader:r=!0,cellExtractor:o=(l,m)=>String(l[m]??""),flushIntervalMs:s=0,batchSize:d=Number.POSITIVE_INFINITY,onTransportError:i,...p}=n,f=!1;return dr(e,t,{serialize:l=>{if(!f&&r){f=!0;let m=a.map(b=>Ue(b,c)).join(c),h=a.map(b=>Ue(o(l,b),c)).join(c);return`${m}
14
+ ${h}
15
+ `}return`${a.map(m=>Ue(o(l,m),c)).join(c)}
16
+ `},flushIntervalMs:s,batchSize:d,onTransportError:i,...p})}function qn(e,t,n,a){let{batchSize:c=1e3,flushIntervalMs:r=5e3,format:o="JSONEachRow",transform:s=i=>i,onTransportError:d}=a??{};return U(e,{onTransportError:d,batchSize:c,flushIntervalMs:r,serialize:s,sendBatch:async i=>{await t.insert({table:n,values:i,format:o})}})}function Vn(e,t,n,a){let{format:c="ndjson",keyGenerator:r=(u,l)=>{let m=Math.floor(l/1e6);return`data/${new Date(m).toISOString().replace(/[:.]/g,"-")}-${u}.${c==="ndjson"?"ndjson":"json"}`},batchSize:o=1e3,flushIntervalMs:s=1e4,transform:d=u=>u,onTransportError:i}=a??{},p=c==="ndjson"?"application/x-ndjson":"application/json",f=0;return U(e,{onTransportError:i,batchSize:o,flushIntervalMs:s,serialize:d,sendBatch:async u=>{f+=1;let l=c==="ndjson"?`${u.map(h=>JSON.stringify(h)).join(`
17
+ `)}
18
+ `:JSON.stringify(u),m=r(f,V());await t.putObject({Bucket:n,Key:m,Body:l,ContentType:p})}})}function $n(e,t,n,a){let{toSQL:c=(o,s)=>({sql:`INSERT INTO "${s.replace(/"/g,'""')}" (data) VALUES ($1)`,params:[JSON.stringify(o)]}),onTransportError:r}=a??{};return U(e,{onTransportError:r,serialize:o=>c(o,n),send:async o=>{let s=o;await t.query(s.sql,s.params)}})}function _n(e,t,n){let{toDocument:a=r=>r,onTransportError:c}=n??{};return U(e,{onTransportError:c,serialize:a,send:async r=>{await t.insertOne(r)}})}function Qn(e,t,n){let{labels:a={},toLine:c=s=>JSON.stringify(s),toLabels:r,onTransportError:o}=n??{};return U(e,{onTransportError:o,serialize:s=>({line:c(s),labels:r?{...a,...r(s)}:a}),send:async s=>{let{line:d,labels:i}=s,p=`${V()}`;await t.push({streams:[{stream:i,values:[[p,d]]}]})}})}function Jn(e,t,n){let{toResourceSpans:a=r=>[r],onTransportError:c}=n??{};return U(e,{onTransportError:c,serialize:a,send:async r=>{await t.push({resourceSpans:r})}})}function Yn(e,t,n,a){let{prefix:c="checkpoints/",debounceMs:r=500,compactEvery:o=10,onError:s}=a??{},d={debounceMs:r,compactEvery:o,save(i,p){let f=Math.floor(V()/1e6),u=`${c}${e.name}/checkpoint-${f}.json`,l;try{l=JSON.stringify(p)}catch(m){s?.(m);return}t.putObject({Bucket:n,Key:u,Body:l,ContentType:"application/json"}).catch(m=>s?.(m))},load(){return null}};return e.attachStorage([d],{onError:i=>s?.(i)})}function Gn(e,t,n){let{prefix:a="graphrefly:checkpoint:",debounceMs:c=500,compactEvery:r=10,onError:o}=n??{},s=`${a}${e.name}`,d={debounceMs:c,compactEvery:r,save(i,p){let f;try{f=JSON.stringify(p)}catch(u){o?.(u);return}t.set(s,f).catch(u=>o?.(u))},async load(){let i=await t.get(s);if(i==null)return null;try{return JSON.parse(i)}catch{return null}}};return e.attachStorage([d],{onError:i=>o?.(i)})}function Xn(e,t,n){let{mapRow:a=o=>o,params:c,...r}=n??{};return W(o=>{try{let d=e.query(t,c).map(a);o.emit(d),o.down([[C]])}catch(s){o.down([[E,s instanceof Error?s:new Error(String(s))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...r})}function Zn(e,t,n){let{mapRow:a=o=>o,params:c,...r}=n??{};return W(o=>{try{let s=e.iterate(t,c);j(()=>{for(let d of s)o.emit(a(d));o.down([[C]])})}catch(s){o.down([[E,s instanceof Error?s:new Error(String(s))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...r})}function eo(e,t,n,a){if(n.includes("\0")||n.length===0)throw new Error(`toSqlite: invalid table name: ${JSON.stringify(n)}`);let{toSQL:c=(R,D)=>({sql:`INSERT INTO "${D.replace(/"/g,'""')}" (data) VALUES (?)`,params:[JSON.stringify(R)]}),onTransportError:r,batchInsert:o=!1,maxBatchSize:s=1e3,flushIntervalMs:d=0}=a??{},i=R=>c(R,n);if(!o)return U(e,{onTransportError:r,serialize:i,send:R=>{let D=R;t.query(D.sql,D.params)}});let p=B(null),f=B(void 0,{equals:()=>!1}),u=B(null),l=B(0),m=B(0),h=R=>{try{r?.(R)}catch{}try{p.down([[x,R]])}catch{}},b=[],g=!1,T,y=!1,k=()=>m.down([[x,b.length]]),v=R=>{y||f.down([[x,R]])},w=R=>{y||u.down([[x,R]])},N=R=>{y||l.down([[x,R]])},O=R=>{y||h(R)},H=()=>{if(b.length===0||g)return;g=!0,N(1);try{t.query("BEGIN",[])}catch(F){g=!1,N(0),O({stage:"send",error:F instanceof Error?F:new Error(String(F)),value:void 0});return}let R=b;b=[],k();let D,X=0;for(let F of R)try{t.query(F.query.sql,F.query.params),X+=1}catch($){D=$ instanceof Error?$:new Error(String($));break}if(D){try{t.query("ROLLBACK",[])}catch{}O({stage:"send",error:D,value:void 0});for(let F of R)w({value:F.value,error:D,attempts:1})}else try{t.query("COMMIT",[]);for(let F of R)v(F.value)}catch(F){let $=F instanceof Error?F:new Error(String(F));O({stage:"send",error:$,value:void 0});for(let Z=0;Z<X;Z++)w({value:R[Z].value,error:$,attempts:1})}g=!1,N(0)},z=()=>{d>0&&T===void 0&&!y&&(T=setTimeout(()=>{T=void 0,H()},d))},J=e.subscribe(R=>{for(let D of R){let X=D[0];if(X===x){let F=D[1],$;try{$=i(F)}catch(Z){let pe=Z instanceof Error?Z:new Error(String(Z));h({stage:"serialize",error:pe,value:F}),u.down([[x,{value:F,error:pe,attempts:0}]]);continue}b.push({value:F,query:$}),k(),b.length>=s?H():z()}else G.messageTier(X)>=3&&H()}});return{dispose:()=>{if(!y){T!==void 0&&(clearTimeout(T),T=void 0),H(),y=!0,J();for(let R of[p,f,u,l,m])try{R.down([[q]])}catch{}}},sent:f,failed:u,inFlight:l,errors:p,buffered:m,flush:async()=>{y||H()}}}function ro(e,t){let{args:n,mapRow:a=r=>r,...c}=t??{};return W(r=>{let o=!0;return e.findMany(n).then(s=>{o&&(r.emit(s.map(a)),r.down([[C]]))}).catch(s=>{if(o)try{r.down([[E,s instanceof Error?s:new Error(String(s))]])}catch{}}),()=>{o=!1}},{...c,describeKind:"producer",completeWhenDepsComplete:!1})}function to(e,t){let{mapRow:n=c=>c,...a}=t??{};return W(c=>{let r=!0;return e.execute().then(o=>{r&&(c.emit(o.map(n)),c.down([[C]]))}).catch(o=>{if(r)try{c.down([[E,o instanceof Error?o:new Error(String(o))]])}catch{}}),()=>{r=!1}},{...a,describeKind:"producer",completeWhenDepsComplete:!1})}function no(e,t){let{mapRow:n=c=>c,...a}=t??{};return W(c=>{let r=!0;return e.execute().then(o=>{r&&(c.emit(o.map(n)),c.down([[C]]))}).catch(o=>{if(r)try{c.down([[E,o instanceof Error?o:new Error(String(o))]])}catch{}}),()=>{r=!1}},{...a,describeKind:"producer",completeWhenDepsComplete:!1})}function lr(){let e=new Map,t=null,n=null;function a(r){r.prev?r.prev.next=r.next:t=r.next,r.next?r.next.prev=r.prev:n=r.prev,r.prev=null,r.next=null}function c(r){r.next=t,r.prev=null,t&&(t.prev=r),t=r,n===null&&(n=r)}return{insert(r){if(e.has(r)){this.touch(r);return}let o={key:r,prev:null,next:null};e.set(r,o),c(o)},touch(r){let o=e.get(r);o&&(a(o),c(o))},delete(r){let o=e.get(r);o&&(a(o),e.delete(r))},evict(r){let o=[];for(let s=0;s<r&&n!==null;s++){let d=n;o.push(d.key),a(d),e.delete(d.key)}return o},size(){return e.size}}}function fr(e){return e!=null&&typeof e.then=="function"}function ue(e){fr(e)&&e.catch(()=>{})}function oo(e,t){let n=new Map,a=t?.maxSize??0,c=a>0?t?.eviction??lr():null,r=t?.writeThrough??!1;function o(i,p,f){for(let u=0;u<f;u++)try{ue(e[u].save(i,p))}catch{}}function s(i,p,f=0){for(let u=f;u<e.length;u++){let l;try{l=e[u].load(i)}catch{continue}if(fr(l)){let m=u;l.then(h=>{h!=null?(p.down([[x,h]]),o(i,h,m)):s(i,p,m+1)},()=>{s(i,p,m+1)});return}if(l!=null){p.down([[x,l]]),o(i,l,u);return}}}function d(){if(!(!c||a<=0))for(;c.size()>=a;){let i=c.evict(1);if(i.length===0)break;for(let p of i){let f=n.get(p);if(f){let u=f.cache;if(f.status!=="sentinel"&&e.length>0){let l=e.length-1;try{ue(e[l].save(p,u))}catch{}for(let m=0;m<l;m++)try{let h=e[m].clear;h&&ue(h.call(e[m],p))}catch{}}f.down([[q]])}n.delete(p)}}}return{load(i){let p=n.get(i);if(p)return c?.touch(i),p;c&&a>0&&c.size()>=a&&d();let f=B(void 0);return n.set(i,f),c?.insert(i),s(i,f),f},save(i,p){if(r)for(let u of e)try{ue(u.save(i,p))}catch{}else if(e[0])try{ue(e[0].save(i,p))}catch{}let f=n.get(i);if(f)f.down([[x,p]]),c?.touch(i);else{c&&a>0&&c.size()>=a&&d();let u=B(p);n.set(i,u),c?.insert(i)}},invalidate(i){let p=n.get(i);p&&s(i,p)},delete(i){c?.delete(i);let p=n.get(i);p&&p.down([[q]]),n.delete(i);for(let f of e)try{let u=f.clear;u&&ue(u.call(f,i))}catch{}},has(i){return n.has(i)},get size(){return n.size}}}var Ee=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(t){return this._topics.has(t)}topicNames(){return this._topics.values()}createTopic(t){return this._topics.has(t)?!1:(this._topics.add(t),this._version+=1,!0)}removeTopic(t){let n=this._topics.delete(t);return n&&(this._version+=1),n}};function so(e={}){let{backend:t}=e,n=t??new Ee,a=new Map;function c(r){let o=a.get(r);return o===void 0&&(o=re({describeKind:"state"}),a.set(r,o),n.createTopic(r)),o}return{topic(r){return c(r)},publish(r,o){c(r).emit(o)},publishMany(r){j(()=>{for(let[o,s]of r)c(o).emit(s)})},removeTopic(r){let o=a.get(r);return o===void 0?!1:(a.delete(r),n.removeTopic(r),o.down([[q]]),!0)},has(r){return n.hasTopic(r)},get size(){return n.topicCount},topicNames(){return n.topicNames()}}}var io=new Map([[Ce,"INVALIDATE"],[Le,"PAUSE"],[Ae,"RESUME"],[q,"TEARDOWN"],[C,"COMPLETE"],[E,"ERROR"]]),ao=new Map([["INVALIDATE",Ce],["PAUSE",Le],["RESUME",Ae],["TEARDOWN",q],["COMPLETE",C],["ERROR",E]]);function se(e){let t=io.get(e);return t||(Symbol.keyFor(e)??"UNKNOWN")}function de(e){let t=ao.get(e);if(t)return t;if(e&&e!=="UNKNOWN")return Symbol.for(e)}function le(e){return e instanceof Error?{message:e.message,name:e.name,stack:e.stack}:{message:String(e),name:"Error"}}function fe(e){let t=new Error(e.message);return t.name=e.name,e.stack&&(t.stack=e.stack),t}function ie(e){if(typeof MessagePort<"u"&&e instanceof MessagePort)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=a=>t(a.data);return e.addEventListener("message",n),e.start(),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof SharedWorker<"u"&&e instanceof SharedWorker)return ie(e.port);if(typeof Worker<"u"&&e instanceof Worker)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=a=>t(a.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.terminate()}};if(typeof BroadcastChannel<"u"&&e instanceof BroadcastChannel)return{post(t,n){n&&n.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),e.postMessage(t)},listen(t){let n=a=>t(a.data);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},terminate(){e.close()}};if(typeof ServiceWorker<"u"&&e instanceof ServiceWorker)return{post(t,n){e.postMessage(t,n??[])},listen(t){let n=a=>{a.source===e&&t(a.data)};return navigator.serviceWorker.addEventListener("message",n),()=>navigator.serviceWorker.removeEventListener("message",n)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function co(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function pr(e,t){let n=co(e)?e:ie(e),a=t.name??"workerBridge",c=Object.entries(t.expose??{}),r=t.import??[],o=t.transfer??{},s=B("connecting",{name:`${a}::meta::status`}),d=B(null,{name:`${a}::meta::error`}),i=new Map,p=new Map;for(let T of r){let y=B(void 0,{name:`${a}::${T}`});i.set(T,y)}let f;if(c.length>0){let T=c.map(([,v])=>v),y=re(T,(v,w)=>{let N={};for(let O=0;O<c.length;O++){let[H]=c[O],z=v[O];z!=null&&z.length>0&&(N[H]=z.at(-1))}Object.keys(N).length!==0&&w.emit(N)},{name:`${a}::aggregated`});f=he([y],v=>{let w=v[0];if(w==null||Object.keys(w).length===0)return;let N=[];for(let z of Object.keys(w)){let J=o[z];J&&N.push(...J(w[z]))}let O;for(let[z,J]of c)z in w&&J.v!=null&&(O==null&&(O={}),O[z]=J.v.version);let H={t:"b",u:w,...O?{v:O}:{}};try{n.post(H,N.length>0?N:void 0)}catch(z){d.down([[x,z instanceof Error?z:new Error(String(z))]])}}).subscribe(()=>{})}let u=!1,l=n.listen(T=>{if(u)return;let y=T;switch(y.t){case"r":{j(()=>{for(let[v,w]of Object.entries(y.stores)){let N=i.get(v);N&&N.down([[x,w]])}}),s.down([[x,"connected"]]);let k={};for(let[v,w]of c)k[v]=w.cache;n.post({t:"i",stores:k});break}case"v":{let k=i.get(y.s);k&&k.down([[x,y.d]]);break}case"b":{j(()=>{for(let[k,v]of Object.entries(y.u)){let w=y.v?.[k];if(w!=null){let O=p.get(k);if(O!=null&&w<=O)continue;p.set(k,w)}let N=i.get(k);N&&N.down([[x,v]])}});break}case"e":{let k=i.get(y.s);k&&k.down([[E,fe(y.err)]]);break}case"s":{let k=de(y.sig);if(!k)break;let v=y.s==="*"?[...i.values()]:i.has(y.s)?[i.get(y.s)]:[];for(let w of v)w.down(y.d===void 0?[[k]]:[[k,y.d]]);break}}}),m=[];for(let[T,y]of c){let k=y.subscribe((v=>{if(!u)for(let w of v){let N=w[0];N!==x&&(G.isLocalOnly(N)||(N===E?n.post({t:"e",s:T,err:le(w[1])}):n.post({t:"s",s:T,sig:se(N),d:w.length>1?w[1]:void 0})))}}));m.push(k)}let h;if(t.timeoutMs!=null&&t.timeoutMs>0){let T=oe(t.timeoutMs),y=Ie(s,v=>v==="connected");h=Fe(We(xe(T,()=>"timeout"),xe(y,()=>"ready"))).subscribe(v=>{for(let w of v)w[0]===x&&w[1]==="timeout"&&(d.down([[x,new Error("Worker bridge handshake timeout")]]),b())})}function b(){if(!u){u=!0,h?.(),n.post({t:"s",s:"*",sig:se(q)}),f&&f();for(let T of m)T();m.length=0,l(),s.down([[x,"closed"]]),p.clear(),i.clear()}}let g={meta:{status:s,error:d},destroy:b};for(let[T,y]of i)g[T]=y;return g}function uo(e){return typeof e=="object"&&e!==null&&typeof e.post=="function"&&typeof e.listen=="function"}function mr(e,t){let n=uo(e)?e:ie(e),a=t.import??[],c=t.transfer??{},r=new Map,o=new Map,s={};for(let b of a){let g=B(void 0,{name:`worker::${b}`});r.set(b,g),s[b]=g}let d=t.expose(s),i=Object.entries(d),p,f=!1;if(i.length>0){let b=i.map(([,y])=>y),g=re(b,(y,k)=>{let v={};for(let w=0;w<i.length;w++){let[N]=i[w],O=y[w];O!=null&&O.length>0&&(v[N]=O.at(-1))}Object.keys(v).length!==0&&k.emit(v)},{name:"workerSelf::aggregated"});p=he([g],y=>{if(f)return;let k=y[0];if(k==null||Object.keys(k).length===0)return;let v=[];for(let O of Object.keys(k)){let H=c[O];H&&v.push(...H(k[O]))}let w;for(let[O,H]of i)O in k&&H.v!=null&&(w==null&&(w={}),w[O]=H.v.version);let N={t:"b",u:k,...w?{v:w}:{}};try{n.post(N,v.length>0?v:void 0)}catch{}}).subscribe(()=>{})}let u=[];for(let[b,g]of i){let T=g.subscribe((y=>{if(!f)for(let k of y){let v=k[0];v!==x&&(G.isLocalOnly(v)||(v===E?n.post({t:"e",s:b,err:le(k[1])}):n.post({t:"s",s:b,sig:se(v),d:k.length>1?k[1]:void 0})))}}));u.push(T)}let l=n.listen(b=>{if(f)return;let g=b;switch(g.t){case"i":{j(()=>{for(let[T,y]of Object.entries(g.stores)){let k=r.get(T);k&&k.down([[x,y]])}});break}case"v":{let T=r.get(g.s);T&&T.down([[x,g.d]]);break}case"b":{j(()=>{for(let[T,y]of Object.entries(g.u)){let k=g.v?.[T];if(k!=null){let w=o.get(T);if(w!=null&&k<=w)continue;o.set(T,k)}let v=r.get(T);v&&v.down([[x,y]])}});break}case"e":{let T=r.get(g.s);T&&T.down([[E,fe(g.err)]]);break}case"s":{let T=de(g.sig);if(!T)break;if(T===q&&g.s==="*"){h();return}let y=g.s==="*"?[...r.values()]:r.has(g.s)?[r.get(g.s)]:[];for(let k of y)k.down(g.d===void 0?[[T]]:[[T,g.d]]);break}}}),m={};for(let[b,g]of i)m[b]=g.cache;n.post({t:"r",stores:m});function h(){if(!f){f=!0,p&&p();for(let b of u)b();u.length=0,l(),n.terminate?.(),o.clear(),r.clear()}}return{destroy:h}}export{ae as a,ze as b,U as c,or as d,un as e,sr as f,dn as g,ln as h,fn as i,pn as j,mn as k,gn as l,Tn as m,yn as n,kn as o,bn as p,hn as q,vn as r,wn as s,Sn as t,En as u,Nn as v,cr as w,Rn as x,Mn as y,Pn as z,Cn as A,Ln as B,An as C,Bn as D,In as E,Fn as F,Wn as G,zn as H,Hn as I,Un as J,Kn as K,jn as L,dr as M,Dn as N,qn as O,Vn as P,$n as Q,_n as R,Qn as S,Jn as T,Yn as U,Gn as V,Xn as W,Zn as X,eo as Y,ro as Z,to as _,no as $,lr as aa,oo as ba,Ee as ca,so as da,se as ea,de as fa,le as ga,fe as ha,ie as ia,pr as ja,mr as ka,lo as la};
@@ -0,0 +1 @@
1
+ import{a as O,b as H,c as W,d as j,e as E,f as et}from"./chunk-QWAPKG3O.js";import{a as N}from"./chunk-ETWTCCJI.js";import{j as T}from"./chunk-CKCSDI7T.js";import{D as I,E as y,G as L,o as S}from"./chunk-ZB5EHBIO.js";import{b as tt}from"./chunk-QYADASLV.js";var ot={};tt(ot,{CanvasMeasureAdapter:()=>$,CliMeasureAdapter:()=>D,ImageSizeAdapter:()=>J,NodeCanvasMeasureAdapter:()=>q,PrecomputedAdapter:()=>V,SvgBoundsAdapter:()=>z,analyzeAndMeasure:()=>O,carveTextLineSlots:()=>j,circleIntervalForBand:()=>U,computeBlockFlow:()=>K,computeCharPositions:()=>E,computeFlowLines:()=>Z,computeLineBreaks:()=>H,computeTotalHeight:()=>_,layoutNextLine:()=>W,measureBlock:()=>X,measureBlocks:()=>Y,reactiveBlockLayout:()=>at,reactiveFlowLayout:()=>it,reactiveLayout:()=>et,rectIntervalForBand:()=>Q});function nt(t){return t>=768&&t<=879||t>=1155&&t<=1161||t>=1425&&t<=1469||t>=1552&&t<=1562||t>=1611&&t<=1631||t>=1648&&t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t>=1767&&t<=1768||t>=1770&&t<=1773||t>=1840&&t<=1866||t>=1958&&t<=1968||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2641||t>=2672&&t<=2673||t>=2677&&t===2677||t>=3633&&t===3633||t>=3636&&t<=3642||t>=3655&&t<=3662||t>=3761&&t===3761||t>=3764&&t<=3772||t>=3784&&t<=3790||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65024&&t<=65039||t>=65056&&t<=65071||t===8205?0:t>=4352&&t<=4447||t>=8986&&t<=8987||t>=9001&&t<=9002||t>=9193&&t<=9203||t>=9208&&t<=9210||t>=9725&&t<=9726||t>=9748&&t<=9749||t>=9800&&t<=9811||t===9855||t===9875||t===9889||t>=9898&&t<=9899||t>=9917&&t<=9918||t>=9924&&t<=9925||t===9934||t===9940||t===9962||t>=9970&&t<=9971||t===9973||t===9978||t===9981||t===9986||t===9989||t>=9992&&t<=9997||t===9999||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t>=10548&&t<=10549||t>=11013&&t<=11015||t>=11035&&t<=11036||t===11088||t===11093||t>=11904&&t<=12350||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12784&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=19968&&t<=40959||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65131||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126980&&t===126980||t===127183||t>=127344&&t<=127345||t===127358||t===127359||t===127374||t>=127377&&t<=127386||t>=127456&&t<=127487||t>=127488&&t<=127490||t===127514||t===127535||t>=127538&&t<=127546||t>=127568&&t<=127569||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=129792&&t<=130047||t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}function rt(t){let e=0;for(let n of t)e+=nt(n.codePointAt(0));return e}var D=class{cellPx;constructor(e){this.cellPx=e?.cellPx??8}measureSegment(e,n){return{width:rt(e)*this.cellPx}}},G=class extends Error{name="KeyError"},V=class{metrics;fallback;constructor(e){this.metrics=e.metrics;let n=e.fallback??"per-char";if(n!=="per-char"&&n!=="error")throw new Error(`fallback must be 'per-char' or 'error', got ${JSON.stringify(e.fallback)}`);this.fallback=n}measureSegment(e,n){let i=this.metrics[n];if(i){let a=i[e];if(a!==void 0)return{width:a}}if(this.fallback==="error")throw new G(`PrecomputedAdapter: no metrics for segment ${JSON.stringify(e)} in font ${JSON.stringify(n)}`);let r=0;if(i)for(let a of e){let l=i[a];l!==void 0&&(r+=l)}return{width:r}}},$=class{ctx=null;currentFont="";emojiCorrection;constructor(e){this.emojiCorrection=e?.emojiCorrection??1}getContext(){if(!this.ctx){if(typeof OffscreenCanvas>"u")throw new Error("CanvasMeasureAdapter requires a browser environment with OffscreenCanvas support. Use CliMeasureAdapter or NodeCanvasMeasureAdapter for Node.js.");let n=new OffscreenCanvas(0,0).getContext("2d");if(!n)throw new Error("CanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(e,n){let i=this.getContext();n!==this.currentFont&&(i.font=n,this.currentFont=n);let r=i.measureText(e).width;return this.emojiCorrection!==1&&new RegExp("\\p{Emoji_Presentation}","u").test(e)&&(r*=this.emojiCorrection),{width:r}}clearCache(){this.currentFont=""}},q=class{ctx=null;currentFont="";canvasModule;constructor(e){this.canvasModule=e}getContext(){if(!this.ctx){let n=this.canvasModule.createCanvas(0,0).getContext("2d");if(!n)throw new Error("NodeCanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(e,n){let i=this.getContext();return n!==this.currentFont&&(i.font=n,this.currentFont=n),{width:i.measureText(e).width}}clearCache(){this.currentFont=""}},z=class{measureSvg(e){let n=e.match(/viewBox\s*=\s*["']([^"']+)["']/);if(n){let a=n[1].trim().split(/[\s,]+/);if(a.length>=4){let l=Number.parseFloat(a[2]),o=Number.parseFloat(a[3]);if(Number.isFinite(l)&&Number.isFinite(o)&&l>0&&o>0)return{width:l,height:o};throw new Error("SvgBoundsAdapter: viewBox width/height are missing, non-finite, or not positive")}}let i=e.match(/<svg[^>]*\bwidth\s*=\s*["']?([\d.]+)/),r=e.match(/<svg[^>]*\bheight\s*=\s*["']?([\d.]+)/);if(i&&r){let a=Number.parseFloat(i[1]),l=Number.parseFloat(r[1]);if(Number.isFinite(a)&&Number.isFinite(l)&&a>0&&l>0)return{width:a,height:l};throw new Error("SvgBoundsAdapter: svg width/height attributes are non-finite or not positive")}throw new Error("SvgBoundsAdapter: cannot determine dimensions \u2014 SVG has no viewBox or width/height attributes")}},J=class{sizes;constructor(e){this.sizes=new Map(Object.entries(e))}measureImage(e){let n=this.sizes.get(e);if(!n)throw new Error(`ImageSizeAdapter: no dimensions registered for ${JSON.stringify(e)}`);return{width:n.width,height:n.height}}};function X(t,e,n,i,r,a,l){switch(t.type){case"text":{let o=t.font??r,x=t.lineHeight??a,h=O(t.text,o,n.text,i),w=H(h,e,n.text,o,i),v=E(w,h,x),B=w.lineCount*x,u=0;for(let d of w.lines)d.width>u&&(u=d.width);return{index:l,type:"text",width:Math.min(u,e),height:B,textSegments:h,textLineBreaks:w,textCharPositions:v}}case"image":{let o,x;if(t.naturalWidth!=null&&t.naturalHeight!=null)o=t.naturalWidth,x=t.naturalHeight;else if(n.image){let h=n.image.measureImage(t.src);o=h.width,x=h.height}else throw new Error(`Image block at index ${l} has no naturalWidth/naturalHeight and no ImageMeasurer adapter`);return o>e&&(x=x*e/o,o=e),{index:l,type:"image",width:o,height:x}}case"svg":{let o,x;if(t.viewBox)o=t.viewBox.width,x=t.viewBox.height;else if(n.svg){let h=n.svg.measureSvg(t.content);o=h.width,x=h.height}else throw new Error(`SVG block at index ${l} has no viewBox and no SvgMeasurer adapter`);return o>e&&(x=x*e/o,o=e),{index:l,type:"svg",width:o,height:x}}}}function Y(t,e,n,i,r,a){return t.map((l,o)=>X(l,e,n,i,r,a,o))}function K(t,e){let n=[],i=0;for(let r=0;r<t.length;r++){let a=t[r];n.push({...a,x:0,y:i}),i+=a.height+(r<t.length-1?e:0)}return n}function _(t){if(t.length===0)return 0;let e=t[t.length-1];return e.y+e.height}function at(t){let{adapters:e,name:n="reactive-block-layout",defaultFont:i="16px sans-serif",defaultLineHeight:r=20}=t,a=new T(n),l=new Map,o=y(t.blocks??[],{name:"blocks"}),x=y(Math.max(0,t.maxWidth??800),{name:"max-width"}),h=y(t.gap??0,{name:"gap"}),w=I([o,x],(u,d,s)=>{let p=u[0]!=null&&u[0].length>0?u[0].at(-1):s.prevData[0],f=u[1]!=null&&u[1].length>0?u[1].at(-1):s.prevData[1],g=S(),m=Y(p,f,e,l,i,r),b=S()-g,c=w.meta;c&&(N(c["block-count"],m.length),N(c["layout-time-ns"],b)),d.emit(m);let C=()=>{l.clear(),e.text.clearCache?.()};return{deactivate:C,invalidate:C}},{name:"measured-blocks",describeKind:"derived",meta:{"block-count":0,"layout-time-ns":0},equals:(u,d)=>{let s=u,p=d;if(s==null||p==null)return s===p;if(s.length!==p.length)return!1;for(let f=0;f<s.length;f++){let g=s[f],m=p[f];if(g.type!==m.type||g.width!==m.width||g.height!==m.height||g.index!==m.index)return!1}return!0}}),v=L([w,h],([u,d])=>K(u,d),{name:"block-flow",equals:(u,d)=>{let s=u,p=d;if(s==null||p==null)return s===p;if(s.length!==p.length)return!1;for(let f=0;f<s.length;f++){let g=s[f],m=p[f];if(g.x!==m.x||g.y!==m.y||g.width!==m.width||g.height!==m.height)return!1}return!0}}),B=L([v],([u])=>_(u),{name:"total-height"});return a.add(o,{name:"blocks"}),a.add(x,{name:"max-width"}),a.add(h,{name:"gap"}),a.add(w,{name:"measured-blocks"}),a.add(v,{name:"block-flow"}),a.add(B,{name:"total-height"}),{graph:a,setBlocks:u=>a.set("blocks",u),setMaxWidth:u=>a.set("max-width",Math.max(0,u)),setGap:u=>a.set("gap",u),measuredBlocks:w,blockFlow:v,totalHeight:B}}function U(t,e,n){let i=t.hPad??0,r=t.vPad??0,a=e-r,l=n+r;if(a>=t.cy+t.r||l<=t.cy-t.r)return null;let o=t.cy>=a&&t.cy<=l?0:t.cy<a?a-t.cy:t.cy-l;if(o>=t.r)return null;let x=Math.sqrt(t.r*t.r-o*o);return{left:t.cx-x-i,right:t.cx+x+i}}function Q(t,e,n){let i=t.hPad??0,r=t.vPad??0;return n<=t.y-r||e>=t.y+t.h+r?null:{left:t.x-i,right:t.x+t.w+i}}function st(t,e,n){return t.kind==="circle"?U(t,e,n):Q(t,e,n)}function Z(t,e,n,i,r,a,l){let o=l?.paragraphSpacing??r,x=[],h={segmentIndex:0,graphemeIndex:0};if(t.length===0||n.count<=0||r<=0)return{lines:x,cursor:h};let w=e.paddingX??0,v=e.paddingY??0,B=Math.max(0,e.width-w*2),u=Math.max(0,e.height-v*2),d=n.gap*Math.max(0,n.count-1),s=Math.max(0,(B-d)/n.count);if(s<=0)return{lines:x,cursor:h};t:for(let p=0;p<n.count;p++){let f=w+p*(s+n.gap),g=f+s,m=v;for(;m+r<=v+u;){let b=m+r,c=[];for(let k=0;k<i.length;k++){let M=st(i[k],m,b);M!==null&&c.push(M)}let C=j({left:f,right:g},c,a);if(C.length===0){m+=r;continue}let F=!1;for(let k=0;k<C.length;k++){let M=C[k],R=M.right-M.left,P=W(t,h,R);if(P===null)return{lines:x,cursor:h};if(P.text.length===0&&P.width===0){h=P.end,F=!0;break}x.push({x:M.left,y:m,width:P.width,slotWidth:R,text:P.text,columnIndex:p,flushToRight:M.right<g-.5}),h=P.end}if(F){m+=o;continue}if(m+=r,h.segmentIndex>=t.length)break t}if(h.segmentIndex>=t.length)break}return{lines:x,cursor:h}}function it(t){let{adapter:e,name:n="reactive-flow-layout",minSlotWidth:i=20}=t,r=new T(n),a=new Map,l=y(t.text??"",{name:"text"}),o=y(t.font??"16px sans-serif",{name:"font"}),x=y(t.lineHeight??20,{name:"line-height"}),h=y(t.container??{width:800,height:600,paddingX:0,paddingY:0},{name:"container"}),w=y(t.columns??{count:1,gap:0},{name:"columns"}),v=y(t.obstacles??[],{name:"obstacles"}),B=y(t.paragraphSpacing??null,{name:"paragraph-spacing"}),u=I([l,o],(s,p,f)=>{let g=s[0],m=g!=null&&g.length>0?g.at(-1):f.prevData[0],b=s[1],c=b!=null&&b.length>0?b.at(-1):f.prevData[1],C=O(m,c,e,a);p.emit(C);let F=()=>{a.clear(),e.clearCache?.()};return{deactivate:F,invalidate:F}},{name:"segments",describeKind:"derived"}),d=L([u,h,w,v,x,B],([s,p,f,g,m,b])=>{let c=s,C=S(),F=b??m,{lines:k,cursor:M}=Z(c,p,f,g,m,i,{paragraphSpacing:F}),R=S()-C,P=Math.max(0,c.length-M.segmentIndex),A=d.meta;return A&&(N(A["line-count"],k.length),N(A["layout-time-ns"],R),N(A["overflow-segments"],P)),k},{name:"flow-lines",meta:{"line-count":0,"layout-time-ns":0,"overflow-segments":0},equals:(s,p)=>{let f=s,g=p;if(f.length!==g.length)return!1;for(let m=0;m<f.length;m++){let b=f[m],c=g[m];if(b.x!==c.x||b.y!==c.y||b.width!==c.width||b.slotWidth!==c.slotWidth||b.text!==c.text||b.columnIndex!==c.columnIndex||b.flushToRight!==c.flushToRight)return!1}return!0}});return r.add(l,{name:"text"}),r.add(o,{name:"font"}),r.add(x,{name:"line-height"}),r.add(h,{name:"container"}),r.add(w,{name:"columns"}),r.add(v,{name:"obstacles"}),r.add(B,{name:"paragraph-spacing"}),r.add(u,{name:"segments"}),r.add(d,{name:"flow-lines"}),{graph:r,setText:s=>r.set("text",s),setFont:s=>r.set("font",s),setLineHeight:s=>r.set("line-height",s),setContainer:s=>r.set("container",s),setColumns:s=>r.set("columns",s),setObstacles:s=>r.set("obstacles",s),setParagraphSpacing:s=>r.set("paragraph-spacing",s),segments:u,flowLines:d}}export{D as a,V as b,$ as c,q as d,z as e,J as f,X as g,Y as h,K as i,_ as j,at as k,U as l,Q as m,Z as n,it as o,ot as p};
@@ -0,0 +1 @@
1
+ import{b as l,c as p,d as R}from"./chunk-CK2E7BTU.js";import{b as K}from"./chunk-QYADASLV.js";var x={};K(x,{useStore:()=>g,useSubscribe:()=>h,useSubscribeRecord:()=>w});import{createSignal as y,getOwner as T,onCleanup as S}from"solid-js";function h(e){let[c,r]=y(e.cache,{equals:!1}),n=e.subscribe(()=>{r(()=>e.cache)});return T()?S(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),c}function g(e){return[h(e),n=>{e.down([[p],[l,n]])}]}function w(e,c){let[r,n]=y({},{equals:!1}),i=[],d=()=>{for(let s of i)s();i=[]},f=()=>{let s={};for(let o of e.cache??[]){let t=c(o),u={};for(let a of Object.keys(t))u[a]=t[a].cache;s[o]=u}return s},b=s=>{d();for(let o of s){let t=c(o);for(let u of Object.keys(t)){let a=t[u].subscribe(()=>{n(()=>f())});i.push(a)}}n(()=>f())},v=e.subscribe(s=>{s.some(o=>o[0]===l||o[0]===R)&&b(e.cache??[])});return b(e.cache??[]),T()?S(()=>{v(),d()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),r}export{h as a,g as b,w as c,x as d};
@@ -0,0 +1 @@
1
+ import{b as l,c as y,d as S}from"./chunk-CK2E7BTU.js";import{b as x}from"./chunk-QYADASLV.js";var A={};x(A,{useStore:()=>E,useSubscribe:()=>T,useSubscribeRecord:()=>j});import{useCallback as K,useMemo as g,useRef as v,useSyncExternalStore as h}from"react";function T(e){return h(o=>{let s=!1,t=e.subscribe(()=>{s||o()});return()=>{s=!0,t()}},()=>e.cache,()=>e.cache)}function E(e){let o=T(e),s=K(t=>{e.down([[y],[l,t]])},[e]);return[o,s]}function j(e,o){let s=v(o);s.current=o;let t=g(()=>{let b=()=>{let c={},n=e.cache??[];for(let r of n){let u=s.current(r),a={};for(let d of Object.keys(u))a[d]=u[d].cache;c[r]=a}return c},p=b();return{subscribe:c=>{let n=!1,r=[],u=()=>{for(let f of r)f();r=[]},a=f=>{u();for(let R of f){let i=s.current(R);for(let k of Object.keys(i)){let m=i[k].subscribe(()=>{p=b(),n||c()});r.push(m)}}p=b(),n||c()},d=e.subscribe(f=>{let R=f.some(i=>i[0]===l||i[0]===S);!n&&R&&a(e.cache??[])});return a(e.cache??[]),()=>{n=!0,d(),u()}},getSnapshot:()=>p}},[e]);return h(t.subscribe,t.getSnapshot,t.getSnapshot)}export{T as a,E as b,j as c,A as d};
@@ -0,0 +1 @@
1
+ import{C as l,v as o}from"./chunk-ZB5EHBIO.js";function h(t,e){if(e!=null&&e.length>0)return new Set(e);switch(t){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;default:return new Set(["type","deps"])}}function m(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function g(t){let e={};for(let[r,a]of Object.entries(t.meta))try{e[r]=a.cache}catch{}return e}function y(t,e){let r=e==null,a=!r&&e!=null?[...e].filter(n=>n.startsWith("meta.")).map(n=>n.slice(5)):null,d=r||e.has("meta")||a!=null&&a.length>0,c="state",p=[];t instanceof l&&(c=m(t),p=t._deps.map(n=>n.node.name??""));let s={type:c,deps:p};(r||e.has("status"))&&(s.status=t.status);let i=t instanceof l?t._guard:void 0;if(d){let n={...g(t)};if(i!=null&&n.access===void 0&&(n.access=o(i)),a!=null&&a.length>0&&!e.has("meta")){let f={};for(let u of a)u in n&&(f[u]=n[u]);s.meta=f}else s.meta=n}if(t.name!=null&&(s.name=t.name),r||e.has("value")){t.status==="sentinel"&&(s.sentinel=!0);try{s.value=t.cache}catch{}}if((r||e.has("v"))&&t.v!=null){let n={id:t.v.id,version:t.v.version};"cid"in t.v&&(n.cid=t.v.cid,n.prev=t.v.prev),s.v=n}return(r||e.has("guard"))&&i!=null&&(s.guard=o(i)),(r||e.has("lastMutation"))&&t.lastMutation!=null&&(s.lastMutation=t.lastMutation),s}export{h as a,y as b};
@@ -0,0 +1 @@
1
+ import{E as b,m as h}from"./chunk-ZB5EHBIO.js";import{b as p,c as l}from"./chunk-CK2E7BTU.js";var u=class{_version=0;_buf;constructor(e){this._buf=e?[...e]:[]}get version(){return this._version}get size(){return this._buf.length}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._buf.length+e;if(!(n<0||n>=this._buf.length))return this._buf[n]}append(e){this._buf.push(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._buf.length;this._buf.length=n+e.length;for(let i=0;i<e.length;i++)this._buf[n+i]=e[i];this._version+=1}insert(e,n){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insert: index ${e} out of range [0, ${this._buf.length}]`);this._buf.splice(e,0,n),this._version+=1}insertMany(e,n){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insertMany: index ${e} out of range [0, ${this._buf.length}]`);n.length!==0&&(this._buf.splice(e,0,...n),this._version+=1)}pop(e){if(this._buf.length===0)throw new RangeError("pop from empty list");if(!Number.isInteger(e))throw new RangeError(`pop: index ${e} must be an integer`);let n=e>=0?e:this._buf.length+e;if(n<0||n>=this._buf.length)throw new RangeError(`pop: index ${e} out of range`);let[i]=this._buf.splice(n,1);return this._version+=1,i}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function y(d,e={}){let{name:n,versioning:i,backend:f}=e,t=f??new u(d),a=b(t.toArray(),{name:n,describeKind:"state",equals:(r,o)=>r===o,...i!=null?{versioning:i}:{}});function v(){let r=t.toArray();h(()=>{a.down([[l]]),a.down([[p,r]])})}function s(r){let o=t.version;try{return r()}finally{t.version!==o&&v()}}return{items:a,get size(){return t.size},at(r){return t.at(r)},append(r){s(()=>t.append(r))},appendMany(r){s(()=>t.appendMany(r))},insert(r,o){s(()=>t.insert(r,o))},insertMany(r,o){s(()=>t.insertMany(r,o))},pop(r=-1){return s(()=>t.pop(r))},clear(){s(()=>t.clear())},dispose(){}}}export{u as a,y as b};
@@ -0,0 +1 @@
1
+ import{c as q}from"./chunk-ETWTCCJI.js";import{j as g}from"./chunk-CKCSDI7T.js";import{b as v}from"./chunk-VTPVOGHH.js";import{b as T}from"./chunk-OAWLCNJJ.js";import{b as y}from"./chunk-D7A7DBE4.js";import{A as d}from"./chunk-2PMCKKRK.js";import{D as w,G as h}from"./chunk-ZB5EHBIO.js";import{b as N}from"./chunk-QYADASLV.js";var $={};N($,{JobFlowGraph:()=>u,JobQueueGraph:()=>p,jobFlow:()=>k,jobQueue:()=>E});var x=2147483647;function J(s,e){if(!Number.isFinite(s)||!Number.isInteger(s)||s<0)throw new Error(`${e} must be a non-negative integer`);return s}function c(s,e){return q("job_queue",s,e)}var p=class extends g{_pending;_jobs;_seq=0;pending;jobs;depth;constructor(e,t={}){super(e,t.graph),this._pending=v([],{name:"pending"}),this._jobs=T({name:"jobs"}),this.pending=this._pending.items,this.jobs=this._jobs.entries,this.add(this.pending,{name:"pending"}),this.add(this.jobs,{name:"jobs"}),this.depth=h([this.pending],([n])=>n.length,{name:"depth",describeKind:"derived",meta:c("queue_depth"),initial:0}),this.add(this.depth,{name:"depth"}),this.addDisposer(d(this.depth))}enqueue(e,t={}){let n=t.id??`${this.name}-${++this._seq}`;if(this._jobs.get(n)!==void 0)throw new Error(`jobQueue("${this.name}"): duplicate job id "${n}"`);let m={id:n,payload:e,attempts:0,metadata:Object.freeze({...t.metadata??{}}),state:"queued"};return this._jobs.set(n,m),this._pending.append(n),n}claim(e=1){let t=J(e,"job queue claim limit");if(t===0)return[];let n=[];for(;n.length<t&&this.pending.cache.length!==0;){let a=this._pending.pop(0),o=this._jobs.get(a);if(!o||o.state!=="queued")continue;let i={...o,state:"inflight",attempts:o.attempts+1};this._jobs.set(a,i),n.push(i)}return n}ack(e){let t=this._jobs.get(e);return!t||t.state!=="inflight"?!1:(this._jobs.delete(e),!0)}nack(e,t={}){let n=this._jobs.get(e);return!n||n.state!=="inflight"?!1:t.requeue??!0?(this._jobs.set(e,{...n,state:"queued"}),this._pending.append(e),!0):(this._jobs.delete(e),!0)}},u=class extends g{_stageNames;_queues=new Map;_completed;completed;completedCount;constructor(e,t={}){super(e,t.graph);let n=(t.stages??["incoming","processing","done"]).map(o=>o.trim());if(n.length<2)throw new Error(`jobFlow("${e}"): requires at least 2 stages`);if(new Set(n).size!==n.length)throw new Error(`jobFlow("${e}"): stage names must be unique`);this._stageNames=Object.freeze([...n]);for(let o of this._stageNames){let i=E(`${e}-${o}`);this._queues.set(o,i),this.mount(o,i)}this._completed=y([],{name:"completed"}),this.completed=this._completed.entries,this.add(this.completed,{name:"completed"}),this.completedCount=h([this.completed],([o])=>o.length,{name:"completedCount",describeKind:"derived",meta:c("job_flow_completed_count"),initial:0}),this.add(this.completedCount,{name:"completedCount"}),this.addDisposer(d(this.completedCount));let a=Math.max(1,J(t.maxPerPump??x,"job flow maxPerPump"));for(let o=0;o<this._stageNames.length;o+=1){let i=this._stageNames[o],l=this.queue(i),b=o+1<this._stageNames.length?this.queue(this._stageNames[o+1]):null,_=w([l.pending],()=>{let f=0;for(;f<a;){let j=l.claim(1);if(j.length===0)break;let r=j[0];if(!r)break;b?b.enqueue(r.payload,{metadata:{...r.metadata,job_flow_from:i}}):this._completed.append(r),l.ack(r.id),f+=1}},{name:`pump_${i}`,describeKind:"effect",meta:c("job_flow_pump")});this.add(_,{name:`pump_${i}`}),this.addDisposer(d(_))}}stages(){return this._stageNames}queue(e){let t=this._queues.get(e);if(!t)throw new Error(`jobFlow("${this.name}"): unknown stage "${e}"`);return t}enqueue(e,t={}){return this.queue(this._stageNames[0]).enqueue(e,t)}retainedCompleted(){return this.completed.cache}};function E(s,e){return new p(s,e)}function k(s,e){return new u(s,e)}export{p as a,u as b,E as c,k as d,$ as e};
@@ -0,0 +1 @@
1
+ import{b as G,d as F}from"./chunk-ERLIRFPA.js";import{c as E}from"./chunk-ETWTCCJI.js";import{a as A}from"./chunk-LQ3Y5NJS.js";import{j as I}from"./chunk-CKCSDI7T.js";import{b as q}from"./chunk-D7A7DBE4.js";import{A as M}from"./chunk-2PMCKKRK.js";import{E as d,G as o,H as O,m as S}from"./chunk-ZB5EHBIO.js";import{b as V}from"./chunk-QYADASLV.js";var $={};V($,{contentModerationGraph:()=>Q,dataQualityGraph:()=>T,issueTrackerGraph:()=>B,observabilityGraph:()=>D});function s(u,a){return E("domain_template",u,a)}function D(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=[{name:"errors",classify:e=>C(e,"error")},{name:"traces",classify:e=>C(e,"trace")},{name:"metrics",classify:e=>C(e,"metric")}],m=a.branches??h,y=m.map(e=>({name:e.name,classify:e.classify})),c=A("stratify",a.source,y);n.mount("stratify",c);let k=m.map(e=>{try{let i=n.resolve(`stratify::branch/${e.name}`);return o([i],([x])=>x,{initial:null})}catch{return d(null)}}),l=a.correlate??(e=>e),_=o(k,e=>l(e),{meta:s("observability",{stage:"correlate"})});n.add(_,{name:"correlate"});let N=a.sloCheck??(()=>({pass:!0})),w=o([_],e=>e[0],{meta:s("observability",{stage:"slo_value"})}),f=o([w],e=>N(e[0]),{meta:s("observability",{stage:"slo_verified"})});n.add(w,{name:"slo_value"}),n.add(f,{name:"slo_verified"});let v=a.weights??m.map(()=>1),b=k.map(e=>o([e],i=>i[0]!=null?1:0)),p=v.map(e=>d(e));for(let e=0;e<b.length;e++)n.add(b[e],{name:`__signal_${e}`}),n.add(p[e],{name:`__weight_${e}`});let t=F(b,p);n.add(t,{name:"alerts"});let g=o([t,f],e=>({scored:e[0],slo:e[1]}),{meta:s("observability",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("observability",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([f],e=>{let i=e[0];return i&&i.pass===!1?i:null},{meta:s("observability",{stage:"feedback_condition"})});return n.add(r,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??5}),n}function B(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=0,m=e=>({id:`issue-${++h}`,title:String(e),severity:1,source:"unknown",raw:e}),y=a.extract??m,c=o([a.source],e=>y(e[0]),{meta:s("issue_tracker",{stage:"extract"})});n.add(c,{name:"extract"});let k=a.verify??(()=>({valid:!0})),l=o([c],e=>{let i=e[0];return{issue:i,verification:k(i)}},{meta:s("issue_tracker",{stage:"verify"})});n.add(l,{name:"verify"});let _=d([],{meta:s("issue_tracker",{stage:"known_patterns"})});n.add(_,{name:"known_patterns"});let N=a.detectRegression??(()=>({regression:!1})),w=o([c,_],e=>{let i=e[0],x=e[1];return{issue:i,regression:N(i,x)}},{meta:s("issue_tracker",{stage:"regression"})});n.add(w,{name:"regression"});let f=o([c],e=>e[0]?.severity??0),v=o([w],e=>e[0]?.regression?2:0);n.add(f,{name:"__severity_signal"}),n.add(v,{name:"__regression_signal"});let b=d(1),p=d(1.5);n.add(b,{name:"__severity_weight"}),n.add(p,{name:"__regression_weight"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([l,w,t],e=>({verified:e[0],regression:e[1],priority:e[2]}),{meta:s("issue_tracker",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("issue_tracker",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([l],e=>{let i=e[0];if(i){let x=i.verification;if(x&&x.valid===!1)return i}return null},{meta:s("issue_tracker",{stage:"feedback_condition"})});return n.add(r,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??3}),n}function Q(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=r=>({label:"review",confidence:.5,original:r}),m=a.classify??h,y=o([a.source],r=>m(r[0]),{meta:s("content_moderation",{stage:"classify"})});n.add(y,{name:"classify"});let c=A("stratify",y,[{name:"safe",classify:r=>r.label==="safe"},{name:"review",classify:r=>r.label==="review"},{name:"block",classify:r=>r.label==="block"}]);n.mount("stratify",c);let k=q([],{name:"review_queue",maxSize:a.maxQueueSize});n.add(k.entries,{name:"review_queue"});let l;try{l=n.resolve("stratify::branch/review")}catch{l=d(null),n.add(l,{name:"__review_fallback"})}let _=O([l],r=>{let e=r[0];e&&k.append(e)});n.add(_,{name:"__review_accumulator"}),n.addDisposer(M(_));let N=d({},{meta:s("content_moderation",{stage:"policy",access:"both",description:"Moderation policy rules \u2014 updated via feedback"})});n.add(N,{name:"policy"});let w=a.weights??[.1,1,2],f=o([y],r=>r[0]?.confidence??0),v=o([y],r=>{let e=r[0];return e?e.label==="block"?w[2]:e.label==="review"?w[1]:w[0]:0});n.add(f,{name:"__confidence_signal"}),n.add(v,{name:"__severity_signal"});let b=d(1),p=d(1);n.add(b,{name:"__w_confidence"}),n.add(p,{name:"__w_severity"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([y,t],r=>({classification:r[0],priority:r[1]}),{meta:s("content_moderation",{stage:"output"})});n.add(g,{name:"output"});let R=o([k.entries,N],r=>{let e=r[0];if(e&&e.length>0){let i=e[e.length-1];if(i&&i.falsePositive)return i}return null},{meta:s("content_moderation",{stage:"feedback_condition"})});return n.add(R,{name:"feedback_condition"}),G(n,"feedback_condition","policy",{maxIterations:a.maxFeedbackIterations??5}),n}function T(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=a.validate??(t=>({valid:!0,errors:[],record:t})),m=o([a.source],t=>t[0]!=null?h(t[0]):void 0,{meta:s("data_quality",{stage:"validate"})});n.add(m,{name:"validate"});let y=a.detectAnomaly??(t=>({anomaly:!1,score:0,record:t})),c=o([a.source],t=>t[0]!=null?y(t[0]):void 0,{meta:s("data_quality",{stage:"anomaly"})});n.add(c,{name:"anomaly"});let k=d(null,{meta:s("data_quality",{stage:"baseline",description:"Rolling baseline for drift detection"})});n.add(k,{name:"baseline"});let l=O([m],t=>{let g=t[0];g?.valid&&S(()=>{k.emit(g.record)})});n.add(l,{name:"__baseline_updater"}),M(l);let _=a.detectDrift??(()=>({drift:!1})),N=o([a.source,k],t=>_(t[0],t[1]),{meta:s("data_quality",{stage:"drift"})});n.add(N,{name:"drift"});let w=a.suggest??(()=>null),f=o([m,c],t=>w({validation:t[0],anomaly:t[1]}),{meta:s("data_quality",{stage:"remediate"})});n.add(f,{name:"remediate"});let v=o([m,c,N,f],t=>({validation:t[0],anomaly:t[1],drift:t[2],remediation:t[3]}),{meta:s("data_quality",{stage:"output"})});n.add(v,{name:"output"});let b=d([],{meta:s("data_quality",{stage:"validation_rules"})});n.add(b,{name:"validation_rules"});let p=o([c],t=>{let g=t[0];return g?.anomaly?g:null},{meta:s("data_quality",{stage:"feedback_condition"})});return n.add(p,{name:"feedback_condition"}),G(n,"feedback_condition","validation_rules",{maxIterations:a.maxFeedbackIterations??3}),n}function C(u,a){if(u==null||typeof u!="object")return!1;let n=u;return n.type===a||n.kind===a}export{D as a,B as b,Q as c,T as d,$ as e};
@@ -0,0 +1 @@
1
+ import{a as $}from"./chunk-DBGGMN3D.js";import{c as O}from"./chunk-ETWTCCJI.js";import{a as C}from"./chunk-2FOAM3OR.js";import{j as A}from"./chunk-CKCSDI7T.js";import{b as x}from"./chunk-D7A7DBE4.js";import{A as R}from"./chunk-2PMCKKRK.js";import{C as T,E as N,G as E,o as b,p as w,u as P,w as S}from"./chunk-ZB5EHBIO.js";import{b as v}from"./chunk-CK2E7BTU.js";import{b as M}from"./chunk-QYADASLV.js";var J={};M(J,{AuditTrailGraph:()=>k,PolicyEnforcerGraph:()=>G,auditTrail:()=>z,complianceSnapshot:()=>F,policyEnforcer:()=>K,reactiveExplainPath:()=>q});function V(i,t){return O("audit",i,t)}var L=new Set(["data","error","complete","teardown"]),k=class extends A{entries;count;_log;_target;constructor(t,n){super(n.name??`${t.name}_audit`,n.graph),this._target=t,this._log=x([],{name:"entries",...n.maxSize!=null?{maxSize:n.maxSize}:{}}),this.entries=this._log.entries,this.add(this.entries,{name:"entries"}),this.count=E([this.entries],([c])=>c.length,{name:"count",describeKind:"derived",meta:V("count")}),this.add(this.count,{name:"count"}),this.addDisposer(R(this.count));let o=n.includeTypes!=null?new Set(n.includeTypes):L,u=n.filter,a=0,h=t.observe({timeline:!0,structured:!0}),m=h.onEvent(c=>{if(c.type==="derived")return;let e=c.type;if(!o.has(e))return;let d=c.path??"",r={seq:a++,timestamp_ns:c.timestamp_ns??b(),wall_clock_ns:w(),path:d,type:e},f=(d?D(t,d):void 0)?.lastMutation;f!=null&&(r.actor=f.actor),e==="data"&&(r.value=c.data),e==="error"&&(r.error=c.data);let l=d?U(t,d):void 0;l!=null&&(r.annotation=l),!(u!=null&&!u(r))&&this._log.append(r)});this.addDisposer(()=>{m(),h.dispose()}),this.addDisposer(()=>this._log.disposeAllViews())}all(){return this.entries.cache??[]}byNode(t){return this.all().filter(n=>n.path===t)}byActor(t){return this.all().filter(n=>n.actor?.id===t)}byActorType(t){return this.all().filter(n=>n.actor?.type===t)}byTimeRange(t,n){return this.all().filter(o=>!(o.timestamp_ns<t||n!=null&&o.timestamp_ns>=n))}get target(){return this._target}};function z(i,t={}){return new k(i,t)}var G=class extends A{policies;violations;violationCount;_target;_mode;_currentGuard;constructor(t,n,o){super(o.name??`${t.name}_policy`,o.graph),this._target=t,this._mode=o.mode??"audit";let u=I(n)?n:N(n,{name:"policies"});this.policies=u,this.add(this.policies,{name:"policies"}),this.violations=new $("violations",{retainedLimit:o.violationsLimit??1e3}),this.mount("violations",this.violations),this.violationCount=E([this.violations.events],([e])=>e.length,{name:"violationCount",describeKind:"derived",meta:V("policy_violation_count")}),this.add(this.violationCount,{name:"violationCount"}),this.addDisposer(R(this.violationCount));let h=u.cache??[];this._currentGuard=P(h);let m=u.subscribe(e=>{for(let d of e)d[0]===v&&(h=d[1]??[],this._currentGuard=P(h))});this.addDisposer(m);let c=o.paths!=null?[...o.paths]:j(t);if(this._mode==="enforce"){let e=new Map,d=r=>{if(e.has(r))return;let s=D(t,r);if(!(s instanceof T))return;let f=(l,p)=>{let y=this._currentGuard(l,p);return y||this._publishViolation(l,p,r,"blocked"),y};e.set(r,s._pushGuard(f))};for(let r of c)d(r);if(o.paths==null){let r=C(t,(s,f,l)=>{if(s.kind==="added")if(s.nodeKind==="node")d(`${l}${s.name}`);else{let p=f._mounts.get(s.name);if(!(p instanceof A))return;let y=`${l}${s.name}::`,_=j(p);for(let g of _)d(g===""?`${l}${s.name}`:`${y}${g}`)}else if(s.kind==="removed")if(s.nodeKind==="node"){let p=`${l}${s.name}`,y=e.get(p);y!=null&&(y(),e.delete(p))}else{let p=`${l}${s.name}`,y=`${p}::`;for(let[_,g]of e)(_===p||_.startsWith(y))&&(g(),e.delete(_))}});this.addDisposer(r)}else{let r=t.topology.subscribe(s=>{for(let f of s){if(f[0]!==v)continue;let l=f[1];if(l.kind!=="removed"||l.nodeKind!=="node")continue;let p=e.get(l.name);p!=null&&(p(),e.delete(l.name))}});this.addDisposer(r)}this.addDisposer(()=>{for(let r of e.values())r();e.clear()})}else{let e=t.observe({timeline:!0,structured:!0}),d=e.onEvent(r=>{if(r.type!=="data"&&r.type!=="error")return;let s=r.path??"";if(!s||o.paths!=null&&!o.paths.includes(s))return;let f=r.actor??D(t,s)?.lastMutation?.actor;if(f==null)return;let l="write";this._currentGuard(f,l)||this._publishViolation(f,l,s,"observed")});this.addDisposer(()=>{d(),e.dispose()})}}_publishViolation(t,n,o,u){this.violations.publish({timestamp_ns:b(),wall_clock_ns:w(),path:o,actor:t,action:n,mode:this._mode,result:u})}all(){return this.violations.retained()}get mode(){return this._mode}get target(){return this._target}};function K(i,t,n={}){return new G(i,t,n)}function q(i,t,n,o){return i.explain(t,n,{reactive:!0,...o})}function F(i,t={}){let n={format_version:1,timestamp_ns:b(),wall_clock_ns:w(),graph:i.snapshot()};if(t.actor!=null&&(n.actor=t.actor),t.audit!=null){let u=[...t.audit.all()];n.audit={count:u.length,entries:u}}if(t.policies!=null){let u=t.policies.policies.cache??[];n.policies={mode:t.policies.mode,rules:u,violations:[...t.policies.all()]}}let o=B(n);return{...n,fingerprint:o}}function I(i){return typeof i=="object"&&i!==null&&"subscribe"in i}function D(i,t){try{return i.node(t)}catch{return}}function U(i,t){try{return i.annotation(t)}catch{return}}function j(i){let t=i.describe({detail:"minimal"});return Object.keys(t.nodes)}function B(i){return S(JSON.stringify(H(i)))}function H(i){let t=new Set,n=o=>{if(o===void 0)return{__undefined:!0};if(o===null)return null;let u=typeof o;if(u==="bigint")return{__bigint:o.toString()};if(u!=="object")return o;let a=o;if(t.has(a))return{__circular:!0};t.add(a);try{if(Array.isArray(a))return a.map(n);if(a instanceof Date)return{__date:a.toISOString()};if(a instanceof RegExp)return{__regexp:{source:a.source,flags:a.flags}};if(a instanceof Map)return{__map:[...a.entries()].map(([c,e])=>[n(c),n(e)])};if(a instanceof Set)return{__set:[...a].map(n)};if(ArrayBuffer.isView(a)){let m=a,c=new Array(m.length);for(let e=0;e<m.length;e++)c[e]=m[e]??0;return{__typed_array:{ctor:a.constructor.name,data:c}}}let h={};for(let m of Object.keys(a).sort())h[m]=n(a[m]);return h}finally{t.delete(a)}};return n(i)}export{k as a,z as b,G as c,K as d,q as e,F as f,J as g};
@@ -0,0 +1 @@
1
+ import{a as P}from"./chunk-4VVTGLXJ.js";import{m as y}from"./chunk-2PMCKKRK.js";import{D as N,F as w,G as W,o as k}from"./chunk-ZB5EHBIO.js";import{a as C,b as p,c as A,d as m,i as a,j as b}from"./chunk-CK2E7BTU.js";function c(d){return{describeKind:"derived",...d}}function H(d,i,u){return N([d],(t,e)=>{let n=t[0];if(n==null||n.length===0){e.down([[m]]);return}for(let o of n)e.emit(i(o))},c(u))}function B(d,i,u){return N([d],(t,e)=>{let n=t[0];if(n==null||n.length===0){e.down([[m]]);return}let o=!1;for(let r of n)i(r)&&(e.emit(r),o=!0);o||e.down([[m]])},c(u))}function J(d,i,u,t){return N([d],(e,n,o)=>{"acc"in o.store||(o.store.acc=u);let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let s of r)o.store.acc=i(o.store.acc,s),n.emit(o.store.acc)},{...c(t),initial:u,resetOnTeardown:!0})}function Q(d,i,u,t){return N([d],(e,n,o)=>{if("acc"in o.store||(o.store.acc=u),o.terminalDeps[0]===!0){n.emit(o.store.acc),n.down([[a]]);return}let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let s of r)o.store.acc=i(o.store.acc,s)},{...c(t),completeWhenDepsComplete:!1})}function M(d,i,u){return i<=0?N([d],(t,e,n)=>{n.store.completed||(n.store.completed=!0,e.down([[a]]))},{...c(u),completeWhenDepsComplete:!1}):N([d],(t,e,n)=>{if("taken"in n.store||(n.store.taken=0),n.store.done){e.down([[m]]);return}if(n.terminalDeps[0]===!0){n.store.done=!0,e.down([[a]]);return}let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}for(let r of o)if(n.store.taken++,e.emit(r),n.store.taken>=i){n.store.done=!0,e.down([[a]]);return}},{...c(u),completeWhenDepsComplete:!1})}function S(d,i,u){return N([d],(t,e,n)=>{"skipped"in n.store||(n.store.skipped=0);let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}let r=!1;for(let s of o)n.store.skipped++,n.store.skipped<=i||(e.emit(s),r=!0);r||e.down([[m]])},c(u))}function X(d,i,u){return N([d],(t,e,n)=>{if(n.store.done){e.down([[m]]);return}let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}for(let r of o){if(!i(r)){n.store.done=!0,e.down([[a]]);return}e.emit(r)}},{...c(u),completeWhenDepsComplete:!1})}function Z(d,i,u){let t=u?.predicate??(o=>o[0]===p),{predicate:e,...n}=u??{};return w(o=>{let r=!1,s=d.subscribe(l=>{if(!r)for(let T of l){if(r)return;T[0]===p?o.emit(T[1]):(T[0]===a||T[0]===b)&&(r=!0,o.down([T]))}}),f=i.subscribe(l=>{if(!r)for(let T of l){if(r)return;if(t(T)){r=!0,o.down([[a]]);return}}});return()=>{s(),f()}},c(n))}function $(d,i){return M(d,1,i)}function ee(d,i){let{defaultValue:u,...t}=i??{},e=i!=null&&Object.hasOwn(i,"defaultValue");return N([d],(n,o,r)=>{if(r.terminalDeps[0]===!0){r.store.has?o.emit(r.store.latest):e&&o.emit(u),o.down([[a]]);return}let s=n[0];if(s==null||s.length===0){o.down([[m]]);return}r.store.latest=s.at(-1),r.store.has=!0},{...c(t),completeWhenDepsComplete:!1})}function ne(d,i,u){return M(B(d,i,u),1,u)}function te(d,i,u){return M(S(d,i,u),1,u)}function oe(d,i,u){if(typeof i=="function")return N([d],(e,n)=>{let o=e[0];if(o==null||o.length===0){n.down([[m]]);return}for(let r of o)i(r),n.emit(r)},c(u));let t=i;return N([d],(e,n,o)=>{if(o.terminalDeps[0]!==void 0){o.terminalDeps[0]===!0?(t.complete?.(),n.down([[a]])):(t.error?.(o.terminalDeps[0]),n.down([[b,o.terminalDeps[0]]]));return}let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let s of r)t.data?.(s),n.emit(s)},{...c(u),completeWhenDepsComplete:!1})}function re(d,i=Object.is,u){return N([d],(t,e,n)=>{let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}let r=!1;for(let s of o)n.store.hasPrev&&i(n.store.prev,s)||(n.store.prev=s,n.store.hasPrev=!0,e.emit(s),r=!0);r||e.down([[m]])},c(u))}function se(d,i){return N([d],(u,t,e)=>{let n=u[0];if(n==null||n.length===0){t.down([[m]]);return}let o=!1;for(let r of n)if(!e.store.hasPrev)e.store.prev=r,e.store.hasPrev=!0;else{let s=[e.store.prev,r];e.store.prev=r,t.emit(s),o=!0}o||t.down([[m]])},c(i))}function V(...d){let i=[...d];return W(i,u=>u,{...c(),equals:(u,t)=>{if(u.length!==t.length)return!1;for(let e=0;e<u.length;e++)if(!Object.is(u[e],t[e]))return!1;return!0}})}function ie(d,i,u){return N([d,i],(t,e,n)=>{let o=t[0],r=t[1],s=r!=null&&r.length>0?r.at(-1):n.prevData[1];if(o!=null&&o.length>0){if(!(r!=null&&r.length>0)&&n.prevData[1]===void 0){e.down([[m]]);return}for(let f of o)e.emit([f,s])}else e.down([[m]])},c(u))}function ue(...d){return d.length===0?w(i=>{i.down([[a]])},c()):w(i=>{let u=d.length,t=0,e=[];for(let n of d){let o=n.subscribe(r=>{for(let s of r)s[0]===p?i.emit(s[1]):s[0]===a?(t+=1,t>=u&&i.down([[a]])):s[0]===b&&i.down([s])});e.push(o)}return()=>{for(let n of e)n()}},c())}function fe(...d){let i=d.length;return i===0?w(u=>{u.emit([]),u.down([[a]])},c()):w(u=>{let t=Array.from({length:i},()=>[]),e=i;function n(){for(;t.every(r=>r.length>0);){let r=t.map(s=>s.shift());u.emit(r)}}let o=[];for(let r=0;r<i;r++){let s=r,f=d[r].subscribe(l=>{for(let T of l)T[0]===p?(t[s].push(T[1]),n()):T[0]===a?(e-=1,(e===0||t[s].length===0)&&u.down([[a]])):T[0]===b&&u.down([T])});o.push(f)}return()=>{for(let r of o)r()}},c())}function de(d,i,u){return w(t=>{let e=0,n=[],o,r;return r=i.subscribe(s=>{for(let f of s)e===0?f[0]===p?n.push(f[1]):f[0]===b&&t.down([f]):f[0]===p?t.emit(f[1]):(f[0]===a||f[0]===b)&&t.down([f])}),o=d.subscribe(s=>{for(let f of s)if(e===0)if(f[0]===p)t.emit(f[1]);else if(f[0]===a){e=1;for(let l of n)t.emit(l);n.length=0}else f[0]===b&&t.down([f])}),()=>{o?.(),r?.()}},c(u))}function le(...d){return d.length===0?w(i=>{i.down([[a]])},c()):d.length===1?N([d[0]],(i,u)=>{let t=i[0];if(t==null||t.length===0){u.down([[m]]);return}for(let e of t)u.emit(e)},c()):w(i=>{let u=null,t=[];for(let e=0;e<d.length;e++){let n=e,o=d[e].subscribe(r=>{for(let s of r){if(u!==null&&n!==u)return;s[0]===p?(u===null&&(u=n),i.emit(s[1])):(s[0]===a||s[0]===b)&&(u===null||n===u)&&i.down([s])}});t.push(o)}return()=>{for(let e of t)e()}},c())}function I(d,i,u){let t,e=!1,n=()=>{e||(e=!0,u())};return t=d.subscribe(o=>{let r=!1,s=!1;for(let f of o)f[0]!==C&&(f[0]===p?i.emit(f[1]):f[0]===a?r=!0:f[0]===b?(s=!0,i.down([f])):(f[0]===A||f[0]===m)&&i.down([f]));s?(t?.(),t=void 0,n()):r&&n()}),()=>{t?.(),t=void 0}}function ae(d,i,u){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,s)=>{if(s.terminalDeps[0]!=null&&s.terminalDeps[0]!==!0){n();return}if(s.terminalDeps[0]===!0){e=!0,t||r.down([[a]]);return}let f=o[0];if(!(f==null||f.length===0))return n(),t=I(y(i(f[f.length-1])),r,()=>{n(),e&&r.down([[a]])}),{deactivate:()=>{n(),e=!1}}},{...c(u),completeWhenDepsComplete:!1})}function ce(d,i,u){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,s)=>{if(s.terminalDeps[0]!=null&&s.terminalDeps[0]!==!0){n();return}if(s.terminalDeps[0]===!0){e=!0,t||r.down([[a]]);return}let f=o[0];if(!(f==null||f.length===0))return t===void 0?t=I(y(i(f[0])),r,()=>{n(),e&&r.down([[a]])}):r.down([[m]]),{deactivate:()=>{n(),e=!1}}},{...c(u),completeWhenDepsComplete:!1})}function Te(d,i,u){let{maxBuffer:t,...e}=u??{},n=[],o,r=!1,s;function f(){o?.(),o=void 0}function l(){if(!s||o!==void 0)return;if(n.length===0){r&&s.down([[a]]);return}let h=n.shift();o=I(y(i(h)),s,()=>{f(),l()})}function T(h){t&&t>0&&n.length>=t&&n.shift(),n.push(h),l()}return N([d],(h,O,E)=>{if(s=O,E.terminalDeps[0]!=null&&E.terminalDeps[0]!==!0){f(),n.length=0;return}if(E.terminalDeps[0]===!0){r=!0,l();return}let x=h[0];if(!(x==null||x.length===0)){for(let v of x)T(v);return{deactivate:()=>{f(),n.length=0,r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}function K(d,i,u){let{concurrent:t,...e}=u??{},n=t!=null&&t>0?t:Number.POSITIVE_INFINITY,o=0,r=!1,s=new Set,f=[],l;function T(){r&&o===0&&f.length===0&&l&&l.down([[a]])}function h(v){if(!l)return;o++;let g;g=I(y(i(v)),l,()=>{g&&s.delete(g),o--,O(),T()}),s.add(g)}function O(){for(;f.length>0&&o<n;)h(f.shift())}function E(v){o<n?h(v):f.push(v)}function x(){for(let v of s)v();s.clear(),o=0,f.length=0}return N([d],(v,g,D)=>{if(l=g,D.terminalDeps[0]!=null&&D.terminalDeps[0]!==!0){x();return}if(D.terminalDeps[0]===!0){r=!0,T();return}let R=v[0];if(!(R==null||R.length===0)){for(let U of R)E(U);return{deactivate:()=>{x(),r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}var pe=K;function me(d,i,u){return w(t=>{let e=new Set;function n(){for(let r of e)clearTimeout(r);e.clear()}let o=d.subscribe(r=>{for(let s of r)if(s[0]===p){let f=setTimeout(()=>{e.delete(f),t.emit(s[1])},i);e.add(f)}else if(s[0]===a){let f=setTimeout(()=>{e.delete(f),t.down([[a]])},i);e.add(f)}else s[0]===b&&(n(),t.down([s]))});return()=>{o(),n()}},c(u))}function q(d,i,u){return w(t=>{let e,n;function o(){e!==void 0&&(clearTimeout(e),e=void 0)}let r=d.subscribe(s=>{for(let f of s)f[0]===p?(o(),n=f[1],e=setTimeout(()=>{e=void 0,t.emit(n)},i)):f[0]===a?(e!==void 0&&(o(),t.emit(n)),t.down([[a]])):f[0]===b&&(o(),t.down([f]))});return()=>{r(),o()}},c(u))}function _(d,i,u){let{leading:t,trailing:e,...n}=u??{},o=t!==!1,r=e===!0,s=i*1e6;return w(f=>{let l,T=-1/0,h,O=!1;function E(){l!==void 0&&(clearTimeout(l),l=void 0)}let x=d.subscribe(v=>{for(let g of v)if(g[0]===p){let D=g[1],R=k();if(o&&R-T>=s)T=R,f.emit(D),E(),r&&(l=setTimeout(()=>{l=void 0,O&&(T=k(),f.emit(h),O=!1)},i));else if(r&&(h=D,O=!0,l===void 0)){let U=(R-T)/1e6;l=setTimeout(()=>{l=void 0,O&&(T=k(),f.emit(h),O=!1)},Math.max(0,i-U))}}else(g[0]===a||g[0]===b)&&(E(),f.down([g]))});return()=>{x(),E()}},c(n))}function be(d,i,u){return w(t=>{let e,n=!1,o=!1,r=d.subscribe(f=>{if(!n)for(let l of f){if(n)return;l[0]===p?e={v:l[1]}:l[0]===b?(n=!0,t.down([l])):l[0]===a&&(o=!0,e=void 0)}}),s=i.subscribe(f=>{if(!n)for(let l of f){if(n)return;l[0]===p?e!==void 0&&!o&&t.emit(e.v):l[0]===b?(n=!0,t.down([l])):l[0]===a&&(n=!0,t.down([[a]]))}});return()=>{r(),s()}},c(u))}function we(d,i,u){return w(t=>{let e,n,o=!1;function r(){e!==void 0&&(clearTimeout(e),e=void 0)}let s=d.subscribe(f=>{for(let l of f)l[0]===p?(n=l[1],o=!0,r(),e=setTimeout(()=>{e=void 0,o&&(o=!1,t.emit(n))},i)):(l[0]===a||l[0]===b)&&(r(),t.down([l]))});return()=>{s(),r()}},c(u))}function Ne(d,i,u){let{with:t,...e}=u??{},n=t??new Error("timeout");return w(o=>{let r;function s(){clearTimeout(r),r=setTimeout(()=>{r=void 0,o.down([[b,n]])},i)}s();let f=d.subscribe(l=>{for(let T of l)T[0]===p?(s(),o.emit(T[1])):(T[0]===a||T[0]===b)&&(clearTimeout(r),o.down([T]))});return()=>{f(),clearTimeout(r)}},c(e))}function he(d,i,u){return w(t=>{let e=[],n=d.subscribe(r=>{for(let s of r)s[0]===p?e.push(s[1]):s[0]===a?(e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):s[0]===b&&t.down([s])}),o=i.subscribe(r=>{for(let s of r)s[0]===p?e.length>0&&(t.emit([...e]),e.length=0):s[0]===a?t.down([[a]]):s[0]===b&&t.down([s])});return()=>{n(),o(),e.length=0}},c(u))}function ve(d,i,u){if(i<=0)throw new RangeError("bufferCount expects count > 0");return w(t=>{let e=[],n=d.subscribe(o=>{for(let r of o)r[0]===p?(e.push(r[1]),e.length>=i&&t.emit(e.splice(0,e.length))):r[0]===a?(e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):r[0]===b&&t.down([r])});return()=>{n(),e.length=0}},c(u))}function ge(d,i,u){if(i<=0)throw new RangeError("windowCount expects count > 0");return w(t=>{let e,n=0;function o(){let s=w(f=>(e=f.down.bind(f),()=>{e=void 0}),c());n=0,t.emit(s)}let r=d.subscribe(s=>{for(let f of s)f[0]===p?(e||o(),e?.([[p,f[1]]]),n+=1,n>=i&&(e?.([[a]]),e=void 0)):f[0]===a?(e?.([[a]]),e=void 0,t.down([[a]])):f[0]===b&&(e?.([f]),e=void 0,t.down([f]))});return()=>{r(),e?.([[a]]),e=void 0}},c(u))}function Oe(d,i,u){return w(t=>{let e=[],n=setInterval(()=>{e.length>0&&(t.emit([...e]),e.length=0)},i),o=d.subscribe(r=>{for(let s of r)s[0]===p?e.push(s[1]):s[0]===a?(clearInterval(n),e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):s[0]===b&&(clearInterval(n),t.down([s]))});return()=>{o(),clearInterval(n),e.length=0}},c(u))}function Ee(d,i,u){return w(t=>{let e;function n(){e?.([[a]]),e=void 0}function o(){let f=w(l=>(e=l.down.bind(l),()=>{e=void 0}),c());t.emit(f)}o();let r=setInterval(()=>{n(),o()},i),s=d.subscribe(f=>{for(let l of f)l[0]===p?e?.([[p,l[1]]]):l[0]===a?(clearInterval(r),n(),t.down([[a]])):l[0]===b&&(clearInterval(r),e?.([l]),n(),t.down([l]))});return()=>{s(),clearInterval(r),n()}},c(u))}function xe(d,i,u){return w(t=>{let e;function n(){e?.([[a]]),e=void 0}function o(){let f=w(l=>(e=l.down.bind(l),()=>{e=void 0}),c());t.emit(f)}let r=d.subscribe(f=>{for(let l of f)l[0]===p?(e||o(),e?.([[p,l[1]]])):l[0]===a?(n(),t.down([[a]])):l[0]===b&&(e?.([l]),e=void 0,t.down([l]))}),s=i.subscribe(f=>{for(let l of f)l[0]===p&&(n(),o())});return()=>{r(),s(),n()}},c(u))}function Re(d,i){return w((u,t)=>{"n"in t.store||(t.store.n=0);let e=setInterval(()=>{u.emit(t.store.n),t.store.n=t.store.n+1},d);return()=>clearInterval(e)},c(i))}function De(d,i,u){if(i<=0)throw new RangeError("repeat expects count > 0");return w(t=>{let e=i,n,o=()=>{n?.(),n=d.subscribe(r=>{let s=!1,f=[];for(let l of r)l[0]===a?s=!0:f.push(l);f.length>0&&t.down(f),s&&(n?.(),n=void 0,e-=1,e>0?o():t.down([[a]]))})};return o(),()=>{n?.()}},c(u))}function ye(d,i){return N([d],(u,t)=>{let e=u[0];if(e==null||e.length===0){t.down([[m]]);return}for(let n of e)t.emit(n)},c(i))}function j(d,i,u){return w(t=>{let e=d.subscribe(n=>{for(let o of n)if(o[0]===p)t.emit(o[1]);else if(o[0]===b)try{t.emit(i(o[1]))}catch(r){t.down([[b,r]])}else o[0]===a&&t.down([[a]])});return()=>{e()}},c(u))}function ke(d,i,u){return N([d,i],(t,e,n)=>{let o=t[1];if(!(o!=null&&o.length>0?o.at(-1):n.prevData[1])){e.down([[m]]);return}let s=t[0];if(s!=null&&s.length>0){for(let f of s)e.emit(f);return}if(o!=null&&o.length>0&&n.prevData[0]!==void 0){e.emit(n.prevData[0]);return}e.down([[m]])},c(u))}var Ie=V,Ue=q,Me=_,Ce=j;export{H as a,B as b,J as c,Q as d,M as e,S as f,X as g,Z as h,$ as i,ee as j,ne as k,te as l,oe as m,re as n,se as o,V as p,ie as q,ue as r,fe as s,de as t,le as u,ae as v,ce as w,Te as x,K as y,pe as z,me as A,q as B,_ as C,be as D,we as E,Ne as F,he as G,ve as H,ge as I,Oe as J,Ee as K,xe as L,Re as M,De as N,ye as O,j as P,ke as Q,Ie as R,Ue as S,Me as T,Ce as U};
@@ -0,0 +1 @@
1
+ import{a as Y,b,c as S,d as v,e as C,f as k,g as L,h as A,i as D,j as _,k as P,l as he,n as se,q as ie,r as fe,s as pe,t as _e,u as re}from"./chunk-CK2E7BTU.js";var Oe={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}};function ze(t){return{name:"dag-cbor",version:1,contentType:"application/dag-cbor",encode:e=>t.encode(e),decode:(e,n)=>t.decode(e)}}function je(t,e){return{name:"dag-cbor-zstd",version:1,contentType:"application/dag-cbor+zstd",encode:n=>e.compressSync(t.encode(n)),decode:(n,s)=>t.decode(e.decompressSync(n))}}var oe=1,ge=4;function qe(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let s=t.version;if(!Number.isInteger(s)||s<0||s>65535)throw new Error(`encodeEnvelope: codec.version ${s} out of u16 range (expected integer 0\u201365535)`);let i=2+n.length+2+e.length;if(i>4294967295)throw new Error(`encodeEnvelope: total envelope size ${i} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let r=new Uint8Array(i),o=0;return r[o++]=oe,r[o++]=n.length,r.set(n,o),o+=n.length,r[o++]=s>>>8&255,r[o++]=s&255,r.set(e,o),r}function Ke(t,e){if(t.length<ge)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${ge})`);let n=0,s=t[n++];if(s!==oe)throw new Error(`decodeEnvelope: unsupported envelope version ${s} (expected ${oe})`);let i=t[n++];if(i===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+i+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+i+2} bytes, have ${t.length})`);let r=new TextDecoder().decode(t.subarray(n,n+i));n+=i;let o=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),d=e.lookupCodec(r);if(d==null)throw new Error(`decodeEnvelope: codec "${r}" not registered (envelope codec_v=${o})`);return{codec:d,codecVersion:o,payload:a}}function ye(t){t.registerCodec(Oe)}function Ye(t){if(t.length===0)throw new Error("WAL is empty \u2014 need at least one full snapshot");let e=t[0];if(e.mode!=="full")throw new Error("WAL must start with a full record carrying a baseline snapshot");let n=JSON.parse(JSON.stringify(e.snapshot)),s=e.seq;for(let i=1;i<t.length;i++){let r=t[i];if(r.seq<=s)throw new Error(`WAL chain broken at index ${i}: seq=${r.seq} must exceed prev seq=${s}`);if(r.mode==="full"){n=JSON.parse(JSON.stringify(r.snapshot)),s=r.seq;continue}let o=r.diff;for(let d of o.nodesRemoved)delete n.nodes[d];let a=o.nodesAddedFull;if(a!=null)for(let[d,l]of Object.entries(a))n.nodes[d]=JSON.parse(JSON.stringify(l));for(let d of o.nodesChanged){let l=n.nodes[d.path];l!=null&&(l[d.field]=d.to)}s=r.seq}return n}var Re={type:"system",id:""};function J(t){if(t==null)return Re;let{type:e,id:n,...s}=t;return{type:e??"system",id:n??"",...s}}var O=0,U=!1,E=[],M=[],R=[],W=[];function me(){return O>0||U}function be(){return O>0}function ve(t){O>0?W.push(t):t()}function Ze(t){O+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(O-=1,O===0)if(e){if(!U){let n=W.splice(0);for(let s of n)try{s()}catch{}E.length=0,M.length=0,R.length=0}}else Fe()}}function Fe(){let t=!U;t&&(U=!0);let e=[],n=0;try{for(;E.length>0||M.length>0||R.length>0||t&&W.length>0;){if(t&&W.length>0){let r=W.splice(0);for(let o of r)try{o()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw E.length=0,M.length=0,R.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let i=(E.length>0?E:M.length>0?M:R).splice(0);for(let r of i)try{r()}catch(o){e.push(o)}}}finally{t&&(U=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function X(t,e,n){if(e.length===0)return;if(e.length===1){let l=n(e[0][0]);if(l<3||!me()){t(e);return}(l>=5?R:l===4?M:E).push(()=>t(e));return}let s=e.length,i=s,r=s,o=s,a=0;for(;a<s&&n(e[a][0])<3;)a++;for(i=a;a<s&&n(e[a][0])===3;)a++;for(r=a;a<s&&n(e[a][0])===4;)a++;o=a;let d=me();if(i>0){let l=e.slice(0,i);t(l)}if(r>i){let l=e.slice(i,r);d?E.push(()=>t(l)):t(l)}if(o>r){let l=e.slice(r,o);d?M.push(()=>t(l)):t(l)}if(s>o){let l=e.slice(o,s);d?R.push(()=>t(l)):t(l)}}function en(){return Math.trunc(performance.now()*1e6)}function we(){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;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=n=>{let s=this._messageTypes.get(n);return s!=null?s.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}};function xe(t){t.registerMessageType(Y,{tier:0,wireCrossing:!1}),t.registerMessageType(S,{tier:1,wireCrossing:!1}),t.registerMessageType(C,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(k,{tier:2,wireCrossing:!1}),t.registerMessageType(L,{tier:2,wireCrossing:!1}),t.registerMessageType(b,{tier:3,wireCrossing:!0}),t.registerMessageType(v,{tier:3,wireCrossing:!0}),t.registerMessageType(D,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(_,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(A,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var F=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};function Te(t){return Array.isArray(t)?[...t]:[t]}function Ge(t,e){return t.has(e)||t.has("*")}function Ie(t){let e=[];return t((i,r)=>{e.push({kind:"allow",actions:new Set(Te(i)),where:r?.where??(()=>!0)})},(i,r)=>{e.push({kind:"deny",actions:new Set(Te(i)),where:r?.where??(()=>!0)})}),(i,r)=>{let o=!1,a=!1;for(let d of e)Ge(d.actions,r)&&d.where(i)&&(d.kind==="deny"?o=!0:a=!0);return o?!1:a}}function rn(t){return Ie((e,n)=>{for(let s of t){let i=s.actorType==null?null:new Set(Array.isArray(s.actorType)?s.actorType:[s.actorType]),r=s.actorId==null?null:new Set(Array.isArray(s.actorId)?s.actorId:[s.actorId]),o=Object.entries(s.claims??{}),a=d=>{if(i!==null&&!i.has(String(d.type))||r!==null&&!r.has(String(d.id??"")))return!1;for(let[l,c]of o)if(d[l]!==c)return!1;return!0};s.effect==="deny"?n(s.action,{where:a}):e(s.action,{where:a})}})}var He=["human","llm","wallet","system"];function on(t){let e=He.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}function ae(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(ae);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=ae(t[n]);return e}return null}var Ve=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]),Le=new TextEncoder;function Pe(t){let e=Le.encode(t),n=e.length,s=n*8,i=n+9+63&-64,r=new Uint8Array(i);r.set(e),r[n]=128;let o=new DataView(r.buffer);o.setUint32(i-4,s>>>0,!1),o.setUint32(i-8,Math.floor(s/4294967296)>>>0,!1);let a=1779033703,d=3144134277,l=1013904242,c=2773480762,u=1359893119,h=2600822924,p=528734635,g=1541459225,N=new Uint32Array(64),m=(x,y)=>x>>>y|x<<32-y;for(let x=0;x<i;x+=64){for(let f=0;f<16;f++)N[f]=o.getUint32(x+f*4,!1);for(let f=16;f<64;f++){let H=N[f-15],V=N[f-2],K=m(H,7)^m(H,18)^H>>>3,te=m(V,17)^m(V,19)^V>>>10;N[f]=N[f-16]+K+N[f-7]+te>>>0}let y=a,G=d,I=l,ee=c,T=u,j=h,q=p,ne=g;for(let f=0;f<64;f++){let H=m(T,6)^m(T,11)^m(T,25),V=T&j^~T&q,K=ne+H+V+Ve[f]+N[f]>>>0,te=m(y,2)^m(y,13)^m(y,22),Ce=y&G^y&I^G&I,De=te+Ce>>>0;ne=q,q=j,j=T,T=ee+K>>>0,ee=I,I=G,G=y,y=K+De>>>0}a=a+y>>>0,d=d+G>>>0,l=l+I>>>0,c=c+ee>>>0,u=u+T>>>0,h=h+j>>>0,p=p+q>>>0,g=g+ne>>>0}let w=x=>x.toString(16).padStart(8,"0");return w(a)+w(d)+w(l)+w(c)+w(u)+w(h)+w(p)+w(g)}function de(t){let e=ae(t??null),n=JSON.stringify(e);return Pe(n).slice(0,16)}function Ue(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function le(t,e,n){let s=n?.id??Ue();if(t===0)return{id:s,version:0};let r=(n?.hash??de)(e);return{id:s,version:0,cid:r,prev:null}}function Ne(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}function dn(t){return"cid"in t}var ke=()=>{},Ae=100;function Ee(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function ce(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Q(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}var We=(t,e,n,s)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},Be=(t,e,n,s)=>{let i=t;if(i._status==="completed"||i._status==="errored")return;let r=i._cached,o=r===void 0?[se]:[se,[b,r]];i._status==="dirty"&&o.push(P),X(e,o,i._config.tierOf)},B=new Z({onMessage:We,onSubscribe:Be});xe(B);ye(B);function mn(t){if(B._isFrozen())throw new Error("configure() called after a node was created \u2014 the default GraphReFlyConfig is frozen. Call configure(...) at application startup, before any node factories run.");t(B)}var $=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,s){this._config=s.config??B,this._config.onMessage,this._optsName=s.name,this._describeKind=s.describeKind,this._equals=s.equals??Object.is,this._resubscribable=s.resubscribable??!1,this._resetOnTeardown=s.resetOnTeardown??!1,this._autoComplete=s.completeWhenDepsComplete??!0,this._autoError=s.errorWhenDepsError??!0,this._pausable=s.pausable??!0,this._guard=s.guard,this._fn=n,this._cached=s.initial!==void 0?s.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=s.versioningHash??this._config.defaultHashFn??de;let i=s.versioning??this._config.defaultVersioning;this._versioningLevel=i,this._versioning=i!=null?le(i,this._cached===void 0?void 0:this._cached,{id:s.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ee);let r={};for(let[a,d]of Object.entries(s.meta??{})){let l={initial:d,name:`${s.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};s.guard!=null&&(l.guard=s.guard),r[a]=new t([],void 0,l)}Object.freeze(r),this.meta=r,this._hasMeta=Object.keys(r).length>0;let o=this;this._actions={emit(a){o._emit([[b,a]])},down(a){o._emit(Q(a))},up(a){o._emitUp(Q(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let s=this._versioningLevel;if(s!=null&&e<=s)return;let i=n?.hash??this._hashFn;i!==this._hashFn&&(this._hashFn=i);let r=this._cached===void 0?void 0:this._cached,o=this._versioning,a=o?.id??n?.id,d=o?.version??0,l=le(e,r,{id:a,hash:i});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 n=J(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let s of this._extraGuards)if(!s(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,s=e?.actor!=null;if(!n&&!s)return;let i=J(e?.actor),r=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(i,r))throw new F({actor:i,action:r,nodeName:this.name});if(this._extraGuards!=null){for(let o of this._extraGuards)if(!o(i,r))throw new F({actor:i,action:r,nodeName:this.name})}this._lastMutation={actor:i,timestamp_ns:we()}}down(e,n){let s=Q(e);s.length!==0&&(this._checkGuard(n),this._emit(s))}emit(e,n){this._checkGuard(n),this._emit([[b,e]])}up(e,n){if(this._deps.length===0)return;let s=Q(e);if(s.length===0)return;this._checkGuard(n);let i=n??{internal:!0};this._validateUpTiers(s);for(let r of this._deps)r.node.up?.(s,i)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let s of e){let i=n(s[0]);if(i===3||i===4)throw new Error(`Node "${this.name}": tier-${i} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let d=J(n);if(!this._guard(d,"observe"))throw new F({actor:d,action:"observe",nodeName:this.name})}let i=this._isTerminal&&this._resubscribable;if(i){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)ce(d)}this._sinkCount+=1;let r;try{r=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:i},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 o=this._isTerminal;if(this._sinkCount===1&&!o)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof r=="function")try{r()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof r=="function"&&r(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let s=0;s<e;s++){let i=s,r=this._deps[s];r.unsub=ke,r.unsub=r.node.subscribe(o=>{if(r.unsub===null)return;let a=this._config.tierOf,d=!1;for(let l of o)a(l[0])>=3&&(d=!0),this._config.onMessage(this,l,{direction:"down-in",depIndex:i},this._actions);d&&this._maybeRunFnOnSettlement()}),n++}}catch(s){this._deps[n].unsub=null;for(let i=0;i<n;i++){let r=this._deps[i];if(r.unsub!=null){let o=r.unsub;r.unsub=null;try{o()}catch{}ce(r)}}throw this._dirtyDepCount=0,s}}_addDep(e){for(let i=0;i<this._deps.length;i++)if(this._deps[i].node===e)return i;let n=this._deps.length,s=Ee(e);if(this._deps.push(s),this._sinks==null)return n;s.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ie),s.unsub=ke;try{s.unsub=e.subscribe(i=>{if(s.unsub===null)return;let r=this._config.tierOf,o=!1;for(let a of i)r(a[0])>=3&&(o=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);o&&this._maybeRunFnOnSettlement()})}catch(i){throw s.unsub=null,this._deps.pop(),this._dirtyDepCount--,i}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(s){this._emit([[_,this._wrapFnError("cleanup threw",s)]])}else if(n!=null&&typeof n=="object"){let s=n.deactivate;if(typeof s=="function")try{s()}catch(i){this._emit([[_,this._wrapFnError("cleanup.deactivate threw",i)]])}}for(let s of this._deps){if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}}ce(s)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let s=this._deps[e],i=n[0];if(this._inspectorHooks!=null){let r={kind:"dep_message",depIndex:e,message:n};for(let o of this._inspectorHooks)o(r)}if(i!==Y){if(i===S){this._depDirtied(s);return}if(i===C){this._depInvalidated(s),this._emit(pe);return}if(i===k||i===L){this._emit([n]);return}if(i===A){this._emit(re);return}if(i===b)this._depSettledAsData(s,n[1]);else if(i===v)this._depSettledAsResolved(s);else if(i===D)this._depSettledAsTerminal(s,!0);else if(i===_)this._depSettledAsTerminal(s,n[1]);else{this._emit([n]);return}if(!this._fn){(i===b||i===v)&&this._emit([n]),(i===D||i===_)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ie))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(fe),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[_,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(_e)}_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(o){this._emit([[_,this._wrapFnError("cleanup threw",o)]]);return}}else if(e!=null&&typeof e=="object"){let o=e.beforeRun;if(typeof o=="function"){e.beforeRun=void 0;try{o()}catch(a){this._emit([[_,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(o=>o.involvedThisWave?o.dataBatch.length>0?[...o.dataBatch]:[]:void 0),s=this._deps.map(o=>o.prevData);for(let o=0;o<this._deps.length;o++){let a=n[o];a!=null&&a.length>0&&(this._deps[o].prevData=a[a.length-1])}let i=this._deps.map(o=>o.terminal),r={prevData:s,terminalDeps:i,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let o={kind:"run",batchData:n,prevData:s};for(let a of this._inspectorHooks)a(o)}this._isExecutingFn=!0;try{let o=this._fn(n,this._actions,r);if(typeof o=="function")this._cleanup=o;else if(o!=null&&typeof o=="object"){let a=o;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=o)}}catch(o){this._emit([[_,this._wrapFnError("fn threw",o)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Ae?(this._rerunDepth=0,this._emit([[_,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Ae} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let s=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${s}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[P,e[0]]:e;let s=!0,i=!1,r=!1,o=-1;for(let d of e){let l=n(d[0]);l<o&&(s=!1),l===3&&(i=!0),d[0]===S&&(r=!0),o=l}let a=e;if(!s){let d=e.map((l,c)=>({m:l,i:c,tier:n(l[0])}));d.sort((l,c)=>l.tier-c.tier||l.i-c.i),a=d.map(l=>l.m)}if(i&&!r&&this._status!=="dirty"){let d=0;for(;d<a.length&&n(a[d][0])===0;)d++;return d===0?[P,...a]:[...a.slice(0,d),P,...a.slice(d)]}return a}_emit(e){if(e.length===0)return;let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(d=>d[0]===A||d[0]===C);if(a.length===0)return;n=a}n=this._frameBatch(n);let i=null;for(let a=0;a<n.length;a++){let d=n[a],l=d[0];if(l!==k&&l!==L){i?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${l===k?"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 u=d[1];if(l===k)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(u),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(u))c=!1;else if(this._pauseLocks.delete(u),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let h=this._pauseBuffer;this._pauseBuffer=[],this._emit(h)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?i?.push(d):i==null&&(i=n.slice(0,a))}if(i!=null){if(i.length===0)return;n=i}if(this._hasMeta&&n.some(a=>a[0]===A))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(re)}catch{}let{finalMessages:r,equalsError:o}=this._updateState(n);if(r.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:r})}catch{}}if(r.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,d=[];for(let l of r){let c=a(l[0]);c<3||c===5?d.push(l):this._pauseBuffer.push(l)}d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(r);o!=null&&this._emit([[_,o]])}_updateState(e){let n=this._config.tierOf,s,i,r=-1,o=0;for(let c of e)n(c[0])===3&&o++;let a=o<=1,d=-1;if(this._versioning!=null&&o>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===b){d=c;break}}for(let c=0;c<e.length;c++){let u=e[c],h=u[0];if(h===b){if(u.length>=2){let p=!1;if(a&&this._cached!==void 0)try{p=this._equals(this._cached,u[1])}catch(g){i=this._wrapFnError("equals threw",g),r=c;break}if(p){s==null&&(s=e.slice(0,c)),s.push(he),this._status="resolved";continue}this._cached=u[1],this._versioning!=null&&(d<0||c===d)&&Ne(this._versioning,u[1],this._hashFn)}this._status="settled",s?.push(u)}else if(s?.push(u),h===S)this._status="dirty";else if(h===v)this._status="resolved";else if(h===D)this._status="completed";else if(h===_)this._status="errored";else if(h===C){this._cached=void 0,this._status="dirty";let p=this._cleanup;if(typeof p=="function"){this._cleanup=void 0;try{p()}catch{}}else if(p!=null&&typeof p=="object"){let g=p.invalidate;if(typeof g=="function")try{g()}catch{}}}else h===A&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let l=r>=0?s??e.slice(0,r):s??e;return i!=null?{finalMessages:l,equalsError:i}:{finalMessages:l}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let s of n)s(e)};_dispatchOrAccumulate(e){if(be()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ve(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}X(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);X(this._deliverToSinks,n,this._config.tierOf)}},Me=t=>Array.isArray(t),ue=t=>typeof t=="object"&&t!=null&&!Array.isArray(t);function z(t,e,n){let s=Me(t)?t:[],i=typeof t=="function"?t:typeof e=="function"?e:void 0,r={};return Me(t)?r=(ue(e)?e:n)??{}:ue(t)?r=t:r=(ue(e)?e:n)??{},new $(s,i,r)}function Se(t,e,n){return n?!1:t.some((s,i)=>!(s!=null&&s.length>0)&&e.prevData[i]===void 0)}function xn(t,e){return z([],{...e,initial:t})}function Tn(t,e){return z((s,i,r)=>t(i,r)??void 0,{describeKind:"producer",...e})}function $e(t,e,n){let s=n?.partial??!1;return z(t,(r,o,a)=>{if(Se(r,a,s)){o.down([[v]]);return}let d=r.map((l,c)=>l!=null&&l.length>0?l.at(-1):a.prevData[c]);o.emit(e(d,a))},{describeKind:"derived",...n})}function Nn(t,e,n){let s=n?.partial??!1;return z(t,(r,o,a)=>{if(Se(r,a,s)){o.down([[v]]);return}let d=r.map((l,c)=>l!=null&&l.length>0?l.at(-1):a.prevData[c]);return e(d,o,a)??void 0},{describeKind:"effect",...n})}function kn(t,e,n){let s=new Map;return t.forEach((i,r)=>{s.set(i,r)}),$e(t,(i,r)=>e(a=>{let d=s.get(a);if(d==null)throw new Error(`dynamicNode: untracked dep "${a.name??"<unnamed>"}"`);return i[d]},r),n)}function An(t,e){let n,s=new Map,i=e?.partial??!1,r=(o,a,d)=>{let l=!1,c=u=>{let h=s.get(u);if(h!==void 0){if(h<o.length){let g=o[h];return g!=null&&g.length>0?g.at(-1):d.prevData[h]}return u.cache}l=!0;let p=n._addDep(u);return s.set(u,p),u.cache};if(!i&&s.size>0){for(let[,u]of s)if(u<o.length){let h=o[u];if(!(h!=null&&h.length>0)&&d.prevData[u]===void 0){a.down([[v]]);return}}}try{let u=t(c,d);l||(a.emit(u),d.store.__autoTrackLastDiscoveryError!=null&&delete d.store.__autoTrackLastDiscoveryError)}catch(u){if(!l)throw u;d.store.__autoTrackLastDiscoveryError=u}};return n=new $([],r,{describeKind:"derived",...e}),n}function En(t,...e){let n=t;for(let s of e)n=s(n);return n}export{Oe as a,ze as b,je as c,oe as d,qe as e,Ke as f,ye as g,Ye as h,Re as i,J as j,me as k,ve as l,Ze as m,X as n,en as o,we as p,Z as q,xe as r,F as s,Ie as t,rn as u,on as v,de as w,le as x,Ne as y,dn as z,B as A,mn as B,$ as C,z as D,xn as E,Tn as F,$e as G,Nn as H,kn as I,An as J,En as K};
@@ -0,0 +1,23 @@
1
+ import{a as v,f as M}from"./chunk-CRXTH3SH.js";import{d as S}from"./chunk-4GKB4OUJ.js";import{o as h}from"./chunk-ZB5EHBIO.js";function O(e={}){return e.sdk?Q(e):z(e)}function _(e,t,o,n){let r=t?.model??o;if(!r)throw new Error("anthropicAdapter: model must be set via options.model or invokeOpts.model");let{system:s,chat:a}=W(e,t?.systemPrompt),i={model:r,messages:a.map(Y),max_tokens:t?.maxTokens??4096};return s&&(i.system=s),t?.temperature!=null&&(i.temperature=t.temperature),t?.tools&&t.tools.length>0&&(i.tools=t.tools.map(V)),t?.maxReasoningTokens!=null&&(i.thinking={type:"enabled",budget_tokens:t.maxReasoningTokens}),t?.cacheHint,n&&(i.stream=!0),t?.providerExtras&&Object.assign(i,t.providerExtras),i}function W(e,t){let o=[];t&&o.push(t);let n=[];for(let r of e)r.role==="system"?o.push(r.content):n.push(r);return{system:o.length>0?o.join(`
2
+
3
+ `):void 0,chat:n}}function Y(e){if(e.role==="tool")return{role:"user",content:[{type:"tool_result",tool_use_id:e.toolCallId,content:e.content}]};if(e.role==="assistant"&&e.toolCalls&&e.toolCalls.length>0){let t=[];e.content&&t.push({type:"text",text:e.content});for(let o of e.toolCalls)t.push({type:"tool_use",id:o.id,name:o.name,input:o.arguments});return{role:"assistant",content:t}}return{role:e.role,content:e.content}}function V(e){return{name:e.name,description:e.description,input_schema:e.parameters}}function A(e,t){if(!e)return{...t};let o={...e};return t.input_tokens!=null&&(o.input_tokens=t.input_tokens),t.output_tokens!=null&&(o.output_tokens=t.output_tokens),t.cache_read_input_tokens!=null&&(o.cache_read_input_tokens=t.cache_read_input_tokens),t.cache_creation_input_tokens!=null&&(o.cache_creation_input_tokens=t.cache_creation_input_tokens),t.cache_creation&&(o.cache_creation={...e.cache_creation??{},...t.cache_creation}),t.server_tool_use&&(o.server_tool_use={...e.server_tool_use??{},...t.server_tool_use}),o}function w(e){let t={input:{regular:e?.input_tokens??0},output:{regular:e?.output_tokens??0},raw:e};return e?.cache_read_input_tokens&&(t.input.cacheRead=e.cache_read_input_tokens),e?.cache_creation?(e.cache_creation.ephemeral_5m_input_tokens&&(t.input.cacheWrite5m=e.cache_creation.ephemeral_5m_input_tokens),e.cache_creation.ephemeral_1h_input_tokens&&(t.input.cacheWrite1h=e.cache_creation.ephemeral_1h_input_tokens)):e?.cache_creation_input_tokens&&(t.input.cacheWrite5m=e.cache_creation_input_tokens),e?.server_tool_use?.web_search_requests&&(t.auxiliary={webSearchRequests:e.server_tool_use.web_search_requests}),t}function P(e,t){let o=[],n=[];for(let r of e.content)if(r.type==="text"&&typeof r.text=="string")o.push(r.text);else if(r.type==="tool_use"){let s=r;n.push({id:s.id,name:s.name,arguments:s.input??{}})}return{content:o.join(""),toolCalls:n.length>0?n:void 0,usage:w(e.usage),finishReason:e.stop_reason,latencyMs:t,model:e.model,provider:"anthropic"}}function z(e){let t=e.apiKey??globalThis.process?.env?.ANTHROPIC_API_KEY,o=e.baseURL??"https://api.anthropic.com",n=e.anthropicVersion??"2023-06-01",r=e.fetchImpl??fetch,s=()=>{if(!t)throw new Error("anthropicAdapter: apiKey required for invoke/stream (or provide opts.sdk)");return{"x-api-key":t,"anthropic-version":n,"content-type":"application/json",...e.headers??{}}};return{provider:"anthropic",model:e.model,async invoke(a,i){let c=_(a,i,e.model,!1),u=h(),d=await r(`${o}/v1/messages`,{method:"POST",headers:s(),body:JSON.stringify(c),signal:i?.signal});if(!d.ok)throw await T(d);let l=await d.json(),p=Math.max(0,(h()-u)/1e6);return P(l,p)},async*stream(a,i){let c=_(a,i,e.model,!0),u=await r(`${o}/v1/messages`,{method:"POST",headers:{...s(),accept:"text/event-stream"},body:JSON.stringify(c),signal:i?.signal});if(!u.ok)throw await T(u);if(!u.body)throw new Error("anthropicAdapter: streaming response has no body");let d,l,p=new Map;for await(let f of X(u.body)){let k=f.data;if(!k)continue;let y;try{y=JSON.parse(k)}catch{continue}switch(y.type){case"message_start":{d=A(d,y.message.usage);break}case"content_block_start":{let g=y,m=g.content_block;m.type==="tool_use"&&(p.set(g.index,{id:String(m.id??""),name:String(m.name??""),argBuf:""}),yield{type:"tool-call-delta",delta:{id:String(m.id??""),name:String(m.name??"")}});break}case"content_block_delta":{let g=y,m=g.delta;if(m.type==="text_delta"&&typeof m.text=="string")yield{type:"token",delta:m.text};else if(m.type==="input_json_delta"&&typeof m.partial_json=="string"){let E=p.get(g.index);E&&(E.argBuf+=m.partial_json),yield{type:"tool-call-delta",delta:{argumentsDelta:m.partial_json}}}else m.type==="thinking_delta"&&typeof m.thinking=="string"&&(yield{type:"thinking",delta:m.thinking});break}case"message_delta":{let g=y;g.delta.stop_reason&&(l=g.delta.stop_reason),g.delta.usage&&(d=A(d,g.delta.usage));break}case"message_stop":break}}d&&(yield{type:"usage",usage:w(d)}),yield{type:"finish",reason:l??"stop"}}}}function Q(e){let t=e.sdk;if(!t)throw new Error("sdkBackedAnthropic: sdk instance required");return{provider:"anthropic",model:e.model,async invoke(o,n){let r=_(o,n,e.model,!1),s=h(),a=await t.messages.create(r,{signal:n?.signal}),i=Math.max(0,(h()-s)/1e6);return P(a,i)},async*stream(o,n){if(!t.messages.stream)throw new Error("sdkBackedAnthropic: SDK instance does not expose .messages.stream");let r=_(o,n,e.model,!0),s,a;for await(let i of t.messages.stream(r,{signal:n?.signal}))switch(i.type){case"message_start":s=A(s,i.message.usage);break;case"content_block_delta":{let c=i.delta;c?.type==="text_delta"&&typeof c.text=="string"?yield{type:"token",delta:c.text}:c?.type==="input_json_delta"&&typeof c.partial_json=="string"?yield{type:"tool-call-delta",delta:{argumentsDelta:c.partial_json}}:c?.type==="thinking_delta"&&typeof c.thinking=="string"&&(yield{type:"thinking",delta:c.thinking});break}case"message_delta":{let c=i;c.delta.stop_reason&&(a=c.delta.stop_reason),c.delta.usage&&(s=A(s,c.delta.usage));break}}s&&(yield{type:"usage",usage:w(s)}),yield{type:"finish",reason:a??"stop"}}}}async function*X(e){let t=e.getReader(),o=new TextDecoder,n="";try{for(;;){let{done:r,value:s}=await t.read();if(r){n.length>0&&(yield I(n));return}n+=o.decode(s,{stream:!0});let a=U(n);for(;a!==null;){let i=n.slice(0,a.index);n=n.slice(a.index+a.length);let c=I(i);(c.data||c.event)&&(yield c),a=U(n)}}}finally{t.releaseLock()}}function I(e){let t={},o=[];for(let n of e.split(`
4
+ `)){let r=n.endsWith("\r")?n.slice(0,-1):n;if(!r||r.startsWith(":"))continue;let s=r.indexOf(":"),a=s===-1?r:r.slice(0,s),i=s===-1?"":r.slice(s+1).replace(/^ /,"");a==="data"?o.push(i):a==="event"?t.event=i:a==="id"&&(t.id=i)}return o.length>0&&(t.data=o.join(`
5
+ `)),t}function U(e){let t=e.indexOf(`\r
6
+ \r
7
+ `),o=e.indexOf(`
8
+
9
+ `),n=null;return t!==-1&&(n={index:t,length:4}),o!==-1&&(n===null||o<n.index)&&(n={index:o,length:2}),n}async function T(e){let t;try{t=await e.text()}catch{t=""}let o=new Error(`Anthropic API ${e.status}: ${e.statusText}${t?` \u2014 ${t}`:""}`);return o.status=e.status,o.headers=e.headers,o}function j(e={}){return e.sdk?ne(e):te(e)}function b(e,t){let o=[],n=[];t?.systemPrompt&&o.push(t.systemPrompt);for(let a of e){if(a.role==="system"){o.push(a.content);continue}if(a.role==="tool"){n.push({role:"user",parts:[{functionResponse:{name:a.name??a.toolCallId??"tool",response:{result:a.content}}}]});continue}if(a.role==="assistant"&&a.toolCalls&&a.toolCalls.length>0){let i=[];a.content&&i.push({text:a.content});for(let c of a.toolCalls)i.push({functionCall:{name:c.name,args:c.arguments}});n.push({role:"model",parts:i});continue}n.push({role:a.role==="assistant"?"model":"user",parts:[{text:a.content}]})}let r={contents:n};o.length>0&&(r.systemInstruction={role:"system",parts:[{text:o.join(`
10
+
11
+ `)}]});let s={};return t?.maxTokens!=null&&(s.maxOutputTokens=t.maxTokens),t?.temperature!=null&&(s.temperature=t.temperature),t?.maxReasoningTokens!=null&&(s.thinkingConfig={thinkingBudget:t.maxReasoningTokens}),Object.keys(s).length>0&&(r.generationConfig=s),t?.tools&&t.tools.length>0&&(r.tools=[{functionDeclarations:t.tools.map(Z)}]),t?.providerExtras&&Object.assign(r,t.providerExtras),r}function Z(e){return{name:e.name,description:e.description,parameters:e.parameters}}function L(e){let t={input:{regular:0},output:{regular:0},raw:e};if(!e)return t;let o=e.promptTokenCount??0,n=e.cachedContentTokenCount??0;if(t.input.regular=Math.max(0,o-n),n>0&&(t.input.cacheRead=n),e.toolUsePromptTokenCount&&(t.input.toolUse=e.toolUsePromptTokenCount),e.promptTokensDetails)for(let r of e.promptTokensDetails){let s=r.modality?.toLowerCase();s==="image"?t.input.image=(t.input.image??0)+r.tokenCount:s==="audio"?t.input.audio=(t.input.audio??0)+r.tokenCount:s==="video"&&(t.input.video=(t.input.video??0)+r.tokenCount)}return t.output.regular=e.candidatesTokenCount??0,e.thoughtsTokenCount&&(t.output.reasoning=e.thoughtsTokenCount),t}function $(e,t){let o=e.candidates?.[0],n=o?.content?.parts??[],r=[],s=[],a=0;for(let i of n)typeof i.text=="string"&&r.push(i.text),i.functionCall&&s.push({id:`${i.functionCall.name}-${a++}`,name:i.functionCall.name,arguments:i.functionCall.args??{}});return{content:r.join(""),toolCalls:s.length>0?s:void 0,usage:L(e.usageMetadata),finishReason:o?.finishReason,latencyMs:t,model:e.modelVersion,provider:"google"}}function ee(e){if(e.apiKey)return e.apiKey;let t=globalThis.process?.env;return t?.GOOGLE_API_KEY??t?.GEMINI_API_KEY}function te(e){let t=e.baseURL??"https://generativelanguage.googleapis.com/v1beta",o=e.fetchImpl??fetch,n=s=>{let a=s?.model??e.model;if(!a)throw new Error("googleAdapter: model must be set via options.model or invokeOpts.model");return a},r=()=>{let s=ee(e);if(!s)throw new Error("googleAdapter: apiKey required for invoke/stream");return`key=${encodeURIComponent(s)}`};return{provider:"google",model:e.model,async invoke(s,a){let i=n(a),c=b(s,a),u=h(),d=`${t}/models/${encodeURIComponent(i)}:generateContent?${r()}`,l=await o(d,{method:"POST",headers:{"content-type":"application/json",...e.headers??{}},body:JSON.stringify(c),signal:a?.signal});if(!l.ok)throw await D(l);let p=await l.json(),f=Math.max(0,(h()-u)/1e6);return $(p,f)},async*stream(s,a){let i=n(a),c=b(s,a),u=`${t}/models/${encodeURIComponent(i)}:streamGenerateContent?alt=sse&${r()}`,d=await o(u,{method:"POST",headers:{"content-type":"application/json",accept:"text/event-stream",...e.headers??{}},body:JSON.stringify(c),signal:a?.signal});if(!d.ok)throw await D(d);if(!d.body)throw new Error("googleAdapter: streaming response has no body");let l,p;for await(let f of oe(d.body)){if(!f.data)continue;let k;try{k=JSON.parse(f.data)}catch{continue}let y=k.candidates?.[0];for(let g of y?.content?.parts??[])typeof g.text=="string"&&(g.thought?yield{type:"thinking",delta:g.text}:yield{type:"token",delta:g.text}),g.functionCall&&(yield{type:"tool-call-delta",delta:{name:g.functionCall.name,argumentsDelta:JSON.stringify(g.functionCall.args??{})}});y?.finishReason&&(p=y.finishReason),k.usageMetadata&&(l=k.usageMetadata)}l&&(yield{type:"usage",usage:L(l)}),yield{type:"finish",reason:p??"stop"}}}}function ne(e){let t=e.sdk;if(!t)throw new Error("sdkBackedGoogle: sdk instance required");return{provider:"google",model:e.model,async invoke(o,n){let r=b(o,n),s=n?.model??e.model;if(!s)throw new Error("googleAdapter: model required");let a=h(),i=await t.models.generateContent({...r,model:s},{signal:n?.signal}),c=Math.max(0,(h()-a)/1e6);return $(i,c)},async*stream(o,n){if(!t.models.generateContentStream)throw new Error("sdkBackedGoogle: SDK instance does not expose generateContentStream");let r=b(o,n),s=n?.model??e.model;if(!s)throw new Error("googleAdapter: model required");let a,i;for await(let c of t.models.generateContentStream({...r,model:s},{signal:n?.signal})){let u=c.candidates?.[0];for(let d of u?.content?.parts??[])typeof d.text=="string"&&(d.thought?yield{type:"thinking",delta:d.text}:yield{type:"token",delta:d.text}),d.functionCall&&(yield{type:"tool-call-delta",delta:{name:d.functionCall.name,argumentsDelta:JSON.stringify(d.functionCall.args??{})}});u?.finishReason&&(i=u.finishReason),c.usageMetadata&&(a=c.usageMetadata)}a&&(yield{type:"usage",usage:L(a)}),yield{type:"finish",reason:i??"stop"}}}}async function*oe(e){let t=e.getReader(),o=new TextDecoder,n="";try{for(;;){let{done:r,value:s}=await t.read();if(r){n.length>0&&(yield G(n));return}n+=o.decode(s,{stream:!0});let a=K(n);for(;a!==null;){let i=n.slice(0,a.index);n=n.slice(a.index+a.length);let c=G(i);(c.data||c.event)&&(yield c),a=K(n)}}}finally{t.releaseLock()}}function G(e){let t={},o=[];for(let n of e.split(`
12
+ `)){let r=n.endsWith("\r")?n.slice(0,-1):n;if(!r||r.startsWith(":"))continue;let s=r.indexOf(":"),a=s===-1?r:r.slice(0,s),i=s===-1?"":r.slice(s+1).replace(/^ /,"");a==="data"?o.push(i):a==="event"?t.event=i:a==="id"&&(t.id=i)}return o.length>0&&(t.data=o.join(`
13
+ `)),t}function K(e){let t=e.indexOf(`\r
14
+ \r
15
+ `),o=e.indexOf(`
16
+
17
+ `),n=null;return t!==-1&&(n={index:t,length:4}),o!==-1&&(n===null||o<n.index)&&(n={index:o,length:2}),n}async function D(e){let t;try{t=await e.text()}catch{t=""}let o=new Error(`Google API ${e.status}: ${e.statusText}${t?` \u2014 ${t}`:""}`);return o.status=e.status,o.headers=e.headers,o}var re={openai:{baseURL:"https://api.openai.com/v1",apiKeyEnv:"OPENAI_API_KEY",provider:"openai"},openrouter:{baseURL:"https://openrouter.ai/api/v1",apiKeyEnv:"OPENROUTER_API_KEY",provider:"openrouter"},groq:{baseURL:"https://api.groq.com/openai/v1",apiKeyEnv:"GROQ_API_KEY",provider:"groq"},ollama:{baseURL:"http://localhost:11434/v1",provider:"ollama"},deepseek:{baseURL:"https://api.deepseek.com/v1",apiKeyEnv:"DEEPSEEK_API_KEY",provider:"deepseek"},xai:{baseURL:"https://api.x.ai/v1",apiKeyEnv:"XAI_API_KEY",provider:"xai"}};function J(e={}){return e.sdk?de(e):ce(e)}function R(e,t,o,n,r){let s=t?.model??o;if(!s)throw new Error("openAICompatAdapter: model must be set via options.model or invokeOpts.model");let a=e.map(ae);t?.systemPrompt&&!e.some(c=>c.role==="system")&&a.unshift({role:"system",content:t.systemPrompt});let i={model:s,messages:a};return t?.maxTokens!=null&&(i.max_tokens=t.maxTokens),t?.temperature!=null&&(i.temperature=t.temperature),t?.tools&&t.tools.length>0&&(i.tools=t.tools.map(se)),t?.maxReasoningTokens!=null&&(i.reasoning={max_tokens:t.maxReasoningTokens}),n&&(i.stream=!0,i.stream_options={include_usage:!0}),r&&Object.assign(i,r),t?.providerExtras&&Object.assign(i,t.providerExtras),i}function ae(e){return e.role==="tool"?{role:"tool",tool_call_id:e.toolCallId,content:e.content}:e.role==="assistant"&&e.toolCalls&&e.toolCalls.length>0?{role:"assistant",content:e.content||null,tool_calls:e.toolCalls.map(t=>({id:t.id,type:"function",function:{name:t.name,arguments:JSON.stringify(t.arguments)}}))}:{role:e.role,content:e.content}}function se(e){return{type:"function",function:{name:e.name,description:e.description,parameters:e.parameters}}}function C(e){let t={input:{regular:0},output:{regular:0},raw:e};if(!e)return t;let o=e.prompt_tokens??0,n=e.prompt_tokens_details?.cached_tokens??0;e.prompt_cache_hit_tokens!=null?(n=e.prompt_cache_hit_tokens,t.input.regular=e.prompt_cache_miss_tokens??Math.max(0,o-n)):t.input.regular=Math.max(0,o-n),n>0&&(t.input.cacheRead=n),e.prompt_tokens_details?.audio_tokens&&(t.input.audio=e.prompt_tokens_details.audio_tokens);let r=e.completion_tokens??0,s=e.completion_tokens_details?.reasoning_tokens??0;return t.output.regular=Math.max(0,r-s),s>0&&(t.output.reasoning=s),e.completion_tokens_details?.audio_tokens&&(t.output.audio=e.completion_tokens_details.audio_tokens),e.completion_tokens_details?.accepted_prediction_tokens&&(t.output.predictionAccepted=e.completion_tokens_details.accepted_prediction_tokens),e.completion_tokens_details?.rejected_prediction_tokens&&(t.output.predictionRejected=e.completion_tokens_details.rejected_prediction_tokens),t}function F(e,t,o){let n=e.choices[0],r=n?.message,s=r?.content??"",a=(r?.tool_calls??[]).map(i=>({id:i.id,name:i.function.name,arguments:ie(i.function.arguments)}));return{content:s,toolCalls:a.length>0?a:void 0,usage:C(e.usage),finishReason:n?.finish_reason,latencyMs:t,model:e.model,provider:o}}function ie(e){try{let t=JSON.parse(e);return typeof t=="object"&&t!=null?t:{_raw:e}}catch{return{_raw:e}}}function H(e){let t=e.preset??"openai",o=re[t],n=e.baseURL??o.baseURL,r=e.provider??o.provider,s=o.apiKeyEnv,a=e.apiKey??(s?globalThis.process?.env?.[s]:void 0);return{provider:r,baseURL:n,apiKey:a}}function ce(e){let{provider:t,baseURL:o,apiKey:n}=H(e),r=e.fetchImpl??fetch,s=t!=="ollama",a=()=>{let i={"content-type":"application/json",...e.headers??{}};if(s){if(!n)throw new Error(`openAICompatAdapter[${t}]: apiKey required for invoke/stream`);i.authorization=`Bearer ${n}`}return i};return{provider:t,model:e.model,async invoke(i,c){let u=R(i,c,e.model,!1,e.bodyExtras),d=h(),l=await r(`${o}/chat/completions`,{method:"POST",headers:a(),body:JSON.stringify(u),signal:c?.signal});if(!l.ok)throw await q(l,t);let p=await l.json(),f=Math.max(0,(h()-d)/1e6);return F(p,f,t)},async*stream(i,c){let u=R(i,c,e.model,!0,e.bodyExtras),d=await r(`${o}/chat/completions`,{method:"POST",headers:{...a(),accept:"text/event-stream"},body:JSON.stringify(u),signal:c?.signal});if(!d.ok)throw await q(d,t);if(!d.body)throw new Error(`openAICompatAdapter[${t}]: streaming response has no body`);let l,p;for await(let f of le(d.body)){if(!f.data||f.data==="[DONE]")continue;let k;try{k=JSON.parse(f.data)}catch{continue}let y=k.choices;if(y){let g=y[0];if(g?.delta?.content&&(yield{type:"token",delta:g.delta.content}),g?.delta?.reasoning_content&&(yield{type:"thinking",delta:g.delta.reasoning_content}),g?.delta?.tool_calls)for(let m of g.delta.tool_calls)yield{type:"tool-call-delta",delta:{id:m.id,name:m.function?.name,argumentsDelta:m.function?.arguments}};g?.finish_reason&&(p=g.finish_reason)}k.usage&&(l=k.usage,yield{type:"usage",usage:C(l)})}yield{type:"finish",reason:p??"stop"}}}}function de(e){let t=e.sdk;if(!t)throw new Error("sdkBackedOpenAI: sdk instance required");let{provider:o}=H(e);return{provider:o,model:e.model,async invoke(n,r){let s=R(n,r,e.model,!1,e.bodyExtras),a=h(),i=await t.chat.completions.create(s,{signal:r?.signal}),c=Math.max(0,(h()-a)/1e6);return F(i,c,o)},async*stream(n,r){let s=R(n,r,e.model,!0,e.bodyExtras),a=await t.chat.completions.create(s,{signal:r?.signal}),i,c;for await(let u of a){let d=u.choices;if(d){let p=d[0];if(p?.delta?.content&&(yield{type:"token",delta:p.delta.content}),p?.delta?.reasoning_content&&(yield{type:"thinking",delta:p.delta.reasoning_content}),p?.delta?.tool_calls)for(let f of p.delta.tool_calls)yield{type:"tool-call-delta",delta:{id:f.id,name:f.function?.name,argumentsDelta:f.function?.arguments}};p?.finish_reason&&(c=p.finish_reason)}let l=u.usage;l&&(i=l,yield{type:"usage",usage:C(l)})}yield{type:"finish",reason:c??"stop"}}}}async function*le(e){let t=e.getReader(),o=new TextDecoder,n="";try{for(;;){let{done:r,value:s}=await t.read();if(r){n.length>0&&(yield B(n));return}n+=o.decode(s,{stream:!0});let a=N(n);for(;a!==null;){let i=n.slice(0,a.index);n=n.slice(a.index+a.length);let c=B(i);(c.data||c.event)&&(yield c),a=N(n)}}}finally{t.releaseLock()}}function B(e){let t={},o=[];for(let n of e.split(`
18
+ `)){let r=n.endsWith("\r")?n.slice(0,-1):n;if(!r||r.startsWith(":"))continue;let s=r.indexOf(":"),a=s===-1?r:r.slice(0,s),i=s===-1?"":r.slice(s+1).replace(/^ /,"");a==="data"?o.push(i):a==="event"?t.event=i:a==="id"&&(t.id=i)}return o.length>0&&(t.data=o.join(`
19
+ `)),t}function N(e){let t=e.indexOf(`\r
20
+ \r
21
+ `),o=e.indexOf(`
22
+
23
+ `),n=null;return t!==-1&&(n={index:t,length:4}),o!==-1&&(n===null||o<n.index)&&(n={index:o,length:2}),n}async function q(e,t){let o;try{o=await e.text()}catch{o=""}let n=new Error(`${t} API ${e.status}: ${e.statusText}${o?` \u2014 ${o}`:""}`);return n.status=e.status,n.headers=e.headers,n}function Re(e){switch(e.provider){case"anthropic":{let t={apiKey:e.apiKey,model:e.model,baseURL:e.baseURL,headers:e.headers,sdk:e.sdk,fetchImpl:e.fetchImpl,...e.extras};return O(t)}case"google":{let t={apiKey:e.apiKey,model:e.model,baseURL:e.baseURL,headers:e.headers,sdk:e.sdk,fetchImpl:e.fetchImpl,...e.extras};return j(t)}case"dry-run":{let t={model:e.model,...e.extras};return v(t)}case"fallback":{let t={provider:e.provider,model:e.model,...e.extras};return M(t)}case"openai":case"openrouter":case"groq":case"ollama":case"deepseek":case"xai":{let t={preset:e.provider,apiKey:e.apiKey,model:e.model,baseURL:e.baseURL,headers:e.headers,bodyExtras:e.bodyExtras,sdk:e.sdk,fetchImpl:e.fetchImpl,...e.extras};return J(t)}default:{let t=e.provider;throw new Error(`createAdapter: unknown provider: ${String(t)}`)}}}var x=class extends Error{name="AllTiersExhaustedError";skipped;failed;constructor(t){let o=[];t.failed.size>0&&o.push(`failed=[${[...t.failed.keys()].join(",")}]`),t.skipped.length>0&&o.push(`skipped=[${t.skipped.map(n=>`${n.name}(${n.reason})`).join(",")}]`),super(`All LLM adapter tiers exhausted: ${o.join(" ")}`),this.skipped=t.skipped,this.failed=t.failed}};function Le(e,t={}){if(e.length===0)throw new RangeError("cascadingLlmAdapter: tiers must be non-empty");let o=e.map(r=>({name:r.name,adapter:r.adapter,filter:r.filter,breaker:r.breaker?"canExecute"in r.breaker?r.breaker:S(r.breaker):void 0})),n=t.streamRetryBeforeFirstChunk??!0;return{provider:"cascading",model:void 0,async invoke(r,s){let a=[],i=new Map;for(let u=0;u<o.length;u++){let d=o[u];if(d.filter&&!d.filter(r,s)){a.push({name:d.name,reason:"filter"});continue}if(d.breaker&&!d.breaker.canExecute()){a.push({name:d.name,reason:"breaker"});continue}try{let l=await Promise.resolve(d.adapter.invoke(r,s));return d.breaker?.recordSuccess(),{...l,metadata:{...l.metadata??{},tier:d.name}}}catch(l){i.set(d.name,l),d.breaker?.recordFailure(l);let p=o[u+1];p&&t.onFallback?.(d.name,p.name,l)}}let c={skipped:a,failed:i};throw t.onExhausted?.(c),new x(c)},async*stream(r,s){let a=[],i=new Map;for(let u=0;u<o.length;u++){let d=o[u];if(d.filter&&!d.filter(r,s)){a.push({name:d.name,reason:"filter"});continue}if(d.breaker&&!d.breaker.canExecute()){a.push({name:d.name,reason:"breaker"});continue}let l=!1;try{for await(let p of d.adapter.stream(r,s))l=!0,yield p;d.breaker?.recordSuccess();return}catch(p){if(i.set(d.name,p),d.breaker?.recordFailure(p),l||!n)throw p;let f=o[u+1];f&&t.onFallback?.(d.name,f.name,p)}}let c={skipped:a,failed:i};throw t.onExhausted?.(c),new x(c)}}}export{O as a,j as b,J as c,Re as d,x as e,Le as f};