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