1import{t as e}from"./TokenManager-lM18Chto.js";import{t}from"./fetch-DFmLSIPj.js";import{t as n}from"./BaseDirectories-BBUCRxER.js";var r=class extends Error{},i=3e3,a=(n,a,o,s)=>{let c=new AbortController,l=!1,u;return(async()=>{for(;!l&&!c.signal.aborted;){let d=await e.getAccessToken();if(!d){s?.(Error(`No auth token for chat stream`));return}try{await t(n,{signal:c.signal,openWhenHidden:!0,headers:{Authorization:`Bearer ${d}`,Accept:`text/event-stream`,...u?{"Last-Event-ID":u}:{}},onopen:async e=>{let t=e.headers.get(`content-type`)??``;if(e.ok&&t.includes(`text/event-stream`)){o?.();return}throw e.status===401||e.status===403?new r(`Chat stream auth failed (${e.status})`):Error(`Chat stream unexpected status ${e.status}`)},onmessage:e=>{if(e.id&&(u=e.id),e.data)try{a(JSON.parse(e.data))}catch{}},onerror:e=>{throw e}})}catch(e){if(e instanceof r){s?.(e);return}if(l||c.signal.aborted)return}if(l||c.signal.aborted)return;await new Promise(e=>setTimeout(e,i))}})(),()=>{l=!0,c.abort()}},o=(e,t)=>a(`${n.AUTH_API_URL}/chat/conversations/${e}/stream`,e=>{e.type===`message`?t.onMessage(e.payload):e.type===`read`&&t.onRead?.(e.payload)},t.onConnected,t.onFatal),s=e=>a(`${n.AUTH_API_URL}/chat/notifications/stream`,t=>{t.type===`new_message`&&e.onNotification(t.payload)},e.onConnected,e.onFatal);export{s as n,o as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.