@graphrefly/graphrefly 0.39.0 → 0.40.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.
- package/dist/{cascading-g2_rhhaM.d.ts → cascading-BNfxffgc.d.ts} +1 -1
- package/dist/{cascading-BzuxW0_w.d.cts → cascading-Cxs1eztH.d.cts} +1 -1
- package/dist/{chunk-7JRF5YEK.js → chunk-2BX4NB34.js} +1 -1
- package/dist/{chunk-TFPZLQ5H.js → chunk-2DMKW2AD.js} +1 -1
- package/dist/{chunk-7NZMZJMW.js → chunk-2QXRYP7Q.js} +1 -1
- package/dist/{chunk-NQI2C36M.js → chunk-32N3JALT.js} +1 -1
- package/dist/{chunk-CGDMTXSY.js → chunk-6I726LZU.js} +1 -1
- package/dist/{chunk-S2U57TFC.js → chunk-6VWBPSSY.js} +1 -1
- package/dist/chunk-6XVD5TZV.js +1 -0
- package/dist/{chunk-VJJLIEAL.js → chunk-756D5TFD.js} +1 -1
- package/dist/{chunk-XQ55HO5N.js → chunk-7Q4ZD3YW.js} +1 -1
- package/dist/{chunk-ZOX3LBRV.js → chunk-B7LCDQEV.js} +1 -1
- package/dist/{chunk-IA7DUNGB.js → chunk-CKFQS2CJ.js} +1 -1
- package/dist/{chunk-R75BMDLA.js → chunk-ECQRP2UT.js} +1 -1
- package/dist/{chunk-L7WY6TZS.js → chunk-FHRBBHJN.js} +1 -1
- package/dist/{chunk-JNMC2WJ6.js → chunk-I2DEVPMU.js} +1 -1
- package/dist/chunk-INQFTVZA.js +61 -0
- package/dist/{chunk-N7UIBZCW.js → chunk-J63M5U46.js} +1 -1
- package/dist/{chunk-7SD73DS6.js → chunk-JKBOIJ22.js} +1 -1
- package/dist/chunk-K2Z7UENB.js +1 -0
- package/dist/{chunk-INH6FS2G.js → chunk-LCGAVGGV.js} +1 -1
- package/dist/{chunk-LQNOXGET.js → chunk-LYM4PBMV.js} +1 -1
- package/dist/{chunk-KD4NHLMU.js → chunk-MNZIKXK4.js} +1 -1
- package/dist/{chunk-RF3QZP6D.js → chunk-N43XM7BM.js} +1 -1
- package/dist/{chunk-5XRI6RM3.js → chunk-OSZ22J7O.js} +1 -1
- package/dist/{chunk-WHIZM6JV.js → chunk-PPUYQ66A.js} +1 -1
- package/dist/{chunk-SC7BQDNP.js → chunk-QSK3RRII.js} +1 -1
- package/dist/chunk-RZJDIV2G.js +1 -0
- package/dist/{chunk-HX3EGQ5Z.js → chunk-SSCGRYJ2.js} +1 -1
- package/dist/chunk-SVFKHUCW.js +1 -0
- package/dist/chunk-TSOYJ743.js +1 -0
- package/dist/{chunk-HAWKGIXM.js → chunk-UWA6D7UF.js} +1 -1
- package/dist/{chunk-GX5LSSRE.js → chunk-VMF23LGB.js} +1 -1
- package/dist/{chunk-5LK7XMEV.js → chunk-WL6LFPJB.js} +1 -1
- package/dist/{chunk-D47YVDR5.js → chunk-WUT362QV.js} +1 -1
- package/dist/{chunk-INHC33EH.js → chunk-XJLYLLIJ.js} +1 -1
- package/dist/{chunk-GEAO3TL3.js → chunk-XW4YDF6G.js} +1 -1
- package/dist/{chunk-XEUANKBO.js → chunk-YKD7WUYJ.js} +1 -1
- package/dist/{chunk-AU7YTQX7.js → chunk-YXDRGKXP.js} +1 -1
- package/dist/{chunk-7QFRK3N3.js → chunk-Z4F3DOWS.js} +1 -1
- package/dist/compat/index.d.cts +6 -6
- package/dist/compat/index.d.ts +6 -6
- package/dist/compat/index.js +1 -1
- package/dist/compat/nestjs/index.d.cts +4 -4
- package/dist/compat/nestjs/index.d.ts +4 -4
- package/dist/compat/nestjs/index.js +1 -1
- package/dist/compat/zustand/index.d.cts +2 -2
- package/dist/compat/zustand/index.d.ts +2 -2
- package/dist/compat/zustand/index.js +1 -1
- package/dist/{composite-DGatA-JK.d.ts → decay-BnrlbxSv.d.ts} +38 -2
- package/dist/{composite-CKd0e2vz.d.cts → decay-C25AyNAj.d.cts} +38 -2
- package/dist/extra/index.cjs +15 -15
- package/dist/extra/index.d.cts +6 -6
- package/dist/extra/index.d.ts +6 -6
- package/dist/extra/index.js +1 -1
- package/dist/extra/node.js +1 -1
- package/dist/extra/operators.js +1 -1
- package/dist/extra/reactive.d.cts +1 -1
- package/dist/extra/reactive.d.ts +1 -1
- package/dist/extra/reactive.js +1 -1
- package/dist/extra/render/index.d.cts +1 -1
- package/dist/extra/render/index.d.ts +1 -1
- package/dist/extra/sources.cjs +1 -1
- package/dist/extra/sources.js +1 -1
- package/dist/graph/index.d.cts +3 -3
- package/dist/graph/index.d.ts +3 -3
- package/dist/graph/index.js +1 -1
- package/dist/{graph-30XSgtVX.d.ts → graph-BkIkog4h.d.ts} +1 -1
- package/dist/{graph-BUwMAxJI.d.cts → graph-E6likq7w.d.cts} +1 -1
- package/dist/{index-BXd6OMEy.d.ts → index-3k4Gg6-n.d.ts} +2 -2
- package/dist/{index-DszPlZzK.d.ts → index-40ZT4MHj.d.ts} +1 -1
- package/dist/index-8s-Qm-gz.d.ts +218 -0
- package/dist/{index-K-vl_c6A.d.cts → index-A3U3CSve.d.cts} +1 -1
- package/dist/{index-jKLph6cu.d.ts → index-B6iTqKtJ.d.ts} +1 -1
- package/dist/{index-WyFKER-c.d.ts → index-B72TQQHd.d.cts} +3 -3
- package/dist/{index-CmqiJZKM.d.ts → index-BAQrjuZF.d.ts} +64 -6
- package/dist/{index-CusEP3Sv.d.ts → index-BQ1fR4li.d.ts} +1 -1
- package/dist/{index-xZYcDqFH.d.cts → index-BTHOTC0Q.d.cts} +2 -2
- package/dist/{index-jr6PuSBt.d.ts → index-BaA-xpSw.d.ts} +2 -2
- package/dist/{index-FVoPvhAu.d.cts → index-Bd91Nmf4.d.cts} +2 -2
- package/dist/{index-PqbnoScQ.d.ts → index-BgjS2b8N.d.ts} +2 -2
- package/dist/{index-DCbE8fFM.d.cts → index-BiHUBEKq.d.cts} +2 -2
- package/dist/{index-DlgHqQxW.d.cts → index-BilOa6AE.d.cts} +6 -32
- package/dist/{index-DoYc8BWK.d.cts → index-BmSQLAZo.d.cts} +2 -2
- package/dist/{index-DlrWu9Hs.d.cts → index-C-dkXOpB.d.cts} +1 -1
- package/dist/{index-C7VV_qOs.d.ts → index-C5cQ7Gfx.d.ts} +2 -2
- package/dist/{index-CPhBvRJU.d.ts → index-C6ZUaos7.d.ts} +1 -1
- package/dist/{index-PlJ3MraE.d.ts → index-CAP3UGsq.d.ts} +1 -1
- package/dist/{index-B41Asm7D.d.ts → index-CD2dBMet.d.ts} +2 -2
- package/dist/index-CGhMJNHb.d.cts +128 -0
- package/dist/{index-BAlaVimV.d.ts → index-CQtWm7jS.d.ts} +2 -2
- package/dist/{index-8R1vzNOx.d.cts → index-CRm0YIzC.d.cts} +2 -2
- package/dist/index-CUIkE1l9.d.cts +230 -0
- package/dist/{index-KlZ_ZUip.d.cts → index-Cczxgd2D.d.ts} +3 -3
- package/dist/{index-DIHcMLr6.d.cts → index-CgnCFhr2.d.cts} +1 -1
- package/dist/{index-BC9VybQs.d.ts → index-Ck35nA-T.d.ts} +2 -2
- package/dist/{index-BndG0cpK.d.cts → index-Cnr1WrlX.d.cts} +1 -1
- package/dist/{index-H_I66pav.d.cts → index-CtFNGe-m.d.cts} +2 -2
- package/dist/index-CuPUehFa.d.cts +218 -0
- package/dist/index-D1Gc7wV5.d.ts +230 -0
- package/dist/{index-iTX5IqSP.d.ts → index-D1IEZUsj.d.ts} +5 -5
- package/dist/{index-CWHtYmSh.d.cts → index-D4uimgee.d.cts} +1 -1
- package/dist/{index-CwP_KAMS.d.cts → index-DGTo1yka.d.cts} +64 -6
- package/dist/{index-BUPVld1w.d.ts → index-DH4fm2Ck.d.ts} +2 -2
- package/dist/{index-mNwgxC21.d.cts → index-DJ_MPOJ5.d.cts} +5 -5
- package/dist/{index-DyM4tFAe.d.cts → index-DQQCOIt8.d.cts} +2 -2
- package/dist/{index-BJ26eEjs.d.cts → index-DVAlsmEU.d.cts} +2 -2
- package/dist/{index-DINuaZlJ.d.cts → index-DVDapw2k.d.cts} +1 -1
- package/dist/{index-DTtBpuQy.d.cts → index-DgJc8Zgc.d.cts} +5 -3
- package/dist/{index-BKMdnYnk.d.ts → index-DhLyOHYZ.d.ts} +1 -1
- package/dist/{index-89FczVZ_.d.ts → index-DhnsQfa3.d.ts} +77 -51
- package/dist/{index-L8XI8Zql.d.cts → index-DktLSZOc.d.cts} +2 -2
- package/dist/{index-pVDQcbar.d.cts → index-DpiGqtrs.d.cts} +77 -51
- package/dist/{index-B9fmw5n2.d.ts → index-I1cCY3ZI.d.ts} +5 -3
- package/dist/{index-C19qqa38.d.ts → index-IUCY0OFN.d.ts} +2 -2
- package/dist/index-N2MAxt7_.d.ts +128 -0
- package/dist/{index-Br3WnqEn.d.ts → index-WSlcjhQF.d.ts} +6 -32
- package/dist/{index-DQUVq1_d.d.ts → index-bXXLSvor.d.ts} +2 -2
- package/dist/{index-BhUaMYm_.d.ts → index-da2V5vPy.d.ts} +1 -1
- package/dist/{index-PsVHpPwP.d.cts → index-t6L2qpHh.d.cts} +2 -2
- package/dist/{index-IwFqHxCs.d.cts → index-tV3AA9hI.d.cts} +1 -1
- package/dist/index.cjs +48 -48
- package/dist/index.d.cts +33 -33
- package/dist/index.d.ts +33 -33
- package/dist/index.js +1 -1
- package/dist/patterns/ai/browser.cjs +5 -5
- package/dist/patterns/ai/browser.d.cts +2 -2
- package/dist/patterns/ai/browser.d.ts +2 -2
- package/dist/patterns/ai/browser.js +1 -1
- package/dist/patterns/ai/index.cjs +14 -14
- package/dist/patterns/ai/index.d.cts +11 -11
- package/dist/patterns/ai/index.d.ts +11 -11
- package/dist/patterns/ai/index.js +1 -1
- package/dist/patterns/ai/node.js +1 -1
- package/dist/patterns/audit/index.d.cts +3 -3
- package/dist/patterns/audit/index.d.ts +3 -3
- package/dist/patterns/audit/index.js +1 -1
- package/dist/patterns/cqrs/index.d.cts +3 -3
- package/dist/patterns/cqrs/index.d.ts +3 -3
- package/dist/patterns/cqrs/index.js +1 -1
- package/dist/patterns/demo-shell/index.d.cts +3 -3
- package/dist/patterns/demo-shell/index.d.ts +3 -3
- package/dist/patterns/demo-shell/index.js +1 -1
- package/dist/patterns/domain-templates/index.d.cts +2 -2
- package/dist/patterns/domain-templates/index.d.ts +2 -2
- package/dist/patterns/domain-templates/index.js +1 -1
- package/dist/patterns/graphspec/index.d.cts +2 -2
- package/dist/patterns/graphspec/index.d.ts +2 -2
- package/dist/patterns/graphspec/index.js +1 -1
- package/dist/patterns/guarded-execution/index.cjs +3 -3
- package/dist/patterns/guarded-execution/index.d.cts +4 -4
- package/dist/patterns/guarded-execution/index.d.ts +4 -4
- package/dist/patterns/guarded-execution/index.js +1 -1
- package/dist/patterns/harness/index.cjs +1 -1
- package/dist/patterns/harness/index.d.cts +7 -7
- package/dist/patterns/harness/index.d.ts +7 -7
- package/dist/patterns/harness/index.js +1 -1
- package/dist/patterns/job-queue/index.d.cts +3 -3
- package/dist/patterns/job-queue/index.d.ts +3 -3
- package/dist/patterns/job-queue/index.js +1 -1
- package/dist/patterns/lens/index.cjs +3 -3
- package/dist/patterns/lens/index.d.cts +3 -4
- package/dist/patterns/lens/index.d.ts +3 -4
- package/dist/patterns/lens/index.js +1 -1
- package/dist/patterns/memory/index.cjs +1 -1
- package/dist/patterns/memory/index.d.cts +3 -3
- package/dist/patterns/memory/index.d.ts +3 -3
- package/dist/patterns/memory/index.js +1 -1
- package/dist/patterns/messaging/index.d.cts +2 -2
- package/dist/patterns/messaging/index.d.ts +2 -2
- package/dist/patterns/messaging/index.js +1 -1
- package/dist/patterns/orchestration/index.d.cts +3 -3
- package/dist/patterns/orchestration/index.d.ts +3 -3
- package/dist/patterns/orchestration/index.js +1 -1
- package/dist/patterns/process/index.d.cts +4 -4
- package/dist/patterns/process/index.d.ts +4 -4
- package/dist/patterns/process/index.js +1 -1
- package/dist/patterns/reactive-layout/index.d.cts +3 -3
- package/dist/patterns/reactive-layout/index.d.ts +3 -3
- package/dist/patterns/reactive-layout/index.js +1 -1
- package/dist/patterns/reduction/index.d.cts +2 -2
- package/dist/patterns/reduction/index.d.ts +2 -2
- package/dist/patterns/reduction/index.js +1 -1
- package/dist/patterns/refine-loop/index.d.cts +3 -3
- package/dist/patterns/refine-loop/index.d.ts +3 -3
- package/dist/patterns/refine-loop/index.js +1 -1
- package/dist/patterns/resilient-pipeline/index.cjs +3 -1
- package/dist/patterns/resilient-pipeline/index.d.cts +7 -3
- package/dist/patterns/resilient-pipeline/index.d.ts +7 -3
- package/dist/patterns/resilient-pipeline/index.js +1 -1
- package/dist/patterns/surface/index.d.cts +3 -3
- package/dist/patterns/surface/index.d.ts +3 -3
- package/dist/patterns/surface/index.js +1 -1
- package/dist/{pipeline-graph-D8vKcO_p.d.ts → pipeline-graph-CB4La-UW.d.ts} +2 -2
- package/dist/{pipeline-graph-BQPr2Lqs.d.cts → pipeline-graph-MWrQZXCq.d.cts} +2 -2
- package/dist/{reactive-layout-8CSc0tiA.d.cts → reactive-layout-BtZfUKuL.d.cts} +1 -1
- package/dist/{reactive-layout-DkTXxtSy.d.ts → reactive-layout-KJj4E2dT.d.ts} +1 -1
- package/dist/{reactive-map-B2qfD3hb.d.cts → reactive-map-6P_k3AQM.d.cts} +1 -1
- package/dist/{reactive-map-jFIsE6Kt.d.ts → reactive-map-CjXByDV-.d.ts} +1 -1
- package/dist/{resilience-HTF2LBRS.js → resilience-S33JV6XC.js} +1 -1
- package/dist/{topology-tree-B5Ngw3j0.d.cts → topology-tree-3LBKFsUo.d.cts} +1 -1
- package/dist/{topology-tree-BtvbgMXJ.d.ts → topology-tree-mF7Emqzm.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-73PBQNST.js +0 -1
- package/dist/chunk-A6ZSKGUG.js +0 -1
- package/dist/chunk-EWF7KCDJ.js +0 -61
- package/dist/chunk-IUB4NYI2.js +0 -1
- package/dist/chunk-MC4UYY2X.js +0 -1
- package/dist/chunk-ZJ7SM3G2.js +0 -1
- package/dist/index-BEHmxORq.d.ts +0 -135
- package/dist/index-BM9szD8n.d.cts +0 -113
- package/dist/index-BskfDoZ_.d.ts +0 -113
- package/dist/index-CIRG8Hxp.d.cts +0 -135
- package/dist/index-Cey6VTnX.d.ts +0 -166
- package/dist/index-CpLpJb6A.d.cts +0 -166
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-39jk0kaV.js';
|
|
2
|
-
import {
|
|
2
|
+
import { b as CircuitBreakerOptions, f as CircuitBreaker } from './index-BAQrjuZF.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-1Dhoi7HM.cjs';
|
|
2
|
-
import {
|
|
2
|
+
import { b as CircuitBreakerOptions, f as CircuitBreaker } from './index-DGTo1yka.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as we}from"./chunk-SGS4OJGS.js";import{a as Me}from"./chunk-ESMPEKEV.js";import{a as ve,d as ye}from"./chunk-35JTVPOX.js";import{C as ne}from"./chunk-
|
|
1
|
+
import{a as we}from"./chunk-SGS4OJGS.js";import{a as Me}from"./chunk-ESMPEKEV.js";import{a as ve,d as ye}from"./chunk-35JTVPOX.js";import{C as ne}from"./chunk-CKFQS2CJ.js";import{A as ge,C as M,E as Z,F as me,G as be,e as $e,f as xe,i as Q,k as Ae,l as te,m as Te,o as z,p as Pe,s as U}from"./chunk-LYCLF26R.js";import{b as q,c as le,d as pe,e as ee,f as fe,g as he,h as L,i as H,j as W}from"./chunk-CK2E7BTU.js";function Oe(o,e){if(Object.is(o,e))return!0;if(o==null||e==null||typeof o!="object"||typeof e!="object")return!1;if(Array.isArray(o)){if(!Array.isArray(e)||o.length!==e.length)return!1;for(let r=0;r<o.length;r++)if(!Oe(o[r],e[r]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(o),n=Object.keys(e);if(t.length!==n.length)return!1;let s=new Set(n);for(let r of t)if(!s.has(r)||!Oe(o[r],e[r]))return!1;return!0}function je(o,e){return`${o}\0${e}`}function _e(o,e){let t=[],n=new Set(o.subgraphs),s=new Set(e.subgraphs),r=[];for(let l of s)n.has(l)||r.push(l);r.sort();for(let l of r)t.push({type:"subgraph-mounted",path:l});let i=new Set(Object.keys(o.nodes)),c=new Set(Object.keys(e.nodes)),d=[];for(let l of c)i.has(l)||d.push(l);d.sort();for(let l of d)t.push({type:"node-added",path:l,node:{...e.nodes[l]}});let a=[];for(let l of c){if(!i.has(l))continue;let O=o.nodes[l]?.meta,m=e.nodes[l]?.meta;O==null&&m==null||Oe(O??{},m??{})||a.push(l)}a.sort();for(let l of a)t.push({type:"node-meta-changed",path:l,prevMeta:o.nodes[l]?.meta??{},nextMeta:e.nodes[l]?.meta??{}});let p=new Map;for(let l of o.edges)p.set(je(l.from,l.to),l);let g=new Map;for(let l of e.edges)g.set(je(l.from,l.to),l);let h=[];for(let[l,O]of g)p.has(l)||h.push(O);h.sort((l,O)=>l.from<O.from?-1:l.from>O.from?1:l.to<O.to?-1:l.to>O.to?1:0);for(let l of h)t.push({type:"edge-added",from:l.from,to:l.to});let f=[];for(let[l,O]of p)g.has(l)||f.push(O);f.sort((l,O)=>l.from<O.from?-1:l.from>O.from?1:l.to<O.to?-1:l.to>O.to?1:0);for(let l of f)t.push({type:"edge-removed",from:l.from,to:l.to});let u=[];for(let l of i)c.has(l)||u.push(l);u.sort();for(let l of u)t.push({type:"node-removed",path:l});let y=[];for(let l of n)s.has(l)||y.push(l);y.sort();for(let l of y)t.push({type:"subgraph-unmounted",path:l});return{events:t,flushedAt_ns:z()}}function Fe(o,e,t,n={}){let s=e in o.nodes,r=t in o.nodes;if(!s)return re(e,t,"no-such-from");if(!r)return re(e,t,"no-such-to");let i=n.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(n.findCycle===!0){let a=Xe(o,e,n);if(a!=null)return a}let d=se(e,o.nodes[e],0,n);return oe(e,t,[d])}if(i===0)return re(e,t,"no-path");let c=Ie(o,e,t,i);return c.found?oe(e,t,Be(o,c.pathOrder,n)):re(e,t,c.truncated?"max-depth-exceeded":"no-path")}function Ie(o,e,t,n){let s=new Map,r=[{path:t,depth:0}],i=new Set([t]),c=0,d=!1;for(;c<r.length;){let g=r[c++];if(g.path===e)break;if(n!=null&&g.depth>=n){let y=o.nodes[g.path];y?.deps&&y.deps.length>0&&(d=!0);continue}let h=o.nodes[g.path];if(h==null)continue;let f=h.deps??[],u=new Map;for(let y=0;y<f.length;y++){let l=f[y];if(!l)continue;let O=u.get(l);O==null&&(O=[],u.set(l,O)),O.push(y)}for(let[y,l]of u)i.has(y)||(i.add(y),s.set(y,{from:g.path,depIndices:l}),r.push({path:y,depth:g.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:d};let a=[{path:e}],p=e;for(;p!==t;){let g=s.get(p);if(g==null)return{found:!1,pathOrder:[],truncated:!1};a[a.length-1].depIndices=g.depIndices,a.push({path:g.from}),p=g.from}return{found:!0,pathOrder:a,truncated:!1}}function Xe(o,e,t){let n=o.nodes[e];if(n==null)return null;let s=n.deps??[],r=[];for(let c=0;c<s.length;c++)s[c]===e&&r.push(c);if(r.length>0){let c=se(e,n,0,t);c.dep_index=r[0];let d=se(e,n,1,t);return oe(e,e,[c,d])}let i=null;for(let c=0;c<s.length;c++){let d=s[c];if(!d||d===e)continue;let a=Ie(o,d,e,t.maxDepth);a.found&&(i==null||a.pathOrder.length<i.pathOrder.length)&&(i=a,i={found:!0,pathOrder:[{path:e,depIndices:[c]},...a.pathOrder],truncated:!1})}return i==null?null:oe(e,e,Be(o,i.pathOrder,t))}function Be(o,e,t){return e.map((n,s)=>{let r=o.nodes[n.path],i=se(n.path,r,s,t);return n.depIndices!=null&&n.depIndices.length>0&&(i.dep_index=n.depIndices[0],n.depIndices.length>1&&(i.dep_indices=[...n.depIndices])),i})}function se(o,e,t,n){let s={path:o,type:e.type,hop:t};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let r=n.annotations?.get(o)??e.annotation;r!=null&&(s.annotation=r);let i=n.lastMutations?.get(o)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function oe(o,e,t){return Le(o,e,!0,"ok",t)}function re(o,e,t){return Le(o,e,!1,t,[])}function Le(o,e,t,n,s){let r=et(o,e,t,n,s);return{from:o,to:e,found:t,reason:n,steps:s,text:r,toJSON(){return{from:o,to:e,found:t,reason:n,steps:s}}}}function et(o,e,t,n,s){if(!t)switch(n){case"no-such-from":return`explainPath: no node named "${o}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${o}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${o}" to "${e}"`}let r=[`Causal path: ${o} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(r.push(d),"value"in i&&r.push(` value: ${tt(i.value)}`),i.annotation!=null&&r.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let a=i.lastMutation.actor;r.push(` actor: ${a.type}${a.id?`:${a.id}`:""}`)}}return r.join(`
|
|
2
2
|
`)}function tt(o){if(o===void 0)return"<sentinel>";if(o===null)return"null";if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean"||typeof o=="bigint")return String(o);try{let e=JSON.stringify(o);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(o)}}var A={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},nt=Symbol.for("sizeof");function ze(o){let e=new WeakSet,t=new WeakSet,n=[o],s=0;for(;n.length>0;){let r=n.pop();s+=rt(r,e,t,n)}return s}function rt(o,e,t,n){if(o==null)return 0;switch(typeof o){case"number":return A.number;case"boolean":return A.boolean;case"string":return A.string+o.length*2;case"bigint":return A.bigint+st(o);case"symbol":return A.symbol;case"function":return e.has(o)?0:(e.add(o),A.function);case"undefined":return 0}let r=o;if(e.has(r))return 0;e.add(r);let i=r[nt];if(typeof i=="function")try{let a=i.call(r);if(typeof a=="number"&&Number.isFinite(a))return a}catch{}if(r instanceof Date)return A.date;if(r instanceof RegExp)return A.regexp+r.source.length*2;if(r instanceof Error){let a=r.message?r.message.length*2:0,p=r.stack?r.stack.length*2:0;return A.error+a+p}if(typeof URL<"u"&&r instanceof URL)return A.url+r.href.length*2;if(typeof Promise<"u"&&r instanceof Promise)return A.promise;if(r instanceof WeakMap)return A.weakmap;if(r instanceof WeakSet)return A.weakset;if(r instanceof Map){let a=A.map;for(let[p,g]of r)a+=A.mapEntry,n.push(p),n.push(g);return a}if(r instanceof Set){let a=A.set;for(let p of r)a+=A.setEntry,n.push(p);return a}if(Array.isArray(r)){let a=A.array+r.length*8;for(let p of r)n.push(p);return a}if(r instanceof ArrayBuffer)return t.has(r)?0:(t.add(r),r.byteLength);if(ArrayBuffer.isView(r)){let a=r;return t.has(a.buffer)?48:(t.add(a.buffer),a.buffer.byteLength+48)}let c=A.object,d=Object.keys(r);for(let a of d){c+=A.string+a.length*2;try{n.push(r[a])}catch{}}return c}function st(o){let e=o<0n?-o:o;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}function Ve(o,e){let t=e?.topN??10,n=o.describe({detail:"standard"}),s=[],r=o._collectObserveTargets;typeof r=="function"&&r.call(o,"",s);let i=new Map;for(let[h,f]of s)i.set(h,f);let c=[];for(let[h,f]of Object.entries(n.nodes)){let u=i.get(h),y=u instanceof M?u:null,l=y?ze(y.cache):0,O=y?y._sinkCount:0,m=f.deps?.length??0,b=f.type==="effect"&&O===0,v=O===0?f.type==="effect"?"orphan-effect":f.type==="derived"?"idle-derived":f.type==="producer"?"idle-producer":null:null;c.push({path:h,type:f.type,status:f.status??"unknown",valueSizeBytes:l,subscriberCount:O,depCount:m,isOrphanEffect:b,orphanKind:v})}let d=c.reduce((h,f)=>h+f.valueSizeBytes,0),a=(h,f)=>[...c].sort(f??((u,y)=>y[h]-u[h])).slice(0,t),p=c.filter(h=>h.orphanKind!=null),g=c.filter(h=>h.isOrphanEffect);return{nodeCount:c.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:c,totalValueSizeBytes:d,hotspots:{byValueSize:a("valueSizeBytes"),bySubscriberCount:a("subscriberCount"),byDepCount:a("depCount")},orphans:p,orphanEffects:g}}var $="::",B="__meta__",J=1;function qe(o,e){let t=Math.max(16,o.size*4),n=0;for(;o.size>0;){if(n++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${o.size} disposer(s) discarded`),o.clear();return}let s=o.values().next();if(s.done)return;let r=s.value;o.delete(r);try{r()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Ye(o){return o!=null&&typeof o=="object"&&"cache"in o&&typeof o.subscribe=="function"&&typeof o.down=="function"}function ot(o){if(o!=null)return Ye(o)?o.cache:o}function K(o){return o!=null&&typeof o=="object"&&"cache"in o&&typeof o.subscribe=="function"&&typeof o.down=="function"}function V(o){return K(o)?o.cache??"":o}function Ke(o){return K(o)?o.cache??0:o}function He(o){return K(o)?o.cache??!1:o}function it(o){let e=[];for(let t of Object.keys(o).sort()){let n=o[t].v;n!=null&&e.push(`${t} ${n.id} ${n.version}`)}return e.join(`
|
|
3
3
|
`)}function We(o){if(o.version!==J)throw new Error(`unsupported snapshot version ${String(o.version)} (expected ${J})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in o))throw new Error(`snapshot missing required key "${e}"`);if(typeof o.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof o.nodes!="object"||o.nodes===null||Array.isArray(o.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(o.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(o.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function at(o,e){let t=new WeakMap,n=(s,r)=>{if(Object.is(s,r))return!0;if(s==null||r==null||typeof s!="object"||typeof r!="object")return!1;let i=t.get(s);if(i==null&&(i=new WeakSet,t.set(s,i)),i.has(r))return!0;i.add(r);let c=s.constructor,d=r.constructor;if(c!==d)return!1;if(s instanceof Date)return s.getTime()===r.getTime();if(s instanceof RegExp)return s.source===r.source&&s.flags===r.flags;if(Array.isArray(s)){let h=r;if(s.length!==h.length)return!1;for(let f=0;f<s.length;f++)if(!n(s[f],h[f]))return!1;return!0}if(s instanceof Map){let h=r;if(s.size!==h.size)return!1;for(let[f,u]of s)if(!h.has(f)||!n(u,h.get(f)))return!1;return!0}if(s instanceof Set){let h=r;if(s.size!==h.size)return!1;for(let f of s){let u=!1;for(let y of h)if(n(f,y)){u=!0;break}if(!u)return!1}return!0}if(ArrayBuffer.isView(s)){let h=s,f=r;if(h.length!==f.length)return!1;for(let u=0;u<h.length;u++)if(h[u]!==f[u])return!1;return!0}let a=Object.keys(s),p=Object.keys(r);if(a.length!==p.length)return!1;let g=new Set(p);for(let h of a)if(!g.has(h)||!n(s[h],r[h]))return!1;return!0};return n(o,e)}function ut(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ie(o){let e="^";for(let t=0;t<o.length;t+=1){let n=o[t];if(n==="*"){e+=".*";continue}if(n==="?"){e+=".";continue}if(n==="["){let s=o.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let r=o.slice(t+1,s);r.startsWith("!")&&(r=`^${r.slice(1)}`),r=r.replace(/\\/g,"\\\\"),e+=`[${r}]`,t=s;continue}e+=ut(n)}return e+="$",new RegExp(e)}var ct={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"},dt={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function Ee(o){if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean"||o==null)return String(o);try{return JSON.stringify(o)}catch{return"[unserializable]"}}function lt(o){return o==="none"?dt:o==="ansi"||o==null?ct:{data:o.data??"",dirty:o.dirty??"",resolved:o.resolved??"",invalidate:o.invalidate??"",pause:o.pause??"",resume:o.resume??"",complete:o.complete??"",error:o.error??"",teardown:o.teardown??"",derived:o.derived??"",path:o.path??"",reset:o.reset??""}}function Ue(o){if(o==null)return{};let e=o.detail;return e==="full"?{...o,structured:o.structured??!0,timeline:o.timeline??!0,causal:o.causal??!0,derived:o.derived??!0}:e==="minimal"?{...o,structured:o.structured??!0}:o.format==="stage-log"?{...o,structured:o.structured??!0,timeline:o.timeline??!0}:o}function pt(o,e,t){for(let n=0;n<o.length;n++){let s=o.charCodeAt(n);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${o}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function ke(o,e,t){if(o==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(o.includes($))throw new Error(`Graph "${e}": ${t} "${o}" must not contain '${$}' (path separator)`);if(o===B)throw new Error(`Graph "${e}": ${t} name "${B}" is reserved for meta companion paths`);pt(o,e,t)}function ft(o,e){if(o==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=o.split($);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function ht(o,e){let t=!1;for(let s of o)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?o.filter(s=>e.isMetaPassthrough(s[0])):o}function Qe(o){for(let e of o._mounts.values())Qe(e);for(let e of o._nodes.values())try{e.down([[L]],{internal:!0})}catch{}}var Se=class o{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes($))throw new Error(`Graph name must not contain '${$}' (got "${e}")`);if(e===B)throw new Error(`Graph name "${B}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??ge,this._traceRing=new we(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning),typeof t?.factory=="string"&&(this._factory=t.factory,t.factoryArgs!==void 0&&(this._factoryArgs=t.factoryArgs))}tagFactory(e,t){return this._factory=e,this._factoryArgs=t,this}ancestors(e=!0){let t=[],n=e?this:this._parent;for(;n!=null;)t.push(n),n=n._parent;return t}get topology(){return this._topology==null&&(this._topology=me(e=>{let t=n=>{e.emit(n)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let n=e.name,s=t?.name??n;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let r=s,i=t?.annotation;if(ke(r,this.name,"add"),this._mounts.has(r))throw new Error(`Graph "${this.name}": name "${r}" is already a mount point`);if(this._nodes.has(r))throw new Error(`Graph "${this.name}": node "${r}" already exists`);let c=this._nodeToName.get(e);if(c!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${c}"`);return this._nodes.set(r,e),this._nodeToName.set(e,r),this._emitTopology({kind:"added",name:r,nodeKind:"node"}),i!=null&&(this._annotations.set(r,i),this.config.inspectorEnabled&&this._traceRing.push({path:r,annotation:i,timestamp_ns:z()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof M&&t._applyVersioning(e)}remove(e){ke(e,this.name,"remove");let t=this._mounts.get(e);if(t){let r={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[c,d]of i)c.includes(`${$}${B}${$}`)||r.nodes.push(c);return r.nodes.sort(),r.mounts.push(e),r.mounts.push(...t._collectSubgraphs(`${e}${$}`)),this._mounts.delete(e),t._parent=void 0,Qe(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:r}),r}let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(n),n.down([[L]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let t=typeof e=="function"?e:(()=>{let r=ie(e);return i=>r.test(i)})(),n={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(r=>t(r));for(let r of s){let i=this.remove(r);n.nodes.push(...i.nodes),n.mounts.push(...i.mounts)}return n.nodes.sort(),n.mounts.sort(),n}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,n=0;return{[Symbol.iterator](){return this},next(){if(n>=e.length)return{value:void 0,done:!0};let s=e[n++];return{value:[s,t.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes($))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,n){let s=n?.internal===!0;this.node(e).down([[q,t]],{actor:n?.actor,internal:s,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);Te(()=>{for(let[s,r]of n)this.set(s,r,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[ee]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let s=n?.internal===!0;this.node(e).down([[W,t]],{actor:n?.actor,internal:s,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[H]],{actor:t?.actor,internal:n,delivery:"write"})}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[d,a]of this._nodes)n.set(a,d);let c=[];for(let[d,a]of this._nodes)if(a instanceof M)for(let p of a._deps){let g=n.get(p.node);g!=null&&c.push([g,d])}return c.sort((d,a)=>d[0]<a[0]?-1:d[0]>a[0]?1:d[1]<a[1]?-1:d[1]>a[1]?1:0),c}let s=[];this._collectObserveTargets("",s);let r=new Map;for(let[c,d]of s)r.set(d,c);let i=[];for(let[c,d]of s)if(d instanceof M)for(let a of d._deps){let p=r.get(a.node);p!=null&&i.push([p,c])}return i.sort((c,d)=>c[0]<d[0]?-1:c[0]>d[0]?1:c[1]<d[1]?-1:c[1]>d[1]?1:0),i}mount(e,t){if(t===void 0){let s=new o(e);return this.mount(e,s)}if(typeof t=="function"){let s=new o(e);return t(s),this.mount(e,s)}let n=t;if(ke(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let t=ft(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let n=t[0],s=t.slice(1);if(s.length===0){let c=this._nodes.get(n);if(c)return c;throw this._mounts.has(n)?new Error(`Graph "${this.name}": path ends at subgraph "${n}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${n}"`)}let r=this._nodes.get(n);if(r&&s.length>0&&s[0]===B)return this._resolveMetaChainFromNode(r,s,t.join($));let i=this._mounts.get(n);if(!i)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${s.join($)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(s.join($))}_resolveMetaChainFromNode(e,t,n){let s=e,r=0,i=[...t];for(;r<i.length;){if(i[r]!==B)throw new Error(`Graph "${this.name}": expected ${B} segment in meta path "${n}"`);if(r+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${B} in "${n}"`);let c=i[r+1],d=s.meta[c];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${c}" in path "${n}"`);s=d,r+=2}return s}signal(e,t){if(t?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let n=[];if(this._signalDeliver(e,t??{},new Set,n),n.length>0)throw n[0]}_signalDeliver(e,t,n,s){for(let d of this._mounts.values())d._signalDeliver(e,t,n,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},c=ht(e,this.config);for(let d of[...this._nodes.keys()].sort()){let a=this._nodes.get(d);if(!n.has(a)){n.add(a);try{a.down(e,i)}catch(p){if(p instanceof U)throw p;s.push(p)}c.length!==0&&this._signalMetaSubtree(a,c,n,i,s)}}}_signalMetaSubtree(e,t,n,s,r){for(let i of Object.keys(e.meta).sort()){let c=e.meta[i];if(!n.has(c)){n.add(c);try{c.down(t,s)}catch(d){if(d instanceof U)throw d;r.push(d)}this._signalMetaSubtree(c,t,n,s,r)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=ot(e?.actor),n=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let s=ve(e?.detail,e?.fields),r=e?.detail==="spec",i=s,c=[];this._collectObserveTargets("",c);let d=new Map;for(let[v,w]of c)d.set(w,v);let a=[];{let v=c.map(([,S])=>S),w=new Set(d.values()),E=0;for(;v.length>0;){let S=v.shift();if(S instanceof M)for(let R of S._deps){let G=R.node;if(d.has(G))continue;let D=G.name??"",k=D;if(!k||w.has(k))if(D){let I=2;for(;w.has(`${D}#${I}`);)I++;k=`${D}#${I}`}else for(k=`__internal__/${E++}`;w.has(k);)k=`__internal__/${E++}`;d.set(G,k),w.add(k),a.push([k,G]),v.push(G)}}}let p=[...c,...a],g={};for(let[v,w]of p){if(t!=null&&!w.allowsObserve(t))continue;let E=ye(w,i,r),S=w instanceof M?w._deps.map(k=>d.get(k.node)??k.node.name??""):[],{name:R,...G}=E,D={...G,deps:S};if(!r){let k=this._annotations.get(v);k!=null&&(D.annotation=k)}if(n!=null)if(typeof n=="function"){let k=n;if(!(k.length>=2?k(v,D):k(D)))continue}else{let k=!0;for(let[I,T]of Object.entries(n)){let x=I==="deps_includes"?"depsIncludes":I==="meta_has"?"metaHas":I;if(x==="depsIncludes"){if(!D.deps.includes(String(T))){k=!1;break}continue}if(x==="metaHas"){if(!Object.hasOwn(D.meta??{},String(T))){k=!1;break}continue}if(D[x]!==T){k=!1;break}}if(!k)continue}g[v]=D}let h=new Set(Object.keys(g)),f=[];for(let[v,w]of p)if(w instanceof M)for(let E of w._deps){let S=d.get(E.node);S!=null&&f.push([S,v])}f.sort((v,w)=>v[0]<w[0]?-1:v[0]>w[0]?1:v[1]<w[1]?-1:v[1]>w[1]?1:0);let u=f.map(([v,w])=>({from:v,to:w}));(t!=null||n!=null)&&(u=u.filter(v=>h.has(v.from)&&h.has(v.to)));let y=this._collectSubgraphs(""),l=t!=null||n!=null?y.filter(v=>{let w=`${v}${$}`;return[...h].some(E=>E===v||E.startsWith(w))}):y,O=this,m=e;return{name:this.name,nodes:g,edges:u,subgraphs:l,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(v){let w={...m};return Array.isArray(v)?(w.fields=v,w.detail=void 0):(w.detail=v,w.fields=void 0),O.describe(w)}}}_collectSubgraphs(e){let t=[];for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${n}`;t.push(s),t.push(...this._mounts.get(n)._collectSubgraphs(`${s}${$}`))}return t}resourceProfile(e){return Ve(this,e)}reachable(e,t,n={}){return n.withDetail===!0?Je(this.describe(),e,t,{...n,withDetail:!0}):Je(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(V(e),V(t),{...n?.maxDepth!==void 0?{maxDepth:Ke(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:He(n.findCycle)}:{}})}_explainStatic(e,t,n){let s=this.describe({detail:"full"}),r=new Map(this._annotations),i=new Map;for(let[c,d]of Object.entries(s.nodes))d.lastMutation!=null&&i.set(c,d.lastMutation);return Fe(s,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:r,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",s=0,r=Z(s,{name:`${n}_version`}),i=this.observe({timeline:!0,structured:!0}),c=!1,d=!1,a=()=>{c||d||(c=!0,te(()=>{c=!1,!d&&(s+=1,r.emit(s))}))},p=i.onEvent(m=>{let b=m.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||a()}),g=[],h=new WeakSet,f=m=>{if(h.has(m)||d)return;h.add(m);let b=m.topology.subscribe(v=>{for(let w of v){if(w[0]!==q)continue;let E=w[1];if(a(),E.kind==="added"&&E.nodeKind==="mount"){let S=m._mounts.get(E.name);S!=null&&f(S)}}});g.push(b);for(let v of m._mounts.keys()){let w=m._mounts.get(v);w!=null&&f(w)}};f(this);let u,y=e.actor;Ye(y)&&(u=y.subscribe(m=>{let b=!1,v=!1;for(let w of m){let E=w[0];E===q?b=!0:(E===H||E===W||E===L)&&(v=!0)}b&&a(),v&&(u?.(),u=void 0,a())}));let l;try{l=be([r],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,b)=>m===b})}catch(m){p(),u?.();for(let b of g)b();throw i.dispose(),m}let O=ne(l);return{node:l,dispose(){d=!0,p(),u?.();for(let m of g)m();g.length=0,i.dispose(),O()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},n=e.reactiveName??"describe-diff",s={name:this.name,nodes:{},edges:[],subgraphs:[]},r=this.describe(t),i=_e(s,r),c=Z(i,{name:n,meta:{domain:"audit",kind:"describe-diff"},equals:(h,f)=>h===f}),d=this._describeReactive({...e,reactiveName:void 0}),a=!1,p=d.node.subscribe(h=>{if(!a)for(let f of h){if(f[0]!==q)continue;let u=f[1],y=_e(r,u);r=u,y.events.length!==0&&c.emit(y)}}),g=ne(c);return{node:c,dispose(){a=!0,p(),d.dispose(),c.down([[L,"describe-diff disposed"]]),g()}}}_explainReactive(e,t,n){let s=0,r=Z(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),c=!1,d=!1,a=()=>{c||d||(c=!0,te(()=>{c=!1,!d&&(s+=1,r.emit(s))}))},p=i.onEvent(m=>{let b=m.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||a()}),g=[];e!=null&&K(e)&&g.push(e),t!=null&&K(t)&&g.push(t),n?.maxDepth!=null&&K(n.maxDepth)&&g.push(n.maxDepth),n?.findCycle!=null&&K(n.findCycle)&&g.push(n.findCycle);let h=()=>{for(let m of g)if(m.cache===void 0)return!1;return!0},f=()=>{let m=V(e),b=V(t);return{from:m,to:b,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:m,to:b,found:!1,reason:"pending",steps:[]})}},u;try{u=be([r],()=>{if(!h())return f();let m=V(e),b=V(t),v={...n?.maxDepth!==void 0?{maxDepth:Ke(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:He(n.findCycle)}:{}};return this._explainStatic(m,b,v)},{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:V(e),to:V(t)},equals:(m,b)=>m.found===b.found&&m.reason===b.reason&&m.steps.length===b.steps.length&&mt(m.steps,b.steps)})}catch(m){throw p(),i.dispose(),m}let y=ne(u),l=[],O=m=>{let b;return b=m.subscribe(v=>{let w=!1,E=!1;for(let S of v){let R=S[0];R===q?w=!0:(R===H||R===W||R===L)&&(E=!0)}(w||E)&&a(),E&&b&&(b(),b=void 0)}),()=>{b&&(b(),b=void 0)}};for(let m of g)l.push(O(m));return{node:u,dispose(){d=!0,p();for(let m of l)m?.();l.length=0,i.dispose(),y()}}}_pathsMatching(e){let t=ie(e),n=[];return this._collectObserveTargets("",n),n.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${$}${n}`;this._mounts.get(n)._collectObserveTargets(s,t)}for(let n of[...this._nodes.keys()].sort()){let s=this._nodes.get(n),r=e===""?n:`${e}${$}${n}`;t.push([r,s]),this._appendMetaObserveTargets(r,s,t)}}_appendMetaObserveTargets(e,t,n){for(let s of Object.keys(t.meta).sort()){let r=t.meta[s],i=`${e}${$}${B}${$}${s}`;n.push([i,r]),this._appendMetaObserveTargets(i,r,n)}}observe(e,t){let n=typeof e=="string",r=Ue(n?t:e);if(r.reactive===!0)return this._observeReactive(n?e:void 0,r);let i=r.structured===!0||r.timeline===!0||r.causal===!0||r.derived===!0||r.detail==="minimal"||r.detail==="full"||r.format!=null,c=r.actor;if(n){let p=e,g=this.resolve(p);if(c!=null&&!g.allowsObserve(c))throw new U({actor:c,action:"observe",nodeName:p});return i?this._buildStructuredObserver([[p,g]],r,"one"):{subscribe(h){return g.subscribe(h)},up(h){try{g.up?.(h)}catch(f){if(f instanceof U)return;throw f}}}}let d=[];this._collectObserveTargets("",d),d.sort((p,g)=>p[0]<g[0]?-1:p[0]>g[0]?1:0);let a=c==null?d:d.filter(([,p])=>p.allowsObserve(c));return i?this._buildStructuredObserver(a,r,"all"):{subscribe:p=>{let g=a.map(([h,f])=>f.subscribe(u=>{p(h,u)}));return()=>{for(let h of g)h()}},up:(p,g)=>{try{this.resolve(p).up?.(g)}catch(h){if(h instanceof U)return;throw h}}}}_observeReactive(e,t){let n=t.tiers,s=n!=null?new Set(n):null,r=t.reactiveName??"observe";return me(i=>{let c=[],d=!1,a=!1,p=()=>{if(c.length===0||a)return;let y={events:c.slice(),flushedAt_ns:z()};c.length=0,i.emit(y)},g={...t,reactive:!1,structured:!0,timeline:!0},h=e!=null?this.observe(e,g):this.observe(g),f=y=>{a||(c.push(y),!d&&(d=!0,te(()=>{d=!1,p()})))};for(let y of h.events)f(y);let u=h.onEvent(f);return()=>{a=!0,u(),h.dispose()}},{name:r,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,n){let s=n==="one"?e[0]?.[0]:void 0,r=i=>{if(n==="one"&&s!=null){let p=this.resolve(s);return this._buildStructuredObserver([[s,p]],i,"one")}let c=[];this._collectObserveTargets("",c),c.sort((p,g)=>p[0]<g[0]?-1:p[0]>g[0]?1:0);let d=i.actor,a=d==null?c:c.filter(([,p])=>p.allowsObserve(d));return this._buildStructuredObserver(a,i,"all")};return this._createObserveResult(e,t,r)}_createObserveResult(e,t,n){let s=t.timeline===!0,r=t.causal===!0,i=t.derived===!0,c=t.detail==="minimal",d=this.config.inspectorEnabled,a=(r||i)&&d,p=t.maxEvents,g=p!=null&&p>0?new we(p):null,h=[],f=new Set,u=t.tiers!=null?new Set(t.tiers):null,y={},l=new Set,O=0,m=0,b=0,v=0,w=0,E=0,S=!1,R=!1,G=0,D=new Map,k=new Map,I=new Map,T=_=>{if(!(u!=null&&!u.has(_.type))){g?g.push(_):h.push(_);for(let C of f)C(_)}},x=_=>u==null||u.has(_),Re=()=>s?{timestamp_ns:z(),in_batch:Ae(),batch_id:G}:{},Ze=(_,C)=>{if(!(!a||!(_ instanceof M)))return _._setInspectorHook(j=>{if(j.kind==="dep_message")D.set(_,j.depIndex);else if(j.kind==="run"){let Y=j.batchData.map((N,P)=>N!=null&&N.length>0?N.at(-1):j.prevData[P]);k.set(_,Y);let F=j.batchData.map(N=>N!=null?[...N]:void 0);I.set(_,F),i&&T({type:"derived",path:C,dep_values:Y,dep_batches:F,...Re()})}})},Ne=_=>{let C=D.get(_),j=k.get(_);if(!r||j==null)return{};let F=(C!=null&&C>=0&&_ instanceof M?_._deps[C]:void 0)?.node,N=F?.v,P=I.get(_);return{trigger_dep_index:C,trigger_dep_name:F?.name,...N!=null?{trigger_version:{id:N.id,version:N.version}}:{},dep_values:[...j],...P!=null?{dep_batches:P}:{}}},Ge=[],De=[];for(let[_,C]of e){let j=Ze(C,_);j&&Ge.push(j),De.push(C.subscribe(Y=>{G++;for(let F of Y){let N=F[0],P=Re();if(N===q){y[_]=F[1];let de=C instanceof M?C.lastMutation?.actor??Q:Q;T({type:"data",path:_,data:F[1],actor:de,...P,...Ne(C)})}else if(c)N===le?x("dirty")&&O++:N===pe?x("resolved")&&m++:N===ee?x("invalidate")&&b++:N===fe?x("pause")&&v++:N===he?x("resume")&&w++:N===L?x("teardown")&&E++:N===H&&!l.has(_)?x("complete")&&(S=!0):N===W&&x("error")&&(R=!0,l.add(_));else if(N===le)x("dirty")&&O++,T({type:"dirty",path:_,...P});else if(N===pe)x("resolved")&&m++,T({type:"resolved",path:_,...P,...Ne(C)});else if(N===ee)x("invalidate")&&b++,T({type:"invalidate",path:_,...P});else if(N===fe)x("pause")&&v++,T({type:"pause",path:_,lockId:F[1],...P});else if(N===he)x("resume")&&w++,T({type:"resume",path:_,lockId:F[1],...P});else if(N===H)x("complete")&&!l.has(_)&&(S=!0),T({type:"complete",path:_,...P});else if(N===W){x("error")&&(R=!0,l.add(_));let de=C instanceof M?C.lastMutation?.actor??Q:Q;T({type:"error",path:_,data:F[1],actor:de,...P})}else N===L&&(x("teardown")&&E++,T({type:"teardown",path:_,...P}))}}))}let ae=!1,ue=()=>{if(!ae){ae=!0;for(let _ of De)_();for(let _ of Ge)_();for(let _ of X)_({value:void 0,done:!0});X.length=0}},ce=[],X=[];f.add(_=>{let C=X.shift();C?C({value:_,done:!1}):ce.push(_)});let Ce={get values(){return y},get dirtyCount(){return O},get resolvedCount(){return m},get invalidateCount(){return b},get pauseCount(){return v},get resumeCount(){return w},get teardownCount(){return E},get events(){return g?g.toArray():[...h]},get anyCompletedCleanly(){return S},get anyErrored(){return R},get completedWithoutErrors(){return S&&!R},onEvent(_){return f.add(_),()=>f.delete(_)},dispose:ue,expand(_){ue();let C={...t};return typeof _=="string"?C.detail=_:Object.assign(C,_),n(Ue(C))},[Symbol.asyncIterator](){return{next(){return ce.length>0?Promise.resolve({value:ce.shift(),done:!1}):ae?Promise.resolve({value:void 0,done:!0}):new Promise(_=>X.push(_))},return(){return ue(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Ce,t),Ce}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let s=t.logger??(u=>console.log(u)),r=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,c=r==null&&i==null?()=>!0:u=>(r==null||r.has(u))&&(i==null||!i.has(u)),d=lt(t.theme),a=n==="stage-log"?z():0,p=u=>u==null?"":t.stageLabels?.[u]??u,g=(u,y)=>u.length>y?`${u.slice(0,y-1)}\u2026`:u,h=u=>u.type==="data"||u.type==="error"?g(Ee(u.data),120):"",f=u=>{if(n==="stage-log"){let S=(z()-a)/1e9,R=p(u.path).padEnd(9);if(u.type==="data"){let G=h(u);return`[${S.toFixed(3)}s] ${R} \u2190${G?` ${G}`:""}`}if(u.type==="error"){let G=h(u);return`[${S.toFixed(3)}s] ${R} \u2717${G?` ${G}`:""}`}return u.type==="complete"?`[${S.toFixed(3)}s] ${R} \u25A0 complete`:`[${S.toFixed(3)}s] ${R} ${u.type}`}if(n==="json")try{return JSON.stringify(u)}catch{return JSON.stringify({type:u.type,path:u.path,data:"[unserializable]"})}let y=d[u.type]??"",l=u.path?`${d.path}${u.path}${d.reset} `:"",O=u.type==="data"||u.type==="error",m=u.type==="pause"||u.type==="resume",b=O?` ${Ee(u.data)}`:m?` ${Ee(u.lockId)}`:"",v=u.type==="data"||u.type==="resolved"||u.type==="derived"?u:void 0,w=v?.trigger_dep_name!=null?` <- ${v.trigger_dep_name}`:v?.trigger_dep_index!=null?` <- #${v.trigger_dep_index}`:"",E=u.in_batch?" [batch]":"";return`${l}${y}${u.type.toUpperCase()}${d.reset}${b}${w}${E}`};e.onEvent(u=>{c(u.type)&&s(f(u),u)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){qe(this._disposers,this.name),this.signal([[L]],{internal:!0}),qe(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:t,...n}=this.describe({detail:"full"}),s={};for(let c of Object.keys(n.nodes).sort()){let{lastMutation:d,guard:a,...p}=n.nodes[c];s[c]=p}let r=[...n.subgraphs].sort(),i={...n,version:1,nodes:s,subgraphs:r};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 c=this.config.lookupCodec(e.codec);if(c==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return $e(c,c.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??ge,{codec:s,codecVersion:r,payload:i}=xe(e,n);return s.decode(i,r)}restore(e,t){if(We(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let n=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(r=>ie(r)),s=t?.includeProducers===!0;for(let r of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(c=>c.test(r)))continue;let i=e.nodes[r];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(r,new Error(`restore: slice.value is undefined for "${r}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let d=this.tryResolve(r)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(r,i.value)}catch(c){t?.onError?.(r,c)}}}}}static fromSnapshot(e,t){We(e);let n=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,r=new o(e.name);if(n)return n(r),r.restore(e),r;for(let f of[...e.subgraphs].sort((u,y)=>{let l=u.split($).length,O=y.split($).length;return l!==O?l-O:u<y?-1:u>y?1:0})){let u=f.split($),y=r;for(let l of u)y._mounts.has(l)||y.mount(l,new o(l)),y=y._mounts.get(l)}let i=s?Object.entries(s).map(([f,u])=>({re:ie(f),factory:u})):[],c=f=>{for(let u of i)if(u.re.test(f))return u.factory},d=f=>{let u=f.split($),y=u.pop();if(y==null||y.length===0)throw new Error(`invalid snapshot path "${f}"`);let l=r;for(let O of u){let m=l._mounts.get(O);if(!m)throw new Error(`unknown mount "${O}" in path "${f}"`);l=m}return[l,y]},a=Object.entries(e.nodes).filter(([f])=>!f.includes(`${$}${B}${$}`)).sort((f,u)=>f[0]<u[0]?-1:f[0]>u[0]?1:0),p=new Map(a),g=new Map,h=!0;for(;p.size>0&&h;){h=!1;for(let[f,u]of[...p.entries()]){let y=u?.deps??[];if(!y.every(w=>g.has(w)))continue;let[l,O]=d(f),m={...u?.meta??{}},b=c(f),v;if(u?.type==="state")v=Z(u.value,{meta:m});else{if(b==null)continue;v=b(O,{path:f,type:u.type,value:u.value,meta:m,deps:y,resolvedDeps:y.map(w=>g.get(w))})}l.add(v,{name:O}),g.set(f,v),p.delete(f),h=!0}}if(p.size>0){let f=[...p.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 r.restore(e),r}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let n=e.map(a=>({tier:a,debounceMs:Math.max(0,a.debounceMs??0),compactEvery:Math.max(1,a.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let s=(a,p)=>{if(a.disposed)return;let g=it(p.nodes);if(a.lastSnapshot!=null&&g!==""&&g===a.lastFingerprint)return;let h=a.seq+1,f=Pe(),l=a.lastSnapshot==null||h%a.compactEvery===0?{name:this.name,mode:"full",snapshot:p,seq:h,timestamp_ns:f,format_version:J}:{name:this.name,mode:"diff",diff:gt(a.lastSnapshot,p),seq:h,timestamp_ns:f,format_version:J};if(a.tier.filter&&!a.tier.filter(l))return;let O;try{O=a.tier.save(l)}catch(m){t.onError?.(m,a.tier);return}if(O&&typeof O.then=="function"){let v=(a.savePending??Promise.resolve()).then(()=>O,()=>O).then(()=>{a.disposed||(a.seq=h,a.lastSnapshot=p,a.lastFingerprint=g)},w=>{t.onError?.(w,a.tier)});a.savePending=v.finally(()=>{a.savePending===v&&(a.savePending=void 0)})}else a.seq=h,a.lastSnapshot=p,a.lastFingerprint=g},r=(a,p)=>{try{s(a,p)}catch(g){t.onError?.(g,a.tier)}},i=(a,p)=>{if(!p.some(u=>{let y=this.config.messageTier(u[0]);return y>=3&&y<5}))return;if(t.filter){let u=this.tryResolve(a);if(u==null)return;let y=ye(u,ve("standard"));if(!t.filter(a,y))return}let h,f=()=>(h==null&&(h=this.snapshot()),h);for(let u of n)u.disposed||(u.debounceMs===0?r(u,f()):(u.timer==null&&(u.timer=new Me),u.timer.start(u.debounceMs,()=>{u.disposed||r(u,this.snapshot())})))},c;if(t.paths!=null){let p=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(g=>{let h=this.tryResolve(g);return h==null?()=>{}:h.subscribe(f=>i(g,f))});c=()=>{for(let g of p)g()}}else c=this.observe().subscribe((a,p)=>i(a,p));let d=()=>{c();for(let a of n)a.disposed=!0,a.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,t){for(let n of e){let s;try{s=await n.load?.()}catch(i){t?.(i,n);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let r=s;try{if(r.mode==="full"&&r.snapshot!=null)return this.restore(r.snapshot),!0;if(r.version===J&&r.nodes!=null)return this.restore(r),!0}catch(i){t?.(i,n)}}return!1}static async fromStorage(e,t,n){for(let s of t){let r;try{r=await s.load?.()}catch(d){n?.onError?.(d,s);continue}if(r==null||typeof r!="object"||Array.isArray(r))continue;let i=r,c=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===J&&i.nodes!=null?i:void 0;if(c!=null)try{return o.fromSnapshot(c,n)}catch(d){n?.onError?.(d,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,n){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:z(),...n?.actor!=null?{actor:n.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(s=>!e(s)),n=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return n}static diff(e,t){let n=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),r=[...s].filter(m=>!n.has(m)).sort(),i=[...n].filter(m=>!s.has(m)).sort(),c=[],d=[];for(let m of n){if(!s.has(m))continue;let b=e.nodes[m],v=t.nodes[m],w=b.v,E=v.v;w!=null&&E!=null&&w.id===E.id&&w.version!==E.version&&d.push({path:m,id:w.id,from:w.version,to:E.version});let S=w!=null&&E!=null&&w.id===E.id&&w.version===E.version;for(let R of["type","status","sentinel"]){let G=b[R],D=v[R];G!==D&&c.push({path:m,field:R,from:G,to:D})}if(!S)for(let R of["value","meta"]){let G=b[R],D=v[R];at(G,D)||c.push({path:m,field:R,from:G,to:D})}}let a=m=>`${m.from} ${m.to}`,p=new Set(e.edges.map(a)),g=new Set(t.edges.map(a)),h=t.edges.filter(m=>!p.has(a(m))),f=e.edges.filter(m=>!g.has(a(m))),u=new Set(e.subgraphs),y=new Set(t.subgraphs),l=[...y].filter(m=>!u.has(m)).sort(),O=[...u].filter(m=>!y.has(m)).sort();return{nodesAdded:r,nodesRemoved:i,nodesChanged:c,versionChanges:d,edgesAdded:h,edgesRemoved:f,subgraphsAdded:l,subgraphsRemoved:O}}};function gt(o,e){let t=Se.diff(o,e),n={};for(let s of t.nodesAdded){let r=e.nodes[s];r!=null&&(n[s]=r)}return{...t,nodesAddedFull:n}}function Je(o,e,t,n={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return n.withDetail?s:[];if(!n.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let r=n.maxDepth;if(r!=null&&(!Number.isInteger(r)||r<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(r===0)return n.withDetail?s:[];let i=new Map,c=new Map,d=new Map,a=new Map,p=new Set;for(let[b,v]of Object.entries(o.nodes)){if(!b)continue;p.add(b);let w=v.deps??[];i.set(b,w);for(let E of w)E&&(p.add(E),c.has(E)||c.set(E,new Set),c.get(E).add(b))}for(let b of o.edges){if(b==null||typeof b!="object")continue;let v=typeof b.from=="string"?b.from:"",w=typeof b.to=="string"?b.to:"";!v||!w||(p.add(v),p.add(w),a.has(v)||a.set(v,new Set),a.get(v).add(w),d.has(w)||d.set(w,new Set),d.get(w).add(v))}if(!p.has(e))return n.withDetail?s:[];let g=n.both===!0,h=b=>{if(g){let S=i.get(b)??[],R=d.get(b),G=c.get(b),D=a.get(b),k=[...S];return R&&k.push(...R),G&&k.push(...G),D&&k.push(...D),k}if(t==="upstream"){let S=i.get(b)??[],R=d.get(b);return R?[...S,...R]:S}let v=c.get(b),w=a.get(b),E=v?[...v]:[];return w&&E.push(...w),E},f=new Set([e]),u=new Map,y=[{path:e,depth:0}],l=0,O=!1;for(;l<y.length;){let b=y[l++];if(r!=null&&b.depth>=r){h(b.path).length>0&&(O=!0);continue}for(let v of h(b.path))!v||f.has(v)||(f.add(v),u.set(v,b.depth+1),y.push({path:v,depth:b.depth+1}))}let m=[...u.keys()].sort((b,v)=>b<v?-1:b>v?1:0);return n.withDetail?{paths:m,depths:u,truncated:O}:m}function mt(o,e){if(o.length!==e.length)return!1;for(let t=0;t<o.length;t++){let n=o[t],s=e[t];if(n.path!==s.path||n.type!==s.type||n.status!==s.status||n.hop!==s.hop||n.dep_index!==s.dep_index||n.annotation!==s.annotation||n.value!==s.value||n.lastMutation!==s.lastMutation)return!1;let r=n.v,i=s.v;if(r!==i&&(r==null||i==null||r.id!==i.id||r.version!==i.version))return!1}return!0}export{_e as a,Fe as b,A as c,nt as d,ze as e,Ve as f,B as g,J as h,Se as i,gt as j,Je as k};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as D,c as j,d as V,e as $}from"./chunk-
|
|
1
|
+
import{a as D,c as j,d as V,e as $}from"./chunk-6I726LZU.js";import{a as v}from"./chunk-ESMPEKEV.js";import{i as S}from"./chunk-D5RFJOZ2.js";import{n as T}from"./chunk-FHRBBHJN.js";import{m as R,x as N}from"./chunk-CKFQS2CJ.js";import{G as K,o as b,p as L}from"./chunk-LYCLF26R.js";import{j as O}from"./chunk-CK2E7BTU.js";function w(){let e=new Error("aborted");return e.name="AbortError",e}function W(e,r){return e<=0?Promise.resolve():r?.aborted?Promise.reject(w()):new Promise((t,s)=>{let p=new v,u,y=()=>{p.cancel(),r&&u&&r.removeEventListener("abort",u)};p.start(e,()=>{y(),t()}),r&&(u=()=>{y(),s(w())},r.addEventListener("abort",u,{once:!0}))})}function U(e={}){let r=e.provider??"dry-run",t=e.model??"dry-run-v1",s=e.latencyMs??0,p=Math.max(1,e.streamChunkSize??16),u=e.respond??(d=>{let o=[...d].reverse().find(n=>n.role==="user");return o?`echo: ${o.content}`:"dry-run: no user message"}),y=e.usage??((d,o)=>{let n=d.reduce((a,l)=>a+l.content.length,0);return{input:{regular:Math.ceil(n/4)},output:{regular:Math.ceil(o.length/4)}}});return{provider:r,model:t,async invoke(d,o){if(await W(s,o?.signal),o?.signal?.aborted)throw w();let n=u(d,o),a=y(d,n);return{content:n,usage:a,finishReason:"stop",model:o?.model??t,provider:r,tier:o?.tier,metadata:{dryRun:!0}}},async*stream(d,o){let n=u(d,o),a=y(d,n),l=Math.ceil(n.length/p)||1,i=s>0?s/l:0;for(let c=0;c<n.length;c+=p){if(o?.signal?.aborted)throw w();await W(i,o?.signal),yield{type:"token",delta:n.slice(c,c+p)}}yield{type:"usage",usage:a},yield{type:"finish",reason:"stop"}}}}function _(e){let{storage:r,mode:t="read-write",keyFn:s,keyPrefix:p="llm-replay"}=e,y=V({storage:r,keyPrefix:p,mode:t==="read-strict"?"read":t,keyContext:({messages:o,opts:n})=>{let{signal:a,keyContext:l,...i}=n??{};return{messages:o,opts:i}}});async function d(o,n){if(s){if(s.length<=1){let l={messages:o,opts:n,context:n?.keyContext},i=await s(l);return`${p}:${i}`}let a=await s(o,n);return`${p}:${a}`}return y.keyFor({messages:o,opts:n})}return{keyFor:d,async lookup(o,n){if(t!=="write"){if(s){let a=await d(o,n),l=await r.load(a);return l===void 0?void 0:l}return y.lookup({messages:o,opts:n})}},async store(o,n,a){if(t!=="read"){if(s){let l=await d(o,n);await r.save(l,a);return}await y.store({messages:o,opts:n},a)}},async forget(o,n){if(!(t==="read"||t==="write")&&r.delete){if(s){let a=await d(o,n);await r.delete(a);return}await y.forget({messages:o,opts:n})}}}}function z(e,r,t){return{provider:t?.provider??e.provider,model:t?.model??e.model,capabilities:t?.capabilities??e.capabilities?.bind(e),invoke:r.invoke,stream:r.stream}}function ce(e,r){let{onResp:t,onError:s,name:p}=r;if(e!=null&&typeof e.then=="function"){let n=e;return s?n.then(t).catch(a=>{throw s(a),a}):n.then(t)}if(e!=null&&typeof e=="object"&&"content"in e)return t(e);let u=R(e);if(s){let n=!1;u.subscribe(a=>{for(let l of a){if(n)return;l[0]===O&&(n=!0,s(l[1]))}})}let y,d=!1,o=T(u,n=>{y=t(n),d=!0});return K([o],([n])=>n==null?null:d?y:t(n),{name:p??"adapt/invokeTap"})}function pe(e){let r=e.endNs??b();return{timestamp:r,wallClock:e.startWallClockNs??L(),provider:e.provider,model:e.model,tier:e.tier,usage:e.usage,latencyMs:Math.max(0,(r-e.startNs)/1e6),method:e.method,...e.error?{error:e.error}:{}}}function ye(){return{input:{regular:0},output:{regular:0}}}var G=Symbol.for("graphrefly.adapter.middlewareLayers");function J(e,r,t){let p=[...t?Q(t):[],r];return Object.defineProperty(e,G,{value:Object.freeze(p),enumerable:!1,writable:!1,configurable:!1}),e}function Q(e){let r=e[G];return Array.isArray(r)?r:[]}var M=class extends Error{constructor(t,s){super(`withReplayCache: no cached response for ${s} (key=${t}, mode=read-strict)`);this.key=t;this.method=s}name="ReplayCacheMissError"};function q(e,r){let t=r.mode??"read-write",s=r.cacheStreaming??!1,p=r.captureStreamCadence??!1,u=r.replaySpeed??1,y=r.keyPrefix??"llm-replay",d=t==="read"||t==="read-strict",o=_({storage:r.storage,mode:t==="write-only"?"write":t,keyFn:r.keyFn,keyPrefix:y}),n=i=>i<=0?Promise.resolve():new Promise(c=>{new v().start(i,()=>c())}),a=$(async({messages:i,invokeOpts:c})=>await N(R(e.invoke(i,c))),{keyFn:({_precomputedKey:i})=>i}),l=z(e,{async invoke(i,c){let C=await o.keyFor(i,c),f=await o.lookup(i,c);if(f?.response){let k=f.response;return{...k,metadata:{...k.metadata??{},replayCache:"hit"}}}if(t==="read-strict")throw new M(C,"invoke");let h=await a({messages:i,invokeOpts:c,_precomputedKey:C});return d||await o.store(i,c,{response:h,storedAtNs:L()}),h},async*stream(i,c){if(!s){for await(let m of e.stream(i,c))yield m;return}let C=await o.keyFor(i,c),f=await o.lookup(i,c);if(f){let m=f.response;if(f.streamChunks&&f.streamCadenceMs)for(let g=0;g<f.streamChunks.length;g++){let A=f.streamCadenceMs[g]??0,E=u>0?A/u:0;E>0&&await n(E),yield{type:"token",delta:f.streamChunks[g]?.delta??""}}else m.content&&(yield{type:"token",delta:m.content});m.usage&&(yield{type:"usage",usage:m.usage}),yield{type:"finish",reason:m.finishReason??"stop"};return}if(t==="read-strict")throw new M(C,"stream");let h="",k,P,F=[],I=[],x;for await(let m of e.stream(i,c)){if(m.type==="token"&&(h+=m.delta,p)){let g=b(),A=x===void 0?0:(g-x)/1e6;I.push(A),x=g,F.push({delta:m.delta})}m.type==="usage"&&(k=m.usage),m.type==="finish"&&(P=m.reason),yield m}if((h||k)&&!d){let g={response:{content:h,usage:k??{input:{regular:0},output:{regular:0}},finishReason:P,model:e.model??c?.model??"",provider:e.provider},storedAtNs:L(),...p?{streamChunks:F,streamCadenceMs:I}:{}};await o.store(i,c,g)}}});return J(l,"withReplayCache",e),l}var B=j;var Ae=M;function H(e,r){return{content:"[fallback: no cached response available for this request]",usage:{input:{regular:0},output:{regular:0}},finishReason:"stop",model:r,provider:e,metadata:{degraded:!0,reason:"no-fixture"}}}function Y(e,r,t){return typeof e=="string"?{content:e,usage:{input:{regular:0},output:{regular:0}},finishReason:"stop",model:t,provider:r,metadata:{degraded:!0,reason:"respond"}}:e}async function X(e,r){if("key"in e)return e.key;let t=B({messages:e.messages,opts:e.invokeOpts??{}}),s=await D(t);return`${r}:${s}`}function Z(e){let r={response:e.response,storedAtNs:L()};if("key"in e&&e.stream){let t=e.stream.chunks.filter(s=>s.type==="token");return{...r,streamChunks:t.map(s=>({delta:s.delta})),streamCadenceMs:e.stream.delaysMs??t.map(()=>0)}}return r}function ee(e,r){let t=[];if(e.fixtures!=null&&t.push("fixtures"),e.fixturesStorage!=null&&t.push("fixturesStorage"),t.length>1)throw new TypeError(`fallbackAdapter: \`fixtures\` and \`fixturesStorage\` are mutually exclusive; got both ${t.join(" and ")}. Pick one source. For filesystem directories use the node subpath's \`fallbackAdapter\`.`);if(e.fixtures){let s=S(),p=e.fixtures,u=(async()=>{for(let y of p){let d=await X(y,r);await s.save(d,Z(y))}})();return u.catch(()=>{}),{tier:s,seedReady:u}}return e.fixturesStorage?{tier:e.fixturesStorage,seedReady:Promise.resolve()}:{tier:void 0,seedReady:Promise.resolve()}}function Se(e={}){let r=e.provider??"fallback",t=e.model??"fallback",s=e.onMiss??"respond",p=e.keyPrefix??"fallback",u=e.record?e.record.adapter:s==="throw"?U({provider:r,model:t,respond:()=>"[unreachable: read-strict mode throws on miss]"}):{provider:r,model:t,async invoke(a,l){let i=e.respond?e.respond(a,l):H(r,t);return Y(i,r,t)},async*stream(a,l){let i=e.respond?e.respond(a,l):H(r,t),c=Y(i,r,t);yield{type:"token",delta:c.content},c.usage&&(yield{type:"usage",usage:c.usage}),yield{type:"finish",reason:c.finishReason??"stop"}}},y,d=Promise.resolve();if(e.record){if(!e.record.storage)throw new TypeError("fallbackAdapter: `record.storage` is required in record mode. For filesystem `record.dir` convenience, use the node subpath's `fallbackAdapter`.");y=e.record.storage}else{let a=ee(e,p);y=a.tier??S(),d=a.seedReady}let o=e.record?"read-write":s==="throw"?"read-strict":"read",n=q(u,{storage:y,mode:o,keyPrefix:p,cacheStreaming:!0,captureStreamCadence:!0,replaySpeed:e.replaySpeed,...e.keyFn?{keyFn:e.keyFn}:{}});return{provider:r,model:t,capabilities:n.capabilities?.bind(n),async invoke(a,l){return await d,n.invoke(a,l)},async*stream(a,l){await d;for await(let i of n.stream(a,l))yield i}}}export{U as a,z as b,ce as c,pe as d,ye as e,J as f,M as g,q as h,B as i,Ae as j,Se as k};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as _}from"./chunk-
|
|
1
|
+
import{i as _}from"./chunk-2BX4NB34.js";import{D as g,E as k}from"./chunk-LYCLF26R.js";import{b as R,c as T,d,h as A,i as O,j as D}from"./chunk-CK2E7BTU.js";function L(c,y,l,a){let s=new _(c,a);s.add(y,{name:"source"});let n=k(l,{meta:{kind:"stratify_rules"}});s.add(n,{name:"rules"});for(let f of l)E(s,y,n,f);return s}function E(c,y,l,a){let s=`branch/${a.name}`,n=Symbol("noValue"),f=!1,m=!1,p=!1,N=n,r=!1,h=l.cache??[];function v(o){if(p){p=!1;let t=N;if(N=n,t!==n){let i=h.find(u=>u.name===a.name),e=!1;try{e=i?.classify(t)??!1}catch{e=!1}e?(r=!1,o.emit(t)):r&&(r=!1,o.down([[T],[d]]))}else r?(r=!1,o.down([[T],[d]])):o.down([[d]])}}let S=g([],(o,t)=>{let i=y.subscribe(u=>{for(let b of u)w(b,0,t)}),e=l.subscribe(u=>{for(let b of u)w(b,1,t)});return()=>{i(),e()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:a.name},completeWhenDepsComplete:!1});function w(o,t,i){let e=o[0];return e===T?(t===0?(f=!0,r=!0):m=!0,!0):e===R||e===d?(t===0?(f=!1,p=!0,N=e===R?o[1]:n):(e===R&&(h=o[1]),m=!1),f||m||v(i),!0):e===O||e===D||e===A?(f=!1,m=!1,p=!1,N=n,r=!1,t===0&&i.down([o]),!0):t===1}if(c.add(S,{name:s}),a.ops){let o=a.ops(S),t=`branch/${a.name}/out`;c.add(o,{name:t})}}export{L as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as $,g as _}from"./chunk-
|
|
1
|
+
import{c as $,g as _}from"./chunk-756D5TFD.js";import{a as L}from"./chunk-L6NSJVJZ.js";import{i as F}from"./chunk-2BX4NB34.js";import{b as z}from"./chunk-35JTVPOX.js";import{D as j,E as G,G as D,m as E,p as B}from"./chunk-LYCLF26R.js";import{b as P,d as S,i as I,j as K}from"./chunk-CK2E7BTU.js";import{b as ie}from"./chunk-QYADASLV.js";var se={};ie(se,{PipelineGraph:()=>x,decisionKeyOf:()=>q,pipelineGraph:()=>W});function N(y,t){return L("orchestration",y,t)}var q=y=>y.action,x=class extends F{constructor(t,i){super(t,i)}task(t,i,e={}){let a=(e.deps??[]).map(c=>this._resolveStep(c)),p=D(a,i,{name:t,describeKind:"derived",meta:N("task",e.meta)});return this.add(p,{name:t}),p}classify(t,i,e,a={}){let p=this._resolveStep(i),c=D([p],([d])=>{try{return{tag:e(d),value:d}}catch(f){return{tag:"error",value:d,error:f}}},{name:t,describeKind:"derived",meta:N("classify",a.meta)});return this.add(c,{name:t}),c}combine(t,i,e={}){let a=Object.keys(i),p=a.map(d=>this._resolveStep(i[d])),c=D(p,d=>{let f={};for(let s=0;s<a.length;s++)f[a[s]]=d[s];return f},{name:t,describeKind:"derived",meta:N("combine",e.meta)});return this.add(c,{name:t}),c}approvalGate(t,i,e={}){let a=e.maxPending??1e3;if(a<1&&a!==Number.POSITIVE_INFINITY)throw new RangeError("approvalGate: maxPending must be >= 1");let p=e.startOpen??!1;typeof i!="string"&&this.nameOf(i)===void 0&&this.add(i,{name:`${t}/source`});let c=this._resolveStep(i),d=new F(`${t}_state`),f=G([],{name:"pending",equals:()=>!1}),s=G(p,{name:"isOpen"}),R=D([f],([n])=>n.length,{name:"count"}),T=G(0,{name:"droppedCount"}),u=$({name:"decisions",retainedLimit:1024,graph:d});d.add(f,{name:"pending"}),d.add(s,{name:"isOpen"}),d.add(R,{name:"count"}),d.add(T,{name:"droppedCount"}),this.mount(`${t}_state`,d);let l=[],v=!1,k=!1,w=p,M=s.subscribe(n=>{for(let o of n)o[0]===P&&(w=o[1])});this.addDisposer(M);function A(){f.emit([...l])}function C(n,o,r){u.append({action:n,t_ns:B(),...o!==void 0?{items:o,count:o.length}:{},...r!==void 0?{unflushed:r}:{},...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}function U(n){if(l.push(n),l.length>a){let o=l.shift();T.emit(T.cache+1),C("drop",[o])}A()}function O(n){let o=l.splice(0,n);return A(),o}let b=j([c],(n,o,r)=>{let h=r.terminalDeps[0];if(h!==void 0){v=!0;let g=l.length;l=[],A(),C("teardown",void 0,g),o.down(h===!0?[[I]]:[[K,h]]);return}let m=n[0];if(m==null||m.length===0){o.down([[S]]);return}for(let g of m)w?o.emit(g):(U(g),o.down([[S]]))},{name:t,describeKind:"derived",meta:N("approval_gate",e.meta)});if(this.add(b,{name:t}),e.approver!=null){e.approver.cache&&(s.emit(!0),w=!0,e.onceOnly&&(k=!0));let o=e.approver.subscribe(r=>{for(let h of r){if(h[0]!==P)continue;let m=!!h[1];if(m&&!w){if(e.onceOnly){if(k)continue;k=!0}E(()=>{s.emit(!0);let g=O(l.length);C("open",g);for(let te of g){if(v)break;b.emit(te)}})}else if(!m&&w){if(e.onceOnly&&k)continue;E(()=>{s.emit(!1),C("close")})}}});this.addDisposer(o)}let V=n=>{if(v)throw new Error(`approvalGate: ${n}() called after the gate was torn down`)},Y=(n=1)=>{V("approve");let o=O(n);for(let r of o){if(v)break;b.emit(r)}},H=(n=1)=>{V("reject"),O(n)},J=(n,o=1)=>{V("modify");let r=[...l],h=O(o);for(let m=0;m<h.length&&!v;m++)b.emit(n(h[m],m,r))},Q=()=>{V("open"),s.emit(!0);let n=O(l.length);for(let o of n){if(v)break;b.emit(o)}},X=()=>{V("close"),!(e.onceOnly&&k)&&s.emit(!1)},Z=_(Y,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"approve",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ee=_(H,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"reject",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ne=_(J,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"modify",count:n[1]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),re=_(Q,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"open",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),oe=_(X,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"close",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})});return this.addDisposer(R.subscribe(()=>{})),{node:b,pending:f,count:R,isOpen:s,droppedCount:T,decisions:u,audit:u,approve:Z,reject:ee,modify:ne,open:re,close:oe}}approval(t,i,e,a={}){return this.approvalGate(t,i,{...a,approver:e,maxPending:1})}catch(t,i,e,a={}){let p=this._resolveStep(i),c=a.on??"errored",d=j([p],(f,s,R)=>{let T=R.terminalDeps[0];if(T!==void 0){let l=T===!0?{kind:"completed"}:{kind:"errored",error:T};if(c==="terminal"||c===l.kind){s.emit(e(l,s));return}s.down(l.kind==="completed"?[[I]]:[[K,l.error]]);return}let u=f[0];if(u==null||u.length===0){s.down([[S]]);return}for(let l of u)s.emit(l)},{name:t,describeKind:"derived",completeWhenDepsComplete:a.completeWhenDepsComplete??!(c==="completed"||c==="terminal"),errorWhenDepsError:!(c==="errored"||c==="terminal"),meta:N("catch",a.meta)});return this.add(d,{name:t}),d}_resolveStep(t){if(typeof t=="string")return this.resolve(t);if(this.nameOf(t)===void 0)throw new Error(`PipelineGraph "${this.name}": Node dep is not registered. Pass a string path or call graph.add(node) first.`);return t}};function W(y,t){let i=new x(y,t),{factory:e,factoryArgs:a,...p}=t??{};return i.tagFactory("pipelineGraph",z(p)),i}export{q as a,x as b,W as c,se as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as x,x as w}from"./chunk-
|
|
1
|
+
import{m as x,x as w}from"./chunk-CKFQS2CJ.js";import{i as g,j as p}from"./chunk-CK2E7BTU.js";async function k(o){let i=typeof o=="string"?new TextEncoder().encode(o):o,c=await globalThis.crypto.subtle.digest("SHA-256",i),t=new Uint8Array(c),n="";for(let r=0;r<t.length;r++)n+=b[t[r]];return n}var b=new Array(256);for(let o=0;o<256;o++)b[o]=o.toString(16).padStart(2,"0");var m=class extends Error{constructor(c,t){super(`content-addressed lookup miss in read-strict mode: ${c}`);this.key=c;this.context=t;this.name="ContentAddressedMissError"}};function T(o){let i=new Set,c=t=>{if(t===null||typeof t!="object")return t;let n=t;if(i.has(n))return{__cycle:!0};i.add(n);try{if(Array.isArray(t))return t.map(c);let r={};for(let d of Object.keys(t).sort())r[d]=c(t[d]);return r}finally{i.delete(n)}};return JSON.stringify(c(o))}function P(o){let{storage:i,keyContext:c,keyPrefix:t,mode:n="read-write"}=o,r=c??(e=>e);async function d(e){let s=T(r(e)),a=await k(s);return t?`${t}:${a}`:a}return{keyFor:d,async lookup(e){if(n==="write")return;let s=await d(e),a=await i.load(s);if(a===void 0){if(n==="read-strict")throw new m(s,e);return}return a},async store(e,s){if(n==="read")return;let a=await d(e);await i.save(a,s)},async forget(e){if(n==="read"||n==="write"||!i.delete)return;let s=await d(e);await i.delete(s)}}}function K(o,i={}){let c=i.keyFn??(n=>String(n)),t=new Map;return n=>{let r=c(n),d=t.get(r);if(d)return d;let e=o(n),s;e!=null&&typeof e.then=="function"?s=Promise.resolve(e):e!=null&&typeof e=="object"&&"subscribe"in e&&"cache"in e?s=w(e):e!=null&&typeof e=="object"&&Symbol.asyncIterator in e?s=(async()=>{let u=e[Symbol.asyncIterator]();try{let{value:l,done:f}=await u.next();if(f)throw new Error("singleFromAny: factory returned empty async iterable");return l}finally{await u.return?.()}})():e!=null&&typeof e=="object"&&Symbol.iterator in e?s=(async()=>{let u=e[Symbol.iterator]();try{let{value:l,done:f}=u.next();if(f)throw new Error("singleFromAny: factory returned empty iterable");return l}finally{u.return?.()}})():s=Promise.resolve(e);let a,y=()=>{t.get(r)===a&&t.delete(r)};return a=s.then(u=>(y(),u),u=>{throw y(),u}),t.set(r,a),a}}function j(o,i={}){let c=i.keyFn??(n=>String(n)),t=new Map;return n=>{let r=c(n),d=t.get(r);if(d)return d;let e=x(o(n));t.set(r,e);let s=e.subscribe(a=>{for(let y of a)if(y[0]===p||y[0]===g){t.get(r)===e&&t.delete(r),s();return}});return e}}export{k as a,m as b,T as c,P as d,K as e,j as f};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as ce}from"./chunk-
|
|
1
|
+
import{e as ce}from"./chunk-7Q4ZD3YW.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{i as L}from"./chunk-2BX4NB34.js";import{f as ae,h as ie}from"./chunk-CKFQS2CJ.js";import{i as ne,j as U}from"./chunk-LYCLF26R.js";import{b,h as _,i as T,j as W}from"./chunk-CK2E7BTU.js";import{b as Oe,c as re,d as te,e as oe}from"./chunk-QYADASLV.js";var ke={};Oe(ke,{ACTOR_KEY:()=>F,COMMAND_HANDLERS:()=>A,CQRS_EVENT_HANDLERS:()=>S,CRON_HANDLERS:()=>D,CommandHandler:()=>me,EVENT_HANDLERS:()=>G,EventHandler:()=>ve,GRAPHREFLY_REQUEST_GRAPH:()=>R,GRAPHREFLY_ROOT_GRAPH:()=>v,GraphCron:()=>fe,GraphInterval:()=>he,GraphReflyEventExplorer:()=>x,GraphReflyGuard:()=>Re,GraphReflyGuardImpl:()=>I,GraphReflyModule:()=>Q,INTERVAL_HANDLERS:()=>O,InjectCqrsGraph:()=>de,InjectGraph:()=>ue,InjectNode:()=>pe,ObserveGateway:()=>B,OnGraphEvent:()=>le,QUERY_HANDLERS:()=>H,QueryHandler:()=>ye,SAGA_HANDLERS:()=>N,SagaHandler:()=>ge,fromHeader:()=>Ee,fromJwtPayload:()=>V,getActor:()=>we,getGraphToken:()=>m,getNodeToken:()=>y,observeSSE:()=>Me,observeSubscription:()=>Ce,toObservable:()=>se});import{Inject as j}from"@nestjs/common";var v=Symbol.for("graphrefly:root-graph");var R=Symbol.for("graphrefly:request-graph");function m(s){return Symbol.for(`graphrefly:graph:${s}`)}function y(s){return Symbol.for(`graphrefly:node:${s}`)}var G=new Map,O=new Map,D=new Map,A=new Map,S=new Map,H=new Map,N=new Map;function ue(s){return s==="request"?j(R):j(s?m(s):v)}function de(s){return j(m(s))}function pe(s){return j(y(s))}function le(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=G.get(o)??[];n.push({nodeName:s,methodKey:t}),G.set(o,n)})}}function he(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=O.get(o)??[];n.push({ms:s,methodKey:t}),O.set(o,n)})}}function fe(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=D.get(o)??[];n.push({expr:s,methodKey:t}),D.set(o,n)})}}function me(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=A.get(n)??[];a.push({cqrsName:s,commandName:e,methodKey:o}),A.set(n,a)})}}function ve(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=S.get(n)??[];a.push({cqrsName:s,eventName:e,methodKey:o}),S.set(n,a)})}}function ye(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=H.get(n)??[];a.push({cqrsName:s,projectionName:e,methodKey:o}),H.set(n,a)})}}function ge(s,e,r){return(t,o)=>{let n=o.name;o.addInitializer(function(){let a=this.constructor,c=N.get(a)??[];c.push({cqrsName:s,eventNames:r,sagaName:e,methodKey:n}),N.set(a,c)})}}var be=0,x=class{constructor(e,r){this.graph=e;this.moduleRef=r}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,r]of G){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireEventHandler(t,o)}}wireEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),a=this.observeNode(r.nodeName).subscribe(c=>{for(let l of c)l[0]===b&&o(l[1])});this.disposers.push(a)}wireIntervals(){for(let[e,r]of O){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireIntervalHandler(t,e,o)}}wireIntervalHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ae(t.ms,{period:t.ms,name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCrons(){for(let[e,r]of D){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCronHandler(t,e,o)}}wireCronHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ie(t.expr,{name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCqrsCommands(){for(let[e,r]of A){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsCommand(t,o)}}wireCqrsCommand(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.command(r.commandName,o)}wireCqrsEvents(){for(let[e,r]of S){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsEventHandler(t,o)}}wireCqrsEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;n.event(r.eventName);let c=n.resolve(r.eventName).cache,l=c&&c.length>0?c[c.length-1].seq:0,p=this.observeNodeOn(n,r.eventName).subscribe(u=>{for(let d of u)if(d[0]===b){let g=d[1];for(let i of g)i.seq>l&&(o(i),l=i.seq)}});this.disposers.push(p)}wireCqrsQueries(){for(let[e,r]of H){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsQuery(t,o)}}wireCqrsQuery(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;let c=this.observeNodeOn(n,r.projectionName).subscribe(l=>{for(let f of l)f[0]===b&&o(f[1])});this.disposers.push(c)}wireCqrsSagas(){for(let[e,r]of N){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsSaga(t,o)}}wireCqrsSaga(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.saga(r.sagaName,r.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,r){return e.observe(r)}resolveCqrsGraph(e){try{return this.moduleRef.get(m(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};function Me(s,e,r){let{actor:t,serialize:o=De,keepAliveMs:n,signal:a}=r??{},c=new TextEncoder,l,f=r?.highWaterMark!=null,p,u,d=[],g=!1;return new ReadableStream({start(i){let h,w=()=>{},M=()=>{if(!g){g=!0,h!==void 0&&clearInterval(h),a?.removeEventListener("abort",K),w(),p?.dispose(),u?.(),u=void 0;for(let k of d)i.enqueue(k.frame);d.length=0,i.close()}};l=M;let K=()=>M(),ee=s.observe(e,{actor:t});f&&(p=P(k=>ee.up(k),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)})),w=ee.subscribe(k=>{for(let $ of k){if(g)return;let q=$[0];if(q===b){let C=c.encode(Y("data",o($[1])));f?(d.push({frame:C,counted:!0}),p.onEnqueue(),u?.(),u=void 0):i.enqueue(C)}else if(q===W){let C=c.encode(Y("error",o($[1])));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C),M();return}else if(q===T||q===_){if(q===T){let C=c.encode(Y("complete"));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C)}M();return}}}),n!==void 0&&n>0&&(h=setInterval(()=>{g||(f?(d.push({frame:c.encode(`: keepalive
|
|
2
2
|
|
|
3
3
|
`),counted:!1}),u?.(),u=void 0):i.enqueue(c.encode(`: keepalive
|
|
4
4
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as g}from"./chunk-VMF23LGB.js";import{a as v}from"./chunk-J63M5U46.js";import{a as N}from"./chunk-L6NSJVJZ.js";import{i as _}from"./chunk-2BX4NB34.js";import{C as D}from"./chunk-CKFQS2CJ.js";import{E as c,G as p,o as G}from"./chunk-LYCLF26R.js";import{b}from"./chunk-CK2E7BTU.js";import{b as L}from"./chunk-QYADASLV.js";var P={};L(P,{GuardedExecutionGraph:()=>d,guardedExecution:()=>x});function u(o){return typeof o=="object"&&o!==null&&"subscribe"in o&&"down"in o}function w(o){return N("guarded",o)}var d=class extends _{enforcer;violations;lints;scope;scopedDescribe;_target;_actorNode;_mode;_firedLintKinds=new Set;constructor(e,i){super(i.name??`${e.name}_guarded`,i.graph),this._target=e,this._mode=i.mode??"enforce";let n=i.policies,r=u(n);if(!r&&this._mode==="enforce"&&n.length===0)throw new RangeError('guardedExecution: empty `policies` in `mode: "enforce"` denies every action. Pass at least `{ effect: "allow", action: "*" }` and layer deny rules on top.');this.lints=new v("lints",{retainedLimit:i.lintsLimit??64}),this.mount("lints",this.lints);let a=i.actor;a==null?this._actorNode=c(null,{name:"actor"}):u(a)?this._actorNode=p([a],([t])=>t??null,{name:"actor",initial:null}):this._actorNode=c(a,{name:"actor"});let m={mode:this._mode,name:"enforcer"};if(i.violationsLimit!=null&&(m.violationsLimit=i.violationsLimit),this.enforcer=g(e,i.policies,m),this.violations=this.enforcer.violations,this.mount("enforcer",this.enforcer),r&&this._mode==="enforce"){let t=n,s=t.cache;s!=null&&s.length===0&&this._fireLint("empty-policies",'`policies` Node cached an empty array in `mode: "enforce"` \u2014 every action will be denied. Add at least one allow rule.');let l=t.subscribe(A=>{for(let h of A){if(h[0]!==b)continue;let y=h[1];(y==null||y.length===0)&&this._fireLint("empty-policies",'`policies` Node emitted an empty array in `mode: "enforce"` \u2014 every action will be denied. Add at least one allow rule.')}});this.addDisposer(l)}if(this._mode==="audit"){let t=e.describe({detail:"full"});Object.values(t.nodes).some(l=>l.guard!=null)||this._fireLint("audit-no-effect",'`mode: "audit"` + target has no per-node guards \u2014 `scopedDescribeNode` filters by per-node guards only, so policy rules will not affect describe() visibility. Policies still populate the `violations` topic on writes.')}a==null&&this._fireLint("no-actor","no actor configured \u2014 `wrapper.scopedDescribe` and `scopedDescribeNode()` will return an unscoped describe (full visibility) unless a per-call actor is supplied."),this.scope=p([this._actorNode,this.enforcer.policies],([t,s])=>({actor:t??null,mode:this._mode,policiesCount:s.length}),{name:"scope",describeKind:"derived",meta:w("scope")}),this.add(this.scope,{name:"scope"}),this.addDisposer(D(this.scope));let f=e.describe({reactive:!0,actor:this._actorNode,reactiveName:"scopedDescribe"});this.scopedDescribe=f.node,this.add(this.scopedDescribe,{name:"scopedDescribe"}),this.addDisposer(f.dispose)}_fireLint(e,i){this._firedLintKinds.has(e)||(this._firedLintKinds.add(e),this.lints.publish({kind:e,message:i,timestamp_ns:G()}))}scopedDescribeNode(e,i){let n=e==null?this._actorNode:u(e)?e:c(e,{name:"actor_override"}),r=this._target.describe({reactive:!0,actor:n,...i??{}});return this.addDisposer(r.dispose),{node:r.node,dispose:r.dispose}}get target(){return this._target}};function x(o,e){return new d(o,e)}export{d as a,x as b,P as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as x}from"./chunk-
|
|
1
|
+
import{i as x}from"./chunk-2BX4NB34.js";import{b as y}from"./chunk-YXDRGKXP.js";import{E as T,m as A,p as f,t as b}from"./chunk-LYCLF26R.js";import{b as m,c as R}from"./chunk-CK2E7BTU.js";function N(r,e){let t=r.cache??0;return t>=e?!1:(r.down([[R],[m,t+1]]),!0)}var M=b((r,e)=>{r("observe"),r("signal"),e("write")});function q(r){let e=y([],{name:r.name,maxSize:r.retainedLimit??1024,guard:r.guard??M,...r.versioning!=null?{versioning:r.versioning}:{}});return e.withLatest(),r.graph&&r.graph.add(e.entries,{name:r.name}),e}function p(r){if(r===null||typeof r!="object"||Object.isFrozen(r))return r;for(let e of Object.keys(r))p(r[e]);return Object.freeze(r)}function w(r){let e=r.cache,u=(typeof e=="number"&&Number.isFinite(e)?e:0)+1;return r.down([[R],[m,u]]),u}function g(r,e,t,u,i,s){let o=e(t,u,i);if(o===void 0)return;let a=s!=null?{...o,handlerVersion:s}:o;r.append(a)}function z(r,e){let t=e.freeze??!0;return function(...i){let s=t?i.map(p):i,o=f(),a=e.seq?w(e.seq):void 0;try{let n=r(...s);return e.onSuccess&&g(e.audit,e.onSuccess,s,n,{t_ns:o,seq:a},e.handlerVersion),n}catch(n){if(e.onFailure){let d=n instanceof Error?n.name:typeof n;g(e.audit,e.onFailure,s,n,{t_ns:o,seq:a,errorType:d},e.handlerVersion)}throw n}}}function G(r,e){let t=e.freeze??!0;return function(...i){let s=t?i.map(p):i,o=f(),a,n,d=!1,l;try{A(()=>{e.seq&&(l=w(e.seq));try{a=r(...s),e.onSuccess&&g(e.audit,e.onSuccess,s,a,{t_ns:o,seq:l},e.handlerVersion)}catch(c){throw n=c,d=!0,c}})}catch(c){if(d&&e.onFailure){let h=n instanceof Error?n.name:typeof n;g(e.audit,e.onFailure,s,n,{t_ns:o,seq:l,errorType:h},e.handlerVersion)}throw d?n:c}return a}}function V(r,e,t=0){let u=T(t,{name:e,describeKind:"state"});return r.add(u,{name:e}),u}function _(r,e,t,u=0){let i={},s=new x(e);for(let o of t){let a=T(u,{name:o,describeKind:"state"});s.add(a,{name:o}),i[o]=a}return r.mount(e,s),i}export{N as a,M as b,q as c,w as d,g as e,z as f,G as g,V as h,_ as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as M,h as oe,i as ae}from"./chunk-VJJLIEAL.js";import{a as ne}from"./chunk-L6NSJVJZ.js";import{i as se}from"./chunk-7JRF5YEK.js";import{b as re}from"./chunk-35JTVPOX.js";import{b as J}from"./chunk-AU7YTQX7.js";import{C as z}from"./chunk-IA7DUNGB.js";import{D as ee,E as te,G as j,m as Y,p as R,t as D}from"./chunk-LYCLF26R.js";import{b as X}from"./chunk-CK2E7BTU.js";import{b as ce}from"./chunk-QYADASLV.js";var me={};ce(me,{CqrsGraph:()=>G,cqrs:()=>fe,cqrsEventKeyOf:()=>pe,dispatchKeyOf:()=>he,sagaInvocationKeyOf:()=>ve});var k=class extends Error{constructor(e,n){super(e,n),this.name=this.constructor.name}},B=class extends k{constructor(n,t){super(`Duplicate ${n} registration: "${t}"`);this.kind=n;this.registrationName=t}},N=class extends k{constructor(n,t,r){super(`Command "${n}" emitted undeclared event "${t}". Declared emits: [${r.join(", ")}]`);this.commandName=n;this.eventName=t;this.declaredEmits=r}},K=class extends k{constructor(n,t,r){super(`Optimistic concurrency conflict on aggregate "${n}": expected version ${t}, got ${r}`);this.aggregateId=n;this.expected=t;this.actual=r}},H=class extends k{constructor(n){super(`Unknown command: "${n}". Register with command() first.`);this.commandName=n}},O=class extends k{constructor(n,t){super(`Command handler "${n}" threw: ${t instanceof Error?t.message:String(t)}`,{cause:t});this.commandName=n}};var P=class extends k{constructor(n,t){super(`Projection "${n}" rebuild failed: ${t instanceof Error?t.message:String(t)}`,{cause:t});this.projectionName=n}};var le=D((o,e)=>{o("write"),o("signal"),e("observe")}),ue=D((o,e)=>{o("observe"),o("signal"),e("write")}),ie=D((o,e)=>{o("observe"),o("signal"),e("write")});function $(o,e){return ne("cqrs",o,e)}function Z(o){if(o===null||typeof o!="object"||Object.isFrozen(o))return o;for(let e of Object.keys(o))Z(o[e]);return Object.freeze(o)}var pe=o=>`${o.type}::${o.aggregateId??"__default__"}`,he=o=>o.commandName,ve=o=>o.eventType,G=class extends se{_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=M({name:"dispatches",retainedLimit:this._retainedLimit,graph:this}),this.audit=this.dispatches,this.aggregateEvictions=M({name:"aggregateEvictions",retainedLimit:this._retainedLimit,graph:this}),this._dispatchSeqCursor=oe(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 t=n.indexOf("::");if(t<0)continue;let r=n.slice(0,t),s=n.slice(t+2),a=this._aggregateVersions.get(n)??0;this._aggregateVersions.delete(n);let i=this._eventLogsByAggregate.get(r);i&&(i.delete(s),i.size===0&&this._eventLogsByAggregate.delete(r)),this.aggregateEvictions.append({aggregateId:s,type:r,lastVersion:a,t_ns:R()})}}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,t]of this._eventLogs){let r=t.log.attachStorage(e),s=this._attachedTierDisposers.get(n);s||(s=[],this._attachedTierDisposers.set(n,s)),s.push(r)}for(let[n,t]of this._eventLogsByAggregate)for(let[r,s]of t){let a=`${n}::${r}`,i=s.log.attachStorage(e),c=this._attachedTierDisposers.get(a);c||(c=[],this._attachedTierDisposers.set(a,c)),c.push(i)}return()=>{let n=this._attachedEventTiers.indexOf(e);n>=0&&this._attachedEventTiers.splice(n,1)}}_autoWireStreamStorage(e,n){if(this._attachedEventTiers.length===0)return;let t=this._attachedTierDisposers.get(e);t||(t=[],this._attachedTierDisposers.set(e,t));for(let r of this._attachedEventTiers)t.push(n.attachStorage(r))}_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 t=this._eventLogs.get(e);if(t)return t.node;let r=J([],{name:e,versioning:0,maxSize:this._retainedLimit});r.withLatest();let s=r.entries,a=j([s],([i])=>i,{name:e,describeKind:"state",meta:$("event",{event_name:e}),guard:ie,initial:s.cache});return this.add(a,{name:e}),this._keepaliveDisposers.push(z(a)),this._eventLogs.set(e,{log:r,node:a}),this._autoWireStreamStorage(e,r),a}_ensureAggregateStream(e,n){this._eventLogs.has(e)||this.event(e);let t=this._eventLogsByAggregate.get(e);t||(t=new Map,this._eventLogsByAggregate.set(e,t));let r=`${e}::${n}`;this._touchAggregate(r);let s=t.get(n);if(s)return s;let a=`${e}_${n.replace(/[^a-zA-Z0-9_-]/g,"_")}`,i=J([],{name:a,versioning:0,maxSize:this._retainedLimit});i.withLatest();let c=i.entries,h=j([c],([p])=>p,{name:a,describeKind:"state",meta:$("event_aggregate",{event_name:e,aggregate_id:n}),guard:ie,initial:c.cache}),l=a,m=0;for(;this.nameOf(this.resolveOptional(l)??h)===l&&(m+=1,l=`${a}_${m}`,this.resolveOptional(l)!==void 0););try{this.add(h,{name:l})}catch{}this._keepaliveDisposers.push(z(h));let u={log:i,node:h};return t.set(n,u),this._autoWireStreamStorage(`${e}::${n}`,i),this._enforceAggregateLru(),u}resolveOptional(e){try{return this.resolve(e)}catch{return}}_appendEvent(e,n,t){let r=this._eventLogs.get(e);if(r||(this.event(e),r=this._eventLogs.get(e)),r.node.status==="completed"||r.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${r.node.status}).`);let s,a;if(t?.aggregateId!==void 0){let l=`${e}::${t.aggregateId}`;s=(this._aggregateVersions.get(l)??0)+1,this._aggregateVersions.set(l,s),a=this._ensureAggregateStream(e,t.aggregateId)}let i=r.log.entries.v,c=this._freezeEventPayload?Z(n):n,h={type:e,payload:c,timestampNs:R(),seq:++this._seq,...t?.aggregateId!==void 0?{aggregateId:t.aggregateId}:{},...s!==void 0?{aggregateVersion:s}:{},...t?.correlationId!==void 0?{correlationId:t.correlationId}:{},...t?.causationId!==void 0?{causationId:t.causationId}:{},...t?.metadata!==void 0?{metadata:Object.freeze({...t.metadata})}:{},...t?.handlerVersion!==void 0?{handlerVersion:t.handlerVersion}:{},...i!=null?{v0:{id:i.id,version:i.version}}:{}};return r.log.append(h),a&&a.log.append(h),h}command(e,n){if(this._commandRegs.has(e))throw new B("command",e);let t=typeof n=="function"?{handler:n}:n,r=te(void 0,{name:e,describeKind:"state",meta:{...$("command",{command_name:e}),error:null},guard:le});if(this.add(r,{name:e}),this._commandRegs.set(e,{handler:t.handler,...t.emits!==void 0?{emits:t.emits}:{},...t.handlerVersion!==void 0?{handlerVersion:t.handlerVersion}:{}}),t.emits)for(let s of t.emits)this._eventLogs.has(s)||this.event(s);return r}dispatch(e,n,t){let r=this._commandRegs.get(e);if(!r)throw new H(e);if(t?.aggregateId!==void 0&&t.expectedAggregateVersion!==void 0&&r.emits!==void 0){let u=0;for(let p of r.emits){let _=this._aggregateVersions.get(`${p}::${t.aggregateId}`);_!==void 0&&_>u&&(u=_)}if(u!==t.expectedAggregateVersion)throw new K(t.aggregateId,t.expectedAggregateVersion,u)}let s=this.resolve(e),a=this._freezeCommandPayload?Z(n):n,i=[],c=R(),h=0,l,m=!1;try{Y(()=>{h=this._bumpDispatchSeq(),s.emit(a,{internal:!0});try{r.handler(a,{emit:(u,p)=>{if(r.emits!==void 0&&!r.emits.includes(u))throw new N(e,u,r.emits);i.push(u),this._appendEvent(u,p,{...t?.aggregateId!==void 0?{aggregateId:t.aggregateId}:{},...t?.correlationId!==void 0?{correlationId:t.correlationId}:{},...t?.causationId!==void 0?{causationId:t.causationId}:{},...t?.metadata!==void 0?{metadata:Object.freeze({...t.metadata})}:{},...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}}),s.meta.error.emit(null,{internal:!0}),this.dispatches.append({commandName:e,payload:a,outcome:"success",emittedEvents:[...i],t_ns:c,seq:h,...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}catch(u){throw l=u,m=!0,u}})}catch(u){if(m){s.meta.error.emit(l,{internal:!0});let p=l instanceof Error?l.name:typeof l,_=l instanceof O?l:new O(e,l);this.dispatches.append({commandName:e,payload:a,outcome:"failure",error:_,errorType:p,emittedEvents:[...i],t_ns:c,seq:h,...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}throw m?l:u}}projection(e){let{name:n,events:t,reducer:r,initial:s}=e,a=e.mode??"scan",i=e.freezeInputs??!0,c=e.snapshot,h=t.map(d=>(this._eventLogs.has(d)||this.event(d),this._eventLogs.get(d).node));function l(d){d.sort((g,v)=>g.timestampNs-v.timestampNs||g.seq-v.seq||(g.aggregateId??"").localeCompare(v.aggregateId??""))}function m(d){let g=[];for(let v of d)g.push(...v);return l(g),g}let u=h.map(d=>d.cache??[]),p=m(u),_=i?Object.freeze(p):p,C=0,y=s;a==="scan"&&p.length>0&&(y=r(s,_),C=p.length);let q=a==="replay"?r(s,_):y,V=c?.saveDebounceMs??1e3,A=c?.saveEvery??1e3,E,L=0;function F(d){if(c?.save){if(L+=1,L>=A){L=0,E!==void 0&&(clearTimeout(E),E=void 0);let g=c.save(d);g instanceof Promise&&g.catch(()=>{});return}E!==void 0&&clearTimeout(E),E=setTimeout(()=>{E=void 0,L=0;let g=c.save(d);g instanceof Promise&&g.catch(()=>{})},V)}}let S=j(h,d=>{let g=m(d),v;if(a==="replay"){let w=i?Object.freeze(g):g;v=r(s,w)}else{let w=g.slice(C);C=g.length;let f=i?Object.freeze(w):w;v=r(y,f),y=v}return F(v),v},{name:n,describeKind:"derived",meta:$("projection",{projection_name:n,source_events:t}),guard:ue,initial:q});return this.add(S,{name:n}),this._keepaliveDisposers.push(z(S)),this._keepaliveDisposers.push(()=>{E!==void 0&&(clearTimeout(E),E=void 0)}),this._projections.add(n),{node:S,rebuild:async d=>{try{let g=d?.pageSize??1e3,v=d?.fromTier??this._attachedEventTiers[0]?.[0],w=m(h.map(T=>T.cache??[])).length,f=s;if(c?.load){let T=await c.load();T!==void 0&&(f=T)}if(!v||!v.loadEntries){let T=m(h.map(I=>I.cache??[])),b=i?Object.freeze(T):T;f=r(f,b)}else{let T=new Set(t),b,I=!1;for(;!I;){let U=await v.loadEntries({cursor:b,pageSize:g}),W=[...U.entries].filter(ge=>T.has(ge.type));l(W);let de=i?Object.freeze(W):W;f=r(f,de),b=U.cursor,I=!b||U.entries.length===0}}if(a==="scan"){let T=m(h.map(I=>I.cache??[])),b=T.slice(w);if(b.length>0){let I=i?Object.freeze(b):b;f=r(f,I)}y=f,C=T.length}return S.emit(f,{internal:!0}),f}catch(g){throw new P(n,g)}},reset:async()=>{try{let d=s;if(c?.load){let f=await c.load();f!==void 0&&(d=f)}let g=m(h.map(f=>f.cache??[])),v=i?Object.freeze(g):g,w=r(d,v);return a==="scan"&&(y=w,C=g.length),S.emit(w,{internal:!0}),w}catch(d){throw new P(n,d)}}}}saga(e,n,t,r={}){let s=n.map(p=>(this._eventLogs.has(p)||this.event(p),this._eventLogs.get(p).node)),a=ae(this,`${e}_cursor`,n,0),i=M({name:`${e}_invocations`,retainedLimit:this._retainedLimit,graph:this}),c=r.aggregateId,h=r.errorPolicy??"advance",l=new Map;for(let p of n){let _=a[p];l.set(p,_.cache??0);let C=_.subscribe(y=>{for(let q of y)q[0]===X&&l.set(p,q[1])});this._keepaliveDisposers.push(C)}let m={},u=ee(s,(p,_)=>{let C=m.n.meta.error;for(let y=0;y<p.length;y++){let q=p[y];if(q==null||q.length===0)continue;let V=q.at(-1);if(!V)continue;let A=n[y],E=a[A],L=l.get(A)??0;if(V.length>L){let F=V.slice(L),S=L;for(let Q of F){let x=Q;if(c!==void 0&&x.aggregateId!==c){S+=1;continue}try{t(x),C.emit(null,{internal:!0}),i.append({eventType:A,outcome:"success",aggregateId:x.aggregateId,event:x,t_ns:R(),...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),S+=1}catch(d){if(C.emit(d,{internal:!0}),i.append({eventType:A,outcome:"failure",error:d,errorType:d instanceof Error?d.name:typeof d,aggregateId:x.aggregateId,event:x,t_ns:R(),...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),h==="hold")break;S+=1}}E.emit(S)}}},{name:e,describeKind:"effect",meta:{...$("saga",{saga_name:e,source_events:n}),error:null}});return m.n=u,this.add(u,{name:e}),this._keepaliveDisposers.push(z(u)),this._sagas.add(e),{node:u,invocations:i,audit:i,cursors:a}}};function fe(o,e){let n=new G(o,e),{factory:t,factoryArgs:r,...s}=e??{};return n.tagFactory("cqrs",re(s)),n}export{pe as a,he as b,ve as c,G as d,fe as e,me as f};
|
|
1
|
+
import{c as M,h as oe,i as ae}from"./chunk-756D5TFD.js";import{a as ne}from"./chunk-L6NSJVJZ.js";import{i as se}from"./chunk-2BX4NB34.js";import{b as re}from"./chunk-35JTVPOX.js";import{b as J}from"./chunk-YXDRGKXP.js";import{C as z}from"./chunk-CKFQS2CJ.js";import{D as ee,E as te,G as j,m as Y,p as R,t as D}from"./chunk-LYCLF26R.js";import{b as X}from"./chunk-CK2E7BTU.js";import{b as ce}from"./chunk-QYADASLV.js";var me={};ce(me,{CqrsGraph:()=>G,cqrs:()=>fe,cqrsEventKeyOf:()=>pe,dispatchKeyOf:()=>he,sagaInvocationKeyOf:()=>ve});var k=class extends Error{constructor(e,n){super(e,n),this.name=this.constructor.name}},B=class extends k{constructor(n,t){super(`Duplicate ${n} registration: "${t}"`);this.kind=n;this.registrationName=t}},N=class extends k{constructor(n,t,r){super(`Command "${n}" emitted undeclared event "${t}". Declared emits: [${r.join(", ")}]`);this.commandName=n;this.eventName=t;this.declaredEmits=r}},K=class extends k{constructor(n,t,r){super(`Optimistic concurrency conflict on aggregate "${n}": expected version ${t}, got ${r}`);this.aggregateId=n;this.expected=t;this.actual=r}},H=class extends k{constructor(n){super(`Unknown command: "${n}". Register with command() first.`);this.commandName=n}},O=class extends k{constructor(n,t){super(`Command handler "${n}" threw: ${t instanceof Error?t.message:String(t)}`,{cause:t});this.commandName=n}};var P=class extends k{constructor(n,t){super(`Projection "${n}" rebuild failed: ${t instanceof Error?t.message:String(t)}`,{cause:t});this.projectionName=n}};var le=D((o,e)=>{o("write"),o("signal"),e("observe")}),ue=D((o,e)=>{o("observe"),o("signal"),e("write")}),ie=D((o,e)=>{o("observe"),o("signal"),e("write")});function $(o,e){return ne("cqrs",o,e)}function Z(o){if(o===null||typeof o!="object"||Object.isFrozen(o))return o;for(let e of Object.keys(o))Z(o[e]);return Object.freeze(o)}var pe=o=>`${o.type}::${o.aggregateId??"__default__"}`,he=o=>o.commandName,ve=o=>o.eventType,G=class extends se{_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=M({name:"dispatches",retainedLimit:this._retainedLimit,graph:this}),this.audit=this.dispatches,this.aggregateEvictions=M({name:"aggregateEvictions",retainedLimit:this._retainedLimit,graph:this}),this._dispatchSeqCursor=oe(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 t=n.indexOf("::");if(t<0)continue;let r=n.slice(0,t),s=n.slice(t+2),a=this._aggregateVersions.get(n)??0;this._aggregateVersions.delete(n);let i=this._eventLogsByAggregate.get(r);i&&(i.delete(s),i.size===0&&this._eventLogsByAggregate.delete(r)),this.aggregateEvictions.append({aggregateId:s,type:r,lastVersion:a,t_ns:R()})}}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,t]of this._eventLogs){let r=t.log.attachStorage(e),s=this._attachedTierDisposers.get(n);s||(s=[],this._attachedTierDisposers.set(n,s)),s.push(r)}for(let[n,t]of this._eventLogsByAggregate)for(let[r,s]of t){let a=`${n}::${r}`,i=s.log.attachStorage(e),c=this._attachedTierDisposers.get(a);c||(c=[],this._attachedTierDisposers.set(a,c)),c.push(i)}return()=>{let n=this._attachedEventTiers.indexOf(e);n>=0&&this._attachedEventTiers.splice(n,1)}}_autoWireStreamStorage(e,n){if(this._attachedEventTiers.length===0)return;let t=this._attachedTierDisposers.get(e);t||(t=[],this._attachedTierDisposers.set(e,t));for(let r of this._attachedEventTiers)t.push(n.attachStorage(r))}_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 t=this._eventLogs.get(e);if(t)return t.node;let r=J([],{name:e,versioning:0,maxSize:this._retainedLimit});r.withLatest();let s=r.entries,a=j([s],([i])=>i,{name:e,describeKind:"state",meta:$("event",{event_name:e}),guard:ie,initial:s.cache});return this.add(a,{name:e}),this._keepaliveDisposers.push(z(a)),this._eventLogs.set(e,{log:r,node:a}),this._autoWireStreamStorage(e,r),a}_ensureAggregateStream(e,n){this._eventLogs.has(e)||this.event(e);let t=this._eventLogsByAggregate.get(e);t||(t=new Map,this._eventLogsByAggregate.set(e,t));let r=`${e}::${n}`;this._touchAggregate(r);let s=t.get(n);if(s)return s;let a=`${e}_${n.replace(/[^a-zA-Z0-9_-]/g,"_")}`,i=J([],{name:a,versioning:0,maxSize:this._retainedLimit});i.withLatest();let c=i.entries,h=j([c],([p])=>p,{name:a,describeKind:"state",meta:$("event_aggregate",{event_name:e,aggregate_id:n}),guard:ie,initial:c.cache}),l=a,m=0;for(;this.nameOf(this.resolveOptional(l)??h)===l&&(m+=1,l=`${a}_${m}`,this.resolveOptional(l)!==void 0););try{this.add(h,{name:l})}catch{}this._keepaliveDisposers.push(z(h));let u={log:i,node:h};return t.set(n,u),this._autoWireStreamStorage(`${e}::${n}`,i),this._enforceAggregateLru(),u}resolveOptional(e){try{return this.resolve(e)}catch{return}}_appendEvent(e,n,t){let r=this._eventLogs.get(e);if(r||(this.event(e),r=this._eventLogs.get(e)),r.node.status==="completed"||r.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${r.node.status}).`);let s,a;if(t?.aggregateId!==void 0){let l=`${e}::${t.aggregateId}`;s=(this._aggregateVersions.get(l)??0)+1,this._aggregateVersions.set(l,s),a=this._ensureAggregateStream(e,t.aggregateId)}let i=r.log.entries.v,c=this._freezeEventPayload?Z(n):n,h={type:e,payload:c,timestampNs:R(),seq:++this._seq,...t?.aggregateId!==void 0?{aggregateId:t.aggregateId}:{},...s!==void 0?{aggregateVersion:s}:{},...t?.correlationId!==void 0?{correlationId:t.correlationId}:{},...t?.causationId!==void 0?{causationId:t.causationId}:{},...t?.metadata!==void 0?{metadata:Object.freeze({...t.metadata})}:{},...t?.handlerVersion!==void 0?{handlerVersion:t.handlerVersion}:{},...i!=null?{v0:{id:i.id,version:i.version}}:{}};return r.log.append(h),a&&a.log.append(h),h}command(e,n){if(this._commandRegs.has(e))throw new B("command",e);let t=typeof n=="function"?{handler:n}:n,r=te(void 0,{name:e,describeKind:"state",meta:{...$("command",{command_name:e}),error:null},guard:le});if(this.add(r,{name:e}),this._commandRegs.set(e,{handler:t.handler,...t.emits!==void 0?{emits:t.emits}:{},...t.handlerVersion!==void 0?{handlerVersion:t.handlerVersion}:{}}),t.emits)for(let s of t.emits)this._eventLogs.has(s)||this.event(s);return r}dispatch(e,n,t){let r=this._commandRegs.get(e);if(!r)throw new H(e);if(t?.aggregateId!==void 0&&t.expectedAggregateVersion!==void 0&&r.emits!==void 0){let u=0;for(let p of r.emits){let _=this._aggregateVersions.get(`${p}::${t.aggregateId}`);_!==void 0&&_>u&&(u=_)}if(u!==t.expectedAggregateVersion)throw new K(t.aggregateId,t.expectedAggregateVersion,u)}let s=this.resolve(e),a=this._freezeCommandPayload?Z(n):n,i=[],c=R(),h=0,l,m=!1;try{Y(()=>{h=this._bumpDispatchSeq(),s.emit(a,{internal:!0});try{r.handler(a,{emit:(u,p)=>{if(r.emits!==void 0&&!r.emits.includes(u))throw new N(e,u,r.emits);i.push(u),this._appendEvent(u,p,{...t?.aggregateId!==void 0?{aggregateId:t.aggregateId}:{},...t?.correlationId!==void 0?{correlationId:t.correlationId}:{},...t?.causationId!==void 0?{causationId:t.causationId}:{},...t?.metadata!==void 0?{metadata:Object.freeze({...t.metadata})}:{},...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}}),s.meta.error.emit(null,{internal:!0}),this.dispatches.append({commandName:e,payload:a,outcome:"success",emittedEvents:[...i],t_ns:c,seq:h,...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}catch(u){throw l=u,m=!0,u}})}catch(u){if(m){s.meta.error.emit(l,{internal:!0});let p=l instanceof Error?l.name:typeof l,_=l instanceof O?l:new O(e,l);this.dispatches.append({commandName:e,payload:a,outcome:"failure",error:_,errorType:p,emittedEvents:[...i],t_ns:c,seq:h,...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}})}throw m?l:u}}projection(e){let{name:n,events:t,reducer:r,initial:s}=e,a=e.mode??"scan",i=e.freezeInputs??!0,c=e.snapshot,h=t.map(d=>(this._eventLogs.has(d)||this.event(d),this._eventLogs.get(d).node));function l(d){d.sort((g,v)=>g.timestampNs-v.timestampNs||g.seq-v.seq||(g.aggregateId??"").localeCompare(v.aggregateId??""))}function m(d){let g=[];for(let v of d)g.push(...v);return l(g),g}let u=h.map(d=>d.cache??[]),p=m(u),_=i?Object.freeze(p):p,C=0,y=s;a==="scan"&&p.length>0&&(y=r(s,_),C=p.length);let q=a==="replay"?r(s,_):y,V=c?.saveDebounceMs??1e3,A=c?.saveEvery??1e3,E,L=0;function F(d){if(c?.save){if(L+=1,L>=A){L=0,E!==void 0&&(clearTimeout(E),E=void 0);let g=c.save(d);g instanceof Promise&&g.catch(()=>{});return}E!==void 0&&clearTimeout(E),E=setTimeout(()=>{E=void 0,L=0;let g=c.save(d);g instanceof Promise&&g.catch(()=>{})},V)}}let S=j(h,d=>{let g=m(d),v;if(a==="replay"){let w=i?Object.freeze(g):g;v=r(s,w)}else{let w=g.slice(C);C=g.length;let f=i?Object.freeze(w):w;v=r(y,f),y=v}return F(v),v},{name:n,describeKind:"derived",meta:$("projection",{projection_name:n,source_events:t}),guard:ue,initial:q});return this.add(S,{name:n}),this._keepaliveDisposers.push(z(S)),this._keepaliveDisposers.push(()=>{E!==void 0&&(clearTimeout(E),E=void 0)}),this._projections.add(n),{node:S,rebuild:async d=>{try{let g=d?.pageSize??1e3,v=d?.fromTier??this._attachedEventTiers[0]?.[0],w=m(h.map(T=>T.cache??[])).length,f=s;if(c?.load){let T=await c.load();T!==void 0&&(f=T)}if(!v||!v.loadEntries){let T=m(h.map(I=>I.cache??[])),b=i?Object.freeze(T):T;f=r(f,b)}else{let T=new Set(t),b,I=!1;for(;!I;){let U=await v.loadEntries({cursor:b,pageSize:g}),W=[...U.entries].filter(ge=>T.has(ge.type));l(W);let de=i?Object.freeze(W):W;f=r(f,de),b=U.cursor,I=!b||U.entries.length===0}}if(a==="scan"){let T=m(h.map(I=>I.cache??[])),b=T.slice(w);if(b.length>0){let I=i?Object.freeze(b):b;f=r(f,I)}y=f,C=T.length}return S.emit(f,{internal:!0}),f}catch(g){throw new P(n,g)}},reset:async()=>{try{let d=s;if(c?.load){let f=await c.load();f!==void 0&&(d=f)}let g=m(h.map(f=>f.cache??[])),v=i?Object.freeze(g):g,w=r(d,v);return a==="scan"&&(y=w,C=g.length),S.emit(w,{internal:!0}),w}catch(d){throw new P(n,d)}}}}saga(e,n,t,r={}){let s=n.map(p=>(this._eventLogs.has(p)||this.event(p),this._eventLogs.get(p).node)),a=ae(this,`${e}_cursor`,n,0),i=M({name:`${e}_invocations`,retainedLimit:this._retainedLimit,graph:this}),c=r.aggregateId,h=r.errorPolicy??"advance",l=new Map;for(let p of n){let _=a[p];l.set(p,_.cache??0);let C=_.subscribe(y=>{for(let q of y)q[0]===X&&l.set(p,q[1])});this._keepaliveDisposers.push(C)}let m={},u=ee(s,(p,_)=>{let C=m.n.meta.error;for(let y=0;y<p.length;y++){let q=p[y];if(q==null||q.length===0)continue;let V=q.at(-1);if(!V)continue;let A=n[y],E=a[A],L=l.get(A)??0;if(V.length>L){let F=V.slice(L),S=L;for(let Q of F){let x=Q;if(c!==void 0&&x.aggregateId!==c){S+=1;continue}try{t(x),C.emit(null,{internal:!0}),i.append({eventType:A,outcome:"success",aggregateId:x.aggregateId,event:x,t_ns:R(),...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),S+=1}catch(d){if(C.emit(d,{internal:!0}),i.append({eventType:A,outcome:"failure",error:d,errorType:d instanceof Error?d.name:typeof d,aggregateId:x.aggregateId,event:x,t_ns:R(),...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),h==="hold")break;S+=1}}E.emit(S)}}},{name:e,describeKind:"effect",meta:{...$("saga",{saga_name:e,source_events:n}),error:null}});return m.n=u,this.add(u,{name:e}),this._keepaliveDisposers.push(z(u)),this._sagas.add(e),{node:u,invocations:i,audit:i,cursors:a}}};function fe(o,e){let n=new G(o,e),{factory:t,factoryArgs:r,...s}=e??{};return n.tagFactory("cqrs",re(s)),n}export{pe as a,he as b,ve as c,G as d,fe as e,me as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as f}from"./chunk-
|
|
1
|
+
import{i as f}from"./chunk-2BX4NB34.js";import{E as d}from"./chunk-LYCLF26R.js";import{b as S}from"./chunk-CK2E7BTU.js";import{b}from"./chunk-QYADASLV.js";var g={};b(g,{create:()=>v});var m=()=>!1;function v(l){let o=new f("zustand"),t=d(void 0,{name:"state",equals:m});o.add(t,{name:"state"});let r=()=>t.cache,n=(e,s)=>{let a=t.cache,i=typeof e=="function"?e(a):e;t.emit(s?i:{...a,...i})},c={getState:r,setState:n,getInitialState:()=>T,subscribe:e=>{let s=!0,a=t.cache;return t.subscribe(i=>{for(let[u,p]of i)if(u===S){if(s){s=!1;continue}e(p,a),a=p}})},destroy:o.destroy.bind(o)},T=l(n,r,c);return t.emit(T),Object.assign(o,c)}export{v as a,g as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as w,E as I,F as b,p as C}from"./chunk-LYCLF26R.js";import{a as S,b as h,c as A,d as x,i as T,j as p}from"./chunk-CK2E7BTU.js";function y(e,n,t){let u=new Set;for(let o of e.split(",")){let[r,i]=o.split("/"),s=i?Number.parseInt(i,10):1;if(Number.isNaN(s)||s<1)throw new Error(`Invalid cron step: ${o}`);let a,d;if(r==="*")a=n,d=t;else if(r.includes("-")){let[f,c]=r.split("-");a=Number.parseInt(f,10),d=Number.parseInt(c,10)}else a=Number.parseInt(r,10),d=a;if(Number.isNaN(a)||Number.isNaN(d))throw new Error(`Invalid cron field: ${e}`);if(a<n||d>t)throw new Error(`Cron field out of range: ${e} (${n}-${t})`);if(a>d)throw new Error(`Invalid cron range: ${a}-${d} in ${e}`);for(let f=a;f<=d;f+=s)u.add(f)}return u}function L(e){let n=e.trim().split(/\s+/);if(n.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${n.length}`);return{minutes:y(n[0],0,59),hours:y(n[1],0,23),daysOfMonth:y(n[2],1,31),months:y(n[3],1,12),daysOfWeek:y(n[4],0,6)}}function P(e,n){return e.minutes.has(n.getMinutes())&&e.hours.has(n.getHours())&&e.daysOfMonth.has(n.getDate())&&e.months.has(n.getMonth()+1)&&e.daysOfWeek.has(n.getDay())}function m(e){return{describeKind:"producer",...e}}function $(e){return/[\\^$+?.()|[\]{}]/.test(e)?`\\${e}`:e}function X(e){let n="^";for(let t=0;t<e.length;t+=1){let u=e[t];if(u==="*"){e[t+1]==="*"?(n+=".*",t+=1):n+="[^/]*";continue}n+=$(u)}return n+="$",new RegExp(n)}function Z(e,n){for(let t of n)if(t.test(e))return!0;return!1}function K(e,n){let t=w([e],(o,r)=>{let i=o[0];if(i==null||i.length===0){r.down([[x]]);return}for(let s of i)r.emit(s)},{describeKind:"derived",initial:e.cache}),u=t.subscribe.bind(t);return t.subscribe=(o,r)=>(n(o),u(o,r)),t}function ee(e,n){let{signal:t,period:u,...o}=n??{};return b(r=>{let i=!1,s=0,a,d,f=()=>{i=!0,a!==void 0&&clearTimeout(a),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",l)},c=()=>{i||(u!=null?(r.emit(s++),d=setInterval(()=>{i||r.emit(s++)},u)):(i=!0,t?.removeEventListener("abort",l),r.emit(s++),r.down([[T]])))},l=()=>{i||(f(),r.down([[p,t.reason]]))};if(t?.aborted){l();return}return a=setTimeout(c,e),t?.addEventListener("abort",l,{once:!0}),f},m(o))}function ne(e){let{signal:n,...t}=e??{};return b(u=>{let o=!1,r,i,s=!1,a=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,f=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,c=typeof document<"u"?document:void 0,l=()=>{r!==void 0&&f&&f(r),i!==void 0&&clearTimeout(i),r=void 0,i=void 0},v=()=>{o=!0,l(),s&&(n?.removeEventListener("abort",N),s=!1),a&&c&&(c.removeEventListener("visibilitychange",k),a=!1)},N=()=>{o||(v(),u.down([[p,n.reason]]))},O=_=>{o||(u.emit(_),g())},g=()=>{o||(d&&(!c||c.visibilityState!=="hidden")?r=d(O):i=setTimeout(()=>O(performance.now()),16))},k=()=>{o||(l(),g())};return n?.aborted?(N(),v):(n?.addEventListener("abort",N,{once:!0}),s=n!==void 0,c&&d&&(c.addEventListener("visibilitychange",k),a=!0),g(),v)},m(t))}function te(e,n){let t=L(e),{tickMs:u,output:o,...r}=n??{},i=u??6e4,s=o==="date";return b(a=>{let d=-1,f=()=>{let l=new Date,v=l.getFullYear()*1e8+(l.getMonth()+1)*1e6+l.getDate()*1e4+l.getHours()*100+l.getMinutes();v!==d&&P(t,l)&&(d=v,a.emit(s?l:C()))};f();let c=setInterval(f,i);return()=>clearInterval(c)},{...m(r),name:r.name??`cron:${e}`})}function re(e,n,t){let{capture:u,passive:o,once:r,...i}=t??{};return b(s=>{let a=f=>{s.emit(f)},d={capture:u,passive:o,once:r};return e.addEventListener(n,a,d),()=>e.removeEventListener(n,a,d)},m(i))}function D(e,n){return b(t=>{let u=!1;try{for(let o of e){if(u)return;t.emit(o)}u||t.down([[T]])}catch(o){u||t.down([[p,o]])}return()=>{u=!0}},m(n))}function W(e){return e!=null&&typeof e.then=="function"}function q(e,n){let{signal:t,...u}=n??{};return b(o=>{let r=!1,i=()=>{r||(r=!0,o.down([[p,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(e).then(s=>{r||(r=!0,t?.removeEventListener("abort",i),o.emit(s),o.down([[T]]))},s=>{r||(r=!0,t?.removeEventListener("abort",i),o.down([[p,s]]))}),()=>{r=!0,t?.removeEventListener("abort",i)}},m(u))}function H(e,n){let{signal:t,...u}=n??{};return b(o=>{let r=new AbortController,i=()=>r.abort(t?.reason);t?.aborted?r.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let s=t??r.signal,a=!1,d=e[Symbol.asyncIterator](),f=()=>{a||s.aborted||Promise.resolve(d.next()).then(c=>{if(!(a||s.aborted)){if(c.done){o.down([[T]]);return}o.emit(c.value),f()}},c=>{!a&&!s.aborted&&o.down([[p,c]])})};return f(),()=>{a=!0,t?.removeEventListener("abort",i),r.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},m(u))}function U(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function V(e,n){if(U(e))return e;if(W(e))return q(e,n);if(e!=null){let t=e;if(typeof t[Symbol.asyncIterator]=="function")return H(e,n);if(typeof t[Symbol.iterator]=="function")return D(e,n)}return B(e)}function B(...e){return D(e,void 0)}function oe(e){return b(n=>{n.down([[T]])},m(e))}function ie(e){return b(()=>{},m(e))}function se(e,n){return b(t=>{t.down([[p,e]])},m(n))}function ue(e,n){let{signal:t,...u}=n??{},o=m(u),r=o.resubscribable===void 0?{...o,resubscribable:!0}:o;return b(i=>{let s,a=!1;try{let d=e();s=V(d,n).subscribe(c=>{if(!a)for(let l of c){let v=l[0];if(v!==S)if(v===h)i.emit(l[1]);else if(v===T){a=!0,i.down([[T]]);break}else if(v===p){a=!0,i.down([[p,l[1]]]);break}else i.down([l])}})}catch(d){let f=d===void 0?new Error("defer: thunk threw undefined"):d;i.down([[p,f]])}return()=>{a=!0,s?.()}},r)}function ae(e,n,t){return w([e],(o,r)=>{let i=o[0];if(i!=null&&i.length>0)for(let s of i)n(s)},{describeKind:"effect",...t}).subscribe(()=>{})}function de(e,n){return w([e],(t,u,o)=>{o.store.buf||(o.store.buf=[]);let r=o.store.buf,i=t[0];if(i!=null&&i.length>0)for(let s of i)r.push(s);if(o.terminalDeps[0]===!0){u.emit([...r]),u.down([[T]]);return}(i==null||i.length===0)&&u.down([[x]])},{describeKind:"derived",completeWhenDepsComplete:!1,...n})}function fe(e,n){return b(t=>e.subscribe(u=>{t.down(u)}),{...m(n),initial:e.cache})}function F(e,n,t){if(n<1)throw new RangeError("replay expects bufferSize >= 1");let u=[],o=b(r=>e.subscribe(i=>{for(let s of i)s[0]===h&&(u.push(s[1]),u.length>n&&u.shift());r.down(i)}),{...m(t),initial:e.cache});return K(o,r=>{for(let i of u)r([[h,i]])})}function ce(e,n){return F(e,1,n)}function le(e){return new Promise((n,t)=>{let u=!1,o=!1,r;r=e.subscribe(i=>{for(let s of i){if(u)return;if(s[0]===h){u=!0,n(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===p){u=!0,t(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===T){u=!0,t(new Error("completed without DATA")),r?(r(),r=void 0):o=!0;return}}}),o&&(r?.(),r=void 0)})}function R(e,n,t){return new Promise((u,o)=>{let r=!1,i=!1,s,a=t?.skipCurrent===!0;s=e.subscribe(d=>{for(let f of d){if(r)return;if(!(a&&f[0]===h)){if(f[0]===h){let c=f[1];if(n(c)){r=!0,u(c),s?(s(),s=void 0):i=!0;return}}if(f[0]===p){r=!0,o(f[1]),s?(s(),s=void 0):i=!0;return}if(f[0]===T){r=!0,o(new Error("completed without matching value")),s?(s(),s=void 0):i=!0;return}}}}),a=!1,i&&(s?.(),s=void 0)})}var E,M;async function pe(e,n){let t=n?.predicate??(r=>r!=null),u=n?.skipCurrent;if(n?.timeoutMs==null||n.timeoutMs<=0)return await R(e,t,{skipCurrent:u});if(E===void 0){let[r,i]=await Promise.all([import("./resilience-
|
|
1
|
+
import{D as w,E as I,F as b,p as C}from"./chunk-LYCLF26R.js";import{a as S,b as h,c as A,d as x,i as T,j as p}from"./chunk-CK2E7BTU.js";function y(e,n,t){let u=new Set;for(let o of e.split(",")){let[r,i]=o.split("/"),s=i?Number.parseInt(i,10):1;if(Number.isNaN(s)||s<1)throw new Error(`Invalid cron step: ${o}`);let a,d;if(r==="*")a=n,d=t;else if(r.includes("-")){let[f,c]=r.split("-");a=Number.parseInt(f,10),d=Number.parseInt(c,10)}else a=Number.parseInt(r,10),d=a;if(Number.isNaN(a)||Number.isNaN(d))throw new Error(`Invalid cron field: ${e}`);if(a<n||d>t)throw new Error(`Cron field out of range: ${e} (${n}-${t})`);if(a>d)throw new Error(`Invalid cron range: ${a}-${d} in ${e}`);for(let f=a;f<=d;f+=s)u.add(f)}return u}function L(e){let n=e.trim().split(/\s+/);if(n.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${n.length}`);return{minutes:y(n[0],0,59),hours:y(n[1],0,23),daysOfMonth:y(n[2],1,31),months:y(n[3],1,12),daysOfWeek:y(n[4],0,6)}}function P(e,n){return e.minutes.has(n.getMinutes())&&e.hours.has(n.getHours())&&e.daysOfMonth.has(n.getDate())&&e.months.has(n.getMonth()+1)&&e.daysOfWeek.has(n.getDay())}function m(e){return{describeKind:"producer",...e}}function $(e){return/[\\^$+?.()|[\]{}]/.test(e)?`\\${e}`:e}function X(e){let n="^";for(let t=0;t<e.length;t+=1){let u=e[t];if(u==="*"){e[t+1]==="*"?(n+=".*",t+=1):n+="[^/]*";continue}n+=$(u)}return n+="$",new RegExp(n)}function Z(e,n){for(let t of n)if(t.test(e))return!0;return!1}function K(e,n){let t=w([e],(o,r)=>{let i=o[0];if(i==null||i.length===0){r.down([[x]]);return}for(let s of i)r.emit(s)},{describeKind:"derived",initial:e.cache}),u=t.subscribe.bind(t);return t.subscribe=(o,r)=>(n(o),u(o,r)),t}function ee(e,n){let{signal:t,period:u,...o}=n??{};return b(r=>{let i=!1,s=0,a,d,f=()=>{i=!0,a!==void 0&&clearTimeout(a),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",l)},c=()=>{i||(u!=null?(r.emit(s++),d=setInterval(()=>{i||r.emit(s++)},u)):(i=!0,t?.removeEventListener("abort",l),r.emit(s++),r.down([[T]])))},l=()=>{i||(f(),r.down([[p,t.reason]]))};if(t?.aborted){l();return}return a=setTimeout(c,e),t?.addEventListener("abort",l,{once:!0}),f},m(o))}function ne(e){let{signal:n,...t}=e??{};return b(u=>{let o=!1,r,i,s=!1,a=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,f=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,c=typeof document<"u"?document:void 0,l=()=>{r!==void 0&&f&&f(r),i!==void 0&&clearTimeout(i),r=void 0,i=void 0},v=()=>{o=!0,l(),s&&(n?.removeEventListener("abort",N),s=!1),a&&c&&(c.removeEventListener("visibilitychange",k),a=!1)},N=()=>{o||(v(),u.down([[p,n.reason]]))},O=_=>{o||(u.emit(_),g())},g=()=>{o||(d&&(!c||c.visibilityState!=="hidden")?r=d(O):i=setTimeout(()=>O(performance.now()),16))},k=()=>{o||(l(),g())};return n?.aborted?(N(),v):(n?.addEventListener("abort",N,{once:!0}),s=n!==void 0,c&&d&&(c.addEventListener("visibilitychange",k),a=!0),g(),v)},m(t))}function te(e,n){let t=L(e),{tickMs:u,output:o,...r}=n??{},i=u??6e4,s=o==="date";return b(a=>{let d=-1,f=()=>{let l=new Date,v=l.getFullYear()*1e8+(l.getMonth()+1)*1e6+l.getDate()*1e4+l.getHours()*100+l.getMinutes();v!==d&&P(t,l)&&(d=v,a.emit(s?l:C()))};f();let c=setInterval(f,i);return()=>clearInterval(c)},{...m(r),name:r.name??`cron:${e}`})}function re(e,n,t){let{capture:u,passive:o,once:r,...i}=t??{};return b(s=>{let a=f=>{s.emit(f)},d={capture:u,passive:o,once:r};return e.addEventListener(n,a,d),()=>e.removeEventListener(n,a,d)},m(i))}function D(e,n){return b(t=>{let u=!1;try{for(let o of e){if(u)return;t.emit(o)}u||t.down([[T]])}catch(o){u||t.down([[p,o]])}return()=>{u=!0}},m(n))}function W(e){return e!=null&&typeof e.then=="function"}function q(e,n){let{signal:t,...u}=n??{};return b(o=>{let r=!1,i=()=>{r||(r=!0,o.down([[p,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(e).then(s=>{r||(r=!0,t?.removeEventListener("abort",i),o.emit(s),o.down([[T]]))},s=>{r||(r=!0,t?.removeEventListener("abort",i),o.down([[p,s]]))}),()=>{r=!0,t?.removeEventListener("abort",i)}},m(u))}function H(e,n){let{signal:t,...u}=n??{};return b(o=>{let r=new AbortController,i=()=>r.abort(t?.reason);t?.aborted?r.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let s=t??r.signal,a=!1,d=e[Symbol.asyncIterator](),f=()=>{a||s.aborted||Promise.resolve(d.next()).then(c=>{if(!(a||s.aborted)){if(c.done){o.down([[T]]);return}o.emit(c.value),f()}},c=>{!a&&!s.aborted&&o.down([[p,c]])})};return f(),()=>{a=!0,t?.removeEventListener("abort",i),r.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},m(u))}function U(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function V(e,n){if(U(e))return e;if(W(e))return q(e,n);if(e!=null){let t=e;if(typeof t[Symbol.asyncIterator]=="function")return H(e,n);if(typeof t[Symbol.iterator]=="function")return D(e,n)}return B(e)}function B(...e){return D(e,void 0)}function oe(e){return b(n=>{n.down([[T]])},m(e))}function ie(e){return b(()=>{},m(e))}function se(e,n){return b(t=>{t.down([[p,e]])},m(n))}function ue(e,n){let{signal:t,...u}=n??{},o=m(u),r=o.resubscribable===void 0?{...o,resubscribable:!0}:o;return b(i=>{let s,a=!1;try{let d=e();s=V(d,n).subscribe(c=>{if(!a)for(let l of c){let v=l[0];if(v!==S)if(v===h)i.emit(l[1]);else if(v===T){a=!0,i.down([[T]]);break}else if(v===p){a=!0,i.down([[p,l[1]]]);break}else i.down([l])}})}catch(d){let f=d===void 0?new Error("defer: thunk threw undefined"):d;i.down([[p,f]])}return()=>{a=!0,s?.()}},r)}function ae(e,n,t){return w([e],(o,r)=>{let i=o[0];if(i!=null&&i.length>0)for(let s of i)n(s)},{describeKind:"effect",...t}).subscribe(()=>{})}function de(e,n){return w([e],(t,u,o)=>{o.store.buf||(o.store.buf=[]);let r=o.store.buf,i=t[0];if(i!=null&&i.length>0)for(let s of i)r.push(s);if(o.terminalDeps[0]===!0){u.emit([...r]),u.down([[T]]);return}(i==null||i.length===0)&&u.down([[x]])},{describeKind:"derived",completeWhenDepsComplete:!1,...n})}function fe(e,n){return b(t=>e.subscribe(u=>{t.down(u)}),{...m(n),initial:e.cache})}function F(e,n,t){if(n<1)throw new RangeError("replay expects bufferSize >= 1");let u=[],o=b(r=>e.subscribe(i=>{for(let s of i)s[0]===h&&(u.push(s[1]),u.length>n&&u.shift());r.down(i)}),{...m(t),initial:e.cache});return K(o,r=>{for(let i of u)r([[h,i]])})}function ce(e,n){return F(e,1,n)}function le(e){return new Promise((n,t)=>{let u=!1,o=!1,r;r=e.subscribe(i=>{for(let s of i){if(u)return;if(s[0]===h){u=!0,n(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===p){u=!0,t(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===T){u=!0,t(new Error("completed without DATA")),r?(r(),r=void 0):o=!0;return}}}),o&&(r?.(),r=void 0)})}function R(e,n,t){return new Promise((u,o)=>{let r=!1,i=!1,s,a=t?.skipCurrent===!0;s=e.subscribe(d=>{for(let f of d){if(r)return;if(!(a&&f[0]===h)){if(f[0]===h){let c=f[1];if(n(c)){r=!0,u(c),s?(s(),s=void 0):i=!0;return}}if(f[0]===p){r=!0,o(f[1]),s?(s(),s=void 0):i=!0;return}if(f[0]===T){r=!0,o(new Error("completed without matching value")),s?(s(),s=void 0):i=!0;return}}}}),a=!1,i&&(s?.(),s=void 0)})}var E,M;async function pe(e,n){let t=n?.predicate??(r=>r!=null),u=n?.skipCurrent;if(n?.timeoutMs==null||n.timeoutMs<=0)return await R(e,t,{skipCurrent:u});if(E===void 0){let[r,i]=await Promise.all([import("./resilience-S33JV6XC.js"),import("./backoff-HPZMEZNF.js")]);E=r.timeout,M=i.NS_PER_MS}let o=E(e,n.timeoutMs*M);return await R(o,t,{skipCurrent:u})}function be(e,n){let t=new AbortController,u=n?.reason??new Error("cancelled via nodeSignal"),o,r=!1,i=()=>{o?(o(),o=void 0):r=!0};return o=e.subscribe(s=>{if(!t.signal.aborted)for(let a of s){if(a[0]===h&&a[1]===!0){t.abort(u),i();return}if(a[0]===p){t.abort(a[1]),i();return}if(a[0]===T){i();return}}}),r&&(o?.(),o=void 0),{signal:t.signal,dispose:()=>{o&&(o(),o=void 0)}}}var me=F;function Te(e){return e.subscribe(()=>{})}function ve(e){let n=I(0);return{node:n,increment(){let t=n.cache??0;return t>=e?!1:(n.down([[A],[h,t+1]]),!0)},get(){return n.cache??0},atCap(){return(n.cache??0)>=e}}}export{L as a,P as b,$ as c,X as d,Z as e,ee as f,ne as g,te as h,re as i,D as j,q as k,H as l,V as m,B as n,oe as o,ie as p,se as q,ue as r,ae as s,de as t,fe as u,F as v,ce as w,le as x,R as y,pe as z,be as A,me as B,Te as C,ve as D};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as V,b as N,c as _,d as j,f as L,g as M}from"./chunk-3G5U5QNE.js";import{b as D,c as x,d as $,e as R,f as A,g as S,h as
|
|
1
|
+
import{a as V,b as N,c as _,d as j,f as L,g as M}from"./chunk-3G5U5QNE.js";import{b as D,c as x,d as $,e as R,f as A,g as S,h as T,i as y,j as F,k as P}from"./chunk-2BX4NB34.js";import{a as m,b as g,c as v,d as O,e as k,f as E,g as G,h as C}from"./chunk-LYCLF26R.js";import{b as u}from"./chunk-CK2E7BTU.js";import{b as W}from"./chunk-QYADASLV.js";var K={};W(K,{ENVELOPE_VERSION:()=>O,GRAPH_META_SEGMENT:()=>S,Graph:()=>y,JsonCodec:()=>m,SIZEOF_OVERHEAD:()=>x,SIZEOF_SYMBOL:()=>$,SNAPSHOT_VERSION:()=>T,createDagCborCodec:()=>g,createDagCborZstdCodec:()=>v,decodeEnvelope:()=>E,diffForWAL:()=>F,encodeEnvelope:()=>k,explainPath:()=>D,graphProfile:()=>A,reachable:()=>P,registerBuiltinCodecs:()=>G,replayWAL:()=>C,sizeof:()=>R,validateGraphObservability:()=>I,watchTopologyTree:()=>w});function w(s,n){let o=new Map,d=(i,p)=>{if(o.has(i))return;let c={off:()=>{},prefix:p};o.set(i,c);let f=i.topology.subscribe(l=>{for(let r of l){if(r[0]!==u)continue;let e=r[1];if(n(e,i,p),e.kind==="added"&&e.nodeKind==="mount"){let t=i._mounts.get(e.name);if(t instanceof y){let a=`${p}${e.name}::`;d(t,a)}}else if(e.kind==="removed"&&e.nodeKind==="mount"){let t=`${p}${e.name}::`;for(let[a,h]of Array.from(o.entries()))a!==s&&h.prefix.startsWith(t)&&(h.off(),o.delete(a))}}});c.off=f;for(let[l,r]of i._mounts)if(r instanceof y){let e=`${p}${l}::`;d(r,e)}};return d(s,""),()=>{for(let i of o.values())i.off();o.clear()}}var H={json:s=>_(s),pretty:s=>M(s),mermaid:s=>j(s),"mermaid-url":s=>L(s),d2:s=>N(s),ascii:s=>V(s)};function I(s,n={}){let o=[],d=n.requireFound??!0;if(n.skipDescribe!==!0)try{let r=s.describe(),e=new Set(Object.keys(r.nodes)),t=[];for(let[a,h]of Object.entries(r.nodes))for(let b of h.deps)b!==""&&!e.has(b)&&t.push(`${a} \u2192 ${b}`);for(let a of r.edges)e.has(a.from)||t.push(`edge.from: ${a.from}`),e.has(a.to)||t.push(`edge.to: ${a.to}`);t.length>0?o.push({kind:"describe",ok:!1,reason:`describe() has ${t.length} dangling pointer(s); nodes \u2289 deps`,danglingDeps:t}):o.push({kind:"describe",ok:!0,nodeCount:e.size,edgeCount:r.edges.length})}catch(r){o.push({kind:"describe",ok:!1,reason:`describe() threw: ${r instanceof Error?r.message:String(r)}`})}if((n.formats?.length??0)>0){let r=s.describe();for(let e of n.formats)try{let t=H[e](r);typeof t!="string"||t.length===0?o.push({kind:"describe-format",ok:!1,format:e,reason:`${e} renderer returned empty or non-string output`}):o.push({kind:"describe-format",ok:!0,format:e,length:t.length})}catch(t){o.push({kind:"describe-format",ok:!1,format:e,reason:t instanceof Error?t.message:String(t)})}}for(let r of n.paths??[])try{s.resolve(r),o.push({kind:"observe",ok:!0,path:r})}catch(e){o.push({kind:"observe",ok:!1,path:r,reason:e instanceof Error?e.message:String(e)})}for(let[r,e]of n.pairs??[])try{let t=s.explain(r,e);d&&t.found===!1?o.push({kind:"explain",ok:!1,from:r,to:e,reason:`explain(${r} \u2192 ${e}) found no path${t.reason?`: ${t.reason}`:""}`}):o.push({kind:"explain",ok:!0,from:r,to:e,found:t.found,steps:t.steps.length})}catch(t){o.push({kind:"explain",ok:!1,from:r,to:e,reason:t instanceof Error?t.message:String(t)})}let i=o.filter(r=>!r.ok),p=i.length===0,c=n.paths?.length??0,f=n.pairs?.length??0,l=n.formats?.length??0;return{ok:p,checks:o,failures:i,summary(){let r=[n.skipDescribe===!0?null:"describe",l>0?`${l} format${l===1?"":"s"}`:null,c>0?`${c} observe path${c===1?"":"s"}`:null,f>0?`${f} explain pair${f===1?"":"s"}`:null].filter(t=>t!=null),e=r.length>0?r.join(", "):"describe-only";return p?`validateGraphObservability: OK (${e})`:`validateGraphObservability: ${i.length} failure(s) across ${e}`}}}export{w as a,I as b,K as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as B}from"./chunk-4VVTGLXJ.js";import{c as h}from"./chunk-35JTVPOX.js";import{m as k}from"./chunk-IA7DUNGB.js";import{D as N,F as w,G as P,o as U}from"./chunk-LYCLF26R.js";import{a as A,b as p,c as W,d as m,i as a,j as b}from"./chunk-CK2E7BTU.js";function c(d){return{describeKind:"derived",...d}}function S(d){return{describeKind:"derived",partial:!0,...d}}function Z(d,i,s){return N([d],(t,e)=>{let n=t[0];if(n==null||n.length===0){e.down([[m]]);return}for(let o of n)e.emit(i(o))},{...c(s),meta:{...h("map"),...s?.meta??{}}})}function V(d,i,s){return N([d],(t,e)=>{let n=t[0];if(n==null||n.length===0){e.down([[m]]);return}let o=!1;for(let r of n)i(r)&&(e.emit(r),o=!0);o||e.down([[m]])},{...c(s),meta:{...h("filter"),...s?.meta??{}}})}function $(d,i,s,t){return N([d],(e,n,o)=>{"acc"in o.store||(o.store.acc=s);let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let u of r)o.store.acc=i(o.store.acc,u),n.emit(o.store.acc)},{...c(t),initial:s,resetOnTeardown:!0,meta:{...h("scan",{initial:s}),...t?.meta??{}}})}function ee(d,i,s,t){return N([d],(e,n,o)=>{if("acc"in o.store||(o.store.acc=s),o.terminalDeps[0]===!0){n.emit(o.store.acc),n.down([[a]]);return}let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let u of r)o.store.acc=i(o.store.acc,u)},{...c(t),completeWhenDepsComplete:!1,meta:{...h("reduce",{initial:s}),...t?.meta??{}}})}function C(d,i,s){return i<=0?N([d],(t,e,n)=>{n.store.completed||(n.store.completed=!0,e.down([[a]]))},{...c(s),completeWhenDepsComplete:!1,meta:{...h("take",{count:i}),...s?.meta??{}}}):N([d],(t,e,n)=>{if("taken"in n.store||(n.store.taken=0),n.store.done){e.down([[m]]);return}if(n.terminalDeps[0]===!0){n.store.done=!0,e.down([[a]]);return}let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}for(let r of o)if(n.store.taken++,e.emit(r),n.store.taken>=i){n.store.done=!0,e.down([[a]]);return}},{...c(s),completeWhenDepsComplete:!1,meta:{...h("take",{count:i}),...s?.meta??{}}})}function K(d,i,s){return N([d],(t,e,n)=>{"skipped"in n.store||(n.store.skipped=0);let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}let r=!1;for(let u of o)n.store.skipped++,n.store.skipped<=i||(e.emit(u),r=!0);r||e.down([[m]])},c(s))}function ne(d,i,s){return N([d],(t,e,n)=>{if(n.store.done){e.down([[m]]);return}let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}for(let r of o){if(!i(r)){n.store.done=!0,e.down([[a]]);return}e.emit(r)}},{...c(s),completeWhenDepsComplete:!1})}function te(d,i,s){let t=s?.predicate??(o=>o[0]===p),{predicate:e,...n}=s??{};return w(o=>{let r=!1,u=d.subscribe(l=>{if(!r)for(let T of l){if(r)return;T[0]===p?o.emit(T[1]):(T[0]===a||T[0]===b)&&(r=!0,o.down([T]))}}),f=i.subscribe(l=>{if(!r)for(let T of l){if(r)return;if(t(T)){r=!0,o.down([[a]]);return}}});return()=>{u(),f()}},c(n))}function oe(d,i){return C(d,1,i)}function re(d,i){let{defaultValue:s,...t}=i??{},e=i!=null&&Object.hasOwn(i,"defaultValue");return N([d],(n,o,r)=>{if(r.terminalDeps[0]===!0){r.store.has?o.emit(r.store.latest):e&&o.emit(s),o.down([[a]]);return}let u=n[0];if(u==null||u.length===0){o.down([[m]]);return}r.store.latest=u.at(-1),r.store.has=!0},{...c(t),completeWhenDepsComplete:!1})}function se(d,i,s){return C(V(d,i,s),1,s)}function ie(d,i,s){return C(K(d,i,s),1,s)}function ue(d,i,s){if(typeof i=="function")return N([d],(e,n)=>{let o=e[0];if(o==null||o.length===0){n.down([[m]]);return}for(let r of o)i(r),n.emit(r)},{...c(s),meta:{...h("tap"),...s?.meta??{}}});let t=i;return N([d],(e,n,o)=>{if(o.terminalDeps[0]!==void 0){o.terminalDeps[0]===!0?(t.complete?.(),n.down([[a]])):(t.error?.(o.terminalDeps[0]),n.down([[b,o.terminalDeps[0]]]));return}let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let u of r)t.data?.(u),n.emit(u)},{...c(s),completeWhenDepsComplete:!1,meta:{...h("tap"),...s?.meta??{}}})}function q(d,i,s){let t=s?.where??(n=>n!=null),e=!1;return N([d],(n,o)=>{let r=n[0];if(r==null||r.length===0){o.down([[m]]);return}for(let u of r)!e&&t(u)&&(e=!0,i(u)),o.emit(u)},c(s))}var fe=q;function de(d,i=Object.is,s){return N([d],(t,e,n)=>{let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}let r=!1;for(let u of o)n.store.hasPrev&&i(n.store.prev,u)||(n.store.prev=u,n.store.hasPrev=!0,e.emit(u),r=!0);r||e.down([[m]])},{...c(s),meta:{...h("distinctUntilChanged"),...s?.meta??{}}})}function le(d,i){return N([d],(s,t,e)=>{let n=s[0];if(n==null||n.length===0){t.down([[m]]);return}let o=!1;for(let r of n)if(!e.store.hasPrev)e.store.prev=r,e.store.hasPrev=!0;else{let u=[e.store.prev,r];e.store.prev=r,t.emit(u),o=!0}o||t.down([[m]])},c(i))}function F(...d){let i=[...d];return P(i,s=>s,{...c(),equals:(s,t)=>{if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(!Object.is(s[e],t[e]))return!1;return!0}})}function ae(d,i,s){return N([d,i],(t,e,n)=>{let o=t[0],r=t[1],u=r!=null&&r.length>0?r.at(-1):n.prevData[1];if(o!=null&&o.length>0){if(!(r!=null&&r.length>0)&&n.prevData[1]===void 0){e.down([[m]]);return}for(let f of o)e.emit([f,u])}else e.down([[m]])},{...S(s),meta:{...h("withLatestFrom"),...s?.meta??{}}})}function ce(...d){return d.length===0?w(i=>{i.down([[a]])},{...c(),meta:{...h("merge")}}):w(i=>{let s=d.length,t=0,e=[];for(let n of d){let o=n.subscribe(r=>{for(let u of r)u[0]===p?i.emit(u[1]):u[0]===a?(t+=1,t>=s&&i.down([[a]])):u[0]===b&&i.down([u])});e.push(o)}return()=>{for(let n of e)n()}},{...c(),meta:{...h("merge")}})}function Te(...d){let i=d.length;return i===0?w(s=>{s.emit([]),s.down([[a]])},c()):w(s=>{let t=Array.from({length:i},()=>[]),e=i;function n(){for(;t.every(r=>r.length>0);){let r=t.map(u=>u.shift());s.emit(r)}}let o=[];for(let r=0;r<i;r++){let u=r,f=d[r].subscribe(l=>{for(let T of l)T[0]===p?(t[u].push(T[1]),n()):T[0]===a?(e-=1,(e===0||t[u].length===0)&&s.down([[a]])):T[0]===b&&s.down([T])});o.push(f)}return()=>{for(let r of o)r()}},c())}function pe(d,i,s){return w(t=>{let e=0,n=[],o,r;return r=i.subscribe(u=>{for(let f of u)e===0?f[0]===p?n.push(f[1]):f[0]===b&&t.down([f]):f[0]===p?t.emit(f[1]):(f[0]===a||f[0]===b)&&t.down([f])}),o=d.subscribe(u=>{for(let f of u)if(e===0)if(f[0]===p)t.emit(f[1]);else if(f[0]===a){e=1;for(let l of n)t.emit(l);n.length=0}else f[0]===b&&t.down([f])}),()=>{o?.(),r?.()}},c(s))}function me(...d){return d.length===0?w(i=>{i.down([[a]])},c()):d.length===1?N([d[0]],(i,s)=>{let t=i[0];if(t==null||t.length===0){s.down([[m]]);return}for(let e of t)s.emit(e)},c()):w(i=>{let s=null,t=[];for(let e=0;e<d.length;e++){let n=e,o=d[e].subscribe(r=>{for(let u of r){if(s!==null&&n!==s)return;u[0]===p?(s===null&&(s=n),i.emit(u[1])):(u[0]===a||u[0]===b)&&(s===null||n===s)&&i.down([u])}});t.push(o)}return()=>{for(let e of t)e()}},c())}function I(d,i,s){let t,e=!1,n=()=>{e||(e=!0,s())};return t=d.subscribe(o=>{let r=!1,u=!1;for(let f of o)f[0]!==A&&(f[0]===p?i.emit(f[1]):f[0]===a?r=!0:f[0]===b?(u=!0,i.down([f])):(f[0]===W||f[0]===m)&&i.down([f]));u?(t?.(),t=void 0,n()):r&&n()}),()=>{t?.(),t=void 0}}function be(d,i,s){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){n();return}if(u.terminalDeps[0]===!0){e=!0,t||r.down([[a]]);return}let f=o[0];if(!(f==null||f.length===0))return n(),t=I(k(i(f[f.length-1])),r,()=>{n(),e&&r.down([[a]])}),{deactivate:()=>{n(),e=!1}}},{...c(s),completeWhenDepsComplete:!1,meta:{...h("switchMap"),...s?.meta??{}}})}function we(d,i,s){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){n();return}if(u.terminalDeps[0]===!0){e=!0,t||r.down([[a]]);return}let f=o[0];if(!(f==null||f.length===0))return t===void 0?t=I(k(i(f[0])),r,()=>{n(),e&&r.down([[a]])}):r.down([[m]]),{deactivate:()=>{n(),e=!1}}},{...c(s),completeWhenDepsComplete:!1})}function Ne(d,i,s){let{maxBuffer:t,...e}=s??{},n=[],o,r=!1,u;function f(){o?.(),o=void 0}function l(){if(!u||o!==void 0)return;if(n.length===0){r&&u.down([[a]]);return}let v=n.shift();o=I(k(i(v)),u,()=>{f(),l()})}function T(v){t&&t>0&&n.length>=t&&n.shift(),n.push(v),l()}return N([d],(v,x,E)=>{if(u=x,E.terminalDeps[0]!=null&&E.terminalDeps[0]!==!0){f(),n.length=0;return}if(E.terminalDeps[0]===!0){r=!0,l();return}let R=v[0];if(!(R==null||R.length===0)){for(let g of R)T(g);return{deactivate:()=>{f(),n.length=0,r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}function L(d,i,s){let{concurrent:t,...e}=s??{},n=t!=null&&t>0?t:Number.POSITIVE_INFINITY,o=0,r=!1,u=new Set,f=[],l;function T(){r&&o===0&&f.length===0&&l&&l.down([[a]])}function v(g){if(!l)return;o++;let O;O=I(k(i(g)),l,()=>{O&&u.delete(O),o--,x(),T()}),u.add(O)}function x(){for(;f.length>0&&o<n;)v(f.shift())}function E(g){o<n?v(g):f.push(g)}function R(){for(let g of u)g();u.clear(),o=0,f.length=0}return N([d],(g,O,y)=>{if(l=O,y.terminalDeps[0]!=null&&y.terminalDeps[0]!==!0){R();return}if(y.terminalDeps[0]===!0){r=!0,T();return}let D=g[0];if(!(D==null||D.length===0)){for(let M of D)E(M);return{deactivate:()=>{R(),r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}var he=L;function ve(d,i,s){return w(t=>{let e=new Set;function n(){for(let r of e)clearTimeout(r);e.clear()}let o=d.subscribe(r=>{for(let u of r)if(u[0]===p){let f=setTimeout(()=>{e.delete(f),t.emit(u[1])},i);e.add(f)}else if(u[0]===a){let f=setTimeout(()=>{e.delete(f),t.down([[a]])},i);e.add(f)}else u[0]===b&&(n(),t.down([u]))});return()=>{o(),n()}},c(s))}function _(d,i,s){return w(t=>{let e,n;function o(){e!==void 0&&(clearTimeout(e),e=void 0)}let r=d.subscribe(u=>{for(let f of u)f[0]===p?(o(),n=f[1],e=setTimeout(()=>{e=void 0,t.emit(n)},i)):f[0]===a?(e!==void 0&&(o(),t.emit(n)),t.down([[a]])):f[0]===b&&(o(),t.down([f]))});return()=>{r(),o()}},{...c(s),meta:{...h("debounce",{ms:i}),...s?.meta??{}}})}function j(d,i,s){let{leading:t,trailing:e,...n}=s??{},o=t!==!1,r=e===!0,u=i*1e6;return w(f=>{let l,T=-1/0,v,x=!1;function E(){l!==void 0&&(clearTimeout(l),l=void 0)}let R=d.subscribe(g=>{for(let O of g)if(O[0]===p){let y=O[1],D=U();if(o&&D-T>=u)T=D,f.emit(y),E(),r&&(l=setTimeout(()=>{l=void 0,x&&(T=U(),f.emit(v),x=!1)},i));else if(r&&(v=y,x=!0,l===void 0)){let M=(D-T)/1e6;l=setTimeout(()=>{l=void 0,x&&(T=U(),f.emit(v),x=!1)},Math.max(0,i-M))}}else(O[0]===a||O[0]===b)&&(E(),f.down([O]))});return()=>{R(),E()}},{...c(n),meta:{...h("throttle",{ms:i,leading:o,trailing:r}),...n.meta??{}}})}function ge(d,i,s){return w(t=>{let e,n=!1,o=!1,r=d.subscribe(f=>{if(!n)for(let l of f){if(n)return;l[0]===p?e={v:l[1]}:l[0]===b?(n=!0,t.down([l])):l[0]===a&&(o=!0,e=void 0)}}),u=i.subscribe(f=>{if(!n)for(let l of f){if(n)return;l[0]===p?e!==void 0&&!o&&t.emit(e.v):l[0]===b?(n=!0,t.down([l])):l[0]===a&&(n=!0,t.down([[a]]))}});return()=>{r(),u()}},c(s))}function Oe(d,i,s){return w(t=>{let e,n,o=!1;function r(){e!==void 0&&(clearTimeout(e),e=void 0)}let u=d.subscribe(f=>{for(let l of f)l[0]===p?(n=l[1],o=!0,r(),e=setTimeout(()=>{e=void 0,o&&(o=!1,t.emit(n))},i)):(l[0]===a||l[0]===b)&&(r(),t.down([l]))});return()=>{u(),r()}},c(s))}function xe(d,i,s){let{with:t,...e}=s??{},n=t??new Error("timeout");return w(o=>{let r;function u(){clearTimeout(r),r=setTimeout(()=>{r=void 0,o.down([[b,n]])},i)}u();let f=d.subscribe(l=>{for(let T of l)T[0]===p?(u(),o.emit(T[1])):(T[0]===a||T[0]===b)&&(clearTimeout(r),o.down([T]))});return()=>{f(),clearTimeout(r)}},c(e))}function Ee(d,i,s){return w(t=>{let e=[],n=d.subscribe(r=>{for(let u of r)u[0]===p?e.push(u[1]):u[0]===a?(e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):u[0]===b&&t.down([u])}),o=i.subscribe(r=>{for(let u of r)u[0]===p?e.length>0&&(t.emit([...e]),e.length=0):u[0]===a?t.down([[a]]):u[0]===b&&t.down([u])});return()=>{n(),o(),e.length=0}},c(s))}function Re(d,i,s){if(i<=0)throw new RangeError("bufferCount expects count > 0");return w(t=>{let e=[],n=d.subscribe(o=>{for(let r of o)r[0]===p?(e.push(r[1]),e.length>=i&&t.emit(e.splice(0,e.length))):r[0]===a?(e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):r[0]===b&&t.down([r])});return()=>{n(),e.length=0}},c(s))}function De(d,i,s){if(i<=0)throw new RangeError("windowCount expects count > 0");return w(t=>{let e,n=0;function o(){let u=w(f=>(e=f.down.bind(f),()=>{e=void 0}),c());n=0,t.emit(u)}let r=d.subscribe(u=>{for(let f of u)f[0]===p?(e||o(),e?.([[p,f[1]]]),n+=1,n>=i&&(e?.([[a]]),e=void 0)):f[0]===a?(e?.([[a]]),e=void 0,t.down([[a]])):f[0]===b&&(e?.([f]),e=void 0,t.down([f]))});return()=>{r(),e?.([[a]]),e=void 0}},c(s))}function ye(d,i,s){return w(t=>{let e=[],n=setInterval(()=>{e.length>0&&(t.emit([...e]),e.length=0)},i),o=d.subscribe(r=>{for(let u of r)u[0]===p?e.push(u[1]):u[0]===a?(clearInterval(n),e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):u[0]===b&&(clearInterval(n),t.down([u]))});return()=>{o(),clearInterval(n),e.length=0}},{...c(s),meta:{...h("bufferTime",{ms:i}),...s?.meta??{}}})}function ke(d,i,s){return w(t=>{let e;function n(){e?.([[a]]),e=void 0}function o(){let f=w(l=>(e=l.down.bind(l),()=>{e=void 0}),c());t.emit(f)}o();let r=setInterval(()=>{n(),o()},i),u=d.subscribe(f=>{for(let l of f)l[0]===p?e?.([[p,l[1]]]):l[0]===a?(clearInterval(r),n(),t.down([[a]])):l[0]===b&&(clearInterval(r),e?.([l]),n(),t.down([l]))});return()=>{u(),clearInterval(r),n()}},c(s))}function Ue(d,i,s){return w(t=>{let e;function n(){e?.([[a]]),e=void 0}function o(){let f=w(l=>(e=l.down.bind(l),()=>{e=void 0}),c());t.emit(f)}let r=d.subscribe(f=>{for(let l of f)l[0]===p?(e||o(),e?.([[p,l[1]]])):l[0]===a?(n(),t.down([[a]])):l[0]===b&&(e?.([l]),e=void 0,t.down([l]))}),u=i.subscribe(f=>{for(let l of f)l[0]===p&&(n(),o())});return()=>{r(),u(),n()}},c(s))}function Ie(d,i){return w((s,t)=>{"n"in t.store||(t.store.n=0);let e=setInterval(()=>{s.emit(t.store.n),t.store.n=t.store.n+1},d);return()=>clearInterval(e)},c(i))}function Me(d,i,s){if(i<=0)throw new RangeError("repeat expects count > 0");return w(t=>{let e=i,n,o=()=>{n?.(),n=d.subscribe(r=>{let u=!1,f=[];for(let l of r)l[0]===a?u=!0:f.push(l);f.length>0&&t.down(f),u&&(n?.(),n=void 0,e-=1,e>0?o():t.down([[a]]))})};return o(),()=>{n?.()}},c(s))}function Ce(d,i){return N([d],(s,t)=>{let e=s[0];if(e==null||e.length===0){t.down([[m]]);return}for(let n of e)t.emit(n)},c(i))}function Y(d,i,s){return w(t=>{let e=d.subscribe(n=>{for(let o of n)if(o[0]===p)t.emit(o[1]);else if(o[0]===b)try{t.emit(i(o[1]))}catch(r){t.down([[b,r]])}else o[0]===a&&t.down([[a]])});return()=>{e()}},c(s))}function Ae(d,i,s){return N([d,i],(t,e,n)=>{let o=t[1];if(!(o!=null&&o.length>0?o.at(-1):n.prevData[1])){e.down([[m]]);return}let u=t[0];if(u!=null&&u.length>0){for(let f of u)e.emit(f);return}if(o!=null&&o.length>0&&n.prevData[0]!==void 0){e.emit(n.prevData[0]);return}e.down([[m]])},S(s))}var We=F,Pe=_,Be=j,Se=Y;export{Z as a,V as b,$ as c,ee as d,C as e,K as f,ne as g,te as h,oe as i,re as j,se as k,ie as l,ue as m,q as n,fe as o,de as p,le as q,F as r,ae as s,ce as t,Te as u,pe as v,me as w,be as x,we as y,Ne as z,L as A,he as B,ve as C,_ as D,j as E,ge as F,Oe as G,xe as H,Ee as I,Re as J,De as K,ye as L,ke as M,Ue as N,Ie as O,Me as P,Ce as Q,Y as R,Ae as S,We as T,Pe as U,Be as V,Se as W};
|
|
1
|
+
import{a as B}from"./chunk-4VVTGLXJ.js";import{c as h}from"./chunk-35JTVPOX.js";import{m as k}from"./chunk-CKFQS2CJ.js";import{D as N,F as w,G as P,o as U}from"./chunk-LYCLF26R.js";import{a as A,b as p,c as W,d as m,i as a,j as b}from"./chunk-CK2E7BTU.js";function c(d){return{describeKind:"derived",...d}}function S(d){return{describeKind:"derived",partial:!0,...d}}function Z(d,i,s){return N([d],(t,e)=>{let n=t[0];if(n==null||n.length===0){e.down([[m]]);return}for(let o of n)e.emit(i(o))},{...c(s),meta:{...h("map"),...s?.meta??{}}})}function V(d,i,s){return N([d],(t,e)=>{let n=t[0];if(n==null||n.length===0){e.down([[m]]);return}let o=!1;for(let r of n)i(r)&&(e.emit(r),o=!0);o||e.down([[m]])},{...c(s),meta:{...h("filter"),...s?.meta??{}}})}function $(d,i,s,t){return N([d],(e,n,o)=>{"acc"in o.store||(o.store.acc=s);let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let u of r)o.store.acc=i(o.store.acc,u),n.emit(o.store.acc)},{...c(t),initial:s,resetOnTeardown:!0,meta:{...h("scan",{initial:s}),...t?.meta??{}}})}function ee(d,i,s,t){return N([d],(e,n,o)=>{if("acc"in o.store||(o.store.acc=s),o.terminalDeps[0]===!0){n.emit(o.store.acc),n.down([[a]]);return}let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let u of r)o.store.acc=i(o.store.acc,u)},{...c(t),completeWhenDepsComplete:!1,meta:{...h("reduce",{initial:s}),...t?.meta??{}}})}function C(d,i,s){return i<=0?N([d],(t,e,n)=>{n.store.completed||(n.store.completed=!0,e.down([[a]]))},{...c(s),completeWhenDepsComplete:!1,meta:{...h("take",{count:i}),...s?.meta??{}}}):N([d],(t,e,n)=>{if("taken"in n.store||(n.store.taken=0),n.store.done){e.down([[m]]);return}if(n.terminalDeps[0]===!0){n.store.done=!0,e.down([[a]]);return}let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}for(let r of o)if(n.store.taken++,e.emit(r),n.store.taken>=i){n.store.done=!0,e.down([[a]]);return}},{...c(s),completeWhenDepsComplete:!1,meta:{...h("take",{count:i}),...s?.meta??{}}})}function K(d,i,s){return N([d],(t,e,n)=>{"skipped"in n.store||(n.store.skipped=0);let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}let r=!1;for(let u of o)n.store.skipped++,n.store.skipped<=i||(e.emit(u),r=!0);r||e.down([[m]])},c(s))}function ne(d,i,s){return N([d],(t,e,n)=>{if(n.store.done){e.down([[m]]);return}let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}for(let r of o){if(!i(r)){n.store.done=!0,e.down([[a]]);return}e.emit(r)}},{...c(s),completeWhenDepsComplete:!1})}function te(d,i,s){let t=s?.predicate??(o=>o[0]===p),{predicate:e,...n}=s??{};return w(o=>{let r=!1,u=d.subscribe(l=>{if(!r)for(let T of l){if(r)return;T[0]===p?o.emit(T[1]):(T[0]===a||T[0]===b)&&(r=!0,o.down([T]))}}),f=i.subscribe(l=>{if(!r)for(let T of l){if(r)return;if(t(T)){r=!0,o.down([[a]]);return}}});return()=>{u(),f()}},c(n))}function oe(d,i){return C(d,1,i)}function re(d,i){let{defaultValue:s,...t}=i??{},e=i!=null&&Object.hasOwn(i,"defaultValue");return N([d],(n,o,r)=>{if(r.terminalDeps[0]===!0){r.store.has?o.emit(r.store.latest):e&&o.emit(s),o.down([[a]]);return}let u=n[0];if(u==null||u.length===0){o.down([[m]]);return}r.store.latest=u.at(-1),r.store.has=!0},{...c(t),completeWhenDepsComplete:!1})}function se(d,i,s){return C(V(d,i,s),1,s)}function ie(d,i,s){return C(K(d,i,s),1,s)}function ue(d,i,s){if(typeof i=="function")return N([d],(e,n)=>{let o=e[0];if(o==null||o.length===0){n.down([[m]]);return}for(let r of o)i(r),n.emit(r)},{...c(s),meta:{...h("tap"),...s?.meta??{}}});let t=i;return N([d],(e,n,o)=>{if(o.terminalDeps[0]!==void 0){o.terminalDeps[0]===!0?(t.complete?.(),n.down([[a]])):(t.error?.(o.terminalDeps[0]),n.down([[b,o.terminalDeps[0]]]));return}let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let u of r)t.data?.(u),n.emit(u)},{...c(s),completeWhenDepsComplete:!1,meta:{...h("tap"),...s?.meta??{}}})}function q(d,i,s){let t=s?.where??(n=>n!=null),e=!1;return N([d],(n,o)=>{let r=n[0];if(r==null||r.length===0){o.down([[m]]);return}for(let u of r)!e&&t(u)&&(e=!0,i(u)),o.emit(u)},c(s))}var fe=q;function de(d,i=Object.is,s){return N([d],(t,e,n)=>{let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}let r=!1;for(let u of o)n.store.hasPrev&&i(n.store.prev,u)||(n.store.prev=u,n.store.hasPrev=!0,e.emit(u),r=!0);r||e.down([[m]])},{...c(s),meta:{...h("distinctUntilChanged"),...s?.meta??{}}})}function le(d,i){return N([d],(s,t,e)=>{let n=s[0];if(n==null||n.length===0){t.down([[m]]);return}let o=!1;for(let r of n)if(!e.store.hasPrev)e.store.prev=r,e.store.hasPrev=!0;else{let u=[e.store.prev,r];e.store.prev=r,t.emit(u),o=!0}o||t.down([[m]])},c(i))}function F(...d){let i=[...d];return P(i,s=>s,{...c(),equals:(s,t)=>{if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(!Object.is(s[e],t[e]))return!1;return!0}})}function ae(d,i,s){return N([d,i],(t,e,n)=>{let o=t[0],r=t[1],u=r!=null&&r.length>0?r.at(-1):n.prevData[1];if(o!=null&&o.length>0){if(!(r!=null&&r.length>0)&&n.prevData[1]===void 0){e.down([[m]]);return}for(let f of o)e.emit([f,u])}else e.down([[m]])},{...S(s),meta:{...h("withLatestFrom"),...s?.meta??{}}})}function ce(...d){return d.length===0?w(i=>{i.down([[a]])},{...c(),meta:{...h("merge")}}):w(i=>{let s=d.length,t=0,e=[];for(let n of d){let o=n.subscribe(r=>{for(let u of r)u[0]===p?i.emit(u[1]):u[0]===a?(t+=1,t>=s&&i.down([[a]])):u[0]===b&&i.down([u])});e.push(o)}return()=>{for(let n of e)n()}},{...c(),meta:{...h("merge")}})}function Te(...d){let i=d.length;return i===0?w(s=>{s.emit([]),s.down([[a]])},c()):w(s=>{let t=Array.from({length:i},()=>[]),e=i;function n(){for(;t.every(r=>r.length>0);){let r=t.map(u=>u.shift());s.emit(r)}}let o=[];for(let r=0;r<i;r++){let u=r,f=d[r].subscribe(l=>{for(let T of l)T[0]===p?(t[u].push(T[1]),n()):T[0]===a?(e-=1,(e===0||t[u].length===0)&&s.down([[a]])):T[0]===b&&s.down([T])});o.push(f)}return()=>{for(let r of o)r()}},c())}function pe(d,i,s){return w(t=>{let e=0,n=[],o,r;return r=i.subscribe(u=>{for(let f of u)e===0?f[0]===p?n.push(f[1]):f[0]===b&&t.down([f]):f[0]===p?t.emit(f[1]):(f[0]===a||f[0]===b)&&t.down([f])}),o=d.subscribe(u=>{for(let f of u)if(e===0)if(f[0]===p)t.emit(f[1]);else if(f[0]===a){e=1;for(let l of n)t.emit(l);n.length=0}else f[0]===b&&t.down([f])}),()=>{o?.(),r?.()}},c(s))}function me(...d){return d.length===0?w(i=>{i.down([[a]])},c()):d.length===1?N([d[0]],(i,s)=>{let t=i[0];if(t==null||t.length===0){s.down([[m]]);return}for(let e of t)s.emit(e)},c()):w(i=>{let s=null,t=[];for(let e=0;e<d.length;e++){let n=e,o=d[e].subscribe(r=>{for(let u of r){if(s!==null&&n!==s)return;u[0]===p?(s===null&&(s=n),i.emit(u[1])):(u[0]===a||u[0]===b)&&(s===null||n===s)&&i.down([u])}});t.push(o)}return()=>{for(let e of t)e()}},c())}function I(d,i,s){let t,e=!1,n=()=>{e||(e=!0,s())};return t=d.subscribe(o=>{let r=!1,u=!1;for(let f of o)f[0]!==A&&(f[0]===p?i.emit(f[1]):f[0]===a?r=!0:f[0]===b?(u=!0,i.down([f])):(f[0]===W||f[0]===m)&&i.down([f]));u?(t?.(),t=void 0,n()):r&&n()}),()=>{t?.(),t=void 0}}function be(d,i,s){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){n();return}if(u.terminalDeps[0]===!0){e=!0,t||r.down([[a]]);return}let f=o[0];if(!(f==null||f.length===0))return n(),t=I(k(i(f[f.length-1])),r,()=>{n(),e&&r.down([[a]])}),{deactivate:()=>{n(),e=!1}}},{...c(s),completeWhenDepsComplete:!1,meta:{...h("switchMap"),...s?.meta??{}}})}function we(d,i,s){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){n();return}if(u.terminalDeps[0]===!0){e=!0,t||r.down([[a]]);return}let f=o[0];if(!(f==null||f.length===0))return t===void 0?t=I(k(i(f[0])),r,()=>{n(),e&&r.down([[a]])}):r.down([[m]]),{deactivate:()=>{n(),e=!1}}},{...c(s),completeWhenDepsComplete:!1})}function Ne(d,i,s){let{maxBuffer:t,...e}=s??{},n=[],o,r=!1,u;function f(){o?.(),o=void 0}function l(){if(!u||o!==void 0)return;if(n.length===0){r&&u.down([[a]]);return}let v=n.shift();o=I(k(i(v)),u,()=>{f(),l()})}function T(v){t&&t>0&&n.length>=t&&n.shift(),n.push(v),l()}return N([d],(v,x,E)=>{if(u=x,E.terminalDeps[0]!=null&&E.terminalDeps[0]!==!0){f(),n.length=0;return}if(E.terminalDeps[0]===!0){r=!0,l();return}let R=v[0];if(!(R==null||R.length===0)){for(let g of R)T(g);return{deactivate:()=>{f(),n.length=0,r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}function L(d,i,s){let{concurrent:t,...e}=s??{},n=t!=null&&t>0?t:Number.POSITIVE_INFINITY,o=0,r=!1,u=new Set,f=[],l;function T(){r&&o===0&&f.length===0&&l&&l.down([[a]])}function v(g){if(!l)return;o++;let O;O=I(k(i(g)),l,()=>{O&&u.delete(O),o--,x(),T()}),u.add(O)}function x(){for(;f.length>0&&o<n;)v(f.shift())}function E(g){o<n?v(g):f.push(g)}function R(){for(let g of u)g();u.clear(),o=0,f.length=0}return N([d],(g,O,y)=>{if(l=O,y.terminalDeps[0]!=null&&y.terminalDeps[0]!==!0){R();return}if(y.terminalDeps[0]===!0){r=!0,T();return}let D=g[0];if(!(D==null||D.length===0)){for(let M of D)E(M);return{deactivate:()=>{R(),r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}var he=L;function ve(d,i,s){return w(t=>{let e=new Set;function n(){for(let r of e)clearTimeout(r);e.clear()}let o=d.subscribe(r=>{for(let u of r)if(u[0]===p){let f=setTimeout(()=>{e.delete(f),t.emit(u[1])},i);e.add(f)}else if(u[0]===a){let f=setTimeout(()=>{e.delete(f),t.down([[a]])},i);e.add(f)}else u[0]===b&&(n(),t.down([u]))});return()=>{o(),n()}},c(s))}function _(d,i,s){return w(t=>{let e,n;function o(){e!==void 0&&(clearTimeout(e),e=void 0)}let r=d.subscribe(u=>{for(let f of u)f[0]===p?(o(),n=f[1],e=setTimeout(()=>{e=void 0,t.emit(n)},i)):f[0]===a?(e!==void 0&&(o(),t.emit(n)),t.down([[a]])):f[0]===b&&(o(),t.down([f]))});return()=>{r(),o()}},{...c(s),meta:{...h("debounce",{ms:i}),...s?.meta??{}}})}function j(d,i,s){let{leading:t,trailing:e,...n}=s??{},o=t!==!1,r=e===!0,u=i*1e6;return w(f=>{let l,T=-1/0,v,x=!1;function E(){l!==void 0&&(clearTimeout(l),l=void 0)}let R=d.subscribe(g=>{for(let O of g)if(O[0]===p){let y=O[1],D=U();if(o&&D-T>=u)T=D,f.emit(y),E(),r&&(l=setTimeout(()=>{l=void 0,x&&(T=U(),f.emit(v),x=!1)},i));else if(r&&(v=y,x=!0,l===void 0)){let M=(D-T)/1e6;l=setTimeout(()=>{l=void 0,x&&(T=U(),f.emit(v),x=!1)},Math.max(0,i-M))}}else(O[0]===a||O[0]===b)&&(E(),f.down([O]))});return()=>{R(),E()}},{...c(n),meta:{...h("throttle",{ms:i,leading:o,trailing:r}),...n.meta??{}}})}function ge(d,i,s){return w(t=>{let e,n=!1,o=!1,r=d.subscribe(f=>{if(!n)for(let l of f){if(n)return;l[0]===p?e={v:l[1]}:l[0]===b?(n=!0,t.down([l])):l[0]===a&&(o=!0,e=void 0)}}),u=i.subscribe(f=>{if(!n)for(let l of f){if(n)return;l[0]===p?e!==void 0&&!o&&t.emit(e.v):l[0]===b?(n=!0,t.down([l])):l[0]===a&&(n=!0,t.down([[a]]))}});return()=>{r(),u()}},c(s))}function Oe(d,i,s){return w(t=>{let e,n,o=!1;function r(){e!==void 0&&(clearTimeout(e),e=void 0)}let u=d.subscribe(f=>{for(let l of f)l[0]===p?(n=l[1],o=!0,r(),e=setTimeout(()=>{e=void 0,o&&(o=!1,t.emit(n))},i)):(l[0]===a||l[0]===b)&&(r(),t.down([l]))});return()=>{u(),r()}},c(s))}function xe(d,i,s){let{with:t,...e}=s??{},n=t??new Error("timeout");return w(o=>{let r;function u(){clearTimeout(r),r=setTimeout(()=>{r=void 0,o.down([[b,n]])},i)}u();let f=d.subscribe(l=>{for(let T of l)T[0]===p?(u(),o.emit(T[1])):(T[0]===a||T[0]===b)&&(clearTimeout(r),o.down([T]))});return()=>{f(),clearTimeout(r)}},c(e))}function Ee(d,i,s){return w(t=>{let e=[],n=d.subscribe(r=>{for(let u of r)u[0]===p?e.push(u[1]):u[0]===a?(e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):u[0]===b&&t.down([u])}),o=i.subscribe(r=>{for(let u of r)u[0]===p?e.length>0&&(t.emit([...e]),e.length=0):u[0]===a?t.down([[a]]):u[0]===b&&t.down([u])});return()=>{n(),o(),e.length=0}},c(s))}function Re(d,i,s){if(i<=0)throw new RangeError("bufferCount expects count > 0");return w(t=>{let e=[],n=d.subscribe(o=>{for(let r of o)r[0]===p?(e.push(r[1]),e.length>=i&&t.emit(e.splice(0,e.length))):r[0]===a?(e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):r[0]===b&&t.down([r])});return()=>{n(),e.length=0}},c(s))}function De(d,i,s){if(i<=0)throw new RangeError("windowCount expects count > 0");return w(t=>{let e,n=0;function o(){let u=w(f=>(e=f.down.bind(f),()=>{e=void 0}),c());n=0,t.emit(u)}let r=d.subscribe(u=>{for(let f of u)f[0]===p?(e||o(),e?.([[p,f[1]]]),n+=1,n>=i&&(e?.([[a]]),e=void 0)):f[0]===a?(e?.([[a]]),e=void 0,t.down([[a]])):f[0]===b&&(e?.([f]),e=void 0,t.down([f]))});return()=>{r(),e?.([[a]]),e=void 0}},c(s))}function ye(d,i,s){return w(t=>{let e=[],n=setInterval(()=>{e.length>0&&(t.emit([...e]),e.length=0)},i),o=d.subscribe(r=>{for(let u of r)u[0]===p?e.push(u[1]):u[0]===a?(clearInterval(n),e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):u[0]===b&&(clearInterval(n),t.down([u]))});return()=>{o(),clearInterval(n),e.length=0}},{...c(s),meta:{...h("bufferTime",{ms:i}),...s?.meta??{}}})}function ke(d,i,s){return w(t=>{let e;function n(){e?.([[a]]),e=void 0}function o(){let f=w(l=>(e=l.down.bind(l),()=>{e=void 0}),c());t.emit(f)}o();let r=setInterval(()=>{n(),o()},i),u=d.subscribe(f=>{for(let l of f)l[0]===p?e?.([[p,l[1]]]):l[0]===a?(clearInterval(r),n(),t.down([[a]])):l[0]===b&&(clearInterval(r),e?.([l]),n(),t.down([l]))});return()=>{u(),clearInterval(r),n()}},c(s))}function Ue(d,i,s){return w(t=>{let e;function n(){e?.([[a]]),e=void 0}function o(){let f=w(l=>(e=l.down.bind(l),()=>{e=void 0}),c());t.emit(f)}let r=d.subscribe(f=>{for(let l of f)l[0]===p?(e||o(),e?.([[p,l[1]]])):l[0]===a?(n(),t.down([[a]])):l[0]===b&&(e?.([l]),e=void 0,t.down([l]))}),u=i.subscribe(f=>{for(let l of f)l[0]===p&&(n(),o())});return()=>{r(),u(),n()}},c(s))}function Ie(d,i){return w((s,t)=>{"n"in t.store||(t.store.n=0);let e=setInterval(()=>{s.emit(t.store.n),t.store.n=t.store.n+1},d);return()=>clearInterval(e)},c(i))}function Me(d,i,s){if(i<=0)throw new RangeError("repeat expects count > 0");return w(t=>{let e=i,n,o=()=>{n?.(),n=d.subscribe(r=>{let u=!1,f=[];for(let l of r)l[0]===a?u=!0:f.push(l);f.length>0&&t.down(f),u&&(n?.(),n=void 0,e-=1,e>0?o():t.down([[a]]))})};return o(),()=>{n?.()}},c(s))}function Ce(d,i){return N([d],(s,t)=>{let e=s[0];if(e==null||e.length===0){t.down([[m]]);return}for(let n of e)t.emit(n)},c(i))}function Y(d,i,s){return w(t=>{let e=d.subscribe(n=>{for(let o of n)if(o[0]===p)t.emit(o[1]);else if(o[0]===b)try{t.emit(i(o[1]))}catch(r){t.down([[b,r]])}else o[0]===a&&t.down([[a]])});return()=>{e()}},c(s))}function Ae(d,i,s){return N([d,i],(t,e,n)=>{let o=t[1];if(!(o!=null&&o.length>0?o.at(-1):n.prevData[1])){e.down([[m]]);return}let u=t[0];if(u!=null&&u.length>0){for(let f of u)e.emit(f);return}if(o!=null&&o.length>0&&n.prevData[0]!==void 0){e.emit(n.prevData[0]);return}e.down([[m]])},S(s))}var We=F,Pe=_,Be=j,Se=Y;export{Z as a,V as b,$ as c,ee as d,C as e,K as f,ne as g,te as h,oe as i,re as j,se as k,ie as l,ue as m,q as n,fe as o,de as p,le as q,F as r,ae as s,ce as t,Te as u,pe as v,me as w,be as x,we as y,Ne as z,L as A,he as B,ve as C,_ as D,j as E,ge as F,Oe as G,xe as H,Ee as I,Re as J,De as K,ye as L,ke as M,Ue as N,Ie as O,Me as P,Ce as Q,Y as R,Ae as S,We as T,Pe as U,Be as V,Se as W};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as v}from"./chunk-KRH66M4O.js";import{i as y}from"./chunk-CLD3F4R5.js";import{G as x}from"./chunk-
|
|
1
|
+
import{b as v}from"./chunk-KRH66M4O.js";import{i as y}from"./chunk-CLD3F4R5.js";import{G as x}from"./chunk-6VWBPSSY.js";import{d as S}from"./chunk-VJLMUKOI.js";import{d as O}from"./chunk-VIMF6LGM.js";import{d as k}from"./chunk-6QZNQS5B.js";import{d as A}from"./chunk-GPW2V3RE.js";import{b as N}from"./chunk-B7LCDQEV.js";import{E as b,J as g,m as _}from"./chunk-LYCLF26R.js";import{b as a,c as p,i as h,j as m}from"./chunk-CK2E7BTU.js";import{b as f}from"./chunk-QYADASLV.js";var j={};f(j,{jotai:()=>v,nanostores:()=>y,nestjs:()=>x,react:()=>S,signals:()=>T,solid:()=>O,svelte:()=>k,vue:()=>A,zustand:()=>N});var T={};f(T,{Signal:()=>q});var s=[];function i(n){let e=n.cache;return n.subscribe(o=>{for(let[d,r]of o)d===a&&(e=r)})(),e}var u=class{_node;_equals;constructor(e,t){this._equals=t?.equals??Object.is,this._node=b(e,{...t,resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}set(e){this._equals(this.get(),e)||_(()=>{this._node.down([[p],[a,e]])})}},l=class{_node;constructor(e,t){this._node=g(o=>{s.push(o);try{return e()}finally{s.pop()}},{...t,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}},q={State:u,Computed:l,sub:(n,e)=>{let t=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,o=!0;return n._node.subscribe(d=>{for(let[r,c]of d){if(r===a){if(o){o=!1;continue}t.data?.(c)}r===m&&t.error?.(c),r===h&&t.complete?.()}})}};export{T as a,j as b};
|