import{aK as o}from"./@ui-core-DKdciH1Z.js";import{H as c,J as i,aA as l,F as y,ao as u,G as f}from"./index-D7KLAbvI.js";import{f as h}from"./stack-detail-query-IhXZFDdF.js";async function p(e){const a=c(i.stackDeployment.config)+(e?`?${l(e)}`:""),t=await y(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 config");throw new f({status:t.status,statusText:t.statusText,message:n})}return t.json()}async function k(e){const a=c(i.stackDeployment.info)+(e?`?${l(e)}`:""),t=await y(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 f({status:t.status,statusText:t.statusText,message:n})}return t.json()}async function m(e){const a=c(i.stackDeployment.stack)+(e?`?${l(e)}`:""),t=await y(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 f({status:t.status,statusText:t.statusText,message:n})}return t.json()}async function w(e){const a=c(i.stacks.all)+(e?`?${l(e)}`:""),t=await y(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 f({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()=>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};
