import{j as m,q as r}from"./@tanstack-DT5WLu9C.js";import{p as c,q as u,k as l,s as p,F as h}from"./index-CCOPpudF.js";import{o as f}from"./url-CkvKAnwF.js";async function i(t){const n=c(u.components.all)+(t?`?${f(t)}`:""),e=await l(n,{method:"GET",headers:{"Content-Type":"application/json"}});if(e.status===404&&p(),!e.ok){const a=await e.json().then(s=>Array.isArray(s.detail)?s.detail[1]:s.detail).catch(()=>"Error while fetching stack components");throw new h({status:e.status,statusText:e.statusText,message:a})}return e.json()}async function y(t){const n=c(u.components.detail(t)),e=await l(n,{method:"GET",headers:{"Content-Type":"application/json"}});if(e.status===404&&p(),!e.ok){const a=await e.json().then(s=>Array.isArray(s.detail)?s.detail[1]:s.detail).catch(()=>"Error while fetching stack components");throw new h({status:e.status,statusText:e.statusText,message:a})}return e.json()}const o={all:["components"],componentListInfinite:t=>m({queryKey:[...o.all,t,"infinite"],queryFn:async({pageParam:n})=>i({...t,page:n}),getNextPageParam:n=>n.index<n.total_pages?n.index+1:null,initialPageParam:1}),componentList:t=>r({queryKey:[...o.all,t],queryFn:async()=>i(t)}),componentDetail:t=>r({queryKey:[...o.all,t],queryFn:async()=>y(t)})};export{o as c};
