1import{a as e}from"./src-DZh7YBmL.js";import{Mi as t,d as n,ki as r,qi as i}from"./core-client-CNBA_1Fn.js";import{t as a}from"./queryOptions-BhcY4uWu.js";var o=t=>`${e()}/v1/organizations/${t}/streams`;async function s(e){if(!e.ok){let t=await e.text();throw Error(t||`Request failed with ${e.status}`)}return await e.json()}var c={all:[`streams`],list:(e,t)=>[...c.all,`list`,e,t??``],listsForOrg:e=>[...c.all,`list`,e],detail:(e,t)=>[...c.all,`detail`,e,t],deliveries:(e,t)=>[...c.all,`deliveries`,e,t],inbound:(e,t)=>[...c.all,`inbound`,e,t]},l=({organizationId:e,query:t})=>{let n=t?.trim()?t.trim():void 0;return a({queryKey:c.list(e,n),queryFn:async()=>{let t=n?`${o(e)}?query=${encodeURIComponent(n)}`:o(e);return s(await fetch(t,{credentials:`include`}))}})},u=({organizationId:e,streamId:t})=>a({queryKey:c.detail(e,t),queryFn:async()=>s(await fetch(`${o(e)}/${t}`,{credentials:`include`})),refetchInterval:e=>{let t=e.state.data;return t&&(t.registration_state===`pending`||t.last_error!==null)?5e3:!1}}),d=({organizationId:e,streamId:t,limit:n=50,before:r})=>a({queryKey:[...c.deliveries(e,t),r??`head`],queryFn:async()=>{let i=new URLSearchParams({limit:String(n)});return r!==void 0&&i.set(`before`,r),s(await fetch(`${o(e)}/${t}/deliveries?${i.toString()}`,{credentials:`include`}))}});function f(e){let n=i();return t({mutationFn:async t=>s(await fetch(o(e),{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})),onSuccess:()=>{n.invalidateQueries({queryKey:c.listsForOrg(e)})}})}function p(e){let a=i();return t({mutationFn:async({streamId:t,...n})=>s(await fetch(`${o(e)}/${t}`,{method:`PATCH`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)})),onSuccess:(t,{streamId:n})=>{a.invalidateQueries({queryKey:c.listsForOrg(e)}),a.invalidateQueries({queryKey:c.detail(e,n)})},onError:e=>r.error(n(e))})}function m(e){let n=i();return t({mutationFn:async t=>s(await fetch(`${o(e)}/${t}`,{method:`DELETE`,credentials:`include`})),onSuccess:()=>{n.invalidateQueries({queryKey:c.listsForOrg(e)})}})}var h=({organizationId:t,sheetId:n})=>a({queryKey:[...c.all,`sheet`,t,n],queryFn:async()=>s(await fetch(`${e()}/v1/organizations/${t}/sheets/${n}/streams`,{credentials:`include`}))});function g(e){let a=i();return t({mutationFn:async t=>s(await fetch(`${o(e)}/${t}/test`,{method:`POST`,credentials:`include`})),onSuccess:(t,n)=>{if(a.invalidateQueries({queryKey:c.deliveries(e,n)}),a.invalidateQueries({queryKey:c.detail(e,n)}),t.subscribers===0){r.warning(`Test event stored, but no sheet is subscribed to this stream.`);return}r.success(`Test event sent to ${t.subscribers} sheet${t.subscribers===1?``:`s`}.`)},onError:e=>r.error(n(e))})}var _=({organizationId:e,streamId:t,enabled:n,awaitingRemoteId:r=!1})=>a({queryKey:c.inbound(e,t),queryFn:async()=>s(await fetch(`${o(e)}/${t}/inbound`,{credentials:`include`})),enabled:n,staleTime:0,gcTime:0,refetchInterval:e=>r&&!e.state.data?.inbound_address?3e3:!1});function v(e){let n=i();return t({mutationFn:async t=>s(await fetch(`${o(e)}/${t}/rotate-secret`,{method:`POST`,credentials:`include`})),onSuccess:(t,r)=>{n.setQueryData(c.inbound(e,r),t),n.invalidateQueries({queryKey:c.detail(e,r)})}})}export{c as a,m as c,p as d,u as i,v as l,d as n,l as o,_ as r,f as s,h as t,g as u};
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.