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