(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,599246,e=>{"use strict";var t=e.i(753930);e.i(785563);var r=e.i(94349),o=e.i(499023),a=e.i(129519);async function n(e,t,o,n){try{let s=await (0,r.fetchWorkflowSnapshot)(e.id,{cache:"no-store"});if(o.current!==n)return;let i=s.steps.map(e=>({id:e.id,title:e.name,color:e.color??"bg-neutral-400",position:e.position,events:e.events,allow_manual_move:e.allow_manual_move,prompt:e.prompt,is_start_step:e.is_start_step,agent_profile_id:e.agent_profile_id})),l=new Set(i.map(e=>e.id)),u=t.getState().kanbanMulti.snapshots[e.id],p=new Map((u?.tasks??[]).map(e=>[e.id,e])),c=s.tasks.filter(e=>!e.is_ephemeral).map(e=>{var t,r;let o=(t=e,r=l,t.workflow_step_id&&r.has(t.workflow_step_id)?(0,a.toKanbanTask)(t):null);if(!o)return null;let n=p.get(o.id);return n&&(o.primarySessionId=o.primarySessionId||n.primarySessionId,o.primarySessionState=o.primarySessionState||n.primarySessionState),o}).filter(e=>null!==e);t.getState().setWorkflowSnapshot(e.id,{workflowId:e.id,workflowName:e.name,steps:i,tasks:c})}catch(t){console.error(`[useAllWorkflowSnapshots] Failed to fetch snapshot for workflow "${e.name}" (${e.id}):`,t)}}function s(e){let r=(0,o.useAppStoreApi)(),a=(0,o.useAppStore)(e=>e.connection.status),s=(0,o.useAppStore)(e=>e.workflows.items),i=(0,t.useRef)(""),l=(0,t.useRef)(null),u=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(l.current!==e&&(null!==l.current&&(r.getState().clearKanbanMulti(),i.current="",u.current+=1),l.current=e),!e)return;let t=s.filter(t=>t.workspaceId===e);if(0===t.length)return;let o=t.map(e=>e.id).sort().join(",")+":"+a;if(i.current===o)return;i.current=o;let p=u.current;r.getState().setKanbanMultiLoading(!0),Promise.all(t.map(e=>n(e,r,u,p))).finally(()=>{u.current===p&&r.getState().setKanbanMultiLoading(!1)})},[e,s,a,r])}e.s(["useAllWorkflowSnapshots",()=>s])}]);