'use client';
import{__rest as e}from"tslib";import t,{useState as a}from"react";import{twMerge as o}from"tailwind-merge";import{ResponsiveContainer as i,AreaChart as r,CartesianGrid as n,XAxis as l,YAxis as s,Tooltip as m,Legend as c,Area as d}from"recharts";import{constructCategoryColors as p,getYAxisDomain as h}from"../common/utils.js";import u from"../common/ChartLegend.js";import y from"../common/ChartTooltip.js";import f from"../common/NoData.js";import{hexColors as v}from"../../../lib/hexColors.js";import{BaseColors as w}from"../../../lib/constants.js";import{themeColorRange as x}from"../../../lib/theme.js";import{defaultValueFormatter as g}from"../../../lib/utils.js";const E=t.forwardRef(((E,k)=>{const{data:A=[],categories:D=[],index:b,stack:j=!1,colors:C=x,valueFormatter:G=g,startEndOnly:L=!1,showXAxis:T=!0,showYAxis:N=!0,yAxisWidth:F=56,showAnimation:O=!0,animationDuration:V=1500,showTooltip:S=!0,showLegend:W=!0,showGridLines:z=!0,showGradient:I=!0,autoMinValue:H=!1,curveType:K="linear",minValue:M,maxValue:X,connectNulls:Y=!1,allowDecimals:R=!0,className:$,noDataText:q}=E,B=e(E,["data","categories","index","stack","colors","valueFormatter","startEndOnly","showXAxis","showYAxis","yAxisWidth","showAnimation","animationDuration","showTooltip","showLegend","showGridLines","showGradient","autoMinValue","curveType","minValue","maxValue","connectNulls","allowDecimals","className","noDataText"]),[J,P]=a(60),Q=p(D,C),U=h(H,M,X);return t.createElement("div",Object.assign({ref:k,className:o("w-full h-80",$)},B),t.createElement(i,{width:"100%",height:"100%"},(null==A?void 0:A.length)?t.createElement(r,{data:A},z?t.createElement(n,{strokeDasharray:"3 3",horizontal:!0,vertical:!1}):null,t.createElement(l,{hide:!T,dataKey:b,tick:{transform:"translate(0, 6)"},ticks:L?[A[0][b],A[A.length-1][b]]:void 0,style:{fontSize:"12px",fontFamily:"Inter; Helvetica",color:"red"},interval:"preserveStartEnd",tickLine:!1,axisLine:!1,padding:{left:10,right:10},minTickGap:5}),t.createElement(s,{width:F,hide:!N,axisLine:!1,tickLine:!1,type:"number",domain:U,tick:{transform:"translate(-3, 0)"},style:{fontSize:"12px",fontFamily:"Inter; Helvetica"},tickFormatter:G,allowDecimals:R}),S?t.createElement(m,{wrapperStyle:{outline:"none"},isAnimationActive:!1,cursor:{stroke:"#d1d5db",strokeWidth:1},content:({active:e,payload:a,label:o})=>t.createElement(y,{active:e,payload:a,label:o,valueFormatter:G,categoryColors:Q}),position:{y:0}}):null,W?t.createElement(c,{verticalAlign:"top",height:J,content:({payload:e})=>u({payload:e},Q,P)}):null,D.map((e=>{var a;const o=v[null!==(a=Q.get(e))&&void 0!==a?a:w.Gray];return t.createElement("defs",{key:e},I?t.createElement("linearGradient",{id:Q.get(e),x1:"0",y1:"0",x2:"0",y2:"1"},t.createElement("stop",{offset:"5%",stopColor:o,stopOpacity:.4}),t.createElement("stop",{offset:"95%",stopColor:o,stopOpacity:0})):t.createElement("linearGradient",{id:Q.get(e),x1:"0",y1:"0",x2:"0",y2:"1"},t.createElement("stop",{stopColor:o,stopOpacity:.3})))})),D.map((e=>{var a;return t.createElement(d,{key:e,name:e,type:K,dataKey:e,stroke:v[null!==(a=Q.get(e))&&void 0!==a?a:w.Gray],fill:`url(#${Q.get(e)})`,strokeWidth:2,dot:!1,isAnimationActive:O,animationDuration:V,stackId:j?"a":void 0,connectNulls:Y})}))):t.createElement(f,{noDataText:q})))}));E.displayName="AreaChart";export{E as default};
