import{fZ as s,bb as l,j as a,l as I,g3 as j,O as T,aT as p,a as i,af as m,Z as g,a$ as y,g4 as D,bd as N,r as d,di as f,dj as b}from"./index-d6499a22.js";import{u as x}from"./useProjectId-6028b5ae.js";import{u as S}from"./useCurrentProject-b23444be.js";const U=e=>{const{deployment:{status:t}}=e;return l(t,[s.RUNNING,s.IDLE,s.FAILED])?a.jsx(v,{...e}):a.jsx(A,{...e})},v=({deployment:e})=>{const[t,n]=I(),[c,{isLoading:r}]=j(),o=x();return a.jsxs(T,{children:[a.jsx(p,{variant:"secondary",color:"labels.red",disabled:l(e.status,h),onClick:n,height:"32px",minWidth:"88px",children:a.jsxs(i,{alignItems:"center",children:[a.jsx(i,{mr:"10px",children:a.jsx(m,{icon:g.stop,color:"labels.red",size:"sm"})}),a.jsx("span",{children:"Stop"})]})}),a.jsx(y,{title:`Stop the deployment ${e.name}`,secondaryText:`You are about to stop the deployment ${e.name}. Please be certain.`,isOpen:t,onClose:n,mainButtonProps:{children:"Stop deployment",isLoading:r,onClick:async()=>{await c({projectId:o,servingId:e.id}),n()}},secondaryButtonProps:{children:"Back",onClick:n}})]})},A=({title:e,deployment:t})=>{const[n,{isLoading:c}]=D(),r=x();return a.jsx(p,{variant:"secondary",color:"labels.green",disabled:l(t.status,h),onClick:()=>n({projectId:r,servingId:t.id}),height:"32px",minWidth:"88px",children:a.jsxs(i,{alignItems:"center",children:[a.jsx(i,{mr:"10px",children:a.jsx(m,{icon:g.play,color:"primary",size:"sm"})}),a.jsx("span",{children:e??"Run"})]})})},h=[s.STARTING,s.STOPPING,s.UPDATING],_=({status:e,...t})=>a.jsx(i,{...t,sx:{gap:"10px"},children:a.jsx(N,{variant:P(e),mode:E(e),loading:!L(e),value:e.toLocaleLowerCase()})}),P=e=>{switch(e){case s.CREATING:return"light";case s.CREATED:return"light";case s.RUNNING:case s.STARTING:case s.IDLE:return"success";case s.UPDATING:return"notice";case s.FAILED:return"fail";case s.STOPPING:case s.STOPPED:return"label";default:return"default"}},E=e=>e===s.IDLE?"bordered":"default",L=e=>e!==s.CREATING&&e!==s.STARTING&&e!==s.UPDATING&&e!==s.STOPPING,k=({projectName:e,deploymentName:t})=>`/grafana/d/kserve/kserve?orgId=1&var-namespace=${e.replaceAll("_","-")}&var-configuration=${t}-predictor-default&var-revision=All&refresh=10s`,w=()=>{const{project:e}=S();return t=>`/hopsworks-api${k({projectName:(e==null?void 0:e.projectName)??"",deploymentName:t})}`},G=({projectName:e,deploymentName:t})=>`/?_g=()&_a=(columns:!(serving_name,log_message,'@timestamp'),index:'${e}_serving-*',interval:auto,query:(language:lucene,query:'serving_name:${t}'),sort:!('@timestamp',desc))`,O=()=>{const{id:e,project:t}=S(),[n,c]=d.useState(),r=async o=>{const{data:u}=await new f().request({url:`/elastic/jwt/${o} `,type:b.get});u&&c(u.kibanaUrl)};return d.useEffect(()=>{r(e)},[e]),o=>`${n}security_tenant=private#${G({projectName:(t==null?void 0:t.projectName)??"",deploymentName:o})}`};export{U as D,_ as S,w as a,O as u};
