function getChartColorsArray(t){const e=document.getElementById(t);if(!e)return null;return JSON.parse(e.getAttribute("data-colors")).map((t=>{if(-1===(t=t.trim()).indexOf(",")){return getComputedStyle(document.documentElement).getPropertyValue(t)||t}{let e=t.split(",");if(2===e.length){return`rgba(${getComputedStyle(document.documentElement).getPropertyValue(e[0])},${e[1]})`}return t}}))}const METRICS={"Heart Rate":{base:75,min:60,max:100,variation:8,unit:" bpm"},"Blood Pressure":{base:120,min:80,max:160,variation:10,unit:" mmHg"},"Oxygen Levels":{base:98,min:95,max:100,variation:2,unit:"%"},"Overall Status":{base:85,min:70,max:100,variation:12,unit:"%"}};function generateData(t){const{base:e,min:a,max:r,variation:o}=METRICS[t],n=[],i=new Date;i.setDate(i.getDate()-30);for(let s=0;s<30;s++){const l=new Date(i);l.setDate(l.getDate()+s);const m=e+(Math.random()-.5)*o+("Overall Status"===t?6*Math.cos(.15*s):5*Math.sin(.2*s));n.push({x:l.getTime(),y:Math.max(a,Math.min(r,m))})}return n}const colors=getChartColorsArray("healthChart"),chart=new ApexCharts(document.querySelector("#healthChart"),{series:[{name:"Heart Rate",data:generateData("Heart Rate")}],chart:{type:"area",height:136,toolbar:{show:!1},zoom:{enabled:!1}},dataLabels:{enabled:!1},stroke:{curve:"smooth",width:2,colors:colors},fill:{type:"gradient",gradient:{shadeIntensity:1,opacityFrom:.3,opacityTo:0,gradientToColors:colors,stops:[0,100]}},grid:{borderColor:"#e9ecef",strokeDashArray:3,xaxis:{lines:{show:!1}},yaxis:{lines:{show:!0}},padding:{top:-10,right:0,bottom:0}},xaxis:{type:"datetime",labels:{style:{colors:"#8e8da4",fontSize:"11px"},format:"MMM dd"},axisBorder:{show:!1},axisTicks:{show:!1}},yaxis:{show:!1,min:60,max:100},tooltip:{theme:"light",x:{format:"dd MMM yyyy"},y:{formatter:t=>t.toFixed(1)+" bpm"}},colors:colors});chart.render(),document.querySelectorAll(".nav .nav-link").forEach((t=>{t.addEventListener("click",(()=>{document.querySelectorAll(".nav .nav-link").forEach((t=>t.classList.remove("active"))),t.classList.add("active");const e=t.textContent.trim(),a=METRICS[e];chart.updateOptions({yaxis:{min:a.min,max:a.max},tooltip:{y:{formatter:t=>t.toFixed(1)+a.unit}}}),chart.updateSeries([{name:e,data:generateData(e)}])}))}));