import{C as _}from"./gateway.349a9491.js";import{d as k,eA as w,b as c,c as m,w as n,u as o,eu as v,f as a,bS as I,bv as A,bt as S,e as L,I as y,aq as d,cF as g,eD as p,ew as b,cn as T}from"./outputWidgets.e822ff0f.js";import{E as V,a as j,f as $,j as C,h as D}from"./icons.0ab0d55f.js";import{a as E}from"./router.8fbd98d9.js";import{c as f}from"./Text.4c9d53a2.js";import{a as N,A as Q}from"./index.3873cc30.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[t]="d113e76f-2f99-418c-b4fb-95310188322e",l._sentryDebugIdIdentifier="sentry-dbid-d113e76f-2f99-418c-b4fb-95310188322e")}catch{}})();class h{constructor(t,r,s){this.projectId=t,this.buildId=r,this.project=s}static fromV0(t,r,s){const u={hooks:s.hooks.map(e=>({id:e.path,logQuery:{buildId:r,runtimeId:e.path,runtimeTitle:e.title},...e})),forms:s.forms.map(e=>({id:e.path,logQuery:{buildId:r,runtimeId:e.path,runtimeTitle:e.title},...e})),jobs:s.jobs.map(e=>({id:e.identifier,logQuery:{buildId:r,runtimeId:e.identifier,runtimeTitle:e.title},...e}))};return new h(t,r,u)}static fromV1(t,r,s){const u={hooks:s.hooks.map(e=>({logQuery:{buildId:r,runtimeId:e.id,runtimeTitle:e.title},...e})),forms:s.forms.map(e=>({logQuery:{buildId:r,runtimeId:e.id,runtimeTitle:e.title},...e})),jobs:s.jobs.map(e=>({logQuery:{buildId:r,runtimeId:e.id,runtimeTitle:e.title},...e}))};return new h(t,r,u)}static from(t,r,s){if(s.version==="0.1")return this.fromV0(t,r,s);if(s.version==="1.0")return this.fromV1(t,r,s);throw new Error(`Unsupported project version: ${s.version}`)}get runtimes(){return[...this.project.forms.map(t=>({...t,type:"form"})),...this.project.hooks.map(t=>({...t,type:"hook"})),...this.project.jobs.map(t=>({...t,type:"job"}))]}}const U=async l=>{try{const t=await _.get(`projects/${l}/latest-build`);if(!t)return null;const{id:r,abstraJson:s}=t,u=JSON.parse(s);if(!u.version)throw new Error("version is invalid");return h.from(l,r,u)}catch(t){return console.log(`Latest build is invalid: ${t.message}`),null}},H=async l=>{try{const t=await _.get(`builds/${l}`);if(!t)return null;const{projectId:r,abstraJson:s}=t,u=JSON.parse(s);if(!u.version)throw new Error("version is invalid");return h.from(r,l,u)}catch(t){return console.log(`Latest build is invalid: ${t.message}`),null}},x={style:{display:"flex","align-items":"center",gap:"5px"}},B={key:1},K=k({__name:"component",props:{buildSpec:{},subdomain:{}},setup(l){const t=l,r=w(),s=e=>!t.subdomain||e.type!="form"?"":`https://${t.subdomain}.abstra.app/${e.path}`,u=e=>{r.push({name:"logs",params:{projectId:t.buildSpec.projectId},query:e.logQuery})};return(e,z)=>e.buildSpec.runtimes.length>0?(c(),m(o(Q),{key:0,"item-layout":"horizontal","data-source":e.buildSpec.runtimes},{renderItem:n(({item:i})=>[a(o(N),null,{actions:n(()=>[a(o(I),null,{overlay:n(()=>[a(o(A),null,{default:n(()=>[a(o(S),{onClick:J=>u(i)},{default:n(()=>[L("div",x,[a(y,{path:o(V)},null,8,["path"]),a(o(f),null,{default:n(()=>[d(" View Logs")]),_:1})])]),_:2},1032,["onClick"])]),_:2},1024)]),default:n(()=>[a(y,{path:o(j),style:{cursor:"pointer"}},null,8,["path"])]),_:2},1024)]),default:n(()=>[i.type=="form"?(c(),m(o(g),{key:0,size:"large"},{default:n(()=>[a(y,{path:o($)},null,8,["path"]),s(i)?(c(),m(o(E),{key:0,href:s(i),strong:""},{default:n(()=>[d(p(i.title),1)]),_:2},1032,["href"])):(c(),m(o(f),{key:1,strong:""},{default:n(()=>[d(p(i.title),1)]),_:2},1024)),a(o(f),{type:"secondary",code:""},{default:n(()=>[d("/"+p(i.path),1)]),_:2},1024)]),_:2},1024)):b("",!0),i.type=="job"?(c(),m(o(g),{key:1,size:"large"},{default:n(()=>[a(y,{path:o(C)},null,8,["path"]),a(o(f),{strong:""},{default:n(()=>[d(p(i.title),1)]),_:2},1024),a(o(f),{type:"secondary",code:""},{default:n(()=>[d(p(i.schedule),1)]),_:2},1024)]),_:2},1024)):b("",!0),i.type=="hook"?(c(),m(o(g),{key:2,size:"large"},{default:n(()=>[a(y,{path:o(D)},null,8,["path"]),a(o(f),{strong:""},{default:n(()=>[d(p(i.title),1)]),_:2},1024),a(o(f),{type:"secondary",code:""},{default:n(()=>[d("/_hooks/"+p(i.path),1)]),_:2},1024)]),_:2},1024)):b("",!0)]),_:2},1024)]),_:1},8,["data-source"])):(c(),v("div",B,[a(o(T),{description:"No runtimes found. Make sure your project has forms, hooks or jobs before deploying it"})]))}});export{K as _,H as a,U as g};
//# sourceMappingURL=component.vue_vue_type_script_setup_true_lang.4592753b.js.map
