@graphrefly/graphrefly 0.31.0 → 0.32.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 (177) hide show
  1. package/dist/chunk-2JNT5NDF.js +61 -0
  2. package/dist/{chunk-KN4Q5MQO.js → chunk-2RH4QNDQ.js} +1 -1
  3. package/dist/chunk-4JBKKUCJ.js +7 -0
  4. package/dist/{chunk-WLPVGXQ6.js → chunk-4YGJ7KZ6.js} +1 -1
  5. package/dist/{chunk-3Q2WXM6X.js → chunk-5PBXUVHI.js} +1 -1
  6. package/dist/{chunk-WYJTXYWX.js → chunk-7EMUF2RY.js} +1 -1
  7. package/dist/chunk-7JZ3YORY.js +80 -0
  8. package/dist/{chunk-I4U3TPK2.js → chunk-7QS77X6G.js} +1 -1
  9. package/dist/{chunk-ZM7C2FUM.js → chunk-BU4SUZSA.js} +1 -1
  10. package/dist/{chunk-GF5T7PGC.js → chunk-CNXUW2CU.js} +1 -1
  11. package/dist/{chunk-Z3UWIJ3A.js → chunk-EIFHFDFD.js} +1 -1
  12. package/dist/{chunk-3JRKP4BH.js → chunk-JAHAJU4G.js} +1 -1
  13. package/dist/{chunk-4ZPO2EL5.js → chunk-JYMNVEH6.js} +1 -1
  14. package/dist/{chunk-4KAUNEKV.js → chunk-KD3IYBTD.js} +1 -1
  15. package/dist/{chunk-X2VHDT26.js → chunk-LG73TUF4.js} +2 -2
  16. package/dist/{chunk-JXRZXP3N.js → chunk-LJGPOJHS.js} +1 -1
  17. package/dist/{chunk-YQJPYEAL.js → chunk-M2VFLRPJ.js} +1 -1
  18. package/dist/{chunk-7EQPXQ7H.js → chunk-MFNOZ5E6.js} +1 -1
  19. package/dist/{chunk-YZ6VYLFD.js → chunk-PWKLZ2XU.js} +1 -1
  20. package/dist/{chunk-OKQUPJRY.js → chunk-TOCCHQI6.js} +1 -1
  21. package/dist/{chunk-PZP4MEXK.js → chunk-UXEB35L4.js} +1 -1
  22. package/dist/{chunk-EBQ6FXKW.js → chunk-VXJX3ZZP.js} +1 -1
  23. package/dist/{chunk-7EJTWGKW.js → chunk-WE32AFFA.js} +1 -1
  24. package/dist/{chunk-JMGGCSIC.js → chunk-WF3V5X2L.js} +1 -1
  25. package/dist/{chunk-YZKGGMPT.js → chunk-X4OOM6QU.js} +1 -1
  26. package/dist/{chunk-5LJAQTSS.js → chunk-ZWETYYQG.js} +1 -1
  27. package/dist/compat/index.cjs +1 -1
  28. package/dist/compat/index.d.cts +5 -5
  29. package/dist/compat/index.d.ts +5 -5
  30. package/dist/compat/index.js +1 -1
  31. package/dist/compat/nestjs/index.cjs +1 -1
  32. package/dist/compat/nestjs/index.d.cts +3 -3
  33. package/dist/compat/nestjs/index.d.ts +3 -3
  34. package/dist/compat/nestjs/index.js +1 -1
  35. package/dist/compat/zustand/index.cjs +1 -1
  36. package/dist/compat/zustand/index.d.cts +2 -2
  37. package/dist/compat/zustand/index.d.ts +2 -2
  38. package/dist/compat/zustand/index.js +1 -1
  39. package/dist/extra/index.cjs +1 -1
  40. package/dist/extra/index.d.cts +2 -2
  41. package/dist/extra/index.d.ts +2 -2
  42. package/dist/extra/index.js +1 -1
  43. package/dist/graph/index.cjs +1 -1
  44. package/dist/graph/index.d.cts +3 -3
  45. package/dist/graph/index.d.ts +3 -3
  46. package/dist/graph/index.js +1 -1
  47. package/dist/{graph-CWeI0aHd.d.ts → graph-BOhEGJ6E.d.ts} +10 -0
  48. package/dist/{graph-C4Uxwv0T.d.cts → graph-CdJeX7O7.d.cts} +10 -0
  49. package/dist/{index-B-z8WaSd.d.cts → index-BDLy6CQ9.d.cts} +1 -1
  50. package/dist/{index-iBp74eGU.d.cts → index-BJDXj9Wf.d.cts} +2 -2
  51. package/dist/{index-BBINVimG.d.ts → index-BUZPTPSQ.d.ts} +2 -2
  52. package/dist/{index-DnrZghBB.d.ts → index-BbcSZCAG.d.ts} +1 -1
  53. package/dist/{index-lKuLYmHO.d.cts → index-BiGeETJs.d.cts} +1 -1
  54. package/dist/{index-Dm3_D5Ta.d.cts → index-BmZb8fNF.d.cts} +2 -2
  55. package/dist/{index-Docdiu9a.d.ts → index-Bnmttu35.d.ts} +1 -1
  56. package/dist/{index-CZChc85Q.d.cts → index-BuN2wGJs.d.cts} +297 -22
  57. package/dist/{index-Cy7eFeIX.d.cts → index-BwdPDWI4.d.cts} +1 -1
  58. package/dist/{index-DylQCKEL.d.cts → index-BzxU4yhV.d.cts} +11 -2
  59. package/dist/{index-D9Y_u6BG.d.cts → index-C-Gsh-0a.d.cts} +2 -2
  60. package/dist/{index-DD7RhHNJ.d.cts → index-C22aTC1X.d.cts} +4 -4
  61. package/dist/{index-yIdWFo2b.d.cts → index-C4QTaDli.d.cts} +2 -2
  62. package/dist/{index-CJymKyzT.d.ts → index-C7RqYbOZ.d.ts} +1 -1
  63. package/dist/{index-C5Ghnp5B.d.ts → index-C9qCLIN4.d.ts} +2 -2
  64. package/dist/{index-DVNLe3pS.d.cts → index-CCdg0JLX.d.cts} +1 -1
  65. package/dist/{index-B5iVOD7w.d.ts → index-CEoU-r-g.d.ts} +2 -2
  66. package/dist/{index-CfFYyLR8.d.ts → index-CHfBm51k.d.ts} +11 -2
  67. package/dist/{index-BXzl1NDD.d.ts → index-CNyiYQWF.d.ts} +4 -4
  68. package/dist/{index-C6NBfXj-.d.ts → index-CVevMZ0n.d.ts} +2 -2
  69. package/dist/{index-DGb1awva.d.ts → index-CZUzi6Dy.d.ts} +2 -2
  70. package/dist/{index-FrYrV-Vf.d.ts → index-Ckl03Q0s.d.ts} +1 -1
  71. package/dist/{index-Bvi5uJxX.d.ts → index-CmSjld-4.d.ts} +1 -1
  72. package/dist/{index-9iguV3bF.d.cts → index-CnjUhRbs.d.cts} +2 -2
  73. package/dist/{index-C98oJsEs.d.cts → index-D3HcdZ4d.d.cts} +1 -1
  74. package/dist/{index-IZ3l_vQ9.d.ts → index-DD1czHj3.d.ts} +1 -1
  75. package/dist/{index-gJQqJTKx.d.cts → index-DNhTQReY.d.cts} +1 -1
  76. package/dist/{index-UZO988ox.d.cts → index-DSawGt8n.d.cts} +2 -2
  77. package/dist/{index-CcpEvuPl.d.cts → index-DUkuH3jP.d.cts} +1 -1
  78. package/dist/{index-CRAkoq-y.d.cts → index-DY2QbdoP.d.cts} +1 -1
  79. package/dist/{index-CvS9IuTG.d.ts → index-Dbmj0iYR.d.ts} +1 -1
  80. package/dist/{index-Bd6oFZqO.d.ts → index-DhlAMlm9.d.ts} +297 -22
  81. package/dist/{index-BMe3pCom.d.cts → index-DlGaEBW5.d.cts} +2 -2
  82. package/dist/{index-CotRMjtJ.d.ts → index-Dp_pS7Bw.d.ts} +1 -1
  83. package/dist/{index-DxMS0cHM.d.ts → index-Dxk-pUQI.d.ts} +2 -2
  84. package/dist/{index-DBQUKh59.d.cts → index-EGjF6iSY.d.cts} +3 -3
  85. package/dist/{index-D9HrBx2J.d.ts → index-LGzAYqdR.d.ts} +1 -1
  86. package/dist/{index-DR3gf_DG.d.cts → index-LzCJ0kMT.d.cts} +2 -2
  87. package/dist/{index-RQg6lTrN.d.ts → index-MV2yGIAq.d.ts} +2 -2
  88. package/dist/{index-Bs3-LC83.d.cts → index-_BXz9K7b.d.cts} +1 -1
  89. package/dist/{index-SSGqF8mI.d.cts → index-aBqZUx3B.d.cts} +1 -1
  90. package/dist/{index-CFW32Dy1.d.ts → index-eYHRkoK-.d.ts} +1 -1
  91. package/dist/{index-CwhcFzTA.d.ts → index-gXTVbSax.d.ts} +2 -2
  92. package/dist/{index-D-kHVedZ.d.cts → index-j33Lfb1G.d.cts} +22 -1
  93. package/dist/{index-BEpRsvhg.d.ts → index-lpGUhTBn.d.ts} +3 -3
  94. package/dist/{index-CcS0t-l2.d.ts → index-zMQIQuDu.d.ts} +22 -1
  95. package/dist/index.cjs +53 -50
  96. package/dist/index.d.cts +26 -26
  97. package/dist/index.d.ts +26 -26
  98. package/dist/index.js +1 -1
  99. package/dist/patterns/ai/index.cjs +21 -18
  100. package/dist/patterns/ai/index.d.cts +6 -6
  101. package/dist/patterns/ai/index.d.ts +6 -6
  102. package/dist/patterns/ai/index.js +1 -1
  103. package/dist/patterns/audit/index.cjs +1 -1
  104. package/dist/patterns/audit/index.d.cts +3 -3
  105. package/dist/patterns/audit/index.d.ts +3 -3
  106. package/dist/patterns/audit/index.js +1 -1
  107. package/dist/patterns/cqrs/index.cjs +1 -1
  108. package/dist/patterns/cqrs/index.d.cts +2 -2
  109. package/dist/patterns/cqrs/index.d.ts +2 -2
  110. package/dist/patterns/cqrs/index.js +1 -1
  111. package/dist/patterns/demo-shell/index.cjs +1 -1
  112. package/dist/patterns/demo-shell/index.d.cts +3 -3
  113. package/dist/patterns/demo-shell/index.d.ts +3 -3
  114. package/dist/patterns/demo-shell/index.js +1 -1
  115. package/dist/patterns/domain-templates/index.cjs +5 -5
  116. package/dist/patterns/domain-templates/index.d.cts +2 -2
  117. package/dist/patterns/domain-templates/index.d.ts +2 -2
  118. package/dist/patterns/domain-templates/index.js +1 -1
  119. package/dist/patterns/graphspec/index.cjs +27 -25
  120. package/dist/patterns/graphspec/index.d.cts +2 -2
  121. package/dist/patterns/graphspec/index.d.ts +2 -2
  122. package/dist/patterns/graphspec/index.js +1 -1
  123. package/dist/patterns/guarded-execution/index.cjs +5 -5
  124. package/dist/patterns/guarded-execution/index.d.cts +4 -4
  125. package/dist/patterns/guarded-execution/index.d.ts +4 -4
  126. package/dist/patterns/guarded-execution/index.js +1 -1
  127. package/dist/patterns/harness/index.cjs +12 -11
  128. package/dist/patterns/harness/index.d.cts +5 -5
  129. package/dist/patterns/harness/index.d.ts +5 -5
  130. package/dist/patterns/harness/index.js +1 -1
  131. package/dist/patterns/job-queue/index.cjs +1 -1
  132. package/dist/patterns/job-queue/index.d.cts +2 -2
  133. package/dist/patterns/job-queue/index.d.ts +2 -2
  134. package/dist/patterns/job-queue/index.js +1 -1
  135. package/dist/patterns/lens/index.cjs +1 -1
  136. package/dist/patterns/lens/index.d.cts +3 -3
  137. package/dist/patterns/lens/index.d.ts +3 -3
  138. package/dist/patterns/lens/index.js +1 -1
  139. package/dist/patterns/memory/index.cjs +1 -1
  140. package/dist/patterns/memory/index.d.cts +2 -2
  141. package/dist/patterns/memory/index.d.ts +2 -2
  142. package/dist/patterns/memory/index.js +1 -1
  143. package/dist/patterns/messaging/index.cjs +1 -1
  144. package/dist/patterns/messaging/index.d.cts +2 -2
  145. package/dist/patterns/messaging/index.d.ts +2 -2
  146. package/dist/patterns/messaging/index.js +1 -1
  147. package/dist/patterns/orchestration/index.cjs +7 -7
  148. package/dist/patterns/orchestration/index.d.cts +2 -2
  149. package/dist/patterns/orchestration/index.d.ts +2 -2
  150. package/dist/patterns/orchestration/index.js +1 -1
  151. package/dist/patterns/reactive-layout/index.cjs +1 -1
  152. package/dist/patterns/reactive-layout/index.d.cts +3 -3
  153. package/dist/patterns/reactive-layout/index.d.ts +3 -3
  154. package/dist/patterns/reactive-layout/index.js +1 -1
  155. package/dist/patterns/reduction/index.cjs +1 -1
  156. package/dist/patterns/reduction/index.d.cts +2 -2
  157. package/dist/patterns/reduction/index.d.ts +2 -2
  158. package/dist/patterns/reduction/index.js +1 -1
  159. package/dist/patterns/refine-loop/index.cjs +3 -3
  160. package/dist/patterns/refine-loop/index.d.cts +3 -3
  161. package/dist/patterns/refine-loop/index.d.ts +3 -3
  162. package/dist/patterns/refine-loop/index.js +1 -1
  163. package/dist/patterns/resilient-pipeline/index.d.cts +3 -3
  164. package/dist/patterns/resilient-pipeline/index.d.ts +3 -3
  165. package/dist/patterns/resilient-pipeline/index.js +1 -1
  166. package/dist/patterns/surface/index.cjs +15 -13
  167. package/dist/patterns/surface/index.d.cts +3 -3
  168. package/dist/patterns/surface/index.d.ts +3 -3
  169. package/dist/patterns/surface/index.js +1 -1
  170. package/dist/{reactive-layout-BAr6-_o5.d.ts → reactive-layout-Bq0rA2Wb.d.ts} +1 -1
  171. package/dist/{reactive-layout-5oEn8lHM.d.cts → reactive-layout-Dhhe54Oj.d.cts} +1 -1
  172. package/dist/{topology-tree-CVREibAc.d.cts → topology-tree-CpSjvIXp.d.cts} +1 -1
  173. package/dist/{topology-tree-CkjojcB6.d.ts → topology-tree-DAbCV2Yw.d.ts} +1 -1
  174. package/package.json +1 -1
  175. package/dist/chunk-ASDKRNOJ.js +0 -60
  176. package/dist/chunk-PSQNYY72.js +0 -7
  177. package/dist/chunk-XEFAMCEA.js +0 -78
@@ -1,11 +1,11 @@
1
- export { C as CodeChange, a as CodeChangeBridgeOptions, D as DEFAULT_DECAY_RATE, b as DEFAULT_QUEUE_CONFIGS, c as DEFAULT_SEVERITY_WEIGHTS, E as ErrorClass, d as ErrorClassifier, e as EvalDelta, f as EvalIntakeBridgeOptions, g as EvalJudgeScore, h as EvalResult, j as EvalTaskDelta, k as EvalTaskResult, l as EvalVerifierConfig, m as EvalVerifierSummary, n as ExecuteOutput, o as ExecutionResult, H as HarnessExecutor, p as HarnessGraph, q as HarnessLoopOptions, r as HarnessProfileResult, s as HarnessTraceHandle, t as HarnessTraceOptions, u as HarnessVerifier, I as IntakeBridgeOptions, v as IntakeItem, w as IntakeSource, x as Intervention, L as LintError, N as NotifyEffectOptions, y as NotifyTransport, P as PrioritySignals, Q as QUEUE_NAMES, z as QueueConfig, A as QueueRoute, R as RefineExecutorConfig, B as RefineExecutorResult, F as RootCause, S as Severity, G as StrategyEntry, J as StrategyKey, K as StrategyModelBundle, M as StrategySnapshot, T as TestFailure, O as TraceDetail, U as TraceEvent, V as TraceEventType, W as TriagedItem, X as VerifyOutput, Y as VerifyResult, Z as affectedTaskFilter, _ as beforeAfterCompare, $ as codeChangeBridge, a0 as createIntakeBridge, a1 as defaultErrorClassifier, a2 as defaultLlmExecutor, a3 as defaultLlmVerifier, a4 as evalIntakeBridge, a5 as evalSource, a6 as evalVerifier, a7 as harnessLoop, a8 as harnessProfile, a9 as harnessTrace, aa as notifyEffect, ab as priorityScore, ac as refineExecutor, ad as strategyKey, ae as strategyModel } from '../../index-DD7RhHNJ.cjs';
1
+ export { C as CodeChange, a as CodeChangeBridgeOptions, D as DEFAULT_DECAY_RATE, b as DEFAULT_QUEUE_CONFIGS, c as DEFAULT_SEVERITY_WEIGHTS, E as ErrorClass, d as ErrorClassifier, e as EvalDelta, f as EvalIntakeBridgeOptions, g as EvalJudgeScore, h as EvalResult, j as EvalTaskDelta, k as EvalTaskResult, l as EvalVerifierConfig, m as EvalVerifierSummary, n as ExecuteOutput, o as ExecutionResult, H as HarnessExecutor, p as HarnessGraph, q as HarnessLoopOptions, r as HarnessProfileResult, s as HarnessTraceHandle, t as HarnessTraceOptions, u as HarnessVerifier, I as IntakeBridgeOptions, v as IntakeItem, w as IntakeSource, x as Intervention, L as LintError, N as NotifyEffectOptions, y as NotifyTransport, P as PrioritySignals, Q as QUEUE_NAMES, z as QueueConfig, A as QueueRoute, R as RefineExecutorConfig, B as RefineExecutorResult, F as RootCause, S as Severity, G as StrategyEntry, J as StrategyKey, K as StrategyModelBundle, M as StrategySnapshot, T as TestFailure, O as TraceDetail, U as TraceEvent, V as TraceEventType, W as TriagedItem, X as VerifyOutput, Y as VerifyResult, Z as affectedTaskFilter, _ as beforeAfterCompare, $ as codeChangeBridge, a0 as createIntakeBridge, a1 as defaultErrorClassifier, a2 as defaultLlmExecutor, a3 as defaultLlmVerifier, a4 as evalIntakeBridge, a5 as evalSource, a6 as evalVerifier, a7 as harnessLoop, a8 as harnessProfile, a9 as harnessTrace, aa as notifyEffect, ab as priorityScore, ac as refineExecutor, ad as strategyKey, ae as strategyModel } from '../../index-C22aTC1X.cjs';
2
2
  import '../../node-BVV7G1bq.cjs';
