@graphrefly/graphrefly 0.28.0 → 0.30.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 (284) hide show
  1. package/dist/{cascading-D9WG1-9L.d.ts → cascading-BszPheHD.d.ts} +1 -1
  2. package/dist/{cascading-B-5zmAUv.d.cts → cascading-dNCtjW8j.d.cts} +1 -1
  3. package/dist/{chunk-OAWLCNJJ.js → chunk-2GQREQ6C.js} +1 -1
  4. package/dist/{chunk-DBGGMN3D.js → chunk-33FA6V4B.js} +1 -1
  5. package/dist/chunk-3NEPQO2E.js +43 -0
  6. package/dist/{chunk-UWJE5FQA.js → chunk-4C2OR2GH.js} +11 -11
  7. package/dist/chunk-4JJCCD5S.js +2 -0
  8. package/dist/{chunk-GHJJR5P4.js → chunk-4OFIQ66T.js} +1 -1
  9. package/dist/{chunk-PIOGHC63.js → chunk-567NWZ3T.js} +1 -1
  10. package/dist/chunk-5JDE5JHE.js +1 -0
  11. package/dist/{chunk-ETWTCCJI.js → chunk-5Z4HDCO6.js} +1 -1
  12. package/dist/{chunk-Y2EMPB3I.js → chunk-73Z3W2RN.js} +1 -1
  13. package/dist/{chunk-CRXTH3SH.js → chunk-7JDLFI6N.js} +1 -1
  14. package/dist/{chunk-DQA3UIQ2.js → chunk-7TDOES3L.js} +1 -1
  15. package/dist/{chunk-LBTDSCCO.js → chunk-AMBYCIOH.js} +1 -1
  16. package/dist/{chunk-D7A7DBE4.js → chunk-AUY2YKCO.js} +1 -1
  17. package/dist/{chunk-FNYWM6JC.js → chunk-AV3PIDFQ.js} +1 -1
  18. package/dist/{chunk-UMBIDLJ4.js → chunk-BA5URFYW.js} +1 -1
  19. package/dist/chunk-BKPLTBL5.js +1 -0
  20. package/dist/{chunk-UPXUCFMX.js → chunk-BZP5T4X6.js} +1 -1
  21. package/dist/{chunk-WQ2BN6X6.js → chunk-DDPYNMGG.js} +1 -1
  22. package/dist/{chunk-LQ3Y5NJS.js → chunk-GJR3P6JG.js} +1 -1
  23. package/dist/{chunk-3R5HFPX7.js → chunk-GLSM33ZM.js} +1 -1
  24. package/dist/{chunk-2FOAM3OR.js → chunk-GNCBXARM.js} +1 -1
  25. package/dist/{chunk-K2GNMCQT.js → chunk-ISCENNXS.js} +1 -1
  26. package/dist/{chunk-UPHHLMHE.js → chunk-IUK4EFCE.js} +1 -1
  27. package/dist/{chunk-ERLIRFPA.js → chunk-KA6MMXIY.js} +1 -1
  28. package/dist/{chunk-2PMCKKRK.js → chunk-KASHOCF5.js} +1 -1
  29. package/dist/chunk-LI3E75VE.js +64 -0
  30. package/dist/chunk-MGKAO4EK.js +7 -0
  31. package/dist/{chunk-ZV2DXV5A.js → chunk-NSG4C6BF.js} +1 -1
  32. package/dist/{chunk-4GKB4OUJ.js → chunk-OL33ZI6R.js} +1 -1
  33. package/dist/{chunk-76A3HVQE.js → chunk-P7JXGKDO.js} +1 -1
  34. package/dist/{chunk-U3AICJKU.js → chunk-RD52SNH2.js} +1 -1
  35. package/dist/{chunk-CWLN3X3N.js → chunk-SHYH5SXV.js} +1 -1
  36. package/dist/{chunk-VTPVOGHH.js → chunk-SLMYTGTU.js} +1 -1
  37. package/dist/{chunk-OYHGKYQM.js → chunk-T5SHIKJD.js} +1 -1
  38. package/dist/{chunk-VPYBOXVT.js → chunk-TWMEGG45.js} +1 -1
  39. package/dist/chunk-VIEUJSTT.js +1 -0
  40. package/dist/{chunk-SC3U7ETD.js → chunk-VWPRPPKR.js} +1 -1
  41. package/dist/chunk-W4TSQ6RJ.js +1 -0
  42. package/dist/{chunk-OBKQQA5I.js → chunk-WANIEEKV.js} +1 -1
  43. package/dist/{chunk-XAUNPIMX.js → chunk-XHVB6G6M.js} +1 -1
  44. package/dist/{chunk-MIQTDPY4.js → chunk-XQAXYVXX.js} +1 -1
  45. package/dist/{chunk-MTTAAPCK.js → chunk-Y32RJO24.js} +1 -1
  46. package/dist/{chunk-S35VARIR.js → chunk-Y36UZ5VS.js} +1 -1
  47. package/dist/compat/index.cjs +13 -12
  48. package/dist/compat/index.d.cts +14 -14
  49. package/dist/compat/index.d.ts +14 -14
  50. package/dist/compat/index.js +1 -1
  51. package/dist/compat/jotai/index.cjs +1 -1
  52. package/dist/compat/jotai/index.d.cts +2 -2
  53. package/dist/compat/jotai/index.d.ts +2 -2
  54. package/dist/compat/jotai/index.js +1 -1
  55. package/dist/compat/nanostores/index.cjs +1 -1
  56. package/dist/compat/nanostores/index.d.cts +2 -2
  57. package/dist/compat/nanostores/index.d.ts +2 -2
  58. package/dist/compat/nanostores/index.js +1 -1
  59. package/dist/compat/nestjs/index.cjs +13 -12
  60. package/dist/compat/nestjs/index.d.cts +6 -6
  61. package/dist/compat/nestjs/index.d.ts +6 -6
  62. package/dist/compat/nestjs/index.js +1 -1
  63. package/dist/compat/react/index.d.cts +2 -2
  64. package/dist/compat/react/index.d.ts +2 -2
  65. package/dist/compat/solid/index.d.cts +2 -2
  66. package/dist/compat/solid/index.d.ts +2 -2
  67. package/dist/compat/svelte/index.d.cts +2 -2
  68. package/dist/compat/svelte/index.d.ts +2 -2
  69. package/dist/compat/vue/index.d.cts +2 -2
  70. package/dist/compat/vue/index.d.ts +2 -2
  71. package/dist/compat/zustand/index.cjs +7 -6
  72. package/dist/compat/zustand/index.d.cts +4 -4
  73. package/dist/compat/zustand/index.d.ts +4 -4
  74. package/dist/compat/zustand/index.js +1 -1
  75. package/dist/{composite-BhbKHbOS.d.ts → composite-DGspwCqk.d.ts} +2 -2
  76. package/dist/{composite-B-xqw4Kk.d.cts → composite-nrRumJ7l.d.cts} +2 -2
  77. package/dist/core/index.cjs +1 -1
  78. package/dist/core/index.d.cts +4 -4
  79. package/dist/core/index.d.ts +4 -4
  80. package/dist/core/index.js +1 -1
  81. package/dist/extra/browser.cjs +1 -1
  82. package/dist/extra/browser.d.cts +1 -1
  83. package/dist/extra/browser.d.ts +1 -1
  84. package/dist/extra/browser.js +1 -1
  85. package/dist/extra/index.cjs +20 -19
  86. package/dist/extra/index.d.cts +9 -9
  87. package/dist/extra/index.d.ts +9 -9
  88. package/dist/extra/index.js +1 -1
  89. package/dist/extra/node.cjs +3 -3
  90. package/dist/extra/node.d.cts +1 -1
  91. package/dist/extra/node.d.ts +1 -1
  92. package/dist/extra/node.js +1 -1
  93. package/dist/extra/operators.cjs +1 -1
  94. package/dist/extra/operators.d.cts +1 -1
  95. package/dist/extra/operators.d.ts +1 -1
  96. package/dist/extra/operators.js +1 -1
  97. package/dist/extra/reactive.cjs +1 -1
  98. package/dist/extra/reactive.d.cts +3 -3
  99. package/dist/extra/reactive.d.ts +3 -3
  100. package/dist/extra/reactive.js +1 -1
  101. package/dist/extra/sources.cjs +1 -1
  102. package/dist/extra/sources.d.cts +1 -1
  103. package/dist/extra/sources.d.ts +1 -1
  104. package/dist/extra/sources.js +1 -1
  105. package/dist/extra/storage-browser.cjs +1 -1
  106. package/dist/extra/storage-browser.d.cts +1 -1
  107. package/dist/extra/storage-browser.d.ts +1 -1
  108. package/dist/extra/storage-browser.js +1 -1
  109. package/dist/graph/index.cjs +7 -6
  110. package/dist/graph/index.d.cts +5 -5
  111. package/dist/graph/index.d.ts +5 -5
  112. package/dist/graph/index.js +1 -1
  113. package/dist/{graph-D48Qw9Cg.d.cts → graph-C4Uxwv0T.d.cts} +22 -6
  114. package/dist/{graph-BZGRXwOm.d.ts → graph-CWeI0aHd.d.ts} +22 -6
  115. package/dist/{index-u15meRxL.d.cts → index-9iguV3bF.d.cts} +2 -2
  116. package/dist/{index-DyxjtScX.d.cts → index-B-z8WaSd.d.cts} +2 -2
  117. package/dist/{index-BgyGlizc.d.ts → index-B2HBxvMb.d.ts} +4 -4
  118. package/dist/{index-CzobVSMr.d.ts → index-B5iVOD7w.d.ts} +2 -2
  119. package/dist/{index-rX8HBM5h.d.cts → index-B8Aj_z8S.d.cts} +2 -2
  120. package/dist/{index-D-YB-Vl3.d.ts → index-BANwzwBV.d.ts} +3 -3
  121. package/dist/{index-HDpJe9hX.d.ts → index-BBINVimG.d.ts} +3 -3
  122. package/dist/{index-8FSVk4Uf.d.ts → index-BEpRsvhg.d.ts} +4 -4
  123. package/dist/{index-CHEswufn.d.cts → index-BHu_Wba0.d.cts} +4 -4
  124. package/dist/{index-ZftwfxJM.d.ts → index-BJHQUCZx.d.ts} +7 -7
  125. package/dist/{index-DUqMOlKZ.d.cts → index-BS220yqj.d.cts} +7 -7
  126. package/dist/{index-BWJV63ti.d.ts → index-BX22kvjh.d.ts} +1 -1
  127. package/dist/{index-DfyOkTvs.d.ts → index-BXbQUn4n.d.ts} +2 -2
  128. package/dist/{index-O6TgGUBV.d.cts → index-BpFWP7Bq.d.cts} +3 -3
  129. package/dist/{index-BxJ86YZZ.d.cts → index-Bs3-LC83.d.cts} +3 -3
  130. package/dist/{index-DiOXyAwt.d.ts → index-Bvi5uJxX.d.ts} +1 -1
  131. package/dist/{index-Bqachn9_.d.ts → index-ByPnK85n.d.ts} +1 -1
  132. package/dist/{index-CRO83MmV.d.cts → index-BydMDMf7.d.cts} +1 -1
  133. package/dist/{index-ROpQmGjE.d.ts → index-C5Ghnp5B.d.ts} +3 -3
  134. package/dist/{index-umtoWT8K.d.ts → index-C6NBfXj-.d.ts} +6 -5
  135. package/dist/{index-pXrDMpRO.d.cts → index-C98oJsEs.d.cts} +2 -2
  136. package/dist/{index-B2pwesl9.d.cts → index-CDK5RsV5.d.cts} +1 -1
  137. package/dist/{index-Czq6ynh8.d.ts → index-CFW32Dy1.d.ts} +3 -3
  138. package/dist/{index-Cyojz0AE.d.cts → index-CIXaiYDE.d.cts} +1 -1
  139. package/dist/{index-Oi8d8w4R.d.cts → index-CRAkoq-y.d.cts} +1 -1
  140. package/dist/{index-CpgYhnrG.d.ts → index-Cc8VQIgL.d.ts} +2 -2
  141. package/dist/{index-vscRDkjW.d.cts → index-CcpEvuPl.d.cts} +2 -2
  142. package/dist/{index-BpA5c4G9.d.ts → index-CfFYyLR8.d.ts} +4 -4
  143. package/dist/{index-9oDeHH2u.d.cts → index-ClB7TCfL.d.cts} +2 -2
  144. package/dist/{index-BHvIquRZ.d.ts → index-ClgKmOHe.d.ts} +592 -492
  145. package/dist/{index-DpHe5e0Q.d.ts → index-CotRMjtJ.d.ts} +2 -2
  146. package/dist/{index-B1AmmSlb.d.ts → index-CrC7urhX.d.ts} +1 -1
  147. package/dist/{index-B0c4cmIO.d.ts → index-CvS9IuTG.d.ts} +2 -2
  148. package/dist/{index-rHJSKsU8.d.cts → index-Cy7eFeIX.d.cts} +2 -2
  149. package/dist/{index-BVHOrDwO.d.ts → index-D0C_USMR.d.ts} +1 -1
  150. package/dist/{index-DEwTb_fm.d.cts → index-D6ajK8Mh.d.cts} +592 -492
  151. package/dist/{index-DL-rYJrx.d.cts → index-D7XxY1Ff.d.cts} +1 -1
  152. package/dist/{index-DAlweici.d.ts → index-D9HrBx2J.d.ts} +2 -2
  153. package/dist/{index-fM6y00vT.d.cts → index-D9Y_u6BG.d.cts} +3 -3
  154. package/dist/{index-DcXZBF5a.d.cts → index-DBQUKh59.d.cts} +4 -4
  155. package/dist/{index-D_NwnRYS.d.cts → index-DDo-eqQ4.d.cts} +1 -1
  156. package/dist/{index-m-yHof5p.d.ts → index-DGb1awva.d.ts} +4 -4
  157. package/dist/{index-DxsnAMWD.d.cts → index-DR3gf_DG.d.cts} +9 -9
  158. package/dist/{index-dtN7YA2x.d.cts → index-DVNLe3pS.d.cts} +3 -3
  159. package/dist/{index-Btib9rsU.d.ts → index-Dljd76bC.d.ts} +275 -9
  160. package/dist/{index-DP4ZTkdw.d.ts → index-DnrZghBB.d.ts} +3 -3
  161. package/dist/{index-DaLJvH8Z.d.ts → index-Docdiu9a.d.ts} +3 -3
  162. package/dist/{index-BpIFjILY.d.cts → index-DylQCKEL.d.cts} +4 -4
  163. package/dist/{index-B_agccPe.d.cts → index-FBqTfL_S.d.cts} +1 -1
  164. package/dist/{index-DraikLjn.d.ts → index-FrYrV-Vf.d.ts} +2 -2
  165. package/dist/{index-sm373fsH.d.ts → index-IZ3l_vQ9.d.ts} +2 -2
  166. package/dist/{index-BwM9BEkt.d.ts → index-Ip3q9T9x.d.ts} +1 -1
  167. package/dist/{index-CloUk1kY.d.ts → index-RQg6lTrN.d.ts} +9 -9
  168. package/dist/{index-CEXXwWVH.d.cts → index-SSGqF8mI.d.cts} +2 -2
  169. package/dist/{index-rnwQly8X.d.cts → index-UZO988ox.d.cts} +6 -5
  170. package/dist/{index-C73n7lo-.d.cts → index-iBp74eGU.d.cts} +3 -3
  171. package/dist/{index-tbf2gKHd.d.cts → index-lKuLYmHO.d.cts} +3 -3
  172. package/dist/{index-CMn8S8Hw.d.ts → index-wIx1Jisk.d.ts} +1 -1
  173. package/dist/{index-cByzxQIC.d.cts → index-yIdWFo2b.d.cts} +4 -4
  174. package/dist/{index-RukJ4DLS.d.cts → index-ybtSyjWB.d.cts} +275 -9
  175. package/dist/index.cjs +53 -52
  176. package/dist/index.d.cts +42 -42
  177. package/dist/index.d.ts +42 -42
  178. package/dist/index.js +1 -1
  179. package/dist/{meta-CwesDrMD.d.ts → meta-BMwx3ExI.d.ts} +1 -1
  180. package/dist/{meta-Cgj6zeji.d.cts → meta-COtmHLwT.d.cts} +1 -1
  181. package/dist/{node-Cc1TniY8.d.ts → node-BVV7G1bq.d.cts} +59 -2
  182. package/dist/{node-Cc1TniY8.d.cts → node-BVV7G1bq.d.ts} +59 -2
  183. package/dist/{observable-glXQoGj2.d.cts → observable-BrUAPeH_.d.cts} +1 -1
  184. package/dist/{observable-Ct-gJ9jI.d.ts → observable-ITikPXz3.d.ts} +1 -1
  185. package/dist/patterns/ai/browser.d.cts +3 -3
  186. package/dist/patterns/ai/browser.d.ts +3 -3
  187. package/dist/patterns/ai/browser.js +1 -1
  188. package/dist/patterns/ai/index.cjs +25 -24
  189. package/dist/patterns/ai/index.d.cts +15 -15
  190. package/dist/patterns/ai/index.d.ts +15 -15
  191. package/dist/patterns/ai/index.js +1 -1
  192. package/dist/patterns/ai/node.d.cts +1 -1
  193. package/dist/patterns/ai/node.d.ts +1 -1
  194. package/dist/patterns/ai/node.js +1 -1
  195. package/dist/patterns/audit/index.cjs +7 -6
  196. package/dist/patterns/audit/index.d.cts +5 -5
  197. package/dist/patterns/audit/index.d.ts +5 -5
  198. package/dist/patterns/audit/index.js +1 -1
  199. package/dist/patterns/cqrs/index.cjs +7 -6
  200. package/dist/patterns/cqrs/index.d.cts +4 -4
  201. package/dist/patterns/cqrs/index.d.ts +4 -4
  202. package/dist/patterns/cqrs/index.js +1 -1
  203. package/dist/patterns/demo-shell/index.cjs +8 -7
  204. package/dist/patterns/demo-shell/index.d.cts +5 -5
  205. package/dist/patterns/demo-shell/index.d.ts +5 -5
  206. package/dist/patterns/demo-shell/index.js +1 -1
  207. package/dist/patterns/domain-templates/index.cjs +7 -6
  208. package/dist/patterns/domain-templates/index.d.cts +4 -4
  209. package/dist/patterns/domain-templates/index.d.ts +4 -4
  210. package/dist/patterns/domain-templates/index.js +1 -1
  211. package/dist/patterns/graphspec/index.cjs +26 -25
  212. package/dist/patterns/graphspec/index.d.cts +4 -4
  213. package/dist/patterns/graphspec/index.d.ts +4 -4
  214. package/dist/patterns/graphspec/index.js +1 -1
  215. package/dist/patterns/guarded-execution/index.cjs +7 -6
  216. package/dist/patterns/guarded-execution/index.d.cts +6 -6
  217. package/dist/patterns/guarded-execution/index.d.ts +6 -6
  218. package/dist/patterns/guarded-execution/index.js +1 -1
  219. package/dist/patterns/harness/index.cjs +11 -10
  220. package/dist/patterns/harness/index.d.cts +10 -7
  221. package/dist/patterns/harness/index.d.ts +10 -7
  222. package/dist/patterns/harness/index.js +1 -1
  223. package/dist/patterns/job-queue/index.cjs +7 -6
  224. package/dist/patterns/job-queue/index.d.cts +4 -4
  225. package/dist/patterns/job-queue/index.d.ts +4 -4
  226. package/dist/patterns/job-queue/index.js +1 -1
  227. package/dist/patterns/lens/index.cjs +7 -6
  228. package/dist/patterns/lens/index.d.cts +6 -6
  229. package/dist/patterns/lens/index.d.ts +6 -6
  230. package/dist/patterns/lens/index.js +1 -1
  231. package/dist/patterns/memory/index.cjs +7 -6
  232. package/dist/patterns/memory/index.d.cts +4 -4
  233. package/dist/patterns/memory/index.d.ts +4 -4
  234. package/dist/patterns/memory/index.js +1 -1
  235. package/dist/patterns/messaging/index.cjs +7 -6
  236. package/dist/patterns/messaging/index.d.cts +4 -4
  237. package/dist/patterns/messaging/index.d.ts +4 -4
  238. package/dist/patterns/messaging/index.js +1 -1
  239. package/dist/patterns/orchestration/index.cjs +7 -6
  240. package/dist/patterns/orchestration/index.d.cts +5 -5
  241. package/dist/patterns/orchestration/index.d.ts +5 -5
  242. package/dist/patterns/orchestration/index.js +1 -1
  243. package/dist/patterns/reactive-layout/index.cjs +8 -7
  244. package/dist/patterns/reactive-layout/index.d.cts +5 -5
  245. package/dist/patterns/reactive-layout/index.d.ts +5 -5
  246. package/dist/patterns/reactive-layout/index.js +1 -1
  247. package/dist/patterns/reduction/index.cjs +7 -6
  248. package/dist/patterns/reduction/index.d.cts +4 -4
  249. package/dist/patterns/reduction/index.d.ts +4 -4
  250. package/dist/patterns/reduction/index.js +1 -1
  251. package/dist/patterns/refine-loop/index.cjs +9 -8
  252. package/dist/patterns/refine-loop/index.d.cts +5 -5
  253. package/dist/patterns/refine-loop/index.d.ts +5 -5
  254. package/dist/patterns/refine-loop/index.js +1 -1
  255. package/dist/patterns/resilient-pipeline/index.cjs +1 -1
  256. package/dist/patterns/resilient-pipeline/index.d.cts +6 -6
  257. package/dist/patterns/resilient-pipeline/index.d.ts +6 -6
  258. package/dist/patterns/resilient-pipeline/index.js +1 -1
  259. package/dist/patterns/surface/index.cjs +14 -13
  260. package/dist/patterns/surface/index.d.cts +5 -5
  261. package/dist/patterns/surface/index.d.ts +5 -5
  262. package/dist/patterns/surface/index.js +1 -1
  263. package/dist/{reactive-layout-CpYb5qLP.d.cts → reactive-layout-5oEn8lHM.d.cts} +2 -2
  264. package/dist/{reactive-layout-D8u4wuUR.d.ts → reactive-layout-BAr6-_o5.d.ts} +2 -2
  265. package/dist/{reactive-log-DPzuUDj5.d.cts → reactive-log-5jFeNRmd.d.cts} +1 -1
  266. package/dist/{reactive-log-YuH9VYN8.d.ts → reactive-log-BOJDCI5x.d.ts} +1 -1
  267. package/dist/{reactive-map-CdbNoSgP.d.ts → reactive-map-BvDrRuwt.d.ts} +1 -1
  268. package/dist/{reactive-map-DUeRmb9d.d.cts → reactive-map-CmlPPKHN.d.cts} +1 -1
  269. package/dist/{resilience-CGRzhnD3.d.ts → resilience-CludlzcP.d.ts} +1 -1
  270. package/dist/{resilience-Ba5-b4WD.d.cts → resilience-Q6Bt_7y0.d.cts} +1 -1
  271. package/dist/{resilience-QAHKANT5.js → resilience-XRUF267O.js} +1 -1
  272. package/dist/{sugar-BV0htudb.d.cts → sugar-BHbAACDG.d.ts} +10 -12
  273. package/dist/{sugar-Dtyrq2_q.d.ts → sugar-CqR6DJ7v.d.cts} +10 -12
  274. package/dist/{topology-tree-DROUdq5B.d.cts → topology-tree-CVREibAc.d.cts} +1 -1
  275. package/dist/{topology-tree-CYHOwQZ_.d.ts → topology-tree-CkjojcB6.d.ts} +1 -1
  276. package/package.json +1 -1
  277. package/dist/chunk-6V3SEX2I.js +0 -1
  278. package/dist/chunk-7H6LGFUG.js +0 -64
  279. package/dist/chunk-CKCSDI7T.js +0 -6
  280. package/dist/chunk-QWAPKG3O.js +0 -2
  281. package/dist/chunk-RHESUC3V.js +0 -43
  282. package/dist/chunk-V6YQICXZ.js +0 -1
  283. package/dist/chunk-Z4HDAS2Q.js +0 -1
  284. package/dist/chunk-ZB5EHBIO.js +0 -1
@@ -1,23 +1,24 @@
1
- "use strict";var Zt=Object.defineProperty;var ro=Object.getOwnPropertyDescriptor;var oo=Object.getOwnPropertyNames;var so=Object.prototype.hasOwnProperty;var he=(n,e)=>()=>(n&&(e=n(n=0)),e);var en=(n,e)=>{for(var t in e)Zt(n,t,{get:e[t],enumerable:!0})},io=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of oo(e))!so.call(n,s)&&s!==t&&Zt(n,s,{get:()=>e[s],enumerable:!(r=ro(e,s))||r.enumerable});return n};var ao=n=>io(Zt({},"__esModule",{value:!0}),n);function xt(){return Ye>0||lt}function Un(){return Ye>0}function pt(n){Ye>0?ft.push(n):n()}function K(n){Ye+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(Ye-=1,Ye===0)if(e){if(!lt){let t=ft.splice(0);for(let r of t)try{r()}catch{}Fe.length=0,$e.length=0,Qe.length=0}}else uo()}}function uo(){let n=!lt;n&&(lt=!0);let e=[],t=0;try{for(;Fe.length>0||$e.length>0||Qe.length>0||n&&ft.length>0;){if(n&&ft.length>0){let o=ft.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(t+=1,t>1e3)throw Fe.length=0,$e.length=0,Qe.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(Fe.length>0?Fe:$e.length>0?$e:Qe).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{n&&(lt=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function _t(n,e,t){if(e.length===0)return;if(e.length===1){let u=t(e[0][0]);if(u<3||!xt()){n(e);return}(u>=5?Qe:u===4?$e:Fe).push(()=>n(e));return}let r=e.length,s=r,o=r,i=r,a=0;for(;a<r&&t(e[a][0])<3;)a++;for(s=a;a<r&&t(e[a][0])===3;)a++;for(o=a;a<r&&t(e[a][0])===4;)a++;i=a;let d=xt();if(s>0){let u=e.slice(0,s);n(u)}if(o>s){let u=e.slice(s,o);d?Fe.push(()=>n(u)):n(u)}if(i>o){let u=e.slice(o,i);d?$e.push(()=>n(u)):n(u)}if(r>i){let u=e.slice(i,r);d?Qe.push(()=>n(u)):n(u)}}var Ye,lt,Fe,$e,Qe,ft,ye=he(()=>{"use strict";Ye=0,lt=!1,Fe=[],$e=[],Qe=[],ft=[]});function ee(){return Math.trunc(performance.now()*1e6)}function ne(){return Date.now()*1e6}var Le=he(()=>{"use strict"});var Ge,w,B,R,ve,me,Te,G,k,N,Xe,tn,co,nn,lo,fo,rn,Hn,qn,Jn,on,Q=he(()=>{"use strict";Ge=Symbol.for("graphrefly/START"),w=Symbol.for("graphrefly/DATA"),B=Symbol.for("graphrefly/DIRTY"),R=Symbol.for("graphrefly/RESOLVED"),ve=Symbol.for("graphrefly/INVALIDATE"),me=Symbol.for("graphrefly/PAUSE"),Te=Symbol.for("graphrefly/RESUME"),G=Symbol.for("graphrefly/TEARDOWN"),k=Symbol.for("graphrefly/COMPLETE"),N=Symbol.for("graphrefly/ERROR"),Xe=Object.freeze([B]),tn=Object.freeze([R]),co=Object.freeze([ve]),nn=Object.freeze([Ge]),lo=Object.freeze([k]),fo=Object.freeze([G]),rn=Object.freeze([Xe]),Hn=Object.freeze([tn]),qn=Object.freeze([co]),Jn=Object.freeze([lo]),on=Object.freeze([fo])});function Qn(n,e){let t=new TextEncoder().encode(n.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${n.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let r=n.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let s=2+t.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=sn,o[i++]=t.length,o.set(t,i),i+=t.length,o[i++]=r>>>8&255,o[i++]=r&255,o.set(e,i),o}function Xn(n,e){if(n.length<Yn)throw new Error(`decodeEnvelope: bytes too short (${n.length} < ${Yn})`);let t=0,r=n[t++];if(r!==sn)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${sn})`);let s=n[t++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+s+2>n.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+s+2} bytes, have ${n.length})`);let o=new TextDecoder().decode(n.subarray(t,t+s));t+=s;let i=(n[t]<<8|n[t+1])>>>0;t+=2;let a=n.subarray(t),d=e.lookupCodec(o);if(d==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:d,codecVersion:i,payload:a}}function Zn(n){n.registerCodec(po)}var po,sn,Yn,an=he(()=>{"use strict";po={name:"json",version:1,contentType:"application/json",encode(n){let e=JSON.stringify(n);return new TextEncoder().encode(e)},decode(n,e){let t=new TextDecoder().decode(n);return JSON.parse(t)}},sn=1,Yn=4});function Nt(n){if(n==null)return Ze;let{type:e,id:t,...r}=n;return{type:e??"system",id:t??"",...r}}var Ze,un=he(()=>{"use strict";Ze={type:"system",id:""}});function er(n){n.registerMessageType(Ge,{tier:0,wireCrossing:!1}),n.registerMessageType(B,{tier:1,wireCrossing:!1}),n.registerMessageType(ve,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(me,{tier:2,wireCrossing:!1}),n.registerMessageType(Te,{tier:2,wireCrossing:!1}),n.registerMessageType(w,{tier:3,wireCrossing:!0}),n.registerMessageType(R,{tier:3,wireCrossing:!0}),n.registerMessageType(k,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(N,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(G,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Et,tr=he(()=>{"use strict";Q();Et=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let r=this._messageTypes.get(t);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function dn(n){let e=ho.filter(t=>n({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}var Ne,ho,St=he(()=>{"use strict";Ne=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}},ho=["human","llm","wallet","system"]});function cn(n){if(n===void 0)return null;if(typeof n=="number"){if(!Number.isFinite(n))throw new TypeError(`Cannot hash non-finite number: ${n}`);if(Number.isInteger(n)&&!Number.isSafeInteger(n))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${n}. Cross-language cid parity is not guaranteed for unsafe integers.`);return n}if(typeof n=="string"||typeof n=="boolean"||n===null)return n;if(Array.isArray(n))return n.map(cn);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=cn(n[t]);return e}return null}function bo(n){let e=go.encode(n),t=e.length,r=t*8,s=t+9+63&-64,o=new Uint8Array(s);o.set(e),o[t]=128;let i=new DataView(o.buffer);i.setUint32(s-4,r>>>0,!1),i.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,d=3144134277,u=1013904242,c=2773480762,f=1359893119,p=2600822924,h=528734635,l=1541459225,m=new Uint32Array(64),g=(y,v)=>y>>>v|y<<32-v;for(let y=0;y<s;y+=64){for(let L=0;L<16;L++)m[L]=i.getUint32(y+L*4,!1);for(let L=16;L<64;L++){let $=m[L-15],M=m[L-2],z=g($,7)^g($,18)^$>>>3,te=g(M,17)^g(M,19)^M>>>10;m[L]=m[L-16]+z+m[L-7]+te>>>0}let v=a,T=d,x=u,_=c,E=f,S=p,C=h,F=l;for(let L=0;L<64;L++){let $=g(E,6)^g(E,11)^g(E,25),M=E&S^~E&C,z=F+$+M+mo[L]+m[L]>>>0,te=g(v,2)^g(v,13)^g(v,22),j=v&T^v&x^T&x,ie=te+j>>>0;F=C,C=S,S=E,E=_+z>>>0,_=x,x=T,T=v,v=z+ie>>>0}a=a+v>>>0,d=d+T>>>0,u=u+x>>>0,c=c+_>>>0,f=f+E>>>0,p=p+S>>>0,h=h+C>>>0,l=l+F>>>0}let b=y=>y.toString(16).padStart(8,"0");return b(a)+b(d)+b(u)+b(c)+b(f)+b(p)+b(h)+b(l)}function ln(n){let e=cn(n??null),t=JSON.stringify(e);return bo(t).slice(0,16)}function yo(){let n=globalThis.crypto;if(n?.randomUUID)return n.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function fn(n,e,t){let r=t?.id??yo();if(n===0)return{id:r,version:0};let o=(t?.hash??ln)(e);return{id:r,version:0,cid:o,prev:null}}function nr(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}var mo,go,rr=he(()=>{"use strict";mo=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]),go=new TextEncoder});function ir(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function pn(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function Ot(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}function I(n,e,t){let r=ar(n)?n:[],s=typeof n=="function"?n:typeof e=="function"?e:void 0,o={};return ar(n)?o=(hn(e)?e:t)??{}:hn(n)?o=n:o=(hn(e)?e:t)??{},new re(r,s,o)}var or,sr,vo,To,le,re,ar,hn,we=he(()=>{"use strict";an();un();ye();Le();tr();St();Q();rr();or=()=>{},sr=100;vo=(n,e,t,r)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},To=(n,e,t,r)=>{let s=n;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[nn]:[nn,[w,o]];s._status==="dirty"&&i.push(Xe),_t(e,i,s._config.tierOf)},le=new Et({onMessage:vo,onSubscribe:To});er(le);Zn(le);re=class n{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,r){this._config=r.config??le,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=t,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??ln;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?fn(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(ir);let o={};for(let[a,d]of Object.entries(r.meta??{})){let u={initial:d,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),o[a]=new n([],void 0,u)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[w,a]])},down(a){i._emit(Ot(a))},up(a){i._emitUp(Ot(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let s=t?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??t?.id,d=i?.version??0,u=fn(e,o,{id:a,hash:s});u.version=d,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=Nt(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!t&&!r)return;let s=Nt(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new Ne({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new Ne({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:ne()}}down(e,t){let r=Ot(e);r.length!==0&&(this._checkGuard(t),this._emit(r))}emit(e,t){this._checkGuard(t),this._emit([[w,e]])}up(e,t){if(this._deps.length===0)return;let r=Ot(e);if(r.length===0)return;this._checkGuard(t);let s=t??{internal:!0};this._validateUpTiers(r);for(let o of this._deps)o.node.up?.(r,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let r of e){let s=t(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let d=Nt(t);if(!this._guard(d,"observe"))throw new Ne({actor:d,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)pn(d)}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let r=0;r<e;r++){let s=r,o=this._deps[r];o.unsub=or,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,d=!1;for(let u of i)a(u[0])>=3&&(d=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:s},this._actions);d&&this._maybeRunFnOnSettlement()}),t++}}catch(r){this._deps[t].unsub=null;for(let s=0;s<t;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}pn(o)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let t=this._deps.length,r=ir(e);if(this._deps.push(r),this._sinks==null)return t;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(rn),r.unsub=or;try{r.unsub=e.subscribe(s=>{if(r.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(r){this._emit([[N,this._wrapFnError("cleanup threw",r)]])}else if(t!=null&&typeof t=="object"){let r=t.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[N,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let r of this._deps){if(r.unsub!=null){let s=r.unsub;r.unsub=null;try{s()}catch{}}pn(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let r=this._deps[e],s=t[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(o)}if(s!==Ge){if(s===B){this._depDirtied(r);return}if(s===ve){this._depInvalidated(r),this._emit(qn);return}if(s===me||s===Te){this._emit([t]);return}if(s===G){this._emit(on);return}if(s===w)this._depSettledAsData(r,t[1]);else if(s===R)this._depSettledAsResolved(r);else if(s===k)this._depSettledAsTerminal(r,!0);else if(s===N)this._depSettledAsTerminal(r,t[1]);else{this._emit([t]);return}if(!this._fn){(s===w||s===R)&&this._emit([t]),(s===k||s===N)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(rn))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Hn),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[N,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(Jn)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[N,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[N,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let t=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=t[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[N,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>sr?(this._rerunDepth=0,this._emit([[N,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${sr} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let r=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[Xe,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let d of e){let u=t(d[0]);u<i&&(r=!1),u===3&&(s=!0),d[0]===B&&(o=!0),i=u}let a=e;if(!r){let d=e.map((u,c)=>({m:u,i:c,tier:t(u[0])}));d.sort((u,c)=>u.tier-c.tier||u.i-c.i),a=d.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let d=0;for(;d<a.length&&t(a[d][0])===0;)d++;return d===0?[Xe,...a]:[...a.slice(0,d),Xe,...a.slice(d)]}return a}_emit(e){if(e.length===0)return;let t=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(d=>d[0]===G||d[0]===ve);if(a.length===0)return;t=a}t=this._frameBatch(t);let s=null;for(let a=0;a<t.length;a++){let d=t[a],u=d[0];if(u!==me&&u!==Te){s?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===me?"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 f=d[1];if(u===me)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))c=!1;else if(this._pauseLocks.delete(f),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?s?.push(d):s==null&&(s=t.slice(0,a))}if(s!=null){if(s.length===0)return;t=s}if(this._hasMeta&&t.some(a=>a[0]===G))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(on)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(t);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,d=[];for(let u of o){let c=a(u[0]);c<3||c===5?d.push(u):this._pauseBuffer.push(u)}d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[N,i]])}_updateState(e){let t=this._config.tierOf,r,s,o=-1,i=0;for(let c of e)t(c[0])===3&&i++;let a=i<=1,d=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===w){d=c;break}}for(let c=0;c<e.length;c++){let f=e[c],p=f[0];if(p===w){if(f.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,f[1])}catch(l){s=this._wrapFnError("equals threw",l),o=c;break}if(h){r==null&&(r=e.slice(0,c)),r.push(tn),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(d<0||c===d)&&nr(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),p===B)this._status="dirty";else if(p===R)this._status="resolved";else if(p===k)this._status="completed";else if(p===N)this._status="errored";else if(p===ve){this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let l=h.invalidate;if(typeof l=="function")try{l()}catch{}}}else p===G&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:u,equalsError:s}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let r of t)r(e)};_dispatchOrAccumulate(e){if(Un()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],pt(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}_t(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);_t(this._deliverToSinks,t,this._config.tierOf)}},ar=n=>Array.isArray(n),hn=n=>typeof n=="object"&&n!=null&&!Array.isArray(n)});function ur(n,e,t){return t?!1:n.some((r,s)=>!(r!=null&&r.length>0)&&e.prevData[s]===void 0)}function V(n,e){return I([],{...e,initial:n})}function O(n,e){return I((r,s,o)=>n(s,o)??void 0,{describeKind:"producer",...e})}function ke(n,e,t){let r=t?.partial??!1;return I(n,(o,i,a)=>{if(ur(o,a,r)){i.down([[R]]);return}let d=o.map((u,c)=>u!=null&&u.length>0?u.at(-1):a.prevData[c]);i.emit(e(d,a))},{describeKind:"derived",...t})}function Rt(n,e,t){let r=t?.partial??!1;return I(n,(o,i,a)=>{if(ur(o,a,r)){i.down([[R]]);return}let d=o.map((u,c)=>u!=null&&u.length>0?u.at(-1):a.prevData[c]);return e(d,i,a)??void 0},{describeKind:"effect",...t})}var ue=he(()=>{"use strict";Q();we()});var cr={};en(cr,{NS_PER_MS:()=>fe,NS_PER_SEC:()=>Ae,constant:()=>mn,decorrelatedJitter:()=>vn,exponential:()=>bn,fibonacci:()=>yn,linear:()=>gn,resolveBackoffPreset:()=>ze,withMaxAttempts:()=>dr});function Ke(n){return n<0?0:n}function wo(n,e){return e==="none"?n:e==="full"?Math.random()*n:n/2+Math.random()*(n/2)}function ko(n,e){return n+Math.random()*(e-n)}function mn(n){let e=Ke(n);return()=>e}function gn(n,e){let t=Ke(n),r=e===void 0?t:Ke(e);return s=>t+r*Math.max(0,s)}function bn(n){let e=Ke(n?.baseNs??1e8),t=n?.factor!==void 0&&n.factor<1?1:n?.factor??2,r=Ke(n?.maxDelayNs??30*1e9),s=n?.jitter??"none";return o=>{let i;if(e===0)i=0;else if(t===1)i=e;else{let a=r/e,d=1;for(let u=0;u<Math.max(0,o);u++){if(d>=a){d=a;break}d*=t}i=e*d,i>r&&(i=r)}return wo(i,s)}}function yn(n=100*1e6,e=30*1e9){let t=Ke(n),r=Ke(e);function s(o){if(o<=0)return 1;let i=1,a=2;for(let d=1;d<o;d++){let u=i+a;i=a,a=u}return a}return o=>{let i=s(o)*t;return i<=r?i:r}}function vn(n=100*1e6,e=30*1e9){return(t,r,s)=>{let i=Math.min(e,(s??n)*3);return ko(n,i)}}function dr(n,e){return(t,r,s)=>t>=e?null:n(t,r,s)}function ze(n){if(n==="constant")return mn(1*1e9);if(n==="linear")return gn(1*1e9);if(n==="exponential")return bn();if(n==="fibonacci")return yn();if(n==="decorrelatedJitter")return vn();throw new Error(`Unknown backoff preset: "${String(n)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var fe,Ae,ht=he(()=>{"use strict";fe=1e6,Ae=1e9});function mt(n,e,t){let r=new Set;for(let s of n.split(",")){let[o,i]=s.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${s}`);let d,u;if(o==="*")d=e,u=t;else if(o.includes("-")){let[c,f]=o.split("-");d=Number.parseInt(c,10),u=Number.parseInt(f,10)}else d=Number.parseInt(o,10),u=d;if(Number.isNaN(d)||Number.isNaN(u))throw new Error(`Invalid cron field: ${n}`);if(d<e||u>t)throw new Error(`Cron field out of range: ${n} (${e}-${t})`);if(d>u)throw new Error(`Invalid cron range: ${d}-${u} in ${n}`);for(let c=d;c<=u;c+=a)r.add(c)}return r}function wn(n){let e=n.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:mt(e[0],0,59),hours:mt(e[1],0,23),daysOfMonth:mt(e[2],1,31),months:mt(e[3],1,12),daysOfWeek:mt(e[4],0,6)}}function kn(n,e){return n.minutes.has(e.getMinutes())&&n.hours.has(e.getHours())&&n.daysOfMonth.has(e.getDate())&&n.months.has(e.getMonth()+1)&&n.daysOfWeek.has(e.getDay())}var xn=he(()=>{"use strict"});var Oe,Mt=he(()=>{"use strict";Oe=class{_timer;_gen=0;start(e,t){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&t()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var pr={};en(pr,{CircuitOpenError:()=>tt,RateLimiterOverflowError:()=>nt,TimeoutError:()=>rt,circuitBreaker:()=>Nn,fallback:()=>On,rateLimiter:()=>Sn,retry:()=>_n,retrySource:()=>gt,timeout:()=>Rn,tokenBucket:()=>Ct,withBreaker:()=>En,withStatus:()=>bt});function je(n){return{describeKind:"derived",...n}}function xo(n){return n<0?0:n}function At(n){return n[1]}function fr(n){if(typeof n!="number"||!Number.isFinite(n))throw new TypeError("backoff strategy must return a finite number");return n<0?0:n}function _n(n,e){let t=e?.count,r=e?.backoff,s=t!==void 0?t:r===void 0?0:2147483647;if(s<0)throw new RangeError("retry count must be >= 0");let o=r===void 0?null:typeof r=="string"?ze(r):r;return O(i=>{let a=0,d=!1,u=null,c,f=new Oe;function p(){c?.(),c=void 0}function h(m){if(d)return;if(a>=s){p(),i.down([[N,m]]);return}let g=o===null?0:o(a,m,u);if(g==null){p(),i.down([[N,m]]);return}let b;try{b=fr(g)}catch{p(),i.down([[N,m]]);return}u=b,a+=1,p();let y=b>0?b/1e6:1;f.start(y,()=>{d||l()})}function l(){f.cancel(),p(),c=n.subscribe(m=>{if(!d)for(let g of m){let b=g[0];if(b===B)i.down([[B]]);else if(b===w)a=0,u=null,i.emit(g[1]);else if(b===R)i.down([[R]]);else if(b===k)p(),i.down([[k]]);else if(b===N){h(At(g));return}else i.down([g])}})}return l(),()=>{d=!0,f.cancel(),p()}},{...je(),initial:n.cache})}function gt(n,e){let t=e?.count,r=e?.backoff,s=t!==void 0?t:r===void 0?0:2147483647;if(s<0)throw new RangeError("retry count must be >= 0");let o=r===void 0?null:typeof r=="string"?ze(r):r;return O(i=>{let a=0,d=!1,u=null,c,f=new Oe;function p(){c?.(),c=void 0}function h(m){if(d)return;if(a>=s){p(),i.down([[N,m]]);return}let g=o===null?0:o(a,m,u);if(g==null){p(),i.down([[N,m]]);return}let b;try{b=fr(g)}catch{p(),i.down([[N,m]]);return}u=b,a+=1,p();let y=b>0?b/1e6:1;f.start(y,()=>{d||l()})}function l(){f.cancel(),p();let m;try{m=n()}catch(g){h(g);return}c=m.subscribe(g=>{if(!d)for(let b of g){let y=b[0];if(y===B)i.down([[B]]);else if(y===w)a=0,u=null,i.emit(b[1]);else if(y===R)i.down([[R]]);else if(y===k)p(),i.down([[k]]);else if(y===N){h(At(b));return}else i.down([b])}})}return l(),()=>{d=!0,f.cancel(),p()}},{...je(),initial:e?.initial})}function Nn(n){let e=Math.max(1,n?.failureThreshold??5),t=xo(n?.cooldownNs??30*1e9),r=n?.cooldown??null,s=Math.max(1,n?.halfOpenMax??1),o=n?.now??ee,i="closed",a=0,d=0,u=0,c=t,f=0;function p(){if(!r)return t;let m=r(d);return m!==null?m:t}function h(){i="open",c=p(),u=o(),f=0}return{canExecute(){return i==="closed"?!0:i==="open"?o()-u>=c?(i="half-open",f=1,!0):!1:f<s?(f++,!0):!1},recordSuccess(){i==="half-open"?(i="closed",a=0,d=0):i==="closed"&&(a=0)},recordFailure(m){if(i==="half-open"){d++,h();return}i==="closed"&&(a++,a>=e&&h())},get state(){return i},get failureCount(){return a},reset(){i="closed",a=0,d=0,f=0}}}function En(n,e){let t=e?.onOpen??"skip";return r=>{let s=I([],(o,i)=>{function a(){s.meta.breakerState.down([[w,n.state]])}let d=r.subscribe(u=>{for(let c of u){let f=c[0];f===B?i.down([[B]]):f===w?n.canExecute()?(a(),i.emit(c[1])):(a(),t==="error"?i.down([[N,new tt]]):i.down([[R]])):f===R?i.down([[R]]):f===k?(n.recordSuccess(),a(),i.down([[k]])):f===N?(n.recordFailure(At(c)),a(),i.down([c])):i.down([c])}});return a(),d},{...je(),meta:{breakerState:n.state},completeWhenDepsComplete:!1,initial:r.cache});return{node:s,breakerState:s.meta.breakerState}}}function Ct(n,e){if(n<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let t=n,r=ee();function s(o){if(e>0){let i=o-r;t=Math.min(n,t+i/1e9*e)}r=o}return{available(){return s(ee()),t},tryConsume(o=1){if(o<=0)return!0;let i=ee();return s(i),t>=o?(t-=o,!0):!1},putBack(o=1){o<=0||(s(ee()),t=Math.min(n,t+o))}}}function Sn(n,e){let{maxEvents:t,windowNs:r}=e;if(t<=0)throw new RangeError("maxEvents must be > 0");if(r<=0)throw new RangeError("windowNs must be > 0");let s=e.maxBuffer;if(s!==void 0&&s<1)throw new RangeError("maxBuffer must be >= 1");let o=e.onOverflow??"drop-newest",i=t*1e9/r;return O(a=>{let d=Ct(t,i),u=[],c=new Oe,f=!1,p=1e9/i;function h(){for(;u.length>0;)if(d.tryConsume(1))a.emit(u.shift());else{c.start(Math.max(1,p/1e6),h);return}}let l=n.subscribe(m=>{for(let g of m){if(f)return;let b=g[0];if(b===B)a.down([[B]]);else if(b===w){if(s!==void 0&&u.length>=s){if(o!=="drop-newest")if(o==="drop-oldest")u.shift(),u.push(g[1]);else{f=!0,c.cancel(),u.length=0,a.down([[N,new nt(s)]]);return}}else u.push(g[1]);h()}else if(b===R)a.down([[R]]);else if(b===k)f=!0,c.cancel(),u.length=0,a.down([[k]]);else if(b===N)f=!0,c.cancel(),u.length=0,a.down([g]);else if(b===G){f=!0,c.cancel(),u.length=0,a.down([g]);return}else a.down([g])}});return()=>{f=!0,c.cancel(),l()}},{...je(),initial:n.cache})}function bt(n,e){let t=e?.initialStatus??"pending",r=I([],(s,o)=>{let i=t;return r.meta.status.down([[w,t]]),r.meta.error.down([[w,null]]),n.subscribe(d=>{for(let u of d){let c=u[0];if(c===B)o.down([[B]]);else if(c===w)i==="errored"?K(()=>{r.meta.error.down([[w,null]]),r.meta.status.down([[w,"active"]])}):r.meta.status.down([[w,"active"]]),i="active",o.emit(u[1]);else if(c===R)o.down([[R]]);else if(c===k)r.meta.status.down([[w,"completed"]]),i="completed",o.down([[k]]);else if(c===N){let f=At(u);K(()=>{r.meta.error.down([[w,f]]),r.meta.status.down([[w,"errored"]])}),i="errored",o.down([u])}else o.down([u])}})},{...je(),meta:{status:t,error:null},completeWhenDepsComplete:!1,resubscribable:!0,initial:n.cache});return{node:r,status:r.meta.status,error:r.meta.error}}function _o(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function No(n){return n!=null&&typeof n.then=="function"}function Eo(n){return n!=null&&typeof n=="object"&&typeof n[Symbol.asyncIterator]=="function"}function On(n,e){return O(t=>{let r,s;function o(){s?.(),s=void 0,_o(e)||No(e)||Eo(e)?r=de(e).subscribe(a=>{t.down(a)}):(t.emit(e),t.down([[k]]))}return s=n.subscribe(i=>{for(let a of i){let d=a[0];if(d===B)t.down([[B]]);else if(d===w)t.emit(a[1]);else if(d===R)t.down([[R]]);else if(d===k)t.down([[k]]);else if(d===N){o();return}else if(d===G){r?.(),t.down([a]);return}else t.down([a])}}),()=>{s?.(),r?.()}},{...je(),initial:n.cache})}function Rn(n,e){if(e<=0)throw new RangeError("timeoutNs must be > 0");return O(t=>{let r=!1,s=new Oe;function o(){let a=e/1e6;s.start(a,()=>{r||(r=!0,i(),t.down([[N,new rt(e)]]))})}let i=n.subscribe(a=>{for(let d of a){if(r)return;let u=d[0];if(u===B)t.down([[B]]);else if(u===w)o(),t.emit(d[1]);else if(u===R)t.down([[R]]);else if(u===k){s.cancel(),r=!0,t.down([[k]]);return}else if(u===N){s.cancel(),r=!0,t.down([d]);return}else if(u===G){s.cancel(),r=!0,t.down([d]);return}else t.down([d])}});return o(),()=>{r=!0,s.cancel(),i()}},{...je(),initial:n.cache})}var tt,nt,rt,Dt=he(()=>{"use strict";ye();Le();Q();we();ue();ht();Ie();Mt();tt=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};nt=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};rt=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});function Ee(n){return{describeKind:"producer",...n}}function mr(n){return/[\\^$+?.()|[\]{}]/.test(n)?`\\${n}`:n}function So(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){n[t+1]==="*"?(e+=".*",t+=1):e+="[^/]*";continue}e+=mr(r)}return e+="$",new RegExp(e)}function Oo(n,e){for(let t of e)if(t.test(n))return!0;return!1}function Ro(n,e){let t=I([n],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[R]]);return}for(let a of i)o.emit(a)},{describeKind:"derived",initial:n.cache}),r=t.subscribe.bind(t);return t.subscribe=(s,o)=>(e(s),r(s,o)),t}function We(n,e){let{signal:t,period:r,...s}=e??{};return O(o=>{let i=!1,a=0,d,u,c=()=>{i=!0,d!==void 0&&clearTimeout(d),u!==void 0&&clearInterval(u),t?.removeEventListener("abort",p)},f=()=>{i||(r!=null?(o.emit(a++),u=setInterval(()=>{i||o.emit(a++)},r)):(i=!0,t?.removeEventListener("abort",p),o.emit(a++),o.down([[k]])))},p=()=>{i||(c(),o.down([[N,t.reason]]))};if(t?.aborted){p();return}return d=setTimeout(f,n),t?.addEventListener("abort",p,{once:!0}),c},Ee(s))}function Mo(n){let{signal:e,...t}=n??{};return O(r=>{let s=!1,o,i,a=!1,d=!1,u=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,c=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,f=typeof document<"u"?document:void 0,p=()=>{o!==void 0&&c&&c(o),i!==void 0&&clearTimeout(i),o=void 0,i=void 0},h=()=>{s=!0,p(),a&&(e?.removeEventListener("abort",l),a=!1),d&&f&&(f.removeEventListener("visibilitychange",b),d=!1)},l=()=>{s||(h(),r.down([[N,e.reason]]))},m=y=>{s||(r.emit(y),g())},g=()=>{s||(u&&(!f||f.visibilityState!=="hidden")?o=u(m):i=setTimeout(()=>m(performance.now()),16))},b=()=>{s||(p(),g())};return e?.aborted?(l(),h):(e?.addEventListener("abort",l,{once:!0}),a=e!==void 0,f&&u&&(f.addEventListener("visibilitychange",b),d=!0),g(),h)},Ee(t))}function Ao(n,e){let t=wn(n),{tickMs:r,output:s,...o}=e??{},i=r??6e4,a=s==="date";return O(d=>{let u=-1,c=()=>{let p=new Date,h=p.getFullYear()*1e8+(p.getMonth()+1)*1e6+p.getDate()*1e4+p.getHours()*100+p.getMinutes();h!==u&&kn(t,p)&&(u=h,d.emit(a?p:ne()))};c();let f=setInterval(c,i);return()=>clearInterval(f)},{...Ee(o),name:o.name??`cron:${n}`})}function Co(n,e,t){let{capture:r,passive:s,once:o,...i}=t??{};return O(a=>{let d=c=>{a.emit(c)},u={capture:r,passive:s,once:o};return n.addEventListener(e,d,u),()=>n.removeEventListener(e,d,u)},Ee(i))}function Cn(n,e){return O(t=>{let r=!1;try{for(let s of n){if(r)return;t.emit(s)}r||t.down([[k]])}catch(s){r||t.down([[N,s]])}return()=>{r=!0}},Ee(e))}function Do(n){return n!=null&&typeof n.then=="function"}function gr(n,e){let{signal:t,...r}=e??{};return O(s=>{let o=!1,i=()=>{o||(o=!0,s.down([[N,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(n).then(a=>{o||(o=!0,t?.removeEventListener("abort",i),s.emit(a),s.down([[k]]))},a=>{o||(o=!0,t?.removeEventListener("abort",i),s.down([[N,a]]))}),()=>{o=!0,t?.removeEventListener("abort",i)}},Ee(r))}function br(n,e){let{signal:t,...r}=e??{};return O(s=>{let o=new AbortController,i=()=>o.abort(t?.reason);t?.aborted?o.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let a=t??o.signal,d=!1,u=n[Symbol.asyncIterator](),c=()=>{d||a.aborted||Promise.resolve(u.next()).then(f=>{if(!(d||a.aborted)){if(f.done){s.down([[k]]);return}s.emit(f.value),c()}},f=>{!d&&!a.aborted&&s.down([[N,f]])})};return c(),()=>{d=!0,t?.removeEventListener("abort",i),o.abort(),Promise.resolve(u.return?.()).catch(()=>{})}},Ee(r))}function Po(n){return n!=null&&typeof n=="object"&&"cache"in n&&typeof n.subscribe=="function"}function de(n,e){if(Po(n))return n;if(Do(n))return gr(n,e);if(n!=null){let t=n;if(typeof t[Symbol.asyncIterator]=="function")return br(n,e);if(typeof t[Symbol.iterator]=="function")return Cn(n,e)}return yr(n)}function yr(...n){return Cn(n,void 0)}function Io(n){return O(e=>{e.down([[k]])},Ee(n))}function Lo(n){return O(()=>{},Ee(n))}function Bo(n,e){return O(t=>{t.down([[N,n]])},Ee(e))}function Ue(n,e,t){return I([n],(s,o)=>{let i=s[0];if(i!=null&&i.length>0)for(let a of i)e(a)},{describeKind:"effect",...t}).subscribe(()=>{})}function Vo(n,e){return I([n],(t,r,s)=>{s.store.buf||(s.store.buf=[]);let o=s.store.buf,i=t[0];if(i!=null&&i.length>0)for(let a of i)o.push(a);if(s.terminalDeps[0]===!0){r.emit([...o]),r.down([[k]]);return}(i==null||i.length===0)&&r.down([[R]])},{describeKind:"derived",completeWhenDepsComplete:!1,...e})}function Fo(n,e){return O(t=>n.subscribe(r=>{t.down(r)}),{...Ee(e),initial:n.cache})}function Dn(n,e,t){if(e<1)throw new RangeError("replay expects bufferSize >= 1");let r=[],s=O(o=>n.subscribe(i=>{for(let a of i)a[0]===w&&(r.push(a[1]),r.length>e&&r.shift());o.down(i)}),{...Ee(t),initial:n.cache});return Ro(s,o=>{for(let i of r)o([[w,i]])})}function $o(n,e){return Dn(n,1,e)}function Pn(n){return new Promise((e,t)=>{let r=!1,s=!1,o;o=n.subscribe(i=>{for(let a of i){if(r)return;if(a[0]===w){r=!0,e(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===N){r=!0,t(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===k){r=!0,t(new Error("completed without DATA")),o?(o(),o=void 0):s=!0;return}}}),s&&(o?.(),o=void 0)})}function An(n,e){return new Promise((t,r)=>{let s=!1,o=!1,i;i=n.subscribe(a=>{for(let d of a){if(s)return;if(d[0]===w){let u=d[1];if(e(u)){s=!0,t(u),i?(i(),i=void 0):o=!0;return}}if(d[0]===N){s=!0,r(d[1]),i?(i(),i=void 0):o=!0;return}if(d[0]===k){s=!0,r(new Error("completed without matching value")),i?(i(),i=void 0):o=!0;return}}}),o&&(i?.(),i=void 0)})}async function Go(n,e){let t=e?.predicate??(s=>s!=null);if(e?.timeoutMs==null||e.timeoutMs<=0)return await An(n,t);if(Mn===void 0){let[s,o]=await Promise.all([Promise.resolve().then(()=>(Dt(),pr)),Promise.resolve().then(()=>(ht(),cr))]);Mn=s.timeout,hr=o.NS_PER_MS}let r=Mn(n,e.timeoutMs*hr);return await An(r,t)}function Pt(n){return n.subscribe(()=>{})}function zo(n){let e=V(0);return{node:e,increment(){let t=e.cache??0;return t>=n?!1:(e.down([[B],[w,t+1]]),!0)},get(){return e.cache??0},atCap(){return(e.cache??0)>=n}}}var Mn,hr,Ko,Ie=he(()=>{"use strict";Le();Q();we();ue();xn();Ko=Dn});var ya={};en(ya,{CircuitOpenError:()=>tt,NS_PER_MS:()=>fe,NS_PER_SEC:()=>Ae,NativeIndexBackend:()=>Gt,NativeListBackend:()=>Kt,NativeLogBackend:()=>zt,NativeMapBackend:()=>Ft,NativePubSubBackend:()=>$t,RateLimiterOverflowError:()=>nt,ResettableTimer:()=>Oe,TimeoutError:()=>rt,audit:()=>ds,awaitSettled:()=>Go,buffer:()=>cs,bufferCount:()=>ls,bufferTime:()=>ps,cached:()=>$o,cascadingCache:()=>ki,catchError:()=>xs,checkpointToRedis:()=>pi,checkpointToS3:()=>fi,circuitBreaker:()=>Nn,combine:()=>Tr,combineLatest:()=>Ts,concat:()=>ns,concatMap:()=>ss,constant:()=>mn,createTransport:()=>Je,createWatermarkController:()=>wi,csvRows:()=>Js,debounce:()=>kr,debounceTime:()=>ws,decorrelatedJitter:()=>vn,delay:()=>as,deserializeError:()=>ct,dictStorage:()=>Vi,distill:()=>Ni,distinctUntilChanged:()=>Xo,elementAt:()=>Yo,empty:()=>Io,escapeRegexChar:()=>mr,exhaustMap:()=>os,exponential:()=>bn,externalBundle:()=>Tn,externalProducer:()=>et,fallback:()=>On,fibonacci:()=>yn,filter:()=>Lt,find:()=>Jo,first:()=>In,firstValueFrom:()=>Pn,firstWhere:()=>An,flatMap:()=>is,forEach:()=>Ue,fromAny:()=>de,fromAsyncIter:()=>br,fromCSV:()=>qs,fromClickHouseWatch:()=>Xs,fromCron:()=>Ao,fromDrizzle:()=>yi,fromEvent:()=>Co,fromHTTP:()=>Er,fromHTTPPoll:()=>Cs,fromHTTPStream:()=>As,fromIter:()=>Cn,fromKafka:()=>js,fromKysely:()=>vi,fromMCP:()=>Is,fromNATS:()=>ti,fromNDJSON:()=>Qs,fromOTel:()=>Ls,fromPrisma:()=>bi,fromPrometheus:()=>Ks,fromPromise:()=>gr,fromPulsar:()=>Zs,fromRabbitMQ:()=>ri,fromRaf:()=>Mo,fromRedisStream:()=>Us,fromSSE:()=>Ms,fromSqlite:()=>hi,fromSqliteCursor:()=>mi,fromStatsD:()=>Fs,fromSyslog:()=>Bs,fromTimer:()=>We,fromWebSocket:()=>Nr,fromWebSocketReconnect:()=>Ps,fromWebhook:()=>Ns,globToRegExp:()=>So,interval:()=>gs,keepalive:()=>Pt,last:()=>qo,linear:()=>gn,lru:()=>Cr,map:()=>It,matchesAnyPattern:()=>Oo,matchesCron:()=>kn,memoryStorage:()=>Bi,merge:()=>yt,mergeMap:()=>wr,nameToSignal:()=>ut,ndjsonRows:()=>Ys,never:()=>Lo,of:()=>yr,pairwise:()=>Zo,parseCron:()=>wn,parsePrometheusText:()=>Rr,parseStatsD:()=>Gs,parseSyslog:()=>Vs,pausable:()=>ys,pubsub:()=>Si,race:()=>rs,rateLimiter:()=>Sn,reactiveCounter:()=>zo,reactiveIndex:()=>Mi,reactiveList:()=>Ai,reactiveLog:()=>Di,reactiveMap:()=>Vn,reactiveSink:()=>se,reduce:()=>Wo,repeat:()=>bs,replay:()=>Dn,rescue:()=>_r,resolveBackoffPreset:()=>ze,retry:()=>_n,retrySource:()=>gt,sample:()=>us,scan:()=>jo,serializeError:()=>dt,share:()=>Fo,shareReplay:()=>Ko,signalToName:()=>qe,singleFromAny:()=>Pi,singleNodeFromAny:()=>Ii,skip:()=>vr,sortJsonValue:()=>jt,stableJsonString:()=>Li,stratify:()=>fa,switchMap:()=>Ce,take:()=>Bt,takeUntil:()=>Ho,takeWhile:()=>Uo,tap:()=>Qo,throttle:()=>xr,throttleTime:()=>ks,throwError:()=>Bo,timeout:()=>Rn,toArray:()=>Vo,toCSV:()=>si,toClickHouse:()=>ii,toFile:()=>Ar,toHTTP:()=>Es,toKafka:()=>Ws,toLoki:()=>ci,toMongo:()=>di,toNATS:()=>ni,toObservable:()=>Ei,toPostgres:()=>ui,toPulsar:()=>ei,toRabbitMQ:()=>oi,toReadableStream:()=>Rs,toRedisStream:()=>Hs,toS3:()=>ai,toSSE:()=>Ss,toSSEBytes:()=>Os,toSqlite:()=>gi,toTempo:()=>li,toWebSocket:()=>Ds,tokenBucket:()=>Ct,valve:()=>vs,verifiable:()=>_i,window:()=>ms,windowCount:()=>fs,windowTime:()=>hs,withBreaker:()=>En,withLatestFrom:()=>es,withMaxAttempts:()=>dr,withStatus:()=>bt,workerBridge:()=>Zr,workerSelf:()=>eo,zip:()=>ts});module.exports=ao(ya);ye();Le();Q();we();ue();ye();Q();ue();function lr(n){return{describeKind:"producer",...n}}function et(n,e){return O(t=>{let r=!0,s={emit(i){r&&t.emit(i)},error(i){r&&(r=!1,t.down([[N,i]]))},complete(){r&&(r=!1,t.down([[k]]))}},o;try{let i=n(s);o=typeof i=="function"?i:void 0}catch(i){return s.error(i),()=>{r=!1}}return()=>{r=!1;try{o?.()}catch{}}},lr(e))}function Tn(n,e,t){let r=!0,s,o=0,i=0,a={},d=[],u=()=>{let h=s;s=void 0;try{h?.()}catch{}};for(let h of e){let l=t?.name?`${t.name}::${h}`:h,m=t?.channelOpts?.[h],g=O(b=>(o++,()=>{i++,o>0&&i>=o&&i>=e.length&&u()}),lr({...m,name:l}));a[h]=g,d.push(g)}let c={};for(let h of e)c[h]=l=>{r&&a[h].down([[w,l]])};c.error=h=>{r&&(r=!1,K(()=>{for(let l of d)l.down([[N,h]])}),u())},c.complete=()=>{r&&(r=!1,K(()=>{for(let h of d)h.down([[k]])}),u())};let f=n(c);return s=typeof f=="function"?f:void 0,Object.assign(a,{dispose:()=>{r&&(r=!1,K(()=>{for(let h of d)try{h.down([[k]])}catch{}}),u())}})}Le();Q();we();ue();Ie();function P(n){return{describeKind:"derived",...n}}function It(n,e,t){return I([n],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[R]]);return}for(let i of o)s.emit(e(i))},P(t))}function Lt(n,e,t){return I([n],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[R]]);return}let i=!1;for(let a of o)e(a)&&(s.emit(a),i=!0);i||s.down([[R]])},P(t))}function jo(n,e,t,r){return I([n],(s,o,i)=>{"acc"in i.store||(i.store.acc=t);let a=s[0];if(a==null||a.length===0){o.down([[R]]);return}for(let d of a)i.store.acc=e(i.store.acc,d),o.emit(i.store.acc)},{...P(r),initial:t,resetOnTeardown:!0})}function Wo(n,e,t,r){return I([n],(s,o,i)=>{if("acc"in i.store||(i.store.acc=t),i.terminalDeps[0]===!0){o.emit(i.store.acc),o.down([[k]]);return}let a=s[0];if(a==null||a.length===0){o.down([[R]]);return}for(let d of a)i.store.acc=e(i.store.acc,d)},{...P(r),completeWhenDepsComplete:!1})}function Bt(n,e,t){return e<=0?I([n],(r,s,o)=>{o.store.completed||(o.store.completed=!0,s.down([[k]]))},{...P(t),completeWhenDepsComplete:!1}):I([n],(r,s,o)=>{if("taken"in o.store||(o.store.taken=0),o.store.done){s.down([[R]]);return}if(o.terminalDeps[0]===!0){o.store.done=!0,s.down([[k]]);return}let i=r[0];if(i==null||i.length===0){s.down([[R]]);return}for(let a of i)if(o.store.taken++,s.emit(a),o.store.taken>=e){o.store.done=!0,s.down([[k]]);return}},{...P(t),completeWhenDepsComplete:!1})}function vr(n,e,t){return I([n],(r,s,o)=>{"skipped"in o.store||(o.store.skipped=0);let i=r[0];if(i==null||i.length===0){s.down([[R]]);return}let a=!1;for(let d of i)o.store.skipped++,o.store.skipped<=e||(s.emit(d),a=!0);a||s.down([[R]])},P(t))}function Uo(n,e,t){return I([n],(r,s,o)=>{if(o.store.done){s.down([[R]]);return}let i=r[0];if(i==null||i.length===0){s.down([[R]]);return}for(let a of i){if(!e(a)){o.store.done=!0,s.down([[k]]);return}s.emit(a)}},{...P(t),completeWhenDepsComplete:!1})}function Ho(n,e,t){let r=t?.predicate??(i=>i[0]===w),{predicate:s,...o}=t??{};return O(i=>{let a=!1,d=n.subscribe(c=>{if(!a)for(let f of c){if(a)return;f[0]===w?i.emit(f[1]):(f[0]===k||f[0]===N)&&(a=!0,i.down([f]))}}),u=e.subscribe(c=>{if(!a)for(let f of c){if(a)return;if(r(f)){a=!0,i.down([[k]]);return}}});return()=>{d(),u()}},P(o))}function In(n,e){return Bt(n,1,e)}function qo(n,e){let{defaultValue:t,...r}=e??{},s=e!=null&&Object.hasOwn(e,"defaultValue");return I([n],(o,i,a)=>{if(a.terminalDeps[0]===!0){a.store.has?i.emit(a.store.latest):s&&i.emit(t),i.down([[k]]);return}let d=o[0];if(d==null||d.length===0){i.down([[R]]);return}a.store.latest=d.at(-1),a.store.has=!0},{...P(r),completeWhenDepsComplete:!1})}function Jo(n,e,t){return Bt(Lt(n,e,t),1,t)}function Yo(n,e,t){return Bt(vr(n,e,t),1,t)}function Qo(n,e,t){if(typeof e=="function")return I([n],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[R]]);return}for(let a of i)e(a),o.emit(a)},P(t));let r=e;return I([n],(s,o,i)=>{if(i.terminalDeps[0]!==void 0){i.terminalDeps[0]===!0?(r.complete?.(),o.down([[k]])):(r.error?.(i.terminalDeps[0]),o.down([[N,i.terminalDeps[0]]]));return}let a=s[0];if(a==null||a.length===0){o.down([[R]]);return}for(let d of a)r.data?.(d),o.emit(d)},{...P(t),completeWhenDepsComplete:!1})}function Xo(n,e=Object.is,t){return I([n],(r,s,o)=>{let i=r[0];if(i==null||i.length===0){s.down([[R]]);return}let a=!1;for(let d of i)o.store.hasPrev&&e(o.store.prev,d)||(o.store.prev=d,o.store.hasPrev=!0,s.emit(d),a=!0);a||s.down([[R]])},P(t))}function Zo(n,e){return I([n],(t,r,s)=>{let o=t[0];if(o==null||o.length===0){r.down([[R]]);return}let i=!1;for(let a of o)if(!s.store.hasPrev)s.store.prev=a,s.store.hasPrev=!0;else{let d=[s.store.prev,a];s.store.prev=a,r.emit(d),i=!0}i||r.down([[R]])},P(e))}function Tr(...n){let e=[...n];return ke(e,t=>t,{...P(),equals:(t,r)=>{if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(!Object.is(t[s],r[s]))return!1;return!0}})}function es(n,e,t){return I([n,e],(r,s,o)=>{let i=r[0],a=r[1],d=a!=null&&a.length>0?a.at(-1):o.prevData[1];if(i!=null&&i.length>0){if(!(a!=null&&a.length>0)&&o.prevData[1]===void 0){s.down([[R]]);return}for(let u of i)s.emit([u,d])}else s.down([[R]])},P(t))}function yt(...n){return n.length===0?O(e=>{e.down([[k]])},P()):O(e=>{let t=n.length,r=0,s=[];for(let o of n){let i=o.subscribe(a=>{for(let d of a)d[0]===w?e.emit(d[1]):d[0]===k?(r+=1,r>=t&&e.down([[k]])):d[0]===N&&e.down([d])});s.push(i)}return()=>{for(let o of s)o()}},P())}function ts(...n){let e=n.length;return e===0?O(t=>{t.emit([]),t.down([[k]])},P()):O(t=>{let r=Array.from({length:e},()=>[]),s=e;function o(){for(;r.every(a=>a.length>0);){let a=r.map(d=>d.shift());t.emit(a)}}let i=[];for(let a=0;a<e;a++){let d=a,u=n[a].subscribe(c=>{for(let f of c)f[0]===w?(r[d].push(f[1]),o()):f[0]===k?(s-=1,(s===0||r[d].length===0)&&t.down([[k]])):f[0]===N&&t.down([f])});i.push(u)}return()=>{for(let a of i)a()}},P())}function ns(n,e,t){return O(r=>{let s=0,o=[],i,a;return a=e.subscribe(d=>{for(let u of d)s===0?u[0]===w?o.push(u[1]):u[0]===N&&r.down([u]):u[0]===w?r.emit(u[1]):(u[0]===k||u[0]===N)&&r.down([u])}),i=n.subscribe(d=>{for(let u of d)if(s===0)if(u[0]===w)r.emit(u[1]);else if(u[0]===k){s=1;for(let c of o)r.emit(c);o.length=0}else u[0]===N&&r.down([u])}),()=>{i?.(),a?.()}},P(t))}function rs(...n){return n.length===0?O(e=>{e.down([[k]])},P()):n.length===1?I([n[0]],(e,t)=>{let r=e[0];if(r==null||r.length===0){t.down([[R]]);return}for(let s of r)t.emit(s)},P()):O(e=>{let t=null,r=[];for(let s=0;s<n.length;s++){let o=s,i=n[s].subscribe(a=>{for(let d of a){if(t!==null&&o!==t)return;d[0]===w?(t===null&&(t=o),e.emit(d[1])):(d[0]===k||d[0]===N)&&(t===null||o===t)&&e.down([d])}});r.push(i)}return()=>{for(let s of r)s()}},P())}function Vt(n,e,t){let r,s=!1,o=()=>{s||(s=!0,t())};return r=n.subscribe(i=>{let a=!1,d=!1;for(let u of i)u[0]!==Ge&&(u[0]===w?e.emit(u[1]):u[0]===k?a=!0:u[0]===N?(d=!0,e.down([u])):(u[0]===B||u[0]===R)&&e.down([u]));d?(r?.(),r=void 0,o()):a&&o()}),()=>{r?.(),r=void 0}}function Ce(n,e,t){let r,s=!1;function o(){r?.(),r=void 0}return I([n],(i,a,d)=>{if(d.terminalDeps[0]!=null&&d.terminalDeps[0]!==!0){o();return}if(d.terminalDeps[0]===!0){s=!0,r||a.down([[k]]);return}let u=i[0];if(!(u==null||u.length===0))return o(),r=Vt(de(e(u[u.length-1])),a,()=>{o(),s&&a.down([[k]])}),{deactivate:()=>{o(),s=!1}}},{...P(t),completeWhenDepsComplete:!1})}function os(n,e,t){let r,s=!1;function o(){r?.(),r=void 0}return I([n],(i,a,d)=>{if(d.terminalDeps[0]!=null&&d.terminalDeps[0]!==!0){o();return}if(d.terminalDeps[0]===!0){s=!0,r||a.down([[k]]);return}let u=i[0];if(!(u==null||u.length===0))return r===void 0?r=Vt(de(e(u[0])),a,()=>{o(),s&&a.down([[k]])}):a.down([[R]]),{deactivate:()=>{o(),s=!1}}},{...P(t),completeWhenDepsComplete:!1})}function ss(n,e,t){let{maxBuffer:r,...s}=t??{},o=[],i,a=!1,d;function u(){i?.(),i=void 0}function c(){if(!d||i!==void 0)return;if(o.length===0){a&&d.down([[k]]);return}let p=o.shift();i=Vt(de(e(p)),d,()=>{u(),c()})}function f(p){r&&r>0&&o.length>=r&&o.shift(),o.push(p),c()}return I([n],(p,h,l)=>{if(d=h,l.terminalDeps[0]!=null&&l.terminalDeps[0]!==!0){u(),o.length=0;return}if(l.terminalDeps[0]===!0){a=!0,c();return}let m=p[0];if(!(m==null||m.length===0)){for(let g of m)f(g);return{deactivate:()=>{u(),o.length=0,a=!1}}}},{...P(s),completeWhenDepsComplete:!1})}function wr(n,e,t){let{concurrent:r,...s}=t??{},o=r!=null&&r>0?r:Number.POSITIVE_INFINITY,i=0,a=!1,d=new Set,u=[],c;function f(){a&&i===0&&u.length===0&&c&&c.down([[k]])}function p(g){if(!c)return;i++;let b;b=Vt(de(e(g)),c,()=>{b&&d.delete(b),i--,h(),f()}),d.add(b)}function h(){for(;u.length>0&&i<o;)p(u.shift())}function l(g){i<o?p(g):u.push(g)}function m(){for(let g of d)g();d.clear(),i=0,u.length=0}return I([n],(g,b,y)=>{if(c=b,y.terminalDeps[0]!=null&&y.terminalDeps[0]!==!0){m();return}if(y.terminalDeps[0]===!0){a=!0,f();return}let v=g[0];if(!(v==null||v.length===0)){for(let T of v)l(T);return{deactivate:()=>{m(),a=!1}}}},{...P(s),completeWhenDepsComplete:!1})}var is=wr;function as(n,e,t){return O(r=>{let s=new Set;function o(){for(let a of s)clearTimeout(a);s.clear()}let i=n.subscribe(a=>{for(let d of a)if(d[0]===w){let u=setTimeout(()=>{s.delete(u),r.emit(d[1])},e);s.add(u)}else if(d[0]===k){let u=setTimeout(()=>{s.delete(u),r.down([[k]])},e);s.add(u)}else d[0]===N&&(o(),r.down([d]))});return()=>{i(),o()}},P(t))}function kr(n,e,t){return O(r=>{let s,o;function i(){s!==void 0&&(clearTimeout(s),s=void 0)}let a=n.subscribe(d=>{for(let u of d)u[0]===w?(i(),o=u[1],s=setTimeout(()=>{s=void 0,r.emit(o)},e)):u[0]===k?(s!==void 0&&(i(),r.emit(o)),r.down([[k]])):u[0]===N&&(i(),r.down([u]))});return()=>{a(),i()}},P(t))}function xr(n,e,t){let{leading:r,trailing:s,...o}=t??{},i=r!==!1,a=s===!0,d=e*1e6;return O(u=>{let c,f=-1/0,p,h=!1;function l(){c!==void 0&&(clearTimeout(c),c=void 0)}let m=n.subscribe(g=>{for(let b of g)if(b[0]===w){let y=b[1],v=ee();if(i&&v-f>=d)f=v,u.emit(y),l(),a&&(c=setTimeout(()=>{c=void 0,h&&(f=ee(),u.emit(p),h=!1)},e));else if(a&&(p=y,h=!0,c===void 0)){let T=(v-f)/1e6;c=setTimeout(()=>{c=void 0,h&&(f=ee(),u.emit(p),h=!1)},Math.max(0,e-T))}}else(b[0]===k||b[0]===N)&&(l(),u.down([b]))});return()=>{m(),l()}},P(o))}function us(n,e,t){return O(r=>{let s,o=!1,i=!1,a=n.subscribe(u=>{if(!o)for(let c of u){if(o)return;c[0]===w?s={v:c[1]}:c[0]===N?(o=!0,r.down([c])):c[0]===k&&(i=!0,s=void 0)}}),d=e.subscribe(u=>{if(!o)for(let c of u){if(o)return;c[0]===w?s!==void 0&&!i&&r.emit(s.v):c[0]===N?(o=!0,r.down([c])):c[0]===k&&(o=!0,r.down([[k]]))}});return()=>{a(),d()}},P(t))}function ds(n,e,t){return O(r=>{let s,o,i=!1;function a(){s!==void 0&&(clearTimeout(s),s=void 0)}let d=n.subscribe(u=>{for(let c of u)c[0]===w?(o=c[1],i=!0,a(),s=setTimeout(()=>{s=void 0,i&&(i=!1,r.emit(o))},e)):(c[0]===k||c[0]===N)&&(a(),r.down([c]))});return()=>{d(),a()}},P(t))}function cs(n,e,t){return O(r=>{let s=[],o=n.subscribe(a=>{for(let d of a)d[0]===w?s.push(d[1]):d[0]===k?(s.length>0&&r.emit([...s]),s.length=0,r.down([[k]])):d[0]===N&&r.down([d])}),i=e.subscribe(a=>{for(let d of a)d[0]===w?s.length>0&&(r.emit([...s]),s.length=0):d[0]===k?r.down([[k]]):d[0]===N&&r.down([d])});return()=>{o(),i(),s.length=0}},P(t))}function ls(n,e,t){if(e<=0)throw new RangeError("bufferCount expects count > 0");return O(r=>{let s=[],o=n.subscribe(i=>{for(let a of i)a[0]===w?(s.push(a[1]),s.length>=e&&r.emit(s.splice(0,s.length))):a[0]===k?(s.length>0&&r.emit([...s]),s.length=0,r.down([[k]])):a[0]===N&&r.down([a])});return()=>{o(),s.length=0}},P(t))}function fs(n,e,t){if(e<=0)throw new RangeError("windowCount expects count > 0");return O(r=>{let s,o=0;function i(){let d=O(u=>(s=u.down.bind(u),()=>{s=void 0}),P());o=0,r.emit(d)}let a=n.subscribe(d=>{for(let u of d)u[0]===w?(s||i(),s?.([[w,u[1]]]),o+=1,o>=e&&(s?.([[k]]),s=void 0)):u[0]===k?(s?.([[k]]),s=void 0,r.down([[k]])):u[0]===N&&(s?.([u]),s=void 0,r.down([u]))});return()=>{a(),s?.([[k]]),s=void 0}},P(t))}function ps(n,e,t){return O(r=>{let s=[],o=setInterval(()=>{s.length>0&&(r.emit([...s]),s.length=0)},e),i=n.subscribe(a=>{for(let d of a)d[0]===w?s.push(d[1]):d[0]===k?(clearInterval(o),s.length>0&&r.emit([...s]),s.length=0,r.down([[k]])):d[0]===N&&(clearInterval(o),r.down([d]))});return()=>{i(),clearInterval(o),s.length=0}},P(t))}function hs(n,e,t){return O(r=>{let s;function o(){s?.([[k]]),s=void 0}function i(){let u=O(c=>(s=c.down.bind(c),()=>{s=void 0}),P());r.emit(u)}i();let a=setInterval(()=>{o(),i()},e),d=n.subscribe(u=>{for(let c of u)c[0]===w?s?.([[w,c[1]]]):c[0]===k?(clearInterval(a),o(),r.down([[k]])):c[0]===N&&(clearInterval(a),s?.([c]),o(),r.down([c]))});return()=>{d(),clearInterval(a),o()}},P(t))}function ms(n,e,t){return O(r=>{let s;function o(){s?.([[k]]),s=void 0}function i(){let u=O(c=>(s=c.down.bind(c),()=>{s=void 0}),P());r.emit(u)}let a=n.subscribe(u=>{for(let c of u)c[0]===w?(s||i(),s?.([[w,c[1]]])):c[0]===k?(o(),r.down([[k]])):c[0]===N&&(s?.([c]),s=void 0,r.down([c]))}),d=e.subscribe(u=>{for(let c of u)c[0]===w&&(o(),i())});return()=>{a(),d(),o()}},P(t))}function gs(n,e){return O((t,r)=>{"n"in r.store||(r.store.n=0);let s=setInterval(()=>{t.emit(r.store.n),r.store.n=r.store.n+1},n);return()=>clearInterval(s)},P(e))}function bs(n,e,t){if(e<=0)throw new RangeError("repeat expects count > 0");return O(r=>{let s=e,o,i=()=>{o?.(),o=n.subscribe(a=>{let d=!1,u=[];for(let c of a)c[0]===k?d=!0:u.push(c);u.length>0&&r.down(u),d&&(o?.(),o=void 0,s-=1,s>0?i():r.down([[k]]))})};return i(),()=>{o?.()}},P(t))}function ys(n,e){return I([n],(t,r)=>{let s=t[0];if(s==null||s.length===0){r.down([[R]]);return}for(let o of s)r.emit(o)},P(e))}function _r(n,e,t){return O(r=>{let s=n.subscribe(o=>{for(let i of o)if(i[0]===w)r.emit(i[1]);else if(i[0]===N)try{r.emit(e(i[1]))}catch(a){r.down([[N,a]])}else i[0]===k&&r.down([[k]])});return()=>{s()}},P(t))}function vs(n,e,t){return I([n,e],(r,s,o)=>{let i=r[1];if(!(i!=null&&i.length>0?i.at(-1):o.prevData[1])){s.down([[R]]);return}let d=r[0];if(d!=null&&d.length>0){for(let u of d)s.emit(u);return}if(i!=null&&i.length>0&&o.prevData[0]!==void 0){s.emit(o.prevData[0]);return}s.down([[R]])},P(t))}var Ts=Tr,ws=kr,ks=xr,xs=_r;Q();we();ue();ht();var He=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let t=(this.head+this._size)%this.capacity;this.buf[t]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let t=e<0?this._size+e:e;if(!(t<0||t>=this._size))return this.buf[(this.head+t)%this.capacity]}toArray(){let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this.buf[(this.head+t)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};var Ln=class{ring;arr;constructor(e){e===Number.POSITIVE_INFINITY||e<=0?(this.arr=[],this.ring=null):(this.ring=new He(e),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(e){this.ring!=null?this.ring.push(e):this.arr.push(e)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let t=this.ring.toArray();return this.ring.clear(),t}let e=this.arr;return this.arr=[],e}};function vt(n){return n instanceof Error?n:new Error(String(n))}function _s(n){return n===void 0?null:typeof n=="string"?ze(n):n}function se(n,e){let{name:t,onTransportError:r,retry:s,backpressure:o,batchSize:i=Number.POSITIVE_INFINITY,flushIntervalMs:a=0,serialize:d,stopOn:u,onUpstreamMessage:c,onDispose:f,send:p,sendBatch:h,ctx:l}=e;if(!p&&!h)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let m=l,g=Math.max(1,s?.maxAttempts??1),b=_s(s?.backoff??(g>1?"exponential":void 0)),y=s?.shouldRetry??(()=>!0),v=h!==void 0||i<Number.POSITIVE_INFINITY||a>0,T=A=>t?`${t}::${A}`:void 0,x=V(void 0,{equals:()=>!1,name:T("sent")}),_=V(null,{name:T("failed")}),E=V(0,{name:T("inFlight")}),S=V(null,{name:T("errors")}),C=v?V(0,{name:T("buffered")}):void 0,F=o?V(!1,{name:T("paused")}):void 0,L=0,$=A=>{L+=A,E.down([[w,L]])},M=A=>{try{r?.(A)}catch{}try{S.down([[w,A]])}catch{}},z=new Set,te=A=>{z.add(A);let W=()=>z.delete(A);A.then(W,W)},j=(A,W,J)=>{let X=b?b(W-1,J,null):0,ae=X==null?0:typeof X=="number"&&X>0?X:0,Se=Math.max(1,Math.ceil(ae/1e6));return new Promise(Y=>{setTimeout(()=>Y(A()),Se)})},ie=A=>A!=null&&typeof A=="object"&&typeof A.then=="function",xe=A=>{let W;try{W=d?d(A):A}catch(Y){let U=vt(Y);return M({stage:"serialize",error:U,value:A}),_.down([[w,{value:A,error:U,attempts:0}]]),Promise.resolve()}let J=0,X=Y=>{$(-1);let U=vt(Y);if(M({stage:"send",error:U,value:A,attempt:J}),!(J<g&&y(U,J))){_.down([[w,{value:A,error:U,attempts:J}]]);return}return j(Se,J,U)},ae=()=>{$(-1),x.down([[w,A]])};function Se(){J+=1,$(1);let Y;try{Y=p(W,m)}catch(U){return X(U)??Promise.resolve()}return ie(Y)?Y.then(ae,U=>X(U)):(ae(),Promise.resolve())}return Se()},De=o?.maxBuffer??Number.POSITIVE_INFINITY,_e=new Ln(De),ge,Be=!1,D=()=>{C?.down([[w,_e.length]])},q=A=>{F&&F.down([[w,A]])},pe=o?.strategy??"drop-oldest",Ve=(A,W)=>{let J={value:A,payload:W};if(_e.length<De)return _e.push(J),D(),!0;if(pe==="drop-oldest"){let ae=_e.shift();return _e.push(J),D(),q(!0),_.down([[w,{value:ae.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(pe==="drop-newest")return q(!0),_.down([[w,{value:A,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let X=new Error("backpressure: buffer overflow");return M({stage:"send",error:X,value:A}),_.down([[w,{value:A,error:X,attempts:0}]]),q(!0),!1},be=A=>{let W=0,J=A.map(Y=>Y.payload),X=Y=>{$(-1);let U=vt(Y);if(M({stage:"send",error:U,value:A.map(Xt=>Xt.value),attempt:W}),!(W<g&&y(U,W))){for(let{value:Xt}of A)_.down([[w,{value:Xt,error:U,attempts:W}]]);return}return j(Se,W,U)},ae=()=>{$(-1);for(let{value:Y}of A)x.down([[w,Y]])};function Se(){W+=1,$(1);let Y;try{Y=h(J,m)}catch(U){return X(U)??Promise.resolve()}return ie(Y)?Y.then(ae,U=>X(U)):(ae(),Promise.resolve())}return Se()},H=async A=>{for(let W of A)await ce(W.value,W.payload)},ce=(A,W)=>{let J=0,X=Y=>{$(-1);let U=vt(Y);if(M({stage:"send",error:U,value:A,attempt:J}),!(J<g&&y(U,J))){_.down([[w,{value:A,error:U,attempts:J}]]);return}return j(Se,J,U)},ae=()=>{$(-1),x.down([[w,A]])};function Se(){J+=1,$(1);let Y;try{Y=p(W,m)}catch(U){return X(U)??Promise.resolve()}return ie(Y)?Y.then(ae,U=>X(U)):(ae(),Promise.resolve())}return Se()},Pe=()=>{if(Be||_e.length===0)return Promise.resolve();let A=_e.drain();if(D(),q(!1),h!==void 0){let J=be(A);return te(J),J}let W=H(A);return te(W),W},to=()=>{ge!==void 0||Be||a<=0||(ge=setTimeout(()=>{ge=void 0,Pe()},a))},no=n.subscribe(A=>{for(let W of A){let J=W[0];if(J!==w)try{c?.(W)}catch{}if(J===w){let X=W[1];if(v){let ae;if(d)try{ae=d(X)}catch(Y){let U=vt(Y);M({stage:"serialize",error:U,value:X}),_.down([[w,{value:X,error:U,attempts:0}]]);continue}else ae=X;if(!Ve(X,ae))continue;_e.length>=i?Pe():to()}else{let ae=xe(X);te(ae)}}else le.messageTier(J)>=3&&v&&(ge!==void 0&&(clearTimeout(ge),ge=void 0),Pe())}}),zn;if(u){let A=!1;zn=u.subscribe(W=>{if(!A){A=!0;return}W.length>0&&!Qt&&jn()})}let Qt=!1,jn=()=>{if(Qt)return;Qt=!0,ge!==void 0&&(clearTimeout(ge),ge=void 0),v&&Pe(),Be=!0,zn?.(),no();let A=W=>{try{W.down([[G]])}catch{}};A(S),A(_),A(x),A(E),C&&A(C),F&&A(F);try{f?.()}catch{}},kt={dispose:jn,sent:x,failed:_,inFlight:E,errors:S};return v&&(kt.buffered=C,kt.flush=async()=>{Be||(await Pe(),await Promise.all(z))}),F&&(kt.paused=F),kt}Dt();Ie();function Re(n){return{describeKind:"producer",...n}}function Nr(n,e){let{parse:t,closeOnTeardown:r=!1,...s}=e??{};return O(o=>{let i=!0,a,d=()=>{let b=a;a=void 0,b?.()},u=b=>{i&&(i=!1,o.down([b]),d())},c=(b,y=b)=>{if(i)try{let v=b!==null&&typeof b=="object"&&"data"in b?b.data:b,T=t?t(v,y):v;o.emit(T)}catch(v){u([N,v])}},f=b=>{u([N,b])},p=()=>{u([k])};if(typeof n=="function"){try{if(a=n(c,f,p),typeof a!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(b){u([N,b])}return()=>{i=!1,d()}}let h=n,l=b=>c(b,b),m=b=>f(b),g=()=>p();return h.addEventListener("message",l),h.addEventListener("error",m),h.addEventListener("close",g),a=()=>{h.removeEventListener("message",l),h.removeEventListener("error",m),h.removeEventListener("close",g),r&&h.close()},()=>{i=!1,d()}},Re(s))}function Ns(n,e){return et(n,e)}function Er(n,e){let{method:t="GET",headers:r,body:s,transform:o=v=>v.json(),timeoutNs:i=30*1e9,signal:a,completeAfterFetch:d=!1,refetchOnSubscribe:u=!1,...c}=e??{},f=V(0,{name:`${c.name??"http"}/fetchCount`}),p=V(0,{name:`${c.name??"http"}/lastUpdated`}),h=V(!1,{name:`${c.name??"http"}/fetched`}),l=0,m=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0,g=v=>{let T=new AbortController,x=!0;if(a?.aborted)return x=!1,v.down([[N,a.reason??new Error("Aborted")]]),()=>{};a?.addEventListener("abort",()=>T.abort(a.reason),{once:!0});let _=setTimeout(()=>T.abort(new Error("Request timeout")),Math.ceil(i/1e6));return fetch(n,{method:t,headers:r,body:m,signal:T.signal}).then(async E=>{if(clearTimeout(_),!x)return;if(!E.ok)throw new Error(`HTTP ${E.status}: ${E.statusText}`);let S=await o(E);x&&(K(()=>{l+=1,f.down([[w,l]]),p.down([[w,ne()]]),h.down([[w,!0]]),v.emit(S)}),d&&v.down([[k]]))}).catch(E=>{clearTimeout(_),x&&(E&&E.name==="AbortError"||v.down([[N,E]]))}),()=>{x=!1,T.abort()}},b=O(v=>g({emit:T=>v.emit(T),down:T=>v.down(T)}),{...Re(c),resubscribable:u});return{...bt(b),fetchCount:f,lastUpdated:p,fetched:h}}function Es(n,e,t){let{method:r="POST",headers:s={"Content-Type":"application/json"},serialize:o=l=>JSON.stringify(l),timeoutNs:i,batchFormat:a="json-array",batchSize:d,flushIntervalMs:u,retry:c,onTransportError:f}=t??{},p=async l=>{let m=i!==void 0?new AbortController:void 0,g;m&&i!==void 0&&(g=setTimeout(()=>m.abort(new Error("Request timeout")),Math.ceil(i/1e6)));try{let b=await fetch(e,{method:r,headers:s,body:l,signal:m?.signal}),y=async()=>{try{await b.arrayBuffer?.()}catch{}};if(!b.ok)throw await y(),new Error(`HTTP ${b.status}: ${b.statusText}`);await y()}finally{g!==void 0&&clearTimeout(g)}};return d!==void 0||u!==void 0?se(n,{onTransportError:f,retry:c,batchSize:d,flushIntervalMs:u,sendBatch:async l=>{let m;a==="ndjson"?m=l.map(g=>{let b=o(g);return typeof b=="string"?b:new TextDecoder().decode(b)}).join(`
2
- `):m=JSON.stringify(l),await p(m)}}):se(n,{onTransportError:f,retry:c,serialize:o,send:async l=>{await p(l)}})}function Sr(n){return Symbol.keyFor(n)??n.description??"message"}function ot(n,e){return typeof n=="string"?n:e(n)}function Or(n,e){let t=`event: ${n}
3
- `;if(e!==void 0){let r=e.split(/\r?\n/);for(let s of r)t+=`data: ${s}
4
- `}return`${t}
5
- `}function Ss(n,e){let{serialize:t=h=>{if(h instanceof Error)return h.message;try{return JSON.stringify(h)}catch{return String(h)}},dataEvent:r="data",errorEvent:s="error",completeEvent:o="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:d,signal:u,eventNameResolver:c=Sr}=e??{},f=new TextEncoder,p;return new ReadableStream({start(h){let l=!1,m,g=()=>{},b=()=>{l||(l=!0,m!==void 0&&clearInterval(m),u?.removeEventListener("abort",v),g(),h.close())};p=b;let y=(T,x)=>{l||h.enqueue(f.encode(Or(T,x)))},v=()=>{l||b()};g=n.subscribe(T=>{for(let x of T){let _=x[0];if(!(le.isLocalOnly(_)&&!(_===B&&a))){if(_===w){y(r,ot(x[1],t));continue}if(_===N){y(s,ot(x[1],t)),b();return}if(_===k){y(o),b();return}!i&&_===R||y(c(_),x.length>1?ot(x[1],t):void 0)}}}),d!==void 0&&d>0&&(m=setInterval(()=>{l||h.enqueue(f.encode(`: keepalive
1
+ "use strict";var rn=Object.defineProperty;var To=Object.getOwnPropertyDescriptor;var wo=Object.getOwnPropertyNames;var xo=Object.prototype.hasOwnProperty;var he=(t,e)=>()=>(t&&(e=t(t=0)),e);var on=(t,e)=>{for(var n in e)rn(t,n,{get:e[n],enumerable:!0})},ko=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of wo(e))!xo.call(t,s)&&s!==n&&rn(t,s,{get:()=>e[s],enumerable:!(r=To(e,s))||r.enumerable});return t};var _o=t=>ko(rn({},"__esModule",{value:!0}),t);function _t(){return Qe>0||ft}function Qn(){return Qe>0}function ht(t){Qe>0?pt.push(t):t()}function j(t){Qe+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(Qe-=1,Qe===0)if(e){if(!ft){let n=pt.splice(0);for(let r of n)try{r()}catch{}Fe.length=0,$e.length=0,Xe.length=0}}else No()}}function No(){let t=!ft;t&&(ft=!0);let e=[],n=0;try{for(;Fe.length>0||$e.length>0||Xe.length>0||t&&pt.length>0;){if(t&&pt.length>0){let o=pt.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw Fe.length=0,$e.length=0,Xe.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(Fe.length>0?Fe:$e.length>0?$e:Xe).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{t&&(ft=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Nt(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!_t()){t(e);return}(u>=5?Xe:u===4?$e:Fe).push(()=>t(e));return}let r=e.length,s=r,o=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(s=a;a<r&&n(e[a][0])===3;)a++;for(o=a;a<r&&n(e[a][0])===4;)a++;i=a;let d=_t();if(s>0){let u=e.slice(0,s);t(u)}if(o>s){let u=e.slice(s,o);d?Fe.push(()=>t(u)):t(u)}if(i>o){let u=e.slice(o,i);d?$e.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);d?Xe.push(()=>t(u)):t(u)}}var Qe,ft,Fe,$e,Xe,pt,ye=he(()=>{"use strict";Qe=0,ft=!1,Fe=[],$e=[],Xe=[],pt=[]});function ne(){return Math.trunc(performance.now()*1e6)}function re(){return Date.now()*1e6}var Le=he(()=>{"use strict"});var Ke,w,G,M,ve,me,Te,K,x,N,Ze,sn,Eo,an,So,Oo,un,Xn,Zn,er,dn,X=he(()=>{"use strict";Ke=Symbol.for("graphrefly/START"),w=Symbol.for("graphrefly/DATA"),G=Symbol.for("graphrefly/DIRTY"),M=Symbol.for("graphrefly/RESOLVED"),ve=Symbol.for("graphrefly/INVALIDATE"),me=Symbol.for("graphrefly/PAUSE"),Te=Symbol.for("graphrefly/RESUME"),K=Symbol.for("graphrefly/TEARDOWN"),x=Symbol.for("graphrefly/COMPLETE"),N=Symbol.for("graphrefly/ERROR"),Ze=Object.freeze([G]),sn=Object.freeze([M]),Eo=Object.freeze([ve]),an=Object.freeze([Ke]),So=Object.freeze([x]),Oo=Object.freeze([K]),un=Object.freeze([Ze]),Xn=Object.freeze([sn]),Zn=Object.freeze([Eo]),er=Object.freeze([So]),dn=Object.freeze([Oo])});function nr(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let s=2+n.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=cn,o[i++]=n.length,o.set(n,i),i+=n.length,o[i++]=r>>>8&255,o[i++]=r&255,o.set(e,i),o}function rr(t,e){if(t.length<tr)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${tr})`);let n=0,r=t[n++];if(r!==cn)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${cn})`);let s=t[n++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+s+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+s+2} bytes, have ${t.length})`);let o=new TextDecoder().decode(t.subarray(n,n+s));n+=s;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),d=e.lookupCodec(o);if(d==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:d,codecVersion:i,payload:a}}function or(t){t.registerCodec(Ro)}var Ro,cn,tr,ln=he(()=>{"use strict";Ro={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)}},cn=1,tr=4});function Et(t){if(t==null)return et;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var et,fn=he(()=>{"use strict";et={type:"system",id:""}});function sr(t){t.registerMessageType(Ke,{tier:0,wireCrossing:!1}),t.registerMessageType(G,{tier:1,wireCrossing:!1}),t.registerMessageType(ve,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(me,{tier:2,wireCrossing:!1}),t.registerMessageType(Te,{tier:2,wireCrossing:!1}),t.registerMessageType(w,{tier:3,wireCrossing:!0}),t.registerMessageType(M,{tier:3,wireCrossing:!0}),t.registerMessageType(x,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(N,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(K,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var St,ir=he(()=>{"use strict";X();St=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 r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}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 pn(t){let e=Mo.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var Ne,Mo,Ot=he(()=>{"use strict";Ne=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}},Mo=["human","llm","wallet","system"]});function hn(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(hn);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=hn(t[n]);return e}return null}function Do(t){let e=Co.encode(t),n=e.length,r=n*8,s=n+9+63&-64,o=new Uint8Array(s);o.set(e),o[n]=128;let i=new DataView(o.buffer);i.setUint32(s-4,r>>>0,!1),i.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,d=3144134277,u=1013904242,c=2773480762,f=1359893119,p=2600822924,h=528734635,l=1541459225,m=new Uint32Array(64),g=(y,v)=>y>>>v|y<<32-v;for(let y=0;y<s;y+=64){for(let D=0;D<16;D++)m[D]=i.getUint32(y+D*4,!1);for(let D=16;D<64;D++){let L=m[D-15],O=m[D-2],$=g(L,7)^g(L,18)^L>>>3,ee=g(O,17)^g(O,19)^O>>>10;m[D]=m[D-16]+$+m[D-7]+ee>>>0}let v=a,T=d,k=u,_=c,E=f,S=p,A=h,I=l;for(let D=0;D<64;D++){let L=g(E,6)^g(E,11)^g(E,25),O=E&S^~E&A,$=I+L+O+Ao[D]+m[D]>>>0,ee=g(v,2)^g(v,13)^g(v,22),z=v&T^v&k^T&k,te=ee+z>>>0;I=A,A=S,S=E,E=_+$>>>0,_=k,k=T,T=v,v=$+te>>>0}a=a+v>>>0,d=d+T>>>0,u=u+k>>>0,c=c+_>>>0,f=f+E>>>0,p=p+S>>>0,h=h+A>>>0,l=l+I>>>0}let b=y=>y.toString(16).padStart(8,"0");return b(a)+b(d)+b(u)+b(c)+b(f)+b(p)+b(h)+b(l)}function mn(t){let e=hn(t??null),n=JSON.stringify(e);return Do(n).slice(0,16)}function Po(){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 gn(t,e,n){let r=n?.id??Po();if(t===0)return{id:r,version:0};let o=(n?.hash??mn)(e);return{id:r,version:0,cid:o,prev:null}}function ar(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Ao,Co,ur=he(()=>{"use strict";Ao=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]),Co=new TextEncoder});function lr(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function bn(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Rt(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function B(t,e,n){let r=fr(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,o={};return fr(t)?o=(yn(e)?e:n)??{}:yn(t)?o=t:o=(yn(e)?e:n)??{},new oe(r,s,o)}var dr,cr,Io,Lo,le,oe,fr,yn,we=he(()=>{"use strict";ln();fn();ye();Le();ir();Ot();X();ur();dr=()=>{},cr=100;Io=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},Lo=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[an]:[an,[w,o]];s._status==="dirty"&&i.push(Ze),Nt(e,i,s._config.tierOf)},le=new St({onMessage:Io,onSubscribe:Lo});sr(le);or(le);oe=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??le,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??mn;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?gn(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(lr);let o={};for(let[a,d]of Object.entries(r.meta??{})){let u={initial:d,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),o[a]=new t([],void 0,u)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[w,a]])},down(a){i._emit(Rt(a))},up(a){i._emitUp(Rt(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let s=n?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,d=i?.version??0,u=gn(e,o,{id:a,hash:s});u.version=d,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=Et(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let s=Et(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new Ne({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new Ne({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:re()}}down(e,n){let r=Rt(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[w,e]])}up(e,n){if(this._deps.length===0)return;let r=Rt(e);if(r.length===0)return;this._checkGuard(n);let s=n??{internal:!0};this._validateUpTiers(r);for(let o of this._deps)o.node.up?.(r,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let s=n(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let d=Et(n);if(!this._guard(d,"observe"))throw new Ne({actor:d,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)bn(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let s=r,o=this._deps[r];o.unsub=dr,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,d=!1;for(let u of i)a(u[0])>=3&&(d=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:s},this._actions);d&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let s=0;s<n;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}bn(o)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let n=this._deps.length,r=lr(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(un),r.unsub=dr;try{r.unsub=e.subscribe(s=>{if(r.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[N,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[N,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let r of this._deps){if(r.unsub!=null){let s=r.unsub;r.unsub=null;try{s()}catch{}}bn(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],s=n[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(o)}if(s!==Ke){if(s===G){this._depDirtied(r);return}if(s===ve){this._depInvalidated(r),this._emit(Zn);return}if(s===me||s===Te){this._emit([n]);return}if(s===K){this._emit(dn);return}if(s===w)this._depSettledAsData(r,n[1]);else if(s===M)this._depSettledAsResolved(r);else if(s===x)this._depSettledAsTerminal(r,!0);else if(s===N)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===w||s===M)&&this._emit([n]),(s===x||s===N)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(un))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Xn),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([[N,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(er)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[N,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[N,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[N,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>cr?(this._rerunDepth=0,this._emit([[N,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${cr} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[Ze,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let d of e){let u=n(d[0]);u<i&&(r=!1),u===3&&(s=!0),d[0]===G&&(o=!0),i=u}let a=e;if(!r){let d=e.map((u,c)=>({m:u,i:c,tier:n(u[0])}));d.sort((u,c)=>u.tier-c.tier||u.i-c.i),a=d.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let d=0;for(;d<a.length&&n(a[d][0])===0;)d++;return d===0?[Ze,...a]:[...a.slice(0,d),Ze,...a.slice(d)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let d=e[a];if(d[0]===N&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(d=>d[0]===K||d[0]===ve);if(a.length===0)return;n=a}n=this._frameBatch(n);let s=null;for(let a=0;a<n.length;a++){let d=n[a],u=d[0];if(u!==me&&u!==Te){s?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===me?"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 f=d[1];if(u===me)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))c=!1;else if(this._pauseLocks.delete(f),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?s?.push(d):s==null&&(s=n.slice(0,a))}if(s!=null){if(s.length===0)return;n=s}if(this._hasMeta&&n.some(a=>a[0]===K))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(dn)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(n);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,d=[];for(let u of o)a(u[0])===3?this._pauseBuffer.push(u):d.push(u);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[N,i]])}_updateState(e){let n=this._config.tierOf,r,s,o=-1,i=0;for(let c of e)n(c[0])===3&&i++;let a=i<=1,d=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===w){d=c;break}}for(let c=0;c<e.length;c++){let f=e[c],p=f[0];if(p===w){if(f.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,f[1])}catch(l){s=this._wrapFnError("equals threw",l),o=c;break}if(h){r==null&&(r=e.slice(0,c)),r.push(sn),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(d<0||c===d)&&ar(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),p===G)this._status="dirty";else if(p===M)this._status="resolved";else if(p===x)this._status="completed";else if(p===N)this._status="errored";else if(p===ve){this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let l=h.invalidate;if(typeof l=="function")try{l()}catch{}}}else p===K&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:u,equalsError:s}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(Qn()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ht(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}Nt(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);Nt(this._deliverToSinks,n,this._config.tierOf)}},fr=t=>Array.isArray(t),yn=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function F(t,e){return B([],{...e,initial:t})}function R(t,e){return B((r,s,o)=>t(s,o)??void 0,{describeKind:"producer",...e})}function xe(t,e,n){return B(t,(s,o,i)=>{let a=s.map((d,u)=>d!=null&&d.length>0?d.at(-1):i.prevData[u]);o.emit(e(a,i))},{describeKind:"derived",...n})}function Mt(t,e,n){return B(t,(s,o,i)=>{let a=s.map((d,u)=>d!=null&&d.length>0?d.at(-1):i.prevData[u]);return e(a,o,i)??void 0},{describeKind:"effect",...n})}var ue=he(()=>{"use strict";we()});var hr={};on(hr,{NS_PER_MS:()=>fe,NS_PER_SEC:()=>Ae,constant:()=>vn,decorrelatedJitter:()=>kn,exponential:()=>wn,fibonacci:()=>xn,linear:()=>Tn,resolveBackoffPreset:()=>je,withMaxAttempts:()=>pr});function ze(t){return t<0?0:t}function Bo(t,e){return e==="none"?t:e==="full"?Math.random()*t:t/2+Math.random()*(t/2)}function Vo(t,e){return t+Math.random()*(e-t)}function vn(t){let e=ze(t);return()=>e}function Tn(t,e){let n=ze(t),r=e===void 0?n:ze(e);return s=>n+r*Math.max(0,s)}function wn(t){let e=ze(t?.baseNs??1e8),n=t?.factor!==void 0&&t.factor<1?1:t?.factor??2,r=ze(t?.maxDelayNs??30*1e9),s=t?.jitter??"none";return o=>{let i;if(e===0)i=0;else if(n===1)i=e;else{let a=r/e,d=1;for(let u=0;u<Math.max(0,o);u++){if(d>=a){d=a;break}d*=n}i=e*d,i>r&&(i=r)}return Bo(i,s)}}function xn(t=100*1e6,e=30*1e9){let n=ze(t),r=ze(e);function s(o){if(o<=0)return 1;let i=1,a=2;for(let d=1;d<o;d++){let u=i+a;i=a,a=u}return a}return o=>{let i=s(o)*n;return i<=r?i:r}}function kn(t=100*1e6,e=30*1e9){return(n,r,s)=>{let i=Math.min(e,(s??t)*3);return Vo(t,i)}}function pr(t,e){return(n,r,s)=>n>=e?null:t(n,r,s)}function je(t){if(t==="constant")return vn(1*1e9);if(t==="linear")return Tn(1*1e9);if(t==="exponential")return wn();if(t==="fibonacci")return xn();if(t==="decorrelatedJitter")return kn();throw new Error(`Unknown backoff preset: "${String(t)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var fe,Ae,mt=he(()=>{"use strict";fe=1e6,Ae=1e9});function gt(t,e,n){let r=new Set;for(let s of t.split(",")){let[o,i]=s.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${s}`);let d,u;if(o==="*")d=e,u=n;else if(o.includes("-")){let[c,f]=o.split("-");d=Number.parseInt(c,10),u=Number.parseInt(f,10)}else d=Number.parseInt(o,10),u=d;if(Number.isNaN(d)||Number.isNaN(u))throw new Error(`Invalid cron field: ${t}`);if(d<e||u>n)throw new Error(`Cron field out of range: ${t} (${e}-${n})`);if(d>u)throw new Error(`Invalid cron range: ${d}-${u} in ${t}`);for(let c=d;c<=u;c+=a)r.add(c)}return r}function Nn(t){let e=t.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:gt(e[0],0,59),hours:gt(e[1],0,23),daysOfMonth:gt(e[2],1,31),months:gt(e[3],1,12),daysOfWeek:gt(e[4],0,6)}}function En(t,e){return t.minutes.has(e.getMinutes())&&t.hours.has(e.getHours())&&t.daysOfMonth.has(e.getDate())&&t.months.has(e.getMonth()+1)&&t.daysOfWeek.has(e.getDay())}var Sn=he(()=>{"use strict"});var Oe,At=he(()=>{"use strict";Oe=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var br={};on(br,{CircuitOpenError:()=>nt,RateLimiterOverflowError:()=>rt,TimeoutError:()=>ot,circuitBreaker:()=>Rn,fallback:()=>Cn,rateLimiter:()=>An,retry:()=>On,retrySource:()=>bt,timeout:()=>Dn,tokenBucket:()=>Dt,withBreaker:()=>Mn,withStatus:()=>yt});function We(t){return{describeKind:"derived",...t}}function Go(t){return t<0?0:t}function Ct(t){return t[1]}function gr(t){if(typeof t!="number"||!Number.isFinite(t))throw new TypeError("backoff strategy must return a finite number");return t<0?0:t}function On(t,e){let n=e?.count,r=e?.backoff,s=n!==void 0?n:r===void 0?0:2147483647;if(s<0)throw new RangeError("retry count must be >= 0");let o=r===void 0?null:typeof r=="string"?je(r):r;return R(i=>{let a=0,d=!1,u=null,c,f=new Oe;function p(){c?.(),c=void 0}function h(m){if(d)return;if(a>=s){p(),i.down([[N,m]]);return}let g=o===null?0:o(a,m,u);if(g==null){p(),i.down([[N,m]]);return}let b;try{b=gr(g)}catch{p(),i.down([[N,m]]);return}u=b,a+=1,p();let y=b>0?b/1e6:1;f.start(y,()=>{d||l()})}function l(){f.cancel(),p(),c=t.subscribe(m=>{if(!d)for(let g of m){let b=g[0];if(b===G)i.down([[G]]);else if(b===w)a=0,u=null,i.emit(g[1]);else if(b===M)i.down([[M]]);else if(b===x)p(),i.down([[x]]);else if(b===N){h(Ct(g));return}else i.down([g])}})}return l(),()=>{d=!0,f.cancel(),p()}},{...We(),initial:t.cache})}function bt(t,e){let n=e?.count,r=e?.backoff,s=n!==void 0?n:r===void 0?0:2147483647;if(s<0)throw new RangeError("retry count must be >= 0");let o=r===void 0?null:typeof r=="string"?je(r):r;return R(i=>{let a=0,d=!1,u=null,c,f=new Oe;function p(){c?.(),c=void 0}function h(m){if(d)return;if(a>=s){p(),i.down([[N,m]]);return}let g=o===null?0:o(a,m,u);if(g==null){p(),i.down([[N,m]]);return}let b;try{b=gr(g)}catch{p(),i.down([[N,m]]);return}u=b,a+=1,p();let y=b>0?b/1e6:1;f.start(y,()=>{d||l()})}function l(){f.cancel(),p();let m;try{m=t()}catch(g){h(g);return}c=m.subscribe(g=>{if(!d)for(let b of g){let y=b[0];if(y===G)i.down([[G]]);else if(y===w)a=0,u=null,i.emit(b[1]);else if(y===M)i.down([[M]]);else if(y===x)p(),i.down([[x]]);else if(y===N){h(Ct(b));return}else i.down([b])}})}return l(),()=>{d=!0,f.cancel(),p()}},{...We(),initial:e?.initial})}function Rn(t){let e=Math.max(1,t?.failureThreshold??5),n=Go(t?.cooldownNs??30*1e9),r=t?.cooldown??null,s=Math.max(1,t?.halfOpenMax??1),o=t?.now??ne,i="closed",a=0,d=0,u=0,c=n,f=0;function p(){if(!r)return n;let m=r(d);return m!==null?m:n}function h(){i="open",c=p(),u=o(),f=0}return{canExecute(){return i==="closed"?!0:i==="open"?o()-u>=c?(i="half-open",f=1,!0):!1:f<s?(f++,!0):!1},recordSuccess(){i==="half-open"?(i="closed",a=0,d=0):i==="closed"&&(a=0)},recordFailure(m){if(i==="half-open"){d++,h();return}i==="closed"&&(a++,a>=e&&h())},get state(){return i},get failureCount(){return a},reset(){i="closed",a=0,d=0,f=0}}}function Mn(t,e){let n=e?.onOpen??"skip";return r=>{let s=B([],(o,i)=>{function a(){s.meta.breakerState.down([[w,t.state]])}let d=r.subscribe(u=>{for(let c of u){let f=c[0];f===G?i.down([[G]]):f===w?t.canExecute()?(a(),i.emit(c[1])):(a(),n==="error"?i.down([[N,new nt]]):i.down([[M]])):f===M?i.down([[M]]):f===x?(t.recordSuccess(),a(),i.down([[x]])):f===N?(t.recordFailure(Ct(c)),a(),i.down([c])):i.down([c])}});return a(),d},{...We(),meta:{breakerState:t.state},completeWhenDepsComplete:!1,initial:r.cache});return{node:s,breakerState:s.meta.breakerState}}}function Dt(t,e){if(t<=0)throw new RangeError("capacity must be > 0");if(e<0)throw new RangeError("refillPerSecond must be >= 0");let n=t,r=ne();function s(o){if(e>0){let i=o-r;n=Math.min(t,n+i/1e9*e)}r=o}return{available(){return s(ne()),n},tryConsume(o=1){if(o<=0)return!0;let i=ne();return s(i),n>=o?(n-=o,!0):!1},putBack(o=1){o<=0||(s(ne()),n=Math.min(t,n+o))}}}function An(t,e){let{maxEvents:n,windowNs:r}=e;if(n<=0)throw new RangeError("maxEvents must be > 0");if(r<=0)throw new RangeError("windowNs must be > 0");let s=e.maxBuffer;if(s!==void 0&&s<1)throw new RangeError("maxBuffer must be >= 1");let o=e.onOverflow??"drop-newest",i=n*1e9/r;return R(a=>{let d=Dt(n,i),u=[],c=new Oe,f=!1,p=1e9/i;function h(){for(;u.length>0;)if(d.tryConsume(1))a.emit(u.shift());else{c.start(Math.max(1,p/1e6),h);return}}let l=t.subscribe(m=>{for(let g of m){if(f)return;let b=g[0];if(b===G)a.down([[G]]);else if(b===w){if(s!==void 0&&u.length>=s){if(o!=="drop-newest")if(o==="drop-oldest")u.shift(),u.push(g[1]);else{f=!0,c.cancel(),u.length=0,a.down([[N,new rt(s)]]);return}}else u.push(g[1]);h()}else if(b===M)a.down([[M]]);else if(b===x)f=!0,c.cancel(),u.length=0,a.down([[x]]);else if(b===N)f=!0,c.cancel(),u.length=0,a.down([g]);else if(b===K){f=!0,c.cancel(),u.length=0,a.down([g]);return}else a.down([g])}});return()=>{f=!0,c.cancel(),l()}},{...We(),initial:t.cache})}function yt(t,e){let n=e?.initialStatus??"pending",r=B([],(s,o)=>{let i=n;return r.meta.status.down([[w,n]]),r.meta.error.down([[w,null]]),t.subscribe(d=>{for(let u of d){let c=u[0];if(c===G)o.down([[G]]);else if(c===w)i==="errored"?j(()=>{r.meta.error.down([[w,null]]),r.meta.status.down([[w,"active"]])}):r.meta.status.down([[w,"active"]]),i="active",o.emit(u[1]);else if(c===M)o.down([[M]]);else if(c===x)r.meta.status.down([[w,"completed"]]),i="completed",o.down([[x]]);else if(c===N){let f=Ct(u);j(()=>{r.meta.error.down([[w,f]]),r.meta.status.down([[w,"errored"]])}),i="errored",o.down([u])}else o.down([u])}})},{...We(),meta:{status:n,error:null},completeWhenDepsComplete:!1,resubscribable:!0,initial:t.cache});return{node:r,status:r.meta.status,error:r.meta.error}}function Fo(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function $o(t){return t!=null&&typeof t.then=="function"}function Ko(t){return t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function"}function Cn(t,e){return R(n=>{let r,s;function o(){s?.(),s=void 0,Fo(e)||$o(e)||Ko(e)?r=de(e).subscribe(a=>{n.down(a)}):(n.emit(e),n.down([[x]]))}return s=t.subscribe(i=>{for(let a of i){let d=a[0];if(d===G)n.down([[G]]);else if(d===w)n.emit(a[1]);else if(d===M)n.down([[M]]);else if(d===x)n.down([[x]]);else if(d===N){o();return}else if(d===K){r?.(),n.down([a]);return}else n.down([a])}}),()=>{s?.(),r?.()}},{...We(),initial:t.cache})}function Dn(t,e){if(e<=0)throw new RangeError("timeoutNs must be > 0");return R(n=>{let r=!1,s=new Oe;function o(){let a=e/1e6;s.start(a,()=>{r||(r=!0,i(),n.down([[N,new ot(e)]]))})}let i=t.subscribe(a=>{for(let d of a){if(r)return;let u=d[0];if(u===G)n.down([[G]]);else if(u===w)o(),n.emit(d[1]);else if(u===M)n.down([[M]]);else if(u===x){s.cancel(),r=!0,n.down([[x]]);return}else if(u===N){s.cancel(),r=!0,n.down([d]);return}else if(u===K){s.cancel(),r=!0,n.down([d]);return}else n.down([d])}});return o(),()=>{r=!0,s.cancel(),i()}},{...We(),initial:t.cache})}var nt,rt,ot,Pt=he(()=>{"use strict";ye();Le();X();we();ue();mt();Ie();At();nt=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};rt=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};ot=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});function Ee(t){return{describeKind:"producer",...t}}function vr(t){return/[\\^$+?.()|[\]{}]/.test(t)?`\\${t}`:t}function zo(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){t[n+1]==="*"?(e+=".*",n+=1):e+="[^/]*";continue}e+=vr(r)}return e+="$",new RegExp(e)}function jo(t,e){for(let n of e)if(n.test(t))return!0;return!1}function Wo(t,e){let n=B([t],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[M]]);return}for(let a of i)o.emit(a)},{describeKind:"derived",initial:t.cache}),r=n.subscribe.bind(n);return n.subscribe=(s,o)=>(e(s),r(s,o)),n}function He(t,e){let{signal:n,period:r,...s}=e??{};return R(o=>{let i=!1,a=0,d,u,c=()=>{i=!0,d!==void 0&&clearTimeout(d),u!==void 0&&clearInterval(u),n?.removeEventListener("abort",p)},f=()=>{i||(r!=null?(o.emit(a++),u=setInterval(()=>{i||o.emit(a++)},r)):(i=!0,n?.removeEventListener("abort",p),o.emit(a++),o.down([[x]])))},p=()=>{i||(c(),o.down([[N,n.reason]]))};if(n?.aborted){p();return}return d=setTimeout(f,t),n?.addEventListener("abort",p,{once:!0}),c},Ee(s))}function Ho(t){let{signal:e,...n}=t??{};return R(r=>{let s=!1,o,i,a=!1,d=!1,u=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,c=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,f=typeof document<"u"?document:void 0,p=()=>{o!==void 0&&c&&c(o),i!==void 0&&clearTimeout(i),o=void 0,i=void 0},h=()=>{s=!0,p(),a&&(e?.removeEventListener("abort",l),a=!1),d&&f&&(f.removeEventListener("visibilitychange",b),d=!1)},l=()=>{s||(h(),r.down([[N,e.reason]]))},m=y=>{s||(r.emit(y),g())},g=()=>{s||(u&&(!f||f.visibilityState!=="hidden")?o=u(m):i=setTimeout(()=>m(performance.now()),16))},b=()=>{s||(p(),g())};return e?.aborted?(l(),h):(e?.addEventListener("abort",l,{once:!0}),a=e!==void 0,f&&u&&(f.addEventListener("visibilitychange",b),d=!0),g(),h)},Ee(n))}function Uo(t,e){let n=Nn(t),{tickMs:r,output:s,...o}=e??{},i=r??6e4,a=s==="date";return R(d=>{let u=-1,c=()=>{let p=new Date,h=p.getFullYear()*1e8+(p.getMonth()+1)*1e6+p.getDate()*1e4+p.getHours()*100+p.getMinutes();h!==u&&En(n,p)&&(u=h,d.emit(a?p:re()))};c();let f=setInterval(c,i);return()=>clearInterval(f)},{...Ee(o),name:o.name??`cron:${t}`})}function qo(t,e,n){let{capture:r,passive:s,once:o,...i}=n??{};return R(a=>{let d=c=>{a.emit(c)},u={capture:r,passive:s,once:o};return t.addEventListener(e,d,u),()=>t.removeEventListener(e,d,u)},Ee(i))}function Ln(t,e){return R(n=>{let r=!1;try{for(let s of t){if(r)return;n.emit(s)}r||n.down([[x]])}catch(s){r||n.down([[N,s]])}return()=>{r=!0}},Ee(e))}function Jo(t){return t!=null&&typeof t.then=="function"}function Tr(t,e){let{signal:n,...r}=e??{};return R(s=>{let o=!1,i=()=>{o||(o=!0,s.down([[N,n.reason]]))};if(n?.aborted){i();return}return n?.addEventListener("abort",i,{once:!0}),Promise.resolve(t).then(a=>{o||(o=!0,n?.removeEventListener("abort",i),s.emit(a),s.down([[x]]))},a=>{o||(o=!0,n?.removeEventListener("abort",i),s.down([[N,a]]))}),()=>{o=!0,n?.removeEventListener("abort",i)}},Ee(r))}function wr(t,e){let{signal:n,...r}=e??{};return R(s=>{let o=new AbortController,i=()=>o.abort(n?.reason);n?.aborted?o.abort(n.reason):n?.addEventListener("abort",i,{once:!0});let a=n??o.signal,d=!1,u=t[Symbol.asyncIterator](),c=()=>{d||a.aborted||Promise.resolve(u.next()).then(f=>{if(!(d||a.aborted)){if(f.done){s.down([[x]]);return}s.emit(f.value),c()}},f=>{!d&&!a.aborted&&s.down([[N,f]])})};return c(),()=>{d=!0,n?.removeEventListener("abort",i),o.abort(),Promise.resolve(u.return?.()).catch(()=>{})}},Ee(r))}function Yo(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function de(t,e){if(Yo(t))return t;if(Jo(t))return Tr(t,e);if(t!=null){let n=t;if(typeof n[Symbol.asyncIterator]=="function")return wr(t,e);if(typeof n[Symbol.iterator]=="function")return Ln(t,e)}return xr(t)}function xr(...t){return Ln(t,void 0)}function Qo(t){return R(e=>{e.down([[x]])},Ee(t))}function Xo(t){return R(()=>{},Ee(t))}function Zo(t,e){return R(n=>{n.down([[N,t]])},Ee(e))}function Ue(t,e,n){return B([t],(s,o)=>{let i=s[0];if(i!=null&&i.length>0)for(let a of i)e(a)},{describeKind:"effect",...n}).subscribe(()=>{})}function es(t,e){return B([t],(n,r,s)=>{s.store.buf||(s.store.buf=[]);let o=s.store.buf,i=n[0];if(i!=null&&i.length>0)for(let a of i)o.push(a);if(s.terminalDeps[0]===!0){r.emit([...o]),r.down([[x]]);return}(i==null||i.length===0)&&r.down([[M]])},{describeKind:"derived",completeWhenDepsComplete:!1,...e})}function ts(t,e){return R(n=>t.subscribe(r=>{n.down(r)}),{...Ee(e),initial:t.cache})}function Bn(t,e,n){if(e<1)throw new RangeError("replay expects bufferSize >= 1");let r=[],s=R(o=>t.subscribe(i=>{for(let a of i)a[0]===w&&(r.push(a[1]),r.length>e&&r.shift());o.down(i)}),{...Ee(n),initial:t.cache});return Wo(s,o=>{for(let i of r)o([[w,i]])})}function ns(t,e){return Bn(t,1,e)}function Vn(t){return new Promise((e,n)=>{let r=!1,s=!1,o;o=t.subscribe(i=>{for(let a of i){if(r)return;if(a[0]===w){r=!0,e(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===N){r=!0,n(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===x){r=!0,n(new Error("completed without DATA")),o?(o(),o=void 0):s=!0;return}}}),s&&(o?.(),o=void 0)})}function In(t,e){return new Promise((n,r)=>{let s=!1,o=!1,i;i=t.subscribe(a=>{for(let d of a){if(s)return;if(d[0]===w){let u=d[1];if(e(u)){s=!0,n(u),i?(i(),i=void 0):o=!0;return}}if(d[0]===N){s=!0,r(d[1]),i?(i(),i=void 0):o=!0;return}if(d[0]===x){s=!0,r(new Error("completed without matching value")),i?(i(),i=void 0):o=!0;return}}}),o&&(i?.(),i=void 0)})}async function rs(t,e){let n=e?.predicate??(s=>s!=null);if(e?.timeoutMs==null||e.timeoutMs<=0)return await In(t,n);if(Pn===void 0){let[s,o]=await Promise.all([Promise.resolve().then(()=>(Pt(),br)),Promise.resolve().then(()=>(mt(),hr))]);Pn=s.timeout,yr=o.NS_PER_MS}let r=Pn(t,e.timeoutMs*yr);return await In(r,n)}function It(t){return t.subscribe(()=>{})}function ss(t){let e=F(0);return{node:e,increment(){let n=e.cache??0;return n>=t?!1:(e.down([[G],[w,n+1]]),!0)},get(){return e.cache??0},atCap(){return(e.cache??0)>=t}}}var Pn,yr,os,Ie=he(()=>{"use strict";Le();X();we();ue();Sn();os=Bn});var ru={};on(ru,{CircuitOpenError:()=>nt,NS_PER_MS:()=>fe,NS_PER_SEC:()=>Ae,NativeIndexBackend:()=>Kt,NativeListBackend:()=>zt,NativeLogBackend:()=>jt,NativeMapBackend:()=>Ft,NativePubSubBackend:()=>$t,RateLimiterOverflowError:()=>rt,ResettableTimer:()=>Oe,TimeoutError:()=>ot,audit:()=>Ns,awaitSettled:()=>rs,buffer:()=>Es,bufferCount:()=>Ss,bufferTime:()=>Rs,cached:()=>ns,cascadingCache:()=>Vi,catchError:()=>Gs,checkpointToRedis:()=>Ri,checkpointToS3:()=>Oi,circuitBreaker:()=>Rn,combine:()=>Nr,combineLatest:()=>Ls,concat:()=>ys,concatMap:()=>ws,constant:()=>vn,createTransport:()=>Ye,createWatermarkController:()=>Bi,csvRows:()=>li,debounce:()=>Sr,debounceTime:()=>Bs,decorrelatedJitter:()=>kn,delay:()=>ks,deserializeError:()=>lt,dictStorage:()=>ea,distill:()=>$i,distinctUntilChanged:()=>hs,elementAt:()=>fs,empty:()=>Qo,escapeRegexChar:()=>vr,exhaustMap:()=>Ts,exponential:()=>wn,externalBundle:()=>_n,externalProducer:()=>tt,fallback:()=>Cn,fibonacci:()=>xn,filter:()=>Bt,find:()=>ls,first:()=>Gn,firstValueFrom:()=>Vn,firstWhere:()=>In,flatMap:()=>xs,forEach:()=>Ue,fromAny:()=>de,fromAsyncIter:()=>wr,fromCSV:()=>ci,fromClickHouseWatch:()=>hi,fromCron:()=>Uo,fromDrizzle:()=>Pi,fromEvent:()=>qo,fromHTTP:()=>Ar,fromHTTPPoll:()=>qs,fromHTTPStream:()=>Us,fromIter:()=>Ln,fromKafka:()=>ii,fromKysely:()=>Ii,fromMCP:()=>Qs,fromNATS:()=>bi,fromNDJSON:()=>pi,fromOTel:()=>Xs,fromPrisma:()=>Di,fromPrometheus:()=>oi,fromPromise:()=>Tr,fromPulsar:()=>mi,fromRabbitMQ:()=>vi,fromRaf:()=>Ho,fromRedisStream:()=>ui,fromSSE:()=>Hs,fromSqlite:()=>Mi,fromSqliteCursor:()=>Ai,fromStatsD:()=>ti,fromSyslog:()=>Zs,fromTimer:()=>He,fromWebSocket:()=>Mr,fromWebSocketReconnect:()=>Ys,fromWebhook:()=>$s,globToRegExp:()=>zo,interval:()=>Cs,keepalive:()=>It,last:()=>cs,linear:()=>Tn,lru:()=>Br,map:()=>Lt,matchesAnyPattern:()=>jo,matchesCron:()=>En,memoryStorage:()=>Zi,merge:()=>vt,mergeMap:()=>Er,nameToSignal:()=>dt,ndjsonRows:()=>fi,never:()=>Xo,of:()=>xr,pairwise:()=>ms,parseCron:()=>Nn,parsePrometheusText:()=>Pr,parseStatsD:()=>ri,parseSyslog:()=>ei,pausable:()=>Ps,pubsub:()=>zi,race:()=>vs,rateLimiter:()=>An,reactiveCounter:()=>ss,reactiveIndex:()=>Hi,reactiveList:()=>Ui,reactiveLog:()=>Ji,reactiveMap:()=>Kn,reactiveSink:()=>ie,reduce:()=>as,repeat:()=>Ds,replay:()=>Bn,rescue:()=>Rr,resolveBackoffPreset:()=>je,retry:()=>On,retrySource:()=>bt,sample:()=>_s,scan:()=>is,serializeError:()=>ct,share:()=>ts,shareReplay:()=>os,signalToName:()=>Je,singleFromAny:()=>Yi,singleNodeFromAny:()=>Qi,skip:()=>_r,sortJsonValue:()=>Wt,stableJsonString:()=>Xi,stratify:()=>Qa,switchMap:()=>Ce,take:()=>Vt,takeUntil:()=>ds,takeWhile:()=>us,tap:()=>ps,throttle:()=>Or,throttleTime:()=>Vs,throwError:()=>Zo,timeout:()=>Dn,toArray:()=>es,toCSV:()=>wi,toClickHouse:()=>xi,toFile:()=>Lr,toHTTP:()=>Ks,toKafka:()=>ai,toLoki:()=>Ei,toMongo:()=>Ni,toNATS:()=>yi,toObservable:()=>Ki,toPostgres:()=>_i,toPulsar:()=>gi,toRabbitMQ:()=>Ti,toReadableStream:()=>Ws,toRedisStream:()=>di,toS3:()=>ki,toSSE:()=>zs,toSSEBytes:()=>js,toSqlite:()=>Ci,toTempo:()=>Si,toWebSocket:()=>Js,tokenBucket:()=>Dt,valve:()=>Is,verifiable:()=>Fi,window:()=>As,windowCount:()=>Os,windowTime:()=>Ms,withBreaker:()=>Mn,withLatestFrom:()=>gs,withMaxAttempts:()=>pr,withStatus:()=>yt,workerBridge:()=>go,workerSelf:()=>bo,zip:()=>bs});module.exports=_o(ru);ye();Le();X();we();ue();ye();X();ue();function mr(t){return{describeKind:"producer",...t}}function tt(t,e){return R(n=>{let r=!0,s={emit(i){r&&n.emit(i)},error(i){r&&(r=!1,n.down([[N,i]]))},complete(){r&&(r=!1,n.down([[x]]))}},o;try{let i=t(s);o=typeof i=="function"?i:void 0}catch(i){return s.error(i),()=>{r=!1}}return()=>{r=!1;try{o?.()}catch{}}},mr(e))}function _n(t,e,n){let r=!0,s,o=0,i=0,a={},d=[],u=()=>{let h=s;s=void 0;try{h?.()}catch{}};for(let h of e){let l=n?.name?`${n.name}::${h}`:h,m=n?.channelOpts?.[h],g=R(b=>(o++,()=>{i++,o>0&&i>=o&&i>=e.length&&u()}),mr({...m,name:l}));a[h]=g,d.push(g)}let c={};for(let h of e)c[h]=l=>{r&&a[h].down([[w,l]])};c.error=h=>{r&&(r=!1,j(()=>{for(let l of d)l.down([[N,h]])}),u())},c.complete=()=>{r&&(r=!1,j(()=>{for(let h of d)h.down([[x]])}),u())};let f=t(c);return s=typeof f=="function"?f:void 0,Object.assign(a,{dispose:()=>{r&&(r=!1,j(()=>{for(let h of d)try{h.down([[x]])}catch{}}),u())}})}Le();X();we();ue();Ie();function V(t){return{describeKind:"derived",...t}}function kr(t){return{describeKind:"derived",partial:!0,...t}}function Lt(t,e,n){return B([t],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[M]]);return}for(let i of o)s.emit(e(i))},V(n))}function Bt(t,e,n){return B([t],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[M]]);return}let i=!1;for(let a of o)e(a)&&(s.emit(a),i=!0);i||s.down([[M]])},V(n))}function is(t,e,n,r){return B([t],(s,o,i)=>{"acc"in i.store||(i.store.acc=n);let a=s[0];if(a==null||a.length===0){o.down([[M]]);return}for(let d of a)i.store.acc=e(i.store.acc,d),o.emit(i.store.acc)},{...V(r),initial:n,resetOnTeardown:!0})}function as(t,e,n,r){return B([t],(s,o,i)=>{if("acc"in i.store||(i.store.acc=n),i.terminalDeps[0]===!0){o.emit(i.store.acc),o.down([[x]]);return}let a=s[0];if(a==null||a.length===0){o.down([[M]]);return}for(let d of a)i.store.acc=e(i.store.acc,d)},{...V(r),completeWhenDepsComplete:!1})}function Vt(t,e,n){return e<=0?B([t],(r,s,o)=>{o.store.completed||(o.store.completed=!0,s.down([[x]]))},{...V(n),completeWhenDepsComplete:!1}):B([t],(r,s,o)=>{if("taken"in o.store||(o.store.taken=0),o.store.done){s.down([[M]]);return}if(o.terminalDeps[0]===!0){o.store.done=!0,s.down([[x]]);return}let i=r[0];if(i==null||i.length===0){s.down([[M]]);return}for(let a of i)if(o.store.taken++,s.emit(a),o.store.taken>=e){o.store.done=!0,s.down([[x]]);return}},{...V(n),completeWhenDepsComplete:!1})}function _r(t,e,n){return B([t],(r,s,o)=>{"skipped"in o.store||(o.store.skipped=0);let i=r[0];if(i==null||i.length===0){s.down([[M]]);return}let a=!1;for(let d of i)o.store.skipped++,o.store.skipped<=e||(s.emit(d),a=!0);a||s.down([[M]])},V(n))}function us(t,e,n){return B([t],(r,s,o)=>{if(o.store.done){s.down([[M]]);return}let i=r[0];if(i==null||i.length===0){s.down([[M]]);return}for(let a of i){if(!e(a)){o.store.done=!0,s.down([[x]]);return}s.emit(a)}},{...V(n),completeWhenDepsComplete:!1})}function ds(t,e,n){let r=n?.predicate??(i=>i[0]===w),{predicate:s,...o}=n??{};return R(i=>{let a=!1,d=t.subscribe(c=>{if(!a)for(let f of c){if(a)return;f[0]===w?i.emit(f[1]):(f[0]===x||f[0]===N)&&(a=!0,i.down([f]))}}),u=e.subscribe(c=>{if(!a)for(let f of c){if(a)return;if(r(f)){a=!0,i.down([[x]]);return}}});return()=>{d(),u()}},V(o))}function Gn(t,e){return Vt(t,1,e)}function cs(t,e){let{defaultValue:n,...r}=e??{},s=e!=null&&Object.hasOwn(e,"defaultValue");return B([t],(o,i,a)=>{if(a.terminalDeps[0]===!0){a.store.has?i.emit(a.store.latest):s&&i.emit(n),i.down([[x]]);return}let d=o[0];if(d==null||d.length===0){i.down([[M]]);return}a.store.latest=d.at(-1),a.store.has=!0},{...V(r),completeWhenDepsComplete:!1})}function ls(t,e,n){return Vt(Bt(t,e,n),1,n)}function fs(t,e,n){return Vt(_r(t,e,n),1,n)}function ps(t,e,n){if(typeof e=="function")return B([t],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[M]]);return}for(let a of i)e(a),o.emit(a)},V(n));let r=e;return B([t],(s,o,i)=>{if(i.terminalDeps[0]!==void 0){i.terminalDeps[0]===!0?(r.complete?.(),o.down([[x]])):(r.error?.(i.terminalDeps[0]),o.down([[N,i.terminalDeps[0]]]));return}let a=s[0];if(a==null||a.length===0){o.down([[M]]);return}for(let d of a)r.data?.(d),o.emit(d)},{...V(n),completeWhenDepsComplete:!1})}function hs(t,e=Object.is,n){return B([t],(r,s,o)=>{let i=r[0];if(i==null||i.length===0){s.down([[M]]);return}let a=!1;for(let d of i)o.store.hasPrev&&e(o.store.prev,d)||(o.store.prev=d,o.store.hasPrev=!0,s.emit(d),a=!0);a||s.down([[M]])},V(n))}function ms(t,e){return B([t],(n,r,s)=>{let o=n[0];if(o==null||o.length===0){r.down([[M]]);return}let i=!1;for(let a of o)if(!s.store.hasPrev)s.store.prev=a,s.store.hasPrev=!0;else{let d=[s.store.prev,a];s.store.prev=a,r.emit(d),i=!0}i||r.down([[M]])},V(e))}function Nr(...t){let e=[...t];return xe(e,n=>n,{...V(),equals:(n,r)=>{if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++)if(!Object.is(n[s],r[s]))return!1;return!0}})}function gs(t,e,n){return B([t,e],(r,s,o)=>{let i=r[0],a=r[1],d=a!=null&&a.length>0?a.at(-1):o.prevData[1];if(i!=null&&i.length>0){if(!(a!=null&&a.length>0)&&o.prevData[1]===void 0){s.down([[M]]);return}for(let u of i)s.emit([u,d])}else s.down([[M]])},kr(n))}function vt(...t){return t.length===0?R(e=>{e.down([[x]])},V()):R(e=>{let n=t.length,r=0,s=[];for(let o of t){let i=o.subscribe(a=>{for(let d of a)d[0]===w?e.emit(d[1]):d[0]===x?(r+=1,r>=n&&e.down([[x]])):d[0]===N&&e.down([d])});s.push(i)}return()=>{for(let o of s)o()}},V())}function bs(...t){let e=t.length;return e===0?R(n=>{n.emit([]),n.down([[x]])},V()):R(n=>{let r=Array.from({length:e},()=>[]),s=e;function o(){for(;r.every(a=>a.length>0);){let a=r.map(d=>d.shift());n.emit(a)}}let i=[];for(let a=0;a<e;a++){let d=a,u=t[a].subscribe(c=>{for(let f of c)f[0]===w?(r[d].push(f[1]),o()):f[0]===x?(s-=1,(s===0||r[d].length===0)&&n.down([[x]])):f[0]===N&&n.down([f])});i.push(u)}return()=>{for(let a of i)a()}},V())}function ys(t,e,n){return R(r=>{let s=0,o=[],i,a;return a=e.subscribe(d=>{for(let u of d)s===0?u[0]===w?o.push(u[1]):u[0]===N&&r.down([u]):u[0]===w?r.emit(u[1]):(u[0]===x||u[0]===N)&&r.down([u])}),i=t.subscribe(d=>{for(let u of d)if(s===0)if(u[0]===w)r.emit(u[1]);else if(u[0]===x){s=1;for(let c of o)r.emit(c);o.length=0}else u[0]===N&&r.down([u])}),()=>{i?.(),a?.()}},V(n))}function vs(...t){return t.length===0?R(e=>{e.down([[x]])},V()):t.length===1?B([t[0]],(e,n)=>{let r=e[0];if(r==null||r.length===0){n.down([[M]]);return}for(let s of r)n.emit(s)},V()):R(e=>{let n=null,r=[];for(let s=0;s<t.length;s++){let o=s,i=t[s].subscribe(a=>{for(let d of a){if(n!==null&&o!==n)return;d[0]===w?(n===null&&(n=o),e.emit(d[1])):(d[0]===x||d[0]===N)&&(n===null||o===n)&&e.down([d])}});r.push(i)}return()=>{for(let s of r)s()}},V())}function Gt(t,e,n){let r,s=!1,o=()=>{s||(s=!0,n())};return r=t.subscribe(i=>{let a=!1,d=!1;for(let u of i)u[0]!==Ke&&(u[0]===w?e.emit(u[1]):u[0]===x?a=!0:u[0]===N?(d=!0,e.down([u])):(u[0]===G||u[0]===M)&&e.down([u]));d?(r?.(),r=void 0,o()):a&&o()}),()=>{r?.(),r=void 0}}function Ce(t,e,n){let r,s=!1;function o(){r?.(),r=void 0}return B([t],(i,a,d)=>{if(d.terminalDeps[0]!=null&&d.terminalDeps[0]!==!0){o();return}if(d.terminalDeps[0]===!0){s=!0,r||a.down([[x]]);return}let u=i[0];if(!(u==null||u.length===0))return o(),r=Gt(de(e(u[u.length-1])),a,()=>{o(),s&&a.down([[x]])}),{deactivate:()=>{o(),s=!1}}},{...V(n),completeWhenDepsComplete:!1})}function Ts(t,e,n){let r,s=!1;function o(){r?.(),r=void 0}return B([t],(i,a,d)=>{if(d.terminalDeps[0]!=null&&d.terminalDeps[0]!==!0){o();return}if(d.terminalDeps[0]===!0){s=!0,r||a.down([[x]]);return}let u=i[0];if(!(u==null||u.length===0))return r===void 0?r=Gt(de(e(u[0])),a,()=>{o(),s&&a.down([[x]])}):a.down([[M]]),{deactivate:()=>{o(),s=!1}}},{...V(n),completeWhenDepsComplete:!1})}function ws(t,e,n){let{maxBuffer:r,...s}=n??{},o=[],i,a=!1,d;function u(){i?.(),i=void 0}function c(){if(!d||i!==void 0)return;if(o.length===0){a&&d.down([[x]]);return}let p=o.shift();i=Gt(de(e(p)),d,()=>{u(),c()})}function f(p){r&&r>0&&o.length>=r&&o.shift(),o.push(p),c()}return B([t],(p,h,l)=>{if(d=h,l.terminalDeps[0]!=null&&l.terminalDeps[0]!==!0){u(),o.length=0;return}if(l.terminalDeps[0]===!0){a=!0,c();return}let m=p[0];if(!(m==null||m.length===0)){for(let g of m)f(g);return{deactivate:()=>{u(),o.length=0,a=!1}}}},{...V(s),completeWhenDepsComplete:!1})}function Er(t,e,n){let{concurrent:r,...s}=n??{},o=r!=null&&r>0?r:Number.POSITIVE_INFINITY,i=0,a=!1,d=new Set,u=[],c;function f(){a&&i===0&&u.length===0&&c&&c.down([[x]])}function p(g){if(!c)return;i++;let b;b=Gt(de(e(g)),c,()=>{b&&d.delete(b),i--,h(),f()}),d.add(b)}function h(){for(;u.length>0&&i<o;)p(u.shift())}function l(g){i<o?p(g):u.push(g)}function m(){for(let g of d)g();d.clear(),i=0,u.length=0}return B([t],(g,b,y)=>{if(c=b,y.terminalDeps[0]!=null&&y.terminalDeps[0]!==!0){m();return}if(y.terminalDeps[0]===!0){a=!0,f();return}let v=g[0];if(!(v==null||v.length===0)){for(let T of v)l(T);return{deactivate:()=>{m(),a=!1}}}},{...V(s),completeWhenDepsComplete:!1})}var xs=Er;function ks(t,e,n){return R(r=>{let s=new Set;function o(){for(let a of s)clearTimeout(a);s.clear()}let i=t.subscribe(a=>{for(let d of a)if(d[0]===w){let u=setTimeout(()=>{s.delete(u),r.emit(d[1])},e);s.add(u)}else if(d[0]===x){let u=setTimeout(()=>{s.delete(u),r.down([[x]])},e);s.add(u)}else d[0]===N&&(o(),r.down([d]))});return()=>{i(),o()}},V(n))}function Sr(t,e,n){return R(r=>{let s,o;function i(){s!==void 0&&(clearTimeout(s),s=void 0)}let a=t.subscribe(d=>{for(let u of d)u[0]===w?(i(),o=u[1],s=setTimeout(()=>{s=void 0,r.emit(o)},e)):u[0]===x?(s!==void 0&&(i(),r.emit(o)),r.down([[x]])):u[0]===N&&(i(),r.down([u]))});return()=>{a(),i()}},V(n))}function Or(t,e,n){let{leading:r,trailing:s,...o}=n??{},i=r!==!1,a=s===!0,d=e*1e6;return R(u=>{let c,f=-1/0,p,h=!1;function l(){c!==void 0&&(clearTimeout(c),c=void 0)}let m=t.subscribe(g=>{for(let b of g)if(b[0]===w){let y=b[1],v=ne();if(i&&v-f>=d)f=v,u.emit(y),l(),a&&(c=setTimeout(()=>{c=void 0,h&&(f=ne(),u.emit(p),h=!1)},e));else if(a&&(p=y,h=!0,c===void 0)){let T=(v-f)/1e6;c=setTimeout(()=>{c=void 0,h&&(f=ne(),u.emit(p),h=!1)},Math.max(0,e-T))}}else(b[0]===x||b[0]===N)&&(l(),u.down([b]))});return()=>{m(),l()}},V(o))}function _s(t,e,n){return R(r=>{let s,o=!1,i=!1,a=t.subscribe(u=>{if(!o)for(let c of u){if(o)return;c[0]===w?s={v:c[1]}:c[0]===N?(o=!0,r.down([c])):c[0]===x&&(i=!0,s=void 0)}}),d=e.subscribe(u=>{if(!o)for(let c of u){if(o)return;c[0]===w?s!==void 0&&!i&&r.emit(s.v):c[0]===N?(o=!0,r.down([c])):c[0]===x&&(o=!0,r.down([[x]]))}});return()=>{a(),d()}},V(n))}function Ns(t,e,n){return R(r=>{let s,o,i=!1;function a(){s!==void 0&&(clearTimeout(s),s=void 0)}let d=t.subscribe(u=>{for(let c of u)c[0]===w?(o=c[1],i=!0,a(),s=setTimeout(()=>{s=void 0,i&&(i=!1,r.emit(o))},e)):(c[0]===x||c[0]===N)&&(a(),r.down([c]))});return()=>{d(),a()}},V(n))}function Es(t,e,n){return R(r=>{let s=[],o=t.subscribe(a=>{for(let d of a)d[0]===w?s.push(d[1]):d[0]===x?(s.length>0&&r.emit([...s]),s.length=0,r.down([[x]])):d[0]===N&&r.down([d])}),i=e.subscribe(a=>{for(let d of a)d[0]===w?s.length>0&&(r.emit([...s]),s.length=0):d[0]===x?r.down([[x]]):d[0]===N&&r.down([d])});return()=>{o(),i(),s.length=0}},V(n))}function Ss(t,e,n){if(e<=0)throw new RangeError("bufferCount expects count > 0");return R(r=>{let s=[],o=t.subscribe(i=>{for(let a of i)a[0]===w?(s.push(a[1]),s.length>=e&&r.emit(s.splice(0,s.length))):a[0]===x?(s.length>0&&r.emit([...s]),s.length=0,r.down([[x]])):a[0]===N&&r.down([a])});return()=>{o(),s.length=0}},V(n))}function Os(t,e,n){if(e<=0)throw new RangeError("windowCount expects count > 0");return R(r=>{let s,o=0;function i(){let d=R(u=>(s=u.down.bind(u),()=>{s=void 0}),V());o=0,r.emit(d)}let a=t.subscribe(d=>{for(let u of d)u[0]===w?(s||i(),s?.([[w,u[1]]]),o+=1,o>=e&&(s?.([[x]]),s=void 0)):u[0]===x?(s?.([[x]]),s=void 0,r.down([[x]])):u[0]===N&&(s?.([u]),s=void 0,r.down([u]))});return()=>{a(),s?.([[x]]),s=void 0}},V(n))}function Rs(t,e,n){return R(r=>{let s=[],o=setInterval(()=>{s.length>0&&(r.emit([...s]),s.length=0)},e),i=t.subscribe(a=>{for(let d of a)d[0]===w?s.push(d[1]):d[0]===x?(clearInterval(o),s.length>0&&r.emit([...s]),s.length=0,r.down([[x]])):d[0]===N&&(clearInterval(o),r.down([d]))});return()=>{i(),clearInterval(o),s.length=0}},V(n))}function Ms(t,e,n){return R(r=>{let s;function o(){s?.([[x]]),s=void 0}function i(){let u=R(c=>(s=c.down.bind(c),()=>{s=void 0}),V());r.emit(u)}i();let a=setInterval(()=>{o(),i()},e),d=t.subscribe(u=>{for(let c of u)c[0]===w?s?.([[w,c[1]]]):c[0]===x?(clearInterval(a),o(),r.down([[x]])):c[0]===N&&(clearInterval(a),s?.([c]),o(),r.down([c]))});return()=>{d(),clearInterval(a),o()}},V(n))}function As(t,e,n){return R(r=>{let s;function o(){s?.([[x]]),s=void 0}function i(){let u=R(c=>(s=c.down.bind(c),()=>{s=void 0}),V());r.emit(u)}let a=t.subscribe(u=>{for(let c of u)c[0]===w?(s||i(),s?.([[w,c[1]]])):c[0]===x?(o(),r.down([[x]])):c[0]===N&&(s?.([c]),s=void 0,r.down([c]))}),d=e.subscribe(u=>{for(let c of u)c[0]===w&&(o(),i())});return()=>{a(),d(),o()}},V(n))}function Cs(t,e){return R((n,r)=>{"n"in r.store||(r.store.n=0);let s=setInterval(()=>{n.emit(r.store.n),r.store.n=r.store.n+1},t);return()=>clearInterval(s)},V(e))}function Ds(t,e,n){if(e<=0)throw new RangeError("repeat expects count > 0");return R(r=>{let s=e,o,i=()=>{o?.(),o=t.subscribe(a=>{let d=!1,u=[];for(let c of a)c[0]===x?d=!0:u.push(c);u.length>0&&r.down(u),d&&(o?.(),o=void 0,s-=1,s>0?i():r.down([[x]]))})};return i(),()=>{o?.()}},V(n))}function Ps(t,e){return B([t],(n,r)=>{let s=n[0];if(s==null||s.length===0){r.down([[M]]);return}for(let o of s)r.emit(o)},V(e))}function Rr(t,e,n){return R(r=>{let s=t.subscribe(o=>{for(let i of o)if(i[0]===w)r.emit(i[1]);else if(i[0]===N)try{r.emit(e(i[1]))}catch(a){r.down([[N,a]])}else i[0]===x&&r.down([[x]])});return()=>{s()}},V(n))}function Is(t,e,n){return B([t,e],(r,s,o)=>{let i=r[1];if(!(i!=null&&i.length>0?i.at(-1):o.prevData[1])){s.down([[M]]);return}let d=r[0];if(d!=null&&d.length>0){for(let u of d)s.emit(u);return}if(i!=null&&i.length>0&&o.prevData[0]!==void 0){s.emit(o.prevData[0]);return}s.down([[M]])},kr(n))}var Ls=Nr,Bs=Sr,Vs=Or,Gs=Rr;X();we();ue();mt();var qe=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let n=(this.head+this._size)%this.capacity;this.buf[n]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let n=e<0?this._size+e:e;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this.buf[(this.head+n)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};var Fn=class{ring;arr;constructor(e){e===Number.POSITIVE_INFINITY||e<=0?(this.arr=[],this.ring=null):(this.ring=new qe(e),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(e){this.ring!=null?this.ring.push(e):this.arr.push(e)}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 e=this.arr;return this.arr=[],e}};function Tt(t){return t instanceof Error?t:new Error(String(t))}function Fs(t){return t===void 0?null:typeof t=="string"?je(t):t}function ie(t,e){let{name:n,onTransportError:r,retry:s,backpressure:o,batchSize:i=Number.POSITIVE_INFINITY,flushIntervalMs:a=0,serialize:d,stopOn:u,onUpstreamMessage:c,onDispose:f,send:p,sendBatch:h,ctx:l}=e;if(!p&&!h)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let m=l,g=Math.max(1,s?.maxAttempts??1),b=Fs(s?.backoff??(g>1?"exponential":void 0)),y=s?.shouldRetry??(()=>!0),v=h!==void 0||i<Number.POSITIVE_INFINITY||a>0,T=C=>n?`${n}::${C}`:void 0,k=F(void 0,{equals:()=>!1,name:T("sent")}),_=F(null,{name:T("failed")}),E=F(0,{name:T("inFlight")}),S=F(null,{name:T("errors")}),A=v?F(0,{name:T("buffered")}):void 0,I=o?F(!1,{name:T("paused")}):void 0,D=0,L=C=>{D+=C,E.down([[w,D]])},O=C=>{try{r?.(C)}catch{}try{S.down([[w,C]])}catch{}},$=new Set,ee=C=>{$.add(C);let W=()=>$.delete(C);C.then(W,W)},z=(C,W,J)=>{let Q=b?b(W-1,J,null):0,ae=Q==null?0:typeof Q=="number"&&Q>0?Q:0,Se=Math.max(1,Math.ceil(ae/1e6));return new Promise(Y=>{setTimeout(()=>Y(C()),Se)})},te=C=>C!=null&&typeof C=="object"&&typeof C.then=="function",ke=C=>{let W;try{W=d?d(C):C}catch(Y){let H=Tt(Y);return O({stage:"serialize",error:H,value:C}),_.down([[w,{value:C,error:H,attempts:0}]]),Promise.resolve()}let J=0,Q=Y=>{L(-1);let H=Tt(Y);if(O({stage:"send",error:H,value:C,attempt:J}),!(J<g&&y(H,J))){_.down([[w,{value:C,error:H,attempts:J}]]);return}return z(Se,J,H)},ae=()=>{L(-1),k.down([[w,C]])};function Se(){J+=1,L(1);let Y;try{Y=p(W,m)}catch(H){return Q(H)??Promise.resolve()}return te(Y)?Y.then(ae,H=>Q(H)):(ae(),Promise.resolve())}return Se()},De=o?.maxBuffer??Number.POSITIVE_INFINITY,_e=new Fn(De),ge,Ve=!1,P=()=>{A?.down([[w,_e.length]])},q=C=>{I&&I.down([[w,C]])},pe=o?.strategy??"drop-oldest",Ge=(C,W)=>{let J={value:C,payload:W};if(_e.length<De)return _e.push(J),P(),!0;if(pe==="drop-oldest"){let ae=_e.shift();return _e.push(J),P(),q(!0),_.down([[w,{value:ae.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(pe==="drop-newest")return q(!0),_.down([[w,{value:C,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let Q=new Error("backpressure: buffer overflow");return O({stage:"send",error:Q,value:C}),_.down([[w,{value:C,error:Q,attempts:0}]]),q(!0),!1},be=C=>{let W=0,J=C.map(Y=>Y.payload),Q=Y=>{L(-1);let H=Tt(Y);if(O({stage:"send",error:H,value:C.map(nn=>nn.value),attempt:W}),!(W<g&&y(H,W))){for(let{value:nn}of C)_.down([[w,{value:nn,error:H,attempts:W}]]);return}return z(Se,W,H)},ae=()=>{L(-1);for(let{value:Y}of C)k.down([[w,Y]])};function Se(){W+=1,L(1);let Y;try{Y=h(J,m)}catch(H){return Q(H)??Promise.resolve()}return te(Y)?Y.then(ae,H=>Q(H)):(ae(),Promise.resolve())}return Se()},U=async C=>{for(let W of C)await ce(W.value,W.payload)},ce=(C,W)=>{let J=0,Q=Y=>{L(-1);let H=Tt(Y);if(O({stage:"send",error:H,value:C,attempt:J}),!(J<g&&y(H,J))){_.down([[w,{value:C,error:H,attempts:J}]]);return}return z(Se,J,H)},ae=()=>{L(-1),k.down([[w,C]])};function Se(){J+=1,L(1);let Y;try{Y=p(W,m)}catch(H){return Q(H)??Promise.resolve()}return te(Y)?Y.then(ae,H=>Q(H)):(ae(),Promise.resolve())}return Se()},Pe=()=>{if(Ve||_e.length===0)return Promise.resolve();let C=_e.drain();if(P(),q(!1),h!==void 0){let J=be(C);return ee(J),J}let W=U(C);return ee(W),W},yo=()=>{ge!==void 0||Ve||a<=0||(ge=setTimeout(()=>{ge=void 0,Pe()},a))},vo=t.subscribe(C=>{for(let W of C){let J=W[0];if(J!==w)try{c?.(W)}catch{}if(J===w){let Q=W[1];if(v){let ae;if(d)try{ae=d(Q)}catch(Y){let H=Tt(Y);O({stage:"serialize",error:H,value:Q}),_.down([[w,{value:Q,error:H,attempts:0}]]);continue}else ae=Q;if(!Ge(Q,ae))continue;_e.length>=i?Pe():yo()}else{let ae=ke(Q);ee(ae)}}else le.messageTier(J)>=3&&v&&(ge!==void 0&&(clearTimeout(ge),ge=void 0),Pe())}}),qn;if(u){let C=!1;qn=u.subscribe(W=>{if(!C){C=!0;return}W.length>0&&!tn&&Jn()})}let tn=!1,Jn=()=>{if(tn)return;tn=!0,ge!==void 0&&(clearTimeout(ge),ge=void 0),v&&Pe(),Ve=!0,qn?.(),vo();let C=W=>{try{W.down([[K]])}catch{}};C(S),C(_),C(k),C(E),A&&C(A),I&&C(I);try{f?.()}catch{}},kt={dispose:Jn,sent:k,failed:_,inFlight:E,errors:S};return v&&(kt.buffered=A,kt.flush=async()=>{Ve||(await Pe(),await Promise.all($))}),I&&(kt.paused=I),kt}Pt();Ie();function Re(t){return{describeKind:"producer",...t}}function Mr(t,e){let{parse:n,closeOnTeardown:r=!1,...s}=e??{};return R(o=>{let i=!0,a,d=()=>{let b=a;a=void 0,b?.()},u=b=>{i&&(i=!1,o.down([b]),d())},c=(b,y=b)=>{if(i)try{let v=b!==null&&typeof b=="object"&&"data"in b?b.data:b,T=n?n(v,y):v;o.emit(T)}catch(v){u([N,v])}},f=b=>{u([N,b])},p=()=>{u([x])};if(typeof t=="function"){try{if(a=t(c,f,p),typeof a!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(b){u([N,b])}return()=>{i=!1,d()}}let h=t,l=b=>c(b,b),m=b=>f(b),g=()=>p();return h.addEventListener("message",l),h.addEventListener("error",m),h.addEventListener("close",g),a=()=>{h.removeEventListener("message",l),h.removeEventListener("error",m),h.removeEventListener("close",g),r&&h.close()},()=>{i=!1,d()}},Re(s))}function $s(t,e){return tt(t,e)}function Ar(t,e){let{method:n="GET",headers:r,body:s,transform:o=v=>v.json(),timeoutNs:i=30*1e9,signal:a,completeAfterFetch:d=!1,refetchOnSubscribe:u=!1,...c}=e??{},f=F(0,{name:`${c.name??"http"}/fetchCount`}),p=F(0,{name:`${c.name??"http"}/lastUpdated`}),h=F(!1,{name:`${c.name??"http"}/fetched`}),l=0,m=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0,g=v=>{let T=new AbortController,k=!0;if(a?.aborted)return k=!1,v.down([[N,a.reason??new Error("Aborted")]]),()=>{};a?.addEventListener("abort",()=>T.abort(a.reason),{once:!0});let _=setTimeout(()=>T.abort(new Error("Request timeout")),Math.ceil(i/1e6));return fetch(t,{method:n,headers:r,body:m,signal:T.signal}).then(async E=>{if(clearTimeout(_),!k)return;if(!E.ok)throw new Error(`HTTP ${E.status}: ${E.statusText}`);let S=await o(E);k&&(j(()=>{l+=1,f.down([[w,l]]),p.down([[w,re()]]),h.down([[w,!0]]),v.emit(S)}),d&&v.down([[x]]))}).catch(E=>{clearTimeout(_),k&&(E&&E.name==="AbortError"||v.down([[N,E]]))}),()=>{k=!1,T.abort()}},b=R(v=>g({emit:T=>v.emit(T),down:T=>v.down(T)}),{...Re(c),resubscribable:u});return{...yt(b),fetchCount:f,lastUpdated:p,fetched:h}}function Ks(t,e,n){let{method:r="POST",headers:s={"Content-Type":"application/json"},serialize:o=l=>JSON.stringify(l),timeoutNs:i,batchFormat:a="json-array",batchSize:d,flushIntervalMs:u,retry:c,onTransportError:f}=n??{},p=async l=>{let m=i!==void 0?new AbortController:void 0,g;m&&i!==void 0&&(g=setTimeout(()=>m.abort(new Error("Request timeout")),Math.ceil(i/1e6)));try{let b=await fetch(e,{method:r,headers:s,body:l,signal:m?.signal}),y=async()=>{try{await b.arrayBuffer?.()}catch{}};if(!b.ok)throw await y(),new Error(`HTTP ${b.status}: ${b.statusText}`);await y()}finally{g!==void 0&&clearTimeout(g)}};return d!==void 0||u!==void 0?ie(t,{onTransportError:f,retry:c,batchSize:d,flushIntervalMs:u,sendBatch:async l=>{let m;a==="ndjson"?m=l.map(g=>{let b=o(g);return typeof b=="string"?b:new TextDecoder().decode(b)}).join(`
2
+ `):m=JSON.stringify(l),await p(m)}}):ie(t,{onTransportError:f,retry:c,serialize:o,send:async l=>{await p(l)}})}function Cr(t){return Symbol.keyFor(t)??t.description??"message"}function st(t,e){return typeof t=="string"?t:e(t)}function Dr(t,e){let n=`event: ${t}
3
+ `;if(e!==void 0){let r=e.split(/\r?\n/);for(let s of r)n+=`data: ${s}
4
+ `}return`${n}
5
+ `}function zs(t,e){let{serialize:n=h=>{if(h instanceof Error)return h.message;try{return JSON.stringify(h)}catch{return String(h)}},dataEvent:r="data",errorEvent:s="error",completeEvent:o="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:d,signal:u,eventNameResolver:c=Cr}=e??{},f=new TextEncoder,p;return new ReadableStream({start(h){let l=!1,m,g=()=>{},b=()=>{l||(l=!0,m!==void 0&&clearInterval(m),u?.removeEventListener("abort",v),g(),h.close())};p=b;let y=(T,k)=>{l||h.enqueue(f.encode(Dr(T,k)))},v=()=>{l||b()};g=t.subscribe(T=>{for(let k of T){let _=k[0];if(!(le.isLocalOnly(_)&&!(_===G&&a))){if(_===w){y(r,st(k[1],n));continue}if(_===N){y(s,st(k[1],n)),b();return}if(_===x){y(o),b();return}!i&&_===M||y(c(_),k.length>1?st(k[1],n):void 0)}}}),d!==void 0&&d>0&&(m=setInterval(()=>{l||h.enqueue(f.encode(`: keepalive
6
6
 
7
- `))},d)),u?.aborted?v():u?.addEventListener("abort",v,{once:!0})},cancel(){p?.()}})}function Os(n,e){let{serialize:t=p=>{if(p instanceof Error)return p.message;try{return JSON.stringify(p)}catch{return String(p)}},dataEvent:r="data",errorEvent:s="error",completeEvent:o="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:d,signal:u,eventNameResolver:c=Sr}=e??{},f=new TextEncoder;return O(p=>{let h=!0,l,m=(y,v)=>{h&&p.emit(f.encode(Or(y,v)))},g=()=>{h&&(h=!1,p.down([[k]]))},b=n.subscribe(y=>{if(h)for(let v of y){let T=v[0];if(!(le.isLocalOnly(T)&&!(T===B&&a))){if(T===w){m(r,ot(v[1],t));continue}if(T===N){m(s,ot(v[1],t)),h=!1,p.down([[k]]);return}if(T===k){m(o),h=!1,p.down([[k]]);return}!i&&T===R||m(c(T),v.length>1?ot(v[1],t):void 0)}}});return d!==void 0&&d>0&&(l=setInterval(()=>{h&&p.emit(f.encode(`: keepalive
7
+ `))},d)),u?.aborted?v():u?.addEventListener("abort",v,{once:!0})},cancel(){p?.()}})}function js(t,e){let{serialize:n=p=>{if(p instanceof Error)return p.message;try{return JSON.stringify(p)}catch{return String(p)}},dataEvent:r="data",errorEvent:s="error",completeEvent:o="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:d,signal:u,eventNameResolver:c=Cr}=e??{},f=new TextEncoder;return R(p=>{let h=!0,l,m=(y,v)=>{h&&p.emit(f.encode(Dr(y,v)))},g=()=>{h&&(h=!1,p.down([[x]]))},b=t.subscribe(y=>{if(h)for(let v of y){let T=v[0];if(!(le.isLocalOnly(T)&&!(T===G&&a))){if(T===w){m(r,st(v[1],n));continue}if(T===N){m(s,st(v[1],n)),h=!1,p.down([[x]]);return}if(T===x){m(o),h=!1,p.down([[x]]);return}!i&&T===M||m(c(T),v.length>1?st(v[1],n):void 0)}}});return d!==void 0&&d>0&&(l=setInterval(()=>{h&&p.emit(f.encode(`: keepalive
8
8
 
9
- `))},d)),u?.aborted?g():u?.addEventListener("abort",g,{once:!0}),()=>{h=!1,l!==void 0&&clearInterval(l),u?.removeEventListener("abort",g),b()}})}function Rs(n){let e,t=!1;return new ReadableStream({start(r){e=n.subscribe(s=>{for(let o of s){let i=o[0];if(t)return;if(i===w)try{r.enqueue(o[1])}catch{t=!0,e?.()}else if(i===N){t=!0;try{r.error(o[1])}catch{}return}else if(i===k){t=!0;try{r.close()}catch{}return}}})},cancel(){t=!0,e?.()}})}function Ms(n,e){let{parse:t=s=>s,...r}=e??{};return O(s=>{let o=!0,i=new TextDecoder,a="",d="message",u=[],c,f,p=()=>{if(u.length===0&&d==="message"&&c===void 0){u=[];return}let y=u.join(`
10
- `);s.emit({event:d,data:t(y),id:c,retry:f}),d="message",u=[],c=void 0,f=void 0},h=y=>{if(y===""){p();return}if(y.startsWith(":"))return;let v=y.indexOf(":"),T=v<0?y:y.slice(0,v),x=v<0?"":y.slice(v+1);switch(x.startsWith(" ")&&(x=x.slice(1)),T){case"event":d=x;break;case"data":u.push(x);break;case"id":x.includes("\0")||(c=x);break;case"retry":{let _=Number(x);Number.isFinite(_)&&(f=_);break}}},l=(y,v)=>{if(!o)return;a+=i.decode(y,{stream:!v});let T=a.split(/\r?\n/);a=T.pop()??"";for(let x of T)h(x)},m,g;return(async()=>{try{let y=n,v=n instanceof ReadableStream?n:y&&typeof y=="object"&&y.body instanceof ReadableStream?y.body:null;if(v){for(m=v.getReader();o;){let{value:T,done:x}=await m.read();if(x)break;l(T,!1)}l(new Uint8Array,!0)}else{for(g=n[Symbol.asyncIterator]();o;){let x=await g.next();if(x.done)break;l(x.value,!1)}l(new Uint8Array,!0)}if(a.trim()){for(let T of a.split(/\r?\n/))h(T);p()}o&&s.down([[k]])}catch(y){o&&s.down([[N,y]])}})(),()=>{o=!1,m&&m.cancel().catch(()=>{}),g&&typeof g.return=="function"&&Promise.resolve(g.return()).catch(()=>{})}},Re(r))}function As(n,e){let{method:t="GET",headers:r,body:s,signal:o,...i}=e??{};return O(a=>{let d=!0,u=new AbortController;if(o?.aborted)return a.down([[N,o.reason??new Error("Aborted")]]),()=>{};o?.addEventListener("abort",()=>u.abort(o.reason),{once:!0});let c=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0;return(async()=>{try{let p=await fetch(n,{method:t,headers:r,body:c,signal:u.signal});if(!d)return;if(!p.ok)throw new Error(`HTTP ${p.status}: ${p.statusText}`);if(!p.body)throw new Error("HTTP response has no body");let h=p.body.getReader();for(;d;){let{value:l,done:m}=await h.read();if(m)break;l&&a.emit(l)}d&&a.down([[k]])}catch(p){if(!d||p&&p.name==="AbortError")return;a.down([[N,p]])}})(),()=>{d=!1,u.abort()}},Re(i))}function Cs(n,e){let{intervalMs:t=5e3,...r}=e??{};return Ce(We(t,{period:t}),()=>Er(n,{...r,completeAfterFetch:!0}).node)}function Ds(n,e,t){let{serialize:r=b=>{if(typeof b=="string"||b instanceof Blob||b instanceof ArrayBuffer||ArrayBuffer.isView(b))return b;try{return JSON.stringify(b)}catch{return String(b)}},closeOnComplete:s=!0,closeOnError:o=!0,closeCode:i,closeReason:a,onTransportError:d,retry:u,backpressure:c,stopOn:f}=t??{},p=!1,h=b=>{if(!p){p=!0;try{e.close(i,a)}catch(y){let v=y instanceof Error?y:new Error(String(y));try{d?.({stage:"close",error:v,value:void 0,message:b})}catch{}}}},l=null,g=se(n,{onTransportError:d,serialize:b=>{let y=r(b);if(y===void 0)throw new Error("serialize returned undefined");return y},retry:u,backpressure:c,stopOn:f,onDispose:()=>{if(l){try{e.removeEventListener("close",l)}catch{}l=null}},send:b=>{e.send(b)},onUpstreamMessage:b=>{(b[0]===k&&s||b[0]===N&&o)&&h(b)}});return l=()=>{p=!0,g.dispose()},e.addEventListener("close",l),g}function Ps(n,e){let{parse:t,maxRetries:r,backoff:s="exponential",closeOnTeardown:o=!0,...i}=e??{};return gt(()=>Nr(n(),{parse:t,closeOnTeardown:o,...i}),{count:r,backoff:s})}function Is(n,e){let{method:t="notifications/message",onDisconnect:r,...s}=e??{};return et(({emit:o,error:i})=>(n.setNotificationHandler(t,a=>o(a)),r?.(a=>i(a??new Error("MCP client disconnected"))),()=>n.setNotificationHandler(t,()=>{})),s)}function Ls(n,e){return Tn(({traces:r,metrics:s,logs:o,error:i})=>n({onTraces:a=>{K(()=>{for(let d of a)r(d)})},onMetrics:a=>{K(()=>{for(let d of a)s(d)})},onLogs:a=>{K(()=>{for(let d of a)o(d)})},onError:i})??void 0,["traces","metrics","logs"],e?.name?{name:e.name}:void 0)}function Bs(n,e){return et(n,e)}function Vs(n){let e=n.match(/^<(\d{1,3})>\d?\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*)/s);if(!e){let r=ne();return{facility:1,severity:6,timestamp:new Date(Math.floor(r/1e6)).toISOString(),hostname:"-",appName:"-",procId:"-",msgId:"-",message:n.trim(),timestampNs:r}}let t=Number(e[1]);return{facility:t>>3,severity:t&7,timestamp:e[2],hostname:e[3],appName:e[4],procId:e[5],msgId:e[6],message:(e[7]??"").trim(),timestampNs:ne()}}function Fs(n,e){return et(n,e)}var $s={c:"counter",g:"gauge",ms:"timer",h:"histogram",s:"set",d:"distribution"};function Gs(n){let e=n.split("|"),[t,r]=(e[0]??"").split(":");if(!t||r===void 0)throw new Error(`Invalid StatsD line: ${n}`);let s=e[1]?.trim()??"c",o=$s[s]??"counter",i=o==="set"?0:Number(r),a,d={};for(let u=2;u<e.length;u++){let c=e[u].trim();if(c.startsWith("@"))a=Number(c.slice(1));else if(c.startsWith("#"))for(let f of c.slice(1).split(",")){let[p,h]=f.split(":");p&&(d[p]=h??"")}}return{name:t.trim(),value:i,type:o,sampleRate:a,tags:d,timestampNs:ne()}}function Ks(n,e){let{intervalNs:t=15*1e9,headers:r,timeoutNs:s=10*1e9,signal:o,maxConsecutiveErrors:i=1}=e??{},a=Math.ceil(t/1e6),d=0;return Ce(We(0,{period:a,signal:o}),()=>O(u=>{let c=!0,f=new AbortController,p=setTimeout(()=>f.abort(new Error("Scrape timeout")),Math.ceil(s/1e6));return(async()=>{try{let l=await fetch(n,{headers:{Accept:"text/plain",...r},signal:f.signal});if(clearTimeout(p),!c)return;if(!l.ok)throw new Error(`Prometheus scrape ${l.status}: ${l.statusText}`);let m=await l.text();if(!c)return;let g=Rr(m);for(let b of g)u.emit(b);d=0,u.down([[k]])}catch(l){if(clearTimeout(p),!c||l instanceof Error&&l.name==="AbortError")return;d+=1,d>=i&&u.down([[N,l]])}})(),()=>{c=!1,clearTimeout(p),f.abort()}}))}function Rr(n){let e=[],t=new Map,r=new Map;for(let s of n.split(`
11
- `)){let o=s.trim();if(!o)continue;if(o.startsWith("# TYPE ")){let p=o.slice(7),h=p.indexOf(" ");h>0&&t.set(p.slice(0,h),p.slice(h+1).trim());continue}if(o.startsWith("# HELP ")){let p=o.slice(7),h=p.indexOf(" ");h>0&&r.set(p.slice(0,h),p.slice(h+1).trim());continue}if(o.startsWith("#"))continue;let i,a={},d,u,c=o.indexOf("{");if(c>=0){i=o.slice(0,c);let p=o.indexOf("}",c);if(p<0)continue;let h=o.slice(c+1,p);a=zs(h);let l=o.slice(p+1).trim().split(/\s+/);d=l[0]??"",u=l[1]}else{let p=o.split(/\s+/);i=p[0]??"",d=p[1]??"",u=p[2]}if(!i||!d)continue;let f=i.replace(/(_total|_count|_sum|_bucket|_created|_info)$/,"");e.push({name:i,labels:a,value:Number(d),timestampMs:u?Number(u):void 0,type:t.get(f)??t.get(i),help:r.get(f)??r.get(i),timestampNs:ne()})}return e}function zs(n){let e={},t=/(\w+)="((?:[^"\\]|\\.)*)"/g,r=t.exec(n);for(;r!==null;)e[r[1]]=r[2].replace(/\\(.)/g,"$1"),r=t.exec(n);return e}function js(n,e,t){let{fromBeginning:r=!1,deserialize:s=i=>{if(i===null)return null;try{return JSON.parse(i.toString())}catch{return i.toString()}},...o}=t??{};return O(i=>{let a=!0;return(async()=>{try{await n.subscribe({topic:e,fromBeginning:r}),await n.run({eachMessage:async({topic:u,partition:c,message:f})=>{if(!a)return;let p={};if(f.headers)for(let[h,l]of Object.entries(f.headers))l!==void 0&&(p[h]=typeof l=="string"?l:l.toString());i.emit({topic:u,partition:c,key:f.key?.toString()??null,value:s(f.value),headers:p,offset:f.offset,timestamp:f.timestamp,timestampNs:ne()})}})}catch(u){a&&i.down([[N,u]])}})(),()=>{a=!1}},Re(o))}function Ws(n,e,t,r){let{serialize:s=a=>JSON.stringify(a),keyExtractor:o,onTransportError:i}=r??{};return se(n,{onTransportError:i,send:async a=>{let d=o?.(a)??null,u=s(a);await e.send({topic:t,messages:[{key:d,value:Buffer.from(u)}]})}})}function Us(n,e,t){let{blockMs:r=5e3,startId:s="$",parse:o=a=>{for(let u=0;u<a.length;u+=2)if(a[u]==="data")try{return JSON.parse(a[u+1])}catch{return a[u+1]}let d={};for(let u=0;u<a.length;u+=2)d[a[u]]=a[u+1];return d},...i}=t??{};return O(a=>{let d=!0,u=s;return(async()=>{for(;d;)try{let f=await n.xread("BLOCK",r,"STREAMS",e,u);if(!d)return;if(f)for(let[p,h]of f)for(let[l,m]of h)u=l,a.emit({id:l,key:e,data:o(m),timestampNs:ne()})}catch(f){if(!d)return;a.down([[N,f]]);return}})(),()=>{d=!1}},Re(i))}function Hs(n,e,t,r){let{serialize:s=a=>["data",JSON.stringify(a)],maxLen:o,onTransportError:i}=r??{};return se(n,{onTransportError:i,send:async a=>{let d=s(a);await(o!==void 0?e.xadd(t,"MAXLEN","~",String(o),"*",...d):e.xadd(t,"*",...d))}})}function qs(n,e){let{delimiter:t=",",hasHeader:r=!0,columns:s,parseLine:o,...i}=e??{},a=o??(d=>Mr(d,t));return O(d=>{let u=!1;return(async()=>{try{let f=s,p="";for await(let h of n){if(u)return;p+=h;let l=p.split(/\r?\n/);p=l.pop()??"";for(let m of l){if(u)return;if(!m.trim())continue;let g=a(m);if(!f&&r){f=g;continue}f||(f=g.map((y,v)=>`col${v}`));let b={};for(let y=0;y<f.length;y++)b[f[y]]=g[y]??"";d.emit(b)}}if(!u&&p.trim()){let h=a(p);if(f){let l={};for(let m=0;m<f.length;m++)l[f[m]]=h[m]??"";d.emit(l)}}u||d.down([[k]])}catch(f){u||d.down([[N,f]])}})(),()=>{u=!0}},Re(i))}function Js(n,e){let{delimiter:t=",",hasHeader:r=!0,columns:s,parseLine:o,...i}=e??{},a=o??(d=>Mr(d,t));return I([n],(d,u,c)=>{let f=d[0];if(f==null||f.length===0)return;let p=c.store;typeof p.buffer!="string"&&(p.buffer=""),p.headers===void 0&&s&&(p.headers=s.slice());for(let h of f){p.buffer=p.buffer+h;let l=p.buffer.split(/\r?\n/);p.buffer=l.pop()??"";for(let m of l){if(!m.trim())continue;let g=a(m);if(!p.headers&&r){p.headers=g;continue}p.headers||(p.headers=g.map((y,v)=>`col${v}`));let b={};for(let y=0;y<p.headers.length;y++)b[p.headers[y]]=g[y]??"";u.emit(b)}}},{describeKind:"derived",...i})}function Ys(n,e){return I([n],(t,r,s)=>{let o=t[0];if(o==null||o.length===0)return;let i=s.store;typeof i.buffer!="string"&&(i.buffer="");for(let a of o){i.buffer=i.buffer+a;let d=i.buffer.split(/\r?\n/);i.buffer=d.pop()??"";for(let u of d)if(u.trim())try{r.emit(JSON.parse(u))}catch(c){r.down([[N,c]]);return}}},{describeKind:"derived",...e??{}})}function Mr(n,e){let t=[],r="",s=!1;for(let o=0;o<n.length;o++){let i=n[o];s?i==='"'?n[o+1]==='"'?(r+='"',o++):s=!1:r+=i:i==='"'?s=!0:i===e?(t.push(r),r=""):r+=i}return t.push(r),t}function Qs(n,e){return O(t=>{let r=!1;return(async()=>{try{let o="";for await(let i of n){if(r)return;o+=i;let a=o.split(/\r?\n/);o=a.pop()??"";for(let d of a){if(r)return;let u=d.trim();u&&t.emit(JSON.parse(u))}}!r&&o.trim()&&t.emit(JSON.parse(o.trim())),r||t.down([[k]])}catch(o){r||t.down([[N,o]])}})(),()=>{r=!0}},Re(e))}function Xs(n,e,t){let{intervalNs:r=5*1e9,format:s="JSONEachRow",signal:o,maxConsecutiveErrors:i=1}=t??{},a=Math.ceil(r/1e6),d=0;return Ce(We(0,{period:a,signal:o}),()=>O(u=>{let c=!0;return(async()=>{try{let p=await n.query({query:e,format:s});if(!c)return;let h=await p.json();if(!c)return;for(let l of h)u.emit(l);d=0,u.down([[k]])}catch(p){if(!c)return;d+=1,d>=i&&u.down([[N,p]])}})(),()=>{c=!1}}))}function Zs(n,e){let{autoAck:t=!0,deserialize:r=a=>{try{return JSON.parse(a.toString())}catch{return a.toString()}},onAckError:s,...o}=e??{},i=a=>{if(s)try{s(a instanceof Error?a:new Error(String(a)))}catch{}};return O(a=>{let d=!0;return(async()=>{for(;d;)try{let c=await n.receive();if(!d)return;let f={topic:c.getTopicName(),messageId:c.getMessageId().toString(),key:c.getPartitionKey(),value:r(c.getData()),properties:c.getProperties(),publishTime:c.getPublishTimestamp(),eventTime:c.getEventTimestamp(),timestampNs:ne()};if(t)a.emit(f),n.acknowledge(c).catch(i);else{let p=!1,h={value:f,ack(){p||(p=!0,n.acknowledge(c).catch(i))},nack(l){if(p)return;p=!0;let m=n;try{let g=m.negativeAcknowledge?.(c);g&&typeof g.then=="function"&&g.catch(i)}catch(g){i(g)}}};a.emit(h)}}catch(c){d&&a.down([[N,c]]);return}})(),()=>{d=!1}},Re(o))}function ei(n,e,t){let{serialize:r=a=>Buffer.from(JSON.stringify(a)),keyExtractor:s,propertiesExtractor:o,onTransportError:i}=t??{};return se(n,{onTransportError:i,send:async a=>{await e.send({data:r(a),partitionKey:s?.(a),properties:o?.(a)})}})}function ti(n,e,t){let r=new TextDecoder,{queue:s,deserialize:o=a=>{let d=r.decode(a);try{return JSON.parse(d)}catch{return d}},...i}=t??{};return O(a=>{let d=!0,u=n.subscribe(e,s?{queue:s}:void 0);return(async()=>{try{for await(let f of u){if(!d)return;let p={};if(f.headers)for(let h of f.headers.keys())p[h]=f.headers.get(h);a.emit({subject:f.subject,data:o(f.data),headers:p,reply:f.reply,sid:f.sid,timestampNs:ne()})}d&&a.down([[k]])}catch(f){d&&a.down([[N,f]])}})(),()=>{d=!1}},Re(i))}function ni(n,e,t,r){let s=new TextEncoder,{serialize:o=a=>s.encode(JSON.stringify(a)),onTransportError:i}=r??{};return se(n,{onTransportError:i,send:a=>{e.publish(t,o(a))}})}function ri(n,e,t){let{autoAck:r=!0,deserialize:s=d=>{try{return JSON.parse(d.toString())}catch{return d.toString()}},onAckError:o,...i}=t??{},a=d=>{if(o)try{o(d instanceof Error?d:new Error(String(d)))}catch{}};return O(d=>{let u=!0,c;return(async()=>{try{c=(await n.consume(e,h=>{if(!u)return;if(h===null){u&&d.down([[N,new Error("Consumer cancelled by broker")]]);return}let l={queue:e,routingKey:h.fields.routingKey,exchange:h.fields.exchange,content:s(h.content),properties:h.properties,deliveryTag:h.fields.deliveryTag,redelivered:h.fields.redelivered,timestampNs:ne()};if(r){d.emit(l);try{n.ack(h)}catch(m){a(m)}}else{let m=!1,g=n,b={value:l,ack(){if(!m){m=!0;try{n.ack(h)}catch(y){a(y)}}},nack(y){if(m)return;m=!0;let v=y?.requeue;if(!g.nack){a(new Error("RabbitMQ channel does not expose `nack`; cannot negative-ack"));return}try{g.nack(h,!1,v)}catch(T){a(T)}}};d.emit(b)}},{noAck:!1})).consumerTag}catch(p){u&&d.down([[N,p]])}})(),()=>{u=!1,c!==void 0&&n.cancel(c)}},Re(i))}function oi(n,e,t,r){let{serialize:s=a=>Buffer.from(JSON.stringify(a)),routingKeyExtractor:o=()=>"",onTransportError:i}=r??{};return se(n,{onTransportError:i,send:a=>{let d=o(a),u=s(a);e.publish(t,d,u)}})}function Ar(n,e,t){let{serialize:r=f=>`${JSON.stringify(f)}
12
- `,flushIntervalMs:s=0,batchSize:o=Number.POSITIVE_INFINITY,onTransportError:i,mode:a}=t??{},u=s>0||o<Number.POSITIVE_INFINITY?se(n,{onTransportError:i,batchSize:o,flushIntervalMs:s,serialize:r,sendBatch:f=>{e.write(f.join(""))}}):se(n,{onTransportError:i,serialize:r,send:f=>{e.write(f)}}),c=u.dispose;return u.dispose=()=>{c();try{e.end()}catch{}},u}function Bn(n,e){return n.includes(e)||n.includes('"')||n.includes(`
13
- `)?`"${n.replace(/"/g,'""')}"`:n}function si(n,e,t){let{columns:r,delimiter:s=",",writeHeader:o=!0,cellExtractor:i=(h,l)=>String(h[l]??""),flushIntervalMs:a=0,batchSize:d=Number.POSITIVE_INFINITY,onTransportError:u,...c}=t,f=!1;return Ar(n,e,{serialize:h=>{if(!f&&o){f=!0;let l=r.map(g=>Bn(g,s)).join(s),m=r.map(g=>Bn(i(h,g),s)).join(s);return`${l}
9
+ `))},d)),u?.aborted?g():u?.addEventListener("abort",g,{once:!0}),()=>{h=!1,l!==void 0&&clearInterval(l),u?.removeEventListener("abort",g),b()}})}function Ws(t){let e,n=!1;return new ReadableStream({start(r){e=t.subscribe(s=>{for(let o of s){let i=o[0];if(n)return;if(i===w)try{r.enqueue(o[1])}catch{n=!0,e?.()}else if(i===N){n=!0;try{r.error(o[1])}catch{}return}else if(i===x){n=!0;try{r.close()}catch{}return}}})},cancel(){n=!0,e?.()}})}function Hs(t,e){let{parse:n=s=>s,...r}=e??{};return R(s=>{let o=!0,i=new TextDecoder,a="",d="message",u=[],c,f,p=()=>{if(u.length===0&&d==="message"&&c===void 0){u=[];return}let y=u.join(`
10
+ `);s.emit({event:d,data:n(y),id:c,retry:f}),d="message",u=[],c=void 0,f=void 0},h=y=>{if(y===""){p();return}if(y.startsWith(":"))return;let v=y.indexOf(":"),T=v<0?y:y.slice(0,v),k=v<0?"":y.slice(v+1);switch(k.startsWith(" ")&&(k=k.slice(1)),T){case"event":d=k;break;case"data":u.push(k);break;case"id":k.includes("\0")||(c=k);break;case"retry":{let _=Number(k);Number.isFinite(_)&&(f=_);break}}},l=(y,v)=>{if(!o)return;a+=i.decode(y,{stream:!v});let T=a.split(/\r?\n/);a=T.pop()??"";for(let k of T)h(k)},m,g;return(async()=>{try{let y=t,v=t instanceof ReadableStream?t:y&&typeof y=="object"&&y.body instanceof ReadableStream?y.body:null;if(v){for(m=v.getReader();o;){let{value:T,done:k}=await m.read();if(k)break;l(T,!1)}l(new Uint8Array,!0)}else{for(g=t[Symbol.asyncIterator]();o;){let k=await g.next();if(k.done)break;l(k.value,!1)}l(new Uint8Array,!0)}if(a.trim()){for(let T of a.split(/\r?\n/))h(T);p()}o&&s.down([[x]])}catch(y){o&&s.down([[N,y]])}})(),()=>{o=!1,m&&m.cancel().catch(()=>{}),g&&typeof g.return=="function"&&Promise.resolve(g.return()).catch(()=>{})}},Re(r))}function Us(t,e){let{method:n="GET",headers:r,body:s,signal:o,...i}=e??{};return R(a=>{let d=!0,u=new AbortController;if(o?.aborted)return a.down([[N,o.reason??new Error("Aborted")]]),()=>{};o?.addEventListener("abort",()=>u.abort(o.reason),{once:!0});let c=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0;return(async()=>{try{let p=await fetch(t,{method:n,headers:r,body:c,signal:u.signal});if(!d)return;if(!p.ok)throw new Error(`HTTP ${p.status}: ${p.statusText}`);if(!p.body)throw new Error("HTTP response has no body");let h=p.body.getReader();for(;d;){let{value:l,done:m}=await h.read();if(m)break;l&&a.emit(l)}d&&a.down([[x]])}catch(p){if(!d||p&&p.name==="AbortError")return;a.down([[N,p]])}})(),()=>{d=!1,u.abort()}},Re(i))}function qs(t,e){let{intervalMs:n=5e3,...r}=e??{};return Ce(He(n,{period:n}),()=>Ar(t,{...r,completeAfterFetch:!0}).node)}function Js(t,e,n){let{serialize:r=b=>{if(typeof b=="string"||b instanceof Blob||b instanceof ArrayBuffer||ArrayBuffer.isView(b))return b;try{return JSON.stringify(b)}catch{return String(b)}},closeOnComplete:s=!0,closeOnError:o=!0,closeCode:i,closeReason:a,onTransportError:d,retry:u,backpressure:c,stopOn:f}=n??{},p=!1,h=b=>{if(!p){p=!0;try{e.close(i,a)}catch(y){let v=y instanceof Error?y:new Error(String(y));try{d?.({stage:"close",error:v,value:void 0,message:b})}catch{}}}},l=null,g=ie(t,{onTransportError:d,serialize:b=>{let y=r(b);if(y===void 0)throw new Error("serialize returned undefined");return y},retry:u,backpressure:c,stopOn:f,onDispose:()=>{if(l){try{e.removeEventListener("close",l)}catch{}l=null}},send:b=>{e.send(b)},onUpstreamMessage:b=>{(b[0]===x&&s||b[0]===N&&o)&&h(b)}});return l=()=>{p=!0,g.dispose()},e.addEventListener("close",l),g}function Ys(t,e){let{parse:n,maxRetries:r,backoff:s="exponential",closeOnTeardown:o=!0,...i}=e??{};return bt(()=>Mr(t(),{parse:n,closeOnTeardown:o,...i}),{count:r,backoff:s})}function Qs(t,e){let{method:n="notifications/message",onDisconnect:r,...s}=e??{};return tt(({emit:o,error:i})=>(t.setNotificationHandler(n,a=>o(a)),r?.(a=>i(a??new Error("MCP client disconnected"))),()=>t.setNotificationHandler(n,()=>{})),s)}function Xs(t,e){return _n(({traces:r,metrics:s,logs:o,error:i})=>t({onTraces:a=>{j(()=>{for(let d of a)r(d)})},onMetrics:a=>{j(()=>{for(let d of a)s(d)})},onLogs:a=>{j(()=>{for(let d of a)o(d)})},onError:i})??void 0,["traces","metrics","logs"],e?.name?{name:e.name}:void 0)}function Zs(t,e){return tt(t,e)}function ei(t){let e=t.match(/^<(\d{1,3})>\d?\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*)/s);if(!e){let r=re();return{facility:1,severity:6,timestamp:new Date(Math.floor(r/1e6)).toISOString(),hostname:"-",appName:"-",procId:"-",msgId:"-",message:t.trim(),timestampNs:r}}let n=Number(e[1]);return{facility:n>>3,severity:n&7,timestamp:e[2],hostname:e[3],appName:e[4],procId:e[5],msgId:e[6],message:(e[7]??"").trim(),timestampNs:re()}}function ti(t,e){return tt(t,e)}var ni={c:"counter",g:"gauge",ms:"timer",h:"histogram",s:"set",d:"distribution"};function ri(t){let e=t.split("|"),[n,r]=(e[0]??"").split(":");if(!n||r===void 0)throw new Error(`Invalid StatsD line: ${t}`);let s=e[1]?.trim()??"c",o=ni[s]??"counter",i=o==="set"?0:Number(r),a,d={};for(let u=2;u<e.length;u++){let c=e[u].trim();if(c.startsWith("@"))a=Number(c.slice(1));else if(c.startsWith("#"))for(let f of c.slice(1).split(",")){let[p,h]=f.split(":");p&&(d[p]=h??"")}}return{name:n.trim(),value:i,type:o,sampleRate:a,tags:d,timestampNs:re()}}function oi(t,e){let{intervalNs:n=15*1e9,headers:r,timeoutNs:s=10*1e9,signal:o,maxConsecutiveErrors:i=1}=e??{},a=Math.ceil(n/1e6),d=0;return Ce(He(0,{period:a,signal:o}),()=>R(u=>{let c=!0,f=new AbortController,p=setTimeout(()=>f.abort(new Error("Scrape timeout")),Math.ceil(s/1e6));return(async()=>{try{let l=await fetch(t,{headers:{Accept:"text/plain",...r},signal:f.signal});if(clearTimeout(p),!c)return;if(!l.ok)throw new Error(`Prometheus scrape ${l.status}: ${l.statusText}`);let m=await l.text();if(!c)return;let g=Pr(m);for(let b of g)u.emit(b);d=0,u.down([[x]])}catch(l){if(clearTimeout(p),!c||l instanceof Error&&l.name==="AbortError")return;d+=1,d>=i&&u.down([[N,l]])}})(),()=>{c=!1,clearTimeout(p),f.abort()}}))}function Pr(t){let e=[],n=new Map,r=new Map;for(let s of t.split(`
11
+ `)){let o=s.trim();if(!o)continue;if(o.startsWith("# TYPE ")){let p=o.slice(7),h=p.indexOf(" ");h>0&&n.set(p.slice(0,h),p.slice(h+1).trim());continue}if(o.startsWith("# HELP ")){let p=o.slice(7),h=p.indexOf(" ");h>0&&r.set(p.slice(0,h),p.slice(h+1).trim());continue}if(o.startsWith("#"))continue;let i,a={},d,u,c=o.indexOf("{");if(c>=0){i=o.slice(0,c);let p=o.indexOf("}",c);if(p<0)continue;let h=o.slice(c+1,p);a=si(h);let l=o.slice(p+1).trim().split(/\s+/);d=l[0]??"",u=l[1]}else{let p=o.split(/\s+/);i=p[0]??"",d=p[1]??"",u=p[2]}if(!i||!d)continue;let f=i.replace(/(_total|_count|_sum|_bucket|_created|_info)$/,"");e.push({name:i,labels:a,value:Number(d),timestampMs:u?Number(u):void 0,type:n.get(f)??n.get(i),help:r.get(f)??r.get(i),timestampNs:re()})}return e}function si(t){let e={},n=/(\w+)="((?:[^"\\]|\\.)*)"/g,r=n.exec(t);for(;r!==null;)e[r[1]]=r[2].replace(/\\(.)/g,"$1"),r=n.exec(t);return e}function ii(t,e,n){let{fromBeginning:r=!1,deserialize:s=i=>{if(i===null)return null;try{return JSON.parse(i.toString())}catch{return i.toString()}},...o}=n??{};return R(i=>{let a=!0;return(async()=>{try{await t.subscribe({topic:e,fromBeginning:r}),await t.run({eachMessage:async({topic:u,partition:c,message:f})=>{if(!a)return;let p={};if(f.headers)for(let[h,l]of Object.entries(f.headers))l!==void 0&&(p[h]=typeof l=="string"?l:l.toString());i.emit({topic:u,partition:c,key:f.key?.toString()??null,value:s(f.value),headers:p,offset:f.offset,timestamp:f.timestamp,timestampNs:re()})}})}catch(u){a&&i.down([[N,u]])}})(),()=>{a=!1}},Re(o))}function ai(t,e,n,r){let{serialize:s=a=>JSON.stringify(a),keyExtractor:o,onTransportError:i}=r??{};return ie(t,{onTransportError:i,send:async a=>{let d=o?.(a)??null,u=s(a);await e.send({topic:n,messages:[{key:d,value:Buffer.from(u)}]})}})}function ui(t,e,n){let{blockMs:r=5e3,startId:s="$",parse:o=a=>{for(let u=0;u<a.length;u+=2)if(a[u]==="data")try{return JSON.parse(a[u+1])}catch{return a[u+1]}let d={};for(let u=0;u<a.length;u+=2)d[a[u]]=a[u+1];return d},...i}=n??{};return R(a=>{let d=!0,u=s;return(async()=>{for(;d;)try{let f=await t.xread("BLOCK",r,"STREAMS",e,u);if(!d)return;if(f)for(let[p,h]of f)for(let[l,m]of h)u=l,a.emit({id:l,key:e,data:o(m),timestampNs:re()})}catch(f){if(!d)return;a.down([[N,f]]);return}})(),()=>{d=!1}},Re(i))}function di(t,e,n,r){let{serialize:s=a=>["data",JSON.stringify(a)],maxLen:o,onTransportError:i}=r??{};return ie(t,{onTransportError:i,send:async a=>{let d=s(a);await(o!==void 0?e.xadd(n,"MAXLEN","~",String(o),"*",...d):e.xadd(n,"*",...d))}})}function ci(t,e){let{delimiter:n=",",hasHeader:r=!0,columns:s,parseLine:o,...i}=e??{},a=o??(d=>Ir(d,n));return R(d=>{let u=!1;return(async()=>{try{let f=s,p="";for await(let h of t){if(u)return;p+=h;let l=p.split(/\r?\n/);p=l.pop()??"";for(let m of l){if(u)return;if(!m.trim())continue;let g=a(m);if(!f&&r){f=g;continue}f||(f=g.map((y,v)=>`col${v}`));let b={};for(let y=0;y<f.length;y++)b[f[y]]=g[y]??"";d.emit(b)}}if(!u&&p.trim()){let h=a(p);if(f){let l={};for(let m=0;m<f.length;m++)l[f[m]]=h[m]??"";d.emit(l)}}u||d.down([[x]])}catch(f){u||d.down([[N,f]])}})(),()=>{u=!0}},Re(i))}function li(t,e){let{delimiter:n=",",hasHeader:r=!0,columns:s,parseLine:o,...i}=e??{},a=o??(d=>Ir(d,n));return B([t],(d,u,c)=>{let f=d[0];if(f==null||f.length===0)return;let p=c.store;typeof p.buffer!="string"&&(p.buffer=""),p.headers===void 0&&s&&(p.headers=s.slice());for(let h of f){p.buffer=p.buffer+h;let l=p.buffer.split(/\r?\n/);p.buffer=l.pop()??"";for(let m of l){if(!m.trim())continue;let g=a(m);if(!p.headers&&r){p.headers=g;continue}p.headers||(p.headers=g.map((y,v)=>`col${v}`));let b={};for(let y=0;y<p.headers.length;y++)b[p.headers[y]]=g[y]??"";u.emit(b)}}},{describeKind:"derived",...i})}function fi(t,e){return B([t],(n,r,s)=>{let o=n[0];if(o==null||o.length===0)return;let i=s.store;typeof i.buffer!="string"&&(i.buffer="");for(let a of o){i.buffer=i.buffer+a;let d=i.buffer.split(/\r?\n/);i.buffer=d.pop()??"";for(let u of d)if(u.trim())try{r.emit(JSON.parse(u))}catch(c){r.down([[N,c]]);return}}},{describeKind:"derived",...e??{}})}function Ir(t,e){let n=[],r="",s=!1;for(let o=0;o<t.length;o++){let i=t[o];s?i==='"'?t[o+1]==='"'?(r+='"',o++):s=!1:r+=i:i==='"'?s=!0:i===e?(n.push(r),r=""):r+=i}return n.push(r),n}function pi(t,e){return R(n=>{let r=!1;return(async()=>{try{let o="";for await(let i of t){if(r)return;o+=i;let a=o.split(/\r?\n/);o=a.pop()??"";for(let d of a){if(r)return;let u=d.trim();u&&n.emit(JSON.parse(u))}}!r&&o.trim()&&n.emit(JSON.parse(o.trim())),r||n.down([[x]])}catch(o){r||n.down([[N,o]])}})(),()=>{r=!0}},Re(e))}function hi(t,e,n){let{intervalNs:r=5*1e9,format:s="JSONEachRow",signal:o,maxConsecutiveErrors:i=1}=n??{},a=Math.ceil(r/1e6),d=0;return Ce(He(0,{period:a,signal:o}),()=>R(u=>{let c=!0;return(async()=>{try{let p=await t.query({query:e,format:s});if(!c)return;let h=await p.json();if(!c)return;for(let l of h)u.emit(l);d=0,u.down([[x]])}catch(p){if(!c)return;d+=1,d>=i&&u.down([[N,p]])}})(),()=>{c=!1}}))}function mi(t,e){let{autoAck:n=!0,deserialize:r=a=>{try{return JSON.parse(a.toString())}catch{return a.toString()}},onAckError:s,...o}=e??{},i=a=>{if(s)try{s(a instanceof Error?a:new Error(String(a)))}catch{}};return R(a=>{let d=!0;return(async()=>{for(;d;)try{let c=await t.receive();if(!d)return;let f={topic:c.getTopicName(),messageId:c.getMessageId().toString(),key:c.getPartitionKey(),value:r(c.getData()),properties:c.getProperties(),publishTime:c.getPublishTimestamp(),eventTime:c.getEventTimestamp(),timestampNs:re()};if(n)a.emit(f),t.acknowledge(c).catch(i);else{let p=!1,h={value:f,ack(){p||(p=!0,t.acknowledge(c).catch(i))},nack(l){if(p)return;p=!0;let m=t;try{let g=m.negativeAcknowledge?.(c);g&&typeof g.then=="function"&&g.catch(i)}catch(g){i(g)}}};a.emit(h)}}catch(c){d&&a.down([[N,c]]);return}})(),()=>{d=!1}},Re(o))}function gi(t,e,n){let{serialize:r=a=>Buffer.from(JSON.stringify(a)),keyExtractor:s,propertiesExtractor:o,onTransportError:i}=n??{};return ie(t,{onTransportError:i,send:async a=>{await e.send({data:r(a),partitionKey:s?.(a),properties:o?.(a)})}})}function bi(t,e,n){let r=new TextDecoder,{queue:s,deserialize:o=a=>{let d=r.decode(a);try{return JSON.parse(d)}catch{return d}},...i}=n??{};return R(a=>{let d=!0,u=t.subscribe(e,s?{queue:s}:void 0);return(async()=>{try{for await(let f of u){if(!d)return;let p={};if(f.headers)for(let h of f.headers.keys())p[h]=f.headers.get(h);a.emit({subject:f.subject,data:o(f.data),headers:p,reply:f.reply,sid:f.sid,timestampNs:re()})}d&&a.down([[x]])}catch(f){d&&a.down([[N,f]])}})(),()=>{d=!1}},Re(i))}function yi(t,e,n,r){let s=new TextEncoder,{serialize:o=a=>s.encode(JSON.stringify(a)),onTransportError:i}=r??{};return ie(t,{onTransportError:i,send:a=>{e.publish(n,o(a))}})}function vi(t,e,n){let{autoAck:r=!0,deserialize:s=d=>{try{return JSON.parse(d.toString())}catch{return d.toString()}},onAckError:o,...i}=n??{},a=d=>{if(o)try{o(d instanceof Error?d:new Error(String(d)))}catch{}};return R(d=>{let u=!0,c;return(async()=>{try{c=(await t.consume(e,h=>{if(!u)return;if(h===null){u&&d.down([[N,new Error("Consumer cancelled by broker")]]);return}let l={queue:e,routingKey:h.fields.routingKey,exchange:h.fields.exchange,content:s(h.content),properties:h.properties,deliveryTag:h.fields.deliveryTag,redelivered:h.fields.redelivered,timestampNs:re()};if(r){d.emit(l);try{t.ack(h)}catch(m){a(m)}}else{let m=!1,g=t,b={value:l,ack(){if(!m){m=!0;try{t.ack(h)}catch(y){a(y)}}},nack(y){if(m)return;m=!0;let v=y?.requeue;if(!g.nack){a(new Error("RabbitMQ channel does not expose `nack`; cannot negative-ack"));return}try{g.nack(h,!1,v)}catch(T){a(T)}}};d.emit(b)}},{noAck:!1})).consumerTag}catch(p){u&&d.down([[N,p]])}})(),()=>{u=!1,c!==void 0&&t.cancel(c)}},Re(i))}function Ti(t,e,n,r){let{serialize:s=a=>Buffer.from(JSON.stringify(a)),routingKeyExtractor:o=()=>"",onTransportError:i}=r??{};return ie(t,{onTransportError:i,send:a=>{let d=o(a),u=s(a);e.publish(n,d,u)}})}function Lr(t,e,n){let{serialize:r=f=>`${JSON.stringify(f)}
12
+ `,flushIntervalMs:s=0,batchSize:o=Number.POSITIVE_INFINITY,onTransportError:i,mode:a}=n??{},u=s>0||o<Number.POSITIVE_INFINITY?ie(t,{onTransportError:i,batchSize:o,flushIntervalMs:s,serialize:r,sendBatch:f=>{e.write(f.join(""))}}):ie(t,{onTransportError:i,serialize:r,send:f=>{e.write(f)}}),c=u.dispose;return u.dispose=()=>{c();try{e.end()}catch{}},u}function $n(t,e){return t.includes(e)||t.includes('"')||t.includes(`
13
+ `)?`"${t.replace(/"/g,'""')}"`:t}function wi(t,e,n){let{columns:r,delimiter:s=",",writeHeader:o=!0,cellExtractor:i=(h,l)=>String(h[l]??""),flushIntervalMs:a=0,batchSize:d=Number.POSITIVE_INFINITY,onTransportError:u,...c}=n,f=!1;return Lr(t,e,{serialize:h=>{if(!f&&o){f=!0;let l=r.map(g=>$n(g,s)).join(s),m=r.map(g=>$n(i(h,g),s)).join(s);return`${l}
14
14
  ${m}
15
- `}return`${r.map(l=>Bn(i(h,l),s)).join(s)}
16
- `},flushIntervalMs:a,batchSize:d,onTransportError:u,...c})}function ii(n,e,t,r){let{batchSize:s=1e3,flushIntervalMs:o=5e3,format:i="JSONEachRow",transform:a=u=>u,onTransportError:d}=r??{};return se(n,{onTransportError:d,batchSize:s,flushIntervalMs:o,serialize:a,sendBatch:async u=>{await e.insert({table:t,values:u,format:i})}})}function ai(n,e,t,r){let{format:s="ndjson",keyGenerator:o=(p,h)=>{let l=Math.floor(h/1e6);return`data/${new Date(l).toISOString().replace(/[:.]/g,"-")}-${p}.${s==="ndjson"?"ndjson":"json"}`},batchSize:i=1e3,flushIntervalMs:a=1e4,transform:d=p=>p,onTransportError:u}=r??{},c=s==="ndjson"?"application/x-ndjson":"application/json",f=0;return se(n,{onTransportError:u,batchSize:i,flushIntervalMs:a,serialize:d,sendBatch:async p=>{f+=1;let h=s==="ndjson"?`${p.map(m=>JSON.stringify(m)).join(`
15
+ `}return`${r.map(l=>$n(i(h,l),s)).join(s)}
16
+ `},flushIntervalMs:a,batchSize:d,onTransportError:u,...c})}function xi(t,e,n,r){let{batchSize:s=1e3,flushIntervalMs:o=5e3,format:i="JSONEachRow",transform:a=u=>u,onTransportError:d}=r??{};return ie(t,{onTransportError:d,batchSize:s,flushIntervalMs:o,serialize:a,sendBatch:async u=>{await e.insert({table:n,values:u,format:i})}})}function ki(t,e,n,r){let{format:s="ndjson",keyGenerator:o=(p,h)=>{let l=Math.floor(h/1e6);return`data/${new Date(l).toISOString().replace(/[:.]/g,"-")}-${p}.${s==="ndjson"?"ndjson":"json"}`},batchSize:i=1e3,flushIntervalMs:a=1e4,transform:d=p=>p,onTransportError:u}=r??{},c=s==="ndjson"?"application/x-ndjson":"application/json",f=0;return ie(t,{onTransportError:u,batchSize:i,flushIntervalMs:a,serialize:d,sendBatch:async p=>{f+=1;let h=s==="ndjson"?`${p.map(m=>JSON.stringify(m)).join(`
17
17
  `)}
18
- `:JSON.stringify(p),l=o(f,ne());await e.putObject({Bucket:t,Key:l,Body:h,ContentType:c})}})}function ui(n,e,t,r){let{toSQL:s=(i,a)=>({sql:`INSERT INTO "${a.replace(/"/g,'""')}" (data) VALUES ($1)`,params:[JSON.stringify(i)]}),onTransportError:o}=r??{};return se(n,{onTransportError:o,serialize:i=>s(i,t),send:async i=>{let a=i;await e.query(a.sql,a.params)}})}function di(n,e,t){let{toDocument:r=o=>o,onTransportError:s}=t??{};return se(n,{onTransportError:s,serialize:r,send:async o=>{await e.insertOne(o)}})}function ci(n,e,t){let{labels:r={},toLine:s=a=>JSON.stringify(a),toLabels:o,onTransportError:i}=t??{};return se(n,{onTransportError:i,serialize:a=>({line:s(a),labels:o?{...r,...o(a)}:r}),send:async a=>{let{line:d,labels:u}=a,c=`${ne()}`;await e.push({streams:[{stream:u,values:[[c,d]]}]})}})}function li(n,e,t){let{toResourceSpans:r=o=>[o],onTransportError:s}=t??{};return se(n,{onTransportError:s,serialize:r,send:async o=>{await e.push({resourceSpans:o})}})}function fi(n,e,t,r){let{prefix:s="checkpoints/",debounceMs:o=500,compactEvery:i=10,onError:a}=r??{},d={debounceMs:o,compactEvery:i,save(u,c){let f=Math.floor(ne()/1e6),p=`${s}${n.name}/checkpoint-${f}.json`,h;try{h=JSON.stringify(c)}catch(l){a?.(l);return}e.putObject({Bucket:t,Key:p,Body:h,ContentType:"application/json"}).catch(l=>a?.(l))},load(){return null}};return n.attachStorage([d],{onError:u=>a?.(u)})}function pi(n,e,t){let{prefix:r="graphrefly:checkpoint:",debounceMs:s=500,compactEvery:o=10,onError:i}=t??{},a=`${r}${n.name}`,d={debounceMs:s,compactEvery:o,save(u,c){let f;try{f=JSON.stringify(c)}catch(p){i?.(p);return}e.set(a,f).catch(p=>i?.(p))},async load(){let u=await e.get(a);if(u==null)return null;try{return JSON.parse(u)}catch{return null}}};return n.attachStorage([d],{onError:u=>i?.(u)})}function hi(n,e,t){let{mapRow:r=i=>i,params:s,...o}=t??{};return O(i=>{try{let d=n.query(e,s).map(r);i.emit(d),i.down([[k]])}catch(a){i.down([[N,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function mi(n,e,t){let{mapRow:r=i=>i,params:s,...o}=t??{};return O(i=>{try{let a=n.iterate(e,s);K(()=>{for(let d of a)i.emit(r(d));i.down([[k]])})}catch(a){i.down([[N,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function gi(n,e,t,r){if(t.includes("\0")||t.length===0)throw new Error(`toSqlite: invalid table name: ${JSON.stringify(t)}`);let{toSQL:s=(M,z)=>({sql:`INSERT INTO "${z.replace(/"/g,'""')}" (data) VALUES (?)`,params:[JSON.stringify(M)]}),onTransportError:o,batchInsert:i=!1,maxBatchSize:a=1e3,flushIntervalMs:d=0}=r??{},u=M=>s(M,t);if(!i)return se(n,{onTransportError:o,serialize:u,send:M=>{let z=M;e.query(z.sql,z.params)}});let c=V(null),f=V(void 0,{equals:()=>!1}),p=V(null),h=V(0),l=V(0),m=M=>{try{o?.(M)}catch{}try{c.down([[w,M]])}catch{}},g=[],b=!1,y,v=!1,T=()=>l.down([[w,g.length]]),x=M=>{v||f.down([[w,M]])},_=M=>{v||p.down([[w,M]])},E=M=>{v||h.down([[w,M]])},S=M=>{v||m(M)},C=()=>{if(g.length===0||b)return;b=!0,E(1);try{e.query("BEGIN",[])}catch(j){b=!1,E(0),S({stage:"send",error:j instanceof Error?j:new Error(String(j)),value:void 0});return}let M=g;g=[],T();let z,te=0;for(let j of M)try{e.query(j.query.sql,j.query.params),te+=1}catch(ie){z=ie instanceof Error?ie:new Error(String(ie));break}if(z){try{e.query("ROLLBACK",[])}catch{}S({stage:"send",error:z,value:void 0});for(let j of M)_({value:j.value,error:z,attempts:1})}else try{e.query("COMMIT",[]);for(let j of M)x(j.value)}catch(j){let ie=j instanceof Error?j:new Error(String(j));S({stage:"send",error:ie,value:void 0});for(let xe=0;xe<te;xe++)_({value:M[xe].value,error:ie,attempts:1})}b=!1,E(0)},F=()=>{d>0&&y===void 0&&!v&&(y=setTimeout(()=>{y=void 0,C()},d))},L=n.subscribe(M=>{for(let z of M){let te=z[0];if(te===w){let j=z[1],ie;try{ie=u(j)}catch(xe){let De=xe instanceof Error?xe:new Error(String(xe));m({stage:"serialize",error:De,value:j}),p.down([[w,{value:j,error:De,attempts:0}]]);continue}g.push({value:j,query:ie}),T(),g.length>=a?C():F()}else le.messageTier(te)>=3&&C()}});return{dispose:()=>{if(!v){y!==void 0&&(clearTimeout(y),y=void 0),C(),v=!0,L();for(let M of[c,f,p,h,l])try{M.down([[G]])}catch{}}},sent:f,failed:p,inFlight:h,errors:c,buffered:l,flush:async()=>{v||C()}}}function bi(n,e){let{args:t,mapRow:r=o=>o,...s}=e??{};return O(o=>{let i=!0;return n.findMany(t).then(a=>{i&&(o.emit(a.map(r)),o.down([[k]]))}).catch(a=>{if(i)try{o.down([[N,a instanceof Error?a:new Error(String(a))]])}catch{}}),()=>{i=!1}},{...s,describeKind:"producer",completeWhenDepsComplete:!1})}function yi(n,e){let{mapRow:t=s=>s,...r}=e??{};return O(s=>{let o=!0;return n.execute().then(i=>{o&&(s.emit(i.map(t)),s.down([[k]]))}).catch(i=>{if(o)try{s.down([[N,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}function vi(n,e){let{mapRow:t=s=>s,...r}=e??{};return O(s=>{let o=!0;return n.execute().then(i=>{o&&(s.emit(i.map(t)),s.down([[k]]))}).catch(i=>{if(o)try{s.down([[N,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}ht();Q();var Ti=0;function wi(n,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let t=Symbol(`bp-${++Ti}`),r=0,s=!1;return{onEnqueue(){return r+=1,!s&&r>=e.highWaterMark?(s=!0,n([[me,t]]),!0):!1},onDequeue(){return r>0&&(r-=1),s&&r<=e.lowWaterMark?(s=!1,n([[Te,t]]),!0):!1},get pending(){return r},get paused(){return s},dispose(){s&&(s=!1,n([[Te,t]]))}}}Q();ue();function Cr(){let n=new Map,e=null,t=null;function r(o){o.prev?o.prev.next=o.next:e=o.next,o.next?o.next.prev=o.prev:t=o.prev,o.prev=null,o.next=null}function s(o){o.next=e,o.prev=null,e&&(e.prev=o),e=o,t===null&&(t=o)}return{insert(o){if(n.has(o)){this.touch(o);return}let i={key:o,prev:null,next:null};n.set(o,i),s(i)},touch(o){let i=n.get(o);i&&(r(i),s(i))},delete(o){let i=n.get(o);i&&(r(i),n.delete(o))},evict(o){let i=[];for(let a=0;a<o&&t!==null;a++){let d=t;i.push(d.key),r(d),n.delete(d.key)}return i},size(){return n.size}}}function Dr(n){return n!=null&&typeof n.then=="function"}function st(n){Dr(n)&&n.catch(()=>{})}function ki(n,e){let t=new Map,r=e?.maxSize??0,s=r>0?e?.eviction??Cr():null,o=e?.writeThrough??!1;function i(u,c,f){for(let p=0;p<f;p++)try{st(n[p].save(u,c))}catch{}}function a(u,c,f=0){for(let p=f;p<n.length;p++){let h;try{h=n[p].load(u)}catch{continue}if(Dr(h)){let l=p;h.then(m=>{m!=null?(c.down([[w,m]]),i(u,m,l)):a(u,c,l+1)},()=>{a(u,c,l+1)});return}if(h!=null){c.down([[w,h]]),i(u,h,p);return}}}function d(){if(!(!s||r<=0))for(;s.size()>=r;){let u=s.evict(1);if(u.length===0)break;for(let c of u){let f=t.get(c);if(f){let p=f.cache;if(f.status!=="sentinel"&&n.length>0){let h=n.length-1;try{st(n[h].save(c,p))}catch{}for(let l=0;l<h;l++)try{let m=n[l].clear;m&&st(m.call(n[l],c))}catch{}}f.down([[G]])}t.delete(c)}}}return{load(u){let c=t.get(u);if(c)return s?.touch(u),c;s&&r>0&&s.size()>=r&&d();let f=V(void 0);return t.set(u,f),s?.insert(u),a(u,f),f},save(u,c){if(o)for(let p of n)try{st(p.save(u,c))}catch{}else if(n[0])try{st(n[0].save(u,c))}catch{}let f=t.get(u);if(f)f.down([[w,c]]),s?.touch(u);else{s&&r>0&&s.size()>=r&&d();let p=V(c);t.set(u,p),s?.insert(u)}},invalidate(u){let c=t.get(u);c&&a(u,c)},delete(u){s?.delete(u);let c=t.get(u);c&&c.down([[G]]),t.delete(u);for(let f of n)try{let p=f.clear;p&&st(p.call(f,u))}catch{}},has(u){return t.has(u)},get size(){return t.size}}}ye();Q();ue();ye();Le();Q();ue();var Ft=class{_version=0;_store=new Map;_maxSize;_defaultTtl;constructor(e={}){let{maxSize:t,defaultTtl:r}=e;if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(r!==void 0&&r<=0)throw new RangeError("defaultTtl must be positive");this._maxSize=t,this._defaultTtl=r}get version(){return this._version}get size(){return this._store.size}has(e){let t=this._store.get(e);return t===void 0?!1:this._isExpired(t)?(this._store.delete(e),this._version+=1,!1):(this._touchLru(e,t),!0)}get(e){let t=this._store.get(e);if(t!==void 0){if(this._isExpired(t)){this._store.delete(e),this._version+=1;return}return this._touchLru(e,t),t.value}}set(e,t,r){let s=this._resolveExpiresAt(r);this._store.has(e)&&this._store.delete(e),this._store.set(e,{value:t,expiresAt:s}),this._evictLruWhileOver(),this._version+=1}setMany(e,t){let r=this._resolveExpiresAt(t),s=0;try{for(let[o,i]of e)this._store.has(o)&&this._store.delete(o),this._store.set(o,{value:i,expiresAt:r}),s+=1}finally{s>0&&(this._evictLruWhileOver(),this._version+=1)}}delete(e){let t=this._store.delete(e);return t&&(this._version+=1),t}deleteMany(e){let t=0;try{for(let r of e)this._store.delete(r)&&(t+=1)}finally{t>0&&(this._version+=1)}return t}clear(){let e=this._store.size;return e===0?0:(this._store.clear(),this._version+=1,e)}pruneExpired(){let e=ee(),t=0;for(let[r,s]of this._store)this._isExpired(s,e)&&(this._store.delete(r),t+=1);return t>0&&(this._version+=1),t}toMap(){let e=ee(),t=new Map;for(let[r,s]of this._store)this._isExpired(s,e)||t.set(r,s.value);return t}_resolveExpiresAt(e){let t=e??this._defaultTtl;if(t!==void 0){if(!Number.isFinite(t)||t<=0)throw new RangeError(`MapBackend: ttl must be a positive finite number (got ${t})`);return ee()+t*1e9}}_isExpired(e,t){return e.expiresAt===void 0?!1:(t??ee())>=e.expiresAt}_touchLru(e,t){this._store.delete(e),this._store.set(e,t)}_evictLruWhileOver(){if(this._maxSize!==void 0)for(;this._store.size>this._maxSize;){let e=this._store.keys().next().value;if(e===void 0)break;this._store.delete(e)}}};function Vn(n={}){let{name:e,maxSize:t,defaultTtl:r,versioning:s,backend:o}=n,i=o??new Ft({maxSize:t,defaultTtl:r}),a=V(i.toMap(),{name:e,describeKind:"state",equals:(c,f)=>c===f,...s!=null?{versioning:s}:{}});function d(){let c=i.toMap();K(()=>{a.down([[B]]),a.down([[w,c]])})}function u(c){let f=i.version;try{return c()}finally{i.version!==f&&d()}}return{entries:a,has(c){return u(()=>i.has(c))},get(c){return u(()=>i.get(c))},set(c,f,p){u(()=>i.set(c,f,p?.ttl))},setMany(c,f){u(()=>i.setMany(c,f?.ttl))},delete(c){u(()=>i.delete(c))},deleteMany(c){u(()=>i.deleteMany(c))},clear(){u(()=>i.clear())},pruneExpired(){u(()=>i.pruneExpired())},get size(){return i.size},dispose(){}}}Ie();function xi(n){return typeof n=="object"&&n!==null&&"cache"in n&&typeof n.subscribe=="function"}function _i(n,e,t){let r=de(n),s=r.v!=null,o=V(t?.initialVerified??null,{...s?{meta:{sourceVersion:null}}:{}}),i=t?.trigger!==void 0&&t.trigger!==null,a=null;if(i&&t?.autoVerify?a=yt(de(t.trigger),r):i?a=de(t.trigger):t?.autoVerify&&(a=r),a!==null){let d;if(a===r)d=Ce(r,u=>e(u));else{let u=r.cache;r.subscribe(c=>{for(let f of c)f[0]===w&&(u=f[1])}),d=Ce(a,()=>e(u))}Ue(d,u=>{K(()=>{if(o.down([[w,u]]),s){let c=r.v;c!=null&&o.meta.sourceVersion.down([[w,{id:c.id,version:c.version}]])}})})}return{node:r,verified:o,trigger:a}}function Pr(n){n.subscribe(()=>{})}function Tt(n){return n instanceof Map?n:new Map}function Ir(n,e){if(!Array.isArray(e.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");K(()=>{for(let{key:t,value:r}of e.upsert)n.set(t,r);for(let t of e.remove??[])n.delete(t)})}function Ni(n,e,t){let r=de(n),s=Vn(t.mapOptions??{}),o=t.budget??2e3,a=t.context!==void 0&&t.context!==null?de(t.context):V(null),d=Tt(s.entries.cache);s.entries.subscribe(h=>{for(let l of h)l[0]===w&&(d=Tt(l[1]))});let u=Ce(r,h=>e(h,d));if(Ue(u,h=>{Ir(s,h)}),t.evict){let h=new Map,l=ke([s.entries],([m])=>{let g=[],b=Tt(m);for(let y of h.keys())b.has(y)||(h.get(y)(),h.delete(y));for(let[y,v]of b){let T=t.evict(y,v);if(xi(T)){if(!h.has(y)){let x=Ue(T,_=>{_===!0&&s.has(y)&&s.delete(y)});h.set(y,x)}continue}if(typeof T=="boolean"){T&&g.push(y);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return g});Ue(l,m=>{for(let g of m)s.delete(g)})}let c=t.consolidateTrigger!==void 0&&t.consolidateTrigger!==null;if(t.consolidate&&c){let h=de(t.consolidateTrigger),l=Ce(h,()=>t.consolidate(d));Ue(l,m=>{Ir(s,m)})}let f=ke([s.entries,a],([h,l])=>{let m=[...Tt(h).entries()].map(([y,v])=>({key:y,value:v,score:t.score(v,l),cost:t.cost(v)}));m.sort((y,v)=>v.score-y.score);let g=[],b=o;for(let y of m)y.cost<=b&&(g.push({key:y.key,value:y.value,score:y.score}),b-=y.cost);return g}),p=ke([s.entries],([h])=>Tt(h).size);return Pr(f),Pr(p),{store:s,compact:f,size:p}}xn();var Fn=require("rxjs");Q();function Ei(n,e){return e?.raw?new Fn.Observable(t=>n.subscribe(s=>{if(!t.closed){t.next(s);for(let o of s){if(o[0]===N){t.error(o[1]);return}if(o[0]===k){t.complete();return}}}})):new Fn.Observable(t=>n.subscribe(s=>{for(let o of s){if(t.closed)return;if(o[0]===w)t.next(o[1]);else if(o[0]===N){t.error(o[1]);return}else if(o[0]===k){t.complete();return}}}))}ye();Q();we();var $t=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(e){return this._topics.has(e)}topicNames(){return this._topics.values()}createTopic(e){return this._topics.has(e)?!1:(this._topics.add(e),this._version+=1,!0)}removeTopic(e){let t=this._topics.delete(e);return t&&(this._version+=1),t}};function Si(n={}){let{backend:e}=n,t=e??new $t,r=new Map;function s(o){let i=r.get(o);return i===void 0&&(i=I({describeKind:"state"}),r.set(o,i),t.createTopic(o)),i}return{topic(o){return s(o)},publish(o,i){s(o).emit(i)},publishMany(o){K(()=>{for(let[i,a]of o)s(i).emit(a)})},removeTopic(o){let i=r.get(o);return i===void 0?!1:(r.delete(o),t.removeTopic(o),i.down([[G]]),!0)},has(o){return t.hasTopic(o)},get size(){return t.topicCount},topicNames(){return t.topicNames()}}}ye();Q();ue();function Lr(n,e){if(n===e)return 0;let t=typeof n;if(t===typeof e&&(t==="number"||t==="string"||t==="boolean"||t==="bigint")){let s=n,o=e;return s<o?-1:s>o?1:0}return String(n).localeCompare(String(e))}function Oi(n,e){let t=Lr(n[0],e[0]);return t!==0?t:Lr(n[1],e[1])}function Br(n){return[n.secondary,n.primary]}function it(n,e){let t=Br(e),r=0,s=n.length;for(;r<s;){let o=r+s>>1;Oi(t,Br(n[o]))>0?r=o+1:s=o}return r}var Gt=class{_version=0;_buf=[];_byPrimary=new Map;get version(){return this._version}get size(){return this._buf.length}has(e){return this._byPrimary.has(e)}get(e){return this._byPrimary.get(e)?.value}upsert(e,t,r,s){let o=this._byPrimary.get(e),i={primary:e,secondary:t,value:r};if(o!==void 0&&s?.equals?.(o,i))return!1;if(o!==void 0){let d=it(this._buf,o);this._buf.splice(d,1)}let a=it(this._buf,i);return this._buf.splice(a,0,i),this._byPrimary.set(e,i),this._version+=1,o===void 0}upsertMany(e,t){let r=0;try{for(let s of e){let o=this._byPrimary.get(s.primary),i={primary:s.primary,secondary:s.secondary,value:s.value};if(o!==void 0&&t?.equals?.(o,i))continue;if(o!==void 0){let d=it(this._buf,o);this._buf.splice(d,1)}let a=it(this._buf,i);this._buf.splice(a,0,i),this._byPrimary.set(s.primary,i),r+=1}}finally{r>0&&(this._version+=1)}return r}delete(e){let t=this._byPrimary.get(e);if(t===void 0)return!1;let r=it(this._buf,t);return this._buf.splice(r,1),this._byPrimary.delete(e),this._version+=1,!0}deleteMany(e){let t=0;try{for(let r of e){let s=this._byPrimary.get(r);if(s===void 0)continue;let o=it(this._buf,s);this._buf.splice(o,1),this._byPrimary.delete(r),t+=1}}finally{t>0&&(this._version+=1)}return t}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._byPrimary.clear(),this._version+=1,e)}toArray(){return[...this._buf]}toPrimaryMap(){let e=new Map;for(let t of this._buf)e.set(t.primary,t.value);return e}};function Ri(n){return n.subscribe(()=>{})}function Mi(n={}){let{name:e,versioning:t,equals:r,backend:s}=n,o=s??new Gt;function i(h){return h?.equals!==void 0||r===void 0?h:{...h,equals:r}}let a=V([],{name:e,describeKind:"state",equals:(h,l)=>h===l,...t!=null?{versioning:t}:{}}),d=ke([a],([h])=>{let l=h,m=new Map;for(let g of l)m.set(g.primary,g.value);return m},{initial:o.toPrimaryMap(),describeKind:"derived"}),u=Ri(d),c=!1;function f(){let h=o.toArray();K(()=>{a.down([[B]]),a.down([[w,h]])})}function p(h){let l=o.version;try{return h()}finally{o.version!==l&&f()}}return{ordered:a,byPrimary:d,has(h){return o.has(h)},get(h){return o.get(h)},get size(){return o.size},upsert(h,l,m,g){return p(()=>o.upsert(h,l,m,i(g)))},upsertMany(h,l){let m=[...h];m.length!==0&&p(()=>o.upsertMany(m,i(l)))},delete(h){p(()=>o.delete(h))},deleteMany(h){let l=[...h];l.length!==0&&p(()=>o.deleteMany(l))},clear(){p(()=>o.clear())},dispose(){c||(c=!0,u())}}}ye();Q();ue();var Kt=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 t=e>=0?e:this._buf.length+e;if(!(t<0||t>=this._buf.length))return this._buf[t]}append(e){this._buf.push(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._buf.length;this._buf.length=t+e.length;for(let r=0;r<e.length;r++)this._buf[t+r]=e[r];this._version+=1}insert(e,t){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,t),this._version+=1}insertMany(e,t){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insertMany: index ${e} out of range [0, ${this._buf.length}]`);t.length!==0&&(this._buf.splice(e,0,...t),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 t=e>=0?e:this._buf.length+e;if(t<0||t>=this._buf.length)throw new RangeError(`pop: index ${e} out of range`);let[r]=this._buf.splice(t,1);return this._version+=1,r}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function Ai(n,e={}){let{name:t,versioning:r,backend:s}=e,o=s??new Kt(n),i=V(o.toArray(),{name:t,describeKind:"state",equals:(u,c)=>u===c,...r!=null?{versioning:r}:{}});function a(){let u=o.toArray();K(()=>{i.down([[B]]),i.down([[w,u]])})}function d(u){let c=o.version;try{return u()}finally{o.version!==c&&a()}}return{items:i,get size(){return o.size},at(u){return o.at(u)},append(u){d(()=>o.append(u))},appendMany(u){d(()=>o.appendMany(u))},insert(u,c){d(()=>o.insert(u,c))},insertMany(u,c){d(()=>o.insertMany(u,c))},pop(u=-1){return d(()=>o.pop(u))},clear(){d(()=>o.clear())},dispose(){}}}ye();Q();ue();var zt=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),e&&e.length>0){let r=Math.min(e.length,t),s=e.length-r;for(let o=0;o<r;o++)this._buf[o]=e[s+o];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._size+e;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=t;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<e;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let t=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let r=0;r<t;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(e,t){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let r=t===void 0?this._size:Math.min(Math.max(t,0),this._size),s=Math.min(e,this._size);if(s>=r)return[];let o=r-s;if(this._maxSize===void 0)return this._buf.slice(s,r);let i=new Array(o);for(let a=0;a<o;a++)i[a]=this._buf[(this._head+s+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let t=Math.min(e,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this._buf[(this._head+t)%this._maxSize];return e}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function Vr(n){return n.subscribe(()=>{})}var Ci=64;function Di(n,e={}){let{name:t,maxSize:r,versioning:s,backend:o}=e,i=o??new zt(n,r),a=V(i.toArray(),{name:t,describeKind:"state",equals:(l,m)=>l===m,...s!=null?{versioning:s}:{}});function d(){let l=i.toArray();K(()=>{a.down([[B]]),a.down([[w,l]])})}let u=new Map,c=new Map;function f(l,m){return`${l}:${m===void 0?"END":m}`}function p(l){if(l.size<Ci)return;let m=l.keys().next();if(m.done)return;let g=l.get(m.value);g!==void 0&&g.dispose(),l.delete(m.value)}function h(l){let m=i.version;try{return l()}finally{i.version!==m&&d()}}return{entries:a,get size(){return i.size},at(l){return i.at(l)},append(l){h(()=>i.append(l))},appendMany(l){l.length!==0&&h(()=>i.appendMany(l))},clear(){h(()=>i.clear())},trimHead(l){h(()=>i.trimHead(l))},tail(l){if(!Number.isInteger(l)||l<0)throw new RangeError(`tail: n must be a non-negative integer (got ${l})`);let m=u.get(l);if(m!==void 0)return u.delete(l),u.set(l,m),m.node;p(u);let g=ke([a],([y])=>{let v=y;return l===0||v.length===0?[]:v.slice(Math.max(0,v.length-l))},{initial:i.tail(l),describeKind:"derived"}),b=Vr(g);return u.set(l,{node:g,dispose:b}),g},slice(l,m){if(!Number.isInteger(l)||l<0)throw new RangeError(`slice: start must be a non-negative integer (got ${l})`);if(m!==void 0&&(!Number.isInteger(m)||m<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${m})`);let g=f(l,m),b=c.get(g);if(b!==void 0)return c.delete(g),c.set(g,b),b.node;p(c);let y=ke([a],([T])=>{let x=T;return m===void 0?x.slice(l):x.slice(l,m)},{initial:i.slice(l,m),describeKind:"derived"}),v=Vr(y);return c.set(g,{node:y,dispose:v}),y},disposeTail(l){let m=u.get(l);return m===void 0?!1:(m.dispose(),u.delete(l),!0)},disposeSlice(l,m){let g=f(l,m),b=c.get(g);return b===void 0?!1:(b.dispose(),c.delete(g),!0)},disposeAllViews(){for(let l of u.values())l.dispose();u.clear();for(let l of c.values())l.dispose();c.clear()},dispose(){for(let l of u.values())l.dispose();u.clear();for(let l of c.values())l.dispose();c.clear()}}}Dt();Q();Ie();function Pi(n,e={}){let t=e.keyFn??(s=>String(s)),r=new Map;return s=>{let o=t(s),i=r.get(o);if(i)return i;let a=n(s),d;a!=null&&typeof a.then=="function"?d=Promise.resolve(a):a!=null&&typeof a=="object"&&"subscribe"in a&&"cache"in a?d=Pn(a):a!=null&&typeof a=="object"&&Symbol.asyncIterator in a?d=(async()=>{let f=a[Symbol.asyncIterator]();try{let{value:p,done:h}=await f.next();if(h)throw new Error("singleFromAny: factory returned empty async iterable");return p}finally{await f.return?.()}})():a!=null&&typeof a=="object"&&Symbol.iterator in a?d=(async()=>{let f=a[Symbol.iterator]();try{let{value:p,done:h}=f.next();if(h)throw new Error("singleFromAny: factory returned empty iterable");return p}finally{f.return?.()}})():d=Promise.resolve(a);let u,c=()=>{r.get(o)===u&&r.delete(o)};return u=d.then(f=>(c(),f),f=>{throw c(),f}),r.set(o,u),u}}function Ii(n,e={}){let t=e.keyFn??(s=>String(s)),r=new Map;return s=>{let o=t(s),i=r.get(o);if(i)return i;let a=de(n(s));r.set(o,a);let d=a.subscribe(u=>{for(let c of u)if(c[0]===N||c[0]===k){r.get(o)===a&&r.delete(o),d();return}});return a}}Ie();function jt(n){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(jt);let e=n,t=Object.keys(e).sort(),r={};for(let s of t)r[s]=jt(e[s]);return r}function Li(n){return JSON.stringify(jt(n),void 0,0)}function Bi(){let n=new Map;return{save(e,t){n.set(e,JSON.parse(JSON.stringify(t)))},load(e){let t=n.get(e);return t===void 0?null:JSON.parse(JSON.stringify(t))},clear(e){n.delete(e)},list(){return[...n.keys()].sort()}}}function Vi(n){return{save(e,t){n[e]=JSON.parse(JSON.stringify(t))},load(e){let t=n[e];return t===void 0?null:JSON.parse(JSON.stringify(t))},clear(e){delete n[e]},list(){return Object.keys(n).sort()}}}Q();we();ue();un();ye();Le();St();Q();St();we();function Wt(n,e){if(e!=null&&e.length>0)return new Set(e);switch(n){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;default:return new Set(["type","deps"])}}function Fi(n){return n._describeKind!=null?n._describeKind:n._deps.length>0?"derived":n._fn!=null?"producer":"state"}function $i(n){let e={};for(let[t,r]of Object.entries(n.meta))try{e[t]=r.cache}catch{}return e}function $n(n,e){let t=e==null,r=!t&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,s=t||e.has("meta")||r!=null&&r.length>0,o="state",i=[];n instanceof re&&(o=Fi(n),i=n._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(t||e.has("status"))&&(a.status=n.status);let d=n instanceof re?n._guard:void 0;if(s){let u={...$i(n)};if(d!=null&&u.access===void 0&&(u.access=dn(d)),r!=null&&r.length>0&&!e.has("meta")){let c={};for(let f of r)f in u&&(c[f]=u[f]);a.meta=c}else a.meta=u}if(n.name!=null&&(a.name=n.name),t||e.has("value")){n.status==="sentinel"&&(a.sentinel=!0);try{a.value=n.cache}catch{}}if((t||e.has("v"))&&n.v!=null){let u={id:n.v.id,version:n.v.version};"cid"in n.v&&(u.cid=n.v.cid,u.prev=n.v.prev),a.v=u}return(t||e.has("guard"))&&d!=null&&(a.guard=dn(d)),(t||e.has("lastMutation"))&&n.lastMutation!=null&&(a.lastMutation=n.lastMutation),a}we();ue();Ie();Mt();an();function Fr(n,e,t,r={}){let s=e in n.nodes,o=t in n.nodes;if(!s)return Ut(e,t,"no-such-from");if(!o)return Ut(e,t,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(r.findCycle===!0){let u=Gi(n,e,r);if(u!=null)return u}let d=Ht(e,n.nodes[e],0,r);return qt(e,t,[d])}if(i===0)return Ut(e,t,"no-path");let a=$r(n,e,t,i);return a.found?qt(e,t,Gr(n,a.pathOrder,r)):Ut(e,t,a.truncated?"max-depth-exceeded":"no-path")}function $r(n,e,t,r){let s=new Map,o=[{path:t,depth:0}],i=new Set([t]),a=0,d=!1;for(;a<o.length;){let f=o[a++];if(f.path===e)break;if(r!=null&&f.depth>=r){let m=n.nodes[f.path];m?.deps&&m.deps.length>0&&(d=!0);continue}let p=n.nodes[f.path];if(p==null)continue;let h=p.deps??[],l=new Map;for(let m=0;m<h.length;m++){let g=h[m];if(!g)continue;let b=l.get(g);b==null&&(b=[],l.set(g,b)),b.push(m)}for(let[m,g]of l)i.has(m)||(i.add(m),s.set(m,{from:f.path,depIndices:g}),o.push({path:m,depth:f.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:d};let u=[{path:e}],c=e;for(;c!==t;){let f=s.get(c);if(f==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=f.depIndices,u.push({path:f.from}),c=f.from}return{found:!0,pathOrder:u,truncated:!1}}function Gi(n,e,t){let r=n.nodes[e];if(r==null)return null;let s=r.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=Ht(e,r,0,t);a.dep_index=o[0];let d=Ht(e,r,1,t);return qt(e,e,[a,d])}let i=null;for(let a=0;a<s.length;a++){let d=s[a];if(!d||d===e)continue;let u=$r(n,d,e,t.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:qt(e,e,Gr(n,i.pathOrder,t))}function Gr(n,e,t){return e.map((r,s)=>{let o=n.nodes[r.path],i=Ht(r.path,o,s,t);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function Ht(n,e,t,r){let s={path:n,type:e.type,hop:t};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=r.annotations?.get(n)??e.annotation;o!=null&&(s.annotation=o);let i=r.lastMutations?.get(n)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function qt(n,e,t){return Kr(n,e,!0,"ok",t)}function Ut(n,e,t){return Kr(n,e,!1,t,[])}function Kr(n,e,t,r,s){let o=Ki(n,e,t,r,s);return{from:n,to:e,found:t,reason:r,steps:s,text:o,toJSON(){return{from:n,to:e,found:t,reason:r,steps:s}}}}function Ki(n,e,t,r,s){if(!t)switch(r){case"no-such-from":return`explainPath: no node named "${n}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${n}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${n}" to "${e}"`}let o=[`Causal path: ${n} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(d),"value"in i&&o.push(` value: ${zi(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;o.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return o.join(`
19
- `)}function zi(n){if(n===void 0)return"<sentinel>";if(n===null)return"null";if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||typeof n=="bigint")return String(n);try{let e=JSON.stringify(n);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(n)}}we();var oe={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},ji=Symbol.for("sizeof");function zr(n){let e=new WeakSet,t=new WeakSet,r=[n],s=0;for(;r.length>0;){let o=r.pop();s+=Wi(o,e,t,r)}return s}function Wi(n,e,t,r){if(n==null)return 0;switch(typeof n){case"number":return oe.number;case"boolean":return oe.boolean;case"string":return oe.string+n.length*2;case"bigint":return oe.bigint+Ui(n);case"symbol":return oe.symbol;case"function":return e.has(n)?0:(e.add(n),oe.function);case"undefined":return 0}let o=n;if(e.has(o))return 0;e.add(o);let i=o[ji];if(typeof i=="function")try{let u=i.call(o);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(o instanceof Date)return oe.date;if(o instanceof RegExp)return oe.regexp+o.source.length*2;if(o instanceof Error){let u=o.message?o.message.length*2:0,c=o.stack?o.stack.length*2:0;return oe.error+u+c}if(typeof URL<"u"&&o instanceof URL)return oe.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return oe.promise;if(o instanceof WeakMap)return oe.weakmap;if(o instanceof WeakSet)return oe.weakset;if(o instanceof Map){let u=oe.map;for(let[c,f]of o)u+=oe.mapEntry,r.push(c),r.push(f);return u}if(o instanceof Set){let u=oe.set;for(let c of o)u+=oe.setEntry,r.push(c);return u}if(Array.isArray(o)){let u=oe.array+o.length*8;for(let c of o)r.push(c);return u}if(o instanceof ArrayBuffer)return t.has(o)?0:(t.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let u=o;return t.has(u.buffer)?48:(t.add(u.buffer),u.buffer.byteLength+48)}let a=oe.object,d=Object.keys(o);for(let u of d){a+=oe.string+u.length*2;try{r.push(o[u])}catch{}}return a}function Ui(n){let e=n<0n?-n:n;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}function jr(n,e){let t=e?.topN??10,r=n.describe({detail:"standard"}),s=[],o=n._collectObserveTargets;typeof o=="function"&&o.call(n,"",s);let i=new Map;for(let[p,h]of s)i.set(p,h);let a=[];for(let[p,h]of Object.entries(r.nodes)){let l=i.get(p),m=l instanceof re?l:null,g=m?zr(m.cache):0,b=m?m._sinkCount:0,y=h.deps?.length??0,v=h.type==="effect"&&b===0,T=b===0?h.type==="effect"?"orphan-effect":h.type==="derived"?"idle-derived":h.type==="producer"?"idle-producer":null:null;a.push({path:p,type:h.type,status:h.status??"unknown",valueSizeBytes:g,subscriberCount:b,depCount:y,isOrphanEffect:v,orphanKind:T})}let d=a.reduce((p,h)=>p+h.valueSizeBytes,0),u=(p,h)=>[...a].sort(h??((l,m)=>m[p]-l[p])).slice(0,t),c=a.filter(p=>p.orphanKind!=null),f=a.filter(p=>p.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:d,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:c,orphanEffects:f}}var Z="::",Me="__meta__",at=1;function Wr(n,e){let t=Math.max(16,n.size*4),r=0;for(;n.size>0;){if(r++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${n.size} disposer(s) discarded`),n.clear();return}let s=n.values().next();if(s.done)return;let o=s.value;n.delete(o);try{o()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Hi(n){let e=[];for(let t of Object.keys(n).sort()){let r=n[t].v;r!=null&&e.push(`${t} ${r.id} ${r.version}`)}return e.join(`
20
- `)}function Ur(n){if(n.version!==at)throw new Error(`unsupported snapshot version ${String(n.version)} (expected ${at})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in n))throw new Error(`snapshot missing required key "${e}"`);if(typeof n.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof n.nodes!="object"||n.nodes===null||Array.isArray(n.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(n.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(n.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function qi(n,e){let t=new WeakMap,r=(s,o)=>{if(Object.is(s,o))return!0;if(s==null||o==null||typeof s!="object"||typeof o!="object")return!1;let i=t.get(s);if(i==null&&(i=new WeakSet,t.set(s,i)),i.has(o))return!0;i.add(o);let a=s.constructor,d=o.constructor;if(a!==d)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let p=o;if(s.length!==p.length)return!1;for(let h=0;h<s.length;h++)if(!r(s[h],p[h]))return!1;return!0}if(s instanceof Map){let p=o;if(s.size!==p.size)return!1;for(let[h,l]of s)if(!p.has(h)||!r(l,p.get(h)))return!1;return!0}if(s instanceof Set){let p=o;if(s.size!==p.size)return!1;for(let h of s){let l=!1;for(let m of p)if(r(h,m)){l=!0;break}if(!l)return!1}return!0}if(ArrayBuffer.isView(s)){let p=s,h=o;if(p.length!==h.length)return!1;for(let l=0;l<p.length;l++)if(p[l]!==h[l])return!1;return!0}let u=Object.keys(s),c=Object.keys(o);if(u.length!==c.length)return!1;let f=new Set(c);for(let p of u)if(!f.has(p)||!r(s[p],o[p]))return!1;return!0};return r(n,e)}function Kn(n){if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(Kn);let e=n,t=Object.keys(e).sort(),r={};for(let s of t)r[s]=Kn(e[s]);return r}function Ji(n){return n.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Yi(n){return n.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Qi(n){return n==="TD"?"down":n==="BT"?"up":n==="RL"?"left":"right"}function Jr(n){let e=new Set,t=[];function r(s,o){let i=`${s}\0${o}`;e.has(i)||(e.add(i),t.push([s,o]))}for(let[s,o]of Object.entries(n.nodes)){let i=o.deps;if(i)for(let a of i)r(a,s)}for(let s of n.edges)r(s.from,s.to);return t}function Yr(n){if(n===void 0)return"LR";if(n==="TD"||n==="LR"||n==="BT"||n==="RL")return n;throw new Error(`invalid diagram direction ${String(n)}; expected one of: TD, LR, BT, RL`)}function Xi(n,e){let t=e.includeEdges??!0,r=e.includeSubgraphs??!0,{expand:s,...o}=n,i={...o,edges:t?n.edges:[],subgraphs:r?n.subgraphs:[]},a=JSON.stringify(Kn(i),null,e.indent??2);return e.logger?.(a),a}function Zi(n,e){let t=e.includeEdges??!0,r=e.includeSubgraphs??!0,s=[];s.push(`Graph ${n.name}`),s.push("Nodes:");for(let i of Object.keys(n.nodes).sort()){let a=n.nodes[i];s.push(`- ${i} (${a.type}/${a.status}): ${Yt(a.value)}`)}if(t){s.push("Edges:");for(let i of n.edges)s.push(`- ${i.from} -> ${i.to}`)}if(r){s.push("Subgraphs:");for(let i of n.subgraphs)s.push(`- ${i}`)}let o=s.join(`
21
- `);return e.logger?.(o),o}function Qr(n,e){let t=Yr(e.direction),r=Object.keys(n.nodes).sort(),s=new Map;for(let i=0;i<r.length;i+=1)s.set(r[i],`n${i}`);let o=[`flowchart ${t}`];for(let i of r){let a=s.get(i);o.push(` ${a}["${Ji(i)}"]`)}for(let[i,a]of Jr(n)){let d=s.get(i),u=s.get(a);!d||!u||o.push(` ${d} --> ${u}`)}return o.join(`
22
- `)}function ea(n,e){let t=Qr(n,e);return ta(t)}function ta(n,e){let t=e?.theme??"default",r=e?.autoSync??!0,o=JSON.stringify({code:n,mermaid:{theme:t},autoSync:r}),i=new TextEncoder().encode(o),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function na(n,e){let t=Yr(e.direction),r=Object.keys(n.nodes).sort(),s=new Map;for(let i=0;i<r.length;i+=1)s.set(r[i],`n${i}`);let o=[`direction: ${Qi(t)}`];for(let i of r){let a=s.get(i);o.push(`${a}: "${Yi(i)}"`)}for(let[i,a]of Jr(n)){let d=s.get(i),u=s.get(a);!d||!u||o.push(`${d} -> ${u}`)}return o.join(`
23
- `)}function ra(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Jt(n){let e="^";for(let t=0;t<n.length;t+=1){let r=n[t];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let s=n.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let o=n.slice(t+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,t=s;continue}e+=ra(r)}return e+="$",new RegExp(e)}var oa={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},sa={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function Yt(n){if(typeof n=="string")return JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean"||n==null)return String(n);try{return JSON.stringify(n)}catch{return"[unserializable]"}}function ia(n){return n==="none"?sa:n==="ansi"||n==null?oa:{data:n.data??"",dirty:n.dirty??"",resolved:n.resolved??"",invalidate:n.invalidate??"",pause:n.pause??"",resume:n.resume??"",complete:n.complete??"",error:n.error??"",teardown:n.teardown??"",derived:n.derived??"",path:n.path??"",reset:n.reset??""}}function Hr(n){if(n==null)return{};let e=n.detail;return e==="full"?{...n,structured:n.structured??!0,timeline:n.timeline??!0,causal:n.causal??!0,derived:n.derived??!0}:e==="minimal"?{...n,structured:n.structured??!0}:n.format==="stage-log"?{...n,structured:n.structured??!0,timeline:n.timeline??!0}:n}function aa(n,e,t){for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${n}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function Gn(n,e,t){if(n==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(n.includes(Z))throw new Error(`Graph "${e}": ${t} "${n}" must not contain '${Z}' (path separator)`);if(n===Me)throw new Error(`Graph "${e}": ${t} name "${Me}" is reserved for meta companion paths`);aa(n,e,t)}function ua(n,e){if(n==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=n.split(Z);for(let r of t)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function da(n,e){let t=!1;for(let s of n)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?n.filter(s=>e.isMetaPassthrough(s[0])):n}function Xr(n){for(let e of n._mounts.values())Xr(e);for(let e of n._nodes.values())try{e.down([[G]],{internal:!0})}catch{}}var wt=class n{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_topology;_topologyEmitters=new Set;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(Z))throw new Error(`Graph name must not contain '${Z}' (got "${e}")`);if(e===Me)throw new Error(`Graph name "${Me}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??le,this._traceRing=new He(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning)}ancestors(e=!0){let t=[],r=e?this:this._parent;for(;r!=null;)t.push(r),r=r._parent;return t}get topology(){return this._topology==null&&(this._topology=O(e=>{let t=r=>{e.emit(r)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}add(e,t){let r=e.name,s=t?.name??r;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,i=t?.annotation;if(Gn(o,this.name,"add"),this._mounts.has(o))throw new Error(`Graph "${this.name}": name "${o}" is already a mount point`);if(this._nodes.has(o))throw new Error(`Graph "${this.name}": node "${o}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(o,e),this._nodeToName.set(e,o),this._emitTopology({kind:"added",name:o,nodeKind:"node"}),i!=null&&(this._annotations.set(o,i),this.config.inspectorEnabled&&this._traceRing.push({path:o,annotation:i,timestamp_ns:ee()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof re&&t._applyVersioning(e)}remove(e){Gn(e,this.name,"remove");let t=this._mounts.get(e);if(t){let o={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,d]of i)a.includes(`${Z}${Me}${Z}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...t._collectSubgraphs(`${e}${Z}`)),this._mounts.delete(e),t._parent=void 0,Xr(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:o}),o}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[G]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let t=typeof e=="function"?e:(()=>{let o=Jt(e);return i=>o.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>t(o));for(let o of s){let i=this.remove(o);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let s=e[r++];return{value:[s,t.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(Z))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,r){let s=r?.internal===!0;this.node(e).down([[w,t]],{actor:r?.actor,internal:s,delivery:"write"})}setAll(e,t){let r=Symbol.iterator in e?e:Object.entries(e);K(()=>{for(let[s,o]of r)this.set(s,o,t)})}invalidate(e,t){let r=t?.internal===!0;this.node(e).down([[ve]],{actor:t?.actor,internal:r,delivery:"write"})}error(e,t,r){let s=r?.internal===!0;this.node(e).down([[N,t]],{actor:r?.actor,internal:s,delivery:"write"})}complete(e,t){let r=t?.internal===!0;this.node(e).down([[k]],{actor:t?.actor,internal:r,delivery:"write"})}edges(e){let t=e?.recursive===!0,r=new Map;if(!t){for(let[d,u]of this._nodes)r.set(u,d);let a=[];for(let[d,u]of this._nodes)if(u instanceof re)for(let c of u._deps){let f=r.get(c.node);f!=null&&a.push([f,d])}return a.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,d]of s)o.set(d,a);let i=[];for(let[a,d]of s)if(d instanceof re)for(let u of d._deps){let c=o.get(u.node);c!=null&&i.push([c,a])}return i.sort((a,d)=>a[0]<d[0]?-1:a[0]>d[0]?1:a[1]<d[1]?-1:a[1]>d[1]?1:0),i}mount(e,t){if(Gn(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(t===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(t._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${t._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===t)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,t),t._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),t}resolve(e){let t=ua(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=t[0],s=t.slice(1);if(s.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let o=this._nodes.get(r);if(o&&s.length>0&&s[0]===Me)return this._resolveMetaChainFromNode(o,s,t.join(Z));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${s.join(Z)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(s.join(Z))}_resolveMetaChainFromNode(e,t,r){let s=e,o=0,i=[...t];for(;o<i.length;){if(i[o]!==Me)throw new Error(`Graph "${this.name}": expected ${Me} segment in meta path "${r}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Me} in "${r}"`);let a=i[o+1],d=s.meta[a];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);s=d,o+=2}return s}signal(e,t){if(t?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,t??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,t,r,s){for(let d of this._mounts.values())d._signalDeliver(e,t,r,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=da(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(c){if(c instanceof Ne)throw c;s.push(c)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,s)}}}_signalMetaSubtree(e,t,r,s,o){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(t,s)}catch(d){if(d instanceof Ne)throw d;o.push(d)}this._signalMetaSubtree(a,t,r,s,o)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let t=e?.actor,r=e?.filter,s=Wt(e?.detail,e?.fields),o=e?.format==="spec",i=o?Wt("minimal"):s,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[_,E]of a)d.set(E,_);let u=[];{let _=a.map(([,C])=>C),E=new Set(d.values()),S=0;for(;_.length>0;){let C=_.shift();if(C instanceof re)for(let F of C._deps){let L=F.node;if(d.has(L))continue;let $=L.name??"",M=$;if(!M||E.has(M))if($){let z=2;for(;E.has(`${$}#${z}`);)z++;M=`${$}#${z}`}else for(M=`__internal__/${S++}`;E.has(M);)M=`__internal__/${S++}`;d.set(L,M),E.add(M),u.push([M,L]),_.push(L)}}}let c=[...a,...u],f={};for(let[_,E]of c){if(t!=null&&!E.allowsObserve(t))continue;let S=$n(E,i),C=E instanceof re?E._deps.map(M=>d.get(M.node)??M.node.name??""):[],{name:F,...L}=S,$={...L,deps:C};if(!o){let M=this._annotations.get(_);M!=null&&($.annotation=M)}if(r!=null)if(typeof r=="function"){let M=r;if(!(M.length>=2?M(_,$):M($)))continue}else{let M=!0;for(let[z,te]of Object.entries(r)){let j=z==="deps_includes"?"depsIncludes":z==="meta_has"?"metaHas":z;if(j==="depsIncludes"){if(!$.deps.includes(String(te))){M=!1;break}continue}if(j==="metaHas"){if(!Object.hasOwn($.meta??{},String(te))){M=!1;break}continue}if($[j]!==te){M=!1;break}}if(!M)continue}f[_]=$}let p=new Set(Object.keys(f)),h=[];for(let[_,E]of c)if(E instanceof re)for(let S of E._deps){let C=d.get(S.node);C!=null&&h.push([C,_])}h.sort((_,E)=>_[0]<E[0]?-1:_[0]>E[0]?1:_[1]<E[1]?-1:_[1]>E[1]?1:0);let l=h.map(([_,E])=>({from:_,to:E}));(t!=null||r!=null)&&(l=l.filter(_=>p.has(_.from)&&p.has(_.to)));let m=this._collectSubgraphs(""),g=t!=null||r!=null?m.filter(_=>{let E=`${_}${Z}`;return[...p].some(S=>S===_||S.startsWith(E))}):m,b=this,y=e,v={name:this.name,nodes:f,edges:l,subgraphs:g,expand(_){let E={...y,format:void 0};return Array.isArray(_)?(E.fields=_,E.detail=void 0):(E.detail=_,E.fields=void 0),b.describe(E)}},T=e??{},x=T.format;return x==="json"?Xi(v,T):x==="pretty"?Zi(v,T):x==="mermaid"?Qr(v,T):x==="mermaid-url"?ea(v,T):x==="d2"?na(v,T):v}_collectSubgraphs(e){let t=[];for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${r}`;t.push(s),t.push(...this._mounts.get(r)._collectSubgraphs(`${s}${Z}`))}return t}resourceProfile(e){return jr(this,e)}reachable(e,t,r={}){return r.withDetail===!0?qr(this.describe(),e,t,{...r,withDetail:!0}):qr(this.describe(),e,t,r)}explain(e,t,r){return r?.reactive===!0?this._explainReactive(e,t,r):this._explainStatic(e,t,r)}_explainStatic(e,t,r){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,d]of Object.entries(s.nodes))d.lastMutation!=null&&i.set(a,d.lastMutation);return Fr(s,e,t,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},r=e.reactiveName??"describe",s=0,o=V(s,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,pt(()=>{a=!1,!d&&(s+=1,o.emit(s))}))},c=i.onEvent(g=>{let b=g.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||u()}),f=[],p=new WeakSet,h=g=>{if(p.has(g)||d)return;p.add(g);let b=g.topology.subscribe(y=>{for(let v of y){if(v[0]!==w)continue;let T=v[1];if(u(),T.kind==="added"&&T.nodeKind==="mount"){let x=g._mounts.get(T.name);x!=null&&h(x)}}});f.push(b);for(let y of g._mounts.keys()){let v=g._mounts.get(y);v!=null&&h(v)}};h(this);let l;try{l=ke([o],()=>this.describe(t),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(g,b)=>g===b})}catch(g){c();for(let b of f)b();throw i.dispose(),g}let m=Pt(l);return{node:l,dispose(){d=!0,c();for(let g of f)g();f.length=0,i.dispose(),m()}}}_explainReactive(e,t,r){let s=0,o=V(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(h=>{let l=h.type;l!=="data"&&l!=="error"&&l!=="complete"&&l!=="teardown"||a||d||(a=!0,pt(()=>{a=!1,!d&&(s+=1,o.emit(s))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},f;try{f=ke([o],()=>this._explainStatic(e,t,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:t},equals:(h,l)=>h.found===l.found&&h.reason===l.reason&&h.steps.length===l.steps.length&&la(h.steps,l.steps)})}catch(h){throw u(),i.dispose(),h}let p=Pt(f);return{node:f,dispose(){d=!0,u(),i.dispose(),p()}}}_pathsMatching(e){let t=Jt(e),r=[];return this._collectObserveTargets("",r),r.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${Z}${r}`;this._mounts.get(r)._collectObserveTargets(s,t)}for(let r of[...this._nodes.keys()].sort()){let s=this._nodes.get(r),o=e===""?r:`${e}${Z}${r}`;t.push([o,s]),this._appendMetaObserveTargets(o,s,t)}}_appendMetaObserveTargets(e,t,r){for(let s of Object.keys(t.meta).sort()){let o=t.meta[s],i=`${e}${Z}${Me}${Z}${s}`;r.push([i,o]),this._appendMetaObserveTargets(i,o,r)}}observe(e,t){let r=typeof e=="string",o=Hr(r?t:e),i=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,a=o.actor;if(r){let c=e,f=this.resolve(c);if(a!=null&&!f.allowsObserve(a))throw new Ne({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,f]],o,"one"):{subscribe(p){return f.subscribe(p)},up(p){try{f.up?.(p)}catch(h){if(h instanceof Ne)return;throw h}}}}let d=[];this._collectObserveTargets("",d),d.sort((c,f)=>c[0]<f[0]?-1:c[0]>f[0]?1:0);let u=a==null?d:d.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,o,"all"):{subscribe:c=>{let f=u.map(([p,h])=>h.subscribe(l=>{c(p,l)}));return()=>{for(let p of f)p()}},up:(c,f)=>{try{this.resolve(c).up?.(f)}catch(p){if(p instanceof Ne)return;throw p}}}}_buildStructuredObserver(e,t,r){let s=r==="one"?e[0]?.[0]:void 0,o=i=>{if(r==="one"&&s!=null){let c=this.resolve(s);return this._buildStructuredObserver([[s,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,f)=>c[0]<f[0]?-1:c[0]>f[0]?1:0);let d=i.actor,u=d==null?a:a.filter(([,c])=>c.allowsObserve(d));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,t,o)}_createObserveResult(e,t,r){let s=t.timeline===!0,o=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",d=this.config.inspectorEnabled,u=(o||i)&&d,c=t.maxEvents,f=c!=null&&c>0?new He(c):null,p=[],h=new Set,l={},m=new Set,g=0,b=0,y=0,v=0,T=0,x=0,_=!1,E=!1,S=0,C=new Map,F=new Map,L=new Map,$=D=>{f?f.push(D):p.push(D);for(let q of h)q(D)},M=()=>s?{timestamp_ns:ee(),in_batch:xt(),batch_id:S}:{},z=(D,q)=>{if(!(!u||!(D instanceof re)))return D._setInspectorHook(pe=>{if(pe.kind==="dep_message")C.set(D,pe.depIndex);else if(pe.kind==="run"){let Ve=pe.batchData.map((H,ce)=>H!=null&&H.length>0?H.at(-1):pe.prevData[ce]);F.set(D,Ve);let be=pe.batchData.map(H=>H!=null?[...H]:void 0);L.set(D,be),i&&$({type:"derived",path:q,dep_values:Ve,dep_batches:be,...M()})}})},te=D=>{let q=C.get(D),pe=F.get(D);if(!o||pe==null)return{};let be=(q!=null&&q>=0&&D instanceof re?D._deps[q]:void 0)?.node,H=be?.v,ce=L.get(D);return{trigger_dep_index:q,trigger_dep_name:be?.name,...H!=null?{trigger_version:{id:H.id,version:H.version}}:{},dep_values:[...pe],...ce!=null?{dep_batches:ce}:{}}},j=[],ie=[];for(let[D,q]of e){let pe=z(q,D);pe&&j.push(pe),ie.push(q.subscribe(Ve=>{S++;for(let be of Ve){let H=be[0],ce=M();if(H===w){l[D]=be[1];let Pe=q instanceof re?q.lastMutation?.actor??Ze:Ze;$({type:"data",path:D,data:be[1],actor:Pe,...ce,...te(q)})}else if(a)H===B?g++:H===R?b++:H===ve?y++:H===me?v++:H===Te?T++:H===G?x++:H===k&&!m.has(D)?_=!0:H===N&&(E=!0,m.add(D));else if(H===B)g++,$({type:"dirty",path:D,...ce});else if(H===R)b++,$({type:"resolved",path:D,...ce,...te(q)});else if(H===ve)y++,$({type:"invalidate",path:D,...ce});else if(H===me)v++,$({type:"pause",path:D,lockId:be[1],...ce});else if(H===Te)T++,$({type:"resume",path:D,lockId:be[1],...ce});else if(H===k)m.has(D)||(_=!0),$({type:"complete",path:D,...ce});else if(H===N){E=!0,m.add(D);let Pe=q instanceof re?q.lastMutation?.actor??Ze:Ze;$({type:"error",path:D,data:be[1],actor:Pe,...ce})}else H===G&&(x++,$({type:"teardown",path:D,...ce}))}}))}let xe=!1,De=()=>{if(!xe){xe=!0;for(let D of ie)D();for(let D of j)D();for(let D of ge)D({value:void 0,done:!0});ge.length=0}},_e=[],ge=[];h.add(D=>{let q=ge.shift();q?q({value:D,done:!1}):_e.push(D)});let Be={get values(){return l},get dirtyCount(){return g},get resolvedCount(){return b},get invalidateCount(){return y},get pauseCount(){return v},get resumeCount(){return T},get teardownCount(){return x},get events(){return f?f.toArray():[...p]},get anyCompletedCleanly(){return _},get anyErrored(){return E},get completedWithoutErrors(){return _&&!E},onEvent(D){return h.add(D),()=>h.delete(D)},dispose:De,expand(D){De();let q={...t};return typeof D=="string"?q.detail=D:Object.assign(q,D),r(Hr(q))},[Symbol.asyncIterator](){return{next(){return _e.length>0?Promise.resolve({value:_e.shift(),done:!1}):xe?Promise.resolve({value:void 0,done:!0}):new Promise(D=>ge.push(D))},return(){return De(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Be,t),Be}_attachFormatLogger(e,t){let r=t.format;if(r==null)return;let s=t.logger??(l=>console.log(l)),o=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=o==null&&i==null?()=>!0:l=>(o==null||o.has(l))&&(i==null||!i.has(l)),d=ia(t.theme),u=r==="stage-log"?ee():0,c=l=>l==null?"":t.stageLabels?.[l]??l,f=(l,m)=>l.length>m?`${l.slice(0,m-1)}\u2026`:l,p=l=>l.type==="data"||l.type==="error"?f(Yt(l.data),120):"",h=l=>{if(r==="stage-log"){let E=(ee()-u)/1e9,S=c(l.path).padEnd(9);if(l.type==="data"){let C=p(l);return`[${E.toFixed(3)}s] ${S} \u2190${C?` ${C}`:""}`}if(l.type==="error"){let C=p(l);return`[${E.toFixed(3)}s] ${S} \u2717${C?` ${C}`:""}`}return l.type==="complete"?`[${E.toFixed(3)}s] ${S} \u25A0 complete`:`[${E.toFixed(3)}s] ${S} ${l.type}`}if(r==="json")try{return JSON.stringify(l)}catch{return JSON.stringify({type:l.type,path:l.path,data:"[unserializable]"})}let m=d[l.type]??"",g=l.path?`${d.path}${l.path}${d.reset} `:"",b=l.type==="data"||l.type==="error",y=l.type==="pause"||l.type==="resume",v=b?` ${Yt(l.data)}`:y?` ${Yt(l.lockId)}`:"",T=l.type==="data"||l.type==="resolved"||l.type==="derived"?l:void 0,x=T?.trigger_dep_name!=null?` <- ${T.trigger_dep_name}`:T?.trigger_dep_index!=null?` <- #${T.trigger_dep_index}`:"",_=l.in_batch?" [batch]":"";return`${g}${m}${l.type.toUpperCase()}${d.reset}${v}${x}${_}`};e.onEvent(l=>{a(l.type)&&s(h(l),l)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){Wr(this._disposers,this.name),this.signal([[G]],{internal:!0}),Wr(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}snapshot(e){let{expand:t,...r}=this.describe({detail:"full"}),s={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:d,guard:u,...c}=r.nodes[a];s[a]=c}let o=[...r.subgraphs].sort(),i={...r,version:1,nodes:s,subgraphs:o};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return Qn(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let r=t?.config??le,{codec:s,codecVersion:o,payload:i}=Xn(e,r);return s.decode(i,o)}restore(e,t){if(Ur(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(o=>Jt(o)),s=t?.includeProducers===!0;for(let o of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(o)))continue;let i=e.nodes[o];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let d=this.tryResolve(o)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){t?.onError?.(o,a)}}}}}static fromSnapshot(e,t){Ur(e);let r=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,o=new n(e.name);if(r)return r(o),o.restore(e),o;for(let h of[...e.subgraphs].sort((l,m)=>{let g=l.split(Z).length,b=m.split(Z).length;return g!==b?g-b:l<m?-1:l>m?1:0})){let l=h.split(Z),m=o;for(let g of l)m._mounts.has(g)||m.mount(g,new n(g)),m=m._mounts.get(g)}let i=s?Object.entries(s).map(([h,l])=>({re:Jt(h),factory:l})):[],a=h=>{for(let l of i)if(l.re.test(h))return l.factory},d=h=>{let l=h.split(Z),m=l.pop();if(m==null||m.length===0)throw new Error(`invalid snapshot path "${h}"`);let g=o;for(let b of l){let y=g._mounts.get(b);if(!y)throw new Error(`unknown mount "${b}" in path "${h}"`);g=y}return[g,m]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${Z}${Me}${Z}`)).sort((h,l)=>h[0]<l[0]?-1:h[0]>l[0]?1:0),c=new Map(u),f=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[h,l]of[...c.entries()]){let m=l?.deps??[];if(!m.every(x=>f.has(x)))continue;let[g,b]=d(h),y={...l?.meta??{}},v=a(h),T;if(l?.type==="state")T=V(l.value,{meta:y});else{if(v==null)continue;T=v(b,{path:h,type:l.type,value:l.value,meta:y,deps:m,resolvedDeps:m.map(x=>f.get(x))})}g.add(T,{name:b}),f.set(h,T),c.delete(h),p=!0}}if(c.size>0){let h=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachStorage(e,t={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let s=(u,c)=>{if(u.disposed)return;let f=Hi(c.nodes);if(u.lastSnapshot!=null&&f!==""&&f===u.lastFingerprint)return;let p=u.seq+1,h=ne(),g=u.lastSnapshot==null||p%u.compactEvery===0?{mode:"full",snapshot:c,seq:p,timestamp_ns:h,format_version:at}:{mode:"diff",diff:ca(u.lastSnapshot,c),seq:p,timestamp_ns:h,format_version:at};if(u.tier.filter&&!u.tier.filter(this.name,g))return;let b;try{b=u.tier.save(this.name,g)}catch(y){t.onError?.(y,u.tier);return}if(b&&typeof b.then=="function"){let T=(u.savePending??Promise.resolve()).then(()=>b,()=>b).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=c,u.lastFingerprint=f)},x=>{t.onError?.(x,u.tier)});u.savePending=T.finally(()=>{u.savePending===T&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=c,u.lastFingerprint=f},o=(u,c)=>{try{s(u,c)}catch(f){t.onError?.(f,u.tier)}},i=(u,c)=>{if(!c.some(l=>{let m=this.config.messageTier(l[0]);return m>=3&&m<5}))return;if(t.filter){let l=this.tryResolve(u);if(l==null)return;let m=$n(l,Wt("standard"));if(!t.filter(u,m))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let l of r)l.disposed||(l.debounceMs===0?o(l,h()):(l.timer==null&&(l.timer=new Oe),l.timer.start(l.debounceMs,()=>{l.disposed||o(l,this.snapshot())})))},a;if(t.paths!=null){let c=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(f=>{let p=this.tryResolve(f);return p==null?()=>{}:p.subscribe(h=>i(f,h))});a=()=>{for(let f of c)f()}}else a=this.observe().subscribe((u,c)=>i(u,c));let d=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,t){for(let r of e){let s;try{s=await r.load(this.name)}catch(i){t?.(i,r);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===at&&o.nodes!=null)return this.restore(o),!0}catch(i){t?.(i,r)}}return!1}static async fromStorage(e,t,r){for(let s of t){let o;try{o=await s.load(e)}catch(d){r?.onError?.(d,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===at&&i.nodes!=null?i:void 0;if(a!=null)try{return n.fromSnapshot(a,r)}catch(d){r?.onError?.(d,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,r){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:ee(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(s=>!e(s)),r=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return r}static diff(e,t){let r=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),o=[...s].filter(y=>!r.has(y)).sort(),i=[...r].filter(y=>!s.has(y)).sort(),a=[],d=[];for(let y of r){if(!s.has(y))continue;let v=e.nodes[y],T=t.nodes[y],x=v.v,_=T.v;x!=null&&_!=null&&x.id===_.id&&x.version!==_.version&&d.push({path:y,id:x.id,from:x.version,to:_.version});let E=x!=null&&_!=null&&x.id===_.id&&x.version===_.version;for(let S of["type","status","sentinel"]){let C=v[S],F=T[S];C!==F&&a.push({path:y,field:S,from:C,to:F})}if(!E)for(let S of["value","meta"]){let C=v[S],F=T[S];qi(C,F)||a.push({path:y,field:S,from:C,to:F})}}let u=y=>`${y.from} ${y.to}`,c=new Set(e.edges.map(u)),f=new Set(t.edges.map(u)),p=t.edges.filter(y=>!c.has(u(y))),h=e.edges.filter(y=>!f.has(u(y))),l=new Set(e.subgraphs),m=new Set(t.subgraphs),g=[...m].filter(y=>!l.has(y)).sort(),b=[...l].filter(y=>!m.has(y)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:p,edgesRemoved:h,subgraphsAdded:g,subgraphsRemoved:b}}};function ca(n,e){let t=wt.diff(n,e),r={};for(let s of t.nodesAdded){let o=e.nodes[s];o!=null&&(r[s]=o)}return{...t,nodesAddedFull:r}}function qr(n,e,t,r={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?s:[];if(!r.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=r.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return r.withDetail?s:[];let i=new Map,a=new Map,d=new Map,u=new Map,c=new Set;for(let[v,T]of Object.entries(n.nodes)){if(!v)continue;c.add(v);let x=T.deps??[];i.set(v,x);for(let _ of x)_&&(c.add(_),a.has(_)||a.set(_,new Set),a.get(_).add(v))}for(let v of n.edges){if(v==null||typeof v!="object")continue;let T=typeof v.from=="string"?v.from:"",x=typeof v.to=="string"?v.to:"";!T||!x||(c.add(T),c.add(x),u.has(T)||u.set(T,new Set),u.get(T).add(x),d.has(x)||d.set(x,new Set),d.get(x).add(T))}if(!c.has(e))return r.withDetail?s:[];let f=r.both===!0,p=v=>{if(f){let E=i.get(v)??[],S=d.get(v),C=a.get(v),F=u.get(v),L=[...E];return S&&L.push(...S),C&&L.push(...C),F&&L.push(...F),L}if(t==="upstream"){let E=i.get(v)??[],S=d.get(v);return S?[...E,...S]:E}let T=a.get(v),x=u.get(v),_=T?[...T]:[];return x&&_.push(...x),_},h=new Set([e]),l=new Map,m=[{path:e,depth:0}],g=0,b=!1;for(;g<m.length;){let v=m[g++];if(o!=null&&v.depth>=o){p(v.path).length>0&&(b=!0);continue}for(let T of p(v.path))!T||h.has(T)||(h.add(T),l.set(T,v.depth+1),m.push({path:T,depth:v.depth+1}))}let y=[...l.keys()].sort((v,T)=>v<T?-1:v>T?1:0);return r.withDetail?{paths:y,depths:l,truncated:b}:y}function la(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++){let r=n[t],s=e[t];if(r.path!==s.path||r.type!==s.type||r.status!==s.status||r.hop!==s.hop||r.dep_index!==s.dep_index||r.annotation!==s.annotation||r.value!==s.value||r.lastMutation!==s.lastMutation)return!1;let o=r.v,i=s.v;if(o!==i&&(o==null||i==null||o.id!==i.id||o.version!==i.version))return!1}return!0}function fa(n,e,t,r){let s=new wt(n,r);s.add(e,{name:"source"});let o=V(t,{meta:{kind:"stratify_rules"}});s.add(o,{name:"rules"});for(let i of t)pa(s,e,o,i);return s}function pa(n,e,t,r){let s=`branch/${r.name}`,o=Symbol("noValue"),i=!1,a=!1,d=!1,u=o,c=!1,f=t.cache??[];function p(m){if(d){d=!1;let g=u;if(u=o,g!==o){let b=f.find(v=>v.name===r.name),y=!1;try{y=b?.classify(g)??!1}catch{y=!1}y?(c=!1,m.emit(g)):c&&(c=!1,m.down([[B],[R]]))}else c?(c=!1,m.down([[B],[R]])):m.down([[R]])}}let h=I([],(m,g)=>{let b=e.subscribe(v=>{for(let T of v)l(T,0,g)}),y=t.subscribe(v=>{for(let T of v)l(T,1,g)});return()=>{b(),y()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:r.name},completeWhenDepsComplete:!1});function l(m,g,b){let y=m[0];return y===B?(g===0?(i=!0,c=!0):a=!0,!0):y===w||y===R?(g===0?(i=!1,d=!0,u=y===w?m[1]:o):(y===w&&(f=m[1]),a=!1),i||a||p(b),!0):y===k||y===N||y===G?(i=!1,a=!1,d=!1,u=o,c=!1,g===0&&b.down([m]),!0):g===1}if(n.add(h,{name:s}),r.ops){let m=r.ops(h),g=`branch/${r.name}/out`;n.add(m,{name:g})}}Mt();ye();Q();we();ue();Ie();Q();var ha=new Map([[ve,"INVALIDATE"],[me,"PAUSE"],[Te,"RESUME"],[G,"TEARDOWN"],[k,"COMPLETE"],[N,"ERROR"]]),ma=new Map([["INVALIDATE",ve],["PAUSE",me],["RESUME",Te],["TEARDOWN",G],["COMPLETE",k],["ERROR",N]]);function qe(n){let e=ha.get(n);return e||(Symbol.keyFor(n)??"UNKNOWN")}function ut(n){let e=ma.get(n);if(e)return e;if(n&&n!=="UNKNOWN")return Symbol.for(n)}function dt(n){return n instanceof Error?{message:n.message,name:n.name,stack:n.stack}:{message:String(n),name:"Error"}}function ct(n){let e=new Error(n.message);return e.name=n.name,n.stack&&(e.stack=n.stack),e}function Je(n){if(typeof MessagePort<"u"&&n instanceof MessagePort)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),n.start(),()=>n.removeEventListener("message",t)},terminate(){n.close()}};if(typeof SharedWorker<"u"&&n instanceof SharedWorker)return Je(n.port);if(typeof Worker<"u"&&n instanceof Worker)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),()=>n.removeEventListener("message",t)},terminate(){n.terminate()}};if(typeof BroadcastChannel<"u"&&n instanceof BroadcastChannel)return{post(e,t){t&&t.length>0&&console.warn("[graphrefly] WorkerTransport: BroadcastChannel does not support Transferable objects. The transfer argument is ignored and objects will be cloned instead."),n.postMessage(e)},listen(e){let t=r=>e(r.data);return n.addEventListener("message",t),()=>n.removeEventListener("message",t)},terminate(){n.close()}};if(typeof ServiceWorker<"u"&&n instanceof ServiceWorker)return{post(e,t){n.postMessage(e,t??[])},listen(e){let t=r=>{r.source===n&&e(r.data)};return navigator.serviceWorker.addEventListener("message",t),()=>navigator.serviceWorker.removeEventListener("message",t)}};throw new Error("createTransport: unsupported target type. Expected Worker, SharedWorker, ServiceWorker, BroadcastChannel, or MessagePort.")}function ga(n){return typeof n=="object"&&n!==null&&typeof n.post=="function"&&typeof n.listen=="function"}function Zr(n,e){let t=ga(n)?n:Je(n),r=e.name??"workerBridge",s=Object.entries(e.expose??{}),o=e.import??[],i=e.transfer??{},a=V("connecting",{name:`${r}::meta::status`}),d=V(null,{name:`${r}::meta::error`}),u=new Map,c=new Map;for(let y of o){let v=V(void 0,{name:`${r}::${y}`});u.set(y,v)}let f;if(s.length>0){let y=s.map(([,x])=>x),v=I(y,(x,_)=>{let E={};for(let S=0;S<s.length;S++){let[C]=s[S],F=x[S];F!=null&&F.length>0&&(E[C]=F.at(-1))}Object.keys(E).length!==0&&_.emit(E)},{name:`${r}::aggregated`});f=Rt([v],x=>{let _=x[0];if(_==null||Object.keys(_).length===0)return;let E=[];for(let F of Object.keys(_)){let L=i[F];L&&E.push(...L(_[F]))}let S;for(let[F,L]of s)F in _&&L.v!=null&&(S==null&&(S={}),S[F]=L.v.version);let C={t:"b",u:_,...S?{v:S}:{}};try{t.post(C,E.length>0?E:void 0)}catch(F){d.down([[w,F instanceof Error?F:new Error(String(F))]])}}).subscribe(()=>{})}let p=!1,h=t.listen(y=>{if(p)return;let v=y;switch(v.t){case"r":{K(()=>{for(let[x,_]of Object.entries(v.stores)){let E=u.get(x);E&&E.down([[w,_]])}}),a.down([[w,"connected"]]);let T={};for(let[x,_]of s)T[x]=_.cache;t.post({t:"i",stores:T});break}case"v":{let T=u.get(v.s);T&&T.down([[w,v.d]]);break}case"b":{K(()=>{for(let[T,x]of Object.entries(v.u)){let _=v.v?.[T];if(_!=null){let S=c.get(T);if(S!=null&&_<=S)continue;c.set(T,_)}let E=u.get(T);E&&E.down([[w,x]])}});break}case"e":{let T=u.get(v.s);T&&T.down([[N,ct(v.err)]]);break}case"s":{let T=ut(v.sig);if(!T)break;let x=v.s==="*"?[...u.values()]:u.has(v.s)?[u.get(v.s)]:[];for(let _ of x)_.down(v.d===void 0?[[T]]:[[T,v.d]]);break}}}),l=[];for(let[y,v]of s){let T=v.subscribe((x=>{if(!p)for(let _ of x){let E=_[0];E!==w&&(le.isLocalOnly(E)||(E===N?t.post({t:"e",s:y,err:dt(_[1])}):t.post({t:"s",s:y,sig:qe(E),d:_.length>1?_[1]:void 0})))}}));l.push(T)}let m;if(e.timeoutMs!=null&&e.timeoutMs>0){let y=We(e.timeoutMs),v=Lt(a,x=>x==="connected");m=In(yt(It(y,()=>"timeout"),It(v,()=>"ready"))).subscribe(x=>{for(let _ of x)_[0]===w&&_[1]==="timeout"&&(d.down([[w,new Error("Worker bridge handshake timeout")]]),g())})}function g(){if(!p){p=!0,m?.(),t.post({t:"s",s:"*",sig:qe(G)}),f&&f();for(let y of l)y();l.length=0,h(),a.down([[w,"closed"]]),c.clear(),u.clear()}}let b={meta:{status:a,error:d},destroy:g};for(let[y,v]of u)b[y]=v;return b}ye();Q();we();ue();function ba(n){return typeof n=="object"&&n!==null&&typeof n.post=="function"&&typeof n.listen=="function"}function eo(n,e){let t=ba(n)?n:Je(n),r=e.import??[],s=e.transfer??{},o=new Map,i=new Map,a={};for(let g of r){let b=V(void 0,{name:`worker::${g}`});o.set(g,b),a[g]=b}let d=e.expose(a),u=Object.entries(d),c,f=!1;if(u.length>0){let g=u.map(([,v])=>v),b=I(g,(v,T)=>{let x={};for(let _=0;_<u.length;_++){let[E]=u[_],S=v[_];S!=null&&S.length>0&&(x[E]=S.at(-1))}Object.keys(x).length!==0&&T.emit(x)},{name:"workerSelf::aggregated"});c=Rt([b],v=>{if(f)return;let T=v[0];if(T==null||Object.keys(T).length===0)return;let x=[];for(let S of Object.keys(T)){let C=s[S];C&&x.push(...C(T[S]))}let _;for(let[S,C]of u)S in T&&C.v!=null&&(_==null&&(_={}),_[S]=C.v.version);let E={t:"b",u:T,..._?{v:_}:{}};try{t.post(E,x.length>0?x:void 0)}catch{}}).subscribe(()=>{})}let p=[];for(let[g,b]of u){let y=b.subscribe((v=>{if(!f)for(let T of v){let x=T[0];x!==w&&(le.isLocalOnly(x)||(x===N?t.post({t:"e",s:g,err:dt(T[1])}):t.post({t:"s",s:g,sig:qe(x),d:T.length>1?T[1]:void 0})))}}));p.push(y)}let h=t.listen(g=>{if(f)return;let b=g;switch(b.t){case"i":{K(()=>{for(let[y,v]of Object.entries(b.stores)){let T=o.get(y);T&&T.down([[w,v]])}});break}case"v":{let y=o.get(b.s);y&&y.down([[w,b.d]]);break}case"b":{K(()=>{for(let[y,v]of Object.entries(b.u)){let T=b.v?.[y];if(T!=null){let _=i.get(y);if(_!=null&&T<=_)continue;i.set(y,T)}let x=o.get(y);x&&x.down([[w,v]])}});break}case"e":{let y=o.get(b.s);y&&y.down([[N,ct(b.err)]]);break}case"s":{let y=ut(b.sig);if(!y)break;if(y===G&&b.s==="*"){m();return}let v=b.s==="*"?[...o.values()]:o.has(b.s)?[o.get(b.s)]:[];for(let T of v)T.down(b.d===void 0?[[y]]:[[y,b.d]]);break}}}),l={};for(let[g,b]of u)l[g]=b.cache;t.post({t:"r",stores:l});function m(){if(!f){f=!0,c&&c();for(let g of p)g();p.length=0,h(),t.terminate?.(),i.clear(),o.clear()}}return{destroy:m}}0&&(module.exports={CircuitOpenError,NS_PER_MS,NS_PER_SEC,NativeIndexBackend,NativeListBackend,NativeLogBackend,NativeMapBackend,NativePubSubBackend,RateLimiterOverflowError,ResettableTimer,TimeoutError,audit,awaitSettled,buffer,bufferCount,bufferTime,cached,cascadingCache,catchError,checkpointToRedis,checkpointToS3,circuitBreaker,combine,combineLatest,concat,concatMap,constant,createTransport,createWatermarkController,csvRows,debounce,debounceTime,decorrelatedJitter,delay,deserializeError,dictStorage,distill,distinctUntilChanged,elementAt,empty,escapeRegexChar,exhaustMap,exponential,externalBundle,externalProducer,fallback,fibonacci,filter,find,first,firstValueFrom,firstWhere,flatMap,forEach,fromAny,fromAsyncIter,fromCSV,fromClickHouseWatch,fromCron,fromDrizzle,fromEvent,fromHTTP,fromHTTPPoll,fromHTTPStream,fromIter,fromKafka,fromKysely,fromMCP,fromNATS,fromNDJSON,fromOTel,fromPrisma,fromPrometheus,fromPromise,fromPulsar,fromRabbitMQ,fromRaf,fromRedisStream,fromSSE,fromSqlite,fromSqliteCursor,fromStatsD,fromSyslog,fromTimer,fromWebSocket,fromWebSocketReconnect,fromWebhook,globToRegExp,interval,keepalive,last,linear,lru,map,matchesAnyPattern,matchesCron,memoryStorage,merge,mergeMap,nameToSignal,ndjsonRows,never,of,pairwise,parseCron,parsePrometheusText,parseStatsD,parseSyslog,pausable,pubsub,race,rateLimiter,reactiveCounter,reactiveIndex,reactiveList,reactiveLog,reactiveMap,reactiveSink,reduce,repeat,replay,rescue,resolveBackoffPreset,retry,retrySource,sample,scan,serializeError,share,shareReplay,signalToName,singleFromAny,singleNodeFromAny,skip,sortJsonValue,stableJsonString,stratify,switchMap,take,takeUntil,takeWhile,tap,throttle,throttleTime,throwError,timeout,toArray,toCSV,toClickHouse,toFile,toHTTP,toKafka,toLoki,toMongo,toNATS,toObservable,toPostgres,toPulsar,toRabbitMQ,toReadableStream,toRedisStream,toS3,toSSE,toSSEBytes,toSqlite,toTempo,toWebSocket,tokenBucket,valve,verifiable,window,windowCount,windowTime,withBreaker,withLatestFrom,withMaxAttempts,withStatus,workerBridge,workerSelf,zip});
18
+ `:JSON.stringify(p),l=o(f,re());await e.putObject({Bucket:n,Key:l,Body:h,ContentType:c})}})}function _i(t,e,n,r){let{toSQL:s=(i,a)=>({sql:`INSERT INTO "${a.replace(/"/g,'""')}" (data) VALUES ($1)`,params:[JSON.stringify(i)]}),onTransportError:o}=r??{};return ie(t,{onTransportError:o,serialize:i=>s(i,n),send:async i=>{let a=i;await e.query(a.sql,a.params)}})}function Ni(t,e,n){let{toDocument:r=o=>o,onTransportError:s}=n??{};return ie(t,{onTransportError:s,serialize:r,send:async o=>{await e.insertOne(o)}})}function Ei(t,e,n){let{labels:r={},toLine:s=a=>JSON.stringify(a),toLabels:o,onTransportError:i}=n??{};return ie(t,{onTransportError:i,serialize:a=>({line:s(a),labels:o?{...r,...o(a)}:r}),send:async a=>{let{line:d,labels:u}=a,c=`${re()}`;await e.push({streams:[{stream:u,values:[[c,d]]}]})}})}function Si(t,e,n){let{toResourceSpans:r=o=>[o],onTransportError:s}=n??{};return ie(t,{onTransportError:s,serialize:r,send:async o=>{await e.push({resourceSpans:o})}})}function Oi(t,e,n,r){let{prefix:s="checkpoints/",debounceMs:o=500,compactEvery:i=10,onError:a}=r??{},d={debounceMs:o,compactEvery:i,save(u,c){let f=Math.floor(re()/1e6),p=`${s}${t.name}/checkpoint-${f}.json`,h;try{h=JSON.stringify(c)}catch(l){a?.(l);return}e.putObject({Bucket:n,Key:p,Body:h,ContentType:"application/json"}).catch(l=>a?.(l))},load(){return null}};return t.attachStorage([d],{onError:u=>a?.(u)})}function Ri(t,e,n){let{prefix:r="graphrefly:checkpoint:",debounceMs:s=500,compactEvery:o=10,onError:i}=n??{},a=`${r}${t.name}`,d={debounceMs:s,compactEvery:o,save(u,c){let f;try{f=JSON.stringify(c)}catch(p){i?.(p);return}e.set(a,f).catch(p=>i?.(p))},async load(){let u=await e.get(a);if(u==null)return null;try{return JSON.parse(u)}catch{return null}}};return t.attachStorage([d],{onError:u=>i?.(u)})}function Mi(t,e,n){let{mapRow:r=i=>i,params:s,...o}=n??{};return R(i=>{try{let d=t.query(e,s).map(r);i.emit(d),i.down([[x]])}catch(a){i.down([[N,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function Ai(t,e,n){let{mapRow:r=i=>i,params:s,...o}=n??{};return R(i=>{try{let a=t.iterate(e,s);j(()=>{for(let d of a)i.emit(r(d));i.down([[x]])})}catch(a){i.down([[N,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function Ci(t,e,n,r){if(n.includes("\0")||n.length===0)throw new Error(`toSqlite: invalid table name: ${JSON.stringify(n)}`);let{toSQL:s=(O,$)=>({sql:`INSERT INTO "${$.replace(/"/g,'""')}" (data) VALUES (?)`,params:[JSON.stringify(O)]}),onTransportError:o,batchInsert:i=!1,maxBatchSize:a=1e3,flushIntervalMs:d=0}=r??{},u=O=>s(O,n);if(!i)return ie(t,{onTransportError:o,serialize:u,send:O=>{let $=O;e.query($.sql,$.params)}});let c=F(null),f=F(void 0,{equals:()=>!1}),p=F(null),h=F(0),l=F(0),m=O=>{try{o?.(O)}catch{}try{c.down([[w,O]])}catch{}},g=[],b=!1,y,v=!1,T=()=>l.down([[w,g.length]]),k=O=>{v||f.down([[w,O]])},_=O=>{v||p.down([[w,O]])},E=O=>{v||h.down([[w,O]])},S=O=>{v||m(O)},A=()=>{if(g.length===0||b)return;b=!0,E(1);try{e.query("BEGIN",[])}catch(z){b=!1,E(0),S({stage:"send",error:z instanceof Error?z:new Error(String(z)),value:void 0});return}let O=g;g=[],T();let $,ee=0;for(let z of O)try{e.query(z.query.sql,z.query.params),ee+=1}catch(te){$=te instanceof Error?te:new Error(String(te));break}if($){try{e.query("ROLLBACK",[])}catch{}S({stage:"send",error:$,value:void 0});for(let z of O)_({value:z.value,error:$,attempts:1})}else try{e.query("COMMIT",[]);for(let z of O)k(z.value)}catch(z){let te=z instanceof Error?z:new Error(String(z));S({stage:"send",error:te,value:void 0});for(let ke=0;ke<ee;ke++)_({value:O[ke].value,error:te,attempts:1})}b=!1,E(0)},I=()=>{d>0&&y===void 0&&!v&&(y=setTimeout(()=>{y=void 0,A()},d))},D=t.subscribe(O=>{for(let $ of O){let ee=$[0];if(ee===w){let z=$[1],te;try{te=u(z)}catch(ke){let De=ke instanceof Error?ke:new Error(String(ke));m({stage:"serialize",error:De,value:z}),p.down([[w,{value:z,error:De,attempts:0}]]);continue}g.push({value:z,query:te}),T(),g.length>=a?A():I()}else le.messageTier(ee)>=3&&A()}});return{dispose:()=>{if(!v){y!==void 0&&(clearTimeout(y),y=void 0),A(),v=!0,D();for(let O of[c,f,p,h,l])try{O.down([[K]])}catch{}}},sent:f,failed:p,inFlight:h,errors:c,buffered:l,flush:async()=>{v||A()}}}function Di(t,e){let{args:n,mapRow:r=o=>o,...s}=e??{};return R(o=>{let i=!0;return t.findMany(n).then(a=>{i&&(o.emit(a.map(r)),o.down([[x]]))}).catch(a=>{if(i)try{o.down([[N,a instanceof Error?a:new Error(String(a))]])}catch{}}),()=>{i=!1}},{...s,describeKind:"producer",completeWhenDepsComplete:!1})}function Pi(t,e){let{mapRow:n=s=>s,...r}=e??{};return R(s=>{let o=!0;return t.execute().then(i=>{o&&(s.emit(i.map(n)),s.down([[x]]))}).catch(i=>{if(o)try{s.down([[N,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}function Ii(t,e){let{mapRow:n=s=>s,...r}=e??{};return R(s=>{let o=!0;return t.execute().then(i=>{o&&(s.emit(i.map(n)),s.down([[x]]))}).catch(i=>{if(o)try{s.down([[N,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}mt();X();var Li=0;function Bi(t,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let n=Symbol(`bp-${++Li}`),r=0,s=!1;return{onEnqueue(){return r+=1,!s&&r>=e.highWaterMark?(s=!0,t([[me,n]]),!0):!1},onDequeue(){return r>0&&(r-=1),s&&r<=e.lowWaterMark?(s=!1,t([[Te,n]]),!0):!1},get pending(){return r},get paused(){return s},dispose(){s&&(s=!1,t([[Te,n]]))}}}X();ue();function Br(){let t=new Map,e=null,n=null;function r(o){o.prev?o.prev.next=o.next:e=o.next,o.next?o.next.prev=o.prev:n=o.prev,o.prev=null,o.next=null}function s(o){o.next=e,o.prev=null,e&&(e.prev=o),e=o,n===null&&(n=o)}return{insert(o){if(t.has(o)){this.touch(o);return}let i={key:o,prev:null,next:null};t.set(o,i),s(i)},touch(o){let i=t.get(o);i&&(r(i),s(i))},delete(o){let i=t.get(o);i&&(r(i),t.delete(o))},evict(o){let i=[];for(let a=0;a<o&&n!==null;a++){let d=n;i.push(d.key),r(d),t.delete(d.key)}return i},size(){return t.size}}}function Vr(t){return t!=null&&typeof t.then=="function"}function it(t){Vr(t)&&t.catch(()=>{})}function Vi(t,e){let n=new Map,r=e?.maxSize??0,s=r>0?e?.eviction??Br():null,o=e?.writeThrough??!1;function i(u,c,f){for(let p=0;p<f;p++)try{it(t[p].save(u,c))}catch{}}function a(u,c,f=0){for(let p=f;p<t.length;p++){let h;try{h=t[p].load(u)}catch{continue}if(Vr(h)){let l=p;h.then(m=>{m!=null?(c.down([[w,m]]),i(u,m,l)):a(u,c,l+1)},()=>{a(u,c,l+1)});return}if(h!=null){c.down([[w,h]]),i(u,h,p);return}}}function d(){if(!(!s||r<=0))for(;s.size()>=r;){let u=s.evict(1);if(u.length===0)break;for(let c of u){let f=n.get(c);if(f){let p=f.cache;if(f.status!=="sentinel"&&t.length>0){let h=t.length-1;try{it(t[h].save(c,p))}catch{}for(let l=0;l<h;l++)try{let m=t[l].clear;m&&it(m.call(t[l],c))}catch{}}f.down([[K]])}n.delete(c)}}}return{load(u){let c=n.get(u);if(c)return s?.touch(u),c;s&&r>0&&s.size()>=r&&d();let f=F(void 0);return n.set(u,f),s?.insert(u),a(u,f),f},save(u,c){if(o)for(let p of t)try{it(p.save(u,c))}catch{}else if(t[0])try{it(t[0].save(u,c))}catch{}let f=n.get(u);if(f)f.down([[w,c]]),s?.touch(u);else{s&&r>0&&s.size()>=r&&d();let p=F(c);n.set(u,p),s?.insert(u)}},invalidate(u){let c=n.get(u);c&&a(u,c)},delete(u){s?.delete(u);let c=n.get(u);c&&c.down([[K]]),n.delete(u);for(let f of t)try{let p=f.clear;p&&it(p.call(f,u))}catch{}},has(u){return n.has(u)},get size(){return n.size}}}ye();X();ue();ye();Le();X();ue();var Ft=class{_version=0;_store=new Map;_maxSize;_defaultTtl;constructor(e={}){let{maxSize:n,defaultTtl:r}=e;if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(r!==void 0&&r<=0)throw new RangeError("defaultTtl must be positive");this._maxSize=n,this._defaultTtl=r}get version(){return this._version}get size(){return this._store.size}has(e){let n=this._store.get(e);return n===void 0?!1:this._isExpired(n)?(this._store.delete(e),this._version+=1,!1):(this._touchLru(e,n),!0)}get(e){let n=this._store.get(e);if(n!==void 0){if(this._isExpired(n)){this._store.delete(e),this._version+=1;return}return this._touchLru(e,n),n.value}}set(e,n,r){let s=this._resolveExpiresAt(r);this._store.has(e)&&this._store.delete(e),this._store.set(e,{value:n,expiresAt:s}),this._evictLruWhileOver(),this._version+=1}setMany(e,n){let r=this._resolveExpiresAt(n),s=0;try{for(let[o,i]of e)this._store.has(o)&&this._store.delete(o),this._store.set(o,{value:i,expiresAt:r}),s+=1}finally{s>0&&(this._evictLruWhileOver(),this._version+=1)}}delete(e){let n=this._store.delete(e);return n&&(this._version+=1),n}deleteMany(e){let n=0;try{for(let r of e)this._store.delete(r)&&(n+=1)}finally{n>0&&(this._version+=1)}return n}clear(){let e=this._store.size;return e===0?0:(this._store.clear(),this._version+=1,e)}pruneExpired(){let e=ne(),n=0;for(let[r,s]of this._store)this._isExpired(s,e)&&(this._store.delete(r),n+=1);return n>0&&(this._version+=1),n}toMap(){let e=ne(),n=new Map;for(let[r,s]of this._store)this._isExpired(s,e)||n.set(r,s.value);return n}_resolveExpiresAt(e){let n=e??this._defaultTtl;if(n!==void 0){if(!Number.isFinite(n)||n<=0)throw new RangeError(`MapBackend: ttl must be a positive finite number (got ${n})`);return ne()+n*1e9}}_isExpired(e,n){return e.expiresAt===void 0?!1:(n??ne())>=e.expiresAt}_touchLru(e,n){this._store.delete(e),this._store.set(e,n)}_evictLruWhileOver(){if(this._maxSize!==void 0)for(;this._store.size>this._maxSize;){let e=this._store.keys().next().value;if(e===void 0)break;this._store.delete(e)}}};function Kn(t={}){let{name:e,maxSize:n,defaultTtl:r,versioning:s,backend:o}=t,i=o??new Ft({maxSize:n,defaultTtl:r}),a=F(i.toMap(),{name:e,describeKind:"state",equals:(c,f)=>c===f,...s!=null?{versioning:s}:{}});function d(){let c=i.toMap();j(()=>{a.down([[G]]),a.down([[w,c]])})}function u(c){let f=i.version;try{return c()}finally{i.version!==f&&d()}}return{entries:a,has(c){return u(()=>i.has(c))},get(c){return u(()=>i.get(c))},set(c,f,p){u(()=>i.set(c,f,p?.ttl))},setMany(c,f){u(()=>i.setMany(c,f?.ttl))},delete(c){u(()=>i.delete(c))},deleteMany(c){u(()=>i.deleteMany(c))},clear(){u(()=>i.clear())},pruneExpired(){u(()=>i.pruneExpired())},get size(){return i.size},dispose(){}}}Ie();function Gi(t){return typeof t=="object"&&t!==null&&"cache"in t&&typeof t.subscribe=="function"}function Fi(t,e,n){let r=de(t),s=r.v!=null,o=F(n?.initialVerified??null,{...s?{meta:{sourceVersion:null}}:{}}),i=n?.trigger!==void 0&&n.trigger!==null,a=null;if(i&&n?.autoVerify?a=vt(de(n.trigger),r):i?a=de(n.trigger):n?.autoVerify&&(a=r),a!==null){let d;if(a===r)d=Ce(r,u=>e(u));else{let u=r.cache;r.subscribe(c=>{for(let f of c)f[0]===w&&(u=f[1])}),d=Ce(a,()=>e(u))}Ue(d,u=>{j(()=>{if(o.down([[w,u]]),s){let c=r.v;c!=null&&o.meta.sourceVersion.down([[w,{id:c.id,version:c.version}]])}})})}return{node:r,verified:o,trigger:a}}function Gr(t){t.subscribe(()=>{})}function wt(t){return t instanceof Map?t:new Map}function Fr(t,e){if(!Array.isArray(e.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");j(()=>{for(let{key:n,value:r}of e.upsert)t.set(n,r);for(let n of e.remove??[])t.delete(n)})}function $i(t,e,n){let r=de(t),s=Kn(n.mapOptions??{}),o=n.budget??2e3,a=n.context!==void 0&&n.context!==null?de(n.context):F(null),d=wt(s.entries.cache);s.entries.subscribe(h=>{for(let l of h)l[0]===w&&(d=wt(l[1]))});let u=Ce(r,h=>e(h,d));if(Ue(u,h=>{Fr(s,h)}),n.evict){let h=new Map,l=xe([s.entries],([m])=>{let g=[],b=wt(m);for(let y of h.keys())b.has(y)||(h.get(y)(),h.delete(y));for(let[y,v]of b){let T=n.evict(y,v);if(Gi(T)){if(!h.has(y)){let k=Ue(T,_=>{_===!0&&s.has(y)&&s.delete(y)});h.set(y,k)}continue}if(typeof T=="boolean"){T&&g.push(y);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return g});Ue(l,m=>{for(let g of m)s.delete(g)})}let c=n.consolidateTrigger!==void 0&&n.consolidateTrigger!==null;if(n.consolidate&&c){let h=de(n.consolidateTrigger),l=Ce(h,()=>n.consolidate(d));Ue(l,m=>{Fr(s,m)})}let f=xe([s.entries,a],([h,l])=>{let m=[...wt(h).entries()].map(([y,v])=>({key:y,value:v,score:n.score(v,l),cost:n.cost(v)}));m.sort((y,v)=>v.score-y.score);let g=[],b=o;for(let y of m)y.cost<=b&&(g.push({key:y.key,value:y.value,score:y.score}),b-=y.cost);return g}),p=xe([s.entries],([h])=>wt(h).size);return Gr(f),Gr(p),{store:s,compact:f,size:p}}Sn();var zn=require("rxjs");X();function Ki(t,e){return e?.raw?new zn.Observable(n=>t.subscribe(s=>{if(!n.closed){n.next(s);for(let o of s){if(o[0]===N){n.error(o[1]);return}if(o[0]===x){n.complete();return}}}})):new zn.Observable(n=>t.subscribe(s=>{for(let o of s){if(n.closed)return;if(o[0]===w)n.next(o[1]);else if(o[0]===N){n.error(o[1]);return}else if(o[0]===x){n.complete();return}}}))}ye();X();we();var $t=class{_version=0;_topics=new Set;get version(){return this._version}get topicCount(){return this._topics.size}hasTopic(e){return this._topics.has(e)}topicNames(){return this._topics.values()}createTopic(e){return this._topics.has(e)?!1:(this._topics.add(e),this._version+=1,!0)}removeTopic(e){let n=this._topics.delete(e);return n&&(this._version+=1),n}};function zi(t={}){let{backend:e}=t,n=e??new $t,r=new Map;function s(o){let i=r.get(o);return i===void 0&&(i=B({describeKind:"state"}),r.set(o,i),n.createTopic(o)),i}return{topic(o){return s(o)},publish(o,i){s(o).emit(i)},publishMany(o){j(()=>{for(let[i,a]of o)s(i).emit(a)})},removeTopic(o){let i=r.get(o);return i===void 0?!1:(r.delete(o),n.removeTopic(o),i.down([[K]]),!0)},has(o){return n.hasTopic(o)},get size(){return n.topicCount},topicNames(){return n.topicNames()}}}ye();X();ue();function $r(t,e){if(t===e)return 0;let n=typeof t;if(n===typeof e&&(n==="number"||n==="string"||n==="boolean"||n==="bigint")){let s=t,o=e;return s<o?-1:s>o?1:0}return String(t).localeCompare(String(e))}function ji(t,e){let n=$r(t[0],e[0]);return n!==0?n:$r(t[1],e[1])}function Kr(t){return[t.secondary,t.primary]}function at(t,e){let n=Kr(e),r=0,s=t.length;for(;r<s;){let o=r+s>>1;ji(n,Kr(t[o]))>0?r=o+1:s=o}return r}var Kt=class{_version=0;_buf=[];_byPrimary=new Map;get version(){return this._version}get size(){return this._buf.length}has(e){return this._byPrimary.has(e)}get(e){return this._byPrimary.get(e)?.value}upsert(e,n,r,s){let o=this._byPrimary.get(e),i={primary:e,secondary:n,value:r};if(o!==void 0&&s?.equals?.(o,i))return!1;if(o!==void 0){let d=at(this._buf,o);this._buf.splice(d,1)}let a=at(this._buf,i);return this._buf.splice(a,0,i),this._byPrimary.set(e,i),this._version+=1,o===void 0}upsertMany(e,n){let r=0;try{for(let s of e){let o=this._byPrimary.get(s.primary),i={primary:s.primary,secondary:s.secondary,value:s.value};if(o!==void 0&&n?.equals?.(o,i))continue;if(o!==void 0){let d=at(this._buf,o);this._buf.splice(d,1)}let a=at(this._buf,i);this._buf.splice(a,0,i),this._byPrimary.set(s.primary,i),r+=1}}finally{r>0&&(this._version+=1)}return r}delete(e){let n=this._byPrimary.get(e);if(n===void 0)return!1;let r=at(this._buf,n);return this._buf.splice(r,1),this._byPrimary.delete(e),this._version+=1,!0}deleteMany(e){let n=0;try{for(let r of e){let s=this._byPrimary.get(r);if(s===void 0)continue;let o=at(this._buf,s);this._buf.splice(o,1),this._byPrimary.delete(r),n+=1}}finally{n>0&&(this._version+=1)}return n}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._byPrimary.clear(),this._version+=1,e)}toArray(){return[...this._buf]}toPrimaryMap(){let e=new Map;for(let n of this._buf)e.set(n.primary,n.value);return e}};function Wi(t){return t.subscribe(()=>{})}function Hi(t={}){let{name:e,versioning:n,equals:r,backend:s}=t,o=s??new Kt;function i(h){return h?.equals!==void 0||r===void 0?h:{...h,equals:r}}let a=F([],{name:e,describeKind:"state",equals:(h,l)=>h===l,...n!=null?{versioning:n}:{}}),d=xe([a],([h])=>{let l=h,m=new Map;for(let g of l)m.set(g.primary,g.value);return m},{initial:o.toPrimaryMap(),describeKind:"derived"}),u=Wi(d),c=!1;function f(){let h=o.toArray();j(()=>{a.down([[G]]),a.down([[w,h]])})}function p(h){let l=o.version;try{return h()}finally{o.version!==l&&f()}}return{ordered:a,byPrimary:d,has(h){return o.has(h)},get(h){return o.get(h)},get size(){return o.size},upsert(h,l,m,g){return p(()=>o.upsert(h,l,m,i(g)))},upsertMany(h,l){let m=[...h];m.length!==0&&p(()=>o.upsertMany(m,i(l)))},delete(h){p(()=>o.delete(h))},deleteMany(h){let l=[...h];l.length!==0&&p(()=>o.deleteMany(l))},clear(){p(()=>o.clear())},dispose(){c||(c=!0,u())}}}ye();X();ue();var zt=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 r=0;r<e.length;r++)this._buf[n+r]=e[r];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[r]=this._buf.splice(n,1);return this._version+=1,r}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function Ui(t,e={}){let{name:n,versioning:r,backend:s}=e,o=s??new zt(t),i=F(o.toArray(),{name:n,describeKind:"state",equals:(u,c)=>u===c,...r!=null?{versioning:r}:{}});function a(){let u=o.toArray();j(()=>{i.down([[G]]),i.down([[w,u]])})}function d(u){let c=o.version;try{return u()}finally{o.version!==c&&a()}}return{items:i,get size(){return o.size},at(u){return o.at(u)},append(u){d(()=>o.append(u))},appendMany(u){d(()=>o.appendMany(u))},insert(u,c){d(()=>o.insert(u,c))},insertMany(u,c){d(()=>o.insertMany(u,c))},pop(u=-1){return d(()=>o.pop(u))},clear(){d(()=>o.clear())},dispose(){}}}ye();X();ue();var jt=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,n){if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=n,n!==void 0){if(this._buf=new Array(n),e&&e.length>0){let r=Math.min(e.length,n),s=e.length-r;for(let o=0;o<r;o++)this._buf[o]=e[s+o];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._size+e;if(!(n<0||n>=this._size))return this._maxSize!==void 0?this._buf[(this._head+n)%this._maxSize]:this._buf[n]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=n;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let n=0;n<e;n++)this._buf[(this._head+n)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let n=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,n);else{for(let r=0;r<n;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+n)%this._maxSize}return this._size-=n,this._version+=1,n}slice(e,n){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(n!==void 0&&(!Number.isInteger(n)||n<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${n})`);let r=n===void 0?this._size:Math.min(Math.max(n,0),this._size),s=Math.min(e,this._size);if(s>=r)return[];let o=r-s;if(this._maxSize===void 0)return this._buf.slice(s,r);let i=new Array(o);for(let a=0;a<o;a++)i[a]=this._buf[(this._head+s+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let n=Math.min(e,this._size);return this.slice(this._size-n,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this._buf[(this._head+n)%this._maxSize];return e}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function zr(t){return t.subscribe(()=>{})}var qi=64;function Ji(t,e={}){let{name:n,maxSize:r,versioning:s,backend:o}=e,i=o??new jt(t,r),a=F(i.toArray(),{name:n,describeKind:"state",equals:(l,m)=>l===m,...s!=null?{versioning:s}:{}});function d(){let l=i.toArray();j(()=>{a.down([[G]]),a.down([[w,l]])})}let u=new Map,c=new Map;function f(l,m){return`${l}:${m===void 0?"END":m}`}function p(l){if(l.size<qi)return;let m=l.keys().next();if(m.done)return;let g=l.get(m.value);g!==void 0&&g.dispose(),l.delete(m.value)}function h(l){let m=i.version;try{return l()}finally{i.version!==m&&d()}}return{entries:a,get size(){return i.size},at(l){return i.at(l)},append(l){h(()=>i.append(l))},appendMany(l){l.length!==0&&h(()=>i.appendMany(l))},clear(){h(()=>i.clear())},trimHead(l){h(()=>i.trimHead(l))},tail(l){if(!Number.isInteger(l)||l<0)throw new RangeError(`tail: n must be a non-negative integer (got ${l})`);let m=u.get(l);if(m!==void 0)return u.delete(l),u.set(l,m),m.node;p(u);let g=xe([a],([y])=>{let v=y;return l===0||v.length===0?[]:v.slice(Math.max(0,v.length-l))},{initial:i.tail(l),describeKind:"derived"}),b=zr(g);return u.set(l,{node:g,dispose:b}),g},slice(l,m){if(!Number.isInteger(l)||l<0)throw new RangeError(`slice: start must be a non-negative integer (got ${l})`);if(m!==void 0&&(!Number.isInteger(m)||m<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${m})`);let g=f(l,m),b=c.get(g);if(b!==void 0)return c.delete(g),c.set(g,b),b.node;p(c);let y=xe([a],([T])=>{let k=T;return m===void 0?k.slice(l):k.slice(l,m)},{initial:i.slice(l,m),describeKind:"derived"}),v=zr(y);return c.set(g,{node:y,dispose:v}),y},disposeTail(l){let m=u.get(l);return m===void 0?!1:(m.dispose(),u.delete(l),!0)},disposeSlice(l,m){let g=f(l,m),b=c.get(g);return b===void 0?!1:(b.dispose(),c.delete(g),!0)},disposeAllViews(){for(let l of u.values())l.dispose();u.clear();for(let l of c.values())l.dispose();c.clear()},dispose(){for(let l of u.values())l.dispose();u.clear();for(let l of c.values())l.dispose();c.clear()}}}Pt();X();Ie();function Yi(t,e={}){let n=e.keyFn??(s=>String(s)),r=new Map;return s=>{let o=n(s),i=r.get(o);if(i)return i;let a=t(s),d;a!=null&&typeof a.then=="function"?d=Promise.resolve(a):a!=null&&typeof a=="object"&&"subscribe"in a&&"cache"in a?d=Vn(a):a!=null&&typeof a=="object"&&Symbol.asyncIterator in a?d=(async()=>{let f=a[Symbol.asyncIterator]();try{let{value:p,done:h}=await f.next();if(h)throw new Error("singleFromAny: factory returned empty async iterable");return p}finally{await f.return?.()}})():a!=null&&typeof a=="object"&&Symbol.iterator in a?d=(async()=>{let f=a[Symbol.iterator]();try{let{value:p,done:h}=f.next();if(h)throw new Error("singleFromAny: factory returned empty iterable");return p}finally{f.return?.()}})():d=Promise.resolve(a);let u,c=()=>{r.get(o)===u&&r.delete(o)};return u=d.then(f=>(c(),f),f=>{throw c(),f}),r.set(o,u),u}}function Qi(t,e={}){let n=e.keyFn??(s=>String(s)),r=new Map;return s=>{let o=n(s),i=r.get(o);if(i)return i;let a=de(t(s));r.set(o,a);let d=a.subscribe(u=>{for(let c of u)if(c[0]===N||c[0]===x){r.get(o)===a&&r.delete(o),d();return}});return a}}Ie();function Wt(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Wt);let e=t,n=Object.keys(e).sort(),r={};for(let s of n)r[s]=Wt(e[s]);return r}function Xi(t){return JSON.stringify(Wt(t),void 0,0)}function Zi(){let t=new Map;return{save(e,n){t.set(e,JSON.parse(JSON.stringify(n)))},load(e){let n=t.get(e);return n===void 0?null:JSON.parse(JSON.stringify(n))},clear(e){t.delete(e)},list(){return[...t.keys()].sort()}}}function ea(t){return{save(e,n){t[e]=JSON.parse(JSON.stringify(n))},load(e){let n=t[e];return n===void 0?null:JSON.parse(JSON.stringify(n))},clear(e){delete t[e]},list(){return Object.keys(t).sort()}}}X();we();ue();fn();ye();Le();Ot();X();Ot();we();function Ht(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 ta(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function na(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function jn(t,e){let n=e==null,r=!n&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,s=n||e.has("meta")||r!=null&&r.length>0,o="state",i=[];t instanceof oe&&(o=ta(t),i=t._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(n||e.has("status"))&&(a.status=t.status);let d=t instanceof oe?t._guard:void 0;if(s){let u={...na(t)};if(d!=null&&u.access===void 0&&(u.access=pn(d)),r!=null&&r.length>0&&!e.has("meta")){let c={};for(let f of r)f in u&&(c[f]=u[f]);a.meta=c}else a.meta=u}if(t.name!=null&&(a.name=t.name),n||e.has("value")){t.status==="sentinel"&&(a.sentinel=!0);try{a.value=t.cache}catch{}}if((n||e.has("v"))&&t.v!=null){let u={id:t.v.id,version:t.v.version};"cid"in t.v&&(u.cid=t.v.cid,u.prev=t.v.prev),a.v=u}return(n||e.has("guard"))&&d!=null&&(a.guard=pn(d)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}we();ue();Ie();At();ln();function Wn(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 Ut(t){let e=0;for(let n of t)e+=Wn(n.codePointAt(0));return e}function jr(t,e){if(e<=0)return"";let n=0,r="";for(let s of t){let o=Wn(s.codePointAt(0));if(n+o>e){if(e<=1)return"\u2026";for(;n+1>e&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=Wn(i.codePointAt(0))}return`${r}\u2026`}r+=s,n+=o}return r}var ra={horizontal:"\u2500",vertical:"\u2502",cornerTL:"\u250C",cornerTR:"\u2510",cornerBL:"\u2514",cornerBR:"\u2518",tDown:"\u252C",tUp:"\u2534",tRight:"\u251C",tLeft:"\u2524",cross:"\u253C",arrowRight:"\u25B6",arrowDown:"\u25BC",arrowLeft:"\u25C0",arrowUp:"\u25B2",boxTL:"\u250C",boxTR:"\u2510",boxBL:"\u2514",boxBR:"\u2518",boxH:"\u2500",boxV:"\u2502"},oa={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function qr(t,e){let n=e.charset==="ascii"?oa:ra,r=t.width,s=t.height,o=Array.from({length:s},()=>Array.from({length:r},()=>" ")),i=Array.from({length:s},()=>Array.from({length:r},()=>"empty"));for(let a of t.edges)ia(o,i,n,a);for(let a of t.boxes)sa(o,i,n,a,e.labelOf(a.id));return o.map(a=>ca(a.join(""))).join(`
19
+ `)}function sa(t,e,n,r,s){let{x:o,y:i,w:a,h:d}=r;if(a<2||d<2){d>0&&Wr(t,e,o,i,a,s);return}Be(t,e,o,i,n.boxTL);for(let c=o+1;c<o+a-1;c+=1)Be(t,e,c,i,n.boxH);Be(t,e,o+a-1,i,n.boxTR);for(let c=i+1;c<i+d-1;c+=1){Be(t,e,o,c,n.boxV);for(let f=o+1;f<o+a-1;f+=1)Jr(t,e,f,c," ","empty");Be(t,e,o+a-1,c,n.boxV)}Be(t,e,o,i+d-1,n.boxBL);for(let c=o+1;c<o+a-1;c+=1)Be(t,e,c,i+d-1,n.boxH);Be(t,e,o+a-1,i+d-1,n.boxBR);let u=i+Math.floor(d/2);Wr(t,e,o+1,u,a-2,s)}function Be(t,e,n,r,s){Jr(t,e,n,r,s,s===" "?"empty":s==="\u2500"||s==="-"?"boxH":s==="\u2502"||s==="|"?"boxV":"boxCorner")}function Jr(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];n<0||n>=i.length||(i[n]=s,e[r][n]=o)}function Wr(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=n,a=s;for(let d of o){let u=Ut(d);if(u!==0){if(a<u)break;i>=0&&i<t[r].length&&(t[r][i]=d,e[r][i]="label",u===2&&i+1<t[r].length&&(t[r][i+1]="",e[r][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<t[r].length&&(t[r][i]=" ",e[r][i]="empty"),i+=1,a-=1}function ia(t,e,n,r){let s=r.points;if(s.length<2)return;for(let d=0;d+1<s.length;d+=1)aa(t,e,n,s[d],s[d+1]);for(let d=1;d+1<s.length;d+=1){let u=s[d-1],c=s[d],f=s[d+1],p=ua(u,c,f,n);p&&Ur(t,e,c.x,c.y,p,"edgeCorner")}let o=s[s.length-1],i=s[s.length-2],a=da(i,o,n);a&&Ur(t,e,o.x,o.y,a,"arrow")}function aa(t,e,n,r,s){if(!(r.x===s.x&&r.y===s.y)){if(r.y===s.y){let o=r.y,i=Math.min(r.x,s.x),a=Math.max(r.x,s.x);for(let d=i;d<=a;d+=1)Hr(t,e,d,o,n,"h")}else if(r.x===s.x){let o=r.x,i=Math.min(r.y,s.y),a=Math.max(r.y,s.y);for(let d=i;d<=a;d+=1)Hr(t,e,o,d,n,"v")}}}function Hr(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[n]=o==="h"?s.horizontal:s.vertical,e[r][n]=o==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&o==="v"){i[n]=s.cross,e[r][n]="edgeCorner";return}if(a==="edgeV"&&o==="h"){i[n]=s.cross,e[r][n]="edgeCorner";return}}}function Ur(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[n]=s,e[r][n]=o)}function ua(t,e,n,r){let s=t.y===e.y,o=e.y===n.y;if(s===o)return;if(s){let d=t.x<e.x,u=n.y>e.y;return d&&u?r.cornerTR:d&&!u?r.cornerBR:!d&&u?r.cornerTL:r.cornerBL}let i=t.y<e.y,a=n.x>e.x;return i&&a?r.cornerBL:i&&!a?r.cornerBR:!i&&a?r.cornerTL:r.cornerTR}function da(t,e,n){if(e.x>t.x)return n.arrowRight;if(e.x<t.x)return n.arrowLeft;if(e.y>t.y)return n.arrowDown;if(e.y<t.y)return n.arrowUp}function ca(t){let e=t.length;for(;e>0&&t.charCodeAt(e-1)===32;)e-=1;return t.slice(0,e)}function Xr(t){let e=la(t);fa(e),pa(e),ha(e),ma(e,t);let n=ya(e,t),{width:r,height:s}=Ta(e),o=[];for(let i of e.layers)for(let a of i)a.isVirtual||o.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:o,edges:n,width:r,height:s}}function la(t){let e=new Map;for(let s of t.nodes)e.set(s,{id:s,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:t.widthCells(s),h:t.heightCells(s),in:[],out:[]});let n=[],r=0;for(let s of t.edges){if(s.from===s.to)continue;let o=e.get(s.from),i=e.get(s.to);if(!o||!i)continue;let a={chainId:r++,chainFrom:s.from,chainTo:s.to,fromId:s.from,toId:s.to,hopIndex:0,chainLen:1};o.out.push(a),i.in.push(a),n.push(a)}return{nodes:e,layers:[],hops:n}}function fa(t){let e=new Map;for(let o of t.nodes.values())e.set(o.id,o.in.length);let n=[];for(let o of t.nodes.values())(e.get(o.id)??0)===0&&(o.layer=0,n.push(o));let r=new Set,s=0;for(;s<n.length;){let o=n[s++];if(!r.has(o.id)){r.add(o.id);for(let i of o.out){let a=t.nodes.get(i.toId);a.layer=Math.max(a.layer,o.layer+1);let d=(e.get(a.id)??0)-1;e.set(a.id,d),d<=0&&n.push(a)}}}for(let o of t.nodes.values())o.layer<0&&(o.layer=0)}function pa(t){let e=Math.max(0,...Array.from(t.nodes.values(),o=>o.layer)),n=Array.from({length:e+1},()=>[]);for(let o of t.nodes.values())n[o.layer].push(o);let r=[],s=0;for(let o of t.hops){let i=t.nodes.get(o.fromId),a=t.nodes.get(o.toId),d=a.layer-i.layer;if(d<=0){i.out=i.out.filter(f=>f!==o),a.in=a.in.filter(f=>f!==o);continue}if(d===1){o.hopIndex=0,o.chainLen=1,r.push(o);continue}i.out=i.out.filter(f=>f!==o),a.in=a.in.filter(f=>f!==o);let u=i;for(let f=1;f<d;f+=1){let p=`__virt_${s++}__`,h={id:p,isVirtual:!0,layer:i.layer+f,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};t.nodes.set(p,h),n[h.layer].push(h);let l={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:p,hopIndex:f-1,chainLen:d};u.out.push(l),h.in.push(l),r.push(l),u=h}let c={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:a.id,hopIndex:d-1,chainLen:d};u.out.push(c),a.in.push(c),r.push(c)}for(let o of n)for(let i=0;i<o.length;i+=1)o[i].order=i;t.layers=n,t.hops=r}function ha(t){for(let n=0;n<4;n+=1){for(let r=1;r<t.layers.length;r+=1)Yr(t,t.layers[r],"in"),qt(t.layers[r]);for(let r=t.layers.length-2;r>=0;r-=1)Yr(t,t.layers[r],"out"),qt(t.layers[r])}for(let n=0;n<2;n+=1){let r=!1;for(let s=1;s<t.layers.length;s+=1){let o=t.layers[s];for(let i=0;i+1<o.length;i+=1){let a=Qr(t,o[i],o[i+1],"in");[o[i],o[i+1]]=[o[i+1],o[i]],qt(o),Qr(t,o[i],o[i+1],"in")<a?r=!0:([o[i],o[i+1]]=[o[i+1],o[i]],qt(o))}}if(!r)break}}function Yr(t,e,n){let r=new Map;for(let s of e){let o=n==="in"?s.in:s.out;if(o.length===0){r.set(s.id,s.order);continue}let i=0,a=0;for(let d of o){let u=t.nodes.get(n==="in"?d.fromId:d.toId);u&&(i+=u.order,a+=1)}r.set(s.id,a===0?s.order:i/a)}e.sort((s,o)=>{let i=r.get(s.id),a=r.get(o.id);return i!==a?i-a:s.order-o.order})}function qt(t){for(let e=0;e<t.length;e+=1)t[e].order=e}function Qr(t,e,n,r){let s=r==="in"?e.in:e.out,o=r==="in"?n.in:n.out,i=0;for(let a of s)for(let d of o){let u=t.nodes.get(r==="in"?a.fromId:a.toId)?.order??0,c=t.nodes.get(r==="in"?d.fromId:d.toId)?.order??0;(e.order<n.order&&u>c||e.order>n.order&&u<c)&&(i+=1)}return i}function ma(t,e){e.direction==="LR"?ga(t,e):ba(t,e)}function ga(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.w);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.x=n[s];for(let s of t.layers){let o=0;for(let i of s)i.y=o,o+=i.h+e.nodeGap}Zr(t,e,"y")}function ba(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.h);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.y=n[s];for(let s of t.layers){let o=0;for(let i of s)i.x=o,o+=i.w+e.nodeGap}Zr(t,e,"x")}function Zr(t,e,n){let r=o=>n==="y"?o.h:o.w,s=e.nodeGap;for(let o=0;o<2;o+=1){let i=o===0?t.layers.slice(1):t.layers.slice(0,-1).reverse();for(let a of i){let d=new Map;for(let c of a){let f=o===0?c.in:c.out;if(f.length===0)continue;let p=[];for(let l of f){let m=t.nodes.get(o===0?l.fromId:l.toId);if(!m)continue;let g=n==="y"?m.y:m.x;p.push(g+Math.floor(r(m)/2))}if(p.length===0)continue;p.sort((l,m)=>l-m);let h=p[Math.floor(p.length/2)];d.set(c.id,h-Math.floor(r(c)/2))}let u=0;for(let c of a){let f=d.get(c.id),p=n==="y"?c.y:c.x,l=Math.max(f??p,u);n==="y"?c.y=l:c.x=l,u=l+r(c)+s}}}}function ya(t,e){let n=new Map;for(let u of t.hops){let c=n.get(u.chainId);c?c.push(u):n.set(u.chainId,[u])}for(let u of n.values())u.sort((c,f)=>c.hopIndex-f.hopIndex);let r=e.direction==="LR",s=u=>r?u.x:u.y,o=u=>r?u.w:u.h,i=u=>r?u.y+Math.floor(u.h/2):u.x+Math.floor(u.w/2),a=new Map;for(let u=0;u+1<t.layers.length;u+=1){let c=t.layers[u],f=t.layers[u+1],p=0;for(let S of c)p=Math.max(p,s(S)+o(S));let h=Number.POSITIVE_INFINITY;for(let S of f)h=Math.min(h,s(S));let l=Number.isFinite(h)?h-1:p,m=Math.max(1,l-p+1),g=[];for(let S of c)for(let A of S.out)g.push(A);g.sort((S,A)=>{let I=i(t.nodes.get(S.fromId)),D=i(t.nodes.get(A.fromId));if(I!==D)return I-D;let L=i(t.nodes.get(S.toId)),O=i(t.nodes.get(A.toId));return L-O});let b=[],y=new Map;for(let S of g){let A=i(t.nodes.get(S.fromId)),I=i(t.nodes.get(S.toId)),D=Math.min(A,I),L=Math.max(A,I),O=-1;for(let $=0;$<b.length;$+=1){let ee=b[$],z=!0;for(let te of ee)if(te.lo<=L&&D<=te.hi){z=!1;break}if(z){ee.push({lo:D,hi:L}),O=$;break}}O<0&&(b.push([{lo:D,hi:L}]),O=b.length-1),y.set(S,O)}let v=b.length,T=m>=Math.max(3,v+2),k=T?p+1:p,_=T?l-1:l,E=Math.max(1,_-k+1);for(let S of g){let A=y.get(S),I;if(v<=1)I=k+Math.floor(E/2);else{let D=(E-1)/(v-1);I=k+Math.floor(A*D)}a.set(S,Math.max(p,Math.min(l,I)))}}let d=[];for(let[,u]of n){let c=[];for(let p=0;p<u.length;p+=1){let h=u[p],l=t.nodes.get(h.fromId),m=t.nodes.get(h.toId),g=a.get(h),b=l.isVirtual?s(l):s(l)+o(l),y=m.isVirtual?s(m):s(m)-1,v=i(l),T=i(m);p===0&&Jt(c,r,b,v),v!==T&&(Jt(c,r,g,v),Jt(c,r,g,T)),Jt(c,r,y,T)}let f=u[0];d.push({from:f.chainFrom,to:f.chainTo,points:va(c)})}return d}function Jt(t,e,n,r){t.push(e?{x:n,y:r}:{x:r,y:n})}function va(t){let e=[];for(let n of t){let r=e[e.length-1];(!r||r.x!==n.x||r.y!==n.y)&&e.push(n)}return e}function Ta(t){let e=0,n=0;for(let r of t.layers)for(let s of r)e=Math.max(e,s.x+s.w),n=Math.max(n,s.y+s.h);return{width:e,height:n}}var wa=24,xa=4,ka=1,_a=3;function eo(t,e){let n=Na(e.direction),r=Math.max(3,e.maxLabelWidth??wa),s=e.asciiCharset??"unicode",o=Object.keys(t.nodes).sort(),i=new Set(o),a=t.edges.filter(h=>i.has(h.from)&&i.has(h.to)),d=new Map,u=new Map;for(let h of o){let l=jr(h,r);d.set(h,l),u.set(h,Ut(l)+4)}let c=Xr({nodes:o,edges:a,widthCells:h=>u.get(h)??3,heightCells:()=>_a,layerGap:xa,nodeGap:ka,direction:n}),f=qr(c,{charset:s,labelOf:h=>d.get(h)??h}),p=e.logger;return p&&p(f),f}function Na(t){if(t===void 0||t==="LR")return"LR";if(t==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(t)}`)}function to(t,e,n,r={}){let s=e in t.nodes,o=n in t.nodes;if(!s)return Yt(e,n,"no-such-from");if(!o)return Yt(e,n,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===n){if(r.findCycle===!0){let u=Ea(t,e,r);if(u!=null)return u}let d=Qt(e,t.nodes[e],0,r);return Xt(e,n,[d])}if(i===0)return Yt(e,n,"no-path");let a=no(t,e,n,i);return a.found?Xt(e,n,ro(t,a.pathOrder,r)):Yt(e,n,a.truncated?"max-depth-exceeded":"no-path")}function no(t,e,n,r){let s=new Map,o=[{path:n,depth:0}],i=new Set([n]),a=0,d=!1;for(;a<o.length;){let f=o[a++];if(f.path===e)break;if(r!=null&&f.depth>=r){let m=t.nodes[f.path];m?.deps&&m.deps.length>0&&(d=!0);continue}let p=t.nodes[f.path];if(p==null)continue;let h=p.deps??[],l=new Map;for(let m=0;m<h.length;m++){let g=h[m];if(!g)continue;let b=l.get(g);b==null&&(b=[],l.set(g,b)),b.push(m)}for(let[m,g]of l)i.has(m)||(i.add(m),s.set(m,{from:f.path,depIndices:g}),o.push({path:m,depth:f.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:d};let u=[{path:e}],c=e;for(;c!==n;){let f=s.get(c);if(f==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=f.depIndices,u.push({path:f.from}),c=f.from}return{found:!0,pathOrder:u,truncated:!1}}function Ea(t,e,n){let r=t.nodes[e];if(r==null)return null;let s=r.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=Qt(e,r,0,n);a.dep_index=o[0];let d=Qt(e,r,1,n);return Xt(e,e,[a,d])}let i=null;for(let a=0;a<s.length;a++){let d=s[a];if(!d||d===e)continue;let u=no(t,d,e,n.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:Xt(e,e,ro(t,i.pathOrder,n))}function ro(t,e,n){return e.map((r,s)=>{let o=t.nodes[r.path],i=Qt(r.path,o,s,n);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function Qt(t,e,n,r){let s={path:t,type:e.type,hop:n};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=r.annotations?.get(t)??e.annotation;o!=null&&(s.annotation=o);let i=r.lastMutations?.get(t)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function Xt(t,e,n){return oo(t,e,!0,"ok",n)}function Yt(t,e,n){return oo(t,e,!1,n,[])}function oo(t,e,n,r,s){let o=Sa(t,e,n,r,s);return{from:t,to:e,found:n,reason:r,steps:s,text:o,toJSON(){return{from:t,to:e,found:n,reason:r,steps:s}}}}function Sa(t,e,n,r,s){if(!n)switch(r){case"no-such-from":return`explainPath: no node named "${t}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${t}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${t}" to "${e}"`}let o=[`Causal path: ${t} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(d),"value"in i&&o.push(` value: ${Oa(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;o.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return o.join(`
20
+ `)}function Oa(t){if(t===void 0)return"<sentinel>";if(t===null)return"null";if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);try{let e=JSON.stringify(t);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(t)}}we();var se={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},Ra=Symbol.for("sizeof");function so(t){let e=new WeakSet,n=new WeakSet,r=[t],s=0;for(;r.length>0;){let o=r.pop();s+=Ma(o,e,n,r)}return s}function Ma(t,e,n,r){if(t==null)return 0;switch(typeof t){case"number":return se.number;case"boolean":return se.boolean;case"string":return se.string+t.length*2;case"bigint":return se.bigint+Aa(t);case"symbol":return se.symbol;case"function":return e.has(t)?0:(e.add(t),se.function);case"undefined":return 0}let o=t;if(e.has(o))return 0;e.add(o);let i=o[Ra];if(typeof i=="function")try{let u=i.call(o);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(o instanceof Date)return se.date;if(o instanceof RegExp)return se.regexp+o.source.length*2;if(o instanceof Error){let u=o.message?o.message.length*2:0,c=o.stack?o.stack.length*2:0;return se.error+u+c}if(typeof URL<"u"&&o instanceof URL)return se.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return se.promise;if(o instanceof WeakMap)return se.weakmap;if(o instanceof WeakSet)return se.weakset;if(o instanceof Map){let u=se.map;for(let[c,f]of o)u+=se.mapEntry,r.push(c),r.push(f);return u}if(o instanceof Set){let u=se.set;for(let c of o)u+=se.setEntry,r.push(c);return u}if(Array.isArray(o)){let u=se.array+o.length*8;for(let c of o)r.push(c);return u}if(o instanceof ArrayBuffer)return n.has(o)?0:(n.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let u=o;return n.has(u.buffer)?48:(n.add(u.buffer),u.buffer.byteLength+48)}let a=se.object,d=Object.keys(o);for(let u of d){a+=se.string+u.length*2;try{r.push(o[u])}catch{}}return a}function Aa(t){let e=t<0n?-t:t;if(e===0n)return 0;let n=e.toString(2).length;return Math.ceil(n/32)*8}function io(t,e){let n=e?.topN??10,r=t.describe({detail:"standard"}),s=[],o=t._collectObserveTargets;typeof o=="function"&&o.call(t,"",s);let i=new Map;for(let[p,h]of s)i.set(p,h);let a=[];for(let[p,h]of Object.entries(r.nodes)){let l=i.get(p),m=l instanceof oe?l:null,g=m?so(m.cache):0,b=m?m._sinkCount:0,y=h.deps?.length??0,v=h.type==="effect"&&b===0,T=b===0?h.type==="effect"?"orphan-effect":h.type==="derived"?"idle-derived":h.type==="producer"?"idle-producer":null:null;a.push({path:p,type:h.type,status:h.status??"unknown",valueSizeBytes:g,subscriberCount:b,depCount:y,isOrphanEffect:v,orphanKind:T})}let d=a.reduce((p,h)=>p+h.valueSizeBytes,0),u=(p,h)=>[...a].sort(h??((l,m)=>m[p]-l[p])).slice(0,n),c=a.filter(p=>p.orphanKind!=null),f=a.filter(p=>p.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:d,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:c,orphanEffects:f}}var Z="::",Me="__meta__",ut=1;function ao(t,e){let n=Math.max(16,t.size*4),r=0;for(;t.size>0;){if(r++>=n){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${n}); ${t.size} disposer(s) discarded`),t.clear();return}let s=t.values().next();if(s.done)return;let o=s.value;t.delete(o);try{o()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Ca(t){let e=[];for(let n of Object.keys(t).sort()){let r=t[n].v;r!=null&&e.push(`${n} ${r.id} ${r.version}`)}return e.join(`
21
+ `)}function uo(t){if(t.version!==ut)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${ut})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in t))throw new Error(`snapshot missing required key "${e}"`);if(typeof t.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof t.nodes!="object"||t.nodes===null||Array.isArray(t.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(t.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(t.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Da(t,e){let n=new WeakMap,r=(s,o)=>{if(Object.is(s,o))return!0;if(s==null||o==null||typeof s!="object"||typeof o!="object")return!1;let i=n.get(s);if(i==null&&(i=new WeakSet,n.set(s,i)),i.has(o))return!0;i.add(o);let a=s.constructor,d=o.constructor;if(a!==d)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let p=o;if(s.length!==p.length)return!1;for(let h=0;h<s.length;h++)if(!r(s[h],p[h]))return!1;return!0}if(s instanceof Map){let p=o;if(s.size!==p.size)return!1;for(let[h,l]of s)if(!p.has(h)||!r(l,p.get(h)))return!1;return!0}if(s instanceof Set){let p=o;if(s.size!==p.size)return!1;for(let h of s){let l=!1;for(let m of p)if(r(h,m)){l=!0;break}if(!l)return!1}return!0}if(ArrayBuffer.isView(s)){let p=s,h=o;if(p.length!==h.length)return!1;for(let l=0;l<p.length;l++)if(p[l]!==h[l])return!1;return!0}let u=Object.keys(s),c=Object.keys(o);if(u.length!==c.length)return!1;let f=new Set(c);for(let p of u)if(!f.has(p)||!r(s[p],o[p]))return!1;return!0};return r(t,e)}function Un(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Un);let e=t,n=Object.keys(e).sort(),r={};for(let s of n)r[s]=Un(e[s]);return r}function Pa(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Ia(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function La(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function fo(t){let e=new Set,n=[];function r(s,o){let i=`${s}\0${o}`;e.has(i)||(e.add(i),n.push([s,o]))}for(let[s,o]of Object.entries(t.nodes)){let i=o.deps;if(i)for(let a of i)r(a,s)}for(let s of t.edges)r(s.from,s.to);return n}function po(t){if(t===void 0)return"LR";if(t==="TD"||t==="LR"||t==="BT"||t==="RL")return t;throw new Error(`invalid diagram direction ${String(t)}; expected one of: TD, LR, BT, RL`)}function Ba(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,{expand:s,...o}=t,i={...o,edges:n?t.edges:[],subgraphs:r?t.subgraphs:[]},a=JSON.stringify(Un(i),null,e.indent??2);return e.logger?.(a),a}function Va(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,s=[];s.push(`Graph ${t.name}`),s.push("Nodes:");for(let i of Object.keys(t.nodes).sort()){let a=t.nodes[i];s.push(`- ${i} (${a.type}/${a.status}): ${en(a.value)}`)}if(n){s.push("Edges:");for(let i of t.edges)s.push(`- ${i.from} -> ${i.to}`)}if(r){s.push("Subgraphs:");for(let i of t.subgraphs)s.push(`- ${i}`)}let o=s.join(`
22
+ `);return e.logger?.(o),o}function ho(t,e){let n=po(e.direction),r=Object.keys(t.nodes).sort(),s=new Map;for(let i=0;i<r.length;i+=1)s.set(r[i],`n${i}`);let o=[`flowchart ${n}`];for(let i of r){let a=s.get(i);o.push(` ${a}["${Pa(i)}"]`)}for(let[i,a]of fo(t)){let d=s.get(i),u=s.get(a);!d||!u||o.push(` ${d} --> ${u}`)}return o.join(`
23
+ `)}function Ga(t,e){let n=ho(t,e);return Fa(n)}function Fa(t,e){let n=e?.theme??"default",r=e?.autoSync??!0,o=JSON.stringify({code:t,mermaid:{theme:n},autoSync:r}),i=new TextEncoder().encode(o),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function $a(t,e){let n=po(e.direction),r=Object.keys(t.nodes).sort(),s=new Map;for(let i=0;i<r.length;i+=1)s.set(r[i],`n${i}`);let o=[`direction: ${La(n)}`];for(let i of r){let a=s.get(i);o.push(`${a}: "${Ia(i)}"`)}for(let[i,a]of fo(t)){let d=s.get(i),u=s.get(a);!d||!u||o.push(`${d} -> ${u}`)}return o.join(`
24
+ `)}function Ka(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Zt(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let s=t.indexOf("]",n+1);if(s<=n+1){e+="\\[";continue}let o=t.slice(n+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,n=s;continue}e+=Ka(r)}return e+="$",new RegExp(e)}var za={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},ja={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function en(t){if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||t==null)return String(t);try{return JSON.stringify(t)}catch{return"[unserializable]"}}function Wa(t){return t==="none"?ja:t==="ansi"||t==null?za:{data:t.data??"",dirty:t.dirty??"",resolved:t.resolved??"",invalidate:t.invalidate??"",pause:t.pause??"",resume:t.resume??"",complete:t.complete??"",error:t.error??"",teardown:t.teardown??"",derived:t.derived??"",path:t.path??"",reset:t.reset??""}}function co(t){if(t==null)return{};let e=t.detail;return e==="full"?{...t,structured:t.structured??!0,timeline:t.timeline??!0,causal:t.causal??!0,derived:t.derived??!0}:e==="minimal"?{...t,structured:t.structured??!0}:t.format==="stage-log"?{...t,structured:t.structured??!0,timeline:t.timeline??!0}:t}function Ha(t,e,n){for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);if(s<32||s===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function Hn(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(Z))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${Z}' (path separator)`);if(t===Me)throw new Error(`Graph "${e}": ${n} name "${Me}" is reserved for meta companion paths`);Ha(t,e,n)}function Ua(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(Z);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function qa(t,e){let n=!1;for(let s of t)if(!e.isMetaPassthrough(s[0])){n=!0;break}return n?t.filter(s=>e.isMetaPassthrough(s[0])):t}function mo(t){for(let e of t._mounts.values())mo(e);for(let e of t._nodes.values())try{e.down([[K]],{internal:!0})}catch{}}var xt=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(Z))throw new Error(`Graph name must not contain '${Z}' (got "${e}")`);if(e===Me)throw new Error(`Graph name "${Me}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??le,this._traceRing=new qe(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=R(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}add(e,n){let r=e.name,s=n?.name??r;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,i=n?.annotation;if(Hn(o,this.name,"add"),this._mounts.has(o))throw new Error(`Graph "${this.name}": name "${o}" is already a mount point`);if(this._nodes.has(o))throw new Error(`Graph "${this.name}": node "${o}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(o,e),this._nodeToName.set(e,o),this._emitTopology({kind:"added",name:o,nodeKind:"node"}),i!=null&&(this._annotations.set(o,i),this.config.inspectorEnabled&&this._traceRing.push({path:o,annotation:i,timestamp_ns:ne()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof oe&&n._applyVersioning(e)}remove(e){Hn(e,this.name,"remove");let n=this._mounts.get(e);if(n){let o={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,d]of i)a.includes(`${Z}${Me}${Z}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...n._collectSubgraphs(`${e}${Z}`)),this._mounts.delete(e),n._parent=void 0,mo(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:o}),o}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[K]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let n=typeof e=="function"?e:(()=>{let o=Zt(e);return i=>o.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>n(o));for(let o of s){let i=this.remove(o);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let s=e[r++];return{value:[s,n.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(Z))return this.resolve(e);let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return n}get(e){return this.node(e).cache}set(e,n,r){let s=r?.internal===!0;this.node(e).down([[w,n]],{actor:r?.actor,internal:s,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);j(()=>{for(let[s,o]of r)this.set(s,o,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[ve]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let s=r?.internal===!0;this.node(e).down([[N,n]],{actor:r?.actor,internal:s,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[x]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[d,u]of this._nodes)r.set(u,d);let a=[];for(let[d,u]of this._nodes)if(u instanceof oe)for(let c of u._deps){let f=r.get(c.node);f!=null&&a.push([f,d])}return a.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,d]of s)o.set(d,a);let i=[];for(let[a,d]of s)if(d instanceof oe)for(let u of d._deps){let c=o.get(u.node);c!=null&&i.push([c,a])}return i.sort((a,d)=>a[0]<d[0]?-1:a[0]>d[0]?1:a[1]<d[1]?-1:a[1]>d[1]?1:0),i}mount(e,n){if(Hn(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let n=Ua(e,this.name);return this._resolveFromSegments(n)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let n=e;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],s=n.slice(1);if(s.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let o=this._nodes.get(r);if(o&&s.length>0&&s[0]===Me)return this._resolveMetaChainFromNode(o,s,n.join(Z));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${s.join(Z)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(s.join(Z))}_resolveMetaChainFromNode(e,n,r){let s=e,o=0,i=[...n];for(;o<i.length;){if(i[o]!==Me)throw new Error(`Graph "${this.name}": expected ${Me} segment in meta path "${r}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Me} in "${r}"`);let a=i[o+1],d=s.meta[a];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);s=d,o+=2}return s}signal(e,n){if(n?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,s){for(let d of this._mounts.values())d._signalDeliver(e,n,r,s);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=qa(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(c){if(c instanceof Ne)throw c;s.push(c)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,s)}}}_signalMetaSubtree(e,n,r,s,o){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,s)}catch(d){if(d instanceof Ne)throw d;o.push(d)}this._signalMetaSubtree(a,n,r,s,o)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,s=Ht(e?.detail,e?.fields),o=e?.format==="spec",i=o?Ht("minimal"):s,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[_,E]of a)d.set(E,_);let u=[];{let _=a.map(([,A])=>A),E=new Set(d.values()),S=0;for(;_.length>0;){let A=_.shift();if(A instanceof oe)for(let I of A._deps){let D=I.node;if(d.has(D))continue;let L=D.name??"",O=L;if(!O||E.has(O))if(L){let $=2;for(;E.has(`${L}#${$}`);)$++;O=`${L}#${$}`}else for(O=`__internal__/${S++}`;E.has(O);)O=`__internal__/${S++}`;d.set(D,O),E.add(O),u.push([O,D]),_.push(D)}}}let c=[...a,...u],f={};for(let[_,E]of c){if(n!=null&&!E.allowsObserve(n))continue;let S=jn(E,i),A=E instanceof oe?E._deps.map(O=>d.get(O.node)??O.node.name??""):[],{name:I,...D}=S,L={...D,deps:A};if(!o){let O=this._annotations.get(_);O!=null&&(L.annotation=O)}if(r!=null)if(typeof r=="function"){let O=r;if(!(O.length>=2?O(_,L):O(L)))continue}else{let O=!0;for(let[$,ee]of Object.entries(r)){let z=$==="deps_includes"?"depsIncludes":$==="meta_has"?"metaHas":$;if(z==="depsIncludes"){if(!L.deps.includes(String(ee))){O=!1;break}continue}if(z==="metaHas"){if(!Object.hasOwn(L.meta??{},String(ee))){O=!1;break}continue}if(L[z]!==ee){O=!1;break}}if(!O)continue}f[_]=L}let p=new Set(Object.keys(f)),h=[];for(let[_,E]of c)if(E instanceof oe)for(let S of E._deps){let A=d.get(S.node);A!=null&&h.push([A,_])}h.sort((_,E)=>_[0]<E[0]?-1:_[0]>E[0]?1:_[1]<E[1]?-1:_[1]>E[1]?1:0);let l=h.map(([_,E])=>({from:_,to:E}));(n!=null||r!=null)&&(l=l.filter(_=>p.has(_.from)&&p.has(_.to)));let m=this._collectSubgraphs(""),g=n!=null||r!=null?m.filter(_=>{let E=`${_}${Z}`;return[...p].some(S=>S===_||S.startsWith(E))}):m,b=this,y=e,v={name:this.name,nodes:f,edges:l,subgraphs:g,expand(_){let E={...y,format:void 0};return Array.isArray(_)?(E.fields=_,E.detail=void 0):(E.detail=_,E.fields=void 0),b.describe(E)}},T=e??{},k=T.format;return k==="json"?Ba(v,T):k==="pretty"?Va(v,T):k==="mermaid"?ho(v,T):k==="mermaid-url"?Ga(v,T):k==="d2"?$a(v,T):k==="ascii"?eo(v,T):v}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${r}`;n.push(s),n.push(...this._mounts.get(r)._collectSubgraphs(`${s}${Z}`))}return n}resourceProfile(e){return io(this,e)}reachable(e,n,r={}){return r.withDetail===!0?lo(this.describe(),e,n,{...r,withDetail:!0}):lo(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,d]of Object.entries(s.nodes))d.lastMutation!=null&&i.set(a,d.lastMutation);return to(s,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",s=0,o=F(s,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,ht(()=>{a=!1,!d&&(s+=1,o.emit(s))}))},c=i.onEvent(g=>{let b=g.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||u()}),f=[],p=new WeakSet,h=g=>{if(p.has(g)||d)return;p.add(g);let b=g.topology.subscribe(y=>{for(let v of y){if(v[0]!==w)continue;let T=v[1];if(u(),T.kind==="added"&&T.nodeKind==="mount"){let k=g._mounts.get(T.name);k!=null&&h(k)}}});f.push(b);for(let y of g._mounts.keys()){let v=g._mounts.get(y);v!=null&&h(v)}};h(this);let l;try{l=xe([o],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(g,b)=>g===b})}catch(g){c();for(let b of f)b();throw i.dispose(),g}let m=It(l);return{node:l,dispose(){d=!0,c();for(let g of f)g();f.length=0,i.dispose(),m()}}}_explainReactive(e,n,r){let s=0,o=F(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(h=>{let l=h.type;l!=="data"&&l!=="error"&&l!=="complete"&&l!=="teardown"||a||d||(a=!0,ht(()=>{a=!1,!d&&(s+=1,o.emit(s))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},f;try{f=xe([o],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(h,l)=>h.found===l.found&&h.reason===l.reason&&h.steps.length===l.steps.length&&Ya(h.steps,l.steps)})}catch(h){throw u(),i.dispose(),h}let p=It(f);return{node:f,dispose(){d=!0,u(),i.dispose(),p()}}}_pathsMatching(e){let n=Zt(e),r=[];return this._collectObserveTargets("",r),r.map(([s])=>s).filter(s=>n.test(s))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let s=e===""?r:`${e}${Z}${r}`;this._mounts.get(r)._collectObserveTargets(s,n)}for(let r of[...this._nodes.keys()].sort()){let s=this._nodes.get(r),o=e===""?r:`${e}${Z}${r}`;n.push([o,s]),this._appendMetaObserveTargets(o,s,n)}}_appendMetaObserveTargets(e,n,r){for(let s of Object.keys(n.meta).sort()){let o=n.meta[s],i=`${e}${Z}${Me}${Z}${s}`;r.push([i,o]),this._appendMetaObserveTargets(i,o,r)}}observe(e,n){let r=typeof e=="string",o=co(r?n:e),i=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,a=o.actor;if(r){let c=e,f=this.resolve(c);if(a!=null&&!f.allowsObserve(a))throw new Ne({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,f]],o,"one"):{subscribe(p){return f.subscribe(p)},up(p){try{f.up?.(p)}catch(h){if(h instanceof Ne)return;throw h}}}}let d=[];this._collectObserveTargets("",d),d.sort((c,f)=>c[0]<f[0]?-1:c[0]>f[0]?1:0);let u=a==null?d:d.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,o,"all"):{subscribe:c=>{let f=u.map(([p,h])=>h.subscribe(l=>{c(p,l)}));return()=>{for(let p of f)p()}},up:(c,f)=>{try{this.resolve(c).up?.(f)}catch(p){if(p instanceof Ne)return;throw p}}}}_buildStructuredObserver(e,n,r){let s=r==="one"?e[0]?.[0]:void 0,o=i=>{if(r==="one"&&s!=null){let c=this.resolve(s);return this._buildStructuredObserver([[s,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,f)=>c[0]<f[0]?-1:c[0]>f[0]?1:0);let d=i.actor,u=d==null?a:a.filter(([,c])=>c.allowsObserve(d));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,o)}_createObserveResult(e,n,r){let s=n.timeline===!0,o=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",d=this.config.inspectorEnabled,u=(o||i)&&d,c=n.maxEvents,f=c!=null&&c>0?new qe(c):null,p=[],h=new Set,l={},m=new Set,g=0,b=0,y=0,v=0,T=0,k=0,_=!1,E=!1,S=0,A=new Map,I=new Map,D=new Map,L=P=>{f?f.push(P):p.push(P);for(let q of h)q(P)},O=()=>s?{timestamp_ns:ne(),in_batch:_t(),batch_id:S}:{},$=(P,q)=>{if(!(!u||!(P instanceof oe)))return P._setInspectorHook(pe=>{if(pe.kind==="dep_message")A.set(P,pe.depIndex);else if(pe.kind==="run"){let Ge=pe.batchData.map((U,ce)=>U!=null&&U.length>0?U.at(-1):pe.prevData[ce]);I.set(P,Ge);let be=pe.batchData.map(U=>U!=null?[...U]:void 0);D.set(P,be),i&&L({type:"derived",path:q,dep_values:Ge,dep_batches:be,...O()})}})},ee=P=>{let q=A.get(P),pe=I.get(P);if(!o||pe==null)return{};let be=(q!=null&&q>=0&&P instanceof oe?P._deps[q]:void 0)?.node,U=be?.v,ce=D.get(P);return{trigger_dep_index:q,trigger_dep_name:be?.name,...U!=null?{trigger_version:{id:U.id,version:U.version}}:{},dep_values:[...pe],...ce!=null?{dep_batches:ce}:{}}},z=[],te=[];for(let[P,q]of e){let pe=$(q,P);pe&&z.push(pe),te.push(q.subscribe(Ge=>{S++;for(let be of Ge){let U=be[0],ce=O();if(U===w){l[P]=be[1];let Pe=q instanceof oe?q.lastMutation?.actor??et:et;L({type:"data",path:P,data:be[1],actor:Pe,...ce,...ee(q)})}else if(a)U===G?g++:U===M?b++:U===ve?y++:U===me?v++:U===Te?T++:U===K?k++:U===x&&!m.has(P)?_=!0:U===N&&(E=!0,m.add(P));else if(U===G)g++,L({type:"dirty",path:P,...ce});else if(U===M)b++,L({type:"resolved",path:P,...ce,...ee(q)});else if(U===ve)y++,L({type:"invalidate",path:P,...ce});else if(U===me)v++,L({type:"pause",path:P,lockId:be[1],...ce});else if(U===Te)T++,L({type:"resume",path:P,lockId:be[1],...ce});else if(U===x)m.has(P)||(_=!0),L({type:"complete",path:P,...ce});else if(U===N){E=!0,m.add(P);let Pe=q instanceof oe?q.lastMutation?.actor??et:et;L({type:"error",path:P,data:be[1],actor:Pe,...ce})}else U===K&&(k++,L({type:"teardown",path:P,...ce}))}}))}let ke=!1,De=()=>{if(!ke){ke=!0;for(let P of te)P();for(let P of z)P();for(let P of ge)P({value:void 0,done:!0});ge.length=0}},_e=[],ge=[];h.add(P=>{let q=ge.shift();q?q({value:P,done:!1}):_e.push(P)});let Ve={get values(){return l},get dirtyCount(){return g},get resolvedCount(){return b},get invalidateCount(){return y},get pauseCount(){return v},get resumeCount(){return T},get teardownCount(){return k},get events(){return f?f.toArray():[...p]},get anyCompletedCleanly(){return _},get anyErrored(){return E},get completedWithoutErrors(){return _&&!E},onEvent(P){return h.add(P),()=>h.delete(P)},dispose:De,expand(P){De();let q={...n};return typeof P=="string"?q.detail=P:Object.assign(q,P),r(co(q))},[Symbol.asyncIterator](){return{next(){return _e.length>0?Promise.resolve({value:_e.shift(),done:!1}):ke?Promise.resolve({value:void 0,done:!0}):new Promise(P=>ge.push(P))},return(){return De(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Ve,n),Ve}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let s=n.logger??(l=>console.log(l)),o=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=o==null&&i==null?()=>!0:l=>(o==null||o.has(l))&&(i==null||!i.has(l)),d=Wa(n.theme),u=r==="stage-log"?ne():0,c=l=>l==null?"":n.stageLabels?.[l]??l,f=(l,m)=>l.length>m?`${l.slice(0,m-1)}\u2026`:l,p=l=>l.type==="data"||l.type==="error"?f(en(l.data),120):"",h=l=>{if(r==="stage-log"){let E=(ne()-u)/1e9,S=c(l.path).padEnd(9);if(l.type==="data"){let A=p(l);return`[${E.toFixed(3)}s] ${S} \u2190${A?` ${A}`:""}`}if(l.type==="error"){let A=p(l);return`[${E.toFixed(3)}s] ${S} \u2717${A?` ${A}`:""}`}return l.type==="complete"?`[${E.toFixed(3)}s] ${S} \u25A0 complete`:`[${E.toFixed(3)}s] ${S} ${l.type}`}if(r==="json")try{return JSON.stringify(l)}catch{return JSON.stringify({type:l.type,path:l.path,data:"[unserializable]"})}let m=d[l.type]??"",g=l.path?`${d.path}${l.path}${d.reset} `:"",b=l.type==="data"||l.type==="error",y=l.type==="pause"||l.type==="resume",v=b?` ${en(l.data)}`:y?` ${en(l.lockId)}`:"",T=l.type==="data"||l.type==="resolved"||l.type==="derived"?l:void 0,k=T?.trigger_dep_name!=null?` <- ${T.trigger_dep_name}`:T?.trigger_dep_index!=null?` <- #${T.trigger_dep_index}`:"",_=l.in_batch?" [batch]":"";return`${g}${m}${l.type.toUpperCase()}${d.reset}${v}${k}${_}`};e.onEvent(l=>{a(l.type)&&s(h(l),l)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){ao(this._disposers,this.name),this.signal([[K]],{internal:!0}),ao(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}snapshot(e){let{expand:n,...r}=this.describe({detail:"full"}),s={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:d,guard:u,...c}=r.nodes[a];s[a]=c}let o=[...r.subgraphs].sort(),i={...r,version:1,nodes:s,subgraphs:o};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return nr(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??le,{codec:s,codecVersion:o,payload:i}=rr(e,r);return s.decode(i,o)}restore(e,n){if(uo(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(o=>Zt(o)),s=n?.includeProducers===!0;for(let o of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(o)))continue;let i=e.nodes[o];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let d=this.tryResolve(o)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){n?.onError?.(o,a)}}}}}static fromSnapshot(e,n){uo(e);let r=typeof n=="function"?n:n?.build,s=typeof n=="function"?void 0:n?.factories,o=new t(e.name);if(r)return r(o),o.restore(e),o;for(let h of[...e.subgraphs].sort((l,m)=>{let g=l.split(Z).length,b=m.split(Z).length;return g!==b?g-b:l<m?-1:l>m?1:0})){let l=h.split(Z),m=o;for(let g of l)m._mounts.has(g)||m.mount(g,new t(g)),m=m._mounts.get(g)}let i=s?Object.entries(s).map(([h,l])=>({re:Zt(h),factory:l})):[],a=h=>{for(let l of i)if(l.re.test(h))return l.factory},d=h=>{let l=h.split(Z),m=l.pop();if(m==null||m.length===0)throw new Error(`invalid snapshot path "${h}"`);let g=o;for(let b of l){let y=g._mounts.get(b);if(!y)throw new Error(`unknown mount "${b}" in path "${h}"`);g=y}return[g,m]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${Z}${Me}${Z}`)).sort((h,l)=>h[0]<l[0]?-1:h[0]>l[0]?1:0),c=new Map(u),f=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[h,l]of[...c.entries()]){let m=l?.deps??[];if(!m.every(k=>f.has(k)))continue;let[g,b]=d(h),y={...l?.meta??{}},v=a(h),T;if(l?.type==="state")T=F(l.value,{meta:y});else{if(v==null)continue;T=v(b,{path:h,type:l.type,value:l.value,meta:y,deps:m,resolvedDeps:m.map(k=>f.get(k))})}g.add(T,{name:b}),f.set(h,T),c.delete(h),p=!0}}if(c.size>0){let h=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let s=(u,c)=>{if(u.disposed)return;let f=Ca(c.nodes);if(u.lastSnapshot!=null&&f!==""&&f===u.lastFingerprint)return;let p=u.seq+1,h=re(),g=u.lastSnapshot==null||p%u.compactEvery===0?{mode:"full",snapshot:c,seq:p,timestamp_ns:h,format_version:ut}:{mode:"diff",diff:Ja(u.lastSnapshot,c),seq:p,timestamp_ns:h,format_version:ut};if(u.tier.filter&&!u.tier.filter(this.name,g))return;let b;try{b=u.tier.save(this.name,g)}catch(y){n.onError?.(y,u.tier);return}if(b&&typeof b.then=="function"){let T=(u.savePending??Promise.resolve()).then(()=>b,()=>b).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=c,u.lastFingerprint=f)},k=>{n.onError?.(k,u.tier)});u.savePending=T.finally(()=>{u.savePending===T&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=c,u.lastFingerprint=f},o=(u,c)=>{try{s(u,c)}catch(f){n.onError?.(f,u.tier)}},i=(u,c)=>{if(!c.some(l=>{let m=this.config.messageTier(l[0]);return m>=3&&m<5}))return;if(n.filter){let l=this.tryResolve(u);if(l==null)return;let m=jn(l,Ht("standard"));if(!n.filter(u,m))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let l of r)l.disposed||(l.debounceMs===0?o(l,h()):(l.timer==null&&(l.timer=new Oe),l.timer.start(l.debounceMs,()=>{l.disposed||o(l,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(f=>{let p=this.tryResolve(f);return p==null?()=>{}:p.subscribe(h=>i(f,h))});a=()=>{for(let f of c)f()}}else a=this.observe().subscribe((u,c)=>i(u,c));let d=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,n){for(let r of e){let s;try{s=await r.load(this.name)}catch(i){n?.(i,r);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===ut&&o.nodes!=null)return this.restore(o),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let s of n){let o;try{o=await s.load(e)}catch(d){r?.onError?.(d,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===ut&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(d){r?.onError?.(d,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,n,r){if(e!=null&&n!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,n),this.config.inspectorEnabled){let s={path:e,annotation:n,timestamp_ns:ne(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(s=>!e(s)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let s of n)this._traceRing.push(s);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(n.nodes)),o=[...s].filter(y=>!r.has(y)).sort(),i=[...r].filter(y=>!s.has(y)).sort(),a=[],d=[];for(let y of r){if(!s.has(y))continue;let v=e.nodes[y],T=n.nodes[y],k=v.v,_=T.v;k!=null&&_!=null&&k.id===_.id&&k.version!==_.version&&d.push({path:y,id:k.id,from:k.version,to:_.version});let E=k!=null&&_!=null&&k.id===_.id&&k.version===_.version;for(let S of["type","status","sentinel"]){let A=v[S],I=T[S];A!==I&&a.push({path:y,field:S,from:A,to:I})}if(!E)for(let S of["value","meta"]){let A=v[S],I=T[S];Da(A,I)||a.push({path:y,field:S,from:A,to:I})}}let u=y=>`${y.from} ${y.to}`,c=new Set(e.edges.map(u)),f=new Set(n.edges.map(u)),p=n.edges.filter(y=>!c.has(u(y))),h=e.edges.filter(y=>!f.has(u(y))),l=new Set(e.subgraphs),m=new Set(n.subgraphs),g=[...m].filter(y=>!l.has(y)).sort(),b=[...l].filter(y=>!m.has(y)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:p,edgesRemoved:h,subgraphsAdded:g,subgraphsRemoved:b}}};function Ja(t,e){let n=xt.diff(t,e),r={};for(let s of n.nodesAdded){let o=e.nodes[s];o!=null&&(r[s]=o)}return{...n,nodesAddedFull:r}}function lo(t,e,n,r={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?s:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=r.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return r.withDetail?s:[];let i=new Map,a=new Map,d=new Map,u=new Map,c=new Set;for(let[v,T]of Object.entries(t.nodes)){if(!v)continue;c.add(v);let k=T.deps??[];i.set(v,k);for(let _ of k)_&&(c.add(_),a.has(_)||a.set(_,new Set),a.get(_).add(v))}for(let v of t.edges){if(v==null||typeof v!="object")continue;let T=typeof v.from=="string"?v.from:"",k=typeof v.to=="string"?v.to:"";!T||!k||(c.add(T),c.add(k),u.has(T)||u.set(T,new Set),u.get(T).add(k),d.has(k)||d.set(k,new Set),d.get(k).add(T))}if(!c.has(e))return r.withDetail?s:[];let f=r.both===!0,p=v=>{if(f){let E=i.get(v)??[],S=d.get(v),A=a.get(v),I=u.get(v),D=[...E];return S&&D.push(...S),A&&D.push(...A),I&&D.push(...I),D}if(n==="upstream"){let E=i.get(v)??[],S=d.get(v);return S?[...E,...S]:E}let T=a.get(v),k=u.get(v),_=T?[...T]:[];return k&&_.push(...k),_},h=new Set([e]),l=new Map,m=[{path:e,depth:0}],g=0,b=!1;for(;g<m.length;){let v=m[g++];if(o!=null&&v.depth>=o){p(v.path).length>0&&(b=!0);continue}for(let T of p(v.path))!T||h.has(T)||(h.add(T),l.set(T,v.depth+1),m.push({path:T,depth:v.depth+1}))}let y=[...l.keys()].sort((v,T)=>v<T?-1:v>T?1:0);return r.withDetail?{paths:y,depths:l,truncated:b}:y}function Ya(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],s=e[n];if(r.path!==s.path||r.type!==s.type||r.status!==s.status||r.hop!==s.hop||r.dep_index!==s.dep_index||r.annotation!==s.annotation||r.value!==s.value||r.lastMutation!==s.lastMutation)return!1;let o=r.v,i=s.v;if(o!==i&&(o==null||i==null||o.id!==i.id||o.version!==i.version))return!1}return!0}function Qa(t,e,n,r){let s=new xt(t,r);s.add(e,{name:"source"});let o=F(n,{meta:{kind:"stratify_rules"}});s.add(o,{name:"rules"});for(let i of n)Xa(s,e,o,i);return s}function Xa(t,e,n,r){let s=`branch/${r.name}`,o=Symbol("noValue"),i=!1,a=!1,d=!1,u=o,c=!1,f=n.cache??[];function p(m){if(d){d=!1;let g=u;if(u=o,g!==o){let b=f.find(v=>v.name===r.name),y=!1;try{y=b?.classify(g)??!1}catch{y=!1}y?(c=!1,m.emit(g)):c&&(c=!1,m.down([[G],[M]]))}else c?(c=!1,m.down([[G],[M]])):m.down([[M]])}}let h=B([],(m,g)=>{let b=e.subscribe(v=>{for(let T of v)l(T,0,g)}),y=n.subscribe(v=>{for(let T of v)l(T,1,g)});return()=>{b(),y()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:r.name},completeWhenDepsComplete:!1});function l(m,g,b){let y=m[0];return y===G?(g===0?(i=!0,c=!0):a=!0,!0):y===w||y===M?(g===0?(i=!1,d=!0,u=y===w?m[1]:o):(y===w&&(f=m[1]),a=!1),i||a||p(b),!0):y===x||y===N||y===K?(i=!1,a=!1,d=!1,u=o,c=!1,g===0&&b.down([m]),!0):g===1}if(t.add(h,{name:s}),r.ops){let m=r.ops(h),g=`branch/${r.name}/out`;t.add(m,{name:g})}}At();ye();X();we();ue();Ie();X();var Za=new Map([[ve,"INVALIDATE"],[me,"PAUSE"],[Te,"RESUME"],[K,"TEARDOWN"],[x,"COMPLETE"],[N,"ERROR"]]),eu=new Map([["INVALIDATE",ve],["PAUSE",me],["RESUME",Te],["TEARDOWN",K],["COMPLETE",x],["ERROR",N]]);function Je(t){let e=Za.get(t);return e||(Symbol.keyFor(t)??"UNKNOWN")}function dt(t){let e=eu.get(t);if(e)return e;if(t&&t!=="UNKNOWN")return Symbol.for(t)}function ct(t){return t instanceof Error?{message:t.message,name:t.name,stack:t.stack}:{message:String(t),name:"Error"}}function lt(t){let e=new Error(t.message);return e.name=t.name,t.stack&&(e.stack=t.stack),e}function Ye(t){if(typeof MessagePort<"u"&&t instanceof MessagePort)return{post(e,n){t.postMessage(e,n??[])},listen(e){let n=r=>e(r.data);return t.addEventListener("message",n),t.start(),()=>t.removeEventListener("message",n)},terminate(){t.close()}};if(typeof SharedWorker<"u"&&t instanceof SharedWorker)return Ye(t.port);if(typeof Worker<"u"&&t instanceof Worker)return{post(e,n){t.postMessage(e,n??[])},listen(e){let n=r=>e(r.data);return t.addEventListener("message",n),()=>t.removeEventListener("message",n)},terminate(){t.terminate()}};if(typeof BroadcastChannel<"u"&&t instanceof BroadcastChannel)return{post(e,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."),t.postMessage(e)},listen(e){let n=r=>e(r.data);return t.addEventListener("message",n),()=>t.removeEventListener("message",n)},terminate(){t.close()}};if(typeof ServiceWorker<"u"&&t instanceof ServiceWorker)return{post(e,n){t.postMessage(e,n??[])},listen(e){let n=r=>{r.source===t&&e(r.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 tu(t){return typeof t=="object"&&t!==null&&typeof t.post=="function"&&typeof t.listen=="function"}function go(t,e){let n=tu(t)?t:Ye(t),r=e.name??"workerBridge",s=Object.entries(e.expose??{}),o=e.import??[],i=e.transfer??{},a=F("connecting",{name:`${r}::meta::status`}),d=F(null,{name:`${r}::meta::error`}),u=new Map,c=new Map;for(let y of o){let v=F(void 0,{name:`${r}::${y}`});u.set(y,v)}let f;if(s.length>0){let y=s.map(([,k])=>k),v=B(y,(k,_)=>{let E={};for(let S=0;S<s.length;S++){let[A]=s[S],I=k[S];I!=null&&I.length>0&&(E[A]=I.at(-1))}Object.keys(E).length!==0&&_.emit(E)},{name:`${r}::aggregated`,partial:!0});f=Mt([v],k=>{let _=k[0];if(_==null||Object.keys(_).length===0)return;let E=[];for(let I of Object.keys(_)){let D=i[I];D&&E.push(...D(_[I]))}let S;for(let[I,D]of s)I in _&&D.v!=null&&(S==null&&(S={}),S[I]=D.v.version);let A={t:"b",u:_,...S?{v:S}:{}};try{n.post(A,E.length>0?E:void 0)}catch(I){d.down([[w,I instanceof Error?I:new Error(String(I))]])}}).subscribe(()=>{})}let p=!1,h=n.listen(y=>{if(p)return;let v=y;switch(v.t){case"r":{j(()=>{for(let[k,_]of Object.entries(v.stores)){let E=u.get(k);E&&E.down([[w,_]])}}),a.down([[w,"connected"]]);let T={};for(let[k,_]of s)T[k]=_.cache;n.post({t:"i",stores:T});break}case"v":{let T=u.get(v.s);T&&T.down([[w,v.d]]);break}case"b":{j(()=>{for(let[T,k]of Object.entries(v.u)){let _=v.v?.[T];if(_!=null){let S=c.get(T);if(S!=null&&_<=S)continue;c.set(T,_)}let E=u.get(T);E&&E.down([[w,k]])}});break}case"e":{let T=u.get(v.s);T&&T.down([[N,lt(v.err)]]);break}case"s":{let T=dt(v.sig);if(!T)break;let k=v.s==="*"?[...u.values()]:u.has(v.s)?[u.get(v.s)]:[];for(let _ of k)_.down(v.d===void 0?[[T]]:[[T,v.d]]);break}}}),l=[];for(let[y,v]of s){let T=v.subscribe((k=>{if(!p)for(let _ of k){let E=_[0];E!==w&&(le.isLocalOnly(E)||(E===N?n.post({t:"e",s:y,err:ct(_[1])}):n.post({t:"s",s:y,sig:Je(E),d:_.length>1?_[1]:void 0})))}}));l.push(T)}let m;if(e.timeoutMs!=null&&e.timeoutMs>0){let y=He(e.timeoutMs),v=Bt(a,k=>k==="connected");m=Gn(vt(Lt(y,()=>"timeout"),Lt(v,()=>"ready"))).subscribe(k=>{for(let _ of k)_[0]===w&&_[1]==="timeout"&&(d.down([[w,new Error("Worker bridge handshake timeout")]]),g())})}function g(){if(!p){p=!0,m?.(),n.post({t:"s",s:"*",sig:Je(K)}),f&&f();for(let y of l)y();l.length=0,h(),a.down([[w,"closed"]]),c.clear(),u.clear()}}let b={meta:{status:a,error:d},destroy:g};for(let[y,v]of u)b[y]=v;return b}ye();X();we();ue();function nu(t){return typeof t=="object"&&t!==null&&typeof t.post=="function"&&typeof t.listen=="function"}function bo(t,e){let n=nu(t)?t:Ye(t),r=e.import??[],s=e.transfer??{},o=new Map,i=new Map,a={};for(let g of r){let b=F(void 0,{name:`worker::${g}`});o.set(g,b),a[g]=b}let d=e.expose(a),u=Object.entries(d),c,f=!1;if(u.length>0){let g=u.map(([,v])=>v),b=B(g,(v,T)=>{let k={};for(let _=0;_<u.length;_++){let[E]=u[_],S=v[_];S!=null&&S.length>0&&(k[E]=S.at(-1))}Object.keys(k).length!==0&&T.emit(k)},{name:"workerSelf::aggregated",partial:!0});c=Mt([b],v=>{if(f)return;let T=v[0];if(T==null||Object.keys(T).length===0)return;let k=[];for(let S of Object.keys(T)){let A=s[S];A&&k.push(...A(T[S]))}let _;for(let[S,A]of u)S in T&&A.v!=null&&(_==null&&(_={}),_[S]=A.v.version);let E={t:"b",u:T,..._?{v:_}:{}};try{n.post(E,k.length>0?k:void 0)}catch{}}).subscribe(()=>{})}let p=[];for(let[g,b]of u){let y=b.subscribe((v=>{if(!f)for(let T of v){let k=T[0];k!==w&&(le.isLocalOnly(k)||(k===N?n.post({t:"e",s:g,err:ct(T[1])}):n.post({t:"s",s:g,sig:Je(k),d:T.length>1?T[1]:void 0})))}}));p.push(y)}let h=n.listen(g=>{if(f)return;let b=g;switch(b.t){case"i":{j(()=>{for(let[y,v]of Object.entries(b.stores)){let T=o.get(y);T&&T.down([[w,v]])}});break}case"v":{let y=o.get(b.s);y&&y.down([[w,b.d]]);break}case"b":{j(()=>{for(let[y,v]of Object.entries(b.u)){let T=b.v?.[y];if(T!=null){let _=i.get(y);if(_!=null&&T<=_)continue;i.set(y,T)}let k=o.get(y);k&&k.down([[w,v]])}});break}case"e":{let y=o.get(b.s);y&&y.down([[N,lt(b.err)]]);break}case"s":{let y=dt(b.sig);if(!y)break;if(y===K&&b.s==="*"){m();return}let v=b.s==="*"?[...o.values()]:o.has(b.s)?[o.get(b.s)]:[];for(let T of v)T.down(b.d===void 0?[[y]]:[[y,b.d]]);break}}}),l={};for(let[g,b]of u)l[g]=b.cache;n.post({t:"r",stores:l});function m(){if(!f){f=!0,c&&c();for(let g of p)g();p.length=0,h(),n.terminate?.(),i.clear(),o.clear()}}return{destroy:m}}0&&(module.exports={CircuitOpenError,NS_PER_MS,NS_PER_SEC,NativeIndexBackend,NativeListBackend,NativeLogBackend,NativeMapBackend,NativePubSubBackend,RateLimiterOverflowError,ResettableTimer,TimeoutError,audit,awaitSettled,buffer,bufferCount,bufferTime,cached,cascadingCache,catchError,checkpointToRedis,checkpointToS3,circuitBreaker,combine,combineLatest,concat,concatMap,constant,createTransport,createWatermarkController,csvRows,debounce,debounceTime,decorrelatedJitter,delay,deserializeError,dictStorage,distill,distinctUntilChanged,elementAt,empty,escapeRegexChar,exhaustMap,exponential,externalBundle,externalProducer,fallback,fibonacci,filter,find,first,firstValueFrom,firstWhere,flatMap,forEach,fromAny,fromAsyncIter,fromCSV,fromClickHouseWatch,fromCron,fromDrizzle,fromEvent,fromHTTP,fromHTTPPoll,fromHTTPStream,fromIter,fromKafka,fromKysely,fromMCP,fromNATS,fromNDJSON,fromOTel,fromPrisma,fromPrometheus,fromPromise,fromPulsar,fromRabbitMQ,fromRaf,fromRedisStream,fromSSE,fromSqlite,fromSqliteCursor,fromStatsD,fromSyslog,fromTimer,fromWebSocket,fromWebSocketReconnect,fromWebhook,globToRegExp,interval,keepalive,last,linear,lru,map,matchesAnyPattern,matchesCron,memoryStorage,merge,mergeMap,nameToSignal,ndjsonRows,never,of,pairwise,parseCron,parsePrometheusText,parseStatsD,parseSyslog,pausable,pubsub,race,rateLimiter,reactiveCounter,reactiveIndex,reactiveList,reactiveLog,reactiveMap,reactiveSink,reduce,repeat,replay,rescue,resolveBackoffPreset,retry,retrySource,sample,scan,serializeError,share,shareReplay,signalToName,singleFromAny,singleNodeFromAny,skip,sortJsonValue,stableJsonString,stratify,switchMap,take,takeUntil,takeWhile,tap,throttle,throttleTime,throwError,timeout,toArray,toCSV,toClickHouse,toFile,toHTTP,toKafka,toLoki,toMongo,toNATS,toObservable,toPostgres,toPulsar,toRabbitMQ,toReadableStream,toRedisStream,toS3,toSSE,toSSEBytes,toSqlite,toTempo,toWebSocket,tokenBucket,valve,verifiable,window,windowCount,windowTime,withBreaker,withLatestFrom,withMaxAttempts,withStatus,workerBridge,workerSelf,zip});