import{i as y,q as i}from"./@tanstack-Dwlisomv.js";import{F as l,H as c,Z as p,x as u,_ as f,G as h}from"./index-CO6UN3UX.js";async function o(t){const a=l(c.flavors.all)+(t?`?${p(t)}`:""),e=await u(a,{method:"GET",headers:{"Content-Type":"application/json"}});if(e.status===404&&f(),!e.ok){const s=await e.json().then(r=>Array.isArray(r.detail)?r.detail[1]:r.detail).catch(()=>"Error while fetching flavors");throw new h({status:e.status,statusText:e.statusText,message:s})}return e.json()}async function w(t){const a=l(c.flavors.detail(t)),e=await u(a,{method:"GET",headers:{"Content-Type":"application/json"}});if(e.status===404&&f(),!e.ok){const s=await e.json().then(r=>Array.isArray(r.detail)?r.detail[1]:r.detail).catch(()=>`Error while fetching flavor ${t}`);throw new h({status:e.status,statusText:e.statusText,message:s})}return e.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:a})=>o({...t,page:a}),getNextPageParam:a=>a.index<a.total_pages?a.index+1:null,initialPageParam:1})};export{n as f};
