import{W as l,a5 as y}from"./CJVCACDl.js";function x(s=l()){var e;return(e=s.ssrContext)==null?void 0:e.event}function m(){const s=y();x();async function e(p,o={}){var r;const f=`${s.public.apiBase}${p}`,d={"Content-Type":"application/json"},{body:a,...h}=o,c={...h,headers:{...d,...o.headers},credentials:"include"};a!==void 0&&(c.body=JSON.stringify(a));const t=await fetch(f,c);if(!t.ok){const n=await t.text().catch(()=>"");let i=n;try{i=((r=JSON.parse(n))==null?void 0:r.detail)??n}catch{}const u=new Error(i||`HTTP ${t.status}`);throw u.status=t.status,u}return(t.headers.get("content-type")??"").includes("application/json")?t.json():t.text()}return{apiFetch:e}}export{m as u};
