import{u as e,j as a,o as t,g as r,b as s,h as o,s as l,c as u,e as n}from"./index-5CctA6VU.js";import{m as c,u as p,a as h,C as i}from"./chart-B9YFdgqs.js";import"./SLLoading-CnnPDveI.js";const d={__name:"ChartsPage",props:{groups:{type:Array,required:!0},charts:{type:Array,required:!0},defaultColor:{type:String,required:!0},getColor:{type:Function,required:!0}},setup(l){const u=l,n=e(),d=new Map;a(()=>{d.forEach(e=>{clearInterval(e)})});const g=(e,a,t)=>{e.map(e=>{if(0===n.experiments.find(a=>a.name===e).show)return t(e,null,null);m(e,a,t),0===n.experiments.find(a=>a.name===e).status&&((e,a,t)=>{const r=setInterval(()=>{m(e,a,t)},5e3);d.set(e+"-"+a,r)})(e,a,t)})},m=(e,a,t)=>{const r=n.experiments.find(a=>a.name===e).id,s=u.charts.find(e=>e.id===a).name;o.get(`/experiment/${r}/tag/${s}`).then(a=>{t(e,a.data,null)}).catch(()=>{t(e,null,null)})};return(e,a)=>(t(),r(i,{groups:l.groups,"update-chart-status":s(h),"update-namespace-status":s(p),media:s(c),"default-color":l.defaultColor,"get-color":l.getColor,subscribe:g},null,8,["groups","update-chart-status","update-namespace-status","media","default-color","get-color"]))}},g={class:"flex flex-col min-h-full bg-higher"},m={key:1,class:"font-semibold pt-5 text-center"},f={__name:"ChartsView",setup(c){const p=e();o.get("/project/charts").then(({data:e})=>{f.value=e.charts,v.value=e.namespaces,i.value=C(),h.value=!0});const h=l(!1),i=l([]),f=l([]),v=l([]),y=l(0),C=()=>{const e=[];return v.value.forEach(a=>{const t={...a,charts:[]};a.charts.forEach(e=>{const a=f.value.find(a=>a.id===e);if(a.source.every(e=>!p.showMap[e]))return;a.source.filter(e=>!a.error[e]).every(e=>!p.showMap[e])||t.charts.push(a)}),t.charts.length&&e.push(t)}),e};p.registerChangeShowCallback(()=>{y.value++,i.value=C()}),a(()=>{p.destoryChangeShowCallback()});const x=(()=>{const e=p.colorMap;return a=>e[a]})(),b=p.colors[0];return(e,a)=>(t(),u("div",g,[i.value.length?(t(),r(d,{groups:i.value,charts:f.value,"default-color":s(b),"get-color":s(x),key:y.value},null,8,["groups","charts","default-color","get-color"])):h.value?(t(),u("p",m,"Empty Charts")):n("",!0)]))}};export{f as default};
