import{gq as u,jJ as p,jK as E,K as b,jL as M,M as x,jM as v,jN as P,jO as S,jP as f,jQ as F,jR as N,u as C,Z as k,r as D,j as h,aV as A,aU as w,aT as L,cS as O,gg as Y}from"./index-46ma1THH.js";import{c as G,d as U}from"./index-DoAo8g_G.js";function H(s,t){const n=u(s),e=u(t);return n.getFullYear()-e.getFullYear()}function _(s,t){const n=u(s),e=u(t),o=y(n,e),r=Math.abs(p(n,e));n.setDate(n.getDate()-o*r);const c=+(y(n,e)===-o),a=o*(r-c);return a===0?0:a}function y(s,t){const n=s.getFullYear()-t.getFullYear()||s.getMonth()-t.getMonth()||s.getDate()-t.getDate()||s.getHours()-t.getHours()||s.getMinutes()-t.getMinutes()||s.getSeconds()-t.getSeconds()||s.getMilliseconds()-t.getMilliseconds();return n<0?-1:n>0?1:n}function R(s,t,n){const e=E(s,t)/b;return M()(e)}function z(s,t,n){const e=E(s,t)/x;return M()(e)}function K(s,t){const n=u(s),e=u(t),o=v(n,e),r=Math.abs(H(n,e));n.setFullYear(1584),e.setFullYear(1584);const c=v(n,e)===-o,a=o*(r-+c);return a===0?0:a}const T=["years","months","weeks","days","hours","minutes","seconds"];function J(s,t){const n=P(),e=(t==null?void 0:t.locale)??n.locale??S,o=(t==null?void 0:t.format)??T,r=(t==null?void 0:t.zero)??!1,c=(t==null?void 0:t.delimiter)??" ";return e.formatDistance?o.reduce((i,l)=>{const g=`x${l.replace(/(^.)/,m=>m.toUpperCase())}`,d=s[l];return d!==void 0&&(r||s[l])?i.concat(e.formatDistance(g,d)):i},[]).join(c):""}function Q(s){const t=u(s.start),n=u(s.end),e={},o=K(n,t);o&&(e.years=o);const r=f(t,{years:e.years}),c=F(n,r);c&&(e.months=c);const a=f(r,{months:e.months}),i=_(n,a);i&&(e.days=i);const l=f(a,{days:e.days}),g=R(n,l);g&&(e.hours=g);const d=f(l,{hours:e.hours}),m=z(n,d);m&&(e.minutes=m);const j=f(d,{minutes:e.minutes}),I=N(n,j);return I&&(e.seconds=I),e}const V=s=>J(Q({start:0,end:s}),{format:["years","months","days","hours","minutes","seconds"],locale:{formatDistance:(t,n)=>$[t].replace("{{count}}",n)}}),$={xSeconds:"{{count}}s",xMinutes:"{{count}}m",xHours:"{{count}}h",xDays:"{{count}}d",xMonths:"{{count}}m",xYears:"{{count}}y"},Z=({projectId:s,jobName:t,execution:n})=>{const{id:e}=C(),r={pId:s??e,name:t,execId:(n==null?void 0:n.id)??0},{currentData:c}=G.getJobExecution.useQueryState(r),a=k(n??{},c??{}),i=(a==null?void 0:a.finalStatus)==="UNDEFINED"||(a==null?void 0:a.state)==="AGGREGATING_LOGS";return U(r,{skip:!i,pollingInterval:5e3}),D.useMemo(()=>({execution:a,isStillExecuting:i}),[a,i])},W=({execution:s,isOpenPopup:t,handleTogglePopup:n})=>{const[e,o]=D.useState("stdoutPath"),r=s[e]??"",c=D.useMemo(()=>[{title:"stdout",isActive:e==="stdoutPath",onClick:()=>o("stdoutPath")},{title:"stderr",isActive:e==="stderrPath",onClick:()=>o("stderrPath")},...s.notebookOutPath?[{title:"notebook out",isActive:e==="notebookOutPath",onClick:()=>o("notebookOutPath")}]:[]],[e,s.notebookOutPath]);return h.jsx(A,{size:"7xl",isOpen:t,onClose:n,hasCloseButton:!0,title:h.jsx(O,{title:"Logs",tabs:c,width:"90%"}),bodyProps:{pt:0,mt:"10px"},children:h.jsx(w,{file:{attributes:{path:r,name:L(r)}},errorContent:{title:"Logs not found",message:""}},e)})},X=(s,t=[])=>{const n=t.filter(e=>e.state==="RUNNING").length;if(n)return{width:"fit-content",value:`${n} ${n>1?"executions":"execution"} in progress`,variant:"light",loading:!0};switch(s){case"SUCCEEDED":return{width:"fit-content",value:"Success",variant:"success"};case"FAILED":return{width:"fit-content",value:"Fail",variant:"fail"};case"IN_PROGRESS":return{width:"fit-content",value:"In progress",variant:"light",loading:!0};case"KILLED":return{width:"fit-content",value:"Killed",variant:"label"};case"UNDEFINED":return{width:"fit-content",value:"-",variant:"label",loading:!0};default:return{width:"fit-content",value:s?Y(s).replaceAll("_"," "):"-",variant:"label"}}};export{W as E,X as g,V as m,Z as u};
