import{cJ as l,fh as T,T as N,fi as h,eM as d}from"./index-_eM6l4Nf.js";var v=(e=>(e.NODE="NODE",e.KUBE_CLUSTER="KUBE_CLUSTER",e.LOAD_BALANCER="LOAD_BALANCER",e))(v||{}),g=(e=>(e.HTTP="HTTP",e.HTTPS="HTTPS",e.STATUS="STATUS",e.TLS="TLS",e))(g||{});const E=(e,r,t)=>{const s=t?e.hopsworksInferencePath:e.modelServerInferencePath;return!t&&e.modelServer===l.VLLM?`${s}${r}`:`${s}:${r}`},D=(e,r)=>`${e.hopsworksInferencePath}:${r}/test`,R={name:({name:e},{name:r})=>e.localeCompare(r),"last created":({created:e},{created:r})=>{const t=new Date(e).getTime(),s=new Date(r).getTime();return t===s?0:t<s?1:-1}},O=(e,r)=>{const t=R[r];return t?e.sort(t):e},S=(e,r)=>r?e.filter(t=>t.name.toLowerCase().includes(r.toLowerCase())):e,f=(e,{selectedModel:r,selectedStatuses:t,selectedUsername:s})=>{let o=e;return r&&r!=="ANY"&&(r==="NONE"?o=o.filter(n=>!n.modelName):o=o.filter(n=>n.modelName===r)),t!=null&&t.length&&(o=o.filter(n=>t.includes(n.status.toLowerCase()))),s?o.filter(n=>n.creator.toLowerCase()===s):o},$=e=>T(N("modelName"),e).filter(h("modelName")).map(r=>r.modelName),L=e=>e.batchingEnabled?e:{},u=(e,r)=>{if(e&&r)return"ALL";if(e)return"MODEL_INPUTS";if(r)return"PREDICTIONS"},p=(e,r,t,s)=>{let o=e.substring(e.lastIndexOf("/")+1);return e.endsWith(`Models/${s}/${t}/Artifacts/${r}/${o}`)?(o.startsWith("predictor-")?o=o.slice(10):o.startsWith("transformer-")?o=o.slice(12):o.startsWith("configfile-")&&(o=o.slice(11)),o):e},P=({formValues:e,apiValues:r={},project:t})=>({...r,modelServer:e.modelServer,name:e.name,description:e.description,modelName:e.modelName,...e.modelName?{modelPath:`/Projects/${t.projectName}/Models/${e.modelName}`,modelVersion:e.modelVersion,modelFramework:e.modelFramework}:{},artifactVersion:e.artifactVersion,servingTool:e.kserve?"KSERVE":"DEFAULT",...e.environmentDTO?{environmentDTO:e.environmentDTO}:{},...e.kserve?{apiProtocol:e.apiProtocol}:{},predictor:e.predictor?p(e.predictor,e.artifactVersion,e.modelVersion,e.modelName):void 0,transformer:e.transformer?p(e.transformer,e.artifactVersion,e.modelVersion,e.modelName):void 0,configFile:e.configFile?p(e.configFile,e.artifactVersion,e.modelVersion,e.modelName):void 0,inferenceLogging:u(e.modelInput,e.predictions),kafkaTopicDTO:e.kafkaTopicDTO,batchingConfiguration:L(e.batchingConfiguration),requestedInstances:e.requestedInstances,requestedTransformerInstances:e.transformer?e.requestedTransformerInstances:void 0,predictorResources:{requests:{cores:e.predictorResources.cores[0],memory:e.predictorResources.memory[0],gpus:e.predictorResources.gpus},limits:{cores:e.predictorResources.cores[1],memory:e.predictorResources.memory[1],gpus:e.predictorResources.gpus}},transformerResources:e.transformer&&e.transformerResources?{requests:{cores:e.transformerResources.cores[0],memory:e.transformerResources.memory[0],gpus:e.transformerResources.gpus},limits:{cores:e.transformerResources.cores[1],memory:e.transformerResources.memory[1],gpus:e.transformerResources.gpus}}:void 0,schedulingConfig:e.schedulingConfig}),C=e=>{if(!e)return e;const{kafkaTopicDTO:r,inferenceLogging:t}=e,{predictorResources:s,transformerResources:o}=e,n=s.requests,a=s.limits,i=o==null?void 0:o.requests,c=o==null?void 0:o.limits;return{...e,kafkaTopicDTO:r??{name:"NONE"},inferenceLogging:t??"NONE",predictorResources:{cores:[n.cores,a.cores],memory:[n.memory,a.memory],gpus:n.gpus},transformerResources:i&&c?{cores:[i.cores,c.cores],memory:[i.memory,c.memory],gpus:i.gpus}:void 0}},I=[{label:"predict",value:"predict"},{label:"regress",value:"regress"},{label:"classify",value:"classify"}],y=[{label:"predict",value:"predict"}],b=[{label:"v1/chat/completions",value:"v1/chat/completions"},{label:"v1/completions",value:"v1/completions"}],k=[{label:"openai/v1/chat/completions",value:"openai/v1/chat/completions"},{label:"openai/v1/completions",value:"openai/v1/completions"}],A=(e,r)=>{const t=E(e,r,!0);try{return new URL(`${d}${t===void 0?"":t}`).href}catch{return`${d}${t}`}},w=(e,r,t)=>{const s=t.ports.find(m=>m.name===g.HTTP),o=t.ports.find(m=>m.name===g.HTTPS),n=o?o.number:s==null?void 0:s.number,a=o?"https":"http",i=E(e,r,!1);let c=`${a}://${t.hosts[0]}`;return n!==80&&n!==443&&(c+=`:${n}`),new URL(i===void 0?"/":i,c).href},M=(e,r,t)=>`${r}.${e.replaceAll("_","-")}.${t}`.toLowerCase();export{v as I,b as K,I as N,k as a,y as b,M as c,D as d,P as e,C as f,w as g,A as h,$ as i,S as j,O as k,f as l,R as s};
