@graphrefly/graphrefly 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/dist/{cascading-dNCtjW8j.d.cts → cascading-BfQmSmjU.d.cts} +21 -2
  2. package/dist/{cascading-BszPheHD.d.ts → cascading-D3sapjue.d.ts} +21 -2
  3. package/dist/{chunk-T5SHIKJD.js → chunk-3JRKP4BH.js} +1 -1
  4. package/dist/{chunk-GJR3P6JG.js → chunk-3Q2WXM6X.js} +1 -1
  5. package/dist/chunk-4KAUNEKV.js +3 -0
  6. package/dist/{chunk-SLMYTGTU.js → chunk-4UUDNFYG.js} +1 -1
  7. package/dist/chunk-4VXL3UZK.js +1 -0
  8. package/dist/{chunk-AV3PIDFQ.js → chunk-4ZPO2EL5.js} +1 -1
  9. package/dist/{chunk-VWPRPPKR.js → chunk-5LJAQTSS.js} +1 -1
  10. package/dist/{chunk-W4TSQ6RJ.js → chunk-7AJKUA36.js} +1 -1
  11. package/dist/{chunk-RD52SNH2.js → chunk-7EJTWGKW.js} +1 -1
  12. package/dist/{chunk-GNCBXARM.js → chunk-7EQPXQ7H.js} +1 -1
  13. package/dist/chunk-7QMVU3IX.js +1 -0
  14. package/dist/{chunk-BA5URFYW.js → chunk-A4JT4SAD.js} +1 -1
  15. package/dist/chunk-ASDKRNOJ.js +60 -0
  16. package/dist/{chunk-Y32RJO24.js → chunk-CZVYLXFK.js} +1 -1
  17. package/dist/{chunk-567NWZ3T.js → chunk-DWIAG62L.js} +1 -1
  18. package/dist/{chunk-33FA6V4B.js → chunk-EBQ6FXKW.js} +1 -1
  19. package/dist/chunk-FTA5TB2A.js +1 -0
  20. package/dist/{chunk-P7JXGKDO.js → chunk-GF5T7PGC.js} +1 -1
  21. package/dist/{chunk-WANIEEKV.js → chunk-I4U3TPK2.js} +1 -1
  22. package/dist/{chunk-KA6MMXIY.js → chunk-JMGGCSIC.js} +1 -1
  23. package/dist/chunk-JXRZXP3N.js +1 -0
  24. package/dist/{chunk-5Z4HDCO6.js → chunk-K54OKWNY.js} +1 -1
  25. package/dist/{chunk-DDPYNMGG.js → chunk-KN4Q5MQO.js} +1 -1
  26. package/dist/chunk-LWGLBCMU.js +1 -0
  27. package/dist/{chunk-TWMEGG45.js → chunk-N2KKISCE.js} +1 -1
  28. package/dist/{chunk-4OFIQ66T.js → chunk-OKQUPJRY.js} +1 -1
  29. package/dist/chunk-PNTBXOQ6.js +5 -0
  30. package/dist/chunk-PSQNYY72.js +7 -0
  31. package/dist/{chunk-XHVB6G6M.js → chunk-PZP4MEXK.js} +1 -1
  32. package/dist/{chunk-7TDOES3L.js → chunk-Q2SY7M7K.js} +1 -1
  33. package/dist/{chunk-OL33ZI6R.js → chunk-RWGJQQLT.js} +1 -1
  34. package/dist/chunk-SGS4OJGS.js +1 -0
  35. package/dist/chunk-UMH3HSP7.js +1 -0
  36. package/dist/{chunk-BZP5T4X6.js → chunk-W6FQIFVE.js} +1 -1
  37. package/dist/{chunk-SHYH5SXV.js → chunk-WLPVGXQ6.js} +1 -1
  38. package/dist/chunk-WQ7I7JVU.js +1 -0
  39. package/dist/{chunk-XQAXYVXX.js → chunk-WYJTXYWX.js} +1 -1
  40. package/dist/{chunk-3NEPQO2E.js → chunk-X2VHDT26.js} +1 -1
  41. package/dist/{chunk-GLSM33ZM.js → chunk-XEFAMCEA.js} +1 -1
  42. package/dist/{chunk-AUY2YKCO.js → chunk-XRSHMHEG.js} +1 -1
  43. package/dist/chunk-Y26UN6J5.js +18 -0
  44. package/dist/{chunk-BKPLTBL5.js → chunk-YQJPYEAL.js} +1 -1
  45. package/dist/{chunk-73Z3W2RN.js → chunk-YZ6VYLFD.js} +1 -1
  46. package/dist/{chunk-4JJCCD5S.js → chunk-YZKGGMPT.js} +1 -1
  47. package/dist/chunk-Z3UWIJ3A.js +1 -0
  48. package/dist/{chunk-Y36UZ5VS.js → chunk-ZM7C2FUM.js} +1 -1
  49. package/dist/compat/index.cjs +1 -1
  50. package/dist/compat/index.js +1 -1
  51. package/dist/compat/jotai/index.cjs +1 -1
  52. package/dist/compat/jotai/index.js +1 -1
  53. package/dist/compat/nanostores/index.cjs +1 -1
  54. package/dist/compat/nanostores/index.js +1 -1
  55. package/dist/compat/nestjs/index.cjs +5 -5
  56. package/dist/compat/nestjs/index.js +1 -1
  57. package/dist/compat/zustand/index.cjs +1 -1
  58. package/dist/compat/zustand/index.js +1 -1
  59. package/dist/{composite-DGspwCqk.d.ts → composite-BY9hMxN7.d.ts} +1 -1
  60. package/dist/{composite-nrRumJ7l.d.cts → composite-CH0S8DFn.d.cts} +1 -1
  61. package/dist/content-addressed-storage-BUiREIuj.d.ts +124 -0
  62. package/dist/content-addressed-storage-DqIWCmZG.d.cts +124 -0
  63. package/dist/core/index.cjs +1 -1
  64. package/dist/core/index.js +1 -1
  65. package/dist/extra/browser.cjs +1 -1
  66. package/dist/extra/browser.js +1 -1
  67. package/dist/extra/index.cjs +18 -18
  68. package/dist/extra/index.d.cts +6 -5
  69. package/dist/extra/index.d.ts +6 -5
  70. package/dist/extra/index.js +1 -1
  71. package/dist/extra/node.cjs +2 -2
  72. package/dist/extra/node.js +1 -1
  73. package/dist/extra/operators.cjs +1 -1
  74. package/dist/extra/operators.d.cts +41 -1
  75. package/dist/extra/operators.d.ts +41 -1
  76. package/dist/extra/operators.js +1 -1
  77. package/dist/extra/reactive.cjs +1 -1
  78. package/dist/extra/reactive.d.cts +1 -1
  79. package/dist/extra/reactive.d.ts +1 -1
  80. package/dist/extra/reactive.js +1 -1
  81. package/dist/extra/sources.cjs +1 -1
  82. package/dist/extra/sources.d.cts +62 -2
  83. package/dist/extra/sources.d.ts +62 -2
  84. package/dist/extra/sources.js +1 -1
  85. package/dist/extra/storage-browser.cjs +1 -1
  86. package/dist/extra/storage-browser.js +1 -1
  87. package/dist/{fallback-BaTS7vVY.d.cts → fallback-Cb3GH1O7.d.cts} +6 -14
  88. package/dist/{fallback-eOm3LNxP.d.ts → fallback-DRjJ_ZM8.d.ts} +6 -14
  89. package/dist/graph/index.cjs +4 -4
  90. package/dist/graph/index.js +1 -1
  91. package/dist/{index-ClB7TCfL.d.cts → index-BMe3pCom.d.cts} +1 -1
  92. package/dist/{index-Dljd76bC.d.ts → index-BXzl1NDD.d.ts} +1 -1
  93. package/dist/{index-ClgKmOHe.d.ts → index-Bd6oFZqO.d.ts} +223 -115
  94. package/dist/{index-BJHQUCZx.d.ts → index-CJymKyzT.d.ts} +81 -6
  95. package/dist/{index-D6ajK8Mh.d.cts → index-CZChc85Q.d.cts} +223 -115
  96. package/dist/{index-BXbQUn4n.d.ts → index-CcS0t-l2.d.ts} +1 -1
  97. package/dist/{index-B2HBxvMb.d.ts → index-CwhcFzTA.d.ts} +1 -1
  98. package/dist/{index-B8Aj_z8S.d.cts → index-D-kHVedZ.d.cts} +1 -1
  99. package/dist/{index-ybtSyjWB.d.cts → index-DD7RhHNJ.d.cts} +1 -1
  100. package/dist/{index-BHu_Wba0.d.cts → index-Dm3_D5Ta.d.cts} +1 -1
  101. package/dist/{index-Cc8VQIgL.d.ts → index-DxMS0cHM.d.ts} +1 -1
  102. package/dist/{index-BS220yqj.d.cts → index-gJQqJTKx.d.cts} +81 -6
  103. package/dist/index.cjs +99 -121
  104. package/dist/index.d.cts +14 -13
  105. package/dist/index.d.ts +14 -13
  106. package/dist/index.js +1 -1
  107. package/dist/patterns/ai/browser.cjs +5 -22
  108. package/dist/patterns/ai/browser.d.cts +3 -3
  109. package/dist/patterns/ai/browser.d.ts +3 -3
  110. package/dist/patterns/ai/browser.js +1 -1
  111. package/dist/patterns/ai/index.cjs +27 -44
  112. package/dist/patterns/ai/index.d.cts +9 -7
  113. package/dist/patterns/ai/index.d.ts +9 -7
  114. package/dist/patterns/ai/index.js +1 -1
  115. package/dist/patterns/ai/node.cjs +2 -2
  116. package/dist/patterns/ai/node.d.cts +5 -4
  117. package/dist/patterns/ai/node.d.ts +5 -4
  118. package/dist/patterns/ai/node.js +1 -1
  119. package/dist/patterns/audit/index.cjs +3 -3
  120. package/dist/patterns/audit/index.js +1 -1
  121. package/dist/patterns/cqrs/index.cjs +6 -6
  122. package/dist/patterns/cqrs/index.js +1 -1
  123. package/dist/patterns/demo-shell/index.cjs +1 -1
  124. package/dist/patterns/demo-shell/index.js +1 -1
  125. package/dist/patterns/domain-templates/index.cjs +4 -4
  126. package/dist/patterns/domain-templates/index.js +1 -1
  127. package/dist/patterns/graphspec/index.cjs +6 -6
  128. package/dist/patterns/graphspec/index.d.cts +2 -2
  129. package/dist/patterns/graphspec/index.d.ts +2 -2
  130. package/dist/patterns/graphspec/index.js +1 -1
  131. package/dist/patterns/guarded-execution/index.cjs +7 -7
  132. package/dist/patterns/guarded-execution/index.js +1 -1
  133. package/dist/patterns/harness/index.cjs +11 -11
  134. package/dist/patterns/harness/index.d.cts +2 -2
  135. package/dist/patterns/harness/index.d.ts +2 -2
  136. package/dist/patterns/harness/index.js +1 -1
  137. package/dist/patterns/job-queue/index.cjs +5 -5
  138. package/dist/patterns/job-queue/index.js +1 -1
  139. package/dist/patterns/lens/index.cjs +5 -5
  140. package/dist/patterns/lens/index.d.cts +2 -2
  141. package/dist/patterns/lens/index.d.ts +2 -2
  142. package/dist/patterns/lens/index.js +1 -1
  143. package/dist/patterns/memory/index.cjs +4 -4
  144. package/dist/patterns/memory/index.js +1 -1
  145. package/dist/patterns/messaging/index.cjs +5 -5
  146. package/dist/patterns/messaging/index.js +1 -1
  147. package/dist/patterns/orchestration/index.cjs +1 -1
  148. package/dist/patterns/orchestration/index.js +1 -1
  149. package/dist/patterns/reactive-layout/index.cjs +1 -1
  150. package/dist/patterns/reactive-layout/index.js +1 -1
  151. package/dist/patterns/reduction/index.cjs +5 -5
  152. package/dist/patterns/reduction/index.js +1 -1
  153. package/dist/patterns/refine-loop/index.cjs +8 -8
  154. package/dist/patterns/refine-loop/index.js +1 -1
  155. package/dist/patterns/resilient-pipeline/index.cjs +1 -1
  156. package/dist/patterns/resilient-pipeline/index.js +1 -1
  157. package/dist/patterns/surface/index.cjs +7 -7
  158. package/dist/patterns/surface/index.d.cts +3 -3
  159. package/dist/patterns/surface/index.d.ts +3 -3
  160. package/dist/patterns/surface/index.js +1 -1
  161. package/dist/{reactive-map-BvDrRuwt.d.ts → reactive-map-CtRaCddO.d.ts} +59 -1
  162. package/dist/{reactive-map-CmlPPKHN.d.cts → reactive-map-IJIfZxoh.d.cts} +59 -1
  163. package/dist/{resilience-XRUF267O.js → resilience-IVNDYORD.js} +1 -1
  164. package/dist/{types-O3GzJY2U.d.cts → types-BgMqbc7N.d.cts} +41 -14
  165. package/dist/{types-u64Ose53.d.ts → types-CdfO2QTt.d.ts} +41 -14
  166. package/package.json +1 -1
  167. package/dist/chunk-2GQREQ6C.js +0 -1
  168. package/dist/chunk-4C2OR2GH.js +0 -18
  169. package/dist/chunk-5JDE5JHE.js +0 -1
  170. package/dist/chunk-7JDLFI6N.js +0 -1
  171. package/dist/chunk-AMBYCIOH.js +0 -3
  172. package/dist/chunk-ISCENNXS.js +0 -1
  173. package/dist/chunk-IUK4EFCE.js +0 -1
  174. package/dist/chunk-KASHOCF5.js +0 -1
  175. package/dist/chunk-LI3E75VE.js +0 -64
  176. package/dist/chunk-MGKAO4EK.js +0 -7
  177. package/dist/chunk-NSG4C6BF.js +0 -23
  178. package/dist/chunk-VIEUJSTT.js +0 -1
