import{a as f,b as p}from"./vendor-query-B2UbickB.js";import{c as e,N as a}from"./index-_BRA9uFL.js";function w(s){const t=[],o=s.type.split(".");switch(o[0]==="system"?o[1]:o[0]){case"task":t.push(["tasks"]),t.push(["jobs"]),t.push(["processes"]),s.workflowId&&(t.push(["workflowExecution",s.workflowId]),t.push(["workflowState",s.workflowId]),t.push(["mcpQueryExecution",s.workflowId])),s.originId&&t.push(["processes",s.originId]);break;case"escalation":t.push(["escalations"]),t.push(["escalationStats"]),s.workflowId&&t.push(["workflowExecution",s.workflowId]);break;case"workflow":t.push(["jobs"]),t.push(["tasks"]),t.push(["processes"]),s.workflowId&&(t.push(["workflowExecution",s.workflowId]),t.push(["workflowState",s.workflowId]),t.push(["mcpQueryExecution",s.workflowId]),t.push(["mcpQueryResult",s.workflowId]),t.push(["builderResult",s.workflowId]));break;case"activity":s.workflowId&&t.push(["mcpRunExecution",s.workflowId]),t.push(["mcpRuns"]);break;case"milestone":s.workflowId&&(t.push(["workflowExecution",s.workflowId]),t.push(["mcpQueryExecution",s.workflowId])),t.push(["tasks"]);break;case"knowledge":t.push(["knowledge"]);break;case"file":t.push(["files"]);break;case"agent":t.push(["agents"]);break;default:t.push(["jobs"]),t.push(["tasks"]);break}return t}function n(s=500){const t=p(),o=f.useRef(new Set),c=f.useRef(null);return f.useCallback(i=>{for(const r of i)o.current.add(JSON.stringify(r));c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{for(const r of o.current)t.invalidateQueries({queryKey:JSON.parse(r)});o.current.clear(),c.current=null},s)},[t,s])}function y(){const s=n(300);e(`${a}.system.task.>`,()=>{s([["jobs"]])}),e(`${a}.system.workflow.>`,()=>{s([["jobs"]])})}function h(s){const t=n(400);e(`${a}.>`,o=>{var l;if(!s||!(o.workflowId===s||((l=o.workflowId)==null?void 0:l.includes(s))))return;const i=o.type.split("."),r=i[0]==="system"?i[1]:i[0],u=w(o);r==="escalation"&&u.push(["escalations","by-workflow",s]),t(u)})}function m(s){const t=n(400);e(`${a}.>`,o=>{var l;if(!s||!(o.workflowId===s||((l=o.workflowId)==null?void 0:l.includes(s))))return;const i=o.type.split("."),r=i[0]==="system"?i[1]:i[0],u=w(o);r==="escalation"&&u.push(["escalations","by-workflow",s]),t(u)})}function E(s){const t=n(400);e(`${a}.>`,o=>{var r;if(!s||!(o.workflowId===s||((r=o.workflowId)==null?void 0:r.includes(s))))return;const i=w(o);i.push(["workflowSets"]),i.push(["yamlWorkflows"]),t(i)})}function b(s){const t=n(300),o=f.useCallback(c=>{s&&(c.originId!==s&&c.workflowId!==s||t([["processes",s]]))},[s,t]);e(`${a}.system.task.>`,o),e(`${a}.system.workflow.>`,o),e(`${a}.system.escalation.>`,o)}function I(){const s=n(300);e(`${a}.system.escalation.>`,()=>{s([["escalationStats"]])})}function g(){const s=n(300);e(`${a}.system.escalation.>`,()=>{s([["escalations"]])})}function $(s){const t=n(300);e(`${a}.system.escalation.>`,o=>{s&&o.escalationId===s&&t([["escalations",s],["escalations"],["escalationStats"]])})}function R(){const s=n(300);e(`${a}.system.agent.>`,()=>{s([["agents"]])})}function S(){const s=n(300);e(`${a}.system.task.>`,()=>{s([["processes"]])}),e(`${a}.system.workflow.>`,()=>{s([["processes"]])})}export{b as a,y as b,m as c,E as d,I as e,g as f,$ as g,h,R as i,S as u};
//# sourceMappingURL=useEventHooks-XNNzwADV.js.map
