import{j as s,r as g}from"./vendor-react-wBh_31cN.js";import{G as f,d as w,e as L,u as b,p as k,aq as v,S as M}from"./index-BKr2rJhV.js";import{D as C,a as N,b as S,h as O,i as P,j as E,c as m}from"./dropdown-menu-CUHqMoVG.js";import{s as c,a as d}from"./ExecutionLogPopup-C3JnewfG.js";import{ad as I,a_ as z,v as D,ak as F}from"./vendor-icons-BUUmD6ht.js";import{I as J}from"./icon-button-FETOk6q1.js";import{K as x,a as j}from"./KubeMonitoringPods-CTAKeFzc.js";import{c as R}from"./index-7v8-2hdX.js";import{c as _}from"./vendor-router-D1GqFWiT.js";const h=({jobType:n,openSearchHref:o,plainLogsEnabled:i,onOpenPlainLogs:e})=>{const a=c(n)&&!!o,r=d(n),l=r&&!i;return!a&&!r?null:s.jsxs(s.Fragment,{children:[a&&s.jsxs(m,{onClick:()=>{window.open(o,"_blank","noopener,noreferrer")},children:[s.jsx(z,{className:"size-4"}),"In OpenSearch"]}),r&&s.jsxs(m,{disabled:l,onClick:e,children:[s.jsx(D,{className:"size-4"}),"Plain logs"]})]})},X=({jobType:n,openSearchHref:o,plainLogsEnabled:i,onOpenPlainLogs:e,className:a})=>{const r=c(n)&&!!o,l=d(n);return!r&&!l?null:s.jsxs(C,{children:[s.jsx(N,{asChild:!0,children:s.jsxs(f,{type:"button",variant:"outline",size:"sm",className:w("gap-1.5",a),onClick:t=>t.stopPropagation(),children:["Live Logs",s.jsx(I,{className:"size-4"})]})}),s.jsx(S,{align:"end",className:"min-w-40",children:s.jsx(h,{jobType:n,openSearchHref:o,plainLogsEnabled:i,onOpenPlainLogs:e})})]})},Y=({jobType:n,openSearchHref:o,plainLogsEnabled:i,onOpenPlainLogs:e})=>{const a=c(n)&&!!o,r=d(n);return!a&&!r?null:s.jsxs(O,{children:[s.jsx(P,{children:"Live Logs"}),s.jsx(E,{children:s.jsx(h,{jobType:n,openSearchHref:o,plainLogsEnabled:i,onOpenPlainLogs:e})})]})},B=({jobName:n,executionId:o})=>{var p,u;const{id:i}=_(),{data:e,isLoading:a,isFetching:r,refetch:l}=R({pId:i,name:n,execId:o,params:{expand:"kube_monitor"}},{selectFromResult:L({data:b(k("kubeMonitor"))}),pollingInterval:5e3,skip:!o}),t=(e==null?void 0:e.job)??(e==null?void 0:e.sparkJob)??(e==null?void 0:e.rayJob);return a?s.jsx("div",{className:"relative py-[100px]",children:s.jsx(v,{})}):s.jsxs("div",{className:"mb-5 flex flex-col gap-4",children:[s.jsx("div",{className:"flex justify-end",children:r?s.jsx(M,{}):s.jsx(J,{variant:"ghost",size:"icon-sm",onClick:l,"aria-label":"Refresh",children:s.jsx(F,{className:"size-4"})})}),t&&s.jsx(x,{title:"Job Status",...t,children:((p=t.pods)==null?void 0:p.items)&&s.jsx(j,{pods:t.pods.items})}),(e==null?void 0:e.workload)&&s.jsx(x,{title:"Workload Status",...e.workload,children:((u=e.workload.pods)==null?void 0:u.items)&&s.jsx(j,{pods:e.workload.pods.items})})]})},Z=g.memo(B);export{Z as E,Y as L,X as a};
