import{n as e}from"./rolldown-runtime-Czos8NxU.js";import{At as t,Dt as n,Et as r,Rt as i,Tl as a,Xs as o,_l as s,_t as c,bt as l,cl as u,kt as d,nc as f,yt as p,zt as m}from"./app-initial~app-main~worktree-init-v2-page~appgen-settings-page~page~appgen-publication-ter~fzo5ij6p-BKVLyD1q.js";function h(e,t,n,r=Date.now()){let i=e.items.find(e=>e.id===t);if(i==null||i.readAt!=null===n)return e;let a=e.unreadRunCounts;if(i.automationId!=null&&i.threadId!=null&&(i.status===`PENDING_REVIEW`||i.status===`ACCEPTED`)){let e=n?a.unreadRuns.filter(e=>e.threadId!==i.threadId):[...a.unreadRuns.filter(e=>e.threadId!==i.threadId),{automationId:i.automationId,threadId:i.threadId}];a={total:e.length,automationIds:[...new Set(e.map(e=>e.automationId))],unreadRuns:e}}return{...e,items:e.items.map(e=>e===i?{...e,readAt:n?r:null}:e),unreadRunCounts:a}}function g(){let e=(0,_.c)(15),n=s(),r=f(v),i;e[0]===n?i=e[1]:(i=e=>{n.setQueryData(c(`inbox-items`,{limit:200}),t=>t==null?t:h(t,e,!0)),t.dispatchMessage(`inbox-item-set-read-state`,{id:e,isRead:!0})},e[0]=n,e[1]=i);let a=i,o;e[2]===n?o=e[3]:(o=e=>{n.setQueryData(c(`inbox-items`,{limit:200}),t=>t==null?t:h(t,e,!1)),t.dispatchMessage(`inbox-item-set-read-state`,{id:e,isRead:!1})},e[2]=n,e[3]=o);let l=o,u;e[4]===n?u=e[5]:(u=()=>{let e=Date.now();n.setQueryData(c(`inbox-items`,{limit:200}),t=>t==null?t:{...t,items:t.items.map(t=>t.readAt==null&&(t.status===`PENDING_REVIEW`||t.status===`ACCEPTED`||t.status===`ARCHIVED`)?{...t,readAt:e}:t),unreadRunCounts:{total:0,automationIds:[],unreadRuns:[]}}),t.dispatchMessage(`inbox-automation-runs-mark-all-read`,{readAt:e})},e[4]=n,e[5]=u);let d=u,p;e[6]===r.data?.items?p=e[7]:(p=r.data?.items??[],e[6]=r.data?.items,e[7]=p);let m=r.data?.unreadRunCounts,g;return e[8]!==r.isLoading||e[9]!==d||e[10]!==a||e[11]!==l||e[12]!==p||e[13]!==m?(g={items:p,isLoading:r.isLoading,markAllRead:d,markRead:a,markUnread:l,unreadRunCounts:m},e[8]=r.isLoading,e[9]=d,e[10]=a,e[11]=l,e[12]=p,e[13]=m,e[14]=g):g=e[14],g}var _,v,y=e((()=>{_=a(),u(),o(),d(),m(),n(),l(),v=p(i,`inbox-items`,{enabled:!0,params:{limit:200},refetchInterval:r.ONE_MINUTE,staleTime:r.ONE_MINUTE})}));export{g as n,y as t};
//# sourceMappingURL=app-initial~app-main~remote-conversation-page~hotkey-window-thread-page~automations-page~th~bnlvjk3w-yFl809sL.js.map