import{u as e,k as a,o as t,g as r,d as s,h as o,i as l,a as u,f as n}from"./index-mtICtCH6.js";import{u as c,a as p,m as h,C as i}from"./chart-C_A2TaVz.js";import"./SLLoading-Ba4myrl9.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);f(e,a,t),0===n.experiments.find((a=>a.name===e)).status&&((e,a,t)=>{const r=setInterval((()=>{f(e,a,t)}),5e3);d.set(e+"-"+a,r)})(e,a,t)}))},f=(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(c),"update-namespace-status":s(p),media:s(h),"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"},f={key:1,class:"font-semibold pt-5 text-center"},m={__name:"ChartsView",setup(c){const p=e();o.get("/project/charts").then((({data:e})=>{m.value=e.charts,v.value=e.namespaces,i.value=C(),h.value=!0}));const h=l(!1),i=l([]),m=l([]),v=l([]),y=l(0),C=()=>{const e=[];return v.value.forEach((a=>{const t={...a,charts:[]};a.charts.forEach((e=>{const a=m.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]})(),w=p.colors[0];return(e,a)=>(t(),u("div",g,[i.value.length?(t(),r(d,{groups:i.value,charts:m.value,"default-color":s(w),"get-color":s(x),key:y.value},null,8,["groups","charts","default-color","get-color"])):h.value?(t(),u("p",f,"Empty Charts")):n("",!0)]))}};export{m as default};
