import{q as o}from"./@tanstack-DYiOyJUL.js";import{k as c,l as i,j as l,n as u,F as y}from"./index-DK1ynKjA.js";import{o as h}from"./url-DuQMeqYA.js";async function f(e){const a=c(i.stacks.all)+(e?`?${h(e)}`:""),t=await l(a,{method:"GET",headers:{"Content-Type":"application/json"}});if(t.status===404&&u(),!t.ok){const n=await t.json().then(s=>Array.isArray(s.detail)?s.detail[1]:s.detail).catch(()=>"Error while fetching stacks");throw new y({status:t.status,statusText:t.statusText,message:n})}return t.json()}async function p(e){const a=c(i.stackDeployment.info)+(e?`?${h(e)}`:""),t=await l(a,{method:"GET",headers:{"Content-Type":"application/json"}});if(t.status===404&&u(),!t.ok){const n=await t.json().then(s=>Array.isArray(s.detail)?s.detail[1]:s.detail).catch(()=>"Error while fetching stack deployment info");throw new y({status:t.status,statusText:t.statusText,message:n})}return t.json()}async function k(e){const a=c(i.stackDeployment.stack)+(e?`?${h(e)}`:""),t=await l(a,{method:"GET",headers:{"Content-Type":"application/json"}});if(t.status===404&&u(),!t.ok){const n=await t.json().then(s=>Array.isArray(s.detail)?s.detail[1]:s.detail).catch(()=>"Error while fetching the deployed stack");throw new y({status:t.status,statusText:t.statusText,message:n})}return t.json()}const r={all:["stacks"],stackDeployment:["stack-deployment"],stackList:e=>o({queryKey:[...r.all,e],queryFn:async()=>f(e)}),stackDeploymentInfo:e=>o({queryKey:[...r.stackDeployment,"info",e],queryFn:async()=>p(e)}),stackDeploymentStack:e=>o({queryKey:[...r.stackDeployment,"stack",e],queryFn:async()=>k(e)})};export{f,r as s};
