import{c as E,h as d}from"/build/_shared/chunk-EORSPQDF.js";var m=E((x,$)=>{d();$.exports={}});d();function R(e){return[204,410].includes(e.status)}var S=e=>async t=>{let{params:s,baseUrl:r,apiVersion:i="v1",shouldDeserialize:n=!0,...a}=t||{},{headers:o,body:c,...l}=a||{},y=r||process.env.REACT_APP_BASE_URL,j=v(`${y}/${i}/${e}`,s);try{let u=await fetch(j,{headers:{"Content-Type":"application/json",...o&&o},...c&&{body:JSON.stringify(c)},...l});if(R(u))return;let f=await u.json(),p=f?.errors;if(p)throw Error(p[0].detail);return n?{...f,data:w(f)}:f}catch(u){if(!(u instanceof SyntaxError))throw u}},b=(e,t)=>Object.keys(e).flatMap(s=>{let r=e[s];return!r&&(r!==!1||Array.isArray(r)&&!r.length)?[]:Array.isArray(r)?t?`${t}[${s}]=${r.join(",")}`:`${s}=${r.join(",")}`:typeof r!="object"?t?`${t}[${s}]=${r}`:`${s}=${r}`:b(r,s)}).join("&"),v=(e,t)=>t?`${e}?${b(t)}`:e,w=(e,t={})=>{t||(t={});let s=e.included||[];return Array.isArray(e.data)?e.data.map(r=>h(r,s,!1,t)):h(e.data,s,!1,t)},h=(e,t,s,r)=>{let n={...e?.attributes||{}};if(n.id=e.id,n.type=e.type,e.relationships)for(let a of Object.keys(e.relationships)){let o=e.relationships[a];if(Array.isArray(o.data)){let c=[];o.data.forEach(l=>{let y=A(t,l.type,l.id,r);c.push(y)}),n[a]=c}else o&&o.data?n[a]=A(t,o.data.type,o.data.id,r):n[a]=null}return n},A=(e,t,s,r)=>{let i=null;return e.forEach((n,a)=>{n.type===t&&n.id===s&&(i=h(n,e,!0,r))}),i||(i={id:s}),i};export{m as a,S as b};
