import{C as n}from"./gateway.5878b159.js";import"./outputWidgets.a5fcf389.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="ebf01d2a-26b5-4b51-9c19-3a06747cde78",i._sentryDebugIdIdentifier="sentry-dbid-ebf01d2a-26b5-4b51-9c19-3a06747cde78")}catch{}})();class c{async list(e){return n.get(`projects/${e}/builds`)}async get(e){return n.get(`builds/${e}`)}async download(e){return n.get(`builds/${e}/download`)}}const a=new c;class u{constructor(e){this.dto=e}static async list(e){return(await a.list(e)).map(s=>new u(s))}get id(){return this.dto.id}get projectId(){return this.dto.projectId}get createdAt(){return new Date(this.dto.createdAt)}get status(){return this.dto.status}get log(){return this.dto.log}get latest(){return this.dto.latest}async download(){const e=await a.download(this.id);if(!e)throw new Error("Download failed");window.open(e.url,"_blank")}}class d{constructor(e,r,s){this.projectId=e,this.buildId=r,this.project=s}static fromV0(e,r,s){const o={hooks:s.hooks.map(t=>({id:t.path,logQuery:{buildId:r,runtimeId:t.path,runtimeTitle:t.title},...t})),forms:s.forms.map(t=>({id:t.path,logQuery:{buildId:r,runtimeId:t.path,runtimeTitle:t.title},...t})),jobs:s.jobs.map(t=>({id:t.identifier,logQuery:{buildId:r,runtimeId:t.identifier,runtimeTitle:t.title},...t}))};return new d(e,r,o)}static fromV1(e,r,s){const o={hooks:s.hooks.map(t=>({logQuery:{buildId:r,runtimeId:t.id,runtimeTitle:t.title},...t})),forms:s.forms.map(t=>({logQuery:{buildId:r,runtimeId:t.id,runtimeTitle:t.title},...t})),jobs:s.jobs.map(t=>({logQuery:{buildId:r,runtimeId:t.id,runtimeTitle:t.title},...t}))};return new d(e,r,o)}static async get(e){const r=await a.get(e);if(!r)throw new Error("Build not found");const{projectId:s,abstraJson:o}=r,t=JSON.parse(o);if(!t.version)throw new Error("Version is invalid");if(t.version==="0.1")return this.fromV0(s,e,t);if(t.version==="1.0")return this.fromV1(s,e,t);throw new Error(`Unsupported project version: ${t.version}`)}get runtimes(){return[...this.project.forms.map(e=>({...e,type:"form"})),...this.project.hooks.map(e=>({...e,type:"hook"})),...this.project.jobs.map(e=>({...e,type:"job"}))]}}export{u as B,d as a};
//# sourceMappingURL=build.f1d97524.js.map
