import{r as o}from"./markdown-9_JKOUHQ.js";import{a as u,b as d,u as i}from"./use-ws-BIe6kKa2.js";let c=null,l=0,S=-1;i.subscribe(()=>{l++,c=null});d.subscribe(()=>{l++,c=null});u.subscribe(()=>{l++,c=null});function f(){return c!==null&&S===l||(c={...i.getState(),...d.getState(),...u.getState()},S=l),c}function p(e){const t=i.subscribe(e),a=d.subscribe(e),r=u.subscribe(e);return()=>{t(),a(),r()}}function j(e){const t=o.useRef(null),a=o.useRef(e);a.current=e;const r=o.useCallback(()=>{const s=a.current(f());return t.current!==null&&Object.is(t.current.value,s)?t.current.value:(t.current={value:s},s)},[]);return o.useSyncExternalStore(p,r,r)}j.getState=f;j.setState=e=>{const t=["projects","expandedProjects","selectedProjectId","initialized","loadProjects","toggleProject","selectProject","deleteProject","reorderProjects","renameProject"],a=["threadsByProject","selectedThreadId","activeThread","loadThreadsForProject","selectThread","archiveThread","pinThread","deleteThread","appendOptimisticMessage","refreshActiveThread","refreshAllLoadedThreads","clearProjectThreads","handleWSInit","handleWSMessage","handleWSToolCall","handleWSToolOutput","handleWSStatus","handleWSResult","handleWSQueueUpdate"],r={},s={},h={};for(const[n,b]of Object.entries(e))t.includes(n)?r[n]=b:a.includes(n)?s[n]=b:h[n]=b;Object.keys(r).length>0&&i.setState(r),Object.keys(s).length>0&&d.setState(s),Object.keys(h).length>0&&u.setState(h)};export{j as u};
