import{d as L,eA as j,H as P,J as $,b as n,c as m,w as s,u as e,f as r,aJ as C,af as U,cA as V,c4 as E,eC as o,ew as S,eu as f,eB as O,e as y,cT as J,bg as G,cw as H,eF as z}from"./outputWidgets.f120b477.js";import"./router.e3ecb487.js";import{B as K}from"./build.41e77770.js";import"./index.81859a03.js";import{C as M}from"./gateway.a36b7b3a.js";import{a as Q}from"./asyncComputed.5ccd4614.js";import{t as W}from"./ant-design.13a5e655.js";import{h as R}from"./index.bc6db419.js";import{R as X}from"./dayjs.4982b6e6.js";import{f as Y}from"./index.b048d0fb.js";import{c as Z,A as w}from"./Title.3dc4e32d.js";import{F as q}from"./Form.ec892c10.js";import{a as ee}from"./index.3ab4f365.js";import{C as te,A as ae}from"./CollapsePanel.a5b374bc.js";import{A as h}from"./index.de46e6db.js";import{A as F}from"./index.54e8798a.js";import"./index.5818bfb2.js";import"./activeRecord.d87d7ef2.js";import"./pubsub.4681462f.js";import"./index.b96fbbd8.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]="272073f2-b653-44a7-b575-e4206cc810f0",p._sentryDebugIdIdentifier="sentry-dbid-272073f2-b653-44a7-b575-e4206cc810f0")}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 M.get(`projects/${t.projectId}/builds/${t.buildId}/logs?${d}`)}}const re=new le;class b{constructor(t,d,v,l,_,A,g){this.executionId=t,this.runtimeType=d,this.runtimeName=v,this.payload=l,this.event=_,this.buildId=A,this.createdAt=g}static fromDTO(t){return new b(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(b.fromDTO)}}const ne={key:0},se=["textContent"],oe=["textContent"],ie=["textContent"],de=["textContent"],Se=L({__name:"Logs",setup(p){function t(i){return Y(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,I()},{loading:g,result:c,refetch:I}=Q(()=>Promise.all([b.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}),K.list(v)]).then(([i,u])=>z({logs:i,builds:u})));return(i,u)=>(n(),m(e(F),{direction:"vertical"},{default:s(()=>{var k,x,B;return[r(e(Z),null,{default:s(()=>[C("Logs")]),_:1}),r(e(q),null,{default:s(()=>[r(e(w),{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(w),{label:"From"},{default:s(()=>[r(e(X),{value:l.dateRange,"onUpdate:value":u[1]||(u[1]=a=>l.dateRange=a)},null,8,["value"])]),_:1}),r(e(w),{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(E),{loading:e(g),onClick:e(I)},{default:s(()=>[C("Filter")]),_:1},8,["loading","onClick"])]),_:1}),(k=e(c))!=null&&k.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(g)},{default:s(()=>[(n(!0),f(G,null,O(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(h),{type:"vertical"}),y("span",null,o(t(a.createdAt)),1),r(e(h),{type:"vertical"}),y("span",null,o(a.runtimeType)+":"+o(a.runtimeName),1),r(e(h),{type:"vertical"}),y("span",null,o(a.executionId.slice(0,8)),1),r(e(h),{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(J),{key:4,"tree-data":e(W)(a.payload)},null,8,["tree-data"]))])]}),_:2},1024))),128))]),_:1},8,["data-source","loading"])):(n(),m(e(H),{key:2}))]}),_:1}))}});export{Se as default};
//# sourceMappingURL=Logs.35b147cc.js.map
