@graphrefly/graphrefly 0.35.0 → 0.36.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 (107) hide show
  1. package/dist/{chunk-CD4CB6S7.js → chunk-3U7IIQB2.js} +1 -1
  2. package/dist/{chunk-PIIUJIF7.js → chunk-44QWWUA3.js} +1 -1
  3. package/dist/{chunk-3OT7K33Q.js → chunk-5CZ3KIRJ.js} +1 -1
  4. package/dist/{chunk-6SVKZ7VI.js → chunk-5RTZ6DXG.js} +1 -1
  5. package/dist/{chunk-T7GWBGOO.js → chunk-5Z3AFBN7.js} +1 -1
  6. package/dist/{chunk-XMDNNSMK.js → chunk-7LYIKMW5.js} +1 -1
  7. package/dist/{chunk-W2ZU226Q.js → chunk-AACJX2L7.js} +1 -1
  8. package/dist/{chunk-BGEY3PXH.js → chunk-AQC53OWG.js} +1 -1
  9. package/dist/{chunk-CUQFO6MT.js → chunk-CGA5RXO6.js} +1 -1
  10. package/dist/{chunk-RRFOCAH6.js → chunk-DBPFMCVH.js} +1 -1
  11. package/dist/{chunk-UAMWD4GG.js → chunk-F36TA3ET.js} +1 -1
  12. package/dist/{chunk-5XZRCS2M.js → chunk-I57VSGRB.js} +1 -1
  13. package/dist/{chunk-PVUTRA5K.js → chunk-K5ZXJPWU.js} +1 -1
  14. package/dist/{chunk-2Y3DKIZL.js → chunk-KCE6WWJE.js} +1 -1
  15. package/dist/{chunk-53XJ2S6D.js → chunk-KL7CILPL.js} +1 -1
  16. package/dist/{chunk-RLMYS3XZ.js → chunk-KUVDFOJH.js} +1 -1
  17. package/dist/{chunk-ZGVA2SR5.js → chunk-LO3LO2TO.js} +1 -1
  18. package/dist/{chunk-M5UC63ZI.js → chunk-N2GCKKKH.js} +1 -1
  19. package/dist/{chunk-EUE7ELFQ.js → chunk-PYEIPRSZ.js} +1 -1
  20. package/dist/{chunk-U347KVM4.js → chunk-QKUWS7CO.js} +1 -1
  21. package/dist/{chunk-YV2A2VWG.js → chunk-TQSTS3BY.js} +1 -1
  22. package/dist/{chunk-E5YSBQSF.js → chunk-YBA5N4XY.js} +1 -1
  23. package/dist/compat/index.d.cts +4 -4
  24. package/dist/compat/index.d.ts +4 -4
  25. package/dist/compat/index.js +1 -1
  26. package/dist/compat/nestjs/index.d.cts +3 -3
  27. package/dist/compat/nestjs/index.d.ts +3 -3
  28. package/dist/compat/nestjs/index.js +1 -1
  29. package/dist/extra/index.cjs +15 -15
  30. package/dist/extra/index.d.cts +2 -2
  31. package/dist/extra/index.d.ts +2 -2
  32. package/dist/extra/index.js +1 -1
  33. package/dist/extra/reactive.cjs +1 -1
  34. package/dist/extra/reactive.d.cts +1 -1
  35. package/dist/extra/reactive.d.ts +1 -1
  36. package/dist/extra/reactive.js +1 -1
  37. package/dist/{index-zK_mN1D-.d.cts → index-2URa-V4S.d.cts} +1 -1
  38. package/dist/{index-B3Dfl5sS.d.cts → index-33mF4XyU.d.cts} +1 -1
  39. package/dist/{index-CfOSES72.d.cts → index-BC-xjOrd.d.cts} +4 -4
  40. package/dist/{index-hXKhbfh-.d.ts → index-BTJxM-wZ.d.ts} +12 -7
  41. package/dist/{index-CzC0G0C3.d.cts → index-BVNGEX7d.d.cts} +1 -1
  42. package/dist/{index-D6JRP-1_.d.cts → index-C4ig7whw.d.cts} +1 -1
  43. package/dist/{index-KNAMYngu.d.ts → index-CVhBdCMf.d.ts} +1 -1
  44. package/dist/{index-DwNNufVa.d.ts → index-CZAixNU3.d.ts} +2 -2
  45. package/dist/{index-Qq-G9B6g.d.cts → index-Cjrpx2Mg.d.cts} +1 -1
  46. package/dist/{index-BF-ssbJB.d.ts → index-CsD0fqnO.d.ts} +1 -1
  47. package/dist/{index-DeyzuqAi.d.cts → index-CvUrRb4m.d.cts} +1 -1
  48. package/dist/{index-BkbawFkI.d.cts → index-DHv2M7s8.d.cts} +3 -3
  49. package/dist/{index-DSD6xnbT.d.ts → index-DLyQC5Ww.d.ts} +1 -1
  50. package/dist/{index-Bilohojo.d.ts → index-DSSsxS7B.d.ts} +1 -1
  51. package/dist/{index-BEvsFlfH.d.ts → index-DtSVSKnd.d.ts} +1 -1
  52. package/dist/{index-C9xF16gc.d.ts → index-DxxvGTXp.d.ts} +1 -1
  53. package/dist/{index-CGKs5ixV.d.cts → index-DzCQt2FJ.d.cts} +12 -7
  54. package/dist/{index-BpFwRAf9.d.cts → index-EfPb77rT.d.cts} +1 -1
  55. package/dist/{index-D7r_vd0b.d.cts → index-HCp5ua_i.d.cts} +2 -2
  56. package/dist/{index-DBmBtqAN.d.ts → index-KeBhbNg3.d.ts} +1 -1
  57. package/dist/{index-Dp69u0ym.d.ts → index-Pu1Wa7en.d.ts} +3 -3
  58. package/dist/{index-DXZsXxtU.d.cts → index-RJIY7QVW.d.cts} +1 -1
  59. package/dist/{index-C40wA8zt.d.ts → index-isdlyeeO.d.ts} +4 -4
  60. package/dist/{index-DzgS5uYi.d.ts → index-jA_OwwNg.d.ts} +1 -1
  61. package/dist/{index-BtY2QVDf.d.cts → index-k67aNfqC.d.cts} +1 -1
  62. package/dist/{index-CAIhFfws.d.ts → index-kBUQj-rT.d.ts} +1 -1
  63. package/dist/index.cjs +1 -1
  64. package/dist/index.d.cts +15 -15
  65. package/dist/index.d.ts +15 -15
  66. package/dist/index.js +1 -1
  67. package/dist/patterns/ai/index.d.cts +4 -4
  68. package/dist/patterns/ai/index.d.ts +4 -4
  69. package/dist/patterns/ai/index.js +1 -1
  70. package/dist/patterns/audit/index.d.cts +3 -3
  71. package/dist/patterns/audit/index.d.ts +3 -3
  72. package/dist/patterns/audit/index.js +1 -1
  73. package/dist/patterns/cqrs/index.d.cts +2 -2
  74. package/dist/patterns/cqrs/index.d.ts +2 -2
  75. package/dist/patterns/cqrs/index.js +1 -1
  76. package/dist/patterns/domain-templates/index.js +1 -1
  77. package/dist/patterns/graphspec/index.js +1 -1
  78. package/dist/patterns/guarded-execution/index.d.cts +4 -4
  79. package/dist/patterns/guarded-execution/index.d.ts +4 -4
  80. package/dist/patterns/guarded-execution/index.js +1 -1
  81. package/dist/patterns/harness/index.d.cts +6 -6
  82. package/dist/patterns/harness/index.d.ts +6 -6
  83. package/dist/patterns/harness/index.js +1 -1
  84. package/dist/patterns/job-queue/index.d.cts +2 -2
  85. package/dist/patterns/job-queue/index.d.ts +2 -2
  86. package/dist/patterns/job-queue/index.js +1 -1
  87. package/dist/patterns/lens/index.js +1 -1
  88. package/dist/patterns/messaging/index.d.cts +2 -2
  89. package/dist/patterns/messaging/index.d.ts +2 -2
  90. package/dist/patterns/messaging/index.js +1 -1
  91. package/dist/patterns/orchestration/index.d.cts +2 -2
  92. package/dist/patterns/orchestration/index.d.ts +2 -2
  93. package/dist/patterns/orchestration/index.js +1 -1
  94. package/dist/patterns/process/index.d.cts +3 -3
  95. package/dist/patterns/process/index.d.ts +3 -3
  96. package/dist/patterns/process/index.js +1 -1
  97. package/dist/patterns/reduction/index.js +1 -1
  98. package/dist/patterns/refine-loop/index.d.cts +3 -3
  99. package/dist/patterns/refine-loop/index.d.ts +3 -3
  100. package/dist/patterns/refine-loop/index.js +1 -1
  101. package/dist/patterns/resilient-pipeline/index.js +1 -1
  102. package/dist/patterns/surface/index.js +1 -1
  103. package/dist/{pipeline-graph-B85HUrWg.d.cts → pipeline-graph-BlLBWSZ2.d.cts} +1 -1
  104. package/dist/{pipeline-graph-HOTU4UG0.d.ts → pipeline-graph-DdBoRu37.d.ts} +1 -1
  105. package/dist/{reactive-log-CgbNqksB.d.cts → reactive-log-ScpWyqny.d.cts} +11 -3
  106. package/dist/{reactive-log-ByBb8g6A.d.ts → reactive-log-jirQsxMY.d.ts} +11 -3
  107. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { C as CatchOptions, a as ClassifyResult, D as Decision, b as DecisionAction, G as GateController, c as GateOptions, P as PipelineGraph, S as StepRef, T as TerminalCause, d as decisionKeyOf, p as pipelineGraph } from './pipeline-graph-B85HUrWg.cjs';
1
+ import { C as CatchOptions, a as ClassifyResult, D as Decision, b as DecisionAction, G as GateController, c as GateOptions, P as PipelineGraph, S as StepRef, T as TerminalCause, d as decisionKeyOf, p as pipelineGraph } from './pipeline-graph-BlLBWSZ2.cjs';
2
2
 
3
3
  /**
4
4
  * Orchestration patterns (roadmap §4.1).
@@ -1,7 +1,7 @@
1
1
  import { P as PolicyRuleData, a as Node, A as Actor } from './node-fSc-hCv8.cjs';
2
2
  import { G as Graph, a as GraphOptions, c as GraphDescribeOptions, d as GraphDescribeOutput, D as DescribeFilter } from './graph-kTltt95s.cjs';
3
- import { P as PolicyEnforcerGraph, a as PolicyViolation } from './index-D6JRP-1_.cjs';
4
- import { T as TopicGraph } from './index-B3Dfl5sS.cjs';
3
+ import { P as PolicyEnforcerGraph, a as PolicyViolation } from './index-C4ig7whw.cjs';
4
+ import { T as TopicGraph } from './index-33mF4XyU.cjs';
5
5
 
6
6
  /**
7
7
  * Composable safety layer (roadmap §9.0b).
@@ -1,5 +1,5 @@
1
1
  import { a as Node } from './node-fSc-hCv8.js';
2
- import { R as ReactiveLogBundle } from './reactive-log-ByBb8g6A.js';
2
+ import { R as ReactiveLogBundle } from './reactive-log-jirQsxMY.js';
3
3
  import { AppendLogStorageTier } from './extra/storage-tiers.js';
4
4
  import { a as GraphOptions, G as Graph } from './graph-Cv-8x0ZI.js';
5
5
  import { B as BaseAuditRecord } from './imperative-audit-ahAE65a9.js';
@@ -1,13 +1,13 @@
1
1
  import { T as TokenUsage, L as LLMAdapter, P as PricingFn, C as ChatMessage, a as LLMInvokeOptions, d as ToolDefinition, b as LLMResponse, S as StreamDelta, c as ToolCall, e as CapabilitiesRegistry, M as ModelCapabilities, f as ModelFeatures, g as ModelLimits, h as ModelPricing, i as PriceBreakdown, j as PricingRegistry, R as Rate, k as TieredRate, l as composePricing, m as computePrice, n as createCapabilitiesRegistry, o as createPricingRegistry, p as pricingFor, r as registryPricing, z as zeroPrice } from './types-CidcBDuk.js';
2
2
  import { a as CascadeExhaustionReport, A as AdapterProvider, b as AdapterTier, d as AllTiersExhaustedError, C as CascadingLlmAdapterOptions, e as CreateAdapterOptions, O as OpenAICompatAdapterOptions, f as OpenAICompatPreset, g as OpenAISdkLike, h as cascadingLlmAdapter, c as createAdapter, o as openAICompatAdapter, t as tier } from './cascading-BsJ4GbnS.js';
3
3
  import { a as Node, A as Actor } from './node-fSc-hCv8.js';
4
- import { R as ReactiveLogBundle } from './reactive-log-ByBb8g6A.js';
4
+ import { R as ReactiveLogBundle } from './reactive-log-jirQsxMY.js';
5
5
  import { a as CircuitBreakerOptions, e as CircuitBreaker, f as CircuitOpenError } from './resilience-Bys63Cpd.js';
6
6
  import { NodeInput } from './extra/sources.js';
7
7
  import { W as WithReplayCacheOptions, F as FallbackAdapterOptions, a as FallbackFixture, b as FallbackMissError, c as FallbackMissPolicy, R as ReplayCacheKeyContext, d as ReplayCacheMissError, e as ReplayCacheMode, f as canonicalJson, g as fallbackAdapter, w as withReplayCache } from './fallback-DuEXfA4F.js';
8
8
  import { G as Graph, a as GraphOptions, i as GraphCheckpointRecord, h as GraphAttachStorageOptions } from './graph-Cv-8x0ZI.js';
9
- import { T as TopicGraph } from './index-C9xF16gc.js';
10
- import { G as GateController, c as GateOptions } from './pipeline-graph-HOTU4UG0.js';
9
+ import { T as TopicGraph } from './index-DxxvGTXp.js';
10
+ import { G as GateController, c as GateOptions } from './pipeline-graph-DdBoRu37.js';
11
11
  import { D as DistillBundle, E as Extraction } from './composite-CT_mApQD.js';
12
12
  import { V as VectorSearchResult, L as LightCollectionBundle, a as VectorIndexBundle, K as KnowledgeGraphGraph } from './index-CI_yjtua.js';
13
13
  import { StorageHandle } from './extra/storage-core.js';
@@ -8,7 +8,7 @@ import { C as ContentAddressedMissError, a as ContentAddressedMode, b as Content
8
8
  import { T as ToObservableOptions, t as toObservable } from './observable-Cqty11jG.cjs';
9
9
  import { MergeMapOptions, TapObserver, ThrottleOptions, audit, buffer, bufferCount, bufferTime, catchError, combine, combineLatest, concat, concatMap, debounce, debounceTime, delay, distinctUntilChanged, elementAt, exhaustMap, filter, find, first, flatMap, interval, last, map, merge, mergeMap, onFirstData, pairwise, pausable, race, reduce, repeat, rescue, sample, scan, skip, switchMap, take, takeUntil, takeWhile, tap, tapFirst, throttle, throttleTime, valve, window, windowCount, windowTime, withLatestFrom, zip } from './extra/operators.cjs';
10
10
  import { IndexBackend, IndexRow, ListBackend, NativeIndexBackend, NativeListBackend, ReactiveIndexBundle, ReactiveIndexOptions, ReactiveListBundle, ReactiveListOptions, UpsertOptions, reactiveIndex, reactiveList } from './extra/reactive.cjs';
11
- import { L as LogBackend, M as MergedReactiveLog, N as NativeLogBackend, R as ReactiveLogBundle, a as ReactiveLogOptions, V as ViewSpec, m as mergeReactiveLogs, r as reactiveLog } from './reactive-log-CgbNqksB.cjs';
11
+ import { L as LogBackend, M as MergedReactiveLog, N as NativeLogBackend, R as ReactiveLogBundle, a as ReactiveLogOptions, V as ViewSpec, m as mergeReactiveLogs, r as reactiveLog } from './reactive-log-ScpWyqny.cjs';
12
12
  import { M as MapBackend, N as NativeMapBackend, b as NativeMapBackendOptions, R as ReactiveMapBundle, a as ReactiveMapOptions, c as ReactiveMapRetention, r as reactiveMap } from './reactive-map-DmgeADH8.cjs';
13
13
  import { StorageHandle, sortJsonValue, stableJsonString } from './extra/storage-core.cjs';
14
14
 
@@ -1,11 +1,11 @@
1
1
  import { NodeInput } from './extra/sources.js';
2
2
  import { a as Node } from './node-fSc-hCv8.js';
3
3
  import { L as LLMAdapter } from './types-CidcBDuk.js';
4
- import { T as TopicGraph, M as MessagingHubGraph } from './index-C9xF16gc.js';
5
- import { E as Evaluator, D as DatasetItem, a as EvalResult$1, R as RefineStrategy, b as RefineLoopOptions, c as RefineStatus } from './index-BF-ssbJB.js';
4
+ import { T as TopicGraph, M as MessagingHubGraph } from './index-DxxvGTXp.js';
5
+ import { E as Evaluator, D as DatasetItem, a as EvalResult$1, R as RefineStrategy, b as RefineLoopOptions, c as RefineStatus } from './index-CsD0fqnO.js';
6
6
  import { G as Graph, s as GraphProfileResult, r as GraphProfileOptions } from './graph-Cv-8x0ZI.js';
7
- import { G as GateController } from './pipeline-graph-HOTU4UG0.js';
8
- import { J as JobQueueGraph } from './index-CAIhFfws.js';
7
+ import { G as GateController } from './pipeline-graph-DdBoRu37.js';
8
+ import { J as JobQueueGraph } from './index-kBUQj-rT.js';
9
9
 
10
10
  /**
11
11
  * Strategy model and priority scoring (roadmap §9.0).
@@ -1,4 +1,4 @@
1
- import { C as CatchOptions, a as ClassifyResult, D as Decision, b as DecisionAction, G as GateController, c as GateOptions, P as PipelineGraph, S as StepRef, T as TerminalCause, d as decisionKeyOf, p as pipelineGraph } from './pipeline-graph-HOTU4UG0.js';
1
+ import { C as CatchOptions, a as ClassifyResult, D as Decision, b as DecisionAction, G as GateController, c as GateOptions, P as PipelineGraph, S as StepRef, T as TerminalCause, d as decisionKeyOf, p as pipelineGraph } from './pipeline-graph-DdBoRu37.js';
2
2
 
3
3
  /**
4
4
  * Orchestration patterns (roadmap §4.1).
@@ -3,7 +3,7 @@ import { OnModuleInit, OnModuleDestroy, ExecutionContext, CanActivate, DynamicMo
3
3
  import { ModuleRef } from '@nestjs/core';
4
4
  import { G as Graph, b as GraphPersistSnapshot } from './graph-kTltt95s.cjs';
5
5
  import { A as Actor } from './node-fSc-hCv8.cjs';
6
- import { c as CqrsOptions, b as CqrsGraph, a as CqrsEvent } from './index-zK_mN1D-.cjs';
6
+ import { c as CqrsOptions, b as CqrsGraph, a as CqrsEvent } from './index-2URa-V4S.cjs';
7
7
  import { AppendLogStorageTier } from './extra/storage-tiers.cjs';
8
8
 
9
9
  /** Class constructor key for decorator registries and Nest `ModuleRef.get()`. */
@@ -1,5 +1,5 @@
1
1
  import { a as Node } from './node-fSc-hCv8.js';
2
- import { R as ReactiveLogBundle } from './reactive-log-ByBb8g6A.js';
2
+ import { R as ReactiveLogBundle } from './reactive-log-jirQsxMY.js';
3
3
  import { NodeInput } from './extra/sources.js';
4
4
  import { AppendLogStorageTier } from './extra/storage-tiers.js';
5
5
  import { G as Graph, a as GraphOptions } from './graph-Cv-8x0ZI.js';
package/dist/index.cjs CHANGED
@@ -12,7 +12,7 @@
12
12
  `)}function pc(t){if(t.version!==ft)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${ft})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in t))throw new Error(`snapshot missing required key "${e}"`);if(typeof t.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof t.nodes!="object"||t.nodes===null||Array.isArray(t.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(t.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(t.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Jm(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,u=s.constructor;if(a!==u)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,m]of o)if(!p.has(f)||!r(m,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 m=!1;for(let h of p)if(r(f,h)){m=!0;break}if(!m)return!1}return!0}if(ArrayBuffer.isView(o)){let p=o,f=s;if(p.length!==f.length)return!1;for(let m=0;m<p.length;m++)if(p[m]!==f[m])return!1;return!0}let d=Object.keys(o),c=Object.keys(s);if(d.length!==c.length)return!1;let l=new Set(c);for(let p of d)if(!l.has(p)||!r(o[p],s[p]))return!1;return!0};return r(t,e)}function ba(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(ba);let e=t,n=Object.keys(e).sort(),r={};for(let o of n)r[o]=ba(e[o]);return r}function Ym(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Qm(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Xm(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function mc(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 gc(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 Zm(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(ba(i),null,e.indent??2);return e.logger?.(a),a}function eg(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}): ${ls(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(`
