import{r as c}from"./react-C1sqhVEE.js";import{d as s,_ as l,e as u}from"./Settings-C7_TiiRH.js";import{j as m}from"./ui-cEB64NN_.js";import{u as d,i as p,a as h,b,c as g,d as v,e as f,f as y}from"./echarts-gihz4qUC.js";d([p,h,b,g,v,f,y]);const S={show:!0,rotate:90,formatter:"{c}",fontSize:12,color:"#065f9f",rich:{name:{}}},$=function(e){const a=e[0];let o=`<strong>${a.name}</strong><br/>`;const i=e[1],t=a.value?(i.value/a.value).toLocaleString(void 0,{style:"percent",minimumFractionDigits:1}):"n/a",r=e[2],n=a.value?(r.value/a.value).toLocaleString(void 0,{style:"percent",minimumFractionDigits:1}):"n/a";return a.value?(o+=`<small>Transactions: ${a.value}<br/>`,o+=`Cached: ${r.value} (${n})<br/>`,o+=`Errors: ${i.value} (${t})<br/>`,o+="</small>"):o+="<small>No transactions</small>",o},w=({data:e,timeRange:a})=>{const o=c.useMemo(()=>{const i=t=>{const r=new Date(t);switch(a){case"1h":return r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});case"24h":return r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});case"7d":return r.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"});case"1m":return r.toLocaleDateString(void 0,{month:"short",day:"numeric"});case"1y":return r.toLocaleDateString(void 0,{month:"short",year:"numeric"});default:return r.toLocaleDateString()}};return{...s,xAxis:{type:"category",data:e.map(t=>i(t.datetime))},yAxis:{type:"value"},tooltip:{...s.tooltip,formatter:$},series:[{name:"transactions",data:e.map(t=>t.count),type:"bar",color:"#ADD8E6",barWidth:"30px",label:S},{name:"errors",data:e.map(t=>t.errors),type:"bar",barWidth:"10px",barGap:"0",color:"#e6adad",stack:"details"},{name:"cached",data:e.map(t=>t.cached),type:"bar",barWidth:"10px",barGap:"0",color:"#b9e6ad",stack:"details"},{name:"rest",data:e.map(t=>t.count-t.errors-t.cached),type:"bar",barWidth:"10px",barGap:"0",color:"#e5e5e5",stack:"details"}]}},[e,a]);return m(l,{echarts:u,option:o,notMerge:!0,lazyUpdate:!0,opts:{height:300,width:"auto"}})};export{w as default};
