@graphrefly/graphrefly 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2JNT5NDF.js +61 -0
- package/dist/{chunk-KN4Q5MQO.js → chunk-2RH4QNDQ.js} +1 -1
- package/dist/chunk-4JBKKUCJ.js +7 -0
- package/dist/{chunk-WLPVGXQ6.js → chunk-4YGJ7KZ6.js} +1 -1
- package/dist/{chunk-3Q2WXM6X.js → chunk-5PBXUVHI.js} +1 -1
- package/dist/{chunk-WYJTXYWX.js → chunk-7EMUF2RY.js} +1 -1
- package/dist/chunk-7JZ3YORY.js +80 -0
- package/dist/{chunk-I4U3TPK2.js → chunk-7QS77X6G.js} +1 -1
- package/dist/{chunk-ZM7C2FUM.js → chunk-BU4SUZSA.js} +1 -1
- package/dist/{chunk-GF5T7PGC.js → chunk-CNXUW2CU.js} +1 -1
- package/dist/{chunk-Z3UWIJ3A.js → chunk-EIFHFDFD.js} +1 -1
- package/dist/{chunk-3JRKP4BH.js → chunk-JAHAJU4G.js} +1 -1
- package/dist/{chunk-4ZPO2EL5.js → chunk-JYMNVEH6.js} +1 -1
- package/dist/{chunk-4KAUNEKV.js → chunk-KD3IYBTD.js} +1 -1
- package/dist/{chunk-X2VHDT26.js → chunk-LG73TUF4.js} +2 -2
- package/dist/{chunk-JXRZXP3N.js → chunk-LJGPOJHS.js} +1 -1
- package/dist/{chunk-YQJPYEAL.js → chunk-M2VFLRPJ.js} +1 -1
- package/dist/{chunk-7EQPXQ7H.js → chunk-MFNOZ5E6.js} +1 -1
- package/dist/{chunk-YZ6VYLFD.js → chunk-PWKLZ2XU.js} +1 -1
- package/dist/{chunk-OKQUPJRY.js → chunk-TOCCHQI6.js} +1 -1
- package/dist/{chunk-PZP4MEXK.js → chunk-UXEB35L4.js} +1 -1
- package/dist/{chunk-EBQ6FXKW.js → chunk-VXJX3ZZP.js} +1 -1
- package/dist/{chunk-7EJTWGKW.js → chunk-WE32AFFA.js} +1 -1
- package/dist/{chunk-JMGGCSIC.js → chunk-WF3V5X2L.js} +1 -1
- package/dist/{chunk-YZKGGMPT.js → chunk-X4OOM6QU.js} +1 -1
- package/dist/{chunk-5LJAQTSS.js → chunk-ZWETYYQG.js} +1 -1
- package/dist/compat/index.cjs +1 -1
- package/dist/compat/index.d.cts +5 -5
- package/dist/compat/index.d.ts +5 -5
- package/dist/compat/index.js +1 -1
- package/dist/compat/nestjs/index.cjs +1 -1
- package/dist/compat/nestjs/index.d.cts +3 -3
- package/dist/compat/nestjs/index.d.ts +3 -3
- package/dist/compat/nestjs/index.js +1 -1
- package/dist/compat/zustand/index.cjs +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/extra/index.cjs +1 -1
- package/dist/extra/index.d.cts +2 -2
- package/dist/extra/index.d.ts +2 -2
- package/dist/extra/index.js +1 -1
- package/dist/graph/index.cjs +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-CWeI0aHd.d.ts → graph-BOhEGJ6E.d.ts} +10 -0
- package/dist/{graph-C4Uxwv0T.d.cts → graph-CdJeX7O7.d.cts} +10 -0
- package/dist/{index-B-z8WaSd.d.cts → index-BDLy6CQ9.d.cts} +1 -1
- package/dist/{index-iBp74eGU.d.cts → index-BJDXj9Wf.d.cts} +2 -2
- package/dist/{index-BBINVimG.d.ts → index-BUZPTPSQ.d.ts} +2 -2
- package/dist/{index-DnrZghBB.d.ts → index-BbcSZCAG.d.ts} +1 -1
- package/dist/{index-lKuLYmHO.d.cts → index-BiGeETJs.d.cts} +1 -1
- package/dist/{index-Dm3_D5Ta.d.cts → index-BmZb8fNF.d.cts} +2 -2
- package/dist/{index-Docdiu9a.d.ts → index-Bnmttu35.d.ts} +1 -1
- package/dist/{index-CZChc85Q.d.cts → index-BuN2wGJs.d.cts} +297 -22
- package/dist/{index-Cy7eFeIX.d.cts → index-BwdPDWI4.d.cts} +1 -1
- package/dist/{index-DylQCKEL.d.cts → index-BzxU4yhV.d.cts} +11 -2
- package/dist/{index-D9Y_u6BG.d.cts → index-C-Gsh-0a.d.cts} +2 -2
- package/dist/{index-DD7RhHNJ.d.cts → index-C22aTC1X.d.cts} +4 -4
- package/dist/{index-yIdWFo2b.d.cts → index-C4QTaDli.d.cts} +2 -2
- package/dist/{index-CJymKyzT.d.ts → index-C7RqYbOZ.d.ts} +1 -1
- package/dist/{index-C5Ghnp5B.d.ts → index-C9qCLIN4.d.ts} +2 -2
- package/dist/{index-DVNLe3pS.d.cts → index-CCdg0JLX.d.cts} +1 -1
- package/dist/{index-B5iVOD7w.d.ts → index-CEoU-r-g.d.ts} +2 -2
- package/dist/{index-CfFYyLR8.d.ts → index-CHfBm51k.d.ts} +11 -2
- package/dist/{index-BXzl1NDD.d.ts → index-CNyiYQWF.d.ts} +4 -4
- package/dist/{index-C6NBfXj-.d.ts → index-CVevMZ0n.d.ts} +2 -2
- package/dist/{index-DGb1awva.d.ts → index-CZUzi6Dy.d.ts} +2 -2
- package/dist/{index-FrYrV-Vf.d.ts → index-Ckl03Q0s.d.ts} +1 -1
- package/dist/{index-Bvi5uJxX.d.ts → index-CmSjld-4.d.ts} +1 -1
- package/dist/{index-9iguV3bF.d.cts → index-CnjUhRbs.d.cts} +2 -2
- package/dist/{index-C98oJsEs.d.cts → index-D3HcdZ4d.d.cts} +1 -1
- package/dist/{index-IZ3l_vQ9.d.ts → index-DD1czHj3.d.ts} +1 -1
- package/dist/{index-gJQqJTKx.d.cts → index-DNhTQReY.d.cts} +1 -1
- package/dist/{index-UZO988ox.d.cts → index-DSawGt8n.d.cts} +2 -2
- package/dist/{index-CcpEvuPl.d.cts → index-DUkuH3jP.d.cts} +1 -1
- package/dist/{index-CRAkoq-y.d.cts → index-DY2QbdoP.d.cts} +1 -1
- package/dist/{index-CvS9IuTG.d.ts → index-Dbmj0iYR.d.ts} +1 -1
- package/dist/{index-Bd6oFZqO.d.ts → index-DhlAMlm9.d.ts} +297 -22
- package/dist/{index-BMe3pCom.d.cts → index-DlGaEBW5.d.cts} +2 -2
- package/dist/{index-CotRMjtJ.d.ts → index-Dp_pS7Bw.d.ts} +1 -1
- package/dist/{index-DxMS0cHM.d.ts → index-Dxk-pUQI.d.ts} +2 -2
- package/dist/{index-DBQUKh59.d.cts → index-EGjF6iSY.d.cts} +3 -3
- package/dist/{index-D9HrBx2J.d.ts → index-LGzAYqdR.d.ts} +1 -1
- package/dist/{index-DR3gf_DG.d.cts → index-LzCJ0kMT.d.cts} +2 -2
- package/dist/{index-RQg6lTrN.d.ts → index-MV2yGIAq.d.ts} +2 -2
- package/dist/{index-Bs3-LC83.d.cts → index-_BXz9K7b.d.cts} +1 -1
- package/dist/{index-SSGqF8mI.d.cts → index-aBqZUx3B.d.cts} +1 -1
- package/dist/{index-CFW32Dy1.d.ts → index-eYHRkoK-.d.ts} +1 -1
- package/dist/{index-CwhcFzTA.d.ts → index-gXTVbSax.d.ts} +2 -2
- package/dist/{index-D-kHVedZ.d.cts → index-j33Lfb1G.d.cts} +22 -1
- package/dist/{index-BEpRsvhg.d.ts → index-lpGUhTBn.d.ts} +3 -3
- package/dist/{index-CcS0t-l2.d.ts → index-zMQIQuDu.d.ts} +22 -1
- package/dist/index.cjs +53 -50
- package/dist/index.d.cts +26 -26
- package/dist/index.d.ts +26 -26
- package/dist/index.js +1 -1
- package/dist/patterns/ai/index.cjs +21 -18
- package/dist/patterns/ai/index.d.cts +6 -6
- package/dist/patterns/ai/index.d.ts +6 -6
- package/dist/patterns/ai/index.js +1 -1
- package/dist/patterns/audit/index.cjs +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.cjs +1 -1
- package/dist/patterns/cqrs/index.d.cts +2 -2
- package/dist/patterns/cqrs/index.d.ts +2 -2
- package/dist/patterns/cqrs/index.js +1 -1
- package/dist/patterns/demo-shell/index.cjs +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.cjs +5 -5
- 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.cjs +27 -25
- 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 +5 -5
- 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 +12 -11
- package/dist/patterns/harness/index.d.cts +5 -5
- package/dist/patterns/harness/index.d.ts +5 -5
- package/dist/patterns/harness/index.js +1 -1
- package/dist/patterns/job-queue/index.cjs +1 -1
- package/dist/patterns/job-queue/index.d.cts +2 -2
- package/dist/patterns/job-queue/index.d.ts +2 -2
- package/dist/patterns/job-queue/index.js +1 -1
- package/dist/patterns/lens/index.cjs +1 -1
- package/dist/patterns/lens/index.d.cts +3 -3
- package/dist/patterns/lens/index.d.ts +3 -3
- package/dist/patterns/lens/index.js +1 -1
- package/dist/patterns/memory/index.cjs +1 -1
- package/dist/patterns/memory/index.d.cts +2 -2
- package/dist/patterns/memory/index.d.ts +2 -2
- package/dist/patterns/memory/index.js +1 -1
- package/dist/patterns/messaging/index.cjs +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.cjs +7 -7
- package/dist/patterns/orchestration/index.d.cts +2 -2
- package/dist/patterns/orchestration/index.d.ts +2 -2
- package/dist/patterns/orchestration/index.js +1 -1
- package/dist/patterns/reactive-layout/index.cjs +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.cjs +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.cjs +3 -3
- 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.d.cts +3 -3
- package/dist/patterns/resilient-pipeline/index.d.ts +3 -3
- package/dist/patterns/resilient-pipeline/index.js +1 -1
- package/dist/patterns/surface/index.cjs +15 -13
- 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/{reactive-layout-BAr6-_o5.d.ts → reactive-layout-Bq0rA2Wb.d.ts} +1 -1
- package/dist/{reactive-layout-5oEn8lHM.d.cts → reactive-layout-Dhhe54Oj.d.cts} +1 -1
- package/dist/{topology-tree-CVREibAc.d.cts → topology-tree-CpSjvIXp.d.cts} +1 -1
- package/dist/{topology-tree-CkjojcB6.d.ts → topology-tree-DAbCV2Yw.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-ASDKRNOJ.js +0 -60
- package/dist/chunk-PSQNYY72.js +0 -7
- package/dist/chunk-XEFAMCEA.js +0 -78
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as I}from"./chunk-K54OKWNY.js";import{g as _,j as P}from"./chunk-
|
|
1
|
+
import{c as I}from"./chunk-K54OKWNY.js";import{g as _,j as P}from"./chunk-4JBKKUCJ.js";import{D as y,E as K,G as E,m as F}from"./chunk-7AJKUA36.js";import{b as j,d as x,i as A,j as D}from"./chunk-CK2E7BTU.js";import{b as B}from"./chunk-QYADASLV.js";var ee={};B(ee,{approval:()=>V,branch:()=>U,gate:()=>z,join:()=>J,loop:()=>Q,onFailure:()=>Z,pipeline:()=>L,sensor:()=>Y,subPipeline:()=>X,task:()=>H});function O(e,n){if(typeof n=="string")return{node:e.resolve(n),path:n};let o=$(e,n);if(!o)throw new Error("orchestration dep node must already be registered in the graph so explicit edges can be recorded; pass a string path or register the node first");return{node:n,path:o}}function $(e,n){let o=e.describe(),r=`::${_}::`;for(let t of Object.keys(o.nodes).sort())if(!t.includes(r))try{if(e.resolve(t)===n)return t}catch{}}function w(e,n,o,r){e.add(o,{name:n})}function N(e,n){return I("orchestration",e,n)}function W(e){let n=r=>{let t=r.trim();return t.length===0?0:Number(t)},o;return typeof e=="string"?o=n(e):e===null?o=0:o=Number(e),Number.isFinite(o)?Math.max(0,Math.trunc(o)):1}function L(e,n){return new P(e,n)}function H(e,n,o,r){let a=(r?.deps??[]).map(i=>O(e,i)),{deps:s,...p}=r??{},T=(i,f,c)=>{let l=i.map((h,g)=>h!=null&&h.length>0?h.at(-1):c.prevData[g]);f.emit(o(l,c))},d=y(a.map(i=>i.node),T,{...p,name:n,describeKind:"derived",meta:N("task",r?.meta)});return w(e,n,d,a.flatMap(i=>i.path?[i.path]:[])),d}function U(e,n,o,r,t){let a=O(e,o),s=E([a.node],([p])=>({branch:r(p)?"then":"else",value:p}),{...t,name:n,meta:N("branch",t?.meta)});return w(e,n,s,a.path?[a.path]:[]),s}function V(e,n,o,r,t){let a=O(e,o),s=O(e,r),p=t?.isApproved??(d=>!!d),T=y([a.node,s.node],(d,i,f)=>{let c=d[0],l=d[1],h=l!=null&&l.length>0?l.at(-1):f.prevData[1];if(h===void 0||!p(h)){i.down([[x]]);return}if(c==null||c.length===0){l!=null&&l.length>0&&f.prevData[0]!==void 0?i.emit(f.prevData[0]):i.down([[x]]);return}for(let g of c)i.emit(g)},{...t,name:n,describeKind:"derived",meta:N("approval",t?.meta)});return w(e,n,T,[a.path,s.path].filter(d=>typeof d=="string")),T}function z(e,n,o,r){let t=r?.maxPending??1/0;if(t<1&&t!==1/0)throw new RangeError("gate: maxPending must be >= 1");let a=r?.startOpen??!1,s=O(e,o),p=K([],{name:"pending",equals:()=>!1}),T=K(a,{name:"isOpen"}),d=E([p],([u])=>u.length,{name:"count"}),i=[],f=!1,c=a,l=T.subscribe(u=>{for(let m of u)m[0]===j&&(c=m[1])});function h(){p.emit([...i])}function g(u){i.push(u),i.length>t&&i.shift(),h()}function R(u){let m=i.splice(0,u);return h(),m}function k(u){if(f)throw new Error(`gate: ${u}() called after gate was torn down`)}let b=y([s.node],(u,m,S)=>{let G=S.terminalDeps[0];if(G!==void 0){f=!0,i=[],h(),m.down(G===!0?[[A]]:[[D,G]]);return}let v=u[0];if(v==null||v.length===0){m.down([[x]]);return}for(let C of v)c?m.emit(C):(g(C),m.down([[x]]))},{name:n,describeKind:"derived",meta:N("gate",r?.meta)}),q={node:b,pending:p,count:d,isOpen:T,approve(u=1){k("approve");let m=R(u);for(let S of m){if(f)break;b.emit(S)}},reject(u=1){k("reject"),R(u)},modify(u,m=1){k("modify");let S=[...i],G=R(m);for(let v=0;v<G.length&&!f;v++)b.emit(u(G[v],v,S))},open(){k("open"),F(()=>{T.emit(!0);let u=R(i.length);for(let m of u){if(f)break;b.emit(m)}})},close(){k("close"),T.emit(!1)}};e.addDisposer(d.subscribe(()=>{})),e.addDisposer(l),w(e,n,b,s.path?[s.path]:[]);let M=new P(`${n}_state`);return M.add(p,{name:"pending"}),M.add(T,{name:"isOpen"}),M.add(d,{name:"count"}),e.mount(`${n}_state`,M),q}function J(e,n,o,r){let t=o.map(s=>O(e,s)),a=E(t.map(s=>s.node),s=>s,{...r,name:n,meta:N("join",r?.meta)});return w(e,n,a,t.flatMap(s=>s.path?[s.path]:[])),a}function Q(e,n,o,r,t){let a=O(e,o),s=t?.iterations,p=typeof s=="number"||s===void 0?void 0:O(e,s),T=typeof s=="number"?s:void 0,d=y(p?[a.node,p.node]:[a.node],(i,f,c)=>{let l=i[0],h=l!=null&&l.length>0?l.at(-1):c.prevData[0],g=p?i[1]:void 0,R=T??(p?g!=null&&g.length>0?g.at(-1):c.prevData[1]:1),k=W(R);for(let b=0;b<k;b+=1)h=r(h,b,f);f.emit(h)},{...t,name:n,describeKind:"derived",meta:N("loop",t?.meta)});return w(e,n,d,[a.path,p?.path].filter(i=>typeof i=="string")),d}function X(e,n,o,r){let t=o instanceof P?o:L(n,r);return typeof o=="function"&&o(t),e.mount(n,t),t}function Y(e,n,o,r){let t=y([],()=>{},{...r,name:n,initial:o,describeKind:"producer",meta:N("sensor",r?.meta)});return w(e,n,t,[]),{node:t,push(a){t.emit(a)},error(a){t.down([[D,a]])},complete(){t.down([[A]])}}}function Z(e,n,o,r,t){let a=O(e,o),s=!1,p=y([],(T,d)=>{let i=a.node.subscribe(f=>{for(let c of f){if(s)return;if(c[0]===D)try{d.emit(r(c[1],d))}catch(l){s=!0,d.down([[D,l]])}else d.down([c]),c[0]===A&&(s=!0)}});return()=>i()},{...t,name:n,describeKind:"derived",completeWhenDepsComplete:!1,errorWhenDepsError:!1,meta:N("onFailure",t?.meta)});return w(e,n,p,a.path?[a.path]:[]),p}export{L as a,H as b,U as c,V as d,z as e,J as f,Q as g,X as h,Y as i,Z as j,ee as k};
|
package/dist/compat/index.cjs
CHANGED
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
`)}function qr(t){if(t.version!==Ne)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${Ne})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in t))throw new Error(`snapshot missing required key "${e}"`);if(typeof t.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof t.nodes!="object"||t.nodes===null||Array.isArray(t.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(t.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(t.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function vs(t,e){let n=new WeakMap,r=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=n.get(o);if(i==null&&(i=new WeakSet,n.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,c=s.constructor;if(a!==c)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let p=s;if(o.length!==p.length)return!1;for(let h=0;h<o.length;h++)if(!r(o[h],p[h]))return!1;return!0}if(o instanceof Map){let p=s;if(o.size!==p.size)return!1;for(let[h,d]of o)if(!p.has(h)||!r(d,p.get(h)))return!1;return!0}if(o instanceof Set){let p=s;if(o.size!==p.size)return!1;for(let h of o){let d=!1;for(let g of p)if(r(h,g)){d=!0;break}if(!d)return!1}return!0}if(ArrayBuffer.isView(o)){let p=o,h=s;if(p.length!==h.length)return!1;for(let d=0;d<p.length;d++)if(p[d]!==h[d])return!1;return!0}let u=Object.keys(o),l=Object.keys(s);if(u.length!==l.length)return!1;let f=new Set(l);for(let p of u)if(!f.has(p)||!r(o[p],s[p]))return!1;return!0};return r(t,e)}function an(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(an);let e=t,n=Object.keys(e).sort(),r={};for(let o of n)r[o]=an(e[o]);return r}function _s(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function xs(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function ws(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function Br(t){let e=new Set,n=[];function r(o,s){let i=`${o}\0${s}`;e.has(i)||(e.add(i),n.push([o,s]))}for(let[o,s]of Object.entries(t.nodes)){let i=s.deps;if(i)for(let a of i)r(a,o)}for(let o of t.edges)r(o.from,o.to);return n}function zr(t){if(t===void 0)return"LR";if(t==="TD"||t==="LR"||t==="BT"||t==="RL")return t;throw new Error(`invalid diagram direction ${String(t)}; expected one of: TD, LR, BT, RL`)}function Ts(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,{expand:o,...s}=t,i={...s,edges:n?t.edges:[],subgraphs:r?t.subgraphs:[]},a=JSON.stringify(an(i),null,e.indent??2);return e.logger?.(a),a}function Es(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,o=[];o.push(`Graph ${t.name}`),o.push("Nodes:");for(let i of Object.keys(t.nodes).sort()){let a=t.nodes[i];o.push(`- ${i} (${a.type}/${a.status}): ${St(a.value)}`)}if(n){o.push("Edges:");for(let i of t.edges)o.push(`- ${i.from} -> ${i.to}`)}if(r){o.push("Subgraphs:");for(let i of t.subgraphs)o.push(`- ${i}`)}let s=o.join(`
|
|
13
13
|
`);return e.logger?.(s),s}function Kr(t,e){let n=zr(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`flowchart ${n}`];for(let i of r){let a=o.get(i);s.push(` ${a}["${_s(i)}"]`)}for(let[i,a]of Br(t)){let c=o.get(i),u=o.get(a);!c||!u||s.push(` ${c} --> ${u}`)}return s.join(`
|
|
14
14
|
`)}function Os(t,e){let n=Kr(t,e);return Ur(n)}function Ur(t,e){let n=e?.theme??"default",r=e?.autoSync??!0,s=JSON.stringify({code:t,mermaid:{theme:n},autoSync:r}),i=new TextEncoder().encode(s),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function Rs(t,e){let n=zr(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`direction: ${ws(n)}`];for(let i of r){let a=o.get(i);s.push(`${a}: "${xs(i)}"`)}for(let[i,a]of Br(t)){let c=o.get(i),u=o.get(a);!c||!u||s.push(`${c} -> ${u}`)}return s.join(`
|
|
15
|
-
`)}function Ns(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Nt(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let o=t.indexOf("]",n+1);if(o<=n+1){e+="\\[";continue}let s=t.slice(n+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,n=o;continue}e+=Ns(r)}return e+="$",new RegExp(e)}var Ss={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"},As={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function St(t){if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||t==null)return String(t);try{return JSON.stringify(t)}catch{return"[unserializable]"}}function ks(t){return t==="none"?As:t==="ansi"||t==null?Ss:{data:t.data??"",dirty:t.dirty??"",resolved:t.resolved??"",invalidate:t.invalidate??"",pause:t.pause??"",resume:t.resume??"",complete:t.complete??"",error:t.error??"",teardown:t.teardown??"",derived:t.derived??"",path:t.path??"",reset:t.reset??""}}function Wr(t){if(t==null)return{};let e=t.detail;return e==="full"?{...t,structured:t.structured??!0,timeline:t.timeline??!0,causal:t.causal??!0,derived:t.derived??!0}:e==="minimal"?{...t,structured:t.structured??!0}:t.format==="stage-log"?{...t,structured:t.structured??!0,timeline:t.timeline??!0}:t}function Cs(t,e,n){for(let r=0;r<t.length;r++){let o=t.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function sn(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(L))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${L}' (path separator)`);if(t===te)throw new Error(`Graph "${e}": ${n} name "${te}" is reserved for meta companion paths`);Cs(t,e,n)}function Ms(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(L);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function Ds(t,e){let n=!1;for(let o of t)if(!e.isMetaPassthrough(o[0])){n=!0;break}return n?t.filter(o=>e.isMetaPassthrough(o[0])):t}function Yr(t){for(let e of t._mounts.values())Yr(e);for(let e of t._nodes.values())try{e.down([[q]],{internal:!0})}catch{}}var ne=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(L))throw new Error(`Graph name must not contain '${L}' (got "${e}")`);if(e===te)throw new Error(`Graph name "${te}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??Te,this._traceRing=new ot(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=Ie(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}add(e,n){let r=e.name,o=n?.name??r;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=n?.annotation;if(sn(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:Me()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof $&&n._applyVersioning(e)}remove(e){sn(e,this.name,"remove");let n=this._mounts.get(e);if(n){let s={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,c]of i)a.includes(`${L}${te}${L}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...n._collectSubgraphs(`${e}${L}`)),this._mounts.delete(e),n._parent=void 0,Yr(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[q]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let n=typeof e=="function"?e:(()=>{let s=Nt(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>n(s));for(let s of o){let i=this.remove(s);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let o=e[r++];return{value:[o,n.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(L))return this.resolve(e);let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return n}get(e){return this.node(e).cache}set(e,n,r){let o=r?.internal===!0;this.node(e).down([[E,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);ce(()=>{for(let[o,s]of r)this.set(o,s,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[oe]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let o=r?.internal===!0;this.node(e).down([[C,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[P]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[c,u]of this._nodes)r.set(u,c);let a=[];for(let[c,u]of this._nodes)if(u instanceof $)for(let l of u._deps){let f=r.get(l.node);f!=null&&a.push([f,c])}return a.sort((c,u)=>c[0]<u[0]?-1:c[0]>u[0]?1:c[1]<u[1]?-1:c[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,c]of o)s.set(c,a);let i=[];for(let[a,c]of o)if(c instanceof $)for(let u of c._deps){let l=s.get(u.node);l!=null&&i.push([l,a])}return i.sort((a,c)=>a[0]<c[0]?-1:a[0]>c[0]?1:a[1]<c[1]?-1:a[1]>c[1]?1:0),i}mount(e,n){if(sn(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let n=Ms(e,this.name);return this._resolveFromSegments(n)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let n=e;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],o=n.slice(1);if(o.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let s=this._nodes.get(r);if(s&&o.length>0&&o[0]===te)return this._resolveMetaChainFromNode(s,o,n.join(L));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(L)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(L))}_resolveMetaChainFromNode(e,n,r){let o=e,s=0,i=[...n];for(;s<i.length;){if(i[s]!==te)throw new Error(`Graph "${this.name}": expected ${te} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${te} in "${r}"`);let a=i[s+1],c=o.meta[a];if(!c)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=c,s+=2}return o}signal(e,n){if(n?.internal!==!0){for(let o of e)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,o){for(let c of this._mounts.values())c._signalDeliver(e,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=Ds(e,this.config);for(let c of[...this._nodes.keys()].sort()){let u=this._nodes.get(c);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(l){if(l instanceof Z)throw l;o.push(l)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,o)}}}_signalMetaSubtree(e,n,r,o,s){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,o)}catch(c){if(c instanceof Z)throw c;s.push(c)}this._signalMetaSubtree(a,n,r,o,s)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,o=vt(e?.detail,e?.fields),s=e?.format==="spec",i=s?vt("minimal"):o,a=[];this._collectObserveTargets("",a);let c=new Map;for(let[T,x]of a)c.set(x,T);let u=[];{let T=a.map(([,N])=>N),x=new Set(c.values()),O=0;for(;T.length>0;){let N=T.shift();if(N instanceof $)for(let M of N._deps){let S=M.node;if(c.has(S))continue;let k=S.name??"",A=k;if(!A||x.has(A))if(k){let F=2;for(;x.has(`${k}#${F}`);)F++;A=`${k}#${F}`}else for(A=`__internal__/${O++}`;x.has(A);)A=`__internal__/${O++}`;c.set(S,A),x.add(A),u.push([A,S]),T.push(S)}}}let l=[...a,...u],f={};for(let[T,x]of l){if(n!=null&&!x.allowsObserve(n))continue;let O=rn(x,i),N=x instanceof $?x._deps.map(A=>c.get(A.node)??A.node.name??""):[],{name:M,...S}=O,k={...S,deps:N};if(!s){let A=this._annotations.get(T);A!=null&&(k.annotation=A)}if(r!=null)if(typeof r=="function"){let A=r;if(!(A.length>=2?A(T,k):A(k)))continue}else{let A=!0;for(let[F,U]of Object.entries(r)){let re=F==="deps_includes"?"depsIncludes":F==="meta_has"?"metaHas":F;if(re==="depsIncludes"){if(!k.deps.includes(String(U))){A=!1;break}continue}if(re==="metaHas"){if(!Object.hasOwn(k.meta??{},String(U))){A=!1;break}continue}if(k[re]!==U){A=!1;break}}if(!A)continue}f[T]=k}let p=new Set(Object.keys(f)),h=[];for(let[T,x]of l)if(x instanceof $)for(let O of x._deps){let N=c.get(O.node);N!=null&&h.push([N,T])}h.sort((T,x)=>T[0]<x[0]?-1:T[0]>x[0]?1:T[1]<x[1]?-1:T[1]>x[1]?1:0);let d=h.map(([T,x])=>({from:T,to:x}));(n!=null||r!=null)&&(d=d.filter(T=>p.has(T.from)&&p.has(T.to)));let g=this._collectSubgraphs(""),m=n!=null||r!=null?g.filter(T=>{let x=`${T}${L}`;return[...p].some(O=>O===T||O.startsWith(x))}):g,v=this,_=e,b={name:this.name,nodes:f,edges:d,subgraphs:m,expand(T){let x={..._,format:void 0};return Array.isArray(T)?(x.fields=T,x.detail=void 0):(x.detail=T,x.fields=void 0),v.describe(x)}},y=e??{},w=y.format;return w==="json"?Ts(b,y):w==="pretty"?Es(b,y):w==="mermaid"?Kr(b,y):w==="mermaid-url"?Os(b,y):w==="d2"?Rs(b,y):w==="ascii"?Ir(b,y):b}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;n.push(o),n.push(...this._mounts.get(r)._collectSubgraphs(`${o}${L}`))}return n}resourceProfile(e){return jr(this,e)}reachable(e,n,r={}){return r.withDetail===!0?un(this.describe(),e,n,{...r,withDetail:!0}):un(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,c]of Object.entries(o.nodes))c.lastMutation!=null&&i.set(a,c.lastMutation);return Lr(o,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=V(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=()=>{a||c||(a=!0,Qe(()=>{a=!1,!c&&(o+=1,s.emit(o))}))},l=i.onEvent(m=>{let v=m.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||u()}),f=[],p=new WeakSet,h=m=>{if(p.has(m)||c)return;p.add(m);let v=m.topology.subscribe(_=>{for(let b of _){if(b[0]!==E)continue;let y=b[1];if(u(),y.kind==="added"&&y.nodeKind==="mount"){let w=m._mounts.get(y.name);w!=null&&h(w)}}});f.push(v);for(let _ of m._mounts.keys()){let b=m._mounts.get(_);b!=null&&h(b)}};h(this);let d;try{d=ie([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,v)=>m===v})}catch(m){l();for(let v of f)v();throw i.dispose(),m}let g=ge(d);return{node:d,dispose(){c=!0,l();for(let m of f)m();f.length=0,i.dispose(),g()}}}_explainReactive(e,n,r){let o=0,s=V(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=i.onEvent(h=>{let d=h.type;d!=="data"&&d!=="error"&&d!=="complete"&&d!=="teardown"||a||c||(a=!0,Qe(()=>{a=!1,!c&&(o+=1,s.emit(o))}))}),l={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},f;try{f=ie([s],()=>this._explainStatic(e,n,l),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(h,d)=>h.found===d.found&&h.reason===d.reason&&h.steps.length===d.steps.length&&Gs(h.steps,d.steps)})}catch(h){throw u(),i.dispose(),h}let p=ge(f);return{node:f,dispose(){c=!0,u(),i.dispose(),p()}}}_pathsMatching(e){let n=Nt(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>n.test(o))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${L}${r}`;this._mounts.get(r)._collectObserveTargets(o,n)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${L}${r}`;n.push([s,o]),this._appendMetaObserveTargets(s,o,n)}}_appendMetaObserveTargets(e,n,r){for(let o of Object.keys(n.meta).sort()){let s=n.meta[o],i=`${e}${L}${te}${L}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,n){let r=typeof e=="string",s=Wr(r?n:e),i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let l=e,f=this.resolve(l);if(a!=null&&!f.allowsObserve(a))throw new Z({actor:a,action:"observe",nodeName:l});return i?this._buildStructuredObserver([[l,f]],s,"one"):{subscribe(p){return f.subscribe(p)},up(p){try{f.up?.(p)}catch(h){if(h instanceof Z)return;throw h}}}}let c=[];this._collectObserveTargets("",c),c.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let u=a==null?c:c.filter(([,l])=>l.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:l=>{let f=u.map(([p,h])=>h.subscribe(d=>{l(p,d)}));return()=>{for(let p of f)p()}},up:(l,f)=>{try{this.resolve(l).up?.(f)}catch(p){if(p instanceof Z)return;throw p}}}}_buildStructuredObserver(e,n,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let l=this.resolve(o);return this._buildStructuredObserver([[o,l]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let c=i.actor,u=c==null?a:a.filter(([,l])=>l.allowsObserve(c));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,s)}_createObserveResult(e,n,r){let o=n.timeline===!0,s=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",c=this.config.inspectorEnabled,u=(s||i)&&c,l=n.maxEvents,f=l!=null&&l>0?new ot(l):null,p=[],h=new Set,d={},g=new Set,m=0,v=0,_=0,b=0,y=0,w=0,T=!1,x=!1,O=0,N=new Map,M=new Map,S=new Map,k=R=>{f?f.push(R):p.push(R);for(let G of h)G(R)},A=()=>o?{timestamp_ns:Me(),in_batch:at(),batch_id:O}:{},F=(R,G)=>{if(!(!u||!(R instanceof $)))return R._setInspectorHook(J=>{if(J.kind==="dep_message")N.set(R,J.depIndex);else if(J.kind==="run"){let We=J.batchData.map((D,z)=>D!=null&&D.length>0?D.at(-1):J.prevData[z]);M.set(R,We);let Q=J.batchData.map(D=>D!=null?[...D]:void 0);S.set(R,Q),i&&k({type:"derived",path:G,dep_values:We,dep_batches:Q,...A()})}})},U=R=>{let G=N.get(R),J=M.get(R);if(!s||J==null)return{};let Q=(G!=null&&G>=0&&R instanceof $?R._deps[G]:void 0)?.node,D=Q?.v,z=S.get(R);return{trigger_dep_index:G,trigger_dep_name:Q?.name,...D!=null?{trigger_version:{id:D.id,version:D.version}}:{},dep_values:[...J],...z!=null?{dep_batches:z}:{}}},re=[],ye=[];for(let[R,G]of e){let J=F(G,R);J&&re.push(J),ye.push(G.subscribe(We=>{O++;for(let Q of We){let D=Q[0],z=A();if(D===E){d[R]=Q[1];let It=G instanceof $?G.lastMutation?.actor??pe:pe;k({type:"data",path:R,data:Q[1],actor:It,...z,...U(G)})}else if(a)D===I?m++:D===B?v++:D===oe?_++:D===X?b++:D===se?y++:D===q?w++:D===P&&!g.has(R)?T=!0:D===C&&(x=!0,g.add(R));else if(D===I)m++,k({type:"dirty",path:R,...z});else if(D===B)v++,k({type:"resolved",path:R,...z,...U(G)});else if(D===oe)_++,k({type:"invalidate",path:R,...z});else if(D===X)b++,k({type:"pause",path:R,lockId:Q[1],...z});else if(D===se)y++,k({type:"resume",path:R,lockId:Q[1],...z});else if(D===P)g.has(R)||(T=!0),k({type:"complete",path:R,...z});else if(D===C){x=!0,g.add(R);let It=G instanceof $?G.lastMutation?.actor??pe:pe;k({type:"error",path:R,data:Q[1],actor:It,...z})}else D===q&&(w++,k({type:"teardown",path:R,...z}))}}))}let Mt=!1,Dt=()=>{if(!Mt){Mt=!0;for(let R of ye)R();for(let R of re)R();for(let R of it)R({value:void 0,done:!0});it.length=0}},Gt=[],it=[];h.add(R=>{let G=it.shift();G?G({value:R,done:!1}):Gt.push(R)});let Tn={get values(){return d},get dirtyCount(){return m},get resolvedCount(){return v},get invalidateCount(){return _},get pauseCount(){return b},get resumeCount(){return y},get teardownCount(){return w},get events(){return f?f.toArray():[...p]},get anyCompletedCleanly(){return T},get anyErrored(){return x},get completedWithoutErrors(){return T&&!x},onEvent(R){return h.add(R),()=>h.delete(R)},dispose:Dt,expand(R){Dt();let G={...n};return typeof R=="string"?G.detail=R:Object.assign(G,R),r(Wr(G))},[Symbol.asyncIterator](){return{next(){return Gt.length>0?Promise.resolve({value:Gt.shift(),done:!1}):Mt?Promise.resolve({value:void 0,done:!0}):new Promise(R=>it.push(R))},return(){return Dt(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Tn,n),Tn}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let o=n.logger??(d=>console.log(d)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:d=>(s==null||s.has(d))&&(i==null||!i.has(d)),c=ks(n.theme),u=r==="stage-log"?Me():0,l=d=>d==null?"":n.stageLabels?.[d]??d,f=(d,g)=>d.length>g?`${d.slice(0,g-1)}\u2026`:d,p=d=>d.type==="data"||d.type==="error"?f(St(d.data),120):"",h=d=>{if(r==="stage-log"){let x=(Me()-u)/1e9,O=l(d.path).padEnd(9);if(d.type==="data"){let N=p(d);return`[${x.toFixed(3)}s] ${O} \u2190${N?` ${N}`:""}`}if(d.type==="error"){let N=p(d);return`[${x.toFixed(3)}s] ${O} \u2717${N?` ${N}`:""}`}return d.type==="complete"?`[${x.toFixed(3)}s] ${O} \u25A0 complete`:`[${x.toFixed(3)}s] ${O} ${d.type}`}if(r==="json")try{return JSON.stringify(d)}catch{return JSON.stringify({type:d.type,path:d.path,data:"[unserializable]"})}let g=c[d.type]??"",m=d.path?`${c.path}${d.path}${c.reset} `:"",v=d.type==="data"||d.type==="error",_=d.type==="pause"||d.type==="resume",b=v?` ${St(d.data)}`:_?` ${St(d.lockId)}`:"",y=d.type==="data"||d.type==="resolved"||d.type==="derived"?d:void 0,w=y?.trigger_dep_name!=null?` <- ${y.trigger_dep_name}`:y?.trigger_dep_index!=null?` <- #${y.trigger_dep_index}`:"",T=d.in_batch?" [batch]":"";return`${m}${g}${d.type.toUpperCase()}${c.reset}${b}${w}${T}`};e.onEvent(d=>{a(d.type)&&o(h(d),d)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){Vr(this._disposers,this.name),this.signal([[q]],{internal:!0}),Vr(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}snapshot(e){let{expand:n,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:c,guard:u,...l}=r.nodes[a];o[a]=l}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return Pn(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??Te,{codec:o,codecVersion:s,payload:i}=$n(e,r);return o.decode(i,s)}restore(e,n){if(qr(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(s=>Nt(s)),o=n?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let c=this.tryResolve(s)?.v;if(c!=null&&c.id===i.v.id&&c.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(e,n){qr(e);let r=typeof n=="function"?n:n?.build,o=typeof n=="function"?void 0:n?.factories,s=new t(e.name);if(r)return r(s),s.restore(e),s;for(let h of[...e.subgraphs].sort((d,g)=>{let m=d.split(L).length,v=g.split(L).length;return m!==v?m-v:d<g?-1:d>g?1:0})){let d=h.split(L),g=s;for(let m of d)g._mounts.has(m)||g.mount(m,new t(m)),g=g._mounts.get(m)}let i=o?Object.entries(o).map(([h,d])=>({re:Nt(h),factory:d})):[],a=h=>{for(let d of i)if(d.re.test(h))return d.factory},c=h=>{let d=h.split(L),g=d.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${h}"`);let m=s;for(let v of d){let _=m._mounts.get(v);if(!_)throw new Error(`unknown mount "${v}" in path "${h}"`);m=_}return[m,g]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${L}${te}${L}`)).sort((h,d)=>h[0]<d[0]?-1:h[0]>d[0]?1:0),l=new Map(u),f=new Map,p=!0;for(;l.size>0&&p;){p=!1;for(let[h,d]of[...l.entries()]){let g=d?.deps??[];if(!g.every(w=>f.has(w)))continue;let[m,v]=c(h),_={...d?.meta??{}},b=a(h),y;if(d?.type==="state")y=V(d.value,{meta:_});else{if(b==null)continue;y=b(v,{path:h,type:d.type,value:d.value,meta:_,deps:g,resolvedDeps:g.map(w=>f.get(w))})}m.add(y,{name:v}),f.set(h,y),l.delete(h),p=!0}}if(l.size>0){let h=[...l.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let o=(u,l)=>{if(u.disposed)return;let f=ys(l.nodes);if(u.lastSnapshot!=null&&f!==""&&f===u.lastFingerprint)return;let p=u.seq+1,h=he(),m=u.lastSnapshot==null||p%u.compactEvery===0?{mode:"full",snapshot:l,seq:p,timestamp_ns:h,format_version:Ne}:{mode:"diff",diff:Jr(u.lastSnapshot,l),seq:p,timestamp_ns:h,format_version:Ne};if(u.tier.filter&&!u.tier.filter(this.name,m))return;let v;try{v=u.tier.save(this.name,m)}catch(_){n.onError?.(_,u.tier);return}if(v&&typeof v.then=="function"){let y=(u.savePending??Promise.resolve()).then(()=>v,()=>v).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=l,u.lastFingerprint=f)},w=>{n.onError?.(w,u.tier)});u.savePending=y.finally(()=>{u.savePending===y&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=l,u.lastFingerprint=f},s=(u,l)=>{try{o(u,l)}catch(f){n.onError?.(f,u.tier)}},i=(u,l)=>{if(!l.some(d=>{let g=this.config.messageTier(d[0]);return g>=3&&g<5}))return;if(n.filter){let d=this.tryResolve(u);if(d==null)return;let g=rn(d,vt("standard"));if(!n.filter(u,g))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let d of r)d.disposed||(d.debounceMs===0?s(d,h()):(d.timer==null&&(d.timer=new _t),d.timer.start(d.debounceMs,()=>{d.disposed||s(d,this.snapshot())})))},a;if(n.paths!=null){let l=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(f=>{let p=this.tryResolve(f);return p==null?()=>{}:p.subscribe(h=>i(f,h))});a=()=>{for(let f of l)f()}}else a=this.observe().subscribe((u,l)=>i(u,l));let c=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(c)};return this._storageDisposers.add(c),{dispose:c}}async _cascadeRestore(e,n){for(let r of e){let o;try{o=await r.load(this.name)}catch(i){n?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===Ne&&s.nodes!=null)return this.restore(s),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let o of n){let s;try{s=await o.load(e)}catch(c){r?.onError?.(c,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===Ne&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(c){r?.onError?.(c,o)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,n,r){if(e!=null&&n!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,n),this.config.inspectorEnabled){let o={path:e,annotation:n,timestamp_ns:Me(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(o=>!e(o)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let o of n)this._traceRing.push(o);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(n.nodes)),s=[...o].filter(_=>!r.has(_)).sort(),i=[...r].filter(_=>!o.has(_)).sort(),a=[],c=[];for(let _ of r){if(!o.has(_))continue;let b=e.nodes[_],y=n.nodes[_],w=b.v,T=y.v;w!=null&&T!=null&&w.id===T.id&&w.version!==T.version&&c.push({path:_,id:w.id,from:w.version,to:T.version});let x=w!=null&&T!=null&&w.id===T.id&&w.version===T.version;for(let O of["type","status","sentinel"]){let N=b[O],M=y[O];N!==M&&a.push({path:_,field:O,from:N,to:M})}if(!x)for(let O of["value","meta"]){let N=b[O],M=y[O];vs(N,M)||a.push({path:_,field:O,from:N,to:M})}}let u=_=>`${_.from} ${_.to}`,l=new Set(e.edges.map(u)),f=new Set(n.edges.map(u)),p=n.edges.filter(_=>!l.has(u(_))),h=e.edges.filter(_=>!f.has(u(_))),d=new Set(e.subgraphs),g=new Set(n.subgraphs),m=[...g].filter(_=>!d.has(_)).sort(),v=[...d].filter(_=>!g.has(_)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:c,edgesAdded:p,edgesRemoved:h,subgraphsAdded:m,subgraphsRemoved:v}}};function Jr(t,e){let n=ne.diff(t,e),r={};for(let o of n.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...n,nodesAddedFull:r}}function un(t,e,n,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,c=new Map,u=new Map,l=new Set;for(let[b,y]of Object.entries(t.nodes)){if(!b)continue;l.add(b);let w=y.deps??[];i.set(b,w);for(let T of w)T&&(l.add(T),a.has(T)||a.set(T,new Set),a.get(T).add(b))}for(let b of t.edges){if(b==null||typeof b!="object")continue;let y=typeof b.from=="string"?b.from:"",w=typeof b.to=="string"?b.to:"";!y||!w||(l.add(y),l.add(w),u.has(y)||u.set(y,new Set),u.get(y).add(w),c.has(w)||c.set(w,new Set),c.get(w).add(y))}if(!l.has(e))return r.withDetail?o:[];let f=r.both===!0,p=b=>{if(f){let x=i.get(b)??[],O=c.get(b),N=a.get(b),M=u.get(b),S=[...x];return O&&S.push(...O),N&&S.push(...N),M&&S.push(...M),S}if(n==="upstream"){let x=i.get(b)??[],O=c.get(b);return O?[...x,...O]:x}let y=a.get(b),w=u.get(b),T=y?[...y]:[];return w&&T.push(...w),T},h=new Set([e]),d=new Map,g=[{path:e,depth:0}],m=0,v=!1;for(;m<g.length;){let b=g[m++];if(s!=null&&b.depth>=s){p(b.path).length>0&&(v=!0);continue}for(let y of p(b.path))!y||h.has(y)||(h.add(y),d.set(y,b.depth+1),g.push({path:y,depth:b.depth+1}))}let _=[...d.keys()].sort((b,y)=>b<y?-1:b>y?1:0);return r.withDetail?{paths:_,depths:d,truncated:v}:_}function Gs(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],o=e[n];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}we();Xe();De();Ue();De();Ge();de();we();W();de();var cn=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,n){if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=n,n!==void 0){if(this._buf=new Array(n),e&&e.length>0){let r=Math.min(e.length,n),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._size+e;if(!(n<0||n>=this._size))return this._maxSize!==void 0?this._buf[(this._head+n)%this._maxSize]:this._buf[n]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=n;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let n=0;n<e;n++)this._buf[(this._head+n)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let n=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,n);else{for(let r=0;r<n;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+n)%this._maxSize}return this._size-=n,this._version+=1,n}slice(e,n){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(n!==void 0&&(!Number.isInteger(n)||n<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${n})`);let r=n===void 0?this._size:Math.min(Math.max(n,0),this._size),o=Math.min(e,this._size);if(o>=r)return[];let s=r-o;if(this._maxSize===void 0)return this._buf.slice(o,r);let i=new Array(s);for(let a=0;a<s;a++)i[a]=this._buf[(this._head+o+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let n=Math.min(e,this._size);return this.slice(this._size-n,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this._buf[(this._head+n)%this._maxSize];return e}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function Qr(t){return t.subscribe(()=>{})}var Is=64;function Xr(t,e={}){let{name:n,maxSize:r,versioning:o,backend:s}=e,i=s??new cn(t,r),a=V(i.toArray(),{name:n,describeKind:"state",equals:(d,g)=>d===g,...o!=null?{versioning:o}:{}});function c(){let d=i.toArray();ce(()=>{a.down([[I]]),a.down([[E,d]])})}let u=new Map,l=new Map;function f(d,g){return`${d}:${g===void 0?"END":g}`}function p(d){if(d.size<Is)return;let g=d.keys().next();if(g.done)return;let m=d.get(g.value);m!==void 0&&m.dispose(),d.delete(g.value)}function h(d){let g=i.version;try{return d()}finally{i.version!==g&&c()}}return{entries:a,get size(){return i.size},at(d){return i.at(d)},append(d){h(()=>i.append(d))},appendMany(d){d.length!==0&&h(()=>i.appendMany(d))},clear(){h(()=>i.clear())},trimHead(d){h(()=>i.trimHead(d))},tail(d){if(!Number.isInteger(d)||d<0)throw new RangeError(`tail: n must be a non-negative integer (got ${d})`);let g=u.get(d);if(g!==void 0)return u.delete(d),u.set(d,g),g.node;p(u);let m=ie([a],([_])=>{let b=_;return d===0||b.length===0?[]:b.slice(Math.max(0,b.length-d))},{initial:i.tail(d),describeKind:"derived"}),v=Qr(m);return u.set(d,{node:m,dispose:v}),m},slice(d,g){if(!Number.isInteger(d)||d<0)throw new RangeError(`slice: start must be a non-negative integer (got ${d})`);if(g!==void 0&&(!Number.isInteger(g)||g<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${g})`);let m=f(d,g),v=l.get(m);if(v!==void 0)return l.delete(m),l.set(m,v),v.node;p(l);let _=ie([a],([y])=>{let w=y;return g===void 0?w.slice(d):w.slice(d,g)},{initial:i.slice(d,g),describeKind:"derived"}),b=Qr(_);return l.set(m,{node:_,dispose:b}),_},disposeTail(d){let g=u.get(d);return g===void 0?!1:(g.dispose(),u.delete(d),!0)},disposeSlice(d,g){let m=f(d,g),v=l.get(m);return v===void 0?!1:(v.dispose(),l.delete(m),!0)},disposeAllViews(){for(let d of u.values())d.dispose();u.clear();for(let d of l.values())d.dispose();l.clear()},dispose(){for(let d of u.values())d.dispose();u.clear();for(let d of l.values())d.dispose();l.clear()}}}gt();function Zr(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}var Ls=dt((t,e)=>{t("write"),t("signal"),e("observe")}),Ps=dt((t,e)=>{t("observe"),t("signal"),e("write")}),$s=dt((t,e)=>{t("observe"),t("signal"),e("write")});function At(t,e){return Zr("cqrs",t,e)}var dn=class extends ne{_eventLogs=new Map;_commandHandlers=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_eventStore;_seq=0;constructor(e,n={}){super(e,n.graph)}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}event(e){let n=this._eventLogs.get(e);if(n)return n.node;let r=Xr([],{name:e,versioning:0}),o=r.entries,s=ie([o],([i])=>i,{name:e,describeKind:"state",meta:At("event",{event_name:e}),guard:$s,initial:o.cache});return this.add(s,{name:e}),this._keepaliveDisposers.push(ge(s)),this._eventLogs.set(e,{log:r,node:s}),s}_appendEvent(e,n){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 o=r.log.entries.v,s={type:e,payload:n,timestampNs:he(),seq:++this._seq,...o!=null?{v0:{id:o.id,version:o.version}}:{}};r.log.append(s),this._eventStore&&this._eventStore.persist(s)}command(e,n){let r=V(void 0,{name:e,describeKind:"state",meta:{...At("command",{command_name:e}),error:null},guard:Ls});return this.add(r,{name:e}),this._commandHandlers.set(e,n),r}dispatch(e,n){let r=this._commandHandlers.get(e);if(!r)throw new Error(`Unknown command: "${e}". Register with .command() first.`);let o=this.resolve(e);ce(()=>{o.emit(n,{internal:!0});try{r(n,{emit:(s,i)=>this._appendEvent(s,i)}),o.meta.error.emit(null,{internal:!0})}catch(s){throw o.meta.error.emit(s,{internal:!0}),s}})}projection(e,n,r,o){let s=n.map(a=>(this._eventLogs.has(a)||this.event(a),this._eventLogs.get(a).node)),i=ie(s,a=>{let c=[];for(let u of a){let l=u;c.push(...l)}return c.sort((u,l)=>u.timestampNs-l.timestampNs||u.seq-l.seq),r(o,c)},{name:e,describeKind:"derived",meta:At("projection",{projection_name:e,source_events:n}),guard:Ps,initial:o});return this.add(i,{name:e}),this._keepaliveDisposers.push(ge(i)),this._projections.add(e),i}saga(e,n,r){let o=n.map(c=>(this._eventLogs.has(c)||this.event(c),this._eventLogs.get(c).node)),s=new Map,i={},a=Ee(o,(c,u)=>{let l=i.n.meta.error;for(let f=0;f<c.length;f++){let p=c[f];if(p==null||p.length===0)continue;let h=p.at(-1);if(!h)continue;let d=n[f],g=s.get(d)??0;if(h.length>g){let m=h.slice(g);for(let v of m)try{r(v),l.emit(null,{internal:!0})}catch(_){l.emit(_,{internal:!0})}s.set(d,h.length)}}},{name:e,describeKind:"effect",meta:{...At("saga",{saga_name:e,source_events:n}),error:null}});return i.n=a,this.add(a,{name:e}),this._keepaliveDisposers.push(ge(a)),this._sagas.add(e),a}useEventStore(e){this._eventStore=e}async rebuildProjection(e,n,r){if(!this._eventStore)throw new Error("No event store wired. Call useEventStore() first.");let o=[];for(let s of e){let i=await this._eventStore.loadEvents(s);o.push(...i.events)}return o.sort((s,i)=>s.timestampNs-i.timestampNs||s.seq-i.seq),n(r,o)}};function eo(t,e){return new dn(t,e)}var fn=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},pn=class{graph=new ne("request");onModuleDestroy(){this.graph.destroy()}},to,ln;to=[(0,st.Module)({})];var be=class be{static forRoot(e){let n=e??{},r=n.name??"root",o=[{provide:ee,useFactory:()=>{let s=new ne(r);return n.build&&n.build(s),n.snapshot&&s.restore(n.snapshot),s}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:s=>new fn(s),inject:[ee]},{provide:Re,useFactory:(s,i)=>new Re(s,i),inject:[ee,no.ModuleRef]}];if(n.nodes)for(let s of n.nodes)o.push({provide:ae(s),useFactory:i=>i.resolve(s),inject:[ee]});return n.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new pn,scope:st.Scope.REQUEST},{provide:Oe,useFactory:s=>s.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:st.Scope.REQUEST}),{module:be,global:!0,providers:o,exports:[ee,...(n.nodes??[]).map(ae),...n.requestScope?[Oe]:[]]}}static forFeature(e){let n=[{provide:K(e.name),useFactory:r=>{let o=new ne(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),r.mount(e.name,o),o},inject:[ee]}];if(e.nodes)for(let r of e.nodes)n.push({provide:ae(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[K(e.name)]});return{module:be,providers:n,exports:[K(e.name),...(e.nodes??[]).map(r=>ae(`${e.name}::${r}`))]}}static forCqrs(e){let n=[{provide:K(e.name),useFactory:r=>{let o=eo(e.name,e.cqrs);return e.eventStore&&o.useEventStore(e.eventStore),e.build&&e.build(o),r.mount(e.name,o),o},inject:[ee]}];if(e.nodes)for(let r of e.nodes)n.push({provide:ae(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[K(e.name)]});return{module:be,providers:n,exports:[K(e.name),...(e.nodes??[]).map(r=>ae(`${e.name}::${r}`))]}}};ln=An(null),be=Mn(ln,0,"GraphReflyModule",to,be),Cn(ln,1,be);var kt=be;var gn={};ue(gn,{useStore:()=>Hs,useSubscribe:()=>ro,useSubscribeRecord:()=>Fs});var le=require("react");W();function ro(t){return(0,le.useSyncExternalStore)(e=>{let n=!1,r=t.subscribe(()=>{n||e()});return()=>{n=!0,r()}},()=>t.cache,()=>t.cache)}function Hs(t){let e=ro(t),n=(0,le.useCallback)(r=>{t.down([[I],[E,r]])},[t]);return[e,n]}function Fs(t,e){let n=(0,le.useRef)(e);n.current=e;let r=(0,le.useMemo)(()=>{let o=()=>{let i={},a=t.cache??[];for(let c of a){let u=n.current(c),l={};for(let f of Object.keys(u))l[f]=u[f].cache;i[c]=l}return i},s=o();return{subscribe:i=>{let a=!1,c=[],u=()=>{for(let p of c)p();c=[]},l=p=>{u();for(let h of p){let d=n.current(h);for(let g of Object.keys(d)){let m=d[g].subscribe(()=>{s=o(),a||i()});c.push(m)}}s=o(),a||i()},f=t.subscribe(p=>{let h=p.some(d=>d[0]===E||d[0]===B);!a&&h&&l(t.cache??[])});return l(t.cache??[]),()=>{a=!0,f(),u()}},getSnapshot:()=>s}},[t]);return(0,le.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot)}var yn={};ue(yn,{Signal:()=>js});we();W();de();var qe=[];function Ct(t){let e=t.cache;return t.subscribe(r=>{for(let[o,s]of r)o===E&&(e=s)})(),e}var mn=class{_node;_equals;constructor(e,n){this._equals=n?.equals??Object.is,this._node=V(e,{...n,resubscribable:!0,resetOnTeardown:!0})}get(){let e=qe[qe.length-1];return e?(this._node.status==="sentinel"&&Ct(this._node),e(this._node)):this._node.status==="sentinel"?Ct(this._node):this._node.cache}set(e){this._equals(this.get(),e)||ce(()=>{this._node.down([[I],[E,e]])})}},bn=class{_node;constructor(e,n){this._node=Ze(r=>{qe.push(r);try{return e()}finally{qe.pop()}},{...n,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=qe[qe.length-1];return e?(this._node.status==="sentinel"&&Ct(this._node),e(this._node)):this._node.status==="sentinel"?Ct(this._node):this._node.cache}},js={State:mn,Computed:bn,sub:(t,e)=>{let n=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,r=!0;return t._node.subscribe(o=>{for(let[s,i]of o){if(s===E){if(r){r=!1;continue}n.data?.(i)}s===C&&n.error?.(i),s===P&&n.complete?.()}})}};var vn={};ue(vn,{useStore:()=>Vs,useSubscribe:()=>oo,useSubscribeRecord:()=>qs});var fe=require("solid-js");W();function oo(t){let[e,n]=(0,fe.createSignal)(t.cache,{equals:!1}),r=t.subscribe(()=>{n(()=>t.cache)});return(0,fe.getOwner)()?(0,fe.onCleanup)(()=>r()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),e}function Vs(t){return[oo(t),r=>{t.down([[I],[E,r]])}]}function qs(t,e){let[n,r]=(0,fe.createSignal)({},{equals:!1}),o=[],s=()=>{for(let u of o)u();o=[]},i=()=>{let u={};for(let l of t.cache??[]){let f=e(l),p={};for(let h of Object.keys(f))p[h]=f[h].cache;u[l]=p}return u},a=u=>{s();for(let l of u){let f=e(l);for(let p of Object.keys(f)){let h=f[p].subscribe(()=>{r(()=>i())});o.push(h)}}r(()=>i())},c=t.subscribe(u=>{u.some(l=>l[0]===E||l[0]===B)&&a(t.cache??[])});return a(t.cache??[]),(0,fe.getOwner)()?(0,fe.onCleanup)(()=>{c(),s()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),n}var _n={};ue(_n,{useStore:()=>Bs,useSubscribe:()=>Ws,useSubscribeRecord:()=>zs});W();function Ws(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n}}}function Bs(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n},set(e){t.down([[I],[E,e]])},update(e){let n=e(t.cache);t.down([[I],[E,n]])}}}function zs(t,e){return{subscribe(n){let r=[],o=()=>{for(let c of r)c();r=[]},s=()=>{let c={};for(let u of t.cache??[]){let l=e(u),f={};for(let p of Object.keys(l))f[p]=l[p].cache;c[u]=f}return c},i=c=>{o();for(let u of c){let l=e(u);for(let f of Object.keys(l)){let p=l[f].subscribe(()=>{n(s())});r.push(p)}}n(s())},a=t.subscribe(c=>{c.some(u=>u[0]===E||u[0]===B)&&i(t.cache??[])});return i(t.cache??[]),()=>{a(),o()}}}}var xn={};ue(xn,{useStore:()=>Us,useSubscribe:()=>Ks,useSubscribeRecord:()=>Ys});var H=require("vue");W();function Ks(t){let e=(0,H.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,H.getCurrentScope)()?(0,H.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,H.readonly)(e)}function Us(t){let e=(0,H.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,H.getCurrentScope)()?(0,H.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useStore called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,H.computed)({get:()=>e.value,set:r=>{t.down([[I],[E,r]])}})}function Ys(t,e){let n=(0,H.shallowRef)({}),r=new Map;function o(){let a={};for(let[c,u]of r)a[c]={...u.values};n.value=a}function s(a){for(let u of r.values())for(let l of u.subs)l();r.clear();for(let u of a){let l=e(u),f=Object.keys(l),p={},h=[];for(let d of f){let g=l[d];p[d]=g.cache;let m=g.subscribe(()=>{p[d]=g.cache,o()});h.push(m)}r.set(u,{subs:h,values:p})}let c={};for(let[u,l]of r)c[u]={...l.values};n.value=c}return(0,H.watch)(()=>[...(typeof t=="function"?t():(0,H.isRef)(t)?t.value:t)??[]],a=>s(a??[]),{immediate:!0}),(0,H.getCurrentScope)()?(0,H.onScopeDispose)(()=>{for(let a of r.values())for(let c of a.subs)c();r.clear()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,H.readonly)(n)}var wn={};ue(wn,{create:()=>Qs});W();de();var Js=()=>!1;function Qs(t){let e=new ne("zustand"),n=V(void 0,{name:"state",equals:Js});e.add(n,{name:"state"});let r=()=>n.cache,o=(a,c)=>{let u=n.cache,l=typeof a=="function"?a(u):a;n.emit(c?l:{...u,...l})},s={getState:r,setState:o,getInitialState:()=>i,subscribe:a=>{let c=!0,u=n.cache;return n.subscribe(l=>{for(let[f,p]of l)if(f===E){if(c){c=!1;continue}a(p,u),u=p}})},destroy:e.destroy.bind(e)},i=t(o,r,s);return n.emit(i),Object.assign(e,s)}0&&(module.exports={jotai,nanostores,nestjs,react,signals,solid,svelte,vue,zustand});
|
|
15
|
+
`)}function Ns(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Nt(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let o=t.indexOf("]",n+1);if(o<=n+1){e+="\\[";continue}let s=t.slice(n+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,n=o;continue}e+=Ns(r)}return e+="$",new RegExp(e)}var Ss={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"},As={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function St(t){if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||t==null)return String(t);try{return JSON.stringify(t)}catch{return"[unserializable]"}}function ks(t){return t==="none"?As:t==="ansi"||t==null?Ss:{data:t.data??"",dirty:t.dirty??"",resolved:t.resolved??"",invalidate:t.invalidate??"",pause:t.pause??"",resume:t.resume??"",complete:t.complete??"",error:t.error??"",teardown:t.teardown??"",derived:t.derived??"",path:t.path??"",reset:t.reset??""}}function Wr(t){if(t==null)return{};let e=t.detail;return e==="full"?{...t,structured:t.structured??!0,timeline:t.timeline??!0,causal:t.causal??!0,derived:t.derived??!0}:e==="minimal"?{...t,structured:t.structured??!0}:t.format==="stage-log"?{...t,structured:t.structured??!0,timeline:t.timeline??!0}:t}function Cs(t,e,n){for(let r=0;r<t.length;r++){let o=t.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function sn(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(L))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${L}' (path separator)`);if(t===te)throw new Error(`Graph "${e}": ${n} name "${te}" is reserved for meta companion paths`);Cs(t,e,n)}function Ms(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(L);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function Ds(t,e){let n=!1;for(let o of t)if(!e.isMetaPassthrough(o[0])){n=!0;break}return n?t.filter(o=>e.isMetaPassthrough(o[0])):t}function Yr(t){for(let e of t._mounts.values())Yr(e);for(let e of t._nodes.values())try{e.down([[q]],{internal:!0})}catch{}}var ne=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(L))throw new Error(`Graph name must not contain '${L}' (got "${e}")`);if(e===te)throw new Error(`Graph name "${te}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??Te,this._traceRing=new ot(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=Ie(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}add(e,n){let r=e.name,o=n?.name??r;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=n?.annotation;if(sn(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:Me()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof $&&n._applyVersioning(e)}remove(e){sn(e,this.name,"remove");let n=this._mounts.get(e);if(n){let s={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,c]of i)a.includes(`${L}${te}${L}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...n._collectSubgraphs(`${e}${L}`)),this._mounts.delete(e),n._parent=void 0,Yr(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[q]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let n=typeof e=="function"?e:(()=>{let s=Nt(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>n(s));for(let s of o){let i=this.remove(s);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let o=e[r++];return{value:[o,n.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(L))return this.resolve(e);let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return n}get(e){return this.node(e).cache}set(e,n,r){let o=r?.internal===!0;this.node(e).down([[E,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);ce(()=>{for(let[o,s]of r)this.set(o,s,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[oe]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let o=r?.internal===!0;this.node(e).down([[C,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[P]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[c,u]of this._nodes)r.set(u,c);let a=[];for(let[c,u]of this._nodes)if(u instanceof $)for(let l of u._deps){let f=r.get(l.node);f!=null&&a.push([f,c])}return a.sort((c,u)=>c[0]<u[0]?-1:c[0]>u[0]?1:c[1]<u[1]?-1:c[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,c]of o)s.set(c,a);let i=[];for(let[a,c]of o)if(c instanceof $)for(let u of c._deps){let l=s.get(u.node);l!=null&&i.push([l,a])}return i.sort((a,c)=>a[0]<c[0]?-1:a[0]>c[0]?1:a[1]<c[1]?-1:a[1]>c[1]?1:0),i}mount(e,n){if(sn(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let n=Ms(e,this.name);return this._resolveFromSegments(n)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let n=e;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],o=n.slice(1);if(o.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let s=this._nodes.get(r);if(s&&o.length>0&&o[0]===te)return this._resolveMetaChainFromNode(s,o,n.join(L));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(L)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(L))}_resolveMetaChainFromNode(e,n,r){let o=e,s=0,i=[...n];for(;s<i.length;){if(i[s]!==te)throw new Error(`Graph "${this.name}": expected ${te} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${te} in "${r}"`);let a=i[s+1],c=o.meta[a];if(!c)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=c,s+=2}return o}signal(e,n){if(n?.internal!==!0){for(let o of e)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,o){for(let c of this._mounts.values())c._signalDeliver(e,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=Ds(e,this.config);for(let c of[...this._nodes.keys()].sort()){let u=this._nodes.get(c);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(l){if(l instanceof Z)throw l;o.push(l)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,o)}}}_signalMetaSubtree(e,n,r,o,s){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,o)}catch(c){if(c instanceof Z)throw c;s.push(c)}this._signalMetaSubtree(a,n,r,o,s)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,o=vt(e?.detail,e?.fields),s=e?.format==="spec",i=s?vt("minimal"):o,a=[];this._collectObserveTargets("",a);let c=new Map;for(let[T,x]of a)c.set(x,T);let u=[];{let T=a.map(([,N])=>N),x=new Set(c.values()),O=0;for(;T.length>0;){let N=T.shift();if(N instanceof $)for(let M of N._deps){let S=M.node;if(c.has(S))continue;let k=S.name??"",A=k;if(!A||x.has(A))if(k){let F=2;for(;x.has(`${k}#${F}`);)F++;A=`${k}#${F}`}else for(A=`__internal__/${O++}`;x.has(A);)A=`__internal__/${O++}`;c.set(S,A),x.add(A),u.push([A,S]),T.push(S)}}}let l=[...a,...u],f={};for(let[T,x]of l){if(n!=null&&!x.allowsObserve(n))continue;let O=rn(x,i),N=x instanceof $?x._deps.map(A=>c.get(A.node)??A.node.name??""):[],{name:M,...S}=O,k={...S,deps:N};if(!s){let A=this._annotations.get(T);A!=null&&(k.annotation=A)}if(r!=null)if(typeof r=="function"){let A=r;if(!(A.length>=2?A(T,k):A(k)))continue}else{let A=!0;for(let[F,U]of Object.entries(r)){let re=F==="deps_includes"?"depsIncludes":F==="meta_has"?"metaHas":F;if(re==="depsIncludes"){if(!k.deps.includes(String(U))){A=!1;break}continue}if(re==="metaHas"){if(!Object.hasOwn(k.meta??{},String(U))){A=!1;break}continue}if(k[re]!==U){A=!1;break}}if(!A)continue}f[T]=k}let p=new Set(Object.keys(f)),h=[];for(let[T,x]of l)if(x instanceof $)for(let O of x._deps){let N=c.get(O.node);N!=null&&h.push([N,T])}h.sort((T,x)=>T[0]<x[0]?-1:T[0]>x[0]?1:T[1]<x[1]?-1:T[1]>x[1]?1:0);let d=h.map(([T,x])=>({from:T,to:x}));(n!=null||r!=null)&&(d=d.filter(T=>p.has(T.from)&&p.has(T.to)));let g=this._collectSubgraphs(""),m=n!=null||r!=null?g.filter(T=>{let x=`${T}${L}`;return[...p].some(O=>O===T||O.startsWith(x))}):g,v=this,_=e,b={name:this.name,nodes:f,edges:d,subgraphs:m,expand(T){let x={..._,format:void 0};return Array.isArray(T)?(x.fields=T,x.detail=void 0):(x.detail=T,x.fields=void 0),v.describe(x)}},y=e??{},w=y.format;return w==="json"?Ts(b,y):w==="pretty"?Es(b,y):w==="mermaid"?Kr(b,y):w==="mermaid-url"?Os(b,y):w==="d2"?Rs(b,y):w==="ascii"?Ir(b,y):b}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;n.push(o),n.push(...this._mounts.get(r)._collectSubgraphs(`${o}${L}`))}return n}resourceProfile(e){return jr(this,e)}reachable(e,n,r={}){return r.withDetail===!0?un(this.describe(),e,n,{...r,withDetail:!0}):un(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,c]of Object.entries(o.nodes))c.lastMutation!=null&&i.set(a,c.lastMutation);return Lr(o,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=V(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=()=>{a||c||(a=!0,Qe(()=>{a=!1,!c&&(o+=1,s.emit(o))}))},l=i.onEvent(m=>{let v=m.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||u()}),f=[],p=new WeakSet,h=m=>{if(p.has(m)||c)return;p.add(m);let v=m.topology.subscribe(_=>{for(let b of _){if(b[0]!==E)continue;let y=b[1];if(u(),y.kind==="added"&&y.nodeKind==="mount"){let w=m._mounts.get(y.name);w!=null&&h(w)}}});f.push(v);for(let _ of m._mounts.keys()){let b=m._mounts.get(_);b!=null&&h(b)}};h(this);let d;try{d=ie([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,v)=>m===v})}catch(m){l();for(let v of f)v();throw i.dispose(),m}let g=ge(d);return{node:d,dispose(){c=!0,l();for(let m of f)m();f.length=0,i.dispose(),g()}}}_explainReactive(e,n,r){let o=0,s=V(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=i.onEvent(h=>{let d=h.type;d!=="data"&&d!=="error"&&d!=="complete"&&d!=="teardown"||a||c||(a=!0,Qe(()=>{a=!1,!c&&(o+=1,s.emit(o))}))}),l={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},f;try{f=ie([s],()=>this._explainStatic(e,n,l),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(h,d)=>h.found===d.found&&h.reason===d.reason&&h.steps.length===d.steps.length&&Gs(h.steps,d.steps)})}catch(h){throw u(),i.dispose(),h}let p=ge(f);return{node:f,dispose(){c=!0,u(),i.dispose(),p()}}}_pathsMatching(e){let n=Nt(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>n.test(o))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${L}${r}`;this._mounts.get(r)._collectObserveTargets(o,n)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${L}${r}`;n.push([s,o]),this._appendMetaObserveTargets(s,o,n)}}_appendMetaObserveTargets(e,n,r){for(let o of Object.keys(n.meta).sort()){let s=n.meta[o],i=`${e}${L}${te}${L}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,n){let r=typeof e=="string",s=Wr(r?n:e),i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let l=e,f=this.resolve(l);if(a!=null&&!f.allowsObserve(a))throw new Z({actor:a,action:"observe",nodeName:l});return i?this._buildStructuredObserver([[l,f]],s,"one"):{subscribe(p){return f.subscribe(p)},up(p){try{f.up?.(p)}catch(h){if(h instanceof Z)return;throw h}}}}let c=[];this._collectObserveTargets("",c),c.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let u=a==null?c:c.filter(([,l])=>l.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:l=>{let f=u.map(([p,h])=>h.subscribe(d=>{l(p,d)}));return()=>{for(let p of f)p()}},up:(l,f)=>{try{this.resolve(l).up?.(f)}catch(p){if(p instanceof Z)return;throw p}}}}_buildStructuredObserver(e,n,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let l=this.resolve(o);return this._buildStructuredObserver([[o,l]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let c=i.actor,u=c==null?a:a.filter(([,l])=>l.allowsObserve(c));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,s)}_createObserveResult(e,n,r){let o=n.timeline===!0,s=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",c=this.config.inspectorEnabled,u=(s||i)&&c,l=n.maxEvents,f=l!=null&&l>0?new ot(l):null,p=[],h=new Set,d={},g=new Set,m=0,v=0,_=0,b=0,y=0,w=0,T=!1,x=!1,O=0,N=new Map,M=new Map,S=new Map,k=R=>{f?f.push(R):p.push(R);for(let G of h)G(R)},A=()=>o?{timestamp_ns:Me(),in_batch:at(),batch_id:O}:{},F=(R,G)=>{if(!(!u||!(R instanceof $)))return R._setInspectorHook(J=>{if(J.kind==="dep_message")N.set(R,J.depIndex);else if(J.kind==="run"){let We=J.batchData.map((D,z)=>D!=null&&D.length>0?D.at(-1):J.prevData[z]);M.set(R,We);let Q=J.batchData.map(D=>D!=null?[...D]:void 0);S.set(R,Q),i&&k({type:"derived",path:G,dep_values:We,dep_batches:Q,...A()})}})},U=R=>{let G=N.get(R),J=M.get(R);if(!s||J==null)return{};let Q=(G!=null&&G>=0&&R instanceof $?R._deps[G]:void 0)?.node,D=Q?.v,z=S.get(R);return{trigger_dep_index:G,trigger_dep_name:Q?.name,...D!=null?{trigger_version:{id:D.id,version:D.version}}:{},dep_values:[...J],...z!=null?{dep_batches:z}:{}}},re=[],ye=[];for(let[R,G]of e){let J=F(G,R);J&&re.push(J),ye.push(G.subscribe(We=>{O++;for(let Q of We){let D=Q[0],z=A();if(D===E){d[R]=Q[1];let It=G instanceof $?G.lastMutation?.actor??pe:pe;k({type:"data",path:R,data:Q[1],actor:It,...z,...U(G)})}else if(a)D===I?m++:D===B?v++:D===oe?_++:D===X?b++:D===se?y++:D===q?w++:D===P&&!g.has(R)?T=!0:D===C&&(x=!0,g.add(R));else if(D===I)m++,k({type:"dirty",path:R,...z});else if(D===B)v++,k({type:"resolved",path:R,...z,...U(G)});else if(D===oe)_++,k({type:"invalidate",path:R,...z});else if(D===X)b++,k({type:"pause",path:R,lockId:Q[1],...z});else if(D===se)y++,k({type:"resume",path:R,lockId:Q[1],...z});else if(D===P)g.has(R)||(T=!0),k({type:"complete",path:R,...z});else if(D===C){x=!0,g.add(R);let It=G instanceof $?G.lastMutation?.actor??pe:pe;k({type:"error",path:R,data:Q[1],actor:It,...z})}else D===q&&(w++,k({type:"teardown",path:R,...z}))}}))}let Mt=!1,Dt=()=>{if(!Mt){Mt=!0;for(let R of ye)R();for(let R of re)R();for(let R of it)R({value:void 0,done:!0});it.length=0}},Gt=[],it=[];h.add(R=>{let G=it.shift();G?G({value:R,done:!1}):Gt.push(R)});let Tn={get values(){return d},get dirtyCount(){return m},get resolvedCount(){return v},get invalidateCount(){return _},get pauseCount(){return b},get resumeCount(){return y},get teardownCount(){return w},get events(){return f?f.toArray():[...p]},get anyCompletedCleanly(){return T},get anyErrored(){return x},get completedWithoutErrors(){return T&&!x},onEvent(R){return h.add(R),()=>h.delete(R)},dispose:Dt,expand(R){Dt();let G={...n};return typeof R=="string"?G.detail=R:Object.assign(G,R),r(Wr(G))},[Symbol.asyncIterator](){return{next(){return Gt.length>0?Promise.resolve({value:Gt.shift(),done:!1}):Mt?Promise.resolve({value:void 0,done:!0}):new Promise(R=>it.push(R))},return(){return Dt(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Tn,n),Tn}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let o=n.logger??(d=>console.log(d)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:d=>(s==null||s.has(d))&&(i==null||!i.has(d)),c=ks(n.theme),u=r==="stage-log"?Me():0,l=d=>d==null?"":n.stageLabels?.[d]??d,f=(d,g)=>d.length>g?`${d.slice(0,g-1)}\u2026`:d,p=d=>d.type==="data"||d.type==="error"?f(St(d.data),120):"",h=d=>{if(r==="stage-log"){let x=(Me()-u)/1e9,O=l(d.path).padEnd(9);if(d.type==="data"){let N=p(d);return`[${x.toFixed(3)}s] ${O} \u2190${N?` ${N}`:""}`}if(d.type==="error"){let N=p(d);return`[${x.toFixed(3)}s] ${O} \u2717${N?` ${N}`:""}`}return d.type==="complete"?`[${x.toFixed(3)}s] ${O} \u25A0 complete`:`[${x.toFixed(3)}s] ${O} ${d.type}`}if(r==="json")try{return JSON.stringify(d)}catch{return JSON.stringify({type:d.type,path:d.path,data:"[unserializable]"})}let g=c[d.type]??"",m=d.path?`${c.path}${d.path}${c.reset} `:"",v=d.type==="data"||d.type==="error",_=d.type==="pause"||d.type==="resume",b=v?` ${St(d.data)}`:_?` ${St(d.lockId)}`:"",y=d.type==="data"||d.type==="resolved"||d.type==="derived"?d:void 0,w=y?.trigger_dep_name!=null?` <- ${y.trigger_dep_name}`:y?.trigger_dep_index!=null?` <- #${y.trigger_dep_index}`:"",T=d.in_batch?" [batch]":"";return`${m}${g}${d.type.toUpperCase()}${c.reset}${b}${w}${T}`};e.onEvent(d=>{a(d.type)&&o(h(d),d)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){Vr(this._disposers,this.name),this.signal([[q]],{internal:!0}),Vr(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:n,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:c,guard:u,...l}=r.nodes[a];o[a]=l}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return Pn(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??Te,{codec:o,codecVersion:s,payload:i}=$n(e,r);return o.decode(i,s)}restore(e,n){if(qr(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(s=>Nt(s)),o=n?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let c=this.tryResolve(s)?.v;if(c!=null&&c.id===i.v.id&&c.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(e,n){qr(e);let r=typeof n=="function"?n:n?.build,o=typeof n=="function"?void 0:n?.factories,s=new t(e.name);if(r)return r(s),s.restore(e),s;for(let h of[...e.subgraphs].sort((d,g)=>{let m=d.split(L).length,v=g.split(L).length;return m!==v?m-v:d<g?-1:d>g?1:0})){let d=h.split(L),g=s;for(let m of d)g._mounts.has(m)||g.mount(m,new t(m)),g=g._mounts.get(m)}let i=o?Object.entries(o).map(([h,d])=>({re:Nt(h),factory:d})):[],a=h=>{for(let d of i)if(d.re.test(h))return d.factory},c=h=>{let d=h.split(L),g=d.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${h}"`);let m=s;for(let v of d){let _=m._mounts.get(v);if(!_)throw new Error(`unknown mount "${v}" in path "${h}"`);m=_}return[m,g]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${L}${te}${L}`)).sort((h,d)=>h[0]<d[0]?-1:h[0]>d[0]?1:0),l=new Map(u),f=new Map,p=!0;for(;l.size>0&&p;){p=!1;for(let[h,d]of[...l.entries()]){let g=d?.deps??[];if(!g.every(w=>f.has(w)))continue;let[m,v]=c(h),_={...d?.meta??{}},b=a(h),y;if(d?.type==="state")y=V(d.value,{meta:_});else{if(b==null)continue;y=b(v,{path:h,type:d.type,value:d.value,meta:_,deps:g,resolvedDeps:g.map(w=>f.get(w))})}m.add(y,{name:v}),f.set(h,y),l.delete(h),p=!0}}if(l.size>0){let h=[...l.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let o=(u,l)=>{if(u.disposed)return;let f=ys(l.nodes);if(u.lastSnapshot!=null&&f!==""&&f===u.lastFingerprint)return;let p=u.seq+1,h=he(),m=u.lastSnapshot==null||p%u.compactEvery===0?{mode:"full",snapshot:l,seq:p,timestamp_ns:h,format_version:Ne}:{mode:"diff",diff:Jr(u.lastSnapshot,l),seq:p,timestamp_ns:h,format_version:Ne};if(u.tier.filter&&!u.tier.filter(this.name,m))return;let v;try{v=u.tier.save(this.name,m)}catch(_){n.onError?.(_,u.tier);return}if(v&&typeof v.then=="function"){let y=(u.savePending??Promise.resolve()).then(()=>v,()=>v).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=l,u.lastFingerprint=f)},w=>{n.onError?.(w,u.tier)});u.savePending=y.finally(()=>{u.savePending===y&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=l,u.lastFingerprint=f},s=(u,l)=>{try{o(u,l)}catch(f){n.onError?.(f,u.tier)}},i=(u,l)=>{if(!l.some(d=>{let g=this.config.messageTier(d[0]);return g>=3&&g<5}))return;if(n.filter){let d=this.tryResolve(u);if(d==null)return;let g=rn(d,vt("standard"));if(!n.filter(u,g))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let d of r)d.disposed||(d.debounceMs===0?s(d,h()):(d.timer==null&&(d.timer=new _t),d.timer.start(d.debounceMs,()=>{d.disposed||s(d,this.snapshot())})))},a;if(n.paths!=null){let l=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(f=>{let p=this.tryResolve(f);return p==null?()=>{}:p.subscribe(h=>i(f,h))});a=()=>{for(let f of l)f()}}else a=this.observe().subscribe((u,l)=>i(u,l));let c=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(c)};return this._storageDisposers.add(c),{dispose:c}}async _cascadeRestore(e,n){for(let r of e){let o;try{o=await r.load(this.name)}catch(i){n?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===Ne&&s.nodes!=null)return this.restore(s),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let o of n){let s;try{s=await o.load(e)}catch(c){r?.onError?.(c,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===Ne&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(c){r?.onError?.(c,o)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,n,r){if(e!=null&&n!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,n),this.config.inspectorEnabled){let o={path:e,annotation:n,timestamp_ns:Me(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(o=>!e(o)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let o of n)this._traceRing.push(o);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(n.nodes)),s=[...o].filter(_=>!r.has(_)).sort(),i=[...r].filter(_=>!o.has(_)).sort(),a=[],c=[];for(let _ of r){if(!o.has(_))continue;let b=e.nodes[_],y=n.nodes[_],w=b.v,T=y.v;w!=null&&T!=null&&w.id===T.id&&w.version!==T.version&&c.push({path:_,id:w.id,from:w.version,to:T.version});let x=w!=null&&T!=null&&w.id===T.id&&w.version===T.version;for(let O of["type","status","sentinel"]){let N=b[O],M=y[O];N!==M&&a.push({path:_,field:O,from:N,to:M})}if(!x)for(let O of["value","meta"]){let N=b[O],M=y[O];vs(N,M)||a.push({path:_,field:O,from:N,to:M})}}let u=_=>`${_.from} ${_.to}`,l=new Set(e.edges.map(u)),f=new Set(n.edges.map(u)),p=n.edges.filter(_=>!l.has(u(_))),h=e.edges.filter(_=>!f.has(u(_))),d=new Set(e.subgraphs),g=new Set(n.subgraphs),m=[...g].filter(_=>!d.has(_)).sort(),v=[...d].filter(_=>!g.has(_)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:c,edgesAdded:p,edgesRemoved:h,subgraphsAdded:m,subgraphsRemoved:v}}};function Jr(t,e){let n=ne.diff(t,e),r={};for(let o of n.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...n,nodesAddedFull:r}}function un(t,e,n,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,c=new Map,u=new Map,l=new Set;for(let[b,y]of Object.entries(t.nodes)){if(!b)continue;l.add(b);let w=y.deps??[];i.set(b,w);for(let T of w)T&&(l.add(T),a.has(T)||a.set(T,new Set),a.get(T).add(b))}for(let b of t.edges){if(b==null||typeof b!="object")continue;let y=typeof b.from=="string"?b.from:"",w=typeof b.to=="string"?b.to:"";!y||!w||(l.add(y),l.add(w),u.has(y)||u.set(y,new Set),u.get(y).add(w),c.has(w)||c.set(w,new Set),c.get(w).add(y))}if(!l.has(e))return r.withDetail?o:[];let f=r.both===!0,p=b=>{if(f){let x=i.get(b)??[],O=c.get(b),N=a.get(b),M=u.get(b),S=[...x];return O&&S.push(...O),N&&S.push(...N),M&&S.push(...M),S}if(n==="upstream"){let x=i.get(b)??[],O=c.get(b);return O?[...x,...O]:x}let y=a.get(b),w=u.get(b),T=y?[...y]:[];return w&&T.push(...w),T},h=new Set([e]),d=new Map,g=[{path:e,depth:0}],m=0,v=!1;for(;m<g.length;){let b=g[m++];if(s!=null&&b.depth>=s){p(b.path).length>0&&(v=!0);continue}for(let y of p(b.path))!y||h.has(y)||(h.add(y),d.set(y,b.depth+1),g.push({path:y,depth:b.depth+1}))}let _=[...d.keys()].sort((b,y)=>b<y?-1:b>y?1:0);return r.withDetail?{paths:_,depths:d,truncated:v}:_}function Gs(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],o=e[n];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}we();Xe();De();Ue();De();Ge();de();we();W();de();var cn=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,n){if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=n,n!==void 0){if(this._buf=new Array(n),e&&e.length>0){let r=Math.min(e.length,n),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._size+e;if(!(n<0||n>=this._size))return this._maxSize!==void 0?this._buf[(this._head+n)%this._maxSize]:this._buf[n]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=n;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let n=0;n<e;n++)this._buf[(this._head+n)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let n=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,n);else{for(let r=0;r<n;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+n)%this._maxSize}return this._size-=n,this._version+=1,n}slice(e,n){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(n!==void 0&&(!Number.isInteger(n)||n<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${n})`);let r=n===void 0?this._size:Math.min(Math.max(n,0),this._size),o=Math.min(e,this._size);if(o>=r)return[];let s=r-o;if(this._maxSize===void 0)return this._buf.slice(o,r);let i=new Array(s);for(let a=0;a<s;a++)i[a]=this._buf[(this._head+o+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let n=Math.min(e,this._size);return this.slice(this._size-n,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this._buf[(this._head+n)%this._maxSize];return e}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function Qr(t){return t.subscribe(()=>{})}var Is=64;function Xr(t,e={}){let{name:n,maxSize:r,versioning:o,backend:s}=e,i=s??new cn(t,r),a=V(i.toArray(),{name:n,describeKind:"state",equals:(d,g)=>d===g,...o!=null?{versioning:o}:{}});function c(){let d=i.toArray();ce(()=>{a.down([[I]]),a.down([[E,d]])})}let u=new Map,l=new Map;function f(d,g){return`${d}:${g===void 0?"END":g}`}function p(d){if(d.size<Is)return;let g=d.keys().next();if(g.done)return;let m=d.get(g.value);m!==void 0&&m.dispose(),d.delete(g.value)}function h(d){let g=i.version;try{return d()}finally{i.version!==g&&c()}}return{entries:a,get size(){return i.size},at(d){return i.at(d)},append(d){h(()=>i.append(d))},appendMany(d){d.length!==0&&h(()=>i.appendMany(d))},clear(){h(()=>i.clear())},trimHead(d){h(()=>i.trimHead(d))},tail(d){if(!Number.isInteger(d)||d<0)throw new RangeError(`tail: n must be a non-negative integer (got ${d})`);let g=u.get(d);if(g!==void 0)return u.delete(d),u.set(d,g),g.node;p(u);let m=ie([a],([_])=>{let b=_;return d===0||b.length===0?[]:b.slice(Math.max(0,b.length-d))},{initial:i.tail(d),describeKind:"derived"}),v=Qr(m);return u.set(d,{node:m,dispose:v}),m},slice(d,g){if(!Number.isInteger(d)||d<0)throw new RangeError(`slice: start must be a non-negative integer (got ${d})`);if(g!==void 0&&(!Number.isInteger(g)||g<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${g})`);let m=f(d,g),v=l.get(m);if(v!==void 0)return l.delete(m),l.set(m,v),v.node;p(l);let _=ie([a],([y])=>{let w=y;return g===void 0?w.slice(d):w.slice(d,g)},{initial:i.slice(d,g),describeKind:"derived"}),b=Qr(_);return l.set(m,{node:_,dispose:b}),_},disposeTail(d){let g=u.get(d);return g===void 0?!1:(g.dispose(),u.delete(d),!0)},disposeSlice(d,g){let m=f(d,g),v=l.get(m);return v===void 0?!1:(v.dispose(),l.delete(m),!0)},disposeAllViews(){for(let d of u.values())d.dispose();u.clear();for(let d of l.values())d.dispose();l.clear()},dispose(){for(let d of u.values())d.dispose();u.clear();for(let d of l.values())d.dispose();l.clear()}}}gt();function Zr(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}var Ls=dt((t,e)=>{t("write"),t("signal"),e("observe")}),Ps=dt((t,e)=>{t("observe"),t("signal"),e("write")}),$s=dt((t,e)=>{t("observe"),t("signal"),e("write")});function At(t,e){return Zr("cqrs",t,e)}var dn=class extends ne{_eventLogs=new Map;_commandHandlers=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_eventStore;_seq=0;constructor(e,n={}){super(e,n.graph)}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}event(e){let n=this._eventLogs.get(e);if(n)return n.node;let r=Xr([],{name:e,versioning:0}),o=r.entries,s=ie([o],([i])=>i,{name:e,describeKind:"state",meta:At("event",{event_name:e}),guard:$s,initial:o.cache});return this.add(s,{name:e}),this._keepaliveDisposers.push(ge(s)),this._eventLogs.set(e,{log:r,node:s}),s}_appendEvent(e,n){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 o=r.log.entries.v,s={type:e,payload:n,timestampNs:he(),seq:++this._seq,...o!=null?{v0:{id:o.id,version:o.version}}:{}};r.log.append(s),this._eventStore&&this._eventStore.persist(s)}command(e,n){let r=V(void 0,{name:e,describeKind:"state",meta:{...At("command",{command_name:e}),error:null},guard:Ls});return this.add(r,{name:e}),this._commandHandlers.set(e,n),r}dispatch(e,n){let r=this._commandHandlers.get(e);if(!r)throw new Error(`Unknown command: "${e}". Register with .command() first.`);let o=this.resolve(e);ce(()=>{o.emit(n,{internal:!0});try{r(n,{emit:(s,i)=>this._appendEvent(s,i)}),o.meta.error.emit(null,{internal:!0})}catch(s){throw o.meta.error.emit(s,{internal:!0}),s}})}projection(e,n,r,o){let s=n.map(a=>(this._eventLogs.has(a)||this.event(a),this._eventLogs.get(a).node)),i=ie(s,a=>{let c=[];for(let u of a){let l=u;c.push(...l)}return c.sort((u,l)=>u.timestampNs-l.timestampNs||u.seq-l.seq),r(o,c)},{name:e,describeKind:"derived",meta:At("projection",{projection_name:e,source_events:n}),guard:Ps,initial:o});return this.add(i,{name:e}),this._keepaliveDisposers.push(ge(i)),this._projections.add(e),i}saga(e,n,r){let o=n.map(c=>(this._eventLogs.has(c)||this.event(c),this._eventLogs.get(c).node)),s=new Map,i={},a=Ee(o,(c,u)=>{let l=i.n.meta.error;for(let f=0;f<c.length;f++){let p=c[f];if(p==null||p.length===0)continue;let h=p.at(-1);if(!h)continue;let d=n[f],g=s.get(d)??0;if(h.length>g){let m=h.slice(g);for(let v of m)try{r(v),l.emit(null,{internal:!0})}catch(_){l.emit(_,{internal:!0})}s.set(d,h.length)}}},{name:e,describeKind:"effect",meta:{...At("saga",{saga_name:e,source_events:n}),error:null}});return i.n=a,this.add(a,{name:e}),this._keepaliveDisposers.push(ge(a)),this._sagas.add(e),a}useEventStore(e){this._eventStore=e}async rebuildProjection(e,n,r){if(!this._eventStore)throw new Error("No event store wired. Call useEventStore() first.");let o=[];for(let s of e){let i=await this._eventStore.loadEvents(s);o.push(...i.events)}return o.sort((s,i)=>s.timestampNs-i.timestampNs||s.seq-i.seq),n(r,o)}};function eo(t,e){return new dn(t,e)}var fn=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},pn=class{graph=new ne("request");onModuleDestroy(){this.graph.destroy()}},to,ln;to=[(0,st.Module)({})];var be=class be{static forRoot(e){let n=e??{},r=n.name??"root",o=[{provide:ee,useFactory:()=>{let s=new ne(r);return n.build&&n.build(s),n.snapshot&&s.restore(n.snapshot),s}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:s=>new fn(s),inject:[ee]},{provide:Re,useFactory:(s,i)=>new Re(s,i),inject:[ee,no.ModuleRef]}];if(n.nodes)for(let s of n.nodes)o.push({provide:ae(s),useFactory:i=>i.resolve(s),inject:[ee]});return n.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new pn,scope:st.Scope.REQUEST},{provide:Oe,useFactory:s=>s.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:st.Scope.REQUEST}),{module:be,global:!0,providers:o,exports:[ee,...(n.nodes??[]).map(ae),...n.requestScope?[Oe]:[]]}}static forFeature(e){let n=[{provide:K(e.name),useFactory:r=>{let o=new ne(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),r.mount(e.name,o),o},inject:[ee]}];if(e.nodes)for(let r of e.nodes)n.push({provide:ae(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[K(e.name)]});return{module:be,providers:n,exports:[K(e.name),...(e.nodes??[]).map(r=>ae(`${e.name}::${r}`))]}}static forCqrs(e){let n=[{provide:K(e.name),useFactory:r=>{let o=eo(e.name,e.cqrs);return e.eventStore&&o.useEventStore(e.eventStore),e.build&&e.build(o),r.mount(e.name,o),o},inject:[ee]}];if(e.nodes)for(let r of e.nodes)n.push({provide:ae(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[K(e.name)]});return{module:be,providers:n,exports:[K(e.name),...(e.nodes??[]).map(r=>ae(`${e.name}::${r}`))]}}};ln=An(null),be=Mn(ln,0,"GraphReflyModule",to,be),Cn(ln,1,be);var kt=be;var gn={};ue(gn,{useStore:()=>Hs,useSubscribe:()=>ro,useSubscribeRecord:()=>Fs});var le=require("react");W();function ro(t){return(0,le.useSyncExternalStore)(e=>{let n=!1,r=t.subscribe(()=>{n||e()});return()=>{n=!0,r()}},()=>t.cache,()=>t.cache)}function Hs(t){let e=ro(t),n=(0,le.useCallback)(r=>{t.down([[I],[E,r]])},[t]);return[e,n]}function Fs(t,e){let n=(0,le.useRef)(e);n.current=e;let r=(0,le.useMemo)(()=>{let o=()=>{let i={},a=t.cache??[];for(let c of a){let u=n.current(c),l={};for(let f of Object.keys(u))l[f]=u[f].cache;i[c]=l}return i},s=o();return{subscribe:i=>{let a=!1,c=[],u=()=>{for(let p of c)p();c=[]},l=p=>{u();for(let h of p){let d=n.current(h);for(let g of Object.keys(d)){let m=d[g].subscribe(()=>{s=o(),a||i()});c.push(m)}}s=o(),a||i()},f=t.subscribe(p=>{let h=p.some(d=>d[0]===E||d[0]===B);!a&&h&&l(t.cache??[])});return l(t.cache??[]),()=>{a=!0,f(),u()}},getSnapshot:()=>s}},[t]);return(0,le.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot)}var yn={};ue(yn,{Signal:()=>js});we();W();de();var qe=[];function Ct(t){let e=t.cache;return t.subscribe(r=>{for(let[o,s]of r)o===E&&(e=s)})(),e}var mn=class{_node;_equals;constructor(e,n){this._equals=n?.equals??Object.is,this._node=V(e,{...n,resubscribable:!0,resetOnTeardown:!0})}get(){let e=qe[qe.length-1];return e?(this._node.status==="sentinel"&&Ct(this._node),e(this._node)):this._node.status==="sentinel"?Ct(this._node):this._node.cache}set(e){this._equals(this.get(),e)||ce(()=>{this._node.down([[I],[E,e]])})}},bn=class{_node;constructor(e,n){this._node=Ze(r=>{qe.push(r);try{return e()}finally{qe.pop()}},{...n,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=qe[qe.length-1];return e?(this._node.status==="sentinel"&&Ct(this._node),e(this._node)):this._node.status==="sentinel"?Ct(this._node):this._node.cache}},js={State:mn,Computed:bn,sub:(t,e)=>{let n=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,r=!0;return t._node.subscribe(o=>{for(let[s,i]of o){if(s===E){if(r){r=!1;continue}n.data?.(i)}s===C&&n.error?.(i),s===P&&n.complete?.()}})}};var vn={};ue(vn,{useStore:()=>Vs,useSubscribe:()=>oo,useSubscribeRecord:()=>qs});var fe=require("solid-js");W();function oo(t){let[e,n]=(0,fe.createSignal)(t.cache,{equals:!1}),r=t.subscribe(()=>{n(()=>t.cache)});return(0,fe.getOwner)()?(0,fe.onCleanup)(()=>r()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),e}function Vs(t){return[oo(t),r=>{t.down([[I],[E,r]])}]}function qs(t,e){let[n,r]=(0,fe.createSignal)({},{equals:!1}),o=[],s=()=>{for(let u of o)u();o=[]},i=()=>{let u={};for(let l of t.cache??[]){let f=e(l),p={};for(let h of Object.keys(f))p[h]=f[h].cache;u[l]=p}return u},a=u=>{s();for(let l of u){let f=e(l);for(let p of Object.keys(f)){let h=f[p].subscribe(()=>{r(()=>i())});o.push(h)}}r(()=>i())},c=t.subscribe(u=>{u.some(l=>l[0]===E||l[0]===B)&&a(t.cache??[])});return a(t.cache??[]),(0,fe.getOwner)()?(0,fe.onCleanup)(()=>{c(),s()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),n}var _n={};ue(_n,{useStore:()=>Bs,useSubscribe:()=>Ws,useSubscribeRecord:()=>zs});W();function Ws(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n}}}function Bs(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n},set(e){t.down([[I],[E,e]])},update(e){let n=e(t.cache);t.down([[I],[E,n]])}}}function zs(t,e){return{subscribe(n){let r=[],o=()=>{for(let c of r)c();r=[]},s=()=>{let c={};for(let u of t.cache??[]){let l=e(u),f={};for(let p of Object.keys(l))f[p]=l[p].cache;c[u]=f}return c},i=c=>{o();for(let u of c){let l=e(u);for(let f of Object.keys(l)){let p=l[f].subscribe(()=>{n(s())});r.push(p)}}n(s())},a=t.subscribe(c=>{c.some(u=>u[0]===E||u[0]===B)&&i(t.cache??[])});return i(t.cache??[]),()=>{a(),o()}}}}var xn={};ue(xn,{useStore:()=>Us,useSubscribe:()=>Ks,useSubscribeRecord:()=>Ys});var H=require("vue");W();function Ks(t){let e=(0,H.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,H.getCurrentScope)()?(0,H.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,H.readonly)(e)}function Us(t){let e=(0,H.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,H.getCurrentScope)()?(0,H.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useStore called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,H.computed)({get:()=>e.value,set:r=>{t.down([[I],[E,r]])}})}function Ys(t,e){let n=(0,H.shallowRef)({}),r=new Map;function o(){let a={};for(let[c,u]of r)a[c]={...u.values};n.value=a}function s(a){for(let u of r.values())for(let l of u.subs)l();r.clear();for(let u of a){let l=e(u),f=Object.keys(l),p={},h=[];for(let d of f){let g=l[d];p[d]=g.cache;let m=g.subscribe(()=>{p[d]=g.cache,o()});h.push(m)}r.set(u,{subs:h,values:p})}let c={};for(let[u,l]of r)c[u]={...l.values};n.value=c}return(0,H.watch)(()=>[...(typeof t=="function"?t():(0,H.isRef)(t)?t.value:t)??[]],a=>s(a??[]),{immediate:!0}),(0,H.getCurrentScope)()?(0,H.onScopeDispose)(()=>{for(let a of r.values())for(let c of a.subs)c();r.clear()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,H.readonly)(n)}var wn={};ue(wn,{create:()=>Qs});W();de();var Js=()=>!1;function Qs(t){let e=new ne("zustand"),n=V(void 0,{name:"state",equals:Js});e.add(n,{name:"state"});let r=()=>n.cache,o=(a,c)=>{let u=n.cache,l=typeof a=="function"?a(u):a;n.emit(c?l:{...u,...l})},s={getState:r,setState:o,getInitialState:()=>i,subscribe:a=>{let c=!0,u=n.cache;return n.subscribe(l=>{for(let[f,p]of l)if(f===E){if(c){c=!1;continue}a(p,u),u=p}})},destroy:e.destroy.bind(e)},i=t(o,r,s);return n.emit(i),Object.assign(e,s)}0&&(module.exports={jotai,nanostores,nestjs,react,signals,solid,svelte,vue,zustand});
|
package/dist/compat/index.d.cts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
export { i as jotai } from '../index-BydMDMf7.cjs';
|
|
2
2
|
export { i as nanostores } from '../index-CIXaiYDE.cjs';
|
|
3
|
-
export { i as nestjs } from '../index-
|
|
3
|
+
export { i as nestjs } from '../index-C4QTaDli.cjs';
|
|
4
4
|
export { i as react } from '../index-D7XxY1Ff.cjs';
|
|
5
|
-
export { a as signals } from '../index-
|
|
5
|
+
export { a as signals } from '../index-LzCJ0kMT.cjs';
|
|
6
6
|
export { i as solid } from '../index-FBqTfL_S.cjs';
|
|
7
7
|
export { i as svelte } from '../index-CDK5RsV5.cjs';
|
|
8
8
|
export { i as vue } from '../index-DDo-eqQ4.cjs';
|
|
9
|
-
export { i as zustand } from '../index-
|
|
9
|
+
export { i as zustand } from '../index-DY2QbdoP.cjs';
|
|
10
10
|
import '../node-BVV7G1bq.cjs';
|
|
11
11
|
import '../observable-BrUAPeH_.cjs';
|
|
12
12
|
import 'rxjs';
|
|
13
13
|
import '@nestjs/common';
|
|
14
14
|
import '@nestjs/core';
|
|
15
|
-
import '../graph-
|
|
15
|
+
import '../graph-CdJeX7O7.cjs';
|
|
16
16
|
import '../meta-COtmHLwT.cjs';
|
|
17
17
|
import '../extra/storage-core.cjs';
|
|
18
|
-
import '../index-
|
|
18
|
+
import '../index-aBqZUx3B.cjs';
|
|
19
19
|
import 'vue';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
export { i as jotai } from '../index-ByPnK85n.js';
|
|
2
2
|
export { i as nanostores } from '../index-wIx1Jisk.js';
|
|
3
|
-
export { i as nestjs } from '../index-
|
|
3
|
+
export { i as nestjs } from '../index-CZUzi6Dy.js';
|
|
4
4
|
export { i as react } from '../index-D0C_USMR.js';
|
|
5
|
-
export { a as signals } from '../index-
|
|
5
|
+
export { a as signals } from '../index-MV2yGIAq.js';
|
|
6
6
|
export { i as solid } from '../index-CrC7urhX.js';
|
|
7
7
|
export { i as svelte } from '../index-BX22kvjh.js';
|
|
8
8
|
export { i as vue } from '../index-Ip3q9T9x.js';
|
|
9
|
-
export { i as zustand } from '../index-
|
|
9
|
+
export { i as zustand } from '../index-CmSjld-4.js';
|
|
10
10
|
import '../node-BVV7G1bq.js';
|
|
11
11
|
import '../observable-ITikPXz3.js';
|
|
12
12
|
import 'rxjs';
|
|
13
13
|
import '@nestjs/common';
|
|
14
14
|
import '@nestjs/core';
|
|
15
|
-
import '../graph-
|
|
15
|
+
import '../graph-BOhEGJ6E.js';
|
|
16
16
|
import '../meta-BMwx3ExI.js';
|
|
17
17
|
import '../extra/storage-core.js';
|
|
18
|
-
import '../index-
|
|
18
|
+
import '../index-DD1czHj3.js';
|
|
19
19
|
import 'vue';
|
package/dist/compat/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"../chunk-
|
|
1
|
+
import{a as e}from"../chunk-7QS77X6G.js";import{d}from"../chunk-VJLMUKOI.js";import{d as f}from"../chunk-VIMF6LGM.js";import{d as g}from"../chunk-6QZNQS5B.js";import{d as h}from"../chunk-GPW2V3RE.js";import{b as i}from"../chunk-JYMNVEH6.js";import{b as a}from"../chunk-A4JT4SAD.js";import{i as b}from"../chunk-W6FQIFVE.js";import{G as c}from"../chunk-CNXUW2CU.js";import"../chunk-EIFHFDFD.js";import"../chunk-K54OKWNY.js";import"../chunk-CZVYLXFK.js";import"../chunk-MFNOZ5E6.js";import"../chunk-5QDBSZBV.js";import"../chunk-XRSHMHEG.js";import"../chunk-4JBKKUCJ.js";import"../chunk-SGS4OJGS.js";import"../chunk-ESMPEKEV.js";import"../chunk-N2KKISCE.js";import"../chunk-UMH3HSP7.js";import"../chunk-7AJKUA36.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{a as jotai,b as nanostores,c as nestjs,d as react,e as signals,f as solid,g as svelte,h as vue,i as zustand};
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
`)}function hr(t){if(t.version!==_e)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${_e})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in t))throw new Error(`snapshot missing required key "${e}"`);if(typeof t.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof t.nodes!="object"||t.nodes===null||Array.isArray(t.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(t.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(t.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Io(t,e){let n=new WeakMap,r=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=n.get(o);if(i==null&&(i=new WeakSet,n.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,d=s.constructor;if(a!==d)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let p=s;if(o.length!==p.length)return!1;for(let h=0;h<o.length;h++)if(!r(o[h],p[h]))return!1;return!0}if(o instanceof Map){let p=s;if(o.size!==p.size)return!1;for(let[h,c]of o)if(!p.has(h)||!r(c,p.get(h)))return!1;return!0}if(o instanceof Set){let p=s;if(o.size!==p.size)return!1;for(let h of o){let c=!1;for(let g of p)if(r(h,g)){c=!0;break}if(!c)return!1}return!0}if(ArrayBuffer.isView(o)){let p=o,h=s;if(p.length!==h.length)return!1;for(let c=0;c<p.length;c++)if(p[c]!==h[c])return!1;return!0}let u=Object.keys(o),l=Object.keys(s);if(u.length!==l.length)return!1;let f=new Set(l);for(let p of u)if(!f.has(p)||!r(o[p],s[p]))return!1;return!0};return r(t,e)}function Wt(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Wt);let e=t,n=Object.keys(e).sort(),r={};for(let o of n)r[o]=Wt(e[o]);return r}function Lo(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Po(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function $o(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function mr(t){let e=new Set,n=[];function r(o,s){let i=`${o}\0${s}`;e.has(i)||(e.add(i),n.push([o,s]))}for(let[o,s]of Object.entries(t.nodes)){let i=s.deps;if(i)for(let a of i)r(a,o)}for(let o of t.edges)r(o.from,o.to);return n}function yr(t){if(t===void 0)return"LR";if(t==="TD"||t==="LR"||t==="BT"||t==="RL")return t;throw new Error(`invalid diagram direction ${String(t)}; expected one of: TD, LR, BT, RL`)}function Ho(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,{expand:o,...s}=t,i={...s,edges:n?t.edges:[],subgraphs:r?t.subgraphs:[]},a=JSON.stringify(Wt(i),null,e.indent??2);return e.logger?.(a),a}function Fo(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,o=[];o.push(`Graph ${t.name}`),o.push("Nodes:");for(let i of Object.keys(t.nodes).sort()){let a=t.nodes[i];o.push(`- ${i} (${a.type}/${a.status}): ${bt(a.value)}`)}if(n){o.push("Edges:");for(let i of t.edges)o.push(`- ${i.from} -> ${i.to}`)}if(r){o.push("Subgraphs:");for(let i of t.subgraphs)o.push(`- ${i}`)}let s=o.join(`
|
|
13
13
|
`);return e.logger?.(s),s}function br(t,e){let n=yr(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`flowchart ${n}`];for(let i of r){let a=o.get(i);s.push(` ${a}["${Lo(i)}"]`)}for(let[i,a]of mr(t)){let d=o.get(i),u=o.get(a);!d||!u||s.push(` ${d} --> ${u}`)}return s.join(`
|
|
14
14
|
`)}function qo(t,e){let n=br(t,e);return vr(n)}function vr(t,e){let n=e?.theme??"default",r=e?.autoSync??!0,s=JSON.stringify({code:t,mermaid:{theme:n},autoSync:r}),i=new TextEncoder().encode(s),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function jo(t,e){let n=yr(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`direction: ${$o(n)}`];for(let i of r){let a=o.get(i);s.push(`${a}: "${Po(i)}"`)}for(let[i,a]of mr(t)){let d=o.get(i),u=o.get(a);!d||!u||s.push(`${d} -> ${u}`)}return s.join(`
|
|
15
|
-
`)}function Bo(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yt(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let o=t.indexOf("]",n+1);if(o<=n+1){e+="\\[";continue}let s=t.slice(n+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,n=o;continue}e+=Bo(r)}return e+="$",new RegExp(e)}var Vo={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"},Wo={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function bt(t){if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||t==null)return String(t);try{return JSON.stringify(t)}catch{return"[unserializable]"}}function zo(t){return t==="none"?Wo:t==="ansi"||t==null?Vo:{data:t.data??"",dirty:t.dirty??"",resolved:t.resolved??"",invalidate:t.invalidate??"",pause:t.pause??"",resume:t.resume??"",complete:t.complete??"",error:t.error??"",teardown:t.teardown??"",derived:t.derived??"",path:t.path??"",reset:t.reset??""}}function gr(t){if(t==null)return{};let e=t.detail;return e==="full"?{...t,structured:t.structured??!0,timeline:t.timeline??!0,causal:t.causal??!0,derived:t.derived??!0}:e==="minimal"?{...t,structured:t.structured??!0}:t.format==="stage-log"?{...t,structured:t.structured??!0,timeline:t.timeline??!0}:t}function Uo(t,e,n){for(let r=0;r<t.length;r++){let o=t.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function Vt(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(I))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${I}' (path separator)`);if(t===Q)throw new Error(`Graph "${e}": ${n} name "${Q}" is reserved for meta companion paths`);Uo(t,e,n)}function Ko(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(I);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function Yo(t,e){let n=!1;for(let o of t)if(!e.isMetaPassthrough(o[0])){n=!0;break}return n?t.filter(o=>e.isMetaPassthrough(o[0])):t}function _r(t){for(let e of t._mounts.values())_r(e);for(let e of t._nodes.values())try{e.down([[F]],{internal:!0})}catch{}}var ie=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(I))throw new Error(`Graph name must not contain '${I}' (got "${e}")`);if(e===Q)throw new Error(`Graph name "${Q}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??ye,this._traceRing=new Qe(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=Le(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}add(e,n){let r=e.name,o=n?.name??r;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=n?.annotation;if(Vt(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:Re()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof P&&n._applyVersioning(e)}remove(e){Vt(e,this.name,"remove");let n=this._mounts.get(e);if(n){let s={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,d]of i)a.includes(`${I}${Q}${I}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...n._collectSubgraphs(`${e}${I}`)),this._mounts.delete(e),n._parent=void 0,_r(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[F]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let n=typeof e=="function"?e:(()=>{let s=yt(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>n(s));for(let s of o){let i=this.remove(s);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let o=e[r++];return{value:[o,n.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(I))return this.resolve(e);let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return n}get(e){return this.node(e).cache}set(e,n,r){let o=r?.internal===!0;this.node(e).down([[R,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);Ae(()=>{for(let[o,s]of r)this.set(o,s,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[ee]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let o=r?.internal===!0;this.node(e).down([[A,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[L]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[d,u]of this._nodes)r.set(u,d);let a=[];for(let[d,u]of this._nodes)if(u instanceof P)for(let l of u._deps){let f=r.get(l.node);f!=null&&a.push([f,d])}return a.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,d]of o)s.set(d,a);let i=[];for(let[a,d]of o)if(d instanceof P)for(let u of d._deps){let l=s.get(u.node);l!=null&&i.push([l,a])}return i.sort((a,d)=>a[0]<d[0]?-1:a[0]>d[0]?1:a[1]<d[1]?-1:a[1]>d[1]?1:0),i}mount(e,n){if(Vt(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let n=Ko(e,this.name);return this._resolveFromSegments(n)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let n=e;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],o=n.slice(1);if(o.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let s=this._nodes.get(r);if(s&&o.length>0&&o[0]===Q)return this._resolveMetaChainFromNode(s,o,n.join(I));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(I)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(I))}_resolveMetaChainFromNode(e,n,r){let o=e,s=0,i=[...n];for(;s<i.length;){if(i[s]!==Q)throw new Error(`Graph "${this.name}": expected ${Q} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Q} in "${r}"`);let a=i[s+1],d=o.meta[a];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=d,s+=2}return o}signal(e,n){if(n?.internal!==!0){for(let o of e)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,o){for(let d of this._mounts.values())d._signalDeliver(e,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=Yo(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(l){if(l instanceof J)throw l;o.push(l)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,o)}}}_signalMetaSubtree(e,n,r,o,s){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,o)}catch(d){if(d instanceof J)throw d;s.push(d)}this._signalMetaSubtree(a,n,r,o,s)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,o=dt(e?.detail,e?.fields),s=e?.format==="spec",i=s?dt("minimal"):o,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[T,w]of a)d.set(w,T);let u=[];{let T=a.map(([,N])=>N),w=new Set(d.values()),E=0;for(;T.length>0;){let N=T.shift();if(N instanceof P)for(let M of N._deps){let S=M.node;if(d.has(S))continue;let C=S.name??"",k=C;if(!k||w.has(k))if(C){let $=2;for(;w.has(`${C}#${$}`);)$++;k=`${C}#${$}`}else for(k=`__internal__/${E++}`;w.has(k);)k=`__internal__/${E++}`;d.set(S,k),w.add(k),u.push([k,S]),T.push(S)}}}let l=[...a,...u],f={};for(let[T,w]of l){if(n!=null&&!w.allowsObserve(n))continue;let E=jt(w,i),N=w instanceof P?w._deps.map(k=>d.get(k.node)??k.node.name??""):[],{name:M,...S}=E,C={...S,deps:N};if(!s){let k=this._annotations.get(T);k!=null&&(C.annotation=k)}if(r!=null)if(typeof r=="function"){let k=r;if(!(k.length>=2?k(T,C):k(C)))continue}else{let k=!0;for(let[$,B]of Object.entries(r)){let X=$==="deps_includes"?"depsIncludes":$==="meta_has"?"metaHas":$;if(X==="depsIncludes"){if(!C.deps.includes(String(B))){k=!1;break}continue}if(X==="metaHas"){if(!Object.hasOwn(C.meta??{},String(B))){k=!1;break}continue}if(C[X]!==B){k=!1;break}}if(!k)continue}f[T]=C}let p=new Set(Object.keys(f)),h=[];for(let[T,w]of l)if(w instanceof P)for(let E of w._deps){let N=d.get(E.node);N!=null&&h.push([N,T])}h.sort((T,w)=>T[0]<w[0]?-1:T[0]>w[0]?1:T[1]<w[1]?-1:T[1]>w[1]?1:0);let c=h.map(([T,w])=>({from:T,to:w}));(n!=null||r!=null)&&(c=c.filter(T=>p.has(T.from)&&p.has(T.to)));let g=this._collectSubgraphs(""),m=n!=null||r!=null?g.filter(T=>{let w=`${T}${I}`;return[...p].some(E=>E===T||E.startsWith(w))}):g,v=this,_=e,y={name:this.name,nodes:f,edges:c,subgraphs:m,expand(T){let w={..._,format:void 0};return Array.isArray(T)?(w.fields=T,w.detail=void 0):(w.detail=T,w.fields=void 0),v.describe(w)}},b=e??{},x=b.format;return x==="json"?Ho(y,b):x==="pretty"?Fo(y,b):x==="mermaid"?br(y,b):x==="mermaid-url"?qo(y,b):x==="d2"?jo(y,b):x==="ascii"?ir(y,b):y}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;n.push(o),n.push(...this._mounts.get(r)._collectSubgraphs(`${o}${I}`))}return n}resourceProfile(e){return fr(this,e)}reachable(e,n,r={}){return r.withDetail===!0?zt(this.describe(),e,n,{...r,withDetail:!0}):zt(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,d]of Object.entries(o.nodes))d.lastMutation!=null&&i.set(a,d.lastMutation);return ar(o,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=oe(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,ze(()=>{a=!1,!d&&(o+=1,s.emit(o))}))},l=i.onEvent(m=>{let v=m.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||u()}),f=[],p=new WeakSet,h=m=>{if(p.has(m)||d)return;p.add(m);let v=m.topology.subscribe(_=>{for(let y of _){if(y[0]!==R)continue;let b=y[1];if(u(),b.kind==="added"&&b.nodeKind==="mount"){let x=m._mounts.get(b.name);x!=null&&h(x)}}});f.push(v);for(let _ of m._mounts.keys()){let y=m._mounts.get(_);y!=null&&h(y)}};h(this);let c;try{c=se([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,v)=>m===v})}catch(m){l();for(let v of f)v();throw i.dispose(),m}let g=de(c);return{node:c,dispose(){d=!0,l();for(let m of f)m();f.length=0,i.dispose(),g()}}}_explainReactive(e,n,r){let o=0,s=oe(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(h=>{let c=h.type;c!=="data"&&c!=="error"&&c!=="complete"&&c!=="teardown"||a||d||(a=!0,ze(()=>{a=!1,!d&&(o+=1,s.emit(o))}))}),l={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},f;try{f=se([s],()=>this._explainStatic(e,n,l),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(h,c)=>h.found===c.found&&h.reason===c.reason&&h.steps.length===c.steps.length&&Jo(h.steps,c.steps)})}catch(h){throw u(),i.dispose(),h}let p=de(f);return{node:f,dispose(){d=!0,u(),i.dispose(),p()}}}_pathsMatching(e){let n=yt(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>n.test(o))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${I}${r}`;this._mounts.get(r)._collectObserveTargets(o,n)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${I}${r}`;n.push([s,o]),this._appendMetaObserveTargets(s,o,n)}}_appendMetaObserveTargets(e,n,r){for(let o of Object.keys(n.meta).sort()){let s=n.meta[o],i=`${e}${I}${Q}${I}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,n){let r=typeof e=="string",s=gr(r?n:e),i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let l=e,f=this.resolve(l);if(a!=null&&!f.allowsObserve(a))throw new J({actor:a,action:"observe",nodeName:l});return i?this._buildStructuredObserver([[l,f]],s,"one"):{subscribe(p){return f.subscribe(p)},up(p){try{f.up?.(p)}catch(h){if(h instanceof J)return;throw h}}}}let d=[];this._collectObserveTargets("",d),d.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let u=a==null?d:d.filter(([,l])=>l.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:l=>{let f=u.map(([p,h])=>h.subscribe(c=>{l(p,c)}));return()=>{for(let p of f)p()}},up:(l,f)=>{try{this.resolve(l).up?.(f)}catch(p){if(p instanceof J)return;throw p}}}}_buildStructuredObserver(e,n,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let l=this.resolve(o);return this._buildStructuredObserver([[o,l]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let d=i.actor,u=d==null?a:a.filter(([,l])=>l.allowsObserve(d));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,s)}_createObserveResult(e,n,r){let o=n.timeline===!0,s=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",d=this.config.inspectorEnabled,u=(s||i)&&d,l=n.maxEvents,f=l!=null&&l>0?new Qe(l):null,p=[],h=new Set,c={},g=new Set,m=0,v=0,_=0,y=0,b=0,x=0,T=!1,w=!1,E=0,N=new Map,M=new Map,S=new Map,C=O=>{f?f.push(O):p.push(O);for(let G of h)G(O)},k=()=>o?{timestamp_ns:Re(),in_batch:et(),batch_id:E}:{},$=(O,G)=>{if(!(!u||!(O instanceof P)))return O._setInspectorHook(z=>{if(z.kind==="dep_message")N.set(O,z.depIndex);else if(z.kind==="run"){let Pe=z.batchData.map((D,q)=>D!=null&&D.length>0?D.at(-1):z.prevData[q]);M.set(O,Pe);let U=z.batchData.map(D=>D!=null?[...D]:void 0);S.set(O,U),i&&C({type:"derived",path:G,dep_values:Pe,dep_batches:U,...k()})}})},B=O=>{let G=N.get(O),z=M.get(O);if(!s||z==null)return{};let U=(G!=null&&G>=0&&O instanceof P?O._deps[G]:void 0)?.node,D=U?.v,q=S.get(O);return{trigger_dep_index:G,trigger_dep_name:U?.name,...D!=null?{trigger_version:{id:D.id,version:D.version}}:{},dep_values:[...z],...q!=null?{dep_batches:q}:{}}},X=[],fe=[];for(let[O,G]of e){let z=$(G,O);z&&X.push(z),fe.push(G.subscribe(Pe=>{E++;for(let U of Pe){let D=U[0],q=k();if(D===R){c[O]=U[1];let Et=G instanceof P?G.lastMutation?.actor??ue:ue;C({type:"data",path:O,data:U[1],actor:Et,...q,...B(G)})}else if(a)D===W?m++:D===Z?v++:D===ee?_++:D===K?y++:D===te?b++:D===F?x++:D===L&&!g.has(O)?T=!0:D===A&&(w=!0,g.add(O));else if(D===W)m++,C({type:"dirty",path:O,...q});else if(D===Z)v++,C({type:"resolved",path:O,...q,...B(G)});else if(D===ee)_++,C({type:"invalidate",path:O,...q});else if(D===K)y++,C({type:"pause",path:O,lockId:U[1],...q});else if(D===te)b++,C({type:"resume",path:O,lockId:U[1],...q});else if(D===L)g.has(O)||(T=!0),C({type:"complete",path:O,...q});else if(D===A){w=!0,g.add(O);let Et=G instanceof P?G.lastMutation?.actor??ue:ue;C({type:"error",path:O,data:U[1],actor:Et,...q})}else D===F&&(x++,C({type:"teardown",path:O,...q}))}}))}let wt=!1,xt=()=>{if(!wt){wt=!0;for(let O of fe)O();for(let O of X)O();for(let O of Ze)O({value:void 0,done:!0});Ze.length=0}},Tt=[],Ze=[];h.add(O=>{let G=Ze.shift();G?G({value:O,done:!1}):Tt.push(O)});let Xt={get values(){return c},get dirtyCount(){return m},get resolvedCount(){return v},get invalidateCount(){return _},get pauseCount(){return y},get resumeCount(){return b},get teardownCount(){return x},get events(){return f?f.toArray():[...p]},get anyCompletedCleanly(){return T},get anyErrored(){return w},get completedWithoutErrors(){return T&&!w},onEvent(O){return h.add(O),()=>h.delete(O)},dispose:xt,expand(O){xt();let G={...n};return typeof O=="string"?G.detail=O:Object.assign(G,O),r(gr(G))},[Symbol.asyncIterator](){return{next(){return Tt.length>0?Promise.resolve({value:Tt.shift(),done:!1}):wt?Promise.resolve({value:void 0,done:!0}):new Promise(O=>Ze.push(O))},return(){return xt(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Xt,n),Xt}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let o=n.logger??(c=>console.log(c)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:c=>(s==null||s.has(c))&&(i==null||!i.has(c)),d=zo(n.theme),u=r==="stage-log"?Re():0,l=c=>c==null?"":n.stageLabels?.[c]??c,f=(c,g)=>c.length>g?`${c.slice(0,g-1)}\u2026`:c,p=c=>c.type==="data"||c.type==="error"?f(bt(c.data),120):"",h=c=>{if(r==="stage-log"){let w=(Re()-u)/1e9,E=l(c.path).padEnd(9);if(c.type==="data"){let N=p(c);return`[${w.toFixed(3)}s] ${E} \u2190${N?` ${N}`:""}`}if(c.type==="error"){let N=p(c);return`[${w.toFixed(3)}s] ${E} \u2717${N?` ${N}`:""}`}return c.type==="complete"?`[${w.toFixed(3)}s] ${E} \u25A0 complete`:`[${w.toFixed(3)}s] ${E} ${c.type}`}if(r==="json")try{return JSON.stringify(c)}catch{return JSON.stringify({type:c.type,path:c.path,data:"[unserializable]"})}let g=d[c.type]??"",m=c.path?`${d.path}${c.path}${d.reset} `:"",v=c.type==="data"||c.type==="error",_=c.type==="pause"||c.type==="resume",y=v?` ${bt(c.data)}`:_?` ${bt(c.lockId)}`:"",b=c.type==="data"||c.type==="resolved"||c.type==="derived"?c:void 0,x=b?.trigger_dep_name!=null?` <- ${b.trigger_dep_name}`:b?.trigger_dep_index!=null?` <- #${b.trigger_dep_index}`:"",T=c.in_batch?" [batch]":"";return`${m}${g}${c.type.toUpperCase()}${d.reset}${y}${x}${T}`};e.onEvent(c=>{a(c.type)&&o(h(c),c)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){pr(this._disposers,this.name),this.signal([[F]],{internal:!0}),pr(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}snapshot(e){let{expand:n,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:d,guard:u,...l}=r.nodes[a];o[a]=l}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return En(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??ye,{codec:o,codecVersion:s,payload:i}=On(e,r);return o.decode(i,s)}restore(e,n){if(hr(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(s=>yt(s)),o=n?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let d=this.tryResolve(s)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(e,n){hr(e);let r=typeof n=="function"?n:n?.build,o=typeof n=="function"?void 0:n?.factories,s=new t(e.name);if(r)return r(s),s.restore(e),s;for(let h of[...e.subgraphs].sort((c,g)=>{let m=c.split(I).length,v=g.split(I).length;return m!==v?m-v:c<g?-1:c>g?1:0})){let c=h.split(I),g=s;for(let m of c)g._mounts.has(m)||g.mount(m,new t(m)),g=g._mounts.get(m)}let i=o?Object.entries(o).map(([h,c])=>({re:yt(h),factory:c})):[],a=h=>{for(let c of i)if(c.re.test(h))return c.factory},d=h=>{let c=h.split(I),g=c.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${h}"`);let m=s;for(let v of c){let _=m._mounts.get(v);if(!_)throw new Error(`unknown mount "${v}" in path "${h}"`);m=_}return[m,g]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${I}${Q}${I}`)).sort((h,c)=>h[0]<c[0]?-1:h[0]>c[0]?1:0),l=new Map(u),f=new Map,p=!0;for(;l.size>0&&p;){p=!1;for(let[h,c]of[...l.entries()]){let g=c?.deps??[];if(!g.every(x=>f.has(x)))continue;let[m,v]=d(h),_={...c?.meta??{}},y=a(h),b;if(c?.type==="state")b=oe(c.value,{meta:_});else{if(y==null)continue;b=y(v,{path:h,type:c.type,value:c.value,meta:_,deps:g,resolvedDeps:g.map(x=>f.get(x))})}m.add(b,{name:v}),f.set(h,b),l.delete(h),p=!0}}if(l.size>0){let h=[...l.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let o=(u,l)=>{if(u.disposed)return;let f=Go(l.nodes);if(u.lastSnapshot!=null&&f!==""&&f===u.lastFingerprint)return;let p=u.seq+1,h=ae(),m=u.lastSnapshot==null||p%u.compactEvery===0?{mode:"full",snapshot:l,seq:p,timestamp_ns:h,format_version:_e}:{mode:"diff",diff:wr(u.lastSnapshot,l),seq:p,timestamp_ns:h,format_version:_e};if(u.tier.filter&&!u.tier.filter(this.name,m))return;let v;try{v=u.tier.save(this.name,m)}catch(_){n.onError?.(_,u.tier);return}if(v&&typeof v.then=="function"){let b=(u.savePending??Promise.resolve()).then(()=>v,()=>v).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=l,u.lastFingerprint=f)},x=>{n.onError?.(x,u.tier)});u.savePending=b.finally(()=>{u.savePending===b&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=l,u.lastFingerprint=f},s=(u,l)=>{try{o(u,l)}catch(f){n.onError?.(f,u.tier)}},i=(u,l)=>{if(!l.some(c=>{let g=this.config.messageTier(c[0]);return g>=3&&g<5}))return;if(n.filter){let c=this.tryResolve(u);if(c==null)return;let g=jt(c,dt("standard"));if(!n.filter(u,g))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let c of r)c.disposed||(c.debounceMs===0?s(c,h()):(c.timer==null&&(c.timer=new ct),c.timer.start(c.debounceMs,()=>{c.disposed||s(c,this.snapshot())})))},a;if(n.paths!=null){let l=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(f=>{let p=this.tryResolve(f);return p==null?()=>{}:p.subscribe(h=>i(f,h))});a=()=>{for(let f of l)f()}}else a=this.observe().subscribe((u,l)=>i(u,l));let d=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,n){for(let r of e){let o;try{o=await r.load(this.name)}catch(i){n?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===_e&&s.nodes!=null)return this.restore(s),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let o of n){let s;try{s=await o.load(e)}catch(d){r?.onError?.(d,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===_e&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(d){r?.onError?.(d,o)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,n,r){if(e!=null&&n!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,n),this.config.inspectorEnabled){let o={path:e,annotation:n,timestamp_ns:Re(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(o=>!e(o)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let o of n)this._traceRing.push(o);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(n.nodes)),s=[...o].filter(_=>!r.has(_)).sort(),i=[...r].filter(_=>!o.has(_)).sort(),a=[],d=[];for(let _ of r){if(!o.has(_))continue;let y=e.nodes[_],b=n.nodes[_],x=y.v,T=b.v;x!=null&&T!=null&&x.id===T.id&&x.version!==T.version&&d.push({path:_,id:x.id,from:x.version,to:T.version});let w=x!=null&&T!=null&&x.id===T.id&&x.version===T.version;for(let E of["type","status","sentinel"]){let N=y[E],M=b[E];N!==M&&a.push({path:_,field:E,from:N,to:M})}if(!w)for(let E of["value","meta"]){let N=y[E],M=b[E];Io(N,M)||a.push({path:_,field:E,from:N,to:M})}}let u=_=>`${_.from} ${_.to}`,l=new Set(e.edges.map(u)),f=new Set(n.edges.map(u)),p=n.edges.filter(_=>!l.has(u(_))),h=e.edges.filter(_=>!f.has(u(_))),c=new Set(e.subgraphs),g=new Set(n.subgraphs),m=[...g].filter(_=>!c.has(_)).sort(),v=[...c].filter(_=>!g.has(_)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:p,edgesRemoved:h,subgraphsAdded:m,subgraphsRemoved:v}}};function wr(t,e){let n=ie.diff(t,e),r={};for(let o of n.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...n,nodesAddedFull:r}}function zt(t,e,n,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,d=new Map,u=new Map,l=new Set;for(let[y,b]of Object.entries(t.nodes)){if(!y)continue;l.add(y);let x=b.deps??[];i.set(y,x);for(let T of x)T&&(l.add(T),a.has(T)||a.set(T,new Set),a.get(T).add(y))}for(let y of t.edges){if(y==null||typeof y!="object")continue;let b=typeof y.from=="string"?y.from:"",x=typeof y.to=="string"?y.to:"";!b||!x||(l.add(b),l.add(x),u.has(b)||u.set(b,new Set),u.get(b).add(x),d.has(x)||d.set(x,new Set),d.get(x).add(b))}if(!l.has(e))return r.withDetail?o:[];let f=r.both===!0,p=y=>{if(f){let w=i.get(y)??[],E=d.get(y),N=a.get(y),M=u.get(y),S=[...w];return E&&S.push(...E),N&&S.push(...N),M&&S.push(...M),S}if(n==="upstream"){let w=i.get(y)??[],E=d.get(y);return E?[...w,...E]:w}let b=a.get(y),x=u.get(y),T=b?[...b]:[];return x&&T.push(...x),T},h=new Set([e]),c=new Map,g=[{path:e,depth:0}],m=0,v=!1;for(;m<g.length;){let y=g[m++];if(s!=null&&y.depth>=s){p(y.path).length>0&&(v=!0);continue}for(let b of p(y.path))!b||h.has(b)||(h.add(b),c.set(b,y.depth+1),g.push({path:b,depth:y.depth+1}))}let _=[...c.keys()].sort((y,b)=>y<b?-1:y>b?1:0);return r.withDetail?{paths:_,depths:c,truncated:v}:_}function Jo(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],o=e[n];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}Ue();je();Ge();Be();Ge();Ie();Ke();Ue();re();Ke();var Ut=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,n){if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=n,n!==void 0){if(this._buf=new Array(n),e&&e.length>0){let r=Math.min(e.length,n),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._size+e;if(!(n<0||n>=this._size))return this._maxSize!==void 0?this._buf[(this._head+n)%this._maxSize]:this._buf[n]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=n;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let n=0;n<e;n++)this._buf[(this._head+n)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let n=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,n);else{for(let r=0;r<n;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+n)%this._maxSize}return this._size-=n,this._version+=1,n}slice(e,n){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(n!==void 0&&(!Number.isInteger(n)||n<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${n})`);let r=n===void 0?this._size:Math.min(Math.max(n,0),this._size),o=Math.min(e,this._size);if(o>=r)return[];let s=r-o;if(this._maxSize===void 0)return this._buf.slice(o,r);let i=new Array(s);for(let a=0;a<s;a++)i[a]=this._buf[(this._head+o+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let n=Math.min(e,this._size);return this.slice(this._size-n,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this._buf[(this._head+n)%this._maxSize];return e}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function xr(t){return t.subscribe(()=>{})}var Qo=64;function Tr(t,e={}){let{name:n,maxSize:r,versioning:o,backend:s}=e,i=s??new Ut(t,r),a=oe(i.toArray(),{name:n,describeKind:"state",equals:(c,g)=>c===g,...o!=null?{versioning:o}:{}});function d(){let c=i.toArray();Ae(()=>{a.down([[W]]),a.down([[R,c]])})}let u=new Map,l=new Map;function f(c,g){return`${c}:${g===void 0?"END":g}`}function p(c){if(c.size<Qo)return;let g=c.keys().next();if(g.done)return;let m=c.get(g.value);m!==void 0&&m.dispose(),c.delete(g.value)}function h(c){let g=i.version;try{return c()}finally{i.version!==g&&d()}}return{entries:a,get size(){return i.size},at(c){return i.at(c)},append(c){h(()=>i.append(c))},appendMany(c){c.length!==0&&h(()=>i.appendMany(c))},clear(){h(()=>i.clear())},trimHead(c){h(()=>i.trimHead(c))},tail(c){if(!Number.isInteger(c)||c<0)throw new RangeError(`tail: n must be a non-negative integer (got ${c})`);let g=u.get(c);if(g!==void 0)return u.delete(c),u.set(c,g),g.node;p(u);let m=se([a],([_])=>{let y=_;return c===0||y.length===0?[]:y.slice(Math.max(0,y.length-c))},{initial:i.tail(c),describeKind:"derived"}),v=xr(m);return u.set(c,{node:m,dispose:v}),m},slice(c,g){if(!Number.isInteger(c)||c<0)throw new RangeError(`slice: start must be a non-negative integer (got ${c})`);if(g!==void 0&&(!Number.isInteger(g)||g<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${g})`);let m=f(c,g),v=l.get(m);if(v!==void 0)return l.delete(m),l.set(m,v),v.node;p(l);let _=se([a],([b])=>{let x=b;return g===void 0?x.slice(c):x.slice(c,g)},{initial:i.slice(c,g),describeKind:"derived"}),y=xr(_);return l.set(m,{node:_,dispose:y}),_},disposeTail(c){let g=u.get(c);return g===void 0?!1:(g.dispose(),u.delete(c),!0)},disposeSlice(c,g){let m=f(c,g),v=l.get(m);return v===void 0?!1:(v.dispose(),l.delete(m),!0)},disposeAllViews(){for(let c of u.values())c.dispose();u.clear();for(let c of l.values())c.dispose();l.clear()},dispose(){for(let c of u.values())c.dispose();u.clear();for(let c of l.values())c.dispose();l.clear()}}}st();function Er(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}var Xo=rt((t,e)=>{t("write"),t("signal"),e("observe")}),Zo=rt((t,e)=>{t("observe"),t("signal"),e("write")}),es=rt((t,e)=>{t("observe"),t("signal"),e("write")});function vt(t,e){return Er("cqrs",t,e)}var Kt=class extends ie{_eventLogs=new Map;_commandHandlers=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_eventStore;_seq=0;constructor(e,n={}){super(e,n.graph)}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}event(e){let n=this._eventLogs.get(e);if(n)return n.node;let r=Tr([],{name:e,versioning:0}),o=r.entries,s=se([o],([i])=>i,{name:e,describeKind:"state",meta:vt("event",{event_name:e}),guard:es,initial:o.cache});return this.add(s,{name:e}),this._keepaliveDisposers.push(de(s)),this._eventLogs.set(e,{log:r,node:s}),s}_appendEvent(e,n){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 o=r.log.entries.v,s={type:e,payload:n,timestampNs:ae(),seq:++this._seq,...o!=null?{v0:{id:o.id,version:o.version}}:{}};r.log.append(s),this._eventStore&&this._eventStore.persist(s)}command(e,n){let r=oe(void 0,{name:e,describeKind:"state",meta:{...vt("command",{command_name:e}),error:null},guard:Xo});return this.add(r,{name:e}),this._commandHandlers.set(e,n),r}dispatch(e,n){let r=this._commandHandlers.get(e);if(!r)throw new Error(`Unknown command: "${e}". Register with .command() first.`);let o=this.resolve(e);Ae(()=>{o.emit(n,{internal:!0});try{r(n,{emit:(s,i)=>this._appendEvent(s,i)}),o.meta.error.emit(null,{internal:!0})}catch(s){throw o.meta.error.emit(s,{internal:!0}),s}})}projection(e,n,r,o){let s=n.map(a=>(this._eventLogs.has(a)||this.event(a),this._eventLogs.get(a).node)),i=se(s,a=>{let d=[];for(let u of a){let l=u;d.push(...l)}return d.sort((u,l)=>u.timestampNs-l.timestampNs||u.seq-l.seq),r(o,d)},{name:e,describeKind:"derived",meta:vt("projection",{projection_name:e,source_events:n}),guard:Zo,initial:o});return this.add(i,{name:e}),this._keepaliveDisposers.push(de(i)),this._projections.add(e),i}saga(e,n,r){let o=n.map(d=>(this._eventLogs.has(d)||this.event(d),this._eventLogs.get(d).node)),s=new Map,i={},a=be(o,(d,u)=>{let l=i.n.meta.error;for(let f=0;f<d.length;f++){let p=d[f];if(p==null||p.length===0)continue;let h=p.at(-1);if(!h)continue;let c=n[f],g=s.get(c)??0;if(h.length>g){let m=h.slice(g);for(let v of m)try{r(v),l.emit(null,{internal:!0})}catch(_){l.emit(_,{internal:!0})}s.set(c,h.length)}}},{name:e,describeKind:"effect",meta:{...vt("saga",{saga_name:e,source_events:n}),error:null}});return i.n=a,this.add(a,{name:e}),this._keepaliveDisposers.push(de(a)),this._sagas.add(e),a}useEventStore(e){this._eventStore=e}async rebuildProjection(e,n,r){if(!this._eventStore)throw new Error("No event store wired. Call useEventStore() first.");let o=[];for(let s of e){let i=await this._eventStore.loadEvents(s);o.push(...i.events)}return o.sort((s,i)=>s.timestampNs-i.timestampNs||s.seq-i.seq),n(r,o)}};function Or(t,e){return new Kt(t,e)}var Jt=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},Qt=class{graph=new ie("request");onModuleDestroy(){this.graph.destroy()}},Nr,Yt;Nr=[(0,Xe.Module)({})];var le=class le{static forRoot(e){let n=e??{},r=n.name??"root",o=[{provide:Y,useFactory:()=>{let s=new ie(r);return n.build&&n.build(s),n.snapshot&&s.restore(n.snapshot),s}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:s=>new Jt(s),inject:[Y]},{provide:ve,useFactory:(s,i)=>new ve(s,i),inject:[Y,Sr.ModuleRef]}];if(n.nodes)for(let s of n.nodes)o.push({provide:ne(s),useFactory:i=>i.resolve(s),inject:[Y]});return n.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new Qt,scope:Xe.Scope.REQUEST},{provide:pe,useFactory:s=>s.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:Xe.Scope.REQUEST}),{module:le,global:!0,providers:o,exports:[Y,...(n.nodes??[]).map(ne),...n.requestScope?[pe]:[]]}}static forFeature(e){let n=[{provide:j(e.name),useFactory:r=>{let o=new ie(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),r.mount(e.name,o),o},inject:[Y]}];if(e.nodes)for(let r of e.nodes)n.push({provide:ne(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[j(e.name)]});return{module:le,providers:n,exports:[j(e.name),...(e.nodes??[]).map(r=>ne(`${e.name}::${r}`))]}}static forCqrs(e){let n=[{provide:j(e.name),useFactory:r=>{let o=Or(e.name,e.cqrs);return e.eventStore&&o.useEventStore(e.eventStore),e.build&&e.build(o),r.mount(e.name,o),o},inject:[Y]}];if(e.nodes)for(let r of e.nodes)n.push({provide:ne(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[j(e.name)]});return{module:le,providers:n,exports:[j(e.name),...(e.nodes??[]).map(r=>ne(`${e.name}::${r}`))]}}};Yt=on(null),le=un(Yt,0,"GraphReflyModule",Nr,le),an(Yt,1,le);var _t=le;0&&(module.exports={ACTOR_KEY,COMMAND_HANDLERS,CQRS_EVENT_HANDLERS,CRON_HANDLERS,CommandHandler,EVENT_HANDLERS,EventHandler,GRAPHREFLY_REQUEST_GRAPH,GRAPHREFLY_ROOT_GRAPH,GraphCron,GraphInterval,GraphReflyEventExplorer,GraphReflyGuard,GraphReflyGuardImpl,GraphReflyModule,INTERVAL_HANDLERS,InjectCqrsGraph,InjectGraph,InjectNode,ObserveGateway,OnGraphEvent,QUERY_HANDLERS,QueryHandler,SAGA_HANDLERS,SagaHandler,fromHeader,fromJwtPayload,getActor,getGraphToken,getNodeToken,observeSSE,observeSubscription,toObservable});
|
|
15
|
+
`)}function Bo(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yt(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let o=t.indexOf("]",n+1);if(o<=n+1){e+="\\[";continue}let s=t.slice(n+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,n=o;continue}e+=Bo(r)}return e+="$",new RegExp(e)}var Vo={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"},Wo={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function bt(t){if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||t==null)return String(t);try{return JSON.stringify(t)}catch{return"[unserializable]"}}function zo(t){return t==="none"?Wo:t==="ansi"||t==null?Vo:{data:t.data??"",dirty:t.dirty??"",resolved:t.resolved??"",invalidate:t.invalidate??"",pause:t.pause??"",resume:t.resume??"",complete:t.complete??"",error:t.error??"",teardown:t.teardown??"",derived:t.derived??"",path:t.path??"",reset:t.reset??""}}function gr(t){if(t==null)return{};let e=t.detail;return e==="full"?{...t,structured:t.structured??!0,timeline:t.timeline??!0,causal:t.causal??!0,derived:t.derived??!0}:e==="minimal"?{...t,structured:t.structured??!0}:t.format==="stage-log"?{...t,structured:t.structured??!0,timeline:t.timeline??!0}:t}function Uo(t,e,n){for(let r=0;r<t.length;r++){let o=t.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function Vt(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(I))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${I}' (path separator)`);if(t===Q)throw new Error(`Graph "${e}": ${n} name "${Q}" is reserved for meta companion paths`);Uo(t,e,n)}function Ko(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(I);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function Yo(t,e){let n=!1;for(let o of t)if(!e.isMetaPassthrough(o[0])){n=!0;break}return n?t.filter(o=>e.isMetaPassthrough(o[0])):t}function _r(t){for(let e of t._mounts.values())_r(e);for(let e of t._nodes.values())try{e.down([[F]],{internal:!0})}catch{}}var ie=class t{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;constructor(e,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(I))throw new Error(`Graph name must not contain '${I}' (got "${e}")`);if(e===Q)throw new Error(`Graph name "${Q}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??ye,this._traceRing=new Qe(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=Le(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}add(e,n){let r=e.name,o=n?.name??r;if(o==null||o==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let s=o,i=n?.annotation;if(Vt(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:Re()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof P&&n._applyVersioning(e)}remove(e){Vt(e,this.name,"remove");let n=this._mounts.get(e);if(n){let s={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,d]of i)a.includes(`${I}${Q}${I}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...n._collectSubgraphs(`${e}${I}`)),this._mounts.delete(e),n._parent=void 0,_r(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[F]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let n=typeof e=="function"?e:(()=>{let s=yt(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>n(s));for(let s of o){let i=this.remove(s);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let o=e[r++];return{value:[o,n.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(I))return this.resolve(e);let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return n}get(e){return this.node(e).cache}set(e,n,r){let o=r?.internal===!0;this.node(e).down([[R,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);Ae(()=>{for(let[o,s]of r)this.set(o,s,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[ee]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let o=r?.internal===!0;this.node(e).down([[A,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[L]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[d,u]of this._nodes)r.set(u,d);let a=[];for(let[d,u]of this._nodes)if(u instanceof P)for(let l of u._deps){let f=r.get(l.node);f!=null&&a.push([f,d])}return a.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,d]of o)s.set(d,a);let i=[];for(let[a,d]of o)if(d instanceof P)for(let u of d._deps){let l=s.get(u.node);l!=null&&i.push([l,a])}return i.sort((a,d)=>a[0]<d[0]?-1:a[0]>d[0]?1:a[1]<d[1]?-1:a[1]>d[1]?1:0),i}mount(e,n){if(Vt(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let r=this;r!=null;r=r._parent)if(r===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let n=Ko(e,this.name);return this._resolveFromSegments(n)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let n=e;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],o=n.slice(1);if(o.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let s=this._nodes.get(r);if(s&&o.length>0&&o[0]===Q)return this._resolveMetaChainFromNode(s,o,n.join(I));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(I)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(I))}_resolveMetaChainFromNode(e,n,r){let o=e,s=0,i=[...n];for(;s<i.length;){if(i[s]!==Q)throw new Error(`Graph "${this.name}": expected ${Q} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Q} in "${r}"`);let a=i[s+1],d=o.meta[a];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=d,s+=2}return o}signal(e,n){if(n?.internal!==!0){for(let o of e)if(this.config.messageTier(o[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,o){for(let d of this._mounts.values())d._signalDeliver(e,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=Yo(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(l){if(l instanceof J)throw l;o.push(l)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,o)}}}_signalMetaSubtree(e,n,r,o,s){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,o)}catch(d){if(d instanceof J)throw d;s.push(d)}this._signalMetaSubtree(a,n,r,o,s)}}}describe(e){if(e?.reactive===!0)return this._describeReactive(e);let n=e?.actor,r=e?.filter,o=dt(e?.detail,e?.fields),s=e?.format==="spec",i=s?dt("minimal"):o,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[T,w]of a)d.set(w,T);let u=[];{let T=a.map(([,N])=>N),w=new Set(d.values()),E=0;for(;T.length>0;){let N=T.shift();if(N instanceof P)for(let M of N._deps){let S=M.node;if(d.has(S))continue;let C=S.name??"",k=C;if(!k||w.has(k))if(C){let $=2;for(;w.has(`${C}#${$}`);)$++;k=`${C}#${$}`}else for(k=`__internal__/${E++}`;w.has(k);)k=`__internal__/${E++}`;d.set(S,k),w.add(k),u.push([k,S]),T.push(S)}}}let l=[...a,...u],f={};for(let[T,w]of l){if(n!=null&&!w.allowsObserve(n))continue;let E=jt(w,i),N=w instanceof P?w._deps.map(k=>d.get(k.node)??k.node.name??""):[],{name:M,...S}=E,C={...S,deps:N};if(!s){let k=this._annotations.get(T);k!=null&&(C.annotation=k)}if(r!=null)if(typeof r=="function"){let k=r;if(!(k.length>=2?k(T,C):k(C)))continue}else{let k=!0;for(let[$,B]of Object.entries(r)){let X=$==="deps_includes"?"depsIncludes":$==="meta_has"?"metaHas":$;if(X==="depsIncludes"){if(!C.deps.includes(String(B))){k=!1;break}continue}if(X==="metaHas"){if(!Object.hasOwn(C.meta??{},String(B))){k=!1;break}continue}if(C[X]!==B){k=!1;break}}if(!k)continue}f[T]=C}let p=new Set(Object.keys(f)),h=[];for(let[T,w]of l)if(w instanceof P)for(let E of w._deps){let N=d.get(E.node);N!=null&&h.push([N,T])}h.sort((T,w)=>T[0]<w[0]?-1:T[0]>w[0]?1:T[1]<w[1]?-1:T[1]>w[1]?1:0);let c=h.map(([T,w])=>({from:T,to:w}));(n!=null||r!=null)&&(c=c.filter(T=>p.has(T.from)&&p.has(T.to)));let g=this._collectSubgraphs(""),m=n!=null||r!=null?g.filter(T=>{let w=`${T}${I}`;return[...p].some(E=>E===T||E.startsWith(w))}):g,v=this,_=e,y={name:this.name,nodes:f,edges:c,subgraphs:m,expand(T){let w={..._,format:void 0};return Array.isArray(T)?(w.fields=T,w.detail=void 0):(w.detail=T,w.fields=void 0),v.describe(w)}},b=e??{},x=b.format;return x==="json"?Ho(y,b):x==="pretty"?Fo(y,b):x==="mermaid"?br(y,b):x==="mermaid-url"?qo(y,b):x==="d2"?jo(y,b):x==="ascii"?ir(y,b):y}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;n.push(o),n.push(...this._mounts.get(r)._collectSubgraphs(`${o}${I}`))}return n}resourceProfile(e){return fr(this,e)}reachable(e,n,r={}){return r.withDetail===!0?zt(this.describe(),e,n,{...r,withDetail:!0}):zt(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,d]of Object.entries(o.nodes))d.lastMutation!=null&&i.set(a,d.lastMutation);return ar(o,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=oe(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,ze(()=>{a=!1,!d&&(o+=1,s.emit(o))}))},l=i.onEvent(m=>{let v=m.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||u()}),f=[],p=new WeakSet,h=m=>{if(p.has(m)||d)return;p.add(m);let v=m.topology.subscribe(_=>{for(let y of _){if(y[0]!==R)continue;let b=y[1];if(u(),b.kind==="added"&&b.nodeKind==="mount"){let x=m._mounts.get(b.name);x!=null&&h(x)}}});f.push(v);for(let _ of m._mounts.keys()){let y=m._mounts.get(_);y!=null&&h(y)}};h(this);let c;try{c=se([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,v)=>m===v})}catch(m){l();for(let v of f)v();throw i.dispose(),m}let g=de(c);return{node:c,dispose(){d=!0,l();for(let m of f)m();f.length=0,i.dispose(),g()}}}_explainReactive(e,n,r){let o=0,s=oe(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(h=>{let c=h.type;c!=="data"&&c!=="error"&&c!=="complete"&&c!=="teardown"||a||d||(a=!0,ze(()=>{a=!1,!d&&(o+=1,s.emit(o))}))}),l={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},f;try{f=se([s],()=>this._explainStatic(e,n,l),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(h,c)=>h.found===c.found&&h.reason===c.reason&&h.steps.length===c.steps.length&&Jo(h.steps,c.steps)})}catch(h){throw u(),i.dispose(),h}let p=de(f);return{node:f,dispose(){d=!0,u(),i.dispose(),p()}}}_pathsMatching(e){let n=yt(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>n.test(o))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${I}${r}`;this._mounts.get(r)._collectObserveTargets(o,n)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${I}${r}`;n.push([s,o]),this._appendMetaObserveTargets(s,o,n)}}_appendMetaObserveTargets(e,n,r){for(let o of Object.keys(n.meta).sort()){let s=n.meta[o],i=`${e}${I}${Q}${I}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,n){let r=typeof e=="string",s=gr(r?n:e),i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let l=e,f=this.resolve(l);if(a!=null&&!f.allowsObserve(a))throw new J({actor:a,action:"observe",nodeName:l});return i?this._buildStructuredObserver([[l,f]],s,"one"):{subscribe(p){return f.subscribe(p)},up(p){try{f.up?.(p)}catch(h){if(h instanceof J)return;throw h}}}}let d=[];this._collectObserveTargets("",d),d.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let u=a==null?d:d.filter(([,l])=>l.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:l=>{let f=u.map(([p,h])=>h.subscribe(c=>{l(p,c)}));return()=>{for(let p of f)p()}},up:(l,f)=>{try{this.resolve(l).up?.(f)}catch(p){if(p instanceof J)return;throw p}}}}_buildStructuredObserver(e,n,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let l=this.resolve(o);return this._buildStructuredObserver([[o,l]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((l,f)=>l[0]<f[0]?-1:l[0]>f[0]?1:0);let d=i.actor,u=d==null?a:a.filter(([,l])=>l.allowsObserve(d));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,s)}_createObserveResult(e,n,r){let o=n.timeline===!0,s=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",d=this.config.inspectorEnabled,u=(s||i)&&d,l=n.maxEvents,f=l!=null&&l>0?new Qe(l):null,p=[],h=new Set,c={},g=new Set,m=0,v=0,_=0,y=0,b=0,x=0,T=!1,w=!1,E=0,N=new Map,M=new Map,S=new Map,C=O=>{f?f.push(O):p.push(O);for(let G of h)G(O)},k=()=>o?{timestamp_ns:Re(),in_batch:et(),batch_id:E}:{},$=(O,G)=>{if(!(!u||!(O instanceof P)))return O._setInspectorHook(z=>{if(z.kind==="dep_message")N.set(O,z.depIndex);else if(z.kind==="run"){let Pe=z.batchData.map((D,q)=>D!=null&&D.length>0?D.at(-1):z.prevData[q]);M.set(O,Pe);let U=z.batchData.map(D=>D!=null?[...D]:void 0);S.set(O,U),i&&C({type:"derived",path:G,dep_values:Pe,dep_batches:U,...k()})}})},B=O=>{let G=N.get(O),z=M.get(O);if(!s||z==null)return{};let U=(G!=null&&G>=0&&O instanceof P?O._deps[G]:void 0)?.node,D=U?.v,q=S.get(O);return{trigger_dep_index:G,trigger_dep_name:U?.name,...D!=null?{trigger_version:{id:D.id,version:D.version}}:{},dep_values:[...z],...q!=null?{dep_batches:q}:{}}},X=[],fe=[];for(let[O,G]of e){let z=$(G,O);z&&X.push(z),fe.push(G.subscribe(Pe=>{E++;for(let U of Pe){let D=U[0],q=k();if(D===R){c[O]=U[1];let Et=G instanceof P?G.lastMutation?.actor??ue:ue;C({type:"data",path:O,data:U[1],actor:Et,...q,...B(G)})}else if(a)D===W?m++:D===Z?v++:D===ee?_++:D===K?y++:D===te?b++:D===F?x++:D===L&&!g.has(O)?T=!0:D===A&&(w=!0,g.add(O));else if(D===W)m++,C({type:"dirty",path:O,...q});else if(D===Z)v++,C({type:"resolved",path:O,...q,...B(G)});else if(D===ee)_++,C({type:"invalidate",path:O,...q});else if(D===K)y++,C({type:"pause",path:O,lockId:U[1],...q});else if(D===te)b++,C({type:"resume",path:O,lockId:U[1],...q});else if(D===L)g.has(O)||(T=!0),C({type:"complete",path:O,...q});else if(D===A){w=!0,g.add(O);let Et=G instanceof P?G.lastMutation?.actor??ue:ue;C({type:"error",path:O,data:U[1],actor:Et,...q})}else D===F&&(x++,C({type:"teardown",path:O,...q}))}}))}let wt=!1,xt=()=>{if(!wt){wt=!0;for(let O of fe)O();for(let O of X)O();for(let O of Ze)O({value:void 0,done:!0});Ze.length=0}},Tt=[],Ze=[];h.add(O=>{let G=Ze.shift();G?G({value:O,done:!1}):Tt.push(O)});let Xt={get values(){return c},get dirtyCount(){return m},get resolvedCount(){return v},get invalidateCount(){return _},get pauseCount(){return y},get resumeCount(){return b},get teardownCount(){return x},get events(){return f?f.toArray():[...p]},get anyCompletedCleanly(){return T},get anyErrored(){return w},get completedWithoutErrors(){return T&&!w},onEvent(O){return h.add(O),()=>h.delete(O)},dispose:xt,expand(O){xt();let G={...n};return typeof O=="string"?G.detail=O:Object.assign(G,O),r(gr(G))},[Symbol.asyncIterator](){return{next(){return Tt.length>0?Promise.resolve({value:Tt.shift(),done:!1}):wt?Promise.resolve({value:void 0,done:!0}):new Promise(O=>Ze.push(O))},return(){return xt(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(Xt,n),Xt}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let o=n.logger??(c=>console.log(c)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:c=>(s==null||s.has(c))&&(i==null||!i.has(c)),d=zo(n.theme),u=r==="stage-log"?Re():0,l=c=>c==null?"":n.stageLabels?.[c]??c,f=(c,g)=>c.length>g?`${c.slice(0,g-1)}\u2026`:c,p=c=>c.type==="data"||c.type==="error"?f(bt(c.data),120):"",h=c=>{if(r==="stage-log"){let w=(Re()-u)/1e9,E=l(c.path).padEnd(9);if(c.type==="data"){let N=p(c);return`[${w.toFixed(3)}s] ${E} \u2190${N?` ${N}`:""}`}if(c.type==="error"){let N=p(c);return`[${w.toFixed(3)}s] ${E} \u2717${N?` ${N}`:""}`}return c.type==="complete"?`[${w.toFixed(3)}s] ${E} \u25A0 complete`:`[${w.toFixed(3)}s] ${E} ${c.type}`}if(r==="json")try{return JSON.stringify(c)}catch{return JSON.stringify({type:c.type,path:c.path,data:"[unserializable]"})}let g=d[c.type]??"",m=c.path?`${d.path}${c.path}${d.reset} `:"",v=c.type==="data"||c.type==="error",_=c.type==="pause"||c.type==="resume",y=v?` ${bt(c.data)}`:_?` ${bt(c.lockId)}`:"",b=c.type==="data"||c.type==="resolved"||c.type==="derived"?c:void 0,x=b?.trigger_dep_name!=null?` <- ${b.trigger_dep_name}`:b?.trigger_dep_index!=null?` <- #${b.trigger_dep_index}`:"",T=c.in_batch?" [batch]":"";return`${m}${g}${c.type.toUpperCase()}${d.reset}${y}${x}${T}`};e.onEvent(c=>{a(c.type)&&o(h(c),c)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){pr(this._disposers,this.name),this.signal([[F]],{internal:!0}),pr(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:n,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:d,guard:u,...l}=r.nodes[a];o[a]=l}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return En(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??ye,{codec:o,codecVersion:s,payload:i}=On(e,r);return o.decode(i,s)}restore(e,n){if(hr(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(s=>yt(s)),o=n?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let d=this.tryResolve(s)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(e,n){hr(e);let r=typeof n=="function"?n:n?.build,o=typeof n=="function"?void 0:n?.factories,s=new t(e.name);if(r)return r(s),s.restore(e),s;for(let h of[...e.subgraphs].sort((c,g)=>{let m=c.split(I).length,v=g.split(I).length;return m!==v?m-v:c<g?-1:c>g?1:0})){let c=h.split(I),g=s;for(let m of c)g._mounts.has(m)||g.mount(m,new t(m)),g=g._mounts.get(m)}let i=o?Object.entries(o).map(([h,c])=>({re:yt(h),factory:c})):[],a=h=>{for(let c of i)if(c.re.test(h))return c.factory},d=h=>{let c=h.split(I),g=c.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${h}"`);let m=s;for(let v of c){let _=m._mounts.get(v);if(!_)throw new Error(`unknown mount "${v}" in path "${h}"`);m=_}return[m,g]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${I}${Q}${I}`)).sort((h,c)=>h[0]<c[0]?-1:h[0]>c[0]?1:0),l=new Map(u),f=new Map,p=!0;for(;l.size>0&&p;){p=!1;for(let[h,c]of[...l.entries()]){let g=c?.deps??[];if(!g.every(x=>f.has(x)))continue;let[m,v]=d(h),_={...c?.meta??{}},y=a(h),b;if(c?.type==="state")b=oe(c.value,{meta:_});else{if(y==null)continue;b=y(v,{path:h,type:c.type,value:c.value,meta:_,deps:g,resolvedDeps:g.map(x=>f.get(x))})}m.add(b,{name:v}),f.set(h,b),l.delete(h),p=!0}}if(l.size>0){let h=[...l.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let o=(u,l)=>{if(u.disposed)return;let f=Go(l.nodes);if(u.lastSnapshot!=null&&f!==""&&f===u.lastFingerprint)return;let p=u.seq+1,h=ae(),m=u.lastSnapshot==null||p%u.compactEvery===0?{mode:"full",snapshot:l,seq:p,timestamp_ns:h,format_version:_e}:{mode:"diff",diff:wr(u.lastSnapshot,l),seq:p,timestamp_ns:h,format_version:_e};if(u.tier.filter&&!u.tier.filter(this.name,m))return;let v;try{v=u.tier.save(this.name,m)}catch(_){n.onError?.(_,u.tier);return}if(v&&typeof v.then=="function"){let b=(u.savePending??Promise.resolve()).then(()=>v,()=>v).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=l,u.lastFingerprint=f)},x=>{n.onError?.(x,u.tier)});u.savePending=b.finally(()=>{u.savePending===b&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=l,u.lastFingerprint=f},s=(u,l)=>{try{o(u,l)}catch(f){n.onError?.(f,u.tier)}},i=(u,l)=>{if(!l.some(c=>{let g=this.config.messageTier(c[0]);return g>=3&&g<5}))return;if(n.filter){let c=this.tryResolve(u);if(c==null)return;let g=jt(c,dt("standard"));if(!n.filter(u,g))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let c of r)c.disposed||(c.debounceMs===0?s(c,h()):(c.timer==null&&(c.timer=new ct),c.timer.start(c.debounceMs,()=>{c.disposed||s(c,this.snapshot())})))},a;if(n.paths!=null){let l=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(f=>{let p=this.tryResolve(f);return p==null?()=>{}:p.subscribe(h=>i(f,h))});a=()=>{for(let f of l)f()}}else a=this.observe().subscribe((u,l)=>i(u,l));let d=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,n){for(let r of e){let o;try{o=await r.load(this.name)}catch(i){n?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===_e&&s.nodes!=null)return this.restore(s),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let o of n){let s;try{s=await o.load(e)}catch(d){r?.onError?.(d,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===_e&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(d){r?.onError?.(d,o)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,n,r){if(e!=null&&n!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,n),this.config.inspectorEnabled){let o={path:e,annotation:n,timestamp_ns:Re(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let n=this._traceRing.toArray().filter(o=>!e(o)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let o of n)this._traceRing.push(o);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(n.nodes)),s=[...o].filter(_=>!r.has(_)).sort(),i=[...r].filter(_=>!o.has(_)).sort(),a=[],d=[];for(let _ of r){if(!o.has(_))continue;let y=e.nodes[_],b=n.nodes[_],x=y.v,T=b.v;x!=null&&T!=null&&x.id===T.id&&x.version!==T.version&&d.push({path:_,id:x.id,from:x.version,to:T.version});let w=x!=null&&T!=null&&x.id===T.id&&x.version===T.version;for(let E of["type","status","sentinel"]){let N=y[E],M=b[E];N!==M&&a.push({path:_,field:E,from:N,to:M})}if(!w)for(let E of["value","meta"]){let N=y[E],M=b[E];Io(N,M)||a.push({path:_,field:E,from:N,to:M})}}let u=_=>`${_.from} ${_.to}`,l=new Set(e.edges.map(u)),f=new Set(n.edges.map(u)),p=n.edges.filter(_=>!l.has(u(_))),h=e.edges.filter(_=>!f.has(u(_))),c=new Set(e.subgraphs),g=new Set(n.subgraphs),m=[...g].filter(_=>!c.has(_)).sort(),v=[...c].filter(_=>!g.has(_)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:p,edgesRemoved:h,subgraphsAdded:m,subgraphsRemoved:v}}};function wr(t,e){let n=ie.diff(t,e),r={};for(let o of n.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...n,nodesAddedFull:r}}function zt(t,e,n,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,d=new Map,u=new Map,l=new Set;for(let[y,b]of Object.entries(t.nodes)){if(!y)continue;l.add(y);let x=b.deps??[];i.set(y,x);for(let T of x)T&&(l.add(T),a.has(T)||a.set(T,new Set),a.get(T).add(y))}for(let y of t.edges){if(y==null||typeof y!="object")continue;let b=typeof y.from=="string"?y.from:"",x=typeof y.to=="string"?y.to:"";!b||!x||(l.add(b),l.add(x),u.has(b)||u.set(b,new Set),u.get(b).add(x),d.has(x)||d.set(x,new Set),d.get(x).add(b))}if(!l.has(e))return r.withDetail?o:[];let f=r.both===!0,p=y=>{if(f){let w=i.get(y)??[],E=d.get(y),N=a.get(y),M=u.get(y),S=[...w];return E&&S.push(...E),N&&S.push(...N),M&&S.push(...M),S}if(n==="upstream"){let w=i.get(y)??[],E=d.get(y);return E?[...w,...E]:w}let b=a.get(y),x=u.get(y),T=b?[...b]:[];return x&&T.push(...x),T},h=new Set([e]),c=new Map,g=[{path:e,depth:0}],m=0,v=!1;for(;m<g.length;){let y=g[m++];if(s!=null&&y.depth>=s){p(y.path).length>0&&(v=!0);continue}for(let b of p(y.path))!b||h.has(b)||(h.add(b),c.set(b,y.depth+1),g.push({path:b,depth:y.depth+1}))}let _=[...c.keys()].sort((y,b)=>y<b?-1:y>b?1:0);return r.withDetail?{paths:_,depths:c,truncated:v}:_}function Jo(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],o=e[n];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}Ue();je();Ge();Be();Ge();Ie();Ke();Ue();re();Ke();var Ut=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,n){if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=n,n!==void 0){if(this._buf=new Array(n),e&&e.length>0){let r=Math.min(e.length,n),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._size+e;if(!(n<0||n>=this._size))return this._maxSize!==void 0?this._buf[(this._head+n)%this._maxSize]:this._buf[n]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=n;r<e.length;r++)this._rawAppend(e[r]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let n=0;n<e;n++)this._buf[(this._head+n)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let n=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,n);else{for(let r=0;r<n;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+n)%this._maxSize}return this._size-=n,this._version+=1,n}slice(e,n){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(n!==void 0&&(!Number.isInteger(n)||n<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${n})`);let r=n===void 0?this._size:Math.min(Math.max(n,0),this._size),o=Math.min(e,this._size);if(o>=r)return[];let s=r-o;if(this._maxSize===void 0)return this._buf.slice(o,r);let i=new Array(s);for(let a=0;a<s;a++)i[a]=this._buf[(this._head+o+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let n=Math.min(e,this._size);return this.slice(this._size-n,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this._buf[(this._head+n)%this._maxSize];return e}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function xr(t){return t.subscribe(()=>{})}var Qo=64;function Tr(t,e={}){let{name:n,maxSize:r,versioning:o,backend:s}=e,i=s??new Ut(t,r),a=oe(i.toArray(),{name:n,describeKind:"state",equals:(c,g)=>c===g,...o!=null?{versioning:o}:{}});function d(){let c=i.toArray();Ae(()=>{a.down([[W]]),a.down([[R,c]])})}let u=new Map,l=new Map;function f(c,g){return`${c}:${g===void 0?"END":g}`}function p(c){if(c.size<Qo)return;let g=c.keys().next();if(g.done)return;let m=c.get(g.value);m!==void 0&&m.dispose(),c.delete(g.value)}function h(c){let g=i.version;try{return c()}finally{i.version!==g&&d()}}return{entries:a,get size(){return i.size},at(c){return i.at(c)},append(c){h(()=>i.append(c))},appendMany(c){c.length!==0&&h(()=>i.appendMany(c))},clear(){h(()=>i.clear())},trimHead(c){h(()=>i.trimHead(c))},tail(c){if(!Number.isInteger(c)||c<0)throw new RangeError(`tail: n must be a non-negative integer (got ${c})`);let g=u.get(c);if(g!==void 0)return u.delete(c),u.set(c,g),g.node;p(u);let m=se([a],([_])=>{let y=_;return c===0||y.length===0?[]:y.slice(Math.max(0,y.length-c))},{initial:i.tail(c),describeKind:"derived"}),v=xr(m);return u.set(c,{node:m,dispose:v}),m},slice(c,g){if(!Number.isInteger(c)||c<0)throw new RangeError(`slice: start must be a non-negative integer (got ${c})`);if(g!==void 0&&(!Number.isInteger(g)||g<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${g})`);let m=f(c,g),v=l.get(m);if(v!==void 0)return l.delete(m),l.set(m,v),v.node;p(l);let _=se([a],([b])=>{let x=b;return g===void 0?x.slice(c):x.slice(c,g)},{initial:i.slice(c,g),describeKind:"derived"}),y=xr(_);return l.set(m,{node:_,dispose:y}),_},disposeTail(c){let g=u.get(c);return g===void 0?!1:(g.dispose(),u.delete(c),!0)},disposeSlice(c,g){let m=f(c,g),v=l.get(m);return v===void 0?!1:(v.dispose(),l.delete(m),!0)},disposeAllViews(){for(let c of u.values())c.dispose();u.clear();for(let c of l.values())c.dispose();l.clear()},dispose(){for(let c of u.values())c.dispose();u.clear();for(let c of l.values())c.dispose();l.clear()}}}st();function Er(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}var Xo=rt((t,e)=>{t("write"),t("signal"),e("observe")}),Zo=rt((t,e)=>{t("observe"),t("signal"),e("write")}),es=rt((t,e)=>{t("observe"),t("signal"),e("write")});function vt(t,e){return Er("cqrs",t,e)}var Kt=class extends ie{_eventLogs=new Map;_commandHandlers=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_eventStore;_seq=0;constructor(e,n={}){super(e,n.graph)}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}event(e){let n=this._eventLogs.get(e);if(n)return n.node;let r=Tr([],{name:e,versioning:0}),o=r.entries,s=se([o],([i])=>i,{name:e,describeKind:"state",meta:vt("event",{event_name:e}),guard:es,initial:o.cache});return this.add(s,{name:e}),this._keepaliveDisposers.push(de(s)),this._eventLogs.set(e,{log:r,node:s}),s}_appendEvent(e,n){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 o=r.log.entries.v,s={type:e,payload:n,timestampNs:ae(),seq:++this._seq,...o!=null?{v0:{id:o.id,version:o.version}}:{}};r.log.append(s),this._eventStore&&this._eventStore.persist(s)}command(e,n){let r=oe(void 0,{name:e,describeKind:"state",meta:{...vt("command",{command_name:e}),error:null},guard:Xo});return this.add(r,{name:e}),this._commandHandlers.set(e,n),r}dispatch(e,n){let r=this._commandHandlers.get(e);if(!r)throw new Error(`Unknown command: "${e}". Register with .command() first.`);let o=this.resolve(e);Ae(()=>{o.emit(n,{internal:!0});try{r(n,{emit:(s,i)=>this._appendEvent(s,i)}),o.meta.error.emit(null,{internal:!0})}catch(s){throw o.meta.error.emit(s,{internal:!0}),s}})}projection(e,n,r,o){let s=n.map(a=>(this._eventLogs.has(a)||this.event(a),this._eventLogs.get(a).node)),i=se(s,a=>{let d=[];for(let u of a){let l=u;d.push(...l)}return d.sort((u,l)=>u.timestampNs-l.timestampNs||u.seq-l.seq),r(o,d)},{name:e,describeKind:"derived",meta:vt("projection",{projection_name:e,source_events:n}),guard:Zo,initial:o});return this.add(i,{name:e}),this._keepaliveDisposers.push(de(i)),this._projections.add(e),i}saga(e,n,r){let o=n.map(d=>(this._eventLogs.has(d)||this.event(d),this._eventLogs.get(d).node)),s=new Map,i={},a=be(o,(d,u)=>{let l=i.n.meta.error;for(let f=0;f<d.length;f++){let p=d[f];if(p==null||p.length===0)continue;let h=p.at(-1);if(!h)continue;let c=n[f],g=s.get(c)??0;if(h.length>g){let m=h.slice(g);for(let v of m)try{r(v),l.emit(null,{internal:!0})}catch(_){l.emit(_,{internal:!0})}s.set(c,h.length)}}},{name:e,describeKind:"effect",meta:{...vt("saga",{saga_name:e,source_events:n}),error:null}});return i.n=a,this.add(a,{name:e}),this._keepaliveDisposers.push(de(a)),this._sagas.add(e),a}useEventStore(e){this._eventStore=e}async rebuildProjection(e,n,r){if(!this._eventStore)throw new Error("No event store wired. Call useEventStore() first.");let o=[];for(let s of e){let i=await this._eventStore.loadEvents(s);o.push(...i.events)}return o.sort((s,i)=>s.timestampNs-i.timestampNs||s.seq-i.seq),n(r,o)}};function Or(t,e){return new Kt(t,e)}var Jt=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},Qt=class{graph=new ie("request");onModuleDestroy(){this.graph.destroy()}},Nr,Yt;Nr=[(0,Xe.Module)({})];var le=class le{static forRoot(e){let n=e??{},r=n.name??"root",o=[{provide:Y,useFactory:()=>{let s=new ie(r);return n.build&&n.build(s),n.snapshot&&s.restore(n.snapshot),s}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:s=>new Jt(s),inject:[Y]},{provide:ve,useFactory:(s,i)=>new ve(s,i),inject:[Y,Sr.ModuleRef]}];if(n.nodes)for(let s of n.nodes)o.push({provide:ne(s),useFactory:i=>i.resolve(s),inject:[Y]});return n.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new Qt,scope:Xe.Scope.REQUEST},{provide:pe,useFactory:s=>s.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:Xe.Scope.REQUEST}),{module:le,global:!0,providers:o,exports:[Y,...(n.nodes??[]).map(ne),...n.requestScope?[pe]:[]]}}static forFeature(e){let n=[{provide:j(e.name),useFactory:r=>{let o=new ie(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),r.mount(e.name,o),o},inject:[Y]}];if(e.nodes)for(let r of e.nodes)n.push({provide:ne(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[j(e.name)]});return{module:le,providers:n,exports:[j(e.name),...(e.nodes??[]).map(r=>ne(`${e.name}::${r}`))]}}static forCqrs(e){let n=[{provide:j(e.name),useFactory:r=>{let o=Or(e.name,e.cqrs);return e.eventStore&&o.useEventStore(e.eventStore),e.build&&e.build(o),r.mount(e.name,o),o},inject:[Y]}];if(e.nodes)for(let r of e.nodes)n.push({provide:ne(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[j(e.name)]});return{module:le,providers:n,exports:[j(e.name),...(e.nodes??[]).map(r=>ne(`${e.name}::${r}`))]}}};Yt=on(null),le=un(Yt,0,"GraphReflyModule",Nr,le),an(Yt,1,le);var _t=le;0&&(module.exports={ACTOR_KEY,COMMAND_HANDLERS,CQRS_EVENT_HANDLERS,CRON_HANDLERS,CommandHandler,EVENT_HANDLERS,EventHandler,GRAPHREFLY_REQUEST_GRAPH,GRAPHREFLY_ROOT_GRAPH,GraphCron,GraphInterval,GraphReflyEventExplorer,GraphReflyGuard,GraphReflyGuardImpl,GraphReflyModule,INTERVAL_HANDLERS,InjectCqrsGraph,InjectGraph,InjectNode,ObserveGateway,OnGraphEvent,QUERY_HANDLERS,QueryHandler,SAGA_HANDLERS,SagaHandler,fromHeader,fromJwtPayload,getActor,getGraphToken,getNodeToken,observeSSE,observeSubscription,toObservable});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { T as ToObservableOptions, t as toObservable } from '../../observable-BrUAPeH_.cjs';
|
|
2
|
-
export { A as ACTOR_KEY, a as ActorExtractor, C as COMMAND_HANDLERS, b as CQRS_EVENT_HANDLERS, c as CRON_HANDLERS, d as CommandHandler, e as CommandHandlerMeta, E as EVENT_HANDLERS, f as EventHandler, g as EventHandlerMeta, G as GRAPHREFLY_REQUEST_GRAPH, h as GRAPHREFLY_ROOT_GRAPH, j as GraphCron, k as GraphCronMeta, l as GraphInterval, m as GraphIntervalMeta, n as GraphReflyCqrsOptions, o as GraphReflyEventExplorer, p as GraphReflyFeatureOptions, q as GraphReflyGuard, r as GraphReflyGuardImpl, s as GraphReflyModule, t as GraphReflyRootOptions, I as INTERVAL_HANDLERS, u as InjectCqrsGraph, v as InjectGraph, w as InjectNode, O as ObserveGateway, x as ObserveGatewayOptions, y as ObserveSSEOptions, z as ObserveSubscriptionOptions, B as ObserveWsCommand, D as ObserveWsMessage, F as OnGraphEvent, H as OnGraphEventMeta, Q as QUERY_HANDLERS, J as QueryHandler, K as QueryHandlerMeta, S as SAGA_HANDLERS, L as SagaHandler, M as SagaHandlerMeta, N as fromHeader, P as fromJwtPayload, R as getActor, T as getGraphToken, U as getNodeToken, V as observeSSE, W as observeSubscription } from '../../index-
|
|
2
|
+
export { A as ACTOR_KEY, a as ActorExtractor, C as COMMAND_HANDLERS, b as CQRS_EVENT_HANDLERS, c as CRON_HANDLERS, d as CommandHandler, e as CommandHandlerMeta, E as EVENT_HANDLERS, f as EventHandler, g as EventHandlerMeta, G as GRAPHREFLY_REQUEST_GRAPH, h as GRAPHREFLY_ROOT_GRAPH, j as GraphCron, k as GraphCronMeta, l as GraphInterval, m as GraphIntervalMeta, n as GraphReflyCqrsOptions, o as GraphReflyEventExplorer, p as GraphReflyFeatureOptions, q as GraphReflyGuard, r as GraphReflyGuardImpl, s as GraphReflyModule, t as GraphReflyRootOptions, I as INTERVAL_HANDLERS, u as InjectCqrsGraph, v as InjectGraph, w as InjectNode, O as ObserveGateway, x as ObserveGatewayOptions, y as ObserveSSEOptions, z as ObserveSubscriptionOptions, B as ObserveWsCommand, D as ObserveWsMessage, F as OnGraphEvent, H as OnGraphEventMeta, Q as QUERY_HANDLERS, J as QueryHandler, K as QueryHandlerMeta, S as SAGA_HANDLERS, L as SagaHandler, M as SagaHandlerMeta, N as fromHeader, P as fromJwtPayload, R as getActor, T as getGraphToken, U as getNodeToken, V as observeSSE, W as observeSubscription } from '../../index-C4QTaDli.cjs';
|
|
3
3
|
import 'rxjs';
|
|
4
4
|
import '../../node-BVV7G1bq.cjs';
|
|
5
5
|
import '@nestjs/common';
|
|
6
6
|
import '@nestjs/core';
|
|
7
|
-
import '../../graph-
|
|
7
|
+
import '../../graph-CdJeX7O7.cjs';
|
|
8
8
|
import '../../meta-COtmHLwT.cjs';
|
|
9
9
|
import '../../extra/storage-core.cjs';
|
|
10
|
-
import '../../index-
|
|
10
|
+
import '../../index-aBqZUx3B.cjs';
|