13
13
  `);return e.logger?.(s),s}function hc(t,e){let n=gc(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}["${Ym(i)}"]`)}for(let[i,a]of mc(t)){let u=o.get(i),d=o.get(a);!u||!d||s.push(` ${u} --> ${d}`)}return s.join(`
14
14
  `)}function tg(t,e){let n=hc(t,e);return ps(n)}function ps(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 d=0;d<i.length;d++)a+=String.fromCharCode(i[d]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function ng(t,e){let n=gc(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: ${Xm(n)}`];for(let i of r){let a=o.get(i);s.push(`${a}: "${Qm(i)}"`)}for(let[i,a]of mc(t)){let u=o.get(i),d=o.get(a);!u||!d||s.push(`${u} -> ${d}`)}return s.join(`
15
- `)}function rg(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function cs(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+=rg(r)}return e+="$",new RegExp(e)}var og={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"},sg={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function ls(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 ig(t){return t==="none"?sg:t==="ansi"||t==null?og:{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 fc(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 ag(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 ya(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(De))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${De}' (path separator)`);if(t===Qe)throw new Error(`Graph "${e}": ${n} name "${Qe}" is reserved for meta companion paths`);ag(t,e,n)}function ug(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(De);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function dg(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 yc(t){for(let e of t._mounts.values())yc(e);for(let e of t._nodes.values())try{e.down([[le]],{internal:!0})}catch{}}var Y=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(De))throw new Error(`Graph name must not contain '${De}' (got "${e}")`);if(e===Qe)throw new Error(`Graph name "${Qe}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??$e,this._traceRing=new ln(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=K(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}nameOf(e){return this._nodeToName.get(e)}add(e,n){let r=e.name,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(ya(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:H()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof Ae&&n._applyVersioning(e)}remove(e){ya(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,u]of i)a.includes(`${De}${Qe}${De}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...n._collectSubgraphs(`${e}${De}`)),this._mounts.delete(e),n._parent=void 0,yc(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([[le]],{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=cs(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(De))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([[E,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);X(()=>{for(let[o,s]of r)this.set(o,s,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[Je]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let o=r?.internal===!0;this.node(e).down([[C,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[L]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[u,d]of this._nodes)r.set(d,u);let a=[];for(let[u,d]of this._nodes)if(d instanceof Ae)for(let c of d._deps){let l=r.get(c.node);l!=null&&a.push([l,u])}return a.sort((u,d)=>u[0]<d[0]?-1:u[0]>d[0]?1:u[1]<d[1]?-1:u[1]>d[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,u]of o)s.set(u,a);let i=[];for(let[a,u]of o)if(u instanceof Ae)for(let d of u._deps){let c=s.get(d.node);c!=null&&i.push([c,a])}return i.sort((a,u)=>a[0]<u[0]?-1:a[0]>u[0]?1:a[1]<u[1]?-1:a[1]>u[1]?1:0),i}mount(e,n){if(n===void 0){let o=new t(e);return this.mount(e,o)}if(typeof n=="function"){let o=new t(e);return n(o),this.mount(e,o)}let r=n;if(ya(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let o=this;o!=null;o=o._parent)if(o===r)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,r),r._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),r}resolve(e){let n=ug(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]===Qe)return this._resolveMetaChainFromNode(s,o,n.join(De));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(De)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(De))}_resolveMetaChainFromNode(e,n,r){let o=e,s=0,i=[...n];for(;s<i.length;){if(i[s]!==Qe)throw new Error(`Graph "${this.name}": expected ${Qe} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Qe} in "${r}"`);let a=i[s+1],u=o.meta[a];if(!u)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=u,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 u of this._mounts.values())u._signalDeliver(e,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=dg(e,this.config);for(let u of[...this._nodes.keys()].sort()){let d=this._nodes.get(u);if(!r.has(d)){r.add(d);try{d.down(e,i)}catch(c){if(c instanceof rt)throw c;o.push(c)}a.length!==0&&this._signalMetaSubtree(d,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(u){if(u instanceof rt)throw u;s.push(u)}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=Ct(e?.detail,e?.fields),s=e?.format==="spec",i=s?Ct("minimal"):o,a=[];this._collectObserveTargets("",a);let u=new Map;for(let[x,k]of a)u.set(k,x);let d=[];{let x=a.map(([,R])=>R),k=new Set(u.values()),S=0;for(;x.length>0;){let R=x.shift();if(R instanceof Ae)for(let N of R._deps){let _=N.node;if(u.has(_))continue;let I=_.name??"",O=I;if(!O||k.has(O))if(I){let P=2;for(;k.has(`${I}#${P}`);)P++;O=`${I}#${P}`}else for(O=`__internal__/${S++}`;k.has(O);)O=`__internal__/${S++}`;u.set(_,O),k.add(O),d.push([O,_]),x.push(_)}}}let c=[...a,...d],l={};for(let[x,k]of c){if(n!=null&&!k.allowsObserve(n))continue;let S=Dr(k,i),R=k instanceof Ae?k._deps.map(O=>u.get(O.node)??O.node.name??""):[],{name:N,..._}=S,I={..._,deps:R};if(!s){let O=this._annotations.get(x);O!=null&&(I.annotation=O)}if(r!=null)if(typeof r=="function"){let O=r;if(!(O.length>=2?O(x,I):O(I)))continue}else{let O=!0;for(let[P,B]of Object.entries(r)){let j=P==="deps_includes"?"depsIncludes":P==="meta_has"?"metaHas":P;if(j==="depsIncludes"){if(!I.deps.includes(String(B))){O=!1;break}continue}if(j==="metaHas"){if(!Object.hasOwn(I.meta??{},String(B))){O=!1;break}continue}if(I[j]!==B){O=!1;break}}if(!O)continue}l[x]=I}let p=new Set(Object.keys(l)),f=[];for(let[x,k]of c)if(k instanceof Ae)for(let S of k._deps){let R=u.get(S.node);R!=null&&f.push([R,x])}f.sort((x,k)=>x[0]<k[0]?-1:x[0]>k[0]?1:x[1]<k[1]?-1:x[1]>k[1]?1:0);let m=f.map(([x,k])=>({from:x,to:k}));(n!=null||r!=null)&&(m=m.filter(x=>p.has(x.from)&&p.has(x.to)));let h=this._collectSubgraphs(""),g=n!=null||r!=null?h.filter(x=>{let k=`${x}${De}`;return[...p].some(S=>S===x||S.startsWith(k))}):h,y=this,b=e,v={name:this.name,nodes:l,edges:m,subgraphs:g,expand(x){let k={...b,format:void 0};return Array.isArray(x)?(k.fields=x,k.detail=void 0):(k.detail=x,k.fields=void 0),y.describe(k)}},T=e??{},w=T.format;return w==="json"?Zm(v,T):w==="pretty"?eg(v,T):w==="mermaid"?hc(v,T):w==="mermaid-url"?tg(v,T):w==="d2"?ng(v,T):w==="ascii"?ac(v,T):v}_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}${De}`))}return n}resourceProfile(e){return pn(this,e)}reachable(e,n,r={}){return r.withDetail===!0?fn(this.describe(),e,n,{...r,withDetail:!0}):fn(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,u]of Object.entries(o.nodes))u.lastMutation!=null&&i.set(a,u.lastMutation);return Gr(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=M(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,Sr(()=>{a=!1,!u&&(o+=1,s.emit(o))}))},c=i.onEvent(g=>{let y=g.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||d()}),l=[],p=new WeakSet,f=g=>{if(p.has(g)||u)return;p.add(g);let y=g.topology.subscribe(b=>{for(let v of b){if(v[0]!==E)continue;let T=v[1];if(d(),T.kind==="added"&&T.nodeKind==="mount"){let w=g._mounts.get(T.name);w!=null&&f(w)}}});l.push(y);for(let b of g._mounts.keys()){let v=g._mounts.get(b);v!=null&&f(v)}};f(this);let m;try{m=A([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(g,y)=>g===y})}catch(g){c();for(let y of l)y();throw i.dispose(),g}let h=re(m);return{node:m,dispose(){u=!0,c();for(let g of l)g();l.length=0,i.dispose(),h()}}}_explainReactive(e,n,r){let o=0,s=M(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=i.onEvent(f=>{let m=f.type;m!=="data"&&m!=="error"&&m!=="complete"&&m!=="teardown"||a||u||(a=!0,Sr(()=>{a=!1,!u&&(o+=1,s.emit(o))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},l;try{l=A([s],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(f,m)=>f.found===m.found&&f.reason===m.reason&&f.steps.length===m.steps.length&&cg(f.steps,m.steps)})}catch(f){throw d(),i.dispose(),f}let p=re(l);return{node:l,dispose(){u=!0,d(),i.dispose(),p()}}}_pathsMatching(e){let n=cs(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}${De}${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}${De}${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}${De}${Qe}${De}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,n){let r=typeof e=="string",s=fc(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,l=this.resolve(c);if(a!=null&&!l.allowsObserve(a))throw new rt({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,l]],s,"one"):{subscribe(p){return l.subscribe(p)},up(p){try{l.up?.(p)}catch(f){if(f instanceof rt)return;throw f}}}}let u=[];this._collectObserveTargets("",u),u.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let d=a==null?u:u.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(d,s,"all"):{subscribe:c=>{let l=d.map(([p,f])=>f.subscribe(m=>{c(p,m)}));return()=>{for(let p of l)p()}},up:(c,l)=>{try{this.resolve(c).up?.(l)}catch(p){if(p instanceof rt)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,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let u=i.actor,d=u==null?a:a.filter(([,c])=>c.allowsObserve(u));return this._buildStructuredObserver(d,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",u=this.config.inspectorEnabled,d=(s||i)&&u,c=n.maxEvents,l=c!=null&&c>0?new ln(c):null,p=[],f=new Set,m={},h=new Set,g=0,y=0,b=0,v=0,T=0,w=0,x=!1,k=!1,S=0,R=new Map,N=new Map,_=new Map,I=$=>{l?l.push($):p.push($);for(let te of f)te($)},O=()=>o?{timestamp_ns:H(),in_batch:tn(),batch_id:S}:{},P=($,te)=>{if(!(!d||!($ instanceof Ae)))return $._setInspectorHook(Re=>{if(Re.kind==="dep_message")R.set($,Re.depIndex);else if(Re.kind==="run"){let Oe=Re.batchData.map((ye,Ge)=>ye!=null&&ye.length>0?ye.at(-1):Re.prevData[Ge]);N.set($,Oe);let Ce=Re.batchData.map(ye=>ye!=null?[...ye]:void 0);_.set($,Ce),i&&I({type:"derived",path:te,dep_values:Oe,dep_batches:Ce,...O()})}})},B=$=>{let te=R.get($),Re=N.get($);if(!s||Re==null)return{};let Ce=(te!=null&&te>=0&&$ instanceof Ae?$._deps[te]:void 0)?.node,ye=Ce?.v,Ge=_.get($);return{trigger_dep_index:te,trigger_dep_name:Ce?.name,...ye!=null?{trigger_version:{id:ye.id,version:ye.version}}:{},dep_values:[...Re],...Ge!=null?{dep_batches:Ge}:{}}},j=[],D=[];for(let[$,te]of e){let Re=P(te,$);Re&&j.push(Re),D.push(te.subscribe(Oe=>{S++;for(let Ce of Oe){let ye=Ce[0],Ge=O();if(ye===E){m[$]=Ce[1];let ie=te instanceof Ae?te.lastMutation?.actor??bt:bt;I({type:"data",path:$,data:Ce[1],actor:ie,...Ge,...B(te)})}else if(a)ye===ne?g++:ye===V?y++:ye===Je?b++:ye===Be?v++:ye===qe?T++:ye===le?w++:ye===L&&!h.has($)?x=!0:ye===C&&(k=!0,h.add($));else if(ye===ne)g++,I({type:"dirty",path:$,...Ge});else if(ye===V)y++,I({type:"resolved",path:$,...Ge,...B(te)});else if(ye===Je)b++,I({type:"invalidate",path:$,...Ge});else if(ye===Be)v++,I({type:"pause",path:$,lockId:Ce[1],...Ge});else if(ye===qe)T++,I({type:"resume",path:$,lockId:Ce[1],...Ge});else if(ye===L)h.has($)||(x=!0),I({type:"complete",path:$,...Ge});else if(ye===C){k=!0,h.add($);let ie=te instanceof Ae?te.lastMutation?.actor??bt:bt;I({type:"error",path:$,data:Ce[1],actor:ie,...Ge})}else ye===le&&(w++,I({type:"teardown",path:$,...Ge}))}}))}let Z=!1,F=()=>{if(!Z){Z=!0;for(let $ of D)$();for(let $ of j)$();for(let $ of G)$({value:void 0,done:!0});G.length=0}},Q=[],G=[];f.add($=>{let te=G.shift();te?te({value:$,done:!1}):Q.push($)});let q={get values(){return m},get dirtyCount(){return g},get resolvedCount(){return y},get invalidateCount(){return b},get pauseCount(){return v},get resumeCount(){return T},get teardownCount(){return w},get events(){return l?l.toArray():[...p]},get anyCompletedCleanly(){return x},get anyErrored(){return k},get completedWithoutErrors(){return x&&!k},onEvent($){return f.add($),()=>f.delete($)},dispose:F,expand($){F();let te={...n};return typeof $=="string"?te.detail=$:Object.assign(te,$),r(fc(te))},[Symbol.asyncIterator](){return{next(){return Q.length>0?Promise.resolve({value:Q.shift(),done:!1}):Z?Promise.resolve({value:void 0,done:!0}):new Promise($=>G.push($))},return(){return F(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(q,n),q}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let o=n.logger??(m=>console.log(m)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:m=>(s==null||s.has(m))&&(i==null||!i.has(m)),u=ig(n.theme),d=r==="stage-log"?H():0,c=m=>m==null?"":n.stageLabels?.[m]??m,l=(m,h)=>m.length>h?`${m.slice(0,h-1)}\u2026`:m,p=m=>m.type==="data"||m.type==="error"?l(ls(m.data),120):"",f=m=>{if(r==="stage-log"){let k=(H()-d)/1e9,S=c(m.path).padEnd(9);if(m.type==="data"){let R=p(m);return`[${k.toFixed(3)}s] ${S} \u2190${R?` ${R}`:""}`}if(m.type==="error"){let R=p(m);return`[${k.toFixed(3)}s] ${S} \u2717${R?` ${R}`:""}`}return m.type==="complete"?`[${k.toFixed(3)}s] ${S} \u25A0 complete`:`[${k.toFixed(3)}s] ${S} ${m.type}`}if(r==="json")try{return JSON.stringify(m)}catch{return JSON.stringify({type:m.type,path:m.path,data:"[unserializable]"})}let h=u[m.type]??"",g=m.path?`${u.path}${m.path}${u.reset} `:"",y=m.type==="data"||m.type==="error",b=m.type==="pause"||m.type==="resume",v=y?` ${ls(m.data)}`:b?` ${ls(m.lockId)}`:"",T=m.type==="data"||m.type==="resolved"||m.type==="derived"?m:void 0,w=T?.trigger_dep_name!=null?` <- ${T.trigger_dep_name}`:T?.trigger_dep_index!=null?` <- #${T.trigger_dep_index}`:"",x=m.in_batch?" [batch]":"";return`${g}${h}${m.type.toUpperCase()}${u.reset}${v}${w}${x}`};e.onEvent(m=>{a(m.type)&&o(f(m),m)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){lc(this._disposers,this.name),this.signal([[le]],{internal:!0}),lc(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:u,guard:d,...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 vr(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??$e,{codec:o,codecVersion:s,payload:i}=Tr(e,r);return o.decode(i,s)}restore(e,n){if(pc(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=>cs(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 u=this.tryResolve(s)?.v;if(u!=null&&u.id===i.v.id&&u.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(e,n){pc(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((m,h)=>{let g=m.split(De).length,y=h.split(De).length;return g!==y?g-y:m<h?-1:m>h?1:0})){let m=f.split(De),h=s;for(let g of m)h._mounts.has(g)||h.mount(g,new t(g)),h=h._mounts.get(g)}let i=o?Object.entries(o).map(([f,m])=>({re:cs(f),factory:m})):[],a=f=>{for(let m of i)if(m.re.test(f))return m.factory},u=f=>{let m=f.split(De),h=m.pop();if(h==null||h.length===0)throw new Error(`invalid snapshot path "${f}"`);let g=s;for(let y of m){let b=g._mounts.get(y);if(!b)throw new Error(`unknown mount "${y}" in path "${f}"`);g=b}return[g,h]},d=Object.entries(e.nodes).filter(([f])=>!f.includes(`${De}${Qe}${De}`)).sort((f,m)=>f[0]<m[0]?-1:f[0]>m[0]?1:0),c=new Map(d),l=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[f,m]of[...c.entries()]){let h=m?.deps??[];if(!h.every(w=>l.has(w)))continue;let[g,y]=u(f),b={...m?.meta??{}},v=a(f),T;if(m?.type==="state")T=M(m.value,{meta:b});else{if(v==null)continue;T=v(y,{path:f,type:m.type,value:m.value,meta:b,deps:h,resolvedDeps:h.map(w=>l.get(w))})}g.add(T,{name:y}),l.set(f,T),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()}attachSnapshotStorage(e,n={}){let r=e.map(d=>({tier:d,debounceMs:Math.max(0,d.debounceMs??0),compactEvery:Math.max(1,d.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=(d,c)=>{if(d.disposed)return;let l=Um(c.nodes);if(d.lastSnapshot!=null&&l!==""&&l===d.lastFingerprint)return;let p=d.seq+1,f=oe(),g=d.lastSnapshot==null||p%d.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:p,timestamp_ns:f,format_version:ft}:{name:this.name,mode:"diff",diff:fs(d.lastSnapshot,c),seq:p,timestamp_ns:f,format_version:ft};if(d.tier.filter&&!d.tier.filter(g))return;let y;try{y=d.tier.save(g)}catch(b){n.onError?.(b,d.tier);return}if(y&&typeof y.then=="function"){let T=(d.savePending??Promise.resolve()).then(()=>y,()=>y).then(()=>{d.disposed||(d.seq=p,d.lastSnapshot=c,d.lastFingerprint=l)},w=>{n.onError?.(w,d.tier)});d.savePending=T.finally(()=>{d.savePending===T&&(d.savePending=void 0)})}else d.seq=p,d.lastSnapshot=c,d.lastFingerprint=l},s=(d,c)=>{try{o(d,c)}catch(l){n.onError?.(l,d.tier)}},i=(d,c)=>{if(!c.some(m=>{let h=this.config.messageTier(m[0]);return h>=3&&h<5}))return;if(n.filter){let m=this.tryResolve(d);if(m==null)return;let h=Dr(m,Ct("standard"));if(!n.filter(d,h))return}let p,f=()=>(p==null&&(p=this.snapshot()),p);for(let m of r)m.disposed||(m.debounceMs===0?s(m,f()):(m.timer==null&&(m.timer=new Le),m.timer.start(m.debounceMs,()=>{m.disposed||s(m,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(l=>{let p=this.tryResolve(l);return p==null?()=>{}:p.subscribe(f=>i(l,f))});a=()=>{for(let l of c)l()}}else a=this.observe().subscribe((d,c)=>i(d,c));let u=()=>{a();for(let d of r)d.disposed=!0,d.timer?.cancel();this._storageDisposers.delete(u)};return this._storageDisposers.add(u),{dispose:u}}async _cascadeRestore(e,n){for(let r of e){let o;try{o=await r.load?.()}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===ft&&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?.()}catch(u){r?.onError?.(u,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===ft&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(u){r?.onError?.(u,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:H(),...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(b=>!r.has(b)).sort(),i=[...r].filter(b=>!o.has(b)).sort(),a=[],u=[];for(let b of r){if(!o.has(b))continue;let v=e.nodes[b],T=n.nodes[b],w=v.v,x=T.v;w!=null&&x!=null&&w.id===x.id&&w.version!==x.version&&u.push({path:b,id:w.id,from:w.version,to:x.version});let k=w!=null&&x!=null&&w.id===x.id&&w.version===x.version;for(let S of["type","status","sentinel"]){let R=v[S],N=T[S];R!==N&&a.push({path:b,field:S,from:R,to:N})}if(!k)for(let S of["value","meta"]){let R=v[S],N=T[S];Jm(R,N)||a.push({path:b,field:S,from:R,to:N})}}let d=b=>`${b.from} ${b.to}`,c=new Set(e.edges.map(d)),l=new Set(n.edges.map(d)),p=n.edges.filter(b=>!c.has(d(b))),f=e.edges.filter(b=>!l.has(d(b))),m=new Set(e.subgraphs),h=new Set(n.subgraphs),g=[...h].filter(b=>!m.has(b)).sort(),y=[...m].filter(b=>!h.has(b)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:u,edgesAdded:p,edgesRemoved:f,subgraphsAdded:g,subgraphsRemoved:y}}};function fs(t,e){let n=Y.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 fn(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,u=new Map,d=new Map,c=new Set;for(let[v,T]of Object.entries(t.nodes)){if(!v)continue;c.add(v);let w=T.deps??[];i.set(v,w);for(let x of w)x&&(c.add(x),a.has(x)||a.set(x,new Set),a.get(x).add(v))}for(let v of t.edges){if(v==null||typeof v!="object")continue;let T=typeof v.from=="string"?v.from:"",w=typeof v.to=="string"?v.to:"";!T||!w||(c.add(T),c.add(w),d.has(T)||d.set(T,new Set),d.get(T).add(w),u.has(w)||u.set(w,new Set),u.get(w).add(T))}if(!c.has(e))return r.withDetail?o:[];let l=r.both===!0,p=v=>{if(l){let k=i.get(v)??[],S=u.get(v),R=a.get(v),N=d.get(v),_=[...k];return S&&_.push(...S),R&&_.push(...R),N&&_.push(...N),_}if(n==="upstream"){let k=i.get(v)??[],S=u.get(v);return S?[...k,...S]:k}let T=a.get(v),w=d.get(v),x=T?[...T]:[];return w&&x.push(...w),x},f=new Set([e]),m=new Map,h=[{path:e,depth:0}],g=0,y=!1;for(;g<h.length;){let v=h[g++];if(s!=null&&v.depth>=s){p(v.path).length>0&&(y=!0);continue}for(let T of p(v.path))!T||f.has(T)||(f.add(T),m.set(T,v.depth+1),h.push({path:T,depth:v.depth+1}))}let b=[...m.keys()].sort((v,T)=>v<T?-1:v>T?1:0);return r.withDetail?{paths:b,depths:m,truncated:y}:b}function cg(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}var Ts={};ke(Ts,{CqrsGraph:()=>vs,cqrs:()=>Ra,cqrsEventKeyOf:()=>hg,dispatchKeyOf:()=>yg,sagaInvocationKeyOf:()=>bg});Me();xe();$t();var va={};ke(va,{COMPLETE:()=>L,COMPLETE_MSG:()=>Oo,COMPLETE_ONLY_BATCH:()=>br,DATA:()=>E,DEFAULT_ACTOR:()=>bt,DIRTY:()=>ne,DIRTY_MSG:()=>Et,DIRTY_ONLY_BATCH:()=>Mn,ERROR:()=>C,GraphReFlyConfig:()=>nn,GuardDenied:()=>rt,INVALIDATE:()=>Je,INVALIDATE_MSG:()=>Mo,INVALIDATE_ONLY_BATCH:()=>yr,NodeImpl:()=>Ae,PAUSE:()=>Be,RESOLVED:()=>V,RESOLVED_MSG:()=>Nn,RESOLVED_ONLY_BATCH:()=>hr,RESUME:()=>qe,START:()=>dt,START_MSG:()=>_n,TEARDOWN:()=>le,TEARDOWN_MSG:()=>Co,TEARDOWN_ONLY_BATCH:()=>On,accessHintForGuard:()=>_r,advanceVersion:()=>Mr,autoTrackNode:()=>rn,batch:()=>X,configure:()=>ra,createVersioning:()=>In,defaultConfig:()=>$e,defaultHash:()=>jt,derived:()=>A,downWithBatch:()=>_t,dynamicNode:()=>Or,effect:()=>pe,isBatching:()=>tn,isV1:()=>ea,monotonicNs:()=>H,node:()=>z,normalizeActor:()=>Nt,pipe:()=>oa,policy:()=>Mt,policyFromRules:()=>Nr,producer:()=>K,registerBuiltins:()=>Er,resolveDescribeFields:()=>Ct,state:()=>M,wallClockNs:()=>oe});kr();Me();xe();Xi();$t();ae();_e();ee();Io();Me();ae();_e();ee();he();var jr=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,n){if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=n,n!==void 0){if(this._buf=new Array(n),e&&e.length>0){let r=Math.min(e.length,n),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._size+e;if(!(n<0||n>=this._size))return this._maxSize!==void 0?this._buf[(this._head+n)%this._maxSize]:this._buf[n]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=n;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let n=0;n<e;n++)this._buf[(this._head+n)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let n=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,n);else{for(let r=0;r<n;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+n)%this._maxSize}return this._size-=n,this._version+=1,n}slice(e,n){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(n!==void 0&&(!Number.isInteger(n)||n<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${n})`);let r=n===void 0?this._size:Math.min(Math.max(n,0),this._size),o=Math.min(e,this._size);if(o>=r)return[];let s=r-o;if(this._maxSize===void 0)return this._buf.slice(o,r);let i=new Array(s);for(let a=0;a<s;a++)i[a]=this._buf[(this._head+o+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let n=Math.min(e,this._size);return this.slice(this._size-n,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this._buf[(this._head+n)%this._maxSize];return e}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let n=0;n<e.length;n++)this._buf.push(e[n]);this._size=this._buf.length}else{let n=this._maxSize;for(let s=0;s<n;s++)this._buf[s]=void 0;this._head=0;let r=Math.min(e.length,n),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function $r(t){return t.subscribe(()=>{})}var lg=64;function Ve(t,e={}){let{name:n,maxSize:r,versioning:o,guard:s,backend:i}=e,a=i??new jr(t,r),u=M(a.toArray(),{name:n,describeKind:"state",equals:(k,S)=>k===S,...o!=null?{versioning:o}:{},...s!=null?{guard:s}:{}});function d(){let k=a.toArray();X(()=>{u.down([[ne]],{internal:!0}),u.down([[E,k]],{internal:!0})})}let c=new Map,l=new Map,p=new Map;function f(k,S){return`${k}:${S===void 0?"END":S}`}function m(k){if(k.size<lg)return;let S=k.keys().next();if(S.done)return;let R=k.get(S.value);R!==void 0&&R.dispose(),k.delete(S.value)}function h(k){let S=a.version;try{return k()}finally{a.version!==S&&d()}}function g(k){if(!Number.isInteger(k)||k<0)throw new RangeError(`tail: n must be a non-negative integer (got ${k})`);let S=c.get(k);if(S!==void 0)return c.delete(k),c.set(k,S),S.node;m(c);let R=A([u],([_])=>{let I=_;return k===0||I.length===0?[]:I.slice(Math.max(0,I.length-k))},{initial:a.tail(k),describeKind:"derived"}),N=$r(R);return c.set(k,{node:R,dispose:N}),R}function y(k,S){if(!Number.isInteger(k)||k<0)throw new RangeError(`slice: start must be a non-negative integer (got ${k})`);if(S!==void 0&&(!Number.isInteger(S)||S<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${S})`);let R=f(k,S),N=l.get(R);if(N!==void 0)return l.delete(R),l.set(R,N),N.node;m(l);let _=A([u],([O])=>{let P=O;return S===void 0?P.slice(k):P.slice(k,S)},{initial:a.slice(k,S),describeKind:"derived"}),I=$r(_);return l.set(R,{node:_,dispose:I}),_}function b(k){let S=p.get(k);if(S!==void 0)return S.node;let R=A([u,k],([_,I])=>{let O=_,P=Math.max(0,Math.trunc(I??0));return O.slice(P)},{initial:[],describeKind:"derived"}),N=$r(R);return p.set(k,{node:R,dispose:N}),R}let v,T;function w(){v===void 0&&(v=z([u],(k,S,R)=>{let N=k[0],I=N!=null&&N.length>0?N.at(-1):R.prevData[0];if(I==null||I.length===0){S.down([[V]]);return}S.emit(I[I.length-1])},{name:n!=null?`${n}::lastValue`:"lastValue",describeKind:"derived",initial:a.size===0?void 0:a.at(a.size-1)}),T=A([u],([k])=>k.length>0,{name:n!=null?`${n}::hasLatest`:"hasLatest",describeKind:"derived",initial:a.size>0}),$r(v),$r(T))}let x={entries:u,get size(){return a.size},at(k){return a.at(k)},append(k){h(()=>a.append(k))},appendMany(k){k.length!==0&&h(()=>a.appendMany(k))},clear(){h(()=>a.clear())},trimHead(k){h(()=>a.trimHead(k))},withLatest(){return w(),u},get lastValue(){return w(),v},get hasLatest(){return w(),T},view(k){switch(k.kind){case"tail":return g(k.n);case"slice":return y(k.start,k.stop);case"fromCursor":return b(k.cursor)}},attach(k){let S=k.subscribe(R=>{for(let N of R)N[0]===E&&x.append(N[1])});return()=>S()},attachStorage(k){if(k.length===0)return()=>{};let S=new Map;for(let N of k)S.set(N,a.size);(async()=>{for(let N of k)if(typeof N.loadEntries=="function")try{let _=await Promise.resolve(N.loadEntries());_.entries.length>0&&a.size===0&&(a.restore(_.entries),S.set(N,_.entries.length),d());break}catch{}})();let R=u.subscribe(N=>{for(let _ of N){if(_[0]!==E)continue;let I=_[1];for(let O of k){let P=S.get(O)??0;if(I.length<P){try{let j=O.appendEntries(I);j instanceof Promise&&j.catch(()=>{})}catch{}S.set(O,I.length);continue}if(I.length===P)continue;let B=I.slice(P);S.set(O,I.length);try{let j=O.appendEntries(B);j instanceof Promise&&j.catch(()=>{})}catch{}}}});return()=>R()},disposeAllViews(){for(let k of c.values())k.dispose();c.clear();for(let k of l.values())k.dispose();l.clear();for(let k of p.values())k.dispose();p.clear()},dispose(){for(let k of c.values())k.dispose();c.clear();for(let k of l.values())k.dispose();l.clear();for(let k of p.values())k.dispose();p.clear()}};return x}var Ta=new WeakMap;function bc(t){let e=Ta.get(t);if(e)return e;let n=t.map(c=>c.cache??[]),r=n.flat(),o=M(r,{name:"mergeReactiveLogs",describeKind:"state",equals:(c,l)=>c===l}),s=t.map((c,l)=>[...n[l]??[]]),i=[];for(let c=0;c<t.length;c++){let l=c,p=t[l].subscribe(f=>{for(let m of f)m[0]===E?(s[l]=[...m[1]],o.emit(s.flat())):m[0]===L?s[l]=[]:m[0]===C&&o.down([[C,m[1]]])});i.push(p)}let a=re(o),u=!1,d={node:o,dispose(){if(!u){u=!0;for(let c of i)c();i.length=0,a(),Ta.delete(t)}}};return Ta.set(t,d),d}var ka={};ke(ka,{ENVELOPE_VERSION:()=>Cn,GRAPH_META_SEGMENT:()=>Qe,Graph:()=>Y,JsonCodec:()=>Ao,SIZEOF_OVERHEAD:()=>je,SIZEOF_SYMBOL:()=>ds,SNAPSHOT_VERSION:()=>ft,createDagCborCodec:()=>Ji,createDagCborZstdCodec:()=>Yi,decodeEnvelope:()=>Tr,diffForWAL:()=>fs,encodeEnvelope:()=>vr,explainPath:()=>Gr,graphProfile:()=>pn,mermaidLiveUrl:()=>ps,reachable:()=>fn,registerBuiltinCodecs:()=>wr,replayWAL:()=>Qi,sizeof:()=>Fr,validateGraphObservability:()=>wa,watchTopologyTree:()=>At});Lo();ae();function At(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(u=>{for(let d of u){if(d[0]!==E)continue;let c=d[1];if(e(c,o,s),c.kind==="added"&&c.nodeKind==="mount"){let l=o._mounts.get(c.name);if(l instanceof Y){let p=`${s}${c.name}::`;r(l,p)}}else if(c.kind==="removed"&&c.nodeKind==="mount"){let l=`${s}${c.name}::`;for(let[p,f]of Array.from(n.entries()))p!==t&&f.prefix.startsWith(l)&&(f.off(),n.delete(p))}}});i.off=a;for(let[u,d]of o._mounts)if(d instanceof Y){let c=`${s}${u}::`;r(d,c)}};return r(t,""),()=>{for(let o of n.values())o.off();n.clear()}}function wa(t,e={}){let n=[],r=e.requireFound??!0;if(e.skipDescribe!==!0)try{let d=t.describe(),c=new Set(Object.keys(d.nodes)),l=[];for(let[p,f]of Object.entries(d.nodes))for(let m of f.deps)m!==""&&!c.has(m)&&l.push(`${p} \u2192 ${m}`);for(let p of d.edges)c.has(p.from)||l.push(`edge.from: ${p.from}`),c.has(p.to)||l.push(`edge.to: ${p.to}`);l.length>0?n.push({kind:"describe",ok:!1,reason:`describe() has ${l.length} dangling pointer(s); nodes \u2289 deps`,danglingDeps:l}):n.push({kind:"describe",ok:!0,nodeCount:c.size,edgeCount:d.edges.length})}catch(d){n.push({kind:"describe",ok:!1,reason:`describe() threw: ${d instanceof Error?d.message:String(d)}`})}for(let d of e.formats??[])try{let c=t.describe({format:d});typeof c!="string"||c.length===0?n.push({kind:"describe-format",ok:!1,format:d,reason:`describe({ format: "${d}" }) returned empty or non-string output`}):n.push({kind:"describe-format",ok:!0,format:d,length:c.length})}catch(c){n.push({kind:"describe-format",ok:!1,format:d,reason:c instanceof Error?c.message:String(c)})}for(let d of e.paths??[])try{t.resolve(d),n.push({kind:"observe",ok:!0,path:d})}catch(c){n.push({kind:"observe",ok:!1,path:d,reason:c instanceof Error?c.message:String(c)})}for(let[d,c]of e.pairs??[])try{let l=t.explain(d,c);r&&l.found===!1?n.push({kind:"explain",ok:!1,from:d,to:c,reason:`explain(${d} \u2192 ${c}) found no path${l.reason?`: ${l.reason}`:""}`}):n.push({kind:"explain",ok:!0,from:d,to:c,found:l.found,steps:l.steps.length})}catch(l){n.push({kind:"explain",ok:!1,from:d,to:c,reason:l instanceof Error?l.message:String(l)})}let o=n.filter(d=>!d.ok),s=o.length===0,i=e.paths?.length??0,a=e.pairs?.length??0,u=e.formats?.length??0;return{ok:s,checks:n,failures:o,summary(){let d=[e.skipDescribe===!0?null:"describe",u>0?`${u} format${u===1?"":"s"}`:null,i>0?`${i} observe path${i===1?"":"s"}`:null,a>0?`${a} explain pair${a===1?"":"s"}`:null].filter(l=>l!=null),c=d.length>0?d.join(", "):"describe-only";return s?`validateGraphObservability: OK (${c})`:`validateGraphObservability: ${o.length} failure(s) across ${c}`}}}var Wt=class extends Error{constructor(e,n){super(e,n),this.name=this.constructor.name}},ms=class extends Wt{constructor(n,r){super(`Duplicate ${n} registration: "${r}"`);this.kind=n;this.registrationName=r}},gs=class extends Wt{constructor(n,r,o){super(`Command "${n}" emitted undeclared event "${r}". Declared emits: [${o.join(", ")}]`);this.commandName=n;this.eventName=r;this.declaredEmits=o}},hs=class extends Wt{constructor(n,r,o){super(`Optimistic concurrency conflict on aggregate "${n}": expected version ${r}, got ${o}`);this.aggregateId=n;this.expected=r;this.actual=o}},ys=class extends Wt{constructor(n){super(`Unknown command: "${n}". Register with command() first.`);this.commandName=n}},Br=class extends Wt{constructor(n,r){super(`Command handler "${n}" threw: ${r instanceof Error?r.message:String(r)}`,{cause:r});this.commandName=n}};var Vr=class extends Wt{constructor(n,r){super(`Projection "${n}" rebuild failed: ${r instanceof Error?r.message:String(r)}`,{cause:r});this.projectionName=n}};Me();xe();$t();ae();ee();var pg=Mt((t,e)=>{t("observe"),t("signal"),e("write")});function kt(t){let e=Ve([],{name:t.name,maxSize:t.retainedLimit??1024,guard:t.guard??pg,...t.versioning!=null?{versioning:t.versioning}:{}});return e.withLatest(),t.graph&&t.graph.add(e.entries,{name:t.name}),e}function vc(t){if(t===null||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.keys(t))vc(t[e]);return Object.freeze(t)}function fg(t){let n=(t.cache??0)+1;return t.down([[ne],[E,n]]),n}function Yn(t,e){let n=e.freeze??!0;return function(...o){let s=n?o.map(vc):o,i=oe(),a,u,d=!1,c;try{X(()=>{e.seq&&(c=fg(e.seq));try{if(a=t(...s),e.onSuccess){let l=e.onSuccess(s,a,{t_ns:i,seq:c});if(l!==void 0){let p=e.handlerVersion!=null?{...l,handlerVersion:e.handlerVersion}:l;e.audit.append(p)}}}catch(l){throw u=l,d=!0,l}})}catch(l){if(d&&e.onFailure){let p=u instanceof Error?u.name:typeof u,f=e.onFailure(s,u,{t_ns:i,seq:c,errorType:p});if(f!==void 0){let m=e.handlerVersion!=null?{...f,handlerVersion:e.handlerVersion}:f;e.audit.append(m)}}throw d?u:l}return a}}function bs(t,e,n=0){let r=M(n,{name:e,describeKind:"state"});return t.add(r,{name:e}),r}function Tc(t,e,n,r=0){let o={},s=new Y(e);for(let i of n){let a=M(r,{name:i,describeKind:"state"});s.add(a,{name:i}),o[i]=a}return t.mount(e,s),o}Me();ae();_e();he();function mt(t,e){t!=null&&_t(n=>t.down(n),[[E,e]],$e.tierOf)}function Kr(t,e){let n=t.cache??0;return n>=e?!1:(t.down([[ne],[E,n+1]]),!0)}function ze(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}function qr(t){return t.relatedTo?.[0]??t.summary}var mg=Mt((t,e)=>{t("write"),t("signal"),e("observe")}),gg=Mt((t,e)=>{t("observe"),t("signal"),e("write")}),wc=Mt((t,e)=>{t("observe"),t("signal"),e("write")});function Hr(t,e){return ze("cqrs",t,e)}function xa(t){if(t===null||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.keys(t))xa(t[e]);return Object.freeze(t)}var hg=t=>`${t.type}::${t.aggregateId??"__default__"}`,yg=t=>t.commandName,bg=t=>t.eventType,vs=class extends Y{_eventLogs=new Map;_eventLogsByAggregate=new Map;_aggregateVersions=new Map;_aggregateLru=new Map;_commandRegs=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_seq=0;_retainedLimit;_freezeCommandPayload;_freezeEventPayload;_maxAggregates;_dispatchSeqCursor;dispatches;audit;aggregateEvictions;constructor(e,n={}){super(e,n.graph),this._retainedLimit=n.retainedLimit??1024,this._freezeCommandPayload=n.freezeCommandPayload??!0,this._freezeEventPayload=n.freezeEventPayload??!0,this._maxAggregates=n.maxAggregates??1e4,this.dispatches=kt({name:"dispatches",retainedLimit:this._retainedLimit,graph:this}),this.audit=this.dispatches,this.aggregateEvictions=kt({name:"aggregateEvictions",retainedLimit:this._retainedLimit,graph:this}),this._dispatchSeqCursor=bs(this,"dispatch_seq",0)}aggregateVersion(e,n){return this._aggregateVersions.get(`${e}::${n}`)??0}_touchAggregate(e){this._aggregateLru.delete(e),this._aggregateLru.set(e,!0)}_enforceAggregateLru(){for(;this._aggregateLru.size>this._maxAggregates;){let e=this._aggregateLru.keys().next();if(e.done)break;let n=e.value;this._aggregateLru.delete(n);let r=n.indexOf("::");if(r<0)continue;let o=n.slice(0,r),s=n.slice(r+2),i=this._aggregateVersions.get(n)??0;this._aggregateVersions.delete(n);let a=this._eventLogsByAggregate.get(o);a&&(a.delete(s),a.size===0&&this._eventLogsByAggregate.delete(o)),this.aggregateEvictions.append({aggregateId:s,type:o,lastVersion:i,t_ns:oe()})}}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}_attachedEventTiers=[];_attachedTierDisposers=new Map;attachEventStorage(e){this._attachedEventTiers.push(e);for(let[n,r]of this._eventLogs){let o=r.log.attachStorage(e),s=this._attachedTierDisposers.get(n);s||(s=[],this._attachedTierDisposers.set(n,s)),s.push(o)}for(let[n,r]of this._eventLogsByAggregate)for(let[o,s]of r){let i=`${n}::${o}`,a=s.log.attachStorage(e),u=this._attachedTierDisposers.get(i);u||(u=[],this._attachedTierDisposers.set(i,u)),u.push(a)}return()=>{let n=this._attachedEventTiers.indexOf(e);n>=0&&this._attachedEventTiers.splice(n,1)}}_autoWireStreamStorage(e,n){if(this._attachedEventTiers.length===0)return;let r=this._attachedTierDisposers.get(e);r||(r=[],this._attachedTierDisposers.set(e,r));for(let o of this._attachedEventTiers)r.push(n.attachStorage(o))}_bumpDispatchSeq(){let n=(this._dispatchSeqCursor.cache??0)+1;return this._dispatchSeqCursor.emit(n),n}event(e,n){if(n!==void 0)return this._ensureAggregateStream(e,n).node;let r=this._eventLogs.get(e);if(r)return r.node;let o=Ve([],{name:e,versioning:0,maxSize:this._retainedLimit});o.withLatest();let s=o.entries,i=A([s],([a])=>a,{name:e,describeKind:"state",meta:Hr("event",{event_name:e}),guard:wc,initial:s.cache});return this.add(i,{name:e}),this._keepaliveDisposers.push(re(i)),this._eventLogs.set(e,{log:o,node:i}),this._autoWireStreamStorage(e,o),i}_ensureAggregateStream(e,n){this._eventLogs.has(e)||this.event(e);let r=this._eventLogsByAggregate.get(e);r||(r=new Map,this._eventLogsByAggregate.set(e,r));let o=`${e}::${n}`;this._touchAggregate(o);let s=r.get(n);if(s)return s;let i=`${e}_${n.replace(/[^a-zA-Z0-9_-]/g,"_")}`,a=Ve([],{name:i,versioning:0,maxSize:this._retainedLimit});a.withLatest();let u=a.entries,d=A([u],([f])=>f,{name:i,describeKind:"state",meta:Hr("event_aggregate",{event_name:e,aggregate_id:n}),guard:wc,initial:u.cache}),c=i,l=0;for(;this.nameOf(this.resolveOptional(c)??d)===c&&(l+=1,c=`${i}_${l}`,this.resolveOptional(c)!==void 0););try{this.add(d,{name:c})}catch{}this._keepaliveDisposers.push(re(d));let p={log:a,node:d};return r.set(n,p),this._autoWireStreamStorage(`${e}::${n}`,a),this._enforceAggregateLru(),p}resolveOptional(e){try{return this.resolve(e)}catch{return}}_appendEvent(e,n,r){let o=this._eventLogs.get(e);if(o||(this.event(e),o=this._eventLogs.get(e)),o.node.status==="completed"||o.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${o.node.status}).`);let s,i;if(r?.aggregateId!==void 0){let c=`${e}::${r.aggregateId}`;s=(this._aggregateVersions.get(c)??0)+1,this._aggregateVersions.set(c,s),i=this._ensureAggregateStream(e,r.aggregateId)}let a=o.log.entries.v,u=this._freezeEventPayload?xa(n):n,d={type:e,payload:u,timestampNs:oe(),seq:++this._seq,...r?.aggregateId!==void 0?{aggregateId:r.aggregateId}:{},...s!==void 0?{aggregateVersion:s}:{},...r?.correlationId!==void 0?{correlationId:r.correlationId}:{},...r?.causationId!==void 0?{causationId:r.causationId}:{},...r?.metadata!==void 0?{metadata:Object.freeze({...r.metadata})}:{},...r?.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{},...a!=null?{v0:{id:a.id,version:a.version}}:{}};return o.log.append(d),i&&i.log.append(d),d}command(e,n){if(this._commandRegs.has(e))throw new ms("command",e);let r=typeof n=="function"?{handler:n}:n,o=M(void 0,{name:e,describeKind:"state",meta:{...Hr("command",{command_name:e}),error:null},guard:mg});if(this.add(o,{name:e}),this._commandRegs.set(e,{handler:r.handler,...r.emits!==void 0?{emits:r.emits}:{},...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),r.emits)for(let s of r.emits)this._eventLogs.has(s)||this.event(s);return o}dispatch(e,n,r){let o=this._commandRegs.get(e);if(!o)throw new ys(e);if(r?.aggregateId!==void 0&&r.expectedAggregateVersion!==void 0&&o.emits!==void 0){let p=0;for(let f of o.emits){let m=this._aggregateVersions.get(`${f}::${r.aggregateId}`);m!==void 0&&m>p&&(p=m)}if(p!==r.expectedAggregateVersion)throw new hs(r.aggregateId,r.expectedAggregateVersion,p)}let s=this.resolve(e),i=this._freezeCommandPayload?xa(n):n,a=[],u=oe(),d=0,c,l=!1;try{X(()=>{d=this._bumpDispatchSeq(),s.emit(i,{internal:!0});try{o.handler(i,{emit:(p,f)=>{if(o.emits!==void 0&&!o.emits.includes(p))throw new gs(e,p,o.emits);a.push(p),this._appendEvent(p,f,{...r?.aggregateId!==void 0?{aggregateId:r.aggregateId}:{},...r?.correlationId!==void 0?{correlationId:r.correlationId}:{},...r?.causationId!==void 0?{causationId:r.causationId}:{},...r?.metadata!==void 0?{metadata:Object.freeze({...r.metadata})}:{},...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}}),s.meta.error.emit(null,{internal:!0}),this.dispatches.append({commandName:e,payload:i,status:"success",emittedEvents:[...a],t_ns:u,seq:d,...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}catch(p){throw c=p,l=!0,p}})}catch(p){if(l){s.meta.error.emit(c,{internal:!0});let f=c instanceof Error?c.name:typeof c,m=c instanceof Br?c:new Br(e,c);this.dispatches.append({commandName:e,payload:i,status:"failed",error:m,errorType:f,emittedEvents:[...a],t_ns:u,seq:d,...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}throw l?c:p}}projection(e){let{name:n,events:r,reducer:o,initial:s}=e,i=e.mode??"scan",a=e.freezeInputs??!0,u=e.snapshot,d=r.map(N=>(this._eventLogs.has(N)||this.event(N),this._eventLogs.get(N).node));function c(N){N.sort((_,I)=>_.timestampNs-I.timestampNs||_.seq-I.seq||(_.aggregateId??"").localeCompare(I.aggregateId??""))}function l(N){let _=[];for(let I of N)_.push(...I);return c(_),_}let p=d.map(N=>N.cache??[]),f=l(p),m=a?Object.freeze(f):f,h=0,g=s;i==="scan"&&f.length>0&&(g=o(s,m),h=f.length);let y=i==="replay"?o(s,m):g,b=u?.saveDebounceMs??1e3,v=u?.saveEvery??1e3,T,w=0;function x(N){if(u?.save){if(w+=1,w>=v){w=0,T!==void 0&&(clearTimeout(T),T=void 0);let _=u.save(N);_ instanceof Promise&&_.catch(()=>{});return}T!==void 0&&clearTimeout(T),T=setTimeout(()=>{T=void 0,w=0;let _=u.save(N);_ instanceof Promise&&_.catch(()=>{})},b)}}let k=A(d,N=>{let _=l(N),I;if(i==="replay"){let O=a?Object.freeze(_):_;I=o(s,O)}else{let O=_.slice(h);h=_.length;let P=a?Object.freeze(O):O;I=o(g,P),g=I}return x(I),I},{name:n,describeKind:"derived",meta:Hr("projection",{projection_name:n,source_events:r}),guard:gg,initial:y});return this.add(k,{name:n}),this._keepaliveDisposers.push(re(k)),this._keepaliveDisposers.push(()=>{T!==void 0&&(clearTimeout(T),T=void 0)}),this._projections.add(n),{node:k,rebuild:async N=>{try{let _=N?.pageSize??1e3,I=N?.fromTier??this._attachedEventTiers[0]?.[0],O=l(d.map(B=>B.cache??[])).length,P=s;if(u?.load){let B=await u.load();B!==void 0&&(P=B)}if(!I||!I.loadEntries){let B=l(d.map(D=>D.cache??[])),j=a?Object.freeze(B):B;P=o(P,j)}else{let B=new Set(r),j,D=!1;for(;!D;){let Z=await I.loadEntries({cursor:j,pageSize:_}),F=[...Z.entries].filter(G=>B.has(G.type));c(F);let Q=a?Object.freeze(F):F;P=o(P,Q),j=Z.cursor,D=!j||Z.entries.length===0}}if(i==="scan"){let B=l(d.map(D=>D.cache??[])),j=B.slice(O);if(j.length>0){let D=a?Object.freeze(j):j;P=o(P,D)}g=P,h=B.length}return k.emit(P,{internal:!0}),P}catch(_){throw new Vr(n,_)}},reset:async()=>{try{let N=s;if(u?.load){let P=await u.load();P!==void 0&&(N=P)}let _=l(d.map(P=>P.cache??[])),I=a?Object.freeze(_):_,O=o(N,I);return i==="scan"&&(g=O,h=_.length),k.emit(O,{internal:!0}),O}catch(N){throw new Vr(n,N)}}}}saga(e,n,r,o={}){let s=n.map(f=>(this._eventLogs.has(f)||this.event(f),this._eventLogs.get(f).node)),i=Tc(this,`${e}_cursor`,n,0),a=kt({name:`${e}_invocations`,retainedLimit:this._retainedLimit,graph:this}),u=o.aggregateId,d=o.errorPolicy??"advance",c=new Map;for(let f of n){let m=i[f];c.set(f,m.cache??0);let h=m.subscribe(g=>{for(let y of g)y[0]===E&&c.set(f,y[1])});this._keepaliveDisposers.push(h)}let l={},p=z(s,(f,m)=>{let h=l.n.meta.error;for(let g=0;g<f.length;g++){let y=f[g];if(y==null||y.length===0)continue;let b=y.at(-1);if(!b)continue;let v=n[g],T=i[v],w=c.get(v)??0;if(b.length>w){let x=b.slice(w),k=w;for(let S of x){let R=S;if(u!==void 0&&R.aggregateId!==u){k+=1;continue}try{r(R),h.emit(null,{internal:!0}),a.append({eventType:v,status:"success",aggregateId:R.aggregateId,event:R,t_ns:oe(),...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}}),k+=1}catch(N){if(h.emit(N,{internal:!0}),a.append({eventType:v,status:"failed",error:N,errorType:N instanceof Error?N.name:typeof N,aggregateId:R.aggregateId,event:R,t_ns:oe(),...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}}),d==="hold")break;k+=1}}T.emit(k)}}},{name:e,describeKind:"effect",meta:{...Hr("saga",{saga_name:e,source_events:n}),error:null}});return l.n=p,this.add(p,{name:e}),this._keepaliveDisposers.push(re(p)),this._sagas.add(e),{node:p,invocations:a,audit:a,cursors:i}}};function Ra(t,e){return new vs(t,e)}var Ea=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},Na=class{graph=new Y("request");onModuleDestroy(){this.graph.destroy()}},kc,Sa;kc=[(0,Wr.Module)({})];var zt=class zt{static forRoot(e){let n=e??{},r=n.name??"root",o=[{provide:ct,useFactory:()=>{let s=new Y(r);return n.build&&n.build(s),n.snapshot&&s.restore(n.snapshot),s}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:s=>new Ea(s),inject:[ct]},{provide:cn,useFactory:(s,i)=>new cn(s,i),inject:[ct,xc.ModuleRef]}];if(n.nodes)for(let s of n.nodes)o.push({provide:lt(s),useFactory:i=>i.resolve(s),inject:[ct]});return n.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new Na,scope:Wr.Scope.REQUEST},{provide:on,useFactory:s=>s.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:Wr.Scope.REQUEST}),{module:zt,global:!0,providers:o,exports:[ct,...(n.nodes??[]).map(lt),...n.requestScope?[on]:[]]}}static forFeature(e){let n=[{provide:ot(e.name),useFactory:r=>{let o=new Y(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),r.mount(e.name,o),o},inject:[ct]}];if(e.nodes)for(let r of e.nodes)n.push({provide:lt(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[ot(e.name)]});return{module:zt,providers:n,exports:[ot(e.name),...(e.nodes??[]).map(r=>lt(`${e.name}::${r}`))]}}static forCqrs(e){let n=[{provide:ot(e.name),useFactory:r=>{let o=Ra(e.name,e.cqrs);return e.eventStorage&&o.attachEventStorage(e.eventStorage),e.build&&e.build(o),r.mount(e.name,o),o},inject:[ct]}];if(e.nodes)for(let r of e.nodes)n.push({provide:lt(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[ot(e.name)]});return{module:zt,providers:n,exports:[ot(e.name),...(e.nodes??[]).map(r=>lt(`${e.name}::${r}`))]}}};Sa=rd(null),zt=id(Sa,0,"GraphReflyModule",kc,zt),sd(Sa,1,zt);var ws=zt;var xs={};ke(xs,{useStore:()=>vg,useSubscribe:()=>Rc,useSubscribeRecord:()=>Tg});var Lt=require("react");ae();function Rc(t){return(0,Lt.useSyncExternalStore)(e=>{let n=!1,r=t.subscribe(()=>{n||e()});return()=>{n=!0,r()}},()=>t.cache,()=>t.cache)}function vg(t){let e=Rc(t),n=(0,Lt.useCallback)(r=>{t.down([[ne],[E,r]])},[t]);return[e,n]}function Tg(t,e){let n=(0,Lt.useRef)(e);n.current=e;let r=(0,Lt.useMemo)(()=>{let o=()=>{let i={},a=t.cache??[];for(let u of a){let d=n.current(u),c={};for(let l of Object.keys(d))c[l]=d[l].cache;i[u]=c}return i},s=o();return{subscribe:i=>{let a=!1,u=[],d=()=>{for(let p of u)p();u=[]},c=p=>{d();for(let f of p){let m=n.current(f);for(let h of Object.keys(m)){let g=m[h].subscribe(()=>{s=o(),a||i()});u.push(g)}}s=o(),a||i()},l=t.subscribe(p=>{let f=p.some(m=>m[0]===E||m[0]===V);!a&&f&&c(t.cache??[])});return c(t.cache??[]),()=>{a=!0,l(),d()}},getSnapshot:()=>s}},[t]);return(0,Lt.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot)}var Ss={};ke(Ss,{Signal:()=>wg});Me();ae();ee();var Qn=[];function Rs(t){let e=t.cache;return t.subscribe(r=>{for(let[o,s]of r)o===E&&(e=s)})(),e}var _a=class{_node;_equals;constructor(e,n){this._equals=n?.equals??Object.is,this._node=M(e,{...n,resubscribable:!0,resetOnTeardown:!0})}get(){let e=Qn[Qn.length-1];return e?(this._node.status==="sentinel"&&Rs(this._node),e(this._node)):this._node.status==="sentinel"?Rs(this._node):this._node.cache}set(e){this._equals(this.get(),e)||X(()=>{this._node.down([[ne],[E,e]])})}},Ma=class{_node;constructor(e,n){this._node=rn(r=>{Qn.push(r);try{return e()}finally{Qn.pop()}},{...n,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=Qn[Qn.length-1];return e?(this._node.status==="sentinel"&&Rs(this._node),e(this._node)):this._node.status==="sentinel"?Rs(this._node):this._node.cache}},wg={State:_a,Computed:Ma,sub:(t,e)=>{let n=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,r=!0;return t._node.subscribe(o=>{for(let[s,i]of o){if(s===E){if(r){r=!1;continue}n.data?.(i)}s===C&&n.error?.(i),s===L&&n.complete?.()}})}};var Es={};ke(Es,{useStore:()=>kg,useSubscribe:()=>Sc,useSubscribeRecord:()=>xg});var It=require("solid-js");ae();function Sc(t){let[e,n]=(0,It.createSignal)(t.cache,{equals:!1}),r=t.subscribe(()=>{n(()=>t.cache)});return(0,It.getOwner)()?(0,It.onCleanup)(()=>r()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),e}function kg(t){return[Sc(t),r=>{t.down([[ne],[E,r]])}]}function xg(t,e){let[n,r]=(0,It.createSignal)({},{equals:!1}),o=[],s=()=>{for(let d of o)d();o=[]},i=()=>{let d={};for(let c of t.cache??[]){let l=e(c),p={};for(let f of Object.keys(l))p[f]=l[f].cache;d[c]=p}return d},a=d=>{s();for(let c of d){let l=e(c);for(let p of Object.keys(l)){let f=l[p].subscribe(()=>{r(()=>i())});o.push(f)}}r(()=>i())},u=t.subscribe(d=>{d.some(c=>c[0]===E||c[0]===V)&&a(t.cache??[])});return a(t.cache??[]),(0,It.getOwner)()?(0,It.onCleanup)(()=>{u(),s()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),n}var Ns={};ke(Ns,{useStore:()=>Sg,useSubscribe:()=>Rg,useSubscribeRecord:()=>Eg});ae();function Rg(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n}}}function Sg(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n},set(e){t.down([[ne],[E,e]])},update(e){let n=e(t.cache);t.down([[ne],[E,n]])}}}function Eg(t,e){return{subscribe(n){let r=[],o=()=>{for(let u of r)u();r=[]},s=()=>{let u={};for(let d of t.cache??[]){let c=e(d),l={};for(let p of Object.keys(c))l[p]=c[p].cache;u[d]=l}return u},i=u=>{o();for(let d of u){let c=e(d);for(let l of Object.keys(c)){let p=c[l].subscribe(()=>{n(s())});r.push(p)}}n(s())},a=t.subscribe(u=>{u.some(d=>d[0]===E||d[0]===V)&&i(t.cache??[])});return i(t.cache??[]),()=>{a(),o()}}}}var _s={};ke(_s,{useStore:()=>_g,useSubscribe:()=>Ng,useSubscribeRecord:()=>Mg});var Ke=require("vue");ae();function Ng(t){let e=(0,Ke.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,Ke.getCurrentScope)()?(0,Ke.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,Ke.readonly)(e)}function _g(t){let e=(0,Ke.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,Ke.getCurrentScope)()?(0,Ke.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useStore called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,Ke.computed)({get:()=>e.value,set:r=>{t.down([[ne],[E,r]])}})}function Mg(t,e){let n=(0,Ke.shallowRef)({}),r=new Map;function o(){let a={};for(let[u,d]of r)a[u]={...d.values};n.value=a}function s(a){for(let d of r.values())for(let c of d.subs)c();r.clear();for(let d of a){let c=e(d),l=Object.keys(c),p={},f=[];for(let m of l){let h=c[m];p[m]=h.cache;let g=h.subscribe(()=>{p[m]=h.cache,o()});f.push(g)}r.set(d,{subs:f,values:p})}let u={};for(let[d,c]of r)u[d]={...c.values};n.value=u}return(0,Ke.watch)(()=>[...(typeof t=="function"?t():(0,Ke.isRef)(t)?t.value:t)??[]],a=>s(a??[]),{immediate:!0}),(0,Ke.getCurrentScope)()?(0,Ke.onScopeDispose)(()=>{for(let a of r.values())for(let u of a.subs)u();r.clear()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,Ke.readonly)(n)}var Ms={};ke(Ms,{create:()=>Cg});ae();ee();var Og=()=>!1;function Cg(t){let e=new Y("zustand"),n=M(void 0,{name:"state",equals:Og});e.add(n,{name:"state"});let r=()=>n.cache,o=(a,u)=>{let d=n.cache,c=typeof a=="function"?a(d):a;n.emit(u?c:{...d,...c})},s={getState:r,setState:o,getInitialState:()=>i,subscribe:a=>{let u=!0,d=n.cache;return n.subscribe(c=>{for(let[l,p]of c)if(l===E){if(u){u=!1;continue}a(p,d),d=p}})},destroy:e.destroy.bind(e)},i=t(o,r,s);return n.emit(i),Object.assign(e,s)}var Wa={};ke(Wa,{CircuitOpenError:()=>pt,ContentAddressedMissError:()=>eo,NS_PER_MS:()=>He,NS_PER_SEC:()=>at,NativeIndexBackend:()=>ro,NativeListBackend:()=>oo,NativeLogBackend:()=>jr,NativeMapBackend:()=>Xr,NativePubSubBackend:()=>no,RateLimiterOverflowError:()=>an,ResettableTimer:()=>Le,TimeoutError:()=>un,appendLogStorage:()=>Ka,audit:()=>zc,awaitSettled:()=>es,buffer:()=>Uc,bufferCount:()=>Jc,bufferTime:()=>Qc,cached:()=>Kd,canonicalJson:()=>to,cascadingCache:()=>sp,catchError:()=>al,checkpointToRedis:()=>Ql,checkpointToS3:()=>Yl,circuitBreaker:()=>wt,combine:()=>Aa,combineLatest:()=>ol,concat:()=>jc,concatMap:()=>Kc,constant:()=>qo,contentAddressedStorage:()=>Ps,createTransport:()=>Jt,createWatermarkController:()=>Un,csvRows:()=>Al,debounce:()=>Ia,debounceTime:()=>sl,decorrelatedJitter:()=>Uo,defer:()=>jd,delay:()=>Hc,deserializeError:()=>yn,dictKv:()=>bp,dictSnapshot:()=>vp,distill:()=>Ls,distinctUntilChanged:()=>Gc,elementAt:()=>Ic,empty:()=>Gd,escapeRegexChar:()=>ca,exhaustMap:()=>Vc,exponential:()=>Wo,externalBundle:()=>Os,externalProducer:()=>mn,fallback:()=>Hn,fibonacci:()=>zo,filter:()=>Xe,find:()=>Lc,first:()=>Cs,firstValueFrom:()=>Ye,firstWhere:()=>Yo,flatMap:()=>qc,forEach:()=>qt,fromAny:()=>U,fromAsyncIter:()=>Ir,fromCSV:()=>Cl,fromClickHouseWatch:()=>Dl,fromCron:()=>Qo,fromDrizzle:()=>np,fromEvent:()=>Dd,fromHTTP:()=>$a,fromHTTPPoll:()=>yl,fromHTTPStream:()=>hl,fromIter:()=>Xo,fromKafka:()=>Nl,fromKysely:()=>rp,fromMCP:()=>Tl,fromNATS:()=>$l,fromNDJSON:()=>Pl,fromOTel:()=>wl,fromPrisma:()=>tp,fromPrometheus:()=>El,fromPromise:()=>zn,fromPulsar:()=>Gl,fromRabbitMQ:()=>Bl,fromRaf:()=>Pd,fromRedisStream:()=>Ml,fromSSE:()=>gl,fromSqlite:()=>Xl,fromSqliteCursor:()=>Zl,fromStatsD:()=>Rl,fromSyslog:()=>kl,fromTimer:()=>st,fromWebSocket:()=>Fa,fromWebSocketReconnect:()=>vl,fromWebhook:()=>ul,globToRegExp:()=>Ld,interval:()=>el,jsonCodec:()=>tr,jsonCodecFor:()=>gp,keepalive:()=>re,kvStorage:()=>js,last:()=>Ac,linear:()=>Ho,lru:()=>Va,makeHttpError:()=>ht,map:()=>zr,matchesAnyPattern:()=>Id,matchesCron:()=>Ko,memoryAppendLog:()=>yp,memoryBackend:()=>io,memoryKv:()=>ao,memorySnapshot:()=>hp,merge:()=>xt,mergeMap:()=>La,mergeReactiveLogs:()=>bc,nameToSignal:()=>gn,ndjsonRows:()=>Ll,never:()=>Fd,nodeSignal:()=>ts,of:()=>la,onFirstData:()=>Jr,pairwise:()=>Fc,parseCron:()=>Vo,parsePrometheusText:()=>ja,parseSSEStream:()=>Dt,parseStatsD:()=>Sl,parseSyslog:()=>xl,pausable:()=>nl,pubsub:()=>cp,race:()=>Bc,rateLimiter:()=>qn,reactiveCounter:()=>pa,reactiveIndex:()=>fp,reactiveList:()=>Ds,reactiveLog:()=>Ve,reactiveMap:()=>Ze,reactiveSink:()=>We,reduce:()=>Mc,repeat:()=>tl,replay:()=>Zo,rescue:()=>Yr,resolveBackoffPreset:()=>Bt,retry:()=>Tt,sample:()=>Wc,scan:()=>_c,serializeError:()=>hn,share:()=>Vd,shareReplay:()=>qd,signalToName:()=>Ut,singleFromAny:()=>Gs,singleNodeFromAny:()=>mp,skip:()=>Ca,snapshotStorage:()=>$s,sortJsonValue:()=>so,stableJsonString:()=>Fs,stratify:()=>uo,switchMap:()=>Te,take:()=>Ur,takeUntil:()=>Cc,takeWhile:()=>Oc,tap:()=>Pc,tapFirst:()=>Dc,throttle:()=>Pa,throttleTime:()=>il,throwError:()=>$d,timeout:()=>Wn,toArray:()=>Bd,toCSV:()=>Kl,toClickHouse:()=>ql,toFile:()=>Ba,toHTTP:()=>dl,toKafka:()=>_l,toLoki:()=>Ul,toMongo:()=>zl,toNATS:()=>jl,toObservable:()=>Bo,toPostgres:()=>Wl,toPulsar:()=>Fl,toRabbitMQ:()=>Vl,toReadableStream:()=>ml,toRedisStream:()=>Ol,toS3:()=>Hl,toSSE:()=>pl,toSSEBytes:()=>fl,toSqlite:()=>ep,toTempo:()=>Jl,toWebSocket:()=>bl,tokenBucket:()=>Vt,valve:()=>rl,verifiable:()=>up,window:()=>Zc,windowCount:()=>Yc,windowTime:()=>Xc,withBreaker:()=>Kn,withLatestFrom:()=>Pt,withMaxAttempts:()=>ua,withStatus:()=>Kt,workerBridge:()=>qa,workerSelf:()=>Ha,zip:()=>$c});Me();xe();ae();_e();ee();Me();ae();ee();function Ec(t){return{describeKind:"producer",...t}}function mn(t,e){return K(n=>{let r=!0,o={emit(i){r&&n.emit(i)},error(i){r&&(r=!1,n.down([[C,i]]))},complete(){r&&(r=!1,n.down([[L]]))}},s;try{let i=t(o);s=typeof i=="function"?i:void 0}catch(i){return o.error(i),()=>{r=!1}}return()=>{r=!1;try{s?.()}catch{}}},Ec(e))}function Os(t,e,n){let r=!0,o,s=0,i=0,a={},u=[],d=()=>{let f=o;o=void 0;try{f?.()}catch{}};for(let f of e){let m=n?.name?`${n.name}::${f}`:f,h=n?.channelOpts?.[f],g=K(y=>(s++,()=>{i++,s>0&&i>=s&&i>=e.length&&d()}),Ec({...h,name:m}));a[f]=g,u.push(g)}let c={};for(let f of e)c[f]=m=>{r&&a[f].down([[E,m]])};c.error=f=>{r&&(r=!1,X(()=>{for(let m of u)m.down([[C,f]])}),d())},c.complete=()=>{r&&(r=!1,X(()=>{for(let f of u)f.down([[L]])}),d())};let l=t(c);return o=typeof l=="function"?l:void 0,Object.assign(a,{dispose:()=>{r&&(r=!1,X(()=>{for(let f of u)try{f.down([[L]])}catch{}}),d())}})}xe();ae();_e();ee();he();function ue(t){return{describeKind:"derived",...t}}function Nc(t){return{describeKind:"derived",partial:!0,...t}}function zr(t,e,n){return z([t],(r,o)=>{let s=r[0];if(s==null||s.length===0){o.down([[V]]);return}for(let i of s)o.emit(e(i))},ue(n))}function Xe(t,e,n){return z([t],(r,o)=>{let s=r[0];if(s==null||s.length===0){o.down([[V]]);return}let i=!1;for(let a of s)e(a)&&(o.emit(a),i=!0);i||o.down([[V]])},ue(n))}function _c(t,e,n,r){return z([t],(o,s,i)=>{"acc"in i.store||(i.store.acc=n);let a=o[0];if(a==null||a.length===0){s.down([[V]]);return}for(let u of a)i.store.acc=e(i.store.acc,u),s.emit(i.store.acc)},{...ue(r),initial:n,resetOnTeardown:!0})}function Mc(t,e,n,r){return z([t],(o,s,i)=>{if("acc"in i.store||(i.store.acc=n),i.terminalDeps[0]===!0){s.emit(i.store.acc),s.down([[L]]);return}let a=o[0];if(a==null||a.length===0){s.down([[V]]);return}for(let u of a)i.store.acc=e(i.store.acc,u)},{...ue(r),completeWhenDepsComplete:!1})}function Ur(t,e,n){return e<=0?z([t],(r,o,s)=>{s.store.completed||(s.store.completed=!0,o.down([[L]]))},{...ue(n),completeWhenDepsComplete:!1}):z([t],(r,o,s)=>{if("taken"in s.store||(s.store.taken=0),s.store.done){o.down([[V]]);return}if(s.terminalDeps[0]===!0){s.store.done=!0,o.down([[L]]);return}let i=r[0];if(i==null||i.length===0){o.down([[V]]);return}for(let a of i)if(s.store.taken++,o.emit(a),s.store.taken>=e){s.store.done=!0,o.down([[L]]);return}},{...ue(n),completeWhenDepsComplete:!1})}function Ca(t,e,n){return z([t],(r,o,s)=>{"skipped"in s.store||(s.store.skipped=0);let i=r[0];if(i==null||i.length===0){o.down([[V]]);return}let a=!1;for(let u of i)s.store.skipped++,s.store.skipped<=e||(o.emit(u),a=!0);a||o.down([[V]])},ue(n))}function Oc(t,e,n){return z([t],(r,o,s)=>{if(s.store.done){o.down([[V]]);return}let i=r[0];if(i==null||i.length===0){o.down([[V]]);return}for(let a of i){if(!e(a)){s.store.done=!0,o.down([[L]]);return}o.emit(a)}},{...ue(n),completeWhenDepsComplete:!1})}function Cc(t,e,n){let r=n?.predicate??(i=>i[0]===E),{predicate:o,...s}=n??{};return K(i=>{let a=!1,u=t.subscribe(c=>{if(!a)for(let l of c){if(a)return;l[0]===E?i.emit(l[1]):(l[0]===L||l[0]===C)&&(a=!0,i.down([l]))}}),d=e.subscribe(c=>{if(!a)for(let l of c){if(a)return;if(r(l)){a=!0,i.down([[L]]);return}}});return()=>{u(),d()}},ue(s))}function Cs(t,e){return Ur(t,1,e)}function Ac(t,e){let{defaultValue:n,...r}=e??{},o=e!=null&&Object.hasOwn(e,"defaultValue");return z([t],(s,i,a)=>{if(a.terminalDeps[0]===!0){a.store.has?i.emit(a.store.latest):o&&i.emit(n),i.down([[L]]);return}let u=s[0];if(u==null||u.length===0){i.down([[V]]);return}a.store.latest=u.at(-1),a.store.has=!0},{...ue(r),completeWhenDepsComplete:!1})}function Lc(t,e,n){return Ur(Xe(t,e,n),1,n)}function Ic(t,e,n){return Ur(Ca(t,e,n),1,n)}function Pc(t,e,n){if(typeof e=="function")return z([t],(o,s)=>{let i=o[0];if(i==null||i.length===0){s.down([[V]]);return}for(let a of i)e(a),s.emit(a)},ue(n));let r=e;return z([t],(o,s,i)=>{if(i.terminalDeps[0]!==void 0){i.terminalDeps[0]===!0?(r.complete?.(),s.down([[L]])):(r.error?.(i.terminalDeps[0]),s.down([[C,i.terminalDeps[0]]]));return}let a=o[0];if(a==null||a.length===0){s.down([[V]]);return}for(let u of a)r.data?.(u),s.emit(u)},{...ue(n),completeWhenDepsComplete:!1})}function Jr(t,e,n){let r=n?.where??(s=>s!=null),o=!1;return z([t],(s,i)=>{let a=s[0];if(a==null||a.length===0){i.down([[V]]);return}for(let u of a)!o&&r(u)&&(o=!0,e(u)),i.emit(u)},ue(n))}var Dc=Jr;function Gc(t,e=Object.is,n){return z([t],(r,o,s)=>{let i=r[0];if(i==null||i.length===0){o.down([[V]]);return}let a=!1;for(let u of i)s.store.hasPrev&&e(s.store.prev,u)||(s.store.prev=u,s.store.hasPrev=!0,o.emit(u),a=!0);a||o.down([[V]])},ue(n))}function Fc(t,e){return z([t],(n,r,o)=>{let s=n[0];if(s==null||s.length===0){r.down([[V]]);return}let i=!1;for(let a of s)if(!o.store.hasPrev)o.store.prev=a,o.store.hasPrev=!0;else{let u=[o.store.prev,a];o.store.prev=a,r.emit(u),i=!0}i||r.down([[V]])},ue(e))}function Aa(...t){let e=[...t];return A(e,n=>n,{...ue(),equals:(n,r)=>{if(n.length!==r.length)return!1;for(let o=0;o<n.length;o++)if(!Object.is(n[o],r[o]))return!1;return!0}})}function Pt(t,e,n){return z([t,e],(r,o,s)=>{let i=r[0],a=r[1],u=a!=null&&a.length>0?a.at(-1):s.prevData[1];if(i!=null&&i.length>0){if(!(a!=null&&a.length>0)&&s.prevData[1]===void 0){o.down([[V]]);return}for(let d of i)o.emit([d,u])}else o.down([[V]])},Nc(n))}function xt(...t){return t.length===0?K(e=>{e.down([[L]])},ue()):K(e=>{let n=t.length,r=0,o=[];for(let s of t){let i=s.subscribe(a=>{for(let u of a)u[0]===E?e.emit(u[1]):u[0]===L?(r+=1,r>=n&&e.down([[L]])):u[0]===C&&e.down([u])});o.push(i)}return()=>{for(let s of o)s()}},ue())}function $c(...t){let e=t.length;return e===0?K(n=>{n.emit([]),n.down([[L]])},ue()):K(n=>{let r=Array.from({length:e},()=>[]),o=e;function s(){for(;r.every(a=>a.length>0);){let a=r.map(u=>u.shift());n.emit(a)}}let i=[];for(let a=0;a<e;a++){let u=a,d=t[a].subscribe(c=>{for(let l of c)l[0]===E?(r[u].push(l[1]),s()):l[0]===L?(o-=1,(o===0||r[u].length===0)&&n.down([[L]])):l[0]===C&&n.down([l])});i.push(d)}return()=>{for(let a of i)a()}},ue())}function jc(t,e,n){return K(r=>{let o=0,s=[],i,a;return a=e.subscribe(u=>{for(let d of u)o===0?d[0]===E?s.push(d[1]):d[0]===C&&r.down([d]):d[0]===E?r.emit(d[1]):(d[0]===L||d[0]===C)&&r.down([d])}),i=t.subscribe(u=>{for(let d of u)if(o===0)if(d[0]===E)r.emit(d[1]);else if(d[0]===L){o=1;for(let c of s)r.emit(c);s.length=0}else d[0]===C&&r.down([d])}),()=>{i?.(),a?.()}},ue(n))}function Bc(...t){return t.length===0?K(e=>{e.down([[L]])},ue()):t.length===1?z([t[0]],(e,n)=>{let r=e[0];if(r==null||r.length===0){n.down([[V]]);return}for(let o of r)n.emit(o)},ue()):K(e=>{let n=null,r=[];for(let o=0;o<t.length;o++){let s=o,i=t[o].subscribe(a=>{for(let u of a){if(n!==null&&s!==n)return;u[0]===E?(n===null&&(n=s),e.emit(u[1])):(u[0]===L||u[0]===C)&&(n===null||s===n)&&e.down([u])}});r.push(i)}return()=>{for(let o of r)o()}},ue())}function As(t,e,n){let r,o=!1,s=()=>{o||(o=!0,n())};return r=t.subscribe(i=>{let a=!1,u=!1;for(let d of i)d[0]!==dt&&(d[0]===E?e.emit(d[1]):d[0]===L?a=!0:d[0]===C?(u=!0,e.down([d])):(d[0]===ne||d[0]===V)&&e.down([d]));u?(r?.(),r=void 0,s()):a&&s()}),()=>{r?.(),r=void 0}}function Te(t,e,n){let r,o=!1;function s(){r?.(),r=void 0}return z([t],(i,a,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){s();return}if(u.terminalDeps[0]===!0){o=!0,r||a.down([[L]]);return}let d=i[0];if(!(d==null||d.length===0))return s(),r=As(U(e(d[d.length-1])),a,()=>{s(),o&&a.down([[L]])}),{deactivate:()=>{s(),o=!1}}},{...ue(n),completeWhenDepsComplete:!1})}function Vc(t,e,n){let r,o=!1;function s(){r?.(),r=void 0}return z([t],(i,a,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){s();return}if(u.terminalDeps[0]===!0){o=!0,r||a.down([[L]]);return}let d=i[0];if(!(d==null||d.length===0))return r===void 0?r=As(U(e(d[0])),a,()=>{s(),o&&a.down([[L]])}):a.down([[V]]),{deactivate:()=>{s(),o=!1}}},{...ue(n),completeWhenDepsComplete:!1})}function Kc(t,e,n){let{maxBuffer:r,...o}=n??{},s=[],i,a=!1,u;function d(){i?.(),i=void 0}function c(){if(!u||i!==void 0)return;if(s.length===0){a&&u.down([[L]]);return}let p=s.shift();i=As(U(e(p)),u,()=>{d(),c()})}function l(p){r&&r>0&&s.length>=r&&s.shift(),s.push(p),c()}return z([t],(p,f,m)=>{if(u=f,m.terminalDeps[0]!=null&&m.terminalDeps[0]!==!0){d(),s.length=0;return}if(m.terminalDeps[0]===!0){a=!0,c();return}let h=p[0];if(!(h==null||h.length===0)){for(let g of h)l(g);return{deactivate:()=>{d(),s.length=0,a=!1}}}},{...ue(o),completeWhenDepsComplete:!1})}function La(t,e,n){let{concurrent:r,...o}=n??{},s=r!=null&&r>0?r:Number.POSITIVE_INFINITY,i=0,a=!1,u=new Set,d=[],c;function l(){a&&i===0&&d.length===0&&c&&c.down([[L]])}function p(g){if(!c)return;i++;let y;y=As(U(e(g)),c,()=>{y&&u.delete(y),i--,f(),l()}),u.add(y)}function f(){for(;d.length>0&&i<s;)p(d.shift())}function m(g){i<s?p(g):d.push(g)}function h(){for(let g of u)g();u.clear(),i=0,d.length=0}return z([t],(g,y,b)=>{if(c=y,b.terminalDeps[0]!=null&&b.terminalDeps[0]!==!0){h();return}if(b.terminalDeps[0]===!0){a=!0,l();return}let v=g[0];if(!(v==null||v.length===0)){for(let T of v)m(T);return{deactivate:()=>{h(),a=!1}}}},{...ue(o),completeWhenDepsComplete:!1})}var qc=La;function Hc(t,e,n){return K(r=>{let o=new Set;function s(){for(let a of o)clearTimeout(a);o.clear()}let i=t.subscribe(a=>{for(let u of a)if(u[0]===E){let d=setTimeout(()=>{o.delete(d),r.emit(u[1])},e);o.add(d)}else if(u[0]===L){let d=setTimeout(()=>{o.delete(d),r.down([[L]])},e);o.add(d)}else u[0]===C&&(s(),r.down([u]))});return()=>{i(),s()}},ue(n))}function Ia(t,e,n){return K(r=>{let o,s;function i(){o!==void 0&&(clearTimeout(o),o=void 0)}let a=t.subscribe(u=>{for(let d of u)d[0]===E?(i(),s=d[1],o=setTimeout(()=>{o=void 0,r.emit(s)},e)):d[0]===L?(o!==void 0&&(i(),r.emit(s)),r.down([[L]])):d[0]===C&&(i(),r.down([d]))});return()=>{a(),i()}},ue(n))}function Pa(t,e,n){let{leading:r,trailing:o,...s}=n??{},i=r!==!1,a=o===!0,u=e*1e6;return K(d=>{let c,l=-1/0,p,f=!1;function m(){c!==void 0&&(clearTimeout(c),c=void 0)}let h=t.subscribe(g=>{for(let y of g)if(y[0]===E){let b=y[1],v=H();if(i&&v-l>=u)l=v,d.emit(b),m(),a&&(c=setTimeout(()=>{c=void 0,f&&(l=H(),d.emit(p),f=!1)},e));else if(a&&(p=b,f=!0,c===void 0)){let T=(v-l)/1e6;c=setTimeout(()=>{c=void 0,f&&(l=H(),d.emit(p),f=!1)},Math.max(0,e-T))}}else(y[0]===L||y[0]===C)&&(m(),d.down([y]))});return()=>{h(),m()}},ue(s))}function Wc(t,e,n){return K(r=>{let o,s=!1,i=!1,a=t.subscribe(d=>{if(!s)for(let c of d){if(s)return;c[0]===E?o={v:c[1]}:c[0]===C?(s=!0,r.down([c])):c[0]===L&&(i=!0,o=void 0)}}),u=e.subscribe(d=>{if(!s)for(let c of d){if(s)return;c[0]===E?o!==void 0&&!i&&r.emit(o.v):c[0]===C?(s=!0,r.down([c])):c[0]===L&&(s=!0,r.down([[L]]))}});return()=>{a(),u()}},ue(n))}function zc(t,e,n){return K(r=>{let o,s,i=!1;function a(){o!==void 0&&(clearTimeout(o),o=void 0)}let u=t.subscribe(d=>{for(let c of d)c[0]===E?(s=c[1],i=!0,a(),o=setTimeout(()=>{o=void 0,i&&(i=!1,r.emit(s))},e)):(c[0]===L||c[0]===C)&&(a(),r.down([c]))});return()=>{u(),a()}},ue(n))}function Uc(t,e,n){return K(r=>{let o=[],s=t.subscribe(a=>{for(let u of a)u[0]===E?o.push(u[1]):u[0]===L?(o.length>0&&r.emit([...o]),o.length=0,r.down([[L]])):u[0]===C&&r.down([u])}),i=e.subscribe(a=>{for(let u of a)u[0]===E?o.length>0&&(r.emit([...o]),o.length=0):u[0]===L?r.down([[L]]):u[0]===C&&r.down([u])});return()=>{s(),i(),o.length=0}},ue(n))}function Jc(t,e,n){if(e<=0)throw new RangeError("bufferCount expects count > 0");return K(r=>{let o=[],s=t.subscribe(i=>{for(let a of i)a[0]===E?(o.push(a[1]),o.length>=e&&r.emit(o.splice(0,o.length))):a[0]===L?(o.length>0&&r.emit([...o]),o.length=0,r.down([[L]])):a[0]===C&&r.down([a])});return()=>{s(),o.length=0}},ue(n))}function Yc(t,e,n){if(e<=0)throw new RangeError("windowCount expects count > 0");return K(r=>{let o,s=0;function i(){let u=K(d=>(o=d.down.bind(d),()=>{o=void 0}),ue());s=0,r.emit(u)}let a=t.subscribe(u=>{for(let d of u)d[0]===E?(o||i(),o?.([[E,d[1]]]),s+=1,s>=e&&(o?.([[L]]),o=void 0)):d[0]===L?(o?.([[L]]),o=void 0,r.down([[L]])):d[0]===C&&(o?.([d]),o=void 0,r.down([d]))});return()=>{a(),o?.([[L]]),o=void 0}},ue(n))}function Qc(t,e,n){return K(r=>{let o=[],s=setInterval(()=>{o.length>0&&(r.emit([...o]),o.length=0)},e),i=t.subscribe(a=>{for(let u of a)u[0]===E?o.push(u[1]):u[0]===L?(clearInterval(s),o.length>0&&r.emit([...o]),o.length=0,r.down([[L]])):u[0]===C&&(clearInterval(s),r.down([u]))});return()=>{i(),clearInterval(s),o.length=0}},ue(n))}function Xc(t,e,n){return K(r=>{let o;function s(){o?.([[L]]),o=void 0}function i(){let d=K(c=>(o=c.down.bind(c),()=>{o=void 0}),ue());r.emit(d)}i();let a=setInterval(()=>{s(),i()},e),u=t.subscribe(d=>{for(let c of d)c[0]===E?o?.([[E,c[1]]]):c[0]===L?(clearInterval(a),s(),r.down([[L]])):c[0]===C&&(clearInterval(a),o?.([c]),s(),r.down([c]))});return()=>{u(),clearInterval(a),s()}},ue(n))}function Zc(t,e,n){return K(r=>{let o;function s(){o?.([[L]]),o=void 0}function i(){let d=K(c=>(o=c.down.bind(c),()=>{o=void 0}),ue());r.emit(d)}let a=t.subscribe(d=>{for(let c of d)c[0]===E?(o||i(),o?.([[E,c[1]]])):c[0]===L?(s(),r.down([[L]])):c[0]===C&&(o?.([c]),o=void 0,r.down([c]))}),u=e.subscribe(d=>{for(let c of d)c[0]===E&&(s(),i())});return()=>{a(),u(),s()}},ue(n))}function el(t,e){return K((n,r)=>{"n"in r.store||(r.store.n=0);let o=setInterval(()=>{n.emit(r.store.n),r.store.n=r.store.n+1},t);return()=>clearInterval(o)},ue(e))}function tl(t,e,n){if(e<=0)throw new RangeError("repeat expects count > 0");return K(r=>{let o=e,s,i=()=>{s?.(),s=t.subscribe(a=>{let u=!1,d=[];for(let c of a)c[0]===L?u=!0:d.push(c);d.length>0&&r.down(d),u&&(s?.(),s=void 0,o-=1,o>0?i():r.down([[L]]))})};return i(),()=>{s?.()}},ue(n))}function nl(t,e){return z([t],(n,r)=>{let o=n[0];if(o==null||o.length===0){r.down([[V]]);return}for(let s of o)r.emit(s)},ue(e))}function Yr(t,e,n){return K(r=>{let o=t.subscribe(s=>{for(let i of s)if(i[0]===E)r.emit(i[1]);else if(i[0]===C)try{r.emit(e(i[1]))}catch(a){r.down([[C,a]])}else i[0]===L&&r.down([[L]])});return()=>{o()}},ue(n))}function rl(t,e,n){return z([t,e],(r,o,s)=>{let i=r[1];if(!(i!=null&&i.length>0?i.at(-1):s.prevData[1])){o.down([[V]]);return}let u=r[0];if(u!=null&&u.length>0){for(let d of u)o.emit(d);return}if(i!=null&&i.length>0&&s.prevData[0]!==void 0){o.emit(s.prevData[0]);return}o.down([[V]])},Nc(n))}var ol=Aa,sl=Ia,il=Pa,al=Yr;ae();_e();ee();Vn();var Da=class{ring;arr;constructor(e){e===Number.POSITIVE_INFINITY||e<=0?(this.arr=[],this.ring=null):(this.ring=new ln(e),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(e){this.ring!=null?this.ring.push(e):this.arr.push(e)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let n=this.ring.toArray();return this.ring.clear(),n}let e=this.arr;return this.arr=[],e}};function Qr(t){return t instanceof Error?t:new Error(String(t))}function Ag(t){return t===void 0?null:typeof t=="string"?Bt(t):t}function We(t,e){let{name:n,onTransportError:r,retry:o,backpressure:s,batchSize:i=Number.POSITIVE_INFINITY,flushIntervalMs:a=0,serialize:u,stopOn:d,onUpstreamMessage:c,onDispose:l,send:p,sendBatch:f,ctx:m}=e;if(!p&&!f)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let h=m,g=Math.max(1,o?.maxAttempts??1),y=Ag(o?.backoff??(g>1?"exponential":void 0)),b=o?.shouldRetry??(()=>!0),v=f!==void 0||i<Number.POSITIVE_INFINITY||a>0,T=W=>n?`${n}::${W}`:void 0,w=M(void 0,{equals:()=>!1,name:T("sent")}),x=M(null,{name:T("failed")}),k=M(0,{name:T("inFlight")}),S=M(null,{name:T("errors")}),R=v?M(0,{name:T("buffered")}):void 0,N=s?M(!1,{name:T("paused")}):void 0,_=0,I=W=>{_+=W,k.down([[E,_]])},O=W=>{try{r?.(W)}catch{}try{S.down([[E,W]])}catch{}},P=new Set,B=W=>{P.add(W);let de=()=>P.delete(W);W.then(de,de)},j=(W,de,Se)=>{let Ee=y?y(de-1,Se,null):0,ce=Ee==null?0:typeof Ee=="number"&&Ee>0?Ee:0,Pe=Math.max(1,Math.ceil(ce/1e6));return new Promise(me=>{setTimeout(()=>me(W()),Pe)})},D=W=>W!=null&&typeof W=="object"&&typeof W.then=="function",Z=W=>{let de;try{de=u?u(W):W}catch(me){let ge=Qr(me);return O({stage:"serialize",error:ge,value:W}),x.down([[E,{value:W,error:ge,attempts:0}]]),Promise.resolve()}let Se=0,Ee=me=>{I(-1);let ge=Qr(me);if(O({stage:"send",error:ge,value:W,attempt:Se}),!(Se<g&&b(ge,Se))){x.down([[E,{value:W,error:ge,attempts:Se}]]);return}return j(Pe,Se,ge)},ce=()=>{I(-1),w.down([[E,W]])};function Pe(){Se+=1,I(1);let me;try{me=p(de,h)}catch(ge){return Ee(ge)??Promise.resolve()}return D(me)?me.then(ce,ge=>Ee(ge)):(ce(),Promise.resolve())}return Pe()},F=s?.maxBuffer??Number.POSITIVE_INFINITY,Q=new Da(F),G,q=!1,$=()=>{R?.down([[E,Q.length]])},te=W=>{N&&N.down([[E,W]])},Re=s?.strategy??"drop-oldest",Oe=(W,de)=>{let Se={value:W,payload:de};if(Q.length<F)return Q.push(Se),$(),!0;if(Re==="drop-oldest"){let ce=Q.shift();return Q.push(Se),$(),te(!0),x.down([[E,{value:ce.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(Re==="drop-newest")return te(!0),x.down([[E,{value:W,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let Ee=new Error("backpressure: buffer overflow");return O({stage:"send",error:Ee,value:W}),x.down([[E,{value:W,error:Ee,attempts:0}]]),te(!0),!1},Ce=W=>{let de=0,Se=W.map(me=>me.payload),Ee=me=>{I(-1);let ge=Qr(me);if(O({stage:"send",error:ge,value:W.map(Sn=>Sn.value),attempt:de}),!(de<g&&b(ge,de))){for(let{value:Sn}of W)x.down([[E,{value:Sn,error:ge,attempts:de}]]);return}return j(Pe,de,ge)},ce=()=>{I(-1);for(let{value:me}of W)w.down([[E,me]])};function Pe(){de+=1,I(1);let me;try{me=f(Se,h)}catch(ge){return Ee(ge)??Promise.resolve()}return D(me)?me.then(ce,ge=>Ee(ge)):(ce(),Promise.resolve())}return Pe()},ye=async W=>{for(let de of W)await Ge(de.value,de.payload)},Ge=(W,de)=>{let Se=0,Ee=me=>{I(-1);let ge=Qr(me);if(O({stage:"send",error:ge,value:W,attempt:Se}),!(Se<g&&b(ge,Se))){x.down([[E,{value:W,error:ge,attempts:Se}]]);return}return j(Pe,Se,ge)},ce=()=>{I(-1),w.down([[E,W]])};function Pe(){Se+=1,I(1);let me;try{me=p(de,h)}catch(ge){return Ee(ge)??Promise.resolve()}return D(me)?me.then(ce,ge=>Ee(ge)):(ce(),Promise.resolve())}return Pe()},ie=()=>{if(q||Q.length===0)return Promise.resolve();let W=Q.drain();if($(),te(!1),f!==void 0){let Se=Ce(W);return B(Se),Se}let de=ye(W);return B(de),de},we=()=>{G!==void 0||q||a<=0||(G=setTimeout(()=>{G=void 0,ie()},a))},Fe=t.subscribe(W=>{for(let de of W){let Se=de[0];if(Se!==E)try{c?.(de)}catch{}if(Se===E){let Ee=de[1];if(v){let ce;if(u)try{ce=u(Ee)}catch(me){let ge=Qr(me);O({stage:"serialize",error:ge,value:Ee}),x.down([[E,{value:Ee,error:ge,attempts:0}]]);continue}else ce=Ee;if(!Oe(Ee,ce))continue;Q.length>=i?ie():we()}else{let ce=Z(Ee);B(ce)}}else $e.messageTier(Se)>=3&&v&&(G!==void 0&&(clearTimeout(G),G=void 0),ie())}}),be;if(d){let W=!1;be=d.subscribe(de=>{if(!W){W=!0;return}de.length>0&&!J&&se()})}let J=!1,se=()=>{if(J)return;J=!0,G!==void 0&&(clearTimeout(G),G=void 0),v&&ie(),q=!0,be?.(),Fe();let W=de=>{try{de.down([[le]])}catch{}};W(S),W(x),W(w),W(k),R&&W(R),N&&W(N);try{l?.()}catch{}},ve={dispose:se,sent:w,failed:x,inFlight:k,errors:S};return v&&(ve.buffered=R,ve.flush=async()=>{q||(await ie(),await Promise.all(P))}),N&&(ve.paused=N),ve}Ot();he();function gt(t){return{describeKind:"producer",...t}}function Fa(t,e){let{parse:n,closeOnTeardown:r=!1,...o}=e??{};return K(s=>{let i=!0,a,u=()=>{let y=a;a=void 0,y?.()},d=y=>{i&&(i=!1,s.down([y]),u())},c=(y,b=y)=>{if(i)try{let v=y!==null&&typeof y=="object"&&"data"in y?y.data:y,T=n?n(v,b):v;s.emit(T)}catch(v){d([C,v])}},l=y=>{d([C,y])},p=()=>{d([L])};if(typeof t=="function"){try{if(a=t(c,l,p),typeof a!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(y){d([C,y])}return()=>{i=!1,u()}}let f=t,m=y=>c(y,y),h=y=>l(y),g=()=>p();return f.addEventListener("message",m),f.addEventListener("error",h),f.addEventListener("close",g),a=()=>{f.removeEventListener("message",m),f.removeEventListener("error",h),f.removeEventListener("close",g),r&&f.close()},()=>{i=!1,u()}},gt(o))}function ul(t,e){return mn(t,e)}function $a(t,e){let{method:n="GET",headers:r,body:o,transform:s=v=>v.json(),timeoutNs:i=30*1e9,signal:a,completeAfterFetch:u=!1,refetchOnSubscribe:d=!1,...c}=e??{},l=M(0,{name:`${c.name??"http"}/fetchCount`}),p=M(0,{name:`${c.name??"http"}/lastUpdated`}),f=M(!1,{name:`${c.name??"http"}/fetched`}),m=0,h=o!==void 0?typeof o=="string"?o:JSON.stringify(o):void 0,g=v=>{let T=new AbortController,w=!0;if(a?.aborted)return w=!1,v.down([[C,a.reason??new Error("Aborted")]]),()=>{};a?.addEventListener("abort",()=>T.abort(a.reason),{once:!0});let x=setTimeout(()=>T.abort(new Error("Request timeout")),Math.ceil(i/1e6));return fetch(t,{method:n,headers:r,body:h,signal:T.signal}).then(async k=>{if(clearTimeout(x),!w)return;if(!k.ok)throw new Error(`HTTP ${k.status}: ${k.statusText}`);let S=await s(k);w&&(X(()=>{m+=1,l.down([[E,m]]),p.down([[E,oe()]]),f.down([[E,!0]]),v.emit(S)}),u&&v.down([[L]]))}).catch(k=>{clearTimeout(x),w&&(k&&k.name==="AbortError"||v.down([[C,k]]))}),()=>{w=!1,T.abort()}},y=K(v=>g({emit:T=>v.emit(T),down:T=>v.down(T)}),{...gt(c),resubscribable:d});return{...Kt(y),fetchCount:l,lastUpdated:p,fetched:f}}function dl(t,e,n){let{method:r="POST",headers:o={"Content-Type":"application/json"},serialize:s=m=>JSON.stringify(m),timeoutNs:i,batchFormat:a="json-array",batchSize:u,flushIntervalMs:d,retry:c,onTransportError:l}=n??{},p=async m=>{let h=i!==void 0?new AbortController:void 0,g;h&&i!==void 0&&(g=setTimeout(()=>h.abort(new Error("Request timeout")),Math.ceil(i/1e6)));try{let y=await fetch(e,{method:r,headers:o,body:m,signal:h?.signal}),b=async()=>{try{await y.arrayBuffer?.()}catch{}};if(!y.ok)throw await b(),new Error(`HTTP ${y.status}: ${y.statusText}`);await b()}finally{g!==void 0&&clearTimeout(g)}};return u!==void 0||d!==void 0?We(t,{onTransportError:l,retry:c,batchSize:u,flushIntervalMs:d,sendBatch:async m=>{let h;a==="ndjson"?h=m.map(g=>{let y=s(g);return typeof y=="string"?y:new TextDecoder().decode(y)}).join(`
15
+ `)}function rg(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function cs(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+=rg(r)}return e+="$",new RegExp(e)}var og={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"},sg={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function ls(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 ig(t){return t==="none"?sg:t==="ansi"||t==null?og:{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 fc(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 ag(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 ya(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(De))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${De}' (path separator)`);if(t===Qe)throw new Error(`Graph "${e}": ${n} name "${Qe}" is reserved for meta companion paths`);ag(t,e,n)}function ug(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(De);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function dg(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 yc(t){for(let e of t._mounts.values())yc(e);for(let e of t._nodes.values())try{e.down([[le]],{internal:!0})}catch{}}var Y=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(De))throw new Error(`Graph name must not contain '${De}' (got "${e}")`);if(e===Qe)throw new Error(`Graph name "${Qe}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??$e,this._traceRing=new ln(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=K(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}nameOf(e){return this._nodeToName.get(e)}add(e,n){let r=e.name,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(ya(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:H()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof Ae&&n._applyVersioning(e)}remove(e){ya(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,u]of i)a.includes(`${De}${Qe}${De}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...n._collectSubgraphs(`${e}${De}`)),this._mounts.delete(e),n._parent=void 0,yc(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([[le]],{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=cs(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(De))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([[E,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);X(()=>{for(let[o,s]of r)this.set(o,s,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[Je]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let o=r?.internal===!0;this.node(e).down([[C,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[L]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[u,d]of this._nodes)r.set(d,u);let a=[];for(let[u,d]of this._nodes)if(d instanceof Ae)for(let c of d._deps){let l=r.get(c.node);l!=null&&a.push([l,u])}return a.sort((u,d)=>u[0]<d[0]?-1:u[0]>d[0]?1:u[1]<d[1]?-1:u[1]>d[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,u]of o)s.set(u,a);let i=[];for(let[a,u]of o)if(u instanceof Ae)for(let d of u._deps){let c=s.get(d.node);c!=null&&i.push([c,a])}return i.sort((a,u)=>a[0]<u[0]?-1:a[0]>u[0]?1:a[1]<u[1]?-1:a[1]>u[1]?1:0),i}mount(e,n){if(n===void 0){let o=new t(e);return this.mount(e,o)}if(typeof n=="function"){let o=new t(e);return n(o),this.mount(e,o)}let r=n;if(ya(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let o=this;o!=null;o=o._parent)if(o===r)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,r),r._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),r}resolve(e){let n=ug(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]===Qe)return this._resolveMetaChainFromNode(s,o,n.join(De));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(De)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(De))}_resolveMetaChainFromNode(e,n,r){let o=e,s=0,i=[...n];for(;s<i.length;){if(i[s]!==Qe)throw new Error(`Graph "${this.name}": expected ${Qe} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Qe} in "${r}"`);let a=i[s+1],u=o.meta[a];if(!u)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=u,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 u of this._mounts.values())u._signalDeliver(e,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=dg(e,this.config);for(let u of[...this._nodes.keys()].sort()){let d=this._nodes.get(u);if(!r.has(d)){r.add(d);try{d.down(e,i)}catch(c){if(c instanceof rt)throw c;o.push(c)}a.length!==0&&this._signalMetaSubtree(d,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(u){if(u instanceof rt)throw u;s.push(u)}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=Ct(e?.detail,e?.fields),s=e?.format==="spec",i=s?Ct("minimal"):o,a=[];this._collectObserveTargets("",a);let u=new Map;for(let[x,k]of a)u.set(k,x);let d=[];{let x=a.map(([,R])=>R),k=new Set(u.values()),S=0;for(;x.length>0;){let R=x.shift();if(R instanceof Ae)for(let N of R._deps){let _=N.node;if(u.has(_))continue;let I=_.name??"",O=I;if(!O||k.has(O))if(I){let P=2;for(;k.has(`${I}#${P}`);)P++;O=`${I}#${P}`}else for(O=`__internal__/${S++}`;k.has(O);)O=`__internal__/${S++}`;u.set(_,O),k.add(O),d.push([O,_]),x.push(_)}}}let c=[...a,...d],l={};for(let[x,k]of c){if(n!=null&&!k.allowsObserve(n))continue;let S=Dr(k,i),R=k instanceof Ae?k._deps.map(O=>u.get(O.node)??O.node.name??""):[],{name:N,..._}=S,I={..._,deps:R};if(!s){let O=this._annotations.get(x);O!=null&&(I.annotation=O)}if(r!=null)if(typeof r=="function"){let O=r;if(!(O.length>=2?O(x,I):O(I)))continue}else{let O=!0;for(let[P,B]of Object.entries(r)){let j=P==="deps_includes"?"depsIncludes":P==="meta_has"?"metaHas":P;if(j==="depsIncludes"){if(!I.deps.includes(String(B))){O=!1;break}continue}if(j==="metaHas"){if(!Object.hasOwn(I.meta??{},String(B))){O=!1;break}continue}if(I[j]!==B){O=!1;break}}if(!O)continue}l[x]=I}let p=new Set(Object.keys(l)),f=[];for(let[x,k]of c)if(k instanceof Ae)for(let S of k._deps){let R=u.get(S.node);R!=null&&f.push([R,x])}f.sort((x,k)=>x[0]<k[0]?-1:x[0]>k[0]?1:x[1]<k[1]?-1:x[1]>k[1]?1:0);let m=f.map(([x,k])=>({from:x,to:k}));(n!=null||r!=null)&&(m=m.filter(x=>p.has(x.from)&&p.has(x.to)));let h=this._collectSubgraphs(""),g=n!=null||r!=null?h.filter(x=>{let k=`${x}${De}`;return[...p].some(S=>S===x||S.startsWith(k))}):h,y=this,b=e,v={name:this.name,nodes:l,edges:m,subgraphs:g,expand(x){let k={...b,format:void 0};return Array.isArray(x)?(k.fields=x,k.detail=void 0):(k.detail=x,k.fields=void 0),y.describe(k)}},T=e??{},w=T.format;return w==="json"?Zm(v,T):w==="pretty"?eg(v,T):w==="mermaid"?hc(v,T):w==="mermaid-url"?tg(v,T):w==="d2"?ng(v,T):w==="ascii"?ac(v,T):v}_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}${De}`))}return n}resourceProfile(e){return pn(this,e)}reachable(e,n,r={}){return r.withDetail===!0?fn(this.describe(),e,n,{...r,withDetail:!0}):fn(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,u]of Object.entries(o.nodes))u.lastMutation!=null&&i.set(a,u.lastMutation);return Gr(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=M(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,Sr(()=>{a=!1,!u&&(o+=1,s.emit(o))}))},c=i.onEvent(g=>{let y=g.type;y!=="data"&&y!=="error"&&y!=="complete"&&y!=="teardown"||d()}),l=[],p=new WeakSet,f=g=>{if(p.has(g)||u)return;p.add(g);let y=g.topology.subscribe(b=>{for(let v of b){if(v[0]!==E)continue;let T=v[1];if(d(),T.kind==="added"&&T.nodeKind==="mount"){let w=g._mounts.get(T.name);w!=null&&f(w)}}});l.push(y);for(let b of g._mounts.keys()){let v=g._mounts.get(b);v!=null&&f(v)}};f(this);let m;try{m=A([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(g,y)=>g===y})}catch(g){c();for(let y of l)y();throw i.dispose(),g}let h=re(m);return{node:m,dispose(){u=!0,c();for(let g of l)g();l.length=0,i.dispose(),h()}}}_explainReactive(e,n,r){let o=0,s=M(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=i.onEvent(f=>{let m=f.type;m!=="data"&&m!=="error"&&m!=="complete"&&m!=="teardown"||a||u||(a=!0,Sr(()=>{a=!1,!u&&(o+=1,s.emit(o))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},l;try{l=A([s],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(f,m)=>f.found===m.found&&f.reason===m.reason&&f.steps.length===m.steps.length&&cg(f.steps,m.steps)})}catch(f){throw d(),i.dispose(),f}let p=re(l);return{node:l,dispose(){u=!0,d(),i.dispose(),p()}}}_pathsMatching(e){let n=cs(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}${De}${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}${De}${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}${De}${Qe}${De}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,n){let r=typeof e=="string",s=fc(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,l=this.resolve(c);if(a!=null&&!l.allowsObserve(a))throw new rt({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,l]],s,"one"):{subscribe(p){return l.subscribe(p)},up(p){try{l.up?.(p)}catch(f){if(f instanceof rt)return;throw f}}}}let u=[];this._collectObserveTargets("",u),u.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let d=a==null?u:u.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(d,s,"all"):{subscribe:c=>{let l=d.map(([p,f])=>f.subscribe(m=>{c(p,m)}));return()=>{for(let p of l)p()}},up:(c,l)=>{try{this.resolve(c).up?.(l)}catch(p){if(p instanceof rt)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,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let u=i.actor,d=u==null?a:a.filter(([,c])=>c.allowsObserve(u));return this._buildStructuredObserver(d,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",u=this.config.inspectorEnabled,d=(s||i)&&u,c=n.maxEvents,l=c!=null&&c>0?new ln(c):null,p=[],f=new Set,m={},h=new Set,g=0,y=0,b=0,v=0,T=0,w=0,x=!1,k=!1,S=0,R=new Map,N=new Map,_=new Map,I=$=>{l?l.push($):p.push($);for(let te of f)te($)},O=()=>o?{timestamp_ns:H(),in_batch:tn(),batch_id:S}:{},P=($,te)=>{if(!(!d||!($ instanceof Ae)))return $._setInspectorHook(Re=>{if(Re.kind==="dep_message")R.set($,Re.depIndex);else if(Re.kind==="run"){let Oe=Re.batchData.map((ye,Ge)=>ye!=null&&ye.length>0?ye.at(-1):Re.prevData[Ge]);N.set($,Oe);let Ce=Re.batchData.map(ye=>ye!=null?[...ye]:void 0);_.set($,Ce),i&&I({type:"derived",path:te,dep_values:Oe,dep_batches:Ce,...O()})}})},B=$=>{let te=R.get($),Re=N.get($);if(!s||Re==null)return{};let Ce=(te!=null&&te>=0&&$ instanceof Ae?$._deps[te]:void 0)?.node,ye=Ce?.v,Ge=_.get($);return{trigger_dep_index:te,trigger_dep_name:Ce?.name,...ye!=null?{trigger_version:{id:ye.id,version:ye.version}}:{},dep_values:[...Re],...Ge!=null?{dep_batches:Ge}:{}}},j=[],D=[];for(let[$,te]of e){let Re=P(te,$);Re&&j.push(Re),D.push(te.subscribe(Oe=>{S++;for(let Ce of Oe){let ye=Ce[0],Ge=O();if(ye===E){m[$]=Ce[1];let ie=te instanceof Ae?te.lastMutation?.actor??bt:bt;I({type:"data",path:$,data:Ce[1],actor:ie,...Ge,...B(te)})}else if(a)ye===ne?g++:ye===V?y++:ye===Je?b++:ye===Be?v++:ye===qe?T++:ye===le?w++:ye===L&&!h.has($)?x=!0:ye===C&&(k=!0,h.add($));else if(ye===ne)g++,I({type:"dirty",path:$,...Ge});else if(ye===V)y++,I({type:"resolved",path:$,...Ge,...B(te)});else if(ye===Je)b++,I({type:"invalidate",path:$,...Ge});else if(ye===Be)v++,I({type:"pause",path:$,lockId:Ce[1],...Ge});else if(ye===qe)T++,I({type:"resume",path:$,lockId:Ce[1],...Ge});else if(ye===L)h.has($)||(x=!0),I({type:"complete",path:$,...Ge});else if(ye===C){k=!0,h.add($);let ie=te instanceof Ae?te.lastMutation?.actor??bt:bt;I({type:"error",path:$,data:Ce[1],actor:ie,...Ge})}else ye===le&&(w++,I({type:"teardown",path:$,...Ge}))}}))}let Z=!1,F=()=>{if(!Z){Z=!0;for(let $ of D)$();for(let $ of j)$();for(let $ of G)$({value:void 0,done:!0});G.length=0}},Q=[],G=[];f.add($=>{let te=G.shift();te?te({value:$,done:!1}):Q.push($)});let q={get values(){return m},get dirtyCount(){return g},get resolvedCount(){return y},get invalidateCount(){return b},get pauseCount(){return v},get resumeCount(){return T},get teardownCount(){return w},get events(){return l?l.toArray():[...p]},get anyCompletedCleanly(){return x},get anyErrored(){return k},get completedWithoutErrors(){return x&&!k},onEvent($){return f.add($),()=>f.delete($)},dispose:F,expand($){F();let te={...n};return typeof $=="string"?te.detail=$:Object.assign(te,$),r(fc(te))},[Symbol.asyncIterator](){return{next(){return Q.length>0?Promise.resolve({value:Q.shift(),done:!1}):Z?Promise.resolve({value:void 0,done:!0}):new Promise($=>G.push($))},return(){return F(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(q,n),q}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let o=n.logger??(m=>console.log(m)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:m=>(s==null||s.has(m))&&(i==null||!i.has(m)),u=ig(n.theme),d=r==="stage-log"?H():0,c=m=>m==null?"":n.stageLabels?.[m]??m,l=(m,h)=>m.length>h?`${m.slice(0,h-1)}\u2026`:m,p=m=>m.type==="data"||m.type==="error"?l(ls(m.data),120):"",f=m=>{if(r==="stage-log"){let k=(H()-d)/1e9,S=c(m.path).padEnd(9);if(m.type==="data"){let R=p(m);return`[${k.toFixed(3)}s] ${S} \u2190${R?` ${R}`:""}`}if(m.type==="error"){let R=p(m);return`[${k.toFixed(3)}s] ${S} \u2717${R?` ${R}`:""}`}return m.type==="complete"?`[${k.toFixed(3)}s] ${S} \u25A0 complete`:`[${k.toFixed(3)}s] ${S} ${m.type}`}if(r==="json")try{return JSON.stringify(m)}catch{return JSON.stringify({type:m.type,path:m.path,data:"[unserializable]"})}let h=u[m.type]??"",g=m.path?`${u.path}${m.path}${u.reset} `:"",y=m.type==="data"||m.type==="error",b=m.type==="pause"||m.type==="resume",v=y?` ${ls(m.data)}`:b?` ${ls(m.lockId)}`:"",T=m.type==="data"||m.type==="resolved"||m.type==="derived"?m:void 0,w=T?.trigger_dep_name!=null?` <- ${T.trigger_dep_name}`:T?.trigger_dep_index!=null?` <- #${T.trigger_dep_index}`:"",x=m.in_batch?" [batch]":"";return`${g}${h}${m.type.toUpperCase()}${u.reset}${v}${w}${x}`};e.onEvent(m=>{a(m.type)&&o(f(m),m)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){lc(this._disposers,this.name),this.signal([[le]],{internal:!0}),lc(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:u,guard:d,...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 vr(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??$e,{codec:o,codecVersion:s,payload:i}=Tr(e,r);return o.decode(i,s)}restore(e,n){if(pc(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=>cs(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 u=this.tryResolve(s)?.v;if(u!=null&&u.id===i.v.id&&u.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(e,n){pc(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((m,h)=>{let g=m.split(De).length,y=h.split(De).length;return g!==y?g-y:m<h?-1:m>h?1:0})){let m=f.split(De),h=s;for(let g of m)h._mounts.has(g)||h.mount(g,new t(g)),h=h._mounts.get(g)}let i=o?Object.entries(o).map(([f,m])=>({re:cs(f),factory:m})):[],a=f=>{for(let m of i)if(m.re.test(f))return m.factory},u=f=>{let m=f.split(De),h=m.pop();if(h==null||h.length===0)throw new Error(`invalid snapshot path "${f}"`);let g=s;for(let y of m){let b=g._mounts.get(y);if(!b)throw new Error(`unknown mount "${y}" in path "${f}"`);g=b}return[g,h]},d=Object.entries(e.nodes).filter(([f])=>!f.includes(`${De}${Qe}${De}`)).sort((f,m)=>f[0]<m[0]?-1:f[0]>m[0]?1:0),c=new Map(d),l=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[f,m]of[...c.entries()]){let h=m?.deps??[];if(!h.every(w=>l.has(w)))continue;let[g,y]=u(f),b={...m?.meta??{}},v=a(f),T;if(m?.type==="state")T=M(m.value,{meta:b});else{if(v==null)continue;T=v(y,{path:f,type:m.type,value:m.value,meta:b,deps:h,resolvedDeps:h.map(w=>l.get(w))})}g.add(T,{name:y}),l.set(f,T),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()}attachSnapshotStorage(e,n={}){let r=e.map(d=>({tier:d,debounceMs:Math.max(0,d.debounceMs??0),compactEvery:Math.max(1,d.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=(d,c)=>{if(d.disposed)return;let l=Um(c.nodes);if(d.lastSnapshot!=null&&l!==""&&l===d.lastFingerprint)return;let p=d.seq+1,f=oe(),g=d.lastSnapshot==null||p%d.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:p,timestamp_ns:f,format_version:ft}:{name:this.name,mode:"diff",diff:fs(d.lastSnapshot,c),seq:p,timestamp_ns:f,format_version:ft};if(d.tier.filter&&!d.tier.filter(g))return;let y;try{y=d.tier.save(g)}catch(b){n.onError?.(b,d.tier);return}if(y&&typeof y.then=="function"){let T=(d.savePending??Promise.resolve()).then(()=>y,()=>y).then(()=>{d.disposed||(d.seq=p,d.lastSnapshot=c,d.lastFingerprint=l)},w=>{n.onError?.(w,d.tier)});d.savePending=T.finally(()=>{d.savePending===T&&(d.savePending=void 0)})}else d.seq=p,d.lastSnapshot=c,d.lastFingerprint=l},s=(d,c)=>{try{o(d,c)}catch(l){n.onError?.(l,d.tier)}},i=(d,c)=>{if(!c.some(m=>{let h=this.config.messageTier(m[0]);return h>=3&&h<5}))return;if(n.filter){let m=this.tryResolve(d);if(m==null)return;let h=Dr(m,Ct("standard"));if(!n.filter(d,h))return}let p,f=()=>(p==null&&(p=this.snapshot()),p);for(let m of r)m.disposed||(m.debounceMs===0?s(m,f()):(m.timer==null&&(m.timer=new Le),m.timer.start(m.debounceMs,()=>{m.disposed||s(m,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(l=>{let p=this.tryResolve(l);return p==null?()=>{}:p.subscribe(f=>i(l,f))});a=()=>{for(let l of c)l()}}else a=this.observe().subscribe((d,c)=>i(d,c));let u=()=>{a();for(let d of r)d.disposed=!0,d.timer?.cancel();this._storageDisposers.delete(u)};return this._storageDisposers.add(u),{dispose:u}}async _cascadeRestore(e,n){for(let r of e){let o;try{o=await r.load?.()}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===ft&&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?.()}catch(u){r?.onError?.(u,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===ft&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(u){r?.onError?.(u,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:H(),...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(b=>!r.has(b)).sort(),i=[...r].filter(b=>!o.has(b)).sort(),a=[],u=[];for(let b of r){if(!o.has(b))continue;let v=e.nodes[b],T=n.nodes[b],w=v.v,x=T.v;w!=null&&x!=null&&w.id===x.id&&w.version!==x.version&&u.push({path:b,id:w.id,from:w.version,to:x.version});let k=w!=null&&x!=null&&w.id===x.id&&w.version===x.version;for(let S of["type","status","sentinel"]){let R=v[S],N=T[S];R!==N&&a.push({path:b,field:S,from:R,to:N})}if(!k)for(let S of["value","meta"]){let R=v[S],N=T[S];Jm(R,N)||a.push({path:b,field:S,from:R,to:N})}}let d=b=>`${b.from} ${b.to}`,c=new Set(e.edges.map(d)),l=new Set(n.edges.map(d)),p=n.edges.filter(b=>!c.has(d(b))),f=e.edges.filter(b=>!l.has(d(b))),m=new Set(e.subgraphs),h=new Set(n.subgraphs),g=[...h].filter(b=>!m.has(b)).sort(),y=[...m].filter(b=>!h.has(b)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:u,edgesAdded:p,edgesRemoved:f,subgraphsAdded:g,subgraphsRemoved:y}}};function fs(t,e){let n=Y.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 fn(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,u=new Map,d=new Map,c=new Set;for(let[v,T]of Object.entries(t.nodes)){if(!v)continue;c.add(v);let w=T.deps??[];i.set(v,w);for(let x of w)x&&(c.add(x),a.has(x)||a.set(x,new Set),a.get(x).add(v))}for(let v of t.edges){if(v==null||typeof v!="object")continue;let T=typeof v.from=="string"?v.from:"",w=typeof v.to=="string"?v.to:"";!T||!w||(c.add(T),c.add(w),d.has(T)||d.set(T,new Set),d.get(T).add(w),u.has(w)||u.set(w,new Set),u.get(w).add(T))}if(!c.has(e))return r.withDetail?o:[];let l=r.both===!0,p=v=>{if(l){let k=i.get(v)??[],S=u.get(v),R=a.get(v),N=d.get(v),_=[...k];return S&&_.push(...S),R&&_.push(...R),N&&_.push(...N),_}if(n==="upstream"){let k=i.get(v)??[],S=u.get(v);return S?[...k,...S]:k}let T=a.get(v),w=d.get(v),x=T?[...T]:[];return w&&x.push(...w),x},f=new Set([e]),m=new Map,h=[{path:e,depth:0}],g=0,y=!1;for(;g<h.length;){let v=h[g++];if(s!=null&&v.depth>=s){p(v.path).length>0&&(y=!0);continue}for(let T of p(v.path))!T||f.has(T)||(f.add(T),m.set(T,v.depth+1),h.push({path:T,depth:v.depth+1}))}let b=[...m.keys()].sort((v,T)=>v<T?-1:v>T?1:0);return r.withDetail?{paths:b,depths:m,truncated:y}:b}function cg(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}var Ts={};ke(Ts,{CqrsGraph:()=>vs,cqrs:()=>Ra,cqrsEventKeyOf:()=>hg,dispatchKeyOf:()=>yg,sagaInvocationKeyOf:()=>bg});Me();xe();$t();var va={};ke(va,{COMPLETE:()=>L,COMPLETE_MSG:()=>Oo,COMPLETE_ONLY_BATCH:()=>br,DATA:()=>E,DEFAULT_ACTOR:()=>bt,DIRTY:()=>ne,DIRTY_MSG:()=>Et,DIRTY_ONLY_BATCH:()=>Mn,ERROR:()=>C,GraphReFlyConfig:()=>nn,GuardDenied:()=>rt,INVALIDATE:()=>Je,INVALIDATE_MSG:()=>Mo,INVALIDATE_ONLY_BATCH:()=>yr,NodeImpl:()=>Ae,PAUSE:()=>Be,RESOLVED:()=>V,RESOLVED_MSG:()=>Nn,RESOLVED_ONLY_BATCH:()=>hr,RESUME:()=>qe,START:()=>dt,START_MSG:()=>_n,TEARDOWN:()=>le,TEARDOWN_MSG:()=>Co,TEARDOWN_ONLY_BATCH:()=>On,accessHintForGuard:()=>_r,advanceVersion:()=>Mr,autoTrackNode:()=>rn,batch:()=>X,configure:()=>ra,createVersioning:()=>In,defaultConfig:()=>$e,defaultHash:()=>jt,derived:()=>A,downWithBatch:()=>_t,dynamicNode:()=>Or,effect:()=>pe,isBatching:()=>tn,isV1:()=>ea,monotonicNs:()=>H,node:()=>z,normalizeActor:()=>Nt,pipe:()=>oa,policy:()=>Mt,policyFromRules:()=>Nr,producer:()=>K,registerBuiltins:()=>Er,resolveDescribeFields:()=>Ct,state:()=>M,wallClockNs:()=>oe});kr();Me();xe();Xi();$t();ae();_e();ee();Io();Me();ae();_e();ee();he();var jr=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,n){if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=n,n!==void 0){if(this._buf=new Array(n),e&&e.length>0){let r=Math.min(e.length,n),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._size+e;if(!(n<0||n>=this._size))return this._maxSize!==void 0?this._buf[(this._head+n)%this._maxSize]:this._buf[n]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=n;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let n=0;n<e;n++)this._buf[(this._head+n)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let n=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,n);else{for(let r=0;r<n;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+n)%this._maxSize}return this._size-=n,this._version+=1,n}slice(e,n){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(n!==void 0&&(!Number.isInteger(n)||n<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${n})`);let r=n===void 0?this._size:Math.min(Math.max(n,0),this._size),o=Math.min(e,this._size);if(o>=r)return[];let s=r-o;if(this._maxSize===void 0)return this._buf.slice(o,r);let i=new Array(s);for(let a=0;a<s;a++)i[a]=this._buf[(this._head+o+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let n=Math.min(e,this._size);return this.slice(this._size-n,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this._buf[(this._head+n)%this._maxSize];return e}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let n=0;n<e.length;n++)this._buf.push(e[n]);this._size=this._buf.length}else{let n=this._maxSize;for(let s=0;s<n;s++)this._buf[s]=void 0;this._head=0;let r=Math.min(e.length,n),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function $r(t){return t.subscribe(()=>{})}var lg=64;function Ve(t,e={}){let{name:n,maxSize:r,versioning:o,guard:s,backend:i}=e,a=i??new jr(t,r),u=M(a.toArray(),{name:n,describeKind:"state",equals:(k,S)=>k===S,...o!=null?{versioning:o}:{},...s!=null?{guard:s}:{}});function d(){let k=a.toArray();X(()=>{u.down([[ne]],{internal:!0}),u.down([[E,k]],{internal:!0})})}let c=new Map,l=new Map,p=new Map;function f(k,S){return`${k}:${S===void 0?"END":S}`}function m(k){if(k.size<lg)return;let S=k.keys().next();if(S.done)return;let R=k.get(S.value);R!==void 0&&R.dispose(),k.delete(S.value)}function h(k){let S=a.version;try{return k()}finally{a.version!==S&&d()}}function g(k){if(!Number.isInteger(k)||k<0)throw new RangeError(`tail: n must be a non-negative integer (got ${k})`);let S=c.get(k);if(S!==void 0)return c.delete(k),c.set(k,S),S.node;m(c);let R=A([u],([_])=>{let I=_;return k===0||I.length===0?[]:I.slice(Math.max(0,I.length-k))},{initial:a.tail(k),describeKind:"derived"}),N=$r(R);return c.set(k,{node:R,dispose:N}),R}function y(k,S){if(!Number.isInteger(k)||k<0)throw new RangeError(`slice: start must be a non-negative integer (got ${k})`);if(S!==void 0&&(!Number.isInteger(S)||S<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${S})`);let R=f(k,S),N=l.get(R);if(N!==void 0)return l.delete(R),l.set(R,N),N.node;m(l);let _=A([u],([O])=>{let P=O;return S===void 0?P.slice(k):P.slice(k,S)},{initial:a.slice(k,S),describeKind:"derived"}),I=$r(_);return l.set(R,{node:_,dispose:I}),_}function b(k){let S=p.get(k);if(S!==void 0)return S.node;let R=A([u,k],([_,I])=>{let O=_,P=Math.max(0,Math.trunc(I??0));return O.slice(P)},{initial:[],describeKind:"derived"}),N=$r(R);return p.set(k,{node:R,dispose:N}),R}let v,T;function w(){v===void 0&&(v=z([u],(k,S,R)=>{let N=k[0],I=N!=null&&N.length>0?N.at(-1):R.prevData[0];if(I==null||I.length===0){S.down([[V]]);return}S.emit(I[I.length-1])},{name:n!=null?`${n}::lastValue`:"lastValue",describeKind:"derived",initial:a.size===0?void 0:a.at(a.size-1)}),T=A([u],([k])=>k.length>0,{name:n!=null?`${n}::hasLatest`:"hasLatest",describeKind:"derived",initial:a.size>0}),$r(v),$r(T))}let x={entries:u,get size(){return a.size},at(k){return a.at(k)},append(k){h(()=>a.append(k))},appendMany(k){k.length!==0&&h(()=>a.appendMany(k))},clear(){h(()=>a.clear())},trimHead(k){h(()=>a.trimHead(k))},withLatest(){return w(),u},get lastValue(){return w(),v},get hasLatest(){return w(),T},view(k){switch(k.kind){case"tail":return g(k.n);case"slice":return y(k.start,k.stop);case"fromCursor":return b(k.cursor)}},attach(k){let S=k.subscribe(R=>{for(let N of R)N[0]===E&&x.append(N[1])});return()=>S()},attachStorage(k){if(k.length===0)return()=>{};let S=new Map;for(let N of k)S.set(N,a.size);(async()=>{for(let N of k)if(typeof N.loadEntries=="function")try{let _=await Promise.resolve(N.loadEntries());_.entries.length>0&&a.size===0&&(a.restore(_.entries),S.set(N,_.entries.length),d());break}catch{}})();let R=u.subscribe(N=>{for(let _ of N){if(_[0]!==E)continue;let I=_[1];for(let O of k){let P=S.get(O)??0;if(I.length<P){try{let j=O.appendEntries(I);j instanceof Promise&&j.catch(()=>{})}catch{}S.set(O,I.length);continue}if(I.length===P)continue;let B=I.slice(P);S.set(O,I.length);try{let j=O.appendEntries(B);j instanceof Promise&&j.catch(()=>{})}catch{}}}});return()=>R()},disposeAllViews(){for(let k of c.values())k.dispose();c.clear();for(let k of l.values())k.dispose();l.clear();for(let k of p.values())k.dispose();p.clear()},dispose(){for(let k of c.values())k.dispose();c.clear();for(let k of l.values())k.dispose();l.clear();for(let k of p.values())k.dispose();p.clear()}};return x}var Ta=new WeakMap;function bc(t){let e=Ta.get(t);if(e)return e;let n=t.map(c=>c.cache??[]),r=n.flat(),o=M(r,{name:"mergeReactiveLogs",describeKind:"state",equals:(c,l)=>c===l}),s=t.map((c,l)=>[...n[l]??[]]),i=[];for(let c=0;c<t.length;c++){let l=c,p=t[l].subscribe(f=>{for(let m of f)if(m[0]===E)s[l]=[...m[1]],o.emit(s.flat());else if(m[0]===L){s[l]=[];let h=i[l];h!==void 0&&(i[l]=void 0,h())}else m[0]===C&&o.down([[C,m[1]]])});i.push(p)}let a=re(o),u=!1,d={node:o,dispose(){if(!u){u=!0;for(let c of i)c?.();i.length=0,a(),Ta.delete(t)}}};return Ta.set(t,d),d}var ka={};ke(ka,{ENVELOPE_VERSION:()=>Cn,GRAPH_META_SEGMENT:()=>Qe,Graph:()=>Y,JsonCodec:()=>Ao,SIZEOF_OVERHEAD:()=>je,SIZEOF_SYMBOL:()=>ds,SNAPSHOT_VERSION:()=>ft,createDagCborCodec:()=>Ji,createDagCborZstdCodec:()=>Yi,decodeEnvelope:()=>Tr,diffForWAL:()=>fs,encodeEnvelope:()=>vr,explainPath:()=>Gr,graphProfile:()=>pn,mermaidLiveUrl:()=>ps,reachable:()=>fn,registerBuiltinCodecs:()=>wr,replayWAL:()=>Qi,sizeof:()=>Fr,validateGraphObservability:()=>wa,watchTopologyTree:()=>At});Lo();ae();function At(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(u=>{for(let d of u){if(d[0]!==E)continue;let c=d[1];if(e(c,o,s),c.kind==="added"&&c.nodeKind==="mount"){let l=o._mounts.get(c.name);if(l instanceof Y){let p=`${s}${c.name}::`;r(l,p)}}else if(c.kind==="removed"&&c.nodeKind==="mount"){let l=`${s}${c.name}::`;for(let[p,f]of Array.from(n.entries()))p!==t&&f.prefix.startsWith(l)&&(f.off(),n.delete(p))}}});i.off=a;for(let[u,d]of o._mounts)if(d instanceof Y){let c=`${s}${u}::`;r(d,c)}};return r(t,""),()=>{for(let o of n.values())o.off();n.clear()}}function wa(t,e={}){let n=[],r=e.requireFound??!0;if(e.skipDescribe!==!0)try{let d=t.describe(),c=new Set(Object.keys(d.nodes)),l=[];for(let[p,f]of Object.entries(d.nodes))for(let m of f.deps)m!==""&&!c.has(m)&&l.push(`${p} \u2192 ${m}`);for(let p of d.edges)c.has(p.from)||l.push(`edge.from: ${p.from}`),c.has(p.to)||l.push(`edge.to: ${p.to}`);l.length>0?n.push({kind:"describe",ok:!1,reason:`describe() has ${l.length} dangling pointer(s); nodes \u2289 deps`,danglingDeps:l}):n.push({kind:"describe",ok:!0,nodeCount:c.size,edgeCount:d.edges.length})}catch(d){n.push({kind:"describe",ok:!1,reason:`describe() threw: ${d instanceof Error?d.message:String(d)}`})}for(let d of e.formats??[])try{let c=t.describe({format:d});typeof c!="string"||c.length===0?n.push({kind:"describe-format",ok:!1,format:d,reason:`describe({ format: "${d}" }) returned empty or non-string output`}):n.push({kind:"describe-format",ok:!0,format:d,length:c.length})}catch(c){n.push({kind:"describe-format",ok:!1,format:d,reason:c instanceof Error?c.message:String(c)})}for(let d of e.paths??[])try{t.resolve(d),n.push({kind:"observe",ok:!0,path:d})}catch(c){n.push({kind:"observe",ok:!1,path:d,reason:c instanceof Error?c.message:String(c)})}for(let[d,c]of e.pairs??[])try{let l=t.explain(d,c);r&&l.found===!1?n.push({kind:"explain",ok:!1,from:d,to:c,reason:`explain(${d} \u2192 ${c}) found no path${l.reason?`: ${l.reason}`:""}`}):n.push({kind:"explain",ok:!0,from:d,to:c,found:l.found,steps:l.steps.length})}catch(l){n.push({kind:"explain",ok:!1,from:d,to:c,reason:l instanceof Error?l.message:String(l)})}let o=n.filter(d=>!d.ok),s=o.length===0,i=e.paths?.length??0,a=e.pairs?.length??0,u=e.formats?.length??0;return{ok:s,checks:n,failures:o,summary(){let d=[e.skipDescribe===!0?null:"describe",u>0?`${u} format${u===1?"":"s"}`:null,i>0?`${i} observe path${i===1?"":"s"}`:null,a>0?`${a} explain pair${a===1?"":"s"}`:null].filter(l=>l!=null),c=d.length>0?d.join(", "):"describe-only";return s?`validateGraphObservability: OK (${c})`:`validateGraphObservability: ${o.length} failure(s) across ${c}`}}}var Wt=class extends Error{constructor(e,n){super(e,n),this.name=this.constructor.name}},ms=class extends Wt{constructor(n,r){super(`Duplicate ${n} registration: "${r}"`);this.kind=n;this.registrationName=r}},gs=class extends Wt{constructor(n,r,o){super(`Command "${n}" emitted undeclared event "${r}". Declared emits: [${o.join(", ")}]`);this.commandName=n;this.eventName=r;this.declaredEmits=o}},hs=class extends Wt{constructor(n,r,o){super(`Optimistic concurrency conflict on aggregate "${n}": expected version ${r}, got ${o}`);this.aggregateId=n;this.expected=r;this.actual=o}},ys=class extends Wt{constructor(n){super(`Unknown command: "${n}". Register with command() first.`);this.commandName=n}},Br=class extends Wt{constructor(n,r){super(`Command handler "${n}" threw: ${r instanceof Error?r.message:String(r)}`,{cause:r});this.commandName=n}};var Vr=class extends Wt{constructor(n,r){super(`Projection "${n}" rebuild failed: ${r instanceof Error?r.message:String(r)}`,{cause:r});this.projectionName=n}};Me();xe();$t();ae();ee();var pg=Mt((t,e)=>{t("observe"),t("signal"),e("write")});function kt(t){let e=Ve([],{name:t.name,maxSize:t.retainedLimit??1024,guard:t.guard??pg,...t.versioning!=null?{versioning:t.versioning}:{}});return e.withLatest(),t.graph&&t.graph.add(e.entries,{name:t.name}),e}function vc(t){if(t===null||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.keys(t))vc(t[e]);return Object.freeze(t)}function fg(t){let n=(t.cache??0)+1;return t.down([[ne],[E,n]]),n}function Yn(t,e){let n=e.freeze??!0;return function(...o){let s=n?o.map(vc):o,i=oe(),a,u,d=!1,c;try{X(()=>{e.seq&&(c=fg(e.seq));try{if(a=t(...s),e.onSuccess){let l=e.onSuccess(s,a,{t_ns:i,seq:c});if(l!==void 0){let p=e.handlerVersion!=null?{...l,handlerVersion:e.handlerVersion}:l;e.audit.append(p)}}}catch(l){throw u=l,d=!0,l}})}catch(l){if(d&&e.onFailure){let p=u instanceof Error?u.name:typeof u,f=e.onFailure(s,u,{t_ns:i,seq:c,errorType:p});if(f!==void 0){let m=e.handlerVersion!=null?{...f,handlerVersion:e.handlerVersion}:f;e.audit.append(m)}}throw d?u:l}return a}}function bs(t,e,n=0){let r=M(n,{name:e,describeKind:"state"});return t.add(r,{name:e}),r}function Tc(t,e,n,r=0){let o={},s=new Y(e);for(let i of n){let a=M(r,{name:i,describeKind:"state"});s.add(a,{name:i}),o[i]=a}return t.mount(e,s),o}Me();ae();_e();he();function mt(t,e){t!=null&&_t(n=>t.down(n),[[E,e]],$e.tierOf)}function Kr(t,e){let n=t.cache??0;return n>=e?!1:(t.down([[ne],[E,n+1]]),!0)}function ze(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}function qr(t){return t.relatedTo?.[0]??t.summary}var mg=Mt((t,e)=>{t("write"),t("signal"),e("observe")}),gg=Mt((t,e)=>{t("observe"),t("signal"),e("write")}),wc=Mt((t,e)=>{t("observe"),t("signal"),e("write")});function Hr(t,e){return ze("cqrs",t,e)}function xa(t){if(t===null||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.keys(t))xa(t[e]);return Object.freeze(t)}var hg=t=>`${t.type}::${t.aggregateId??"__default__"}`,yg=t=>t.commandName,bg=t=>t.eventType,vs=class extends Y{_eventLogs=new Map;_eventLogsByAggregate=new Map;_aggregateVersions=new Map;_aggregateLru=new Map;_commandRegs=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_seq=0;_retainedLimit;_freezeCommandPayload;_freezeEventPayload;_maxAggregates;_dispatchSeqCursor;dispatches;audit;aggregateEvictions;constructor(e,n={}){super(e,n.graph),this._retainedLimit=n.retainedLimit??1024,this._freezeCommandPayload=n.freezeCommandPayload??!0,this._freezeEventPayload=n.freezeEventPayload??!0,this._maxAggregates=n.maxAggregates??1e4,this.dispatches=kt({name:"dispatches",retainedLimit:this._retainedLimit,graph:this}),this.audit=this.dispatches,this.aggregateEvictions=kt({name:"aggregateEvictions",retainedLimit:this._retainedLimit,graph:this}),this._dispatchSeqCursor=bs(this,"dispatch_seq",0)}aggregateVersion(e,n){return this._aggregateVersions.get(`${e}::${n}`)??0}_touchAggregate(e){this._aggregateLru.delete(e),this._aggregateLru.set(e,!0)}_enforceAggregateLru(){for(;this._aggregateLru.size>this._maxAggregates;){let e=this._aggregateLru.keys().next();if(e.done)break;let n=e.value;this._aggregateLru.delete(n);let r=n.indexOf("::");if(r<0)continue;let o=n.slice(0,r),s=n.slice(r+2),i=this._aggregateVersions.get(n)??0;this._aggregateVersions.delete(n);let a=this._eventLogsByAggregate.get(o);a&&(a.delete(s),a.size===0&&this._eventLogsByAggregate.delete(o)),this.aggregateEvictions.append({aggregateId:s,type:o,lastVersion:i,t_ns:oe()})}}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}_attachedEventTiers=[];_attachedTierDisposers=new Map;attachEventStorage(e){this._attachedEventTiers.push(e);for(let[n,r]of this._eventLogs){let o=r.log.attachStorage(e),s=this._attachedTierDisposers.get(n);s||(s=[],this._attachedTierDisposers.set(n,s)),s.push(o)}for(let[n,r]of this._eventLogsByAggregate)for(let[o,s]of r){let i=`${n}::${o}`,a=s.log.attachStorage(e),u=this._attachedTierDisposers.get(i);u||(u=[],this._attachedTierDisposers.set(i,u)),u.push(a)}return()=>{let n=this._attachedEventTiers.indexOf(e);n>=0&&this._attachedEventTiers.splice(n,1)}}_autoWireStreamStorage(e,n){if(this._attachedEventTiers.length===0)return;let r=this._attachedTierDisposers.get(e);r||(r=[],this._attachedTierDisposers.set(e,r));for(let o of this._attachedEventTiers)r.push(n.attachStorage(o))}_bumpDispatchSeq(){let n=(this._dispatchSeqCursor.cache??0)+1;return this._dispatchSeqCursor.emit(n),n}event(e,n){if(n!==void 0)return this._ensureAggregateStream(e,n).node;let r=this._eventLogs.get(e);if(r)return r.node;let o=Ve([],{name:e,versioning:0,maxSize:this._retainedLimit});o.withLatest();let s=o.entries,i=A([s],([a])=>a,{name:e,describeKind:"state",meta:Hr("event",{event_name:e}),guard:wc,initial:s.cache});return this.add(i,{name:e}),this._keepaliveDisposers.push(re(i)),this._eventLogs.set(e,{log:o,node:i}),this._autoWireStreamStorage(e,o),i}_ensureAggregateStream(e,n){this._eventLogs.has(e)||this.event(e);let r=this._eventLogsByAggregate.get(e);r||(r=new Map,this._eventLogsByAggregate.set(e,r));let o=`${e}::${n}`;this._touchAggregate(o);let s=r.get(n);if(s)return s;let i=`${e}_${n.replace(/[^a-zA-Z0-9_-]/g,"_")}`,a=Ve([],{name:i,versioning:0,maxSize:this._retainedLimit});a.withLatest();let u=a.entries,d=A([u],([f])=>f,{name:i,describeKind:"state",meta:Hr("event_aggregate",{event_name:e,aggregate_id:n}),guard:wc,initial:u.cache}),c=i,l=0;for(;this.nameOf(this.resolveOptional(c)??d)===c&&(l+=1,c=`${i}_${l}`,this.resolveOptional(c)!==void 0););try{this.add(d,{name:c})}catch{}this._keepaliveDisposers.push(re(d));let p={log:a,node:d};return r.set(n,p),this._autoWireStreamStorage(`${e}::${n}`,a),this._enforceAggregateLru(),p}resolveOptional(e){try{return this.resolve(e)}catch{return}}_appendEvent(e,n,r){let o=this._eventLogs.get(e);if(o||(this.event(e),o=this._eventLogs.get(e)),o.node.status==="completed"||o.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${o.node.status}).`);let s,i;if(r?.aggregateId!==void 0){let c=`${e}::${r.aggregateId}`;s=(this._aggregateVersions.get(c)??0)+1,this._aggregateVersions.set(c,s),i=this._ensureAggregateStream(e,r.aggregateId)}let a=o.log.entries.v,u=this._freezeEventPayload?xa(n):n,d={type:e,payload:u,timestampNs:oe(),seq:++this._seq,...r?.aggregateId!==void 0?{aggregateId:r.aggregateId}:{},...s!==void 0?{aggregateVersion:s}:{},...r?.correlationId!==void 0?{correlationId:r.correlationId}:{},...r?.causationId!==void 0?{causationId:r.causationId}:{},...r?.metadata!==void 0?{metadata:Object.freeze({...r.metadata})}:{},...r?.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{},...a!=null?{v0:{id:a.id,version:a.version}}:{}};return o.log.append(d),i&&i.log.append(d),d}command(e,n){if(this._commandRegs.has(e))throw new ms("command",e);let r=typeof n=="function"?{handler:n}:n,o=M(void 0,{name:e,describeKind:"state",meta:{...Hr("command",{command_name:e}),error:null},guard:mg});if(this.add(o,{name:e}),this._commandRegs.set(e,{handler:r.handler,...r.emits!==void 0?{emits:r.emits}:{},...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),r.emits)for(let s of r.emits)this._eventLogs.has(s)||this.event(s);return o}dispatch(e,n,r){let o=this._commandRegs.get(e);if(!o)throw new ys(e);if(r?.aggregateId!==void 0&&r.expectedAggregateVersion!==void 0&&o.emits!==void 0){let p=0;for(let f of o.emits){let m=this._aggregateVersions.get(`${f}::${r.aggregateId}`);m!==void 0&&m>p&&(p=m)}if(p!==r.expectedAggregateVersion)throw new hs(r.aggregateId,r.expectedAggregateVersion,p)}let s=this.resolve(e),i=this._freezeCommandPayload?xa(n):n,a=[],u=oe(),d=0,c,l=!1;try{X(()=>{d=this._bumpDispatchSeq(),s.emit(i,{internal:!0});try{o.handler(i,{emit:(p,f)=>{if(o.emits!==void 0&&!o.emits.includes(p))throw new gs(e,p,o.emits);a.push(p),this._appendEvent(p,f,{...r?.aggregateId!==void 0?{aggregateId:r.aggregateId}:{},...r?.correlationId!==void 0?{correlationId:r.correlationId}:{},...r?.causationId!==void 0?{causationId:r.causationId}:{},...r?.metadata!==void 0?{metadata:Object.freeze({...r.metadata})}:{},...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}}),s.meta.error.emit(null,{internal:!0}),this.dispatches.append({commandName:e,payload:i,status:"success",emittedEvents:[...a],t_ns:u,seq:d,...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}catch(p){throw c=p,l=!0,p}})}catch(p){if(l){s.meta.error.emit(c,{internal:!0});let f=c instanceof Error?c.name:typeof c,m=c instanceof Br?c:new Br(e,c);this.dispatches.append({commandName:e,payload:i,status:"failed",error:m,errorType:f,emittedEvents:[...a],t_ns:u,seq:d,...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}throw l?c:p}}projection(e){let{name:n,events:r,reducer:o,initial:s}=e,i=e.mode??"scan",a=e.freezeInputs??!0,u=e.snapshot,d=r.map(N=>(this._eventLogs.has(N)||this.event(N),this._eventLogs.get(N).node));function c(N){N.sort((_,I)=>_.timestampNs-I.timestampNs||_.seq-I.seq||(_.aggregateId??"").localeCompare(I.aggregateId??""))}function l(N){let _=[];for(let I of N)_.push(...I);return c(_),_}let p=d.map(N=>N.cache??[]),f=l(p),m=a?Object.freeze(f):f,h=0,g=s;i==="scan"&&f.length>0&&(g=o(s,m),h=f.length);let y=i==="replay"?o(s,m):g,b=u?.saveDebounceMs??1e3,v=u?.saveEvery??1e3,T,w=0;function x(N){if(u?.save){if(w+=1,w>=v){w=0,T!==void 0&&(clearTimeout(T),T=void 0);let _=u.save(N);_ instanceof Promise&&_.catch(()=>{});return}T!==void 0&&clearTimeout(T),T=setTimeout(()=>{T=void 0,w=0;let _=u.save(N);_ instanceof Promise&&_.catch(()=>{})},b)}}let k=A(d,N=>{let _=l(N),I;if(i==="replay"){let O=a?Object.freeze(_):_;I=o(s,O)}else{let O=_.slice(h);h=_.length;let P=a?Object.freeze(O):O;I=o(g,P),g=I}return x(I),I},{name:n,describeKind:"derived",meta:Hr("projection",{projection_name:n,source_events:r}),guard:gg,initial:y});return this.add(k,{name:n}),this._keepaliveDisposers.push(re(k)),this._keepaliveDisposers.push(()=>{T!==void 0&&(clearTimeout(T),T=void 0)}),this._projections.add(n),{node:k,rebuild:async N=>{try{let _=N?.pageSize??1e3,I=N?.fromTier??this._attachedEventTiers[0]?.[0],O=l(d.map(B=>B.cache??[])).length,P=s;if(u?.load){let B=await u.load();B!==void 0&&(P=B)}if(!I||!I.loadEntries){let B=l(d.map(D=>D.cache??[])),j=a?Object.freeze(B):B;P=o(P,j)}else{let B=new Set(r),j,D=!1;for(;!D;){let Z=await I.loadEntries({cursor:j,pageSize:_}),F=[...Z.entries].filter(G=>B.has(G.type));c(F);let Q=a?Object.freeze(F):F;P=o(P,Q),j=Z.cursor,D=!j||Z.entries.length===0}}if(i==="scan"){let B=l(d.map(D=>D.cache??[])),j=B.slice(O);if(j.length>0){let D=a?Object.freeze(j):j;P=o(P,D)}g=P,h=B.length}return k.emit(P,{internal:!0}),P}catch(_){throw new Vr(n,_)}},reset:async()=>{try{let N=s;if(u?.load){let P=await u.load();P!==void 0&&(N=P)}let _=l(d.map(P=>P.cache??[])),I=a?Object.freeze(_):_,O=o(N,I);return i==="scan"&&(g=O,h=_.length),k.emit(O,{internal:!0}),O}catch(N){throw new Vr(n,N)}}}}saga(e,n,r,o={}){let s=n.map(f=>(this._eventLogs.has(f)||this.event(f),this._eventLogs.get(f).node)),i=Tc(this,`${e}_cursor`,n,0),a=kt({name:`${e}_invocations`,retainedLimit:this._retainedLimit,graph:this}),u=o.aggregateId,d=o.errorPolicy??"advance",c=new Map;for(let f of n){let m=i[f];c.set(f,m.cache??0);let h=m.subscribe(g=>{for(let y of g)y[0]===E&&c.set(f,y[1])});this._keepaliveDisposers.push(h)}let l={},p=z(s,(f,m)=>{let h=l.n.meta.error;for(let g=0;g<f.length;g++){let y=f[g];if(y==null||y.length===0)continue;let b=y.at(-1);if(!b)continue;let v=n[g],T=i[v],w=c.get(v)??0;if(b.length>w){let x=b.slice(w),k=w;for(let S of x){let R=S;if(u!==void 0&&R.aggregateId!==u){k+=1;continue}try{r(R),h.emit(null,{internal:!0}),a.append({eventType:v,status:"success",aggregateId:R.aggregateId,event:R,t_ns:oe(),...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}}),k+=1}catch(N){if(h.emit(N,{internal:!0}),a.append({eventType:v,status:"failed",error:N,errorType:N instanceof Error?N.name:typeof N,aggregateId:R.aggregateId,event:R,t_ns:oe(),...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}}),d==="hold")break;k+=1}}T.emit(k)}}},{name:e,describeKind:"effect",meta:{...Hr("saga",{saga_name:e,source_events:n}),error:null}});return l.n=p,this.add(p,{name:e}),this._keepaliveDisposers.push(re(p)),this._sagas.add(e),{node:p,invocations:a,audit:a,cursors:i}}};function Ra(t,e){return new vs(t,e)}var Ea=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},Na=class{graph=new Y("request");onModuleDestroy(){this.graph.destroy()}},kc,Sa;kc=[(0,Wr.Module)({})];var zt=class zt{static forRoot(e){let n=e??{},r=n.name??"root",o=[{provide:ct,useFactory:()=>{let s=new Y(r);return n.build&&n.build(s),n.snapshot&&s.restore(n.snapshot),s}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:s=>new Ea(s),inject:[ct]},{provide:cn,useFactory:(s,i)=>new cn(s,i),inject:[ct,xc.ModuleRef]}];if(n.nodes)for(let s of n.nodes)o.push({provide:lt(s),useFactory:i=>i.resolve(s),inject:[ct]});return n.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new Na,scope:Wr.Scope.REQUEST},{provide:on,useFactory:s=>s.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:Wr.Scope.REQUEST}),{module:zt,global:!0,providers:o,exports:[ct,...(n.nodes??[]).map(lt),...n.requestScope?[on]:[]]}}static forFeature(e){let n=[{provide:ot(e.name),useFactory:r=>{let o=new Y(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),r.mount(e.name,o),o},inject:[ct]}];if(e.nodes)for(let r of e.nodes)n.push({provide:lt(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[ot(e.name)]});return{module:zt,providers:n,exports:[ot(e.name),...(e.nodes??[]).map(r=>lt(`${e.name}::${r}`))]}}static forCqrs(e){let n=[{provide:ot(e.name),useFactory:r=>{let o=Ra(e.name,e.cqrs);return e.eventStorage&&o.attachEventStorage(e.eventStorage),e.build&&e.build(o),r.mount(e.name,o),o},inject:[ct]}];if(e.nodes)for(let r of e.nodes)n.push({provide:lt(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[ot(e.name)]});return{module:zt,providers:n,exports:[ot(e.name),...(e.nodes??[]).map(r=>lt(`${e.name}::${r}`))]}}};Sa=rd(null),zt=id(Sa,0,"GraphReflyModule",kc,zt),sd(Sa,1,zt);var ws=zt;var xs={};ke(xs,{useStore:()=>vg,useSubscribe:()=>Rc,useSubscribeRecord:()=>Tg});var Lt=require("react");ae();function Rc(t){return(0,Lt.useSyncExternalStore)(e=>{let n=!1,r=t.subscribe(()=>{n||e()});return()=>{n=!0,r()}},()=>t.cache,()=>t.cache)}function vg(t){let e=Rc(t),n=(0,Lt.useCallback)(r=>{t.down([[ne],[E,r]])},[t]);return[e,n]}function Tg(t,e){let n=(0,Lt.useRef)(e);n.current=e;let r=(0,Lt.useMemo)(()=>{let o=()=>{let i={},a=t.cache??[];for(let u of a){let d=n.current(u),c={};for(let l of Object.keys(d))c[l]=d[l].cache;i[u]=c}return i},s=o();return{subscribe:i=>{let a=!1,u=[],d=()=>{for(let p of u)p();u=[]},c=p=>{d();for(let f of p){let m=n.current(f);for(let h of Object.keys(m)){let g=m[h].subscribe(()=>{s=o(),a||i()});u.push(g)}}s=o(),a||i()},l=t.subscribe(p=>{let f=p.some(m=>m[0]===E||m[0]===V);!a&&f&&c(t.cache??[])});return c(t.cache??[]),()=>{a=!0,l(),d()}},getSnapshot:()=>s}},[t]);return(0,Lt.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot)}var Ss={};ke(Ss,{Signal:()=>wg});Me();ae();ee();var Qn=[];function Rs(t){let e=t.cache;return t.subscribe(r=>{for(let[o,s]of r)o===E&&(e=s)})(),e}var _a=class{_node;_equals;constructor(e,n){this._equals=n?.equals??Object.is,this._node=M(e,{...n,resubscribable:!0,resetOnTeardown:!0})}get(){let e=Qn[Qn.length-1];return e?(this._node.status==="sentinel"&&Rs(this._node),e(this._node)):this._node.status==="sentinel"?Rs(this._node):this._node.cache}set(e){this._equals(this.get(),e)||X(()=>{this._node.down([[ne],[E,e]])})}},Ma=class{_node;constructor(e,n){this._node=rn(r=>{Qn.push(r);try{return e()}finally{Qn.pop()}},{...n,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=Qn[Qn.length-1];return e?(this._node.status==="sentinel"&&Rs(this._node),e(this._node)):this._node.status==="sentinel"?Rs(this._node):this._node.cache}},wg={State:_a,Computed:Ma,sub:(t,e)=>{let n=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,r=!0;return t._node.subscribe(o=>{for(let[s,i]of o){if(s===E){if(r){r=!1;continue}n.data?.(i)}s===C&&n.error?.(i),s===L&&n.complete?.()}})}};var Es={};ke(Es,{useStore:()=>kg,useSubscribe:()=>Sc,useSubscribeRecord:()=>xg});var It=require("solid-js");ae();function Sc(t){let[e,n]=(0,It.createSignal)(t.cache,{equals:!1}),r=t.subscribe(()=>{n(()=>t.cache)});return(0,It.getOwner)()?(0,It.onCleanup)(()=>r()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),e}function kg(t){return[Sc(t),r=>{t.down([[ne],[E,r]])}]}function xg(t,e){let[n,r]=(0,It.createSignal)({},{equals:!1}),o=[],s=()=>{for(let d of o)d();o=[]},i=()=>{let d={};for(let c of t.cache??[]){let l=e(c),p={};for(let f of Object.keys(l))p[f]=l[f].cache;d[c]=p}return d},a=d=>{s();for(let c of d){let l=e(c);for(let p of Object.keys(l)){let f=l[p].subscribe(()=>{r(()=>i())});o.push(f)}}r(()=>i())},u=t.subscribe(d=>{d.some(c=>c[0]===E||c[0]===V)&&a(t.cache??[])});return a(t.cache??[]),(0,It.getOwner)()?(0,It.onCleanup)(()=>{u(),s()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),n}var Ns={};ke(Ns,{useStore:()=>Sg,useSubscribe:()=>Rg,useSubscribeRecord:()=>Eg});ae();function Rg(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n}}}function Sg(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n},set(e){t.down([[ne],[E,e]])},update(e){let n=e(t.cache);t.down([[ne],[E,n]])}}}function Eg(t,e){return{subscribe(n){let r=[],o=()=>{for(let u of r)u();r=[]},s=()=>{let u={};for(let d of t.cache??[]){let c=e(d),l={};for(let p of Object.keys(c))l[p]=c[p].cache;u[d]=l}return u},i=u=>{o();for(let d of u){let c=e(d);for(let l of Object.keys(c)){let p=c[l].subscribe(()=>{n(s())});r.push(p)}}n(s())},a=t.subscribe(u=>{u.some(d=>d[0]===E||d[0]===V)&&i(t.cache??[])});return i(t.cache??[]),()=>{a(),o()}}}}var _s={};ke(_s,{useStore:()=>_g,useSubscribe:()=>Ng,useSubscribeRecord:()=>Mg});var Ke=require("vue");ae();function Ng(t){let e=(0,Ke.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,Ke.getCurrentScope)()?(0,Ke.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,Ke.readonly)(e)}function _g(t){let e=(0,Ke.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,Ke.getCurrentScope)()?(0,Ke.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useStore called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,Ke.computed)({get:()=>e.value,set:r=>{t.down([[ne],[E,r]])}})}function Mg(t,e){let n=(0,Ke.shallowRef)({}),r=new Map;function o(){let a={};for(let[u,d]of r)a[u]={...d.values};n.value=a}function s(a){for(let d of r.values())for(let c of d.subs)c();r.clear();for(let d of a){let c=e(d),l=Object.keys(c),p={},f=[];for(let m of l){let h=c[m];p[m]=h.cache;let g=h.subscribe(()=>{p[m]=h.cache,o()});f.push(g)}r.set(d,{subs:f,values:p})}let u={};for(let[d,c]of r)u[d]={...c.values};n.value=u}return(0,Ke.watch)(()=>[...(typeof t=="function"?t():(0,Ke.isRef)(t)?t.value:t)??[]],a=>s(a??[]),{immediate:!0}),(0,Ke.getCurrentScope)()?(0,Ke.onScopeDispose)(()=>{for(let a of r.values())for(let u of a.subs)u();r.clear()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,Ke.readonly)(n)}var Ms={};ke(Ms,{create:()=>Cg});ae();ee();var Og=()=>!1;function Cg(t){let e=new Y("zustand"),n=M(void 0,{name:"state",equals:Og});e.add(n,{name:"state"});let r=()=>n.cache,o=(a,u)=>{let d=n.cache,c=typeof a=="function"?a(d):a;n.emit(u?c:{...d,...c})},s={getState:r,setState:o,getInitialState:()=>i,subscribe:a=>{let u=!0,d=n.cache;return n.subscribe(c=>{for(let[l,p]of c)if(l===E){if(u){u=!1;continue}a(p,d),d=p}})},destroy:e.destroy.bind(e)},i=t(o,r,s);return n.emit(i),Object.assign(e,s)}var Wa={};ke(Wa,{CircuitOpenError:()=>pt,ContentAddressedMissError:()=>eo,NS_PER_MS:()=>He,NS_PER_SEC:()=>at,NativeIndexBackend:()=>ro,NativeListBackend:()=>oo,NativeLogBackend:()=>jr,NativeMapBackend:()=>Xr,NativePubSubBackend:()=>no,RateLimiterOverflowError:()=>an,ResettableTimer:()=>Le,TimeoutError:()=>un,appendLogStorage:()=>Ka,audit:()=>zc,awaitSettled:()=>es,buffer:()=>Uc,bufferCount:()=>Jc,bufferTime:()=>Qc,cached:()=>Kd,canonicalJson:()=>to,cascadingCache:()=>sp,catchError:()=>al,checkpointToRedis:()=>Ql,checkpointToS3:()=>Yl,circuitBreaker:()=>wt,combine:()=>Aa,combineLatest:()=>ol,concat:()=>jc,concatMap:()=>Kc,constant:()=>qo,contentAddressedStorage:()=>Ps,createTransport:()=>Jt,createWatermarkController:()=>Un,csvRows:()=>Al,debounce:()=>Ia,debounceTime:()=>sl,decorrelatedJitter:()=>Uo,defer:()=>jd,delay:()=>Hc,deserializeError:()=>yn,dictKv:()=>bp,dictSnapshot:()=>vp,distill:()=>Ls,distinctUntilChanged:()=>Gc,elementAt:()=>Ic,empty:()=>Gd,escapeRegexChar:()=>ca,exhaustMap:()=>Vc,exponential:()=>Wo,externalBundle:()=>Os,externalProducer:()=>mn,fallback:()=>Hn,fibonacci:()=>zo,filter:()=>Xe,find:()=>Lc,first:()=>Cs,firstValueFrom:()=>Ye,firstWhere:()=>Yo,flatMap:()=>qc,forEach:()=>qt,fromAny:()=>U,fromAsyncIter:()=>Ir,fromCSV:()=>Cl,fromClickHouseWatch:()=>Dl,fromCron:()=>Qo,fromDrizzle:()=>np,fromEvent:()=>Dd,fromHTTP:()=>$a,fromHTTPPoll:()=>yl,fromHTTPStream:()=>hl,fromIter:()=>Xo,fromKafka:()=>Nl,fromKysely:()=>rp,fromMCP:()=>Tl,fromNATS:()=>$l,fromNDJSON:()=>Pl,fromOTel:()=>wl,fromPrisma:()=>tp,fromPrometheus:()=>El,fromPromise:()=>zn,fromPulsar:()=>Gl,fromRabbitMQ:()=>Bl,fromRaf:()=>Pd,fromRedisStream:()=>Ml,fromSSE:()=>gl,fromSqlite:()=>Xl,fromSqliteCursor:()=>Zl,fromStatsD:()=>Rl,fromSyslog:()=>kl,fromTimer:()=>st,fromWebSocket:()=>Fa,fromWebSocketReconnect:()=>vl,fromWebhook:()=>ul,globToRegExp:()=>Ld,interval:()=>el,jsonCodec:()=>tr,jsonCodecFor:()=>gp,keepalive:()=>re,kvStorage:()=>js,last:()=>Ac,linear:()=>Ho,lru:()=>Va,makeHttpError:()=>ht,map:()=>zr,matchesAnyPattern:()=>Id,matchesCron:()=>Ko,memoryAppendLog:()=>yp,memoryBackend:()=>io,memoryKv:()=>ao,memorySnapshot:()=>hp,merge:()=>xt,mergeMap:()=>La,mergeReactiveLogs:()=>bc,nameToSignal:()=>gn,ndjsonRows:()=>Ll,never:()=>Fd,nodeSignal:()=>ts,of:()=>la,onFirstData:()=>Jr,pairwise:()=>Fc,parseCron:()=>Vo,parsePrometheusText:()=>ja,parseSSEStream:()=>Dt,parseStatsD:()=>Sl,parseSyslog:()=>xl,pausable:()=>nl,pubsub:()=>cp,race:()=>Bc,rateLimiter:()=>qn,reactiveCounter:()=>pa,reactiveIndex:()=>fp,reactiveList:()=>Ds,reactiveLog:()=>Ve,reactiveMap:()=>Ze,reactiveSink:()=>We,reduce:()=>Mc,repeat:()=>tl,replay:()=>Zo,rescue:()=>Yr,resolveBackoffPreset:()=>Bt,retry:()=>Tt,sample:()=>Wc,scan:()=>_c,serializeError:()=>hn,share:()=>Vd,shareReplay:()=>qd,signalToName:()=>Ut,singleFromAny:()=>Gs,singleNodeFromAny:()=>mp,skip:()=>Ca,snapshotStorage:()=>$s,sortJsonValue:()=>so,stableJsonString:()=>Fs,stratify:()=>uo,switchMap:()=>Te,take:()=>Ur,takeUntil:()=>Cc,takeWhile:()=>Oc,tap:()=>Pc,tapFirst:()=>Dc,throttle:()=>Pa,throttleTime:()=>il,throwError:()=>$d,timeout:()=>Wn,toArray:()=>Bd,toCSV:()=>Kl,toClickHouse:()=>ql,toFile:()=>Ba,toHTTP:()=>dl,toKafka:()=>_l,toLoki:()=>Ul,toMongo:()=>zl,toNATS:()=>jl,toObservable:()=>Bo,toPostgres:()=>Wl,toPulsar:()=>Fl,toRabbitMQ:()=>Vl,toReadableStream:()=>ml,toRedisStream:()=>Ol,toS3:()=>Hl,toSSE:()=>pl,toSSEBytes:()=>fl,toSqlite:()=>ep,toTempo:()=>Jl,toWebSocket:()=>bl,tokenBucket:()=>Vt,valve:()=>rl,verifiable:()=>up,window:()=>Zc,windowCount:()=>Yc,windowTime:()=>Xc,withBreaker:()=>Kn,withLatestFrom:()=>Pt,withMaxAttempts:()=>ua,withStatus:()=>Kt,workerBridge:()=>qa,workerSelf:()=>Ha,zip:()=>$c});Me();xe();ae();_e();ee();Me();ae();ee();function Ec(t){return{describeKind:"producer",...t}}function mn(t,e){return K(n=>{let r=!0,o={emit(i){r&&n.emit(i)},error(i){r&&(r=!1,n.down([[C,i]]))},complete(){r&&(r=!1,n.down([[L]]))}},s;try{let i=t(o);s=typeof i=="function"?i:void 0}catch(i){return o.error(i),()=>{r=!1}}return()=>{r=!1;try{s?.()}catch{}}},Ec(e))}function Os(t,e,n){let r=!0,o,s=0,i=0,a={},u=[],d=()=>{let f=o;o=void 0;try{f?.()}catch{}};for(let f of e){let m=n?.name?`${n.name}::${f}`:f,h=n?.channelOpts?.[f],g=K(y=>(s++,()=>{i++,s>0&&i>=s&&i>=e.length&&d()}),Ec({...h,name:m}));a[f]=g,u.push(g)}let c={};for(let f of e)c[f]=m=>{r&&a[f].down([[E,m]])};c.error=f=>{r&&(r=!1,X(()=>{for(let m of u)m.down([[C,f]])}),d())},c.complete=()=>{r&&(r=!1,X(()=>{for(let f of u)f.down([[L]])}),d())};let l=t(c);return o=typeof l=="function"?l:void 0,Object.assign(a,{dispose:()=>{r&&(r=!1,X(()=>{for(let f of u)try{f.down([[L]])}catch{}}),d())}})}xe();ae();_e();ee();he();function ue(t){return{describeKind:"derived",...t}}function Nc(t){return{describeKind:"derived",partial:!0,...t}}function zr(t,e,n){return z([t],(r,o)=>{let s=r[0];if(s==null||s.length===0){o.down([[V]]);return}for(let i of s)o.emit(e(i))},ue(n))}function Xe(t,e,n){return z([t],(r,o)=>{let s=r[0];if(s==null||s.length===0){o.down([[V]]);return}let i=!1;for(let a of s)e(a)&&(o.emit(a),i=!0);i||o.down([[V]])},ue(n))}function _c(t,e,n,r){return z([t],(o,s,i)=>{"acc"in i.store||(i.store.acc=n);let a=o[0];if(a==null||a.length===0){s.down([[V]]);return}for(let u of a)i.store.acc=e(i.store.acc,u),s.emit(i.store.acc)},{...ue(r),initial:n,resetOnTeardown:!0})}function Mc(t,e,n,r){return z([t],(o,s,i)=>{if("acc"in i.store||(i.store.acc=n),i.terminalDeps[0]===!0){s.emit(i.store.acc),s.down([[L]]);return}let a=o[0];if(a==null||a.length===0){s.down([[V]]);return}for(let u of a)i.store.acc=e(i.store.acc,u)},{...ue(r),completeWhenDepsComplete:!1})}function Ur(t,e,n){return e<=0?z([t],(r,o,s)=>{s.store.completed||(s.store.completed=!0,o.down([[L]]))},{...ue(n),completeWhenDepsComplete:!1}):z([t],(r,o,s)=>{if("taken"in s.store||(s.store.taken=0),s.store.done){o.down([[V]]);return}if(s.terminalDeps[0]===!0){s.store.done=!0,o.down([[L]]);return}let i=r[0];if(i==null||i.length===0){o.down([[V]]);return}for(let a of i)if(s.store.taken++,o.emit(a),s.store.taken>=e){s.store.done=!0,o.down([[L]]);return}},{...ue(n),completeWhenDepsComplete:!1})}function Ca(t,e,n){return z([t],(r,o,s)=>{"skipped"in s.store||(s.store.skipped=0);let i=r[0];if(i==null||i.length===0){o.down([[V]]);return}let a=!1;for(let u of i)s.store.skipped++,s.store.skipped<=e||(o.emit(u),a=!0);a||o.down([[V]])},ue(n))}function Oc(t,e,n){return z([t],(r,o,s)=>{if(s.store.done){o.down([[V]]);return}let i=r[0];if(i==null||i.length===0){o.down([[V]]);return}for(let a of i){if(!e(a)){s.store.done=!0,o.down([[L]]);return}o.emit(a)}},{...ue(n),completeWhenDepsComplete:!1})}function Cc(t,e,n){let r=n?.predicate??(i=>i[0]===E),{predicate:o,...s}=n??{};return K(i=>{let a=!1,u=t.subscribe(c=>{if(!a)for(let l of c){if(a)return;l[0]===E?i.emit(l[1]):(l[0]===L||l[0]===C)&&(a=!0,i.down([l]))}}),d=e.subscribe(c=>{if(!a)for(let l of c){if(a)return;if(r(l)){a=!0,i.down([[L]]);return}}});return()=>{u(),d()}},ue(s))}function Cs(t,e){return Ur(t,1,e)}function Ac(t,e){let{defaultValue:n,...r}=e??{},o=e!=null&&Object.hasOwn(e,"defaultValue");return z([t],(s,i,a)=>{if(a.terminalDeps[0]===!0){a.store.has?i.emit(a.store.latest):o&&i.emit(n),i.down([[L]]);return}let u=s[0];if(u==null||u.length===0){i.down([[V]]);return}a.store.latest=u.at(-1),a.store.has=!0},{...ue(r),completeWhenDepsComplete:!1})}function Lc(t,e,n){return Ur(Xe(t,e,n),1,n)}function Ic(t,e,n){return Ur(Ca(t,e,n),1,n)}function Pc(t,e,n){if(typeof e=="function")return z([t],(o,s)=>{let i=o[0];if(i==null||i.length===0){s.down([[V]]);return}for(let a of i)e(a),s.emit(a)},ue(n));let r=e;return z([t],(o,s,i)=>{if(i.terminalDeps[0]!==void 0){i.terminalDeps[0]===!0?(r.complete?.(),s.down([[L]])):(r.error?.(i.terminalDeps[0]),s.down([[C,i.terminalDeps[0]]]));return}let a=o[0];if(a==null||a.length===0){s.down([[V]]);return}for(let u of a)r.data?.(u),s.emit(u)},{...ue(n),completeWhenDepsComplete:!1})}function Jr(t,e,n){let r=n?.where??(s=>s!=null),o=!1;return z([t],(s,i)=>{let a=s[0];if(a==null||a.length===0){i.down([[V]]);return}for(let u of a)!o&&r(u)&&(o=!0,e(u)),i.emit(u)},ue(n))}var Dc=Jr;function Gc(t,e=Object.is,n){return z([t],(r,o,s)=>{let i=r[0];if(i==null||i.length===0){o.down([[V]]);return}let a=!1;for(let u of i)s.store.hasPrev&&e(s.store.prev,u)||(s.store.prev=u,s.store.hasPrev=!0,o.emit(u),a=!0);a||o.down([[V]])},ue(n))}function Fc(t,e){return z([t],(n,r,o)=>{let s=n[0];if(s==null||s.length===0){r.down([[V]]);return}let i=!1;for(let a of s)if(!o.store.hasPrev)o.store.prev=a,o.store.hasPrev=!0;else{let u=[o.store.prev,a];o.store.prev=a,r.emit(u),i=!0}i||r.down([[V]])},ue(e))}function Aa(...t){let e=[...t];return A(e,n=>n,{...ue(),equals:(n,r)=>{if(n.length!==r.length)return!1;for(let o=0;o<n.length;o++)if(!Object.is(n[o],r[o]))return!1;return!0}})}function Pt(t,e,n){return z([t,e],(r,o,s)=>{let i=r[0],a=r[1],u=a!=null&&a.length>0?a.at(-1):s.prevData[1];if(i!=null&&i.length>0){if(!(a!=null&&a.length>0)&&s.prevData[1]===void 0){o.down([[V]]);return}for(let d of i)o.emit([d,u])}else o.down([[V]])},Nc(n))}function xt(...t){return t.length===0?K(e=>{e.down([[L]])},ue()):K(e=>{let n=t.length,r=0,o=[];for(let s of t){let i=s.subscribe(a=>{for(let u of a)u[0]===E?e.emit(u[1]):u[0]===L?(r+=1,r>=n&&e.down([[L]])):u[0]===C&&e.down([u])});o.push(i)}return()=>{for(let s of o)s()}},ue())}function $c(...t){let e=t.length;return e===0?K(n=>{n.emit([]),n.down([[L]])},ue()):K(n=>{let r=Array.from({length:e},()=>[]),o=e;function s(){for(;r.every(a=>a.length>0);){let a=r.map(u=>u.shift());n.emit(a)}}let i=[];for(let a=0;a<e;a++){let u=a,d=t[a].subscribe(c=>{for(let l of c)l[0]===E?(r[u].push(l[1]),s()):l[0]===L?(o-=1,(o===0||r[u].length===0)&&n.down([[L]])):l[0]===C&&n.down([l])});i.push(d)}return()=>{for(let a of i)a()}},ue())}function jc(t,e,n){return K(r=>{let o=0,s=[],i,a;return a=e.subscribe(u=>{for(let d of u)o===0?d[0]===E?s.push(d[1]):d[0]===C&&r.down([d]):d[0]===E?r.emit(d[1]):(d[0]===L||d[0]===C)&&r.down([d])}),i=t.subscribe(u=>{for(let d of u)if(o===0)if(d[0]===E)r.emit(d[1]);else if(d[0]===L){o=1;for(let c of s)r.emit(c);s.length=0}else d[0]===C&&r.down([d])}),()=>{i?.(),a?.()}},ue(n))}function Bc(...t){return t.length===0?K(e=>{e.down([[L]])},ue()):t.length===1?z([t[0]],(e,n)=>{let r=e[0];if(r==null||r.length===0){n.down([[V]]);return}for(let o of r)n.emit(o)},ue()):K(e=>{let n=null,r=[];for(let o=0;o<t.length;o++){let s=o,i=t[o].subscribe(a=>{for(let u of a){if(n!==null&&s!==n)return;u[0]===E?(n===null&&(n=s),e.emit(u[1])):(u[0]===L||u[0]===C)&&(n===null||s===n)&&e.down([u])}});r.push(i)}return()=>{for(let o of r)o()}},ue())}function As(t,e,n){let r,o=!1,s=()=>{o||(o=!0,n())};return r=t.subscribe(i=>{let a=!1,u=!1;for(let d of i)d[0]!==dt&&(d[0]===E?e.emit(d[1]):d[0]===L?a=!0:d[0]===C?(u=!0,e.down([d])):(d[0]===ne||d[0]===V)&&e.down([d]));u?(r?.(),r=void 0,s()):a&&s()}),()=>{r?.(),r=void 0}}function Te(t,e,n){let r,o=!1;function s(){r?.(),r=void 0}return z([t],(i,a,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){s();return}if(u.terminalDeps[0]===!0){o=!0,r||a.down([[L]]);return}let d=i[0];if(!(d==null||d.length===0))return s(),r=As(U(e(d[d.length-1])),a,()=>{s(),o&&a.down([[L]])}),{deactivate:()=>{s(),o=!1}}},{...ue(n),completeWhenDepsComplete:!1})}function Vc(t,e,n){let r,o=!1;function s(){r?.(),r=void 0}return z([t],(i,a,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){s();return}if(u.terminalDeps[0]===!0){o=!0,r||a.down([[L]]);return}let d=i[0];if(!(d==null||d.length===0))return r===void 0?r=As(U(e(d[0])),a,()=>{s(),o&&a.down([[L]])}):a.down([[V]]),{deactivate:()=>{s(),o=!1}}},{...ue(n),completeWhenDepsComplete:!1})}function Kc(t,e,n){let{maxBuffer:r,...o}=n??{},s=[],i,a=!1,u;function d(){i?.(),i=void 0}function c(){if(!u||i!==void 0)return;if(s.length===0){a&&u.down([[L]]);return}let p=s.shift();i=As(U(e(p)),u,()=>{d(),c()})}function l(p){r&&r>0&&s.length>=r&&s.shift(),s.push(p),c()}return z([t],(p,f,m)=>{if(u=f,m.terminalDeps[0]!=null&&m.terminalDeps[0]!==!0){d(),s.length=0;return}if(m.terminalDeps[0]===!0){a=!0,c();return}let h=p[0];if(!(h==null||h.length===0)){for(let g of h)l(g);return{deactivate:()=>{d(),s.length=0,a=!1}}}},{...ue(o),completeWhenDepsComplete:!1})}function La(t,e,n){let{concurrent:r,...o}=n??{},s=r!=null&&r>0?r:Number.POSITIVE_INFINITY,i=0,a=!1,u=new Set,d=[],c;function l(){a&&i===0&&d.length===0&&c&&c.down([[L]])}function p(g){if(!c)return;i++;let y;y=As(U(e(g)),c,()=>{y&&u.delete(y),i--,f(),l()}),u.add(y)}function f(){for(;d.length>0&&i<s;)p(d.shift())}function m(g){i<s?p(g):d.push(g)}function h(){for(let g of u)g();u.clear(),i=0,d.length=0}return z([t],(g,y,b)=>{if(c=y,b.terminalDeps[0]!=null&&b.terminalDeps[0]!==!0){h();return}if(b.terminalDeps[0]===!0){a=!0,l();return}let v=g[0];if(!(v==null||v.length===0)){for(let T of v)m(T);return{deactivate:()=>{h(),a=!1}}}},{...ue(o),completeWhenDepsComplete:!1})}var qc=La;function Hc(t,e,n){return K(r=>{let o=new Set;function s(){for(let a of o)clearTimeout(a);o.clear()}let i=t.subscribe(a=>{for(let u of a)if(u[0]===E){let d=setTimeout(()=>{o.delete(d),r.emit(u[1])},e);o.add(d)}else if(u[0]===L){let d=setTimeout(()=>{o.delete(d),r.down([[L]])},e);o.add(d)}else u[0]===C&&(s(),r.down([u]))});return()=>{i(),s()}},ue(n))}function Ia(t,e,n){return K(r=>{let o,s;function i(){o!==void 0&&(clearTimeout(o),o=void 0)}let a=t.subscribe(u=>{for(let d of u)d[0]===E?(i(),s=d[1],o=setTimeout(()=>{o=void 0,r.emit(s)},e)):d[0]===L?(o!==void 0&&(i(),r.emit(s)),r.down([[L]])):d[0]===C&&(i(),r.down([d]))});return()=>{a(),i()}},ue(n))}function Pa(t,e,n){let{leading:r,trailing:o,...s}=n??{},i=r!==!1,a=o===!0,u=e*1e6;return K(d=>{let c,l=-1/0,p,f=!1;function m(){c!==void 0&&(clearTimeout(c),c=void 0)}let h=t.subscribe(g=>{for(let y of g)if(y[0]===E){let b=y[1],v=H();if(i&&v-l>=u)l=v,d.emit(b),m(),a&&(c=setTimeout(()=>{c=void 0,f&&(l=H(),d.emit(p),f=!1)},e));else if(a&&(p=b,f=!0,c===void 0)){let T=(v-l)/1e6;c=setTimeout(()=>{c=void 0,f&&(l=H(),d.emit(p),f=!1)},Math.max(0,e-T))}}else(y[0]===L||y[0]===C)&&(m(),d.down([y]))});return()=>{h(),m()}},ue(s))}function Wc(t,e,n){return K(r=>{let o,s=!1,i=!1,a=t.subscribe(d=>{if(!s)for(let c of d){if(s)return;c[0]===E?o={v:c[1]}:c[0]===C?(s=!0,r.down([c])):c[0]===L&&(i=!0,o=void 0)}}),u=e.subscribe(d=>{if(!s)for(let c of d){if(s)return;c[0]===E?o!==void 0&&!i&&r.emit(o.v):c[0]===C?(s=!0,r.down([c])):c[0]===L&&(s=!0,r.down([[L]]))}});return()=>{a(),u()}},ue(n))}function zc(t,e,n){return K(r=>{let o,s,i=!1;function a(){o!==void 0&&(clearTimeout(o),o=void 0)}let u=t.subscribe(d=>{for(let c of d)c[0]===E?(s=c[1],i=!0,a(),o=setTimeout(()=>{o=void 0,i&&(i=!1,r.emit(s))},e)):(c[0]===L||c[0]===C)&&(a(),r.down([c]))});return()=>{u(),a()}},ue(n))}function Uc(t,e,n){return K(r=>{let o=[],s=t.subscribe(a=>{for(let u of a)u[0]===E?o.push(u[1]):u[0]===L?(o.length>0&&r.emit([...o]),o.length=0,r.down([[L]])):u[0]===C&&r.down([u])}),i=e.subscribe(a=>{for(let u of a)u[0]===E?o.length>0&&(r.emit([...o]),o.length=0):u[0]===L?r.down([[L]]):u[0]===C&&r.down([u])});return()=>{s(),i(),o.length=0}},ue(n))}function Jc(t,e,n){if(e<=0)throw new RangeError("bufferCount expects count > 0");return K(r=>{let o=[],s=t.subscribe(i=>{for(let a of i)a[0]===E?(o.push(a[1]),o.length>=e&&r.emit(o.splice(0,o.length))):a[0]===L?(o.length>0&&r.emit([...o]),o.length=0,r.down([[L]])):a[0]===C&&r.down([a])});return()=>{s(),o.length=0}},ue(n))}function Yc(t,e,n){if(e<=0)throw new RangeError("windowCount expects count > 0");return K(r=>{let o,s=0;function i(){let u=K(d=>(o=d.down.bind(d),()=>{o=void 0}),ue());s=0,r.emit(u)}let a=t.subscribe(u=>{for(let d of u)d[0]===E?(o||i(),o?.([[E,d[1]]]),s+=1,s>=e&&(o?.([[L]]),o=void 0)):d[0]===L?(o?.([[L]]),o=void 0,r.down([[L]])):d[0]===C&&(o?.([d]),o=void 0,r.down([d]))});return()=>{a(),o?.([[L]]),o=void 0}},ue(n))}function Qc(t,e,n){return K(r=>{let o=[],s=setInterval(()=>{o.length>0&&(r.emit([...o]),o.length=0)},e),i=t.subscribe(a=>{for(let u of a)u[0]===E?o.push(u[1]):u[0]===L?(clearInterval(s),o.length>0&&r.emit([...o]),o.length=0,r.down([[L]])):u[0]===C&&(clearInterval(s),r.down([u]))});return()=>{i(),clearInterval(s),o.length=0}},ue(n))}function Xc(t,e,n){return K(r=>{let o;function s(){o?.([[L]]),o=void 0}function i(){let d=K(c=>(o=c.down.bind(c),()=>{o=void 0}),ue());r.emit(d)}i();let a=setInterval(()=>{s(),i()},e),u=t.subscribe(d=>{for(let c of d)c[0]===E?o?.([[E,c[1]]]):c[0]===L?(clearInterval(a),s(),r.down([[L]])):c[0]===C&&(clearInterval(a),o?.([c]),s(),r.down([c]))});return()=>{u(),clearInterval(a),s()}},ue(n))}function Zc(t,e,n){return K(r=>{let o;function s(){o?.([[L]]),o=void 0}function i(){let d=K(c=>(o=c.down.bind(c),()=>{o=void 0}),ue());r.emit(d)}let a=t.subscribe(d=>{for(let c of d)c[0]===E?(o||i(),o?.([[E,c[1]]])):c[0]===L?(s(),r.down([[L]])):c[0]===C&&(o?.([c]),o=void 0,r.down([c]))}),u=e.subscribe(d=>{for(let c of d)c[0]===E&&(s(),i())});return()=>{a(),u(),s()}},ue(n))}function el(t,e){return K((n,r)=>{"n"in r.store||(r.store.n=0);let o=setInterval(()=>{n.emit(r.store.n),r.store.n=r.store.n+1},t);return()=>clearInterval(o)},ue(e))}function tl(t,e,n){if(e<=0)throw new RangeError("repeat expects count > 0");return K(r=>{let o=e,s,i=()=>{s?.(),s=t.subscribe(a=>{let u=!1,d=[];for(let c of a)c[0]===L?u=!0:d.push(c);d.length>0&&r.down(d),u&&(s?.(),s=void 0,o-=1,o>0?i():r.down([[L]]))})};return i(),()=>{s?.()}},ue(n))}function nl(t,e){return z([t],(n,r)=>{let o=n[0];if(o==null||o.length===0){r.down([[V]]);return}for(let s of o)r.emit(s)},ue(e))}function Yr(t,e,n){return K(r=>{let o=t.subscribe(s=>{for(let i of s)if(i[0]===E)r.emit(i[1]);else if(i[0]===C)try{r.emit(e(i[1]))}catch(a){r.down([[C,a]])}else i[0]===L&&r.down([[L]])});return()=>{o()}},ue(n))}function rl(t,e,n){return z([t,e],(r,o,s)=>{let i=r[1];if(!(i!=null&&i.length>0?i.at(-1):s.prevData[1])){o.down([[V]]);return}let u=r[0];if(u!=null&&u.length>0){for(let d of u)o.emit(d);return}if(i!=null&&i.length>0&&s.prevData[0]!==void 0){o.emit(s.prevData[0]);return}o.down([[V]])},Nc(n))}var ol=Aa,sl=Ia,il=Pa,al=Yr;ae();_e();ee();Vn();var Da=class{ring;arr;constructor(e){e===Number.POSITIVE_INFINITY||e<=0?(this.arr=[],this.ring=null):(this.ring=new ln(e),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(e){this.ring!=null?this.ring.push(e):this.arr.push(e)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let n=this.ring.toArray();return this.ring.clear(),n}let e=this.arr;return this.arr=[],e}};function Qr(t){return t instanceof Error?t:new Error(String(t))}function Ag(t){return t===void 0?null:typeof t=="string"?Bt(t):t}function We(t,e){let{name:n,onTransportError:r,retry:o,backpressure:s,batchSize:i=Number.POSITIVE_INFINITY,flushIntervalMs:a=0,serialize:u,stopOn:d,onUpstreamMessage:c,onDispose:l,send:p,sendBatch:f,ctx:m}=e;if(!p&&!f)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let h=m,g=Math.max(1,o?.maxAttempts??1),y=Ag(o?.backoff??(g>1?"exponential":void 0)),b=o?.shouldRetry??(()=>!0),v=f!==void 0||i<Number.POSITIVE_INFINITY||a>0,T=W=>n?`${n}::${W}`:void 0,w=M(void 0,{equals:()=>!1,name:T("sent")}),x=M(null,{name:T("failed")}),k=M(0,{name:T("inFlight")}),S=M(null,{name:T("errors")}),R=v?M(0,{name:T("buffered")}):void 0,N=s?M(!1,{name:T("paused")}):void 0,_=0,I=W=>{_+=W,k.down([[E,_]])},O=W=>{try{r?.(W)}catch{}try{S.down([[E,W]])}catch{}},P=new Set,B=W=>{P.add(W);let de=()=>P.delete(W);W.then(de,de)},j=(W,de,Se)=>{let Ee=y?y(de-1,Se,null):0,ce=Ee==null?0:typeof Ee=="number"&&Ee>0?Ee:0,Pe=Math.max(1,Math.ceil(ce/1e6));return new Promise(me=>{setTimeout(()=>me(W()),Pe)})},D=W=>W!=null&&typeof W=="object"&&typeof W.then=="function",Z=W=>{let de;try{de=u?u(W):W}catch(me){let ge=Qr(me);return O({stage:"serialize",error:ge,value:W}),x.down([[E,{value:W,error:ge,attempts:0}]]),Promise.resolve()}let Se=0,Ee=me=>{I(-1);let ge=Qr(me);if(O({stage:"send",error:ge,value:W,attempt:Se}),!(Se<g&&b(ge,Se))){x.down([[E,{value:W,error:ge,attempts:Se}]]);return}return j(Pe,Se,ge)},ce=()=>{I(-1),w.down([[E,W]])};function Pe(){Se+=1,I(1);let me;try{me=p(de,h)}catch(ge){return Ee(ge)??Promise.resolve()}return D(me)?me.then(ce,ge=>Ee(ge)):(ce(),Promise.resolve())}return Pe()},F=s?.maxBuffer??Number.POSITIVE_INFINITY,Q=new Da(F),G,q=!1,$=()=>{R?.down([[E,Q.length]])},te=W=>{N&&N.down([[E,W]])},Re=s?.strategy??"drop-oldest",Oe=(W,de)=>{let Se={value:W,payload:de};if(Q.length<F)return Q.push(Se),$(),!0;if(Re==="drop-oldest"){let ce=Q.shift();return Q.push(Se),$(),te(!0),x.down([[E,{value:ce.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(Re==="drop-newest")return te(!0),x.down([[E,{value:W,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let Ee=new Error("backpressure: buffer overflow");return O({stage:"send",error:Ee,value:W}),x.down([[E,{value:W,error:Ee,attempts:0}]]),te(!0),!1},Ce=W=>{let de=0,Se=W.map(me=>me.payload),Ee=me=>{I(-1);let ge=Qr(me);if(O({stage:"send",error:ge,value:W.map(Sn=>Sn.value),attempt:de}),!(de<g&&b(ge,de))){for(let{value:Sn}of W)x.down([[E,{value:Sn,error:ge,attempts:de}]]);return}return j(Pe,de,ge)},ce=()=>{I(-1);for(let{value:me}of W)w.down([[E,me]])};function Pe(){de+=1,I(1);let me;try{me=f(Se,h)}catch(ge){return Ee(ge)??Promise.resolve()}return D(me)?me.then(ce,ge=>Ee(ge)):(ce(),Promise.resolve())}return Pe()},ye=async W=>{for(let de of W)await Ge(de.value,de.payload)},Ge=(W,de)=>{let Se=0,Ee=me=>{I(-1);let ge=Qr(me);if(O({stage:"send",error:ge,value:W,attempt:Se}),!(Se<g&&b(ge,Se))){x.down([[E,{value:W,error:ge,attempts:Se}]]);return}return j(Pe,Se,ge)},ce=()=>{I(-1),w.down([[E,W]])};function Pe(){Se+=1,I(1);let me;try{me=p(de,h)}catch(ge){return Ee(ge)??Promise.resolve()}return D(me)?me.then(ce,ge=>Ee(ge)):(ce(),Promise.resolve())}return Pe()},ie=()=>{if(q||Q.length===0)return Promise.resolve();let W=Q.drain();if($(),te(!1),f!==void 0){let Se=Ce(W);return B(Se),Se}let de=ye(W);return B(de),de},we=()=>{G!==void 0||q||a<=0||(G=setTimeout(()=>{G=void 0,ie()},a))},Fe=t.subscribe(W=>{for(let de of W){let Se=de[0];if(Se!==E)try{c?.(de)}catch{}if(Se===E){let Ee=de[1];if(v){let ce;if(u)try{ce=u(Ee)}catch(me){let ge=Qr(me);O({stage:"serialize",error:ge,value:Ee}),x.down([[E,{value:Ee,error:ge,attempts:0}]]);continue}else ce=Ee;if(!Oe(Ee,ce))continue;Q.length>=i?ie():we()}else{let ce=Z(Ee);B(ce)}}else $e.messageTier(Se)>=3&&v&&(G!==void 0&&(clearTimeout(G),G=void 0),ie())}}),be;if(d){let W=!1;be=d.subscribe(de=>{if(!W){W=!0;return}de.length>0&&!J&&se()})}let J=!1,se=()=>{if(J)return;J=!0,G!==void 0&&(clearTimeout(G),G=void 0),v&&ie(),q=!0,be?.(),Fe();let W=de=>{try{de.down([[le]])}catch{}};W(S),W(x),W(w),W(k),R&&W(R),N&&W(N);try{l?.()}catch{}},ve={dispose:se,sent:w,failed:x,inFlight:k,errors:S};return v&&(ve.buffered=R,ve.flush=async()=>{q||(await ie(),await Promise.all(P))}),N&&(ve.paused=N),ve}Ot();he();function gt(t){return{describeKind:"producer",...t}}function Fa(t,e){let{parse:n,closeOnTeardown:r=!1,...o}=e??{};return K(s=>{let i=!0,a,u=()=>{let y=a;a=void 0,y?.()},d=y=>{i&&(i=!1,s.down([y]),u())},c=(y,b=y)=>{if(i)try{let v=y!==null&&typeof y=="object"&&"data"in y?y.data:y,T=n?n(v,b):v;s.emit(T)}catch(v){d([C,v])}},l=y=>{d([C,y])},p=()=>{d([L])};if(typeof t=="function"){try{if(a=t(c,l,p),typeof a!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(y){d([C,y])}return()=>{i=!1,u()}}let f=t,m=y=>c(y,y),h=y=>l(y),g=()=>p();return f.addEventListener("message",m),f.addEventListener("error",h),f.addEventListener("close",g),a=()=>{f.removeEventListener("message",m),f.removeEventListener("error",h),f.removeEventListener("close",g),r&&f.close()},()=>{i=!1,u()}},gt(o))}function ul(t,e){return mn(t,e)}function $a(t,e){let{method:n="GET",headers:r,body:o,transform:s=v=>v.json(),timeoutNs:i=30*1e9,signal:a,completeAfterFetch:u=!1,refetchOnSubscribe:d=!1,...c}=e??{},l=M(0,{name:`${c.name??"http"}/fetchCount`}),p=M(0,{name:`${c.name??"http"}/lastUpdated`}),f=M(!1,{name:`${c.name??"http"}/fetched`}),m=0,h=o!==void 0?typeof o=="string"?o:JSON.stringify(o):void 0,g=v=>{let T=new AbortController,w=!0;if(a?.aborted)return w=!1,v.down([[C,a.reason??new Error("Aborted")]]),()=>{};a?.addEventListener("abort",()=>T.abort(a.reason),{once:!0});let x=setTimeout(()=>T.abort(new Error("Request timeout")),Math.ceil(i/1e6));return fetch(t,{method:n,headers:r,body:h,signal:T.signal}).then(async k=>{if(clearTimeout(x),!w)return;if(!k.ok)throw new Error(`HTTP ${k.status}: ${k.statusText}`);let S=await s(k);w&&(X(()=>{m+=1,l.down([[E,m]]),p.down([[E,oe()]]),f.down([[E,!0]]),v.emit(S)}),u&&v.down([[L]]))}).catch(k=>{clearTimeout(x),w&&(k&&k.name==="AbortError"||v.down([[C,k]]))}),()=>{w=!1,T.abort()}},y=K(v=>g({emit:T=>v.emit(T),down:T=>v.down(T)}),{...gt(c),resubscribable:d});return{...Kt(y),fetchCount:l,lastUpdated:p,fetched:f}}function dl(t,e,n){let{method:r="POST",headers:o={"Content-Type":"application/json"},serialize:s=m=>JSON.stringify(m),timeoutNs:i,batchFormat:a="json-array",batchSize:u,flushIntervalMs:d,retry:c,onTransportError:l}=n??{},p=async m=>{let h=i!==void 0?new AbortController:void 0,g;h&&i!==void 0&&(g=setTimeout(()=>h.abort(new Error("Request timeout")),Math.ceil(i/1e6)));try{let y=await fetch(e,{method:r,headers:o,body:m,signal:h?.signal}),b=async()=>{try{await y.arrayBuffer?.()}catch{}};if(!y.ok)throw await b(),new Error(`HTTP ${y.status}: ${y.statusText}`);await b()}finally{g!==void 0&&clearTimeout(g)}};return u!==void 0||d!==void 0?We(t,{onTransportError:l,retry:c,batchSize:u,flushIntervalMs:d,sendBatch:async m=>{let h;a==="ndjson"?h=m.map(g=>{let y=s(g);return typeof y=="string"?y:new TextDecoder().decode(y)}).join(`
16
16
  `):h=JSON.stringify(m),await p(h)}}):We(t,{onTransportError:l,retry:c,serialize:s,send:async m=>{await p(m)}})}function cl(t){return Symbol.keyFor(t)??t.description??"message"}function Xn(t,e){return typeof t=="string"?t:e(t)}function ll(t,e){let n=`event: ${t}
17
17
  `;if(e!==void 0){let r=e.split(/\r?\n/);for(let o of r)n+=`data: ${o}
18
18
  `}return`${n}