import{r as n}from"./index-CqIc3cxq.js";const d=n.createContext(new Map);d.Provider;function m(r,{event:o="message",init:u,enabled:c=!0}={}){let t=n.useContext(d),[i,a]=n.useState(null);return n.useEffect(()=>{if(!c)return;let s=[r.toString(),u?.withCredentials].join("::"),e=t.get(s)??{count:0,source:new EventSource(r,u)};++e.count,t.set(s,e),e.source.addEventListener(o,l),a(null);function l(f){a(f.data||"UNKNOWN_EVENT_DATA")}return()=>{e.source.removeEventListener(o,l),--e.count,e.count<=0&&(e.source.close(),t.delete(s))}},[r,o,u,t,c]),i}export{m as u};
//# sourceMappingURL=use-event-source-BuD4_2SF.js.map
