import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{m as t}from"./vendor-dnd-C1cICjTT.js";import{o as n}from"./serverStorage-7ZBX37kd.js";import{K as r,Q as i,X as a,Z as o,q as s}from"./sidebarHelpers-grqz25LR.js";var c=e(t(),1),l=`mc-session-blue-dot-ack-v1`,u=`mc-session-processing-seen-v1`,d=/^tab-(?:float|dormant)-restored-\d+-\d+$/;function f(e){return d.test(e)}function p(e){let t=null;for(let n of Object.keys(e))f(n)&&(t||={...e},delete t[n]);return t??e}function m(e,t){let n=p(e),a=n!==e;for(let e of t){if(!e||!o(e))continue;let t=r(e);if(!t)continue;let s=i(e);n[t]!==s&&(a||(n={...n}),a=!0,n[t]=s)}return a?n:e}function h(){let[e,t,i]=n(l,{}),[o,d,f]=n(u,{});(0,c.useEffect)(()=>{i&&t(e=>p(e)),f&&d(e=>p(e))},[i,f,t,d]);let h=(0,c.useCallback)(e=>{if(!e)return null;let t=s(e);if(t)return t;let n=r(e);return(e.task_status??e.taskStatus??null)===`done`&&n&&o[n]?`done`:null},[o]),g=(0,c.useCallback)(t=>{if(!t)return!1;let n=h(t),i=r(t),o=a(t,n);return!!i&&!!o&&e[i]===o},[e,h]);return{acknowledge:(0,c.useCallback)(e=>{if(!e)return;let n=h(e),i=r(e),o=a(e,n);if(!(!i||!o)&&(t(e=>e[i]===o?e:{...e,[i]:o}),e.runtimeLifecycle?.unreadCompletion)){let t=e.runtimeLifecycle.sessionId;fetch(`/api/sessions/${encodeURIComponent(t)}/lifecycle/ack`,{method:`POST`}).catch(()=>void 0)}},[h,t]),attentionKind:h,isAcknowledged:g,markProcessingSeen:(0,c.useCallback)(e=>{d(t=>m(t,[e]))},[d]),markProcessingSeenBatch:(0,c.useCallback)(e=>{d(t=>m(t,e))},[d])}}export{h as t};