import{C as o}from"./router.4a0ba06b.js";import"./outputWidgets.6e1c5425.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[t]="38d398b9-2df5-4848-aae5-a7941a3a850c",s._sentryDebugIdIdentifier="sentry-dbid-38d398b9-2df5-4848-aae5-a7941a3a850c")}catch{}})();class l{async list(t){return o.get(`projects/${t}/builds`)}async get(t){return o.get(`builds/${t}`)}async download(t){return o.get(`builds/${t}/download`)}}const a=new l;class u{constructor(t){this.dto=t}static async list(t){return(await a.list(t)).map(i=>new u(i))}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 t=await a.download(this.id);if(!t)throw new Error("Download failed");window.open(t.url,"_blank")}}class d{constructor(t,r,i){this.projectId=t,this.buildId=r,this.project=i}static fromV0(t,r,i){const n={hooks:i.hooks.map(e=>({id:e.path,logQuery:{buildId:r,runtimeId:e.path,runtimeTitle:e.title},...e})),forms:i.forms.map(e=>({id:e.path,logQuery:{buildId:r,runtimeId:e.path,runtimeTitle:e.title},...e})),jobs:i.jobs.map(e=>({id:e.identifier,logQuery:{buildId:r,runtimeId:e.identifier,runtimeTitle:e.title},...e})),scripts:[]};return new d(t,r,n)}static fromDTO(t,r,i){const n={hooks:i.hooks.map(e=>({logQuery:{buildId:r,runtimeId:e.id,runtimeTitle:e.title},...e})),forms:i.forms.map(e=>({logQuery:{buildId:r,runtimeId:e.id,runtimeTitle:e.title},...e})),jobs:i.jobs.map(e=>({logQuery:{buildId:r,runtimeId:e.id,runtimeTitle:e.title},...e})),scripts:i.scripts.map(e=>({logQuery:{buildId:r,runtimeId:e.id,runtimeTitle:e.title},...e}))};return new d(t,r,n)}static async get(t){const r=await a.get(t);if(!r)throw new Error("Build not found");const{projectId:i,abstraJson:n}=r;if(!n)return null;const e=JSON.parse(n);if(!e.version)throw new Error("Version is invalid");return e.version==="0.1"?this.fromV0(i,t,e):this.fromDTO(i,t,e)}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"})),...this.project.scripts.map(t=>({...t,type:"script"}))]}}function g(s,t){return s.toLocaleString(void 0,{hour12:!1,timeZoneName:"short",day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",weekday:"long",...t})}export{u as B,d as a,l as b,g};
//# sourceMappingURL=datetime.4c04cd60.js.map
