import{C as n}from"./gateway.8733a5f3.js";import"./index.82b3148c.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[e]="be909f3d-0cf6-4f0c-b2fc-623cb8f1d7f2",a._sentryDebugIdIdentifier="sentry-dbid-be909f3d-0cf6-4f0c-b2fc-623cb8f1d7f2")}catch{}})();class g{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 d=new g;class l{constructor(e){this.dto=e}static async list(e){return(await d.list(e)).map(o=>new l(o))}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}get abstraVersion(){return this.dto.abstraVersion}async download(){const e=await d.download(this.id);if(!e)throw new Error("Download failed");window.open(e.url,"_blank")}}class c{constructor(e,s,o,r){this.projectId=e,this.buildId=s,this.abstraVersion=o,this.project=r}static fromV0(e,s,o,r){const i={hooks:r.hooks.map(t=>({id:t.path,logQuery:{buildId:s,stageId:t.path,stageTitle:t.title},...t})),forms:r.forms.map(t=>({id:t.path,logQuery:{buildId:s,stageId:t.path,stageTitle:t.title},...t})),jobs:r.jobs.map(t=>({id:t.identifier,logQuery:{buildId:s,stageId:t.identifier,stageTitle:t.title},...t})),scripts:[]};return new c(e,s,o,i)}static fromDTO(e,s,o,r){const i={hooks:r.hooks.map(t=>({logQuery:{buildId:s,stageId:t.id,stageTitle:t.title},...t})),forms:r.forms.map(t=>({logQuery:{buildId:s,stageId:t.id,stageTitle:t.title},...t})),jobs:r.jobs.map(t=>({logQuery:{buildId:s,stageId:t.id,stageTitle:t.title},...t})),scripts:r.scripts.map(t=>({logQuery:{buildId:s,stageId:t.id,stageTitle:t.title},...t}))};return new c(e,s,o,i)}static async get(e){const s=await d.get(e);if(!s)throw new Error("Build not found");const{projectId:o,abstraJson:r,abstraVersion:i}=s;if(!r||!i)return null;const t=JSON.parse(r);if(!t.version)throw new Error("Version is invalid");return t.version==="0.1"?this.fromV0(o,e,i,t):this.fromDTO(o,e,i,t)}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"})),...this.project.scripts.map(e=>({...e,type:"script"}))]}}export{c as B,l as a,g as b};
//# sourceMappingURL=build.266f1e37.js.map
