@graphrefly/graphrefly 0.40.0 → 0.42.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 (296) hide show
  1. package/dist/{cascading-Cxs1eztH.d.cts → cascading-CH-_VwG9.d.cts} +2 -2
  2. package/dist/{cascading-BNfxffgc.d.ts → cascading-OgKQZjsa.d.ts} +2 -2
  3. package/dist/{chunk-CKFQS2CJ.js → chunk-2K5RXLAH.js} +1 -1
  4. package/dist/chunk-3ERTUW2J.js +45 -0
  5. package/dist/chunk-3K7HA4Y6.js +1 -0
  6. package/dist/chunk-3ZZX7M25.js +1 -0
  7. package/dist/chunk-4QH6VJF4.js +1 -0
  8. package/dist/{chunk-I2DEVPMU.js → chunk-5QRRKBUT.js} +1 -1
  9. package/dist/chunk-5ST42ESJ.js +1 -0
  10. package/dist/{chunk-FHRBBHJN.js → chunk-6YFZMUMR.js} +1 -1
  11. package/dist/{chunk-MNZIKXK4.js → chunk-7ARY3Y3T.js} +1 -1
  12. package/dist/chunk-7B7ELAT2.js +1 -0
  13. package/dist/{chunk-Z4F3DOWS.js → chunk-7VKFXLZQ.js} +1 -1
  14. package/dist/chunk-ACMJ2ZPS.js +3 -0
  15. package/dist/{chunk-32N3JALT.js → chunk-AGNM6RS6.js} +1 -1
  16. package/dist/chunk-AS3TV2TV.js +1 -0
  17. package/dist/{chunk-B7LCDQEV.js → chunk-CISGGAIF.js} +1 -1
  18. package/dist/{chunk-N43XM7BM.js → chunk-DEJTNNQC.js} +1 -1
  19. package/dist/{chunk-2QXRYP7Q.js → chunk-FDZAZNRO.js} +1 -1
  20. package/dist/{chunk-QSK3RRII.js → chunk-FUZ6S2DY.js} +1 -1
  21. package/dist/{chunk-LYM4PBMV.js → chunk-G5VBJ5K6.js} +1 -1
  22. package/dist/{chunk-6I726LZU.js → chunk-HZKW2AAB.js} +1 -1
  23. package/dist/{chunk-LCGAVGGV.js → chunk-IZM3UEH3.js} +3 -3
  24. package/dist/{chunk-2DMKW2AD.js → chunk-KCACBSJH.js} +1 -1
  25. package/dist/{chunk-SSCGRYJ2.js → chunk-KT5DTRBP.js} +1 -1
  26. package/dist/{chunk-WL6LFPJB.js → chunk-KY2LMAXU.js} +1 -1
  27. package/dist/{chunk-YXDRGKXP.js → chunk-LDQ3IUIP.js} +1 -1
  28. package/dist/chunk-LPRWATHB.js +61 -0
  29. package/dist/{chunk-6VWBPSSY.js → chunk-NWXQIOIB.js} +3 -3
  30. package/dist/{chunk-XW4YDF6G.js → chunk-Q7QQQA3I.js} +1 -1
  31. package/dist/chunk-VE5SIZEM.js +1 -0
  32. package/dist/chunk-VRALOYRD.js +1 -0
  33. package/dist/{chunk-XJLYLLIJ.js → chunk-WHMUB5QB.js} +1 -1
  34. package/dist/chunk-XLQPNNIC.js +1 -0
  35. package/dist/{chunk-JKBOIJ22.js → chunk-YGL7FPVQ.js} +1 -1
  36. package/dist/compat/index.cjs +5 -5
  37. package/dist/compat/index.d.cts +16 -16
  38. package/dist/compat/index.d.ts +16 -16
  39. package/dist/compat/index.js +1 -1
  40. package/dist/compat/jotai/index.d.cts +2 -2
  41. package/dist/compat/jotai/index.d.ts +2 -2
  42. package/dist/compat/nanostores/index.d.cts +2 -2
  43. package/dist/compat/nanostores/index.d.ts +2 -2
  44. package/dist/compat/nestjs/index.cjs +5 -5
  45. package/dist/compat/nestjs/index.d.cts +8 -8
  46. package/dist/compat/nestjs/index.d.ts +8 -8
  47. package/dist/compat/nestjs/index.js +1 -1
  48. package/dist/compat/react/index.d.cts +2 -2
  49. package/dist/compat/react/index.d.ts +2 -2
  50. package/dist/compat/solid/index.d.cts +2 -2
  51. package/dist/compat/solid/index.d.ts +2 -2
  52. package/dist/compat/svelte/index.d.cts +2 -2
  53. package/dist/compat/svelte/index.d.ts +2 -2
  54. package/dist/compat/vue/index.d.cts +2 -2
  55. package/dist/compat/vue/index.d.ts +2 -2
  56. package/dist/compat/zustand/index.cjs +3 -3
  57. package/dist/compat/zustand/index.d.cts +4 -4
  58. package/dist/compat/zustand/index.d.ts +4 -4
  59. package/dist/compat/zustand/index.js +1 -1
  60. package/dist/core/index.d.cts +4 -4
  61. package/dist/core/index.d.ts +4 -4
  62. package/dist/{decay-C25AyNAj.d.cts → decay-2ZukgQ4o.d.cts} +2 -2
  63. package/dist/{decay-BnrlbxSv.d.ts → decay-CdEBmDIs.d.ts} +2 -2
  64. package/dist/extra/browser.d.cts +1 -1
  65. package/dist/extra/browser.d.ts +1 -1
  66. package/dist/extra/index.cjs +14 -14
  67. package/dist/extra/index.d.cts +10 -11
  68. package/dist/extra/index.d.ts +10 -11
  69. package/dist/extra/index.js +1 -1
  70. package/dist/extra/node.cjs +2 -2
  71. package/dist/extra/node.d.cts +1 -1
  72. package/dist/extra/node.d.ts +1 -1
  73. package/dist/extra/node.js +1 -1
  74. package/dist/extra/operators.cjs +1 -1
  75. package/dist/extra/operators.d.cts +1 -1
  76. package/dist/extra/operators.d.ts +1 -1
  77. package/dist/extra/operators.js +1 -1
  78. package/dist/extra/reactive.d.cts +3 -3
  79. package/dist/extra/reactive.d.ts +3 -3
  80. package/dist/extra/reactive.js +1 -1
  81. package/dist/extra/render/index.d.cts +3 -3
  82. package/dist/extra/render/index.d.ts +3 -3
  83. package/dist/extra/sources.cjs +3 -1
  84. package/dist/extra/sources.d.cts +1 -1
  85. package/dist/extra/sources.d.ts +1 -1
  86. package/dist/extra/sources.js +1 -1
  87. package/dist/extra/storage-browser.d.cts +1 -1
  88. package/dist/extra/storage-browser.d.ts +1 -1
  89. package/dist/{fallback-CMZl39L5.d.ts → fallback-CqYVLL6X.d.ts} +1 -1
  90. package/dist/{fallback-8JYU8tlT.d.cts → fallback-Ctlj2tMY.d.cts} +1 -1
  91. package/dist/graph/index.cjs +7 -7
  92. package/dist/graph/index.d.cts +5 -5
  93. package/dist/graph/index.d.ts +5 -5
  94. package/dist/graph/index.js +1 -1
  95. package/dist/{graph-BkIkog4h.d.ts → graph-7VguS7a4.d.ts} +3 -3
  96. package/dist/{graph-E6likq7w.d.cts → graph-C4SHb3Ly.d.cts} +3 -3
  97. package/dist/{index-DktLSZOc.d.cts → index-2B7u2pVn.d.cts} +4 -4
  98. package/dist/{index-BTHOTC0Q.d.cts → index-3NmAfcH0.d.cts} +25 -7
  99. package/dist/{index-D1IEZUsj.d.ts → index-4Uz-e_fL.d.ts} +573 -213
  100. package/dist/{index-BAQrjuZF.d.ts → index-B-i4_g3k.d.ts} +2 -2
  101. package/dist/{index-DpiGqtrs.d.cts → index-B11anra4.d.cts} +441 -381
  102. package/dist/{index-WSlcjhQF.d.ts → index-B3OTH1dV.d.ts} +124 -13
  103. package/dist/{index-2n8Eai6M.d.ts → index-BG0BN3PB.d.ts} +1 -1
  104. package/dist/{index-z8WFPVI8.d.cts → index-BJX94aud.d.cts} +1 -1
  105. package/dist/{index-DhLyOHYZ.d.ts → index-BP8a88zx.d.ts} +11 -4
  106. package/dist/{index-Cnr1WrlX.d.cts → index-BTQtTb_H.d.cts} +14 -3
  107. package/dist/{index-BaA-xpSw.d.ts → index-BUYXac2c.d.ts} +3 -3
  108. package/dist/{index-DOBLxOti.d.cts → index-BVpm6noz.d.cts} +1 -1
  109. package/dist/{index-DhnsQfa3.d.ts → index-Bbkgpt5t.d.ts} +441 -381
  110. package/dist/{index-Cczxgd2D.d.ts → index-Bc41FuHp.d.cts} +3 -3
  111. package/dist/{index-BiHUBEKq.d.cts → index-BdGtBX-X.d.cts} +3 -3
  112. package/dist/index-BeT2r7sk.d.ts +760 -0
  113. package/dist/{index-da2V5vPy.d.ts → index-Bf7eqeSF.d.ts} +2 -2
  114. package/dist/{index-bXXLSvor.d.ts → index-Bn4zHYLj.d.ts} +4 -4
  115. package/dist/{index-DGTo1yka.d.cts → index-BoLv_OfD.d.cts} +2 -2
  116. package/dist/{index-B72TQQHd.d.cts → index-BsT7F2et.d.ts} +3 -3
  117. package/dist/{index-Bd91Nmf4.d.cts → index-BtAsBp8K.d.cts} +4 -4
  118. package/dist/{index-DgJc8Zgc.d.cts → index-C0-Jv1kP.d.cts} +81 -5
  119. package/dist/{index-C6ZUaos7.d.ts → index-C7O6r5fV.d.ts} +1 -1
  120. package/dist/{index-CL7oilfm.d.cts → index-C9kSENB4.d.cts} +1 -1
  121. package/dist/{index-yLt-aPMp.d.ts → index-CCq87F7t.d.ts} +1 -1
  122. package/dist/{index-DQQCOIt8.d.cts → index-CEMx8n40.d.cts} +10 -5
  123. package/dist/{index-BilOa6AE.d.cts → index-CJIuLu2f.d.cts} +124 -13
  124. package/dist/{index-B2RUoIUz.d.ts → index-CJK1JkYy.d.ts} +1 -1
  125. package/dist/{index-IUCY0OFN.d.ts → index-CJQm0g38.d.ts} +25 -7
  126. package/dist/index-CPNSy-U0.d.cts +760 -0
  127. package/dist/{index-A3U3CSve.d.cts → index-CZjOhcBy.d.cts} +2 -2
  128. package/dist/{index-CAP3UGsq.d.ts → index-CZmcDtFn.d.ts} +1 -1
  129. package/dist/{index-DYTBbF8T.d.cts → index-ChOyVLKm.d.cts} +1 -1
  130. package/dist/{index-eaQuGJnv.d.ts → index-CpyNFqkB.d.ts} +3 -3
  131. package/dist/{index-BJSZxSFX.d.ts → index-CvrqGfNS.d.ts} +1 -1
  132. package/dist/{index-DJ_MPOJ5.d.cts → index-D-Xs74HZ.d.cts} +573 -213
  133. package/dist/{index-C5cQ7Gfx.d.ts → index-D6egPFAL.d.ts} +4 -4
  134. package/dist/{index-CD2dBMet.d.ts → index-D8l8hNXn.d.ts} +10 -5
  135. package/dist/{index-40ZT4MHj.d.ts → index-DBHK8O6H.d.ts} +14 -3
  136. package/dist/{index-DVDapw2k.d.cts → index-DBIqYS43.d.cts} +35 -21
  137. package/dist/{index-3k4Gg6-n.d.ts → index-DBevwHj_.d.ts} +3 -3
  138. package/dist/{index-Ctb7_2sG.d.ts → index-DIOoAZUX.d.ts} +1 -1
  139. package/dist/{index-BQ1fR4li.d.ts → index-DO9XxMzS.d.ts} +35 -21
  140. package/dist/{index-CQtWm7jS.d.ts → index-DQo8xBgd.d.ts} +9 -9
  141. package/dist/{index-DH4fm2Ck.d.ts → index-Dgs8zcj7.d.ts} +2 -2
  142. package/dist/{index-CtFNGe-m.d.cts → index-Dhc7a7Xo.d.cts} +2 -2
  143. package/dist/{index-MxYuWOrf.d.cts → index-DmAgG5CI.d.cts} +3 -3
  144. package/dist/{index-CoM4rzyB.d.ts → index-Dmqp7KjD.d.ts} +1 -1
  145. package/dist/{index-B6iTqKtJ.d.ts → index-Dn-wI9g4.d.ts} +2 -2
  146. package/dist/{index-C-dkXOpB.d.cts → index-Du7u1lSf.d.cts} +11 -4
  147. package/dist/{index-DVAlsmEU.d.cts → index-HoU88d5U.d.cts} +3 -3
  148. package/dist/{index-CRm0YIzC.d.cts → index-LIpQQE9f.d.cts} +9 -9
  149. package/dist/{index-CgnCFhr2.d.cts → index-f5IivDUX.d.cts} +1 -1
  150. package/dist/{index-PgwvGWa1.d.cts → index-hHcaFlJX.d.cts} +1 -1
  151. package/dist/{index-I1cCY3ZI.d.ts → index-pT8sCpOJ.d.ts} +81 -5
  152. package/dist/{index-D4uimgee.d.cts → index-sl4NyzQx.d.cts} +1 -1
  153. package/dist/{index-tV3AA9hI.d.cts → index-tJoTcnHh.d.cts} +2 -2
  154. package/dist/{index-D3ayz3hy.d.cts → index-z96luz5O.d.cts} +1 -1
  155. package/dist/index.cjs +48 -48
  156. package/dist/index.d.cts +45 -50
  157. package/dist/index.d.ts +45 -50
  158. package/dist/index.js +1 -1
  159. package/dist/{meta-D8OyedKp.d.ts → meta-BgVAsg9j.d.ts} +1 -1
  160. package/dist/{meta-Ct9nqQS5.d.cts → meta-vE8bxW1E.d.cts} +1 -1
  161. package/dist/{node-BYInONRr.d.cts → node-ClS5yC-B.d.cts} +1 -1
  162. package/dist/{node-BYInONRr.d.ts → node-ClS5yC-B.d.ts} +1 -1
  163. package/dist/{observable-DO8DDEzv.d.ts → observable-BsBzUrcI.d.ts} +1 -1
  164. package/dist/{observable-DMIlYJV1.d.cts → observable-DLGPPtb8.d.cts} +1 -1
  165. package/dist/patterns/ai/browser.d.cts +4 -4
  166. package/dist/patterns/ai/browser.d.ts +4 -4
  167. package/dist/patterns/ai/browser.js +1 -1
  168. package/dist/patterns/ai/index.cjs +17 -17
  169. package/dist/patterns/ai/index.d.cts +17 -17
  170. package/dist/patterns/ai/index.d.ts +17 -17
  171. package/dist/patterns/ai/index.js +1 -1
  172. package/dist/patterns/ai/node.d.cts +4 -4
  173. package/dist/patterns/ai/node.d.ts +4 -4
  174. package/dist/patterns/ai/node.js +1 -1
  175. package/dist/patterns/cqrs/index.cjs +3 -3
  176. package/dist/patterns/cqrs/index.d.cts +6 -6
  177. package/dist/patterns/cqrs/index.d.ts +6 -6
  178. package/dist/patterns/cqrs/index.js +1 -1
  179. package/dist/patterns/demo-shell/index.cjs +5 -5
  180. package/dist/patterns/demo-shell/index.d.cts +5 -5
  181. package/dist/patterns/demo-shell/index.d.ts +5 -5
  182. package/dist/patterns/demo-shell/index.js +1 -1
  183. package/dist/patterns/domain-templates/index.cjs +3 -3
  184. package/dist/patterns/domain-templates/index.d.cts +4 -4
  185. package/dist/patterns/domain-templates/index.d.ts +4 -4
  186. package/dist/patterns/domain-templates/index.js +1 -1
  187. package/dist/patterns/graphspec/index.cjs +12 -12
  188. package/dist/patterns/graphspec/index.d.cts +5 -5
  189. package/dist/patterns/graphspec/index.d.ts +5 -5
  190. package/dist/patterns/graphspec/index.js +1 -1
  191. package/dist/patterns/harness/index.cjs +10 -8
  192. package/dist/patterns/harness/index.d.cts +11 -12
  193. package/dist/patterns/harness/index.d.ts +11 -12
  194. package/dist/patterns/harness/index.js +1 -1
  195. package/dist/patterns/inspect/index.cjs +3 -0
  196. package/dist/patterns/inspect/index.d.cts +9 -0
  197. package/dist/patterns/inspect/index.d.ts +9 -0
  198. package/dist/patterns/inspect/index.js +1 -0
  199. package/dist/patterns/job-queue/index.cjs +3 -3
  200. package/dist/patterns/job-queue/index.d.cts +6 -6
  201. package/dist/patterns/job-queue/index.d.ts +6 -6
  202. package/dist/patterns/job-queue/index.js +1 -1
  203. package/dist/patterns/memory/index.cjs +3 -3
  204. package/dist/patterns/memory/index.d.cts +6 -6
  205. package/dist/patterns/memory/index.d.ts +6 -6
  206. package/dist/patterns/memory/index.js +1 -1
  207. package/dist/patterns/messaging/index.cjs +3 -3
  208. package/dist/patterns/messaging/index.d.cts +5 -5
  209. package/dist/patterns/messaging/index.d.ts +5 -5
  210. package/dist/patterns/messaging/index.js +1 -1
  211. package/dist/patterns/orchestration/index.cjs +3 -3
  212. package/dist/patterns/orchestration/index.d.cts +7 -7
  213. package/dist/patterns/orchestration/index.d.ts +7 -7
  214. package/dist/patterns/orchestration/index.js +1 -1
  215. package/dist/patterns/process/index.cjs +1 -1
  216. package/dist/patterns/process/index.d.cts +7 -7
  217. package/dist/patterns/process/index.d.ts +7 -7
  218. package/dist/patterns/process/index.js +1 -1
  219. package/dist/patterns/reactive-layout/index.cjs +4 -4
  220. package/dist/patterns/reactive-layout/index.d.cts +5 -5
  221. package/dist/patterns/reactive-layout/index.d.ts +5 -5
  222. package/dist/patterns/reactive-layout/index.js +1 -1
  223. package/dist/patterns/reduction/index.cjs +3 -3
  224. package/dist/patterns/reduction/index.d.cts +4 -4
  225. package/dist/patterns/reduction/index.d.ts +4 -4
  226. package/dist/patterns/reduction/index.js +1 -1
  227. package/dist/patterns/surface/index.cjs +8 -8
  228. package/dist/patterns/surface/index.d.cts +6 -6
  229. package/dist/patterns/surface/index.d.ts +6 -6
  230. package/dist/patterns/surface/index.js +1 -1
  231. package/dist/{pipeline-graph-MWrQZXCq.d.cts → pipeline-graph-WBlobVhU.d.cts} +5 -5
  232. package/dist/{pipeline-graph-CB4La-UW.d.ts → pipeline-graph-v8fMvqNk.d.ts} +5 -5
  233. package/dist/{reactive-layout-BtZfUKuL.d.cts → reactive-layout-Dsvob4zD.d.cts} +2 -2
  234. package/dist/{reactive-layout-KJj4E2dT.d.ts → reactive-layout-v7KPvxoc.d.ts} +2 -2
  235. package/dist/{reactive-log-_zeEnB9H.d.cts → reactive-log-B00laMSQ.d.cts} +1 -1
  236. package/dist/{reactive-log-BlAsPLl2.d.ts → reactive-log-BezYsbA_.d.ts} +1 -1
  237. package/dist/{reactive-map-6P_k3AQM.d.cts → reactive-map-48mnZ-nu.d.cts} +1 -1
  238. package/dist/{reactive-map-CjXByDV-.d.ts → reactive-map-BVVPdvmi.d.ts} +1 -1
  239. package/dist/resilience-445VFFXQ.js +1 -0
  240. package/dist/{sugar-BhfjgetH.d.ts → sugar-CH-2ZY90.d.ts} +1 -1
  241. package/dist/{sugar-DzePN5-g.d.cts → sugar-DStZfUEK.d.cts} +1 -1
  242. package/dist/{topology-tree-mF7Emqzm.d.ts → topology-tree-BNGvuG82.d.ts} +1 -1
  243. package/dist/{topology-tree-3LBKFsUo.d.cts → topology-tree-BSdfSwMi.d.cts} +1 -1
  244. package/dist/{types-1Dhoi7HM.d.cts → types-B1jDWVsM.d.cts} +1 -1
  245. package/dist/{types-39jk0kaV.d.ts → types-DkzUUs0H.d.ts} +1 -1
  246. package/package.json +11 -51
  247. package/dist/budget-gate-CmmVtasH.d.ts +0 -115
  248. package/dist/budget-gate-DiP_nK0n.d.cts +0 -115
  249. package/dist/chunk-2BX4NB34.js +0 -3
  250. package/dist/chunk-6XVD5TZV.js +0 -1
  251. package/dist/chunk-756D5TFD.js +0 -1
  252. package/dist/chunk-7Q4ZD3YW.js +0 -1
  253. package/dist/chunk-ECQRP2UT.js +0 -1
  254. package/dist/chunk-INQFTVZA.js +0 -61
  255. package/dist/chunk-J63M5U46.js +0 -1
  256. package/dist/chunk-K2Z7UENB.js +0 -1
  257. package/dist/chunk-OSZ22J7O.js +0 -1
  258. package/dist/chunk-PPUYQ66A.js +0 -1
  259. package/dist/chunk-RZJDIV2G.js +0 -1
  260. package/dist/chunk-SGS4OJGS.js +0 -1
  261. package/dist/chunk-SVFKHUCW.js +0 -1
  262. package/dist/chunk-UWA6D7UF.js +0 -3
  263. package/dist/chunk-VMF23LGB.js +0 -1
  264. package/dist/chunk-WUT362QV.js +0 -1
  265. package/dist/chunk-YKD7WUYJ.js +0 -43
  266. package/dist/index-8s-Qm-gz.d.ts +0 -218
  267. package/dist/index-BgjS2b8N.d.ts +0 -366
  268. package/dist/index-BmSQLAZo.d.cts +0 -244
  269. package/dist/index-CGhMJNHb.d.cts +0 -128
  270. package/dist/index-CUIkE1l9.d.cts +0 -230
  271. package/dist/index-Ck35nA-T.d.ts +0 -244
  272. package/dist/index-CuPUehFa.d.cts +0 -218
  273. package/dist/index-D1Gc7wV5.d.ts +0 -230
  274. package/dist/index-N2MAxt7_.d.ts +0 -128
  275. package/dist/index-t6L2qpHh.d.cts +0 -366
  276. package/dist/patterns/audit/index.cjs +0 -3
  277. package/dist/patterns/audit/index.d.cts +0 -8
  278. package/dist/patterns/audit/index.d.ts +0 -8
  279. package/dist/patterns/audit/index.js +0 -1
  280. package/dist/patterns/guarded-execution/index.cjs +0 -3
  281. package/dist/patterns/guarded-execution/index.d.cts +0 -9
  282. package/dist/patterns/guarded-execution/index.d.ts +0 -9
  283. package/dist/patterns/guarded-execution/index.js +0 -1
  284. package/dist/patterns/lens/index.cjs +0 -3
  285. package/dist/patterns/lens/index.d.cts +0 -7
  286. package/dist/patterns/lens/index.d.ts +0 -7
  287. package/dist/patterns/lens/index.js +0 -1
  288. package/dist/patterns/refine-loop/index.cjs +0 -5
  289. package/dist/patterns/refine-loop/index.d.cts +0 -9
  290. package/dist/patterns/refine-loop/index.d.ts +0 -9
  291. package/dist/patterns/refine-loop/index.js +0 -1
  292. package/dist/patterns/resilient-pipeline/index.cjs +0 -3
  293. package/dist/patterns/resilient-pipeline/index.d.cts +0 -8
  294. package/dist/patterns/resilient-pipeline/index.d.ts +0 -8
  295. package/dist/patterns/resilient-pipeline/index.js +0 -1
  296. package/dist/resilience-S33JV6XC.js +0 -1
