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