import{d as L,ez as j,F as P,G as $,b as n,c as m,w as s,u as e,eE as E,f as r,aA as C,ad as U,ct as V,bZ as O,eB as o,ev as S,et as f,eA as G,e as y,cM as z,b8 as M,cp as Z}from"./outputWidgets.0fb707c7.js";import"./router.81de177d.js";import{B as H}from"./build.32702ec7.js";import"./columns.37a1e6f7.js";import{C as J}from"./gateway.7ee47e62.js";import{a as K}from"./asyncComputed.a0ca296c.js";import{t as Q}from"./ant-design.c18e1d39.js";import{h as R}from"./index.215cc261.js";import{R as W}from"./dayjs.c5abb343.js";import{f as X}from"./index.b048d0fb.js";import{a as Y,A as I}from"./Title.f00a58f9.js";import{F as q}from"./Form.0dcb97c0.js";import{a as ee}from"./Text.3ec0a64d.js";import{C as te,A as ae}from"./CollapsePanel.d73eca3e.js";import{A as g}from"./index.0d3d2205.js";import{A as F}from"./index.a2e845fd.js";import"./index.140c5bc8.js";import"./activeRecord.204186f3.js";import"./pubsub.7d8bce56.js";import"./index.cf4c23b9.js";import"./transButton.220177fb.js";import"./index.85d2f01b.js";(function(){try{var p=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(p._sentryDebugIds=p._sentryDebugIds||{},p._sentryDebugIds[t]="065e97ca-37cf-4870-9b8e-66e083a9b215",p._sentryDebugIdIdentifier="sentry-dbid-065e97ca-37cf-4870-9b8e-66e083a9b215")}catch{}})();class le{list(t){const d=new URLSearchParams({offset:t.offset.toString(),limit:t.limit.toString(),from:t.from.getTime().toString(),to:t.to.getTime().toString(),search:t.search});return J.get(`projects/${t.projectId}/builds/${t.buildId}/logs?${d}`)}}const re=new le;class h{constructor(t,d,v,l,_,A,b){this.executionId=t,this.runtimeType=d,this.runtimeName=v,this.payload=l,this.event=_,this.buildId=A,this.createdAt=b}static fromDTO(t){return new h(t.executionId,t.runtimeType,t.runtimeName,t.payload,t.event,t.buildId,new Date(t.createdAt))}static async list(t){return(await re.list(t)).logs.map(h.fromDTO)}}const ne={key:0},se=["textContent"],oe=["textContent"],ie=["textContent"],de=["textContent"],Fe=L({__name:"Logs",setup(p){function t(i){return X(i,new Date,{addSuffix:!0})}const d=j(),v=d.params.projectId,l=P({selectedBuild:d.query.buildId||"latest",dateRange:[R().subtract(30,"days"),R()],search:"",limit:50,offset:0}),_=$(()=>c.value?[{label:"Latest",value:"latest"},{label:"All",value:"all"},...c.value.builds.map(i=>({label:`${t(i.createdAt)} (${i.id.slice(0,8)})`,value:i.id}))]:[{label:"Latest",value:"latest"},{label:"All",value:"all"}]),A=i=>{l.selectedBuild=i,k()},{loading:b,result:c,refetch:k}=K(()=>Promise.all([h.list({projectId:v,limit:l.limit,offset:l.offset,buildId:l.selectedBuild,from:l.dateRange[0].toDate(),to:l.dateRange[1].toDate(),search:l.search}),H.list(v)]).then(([i,u])=>E({logs:i,builds:u})));return(i,u)=>(n(),m(e(F),{direction:"vertical"},{default:s(()=>{var w,x,B;return[r(e(Y),null,{default:s(()=>[C("Logs")]),_:1}),r(e(q),null,{default:s(()=>[r(e(I),{label:"Build"},{default:s(()=>[r(e(U),{value:l.selectedBuild,"onUpdate:value":u[0]||(u[0]=a=>l.selectedBuild=a),options:_.value,"option-label":"label","option-value":"value",filter:!1,onChange:A},null,8,["value","options"])]),_:1}),r(e(I),{label:"From"},{default:s(()=>[r(e(W),{value:l.dateRange,"onUpdate:value":u[1]||(u[1]=a=>l.dateRange=a)},null,8,["value"])]),_:1}),r(e(I),{label:"Search"},{default:s(()=>[r(e(V),{value:l.search,"onUpdate:value":u[2]||(u[2]=a=>l.search=a),type:"search"},null,8,["value"])]),_:1}),r(e(O),{loading:e(b),onClick:e(k)},{default:s(()=>[C("Filter")]),_:1},8,["loading","onClick"])]),_:1}),(w=e(c))!=null&&w.logs.length?(n(),m(e(ee),{key:0},{default:s(()=>[C(" Showing from "+o(l.offset+1)+" to "+o(l.offset+l.limit),1)]),_:1})):S("",!0),(x=e(c))!=null&&x.logs.length?(n(),m(e(te),{key:1,"data-source":(B=e(c))==null?void 0:B.logs,loading:e(b)},{default:s(()=>[(n(!0),f(M,null,G(e(c).logs,(a,N)=>(n(),m(e(ae),{key:N},{header:s(()=>[r(e(F),null,{default:s(()=>[l.selectedBuild=="all"?(n(),f("span",ne,o(a.buildId.split("-")[0]),1)):S("",!0),r(e(g),{type:"vertical"}),y("span",null,o(t(a.createdAt)),1),r(e(g),{type:"vertical"}),y("span",null,o(a.runtimeType)+":"+o(a.runtimeName),1),r(e(g),{type:"vertical"}),y("span",null,o(a.executionId.slice(0,8)),1),r(e(g),{type:"vertical"}),y("span",null,o(a.event),1)]),_:2},1024)]),default:s(()=>{var D,T;return[y("div",null,[a.event==="stdout"?(n(),f("pre",{key:0,textContent:o(a.payload.log)},null,8,se)):a.event==="stderr"?(n(),f("pre",{key:1,textContent:o(a.payload.log)},null,8,oe)):a.event==="program-start-failed"?(n(),f("pre",{key:2,textContent:o(a.payload.error)},null,8,ie)):a.event==="widgets-computed"&&((T=(D=a.payload.errors)==null?void 0:D.general)==null?void 0:T.repr)?(n(),f("pre",{key:3,textContent:o(a.payload.errors.general.repr)},null,8,de)):(n(),m(e(z),{key:4,"tree-data":e(Q)(a.payload)},null,8,["tree-data"]))])]}),_:2},1024))),128))]),_:1},8,["data-source","loading"])):(n(),m(e(Z),{key:2}))]}),_:1}))}});export{Fe as default};
//# sourceMappingURL=Logs.1e4a2ddd.js.map
