import{ac as w,r as d,j as a,a as t,aT as H,g5 as I}from"./index-d6499a22.js";const j=[{duration:"5m",label:"5 min"},{duration:"15m",label:"15 min"},{duration:"30m",label:"30 min"},{duration:"1h",label:"1 hr"},{duration:"5h",label:"5 hr"},{duration:"24h",label:"24 hr"}],e={THEME:"light",DURATION_TO:"now",REFRESH:"10s",HEIGHT:"300px",PANEL_WIDTH:"50%",DURATION_FROM:"15m"},O=({panels:n,panelDurationsControls:i=j})=>{const{colorMode:l}=w(),[s,o]=d.useState(e.DURATION_FROM),u=({urlPath:r,refresh:m=e.REFRESH,theme:f=e.THEME,variables:x,panelId:E,duration:T=s,to:b=e.DURATION_TO})=>{const D={...x.reduce((R,c)=>({...R,[`var-${c.name}`]:c.value}),{}),theme:f,refresh:m,panelId:E,from:`now-${T}`,to:b,orgId:1},g=I.stringify(D);return`/hopsworks-api/${r}?${g}`},h=d.useCallback(r=>()=>{o(r)},[o]);return a.jsxs(a.Fragment,{children:[i.length>0&&a.jsx(t,{flexDirection:"row",mb:20,children:i.map(r=>a.jsx(H,{onClick:h(r.duration),intent:r.duration===s?"primary":"secondary",children:r.label},`option-${r.label}`))}),n.length>0&&a.jsx(t,{justifyContent:"space-between",alignItems:"center",flexDirection:"row",flexWrap:"wrap",sx:{...l==="dark"?{filter:"invert(92%)"}:{}},children:n.map(r=>a.jsx(t,{width:r.width??e.PANEL_WIDTH,sx:{...l==="dark"&&{filter:"invert(92%)"}},children:a.jsx("iframe",{title:r.title,src:u({...r.linkParams}),width:"100%",height:r.height??e.HEIGHT,frameBorder:"0"})},`panel-${r.title.replace(/\s/g,"")}`))})]})};export{O as G};