@@ -1,4 +1,4 @@
1
- "use strict";var so=Object.create;var Se=Object.defineProperty;var Nn=Object.getOwnPropertyDescriptor;var io=Object.getOwnPropertyNames;var ao=Object.prototype.hasOwnProperty;var Sn=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ze=t=>{throw TypeError(t)};var uo=(t,e,n)=>e in t?Se(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var En=(t,e)=>Se(t,"name",{value:e,configurable:!0});var Y=(t,e)=>()=>(t&&(e=t(t=0)),e);var ue=(t,e)=>{for(var n in e)Se(t,n,{get:e[n],enumerable:!0})},co=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of io(e))!ao.call(t,o)&&o!==n&&Se(t,o,{get:()=>e[o],enumerable:!(r=Nn(e,o))||r.enumerable});return t};var lo=t=>co(Se({},"__esModule",{value:!0}),t);var An=t=>[,,,so(t?.[Sn("metadata")]??null)],kn=["class","method","getter","setter","accessor","field","value","get","set"],Be=t=>t!==void 0&&typeof t!="function"?ze("Function expected"):t,fo=(t,e,n,r,o)=>({kind:kn[t],name:e,metadata:r,addInitializer:s=>n._?ze("Already initialized"):o.push(Be(s||null))}),po=(t,e)=>uo(e,Sn("metadata"),t[3]),Cn=(t,e,n,r)=>{for(var o=0,s=t[e>>1],i=s&&s.length;o<i;o++)e&1?s[o].call(n):r=s[o].call(n,r);return r},Mn=(t,e,n,r,o,s)=>{var i,a,c,u,l,f=e&7,p=!!(e&8),h=!!(e&16),d=f>3?t.length+1:f?p?1:2:0,g=kn[f+5],m=f>3&&(t[d-1]=[]),v=t[d]||(t[d]=[]),_=f&&(!h&&!p&&(o=o.prototype),f<5&&(f>3||!h)&&Nn(f<4?o:{get[n](){return On(this,s)},set[n](y){return Rn(this,s,y)}},n));f?h&&f<4&&En(s,(f>2?"set ":f>1?"get ":"")+n):En(o,n);for(var b=r.length-1;b>=0;b--)u=fo(f,n,c={},t[3],v),f&&(u.static=p,u.private=h,l=u.access={has:h?y=>ho(o,y):y=>n in y},f^3&&(l.get=h?y=>(f^1?On:go)(y,o,f^4?s:_.get):y=>y[n]),f>2&&(l.set=h?(y,w)=>Rn(y,o,w,f^4?s:_.set):(y,w)=>y[n]=w)),a=(0,r[b])(f?f<4?h?s:_[g]:f>4?void 0:{get:_.get,set:_.set}:o,u),c._=1,f^4||a===void 0?Be(a)&&(f>4?m.unshift(a):f?h?s=a:_[g]=a:o=a):typeof a!="object"||a===null?ze("Object expected"):(Be(i=a.get)&&(_.get=i),Be(i=a.set)&&(_.set=i),Be(i=a.init)&&m.unshift(i));return f||po(t,o),_&&Se(o,n,_),h?f^4?s:_:o};var Lt=(t,e,n)=>e.has(t)||ze("Cannot "+n),ho=(t,e)=>Object(e)!==e?ze('Cannot use the "in" operator on this value'):t.has(e),On=(t,e,n)=>(Lt(t,e,"read from private field"),n?n.call(t):e.get(t));var Rn=(t,e,n,r)=>(Lt(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),go=(t,e,n)=>(Lt(t,e,"access private method"),n);var Ke,E,I,B,oe,X,se,q,P,C,Ae,Pt,mo,$t,bo,yo,Ht,Dn,Gn,In,Ft,W=Y(()=>{"use strict";Ke=Symbol.for("graphrefly/START"),E=Symbol.for("graphrefly/DATA"),I=Symbol.for("graphrefly/DIRTY"),B=Symbol.for("graphrefly/RESOLVED"),oe=Symbol.for("graphrefly/INVALIDATE"),X=Symbol.for("graphrefly/PAUSE"),se=Symbol.for("graphrefly/RESUME"),q=Symbol.for("graphrefly/TEARDOWN"),P=Symbol.for("graphrefly/COMPLETE"),C=Symbol.for("graphrefly/ERROR"),Ae=Object.freeze([I]),Pt=Object.freeze([B]),mo=Object.freeze([oe]),$t=Object.freeze([Ke]),bo=Object.freeze([P]),yo=Object.freeze([q]),Ht=Object.freeze([Ae]),Dn=Object.freeze([Pt]),Gn=Object.freeze([mo]),In=Object.freeze([bo]),Ft=Object.freeze([yo])});function Pn(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let o=2+n.length+2+e.length;if(o>4294967295)throw new Error(`encodeEnvelope: total envelope size ${o} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let s=new Uint8Array(o),i=0;return s[i++]=jt,s[i++]=n.length,s.set(n,i),i+=n.length,s[i++]=r>>>8&255,s[i++]=r&255,s.set(e,i),s}function $n(t,e){if(t.length<Ln)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${Ln})`);let n=0,r=t[n++];if(r!==jt)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${jt})`);let o=t[n++];if(o===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+o+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+o+2} bytes, have ${t.length})`);let s=new TextDecoder().decode(t.subarray(n,n+o));n+=o;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),c=e.lookupCodec(s);if(c==null)throw new Error(`decodeEnvelope: codec "${s}" not registered (envelope codec_v=${i})`);return{codec:c,codecVersion:i,payload:a}}function Hn(t){t.registerCodec(vo)}var vo,jt,Ln,Vt=Y(()=>{"use strict";vo={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}},jt=1,Ln=4});function ve(t){if(t==null)return pe;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var pe,Ue=Y(()=>{"use strict";pe={type:"system",id:""}});function at(){return ke>0||Ye}function Fn(){return ke>0}function Qe(t){ke>0?Je.push(t):t()}function ce(t){ke+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(ke-=1,ke===0)if(e){if(!Ye){let n=Je.splice(0);for(let r of n)try{r()}catch{}_e.length=0,xe.length=0,Ce.length=0}}else _o()}}function _o(){let t=!Ye;t&&(Ye=!0);let e=[],n=0;try{for(;_e.length>0||xe.length>0||Ce.length>0||t&&Je.length>0;){if(t&&Je.length>0){let s=Je.splice(0);for(let i of s)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw _e.length=0,xe.length=0,Ce.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(_e.length>0?_e:xe.length>0?xe:Ce).splice(0);for(let s of o)try{s()}catch(i){e.push(i)}}}finally{t&&(Ye=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function ut(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!at()){t(e);return}(u>=5?Ce:u===4?xe:_e).push(()=>t(e));return}let r=e.length,o=r,s=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(o=a;a<r&&n(e[a][0])===3;)a++;for(s=a;a<r&&n(e[a][0])===4;)a++;i=a;let c=at();if(o>0){let u=e.slice(0,o);t(u)}if(s>o){let u=e.slice(o,s);c?_e.push(()=>t(u)):t(u)}if(i>s){let u=e.slice(s,i);c?xe.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);c?Ce.push(()=>t(u)):t(u)}}var ke,Ye,_e,xe,Ce,Je,we=Y(()=>{"use strict";ke=0,Ye=!1,_e=[],xe=[],Ce=[],Je=[]});function Me(){return Math.trunc(performance.now()*1e6)}function he(){return Date.now()*1e6}var Xe=Y(()=>{"use strict"});function jn(t){t.registerMessageType(Ke,{tier:0,wireCrossing:!1}),t.registerMessageType(I,{tier:1,wireCrossing:!1}),t.registerMessageType(oe,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(X,{tier:2,wireCrossing:!1}),t.registerMessageType(se,{tier:2,wireCrossing:!1}),t.registerMessageType(E,{tier:3,wireCrossing:!0}),t.registerMessageType(B,{tier:3,wireCrossing:!0}),t.registerMessageType(P,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(C,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(q,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var ct,Vn=Y(()=>{"use strict";W();ct=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function qn(t){return Array.isArray(t)?[...t]:[t]}function xo(t,e){return t.has(e)||t.has("*")}function dt(t){let e=[];return t((o,s)=>{e.push({kind:"allow",actions:new Set(qn(o)),where:s?.where??(()=>!0)})},(o,s)=>{e.push({kind:"deny",actions:new Set(qn(o)),where:s?.where??(()=>!0)})}),(o,s)=>{let i=!1,a=!1;for(let c of e)xo(c.actions,s)&&c.where(o)&&(c.kind==="deny"?i=!0:a=!0);return i?!1:a}}function qt(t){let e=wo.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var Z,wo,De=Y(()=>{"use strict";Z=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};wo=["human","llm","wallet","system"]});function Wt(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(Wt);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=Wt(t[n]);return e}return null}function Oo(t){let e=Eo.encode(t),n=e.length,r=n*8,o=n+9+63&-64,s=new Uint8Array(o);s.set(e),s[n]=128;let i=new DataView(s.buffer);i.setUint32(o-4,r>>>0,!1),i.setUint32(o-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,c=3144134277,u=1013904242,l=2773480762,f=1359893119,p=2600822924,h=528734635,d=1541459225,g=new Uint32Array(64),m=(_,b)=>_>>>b|_<<32-b;for(let _=0;_<o;_+=64){for(let S=0;S<16;S++)g[S]=i.getUint32(_+S*4,!1);for(let S=16;S<64;S++){let k=g[S-15],A=g[S-2],F=m(k,7)^m(k,18)^k>>>3,U=m(A,17)^m(A,19)^A>>>10;g[S]=g[S-16]+F+g[S-7]+U>>>0}let b=a,y=c,w=u,T=l,x=f,O=p,N=h,M=d;for(let S=0;S<64;S++){let k=m(x,6)^m(x,11)^m(x,25),A=x&O^~x&N,F=M+k+A+To[S]+g[S]>>>0,U=m(b,2)^m(b,13)^m(b,22),re=b&y^b&w^y&w,ye=U+re>>>0;M=N,N=O,O=x,x=T+F>>>0,T=w,w=y,y=b,b=F+ye>>>0}a=a+b>>>0,c=c+y>>>0,u=u+w>>>0,l=l+T>>>0,f=f+x>>>0,p=p+O>>>0,h=h+N>>>0,d=d+M>>>0}let v=_=>_.toString(16).padStart(8,"0");return v(a)+v(c)+v(u)+v(l)+v(f)+v(p)+v(h)+v(d)}function Bt(t){let e=Wt(t??null),n=JSON.stringify(e);return Oo(n).slice(0,16)}function Ro(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function zt(t,e,n){let r=n?.id??Ro();if(t===0)return{id:r,version:0};let s=(n?.hash??Bt)(e);return{id:r,version:0,cid:s,prev:null}}function Wn(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var To,Eo,Bn=Y(()=>{"use strict";To=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Eo=new TextEncoder});function Un(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function Kt(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function lt(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function Ee(t,e,n){let r=Yn(t)?t:[],o=typeof t=="function"?t:typeof e=="function"?e:void 0,s={};return Yn(t)?s=(Ut(e)?e:n)??{}:Ut(t)?s=t:s=(Ut(e)?e:n)??{},new $(r,o,s)}var zn,Kn,No,So,Te,$,Yn,Ut,Ge=Y(()=>{"use strict";Vt();Ue();we();Xe();Vn();De();W();Bn();zn=()=>{},Kn=100;No=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},So=(t,e,n,r)=>{let o=t;if(o._status==="completed"||o._status==="errored")return;let s=o._cached,i=s===void 0?[$t]:[$t,[E,s]];o._status==="dirty"&&i.push(Ae),ut(e,i,o._config.tierOf)},Te=new ct({onMessage:No,onSubscribe:So});jn(Te);Hn(Te);$=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??Te,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??Bt;let o=r.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?zt(o,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Un);let s={};for(let[a,c]of Object.entries(r.meta??{})){let u={initial:c,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),s[a]=new t([],void 0,u)}Object.freeze(s),this.meta=s,this._hasMeta=Object.keys(s).length>0;let i=this;this._actions={emit(a){i._emit([[E,a]])},down(a){i._emit(lt(a))},up(a){i._emitUp(lt(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let o=n?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let s=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,c=i?.version??0,u=zt(e,s,{id:a,hash:o});u.version=c,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=ve(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let o=ve(e?.actor),s=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,s))throw new Z({actor:o,action:s,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(o,s))throw new Z({actor:o,action:s,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:he()}}down(e,n){let r=lt(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[E,e]])}up(e,n){if(this._deps.length===0)return;let r=lt(e);if(r.length===0)return;this._checkGuard(n);let o=n??{internal:!0};this._validateUpTiers(r);for(let s of this._deps)s.node.up?.(r,o)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let o=n(r[0]);if(o===3||o===4)throw new Error(`Node "${this.name}": tier-${o} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let c=ve(n);if(!this._guard(c,"observe"))throw new Z({actor:c,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let c of this._deps)Kt(c);if(this._partial===!1){for(let c of this._deps)if(c.prevData!==void 0||c.dataBatch.length!==0||c.terminal!==void 0||c.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let s;try{s=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:o},this._actions)}catch(c){throw this._sinkCount-=1,c}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(c){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof s=="function")try{s()}catch{}throw c}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof s=="function"&&s(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let o=r,s=this._deps[r];s.unsub=zn,s.unsub=s.node.subscribe(i=>{if(s.unsub===null)return;let a=this._config.tierOf,c=!1;for(let u of i)a(u[0])>=3&&(c=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:o},this._actions);c&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let o=0;o<n;o++){let s=this._deps[o];if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}Kt(s)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let n=this._deps.length,r=Un(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Ht),r.unsub=zn;try{r.unsub=e.subscribe(o=>{if(r.unsub===null)return;let s=this._config.tierOf,i=!1;for(let a of o)s(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(o){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,o}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[C,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(o){this._emit([[C,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let r of this._deps){if(r.unsub!=null){let o=r.unsub;r.unsub=null;try{o()}catch{}}Kt(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],o=n[0];if(this._inspectorHooks!=null){let s={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(s)}if(o!==Ke){if(o===I){this._depDirtied(r);return}if(o===oe){this._depInvalidated(r),this._emit(Gn);return}if(o===X||o===se){this._emit([n]);return}if(o===q){this._emit(Ft);return}if(o===E)this._depSettledAsData(r,n[1]);else if(o===B)this._depSettledAsResolved(r);else if(o===P)this._depSettledAsTerminal(r,!0);else if(o===C)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(o===E||o===B)&&this._emit([n]),(o===P||o===C)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Ht))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Dn),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[C,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(In)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[C,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[C,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let o=this._deps.map(i=>i.terminal),s={prevData:r,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,s);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[C,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Kn?(this._rerunDepth=0,this._emit([[C,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Kn} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[Ae,e[0]]:e;let r=!0,o=!1,s=!1,i=-1;for(let c of e){let u=n(c[0]);u<i&&(r=!1),u===3&&(o=!0),c[0]===I&&(s=!0),i=u}let a=e;if(!r){let c=e.map((u,l)=>({m:u,i:l,tier:n(u[0])}));c.sort((u,l)=>u.tier-l.tier||u.i-l.i),a=c.map(u=>u.m)}if(o&&!s&&this._status!=="dirty"){let c=0;for(;c<a.length&&n(a[c][0])===0;)c++;return c===0?[Ae,...a]:[...a.slice(0,c),Ae,...a.slice(c)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let c=e[a];if(c[0]===C&&c[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(c=>c[0]===q||c[0]===oe);if(a.length===0)return;n=a}n=this._frameBatch(n);let o=null;for(let a=0;a<n.length;a++){let c=n[a],u=c[0];if(u!==X&&u!==se){o?.push(c);continue}if(c.length<2)throw new Error(`Node "${this.name}": [[${u===X?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let l=!0;if(this._pausable!==!1){let f=c[1];if(u===X)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))l=!1;else if(this._pauseLocks.delete(f),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}l?o?.push(c):o==null&&(o=n.slice(0,a))}if(o!=null){if(o.length===0)return;n=o}if(this._hasMeta&&n.some(a=>a[0]===q))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(Ft)}catch{}let{finalMessages:s,equalsError:i}=this._updateState(n);if(s.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:s})}catch{}}if(s.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,c=[];for(let u of s)a(u[0])===3?this._pauseBuffer.push(u):c.push(u);c.length>0&&this._dispatchOrAccumulate(c)}else this._dispatchOrAccumulate(s);i!=null&&this._emit([[C,i]])}_updateState(e){let n=this._config.tierOf,r,o,s=-1,i=0;for(let l of e)n(l[0])===3&&i++;let a=i<=1,c=-1;if(this._versioning!=null&&i>1){for(let l=e.length-1;l>=0;l--)if(e[l][0]===E){c=l;break}}for(let l=0;l<e.length;l++){let f=e[l],p=f[0];if(p===E){if(f.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,f[1])}catch(d){o=this._wrapFnError("equals threw",d),s=l;break}if(h){r==null&&(r=e.slice(0,l)),r.push(Pt),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(c<0||l===c)&&Wn(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),p===I)this._status="dirty";else if(p===B)this._status="resolved";else if(p===P)this._status="completed";else if(p===C)this._status="errored";else if(p===oe){this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let d=h.invalidate;if(typeof d=="function")try{d()}catch{}}}else p===q&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=s>=0?r??e.slice(0,s):r??e;return o!=null?{finalMessages:u,equalsError:o}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(Fn()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Qe(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}ut(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);ut(this._deliverToSinks,n,this._config.tierOf)}},Yn=t=>Array.isArray(t),Ut=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function V(t,e){return Ee([],{...e,initial:t})}function Ie(t,e){return Ee((r,o,s)=>t(o,s)??void 0,{describeKind:"producer",...e})}function ie(t,e,n){return Ee(t,(o,s,i)=>{let a=o.map((c,u)=>c!=null&&c.length>0?c.at(-1):i.prevData[u]);s.emit(e(a,i))},{describeKind:"derived",...n})}function Yt(t,e,n){let r=new Map;return t.forEach((o,s)=>{r.set(o,s)}),ie(t,(o,s)=>e(a=>{let c=r.get(a);if(c==null)throw new Error(`dynamicNode: untracked dep "${a.name??"<unnamed>"}"`);return o[c]},s),n)}function Ze(t,e){let n,r=new Map,o=(s,i,a)=>{let c=!1,u=l=>{let f=r.get(l);if(f!==void 0){if(f<s.length){let h=s[f];return h!=null&&h.length>0?h.at(-1):a.prevData[f]}return l.cache}c=!0;let p=n._addDep(l);return r.set(l,p),l.cache};try{let l=t(u,a);c||(i.emit(l),a.store.__autoTrackLastDiscoveryError!=null&&delete a.store.__autoTrackLastDiscoveryError)}catch(l){if(!c)throw l;a.store.__autoTrackLastDiscoveryError=l}};return n=new $([],o,{describeKind:"derived",...e}),n}var de=Y(()=>{"use strict";Ge()});function nt(t,e,n){let r=new Set;for(let o of t.split(",")){let[s,i]=o.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${o}`);let c,u;if(s==="*")c=e,u=n;else if(s.includes("-")){let[l,f]=s.split("-");c=Number.parseInt(l,10),u=Number.parseInt(f,10)}else c=Number.parseInt(s,10),u=c;if(Number.isNaN(c)||Number.isNaN(u))throw new Error(`Invalid cron field: ${t}`);if(c<e||u>n)throw new Error(`Cron field out of range: ${t} (${e}-${n})`);if(c>u)throw new Error(`Invalid cron range: ${c}-${u} in ${t}`);for(let l=c;l<=u;l+=a)r.add(l)}return r}function fr(t){let e=t.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:nt(e[0],0,59),hours:nt(e[1],0,23),daysOfMonth:nt(e[2],1,31),months:nt(e[3],1,12),daysOfWeek:nt(e[4],0,6)}}function pr(t,e){return t.minutes.has(e.getMinutes())&&t.hours.has(e.getHours())&&t.daysOfMonth.has(e.getDate())&&t.months.has(e.getMonth()+1)&&t.daysOfWeek.has(e.getDay())}var hr=Y(()=>{"use strict"});function gr(t){return{describeKind:"producer",...t}}function mr(t,e){let{signal:n,period:r,...o}=e??{};return Ie(s=>{let i=!1,a=0,c,u,l=()=>{i=!0,c!==void 0&&clearTimeout(c),u!==void 0&&clearInterval(u),n?.removeEventListener("abort",p)},f=()=>{i||(r!=null?(s.emit(a++),u=setInterval(()=>{i||s.emit(a++)},r)):(i=!0,n?.removeEventListener("abort",p),s.emit(a++),s.down([[P]])))},p=()=>{i||(l(),s.down([[C,n.reason]]))};if(n?.aborted){p();return}return c=setTimeout(f,t),n?.addEventListener("abort",p,{once:!0}),l},gr(o))}function br(t,e){let n=fr(t),{tickMs:r,output:o,...s}=e??{},i=r??6e4,a=o==="date";return Ie(c=>{let u=-1,l=()=>{let p=new Date,h=p.getFullYear()*1e8+(p.getMonth()+1)*1e6+p.getDate()*1e4+p.getHours()*100+p.getMinutes();h!==u&&pr(n,p)&&(u=h,c.emit(a?p:he()))};l();let f=setInterval(l,i);return()=>clearInterval(f)},{...gr(s),name:s.name??`cron:${t}`})}function ge(t){return t.subscribe(()=>{})}var gt=Y(()=>{"use strict";Xe();W();de();hr()});var _t,Er=Y(()=>{"use strict";_t=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Xs={};ue(Xs,{jotai:()=>Jt,nanostores:()=>Xt,nestjs:()=>hn,react:()=>gn,signals:()=>yn,solid:()=>vn,svelte:()=>_n,vue:()=>xn,zustand:()=>wn});module.exports=lo(Xs);var Jt={};ue(Jt,{atom:()=>Ao});W();de();function Ao(t,e,n){if(typeof t=="function"){let r=t;return typeof e=="function"?Jn(r,e,n):Jn(r,void 0,e)}return ko(t,e)}function et(t){let e=t.cache,n;if(t.subscribe(o=>{for(let[s,i]of o)s===E&&(e=i),s===C&&(n=i)})(),n)throw n;return e}function ko(t,e){let n=V(t,{...e,resubscribable:!0,resetOnTeardown:!0});return{get:()=>n.status==="sentinel"?et(n):n.cache,set:r=>n.emit(r),update:r=>{let o=n.status==="sentinel"?et(n):n.cache;n.emit(r(o))},subscribe:r=>{let o=!0;return n.subscribe(s=>{for(let[i,a]of s)if(i===E){if(o){o=!1;continue}r(a)}})},meta:n.meta,_node:n}}function Jn(t,e,n){let r=Ze(s=>t(i=>{let a=i._node;return a.status==="sentinel"&&et(a),s(a)}),{...n,resubscribable:!0,resetOnTeardown:!0}),o={get:()=>r.status==="sentinel"?et(r):r.cache,subscribe:s=>{let i=!0;return r.subscribe(a=>{for(let[c,u]of a)if(c===E){if(i){i=!1;continue}s(u)}})},meta:r.meta,_node:r};if(e){let s=c=>c.get(),i=(c,u)=>c.set(u),a=o;return a.set=c=>e(s,i,c),a.update=c=>{let u=r.status==="sentinel"?et(r):r.cache;return e(s,i,c(u))},a}return o}var Xt={};ue(Xt,{action:()=>Lo,atom:()=>Co,computed:()=>Mo,getValue:()=>Go,map:()=>Do,onMount:()=>Io,onStart:()=>Zn,onStop:()=>er});we();W();de();var pt=new WeakMap,ht=new WeakMap;function ft(t,e){let n=e.get(t);if(n)for(let r of n)r()}function Qt(t,e={}){let n=0;return{...e,get:()=>Xn(t),subscribe:o=>{n===0&&ft(t,pt),n++;let s=t.subscribe(i=>{for(let[a,c]of i)a===E&&o(c)});return()=>{s(),n--,n===0&&ft(t,ht)}},listen:o=>{n===0&&ft(t,pt),n++;let s=!0,i=t.subscribe(a=>{for(let[c,u]of a)if(c===E){if(s){s=!1;continue}o(u)}});return()=>{i(),n--,n===0&&ft(t,ht)}},_node:t}}function Qn(t){let e=t.cache,n;if(t.subscribe(o=>{for(let[s,i]of o)s===E&&(e=i),s===C&&(n=i)})(),n)throw n;return e}function Xn(t){return t.status==="sentinel"?Qn(t):t.cache}function Co(t){let e=V(t,{resubscribable:!0,resetOnTeardown:!0});return Qt(e,{set:n=>e.emit(n)})}function Mo(t,e){let n=Array.isArray(t)?t:[t],r=n.map(s=>s._node),o=Yt(r,s=>{let i=n.map(a=>{let c=a._node;return c.status==="sentinel"&&Qn(c),s(c)});return e(...i)},{resubscribable:!0,resetOnTeardown:!0,equals:Object.is});return Qt(o)}function Do(t){let e=V(t,{resubscribable:!0,resetOnTeardown:!0,equals:()=>!1});return Qt(e,{set:n=>e.emit(n),setKey:(n,r)=>{let o=Xn(e);e.emit({...o,[n]:r})}})}function Go(t){return t.get()}function Zn(t,e){let n=t._node,r=pt.get(n);r||(r=new Set,pt.set(n,r)),r.add(e)}function er(t,e){let n=t._node,r=ht.get(n);r||(r=new Set,ht.set(n,r)),r.add(e)}function Io(t,e){Zn(t,()=>{let n=e();typeof n=="function"&&er(t,n)})}function Lo(t,e,n){return(...r)=>{let o;return ce(()=>{o=n(...r)}),o}}var hn={};ue(hn,{ACTOR_KEY:()=>yt,COMMAND_HANDLERS:()=>He,CQRS_EVENT_HANDLERS:()=>Fe,CRON_HANDLERS:()=>$e,CommandHandler:()=>ur,EVENT_HANDLERS:()=>Le,EventHandler:()=>cr,GRAPHREFLY_REQUEST_GRAPH:()=>Oe,GRAPHREFLY_ROOT_GRAPH:()=>ee,GraphCron:()=>ar,GraphInterval:()=>ir,GraphReflyEventExplorer:()=>Re,GraphReflyGuard:()=>Tr,GraphReflyGuardImpl:()=>rt,GraphReflyModule:()=>kt,INTERVAL_HANDLERS:()=>Pe,InjectCqrsGraph:()=>rr,InjectGraph:()=>nr,InjectNode:()=>or,ObserveGateway:()=>bt,OnGraphEvent:()=>sr,QUERY_HANDLERS:()=>je,QueryHandler:()=>dr,SAGA_HANDLERS:()=>Ve,SagaHandler:()=>lr,fromHeader:()=>xr,fromJwtPayload:()=>nn,getActor:()=>wr,getGraphToken:()=>K,getNodeToken:()=>ae,observeSSE:()=>vr,observeSubscription:()=>_r,toObservable:()=>tr});var Zt=require("rxjs");W();function tr(t,e){return e?.raw?new Zt.Observable(n=>t.subscribe(o=>{if(!n.closed){n.next(o);for(let s of o){if(s[0]===C){n.error(s[1]);return}if(s[0]===P){n.complete();return}}}})):new Zt.Observable(n=>t.subscribe(o=>{for(let s of o){if(n.closed)return;if(s[0]===E)n.next(s[1]);else if(s[0]===C){n.error(s[1]);return}else if(s[0]===P){n.complete();return}}}))}var tt=require("@nestjs/common");var ee=Symbol.for("graphrefly:root-graph");var Oe=Symbol.for("graphrefly:request-graph");function K(t){return Symbol.for(`graphrefly:graph:${t}`)}function ae(t){return Symbol.for(`graphrefly:node:${t}`)}var Le=new Map,Pe=new Map,$e=new Map,He=new Map,Fe=new Map,je=new Map,Ve=new Map;function nr(t){return t==="request"?(0,tt.Inject)(Oe):(0,tt.Inject)(t?K(t):ee)}function rr(t){return(0,tt.Inject)(K(t))}function or(t){return(0,tt.Inject)(ae(t))}function sr(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=Le.get(o)??[];s.push({nodeName:t,methodKey:r}),Le.set(o,s)})}}function ir(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=Pe.get(o)??[];s.push({ms:t,methodKey:r}),Pe.set(o,s)})}}function ar(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=$e.get(o)??[];s.push({expr:t,methodKey:r}),$e.set(o,s)})}}function ur(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=He.get(s)??[];i.push({cqrsName:t,commandName:e,methodKey:o}),He.set(s,i)})}}function cr(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=Fe.get(s)??[];i.push({cqrsName:t,eventName:e,methodKey:o}),Fe.set(s,i)})}}function dr(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=je.get(s)??[];i.push({cqrsName:t,projectionName:e,methodKey:o}),je.set(s,i)})}}function lr(t,e,n){return(r,o)=>{let s=o.name;o.addInitializer(function(){let i=this.constructor,a=Ve.get(i)??[];a.push({cqrsName:t,eventNames:n,sagaName:e,methodKey:s}),Ve.set(i,a)})}}W();gt();var yr=0,Re=class{constructor(e,n){this.graph=e;this.moduleRef=n}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,n]of Le){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireEventHandler(r,o)}}wireEventHandler(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),i=this.observeNode(n.nodeName).subscribe(a=>{for(let c of a)c[0]===E&&o(c[1])});this.disposers.push(i)}wireIntervals(){for(let[e,n]of Pe){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireIntervalHandler(r,e,o)}}wireIntervalHandler(e,n,r){let o=e[r.methodKey];if(typeof o!="function")return;let s=o.bind(e),a=`__schedule__.${n.name??"anonymous"}.${String(r.methodKey)}.${yr++}`,c=mr(r.ms,{period:r.ms,name:a});this.graph.add(c),this.scheduleNodeNames.push(a);let l=this.observeNode(a).subscribe(f=>{for(let p of f)p[0]===E&&s(p[1])});this.disposers.push(l)}wireCrons(){for(let[e,n]of $e){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCronHandler(r,e,o)}}wireCronHandler(e,n,r){let o=e[r.methodKey];if(typeof o!="function")return;let s=o.bind(e),a=`__schedule__.${n.name??"anonymous"}.${String(r.methodKey)}.${yr++}`,c=br(r.expr,{name:a});this.graph.add(c),this.scheduleNodeNames.push(a);let l=this.observeNode(a).subscribe(f=>{for(let p of f)p[0]===E&&s(p[1])});this.disposers.push(l)}wireCqrsCommands(){for(let[e,n]of He){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsCommand(r,o)}}wireCqrsCommand(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);s&&s.command(n.commandName,o)}wireCqrsEvents(){for(let[e,n]of Fe){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsEventHandler(r,o)}}wireCqrsEventHandler(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);if(!s)return;s.event(n.eventName);let a=s.resolve(n.eventName).cache,c=a&&a.length>0?a[a.length-1].seq:0,l=this.observeNodeOn(s,n.eventName).subscribe(f=>{for(let p of f)if(p[0]===E){let h=p[1];for(let d of h)d.seq>c&&(o(d),c=d.seq)}});this.disposers.push(l)}wireCqrsQueries(){for(let[e,n]of je){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsQuery(r,o)}}wireCqrsQuery(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);if(!s)return;let a=this.observeNodeOn(s,n.projectionName).subscribe(c=>{for(let u of c)u[0]===E&&o(u[1])});this.disposers.push(a)}wireCqrsSagas(){for(let[e,n]of Ve){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsSaga(r,o)}}wireCqrsSaga(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);s&&s.saga(n.sagaName,n.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,n){return e.observe(n)}resolveCqrsGraph(e){try{return this.moduleRef.get(K(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};W();W();var Po=0;function mt(t,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let n=Symbol(`bp-${++Po}`),r=0,o=!1;return{onEnqueue(){return r+=1,!o&&r>=e.highWaterMark?(o=!0,t([[X,n]]),!0):!1},onDequeue(){return r>0&&(r-=1),o&&r<=e.lowWaterMark?(o=!1,t([[se,n]]),!0):!1},get pending(){return r},get paused(){return o},dispose(){o&&(o=!1,t([[se,n]]))}}}function vr(t,e,n){let{actor:r,serialize:o=$o,keepAliveMs:s,signal:i}=n??{},a=new TextEncoder,c,u=n?.highWaterMark!=null,l,f,p=[],h=!1;return new ReadableStream({start(d){let g,m=()=>{},v=()=>{if(!h){h=!0,g!==void 0&&clearInterval(g),i?.removeEventListener("abort",_),m(),l?.dispose(),f?.(),f=void 0;for(let y of p)d.enqueue(y.frame);p.length=0,d.close()}};c=v;let _=()=>v(),b=t.observe(e,{actor:r});u&&(l=mt(y=>b.up(y),{highWaterMark:n.highWaterMark,lowWaterMark:n.lowWaterMark??Math.floor(n.highWaterMark/2)})),m=b.subscribe(y=>{for(let w of y){if(h)return;let T=w[0];if(T===E){let x=a.encode(en("data",o(w[1])));u?(p.push({frame:x,counted:!0}),l.onEnqueue(),f?.(),f=void 0):d.enqueue(x)}else if(T===C){let x=a.encode(en("error",o(w[1])));u?(p.push({frame:x,counted:!1}),f?.(),f=void 0):d.enqueue(x),v();return}else if(T===P||T===q){if(T===P){let x=a.encode(en("complete"));u?(p.push({frame:x,counted:!1}),f?.(),f=void 0):d.enqueue(x)}v();return}}}),s!==void 0&&s>0&&(g=setInterval(()=>{h||(u?(p.push({frame:a.encode(`: keepalive
1
+ "use strict";var so=Object.create;var Se=Object.defineProperty;var Nn=Object.getOwnPropertyDescriptor;var io=Object.getOwnPropertyNames;var ao=Object.prototype.hasOwnProperty;var Sn=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ze=t=>{throw TypeError(t)};var uo=(t,e,n)=>e in t?Se(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var En=(t,e)=>Se(t,"name",{value:e,configurable:!0});var Y=(t,e)=>()=>(t&&(e=t(t=0)),e);var ue=(t,e)=>{for(var n in e)Se(t,n,{get:e[n],enumerable:!0})},co=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of io(e))!ao.call(t,o)&&o!==n&&Se(t,o,{get:()=>e[o],enumerable:!(r=Nn(e,o))||r.enumerable});return t};var lo=t=>co(Se({},"__esModule",{value:!0}),t);var An=t=>[,,,so(t?.[Sn("metadata")]??null)],kn=["class","method","getter","setter","accessor","field","value","get","set"],Be=t=>t!==void 0&&typeof t!="function"?ze("Function expected"):t,fo=(t,e,n,r,o)=>({kind:kn[t],name:e,metadata:r,addInitializer:s=>n._?ze("Already initialized"):o.push(Be(s||null))}),po=(t,e)=>uo(e,Sn("metadata"),t[3]),Cn=(t,e,n,r)=>{for(var o=0,s=t[e>>1],i=s&&s.length;o<i;o++)e&1?s[o].call(n):r=s[o].call(n,r);return r},Mn=(t,e,n,r,o,s)=>{var i,a,c,u,l,f=e&7,p=!!(e&8),h=!!(e&16),d=f>3?t.length+1:f?p?1:2:0,g=kn[f+5],m=f>3&&(t[d-1]=[]),v=t[d]||(t[d]=[]),_=f&&(!h&&!p&&(o=o.prototype),f<5&&(f>3||!h)&&Nn(f<4?o:{get[n](){return On(this,s)},set[n](y){return Rn(this,s,y)}},n));f?h&&f<4&&En(s,(f>2?"set ":f>1?"get ":"")+n):En(o,n);for(var b=r.length-1;b>=0;b--)u=fo(f,n,c={},t[3],v),f&&(u.static=p,u.private=h,l=u.access={has:h?y=>ho(o,y):y=>n in y},f^3&&(l.get=h?y=>(f^1?On:go)(y,o,f^4?s:_.get):y=>y[n]),f>2&&(l.set=h?(y,w)=>Rn(y,o,w,f^4?s:_.set):(y,w)=>y[n]=w)),a=(0,r[b])(f?f<4?h?s:_[g]:f>4?void 0:{get:_.get,set:_.set}:o,u),c._=1,f^4||a===void 0?Be(a)&&(f>4?m.unshift(a):f?h?s=a:_[g]=a:o=a):typeof a!="object"||a===null?ze("Object expected"):(Be(i=a.get)&&(_.get=i),Be(i=a.set)&&(_.set=i),Be(i=a.init)&&m.unshift(i));return f||po(t,o),_&&Se(o,n,_),h?f^4?s:_:o};var Lt=(t,e,n)=>e.has(t)||ze("Cannot "+n),ho=(t,e)=>Object(e)!==e?ze('Cannot use the "in" operator on this value'):t.has(e),On=(t,e,n)=>(Lt(t,e,"read from private field"),n?n.call(t):e.get(t));var Rn=(t,e,n,r)=>(Lt(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),go=(t,e,n)=>(Lt(t,e,"access private method"),n);var Ke,E,I,B,oe,X,se,q,P,C,Ae,Pt,mo,$t,bo,yo,Ht,Dn,Gn,In,Ft,W=Y(()=>{"use strict";Ke=Symbol.for("graphrefly/START"),E=Symbol.for("graphrefly/DATA"),I=Symbol.for("graphrefly/DIRTY"),B=Symbol.for("graphrefly/RESOLVED"),oe=Symbol.for("graphrefly/INVALIDATE"),X=Symbol.for("graphrefly/PAUSE"),se=Symbol.for("graphrefly/RESUME"),q=Symbol.for("graphrefly/TEARDOWN"),P=Symbol.for("graphrefly/COMPLETE"),C=Symbol.for("graphrefly/ERROR"),Ae=Object.freeze([I]),Pt=Object.freeze([B]),mo=Object.freeze([oe]),$t=Object.freeze([Ke]),bo=Object.freeze([P]),yo=Object.freeze([q]),Ht=Object.freeze([Ae]),Dn=Object.freeze([Pt]),Gn=Object.freeze([mo]),In=Object.freeze([bo]),Ft=Object.freeze([yo])});function Pn(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let o=2+n.length+2+e.length;if(o>4294967295)throw new Error(`encodeEnvelope: total envelope size ${o} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let s=new Uint8Array(o),i=0;return s[i++]=jt,s[i++]=n.length,s.set(n,i),i+=n.length,s[i++]=r>>>8&255,s[i++]=r&255,s.set(e,i),s}function $n(t,e){if(t.length<Ln)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${Ln})`);let n=0,r=t[n++];if(r!==jt)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${jt})`);let o=t[n++];if(o===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+o+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+o+2} bytes, have ${t.length})`);let s=new TextDecoder().decode(t.subarray(n,n+o));n+=o;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),c=e.lookupCodec(s);if(c==null)throw new Error(`decodeEnvelope: codec "${s}" not registered (envelope codec_v=${i})`);return{codec:c,codecVersion:i,payload:a}}function Hn(t){t.registerCodec(vo)}var vo,jt,Ln,Vt=Y(()=>{"use strict";vo={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}},jt=1,Ln=4});function ve(t){if(t==null)return pe;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var pe,Ue=Y(()=>{"use strict";pe={type:"system",id:""}});function at(){return ke>0||Ye}function Fn(){return ke>0}function Qe(t){ke>0?Je.push(t):t()}function ce(t){ke+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(ke-=1,ke===0)if(e){if(!Ye){let n=Je.splice(0);for(let r of n)try{r()}catch{}_e.length=0,xe.length=0,Ce.length=0}}else _o()}}function _o(){let t=!Ye;t&&(Ye=!0);let e=[],n=0;try{for(;_e.length>0||xe.length>0||Ce.length>0||t&&Je.length>0;){if(t&&Je.length>0){let s=Je.splice(0);for(let i of s)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw _e.length=0,xe.length=0,Ce.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(_e.length>0?_e:xe.length>0?xe:Ce).splice(0);for(let s of o)try{s()}catch(i){e.push(i)}}}finally{t&&(Ye=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function ut(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!at()){t(e);return}(u>=5?Ce:u===4?xe:_e).push(()=>t(e));return}let r=e.length,o=r,s=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(o=a;a<r&&n(e[a][0])===3;)a++;for(s=a;a<r&&n(e[a][0])===4;)a++;i=a;let c=at();if(o>0){let u=e.slice(0,o);t(u)}if(s>o){let u=e.slice(o,s);c?_e.push(()=>t(u)):t(u)}if(i>s){let u=e.slice(s,i);c?xe.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);c?Ce.push(()=>t(u)):t(u)}}var ke,Ye,_e,xe,Ce,Je,we=Y(()=>{"use strict";ke=0,Ye=!1,_e=[],xe=[],Ce=[],Je=[]});function Me(){return Math.trunc(performance.now()*1e6)}function he(){return Date.now()*1e6}var Xe=Y(()=>{"use strict"});function jn(t){t.registerMessageType(Ke,{tier:0,wireCrossing:!1}),t.registerMessageType(I,{tier:1,wireCrossing:!1}),t.registerMessageType(oe,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(X,{tier:2,wireCrossing:!1}),t.registerMessageType(se,{tier:2,wireCrossing:!1}),t.registerMessageType(E,{tier:3,wireCrossing:!0}),t.registerMessageType(B,{tier:3,wireCrossing:!0}),t.registerMessageType(P,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(C,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(q,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var ct,Vn=Y(()=>{"use strict";W();ct=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function qn(t){return Array.isArray(t)?[...t]:[t]}function xo(t,e){return t.has(e)||t.has("*")}function dt(t){let e=[];return t((o,s)=>{e.push({kind:"allow",actions:new Set(qn(o)),where:s?.where??(()=>!0)})},(o,s)=>{e.push({kind:"deny",actions:new Set(qn(o)),where:s?.where??(()=>!0)})}),(o,s)=>{let i=!1,a=!1;for(let c of e)xo(c.actions,s)&&c.where(o)&&(c.kind==="deny"?i=!0:a=!0);return i?!1:a}}function qt(t){let e=wo.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var Z,wo,De=Y(()=>{"use strict";Z=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};wo=["human","llm","wallet","system"]});function Wt(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(Wt);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=Wt(t[n]);return e}return null}function Oo(t){let e=Eo.encode(t),n=e.length,r=n*8,o=n+9+63&-64,s=new Uint8Array(o);s.set(e),s[n]=128;let i=new DataView(s.buffer);i.setUint32(o-4,r>>>0,!1),i.setUint32(o-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,c=3144134277,u=1013904242,l=2773480762,f=1359893119,p=2600822924,h=528734635,d=1541459225,g=new Uint32Array(64),m=(_,b)=>_>>>b|_<<32-b;for(let _=0;_<o;_+=64){for(let S=0;S<16;S++)g[S]=i.getUint32(_+S*4,!1);for(let S=16;S<64;S++){let k=g[S-15],A=g[S-2],F=m(k,7)^m(k,18)^k>>>3,U=m(A,17)^m(A,19)^A>>>10;g[S]=g[S-16]+F+g[S-7]+U>>>0}let b=a,y=c,w=u,T=l,x=f,O=p,N=h,M=d;for(let S=0;S<64;S++){let k=m(x,6)^m(x,11)^m(x,25),A=x&O^~x&N,F=M+k+A+To[S]+g[S]>>>0,U=m(b,2)^m(b,13)^m(b,22),re=b&y^b&w^y&w,ye=U+re>>>0;M=N,N=O,O=x,x=T+F>>>0,T=w,w=y,y=b,b=F+ye>>>0}a=a+b>>>0,c=c+y>>>0,u=u+w>>>0,l=l+T>>>0,f=f+x>>>0,p=p+O>>>0,h=h+N>>>0,d=d+M>>>0}let v=_=>_.toString(16).padStart(8,"0");return v(a)+v(c)+v(u)+v(l)+v(f)+v(p)+v(h)+v(d)}function Bt(t){let e=Wt(t??null),n=JSON.stringify(e);return Oo(n).slice(0,16)}function Ro(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function zt(t,e,n){let r=n?.id??Ro();if(t===0)return{id:r,version:0};let s=(n?.hash??Bt)(e);return{id:r,version:0,cid:s,prev:null}}function Wn(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var To,Eo,Bn=Y(()=>{"use strict";To=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Eo=new TextEncoder});function Un(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function Kt(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function lt(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function Ee(t,e,n){let r=Yn(t)?t:[],o=typeof t=="function"?t:typeof e=="function"?e:void 0,s={};return Yn(t)?s=(Ut(e)?e:n)??{}:Ut(t)?s=t:s=(Ut(e)?e:n)??{},new $(r,o,s)}var zn,Kn,No,So,Te,$,Yn,Ut,Ge=Y(()=>{"use strict";Vt();Ue();we();Xe();Vn();De();W();Bn();zn=()=>{},Kn=100;No=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},So=(t,e,n,r)=>{let o=t;if(o._status==="completed"||o._status==="errored")return;let s=o._cached,i=s===void 0?[$t]:[$t,[E,s]];o._status==="dirty"&&i.push(Ae),ut(e,i,o._config.tierOf)},Te=new ct({onMessage:No,onSubscribe:So});jn(Te);Hn(Te);$=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??Te,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??Bt;let o=r.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?zt(o,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Un);let s={};for(let[a,c]of Object.entries(r.meta??{})){let u={initial:c,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),s[a]=new t([],void 0,u)}Object.freeze(s),this.meta=s,this._hasMeta=Object.keys(s).length>0;let i=this;this._actions={emit(a){i._emit([[E,a]])},down(a){i._emit(lt(a))},up(a){i._emitUp(lt(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let o=n?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let s=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,c=i?.version??0,u=zt(e,s,{id:a,hash:o});u.version=c,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=ve(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let o=ve(e?.actor),s=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,s))throw new Z({actor:o,action:s,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(o,s))throw new Z({actor:o,action:s,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:he()}}down(e,n){let r=lt(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[E,e]])}up(e,n){if(this._deps.length===0)return;let r=lt(e);if(r.length===0)return;this._checkGuard(n);let o=n??{internal:!0};this._validateUpTiers(r);for(let s of this._deps)s.node.up?.(r,o)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let o=n(r[0]);if(o===3||o===4)throw new Error(`Node "${this.name}": tier-${o} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let c=ve(n);if(!this._guard(c,"observe"))throw new Z({actor:c,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let c of this._deps)Kt(c);if(this._partial===!1){for(let c of this._deps)if(c.prevData!==void 0||c.dataBatch.length!==0||c.terminal!==void 0||c.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let s;try{s=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:o},this._actions)}catch(c){throw this._sinkCount-=1,c}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(c){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof s=="function")try{s()}catch{}throw c}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof s=="function"&&s(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let o=r,s=this._deps[r];s.unsub=zn,s.unsub=s.node.subscribe(i=>{if(s.unsub===null)return;let a=this._config.tierOf,c=!1;for(let u of i)a(u[0])>=3&&(c=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:o},this._actions);c&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let o=0;o<n;o++){let s=this._deps[o];if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}Kt(s)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let n=this._deps.length,r=Un(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Ht),r.unsub=zn;try{r.unsub=e.subscribe(o=>{if(r.unsub===null)return;let s=this._config.tierOf,i=!1;for(let a of o)s(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(o){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,o}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[C,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(o){this._emit([[C,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let r of this._deps){if(r.unsub!=null){let o=r.unsub;r.unsub=null;try{o()}catch{}}Kt(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],o=n[0];if(this._inspectorHooks!=null){let s={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(s)}if(o!==Ke){if(o===I){this._depDirtied(r);return}if(o===oe){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(Gn);return}if(o===X||o===se){this._emit([n]);return}if(o===q){this._emit(Ft);return}if(o===E)this._depSettledAsData(r,n[1]);else if(o===B)this._depSettledAsResolved(r);else if(o===P)this._depSettledAsTerminal(r,!0);else if(o===C)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(o===E||o===B)&&this._emit([n]),(o===P||o===C)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Ht))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Dn),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[C,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(In)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[C,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[C,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let o=this._deps.map(i=>i.terminal),s={prevData:r,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,s);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[C,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Kn?(this._rerunDepth=0,this._emit([[C,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Kn} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[Ae,e[0]]:e;let r=!0,o=!1,s=!1,i=-1;for(let c of e){let u=n(c[0]);u<i&&(r=!1),u===3&&(o=!0),c[0]===I&&(s=!0),i=u}let a=e;if(!r){let c=e.map((u,l)=>({m:u,i:l,tier:n(u[0])}));c.sort((u,l)=>u.tier-l.tier||u.i-l.i),a=c.map(u=>u.m)}if(o&&!s&&this._status!=="dirty"){let c=0;for(;c<a.length&&n(a[c][0])===0;)c++;return c===0?[Ae,...a]:[...a.slice(0,c),Ae,...a.slice(c)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let c=e[a];if(c[0]===C&&c[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(c=>c[0]===q||c[0]===oe);if(a.length===0)return;n=a}n=this._frameBatch(n);let o=null;for(let a=0;a<n.length;a++){let c=n[a],u=c[0];if(u!==X&&u!==se){o?.push(c);continue}if(c.length<2)throw new Error(`Node "${this.name}": [[${u===X?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let l=!0;if(this._pausable!==!1){let f=c[1];if(u===X)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))l=!1;else if(this._pauseLocks.delete(f),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}l?o?.push(c):o==null&&(o=n.slice(0,a))}if(o!=null){if(o.length===0)return;n=o}if(this._hasMeta&&n.some(a=>a[0]===q))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(Ft)}catch{}let{finalMessages:s,equalsError:i}=this._updateState(n);if(s.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:s})}catch{}}if(s.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,c=[];for(let u of s)a(u[0])===3?this._pauseBuffer.push(u):c.push(u);c.length>0&&this._dispatchOrAccumulate(c)}else this._dispatchOrAccumulate(s);i!=null&&this._emit([[C,i]])}_updateState(e){let n=this._config.tierOf,r,o,s=-1,i=0;for(let l of e)n(l[0])===3&&i++;let a=i<=1,c=-1;if(this._versioning!=null&&i>1){for(let l=e.length-1;l>=0;l--)if(e[l][0]===E){c=l;break}}for(let l=0;l<e.length;l++){let f=e[l],p=f[0];if(p===E){if(f.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,f[1])}catch(d){o=this._wrapFnError("equals threw",d),s=l;break}if(h){r==null&&(r=e.slice(0,l)),r.push(Pt),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(c<0||l===c)&&Wn(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),p===I)this._status="dirty";else if(p===B)this._status="resolved";else if(p===P)this._status="completed";else if(p===C)this._status="errored";else if(p===oe){this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let d=h.invalidate;if(typeof d=="function")try{d()}catch{}}}else p===q&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=s>=0?r??e.slice(0,s):r??e;return o!=null?{finalMessages:u,equalsError:o}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(Fn()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Qe(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}ut(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);ut(this._deliverToSinks,n,this._config.tierOf)}},Yn=t=>Array.isArray(t),Ut=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function V(t,e){return Ee([],{...e,initial:t})}function Ie(t,e){return Ee((r,o,s)=>t(o,s)??void 0,{describeKind:"producer",...e})}function ie(t,e,n){return Ee(t,(o,s,i)=>{let a=o.map((c,u)=>c!=null&&c.length>0?c.at(-1):i.prevData[u]);s.emit(e(a,i))},{describeKind:"derived",...n})}function Yt(t,e,n){let r=new Map;return t.forEach((o,s)=>{r.set(o,s)}),ie(t,(o,s)=>e(a=>{let c=r.get(a);if(c==null)throw new Error(`dynamicNode: untracked dep "${a.name??"<unnamed>"}"`);return o[c]},s),n)}function Ze(t,e){let n,r=new Map,o=(s,i,a)=>{let c=!1,u=l=>{let f=r.get(l);if(f!==void 0){if(f<s.length){let h=s[f];return h!=null&&h.length>0?h.at(-1):a.prevData[f]}return l.cache}c=!0;let p=n._addDep(l);return r.set(l,p),l.cache};try{let l=t(u,a);c||(i.emit(l),a.store.__autoTrackLastDiscoveryError!=null&&delete a.store.__autoTrackLastDiscoveryError)}catch(l){if(!c)throw l;a.store.__autoTrackLastDiscoveryError=l}};return n=new $([],o,{describeKind:"derived",...e}),n}var de=Y(()=>{"use strict";Ge()});function nt(t,e,n){let r=new Set;for(let o of t.split(",")){let[s,i]=o.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${o}`);let c,u;if(s==="*")c=e,u=n;else if(s.includes("-")){let[l,f]=s.split("-");c=Number.parseInt(l,10),u=Number.parseInt(f,10)}else c=Number.parseInt(s,10),u=c;if(Number.isNaN(c)||Number.isNaN(u))throw new Error(`Invalid cron field: ${t}`);if(c<e||u>n)throw new Error(`Cron field out of range: ${t} (${e}-${n})`);if(c>u)throw new Error(`Invalid cron range: ${c}-${u} in ${t}`);for(let l=c;l<=u;l+=a)r.add(l)}return r}function fr(t){let e=t.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:nt(e[0],0,59),hours:nt(e[1],0,23),daysOfMonth:nt(e[2],1,31),months:nt(e[3],1,12),daysOfWeek:nt(e[4],0,6)}}function pr(t,e){return t.minutes.has(e.getMinutes())&&t.hours.has(e.getHours())&&t.daysOfMonth.has(e.getDate())&&t.months.has(e.getMonth()+1)&&t.daysOfWeek.has(e.getDay())}var hr=Y(()=>{"use strict"});function gr(t){return{describeKind:"producer",...t}}function mr(t,e){let{signal:n,period:r,...o}=e??{};return Ie(s=>{let i=!1,a=0,c,u,l=()=>{i=!0,c!==void 0&&clearTimeout(c),u!==void 0&&clearInterval(u),n?.removeEventListener("abort",p)},f=()=>{i||(r!=null?(s.emit(a++),u=setInterval(()=>{i||s.emit(a++)},r)):(i=!0,n?.removeEventListener("abort",p),s.emit(a++),s.down([[P]])))},p=()=>{i||(l(),s.down([[C,n.reason]]))};if(n?.aborted){p();return}return c=setTimeout(f,t),n?.addEventListener("abort",p,{once:!0}),l},gr(o))}function br(t,e){let n=fr(t),{tickMs:r,output:o,...s}=e??{},i=r??6e4,a=o==="date";return Ie(c=>{let u=-1,l=()=>{let p=new Date,h=p.getFullYear()*1e8+(p.getMonth()+1)*1e6+p.getDate()*1e4+p.getHours()*100+p.getMinutes();h!==u&&pr(n,p)&&(u=h,c.emit(a?p:he()))};l();let f=setInterval(l,i);return()=>clearInterval(f)},{...gr(s),name:s.name??`cron:${t}`})}function ge(t){return t.subscribe(()=>{})}var gt=Y(()=>{"use strict";Xe();W();de();hr()});var _t,Er=Y(()=>{"use strict";_t=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Xs={};ue(Xs,{jotai:()=>Jt,nanostores:()=>Xt,nestjs:()=>hn,react:()=>gn,signals:()=>yn,solid:()=>vn,svelte:()=>_n,vue:()=>xn,zustand:()=>wn});module.exports=lo(Xs);var Jt={};ue(Jt,{atom:()=>Ao});W();de();function Ao(t,e,n){if(typeof t=="function"){let r=t;return typeof e=="function"?Jn(r,e,n):Jn(r,void 0,e)}return ko(t,e)}function et(t){let e=t.cache,n;if(t.subscribe(o=>{for(let[s,i]of o)s===E&&(e=i),s===C&&(n=i)})(),n)throw n;return e}function ko(t,e){let n=V(t,{...e,resubscribable:!0,resetOnTeardown:!0});return{get:()=>n.status==="sentinel"?et(n):n.cache,set:r=>n.emit(r),update:r=>{let o=n.status==="sentinel"?et(n):n.cache;n.emit(r(o))},subscribe:r=>{let o=!0;return n.subscribe(s=>{for(let[i,a]of s)if(i===E){if(o){o=!1;continue}r(a)}})},meta:n.meta,_node:n}}function Jn(t,e,n){let r=Ze(s=>t(i=>{let a=i._node;return a.status==="sentinel"&&et(a),s(a)}),{...n,resubscribable:!0,resetOnTeardown:!0}),o={get:()=>r.status==="sentinel"?et(r):r.cache,subscribe:s=>{let i=!0;return r.subscribe(a=>{for(let[c,u]of a)if(c===E){if(i){i=!1;continue}s(u)}})},meta:r.meta,_node:r};if(e){let s=c=>c.get(),i=(c,u)=>c.set(u),a=o;return a.set=c=>e(s,i,c),a.update=c=>{let u=r.status==="sentinel"?et(r):r.cache;return e(s,i,c(u))},a}return o}var Xt={};ue(Xt,{action:()=>Lo,atom:()=>Co,computed:()=>Mo,getValue:()=>Go,map:()=>Do,onMount:()=>Io,onStart:()=>Zn,onStop:()=>er});we();W();de();var pt=new WeakMap,ht=new WeakMap;function ft(t,e){let n=e.get(t);if(n)for(let r of n)r()}function Qt(t,e={}){let n=0;return{...e,get:()=>Xn(t),subscribe:o=>{n===0&&ft(t,pt),n++;let s=t.subscribe(i=>{for(let[a,c]of i)a===E&&o(c)});return()=>{s(),n--,n===0&&ft(t,ht)}},listen:o=>{n===0&&ft(t,pt),n++;let s=!0,i=t.subscribe(a=>{for(let[c,u]of a)if(c===E){if(s){s=!1;continue}o(u)}});return()=>{i(),n--,n===0&&ft(t,ht)}},_node:t}}function Qn(t){let e=t.cache,n;if(t.subscribe(o=>{for(let[s,i]of o)s===E&&(e=i),s===C&&(n=i)})(),n)throw n;return e}function Xn(t){return t.status==="sentinel"?Qn(t):t.cache}function Co(t){let e=V(t,{resubscribable:!0,resetOnTeardown:!0});return Qt(e,{set:n=>e.emit(n)})}function Mo(t,e){let n=Array.isArray(t)?t:[t],r=n.map(s=>s._node),o=Yt(r,s=>{let i=n.map(a=>{let c=a._node;return c.status==="sentinel"&&Qn(c),s(c)});return e(...i)},{resubscribable:!0,resetOnTeardown:!0,equals:Object.is});return Qt(o)}function Do(t){let e=V(t,{resubscribable:!0,resetOnTeardown:!0,equals:()=>!1});return Qt(e,{set:n=>e.emit(n),setKey:(n,r)=>{let o=Xn(e);e.emit({...o,[n]:r})}})}function Go(t){return t.get()}function Zn(t,e){let n=t._node,r=pt.get(n);r||(r=new Set,pt.set(n,r)),r.add(e)}function er(t,e){let n=t._node,r=ht.get(n);r||(r=new Set,ht.set(n,r)),r.add(e)}function Io(t,e){Zn(t,()=>{let n=e();typeof n=="function"&&er(t,n)})}function Lo(t,e,n){return(...r)=>{let o;return ce(()=>{o=n(...r)}),o}}var hn={};ue(hn,{ACTOR_KEY:()=>yt,COMMAND_HANDLERS:()=>He,CQRS_EVENT_HANDLERS:()=>Fe,CRON_HANDLERS:()=>$e,CommandHandler:()=>ur,EVENT_HANDLERS:()=>Le,EventHandler:()=>cr,GRAPHREFLY_REQUEST_GRAPH:()=>Oe,GRAPHREFLY_ROOT_GRAPH:()=>ee,GraphCron:()=>ar,GraphInterval:()=>ir,GraphReflyEventExplorer:()=>Re,GraphReflyGuard:()=>Tr,GraphReflyGuardImpl:()=>rt,GraphReflyModule:()=>kt,INTERVAL_HANDLERS:()=>Pe,InjectCqrsGraph:()=>rr,InjectGraph:()=>nr,InjectNode:()=>or,ObserveGateway:()=>bt,OnGraphEvent:()=>sr,QUERY_HANDLERS:()=>je,QueryHandler:()=>dr,SAGA_HANDLERS:()=>Ve,SagaHandler:()=>lr,fromHeader:()=>xr,fromJwtPayload:()=>nn,getActor:()=>wr,getGraphToken:()=>K,getNodeToken:()=>ae,observeSSE:()=>vr,observeSubscription:()=>_r,toObservable:()=>tr});var Zt=require("rxjs");W();function tr(t,e){return e?.raw?new Zt.Observable(n=>t.subscribe(o=>{if(!n.closed){n.next(o);for(let s of o){if(s[0]===C){n.error(s[1]);return}if(s[0]===P){n.complete();return}}}})):new Zt.Observable(n=>t.subscribe(o=>{for(let s of o){if(n.closed)return;if(s[0]===E)n.next(s[1]);else if(s[0]===C){n.error(s[1]);return}else if(s[0]===P){n.complete();return}}}))}var tt=require("@nestjs/common");var ee=Symbol.for("graphrefly:root-graph");var Oe=Symbol.for("graphrefly:request-graph");function K(t){return Symbol.for(`graphrefly:graph:${t}`)}function ae(t){return Symbol.for(`graphrefly:node:${t}`)}var Le=new Map,Pe=new Map,$e=new Map,He=new Map,Fe=new Map,je=new Map,Ve=new Map;function nr(t){return t==="request"?(0,tt.Inject)(Oe):(0,tt.Inject)(t?K(t):ee)}function rr(t){return(0,tt.Inject)(K(t))}function or(t){return(0,tt.Inject)(ae(t))}function sr(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=Le.get(o)??[];s.push({nodeName:t,methodKey:r}),Le.set(o,s)})}}function ir(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=Pe.get(o)??[];s.push({ms:t,methodKey:r}),Pe.set(o,s)})}}function ar(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=$e.get(o)??[];s.push({expr:t,methodKey:r}),$e.set(o,s)})}}function ur(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=He.get(s)??[];i.push({cqrsName:t,commandName:e,methodKey:o}),He.set(s,i)})}}function cr(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=Fe.get(s)??[];i.push({cqrsName:t,eventName:e,methodKey:o}),Fe.set(s,i)})}}function dr(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=je.get(s)??[];i.push({cqrsName:t,projectionName:e,methodKey:o}),je.set(s,i)})}}function lr(t,e,n){return(r,o)=>{let s=o.name;o.addInitializer(function(){let i=this.constructor,a=Ve.get(i)??[];a.push({cqrsName:t,eventNames:n,sagaName:e,methodKey:s}),Ve.set(i,a)})}}W();gt();var yr=0,Re=class{constructor(e,n){this.graph=e;this.moduleRef=n}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,n]of Le){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireEventHandler(r,o)}}wireEventHandler(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),i=this.observeNode(n.nodeName).subscribe(a=>{for(let c of a)c[0]===E&&o(c[1])});this.disposers.push(i)}wireIntervals(){for(let[e,n]of Pe){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireIntervalHandler(r,e,o)}}wireIntervalHandler(e,n,r){let o=e[r.methodKey];if(typeof o!="function")return;let s=o.bind(e),a=`__schedule__.${n.name??"anonymous"}.${String(r.methodKey)}.${yr++}`,c=mr(r.ms,{period:r.ms,name:a});this.graph.add(c),this.scheduleNodeNames.push(a);let l=this.observeNode(a).subscribe(f=>{for(let p of f)p[0]===E&&s(p[1])});this.disposers.push(l)}wireCrons(){for(let[e,n]of $e){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCronHandler(r,e,o)}}wireCronHandler(e,n,r){let o=e[r.methodKey];if(typeof o!="function")return;let s=o.bind(e),a=`__schedule__.${n.name??"anonymous"}.${String(r.methodKey)}.${yr++}`,c=br(r.expr,{name:a});this.graph.add(c),this.scheduleNodeNames.push(a);let l=this.observeNode(a).subscribe(f=>{for(let p of f)p[0]===E&&s(p[1])});this.disposers.push(l)}wireCqrsCommands(){for(let[e,n]of He){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsCommand(r,o)}}wireCqrsCommand(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);s&&s.command(n.commandName,o)}wireCqrsEvents(){for(let[e,n]of Fe){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsEventHandler(r,o)}}wireCqrsEventHandler(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);if(!s)return;s.event(n.eventName);let a=s.resolve(n.eventName).cache,c=a&&a.length>0?a[a.length-1].seq:0,l=this.observeNodeOn(s,n.eventName).subscribe(f=>{for(let p of f)if(p[0]===E){let h=p[1];for(let d of h)d.seq>c&&(o(d),c=d.seq)}});this.disposers.push(l)}wireCqrsQueries(){for(let[e,n]of je){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsQuery(r,o)}}wireCqrsQuery(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);if(!s)return;let a=this.observeNodeOn(s,n.projectionName).subscribe(c=>{for(let u of c)u[0]===E&&o(u[1])});this.disposers.push(a)}wireCqrsSagas(){for(let[e,n]of Ve){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsSaga(r,o)}}wireCqrsSaga(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);s&&s.saga(n.sagaName,n.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,n){return e.observe(n)}resolveCqrsGraph(e){try{return this.moduleRef.get(K(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};W();W();var Po=0;function mt(t,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let n=Symbol(`bp-${++Po}`),r=0,o=!1;return{onEnqueue(){return r+=1,!o&&r>=e.highWaterMark?(o=!0,t([[X,n]]),!0):!1},onDequeue(){return r>0&&(r-=1),o&&r<=e.lowWaterMark?(o=!1,t([[se,n]]),!0):!1},get pending(){return r},get paused(){return o},dispose(){o&&(o=!1,t([[se,n]]))}}}function vr(t,e,n){let{actor:r,serialize:o=$o,keepAliveMs:s,signal:i}=n??{},a=new TextEncoder,c,u=n?.highWaterMark!=null,l,f,p=[],h=!1;return new ReadableStream({start(d){let g,m=()=>{},v=()=>{if(!h){h=!0,g!==void 0&&clearInterval(g),i?.removeEventListener("abort",_),m(),l?.dispose(),f?.(),f=void 0;for(let y of p)d.enqueue(y.frame);p.length=0,d.close()}};c=v;let _=()=>v(),b=t.observe(e,{actor:r});u&&(l=mt(y=>b.up(y),{highWaterMark:n.highWaterMark,lowWaterMark:n.lowWaterMark??Math.floor(n.highWaterMark/2)})),m=b.subscribe(y=>{for(let w of y){if(h)return;let T=w[0];if(T===E){let x=a.encode(en("data",o(w[1])));u?(p.push({frame:x,counted:!0}),l.onEnqueue(),f?.(),f=void 0):d.enqueue(x)}else if(T===C){let x=a.encode(en("error",o(w[1])));u?(p.push({frame:x,counted:!1}),f?.(),f=void 0):d.enqueue(x),v();return}else if(T===P||T===q){if(T===P){let x=a.encode(en("complete"));u?(p.push({frame:x,counted:!1}),f?.(),f=void 0):d.enqueue(x)}v();return}}}),s!==void 0&&s>0&&(g=setInterval(()=>{h||(u?(p.push({frame:a.encode(`: keepalive
2
2
 
3
3
  `),counted:!1}),f?.(),f=void 0):d.enqueue(a.encode(`: keepalive
4
4
 
@@ -1 +1 @@
1
- import{a as e}from"../chunk-WANIEEKV.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-AV3PIDFQ.js";import{b as a}from"../chunk-BA5URFYW.js";import{i as b}from"../chunk-BZP5T4X6.js";import{G as c}from"../chunk-P7JXGKDO.js";import"../chunk-VIEUJSTT.js";import"../chunk-5Z4HDCO6.js";import"../chunk-GNCBXARM.js";import"../chunk-Y32RJO24.js";import"../chunk-5QDBSZBV.js";import"../chunk-MGKAO4EK.js";import"../chunk-ESMPEKEV.js";import"../chunk-TWMEGG45.js";import"../chunk-AUY2YKCO.js";import"../chunk-KASHOCF5.js";import"../chunk-W4TSQ6RJ.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};
1
+ import{a as e}from"../chunk-I4U3TPK2.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-4ZPO2EL5.js";import{b as a}from"../chunk-A4JT4SAD.js";import{i as b}from"../chunk-W6FQIFVE.js";import{G as c}from"../chunk-GF5T7PGC.js";import"../chunk-Z3UWIJ3A.js";import"../chunk-K54OKWNY.js";import"../chunk-CZVYLXFK.js";import"../chunk-7EQPXQ7H.js";import"../chunk-5QDBSZBV.js";import"../chunk-XRSHMHEG.js";import"../chunk-PSQNYY72.js";import"../chunk-SGS4OJGS.js";import"../chunk-ESMPEKEV.js";import"../chunk-N2KKISCE.js";import"../chunk-UMH3HSP7.js";import"../chunk-7AJKUA36.js";import"../chunk-CK2E7BTU.js";import"../chunk-QYADASLV.js";export{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};
@@ -1 +1 @@
1
- "use strict";var J=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var Fe=(s,e)=>{for(var t in e)J(s,t,{get:e[t],enumerable:!0})},Ge=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of De(e))!Ce.call(s,r)&&r!==t&&J(s,r,{get:()=>e[r],enumerable:!(n=Oe(e,r))||n.enumerable});return s};var Ie=s=>Ge(J({},"__esModule",{value:!0}),s);var Ze={};Fe(Ze,{atom:()=>Je});module.exports=Ie(Ze);var I=Symbol.for("graphrefly/START"),g=Symbol.for("graphrefly/DATA"),A=Symbol.for("graphrefly/DIRTY"),k=Symbol.for("graphrefly/RESOLVED"),M=Symbol.for("graphrefly/INVALIDATE"),E=Symbol.for("graphrefly/PAUSE"),V=Symbol.for("graphrefly/RESUME"),w=Symbol.for("graphrefly/TEARDOWN"),S=Symbol.for("graphrefly/COMPLETE"),p=Symbol.for("graphrefly/ERROR"),R=Object.freeze([A]),X=Object.freeze([k]),Ve=Object.freeze([M]),Z=Object.freeze([I]),He=Object.freeze([S]),Le=Object.freeze([w]),Q=Object.freeze([R]),de=Object.freeze([X]),le=Object.freeze([Ve]),ce=Object.freeze([He]),ee=Object.freeze([Le]);var Pe={name:"json",version:1,contentType:"application/json",encode(s){let e=JSON.stringify(s);return new TextEncoder().encode(e)},decode(s,e){let t=new TextDecoder().decode(s);return JSON.parse(t)}};function ue(s){s.registerCodec(Pe)}var We={type:"system",id:""};function B(s){if(s==null)return We;let{type:e,id:t,...n}=s;return{type:e??"system",id:t??"",...n}}var te=0,Ue=!1,fe=[],he=[],pe=[],Be=[];function _e(){return te>0||Ue}function ge(){return te>0}function ye(s){te>0?Be.push(s):s()}function j(s,e,t){if(e.length===0)return;if(e.length===1){let l=t(e[0][0]);if(l<3||!_e()){s(e);return}(l>=5?pe:l===4?he:fe).push(()=>s(e));return}let n=e.length,r=n,a=n,i=n,o=0;for(;o<n&&t(e[o][0])<3;)o++;for(r=o;o<n&&t(e[o][0])===3;)o++;for(a=o;o<n&&t(e[o][0])===4;)o++;i=o;let d=_e();if(r>0){let l=e.slice(0,r);s(l)}if(a>r){let l=e.slice(r,a);d?fe.push(()=>s(l)):s(l)}if(i>a){let l=e.slice(a,i);d?he.push(()=>s(l)):s(l)}if(n>i){let l=e.slice(i,n);d?pe.push(()=>s(l)):s(l)}}function me(){return Date.now()*1e6}var z=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let n=this._messageTypes.get(t);return n!=null?n.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}};function be(s){s.registerMessageType(I,{tier:0,wireCrossing:!1}),s.registerMessageType(A,{tier:1,wireCrossing:!1}),s.registerMessageType(M,{tier:1,wireCrossing:!1,metaPassthrough:!1}),s.registerMessageType(E,{tier:2,wireCrossing:!1}),s.registerMessageType(V,{tier:2,wireCrossing:!1}),s.registerMessageType(g,{tier:3,wireCrossing:!0}),s.registerMessageType(k,{tier:3,wireCrossing:!0}),s.registerMessageType(S,{tier:4,wireCrossing:!0,metaPassthrough:!1}),s.registerMessageType(p,{tier:4,wireCrossing:!0,metaPassthrough:!1}),s.registerMessageType(w,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var O=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};function ne(s){if(s===void 0)return null;if(typeof s=="number"){if(!Number.isFinite(s))throw new TypeError(`Cannot hash non-finite number: ${s}`);if(Number.isInteger(s)&&!Number.isSafeInteger(s))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${s}. Cross-language cid parity is not guaranteed for unsafe integers.`);return s}if(typeof s=="string"||typeof s=="boolean"||s===null)return s;if(Array.isArray(s))return s.map(ne);if(typeof s=="object"&&s!==null){let e={};for(let t of Object.keys(s).sort())e[t]=ne(s[t]);return e}return null}var je=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ze=new TextEncoder;function $e(s){let e=ze.encode(s),t=e.length,n=t*8,r=t+9+63&-64,a=new Uint8Array(r);a.set(e),a[t]=128;let i=new DataView(a.buffer);i.setUint32(r-4,n>>>0,!1),i.setUint32(r-8,Math.floor(n/4294967296)>>>0,!1);let o=1779033703,d=3144134277,l=1013904242,c=2773480762,u=1359893119,_=2600822924,f=528734635,b=1541459225,N=new Uint32Array(64),m=(T,y)=>T>>>y|T<<32-y;for(let T=0;T<r;T+=64){for(let h=0;h<16;h++)N[h]=i.getUint32(T+h*4,!1);for(let h=16;h<64;h++){let F=N[h-15],G=N[h-2],U=m(F,7)^m(F,18)^F>>>3,K=m(G,17)^m(G,19)^G>>>10;N[h]=N[h-16]+U+N[h-7]+K>>>0}let y=o,D=d,C=l,q=c,x=u,P=_,W=f,Y=b;for(let h=0;h<64;h++){let F=m(x,6)^m(x,11)^m(x,25),G=x&P^~x&W,U=Y+F+G+je[h]+N[h]>>>0,K=m(y,2)^m(y,13)^m(y,22),Se=y&D^y&C^D&C,Re=K+Se>>>0;Y=W,W=P,P=x,x=q+U>>>0,q=C,C=D,D=y,y=U+Re>>>0}o=o+y>>>0,d=d+D>>>0,l=l+C>>>0,c=c+q>>>0,u=u+x>>>0,_=_+P>>>0,f=f+W>>>0,b=b+Y>>>0}let v=T=>T.toString(16).padStart(8,"0");return v(o)+v(d)+v(l)+v(c)+v(u)+v(_)+v(f)+v(b)}function se(s){let e=ne(s??null),t=JSON.stringify(e);return $e(t).slice(0,16)}function qe(){let s=globalThis.crypto;if(s?.randomUUID)return s.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function re(s,e,t){let n=t?.id??qe();if(s===0)return{id:n,version:0};let a=(t?.hash??se)(e);return{id:n,version:0,cid:a,prev:null}}function ve(s,e,t){s.version+=1,"cid"in s&&(s.prev=s.cid,s.cid=t(e))}var Te=()=>{},xe=100;function we(s){return{node:s,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function oe(s){s.prevData=void 0,s.dirty=!1,s.involvedThisWave=!1,s.dataBatch.length=0,s.terminal=void 0}function $(s){return s.length===0?s:typeof s[0]=="symbol"?[s]:s}var Ye=(s,e,t,n)=>{t.direction==="down-in"&&s._onDepMessage(t.depIndex,e)},Ke=(s,e,t,n)=>{let r=s;if(r._status==="completed"||r._status==="errored")return;let a=r._cached,i=a===void 0?[Z]:[Z,[g,a]];r._status==="dirty"&&i.push(R),j(e,i,r._config.tierOf)},ae=new z({onMessage:Ye,onSubscribe:Ke});be(ae);ue(ae);var H=class s{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,n){this._config=n.config??ae,this._config.onMessage,this._optsName=n.name,this._describeKind=n.describeKind,this._equals=n.equals??Object.is,this._resubscribable=n.resubscribable??!1,this._resetOnTeardown=n.resetOnTeardown??!1,this._autoComplete=n.completeWhenDepsComplete??!0,this._autoError=n.errorWhenDepsError??!0,this._pausable=n.pausable??!0,this._guard=n.guard,this._fn=t,this._partial=n.partial??!1,this._cached=n.initial!==void 0?n.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=n.versioningHash??this._config.defaultHashFn??se;let r=n.versioning??this._config.defaultVersioning;this._versioningLevel=r,this._versioning=r!=null?re(r,this._cached===void 0?void 0:this._cached,{id:n.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(we);let a={};for(let[o,d]of Object.entries(n.meta??{})){let l={initial:d,name:`${n.name??"node"}:meta:${o}`,describeKind:"state",config:this._config};n.guard!=null&&(l.guard=n.guard),a[o]=new s([],void 0,l)}Object.freeze(a),this.meta=a,this._hasMeta=Object.keys(a).length>0;let i=this;this._actions={emit(o){i._emit([[g,o]])},down(o){i._emit($(o))},up(o){i._emitUp($(o))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let n=this._versioningLevel;if(n!=null&&e<=n)return;let r=t?.hash??this._hashFn;r!==this._hashFn&&(this._hashFn=r);let a=this._cached===void 0?void 0:this._cached,i=this._versioning,o=i?.id??t?.id,d=i?.version??0,l=re(e,a,{id:o,hash:r});l.version=d,this._versioning=l,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=B(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let n of this._extraGuards)if(!n(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,n=e?.actor!=null;if(!t&&!n)return;let r=B(e?.actor),a=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(r,a))throw new O({actor:r,action:a,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(r,a))throw new O({actor:r,action:a,nodeName:this.name})}this._lastMutation={actor:r,timestamp_ns:me()}}down(e,t){let n=$(e);n.length!==0&&(this._checkGuard(t),this._emit(n))}emit(e,t){this._checkGuard(t),this._emit([[g,e]])}up(e,t){if(this._deps.length===0)return;let n=$(e);if(n.length===0)return;this._checkGuard(t);let r=t??{internal:!0};this._validateUpTiers(n);for(let a of this._deps)a.node.up?.(n,r)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let n of e){let r=t(n[0]);if(r===3||r===4)throw new Error(`Node "${this.name}": tier-${r} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let d=B(t);if(!this._guard(d,"observe"))throw new O({actor:d,action:"observe",nodeName:this.name})}let r=this._isTerminal&&this._resubscribable;if(r){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)oe(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let a;try{a=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:r},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof a=="function")try{a()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let o=!1;return()=>{o||(o=!0,this._sinkCount-=1,this._removeSink(e),typeof a=="function"&&a(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let n=0;n<e;n++){let r=n,a=this._deps[n];a.unsub=Te,a.unsub=a.node.subscribe(i=>{if(a.unsub===null)return;let o=this._config.tierOf,d=!1;for(let l of i)o(l[0])>=3&&(d=!0),this._config.onMessage(this,l,{direction:"down-in",depIndex:r},this._actions);d&&this._maybeRunFnOnSettlement()}),t++}}catch(n){this._deps[t].unsub=null;for(let r=0;r<t;r++){let a=this._deps[r];if(a.unsub!=null){let i=a.unsub;a.unsub=null;try{i()}catch{}oe(a)}}throw this._dirtyDepCount=0,n}}_addDep(e){for(let r=0;r<this._deps.length;r++)if(this._deps[r].node===e)return r;let t=this._deps.length,n=we(e);if(this._deps.push(n),this._sinks==null)return t;n.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Q),n.unsub=Te;try{n.unsub=e.subscribe(r=>{if(n.unsub===null)return;let a=this._config.tierOf,i=!1;for(let o of r)a(o[0])>=3&&(i=!0),this._config.onMessage(this,o,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(r){throw n.unsub=null,this._deps.pop(),this._dirtyDepCount--,r}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(n){this._emit([[p,this._wrapFnError("cleanup threw",n)]])}else if(t!=null&&typeof t=="object"){let n=t.deactivate;if(typeof n=="function")try{n()}catch(r){this._emit([[p,this._wrapFnError("cleanup.deactivate threw",r)]])}}for(let n of this._deps){if(n.unsub!=null){let r=n.unsub;n.unsub=null;try{r()}catch{}}oe(n)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let n=this._deps[e],r=t[0];if(this._inspectorHooks!=null){let a={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(a)}if(r!==I){if(r===A){this._depDirtied(n);return}if(r===M){this._depInvalidated(n),this._emit(le);return}if(r===E||r===V){this._emit([t]);return}if(r===w){this._emit(ee);return}if(r===g)this._depSettledAsData(n,t[1]);else if(r===k)this._depSettledAsResolved(n);else if(r===S)this._depSettledAsTerminal(n,!0);else if(r===p)this._depSettledAsTerminal(n,t[1]);else{this._emit([t]);return}if(!this._fn){(r===g||r===k)&&this._emit([t]),(r===S||r===p)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Q))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let t=this._deps[e];if(t.dataBatch.length===0&&t.prevData===void 0&&t.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(de),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[p,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(ce)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[p,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(o){this._emit([[p,this._wrapFnError("cleanup.beforeRun threw",o)]]);return}}}let t=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),n=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let o=t[i];o!=null&&o.length>0&&(this._deps[i].prevData=o[o.length-1])}let r=this._deps.map(i=>i.terminal),a={prevData:n,terminalDeps:r,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:n};for(let o of this._inspectorHooks)o(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,a);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let o=i;(typeof o.beforeRun=="function"||typeof o.deactivate=="function"||typeof o.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[p,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>xe?(this._rerunDepth=0,this._emit([[p,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${xe} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let n=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${n}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[R,e[0]]:e;let n=!0,r=!1,a=!1,i=-1;for(let d of e){let l=t(d[0]);l<i&&(n=!1),l===3&&(r=!0),d[0]===A&&(a=!0),i=l}let o=e;if(!n){let d=e.map((l,c)=>({m:l,i:c,tier:t(l[0])}));d.sort((l,c)=>l.tier-c.tier||l.i-c.i),o=d.map(l=>l.m)}if(r&&!a&&this._status!=="dirty"){let d=0;for(;d<o.length&&t(o[d][0])===0;)d++;return d===0?[R,...o]:[...o.slice(0,d),R,...o.slice(d)]}return o}_emit(e){if(e.length===0)return;for(let o=0;o<e.length;o++){let d=e[o];if(d[0]===p&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let o=e.filter(d=>d[0]===w||d[0]===M);if(o.length===0)return;t=o}t=this._frameBatch(t);let r=null;for(let o=0;o<t.length;o++){let d=t[o],l=d[0];if(l!==E&&l!==V){r?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${l===E?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let u=d[1];if(l===E)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(u),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(u))c=!1;else if(this._pauseLocks.delete(u),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let _=this._pauseBuffer;this._pauseBuffer=[],this._emit(_)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?r?.push(d):r==null&&(r=t.slice(0,o))}if(r!=null){if(r.length===0)return;t=r}if(this._hasMeta&&t.some(o=>o[0]===w))for(let o of Object.keys(this.meta))try{this.meta[o]._emit(ee)}catch{}let{finalMessages:a,equalsError:i}=this._updateState(t);if(a.length>0&&this._config.inspectorEnabled){let o=this._config.globalInspector;if(o!=null)try{o({kind:"emit",node:this,messages:a})}catch{}}if(a.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let o=this._config.tierOf,d=[];for(let l of a)o(l[0])===3?this._pauseBuffer.push(l):d.push(l);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(a);i!=null&&this._emit([[p,i]])}_updateState(e){let t=this._config.tierOf,n,r,a=-1,i=0;for(let c of e)t(c[0])===3&&i++;let o=i<=1,d=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===g){d=c;break}}for(let c=0;c<e.length;c++){let u=e[c],_=u[0];if(_===g){if(u.length>=2){let f=!1;if(o&&this._cached!==void 0)try{f=this._equals(this._cached,u[1])}catch(b){r=this._wrapFnError("equals threw",b),a=c;break}if(f){n==null&&(n=e.slice(0,c)),n.push(X),this._status="resolved";continue}this._cached=u[1],this._versioning!=null&&(d<0||c===d)&&ve(this._versioning,u[1],this._hashFn)}this._status="settled",n?.push(u)}else if(n?.push(u),_===A)this._status="dirty";else if(_===k)this._status="resolved";else if(_===S)this._status="completed";else if(_===p)this._status="errored";else if(_===M){this._cached=void 0,this._status="dirty";let f=this._cleanup;if(typeof f=="function"){this._cleanup=void 0;try{f()}catch{}}else if(f!=null&&typeof f=="object"){let b=f.invalidate;if(typeof b=="function")try{b()}catch{}}}else _===w&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let l=a>=0?n??e.slice(0,a):n??e;return r!=null?{finalMessages:l,equalsError:r}:{finalMessages:l}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let n of t)n(e)};_dispatchOrAccumulate(e){if(ge()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ye(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}j(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);j(this._deliverToSinks,t,this._config.tierOf)}},Ne=s=>Array.isArray(s),ie=s=>typeof s=="object"&&s!=null&&!Array.isArray(s);function Ae(s,e,t){let n=Ne(s)?s:[],r=typeof s=="function"?s:typeof e=="function"?e:void 0,a={};return Ne(s)?a=(ie(e)?e:t)??{}:ie(s)?a=s:a=(ie(e)?e:t)??{},new H(n,r,a)}function ke(s,e){return Ae([],{...e,initial:s})}function Me(s,e){let t,n=new Map,r=(a,i,o)=>{let d=!1,l=c=>{let u=n.get(c);if(u!==void 0){if(u<a.length){let f=a[u];return f!=null&&f.length>0?f.at(-1):o.prevData[u]}return c.cache}d=!0;let _=t._addDep(c);return n.set(c,_),c.cache};try{let c=s(l,o);d||(i.emit(c),o.store.__autoTrackLastDiscoveryError!=null&&delete o.store.__autoTrackLastDiscoveryError)}catch(c){if(!d)throw c;o.store.__autoTrackLastDiscoveryError=c}};return t=new H([],r,{describeKind:"derived",...e}),t}function Je(s,e,t){if(typeof s=="function"){let n=s;return typeof e=="function"?Ee(n,e,t):Ee(n,void 0,e)}return Xe(s,e)}function L(s){let e=s.cache,t;if(s.subscribe(r=>{for(let[a,i]of r)a===g&&(e=i),a===p&&(t=i)})(),t)throw t;return e}function Xe(s,e){let t=ke(s,{...e,resubscribable:!0,resetOnTeardown:!0});return{get:()=>t.status==="sentinel"?L(t):t.cache,set:n=>t.emit(n),update:n=>{let r=t.status==="sentinel"?L(t):t.cache;t.emit(n(r))},subscribe:n=>{let r=!0;return t.subscribe(a=>{for(let[i,o]of a)if(i===g){if(r){r=!1;continue}n(o)}})},meta:t.meta,_node:t}}function Ee(s,e,t){let n=Me(a=>s(i=>{let o=i._node;return o.status==="sentinel"&&L(o),a(o)}),{...t,resubscribable:!0,resetOnTeardown:!0}),r={get:()=>n.status==="sentinel"?L(n):n.cache,subscribe:a=>{let i=!0;return n.subscribe(o=>{for(let[d,l]of o)if(d===g){if(i){i=!1;continue}a(l)}})},meta:n.meta,_node:n};if(e){let a=d=>d.get(),i=(d,l)=>d.set(l),o=r;return o.set=d=>e(a,i,d),o.update=d=>{let l=n.status==="sentinel"?L(n):n.cache;return e(a,i,d(l))},o}return r}0&&(module.exports={atom});
1
+ "use strict";var J=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var Fe=(s,e)=>{for(var t in e)J(s,t,{get:e[t],enumerable:!0})},Ge=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of De(e))!Ce.call(s,r)&&r!==t&&J(s,r,{get:()=>e[r],enumerable:!(n=Oe(e,r))||n.enumerable});return s};var Ie=s=>Ge(J({},"__esModule",{value:!0}),s);var Ze={};Fe(Ze,{atom:()=>Je});module.exports=Ie(Ze);var I=Symbol.for("graphrefly/START"),g=Symbol.for("graphrefly/DATA"),A=Symbol.for("graphrefly/DIRTY"),k=Symbol.for("graphrefly/RESOLVED"),M=Symbol.for("graphrefly/INVALIDATE"),E=Symbol.for("graphrefly/PAUSE"),V=Symbol.for("graphrefly/RESUME"),w=Symbol.for("graphrefly/TEARDOWN"),S=Symbol.for("graphrefly/COMPLETE"),p=Symbol.for("graphrefly/ERROR"),R=Object.freeze([A]),X=Object.freeze([k]),Ve=Object.freeze([M]),Z=Object.freeze([I]),He=Object.freeze([S]),Le=Object.freeze([w]),Q=Object.freeze([R]),de=Object.freeze([X]),le=Object.freeze([Ve]),ce=Object.freeze([He]),ee=Object.freeze([Le]);var Pe={name:"json",version:1,contentType:"application/json",encode(s){let e=JSON.stringify(s);return new TextEncoder().encode(e)},decode(s,e){let t=new TextDecoder().decode(s);return JSON.parse(t)}};function ue(s){s.registerCodec(Pe)}var We={type:"system",id:""};function B(s){if(s==null)return We;let{type:e,id:t,...n}=s;return{type:e??"system",id:t??"",...n}}var te=0,Ue=!1,fe=[],he=[],pe=[],Be=[];function _e(){return te>0||Ue}function ge(){return te>0}function ye(s){te>0?Be.push(s):s()}function j(s,e,t){if(e.length===0)return;if(e.length===1){let l=t(e[0][0]);if(l<3||!_e()){s(e);return}(l>=5?pe:l===4?he:fe).push(()=>s(e));return}let n=e.length,r=n,a=n,i=n,o=0;for(;o<n&&t(e[o][0])<3;)o++;for(r=o;o<n&&t(e[o][0])===3;)o++;for(a=o;o<n&&t(e[o][0])===4;)o++;i=o;let d=_e();if(r>0){let l=e.slice(0,r);s(l)}if(a>r){let l=e.slice(r,a);d?fe.push(()=>s(l)):s(l)}if(i>a){let l=e.slice(a,i);d?he.push(()=>s(l)):s(l)}if(n>i){let l=e.slice(i,n);d?pe.push(()=>s(l)):s(l)}}function me(){return Date.now()*1e6}var z=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let n=this._messageTypes.get(t);return n!=null?n.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}};function be(s){s.registerMessageType(I,{tier:0,wireCrossing:!1}),s.registerMessageType(A,{tier:1,wireCrossing:!1}),s.registerMessageType(M,{tier:1,wireCrossing:!1,metaPassthrough:!1}),s.registerMessageType(E,{tier:2,wireCrossing:!1}),s.registerMessageType(V,{tier:2,wireCrossing:!1}),s.registerMessageType(g,{tier:3,wireCrossing:!0}),s.registerMessageType(k,{tier:3,wireCrossing:!0}),s.registerMessageType(S,{tier:4,wireCrossing:!0,metaPassthrough:!1}),s.registerMessageType(p,{tier:4,wireCrossing:!0,metaPassthrough:!1}),s.registerMessageType(w,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var O=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};function ne(s){if(s===void 0)return null;if(typeof s=="number"){if(!Number.isFinite(s))throw new TypeError(`Cannot hash non-finite number: ${s}`);if(Number.isInteger(s)&&!Number.isSafeInteger(s))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${s}. Cross-language cid parity is not guaranteed for unsafe integers.`);return s}if(typeof s=="string"||typeof s=="boolean"||s===null)return s;if(Array.isArray(s))return s.map(ne);if(typeof s=="object"&&s!==null){let e={};for(let t of Object.keys(s).sort())e[t]=ne(s[t]);return e}return null}var je=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ze=new TextEncoder;function $e(s){let e=ze.encode(s),t=e.length,n=t*8,r=t+9+63&-64,a=new Uint8Array(r);a.set(e),a[t]=128;let i=new DataView(a.buffer);i.setUint32(r-4,n>>>0,!1),i.setUint32(r-8,Math.floor(n/4294967296)>>>0,!1);let o=1779033703,d=3144134277,l=1013904242,c=2773480762,u=1359893119,_=2600822924,f=528734635,b=1541459225,N=new Uint32Array(64),m=(T,y)=>T>>>y|T<<32-y;for(let T=0;T<r;T+=64){for(let h=0;h<16;h++)N[h]=i.getUint32(T+h*4,!1);for(let h=16;h<64;h++){let F=N[h-15],G=N[h-2],U=m(F,7)^m(F,18)^F>>>3,K=m(G,17)^m(G,19)^G>>>10;N[h]=N[h-16]+U+N[h-7]+K>>>0}let y=o,D=d,C=l,q=c,x=u,P=_,W=f,Y=b;for(let h=0;h<64;h++){let F=m(x,6)^m(x,11)^m(x,25),G=x&P^~x&W,U=Y+F+G+je[h]+N[h]>>>0,K=m(y,2)^m(y,13)^m(y,22),Se=y&D^y&C^D&C,Re=K+Se>>>0;Y=W,W=P,P=x,x=q+U>>>0,q=C,C=D,D=y,y=U+Re>>>0}o=o+y>>>0,d=d+D>>>0,l=l+C>>>0,c=c+q>>>0,u=u+x>>>0,_=_+P>>>0,f=f+W>>>0,b=b+Y>>>0}let v=T=>T.toString(16).padStart(8,"0");return v(o)+v(d)+v(l)+v(c)+v(u)+v(_)+v(f)+v(b)}function se(s){let e=ne(s??null),t=JSON.stringify(e);return $e(t).slice(0,16)}function qe(){let s=globalThis.crypto;if(s?.randomUUID)return s.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function re(s,e,t){let n=t?.id??qe();if(s===0)return{id:n,version:0};let a=(t?.hash??se)(e);return{id:n,version:0,cid:a,prev:null}}function ve(s,e,t){s.version+=1,"cid"in s&&(s.prev=s.cid,s.cid=t(e))}var Te=()=>{},xe=100;function we(s){return{node:s,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function oe(s){s.prevData=void 0,s.dirty=!1,s.involvedThisWave=!1,s.dataBatch.length=0,s.terminal=void 0}function $(s){return s.length===0?s:typeof s[0]=="symbol"?[s]:s}var Ye=(s,e,t,n)=>{t.direction==="down-in"&&s._onDepMessage(t.depIndex,e)},Ke=(s,e,t,n)=>{let r=s;if(r._status==="completed"||r._status==="errored")return;let a=r._cached,i=a===void 0?[Z]:[Z,[g,a]];r._status==="dirty"&&i.push(R),j(e,i,r._config.tierOf)},ae=new z({onMessage:Ye,onSubscribe:Ke});be(ae);ue(ae);var H=class s{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,n){this._config=n.config??ae,this._config.onMessage,this._optsName=n.name,this._describeKind=n.describeKind,this._equals=n.equals??Object.is,this._resubscribable=n.resubscribable??!1,this._resetOnTeardown=n.resetOnTeardown??!1,this._autoComplete=n.completeWhenDepsComplete??!0,this._autoError=n.errorWhenDepsError??!0,this._pausable=n.pausable??!0,this._guard=n.guard,this._fn=t,this._partial=n.partial??!1,this._cached=n.initial!==void 0?n.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=n.versioningHash??this._config.defaultHashFn??se;let r=n.versioning??this._config.defaultVersioning;this._versioningLevel=r,this._versioning=r!=null?re(r,this._cached===void 0?void 0:this._cached,{id:n.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(we);let a={};for(let[o,d]of Object.entries(n.meta??{})){let l={initial:d,name:`${n.name??"node"}:meta:${o}`,describeKind:"state",config:this._config};n.guard!=null&&(l.guard=n.guard),a[o]=new s([],void 0,l)}Object.freeze(a),this.meta=a,this._hasMeta=Object.keys(a).length>0;let i=this;this._actions={emit(o){i._emit([[g,o]])},down(o){i._emit($(o))},up(o){i._emitUp($(o))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let n=this._versioningLevel;if(n!=null&&e<=n)return;let r=t?.hash??this._hashFn;r!==this._hashFn&&(this._hashFn=r);let a=this._cached===void 0?void 0:this._cached,i=this._versioning,o=i?.id??t?.id,d=i?.version??0,l=re(e,a,{id:o,hash:r});l.version=d,this._versioning=l,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=B(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let n of this._extraGuards)if(!n(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,n=e?.actor!=null;if(!t&&!n)return;let r=B(e?.actor),a=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(r,a))throw new O({actor:r,action:a,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(r,a))throw new O({actor:r,action:a,nodeName:this.name})}this._lastMutation={actor:r,timestamp_ns:me()}}down(e,t){let n=$(e);n.length!==0&&(this._checkGuard(t),this._emit(n))}emit(e,t){this._checkGuard(t),this._emit([[g,e]])}up(e,t){if(this._deps.length===0)return;let n=$(e);if(n.length===0)return;this._checkGuard(t);let r=t??{internal:!0};this._validateUpTiers(n);for(let a of this._deps)a.node.up?.(n,r)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let n of e){let r=t(n[0]);if(r===3||r===4)throw new Error(`Node "${this.name}": tier-${r} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let d=B(t);if(!this._guard(d,"observe"))throw new O({actor:d,action:"observe",nodeName:this.name})}let r=this._isTerminal&&this._resubscribable;if(r){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)oe(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let a;try{a=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:r},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof a=="function")try{a()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let o=!1;return()=>{o||(o=!0,this._sinkCount-=1,this._removeSink(e),typeof a=="function"&&a(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let n=0;n<e;n++){let r=n,a=this._deps[n];a.unsub=Te,a.unsub=a.node.subscribe(i=>{if(a.unsub===null)return;let o=this._config.tierOf,d=!1;for(let l of i)o(l[0])>=3&&(d=!0),this._config.onMessage(this,l,{direction:"down-in",depIndex:r},this._actions);d&&this._maybeRunFnOnSettlement()}),t++}}catch(n){this._deps[t].unsub=null;for(let r=0;r<t;r++){let a=this._deps[r];if(a.unsub!=null){let i=a.unsub;a.unsub=null;try{i()}catch{}oe(a)}}throw this._dirtyDepCount=0,n}}_addDep(e){for(let r=0;r<this._deps.length;r++)if(this._deps[r].node===e)return r;let t=this._deps.length,n=we(e);if(this._deps.push(n),this._sinks==null)return t;n.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Q),n.unsub=Te;try{n.unsub=e.subscribe(r=>{if(n.unsub===null)return;let a=this._config.tierOf,i=!1;for(let o of r)a(o[0])>=3&&(i=!0),this._config.onMessage(this,o,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(r){throw n.unsub=null,this._deps.pop(),this._dirtyDepCount--,r}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(n){this._emit([[p,this._wrapFnError("cleanup threw",n)]])}else if(t!=null&&typeof t=="object"){let n=t.deactivate;if(typeof n=="function")try{n()}catch(r){this._emit([[p,this._wrapFnError("cleanup.deactivate threw",r)]])}}for(let n of this._deps){if(n.unsub!=null){let r=n.unsub;n.unsub=null;try{r()}catch{}}oe(n)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let n=this._deps[e],r=t[0];if(this._inspectorHooks!=null){let a={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(a)}if(r!==I){if(r===A){this._depDirtied(n);return}if(r===M){if(this._depInvalidated(n),this._cached===void 0)return;this._emit(le);return}if(r===E||r===V){this._emit([t]);return}if(r===w){this._emit(ee);return}if(r===g)this._depSettledAsData(n,t[1]);else if(r===k)this._depSettledAsResolved(n);else if(r===S)this._depSettledAsTerminal(n,!0);else if(r===p)this._depSettledAsTerminal(n,t[1]);else{this._emit([t]);return}if(!this._fn){(r===g||r===k)&&this._emit([t]),(r===S||r===p)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Q))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let t=this._deps[e];if(t.dataBatch.length===0&&t.prevData===void 0&&t.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(de),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[p,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(ce)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[p,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(o){this._emit([[p,this._wrapFnError("cleanup.beforeRun threw",o)]]);return}}}let t=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),n=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let o=t[i];o!=null&&o.length>0&&(this._deps[i].prevData=o[o.length-1])}let r=this._deps.map(i=>i.terminal),a={prevData:n,terminalDeps:r,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:n};for(let o of this._inspectorHooks)o(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,a);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let o=i;(typeof o.beforeRun=="function"||typeof o.deactivate=="function"||typeof o.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[p,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>xe?(this._rerunDepth=0,this._emit([[p,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${xe} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let n=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${n}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[R,e[0]]:e;let n=!0,r=!1,a=!1,i=-1;for(let d of e){let l=t(d[0]);l<i&&(n=!1),l===3&&(r=!0),d[0]===A&&(a=!0),i=l}let o=e;if(!n){let d=e.map((l,c)=>({m:l,i:c,tier:t(l[0])}));d.sort((l,c)=>l.tier-c.tier||l.i-c.i),o=d.map(l=>l.m)}if(r&&!a&&this._status!=="dirty"){let d=0;for(;d<o.length&&t(o[d][0])===0;)d++;return d===0?[R,...o]:[...o.slice(0,d),R,...o.slice(d)]}return o}_emit(e){if(e.length===0)return;for(let o=0;o<e.length;o++){let d=e[o];if(d[0]===p&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let o=e.filter(d=>d[0]===w||d[0]===M);if(o.length===0)return;t=o}t=this._frameBatch(t);let r=null;for(let o=0;o<t.length;o++){let d=t[o],l=d[0];if(l!==E&&l!==V){r?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${l===E?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let u=d[1];if(l===E)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(u),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(u))c=!1;else if(this._pauseLocks.delete(u),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let _=this._pauseBuffer;this._pauseBuffer=[],this._emit(_)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?r?.push(d):r==null&&(r=t.slice(0,o))}if(r!=null){if(r.length===0)return;t=r}if(this._hasMeta&&t.some(o=>o[0]===w))for(let o of Object.keys(this.meta))try{this.meta[o]._emit(ee)}catch{}let{finalMessages:a,equalsError:i}=this._updateState(t);if(a.length>0&&this._config.inspectorEnabled){let o=this._config.globalInspector;if(o!=null)try{o({kind:"emit",node:this,messages:a})}catch{}}if(a.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let o=this._config.tierOf,d=[];for(let l of a)o(l[0])===3?this._pauseBuffer.push(l):d.push(l);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(a);i!=null&&this._emit([[p,i]])}_updateState(e){let t=this._config.tierOf,n,r,a=-1,i=0;for(let c of e)t(c[0])===3&&i++;let o=i<=1,d=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===g){d=c;break}}for(let c=0;c<e.length;c++){let u=e[c],_=u[0];if(_===g){if(u.length>=2){let f=!1;if(o&&this._cached!==void 0)try{f=this._equals(this._cached,u[1])}catch(b){r=this._wrapFnError("equals threw",b),a=c;break}if(f){n==null&&(n=e.slice(0,c)),n.push(X),this._status="resolved";continue}this._cached=u[1],this._versioning!=null&&(d<0||c===d)&&ve(this._versioning,u[1],this._hashFn)}this._status="settled",n?.push(u)}else if(n?.push(u),_===A)this._status="dirty";else if(_===k)this._status="resolved";else if(_===S)this._status="completed";else if(_===p)this._status="errored";else if(_===M){this._cached=void 0,this._status="dirty";let f=this._cleanup;if(typeof f=="function"){this._cleanup=void 0;try{f()}catch{}}else if(f!=null&&typeof f=="object"){let b=f.invalidate;if(typeof b=="function")try{b()}catch{}}}else _===w&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let l=a>=0?n??e.slice(0,a):n??e;return r!=null?{finalMessages:l,equalsError:r}:{finalMessages:l}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let n of t)n(e)};_dispatchOrAccumulate(e){if(ge()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ye(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}j(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);j(this._deliverToSinks,t,this._config.tierOf)}},Ne=s=>Array.isArray(s),ie=s=>typeof s=="object"&&s!=null&&!Array.isArray(s);function Ae(s,e,t){let n=Ne(s)?s:[],r=typeof s=="function"?s:typeof e=="function"?e:void 0,a={};return Ne(s)?a=(ie(e)?e:t)??{}:ie(s)?a=s:a=(ie(e)?e:t)??{},new H(n,r,a)}function ke(s,e){return Ae([],{...e,initial:s})}function Me(s,e){let t,n=new Map,r=(a,i,o)=>{let d=!1,l=c=>{let u=n.get(c);if(u!==void 0){if(u<a.length){let f=a[u];return f!=null&&f.length>0?f.at(-1):o.prevData[u]}return c.cache}d=!0;let _=t._addDep(c);return n.set(c,_),c.cache};try{let c=s(l,o);d||(i.emit(c),o.store.__autoTrackLastDiscoveryError!=null&&delete o.store.__autoTrackLastDiscoveryError)}catch(c){if(!d)throw c;o.store.__autoTrackLastDiscoveryError=c}};return t=new H([],r,{describeKind:"derived",...e}),t}function Je(s,e,t){if(typeof s=="function"){let n=s;return typeof e=="function"?Ee(n,e,t):Ee(n,void 0,e)}return Xe(s,e)}function L(s){let e=s.cache,t;if(s.subscribe(r=>{for(let[a,i]of r)a===g&&(e=i),a===p&&(t=i)})(),t)throw t;return e}function Xe(s,e){let t=ke(s,{...e,resubscribable:!0,resetOnTeardown:!0});return{get:()=>t.status==="sentinel"?L(t):t.cache,set:n=>t.emit(n),update:n=>{let r=t.status==="sentinel"?L(t):t.cache;t.emit(n(r))},subscribe:n=>{let r=!0;return t.subscribe(a=>{for(let[i,o]of a)if(i===g){if(r){r=!1;continue}n(o)}})},meta:t.meta,_node:t}}function Ee(s,e,t){let n=Me(a=>s(i=>{let o=i._node;return o.status==="sentinel"&&L(o),a(o)}),{...t,resubscribable:!0,resetOnTeardown:!0}),r={get:()=>n.status==="sentinel"?L(n):n.cache,subscribe:a=>{let i=!0;return n.subscribe(o=>{for(let[d,l]of o)if(d===g){if(i){i=!1;continue}a(l)}})},meta:n.meta,_node:n};if(e){let a=d=>d.get(),i=(d,l)=>d.set(l),o=r;return o.set=d=>e(a,i,d),o.update=d=>{let l=n.status==="sentinel"?L(n):n.cache;return e(a,i,d(l))},o}return r}0&&(module.exports={atom});
@@ -1 +1 @@
1
- import{a}from"../../chunk-BA5URFYW.js";import"../../chunk-W4TSQ6RJ.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{a as atom};
1
+ import{a}from"../../chunk-A4JT4SAD.js";import"../../chunk-7AJKUA36.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{a as atom};
@@ -1 +1 @@
1
- "use strict";var re=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Be=Object.prototype.hasOwnProperty;var We=(n,e)=>{for(var t in e)re(n,t,{get:e[t],enumerable:!0})},je=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ue(e))!Be.call(n,r)&&r!==t&&re(n,r,{get:()=>e[r],enumerable:!(s=Pe(e,r))||s.enumerable});return n};var ze=n=>je(re({},"__esModule",{value:!0}),n);var ut={};We(ut,{action:()=>lt,atom:()=>ot,computed:()=>it,getValue:()=>dt,map:()=>at,onMount:()=>ct,onStart:()=>Ge,onStop:()=>He});module.exports=ze(ut);var O=0,P=!1,A=[],k=[],D=[],U=[];function me(){return O>0||P}function be(){return O>0}function ve(n){O>0?U.push(n):n()}function Te(n){O+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(O-=1,O===0)if(e){if(!P){let t=U.splice(0);for(let s of t)try{s()}catch{}A.length=0,k.length=0,D.length=0}}else $e()}}function $e(){let n=!P;n&&(P=!0);let e=[],t=0;try{for(;A.length>0||k.length>0||D.length>0||n&&U.length>0;){if(n&&U.length>0){let i=U.splice(0);for(let a of i)try{a()}catch(o){e.push(o)}continue}if(t+=1,t>1e3)throw A.length=0,k.length=0,D.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let r=(A.length>0?A:k.length>0?k:D).splice(0);for(let i of r)try{i()}catch(a){e.push(a)}}}finally{n&&(P=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function q(n,e,t){if(e.length===0)return;if(e.length===1){let c=t(e[0][0]);if(c<3||!me()){n(e);return}(c>=5?D:c===4?k:A).push(()=>n(e));return}let s=e.length,r=s,i=s,a=s,o=0;for(;o<s&&t(e[o][0])<3;)o++;for(r=o;o<s&&t(e[o][0])===3;)o++;for(i=o;o<s&&t(e[o][0])===4;)o++;a=o;let d=me();if(r>0){let c=e.slice(0,r);n(c)}if(i>r){let c=e.slice(r,i);d?A.push(()=>n(c)):n(c)}if(a>i){let c=e.slice(i,a);d?k.push(()=>n(c)):n(c)}if(s>a){let c=e.slice(a,s);d?D.push(()=>n(c)):n(c)}}var B=Symbol.for("graphrefly/START"),g=Symbol.for("graphrefly/DATA"),M=Symbol.for("graphrefly/DIRTY"),E=Symbol.for("graphrefly/RESOLVED"),S=Symbol.for("graphrefly/INVALIDATE"),C=Symbol.for("graphrefly/PAUSE"),W=Symbol.for("graphrefly/RESUME"),w=Symbol.for("graphrefly/TEARDOWN"),R=Symbol.for("graphrefly/COMPLETE"),f=Symbol.for("graphrefly/ERROR"),F=Object.freeze([M]),oe=Object.freeze([E]),qe=Object.freeze([S]),ie=Object.freeze([B]),Ke=Object.freeze([R]),Ye=Object.freeze([w]),ae=Object.freeze([F]),xe=Object.freeze([oe]),we=Object.freeze([qe]),Ne=Object.freeze([Ke]),de=Object.freeze([Ye]);var Je={name:"json",version:1,contentType:"application/json",encode(n){let e=JSON.stringify(n);return new TextEncoder().encode(e)},decode(n,e){let t=new TextDecoder().decode(n);return JSON.parse(t)}};function Ae(n){n.registerCodec(Je)}var Xe={type:"system",id:""};function K(n){if(n==null)return Xe;let{type:e,id:t,...s}=n;return{type:e??"system",id:t??"",...s}}function ke(){return Date.now()*1e6}var Y=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let s=this._messageTypes.get(t);return s!=null?s.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}};function Me(n){n.registerMessageType(B,{tier:0,wireCrossing:!1}),n.registerMessageType(M,{tier:1,wireCrossing:!1}),n.registerMessageType(S,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(C,{tier:2,wireCrossing:!1}),n.registerMessageType(W,{tier:2,wireCrossing:!1}),n.registerMessageType(g,{tier:3,wireCrossing:!0}),n.registerMessageType(E,{tier:3,wireCrossing:!0}),n.registerMessageType(R,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(f,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(w,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var I=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};function ce(n){if(n===void 0)return null;if(typeof n=="number"){if(!Number.isFinite(n))throw new TypeError(`Cannot hash non-finite number: ${n}`);if(Number.isInteger(n)&&!Number.isSafeInteger(n))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${n}. Cross-language cid parity is not guaranteed for unsafe integers.`);return n}if(typeof n=="string"||typeof n=="boolean"||n===null)return n;if(Array.isArray(n))return n.map(ce);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=ce(n[t]);return e}return null}var Ze=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Qe=new TextEncoder;function et(n){let e=Qe.encode(n),t=e.length,s=t*8,r=t+9+63&-64,i=new Uint8Array(r);i.set(e),i[t]=128;let a=new DataView(i.buffer);a.setUint32(r-4,s>>>0,!1),a.setUint32(r-8,Math.floor(s/4294967296)>>>0,!1);let o=1779033703,d=3144134277,c=1013904242,l=2773480762,h=1359893119,p=2600822924,_=528734635,b=1541459225,N=new Uint32Array(64),m=(T,y)=>T>>>y|T<<32-y;for(let T=0;T<r;T+=64){for(let u=0;u<16;u++)N[u]=a.getUint32(T+u*4,!1);for(let u=16;u<64;u++){let L=N[u-15],V=N[u-2],$=m(L,7)^m(L,18)^L>>>3,se=m(V,17)^m(V,19)^V>>>10;N[u]=N[u-16]+$+N[u-7]+se>>>0}let y=o,G=d,H=c,te=l,x=h,j=p,z=_,ne=b;for(let u=0;u<64;u++){let L=m(x,6)^m(x,11)^m(x,25),V=x&j^~x&z,$=ne+L+V+Ze[u]+N[u]>>>0,se=m(y,2)^m(y,13)^m(y,22),Le=y&G^y&H^G&H,Ve=se+Le>>>0;ne=z,z=j,j=x,x=te+$>>>0,te=H,H=G,G=y,y=$+Ve>>>0}o=o+y>>>0,d=d+G>>>0,c=c+H>>>0,l=l+te>>>0,h=h+x>>>0,p=p+j>>>0,_=_+z>>>0,b=b+ne>>>0}let v=T=>T.toString(16).padStart(8,"0");return v(o)+v(d)+v(c)+v(l)+v(h)+v(p)+v(_)+v(b)}function le(n){let e=ce(n??null),t=JSON.stringify(e);return et(t).slice(0,16)}function tt(){let n=globalThis.crypto;if(n?.randomUUID)return n.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function ue(n,e,t){let s=t?.id??tt();if(n===0)return{id:s,version:0};let i=(t?.hash??le)(e);return{id:s,version:0,cid:i,prev:null}}function Ee(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}var Se=()=>{},Ce=100;function Re(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function fe(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function J(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}var nt=(n,e,t,s)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},st=(n,e,t,s)=>{let r=n;if(r._status==="completed"||r._status==="errored")return;let i=r._cached,a=i===void 0?[ie]:[ie,[g,i]];r._status==="dirty"&&a.push(F),q(e,a,r._config.tierOf)},pe=new Y({onMessage:nt,onSubscribe:st});Me(pe);Ae(pe);var X=class n{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,s){this._config=s.config??pe,this._config.onMessage,this._optsName=s.name,this._describeKind=s.describeKind,this._equals=s.equals??Object.is,this._resubscribable=s.resubscribable??!1,this._resetOnTeardown=s.resetOnTeardown??!1,this._autoComplete=s.completeWhenDepsComplete??!0,this._autoError=s.errorWhenDepsError??!0,this._pausable=s.pausable??!0,this._guard=s.guard,this._fn=t,this._partial=s.partial??!1,this._cached=s.initial!==void 0?s.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=s.versioningHash??this._config.defaultHashFn??le;let r=s.versioning??this._config.defaultVersioning;this._versioningLevel=r,this._versioning=r!=null?ue(r,this._cached===void 0?void 0:this._cached,{id:s.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Re);let i={};for(let[o,d]of Object.entries(s.meta??{})){let c={initial:d,name:`${s.name??"node"}:meta:${o}`,describeKind:"state",config:this._config};s.guard!=null&&(c.guard=s.guard),i[o]=new n([],void 0,c)}Object.freeze(i),this.meta=i,this._hasMeta=Object.keys(i).length>0;let a=this;this._actions={emit(o){a._emit([[g,o]])},down(o){a._emit(J(o))},up(o){a._emitUp(J(o))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let s=this._versioningLevel;if(s!=null&&e<=s)return;let r=t?.hash??this._hashFn;r!==this._hashFn&&(this._hashFn=r);let i=this._cached===void 0?void 0:this._cached,a=this._versioning,o=a?.id??t?.id,d=a?.version??0,c=ue(e,i,{id:o,hash:r});c.version=d,this._versioning=c,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=K(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let s of this._extraGuards)if(!s(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,s=e?.actor!=null;if(!t&&!s)return;let r=K(e?.actor),i=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(r,i))throw new I({actor:r,action:i,nodeName:this.name});if(this._extraGuards!=null){for(let a of this._extraGuards)if(!a(r,i))throw new I({actor:r,action:i,nodeName:this.name})}this._lastMutation={actor:r,timestamp_ns:ke()}}down(e,t){let s=J(e);s.length!==0&&(this._checkGuard(t),this._emit(s))}emit(e,t){this._checkGuard(t),this._emit([[g,e]])}up(e,t){if(this._deps.length===0)return;let s=J(e);if(s.length===0)return;this._checkGuard(t);let r=t??{internal:!0};this._validateUpTiers(s);for(let i of this._deps)i.node.up?.(s,r)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let s of e){let r=t(s[0]);if(r===3||r===4)throw new Error(`Node "${this.name}": tier-${r} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let d=K(t);if(!this._guard(d,"observe"))throw new I({actor:d,action:"observe",nodeName:this.name})}let r=this._isTerminal&&this._resubscribable;if(r){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)fe(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let i;try{i=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:r},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let a=this._isTerminal;if(this._sinkCount===1&&!a)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof i=="function")try{i()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let o=!1;return()=>{o||(o=!0,this._sinkCount-=1,this._removeSink(e),typeof i=="function"&&i(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let s=0;s<e;s++){let r=s,i=this._deps[s];i.unsub=Se,i.unsub=i.node.subscribe(a=>{if(i.unsub===null)return;let o=this._config.tierOf,d=!1;for(let c of a)o(c[0])>=3&&(d=!0),this._config.onMessage(this,c,{direction:"down-in",depIndex:r},this._actions);d&&this._maybeRunFnOnSettlement()}),t++}}catch(s){this._deps[t].unsub=null;for(let r=0;r<t;r++){let i=this._deps[r];if(i.unsub!=null){let a=i.unsub;i.unsub=null;try{a()}catch{}fe(i)}}throw this._dirtyDepCount=0,s}}_addDep(e){for(let r=0;r<this._deps.length;r++)if(this._deps[r].node===e)return r;let t=this._deps.length,s=Re(e);if(this._deps.push(s),this._sinks==null)return t;s.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ae),s.unsub=Se;try{s.unsub=e.subscribe(r=>{if(s.unsub===null)return;let i=this._config.tierOf,a=!1;for(let o of r)i(o[0])>=3&&(a=!0),this._config.onMessage(this,o,{direction:"down-in",depIndex:t},this._actions);a&&this._maybeRunFnOnSettlement()})}catch(r){throw s.unsub=null,this._deps.pop(),this._dirtyDepCount--,r}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(s){this._emit([[f,this._wrapFnError("cleanup threw",s)]])}else if(t!=null&&typeof t=="object"){let s=t.deactivate;if(typeof s=="function")try{s()}catch(r){this._emit([[f,this._wrapFnError("cleanup.deactivate threw",r)]])}}for(let s of this._deps){if(s.unsub!=null){let r=s.unsub;s.unsub=null;try{r()}catch{}}fe(s)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let s=this._deps[e],r=t[0];if(this._inspectorHooks!=null){let i={kind:"dep_message",depIndex:e,message:t};for(let a of this._inspectorHooks)a(i)}if(r!==B){if(r===M){this._depDirtied(s);return}if(r===S){this._depInvalidated(s),this._emit(we);return}if(r===C||r===W){this._emit([t]);return}if(r===w){this._emit(de);return}if(r===g)this._depSettledAsData(s,t[1]);else if(r===E)this._depSettledAsResolved(s);else if(r===R)this._depSettledAsTerminal(s,!0);else if(r===f)this._depSettledAsTerminal(s,t[1]);else{this._emit([t]);return}if(!this._fn){(r===g||r===E)&&this._emit([t]),(r===R||r===f)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ae))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let t=this._deps[e];if(t.dataBatch.length===0&&t.prevData===void 0&&t.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(xe),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[f,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(Ne)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(a){this._emit([[f,this._wrapFnError("cleanup threw",a)]]);return}}else if(e!=null&&typeof e=="object"){let a=e.beforeRun;if(typeof a=="function"){e.beforeRun=void 0;try{a()}catch(o){this._emit([[f,this._wrapFnError("cleanup.beforeRun threw",o)]]);return}}}let t=this._deps.map(a=>a.involvedThisWave?a.dataBatch.length>0?[...a.dataBatch]:[]:void 0),s=this._deps.map(a=>a.prevData);for(let a=0;a<this._deps.length;a++){let o=t[a];o!=null&&o.length>0&&(this._deps[a].prevData=o[o.length-1])}let r=this._deps.map(a=>a.terminal),i={prevData:s,terminalDeps:r,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let a={kind:"run",batchData:t,prevData:s};for(let o of this._inspectorHooks)o(a)}this._isExecutingFn=!0;try{let a=this._fn(t,this._actions,i);if(typeof a=="function")this._cleanup=a;else if(a!=null&&typeof a=="object"){let o=a;(typeof o.beforeRun=="function"||typeof o.deactivate=="function"||typeof o.invalidate=="function")&&(this._cleanup=a)}}catch(a){this._emit([[f,this._wrapFnError("fn threw",a)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Ce?(this._rerunDepth=0,this._emit([[f,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Ce} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let s=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${s}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[F,e[0]]:e;let s=!0,r=!1,i=!1,a=-1;for(let d of e){let c=t(d[0]);c<a&&(s=!1),c===3&&(r=!0),d[0]===M&&(i=!0),a=c}let o=e;if(!s){let d=e.map((c,l)=>({m:c,i:l,tier:t(c[0])}));d.sort((c,l)=>c.tier-l.tier||c.i-l.i),o=d.map(c=>c.m)}if(r&&!i&&this._status!=="dirty"){let d=0;for(;d<o.length&&t(o[d][0])===0;)d++;return d===0?[F,...o]:[...o.slice(0,d),F,...o.slice(d)]}return o}_emit(e){if(e.length===0)return;for(let o=0;o<e.length;o++){let d=e[o];if(d[0]===f&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let o=e.filter(d=>d[0]===w||d[0]===S);if(o.length===0)return;t=o}t=this._frameBatch(t);let r=null;for(let o=0;o<t.length;o++){let d=t[o],c=d[0];if(c!==C&&c!==W){r?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${c===C?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let l=!0;if(this._pausable!==!1){let h=d[1];if(c===C)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(h),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(h))l=!1;else if(this._pauseLocks.delete(h),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}l?r?.push(d):r==null&&(r=t.slice(0,o))}if(r!=null){if(r.length===0)return;t=r}if(this._hasMeta&&t.some(o=>o[0]===w))for(let o of Object.keys(this.meta))try{this.meta[o]._emit(de)}catch{}let{finalMessages:i,equalsError:a}=this._updateState(t);if(i.length>0&&this._config.inspectorEnabled){let o=this._config.globalInspector;if(o!=null)try{o({kind:"emit",node:this,messages:i})}catch{}}if(i.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let o=this._config.tierOf,d=[];for(let c of i)o(c[0])===3?this._pauseBuffer.push(c):d.push(c);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(i);a!=null&&this._emit([[f,a]])}_updateState(e){let t=this._config.tierOf,s,r,i=-1,a=0;for(let l of e)t(l[0])===3&&a++;let o=a<=1,d=-1;if(this._versioning!=null&&a>1){for(let l=e.length-1;l>=0;l--)if(e[l][0]===g){d=l;break}}for(let l=0;l<e.length;l++){let h=e[l],p=h[0];if(p===g){if(h.length>=2){let _=!1;if(o&&this._cached!==void 0)try{_=this._equals(this._cached,h[1])}catch(b){r=this._wrapFnError("equals threw",b),i=l;break}if(_){s==null&&(s=e.slice(0,l)),s.push(oe),this._status="resolved";continue}this._cached=h[1],this._versioning!=null&&(d<0||l===d)&&Ee(this._versioning,h[1],this._hashFn)}this._status="settled",s?.push(h)}else if(s?.push(h),p===M)this._status="dirty";else if(p===E)this._status="resolved";else if(p===R)this._status="completed";else if(p===f)this._status="errored";else if(p===S){this._cached=void 0,this._status="dirty";let _=this._cleanup;if(typeof _=="function"){this._cleanup=void 0;try{_()}catch{}}else if(_!=null&&typeof _=="object"){let b=_.invalidate;if(typeof b=="function")try{b()}catch{}}}else p===w&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let c=i>=0?s??e.slice(0,i):s??e;return r!=null?{finalMessages:c,equalsError:r}:{finalMessages:c}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let s of t)s(e)};_dispatchOrAccumulate(e){if(be()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ve(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}q(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);q(this._deliverToSinks,t,this._config.tierOf)}},Oe=n=>Array.isArray(n),he=n=>typeof n=="object"&&n!=null&&!Array.isArray(n);function ge(n,e,t){let s=Oe(n)?n:[],r=typeof n=="function"?n:typeof e=="function"?e:void 0,i={};return Oe(n)?i=(he(e)?e:t)??{}:he(n)?i=n:i=(he(e)?e:t)??{},new X(s,r,i)}function _e(n,e){return ge([],{...e,initial:n})}function rt(n,e,t){return ge(n,(r,i,a)=>{let o=r.map((d,c)=>d!=null&&d.length>0?d.at(-1):a.prevData[c]);i.emit(e(o,a))},{describeKind:"derived",...t})}function De(n,e,t){let s=new Map;return n.forEach((r,i)=>{s.set(r,i)}),rt(n,(r,i)=>e(o=>{let d=s.get(o);if(d==null)throw new Error(`dynamicNode: untracked dep "${o.name??"<unnamed>"}"`);return r[d]},i),t)}var Q=new WeakMap,ee=new WeakMap;function Z(n,e){let t=e.get(n);if(t)for(let s of t)s()}function ye(n,e={}){let t=0;return{...e,get:()=>Ie(n),subscribe:r=>{t===0&&Z(n,Q),t++;let i=n.subscribe(a=>{for(let[o,d]of a)o===g&&r(d)});return()=>{i(),t--,t===0&&Z(n,ee)}},listen:r=>{t===0&&Z(n,Q),t++;let i=!0,a=n.subscribe(o=>{for(let[d,c]of o)if(d===g){if(i){i=!1;continue}r(c)}});return()=>{a(),t--,t===0&&Z(n,ee)}},_node:n}}function Fe(n){let e=n.cache,t;if(n.subscribe(r=>{for(let[i,a]of r)i===g&&(e=a),i===f&&(t=a)})(),t)throw t;return e}function Ie(n){return n.status==="sentinel"?Fe(n):n.cache}function ot(n){let e=_e(n,{resubscribable:!0,resetOnTeardown:!0});return ye(e,{set:t=>e.emit(t)})}function it(n,e){let t=Array.isArray(n)?n:[n],s=t.map(i=>i._node),r=De(s,i=>{let a=t.map(o=>{let d=o._node;return d.status==="sentinel"&&Fe(d),i(d)});return e(...a)},{resubscribable:!0,resetOnTeardown:!0,equals:Object.is});return ye(r)}function at(n){let e=_e(n,{resubscribable:!0,resetOnTeardown:!0,equals:()=>!1});return ye(e,{set:t=>e.emit(t),setKey:(t,s)=>{let r=Ie(e);e.emit({...r,[t]:s})}})}function dt(n){return n.get()}function Ge(n,e){let t=n._node,s=Q.get(t);s||(s=new Set,Q.set(t,s)),s.add(e)}function He(n,e){let t=n._node,s=ee.get(t);s||(s=new Set,ee.set(t,s)),s.add(e)}function ct(n,e){Ge(n,()=>{let t=e();typeof t=="function"&&He(n,t)})}function lt(n,e,t){return(...s)=>{let r;return Te(()=>{r=t(...s)}),r}}0&&(module.exports={action,atom,computed,getValue,map,onMount,onStart,onStop});
1
+ "use strict";var re=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Be=Object.prototype.hasOwnProperty;var We=(n,e)=>{for(var t in e)re(n,t,{get:e[t],enumerable:!0})},je=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ue(e))!Be.call(n,r)&&r!==t&&re(n,r,{get:()=>e[r],enumerable:!(s=Pe(e,r))||s.enumerable});return n};var ze=n=>je(re({},"__esModule",{value:!0}),n);var ut={};We(ut,{action:()=>lt,atom:()=>ot,computed:()=>it,getValue:()=>dt,map:()=>at,onMount:()=>ct,onStart:()=>Ge,onStop:()=>He});module.exports=ze(ut);var O=0,P=!1,A=[],k=[],D=[],U=[];function me(){return O>0||P}function be(){return O>0}function ve(n){O>0?U.push(n):n()}function Te(n){O+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(O-=1,O===0)if(e){if(!P){let t=U.splice(0);for(let s of t)try{s()}catch{}A.length=0,k.length=0,D.length=0}}else $e()}}function $e(){let n=!P;n&&(P=!0);let e=[],t=0;try{for(;A.length>0||k.length>0||D.length>0||n&&U.length>0;){if(n&&U.length>0){let i=U.splice(0);for(let a of i)try{a()}catch(o){e.push(o)}continue}if(t+=1,t>1e3)throw A.length=0,k.length=0,D.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let r=(A.length>0?A:k.length>0?k:D).splice(0);for(let i of r)try{i()}catch(a){e.push(a)}}}finally{n&&(P=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function q(n,e,t){if(e.length===0)return;if(e.length===1){let c=t(e[0][0]);if(c<3||!me()){n(e);return}(c>=5?D:c===4?k:A).push(()=>n(e));return}let s=e.length,r=s,i=s,a=s,o=0;for(;o<s&&t(e[o][0])<3;)o++;for(r=o;o<s&&t(e[o][0])===3;)o++;for(i=o;o<s&&t(e[o][0])===4;)o++;a=o;let d=me();if(r>0){let c=e.slice(0,r);n(c)}if(i>r){let c=e.slice(r,i);d?A.push(()=>n(c)):n(c)}if(a>i){let c=e.slice(i,a);d?k.push(()=>n(c)):n(c)}if(s>a){let c=e.slice(a,s);d?D.push(()=>n(c)):n(c)}}var B=Symbol.for("graphrefly/START"),g=Symbol.for("graphrefly/DATA"),M=Symbol.for("graphrefly/DIRTY"),E=Symbol.for("graphrefly/RESOLVED"),S=Symbol.for("graphrefly/INVALIDATE"),C=Symbol.for("graphrefly/PAUSE"),W=Symbol.for("graphrefly/RESUME"),w=Symbol.for("graphrefly/TEARDOWN"),R=Symbol.for("graphrefly/COMPLETE"),f=Symbol.for("graphrefly/ERROR"),F=Object.freeze([M]),oe=Object.freeze([E]),qe=Object.freeze([S]),ie=Object.freeze([B]),Ke=Object.freeze([R]),Ye=Object.freeze([w]),ae=Object.freeze([F]),xe=Object.freeze([oe]),we=Object.freeze([qe]),Ne=Object.freeze([Ke]),de=Object.freeze([Ye]);var Je={name:"json",version:1,contentType:"application/json",encode(n){let e=JSON.stringify(n);return new TextEncoder().encode(e)},decode(n,e){let t=new TextDecoder().decode(n);return JSON.parse(t)}};function Ae(n){n.registerCodec(Je)}var Xe={type:"system",id:""};function K(n){if(n==null)return Xe;let{type:e,id:t,...s}=n;return{type:e??"system",id:t??"",...s}}function ke(){return Date.now()*1e6}var Y=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let s=this._messageTypes.get(t);return s!=null?s.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}};function Me(n){n.registerMessageType(B,{tier:0,wireCrossing:!1}),n.registerMessageType(M,{tier:1,wireCrossing:!1}),n.registerMessageType(S,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(C,{tier:2,wireCrossing:!1}),n.registerMessageType(W,{tier:2,wireCrossing:!1}),n.registerMessageType(g,{tier:3,wireCrossing:!0}),n.registerMessageType(E,{tier:3,wireCrossing:!0}),n.registerMessageType(R,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(f,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(w,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var I=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};function ce(n){if(n===void 0)return null;if(typeof n=="number"){if(!Number.isFinite(n))throw new TypeError(`Cannot hash non-finite number: ${n}`);if(Number.isInteger(n)&&!Number.isSafeInteger(n))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${n}. Cross-language cid parity is not guaranteed for unsafe integers.`);return n}if(typeof n=="string"||typeof n=="boolean"||n===null)return n;if(Array.isArray(n))return n.map(ce);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=ce(n[t]);return e}return null}var Ze=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Qe=new TextEncoder;function et(n){let e=Qe.encode(n),t=e.length,s=t*8,r=t+9+63&-64,i=new Uint8Array(r);i.set(e),i[t]=128;let a=new DataView(i.buffer);a.setUint32(r-4,s>>>0,!1),a.setUint32(r-8,Math.floor(s/4294967296)>>>0,!1);let o=1779033703,d=3144134277,c=1013904242,l=2773480762,h=1359893119,p=2600822924,_=528734635,b=1541459225,N=new Uint32Array(64),m=(T,y)=>T>>>y|T<<32-y;for(let T=0;T<r;T+=64){for(let u=0;u<16;u++)N[u]=a.getUint32(T+u*4,!1);for(let u=16;u<64;u++){let L=N[u-15],V=N[u-2],$=m(L,7)^m(L,18)^L>>>3,se=m(V,17)^m(V,19)^V>>>10;N[u]=N[u-16]+$+N[u-7]+se>>>0}let y=o,G=d,H=c,te=l,x=h,j=p,z=_,ne=b;for(let u=0;u<64;u++){let L=m(x,6)^m(x,11)^m(x,25),V=x&j^~x&z,$=ne+L+V+Ze[u]+N[u]>>>0,se=m(y,2)^m(y,13)^m(y,22),Le=y&G^y&H^G&H,Ve=se+Le>>>0;ne=z,z=j,j=x,x=te+$>>>0,te=H,H=G,G=y,y=$+Ve>>>0}o=o+y>>>0,d=d+G>>>0,c=c+H>>>0,l=l+te>>>0,h=h+x>>>0,p=p+j>>>0,_=_+z>>>0,b=b+ne>>>0}let v=T=>T.toString(16).padStart(8,"0");return v(o)+v(d)+v(c)+v(l)+v(h)+v(p)+v(_)+v(b)}function le(n){let e=ce(n??null),t=JSON.stringify(e);return et(t).slice(0,16)}function tt(){let n=globalThis.crypto;if(n?.randomUUID)return n.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function ue(n,e,t){let s=t?.id??tt();if(n===0)return{id:s,version:0};let i=(t?.hash??le)(e);return{id:s,version:0,cid:i,prev:null}}function Ee(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}var Se=()=>{},Ce=100;function Re(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function fe(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function J(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}var nt=(n,e,t,s)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},st=(n,e,t,s)=>{let r=n;if(r._status==="completed"||r._status==="errored")return;let i=r._cached,a=i===void 0?[ie]:[ie,[g,i]];r._status==="dirty"&&a.push(F),q(e,a,r._config.tierOf)},pe=new Y({onMessage:nt,onSubscribe:st});Me(pe);Ae(pe);var X=class n{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,s){this._config=s.config??pe,this._config.onMessage,this._optsName=s.name,this._describeKind=s.describeKind,this._equals=s.equals??Object.is,this._resubscribable=s.resubscribable??!1,this._resetOnTeardown=s.resetOnTeardown??!1,this._autoComplete=s.completeWhenDepsComplete??!0,this._autoError=s.errorWhenDepsError??!0,this._pausable=s.pausable??!0,this._guard=s.guard,this._fn=t,this._partial=s.partial??!1,this._cached=s.initial!==void 0?s.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=s.versioningHash??this._config.defaultHashFn??le;let r=s.versioning??this._config.defaultVersioning;this._versioningLevel=r,this._versioning=r!=null?ue(r,this._cached===void 0?void 0:this._cached,{id:s.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Re);let i={};for(let[o,d]of Object.entries(s.meta??{})){let c={initial:d,name:`${s.name??"node"}:meta:${o}`,describeKind:"state",config:this._config};s.guard!=null&&(c.guard=s.guard),i[o]=new n([],void 0,c)}Object.freeze(i),this.meta=i,this._hasMeta=Object.keys(i).length>0;let a=this;this._actions={emit(o){a._emit([[g,o]])},down(o){a._emit(J(o))},up(o){a._emitUp(J(o))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let s=this._versioningLevel;if(s!=null&&e<=s)return;let r=t?.hash??this._hashFn;r!==this._hashFn&&(this._hashFn=r);let i=this._cached===void 0?void 0:this._cached,a=this._versioning,o=a?.id??t?.id,d=a?.version??0,c=ue(e,i,{id:o,hash:r});c.version=d,this._versioning=c,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=K(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let s of this._extraGuards)if(!s(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,s=e?.actor!=null;if(!t&&!s)return;let r=K(e?.actor),i=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(r,i))throw new I({actor:r,action:i,nodeName:this.name});if(this._extraGuards!=null){for(let a of this._extraGuards)if(!a(r,i))throw new I({actor:r,action:i,nodeName:this.name})}this._lastMutation={actor:r,timestamp_ns:ke()}}down(e,t){let s=J(e);s.length!==0&&(this._checkGuard(t),this._emit(s))}emit(e,t){this._checkGuard(t),this._emit([[g,e]])}up(e,t){if(this._deps.length===0)return;let s=J(e);if(s.length===0)return;this._checkGuard(t);let r=t??{internal:!0};this._validateUpTiers(s);for(let i of this._deps)i.node.up?.(s,r)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let s of e){let r=t(s[0]);if(r===3||r===4)throw new Error(`Node "${this.name}": tier-${r} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let d=K(t);if(!this._guard(d,"observe"))throw new I({actor:d,action:"observe",nodeName:this.name})}let r=this._isTerminal&&this._resubscribable;if(r){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)fe(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let i;try{i=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:r},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let a=this._isTerminal;if(this._sinkCount===1&&!a)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof i=="function")try{i()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let o=!1;return()=>{o||(o=!0,this._sinkCount-=1,this._removeSink(e),typeof i=="function"&&i(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let s=0;s<e;s++){let r=s,i=this._deps[s];i.unsub=Se,i.unsub=i.node.subscribe(a=>{if(i.unsub===null)return;let o=this._config.tierOf,d=!1;for(let c of a)o(c[0])>=3&&(d=!0),this._config.onMessage(this,c,{direction:"down-in",depIndex:r},this._actions);d&&this._maybeRunFnOnSettlement()}),t++}}catch(s){this._deps[t].unsub=null;for(let r=0;r<t;r++){let i=this._deps[r];if(i.unsub!=null){let a=i.unsub;i.unsub=null;try{a()}catch{}fe(i)}}throw this._dirtyDepCount=0,s}}_addDep(e){for(let r=0;r<this._deps.length;r++)if(this._deps[r].node===e)return r;let t=this._deps.length,s=Re(e);if(this._deps.push(s),this._sinks==null)return t;s.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ae),s.unsub=Se;try{s.unsub=e.subscribe(r=>{if(s.unsub===null)return;let i=this._config.tierOf,a=!1;for(let o of r)i(o[0])>=3&&(a=!0),this._config.onMessage(this,o,{direction:"down-in",depIndex:t},this._actions);a&&this._maybeRunFnOnSettlement()})}catch(r){throw s.unsub=null,this._deps.pop(),this._dirtyDepCount--,r}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(s){this._emit([[f,this._wrapFnError("cleanup threw",s)]])}else if(t!=null&&typeof t=="object"){let s=t.deactivate;if(typeof s=="function")try{s()}catch(r){this._emit([[f,this._wrapFnError("cleanup.deactivate threw",r)]])}}for(let s of this._deps){if(s.unsub!=null){let r=s.unsub;s.unsub=null;try{r()}catch{}}fe(s)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let s=this._deps[e],r=t[0];if(this._inspectorHooks!=null){let i={kind:"dep_message",depIndex:e,message:t};for(let a of this._inspectorHooks)a(i)}if(r!==B){if(r===M){this._depDirtied(s);return}if(r===S){if(this._depInvalidated(s),this._cached===void 0)return;this._emit(we);return}if(r===C||r===W){this._emit([t]);return}if(r===w){this._emit(de);return}if(r===g)this._depSettledAsData(s,t[1]);else if(r===E)this._depSettledAsResolved(s);else if(r===R)this._depSettledAsTerminal(s,!0);else if(r===f)this._depSettledAsTerminal(s,t[1]);else{this._emit([t]);return}if(!this._fn){(r===g||r===E)&&this._emit([t]),(r===R||r===f)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ae))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let t=this._deps[e];if(t.dataBatch.length===0&&t.prevData===void 0&&t.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(xe),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[f,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(Ne)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(a){this._emit([[f,this._wrapFnError("cleanup threw",a)]]);return}}else if(e!=null&&typeof e=="object"){let a=e.beforeRun;if(typeof a=="function"){e.beforeRun=void 0;try{a()}catch(o){this._emit([[f,this._wrapFnError("cleanup.beforeRun threw",o)]]);return}}}let t=this._deps.map(a=>a.involvedThisWave?a.dataBatch.length>0?[...a.dataBatch]:[]:void 0),s=this._deps.map(a=>a.prevData);for(let a=0;a<this._deps.length;a++){let o=t[a];o!=null&&o.length>0&&(this._deps[a].prevData=o[o.length-1])}let r=this._deps.map(a=>a.terminal),i={prevData:s,terminalDeps:r,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let a={kind:"run",batchData:t,prevData:s};for(let o of this._inspectorHooks)o(a)}this._isExecutingFn=!0;try{let a=this._fn(t,this._actions,i);if(typeof a=="function")this._cleanup=a;else if(a!=null&&typeof a=="object"){let o=a;(typeof o.beforeRun=="function"||typeof o.deactivate=="function"||typeof o.invalidate=="function")&&(this._cleanup=a)}}catch(a){this._emit([[f,this._wrapFnError("fn threw",a)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Ce?(this._rerunDepth=0,this._emit([[f,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Ce} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let s=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${s}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[F,e[0]]:e;let s=!0,r=!1,i=!1,a=-1;for(let d of e){let c=t(d[0]);c<a&&(s=!1),c===3&&(r=!0),d[0]===M&&(i=!0),a=c}let o=e;if(!s){let d=e.map((c,l)=>({m:c,i:l,tier:t(c[0])}));d.sort((c,l)=>c.tier-l.tier||c.i-l.i),o=d.map(c=>c.m)}if(r&&!i&&this._status!=="dirty"){let d=0;for(;d<o.length&&t(o[d][0])===0;)d++;return d===0?[F,...o]:[...o.slice(0,d),F,...o.slice(d)]}return o}_emit(e){if(e.length===0)return;for(let o=0;o<e.length;o++){let d=e[o];if(d[0]===f&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let o=e.filter(d=>d[0]===w||d[0]===S);if(o.length===0)return;t=o}t=this._frameBatch(t);let r=null;for(let o=0;o<t.length;o++){let d=t[o],c=d[0];if(c!==C&&c!==W){r?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${c===C?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let l=!0;if(this._pausable!==!1){let h=d[1];if(c===C)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(h),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(h))l=!1;else if(this._pauseLocks.delete(h),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}l?r?.push(d):r==null&&(r=t.slice(0,o))}if(r!=null){if(r.length===0)return;t=r}if(this._hasMeta&&t.some(o=>o[0]===w))for(let o of Object.keys(this.meta))try{this.meta[o]._emit(de)}catch{}let{finalMessages:i,equalsError:a}=this._updateState(t);if(i.length>0&&this._config.inspectorEnabled){let o=this._config.globalInspector;if(o!=null)try{o({kind:"emit",node:this,messages:i})}catch{}}if(i.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let o=this._config.tierOf,d=[];for(let c of i)o(c[0])===3?this._pauseBuffer.push(c):d.push(c);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(i);a!=null&&this._emit([[f,a]])}_updateState(e){let t=this._config.tierOf,s,r,i=-1,a=0;for(let l of e)t(l[0])===3&&a++;let o=a<=1,d=-1;if(this._versioning!=null&&a>1){for(let l=e.length-1;l>=0;l--)if(e[l][0]===g){d=l;break}}for(let l=0;l<e.length;l++){let h=e[l],p=h[0];if(p===g){if(h.length>=2){let _=!1;if(o&&this._cached!==void 0)try{_=this._equals(this._cached,h[1])}catch(b){r=this._wrapFnError("equals threw",b),i=l;break}if(_){s==null&&(s=e.slice(0,l)),s.push(oe),this._status="resolved";continue}this._cached=h[1],this._versioning!=null&&(d<0||l===d)&&Ee(this._versioning,h[1],this._hashFn)}this._status="settled",s?.push(h)}else if(s?.push(h),p===M)this._status="dirty";else if(p===E)this._status="resolved";else if(p===R)this._status="completed";else if(p===f)this._status="errored";else if(p===S){this._cached=void 0,this._status="dirty";let _=this._cleanup;if(typeof _=="function"){this._cleanup=void 0;try{_()}catch{}}else if(_!=null&&typeof _=="object"){let b=_.invalidate;if(typeof b=="function")try{b()}catch{}}}else p===w&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let c=i>=0?s??e.slice(0,i):s??e;return r!=null?{finalMessages:c,equalsError:r}:{finalMessages:c}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let s of t)s(e)};_dispatchOrAccumulate(e){if(be()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ve(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}q(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);q(this._deliverToSinks,t,this._config.tierOf)}},Oe=n=>Array.isArray(n),he=n=>typeof n=="object"&&n!=null&&!Array.isArray(n);function ge(n,e,t){let s=Oe(n)?n:[],r=typeof n=="function"?n:typeof e=="function"?e:void 0,i={};return Oe(n)?i=(he(e)?e:t)??{}:he(n)?i=n:i=(he(e)?e:t)??{},new X(s,r,i)}function _e(n,e){return ge([],{...e,initial:n})}function rt(n,e,t){return ge(n,(r,i,a)=>{let o=r.map((d,c)=>d!=null&&d.length>0?d.at(-1):a.prevData[c]);i.emit(e(o,a))},{describeKind:"derived",...t})}function De(n,e,t){let s=new Map;return n.forEach((r,i)=>{s.set(r,i)}),rt(n,(r,i)=>e(o=>{let d=s.get(o);if(d==null)throw new Error(`dynamicNode: untracked dep "${o.name??"<unnamed>"}"`);return r[d]},i),t)}var Q=new WeakMap,ee=new WeakMap;function Z(n,e){let t=e.get(n);if(t)for(let s of t)s()}function ye(n,e={}){let t=0;return{...e,get:()=>Ie(n),subscribe:r=>{t===0&&Z(n,Q),t++;let i=n.subscribe(a=>{for(let[o,d]of a)o===g&&r(d)});return()=>{i(),t--,t===0&&Z(n,ee)}},listen:r=>{t===0&&Z(n,Q),t++;let i=!0,a=n.subscribe(o=>{for(let[d,c]of o)if(d===g){if(i){i=!1;continue}r(c)}});return()=>{a(),t--,t===0&&Z(n,ee)}},_node:n}}function Fe(n){let e=n.cache,t;if(n.subscribe(r=>{for(let[i,a]of r)i===g&&(e=a),i===f&&(t=a)})(),t)throw t;return e}function Ie(n){return n.status==="sentinel"?Fe(n):n.cache}function ot(n){let e=_e(n,{resubscribable:!0,resetOnTeardown:!0});return ye(e,{set:t=>e.emit(t)})}function it(n,e){let t=Array.isArray(n)?n:[n],s=t.map(i=>i._node),r=De(s,i=>{let a=t.map(o=>{let d=o._node;return d.status==="sentinel"&&Fe(d),i(d)});return e(...a)},{resubscribable:!0,resetOnTeardown:!0,equals:Object.is});return ye(r)}function at(n){let e=_e(n,{resubscribable:!0,resetOnTeardown:!0,equals:()=>!1});return ye(e,{set:t=>e.emit(t),setKey:(t,s)=>{let r=Ie(e);e.emit({...r,[t]:s})}})}function dt(n){return n.get()}function Ge(n,e){let t=n._node,s=Q.get(t);s||(s=new Set,Q.set(t,s)),s.add(e)}function He(n,e){let t=n._node,s=ee.get(t);s||(s=new Set,ee.set(t,s)),s.add(e)}function ct(n,e){Ge(n,()=>{let t=e();typeof t=="function"&&He(n,t)})}function lt(n,e,t){return(...s)=>{let r;return Te(()=>{r=t(...s)}),r}}0&&(module.exports={action,atom,computed,getValue,map,onMount,onStart,onStop});
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h}from"../../chunk-BZP5T4X6.js";import"../../chunk-W4TSQ6RJ.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{h as action,a as atom,b as computed,d as getValue,c as map,g as onMount,e as onStart,f as onStop};
1
+ import{a,b,c,d,e,f,g,h}from"../../chunk-W6FQIFVE.js";import"../../chunk-7AJKUA36.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{h as action,a as atom,b as computed,d as getValue,c as map,g as onMount,e as onStart,f as onStop};