import{aL as y,aK as i}from"./@ui-core-DKdciH1Z.js";import{H as l,J as c,aA as p,F as u,ao as f,G as h}from"./index-D7KLAbvI.js";async function o(t){const e=l(c.flavors.all)+(t?`?${p(t)}`:""),a=await u(e,{method:"GET",headers:{"Content-Type":"application/json"}});if(a.status===404&&f(),!a.ok){const s=await a.json().then(r=>Array.isArray(r.detail)?r.detail[1]:r.detail).catch(()=>"Error while fetching flavors");throw new h({status:a.status,statusText:a.statusText,message:s})}return a.json()}async function w(t){const e=l(c.flavors.detail(t)),a=await u(e,{method:"GET",headers:{"Content-Type":"application/json"}});if(a.status===404&&f(),!a.ok){const s=await a.json().then(r=>Array.isArray(r.detail)?r.detail[1]:r.detail).catch(()=>`Error while fetching flavor ${t}`);throw new h({status:a.status,statusText:a.statusText,message:s})}return a.json()}const n={all:["flavors"],flavorList:t=>i({queryKey:[...n.all,t],queryFn:async()=>o(t)}),flavorDetail:t=>i({queryKey:[...n.all,t],queryFn:async()=>w(t)}),flavorListInfinite:t=>y({queryKey:[...n.all,t,"infinite"],queryFn:({pageParam:e})=>o({...t,page:e}),getNextPageParam:e=>e.index<e.total_pages?e.index+1:null,initialPageParam:1})};export{n as f};