3
- import '../../index-B-z8WaSd.cjs';
4
- import '../../graph-C4Uxwv0T.cjs';
3
+ import '../../index-BDLy6CQ9.cjs';
4
+ import '../../graph-CdJeX7O7.cjs';
5
5
  import '../../meta-COtmHLwT.cjs';
6
6
  import '../../extra/storage-core.cjs';
7
- import '../../index-DylQCKEL.cjs';
7
+ import '../../index-BzxU4yhV.cjs';
8
8
  import '../../extra/sources.cjs';
9
9
  import '../../types-BgMqbc7N.cjs';
10
- import '../../index-DVNLe3pS.cjs';
10
+ import '../../index-CCdg0JLX.cjs';
11
11
  import '../../sugar-CqR6DJ7v.cjs';
@@ -1,11 +1,11 @@
1
- export { C as CodeChange, a as CodeChangeBridgeOptions, D as DEFAULT_DECAY_RATE, b as DEFAULT_QUEUE_CONFIGS, c as DEFAULT_SEVERITY_WEIGHTS, E as ErrorClass, d as ErrorClassifier, e as EvalDelta, f as EvalIntakeBridgeOptions, g as EvalJudgeScore, h as EvalResult, j as EvalTaskDelta, k as EvalTaskResult, l as EvalVerifierConfig, m as EvalVerifierSummary, n as ExecuteOutput, o as ExecutionResult, H as HarnessExecutor, p as HarnessGraph, q as HarnessLoopOptions, r as HarnessProfileResult, s as HarnessTraceHandle, t as HarnessTraceOptions, u as HarnessVerifier, I as IntakeBridgeOptions, v as IntakeItem, w as IntakeSource, x as Intervention, L as LintError, N as NotifyEffectOptions, y as NotifyTransport, P as PrioritySignals, Q as QUEUE_NAMES, z as QueueConfig, A as QueueRoute, R as RefineExecutorConfig, B as RefineExecutorResult, F as RootCause, S as Severity, G as StrategyEntry, J as StrategyKey, K as StrategyModelBundle, M as StrategySnapshot, T as TestFailure, O as TraceDetail, U as TraceEvent, V as TraceEventType, W as TriagedItem, X as VerifyOutput, Y as VerifyResult, Z as affectedTaskFilter, _ as beforeAfterCompare, $ as codeChangeBridge, a0 as createIntakeBridge, a1 as defaultErrorClassifier, a2 as defaultLlmExecutor, a3 as defaultLlmVerifier, a4 as evalIntakeBridge, a5 as evalSource, a6 as evalVerifier, a7 as harnessLoop, a8 as harnessProfile, a9 as harnessTrace, aa as notifyEffect, ab as priorityScore, ac as refineExecutor, ad as strategyKey, ae as strategyModel } from '../../index-BXzl1NDD.js';
1
+ export { C as CodeChange, a as CodeChangeBridgeOptions, D as DEFAULT_DECAY_RATE, b as DEFAULT_QUEUE_CONFIGS, c as DEFAULT_SEVERITY_WEIGHTS, E as ErrorClass, d as ErrorClassifier, e as EvalDelta, f as EvalIntakeBridgeOptions, g as EvalJudgeScore, h as EvalResult, j as EvalTaskDelta, k as EvalTaskResult, l as EvalVerifierConfig, m as EvalVerifierSummary, n as ExecuteOutput, o as ExecutionResult, H as HarnessExecutor, p as HarnessGraph, q as HarnessLoopOptions, r as HarnessProfileResult, s as HarnessTraceHandle, t as HarnessTraceOptions, u as HarnessVerifier, I as IntakeBridgeOptions, v as IntakeItem, w as IntakeSource, x as Intervention, L as LintError, N as NotifyEffectOptions, y as NotifyTransport, P as PrioritySignals, Q as QUEUE_NAMES, z as QueueConfig, A as QueueRoute, R as RefineExecutorConfig, B as RefineExecutorResult, F as RootCause, S as Severity, G as StrategyEntry, J as StrategyKey, K as StrategyModelBundle, M as StrategySnapshot, T as TestFailure, O as TraceDetail, U as TraceEvent, V as TraceEventType, W as TriagedItem, X as VerifyOutput, Y as VerifyResult, Z as affectedTaskFilter, _ as beforeAfterCompare, $ as codeChangeBridge, a0 as createIntakeBridge, a1 as defaultErrorClassifier, a2 as defaultLlmExecutor, a3 as defaultLlmVerifier, a4 as evalIntakeBridge, a5 as evalSource, a6 as evalVerifier, a7 as harnessLoop, a8 as harnessProfile, a9 as harnessTrace, aa as notifyEffect, ab as priorityScore, ac as refineExecutor, ad as strategyKey, ae as strategyModel } from '../../index-CNyiYQWF.js';
2
2
  import '../../node-BVV7G1bq.js';
3
- import '../../index-CvS9IuTG.js';
4
- import '../../graph-CWeI0aHd.js';
3
+ import '../../index-Dbmj0iYR.js';
4
+ import '../../graph-BOhEGJ6E.js';
5
5
  import '../../meta-BMwx3ExI.js';
6
6
  import '../../extra/storage-core.js';
7
- import '../../index-CfFYyLR8.js';
7
+ import '../../index-CHfBm51k.js';
8
8
  import '../../extra/sources.js';
9
9
  import '../../types-CdfO2QTt.js';
