@graphrefly/graphrefly 0.36.0 → 0.38.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 (249) hide show
  1. package/dist/{chunk-J6TGRQUP.js → chunk-2YFDSYEF.js} +1 -1
  2. package/dist/{chunk-JUJEPZOI.js → chunk-4BDQXBXE.js} +1 -1
  3. package/dist/chunk-5BGFS2XH.js +1 -0
  4. package/dist/chunk-6773HURD.js +1 -0
  5. package/dist/{chunk-AQC53OWG.js → chunk-6KZZ6XQE.js} +1 -1
  6. package/dist/{chunk-5CPPC75H.js → chunk-6VFC334U.js} +1 -1
  7. package/dist/{chunk-KUVDFOJH.js → chunk-7KZZLWZ6.js} +1 -1
  8. package/dist/{chunk-Q7EUZ6NN.js → chunk-B5S7KTGP.js} +1 -1
  9. package/dist/chunk-CMTN3KPT.js +80 -0
  10. package/dist/chunk-DQJLC6YY.js +1 -0
  11. package/dist/chunk-DSOVKKTI.js +1 -0
  12. package/dist/chunk-FAYEMS5M.js +1 -0
  13. package/dist/chunk-FWGIZP3W.js +1 -0
  14. package/dist/{chunk-5Z3AFBN7.js → chunk-G7JN6LCB.js} +1 -1
  15. package/dist/{chunk-PCD2MU7X.js → chunk-IBGE62GZ.js} +1 -1
  16. package/dist/{chunk-MYFR67PY.js → chunk-K5C67OGE.js} +1 -1
  17. package/dist/chunk-KJEAIIIY.js +43 -0
  18. package/dist/chunk-LV3ACS5J.js +1 -0
  19. package/dist/{chunk-7LYIKMW5.js → chunk-NBGPXQSP.js} +1 -1
  20. package/dist/chunk-NN3QPJ6U.js +1 -0
  21. package/dist/{chunk-T6RPUERH.js → chunk-NSAZ6PR6.js} +1 -1
  22. package/dist/{chunk-KCE6WWJE.js → chunk-NV63VQHI.js} +1 -1
  23. package/dist/{chunk-PYEIPRSZ.js → chunk-O245YLM5.js} +1 -1
  24. package/dist/{chunk-K5ZXJPWU.js → chunk-O2BLVQU4.js} +1 -1
  25. package/dist/chunk-PHXZRR6C.js +1 -0
  26. package/dist/{chunk-I57VSGRB.js → chunk-POCWFIJ7.js} +1 -1
  27. package/dist/{chunk-TQSTS3BY.js → chunk-QEVSIVSF.js} +1 -1
  28. package/dist/chunk-QMC2PLNM.js +7 -0
  29. package/dist/chunk-QOJFR6GS.js +1 -0
  30. package/dist/{chunk-MQZWA3DF.js → chunk-RZ5HKPGI.js} +1 -1
  31. package/dist/{chunk-XINLP35X.js → chunk-SFK7MN7S.js} +1 -1
  32. package/dist/{chunk-YOUAVGHJ.js → chunk-SP5O2MIX.js} +1 -1
  33. package/dist/chunk-TB7JKSVS.js +61 -0
  34. package/dist/{chunk-6G5YD37E.js → chunk-TMVY7OWG.js} +1 -1
  35. package/dist/{chunk-F36TA3ET.js → chunk-UAXFKMAG.js} +1 -1
  36. package/dist/{chunk-AACJX2L7.js → chunk-UVLZX2OU.js} +1 -1
  37. package/dist/chunk-XIMFHEKV.js +1 -0
  38. package/dist/{chunk-LO3LO2TO.js → chunk-XLMYQB6F.js} +1 -1
  39. package/dist/{chunk-44QWWUA3.js → chunk-XLYF4LBH.js} +1 -1
  40. package/dist/compat/index.cjs +9 -9
  41. package/dist/compat/index.d.cts +7 -7
  42. package/dist/compat/index.d.ts +7 -7
  43. package/dist/compat/index.js +1 -1
  44. package/dist/compat/nestjs/index.cjs +9 -9
  45. package/dist/compat/nestjs/index.d.cts +5 -5
  46. package/dist/compat/nestjs/index.d.ts +5 -5
  47. package/dist/compat/nestjs/index.js +1 -1
  48. package/dist/compat/zustand/index.cjs +7 -7
  49. package/dist/compat/zustand/index.d.cts +3 -3
  50. package/dist/compat/zustand/index.d.ts +3 -3
  51. package/dist/compat/zustand/index.js +1 -1
  52. package/dist/{composite-_XckYx2e.d.cts → composite-CgG0MqHm.d.cts} +8 -1
  53. package/dist/{composite-CT_mApQD.d.ts → composite-DTOlDuch.d.ts} +8 -1
  54. package/dist/core/index.cjs +1 -1
  55. package/dist/core/index.d.cts +2 -2
  56. package/dist/core/index.d.ts +2 -2
  57. package/dist/core/index.js +1 -1
  58. package/dist/extra/index.cjs +19 -19
  59. package/dist/extra/index.d.cts +5 -5
  60. package/dist/extra/index.d.ts +5 -5
  61. package/dist/extra/index.js +1 -1
  62. package/dist/extra/node.cjs +2 -2
  63. package/dist/extra/node.d.cts +107 -1
  64. package/dist/extra/node.d.ts +107 -1
  65. package/dist/extra/node.js +2 -2
  66. package/dist/extra/operators.cjs +1 -1
  67. package/dist/extra/operators.js +1 -1
  68. package/dist/extra/reactive.d.cts +1 -1
  69. package/dist/extra/reactive.d.ts +1 -1
  70. package/dist/extra/reactive.js +1 -1
  71. package/dist/extra/sources.cjs +1 -1
  72. package/dist/extra/sources.js +1 -1
  73. package/dist/extra/storage-tiers-browser.d.cts +76 -5
  74. package/dist/extra/storage-tiers-browser.d.ts +76 -5
  75. package/dist/extra/storage-tiers-node.d.cts +137 -13
  76. package/dist/extra/storage-tiers-node.d.ts +137 -13
  77. package/dist/extra/storage-tiers.d.cts +151 -23
  78. package/dist/extra/storage-tiers.d.ts +151 -23
  79. package/dist/graph/index.cjs +7 -7
  80. package/dist/graph/index.d.cts +4 -4
  81. package/dist/graph/index.d.ts +4 -4
  82. package/dist/graph/index.js +1 -1
  83. package/dist/{graph-Cv-8x0ZI.d.ts → graph-BjW1taJl.d.ts} +243 -11
  84. package/dist/{graph-kTltt95s.d.cts → graph-CHsVwf9S.d.cts} +243 -11
  85. package/dist/{index-CZAixNU3.d.ts → index-5dNRlW7J.d.ts} +3 -3
  86. package/dist/{index-DtSVSKnd.d.ts → index-AUqWe_fX.d.ts} +7 -4
  87. package/dist/{index-DLyQC5Ww.d.ts → index-B-ORMr3k.d.ts} +2 -2
  88. package/dist/{index-C4ig7whw.d.cts → index-B2IUcH13.d.cts} +2 -2
  89. package/dist/{index-KeBhbNg3.d.ts → index-BFaALJxR.d.ts} +2 -2
  90. package/dist/{index-CsD0fqnO.d.ts → index-BI1wMfyc.d.ts} +2 -2
  91. package/dist/{index-DxxvGTXp.d.ts → index-BUFCHvOR.d.ts} +2 -2
  92. package/dist/{index-HCp5ua_i.d.cts → index-BWUMIt7J.d.cts} +3 -3
  93. package/dist/{index-DHv2M7s8.d.cts → index-BaSy4L6w.d.cts} +37 -17
  94. package/dist/{index-BhkPzu-Z.d.cts → index-BgzPO43H.d.cts} +2 -2
  95. package/dist/{index-BsZlbHM5.d.cts → index-BhzwpIJc.d.cts} +1 -1
  96. package/dist/{index-BC-xjOrd.d.cts → index-BkQqf1EF.d.cts} +80 -7
  97. package/dist/{index-BBdwz2BW.d.ts → index-BmWuVdER.d.ts} +2 -2
  98. package/dist/{index-CVhBdCMf.d.ts → index-Bn0uZEL4.d.ts} +2 -2
  99. package/dist/{index-33mF4XyU.d.cts → index-BpMZzX9P.d.cts} +2 -2
  100. package/dist/{index-ZhKyR8co.d.cts → index-Bpr0Pwgl.d.cts} +2 -2
  101. package/dist/{index-2URa-V4S.d.cts → index-BqcgiSQg.d.cts} +2 -2
  102. package/dist/{index-DzYTXMBz.d.ts → index-BsZk9T8y.d.ts} +1 -1
  103. package/dist/{index-CvUrRb4m.d.cts → index-BsgxnHN8.d.cts} +2 -2
  104. package/dist/index-Bub6x_D4.d.cts +427 -0
  105. package/dist/{index-BZ1V5GzX.d.ts → index-BwOsJfLJ.d.ts} +2 -2
  106. package/dist/{index-BuMzxRO2.d.ts → index-Byp771zP.d.ts} +1 -1
  107. package/dist/{index-DKp1CIbG.d.cts → index-C-3UXnHT.d.cts} +1 -1
  108. package/dist/{index-GaW6Welt.d.cts → index-C56XZiDe.d.cts} +2 -2
  109. package/dist/{index-k67aNfqC.d.cts → index-CAV-3RpJ.d.cts} +2 -2
  110. package/dist/{index-DmtWMP0X.d.cts → index-CAbHN_rP.d.cts} +1 -1
  111. package/dist/{index-BTJxM-wZ.d.ts → index-CEVzBWeB.d.ts} +2 -2
  112. package/dist/{index-BVNGEX7d.d.cts → index-CM-i58FY.d.cts} +2 -2
  113. package/dist/{index-EfPb77rT.d.cts → index-CQsqqEVz.d.cts} +1 -1
  114. package/dist/{index-Cot94_82.d.ts → index-CijfwEWx.d.ts} +2 -2
  115. package/dist/{index-PluovH45.d.cts → index-Ckil6miL.d.cts} +2 -2
  116. package/dist/{index-XxSeddWP.d.cts → index-CpdnP-0y.d.cts} +1 -1
  117. package/dist/{index-Pu1Wa7en.d.ts → index-CrlHFsiT.d.ts} +37 -17
  118. package/dist/{index-BWH17rK_.d.cts → index-Czk3r0yA.d.cts} +37 -3
  119. package/dist/{index-BlRVj-7Q.d.cts → index-D-B7U42V.d.cts} +2 -2
  120. package/dist/{index-B4s70vYf.d.ts → index-D-HZ7sP4.d.ts} +2 -2
  121. package/dist/{index-Cjrpx2Mg.d.cts → index-D7-RSD93.d.cts} +2 -2
  122. package/dist/{index-kBUQj-rT.d.ts → index-D9vBTuzo.d.ts} +2 -2
  123. package/dist/{index-DzCQt2FJ.d.cts → index-DJNAWzcH.d.cts} +2 -2
  124. package/dist/{index-DSSsxS7B.d.ts → index-DJVQ-t07.d.ts} +2 -2
  125. package/dist/{index-BwYGLgmI.d.ts → index-DKrIuF-r.d.ts} +2 -2
  126. package/dist/{index-DXSLMoma.d.ts → index-DOU1Ee_k.d.ts} +1 -1
  127. package/dist/{index-DlccEIi3.d.ts → index-DTDVDzhA.d.ts} +37 -3
  128. package/dist/{index-B5UR87KG.d.ts → index-DY2f2b9z.d.ts} +4 -2
  129. package/dist/{index-D8IyqHvT.d.cts → index-DeSsvHDD.d.cts} +4 -2
  130. package/dist/index-Di7OdwlO.d.ts +427 -0
  131. package/dist/{index-isdlyeeO.d.ts → index-DqICM_I7.d.ts} +80 -7
  132. package/dist/{index-DFe2Pk2u.d.ts → index-ML6vHKXK.d.ts} +1 -1
  133. package/dist/{index-RJIY7QVW.d.cts → index-UsU9ptzs.d.cts} +7 -4
  134. package/dist/{index-jA_OwwNg.d.ts → index-Vz7KPfgz.d.ts} +1 -1
  135. package/dist/index.cjs +50 -50
  136. package/dist/index.d.cts +32 -32
  137. package/dist/index.d.ts +32 -32
  138. package/dist/index.js +1 -1
  139. package/dist/meta-BYqlATmg.d.ts +98 -0
  140. package/dist/meta-DreaEM_a.d.cts +98 -0
  141. package/dist/patterns/ai/browser.cjs +2 -2
  142. package/dist/patterns/ai/browser.js +1 -1
  143. package/dist/patterns/ai/index.cjs +21 -21
  144. package/dist/patterns/ai/index.d.cts +9 -9
  145. package/dist/patterns/ai/index.d.ts +9 -9
  146. package/dist/patterns/ai/index.js +1 -1
  147. package/dist/patterns/ai/node.js +1 -1
  148. package/dist/patterns/audit/index.cjs +7 -7
  149. package/dist/patterns/audit/index.d.cts +5 -5
  150. package/dist/patterns/audit/index.d.ts +5 -5
  151. package/dist/patterns/audit/index.js +1 -1
  152. package/dist/patterns/cqrs/index.cjs +7 -7
  153. package/dist/patterns/cqrs/index.d.cts +4 -4
  154. package/dist/patterns/cqrs/index.d.ts +4 -4
  155. package/dist/patterns/cqrs/index.js +1 -1
  156. package/dist/patterns/demo-shell/index.cjs +8 -8
  157. package/dist/patterns/demo-shell/index.d.cts +4 -4
  158. package/dist/patterns/demo-shell/index.d.ts +4 -4
  159. package/dist/patterns/demo-shell/index.js +1 -1
  160. package/dist/patterns/domain-templates/index.cjs +7 -7
  161. package/dist/patterns/domain-templates/index.d.cts +3 -3
  162. package/dist/patterns/domain-templates/index.d.ts +3 -3
  163. package/dist/patterns/domain-templates/index.js +1 -1
  164. package/dist/patterns/graphspec/index.cjs +21 -21
  165. package/dist/patterns/graphspec/index.d.cts +3 -3
  166. package/dist/patterns/graphspec/index.d.ts +3 -3
  167. package/dist/patterns/graphspec/index.js +1 -1
  168. package/dist/patterns/guarded-execution/index.cjs +7 -7
  169. package/dist/patterns/guarded-execution/index.d.cts +6 -6
  170. package/dist/patterns/guarded-execution/index.d.ts +6 -6
  171. package/dist/patterns/guarded-execution/index.js +1 -1
  172. package/dist/patterns/harness/index.cjs +12 -12
  173. package/dist/patterns/harness/index.d.cts +8 -8
  174. package/dist/patterns/harness/index.d.ts +8 -8
  175. package/dist/patterns/harness/index.js +1 -1
  176. package/dist/patterns/job-queue/index.cjs +7 -7
  177. package/dist/patterns/job-queue/index.d.cts +4 -4
  178. package/dist/patterns/job-queue/index.d.ts +4 -4
  179. package/dist/patterns/job-queue/index.js +1 -1
  180. package/dist/patterns/lens/index.cjs +7 -7
  181. package/dist/patterns/lens/index.d.cts +4 -4
  182. package/dist/patterns/lens/index.d.ts +4 -4
  183. package/dist/patterns/lens/index.js +1 -1
  184. package/dist/patterns/memory/index.cjs +7 -7
  185. package/dist/patterns/memory/index.d.cts +6 -4
  186. package/dist/patterns/memory/index.d.ts +6 -4
  187. package/dist/patterns/memory/index.js +1 -1
  188. package/dist/patterns/messaging/index.cjs +7 -7
  189. package/dist/patterns/messaging/index.d.cts +4 -4
  190. package/dist/patterns/messaging/index.d.ts +4 -4
  191. package/dist/patterns/messaging/index.js +1 -1
  192. package/dist/patterns/orchestration/index.cjs +7 -7
  193. package/dist/patterns/orchestration/index.d.cts +4 -4
  194. package/dist/patterns/orchestration/index.d.ts +4 -4
  195. package/dist/patterns/orchestration/index.js +1 -1
  196. package/dist/patterns/process/index.cjs +1 -1
  197. package/dist/patterns/process/index.d.cts +5 -5
  198. package/dist/patterns/process/index.d.ts +5 -5
  199. package/dist/patterns/process/index.js +1 -1
  200. package/dist/patterns/reactive-layout/index.cjs +8 -8
  201. package/dist/patterns/reactive-layout/index.d.cts +4 -4
  202. package/dist/patterns/reactive-layout/index.d.ts +4 -4
  203. package/dist/patterns/reactive-layout/index.js +1 -1
  204. package/dist/patterns/reduction/index.cjs +7 -7
  205. package/dist/patterns/reduction/index.d.cts +3 -3
  206. package/dist/patterns/reduction/index.d.ts +3 -3
  207. package/dist/patterns/reduction/index.js +1 -1
  208. package/dist/patterns/refine-loop/index.cjs +8 -8
  209. package/dist/patterns/refine-loop/index.d.cts +5 -5
  210. package/dist/patterns/refine-loop/index.d.ts +5 -5
  211. package/dist/patterns/refine-loop/index.js +1 -1
  212. package/dist/patterns/resilient-pipeline/index.cjs +1 -1
  213. package/dist/patterns/resilient-pipeline/index.d.cts +4 -4
  214. package/dist/patterns/resilient-pipeline/index.d.ts +4 -4
  215. package/dist/patterns/resilient-pipeline/index.js +1 -1
  216. package/dist/patterns/surface/index.cjs +14 -14
  217. package/dist/patterns/surface/index.d.cts +4 -4
  218. package/dist/patterns/surface/index.d.ts +4 -4
  219. package/dist/patterns/surface/index.js +1 -1
  220. package/dist/{pipeline-graph-DdBoRu37.d.ts → pipeline-graph-9JBbmRxA.d.ts} +2 -2
  221. package/dist/{pipeline-graph-BlLBWSZ2.d.cts → pipeline-graph-DuHpXSOn.d.cts} +2 -2
  222. package/dist/{reactive-layout-D9zqqaqK.d.cts → reactive-layout-BMLDB4Vd.d.cts} +1 -1
  223. package/dist/{reactive-layout-Btv0-efV.d.ts → reactive-layout-D-tRiNhg.d.ts} +1 -1
  224. package/dist/{reactive-log-jirQsxMY.d.ts → reactive-log-BgWSA1fg.d.ts} +28 -1
  225. package/dist/{reactive-log-ScpWyqny.d.cts → reactive-log-C3IMAGpT.d.cts} +28 -1
  226. package/dist/resilience-LGBK236C.js +1 -0
  227. package/dist/{topology-tree-CJsT24DP.d.ts → topology-tree-D47-nI6Z.d.ts} +1 -1
  228. package/dist/{topology-tree-C50l9ARE.d.cts → topology-tree-jrZue3ao.d.cts} +1 -1
  229. package/package.json +1 -1
  230. package/dist/chunk-3U7IIQB2.js +0 -1
  231. package/dist/chunk-533RQFF6.js +0 -1
  232. package/dist/chunk-5CZ3KIRJ.js +0 -1
  233. package/dist/chunk-5KPIYVCC.js +0 -7
  234. package/dist/chunk-5RTZ6DXG.js +0 -1
  235. package/dist/chunk-A5HZZYRK.js +0 -1
  236. package/dist/chunk-CGA5RXO6.js +0 -1
  237. package/dist/chunk-DBPFMCVH.js +0 -1
  238. package/dist/chunk-GWOKTENT.js +0 -1
  239. package/dist/chunk-JJTF75VS.js +0 -1
  240. package/dist/chunk-KL7CILPL.js +0 -1
  241. package/dist/chunk-M27MVZCP.js +0 -1
  242. package/dist/chunk-N2GCKKKH.js +0 -43
  243. package/dist/chunk-QKUWS7CO.js +0 -80
  244. package/dist/chunk-YBA5N4XY.js +0 -61
  245. package/dist/index-CI_yjtua.d.ts +0 -139
  246. package/dist/index-D9qoEOj_.d.cts +0 -139
  247. package/dist/meta-BGO6C7K9.d.cts +0 -41
  248. package/dist/meta-CC6EPdpK.d.ts +0 -41
  249. package/dist/resilience-OBU472D2.js +0 -1
@@ -1,24 +1,24 @@
1
- "use strict";var un=Object.defineProperty;var Co=Object.getOwnPropertyDescriptor;var Po=Object.getOwnPropertyNames;var Do=Object.prototype.hasOwnProperty;var me=(t,e)=>()=>(t&&(e=t(t=0)),e);var dn=(t,e)=>{for(var n in e)un(t,n,{get:e[n],enumerable:!0})},Io=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Po(e))!Do.call(t,s)&&s!==n&&un(t,s,{get:()=>e[s],enumerable:!(r=Co(e,s))||r.enumerable});return t};var Lo=t=>Io(un({},"__esModule",{value:!0}),t);function Et(){return Qe>0||pt}function or(){return Qe>0}function mt(t){Qe>0?ht.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(!pt){let n=ht.splice(0);for(let r of n)try{r()}catch{}$e.length=0,Ke.length=0,Xe.length=0}}else Bo()}}function Bo(){let t=!pt;t&&(pt=!0);let e=[],n=0;try{for(;$e.length>0||Ke.length>0||Xe.length>0||t&&ht.length>0;){if(t&&ht.length>0){let o=ht.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw $e.length=0,Ke.length=0,Xe.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=($e.length>0?$e:Ke.length>0?Ke:Xe).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{t&&(pt=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Ot(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!Et()){t(e);return}(u>=5?Xe:u===4?Ke:$e).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=Et();if(s>0){let u=e.slice(0,s);t(u)}if(o>s){let u=e.slice(s,o);d?$e.push(()=>t(u)):t(u)}if(i>o){let u=e.slice(o,i);d?Ke.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);d?Xe.push(()=>t(u)):t(u)}}var Qe,pt,$e,Ke,Xe,ht,Te=me(()=>{"use strict";Qe=0,pt=!1,$e=[],Ke=[],Xe=[],ht=[]});function ne(){return Math.trunc(performance.now()*1e6)}function re(){return Date.now()*1e6}var Be=me(()=>{"use strict"});var Le,x,$,P,we,ge,xe,z,N,E,Ze,cn,Vo,ln,Go,Fo,fn,sr,ir,ar,pn,Z=me(()=>{"use strict";Le=Symbol.for("graphrefly/START"),x=Symbol.for("graphrefly/DATA"),$=Symbol.for("graphrefly/DIRTY"),P=Symbol.for("graphrefly/RESOLVED"),we=Symbol.for("graphrefly/INVALIDATE"),ge=Symbol.for("graphrefly/PAUSE"),xe=Symbol.for("graphrefly/RESUME"),z=Symbol.for("graphrefly/TEARDOWN"),N=Symbol.for("graphrefly/COMPLETE"),E=Symbol.for("graphrefly/ERROR"),Ze=Object.freeze([$]),cn=Object.freeze([P]),Vo=Object.freeze([we]),ln=Object.freeze([Le]),Go=Object.freeze([N]),Fo=Object.freeze([z]),fn=Object.freeze([Ze]),sr=Object.freeze([cn]),ir=Object.freeze([Vo]),ar=Object.freeze([Go]),pn=Object.freeze([Fo])});function dr(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++]=hn,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 cr(t,e){if(t.length<ur)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${ur})`);let n=0,r=t[n++];if(r!==hn)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${hn})`);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 lr(t){t.registerCodec($o)}var $o,hn,ur,mn=me(()=>{"use strict";$o={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)}},hn=1,ur=4});function Rt(t){if(t==null)return et;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var et,gn=me(()=>{"use strict";et={type:"system",id:""}});function fr(t){t.registerMessageType(Le,{tier:0,wireCrossing:!1}),t.registerMessageType($,{tier:1,wireCrossing:!1}),t.registerMessageType(we,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(ge,{tier:2,wireCrossing:!1}),t.registerMessageType(xe,{tier:2,wireCrossing:!1}),t.registerMessageType(x,{tier:3,wireCrossing:!0}),t.registerMessageType(P,{tier:3,wireCrossing:!0}),t.registerMessageType(N,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(E,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(z,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Mt,pr=me(()=>{"use strict";Z();Mt=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=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}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=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 bn(t){let e=Ko.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 Se,Ko,At=me(()=>{"use strict";Se=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}},Ko=["human","llm","wallet","system"]});function yn(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(yn);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=yn(t[n]);return e}return null}function Wo(t){let e=jo.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,l=1359893119,f=2600822924,p=528734635,h=1541459225,m=new Uint32Array(64),b=(y,v)=>y>>>v|y<<32-v;for(let y=0;y<s;y+=64){for(let C=0;C<16;C++)m[C]=i.getUint32(y+C*4,!1);for(let C=16;C<64;C++){let D=m[C-15],R=m[C-2],V=b(D,7)^b(D,18)^D>>>3,Q=b(R,17)^b(R,19)^R>>>10;m[C]=m[C-16]+V+m[C-7]+Q>>>0}let v=a,w=d,_=u,k=c,T=l,S=f,O=p,M=h;for(let C=0;C<64;C++){let D=b(T,6)^b(T,11)^b(T,25),R=T&S^~T&O,V=M+D+R+zo[C]+m[C]>>>0,Q=b(v,2)^b(v,13)^b(v,22),K=v&w^v&_^w&_,te=Q+K>>>0;M=O,O=S,S=T,T=k+V>>>0,k=_,_=w,w=v,v=V+te>>>0}a=a+v>>>0,d=d+w>>>0,u=u+_>>>0,c=c+k>>>0,l=l+T>>>0,f=f+S>>>0,p=p+O>>>0,h=h+M>>>0}let g=y=>y.toString(16).padStart(8,"0");return g(a)+g(d)+g(u)+g(c)+g(l)+g(f)+g(p)+g(h)}function vn(t){let e=yn(t??null),n=JSON.stringify(e);return Wo(n).slice(0,16)}function Ho(){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 Tn(t,e,n){let r=n?.id??Ho();if(t===0)return{id:r,version:0};let o=(n?.hash??vn)(e);return{id:r,version:0,cid:o,prev:null}}function hr(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var zo,jo,mr=me(()=>{"use strict";zo=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]),jo=new TextEncoder});function yr(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function wn(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Ct(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function B(t,e,n){let r=vr(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,o={};return vr(t)?o=(xn(e)?e:n)??{}:xn(t)?o=t:o=(xn(e)?e:n)??{},new oe(r,s,o)}var gr,br,Uo,qo,le,oe,vr,xn,be=me(()=>{"use strict";mn();gn();Te();Be();pr();At();Z();mr();gr=()=>{},br=100;Uo=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},qo=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[ln]:[ln,[x,o]];s._status==="dirty"&&i.push(Ze),Ot(e,i,s._config.tierOf)},le=new Mt({onMessage:Uo,onSubscribe:qo});fr(le);lr(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??vn;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?Tn(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(yr);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([[x,a]])},down(a){i._emit(Ct(a))},up(a){i._emitUp(Ct(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=Tn(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=Rt(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=Rt(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new Se({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new Se({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:re()}}down(e,n){let r=Ct(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[x,e]])}up(e,n){if(this._deps.length===0)return;let r=Ct(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=Rt(n);if(!this._guard(d,"observe"))throw new Se({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)wn(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=gr,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{}wn(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=yr(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(fn),r.unsub=gr;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([[E,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([[E,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{}}wn(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!==Le){if(s===$){this._depDirtied(r);return}if(s===we){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(ir);return}if(s===ge||s===xe){this._emit([n]);return}if(s===z){this._emit(pn);return}if(s===x)this._depSettledAsData(r,n[1]);else if(s===P)this._depSettledAsResolved(r);else if(s===N)this._depSettledAsTerminal(r,!0);else if(s===E)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===x||s===P)&&this._emit([n]),(s===N||s===E)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(fn))}_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(sr),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[E,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(ar)}_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([[E,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([[E,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([[E,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>br?(this._rerunDepth=0,this._emit([[E,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${br} \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]===$&&(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]===E&&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]===z||d[0]===we);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!==ge&&u!==xe){s?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===ge?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let l=d[1];if(u===ge)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(l),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(l))c=!1;else if(this._pauseLocks.delete(l),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let f=this._pauseBuffer;this._pauseBuffer=[],this._emit(f)}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]===z))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(pn)}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([[E,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]===x){d=c;break}}for(let c=0;c<e.length;c++){let l=e[c],f=l[0];if(f===x){if(l.length>=2){let p=!1;if(a&&this._cached!==void 0)try{p=this._equals(this._cached,l[1])}catch(h){s=this._wrapFnError("equals threw",h),o=c;break}if(p){r==null&&(r=e.slice(0,c)),r.push(cn),this._status="resolved";continue}this._cached=l[1],this._versioning!=null&&(d<0||c===d)&&hr(this._versioning,l[1],this._hashFn)}this._status="settled",r?.push(l)}else if(r?.push(l),f===$)this._status="dirty";else if(f===P)this._status="resolved";else if(f===N){this._status="completed";{let p=this._config.rigorRecorder;if(p!=null)try{p.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(f===E){this._status="errored";{let p=this._config.rigorRecorder;if(p!=null)try{p.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(f===we){if(this._cached!==void 0){let h=this._config.rigorRecorder;if(h!=null)try{h.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let p=this._cleanup;if(typeof p=="function"){this._cleanup=void 0;try{p()}catch{}}else if(p!=null&&typeof p=="object"){let h=p.invalidate;if(typeof h=="function")try{h()}catch{}}}else f===z&&(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(or()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],mt(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}Ot(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);Ot(this._deliverToSinks,n,this._config.tierOf)}},vr=t=>Array.isArray(t),xn=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function F(t,e){return B([],{...e,initial:t})}function A(t,e){return B((r,s,o)=>t(s,o)??void 0,{describeKind:"producer",...e})}function fe(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 Pt(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 de=me(()=>{"use strict";be()});var wr={};dn(wr,{NS_PER_MS:()=>pe,NS_PER_SEC:()=>Ae,constant:()=>kn,decorrelatedJitter:()=>En,exponential:()=>Nn,fibonacci:()=>Sn,linear:()=>_n,resolveBackoffPreset:()=>je,withMaxAttempts:()=>Tr});function ze(t){return t<0?0:t}function Jo(t,e){return e==="none"?t:e==="full"?Math.random()*t:t/2+Math.random()*(t/2)}function Yo(t,e){return t+Math.random()*(e-t)}function kn(t){let e=ze(t);return()=>e}function _n(t,e){let n=ze(t),r=e===void 0?n:ze(e);return s=>n+r*Math.max(0,s)}function Nn(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 Jo(i,s)}}function Sn(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 En(t=100*1e6,e=30*1e9){return(n,r,s)=>{let i=Math.min(e,(s??t)*3);return Yo(t,i)}}function Tr(t,e){return(n,r,s)=>n>=e?null:t(n,r,s)}function je(t){if(t==="constant")return kn(1*1e9);if(t==="linear")return _n(1*1e9);if(t==="exponential")return Nn();if(t==="fibonacci")return Sn();if(t==="decorrelatedJitter")return En();throw new Error(`Unknown backoff preset: "${String(t)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var pe,Ae,gt=me(()=>{"use strict";pe=1e6,Ae=1e9});function bt(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,l]=o.split("-");d=Number.parseInt(c,10),u=Number.parseInt(l,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 Rn(t){let e=t.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:bt(e[0],0,59),hours:bt(e[1],0,23),daysOfMonth:bt(e[2],1,31),months:bt(e[3],1,12),daysOfWeek:bt(e[4],0,6)}}function Mn(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 An=me(()=>{"use strict"});var Oe,Dt=me(()=>{"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 _r={};dn(_r,{CircuitOpenError:()=>nt,RateLimiterOverflowError:()=>rt,TimeoutError:()=>ot,circuitBreaker:()=>Cn,fallback:()=>In,rateLimiter:()=>Dn,retry:()=>yt,timeout:()=>Ln,tokenBucket:()=>Lt,withBreaker:()=>Pn,withStatus:()=>vt});function We(t){return{describeKind:"derived",...t}}function Qo(t){return t<0?0:t}function It(t){return t[1]}function kr(t){if(typeof t!="number"||!Number.isFinite(t))throw new TypeError("backoff strategy must return a finite number");return t<0?0:t}function yt(t,e){return typeof t=="function"?Zo(t,e):Xo(t,e)}function Xo(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 A(i=>{let a=0,d=!1,u=null,c,l=new Oe;function f(){c?.(),c=void 0}function p(m){if(d)return;if(a>=s){f(),i.down([[E,m]]);return}let b=o===null?0:o(a,m,u);if(b==null){f(),i.down([[E,m]]);return}let g;try{g=kr(b)}catch{f(),i.down([[E,m]]);return}u=g,a+=1,f();let y=g>0?g/1e6:1;l.start(y,()=>{d||h()})}function h(){l.cancel(),f(),c=t.subscribe(m=>{if(!d)for(let b of m){let g=b[0];if(g===$)i.down([[$]]);else if(g===x)a=0,u=null,i.emit(b[1]);else if(g===P)i.down([[P]]);else if(g===N)f(),i.down([[N]]);else if(g===E){p(It(b));return}else i.down([b])}})}return h(),()=>{d=!0,l.cancel(),f()}},{...We(),initial:t.cache})}function Zo(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 A(i=>{let a=0,d=!1,u=null,c,l=new Oe;function f(){c?.(),c=void 0}function p(m){if(d)return;if(a>=s){f(),i.down([[E,m]]);return}let b=o===null?0:o(a,m,u);if(b==null){f(),i.down([[E,m]]);return}let g;try{g=kr(b)}catch{f(),i.down([[E,m]]);return}u=g,a+=1,f();let y=g>0?g/1e6:1;l.start(y,()=>{d||h()})}function h(){l.cancel(),f();let m;try{m=t()}catch(b){p(b);return}c=m.subscribe(b=>{if(!d)for(let g of b){let y=g[0];if(y===$)i.down([[$]]);else if(y===x)a=0,u=null,i.emit(g[1]);else if(y===P)i.down([[P]]);else if(y===N)f(),i.down([[N]]);else if(y===E){p(It(g));return}else i.down([g])}})}return h(),()=>{d=!0,l.cancel(),f()}},{...We(),initial:e?.initial})}function Cn(t){let e=Math.max(1,t?.failureThreshold??5),n=Qo(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,l=0;function f(){if(!r)return n;let m=r(d);return m!==null?m:n}function p(){i="open",c=f(),u=o(),l=0}return{canExecute(){return i==="closed"?!0:i==="open"?o()-u>=c?(i="half-open",l=1,!0):!1:l<s?(l++,!0):!1},recordSuccess(){i==="half-open"?(i="closed",a=0,d=0):i==="closed"&&(a=0)},recordFailure(m){if(i==="half-open"){d++,p();return}i==="closed"&&(a++,a>=e&&p())},get state(){return i},get failureCount(){return a},reset(){i="closed",a=0,d=0,l=0}}}function Pn(t,e){let n=e?.onOpen??"skip";return r=>{let s=B([],(o,i)=>{function a(){s.meta.breakerState.down([[x,t.state]])}let d=r.subscribe(u=>{for(let c of u){let l=c[0];l===$?i.down([[$]]):l===x?t.canExecute()?(a(),i.emit(c[1])):(a(),n==="error"?i.down([[E,new nt]]):i.down([[P]])):l===P?i.down([[P]]):l===N?(t.recordSuccess(),a(),i.down([[N]])):l===E?(t.recordFailure(It(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 Lt(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 Dn(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 A(a=>{let d=Lt(n,i),u=[],c=new Oe,l=!1,f=1e9/i;function p(){for(;u.length>0;)if(d.tryConsume(1))a.emit(u.shift());else{c.start(Math.max(1,f/1e6),p);return}}let h=t.subscribe(m=>{for(let b of m){if(l)return;let g=b[0];if(g===$)a.down([[$]]);else if(g===x){if(s!==void 0&&u.length>=s){if(o!=="drop-newest")if(o==="drop-oldest")u.shift(),u.push(b[1]);else{l=!0,c.cancel(),u.length=0,a.down([[E,new rt(s)]]);return}}else u.push(b[1]);p()}else if(g===P)a.down([[P]]);else if(g===N)l=!0,c.cancel(),u.length=0,a.down([[N]]);else if(g===E)l=!0,c.cancel(),u.length=0,a.down([b]);else if(g===z){l=!0,c.cancel(),u.length=0,a.down([b]);return}else a.down([b])}});return()=>{l=!0,c.cancel(),h()}},{...We(),initial:t.cache})}function vt(t,e){let n=e?.initialStatus??"pending",r=B([],(s,o)=>{let i=n;return r.meta.status.down([[x,n]]),r.meta.error.down([[x,null]]),t.subscribe(d=>{for(let u of d){let c=u[0];if(c===$)o.down([[$]]);else if(c===x)i==="errored"?j(()=>{r.meta.error.down([[x,null]]),r.meta.status.down([[x,"active"]])}):r.meta.status.down([[x,"active"]]),i="active",o.emit(u[1]);else if(c===P)o.down([[P]]);else if(c===N)r.meta.status.down([[x,"completed"]]),i="completed",o.down([[N]]);else if(c===E){let l=It(u);j(()=>{r.meta.error.down([[x,l]]),r.meta.status.down([[x,"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 es(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function ts(t){return t!=null&&typeof t.then=="function"}function ns(t){return t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function"}function In(t,e){return A(n=>{let r,s;function o(){s?.(),s=void 0,es(e)||ts(e)||ns(e)?r=ue(e).subscribe(a=>{n.down(a)}):(n.emit(e),n.down([[N]]))}return s=t.subscribe(i=>{for(let a of i){let d=a[0];if(d===$)n.down([[$]]);else if(d===x)n.emit(a[1]);else if(d===P)n.down([[P]]);else if(d===N)n.down([[N]]);else if(d===E){o();return}else if(d===z){r?.(),n.down([a]);return}else n.down([a])}}),()=>{s?.(),r?.()}},{...We(),initial:t.cache})}function Ln(t,e){if(e<=0)throw new RangeError("timeoutNs must be > 0");return A(n=>{let r=!1,s=new Oe;function o(){let a=e/1e6;s.start(a,()=>{r||(r=!0,i(),n.down([[E,new ot(e)]]))})}let i=t.subscribe(a=>{for(let d of a){if(r)return;let u=d[0];if(u===$)n.down([[$]]);else if(u===x)o(),n.emit(d[1]);else if(u===P)n.down([[P]]);else if(u===N){s.cancel(),r=!0,n.down([[N]]);return}else if(u===E){s.cancel(),r=!0,n.down([d]);return}else if(u===z){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,Bt=me(()=>{"use strict";Te();Be();Z();be();de();gt();Ce();Dt();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 _e(t){return{describeKind:"producer",...t}}function Sr(t){return/[\\^$+?.()|[\]{}]/.test(t)?`\\${t}`:t}function rs(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+=Sr(r)}return e+="$",new RegExp(e)}function os(t,e){for(let n of e)if(n.test(t))return!0;return!1}function ss(t,e){let n=B([t],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[P]]);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 A(o=>{let i=!1,a=0,d,u,c=()=>{i=!0,d!==void 0&&clearTimeout(d),u!==void 0&&clearInterval(u),n?.removeEventListener("abort",f)},l=()=>{i||(r!=null?(o.emit(a++),u=setInterval(()=>{i||o.emit(a++)},r)):(i=!0,n?.removeEventListener("abort",f),o.emit(a++),o.down([[N]])))},f=()=>{i||(c(),o.down([[E,n.reason]]))};if(n?.aborted){f();return}return d=setTimeout(l,t),n?.addEventListener("abort",f,{once:!0}),c},_e(s))}function is(t){let{signal:e,...n}=t??{};return A(r=>{let s=!1,o,i,a=!1,d=!1,u=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,c=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,l=typeof document<"u"?document:void 0,f=()=>{o!==void 0&&c&&c(o),i!==void 0&&clearTimeout(i),o=void 0,i=void 0},p=()=>{s=!0,f(),a&&(e?.removeEventListener("abort",h),a=!1),d&&l&&(l.removeEventListener("visibilitychange",g),d=!1)},h=()=>{s||(p(),r.down([[E,e.reason]]))},m=y=>{s||(r.emit(y),b())},b=()=>{s||(u&&(!l||l.visibilityState!=="hidden")?o=u(m):i=setTimeout(()=>m(performance.now()),16))},g=()=>{s||(f(),b())};return e?.aborted?(h(),p):(e?.addEventListener("abort",h,{once:!0}),a=e!==void 0,l&&u&&(l.addEventListener("visibilitychange",g),d=!0),b(),p)},_e(n))}function as(t,e){let n=Rn(t),{tickMs:r,output:s,...o}=e??{},i=r??6e4,a=s==="date";return A(d=>{let u=-1,c=()=>{let f=new Date,p=f.getFullYear()*1e8+(f.getMonth()+1)*1e6+f.getDate()*1e4+f.getHours()*100+f.getMinutes();p!==u&&Mn(n,f)&&(u=p,d.emit(a?f:re()))};c();let l=setInterval(c,i);return()=>clearInterval(l)},{..._e(o),name:o.name??`cron:${t}`})}function us(t,e,n){let{capture:r,passive:s,once:o,...i}=n??{};return A(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)},_e(i))}function Gn(t,e){return A(n=>{let r=!1;try{for(let s of t){if(r)return;n.emit(s)}r||n.down([[N]])}catch(s){r||n.down([[E,s]])}return()=>{r=!0}},_e(e))}function ds(t){return t!=null&&typeof t.then=="function"}function Er(t,e){let{signal:n,...r}=e??{};return A(s=>{let o=!1,i=()=>{o||(o=!0,s.down([[E,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([[N]]))},a=>{o||(o=!0,n?.removeEventListener("abort",i),s.down([[E,a]]))}),()=>{o=!0,n?.removeEventListener("abort",i)}},_e(r))}function Or(t,e){let{signal:n,...r}=e??{};return A(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(l=>{if(!(d||a.aborted)){if(l.done){s.down([[N]]);return}s.emit(l.value),c()}},l=>{!d&&!a.aborted&&s.down([[E,l]])})};return c(),()=>{d=!0,n?.removeEventListener("abort",i),o.abort(),Promise.resolve(u.return?.()).catch(()=>{})}},_e(r))}function cs(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function ue(t,e){if(cs(t))return t;if(ds(t))return Er(t,e);if(t!=null){let n=t;if(typeof n[Symbol.asyncIterator]=="function")return Or(t,e);if(typeof n[Symbol.iterator]=="function")return Gn(t,e)}return Rr(t)}function Rr(...t){return Gn(t,void 0)}function ls(t){return A(e=>{e.down([[N]])},_e(t))}function fs(t){return A(()=>{},_e(t))}function ps(t,e){return A(n=>{n.down([[E,t]])},_e(e))}function hs(t,e){let{signal:n,...r}=e??{},s=_e(r),o=s.resubscribable===void 0?{...s,resubscribable:!0}:s;return A(i=>{let a,d=!1;try{let u=t();a=ue(u,e).subscribe(l=>{if(!d)for(let f of l){let p=f[0];if(p!==Le)if(p===x)i.emit(f[1]);else if(p===N){d=!0,i.down([[N]]);break}else if(p===E){d=!0,i.down([[E,f[1]]]);break}else i.down([f])}})}catch(u){let c=u===void 0?new Error("defer: thunk threw undefined"):u;i.down([[E,c]])}return()=>{d=!0,a?.()}},o)}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 ms(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([[N]]);return}(i==null||i.length===0)&&r.down([[P]])},{describeKind:"derived",completeWhenDepsComplete:!1,...e})}function gs(t,e){return A(n=>t.subscribe(r=>{n.down(r)}),{..._e(e),initial:t.cache})}function Fn(t,e,n){if(e<1)throw new RangeError("replay expects bufferSize >= 1");let r=[],s=A(o=>t.subscribe(i=>{for(let a of i)a[0]===x&&(r.push(a[1]),r.length>e&&r.shift());o.down(i)}),{..._e(n),initial:t.cache});return ss(s,o=>{for(let i of r)o([[x,i]])})}function bs(t,e){return Fn(t,1,e)}function $n(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]===x){r=!0,e(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===E){r=!0,n(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===N){r=!0,n(new Error("completed without DATA")),o?(o(),o=void 0):s=!0;return}}}),s&&(o?.(),o=void 0)})}function Vn(t,e,n){return new Promise((r,s)=>{let o=!1,i=!1,a,d=n?.skipCurrent===!0;a=t.subscribe(u=>{for(let c of u){if(o)return;if(!(d&&c[0]===x)){if(c[0]===x){let l=c[1];if(e(l)){o=!0,r(l),a?(a(),a=void 0):i=!0;return}}if(c[0]===E){o=!0,s(c[1]),a?(a(),a=void 0):i=!0;return}if(c[0]===N){o=!0,s(new Error("completed without matching value")),a?(a(),a=void 0):i=!0;return}}}}),d=!1,i&&(a?.(),a=void 0)})}async function ys(t,e){let n=e?.predicate??(o=>o!=null),r=e?.skipCurrent;if(e?.timeoutMs==null||e.timeoutMs<=0)return await Vn(t,n,{skipCurrent:r});if(Bn===void 0){let[o,i]=await Promise.all([Promise.resolve().then(()=>(Bt(),_r)),Promise.resolve().then(()=>(gt(),wr))]);Bn=o.timeout,Nr=i.NS_PER_MS}let s=Bn(t,e.timeoutMs*Nr);return await Vn(s,n,{skipCurrent:r})}function vs(t,e){let n=new AbortController,r=e?.reason??new Error("cancelled via nodeSignal"),s,o=!1,i=()=>{s?(s(),s=void 0):o=!0};return s=t.subscribe(a=>{if(!n.signal.aborted)for(let d of a){if(d[0]===x&&d[1]===!0){n.abort(r),i();return}if(d[0]===E){n.abort(d[1]),i();return}if(d[0]===N){i();return}}}),o&&(s?.(),s=void 0),{signal:n.signal,dispose:()=>{s&&(s(),s=void 0)}}}function st(t){return t.subscribe(()=>{})}function ws(t){let e=F(0);return{node:e,increment(){let n=e.cache??0;return n>=t?!1:(e.down([[$],[x,n+1]]),!0)},get(){return e.cache??0},atCap(){return(e.cache??0)>=t}}}var Bn,Nr,Ts,Ce=me(()=>{"use strict";Be();Z();be();de();An();Ts=Fn});var Ou={};dn(Ou,{CircuitOpenError:()=>nt,ContentAddressedMissError:()=>zt,NS_PER_MS:()=>pe,NS_PER_SEC:()=>Ae,NativeIndexBackend:()=>Wt,NativeListBackend:()=>Ht,NativeLogBackend:()=>Ut,NativeMapBackend:()=>Kt,NativePubSubBackend:()=>jt,RateLimiterOverflowError:()=>rt,ResettableTimer:()=>Oe,TimeoutError:()=>ot,appendLogStorage:()=>to,audit:()=>Ks,awaitSettled:()=>ys,buffer:()=>zs,bufferCount:()=>js,bufferTime:()=>Hs,cached:()=>bs,canonicalJson:()=>Xr,cascadingCache:()=>ta,catchError:()=>ni,checkpointToRedis:()=>Hi,checkpointToS3:()=>Wi,circuitBreaker:()=>Cn,combine:()=>Pr,combineLatest:()=>Zs,concat:()=>Is,concatMap:()=>Vs,constant:()=>kn,contentAddressedStorage:()=>sa,createTransport:()=>Ye,createWatermarkController:()=>ea,csvRows:()=>Oi,debounce:()=>Ir,debounceTime:()=>ei,decorrelatedJitter:()=>En,defer:()=>hs,delay:()=>Fs,deserializeError:()=>ft,dictKv:()=>_a,dictSnapshot:()=>Na,distill:()=>oa,distinctUntilChanged:()=>As,elementAt:()=>Os,empty:()=>ls,escapeRegexChar:()=>Sr,exhaustMap:()=>Bs,exponential:()=>Nn,externalBundle:()=>On,externalProducer:()=>tt,fallback:()=>In,fibonacci:()=>Sn,filter:()=>Gt,find:()=>Es,first:()=>Kn,firstValueFrom:()=>$n,firstWhere:()=>Vn,flatMap:()=>Gs,forEach:()=>Ue,fromAny:()=>ue,fromAsyncIter:()=>Or,fromCSV:()=>Ei,fromClickHouseWatch:()=>Ai,fromCron:()=>as,fromDrizzle:()=>Qi,fromEvent:()=>us,fromHTTP:()=>Gr,fromHTTPPoll:()=>li,fromHTTPStream:()=>ci,fromIter:()=>Gn,fromKafka:()=>ki,fromKysely:()=>Xi,fromMCP:()=>hi,fromNATS:()=>Di,fromNDJSON:()=>Mi,fromOTel:()=>mi,fromPrisma:()=>Yi,fromPrometheus:()=>wi,fromPromise:()=>Er,fromPulsar:()=>Ci,fromRabbitMQ:()=>Li,fromRaf:()=>is,fromRedisStream:()=>Ni,fromSSE:()=>di,fromSqlite:()=>Ui,fromSqliteCursor:()=>qi,fromStatsD:()=>yi,fromSyslog:()=>gi,fromTimer:()=>He,fromWebSocket:()=>Vr,fromWebSocketReconnect:()=>pi,fromWebhook:()=>oi,globToRegExp:()=>rs,interval:()=>Js,jsonCodec:()=>_t,jsonCodecFor:()=>Ta,keepalive:()=>st,kvStorage:()=>Yn,last:()=>Ss,linear:()=>_n,lru:()=>Hr,makeHttpError:()=>ia,map:()=>Vt,matchesAnyPattern:()=>os,matchesCron:()=>Mn,memoryAppendLog:()=>xa,memoryBackend:()=>Jt,memoryKv:()=>ka,memorySnapshot:()=>wa,merge:()=>Tt,mergeMap:()=>Dr,mergeReactiveLogs:()=>ma,nameToSignal:()=>ct,ndjsonRows:()=>Ri,never:()=>fs,nodeSignal:()=>vs,of:()=>Rr,onFirstData:()=>Cr,pairwise:()=>Cs,parseCron:()=>Rn,parsePrometheusText:()=>zr,parseSSEStream:()=>Kr,parseStatsD:()=>Ti,parseSyslog:()=>bi,pausable:()=>Qs,pubsub:()=>ua,race:()=>Ls,rateLimiter:()=>Dn,reactiveCounter:()=>ws,reactiveIndex:()=>la,reactiveList:()=>fa,reactiveLog:()=>ha,reactiveMap:()=>Wn,reactiveSink:()=>ie,reduce:()=>ks,repeat:()=>Ys,replay:()=>Fn,rescue:()=>Br,resolveBackoffPreset:()=>je,retry:()=>yt,sample:()=>$s,scan:()=>xs,serializeError:()=>lt,share:()=>gs,shareReplay:()=>Ts,signalToName:()=>Je,singleFromAny:()=>ga,singleNodeFromAny:()=>ba,skip:()=>Ar,snapshotStorage:()=>Jn,sortJsonValue:()=>qt,stableJsonString:()=>qn,stratify:()=>xu,switchMap:()=>Pe,take:()=>Ft,takeUntil:()=>Ns,takeWhile:()=>_s,tap:()=>Rs,tapFirst:()=>Ms,throttle:()=>Lr,throttleTime:()=>ti,throwError:()=>ps,timeout:()=>Ln,toArray:()=>ms,toCSV:()=>Vi,toClickHouse:()=>Gi,toFile:()=>Wr,toHTTP:()=>si,toKafka:()=>_i,toLoki:()=>zi,toMongo:()=>Ki,toNATS:()=>Ii,toObservable:()=>aa,toPostgres:()=>$i,toPulsar:()=>Pi,toRabbitMQ:()=>Bi,toReadableStream:()=>ui,toRedisStream:()=>Si,toS3:()=>Fi,toSSE:()=>ii,toSSEBytes:()=>ai,toSqlite:()=>Ji,toTempo:()=>ji,toWebSocket:()=>fi,tokenBucket:()=>Lt,valve:()=>Xs,verifiable:()=>ra,window:()=>qs,windowCount:()=>Ws,windowTime:()=>Us,withBreaker:()=>Pn,withLatestFrom:()=>Ps,withMaxAttempts:()=>Tr,withStatus:()=>vt,workerBridge:()=>Oo,workerSelf:()=>Ro,zip:()=>Ds});module.exports=Lo(Ou);Te();Be();Z();be();de();Te();Z();de();function xr(t){return{describeKind:"producer",...t}}function tt(t,e){return A(n=>{let r=!0,s={emit(i){r&&n.emit(i)},error(i){r&&(r=!1,n.down([[E,i]]))},complete(){r&&(r=!1,n.down([[N]]))}},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{}}},xr(e))}function On(t,e,n){let r=!0,s,o=0,i=0,a={},d=[],u=()=>{let p=s;s=void 0;try{p?.()}catch{}};for(let p of e){let h=n?.name?`${n.name}::${p}`:p,m=n?.channelOpts?.[p],b=A(g=>(o++,()=>{i++,o>0&&i>=o&&i>=e.length&&u()}),xr({...m,name:h}));a[p]=b,d.push(b)}let c={};for(let p of e)c[p]=h=>{r&&a[p].down([[x,h]])};c.error=p=>{r&&(r=!1,j(()=>{for(let h of d)h.down([[E,p]])}),u())},c.complete=()=>{r&&(r=!1,j(()=>{for(let p of d)p.down([[N]])}),u())};let l=t(c);return s=typeof l=="function"?l:void 0,Object.assign(a,{dispose:()=>{r&&(r=!1,j(()=>{for(let p of d)try{p.down([[N]])}catch{}}),u())}})}Be();Z();be();de();Ce();function G(t){return{describeKind:"derived",...t}}function Mr(t){return{describeKind:"derived",partial:!0,...t}}function Vt(t,e,n){return B([t],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[P]]);return}for(let i of o)s.emit(e(i))},G(n))}function Gt(t,e,n){return B([t],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[P]]);return}let i=!1;for(let a of o)e(a)&&(s.emit(a),i=!0);i||s.down([[P]])},G(n))}function xs(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([[P]]);return}for(let d of a)i.store.acc=e(i.store.acc,d),o.emit(i.store.acc)},{...G(r),initial:n,resetOnTeardown:!0})}function ks(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([[N]]);return}let a=s[0];if(a==null||a.length===0){o.down([[P]]);return}for(let d of a)i.store.acc=e(i.store.acc,d)},{...G(r),completeWhenDepsComplete:!1})}function Ft(t,e,n){return e<=0?B([t],(r,s,o)=>{o.store.completed||(o.store.completed=!0,s.down([[N]]))},{...G(n),completeWhenDepsComplete:!1}):B([t],(r,s,o)=>{if("taken"in o.store||(o.store.taken=0),o.store.done){s.down([[P]]);return}if(o.terminalDeps[0]===!0){o.store.done=!0,s.down([[N]]);return}let i=r[0];if(i==null||i.length===0){s.down([[P]]);return}for(let a of i)if(o.store.taken++,s.emit(a),o.store.taken>=e){o.store.done=!0,s.down([[N]]);return}},{...G(n),completeWhenDepsComplete:!1})}function Ar(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([[P]]);return}let a=!1;for(let d of i)o.store.skipped++,o.store.skipped<=e||(s.emit(d),a=!0);a||s.down([[P]])},G(n))}function _s(t,e,n){return B([t],(r,s,o)=>{if(o.store.done){s.down([[P]]);return}let i=r[0];if(i==null||i.length===0){s.down([[P]]);return}for(let a of i){if(!e(a)){o.store.done=!0,s.down([[N]]);return}s.emit(a)}},{...G(n),completeWhenDepsComplete:!1})}function Ns(t,e,n){let r=n?.predicate??(i=>i[0]===x),{predicate:s,...o}=n??{};return A(i=>{let a=!1,d=t.subscribe(c=>{if(!a)for(let l of c){if(a)return;l[0]===x?i.emit(l[1]):(l[0]===N||l[0]===E)&&(a=!0,i.down([l]))}}),u=e.subscribe(c=>{if(!a)for(let l of c){if(a)return;if(r(l)){a=!0,i.down([[N]]);return}}});return()=>{d(),u()}},G(o))}function Kn(t,e){return Ft(t,1,e)}function Ss(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([[N]]);return}let d=o[0];if(d==null||d.length===0){i.down([[P]]);return}a.store.latest=d.at(-1),a.store.has=!0},{...G(r),completeWhenDepsComplete:!1})}function Es(t,e,n){return Ft(Gt(t,e,n),1,n)}function Os(t,e,n){return Ft(Ar(t,e,n),1,n)}function Rs(t,e,n){if(typeof e=="function")return B([t],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[P]]);return}for(let a of i)e(a),o.emit(a)},G(n));let r=e;return B([t],(s,o,i)=>{if(i.terminalDeps[0]!==void 0){i.terminalDeps[0]===!0?(r.complete?.(),o.down([[N]])):(r.error?.(i.terminalDeps[0]),o.down([[E,i.terminalDeps[0]]]));return}let a=s[0];if(a==null||a.length===0){o.down([[P]]);return}for(let d of a)r.data?.(d),o.emit(d)},{...G(n),completeWhenDepsComplete:!1})}function Cr(t,e,n){let r=n?.where??(o=>o!=null),s=!1;return B([t],(o,i)=>{let a=o[0];if(a==null||a.length===0){i.down([[P]]);return}for(let d of a)!s&&r(d)&&(s=!0,e(d)),i.emit(d)},G(n))}var Ms=Cr;function As(t,e=Object.is,n){return B([t],(r,s,o)=>{let i=r[0];if(i==null||i.length===0){s.down([[P]]);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([[P]])},G(n))}function Cs(t,e){return B([t],(n,r,s)=>{let o=n[0];if(o==null||o.length===0){r.down([[P]]);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([[P]])},G(e))}function Pr(...t){let e=[...t];return fe(e,n=>n,{...G(),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 Ps(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([[P]]);return}for(let u of i)s.emit([u,d])}else s.down([[P]])},Mr(n))}function Tt(...t){return t.length===0?A(e=>{e.down([[N]])},G()):A(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]===x?e.emit(d[1]):d[0]===N?(r+=1,r>=n&&e.down([[N]])):d[0]===E&&e.down([d])});s.push(i)}return()=>{for(let o of s)o()}},G())}function Ds(...t){let e=t.length;return e===0?A(n=>{n.emit([]),n.down([[N]])},G()):A(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 l of c)l[0]===x?(r[d].push(l[1]),o()):l[0]===N?(s-=1,(s===0||r[d].length===0)&&n.down([[N]])):l[0]===E&&n.down([l])});i.push(u)}return()=>{for(let a of i)a()}},G())}function Is(t,e,n){return A(r=>{let s=0,o=[],i,a;return a=e.subscribe(d=>{for(let u of d)s===0?u[0]===x?o.push(u[1]):u[0]===E&&r.down([u]):u[0]===x?r.emit(u[1]):(u[0]===N||u[0]===E)&&r.down([u])}),i=t.subscribe(d=>{for(let u of d)if(s===0)if(u[0]===x)r.emit(u[1]);else if(u[0]===N){s=1;for(let c of o)r.emit(c);o.length=0}else u[0]===E&&r.down([u])}),()=>{i?.(),a?.()}},G(n))}function Ls(...t){return t.length===0?A(e=>{e.down([[N]])},G()):t.length===1?B([t[0]],(e,n)=>{let r=e[0];if(r==null||r.length===0){n.down([[P]]);return}for(let s of r)n.emit(s)},G()):A(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]===x?(n===null&&(n=o),e.emit(d[1])):(d[0]===N||d[0]===E)&&(n===null||o===n)&&e.down([d])}});r.push(i)}return()=>{for(let s of r)s()}},G())}function $t(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]!==Le&&(u[0]===x?e.emit(u[1]):u[0]===N?a=!0:u[0]===E?(d=!0,e.down([u])):(u[0]===$||u[0]===P)&&e.down([u]));d?(r?.(),r=void 0,o()):a&&o()}),()=>{r?.(),r=void 0}}function Pe(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([[N]]);return}let u=i[0];if(!(u==null||u.length===0))return o(),r=$t(ue(e(u[u.length-1])),a,()=>{o(),s&&a.down([[N]])}),{deactivate:()=>{o(),s=!1}}},{...G(n),completeWhenDepsComplete:!1})}function Bs(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([[N]]);return}let u=i[0];if(!(u==null||u.length===0))return r===void 0?r=$t(ue(e(u[0])),a,()=>{o(),s&&a.down([[N]])}):a.down([[P]]),{deactivate:()=>{o(),s=!1}}},{...G(n),completeWhenDepsComplete:!1})}function Vs(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([[N]]);return}let f=o.shift();i=$t(ue(e(f)),d,()=>{u(),c()})}function l(f){r&&r>0&&o.length>=r&&o.shift(),o.push(f),c()}return B([t],(f,p,h)=>{if(d=p,h.terminalDeps[0]!=null&&h.terminalDeps[0]!==!0){u(),o.length=0;return}if(h.terminalDeps[0]===!0){a=!0,c();return}let m=f[0];if(!(m==null||m.length===0)){for(let b of m)l(b);return{deactivate:()=>{u(),o.length=0,a=!1}}}},{...G(s),completeWhenDepsComplete:!1})}function Dr(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 l(){a&&i===0&&u.length===0&&c&&c.down([[N]])}function f(b){if(!c)return;i++;let g;g=$t(ue(e(b)),c,()=>{g&&d.delete(g),i--,p(),l()}),d.add(g)}function p(){for(;u.length>0&&i<o;)f(u.shift())}function h(b){i<o?f(b):u.push(b)}function m(){for(let b of d)b();d.clear(),i=0,u.length=0}return B([t],(b,g,y)=>{if(c=g,y.terminalDeps[0]!=null&&y.terminalDeps[0]!==!0){m();return}if(y.terminalDeps[0]===!0){a=!0,l();return}let v=b[0];if(!(v==null||v.length===0)){for(let w of v)h(w);return{deactivate:()=>{m(),a=!1}}}},{...G(s),completeWhenDepsComplete:!1})}var Gs=Dr;function Fs(t,e,n){return A(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]===x){let u=setTimeout(()=>{s.delete(u),r.emit(d[1])},e);s.add(u)}else if(d[0]===N){let u=setTimeout(()=>{s.delete(u),r.down([[N]])},e);s.add(u)}else d[0]===E&&(o(),r.down([d]))});return()=>{i(),o()}},G(n))}function Ir(t,e,n){return A(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]===x?(i(),o=u[1],s=setTimeout(()=>{s=void 0,r.emit(o)},e)):u[0]===N?(s!==void 0&&(i(),r.emit(o)),r.down([[N]])):u[0]===E&&(i(),r.down([u]))});return()=>{a(),i()}},G(n))}function Lr(t,e,n){let{leading:r,trailing:s,...o}=n??{},i=r!==!1,a=s===!0,d=e*1e6;return A(u=>{let c,l=-1/0,f,p=!1;function h(){c!==void 0&&(clearTimeout(c),c=void 0)}let m=t.subscribe(b=>{for(let g of b)if(g[0]===x){let y=g[1],v=ne();if(i&&v-l>=d)l=v,u.emit(y),h(),a&&(c=setTimeout(()=>{c=void 0,p&&(l=ne(),u.emit(f),p=!1)},e));else if(a&&(f=y,p=!0,c===void 0)){let w=(v-l)/1e6;c=setTimeout(()=>{c=void 0,p&&(l=ne(),u.emit(f),p=!1)},Math.max(0,e-w))}}else(g[0]===N||g[0]===E)&&(h(),u.down([g]))});return()=>{m(),h()}},G(o))}function $s(t,e,n){return A(r=>{let s,o=!1,i=!1,a=t.subscribe(u=>{if(!o)for(let c of u){if(o)return;c[0]===x?s={v:c[1]}:c[0]===E?(o=!0,r.down([c])):c[0]===N&&(i=!0,s=void 0)}}),d=e.subscribe(u=>{if(!o)for(let c of u){if(o)return;c[0]===x?s!==void 0&&!i&&r.emit(s.v):c[0]===E?(o=!0,r.down([c])):c[0]===N&&(o=!0,r.down([[N]]))}});return()=>{a(),d()}},G(n))}function Ks(t,e,n){return A(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]===x?(o=c[1],i=!0,a(),s=setTimeout(()=>{s=void 0,i&&(i=!1,r.emit(o))},e)):(c[0]===N||c[0]===E)&&(a(),r.down([c]))});return()=>{d(),a()}},G(n))}function zs(t,e,n){return A(r=>{let s=[],o=t.subscribe(a=>{for(let d of a)d[0]===x?s.push(d[1]):d[0]===N?(s.length>0&&r.emit([...s]),s.length=0,r.down([[N]])):d[0]===E&&r.down([d])}),i=e.subscribe(a=>{for(let d of a)d[0]===x?s.length>0&&(r.emit([...s]),s.length=0):d[0]===N?r.down([[N]]):d[0]===E&&r.down([d])});return()=>{o(),i(),s.length=0}},G(n))}function js(t,e,n){if(e<=0)throw new RangeError("bufferCount expects count > 0");return A(r=>{let s=[],o=t.subscribe(i=>{for(let a of i)a[0]===x?(s.push(a[1]),s.length>=e&&r.emit(s.splice(0,s.length))):a[0]===N?(s.length>0&&r.emit([...s]),s.length=0,r.down([[N]])):a[0]===E&&r.down([a])});return()=>{o(),s.length=0}},G(n))}function Ws(t,e,n){if(e<=0)throw new RangeError("windowCount expects count > 0");return A(r=>{let s,o=0;function i(){let d=A(u=>(s=u.down.bind(u),()=>{s=void 0}),G());o=0,r.emit(d)}let a=t.subscribe(d=>{for(let u of d)u[0]===x?(s||i(),s?.([[x,u[1]]]),o+=1,o>=e&&(s?.([[N]]),s=void 0)):u[0]===N?(s?.([[N]]),s=void 0,r.down([[N]])):u[0]===E&&(s?.([u]),s=void 0,r.down([u]))});return()=>{a(),s?.([[N]]),s=void 0}},G(n))}function Hs(t,e,n){return A(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]===x?s.push(d[1]):d[0]===N?(clearInterval(o),s.length>0&&r.emit([...s]),s.length=0,r.down([[N]])):d[0]===E&&(clearInterval(o),r.down([d]))});return()=>{i(),clearInterval(o),s.length=0}},G(n))}function Us(t,e,n){return A(r=>{let s;function o(){s?.([[N]]),s=void 0}function i(){let u=A(c=>(s=c.down.bind(c),()=>{s=void 0}),G());r.emit(u)}i();let a=setInterval(()=>{o(),i()},e),d=t.subscribe(u=>{for(let c of u)c[0]===x?s?.([[x,c[1]]]):c[0]===N?(clearInterval(a),o(),r.down([[N]])):c[0]===E&&(clearInterval(a),s?.([c]),o(),r.down([c]))});return()=>{d(),clearInterval(a),o()}},G(n))}function qs(t,e,n){return A(r=>{let s;function o(){s?.([[N]]),s=void 0}function i(){let u=A(c=>(s=c.down.bind(c),()=>{s=void 0}),G());r.emit(u)}let a=t.subscribe(u=>{for(let c of u)c[0]===x?(s||i(),s?.([[x,c[1]]])):c[0]===N?(o(),r.down([[N]])):c[0]===E&&(s?.([c]),s=void 0,r.down([c]))}),d=e.subscribe(u=>{for(let c of u)c[0]===x&&(o(),i())});return()=>{a(),d(),o()}},G(n))}function Js(t,e){return A((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)},G(e))}function Ys(t,e,n){if(e<=0)throw new RangeError("repeat expects count > 0");return A(r=>{let s=e,o,i=()=>{o?.(),o=t.subscribe(a=>{let d=!1,u=[];for(let c of a)c[0]===N?d=!0:u.push(c);u.length>0&&r.down(u),d&&(o?.(),o=void 0,s-=1,s>0?i():r.down([[N]]))})};return i(),()=>{o?.()}},G(n))}function Qs(t,e){return B([t],(n,r)=>{let s=n[0];if(s==null||s.length===0){r.down([[P]]);return}for(let o of s)r.emit(o)},G(e))}function Br(t,e,n){return A(r=>{let s=t.subscribe(o=>{for(let i of o)if(i[0]===x)r.emit(i[1]);else if(i[0]===E)try{r.emit(e(i[1]))}catch(a){r.down([[E,a]])}else i[0]===N&&r.down([[N]])});return()=>{s()}},G(n))}function Xs(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([[P]]);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([[P]])},Mr(n))}var Zs=Pr,ei=Ir,ti=Lr,ni=Br;Z();be();de();gt();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 zn=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 wt(t){return t instanceof Error?t:new Error(String(t))}function ri(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:l,send:f,sendBatch:p,ctx:h}=e;if(!f&&!p)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let m=h,b=Math.max(1,s?.maxAttempts??1),g=ri(s?.backoff??(b>1?"exponential":void 0)),y=s?.shouldRetry??(()=>!0),v=p!==void 0||i<Number.POSITIVE_INFINITY||a>0,w=I=>n?`${n}::${I}`:void 0,_=F(void 0,{equals:()=>!1,name:w("sent")}),k=F(null,{name:w("failed")}),T=F(0,{name:w("inFlight")}),S=F(null,{name:w("errors")}),O=v?F(0,{name:w("buffered")}):void 0,M=o?F(!1,{name:w("paused")}):void 0,C=0,D=I=>{C+=I,T.down([[x,C]])},R=I=>{try{r?.(I)}catch{}try{S.down([[x,I]])}catch{}},V=new Set,Q=I=>{V.add(I);let W=()=>V.delete(I);I.then(W,W)},K=(I,W,J)=>{let X=g?g(W-1,J,null):0,ae=X==null?0:typeof X=="number"&&X>0?X:0,Ee=Math.max(1,Math.ceil(ae/1e6));return new Promise(Y=>{setTimeout(()=>Y(I()),Ee)})},te=I=>I!=null&&typeof I=="object"&&typeof I.then=="function",ke=I=>{let W;try{W=d?d(I):I}catch(Y){let H=wt(Y);return R({stage:"serialize",error:H,value:I}),k.down([[x,{value:I,error:H,attempts:0}]]),Promise.resolve()}let J=0,X=Y=>{D(-1);let H=wt(Y);if(R({stage:"send",error:H,value:I,attempt:J}),!(J<b&&y(H,J))){k.down([[x,{value:I,error:H,attempts:J}]]);return}return K(Ee,J,H)},ae=()=>{D(-1),_.down([[x,I]])};function Ee(){J+=1,D(1);let Y;try{Y=f(W,m)}catch(H){return X(H)??Promise.resolve()}return te(Y)?Y.then(ae,H=>X(H)):(ae(),Promise.resolve())}return Ee()},De=o?.maxBuffer??Number.POSITIVE_INFINITY,Ne=new zn(De),ye,Ge=!1,L=()=>{O?.down([[x,Ne.length]])},q=I=>{M&&M.down([[x,I]])},he=o?.strategy??"drop-oldest",Fe=(I,W)=>{let J={value:I,payload:W};if(Ne.length<De)return Ne.push(J),L(),!0;if(he==="drop-oldest"){let ae=Ne.shift();return Ne.push(J),L(),q(!0),k.down([[x,{value:ae.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(he==="drop-newest")return q(!0),k.down([[x,{value:I,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let X=new Error("backpressure: buffer overflow");return R({stage:"send",error:X,value:I}),k.down([[x,{value:I,error:X,attempts:0}]]),q(!0),!1},ve=I=>{let W=0,J=I.map(Y=>Y.payload),X=Y=>{D(-1);let H=wt(Y);if(R({stage:"send",error:H,value:I.map(an=>an.value),attempt:W}),!(W<b&&y(H,W))){for(let{value:an}of I)k.down([[x,{value:an,error:H,attempts:W}]]);return}return K(Ee,W,H)},ae=()=>{D(-1);for(let{value:Y}of I)_.down([[x,Y]])};function Ee(){W+=1,D(1);let Y;try{Y=p(J,m)}catch(H){return X(H)??Promise.resolve()}return te(Y)?Y.then(ae,H=>X(H)):(ae(),Promise.resolve())}return Ee()},U=async I=>{for(let W of I)await ce(W.value,W.payload)},ce=(I,W)=>{let J=0,X=Y=>{D(-1);let H=wt(Y);if(R({stage:"send",error:H,value:I,attempt:J}),!(J<b&&y(H,J))){k.down([[x,{value:I,error:H,attempts:J}]]);return}return K(Ee,J,H)},ae=()=>{D(-1),_.down([[x,I]])};function Ee(){J+=1,D(1);let Y;try{Y=f(W,m)}catch(H){return X(H)??Promise.resolve()}return te(Y)?Y.then(ae,H=>X(H)):(ae(),Promise.resolve())}return Ee()},Ie=()=>{if(Ge||Ne.length===0)return Promise.resolve();let I=Ne.drain();if(L(),q(!1),p!==void 0){let J=ve(I);return Q(J),J}let W=U(I);return Q(W),W},Mo=()=>{ye!==void 0||Ge||a<=0||(ye=setTimeout(()=>{ye=void 0,Ie()},a))},Ao=t.subscribe(I=>{for(let W of I){let J=W[0];if(J!==x)try{c?.(W)}catch{}if(J===x){let X=W[1];if(v){let ae;if(d)try{ae=d(X)}catch(Y){let H=wt(Y);R({stage:"serialize",error:H,value:X}),k.down([[x,{value:X,error:H,attempts:0}]]);continue}else ae=X;if(!Fe(X,ae))continue;Ne.length>=i?Ie():Mo()}else{let ae=ke(X);Q(ae)}}else le.messageTier(J)>=3&&v&&(ye!==void 0&&(clearTimeout(ye),ye=void 0),Ie())}}),tr;if(u){let I=!1;tr=u.subscribe(W=>{if(!I){I=!0;return}W.length>0&&!sn&&nr()})}let sn=!1,nr=()=>{if(sn)return;sn=!0,ye!==void 0&&(clearTimeout(ye),ye=void 0),v&&Ie(),Ge=!0,tr?.(),Ao();let I=W=>{try{W.down([[z]])}catch{}};I(S),I(k),I(_),I(T),O&&I(O),M&&I(M);try{l?.()}catch{}},St={dispose:nr,sent:_,failed:k,inFlight:T,errors:S};return v&&(St.buffered=O,St.flush=async()=>{Ge||(await Ie(),await Promise.all(V))}),M&&(St.paused=M),St}Bt();Ce();function Re(t){return{describeKind:"producer",...t}}function Vr(t,e){let{parse:n,closeOnTeardown:r=!1,...s}=e??{};return A(o=>{let i=!0,a,d=()=>{let g=a;a=void 0,g?.()},u=g=>{i&&(i=!1,o.down([g]),d())},c=(g,y=g)=>{if(i)try{let v=g!==null&&typeof g=="object"&&"data"in g?g.data:g,w=n?n(v,y):v;o.emit(w)}catch(v){u([E,v])}},l=g=>{u([E,g])},f=()=>{u([N])};if(typeof t=="function"){try{if(a=t(c,l,f),typeof a!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(g){u([E,g])}return()=>{i=!1,d()}}let p=t,h=g=>c(g,g),m=g=>l(g),b=()=>f();return p.addEventListener("message",h),p.addEventListener("error",m),p.addEventListener("close",b),a=()=>{p.removeEventListener("message",h),p.removeEventListener("error",m),p.removeEventListener("close",b),r&&p.close()},()=>{i=!1,d()}},Re(s))}function oi(t,e){return tt(t,e)}function Gr(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??{},l=F(0,{name:`${c.name??"http"}/fetchCount`}),f=F(0,{name:`${c.name??"http"}/lastUpdated`}),p=F(!1,{name:`${c.name??"http"}/fetched`}),h=0,m=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0,b=v=>{let w=new AbortController,_=!0;if(a?.aborted)return _=!1,v.down([[E,a.reason??new Error("Aborted")]]),()=>{};a?.addEventListener("abort",()=>w.abort(a.reason),{once:!0});let k=setTimeout(()=>w.abort(new Error("Request timeout")),Math.ceil(i/1e6));return fetch(t,{method:n,headers:r,body:m,signal:w.signal}).then(async T=>{if(clearTimeout(k),!_)return;if(!T.ok)throw new Error(`HTTP ${T.status}: ${T.statusText}`);let S=await o(T);_&&(j(()=>{h+=1,l.down([[x,h]]),f.down([[x,re()]]),p.down([[x,!0]]),v.emit(S)}),d&&v.down([[N]]))}).catch(T=>{clearTimeout(k),_&&(T&&T.name==="AbortError"||v.down([[E,T]]))}),()=>{_=!1,w.abort()}},g=A(v=>b({emit:w=>v.emit(w),down:w=>v.down(w)}),{...Re(c),resubscribable:u});return{...vt(g),fetchCount:l,lastUpdated:f,fetched:p}}function si(t,e,n){let{method:r="POST",headers:s={"Content-Type":"application/json"},serialize:o=h=>JSON.stringify(h),timeoutNs:i,batchFormat:a="json-array",batchSize:d,flushIntervalMs:u,retry:c,onTransportError:l}=n??{},f=async h=>{let m=i!==void 0?new AbortController:void 0,b;m&&i!==void 0&&(b=setTimeout(()=>m.abort(new Error("Request timeout")),Math.ceil(i/1e6)));try{let g=await fetch(e,{method:r,headers:s,body:h,signal:m?.signal}),y=async()=>{try{await g.arrayBuffer?.()}catch{}};if(!g.ok)throw await y(),new Error(`HTTP ${g.status}: ${g.statusText}`);await y()}finally{b!==void 0&&clearTimeout(b)}};return d!==void 0||u!==void 0?ie(t,{onTransportError:l,retry:c,batchSize:d,flushIntervalMs:u,sendBatch:async h=>{let m;a==="ndjson"?m=h.map(b=>{let g=o(b);return typeof g=="string"?g:new TextDecoder().decode(g)}).join(`
2
- `):m=JSON.stringify(h),await f(m)}}):ie(t,{onTransportError:l,retry:c,serialize:o,send:async h=>{await f(h)}})}function Fr(t){return Symbol.keyFor(t)??t.description??"message"}function it(t,e){return typeof t=="string"?t:e(t)}function $r(t,e){let n=`event: ${t}
1
+ "use strict";var pn=Object.defineProperty;var Vo=Object.getOwnPropertyDescriptor;var Fo=Object.getOwnPropertyNames;var $o=Object.prototype.hasOwnProperty;var fe=(t,e)=>()=>(t&&(e=t(t=0)),e);var hn=(t,e)=>{for(var n in e)pn(t,n,{get:e[n],enumerable:!0})},Ko=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Fo(e))!$o.call(t,s)&&s!==n&&pn(t,s,{get:()=>e[s],enumerable:!(r=Vo(e,s))||r.enumerable});return t};var zo=t=>Ko(pn({},"__esModule",{value:!0}),t);function Ct(){return et>0||yt}function cr(){return et>0}function nt(t){et>0?bt.push(t):t()}function H(t){et+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(et-=1,et===0)if(e){if(!yt){let n=bt.splice(0);for(let r of n)try{r()}catch{}ze.length=0,je.length=0,tt.length=0}}else jo()}}function jo(){let t=!yt;t&&(yt=!0);let e=[],n=0;try{for(;ze.length>0||je.length>0||tt.length>0||t&&bt.length>0;){if(t&&bt.length>0){let o=bt.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw ze.length=0,je.length=0,tt.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(ze.length>0?ze:je.length>0?je:tt).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{t&&(yt=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Dt(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!Ct()){t(e);return}(u>=5?tt:u===4?je:ze).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=Ct();if(s>0){let u=e.slice(0,s);t(u)}if(o>s){let u=e.slice(s,o);d?ze.push(()=>t(u)):t(u)}if(i>o){let u=e.slice(o,i);d?je.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);d?tt.push(()=>t(u)):t(u)}}var et,yt,ze,je,tt,bt,Te=fe(()=>{"use strict";et=0,yt=!1,ze=[],je=[],tt=[],bt=[]});function ee(){return Math.trunc(performance.now()*1e6)}function oe(){return Date.now()*1e6}var Pe=fe(()=>{"use strict"});var Ie,k,$,D,we,ge,xe,z,S,E,rt,mn,Ho,gn,Wo,Uo,yn,lr,fr,pr,bn,te=fe(()=>{"use strict";Ie=Symbol.for("graphrefly/START"),k=Symbol.for("graphrefly/DATA"),$=Symbol.for("graphrefly/DIRTY"),D=Symbol.for("graphrefly/RESOLVED"),we=Symbol.for("graphrefly/INVALIDATE"),ge=Symbol.for("graphrefly/PAUSE"),xe=Symbol.for("graphrefly/RESUME"),z=Symbol.for("graphrefly/TEARDOWN"),S=Symbol.for("graphrefly/COMPLETE"),E=Symbol.for("graphrefly/ERROR"),rt=Object.freeze([$]),mn=Object.freeze([D]),Ho=Object.freeze([we]),gn=Object.freeze([Ie]),Wo=Object.freeze([S]),Uo=Object.freeze([z]),yn=Object.freeze([rt]),lr=Object.freeze([mn]),fr=Object.freeze([Ho]),pr=Object.freeze([Wo]),bn=Object.freeze([Uo])});function mr(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++]=vn,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 gr(t,e){if(t.length<hr)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${hr})`);let n=0,r=t[n++];if(r!==vn)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${vn})`);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 yr(t){t.registerCodec(qo)}var qo,vn,hr,Tn=fe(()=>{"use strict";qo={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)}},vn=1,hr=4});function Pt(t){if(t==null)return ot;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var ot,wn=fe(()=>{"use strict";ot={type:"system",id:""}});function br(t){t.registerMessageType(Ie,{tier:0,wireCrossing:!1}),t.registerMessageType($,{tier:1,wireCrossing:!1}),t.registerMessageType(we,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(ge,{tier:2,wireCrossing:!1}),t.registerMessageType(xe,{tier:2,wireCrossing:!1}),t.registerMessageType(k,{tier:3,wireCrossing:!0}),t.registerMessageType(D,{tier:3,wireCrossing:!0}),t.registerMessageType(S,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(E,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(z,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var It,vr=fe(()=>{"use strict";te();It=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=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}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=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 xn(t){let e=Jo.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 Ee,Jo,Lt=fe(()=>{"use strict";Ee=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}},Jo=["human","llm","wallet","system"]});function kn(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(kn);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=kn(t[n]);return e}return null}function Xo(t){let e=Qo.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,l=1359893119,f=2600822924,p=528734635,h=1541459225,g=new Uint32Array(64),m=(b,v)=>b>>>v|b<<32-v;for(let b=0;b<s;b+=64){for(let C=0;C<16;C++)g[C]=i.getUint32(b+C*4,!1);for(let C=16;C<64;C++){let I=g[C-15],O=g[C-2],P=m(I,7)^m(I,18)^I>>>3,X=m(O,17)^m(O,19)^O>>>10;g[C]=g[C-16]+P+g[C-7]+X>>>0}let v=a,w=d,_=u,x=c,T=l,N=f,R=p,M=h;for(let C=0;C<64;C++){let I=m(T,6)^m(T,11)^m(T,25),O=T&N^~T&R,P=M+I+O+Yo[C]+g[C]>>>0,X=m(v,2)^m(v,13)^m(v,22),K=v&w^v&_^w&_,re=X+K>>>0;M=R,R=N,N=T,T=x+P>>>0,x=_,_=w,w=v,v=P+re>>>0}a=a+v>>>0,d=d+w>>>0,u=u+_>>>0,c=c+x>>>0,l=l+T>>>0,f=f+N>>>0,p=p+R>>>0,h=h+M>>>0}let y=b=>b.toString(16).padStart(8,"0");return y(a)+y(d)+y(u)+y(c)+y(l)+y(f)+y(p)+y(h)}function _n(t){let e=kn(t??null),n=JSON.stringify(e);return Xo(n).slice(0,16)}function Zo(){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 Nn(t,e,n){let r=n?.id??Zo();if(t===0)return{id:r,version:0};let o=(n?.hash??_n)(e);return{id:r,version:0,cid:o,prev:null}}function Tr(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Yo,Qo,wr=fe(()=>{"use strict";Yo=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]),Qo=new TextEncoder});function _r(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function Sn(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Bt(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function G(t,e,n){let r=Nr(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,o={};return Nr(t)?o=(En(e)?e:n)??{}:En(t)?o=t:o=(En(e)?e:n)??{},new se(r,s,o)}var xr,kr,es,ts,pe,se,Nr,En,ye=fe(()=>{"use strict";Tn();wn();Te();Pe();vr();Lt();te();wr();xr=()=>{},kr=100;es=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},ts=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[gn]:[gn,[k,o]];s._status==="dirty"&&i.push(rt),Dt(e,i,s._config.tierOf)},pe=new It({onMessage:es,onSubscribe:ts});br(pe);yr(pe);se=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??pe,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??_n;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?Nn(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(_r);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([[k,a]])},down(a){i._emit(Bt(a))},up(a){i._emitUp(Bt(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=Nn(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=Pt(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=Pt(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new Ee({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new Ee({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:oe()}}down(e,n){let r=Bt(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[k,e]])}up(e,n){if(this._deps.length===0)return;let r=Bt(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=Pt(n);if(!this._guard(d,"observe"))throw new Ee({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)Sn(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=xr,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{}Sn(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=_r(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(yn),r.unsub=xr;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([[E,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([[E,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{}}Sn(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!==Ie){if(s===$){this._depDirtied(r);return}if(s===we){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(fr);return}if(s===ge||s===xe){this._emit([n]);return}if(s===z){this._emit(bn);return}if(s===k)this._depSettledAsData(r,n[1]);else if(s===D)this._depSettledAsResolved(r);else if(s===S)this._depSettledAsTerminal(r,!0);else if(s===E)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===k||s===D)&&this._emit([n]),(s===S||s===E)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(yn))}_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(lr),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[E,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(pr)}_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([[E,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([[E,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([[E,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>kr?(this._rerunDepth=0,this._emit([[E,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${kr} \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"?[rt,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]===$&&(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?[rt,...a]:[...a.slice(0,d),rt,...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]===E&&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]===z||d[0]===we);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!==ge&&u!==xe){s?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===ge?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let l=d[1];if(u===ge)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(l),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(l))c=!1;else if(this._pauseLocks.delete(l),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let f=this._pauseBuffer;this._pauseBuffer=[],this._emit(f)}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]===z))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(bn)}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([[E,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]===k){d=c;break}}for(let c=0;c<e.length;c++){let l=e[c],f=l[0];if(f===k){if(l.length>=2){let p=!1;if(a&&this._cached!==void 0)try{p=this._equals(this._cached,l[1])}catch(h){s=this._wrapFnError("equals threw",h),o=c;break}if(p){r==null&&(r=e.slice(0,c)),r.push(mn),this._status="resolved";continue}this._cached=l[1],this._versioning!=null&&(d<0||c===d)&&Tr(this._versioning,l[1],this._hashFn)}this._status="settled",r?.push(l)}else if(r?.push(l),f===$)this._status="dirty";else if(f===D)this._status="resolved";else if(f===S){this._status="completed";{let p=this._config.rigorRecorder;if(p!=null)try{p.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(f===E){this._status="errored";{let p=this._config.rigorRecorder;if(p!=null)try{p.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(f===we){if(this._cached!==void 0){let h=this._config.rigorRecorder;if(h!=null)try{h.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let p=this._cleanup;if(typeof p=="function"){this._cleanup=void 0;try{p()}catch{}}else if(p!=null&&typeof p=="object"){let h=p.invalidate;if(typeof h=="function")try{h()}catch{}}}else f===z&&(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(cr()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],nt(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}Dt(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);Dt(this._deliverToSinks,n,this._config.tierOf)}},Nr=t=>Array.isArray(t),En=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function V(t,e){return G([],{...e,initial:t})}function A(t,e){return G((r,s,o)=>t(s,o)??void 0,{describeKind:"producer",...e})}function he(t,e,n){return G(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 Gt(t,e,n){return G(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 ce=fe(()=>{"use strict";ye()});var Er={};hn(Er,{NS_PER_MS:()=>me,NS_PER_SEC:()=>Ce,constant:()=>On,decorrelatedJitter:()=>Cn,exponential:()=>Mn,fibonacci:()=>An,linear:()=>Rn,resolveBackoffPreset:()=>We,withMaxAttempts:()=>Sr});function He(t){return t<0?0:t}function ns(t,e){return e==="none"?t:e==="full"?Math.random()*t:t/2+Math.random()*(t/2)}function rs(t,e){return t+Math.random()*(e-t)}function On(t){let e=He(t);return()=>e}function Rn(t,e){let n=He(t),r=e===void 0?n:He(e);return s=>n+r*Math.max(0,s)}function Mn(t){let e=He(t?.baseNs??1e8),n=t?.factor!==void 0&&t.factor<1?1:t?.factor??2,r=He(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 ns(i,s)}}function An(t=100*1e6,e=30*1e9){let n=He(t),r=He(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 Cn(t=100*1e6,e=30*1e9){return(n,r,s)=>{let i=Math.min(e,(s??t)*3);return rs(t,i)}}function Sr(t,e){return(n,r,s)=>n>=e?null:t(n,r,s)}function We(t){if(t==="constant")return On(1*1e9);if(t==="linear")return Rn(1*1e9);if(t==="exponential")return Mn();if(t==="fibonacci")return An();if(t==="decorrelatedJitter")return Cn();throw new Error(`Unknown backoff preset: "${String(t)}". Use one of: constant, linear, exponential, fibonacci, decorrelatedJitter`)}var me,Ce,vt=fe(()=>{"use strict";me=1e6,Ce=1e9});function Vt(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;case"spec":return new Set(["type","deps","meta"]);default:return new Set(["type","deps"])}}function os(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function q(t,e){let n={factory:t};return e!==void 0&&(n.factoryArgs=e),n}function ss(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function Pn(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 se&&(o=os(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 se?t._guard:void 0;if(s){let u={...ss(t)};if(d!=null&&u.access===void 0&&(u.access=xn(d)),r!=null&&r.length>0&&!e.has("meta")){let c={};for(let l of r)l in u&&(c[l]=u[l]);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=xn(d)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}var Tt=fe(()=>{"use strict";Lt();ye()});function wt(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,l]=o.split("-");d=Number.parseInt(c,10),u=Number.parseInt(l,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 In(t){let e=t.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:wt(e[0],0,59),hours:wt(e[1],0,23),daysOfMonth:wt(e[2],1,31),months:wt(e[3],1,12),daysOfWeek:wt(e[4],0,6)}}function Ln(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 Bn=fe(()=>{"use strict"});var Re,Ft=fe(()=>{"use strict";Re=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 Ar={};hn(Ar,{CircuitOpenError:()=>it,RateLimiterOverflowError:()=>at,TimeoutError:()=>ut,circuitBreaker:()=>Gn,fallback:()=>$n,rateLimiter:()=>Fn,retry:()=>xt,timeout:()=>Kn,tokenBucket:()=>Kt,withBreaker:()=>Vn,withStatus:()=>kt});function Ue(t){return{describeKind:"derived",...t}}function is(t){return t<0?0:t}function $t(t){return t[1]}function Rr(t){if(typeof t!="number"||!Number.isFinite(t))throw new TypeError("backoff strategy must return a finite number");return t<0?0:t}function xt(t,e){return typeof t=="function"?us(t,e):as(t,e)}function Mr(t){let e={};return t?.count!==void 0&&(e.count=t.count),typeof t?.backoff=="string"&&(e.backoff=t.backoff),Object.keys(e).length>0?e:void 0}function as(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"?We(r):r;return A(i=>{let a=0,d=!1,u=null,c,l=new Re;function f(){c?.(),c=void 0}function p(g){if(d)return;if(a>=s){f(),i.down([[E,g]]);return}let m=o===null?0:o(a,g,u);if(m==null){f(),i.down([[E,g]]);return}let y;try{y=Rr(m)}catch{f(),i.down([[E,g]]);return}u=y,a+=1,f();let b=y>0?y/1e6:1;l.start(b,()=>{d||h()})}function h(){l.cancel(),f(),c=t.subscribe(g=>{if(!d)for(let m of g){let y=m[0];if(y===$)i.down([[$]]);else if(y===k)a=0,u=null,i.emit(m[1]);else if(y===D)i.down([[D]]);else if(y===S)f(),i.down([[S]]);else if(y===E){p($t(m));return}else i.down([m])}})}return h(),()=>{d=!0,l.cancel(),f()}},{...Ue(),initial:t.cache,meta:{...q("retry",Mr(e))}})}function us(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"?We(r):r;return A(i=>{let a=0,d=!1,u=null,c,l=new Re;function f(){c?.(),c=void 0}function p(g){if(d)return;if(a>=s){f(),i.down([[E,g]]);return}let m=o===null?0:o(a,g,u);if(m==null){f(),i.down([[E,g]]);return}let y;try{y=Rr(m)}catch{f(),i.down([[E,g]]);return}u=y,a+=1,f();let b=y>0?y/1e6:1;l.start(b,()=>{d||h()})}function h(){l.cancel(),f();let g;try{g=t()}catch(m){p(m);return}c=g.subscribe(m=>{if(!d)for(let y of m){let b=y[0];if(b===$)i.down([[$]]);else if(b===k)a=0,u=null,i.emit(y[1]);else if(b===D)i.down([[D]]);else if(b===S)f(),i.down([[S]]);else if(b===E){p($t(y));return}else i.down([y])}})}return h(),()=>{d=!0,l.cancel(),f()}},{...Ue(),initial:e?.initial,meta:{...q("retry",Mr(e))}})}function Gn(t){let e=Math.max(1,t?.failureThreshold??5),n=is(t?.cooldownNs??30*1e9),r=t?.cooldown??null,s=Math.max(1,t?.halfOpenMax??1),o=t?.now??ee,i="closed",a=0,d=0,u=0,c=n,l=0;function f(){if(!r)return n;let g=r(d);return g!==null?g:n}function p(){i="open",c=f(),u=o(),l=0}return{canExecute(){return i==="closed"?!0:i==="open"?o()-u>=c?(i="half-open",l=1,!0):!1:l<s?(l++,!0):!1},recordSuccess(){i==="half-open"?(i="closed",a=0,d=0):i==="closed"&&(a=0)},recordFailure(g){if(i==="half-open"){d++,p();return}i==="closed"&&(a++,a>=e&&p())},get state(){return i},get failureCount(){return a},reset(){i="closed",a=0,d=0,l=0}}}function Vn(t,e){let n=e?.onOpen??"skip";return r=>{let s=G([],(o,i)=>{function a(){s.meta.breakerState.down([[k,t.state]])}let d=r.subscribe(u=>{for(let c of u){let l=c[0];l===$?i.down([[$]]):l===k?t.canExecute()?(a(),i.emit(c[1])):(a(),n==="error"?i.down([[E,new it]]):i.down([[D]])):l===D?i.down([[D]]):l===S?(t.recordSuccess(),a(),i.down([[S]])):l===E?(t.recordFailure($t(c)),a(),i.down([c])):i.down([c])}});return a(),d},{...Ue(),meta:{breakerState:t.state,...q("withBreaker",{onOpen:n})},completeWhenDepsComplete:!1,initial:r.cache});return{node:s,breakerState:s.meta.breakerState}}}function Kt(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=ee();function s(o){if(e>0){let i=o-r;n=Math.min(t,n+i/1e9*e)}r=o}return{available(){return s(ee()),n},tryConsume(o=1){if(o<=0)return!0;let i=ee();return s(i),n>=o?(n-=o,!0):!1},putBack(o=1){o<=0||(s(ee()),n=Math.min(t,n+o))}}}function Fn(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 A(a=>{let d=Kt(n,i),u=[],c=new Re,l=!1,f=1e9/i;function p(){for(;u.length>0;)if(d.tryConsume(1))a.emit(u.shift());else{c.start(Math.max(1,f/1e6),p);return}}let h=t.subscribe(g=>{for(let m of g){if(l)return;let y=m[0];if(y===$)a.down([[$]]);else if(y===k){if(s!==void 0&&u.length>=s){if(o!=="drop-newest")if(o==="drop-oldest")u.shift(),u.push(m[1]);else{l=!0,c.cancel(),u.length=0,a.down([[E,new at(s)]]);return}}else u.push(m[1]);p()}else if(y===D)a.down([[D]]);else if(y===S)l=!0,c.cancel(),u.length=0,a.down([[S]]);else if(y===E)l=!0,c.cancel(),u.length=0,a.down([m]);else if(y===z){l=!0,c.cancel(),u.length=0,a.down([m]);return}else a.down([m])}});return()=>{l=!0,c.cancel(),h()}},{...Ue(),initial:t.cache,meta:{...q("rateLimiter",e)}})}function kt(t,e){let n=e?.initialStatus??"pending",r=G([],(s,o)=>{let i=n;return r.meta.status.down([[k,n]]),r.meta.error.down([[k,null]]),t.subscribe(d=>{for(let u of d){let c=u[0];if(c===$)o.down([[$]]);else if(c===k)i==="errored"?H(()=>{r.meta.error.down([[k,null]]),r.meta.status.down([[k,"active"]])}):r.meta.status.down([[k,"active"]]),i="active",o.emit(u[1]);else if(c===D)o.down([[D]]);else if(c===S)r.meta.status.down([[k,"completed"]]),i="completed",o.down([[S]]);else if(c===E){let l=$t(u);H(()=>{r.meta.error.down([[k,l]]),r.meta.status.down([[k,"errored"]])}),i="errored",o.down([u])}else o.down([u])}})},{...Ue(),meta:{status:n,error:null,...q("withStatus",{initialStatus:n})},completeWhenDepsComplete:!1,resubscribable:!0,initial:t.cache});return{node:r,status:r.meta.status,error:r.meta.error}}function ds(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function cs(t){return t!=null&&typeof t.then=="function"}function ls(t){return t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function"}function $n(t,e){return A(n=>{let r,s;function o(){s?.(),s=void 0,ds(e)||cs(e)||ls(e)?r=ae(e).subscribe(a=>{n.down(a)}):(n.emit(e),n.down([[S]]))}return s=t.subscribe(i=>{for(let a of i){let d=a[0];if(d===$)n.down([[$]]);else if(d===k)n.emit(a[1]);else if(d===D)n.down([[D]]);else if(d===S)n.down([[S]]);else if(d===E){o();return}else if(d===z){r?.(),n.down([a]);return}else n.down([a])}}),()=>{s?.(),r?.()}},{...Ue(),initial:t.cache,meta:{...q("fallback")}})}function Kn(t,e){if(e<=0)throw new RangeError("timeoutNs must be > 0");return A(n=>{let r=!1,s=new Re;function o(){let a=e/1e6;s.start(a,()=>{r||(r=!0,i(),n.down([[E,new ut(e)]]))})}let i=t.subscribe(a=>{for(let d of a){if(r)return;let u=d[0];if(u===$)n.down([[$]]);else if(u===k)o(),n.emit(d[1]);else if(u===D)n.down([[D]]);else if(u===S){s.cancel(),r=!0,n.down([[S]]);return}else if(u===E){s.cancel(),r=!0,n.down([d]);return}else if(u===z){s.cancel(),r=!0,n.down([d]);return}else n.down([d])}});return o(),()=>{r=!0,s.cancel(),i()}},{...Ue(),initial:t.cache,meta:{...q("timeout",{timeoutNs:e})}})}var it,at,ut,zt=fe(()=>{"use strict";Te();Pe();te();Tt();ye();ce();vt();De();Ft();it=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};at=class extends Error{name="RateLimiterOverflowError";constructor(e){super(`rateLimiter buffer overflow (maxBuffer=${e})`)}};ut=class extends Error{name="TimeoutError";constructor(e){super(`Timed out after ${e/1e6}ms`)}}});function _e(t){return{describeKind:"producer",...t}}function Dr(t){return/[\\^$+?.()|[\]{}]/.test(t)?`\\${t}`:t}function fs(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+=Dr(r)}return e+="$",new RegExp(e)}function ps(t,e){for(let n of e)if(n.test(t))return!0;return!1}function hs(t,e){let n=G([t],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[D]]);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 qe(t,e){let{signal:n,period:r,...s}=e??{};return A(o=>{let i=!1,a=0,d,u,c=()=>{i=!0,d!==void 0&&clearTimeout(d),u!==void 0&&clearInterval(u),n?.removeEventListener("abort",f)},l=()=>{i||(r!=null?(o.emit(a++),u=setInterval(()=>{i||o.emit(a++)},r)):(i=!0,n?.removeEventListener("abort",f),o.emit(a++),o.down([[S]])))},f=()=>{i||(c(),o.down([[E,n.reason]]))};if(n?.aborted){f();return}return d=setTimeout(l,t),n?.addEventListener("abort",f,{once:!0}),c},_e(s))}function ms(t){let{signal:e,...n}=t??{};return A(r=>{let s=!1,o,i,a=!1,d=!1,u=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,c=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,l=typeof document<"u"?document:void 0,f=()=>{o!==void 0&&c&&c(o),i!==void 0&&clearTimeout(i),o=void 0,i=void 0},p=()=>{s=!0,f(),a&&(e?.removeEventListener("abort",h),a=!1),d&&l&&(l.removeEventListener("visibilitychange",y),d=!1)},h=()=>{s||(p(),r.down([[E,e.reason]]))},g=b=>{s||(r.emit(b),m())},m=()=>{s||(u&&(!l||l.visibilityState!=="hidden")?o=u(g):i=setTimeout(()=>g(performance.now()),16))},y=()=>{s||(f(),m())};return e?.aborted?(h(),p):(e?.addEventListener("abort",h,{once:!0}),a=e!==void 0,l&&u&&(l.addEventListener("visibilitychange",y),d=!0),m(),p)},_e(n))}function gs(t,e){let n=In(t),{tickMs:r,output:s,...o}=e??{},i=r??6e4,a=s==="date";return A(d=>{let u=-1,c=()=>{let f=new Date,p=f.getFullYear()*1e8+(f.getMonth()+1)*1e6+f.getDate()*1e4+f.getHours()*100+f.getMinutes();p!==u&&Ln(n,f)&&(u=p,d.emit(a?f:oe()))};c();let l=setInterval(c,i);return()=>clearInterval(l)},{..._e(o),name:o.name??`cron:${t}`})}function ys(t,e,n){let{capture:r,passive:s,once:o,...i}=n??{};return A(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)},_e(i))}function Hn(t,e){return A(n=>{let r=!1;try{for(let s of t){if(r)return;n.emit(s)}r||n.down([[S]])}catch(s){r||n.down([[E,s]])}return()=>{r=!0}},_e(e))}function bs(t){return t!=null&&typeof t.then=="function"}function Pr(t,e){let{signal:n,...r}=e??{};return A(s=>{let o=!1,i=()=>{o||(o=!0,s.down([[E,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([[S]]))},a=>{o||(o=!0,n?.removeEventListener("abort",i),s.down([[E,a]]))}),()=>{o=!0,n?.removeEventListener("abort",i)}},_e(r))}function Ir(t,e){let{signal:n,...r}=e??{};return A(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(l=>{if(!(d||a.aborted)){if(l.done){s.down([[S]]);return}s.emit(l.value),c()}},l=>{!d&&!a.aborted&&s.down([[E,l]])})};return c(),()=>{d=!0,n?.removeEventListener("abort",i),o.abort(),Promise.resolve(u.return?.()).catch(()=>{})}},_e(r))}function vs(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"}function ae(t,e){if(vs(t))return t;if(bs(t))return Pr(t,e);if(t!=null){let n=t;if(typeof n[Symbol.asyncIterator]=="function")return Ir(t,e);if(typeof n[Symbol.iterator]=="function")return Hn(t,e)}return Lr(t)}function Lr(...t){return Hn(t,void 0)}function Ts(t){return A(e=>{e.down([[S]])},_e(t))}function ws(t){return A(()=>{},_e(t))}function xs(t,e){return A(n=>{n.down([[E,t]])},_e(e))}function ks(t,e){let{signal:n,...r}=e??{},s=_e(r),o=s.resubscribable===void 0?{...s,resubscribable:!0}:s;return A(i=>{let a,d=!1;try{let u=t();a=ae(u,e).subscribe(l=>{if(!d)for(let f of l){let p=f[0];if(p!==Ie)if(p===k)i.emit(f[1]);else if(p===S){d=!0,i.down([[S]]);break}else if(p===E){d=!0,i.down([[E,f[1]]]);break}else i.down([f])}})}catch(u){let c=u===void 0?new Error("defer: thunk threw undefined"):u;i.down([[E,c]])}return()=>{d=!0,a?.()}},o)}function Je(t,e,n){return G([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 _s(t,e){return G([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([[S]]);return}(i==null||i.length===0)&&r.down([[D]])},{describeKind:"derived",completeWhenDepsComplete:!1,...e})}function Ns(t,e){return A(n=>t.subscribe(r=>{n.down(r)}),{..._e(e),initial:t.cache})}function Wn(t,e,n){if(e<1)throw new RangeError("replay expects bufferSize >= 1");let r=[],s=A(o=>t.subscribe(i=>{for(let a of i)a[0]===k&&(r.push(a[1]),r.length>e&&r.shift());o.down(i)}),{..._e(n),initial:t.cache});return hs(s,o=>{for(let i of r)o([[k,i]])})}function Ss(t,e){return Wn(t,1,e)}function Un(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]===k){r=!0,e(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===E){r=!0,n(a[1]),o?(o(),o=void 0):s=!0;return}if(a[0]===S){r=!0,n(new Error("completed without DATA")),o?(o(),o=void 0):s=!0;return}}}),s&&(o?.(),o=void 0)})}function jn(t,e,n){return new Promise((r,s)=>{let o=!1,i=!1,a,d=n?.skipCurrent===!0;a=t.subscribe(u=>{for(let c of u){if(o)return;if(!(d&&c[0]===k)){if(c[0]===k){let l=c[1];if(e(l)){o=!0,r(l),a?(a(),a=void 0):i=!0;return}}if(c[0]===E){o=!0,s(c[1]),a?(a(),a=void 0):i=!0;return}if(c[0]===S){o=!0,s(new Error("completed without matching value")),a?(a(),a=void 0):i=!0;return}}}}),d=!1,i&&(a?.(),a=void 0)})}async function Es(t,e){let n=e?.predicate??(o=>o!=null),r=e?.skipCurrent;if(e?.timeoutMs==null||e.timeoutMs<=0)return await jn(t,n,{skipCurrent:r});if(zn===void 0){let[o,i]=await Promise.all([Promise.resolve().then(()=>(zt(),Ar)),Promise.resolve().then(()=>(vt(),Er))]);zn=o.timeout,Cr=i.NS_PER_MS}let s=zn(t,e.timeoutMs*Cr);return await jn(s,n,{skipCurrent:r})}function Os(t,e){let n=new AbortController,r=e?.reason??new Error("cancelled via nodeSignal"),s,o=!1,i=()=>{s?(s(),s=void 0):o=!0};return s=t.subscribe(a=>{if(!n.signal.aborted)for(let d of a){if(d[0]===k&&d[1]===!0){n.abort(r),i();return}if(d[0]===E){n.abort(d[1]),i();return}if(d[0]===S){i();return}}}),o&&(s?.(),s=void 0),{signal:n.signal,dispose:()=>{s&&(s(),s=void 0)}}}function Ye(t){return t.subscribe(()=>{})}function Ms(t){let e=V(0);return{node:e,increment(){let n=e.cache??0;return n>=t?!1:(e.down([[$],[k,n+1]]),!0)},get(){return e.cache??0},atCap(){return(e.cache??0)>=t}}}var zn,Cr,Rs,De=fe(()=>{"use strict";Pe();te();ye();ce();Bn();Rs=Wn});var Lu={};hn(Lu,{CircuitOpenError:()=>it,ContentAddressedMissError:()=>Jt,NS_PER_MS:()=>me,NS_PER_SEC:()=>Ce,NativeIndexBackend:()=>Qt,NativeListBackend:()=>Xt,NativeLogBackend:()=>Zt,NativeMapBackend:()=>qt,NativePubSubBackend:()=>Yt,RateLimiterOverflowError:()=>at,ResettableTimer:()=>Re,TimeoutError:()=>ut,appendLogStorage:()=>co,audit:()=>Qs,awaitSettled:()=>Es,buffer:()=>Xs,bufferCount:()=>Zs,bufferTime:()=>ti,cached:()=>Ss,canonicalJson:()=>io,cascadingCache:()=>ca,catchError:()=>li,checkpointToRedis:()=>ta,checkpointToS3:()=>ea,circuitBreaker:()=>Gn,combine:()=>Fr,combineLatest:()=>ui,concat:()=>js,concatMap:()=>Us,constant:()=>On,contentAddressedStorage:()=>ha,createTransport:()=>Ze,createWatermarkController:()=>da,csvRows:()=>Bi,debounce:()=>Kr,debounceTime:()=>di,decorrelatedJitter:()=>Cn,defer:()=>ks,delay:()=>Js,deserializeError:()=>mt,dictKv:()=>Da,dictSnapshot:()=>Pa,distill:()=>pa,distinctUntilChanged:()=>Fs,elementAt:()=>Bs,empty:()=>Ts,escapeRegexChar:()=>Dr,exhaustMap:()=>Ws,exponential:()=>Mn,externalBundle:()=>Dn,externalProducer:()=>st,fallback:()=>$n,fibonacci:()=>An,filter:()=>Ht,find:()=>Ls,first:()=>qn,firstValueFrom:()=>Un,firstWhere:()=>jn,flatMap:()=>qs,forEach:()=>Je,fromAny:()=>ae,fromAsyncIter:()=>Ir,fromCSV:()=>Li,fromClickHouseWatch:()=>Fi,fromCron:()=>gs,fromDrizzle:()=>ia,fromEvent:()=>ys,fromHTTP:()=>Wr,fromHTTPPoll:()=>Ti,fromHTTPStream:()=>vi,fromIter:()=>Hn,fromKafka:()=>Ci,fromKysely:()=>aa,fromMCP:()=>ki,fromNATS:()=>zi,fromNDJSON:()=>Vi,fromOTel:()=>_i,fromPrisma:()=>sa,fromPrometheus:()=>Mi,fromPromise:()=>Pr,fromPulsar:()=>$i,fromRabbitMQ:()=>Hi,fromRaf:()=>ms,fromRedisStream:()=>Pi,fromSSE:()=>bi,fromSqlite:()=>na,fromSqliteCursor:()=>ra,fromStatsD:()=>Ei,fromSyslog:()=>Ni,fromTimer:()=>qe,fromWebSocket:()=>Hr,fromWebSocketReconnect:()=>xi,fromWebhook:()=>pi,globToRegExp:()=>fs,interval:()=>oi,jsonCodec:()=>Rt,jsonCodecFor:()=>Ra,keepalive:()=>Ye,kvStorage:()=>rr,last:()=>Is,linear:()=>Rn,lru:()=>Zr,makeHttpError:()=>ma,map:()=>jt,matchesAnyPattern:()=>ps,matchesCron:()=>Ln,memoryAppendLog:()=>Aa,memoryBackend:()=>tn,memoryKv:()=>Ca,memorySnapshot:()=>Ma,merge:()=>_t,mergeMap:()=>$r,mergeReactiveLogs:()=>_a,nameToSignal:()=>pt,ndjsonRows:()=>Gi,never:()=>ws,nodeSignal:()=>Os,of:()=>Lr,onFirstData:()=>Vr,pairwise:()=>$s,parseCron:()=>In,parsePrometheusText:()=>Yr,parseSSEStream:()=>Jr,parseStatsD:()=>Ri,parseSyslog:()=>Si,pausable:()=>ii,pubsub:()=>ya,race:()=>Hs,rateLimiter:()=>Fn,reactiveCounter:()=>Ms,reactiveIndex:()=>Ta,reactiveList:()=>wa,reactiveLog:()=>ka,reactiveMap:()=>Qn,reactiveSink:()=>ue,reduce:()=>Cs,repeat:()=>si,replay:()=>Wn,rescue:()=>jr,resolveBackoffPreset:()=>We,retry:()=>xt,sample:()=>Ys,scan:()=>As,serializeError:()=>ht,share:()=>Ns,shareReplay:()=>Rs,signalToName:()=>Xe,singleFromAny:()=>Na,singleNodeFromAny:()=>Sa,skip:()=>Gr,snapshotStorage:()=>nr,sortJsonValue:()=>en,stableJsonString:()=>tr,stratify:()=>Mu,switchMap:()=>Le,take:()=>Wt,takeUntil:()=>Ps,takeWhile:()=>Ds,tap:()=>Gs,tapFirst:()=>Vs,throttle:()=>zr,throttleTime:()=>ci,throwError:()=>xs,timeout:()=>Kn,toArray:()=>_s,toCSV:()=>Ui,toClickHouse:()=>qi,toFile:()=>Xr,toHTTP:()=>hi,toKafka:()=>Di,toLoki:()=>Xi,toMongo:()=>Qi,toNATS:()=>ji,toObservable:()=>ga,toPostgres:()=>Yi,toPulsar:()=>Ki,toRabbitMQ:()=>Wi,toReadableStream:()=>yi,toRedisStream:()=>Ii,toS3:()=>Ji,toSSE:()=>mi,toSSEBytes:()=>gi,toSqlite:()=>oa,toTempo:()=>Zi,toWebSocket:()=>wi,tokenBucket:()=>Kt,topologyDiff:()=>Et,valve:()=>ai,verifiable:()=>fa,window:()=>ri,windowCount:()=>ei,windowTime:()=>ni,withBreaker:()=>Vn,withLatestFrom:()=>Ks,withMaxAttempts:()=>Sr,withStatus:()=>kt,workerBridge:()=>Bo,workerSelf:()=>Go,zip:()=>zs});module.exports=zo(Lu);Te();Pe();te();ye();ce();Te();te();ce();function Or(t){return{describeKind:"producer",...t}}function st(t,e){return A(n=>{let r=!0,s={emit(i){r&&n.emit(i)},error(i){r&&(r=!1,n.down([[E,i]]))},complete(){r&&(r=!1,n.down([[S]]))}},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{}}},Or(e))}function Dn(t,e,n){let r=!0,s,o=0,i=0,a={},d=[],u=()=>{let p=s;s=void 0;try{p?.()}catch{}};for(let p of e){let h=n?.name?`${n.name}::${p}`:p,g=n?.channelOpts?.[p],m=A(y=>(o++,()=>{i++,o>0&&i>=o&&i>=e.length&&u()}),Or({...g,name:h}));a[p]=m,d.push(m)}let c={};for(let p of e)c[p]=h=>{r&&a[p].down([[k,h]])};c.error=p=>{r&&(r=!1,H(()=>{for(let h of d)h.down([[E,p]])}),u())},c.complete=()=>{r&&(r=!1,H(()=>{for(let p of d)p.down([[S]])}),u())};let l=t(c);return s=typeof l=="function"?l:void 0,Object.assign(a,{dispose:()=>{r&&(r=!1,H(()=>{for(let p of d)try{p.down([[S]])}catch{}}),u())}})}Pe();te();Tt();ye();ce();De();function F(t){return{describeKind:"derived",...t}}function Br(t){return{describeKind:"derived",partial:!0,...t}}function jt(t,e,n){return G([t],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[D]]);return}for(let i of o)s.emit(e(i))},{...F(n),meta:{...q("map"),...n?.meta??{}}})}function Ht(t,e,n){return G([t],(r,s)=>{let o=r[0];if(o==null||o.length===0){s.down([[D]]);return}let i=!1;for(let a of o)e(a)&&(s.emit(a),i=!0);i||s.down([[D]])},{...F(n),meta:{...q("filter"),...n?.meta??{}}})}function As(t,e,n,r){return G([t],(s,o,i)=>{"acc"in i.store||(i.store.acc=n);let a=s[0];if(a==null||a.length===0){o.down([[D]]);return}for(let d of a)i.store.acc=e(i.store.acc,d),o.emit(i.store.acc)},{...F(r),initial:n,resetOnTeardown:!0,meta:{...q("scan",{initial:n}),...r?.meta??{}}})}function Cs(t,e,n,r){return G([t],(s,o,i)=>{if("acc"in i.store||(i.store.acc=n),i.terminalDeps[0]===!0){o.emit(i.store.acc),o.down([[S]]);return}let a=s[0];if(a==null||a.length===0){o.down([[D]]);return}for(let d of a)i.store.acc=e(i.store.acc,d)},{...F(r),completeWhenDepsComplete:!1,meta:{...q("reduce",{initial:n}),...r?.meta??{}}})}function Wt(t,e,n){return e<=0?G([t],(r,s,o)=>{o.store.completed||(o.store.completed=!0,s.down([[S]]))},{...F(n),completeWhenDepsComplete:!1,meta:{...q("take",{count:e}),...n?.meta??{}}}):G([t],(r,s,o)=>{if("taken"in o.store||(o.store.taken=0),o.store.done){s.down([[D]]);return}if(o.terminalDeps[0]===!0){o.store.done=!0,s.down([[S]]);return}let i=r[0];if(i==null||i.length===0){s.down([[D]]);return}for(let a of i)if(o.store.taken++,s.emit(a),o.store.taken>=e){o.store.done=!0,s.down([[S]]);return}},{...F(n),completeWhenDepsComplete:!1,meta:{...q("take",{count:e}),...n?.meta??{}}})}function Gr(t,e,n){return G([t],(r,s,o)=>{"skipped"in o.store||(o.store.skipped=0);let i=r[0];if(i==null||i.length===0){s.down([[D]]);return}let a=!1;for(let d of i)o.store.skipped++,o.store.skipped<=e||(s.emit(d),a=!0);a||s.down([[D]])},F(n))}function Ds(t,e,n){return G([t],(r,s,o)=>{if(o.store.done){s.down([[D]]);return}let i=r[0];if(i==null||i.length===0){s.down([[D]]);return}for(let a of i){if(!e(a)){o.store.done=!0,s.down([[S]]);return}s.emit(a)}},{...F(n),completeWhenDepsComplete:!1})}function Ps(t,e,n){let r=n?.predicate??(i=>i[0]===k),{predicate:s,...o}=n??{};return A(i=>{let a=!1,d=t.subscribe(c=>{if(!a)for(let l of c){if(a)return;l[0]===k?i.emit(l[1]):(l[0]===S||l[0]===E)&&(a=!0,i.down([l]))}}),u=e.subscribe(c=>{if(!a)for(let l of c){if(a)return;if(r(l)){a=!0,i.down([[S]]);return}}});return()=>{d(),u()}},F(o))}function qn(t,e){return Wt(t,1,e)}function Is(t,e){let{defaultValue:n,...r}=e??{},s=e!=null&&Object.hasOwn(e,"defaultValue");return G([t],(o,i,a)=>{if(a.terminalDeps[0]===!0){a.store.has?i.emit(a.store.latest):s&&i.emit(n),i.down([[S]]);return}let d=o[0];if(d==null||d.length===0){i.down([[D]]);return}a.store.latest=d.at(-1),a.store.has=!0},{...F(r),completeWhenDepsComplete:!1})}function Ls(t,e,n){return Wt(Ht(t,e,n),1,n)}function Bs(t,e,n){return Wt(Gr(t,e,n),1,n)}function Gs(t,e,n){if(typeof e=="function")return G([t],(s,o)=>{let i=s[0];if(i==null||i.length===0){o.down([[D]]);return}for(let a of i)e(a),o.emit(a)},{...F(n),meta:{...q("tap"),...n?.meta??{}}});let r=e;return G([t],(s,o,i)=>{if(i.terminalDeps[0]!==void 0){i.terminalDeps[0]===!0?(r.complete?.(),o.down([[S]])):(r.error?.(i.terminalDeps[0]),o.down([[E,i.terminalDeps[0]]]));return}let a=s[0];if(a==null||a.length===0){o.down([[D]]);return}for(let d of a)r.data?.(d),o.emit(d)},{...F(n),completeWhenDepsComplete:!1,meta:{...q("tap"),...n?.meta??{}}})}function Vr(t,e,n){let r=n?.where??(o=>o!=null),s=!1;return G([t],(o,i)=>{let a=o[0];if(a==null||a.length===0){i.down([[D]]);return}for(let d of a)!s&&r(d)&&(s=!0,e(d)),i.emit(d)},F(n))}var Vs=Vr;function Fs(t,e=Object.is,n){return G([t],(r,s,o)=>{let i=r[0];if(i==null||i.length===0){s.down([[D]]);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([[D]])},{...F(n),meta:{...q("distinctUntilChanged"),...n?.meta??{}}})}function $s(t,e){return G([t],(n,r,s)=>{let o=n[0];if(o==null||o.length===0){r.down([[D]]);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([[D]])},F(e))}function Fr(...t){let e=[...t];return he(e,n=>n,{...F(),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 Ks(t,e,n){return G([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([[D]]);return}for(let u of i)s.emit([u,d])}else s.down([[D]])},{...Br(n),meta:{...q("withLatestFrom"),...n?.meta??{}}})}function _t(...t){return t.length===0?A(e=>{e.down([[S]])},{...F(),meta:{...q("merge")}}):A(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]===k?e.emit(d[1]):d[0]===S?(r+=1,r>=n&&e.down([[S]])):d[0]===E&&e.down([d])});s.push(i)}return()=>{for(let o of s)o()}},{...F(),meta:{...q("merge")}})}function zs(...t){let e=t.length;return e===0?A(n=>{n.emit([]),n.down([[S]])},F()):A(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 l of c)l[0]===k?(r[d].push(l[1]),o()):l[0]===S?(s-=1,(s===0||r[d].length===0)&&n.down([[S]])):l[0]===E&&n.down([l])});i.push(u)}return()=>{for(let a of i)a()}},F())}function js(t,e,n){return A(r=>{let s=0,o=[],i,a;return a=e.subscribe(d=>{for(let u of d)s===0?u[0]===k?o.push(u[1]):u[0]===E&&r.down([u]):u[0]===k?r.emit(u[1]):(u[0]===S||u[0]===E)&&r.down([u])}),i=t.subscribe(d=>{for(let u of d)if(s===0)if(u[0]===k)r.emit(u[1]);else if(u[0]===S){s=1;for(let c of o)r.emit(c);o.length=0}else u[0]===E&&r.down([u])}),()=>{i?.(),a?.()}},F(n))}function Hs(...t){return t.length===0?A(e=>{e.down([[S]])},F()):t.length===1?G([t[0]],(e,n)=>{let r=e[0];if(r==null||r.length===0){n.down([[D]]);return}for(let s of r)n.emit(s)},F()):A(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]===k?(n===null&&(n=o),e.emit(d[1])):(d[0]===S||d[0]===E)&&(n===null||o===n)&&e.down([d])}});r.push(i)}return()=>{for(let s of r)s()}},F())}function Ut(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]!==Ie&&(u[0]===k?e.emit(u[1]):u[0]===S?a=!0:u[0]===E?(d=!0,e.down([u])):(u[0]===$||u[0]===D)&&e.down([u]));d?(r?.(),r=void 0,o()):a&&o()}),()=>{r?.(),r=void 0}}function Le(t,e,n){let r,s=!1;function o(){r?.(),r=void 0}return G([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([[S]]);return}let u=i[0];if(!(u==null||u.length===0))return o(),r=Ut(ae(e(u[u.length-1])),a,()=>{o(),s&&a.down([[S]])}),{deactivate:()=>{o(),s=!1}}},{...F(n),completeWhenDepsComplete:!1,meta:{...q("switchMap"),...n?.meta??{}}})}function Ws(t,e,n){let r,s=!1;function o(){r?.(),r=void 0}return G([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([[S]]);return}let u=i[0];if(!(u==null||u.length===0))return r===void 0?r=Ut(ae(e(u[0])),a,()=>{o(),s&&a.down([[S]])}):a.down([[D]]),{deactivate:()=>{o(),s=!1}}},{...F(n),completeWhenDepsComplete:!1})}function Us(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([[S]]);return}let f=o.shift();i=Ut(ae(e(f)),d,()=>{u(),c()})}function l(f){r&&r>0&&o.length>=r&&o.shift(),o.push(f),c()}return G([t],(f,p,h)=>{if(d=p,h.terminalDeps[0]!=null&&h.terminalDeps[0]!==!0){u(),o.length=0;return}if(h.terminalDeps[0]===!0){a=!0,c();return}let g=f[0];if(!(g==null||g.length===0)){for(let m of g)l(m);return{deactivate:()=>{u(),o.length=0,a=!1}}}},{...F(s),completeWhenDepsComplete:!1})}function $r(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 l(){a&&i===0&&u.length===0&&c&&c.down([[S]])}function f(m){if(!c)return;i++;let y;y=Ut(ae(e(m)),c,()=>{y&&d.delete(y),i--,p(),l()}),d.add(y)}function p(){for(;u.length>0&&i<o;)f(u.shift())}function h(m){i<o?f(m):u.push(m)}function g(){for(let m of d)m();d.clear(),i=0,u.length=0}return G([t],(m,y,b)=>{if(c=y,b.terminalDeps[0]!=null&&b.terminalDeps[0]!==!0){g();return}if(b.terminalDeps[0]===!0){a=!0,l();return}let v=m[0];if(!(v==null||v.length===0)){for(let w of v)h(w);return{deactivate:()=>{g(),a=!1}}}},{...F(s),completeWhenDepsComplete:!1})}var qs=$r;function Js(t,e,n){return A(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]===k){let u=setTimeout(()=>{s.delete(u),r.emit(d[1])},e);s.add(u)}else if(d[0]===S){let u=setTimeout(()=>{s.delete(u),r.down([[S]])},e);s.add(u)}else d[0]===E&&(o(),r.down([d]))});return()=>{i(),o()}},F(n))}function Kr(t,e,n){return A(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]===k?(i(),o=u[1],s=setTimeout(()=>{s=void 0,r.emit(o)},e)):u[0]===S?(s!==void 0&&(i(),r.emit(o)),r.down([[S]])):u[0]===E&&(i(),r.down([u]))});return()=>{a(),i()}},{...F(n),meta:{...q("debounce",{ms:e}),...n?.meta??{}}})}function zr(t,e,n){let{leading:r,trailing:s,...o}=n??{},i=r!==!1,a=s===!0,d=e*1e6;return A(u=>{let c,l=-1/0,f,p=!1;function h(){c!==void 0&&(clearTimeout(c),c=void 0)}let g=t.subscribe(m=>{for(let y of m)if(y[0]===k){let b=y[1],v=ee();if(i&&v-l>=d)l=v,u.emit(b),h(),a&&(c=setTimeout(()=>{c=void 0,p&&(l=ee(),u.emit(f),p=!1)},e));else if(a&&(f=b,p=!0,c===void 0)){let w=(v-l)/1e6;c=setTimeout(()=>{c=void 0,p&&(l=ee(),u.emit(f),p=!1)},Math.max(0,e-w))}}else(y[0]===S||y[0]===E)&&(h(),u.down([y]))});return()=>{g(),h()}},{...F(o),meta:{...q("throttle",{ms:e,leading:i,trailing:a}),...o.meta??{}}})}function Ys(t,e,n){return A(r=>{let s,o=!1,i=!1,a=t.subscribe(u=>{if(!o)for(let c of u){if(o)return;c[0]===k?s={v:c[1]}:c[0]===E?(o=!0,r.down([c])):c[0]===S&&(i=!0,s=void 0)}}),d=e.subscribe(u=>{if(!o)for(let c of u){if(o)return;c[0]===k?s!==void 0&&!i&&r.emit(s.v):c[0]===E?(o=!0,r.down([c])):c[0]===S&&(o=!0,r.down([[S]]))}});return()=>{a(),d()}},F(n))}function Qs(t,e,n){return A(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]===k?(o=c[1],i=!0,a(),s=setTimeout(()=>{s=void 0,i&&(i=!1,r.emit(o))},e)):(c[0]===S||c[0]===E)&&(a(),r.down([c]))});return()=>{d(),a()}},F(n))}function Xs(t,e,n){return A(r=>{let s=[],o=t.subscribe(a=>{for(let d of a)d[0]===k?s.push(d[1]):d[0]===S?(s.length>0&&r.emit([...s]),s.length=0,r.down([[S]])):d[0]===E&&r.down([d])}),i=e.subscribe(a=>{for(let d of a)d[0]===k?s.length>0&&(r.emit([...s]),s.length=0):d[0]===S?r.down([[S]]):d[0]===E&&r.down([d])});return()=>{o(),i(),s.length=0}},F(n))}function Zs(t,e,n){if(e<=0)throw new RangeError("bufferCount expects count > 0");return A(r=>{let s=[],o=t.subscribe(i=>{for(let a of i)a[0]===k?(s.push(a[1]),s.length>=e&&r.emit(s.splice(0,s.length))):a[0]===S?(s.length>0&&r.emit([...s]),s.length=0,r.down([[S]])):a[0]===E&&r.down([a])});return()=>{o(),s.length=0}},F(n))}function ei(t,e,n){if(e<=0)throw new RangeError("windowCount expects count > 0");return A(r=>{let s,o=0;function i(){let d=A(u=>(s=u.down.bind(u),()=>{s=void 0}),F());o=0,r.emit(d)}let a=t.subscribe(d=>{for(let u of d)u[0]===k?(s||i(),s?.([[k,u[1]]]),o+=1,o>=e&&(s?.([[S]]),s=void 0)):u[0]===S?(s?.([[S]]),s=void 0,r.down([[S]])):u[0]===E&&(s?.([u]),s=void 0,r.down([u]))});return()=>{a(),s?.([[S]]),s=void 0}},F(n))}function ti(t,e,n){return A(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]===k?s.push(d[1]):d[0]===S?(clearInterval(o),s.length>0&&r.emit([...s]),s.length=0,r.down([[S]])):d[0]===E&&(clearInterval(o),r.down([d]))});return()=>{i(),clearInterval(o),s.length=0}},{...F(n),meta:{...q("bufferTime",{ms:e}),...n?.meta??{}}})}function ni(t,e,n){return A(r=>{let s;function o(){s?.([[S]]),s=void 0}function i(){let u=A(c=>(s=c.down.bind(c),()=>{s=void 0}),F());r.emit(u)}i();let a=setInterval(()=>{o(),i()},e),d=t.subscribe(u=>{for(let c of u)c[0]===k?s?.([[k,c[1]]]):c[0]===S?(clearInterval(a),o(),r.down([[S]])):c[0]===E&&(clearInterval(a),s?.([c]),o(),r.down([c]))});return()=>{d(),clearInterval(a),o()}},F(n))}function ri(t,e,n){return A(r=>{let s;function o(){s?.([[S]]),s=void 0}function i(){let u=A(c=>(s=c.down.bind(c),()=>{s=void 0}),F());r.emit(u)}let a=t.subscribe(u=>{for(let c of u)c[0]===k?(s||i(),s?.([[k,c[1]]])):c[0]===S?(o(),r.down([[S]])):c[0]===E&&(s?.([c]),s=void 0,r.down([c]))}),d=e.subscribe(u=>{for(let c of u)c[0]===k&&(o(),i())});return()=>{a(),d(),o()}},F(n))}function oi(t,e){return A((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)},F(e))}function si(t,e,n){if(e<=0)throw new RangeError("repeat expects count > 0");return A(r=>{let s=e,o,i=()=>{o?.(),o=t.subscribe(a=>{let d=!1,u=[];for(let c of a)c[0]===S?d=!0:u.push(c);u.length>0&&r.down(u),d&&(o?.(),o=void 0,s-=1,s>0?i():r.down([[S]]))})};return i(),()=>{o?.()}},F(n))}function ii(t,e){return G([t],(n,r)=>{let s=n[0];if(s==null||s.length===0){r.down([[D]]);return}for(let o of s)r.emit(o)},F(e))}function jr(t,e,n){return A(r=>{let s=t.subscribe(o=>{for(let i of o)if(i[0]===k)r.emit(i[1]);else if(i[0]===E)try{r.emit(e(i[1]))}catch(a){r.down([[E,a]])}else i[0]===S&&r.down([[S]])});return()=>{s()}},F(n))}function ai(t,e,n){return G([t,e],(r,s,o)=>{let i=r[1];if(!(i!=null&&i.length>0?i.at(-1):o.prevData[1])){s.down([[D]]);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([[D]])},Br(n))}var ui=Fr,di=Kr,ci=zr,li=jr;te();ye();ce();vt();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 Jn=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 Nt(t){return t instanceof Error?t:new Error(String(t))}function fi(t){return t===void 0?null:typeof t=="string"?We(t):t}function ue(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:l,send:f,sendBatch:p,ctx:h}=e;if(!f&&!p)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let g=h,m=Math.max(1,s?.maxAttempts??1),y=fi(s?.backoff??(m>1?"exponential":void 0)),b=s?.shouldRetry??(()=>!0),v=p!==void 0||i<Number.POSITIVE_INFINITY||a>0,w=L=>n?`${n}::${L}`:void 0,_=V(void 0,{equals:()=>!1,name:w("sent")}),x=V(null,{name:w("failed")}),T=V(0,{name:w("inFlight")}),N=V(null,{name:w("errors")}),R=v?V(0,{name:w("buffered")}):void 0,M=o?V(!1,{name:w("paused")}):void 0,C=0,I=L=>{C+=L,T.down([[k,C]])},O=L=>{try{r?.(L)}catch{}try{N.down([[k,L]])}catch{}},P=new Set,X=L=>{P.add(L);let W=()=>P.delete(L);L.then(W,W)},K=(L,W,J)=>{let Z=y?y(W-1,J,null):0,de=Z==null?0:typeof Z=="number"&&Z>0?Z:0,Oe=Math.max(1,Math.ceil(de/1e6));return new Promise(Y=>{setTimeout(()=>Y(L()),Oe)})},re=L=>L!=null&&typeof L=="object"&&typeof L.then=="function",Ne=L=>{let W;try{W=d?d(L):L}catch(Y){let U=Nt(Y);return O({stage:"serialize",error:U,value:L}),x.down([[k,{value:L,error:U,attempts:0}]]),Promise.resolve()}let J=0,Z=Y=>{I(-1);let U=Nt(Y);if(O({stage:"send",error:U,value:L,attempt:J}),!(J<m&&b(U,J))){x.down([[k,{value:L,error:U,attempts:J}]]);return}return K(Oe,J,U)},de=()=>{I(-1),_.down([[k,L]])};function Oe(){J+=1,I(1);let Y;try{Y=f(W,g)}catch(U){return Z(U)??Promise.resolve()}return re(Y)?Y.then(de,U=>Z(U)):(de(),Promise.resolve())}return Oe()},Be=o?.maxBuffer??Number.POSITIVE_INFINITY,Se=new Jn(Be),ke,Ge=!1,Ve=()=>{R?.down([[k,Se.length]])},$e=L=>{M&&M.down([[k,L]])},B=o?.strategy??"drop-oldest",Q=(L,W)=>{let J={value:L,payload:W};if(Se.length<Be)return Se.push(J),Ve(),!0;if(B==="drop-oldest"){let de=Se.shift();return Se.push(J),Ve(),$e(!0),x.down([[k,{value:de.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(B==="drop-newest")return $e(!0),x.down([[k,{value:L,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let Z=new Error("backpressure: buffer overflow");return O({stage:"send",error:Z,value:L}),x.down([[k,{value:L,error:Z,attempts:0}]]),$e(!0),!1},be=L=>{let W=0,J=L.map(Y=>Y.payload),Z=Y=>{I(-1);let U=Nt(Y);if(O({stage:"send",error:U,value:L.map(fn=>fn.value),attempt:W}),!(W<m&&b(U,W))){for(let{value:fn}of L)x.down([[k,{value:fn,error:U,attempts:W}]]);return}return K(Oe,W,U)},de=()=>{I(-1);for(let{value:Y}of L)_.down([[k,Y]])};function Oe(){W+=1,I(1);let Y;try{Y=p(J,g)}catch(U){return Z(U)??Promise.resolve()}return re(Y)?Y.then(de,U=>Z(U)):(de(),Promise.resolve())}return Oe()},Ke=async L=>{for(let W of L)await ve(W.value,W.payload)},ve=(L,W)=>{let J=0,Z=Y=>{I(-1);let U=Nt(Y);if(O({stage:"send",error:U,value:L,attempt:J}),!(J<m&&b(U,J))){x.down([[k,{value:L,error:U,attempts:J}]]);return}return K(Oe,J,U)},de=()=>{I(-1),_.down([[k,L]])};function Oe(){J+=1,I(1);let Y;try{Y=f(W,g)}catch(U){return Z(U)??Promise.resolve()}return re(Y)?Y.then(de,U=>Z(U)):(de(),Promise.resolve())}return Oe()},j=()=>{if(Ge||Se.length===0)return Promise.resolve();let L=Se.drain();if(Ve(),$e(!1),p!==void 0){let J=be(L);return X(J),J}let W=Ke(L);return X(W),W},le=()=>{ke!==void 0||Ge||a<=0||(ke=setTimeout(()=>{ke=void 0,j()},a))},gt=t.subscribe(L=>{for(let W of L){let J=W[0];if(J!==k)try{c?.(W)}catch{}if(J===k){let Z=W[1];if(v){let de;if(d)try{de=d(Z)}catch(Y){let U=Nt(Y);O({stage:"serialize",error:U,value:Z}),x.down([[k,{value:Z,error:U,attempts:0}]]);continue}else de=Z;if(!Q(Z,de))continue;Se.length>=i?j():le()}else{let de=Ne(Z);X(de)}}else pe.messageTier(J)>=3&&v&&(ke!==void 0&&(clearTimeout(ke),ke=void 0),j())}}),ar;if(u){let L=!1;ar=u.subscribe(W=>{if(!L){L=!0;return}W.length>0&&!ln&&ur()})}let ln=!1,ur=()=>{if(ln)return;ln=!0,ke!==void 0&&(clearTimeout(ke),ke=void 0),v&&j(),Ge=!0,ar?.(),gt();let L=W=>{try{W.down([[z]])}catch{}};L(N),L(x),L(_),L(T),R&&L(R),M&&L(M);try{l?.()}catch{}},At={dispose:ur,sent:_,failed:x,inFlight:T,errors:N};return v&&(At.buffered=R,At.flush=async()=>{Ge||(await j(),await Promise.all(P))}),M&&(At.paused=M),At}zt();De();function Me(t){return{describeKind:"producer",...t}}function Hr(t,e){let{parse:n,closeOnTeardown:r=!1,...s}=e??{};return A(o=>{let i=!0,a,d=()=>{let y=a;a=void 0,y?.()},u=y=>{i&&(i=!1,o.down([y]),d())},c=(y,b=y)=>{if(i)try{let v=y!==null&&typeof y=="object"&&"data"in y?y.data:y,w=n?n(v,b):v;o.emit(w)}catch(v){u([E,v])}},l=y=>{u([E,y])},f=()=>{u([S])};if(typeof t=="function"){try{if(a=t(c,l,f),typeof a!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(y){u([E,y])}return()=>{i=!1,d()}}let p=t,h=y=>c(y,y),g=y=>l(y),m=()=>f();return p.addEventListener("message",h),p.addEventListener("error",g),p.addEventListener("close",m),a=()=>{p.removeEventListener("message",h),p.removeEventListener("error",g),p.removeEventListener("close",m),r&&p.close()},()=>{i=!1,d()}},Me(s))}function pi(t,e){return st(t,e)}function Wr(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??{},l=V(0,{name:`${c.name??"http"}/fetchCount`}),f=V(0,{name:`${c.name??"http"}/lastUpdated`}),p=V(!1,{name:`${c.name??"http"}/fetched`}),h=0,g=s!==void 0?typeof s=="string"?s:JSON.stringify(s):void 0,m=v=>{let w=new AbortController,_=!0;if(a?.aborted)return _=!1,v.down([[E,a.reason??new Error("Aborted")]]),()=>{};a?.addEventListener("abort",()=>w.abort(a.reason),{once:!0});let x=setTimeout(()=>w.abort(new Error("Request timeout")),Math.ceil(i/1e6));return fetch(t,{method:n,headers:r,body:g,signal:w.signal}).then(async T=>{if(clearTimeout(x),!_)return;if(!T.ok)throw new Error(`HTTP ${T.status}: ${T.statusText}`);let N=await o(T);_&&(H(()=>{h+=1,l.down([[k,h]]),f.down([[k,oe()]]),p.down([[k,!0]]),v.emit(N)}),d&&v.down([[S]]))}).catch(T=>{clearTimeout(x),_&&(T&&T.name==="AbortError"||v.down([[E,T]]))}),()=>{_=!1,w.abort()}},y=A(v=>m({emit:w=>v.emit(w),down:w=>v.down(w)}),{...Me(c),resubscribable:u});return{...kt(y),fetchCount:l,lastUpdated:f,fetched:p}}function hi(t,e,n){let{method:r="POST",headers:s={"Content-Type":"application/json"},serialize:o=h=>JSON.stringify(h),timeoutNs:i,batchFormat:a="json-array",batchSize:d,flushIntervalMs:u,retry:c,onTransportError:l}=n??{},f=async h=>{let g=i!==void 0?new AbortController:void 0,m;g&&i!==void 0&&(m=setTimeout(()=>g.abort(new Error("Request timeout")),Math.ceil(i/1e6)));try{let y=await fetch(e,{method:r,headers:s,body:h,signal:g?.signal}),b=async()=>{try{await y.arrayBuffer?.()}catch{}};if(!y.ok)throw await b(),new Error(`HTTP ${y.status}: ${y.statusText}`);await b()}finally{m!==void 0&&clearTimeout(m)}};return d!==void 0||u!==void 0?ue(t,{onTransportError:l,retry:c,batchSize:d,flushIntervalMs:u,sendBatch:async h=>{let g;a==="ndjson"?g=h.map(m=>{let y=o(m);return typeof y=="string"?y:new TextDecoder().decode(y)}).join(`
2
+ `):g=JSON.stringify(h),await f(g)}}):ue(t,{onTransportError:l,retry:c,serialize:o,send:async h=>{await f(h)}})}function Ur(t){return Symbol.keyFor(t)??t.description??"message"}function dt(t,e){return typeof t=="string"?t:e(t)}function qr(t,e){let n=`event: ${t}
3
3
  `;if(e!==void 0){let r=e.split(/\r?\n/);for(let s of r)n+=`data: ${s}
4
4
  `}return`${n}
5
- `}function ii(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=Fr}=e??{},l=new TextEncoder,f;return new ReadableStream({start(p){let h=!1,m,b=()=>{},g=()=>{h||(h=!0,m!==void 0&&clearInterval(m),u?.removeEventListener("abort",v),b(),p.close())};f=g;let y=(w,_)=>{h||p.enqueue(l.encode($r(w,_)))},v=()=>{h||g()};b=t.subscribe(w=>{for(let _ of w){let k=_[0];if(!(le.isLocalOnly(k)&&!(k===$&&a))){if(k===x){y(r,it(_[1],n));continue}if(k===E){y(s,it(_[1],n)),g();return}if(k===N){y(o),g();return}!i&&k===P||y(c(k),_.length>1?it(_[1],n):void 0)}}}),d!==void 0&&d>0&&(m=setInterval(()=>{h||p.enqueue(l.encode(`: keepalive
5
+ `}function mi(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=Ur}=e??{},l=new TextEncoder,f;return new ReadableStream({start(p){let h=!1,g,m=()=>{},y=()=>{h||(h=!0,g!==void 0&&clearInterval(g),u?.removeEventListener("abort",v),m(),p.close())};f=y;let b=(w,_)=>{h||p.enqueue(l.encode(qr(w,_)))},v=()=>{h||y()};m=t.subscribe(w=>{for(let _ of w){let x=_[0];if(!(pe.isLocalOnly(x)&&!(x===$&&a))){if(x===k){b(r,dt(_[1],n));continue}if(x===E){b(s,dt(_[1],n)),y();return}if(x===S){b(o),y();return}!i&&x===D||b(c(x),_.length>1?dt(_[1],n):void 0)}}}),d!==void 0&&d>0&&(g=setInterval(()=>{h||p.enqueue(l.encode(`: keepalive
6
6
 
7
- `))},d)),u?.aborted?v():u?.addEventListener("abort",v,{once:!0})},cancel(){f?.()}})}function ai(t,e){let{serialize:n=f=>{if(f instanceof Error)return f.message;try{return JSON.stringify(f)}catch{return String(f)}},dataEvent:r="data",errorEvent:s="error",completeEvent:o="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:d,signal:u,eventNameResolver:c=Fr}=e??{},l=new TextEncoder;return A(f=>{let p=!0,h,m=(y,v)=>{p&&f.emit(l.encode($r(y,v)))},b=()=>{p&&(p=!1,f.down([[N]]))},g=t.subscribe(y=>{if(p)for(let v of y){let w=v[0];if(!(le.isLocalOnly(w)&&!(w===$&&a))){if(w===x){m(r,it(v[1],n));continue}if(w===E){m(s,it(v[1],n)),p=!1,f.down([[N]]);return}if(w===N){m(o),p=!1,f.down([[N]]);return}!i&&w===P||m(c(w),v.length>1?it(v[1],n):void 0)}}});return d!==void 0&&d>0&&(h=setInterval(()=>{p&&f.emit(l.encode(`: keepalive
7
+ `))},d)),u?.aborted?v():u?.addEventListener("abort",v,{once:!0})},cancel(){f?.()}})}function gi(t,e){let{serialize:n=f=>{if(f instanceof Error)return f.message;try{return JSON.stringify(f)}catch{return String(f)}},dataEvent:r="data",errorEvent:s="error",completeEvent:o="complete",includeResolved:i=!1,includeDirty:a=!1,keepAliveMs:d,signal:u,eventNameResolver:c=Ur}=e??{},l=new TextEncoder;return A(f=>{let p=!0,h,g=(b,v)=>{p&&f.emit(l.encode(qr(b,v)))},m=()=>{p&&(p=!1,f.down([[S]]))},y=t.subscribe(b=>{if(p)for(let v of b){let w=v[0];if(!(pe.isLocalOnly(w)&&!(w===$&&a))){if(w===k){g(r,dt(v[1],n));continue}if(w===E){g(s,dt(v[1],n)),p=!1,f.down([[S]]);return}if(w===S){g(o),p=!1,f.down([[S]]);return}!i&&w===D||g(c(w),v.length>1?dt(v[1],n):void 0)}}});return d!==void 0&&d>0&&(h=setInterval(()=>{p&&f.emit(l.encode(`: keepalive
8
8
 
9
- `))},d)),u?.aborted?b():u?.addEventListener("abort",b,{once:!0}),()=>{p=!1,h!==void 0&&clearInterval(h),u?.removeEventListener("abort",b),g()}})}function ui(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===x)try{r.enqueue(o[1])}catch{n=!0,e?.()}else if(i===E){n=!0;try{r.error(o[1])}catch{}return}else if(i===N){n=!0;try{r.close()}catch{}return}}})},cancel(){n=!0,e?.()}})}async function*Kr(t,e){let n=e?.parse??(_=>_),r=e?.signal,s=new TextDecoder,o="",i="message",a=[],d,u,c=[],l=()=>{if(a.length===0&&i==="message"&&d===void 0){a=[];return}let _=a.join(`
10
- `);c.push({event:i,data:n(_),id:d,retry:u}),i="message",a=[],d=void 0,u=void 0},f=_=>{if(_===""){l();return}if(_.startsWith(":"))return;let k=_.indexOf(":"),T=k<0?_:_.slice(0,k),S=k<0?"":_.slice(k+1);switch(S.startsWith(" ")&&(S=S.slice(1)),T){case"event":i=S;break;case"data":a.push(S);break;case"id":S.includes("\0")||(d=S);break;case"retry":{let O=Number(S);Number.isFinite(O)&&(u=O);break}}},p=(_,k)=>{o+=s.decode(_,{stream:!k});let T=o.split(/\r?\n/);o=T.pop()??"";for(let S of T)f(S)},h=t,m=t instanceof ReadableStream?t:h&&typeof h=="object"&&h.body instanceof ReadableStream?h.body:null,b,g,y=!1,v=()=>{y||(y=!0,b&&b.cancel().catch(()=>{}),g&&typeof g.return=="function"&&Promise.resolve(g.return()).catch(()=>{}))},w=()=>{v()};if(r){if(r.aborted)return;r.addEventListener("abort",w,{once:!0})}try{if(m){for(b=m.getReader();!r?.aborted;){let{value:_,done:k}=await b.read();if(k)break;for(p(_,!1);c.length>0;)yield c.shift()}p(new Uint8Array,!0)}else{for(g=t[Symbol.asyncIterator]();!r?.aborted;){let k=await g.next();if(k.done)break;for(p(k.value,!1);c.length>0;)yield c.shift()}p(new Uint8Array,!0)}if(o.trim()){for(let _ of o.split(/\r?\n/))f(_);l()}for(;c.length>0;)yield c.shift()}finally{r&&r.removeEventListener("abort",w),v()}}function di(t,e){let{parse:n,...r}=e??{};return A(s=>{let o=!0,i=new AbortController;return(async()=>{try{for await(let d of Kr(t,{parse:n,signal:i.signal})){if(!o)return;s.emit(d)}o&&s.down([[N]])}catch(d){o&&s.down([[E,d]])}})(),()=>{o=!1,i.abort()}},Re(r))}function ci(t,e){let{method:n="GET",headers:r,body:s,signal:o,...i}=e??{};return A(a=>{let d=!0,u=new AbortController;if(o?.aborted)return a.down([[E,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 f=await fetch(t,{method:n,headers:r,body:c,signal:u.signal});if(!d)return;if(!f.ok)throw new Error(`HTTP ${f.status}: ${f.statusText}`);if(!f.body)throw new Error("HTTP response has no body");let p=f.body.getReader();for(;d;){let{value:h,done:m}=await p.read();if(m)break;h&&a.emit(h)}d&&a.down([[N]])}catch(f){if(!d||f&&f.name==="AbortError")return;a.down([[E,f]])}})(),()=>{d=!1,u.abort()}},Re(i))}function li(t,e){let{intervalMs:n=5e3,...r}=e??{};return Pe(He(n,{period:n}),()=>Gr(t,{...r,completeAfterFetch:!0}).node)}function fi(t,e,n){let{serialize:r=g=>{if(typeof g=="string"||g instanceof Blob||g instanceof ArrayBuffer||ArrayBuffer.isView(g))return g;try{return JSON.stringify(g)}catch{return String(g)}},closeOnComplete:s=!0,closeOnError:o=!0,closeCode:i,closeReason:a,onTransportError:d,retry:u,backpressure:c,stopOn:l}=n??{},f=!1,p=g=>{if(!f){f=!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:g})}catch{}}}},h=null,b=ie(t,{onTransportError:d,serialize:g=>{let y=r(g);if(y===void 0)throw new Error("serialize returned undefined");return y},retry:u,backpressure:c,stopOn:l,onDispose:()=>{if(h){try{e.removeEventListener("close",h)}catch{}h=null}},send:g=>{e.send(g)},onUpstreamMessage:g=>{(g[0]===N&&s||g[0]===E&&o)&&p(g)}});return h=()=>{f=!0,b.dispose()},e.addEventListener("close",h),b}function pi(t,e){let{parse:n,maxRetries:r,backoff:s="exponential",closeOnTeardown:o=!0,...i}=e??{};return yt(()=>Vr(t(),{parse:n,closeOnTeardown:o,...i}),{count:r,backoff:s})}function hi(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 mi(t,e){return On(({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 gi(t,e){return tt(t,e)}function bi(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 yi(t,e){return tt(t,e)}var vi={c:"counter",g:"gauge",ms:"timer",h:"histogram",s:"set",d:"distribution"};function Ti(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=vi[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 l of c.slice(1).split(",")){let[f,p]=l.split(":");f&&(d[f]=p??"")}}return{name:n.trim(),value:i,type:o,sampleRate:a,tags:d,timestampNs:re()}}function wi(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 Pe(He(0,{period:a,signal:o}),()=>A(u=>{let c=!0,l=new AbortController,f=setTimeout(()=>l.abort(new Error("Scrape timeout")),Math.ceil(s/1e6));return(async()=>{try{let h=await fetch(t,{headers:{Accept:"text/plain",...r},signal:l.signal});if(clearTimeout(f),!c)return;if(!h.ok)throw new Error(`Prometheus scrape ${h.status}: ${h.statusText}`);let m=await h.text();if(!c)return;let b=zr(m);for(let g of b)u.emit(g);d=0,u.down([[N]])}catch(h){if(clearTimeout(f),!c||h instanceof Error&&h.name==="AbortError")return;d+=1,d>=i&&u.down([[E,h]])}})(),()=>{c=!1,clearTimeout(f),l.abort()}}))}function zr(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 f=o.slice(7),p=f.indexOf(" ");p>0&&n.set(f.slice(0,p),f.slice(p+1).trim());continue}if(o.startsWith("# HELP ")){let f=o.slice(7),p=f.indexOf(" ");p>0&&r.set(f.slice(0,p),f.slice(p+1).trim());continue}if(o.startsWith("#"))continue;let i,a={},d,u,c=o.indexOf("{");if(c>=0){i=o.slice(0,c);let f=o.indexOf("}",c);if(f<0)continue;let p=o.slice(c+1,f);a=xi(p);let h=o.slice(f+1).trim().split(/\s+/);d=h[0]??"",u=h[1]}else{let f=o.split(/\s+/);i=f[0]??"",d=f[1]??"",u=f[2]}if(!i||!d)continue;let l=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(l)??n.get(i),help:r.get(l)??r.get(i),timestampNs:re()})}return e}function xi(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 ki(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 A(i=>{let a=!0;return(async()=>{try{await t.subscribe({topic:e,fromBeginning:r}),await t.run({eachMessage:async({topic:u,partition:c,message:l})=>{if(!a)return;let f={};if(l.headers)for(let[p,h]of Object.entries(l.headers))h!==void 0&&(f[p]=typeof h=="string"?h:h.toString());i.emit({topic:u,partition:c,key:l.key?.toString()??null,value:s(l.value),headers:f,offset:l.offset,timestamp:l.timestamp,timestampNs:re()})}})}catch(u){a&&i.down([[E,u]])}})(),()=>{a=!1}},Re(o))}function _i(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 Ni(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 A(a=>{let d=!0,u=s;return(async()=>{for(;d;)try{let l=await t.xread("BLOCK",r,"STREAMS",e,u);if(!d)return;if(l)for(let[f,p]of l)for(let[h,m]of p)u=h,a.emit({id:h,key:e,data:o(m),timestampNs:re()})}catch(l){if(!d)return;a.down([[E,l]]);return}})(),()=>{d=!1}},Re(i))}function Si(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 Ei(t,e){let{delimiter:n=",",hasHeader:r=!0,columns:s,parseLine:o,...i}=e??{},a=o??(d=>jr(d,n));return A(d=>{let u=!1;return(async()=>{try{let l=s,f="";for await(let p of t){if(u)return;f+=p;let h=f.split(/\r?\n/);f=h.pop()??"";for(let m of h){if(u)return;if(!m.trim())continue;let b=a(m);if(!l&&r){l=b;continue}l||(l=b.map((y,v)=>`col${v}`));let g={};for(let y=0;y<l.length;y++)g[l[y]]=b[y]??"";d.emit(g)}}if(!u&&f.trim()){let p=a(f);if(l){let h={};for(let m=0;m<l.length;m++)h[l[m]]=p[m]??"";d.emit(h)}}u||d.down([[N]])}catch(l){u||d.down([[E,l]])}})(),()=>{u=!0}},Re(i))}function Oi(t,e){let{delimiter:n=",",hasHeader:r=!0,columns:s,parseLine:o,...i}=e??{},a=o??(d=>jr(d,n));return B([t],(d,u,c)=>{let l=d[0];if(l==null||l.length===0)return;let f=c.store;typeof f.buffer!="string"&&(f.buffer=""),f.headers===void 0&&s&&(f.headers=s.slice());for(let p of l){f.buffer=f.buffer+p;let h=f.buffer.split(/\r?\n/);f.buffer=h.pop()??"";for(let m of h){if(!m.trim())continue;let b=a(m);if(!f.headers&&r){f.headers=b;continue}f.headers||(f.headers=b.map((y,v)=>`col${v}`));let g={};for(let y=0;y<f.headers.length;y++)g[f.headers[y]]=b[y]??"";u.emit(g)}}},{describeKind:"derived",...i})}function Ri(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([[E,c]]);return}}},{describeKind:"derived",...e??{}})}function jr(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 Mi(t,e){return A(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([[N]])}catch(o){r||n.down([[E,o]])}})(),()=>{r=!0}},Re(e))}function Ai(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 Pe(He(0,{period:a,signal:o}),()=>A(u=>{let c=!0;return(async()=>{try{let f=await t.query({query:e,format:s});if(!c)return;let p=await f.json();if(!c)return;for(let h of p)u.emit(h);d=0,u.down([[N]])}catch(f){if(!c)return;d+=1,d>=i&&u.down([[E,f]])}})(),()=>{c=!1}}))}function Ci(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 A(a=>{let d=!0;return(async()=>{for(;d;)try{let c=await t.receive();if(!d)return;let l={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(l),t.acknowledge(c).catch(i);else{let f=!1,p={value:l,ack(){f||(f=!0,t.acknowledge(c).catch(i))},nack(h){if(f)return;f=!0;let m=t;try{let b=m.negativeAcknowledge?.(c);b&&typeof b.then=="function"&&b.catch(i)}catch(b){i(b)}}};a.emit(p)}}catch(c){d&&a.down([[E,c]]);return}})(),()=>{d=!1}},Re(o))}function Pi(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 Di(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 A(a=>{let d=!0,u=t.subscribe(e,s?{queue:s}:void 0);return(async()=>{try{for await(let l of u){if(!d)return;let f={};if(l.headers)for(let p of l.headers.keys())f[p]=l.headers.get(p);a.emit({subject:l.subject,data:o(l.data),headers:f,reply:l.reply,sid:l.sid,timestampNs:re()})}d&&a.down([[N]])}catch(l){d&&a.down([[E,l]])}})(),()=>{d=!1}},Re(i))}function Ii(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 Li(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 A(d=>{let u=!0,c;return(async()=>{try{c=(await t.consume(e,p=>{if(!u)return;if(p===null){u&&d.down([[E,new Error("Consumer cancelled by broker")]]);return}let h={queue:e,routingKey:p.fields.routingKey,exchange:p.fields.exchange,content:s(p.content),properties:p.properties,deliveryTag:p.fields.deliveryTag,redelivered:p.fields.redelivered,timestampNs:re()};if(r){d.emit(h);try{t.ack(p)}catch(m){a(m)}}else{let m=!1,b=t,g={value:h,ack(){if(!m){m=!0;try{t.ack(p)}catch(y){a(y)}}},nack(y){if(m)return;m=!0;let v=y?.requeue;if(!b.nack){a(new Error("RabbitMQ channel does not expose `nack`; cannot negative-ack"));return}try{b.nack(p,!1,v)}catch(w){a(w)}}};d.emit(g)}},{noAck:!1})).consumerTag}catch(f){u&&d.down([[E,f]])}})(),()=>{u=!1,c!==void 0&&t.cancel(c)}},Re(i))}function Bi(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 Wr(t,e,n){let{serialize:r=l=>`${JSON.stringify(l)}
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:l=>{e.write(l.join(""))}}):ie(t,{onTransportError:i,serialize:r,send:l=>{e.write(l)}}),c=u.dispose;return u.dispose=()=>{c();try{e.end()}catch{}},u}function jn(t,e){return t.includes(e)||t.includes('"')||t.includes(`
13
- `)?`"${t.replace(/"/g,'""')}"`:t}function Vi(t,e,n){let{columns:r,delimiter:s=",",writeHeader:o=!0,cellExtractor:i=(p,h)=>String(p[h]??""),flushIntervalMs:a=0,batchSize:d=Number.POSITIVE_INFINITY,onTransportError:u,...c}=n,l=!1;return Wr(t,e,{serialize:p=>{if(!l&&o){l=!0;let h=r.map(b=>jn(b,s)).join(s),m=r.map(b=>jn(i(p,b),s)).join(s);return`${h}
14
- ${m}
15
- `}return`${r.map(h=>jn(i(p,h),s)).join(s)}
16
- `},flushIntervalMs:a,batchSize:d,onTransportError:u,...c})}function Gi(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 Fi(t,e,n,r){let{format:s="ndjson",keyGenerator:o=(f,p)=>{let h=Math.floor(p/1e6);return`data/${new Date(h).toISOString().replace(/[:.]/g,"-")}-${f}.${s==="ndjson"?"ndjson":"json"}`},batchSize:i=1e3,flushIntervalMs:a=1e4,transform:d=f=>f,onTransportError:u}=r??{},c=s==="ndjson"?"application/x-ndjson":"application/json",l=0;return ie(t,{onTransportError:u,batchSize:i,flushIntervalMs:a,serialize:d,sendBatch:async f=>{l+=1;let p=s==="ndjson"?`${f.map(m=>JSON.stringify(m)).join(`
9
+ `))},d)),u?.aborted?m():u?.addEventListener("abort",m,{once:!0}),()=>{p=!1,h!==void 0&&clearInterval(h),u?.removeEventListener("abort",m),y()}})}function yi(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===k)try{r.enqueue(o[1])}catch{n=!0,e?.()}else if(i===E){n=!0;try{r.error(o[1])}catch{}return}else if(i===S){n=!0;try{r.close()}catch{}return}}})},cancel(){n=!0,e?.()}})}async function*Jr(t,e){let n=e?.parse??(_=>_),r=e?.signal,s=new TextDecoder,o="",i="message",a=[],d,u,c=[],l=()=>{if(a.length===0&&i==="message"&&d===void 0){a=[];return}let _=a.join(`
10
+ `);c.push({event:i,data:n(_),id:d,retry:u}),i="message",a=[],d=void 0,u=void 0},f=_=>{if(_===""){l();return}if(_.startsWith(":"))return;let x=_.indexOf(":"),T=x<0?_:_.slice(0,x),N=x<0?"":_.slice(x+1);switch(N.startsWith(" ")&&(N=N.slice(1)),T){case"event":i=N;break;case"data":a.push(N);break;case"id":N.includes("\0")||(d=N);break;case"retry":{let R=Number(N);Number.isFinite(R)&&(u=R);break}}},p=(_,x)=>{o+=s.decode(_,{stream:!x});let T=o.split(/\r?\n/);o=T.pop()??"";for(let N of T)f(N)},h=t,g=t instanceof ReadableStream?t:h&&typeof h=="object"&&h.body instanceof ReadableStream?h.body:null,m,y,b=!1,v=()=>{b||(b=!0,m&&m.cancel().catch(()=>{}),y&&typeof y.return=="function"&&Promise.resolve(y.return()).catch(()=>{}))},w=()=>{v()};if(r){if(r.aborted)return;r.addEventListener("abort",w,{once:!0})}try{if(g){for(m=g.getReader();!r?.aborted;){let{value:_,done:x}=await m.read();if(x)break;for(p(_,!1);c.length>0;)yield c.shift()}p(new Uint8Array,!0)}else{for(y=t[Symbol.asyncIterator]();!r?.aborted;){let x=await y.next();if(x.done)break;for(p(x.value,!1);c.length>0;)yield c.shift()}p(new Uint8Array,!0)}if(o.trim()){for(let _ of o.split(/\r?\n/))f(_);l()}for(;c.length>0;)yield c.shift()}finally{r&&r.removeEventListener("abort",w),v()}}function bi(t,e){let{parse:n,...r}=e??{};return A(s=>{let o=!0,i=new AbortController;return(async()=>{try{for await(let d of Jr(t,{parse:n,signal:i.signal})){if(!o)return;s.emit(d)}o&&s.down([[S]])}catch(d){o&&s.down([[E,d]])}})(),()=>{o=!1,i.abort()}},Me(r))}function vi(t,e){let{method:n="GET",headers:r,body:s,signal:o,...i}=e??{};return A(a=>{let d=!0,u=new AbortController;if(o?.aborted)return a.down([[E,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 f=await fetch(t,{method:n,headers:r,body:c,signal:u.signal});if(!d)return;if(!f.ok)throw new Error(`HTTP ${f.status}: ${f.statusText}`);if(!f.body)throw new Error("HTTP response has no body");let p=f.body.getReader();for(;d;){let{value:h,done:g}=await p.read();if(g)break;h&&a.emit(h)}d&&a.down([[S]])}catch(f){if(!d||f&&f.name==="AbortError")return;a.down([[E,f]])}})(),()=>{d=!1,u.abort()}},Me(i))}function Ti(t,e){let{intervalMs:n=5e3,...r}=e??{};return Le(qe(n,{period:n}),()=>Wr(t,{...r,completeAfterFetch:!0}).node)}function wi(t,e,n){let{serialize:r=y=>{if(typeof y=="string"||y instanceof Blob||y instanceof ArrayBuffer||ArrayBuffer.isView(y))return y;try{return JSON.stringify(y)}catch{return String(y)}},closeOnComplete:s=!0,closeOnError:o=!0,closeCode:i,closeReason:a,onTransportError:d,retry:u,backpressure:c,stopOn:l}=n??{},f=!1,p=y=>{if(!f){f=!0;try{e.close(i,a)}catch(b){let v=b instanceof Error?b:new Error(String(b));try{d?.({stage:"close",error:v,value:void 0,message:y})}catch{}}}},h=null,m=ue(t,{onTransportError:d,serialize:y=>{let b=r(y);if(b===void 0)throw new Error("serialize returned undefined");return b},retry:u,backpressure:c,stopOn:l,onDispose:()=>{if(h){try{e.removeEventListener("close",h)}catch{}h=null}},send:y=>{e.send(y)},onUpstreamMessage:y=>{(y[0]===S&&s||y[0]===E&&o)&&p(y)}});return h=()=>{f=!0,m.dispose()},e.addEventListener("close",h),m}function xi(t,e){let{parse:n,maxRetries:r,backoff:s="exponential",closeOnTeardown:o=!0,...i}=e??{};return xt(()=>Hr(t(),{parse:n,closeOnTeardown:o,...i}),{count:r,backoff:s})}function ki(t,e){let{method:n="notifications/message",onDisconnect:r,...s}=e??{};return st(({emit:o,error:i})=>(t.setNotificationHandler(n,a=>o(a)),r?.(a=>i(a??new Error("MCP client disconnected"))),()=>t.setNotificationHandler(n,()=>{})),s)}function _i(t,e){return Dn(({traces:r,metrics:s,logs:o,error:i})=>t({onTraces:a=>{H(()=>{for(let d of a)r(d)})},onMetrics:a=>{H(()=>{for(let d of a)s(d)})},onLogs:a=>{H(()=>{for(let d of a)o(d)})},onError:i})??void 0,["traces","metrics","logs"],e?.name?{name:e.name}:void 0)}function Ni(t,e){return st(t,e)}function Si(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=oe();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:oe()}}function Ei(t,e){return st(t,e)}var Oi={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=Oi[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 l of c.slice(1).split(",")){let[f,p]=l.split(":");f&&(d[f]=p??"")}}return{name:n.trim(),value:i,type:o,sampleRate:a,tags:d,timestampNs:oe()}}function Mi(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 Le(qe(0,{period:a,signal:o}),()=>A(u=>{let c=!0,l=new AbortController,f=setTimeout(()=>l.abort(new Error("Scrape timeout")),Math.ceil(s/1e6));return(async()=>{try{let h=await fetch(t,{headers:{Accept:"text/plain",...r},signal:l.signal});if(clearTimeout(f),!c)return;if(!h.ok)throw new Error(`Prometheus scrape ${h.status}: ${h.statusText}`);let g=await h.text();if(!c)return;let m=Yr(g);for(let y of m)u.emit(y);d=0,u.down([[S]])}catch(h){if(clearTimeout(f),!c||h instanceof Error&&h.name==="AbortError")return;d+=1,d>=i&&u.down([[E,h]])}})(),()=>{c=!1,clearTimeout(f),l.abort()}}))}function Yr(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 f=o.slice(7),p=f.indexOf(" ");p>0&&n.set(f.slice(0,p),f.slice(p+1).trim());continue}if(o.startsWith("# HELP ")){let f=o.slice(7),p=f.indexOf(" ");p>0&&r.set(f.slice(0,p),f.slice(p+1).trim());continue}if(o.startsWith("#"))continue;let i,a={},d,u,c=o.indexOf("{");if(c>=0){i=o.slice(0,c);let f=o.indexOf("}",c);if(f<0)continue;let p=o.slice(c+1,f);a=Ai(p);let h=o.slice(f+1).trim().split(/\s+/);d=h[0]??"",u=h[1]}else{let f=o.split(/\s+/);i=f[0]??"",d=f[1]??"",u=f[2]}if(!i||!d)continue;let l=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(l)??n.get(i),help:r.get(l)??r.get(i),timestampNs:oe()})}return e}function Ai(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 Ci(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 A(i=>{let a=!0;return(async()=>{try{await t.subscribe({topic:e,fromBeginning:r}),await t.run({eachMessage:async({topic:u,partition:c,message:l})=>{if(!a)return;let f={};if(l.headers)for(let[p,h]of Object.entries(l.headers))h!==void 0&&(f[p]=typeof h=="string"?h:h.toString());i.emit({topic:u,partition:c,key:l.key?.toString()??null,value:s(l.value),headers:f,offset:l.offset,timestamp:l.timestamp,timestampNs:oe()})}})}catch(u){a&&i.down([[E,u]])}})(),()=>{a=!1}},Me(o))}function Di(t,e,n,r){let{serialize:s=a=>JSON.stringify(a),keyExtractor:o,onTransportError:i}=r??{};return ue(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 Pi(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 A(a=>{let d=!0,u=s;return(async()=>{for(;d;)try{let l=await t.xread("BLOCK",r,"STREAMS",e,u);if(!d)return;if(l)for(let[f,p]of l)for(let[h,g]of p)u=h,a.emit({id:h,key:e,data:o(g),timestampNs:oe()})}catch(l){if(!d)return;a.down([[E,l]]);return}})(),()=>{d=!1}},Me(i))}function Ii(t,e,n,r){let{serialize:s=a=>["data",JSON.stringify(a)],maxLen:o,onTransportError:i}=r??{};return ue(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 Li(t,e){let{delimiter:n=",",hasHeader:r=!0,columns:s,parseLine:o,...i}=e??{},a=o??(d=>Qr(d,n));return A(d=>{let u=!1;return(async()=>{try{let l=s,f="";for await(let p of t){if(u)return;f+=p;let h=f.split(/\r?\n/);f=h.pop()??"";for(let g of h){if(u)return;if(!g.trim())continue;let m=a(g);if(!l&&r){l=m;continue}l||(l=m.map((b,v)=>`col${v}`));let y={};for(let b=0;b<l.length;b++)y[l[b]]=m[b]??"";d.emit(y)}}if(!u&&f.trim()){let p=a(f);if(l){let h={};for(let g=0;g<l.length;g++)h[l[g]]=p[g]??"";d.emit(h)}}u||d.down([[S]])}catch(l){u||d.down([[E,l]])}})(),()=>{u=!0}},Me(i))}function Bi(t,e){let{delimiter:n=",",hasHeader:r=!0,columns:s,parseLine:o,...i}=e??{},a=o??(d=>Qr(d,n));return G([t],(d,u,c)=>{let l=d[0];if(l==null||l.length===0)return;let f=c.store;typeof f.buffer!="string"&&(f.buffer=""),f.headers===void 0&&s&&(f.headers=s.slice());for(let p of l){f.buffer=f.buffer+p;let h=f.buffer.split(/\r?\n/);f.buffer=h.pop()??"";for(let g of h){if(!g.trim())continue;let m=a(g);if(!f.headers&&r){f.headers=m;continue}f.headers||(f.headers=m.map((b,v)=>`col${v}`));let y={};for(let b=0;b<f.headers.length;b++)y[f.headers[b]]=m[b]??"";u.emit(y)}}},{describeKind:"derived",...i})}function Gi(t,e){return G([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([[E,c]]);return}}},{describeKind:"derived",...e??{}})}function Qr(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 Vi(t,e){return A(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([[S]])}catch(o){r||n.down([[E,o]])}})(),()=>{r=!0}},Me(e))}function Fi(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 Le(qe(0,{period:a,signal:o}),()=>A(u=>{let c=!0;return(async()=>{try{let f=await t.query({query:e,format:s});if(!c)return;let p=await f.json();if(!c)return;for(let h of p)u.emit(h);d=0,u.down([[S]])}catch(f){if(!c)return;d+=1,d>=i&&u.down([[E,f]])}})(),()=>{c=!1}}))}function $i(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 A(a=>{let d=!0;return(async()=>{for(;d;)try{let c=await t.receive();if(!d)return;let l={topic:c.getTopicName(),messageId:c.getMessageId().toString(),key:c.getPartitionKey(),value:r(c.getData()),properties:c.getProperties(),publishTime:c.getPublishTimestamp(),eventTime:c.getEventTimestamp(),timestampNs:oe()};if(n)a.emit(l),t.acknowledge(c).catch(i);else{let f=!1,p={value:l,ack(){f||(f=!0,t.acknowledge(c).catch(i))},nack(h){if(f)return;f=!0;let g=t;try{let m=g.negativeAcknowledge?.(c);m&&typeof m.then=="function"&&m.catch(i)}catch(m){i(m)}}};a.emit(p)}}catch(c){d&&a.down([[E,c]]);return}})(),()=>{d=!1}},Me(o))}function Ki(t,e,n){let{serialize:r=a=>Buffer.from(JSON.stringify(a)),keyExtractor:s,propertiesExtractor:o,onTransportError:i}=n??{};return ue(t,{onTransportError:i,send:async a=>{await e.send({data:r(a),partitionKey:s?.(a),properties:o?.(a)})}})}function zi(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 A(a=>{let d=!0,u=t.subscribe(e,s?{queue:s}:void 0);return(async()=>{try{for await(let l of u){if(!d)return;let f={};if(l.headers)for(let p of l.headers.keys())f[p]=l.headers.get(p);a.emit({subject:l.subject,data:o(l.data),headers:f,reply:l.reply,sid:l.sid,timestampNs:oe()})}d&&a.down([[S]])}catch(l){d&&a.down([[E,l]])}})(),()=>{d=!1}},Me(i))}function ji(t,e,n,r){let s=new TextEncoder,{serialize:o=a=>s.encode(JSON.stringify(a)),onTransportError:i}=r??{};return ue(t,{onTransportError:i,send:a=>{e.publish(n,o(a))}})}function Hi(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 A(d=>{let u=!0,c;return(async()=>{try{c=(await t.consume(e,p=>{if(!u)return;if(p===null){u&&d.down([[E,new Error("Consumer cancelled by broker")]]);return}let h={queue:e,routingKey:p.fields.routingKey,exchange:p.fields.exchange,content:s(p.content),properties:p.properties,deliveryTag:p.fields.deliveryTag,redelivered:p.fields.redelivered,timestampNs:oe()};if(r){d.emit(h);try{t.ack(p)}catch(g){a(g)}}else{let g=!1,m=t,y={value:h,ack(){if(!g){g=!0;try{t.ack(p)}catch(b){a(b)}}},nack(b){if(g)return;g=!0;let v=b?.requeue;if(!m.nack){a(new Error("RabbitMQ channel does not expose `nack`; cannot negative-ack"));return}try{m.nack(p,!1,v)}catch(w){a(w)}}};d.emit(y)}},{noAck:!1})).consumerTag}catch(f){u&&d.down([[E,f]])}})(),()=>{u=!1,c!==void 0&&t.cancel(c)}},Me(i))}function Wi(t,e,n,r){let{serialize:s=a=>Buffer.from(JSON.stringify(a)),routingKeyExtractor:o=()=>"",onTransportError:i}=r??{};return ue(t,{onTransportError:i,send:a=>{let d=o(a),u=s(a);e.publish(n,d,u)}})}function Xr(t,e,n){let{serialize:r=l=>`${JSON.stringify(l)}
12
+ `,flushIntervalMs:s=0,batchSize:o=Number.POSITIVE_INFINITY,onTransportError:i,mode:a}=n??{},u=s>0||o<Number.POSITIVE_INFINITY?ue(t,{onTransportError:i,batchSize:o,flushIntervalMs:s,serialize:r,sendBatch:l=>{e.write(l.join(""))}}):ue(t,{onTransportError:i,serialize:r,send:l=>{e.write(l)}}),c=u.dispose;return u.dispose=()=>{c();try{e.end()}catch{}},u}function Yn(t,e){return t.includes(e)||t.includes('"')||t.includes(`
13
+ `)?`"${t.replace(/"/g,'""')}"`:t}function Ui(t,e,n){let{columns:r,delimiter:s=",",writeHeader:o=!0,cellExtractor:i=(p,h)=>String(p[h]??""),flushIntervalMs:a=0,batchSize:d=Number.POSITIVE_INFINITY,onTransportError:u,...c}=n,l=!1;return Xr(t,e,{serialize:p=>{if(!l&&o){l=!0;let h=r.map(m=>Yn(m,s)).join(s),g=r.map(m=>Yn(i(p,m),s)).join(s);return`${h}
14
+ ${g}
15
+ `}return`${r.map(h=>Yn(i(p,h),s)).join(s)}
16
+ `},flushIntervalMs:a,batchSize:d,onTransportError:u,...c})}function qi(t,e,n,r){let{batchSize:s=1e3,flushIntervalMs:o=5e3,format:i="JSONEachRow",transform:a=u=>u,onTransportError:d}=r??{};return ue(t,{onTransportError:d,batchSize:s,flushIntervalMs:o,serialize:a,sendBatch:async u=>{await e.insert({table:n,values:u,format:i})}})}function Ji(t,e,n,r){let{format:s="ndjson",keyGenerator:o=(f,p)=>{let h=Math.floor(p/1e6);return`data/${new Date(h).toISOString().replace(/[:.]/g,"-")}-${f}.${s==="ndjson"?"ndjson":"json"}`},batchSize:i=1e3,flushIntervalMs:a=1e4,transform:d=f=>f,onTransportError:u}=r??{},c=s==="ndjson"?"application/x-ndjson":"application/json",l=0;return ue(t,{onTransportError:u,batchSize:i,flushIntervalMs:a,serialize:d,sendBatch:async f=>{l+=1;let p=s==="ndjson"?`${f.map(g=>JSON.stringify(g)).join(`
17
17
  `)}
18
- `:JSON.stringify(f),h=o(l,re());await e.putObject({Bucket:n,Key:h,Body:p,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 Ki(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 zi(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 ji(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 Wi(t,e,n,r){let{prefix:s="checkpoints/",debounceMs:o=500,compactEvery:i=10,onError:a}=r??{},d={name:`s3:${n}`,debounceMs:o,compactEvery:i,save(u){let c=Math.floor(re()/1e6),l=`${s}${t.name}/checkpoint-${c}.json`,f;try{f=JSON.stringify(u)}catch(p){a?.(p);return}e.putObject({Bucket:n,Key:l,Body:f,ContentType:"application/json"}).catch(p=>a?.(p))}};return t.attachSnapshotStorage([d],{onError:u=>a?.(u)})}function Hi(t,e,n){let{prefix:r="graphrefly:checkpoint:",debounceMs:s=500,compactEvery:o=10,onError:i}=n??{},a=`${r}${t.name}`,d={name:`redis:${a}`,debounceMs:s,compactEvery:o,save(u){let c;try{c=JSON.stringify(u)}catch(l){i?.(l);return}e.set(a,c).catch(l=>i?.(l))},async load(){let u=await e.get(a);if(u!=null)try{return JSON.parse(u)}catch{return}}};return t.attachSnapshotStorage([d],{onError:u=>i?.(u)})}function Ui(t,e,n){let{mapRow:r=i=>i,params:s,...o}=n??{};return A(i=>{try{let d=t.query(e,s).map(r);i.emit(d),i.down([[N]])}catch(a){i.down([[E,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function qi(t,e,n){let{mapRow:r=i=>i,params:s,...o}=n??{};return A(i=>{try{let a=t.iterate(e,s);j(()=>{for(let d of a)i.emit(r(d));i.down([[N]])})}catch(a){i.down([[E,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function Ji(t,e,n,r){if(n.includes("\0")||n.length===0)throw new Error(`toSqlite: invalid table name: ${JSON.stringify(n)}`);let{toSQL:s=(R,V)=>({sql:`INSERT INTO "${V.replace(/"/g,'""')}" (data) VALUES (?)`,params:[JSON.stringify(R)]}),onTransportError:o,batchInsert:i=!1,maxBatchSize:a=1e3,flushIntervalMs:d=0}=r??{},u=R=>s(R,n);if(!i)return ie(t,{onTransportError:o,serialize:u,send:R=>{let V=R;e.query(V.sql,V.params)}});let c=F(null),l=F(void 0,{equals:()=>!1}),f=F(null),p=F(0),h=F(0),m=R=>{try{o?.(R)}catch{}try{c.down([[x,R]])}catch{}},b=[],g=!1,y,v=!1,w=()=>h.down([[x,b.length]]),_=R=>{v||l.down([[x,R]])},k=R=>{v||f.down([[x,R]])},T=R=>{v||p.down([[x,R]])},S=R=>{v||m(R)},O=()=>{if(b.length===0||g)return;g=!0,T(1);try{e.query("BEGIN",[])}catch(K){g=!1,T(0),S({stage:"send",error:K instanceof Error?K:new Error(String(K)),value:void 0});return}let R=b;b=[],w();let V,Q=0;for(let K of R)try{e.query(K.query.sql,K.query.params),Q+=1}catch(te){V=te instanceof Error?te:new Error(String(te));break}if(V){try{e.query("ROLLBACK",[])}catch{}S({stage:"send",error:V,value:void 0});for(let K of R)k({value:K.value,error:V,attempts:1})}else try{e.query("COMMIT",[]);for(let K of R)_(K.value)}catch(K){let te=K instanceof Error?K:new Error(String(K));S({stage:"send",error:te,value:void 0});for(let ke=0;ke<Q;ke++)k({value:R[ke].value,error:te,attempts:1})}g=!1,T(0)},M=()=>{d>0&&y===void 0&&!v&&(y=setTimeout(()=>{y=void 0,O()},d))},C=t.subscribe(R=>{for(let V of R){let Q=V[0];if(Q===x){let K=V[1],te;try{te=u(K)}catch(ke){let De=ke instanceof Error?ke:new Error(String(ke));m({stage:"serialize",error:De,value:K}),f.down([[x,{value:K,error:De,attempts:0}]]);continue}b.push({value:K,query:te}),w(),b.length>=a?O():M()}else le.messageTier(Q)>=3&&O()}});return{dispose:()=>{if(!v){y!==void 0&&(clearTimeout(y),y=void 0),O(),v=!0,C();for(let R of[c,l,f,p,h])try{R.down([[z]])}catch{}}},sent:l,failed:f,inFlight:p,errors:c,buffered:h,flush:async()=>{v||O()}}}function Yi(t,e){let{args:n,mapRow:r=o=>o,...s}=e??{};return A(o=>{let i=!0;return t.findMany(n).then(a=>{i&&(o.emit(a.map(r)),o.down([[N]]))}).catch(a=>{if(i)try{o.down([[E,a instanceof Error?a:new Error(String(a))]])}catch{}}),()=>{i=!1}},{...s,describeKind:"producer",completeWhenDepsComplete:!1})}function Qi(t,e){let{mapRow:n=s=>s,...r}=e??{};return A(s=>{let o=!0;return t.execute().then(i=>{o&&(s.emit(i.map(n)),s.down([[N]]))}).catch(i=>{if(o)try{s.down([[E,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}function Xi(t,e){let{mapRow:n=s=>s,...r}=e??{};return A(s=>{let o=!0;return t.execute().then(i=>{o&&(s.emit(i.map(n)),s.down([[N]]))}).catch(i=>{if(o)try{s.down([[E,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}gt();Z();var Zi=0;function ea(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-${++Zi}`),r=0,s=!1;return{onEnqueue(){return r+=1,!s&&r>=e.highWaterMark?(s=!0,t([[ge,n]]),!0):!1},onDequeue(){return r>0&&(r-=1),s&&r<=e.lowWaterMark?(s=!1,t([[xe,n]]),!0):!1},get pending(){return r},get paused(){return s},dispose(){s&&(s=!1,t([[xe,n]]))}}}Z();de();function Hr(){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 Ur(t){return t!=null&&typeof t.then=="function"}function at(t){Ur(t)&&t.catch(()=>{})}function ta(t,e){let n=new Map,r=e?.maxSize??0,s=r>0?e?.eviction??Hr():null,o=e?.writeThrough??!1;function i(u,c,l){for(let f=0;f<l;f++)try{at(t[f].save(u,c))}catch{}}function a(u,c,l=0){for(let f=l;f<t.length;f++){let p;try{p=t[f].load(u)}catch{continue}if(Ur(p)){let h=f;p.then(m=>{m!==void 0?(c.down([[x,m]]),i(u,m,h)):a(u,c,h+1)},()=>{a(u,c,h+1)});return}if(p!==void 0){c.down([[x,p]]),i(u,p,f);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 l=n.get(c);if(l){let f=l.cache;if(l.status!=="sentinel"&&t.length>0){let p=t.length-1;try{at(t[p].save(c,f))}catch{}for(let h=0;h<p;h++)try{let m=t[h].delete;m&&at(m.call(t[h],c))}catch{}}l.down([[z]])}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 l=F(void 0);return n.set(u,l),s?.insert(u),a(u,l),l},save(u,c){if(o)for(let f of t)try{at(f.save(u,c))}catch{}else if(t[0])try{at(t[0].save(u,c))}catch{}let l=n.get(u);if(l)l.down([[x,c]]),s?.touch(u);else{s&&r>0&&s.size()>=r&&d();let f=F(c);n.set(u,f),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([[z]]),n.delete(u);for(let l of t)try{let f=l.delete;f&&at(f.call(l,u))}catch{}},has(u){return n.has(u)},get size(){return n.size}}}Te();Z();de();Te();Be();Z();de();var Kt=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 Wn(t={}){let{name:e,maxSize:n,defaultTtl:r,versioning:s,backend:o,retention:i}=t;if(i&&n!==void 0)throw new RangeError("reactiveMap: `maxSize` (LRU) and `retention` (score-based) are mutually exclusive. Pick one eviction policy.");if(i&&i.archiveThreshold===void 0&&i.maxSize===void 0)throw new RangeError("reactiveMap: `retention` requires at least one of `archiveThreshold` or `maxSize` to trigger archival.");let a=o??new Kt({maxSize:n,defaultTtl:r}),d=F(a.toMap(),{name:e,describeKind:"state",equals:(f,p)=>f===p,...s!=null?{versioning:s}:{}});function u(){let f=a.toMap();j(()=>{d.down([[$]]),d.down([[x,f]])})}function c(){if(!i)return;let f=a.toMap(),p=i.archiveThreshold,h=i.maxSize,m=[];for(let[g,y]of f)m.push({key:g,value:y,score:i.score(g,y)});m.sort((g,y)=>g.score-y.score);let b=new Set;if(p!==void 0)for(let g of m)if(g.score<p)b.add(g.key);else break;if(h!==void 0&&m.length-b.size>h)for(let g of m){if(m.length-b.size<=h)break;b.has(g.key)||b.add(g.key)}if(b.size!==0)for(let g of m)b.has(g.key)&&(i.onArchive?.(g.key,g.value,g.score),a.delete(g.key))}function l(f,p="mutation"){let h=a.version;try{return f()}finally{a.version!==h&&(p==="mutation"&&c(),u())}}return{entries:d,has(f){return l(()=>a.has(f),"read")},get(f){return l(()=>a.get(f),"read")},set(f,p,h){l(()=>a.set(f,p,h?.ttl))},setMany(f,p){l(()=>a.setMany(f,p?.ttl))},delete(f){l(()=>a.delete(f))},deleteMany(f){l(()=>a.deleteMany(f))},clear(){l(()=>a.clear())},pruneExpired(){l(()=>a.pruneExpired())},get size(){return a.size},dispose(){}}}Ce();function na(t){return typeof t=="object"&&t!==null&&"cache"in t&&typeof t.subscribe=="function"}function ra(t,e,n){let r=ue(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=Tt(ue(n.trigger),r):i?a=ue(n.trigger):n?.autoVerify&&(a=r),a!==null){let d;if(a===r)d=Pe(r,u=>e(u));else{let u=r.cache;r.subscribe(c=>{for(let l of c)l[0]===x&&(u=l[1])}),d=Pe(a,()=>e(u))}Ue(d,u=>{j(()=>{if(o.down([[x,u]]),s){let c=r.v;c!=null&&o.meta.sourceVersion.down([[x,{id:c.id,version:c.version}]])}})})}return{node:r,verified:o,trigger:a}}function qr(t){t.subscribe(()=>{})}function xt(t){return t instanceof Map?t:new Map}function Jr(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 oa(t,e,n){let r=ue(t),s=Wn(n.mapOptions??{}),o=n.budget??2e3,a=n.context!==void 0&&n.context!==null?ue(n.context):F(null),d=xt(s.entries.cache);s.entries.subscribe(p=>{for(let h of p)h[0]===x&&(d=xt(h[1]))});let u=Pe(r,p=>e(p,d));if(Ue(u,p=>{Jr(s,p)}),n.evict){let p=new Map,h=fe([s.entries],([m])=>{let b=[],g=xt(m);for(let y of p.keys())g.has(y)||(p.get(y)(),p.delete(y));for(let[y,v]of g){let w=n.evict(y,v);if(na(w)){if(!p.has(y)){let _=Ue(w,k=>{k===!0&&s.has(y)&&s.delete(y)});p.set(y,_)}continue}if(typeof w=="boolean"){w&&b.push(y);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return b});Ue(h,m=>{for(let b of m)s.delete(b)})}let c=n.consolidateTrigger!==void 0&&n.consolidateTrigger!==null;if(n.consolidate&&c){let p=ue(n.consolidateTrigger),h=Pe(p,()=>n.consolidate(d));Ue(h,m=>{Jr(s,m)})}let l=fe([s.entries,a],([p,h])=>{let m=[...xt(p).entries()].map(([y,v])=>({key:y,value:v,score:n.score(v,h),cost:n.cost(v)}));m.sort((y,v)=>v.score-y.score);let b=[],g=o;for(let y of m)y.cost<=g&&(b.push({key:y.key,value:y.value,score:y.score}),g-=y.cost);return b}),f=fe([s.entries],([p])=>xt(p).size);return qr(l),qr(f),{store:s,compact:l,size:f}}async function Yr(t){let e=typeof t=="string"?new TextEncoder().encode(t):t,n=await globalThis.crypto.subtle.digest("SHA-256",e),r=new Uint8Array(n),s="";for(let o=0;o<r.length;o++)s+=Qr[r[o]];return s}var Qr=new Array(256);for(let t=0;t<256;t++)Qr[t]=t.toString(16).padStart(2,"0");var zt=class extends Error{constructor(n,r){super(`content-addressed lookup miss in read-strict mode: ${n}`);this.key=n;this.context=r;this.name="ContentAddressedMissError"}};function Xr(t){let e=new Set,n=r=>{if(r===null||typeof r!="object")return r;let s=r;if(e.has(s))return{__cycle:!0};e.add(s);try{if(Array.isArray(r))return r.map(n);let o={};for(let i of Object.keys(r).sort())o[i]=n(r[i]);return o}finally{e.delete(s)}};return JSON.stringify(n(t))}function sa(t){let{storage:e,keyContext:n,keyPrefix:r,mode:s="read-write"}=t,o=n??(a=>a);async function i(a){let d=Xr(o(a)),u=await Yr(d);return r?`${r}:${u}`:u}return{keyFor:i,async lookup(a){if(s==="write")return;let d=await i(a),u=await e.load(d);if(u===void 0){if(s==="read-strict")throw new zt(d,a);return}return u},async store(a,d){if(s==="read")return;let u=await i(a);await e.save(u,d)},async forget(a){if(s==="read"||s==="write"||!e.delete)return;let d=await i(a);await e.delete(d)}}}An();async function ia(t,e){let n;try{n=await t.text()}catch{n=""}let r=e??"HTTP",s=new Error(`${r} API ${t.status}: ${t.statusText}${n?` \u2014 ${n}`:""}`);return s.status=t.status,s.headers=t.headers,s}var Hn=require("rxjs");Z();function aa(t,e){return e?.raw?new Hn.Observable(n=>t.subscribe(s=>{if(!n.closed){n.next(s);for(let o of s){if(o[0]===E){n.error(o[1]);return}if(o[0]===N){n.complete();return}}}})):new Hn.Observable(n=>t.subscribe(s=>{for(let o of s){if(n.closed)return;if(o[0]===x)n.next(o[1]);else if(o[0]===E){n.error(o[1]);return}else if(o[0]===N){n.complete();return}}}))}Te();Z();be();var jt=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 ua(t={}){let{backend:e}=t,n=e??new jt,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([[z]]),!0)},has(o){return n.hasTopic(o)},get size(){return n.topicCount},topicNames(){return n.topicNames()}}}Te();Z();de();function Zr(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 da(t,e){let n=Zr(t[0],e[0]);return n!==0?n:Zr(t[1],e[1])}function eo(t){return[t.secondary,t.primary]}function ut(t,e){let n=eo(e),r=0,s=t.length;for(;r<s;){let o=r+s>>1;da(n,eo(t[o]))>0?r=o+1:s=o}return r}var Wt=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=ut(this._buf,o);this._buf.splice(d,1)}let a=ut(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=ut(this._buf,o);this._buf.splice(d,1)}let a=ut(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=ut(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=ut(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 ca(t){return t.subscribe(()=>{})}function la(t={}){let{name:e,versioning:n,equals:r,backend:s}=t,o=s??new Wt;function i(p){return p?.equals!==void 0||r===void 0?p:{...p,equals:r}}let a=F([],{name:e,describeKind:"state",equals:(p,h)=>p===h,...n!=null?{versioning:n}:{}}),d=fe([a],([p])=>{let h=p,m=new Map;for(let b of h)m.set(b.primary,b.value);return m},{initial:o.toPrimaryMap(),describeKind:"derived"}),u=ca(d),c=!1;function l(){let p=o.toArray();j(()=>{a.down([[$]]),a.down([[x,p]])})}function f(p){let h=o.version;try{return p()}finally{o.version!==h&&l()}}return{ordered:a,byPrimary:d,has(p){return o.has(p)},get(p){return o.get(p)},get size(){return o.size},upsert(p,h,m,b){return f(()=>o.upsert(p,h,m,i(b)))},upsertMany(p,h){let m=[...p];m.length!==0&&f(()=>o.upsertMany(m,i(h)))},delete(p){f(()=>o.delete(p))},deleteMany(p){let h=[...p];h.length!==0&&f(()=>o.deleteMany(h))},clear(){f(()=>o.clear())},dispose(){c||(c=!0,u())}}}Te();Z();de();var Ht=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 fa(t,e={}){let{name:n,versioning:r,backend:s}=e,o=s??new Ht(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([[$]]),i.down([[x,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(){}}}Te();Z();be();de();Ce();var Ut=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}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let n=0;n<e.length;n++)this._buf.push(e[n]);this._size=this._buf.length}else{let n=this._maxSize;for(let o=0;o<n;o++)this._buf[o]=void 0;this._head=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}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function kt(t){return t.subscribe(()=>{})}var pa=64;function ha(t,e={}){let{name:n,maxSize:r,versioning:s,guard:o,backend:i}=e,a=i??new Ut(t,r),d=F(a.toArray(),{name:n,describeKind:"state",equals:(T,S)=>T===S,...s!=null?{versioning:s}:{},...o!=null?{guard:o}:{}});function u(){let T=a.toArray();j(()=>{d.down([[$]],{internal:!0}),d.down([[x,T]],{internal:!0})})}let c=new Map,l=new Map,f=new Map;function p(T,S){return`${T}:${S===void 0?"END":S}`}function h(T){if(T.size<pa)return;let S=T.keys().next();if(S.done)return;let O=T.get(S.value);O!==void 0&&O.dispose(),T.delete(S.value)}function m(T){let S=a.version;try{return T()}finally{a.version!==S&&u()}}function b(T){if(!Number.isInteger(T)||T<0)throw new RangeError(`tail: n must be a non-negative integer (got ${T})`);let S=c.get(T);if(S!==void 0)return c.delete(T),c.set(T,S),S.node;h(c);let O=fe([d],([C])=>{let D=C;return T===0||D.length===0?[]:D.slice(Math.max(0,D.length-T))},{initial:a.tail(T),describeKind:"derived"}),M=kt(O);return c.set(T,{node:O,dispose:M}),O}function g(T,S){if(!Number.isInteger(T)||T<0)throw new RangeError(`slice: start must be a non-negative integer (got ${T})`);if(S!==void 0&&(!Number.isInteger(S)||S<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${S})`);let O=p(T,S),M=l.get(O);if(M!==void 0)return l.delete(O),l.set(O,M),M.node;h(l);let C=fe([d],([R])=>{let V=R;return S===void 0?V.slice(T):V.slice(T,S)},{initial:a.slice(T,S),describeKind:"derived"}),D=kt(C);return l.set(O,{node:C,dispose:D}),C}function y(T){let S=f.get(T);if(S!==void 0)return S.node;let O=fe([d,T],([C,D])=>{let R=C,V=Math.max(0,Math.trunc(D??0));return R.slice(V)},{initial:[],describeKind:"derived"}),M=kt(O);return f.set(T,{node:O,dispose:M}),O}let v,w;function _(){v===void 0&&(v=B([d],(T,S,O)=>{let M=T[0],D=M!=null&&M.length>0?M.at(-1):O.prevData[0];if(D==null||D.length===0){S.down([[P]]);return}S.emit(D[D.length-1])},{name:n!=null?`${n}::lastValue`:"lastValue",describeKind:"derived",initial:a.size===0?void 0:a.at(a.size-1)}),w=fe([d],([T])=>T.length>0,{name:n!=null?`${n}::hasLatest`:"hasLatest",describeKind:"derived",initial:a.size>0}),kt(v),kt(w))}let k={entries:d,get size(){return a.size},at(T){return a.at(T)},append(T){m(()=>a.append(T))},appendMany(T){T.length!==0&&m(()=>a.appendMany(T))},clear(){m(()=>a.clear())},trimHead(T){m(()=>a.trimHead(T))},withLatest(){return _(),d},get lastValue(){return _(),v},get hasLatest(){return _(),w},view(T){switch(T.kind){case"tail":return b(T.n);case"slice":return g(T.start,T.stop);case"fromCursor":return y(T.cursor)}},attach(T){let S=T.subscribe(O=>{for(let M of O)M[0]===x&&k.append(M[1])});return()=>S()},attachStorage(T){if(T.length===0)return()=>{};let S=new Map;for(let M of T)S.set(M,a.size);(async()=>{for(let M of T)if(typeof M.loadEntries=="function")try{let C=await Promise.resolve(M.loadEntries());C.entries.length>0&&a.size===0&&(a.restore(C.entries),S.set(M,C.entries.length),u());break}catch{}})();let O=d.subscribe(M=>{for(let C of M){if(C[0]!==x)continue;let D=C[1];for(let R of T){let V=S.get(R)??0;if(D.length<V){try{let K=R.appendEntries(D);K instanceof Promise&&K.catch(()=>{})}catch{}S.set(R,D.length);continue}if(D.length===V)continue;let Q=D.slice(V);S.set(R,D.length);try{let K=R.appendEntries(Q);K instanceof Promise&&K.catch(()=>{})}catch{}}}});return()=>O()},disposeAllViews(){for(let T of c.values())T.dispose();c.clear();for(let T of l.values())T.dispose();l.clear();for(let T of f.values())T.dispose();f.clear()},dispose(){for(let T of c.values())T.dispose();c.clear();for(let T of l.values())T.dispose();l.clear();for(let T of f.values())T.dispose();f.clear()}};return k}var Un=new WeakMap;function ma(t){let e=Un.get(t);if(e)return e;let n=t.map(c=>c.cache??[]),r=n.flat(),s=F(r,{name:"mergeReactiveLogs",describeKind:"state",equals:(c,l)=>c===l}),o=t.map((c,l)=>[...n[l]??[]]),i=[];for(let c=0;c<t.length;c++){let l=c,f=t[l].subscribe(p=>{for(let h of p)if(h[0]===x)o[l]=[...h[1]],s.emit(o.flat());else if(h[0]===N){o[l]=[];let m=i[l];m!==void 0&&(i[l]=void 0,m())}else h[0]===E&&s.down([[E,h[1]]])});i.push(f)}let a=st(s),d=!1,u={node:s,dispose(){if(!d){d=!0;for(let c of i)c?.();i.length=0,a(),Un.delete(t)}}};return Un.set(t,u),u}Bt();Z();Ce();function ga(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=$n(a):a!=null&&typeof a=="object"&&Symbol.asyncIterator in a?d=(async()=>{let l=a[Symbol.asyncIterator]();try{let{value:f,done:p}=await l.next();if(p)throw new Error("singleFromAny: factory returned empty async iterable");return f}finally{await l.return?.()}})():a!=null&&typeof a=="object"&&Symbol.iterator in a?d=(async()=>{let l=a[Symbol.iterator]();try{let{value:f,done:p}=l.next();if(p)throw new Error("singleFromAny: factory returned empty iterable");return f}finally{l.return?.()}})():d=Promise.resolve(a);let u,c=()=>{r.get(o)===u&&r.delete(o)};return u=d.then(l=>(c(),l),l=>{throw c(),l}),r.set(o,u),u}}function ba(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=ue(t(s));r.set(o,a);let d=a.subscribe(u=>{for(let c of u)if(c[0]===E||c[0]===N){r.get(o)===a&&r.delete(o),d();return}});return a}}Ce();function qt(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(qt);let e=t,n=Object.keys(e).sort(),r={};for(let s of n)r[s]=qt(e[s]);return r}function qn(t){return JSON.stringify(qt(t),void 0,0)}var ya=new TextEncoder,va=new TextDecoder("utf-8",{fatal:!0}),_t={name:"json",version:1,encode(t){return ya.encode(qn(t))},decode(t){return JSON.parse(va.decode(t))}};function Ta(){return _t}function Jt(){let t=new Map;return{name:"memory",read(e){let n=t.get(e);return n===void 0?void 0:new Uint8Array(n)},write(e,n){t.set(e,new Uint8Array(n))},delete(e){t.delete(e)},list(e){let n=[...t.keys()];return e?n.filter(r=>r.startsWith(e)).sort():n.sort()}}}function Jn(t,e={}){let n=e.codec??_t,r=e.name??t.name??"snapshot",s=e.keyOf??(l=>l.name??e.name??t.name??"snapshot"),o,i=0,a=e.compactEvery,d,u={name:r,debounceMs:e.debounceMs,compactEvery:a,filter:e.filter,keyOf:s,save(l){if(!(e.filter&&!e.filter(l))&&(o={snapshot:l},i+=1,a!==void 0&&i%a===0||!e.debounceMs))return c()},load(){let l=d??r,f=t.read(l);if(f!==void 0)return f instanceof Uint8Array?f.length===0?void 0:n.decode(f):Promise.resolve(f).then(p=>p===void 0||p.length===0?void 0:n.decode(p))},async flush(){await c()},async rollback(){o=void 0}};function c(){let l=o;if(!l)return;o=void 0;let f=s(l.snapshot),p=n.encode(l.snapshot),h=t.write(f,p);if(h instanceof Promise)return h.then(()=>{d=f});d=f}return u}function to(t,e={}){let n=e.codec??_t,r=e.name??t.name??"append-log",s=e.keyOf??(f=>r),o=e.compactEvery,i=new Map,a=0,d,u={name:r,debounceMs:e.debounceMs,compactEvery:o,keyOf:s,appendEntries(f){if(f.length!==0){for(let p of f){let h=s(p),m=i.get(h);m||(m=[],i.set(h,m)),m.push(p)}if(a+=f.length,o!==void 0&&a%o===0||!e.debounceMs)return c()}},async loadEntries(f){let p=f?.keyFilter,h=t.list===void 0?p!==void 0?[p]:[r]:await Promise.resolve(t.list(p)),m=[];for(let b of h){let g=await Promise.resolve(t.read(b));if(g===void 0||g.length===0)continue;let y=n.decode(g);Array.isArray(y)&&m.push(...y)}return{entries:m,cursor:void 0}},async flush(){await c()},async rollback(){i=new Map}};function c(){if(i.size===0)return;let f=i;i=new Map;let p=(d??Promise.resolve()).then(()=>{let h=l(f);return h instanceof Promise?h:Promise.resolve()},()=>{let h=l(f);return h instanceof Promise?h:Promise.resolve()});return d=p.finally(()=>{d===p&&(d=void 0)}),d}function l(f){let p=[];for(let[h,m]of f){let b=t.read(h),g=y=>{let w=[...y===void 0||y.length===0?[]:n.decode(y)??[],...m],_=n.encode(w);return t.write(h,_)};if(b instanceof Promise)p.push(b.then(async y=>{let v=g(y);v instanceof Promise&&await v}));else{let y=g(b);y instanceof Promise&&p.push(y)}}if(p.length>0)return Promise.all(p).then(()=>{})}return u}function Yn(t,e={}){let n=e.codec??_t,r=e.name??t.name??"kv",s=e.compactEvery,o=new Map,i=0,a={name:r,debounceMs:e.debounceMs,compactEvery:s,filter:e.filter,save(u,c){if(!(e.filter&&!e.filter(u,c))&&(o.set(u,c),i+=1,s!==void 0&&i%s===0||!e.debounceMs))return d()},load(u){let c=t.read(u);if(c!==void 0)return c instanceof Uint8Array?c.length===0?void 0:n.decode(c):Promise.resolve(c).then(l=>l===void 0||l.length===0?void 0:n.decode(l))},delete(u){if(o.delete(u),!!t.delete)return t.delete(u)},list(u){return t.list?t.list(u):[]},async flush(){await d()},async rollback(){o=new Map}};function d(){if(o.size===0)return;let u=o;o=new Map;let c=[];for(let[l,f]of u){let p=n.encode(f),h=t.write(l,p);h instanceof Promise&&c.push(h)}if(c.length>0)return Promise.all(c).then(()=>{})}return a}function wa(t){return Jn(Jt(),t)}function xa(t){return to(Jt(),t)}function ka(t){return Yn(Jt(),t)}function _a(t,e){let n={name:e?.name??"dict-kv",read(r){return t[r]},write(r,s){t[r]=new Uint8Array(s)},delete(r){delete t[r]},list(r){let s=Object.keys(t).sort();return r?s.filter(o=>o.startsWith(r)):s}};return Yn(n,e)}function Na(t,e){return Jn({name:"dict",read(r){return t[r]},write(r,s){t[r]=new Uint8Array(s)},delete(r){delete t[r]},list(r){let s=Object.keys(t).sort();return r?s.filter(o=>o.startsWith(r)):s}},e)}Z();be();de();gn();Te();Be();At();Z();At();be();function Yt(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 Sa(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function Ea(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function Qn(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=Sa(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={...Ea(t)};if(d!=null&&u.access===void 0&&(u.access=bn(d)),r!=null&&r.length>0&&!e.has("meta")){let c={};for(let l of r)l in u&&(c[l]=u[l]);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=bn(d)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}be();de();Ce();Dt();mn();function Xn(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 Qt(t){let e=0;for(let n of t)e+=Xn(n.codePointAt(0));return e}function no(t,e){if(e<=0)return"";let n=0,r="";for(let s of t){let o=Xn(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-=Xn(i.codePointAt(0))}return`${r}\u2026`}r+=s,n+=o}return r}var Oa={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"},Ra={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function io(t,e){let n=e.charset==="ascii"?Ra:Oa,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)Aa(o,i,n,a);for(let a of t.boxes)Ma(o,i,n,a,e.labelOf(a.id));return o.map(a=>Ia(a.join(""))).join(`
19
- `)}function Ma(t,e,n,r,s){let{x:o,y:i,w:a,h:d}=r;if(a<2||d<2){d>0&&ro(t,e,o,i,a,s);return}Ve(t,e,o,i,n.boxTL);for(let c=o+1;c<o+a-1;c+=1)Ve(t,e,c,i,n.boxH);Ve(t,e,o+a-1,i,n.boxTR);for(let c=i+1;c<i+d-1;c+=1){Ve(t,e,o,c,n.boxV);for(let l=o+1;l<o+a-1;l+=1)ao(t,e,l,c," ","empty");Ve(t,e,o+a-1,c,n.boxV)}Ve(t,e,o,i+d-1,n.boxBL);for(let c=o+1;c<o+a-1;c+=1)Ve(t,e,c,i+d-1,n.boxH);Ve(t,e,o+a-1,i+d-1,n.boxBR);let u=i+Math.floor(d/2);ro(t,e,o+1,u,a-2,s)}function Ve(t,e,n,r,s){ao(t,e,n,r,s,s===" "?"empty":s==="\u2500"||s==="-"?"boxH":s==="\u2502"||s==="|"?"boxV":"boxCorner")}function ao(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 ro(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=Qt(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 Aa(t,e,n,r){let s=r.points;if(s.length<2)return;for(let d=0;d+1<s.length;d+=1)Ca(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],l=s[d+1],f=Pa(u,c,l,n);f&&so(t,e,c.x,c.y,f,"edgeCorner")}let o=s[s.length-1],i=s[s.length-2],a=Da(i,o,n);a&&so(t,e,o.x,o.y,a,"arrow")}function Ca(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)oo(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)oo(t,e,o,d,n,"v")}}}function oo(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 so(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 Pa(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 Ia(t){let e=t.length;for(;e>0&&t.charCodeAt(e-1)===32;)e-=1;return t.slice(0,e)}function lo(t){let e=La(t);Ba(e),Va(e),Ga(e),Fa(e,t);let n=za(e,t),{width:r,height:s}=Wa(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 Ba(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 Va(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(l=>l!==o),a.in=a.in.filter(l=>l!==o);continue}if(d===1){o.hopIndex=0,o.chainLen=1,r.push(o);continue}i.out=i.out.filter(l=>l!==o),a.in=a.in.filter(l=>l!==o);let u=i;for(let l=1;l<d;l+=1){let f=`__virt_${s++}__`,p={id:f,isVirtual:!0,layer:i.layer+l,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};t.nodes.set(f,p),n[p.layer].push(p);let h={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:f,hopIndex:l-1,chainLen:d};u.out.push(h),p.in.push(h),r.push(h),u=p}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 Ga(t){for(let n=0;n<4;n+=1){for(let r=1;r<t.layers.length;r+=1)uo(t,t.layers[r],"in"),Xt(t.layers[r]);for(let r=t.layers.length-2;r>=0;r-=1)uo(t,t.layers[r],"out"),Xt(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=co(t,o[i],o[i+1],"in");[o[i],o[i+1]]=[o[i+1],o[i]],Xt(o),co(t,o[i],o[i+1],"in")<a?r=!0:([o[i],o[i+1]]=[o[i+1],o[i]],Xt(o))}}if(!r)break}}function uo(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 Xt(t){for(let e=0;e<t.length;e+=1)t[e].order=e}function co(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 Fa(t,e){e.direction==="LR"?$a(t,e):Ka(t,e)}function $a(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}fo(t,e,"y")}function Ka(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}fo(t,e,"x")}function fo(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 l=o===0?c.in:c.out;if(l.length===0)continue;let f=[];for(let h of l){let m=t.nodes.get(o===0?h.fromId:h.toId);if(!m)continue;let b=n==="y"?m.y:m.x;f.push(b+Math.floor(r(m)/2))}if(f.length===0)continue;f.sort((h,m)=>h-m);let p=f[Math.floor(f.length/2)];d.set(c.id,p-Math.floor(r(c)/2))}let u=0;for(let c of a){let l=d.get(c.id),f=n==="y"?c.y:c.x,h=Math.max(l??f,u);n==="y"?c.y=h:c.x=h,u=h+r(c)+s}}}}function za(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,l)=>c.hopIndex-l.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],l=t.layers[u+1],f=0;for(let S of c)f=Math.max(f,s(S)+o(S));let p=Number.POSITIVE_INFINITY;for(let S of l)p=Math.min(p,s(S));let h=Number.isFinite(p)?p-1:f,m=Math.max(1,h-f+1),b=[];for(let S of c)for(let O of S.out)b.push(O);b.sort((S,O)=>{let M=i(t.nodes.get(S.fromId)),C=i(t.nodes.get(O.fromId));if(M!==C)return M-C;let D=i(t.nodes.get(S.toId)),R=i(t.nodes.get(O.toId));return D-R});let g=[],y=new Map;for(let S of b){let O=i(t.nodes.get(S.fromId)),M=i(t.nodes.get(S.toId)),C=Math.min(O,M),D=Math.max(O,M),R=-1;for(let V=0;V<g.length;V+=1){let Q=g[V],K=!0;for(let te of Q)if(te.lo<=D&&C<=te.hi){K=!1;break}if(K){Q.push({lo:C,hi:D}),R=V;break}}R<0&&(g.push([{lo:C,hi:D}]),R=g.length-1),y.set(S,R)}let v=g.length,w=m>=Math.max(3,v+2),_=w?f+1:f,k=w?h-1:h,T=Math.max(1,k-_+1);for(let S of b){let O=y.get(S),M;if(v<=1)M=_+Math.floor(T/2);else{let C=(T-1)/(v-1);M=_+Math.floor(O*C)}a.set(S,Math.max(f,Math.min(h,M)))}}let d=[];for(let[,u]of n){let c=[];for(let f=0;f<u.length;f+=1){let p=u[f],h=t.nodes.get(p.fromId),m=t.nodes.get(p.toId),b=a.get(p),g=h.isVirtual?s(h):s(h)+o(h),y=m.isVirtual?s(m):s(m)-1,v=i(h),w=i(m);f===0&&Zt(c,r,g,v),v!==w&&(Zt(c,r,b,v),Zt(c,r,b,w)),Zt(c,r,y,w)}let l=u[0];d.push({from:l.chainFrom,to:l.chainTo,points:ja(c)})}return d}function Zt(t,e,n,r){t.push(e?{x:n,y:r}:{x:r,y:n})}function ja(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 Wa(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 Ha=24,Ua=4,qa=1,Ja=3;function po(t,e){let n=Ya(e.direction),r=Math.max(3,e.maxLabelWidth??Ha),s=e.asciiCharset??"unicode",o=Object.keys(t.nodes).sort(),i=new Set(o),a=t.edges.filter(p=>i.has(p.from)&&i.has(p.to)),d=new Map,u=new Map;for(let p of o){let h=no(p,r);d.set(p,h),u.set(p,Qt(h)+4)}let c=lo({nodes:o,edges:a,widthCells:p=>u.get(p)??3,heightCells:()=>Ja,layerGap:Ua,nodeGap:qa,direction:n}),l=io(c,{charset:s,labelOf:p=>d.get(p)??p}),f=e.logger;return f&&f(l),l}function Ya(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 ho(t,e,n,r={}){let s=e in t.nodes,o=n in t.nodes;if(!s)return en(e,n,"no-such-from");if(!o)return en(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=Qa(t,e,r);if(u!=null)return u}let d=tn(e,t.nodes[e],0,r);return nn(e,n,[d])}if(i===0)return en(e,n,"no-path");let a=mo(t,e,n,i);return a.found?nn(e,n,go(t,a.pathOrder,r)):en(e,n,a.truncated?"max-depth-exceeded":"no-path")}function mo(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 l=o[a++];if(l.path===e)break;if(r!=null&&l.depth>=r){let m=t.nodes[l.path];m?.deps&&m.deps.length>0&&(d=!0);continue}let f=t.nodes[l.path];if(f==null)continue;let p=f.deps??[],h=new Map;for(let m=0;m<p.length;m++){let b=p[m];if(!b)continue;let g=h.get(b);g==null&&(g=[],h.set(b,g)),g.push(m)}for(let[m,b]of h)i.has(m)||(i.add(m),s.set(m,{from:l.path,depIndices:b}),o.push({path:m,depth:l.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:d};let u=[{path:e}],c=e;for(;c!==n;){let l=s.get(c);if(l==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=l.depIndices,u.push({path:l.from}),c=l.from}return{found:!0,pathOrder:u,truncated:!1}}function Qa(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=tn(e,r,0,n);a.dep_index=o[0];let d=tn(e,r,1,n);return nn(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=mo(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:nn(e,e,go(t,i.pathOrder,n))}function go(t,e,n){return e.map((r,s)=>{let o=t.nodes[r.path],i=tn(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 tn(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 nn(t,e,n){return bo(t,e,!0,"ok",n)}function en(t,e,n){return bo(t,e,!1,n,[])}function bo(t,e,n,r,s){let o=Xa(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 Xa(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: ${Za(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 Za(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)}}be();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},eu=Symbol.for("sizeof");function yo(t){let e=new WeakSet,n=new WeakSet,r=[t],s=0;for(;r.length>0;){let o=r.pop();s+=tu(o,e,n,r)}return s}function tu(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+nu(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[eu];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,l]of o)u+=se.mapEntry,r.push(c),r.push(l);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 nu(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 vo(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[f,p]of s)i.set(f,p);let a=[];for(let[f,p]of Object.entries(r.nodes)){let h=i.get(f),m=h instanceof oe?h:null,b=m?yo(m.cache):0,g=m?m._sinkCount:0,y=p.deps?.length??0,v=p.type==="effect"&&g===0,w=g===0?p.type==="effect"?"orphan-effect":p.type==="derived"?"idle-derived":p.type==="producer"?"idle-producer":null:null;a.push({path:f,type:p.type,status:p.status??"unknown",valueSizeBytes:b,subscriberCount:g,depCount:y,isOrphanEffect:v,orphanKind:w})}let d=a.reduce((f,p)=>f+p.valueSizeBytes,0),u=(f,p)=>[...a].sort(p??((h,m)=>m[f]-h[f])).slice(0,n),c=a.filter(f=>f.orphanKind!=null),l=a.filter(f=>f.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:l}}var ee="::",Me="__meta__",dt=1;function To(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 ru(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 wo(t){if(t.version!==dt)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${dt})`);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 ou(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 f=o;if(s.length!==f.length)return!1;for(let p=0;p<s.length;p++)if(!r(s[p],f[p]))return!1;return!0}if(s instanceof Map){let f=o;if(s.size!==f.size)return!1;for(let[p,h]of s)if(!f.has(p)||!r(h,f.get(p)))return!1;return!0}if(s instanceof Set){let f=o;if(s.size!==f.size)return!1;for(let p of s){let h=!1;for(let m of f)if(r(p,m)){h=!0;break}if(!h)return!1}return!0}if(ArrayBuffer.isView(s)){let f=s,p=o;if(f.length!==p.length)return!1;for(let h=0;h<f.length;h++)if(f[h]!==p[h])return!1;return!0}let u=Object.keys(s),c=Object.keys(o);if(u.length!==c.length)return!1;let l=new Set(c);for(let f of u)if(!l.has(f)||!r(s[f],o[f]))return!1;return!0};return r(t,e)}function er(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(er);let e=t,n=Object.keys(e).sort(),r={};for(let s of n)r[s]=er(e[s]);return r}function su(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function iu(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function au(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function _o(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 No(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 uu(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(er(i),null,e.indent??2);return e.logger?.(a),a}function du(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}): ${on(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 So(t,e){let n=No(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}["${su(i)}"]`)}for(let[i,a]of _o(t)){let d=s.get(i),u=s.get(a);!d||!u||o.push(` ${d} --> ${u}`)}return o.join(`
23
- `)}function cu(t,e){let n=So(t,e);return lu(n)}function lu(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 fu(t,e){let n=No(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: ${au(n)}`];for(let i of r){let a=s.get(i);o.push(`${a}: "${iu(i)}"`)}for(let[i,a]of _o(t)){let d=s.get(i),u=s.get(a);!d||!u||o.push(`${d} -> ${u}`)}return o.join(`
24
- `)}function pu(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rn(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+=pu(r)}return e+="$",new RegExp(e)}var hu={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"},mu={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function on(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 gu(t){return t==="none"?mu:t==="ansi"||t==null?hu:{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 xo(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 bu(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 Zn(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(ee))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${ee}' (path separator)`);if(t===Me)throw new Error(`Graph "${e}": ${n} name "${Me}" is reserved for meta companion paths`);bu(t,e,n)}function yu(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(ee);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function vu(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 Eo(t){for(let e of t._mounts.values())Eo(e);for(let e of t._nodes.values())try{e.down([[z]],{internal:!0})}catch{}}var Nt=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(ee))throw new Error(`Graph name must not contain '${ee}' (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=A(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)}nameOf(e){return this._nodeToName.get(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(Zn(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){Zn(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(`${ee}${Me}${ee}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...n._collectSubgraphs(`${e}${ee}`)),this._mounts.delete(e),n._parent=void 0,Eo(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([[z]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let n=typeof e=="function"?e:(()=>{let o=rn(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(ee))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([[x,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([[we]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let s=r?.internal===!0;this.node(e).down([[E,n]],{actor:r?.actor,internal:s,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[N]],{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 l=r.get(c.node);l!=null&&a.push([l,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(n===void 0){let s=new t(e);return this.mount(e,s)}if(typeof n=="function"){let s=new t(e);return n(s),this.mount(e,s)}let r=n;if(Zn(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(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===r)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,r),r._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),r}resolve(e){let n=yu(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(ee));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(ee)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(s.join(ee))}_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=vu(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 Se)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 Se)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=Yt(e?.detail,e?.fields),o=e?.format==="spec",i=o?Yt("minimal"):s,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[k,T]of a)d.set(T,k);let u=[];{let k=a.map(([,O])=>O),T=new Set(d.values()),S=0;for(;k.length>0;){let O=k.shift();if(O instanceof oe)for(let M of O._deps){let C=M.node;if(d.has(C))continue;let D=C.name??"",R=D;if(!R||T.has(R))if(D){let V=2;for(;T.has(`${D}#${V}`);)V++;R=`${D}#${V}`}else for(R=`__internal__/${S++}`;T.has(R);)R=`__internal__/${S++}`;d.set(C,R),T.add(R),u.push([R,C]),k.push(C)}}}let c=[...a,...u],l={};for(let[k,T]of c){if(n!=null&&!T.allowsObserve(n))continue;let S=Qn(T,i),O=T instanceof oe?T._deps.map(R=>d.get(R.node)??R.node.name??""):[],{name:M,...C}=S,D={...C,deps:O};if(!o){let R=this._annotations.get(k);R!=null&&(D.annotation=R)}if(r!=null)if(typeof r=="function"){let R=r;if(!(R.length>=2?R(k,D):R(D)))continue}else{let R=!0;for(let[V,Q]of Object.entries(r)){let K=V==="deps_includes"?"depsIncludes":V==="meta_has"?"metaHas":V;if(K==="depsIncludes"){if(!D.deps.includes(String(Q))){R=!1;break}continue}if(K==="metaHas"){if(!Object.hasOwn(D.meta??{},String(Q))){R=!1;break}continue}if(D[K]!==Q){R=!1;break}}if(!R)continue}l[k]=D}let f=new Set(Object.keys(l)),p=[];for(let[k,T]of c)if(T instanceof oe)for(let S of T._deps){let O=d.get(S.node);O!=null&&p.push([O,k])}p.sort((k,T)=>k[0]<T[0]?-1:k[0]>T[0]?1:k[1]<T[1]?-1:k[1]>T[1]?1:0);let h=p.map(([k,T])=>({from:k,to:T}));(n!=null||r!=null)&&(h=h.filter(k=>f.has(k.from)&&f.has(k.to)));let m=this._collectSubgraphs(""),b=n!=null||r!=null?m.filter(k=>{let T=`${k}${ee}`;return[...f].some(S=>S===k||S.startsWith(T))}):m,g=this,y=e,v={name:this.name,nodes:l,edges:h,subgraphs:b,expand(k){let T={...y,format:void 0};return Array.isArray(k)?(T.fields=k,T.detail=void 0):(T.detail=k,T.fields=void 0),g.describe(T)}},w=e??{},_=w.format;return _==="json"?uu(v,w):_==="pretty"?du(v,w):_==="mermaid"?So(v,w):_==="mermaid-url"?cu(v,w):_==="d2"?fu(v,w):_==="ascii"?po(v,w):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}${ee}`))}return n}resourceProfile(e){return vo(this,e)}reachable(e,n,r={}){return r.withDetail===!0?ko(this.describe(),e,n,{...r,withDetail:!0}):ko(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 ho(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,mt(()=>{a=!1,!d&&(s+=1,o.emit(s))}))},c=i.onEvent(b=>{let g=b.type;g!=="data"&&g!=="error"&&g!=="complete"&&g!=="teardown"||u()}),l=[],f=new WeakSet,p=b=>{if(f.has(b)||d)return;f.add(b);let g=b.topology.subscribe(y=>{for(let v of y){if(v[0]!==x)continue;let w=v[1];if(u(),w.kind==="added"&&w.nodeKind==="mount"){let _=b._mounts.get(w.name);_!=null&&p(_)}}});l.push(g);for(let y of b._mounts.keys()){let v=b._mounts.get(y);v!=null&&p(v)}};p(this);let h;try{h=fe([o],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,g)=>b===g})}catch(b){c();for(let g of l)g();throw i.dispose(),b}let m=st(h);return{node:h,dispose(){d=!0,c();for(let b of l)b();l.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(p=>{let h=p.type;h!=="data"&&h!=="error"&&h!=="complete"&&h!=="teardown"||a||d||(a=!0,mt(()=>{a=!1,!d&&(s+=1,o.emit(s))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},l;try{l=fe([o],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(p,h)=>p.found===h.found&&p.reason===h.reason&&p.steps.length===h.steps.length&&wu(p.steps,h.steps)})}catch(p){throw u(),i.dispose(),p}let f=st(l);return{node:l,dispose(){d=!0,u(),i.dispose(),f()}}}_pathsMatching(e){let n=rn(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}${ee}${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}${ee}${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}${ee}${Me}${ee}${s}`;r.push([i,o]),this._appendMetaObserveTargets(i,o,r)}}observe(e,n){let r=typeof e=="string",o=xo(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,l=this.resolve(c);if(a!=null&&!l.allowsObserve(a))throw new Se({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,l]],o,"one"):{subscribe(f){return l.subscribe(f)},up(f){try{l.up?.(f)}catch(p){if(p instanceof Se)return;throw p}}}}let d=[];this._collectObserveTargets("",d),d.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let u=a==null?d:d.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,o,"all"):{subscribe:c=>{let l=u.map(([f,p])=>p.subscribe(h=>{c(f,h)}));return()=>{for(let f of l)f()}},up:(c,l)=>{try{this.resolve(c).up?.(l)}catch(f){if(f instanceof Se)return;throw f}}}}_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,l)=>c[0]<l[0]?-1:c[0]>l[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,l=c!=null&&c>0?new qe(c):null,f=[],p=new Set,h={},m=new Set,b=0,g=0,y=0,v=0,w=0,_=0,k=!1,T=!1,S=0,O=new Map,M=new Map,C=new Map,D=L=>{l?l.push(L):f.push(L);for(let q of p)q(L)},R=()=>s?{timestamp_ns:ne(),in_batch:Et(),batch_id:S}:{},V=(L,q)=>{if(!(!u||!(L instanceof oe)))return L._setInspectorHook(he=>{if(he.kind==="dep_message")O.set(L,he.depIndex);else if(he.kind==="run"){let Fe=he.batchData.map((U,ce)=>U!=null&&U.length>0?U.at(-1):he.prevData[ce]);M.set(L,Fe);let ve=he.batchData.map(U=>U!=null?[...U]:void 0);C.set(L,ve),i&&D({type:"derived",path:q,dep_values:Fe,dep_batches:ve,...R()})}})},Q=L=>{let q=O.get(L),he=M.get(L);if(!o||he==null)return{};let ve=(q!=null&&q>=0&&L instanceof oe?L._deps[q]:void 0)?.node,U=ve?.v,ce=C.get(L);return{trigger_dep_index:q,trigger_dep_name:ve?.name,...U!=null?{trigger_version:{id:U.id,version:U.version}}:{},dep_values:[...he],...ce!=null?{dep_batches:ce}:{}}},K=[],te=[];for(let[L,q]of e){let he=V(q,L);he&&K.push(he),te.push(q.subscribe(Fe=>{S++;for(let ve of Fe){let U=ve[0],ce=R();if(U===x){h[L]=ve[1];let Ie=q instanceof oe?q.lastMutation?.actor??et:et;D({type:"data",path:L,data:ve[1],actor:Ie,...ce,...Q(q)})}else if(a)U===$?b++:U===P?g++:U===we?y++:U===ge?v++:U===xe?w++:U===z?_++:U===N&&!m.has(L)?k=!0:U===E&&(T=!0,m.add(L));else if(U===$)b++,D({type:"dirty",path:L,...ce});else if(U===P)g++,D({type:"resolved",path:L,...ce,...Q(q)});else if(U===we)y++,D({type:"invalidate",path:L,...ce});else if(U===ge)v++,D({type:"pause",path:L,lockId:ve[1],...ce});else if(U===xe)w++,D({type:"resume",path:L,lockId:ve[1],...ce});else if(U===N)m.has(L)||(k=!0),D({type:"complete",path:L,...ce});else if(U===E){T=!0,m.add(L);let Ie=q instanceof oe?q.lastMutation?.actor??et:et;D({type:"error",path:L,data:ve[1],actor:Ie,...ce})}else U===z&&(_++,D({type:"teardown",path:L,...ce}))}}))}let ke=!1,De=()=>{if(!ke){ke=!0;for(let L of te)L();for(let L of K)L();for(let L of ye)L({value:void 0,done:!0});ye.length=0}},Ne=[],ye=[];p.add(L=>{let q=ye.shift();q?q({value:L,done:!1}):Ne.push(L)});let Ge={get values(){return h},get dirtyCount(){return b},get resolvedCount(){return g},get invalidateCount(){return y},get pauseCount(){return v},get resumeCount(){return w},get teardownCount(){return _},get events(){return l?l.toArray():[...f]},get anyCompletedCleanly(){return k},get anyErrored(){return T},get completedWithoutErrors(){return k&&!T},onEvent(L){return p.add(L),()=>p.delete(L)},dispose:De,expand(L){De();let q={...n};return typeof L=="string"?q.detail=L:Object.assign(q,L),r(xo(q))},[Symbol.asyncIterator](){return{next(){return Ne.length>0?Promise.resolve({value:Ne.shift(),done:!1}):ke?Promise.resolve({value:void 0,done:!0}):new Promise(L=>ye.push(L))},return(){return De(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Ge,n),Ge}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let s=n.logger??(h=>console.log(h)),o=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=o==null&&i==null?()=>!0:h=>(o==null||o.has(h))&&(i==null||!i.has(h)),d=gu(n.theme),u=r==="stage-log"?ne():0,c=h=>h==null?"":n.stageLabels?.[h]??h,l=(h,m)=>h.length>m?`${h.slice(0,m-1)}\u2026`:h,f=h=>h.type==="data"||h.type==="error"?l(on(h.data),120):"",p=h=>{if(r==="stage-log"){let T=(ne()-u)/1e9,S=c(h.path).padEnd(9);if(h.type==="data"){let O=f(h);return`[${T.toFixed(3)}s] ${S} \u2190${O?` ${O}`:""}`}if(h.type==="error"){let O=f(h);return`[${T.toFixed(3)}s] ${S} \u2717${O?` ${O}`:""}`}return h.type==="complete"?`[${T.toFixed(3)}s] ${S} \u25A0 complete`:`[${T.toFixed(3)}s] ${S} ${h.type}`}if(r==="json")try{return JSON.stringify(h)}catch{return JSON.stringify({type:h.type,path:h.path,data:"[unserializable]"})}let m=d[h.type]??"",b=h.path?`${d.path}${h.path}${d.reset} `:"",g=h.type==="data"||h.type==="error",y=h.type==="pause"||h.type==="resume",v=g?` ${on(h.data)}`:y?` ${on(h.lockId)}`:"",w=h.type==="data"||h.type==="resolved"||h.type==="derived"?h:void 0,_=w?.trigger_dep_name!=null?` <- ${w.trigger_dep_name}`:w?.trigger_dep_index!=null?` <- #${w.trigger_dep_index}`:"",k=h.in_batch?" [batch]":"";return`${b}${m}${h.type.toUpperCase()}${d.reset}${v}${_}${k}`};e.onEvent(h=>{a(h.type)&&s(p(h),h)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){To(this._disposers,this.name),this.signal([[z]],{internal:!0}),To(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand: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 dr(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}=cr(e,r);return s.decode(i,o)}restore(e,n){if(wo(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=>rn(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){wo(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 p of[...e.subgraphs].sort((h,m)=>{let b=h.split(ee).length,g=m.split(ee).length;return b!==g?b-g:h<m?-1:h>m?1:0})){let h=p.split(ee),m=o;for(let b of h)m._mounts.has(b)||m.mount(b,new t(b)),m=m._mounts.get(b)}let i=s?Object.entries(s).map(([p,h])=>({re:rn(p),factory:h})):[],a=p=>{for(let h of i)if(h.re.test(p))return h.factory},d=p=>{let h=p.split(ee),m=h.pop();if(m==null||m.length===0)throw new Error(`invalid snapshot path "${p}"`);let b=o;for(let g of h){let y=b._mounts.get(g);if(!y)throw new Error(`unknown mount "${g}" in path "${p}"`);b=y}return[b,m]},u=Object.entries(e.nodes).filter(([p])=>!p.includes(`${ee}${Me}${ee}`)).sort((p,h)=>p[0]<h[0]?-1:p[0]>h[0]?1:0),c=new Map(u),l=new Map,f=!0;for(;c.size>0&&f;){f=!1;for(let[p,h]of[...c.entries()]){let m=h?.deps??[];if(!m.every(_=>l.has(_)))continue;let[b,g]=d(p),y={...h?.meta??{}},v=a(p),w;if(h?.type==="state")w=F(h.value,{meta:y});else{if(v==null)continue;w=v(g,{path:p,type:h.type,value:h.value,meta:y,deps:m,resolvedDeps:m.map(_=>l.get(_))})}b.add(w,{name:g}),l.set(p,w),c.delete(p),f=!0}}if(c.size>0){let p=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${p}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachSnapshotStorage(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 l=ru(c.nodes);if(u.lastSnapshot!=null&&l!==""&&l===u.lastFingerprint)return;let f=u.seq+1,p=re(),b=u.lastSnapshot==null||f%u.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:f,timestamp_ns:p,format_version:dt}:{name:this.name,mode:"diff",diff:Tu(u.lastSnapshot,c),seq:f,timestamp_ns:p,format_version:dt};if(u.tier.filter&&!u.tier.filter(b))return;let g;try{g=u.tier.save(b)}catch(y){n.onError?.(y,u.tier);return}if(g&&typeof g.then=="function"){let w=(u.savePending??Promise.resolve()).then(()=>g,()=>g).then(()=>{u.disposed||(u.seq=f,u.lastSnapshot=c,u.lastFingerprint=l)},_=>{n.onError?.(_,u.tier)});u.savePending=w.finally(()=>{u.savePending===w&&(u.savePending=void 0)})}else u.seq=f,u.lastSnapshot=c,u.lastFingerprint=l},o=(u,c)=>{try{s(u,c)}catch(l){n.onError?.(l,u.tier)}},i=(u,c)=>{if(!c.some(h=>{let m=this.config.messageTier(h[0]);return m>=3&&m<5}))return;if(n.filter){let h=this.tryResolve(u);if(h==null)return;let m=Qn(h,Yt("standard"));if(!n.filter(u,m))return}let f,p=()=>(f==null&&(f=this.snapshot()),f);for(let h of r)h.disposed||(h.debounceMs===0?o(h,p()):(h.timer==null&&(h.timer=new Oe),h.timer.start(h.debounceMs,()=>{h.disposed||o(h,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(l=>{let f=this.tryResolve(l);return f==null?()=>{}:f.subscribe(p=>i(l,p))});a=()=>{for(let l of c)l()}}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?.()}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===dt&&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?.()}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===dt&&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],w=n.nodes[y],_=v.v,k=w.v;_!=null&&k!=null&&_.id===k.id&&_.version!==k.version&&d.push({path:y,id:_.id,from:_.version,to:k.version});let T=_!=null&&k!=null&&_.id===k.id&&_.version===k.version;for(let S of["type","status","sentinel"]){let O=v[S],M=w[S];O!==M&&a.push({path:y,field:S,from:O,to:M})}if(!T)for(let S of["value","meta"]){let O=v[S],M=w[S];ou(O,M)||a.push({path:y,field:S,from:O,to:M})}}let u=y=>`${y.from} ${y.to}`,c=new Set(e.edges.map(u)),l=new Set(n.edges.map(u)),f=n.edges.filter(y=>!c.has(u(y))),p=e.edges.filter(y=>!l.has(u(y))),h=new Set(e.subgraphs),m=new Set(n.subgraphs),b=[...m].filter(y=>!h.has(y)).sort(),g=[...h].filter(y=>!m.has(y)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:f,edgesRemoved:p,subgraphsAdded:b,subgraphsRemoved:g}}};function Tu(t,e){let n=Nt.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 ko(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,w]of Object.entries(t.nodes)){if(!v)continue;c.add(v);let _=w.deps??[];i.set(v,_);for(let k of _)k&&(c.add(k),a.has(k)||a.set(k,new Set),a.get(k).add(v))}for(let v of t.edges){if(v==null||typeof v!="object")continue;let w=typeof v.from=="string"?v.from:"",_=typeof v.to=="string"?v.to:"";!w||!_||(c.add(w),c.add(_),u.has(w)||u.set(w,new Set),u.get(w).add(_),d.has(_)||d.set(_,new Set),d.get(_).add(w))}if(!c.has(e))return r.withDetail?s:[];let l=r.both===!0,f=v=>{if(l){let T=i.get(v)??[],S=d.get(v),O=a.get(v),M=u.get(v),C=[...T];return S&&C.push(...S),O&&C.push(...O),M&&C.push(...M),C}if(n==="upstream"){let T=i.get(v)??[],S=d.get(v);return S?[...T,...S]:T}let w=a.get(v),_=u.get(v),k=w?[...w]:[];return _&&k.push(..._),k},p=new Set([e]),h=new Map,m=[{path:e,depth:0}],b=0,g=!1;for(;b<m.length;){let v=m[b++];if(o!=null&&v.depth>=o){f(v.path).length>0&&(g=!0);continue}for(let w of f(v.path))!w||p.has(w)||(p.add(w),h.set(w,v.depth+1),m.push({path:w,depth:v.depth+1}))}let y=[...h.keys()].sort((v,w)=>v<w?-1:v>w?1:0);return r.withDetail?{paths:y,depths:h,truncated:g}:y}function wu(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 xu(t,e,n,r){let s=new Nt(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)ku(s,e,o,i);return s}function ku(t,e,n,r){let s=`branch/${r.name}`,o=Symbol("noValue"),i=!1,a=!1,d=!1,u=o,c=!1,l=n.cache??[];function f(m){if(d){d=!1;let b=u;if(u=o,b!==o){let g=l.find(v=>v.name===r.name),y=!1;try{y=g?.classify(b)??!1}catch{y=!1}y?(c=!1,m.emit(b)):c&&(c=!1,m.down([[$],[P]]))}else c?(c=!1,m.down([[$],[P]])):m.down([[P]])}}let p=B([],(m,b)=>{let g=e.subscribe(v=>{for(let w of v)h(w,0,b)}),y=n.subscribe(v=>{for(let w of v)h(w,1,b)});return()=>{g(),y()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:r.name},completeWhenDepsComplete:!1});function h(m,b,g){let y=m[0];return y===$?(b===0?(i=!0,c=!0):a=!0,!0):y===x||y===P?(b===0?(i=!1,d=!0,u=y===x?m[1]:o):(y===x&&(l=m[1]),a=!1),i||a||f(g),!0):y===N||y===E||y===z?(i=!1,a=!1,d=!1,u=o,c=!1,b===0&&g.down([m]),!0):b===1}if(t.add(p,{name:s}),r.ops){let m=r.ops(p),b=`branch/${r.name}/out`;t.add(m,{name:b})}}Dt();Te();Z();be();de();Ce();Z();var _u=new Map([[we,"INVALIDATE"],[ge,"PAUSE"],[xe,"RESUME"],[z,"TEARDOWN"],[N,"COMPLETE"],[E,"ERROR"]]),Nu=new Map([["INVALIDATE",we],["PAUSE",ge],["RESUME",xe],["TEARDOWN",z],["COMPLETE",N],["ERROR",E]]);function Je(t){let e=_u.get(t);return e||(Symbol.keyFor(t)??"UNKNOWN")}function ct(t){let e=Nu.get(t);if(e)return e;if(t&&t!=="UNKNOWN")return Symbol.for(t)}function lt(t){return t instanceof Error?{message:t.message,name:t.name,stack:t.stack}:{message:String(t),name:"Error"}}function ft(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 Su(t){return typeof t=="object"&&t!==null&&typeof t.post=="function"&&typeof t.listen=="function"}function Oo(t,e){let n=Su(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 l;if(s.length>0){let y=s.map(([,_])=>_),v=B(y,(_,k)=>{let T={};for(let S=0;S<s.length;S++){let[O]=s[S],M=_[S];M!=null&&M.length>0&&(T[O]=M.at(-1))}Object.keys(T).length!==0&&k.emit(T)},{name:`${r}::aggregated`,partial:!0});l=Pt([v],_=>{let k=_[0];if(k==null||Object.keys(k).length===0)return;let T=[];for(let M of Object.keys(k)){let C=i[M];C&&T.push(...C(k[M]))}let S;for(let[M,C]of s)M in k&&C.v!=null&&(S==null&&(S={}),S[M]=C.v.version);let O={t:"b",u:k,...S?{v:S}:{}};try{n.post(O,T.length>0?T:void 0)}catch(M){d.down([[x,M instanceof Error?M:new Error(String(M))]])}}).subscribe(()=>{})}let f=!1,p=n.listen(y=>{if(f)return;let v=y;switch(v.t){case"r":{j(()=>{for(let[_,k]of Object.entries(v.stores)){let T=u.get(_);T&&T.down([[x,k]])}}),a.down([[x,"connected"]]);let w={};for(let[_,k]of s)w[_]=k.cache;n.post({t:"i",stores:w});break}case"v":{let w=u.get(v.s);w&&w.down([[x,v.d]]);break}case"b":{j(()=>{for(let[w,_]of Object.entries(v.u)){let k=v.v?.[w];if(k!=null){let S=c.get(w);if(S!=null&&k<=S)continue;c.set(w,k)}let T=u.get(w);T&&T.down([[x,_]])}});break}case"e":{let w=u.get(v.s);w&&w.down([[E,ft(v.err)]]);break}case"s":{let w=ct(v.sig);if(!w)break;let _=v.s==="*"?[...u.values()]:u.has(v.s)?[u.get(v.s)]:[];for(let k of _)k.down(v.d===void 0?[[w]]:[[w,v.d]]);break}}}),h=[];for(let[y,v]of s){let w=v.subscribe((_=>{if(!f)for(let k of _){let T=k[0];T!==x&&(le.isLocalOnly(T)||(T===E?n.post({t:"e",s:y,err:lt(k[1])}):n.post({t:"s",s:y,sig:Je(T),d:k.length>1?k[1]:void 0})))}}));h.push(w)}let m;if(e.timeoutMs!=null&&e.timeoutMs>0){let y=He(e.timeoutMs),v=Gt(a,_=>_==="connected");m=Kn(Tt(Vt(y,()=>"timeout"),Vt(v,()=>"ready"))).subscribe(_=>{for(let k of _)k[0]===x&&k[1]==="timeout"&&(d.down([[x,new Error("Worker bridge handshake timeout")]]),b())})}function b(){if(!f){f=!0,m?.(),n.post({t:"s",s:"*",sig:Je(z)}),l&&l();for(let y of h)y();h.length=0,p(),a.down([[x,"closed"]]),c.clear(),u.clear()}}let g={meta:{status:a,error:d},destroy:b};for(let[y,v]of u)g[y]=v;return g}Te();Z();be();de();function Eu(t){return typeof t=="object"&&t!==null&&typeof t.post=="function"&&typeof t.listen=="function"}function Ro(t,e){let n=Eu(t)?t:Ye(t),r=e.import??[],s=e.transfer??{},o=new Map,i=new Map,a={};for(let b of r){let g=F(void 0,{name:`worker::${b}`});o.set(b,g),a[b]=g}let d=e.expose(a),u=Object.entries(d),c,l=!1;if(u.length>0){let b=u.map(([,v])=>v),g=B(b,(v,w)=>{let _={};for(let k=0;k<u.length;k++){let[T]=u[k],S=v[k];S!=null&&S.length>0&&(_[T]=S.at(-1))}Object.keys(_).length!==0&&w.emit(_)},{name:"workerSelf::aggregated",partial:!0});c=Pt([g],v=>{if(l)return;let w=v[0];if(w==null||Object.keys(w).length===0)return;let _=[];for(let S of Object.keys(w)){let O=s[S];O&&_.push(...O(w[S]))}let k;for(let[S,O]of u)S in w&&O.v!=null&&(k==null&&(k={}),k[S]=O.v.version);let T={t:"b",u:w,...k?{v:k}:{}};try{n.post(T,_.length>0?_:void 0)}catch{}}).subscribe(()=>{})}let f=[];for(let[b,g]of u){let y=g.subscribe((v=>{if(!l)for(let w of v){let _=w[0];_!==x&&(le.isLocalOnly(_)||(_===E?n.post({t:"e",s:b,err:lt(w[1])}):n.post({t:"s",s:b,sig:Je(_),d:w.length>1?w[1]:void 0})))}}));f.push(y)}let p=n.listen(b=>{if(l)return;let g=b;switch(g.t){case"i":{j(()=>{for(let[y,v]of Object.entries(g.stores)){let w=o.get(y);w&&w.down([[x,v]])}});break}case"v":{let y=o.get(g.s);y&&y.down([[x,g.d]]);break}case"b":{j(()=>{for(let[y,v]of Object.entries(g.u)){let w=g.v?.[y];if(w!=null){let k=i.get(y);if(k!=null&&w<=k)continue;i.set(y,w)}let _=o.get(y);_&&_.down([[x,v]])}});break}case"e":{let y=o.get(g.s);y&&y.down([[E,ft(g.err)]]);break}case"s":{let y=ct(g.sig);if(!y)break;if(y===z&&g.s==="*"){m();return}let v=g.s==="*"?[...o.values()]:o.has(g.s)?[o.get(g.s)]:[];for(let w of v)w.down(g.d===void 0?[[y]]:[[y,g.d]]);break}}}),h={};for(let[b,g]of u)h[b]=g.cache;n.post({t:"r",stores:h});function m(){if(!l){l=!0,c&&c();for(let b of f)b();f.length=0,p(),n.terminate?.(),i.clear(),o.clear()}}return{destroy:m}}0&&(module.exports={CircuitOpenError,ContentAddressedMissError,NS_PER_MS,NS_PER_SEC,NativeIndexBackend,NativeListBackend,NativeLogBackend,NativeMapBackend,NativePubSubBackend,RateLimiterOverflowError,ResettableTimer,TimeoutError,appendLogStorage,audit,awaitSettled,buffer,bufferCount,bufferTime,cached,canonicalJson,cascadingCache,catchError,checkpointToRedis,checkpointToS3,circuitBreaker,combine,combineLatest,concat,concatMap,constant,contentAddressedStorage,createTransport,createWatermarkController,csvRows,debounce,debounceTime,decorrelatedJitter,defer,delay,deserializeError,dictKv,dictSnapshot,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,jsonCodec,jsonCodecFor,keepalive,kvStorage,last,linear,lru,makeHttpError,map,matchesAnyPattern,matchesCron,memoryAppendLog,memoryBackend,memoryKv,memorySnapshot,merge,mergeMap,mergeReactiveLogs,nameToSignal,ndjsonRows,never,nodeSignal,of,onFirstData,pairwise,parseCron,parsePrometheusText,parseSSEStream,parseStatsD,parseSyslog,pausable,pubsub,race,rateLimiter,reactiveCounter,reactiveIndex,reactiveList,reactiveLog,reactiveMap,reactiveSink,reduce,repeat,replay,rescue,resolveBackoffPreset,retry,sample,scan,serializeError,share,shareReplay,signalToName,singleFromAny,singleNodeFromAny,skip,snapshotStorage,sortJsonValue,stableJsonString,stratify,switchMap,take,takeUntil,takeWhile,tap,tapFirst,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(f),h=o(l,oe());await e.putObject({Bucket:n,Key:h,Body:p,ContentType:c})}})}function Yi(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 ue(t,{onTransportError:o,serialize:i=>s(i,n),send:async i=>{let a=i;await e.query(a.sql,a.params)}})}function Qi(t,e,n){let{toDocument:r=o=>o,onTransportError:s}=n??{};return ue(t,{onTransportError:s,serialize:r,send:async o=>{await e.insertOne(o)}})}function Xi(t,e,n){let{labels:r={},toLine:s=a=>JSON.stringify(a),toLabels:o,onTransportError:i}=n??{};return ue(t,{onTransportError:i,serialize:a=>({line:s(a),labels:o?{...r,...o(a)}:r}),send:async a=>{let{line:d,labels:u}=a,c=`${oe()}`;await e.push({streams:[{stream:u,values:[[c,d]]}]})}})}function Zi(t,e,n){let{toResourceSpans:r=o=>[o],onTransportError:s}=n??{};return ue(t,{onTransportError:s,serialize:r,send:async o=>{await e.push({resourceSpans:o})}})}function ea(t,e,n,r){let{prefix:s="checkpoints/",debounceMs:o=500,compactEvery:i=10,onError:a}=r??{},d={name:`s3:${n}`,debounceMs:o,compactEvery:i,save(u){let c=Math.floor(oe()/1e6),l=`${s}${t.name}/checkpoint-${c}.json`,f;try{f=JSON.stringify(u)}catch(p){a?.(p);return}e.putObject({Bucket:n,Key:l,Body:f,ContentType:"application/json"}).catch(p=>a?.(p))}};return t.attachSnapshotStorage([d],{onError:u=>a?.(u)})}function ta(t,e,n){let{prefix:r="graphrefly:checkpoint:",debounceMs:s=500,compactEvery:o=10,onError:i}=n??{},a=`${r}${t.name}`,d={name:`redis:${a}`,debounceMs:s,compactEvery:o,save(u){let c;try{c=JSON.stringify(u)}catch(l){i?.(l);return}e.set(a,c).catch(l=>i?.(l))},async load(){let u=await e.get(a);if(u!=null)try{return JSON.parse(u)}catch{return}}};return t.attachSnapshotStorage([d],{onError:u=>i?.(u)})}function na(t,e,n){let{mapRow:r=i=>i,params:s,...o}=n??{};return A(i=>{try{let d=t.query(e,s).map(r);i.emit(d),i.down([[S]])}catch(a){i.down([[E,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function ra(t,e,n){let{mapRow:r=i=>i,params:s,...o}=n??{};return A(i=>{try{let a=t.iterate(e,s);H(()=>{for(let d of a)i.emit(r(d));i.down([[S]])})}catch(a){i.down([[E,a instanceof Error?a:new Error(String(a))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function oa(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,P)=>({sql:`INSERT INTO "${P.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 ue(t,{onTransportError:o,serialize:u,send:O=>{let P=O;e.query(P.sql,P.params)}});let c=V(null),l=V(void 0,{equals:()=>!1}),f=V(null),p=V(0),h=V(0),g=O=>{try{o?.(O)}catch{}try{c.down([[k,O]])}catch{}},m=[],y=!1,b,v=!1,w=()=>h.down([[k,m.length]]),_=O=>{v||l.down([[k,O]])},x=O=>{v||f.down([[k,O]])},T=O=>{v||p.down([[k,O]])},N=O=>{v||g(O)},R=()=>{if(m.length===0||y)return;y=!0,T(1);try{e.query("BEGIN",[])}catch(K){y=!1,T(0),N({stage:"send",error:K instanceof Error?K:new Error(String(K)),value:void 0});return}let O=m;m=[],w();let P,X=0;for(let K of O)try{e.query(K.query.sql,K.query.params),X+=1}catch(re){P=re instanceof Error?re:new Error(String(re));break}if(P){try{e.query("ROLLBACK",[])}catch{}N({stage:"send",error:P,value:void 0});for(let K of O)x({value:K.value,error:P,attempts:1})}else try{e.query("COMMIT",[]);for(let K of O)_(K.value)}catch(K){let re=K instanceof Error?K:new Error(String(K));N({stage:"send",error:re,value:void 0});for(let Ne=0;Ne<X;Ne++)x({value:O[Ne].value,error:re,attempts:1})}y=!1,T(0)},M=()=>{d>0&&b===void 0&&!v&&(b=setTimeout(()=>{b=void 0,R()},d))},C=t.subscribe(O=>{for(let P of O){let X=P[0];if(X===k){let K=P[1],re;try{re=u(K)}catch(Ne){let Be=Ne instanceof Error?Ne:new Error(String(Ne));g({stage:"serialize",error:Be,value:K}),f.down([[k,{value:K,error:Be,attempts:0}]]);continue}m.push({value:K,query:re}),w(),m.length>=a?R():M()}else pe.messageTier(X)>=3&&R()}});return{dispose:()=>{if(!v){b!==void 0&&(clearTimeout(b),b=void 0),R(),v=!0,C();for(let O of[c,l,f,p,h])try{O.down([[z]])}catch{}}},sent:l,failed:f,inFlight:p,errors:c,buffered:h,flush:async()=>{v||R()}}}function sa(t,e){let{args:n,mapRow:r=o=>o,...s}=e??{};return A(o=>{let i=!0;return t.findMany(n).then(a=>{i&&(o.emit(a.map(r)),o.down([[S]]))}).catch(a=>{if(i)try{o.down([[E,a instanceof Error?a:new Error(String(a))]])}catch{}}),()=>{i=!1}},{...s,describeKind:"producer",completeWhenDepsComplete:!1})}function ia(t,e){let{mapRow:n=s=>s,...r}=e??{};return A(s=>{let o=!0;return t.execute().then(i=>{o&&(s.emit(i.map(n)),s.down([[S]]))}).catch(i=>{if(o)try{s.down([[E,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}function aa(t,e){let{mapRow:n=s=>s,...r}=e??{};return A(s=>{let o=!0;return t.execute().then(i=>{o&&(s.emit(i.map(n)),s.down([[S]]))}).catch(i=>{if(o)try{s.down([[E,i instanceof Error?i:new Error(String(i))]])}catch{}}),()=>{o=!1}},{...r,describeKind:"producer",completeWhenDepsComplete:!1})}vt();te();var ua=0;function da(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-${++ua}`),r=0,s=!1;return{onEnqueue(){return r+=1,!s&&r>=e.highWaterMark?(s=!0,t([[ge,n]]),!0):!1},onDequeue(){return r>0&&(r-=1),s&&r<=e.lowWaterMark?(s=!1,t([[xe,n]]),!0):!1},get pending(){return r},get paused(){return s},dispose(){s&&(s=!1,t([[xe,n]]))}}}te();ce();function Zr(){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 eo(t){return t!=null&&typeof t.then=="function"}function ct(t){eo(t)&&t.catch(()=>{})}function ca(t,e){let n=new Map,r=e?.maxSize??0,s=r>0?e?.eviction??Zr():null,o=e?.writeThrough??!1;function i(u,c,l){for(let f=0;f<l;f++)try{ct(t[f].save(u,c))}catch{}}function a(u,c,l=0){for(let f=l;f<t.length;f++){let p;try{p=t[f].load(u)}catch{continue}if(eo(p)){let h=f;p.then(g=>{g!==void 0?(c.down([[k,g]]),i(u,g,h)):a(u,c,h+1)},()=>{a(u,c,h+1)});return}if(p!==void 0){c.down([[k,p]]),i(u,p,f);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 l=n.get(c);if(l){let f=l.cache;if(l.status!=="sentinel"&&t.length>0){let p=t.length-1;try{ct(t[p].save(c,f))}catch{}for(let h=0;h<p;h++)try{let g=t[h].delete;g&&ct(g.call(t[h],c))}catch{}}l.down([[z]])}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 l=V(void 0);return n.set(u,l),s?.insert(u),a(u,l),l},save(u,c){if(o)for(let f of t)try{ct(f.save(u,c))}catch{}else if(t[0])try{ct(t[0].save(u,c))}catch{}let l=n.get(u);if(l)l.down([[k,c]]),s?.touch(u);else{s&&r>0&&s.size()>=r&&d();let f=V(c);n.set(u,f),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([[z]]),n.delete(u);for(let l of t)try{let f=l.delete;f&&ct(f.call(l,u))}catch{}},has(u){return n.has(u)},get size(){return n.size}}}Te();te();Tt();ce();Te();Pe();te();ce();var qt=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=ee(),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=ee(),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 ee()+n*1e9}}_isExpired(e,n){return e.expiresAt===void 0?!1:(n??ee())>=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 Qn(t={}){let{name:e,maxSize:n,defaultTtl:r,versioning:s,backend:o,retention:i}=t;if(i&&n!==void 0)throw new RangeError("reactiveMap: `maxSize` (LRU) and `retention` (score-based) are mutually exclusive. Pick one eviction policy.");if(i&&i.archiveThreshold===void 0&&i.maxSize===void 0)throw new RangeError("reactiveMap: `retention` requires at least one of `archiveThreshold` or `maxSize` to trigger archival.");let a=o??new qt({maxSize:n,defaultTtl:r}),d=V(a.toMap(),{name:e,describeKind:"state",equals:(f,p)=>f===p,...s!=null?{versioning:s}:{}});function u(){let f=a.toMap();H(()=>{d.down([[$]]),d.down([[k,f]])})}function c(){if(!i)return;let f=a.toMap(),p=i.archiveThreshold,h=i.maxSize,g=[];for(let[y,b]of f)g.push({key:y,value:b,score:i.score(y,b)});g.sort((y,b)=>y.score-b.score);let m=new Set;if(p!==void 0)for(let y of g)if(y.score<p)m.add(y.key);else break;if(h!==void 0&&g.length-m.size>h)for(let y of g){if(g.length-m.size<=h)break;m.has(y.key)||m.add(y.key)}if(m.size!==0)for(let y of g)m.has(y.key)&&(i.onArchive?.(y.key,y.value,y.score),a.delete(y.key))}function l(f,p="mutation"){let h=a.version;try{return f()}finally{a.version!==h&&(p==="mutation"&&c(),u())}}return{entries:d,has(f){return l(()=>a.has(f),"read")},get(f){return l(()=>a.get(f),"read")},set(f,p,h){l(()=>a.set(f,p,h?.ttl))},setMany(f,p){l(()=>a.setMany(f,p?.ttl))},delete(f){l(()=>a.delete(f))},deleteMany(f){l(()=>a.deleteMany(f))},clear(){l(()=>a.clear())},pruneExpired(){l(()=>a.pruneExpired())},get size(){return a.size},dispose(){}}}De();function la(t){return typeof t=="object"&&t!==null&&"cache"in t&&typeof t.subscribe=="function"}function fa(t,e,n){let r=ae(t),s=r.v!=null,o=V(n?.initialVerified??null,{meta:{...q("verifiable"),...s?{sourceVersion:null}:{}}}),i=n?.trigger!==void 0&&n.trigger!==null,a=null;if(i&&n?.autoVerify?a=_t(ae(n.trigger),r):i?a=ae(n.trigger):n?.autoVerify&&(a=r),a!==null){let d;if(a===r)d=Le(r,u=>e(u));else{let u=r.cache;r.subscribe(c=>{for(let l of c)l[0]===k&&(u=l[1])}),d=Le(a,()=>e(u))}Je(d,u=>{H(()=>{if(o.down([[k,u]]),s){let c=r.v;c!=null&&o.meta.sourceVersion.down([[k,{id:c.id,version:c.version}]])}})})}return{node:r,verified:o,trigger:a}}function to(t){t.subscribe(()=>{})}function St(t){return t instanceof Map?t:new Map}function no(t,e){if(!Array.isArray(e.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");H(()=>{for(let{key:n,value:r}of e.upsert)t.set(n,r);for(let n of e.remove??[])t.delete(n)})}function pa(t,e,n){let r=ae(t),s=Qn(n.mapOptions??{}),o=n.budget??2e3,a=n.context!==void 0&&n.context!==null?ae(n.context):V(null),d=St(s.entries.cache);s.entries.subscribe(p=>{for(let h of p)h[0]===k&&(d=St(h[1]))});let u=ae(e(r,s.entries));if(Je(u,p=>{no(s,p)}),n.evict){let p=new Map,h=he([s.entries],([g])=>{let m=[],y=St(g);for(let b of p.keys())y.has(b)||(p.get(b)(),p.delete(b));for(let[b,v]of y){let w=n.evict(b,v);if(la(w)){if(!p.has(b)){let _=Je(w,x=>{x===!0&&s.has(b)&&s.delete(b)});p.set(b,_)}continue}if(typeof w=="boolean"){w&&m.push(b);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return m});Je(h,g=>{for(let m of g)s.delete(m)})}let c=n.consolidateTrigger!==void 0&&n.consolidateTrigger!==null;if(n.consolidate&&c){let p=ae(n.consolidateTrigger),h=Le(p,()=>n.consolidate(d));Je(h,g=>{no(s,g)})}let l=he([s.entries,a],([p,h])=>{let g=[...St(p).entries()].map(([b,v])=>({key:b,value:v,score:n.score(v,h),cost:n.cost(v)}));g.sort((b,v)=>v.score-b.score);let m=[],y=o;for(let b of g)b.cost<=y&&(m.push({key:b.key,value:b.value,score:b.score}),y-=b.cost);return m},{meta:{...q("distill",{budget:o})}}),f=he([s.entries],([p])=>St(p).size);return to(l),to(f),{store:s,compact:l,size:f}}Pe();function Xn(t,e){if(Object.is(t,e))return!0;if(t==null||e==null||typeof t!="object"||typeof e!="object")return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(!Xn(t[o],e[o]))return!1;return!0}if(Array.isArray(e))return!1;let n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;let s=new Set(r);for(let o of n)if(!s.has(o)||!Xn(t[o],e[o]))return!1;return!0}function ro(t,e){return`${t}\0${e}`}function Et(t,e){let n=[],r=new Set(t.subgraphs),s=new Set(e.subgraphs),o=[];for(let m of s)r.has(m)||o.push(m);o.sort();for(let m of o)n.push({type:"subgraph-mounted",path:m});let i=new Set(Object.keys(t.nodes)),a=new Set(Object.keys(e.nodes)),d=[];for(let m of a)i.has(m)||d.push(m);d.sort();for(let m of d)n.push({type:"node-added",path:m,node:{...e.nodes[m]}});let u=[];for(let m of a){if(!i.has(m))continue;let y=t.nodes[m]?.meta,b=e.nodes[m]?.meta;y==null&&b==null||Xn(y??{},b??{})||u.push(m)}u.sort();for(let m of u)n.push({type:"node-meta-changed",path:m,prevMeta:t.nodes[m]?.meta??{},nextMeta:e.nodes[m]?.meta??{}});let c=new Map;for(let m of t.edges)c.set(ro(m.from,m.to),m);let l=new Map;for(let m of e.edges)l.set(ro(m.from,m.to),m);let f=[];for(let[m,y]of l)c.has(m)||f.push(y);f.sort((m,y)=>m.from<y.from?-1:m.from>y.from?1:m.to<y.to?-1:m.to>y.to?1:0);for(let m of f)n.push({type:"edge-added",from:m.from,to:m.to});let p=[];for(let[m,y]of c)l.has(m)||p.push(y);p.sort((m,y)=>m.from<y.from?-1:m.from>y.from?1:m.to<y.to?-1:m.to>y.to?1:0);for(let m of p)n.push({type:"edge-removed",from:m.from,to:m.to});let h=[];for(let m of i)a.has(m)||h.push(m);h.sort();for(let m of h)n.push({type:"node-removed",path:m});let g=[];for(let m of r)s.has(m)||g.push(m);g.sort();for(let m of g)n.push({type:"subgraph-unmounted",path:m});return{events:n,flushedAt_ns:ee()}}async function oo(t){let e=typeof t=="string"?new TextEncoder().encode(t):t,n=await globalThis.crypto.subtle.digest("SHA-256",e),r=new Uint8Array(n),s="";for(let o=0;o<r.length;o++)s+=so[r[o]];return s}var so=new Array(256);for(let t=0;t<256;t++)so[t]=t.toString(16).padStart(2,"0");var Jt=class extends Error{constructor(n,r){super(`content-addressed lookup miss in read-strict mode: ${n}`);this.key=n;this.context=r;this.name="ContentAddressedMissError"}};function io(t){let e=new Set,n=r=>{if(r===null||typeof r!="object")return r;let s=r;if(e.has(s))return{__cycle:!0};e.add(s);try{if(Array.isArray(r))return r.map(n);let o={};for(let i of Object.keys(r).sort())o[i]=n(r[i]);return o}finally{e.delete(s)}};return JSON.stringify(n(t))}function ha(t){let{storage:e,keyContext:n,keyPrefix:r,mode:s="read-write"}=t,o=n??(a=>a);async function i(a){let d=io(o(a)),u=await oo(d);return r?`${r}:${u}`:u}return{keyFor:i,async lookup(a){if(s==="write")return;let d=await i(a),u=await e.load(d);if(u===void 0){if(s==="read-strict")throw new Jt(d,a);return}return u},async store(a,d){if(s==="read")return;let u=await i(a);await e.save(u,d)},async forget(a){if(s==="read"||s==="write"||!e.delete)return;let d=await i(a);await e.delete(d)}}}Bn();async function ma(t,e){let n;try{n=await t.text()}catch{n=""}let r=e??"HTTP",s=new Error(`${r} API ${t.status}: ${t.statusText}${n?` \u2014 ${n}`:""}`);return s.status=t.status,s.headers=t.headers,s}var Zn=require("rxjs");te();function ga(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]===E){n.error(o[1]);return}if(o[0]===S){n.complete();return}}}})):new Zn.Observable(n=>t.subscribe(s=>{for(let o of s){if(n.closed)return;if(o[0]===k)n.next(o[1]);else if(o[0]===E){n.error(o[1]);return}else if(o[0]===S){n.complete();return}}}))}Te();te();ye();var Yt=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 ya(t={}){let{backend:e}=t,n=e??new Yt,r=new Map;function s(o){let i=r.get(o);return i===void 0&&(i=G({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){H(()=>{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([[z]]),!0)},has(o){return n.hasTopic(o)},get size(){return n.topicCount},topicNames(){return n.topicNames()}}}Te();te();ce();function ao(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 ba(t,e){let n=ao(t[0],e[0]);return n!==0?n:ao(t[1],e[1])}function uo(t){return[t.secondary,t.primary]}function lt(t,e){let n=uo(e),r=0,s=t.length;for(;r<s;){let o=r+s>>1;ba(n,uo(t[o]))>0?r=o+1:s=o}return r}var Qt=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=lt(this._buf,o);this._buf.splice(d,1)}let a=lt(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=lt(this._buf,o);this._buf.splice(d,1)}let a=lt(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=lt(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=lt(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 va(t){return t.subscribe(()=>{})}function Ta(t={}){let{name:e,versioning:n,equals:r,backend:s}=t,o=s??new Qt;function i(p){return p?.equals!==void 0||r===void 0?p:{...p,equals:r}}let a=V([],{name:e,describeKind:"state",equals:(p,h)=>p===h,...n!=null?{versioning:n}:{}}),d=he([a],([p])=>{let h=p,g=new Map;for(let m of h)g.set(m.primary,m.value);return g},{initial:o.toPrimaryMap(),describeKind:"derived"}),u=va(d),c=!1;function l(){let p=o.toArray();H(()=>{a.down([[$]]),a.down([[k,p]])})}function f(p){let h=o.version;try{return p()}finally{o.version!==h&&l()}}return{ordered:a,byPrimary:d,has(p){return o.has(p)},get(p){return o.get(p)},get size(){return o.size},upsert(p,h,g,m){return f(()=>o.upsert(p,h,g,i(m)))},upsertMany(p,h){let g=[...p];g.length!==0&&f(()=>o.upsertMany(g,i(h)))},delete(p){f(()=>o.delete(p))},deleteMany(p){let h=[...p];h.length!==0&&f(()=>o.deleteMany(h))},clear(){f(()=>o.clear())},dispose(){c||(c=!0,u())}}}Te();te();ce();var Xt=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 wa(t,e={}){let{name:n,versioning:r,backend:s}=e,o=s??new Xt(t),i=V(o.toArray(),{name:n,describeKind:"state",equals:(u,c)=>u===c,...r!=null?{versioning:r}:{}});function a(){let u=o.toArray();H(()=>{i.down([[$]]),i.down([[k,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(){}}}Te();te();ye();ce();De();var Zt=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}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let n=0;n<e.length;n++)this._buf.push(e[n]);this._size=this._buf.length}else{let n=this._maxSize;for(let o=0;o<n;o++)this._buf[o]=void 0;this._head=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}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function Ot(t){return t.subscribe(()=>{})}var xa=64;function ka(t,e={}){let{name:n,maxSize:r,versioning:s,guard:o,backend:i}=e,a=i??new Zt(t,r),d=V(a.toArray(),{name:n,describeKind:"state",equals:(T,N)=>T===N,...s!=null?{versioning:s}:{},...o!=null?{guard:o}:{}});function u(){let T=a.toArray();H(()=>{d.down([[$]],{internal:!0}),d.down([[k,T]],{internal:!0})})}let c=new Map,l=new Map,f=new Map;function p(T,N){return`${T}:${N===void 0?"END":N}`}function h(T){if(T.size<xa)return;let N=T.keys().next();if(N.done)return;let R=T.get(N.value);R!==void 0&&R.dispose(),T.delete(N.value)}function g(T){let N=a.version;try{return T()}finally{a.version!==N&&u()}}function m(T){if(!Number.isInteger(T)||T<0)throw new RangeError(`tail: n must be a non-negative integer (got ${T})`);let N=c.get(T);if(N!==void 0)return c.delete(T),c.set(T,N),N.node;h(c);let R=he([d],([C])=>{let I=C;return T===0||I.length===0?[]:I.slice(Math.max(0,I.length-T))},{initial:a.tail(T),describeKind:"derived"}),M=Ot(R);return c.set(T,{node:R,dispose:M}),R}function y(T,N){if(!Number.isInteger(T)||T<0)throw new RangeError(`slice: start must be a non-negative integer (got ${T})`);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=p(T,N),M=l.get(R);if(M!==void 0)return l.delete(R),l.set(R,M),M.node;h(l);let C=he([d],([O])=>{let P=O;return N===void 0?P.slice(T):P.slice(T,N)},{initial:a.slice(T,N),describeKind:"derived"}),I=Ot(C);return l.set(R,{node:C,dispose:I}),C}function b(T){let N=f.get(T);if(N!==void 0)return N.node;let R=he([d,T],([C,I])=>{let O=C,P=Math.max(0,Math.trunc(I??0));return O.slice(P)},{initial:[],describeKind:"derived"}),M=Ot(R);return f.set(T,{node:R,dispose:M}),R}let v,w;function _(){v===void 0&&(v=G([d],(T,N,R)=>{let M=T[0],I=M!=null&&M.length>0?M.at(-1):R.prevData[0];if(I==null||I.length===0){N.down([[D]]);return}N.emit(I[I.length-1])},{name:n!=null?`${n}::lastValue`:"lastValue",describeKind:"derived",initial:a.size===0?void 0:a.at(a.size-1)}),w=he([d],([T])=>T.length>0,{name:n!=null?`${n}::hasLatest`:"hasLatest",describeKind:"derived",initial:a.size>0}),Ot(v),Ot(w))}let x={entries:d,get size(){return a.size},at(T){return a.at(T)},append(T){g(()=>a.append(T))},appendMany(T){T.length!==0&&g(()=>a.appendMany(T))},clear(){g(()=>a.clear())},trimHead(T){g(()=>a.trimHead(T))},withLatest(){return _(),d},get lastValue(){return _(),v},get hasLatest(){return _(),w},view(T){switch(T.kind){case"tail":return m(T.n);case"slice":return y(T.start,T.stop);case"fromCursor":return b(T.cursor)}},attach(T){let N=T.subscribe(R=>{for(let M of R)M[0]===k&&x.append(M[1])});return()=>N()},attachStorage(T){if(T.length===0)return()=>{};let N=new Map;for(let M of T)N.set(M,a.size);(async()=>{for(let M of T)if(typeof M.loadEntries=="function")try{let C=await Promise.resolve(M.loadEntries());C.entries.length>0&&a.size===0&&(a.restore(C.entries),N.set(M,C.entries.length),u());break}catch{}})();let R=d.subscribe(M=>{for(let C of M){if(C[0]!==k)continue;let I=C[1];for(let O of T){let P=N.get(O)??0;if(I.length<P){try{let K=O.appendEntries(I);K instanceof Promise&&K.catch(()=>{})}catch{}N.set(O,I.length);continue}if(I.length===P)continue;let X=I.slice(P);N.set(O,I.length);try{let K=O.appendEntries(X);K instanceof Promise&&K.catch(()=>{})}catch{}}}});return()=>R()},disposeAllViews(){for(let T of c.values())T.dispose();c.clear();for(let T of l.values())T.dispose();l.clear();for(let T of f.values())T.dispose();f.clear()},dispose(){for(let T of c.values())T.dispose();c.clear();for(let T of l.values())T.dispose();l.clear();for(let T of f.values())T.dispose();f.clear()}};return x}var er=new WeakMap;function _a(t){let e=er.get(t);if(e)return e;let n=t.map(c=>c.cache??[]),r=n.flat(),s=V(r,{name:"mergeReactiveLogs",describeKind:"state",equals:(c,l)=>c===l}),o=t.map((c,l)=>[...n[l]??[]]),i=[];for(let c=0;c<t.length;c++){let l=c,f=t[l].subscribe(p=>{for(let h of p)if(h[0]===k)o[l]=[...h[1]],s.emit(o.flat());else if(h[0]===S){o[l]=[];let g=i[l];g!==void 0&&(i[l]=void 0,g())}else h[0]===E&&s.down([[E,h[1]]])});i.push(f)}let a=Ye(s),d=!1,u={node:s,dispose(){if(!d){d=!0;for(let c of i)c?.();i.length=0,a(),er.delete(t)}}};return er.set(t,u),u}zt();te();De();function Na(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=Un(a):a!=null&&typeof a=="object"&&Symbol.asyncIterator in a?d=(async()=>{let l=a[Symbol.asyncIterator]();try{let{value:f,done:p}=await l.next();if(p)throw new Error("singleFromAny: factory returned empty async iterable");return f}finally{await l.return?.()}})():a!=null&&typeof a=="object"&&Symbol.iterator in a?d=(async()=>{let l=a[Symbol.iterator]();try{let{value:f,done:p}=l.next();if(p)throw new Error("singleFromAny: factory returned empty iterable");return f}finally{l.return?.()}})():d=Promise.resolve(a);let u,c=()=>{r.get(o)===u&&r.delete(o)};return u=d.then(l=>(c(),l),l=>{throw c(),l}),r.set(o,u),u}}function Sa(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=ae(t(s));r.set(o,a);let d=a.subscribe(u=>{for(let c of u)if(c[0]===E||c[0]===S){r.get(o)===a&&r.delete(o),d();return}});return a}}De();function en(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(en);let e=t,n=Object.keys(e).sort(),r={};for(let s of n)r[s]=en(e[s]);return r}function tr(t){return JSON.stringify(en(t),void 0,0)}var Ea=new TextEncoder,Oa=new TextDecoder("utf-8",{fatal:!0}),Rt={name:"json",version:1,encode(t){return Ea.encode(tr(t))},decode(t){return JSON.parse(Oa.decode(t))}};function Ra(){return Rt}function tn(){let t=new Map;return{name:"memory",read(e){let n=t.get(e);return n===void 0?void 0:new Uint8Array(n)},write(e,n){t.set(e,new Uint8Array(n))},delete(e){t.delete(e)},list(e){let n=[...t.keys()];return e?n.filter(r=>r.startsWith(e)).sort():n.sort()}}}function nr(t,e={}){let n=e.codec??Rt,r=e.name??t.name??"snapshot",s=e.keyOf??(l=>l.name??e.name??t.name??"snapshot"),o,i=0,a=e.compactEvery,d,u={name:r,debounceMs:e.debounceMs,compactEvery:a,filter:e.filter,keyOf:s,save(l){if(!(e.filter&&!e.filter(l))&&(o={snapshot:l},i+=1,a!==void 0&&i%a===0||!e.debounceMs))return c()},load(){let l=d??r,f=t.read(l);if(f!==void 0)return f instanceof Uint8Array?f.length===0?void 0:n.decode(f):Promise.resolve(f).then(p=>p===void 0||p.length===0?void 0:n.decode(p))},async flush(){await c()},async rollback(){o=void 0}};function c(){let l=o;if(!l)return;o=void 0;let f=s(l.snapshot),p=n.encode(l.snapshot),h=t.write(f,p);if(h instanceof Promise)return h.then(()=>{d=f});d=f}return u}function co(t,e={}){let n=e.codec??Rt,r=e.name??t.name??"append-log",s=e.keyOf??(f=>r),o=e.compactEvery,i=new Map,a=0,d,u={name:r,debounceMs:e.debounceMs,compactEvery:o,keyOf:s,appendEntries(f){if(f.length!==0){for(let p of f){let h=s(p),g=i.get(h);g||(g=[],i.set(h,g)),g.push(p)}if(a+=f.length,o!==void 0&&a%o===0||!e.debounceMs)return c()}},async loadEntries(f){let p=f?.keyFilter,h=t.list===void 0?p!==void 0?[p]:[r]:await Promise.resolve(t.list(p)),g=[];for(let m of h){let y=await Promise.resolve(t.read(m));if(y===void 0||y.length===0)continue;let b=n.decode(y);Array.isArray(b)&&g.push(...b)}return{entries:g,cursor:void 0}},async flush(){await c()},async rollback(){i=new Map}};function c(){if(i.size===0)return;let f=i;i=new Map;let p=(d??Promise.resolve()).then(()=>{let h=l(f);return h instanceof Promise?h:Promise.resolve()},()=>{let h=l(f);return h instanceof Promise?h:Promise.resolve()});return d=p.finally(()=>{d===p&&(d=void 0)}),d}function l(f){let p=[];for(let[h,g]of f){let m=t.read(h),y=b=>{let w=[...b===void 0||b.length===0?[]:n.decode(b)??[],...g],_=n.encode(w);return t.write(h,_)};if(m instanceof Promise)p.push(m.then(async b=>{let v=y(b);v instanceof Promise&&await v}));else{let b=y(m);b instanceof Promise&&p.push(b)}}if(p.length>0)return Promise.all(p).then(()=>{})}return u}function rr(t,e={}){let n=e.codec??Rt,r=e.name??t.name??"kv",s=e.compactEvery,o=new Map,i=0,a={name:r,debounceMs:e.debounceMs,compactEvery:s,filter:e.filter,save(u,c){if(!(e.filter&&!e.filter(u,c))&&(o.set(u,c),i+=1,s!==void 0&&i%s===0||!e.debounceMs))return d()},load(u){let c=t.read(u);if(c!==void 0)return c instanceof Uint8Array?c.length===0?void 0:n.decode(c):Promise.resolve(c).then(l=>l===void 0||l.length===0?void 0:n.decode(l))},delete(u){if(o.delete(u),!!t.delete)return t.delete(u)},list(u){return t.list?t.list(u):[]},async flush(){await d()},async rollback(){o=new Map}};function d(){if(o.size===0)return;let u=o;o=new Map;let c=[];for(let[l,f]of u){let p=n.encode(f),h=t.write(l,p);h instanceof Promise&&c.push(h)}if(c.length>0)return Promise.all(c).then(()=>{})}return a}function Ma(t){return nr(tn(),t)}function Aa(t){return co(tn(),t)}function Ca(t){return rr(tn(),t)}function Da(t,e){let n={name:e?.name??"dict-kv",read(r){return t[r]},write(r,s){t[r]=new Uint8Array(s)},delete(r){delete t[r]},list(r){let s=Object.keys(t).sort();return r?s.filter(o=>o.startsWith(r)):s}};return rr(n,e)}function Pa(t,e){return nr({name:"dict",read(r){return t[r]},write(r,s){t[r]=new Uint8Array(s)},delete(r){delete t[r]},list(r){let s=Object.keys(t).sort();return r?s.filter(o=>o.startsWith(r)):s}},e)}te();ye();ce();wn();Te();Pe();Lt();te();Tt();ye();ce();De();Ft();Tn();function or(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 nn(t){let e=0;for(let n of t)e+=or(n.codePointAt(0));return e}function lo(t,e){if(e<=0)return"";let n=0,r="";for(let s of t){let o=or(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-=or(i.codePointAt(0))}return`${r}\u2026`}r+=s,n+=o}return r}var Ia={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"},La={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function mo(t,e){let n=e.charset==="ascii"?La:Ia,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)Ga(o,i,n,a);for(let a of t.boxes)Ba(o,i,n,a,e.labelOf(a.id));return o.map(a=>Ka(a.join(""))).join(`
19
+ `)}function Ba(t,e,n,r,s){let{x:o,y:i,w:a,h:d}=r;if(a<2||d<2){d>0&&fo(t,e,o,i,a,s);return}Fe(t,e,o,i,n.boxTL);for(let c=o+1;c<o+a-1;c+=1)Fe(t,e,c,i,n.boxH);Fe(t,e,o+a-1,i,n.boxTR);for(let c=i+1;c<i+d-1;c+=1){Fe(t,e,o,c,n.boxV);for(let l=o+1;l<o+a-1;l+=1)go(t,e,l,c," ","empty");Fe(t,e,o+a-1,c,n.boxV)}Fe(t,e,o,i+d-1,n.boxBL);for(let c=o+1;c<o+a-1;c+=1)Fe(t,e,c,i+d-1,n.boxH);Fe(t,e,o+a-1,i+d-1,n.boxBR);let u=i+Math.floor(d/2);fo(t,e,o+1,u,a-2,s)}function Fe(t,e,n,r,s){go(t,e,n,r,s,s===" "?"empty":s==="\u2500"||s==="-"?"boxH":s==="\u2502"||s==="|"?"boxV":"boxCorner")}function go(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 fo(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=nn(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 Ga(t,e,n,r){let s=r.points;if(s.length<2)return;for(let d=0;d+1<s.length;d+=1)Va(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],l=s[d+1],f=Fa(u,c,l,n);f&&ho(t,e,c.x,c.y,f,"edgeCorner")}let o=s[s.length-1],i=s[s.length-2],a=$a(i,o,n);a&&ho(t,e,o.x,o.y,a,"arrow")}function Va(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)po(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)po(t,e,o,d,n,"v")}}}function po(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 ho(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 Fa(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 $a(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 Ka(t){let e=t.length;for(;e>0&&t.charCodeAt(e-1)===32;)e-=1;return t.slice(0,e)}function vo(t){let e=za(t);ja(e),Ha(e),Wa(e),Ua(e,t);let n=Ya(e,t),{width:r,height:s}=Xa(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 za(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 ja(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 Ha(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(l=>l!==o),a.in=a.in.filter(l=>l!==o);continue}if(d===1){o.hopIndex=0,o.chainLen=1,r.push(o);continue}i.out=i.out.filter(l=>l!==o),a.in=a.in.filter(l=>l!==o);let u=i;for(let l=1;l<d;l+=1){let f=`__virt_${s++}__`,p={id:f,isVirtual:!0,layer:i.layer+l,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};t.nodes.set(f,p),n[p.layer].push(p);let h={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:f,hopIndex:l-1,chainLen:d};u.out.push(h),p.in.push(h),r.push(h),u=p}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 Wa(t){for(let n=0;n<4;n+=1){for(let r=1;r<t.layers.length;r+=1)yo(t,t.layers[r],"in"),rn(t.layers[r]);for(let r=t.layers.length-2;r>=0;r-=1)yo(t,t.layers[r],"out"),rn(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=bo(t,o[i],o[i+1],"in");[o[i],o[i+1]]=[o[i+1],o[i]],rn(o),bo(t,o[i],o[i+1],"in")<a?r=!0:([o[i],o[i+1]]=[o[i+1],o[i]],rn(o))}}if(!r)break}}function yo(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 rn(t){for(let e=0;e<t.length;e+=1)t[e].order=e}function bo(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 Ua(t,e){e.direction==="LR"?qa(t,e):Ja(t,e)}function qa(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}To(t,e,"y")}function Ja(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}To(t,e,"x")}function To(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 l=o===0?c.in:c.out;if(l.length===0)continue;let f=[];for(let h of l){let g=t.nodes.get(o===0?h.fromId:h.toId);if(!g)continue;let m=n==="y"?g.y:g.x;f.push(m+Math.floor(r(g)/2))}if(f.length===0)continue;f.sort((h,g)=>h-g);let p=f[Math.floor(f.length/2)];d.set(c.id,p-Math.floor(r(c)/2))}let u=0;for(let c of a){let l=d.get(c.id),f=n==="y"?c.y:c.x,h=Math.max(l??f,u);n==="y"?c.y=h:c.x=h,u=h+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,l)=>c.hopIndex-l.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],l=t.layers[u+1],f=0;for(let N of c)f=Math.max(f,s(N)+o(N));let p=Number.POSITIVE_INFINITY;for(let N of l)p=Math.min(p,s(N));let h=Number.isFinite(p)?p-1:f,g=Math.max(1,h-f+1),m=[];for(let N of c)for(let R of N.out)m.push(R);m.sort((N,R)=>{let M=i(t.nodes.get(N.fromId)),C=i(t.nodes.get(R.fromId));if(M!==C)return M-C;let I=i(t.nodes.get(N.toId)),O=i(t.nodes.get(R.toId));return I-O});let y=[],b=new Map;for(let N of m){let R=i(t.nodes.get(N.fromId)),M=i(t.nodes.get(N.toId)),C=Math.min(R,M),I=Math.max(R,M),O=-1;for(let P=0;P<y.length;P+=1){let X=y[P],K=!0;for(let re of X)if(re.lo<=I&&C<=re.hi){K=!1;break}if(K){X.push({lo:C,hi:I}),O=P;break}}O<0&&(y.push([{lo:C,hi:I}]),O=y.length-1),b.set(N,O)}let v=y.length,w=g>=Math.max(3,v+2),_=w?f+1:f,x=w?h-1:h,T=Math.max(1,x-_+1);for(let N of m){let R=b.get(N),M;if(v<=1)M=_+Math.floor(T/2);else{let C=(T-1)/(v-1);M=_+Math.floor(R*C)}a.set(N,Math.max(f,Math.min(h,M)))}}let d=[];for(let[,u]of n){let c=[];for(let f=0;f<u.length;f+=1){let p=u[f],h=t.nodes.get(p.fromId),g=t.nodes.get(p.toId),m=a.get(p),y=h.isVirtual?s(h):s(h)+o(h),b=g.isVirtual?s(g):s(g)-1,v=i(h),w=i(g);f===0&&on(c,r,y,v),v!==w&&(on(c,r,m,v),on(c,r,m,w)),on(c,r,b,w)}let l=u[0];d.push({from:l.chainFrom,to:l.chainTo,points:Qa(c)})}return d}function on(t,e,n,r){t.push(e?{x:n,y:r}:{x:r,y:n})}function Qa(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 Xa(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 Za=24,eu=4,tu=1,nu=3;function wo(t,e){let n=ru(e.direction),r=Math.max(3,e.maxLabelWidth??Za),s=e.asciiCharset??"unicode",o=Object.keys(t.nodes).sort(),i=new Set(o),a=t.edges.filter(p=>i.has(p.from)&&i.has(p.to)),d=new Map,u=new Map;for(let p of o){let h=lo(p,r);d.set(p,h),u.set(p,nn(h)+4)}let c=vo({nodes:o,edges:a,widthCells:p=>u.get(p)??3,heightCells:()=>nu,layerGap:eu,nodeGap:tu,direction:n}),l=mo(c,{charset:s,labelOf:p=>d.get(p)??p}),f=e.logger;return f&&f(l),l}function ru(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 xo(t,e,n,r={}){let s=e in t.nodes,o=n in t.nodes;if(!s)return sn(e,n,"no-such-from");if(!o)return sn(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=ou(t,e,r);if(u!=null)return u}let d=an(e,t.nodes[e],0,r);return un(e,n,[d])}if(i===0)return sn(e,n,"no-path");let a=ko(t,e,n,i);return a.found?un(e,n,_o(t,a.pathOrder,r)):sn(e,n,a.truncated?"max-depth-exceeded":"no-path")}function ko(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 l=o[a++];if(l.path===e)break;if(r!=null&&l.depth>=r){let g=t.nodes[l.path];g?.deps&&g.deps.length>0&&(d=!0);continue}let f=t.nodes[l.path];if(f==null)continue;let p=f.deps??[],h=new Map;for(let g=0;g<p.length;g++){let m=p[g];if(!m)continue;let y=h.get(m);y==null&&(y=[],h.set(m,y)),y.push(g)}for(let[g,m]of h)i.has(g)||(i.add(g),s.set(g,{from:l.path,depIndices:m}),o.push({path:g,depth:l.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:d};let u=[{path:e}],c=e;for(;c!==n;){let l=s.get(c);if(l==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=l.depIndices,u.push({path:l.from}),c=l.from}return{found:!0,pathOrder:u,truncated:!1}}function ou(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=an(e,r,0,n);a.dep_index=o[0];let d=an(e,r,1,n);return un(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=ko(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:un(e,e,_o(t,i.pathOrder,n))}function _o(t,e,n){return e.map((r,s)=>{let o=t.nodes[r.path],i=an(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 an(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 un(t,e,n){return No(t,e,!0,"ok",n)}function sn(t,e,n){return No(t,e,!1,n,[])}function No(t,e,n,r,s){let o=su(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 su(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: ${iu(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 iu(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)}}ye();var ie={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},au=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+=uu(o,e,n,r)}return s}function uu(t,e,n,r){if(t==null)return 0;switch(typeof t){case"number":return ie.number;case"boolean":return ie.boolean;case"string":return ie.string+t.length*2;case"bigint":return ie.bigint+du(t);case"symbol":return ie.symbol;case"function":return e.has(t)?0:(e.add(t),ie.function);case"undefined":return 0}let o=t;if(e.has(o))return 0;e.add(o);let i=o[au];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 ie.date;if(o instanceof RegExp)return ie.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 ie.error+u+c}if(typeof URL<"u"&&o instanceof URL)return ie.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return ie.promise;if(o instanceof WeakMap)return ie.weakmap;if(o instanceof WeakSet)return ie.weakset;if(o instanceof Map){let u=ie.map;for(let[c,l]of o)u+=ie.mapEntry,r.push(c),r.push(l);return u}if(o instanceof Set){let u=ie.set;for(let c of o)u+=ie.setEntry,r.push(c);return u}if(Array.isArray(o)){let u=ie.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=ie.object,d=Object.keys(o);for(let u of d){a+=ie.string+u.length*2;try{r.push(o[u])}catch{}}return a}function du(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 Eo(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[f,p]of s)i.set(f,p);let a=[];for(let[f,p]of Object.entries(r.nodes)){let h=i.get(f),g=h instanceof se?h:null,m=g?So(g.cache):0,y=g?g._sinkCount:0,b=p.deps?.length??0,v=p.type==="effect"&&y===0,w=y===0?p.type==="effect"?"orphan-effect":p.type==="derived"?"idle-derived":p.type==="producer"?"idle-producer":null:null;a.push({path:f,type:p.type,status:p.status??"unknown",valueSizeBytes:m,subscriberCount:y,depCount:b,isOrphanEffect:v,orphanKind:w})}let d=a.reduce((f,p)=>f+p.valueSizeBytes,0),u=(f,p)=>[...a].sort(p??((h,g)=>g[f]-h[f])).slice(0,n),c=a.filter(f=>f.orphanKind!=null),l=a.filter(f=>f.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:l}}var ne="::",Ae="__meta__",ft=1;function Oo(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 Co(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"&&typeof t.down=="function"}function cu(t){if(t!=null)return Co(t)?t.cache:t}function lu(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 Ro(t){if(t.version!==ft)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${ft})`);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 fu(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 f=o;if(s.length!==f.length)return!1;for(let p=0;p<s.length;p++)if(!r(s[p],f[p]))return!1;return!0}if(s instanceof Map){let f=o;if(s.size!==f.size)return!1;for(let[p,h]of s)if(!f.has(p)||!r(h,f.get(p)))return!1;return!0}if(s instanceof Set){let f=o;if(s.size!==f.size)return!1;for(let p of s){let h=!1;for(let g of f)if(r(p,g)){h=!0;break}if(!h)return!1}return!0}if(ArrayBuffer.isView(s)){let f=s,p=o;if(f.length!==p.length)return!1;for(let h=0;h<f.length;h++)if(f[h]!==p[h])return!1;return!0}let u=Object.keys(s),c=Object.keys(o);if(u.length!==c.length)return!1;let l=new Set(c);for(let f of u)if(!l.has(f)||!r(s[f],o[f]))return!1;return!0};return r(t,e)}function ir(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(ir);let e=t,n=Object.keys(e).sort(),r={};for(let s of n)r[s]=ir(e[s]);return r}function pu(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function hu(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function mu(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function Do(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 gu(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(ir(i),null,e.indent??2);return e.logger?.(a),a}function yu(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}): ${cn(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 Io(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}["${pu(i)}"]`)}for(let[i,a]of Do(t)){let d=s.get(i),u=s.get(a);!d||!u||o.push(` ${d} --> ${u}`)}return o.join(`
23
+ `)}function bu(t,e){let n=Io(t,e);return vu(n)}function vu(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 Tu(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: ${mu(n)}`];for(let i of r){let a=s.get(i);o.push(`${a}: "${hu(i)}"`)}for(let[i,a]of Do(t)){let d=s.get(i),u=s.get(a);!d||!u||o.push(`${d} -> ${u}`)}return o.join(`
24
+ `)}function wu(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dn(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+=wu(r)}return e+="$",new RegExp(e)}var xu={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"},ku={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function cn(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 _u(t){return t==="none"?ku:t==="ansi"||t==null?xu:{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 Mo(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 Nu(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 sr(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(ne))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${ne}' (path separator)`);if(t===Ae)throw new Error(`Graph "${e}": ${n} name "${Ae}" is reserved for meta companion paths`);Nu(t,e,n)}function Su(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(ne);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function Eu(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 Lo(t){for(let e of t._mounts.values())Lo(e);for(let e of t._nodes.values())try{e.down([[z]],{internal:!0})}catch{}}var Mt=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(ne))throw new Error(`Graph name must not contain '${ne}' (got "${e}")`);if(e===Ae)throw new Error(`Graph name "${Ae}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??pe,this._traceRing=new Qe(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning),typeof n?.factory=="string"&&(this._factory=n.factory,n.factoryArgs!==void 0&&(this._factoryArgs=n.factoryArgs))}tagFactory(e,n){return this._factory=e,this._factoryArgs=n,this}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=A(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)}nameOf(e){return this._nodeToName.get(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(sr(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 n of this._nodes.values())n instanceof se&&n._applyVersioning(e)}remove(e){sr(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(`${ne}${Ae}${ne}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...n._collectSubgraphs(`${e}${ne}`)),this._mounts.delete(e),n._parent=void 0,Lo(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([[z]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let n=typeof e=="function"?e:(()=>{let o=dn(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(ne))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([[k,n]],{actor:r?.actor,internal:s,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);H(()=>{for(let[s,o]of r)this.set(s,o,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[we]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let s=r?.internal===!0;this.node(e).down([[E,n]],{actor:r?.actor,internal:s,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[S]],{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 se)for(let c of u._deps){let l=r.get(c.node);l!=null&&a.push([l,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 se)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(n===void 0){let s=new t(e);return this.mount(e,s)}if(typeof n=="function"){let s=new t(e);return n(s),this.mount(e,s)}let r=n;if(sr(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(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===r)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,r),r._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),r}resolve(e){let n=Su(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]===Ae)return this._resolveMetaChainFromNode(o,s,n.join(ne));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(ne)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(s.join(ne))}_resolveMetaChainFromNode(e,n,r){let s=e,o=0,i=[...n];for(;o<i.length;){if(i[o]!==Ae)throw new Error(`Graph "${this.name}": expected ${Ae} segment in meta path "${r}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Ae} 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=Eu(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 Ee)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 Ee)throw d;o.push(d)}this._signalMetaSubtree(a,n,r,s,o)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let n=cu(e?.actor),r=e?.filter,s=Vt(e?.detail,e?.fields),o=e?.format==="spec",i=o?Vt("minimal"):s,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[x,T]of a)d.set(T,x);let u=[];{let x=a.map(([,R])=>R),T=new Set(d.values()),N=0;for(;x.length>0;){let R=x.shift();if(R instanceof se)for(let M of R._deps){let C=M.node;if(d.has(C))continue;let I=C.name??"",O=I;if(!O||T.has(O))if(I){let P=2;for(;T.has(`${I}#${P}`);)P++;O=`${I}#${P}`}else for(O=`__internal__/${N++}`;T.has(O);)O=`__internal__/${N++}`;d.set(C,O),T.add(O),u.push([O,C]),x.push(C)}}}let c=[...a,...u],l={};for(let[x,T]of c){if(n!=null&&!T.allowsObserve(n))continue;let N=Pn(T,i),R=T instanceof se?T._deps.map(O=>d.get(O.node)??O.node.name??""):[],{name:M,...C}=N,I={...C,deps:R};if(!o){let O=this._annotations.get(x);O!=null&&(I.annotation=O)}if(r!=null)if(typeof r=="function"){let O=r;if(!(O.length>=2?O(x,I):O(I)))continue}else{let O=!0;for(let[P,X]of Object.entries(r)){let K=P==="deps_includes"?"depsIncludes":P==="meta_has"?"metaHas":P;if(K==="depsIncludes"){if(!I.deps.includes(String(X))){O=!1;break}continue}if(K==="metaHas"){if(!Object.hasOwn(I.meta??{},String(X))){O=!1;break}continue}if(I[K]!==X){O=!1;break}}if(!O)continue}l[x]=I}let f=new Set(Object.keys(l)),p=[];for(let[x,T]of c)if(T instanceof se)for(let N of T._deps){let R=d.get(N.node);R!=null&&p.push([R,x])}p.sort((x,T)=>x[0]<T[0]?-1:x[0]>T[0]?1:x[1]<T[1]?-1:x[1]>T[1]?1:0);let h=p.map(([x,T])=>({from:x,to:T}));(n!=null||r!=null)&&(h=h.filter(x=>f.has(x.from)&&f.has(x.to)));let g=this._collectSubgraphs(""),m=n!=null||r!=null?g.filter(x=>{let T=`${x}${ne}`;return[...f].some(N=>N===x||N.startsWith(T))}):g,y=this,b=e,v={name:this.name,nodes:l,edges:h,subgraphs:m,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(x){let T={...b,format:void 0};return Array.isArray(x)?(T.fields=x,T.detail=void 0):(T.detail=x,T.fields=void 0),y.describe(T)}},w=e??{},_=w.format;return _==="json"?gu(v,w):_==="pretty"?yu(v,w):_==="mermaid"?Io(v,w):_==="mermaid-url"?bu(v,w):_==="d2"?Tu(v,w):_==="ascii"?wo(v,w):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}${ne}`))}return n}resourceProfile(e){return Eo(this,e)}reachable(e,n,r={}){return r.withDetail===!0?Ao(this.describe(),e,n,{...r,withDetail:!0}):Ao(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 xo(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=V(s,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,nt(()=>{a=!1,!d&&(s+=1,o.emit(s))}))},c=i.onEvent(b=>{let v=b.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||u()}),l=[],f=new WeakSet,p=b=>{if(f.has(b)||d)return;f.add(b);let v=b.topology.subscribe(w=>{for(let _ of w){if(_[0]!==k)continue;let x=_[1];if(u(),x.kind==="added"&&x.nodeKind==="mount"){let T=b._mounts.get(x.name);T!=null&&p(T)}}});l.push(v);for(let w of b._mounts.keys()){let _=b._mounts.get(w);_!=null&&p(_)}};p(this);let h,g=e.actor;Co(g)&&(h=g.subscribe(b=>{let v=!1,w=!1;for(let _ of b){let x=_[0];x===k?v=!0:(x===S||x===E||x===z)&&(w=!0)}v&&u(),w&&(h?.(),h=void 0,u())}));let m;try{m=he([o],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,v)=>b===v})}catch(b){c(),h?.();for(let v of l)v();throw i.dispose(),b}let y=Ye(m);return{node:m,dispose(){d=!0,c(),h?.();for(let b of l)b();l.length=0,i.dispose(),y()}}}_describeReactiveDiff(e){let n={...e,format:void 0,reactive:!1},r=e.reactiveName??"describe-diff",s={name:this.name,nodes:{},edges:[],subgraphs:[]},o=this.describe(n),i=Et(s,o),a=V(i,{name:r,meta:{domain:"audit",kind:"describe-diff"},equals:(f,p)=>f===p}),d=this._describeReactive({...e,format:void 0,reactiveName:void 0}),u=!1,c=d.node.subscribe(f=>{if(!u)for(let p of f){if(p[0]!==k)continue;let h=p[1],g=Et(o,h);o=h,g.events.length!==0&&a.emit(g)}}),l=Ye(a);return{node:a,dispose(){u=!0,c(),d.dispose(),a.down([[z,"describe-diff disposed"]]),l()}}}_explainReactive(e,n,r){let s=0,o=V(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(p=>{let h=p.type;h!=="data"&&h!=="error"&&h!=="complete"&&h!=="teardown"||a||d||(a=!0,nt(()=>{a=!1,!d&&(s+=1,o.emit(s))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},l;try{l=he([o],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(p,h)=>p.found===h.found&&p.reason===h.reason&&p.steps.length===h.steps.length&&Ru(p.steps,h.steps)})}catch(p){throw u(),i.dispose(),p}let f=Ye(l);return{node:l,dispose(){d=!0,u(),i.dispose(),f()}}}_pathsMatching(e){let n=dn(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}${ne}${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}${ne}${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}${ne}${Ae}${ne}${s}`;r.push([i,o]),this._appendMetaObserveTargets(i,o,r)}}observe(e,n){let r=typeof e=="string",o=Mo(r?n:e);if(o.reactive===!0)return this._observeReactive(r?e:void 0,o);let 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,l=this.resolve(c);if(a!=null&&!l.allowsObserve(a))throw new Ee({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,l]],o,"one"):{subscribe(f){return l.subscribe(f)},up(f){try{l.up?.(f)}catch(p){if(p instanceof Ee)return;throw p}}}}let d=[];this._collectObserveTargets("",d),d.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let u=a==null?d:d.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,o,"all"):{subscribe:c=>{let l=u.map(([f,p])=>p.subscribe(h=>{c(f,h)}));return()=>{for(let f of l)f()}},up:(c,l)=>{try{this.resolve(c).up?.(l)}catch(f){if(f instanceof Ee)return;throw f}}}}_observeReactive(e,n){let r=n.tiers,s=r!=null?new Set(r):null,o=n.reactiveName??"observe";return A(i=>{let a=[],d=!1,u=!1,c=()=>{if(a.length===0||u)return;let g={events:a.slice(),flushedAt_ns:ee()};a.length=0,i.emit(g)},l={...n,reactive:!1,structured:!0,timeline:!0},f=e!=null?this.observe(e,l):this.observe(l),p=g=>{u||(a.push(g),!d&&(d=!0,nt(()=>{d=!1,c()})))};for(let g of f.events)p(g);let h=f.onEvent(p);return()=>{u=!0,h(),f.dispose()}},{name:o,meta:{domain:"audit",kind:"observe-reactive"}})}_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,l)=>c[0]<l[0]?-1:c[0]>l[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,l=c!=null&&c>0?new Qe(c):null,f=[],p=new Set,h=n.tiers!=null?new Set(n.tiers):null,g={},m=new Set,y=0,b=0,v=0,w=0,_=0,x=0,T=!1,N=!1,R=0,M=new Map,C=new Map,I=new Map,O=B=>{if(!(h!=null&&!h.has(B.type))){l?l.push(B):f.push(B);for(let Q of p)Q(B)}},P=B=>h==null||h.has(B),X=()=>s?{timestamp_ns:ee(),in_batch:Ct(),batch_id:R}:{},K=(B,Q)=>{if(!(!u||!(B instanceof se)))return B._setInspectorHook(be=>{if(be.kind==="dep_message")M.set(B,be.depIndex);else if(be.kind==="run"){let Ke=be.batchData.map((j,le)=>j!=null&&j.length>0?j.at(-1):be.prevData[le]);C.set(B,Ke);let ve=be.batchData.map(j=>j!=null?[...j]:void 0);I.set(B,ve),i&&O({type:"derived",path:Q,dep_values:Ke,dep_batches:ve,...X()})}})},re=B=>{let Q=M.get(B),be=C.get(B);if(!o||be==null)return{};let ve=(Q!=null&&Q>=0&&B instanceof se?B._deps[Q]:void 0)?.node,j=ve?.v,le=I.get(B);return{trigger_dep_index:Q,trigger_dep_name:ve?.name,...j!=null?{trigger_version:{id:j.id,version:j.version}}:{},dep_values:[...be],...le!=null?{dep_batches:le}:{}}},Ne=[],Be=[];for(let[B,Q]of e){let be=K(Q,B);be&&Ne.push(be),Be.push(Q.subscribe(Ke=>{R++;for(let ve of Ke){let j=ve[0],le=X();if(j===k){g[B]=ve[1];let gt=Q instanceof se?Q.lastMutation?.actor??ot:ot;O({type:"data",path:B,data:ve[1],actor:gt,...le,...re(Q)})}else if(a)j===$?P("dirty")&&y++:j===D?P("resolved")&&b++:j===we?P("invalidate")&&v++:j===ge?P("pause")&&w++:j===xe?P("resume")&&_++:j===z?P("teardown")&&x++:j===S&&!m.has(B)?P("complete")&&(T=!0):j===E&&P("error")&&(N=!0,m.add(B));else if(j===$)P("dirty")&&y++,O({type:"dirty",path:B,...le});else if(j===D)P("resolved")&&b++,O({type:"resolved",path:B,...le,...re(Q)});else if(j===we)P("invalidate")&&v++,O({type:"invalidate",path:B,...le});else if(j===ge)P("pause")&&w++,O({type:"pause",path:B,lockId:ve[1],...le});else if(j===xe)P("resume")&&_++,O({type:"resume",path:B,lockId:ve[1],...le});else if(j===S)P("complete")&&!m.has(B)&&(T=!0),O({type:"complete",path:B,...le});else if(j===E){P("error")&&(N=!0,m.add(B));let gt=Q instanceof se?Q.lastMutation?.actor??ot:ot;O({type:"error",path:B,data:ve[1],actor:gt,...le})}else j===z&&(P("teardown")&&x++,O({type:"teardown",path:B,...le}))}}))}let Se=!1,ke=()=>{if(!Se){Se=!0;for(let B of Be)B();for(let B of Ne)B();for(let B of Ve)B({value:void 0,done:!0});Ve.length=0}},Ge=[],Ve=[];p.add(B=>{let Q=Ve.shift();Q?Q({value:B,done:!1}):Ge.push(B)});let $e={get values(){return g},get dirtyCount(){return y},get resolvedCount(){return b},get invalidateCount(){return v},get pauseCount(){return w},get resumeCount(){return _},get teardownCount(){return x},get events(){return l?l.toArray():[...f]},get anyCompletedCleanly(){return T},get anyErrored(){return N},get completedWithoutErrors(){return T&&!N},onEvent(B){return p.add(B),()=>p.delete(B)},dispose:ke,expand(B){ke();let Q={...n};return typeof B=="string"?Q.detail=B:Object.assign(Q,B),r(Mo(Q))},[Symbol.asyncIterator](){return{next(){return Ge.length>0?Promise.resolve({value:Ge.shift(),done:!1}):Se?Promise.resolve({value:void 0,done:!0}):new Promise(B=>Ve.push(B))},return(){return ke(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger($e,n),$e}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let s=n.logger??(h=>console.log(h)),o=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=o==null&&i==null?()=>!0:h=>(o==null||o.has(h))&&(i==null||!i.has(h)),d=_u(n.theme),u=r==="stage-log"?ee():0,c=h=>h==null?"":n.stageLabels?.[h]??h,l=(h,g)=>h.length>g?`${h.slice(0,g-1)}\u2026`:h,f=h=>h.type==="data"||h.type==="error"?l(cn(h.data),120):"",p=h=>{if(r==="stage-log"){let T=(ee()-u)/1e9,N=c(h.path).padEnd(9);if(h.type==="data"){let R=f(h);return`[${T.toFixed(3)}s] ${N} \u2190${R?` ${R}`:""}`}if(h.type==="error"){let R=f(h);return`[${T.toFixed(3)}s] ${N} \u2717${R?` ${R}`:""}`}return h.type==="complete"?`[${T.toFixed(3)}s] ${N} \u25A0 complete`:`[${T.toFixed(3)}s] ${N} ${h.type}`}if(r==="json")try{return JSON.stringify(h)}catch{return JSON.stringify({type:h.type,path:h.path,data:"[unserializable]"})}let g=d[h.type]??"",m=h.path?`${d.path}${h.path}${d.reset} `:"",y=h.type==="data"||h.type==="error",b=h.type==="pause"||h.type==="resume",v=y?` ${cn(h.data)}`:b?` ${cn(h.lockId)}`:"",w=h.type==="data"||h.type==="resolved"||h.type==="derived"?h:void 0,_=w?.trigger_dep_name!=null?` <- ${w.trigger_dep_name}`:w?.trigger_dep_index!=null?` <- #${w.trigger_dep_index}`:"",x=h.in_batch?" [batch]":"";return`${m}${g}${h.type.toUpperCase()}${d.reset}${v}${_}${x}`};e.onEvent(h=>{a(h.type)&&s(p(h),h)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){Oo(this._disposers,this.name),this.signal([[z]],{internal:!0}),Oo(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand: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 mr(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??pe,{codec:s,codecVersion:o,payload:i}=gr(e,r);return s.decode(i,o)}restore(e,n){if(Ro(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=>dn(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){Ro(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 p of[...e.subgraphs].sort((h,g)=>{let m=h.split(ne).length,y=g.split(ne).length;return m!==y?m-y:h<g?-1:h>g?1:0})){let h=p.split(ne),g=o;for(let m of h)g._mounts.has(m)||g.mount(m,new t(m)),g=g._mounts.get(m)}let i=s?Object.entries(s).map(([p,h])=>({re:dn(p),factory:h})):[],a=p=>{for(let h of i)if(h.re.test(p))return h.factory},d=p=>{let h=p.split(ne),g=h.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${p}"`);let m=o;for(let y of h){let b=m._mounts.get(y);if(!b)throw new Error(`unknown mount "${y}" in path "${p}"`);m=b}return[m,g]},u=Object.entries(e.nodes).filter(([p])=>!p.includes(`${ne}${Ae}${ne}`)).sort((p,h)=>p[0]<h[0]?-1:p[0]>h[0]?1:0),c=new Map(u),l=new Map,f=!0;for(;c.size>0&&f;){f=!1;for(let[p,h]of[...c.entries()]){let g=h?.deps??[];if(!g.every(_=>l.has(_)))continue;let[m,y]=d(p),b={...h?.meta??{}},v=a(p),w;if(h?.type==="state")w=V(h.value,{meta:b});else{if(v==null)continue;w=v(y,{path:p,type:h.type,value:h.value,meta:b,deps:g,resolvedDeps:g.map(_=>l.get(_))})}m.add(w,{name:y}),l.set(p,w),c.delete(p),f=!0}}if(c.size>0){let p=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${p}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachSnapshotStorage(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 l=lu(c.nodes);if(u.lastSnapshot!=null&&l!==""&&l===u.lastFingerprint)return;let f=u.seq+1,p=oe(),m=u.lastSnapshot==null||f%u.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:f,timestamp_ns:p,format_version:ft}:{name:this.name,mode:"diff",diff:Ou(u.lastSnapshot,c),seq:f,timestamp_ns:p,format_version:ft};if(u.tier.filter&&!u.tier.filter(m))return;let y;try{y=u.tier.save(m)}catch(b){n.onError?.(b,u.tier);return}if(y&&typeof y.then=="function"){let w=(u.savePending??Promise.resolve()).then(()=>y,()=>y).then(()=>{u.disposed||(u.seq=f,u.lastSnapshot=c,u.lastFingerprint=l)},_=>{n.onError?.(_,u.tier)});u.savePending=w.finally(()=>{u.savePending===w&&(u.savePending=void 0)})}else u.seq=f,u.lastSnapshot=c,u.lastFingerprint=l},o=(u,c)=>{try{s(u,c)}catch(l){n.onError?.(l,u.tier)}},i=(u,c)=>{if(!c.some(h=>{let g=this.config.messageTier(h[0]);return g>=3&&g<5}))return;if(n.filter){let h=this.tryResolve(u);if(h==null)return;let g=Pn(h,Vt("standard"));if(!n.filter(u,g))return}let f,p=()=>(f==null&&(f=this.snapshot()),f);for(let h of r)h.disposed||(h.debounceMs===0?o(h,p()):(h.timer==null&&(h.timer=new Re),h.timer.start(h.debounceMs,()=>{h.disposed||o(h,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(l=>{let f=this.tryResolve(l);return f==null?()=>{}:f.subscribe(p=>i(l,p))});a=()=>{for(let l of c)l()}}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?.()}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===ft&&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?.()}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===ft&&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: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 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(b=>!r.has(b)).sort(),i=[...r].filter(b=>!s.has(b)).sort(),a=[],d=[];for(let b of r){if(!s.has(b))continue;let v=e.nodes[b],w=n.nodes[b],_=v.v,x=w.v;_!=null&&x!=null&&_.id===x.id&&_.version!==x.version&&d.push({path:b,id:_.id,from:_.version,to:x.version});let T=_!=null&&x!=null&&_.id===x.id&&_.version===x.version;for(let N of["type","status","sentinel"]){let R=v[N],M=w[N];R!==M&&a.push({path:b,field:N,from:R,to:M})}if(!T)for(let N of["value","meta"]){let R=v[N],M=w[N];fu(R,M)||a.push({path:b,field:N,from:R,to:M})}}let u=b=>`${b.from} ${b.to}`,c=new Set(e.edges.map(u)),l=new Set(n.edges.map(u)),f=n.edges.filter(b=>!c.has(u(b))),p=e.edges.filter(b=>!l.has(u(b))),h=new Set(e.subgraphs),g=new Set(n.subgraphs),m=[...g].filter(b=>!h.has(b)).sort(),y=[...h].filter(b=>!g.has(b)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:f,edgesRemoved:p,subgraphsAdded:m,subgraphsRemoved:y}}};function Ou(t,e){let n=Mt.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 Ao(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,w]of Object.entries(t.nodes)){if(!v)continue;c.add(v);let _=w.deps??[];i.set(v,_);for(let x of _)x&&(c.add(x),a.has(x)||a.set(x,new Set),a.get(x).add(v))}for(let v of t.edges){if(v==null||typeof v!="object")continue;let w=typeof v.from=="string"?v.from:"",_=typeof v.to=="string"?v.to:"";!w||!_||(c.add(w),c.add(_),u.has(w)||u.set(w,new Set),u.get(w).add(_),d.has(_)||d.set(_,new Set),d.get(_).add(w))}if(!c.has(e))return r.withDetail?s:[];let l=r.both===!0,f=v=>{if(l){let T=i.get(v)??[],N=d.get(v),R=a.get(v),M=u.get(v),C=[...T];return N&&C.push(...N),R&&C.push(...R),M&&C.push(...M),C}if(n==="upstream"){let T=i.get(v)??[],N=d.get(v);return N?[...T,...N]:T}let w=a.get(v),_=u.get(v),x=w?[...w]:[];return _&&x.push(..._),x},p=new Set([e]),h=new Map,g=[{path:e,depth:0}],m=0,y=!1;for(;m<g.length;){let v=g[m++];if(o!=null&&v.depth>=o){f(v.path).length>0&&(y=!0);continue}for(let w of f(v.path))!w||p.has(w)||(p.add(w),h.set(w,v.depth+1),g.push({path:w,depth:v.depth+1}))}let b=[...h.keys()].sort((v,w)=>v<w?-1:v>w?1:0);return r.withDetail?{paths:b,depths:h,truncated:y}:b}function Ru(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 Mu(t,e,n,r){let s=new Mt(t,r);s.add(e,{name:"source"});let o=V(n,{meta:{kind:"stratify_rules"}});s.add(o,{name:"rules"});for(let i of n)Au(s,e,o,i);return s}function Au(t,e,n,r){let s=`branch/${r.name}`,o=Symbol("noValue"),i=!1,a=!1,d=!1,u=o,c=!1,l=n.cache??[];function f(g){if(d){d=!1;let m=u;if(u=o,m!==o){let y=l.find(v=>v.name===r.name),b=!1;try{b=y?.classify(m)??!1}catch{b=!1}b?(c=!1,g.emit(m)):c&&(c=!1,g.down([[$],[D]]))}else c?(c=!1,g.down([[$],[D]])):g.down([[D]])}}let p=G([],(g,m)=>{let y=e.subscribe(v=>{for(let w of v)h(w,0,m)}),b=n.subscribe(v=>{for(let w of v)h(w,1,m)});return()=>{y(),b()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:r.name},completeWhenDepsComplete:!1});function h(g,m,y){let b=g[0];return b===$?(m===0?(i=!0,c=!0):a=!0,!0):b===k||b===D?(m===0?(i=!1,d=!0,u=b===k?g[1]:o):(b===k&&(l=g[1]),a=!1),i||a||f(y),!0):b===S||b===E||b===z?(i=!1,a=!1,d=!1,u=o,c=!1,m===0&&y.down([g]),!0):m===1}if(t.add(p,{name:s}),r.ops){let g=r.ops(p),m=`branch/${r.name}/out`;t.add(g,{name:m})}}Ft();Te();te();ye();ce();De();te();var Cu=new Map([[we,"INVALIDATE"],[ge,"PAUSE"],[xe,"RESUME"],[z,"TEARDOWN"],[S,"COMPLETE"],[E,"ERROR"]]),Du=new Map([["INVALIDATE",we],["PAUSE",ge],["RESUME",xe],["TEARDOWN",z],["COMPLETE",S],["ERROR",E]]);function Xe(t){let e=Cu.get(t);return e||(Symbol.keyFor(t)??"UNKNOWN")}function pt(t){let e=Du.get(t);if(e)return e;if(t&&t!=="UNKNOWN")return Symbol.for(t)}function ht(t){return t instanceof Error?{message:t.message,name:t.name,stack:t.stack}:{message:String(t),name:"Error"}}function mt(t){let e=new Error(t.message);return e.name=t.name,t.stack&&(e.stack=t.stack),e}function Ze(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 Ze(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 Pu(t){return typeof t=="object"&&t!==null&&typeof t.post=="function"&&typeof t.listen=="function"}function Bo(t,e){let n=Pu(t)?t:Ze(t),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 b of o){let v=V(void 0,{name:`${r}::${b}`});u.set(b,v)}let l;if(s.length>0){let b=s.map(([,_])=>_),v=G(b,(_,x)=>{let T={};for(let N=0;N<s.length;N++){let[R]=s[N],M=_[N];M!=null&&M.length>0&&(T[R]=M.at(-1))}Object.keys(T).length!==0&&x.emit(T)},{name:`${r}::aggregated`,partial:!0});l=Gt([v],_=>{let x=_[0];if(x==null||Object.keys(x).length===0)return;let T=[];for(let M of Object.keys(x)){let C=i[M];C&&T.push(...C(x[M]))}let N;for(let[M,C]of s)M in x&&C.v!=null&&(N==null&&(N={}),N[M]=C.v.version);let R={t:"b",u:x,...N?{v:N}:{}};try{n.post(R,T.length>0?T:void 0)}catch(M){d.down([[k,M instanceof Error?M:new Error(String(M))]])}}).subscribe(()=>{})}let f=!1,p=n.listen(b=>{if(f)return;let v=b;switch(v.t){case"r":{H(()=>{for(let[_,x]of Object.entries(v.stores)){let T=u.get(_);T&&T.down([[k,x]])}}),a.down([[k,"connected"]]);let w={};for(let[_,x]of s)w[_]=x.cache;n.post({t:"i",stores:w});break}case"v":{let w=u.get(v.s);w&&w.down([[k,v.d]]);break}case"b":{H(()=>{for(let[w,_]of Object.entries(v.u)){let x=v.v?.[w];if(x!=null){let N=c.get(w);if(N!=null&&x<=N)continue;c.set(w,x)}let T=u.get(w);T&&T.down([[k,_]])}});break}case"e":{let w=u.get(v.s);w&&w.down([[E,mt(v.err)]]);break}case"s":{let w=pt(v.sig);if(!w)break;let _=v.s==="*"?[...u.values()]:u.has(v.s)?[u.get(v.s)]:[];for(let x of _)x.down(v.d===void 0?[[w]]:[[w,v.d]]);break}}}),h=[];for(let[b,v]of s){let w=v.subscribe((_=>{if(!f)for(let x of _){let T=x[0];T!==k&&(pe.isLocalOnly(T)||(T===E?n.post({t:"e",s:b,err:ht(x[1])}):n.post({t:"s",s:b,sig:Xe(T),d:x.length>1?x[1]:void 0})))}}));h.push(w)}let g;if(e.timeoutMs!=null&&e.timeoutMs>0){let b=qe(e.timeoutMs),v=Ht(a,_=>_==="connected");g=qn(_t(jt(b,()=>"timeout"),jt(v,()=>"ready"))).subscribe(_=>{for(let x of _)x[0]===k&&x[1]==="timeout"&&(d.down([[k,new Error("Worker bridge handshake timeout")]]),m())})}function m(){if(!f){f=!0,g?.(),n.post({t:"s",s:"*",sig:Xe(z)}),l&&l();for(let b of h)b();h.length=0,p(),a.down([[k,"closed"]]),c.clear(),u.clear()}}let y={meta:{status:a,error:d},destroy:m};for(let[b,v]of u)y[b]=v;return y}Te();te();ye();ce();function Iu(t){return typeof t=="object"&&t!==null&&typeof t.post=="function"&&typeof t.listen=="function"}function Go(t,e){let n=Iu(t)?t:Ze(t),r=e.import??[],s=e.transfer??{},o=new Map,i=new Map,a={};for(let m of r){let y=V(void 0,{name:`worker::${m}`});o.set(m,y),a[m]=y}let d=e.expose(a),u=Object.entries(d),c,l=!1;if(u.length>0){let m=u.map(([,v])=>v),y=G(m,(v,w)=>{let _={};for(let x=0;x<u.length;x++){let[T]=u[x],N=v[x];N!=null&&N.length>0&&(_[T]=N.at(-1))}Object.keys(_).length!==0&&w.emit(_)},{name:"workerSelf::aggregated",partial:!0});c=Gt([y],v=>{if(l)return;let w=v[0];if(w==null||Object.keys(w).length===0)return;let _=[];for(let N of Object.keys(w)){let R=s[N];R&&_.push(...R(w[N]))}let x;for(let[N,R]of u)N in w&&R.v!=null&&(x==null&&(x={}),x[N]=R.v.version);let T={t:"b",u:w,...x?{v:x}:{}};try{n.post(T,_.length>0?_:void 0)}catch{}}).subscribe(()=>{})}let f=[];for(let[m,y]of u){let b=y.subscribe((v=>{if(!l)for(let w of v){let _=w[0];_!==k&&(pe.isLocalOnly(_)||(_===E?n.post({t:"e",s:m,err:ht(w[1])}):n.post({t:"s",s:m,sig:Xe(_),d:w.length>1?w[1]:void 0})))}}));f.push(b)}let p=n.listen(m=>{if(l)return;let y=m;switch(y.t){case"i":{H(()=>{for(let[b,v]of Object.entries(y.stores)){let w=o.get(b);w&&w.down([[k,v]])}});break}case"v":{let b=o.get(y.s);b&&b.down([[k,y.d]]);break}case"b":{H(()=>{for(let[b,v]of Object.entries(y.u)){let w=y.v?.[b];if(w!=null){let x=i.get(b);if(x!=null&&w<=x)continue;i.set(b,w)}let _=o.get(b);_&&_.down([[k,v]])}});break}case"e":{let b=o.get(y.s);b&&b.down([[E,mt(y.err)]]);break}case"s":{let b=pt(y.sig);if(!b)break;if(b===z&&y.s==="*"){g();return}let v=y.s==="*"?[...o.values()]:o.has(y.s)?[o.get(y.s)]:[];for(let w of v)w.down(y.d===void 0?[[b]]:[[b,y.d]]);break}}}),h={};for(let[m,y]of u)h[m]=y.cache;n.post({t:"r",stores:h});function g(){if(!l){l=!0,c&&c();for(let m of f)m();f.length=0,p(),n.terminate?.(),i.clear(),o.clear()}}return{destroy:g}}0&&(module.exports={CircuitOpenError,ContentAddressedMissError,NS_PER_MS,NS_PER_SEC,NativeIndexBackend,NativeListBackend,NativeLogBackend,NativeMapBackend,NativePubSubBackend,RateLimiterOverflowError,ResettableTimer,TimeoutError,appendLogStorage,audit,awaitSettled,buffer,bufferCount,bufferTime,cached,canonicalJson,cascadingCache,catchError,checkpointToRedis,checkpointToS3,circuitBreaker,combine,combineLatest,concat,concatMap,constant,contentAddressedStorage,createTransport,createWatermarkController,csvRows,debounce,debounceTime,decorrelatedJitter,defer,delay,deserializeError,dictKv,dictSnapshot,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,jsonCodec,jsonCodecFor,keepalive,kvStorage,last,linear,lru,makeHttpError,map,matchesAnyPattern,matchesCron,memoryAppendLog,memoryBackend,memoryKv,memorySnapshot,merge,mergeMap,mergeReactiveLogs,nameToSignal,ndjsonRows,never,nodeSignal,of,onFirstData,pairwise,parseCron,parsePrometheusText,parseSSEStream,parseStatsD,parseSyslog,pausable,pubsub,race,rateLimiter,reactiveCounter,reactiveIndex,reactiveList,reactiveLog,reactiveMap,reactiveSink,reduce,repeat,replay,rescue,resolveBackoffPreset,retry,sample,scan,serializeError,share,shareReplay,signalToName,singleFromAny,singleNodeFromAny,skip,snapshotStorage,sortJsonValue,stableJsonString,stratify,switchMap,take,takeUntil,takeWhile,tap,tapFirst,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,topologyDiff,valve,verifiable,window,windowCount,windowTime,withBreaker,withLatestFrom,withMaxAttempts,withStatus,workerBridge,workerSelf,zip});