import{fu as s,aH as l,j as a,w as I,fL as j,d as y,bs as d,B as i,au as m,C as g,bA as T,fM as D,bb as b,ay as h,ep as N,r as p,db as f,dc as v}from"./index-C1DmWO_C.js";import{u as S}from"./useProjectId-Cio5B8Wh.js";const _=e=>{const{deployment:{status:t}}=e;return l(t,[s.RUNNING,s.IDLE,s.FAILED,s.STARTING,s.UPDATING])?a.jsx(A,{...e}):a.jsx(P,{...e})},A=({deployment:e})=>{const[t,n]=I(),[c,{isLoading:r}]=j(),o=S();return a.jsxs(y,{children:[a.jsx(d,{variant:"secondary",color:"labels.red",disabled:l(e.status,x),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(T,{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}})]})},P=({title:e,deployment:t})=>{const[n,{isLoading:c}]=D(),r=S();return a.jsx(d,{variant:"secondary",color:"labels.green",disabled:l(t.status,x),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"})]})})},x=[s.STOPPING],$=({status:e,...t})=>a.jsx(i,{...t,sx:{gap:"10px"},children:a.jsx(b,{variant:C(e),mode:E(e),loading:!L(e),value:e.toLocaleLowerCase()})}),C=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,G=({projectName:e,deploymentName:t})=>`/grafana/d/kserve/kserve?${N.stringify({orgId:1,refresh:"10s","var-namespace":e.toLowerCase().replaceAll("_","-"),"var-configuration":`${t}-.*`,"var-revision":"All"})}`,U=()=>{const{project:e}=h();return t=>`/hopsworks-api${G({projectName:(e==null?void 0:e.projectName)??"",deploymentName:t})}`},k=({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))`,B=()=>{const{id:e,project:t}=h(),[n,c]=p.useState(),r=async o=>{const{data:u}=await new f().request({url:`/elastic/jwt/${o} `,type:v.get});u&&c(u.kibanaUrl)};return p.useEffect(()=>{r(e)},[e]),o=>`${n}security_tenant=private#${k({projectName:(t==null?void 0:t.projectName)??"",deploymentName:o})}`};export{_ as D,$ as S,U as a,B as u};
