import{fD as s,a$ as l,j as n,c as I,fH as j,e as y,B as i,as as d,Z as m,bE as D,fI as T,bj as f,ep as N,r as p,d4 as E,d5 as v}from"./index-dP1W1_bd.js";import{u as g}from"./useProjectId-DopcTZap.js";import{B as h}from"./ButtonWithRole-CF64B_Or.js";import{u as S}from"./useDownload-C3yCvYJa.js";const B=e=>{const{deployment:{status:t}}=e;return l(t,[s.RUNNING,s.IDLE,s.FAILED,s.STARTING,s.UPDATING])?n.jsx(b,{...e}):n.jsx(A,{...e})},b=({deployment:e})=>{const[t,a]=I(),[c,{isLoading:r}]=j(),o=g();return n.jsxs(y,{children:[n.jsx(h,{variant:"secondary",color:"labels.red",disabled:l(e.status,x),onClick:a,height:"32px",minWidth:"88px",children:n.jsxs(i,{alignItems:"center",children:[n.jsx(i,{mr:"10px",children:n.jsx(d,{icon:m.stop,color:"labels.red",size:"sm"})}),n.jsx("span",{children:"Stop"})]})}),n.jsx(D,{title:`Stop the deployment ${e.name}`,secondaryText:`You are about to stop the deployment ${e.name}. Please be certain.`,isOpen:t,onClose:a,mainButtonProps:{children:"Stop deployment",isLoading:r,onClick:async()=>{await c({projectId:o,servingId:e.id}),a()}},secondaryButtonProps:{children:"Back",onClick:a}})]})},A=({title:e,deployment:t})=>{const[a,{isLoading:c}]=T(),r=g();return n.jsx(h,{variant:"secondary",color:"labels.green",disabled:l(t.status,x),onClick:()=>a({projectId:r,servingId:t.id}),height:"32px",minWidth:"88px",children:n.jsxs(i,{alignItems:"center",children:[n.jsx(i,{mr:"10px",children:n.jsx(d,{icon:m.play,color:"primary",size:"sm"})}),n.jsx("span",{children:e??"Run"})]})})},x=[s.STOPPING],U=({status:e,...t})=>n.jsx(i,{...t,sx:{gap:"10px"},children:n.jsx(f,{variant:P(e),mode:L(e),loading:!k(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"}},L=e=>e===s.IDLE?"bordered":"default",k=e=>e!==s.CREATING&&e!==s.STARTING&&e!==s.UPDATING&&e!==s.STOPPING,C=({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"})}`,O=()=>{const{project:e}=S();return t=>`/hopsworks-api${C({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))`,q=()=>{const{id:e,project:t}=S(),[a,c]=p.useState(),r=async o=>{const{data:u}=await new E().request({url:`/elastic/jwt/${o} `,type:v.get});u&&c(u.kibanaUrl)};return p.useEffect(()=>{r(e)},[e]),o=>`${a}security_tenant=private#${G({projectName:(t==null?void 0:t.projectName)??"",deploymentName:o})}`};export{B as D,U as S,O as a,q as u};