10
- import '../../index-CFW32Dy1.js';
10
+ import '../../index-eYHRkoK-.js';
11
11
  import '../../sugar-BHbAACDG.js';
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"../../chunk-X2VHDT26.js";import"../../chunk-4KAUNEKV.js";import"../../chunk-ASDKRNOJ.js";import"../../chunk-OKQUPJRY.js";import"../../chunk-5LJAQTSS.js";import"../../chunk-XEFAMCEA.js";import"../../chunk-JMGGCSIC.js";import"../../chunk-EBQ6FXKW.js";import"../../chunk-PNTBXOQ6.js";import"../../chunk-FTA5TB2A.js";import"../../chunk-K54OKWNY.js";import"../../chunk-CZVYLXFK.js";import"../../chunk-7EQPXQ7H.js";import"../../chunk-7QMVU3IX.js";import"../../chunk-Y26UN6J5.js";import"../../chunk-RWGJQQLT.js";import"../../chunk-4VXL3UZK.js";import"../../chunk-LWGLBCMU.js";import"../../chunk-XRSHMHEG.js";import"../../chunk-PSQNYY72.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-N2KKISCE.js";import"../../chunk-I6VIH3VA.js";import"../../chunk-WQ7I7JVU.js";import"../../chunk-4VVTGLXJ.js";import"../../chunk-UMH3HSP7.js";import"../../chunk-7AJKUA36.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{m as DEFAULT_DECAY_RATE,n as DEFAULT_QUEUE_CONFIGS,l as DEFAULT_SEVERITY_WEIGHTS,s as HarnessGraph,i as QUEUE_NAMES,e as affectedTaskFilter,d as beforeAfterCompare,f as codeChangeBridge,a as createIntakeBridge,k as defaultErrorClassifier,q as defaultLlmExecutor,r as defaultLlmVerifier,b as evalIntakeBridge,c as evalSource,h as evalVerifier,t as harnessLoop,u as harnessProfile,w as harnessTrace,g as notifyEffect,p as priorityScore,v as refineExecutor,j as strategyKey,o as strategyModel};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"../../chunk-LG73TUF4.js";import"../../chunk-KD3IYBTD.js";import"../../chunk-2JNT5NDF.js";import"../../chunk-TOCCHQI6.js";import"../../chunk-ZWETYYQG.js";import"../../chunk-7JZ3YORY.js";import"../../chunk-WF3V5X2L.js";import"../../chunk-VXJX3ZZP.js";import"../../chunk-PNTBXOQ6.js";import"../../chunk-FTA5TB2A.js";import"../../chunk-K54OKWNY.js";import"../../chunk-CZVYLXFK.js";import"../../chunk-MFNOZ5E6.js";import"../../chunk-7QMVU3IX.js";import"../../chunk-Y26UN6J5.js";import"../../chunk-RWGJQQLT.js";import"../../chunk-4VXL3UZK.js";import"../../chunk-LWGLBCMU.js";import"../../chunk-XRSHMHEG.js";import"../../chunk-4JBKKUCJ.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-N2KKISCE.js";import"../../chunk-I6VIH3VA.js";import"../../chunk-WQ7I7JVU.js";import"../../chunk-4VVTGLXJ.js";import"../../chunk-UMH3HSP7.js";import"../../chunk-7AJKUA36.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{m as DEFAULT_DECAY_RATE,n as DEFAULT_QUEUE_CONFIGS,l as DEFAULT_SEVERITY_WEIGHTS,s as HarnessGraph,i as QUEUE_NAMES,e as affectedTaskFilter,d as beforeAfterCompare,f as codeChangeBridge,a as createIntakeBridge,k as defaultErrorClassifier,q as defaultLlmExecutor,r as defaultLlmVerifier,b as evalIntakeBridge,c as evalSource,h as evalVerifier,t as harnessLoop,u as harnessProfile,w as harnessTrace,g as notifyEffect,p as priorityScore,v as refineExecutor,j as strategyKey,o as strategyModel};
@@ -4,4 +4,4 @@
4
4
  `)}function ln(t){if(t.version!==le)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${le})`);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 yr(t,e){let n=new WeakMap,r=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=n.get(o);if(i==null&&(i=new WeakSet,n.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,d=s.constructor;if(a!==d)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let p=s;if(o.length!==p.length)return!1;for(let f=0;f<o.length;f++)if(!r(o[f],p[f]))return!1;return!0}if(o instanceof Map){let p=s;if(o.size!==p.size)return!1;for(let[f,l]of o)if(!p.has(f)||!r(l,p.get(f)))return!1;return!0}if(o instanceof Set){let p=s;if(o.size!==p.size)return!1;for(let f of o){let l=!1;for(let g of p)if(r(f,g)){l=!0;break}if(!l)return!1}return!0}if(ArrayBuffer.isView(o)){let p=o,f=s;if(p.length!==f.length)return!1;for(let l=0;l<p.length;l++)if(p[l]!==f[l])return!1;return!0}let u=Object.keys(o),c=Object.keys(s);if(u.length!==c.length)return!1;let h=new Set(c);for(let p of u)if(!h.has(p)||!r(o[p],s[p]))return!1;return!0};return r(t,e)}function _t(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(_t);let e=t,n=Object.keys(e).sort(),r={};for(let o of n)r[o]=_t(e[o]);return r}function vr(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function _r(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function xr(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function fn(t){let e=new Set,n=[];function r(o,s){let i=`${o}\0${s}`;e.has(i)||(e.add(i),n.push([o,s]))}for(let[o,s]of Object.entries(t.nodes)){let i=s.deps;if(i)for(let a of i)r(a,o)}for(let o of t.edges)r(o.from,o.to);return n}function pn(t){if(t===void 0)return"LR";if(t==="TD"||t==="LR"||t==="BT"||t==="RL")return t;throw new Error(`invalid diagram direction ${String(t)}; expected one of: TD, LR, BT, RL`)}function wr(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,{expand:o,...s}=t,i={...s,edges:n?t.edges:[],subgraphs:r?t.subgraphs:[]},a=JSON.stringify(_t(i),null,e.indent??2);return e.logger?.(a),a}function Tr(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,o=[];o.push(`Graph ${t.name}`),o.push("Nodes:");for(let i of Object.keys(t.nodes).sort()){let a=t.nodes[i];o.push(`- ${i} (${a.type}/${a.status}): ${We(a.value)}`)}if(n){o.push("Edges:");for(let i of t.edges)o.push(`- ${i.from} -> ${i.to}`)}if(r){o.push("Subgraphs:");for(let i of t.subgraphs)o.push(`- ${i}`)}let s=o.join(`
5
5
  `);return e.logger?.(s),s}function hn(t,e){let n=pn(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`flowchart ${n}`];for(let i of r){let a=o.get(i);s.push(` ${a}["${vr(i)}"]`)}for(let[i,a]of fn(t)){let d=o.get(i),u=o.get(a);!d||!u||s.push(` ${d} --> ${u}`)}return s.join(`
6
6
  `)}function Er(t,e){let n=hn(t,e);return gn(n)}function gn(t,e){let n=e?.theme??"default",r=e?.autoSync??!0,s=JSON.stringify({code:t,mermaid:{theme:n},autoSync:r}),i=new TextEncoder().encode(s),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function Or(t,e){let n=pn(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`direction: ${xr(n)}`];for(let i of r){let a=o.get(i);s.push(`${a}: "${_r(i)}"`)}for(let[i,a]of fn(t)){let d=o.get(i),u=o.get(a);!d||!u||s.push(`${d} -> ${u}`)}return s.join(`
7
- `)}function Nr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ke(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 o=t.indexOf("]",n+1);if(o<=n+1){e+="\\[";continue}let s=t.slice(n+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,n=o;continue}e+=Nr(r)}return e+="$",new RegExp(e)}var kr={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"},Sr={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function We(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 Rr(t){return t==="none"?Sr:t==="ansi"||t==null?kr:{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 cn(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 Ar(t,e,n){for(let r=0;r<t.length;r++){let o=t.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function vt(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(C))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${C}' (path separator)`);if(t===U)throw new Error(`Graph "${e}": ${n} name "${U}" is reserved for meta companion paths`);Ar(t,e,n)}function Dr(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(C);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function Mr(t,e){let n=!1;for(let o of t)if(!e.isMetaPassthrough(o[0])){n=!0;break}return n?t.filter(o=>e.isMetaPassthrough(o[0])):t}function mn(t){for(let e of t._mounts.values())mn(e);for(let e of t._nodes.values())try{e.down([[z]],{internal:!0})}catch{}}var ce=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(C))throw new Error(`Graph name must not contain '${C}' (got "${e}")`);if(e===U)throw new Error(`Graph name "${U}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??be,this._traceRing=new ke(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=pt(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}add(e,n){let r=e.name,o=n?.name??r;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=n?.annotation;if(vt(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let 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(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:J()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof I&&n._applyVersioning(e)}remove(e){vt(e,this.name,"remove");let n=this._mounts.get(e);if(n){let s={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,d]of i)a.includes(`${C}${U}${C}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...n._collectSubgraphs(`${e}${C}`)),this._mounts.delete(e),n._parent=void 0,mn(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[z]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let n=typeof e=="function"?e:(()=>{let s=Ke(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>n(s));for(let s of o){let i=this.remove(s);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 o=e[r++];return{value:[o,n.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(C))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 o=r?.internal===!0;this.node(e).down([[L,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);ne(()=>{for(let[o,s]of r)this.set(o,s,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 o=r?.internal===!0;this.node(e).down([[$,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[Q]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[d,u]of this._nodes)r.set(u,d);let a=[];for(let[d,u]of this._nodes)if(u instanceof I)for(let c of u._deps){let h=r.get(c.node);h!=null&&a.push([h,d])}return a.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,d]of o)s.set(d,a);let i=[];for(let[a,d]of o)if(d instanceof I)for(let u of d._deps){let c=s.get(u.node);c!=null&&i.push([c,a])}return i.sort((a,d)=>a[0]<d[0]?-1:a[0]>d[0]?1:a[1]<d[1]?-1:a[1]>d[1]?1:0),i}mount(e,n){if(vt(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let n=Dr(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],o=n.slice(1);if(o.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 s=this._nodes.get(r);if(s&&o.length>0&&o[0]===U)return this._resolveMetaChainFromNode(s,o,n.join(C));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(C)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(C))}_resolveMetaChainFromNode(e,n,r){let o=e,s=0,i=[...n];for(;s<i.length;){if(i[s]!==U)throw new Error(`Graph "${this.name}": expected ${U} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${U} in "${r}"`);let a=i[s+1],d=o.meta[a];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=d,s+=2}return o}signal(e,n){if(n?.internal!==!0){for(let o of e)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,o){for(let d of this._mounts.values())d._signalDeliver(e,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=Mr(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(c){if(c instanceof W)throw c;o.push(c)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,o)}}}_signalMetaSubtree(e,n,r,o,s){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,o)}catch(d){if(d instanceof W)throw d;s.push(d)}this._signalMetaSubtree(a,n,r,o,s)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,o=Pe(e?.detail,e?.fields),s=e?.format==="spec",i=s?Pe("minimal"):o,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[x,w]of a)d.set(w,x);let u=[];{let x=a.map(([,N])=>N),w=new Set(d.values()),E=0;for(;x.length>0;){let N=x.shift();if(N instanceof I)for(let A of N._deps){let k=A.node;if(d.has(k))continue;let R=k.name??"",S=R;if(!S||w.has(S))if(R){let G=2;for(;w.has(`${R}#${G}`);)G++;S=`${R}#${G}`}else for(S=`__internal__/${E++}`;w.has(S);)S=`__internal__/${E++}`;d.set(k,S),w.add(S),u.push([S,k]),x.push(k)}}}let c=[...a,...u],h={};for(let[x,w]of c){if(n!=null&&!w.allowsObserve(n))continue;let E=ft(w,i),N=w instanceof I?w._deps.map(S=>d.get(S.node)??S.node.name??""):[],{name:A,...k}=E,R={...k,deps:N};if(!s){let S=this._annotations.get(x);S!=null&&(R.annotation=S)}if(r!=null)if(typeof r=="function"){let S=r;if(!(S.length>=2?S(x,R):S(R)))continue}else{let S=!0;for(let[G,j]of Object.entries(r)){let q=G==="deps_includes"?"depsIncludes":G==="meta_has"?"metaHas":G;if(q==="depsIncludes"){if(!R.deps.includes(String(j))){S=!1;break}continue}if(q==="metaHas"){if(!Object.hasOwn(R.meta??{},String(j))){S=!1;break}continue}if(R[q]!==j){S=!1;break}}if(!S)continue}h[x]=R}let p=new Set(Object.keys(h)),f=[];for(let[x,w]of c)if(w instanceof I)for(let E of w._deps){let N=d.get(E.node);N!=null&&f.push([N,x])}f.sort((x,w)=>x[0]<w[0]?-1:x[0]>w[0]?1:x[1]<w[1]?-1:x[1]>w[1]?1:0);let l=f.map(([x,w])=>({from:x,to:w}));(n!=null||r!=null)&&(l=l.filter(x=>p.has(x.from)&&p.has(x.to)));let g=this._collectSubgraphs(""),m=n!=null||r!=null?g.filter(x=>{let w=`${x}${C}`;return[...p].some(E=>E===x||E.startsWith(w))}):g,b=this,v=e,y={name:this.name,nodes:h,edges:l,subgraphs:m,expand(x){let w={...v,format:void 0};return Array.isArray(x)?(w.fields=x,w.detail=void 0):(w.detail=x,w.fields=void 0),b.describe(w)}},_=e??{},T=_.format;return T==="json"?wr(y,_):T==="pretty"?Tr(y,_):T==="mermaid"?hn(y,_):T==="mermaid-url"?Er(y,_):T==="d2"?Or(y,_):T==="ascii"?an(y,_):y}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;n.push(o),n.push(...this._mounts.get(r)._collectSubgraphs(`${o}${C}`))}return n}resourceProfile(e){return un(this,e)}reachable(e,n,r={}){return r.withDetail===!0?xt(this.describe(),e,n,{...r,withDetail:!0}):xt(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,d]of Object.entries(o.nodes))d.lastMutation!=null&&i.set(a,d.lastMutation);return Kt(o,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=X(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,Ee(()=>{a=!1,!d&&(o+=1,s.emit(o))}))},c=i.onEvent(m=>{let b=m.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||u()}),h=[],p=new WeakSet,f=m=>{if(p.has(m)||d)return;p.add(m);let b=m.topology.subscribe(v=>{for(let y of v){if(y[0]!==L)continue;let _=y[1];if(u(),_.kind==="added"&&_.nodeKind==="mount"){let T=m._mounts.get(_.name);T!=null&&f(T)}}});h.push(b);for(let v of m._mounts.keys()){let y=m._mounts.get(v);y!=null&&f(y)}};f(this);let l;try{l=te([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,b)=>m===b})}catch(m){c();for(let b of h)b();throw i.dispose(),m}let g=se(l);return{node:l,dispose(){d=!0,c();for(let m of h)m();h.length=0,i.dispose(),g()}}}_explainReactive(e,n,r){let o=0,s=X(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(f=>{let l=f.type;l!=="data"&&l!=="error"&&l!=="complete"&&l!=="teardown"||a||d||(a=!0,Ee(()=>{a=!1,!d&&(o+=1,s.emit(o))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},h;try{h=te([s],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(f,l)=>f.found===l.found&&f.reason===l.reason&&f.steps.length===l.steps.length&&Cr(f.steps,l.steps)})}catch(f){throw u(),i.dispose(),f}let p=se(h);return{node:h,dispose(){d=!0,u(),i.dispose(),p()}}}_pathsMatching(e){let n=Ke(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>n.test(o))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${C}${r}`;this._mounts.get(r)._collectObserveTargets(o,n)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${C}${r}`;n.push([s,o]),this._appendMetaObserveTargets(s,o,n)}}_appendMetaObserveTargets(e,n,r){for(let o of Object.keys(n.meta).sort()){let s=n.meta[o],i=`${e}${C}${U}${C}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,n){let r=typeof e=="string",s=cn(r?n:e),i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let c=e,h=this.resolve(c);if(a!=null&&!h.allowsObserve(a))throw new W({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,h]],s,"one"):{subscribe(p){return h.subscribe(p)},up(p){try{h.up?.(p)}catch(f){if(f instanceof W)return;throw f}}}}let d=[];this._collectObserveTargets("",d),d.sort((c,h)=>c[0]<h[0]?-1:c[0]>h[0]?1:0);let u=a==null?d:d.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:c=>{let h=u.map(([p,f])=>f.subscribe(l=>{c(p,l)}));return()=>{for(let p of h)p()}},up:(c,h)=>{try{this.resolve(c).up?.(h)}catch(p){if(p instanceof W)return;throw p}}}}_buildStructuredObserver(e,n,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let c=this.resolve(o);return this._buildStructuredObserver([[o,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,h)=>c[0]<h[0]?-1:c[0]>h[0]?1:0);let d=i.actor,u=d==null?a:a.filter(([,c])=>c.allowsObserve(d));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,s)}_createObserveResult(e,n,r){let o=n.timeline===!0,s=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",d=this.config.inspectorEnabled,u=(s||i)&&d,c=n.maxEvents,h=c!=null&&c>0?new ke(c):null,p=[],f=new Set,l={},g=new Set,m=0,b=0,v=0,y=0,_=0,T=0,x=!1,w=!1,E=0,N=new Map,A=new Map,k=new Map,R=O=>{h?h.push(O):p.push(O);for(let M of f)M(O)},S=()=>o?{timestamp_ns:J(),in_batch:De(),batch_id:E}:{},G=(O,M)=>{if(!(!u||!(O instanceof I)))return O._setInspectorHook(B=>{if(B.kind==="dep_message")N.set(O,B.depIndex);else if(B.kind==="run"){let xe=B.batchData.map((D,V)=>D!=null&&D.length>0?D.at(-1):B.prevData[V]);A.set(O,xe);let H=B.batchData.map(D=>D!=null?[...D]:void 0);k.set(O,H),i&&R({type:"derived",path:M,dep_values:xe,dep_batches:H,...S()})}})},j=O=>{let M=N.get(O),B=A.get(O);if(!s||B==null)return{};let H=(M!=null&&M>=0&&O instanceof I?O._deps[M]:void 0)?.node,D=H?.v,V=k.get(O);return{trigger_dep_index:M,trigger_dep_name:H?.name,...D!=null?{trigger_version:{id:D.id,version:D.version}}:{},dep_values:[...B],...V!=null?{dep_batches:V}:{}}},q=[],ie=[];for(let[O,M]of e){let B=G(M,O);B&&q.push(B),ie.push(M.subscribe(xe=>{E++;for(let H of xe){let D=H[0],V=S();if(D===L){l[O]=H[1];let Xe=M instanceof I?M.lastMutation?.actor??fe:fe;R({type:"data",path:O,data:H[1],actor:Xe,...V,...j(M)})}else if(a)D===F?m++:D===Z?b++:D===Y?v++:D===ee?y++:D===re?_++:D===z?T++:D===Q&&!g.has(O)?x=!0:D===$&&(w=!0,g.add(O));else if(D===F)m++,R({type:"dirty",path:O,...V});else if(D===Z)b++,R({type:"resolved",path:O,...V,...j(M)});else if(D===Y)v++,R({type:"invalidate",path:O,...V});else if(D===ee)y++,R({type:"pause",path:O,lockId:H[1],...V});else if(D===re)_++,R({type:"resume",path:O,lockId:H[1],...V});else if(D===Q)g.has(O)||(x=!0),R({type:"complete",path:O,...V});else if(D===$){w=!0,g.add(O);let Xe=M instanceof I?M.lastMutation?.actor??fe:fe;R({type:"error",path:O,data:H[1],actor:Xe,...V})}else D===z&&(T++,R({type:"teardown",path:O,...V}))}}))}let Je=!1,Ye=()=>{if(!Je){Je=!0;for(let O of ie)O();for(let O of q)O();for(let O of Se)O({value:void 0,done:!0});Se.length=0}},Qe=[],Se=[];f.add(O=>{let M=Se.shift();M?M({value:O,done:!1}):Qe.push(O)});let Tt={get values(){return l},get dirtyCount(){return m},get resolvedCount(){return b},get invalidateCount(){return v},get pauseCount(){return y},get resumeCount(){return _},get teardownCount(){return T},get events(){return h?h.toArray():[...p]},get anyCompletedCleanly(){return x},get anyErrored(){return w},get completedWithoutErrors(){return x&&!w},onEvent(O){return f.add(O),()=>f.delete(O)},dispose:Ye,expand(O){Ye();let M={...n};return typeof O=="string"?M.detail=O:Object.assign(M,O),r(cn(M))},[Symbol.asyncIterator](){return{next(){return Qe.length>0?Promise.resolve({value:Qe.shift(),done:!1}):Je?Promise.resolve({value:void 0,done:!0}):new Promise(O=>Se.push(O))},return(){return Ye(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Tt,n),Tt}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let o=n.logger??(l=>console.log(l)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:l=>(s==null||s.has(l))&&(i==null||!i.has(l)),d=Rr(n.theme),u=r==="stage-log"?J():0,c=l=>l==null?"":n.stageLabels?.[l]??l,h=(l,g)=>l.length>g?`${l.slice(0,g-1)}\u2026`:l,p=l=>l.type==="data"||l.type==="error"?h(We(l.data),120):"",f=l=>{if(r==="stage-log"){let w=(J()-u)/1e9,E=c(l.path).padEnd(9);if(l.type==="data"){let N=p(l);return`[${w.toFixed(3)}s] ${E} \u2190${N?` ${N}`:""}`}if(l.type==="error"){let N=p(l);return`[${w.toFixed(3)}s] ${E} \u2717${N?` ${N}`:""}`}return l.type==="complete"?`[${w.toFixed(3)}s] ${E} \u25A0 complete`:`[${w.toFixed(3)}s] ${E} ${l.type}`}if(r==="json")try{return JSON.stringify(l)}catch{return JSON.stringify({type:l.type,path:l.path,data:"[unserializable]"})}let g=d[l.type]??"",m=l.path?`${d.path}${l.path}${d.reset} `:"",b=l.type==="data"||l.type==="error",v=l.type==="pause"||l.type==="resume",y=b?` ${We(l.data)}`:v?` ${We(l.lockId)}`:"",_=l.type==="data"||l.type==="resolved"||l.type==="derived"?l:void 0,T=_?.trigger_dep_name!=null?` <- ${_.trigger_dep_name}`:_?.trigger_dep_index!=null?` <- #${_.trigger_dep_index}`:"",x=l.in_batch?" [batch]":"";return`${m}${g}${l.type.toUpperCase()}${d.reset}${y}${T}${x}`};e.onEvent(l=>{a(l.type)&&o(f(l),l)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){dn(this._disposers,this.name),this.signal([[z]],{internal:!0}),dn(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}snapshot(e){let{expand:n,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:d,guard:u,...c}=r.nodes[a];o[a]=c}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};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??be,{codec:o,codecVersion:s,payload:i}=Mt(e,r);return o.decode(i,s)}restore(e,n){if(ln(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(s=>Ke(s)),o=n?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let d=this.tryResolve(s)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(e,n){ln(e);let r=typeof n=="function"?n:n?.build,o=typeof n=="function"?void 0:n?.factories,s=new t(e.name);if(r)return r(s),s.restore(e),s;for(let f of[...e.subgraphs].sort((l,g)=>{let m=l.split(C).length,b=g.split(C).length;return m!==b?m-b:l<g?-1:l>g?1:0})){let l=f.split(C),g=s;for(let m of l)g._mounts.has(m)||g.mount(m,new t(m)),g=g._mounts.get(m)}let i=o?Object.entries(o).map(([f,l])=>({re:Ke(f),factory:l})):[],a=f=>{for(let l of i)if(l.re.test(f))return l.factory},d=f=>{let l=f.split(C),g=l.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${f}"`);let m=s;for(let b of l){let v=m._mounts.get(b);if(!v)throw new Error(`unknown mount "${b}" in path "${f}"`);m=v}return[m,g]},u=Object.entries(e.nodes).filter(([f])=>!f.includes(`${C}${U}${C}`)).sort((f,l)=>f[0]<l[0]?-1:f[0]>l[0]?1:0),c=new Map(u),h=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[f,l]of[...c.entries()]){let g=l?.deps??[];if(!g.every(T=>h.has(T)))continue;let[m,b]=d(f),v={...l?.meta??{}},y=a(f),_;if(l?.type==="state")_=X(l.value,{meta:v});else{if(y==null)continue;_=y(b,{path:f,type:l.type,value:l.value,meta:v,deps:g,resolvedDeps:g.map(T=>h.get(T))})}m.add(_,{name:b}),h.set(f,_),c.delete(f),p=!0}}if(c.size>0){let f=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${f}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let o=(u,c)=>{if(u.disposed)return;let h=br(c.nodes);if(u.lastSnapshot!=null&&h!==""&&h===u.lastFingerprint)return;let p=u.seq+1,f=Ce(),m=u.lastSnapshot==null||p%u.compactEvery===0?{mode:"full",snapshot:c,seq:p,timestamp_ns:f,format_version:le}:{mode:"diff",diff:bn(u.lastSnapshot,c),seq:p,timestamp_ns:f,format_version:le};if(u.tier.filter&&!u.tier.filter(this.name,m))return;let b;try{b=u.tier.save(this.name,m)}catch(v){n.onError?.(v,u.tier);return}if(b&&typeof b.then=="function"){let _=(u.savePending??Promise.resolve()).then(()=>b,()=>b).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=c,u.lastFingerprint=h)},T=>{n.onError?.(T,u.tier)});u.savePending=_.finally(()=>{u.savePending===_&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=c,u.lastFingerprint=h},s=(u,c)=>{try{o(u,c)}catch(h){n.onError?.(h,u.tier)}},i=(u,c)=>{if(!c.some(l=>{let g=this.config.messageTier(l[0]);return g>=3&&g<5}))return;if(n.filter){let l=this.tryResolve(u);if(l==null)return;let g=ft(l,Pe("standard"));if(!n.filter(u,g))return}let p,f=()=>(p==null&&(p=this.snapshot()),p);for(let l of r)l.disposed||(l.debounceMs===0?s(l,f()):(l.timer==null&&(l.timer=new ze),l.timer.start(l.debounceMs,()=>{l.disposed||s(l,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(h=>{let p=this.tryResolve(h);return p==null?()=>{}:p.subscribe(f=>i(h,f))});a=()=>{for(let h of c)h()}}else a=this.observe().subscribe((u,c)=>i(u,c));let d=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,n){for(let r of e){let o;try{o=await r.load(this.name)}catch(i){n?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===le&&s.nodes!=null)return this.restore(s),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let o of n){let s;try{s=await o.load(e)}catch(d){r?.onError?.(d,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===le&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(d){r?.onError?.(d,o)}}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 o={path:e,annotation:n,timestamp_ns:J(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(o=>!e(o)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let o of n)this._traceRing.push(o);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(n.nodes)),s=[...o].filter(v=>!r.has(v)).sort(),i=[...r].filter(v=>!o.has(v)).sort(),a=[],d=[];for(let v of r){if(!o.has(v))continue;let y=e.nodes[v],_=n.nodes[v],T=y.v,x=_.v;T!=null&&x!=null&&T.id===x.id&&T.version!==x.version&&d.push({path:v,id:T.id,from:T.version,to:x.version});let w=T!=null&&x!=null&&T.id===x.id&&T.version===x.version;for(let E of["type","status","sentinel"]){let N=y[E],A=_[E];N!==A&&a.push({path:v,field:E,from:N,to:A})}if(!w)for(let E of["value","meta"]){let N=y[E],A=_[E];yr(N,A)||a.push({path:v,field:E,from:N,to:A})}}let u=v=>`${v.from} ${v.to}`,c=new Set(e.edges.map(u)),h=new Set(n.edges.map(u)),p=n.edges.filter(v=>!c.has(u(v))),f=e.edges.filter(v=>!h.has(u(v))),l=new Set(e.subgraphs),g=new Set(n.subgraphs),m=[...g].filter(v=>!l.has(v)).sort(),b=[...l].filter(v=>!g.has(v)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:p,edgesRemoved:f,subgraphsAdded:m,subgraphsRemoved:b}}};function bn(t,e){let n=ce.diff(t,e),r={};for(let o of n.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...n,nodesAddedFull:r}}function xt(t,e,n,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,d=new Map,u=new Map,c=new Set;for(let[y,_]of Object.entries(t.nodes)){if(!y)continue;c.add(y);let T=_.deps??[];i.set(y,T);for(let x of T)x&&(c.add(x),a.has(x)||a.set(x,new Set),a.get(x).add(y))}for(let y of t.edges){if(y==null||typeof y!="object")continue;let _=typeof y.from=="string"?y.from:"",T=typeof y.to=="string"?y.to:"";!_||!T||(c.add(_),c.add(T),u.has(_)||u.set(_,new Set),u.get(_).add(T),d.has(T)||d.set(T,new Set),d.get(T).add(_))}if(!c.has(e))return r.withDetail?o:[];let h=r.both===!0,p=y=>{if(h){let w=i.get(y)??[],E=d.get(y),N=a.get(y),A=u.get(y),k=[...w];return E&&k.push(...E),N&&k.push(...N),A&&k.push(...A),k}if(n==="upstream"){let w=i.get(y)??[],E=d.get(y);return E?[...w,...E]:w}let _=a.get(y),T=u.get(y),x=_?[..._]:[];return T&&x.push(...T),x},f=new Set([e]),l=new Map,g=[{path:e,depth:0}],m=0,b=!1;for(;m<g.length;){let y=g[m++];if(s!=null&&y.depth>=s){p(y.path).length>0&&(b=!0);continue}for(let _ of p(y.path))!_||f.has(_)||(f.add(_),l.set(_,y.depth+1),g.push({path:_,depth:y.depth+1}))}let v=[...l.keys()].sort((y,_)=>y<_?-1:y>_?1:0);return r.withDetail?{paths:v,depths:l,truncated:b}:v}function Cr(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],o=e[n];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}bt();function yn(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}var Gr=2147483647;function vn(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function wt(t,e){return yn("job_queue",t,e)}var Ue=class extends ce{_pending;_jobs;_seq=0;pending;jobs;depth;constructor(e,n={}){super(e,n.graph),this._pending=Vt([],{name:"pending"}),this._jobs=Bt({name:"jobs"}),this.pending=this._pending.items,this.jobs=this._jobs.entries,this.add(this.pending,{name:"pending"}),this.add(this.jobs,{name:"jobs"}),this.depth=te([this.pending],([r])=>r.length,{name:"depth",describeKind:"derived",meta:wt("queue_depth"),initial:0}),this.add(this.depth,{name:"depth"}),this.addDisposer(se(this.depth))}enqueue(e,n={}){let r=n.id??`${this.name}-${++this._seq}`;if(this._jobs.get(r)!==void 0)throw new Error(`jobQueue("${this.name}"): duplicate job id "${r}"`);let o={id:r,payload:e,attempts:0,metadata:Object.freeze({...n.metadata??{}}),state:"queued"};return this._jobs.set(r,o),this._pending.append(r),r}claim(e=1){let n=vn(e,"job queue claim limit");if(n===0)return[];let r=[];for(;r.length<n&&this.pending.cache.length!==0;){let s=this._pending.pop(0),i=this._jobs.get(s);if(!i||i.state!=="queued")continue;let a={...i,state:"inflight",attempts:i.attempts+1};this._jobs.set(s,a),r.push(a)}return r}ack(e){let n=this._jobs.get(e);return!n||n.state!=="inflight"?!1:(this._jobs.delete(e),!0)}nack(e,n={}){let r=this._jobs.get(e);return!r||r.state!=="inflight"?!1:n.requeue??!0?(this._jobs.set(e,{...r,state:"queued"}),this._pending.append(e),!0):(this._jobs.delete(e),!0)}},qe=class extends ce{_stageNames;_queues=new Map;_completed;completed;completedCount;constructor(e,n={}){super(e,n.graph);let r=(n.stages??["incoming","processing","done"]).map(i=>i.trim());if(r.length<2)throw new Error(`jobFlow("${e}"): requires at least 2 stages`);if(new Set(r).size!==r.length)throw new Error(`jobFlow("${e}"): stage names must be unique`);this._stageNames=Object.freeze([...r]);for(let i of this._stageNames){let a=_n(`${e}-${i}`);this._queues.set(i,a),this.mount(i,a)}this._completed=jt([],{name:"completed"}),this.completed=this._completed.entries,this.add(this.completed,{name:"completed"}),this.completedCount=te([this.completed],([i])=>i.length,{name:"completedCount",describeKind:"derived",meta:wt("job_flow_completed_count"),initial:0}),this.add(this.completedCount,{name:"completedCount"}),this.addDisposer(se(this.completedCount));let s=Math.max(1,vn(n.maxPerPump??Gr,"job flow maxPerPump"));for(let i=0;i<this._stageNames.length;i+=1){let a=this._stageNames[i],d=this.queue(a),u=i+1<this._stageNames.length?this.queue(this._stageNames[i+1]):null,c=ye([d.pending],()=>{let h=0;for(;h<s;){let p=d.claim(1);if(p.length===0)break;let f=p[0];if(!f)break;u?u.enqueue(f.payload,{metadata:{...f.metadata,job_flow_from:a}}):this._completed.append(f),d.ack(f.id),h+=1}},{name:`pump_${a}`,describeKind:"effect",meta:wt("job_flow_pump")});this.add(c,{name:`pump_${a}`}),this.addDisposer(se(c))}}stages(){return this._stageNames}queue(e){let n=this._queues.get(e);if(!n)throw new Error(`jobFlow("${this.name}"): unknown stage "${e}"`);return n}enqueue(e,n={}){return this.queue(this._stageNames[0]).enqueue(e,n)}retainedCompleted(){return this.completed.cache}};function _n(t,e){return new Ue(t,e)}function Lr(t,e){return new qe(t,e)}0&&(module.exports={JobFlowGraph,JobQueueGraph,jobFlow,jobQueue});
7
+ `)}function Nr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ke(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 o=t.indexOf("]",n+1);if(o<=n+1){e+="\\[";continue}let s=t.slice(n+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,n=o;continue}e+=Nr(r)}return e+="$",new RegExp(e)}var kr={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"},Sr={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function We(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 Rr(t){return t==="none"?Sr:t==="ansi"||t==null?kr:{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 cn(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 Ar(t,e,n){for(let r=0;r<t.length;r++){let o=t.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function vt(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(C))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${C}' (path separator)`);if(t===U)throw new Error(`Graph "${e}": ${n} name "${U}" is reserved for meta companion paths`);Ar(t,e,n)}function Dr(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(C);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function Mr(t,e){let n=!1;for(let o of t)if(!e.isMetaPassthrough(o[0])){n=!0;break}return n?t.filter(o=>e.isMetaPassthrough(o[0])):t}function mn(t){for(let e of t._mounts.values())mn(e);for(let e of t._nodes.values())try{e.down([[z]],{internal:!0})}catch{}}var ce=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(C))throw new Error(`Graph name must not contain '${C}' (got "${e}")`);if(e===U)throw new Error(`Graph name "${U}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??be,this._traceRing=new ke(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=pt(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}add(e,n){let r=e.name,o=n?.name??r;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=n?.annotation;if(vt(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let 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(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:J()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof I&&n._applyVersioning(e)}remove(e){vt(e,this.name,"remove");let n=this._mounts.get(e);if(n){let s={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,d]of i)a.includes(`${C}${U}${C}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...n._collectSubgraphs(`${e}${C}`)),this._mounts.delete(e),n._parent=void 0,mn(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[z]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let n=typeof e=="function"?e:(()=>{let s=Ke(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>n(s));for(let s of o){let i=this.remove(s);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 o=e[r++];return{value:[o,n.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(C))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 o=r?.internal===!0;this.node(e).down([[L,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);ne(()=>{for(let[o,s]of r)this.set(o,s,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 o=r?.internal===!0;this.node(e).down([[$,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[Q]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[d,u]of this._nodes)r.set(u,d);let a=[];for(let[d,u]of this._nodes)if(u instanceof I)for(let c of u._deps){let h=r.get(c.node);h!=null&&a.push([h,d])}return a.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,d]of o)s.set(d,a);let i=[];for(let[a,d]of o)if(d instanceof I)for(let u of d._deps){let c=s.get(u.node);c!=null&&i.push([c,a])}return i.sort((a,d)=>a[0]<d[0]?-1:a[0]>d[0]?1:a[1]<d[1]?-1:a[1]>d[1]?1:0),i}mount(e,n){if(vt(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let n=Dr(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],o=n.slice(1);if(o.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 s=this._nodes.get(r);if(s&&o.length>0&&o[0]===U)return this._resolveMetaChainFromNode(s,o,n.join(C));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(C)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(C))}_resolveMetaChainFromNode(e,n,r){let o=e,s=0,i=[...n];for(;s<i.length;){if(i[s]!==U)throw new Error(`Graph "${this.name}": expected ${U} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${U} in "${r}"`);let a=i[s+1],d=o.meta[a];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=d,s+=2}return o}signal(e,n){if(n?.internal!==!0){for(let o of e)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,o){for(let d of this._mounts.values())d._signalDeliver(e,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=Mr(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(c){if(c instanceof W)throw c;o.push(c)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,o)}}}_signalMetaSubtree(e,n,r,o,s){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,o)}catch(d){if(d instanceof W)throw d;s.push(d)}this._signalMetaSubtree(a,n,r,o,s)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,o=Pe(e?.detail,e?.fields),s=e?.format==="spec",i=s?Pe("minimal"):o,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[x,w]of a)d.set(w,x);let u=[];{let x=a.map(([,N])=>N),w=new Set(d.values()),E=0;for(;x.length>0;){let N=x.shift();if(N instanceof I)for(let A of N._deps){let k=A.node;if(d.has(k))continue;let R=k.name??"",S=R;if(!S||w.has(S))if(R){let G=2;for(;w.has(`${R}#${G}`);)G++;S=`${R}#${G}`}else for(S=`__internal__/${E++}`;w.has(S);)S=`__internal__/${E++}`;d.set(k,S),w.add(S),u.push([S,k]),x.push(k)}}}let c=[...a,...u],h={};for(let[x,w]of c){if(n!=null&&!w.allowsObserve(n))continue;let E=ft(w,i),N=w instanceof I?w._deps.map(S=>d.get(S.node)??S.node.name??""):[],{name:A,...k}=E,R={...k,deps:N};if(!s){let S=this._annotations.get(x);S!=null&&(R.annotation=S)}if(r!=null)if(typeof r=="function"){let S=r;if(!(S.length>=2?S(x,R):S(R)))continue}else{let S=!0;for(let[G,j]of Object.entries(r)){let q=G==="deps_includes"?"depsIncludes":G==="meta_has"?"metaHas":G;if(q==="depsIncludes"){if(!R.deps.includes(String(j))){S=!1;break}continue}if(q==="metaHas"){if(!Object.hasOwn(R.meta??{},String(j))){S=!1;break}continue}if(R[q]!==j){S=!1;break}}if(!S)continue}h[x]=R}let p=new Set(Object.keys(h)),f=[];for(let[x,w]of c)if(w instanceof I)for(let E of w._deps){let N=d.get(E.node);N!=null&&f.push([N,x])}f.sort((x,w)=>x[0]<w[0]?-1:x[0]>w[0]?1:x[1]<w[1]?-1:x[1]>w[1]?1:0);let l=f.map(([x,w])=>({from:x,to:w}));(n!=null||r!=null)&&(l=l.filter(x=>p.has(x.from)&&p.has(x.to)));let g=this._collectSubgraphs(""),m=n!=null||r!=null?g.filter(x=>{let w=`${x}${C}`;return[...p].some(E=>E===x||E.startsWith(w))}):g,b=this,v=e,y={name:this.name,nodes:h,edges:l,subgraphs:m,expand(x){let w={...v,format:void 0};return Array.isArray(x)?(w.fields=x,w.detail=void 0):(w.detail=x,w.fields=void 0),b.describe(w)}},_=e??{},T=_.format;return T==="json"?wr(y,_):T==="pretty"?Tr(y,_):T==="mermaid"?hn(y,_):T==="mermaid-url"?Er(y,_):T==="d2"?Or(y,_):T==="ascii"?an(y,_):y}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;n.push(o),n.push(...this._mounts.get(r)._collectSubgraphs(`${o}${C}`))}return n}resourceProfile(e){return un(this,e)}reachable(e,n,r={}){return r.withDetail===!0?xt(this.describe(),e,n,{...r,withDetail:!0}):xt(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,d]of Object.entries(o.nodes))d.lastMutation!=null&&i.set(a,d.lastMutation);return Kt(o,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=X(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,Ee(()=>{a=!1,!d&&(o+=1,s.emit(o))}))},c=i.onEvent(m=>{let b=m.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||u()}),h=[],p=new WeakSet,f=m=>{if(p.has(m)||d)return;p.add(m);let b=m.topology.subscribe(v=>{for(let y of v){if(y[0]!==L)continue;let _=y[1];if(u(),_.kind==="added"&&_.nodeKind==="mount"){let T=m._mounts.get(_.name);T!=null&&f(T)}}});h.push(b);for(let v of m._mounts.keys()){let y=m._mounts.get(v);y!=null&&f(y)}};f(this);let l;try{l=te([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,b)=>m===b})}catch(m){c();for(let b of h)b();throw i.dispose(),m}let g=se(l);return{node:l,dispose(){d=!0,c();for(let m of h)m();h.length=0,i.dispose(),g()}}}_explainReactive(e,n,r){let o=0,s=X(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(f=>{let l=f.type;l!=="data"&&l!=="error"&&l!=="complete"&&l!=="teardown"||a||d||(a=!0,Ee(()=>{a=!1,!d&&(o+=1,s.emit(o))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},h;try{h=te([s],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(f,l)=>f.found===l.found&&f.reason===l.reason&&f.steps.length===l.steps.length&&Cr(f.steps,l.steps)})}catch(f){throw u(),i.dispose(),f}let p=se(h);return{node:h,dispose(){d=!0,u(),i.dispose(),p()}}}_pathsMatching(e){let n=Ke(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>n.test(o))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${C}${r}`;this._mounts.get(r)._collectObserveTargets(o,n)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${C}${r}`;n.push([s,o]),this._appendMetaObserveTargets(s,o,n)}}_appendMetaObserveTargets(e,n,r){for(let o of Object.keys(n.meta).sort()){let s=n.meta[o],i=`${e}${C}${U}${C}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,n){let r=typeof e=="string",s=cn(r?n:e),i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let c=e,h=this.resolve(c);if(a!=null&&!h.allowsObserve(a))throw new W({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,h]],s,"one"):{subscribe(p){return h.subscribe(p)},up(p){try{h.up?.(p)}catch(f){if(f instanceof W)return;throw f}}}}let d=[];this._collectObserveTargets("",d),d.sort((c,h)=>c[0]<h[0]?-1:c[0]>h[0]?1:0);let u=a==null?d:d.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:c=>{let h=u.map(([p,f])=>f.subscribe(l=>{c(p,l)}));return()=>{for(let p of h)p()}},up:(c,h)=>{try{this.resolve(c).up?.(h)}catch(p){if(p instanceof W)return;throw p}}}}_buildStructuredObserver(e,n,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let c=this.resolve(o);return this._buildStructuredObserver([[o,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,h)=>c[0]<h[0]?-1:c[0]>h[0]?1:0);let d=i.actor,u=d==null?a:a.filter(([,c])=>c.allowsObserve(d));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,s)}_createObserveResult(e,n,r){let o=n.timeline===!0,s=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",d=this.config.inspectorEnabled,u=(s||i)&&d,c=n.maxEvents,h=c!=null&&c>0?new ke(c):null,p=[],f=new Set,l={},g=new Set,m=0,b=0,v=0,y=0,_=0,T=0,x=!1,w=!1,E=0,N=new Map,A=new Map,k=new Map,R=O=>{h?h.push(O):p.push(O);for(let M of f)M(O)},S=()=>o?{timestamp_ns:J(),in_batch:De(),batch_id:E}:{},G=(O,M)=>{if(!(!u||!(O instanceof I)))return O._setInspectorHook(B=>{if(B.kind==="dep_message")N.set(O,B.depIndex);else if(B.kind==="run"){let xe=B.batchData.map((D,V)=>D!=null&&D.length>0?D.at(-1):B.prevData[V]);A.set(O,xe);let H=B.batchData.map(D=>D!=null?[...D]:void 0);k.set(O,H),i&&R({type:"derived",path:M,dep_values:xe,dep_batches:H,...S()})}})},j=O=>{let M=N.get(O),B=A.get(O);if(!s||B==null)return{};let H=(M!=null&&M>=0&&O instanceof I?O._deps[M]:void 0)?.node,D=H?.v,V=k.get(O);return{trigger_dep_index:M,trigger_dep_name:H?.name,...D!=null?{trigger_version:{id:D.id,version:D.version}}:{},dep_values:[...B],...V!=null?{dep_batches:V}:{}}},q=[],ie=[];for(let[O,M]of e){let B=G(M,O);B&&q.push(B),ie.push(M.subscribe(xe=>{E++;for(let H of xe){let D=H[0],V=S();if(D===L){l[O]=H[1];let Xe=M instanceof I?M.lastMutation?.actor??fe:fe;R({type:"data",path:O,data:H[1],actor:Xe,...V,...j(M)})}else if(a)D===F?m++:D===Z?b++:D===Y?v++:D===ee?y++:D===re?_++:D===z?T++:D===Q&&!g.has(O)?x=!0:D===$&&(w=!0,g.add(O));else if(D===F)m++,R({type:"dirty",path:O,...V});else if(D===Z)b++,R({type:"resolved",path:O,...V,...j(M)});else if(D===Y)v++,R({type:"invalidate",path:O,...V});else if(D===ee)y++,R({type:"pause",path:O,lockId:H[1],...V});else if(D===re)_++,R({type:"resume",path:O,lockId:H[1],...V});else if(D===Q)g.has(O)||(x=!0),R({type:"complete",path:O,...V});else if(D===$){w=!0,g.add(O);let Xe=M instanceof I?M.lastMutation?.actor??fe:fe;R({type:"error",path:O,data:H[1],actor:Xe,...V})}else D===z&&(T++,R({type:"teardown",path:O,...V}))}}))}let Je=!1,Ye=()=>{if(!Je){Je=!0;for(let O of ie)O();for(let O of q)O();for(let O of Se)O({value:void 0,done:!0});Se.length=0}},Qe=[],Se=[];f.add(O=>{let M=Se.shift();M?M({value:O,done:!1}):Qe.push(O)});let Tt={get values(){return l},get dirtyCount(){return m},get resolvedCount(){return b},get invalidateCount(){return v},get pauseCount(){return y},get resumeCount(){return _},get teardownCount(){return T},get events(){return h?h.toArray():[...p]},get anyCompletedCleanly(){return x},get anyErrored(){return w},get completedWithoutErrors(){return x&&!w},onEvent(O){return f.add(O),()=>f.delete(O)},dispose:Ye,expand(O){Ye();let M={...n};return typeof O=="string"?M.detail=O:Object.assign(M,O),r(cn(M))},[Symbol.asyncIterator](){return{next(){return Qe.length>0?Promise.resolve({value:Qe.shift(),done:!1}):Je?Promise.resolve({value:void 0,done:!0}):new Promise(O=>Se.push(O))},return(){return Ye(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Tt,n),Tt}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let o=n.logger??(l=>console.log(l)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:l=>(s==null||s.has(l))&&(i==null||!i.has(l)),d=Rr(n.theme),u=r==="stage-log"?J():0,c=l=>l==null?"":n.stageLabels?.[l]??l,h=(l,g)=>l.length>g?`${l.slice(0,g-1)}\u2026`:l,p=l=>l.type==="data"||l.type==="error"?h(We(l.data),120):"",f=l=>{if(r==="stage-log"){let w=(J()-u)/1e9,E=c(l.path).padEnd(9);if(l.type==="data"){let N=p(l);return`[${w.toFixed(3)}s] ${E} \u2190${N?` ${N}`:""}`}if(l.type==="error"){let N=p(l);return`[${w.toFixed(3)}s] ${E} \u2717${N?` ${N}`:""}`}return l.type==="complete"?`[${w.toFixed(3)}s] ${E} \u25A0 complete`:`[${w.toFixed(3)}s] ${E} ${l.type}`}if(r==="json")try{return JSON.stringify(l)}catch{return JSON.stringify({type:l.type,path:l.path,data:"[unserializable]"})}let g=d[l.type]??"",m=l.path?`${d.path}${l.path}${d.reset} `:"",b=l.type==="data"||l.type==="error",v=l.type==="pause"||l.type==="resume",y=b?` ${We(l.data)}`:v?` ${We(l.lockId)}`:"",_=l.type==="data"||l.type==="resolved"||l.type==="derived"?l:void 0,T=_?.trigger_dep_name!=null?` <- ${_.trigger_dep_name}`:_?.trigger_dep_index!=null?` <- #${_.trigger_dep_index}`:"",x=l.in_batch?" [batch]":"";return`${m}${g}${l.type.toUpperCase()}${d.reset}${y}${T}${x}`};e.onEvent(l=>{a(l.type)&&o(f(l),l)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){dn(this._disposers,this.name),this.signal([[z]],{internal:!0}),dn(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"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:d,guard:u,...c}=r.nodes[a];o[a]=c}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};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??be,{codec:o,codecVersion:s,payload:i}=Mt(e,r);return o.decode(i,s)}restore(e,n){if(ln(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(s=>Ke(s)),o=n?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let d=this.tryResolve(s)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(e,n){ln(e);let r=typeof n=="function"?n:n?.build,o=typeof n=="function"?void 0:n?.factories,s=new t(e.name);if(r)return r(s),s.restore(e),s;for(let f of[...e.subgraphs].sort((l,g)=>{let m=l.split(C).length,b=g.split(C).length;return m!==b?m-b:l<g?-1:l>g?1:0})){let l=f.split(C),g=s;for(let m of l)g._mounts.has(m)||g.mount(m,new t(m)),g=g._mounts.get(m)}let i=o?Object.entries(o).map(([f,l])=>({re:Ke(f),factory:l})):[],a=f=>{for(let l of i)if(l.re.test(f))return l.factory},d=f=>{let l=f.split(C),g=l.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${f}"`);let m=s;for(let b of l){let v=m._mounts.get(b);if(!v)throw new Error(`unknown mount "${b}" in path "${f}"`);m=v}return[m,g]},u=Object.entries(e.nodes).filter(([f])=>!f.includes(`${C}${U}${C}`)).sort((f,l)=>f[0]<l[0]?-1:f[0]>l[0]?1:0),c=new Map(u),h=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[f,l]of[...c.entries()]){let g=l?.deps??[];if(!g.every(T=>h.has(T)))continue;let[m,b]=d(f),v={...l?.meta??{}},y=a(f),_;if(l?.type==="state")_=X(l.value,{meta:v});else{if(y==null)continue;_=y(b,{path:f,type:l.type,value:l.value,meta:v,deps:g,resolvedDeps:g.map(T=>h.get(T))})}m.add(_,{name:b}),h.set(f,_),c.delete(f),p=!0}}if(c.size>0){let f=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${f}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let o=(u,c)=>{if(u.disposed)return;let h=br(c.nodes);if(u.lastSnapshot!=null&&h!==""&&h===u.lastFingerprint)return;let p=u.seq+1,f=Ce(),m=u.lastSnapshot==null||p%u.compactEvery===0?{mode:"full",snapshot:c,seq:p,timestamp_ns:f,format_version:le}:{mode:"diff",diff:bn(u.lastSnapshot,c),seq:p,timestamp_ns:f,format_version:le};if(u.tier.filter&&!u.tier.filter(this.name,m))return;let b;try{b=u.tier.save(this.name,m)}catch(v){n.onError?.(v,u.tier);return}if(b&&typeof b.then=="function"){let _=(u.savePending??Promise.resolve()).then(()=>b,()=>b).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=c,u.lastFingerprint=h)},T=>{n.onError?.(T,u.tier)});u.savePending=_.finally(()=>{u.savePending===_&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=c,u.lastFingerprint=h},s=(u,c)=>{try{o(u,c)}catch(h){n.onError?.(h,u.tier)}},i=(u,c)=>{if(!c.some(l=>{let g=this.config.messageTier(l[0]);return g>=3&&g<5}))return;if(n.filter){let l=this.tryResolve(u);if(l==null)return;let g=ft(l,Pe("standard"));if(!n.filter(u,g))return}let p,f=()=>(p==null&&(p=this.snapshot()),p);for(let l of r)l.disposed||(l.debounceMs===0?s(l,f()):(l.timer==null&&(l.timer=new ze),l.timer.start(l.debounceMs,()=>{l.disposed||s(l,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(h=>{let p=this.tryResolve(h);return p==null?()=>{}:p.subscribe(f=>i(h,f))});a=()=>{for(let h of c)h()}}else a=this.observe().subscribe((u,c)=>i(u,c));let d=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,n){for(let r of e){let o;try{o=await r.load(this.name)}catch(i){n?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===le&&s.nodes!=null)return this.restore(s),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let o of n){let s;try{s=await o.load(e)}catch(d){r?.onError?.(d,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===le&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(d){r?.onError?.(d,o)}}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 o={path:e,annotation:n,timestamp_ns:J(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(o=>!e(o)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let o of n)this._traceRing.push(o);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(n.nodes)),s=[...o].filter(v=>!r.has(v)).sort(),i=[...r].filter(v=>!o.has(v)).sort(),a=[],d=[];for(let v of r){if(!o.has(v))continue;let y=e.nodes[v],_=n.nodes[v],T=y.v,x=_.v;T!=null&&x!=null&&T.id===x.id&&T.version!==x.version&&d.push({path:v,id:T.id,from:T.version,to:x.version});let w=T!=null&&x!=null&&T.id===x.id&&T.version===x.version;for(let E of["type","status","sentinel"]){let N=y[E],A=_[E];N!==A&&a.push({path:v,field:E,from:N,to:A})}if(!w)for(let E of["value","meta"]){let N=y[E],A=_[E];yr(N,A)||a.push({path:v,field:E,from:N,to:A})}}let u=v=>`${v.from} ${v.to}`,c=new Set(e.edges.map(u)),h=new Set(n.edges.map(u)),p=n.edges.filter(v=>!c.has(u(v))),f=e.edges.filter(v=>!h.has(u(v))),l=new Set(e.subgraphs),g=new Set(n.subgraphs),m=[...g].filter(v=>!l.has(v)).sort(),b=[...l].filter(v=>!g.has(v)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:p,edgesRemoved:f,subgraphsAdded:m,subgraphsRemoved:b}}};function bn(t,e){let n=ce.diff(t,e),r={};for(let o of n.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...n,nodesAddedFull:r}}function xt(t,e,n,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,d=new Map,u=new Map,c=new Set;for(let[y,_]of Object.entries(t.nodes)){if(!y)continue;c.add(y);let T=_.deps??[];i.set(y,T);for(let x of T)x&&(c.add(x),a.has(x)||a.set(x,new Set),a.get(x).add(y))}for(let y of t.edges){if(y==null||typeof y!="object")continue;let _=typeof y.from=="string"?y.from:"",T=typeof y.to=="string"?y.to:"";!_||!T||(c.add(_),c.add(T),u.has(_)||u.set(_,new Set),u.get(_).add(T),d.has(T)||d.set(T,new Set),d.get(T).add(_))}if(!c.has(e))return r.withDetail?o:[];let h=r.both===!0,p=y=>{if(h){let w=i.get(y)??[],E=d.get(y),N=a.get(y),A=u.get(y),k=[...w];return E&&k.push(...E),N&&k.push(...N),A&&k.push(...A),k}if(n==="upstream"){let w=i.get(y)??[],E=d.get(y);return E?[...w,...E]:w}let _=a.get(y),T=u.get(y),x=_?[..._]:[];return T&&x.push(...T),x},f=new Set([e]),l=new Map,g=[{path:e,depth:0}],m=0,b=!1;for(;m<g.length;){let y=g[m++];if(s!=null&&y.depth>=s){p(y.path).length>0&&(b=!0);continue}for(let _ of p(y.path))!_||f.has(_)||(f.add(_),l.set(_,y.depth+1),g.push({path:_,depth:y.depth+1}))}let v=[...l.keys()].sort((y,_)=>y<_?-1:y>_?1:0);return r.withDetail?{paths:v,depths:l,truncated:b}:v}function Cr(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],o=e[n];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}bt();function yn(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}var Gr=2147483647;function vn(t,e){if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function wt(t,e){return yn("job_queue",t,e)}var Ue=class extends ce{_pending;_jobs;_seq=0;pending;jobs;depth;constructor(e,n={}){super(e,n.graph),this._pending=Vt([],{name:"pending"}),this._jobs=Bt({name:"jobs"}),this.pending=this._pending.items,this.jobs=this._jobs.entries,this.add(this.pending,{name:"pending"}),this.add(this.jobs,{name:"jobs"}),this.depth=te([this.pending],([r])=>r.length,{name:"depth",describeKind:"derived",meta:wt("queue_depth"),initial:0}),this.add(this.depth,{name:"depth"}),this.addDisposer(se(this.depth))}enqueue(e,n={}){let r=n.id??`${this.name}-${++this._seq}`;if(this._jobs.get(r)!==void 0)throw new Error(`jobQueue("${this.name}"): duplicate job id "${r}"`);let o={id:r,payload:e,attempts:0,metadata:Object.freeze({...n.metadata??{}}),state:"queued"};return this._jobs.set(r,o),this._pending.append(r),r}claim(e=1){let n=vn(e,"job queue claim limit");if(n===0)return[];let r=[];for(;r.length<n&&this.pending.cache.length!==0;){let s=this._pending.pop(0),i=this._jobs.get(s);if(!i||i.state!=="queued")continue;let a={...i,state:"inflight",attempts:i.attempts+1};this._jobs.set(s,a),r.push(a)}return r}ack(e){let n=this._jobs.get(e);return!n||n.state!=="inflight"?!1:(this._jobs.delete(e),!0)}nack(e,n={}){let r=this._jobs.get(e);return!r||r.state!=="inflight"?!1:n.requeue??!0?(this._jobs.set(e,{...r,state:"queued"}),this._pending.append(e),!0):(this._jobs.delete(e),!0)}},qe=class extends ce{_stageNames;_queues=new Map;_completed;completed;completedCount;constructor(e,n={}){super(e,n.graph);let r=(n.stages??["incoming","processing","done"]).map(i=>i.trim());if(r.length<2)throw new Error(`jobFlow("${e}"): requires at least 2 stages`);if(new Set(r).size!==r.length)throw new Error(`jobFlow("${e}"): stage names must be unique`);this._stageNames=Object.freeze([...r]);for(let i of this._stageNames){let a=_n(`${e}-${i}`);this._queues.set(i,a),this.mount(i,a)}this._completed=jt([],{name:"completed"}),this.completed=this._completed.entries,this.add(this.completed,{name:"completed"}),this.completedCount=te([this.completed],([i])=>i.length,{name:"completedCount",describeKind:"derived",meta:wt("job_flow_completed_count"),initial:0}),this.add(this.completedCount,{name:"completedCount"}),this.addDisposer(se(this.completedCount));let s=Math.max(1,vn(n.maxPerPump??Gr,"job flow maxPerPump"));for(let i=0;i<this._stageNames.length;i+=1){let a=this._stageNames[i],d=this.queue(a),u=i+1<this._stageNames.length?this.queue(this._stageNames[i+1]):null,c=ye([d.pending],()=>{let h=0;for(;h<s;){let p=d.claim(1);if(p.length===0)break;let f=p[0];if(!f)break;u?u.enqueue(f.payload,{metadata:{...f.metadata,job_flow_from:a}}):this._completed.append(f),d.ack(f.id),h+=1}},{name:`pump_${a}`,describeKind:"effect",meta:wt("job_flow_pump")});this.add(c,{name:`pump_${a}`}),this.addDisposer(se(c))}}stages(){return this._stageNames}queue(e){let n=this._queues.get(e);if(!n)throw new Error(`jobFlow("${this.name}"): unknown stage "${e}"`);return n}enqueue(e,n={}){return this.queue(this._stageNames[0]).enqueue(e,n)}retainedCompleted(){return this.completed.cache}};function _n(t,e){return new Ue(t,e)}function Lr(t,e){return new qe(t,e)}0&&(module.exports={JobFlowGraph,JobQueueGraph,jobFlow,jobQueue});
@@ -1,5 +1,5 @@
1
1
  import '../../node-BVV7G1bq.cjs';
2
- import '../../graph-C4Uxwv0T.cjs';
3
- export { J as JobEnvelope, a as JobFlowGraph, b as JobFlowOptions, c as JobQueueGraph, d as JobQueueOptions, e as JobState, j as jobFlow, f as jobQueue } from '../../index-CcpEvuPl.cjs';
2
+ import '../../graph-CdJeX7O7.cjs';
3
+ export { J as JobEnvelope, a as JobFlowGraph, b as JobFlowOptions, c as JobQueueGraph, d as JobQueueOptions, e as JobState, j as jobFlow, f as jobQueue } from '../../index-DUkuH3jP.cjs';
4
4
  import '../../meta-COtmHLwT.cjs';
5
5
  import '../../extra/storage-core.cjs';
@@ -1,5 +1,5 @@
1
1
  import '../../node-BVV7G1bq.js';
2
- import '../../graph-CWeI0aHd.js';
3
- export { J as JobEnvelope, a as JobFlowGraph, b as JobFlowOptions, c as JobQueueGraph, d as JobQueueOptions, e as JobState, j as jobFlow, f as jobQueue } from '../../index-FrYrV-Vf.js';
2
+ import '../../graph-BOhEGJ6E.js';
3
+ export { J as JobEnvelope, a as JobFlowGraph, b as JobFlowOptions, c as JobQueueGraph, d as JobQueueOptions, e as JobState, j as jobFlow, f as jobQueue } from '../../index-Ckl03Q0s.js';
4
4
  import '../../meta-BMwx3ExI.js';
5
5
  import '../../extra/storage-core.js';
@@ -1 +1 @@
1
- import{a,b,c,d}from"../../chunk-KN4Q5MQO.js";import"../../chunk-K54OKWNY.js";import"../../chunk-CZVYLXFK.js";import"../../chunk-7EQPXQ7H.js";import"../../chunk-4UUDNFYG.js";import"../../chunk-LWGLBCMU.js";import"../../chunk-XRSHMHEG.js";import"../../chunk-PSQNYY72.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-N2KKISCE.js";import"../../chunk-UMH3HSP7.js";import"../../chunk-7AJKUA36.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{b as JobFlowGraph,a as JobQueueGraph,d as jobFlow,c as jobQueue};
1
+ import{a,b,c,d}from"../../chunk-2RH4QNDQ.js";import"../../chunk-K54OKWNY.js";import"../../chunk-CZVYLXFK.js";import"../../chunk-MFNOZ5E6.js";import"../../chunk-4UUDNFYG.js";import"../../chunk-LWGLBCMU.js";import"../../chunk-XRSHMHEG.js";import"../../chunk-4JBKKUCJ.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-N2KKISCE.js";import"../../chunk-UMH3HSP7.js";import"../../chunk-7AJKUA36.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{b as JobFlowGraph,a as JobQueueGraph,d as jobFlow,c as jobQueue};
@@ -4,4 +4,4 @@
4
4
  `)}function rn(t){if(t.version!==ue)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${ue})`);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 fr(t,e){let n=new WeakMap,r=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=n.get(o);if(i==null&&(i=new WeakSet,n.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,l=s.constructor;if(a!==l)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let f=s;if(o.length!==f.length)return!1;for(let p=0;p<o.length;p++)if(!r(o[p],f[p]))return!1;return!0}if(o instanceof Map){let f=s;if(o.size!==f.size)return!1;for(let[p,d]of o)if(!f.has(p)||!r(d,f.get(p)))return!1;return!0}if(o instanceof Set){let f=s;if(o.size!==f.size)return!1;for(let p of o){let d=!1;for(let g of f)if(r(p,g)){d=!0;break}if(!d)return!1}return!0}if(ArrayBuffer.isView(o)){let f=o,p=s;if(f.length!==p.length)return!1;for(let d=0;d<f.length;d++)if(f[d]!==p[d])return!1;return!0}let u=Object.keys(o),c=Object.keys(s);if(u.length!==c.length)return!1;let h=new Set(c);for(let f of u)if(!h.has(f)||!r(o[f],s[f]))return!1;return!0};return r(t,e)}function bt(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(bt);let e=t,n=Object.keys(e).sort(),r={};for(let o of n)r[o]=bt(e[o]);return r}function pr(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function hr(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function gr(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function sn(t){let e=new Set,n=[];function r(o,s){let i=`${o}\0${s}`;e.has(i)||(e.add(i),n.push([o,s]))}for(let[o,s]of Object.entries(t.nodes)){let i=s.deps;if(i)for(let a of i)r(a,o)}for(let o of t.edges)r(o.from,o.to);return n}function an(t){if(t===void 0)return"LR";if(t==="TD"||t==="LR"||t==="BT"||t==="RL")return t;throw new Error(`invalid diagram direction ${String(t)}; expected one of: TD, LR, BT, RL`)}function mr(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,{expand:o,...s}=t,i={...s,edges:n?t.edges:[],subgraphs:r?t.subgraphs:[]},a=JSON.stringify(bt(i),null,e.indent??2);return e.logger?.(a),a}function yr(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,o=[];o.push(`Graph ${t.name}`),o.push("Nodes:");for(let i of Object.keys(t.nodes).sort()){let a=t.nodes[i];o.push(`- ${i} (${a.type}/${a.status}): ${Ue(a.value)}`)}if(n){o.push("Edges:");for(let i of t.edges)o.push(`- ${i.from} -> ${i.to}`)}if(r){o.push("Subgraphs:");for(let i of t.subgraphs)o.push(`- ${i}`)}let s=o.join(`
5
5
  `);return e.logger?.(s),s}function un(t,e){let n=an(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`flowchart ${n}`];for(let i of r){let a=o.get(i);s.push(` ${a}["${pr(i)}"]`)}for(let[i,a]of sn(t)){let l=o.get(i),u=o.get(a);!l||!u||s.push(` ${l} --> ${u}`)}return s.join(`
6
6
  `)}function br(t,e){let n=un(t,e);return ln(n)}function ln(t,e){let n=e?.theme??"default",r=e?.autoSync??!0,s=JSON.stringify({code:t,mermaid:{theme:n},autoSync:r}),i=new TextEncoder().encode(s),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function vr(t,e){let n=an(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`direction: ${gr(n)}`];for(let i of r){let a=o.get(i);s.push(`${a}: "${hr(i)}"`)}for(let[i,a]of sn(t)){let l=o.get(i),u=o.get(a);!l||!u||s.push(`${l} -> ${u}`)}return s.join(`
7
- `)}function _r(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function We(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 o=t.indexOf("]",n+1);if(o<=n+1){e+="\\[";continue}let s=t.slice(n+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,n=o;continue}e+=_r(r)}return e+="$",new RegExp(e)}var xr={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"},wr={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function Ue(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 Tr(t){return t==="none"?wr:t==="ansi"||t==null?xr:{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 on(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 o=t.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function yt(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(M))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${M}' (path separator)`);if(t===q)throw new Error(`Graph "${e}": ${n} name "${q}" is reserved for meta companion paths`);Or(t,e,n)}function Er(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(M);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function kr(t,e){let n=!1;for(let o of t)if(!e.isMetaPassthrough(o[0])){n=!0;break}return n?t.filter(o=>e.isMetaPassthrough(o[0])):t}function cn(t){for(let e of t._mounts.values())cn(e);for(let e of t._nodes.values())try{e.down([[V]],{internal:!0})}catch{}}var te=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(M))throw new Error(`Graph name must not contain '${M}' (got "${e}")`);if(e===q)throw new Error(`Graph name "${q}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??he,this._traceRing=new Te(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=Lt(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}add(e,n){let r=e.name,o=n?.name??r;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=n?.annotation;if(yt(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let 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(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:B()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof P&&n._applyVersioning(e)}remove(e){yt(e,this.name,"remove");let n=this._mounts.get(e);if(n){let s={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,l]of i)a.includes(`${M}${q}${M}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...n._collectSubgraphs(`${e}${M}`)),this._mounts.delete(e),n._parent=void 0,cn(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}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([[V]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let n=typeof e=="function"?e:(()=>{let s=We(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>n(s));for(let s of o){let i=this.remove(s);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 o=e[r++];return{value:[o,n.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(M))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 o=r?.internal===!0;this.node(e).down([[$,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);Ae(()=>{for(let[o,s]of r)this.set(o,s,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[J]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let o=r?.internal===!0;this.node(e).down([[I,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[X]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[l,u]of this._nodes)r.set(u,l);let a=[];for(let[l,u]of this._nodes)if(u instanceof P)for(let c of u._deps){let h=r.get(c.node);h!=null&&a.push([h,l])}return a.sort((l,u)=>l[0]<u[0]?-1:l[0]>u[0]?1:l[1]<u[1]?-1:l[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,l]of o)s.set(l,a);let i=[];for(let[a,l]of o)if(l instanceof P)for(let u of l._deps){let c=s.get(u.node);c!=null&&i.push([c,a])}return i.sort((a,l)=>a[0]<l[0]?-1:a[0]>l[0]?1:a[1]<l[1]?-1:a[1]>l[1]?1:0),i}mount(e,n){if(yt(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let n=Er(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],o=n.slice(1);if(o.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 s=this._nodes.get(r);if(s&&o.length>0&&o[0]===q)return this._resolveMetaChainFromNode(s,o,n.join(M));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(M)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(M))}_resolveMetaChainFromNode(e,n,r){let o=e,s=0,i=[...n];for(;s<i.length;){if(i[s]!==q)throw new Error(`Graph "${this.name}": expected ${q} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${q} in "${r}"`);let a=i[s+1],l=o.meta[a];if(!l)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=l,s+=2}return o}signal(e,n){if(n?.internal!==!0){for(let o of e)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,o){for(let l of this._mounts.values())l._signalDeliver(e,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=kr(e,this.config);for(let l of[...this._nodes.keys()].sort()){let u=this._nodes.get(l);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(c){if(c instanceof U)throw c;o.push(c)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,o)}}}_signalMetaSubtree(e,n,r,o,s){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,o)}catch(l){if(l instanceof U)throw l;s.push(l)}this._signalMetaSubtree(a,n,r,o,s)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,o=He(e?.detail,e?.fields),s=e?.format==="spec",i=s?He("minimal"):o,a=[];this._collectObserveTargets("",a);let l=new Map;for(let[x,w]of a)l.set(w,x);let u=[];{let x=a.map(([,k])=>k),w=new Set(l.values()),O=0;for(;x.length>0;){let k=x.shift();if(k instanceof P)for(let A of k._deps){let N=A.node;if(l.has(N))continue;let R=N.name??"",S=R;if(!S||w.has(S))if(R){let G=2;for(;w.has(`${R}#${G}`);)G++;S=`${R}#${G}`}else for(S=`__internal__/${O++}`;w.has(S);)S=`__internal__/${O++}`;l.set(N,S),w.add(S),u.push([S,N]),x.push(N)}}}let c=[...a,...u],h={};for(let[x,w]of c){if(n!=null&&!w.allowsObserve(n))continue;let O=ht(w,i),k=w instanceof P?w._deps.map(S=>l.get(S.node)??S.node.name??""):[],{name:A,...N}=O,R={...N,deps:k};if(!s){let S=this._annotations.get(x);S!=null&&(R.annotation=S)}if(r!=null)if(typeof r=="function"){let S=r;if(!(S.length>=2?S(x,R):S(R)))continue}else{let S=!0;for(let[G,H]of Object.entries(r)){let Y=G==="deps_includes"?"depsIncludes":G==="meta_has"?"metaHas":G;if(Y==="depsIncludes"){if(!R.deps.includes(String(H))){S=!1;break}continue}if(Y==="metaHas"){if(!Object.hasOwn(R.meta??{},String(H))){S=!1;break}continue}if(R[Y]!==H){S=!1;break}}if(!S)continue}h[x]=R}let f=new Set(Object.keys(h)),p=[];for(let[x,w]of c)if(w instanceof P)for(let O of w._deps){let k=l.get(O.node);k!=null&&p.push([k,x])}p.sort((x,w)=>x[0]<w[0]?-1:x[0]>w[0]?1:x[1]<w[1]?-1:x[1]>w[1]?1:0);let d=p.map(([x,w])=>({from:x,to:w}));(n!=null||r!=null)&&(d=d.filter(x=>f.has(x.from)&&f.has(x.to)));let g=this._collectSubgraphs(""),m=n!=null||r!=null?g.filter(x=>{let w=`${x}${M}`;return[...f].some(O=>O===x||O.startsWith(w))}):g,y=this,v=e,b={name:this.name,nodes:h,edges:d,subgraphs:m,expand(x){let w={...v,format:void 0};return Array.isArray(x)?(w.fields=x,w.detail=void 0):(w.detail=x,w.fields=void 0),y.describe(w)}},_=e??{},T=_.format;return T==="json"?mr(b,_):T==="pretty"?yr(b,_):T==="mermaid"?un(b,_):T==="mermaid-url"?br(b,_):T==="d2"?vr(b,_):T==="ascii"?en(b,_):b}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;n.push(o),n.push(...this._mounts.get(r)._collectSubgraphs(`${o}${M}`))}return n}resourceProfile(e){return tn(this,e)}reachable(e,n,r={}){return r.withDetail===!0?Oe(this.describe(),e,n,{...r,withDetail:!0}):Oe(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,l]of Object.entries(o.nodes))l.lastMutation!=null&&i.set(a,l.lastMutation);return Ft(o,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=ee(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,l=!1,u=()=>{a||l||(a=!0,_e(()=>{a=!1,!l&&(o+=1,s.emit(o))}))},c=i.onEvent(m=>{let y=m.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||u()}),h=[],f=new WeakSet,p=m=>{if(f.has(m)||l)return;f.add(m);let y=m.topology.subscribe(v=>{for(let b of v){if(b[0]!==$)continue;let _=b[1];if(u(),_.kind==="added"&&_.nodeKind==="mount"){let T=m._mounts.get(_.name);T!=null&&p(T)}}});h.push(y);for(let v of m._mounts.keys()){let b=m._mounts.get(v);b!=null&&p(b)}};p(this);let d;try{d=ge([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,y)=>m===y})}catch(m){c();for(let y of h)y();throw i.dispose(),m}let g=ae(d);return{node:d,dispose(){l=!0,c();for(let m of h)m();h.length=0,i.dispose(),g()}}}_explainReactive(e,n,r){let o=0,s=ee(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,l=!1,u=i.onEvent(p=>{let d=p.type;d!=="data"&&d!=="error"&&d!=="complete"&&d!=="teardown"||a||l||(a=!0,_e(()=>{a=!1,!l&&(o+=1,s.emit(o))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},h;try{h=ge([s],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(p,d)=>p.found===d.found&&p.reason===d.reason&&p.steps.length===d.steps.length&&Nr(p.steps,d.steps)})}catch(p){throw u(),i.dispose(),p}let f=ae(h);return{node:h,dispose(){l=!0,u(),i.dispose(),f()}}}_pathsMatching(e){let n=We(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>n.test(o))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${M}${r}`;this._mounts.get(r)._collectObserveTargets(o,n)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${M}${r}`;n.push([s,o]),this._appendMetaObserveTargets(s,o,n)}}_appendMetaObserveTargets(e,n,r){for(let o of Object.keys(n.meta).sort()){let s=n.meta[o],i=`${e}${M}${q}${M}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,n){let r=typeof e=="string",s=on(r?n:e),i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let c=e,h=this.resolve(c);if(a!=null&&!h.allowsObserve(a))throw new U({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,h]],s,"one"):{subscribe(f){return h.subscribe(f)},up(f){try{h.up?.(f)}catch(p){if(p instanceof U)return;throw p}}}}let l=[];this._collectObserveTargets("",l),l.sort((c,h)=>c[0]<h[0]?-1:c[0]>h[0]?1:0);let u=a==null?l:l.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:c=>{let h=u.map(([f,p])=>p.subscribe(d=>{c(f,d)}));return()=>{for(let f of h)f()}},up:(c,h)=>{try{this.resolve(c).up?.(h)}catch(f){if(f instanceof U)return;throw f}}}}_buildStructuredObserver(e,n,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let c=this.resolve(o);return this._buildStructuredObserver([[o,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,h)=>c[0]<h[0]?-1:c[0]>h[0]?1:0);let l=i.actor,u=l==null?a:a.filter(([,c])=>c.allowsObserve(l));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,s)}_createObserveResult(e,n,r){let o=n.timeline===!0,s=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",l=this.config.inspectorEnabled,u=(s||i)&&l,c=n.maxEvents,h=c!=null&&c>0?new Te(c):null,f=[],p=new Set,d={},g=new Set,m=0,y=0,v=0,b=0,_=0,T=0,x=!1,w=!1,O=0,k=new Map,A=new Map,N=new Map,R=E=>{h?h.push(E):f.push(E);for(let C of p)C(E)},S=()=>o?{timestamp_ns:B(),in_batch:Re(),batch_id:O}:{},G=(E,C)=>{if(!(!u||!(E instanceof P)))return E._setInspectorHook(j=>{if(j.kind==="dep_message")k.set(E,j.depIndex);else if(j.kind==="run"){let me=j.batchData.map((D,F)=>D!=null&&D.length>0?D.at(-1):j.prevData[F]);A.set(E,me);let z=j.batchData.map(D=>D!=null?[...D]:void 0);N.set(E,z),i&&R({type:"derived",path:C,dep_values:me,dep_batches:z,...S()})}})},H=E=>{let C=k.get(E),j=A.get(E);if(!s||j==null)return{};let z=(C!=null&&C>=0&&E instanceof P?E._deps[C]:void 0)?.node,D=z?.v,F=N.get(E);return{trigger_dep_index:C,trigger_dep_name:z?.name,...D!=null?{trigger_version:{id:D.id,version:D.version}}:{},dep_values:[...j],...F!=null?{dep_batches:F}:{}}},Y=[],oe=[];for(let[E,C]of e){let j=G(C,E);j&&Y.push(j),oe.push(C.subscribe(me=>{O++;for(let z of me){let D=z[0],F=S();if(D===$){d[E]=z[1];let Ze=C instanceof P?C.lastMutation?.actor??le:le;R({type:"data",path:E,data:z[1],actor:Ze,...F,...H(C)})}else if(a)D===W?m++:D===Z?y++:D===J?v++:D===Q?b++:D===ne?_++:D===V?T++:D===X&&!g.has(E)?x=!0:D===I&&(w=!0,g.add(E));else if(D===W)m++,R({type:"dirty",path:E,...F});else if(D===Z)y++,R({type:"resolved",path:E,...F,...H(C)});else if(D===J)v++,R({type:"invalidate",path:E,...F});else if(D===Q)b++,R({type:"pause",path:E,lockId:z[1],...F});else if(D===ne)_++,R({type:"resume",path:E,lockId:z[1],...F});else if(D===X)g.has(E)||(x=!0),R({type:"complete",path:E,...F});else if(D===I){w=!0,g.add(E);let Ze=C instanceof P?C.lastMutation?.actor??le:le;R({type:"error",path:E,data:z[1],actor:Ze,...F})}else D===V&&(T++,R({type:"teardown",path:E,...F}))}}))}let Ye=!1,Je=()=>{if(!Ye){Ye=!0;for(let E of oe)E();for(let E of Y)E();for(let E of ke)E({value:void 0,done:!0});ke.length=0}},Xe=[],ke=[];p.add(E=>{let C=ke.shift();C?C({value:E,done:!1}):Xe.push(E)});let vt={get values(){return d},get dirtyCount(){return m},get resolvedCount(){return y},get invalidateCount(){return v},get pauseCount(){return b},get resumeCount(){return _},get teardownCount(){return T},get events(){return h?h.toArray():[...f]},get anyCompletedCleanly(){return x},get anyErrored(){return w},get completedWithoutErrors(){return x&&!w},onEvent(E){return p.add(E),()=>p.delete(E)},dispose:Je,expand(E){Je();let C={...n};return typeof E=="string"?C.detail=E:Object.assign(C,E),r(on(C))},[Symbol.asyncIterator](){return{next(){return Xe.length>0?Promise.resolve({value:Xe.shift(),done:!1}):Ye?Promise.resolve({value:void 0,done:!0}):new Promise(E=>ke.push(E))},return(){return Je(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(vt,n),vt}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let o=n.logger??(d=>console.log(d)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:d=>(s==null||s.has(d))&&(i==null||!i.has(d)),l=Tr(n.theme),u=r==="stage-log"?B():0,c=d=>d==null?"":n.stageLabels?.[d]??d,h=(d,g)=>d.length>g?`${d.slice(0,g-1)}\u2026`:d,f=d=>d.type==="data"||d.type==="error"?h(Ue(d.data),120):"",p=d=>{if(r==="stage-log"){let w=(B()-u)/1e9,O=c(d.path).padEnd(9);if(d.type==="data"){let k=f(d);return`[${w.toFixed(3)}s] ${O} \u2190${k?` ${k}`:""}`}if(d.type==="error"){let k=f(d);return`[${w.toFixed(3)}s] ${O} \u2717${k?` ${k}`:""}`}return d.type==="complete"?`[${w.toFixed(3)}s] ${O} \u25A0 complete`:`[${w.toFixed(3)}s] ${O} ${d.type}`}if(r==="json")try{return JSON.stringify(d)}catch{return JSON.stringify({type:d.type,path:d.path,data:"[unserializable]"})}let g=l[d.type]??"",m=d.path?`${l.path}${d.path}${l.reset} `:"",y=d.type==="data"||d.type==="error",v=d.type==="pause"||d.type==="resume",b=y?` ${Ue(d.data)}`:v?` ${Ue(d.lockId)}`:"",_=d.type==="data"||d.type==="resolved"||d.type==="derived"?d:void 0,T=_?.trigger_dep_name!=null?` <- ${_.trigger_dep_name}`:_?.trigger_dep_index!=null?` <- #${_.trigger_dep_index}`:"",x=d.in_batch?" [batch]":"";return`${m}${g}${d.type.toUpperCase()}${l.reset}${b}${T}${x}`};e.onEvent(d=>{a(d.type)&&o(p(d),d)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){nn(this._disposers,this.name),this.signal([[V]],{internal:!0}),nn(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}snapshot(e){let{expand:n,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:l,guard:u,...c}=r.nodes[a];o[a]=c}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};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 xt(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??he,{codec:o,codecVersion:s,payload:i}=wt(e,r);return o.decode(i,s)}restore(e,n){if(rn(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(s=>We(s)),o=n?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let l=this.tryResolve(s)?.v;if(l!=null&&l.id===i.v.id&&l.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(e,n){rn(e);let r=typeof n=="function"?n:n?.build,o=typeof n=="function"?void 0:n?.factories,s=new t(e.name);if(r)return r(s),s.restore(e),s;for(let p of[...e.subgraphs].sort((d,g)=>{let m=d.split(M).length,y=g.split(M).length;return m!==y?m-y:d<g?-1:d>g?1:0})){let d=p.split(M),g=s;for(let m of d)g._mounts.has(m)||g.mount(m,new t(m)),g=g._mounts.get(m)}let i=o?Object.entries(o).map(([p,d])=>({re:We(p),factory:d})):[],a=p=>{for(let d of i)if(d.re.test(p))return d.factory},l=p=>{let d=p.split(M),g=d.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${p}"`);let m=s;for(let y of d){let v=m._mounts.get(y);if(!v)throw new Error(`unknown mount "${y}" in path "${p}"`);m=v}return[m,g]},u=Object.entries(e.nodes).filter(([p])=>!p.includes(`${M}${q}${M}`)).sort((p,d)=>p[0]<d[0]?-1:p[0]>d[0]?1:0),c=new Map(u),h=new Map,f=!0;for(;c.size>0&&f;){f=!1;for(let[p,d]of[...c.entries()]){let g=d?.deps??[];if(!g.every(T=>h.has(T)))continue;let[m,y]=l(p),v={...d?.meta??{}},b=a(p),_;if(d?.type==="state")_=ee(d.value,{meta:v});else{if(b==null)continue;_=b(y,{path:p,type:d.type,value:d.value,meta:v,deps:g,resolvedDeps:g.map(T=>h.get(T))})}m.add(_,{name:y}),h.set(p,_),c.delete(p),f=!0}}if(c.size>0){let p=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${p}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let o=(u,c)=>{if(u.disposed)return;let h=dr(c.nodes);if(u.lastSnapshot!=null&&h!==""&&h===u.lastFingerprint)return;let f=u.seq+1,p=Ne(),m=u.lastSnapshot==null||f%u.compactEvery===0?{mode:"full",snapshot:c,seq:f,timestamp_ns:p,format_version:ue}:{mode:"diff",diff:dn(u.lastSnapshot,c),seq:f,timestamp_ns:p,format_version:ue};if(u.tier.filter&&!u.tier.filter(this.name,m))return;let y;try{y=u.tier.save(this.name,m)}catch(v){n.onError?.(v,u.tier);return}if(y&&typeof y.then=="function"){let _=(u.savePending??Promise.resolve()).then(()=>y,()=>y).then(()=>{u.disposed||(u.seq=f,u.lastSnapshot=c,u.lastFingerprint=h)},T=>{n.onError?.(T,u.tier)});u.savePending=_.finally(()=>{u.savePending===_&&(u.savePending=void 0)})}else u.seq=f,u.lastSnapshot=c,u.lastFingerprint=h},s=(u,c)=>{try{o(u,c)}catch(h){n.onError?.(h,u.tier)}},i=(u,c)=>{if(!c.some(d=>{let g=this.config.messageTier(d[0]);return g>=3&&g<5}))return;if(n.filter){let d=this.tryResolve(u);if(d==null)return;let g=ht(d,He("standard"));if(!n.filter(u,g))return}let f,p=()=>(f==null&&(f=this.snapshot()),f);for(let d of r)d.disposed||(d.debounceMs===0?s(d,p()):(d.timer==null&&(d.timer=new Be),d.timer.start(d.debounceMs,()=>{d.disposed||s(d,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(h=>{let f=this.tryResolve(h);return f==null?()=>{}:f.subscribe(p=>i(h,p))});a=()=>{for(let h of c)h()}}else a=this.observe().subscribe((u,c)=>i(u,c));let l=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(l)};return this._storageDisposers.add(l),{dispose:l}}async _cascadeRestore(e,n){for(let r of e){let o;try{o=await r.load(this.name)}catch(i){n?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===ue&&s.nodes!=null)return this.restore(s),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let o of n){let s;try{s=await o.load(e)}catch(l){r?.onError?.(l,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===ue&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(l){r?.onError?.(l,o)}}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 o={path:e,annotation:n,timestamp_ns:B(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(o=>!e(o)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let o of n)this._traceRing.push(o);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(n.nodes)),s=[...o].filter(v=>!r.has(v)).sort(),i=[...r].filter(v=>!o.has(v)).sort(),a=[],l=[];for(let v of r){if(!o.has(v))continue;let b=e.nodes[v],_=n.nodes[v],T=b.v,x=_.v;T!=null&&x!=null&&T.id===x.id&&T.version!==x.version&&l.push({path:v,id:T.id,from:T.version,to:x.version});let w=T!=null&&x!=null&&T.id===x.id&&T.version===x.version;for(let O of["type","status","sentinel"]){let k=b[O],A=_[O];k!==A&&a.push({path:v,field:O,from:k,to:A})}if(!w)for(let O of["value","meta"]){let k=b[O],A=_[O];fr(k,A)||a.push({path:v,field:O,from:k,to:A})}}let u=v=>`${v.from} ${v.to}`,c=new Set(e.edges.map(u)),h=new Set(n.edges.map(u)),f=n.edges.filter(v=>!c.has(u(v))),p=e.edges.filter(v=>!h.has(u(v))),d=new Set(e.subgraphs),g=new Set(n.subgraphs),m=[...g].filter(v=>!d.has(v)).sort(),y=[...d].filter(v=>!g.has(v)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:l,edgesAdded:f,edgesRemoved:p,subgraphsAdded:m,subgraphsRemoved:y}}};function dn(t,e){let n=te.diff(t,e),r={};for(let o of n.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...n,nodesAddedFull:r}}function Oe(t,e,n,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,l=new Map,u=new Map,c=new Set;for(let[b,_]of Object.entries(t.nodes)){if(!b)continue;c.add(b);let T=_.deps??[];i.set(b,T);for(let x of T)x&&(c.add(x),a.has(x)||a.set(x,new Set),a.get(x).add(b))}for(let b of t.edges){if(b==null||typeof b!="object")continue;let _=typeof b.from=="string"?b.from:"",T=typeof b.to=="string"?b.to:"";!_||!T||(c.add(_),c.add(T),u.has(_)||u.set(_,new Set),u.get(_).add(T),l.has(T)||l.set(T,new Set),l.get(T).add(_))}if(!c.has(e))return r.withDetail?o:[];let h=r.both===!0,f=b=>{if(h){let w=i.get(b)??[],O=l.get(b),k=a.get(b),A=u.get(b),N=[...w];return O&&N.push(...O),k&&N.push(...k),A&&N.push(...A),N}if(n==="upstream"){let w=i.get(b)??[],O=l.get(b);return O?[...w,...O]:w}let _=a.get(b),T=u.get(b),x=_?[..._]:[];return T&&x.push(...T),x},p=new Set([e]),d=new Map,g=[{path:e,depth:0}],m=0,y=!1;for(;m<g.length;){let b=g[m++];if(s!=null&&b.depth>=s){f(b.path).length>0&&(y=!0);continue}for(let _ of f(b.path))!_||p.has(_)||(p.add(_),d.set(_,b.depth+1),g.push({path:_,depth:b.depth+1}))}let v=[...d.keys()].sort((b,_)=>b<_?-1:b>_?1:0);return r.withDetail?{paths:v,depths:d,truncated:y}:v}function Nr(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],o=e[n];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}pe();function Ee(t,e){let n=new Map,r=(o,s)=>{if(n.has(o))return;let i={off:()=>{},prefix:s};n.set(o,i);let a=o.topology.subscribe(l=>{for(let u of l){if(u[0]!==$)continue;let c=u[1];if(e(c,o,s),c.kind==="added"&&c.nodeKind==="mount"){let h=o._mounts.get(c.name);if(h instanceof te){let f=`${s}${c.name}::`;r(h,f)}}else if(c.kind==="removed"&&c.nodeKind==="mount"){let h=`${s}${c.name}::`;for(let[f,p]of Array.from(n.entries()))f!==t&&p.prefix.startsWith(h)&&(p.off(),n.delete(f))}}});i.off=a;for(let[l,u]of o._mounts)if(u instanceof te){let c=`${s}${l}::`;r(u,c)}};return r(t,""),()=>{for(let o of n.values())o.off();n.clear()}}gt();function fn(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}function pn(t,e,n,r){return t.explain(e,n,{reactive:!0,...r})}function hn(t){return fn("lens",t)}function Sr(t){let e=Object.keys(t.nodes),n=new Map,r=new Map;for(let g of e){let m=t.nodes[g]?.deps??[];n.set(g,m);for(let y of m)r.has(y)||r.set(y,new Set),r.get(y).add(g)}let o=[],s=[];for(let g of e)(n.get(g)??[]).length===0&&o.push(g),r.has(g)||s.push(g);o.sort(),s.sort();let i=t.edges.length,a=0,l=1,u=2,c=new Map;for(let g of e)c.set(g,a);let h=!1,f=new Map,p=g=>{let m=c.get(g)??a;if(m===l)return h=!0,0;if(m===u)return f.get(g)??0;c.set(g,l);let y=0,v=r.get(g);if(v!=null)for(let b of v){let _=p(b);_+1>y&&(y=_+1)}return c.set(g,u),f.set(g,y),y},d=0;for(let g of o){let m=p(g);m>d&&(d=m)}for(let g of e)c.get(g)===a&&p(g);return{nodeCount:e.length,edgeCount:i,subgraphCount:t.subgraphs.length,sources:o,sinks:s,depth:d,hasCycles:h}}function Rr(t){let e=[];for(let[n,r]of Object.entries(t.nodes)){if(r.status!=="errored")continue;let o={path:n,status:"errored"},s=Oe(t,n,"upstream",{});for(let i of s)if(i!==n&&t.nodes[i]?.status==="errored"){o.upstreamCause=i;break}e.push(o)}return e.sort((n,r)=>n.path<r.path?-1:n.path>r.path?1:0),{ok:e.length===0,problems:e}}function Ar(t,e){return t.nodeCount===e.nodeCount&&t.edgeCount===e.edgeCount&&t.subgraphCount===e.subgraphCount&&t.depth===e.depth&&t.hasCycles===e.hasCycles&&gn(t.sources,e.sources)&&gn(t.sinks,e.sinks)}function Dr(t,e){if(t.ok!==e.ok||t.problems.length!==e.problems.length)return!1;for(let n=0;n<t.problems.length;n++){let r=t.problems[n],o=e.problems[n];if(r.path!==o.path||r.status!==o.status||r.upstreamCause!==o.upstreamCause)return!1}return!0}function gn(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}var qe=class extends te{stats;health;flow;_target;constructor(e,n={}){super(n.name??`${e.name}_lens`,n.graph),this._target=e;let r=0,o=0,s=ee(0,{name:"stats_tick"}),i=ee(0,{name:"health_tick"});this.add(s,{name:"stats_tick"}),this.add(i,{name:"health_tick"});let a={name:"flow"};n.maxFlowPaths!=null&&(a.maxSize=n.maxFlowPaths),this.flow=It(a),this.add(this.flow.entries,{name:"flow"});let l=n.pathFilter,u=Ee(e,(f,p,d)=>{if(r+=1,s.emit(r),o+=1,i.emit(o),f.kind==="removed")if(f.nodeKind==="node"){let g=`${d}${f.name}`;this.flow.delete(g)}else{let g=`${d}${f.name}::`,m=[];for(let y of f.audit.nodes){let v=y===""?`${d}${f.name}`:`${g}${y}`;m.push(v)}m.length>0&&this.flow.deleteMany(m)}});this.addDisposer(u);let c=e.observe({timeline:!0,structured:!0}),h=c.onEvent(f=>{let p=f.type;if((p==="error"||p==="complete"||p==="data"||p==="teardown")&&(o+=1,i.emit(o)),p==="data"){let d=f.path??"";if(!d||l!=null&&!l(d))return;let g=this.flow.get(d),m=g!=null?g.count+1:1;this.flow.set(d,{path:d,count:m,lastUpdate_ns:B()})}});this.addDisposer(()=>{h(),c.dispose()}),this.stats=ge([s],()=>Sr(e.describe({detail:"minimal"})),{name:"stats",describeKind:"derived",equals:Ar,meta:hn("stats")}),this.add(this.stats,{name:"stats"}),this.addDisposer(ae(this.stats)),this.health=ge([i],()=>Rr(e.describe({detail:"standard"})),{name:"health",describeKind:"derived",equals:Dr,meta:hn("health")}),this.add(this.health,{name:"health"}),this.addDisposer(ae(this.health))}why(e,n,r){let o=pn(this._target,e,n,r);return this.addDisposer(o.dispose),o}get target(){return this._target}};function Cr(t,e){return new qe(t,e)}0&&(module.exports={LensGraph,graphLens,watchTopologyTree});
7
+ `)}function _r(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function We(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 o=t.indexOf("]",n+1);if(o<=n+1){e+="\\[";continue}let s=t.slice(n+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,n=o;continue}e+=_r(r)}return e+="$",new RegExp(e)}var xr={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"},wr={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function Ue(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 Tr(t){return t==="none"?wr:t==="ansi"||t==null?xr:{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 on(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 o=t.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function yt(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(M))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${M}' (path separator)`);if(t===q)throw new Error(`Graph "${e}": ${n} name "${q}" is reserved for meta companion paths`);Or(t,e,n)}function Er(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(M);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function kr(t,e){let n=!1;for(let o of t)if(!e.isMetaPassthrough(o[0])){n=!0;break}return n?t.filter(o=>e.isMetaPassthrough(o[0])):t}function cn(t){for(let e of t._mounts.values())cn(e);for(let e of t._nodes.values())try{e.down([[V]],{internal:!0})}catch{}}var te=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(M))throw new Error(`Graph name must not contain '${M}' (got "${e}")`);if(e===q)throw new Error(`Graph name "${q}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??he,this._traceRing=new Te(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=Lt(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}add(e,n){let r=e.name,o=n?.name??r;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=n?.annotation;if(yt(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let 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(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:B()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof P&&n._applyVersioning(e)}remove(e){yt(e,this.name,"remove");let n=this._mounts.get(e);if(n){let s={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,l]of i)a.includes(`${M}${q}${M}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...n._collectSubgraphs(`${e}${M}`)),this._mounts.delete(e),n._parent=void 0,cn(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}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([[V]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let n=typeof e=="function"?e:(()=>{let s=We(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>n(s));for(let s of o){let i=this.remove(s);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 o=e[r++];return{value:[o,n.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(M))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 o=r?.internal===!0;this.node(e).down([[$,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);Ae(()=>{for(let[o,s]of r)this.set(o,s,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[J]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let o=r?.internal===!0;this.node(e).down([[I,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[X]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[l,u]of this._nodes)r.set(u,l);let a=[];for(let[l,u]of this._nodes)if(u instanceof P)for(let c of u._deps){let h=r.get(c.node);h!=null&&a.push([h,l])}return a.sort((l,u)=>l[0]<u[0]?-1:l[0]>u[0]?1:l[1]<u[1]?-1:l[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,l]of o)s.set(l,a);let i=[];for(let[a,l]of o)if(l instanceof P)for(let u of l._deps){let c=s.get(u.node);c!=null&&i.push([c,a])}return i.sort((a,l)=>a[0]<l[0]?-1:a[0]>l[0]?1:a[1]<l[1]?-1:a[1]>l[1]?1:0),i}mount(e,n){if(yt(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let n=Er(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],o=n.slice(1);if(o.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 s=this._nodes.get(r);if(s&&o.length>0&&o[0]===q)return this._resolveMetaChainFromNode(s,o,n.join(M));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(M)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(M))}_resolveMetaChainFromNode(e,n,r){let o=e,s=0,i=[...n];for(;s<i.length;){if(i[s]!==q)throw new Error(`Graph "${this.name}": expected ${q} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${q} in "${r}"`);let a=i[s+1],l=o.meta[a];if(!l)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=l,s+=2}return o}signal(e,n){if(n?.internal!==!0){for(let o of e)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,o){for(let l of this._mounts.values())l._signalDeliver(e,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=kr(e,this.config);for(let l of[...this._nodes.keys()].sort()){let u=this._nodes.get(l);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(c){if(c instanceof U)throw c;o.push(c)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,o)}}}_signalMetaSubtree(e,n,r,o,s){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,o)}catch(l){if(l instanceof U)throw l;s.push(l)}this._signalMetaSubtree(a,n,r,o,s)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,o=He(e?.detail,e?.fields),s=e?.format==="spec",i=s?He("minimal"):o,a=[];this._collectObserveTargets("",a);let l=new Map;for(let[x,w]of a)l.set(w,x);let u=[];{let x=a.map(([,k])=>k),w=new Set(l.values()),O=0;for(;x.length>0;){let k=x.shift();if(k instanceof P)for(let A of k._deps){let N=A.node;if(l.has(N))continue;let R=N.name??"",S=R;if(!S||w.has(S))if(R){let G=2;for(;w.has(`${R}#${G}`);)G++;S=`${R}#${G}`}else for(S=`__internal__/${O++}`;w.has(S);)S=`__internal__/${O++}`;l.set(N,S),w.add(S),u.push([S,N]),x.push(N)}}}let c=[...a,...u],h={};for(let[x,w]of c){if(n!=null&&!w.allowsObserve(n))continue;let O=ht(w,i),k=w instanceof P?w._deps.map(S=>l.get(S.node)??S.node.name??""):[],{name:A,...N}=O,R={...N,deps:k};if(!s){let S=this._annotations.get(x);S!=null&&(R.annotation=S)}if(r!=null)if(typeof r=="function"){let S=r;if(!(S.length>=2?S(x,R):S(R)))continue}else{let S=!0;for(let[G,H]of Object.entries(r)){let Y=G==="deps_includes"?"depsIncludes":G==="meta_has"?"metaHas":G;if(Y==="depsIncludes"){if(!R.deps.includes(String(H))){S=!1;break}continue}if(Y==="metaHas"){if(!Object.hasOwn(R.meta??{},String(H))){S=!1;break}continue}if(R[Y]!==H){S=!1;break}}if(!S)continue}h[x]=R}let f=new Set(Object.keys(h)),p=[];for(let[x,w]of c)if(w instanceof P)for(let O of w._deps){let k=l.get(O.node);k!=null&&p.push([k,x])}p.sort((x,w)=>x[0]<w[0]?-1:x[0]>w[0]?1:x[1]<w[1]?-1:x[1]>w[1]?1:0);let d=p.map(([x,w])=>({from:x,to:w}));(n!=null||r!=null)&&(d=d.filter(x=>f.has(x.from)&&f.has(x.to)));let g=this._collectSubgraphs(""),m=n!=null||r!=null?g.filter(x=>{let w=`${x}${M}`;return[...f].some(O=>O===x||O.startsWith(w))}):g,y=this,v=e,b={name:this.name,nodes:h,edges:d,subgraphs:m,expand(x){let w={...v,format:void 0};return Array.isArray(x)?(w.fields=x,w.detail=void 0):(w.detail=x,w.fields=void 0),y.describe(w)}},_=e??{},T=_.format;return T==="json"?mr(b,_):T==="pretty"?yr(b,_):T==="mermaid"?un(b,_):T==="mermaid-url"?br(b,_):T==="d2"?vr(b,_):T==="ascii"?en(b,_):b}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;n.push(o),n.push(...this._mounts.get(r)._collectSubgraphs(`${o}${M}`))}return n}resourceProfile(e){return tn(this,e)}reachable(e,n,r={}){return r.withDetail===!0?Oe(this.describe(),e,n,{...r,withDetail:!0}):Oe(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,l]of Object.entries(o.nodes))l.lastMutation!=null&&i.set(a,l.lastMutation);return Ft(o,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=ee(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,l=!1,u=()=>{a||l||(a=!0,_e(()=>{a=!1,!l&&(o+=1,s.emit(o))}))},c=i.onEvent(m=>{let y=m.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||u()}),h=[],f=new WeakSet,p=m=>{if(f.has(m)||l)return;f.add(m);let y=m.topology.subscribe(v=>{for(let b of v){if(b[0]!==$)continue;let _=b[1];if(u(),_.kind==="added"&&_.nodeKind==="mount"){let T=m._mounts.get(_.name);T!=null&&p(T)}}});h.push(y);for(let v of m._mounts.keys()){let b=m._mounts.get(v);b!=null&&p(b)}};p(this);let d;try{d=ge([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,y)=>m===y})}catch(m){c();for(let y of h)y();throw i.dispose(),m}let g=ae(d);return{node:d,dispose(){l=!0,c();for(let m of h)m();h.length=0,i.dispose(),g()}}}_explainReactive(e,n,r){let o=0,s=ee(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,l=!1,u=i.onEvent(p=>{let d=p.type;d!=="data"&&d!=="error"&&d!=="complete"&&d!=="teardown"||a||l||(a=!0,_e(()=>{a=!1,!l&&(o+=1,s.emit(o))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},h;try{h=ge([s],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(p,d)=>p.found===d.found&&p.reason===d.reason&&p.steps.length===d.steps.length&&Nr(p.steps,d.steps)})}catch(p){throw u(),i.dispose(),p}let f=ae(h);return{node:h,dispose(){l=!0,u(),i.dispose(),f()}}}_pathsMatching(e){let n=We(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>n.test(o))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${M}${r}`;this._mounts.get(r)._collectObserveTargets(o,n)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${M}${r}`;n.push([s,o]),this._appendMetaObserveTargets(s,o,n)}}_appendMetaObserveTargets(e,n,r){for(let o of Object.keys(n.meta).sort()){let s=n.meta[o],i=`${e}${M}${q}${M}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,n){let r=typeof e=="string",s=on(r?n:e),i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let c=e,h=this.resolve(c);if(a!=null&&!h.allowsObserve(a))throw new U({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,h]],s,"one"):{subscribe(f){return h.subscribe(f)},up(f){try{h.up?.(f)}catch(p){if(p instanceof U)return;throw p}}}}let l=[];this._collectObserveTargets("",l),l.sort((c,h)=>c[0]<h[0]?-1:c[0]>h[0]?1:0);let u=a==null?l:l.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:c=>{let h=u.map(([f,p])=>p.subscribe(d=>{c(f,d)}));return()=>{for(let f of h)f()}},up:(c,h)=>{try{this.resolve(c).up?.(h)}catch(f){if(f instanceof U)return;throw f}}}}_buildStructuredObserver(e,n,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let c=this.resolve(o);return this._buildStructuredObserver([[o,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,h)=>c[0]<h[0]?-1:c[0]>h[0]?1:0);let l=i.actor,u=l==null?a:a.filter(([,c])=>c.allowsObserve(l));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,s)}_createObserveResult(e,n,r){let o=n.timeline===!0,s=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",l=this.config.inspectorEnabled,u=(s||i)&&l,c=n.maxEvents,h=c!=null&&c>0?new Te(c):null,f=[],p=new Set,d={},g=new Set,m=0,y=0,v=0,b=0,_=0,T=0,x=!1,w=!1,O=0,k=new Map,A=new Map,N=new Map,R=E=>{h?h.push(E):f.push(E);for(let C of p)C(E)},S=()=>o?{timestamp_ns:B(),in_batch:Re(),batch_id:O}:{},G=(E,C)=>{if(!(!u||!(E instanceof P)))return E._setInspectorHook(j=>{if(j.kind==="dep_message")k.set(E,j.depIndex);else if(j.kind==="run"){let me=j.batchData.map((D,F)=>D!=null&&D.length>0?D.at(-1):j.prevData[F]);A.set(E,me);let z=j.batchData.map(D=>D!=null?[...D]:void 0);N.set(E,z),i&&R({type:"derived",path:C,dep_values:me,dep_batches:z,...S()})}})},H=E=>{let C=k.get(E),j=A.get(E);if(!s||j==null)return{};let z=(C!=null&&C>=0&&E instanceof P?E._deps[C]:void 0)?.node,D=z?.v,F=N.get(E);return{trigger_dep_index:C,trigger_dep_name:z?.name,...D!=null?{trigger_version:{id:D.id,version:D.version}}:{},dep_values:[...j],...F!=null?{dep_batches:F}:{}}},Y=[],oe=[];for(let[E,C]of e){let j=G(C,E);j&&Y.push(j),oe.push(C.subscribe(me=>{O++;for(let z of me){let D=z[0],F=S();if(D===$){d[E]=z[1];let Ze=C instanceof P?C.lastMutation?.actor??le:le;R({type:"data",path:E,data:z[1],actor:Ze,...F,...H(C)})}else if(a)D===W?m++:D===Z?y++:D===J?v++:D===Q?b++:D===ne?_++:D===V?T++:D===X&&!g.has(E)?x=!0:D===I&&(w=!0,g.add(E));else if(D===W)m++,R({type:"dirty",path:E,...F});else if(D===Z)y++,R({type:"resolved",path:E,...F,...H(C)});else if(D===J)v++,R({type:"invalidate",path:E,...F});else if(D===Q)b++,R({type:"pause",path:E,lockId:z[1],...F});else if(D===ne)_++,R({type:"resume",path:E,lockId:z[1],...F});else if(D===X)g.has(E)||(x=!0),R({type:"complete",path:E,...F});else if(D===I){w=!0,g.add(E);let Ze=C instanceof P?C.lastMutation?.actor??le:le;R({type:"error",path:E,data:z[1],actor:Ze,...F})}else D===V&&(T++,R({type:"teardown",path:E,...F}))}}))}let Ye=!1,Je=()=>{if(!Ye){Ye=!0;for(let E of oe)E();for(let E of Y)E();for(let E of ke)E({value:void 0,done:!0});ke.length=0}},Xe=[],ke=[];p.add(E=>{let C=ke.shift();C?C({value:E,done:!1}):Xe.push(E)});let vt={get values(){return d},get dirtyCount(){return m},get resolvedCount(){return y},get invalidateCount(){return v},get pauseCount(){return b},get resumeCount(){return _},get teardownCount(){return T},get events(){return h?h.toArray():[...f]},get anyCompletedCleanly(){return x},get anyErrored(){return w},get completedWithoutErrors(){return x&&!w},onEvent(E){return p.add(E),()=>p.delete(E)},dispose:Je,expand(E){Je();let C={...n};return typeof E=="string"?C.detail=E:Object.assign(C,E),r(on(C))},[Symbol.asyncIterator](){return{next(){return Xe.length>0?Promise.resolve({value:Xe.shift(),done:!1}):Ye?Promise.resolve({value:void 0,done:!0}):new Promise(E=>ke.push(E))},return(){return Je(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(vt,n),vt}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let o=n.logger??(d=>console.log(d)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:d=>(s==null||s.has(d))&&(i==null||!i.has(d)),l=Tr(n.theme),u=r==="stage-log"?B():0,c=d=>d==null?"":n.stageLabels?.[d]??d,h=(d,g)=>d.length>g?`${d.slice(0,g-1)}\u2026`:d,f=d=>d.type==="data"||d.type==="error"?h(Ue(d.data),120):"",p=d=>{if(r==="stage-log"){let w=(B()-u)/1e9,O=c(d.path).padEnd(9);if(d.type==="data"){let k=f(d);return`[${w.toFixed(3)}s] ${O} \u2190${k?` ${k}`:""}`}if(d.type==="error"){let k=f(d);return`[${w.toFixed(3)}s] ${O} \u2717${k?` ${k}`:""}`}return d.type==="complete"?`[${w.toFixed(3)}s] ${O} \u25A0 complete`:`[${w.toFixed(3)}s] ${O} ${d.type}`}if(r==="json")try{return JSON.stringify(d)}catch{return JSON.stringify({type:d.type,path:d.path,data:"[unserializable]"})}let g=l[d.type]??"",m=d.path?`${l.path}${d.path}${l.reset} `:"",y=d.type==="data"||d.type==="error",v=d.type==="pause"||d.type==="resume",b=y?` ${Ue(d.data)}`:v?` ${Ue(d.lockId)}`:"",_=d.type==="data"||d.type==="resolved"||d.type==="derived"?d:void 0,T=_?.trigger_dep_name!=null?` <- ${_.trigger_dep_name}`:_?.trigger_dep_index!=null?` <- #${_.trigger_dep_index}`:"",x=d.in_batch?" [batch]":"";return`${m}${g}${d.type.toUpperCase()}${l.reset}${b}${T}${x}`};e.onEvent(d=>{a(d.type)&&o(p(d),d)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){nn(this._disposers,this.name),this.signal([[V]],{internal:!0}),nn(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"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:l,guard:u,...c}=r.nodes[a];o[a]=c}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};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 xt(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??he,{codec:o,codecVersion:s,payload:i}=wt(e,r);return o.decode(i,s)}restore(e,n){if(rn(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(s=>We(s)),o=n?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let l=this.tryResolve(s)?.v;if(l!=null&&l.id===i.v.id&&l.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(e,n){rn(e);let r=typeof n=="function"?n:n?.build,o=typeof n=="function"?void 0:n?.factories,s=new t(e.name);if(r)return r(s),s.restore(e),s;for(let p of[...e.subgraphs].sort((d,g)=>{let m=d.split(M).length,y=g.split(M).length;return m!==y?m-y:d<g?-1:d>g?1:0})){let d=p.split(M),g=s;for(let m of d)g._mounts.has(m)||g.mount(m,new t(m)),g=g._mounts.get(m)}let i=o?Object.entries(o).map(([p,d])=>({re:We(p),factory:d})):[],a=p=>{for(let d of i)if(d.re.test(p))return d.factory},l=p=>{let d=p.split(M),g=d.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${p}"`);let m=s;for(let y of d){let v=m._mounts.get(y);if(!v)throw new Error(`unknown mount "${y}" in path "${p}"`);m=v}return[m,g]},u=Object.entries(e.nodes).filter(([p])=>!p.includes(`${M}${q}${M}`)).sort((p,d)=>p[0]<d[0]?-1:p[0]>d[0]?1:0),c=new Map(u),h=new Map,f=!0;for(;c.size>0&&f;){f=!1;for(let[p,d]of[...c.entries()]){let g=d?.deps??[];if(!g.every(T=>h.has(T)))continue;let[m,y]=l(p),v={...d?.meta??{}},b=a(p),_;if(d?.type==="state")_=ee(d.value,{meta:v});else{if(b==null)continue;_=b(y,{path:p,type:d.type,value:d.value,meta:v,deps:g,resolvedDeps:g.map(T=>h.get(T))})}m.add(_,{name:y}),h.set(p,_),c.delete(p),f=!0}}if(c.size>0){let p=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${p}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let o=(u,c)=>{if(u.disposed)return;let h=dr(c.nodes);if(u.lastSnapshot!=null&&h!==""&&h===u.lastFingerprint)return;let f=u.seq+1,p=Ne(),m=u.lastSnapshot==null||f%u.compactEvery===0?{mode:"full",snapshot:c,seq:f,timestamp_ns:p,format_version:ue}:{mode:"diff",diff:dn(u.lastSnapshot,c),seq:f,timestamp_ns:p,format_version:ue};if(u.tier.filter&&!u.tier.filter(this.name,m))return;let y;try{y=u.tier.save(this.name,m)}catch(v){n.onError?.(v,u.tier);return}if(y&&typeof y.then=="function"){let _=(u.savePending??Promise.resolve()).then(()=>y,()=>y).then(()=>{u.disposed||(u.seq=f,u.lastSnapshot=c,u.lastFingerprint=h)},T=>{n.onError?.(T,u.tier)});u.savePending=_.finally(()=>{u.savePending===_&&(u.savePending=void 0)})}else u.seq=f,u.lastSnapshot=c,u.lastFingerprint=h},s=(u,c)=>{try{o(u,c)}catch(h){n.onError?.(h,u.tier)}},i=(u,c)=>{if(!c.some(d=>{let g=this.config.messageTier(d[0]);return g>=3&&g<5}))return;if(n.filter){let d=this.tryResolve(u);if(d==null)return;let g=ht(d,He("standard"));if(!n.filter(u,g))return}let f,p=()=>(f==null&&(f=this.snapshot()),f);for(let d of r)d.disposed||(d.debounceMs===0?s(d,p()):(d.timer==null&&(d.timer=new Be),d.timer.start(d.debounceMs,()=>{d.disposed||s(d,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(h=>{let f=this.tryResolve(h);return f==null?()=>{}:f.subscribe(p=>i(h,p))});a=()=>{for(let h of c)h()}}else a=this.observe().subscribe((u,c)=>i(u,c));let l=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(l)};return this._storageDisposers.add(l),{dispose:l}}async _cascadeRestore(e,n){for(let r of e){let o;try{o=await r.load(this.name)}catch(i){n?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===ue&&s.nodes!=null)return this.restore(s),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let o of n){let s;try{s=await o.load(e)}catch(l){r?.onError?.(l,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===ue&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(l){r?.onError?.(l,o)}}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 o={path:e,annotation:n,timestamp_ns:B(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(o=>!e(o)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let o of n)this._traceRing.push(o);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(n.nodes)),s=[...o].filter(v=>!r.has(v)).sort(),i=[...r].filter(v=>!o.has(v)).sort(),a=[],l=[];for(let v of r){if(!o.has(v))continue;let b=e.nodes[v],_=n.nodes[v],T=b.v,x=_.v;T!=null&&x!=null&&T.id===x.id&&T.version!==x.version&&l.push({path:v,id:T.id,from:T.version,to:x.version});let w=T!=null&&x!=null&&T.id===x.id&&T.version===x.version;for(let O of["type","status","sentinel"]){let k=b[O],A=_[O];k!==A&&a.push({path:v,field:O,from:k,to:A})}if(!w)for(let O of["value","meta"]){let k=b[O],A=_[O];fr(k,A)||a.push({path:v,field:O,from:k,to:A})}}let u=v=>`${v.from} ${v.to}`,c=new Set(e.edges.map(u)),h=new Set(n.edges.map(u)),f=n.edges.filter(v=>!c.has(u(v))),p=e.edges.filter(v=>!h.has(u(v))),d=new Set(e.subgraphs),g=new Set(n.subgraphs),m=[...g].filter(v=>!d.has(v)).sort(),y=[...d].filter(v=>!g.has(v)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:l,edgesAdded:f,edgesRemoved:p,subgraphsAdded:m,subgraphsRemoved:y}}};function dn(t,e){let n=te.diff(t,e),r={};for(let o of n.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...n,nodesAddedFull:r}}function Oe(t,e,n,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,l=new Map,u=new Map,c=new Set;for(let[b,_]of Object.entries(t.nodes)){if(!b)continue;c.add(b);let T=_.deps??[];i.set(b,T);for(let x of T)x&&(c.add(x),a.has(x)||a.set(x,new Set),a.get(x).add(b))}for(let b of t.edges){if(b==null||typeof b!="object")continue;let _=typeof b.from=="string"?b.from:"",T=typeof b.to=="string"?b.to:"";!_||!T||(c.add(_),c.add(T),u.has(_)||u.set(_,new Set),u.get(_).add(T),l.has(T)||l.set(T,new Set),l.get(T).add(_))}if(!c.has(e))return r.withDetail?o:[];let h=r.both===!0,f=b=>{if(h){let w=i.get(b)??[],O=l.get(b),k=a.get(b),A=u.get(b),N=[...w];return O&&N.push(...O),k&&N.push(...k),A&&N.push(...A),N}if(n==="upstream"){let w=i.get(b)??[],O=l.get(b);return O?[...w,...O]:w}let _=a.get(b),T=u.get(b),x=_?[..._]:[];return T&&x.push(...T),x},p=new Set([e]),d=new Map,g=[{path:e,depth:0}],m=0,y=!1;for(;m<g.length;){let b=g[m++];if(s!=null&&b.depth>=s){f(b.path).length>0&&(y=!0);continue}for(let _ of f(b.path))!_||p.has(_)||(p.add(_),d.set(_,b.depth+1),g.push({path:_,depth:b.depth+1}))}let v=[...d.keys()].sort((b,_)=>b<_?-1:b>_?1:0);return r.withDetail?{paths:v,depths:d,truncated:y}:v}function Nr(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],o=e[n];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}pe();function Ee(t,e){let n=new Map,r=(o,s)=>{if(n.has(o))return;let i={off:()=>{},prefix:s};n.set(o,i);let a=o.topology.subscribe(l=>{for(let u of l){if(u[0]!==$)continue;let c=u[1];if(e(c,o,s),c.kind==="added"&&c.nodeKind==="mount"){let h=o._mounts.get(c.name);if(h instanceof te){let f=`${s}${c.name}::`;r(h,f)}}else if(c.kind==="removed"&&c.nodeKind==="mount"){let h=`${s}${c.name}::`;for(let[f,p]of Array.from(n.entries()))f!==t&&p.prefix.startsWith(h)&&(p.off(),n.delete(f))}}});i.off=a;for(let[l,u]of o._mounts)if(u instanceof te){let c=`${s}${l}::`;r(u,c)}};return r(t,""),()=>{for(let o of n.values())o.off();n.clear()}}gt();function fn(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}function pn(t,e,n,r){return t.explain(e,n,{reactive:!0,...r})}function hn(t){return fn("lens",t)}function Sr(t){let e=Object.keys(t.nodes),n=new Map,r=new Map;for(let g of e){let m=t.nodes[g]?.deps??[];n.set(g,m);for(let y of m)r.has(y)||r.set(y,new Set),r.get(y).add(g)}let o=[],s=[];for(let g of e)(n.get(g)??[]).length===0&&o.push(g),r.has(g)||s.push(g);o.sort(),s.sort();let i=t.edges.length,a=0,l=1,u=2,c=new Map;for(let g of e)c.set(g,a);let h=!1,f=new Map,p=g=>{let m=c.get(g)??a;if(m===l)return h=!0,0;if(m===u)return f.get(g)??0;c.set(g,l);let y=0,v=r.get(g);if(v!=null)for(let b of v){let _=p(b);_+1>y&&(y=_+1)}return c.set(g,u),f.set(g,y),y},d=0;for(let g of o){let m=p(g);m>d&&(d=m)}for(let g of e)c.get(g)===a&&p(g);return{nodeCount:e.length,edgeCount:i,subgraphCount:t.subgraphs.length,sources:o,sinks:s,depth:d,hasCycles:h}}function Rr(t){let e=[];for(let[n,r]of Object.entries(t.nodes)){if(r.status!=="errored")continue;let o={path:n,status:"errored"},s=Oe(t,n,"upstream",{});for(let i of s)if(i!==n&&t.nodes[i]?.status==="errored"){o.upstreamCause=i;break}e.push(o)}return e.sort((n,r)=>n.path<r.path?-1:n.path>r.path?1:0),{ok:e.length===0,problems:e}}function Ar(t,e){return t.nodeCount===e.nodeCount&&t.edgeCount===e.edgeCount&&t.subgraphCount===e.subgraphCount&&t.depth===e.depth&&t.hasCycles===e.hasCycles&&gn(t.sources,e.sources)&&gn(t.sinks,e.sinks)}function Dr(t,e){if(t.ok!==e.ok||t.problems.length!==e.problems.length)return!1;for(let n=0;n<t.problems.length;n++){let r=t.problems[n],o=e.problems[n];if(r.path!==o.path||r.status!==o.status||r.upstreamCause!==o.upstreamCause)return!1}return!0}function gn(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}var qe=class extends te{stats;health;flow;_target;constructor(e,n={}){super(n.name??`${e.name}_lens`,n.graph),this._target=e;let r=0,o=0,s=ee(0,{name:"stats_tick"}),i=ee(0,{name:"health_tick"});this.add(s,{name:"stats_tick"}),this.add(i,{name:"health_tick"});let a={name:"flow"};n.maxFlowPaths!=null&&(a.maxSize=n.maxFlowPaths),this.flow=It(a),this.add(this.flow.entries,{name:"flow"});let l=n.pathFilter,u=Ee(e,(f,p,d)=>{if(r+=1,s.emit(r),o+=1,i.emit(o),f.kind==="removed")if(f.nodeKind==="node"){let g=`${d}${f.name}`;this.flow.delete(g)}else{let g=`${d}${f.name}::`,m=[];for(let y of f.audit.nodes){let v=y===""?`${d}${f.name}`:`${g}${y}`;m.push(v)}m.length>0&&this.flow.deleteMany(m)}});this.addDisposer(u);let c=e.observe({timeline:!0,structured:!0}),h=c.onEvent(f=>{let p=f.type;if((p==="error"||p==="complete"||p==="data"||p==="teardown")&&(o+=1,i.emit(o)),p==="data"){let d=f.path??"";if(!d||l!=null&&!l(d))return;let g=this.flow.get(d),m=g!=null?g.count+1:1;this.flow.set(d,{path:d,count:m,lastUpdate_ns:B()})}});this.addDisposer(()=>{h(),c.dispose()}),this.stats=ge([s],()=>Sr(e.describe({detail:"minimal"})),{name:"stats",describeKind:"derived",equals:Ar,meta:hn("stats")}),this.add(this.stats,{name:"stats"}),this.addDisposer(ae(this.stats)),this.health=ge([i],()=>Rr(e.describe({detail:"standard"})),{name:"health",describeKind:"derived",equals:Dr,meta:hn("health")}),this.add(this.health,{name:"health"}),this.addDisposer(ae(this.health))}why(e,n,r){let o=pn(this._target,e,n,r);return this.addDisposer(o.dispose),o}get target(){return this._target}};function Cr(t,e){return new qe(t,e)}0&&(module.exports={LensGraph,graphLens,watchTopologyTree});
@@ -1,7 +1,7 @@
1
1
  import '../../node-BVV7G1bq.cjs';
2
2
  import '../../reactive-map-IJIfZxoh.cjs';
3
- import '../../graph-C4Uxwv0T.cjs';
4
- export { w as watchTopologyTree } from '../../topology-tree-CVREibAc.cjs';
5
- export { F as FlowEntry, G as GraphLensOptions, H as HealthProblem, a as HealthReport, L as LensGraph, T as TopologyStats, g as graphLens } from '../../index-Dm3_D5Ta.cjs';
3
+ import '../../graph-CdJeX7O7.cjs';
4
+ export { w as watchTopologyTree } from '../../topology-tree-CpSjvIXp.cjs';
5
+ export { F as FlowEntry, G as GraphLensOptions, H as HealthProblem, a as HealthReport, L as LensGraph, T as TopologyStats, g as graphLens } from '../../index-BmZb8fNF.cjs';
6
6
  import '../../meta-COtmHLwT.cjs';
7
7
  import '../../extra/storage-core.cjs';
@@ -1,7 +1,7 @@
1
1
  import '../../node-BVV7G1bq.js';
2
2
  import '../../reactive-map-CtRaCddO.js';
3
- import '../../graph-CWeI0aHd.js';
4
- export { w as watchTopologyTree } from '../../topology-tree-CkjojcB6.js';
5
- export { F as FlowEntry, G as GraphLensOptions, H as HealthProblem, a as HealthReport, L as LensGraph, T as TopologyStats, g as graphLens } from '../../index-CwhcFzTA.js';
3
+ import '../../graph-BOhEGJ6E.js';
4
+ export { w as watchTopologyTree } from '../../topology-tree-DAbCV2Yw.js';
5
+ export { F as FlowEntry, G as GraphLensOptions, H as HealthProblem, a as HealthReport, L as LensGraph, T as TopologyStats, g as graphLens } from '../../index-gXTVbSax.js';
6
6
  import '../../meta-BMwx3ExI.js';
7
7
  import '../../extra/storage-core.js';
@@ -1 +1 @@
1
- import{a as b,b as c}from"../../chunk-WLPVGXQ6.js";import"../../chunk-YZ6VYLFD.js";import"../../chunk-EBQ6FXKW.js";import"../../chunk-K54OKWNY.js";import"../../chunk-CZVYLXFK.js";import{a}from"../../chunk-7EQPXQ7H.js";import"../../chunk-LWGLBCMU.js";import"../../chunk-XRSHMHEG.js";import"../../chunk-PSQNYY72.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-N2KKISCE.js";import"../../chunk-UMH3HSP7.js";import"../../chunk-7AJKUA36.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{b as LensGraph,c as graphLens,a as watchTopologyTree};
1
+ import{a as b,b as c}from"../../chunk-4YGJ7KZ6.js";import"../../chunk-PWKLZ2XU.js";import"../../chunk-VXJX3ZZP.js";import"../../chunk-K54OKWNY.js";import"../../chunk-CZVYLXFK.js";import{a}from"../../chunk-MFNOZ5E6.js";import"../../chunk-LWGLBCMU.js";import"../../chunk-XRSHMHEG.js";import"../../chunk-4JBKKUCJ.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-N2KKISCE.js";import"../../chunk-UMH3HSP7.js";import"../../chunk-7AJKUA36.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{b as LensGraph,c as graphLens,a as watchTopologyTree};