@@ -1,4 +1,4 @@
1
- "use strict";var Je=Object.defineProperty;var On=Object.getOwnPropertyDescriptor;var Tn=Object.getOwnPropertyNames;var Sn=Object.prototype.hasOwnProperty;var H=(t,e)=>()=>(t&&(e=t(t=0)),e);var En=(t,e)=>{for(var n in e)Je(t,n,{get:e[n],enumerable:!0})},Cn=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Tn(e))!Sn.call(t,s)&&s!==n&&Je(t,s,{get:()=>e[s],enumerable:!(r=On(e,s))||r.enumerable});return t};var Rn=t=>Cn(Je({},"__esModule",{value:!0}),t);function B(){return Math.trunc(performance.now()*1e6)}function Re(){return Date.now()*1e6}var ue=H(()=>{"use strict"});function Dt(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++]=st,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 Gt(t,e){if(t.length<Mt)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${Mt})`);let n=0,r=t[n++];if(r!==st)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${st})`);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),u=e.lookupCodec(o);if(u==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:u,codecVersion:i,payload:a}}function Pt(t){t.registerCodec(Mn)}var Mn,st,Mt,ot=H(()=>{"use strict";Mn={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)}},st=1,Mt=4});function Ae(t){if(t==null)return he;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var he,it=H(()=>{"use strict";he={type:"system",id:""}});function Me(){return pe>0||_e}function It(){return pe>0}function me(t){pe>0?ke.push(t):t()}function Lt(t){pe+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(pe-=1,pe===0)if(e){if(!_e){let n=ke.splice(0);for(let r of n)try{r()}catch{}le.length=0,de.length=0,ge.length=0}}else Dn()}}function Dn(){let t=!_e;t&&(_e=!0);let e=[],n=0;try{for(;le.length>0||de.length>0||ge.length>0||t&&ke.length>0;){if(t&&ke.length>0){let o=ke.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw le.length=0,de.length=0,ge.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(le.length>0?le:de.length>0?de:ge).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{t&&(_e=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function be(t,e,n){if(e.length===0)return;if(e.length===1){let l=n(e[0][0]);if(l<3||!Me()){t(e);return}(l>=5?ge:l===4?de:le).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 u=Me();if(s>0){let l=e.slice(0,s);t(l)}if(o>s){let l=e.slice(s,o);u?le.push(()=>t(l)):t(l)}if(i>o){let l=e.slice(o,i);u?de.push(()=>t(l)):t(l)}if(r>i){let l=e.slice(i,r);u?ge.push(()=>t(l)):t(l)}}var pe,_e,le,de,ge,ke,De=H(()=>{"use strict";pe=0,_e=!1,le=[],de=[],ge=[],ke=[]});var Ne,$,Z,Q,Y,ee,se,j,V,I,ye,at,Gn,ut,Pn,In,lt,Ft,$t,Bt,dt,Oe=H(()=>{"use strict";Ne=Symbol.for("graphrefly/START"),$=Symbol.for("graphrefly/DATA"),Z=Symbol.for("graphrefly/DIRTY"),Q=Symbol.for("graphrefly/RESOLVED"),Y=Symbol.for("graphrefly/INVALIDATE"),ee=Symbol.for("graphrefly/PAUSE"),se=Symbol.for("graphrefly/RESUME"),j=Symbol.for("graphrefly/TEARDOWN"),V=Symbol.for("graphrefly/COMPLETE"),I=Symbol.for("graphrefly/ERROR"),ye=Object.freeze([Z]),at=Object.freeze([Q]),Gn=Object.freeze([Y]),ut=Object.freeze([Ne]),Pn=Object.freeze([V]),In=Object.freeze([j]),lt=Object.freeze([ye]),Ft=Object.freeze([at]),$t=Object.freeze([Gn]),Bt=Object.freeze([Pn]),dt=Object.freeze([In])});function jt(t){t.registerMessageType(Ne,{tier:0,wireCrossing:!1}),t.registerMessageType(Z,{tier:1,wireCrossing:!1}),t.registerMessageType(Y,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(ee,{tier:2,wireCrossing:!1}),t.registerMessageType(se,{tier:2,wireCrossing:!1}),t.registerMessageType($,{tier:3,wireCrossing:!0}),t.registerMessageType(Q,{tier:3,wireCrossing:!0}),t.registerMessageType(V,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(I,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(j,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Ge,Ht=H(()=>{"use strict";Oe();Ge=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 ct(t){let e=Ln.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 K,Ln,Pe=H(()=>{"use strict";K=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}},Ln=["human","llm","wallet","system"]});function ft(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(ft);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=ft(t[n]);return e}return null}function Bn(t){let e=$n.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,u=3144134277,l=1013904242,d=2773480762,h=1359893119,v=2600822924,m=528734635,c=1541459225,b=new Uint32Array(64),f=(g,y)=>g>>>y|g<<32-y;for(let g=0;g<s;g+=64){for(let O=0;O<16;O++)b[O]=i.getUint32(g+O*4,!1);for(let O=16;O<64;O++){let C=b[O-15],M=b[O-2],A=f(C,7)^f(C,18)^C>>>3,fe=f(M,17)^f(M,19)^M>>>10;b[O]=b[O-16]+A+b[O-7]+fe>>>0}let y=a,w=u,p=l,_=d,k=h,N=v,T=m,E=c;for(let O=0;O<64;O++){let C=f(k,6)^f(k,11)^f(k,25),M=k&N^~k&T,A=E+C+M+Fn[O]+b[O]>>>0,fe=f(y,2)^f(y,13)^f(y,22),ze=y&w^y&p^w&p,Ee=fe+ze>>>0;E=T,T=N,N=k,k=_+A>>>0,_=p,p=w,w=y,y=A+Ee>>>0}a=a+y>>>0,u=u+w>>>0,l=l+p>>>0,d=d+_>>>0,h=h+k>>>0,v=v+N>>>0,m=m+T>>>0,c=c+E>>>0}let x=g=>g.toString(16).padStart(8,"0");return x(a)+x(u)+x(l)+x(d)+x(h)+x(v)+x(m)+x(c)}function ht(t){let e=ft(t??null),n=JSON.stringify(e);return Bn(n).slice(0,16)}function jn(){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 pt(t,e,n){let r=n?.id??jn();if(t===0)return{id:r,version:0};let o=(n?.hash??ht)(e);return{id:r,version:0,cid:o,prev:null}}function Wt(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Fn,$n,Vt=H(()=>{"use strict";Fn=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]),$n=new TextEncoder});function Kt(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function gt(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Ie(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function te(t,e,n){let r=qt(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,o={};return qt(t)?o=(mt(e)?e:n)??{}:mt(t)?o=t:o=(mt(e)?e:n)??{},new L(r,s,o)}var zt,Ut,Hn,Wn,oe,L,qt,mt,ne=H(()=>{"use strict";ot();it();De();ue();Ht();Pe();Oe();Vt();zt=()=>{},Ut=100;Hn=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},Wn=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[ut]:[ut,[$,o]];s._status==="dirty"&&i.push(ye),be(e,i,s._config.tierOf)},oe=new Ge({onMessage:Hn,onSubscribe:Wn});jt(oe);Pt(oe);L=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??oe,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??ht;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?pt(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Kt);let o={};for(let[a,u]of Object.entries(r.meta??{})){let l={initial:u,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(l.guard=r.guard),o[a]=new t([],void 0,l)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[$,a]])},down(a){i._emit(Ie(a))},up(a){i._emitUp(Ie(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,u=i?.version??0,l=pt(e,o,{id:a,hash:s});l.version=u,this._versioning=l,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=Ae(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=Ae(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new K({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new K({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Re()}}down(e,n){let r=Ie(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[$,e]])}up(e,n){if(this._deps.length===0)return;let r=Ie(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 u=Ae(n);if(!this._guard(u,"observe"))throw new K({actor:u,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 u of this._deps)gt(u);if(this._partial===!1){for(let u of this._deps)if(u.prevData!==void 0||u.dataBatch.length!==0||u.terminal!==void 0||u.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(u){throw this._sinkCount-=1,u}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(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw u}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=zt,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,u=!1;for(let l of i)a(l[0])>=3&&(u=!0),this._config.onMessage(this,l,{direction:"down-in",depIndex:s},this._actions);u&&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{}gt(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=Kt(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(lt),r.unsub=zt;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([[I,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([[I,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{}}gt(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!==Ne){if(s===Z){this._depDirtied(r);return}if(s===Y){if(this._depInvalidated(r),this._cached===void 0)return;this._emit($t);return}if(s===ee||s===se){this._emit([n]);return}if(s===j){this._emit(dt);return}if(s===$)this._depSettledAsData(r,n[1]);else if(s===Q)this._depSettledAsResolved(r);else if(s===V)this._depSettledAsTerminal(r,!0);else if(s===I)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===$||s===Q)&&this._emit([n]),(s===V||s===I)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(lt))}_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(Ft),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([[I,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(Bt)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[I,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([[I,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([[I,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Ut?(this._rerunDepth=0,this._emit([[I,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Ut} \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"?[ye,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let u of e){let l=n(u[0]);l<i&&(r=!1),l===3&&(s=!0),u[0]===Z&&(o=!0),i=l}let a=e;if(!r){let u=e.map((l,d)=>({m:l,i:d,tier:n(l[0])}));u.sort((l,d)=>l.tier-d.tier||l.i-d.i),a=u.map(l=>l.m)}if(s&&!o&&this._status!=="dirty"){let u=0;for(;u<a.length&&n(a[u][0])===0;)u++;return u===0?[ye,...a]:[...a.slice(0,u),ye,...a.slice(u)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let u=e[a];if(u[0]===I&&u[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(u=>u[0]===j||u[0]===Y);if(a.length===0)return;n=a}n=this._frameBatch(n);let s=null;for(let a=0;a<n.length;a++){let u=n[a],l=u[0];if(l!==ee&&l!==se){s?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${l===ee?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let d=!0;if(this._pausable!==!1){let h=u[1];if(l===ee)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(h),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(h))d=!1;else if(this._pauseLocks.delete(h),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let v=this._pauseBuffer;this._pauseBuffer=[],this._emit(v)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}d?s?.push(u):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]===j))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(dt)}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,u=[];for(let l of o)a(l[0])===3?this._pauseBuffer.push(l):u.push(l);u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[I,i]])}_updateState(e){let n=this._config.tierOf,r,s,o=-1,i=0;for(let d of e)n(d[0])===3&&i++;let a=i<=1,u=-1;if(this._versioning!=null&&i>1){for(let d=e.length-1;d>=0;d--)if(e[d][0]===$){u=d;break}}for(let d=0;d<e.length;d++){let h=e[d],v=h[0];if(v===$){if(h.length>=2){let m=!1;if(a&&this._cached!==void 0)try{m=this._equals(this._cached,h[1])}catch(c){s=this._wrapFnError("equals threw",c),o=d;break}if(m){r==null&&(r=e.slice(0,d)),r.push(at),this._status="resolved";continue}this._cached=h[1],this._versioning!=null&&(u<0||d===u)&&Wt(this._versioning,h[1],this._hashFn)}this._status="settled",r?.push(h)}else if(r?.push(h),v===Z)this._status="dirty";else if(v===Q)this._status="resolved";else if(v===V){this._status="completed";{let m=this._config.rigorRecorder;if(m!=null)try{m.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(v===I){this._status="errored";{let m=this._config.rigorRecorder;if(m!=null)try{m.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(v===Y){if(this._cached!==void 0){let c=this._config.rigorRecorder;if(c!=null)try{c.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let m=this._cleanup;if(typeof m=="function"){this._cleanup=void 0;try{m()}catch{}}else if(m!=null&&typeof m=="object"){let c=m.invalidate;if(typeof c=="function")try{c()}catch{}}}else v===j&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let l=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:l,equalsError:s}:{finalMessages:l}}_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(It()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],me(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}be(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);be(this._deliverToSinks,n,this._config.tierOf)}},qt=t=>Array.isArray(t),mt=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function P(t,e){return te([],{...e,initial:t})}function bt(t,e){return te((r,s,o)=>t(s,o)??void 0,{describeKind:"producer",...e})}function q(t,e,n){return te(t,(s,o,i)=>{let a=s.map((u,l)=>u!=null&&u.length>0?u.at(-1):i.prevData[l]);o.emit(e(a,i))},{describeKind:"derived",...n})}var Te=H(()=>{"use strict";ne()});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;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function Vn(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function zn(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function vt(t,e,n){let r=e==null,s=!r&&e!=null?[...e].filter(d=>d.startsWith("meta.")).map(d=>d.slice(5)):null,o=r||e.has("meta")||s!=null&&s.length>0,i="state",a=[];t instanceof L&&(i=Vn(t),a=t._deps.map(d=>d.node.name??""));let u={type:i,deps:a};(r||e.has("status"))&&(u.status=t.status);let l=t instanceof L?t._guard:void 0;if(o){let d={...zn(t)};if(l!=null&&d.access===void 0&&(d.access=ct(l)),s!=null&&s.length>0&&!e.has("meta")){let h={};for(let v of s)v in d&&(h[v]=d[v]);u.meta=h}else u.meta=d}if(t.name!=null&&(u.name=t.name),(r||e.has("value"))&&(!n||i==="state")){t.status==="sentinel"&&(u.sentinel=!0);try{u.value=t.cache}catch{}}if((r||e.has("v"))&&t.v!=null){let d={id:t.v.id,version:t.v.version};"cid"in t.v&&(d.cid=t.v.cid,d.prev=t.v.prev),u.v=d}return(r||e.has("guard"))&&l!=null&&(u.guard=ct(l)),(r||e.has("lastMutation"))&&t.lastMutation!=null&&(u.lastMutation=t.lastMutation),u}var Yt=H(()=>{"use strict";Pe();ne()});function Le(t){return t.subscribe(()=>{})}var Xt=H(()=>{"use strict"});var Zt=H(()=>{"use strict";Xt()});var Fe,Qt=H(()=>{"use strict";Fe=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 Se,en=H(()=>{"use strict";Se=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 xr={};En(xr,{CanvasMeasureAdapter:()=>et,CliMeasureAdapter:()=>Xe,ImageSizeAdapter:()=>rt,NodeCanvasMeasureAdapter:()=>tt,PrecomputedAdapter:()=>Qe,SvgBoundsAdapter:()=>nt,analyzeAndMeasure:()=>xe,carveTextLineSlots:()=>St,circleIntervalForBand:()=>_n,computeBlockFlow:()=>xn,computeCharPositions:()=>Ve,computeFlowLines:()=>Nn,computeLineBreaks:()=>We,computeTotalHeight:()=>wn,layoutNextLine:()=>Tt,measureBlock:()=>yn,measureBlocks:()=>vn,reactiveBlockLayout:()=>br,reactiveFlowLayout:()=>vr,reactiveLayout:()=>mr,rectIntervalForBand:()=>kn});module.exports=Rn(xr);function An(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 At(t){let e=0;for(let n of t)e+=An(n.codePointAt(0));return e}var Xe=class{cellPx;constructor(e){this.cellPx=e?.cellPx??8}measureSegment(e,n){return{width:At(e)*this.cellPx}}},Ze=class extends Error{name="KeyError"},Qe=class{metrics;fallback;constructor(e){this.metrics=e.metrics;let n=e.fallback??"per-char";if(n!=="per-char"&&n!=="error")throw new Error(`fallback must be 'per-char' or 'error', got ${JSON.stringify(e.fallback)}`);this.fallback=n}measureSegment(e,n){let r=this.metrics[n];if(r){let o=r[e];if(o!==void 0)return{width:o}}if(this.fallback==="error")throw new Ze(`PrecomputedAdapter: no metrics for segment ${JSON.stringify(e)} in font ${JSON.stringify(n)}`);let s=0;if(r)for(let o of e){let i=r[o];i!==void 0&&(s+=i)}return{width:s}}},et=class{ctx=null;currentFont="";emojiCorrection;constructor(e){this.emojiCorrection=e?.emojiCorrection??1}getContext(){if(!this.ctx){if(typeof OffscreenCanvas>"u")throw new Error("CanvasMeasureAdapter requires a browser environment with OffscreenCanvas support. Use CliMeasureAdapter or NodeCanvasMeasureAdapter for Node.js.");let n=new OffscreenCanvas(0,0).getContext("2d");if(!n)throw new Error("CanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(e,n){let r=this.getContext();n!==this.currentFont&&(r.font=n,this.currentFont=n);let s=r.measureText(e).width;return this.emojiCorrection!==1&&new RegExp("\\p{Emoji_Presentation}","u").test(e)&&(s*=this.emojiCorrection),{width:s}}clearCache(){this.currentFont=""}},tt=class{ctx=null;currentFont="";canvasModule;constructor(e){this.canvasModule=e}getContext(){if(!this.ctx){let n=this.canvasModule.createCanvas(0,0).getContext("2d");if(!n)throw new Error("NodeCanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(e,n){let r=this.getContext();return n!==this.currentFont&&(r.font=n,this.currentFont=n),{width:r.measureText(e).width}}clearCache(){this.currentFont=""}},nt=class{measureSvg(e){let n=e.match(/viewBox\s*=\s*["']([^"']+)["']/);if(n){let o=n[1].trim().split(/[\s,]+/);if(o.length>=4){let i=Number.parseFloat(o[2]),a=Number.parseFloat(o[3]);if(Number.isFinite(i)&&Number.isFinite(a)&&i>0&&a>0)return{width:i,height:a};throw new Error("SvgBoundsAdapter: viewBox width/height are missing, non-finite, or not positive")}}let r=e.match(/<svg[^>]*\bwidth\s*=\s*["']?([\d.]+)/),s=e.match(/<svg[^>]*\bheight\s*=\s*["']?([\d.]+)/);if(r&&s){let o=Number.parseFloat(r[1]),i=Number.parseFloat(s[1]);if(Number.isFinite(o)&&Number.isFinite(i)&&o>0&&i>0)return{width:o,height:i};throw new Error("SvgBoundsAdapter: svg width/height attributes are non-finite or not positive")}throw new Error("SvgBoundsAdapter: cannot determine dimensions \u2014 SVG has no viewBox or width/height attributes")}},rt=class{sizes;constructor(e){this.sizes=new Map(Object.entries(e))}measureImage(e){let n=this.sizes.get(e);if(!n)throw new Error(`ImageSizeAdapter: no dimensions registered for ${JSON.stringify(e)}`);return{width:n.width,height:n.height}}};ue();ne();Te();it();De();ue();Pe();Oe();Yt();ne();Te();ue();function xt(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(!xt(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)||!xt(t[o],e[o]))return!1;return!0}function Jt(t,e){return`${t}\0${e}`}function wt(t,e){let n=[],r=new Set(t.subgraphs),s=new Set(e.subgraphs),o=[];for(let f of s)r.has(f)||o.push(f);o.sort();for(let f of o)n.push({type:"subgraph-mounted",path:f});let i=new Set(Object.keys(t.nodes)),a=new Set(Object.keys(e.nodes)),u=[];for(let f of a)i.has(f)||u.push(f);u.sort();for(let f of u)n.push({type:"node-added",path:f,node:{...e.nodes[f]}});let l=[];for(let f of a){if(!i.has(f))continue;let x=t.nodes[f]?.meta,g=e.nodes[f]?.meta;x==null&&g==null||xt(x??{},g??{})||l.push(f)}l.sort();for(let f of l)n.push({type:"node-meta-changed",path:f,prevMeta:t.nodes[f]?.meta??{},nextMeta:e.nodes[f]?.meta??{}});let d=new Map;for(let f of t.edges)d.set(Jt(f.from,f.to),f);let h=new Map;for(let f of e.edges)h.set(Jt(f.from,f.to),f);let v=[];for(let[f,x]of h)d.has(f)||v.push(x);v.sort((f,x)=>f.from<x.from?-1:f.from>x.from?1:f.to<x.to?-1:f.to>x.to?1:0);for(let f of v)n.push({type:"edge-added",from:f.from,to:f.to});let m=[];for(let[f,x]of d)h.has(f)||m.push(x);m.sort((f,x)=>f.from<x.from?-1:f.from>x.from?1:f.to<x.to?-1:f.to>x.to?1:0);for(let f of m)n.push({type:"edge-removed",from:f.from,to:f.to});let c=[];for(let f of i)a.has(f)||c.push(f);c.sort();for(let f of c)n.push({type:"node-removed",path:f});let b=[];for(let f of r)s.has(f)||b.push(f);b.sort();for(let f of b)n.push({type:"subgraph-unmounted",path:f});return{events:n,flushedAt_ns:B()}}Zt();Qt();en();ot();function tn(t,e,n,r={}){let s=e in t.nodes,o=n in t.nodes;if(!s)return $e(e,n,"no-such-from");if(!o)return $e(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 l=Un(t,e,r);if(l!=null)return l}let u=Be(e,t.nodes[e],0,r);return je(e,n,[u])}if(i===0)return $e(e,n,"no-path");let a=nn(t,e,n,i);return a.found?je(e,n,rn(t,a.pathOrder,r)):$e(e,n,a.truncated?"max-depth-exceeded":"no-path")}function nn(t,e,n,r){let s=new Map,o=[{path:n,depth:0}],i=new Set([n]),a=0,u=!1;for(;a<o.length;){let h=o[a++];if(h.path===e)break;if(r!=null&&h.depth>=r){let b=t.nodes[h.path];b?.deps&&b.deps.length>0&&(u=!0);continue}let v=t.nodes[h.path];if(v==null)continue;let m=v.deps??[],c=new Map;for(let b=0;b<m.length;b++){let f=m[b];if(!f)continue;let x=c.get(f);x==null&&(x=[],c.set(f,x)),x.push(b)}for(let[b,f]of c)i.has(b)||(i.add(b),s.set(b,{from:h.path,depIndices:f}),o.push({path:b,depth:h.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:u};let l=[{path:e}],d=e;for(;d!==n;){let h=s.get(d);if(h==null)return{found:!1,pathOrder:[],truncated:!1};l[l.length-1].depIndices=h.depIndices,l.push({path:h.from}),d=h.from}return{found:!0,pathOrder:l,truncated:!1}}function Un(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=Be(e,r,0,n);a.dep_index=o[0];let u=Be(e,r,1,n);return je(e,e,[a,u])}let i=null;for(let a=0;a<s.length;a++){let u=s[a];if(!u||u===e)continue;let l=nn(t,u,e,n.maxDepth);l.found&&(i==null||l.pathOrder.length<i.pathOrder.length)&&(i=l,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...l.pathOrder],truncated:!1})}return i==null?null:je(e,e,rn(t,i.pathOrder,n))}function rn(t,e,n){return e.map((r,s)=>{let o=t.nodes[r.path],i=Be(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 Be(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 je(t,e,n){return sn(t,e,!0,"ok",n)}function $e(t,e,n){return sn(t,e,!1,n,[])}function sn(t,e,n,r,s){let o=Kn(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 Kn(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 u=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(u),"value"in i&&o.push(` value: ${qn(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let l=i.lastMutation.actor;o.push(` actor: ${l.type}${l.id?`:${l.id}`:""}`)}}return o.join(`
2
- `)}function qn(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)}}ne();var F={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},Yn=Symbol.for("sizeof");function on(t){let e=new WeakSet,n=new WeakSet,r=[t],s=0;for(;r.length>0;){let o=r.pop();s+=Jn(o,e,n,r)}return s}function Jn(t,e,n,r){if(t==null)return 0;switch(typeof t){case"number":return F.number;case"boolean":return F.boolean;case"string":return F.string+t.length*2;case"bigint":return F.bigint+Xn(t);case"symbol":return F.symbol;case"function":return e.has(t)?0:(e.add(t),F.function);case"undefined":return 0}let o=t;if(e.has(o))return 0;e.add(o);let i=o[Yn];if(typeof i=="function")try{let l=i.call(o);if(typeof l=="number"&&Number.isFinite(l))return l}catch{}if(o instanceof Date)return F.date;if(o instanceof RegExp)return F.regexp+o.source.length*2;if(o instanceof Error){let l=o.message?o.message.length*2:0,d=o.stack?o.stack.length*2:0;return F.error+l+d}if(typeof URL<"u"&&o instanceof URL)return F.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return F.promise;if(o instanceof WeakMap)return F.weakmap;if(o instanceof WeakSet)return F.weakset;if(o instanceof Map){let l=F.map;for(let[d,h]of o)l+=F.mapEntry,r.push(d),r.push(h);return l}if(o instanceof Set){let l=F.set;for(let d of o)l+=F.setEntry,r.push(d);return l}if(Array.isArray(o)){let l=F.array+o.length*8;for(let d of o)r.push(d);return l}if(o instanceof ArrayBuffer)return n.has(o)?0:(n.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let l=o;return n.has(l.buffer)?48:(n.add(l.buffer),l.buffer.byteLength+48)}let a=F.object,u=Object.keys(o);for(let l of u){a+=F.string+l.length*2;try{r.push(o[l])}catch{}}return a}function Xn(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 an(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[v,m]of s)i.set(v,m);let a=[];for(let[v,m]of Object.entries(r.nodes)){let c=i.get(v),b=c instanceof L?c:null,f=b?on(b.cache):0,x=b?b._sinkCount:0,g=m.deps?.length??0,y=m.type==="effect"&&x===0,w=x===0?m.type==="effect"?"orphan-effect":m.type==="derived"?"idle-derived":m.type==="producer"?"idle-producer":null:null;a.push({path:v,type:m.type,status:m.status??"unknown",valueSizeBytes:f,subscriberCount:x,depCount:g,isOrphanEffect:y,orphanKind:w})}let u=a.reduce((v,m)=>v+m.valueSizeBytes,0),l=(v,m)=>[...a].sort(m??((c,b)=>b[v]-c[v])).slice(0,n),d=a.filter(v=>v.orphanKind!=null),h=a.filter(v=>v.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:u,hotspots:{byValueSize:l("valueSizeBytes"),bySubscriberCount:l("subscriberCount"),byDepCount:l("depCount")},orphans:d,orphanEffects:h}}var G="::",J="__meta__",ve=1;function un(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 pn(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"&&typeof t.down=="function"}function Zn(t){if(t!=null)return pn(t)?t.cache:t}function ce(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"&&typeof t.down=="function"}function ie(t){return ce(t)?t.cache??"":t}function ln(t){return ce(t)?t.cache??0:t}function dn(t){return ce(t)?t.cache??!1:t}function Qn(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(`
3
- `)}function cn(t){if(t.version!==ve)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${ve})`);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 er(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,u=o.constructor;if(a!==u)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 v=o;if(s.length!==v.length)return!1;for(let m=0;m<s.length;m++)if(!r(s[m],v[m]))return!1;return!0}if(s instanceof Map){let v=o;if(s.size!==v.size)return!1;for(let[m,c]of s)if(!v.has(m)||!r(c,v.get(m)))return!1;return!0}if(s instanceof Set){let v=o;if(s.size!==v.size)return!1;for(let m of s){let c=!1;for(let b of v)if(r(m,b)){c=!0;break}if(!c)return!1}return!0}if(ArrayBuffer.isView(s)){let v=s,m=o;if(v.length!==m.length)return!1;for(let c=0;c<v.length;c++)if(v[c]!==m[c])return!1;return!0}let l=Object.keys(s),d=Object.keys(o);if(l.length!==d.length)return!1;let h=new Set(d);for(let v of l)if(!h.has(v)||!r(s[v],o[v]))return!1;return!0};return r(t,e)}function tr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function He(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+=tr(r)}return e+="$",new RegExp(e)}var nr={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"},rr={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function _t(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 sr(t){return t==="none"?rr:t==="ansi"||t==null?nr:{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 fn(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 or(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 kt(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(G))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${G}' (path separator)`);if(t===J)throw new Error(`Graph "${e}": ${n} name "${J}" is reserved for meta companion paths`);or(t,e,n)}function ir(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(G);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function ar(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 gn(t){for(let e of t._mounts.values())gn(e);for(let e of t._nodes.values())try{e.down([[j]],{internal:!0})}catch{}}var re=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(G))throw new Error(`Graph name must not contain '${G}' (got "${e}")`);if(e===J)throw new Error(`Graph name "${J}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??oe,this._traceRing=new Se(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=bt(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(kt(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:B()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof L&&n._applyVersioning(e)}remove(e){kt(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,u]of i)a.includes(`${G}${J}${G}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...n._collectSubgraphs(`${e}${G}`)),this._mounts.delete(e),n._parent=void 0,gn(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([[j]],{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=He(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(G))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([[$,n]],{actor:r?.actor,internal:s,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);Lt(()=>{for(let[s,o]of r)this.set(s,o,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[Y]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let s=r?.internal===!0;this.node(e).down([[I,n]],{actor:r?.actor,internal:s,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[V]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[u,l]of this._nodes)r.set(l,u);let a=[];for(let[u,l]of this._nodes)if(l instanceof L)for(let d of l._deps){let h=r.get(d.node);h!=null&&a.push([h,u])}return a.sort((u,l)=>u[0]<l[0]?-1:u[0]>l[0]?1:u[1]<l[1]?-1:u[1]>l[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,u]of s)o.set(u,a);let i=[];for(let[a,u]of s)if(u instanceof L)for(let l of u._deps){let d=o.get(l.node);d!=null&&i.push([d,a])}return i.sort((a,u)=>a[0]<u[0]?-1:a[0]>u[0]?1:a[1]<u[1]?-1:a[1]>u[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(kt(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=ir(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]===J)return this._resolveMetaChainFromNode(o,s,n.join(G));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(G)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(s.join(G))}_resolveMetaChainFromNode(e,n,r){let s=e,o=0,i=[...n];for(;o<i.length;){if(i[o]!==J)throw new Error(`Graph "${this.name}": expected ${J} segment in meta path "${r}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${J} in "${r}"`);let a=i[o+1],u=s.meta[a];if(!u)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);s=u,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 u of this._mounts.values())u._signalDeliver(e,n,r,s);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=ar(e,this.config);for(let u of[...this._nodes.keys()].sort()){let l=this._nodes.get(u);if(!r.has(l)){r.add(l);try{l.down(e,i)}catch(d){if(d instanceof K)throw d;s.push(d)}a.length!==0&&this._signalMetaSubtree(l,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(u){if(u instanceof K)throw u;o.push(u)}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=Zn(e?.actor),r=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let s=yt(e?.detail,e?.fields),o=e?.detail==="spec",i=s,a=[];this._collectObserveTargets("",a);let u=new Map;for(let[w,p]of a)u.set(p,w);let l=[];{let w=a.map(([,k])=>k),p=new Set(u.values()),_=0;for(;w.length>0;){let k=w.shift();if(k instanceof L)for(let N of k._deps){let T=N.node;if(u.has(T))continue;let E=T.name??"",O=E;if(!O||p.has(O))if(E){let C=2;for(;p.has(`${E}#${C}`);)C++;O=`${E}#${C}`}else for(O=`__internal__/${_++}`;p.has(O);)O=`__internal__/${_++}`;u.set(T,O),p.add(O),l.push([O,T]),w.push(T)}}}let d=[...a,...l],h={};for(let[w,p]of d){if(n!=null&&!p.allowsObserve(n))continue;let _=vt(p,i,o),k=p instanceof L?p._deps.map(O=>u.get(O.node)??O.node.name??""):[],{name:N,...T}=_,E={...T,deps:k};if(!o){let O=this._annotations.get(w);O!=null&&(E.annotation=O)}if(r!=null)if(typeof r=="function"){let O=r;if(!(O.length>=2?O(w,E):O(E)))continue}else{let O=!0;for(let[C,M]of Object.entries(r)){let A=C==="deps_includes"?"depsIncludes":C==="meta_has"?"metaHas":C;if(A==="depsIncludes"){if(!E.deps.includes(String(M))){O=!1;break}continue}if(A==="metaHas"){if(!Object.hasOwn(E.meta??{},String(M))){O=!1;break}continue}if(E[A]!==M){O=!1;break}}if(!O)continue}h[w]=E}let v=new Set(Object.keys(h)),m=[];for(let[w,p]of d)if(p instanceof L)for(let _ of p._deps){let k=u.get(_.node);k!=null&&m.push([k,w])}m.sort((w,p)=>w[0]<p[0]?-1:w[0]>p[0]?1:w[1]<p[1]?-1:w[1]>p[1]?1:0);let c=m.map(([w,p])=>({from:w,to:p}));(n!=null||r!=null)&&(c=c.filter(w=>v.has(w.from)&&v.has(w.to)));let b=this._collectSubgraphs(""),f=n!=null||r!=null?b.filter(w=>{let p=`${w}${G}`;return[...v].some(_=>_===w||_.startsWith(p))}):b,x=this,g=e;return{name:this.name,nodes:h,edges:c,subgraphs:f,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(w){let p={...g};return Array.isArray(w)?(p.fields=w,p.detail=void 0):(p.detail=w,p.fields=void 0),x.describe(p)}}}_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}${G}`))}return n}resourceProfile(e){return an(this,e)}reachable(e,n,r={}){return r.withDetail===!0?hn(this.describe(),e,n,{...r,withDetail:!0}):hn(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(ie(e),ie(n),{...r?.maxDepth!==void 0?{maxDepth:ln(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:dn(r.findCycle)}:{}})}_explainStatic(e,n,r){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,u]of Object.entries(s.nodes))u.lastMutation!=null&&i.set(a,u.lastMutation);return tn(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=P(s,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,l=()=>{a||u||(a=!0,me(()=>{a=!1,!u&&(s+=1,o.emit(s))}))},d=i.onEvent(g=>{let y=g.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||l()}),h=[],v=new WeakSet,m=g=>{if(v.has(g)||u)return;v.add(g);let y=g.topology.subscribe(w=>{for(let p of w){if(p[0]!==$)continue;let _=p[1];if(l(),_.kind==="added"&&_.nodeKind==="mount"){let k=g._mounts.get(_.name);k!=null&&m(k)}}});h.push(y);for(let w of g._mounts.keys()){let p=g._mounts.get(w);p!=null&&m(p)}};m(this);let c,b=e.actor;pn(b)&&(c=b.subscribe(g=>{let y=!1,w=!1;for(let p of g){let _=p[0];_===$?y=!0:(_===V||_===I||_===j)&&(w=!0)}y&&l(),w&&(c?.(),c=void 0,l())}));let f;try{f=q([o],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(g,y)=>g===y})}catch(g){d(),c?.();for(let y of h)y();throw i.dispose(),g}let x=Le(f);return{node:f,dispose(){u=!0,d(),c?.();for(let g of h)g();h.length=0,i.dispose(),x()}}}_describeReactiveDiff(e){let n={...e,reactive:!1},r=e.reactiveName??"describe-diff",s={name:this.name,nodes:{},edges:[],subgraphs:[]},o=this.describe(n),i=wt(s,o),a=P(i,{name:r,meta:{domain:"audit",kind:"describe-diff"},equals:(v,m)=>v===m}),u=this._describeReactive({...e,reactiveName:void 0}),l=!1,d=u.node.subscribe(v=>{if(!l)for(let m of v){if(m[0]!==$)continue;let c=m[1],b=wt(o,c);o=c,b.events.length!==0&&a.emit(b)}}),h=Le(a);return{node:a,dispose(){l=!0,d(),u.dispose(),a.down([[j,"describe-diff disposed"]]),h()}}}_explainReactive(e,n,r){let s=0,o=P(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,l=()=>{a||u||(a=!0,me(()=>{a=!1,!u&&(s+=1,o.emit(s))}))},d=i.onEvent(g=>{let y=g.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||l()}),h=[];e!=null&&ce(e)&&h.push(e),n!=null&&ce(n)&&h.push(n),r?.maxDepth!=null&&ce(r.maxDepth)&&h.push(r.maxDepth),r?.findCycle!=null&&ce(r.findCycle)&&h.push(r.findCycle);let v=()=>{for(let g of h)if(g.cache===void 0)return!1;return!0},m=()=>{let g=ie(e),y=ie(n);return{from:g,to:y,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:g,to:y,found:!1,reason:"pending",steps:[]})}},c;try{c=q([o],()=>{if(!v())return m();let g=ie(e),y=ie(n),w={...r?.maxDepth!==void 0?{maxDepth:ln(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:dn(r.findCycle)}:{}};return this._explainStatic(g,y,w)},{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:ie(e),to:ie(n)},equals:(g,y)=>g.found===y.found&&g.reason===y.reason&&g.steps.length===y.steps.length&&lr(g.steps,y.steps)})}catch(g){throw d(),i.dispose(),g}let b=Le(c),f=[],x=g=>{let y;return y=g.subscribe(w=>{let p=!1,_=!1;for(let k of w){let N=k[0];N===$?p=!0:(N===V||N===I||N===j)&&(_=!0)}(p||_)&&l(),_&&y&&(y(),y=void 0)}),()=>{y&&(y(),y=void 0)}};for(let g of h)f.push(x(g));return{node:c,dispose(){u=!0,d();for(let g of f)g?.();f.length=0,i.dispose(),b()}}}_pathsMatching(e){let n=He(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}${G}${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}${G}${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}${G}${J}${G}${s}`;r.push([i,o]),this._appendMetaObserveTargets(i,o,r)}}observe(e,n){let r=typeof e=="string",o=fn(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 d=e,h=this.resolve(d);if(a!=null&&!h.allowsObserve(a))throw new K({actor:a,action:"observe",nodeName:d});return i?this._buildStructuredObserver([[d,h]],o,"one"):{subscribe(v){return h.subscribe(v)},up(v){try{h.up?.(v)}catch(m){if(m instanceof K)return;throw m}}}}let u=[];this._collectObserveTargets("",u),u.sort((d,h)=>d[0]<h[0]?-1:d[0]>h[0]?1:0);let l=a==null?u:u.filter(([,d])=>d.allowsObserve(a));return i?this._buildStructuredObserver(l,o,"all"):{subscribe:d=>{let h=l.map(([v,m])=>m.subscribe(c=>{d(v,c)}));return()=>{for(let v of h)v()}},up:(d,h)=>{try{this.resolve(d).up?.(h)}catch(v){if(v instanceof K)return;throw v}}}}_observeReactive(e,n){let r=n.tiers,s=r!=null?new Set(r):null,o=n.reactiveName??"observe";return bt(i=>{let a=[],u=!1,l=!1,d=()=>{if(a.length===0||l)return;let b={events:a.slice(),flushedAt_ns:B()};a.length=0,i.emit(b)},h={...n,reactive:!1,structured:!0,timeline:!0},v=e!=null?this.observe(e,h):this.observe(h),m=b=>{l||(a.push(b),!u&&(u=!0,me(()=>{u=!1,d()})))};for(let b of v.events)m(b);let c=v.onEvent(m);return()=>{l=!0,c(),v.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 d=this.resolve(s);return this._buildStructuredObserver([[s,d]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((d,h)=>d[0]<h[0]?-1:d[0]>h[0]?1:0);let u=i.actor,l=u==null?a:a.filter(([,d])=>d.allowsObserve(u));return this._buildStructuredObserver(l,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",u=this.config.inspectorEnabled,l=(o||i)&&u,d=n.maxEvents,h=d!=null&&d>0?new Se(d):null,v=[],m=new Set,c=n.tiers!=null?new Set(n.tiers):null,b={},f=new Set,x=0,g=0,y=0,w=0,p=0,_=0,k=!1,N=!1,T=0,E=new Map,O=new Map,C=new Map,M=S=>{if(!(c!=null&&!c.has(S.type))){h?h.push(S):v.push(S);for(let D of m)D(S)}},A=S=>c==null||c.has(S),fe=()=>s?{timestamp_ns:B(),in_batch:Me(),batch_id:T}:{},ze=(S,D)=>{if(!(!l||!(S instanceof L)))return S._setInspectorHook(z=>{if(z.kind==="dep_message")E.set(S,z.depIndex);else if(z.kind==="run"){let we=z.batchData.map((R,W)=>R!=null&&R.length>0?R.at(-1):z.prevData[W]);O.set(S,we);let U=z.batchData.map(R=>R!=null?[...R]:void 0);C.set(S,U),i&&M({type:"derived",path:D,dep_values:we,dep_batches:U,...fe()})}})},Ee=S=>{let D=E.get(S),z=O.get(S);if(!o||z==null)return{};let U=(D!=null&&D>=0&&S instanceof L?S._deps[D]:void 0)?.node,R=U?.v,W=C.get(S);return{trigger_dep_index:D,trigger_dep_name:U?.name,...R!=null?{trigger_version:{id:R.id,version:R.version}}:{},dep_values:[...z],...W!=null?{dep_batches:W}:{}}},Et=[],Ct=[];for(let[S,D]of e){let z=ze(D,S);z&&Et.push(z),Ct.push(D.subscribe(we=>{T++;for(let U of we){let R=U[0],W=fe();if(R===$){b[S]=U[1];let Ye=D instanceof L?D.lastMutation?.actor??he:he;M({type:"data",path:S,data:U[1],actor:Ye,...W,...Ee(D)})}else if(a)R===Z?A("dirty")&&x++:R===Q?A("resolved")&&g++:R===Y?A("invalidate")&&y++:R===ee?A("pause")&&w++:R===se?A("resume")&&p++:R===j?A("teardown")&&_++:R===V&&!f.has(S)?A("complete")&&(k=!0):R===I&&A("error")&&(N=!0,f.add(S));else if(R===Z)A("dirty")&&x++,M({type:"dirty",path:S,...W});else if(R===Q)A("resolved")&&g++,M({type:"resolved",path:S,...W,...Ee(D)});else if(R===Y)A("invalidate")&&y++,M({type:"invalidate",path:S,...W});else if(R===ee)A("pause")&&w++,M({type:"pause",path:S,lockId:U[1],...W});else if(R===se)A("resume")&&p++,M({type:"resume",path:S,lockId:U[1],...W});else if(R===V)A("complete")&&!f.has(S)&&(k=!0),M({type:"complete",path:S,...W});else if(R===I){A("error")&&(N=!0,f.add(S));let Ye=D instanceof L?D.lastMutation?.actor??he:he;M({type:"error",path:S,data:U[1],actor:Ye,...W})}else R===j&&(A("teardown")&&_++,M({type:"teardown",path:S,...W}))}}))}let Ue=!1,Ke=()=>{if(!Ue){Ue=!0;for(let S of Ct)S();for(let S of Et)S();for(let S of Ce)S({value:void 0,done:!0});Ce.length=0}},qe=[],Ce=[];m.add(S=>{let D=Ce.shift();D?D({value:S,done:!1}):qe.push(S)});let Rt={get values(){return b},get dirtyCount(){return x},get resolvedCount(){return g},get invalidateCount(){return y},get pauseCount(){return w},get resumeCount(){return p},get teardownCount(){return _},get events(){return h?h.toArray():[...v]},get anyCompletedCleanly(){return k},get anyErrored(){return N},get completedWithoutErrors(){return k&&!N},onEvent(S){return m.add(S),()=>m.delete(S)},dispose:Ke,expand(S){Ke();let D={...n};return typeof S=="string"?D.detail=S:Object.assign(D,S),r(fn(D))},[Symbol.asyncIterator](){return{next(){return qe.length>0?Promise.resolve({value:qe.shift(),done:!1}):Ue?Promise.resolve({value:void 0,done:!0}):new Promise(S=>Ce.push(S))},return(){return Ke(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Rt,n),Rt}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let s=n.logger??(c=>console.log(c)),o=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=o==null&&i==null?()=>!0:c=>(o==null||o.has(c))&&(i==null||!i.has(c)),u=sr(n.theme),l=r==="stage-log"?B():0,d=c=>c==null?"":n.stageLabels?.[c]??c,h=(c,b)=>c.length>b?`${c.slice(0,b-1)}\u2026`:c,v=c=>c.type==="data"||c.type==="error"?h(_t(c.data),120):"",m=c=>{if(r==="stage-log"){let k=(B()-l)/1e9,N=d(c.path).padEnd(9);if(c.type==="data"){let T=v(c);return`[${k.toFixed(3)}s] ${N} \u2190${T?` ${T}`:""}`}if(c.type==="error"){let T=v(c);return`[${k.toFixed(3)}s] ${N} \u2717${T?` ${T}`:""}`}return c.type==="complete"?`[${k.toFixed(3)}s] ${N} \u25A0 complete`:`[${k.toFixed(3)}s] ${N} ${c.type}`}if(r==="json")try{return JSON.stringify(c)}catch{return JSON.stringify({type:c.type,path:c.path,data:"[unserializable]"})}let b=u[c.type]??"",f=c.path?`${u.path}${c.path}${u.reset} `:"",x=c.type==="data"||c.type==="error",g=c.type==="pause"||c.type==="resume",y=x?` ${_t(c.data)}`:g?` ${_t(c.lockId)}`:"",w=c.type==="data"||c.type==="resolved"||c.type==="derived"?c:void 0,p=w?.trigger_dep_name!=null?` <- ${w.trigger_dep_name}`:w?.trigger_dep_index!=null?` <- #${w.trigger_dep_index}`:"",_=c.in_batch?" [batch]":"";return`${f}${b}${c.type.toUpperCase()}${u.reset}${y}${p}${_}`};e.onEvent(c=>{a(c.type)&&s(m(c),c)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){un(this._disposers,this.name),this.signal([[j]],{internal:!0}),un(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:u,guard:l,...d}=r.nodes[a];s[a]=d}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 Dt(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??oe,{codec:s,codecVersion:o,payload:i}=Gt(e,r);return s.decode(i,o)}restore(e,n){if(cn(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=>He(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 u=this.tryResolve(o)?.v;if(u!=null&&u.id===i.v.id&&u.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){n?.onError?.(o,a)}}}}}static fromSnapshot(e,n){cn(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 m of[...e.subgraphs].sort((c,b)=>{let f=c.split(G).length,x=b.split(G).length;return f!==x?f-x:c<b?-1:c>b?1:0})){let c=m.split(G),b=o;for(let f of c)b._mounts.has(f)||b.mount(f,new t(f)),b=b._mounts.get(f)}let i=s?Object.entries(s).map(([m,c])=>({re:He(m),factory:c})):[],a=m=>{for(let c of i)if(c.re.test(m))return c.factory},u=m=>{let c=m.split(G),b=c.pop();if(b==null||b.length===0)throw new Error(`invalid snapshot path "${m}"`);let f=o;for(let x of c){let g=f._mounts.get(x);if(!g)throw new Error(`unknown mount "${x}" in path "${m}"`);f=g}return[f,b]},l=Object.entries(e.nodes).filter(([m])=>!m.includes(`${G}${J}${G}`)).sort((m,c)=>m[0]<c[0]?-1:m[0]>c[0]?1:0),d=new Map(l),h=new Map,v=!0;for(;d.size>0&&v;){v=!1;for(let[m,c]of[...d.entries()]){let b=c?.deps??[];if(!b.every(p=>h.has(p)))continue;let[f,x]=u(m),g={...c?.meta??{}},y=a(m),w;if(c?.type==="state")w=P(c.value,{meta:g});else{if(y==null)continue;w=y(x,{path:m,type:c.type,value:c.value,meta:g,deps:b,resolvedDeps:b.map(p=>h.get(p))})}f.add(w,{name:x}),h.set(m,w),d.delete(m),v=!0}}if(d.size>0){let m=[...d.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${m}. 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(l=>({tier:l,debounceMs:Math.max(0,l.debounceMs??0),compactEvery:Math.max(1,l.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=(l,d)=>{if(l.disposed)return;let h=Qn(d.nodes);if(l.lastSnapshot!=null&&h!==""&&h===l.lastFingerprint)return;let v=l.seq+1,m=Re(),f=l.lastSnapshot==null||v%l.compactEvery===0?{name:this.name,mode:"full",snapshot:d,seq:v,timestamp_ns:m,format_version:ve}:{name:this.name,mode:"diff",diff:ur(l.lastSnapshot,d),seq:v,timestamp_ns:m,format_version:ve};if(l.tier.filter&&!l.tier.filter(f))return;let x;try{x=l.tier.save(f)}catch(g){n.onError?.(g,l.tier);return}if(x&&typeof x.then=="function"){let w=(l.savePending??Promise.resolve()).then(()=>x,()=>x).then(()=>{l.disposed||(l.seq=v,l.lastSnapshot=d,l.lastFingerprint=h)},p=>{n.onError?.(p,l.tier)});l.savePending=w.finally(()=>{l.savePending===w&&(l.savePending=void 0)})}else l.seq=v,l.lastSnapshot=d,l.lastFingerprint=h},o=(l,d)=>{try{s(l,d)}catch(h){n.onError?.(h,l.tier)}},i=(l,d)=>{if(!d.some(c=>{let b=this.config.messageTier(c[0]);return b>=3&&b<5}))return;if(n.filter){let c=this.tryResolve(l);if(c==null)return;let b=vt(c,yt("standard"));if(!n.filter(l,b))return}let v,m=()=>(v==null&&(v=this.snapshot()),v);for(let c of r)c.disposed||(c.debounceMs===0?o(c,m()):(c.timer==null&&(c.timer=new Fe),c.timer.start(c.debounceMs,()=>{c.disposed||o(c,this.snapshot())})))},a;if(n.paths!=null){let d=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(h=>{let v=this.tryResolve(h);return v==null?()=>{}:v.subscribe(m=>i(h,m))});a=()=>{for(let h of d)h()}}else a=this.observe().subscribe((l,d)=>i(l,d));let u=()=>{a();for(let l of r)l.disposed=!0,l.timer?.cancel();this._storageDisposers.delete(u)};return this._storageDisposers.add(u),{dispose:u}}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===ve&&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(u){r?.onError?.(u,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===ve&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(u){r?.onError?.(u,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:B(),...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(g=>!r.has(g)).sort(),i=[...r].filter(g=>!s.has(g)).sort(),a=[],u=[];for(let g of r){if(!s.has(g))continue;let y=e.nodes[g],w=n.nodes[g],p=y.v,_=w.v;p!=null&&_!=null&&p.id===_.id&&p.version!==_.version&&u.push({path:g,id:p.id,from:p.version,to:_.version});let k=p!=null&&_!=null&&p.id===_.id&&p.version===_.version;for(let N of["type","status","sentinel"]){let T=y[N],E=w[N];T!==E&&a.push({path:g,field:N,from:T,to:E})}if(!k)for(let N of["value","meta"]){let T=y[N],E=w[N];er(T,E)||a.push({path:g,field:N,from:T,to:E})}}let l=g=>`${g.from} ${g.to}`,d=new Set(e.edges.map(l)),h=new Set(n.edges.map(l)),v=n.edges.filter(g=>!d.has(l(g))),m=e.edges.filter(g=>!h.has(l(g))),c=new Set(e.subgraphs),b=new Set(n.subgraphs),f=[...b].filter(g=>!c.has(g)).sort(),x=[...c].filter(g=>!b.has(g)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:u,edgesAdded:v,edgesRemoved:m,subgraphsAdded:f,subgraphsRemoved:x}}};function ur(t,e){let n=re.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 hn(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,u=new Map,l=new Map,d=new Set;for(let[y,w]of Object.entries(t.nodes)){if(!y)continue;d.add(y);let p=w.deps??[];i.set(y,p);for(let _ of p)_&&(d.add(_),a.has(_)||a.set(_,new Set),a.get(_).add(y))}for(let y of t.edges){if(y==null||typeof y!="object")continue;let w=typeof y.from=="string"?y.from:"",p=typeof y.to=="string"?y.to:"";!w||!p||(d.add(w),d.add(p),l.has(w)||l.set(w,new Set),l.get(w).add(p),u.has(p)||u.set(p,new Set),u.get(p).add(w))}if(!d.has(e))return r.withDetail?s:[];let h=r.both===!0,v=y=>{if(h){let k=i.get(y)??[],N=u.get(y),T=a.get(y),E=l.get(y),O=[...k];return N&&O.push(...N),T&&O.push(...T),E&&O.push(...E),O}if(n==="upstream"){let k=i.get(y)??[],N=u.get(y);return N?[...k,...N]:k}let w=a.get(y),p=l.get(y),_=w?[...w]:[];return p&&_.push(...p),_},m=new Set([e]),c=new Map,b=[{path:e,depth:0}],f=0,x=!1;for(;f<b.length;){let y=b[f++];if(o!=null&&y.depth>=o){v(y.path).length>0&&(x=!0);continue}for(let w of v(y.path))!w||m.has(w)||(m.add(w),c.set(w,y.depth+1),b.push({path:w,depth:y.depth+1}))}let g=[...c.keys()].sort((y,w)=>y<w?-1:y>w?1:0);return r.withDetail?{paths:g,depths:c,truncated:x}:g}function lr(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}De();Oe();ne();function X(t,e){t!=null&&be(n=>t.down(n),[[$,e]],oe.tierOf)}ue();ne();Te();function dr(t){for(let e of t){let n=e.codePointAt(0);if(n>=19968&&n<=40959||n>=13312&&n<=19903||n>=12288&&n<=12351||n>=12352&&n<=12447||n>=12448&&n<=12543||n>=44032&&n<=55215||n>=65280&&n<=65519)return!0}return!1}var mn=new Set(["\uFF0C","\uFF0E","\uFF01","\uFF1A","\uFF1B","\uFF1F","\u3001","\u3002","\u30FB","\uFF09","\u3015","\u3009","\u300B","\u300D","\u300F","\u3011"]),cr=new Set([".",",","!","?",":",";",")","]","}","%",'"',"\u201D","\u2019","\xBB","\u203A","\u2026"]);function fr(t){return t.replace(/[\t\n\r\f ]+/g," ").replace(/^ | $/g,"")}function hr(t){let e=new Intl.Segmenter(void 0,{granularity:"word"}),n=[];for(let r of e.segment(t)){let s=r.segment,o=r.isWordLike??!1,i=[],a=[],u=[],l="",d=null;for(let h of s){let v;h===" "?v="space":h==="\u200B"?v="zero-width-break":h==="\xAD"?v="soft-hyphen":h===`
4
- `?v="hard-break":v="text",d!==null&&v===d?l+=h:(d!==null&&(i.push(l),a.push(d==="text"&&o),u.push(d)),l=h,d=v)}d!==null&&(i.push(l),a.push(d==="text"&&o),u.push(d)),n.push({texts:i,isWordLike:a,kinds:u})}return n}function xe(t,e,n,r,s){let o=fr(t);if(o.length===0)return[];let i=hr(o),a=new Intl.Segmenter(void 0,{granularity:"grapheme"}),u=[],l=[],d=[];for(let x of i)for(let g=0;g<x.texts.length;g++)u.push(x.texts[g]),l.push(x.kinds[g]),d.push(x.isWordLike[g]);let h=[],v=[],m=[];for(let x=0;x<u.length;x++){let g=u[x],y=l[x],w=d[x];if(y==="text"&&!w&&h.length>0&&v[v.length-1]==="text"&&g.length===1&&(cr.has(g)||mn.has(g))){h[h.length-1]+=g;continue}if(g==="-"&&h.length>0&&v[v.length-1]==="text"&&m[m.length-1]){h[h.length-1]+=g;continue}h.push(g),v.push(y),m.push(w)}let c=r.get(e);c||(c=new Map,r.set(e,c));function b(x){let g=c.get(x);if(g===void 0){s&&(s.misses+=1);let y=n.measureSegment(x,e).width;g=Number.isFinite(y)&&y>=0?y:0,c.set(x,g)}else s&&(s.hits+=1);return g}let f=[];for(let x=0;x<h.length;x++){let g=h[x],y=v[x];if(y!=="text"){f.push({text:g,width:y==="space"?b(" ")*g.length:0,kind:y,graphemeWidths:null});continue}if(dr(g)){let _="";for(let k of a.segment(g)){let N=k.segment;if(_.length>0&&mn.has(N)){_+=N;continue}if(_.length>0){let T=b(_);f.push({text:_,width:T,kind:"text",graphemeWidths:null})}_=N}if(_.length>0){let k=b(_);f.push({text:_,width:k,kind:"text",graphemeWidths:null})}continue}let w=b(g),p=null;if(m[x]&&g.length>1){let _=[];for(let k of a.segment(g))_.push(b(k.segment));_.length>1&&(p=_)}f.push({text:g,width:w,kind:"text",graphemeWidths:p})}return f}function We(t,e,n,r,s){if(t.length===0)return{lines:[],lineCount:0};let o=[],i=0,a=!1,u=0,l=0,d=0,h=0,v=-1,m=0,c=s.get(r);c||(c=new Map,s.set(r,c));let b=c.get("-");b===void 0&&(b=n.measureSegment("-",r).width,c.set("-",b));function f(p=d,_=h,k=i){let N="";for(let T=u;T<p;T++){let E=t[T];if(!(E.kind==="soft-hyphen"||E.kind==="hard-break"))if(T===u&&l>0&&E.graphemeWidths){let C=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(E.text)].map(M=>M.segment);N+=C.slice(l).join("")}else N+=E.text}if(_>0&&p<t.length){let T=t[p],O=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(T.text)].map(M=>M.segment),C=u===p?l:0;N+=O.slice(C,_).join("")}p>0&&t[p-1]?.kind==="soft-hyphen"&&!(u===p&&l>0)&&(N+="-"),o.push({text:N,width:k,startSegment:u,startGrapheme:l,endSegment:p,endGrapheme:_}),i=0,a=!1,v=-1,m=0}function x(p){return p==="space"||p==="zero-width-break"||p==="soft-hyphen"}function g(p,_,k){a=!0,u=p,l=_,d=p+1,h=0,i=k}function y(p,_,k){a=!0,u=p,l=_,d=p,h=_+1,i=k}for(let p=0;p<t.length;p++){let _=t[p];if(_.kind==="hard-break"){a?f():o.push({text:"",width:0,startSegment:p,startGrapheme:0,endSegment:p,endGrapheme:0}),u=p+1,l=0;continue}let k=_.width;if(!a){k>e&&_.graphemeWidths?w(p,0,_.graphemeWidths):g(p,0,k),x(_.kind)&&(v=p+1,m=_.kind==="space"?i-k:i);continue}let N=i+k;if(N>e+.005){if(x(_.kind)){i+=k,d=p+1,h=0,f(p+1,0,_.kind==="space"?i-k:i);continue}if(v>=0){f(v,0,m),p--;continue}if(k>e&&_.graphemeWidths){f(),w(p,0,_.graphemeWidths);continue}f(),p--;continue}i=N,d=p+1,h=0,x(_.kind)&&(v=p+1,m=_.kind==="space"?i-k:i)}return a&&f(),{lines:o,lineCount:o.length};function w(p,_,k){for(let N=_;N<k.length;N++){let T=k[N];if(!a){y(p,N,T);continue}i+T>e+.005?(f(),y(p,N,T)):(i+=T,d=p,h=N+1)}a&&d===p&&h===k.length&&(d=p+1,h=0)}}function Nt(t){return t==="space"||t==="zero-width-break"||t==="soft-hyphen"}var Ot=null;function pr(){return Ot===null&&(Ot=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Ot}function bn(t,e,n){if(e===0&&n<0)return t.text;let r=[...pr().segment(t.text)].map(o=>o.segment),s=n<0?r.length:n;return r.slice(e,s).join("")}function ae(t,e,n,r,s,o){let i="";for(let a=e;a<r;a++){let u=t[a];u.kind==="soft-hyphen"||u.kind==="hard-break"||(a===e&&n>0?i+=bn(u,n,-1):i+=u.text)}if(s>0&&r<t.length){let a=t[r];i+=bn(a,e===r?n:0,s)}return o&&(i+="-"),i}function gr(t){if(!t?.adapter||!t.font)return 0;let e=t.cache;if(e){let n=e.get(t.font);n||(n=new Map,e.set(t.font,n));let r=n.get("-");return r===void 0&&(r=t.adapter.measureSegment("-",t.font).width,n.set("-",r)),r}return t.adapter.measureSegment("-",t.font).width}function Tt(t,e,n,r){let s=e.segmentIndex,o=e.graphemeIndex;if(s>=t.length)return null;if(o===0){for(;s<t.length;){let p=t[s];if(p.kind==="hard-break")return{text:"",width:0,start:{segmentIndex:e.segmentIndex,graphemeIndex:0},end:{segmentIndex:s+1,graphemeIndex:0}};if(p.kind==="space"||p.kind==="zero-width-break"||p.kind==="soft-hyphen"){s+=1;continue}break}if(s>=t.length)return null}let i=gr(r),a=s,u=s===e.segmentIndex?o:0,l=0,d=a,h=0,v=!1,m=-1,c=0,b=0,f=!1,x=(p,_,k,N)=>{m=p,c=_,b=k,f=N==="soft-hyphen"},g=(p,_,k)=>{for(let N=_;N<k.length;N++){let T=k[N];if(!v){l=T,d=p,h=N+1,v=!0;continue}if(l+T>n+.005)return!0;l+=T,d=p,h=N+1}return d===p&&h===k.length&&(d=p+1,h=0),!1};if(u>0&&a<t.length){let p=t[a];if(p.graphemeWidths){if(g(a,u,p.graphemeWidths))return{text:ae(t,a,u,d,h,!1),width:l,start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}};s=d}}for(;s<t.length;){let p=t[s];if(p.kind==="hard-break"){if(v){let N=d>0&&t[d-1]?.kind==="soft-hyphen";return{text:ae(t,a,u,d,h,N),width:l+(N?i:0),start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}}}return{text:"",width:0,start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:s+1,graphemeIndex:0}}}let _=p.width;if(!v){if(_>n&&p.graphemeWidths){if(g(s,0,p.graphemeWidths))return{text:ae(t,a,u,d,h,!1),width:l,start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}};s=d;continue}l=_,d=s+1,h=0,v=!0,Nt(p.kind)&&x(s+1,0,p.kind==="space"?l-_:l,p.kind),s+=1;continue}let k=l+_;if(k>n+.005){if(Nt(p.kind)){d=s+1,h=0;let T=p.kind==="soft-hyphen",E=p.kind==="space"?l:l+(T?i:0);return{text:ae(t,a,u,d,h,T),width:E,start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}}}return m>=0?{text:ae(t,a,u,m,c,f),width:b+(f?i:0),start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:m,graphemeIndex:c}}:_>n&&p.graphemeWidths?{text:ae(t,a,u,d,h,!1),width:l,start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}}:{text:ae(t,a,u,d,h,!1),width:l,start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}}}l=k,d=s+1,h=0,Nt(p.kind)&&x(s+1,0,p.kind==="space"?l-_:l,p.kind),s+=1}if(!v)return null;let y=d>0&&t[d-1]?.kind==="soft-hyphen";return{text:ae(t,a,u,d,h,y),width:l+(y?i:0),start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}}}function St(t,e,n=0){let r=[t];for(let s=0;s<e.length;s++){let o=e[s],i=[];for(let a=0;a<r.length;a++){let u=r[a];if(o.right<=u.left||o.left>=u.right){i.push(u);continue}o.left>u.left&&i.push({left:u.left,right:o.left}),o.right<u.right&&i.push({left:o.right,right:u.right})}r=i}return n>0?r.filter(s=>s.right-s.left>=n):r}function Ve(t,e,n){let r=[],s=new Intl.Segmenter(void 0,{granularity:"grapheme"});for(let o=0;o<t.lines.length;o++){let i=t.lines[o],a=o*n,u=0;for(let l=i.startSegment;l<e.length;l++){let d=e[l];if(d.kind==="soft-hyphen"||d.kind==="hard-break"){if(l>=i.endSegment&&i.endGrapheme===0)break;continue}let h=[...s.segment(d.text)].map(c=>c.segment);if(h.length===0)continue;let v=l===i.startSegment?i.startGrapheme:0,m;if(l<i.endSegment)m=h.length;else if(l===i.endSegment&&i.endGrapheme>0)m=i.endGrapheme;else break;for(let c=v;c<m;c++){let b=d.graphemeWidths?d.graphemeWidths[c]:d.width/h.length;r.push({x:u,y:a,width:b,height:n,line:o}),u+=b}}}return r}function mr(t){let{adapter:e,name:n="reactive-layout"}=t,r=new re(n),s=new Map,o=P(t.text??"",{name:"text"}),i=P(t.font??"16px sans-serif",{name:"font"}),a=P(t.lineHeight??20,{name:"line-height"}),u=P(Math.max(0,t.maxWidth??800),{name:"max-width"});function l(c,b){if(c===null||b===null)return c===b;if(c.length!==b.length)return!1;for(let f=0;f<c.length;f++)if(c[f]!==b[f])return!1;return!0}let d=te([o,i],(c,b,f)=>{let x=c[0],g=x!=null&&x.length>0?x.at(-1):f.prevData[0],y=c[1],w=y!=null&&y.length>0?y.at(-1):f.prevData[1],p=B(),_={hits:0,misses:0},k=xe(g,w,e,s,_),N=B()-p,T=_.hits+_.misses,E=T===0?1:_.hits/T,O=d.meta;O&&(X(O["cache-hit-rate"],E),X(O["segment-count"],k.length),X(O["layout-time-ns"],N)),b.emit(k);let C=()=>{s.clear(),e.clearCache?.()};return{deactivate:C,invalidate:C}},{name:"segments",describeKind:"derived",meta:{"cache-hit-rate":0,"segment-count":0,"layout-time-ns":0},equals:(c,b)=>{let f=c,x=b;if(f==null||x==null)return f===x;if(f.length!==x.length)return!1;for(let g=0;g<f.length;g++){let y=f[g],w=x[g];if(y.text!==w.text||y.width!==w.width||y.kind!==w.kind||!l(y.graphemeWidths??null,w.graphemeWidths??null))return!1}return!0}}),h=q([d,u,i],([c,b,f])=>We(c,b,e,f,s),{name:"line-breaks",equals:(c,b)=>{let f=c,x=b;if(f==null||x==null)return f===x;if(f.lineCount!==x.lineCount)return!1;for(let g=0;g<f.lines.length;g++){let y=f.lines[g],w=x.lines[g];if(y.text!==w.text||y.width!==w.width||y.startSegment!==w.startSegment||y.startGrapheme!==w.startGrapheme||y.endSegment!==w.endSegment||y.endGrapheme!==w.endGrapheme)return!1}return!0}}),v=q([h,a],([c,b])=>c.lineCount*b,{name:"height"}),m=q([h,d,a],([c,b,f])=>Ve(c,b,f),{name:"char-positions",equals:(c,b)=>{let f=c,x=b;if(f==null||x==null)return f===x;if(f.length!==x.length)return!1;for(let g=0;g<f.length;g++)if(f[g].x!==x[g].x||f[g].y!==x[g].y||f[g].width!==x[g].width)return!1;return!0}});return r.add(o,{name:"text"}),r.add(i,{name:"font"}),r.add(a,{name:"line-height"}),r.add(u,{name:"max-width"}),r.add(d,{name:"segments"}),r.add(h,{name:"line-breaks"}),r.add(v,{name:"height"}),r.add(m,{name:"char-positions"}),{graph:r,setText:c=>r.set("text",c),setFont:c=>r.set("font",c),setLineHeight:c=>r.set("line-height",c),setMaxWidth:c=>r.set("max-width",Math.max(0,c)),segments:d,lineBreaks:h,height:v,charPositions:m}}function yn(t,e,n,r,s,o,i){switch(t.type){case"text":{let a=t.font??s,u=t.lineHeight??o,l=xe(t.text,a,n.text,r),d=We(l,e,n.text,a,r),h=Ve(d,l,u),v=d.lineCount*u,m=0;for(let c of d.lines)c.width>m&&(m=c.width);return{index:i,type:"text",width:Math.min(m,e),height:v,textSegments:l,textLineBreaks:d,textCharPositions:h}}case"image":{let a,u;if(t.naturalWidth!=null&&t.naturalHeight!=null)a=t.naturalWidth,u=t.naturalHeight;else if(n.image){let l=n.image.measureImage(t.src);a=l.width,u=l.height}else throw new Error(`Image block at index ${i} has no naturalWidth/naturalHeight and no ImageMeasurer adapter`);return a>e&&(u=u*e/a,a=e),{index:i,type:"image",width:a,height:u}}case"svg":{let a,u;if(t.viewBox)a=t.viewBox.width,u=t.viewBox.height;else if(n.svg){let l=n.svg.measureSvg(t.content);a=l.width,u=l.height}else throw new Error(`SVG block at index ${i} has no viewBox and no SvgMeasurer adapter`);return a>e&&(u=u*e/a,a=e),{index:i,type:"svg",width:a,height:u}}}}function vn(t,e,n,r,s,o){return t.map((i,a)=>yn(i,e,n,r,s,o,a))}function xn(t,e){let n=[],r=0;for(let s=0;s<t.length;s++){let o=t[s];n.push({...o,x:0,y:r}),r+=o.height+(s<t.length-1?e:0)}return n}function wn(t){if(t.length===0)return 0;let e=t[t.length-1];return e.y+e.height}function br(t){let{adapters:e,name:n="reactive-block-layout",defaultFont:r="16px sans-serif",defaultLineHeight:s=20}=t,o=new re(n),i=new Map,a=P(t.blocks??[],{name:"blocks"}),u=P(Math.max(0,t.maxWidth??800),{name:"max-width"}),l=P(t.gap??0,{name:"gap"}),d=te([a,u],(m,c,b)=>{let f=m[0]!=null&&m[0].length>0?m[0].at(-1):b.prevData[0],x=m[1]!=null&&m[1].length>0?m[1].at(-1):b.prevData[1],g=B(),y=vn(f,x,e,i,r,s),w=B()-g,p=d.meta;p&&(X(p["block-count"],y.length),X(p["layout-time-ns"],w)),c.emit(y);let _=()=>{i.clear(),e.text.clearCache?.()};return{deactivate:_,invalidate:_}},{name:"measured-blocks",describeKind:"derived",meta:{"block-count":0,"layout-time-ns":0},equals:(m,c)=>{let b=m,f=c;if(b==null||f==null)return b===f;if(b.length!==f.length)return!1;for(let x=0;x<b.length;x++){let g=b[x],y=f[x];if(g.type!==y.type||g.width!==y.width||g.height!==y.height||g.index!==y.index)return!1}return!0}}),h=q([d,l],([m,c])=>xn(m,c),{name:"block-flow",equals:(m,c)=>{let b=m,f=c;if(b==null||f==null)return b===f;if(b.length!==f.length)return!1;for(let x=0;x<b.length;x++){let g=b[x],y=f[x];if(g.x!==y.x||g.y!==y.y||g.width!==y.width||g.height!==y.height)return!1}return!0}}),v=q([h],([m])=>wn(m),{name:"total-height"});return o.add(a,{name:"blocks"}),o.add(u,{name:"max-width"}),o.add(l,{name:"gap"}),o.add(d,{name:"measured-blocks"}),o.add(h,{name:"block-flow"}),o.add(v,{name:"total-height"}),{graph:o,setBlocks:m=>o.set("blocks",m),setMaxWidth:m=>o.set("max-width",Math.max(0,m)),setGap:m=>o.set("gap",m),measuredBlocks:d,blockFlow:h,totalHeight:v}}ue();ne();Te();function _n(t,e,n){let r=t.hPad??0,s=t.vPad??0,o=e-s,i=n+s;if(o>=t.cy+t.r||i<=t.cy-t.r)return null;let a=t.cy>=o&&t.cy<=i?0:t.cy<o?o-t.cy:t.cy-i;if(a>=t.r)return null;let u=Math.sqrt(t.r*t.r-a*a);return{left:t.cx-u-r,right:t.cx+u+r}}function kn(t,e,n){let r=t.hPad??0,s=t.vPad??0;return n<=t.y-s||e>=t.y+t.h+s?null:{left:t.x-r,right:t.x+t.w+r}}function yr(t,e,n){return t.kind==="circle"?_n(t,e,n):kn(t,e,n)}function Nn(t,e,n,r,s,o,i){let a=i?.paragraphSpacing??s,u=[],l={segmentIndex:0,graphemeIndex:0};if(t.length===0||n.count<=0||s<=0)return{lines:u,cursor:l};let d=e.paddingX??0,h=e.paddingY??0,v=Math.max(0,e.width-d*2),m=Math.max(0,e.height-h*2),c=n.gap*Math.max(0,n.count-1),b=Math.max(0,(v-c)/n.count);if(b<=0)return{lines:u,cursor:l};e:for(let f=0;f<n.count;f++){let x=d+f*(b+n.gap),g=x+b,y=h;for(;y+s<=h+m;){let w=y+s,p=[];for(let N=0;N<r.length;N++){let T=yr(r[N],y,w);T!==null&&p.push(T)}let _=St({left:x,right:g},p,o);if(_.length===0){y+=s;continue}let k=!1;for(let N=0;N<_.length;N++){let T=_[N],E=T.right-T.left,O=Tt(t,l,E);if(O===null)return{lines:u,cursor:l};if(O.text.length===0&&O.width===0){l=O.end,k=!0;break}u.push({x:T.left,y,width:O.width,slotWidth:E,text:O.text,columnIndex:f,flushToRight:T.right<g-.5}),l=O.end}if(k){y+=a;continue}if(y+=s,l.segmentIndex>=t.length)break e}if(l.segmentIndex>=t.length)break}return{lines:u,cursor:l}}function vr(t){let{adapter:e,name:n="reactive-flow-layout",minSlotWidth:r=20}=t,s=new re(n),o=new Map,i=P(t.text??"",{name:"text"}),a=P(t.font??"16px sans-serif",{name:"font"}),u=P(t.lineHeight??20,{name:"line-height"}),l=P(t.container??{width:800,height:600,paddingX:0,paddingY:0},{name:"container"}),d=P(t.columns??{count:1,gap:0},{name:"columns"}),h=P(t.obstacles??[],{name:"obstacles"}),v=P(t.paragraphSpacing??null,{name:"paragraph-spacing"}),m=te([i,a],(b,f,x)=>{let g=b[0],y=g!=null&&g.length>0?g.at(-1):x.prevData[0],w=b[1],p=w!=null&&w.length>0?w.at(-1):x.prevData[1],_=xe(y,p,e,o);f.emit(_);let k=()=>{o.clear(),e.clearCache?.()};return{deactivate:k,invalidate:k}},{name:"segments",describeKind:"derived"}),c=q([m,l,d,h,u,v],([b,f,x,g,y,w])=>{let p=b,_=B(),k=w??y,{lines:N,cursor:T}=Nn(p,f,x,g,y,r,{paragraphSpacing:k}),E=B()-_,O=Math.max(0,p.length-T.segmentIndex),C=c.meta;return C&&(X(C["line-count"],N.length),X(C["layout-time-ns"],E),X(C["overflow-segments"],O)),N},{name:"flow-lines",meta:{"line-count":0,"layout-time-ns":0,"overflow-segments":0},equals:(b,f)=>{let x=b,g=f;if(x.length!==g.length)return!1;for(let y=0;y<x.length;y++){let w=x[y],p=g[y];if(w.x!==p.x||w.y!==p.y||w.width!==p.width||w.slotWidth!==p.slotWidth||w.text!==p.text||w.columnIndex!==p.columnIndex||w.flushToRight!==p.flushToRight)return!1}return!0}});return s.add(i,{name:"text"}),s.add(a,{name:"font"}),s.add(u,{name:"line-height"}),s.add(l,{name:"container"}),s.add(d,{name:"columns"}),s.add(h,{name:"obstacles"}),s.add(v,{name:"paragraph-spacing"}),s.add(m,{name:"segments"}),s.add(c,{name:"flow-lines"}),{graph:s,setText:b=>s.set("text",b),setFont:b=>s.set("font",b),setLineHeight:b=>s.set("line-height",b),setContainer:b=>s.set("container",b),setColumns:b=>s.set("columns",b),setObstacles:b=>s.set("obstacles",b),setParagraphSpacing:b=>s.set("paragraph-spacing",b),segments:m,flowLines:c}}0&&(module.exports={CanvasMeasureAdapter,CliMeasureAdapter,ImageSizeAdapter,NodeCanvasMeasureAdapter,PrecomputedAdapter,SvgBoundsAdapter,analyzeAndMeasure,carveTextLineSlots,circleIntervalForBand,computeBlockFlow,computeCharPositions,computeFlowLines,computeLineBreaks,computeTotalHeight,layoutNextLine,measureBlock,measureBlocks,reactiveBlockLayout,reactiveFlowLayout,reactiveLayout,rectIntervalForBand});
1
+ "use strict";var Xe=Object.defineProperty;var An=Object.getOwnPropertyDescriptor;var Mn=Object.getOwnPropertyNames;var Dn=Object.prototype.hasOwnProperty;var I=(t,e)=>()=>(t&&(e=t(t=0)),e);var Gn=(t,e)=>{for(var n in e)Xe(t,n,{get:e[n],enumerable:!0})},Pn=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Mn(e))!Dn.call(t,s)&&s!==n&&Xe(t,s,{get:()=>e[s],enumerable:!(r=An(e,s))||r.enumerable});return t};var In=t=>Pn(Xe({},"__esModule",{value:!0}),t);function Ln(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 Mt(t){let e=0;for(let n of t)e+=Ln(n.codePointAt(0));return e}var Dt=I(()=>{"use strict"});function j(){return Math.trunc(performance.now()*1e6)}function Re(){return Date.now()*1e6}var ue=I(()=>{"use strict"});function Pt(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++]=ot,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 It(t,e){if(t.length<Gt)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${Gt})`);let n=0,r=t[n++];if(r!==ot)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${ot})`);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),u=e.lookupCodec(o);if(u==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:u,codecVersion:i,payload:a}}function Lt(t){t.registerCodec(Fn)}var Fn,ot,Gt,it=I(()=>{"use strict";Fn={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)}},ot=1,Gt=4});function Ae(t){if(t==null)return he;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var he,at=I(()=>{"use strict";he={type:"system",id:""}});function Me(){return pe>0||_e}function Ft(){return pe>0}function me(t){pe>0?ke.push(t):t()}function $t(t){pe+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(pe-=1,pe===0)if(e){if(!_e){let n=ke.splice(0);for(let r of n)try{r()}catch{}le.length=0,de.length=0,ge.length=0}}else $n()}}function $n(){let t=!_e;t&&(_e=!0);let e=[],n=0;try{for(;le.length>0||de.length>0||ge.length>0||t&&ke.length>0;){if(t&&ke.length>0){let o=ke.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw le.length=0,de.length=0,ge.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(le.length>0?le:de.length>0?de:ge).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{t&&(_e=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function be(t,e,n){if(e.length===0)return;if(e.length===1){let l=n(e[0][0]);if(l<3||!Me()){t(e);return}(l>=5?ge:l===4?de:le).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 u=Me();if(s>0){let l=e.slice(0,s);t(l)}if(o>s){let l=e.slice(s,o);u?le.push(()=>t(l)):t(l)}if(i>o){let l=e.slice(o,i);u?de.push(()=>t(l)):t(l)}if(r>i){let l=e.slice(i,r);u?ge.push(()=>t(l)):t(l)}}var pe,_e,le,de,ge,ke,De=I(()=>{"use strict";pe=0,_e=!1,le=[],de=[],ge=[],ke=[]});var Ne,B,Z,Q,Y,ee,se,H,V,L,ye,ut,Bn,lt,jn,Hn,dt,Bt,jt,Ht,ct,Oe=I(()=>{"use strict";Ne=Symbol.for("graphrefly/START"),B=Symbol.for("graphrefly/DATA"),Z=Symbol.for("graphrefly/DIRTY"),Q=Symbol.for("graphrefly/RESOLVED"),Y=Symbol.for("graphrefly/INVALIDATE"),ee=Symbol.for("graphrefly/PAUSE"),se=Symbol.for("graphrefly/RESUME"),H=Symbol.for("graphrefly/TEARDOWN"),V=Symbol.for("graphrefly/COMPLETE"),L=Symbol.for("graphrefly/ERROR"),ye=Object.freeze([Z]),ut=Object.freeze([Q]),Bn=Object.freeze([Y]),lt=Object.freeze([Ne]),jn=Object.freeze([V]),Hn=Object.freeze([H]),dt=Object.freeze([ye]),Bt=Object.freeze([ut]),jt=Object.freeze([Bn]),Ht=Object.freeze([jn]),ct=Object.freeze([Hn])});function Wt(t){t.registerMessageType(Ne,{tier:0,wireCrossing:!1}),t.registerMessageType(Z,{tier:1,wireCrossing:!1}),t.registerMessageType(Y,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(ee,{tier:2,wireCrossing:!1}),t.registerMessageType(se,{tier:2,wireCrossing:!1}),t.registerMessageType(B,{tier:3,wireCrossing:!0}),t.registerMessageType(Q,{tier:3,wireCrossing:!0}),t.registerMessageType(V,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(L,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(H,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Ge,Vt=I(()=>{"use strict";Oe();Ge=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 ft(t){let e=Wn.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 K,Wn,Pe=I(()=>{"use strict";K=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}},Wn=["human","llm","wallet","system"]});function ht(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(ht);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=ht(t[n]);return e}return null}function Un(t){let e=zn.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,u=3144134277,l=1013904242,d=2773480762,h=1359893119,v=2600822924,m=528734635,c=1541459225,b=new Uint32Array(64),f=(g,y)=>g>>>y|g<<32-y;for(let g=0;g<s;g+=64){for(let O=0;O<16;O++)b[O]=i.getUint32(g+O*4,!1);for(let O=16;O<64;O++){let C=b[O-15],M=b[O-2],A=f(C,7)^f(C,18)^C>>>3,fe=f(M,17)^f(M,19)^M>>>10;b[O]=b[O-16]+A+b[O-7]+fe>>>0}let y=a,w=u,p=l,_=d,k=h,N=v,T=m,E=c;for(let O=0;O<64;O++){let C=f(k,6)^f(k,11)^f(k,25),M=k&N^~k&T,A=E+C+M+Vn[O]+b[O]>>>0,fe=f(y,2)^f(y,13)^f(y,22),Ue=y&w^y&p^w&p,Ee=fe+Ue>>>0;E=T,T=N,N=k,k=_+A>>>0,_=p,p=w,w=y,y=A+Ee>>>0}a=a+y>>>0,u=u+w>>>0,l=l+p>>>0,d=d+_>>>0,h=h+k>>>0,v=v+N>>>0,m=m+T>>>0,c=c+E>>>0}let x=g=>g.toString(16).padStart(8,"0");return x(a)+x(u)+x(l)+x(d)+x(h)+x(v)+x(m)+x(c)}function pt(t){let e=ht(t??null),n=JSON.stringify(e);return Un(n).slice(0,16)}function Kn(){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 gt(t,e,n){let r=n?.id??Kn();if(t===0)return{id:r,version:0};let o=(n?.hash??pt)(e);return{id:r,version:0,cid:o,prev:null}}function zt(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Vn,zn,Ut=I(()=>{"use strict";Vn=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]),zn=new TextEncoder});function Yt(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function mt(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Ie(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function te(t,e,n){let r=Jt(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,o={};return Jt(t)?o=(bt(e)?e:n)??{}:bt(t)?o=t:o=(bt(e)?e:n)??{},new F(r,s,o)}var Kt,qt,qn,Yn,oe,F,Jt,bt,ne=I(()=>{"use strict";it();at();De();ue();Vt();Pe();Oe();Ut();Kt=()=>{},qt=100;qn=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},Yn=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[lt]:[lt,[B,o]];s._status==="dirty"&&i.push(ye),be(e,i,s._config.tierOf)},oe=new Ge({onMessage:qn,onSubscribe:Yn});Wt(oe);Lt(oe);F=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??oe,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??pt;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?gt(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Yt);let o={};for(let[a,u]of Object.entries(r.meta??{})){let l={initial:u,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(l.guard=r.guard),o[a]=new t([],void 0,l)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[B,a]])},down(a){i._emit(Ie(a))},up(a){i._emitUp(Ie(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,u=i?.version??0,l=gt(e,o,{id:a,hash:s});l.version=u,this._versioning=l,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=Ae(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=Ae(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new K({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new K({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Re()}}down(e,n){let r=Ie(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[B,e]])}up(e,n){if(this._deps.length===0)return;let r=Ie(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 u=Ae(n);if(!this._guard(u,"observe"))throw new K({actor:u,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 u of this._deps)mt(u);if(this._partial===!1){for(let u of this._deps)if(u.prevData!==void 0||u.dataBatch.length!==0||u.terminal!==void 0||u.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(u){throw this._sinkCount-=1,u}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(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw u}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=Kt,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,u=!1;for(let l of i)a(l[0])>=3&&(u=!0),this._config.onMessage(this,l,{direction:"down-in",depIndex:s},this._actions);u&&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{}mt(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=Yt(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(dt),r.unsub=Kt;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([[L,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([[L,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{}}mt(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!==Ne){if(s===Z){this._depDirtied(r);return}if(s===Y){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(jt);return}if(s===ee||s===se){this._emit([n]);return}if(s===H){this._emit(ct);return}if(s===B)this._depSettledAsData(r,n[1]);else if(s===Q)this._depSettledAsResolved(r);else if(s===V)this._depSettledAsTerminal(r,!0);else if(s===L)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===B||s===Q)&&this._emit([n]),(s===V||s===L)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(dt))}_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(Bt),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([[L,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(Ht)}_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([[L,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([[L,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([[L,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>qt?(this._rerunDepth=0,this._emit([[L,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${qt} \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"?[ye,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let u of e){let l=n(u[0]);l<i&&(r=!1),l===3&&(s=!0),u[0]===Z&&(o=!0),i=l}let a=e;if(!r){let u=e.map((l,d)=>({m:l,i:d,tier:n(l[0])}));u.sort((l,d)=>l.tier-d.tier||l.i-d.i),a=u.map(l=>l.m)}if(s&&!o&&this._status!=="dirty"){let u=0;for(;u<a.length&&n(a[u][0])===0;)u++;return u===0?[ye,...a]:[...a.slice(0,u),ye,...a.slice(u)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let u=e[a];if(u[0]===L&&u[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(u=>u[0]===H||u[0]===Y);if(a.length===0)return;n=a}n=this._frameBatch(n);let s=null;for(let a=0;a<n.length;a++){let u=n[a],l=u[0];if(l!==ee&&l!==se){s?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${l===ee?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let d=!0;if(this._pausable!==!1){let h=u[1];if(l===ee)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(h),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(h))d=!1;else if(this._pauseLocks.delete(h),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let v=this._pauseBuffer;this._pauseBuffer=[],this._emit(v)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}d?s?.push(u):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]===H))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(ct)}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,u=[];for(let l of o)a(l[0])===3?this._pauseBuffer.push(l):u.push(l);u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[L,i]])}_updateState(e){let n=this._config.tierOf,r,s,o=-1,i=0;for(let d of e)n(d[0])===3&&i++;let a=i<=1,u=-1;if(this._versioning!=null&&i>1){for(let d=e.length-1;d>=0;d--)if(e[d][0]===B){u=d;break}}for(let d=0;d<e.length;d++){let h=e[d],v=h[0];if(v===B){if(h.length>=2){let m=!1;if(a&&this._cached!==void 0)try{m=this._equals(this._cached,h[1])}catch(c){s=this._wrapFnError("equals threw",c),o=d;break}if(m){r==null&&(r=e.slice(0,d)),r.push(ut),this._status="resolved";continue}this._cached=h[1],this._versioning!=null&&(u<0||d===u)&&zt(this._versioning,h[1],this._hashFn)}this._status="settled",r?.push(h)}else if(r?.push(h),v===Z)this._status="dirty";else if(v===Q)this._status="resolved";else if(v===V){this._status="completed";{let m=this._config.rigorRecorder;if(m!=null)try{m.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(v===L){this._status="errored";{let m=this._config.rigorRecorder;if(m!=null)try{m.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(v===Y){if(this._cached!==void 0){let c=this._config.rigorRecorder;if(c!=null)try{c.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let m=this._cleanup;if(typeof m=="function"){this._cleanup=void 0;try{m()}catch{}}else if(m!=null&&typeof m=="object"){let c=m.invalidate;if(typeof c=="function")try{c()}catch{}}}else v===H&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let l=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:l,equalsError:s}:{finalMessages:l}}_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(Ft()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],me(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}be(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);be(this._deliverToSinks,n,this._config.tierOf)}},Jt=t=>Array.isArray(t),bt=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function P(t,e){return te([],{...e,initial:t})}function yt(t,e){return te((r,s,o)=>t(s,o)??void 0,{describeKind:"producer",...e})}function q(t,e,n){return te(t,(s,o,i)=>{let a=s.map((u,l)=>u!=null&&u.length>0?u.at(-1):i.prevData[l]);o.emit(e(a,i))},{describeKind:"derived",...n})}var Te=I(()=>{"use strict";ne()});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","value"]);default:return new Set(["type","deps"])}}function Jn(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function Xn(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function xt(t,e,n){let r=e==null,s=!r&&e!=null?[...e].filter(d=>d.startsWith("meta.")).map(d=>d.slice(5)):null,o=r||e.has("meta")||s!=null&&s.length>0,i="state",a=[];t instanceof F&&(i=Jn(t),a=t._deps.map(d=>d.node.name??""));let u={type:i,deps:a};(r||e.has("status"))&&(u.status=t.status);let l=t instanceof F?t._guard:void 0;if(o){let d={...Xn(t)};if(l!=null&&d.access===void 0&&(d.access=ft(l)),s!=null&&s.length>0&&!e.has("meta")){let h={};for(let v of s)v in d&&(h[v]=d[v]);u.meta=h}else u.meta=d}if(t.name!=null&&(u.name=t.name),(r||e.has("value"))&&(!n||i==="state")){t.status==="sentinel"&&(u.sentinel=!0);try{u.value=t.cache}catch{}}if((r||e.has("v"))&&t.v!=null){let d={id:t.v.id,version:t.v.version};"cid"in t.v&&(d.cid=t.v.cid,d.prev=t.v.prev),u.v=d}return(r||e.has("guard"))&&l!=null&&(u.guard=ft(l)),(r||e.has("lastMutation"))&&t.lastMutation!=null&&(u.lastMutation=t.lastMutation),u}var Xt=I(()=>{"use strict";Pe();ne()});function wt(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(!wt(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)||!wt(t[o],e[o]))return!1;return!0}function Zt(t,e){return`${t}\0${e}`}function _t(t,e){let n=[],r=new Set(t.subgraphs),s=new Set(e.subgraphs),o=[];for(let f of s)r.has(f)||o.push(f);o.sort();for(let f of o)n.push({type:"subgraph-mounted",path:f});let i=new Set(Object.keys(t.nodes)),a=new Set(Object.keys(e.nodes)),u=[];for(let f of a)i.has(f)||u.push(f);u.sort();for(let f of u)n.push({type:"node-added",path:f,node:{...e.nodes[f]}});let l=[];for(let f of a){if(!i.has(f))continue;let x=t.nodes[f]?.meta,g=e.nodes[f]?.meta;x==null&&g==null||wt(x??{},g??{})||l.push(f)}l.sort();for(let f of l)n.push({type:"node-meta-changed",path:f,prevMeta:t.nodes[f]?.meta??{},nextMeta:e.nodes[f]?.meta??{}});let d=new Map;for(let f of t.edges)d.set(Zt(f.from,f.to),f);let h=new Map;for(let f of e.edges)h.set(Zt(f.from,f.to),f);let v=[];for(let[f,x]of h)d.has(f)||v.push(x);v.sort((f,x)=>f.from<x.from?-1:f.from>x.from?1:f.to<x.to?-1:f.to>x.to?1:0);for(let f of v)n.push({type:"edge-added",from:f.from,to:f.to});let m=[];for(let[f,x]of d)h.has(f)||m.push(x);m.sort((f,x)=>f.from<x.from?-1:f.from>x.from?1:f.to<x.to?-1:f.to>x.to?1:0);for(let f of m)n.push({type:"edge-removed",from:f.from,to:f.to});let c=[];for(let f of i)a.has(f)||c.push(f);c.sort();for(let f of c)n.push({type:"node-removed",path:f});let b=[];for(let f of r)s.has(f)||b.push(f);b.sort();for(let f of b)n.push({type:"subgraph-unmounted",path:f});return{events:n,flushedAt_ns:j()}}var Qt=I(()=>{"use strict";ue()});function Le(t){return t.subscribe(()=>{})}var en=I(()=>{"use strict"});var tn=I(()=>{"use strict";en()});var Fe,nn=I(()=>{"use strict";Fe=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 Se,rn=I(()=>{"use strict";Se=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}}});function sn(t,e,n,r={}){let s=e in t.nodes,o=n in t.nodes;if(!s)return $e(e,n,"no-such-from");if(!o)return $e(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 l=Zn(t,e,r);if(l!=null)return l}let u=Be(e,t.nodes[e],0,r);return je(e,n,[u])}if(i===0)return $e(e,n,"no-path");let a=on(t,e,n,i);return a.found?je(e,n,an(t,a.pathOrder,r)):$e(e,n,a.truncated?"max-depth-exceeded":"no-path")}function on(t,e,n,r){let s=new Map,o=[{path:n,depth:0}],i=new Set([n]),a=0,u=!1;for(;a<o.length;){let h=o[a++];if(h.path===e)break;if(r!=null&&h.depth>=r){let b=t.nodes[h.path];b?.deps&&b.deps.length>0&&(u=!0);continue}let v=t.nodes[h.path];if(v==null)continue;let m=v.deps??[],c=new Map;for(let b=0;b<m.length;b++){let f=m[b];if(!f)continue;let x=c.get(f);x==null&&(x=[],c.set(f,x)),x.push(b)}for(let[b,f]of c)i.has(b)||(i.add(b),s.set(b,{from:h.path,depIndices:f}),o.push({path:b,depth:h.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:u};let l=[{path:e}],d=e;for(;d!==n;){let h=s.get(d);if(h==null)return{found:!1,pathOrder:[],truncated:!1};l[l.length-1].depIndices=h.depIndices,l.push({path:h.from}),d=h.from}return{found:!0,pathOrder:l,truncated:!1}}function Zn(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=Be(e,r,0,n);a.dep_index=o[0];let u=Be(e,r,1,n);return je(e,e,[a,u])}let i=null;for(let a=0;a<s.length;a++){let u=s[a];if(!u||u===e)continue;let l=on(t,u,e,n.maxDepth);l.found&&(i==null||l.pathOrder.length<i.pathOrder.length)&&(i=l,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...l.pathOrder],truncated:!1})}return i==null?null:je(e,e,an(t,i.pathOrder,n))}function an(t,e,n){return e.map((r,s)=>{let o=t.nodes[r.path],i=Be(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 Be(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 je(t,e,n){return un(t,e,!0,"ok",n)}function $e(t,e,n){return un(t,e,!1,n,[])}function un(t,e,n,r,s){let o=Qn(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 Qn(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 u=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(u),"value"in i&&o.push(` value: ${er(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let l=i.lastMutation.actor;o.push(` actor: ${l.type}${l.id?`:${l.id}`:""}`)}}return o.join(`
2
+ `)}function er(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)}}var ln=I(()=>{"use strict"});function dn(t){let e=new WeakSet,n=new WeakSet,r=[t],s=0;for(;r.length>0;){let o=r.pop();s+=nr(o,e,n,r)}return s}function nr(t,e,n,r){if(t==null)return 0;switch(typeof t){case"number":return $.number;case"boolean":return $.boolean;case"string":return $.string+t.length*2;case"bigint":return $.bigint+rr(t);case"symbol":return $.symbol;case"function":return e.has(t)?0:(e.add(t),$.function);case"undefined":return 0}let o=t;if(e.has(o))return 0;e.add(o);let i=o[tr];if(typeof i=="function")try{let l=i.call(o);if(typeof l=="number"&&Number.isFinite(l))return l}catch{}if(o instanceof Date)return $.date;if(o instanceof RegExp)return $.regexp+o.source.length*2;if(o instanceof Error){let l=o.message?o.message.length*2:0,d=o.stack?o.stack.length*2:0;return $.error+l+d}if(typeof URL<"u"&&o instanceof URL)return $.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return $.promise;if(o instanceof WeakMap)return $.weakmap;if(o instanceof WeakSet)return $.weakset;if(o instanceof Map){let l=$.map;for(let[d,h]of o)l+=$.mapEntry,r.push(d),r.push(h);return l}if(o instanceof Set){let l=$.set;for(let d of o)l+=$.setEntry,r.push(d);return l}if(Array.isArray(o)){let l=$.array+o.length*8;for(let d of o)r.push(d);return l}if(o instanceof ArrayBuffer)return n.has(o)?0:(n.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let l=o;return n.has(l.buffer)?48:(n.add(l.buffer),l.buffer.byteLength+48)}let a=$.object,u=Object.keys(o);for(let l of u){a+=$.string+l.length*2;try{r.push(o[l])}catch{}}return a}function rr(t){let e=t<0n?-t:t;if(e===0n)return 0;let n=e.toString(2).length;return Math.ceil(n/32)*8}var $,tr,cn=I(()=>{"use strict";$={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},tr=Symbol.for("sizeof")});function fn(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[v,m]of s)i.set(v,m);let a=[];for(let[v,m]of Object.entries(r.nodes)){let c=i.get(v),b=c instanceof F?c:null,f=b?dn(b.cache):0,x=b?b._sinkCount:0,g=m.deps?.length??0,y=m.type==="effect"&&x===0,w=x===0?m.type==="effect"?"orphan-effect":m.type==="derived"?"idle-derived":m.type==="producer"?"idle-producer":null:null;a.push({path:v,type:m.type,status:m.status??"unknown",valueSizeBytes:f,subscriberCount:x,depCount:g,isOrphanEffect:y,orphanKind:w})}let u=a.reduce((v,m)=>v+m.valueSizeBytes,0),l=(v,m)=>[...a].sort(m??((c,b)=>b[v]-c[v])).slice(0,n),d=a.filter(v=>v.orphanKind!=null),h=a.filter(v=>v.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:u,hotspots:{byValueSize:l("valueSizeBytes"),bySubscriberCount:l("subscriberCount"),byDepCount:l("depCount")},orphans:d,orphanEffects:h}}var hn=I(()=>{"use strict";ne();cn()});function pn(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 xn(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"&&typeof t.down=="function"}function sr(t){if(t!=null)return xn(t)?t.cache:t}function ce(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"&&typeof t.down=="function"}function ie(t){return ce(t)?t.cache??"":t}function gn(t){return ce(t)?t.cache??0:t}function mn(t){return ce(t)?t.cache??!1:t}function or(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(`
3
+ `)}function bn(t){if(t.version!==ve)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${ve})`);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 ir(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,u=o.constructor;if(a!==u)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 v=o;if(s.length!==v.length)return!1;for(let m=0;m<s.length;m++)if(!r(s[m],v[m]))return!1;return!0}if(s instanceof Map){let v=o;if(s.size!==v.size)return!1;for(let[m,c]of s)if(!v.has(m)||!r(c,v.get(m)))return!1;return!0}if(s instanceof Set){let v=o;if(s.size!==v.size)return!1;for(let m of s){let c=!1;for(let b of v)if(r(m,b)){c=!0;break}if(!c)return!1}return!0}if(ArrayBuffer.isView(s)){let v=s,m=o;if(v.length!==m.length)return!1;for(let c=0;c<v.length;c++)if(v[c]!==m[c])return!1;return!0}let l=Object.keys(s),d=Object.keys(o);if(l.length!==d.length)return!1;let h=new Set(d);for(let v of l)if(!h.has(v)||!r(s[v],o[v]))return!1;return!0};return r(t,e)}function ar(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function He(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+=ar(r)}return e+="$",new RegExp(e)}function kt(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 dr(t){return t==="none"?lr:t==="ansi"||t==null?ur:{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 yn(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 cr(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 Nt(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(G))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${G}' (path separator)`);if(t===J)throw new Error(`Graph "${e}": ${n} name "${J}" is reserved for meta companion paths`);cr(t,e,n)}function fr(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(G);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function hr(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 wn(t){for(let e of t._mounts.values())wn(e);for(let e of t._nodes.values())try{e.down([[H]],{internal:!0})}catch{}}function pr(t,e){let n=re.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 vn(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,u=new Map,l=new Map,d=new Set;for(let[y,w]of Object.entries(t.nodes)){if(!y)continue;d.add(y);let p=w.deps??[];i.set(y,p);for(let _ of p)_&&(d.add(_),a.has(_)||a.set(_,new Set),a.get(_).add(y))}for(let y of t.edges){if(y==null||typeof y!="object")continue;let w=typeof y.from=="string"?y.from:"",p=typeof y.to=="string"?y.to:"";!w||!p||(d.add(w),d.add(p),l.has(w)||l.set(w,new Set),l.get(w).add(p),u.has(p)||u.set(p,new Set),u.get(p).add(w))}if(!d.has(e))return r.withDetail?s:[];let h=r.both===!0,v=y=>{if(h){let k=i.get(y)??[],N=u.get(y),T=a.get(y),E=l.get(y),O=[...k];return N&&O.push(...N),T&&O.push(...T),E&&O.push(...E),O}if(n==="upstream"){let k=i.get(y)??[],N=u.get(y);return N?[...k,...N]:k}let w=a.get(y),p=l.get(y),_=w?[...w]:[];return p&&_.push(...p),_},m=new Set([e]),c=new Map,b=[{path:e,depth:0}],f=0,x=!1;for(;f<b.length;){let y=b[f++];if(o!=null&&y.depth>=o){v(y.path).length>0&&(x=!0);continue}for(let w of v(y.path))!w||m.has(w)||(m.add(w),c.set(w,y.depth+1),b.push({path:w,depth:y.depth+1}))}let g=[...c.keys()].sort((y,w)=>y<w?-1:y>w?1:0);return r.withDetail?{paths:g,depths:c,truncated:x}:g}function gr(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}var G,J,ve,ur,lr,re,We=I(()=>{"use strict";at();De();ue();Pe();Oe();Xt();ne();Te();Qt();tn();nn();rn();it();ln();hn();G="::",J="__meta__",ve=1;ur={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},lr={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};re=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(G))throw new Error(`Graph name must not contain '${G}' (got "${e}")`);if(e===J)throw new Error(`Graph name "${J}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??oe,this._traceRing=new Se(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=yt(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(Nt(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:j()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof F&&n._applyVersioning(e)}remove(e){Nt(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,u]of i)a.includes(`${G}${J}${G}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...n._collectSubgraphs(`${e}${G}`)),this._mounts.delete(e),n._parent=void 0,wn(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([[H]],{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=He(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(G))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([[B,n]],{actor:r?.actor,internal:s,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);$t(()=>{for(let[s,o]of r)this.set(s,o,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[Y]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let s=r?.internal===!0;this.node(e).down([[L,n]],{actor:r?.actor,internal:s,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[V]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[u,l]of this._nodes)r.set(l,u);let a=[];for(let[u,l]of this._nodes)if(l instanceof F)for(let d of l._deps){let h=r.get(d.node);h!=null&&a.push([h,u])}return a.sort((u,l)=>u[0]<l[0]?-1:u[0]>l[0]?1:u[1]<l[1]?-1:u[1]>l[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,u]of s)o.set(u,a);let i=[];for(let[a,u]of s)if(u instanceof F)for(let l of u._deps){let d=o.get(l.node);d!=null&&i.push([d,a])}return i.sort((a,u)=>a[0]<u[0]?-1:a[0]>u[0]?1:a[1]<u[1]?-1:a[1]>u[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(Nt(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=fr(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]===J)return this._resolveMetaChainFromNode(o,s,n.join(G));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(G)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(s.join(G))}_resolveMetaChainFromNode(e,n,r){let s=e,o=0,i=[...n];for(;o<i.length;){if(i[o]!==J)throw new Error(`Graph "${this.name}": expected ${J} segment in meta path "${r}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${J} in "${r}"`);let a=i[o+1],u=s.meta[a];if(!u)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);s=u,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 u of this._mounts.values())u._signalDeliver(e,n,r,s);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=hr(e,this.config);for(let u of[...this._nodes.keys()].sort()){let l=this._nodes.get(u);if(!r.has(l)){r.add(l);try{l.down(e,i)}catch(d){if(d instanceof K)throw d;s.push(d)}a.length!==0&&this._signalMetaSubtree(l,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(u){if(u instanceof K)throw u;o.push(u)}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=sr(e?.actor),r=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let s=vt(e?.detail,e?.fields),o=e?.detail==="spec",i=s,a=[];this._collectObserveTargets("",a);let u=new Map;for(let[w,p]of a)u.set(p,w);let l=[];{let w=a.map(([,k])=>k),p=new Set(u.values()),_=0;for(;w.length>0;){let k=w.shift();if(k instanceof F)for(let N of k._deps){let T=N.node;if(u.has(T))continue;let E=T.name??"",O=E;if(!O||p.has(O))if(E){let C=2;for(;p.has(`${E}#${C}`);)C++;O=`${E}#${C}`}else for(O=`__internal__/${_++}`;p.has(O);)O=`__internal__/${_++}`;u.set(T,O),p.add(O),l.push([O,T]),w.push(T)}}}let d=[...a,...l],h={};for(let[w,p]of d){if(n!=null&&!p.allowsObserve(n))continue;let _=xt(p,i,o),k=p instanceof F?p._deps.map(O=>u.get(O.node)??O.node.name??""):[],{name:N,...T}=_,E={...T,deps:k};if(!o){let O=this._annotations.get(w);O!=null&&(E.annotation=O)}if(r!=null)if(typeof r=="function"){let O=r;if(!(O.length>=2?O(w,E):O(E)))continue}else{let O=!0;for(let[C,M]of Object.entries(r)){let A=C==="deps_includes"?"depsIncludes":C==="meta_has"?"metaHas":C;if(A==="depsIncludes"){if(!E.deps.includes(String(M))){O=!1;break}continue}if(A==="metaHas"){if(!Object.hasOwn(E.meta??{},String(M))){O=!1;break}continue}if(E[A]!==M){O=!1;break}}if(!O)continue}h[w]=E}let v=new Set(Object.keys(h)),m=[];for(let[w,p]of d)if(p instanceof F)for(let _ of p._deps){let k=u.get(_.node);k!=null&&m.push([k,w])}m.sort((w,p)=>w[0]<p[0]?-1:w[0]>p[0]?1:w[1]<p[1]?-1:w[1]>p[1]?1:0);let c=m.map(([w,p])=>({from:w,to:p}));(n!=null||r!=null)&&(c=c.filter(w=>v.has(w.from)&&v.has(w.to)));let b=this._collectSubgraphs(""),f=n!=null||r!=null?b.filter(w=>{let p=`${w}${G}`;return[...v].some(_=>_===w||_.startsWith(p))}):b,x=this,g=e;return{name:this.name,nodes:h,edges:c,subgraphs:f,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(w){let p={...g};return Array.isArray(w)?(p.fields=w,p.detail=void 0):(p.detail=w,p.fields=void 0),x.describe(p)}}}_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}${G}`))}return n}resourceProfile(e){return fn(this,e)}reachable(e,n,r={}){return r.withDetail===!0?vn(this.describe(),e,n,{...r,withDetail:!0}):vn(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(ie(e),ie(n),{...r?.maxDepth!==void 0?{maxDepth:gn(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:mn(r.findCycle)}:{}})}_explainStatic(e,n,r){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,u]of Object.entries(s.nodes))u.lastMutation!=null&&i.set(a,u.lastMutation);return sn(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=P(s,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,l=()=>{a||u||(a=!0,me(()=>{a=!1,!u&&(s+=1,o.emit(s))}))},d=i.onEvent(g=>{let y=g.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||l()}),h=[],v=new WeakSet,m=g=>{if(v.has(g)||u)return;v.add(g);let y=g.topology.subscribe(w=>{for(let p of w){if(p[0]!==B)continue;let _=p[1];if(l(),_.kind==="added"&&_.nodeKind==="mount"){let k=g._mounts.get(_.name);k!=null&&m(k)}}});h.push(y);for(let w of g._mounts.keys()){let p=g._mounts.get(w);p!=null&&m(p)}};m(this);let c,b=e.actor;xn(b)&&(c=b.subscribe(g=>{let y=!1,w=!1;for(let p of g){let _=p[0];_===B?y=!0:(_===V||_===L||_===H)&&(w=!0)}y&&l(),w&&(c?.(),c=void 0,l())}));let f;try{f=q([o],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(g,y)=>g===y})}catch(g){d(),c?.();for(let y of h)y();throw i.dispose(),g}let x=Le(f);return{node:f,dispose(){u=!0,d(),c?.();for(let g of h)g();h.length=0,i.dispose(),x()}}}_describeReactiveDiff(e){let n={...e,reactive:!1},r=e.reactiveName??"describe-diff",s={name:this.name,nodes:{},edges:[],subgraphs:[]},o=this.describe(n),i=_t(s,o),a=P(i,{name:r,meta:{domain:"audit",kind:"describe-diff"},equals:(v,m)=>v===m}),u=this._describeReactive({...e,reactiveName:void 0}),l=!1,d=u.node.subscribe(v=>{if(!l)for(let m of v){if(m[0]!==B)continue;let c=m[1],b=_t(o,c);o=c,b.events.length!==0&&a.emit(b)}}),h=Le(a);return{node:a,dispose(){l=!0,d(),u.dispose(),a.down([[H,"describe-diff disposed"]]),h()}}}_explainReactive(e,n,r){let s=0,o=P(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,l=()=>{a||u||(a=!0,me(()=>{a=!1,!u&&(s+=1,o.emit(s))}))},d=i.onEvent(g=>{let y=g.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||l()}),h=[];e!=null&&ce(e)&&h.push(e),n!=null&&ce(n)&&h.push(n),r?.maxDepth!=null&&ce(r.maxDepth)&&h.push(r.maxDepth),r?.findCycle!=null&&ce(r.findCycle)&&h.push(r.findCycle);let v=()=>{for(let g of h)if(g.cache===void 0)return!1;return!0},m=()=>{let g=ie(e),y=ie(n);return{from:g,to:y,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:g,to:y,found:!1,reason:"pending",steps:[]})}},c;try{c=q([o],()=>{if(!v())return m();let g=ie(e),y=ie(n),w={...r?.maxDepth!==void 0?{maxDepth:gn(r.maxDepth)}:{},...r?.findCycle!==void 0?{findCycle:mn(r.findCycle)}:{}};return this._explainStatic(g,y,w)},{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:ie(e),to:ie(n)},equals:(g,y)=>g.found===y.found&&g.reason===y.reason&&g.steps.length===y.steps.length&&gr(g.steps,y.steps)})}catch(g){throw d(),i.dispose(),g}let b=Le(c),f=[],x=g=>{let y;return y=g.subscribe(w=>{let p=!1,_=!1;for(let k of w){let N=k[0];N===B?p=!0:(N===V||N===L||N===H)&&(_=!0)}(p||_)&&l(),_&&y&&(y(),y=void 0)}),()=>{y&&(y(),y=void 0)}};for(let g of h)f.push(x(g));return{node:c,dispose(){u=!0,d();for(let g of f)g?.();f.length=0,i.dispose(),b()}}}_pathsMatching(e){let n=He(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}${G}${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}${G}${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}${G}${J}${G}${s}`;r.push([i,o]),this._appendMetaObserveTargets(i,o,r)}}observe(e,n){let r=typeof e=="string",o=yn(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 d=e,h=this.resolve(d);if(a!=null&&!h.allowsObserve(a))throw new K({actor:a,action:"observe",nodeName:d});return i?this._buildStructuredObserver([[d,h]],o,"one"):{subscribe(v){return h.subscribe(v)},up(v){try{h.up?.(v)}catch(m){if(m instanceof K)return;throw m}}}}let u=[];this._collectObserveTargets("",u),u.sort((d,h)=>d[0]<h[0]?-1:d[0]>h[0]?1:0);let l=a==null?u:u.filter(([,d])=>d.allowsObserve(a));return i?this._buildStructuredObserver(l,o,"all"):{subscribe:d=>{let h=l.map(([v,m])=>m.subscribe(c=>{d(v,c)}));return()=>{for(let v of h)v()}},up:(d,h)=>{try{this.resolve(d).up?.(h)}catch(v){if(v instanceof K)return;throw v}}}}_observeReactive(e,n){let r=n.tiers,s=r!=null?new Set(r):null,o=n.reactiveName??"observe";return yt(i=>{let a=[],u=!1,l=!1,d=()=>{if(a.length===0||l)return;let b={events:a.slice(),flushedAt_ns:j()};a.length=0,i.emit(b)},h={...n,reactive:!1,structured:!0,timeline:!0},v=e!=null?this.observe(e,h):this.observe(h),m=b=>{l||(a.push(b),!u&&(u=!0,me(()=>{u=!1,d()})))};for(let b of v.events)m(b);let c=v.onEvent(m);return()=>{l=!0,c(),v.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 d=this.resolve(s);return this._buildStructuredObserver([[s,d]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((d,h)=>d[0]<h[0]?-1:d[0]>h[0]?1:0);let u=i.actor,l=u==null?a:a.filter(([,d])=>d.allowsObserve(u));return this._buildStructuredObserver(l,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",u=this.config.inspectorEnabled,l=(o||i)&&u,d=n.maxEvents,h=d!=null&&d>0?new Se(d):null,v=[],m=new Set,c=n.tiers!=null?new Set(n.tiers):null,b={},f=new Set,x=0,g=0,y=0,w=0,p=0,_=0,k=!1,N=!1,T=0,E=new Map,O=new Map,C=new Map,M=S=>{if(!(c!=null&&!c.has(S.type))){h?h.push(S):v.push(S);for(let D of m)D(S)}},A=S=>c==null||c.has(S),fe=()=>s?{timestamp_ns:j(),in_batch:Me(),batch_id:T}:{},Ue=(S,D)=>{if(!(!l||!(S instanceof F)))return S._setInspectorHook(z=>{if(z.kind==="dep_message")E.set(S,z.depIndex);else if(z.kind==="run"){let we=z.batchData.map((R,W)=>R!=null&&R.length>0?R.at(-1):z.prevData[W]);O.set(S,we);let U=z.batchData.map(R=>R!=null?[...R]:void 0);C.set(S,U),i&&M({type:"derived",path:D,dep_values:we,dep_batches:U,...fe()})}})},Ee=S=>{let D=E.get(S),z=O.get(S);if(!o||z==null)return{};let U=(D!=null&&D>=0&&S instanceof F?S._deps[D]:void 0)?.node,R=U?.v,W=C.get(S);return{trigger_dep_index:D,trigger_dep_name:U?.name,...R!=null?{trigger_version:{id:R.id,version:R.version}}:{},dep_values:[...z],...W!=null?{dep_batches:W}:{}}},Ct=[],Rt=[];for(let[S,D]of e){let z=Ue(D,S);z&&Ct.push(z),Rt.push(D.subscribe(we=>{T++;for(let U of we){let R=U[0],W=fe();if(R===B){b[S]=U[1];let Je=D instanceof F?D.lastMutation?.actor??he:he;M({type:"data",path:S,data:U[1],actor:Je,...W,...Ee(D)})}else if(a)R===Z?A("dirty")&&x++:R===Q?A("resolved")&&g++:R===Y?A("invalidate")&&y++:R===ee?A("pause")&&w++:R===se?A("resume")&&p++:R===H?A("teardown")&&_++:R===V&&!f.has(S)?A("complete")&&(k=!0):R===L&&A("error")&&(N=!0,f.add(S));else if(R===Z)A("dirty")&&x++,M({type:"dirty",path:S,...W});else if(R===Q)A("resolved")&&g++,M({type:"resolved",path:S,...W,...Ee(D)});else if(R===Y)A("invalidate")&&y++,M({type:"invalidate",path:S,...W});else if(R===ee)A("pause")&&w++,M({type:"pause",path:S,lockId:U[1],...W});else if(R===se)A("resume")&&p++,M({type:"resume",path:S,lockId:U[1],...W});else if(R===V)A("complete")&&!f.has(S)&&(k=!0),M({type:"complete",path:S,...W});else if(R===L){A("error")&&(N=!0,f.add(S));let Je=D instanceof F?D.lastMutation?.actor??he:he;M({type:"error",path:S,data:U[1],actor:Je,...W})}else R===H&&(A("teardown")&&_++,M({type:"teardown",path:S,...W}))}}))}let Ke=!1,qe=()=>{if(!Ke){Ke=!0;for(let S of Rt)S();for(let S of Ct)S();for(let S of Ce)S({value:void 0,done:!0});Ce.length=0}},Ye=[],Ce=[];m.add(S=>{let D=Ce.shift();D?D({value:S,done:!1}):Ye.push(S)});let At={get values(){return b},get dirtyCount(){return x},get resolvedCount(){return g},get invalidateCount(){return y},get pauseCount(){return w},get resumeCount(){return p},get teardownCount(){return _},get events(){return h?h.toArray():[...v]},get anyCompletedCleanly(){return k},get anyErrored(){return N},get completedWithoutErrors(){return k&&!N},onEvent(S){return m.add(S),()=>m.delete(S)},dispose:qe,expand(S){qe();let D={...n};return typeof S=="string"?D.detail=S:Object.assign(D,S),r(yn(D))},[Symbol.asyncIterator](){return{next(){return Ye.length>0?Promise.resolve({value:Ye.shift(),done:!1}):Ke?Promise.resolve({value:void 0,done:!0}):new Promise(S=>Ce.push(S))},return(){return qe(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(At,n),At}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let s=n.logger??(c=>console.log(c)),o=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=o==null&&i==null?()=>!0:c=>(o==null||o.has(c))&&(i==null||!i.has(c)),u=dr(n.theme),l=r==="stage-log"?j():0,d=c=>c==null?"":n.stageLabels?.[c]??c,h=(c,b)=>c.length>b?`${c.slice(0,b-1)}\u2026`:c,v=c=>c.type==="data"||c.type==="error"?h(kt(c.data),120):"",m=c=>{if(r==="stage-log"){let k=(j()-l)/1e9,N=d(c.path).padEnd(9);if(c.type==="data"){let T=v(c);return`[${k.toFixed(3)}s] ${N} \u2190${T?` ${T}`:""}`}if(c.type==="error"){let T=v(c);return`[${k.toFixed(3)}s] ${N} \u2717${T?` ${T}`:""}`}return c.type==="complete"?`[${k.toFixed(3)}s] ${N} \u25A0 complete`:`[${k.toFixed(3)}s] ${N} ${c.type}`}if(r==="json")try{return JSON.stringify(c)}catch{return JSON.stringify({type:c.type,path:c.path,data:"[unserializable]"})}let b=u[c.type]??"",f=c.path?`${u.path}${c.path}${u.reset} `:"",x=c.type==="data"||c.type==="error",g=c.type==="pause"||c.type==="resume",y=x?` ${kt(c.data)}`:g?` ${kt(c.lockId)}`:"",w=c.type==="data"||c.type==="resolved"||c.type==="derived"?c:void 0,p=w?.trigger_dep_name!=null?` <- ${w.trigger_dep_name}`:w?.trigger_dep_index!=null?` <- #${w.trigger_dep_index}`:"",_=c.in_batch?" [batch]":"";return`${f}${b}${c.type.toUpperCase()}${u.reset}${y}${p}${_}`};e.onEvent(c=>{a(c.type)&&s(m(c),c)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){pn(this._disposers,this.name),this.signal([[H]],{internal:!0}),pn(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:u,guard:l,...d}=r.nodes[a];s[a]=d}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 Pt(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??oe,{codec:s,codecVersion:o,payload:i}=It(e,r);return s.decode(i,o)}restore(e,n){if(bn(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=>He(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 u=this.tryResolve(o)?.v;if(u!=null&&u.id===i.v.id&&u.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){n?.onError?.(o,a)}}}}}static fromSnapshot(e,n){bn(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 m of[...e.subgraphs].sort((c,b)=>{let f=c.split(G).length,x=b.split(G).length;return f!==x?f-x:c<b?-1:c>b?1:0})){let c=m.split(G),b=o;for(let f of c)b._mounts.has(f)||b.mount(f,new t(f)),b=b._mounts.get(f)}let i=s?Object.entries(s).map(([m,c])=>({re:He(m),factory:c})):[],a=m=>{for(let c of i)if(c.re.test(m))return c.factory},u=m=>{let c=m.split(G),b=c.pop();if(b==null||b.length===0)throw new Error(`invalid snapshot path "${m}"`);let f=o;for(let x of c){let g=f._mounts.get(x);if(!g)throw new Error(`unknown mount "${x}" in path "${m}"`);f=g}return[f,b]},l=Object.entries(e.nodes).filter(([m])=>!m.includes(`${G}${J}${G}`)).sort((m,c)=>m[0]<c[0]?-1:m[0]>c[0]?1:0),d=new Map(l),h=new Map,v=!0;for(;d.size>0&&v;){v=!1;for(let[m,c]of[...d.entries()]){let b=c?.deps??[];if(!b.every(p=>h.has(p)))continue;let[f,x]=u(m),g={...c?.meta??{}},y=a(m),w;if(c?.type==="state")w=P(c.value,{meta:g});else{if(y==null)continue;w=y(x,{path:m,type:c.type,value:c.value,meta:g,deps:b,resolvedDeps:b.map(p=>h.get(p))})}f.add(w,{name:x}),h.set(m,w),d.delete(m),v=!0}}if(d.size>0){let m=[...d.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${m}. 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(l=>({tier:l,debounceMs:Math.max(0,l.debounceMs??0),compactEvery:Math.max(1,l.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=(l,d)=>{if(l.disposed)return;let h=or(d.nodes);if(l.lastSnapshot!=null&&h!==""&&h===l.lastFingerprint)return;let v=l.seq+1,m=Re(),f=l.lastSnapshot==null||v%l.compactEvery===0?{name:this.name,mode:"full",snapshot:d,seq:v,timestamp_ns:m,format_version:ve}:{name:this.name,mode:"diff",diff:pr(l.lastSnapshot,d),seq:v,timestamp_ns:m,format_version:ve};if(l.tier.filter&&!l.tier.filter(f))return;let x;try{x=l.tier.save(f)}catch(g){n.onError?.(g,l.tier);return}if(x&&typeof x.then=="function"){let w=(l.savePending??Promise.resolve()).then(()=>x,()=>x).then(()=>{l.disposed||(l.seq=v,l.lastSnapshot=d,l.lastFingerprint=h)},p=>{n.onError?.(p,l.tier)});l.savePending=w.finally(()=>{l.savePending===w&&(l.savePending=void 0)})}else l.seq=v,l.lastSnapshot=d,l.lastFingerprint=h},o=(l,d)=>{try{s(l,d)}catch(h){n.onError?.(h,l.tier)}},i=(l,d)=>{if(!d.some(c=>{let b=this.config.messageTier(c[0]);return b>=3&&b<5}))return;if(n.filter){let c=this.tryResolve(l);if(c==null)return;let b=xt(c,vt("standard"));if(!n.filter(l,b))return}let v,m=()=>(v==null&&(v=this.snapshot()),v);for(let c of r)c.disposed||(c.debounceMs===0?o(c,m()):(c.timer==null&&(c.timer=new Fe),c.timer.start(c.debounceMs,()=>{c.disposed||o(c,this.snapshot())})))},a;if(n.paths!=null){let d=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(h=>{let v=this.tryResolve(h);return v==null?()=>{}:v.subscribe(m=>i(h,m))});a=()=>{for(let h of d)h()}}else a=this.observe().subscribe((l,d)=>i(l,d));let u=()=>{a();for(let l of r)l.disposed=!0,l.timer?.cancel();this._storageDisposers.delete(u)};return this._storageDisposers.add(u),{dispose:u}}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===ve&&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(u){r?.onError?.(u,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===ve&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(u){r?.onError?.(u,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:j(),...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(g=>!r.has(g)).sort(),i=[...r].filter(g=>!s.has(g)).sort(),a=[],u=[];for(let g of r){if(!s.has(g))continue;let y=e.nodes[g],w=n.nodes[g],p=y.v,_=w.v;p!=null&&_!=null&&p.id===_.id&&p.version!==_.version&&u.push({path:g,id:p.id,from:p.version,to:_.version});let k=p!=null&&_!=null&&p.id===_.id&&p.version===_.version;for(let N of["type","status","sentinel"]){let T=y[N],E=w[N];T!==E&&a.push({path:g,field:N,from:T,to:E})}if(!k)for(let N of["value","meta"]){let T=y[N],E=w[N];ir(T,E)||a.push({path:g,field:N,from:T,to:E})}}let l=g=>`${g.from} ${g.to}`,d=new Set(e.edges.map(l)),h=new Set(n.edges.map(l)),v=n.edges.filter(g=>!d.has(l(g))),m=e.edges.filter(g=>!h.has(l(g))),c=new Set(e.subgraphs),b=new Set(n.subgraphs),f=[...b].filter(g=>!c.has(g)).sort(),x=[...c].filter(g=>!b.has(g)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:u,edgesAdded:v,edgesRemoved:m,subgraphsAdded:f,subgraphsRemoved:x}}}});var Tr={};Gn(Tr,{CanvasMeasureAdapter:()=>tt,CliMeasureAdapter:()=>Ze,ImageSizeAdapter:()=>st,NodeCanvasMeasureAdapter:()=>nt,PrecomputedAdapter:()=>et,SvgBoundsAdapter:()=>rt,analyzeAndMeasure:()=>xe,carveTextLineSlots:()=>Et,circleIntervalForBand:()=>En,computeBlockFlow:()=>Tn,computeCharPositions:()=>ze,computeFlowLines:()=>Rn,computeLineBreaks:()=>Ve,computeTotalHeight:()=>Sn,layoutNextLine:()=>St,measureBlock:()=>Nn,measureBlocks:()=>On,reactiveBlockLayout:()=>kr,reactiveFlowLayout:()=>Or,reactiveLayout:()=>_r,rectIntervalForBand:()=>Cn});module.exports=In(Tr);Dt();var Ze=class{cellPx;constructor(e){this.cellPx=e?.cellPx??8}measureSegment(e,n){return{width:Mt(e)*this.cellPx}}},Qe=class extends Error{name="KeyError"},et=class{metrics;fallback;constructor(e){this.metrics=e.metrics;let n=e.fallback??"per-char";if(n!=="per-char"&&n!=="error")throw new Error(`fallback must be 'per-char' or 'error', got ${JSON.stringify(e.fallback)}`);this.fallback=n}measureSegment(e,n){let r=this.metrics[n];if(r){let o=r[e];if(o!==void 0)return{width:o}}if(this.fallback==="error")throw new Qe(`PrecomputedAdapter: no metrics for segment ${JSON.stringify(e)} in font ${JSON.stringify(n)}`);let s=0;if(r)for(let o of e){let i=r[o];i!==void 0&&(s+=i)}return{width:s}}},tt=class{ctx=null;currentFont="";emojiCorrection;constructor(e){this.emojiCorrection=e?.emojiCorrection??1}getContext(){if(!this.ctx){if(typeof OffscreenCanvas>"u")throw new Error("CanvasMeasureAdapter requires a browser environment with OffscreenCanvas support. Use CliMeasureAdapter or NodeCanvasMeasureAdapter for Node.js.");let n=new OffscreenCanvas(0,0).getContext("2d");if(!n)throw new Error("CanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(e,n){let r=this.getContext();n!==this.currentFont&&(r.font=n,this.currentFont=n);let s=r.measureText(e).width;return this.emojiCorrection!==1&&new RegExp("\\p{Emoji_Presentation}","u").test(e)&&(s*=this.emojiCorrection),{width:s}}clearCache(){this.currentFont=""}},nt=class{ctx=null;currentFont="";canvasModule;constructor(e){this.canvasModule=e}getContext(){if(!this.ctx){let n=this.canvasModule.createCanvas(0,0).getContext("2d");if(!n)throw new Error("NodeCanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(e,n){let r=this.getContext();return n!==this.currentFont&&(r.font=n,this.currentFont=n),{width:r.measureText(e).width}}clearCache(){this.currentFont=""}},rt=class{measureSvg(e){let n=e.match(/viewBox\s*=\s*["']([^"']+)["']/);if(n){let o=n[1].trim().split(/[\s,]+/);if(o.length>=4){let i=Number.parseFloat(o[2]),a=Number.parseFloat(o[3]);if(Number.isFinite(i)&&Number.isFinite(a)&&i>0&&a>0)return{width:i,height:a};throw new Error("SvgBoundsAdapter: viewBox width/height are missing, non-finite, or not positive")}}let r=e.match(/<svg[^>]*\bwidth\s*=\s*["']?([\d.]+)/),s=e.match(/<svg[^>]*\bheight\s*=\s*["']?([\d.]+)/);if(r&&s){let o=Number.parseFloat(r[1]),i=Number.parseFloat(s[1]);if(Number.isFinite(o)&&Number.isFinite(i)&&o>0&&i>0)return{width:o,height:i};throw new Error("SvgBoundsAdapter: svg width/height attributes are non-finite or not positive")}throw new Error("SvgBoundsAdapter: cannot determine dimensions \u2014 SVG has no viewBox or width/height attributes")}},st=class{sizes;constructor(e){this.sizes=new Map(Object.entries(e))}measureImage(e){let n=this.sizes.get(e);if(!n)throw new Error(`ImageSizeAdapter: no dimensions registered for ${JSON.stringify(e)}`);return{width:n.width,height:n.height}}};ue();ne();Te();We();De();Oe();ne();function X(t,e){t!=null&&be(n=>t.down(n),[[B,e]],oe.tierOf)}ue();ne();Te();We();function mr(t){for(let e of t){let n=e.codePointAt(0);if(n>=19968&&n<=40959||n>=13312&&n<=19903||n>=12288&&n<=12351||n>=12352&&n<=12447||n>=12448&&n<=12543||n>=44032&&n<=55215||n>=65280&&n<=65519)return!0}return!1}var _n=new Set(["\uFF0C","\uFF0E","\uFF01","\uFF1A","\uFF1B","\uFF1F","\u3001","\u3002","\u30FB","\uFF09","\u3015","\u3009","\u300B","\u300D","\u300F","\u3011"]),br=new Set([".",",","!","?",":",";",")","]","}","%",'"',"\u201D","\u2019","\xBB","\u203A","\u2026"]);function yr(t){return t.replace(/[\t\n\r\f ]+/g," ").replace(/^ | $/g,"")}function vr(t){let e=new Intl.Segmenter(void 0,{granularity:"word"}),n=[];for(let r of e.segment(t)){let s=r.segment,o=r.isWordLike??!1,i=[],a=[],u=[],l="",d=null;for(let h of s){let v;h===" "?v="space":h==="\u200B"?v="zero-width-break":h==="\xAD"?v="soft-hyphen":h===`
4
+ `?v="hard-break":v="text",d!==null&&v===d?l+=h:(d!==null&&(i.push(l),a.push(d==="text"&&o),u.push(d)),l=h,d=v)}d!==null&&(i.push(l),a.push(d==="text"&&o),u.push(d)),n.push({texts:i,isWordLike:a,kinds:u})}return n}function xe(t,e,n,r,s){let o=yr(t);if(o.length===0)return[];let i=vr(o),a=new Intl.Segmenter(void 0,{granularity:"grapheme"}),u=[],l=[],d=[];for(let x of i)for(let g=0;g<x.texts.length;g++)u.push(x.texts[g]),l.push(x.kinds[g]),d.push(x.isWordLike[g]);let h=[],v=[],m=[];for(let x=0;x<u.length;x++){let g=u[x],y=l[x],w=d[x];if(y==="text"&&!w&&h.length>0&&v[v.length-1]==="text"&&g.length===1&&(br.has(g)||_n.has(g))){h[h.length-1]+=g;continue}if(g==="-"&&h.length>0&&v[v.length-1]==="text"&&m[m.length-1]){h[h.length-1]+=g;continue}h.push(g),v.push(y),m.push(w)}let c=r.get(e);c||(c=new Map,r.set(e,c));function b(x){let g=c.get(x);if(g===void 0){s&&(s.misses+=1);let y=n.measureSegment(x,e).width;g=Number.isFinite(y)&&y>=0?y:0,c.set(x,g)}else s&&(s.hits+=1);return g}let f=[];for(let x=0;x<h.length;x++){let g=h[x],y=v[x];if(y!=="text"){f.push({text:g,width:y==="space"?b(" ")*g.length:0,kind:y,graphemeWidths:null});continue}if(mr(g)){let _="";for(let k of a.segment(g)){let N=k.segment;if(_.length>0&&_n.has(N)){_+=N;continue}if(_.length>0){let T=b(_);f.push({text:_,width:T,kind:"text",graphemeWidths:null})}_=N}if(_.length>0){let k=b(_);f.push({text:_,width:k,kind:"text",graphemeWidths:null})}continue}let w=b(g),p=null;if(m[x]&&g.length>1){let _=[];for(let k of a.segment(g))_.push(b(k.segment));_.length>1&&(p=_)}f.push({text:g,width:w,kind:"text",graphemeWidths:p})}return f}function Ve(t,e,n,r,s){if(t.length===0)return{lines:[],lineCount:0};let o=[],i=0,a=!1,u=0,l=0,d=0,h=0,v=-1,m=0,c=s.get(r);c||(c=new Map,s.set(r,c));let b=c.get("-");b===void 0&&(b=n.measureSegment("-",r).width,c.set("-",b));function f(p=d,_=h,k=i){let N="";for(let T=u;T<p;T++){let E=t[T];if(!(E.kind==="soft-hyphen"||E.kind==="hard-break"))if(T===u&&l>0&&E.graphemeWidths){let C=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(E.text)].map(M=>M.segment);N+=C.slice(l).join("")}else N+=E.text}if(_>0&&p<t.length){let T=t[p],O=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(T.text)].map(M=>M.segment),C=u===p?l:0;N+=O.slice(C,_).join("")}p>0&&t[p-1]?.kind==="soft-hyphen"&&!(u===p&&l>0)&&(N+="-"),o.push({text:N,width:k,startSegment:u,startGrapheme:l,endSegment:p,endGrapheme:_}),i=0,a=!1,v=-1,m=0}function x(p){return p==="space"||p==="zero-width-break"||p==="soft-hyphen"}function g(p,_,k){a=!0,u=p,l=_,d=p+1,h=0,i=k}function y(p,_,k){a=!0,u=p,l=_,d=p,h=_+1,i=k}for(let p=0;p<t.length;p++){let _=t[p];if(_.kind==="hard-break"){a?f():o.push({text:"",width:0,startSegment:p,startGrapheme:0,endSegment:p,endGrapheme:0}),u=p+1,l=0;continue}let k=_.width;if(!a){k>e&&_.graphemeWidths?w(p,0,_.graphemeWidths):g(p,0,k),x(_.kind)&&(v=p+1,m=_.kind==="space"?i-k:i);continue}let N=i+k;if(N>e+.005){if(x(_.kind)){i+=k,d=p+1,h=0,f(p+1,0,_.kind==="space"?i-k:i);continue}if(v>=0){f(v,0,m),p--;continue}if(k>e&&_.graphemeWidths){f(),w(p,0,_.graphemeWidths);continue}f(),p--;continue}i=N,d=p+1,h=0,x(_.kind)&&(v=p+1,m=_.kind==="space"?i-k:i)}return a&&f(),{lines:o,lineCount:o.length};function w(p,_,k){for(let N=_;N<k.length;N++){let T=k[N];if(!a){y(p,N,T);continue}i+T>e+.005?(f(),y(p,N,T)):(i+=T,d=p,h=N+1)}a&&d===p&&h===k.length&&(d=p+1,h=0)}}function Ot(t){return t==="space"||t==="zero-width-break"||t==="soft-hyphen"}var Tt=null;function xr(){return Tt===null&&(Tt=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Tt}function kn(t,e,n){if(e===0&&n<0)return t.text;let r=[...xr().segment(t.text)].map(o=>o.segment),s=n<0?r.length:n;return r.slice(e,s).join("")}function ae(t,e,n,r,s,o){let i="";for(let a=e;a<r;a++){let u=t[a];u.kind==="soft-hyphen"||u.kind==="hard-break"||(a===e&&n>0?i+=kn(u,n,-1):i+=u.text)}if(s>0&&r<t.length){let a=t[r];i+=kn(a,e===r?n:0,s)}return o&&(i+="-"),i}function wr(t){if(!t?.adapter||!t.font)return 0;let e=t.cache;if(e){let n=e.get(t.font);n||(n=new Map,e.set(t.font,n));let r=n.get("-");return r===void 0&&(r=t.adapter.measureSegment("-",t.font).width,n.set("-",r)),r}return t.adapter.measureSegment("-",t.font).width}function St(t,e,n,r){let s=e.segmentIndex,o=e.graphemeIndex;if(s>=t.length)return null;if(o===0){for(;s<t.length;){let p=t[s];if(p.kind==="hard-break")return{text:"",width:0,start:{segmentIndex:e.segmentIndex,graphemeIndex:0},end:{segmentIndex:s+1,graphemeIndex:0}};if(p.kind==="space"||p.kind==="zero-width-break"||p.kind==="soft-hyphen"){s+=1;continue}break}if(s>=t.length)return null}let i=wr(r),a=s,u=s===e.segmentIndex?o:0,l=0,d=a,h=0,v=!1,m=-1,c=0,b=0,f=!1,x=(p,_,k,N)=>{m=p,c=_,b=k,f=N==="soft-hyphen"},g=(p,_,k)=>{for(let N=_;N<k.length;N++){let T=k[N];if(!v){l=T,d=p,h=N+1,v=!0;continue}if(l+T>n+.005)return!0;l+=T,d=p,h=N+1}return d===p&&h===k.length&&(d=p+1,h=0),!1};if(u>0&&a<t.length){let p=t[a];if(p.graphemeWidths){if(g(a,u,p.graphemeWidths))return{text:ae(t,a,u,d,h,!1),width:l,start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}};s=d}}for(;s<t.length;){let p=t[s];if(p.kind==="hard-break"){if(v){let N=d>0&&t[d-1]?.kind==="soft-hyphen";return{text:ae(t,a,u,d,h,N),width:l+(N?i:0),start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}}}return{text:"",width:0,start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:s+1,graphemeIndex:0}}}let _=p.width;if(!v){if(_>n&&p.graphemeWidths){if(g(s,0,p.graphemeWidths))return{text:ae(t,a,u,d,h,!1),width:l,start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}};s=d;continue}l=_,d=s+1,h=0,v=!0,Ot(p.kind)&&x(s+1,0,p.kind==="space"?l-_:l,p.kind),s+=1;continue}let k=l+_;if(k>n+.005){if(Ot(p.kind)){d=s+1,h=0;let T=p.kind==="soft-hyphen",E=p.kind==="space"?l:l+(T?i:0);return{text:ae(t,a,u,d,h,T),width:E,start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}}}return m>=0?{text:ae(t,a,u,m,c,f),width:b+(f?i:0),start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:m,graphemeIndex:c}}:_>n&&p.graphemeWidths?{text:ae(t,a,u,d,h,!1),width:l,start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}}:{text:ae(t,a,u,d,h,!1),width:l,start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}}}l=k,d=s+1,h=0,Ot(p.kind)&&x(s+1,0,p.kind==="space"?l-_:l,p.kind),s+=1}if(!v)return null;let y=d>0&&t[d-1]?.kind==="soft-hyphen";return{text:ae(t,a,u,d,h,y),width:l+(y?i:0),start:{segmentIndex:a,graphemeIndex:u},end:{segmentIndex:d,graphemeIndex:h}}}function Et(t,e,n=0){let r=[t];for(let s=0;s<e.length;s++){let o=e[s],i=[];for(let a=0;a<r.length;a++){let u=r[a];if(o.right<=u.left||o.left>=u.right){i.push(u);continue}o.left>u.left&&i.push({left:u.left,right:o.left}),o.right<u.right&&i.push({left:o.right,right:u.right})}r=i}return n>0?r.filter(s=>s.right-s.left>=n):r}function ze(t,e,n){let r=[],s=new Intl.Segmenter(void 0,{granularity:"grapheme"});for(let o=0;o<t.lines.length;o++){let i=t.lines[o],a=o*n,u=0;for(let l=i.startSegment;l<e.length;l++){let d=e[l];if(d.kind==="soft-hyphen"||d.kind==="hard-break"){if(l>=i.endSegment&&i.endGrapheme===0)break;continue}let h=[...s.segment(d.text)].map(c=>c.segment);if(h.length===0)continue;let v=l===i.startSegment?i.startGrapheme:0,m;if(l<i.endSegment)m=h.length;else if(l===i.endSegment&&i.endGrapheme>0)m=i.endGrapheme;else break;for(let c=v;c<m;c++){let b=d.graphemeWidths?d.graphemeWidths[c]:d.width/h.length;r.push({x:u,y:a,width:b,height:n,line:o}),u+=b}}}return r}function _r(t){let{adapter:e,name:n="reactive-layout"}=t,r=new re(n),s=new Map,o=P(t.text??"",{name:"text"}),i=P(t.font??"16px sans-serif",{name:"font"}),a=P(t.lineHeight??20,{name:"line-height"}),u=P(Math.max(0,t.maxWidth??800),{name:"max-width"});function l(c,b){if(c===null||b===null)return c===b;if(c.length!==b.length)return!1;for(let f=0;f<c.length;f++)if(c[f]!==b[f])return!1;return!0}let d=te([o,i],(c,b,f)=>{let x=c[0],g=x!=null&&x.length>0?x.at(-1):f.prevData[0],y=c[1],w=y!=null&&y.length>0?y.at(-1):f.prevData[1],p=j(),_={hits:0,misses:0},k=xe(g,w,e,s,_),N=j()-p,T=_.hits+_.misses,E=T===0?1:_.hits/T,O=d.meta;O&&(X(O["cache-hit-rate"],E),X(O["segment-count"],k.length),X(O["layout-time-ns"],N)),b.emit(k);let C=()=>{s.clear(),e.clearCache?.()};return{deactivate:C,invalidate:C}},{name:"segments",describeKind:"derived",meta:{"cache-hit-rate":0,"segment-count":0,"layout-time-ns":0},equals:(c,b)=>{let f=c,x=b;if(f==null||x==null)return f===x;if(f.length!==x.length)return!1;for(let g=0;g<f.length;g++){let y=f[g],w=x[g];if(y.text!==w.text||y.width!==w.width||y.kind!==w.kind||!l(y.graphemeWidths??null,w.graphemeWidths??null))return!1}return!0}}),h=q([d,u,i],([c,b,f])=>Ve(c,b,e,f,s),{name:"line-breaks",equals:(c,b)=>{let f=c,x=b;if(f==null||x==null)return f===x;if(f.lineCount!==x.lineCount)return!1;for(let g=0;g<f.lines.length;g++){let y=f.lines[g],w=x.lines[g];if(y.text!==w.text||y.width!==w.width||y.startSegment!==w.startSegment||y.startGrapheme!==w.startGrapheme||y.endSegment!==w.endSegment||y.endGrapheme!==w.endGrapheme)return!1}return!0}}),v=q([h,a],([c,b])=>c.lineCount*b,{name:"height"}),m=q([h,d,a],([c,b,f])=>ze(c,b,f),{name:"char-positions",equals:(c,b)=>{let f=c,x=b;if(f==null||x==null)return f===x;if(f.length!==x.length)return!1;for(let g=0;g<f.length;g++)if(f[g].x!==x[g].x||f[g].y!==x[g].y||f[g].width!==x[g].width)return!1;return!0}});return r.add(o,{name:"text"}),r.add(i,{name:"font"}),r.add(a,{name:"line-height"}),r.add(u,{name:"max-width"}),r.add(d,{name:"segments"}),r.add(h,{name:"line-breaks"}),r.add(v,{name:"height"}),r.add(m,{name:"char-positions"}),{graph:r,setText:c=>r.set("text",c),setFont:c=>r.set("font",c),setLineHeight:c=>r.set("line-height",c),setMaxWidth:c=>r.set("max-width",Math.max(0,c)),segments:d,lineBreaks:h,height:v,charPositions:m}}function Nn(t,e,n,r,s,o,i){switch(t.type){case"text":{let a=t.font??s,u=t.lineHeight??o,l=xe(t.text,a,n.text,r),d=Ve(l,e,n.text,a,r),h=ze(d,l,u),v=d.lineCount*u,m=0;for(let c of d.lines)c.width>m&&(m=c.width);return{index:i,type:"text",width:Math.min(m,e),height:v,textSegments:l,textLineBreaks:d,textCharPositions:h}}case"image":{let a,u;if(t.naturalWidth!=null&&t.naturalHeight!=null)a=t.naturalWidth,u=t.naturalHeight;else if(n.image){let l=n.image.measureImage(t.src);a=l.width,u=l.height}else throw new Error(`Image block at index ${i} has no naturalWidth/naturalHeight and no ImageMeasurer adapter`);return a>e&&(u=u*e/a,a=e),{index:i,type:"image",width:a,height:u}}case"svg":{let a,u;if(t.viewBox)a=t.viewBox.width,u=t.viewBox.height;else if(n.svg){let l=n.svg.measureSvg(t.content);a=l.width,u=l.height}else throw new Error(`SVG block at index ${i} has no viewBox and no SvgMeasurer adapter`);return a>e&&(u=u*e/a,a=e),{index:i,type:"svg",width:a,height:u}}}}function On(t,e,n,r,s,o){return t.map((i,a)=>Nn(i,e,n,r,s,o,a))}function Tn(t,e){let n=[],r=0;for(let s=0;s<t.length;s++){let o=t[s];n.push({...o,x:0,y:r}),r+=o.height+(s<t.length-1?e:0)}return n}function Sn(t){if(t.length===0)return 0;let e=t[t.length-1];return e.y+e.height}function kr(t){let{adapters:e,name:n="reactive-block-layout",defaultFont:r="16px sans-serif",defaultLineHeight:s=20}=t,o=new re(n),i=new Map,a=P(t.blocks??[],{name:"blocks"}),u=P(Math.max(0,t.maxWidth??800),{name:"max-width"}),l=P(t.gap??0,{name:"gap"}),d=te([a,u],(m,c,b)=>{let f=m[0]!=null&&m[0].length>0?m[0].at(-1):b.prevData[0],x=m[1]!=null&&m[1].length>0?m[1].at(-1):b.prevData[1],g=j(),y=On(f,x,e,i,r,s),w=j()-g,p=d.meta;p&&(X(p["block-count"],y.length),X(p["layout-time-ns"],w)),c.emit(y);let _=()=>{i.clear(),e.text.clearCache?.()};return{deactivate:_,invalidate:_}},{name:"measured-blocks",describeKind:"derived",meta:{"block-count":0,"layout-time-ns":0},equals:(m,c)=>{let b=m,f=c;if(b==null||f==null)return b===f;if(b.length!==f.length)return!1;for(let x=0;x<b.length;x++){let g=b[x],y=f[x];if(g.type!==y.type||g.width!==y.width||g.height!==y.height||g.index!==y.index)return!1}return!0}}),h=q([d,l],([m,c])=>Tn(m,c),{name:"block-flow",equals:(m,c)=>{let b=m,f=c;if(b==null||f==null)return b===f;if(b.length!==f.length)return!1;for(let x=0;x<b.length;x++){let g=b[x],y=f[x];if(g.x!==y.x||g.y!==y.y||g.width!==y.width||g.height!==y.height)return!1}return!0}}),v=q([h],([m])=>Sn(m),{name:"total-height"});return o.add(a,{name:"blocks"}),o.add(u,{name:"max-width"}),o.add(l,{name:"gap"}),o.add(d,{name:"measured-blocks"}),o.add(h,{name:"block-flow"}),o.add(v,{name:"total-height"}),{graph:o,setBlocks:m=>o.set("blocks",m),setMaxWidth:m=>o.set("max-width",Math.max(0,m)),setGap:m=>o.set("gap",m),measuredBlocks:d,blockFlow:h,totalHeight:v}}ue();ne();Te();We();function En(t,e,n){let r=t.hPad??0,s=t.vPad??0,o=e-s,i=n+s;if(o>=t.cy+t.r||i<=t.cy-t.r)return null;let a=t.cy>=o&&t.cy<=i?0:t.cy<o?o-t.cy:t.cy-i;if(a>=t.r)return null;let u=Math.sqrt(t.r*t.r-a*a);return{left:t.cx-u-r,right:t.cx+u+r}}function Cn(t,e,n){let r=t.hPad??0,s=t.vPad??0;return n<=t.y-s||e>=t.y+t.h+s?null:{left:t.x-r,right:t.x+t.w+r}}function Nr(t,e,n){return t.kind==="circle"?En(t,e,n):Cn(t,e,n)}function Rn(t,e,n,r,s,o,i){let a=i?.paragraphSpacing??s,u=[],l={segmentIndex:0,graphemeIndex:0};if(t.length===0||n.count<=0||s<=0)return{lines:u,cursor:l};let d=e.paddingX??0,h=e.paddingY??0,v=Math.max(0,e.width-d*2),m=Math.max(0,e.height-h*2),c=n.gap*Math.max(0,n.count-1),b=Math.max(0,(v-c)/n.count);if(b<=0)return{lines:u,cursor:l};e:for(let f=0;f<n.count;f++){let x=d+f*(b+n.gap),g=x+b,y=h;for(;y+s<=h+m;){let w=y+s,p=[];for(let N=0;N<r.length;N++){let T=Nr(r[N],y,w);T!==null&&p.push(T)}let _=Et({left:x,right:g},p,o);if(_.length===0){y+=s;continue}let k=!1;for(let N=0;N<_.length;N++){let T=_[N],E=T.right-T.left,O=St(t,l,E);if(O===null)return{lines:u,cursor:l};if(O.text.length===0&&O.width===0){l=O.end,k=!0;break}u.push({x:T.left,y,width:O.width,slotWidth:E,text:O.text,columnIndex:f,flushToRight:T.right<g-.5}),l=O.end}if(k){y+=a;continue}if(y+=s,l.segmentIndex>=t.length)break e}if(l.segmentIndex>=t.length)break}return{lines:u,cursor:l}}function Or(t){let{adapter:e,name:n="reactive-flow-layout",minSlotWidth:r=20}=t,s=new re(n),o=new Map,i=P(t.text??"",{name:"text"}),a=P(t.font??"16px sans-serif",{name:"font"}),u=P(t.lineHeight??20,{name:"line-height"}),l=P(t.container??{width:800,height:600,paddingX:0,paddingY:0},{name:"container"}),d=P(t.columns??{count:1,gap:0},{name:"columns"}),h=P(t.obstacles??[],{name:"obstacles"}),v=P(t.paragraphSpacing??null,{name:"paragraph-spacing"}),m=te([i,a],(b,f,x)=>{let g=b[0],y=g!=null&&g.length>0?g.at(-1):x.prevData[0],w=b[1],p=w!=null&&w.length>0?w.at(-1):x.prevData[1],_=xe(y,p,e,o);f.emit(_);let k=()=>{o.clear(),e.clearCache?.()};return{deactivate:k,invalidate:k}},{name:"segments",describeKind:"derived"}),c=q([m,l,d,h,u,v],([b,f,x,g,y,w])=>{let p=b,_=j(),k=w??y,{lines:N,cursor:T}=Rn(p,f,x,g,y,r,{paragraphSpacing:k}),E=j()-_,O=Math.max(0,p.length-T.segmentIndex),C=c.meta;return C&&(X(C["line-count"],N.length),X(C["layout-time-ns"],E),X(C["overflow-segments"],O)),N},{name:"flow-lines",meta:{"line-count":0,"layout-time-ns":0,"overflow-segments":0},equals:(b,f)=>{let x=b,g=f;if(x.length!==g.length)return!1;for(let y=0;y<x.length;y++){let w=x[y],p=g[y];if(w.x!==p.x||w.y!==p.y||w.width!==p.width||w.slotWidth!==p.slotWidth||w.text!==p.text||w.columnIndex!==p.columnIndex||w.flushToRight!==p.flushToRight)return!1}return!0}});return s.add(i,{name:"text"}),s.add(a,{name:"font"}),s.add(u,{name:"line-height"}),s.add(l,{name:"container"}),s.add(d,{name:"columns"}),s.add(h,{name:"obstacles"}),s.add(v,{name:"paragraph-spacing"}),s.add(m,{name:"segments"}),s.add(c,{name:"flow-lines"}),{graph:s,setText:b=>s.set("text",b),setFont:b=>s.set("font",b),setLineHeight:b=>s.set("line-height",b),setContainer:b=>s.set("container",b),setColumns:b=>s.set("columns",b),setObstacles:b=>s.set("obstacles",b),setParagraphSpacing:b=>s.set("paragraph-spacing",b),segments:m,flowLines:c}}0&&(module.exports={CanvasMeasureAdapter,CliMeasureAdapter,ImageSizeAdapter,NodeCanvasMeasureAdapter,PrecomputedAdapter,SvgBoundsAdapter,analyzeAndMeasure,carveTextLineSlots,circleIntervalForBand,computeBlockFlow,computeCharPositions,computeFlowLines,computeLineBreaks,computeTotalHeight,layoutNextLine,measureBlock,measureBlocks,reactiveBlockLayout,reactiveFlowLayout,reactiveLayout,rectIntervalForBand});
@@ -1,7 +1,7 @@
1
- export { B as BlockAdapters, C as CanvasMeasureAdapter, a as CanvasMeasureAdapterOptions, b as CanvasModule, c as CircleObstacle, d as CliMeasureAdapter, e as CliMeasureAdapterOptions, f as ComputeFlowLinesOptions, g as ContentBlock, F as FlowColumns, h as FlowContainer, j as FlowLinesResult, I as ImageMeasurer, k as ImageSizeAdapter, M as MeasuredBlock, N as NodeCanvasMeasureAdapter, O as Obstacle, P as PositionedBlock, l as PositionedLine, m as PrecomputedAdapter, n as PrecomputedAdapterOptions, R as ReactiveBlockLayoutBundle, o as ReactiveBlockLayoutOptions, p as ReactiveFlowLayoutBundle, q as ReactiveFlowLayoutOptions, r as RectObstacle, S as SvgBoundsAdapter, s as SvgMeasurer, t as circleIntervalForBand, u as computeBlockFlow, v as computeFlowLines, w as computeTotalHeight, x as measureBlock, y as measureBlocks, z as reactiveBlockLayout, A as reactiveFlowLayout, D as rectIntervalForBand } from '../../index-BiHUBEKq.cjs';
2
- export { C as CharPosition, I as Interval, a as LayoutCursor, b as LayoutLine, c as LayoutNextLineContext, d as LayoutNextLineResult, L as LineBreaksResult, M as MeasurementAdapter, P as PreparedSegment, R as ReactiveLayoutBundle, e as ReactiveLayoutOptions, S as SegmentBreakKind, f as SegmentMeasureStats, g as analyzeAndMeasure, h as carveTextLineSlots, i as computeCharPositions, j as computeLineBreaks, l as layoutNextLine, r as reactiveLayout } from '../../reactive-layout-BtZfUKuL.cjs';
3
- import '../../node-BYInONRr.cjs';
4
- import '../../graph-E6likq7w.cjs';
5
- import '../../meta-Ct9nqQS5.cjs';
1
+ export { B as BlockAdapters, C as CanvasMeasureAdapter, a as CanvasMeasureAdapterOptions, b as CanvasModule, c as CircleObstacle, d as CliMeasureAdapter, e as CliMeasureAdapterOptions, f as ComputeFlowLinesOptions, g as ContentBlock, F as FlowColumns, h as FlowContainer, j as FlowLinesResult, I as ImageMeasurer, k as ImageSizeAdapter, M as MeasuredBlock, N as NodeCanvasMeasureAdapter, O as Obstacle, P as PositionedBlock, l as PositionedLine, m as PrecomputedAdapter, n as PrecomputedAdapterOptions, R as ReactiveBlockLayoutBundle, o as ReactiveBlockLayoutOptions, p as ReactiveFlowLayoutBundle, q as ReactiveFlowLayoutOptions, r as RectObstacle, S as SvgBoundsAdapter, s as SvgMeasurer, t as circleIntervalForBand, u as computeBlockFlow, v as computeFlowLines, w as computeTotalHeight, x as measureBlock, y as measureBlocks, z as reactiveBlockLayout, A as reactiveFlowLayout, D as rectIntervalForBand } from '../../index-BdGtBX-X.cjs';
2
+ export { C as CharPosition, I as Interval, a as LayoutCursor, b as LayoutLine, c as LayoutNextLineContext, d as LayoutNextLineResult, L as LineBreaksResult, M as MeasurementAdapter, P as PreparedSegment, R as ReactiveLayoutBundle, e as ReactiveLayoutOptions, S as SegmentBreakKind, f as SegmentMeasureStats, g as analyzeAndMeasure, h as carveTextLineSlots, i as computeCharPositions, j as computeLineBreaks, l as layoutNextLine, r as reactiveLayout } from '../../reactive-layout-Dsvob4zD.cjs';
3
+ import '../../node-ClS5yC-B.cjs';
4
+ import '../../graph-C4SHb3Ly.cjs';
5
+ import '../../meta-vE8bxW1E.cjs';
6
6
  import '../../extra/storage-core.cjs';
7
7
  import '../../extra/storage-tiers.cjs';
@@ -1,7 +1,7 @@
1
- export { B as BlockAdapters, C as CanvasMeasureAdapter, a as CanvasMeasureAdapterOptions, b as CanvasModule, c as CircleObstacle, d as CliMeasureAdapter, e as CliMeasureAdapterOptions, f as ComputeFlowLinesOptions, g as ContentBlock, F as FlowColumns, h as FlowContainer, j as FlowLinesResult, I as ImageMeasurer, k as ImageSizeAdapter, M as MeasuredBlock, N as NodeCanvasMeasureAdapter, O as Obstacle, P as PositionedBlock, l as PositionedLine, m as PrecomputedAdapter, n as PrecomputedAdapterOptions, R as ReactiveBlockLayoutBundle, o as ReactiveBlockLayoutOptions, p as ReactiveFlowLayoutBundle, q as ReactiveFlowLayoutOptions, r as RectObstacle, S as SvgBoundsAdapter, s as SvgMeasurer, t as circleIntervalForBand, u as computeBlockFlow, v as computeFlowLines, w as computeTotalHeight, x as measureBlock, y as measureBlocks, z as reactiveBlockLayout, A as reactiveFlowLayout, D as rectIntervalForBand } from '../../index-3k4Gg6-n.js';
2
- export { C as CharPosition, I as Interval, a as LayoutCursor, b as LayoutLine, c as LayoutNextLineContext, d as LayoutNextLineResult, L as LineBreaksResult, M as MeasurementAdapter, P as PreparedSegment, R as ReactiveLayoutBundle, e as ReactiveLayoutOptions, S as SegmentBreakKind, f as SegmentMeasureStats, g as analyzeAndMeasure, h as carveTextLineSlots, i as computeCharPositions, j as computeLineBreaks, l as layoutNextLine, r as reactiveLayout } from '../../reactive-layout-KJj4E2dT.js';
3
- import '../../node-BYInONRr.js';
4
- import '../../graph-BkIkog4h.js';
5
- import '../../meta-D8OyedKp.js';
1
+ export { B as BlockAdapters, C as CanvasMeasureAdapter, a as CanvasMeasureAdapterOptions, b as CanvasModule, c as CircleObstacle, d as CliMeasureAdapter, e as CliMeasureAdapterOptions, f as ComputeFlowLinesOptions, g as ContentBlock, F as FlowColumns, h as FlowContainer, j as FlowLinesResult, I as ImageMeasurer, k as ImageSizeAdapter, M as MeasuredBlock, N as NodeCanvasMeasureAdapter, O as Obstacle, P as PositionedBlock, l as PositionedLine, m as PrecomputedAdapter, n as PrecomputedAdapterOptions, R as ReactiveBlockLayoutBundle, o as ReactiveBlockLayoutOptions, p as ReactiveFlowLayoutBundle, q as ReactiveFlowLayoutOptions, r as RectObstacle, S as SvgBoundsAdapter, s as SvgMeasurer, t as circleIntervalForBand, u as computeBlockFlow, v as computeFlowLines, w as computeTotalHeight, x as measureBlock, y as measureBlocks, z as reactiveBlockLayout, A as reactiveFlowLayout, D as rectIntervalForBand } from '../../index-DBevwHj_.js';
2
+ export { C as CharPosition, I as Interval, a as LayoutCursor, b as LayoutLine, c as LayoutNextLineContext, d as LayoutNextLineResult, L as LineBreaksResult, M as MeasurementAdapter, P as PreparedSegment, R as ReactiveLayoutBundle, e as ReactiveLayoutOptions, S as SegmentBreakKind, f as SegmentMeasureStats, g as analyzeAndMeasure, h as carveTextLineSlots, i as computeCharPositions, j as computeLineBreaks, l as layoutNextLine, r as reactiveLayout } from '../../reactive-layout-v7KPvxoc.js';
3
+ import '../../node-ClS5yC-B.js';
4
+ import '../../graph-7VguS7a4.js';
5
+ import '../../meta-BgVAsg9j.js';
6
6
  import '../../extra/storage-core.js';
7
7
  import '../../extra/storage-tiers.js';
@@ -1 +1 @@
1
- import{a as g,b as h,c as i,d as j,e as k,f as l,g as m,h as n,i as o,j as p,k as q,l as r,m as s,n as t,o as u}from"../../chunk-XJLYLLIJ.js";import{a,b,c,d,e,f}from"../../chunk-QSK3RRII.js";import"../../chunk-D27JNOLZ.js";import"../../chunk-C72GO4IZ.js";import"../../chunk-2BX4NB34.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-35JTVPOX.js";import"../../chunk-CKFQS2CJ.js";import"../../chunk-LYCLF26R.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{i as CanvasMeasureAdapter,g as CliMeasureAdapter,l as ImageSizeAdapter,j as NodeCanvasMeasureAdapter,h as PrecomputedAdapter,k as SvgBoundsAdapter,a as analyzeAndMeasure,d as carveTextLineSlots,r as circleIntervalForBand,o as computeBlockFlow,e as computeCharPositions,t as computeFlowLines,b as computeLineBreaks,p as computeTotalHeight,c as layoutNextLine,m as measureBlock,n as measureBlocks,q as reactiveBlockLayout,u as reactiveFlowLayout,f as reactiveLayout,s as rectIntervalForBand};
1
+ import{a as g,b as h,c as i,d as j,e as k,f as l,g as m,h as n,i as o,j as p,k as q,l as r,m as s,n as t,o as u}from"../../chunk-WHMUB5QB.js";import{a,b,c,d,e,f}from"../../chunk-FUZ6S2DY.js";import"../../chunk-D27JNOLZ.js";import"../../chunk-C72GO4IZ.js";import"../../chunk-ACMJ2ZPS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-2K5RXLAH.js";import"../../chunk-35JTVPOX.js";import"../../chunk-LYCLF26R.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{i as CanvasMeasureAdapter,g as CliMeasureAdapter,l as ImageSizeAdapter,j as NodeCanvasMeasureAdapter,h as PrecomputedAdapter,k as SvgBoundsAdapter,a as analyzeAndMeasure,d as carveTextLineSlots,r as circleIntervalForBand,o as computeBlockFlow,e as computeCharPositions,t as computeFlowLines,b as computeLineBreaks,p as computeTotalHeight,c as layoutNextLine,m as measureBlock,n as measureBlocks,q as reactiveBlockLayout,u as reactiveFlowLayout,f as reactiveLayout,s as rectIntervalForBand};