@undp/data-viz 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AreaChart.cjs +1 -1
- package/dist/AreaChart.js +21 -21
- package/dist/BarGraph.cjs +1 -1
- package/dist/BarGraph.js +7 -7
- package/dist/BeeSwarmChart.cjs +1 -1
- package/dist/BeeSwarmChart.js +2 -2
- package/dist/BiVariateChoroplethMap.cjs +1 -1
- package/dist/BiVariateChoroplethMap.js +5 -5
- package/dist/BulletChart.cjs +1 -1
- package/dist/BulletChart.js +14 -14
- package/dist/ButterflyChart.cjs +1 -1
- package/dist/ButterflyChart.js +9 -9
- package/dist/ChoroplethMap.cjs +1 -1
- package/dist/ChoroplethMap.js +9 -9
- package/dist/CirclePackingGraph.cjs +1 -1
- package/dist/CirclePackingGraph.js +1 -1
- package/dist/CopyTextButton.cjs +7 -7
- package/dist/CopyTextButton.cjs.map +1 -1
- package/dist/CopyTextButton.js +4 -4
- package/dist/CopyTextButton.js.map +1 -1
- package/dist/DataCards.cjs +9 -9
- package/dist/DataCards.cjs.map +1 -1
- package/dist/DataCards.js +93 -93
- package/dist/DataCards.js.map +1 -1
- package/dist/DifferenceLineChart.cjs +1 -1
- package/dist/DifferenceLineChart.js +18 -18
- package/dist/DonutChart.cjs +1 -1
- package/dist/DonutChart.js +1 -1
- package/dist/DotDensityMap.cjs +1 -1
- package/dist/DotDensityMap.js +8 -8
- package/dist/{DropdownSelect-0I2QxaVy.cjs → DropdownSelect-BmE5JaeE.cjs} +6 -6
- package/dist/{DropdownSelect-0I2QxaVy.cjs.map → DropdownSelect-BmE5JaeE.cjs.map} +1 -1
- package/dist/{DropdownSelect-CDC9lEqU.js → DropdownSelect-CeHog_ih.js} +4 -4
- package/dist/{DropdownSelect-CDC9lEqU.js.map → DropdownSelect-CeHog_ih.js.map} +1 -1
- package/dist/DualAxisLineChart.cjs +1 -1
- package/dist/DualAxisLineChart.js +15 -15
- package/dist/DumbbellChart.cjs +1 -1
- package/dist/DumbbellChart.js +13 -13
- package/dist/GeoHubMap.cjs +1 -1
- package/dist/GeoHubMap.js +2 -2
- package/dist/GeoHubMapWithLayerSelection.cjs +1 -1
- package/dist/GeoHubMapWithLayerSelection.js +2 -2
- package/dist/{GraphEl-B6SoGRFW.cjs → GraphEl-B5gAX1IQ.cjs} +2 -2
- package/dist/{GraphEl-B6SoGRFW.cjs.map → GraphEl-B5gAX1IQ.cjs.map} +1 -1
- package/dist/{GraphEl-Cw2tDUb3.js → GraphEl-BdIyscdt.js} +3 -3
- package/dist/{GraphEl-Cw2tDUb3.js.map → GraphEl-BdIyscdt.js.map} +1 -1
- package/dist/GriddedGraphs.cjs +1 -1
- package/dist/GriddedGraphs.js +4 -4
- package/dist/GriddedGraphsFromConfig.cjs +1 -1
- package/dist/GriddedGraphsFromConfig.js +1 -1
- package/dist/HeatMap.cjs +1 -1
- package/dist/HeatMap.js +10 -10
- package/dist/Histogram.cjs +1 -1
- package/dist/Histogram.js +1 -1
- package/dist/LineChartWithConfidenceInterval.cjs +1 -1
- package/dist/LineChartWithConfidenceInterval.js +21 -21
- package/dist/{Modal-CUU6ZK3U.js → Modal-DVVwpKhP.js} +2 -2
- package/dist/{Modal-CUU6ZK3U.js.map → Modal-DVVwpKhP.js.map} +1 -1
- package/dist/{Modal-C_dl0EtQ.cjs → Modal-tXZlLE5s.cjs} +4 -4
- package/dist/{Modal-C_dl0EtQ.cjs.map → Modal-tXZlLE5s.cjs.map} +1 -1
- package/dist/MultiGraphDashboard.cjs +1 -1
- package/dist/MultiGraphDashboard.js +3 -3
- package/dist/MultiGraphDashboardFromConfig.cjs +1 -1
- package/dist/MultiGraphDashboardFromConfig.js +1 -1
- package/dist/MultiGraphDashboardWideToLongFormat.cjs +1 -1
- package/dist/MultiGraphDashboardWideToLongFormat.js +3 -3
- package/dist/MultiGraphDashboardWideToLongFormatFromConfig.cjs +1 -1
- package/dist/MultiGraphDashboardWideToLongFormatFromConfig.js +1 -1
- package/dist/MultiLineAltChart.cjs +1 -1
- package/dist/MultiLineAltChart.js +21 -21
- package/dist/MultiLineChart.cjs +1 -1
- package/dist/MultiLineChart.js +19 -19
- package/dist/ParetoChart.cjs +1 -1
- package/dist/ParetoChart.js +12 -12
- package/dist/PerformanceIntensiveMultiGraphDashboard.cjs +1 -1
- package/dist/PerformanceIntensiveMultiGraphDashboard.js +3 -3
- package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.cjs +1 -1
- package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.js +1 -1
- package/dist/PerformanceIntensiveScrollStory.cjs +1 -1
- package/dist/PerformanceIntensiveScrollStory.js +2 -2
- package/dist/RadarChart.cjs +1 -1
- package/dist/RadarChart.js +8 -8
- package/dist/{ReferenceLine-CuFMk0cI.cjs → ReferenceLine-CFVBBN__.cjs} +2 -2
- package/dist/{ReferenceLine-CuFMk0cI.cjs.map → ReferenceLine-CFVBBN__.cjs.map} +1 -1
- package/dist/{ReferenceLine-C1GpoG9d.js → ReferenceLine-CfAW3vKJ.js} +2 -2
- package/dist/{ReferenceLine-C1GpoG9d.js.map → ReferenceLine-CfAW3vKJ.js.map} +1 -1
- package/dist/{RegressionLine-BFwDCTUU.js → RegressionLine-mH7UKOPi.js} +3 -3
- package/dist/{RegressionLine-BFwDCTUU.js.map → RegressionLine-mH7UKOPi.js.map} +1 -1
- package/dist/{RegressionLine-7_rKTHN_.cjs → RegressionLine-xKdiJ8sw.cjs} +2 -2
- package/dist/{RegressionLine-7_rKTHN_.cjs.map → RegressionLine-xKdiJ8sw.cjs.map} +1 -1
- package/dist/SankeyChart.cjs +1 -1
- package/dist/SankeyChart.js +4 -4
- package/dist/ScatterPlot.cjs +1 -1
- package/dist/ScatterPlot.js +13 -13
- package/dist/ScrollStory.cjs +1 -1
- package/dist/ScrollStory.js +2 -2
- package/dist/SimpleLineChart.cjs +1 -1
- package/dist/SimpleLineChart.js +20 -20
- package/dist/SingleGraphDashboard.cjs +1 -1
- package/dist/SingleGraphDashboard.js +4 -4
- package/dist/SingleGraphDashboardFromConfig.cjs +1 -1
- package/dist/SingleGraphDashboardFromConfig.js +1 -1
- package/dist/SingleGraphDashboardGeoHubMapsFromConfig.cjs +1 -1
- package/dist/SingleGraphDashboardGeoHubMapsFromConfig.js +1 -1
- package/dist/SingleGraphDashboardThreeDGraphs.cjs +1 -1
- package/dist/SingleGraphDashboardThreeDGraphs.js +3 -3
- package/dist/SingleGraphDashboardThreeDGraphsFromConfig.cjs +1 -1
- package/dist/SingleGraphDashboardThreeDGraphsFromConfig.js +1 -1
- package/dist/SlopeChart.cjs +1 -1
- package/dist/SlopeChart.js +7 -7
- package/dist/StripChart.cjs +1 -1
- package/dist/StripChart.js +9 -9
- package/dist/ThreeDGlobe.cjs +1 -1
- package/dist/ThreeDGlobe.js +2 -2
- package/dist/TreeMapGraph.cjs +1 -1
- package/dist/TreeMapGraph.js +4 -4
- package/dist/UnitChart.cjs +1 -1
- package/dist/UnitChart.js +3 -3
- package/dist/{XAxesLabels-DQFo_z2R.js → XAxesLabels-CaV2q-6H.js} +2 -2
- package/dist/{XAxesLabels-DQFo_z2R.js.map → XAxesLabels-CaV2q-6H.js.map} +1 -1
- package/dist/{XAxesLabels-CJMQbfVy.cjs → XAxesLabels-OjBNl_lS.cjs} +2 -2
- package/dist/{XAxesLabels-CJMQbfVy.cjs.map → XAxesLabels-OjBNl_lS.cjs.map} +1 -1
- package/dist/{YAxesLabels-H5-002X5.js → YAxesLabels-CPGZjmZJ.js} +2 -2
- package/dist/{YAxesLabels-H5-002X5.js.map → YAxesLabels-CPGZjmZJ.js.map} +1 -1
- package/dist/{YAxesLabels-BXLTX7AI.cjs → YAxesLabels-D8IydyZj.cjs} +2 -2
- package/dist/{YAxesLabels-BXLTX7AI.cjs.map → YAxesLabels-D8IydyZj.cjs.map} +1 -1
- package/dist/{checkIfMultiple-Do4kADNr.cjs → checkIfMultiple-BXbHUCWM.cjs} +6 -6
- package/dist/{checkIfMultiple-Do4kADNr.cjs.map → checkIfMultiple-BXbHUCWM.cjs.map} +1 -1
- package/dist/{checkIfMultiple-CYp3vADF.js → checkIfMultiple-ChTJk2Tk.js} +5 -5
- package/dist/{checkIfMultiple-CYp3vADF.js.map → checkIfMultiple-ChTJk2Tk.js.map} +1 -1
- package/dist/{customArea-CaxScFmW.js → customArea-B-dWU0zZ.js} +2 -2
- package/dist/{customArea-CaxScFmW.js.map → customArea-B-dWU0zZ.js.map} +1 -1
- package/dist/{customArea-BYNyxAkm.cjs → customArea-CK768gCn.cjs} +2 -2
- package/dist/{customArea-BYNyxAkm.cjs.map → customArea-CK768gCn.cjs.map} +1 -1
- package/dist/{fetchAndParseData-Bcmr659B.js → fetchAndParseData-4gsYTy6_.js} +3 -3
- package/dist/fetchAndParseData-4gsYTy6_.js.map +1 -0
- package/dist/{fetchAndParseData-DmgQtB9n.cjs → fetchAndParseData-CQyVGCul.cjs} +6 -6
- package/dist/fetchAndParseData-CQyVGCul.cjs.map +1 -0
- package/dist/fetchAndParseData.cjs +1 -1
- package/dist/fetchAndParseData.js +1 -1
- package/dist/index-BW8iNx7E.cjs +10 -0
- package/dist/index-BW8iNx7E.cjs.map +1 -0
- package/dist/index-CNvov0eg.js +122 -0
- package/dist/index-CNvov0eg.js.map +1 -0
- package/dist/{index-D_n8aamX.cjs → index-CZLvTu6p.cjs} +2 -2
- package/dist/{index-D_n8aamX.cjs.map → index-CZLvTu6p.cjs.map} +1 -1
- package/dist/{index-n_RI8T0n.js → index-Cdcfp4nk.js} +2 -2
- package/dist/{index-n_RI8T0n.js.map → index-Cdcfp4nk.js.map} +1 -1
- package/dist/{index-BVnYktl4.js → index-DGAaLNu9.js} +2 -2
- package/dist/{index-BVnYktl4.js.map → index-DGAaLNu9.js.map} +1 -1
- package/dist/{index-CylX-pWB.cjs → index-DNj994Pv.cjs} +2 -2
- package/dist/{index-CylX-pWB.cjs.map → index-DNj994Pv.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/proxy-BHRoeZgd.cjs +2 -0
- package/dist/proxy-BHRoeZgd.cjs.map +1 -0
- package/dist/{proxy-DJxJg1kD.js → proxy-CkpFesk1.js} +4123 -4075
- package/dist/proxy-CkpFesk1.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/transformData.cjs +1 -1
- package/dist/transformData.js +2 -2
- package/dist/{transformDataForGraphFromFile-D9G3ToQf.cjs → transformDataForGraphFromFile-B1A0AS-Z.cjs} +2 -2
- package/dist/{transformDataForGraphFromFile-D9G3ToQf.cjs.map → transformDataForGraphFromFile-B1A0AS-Z.cjs.map} +1 -1
- package/dist/{transformDataForGraphFromFile-CA0rw80A.js → transformDataForGraphFromFile-BCjsizvb.js} +2 -2
- package/dist/{transformDataForGraphFromFile-CA0rw80A.js.map → transformDataForGraphFromFile-BCjsizvb.js.map} +1 -1
- package/dist/{use-in-view-BCmzDU2O.cjs → use-in-view-sQJZ_xDO.cjs} +2 -2
- package/dist/use-in-view-sQJZ_xDO.cjs.map +1 -0
- package/dist/{use-in-view-BAHrBy6b.js → use-in-view-yS6jzJAp.js} +2 -2
- package/dist/use-in-view-yS6jzJAp.js.map +1 -0
- package/dist/x-BBpi7a_7-Dz2vKSfu.cjs +27 -0
- package/dist/x-BBpi7a_7-Dz2vKSfu.cjs.map +1 -0
- package/dist/x-BBpi7a_7-WVdj1j6r.js +106 -0
- package/dist/x-BBpi7a_7-WVdj1j6r.js.map +1 -0
- package/package.json +50 -51
- package/dist/fetchAndParseData-Bcmr659B.js.map +0 -1
- package/dist/fetchAndParseData-DmgQtB9n.cjs.map +0 -1
- package/dist/index-BxAUvrua.js +0 -120
- package/dist/index-BxAUvrua.js.map +0 -1
- package/dist/index-DVOJ7vxH.cjs +0 -10
- package/dist/index-DVOJ7vxH.cjs.map +0 -1
- package/dist/proxy-DJxJg1kD.js.map +0 -1
- package/dist/proxy-PQd2AItT.cjs +0 -2
- package/dist/proxy-PQd2AItT.cjs.map +0 -1
- package/dist/use-in-view-BAHrBy6b.js.map +0 -1
- package/dist/use-in-view-BCmzDU2O.cjs.map +0 -1
- package/dist/x-CnsEH4Ox-CGGXQl4M.cjs +0 -27
- package/dist/x-CnsEH4Ox-CGGXQl4M.cjs.map +0 -1
- package/dist/x-CnsEH4Ox-DDvAJndW.js +0 -101
- package/dist/x-CnsEH4Ox-DDvAJndW.js.map +0 -1
package/dist/AreaChart.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),h=require("react"),u=require("./parse-hMnG_lRV.cjs"),de=require("./index-BzeLQvXk.cjs"),ue=require("./index-C21TvELx.cjs"),he=require("./numberFormattingFunction-02t-wJta.cjs"),fe=require("./Tooltip-n8z5bfav.cjs"),Z=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),me=require("./customArea-BYNyxAkm.cjs"),ye=require("./AxisTitle-CK9YeovX.cjs"),je=require("./Axis-DE7dSn1_.cjs"),ve=require("./XTicksAndGridLines-CCzXIV8d.cjs"),we=require("./ReferenceLine-CuFMk0cI.cjs"),Re=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Ee=require("./index-CylX-pWB.cjs"),Ae=require("./use-in-view-BCmzDU2O.cjs"),Ce=require("./time-Byw_jYQ7.cjs"),be=require("./linear-BVckp9RD.cjs"),Oe=require("./area-D3Qx7k7K.cjs"),qe=require("./line-DHV4JwCR.cjs"),ee=require("./step-BZ3C8QFW.cjs"),Ne=require("./select-Bnfk0lJx.cjs"),te=require("./proxy-PQd2AItT.cjs"),Se=require("./index-DVOJ7vxH.cjs"),$e=require("./init-DU0ybBc_.cjs"),ke=require("./pointer-Dkq5NV1q.cjs"),Le=require("./GraphFooter.cjs"),Te=require("./GraphHeader.cjs"),De=require("./ColorLegend.cjs"),Me=require("./Colors.cjs"),Fe=require("./EmptyState-d8_8SxeW.cjs");function He(se){const{data:w,width:R,height:q,colors:G,dateFormat:o,noOfXTicks:N,rightMargin:l,leftMargin:f,topMargin:ie,bottomMargin:re,yAxisTitle:P,tooltip:D,onSeriesMouseOver:m,highlightAreaSettings:oe,refValues:V,minValue:I,maxValue:Y,rtl:W,annotations:ne,customHighlightAreaSettings:ae,noOfYTicks:S,prefix:M,suffix:F,curveType:$,styles:p,classNames:g,precision:k,customLayers:H,animate:y}=se,E=h.useRef(null),j=Ae.useInView(E,{once:y.once,amount:y.amount}),le=$==="linear"?qe.curveLinear:$==="step"?ee.curveStep:$==="stepAfter"?ee.stepAfter:$==="stepBefore"?ee.stepBefore:ee.monotoneX,[b,X]=h.useState(void 0),[U,B]=h.useState(void 0),[_,z]=h.useState(void 0),d={top:ie,bottom:re,left:P?f+30:f,right:l},J=h.useRef(null),i=de.sortBy(w.map(e=>({...e,date:u.parse(`${e.date}`,o,new Date)})),"date"),A=oe.map(e=>({...e,coordinates:[e.coordinates[0]===null?null:u.parse(`${e.coordinates[0]}`,o,new Date),e.coordinates[1]===null?null:u.parse(`${e.coordinates[1]}`,o,new Date)]})),ce=ae.map(e=>({...e,coordinates:e.coordinates.map((n,a)=>a%2===0?u.parse(`${n}`,o,new Date):n)})),xe=i[0].y.map((e,n)=>i.map(a=>({date:a.date,y0:n===0?0:ue.sum(a.y.filter((T,O)=>O<n)),y1:ue.sum(a.y.filter((T,O)=>O<=n))}))),v=R-d.left-d.right,c=q-d.top-d.bottom,K=i[0].date,Q=i[i.length-1].date,x=Z.checkIfNullOrUndefined(I)?0:I,C=Z.checkIfNullOrUndefined(Y)?Math.max(...w.map(e=>ue.sum(e.y)||0)):Y,r=Ce.time().domain([K,Q]).range([0,v]),s=be.linear().domain([x,C]).range([c,0]).nice(),L=Oe.area().x(e=>r(e.date)).y0(e=>s(e.y0)).y1(e=>s(e.y1)).curve(le),pe=s.ticks(S),ge=r.ticks(N);return h.useEffect(()=>{const e=a=>{const T=i[$e.bisectCenter(i.map(O=>O.date),r.invert(ke.pointer(a)[0]),1)];X(T||i[i.length-1]),m?.(T||i[i.length-1]),z(a.clientY),B(a.clientX)},n=()=>{X(void 0),B(void 0),z(void 0),m?.(void 0)};Ne.select(J.current).on("mousemove",e).on("mouseout",n),m?.(void 0)},[r,i,m]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(te.motion.svg,{width:`${R}px`,height:`${q}px`,viewBox:`0 0 ${R} ${q}`,direction:"ltr",ref:E,children:t.jsxRuntimeExports.jsx(Se.AnimatePresence,{children:t.jsxRuntimeExports.jsxs(te.motion.g,{transform:`translate(${d.left},${d.top})`,children:[t.jsxRuntimeExports.jsx(Ee.HighlightArea,{areaSettings:A,width:v,height:c,scale:r,animate:y,isInView:j}),t.jsxRuntimeExports.jsx(me.CustomArea,{animate:y,areaSettings:ce,scaleX:r,scaleY:s,isInView:j}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(Re.YTicksAndGridLines,{values:pe.filter(e=>e!==0),y:pe.filter(e=>e!==0).map(e=>s(e)),x1:0-f,x2:v+d.right,styles:{gridLines:p?.yAxis?.gridLines,labels:p?.yAxis?.labels},classNames:{gridLines:g?.yAxis?.gridLines,labels:g?.yAxis?.labels},suffix:F,prefix:M,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:k}),t.jsxRuntimeExports.jsx(je.Axis,{y1:s(x<0?0:x),y2:s(x<0?0:x),x1:0-f,x2:v+d.right,label:he.numberFormattingFunction(x<0?0:x,"NA",k,M,F),labelPos:{x:0-f,dx:0,dy:C<0?"1em":-5,y:s(x<0?0:x)},classNames:{axis:g?.xAxis?.axis,label:g?.yAxis?.labels},styles:{axis:p?.xAxis?.axis,label:p?.yAxis?.labels}}),t.jsxRuntimeExports.jsx(ye.AxisTitle,{x:0-f-15,y:c/2,style:p?.yAxis?.title,className:g?.yAxis?.title,text:P,rotate90:!0})]}),t.jsxRuntimeExports.jsx(ve.XTicksAndGridLines,{values:ge.map(e=>u.format(e,o)),x:ge.map(e=>r(e)),y1:0,y2:c,styles:{gridLines:p?.xAxis?.gridLines,labels:p?.xAxis?.labels},classNames:{gridLines:t.mo("opacity-0",g?.xAxis?.gridLines),labels:t.mo("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[8px] sm:text-[9px] md:text-[10px] lg:text-xs",g?.xAxis?.labels)},suffix:F,prefix:M,labelType:"primary",showGridLines:!0,precision:k}),H.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs(te.motion.g,{children:[xe.map((e,n)=>t.jsxRuntimeExports.jsx(te.motion.path,{d:L(e),exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{d:L(e.map(a=>({...a,y0:0,y1:0}))),opacity:0},whileInView:{d:L(e),opacity:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",style:{fill:G[n],opacity:.8}},n)),b?t.jsxRuntimeExports.jsx("line",{y1:0,y2:c,x1:r(b.date),x2:r(b.date),className:t.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",g?.mouseOverLine),style:p?.mouseOverLine}):null]}),V?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:V.map((e,n)=>t.jsxRuntimeExports.jsx(we.RefLineY,{text:e.text,color:e.color,y:s(e.value),x1:0-f,x2:v+d.right,classNames:e.classNames,styles:e.styles,animate:y,isInView:j},n))}):null,t.jsxRuntimeExports.jsx("g",{children:ne.map((e,n)=>{const a=me.getLineEndPoint({x:e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),y:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8},{x:e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date)):0,y:e.yCoordinate?s(e.yCoordinate):0},Z.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius),T=e.showConnector?{y1:a.y,x1:a.x,y2:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0):0+(e.yOffset||0),x2:e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),cx:e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date)):0,cy:e.yCoordinate?s(e.yCoordinate):0,circleRadius:Z.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius,strokeWidth:e.showConnector===!0?2:Math.min(e.showConnector||0,1)}:void 0,O={y:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8,x:W?0:e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),width:W?e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0):v-(e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0)),maxWidth:e.maxWidth,fontWeight:e.fontWeight,align:e.align};return t.jsxRuntimeExports.jsx(me.Annotation,{color:e.color,connectorsSettings:T,labelSettings:O,text:e.text,classNames:e.classNames,styles:e.styles,animate:y,isInView:j},n)})}),H.filter(e=>e.position==="after").map(e=>e.layer),t.jsxRuntimeExports.jsx("rect",{ref:J,style:{fill:"none",pointerEvents:"all"},width:v,height:c})]})})}),b&&D&&U&&_?t.jsxRuntimeExports.jsx(fe.Tooltip,{data:b,body:D,xPos:U,yPos:_,backgroundStyle:p?.tooltip,className:g?.tooltip}):null]})}function Ge(se){const{data:w,graphTitle:R,colors:q=Me.Colors.light.categoricalColors.colors,sources:G,graphDescription:o,height:N,width:l,footNote:f,noOfXTicks:ie=10,dateFormat:re="yyyy",colorDomain:P,padding:D,backgroundColor:m=!1,colorLegendTitle:oe,leftMargin:V=50,rightMargin:I=20,topMargin:Y=20,bottomMargin:W=25,highlightAreaSettings:ne=[],tooltip:ae,relativeHeight:S,onSeriesMouseOver:M,refValues:F=[],graphID:$,minValue:p,maxValue:g,graphDownload:k=!1,dataDownload:H=!1,showColorScale:y=!0,language:E="en",minHeight:j=0,annotations:le=[],customHighlightAreaSettings:b=[],theme:X="light",ariaLabel:U,yAxisTitle:B,noOfYTicks:_=5,prefix:z="",suffix:d="",curveType:J="curve",styles:i,classNames:A,precision:ce=2,customLayers:xe=[],animate:v=!1}=se,[c,K]=h.useState(0),[Q,x]=h.useState(0),C=h.useRef(null),r=h.useRef(null);return h.useEffect(()=>{const s=new ResizeObserver(L=>{K(l||L[0].target.clientWidth||620),x(N||L[0].target.clientHeight||480)});return C.current&&(x(C.current.clientHeight||480),K(C.current.clientWidth||620),l||s.observe(C.current)),()=>s.disconnect()},[l,N]),t.jsxRuntimeExports.jsx("div",{className:`${X||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:E==="he"||E==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${m?m===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${E||"en"}`,A?.graphContainer),style:{...i?.graphContainer||{},...m&&m!==!0?{backgroundColor:m}:{}},id:$,ref:r,"aria-label":U||`${R?`The graph shows ${R}. `:""}This is a stacked area chart that shows trends over time.${o?` ${o}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:m?D||"1rem":D||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[R||o||k||H?t.jsxRuntimeExports.jsx(Te.GraphHeader,{styles:{title:i?.title,description:i?.description},classNames:{title:A?.title,description:A?.description},graphTitle:R,graphDescription:o,width:l,graphDownload:k?r.current:void 0,dataDownload:H?w.map(s=>s.data).filter(s=>s!==void 0).length>0?w.map(s=>s.data).filter(s=>s!==void 0):w.filter(s=>s!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:w.length===0?t.jsxRuntimeExports.jsx(Fe.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[y!==!1?t.jsxRuntimeExports.jsx(De.ColorLegend,{colorDomain:P,colors:q,colorLegendTitle:oe,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:C,"aria-label":"Graph area",children:(l||c)&&(N||Q)?t.jsxRuntimeExports.jsx(He,{data:w,colors:q,width:l||c,height:Math.max(j,N||(S?j?(l||c)*S>j?(l||c)*S:j:(l||c)*S:Q)),dateFormat:re,noOfXTicks:ie,leftMargin:V,rightMargin:I,topMargin:Y,bottomMargin:W,tooltip:ae,onSeriesMouseOver:M,highlightAreaSettings:ne,refValues:F,minValue:p,maxValue:g,rtl:E==="he"||E==="ar",annotations:le,customHighlightAreaSettings:b,yAxisTitle:B,noOfYTicks:_,prefix:z,suffix:d,curveType:J,styles:i,classNames:A,precision:ce,customLayers:xe,animate:v===!0?{duration:.5,once:!0,amount:.5}:v||{duration:0,once:!0,amount:0}}):null})]})}),G||f?t.jsxRuntimeExports.jsx(Le.GraphFooter,{styles:{footnote:i?.footnote,source:i?.source},classNames:{footnote:A?.footnote,source:A?.source},sources:G,footNote:f,width:l}):null]})})})})}exports.AreaChart=Ge;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),h=require("react"),u=require("./parse-hMnG_lRV.cjs"),de=require("./index-BzeLQvXk.cjs"),ue=require("./index-C21TvELx.cjs"),he=require("./numberFormattingFunction-02t-wJta.cjs"),fe=require("./Tooltip-n8z5bfav.cjs"),Z=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),me=require("./customArea-CK768gCn.cjs"),ye=require("./AxisTitle-CK9YeovX.cjs"),je=require("./Axis-DE7dSn1_.cjs"),ve=require("./XTicksAndGridLines-CCzXIV8d.cjs"),we=require("./ReferenceLine-CFVBBN__.cjs"),Re=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Ee=require("./index-DNj994Pv.cjs"),Ae=require("./time-Byw_jYQ7.cjs"),Ce=require("./linear-BVckp9RD.cjs"),be=require("./area-D3Qx7k7K.cjs"),Oe=require("./line-DHV4JwCR.cjs"),ee=require("./step-BZ3C8QFW.cjs"),qe=require("./select-Bnfk0lJx.cjs"),Ne=require("./init-DU0ybBc_.cjs"),Se=require("./pointer-Dkq5NV1q.cjs"),$e=require("./use-in-view-sQJZ_xDO.cjs"),te=require("./proxy-BHRoeZgd.cjs"),ke=require("./index-BW8iNx7E.cjs"),Le=require("./GraphFooter.cjs"),Te=require("./GraphHeader.cjs"),De=require("./ColorLegend.cjs"),Me=require("./Colors.cjs"),Fe=require("./EmptyState-d8_8SxeW.cjs");function He(se){const{data:w,width:R,height:q,colors:G,dateFormat:o,noOfXTicks:N,rightMargin:l,leftMargin:f,topMargin:ie,bottomMargin:re,yAxisTitle:P,tooltip:D,onSeriesMouseOver:m,highlightAreaSettings:oe,refValues:V,minValue:I,maxValue:Y,rtl:W,annotations:ne,customHighlightAreaSettings:ae,noOfYTicks:S,prefix:M,suffix:F,curveType:$,styles:p,classNames:g,precision:k,customLayers:H,animate:y}=se,E=h.useRef(null),j=$e.useInView(E,{once:y.once,amount:y.amount}),le=$==="linear"?Oe.curveLinear:$==="step"?ee.curveStep:$==="stepAfter"?ee.stepAfter:$==="stepBefore"?ee.stepBefore:ee.monotoneX,[b,X]=h.useState(void 0),[U,B]=h.useState(void 0),[_,z]=h.useState(void 0),d={top:ie,bottom:re,left:P?f+30:f,right:l},J=h.useRef(null),i=de.sortBy(w.map(e=>({...e,date:u.parse(`${e.date}`,o,new Date)})),"date"),A=oe.map(e=>({...e,coordinates:[e.coordinates[0]===null?null:u.parse(`${e.coordinates[0]}`,o,new Date),e.coordinates[1]===null?null:u.parse(`${e.coordinates[1]}`,o,new Date)]})),ce=ae.map(e=>({...e,coordinates:e.coordinates.map((n,a)=>a%2===0?u.parse(`${n}`,o,new Date):n)})),xe=i[0].y.map((e,n)=>i.map(a=>({date:a.date,y0:n===0?0:ue.sum(a.y.filter((T,O)=>O<n)),y1:ue.sum(a.y.filter((T,O)=>O<=n))}))),v=R-d.left-d.right,c=q-d.top-d.bottom,K=i[0].date,Q=i[i.length-1].date,x=Z.checkIfNullOrUndefined(I)?0:I,C=Z.checkIfNullOrUndefined(Y)?Math.max(...w.map(e=>ue.sum(e.y)||0)):Y,r=Ae.time().domain([K,Q]).range([0,v]),s=Ce.linear().domain([x,C]).range([c,0]).nice(),L=be.area().x(e=>r(e.date)).y0(e=>s(e.y0)).y1(e=>s(e.y1)).curve(le),pe=s.ticks(S),ge=r.ticks(N);return h.useEffect(()=>{const e=a=>{const T=i[Ne.bisectCenter(i.map(O=>O.date),r.invert(Se.pointer(a)[0]),1)];X(T||i[i.length-1]),m?.(T||i[i.length-1]),z(a.clientY),B(a.clientX)},n=()=>{X(void 0),B(void 0),z(void 0),m?.(void 0)};qe.select(J.current).on("mousemove",e).on("mouseout",n),m?.(void 0)},[r,i,m]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(te.motion.svg,{width:`${R}px`,height:`${q}px`,viewBox:`0 0 ${R} ${q}`,direction:"ltr",ref:E,children:t.jsxRuntimeExports.jsx(ke.AnimatePresence,{children:t.jsxRuntimeExports.jsxs(te.motion.g,{transform:`translate(${d.left},${d.top})`,children:[t.jsxRuntimeExports.jsx(Ee.HighlightArea,{areaSettings:A,width:v,height:c,scale:r,animate:y,isInView:j}),t.jsxRuntimeExports.jsx(me.CustomArea,{animate:y,areaSettings:ce,scaleX:r,scaleY:s,isInView:j}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(Re.YTicksAndGridLines,{values:pe.filter(e=>e!==0),y:pe.filter(e=>e!==0).map(e=>s(e)),x1:0-f,x2:v+d.right,styles:{gridLines:p?.yAxis?.gridLines,labels:p?.yAxis?.labels},classNames:{gridLines:g?.yAxis?.gridLines,labels:g?.yAxis?.labels},suffix:F,prefix:M,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:k}),t.jsxRuntimeExports.jsx(je.Axis,{y1:s(x<0?0:x),y2:s(x<0?0:x),x1:0-f,x2:v+d.right,label:he.numberFormattingFunction(x<0?0:x,"NA",k,M,F),labelPos:{x:0-f,dx:0,dy:C<0?"1em":-5,y:s(x<0?0:x)},classNames:{axis:g?.xAxis?.axis,label:g?.yAxis?.labels},styles:{axis:p?.xAxis?.axis,label:p?.yAxis?.labels}}),t.jsxRuntimeExports.jsx(ye.AxisTitle,{x:0-f-15,y:c/2,style:p?.yAxis?.title,className:g?.yAxis?.title,text:P,rotate90:!0})]}),t.jsxRuntimeExports.jsx(ve.XTicksAndGridLines,{values:ge.map(e=>u.format(e,o)),x:ge.map(e=>r(e)),y1:0,y2:c,styles:{gridLines:p?.xAxis?.gridLines,labels:p?.xAxis?.labels},classNames:{gridLines:t.mo("opacity-0",g?.xAxis?.gridLines),labels:t.mo("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[8px] sm:text-[9px] md:text-[10px] lg:text-xs",g?.xAxis?.labels)},suffix:F,prefix:M,labelType:"primary",showGridLines:!0,precision:k}),H.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs(te.motion.g,{children:[xe.map((e,n)=>t.jsxRuntimeExports.jsx(te.motion.path,{d:L(e),exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{d:L(e.map(a=>({...a,y0:0,y1:0}))),opacity:0},whileInView:{d:L(e),opacity:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",style:{fill:G[n],opacity:.8}},n)),b?t.jsxRuntimeExports.jsx("line",{y1:0,y2:c,x1:r(b.date),x2:r(b.date),className:t.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",g?.mouseOverLine),style:p?.mouseOverLine}):null]}),V?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:V.map((e,n)=>t.jsxRuntimeExports.jsx(we.RefLineY,{text:e.text,color:e.color,y:s(e.value),x1:0-f,x2:v+d.right,classNames:e.classNames,styles:e.styles,animate:y,isInView:j},n))}):null,t.jsxRuntimeExports.jsx("g",{children:ne.map((e,n)=>{const a=me.getLineEndPoint({x:e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),y:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8},{x:e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date)):0,y:e.yCoordinate?s(e.yCoordinate):0},Z.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius),T=e.showConnector?{y1:a.y,x1:a.x,y2:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0):0+(e.yOffset||0),x2:e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),cx:e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date)):0,cy:e.yCoordinate?s(e.yCoordinate):0,circleRadius:Z.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius,strokeWidth:e.showConnector===!0?2:Math.min(e.showConnector||0,1)}:void 0,O={y:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8,x:W?0:e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),width:W?e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0):v-(e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0)),maxWidth:e.maxWidth,fontWeight:e.fontWeight,align:e.align};return t.jsxRuntimeExports.jsx(me.Annotation,{color:e.color,connectorsSettings:T,labelSettings:O,text:e.text,classNames:e.classNames,styles:e.styles,animate:y,isInView:j},n)})}),H.filter(e=>e.position==="after").map(e=>e.layer),t.jsxRuntimeExports.jsx("rect",{ref:J,style:{fill:"none",pointerEvents:"all"},width:v,height:c})]})})}),b&&D&&U&&_?t.jsxRuntimeExports.jsx(fe.Tooltip,{data:b,body:D,xPos:U,yPos:_,backgroundStyle:p?.tooltip,className:g?.tooltip}):null]})}function Ge(se){const{data:w,graphTitle:R,colors:q=Me.Colors.light.categoricalColors.colors,sources:G,graphDescription:o,height:N,width:l,footNote:f,noOfXTicks:ie=10,dateFormat:re="yyyy",colorDomain:P,padding:D,backgroundColor:m=!1,colorLegendTitle:oe,leftMargin:V=50,rightMargin:I=20,topMargin:Y=20,bottomMargin:W=25,highlightAreaSettings:ne=[],tooltip:ae,relativeHeight:S,onSeriesMouseOver:M,refValues:F=[],graphID:$,minValue:p,maxValue:g,graphDownload:k=!1,dataDownload:H=!1,showColorScale:y=!0,language:E="en",minHeight:j=0,annotations:le=[],customHighlightAreaSettings:b=[],theme:X="light",ariaLabel:U,yAxisTitle:B,noOfYTicks:_=5,prefix:z="",suffix:d="",curveType:J="curve",styles:i,classNames:A,precision:ce=2,customLayers:xe=[],animate:v=!1}=se,[c,K]=h.useState(0),[Q,x]=h.useState(0),C=h.useRef(null),r=h.useRef(null);return h.useEffect(()=>{const s=new ResizeObserver(L=>{K(l||L[0].target.clientWidth||620),x(N||L[0].target.clientHeight||480)});return C.current&&(x(C.current.clientHeight||480),K(C.current.clientWidth||620),l||s.observe(C.current)),()=>s.disconnect()},[l,N]),t.jsxRuntimeExports.jsx("div",{className:`${X||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:E==="he"||E==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${m?m===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${E||"en"}`,A?.graphContainer),style:{...i?.graphContainer||{},...m&&m!==!0?{backgroundColor:m}:{}},id:$,ref:r,"aria-label":U||`${R?`The graph shows ${R}. `:""}This is a stacked area chart that shows trends over time.${o?` ${o}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:m?D||"1rem":D||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[R||o||k||H?t.jsxRuntimeExports.jsx(Te.GraphHeader,{styles:{title:i?.title,description:i?.description},classNames:{title:A?.title,description:A?.description},graphTitle:R,graphDescription:o,width:l,graphDownload:k?r.current:void 0,dataDownload:H?w.map(s=>s.data).filter(s=>s!==void 0).length>0?w.map(s=>s.data).filter(s=>s!==void 0):w.filter(s=>s!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:w.length===0?t.jsxRuntimeExports.jsx(Fe.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[y!==!1?t.jsxRuntimeExports.jsx(De.ColorLegend,{colorDomain:P,colors:q,colorLegendTitle:oe,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:C,"aria-label":"Graph area",children:(l||c)&&(N||Q)?t.jsxRuntimeExports.jsx(He,{data:w,colors:q,width:l||c,height:Math.max(j,N||(S?j?(l||c)*S>j?(l||c)*S:j:(l||c)*S:Q)),dateFormat:re,noOfXTicks:ie,leftMargin:V,rightMargin:I,topMargin:Y,bottomMargin:W,tooltip:ae,onSeriesMouseOver:M,highlightAreaSettings:ne,refValues:F,minValue:p,maxValue:g,rtl:E==="he"||E==="ar",annotations:le,customHighlightAreaSettings:b,yAxisTitle:B,noOfYTicks:_,prefix:z,suffix:d,curveType:J,styles:i,classNames:A,precision:ce,customLayers:xe,animate:v===!0?{duration:.5,once:!0,amount:.5}:v||{duration:0,once:!0,amount:0}}):null})]})}),G||f?t.jsxRuntimeExports.jsx(Le.GraphFooter,{styles:{footnote:i?.footnote,source:i?.source},classNames:{footnote:A?.footnote,source:A?.source},sources:G,footNote:f,width:l}):null]})})})})}exports.AreaChart=Ge;
|
|
2
2
|
//# sourceMappingURL=AreaChart.cjs.map
|
package/dist/AreaChart.js
CHANGED
|
@@ -6,24 +6,24 @@ import { s as fe } from "./index-D7ltPi18.js";
|
|
|
6
6
|
import { n as ye } from "./numberFormattingFunction-14YCbkN2.js";
|
|
7
7
|
import { T as ve } from "./Tooltip-DyM5snqx.js";
|
|
8
8
|
import { c as Z } from "./checkIfNullOrUndefined-DmfiKkNw.js";
|
|
9
|
-
import { C as we, g as Ae, A as Ce } from "./customArea-
|
|
9
|
+
import { C as we, g as Ae, A as Ce } from "./customArea-B-dWU0zZ.js";
|
|
10
10
|
import { A as be } from "./AxisTitle-BmHLMRJZ.js";
|
|
11
11
|
import { A as je } from "./Axis-Ddg-seDi.js";
|
|
12
12
|
import { X as Oe } from "./XTicksAndGridLines-Bn9u5gOM.js";
|
|
13
|
-
import { R as $e } from "./ReferenceLine-
|
|
13
|
+
import { R as $e } from "./ReferenceLine-CfAW3vKJ.js";
|
|
14
14
|
import { Y as Ne } from "./YTicksAndGridLines-B6ah7CRf.js";
|
|
15
|
-
import { H as De } from "./index-
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { a as Se } from "./
|
|
19
|
-
import {
|
|
20
|
-
import { c as Me } from "./
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
15
|
+
import { H as De } from "./index-Cdcfp4nk.js";
|
|
16
|
+
import { t as Le } from "./time-BzJP5SPC.js";
|
|
17
|
+
import { a as ke } from "./linear-DUdu7l2G.js";
|
|
18
|
+
import { a as Se } from "./area-BE2wo7fv.js";
|
|
19
|
+
import { c as Te } from "./line-CPfhohvF.js";
|
|
20
|
+
import { c as Me, s as He, a as Re, m as Fe } from "./step-BrDul-H4.js";
|
|
21
|
+
import { s as Ye } from "./select-DKy99ogv.js";
|
|
22
|
+
import { a as Pe } from "./init-BhZylTFx.js";
|
|
23
|
+
import { p as Ve } from "./pointer-CWRWOsrb.js";
|
|
24
|
+
import { u as We } from "./use-in-view-yS6jzJAp.js";
|
|
25
|
+
import { m as ee } from "./proxy-CkpFesk1.js";
|
|
26
|
+
import { A as Xe } from "./index-CNvov0eg.js";
|
|
27
27
|
import { GraphFooter as Ee } from "./GraphFooter.js";
|
|
28
28
|
import { GraphHeader as Ge } from "./GraphHeader.js";
|
|
29
29
|
import { ColorLegend as Ie } from "./ColorLegend.js";
|
|
@@ -60,10 +60,10 @@ function ze(oe) {
|
|
|
60
60
|
precision: S,
|
|
61
61
|
customLayers: Y,
|
|
62
62
|
animate: d
|
|
63
|
-
} = oe, C = ae(null), y =
|
|
63
|
+
} = oe, C = ae(null), y = We(C, {
|
|
64
64
|
once: d.once,
|
|
65
65
|
amount: d.amount
|
|
66
|
-
}), ce = k === "linear" ?
|
|
66
|
+
}), ce = k === "linear" ? Te : k === "step" ? Me : k === "stepAfter" ? He : k === "stepBefore" ? Re : Fe, [O, B] = P(void 0), [_, z] = P(void 0), [U, q] = P(void 0), p = {
|
|
67
67
|
top: se,
|
|
68
68
|
bottom: ie,
|
|
69
69
|
left: W ? u + 30 : u,
|
|
@@ -89,19 +89,19 @@ function ze(oe) {
|
|
|
89
89
|
date: n.date,
|
|
90
90
|
y0: r === 0 ? 0 : fe(n.y.filter((M, $) => $ < r)),
|
|
91
91
|
y1: fe(n.y.filter((M, $) => $ <= r))
|
|
92
|
-
}))), v = A - p.left - p.right, c = N - p.top - p.bottom, K = o[0].date, Q = o[o.length - 1].date, m = Z(E) ? 0 : E, j = Z(G) ? Math.max(...w.map((e) => fe(e.y) || 0)) : G, s =
|
|
92
|
+
}))), v = A - p.left - p.right, c = N - p.top - p.bottom, K = o[0].date, Q = o[o.length - 1].date, m = Z(E) ? 0 : E, j = Z(G) ? Math.max(...w.map((e) => fe(e.y) || 0)) : G, s = Le().domain([K, Q]).range([0, v]), a = ke().domain([m, j]).range([c, 0]).nice(), T = Se().x((e) => s(e.date)).y0((e) => a(e.y0)).y1((e) => a(e.y1)).curve(ce), ge = a.ticks(L), pe = s.ticks(D);
|
|
93
93
|
return he(() => {
|
|
94
94
|
const e = (n) => {
|
|
95
|
-
const M = o[
|
|
95
|
+
const M = o[Pe(
|
|
96
96
|
o.map(($) => $.date),
|
|
97
|
-
s.invert(
|
|
97
|
+
s.invert(Ve(n)[0]),
|
|
98
98
|
1
|
|
99
99
|
)];
|
|
100
100
|
B(M || o[o.length - 1]), x?.(M || o[o.length - 1]), q(n.clientY), z(n.clientX);
|
|
101
101
|
}, r = () => {
|
|
102
102
|
B(void 0), z(void 0), q(void 0), x?.(void 0);
|
|
103
103
|
};
|
|
104
|
-
|
|
104
|
+
Ye(J.current).on("mousemove", e).on("mouseout", r), x?.(void 0);
|
|
105
105
|
}, [s, o, x]), /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
106
106
|
/* @__PURE__ */ t.jsx(
|
|
107
107
|
ee.svg,
|
|
@@ -111,7 +111,7 @@ function ze(oe) {
|
|
|
111
111
|
viewBox: `0 0 ${A} ${N}`,
|
|
112
112
|
direction: "ltr",
|
|
113
113
|
ref: C,
|
|
114
|
-
children: /* @__PURE__ */ t.jsx(
|
|
114
|
+
children: /* @__PURE__ */ t.jsx(Xe, { children: /* @__PURE__ */ t.jsxs(ee.g, { transform: `translate(${p.left},${p.top})`, children: [
|
|
115
115
|
/* @__PURE__ */ t.jsx(
|
|
116
116
|
De,
|
|
117
117
|
{
|
package/dist/BarGraph.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),Se=require("./index-CZbIGs8q.cjs"),m=require("react"),De=require("./index-BzeLQvXk.cjs"),Ee=require("./parse-hMnG_lRV.cjs"),Re=require("./getSliderMarks-CtsEXiLV.cjs"),Te=require("./index-BXns0-ng.cjs"),Ae=require("./Modal-C_dl0EtQ.cjs"),Me=require("./numberFormattingFunction-02t-wJta.cjs"),ze=require("./Tooltip-n8z5bfav.cjs"),Y=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ce=require("./Colors.cjs"),Ve=require("./string2HTML-D2Avudmb.cjs"),Qe=require("./XTicksAndGridLines-CCzXIV8d.cjs"),Ze=require("./YAxesLabels-BXLTX7AI.cjs"),Le=require("./AxisTitle-CK9YeovX.cjs"),Be=require("./Axis-DE7dSn1_.cjs"),Fe=require("./ReferenceLine-CuFMk0cI.cjs"),Pe=require("./use-in-view-BCmzDU2O.cjs"),He=require("./linear-BVckp9RD.cjs"),$e=require("./band-CAApY4Pd.cjs"),ge=require("./proxy-PQd2AItT.cjs"),Ge=require("./index-DVOJ7vxH.cjs"),qe=require("./GraphFooter.cjs"),Ue=require("./GraphHeader.cjs"),We=require("./ColorLegendWithMouseOver.cjs"),Xe=require("./EmptyState-d8_8SxeW.cjs"),Ie=require("./index-BW_-wD2k.cjs"),Ne=require("./ensureCompleteData-DqWQ2Zbi.cjs"),Ye=require("./init-DU0ybBc_.cjs"),ke=require("./index-C21TvELx.cjs"),Ke=require("./getTextColorBasedOnBgColor-nqY-bsM_.cjs"),et=require("./XAxesLabels-CJMQbfVy.cjs"),tt=require("./YTicksAndGridLines-DBDuz6vb.cjs");function it(fe){const{data:l,barColor:p,suffix:H,prefix:A,barPadding:G,showValues:me,showTicks:de,leftMargin:he,truncateBy:Q,width:q,height:ie,colorDomain:I,rightMargin:oe,topMargin:xe,bottomMargin:C,showLabels:U,tooltip:_,onSeriesMouseOver:Z,refValues:E,selectedColor:f,highlightedDataPoints:L,maxValue:ae,minValue:se,onSeriesMouseClick:J,labelOrder:ee,rtl:ne,maxBarThickness:W,minBarThickness:pe,resetSelectionOnDoubleClick:ce,detailsOnClick:S,barAxisTitle:b,valueColor:g,noOfTicks:w,styles:D,classNames:N,animate:M,dimmedOpacity:z,precision:V,customLayers:v,naLabel:j}=fe,X=m.useRef(null),$=Pe.useInView(X,{once:M.once,amount:M.amount}),[T,ue]=m.useState(void 0),[P,B]=m.useState(void 0),[re,R]=m.useState(void 0),[F,h]=m.useState(void 0),k={top:b?xe+25:xe,bottom:C,left:he,right:oe},y=q-k.left-k.right,c=ie-k.top-k.bottom,d=l.map((s,x)=>({...s,id:ee?`${s.label}`:`${x}`})),o=He.linear().domain([se,ae]).range([0,y]).nice(),a=ee||d.map(s=>`${s.id}`),r=$e.band().domain(a).range([0,pe?Math.max(c,pe*a.length):W?Math.min(c,W*a.length):c]).paddingInner(G),t=o.ticks(w);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:X,width:`${q}px`,height:`${ie}px`,viewBox:`0 0 ${q} ${ie}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${k.left},${k.top})`,children:[de?e.jsxRuntimeExports.jsx(Qe.XTicksAndGridLines,{values:t.filter(s=>s!==0),x:t.filter(s=>s!==0).map(s=>o(s)),y1:0-xe,y2:c+k.bottom,styles:{gridLines:D?.xAxis?.gridLines,labels:D?.xAxis?.labels},classNames:{gridLines:N?.xAxis?.gridLines,labels:N?.xAxis?.labels},suffix:H,prefix:A,labelType:"secondary",showGridLines:!0,precision:V}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:y/2,y:0-k.top+15,style:D?.xAxis?.title,className:N?.xAxis?.title,text:b}),v.filter(s=>s.position==="before").map(s=>s.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[d.map(s=>Y.checkIfNullOrUndefined(r(s.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{opacity:f?s.color&&p[I.indexOf(s.color)]===f?1:z:L.length!==0?L.indexOf(s.label)!==-1?.85:z:.85},whileInView:{opacity:f?s.color&&p[I.indexOf(s.color)]===f?1:z:L.length!==0?L.indexOf(s.label)!==-1?.85:z:.85,transition:{duration:M.duration}}},initial:"initial",animate:$?"whileInView":"initial",exit:{opacity:0,transition:{duration:M.duration}},onMouseEnter:x=>{ue(s),h(x.clientY),R(x.clientX),Z?.(s)},onClick:()=>{(J||S)&&(Te.isEqual(P,s)&&ce?(B(void 0),J?.(void 0)):(B(s),J?.(s)))},onMouseMove:x=>{ue(s),h(x.clientY),R(x.clientX)},onMouseLeave:()=>{ue(void 0),R(void 0),h(void 0),Z?.(void 0)},children:[s.size?e.jsxRuntimeExports.jsx(ge.motion.rect,{variants:{initial:{width:0,x:o(0),y:r(`${s.id}`),fill:l.filter(x=>x.color).length===0?p[0]:s.color?p[I.indexOf(s.color)]:Ce.Colors.gray},whileInView:{width:s.size>=0?o(s.size)-o(0):o(0)-o(s.size),x:s.size>=0?o(0):o(s.size),y:r(`${s.id}`),fill:l.filter(x=>x.color).length===0?p[0]:s.color?p[I.indexOf(s.color)]:Ce.Colors.gray,transition:{duration:M.duration}}},initial:"initial",animate:$?"whileInView":"initial",exit:{width:0,x:o(0),transition:{duration:M.duration}},height:r.bandwidth()}):null,U?e.jsxRuntimeExports.jsx(Ze.YAxesLabels,{value:`${s.label}`.length<Q?`${s.label}`:`${`${s.label}`.substring(0,Q)}...`,y:r(s.id)||0,x:(s.size||0)<0?o(0):0-k.left,width:(s.size||0)<0?q-o(0):o(0)+k.left,height:r.bandwidth(),alignment:s.size&&s.size<0?"left":"right",style:D?.yAxis?.labels,className:N?.yAxis?.labels,animate:M,isInView:$}):null,me?e.jsxRuntimeExports.jsx(ge.motion.text,{style:{textAnchor:s.size&&s.size<0?"end":"start",...D?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!g&&p.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",N?.graphObjectValues),dx:s.size&&s.size<0?-5:5,dy:"0.33em",variants:{initial:{x:o(0),y:r(`${s.id}`)+r.bandwidth()/2,opacity:0,fill:g||(l.filter(x=>x.color).length===0?p[0]:s.color?p[I.indexOf(s.color)]:Ce.Colors.gray)},whileInView:{x:s.size?o(s.size):o(0),opacity:1,y:r(`${s.id}`)+r.bandwidth()/2,fill:g||(l.filter(x=>x.color).length===0?p[0]:s.color?p[I.indexOf(s.color)]:Ce.Colors.gray),transition:{duration:M.duration}}},initial:"initial",animate:$?"whileInView":"initial",exit:{opacity:0,transition:{duration:M.duration}},children:Me.numberFormattingFunction(s.size,j,V,A,H)}):null]},s.label)),e.jsxRuntimeExports.jsx(Be.Axis,{x1:o(se<0?0:se),x2:o(se<0?0:se),y1:-2.5,y2:c+k.bottom,classNames:{axis:N?.yAxis?.axis},styles:{axis:D?.yAxis?.axis}}),E?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:E.map((s,x)=>e.jsxRuntimeExports.jsx(Fe.RefLineX,{text:s.text,color:s.color,x:o(s.value),y1:0-k.top,y2:c+k.bottom,textSide:o(s.value)>y*.75||ne?"left":"right",classNames:s.classNames,styles:s.styles,animate:M,isInView:$},x))}):null]}),v.filter(s=>s.position==="after").map(s=>s.layer)]})}),T&&_&&re&&F?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:T,body:_,xPos:re,yPos:F,backgroundStyle:D?.tooltip,className:N?.tooltip}):null,S&&P!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:P!==void 0,onClose:()=>{B(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof S=="string"?{__html:Ve.string2HTML(S,P)}:void 0,children:typeof S=="function"?S(P):null})}):null]})}function at(fe){const{data:l,graphTitle:p,colors:H,suffix:A="",sources:G,prefix:me="",graphDescription:de,barPadding:he=.25,showValues:Q=!0,showTicks:q=!0,leftMargin:ie=100,rightMargin:I=40,truncateBy:oe=999,height:xe,width:C,footNote:U,colorDomain:_,colorLegendTitle:Z,highlightedDataPoints:E=[],padding:f,backgroundColor:L=!1,topMargin:ae=25,bottomMargin:se=10,showLabels:J=!0,relativeHeight:ee,tooltip:ne,onSeriesMouseOver:W,refValues:pe,showColorScale:ce=!0,graphID:S,maxValue:b,minValue:g,onSeriesMouseClick:w,graphDownload:D=!1,dataDownload:N=!1,sortData:M,labelOrder:z,language:V="en",showNAColor:v=!0,minHeight:j=0,theme:X="light",maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B=!0,detailsOnClick:re,barAxisTitle:R,noOfTicks:F=5,valueColor:h,styles:k,classNames:y,filterNA:c=!0,animate:d=!1,dimmedOpacity:o=.3,precision:a=2,customLayers:r=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:s="NA"}=fe,[x,Oe]=m.useState(0),[K,je]=m.useState(0),[ve,we]=m.useState(t.autoplay),le=Re.sort(Se.uniqBy(l.filter(i=>i.date!==void 0&&i.date!==null),i=>i.date).map(i=>Ee.parse(`${i.date}`,t.dateFormat||"yyyy",new Date).getTime()),(i,be)=>Ye.ascending(i,be)),[ye,u]=m.useState(t.autoplay?0:le.length-1),[te,n]=m.useState(void 0),O=m.useRef(null),_e=m.useRef(null);m.useEffect(()=>{const i=new ResizeObserver(be=>{Oe(C||be[0].target.clientWidth||620),je(xe||be[0].target.clientHeight||480)});return O.current&&(je(O.current.clientHeight||480),Oe(O.current.clientWidth||620),C||i.observe(O.current)),()=>i.disconnect()},[C,xe]),m.useEffect(()=>{const i=setInterval(()=>{u(be=>be<le.length-1?be+1:0)},(t.speed||2)*1e3);return ve||clearInterval(i),()=>clearInterval(i)},[le,ve,t.speed]);const Je=Re.getSliderMarks(le,ye,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${X||"light"} flex ${C?"w-fit grow-0":"w-full grow"}`,dir:V==="he"||V==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${L?L===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${V||"en"}`,y?.graphContainer),style:{...k?.graphContainer||{},...L&&L!==!0?{backgroundColor:L}:{}},id:S,ref:_e,"aria-label":P||`${p?`The graph shows ${p}. `:""}This is a bar chart. ${de?` ${de}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:L?f||"1rem":f||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||de||D||N?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:k?.title,description:k?.description},classNames:{title:y?.title,description:y?.description},graphTitle:p,graphDescription:de,width:C,graphDownload:D?_e.current:void 0,dataDownload:N?l.map(i=>i.data).filter(i=>i!==void 0).length>0?l.map(i=>i.data).filter(i=>i!==void 0):l.filter(i=>i!==void 0):null}):null,t.enabled&&le.length>0&&Je?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!ve)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ve?"Click to pause animation":"Click to play animation",children:ve?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:le[0],max:le[le.length-1],marks:Je,step:null,defaultValue:le[le.length-1],value:le[ye],onChangeComplete:i=>{u(le.indexOf(i))},onChange:i=>{u(le.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[ce&&l.filter(i=>i.color).length!==0?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:C,colorLegendTitle:Z,colors:H||Ce.Colors[X].categoricalColors.colors,colorDomain:_||Se.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),setSelectedColor:n,showNAColor:v}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:O,"aria-label":"Graph area",children:(C||x)&&(xe||K)?e.jsxRuntimeExports.jsx(it,{data:M==="asc"?De.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).filter((i,be)=>T?be<T:!0):M==="desc"?De.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).reverse().filter((i,be)=>T?be<T:!0):Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i).filter((i,be)=>T?be<T:!0),barColor:l.filter(i=>i.color).length===0?H?[H]:[Ce.Colors.primaryColors["blue-600"]]:H||Ce.Colors[X].categoricalColors.colors,colorDomain:l.filter(i=>i.color).length===0?[]:_||Se.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),width:C||x,selectedColor:te,height:Math.max(j,xe||(ee?j?(C||x)*ee>j?(C||x)*ee:j:(C||x)*ee:K)),suffix:A,prefix:me,barPadding:he,showValues:Q,showTicks:q,leftMargin:ie,rightMargin:I,topMargin:ae,bottomMargin:se,truncateBy:oe,showLabels:J,tooltip:ne,onSeriesMouseOver:W,refValues:pe,maxValue:Y.checkIfNullOrUndefined(b)?Math.max(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size))<0?0:Math.max(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size)):b,minValue:Y.checkIfNullOrUndefined(g)?Math.min(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size))>=0?0:Math.min(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size)):g,highlightedDataPoints:E,onSeriesMouseClick:w,labelOrder:z,rtl:V==="he"||V==="ar",maxBarThickness:$,minBarThickness:ue,resetSelectionOnDoubleClick:B,detailsOnClick:re,barAxisTitle:R,noOfTicks:F,valueColor:h,classNames:y,styles:k,animate:d===!0?{duration:.5,once:!0,amount:.5}:d||{duration:0,once:!0,amount:0},dimmedOpacity:o,precision:a,customLayers:r,naLabel:s}):null})]})}),G||U?e.jsxRuntimeExports.jsx(qe.GraphFooter,{sources:G,footNote:U,width:C,styles:{footnote:k?.footnote,source:k?.source},classNames:{footnote:y?.footnote,source:y?.source}}):null]})})})})}function st(fe){const{data:l,barColors:p,barPadding:H,showTicks:A,leftMargin:G,truncateBy:me,width:de,height:he,suffix:Q,prefix:q,showValues:ie,rightMargin:I,topMargin:oe,bottomMargin:xe,showLabels:C,tooltip:U,onSeriesMouseOver:_,refValues:Z,maxValue:E,minValue:f,onSeriesMouseClick:L,selectedColor:ae,rtl:se,labelOrder:J,maxBarThickness:ee,resetSelectionOnDoubleClick:ne,detailsOnClick:W,barAxisTitle:pe,valueColor:ce,noOfTicks:S,styles:b,classNames:g,animate:w,colorDomain:D,precision:N,customLayers:M,naLabel:z}=fe,V=m.useRef(null),v=Pe.useInView(V,{once:w.once,amount:w.amount}),j={top:pe?oe+25:oe,bottom:xe,left:G,right:I},[X,$]=m.useState(void 0),[T,ue]=m.useState(void 0),[P,B]=m.useState(void 0),[re,R]=m.useState(void 0),F=de-j.left-j.right,h=he-j.top-j.bottom,k=l.map((r,t)=>({...r,id:J?`${r.label}`:`${t}`})),y=J||k.map(r=>`${r.id}`),c=He.linear().domain([f,E]).range([0,F]).nice(),d=$e.band().domain(y).range([0,ee?Math.min(h,ee*y.length):h]).paddingInner(H),o=$e.band().domain(l[0].size.map((r,t)=>`${t}`)).range([0,d.bandwidth()]).paddingInner(.1),a=c.ticks(S);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:V,width:`${de}px`,height:`${he}px`,viewBox:`0 0 ${de} ${he}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${j.left},${j.top})`,children:[A?e.jsxRuntimeExports.jsx(Qe.XTicksAndGridLines,{values:a.filter(r=>r!==0),x:a.filter(r=>r!==0).map(r=>c(r)),y1:0-oe,y2:h+j.bottom,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.xAxis?.labels},classNames:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},suffix:Q,prefix:q,labelType:"secondary",showGridLines:!0,precision:N}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:F/2,y:0-j.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),M.filter(r=>r.position==="before").map(r=>r.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[k.map(r=>Y.checkIfNullOrUndefined(d(r.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{variants:{initial:{x:0,y:d(`${r.id}`)},whileInView:{x:0,y:d(`${r.id}`),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},children:[r.size.map((t,s)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?p[s]===ae?1:.3:.85,onMouseEnter:x=>{$({...r,sizeIndex:s}),R(x.clientY),B(x.clientX),_?.({...r,sizeIndex:s})},onMouseMove:x=>{$({...r,sizeIndex:s}),R(x.clientY),B(x.clientX)},onMouseLeave:()=>{$(void 0),B(void 0),R(void 0),_?.(void 0)},onClick:()=>{(L||W)&&(Te.isEqual(T,{...r,sizeIndex:s})&&ne?(ue(void 0),L?.(void 0)):(ue({...r,sizeIndex:s}),L&&L({...r,sizeIndex:s})))},children:[Y.checkIfNullOrUndefined(t)?null:e.jsxRuntimeExports.jsx(ge.motion.rect,{y:o(`${s}`),variants:{initial:{width:0,x:c(0),fill:p[s]},whileInView:{width:Y.checkIfNullOrUndefined(t)?0:t>=0?c(t)-c(0):c(0)-c(t),x:t>=0?c(0):c(t),fill:p[s],transition:{duration:w.duration}}},exit:{width:0,x:c(0),transition:{duration:w.duration}},height:o.bandwidth(),initial:"initial",animate:v?"whileInView":"initial"}),ie?e.jsxRuntimeExports.jsx(ge.motion.text,{y:o(`${s}`)+o.bandwidth()/2,style:{fill:ce||p[s],textAnchor:t&&t<0?"end":"start",...b?.graphObjectValues||{}},className:e.mo("graph-value text-sm",g?.graphObjectValues),dx:t&&t<0?-5:5,dy:"0.33em",variants:{initial:{x:c(0),opacity:0},whileInView:{x:c(t||0),opacity:1,transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},children:Me.numberFormattingFunction(t,z,N,q,Q)}):null]},`${r.label}-${D[s]||s}`)),C?e.jsxRuntimeExports.jsx(Ze.YAxesLabels,{value:`${r.label}`.length<me?`${r.label}`:`${`${r.label}`.substring(0,me)}...`,y:0,x:0-j.left,width:c(f<0?0:f)+j.left,height:d.bandwidth(),style:b?.yAxis?.labels,className:g?.yAxis?.labels,animate:w,isInView:v}):null]},r.label)),e.jsxRuntimeExports.jsx(Be.Axis,{x1:c(f<0?0:f),x2:c(f<0?0:f),y1:-2.5,y2:h+j.bottom,classNames:{axis:g?.yAxis?.axis},styles:{axis:b?.yAxis?.axis}}),Z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Z.map((r,t)=>e.jsxRuntimeExports.jsx(Fe.RefLineX,{text:r.text,color:r.color,x:c(r.value),y1:0-j.top,y2:h+j.bottom,textSide:c(r.value)>F*.75||se?"left":"right",classNames:r.classNames,styles:r.styles,animate:w,isInView:v},t))}):null]}),M.filter(r=>r.position==="after").map(r=>r.layer)]})}),X&&U&&P&&re?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:X,body:U,xPos:P,yPos:re,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,W&&T!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:T!==void 0,onClose:()=>{ue(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof W=="string"?{__html:Ve.string2HTML(W,T)}:void 0,children:typeof W=="function"?W(T):null})}):null]})}function rt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:A,graphDescription:G,barPadding:me=.25,showTicks:de=!0,truncateBy:he=999,height:Q,width:q,footNote:ie,colorDomain:I,colorLegendTitle:oe,suffix:xe="",prefix:C="",showValues:U=!0,showColorScale:_=!0,padding:Z,backgroundColor:E=!1,leftMargin:f=100,rightMargin:L=40,topMargin:ae=25,bottomMargin:se=10,showLabels:J=!0,relativeHeight:ee,tooltip:ne,onSeriesMouseOver:W,refValues:pe,graphID:ce,maxValue:S,minValue:b,onSeriesMouseClick:g,graphDownload:w=!1,dataDownload:D=!1,language:N="en",labelOrder:M,minHeight:z=0,theme:V="light",maxBarThickness:v,ariaLabel:j,resetSelectionOnDoubleClick:X=!0,detailsOnClick:$,barAxisTitle:T,noOfTicks:ue=5,valueColor:P,styles:B,classNames:re,filterNA:R=!0,animate:F=!1,precision:h=2,customLayers:k=[],timeline:y={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:c="NA"}=fe,[d,o]=m.useState(0),[a,r]=m.useState(0),[t,s]=m.useState(y.autoplay),x=Re.sort(Se.uniqBy(l.filter(u=>u.date!==void 0&&u.date!==null),u=>u.date).map(u=>Ee.parse(`${u.date}`,y.dateFormat||"yyyy",new Date).getTime()),(u,te)=>Ye.ascending(u,te)),[Oe,K]=m.useState(y.autoplay?0:x.length-1),[je,ve]=m.useState(void 0),we=m.useRef(null),le=m.useRef(null);m.useEffect(()=>{const u=new ResizeObserver(te=>{o(q||te[0].target.clientWidth||620),r(Q||te[0].target.clientHeight||480)});return we.current&&(r(we.current.clientHeight||480),o(we.current.clientWidth||620),q||u.observe(we.current)),()=>u.disconnect()},[q,Q]),m.useEffect(()=>{const u=setInterval(()=>{K(te=>te<x.length-1?te+1:0)},(y.speed||2)*1e3);return t||clearInterval(u),()=>clearInterval(u)},[x,t,y.speed]);const ye=Re.getSliderMarks(x,Oe,y.showOnlyActiveDate,y.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${V||"light"} flex ${q?"w-fit grow-0":"w-full grow"}`,dir:N==="he"||N==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${E?E===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${N||"en"}`,re?.graphContainer),style:{...B?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:ce,ref:le,"aria-label":j||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${G?` ${G}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?Z||"1rem":Z||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[p||G||w||D?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:B?.title,description:B?.description},classNames:{title:re?.title,description:re?.description},graphTitle:p,graphDescription:G,width:q,graphDownload:w?le.current:void 0,dataDownload:D?l.map(u=>u.data).filter(u=>u!==void 0).length>0?l.map(u=>u.data).filter(u=>u!==void 0):l.filter(u=>u!==void 0):null}):null,y.enabled&&x.length>0&&ye?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{s(!t)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":t?"Click to pause animation":"Click to play animation",children:t?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:x[0],max:x[x.length-1],marks:ye,step:null,defaultValue:x[x.length-1],value:x[Oe],onChangeComplete:u=>{K(x.indexOf(u))},onChange:u=>{K(x.indexOf(u))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:q,colorDomain:I,colors:H,colorLegendTitle:oe,setSelectedColor:ve,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:we,"aria-label":"Graph area",children:(q||d)&&(Q||a)?e.jsxRuntimeExports.jsx(st,{data:Ne.ensureCompleteDataForStackedBarChart(l,y.dateFormat||"yyyy").filter(u=>y.enabled?u.date===Ee.format(new Date(x[Oe]),y.dateFormat||"yyyy"):u).filter(u=>R?!u.size.every(te=>te==null):u),barColors:H,width:q||d,height:Math.max(z,Q||(ee?z?(q||d)*ee>z?(q||d)*ee:z:(q||d)*ee:a)),suffix:xe,prefix:C,showValues:U,barPadding:me,showTicks:de,leftMargin:f,rightMargin:L,topMargin:ae,bottomMargin:se,truncateBy:he,showLabels:J,tooltip:ne,onSeriesMouseOver:W,refValues:pe,maxValue:Y.checkIfNullOrUndefined(S)?Math.max(...l.map(u=>Math.max(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te)))))<0?0:Math.max(...l.map(u=>Math.max(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te))))):S,minValue:Y.checkIfNullOrUndefined(b)?Math.min(...l.map(u=>Math.min(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te)))))>=0?0:Math.min(...l.map(u=>Math.min(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te))))):b,onSeriesMouseClick:g,selectedColor:je,labelOrder:M,rtl:N==="he"||N==="ar",maxBarThickness:v,resetSelectionOnDoubleClick:X,detailsOnClick:$,barAxisTitle:T,noOfTicks:ue,valueColor:P,styles:B,classNames:re,colorDomain:I,animate:F===!0?{duration:.5,once:!0,amount:.5}:F||{duration:0,once:!0,amount:0},precision:h,customLayers:k,naLabel:c}):null})]})}),A||ie?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:B?.footnote,source:B?.source},classNames:{footnote:re?.footnote,source:re?.source},sources:A,footNote:ie,width:q}):null]})})})})}function nt(fe){const{data:l,barColors:p,barPadding:H,showTicks:A,leftMargin:G,rightMargin:me,truncateBy:de,width:he,height:Q,topMargin:q,bottomMargin:ie,tooltip:I,onSeriesMouseOver:oe,showLabels:xe,suffix:C,prefix:U,showValues:_,refValues:Z,maxValue:E,onSeriesMouseClick:f,selectedColor:L,rtl:ae,labelOrder:se,maxBarThickness:J,minBarThickness:ee,resetSelectionOnDoubleClick:ne,detailsOnClick:W,barAxisTitle:pe,valueColor:ce,noOfTicks:S,styles:b,classNames:g,animate:w,colorDomain:D,precision:N,customLayers:M,naLabel:z}=fe,V=m.useRef(null),v=Pe.useInView(V,{once:w.once,amount:w.amount}),j={top:pe?q+25:q,bottom:ie,left:G,right:me},[X,$]=m.useState(void 0),[T,ue]=m.useState(void 0),[P,B]=m.useState(void 0),[re,R]=m.useState(void 0),F=he-j.left-j.right,h=Q-j.top-j.bottom,k=l.map((a,r)=>({...a,id:se?`${a.label}`:`${r}`})),y=se||k.map(a=>`${a.id}`),c=He.linear().domain([0,E]).range([0,F]).nice(),d=$e.band().domain(y).range([0,ee?Math.max(h,ee*y.length):J?Math.min(h,J*y.length):h]).paddingInner(H),o=c.ticks(S);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:V,width:`${he}px`,height:`${Q}px`,viewBox:`0 0 ${he} ${Q}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${j.left},${j.top})`,children:[A?e.jsxRuntimeExports.jsx(Qe.XTicksAndGridLines,{values:o.filter(a=>a!==0),x:o.filter(a=>a!==0).map(a=>c(a)),y1:0-q,y2:h+j.bottom,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.xAxis?.labels},classNames:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},suffix:C,prefix:U,labelType:"secondary",showGridLines:!0,precision:N}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:F/2,y:0-j.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),M.filter(a=>a.position==="before").map(a=>a.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[k.map(a=>Y.checkIfNullOrUndefined(d(a.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",variants:{initial:{x:0,y:d(`${a.id}`)},whileInView:{x:0,y:d(`${a.id}`),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},children:[a.size.map((r,t)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{opacity:L?p[t]===L?1:.3:1,onMouseEnter:s=>{$({...a,sizeIndex:t}),R(s.clientY),B(s.clientX),oe?.({...a,sizeIndex:t})},onMouseMove:s=>{$({...a,sizeIndex:t}),R(s.clientY),B(s.clientX)},onMouseLeave:()=>{$(void 0),B(void 0),R(void 0),oe?.(void 0)},onClick:()=>{(f||W)&&(Te.isEqual(T,{...a,sizeIndex:t})&&ne?(ue(void 0),f?.(void 0)):(ue({...a,sizeIndex:t}),f&&f({...a,sizeIndex:t})))},children:[r?e.jsxRuntimeExports.jsx(ge.motion.rect,{y:0,style:{fill:p[t]},height:d.bandwidth(),exit:{width:0,x:c(0),transition:{duration:w.duration}},variants:{initial:{width:0,x:c(0),fill:p[t]},whileInView:{width:c(r||0),x:c(t===0?0:ke.sum(a.size.filter((s,x)=>x<t&&s))),fill:p[t],transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial"},t):null,_?e.jsxRuntimeExports.jsx(ge.motion.text,{y:d.bandwidth()/2,style:{textAnchor:"middle",...b?.graphObjectValues||{}},dy:"0.33em",className:e.mo("graph-value text-sm",g?.graphObjectValues),exit:{opacity:0,transition:{duration:w.duration}},variants:{initial:{x:c(0),opacity:0,fill:Ke.getTextColorBasedOnBgColor(p[t])},whileInView:{x:c(t===0?0:ke.sum(a.size.filter((s,x)=>x<t&&s)))+c(r||0)/2,opacity:r&&c(r)/Me.numberFormattingFunction(r,z,N,U,C).length>12?1:0,fill:Ke.getTextColorBasedOnBgColor(p[t]),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",children:Me.numberFormattingFunction(r,z,N,U,C)}):null]},`${a.label}-${D[t]||t}`)),xe?e.jsxRuntimeExports.jsx(Ze.YAxesLabels,{value:`${a.label}`.length<de?`${a.label}`:`${`${a.label}`.substring(0,de)}...`,y:0,x:0-j.left,width:0+j.left,height:d.bandwidth(),style:b?.yAxis?.labels,className:g?.yAxis?.labels,animate:w,isInView:v}):null,_?e.jsxRuntimeExports.jsx(ge.motion.text,{className:e.mo("graph-value graph-value-total text-sm",ce?"":" fill-primary-gray-700 dark:fill-primary-gray-300",g?.graphObjectValues),style:{...ce?{fill:ce}:{},textAnchor:"start",...b?.graphObjectValues||{}},y:d.bandwidth()/2,dx:5,dy:"0.33em",variants:{initial:{x:c(0),opacity:0},whileInView:{x:c(ke.sum(a.size.map(r=>r||0))),opacity:1,transition:{duration:w.duration}}},exit:{opacity:0,transition:{duration:w.duration}},initial:"initial",animate:v?"whileInView":"initial",children:Me.numberFormattingFunction(ke.sum(a.size.filter(r=>r)),z,N,U,C)}):null]},a.label)),e.jsxRuntimeExports.jsx(Be.Axis,{x1:c(0),x2:c(0),y1:-2.5,y2:h+j.bottom,classNames:{axis:g?.yAxis?.axis},styles:{axis:b?.yAxis?.axis}}),Z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Z.map((a,r)=>e.jsxRuntimeExports.jsx(Fe.RefLineX,{text:a.text,color:a.color,x:c(a.value),y1:0-j.top,y2:h+j.bottom,textSide:c(a.value)>F*.75||ae?"left":"right",classNames:a.classNames,styles:a.styles,animate:w,isInView:v},r))}):null]}),M.filter(a=>a.position==="after").map(a=>a.layer)]})}),X&&I&&P&&re?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:X,body:I,xPos:P,yPos:re,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,W&&T!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:T!==void 0,onClose:()=>{ue(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof W=="string"?{__html:Ve.string2HTML(W,T)}:void 0,children:typeof W=="function"?W(T):null})}):null]})}function lt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:A,graphDescription:G,barPadding:me=.25,showTicks:de=!0,leftMargin:he=100,rightMargin:Q=40,truncateBy:q=999,height:ie,width:I,footNote:oe,colorDomain:xe,colorLegendTitle:C,padding:U,backgroundColor:_=!1,topMargin:Z=25,bottomMargin:E=10,tooltip:f,onSeriesMouseOver:L,suffix:ae="",prefix:se="",showLabels:J=!0,relativeHeight:ee,showValues:ne=!0,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:S,graphDownload:b=!1,dataDownload:g=!1,language:w="en",labelOrder:D,minHeight:N=0,theme:M="light",maxBarThickness:z,sortParameter:V,maxNumberOfBars:v,minBarThickness:j,showColorScale:X=!0,ariaLabel:$,resetSelectionOnDoubleClick:T=!0,detailsOnClick:ue,barAxisTitle:P,noOfTicks:B=5,valueColor:re,styles:R,classNames:F,filterNA:h=!0,animate:k=!1,precision:y=2,customLayers:c=[],timeline:d={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:o="NA"}=fe,[a,r]=m.useState(0),[t,s]=m.useState(0),[x,Oe]=m.useState(d.autoplay),K=Re.sort(Se.uniqBy(l.filter(n=>n.date!==void 0&&n.date!==null),n=>n.date).map(n=>Ee.parse(`${n.date}`,d.dateFormat||"yyyy",new Date).getTime()),(n,O)=>Ye.ascending(n,O)),[je,ve]=m.useState(d.autoplay?0:K.length-1),[we,le]=m.useState(void 0),ye=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{const n=new ResizeObserver(O=>{r(I||O[0].target.clientWidth||620),s(ie||O[0].target.clientHeight||480)});return ye.current&&(s(ye.current.clientHeight||480),r(ye.current.clientWidth||620),I||n.observe(ye.current)),()=>n.disconnect()},[I,ie]),m.useEffect(()=>{const n=setInterval(()=>{ve(O=>O<K.length-1?O+1:0)},(d.speed||2)*1e3);return x||clearInterval(n),()=>clearInterval(n)},[K,x,d.speed]);const te=Re.getSliderMarks(K,je,d.showOnlyActiveDate,d.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${M||"light"} flex ${I?"w-fit grow-0":"w-full grow"}`,dir:w==="he"||w==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${_?_===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${w||"en"}`,F?.graphContainer),style:{...R?.graphContainer||{},..._&&_!==!0?{backgroundColor:_}:{}},id:pe,ref:u,"aria-label":$||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${G?` ${G}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:_?U||"1rem":U||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[p||G||b||g?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:R?.title,description:R?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:G,width:I,graphDownload:b?u.current:void 0,dataDownload:g?l.map(n=>n.data).filter(n=>n!==void 0).length>0?l.map(n=>n.data).filter(n=>n!==void 0):l.filter(n=>n!==void 0):null}):null,d.enabled&&K.length>0&&te?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Oe(!x)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":x?"Click to pause animation":"Click to play animation",children:x?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:K[0],max:K[K.length-1],marks:te,step:null,defaultValue:K[K.length-1],value:K[je],onChangeComplete:n=>{ve(K.indexOf(n))},onChange:n=>{ve(K.indexOf(n))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[X?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:I,colorDomain:xe,colors:H,colorLegendTitle:C,setSelectedColor:le,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:ye,"aria-label":"Graph area",children:(I||a)&&(ie||t)?e.jsxRuntimeExports.jsx(nt,{data:V!==void 0?V==="total"?De.sortBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n),n=>ke.sum(n.size.filter(O=>!Y.checkIfNullOrUndefined(O)))).reverse().filter((n,O)=>v?O<v:!0):De.sortBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n),n=>Y.checkIfNullOrUndefined(n.size[V])?-1/0:n.size[V]).reverse().filter((n,O)=>v?O<v:!0):Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n).filter((n,O)=>v?O<v:!0),barColors:H,width:I||a,height:Math.max(N,ie||(ee?N?(I||a)*ee>N?(I||a)*ee:N:(I||a)*ee:t)),barPadding:me,showTicks:de,leftMargin:he,rightMargin:Q,topMargin:Z,bottomMargin:E,truncateBy:q,showLabels:J,tooltip:f,onSeriesMouseOver:L,showValues:ne,suffix:ae,prefix:se,refValues:W,maxValue:Y.checkIfNullOrUndefined(ce)?Math.max(...l.map(n=>ke.sum(n.size.filter(O=>!Y.checkIfNullOrUndefined(O)))||0)):ce,onSeriesMouseClick:S,selectedColor:we,rtl:w==="he"||w==="ar",labelOrder:D,maxBarThickness:z,minBarThickness:j,resetSelectionOnDoubleClick:T,detailsOnClick:ue,barAxisTitle:P,noOfTicks:B,valueColor:re,classNames:F,styles:R,animate:k===!0?{duration:.5,once:!0,amount:.5}:k||{duration:0,once:!0,amount:0},colorDomain:xe,precision:y,customLayers:c,naLabel:o}):null})]})}),A||oe?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:R?.footnote,source:R?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:A,footNote:oe,width:I}):null]})})})})}function ot(fe){const{data:l,width:p,height:H,barColor:A,suffix:G,prefix:me,barPadding:de,showLabels:he,showValues:Q,showTicks:q,colorDomain:ie,truncateBy:I,rightMargin:oe,topMargin:xe,bottomMargin:C,leftMargin:U,tooltip:_,onSeriesMouseOver:Z,refValues:E,selectedColor:f,maxValue:L,minValue:ae,highlightedDataPoints:se,onSeriesMouseClick:J,labelOrder:ee,maxBarThickness:ne,minBarThickness:W,resetSelectionOnDoubleClick:pe,detailsOnClick:ce,barAxisTitle:S,valueColor:b,noOfTicks:g,styles:w,classNames:D,dimmedOpacity:N,animate:M,precision:z,customLayers:V,naLabel:v}=fe,j=m.useRef(null),X=Pe.useInView(j,{once:M.once,amount:M.amount}),$={top:xe,bottom:C,left:S?U+30:U,right:oe},[T,ue]=m.useState(void 0),[P,B]=m.useState(void 0),[re,R]=m.useState(void 0),[F,h]=m.useState(void 0),k=p-$.left-$.right,y=H-$.top-$.bottom,c=He.linear().domain([ae,L]).range([y,0]).nice(),d=l.map((t,s)=>({...t,id:ee?`${t.label}`:`${s}`})),o=ee||d.map(t=>`${t.id}`),a=$e.band().domain(o).range([0,W?Math.max(k,W*o.length):ne?Math.min(k,ne*o.length):k]).paddingInner(de),r=c.ticks(g);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:j,width:`${p}px`,height:`${H}px`,viewBox:`0 0 ${p} ${H}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${$.left},${$.top})`,children:[e.jsxRuntimeExports.jsx(Be.Axis,{y1:c(ae<0?0:ae),y2:c(ae<0?0:ae),x1:0-U,x2:k+$.right,label:Me.numberFormattingFunction(ae<0?0:ae,v,z,me,G),labelPos:{x:0-U,dx:0,dy:L<0?"1em":-5,y:c(ae<0?0:ae)},classNames:{axis:D?.xAxis?.axis,label:D?.yAxis?.labels},styles:{axis:w?.xAxis?.axis,label:w?.yAxis?.labels}}),q?e.jsxRuntimeExports.jsx(tt.YTicksAndGridLines,{values:r.filter(t=>t!==0),y:r.filter(t=>t!==0).map(t=>c(t)),x1:0-U,x2:k+$.right,styles:{gridLines:w?.yAxis?.gridLines,labels:w?.yAxis?.labels},classNames:{gridLines:D?.yAxis?.gridLines,labels:D?.yAxis?.labels},suffix:G,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:z}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:0-U-15,y:y/2,style:w?.yAxis?.title,className:D?.yAxis?.title,text:S,rotate90:!0}),V.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[d.map((t,s)=>Y.checkIfNullOrUndefined(a(t.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",initial:"initial",animate:X?"whileInView":"initial",variants:{initial:{opacity:f?t.color&&A[ie.indexOf(t.color)]===f?1:N:se.length!==0?se.indexOf(t.label)!==-1?.85:N:.85},whileInView:{opacity:f?t.color&&A[ie.indexOf(t.color)]===f?1:N:se.length!==0?se.indexOf(t.label)!==-1?.85:N:.85,transition:{duration:M.duration}}},exit:{opacity:0,transition:{duration:M.duration}},onMouseEnter:x=>{ue(t),h(x.clientY),R(x.clientX),Z?.(t)},onClick:()=>{(J||ce)&&(Te.isEqual(P,t)&&pe?(B(void 0),J?.(void 0)):(B(t),J?.(t)))},onMouseMove:x=>{ue(t),h(x.clientY),R(x.clientX)},onMouseLeave:()=>{ue(void 0),R(void 0),h(void 0),Z?.(void 0)},children:[t.size?e.jsxRuntimeExports.jsx(ge.motion.rect,{width:a.bandwidth(),initial:"initial",animate:X?"whileInView":"initial",variants:{initial:{height:0,x:a(`${t.id}`),y:c(0),fill:l.filter(x=>x.color).length===0?A[0]:t.color?A[ie.indexOf(t.color)]:Ce.Colors.gray},whileInView:{height:t.size?Math.abs(c(t.size)-c(0)):0,y:t.size&&t.size>0?c(t.size):c(0),x:a(`${t.id}`),fill:l.filter(x=>x.color).length===0?A[0]:t.color?A[ie.indexOf(t.color)]:Ce.Colors.gray,transition:{duration:M.duration}}},exit:{height:0,y:c(0),transition:{duration:M.duration}}}):null,he?e.jsxRuntimeExports.jsx(et.XAxesLabels,{value:`${t.label}`.length<I?`${t.label}`:`${`${t.label}`.substring(0,I)}...`,y:(t.size||0)<0?0:c(0)+5,x:a(`${t.id}`),width:a.bandwidth(),height:(t.size||0)<0?c(0)-5:$.bottom,style:w?.xAxis?.labels,className:D?.xAxis?.labels,alignment:(t.size||0)<0?"bottom":"top",animate:M,isInView:X}):null,Q?e.jsxRuntimeExports.jsx(ge.motion.text,{style:{textAnchor:"middle",...w?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!b&&A.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",D?.graphObjectValues),dy:t.size?t.size>=0?"-5px":"1em":"-5px",variants:{initial:{x:a(`${t.id}`)+a.bandwidth()/2,y:c(0),opacity:0,fill:b||(l.filter(x=>x.color).length===0?A[0]:t.color?A[ie.indexOf(t.color)]:Ce.Colors.gray)},whileInView:{x:a(`${t.id}`)+a.bandwidth()/2,y:c(t.size||0),fill:b||(l.filter(x=>x.color).length===0?A[0]:t.color?A[ie.indexOf(t.color)]:Ce.Colors.gray),opacity:1,transition:{duration:M.duration}}},initial:"initial",animate:X?"whileInView":"initial",exit:{opacity:0,transition:{duration:M.duration}},children:Me.numberFormattingFunction(t.size,v,z,me,G)}):null]},t.label)),E?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:E.map((t,s)=>e.jsxRuntimeExports.jsx(Fe.RefLineY,{text:t.text,color:t.color,y:c(t.value),x1:0-U,x2:k+$.right,classNames:t.classNames,styles:t.styles,animate:M,isInView:X},s))}):null]}),V.filter(t=>t.position==="after").map(t=>t.layer)]})}),T&&_&&re&&F?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:T,body:_,xPos:re,yPos:F,backgroundStyle:w?.tooltip,className:D?.tooltip}):null,ce&&P!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:P!==void 0,onClose:()=>{B(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof ce=="string"?{__html:Ve.string2HTML(ce,P)}:void 0,children:typeof ce=="function"?ce(P):null})}):null]})}function ut(fe){const{data:l,graphTitle:p,colors:H,barPadding:A=.25,showTicks:G=!0,leftMargin:me=20,rightMargin:de=20,topMargin:he=20,bottomMargin:Q=25,truncateBy:q=999,showLabels:ie=!0,showValues:I=!0,backgroundColor:oe=!1,suffix:xe="",prefix:C="",sources:U,graphDescription:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,showColorScale:pe=!0,graphID:ce,maxValue:S,minValue:b,highlightedDataPoints:g=[],onSeriesMouseClick:w,graphDownload:D=!1,dataDownload:N=!1,language:M="en",theme:z="light",sortData:V,labelOrder:v,showNAColor:j=!0,minHeight:X=0,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B=!0,detailsOnClick:re,barAxisTitle:R,noOfTicks:F=5,valueColor:h,styles:k,classNames:y,filterNA:c=!0,animate:d=!1,dimmedOpacity:o=.3,precision:a=2,customLayers:r=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:s="NA"}=fe,[x,Oe]=m.useState(0),[K,je]=m.useState(0),[ve,we]=m.useState(t.autoplay),le=Re.sort(Se.uniqBy(l.filter(i=>i.date!==void 0&&i.date!==null),i=>i.date).map(i=>Ee.parse(`${i.date}`,t.dateFormat||"yyyy",new Date).getTime()),(i,be)=>Ye.ascending(i,be)),[ye,u]=m.useState(t.autoplay?0:le.length-1),[te,n]=m.useState(void 0),O=m.useRef(null),_e=m.useRef(null);m.useEffect(()=>{const i=new ResizeObserver(be=>{Oe(E||be[0].target.clientWidth||620),je(Z||be[0].target.clientHeight||480)});return O.current&&(je(O.current.clientHeight||480),Oe(O.current.clientWidth||620),E||i.observe(O.current)),()=>i.disconnect()},[E,Z]),m.useEffect(()=>{const i=setInterval(()=>{u(be=>be<le.length-1?be+1:0)},(t.speed||2)*1e3);return ve||clearInterval(i),()=>clearInterval(i)},[le,ve,t.speed]);const Je=Re.getSliderMarks(le,ye,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${z||"light"} flex ${E?"w-fit grow-0":"w-full grow"}`,dir:M==="he"||M==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${oe?oe===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,y?.graphContainer),style:{...k?.graphContainer||{},...oe&&oe!==!0?{backgroundColor:oe}:{}},id:ce,ref:_e,"aria-label":P||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${_?` ${_}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:oe?se||"1rem":se||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||_||D||N?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:k?.title,description:k?.description},classNames:{title:y?.title,description:y?.description},graphTitle:p,graphDescription:_,width:E,graphDownload:D?_e.current:void 0,dataDownload:N?l.map(i=>i.data).filter(i=>i!==void 0).length>0?l.map(i=>i.data).filter(i=>i!==void 0):l.filter(i=>i!==void 0):null}):null,t.enabled&&le.length>0&&Je?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!ve)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ve?"Click to pause animation":"Click to play animation",children:ve?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:le[0],max:le[le.length-1],marks:Je,step:null,defaultValue:le[le.length-1],value:le[ye],onChangeComplete:i=>{u(le.indexOf(i))},onChange:i=>{u(le.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[pe&&l.filter(i=>i.color).length!==0?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:E,colorLegendTitle:ae,colors:H||Ce.Colors[z].categoricalColors.colors,colorDomain:L||Se.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),setSelectedColor:n,showNAColor:j}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:O,"aria-label":"Graph area",children:(E||x)&&(Z||K)?e.jsxRuntimeExports.jsx(ot,{data:V==="asc"?De.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).filter((i,be)=>T?be<T:!0):V==="desc"?De.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).reverse().filter((i,be)=>T?be<T:!0):Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i).filter((i,be)=>T?be<T:!0),barColor:l.filter(i=>i.color).length===0?H?[H]:[Ce.Colors.primaryColors["blue-600"]]:H||Ce.Colors[z].categoricalColors.colors,colorDomain:l.filter(i=>i.color).length===0?[]:L||Se.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),width:E||x,refValues:W,height:Math.max(X,Z||(J?X?(E||x)*J>X?(E||x)*J:X:(E||x)*J:K)),suffix:xe,prefix:C,barPadding:A,showLabels:ie,showValues:I,showTicks:G,truncateBy:q,leftMargin:me,rightMargin:de,selectedColor:te,topMargin:he,bottomMargin:Q,tooltip:ee,onSeriesMouseOver:ne,maxValue:Y.checkIfNullOrUndefined(S)?Math.max(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size))<0?0:Math.max(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size)):S,minValue:Y.checkIfNullOrUndefined(b)?Math.min(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size))>=0?0:Math.min(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size)):b,highlightedDataPoints:g,onSeriesMouseClick:w,labelOrder:v,maxBarThickness:$,minBarThickness:ue,resetSelectionOnDoubleClick:B,detailsOnClick:re,barAxisTitle:R,noOfTicks:F,valueColor:h,styles:k,classNames:y,animate:d===!0?{duration:.5,once:!0,amount:.5}:d||{duration:0,once:!0,amount:0},dimmedOpacity:o,precision:a,customLayers:r,naLabel:s}):null})]})}),U||f?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:k?.footnote,source:k?.source},classNames:{footnote:y?.footnote,source:y?.source},sources:U,footNote:f,width:E}):null]})})})})}function ct(fe){const{data:l,width:p,height:H,barColors:A,suffix:G,prefix:me,barPadding:de,showLabels:he,showValues:Q,showTicks:q,truncateBy:ie,leftMargin:I,rightMargin:oe,topMargin:xe,bottomMargin:C,tooltip:U,onSeriesMouseOver:_,refValues:Z,maxValue:E,minValue:f,onSeriesMouseClick:L,selectedColor:ae,labelOrder:se,maxBarThickness:J,resetSelectionOnDoubleClick:ee,detailsOnClick:ne,barAxisTitle:W,valueColor:pe,noOfTicks:ce,styles:S,classNames:b,animate:g,colorDomain:w,precision:D,customLayers:N,naLabel:M}=fe,z=m.useRef(null),V=Pe.useInView(z,{once:g.once,amount:g.amount}),v={top:xe,bottom:C,left:W?I+30:I,right:oe},[j,X]=m.useState(void 0),[$,T]=m.useState(void 0),[ue,P]=m.useState(void 0),[B,re]=m.useState(void 0),R=p-v.left-v.right,F=H-v.top-v.bottom,h=He.linear().domain([f,E]).range([F,0]).nice(),k=l.map((a,r)=>({...a,id:se?`${a.label}`:`${r}`})),y=se||k.map(a=>`${a.id}`),c=$e.band().domain(y).range([0,J?Math.min(R,J*y.length):R]).paddingInner(de),d=$e.band().domain(l[0].size.map((a,r)=>`${r}`)).range([0,c.bandwidth()]).paddingInner(.1),o=h.ticks(ce);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{width:`${p}px`,height:`${H}px`,viewBox:`0 0 ${p} ${H}`,direction:"ltr",ref:z,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${v.left},${v.top})`,children:[e.jsxRuntimeExports.jsx(Be.Axis,{y1:h(f<0?0:f),y2:h(f<0?0:f),x1:0-I,x2:R+v.right,label:Me.numberFormattingFunction(f<0?0:f,M,D,me,G),labelPos:{x:0-I,dx:0,dy:E<0?"1em":-5,y:h(f<0?0:f)},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:S?.xAxis?.axis,label:S?.yAxis?.labels}}),q?e.jsxRuntimeExports.jsx(tt.YTicksAndGridLines,{values:o.filter(a=>a!==0),y:o.filter(a=>a!==0).map(a=>h(a)),x1:0-I,x2:R+v.right,styles:{gridLines:S?.yAxis?.gridLines,labels:S?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:G,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:D}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:0-I-15,y:F/2,style:S?.yAxis?.title,className:b?.yAxis?.title,text:W,rotate90:!0}),N.filter(a=>a.position==="before").map(a=>a.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[k.map(a=>Y.checkIfNullOrUndefined(c(a.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{variants:{initial:{x:c(`${a.id}`),y:0},whileInView:{x:c(`${a.id}`),y:0,transition:{duration:g.duration}}},initial:"initial",animate:V?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[a.size.map((r,t)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?A[t]===ae?1:.3:.85,onMouseEnter:s=>{X({...a,sizeIndex:t}),re(s.clientY),P(s.clientX),_?.({...a,sizeIndex:t})},onMouseMove:s=>{X({...a,sizeIndex:t}),re(s.clientY),P(s.clientX)},onMouseLeave:()=>{X(void 0),P(void 0),re(void 0),_?.(void 0)},onClick:()=>{(L||ne)&&(Te.isEqual($,{...a,sizeIndex:t})&&ee?(T(void 0),L?.(void 0)):(T({...a,sizeIndex:t}),L&&L({...a,sizeIndex:t})))},children:[e.jsxRuntimeExports.jsx(ge.motion.rect,{x:d(`${t}`),width:d.bandwidth(),variants:{initial:{height:0,y:h(0),fill:A[t]},whileInView:{height:Y.checkIfNullOrUndefined(r)?0:Math.abs(h(r)-h(0)),y:Y.checkIfNullOrUndefined(r)?h(0):r>0?h(r):h(0),fill:A[t],transition:{duration:g.duration}}},exit:{height:0,y:h(0),transition:{duration:g.duration}},initial:"initial",animate:V?"whileInView":"initial"}),Q?e.jsxRuntimeExports.jsx(ge.motion.text,{x:d(`${t}`)+d.bandwidth()/2,style:{fill:pe||A[t],textAnchor:"middle",...S?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:r?r>=0?"-5px":"1em":"-5px",variants:{initial:{y:h(0),opacity:0},whileInView:{y:h(r||0),opacity:1,transition:{duration:g.duration}}},initial:"initial",animate:V?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:Me.numberFormattingFunction(r,M,D,me,G)}):null]},`${a.label}-${w[t]||t}`)),he?e.jsxRuntimeExports.jsx(et.XAxesLabels,{value:`${a.label}`.length<ie?`${a.label}`:`${`${a.label}`.substring(0,ie)}...`,y:h(0)+5,x:0,width:c.bandwidth(),height:v.bottom,style:S?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:V}):null]},a.label)),Z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Z.map((a,r)=>e.jsxRuntimeExports.jsx(Fe.RefLineY,{text:a.text,color:a.color,y:h(a.value),x1:0-I,x2:R+v.right,classNames:a.classNames,styles:a.styles,animate:g,isInView:V},r))}):null]}),N.filter(a=>a.position==="after").map(a=>a.layer)]})}),j&&U&&ue&&B?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:j,body:U,xPos:ue,yPos:B,backgroundStyle:S?.tooltip,className:b?.tooltip}):null,ne&&$!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:$!==void 0,onClose:()=>{T(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof ne=="string"?{__html:Ve.string2HTML(ne,$)}:void 0,children:typeof ne=="function"?ne($):null})}):null]})}function xt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:A,graphDescription:G,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:Q=20,topMargin:q=20,bottomMargin:ie=25,truncateBy:I=999,showLabels:oe=!0,showValues:xe=!0,backgroundColor:C=!1,suffix:U="",prefix:_="",height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,graphID:pe,maxValue:ce,minValue:S,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:w=!1,language:D="en",theme:N="light",labelOrder:M,minHeight:z=0,maxBarThickness:V,ariaLabel:v,resetSelectionOnDoubleClick:j=!0,detailsOnClick:X,barAxisTitle:$,noOfTicks:T=5,valueColor:ue,styles:P,classNames:B,filterNA:re=!0,showColorScale:R=!0,animate:F=!1,precision:h=2,customLayers:k=[],timeline:y={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:c="NA"}=fe,[d,o]=m.useState(0),[a,r]=m.useState(0),[t,s]=m.useState(y.autoplay),x=Re.sort(Se.uniqBy(l.filter(u=>u.date!==void 0&&u.date!==null),u=>u.date).map(u=>Ee.parse(`${u.date}`,y.dateFormat||"yyyy",new Date).getTime()),(u,te)=>Ye.ascending(u,te)),[Oe,K]=m.useState(y.autoplay?0:x.length-1),[je,ve]=m.useState(void 0),we=m.useRef(null),le=m.useRef(null);m.useEffect(()=>{const u=new ResizeObserver(te=>{o(E||te[0].target.clientWidth||620),r(Z||te[0].target.clientHeight||480)});return we.current&&(r(we.current.clientHeight||480),o(we.current.clientWidth||620),E||u.observe(we.current)),()=>u.disconnect()},[E,Z]),m.useEffect(()=>{const u=setInterval(()=>{K(te=>te<x.length-1?te+1:0)},(y.speed||2)*1e3);return t||clearInterval(u),()=>clearInterval(u)},[x,t,y.speed]);const ye=Re.getSliderMarks(x,Oe,y.showOnlyActiveDate,y.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${N||"light"} flex ${E?"w-fit grow-0":"w-full grow"}`,dir:D==="he"||D==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${D||"en"}`,B?.graphContainer),style:{...P?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:pe,ref:le,"aria-label":v||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${G?` ${G}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:C?se||"1rem":se||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||G||g||w?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:P?.title,description:P?.description},classNames:{title:B?.title,description:B?.description},graphTitle:p,graphDescription:G,width:E,graphDownload:g?le.current:void 0,dataDownload:w?l.map(u=>u.data).filter(u=>u!==void 0).length>0?l.map(u=>u.data).filter(u=>u!==void 0):l.filter(u=>u!==void 0):null}):null,y.enabled&&x.length>0&&ye?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{s(!t)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":t?"Click to pause animation":"Click to play animation",children:t?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:x[0],max:x[x.length-1],marks:ye,step:null,defaultValue:x[x.length-1],value:x[Oe],onChangeComplete:u=>{K(x.indexOf(u))},onChange:u=>{K(x.indexOf(u))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[R?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:E,colorDomain:L,colors:H,colorLegendTitle:ae,setSelectedColor:ve,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:we,"aria-label":"Graph area",children:(E||d)&&(Z||a)?e.jsxRuntimeExports.jsx(ct,{data:Ne.ensureCompleteDataForStackedBarChart(l,y.dateFormat||"yyyy").filter(u=>y.enabled?u.date===Ee.format(new Date(x[Oe]),y.dateFormat||"yyyy"):u).filter(u=>re?!u.size.every(te=>te==null):u),barColors:H,width:E||d,height:Math.max(z,Z||(J?z?(E||d)*J>z?(E||d)*J:z:(E||d)*J:a)),suffix:U,prefix:_,barPadding:me,showLabels:oe,showValues:xe,showTicks:de,truncateBy:I,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,tooltip:ee,onSeriesMouseOver:ne,refValues:W,maxValue:Y.checkIfNullOrUndefined(ce)?Math.max(...l.map(u=>Math.max(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te)))))<0?0:Math.max(...l.map(u=>Math.max(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te))))):ce,minValue:Y.checkIfNullOrUndefined(S)?Math.min(...l.map(u=>Math.min(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te)))))>=0?0:Math.min(...l.map(u=>Math.min(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te))))):S,onSeriesMouseClick:b,selectedColor:je,labelOrder:M,maxBarThickness:V,resetSelectionOnDoubleClick:j,detailsOnClick:X,barAxisTitle:$,noOfTicks:T,valueColor:ue,styles:P,classNames:B,animate:F===!0?{duration:.5,once:!0,amount:.5}:F||{duration:0,once:!0,amount:0},colorDomain:L,precision:h,customLayers:k,naLabel:c}):null})]})}),A||f?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:P?.footnote,source:P?.source},classNames:{footnote:B?.footnote,source:B?.source},sources:A,footNote:f,width:E}):null]})})})})}function dt(fe){const{data:l,width:p,height:H,barColors:A,barPadding:G,showLabels:me,showTicks:de,truncateBy:he,leftMargin:Q,topMargin:q,bottomMargin:ie,rightMargin:I,tooltip:oe,onSeriesMouseOver:xe,suffix:C,prefix:U,showValues:_,refValues:Z,maxValue:E,onSeriesMouseClick:f,selectedColor:L,labelOrder:ae,maxBarThickness:se,minBarThickness:J,resetSelectionOnDoubleClick:ee,detailsOnClick:ne,barAxisTitle:W,valueColor:pe,noOfTicks:ce,styles:S,classNames:b,animate:g,colorDomain:w,precision:D,customLayers:N,naLabel:M}=fe,z=m.useRef(null),V=Pe.useInView(z,{once:g.once,amount:g.amount}),v={top:q,bottom:ie,left:W?Q+30:Q,right:I},[j,X]=m.useState(void 0),[$,T]=m.useState(void 0),[ue,P]=m.useState(void 0),[B,re]=m.useState(void 0),R=p-v.left-v.right,F=H-v.top-v.bottom,h=He.linear().domain([0,E]).range([F,0]).nice(),k=l.map((o,a)=>({...o,id:ae?`${o.label}`:`${a}`})),y=ae||k.map(o=>`${o.id}`),c=$e.band().domain(y).range([0,J?Math.max(R,J*y.length):se?Math.min(R,se*y.length):R]).paddingInner(G),d=h.ticks(ce);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{width:`${p}px`,height:`${H}px`,viewBox:`0 0 ${p} ${H}`,direction:"ltr",ref:z,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${v.left},${v.top})`,children:[e.jsxRuntimeExports.jsx(Be.Axis,{y1:h(0),y2:h(0),x1:0-Q,x2:R+v.right,label:Me.numberFormattingFunction(0,M,D,U,C),labelPos:{x:0-Q,y:h(0),dx:0,dy:-5},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:S?.xAxis?.axis,label:S?.yAxis?.labels}}),de?e.jsxRuntimeExports.jsx(tt.YTicksAndGridLines,{values:d.filter(o=>o!==0),y:d.filter(o=>o!==0).map(o=>h(o)),x1:0-Q,x2:R+v.right,styles:{gridLines:S?.yAxis?.gridLines,labels:S?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:C,prefix:U,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:D}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:0-Q-15,y:F/2,style:S?.yAxis?.title,className:b?.yAxis?.title,text:W,rotate90:!0}),N.filter(o=>o.position==="before").map(o=>o.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[k.map(o=>Y.checkIfNullOrUndefined(c(o.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",variants:{initial:{x:c(`${o.id}`),y:0},whileInView:{x:c(`${o.id}`),y:0,transition:{duration:g.duration}}},transition:{duration:g.duration},initial:"initial",animate:V?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[o.size.map((a,r)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{opacity:L?A[r]===L?1:.3:1,onMouseEnter:t=>{X({...o,sizeIndex:r}),re(t.clientY),P(t.clientX),xe?.({...o,sizeIndex:r})},onMouseMove:t=>{X({...o,sizeIndex:r}),re(t.clientY),P(t.clientX)},onMouseLeave:()=>{X(void 0),P(void 0),re(void 0),xe?.(void 0)},onClick:()=>{(f||ne)&&(Te.isEqual($,{...o,sizeIndex:r})&&ee?(T(void 0),f?.(void 0)):(T({...o,sizeIndex:r}),f&&f({...o,sizeIndex:r})))},children:[e.jsxRuntimeExports.jsx(ge.motion.rect,{x:0,width:c.bandwidth(),variants:{initial:{height:0,fill:A[r],y:h(0)},whileInView:{height:Math.abs(h(ke.sum(o.size.filter((t,s)=>s<=r&&t)))-h(ke.sum(o.size.filter((t,s)=>s<r&&t)))),y:h(ke.sum(o.size.filter((t,s)=>s<=r&&t))),fill:A[r],transition:{duration:g.duration}}},initial:"initial",animate:V?"whileInView":"initial",exit:{height:0,y:h(0),transition:{duration:g.duration}}}),_?e.jsxRuntimeExports.jsx(ge.motion.text,{x:c.bandwidth()/2,style:{fill:Ke.getTextColorBasedOnBgColor(A[r]),textAnchor:"middle",...S?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:"0.33em",variants:{initial:{y:h(0),opacity:0,fill:Ke.getTextColorBasedOnBgColor(A[r])},whileInView:{y:h(ke.sum(o.size.filter((t,s)=>s<=r&&t)))+Math.abs(h(ke.sum(o.size.filter((t,s)=>s<=r&&t)))-h(ke.sum(o.size.filter((t,s)=>s<r&&t))))/2,opacity:a&&Math.abs(h(ke.sum(o.size.filter((t,s)=>s<=r&&t)))-h(ke.sum(o.size.filter((t,s)=>s<r&&t))))>20?1:0,fill:Ke.getTextColorBasedOnBgColor(A[r]),transition:{duration:g.duration}}},initial:"initial",animate:V?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:Me.numberFormattingFunction(a,M,D,U,C)}):null]},`${o.label}-${w[r]||r}`)),me?e.jsxRuntimeExports.jsx(et.XAxesLabels,{value:`${o.label}`.length<he?`${o.label}`:`${`${o.label}`.substring(0,he)}...`,y:h(0)+5,x:0,width:c.bandwidth(),height:v.bottom,style:S?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:V}):null,_?e.jsxRuntimeExports.jsx(ge.motion.text,{style:{...pe&&{fill:pe},textAnchor:"middle",...S?.graphObjectValues||{}},x:c.bandwidth()/2,dy:-10,className:e.mo("graph-value graph-value-total",pe?"text-sm":"fill-primary-gray-700 dark:fill-primary-gray-300 text-sm",b?.graphObjectValues),variants:{initial:{y:h(0),opacity:0},whileInView:{y:h(ke.sum(o.size.map(a=>a||0))),opacity:1,transition:{duration:g.duration}}},exit:{opacity:0,transition:{duration:g.duration}},initial:"initial",animate:V?"whileInView":"initial",children:Me.numberFormattingFunction(ke.sum(o.size.filter(a=>a)),M,D,U,C)}):null]},o.label)),Z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Z.map((o,a)=>e.jsxRuntimeExports.jsx(Fe.RefLineY,{text:o.text,color:o.color,y:h(o.value),x1:0-Q,x2:R+v.right,classNames:o.classNames,styles:o.styles,animate:g,isInView:V},a))}):null]}),N.filter(o=>o.position==="after").map(o=>o.layer)]})}),j&&oe&&ue&&B?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:j,body:oe,xPos:ue,yPos:B,backgroundStyle:S?.tooltip,className:b?.tooltip}):null,ne&&$!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:$!==void 0,onClose:()=>{T(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof ne=="string"?{__html:Ve.string2HTML(ne,$)}:void 0,children:typeof ne=="function"?ne($):null})}):null]})}function mt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:A,graphDescription:G,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:Q=20,topMargin:q=20,bottomMargin:ie=25,truncateBy:I=999,showLabels:oe=!0,showValues:xe=!0,backgroundColor:C=!1,showColorScale:U=!0,suffix:_="",prefix:Z="",height:E,width:f,footNote:L,colorDomain:ae,colorLegendTitle:se,padding:J,tooltip:ee,onSeriesMouseOver:ne,relativeHeight:W,refValues:pe,graphID:ce,maxValue:S,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:w=!1,language:D="en",theme:N="light",labelOrder:M,minHeight:z=0,maxBarThickness:V,sortParameter:v,maxNumberOfBars:j,minBarThickness:X,ariaLabel:$,resetSelectionOnDoubleClick:T=!0,detailsOnClick:ue,barAxisTitle:P,noOfTicks:B=5,valueColor:re,styles:R,classNames:F,filterNA:h=!0,animate:k=!1,precision:y=2,customLayers:c=[],timeline:d={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:o="NA"}=fe,[a,r]=m.useState(0),[t,s]=m.useState(0),[x,Oe]=m.useState(d.autoplay),K=Re.sort(Se.uniqBy(l.filter(n=>n.date!==void 0&&n.date!==null),n=>n.date).map(n=>Ee.parse(`${n.date}`,d.dateFormat||"yyyy",new Date).getTime()),(n,O)=>Ye.ascending(n,O)),[je,ve]=m.useState(d.autoplay?0:K.length-1),[we,le]=m.useState(void 0),ye=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{const n=new ResizeObserver(O=>{r(f||O[0].target.clientWidth||620),s(E||O[0].target.clientHeight||480)});return ye.current&&(s(ye.current.clientHeight||480),r(ye.current.clientWidth||620),f||n.observe(ye.current)),()=>n.disconnect()},[f,E]),m.useEffect(()=>{const n=setInterval(()=>{ve(O=>O<K.length-1?O+1:0)},(d.speed||2)*1e3);return x||clearInterval(n),()=>clearInterval(n)},[K,x,d.speed]);const te=Re.getSliderMarks(K,je,d.showOnlyActiveDate,d.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${N||"light"} flex ${f?"w-fit grow-0":"w-full grow"}`,dir:D==="he"||D==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${D||"en"}`,F?.graphContainer),style:{...R?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:ce,ref:u,"aria-label":$||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${G?` ${G}`:""}`,children:e.jsxRuntimeExports.jsx("div",{style:{padding:C?J||"1rem":J||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||G||g||w?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:R?.title,description:R?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:G,width:f,graphDownload:g?u.current:void 0,dataDownload:w?l.map(n=>n.data).filter(n=>n!==void 0).length>0?l.map(n=>n.data).filter(n=>n!==void 0):l.filter(n=>n!==void 0):null}):null,d.enabled&&K.length>0&&te?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Oe(!x)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":x?"Click to pause animation":"Click to play animation",children:x?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:K[0],max:K[K.length-1],marks:te,step:null,defaultValue:K[K.length-1],value:K[je],onChangeComplete:n=>{ve(K.indexOf(n))},onChange:n=>{ve(K.indexOf(n))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[U?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:f,colorDomain:ae,colors:H,colorLegendTitle:se,setSelectedColor:le,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:ye,"aria-label":"Graph area",children:(f||a)&&(E||t)?e.jsxRuntimeExports.jsx(dt,{data:v!==void 0?v==="total"?De.sortBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n),n=>ke.sum(n.size.filter(O=>!Y.checkIfNullOrUndefined(O)))).filter((n,O)=>j?O<j:!0):De.sortBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n),n=>Y.checkIfNullOrUndefined(n.size[v])?-1/0:n.size[v]).filter((n,O)=>j?O<j:!0):Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>h?!n.size.every(O=>O==null):n).filter((n,O)=>j?O<j:!0),barColors:H,width:f||a,height:Math.max(z,E||(W?z?(f||a)*W>z?(f||a)*W:z:(f||a)*W:t)),barPadding:me,showLabels:oe,showTicks:de,truncateBy:I,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,tooltip:ee,onSeriesMouseOver:ne,showValues:xe,suffix:_,prefix:Z,refValues:pe,maxValue:Y.checkIfNullOrUndefined(S)?Math.max(...l.map(n=>ke.sum(n.size.filter(O=>!Y.checkIfNullOrUndefined(O)))||0)):S,onSeriesMouseClick:b,selectedColor:we,labelOrder:M,maxBarThickness:V,minBarThickness:X,resetSelectionOnDoubleClick:T,detailsOnClick:ue,barAxisTitle:P,noOfTicks:B,valueColor:re,styles:R,classNames:F,animate:k===!0?{duration:.5,once:!0,amount:.5}:k||{duration:0,once:!0,amount:0},colorDomain:ae,precision:y,customLayers:c,naLabel:o}):null})]})}),A||L?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:R?.footnote,source:R?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:A,footNote:L,width:f}):null]})})})})}function ht(fe){const{data:l,graphTitle:p,colors:H,barPadding:A,showTicks:G,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Q,truncateBy:q,showLabels:ie,showValues:I,backgroundColor:oe,suffix:xe,prefix:C,sources:U,graphDescription:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,showColorScale:pe,graphID:ce,maxValue:S,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:D,dataDownload:N,language:M,theme:z,sortData:V,labelOrder:v,showNAColor:j,minHeight:X,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B,detailsOnClick:re,barAxisTitle:R,noOfTicks:F,valueColor:h,orientation:k="vertical",styles:y,classNames:c,filterNA:d,animate:o,dimmedOpacity:a,precision:r,customLayers:t,timeline:s,naLabel:x}=fe;return k==="vertical"?e.jsxRuntimeExports.jsx(ut,{data:l,graphTitle:p,colors:H,barPadding:A,showTicks:G,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Q,truncateBy:q,showLabels:ie,showValues:I,backgroundColor:oe,suffix:xe,prefix:C,sources:U,graphDescription:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,showColorScale:pe,graphID:ce,maxValue:S,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:D,dataDownload:N,language:M,theme:z,sortData:V,labelOrder:v,showNAColor:j,minHeight:X,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B,styles:y,detailsOnClick:re,barAxisTitle:R,noOfTicks:F,valueColor:h,classNames:c,filterNA:d,animate:o,dimmedOpacity:a,precision:r,customLayers:t,timeline:s}):e.jsxRuntimeExports.jsx(at,{data:l,graphTitle:p,colors:H,barPadding:A,showTicks:G,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Q,truncateBy:q,showLabels:ie,showValues:I,backgroundColor:oe,suffix:xe,prefix:C,sources:U,graphDescription:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,showColorScale:pe,graphID:ce,maxValue:S,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:D,dataDownload:N,language:M,theme:z,sortData:V,labelOrder:v,showNAColor:j,minHeight:X,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B,styles:y,detailsOnClick:re,barAxisTitle:R,noOfTicks:F,valueColor:h,classNames:c,filterNA:d,dimmedOpacity:a,precision:r,customLayers:t,timeline:s,naLabel:x})}function pt(fe){const{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,truncateBy:he,height:Q,width:q,footNote:ie,colorDomain:I,colorLegendTitle:oe,suffix:xe,prefix:C,showValues:U,padding:_,backgroundColor:Z,leftMargin:E,rightMargin:f,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,graphID:pe,maxValue:ce,minValue:S,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:D,labelOrder:N,minHeight:M,theme:z,maxBarThickness:V,ariaLabel:v,resetSelectionOnDoubleClick:j,detailsOnClick:X,barAxisTitle:$,noOfTicks:T,valueColor:ue,orientation:P="vertical",styles:B,classNames:re,filterNA:R,animate:F,precision:h,customLayers:k,showColorScale:y,timeline:c,naLabel:d}=fe;return P==="vertical"?e.jsxRuntimeExports.jsx(xt,{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,truncateBy:he,height:Q,width:q,footNote:ie,colorDomain:I,colorLegendTitle:oe,suffix:xe,prefix:C,showValues:U,padding:_,backgroundColor:Z,leftMargin:E,rightMargin:f,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,graphID:pe,maxValue:ce,minValue:S,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:D,labelOrder:N,minHeight:M,theme:z,maxBarThickness:V,ariaLabel:v,resetSelectionOnDoubleClick:j,styles:B,detailsOnClick:X,barAxisTitle:$,noOfTicks:T,valueColor:ue,classNames:re,filterNA:R,animate:F,precision:h,customLayers:k,showColorScale:y,timeline:c,naLabel:d}):e.jsxRuntimeExports.jsx(rt,{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,truncateBy:he,height:Q,width:q,footNote:ie,colorDomain:I,colorLegendTitle:oe,suffix:xe,prefix:C,showValues:U,padding:_,backgroundColor:Z,leftMargin:E,rightMargin:f,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,graphID:pe,maxValue:ce,minValue:S,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:D,labelOrder:N,minHeight:M,theme:z,maxBarThickness:V,ariaLabel:v,resetSelectionOnDoubleClick:j,styles:B,detailsOnClick:X,barAxisTitle:$,noOfTicks:T,valueColor:ue,classNames:re,filterNA:R,animate:F,precision:h,customLayers:k,showColorScale:y,timeline:c,naLabel:d})}function gt(fe){const{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,truncateBy:I,showLabels:oe,showValues:xe,backgroundColor:C,suffix:U,prefix:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:J,onSeriesMouseOver:ee,relativeHeight:ne,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:S,graphDownload:b,dataDownload:g,language:w,theme:D,labelOrder:N,minHeight:M,maxBarThickness:z,sortParameter:V,maxNumberOfBars:v,minBarThickness:j,ariaLabel:X,resetSelectionOnDoubleClick:$,detailsOnClick:T,barAxisTitle:ue,noOfTicks:P,valueColor:B,orientation:re="vertical",styles:R,classNames:F,filterNA:h,animate:k,precision:y,customLayers:c,showColorScale:d,timeline:o,naLabel:a}=fe;return re==="vertical"?e.jsxRuntimeExports.jsx(mt,{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,truncateBy:I,showLabels:oe,showValues:xe,backgroundColor:C,suffix:U,prefix:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:J,onSeriesMouseOver:ee,relativeHeight:ne,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:S,graphDownload:b,dataDownload:g,language:w,theme:D,labelOrder:N,minHeight:M,maxBarThickness:z,sortParameter:V,maxNumberOfBars:v,minBarThickness:j,ariaLabel:X,resetSelectionOnDoubleClick:$,styles:R,detailsOnClick:T,barAxisTitle:ue,noOfTicks:P,valueColor:B,classNames:F,filterNA:h,animate:k,precision:y,customLayers:c,showColorScale:d,timeline:o,naLabel:a}):e.jsxRuntimeExports.jsx(lt,{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,truncateBy:I,showLabels:oe,showValues:xe,backgroundColor:C,suffix:U,prefix:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:J,onSeriesMouseOver:ee,relativeHeight:ne,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:S,graphDownload:b,dataDownload:g,language:w,theme:D,labelOrder:N,minHeight:M,maxBarThickness:z,sortParameter:V,maxNumberOfBars:v,minBarThickness:j,ariaLabel:X,resetSelectionOnDoubleClick:$,styles:R,detailsOnClick:T,barAxisTitle:ue,noOfTicks:P,valueColor:B,classNames:F,filterNA:h,animate:k,precision:y,customLayers:c,showColorScale:d,timeline:o,naLabel:a})}exports.GroupedBarGraph=pt;exports.SimpleBarGraph=ht;exports.StackedBarGraph=gt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),Se=require("./index-CZbIGs8q.cjs"),m=require("react"),De=require("./index-BzeLQvXk.cjs"),Ee=require("./parse-hMnG_lRV.cjs"),Re=require("./getSliderMarks-CtsEXiLV.cjs"),Te=require("./index-BXns0-ng.cjs"),Ae=require("./Modal-tXZlLE5s.cjs"),Me=require("./numberFormattingFunction-02t-wJta.cjs"),ze=require("./Tooltip-n8z5bfav.cjs"),Y=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ce=require("./Colors.cjs"),Ve=require("./string2HTML-D2Avudmb.cjs"),Qe=require("./XTicksAndGridLines-CCzXIV8d.cjs"),Ze=require("./YAxesLabels-D8IydyZj.cjs"),Le=require("./AxisTitle-CK9YeovX.cjs"),Be=require("./Axis-DE7dSn1_.cjs"),Fe=require("./ReferenceLine-CFVBBN__.cjs"),Pe=require("./use-in-view-sQJZ_xDO.cjs"),He=require("./linear-BVckp9RD.cjs"),$e=require("./band-CAApY4Pd.cjs"),Ge=require("./index-BW8iNx7E.cjs"),ge=require("./proxy-BHRoeZgd.cjs"),qe=require("./GraphFooter.cjs"),Ue=require("./GraphHeader.cjs"),We=require("./ColorLegendWithMouseOver.cjs"),Xe=require("./EmptyState-d8_8SxeW.cjs"),Ie=require("./index-BW_-wD2k.cjs"),Ne=require("./ensureCompleteData-DqWQ2Zbi.cjs"),Ye=require("./init-DU0ybBc_.cjs"),ke=require("./index-C21TvELx.cjs"),Ke=require("./getTextColorBasedOnBgColor-nqY-bsM_.cjs"),et=require("./XAxesLabels-OjBNl_lS.cjs"),tt=require("./YTicksAndGridLines-DBDuz6vb.cjs");function it(fe){const{data:l,barColor:p,suffix:H,prefix:A,barPadding:G,showValues:me,showTicks:de,leftMargin:he,truncateBy:Q,width:q,height:ie,colorDomain:I,rightMargin:oe,topMargin:xe,bottomMargin:C,showLabels:U,tooltip:_,onSeriesMouseOver:Z,refValues:E,selectedColor:f,highlightedDataPoints:L,maxValue:ae,minValue:se,onSeriesMouseClick:J,labelOrder:ee,rtl:ne,maxBarThickness:W,minBarThickness:pe,resetSelectionOnDoubleClick:ce,detailsOnClick:S,barAxisTitle:b,valueColor:g,noOfTicks:w,styles:D,classNames:N,animate:M,dimmedOpacity:z,precision:V,customLayers:v,naLabel:j}=fe,X=m.useRef(null),$=Pe.useInView(X,{once:M.once,amount:M.amount}),[T,ue]=m.useState(void 0),[P,B]=m.useState(void 0),[re,R]=m.useState(void 0),[F,h]=m.useState(void 0),k={top:b?xe+25:xe,bottom:C,left:he,right:oe},y=q-k.left-k.right,c=ie-k.top-k.bottom,d=l.map((s,x)=>({...s,id:ee?`${s.label}`:`${x}`})),o=He.linear().domain([se,ae]).range([0,y]).nice(),a=ee||d.map(s=>`${s.id}`),r=$e.band().domain(a).range([0,pe?Math.max(c,pe*a.length):W?Math.min(c,W*a.length):c]).paddingInner(G),t=o.ticks(w);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:X,width:`${q}px`,height:`${ie}px`,viewBox:`0 0 ${q} ${ie}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${k.left},${k.top})`,children:[de?e.jsxRuntimeExports.jsx(Qe.XTicksAndGridLines,{values:t.filter(s=>s!==0),x:t.filter(s=>s!==0).map(s=>o(s)),y1:0-xe,y2:c+k.bottom,styles:{gridLines:D?.xAxis?.gridLines,labels:D?.xAxis?.labels},classNames:{gridLines:N?.xAxis?.gridLines,labels:N?.xAxis?.labels},suffix:H,prefix:A,labelType:"secondary",showGridLines:!0,precision:V}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:y/2,y:0-k.top+15,style:D?.xAxis?.title,className:N?.xAxis?.title,text:b}),v.filter(s=>s.position==="before").map(s=>s.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[d.map(s=>Y.checkIfNullOrUndefined(r(s.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{opacity:f?s.color&&p[I.indexOf(s.color)]===f?1:z:L.length!==0?L.indexOf(s.label)!==-1?.85:z:.85},whileInView:{opacity:f?s.color&&p[I.indexOf(s.color)]===f?1:z:L.length!==0?L.indexOf(s.label)!==-1?.85:z:.85,transition:{duration:M.duration}}},initial:"initial",animate:$?"whileInView":"initial",exit:{opacity:0,transition:{duration:M.duration}},onMouseEnter:x=>{ue(s),h(x.clientY),R(x.clientX),Z?.(s)},onClick:()=>{(J||S)&&(Te.isEqual(P,s)&&ce?(B(void 0),J?.(void 0)):(B(s),J?.(s)))},onMouseMove:x=>{ue(s),h(x.clientY),R(x.clientX)},onMouseLeave:()=>{ue(void 0),R(void 0),h(void 0),Z?.(void 0)},children:[s.size?e.jsxRuntimeExports.jsx(ge.motion.rect,{variants:{initial:{width:0,x:o(0),y:r(`${s.id}`),fill:l.filter(x=>x.color).length===0?p[0]:s.color?p[I.indexOf(s.color)]:Ce.Colors.gray},whileInView:{width:s.size>=0?o(s.size)-o(0):o(0)-o(s.size),x:s.size>=0?o(0):o(s.size),y:r(`${s.id}`),fill:l.filter(x=>x.color).length===0?p[0]:s.color?p[I.indexOf(s.color)]:Ce.Colors.gray,transition:{duration:M.duration}}},initial:"initial",animate:$?"whileInView":"initial",exit:{width:0,x:o(0),transition:{duration:M.duration}},height:r.bandwidth()}):null,U?e.jsxRuntimeExports.jsx(Ze.YAxesLabels,{value:`${s.label}`.length<Q?`${s.label}`:`${`${s.label}`.substring(0,Q)}...`,y:r(s.id)||0,x:(s.size||0)<0?o(0):0-k.left,width:(s.size||0)<0?q-o(0):o(0)+k.left,height:r.bandwidth(),alignment:s.size&&s.size<0?"left":"right",style:D?.yAxis?.labels,className:N?.yAxis?.labels,animate:M,isInView:$}):null,me?e.jsxRuntimeExports.jsx(ge.motion.text,{style:{textAnchor:s.size&&s.size<0?"end":"start",...D?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!g&&p.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",N?.graphObjectValues),dx:s.size&&s.size<0?-5:5,dy:"0.33em",variants:{initial:{x:o(0),y:r(`${s.id}`)+r.bandwidth()/2,opacity:0,fill:g||(l.filter(x=>x.color).length===0?p[0]:s.color?p[I.indexOf(s.color)]:Ce.Colors.gray)},whileInView:{x:s.size?o(s.size):o(0),opacity:1,y:r(`${s.id}`)+r.bandwidth()/2,fill:g||(l.filter(x=>x.color).length===0?p[0]:s.color?p[I.indexOf(s.color)]:Ce.Colors.gray),transition:{duration:M.duration}}},initial:"initial",animate:$?"whileInView":"initial",exit:{opacity:0,transition:{duration:M.duration}},children:Me.numberFormattingFunction(s.size,j,V,A,H)}):null]},s.label)),e.jsxRuntimeExports.jsx(Be.Axis,{x1:o(se<0?0:se),x2:o(se<0?0:se),y1:-2.5,y2:c+k.bottom,classNames:{axis:N?.yAxis?.axis},styles:{axis:D?.yAxis?.axis}}),E?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:E.map((s,x)=>e.jsxRuntimeExports.jsx(Fe.RefLineX,{text:s.text,color:s.color,x:o(s.value),y1:0-k.top,y2:c+k.bottom,textSide:o(s.value)>y*.75||ne?"left":"right",classNames:s.classNames,styles:s.styles,animate:M,isInView:$},x))}):null]}),v.filter(s=>s.position==="after").map(s=>s.layer)]})}),T&&_&&re&&F?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:T,body:_,xPos:re,yPos:F,backgroundStyle:D?.tooltip,className:N?.tooltip}):null,S&&P!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:P!==void 0,onClose:()=>{B(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof S=="string"?{__html:Ve.string2HTML(S,P)}:void 0,children:typeof S=="function"?S(P):null})}):null]})}function at(fe){const{data:l,graphTitle:p,colors:H,suffix:A="",sources:G,prefix:me="",graphDescription:de,barPadding:he=.25,showValues:Q=!0,showTicks:q=!0,leftMargin:ie=100,rightMargin:I=40,truncateBy:oe=999,height:xe,width:C,footNote:U,colorDomain:_,colorLegendTitle:Z,highlightedDataPoints:E=[],padding:f,backgroundColor:L=!1,topMargin:ae=25,bottomMargin:se=10,showLabels:J=!0,relativeHeight:ee,tooltip:ne,onSeriesMouseOver:W,refValues:pe,showColorScale:ce=!0,graphID:S,maxValue:b,minValue:g,onSeriesMouseClick:w,graphDownload:D=!1,dataDownload:N=!1,sortData:M,labelOrder:z,language:V="en",showNAColor:v=!0,minHeight:j=0,theme:X="light",maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B=!0,detailsOnClick:re,barAxisTitle:R,noOfTicks:F=5,valueColor:h,styles:k,classNames:y,filterNA:c=!0,animate:d=!1,dimmedOpacity:o=.3,precision:a=2,customLayers:r=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:s="NA"}=fe,[x,Oe]=m.useState(0),[K,je]=m.useState(0),[ve,we]=m.useState(t.autoplay),le=Re.sort(Se.uniqBy(l.filter(i=>i.date!==void 0&&i.date!==null),i=>i.date).map(i=>Ee.parse(`${i.date}`,t.dateFormat||"yyyy",new Date).getTime()),(i,be)=>Ye.ascending(i,be)),[ye,u]=m.useState(t.autoplay?0:le.length-1),[te,n]=m.useState(void 0),O=m.useRef(null),_e=m.useRef(null);m.useEffect(()=>{const i=new ResizeObserver(be=>{Oe(C||be[0].target.clientWidth||620),je(xe||be[0].target.clientHeight||480)});return O.current&&(je(O.current.clientHeight||480),Oe(O.current.clientWidth||620),C||i.observe(O.current)),()=>i.disconnect()},[C,xe]),m.useEffect(()=>{const i=setInterval(()=>{u(be=>be<le.length-1?be+1:0)},(t.speed||2)*1e3);return ve||clearInterval(i),()=>clearInterval(i)},[le,ve,t.speed]);const Je=Re.getSliderMarks(le,ye,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${X||"light"} flex ${C?"w-fit grow-0":"w-full grow"}`,dir:V==="he"||V==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${L?L===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${V||"en"}`,y?.graphContainer),style:{...k?.graphContainer||{},...L&&L!==!0?{backgroundColor:L}:{}},id:S,ref:_e,"aria-label":P||`${p?`The graph shows ${p}. `:""}This is a bar chart. ${de?` ${de}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:L?f||"1rem":f||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||de||D||N?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:k?.title,description:k?.description},classNames:{title:y?.title,description:y?.description},graphTitle:p,graphDescription:de,width:C,graphDownload:D?_e.current:void 0,dataDownload:N?l.map(i=>i.data).filter(i=>i!==void 0).length>0?l.map(i=>i.data).filter(i=>i!==void 0):l.filter(i=>i!==void 0):null}):null,t.enabled&&le.length>0&&Je?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!ve)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ve?"Click to pause animation":"Click to play animation",children:ve?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:le[0],max:le[le.length-1],marks:Je,step:null,defaultValue:le[le.length-1],value:le[ye],onChangeComplete:i=>{u(le.indexOf(i))},onChange:i=>{u(le.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[ce&&l.filter(i=>i.color).length!==0?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:C,colorLegendTitle:Z,colors:H||Ce.Colors[X].categoricalColors.colors,colorDomain:_||Se.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),setSelectedColor:n,showNAColor:v}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:O,"aria-label":"Graph area",children:(C||x)&&(xe||K)?e.jsxRuntimeExports.jsx(it,{data:M==="asc"?De.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).filter((i,be)=>T?be<T:!0):M==="desc"?De.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).reverse().filter((i,be)=>T?be<T:!0):Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i).filter((i,be)=>T?be<T:!0),barColor:l.filter(i=>i.color).length===0?H?[H]:[Ce.Colors.primaryColors["blue-600"]]:H||Ce.Colors[X].categoricalColors.colors,colorDomain:l.filter(i=>i.color).length===0?[]:_||Se.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),width:C||x,selectedColor:te,height:Math.max(j,xe||(ee?j?(C||x)*ee>j?(C||x)*ee:j:(C||x)*ee:K)),suffix:A,prefix:me,barPadding:he,showValues:Q,showTicks:q,leftMargin:ie,rightMargin:I,topMargin:ae,bottomMargin:se,truncateBy:oe,showLabels:J,tooltip:ne,onSeriesMouseOver:W,refValues:pe,maxValue:Y.checkIfNullOrUndefined(b)?Math.max(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size))<0?0:Math.max(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size)):b,minValue:Y.checkIfNullOrUndefined(g)?Math.min(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size))>=0?0:Math.min(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size)):g,highlightedDataPoints:E,onSeriesMouseClick:w,labelOrder:z,rtl:V==="he"||V==="ar",maxBarThickness:$,minBarThickness:ue,resetSelectionOnDoubleClick:B,detailsOnClick:re,barAxisTitle:R,noOfTicks:F,valueColor:h,classNames:y,styles:k,animate:d===!0?{duration:.5,once:!0,amount:.5}:d||{duration:0,once:!0,amount:0},dimmedOpacity:o,precision:a,customLayers:r,naLabel:s}):null})]})}),G||U?e.jsxRuntimeExports.jsx(qe.GraphFooter,{sources:G,footNote:U,width:C,styles:{footnote:k?.footnote,source:k?.source},classNames:{footnote:y?.footnote,source:y?.source}}):null]})})})})}function st(fe){const{data:l,barColors:p,barPadding:H,showTicks:A,leftMargin:G,truncateBy:me,width:de,height:he,suffix:Q,prefix:q,showValues:ie,rightMargin:I,topMargin:oe,bottomMargin:xe,showLabels:C,tooltip:U,onSeriesMouseOver:_,refValues:Z,maxValue:E,minValue:f,onSeriesMouseClick:L,selectedColor:ae,rtl:se,labelOrder:J,maxBarThickness:ee,resetSelectionOnDoubleClick:ne,detailsOnClick:W,barAxisTitle:pe,valueColor:ce,noOfTicks:S,styles:b,classNames:g,animate:w,colorDomain:D,precision:N,customLayers:M,naLabel:z}=fe,V=m.useRef(null),v=Pe.useInView(V,{once:w.once,amount:w.amount}),j={top:pe?oe+25:oe,bottom:xe,left:G,right:I},[X,$]=m.useState(void 0),[T,ue]=m.useState(void 0),[P,B]=m.useState(void 0),[re,R]=m.useState(void 0),F=de-j.left-j.right,h=he-j.top-j.bottom,k=l.map((r,t)=>({...r,id:J?`${r.label}`:`${t}`})),y=J||k.map(r=>`${r.id}`),c=He.linear().domain([f,E]).range([0,F]).nice(),d=$e.band().domain(y).range([0,ee?Math.min(h,ee*y.length):h]).paddingInner(H),o=$e.band().domain(l[0].size.map((r,t)=>`${t}`)).range([0,d.bandwidth()]).paddingInner(.1),a=c.ticks(S);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:V,width:`${de}px`,height:`${he}px`,viewBox:`0 0 ${de} ${he}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${j.left},${j.top})`,children:[A?e.jsxRuntimeExports.jsx(Qe.XTicksAndGridLines,{values:a.filter(r=>r!==0),x:a.filter(r=>r!==0).map(r=>c(r)),y1:0-oe,y2:h+j.bottom,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.xAxis?.labels},classNames:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},suffix:Q,prefix:q,labelType:"secondary",showGridLines:!0,precision:N}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:F/2,y:0-j.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),M.filter(r=>r.position==="before").map(r=>r.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[k.map(r=>Y.checkIfNullOrUndefined(d(r.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{variants:{initial:{x:0,y:d(`${r.id}`)},whileInView:{x:0,y:d(`${r.id}`),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},children:[r.size.map((t,s)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?p[s]===ae?1:.3:.85,onMouseEnter:x=>{$({...r,sizeIndex:s}),R(x.clientY),B(x.clientX),_?.({...r,sizeIndex:s})},onMouseMove:x=>{$({...r,sizeIndex:s}),R(x.clientY),B(x.clientX)},onMouseLeave:()=>{$(void 0),B(void 0),R(void 0),_?.(void 0)},onClick:()=>{(L||W)&&(Te.isEqual(T,{...r,sizeIndex:s})&&ne?(ue(void 0),L?.(void 0)):(ue({...r,sizeIndex:s}),L&&L({...r,sizeIndex:s})))},children:[Y.checkIfNullOrUndefined(t)?null:e.jsxRuntimeExports.jsx(ge.motion.rect,{y:o(`${s}`),variants:{initial:{width:0,x:c(0),fill:p[s]},whileInView:{width:Y.checkIfNullOrUndefined(t)?0:t>=0?c(t)-c(0):c(0)-c(t),x:t>=0?c(0):c(t),fill:p[s],transition:{duration:w.duration}}},exit:{width:0,x:c(0),transition:{duration:w.duration}},height:o.bandwidth(),initial:"initial",animate:v?"whileInView":"initial"}),ie?e.jsxRuntimeExports.jsx(ge.motion.text,{y:o(`${s}`)+o.bandwidth()/2,style:{fill:ce||p[s],textAnchor:t&&t<0?"end":"start",...b?.graphObjectValues||{}},className:e.mo("graph-value text-sm",g?.graphObjectValues),dx:t&&t<0?-5:5,dy:"0.33em",variants:{initial:{x:c(0),opacity:0},whileInView:{x:c(t||0),opacity:1,transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},children:Me.numberFormattingFunction(t,z,N,q,Q)}):null]},`${r.label}-${D[s]||s}`)),C?e.jsxRuntimeExports.jsx(Ze.YAxesLabels,{value:`${r.label}`.length<me?`${r.label}`:`${`${r.label}`.substring(0,me)}...`,y:0,x:0-j.left,width:c(f<0?0:f)+j.left,height:d.bandwidth(),style:b?.yAxis?.labels,className:g?.yAxis?.labels,animate:w,isInView:v}):null]},r.label)),e.jsxRuntimeExports.jsx(Be.Axis,{x1:c(f<0?0:f),x2:c(f<0?0:f),y1:-2.5,y2:h+j.bottom,classNames:{axis:g?.yAxis?.axis},styles:{axis:b?.yAxis?.axis}}),Z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Z.map((r,t)=>e.jsxRuntimeExports.jsx(Fe.RefLineX,{text:r.text,color:r.color,x:c(r.value),y1:0-j.top,y2:h+j.bottom,textSide:c(r.value)>F*.75||se?"left":"right",classNames:r.classNames,styles:r.styles,animate:w,isInView:v},t))}):null]}),M.filter(r=>r.position==="after").map(r=>r.layer)]})}),X&&U&&P&&re?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:X,body:U,xPos:P,yPos:re,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,W&&T!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:T!==void 0,onClose:()=>{ue(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof W=="string"?{__html:Ve.string2HTML(W,T)}:void 0,children:typeof W=="function"?W(T):null})}):null]})}function rt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:A,graphDescription:G,barPadding:me=.25,showTicks:de=!0,truncateBy:he=999,height:Q,width:q,footNote:ie,colorDomain:I,colorLegendTitle:oe,suffix:xe="",prefix:C="",showValues:U=!0,showColorScale:_=!0,padding:Z,backgroundColor:E=!1,leftMargin:f=100,rightMargin:L=40,topMargin:ae=25,bottomMargin:se=10,showLabels:J=!0,relativeHeight:ee,tooltip:ne,onSeriesMouseOver:W,refValues:pe,graphID:ce,maxValue:S,minValue:b,onSeriesMouseClick:g,graphDownload:w=!1,dataDownload:D=!1,language:N="en",labelOrder:M,minHeight:z=0,theme:V="light",maxBarThickness:v,ariaLabel:j,resetSelectionOnDoubleClick:X=!0,detailsOnClick:$,barAxisTitle:T,noOfTicks:ue=5,valueColor:P,styles:B,classNames:re,filterNA:R=!0,animate:F=!1,precision:h=2,customLayers:k=[],timeline:y={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:c="NA"}=fe,[d,o]=m.useState(0),[a,r]=m.useState(0),[t,s]=m.useState(y.autoplay),x=Re.sort(Se.uniqBy(l.filter(u=>u.date!==void 0&&u.date!==null),u=>u.date).map(u=>Ee.parse(`${u.date}`,y.dateFormat||"yyyy",new Date).getTime()),(u,te)=>Ye.ascending(u,te)),[Oe,K]=m.useState(y.autoplay?0:x.length-1),[je,ve]=m.useState(void 0),we=m.useRef(null),le=m.useRef(null);m.useEffect(()=>{const u=new ResizeObserver(te=>{o(q||te[0].target.clientWidth||620),r(Q||te[0].target.clientHeight||480)});return we.current&&(r(we.current.clientHeight||480),o(we.current.clientWidth||620),q||u.observe(we.current)),()=>u.disconnect()},[q,Q]),m.useEffect(()=>{const u=setInterval(()=>{K(te=>te<x.length-1?te+1:0)},(y.speed||2)*1e3);return t||clearInterval(u),()=>clearInterval(u)},[x,t,y.speed]);const ye=Re.getSliderMarks(x,Oe,y.showOnlyActiveDate,y.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${V||"light"} flex ${q?"w-fit grow-0":"w-full grow"}`,dir:N==="he"||N==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${E?E===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${N||"en"}`,re?.graphContainer),style:{...B?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:ce,ref:le,"aria-label":j||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${G?` ${G}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?Z||"1rem":Z||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[p||G||w||D?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:B?.title,description:B?.description},classNames:{title:re?.title,description:re?.description},graphTitle:p,graphDescription:G,width:q,graphDownload:w?le.current:void 0,dataDownload:D?l.map(u=>u.data).filter(u=>u!==void 0).length>0?l.map(u=>u.data).filter(u=>u!==void 0):l.filter(u=>u!==void 0):null}):null,y.enabled&&x.length>0&&ye?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{s(!t)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":t?"Click to pause animation":"Click to play animation",children:t?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:x[0],max:x[x.length-1],marks:ye,step:null,defaultValue:x[x.length-1],value:x[Oe],onChangeComplete:u=>{K(x.indexOf(u))},onChange:u=>{K(x.indexOf(u))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:q,colorDomain:I,colors:H,colorLegendTitle:oe,setSelectedColor:ve,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:we,"aria-label":"Graph area",children:(q||d)&&(Q||a)?e.jsxRuntimeExports.jsx(st,{data:Ne.ensureCompleteDataForStackedBarChart(l,y.dateFormat||"yyyy").filter(u=>y.enabled?u.date===Ee.format(new Date(x[Oe]),y.dateFormat||"yyyy"):u).filter(u=>R?!u.size.every(te=>te==null):u),barColors:H,width:q||d,height:Math.max(z,Q||(ee?z?(q||d)*ee>z?(q||d)*ee:z:(q||d)*ee:a)),suffix:xe,prefix:C,showValues:U,barPadding:me,showTicks:de,leftMargin:f,rightMargin:L,topMargin:ae,bottomMargin:se,truncateBy:he,showLabels:J,tooltip:ne,onSeriesMouseOver:W,refValues:pe,maxValue:Y.checkIfNullOrUndefined(S)?Math.max(...l.map(u=>Math.max(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te)))))<0?0:Math.max(...l.map(u=>Math.max(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te))))):S,minValue:Y.checkIfNullOrUndefined(b)?Math.min(...l.map(u=>Math.min(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te)))))>=0?0:Math.min(...l.map(u=>Math.min(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te))))):b,onSeriesMouseClick:g,selectedColor:je,labelOrder:M,rtl:N==="he"||N==="ar",maxBarThickness:v,resetSelectionOnDoubleClick:X,detailsOnClick:$,barAxisTitle:T,noOfTicks:ue,valueColor:P,styles:B,classNames:re,colorDomain:I,animate:F===!0?{duration:.5,once:!0,amount:.5}:F||{duration:0,once:!0,amount:0},precision:h,customLayers:k,naLabel:c}):null})]})}),A||ie?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:B?.footnote,source:B?.source},classNames:{footnote:re?.footnote,source:re?.source},sources:A,footNote:ie,width:q}):null]})})})})}function nt(fe){const{data:l,barColors:p,barPadding:H,showTicks:A,leftMargin:G,rightMargin:me,truncateBy:de,width:he,height:Q,topMargin:q,bottomMargin:ie,tooltip:I,onSeriesMouseOver:oe,showLabels:xe,suffix:C,prefix:U,showValues:_,refValues:Z,maxValue:E,onSeriesMouseClick:f,selectedColor:L,rtl:ae,labelOrder:se,maxBarThickness:J,minBarThickness:ee,resetSelectionOnDoubleClick:ne,detailsOnClick:W,barAxisTitle:pe,valueColor:ce,noOfTicks:S,styles:b,classNames:g,animate:w,colorDomain:D,precision:N,customLayers:M,naLabel:z}=fe,V=m.useRef(null),v=Pe.useInView(V,{once:w.once,amount:w.amount}),j={top:pe?q+25:q,bottom:ie,left:G,right:me},[X,$]=m.useState(void 0),[T,ue]=m.useState(void 0),[P,B]=m.useState(void 0),[re,R]=m.useState(void 0),F=he-j.left-j.right,h=Q-j.top-j.bottom,k=l.map((a,r)=>({...a,id:se?`${a.label}`:`${r}`})),y=se||k.map(a=>`${a.id}`),c=He.linear().domain([0,E]).range([0,F]).nice(),d=$e.band().domain(y).range([0,ee?Math.max(h,ee*y.length):J?Math.min(h,J*y.length):h]).paddingInner(H),o=c.ticks(S);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:V,width:`${he}px`,height:`${Q}px`,viewBox:`0 0 ${he} ${Q}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${j.left},${j.top})`,children:[A?e.jsxRuntimeExports.jsx(Qe.XTicksAndGridLines,{values:o.filter(a=>a!==0),x:o.filter(a=>a!==0).map(a=>c(a)),y1:0-q,y2:h+j.bottom,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.xAxis?.labels},classNames:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},suffix:C,prefix:U,labelType:"secondary",showGridLines:!0,precision:N}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:F/2,y:0-j.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),M.filter(a=>a.position==="before").map(a=>a.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[k.map(a=>Y.checkIfNullOrUndefined(d(a.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",variants:{initial:{x:0,y:d(`${a.id}`)},whileInView:{x:0,y:d(`${a.id}`),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},children:[a.size.map((r,t)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{opacity:L?p[t]===L?1:.3:1,onMouseEnter:s=>{$({...a,sizeIndex:t}),R(s.clientY),B(s.clientX),oe?.({...a,sizeIndex:t})},onMouseMove:s=>{$({...a,sizeIndex:t}),R(s.clientY),B(s.clientX)},onMouseLeave:()=>{$(void 0),B(void 0),R(void 0),oe?.(void 0)},onClick:()=>{(f||W)&&(Te.isEqual(T,{...a,sizeIndex:t})&&ne?(ue(void 0),f?.(void 0)):(ue({...a,sizeIndex:t}),f&&f({...a,sizeIndex:t})))},children:[r?e.jsxRuntimeExports.jsx(ge.motion.rect,{y:0,style:{fill:p[t]},height:d.bandwidth(),exit:{width:0,x:c(0),transition:{duration:w.duration}},variants:{initial:{width:0,x:c(0),fill:p[t]},whileInView:{width:c(r||0),x:c(t===0?0:ke.sum(a.size.filter((s,x)=>x<t&&s))),fill:p[t],transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial"},t):null,_?e.jsxRuntimeExports.jsx(ge.motion.text,{y:d.bandwidth()/2,style:{textAnchor:"middle",...b?.graphObjectValues||{}},dy:"0.33em",className:e.mo("graph-value text-sm",g?.graphObjectValues),exit:{opacity:0,transition:{duration:w.duration}},variants:{initial:{x:c(0),opacity:0,fill:Ke.getTextColorBasedOnBgColor(p[t])},whileInView:{x:c(t===0?0:ke.sum(a.size.filter((s,x)=>x<t&&s)))+c(r||0)/2,opacity:r&&c(r)/Me.numberFormattingFunction(r,z,N,U,C).length>12?1:0,fill:Ke.getTextColorBasedOnBgColor(p[t]),transition:{duration:w.duration}}},initial:"initial",animate:v?"whileInView":"initial",children:Me.numberFormattingFunction(r,z,N,U,C)}):null]},`${a.label}-${D[t]||t}`)),xe?e.jsxRuntimeExports.jsx(Ze.YAxesLabels,{value:`${a.label}`.length<de?`${a.label}`:`${`${a.label}`.substring(0,de)}...`,y:0,x:0-j.left,width:0+j.left,height:d.bandwidth(),style:b?.yAxis?.labels,className:g?.yAxis?.labels,animate:w,isInView:v}):null,_?e.jsxRuntimeExports.jsx(ge.motion.text,{className:e.mo("graph-value graph-value-total text-sm",ce?"":" fill-primary-gray-700 dark:fill-primary-gray-300",g?.graphObjectValues),style:{...ce?{fill:ce}:{},textAnchor:"start",...b?.graphObjectValues||{}},y:d.bandwidth()/2,dx:5,dy:"0.33em",variants:{initial:{x:c(0),opacity:0},whileInView:{x:c(ke.sum(a.size.map(r=>r||0))),opacity:1,transition:{duration:w.duration}}},exit:{opacity:0,transition:{duration:w.duration}},initial:"initial",animate:v?"whileInView":"initial",children:Me.numberFormattingFunction(ke.sum(a.size.filter(r=>r)),z,N,U,C)}):null]},a.label)),e.jsxRuntimeExports.jsx(Be.Axis,{x1:c(0),x2:c(0),y1:-2.5,y2:h+j.bottom,classNames:{axis:g?.yAxis?.axis},styles:{axis:b?.yAxis?.axis}}),Z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Z.map((a,r)=>e.jsxRuntimeExports.jsx(Fe.RefLineX,{text:a.text,color:a.color,x:c(a.value),y1:0-j.top,y2:h+j.bottom,textSide:c(a.value)>F*.75||ae?"left":"right",classNames:a.classNames,styles:a.styles,animate:w,isInView:v},r))}):null]}),M.filter(a=>a.position==="after").map(a=>a.layer)]})}),X&&I&&P&&re?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:X,body:I,xPos:P,yPos:re,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,W&&T!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:T!==void 0,onClose:()=>{ue(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof W=="string"?{__html:Ve.string2HTML(W,T)}:void 0,children:typeof W=="function"?W(T):null})}):null]})}function lt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:A,graphDescription:G,barPadding:me=.25,showTicks:de=!0,leftMargin:he=100,rightMargin:Q=40,truncateBy:q=999,height:ie,width:I,footNote:oe,colorDomain:xe,colorLegendTitle:C,padding:U,backgroundColor:_=!1,topMargin:Z=25,bottomMargin:E=10,tooltip:f,onSeriesMouseOver:L,suffix:ae="",prefix:se="",showLabels:J=!0,relativeHeight:ee,showValues:ne=!0,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:S,graphDownload:b=!1,dataDownload:g=!1,language:w="en",labelOrder:D,minHeight:N=0,theme:M="light",maxBarThickness:z,sortParameter:V,maxNumberOfBars:v,minBarThickness:j,showColorScale:X=!0,ariaLabel:$,resetSelectionOnDoubleClick:T=!0,detailsOnClick:ue,barAxisTitle:P,noOfTicks:B=5,valueColor:re,styles:R,classNames:F,filterNA:h=!0,animate:k=!1,precision:y=2,customLayers:c=[],timeline:d={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:o="NA"}=fe,[a,r]=m.useState(0),[t,s]=m.useState(0),[x,Oe]=m.useState(d.autoplay),K=Re.sort(Se.uniqBy(l.filter(n=>n.date!==void 0&&n.date!==null),n=>n.date).map(n=>Ee.parse(`${n.date}`,d.dateFormat||"yyyy",new Date).getTime()),(n,O)=>Ye.ascending(n,O)),[je,ve]=m.useState(d.autoplay?0:K.length-1),[we,le]=m.useState(void 0),ye=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{const n=new ResizeObserver(O=>{r(I||O[0].target.clientWidth||620),s(ie||O[0].target.clientHeight||480)});return ye.current&&(s(ye.current.clientHeight||480),r(ye.current.clientWidth||620),I||n.observe(ye.current)),()=>n.disconnect()},[I,ie]),m.useEffect(()=>{const n=setInterval(()=>{ve(O=>O<K.length-1?O+1:0)},(d.speed||2)*1e3);return x||clearInterval(n),()=>clearInterval(n)},[K,x,d.speed]);const te=Re.getSliderMarks(K,je,d.showOnlyActiveDate,d.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${M||"light"} flex ${I?"w-fit grow-0":"w-full grow"}`,dir:w==="he"||w==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${_?_===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${w||"en"}`,F?.graphContainer),style:{...R?.graphContainer||{},..._&&_!==!0?{backgroundColor:_}:{}},id:pe,ref:u,"aria-label":$||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${G?` ${G}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:_?U||"1rem":U||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[p||G||b||g?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:R?.title,description:R?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:G,width:I,graphDownload:b?u.current:void 0,dataDownload:g?l.map(n=>n.data).filter(n=>n!==void 0).length>0?l.map(n=>n.data).filter(n=>n!==void 0):l.filter(n=>n!==void 0):null}):null,d.enabled&&K.length>0&&te?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Oe(!x)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":x?"Click to pause animation":"Click to play animation",children:x?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:K[0],max:K[K.length-1],marks:te,step:null,defaultValue:K[K.length-1],value:K[je],onChangeComplete:n=>{ve(K.indexOf(n))},onChange:n=>{ve(K.indexOf(n))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[X?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:I,colorDomain:xe,colors:H,colorLegendTitle:C,setSelectedColor:le,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:ye,"aria-label":"Graph area",children:(I||a)&&(ie||t)?e.jsxRuntimeExports.jsx(nt,{data:V!==void 0?V==="total"?De.sortBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n),n=>ke.sum(n.size.filter(O=>!Y.checkIfNullOrUndefined(O)))).reverse().filter((n,O)=>v?O<v:!0):De.sortBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n),n=>Y.checkIfNullOrUndefined(n.size[V])?-1/0:n.size[V]).reverse().filter((n,O)=>v?O<v:!0):Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n).filter((n,O)=>v?O<v:!0),barColors:H,width:I||a,height:Math.max(N,ie||(ee?N?(I||a)*ee>N?(I||a)*ee:N:(I||a)*ee:t)),barPadding:me,showTicks:de,leftMargin:he,rightMargin:Q,topMargin:Z,bottomMargin:E,truncateBy:q,showLabels:J,tooltip:f,onSeriesMouseOver:L,showValues:ne,suffix:ae,prefix:se,refValues:W,maxValue:Y.checkIfNullOrUndefined(ce)?Math.max(...l.map(n=>ke.sum(n.size.filter(O=>!Y.checkIfNullOrUndefined(O)))||0)):ce,onSeriesMouseClick:S,selectedColor:we,rtl:w==="he"||w==="ar",labelOrder:D,maxBarThickness:z,minBarThickness:j,resetSelectionOnDoubleClick:T,detailsOnClick:ue,barAxisTitle:P,noOfTicks:B,valueColor:re,classNames:F,styles:R,animate:k===!0?{duration:.5,once:!0,amount:.5}:k||{duration:0,once:!0,amount:0},colorDomain:xe,precision:y,customLayers:c,naLabel:o}):null})]})}),A||oe?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:R?.footnote,source:R?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:A,footNote:oe,width:I}):null]})})})})}function ot(fe){const{data:l,width:p,height:H,barColor:A,suffix:G,prefix:me,barPadding:de,showLabels:he,showValues:Q,showTicks:q,colorDomain:ie,truncateBy:I,rightMargin:oe,topMargin:xe,bottomMargin:C,leftMargin:U,tooltip:_,onSeriesMouseOver:Z,refValues:E,selectedColor:f,maxValue:L,minValue:ae,highlightedDataPoints:se,onSeriesMouseClick:J,labelOrder:ee,maxBarThickness:ne,minBarThickness:W,resetSelectionOnDoubleClick:pe,detailsOnClick:ce,barAxisTitle:S,valueColor:b,noOfTicks:g,styles:w,classNames:D,dimmedOpacity:N,animate:M,precision:z,customLayers:V,naLabel:v}=fe,j=m.useRef(null),X=Pe.useInView(j,{once:M.once,amount:M.amount}),$={top:xe,bottom:C,left:S?U+30:U,right:oe},[T,ue]=m.useState(void 0),[P,B]=m.useState(void 0),[re,R]=m.useState(void 0),[F,h]=m.useState(void 0),k=p-$.left-$.right,y=H-$.top-$.bottom,c=He.linear().domain([ae,L]).range([y,0]).nice(),d=l.map((t,s)=>({...t,id:ee?`${t.label}`:`${s}`})),o=ee||d.map(t=>`${t.id}`),a=$e.band().domain(o).range([0,W?Math.max(k,W*o.length):ne?Math.min(k,ne*o.length):k]).paddingInner(de),r=c.ticks(g);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{ref:j,width:`${p}px`,height:`${H}px`,viewBox:`0 0 ${p} ${H}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${$.left},${$.top})`,children:[e.jsxRuntimeExports.jsx(Be.Axis,{y1:c(ae<0?0:ae),y2:c(ae<0?0:ae),x1:0-U,x2:k+$.right,label:Me.numberFormattingFunction(ae<0?0:ae,v,z,me,G),labelPos:{x:0-U,dx:0,dy:L<0?"1em":-5,y:c(ae<0?0:ae)},classNames:{axis:D?.xAxis?.axis,label:D?.yAxis?.labels},styles:{axis:w?.xAxis?.axis,label:w?.yAxis?.labels}}),q?e.jsxRuntimeExports.jsx(tt.YTicksAndGridLines,{values:r.filter(t=>t!==0),y:r.filter(t=>t!==0).map(t=>c(t)),x1:0-U,x2:k+$.right,styles:{gridLines:w?.yAxis?.gridLines,labels:w?.yAxis?.labels},classNames:{gridLines:D?.yAxis?.gridLines,labels:D?.yAxis?.labels},suffix:G,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:z}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:0-U-15,y:y/2,style:w?.yAxis?.title,className:D?.yAxis?.title,text:S,rotate90:!0}),V.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[d.map((t,s)=>Y.checkIfNullOrUndefined(a(t.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",initial:"initial",animate:X?"whileInView":"initial",variants:{initial:{opacity:f?t.color&&A[ie.indexOf(t.color)]===f?1:N:se.length!==0?se.indexOf(t.label)!==-1?.85:N:.85},whileInView:{opacity:f?t.color&&A[ie.indexOf(t.color)]===f?1:N:se.length!==0?se.indexOf(t.label)!==-1?.85:N:.85,transition:{duration:M.duration}}},exit:{opacity:0,transition:{duration:M.duration}},onMouseEnter:x=>{ue(t),h(x.clientY),R(x.clientX),Z?.(t)},onClick:()=>{(J||ce)&&(Te.isEqual(P,t)&&pe?(B(void 0),J?.(void 0)):(B(t),J?.(t)))},onMouseMove:x=>{ue(t),h(x.clientY),R(x.clientX)},onMouseLeave:()=>{ue(void 0),R(void 0),h(void 0),Z?.(void 0)},children:[t.size?e.jsxRuntimeExports.jsx(ge.motion.rect,{width:a.bandwidth(),initial:"initial",animate:X?"whileInView":"initial",variants:{initial:{height:0,x:a(`${t.id}`),y:c(0),fill:l.filter(x=>x.color).length===0?A[0]:t.color?A[ie.indexOf(t.color)]:Ce.Colors.gray},whileInView:{height:t.size?Math.abs(c(t.size)-c(0)):0,y:t.size&&t.size>0?c(t.size):c(0),x:a(`${t.id}`),fill:l.filter(x=>x.color).length===0?A[0]:t.color?A[ie.indexOf(t.color)]:Ce.Colors.gray,transition:{duration:M.duration}}},exit:{height:0,y:c(0),transition:{duration:M.duration}}}):null,he?e.jsxRuntimeExports.jsx(et.XAxesLabels,{value:`${t.label}`.length<I?`${t.label}`:`${`${t.label}`.substring(0,I)}...`,y:(t.size||0)<0?0:c(0)+5,x:a(`${t.id}`),width:a.bandwidth(),height:(t.size||0)<0?c(0)-5:$.bottom,style:w?.xAxis?.labels,className:D?.xAxis?.labels,alignment:(t.size||0)<0?"bottom":"top",animate:M,isInView:X}):null,Q?e.jsxRuntimeExports.jsx(ge.motion.text,{style:{textAnchor:"middle",...w?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!b&&A.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",D?.graphObjectValues),dy:t.size?t.size>=0?"-5px":"1em":"-5px",variants:{initial:{x:a(`${t.id}`)+a.bandwidth()/2,y:c(0),opacity:0,fill:b||(l.filter(x=>x.color).length===0?A[0]:t.color?A[ie.indexOf(t.color)]:Ce.Colors.gray)},whileInView:{x:a(`${t.id}`)+a.bandwidth()/2,y:c(t.size||0),fill:b||(l.filter(x=>x.color).length===0?A[0]:t.color?A[ie.indexOf(t.color)]:Ce.Colors.gray),opacity:1,transition:{duration:M.duration}}},initial:"initial",animate:X?"whileInView":"initial",exit:{opacity:0,transition:{duration:M.duration}},children:Me.numberFormattingFunction(t.size,v,z,me,G)}):null]},t.label)),E?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:E.map((t,s)=>e.jsxRuntimeExports.jsx(Fe.RefLineY,{text:t.text,color:t.color,y:c(t.value),x1:0-U,x2:k+$.right,classNames:t.classNames,styles:t.styles,animate:M,isInView:X},s))}):null]}),V.filter(t=>t.position==="after").map(t=>t.layer)]})}),T&&_&&re&&F?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:T,body:_,xPos:re,yPos:F,backgroundStyle:w?.tooltip,className:D?.tooltip}):null,ce&&P!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:P!==void 0,onClose:()=>{B(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof ce=="string"?{__html:Ve.string2HTML(ce,P)}:void 0,children:typeof ce=="function"?ce(P):null})}):null]})}function ut(fe){const{data:l,graphTitle:p,colors:H,barPadding:A=.25,showTicks:G=!0,leftMargin:me=20,rightMargin:de=20,topMargin:he=20,bottomMargin:Q=25,truncateBy:q=999,showLabels:ie=!0,showValues:I=!0,backgroundColor:oe=!1,suffix:xe="",prefix:C="",sources:U,graphDescription:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,showColorScale:pe=!0,graphID:ce,maxValue:S,minValue:b,highlightedDataPoints:g=[],onSeriesMouseClick:w,graphDownload:D=!1,dataDownload:N=!1,language:M="en",theme:z="light",sortData:V,labelOrder:v,showNAColor:j=!0,minHeight:X=0,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B=!0,detailsOnClick:re,barAxisTitle:R,noOfTicks:F=5,valueColor:h,styles:k,classNames:y,filterNA:c=!0,animate:d=!1,dimmedOpacity:o=.3,precision:a=2,customLayers:r=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:s="NA"}=fe,[x,Oe]=m.useState(0),[K,je]=m.useState(0),[ve,we]=m.useState(t.autoplay),le=Re.sort(Se.uniqBy(l.filter(i=>i.date!==void 0&&i.date!==null),i=>i.date).map(i=>Ee.parse(`${i.date}`,t.dateFormat||"yyyy",new Date).getTime()),(i,be)=>Ye.ascending(i,be)),[ye,u]=m.useState(t.autoplay?0:le.length-1),[te,n]=m.useState(void 0),O=m.useRef(null),_e=m.useRef(null);m.useEffect(()=>{const i=new ResizeObserver(be=>{Oe(E||be[0].target.clientWidth||620),je(Z||be[0].target.clientHeight||480)});return O.current&&(je(O.current.clientHeight||480),Oe(O.current.clientWidth||620),E||i.observe(O.current)),()=>i.disconnect()},[E,Z]),m.useEffect(()=>{const i=setInterval(()=>{u(be=>be<le.length-1?be+1:0)},(t.speed||2)*1e3);return ve||clearInterval(i),()=>clearInterval(i)},[le,ve,t.speed]);const Je=Re.getSliderMarks(le,ye,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${z||"light"} flex ${E?"w-fit grow-0":"w-full grow"}`,dir:M==="he"||M==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${oe?oe===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,y?.graphContainer),style:{...k?.graphContainer||{},...oe&&oe!==!0?{backgroundColor:oe}:{}},id:ce,ref:_e,"aria-label":P||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${_?` ${_}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:oe?se||"1rem":se||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||_||D||N?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:k?.title,description:k?.description},classNames:{title:y?.title,description:y?.description},graphTitle:p,graphDescription:_,width:E,graphDownload:D?_e.current:void 0,dataDownload:N?l.map(i=>i.data).filter(i=>i!==void 0).length>0?l.map(i=>i.data).filter(i=>i!==void 0):l.filter(i=>i!==void 0):null}):null,t.enabled&&le.length>0&&Je?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!ve)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ve?"Click to pause animation":"Click to play animation",children:ve?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:le[0],max:le[le.length-1],marks:Je,step:null,defaultValue:le[le.length-1],value:le[ye],onChangeComplete:i=>{u(le.indexOf(i))},onChange:i=>{u(le.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[pe&&l.filter(i=>i.color).length!==0?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:E,colorLegendTitle:ae,colors:H||Ce.Colors[z].categoricalColors.colors,colorDomain:L||Se.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),setSelectedColor:n,showNAColor:j}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:O,"aria-label":"Graph area",children:(E||x)&&(Z||K)?e.jsxRuntimeExports.jsx(ot,{data:V==="asc"?De.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).filter((i,be)=>T?be<T:!0):V==="desc"?De.sortBy(Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i),i=>i.size).reverse().filter((i,be)=>T?be<T:!0):Ne.ensureCompleteDataForBarChart(l,t.dateFormat||"yyyy").filter(i=>t.enabled?i.date===Ee.format(new Date(le[ye]),t.dateFormat||"yyyy"):i).filter(i=>c?!Y.checkIfNullOrUndefined(i.size):i).filter((i,be)=>T?be<T:!0),barColor:l.filter(i=>i.color).length===0?H?[H]:[Ce.Colors.primaryColors["blue-600"]]:H||Ce.Colors[z].categoricalColors.colors,colorDomain:l.filter(i=>i.color).length===0?[]:L||Se.uniqBy(l.filter(i=>i.color),"color").map(i=>i.color),width:E||x,refValues:W,height:Math.max(X,Z||(J?X?(E||x)*J>X?(E||x)*J:X:(E||x)*J:K)),suffix:xe,prefix:C,barPadding:A,showLabels:ie,showValues:I,showTicks:G,truncateBy:q,leftMargin:me,rightMargin:de,selectedColor:te,topMargin:he,bottomMargin:Q,tooltip:ee,onSeriesMouseOver:ne,maxValue:Y.checkIfNullOrUndefined(S)?Math.max(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size))<0?0:Math.max(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size)):S,minValue:Y.checkIfNullOrUndefined(b)?Math.min(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size))>=0?0:Math.min(...l.filter(i=>!Y.checkIfNullOrUndefined(i.size)).map(i=>i.size)):b,highlightedDataPoints:g,onSeriesMouseClick:w,labelOrder:v,maxBarThickness:$,minBarThickness:ue,resetSelectionOnDoubleClick:B,detailsOnClick:re,barAxisTitle:R,noOfTicks:F,valueColor:h,styles:k,classNames:y,animate:d===!0?{duration:.5,once:!0,amount:.5}:d||{duration:0,once:!0,amount:0},dimmedOpacity:o,precision:a,customLayers:r,naLabel:s}):null})]})}),U||f?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:k?.footnote,source:k?.source},classNames:{footnote:y?.footnote,source:y?.source},sources:U,footNote:f,width:E}):null]})})})})}function ct(fe){const{data:l,width:p,height:H,barColors:A,suffix:G,prefix:me,barPadding:de,showLabels:he,showValues:Q,showTicks:q,truncateBy:ie,leftMargin:I,rightMargin:oe,topMargin:xe,bottomMargin:C,tooltip:U,onSeriesMouseOver:_,refValues:Z,maxValue:E,minValue:f,onSeriesMouseClick:L,selectedColor:ae,labelOrder:se,maxBarThickness:J,resetSelectionOnDoubleClick:ee,detailsOnClick:ne,barAxisTitle:W,valueColor:pe,noOfTicks:ce,styles:S,classNames:b,animate:g,colorDomain:w,precision:D,customLayers:N,naLabel:M}=fe,z=m.useRef(null),V=Pe.useInView(z,{once:g.once,amount:g.amount}),v={top:xe,bottom:C,left:W?I+30:I,right:oe},[j,X]=m.useState(void 0),[$,T]=m.useState(void 0),[ue,P]=m.useState(void 0),[B,re]=m.useState(void 0),R=p-v.left-v.right,F=H-v.top-v.bottom,h=He.linear().domain([f,E]).range([F,0]).nice(),k=l.map((a,r)=>({...a,id:se?`${a.label}`:`${r}`})),y=se||k.map(a=>`${a.id}`),c=$e.band().domain(y).range([0,J?Math.min(R,J*y.length):R]).paddingInner(de),d=$e.band().domain(l[0].size.map((a,r)=>`${r}`)).range([0,c.bandwidth()]).paddingInner(.1),o=h.ticks(ce);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{width:`${p}px`,height:`${H}px`,viewBox:`0 0 ${p} ${H}`,direction:"ltr",ref:z,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${v.left},${v.top})`,children:[e.jsxRuntimeExports.jsx(Be.Axis,{y1:h(f<0?0:f),y2:h(f<0?0:f),x1:0-I,x2:R+v.right,label:Me.numberFormattingFunction(f<0?0:f,M,D,me,G),labelPos:{x:0-I,dx:0,dy:E<0?"1em":-5,y:h(f<0?0:f)},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:S?.xAxis?.axis,label:S?.yAxis?.labels}}),q?e.jsxRuntimeExports.jsx(tt.YTicksAndGridLines,{values:o.filter(a=>a!==0),y:o.filter(a=>a!==0).map(a=>h(a)),x1:0-I,x2:R+v.right,styles:{gridLines:S?.yAxis?.gridLines,labels:S?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:G,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:D}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:0-I-15,y:F/2,style:S?.yAxis?.title,className:b?.yAxis?.title,text:W,rotate90:!0}),N.filter(a=>a.position==="before").map(a=>a.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[k.map(a=>Y.checkIfNullOrUndefined(c(a.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{variants:{initial:{x:c(`${a.id}`),y:0},whileInView:{x:c(`${a.id}`),y:0,transition:{duration:g.duration}}},initial:"initial",animate:V?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[a.size.map((r,t)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?A[t]===ae?1:.3:.85,onMouseEnter:s=>{X({...a,sizeIndex:t}),re(s.clientY),P(s.clientX),_?.({...a,sizeIndex:t})},onMouseMove:s=>{X({...a,sizeIndex:t}),re(s.clientY),P(s.clientX)},onMouseLeave:()=>{X(void 0),P(void 0),re(void 0),_?.(void 0)},onClick:()=>{(L||ne)&&(Te.isEqual($,{...a,sizeIndex:t})&&ee?(T(void 0),L?.(void 0)):(T({...a,sizeIndex:t}),L&&L({...a,sizeIndex:t})))},children:[e.jsxRuntimeExports.jsx(ge.motion.rect,{x:d(`${t}`),width:d.bandwidth(),variants:{initial:{height:0,y:h(0),fill:A[t]},whileInView:{height:Y.checkIfNullOrUndefined(r)?0:Math.abs(h(r)-h(0)),y:Y.checkIfNullOrUndefined(r)?h(0):r>0?h(r):h(0),fill:A[t],transition:{duration:g.duration}}},exit:{height:0,y:h(0),transition:{duration:g.duration}},initial:"initial",animate:V?"whileInView":"initial"}),Q?e.jsxRuntimeExports.jsx(ge.motion.text,{x:d(`${t}`)+d.bandwidth()/2,style:{fill:pe||A[t],textAnchor:"middle",...S?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:r?r>=0?"-5px":"1em":"-5px",variants:{initial:{y:h(0),opacity:0},whileInView:{y:h(r||0),opacity:1,transition:{duration:g.duration}}},initial:"initial",animate:V?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:Me.numberFormattingFunction(r,M,D,me,G)}):null]},`${a.label}-${w[t]||t}`)),he?e.jsxRuntimeExports.jsx(et.XAxesLabels,{value:`${a.label}`.length<ie?`${a.label}`:`${`${a.label}`.substring(0,ie)}...`,y:h(0)+5,x:0,width:c.bandwidth(),height:v.bottom,style:S?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:V}):null]},a.label)),Z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Z.map((a,r)=>e.jsxRuntimeExports.jsx(Fe.RefLineY,{text:a.text,color:a.color,y:h(a.value),x1:0-I,x2:R+v.right,classNames:a.classNames,styles:a.styles,animate:g,isInView:V},r))}):null]}),N.filter(a=>a.position==="after").map(a=>a.layer)]})}),j&&U&&ue&&B?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:j,body:U,xPos:ue,yPos:B,backgroundStyle:S?.tooltip,className:b?.tooltip}):null,ne&&$!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:$!==void 0,onClose:()=>{T(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof ne=="string"?{__html:Ve.string2HTML(ne,$)}:void 0,children:typeof ne=="function"?ne($):null})}):null]})}function xt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:A,graphDescription:G,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:Q=20,topMargin:q=20,bottomMargin:ie=25,truncateBy:I=999,showLabels:oe=!0,showValues:xe=!0,backgroundColor:C=!1,suffix:U="",prefix:_="",height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,graphID:pe,maxValue:ce,minValue:S,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:w=!1,language:D="en",theme:N="light",labelOrder:M,minHeight:z=0,maxBarThickness:V,ariaLabel:v,resetSelectionOnDoubleClick:j=!0,detailsOnClick:X,barAxisTitle:$,noOfTicks:T=5,valueColor:ue,styles:P,classNames:B,filterNA:re=!0,showColorScale:R=!0,animate:F=!1,precision:h=2,customLayers:k=[],timeline:y={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:c="NA"}=fe,[d,o]=m.useState(0),[a,r]=m.useState(0),[t,s]=m.useState(y.autoplay),x=Re.sort(Se.uniqBy(l.filter(u=>u.date!==void 0&&u.date!==null),u=>u.date).map(u=>Ee.parse(`${u.date}`,y.dateFormat||"yyyy",new Date).getTime()),(u,te)=>Ye.ascending(u,te)),[Oe,K]=m.useState(y.autoplay?0:x.length-1),[je,ve]=m.useState(void 0),we=m.useRef(null),le=m.useRef(null);m.useEffect(()=>{const u=new ResizeObserver(te=>{o(E||te[0].target.clientWidth||620),r(Z||te[0].target.clientHeight||480)});return we.current&&(r(we.current.clientHeight||480),o(we.current.clientWidth||620),E||u.observe(we.current)),()=>u.disconnect()},[E,Z]),m.useEffect(()=>{const u=setInterval(()=>{K(te=>te<x.length-1?te+1:0)},(y.speed||2)*1e3);return t||clearInterval(u),()=>clearInterval(u)},[x,t,y.speed]);const ye=Re.getSliderMarks(x,Oe,y.showOnlyActiveDate,y.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${N||"light"} flex ${E?"w-fit grow-0":"w-full grow"}`,dir:D==="he"||D==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${D||"en"}`,B?.graphContainer),style:{...P?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:pe,ref:le,"aria-label":v||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${G?` ${G}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:C?se||"1rem":se||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||G||g||w?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:P?.title,description:P?.description},classNames:{title:B?.title,description:B?.description},graphTitle:p,graphDescription:G,width:E,graphDownload:g?le.current:void 0,dataDownload:w?l.map(u=>u.data).filter(u=>u!==void 0).length>0?l.map(u=>u.data).filter(u=>u!==void 0):l.filter(u=>u!==void 0):null}):null,y.enabled&&x.length>0&&ye?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{s(!t)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":t?"Click to pause animation":"Click to play animation",children:t?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:x[0],max:x[x.length-1],marks:ye,step:null,defaultValue:x[x.length-1],value:x[Oe],onChangeComplete:u=>{K(x.indexOf(u))},onChange:u=>{K(x.indexOf(u))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[R?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:E,colorDomain:L,colors:H,colorLegendTitle:ae,setSelectedColor:ve,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:we,"aria-label":"Graph area",children:(E||d)&&(Z||a)?e.jsxRuntimeExports.jsx(ct,{data:Ne.ensureCompleteDataForStackedBarChart(l,y.dateFormat||"yyyy").filter(u=>y.enabled?u.date===Ee.format(new Date(x[Oe]),y.dateFormat||"yyyy"):u).filter(u=>re?!u.size.every(te=>te==null):u),barColors:H,width:E||d,height:Math.max(z,Z||(J?z?(E||d)*J>z?(E||d)*J:z:(E||d)*J:a)),suffix:U,prefix:_,barPadding:me,showLabels:oe,showValues:xe,showTicks:de,truncateBy:I,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,tooltip:ee,onSeriesMouseOver:ne,refValues:W,maxValue:Y.checkIfNullOrUndefined(ce)?Math.max(...l.map(u=>Math.max(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te)))))<0?0:Math.max(...l.map(u=>Math.max(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te))))):ce,minValue:Y.checkIfNullOrUndefined(S)?Math.min(...l.map(u=>Math.min(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te)))))>=0?0:Math.min(...l.map(u=>Math.min(...u.size.filter(te=>!Y.checkIfNullOrUndefined(te))))):S,onSeriesMouseClick:b,selectedColor:je,labelOrder:M,maxBarThickness:V,resetSelectionOnDoubleClick:j,detailsOnClick:X,barAxisTitle:$,noOfTicks:T,valueColor:ue,styles:P,classNames:B,animate:F===!0?{duration:.5,once:!0,amount:.5}:F||{duration:0,once:!0,amount:0},colorDomain:L,precision:h,customLayers:k,naLabel:c}):null})]})}),A||f?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:P?.footnote,source:P?.source},classNames:{footnote:B?.footnote,source:B?.source},sources:A,footNote:f,width:E}):null]})})})})}function dt(fe){const{data:l,width:p,height:H,barColors:A,barPadding:G,showLabels:me,showTicks:de,truncateBy:he,leftMargin:Q,topMargin:q,bottomMargin:ie,rightMargin:I,tooltip:oe,onSeriesMouseOver:xe,suffix:C,prefix:U,showValues:_,refValues:Z,maxValue:E,onSeriesMouseClick:f,selectedColor:L,labelOrder:ae,maxBarThickness:se,minBarThickness:J,resetSelectionOnDoubleClick:ee,detailsOnClick:ne,barAxisTitle:W,valueColor:pe,noOfTicks:ce,styles:S,classNames:b,animate:g,colorDomain:w,precision:D,customLayers:N,naLabel:M}=fe,z=m.useRef(null),V=Pe.useInView(z,{once:g.once,amount:g.amount}),v={top:q,bottom:ie,left:W?Q+30:Q,right:I},[j,X]=m.useState(void 0),[$,T]=m.useState(void 0),[ue,P]=m.useState(void 0),[B,re]=m.useState(void 0),R=p-v.left-v.right,F=H-v.top-v.bottom,h=He.linear().domain([0,E]).range([F,0]).nice(),k=l.map((o,a)=>({...o,id:ae?`${o.label}`:`${a}`})),y=ae||k.map(o=>`${o.id}`),c=$e.band().domain(y).range([0,J?Math.max(R,J*y.length):se?Math.min(R,se*y.length):R]).paddingInner(G),d=h.ticks(ce);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(ge.motion.svg,{width:`${p}px`,height:`${H}px`,viewBox:`0 0 ${p} ${H}`,direction:"ltr",ref:z,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${v.left},${v.top})`,children:[e.jsxRuntimeExports.jsx(Be.Axis,{y1:h(0),y2:h(0),x1:0-Q,x2:R+v.right,label:Me.numberFormattingFunction(0,M,D,U,C),labelPos:{x:0-Q,y:h(0),dx:0,dy:-5},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:S?.xAxis?.axis,label:S?.yAxis?.labels}}),de?e.jsxRuntimeExports.jsx(tt.YTicksAndGridLines,{values:d.filter(o=>o!==0),y:d.filter(o=>o!==0).map(o=>h(o)),x1:0-Q,x2:R+v.right,styles:{gridLines:S?.yAxis?.gridLines,labels:S?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:C,prefix:U,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:D}):null,e.jsxRuntimeExports.jsx(Le.AxisTitle,{x:0-Q-15,y:F/2,style:S?.yAxis?.title,className:b?.yAxis?.title,text:W,rotate90:!0}),N.filter(o=>o.position==="before").map(o=>o.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[k.map(o=>Y.checkIfNullOrUndefined(c(o.id))?null:e.jsxRuntimeExports.jsxs(ge.motion.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",variants:{initial:{x:c(`${o.id}`),y:0},whileInView:{x:c(`${o.id}`),y:0,transition:{duration:g.duration}}},transition:{duration:g.duration},initial:"initial",animate:V?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[o.size.map((a,r)=>e.jsxRuntimeExports.jsxs(ge.motion.g,{opacity:L?A[r]===L?1:.3:1,onMouseEnter:t=>{X({...o,sizeIndex:r}),re(t.clientY),P(t.clientX),xe?.({...o,sizeIndex:r})},onMouseMove:t=>{X({...o,sizeIndex:r}),re(t.clientY),P(t.clientX)},onMouseLeave:()=>{X(void 0),P(void 0),re(void 0),xe?.(void 0)},onClick:()=>{(f||ne)&&(Te.isEqual($,{...o,sizeIndex:r})&&ee?(T(void 0),f?.(void 0)):(T({...o,sizeIndex:r}),f&&f({...o,sizeIndex:r})))},children:[e.jsxRuntimeExports.jsx(ge.motion.rect,{x:0,width:c.bandwidth(),variants:{initial:{height:0,fill:A[r],y:h(0)},whileInView:{height:Math.abs(h(ke.sum(o.size.filter((t,s)=>s<=r&&t)))-h(ke.sum(o.size.filter((t,s)=>s<r&&t)))),y:h(ke.sum(o.size.filter((t,s)=>s<=r&&t))),fill:A[r],transition:{duration:g.duration}}},initial:"initial",animate:V?"whileInView":"initial",exit:{height:0,y:h(0),transition:{duration:g.duration}}}),_?e.jsxRuntimeExports.jsx(ge.motion.text,{x:c.bandwidth()/2,style:{fill:Ke.getTextColorBasedOnBgColor(A[r]),textAnchor:"middle",...S?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:"0.33em",variants:{initial:{y:h(0),opacity:0,fill:Ke.getTextColorBasedOnBgColor(A[r])},whileInView:{y:h(ke.sum(o.size.filter((t,s)=>s<=r&&t)))+Math.abs(h(ke.sum(o.size.filter((t,s)=>s<=r&&t)))-h(ke.sum(o.size.filter((t,s)=>s<r&&t))))/2,opacity:a&&Math.abs(h(ke.sum(o.size.filter((t,s)=>s<=r&&t)))-h(ke.sum(o.size.filter((t,s)=>s<r&&t))))>20?1:0,fill:Ke.getTextColorBasedOnBgColor(A[r]),transition:{duration:g.duration}}},initial:"initial",animate:V?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:Me.numberFormattingFunction(a,M,D,U,C)}):null]},`${o.label}-${w[r]||r}`)),me?e.jsxRuntimeExports.jsx(et.XAxesLabels,{value:`${o.label}`.length<he?`${o.label}`:`${`${o.label}`.substring(0,he)}...`,y:h(0)+5,x:0,width:c.bandwidth(),height:v.bottom,style:S?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:V}):null,_?e.jsxRuntimeExports.jsx(ge.motion.text,{style:{...pe&&{fill:pe},textAnchor:"middle",...S?.graphObjectValues||{}},x:c.bandwidth()/2,dy:-10,className:e.mo("graph-value graph-value-total",pe?"text-sm":"fill-primary-gray-700 dark:fill-primary-gray-300 text-sm",b?.graphObjectValues),variants:{initial:{y:h(0),opacity:0},whileInView:{y:h(ke.sum(o.size.map(a=>a||0))),opacity:1,transition:{duration:g.duration}}},exit:{opacity:0,transition:{duration:g.duration}},initial:"initial",animate:V?"whileInView":"initial",children:Me.numberFormattingFunction(ke.sum(o.size.filter(a=>a)),M,D,U,C)}):null]},o.label)),Z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Z.map((o,a)=>e.jsxRuntimeExports.jsx(Fe.RefLineY,{text:o.text,color:o.color,y:h(o.value),x1:0-Q,x2:R+v.right,classNames:o.classNames,styles:o.styles,animate:g,isInView:V},a))}):null]}),N.filter(o=>o.position==="after").map(o=>o.layer)]})}),j&&oe&&ue&&B?e.jsxRuntimeExports.jsx(ze.Tooltip,{data:j,body:oe,xPos:ue,yPos:B,backgroundStyle:S?.tooltip,className:b?.tooltip}):null,ne&&$!==void 0?e.jsxRuntimeExports.jsx(Ae.X,{open:$!==void 0,onClose:()=>{T(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof ne=="string"?{__html:Ve.string2HTML(ne,$)}:void 0,children:typeof ne=="function"?ne($):null})}):null]})}function mt(fe){const{data:l,graphTitle:p,colors:H=Ce.Colors.light.categoricalColors.colors,sources:A,graphDescription:G,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:Q=20,topMargin:q=20,bottomMargin:ie=25,truncateBy:I=999,showLabels:oe=!0,showValues:xe=!0,backgroundColor:C=!1,showColorScale:U=!0,suffix:_="",prefix:Z="",height:E,width:f,footNote:L,colorDomain:ae,colorLegendTitle:se,padding:J,tooltip:ee,onSeriesMouseOver:ne,relativeHeight:W,refValues:pe,graphID:ce,maxValue:S,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:w=!1,language:D="en",theme:N="light",labelOrder:M,minHeight:z=0,maxBarThickness:V,sortParameter:v,maxNumberOfBars:j,minBarThickness:X,ariaLabel:$,resetSelectionOnDoubleClick:T=!0,detailsOnClick:ue,barAxisTitle:P,noOfTicks:B=5,valueColor:re,styles:R,classNames:F,filterNA:h=!0,animate:k=!1,precision:y=2,customLayers:c=[],timeline:d={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:o="NA"}=fe,[a,r]=m.useState(0),[t,s]=m.useState(0),[x,Oe]=m.useState(d.autoplay),K=Re.sort(Se.uniqBy(l.filter(n=>n.date!==void 0&&n.date!==null),n=>n.date).map(n=>Ee.parse(`${n.date}`,d.dateFormat||"yyyy",new Date).getTime()),(n,O)=>Ye.ascending(n,O)),[je,ve]=m.useState(d.autoplay?0:K.length-1),[we,le]=m.useState(void 0),ye=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{const n=new ResizeObserver(O=>{r(f||O[0].target.clientWidth||620),s(E||O[0].target.clientHeight||480)});return ye.current&&(s(ye.current.clientHeight||480),r(ye.current.clientWidth||620),f||n.observe(ye.current)),()=>n.disconnect()},[f,E]),m.useEffect(()=>{const n=setInterval(()=>{ve(O=>O<K.length-1?O+1:0)},(d.speed||2)*1e3);return x||clearInterval(n),()=>clearInterval(n)},[K,x,d.speed]);const te=Re.getSliderMarks(K,je,d.showOnlyActiveDate,d.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${N||"light"} flex ${f?"w-fit grow-0":"w-full grow"}`,dir:D==="he"||D==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${D||"en"}`,F?.graphContainer),style:{...R?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:ce,ref:u,"aria-label":$||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${G?` ${G}`:""}`,children:e.jsxRuntimeExports.jsx("div",{style:{padding:C?J||"1rem":J||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||G||g||w?e.jsxRuntimeExports.jsx(Ue.GraphHeader,{styles:{title:R?.title,description:R?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:G,width:f,graphDownload:g?u.current:void 0,dataDownload:w?l.map(n=>n.data).filter(n=>n!==void 0).length>0?l.map(n=>n.data).filter(n=>n!==void 0):l.filter(n=>n!==void 0):null}):null,d.enabled&&K.length>0&&te?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Oe(!x)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":x?"Click to pause animation":"Click to play animation",children:x?e.jsxRuntimeExports.jsx(Ie.Pause,{}):e.jsxRuntimeExports.jsx(Ie.Play,{})}),e.jsxRuntimeExports.jsx(Re.xr,{min:K[0],max:K[K.length-1],marks:te,step:null,defaultValue:K[K.length-1],value:K[je],onChangeComplete:n=>{ve(K.indexOf(n))},onChange:n=>{ve(K.indexOf(n))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?e.jsxRuntimeExports.jsx(Xe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[U?e.jsxRuntimeExports.jsx(We.ColorLegendWithMouseOver,{width:f,colorDomain:ae,colors:H,colorLegendTitle:se,setSelectedColor:le,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:ye,"aria-label":"Graph area",children:(f||a)&&(E||t)?e.jsxRuntimeExports.jsx(dt,{data:v!==void 0?v==="total"?De.sortBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n),n=>ke.sum(n.size.filter(O=>!Y.checkIfNullOrUndefined(O)))).filter((n,O)=>j?O<j:!0):De.sortBy(Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>d.enabled?n.date===Ee.format(new Date(K[je]),d.dateFormat||"yyyy"):n).filter(n=>h?!n.size.every(O=>O==null):n),n=>Y.checkIfNullOrUndefined(n.size[v])?-1/0:n.size[v]).filter((n,O)=>j?O<j:!0):Ne.ensureCompleteDataForStackedBarChart(l,d.dateFormat||"yyyy").filter(n=>h?!n.size.every(O=>O==null):n).filter((n,O)=>j?O<j:!0),barColors:H,width:f||a,height:Math.max(z,E||(W?z?(f||a)*W>z?(f||a)*W:z:(f||a)*W:t)),barPadding:me,showLabels:oe,showTicks:de,truncateBy:I,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,tooltip:ee,onSeriesMouseOver:ne,showValues:xe,suffix:_,prefix:Z,refValues:pe,maxValue:Y.checkIfNullOrUndefined(S)?Math.max(...l.map(n=>ke.sum(n.size.filter(O=>!Y.checkIfNullOrUndefined(O)))||0)):S,onSeriesMouseClick:b,selectedColor:we,labelOrder:M,maxBarThickness:V,minBarThickness:X,resetSelectionOnDoubleClick:T,detailsOnClick:ue,barAxisTitle:P,noOfTicks:B,valueColor:re,styles:R,classNames:F,animate:k===!0?{duration:.5,once:!0,amount:.5}:k||{duration:0,once:!0,amount:0},colorDomain:ae,precision:y,customLayers:c,naLabel:o}):null})]})}),A||L?e.jsxRuntimeExports.jsx(qe.GraphFooter,{styles:{footnote:R?.footnote,source:R?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:A,footNote:L,width:f}):null]})})})})}function ht(fe){const{data:l,graphTitle:p,colors:H,barPadding:A,showTicks:G,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Q,truncateBy:q,showLabels:ie,showValues:I,backgroundColor:oe,suffix:xe,prefix:C,sources:U,graphDescription:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,showColorScale:pe,graphID:ce,maxValue:S,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:D,dataDownload:N,language:M,theme:z,sortData:V,labelOrder:v,showNAColor:j,minHeight:X,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B,detailsOnClick:re,barAxisTitle:R,noOfTicks:F,valueColor:h,orientation:k="vertical",styles:y,classNames:c,filterNA:d,animate:o,dimmedOpacity:a,precision:r,customLayers:t,timeline:s,naLabel:x}=fe;return k==="vertical"?e.jsxRuntimeExports.jsx(ut,{data:l,graphTitle:p,colors:H,barPadding:A,showTicks:G,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Q,truncateBy:q,showLabels:ie,showValues:I,backgroundColor:oe,suffix:xe,prefix:C,sources:U,graphDescription:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,showColorScale:pe,graphID:ce,maxValue:S,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:D,dataDownload:N,language:M,theme:z,sortData:V,labelOrder:v,showNAColor:j,minHeight:X,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B,styles:y,detailsOnClick:re,barAxisTitle:R,noOfTicks:F,valueColor:h,classNames:c,filterNA:d,animate:o,dimmedOpacity:a,precision:r,customLayers:t,timeline:s}):e.jsxRuntimeExports.jsx(at,{data:l,graphTitle:p,colors:H,barPadding:A,showTicks:G,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Q,truncateBy:q,showLabels:ie,showValues:I,backgroundColor:oe,suffix:xe,prefix:C,sources:U,graphDescription:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,showColorScale:pe,graphID:ce,maxValue:S,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:w,graphDownload:D,dataDownload:N,language:M,theme:z,sortData:V,labelOrder:v,showNAColor:j,minHeight:X,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:ue,ariaLabel:P,resetSelectionOnDoubleClick:B,styles:y,detailsOnClick:re,barAxisTitle:R,noOfTicks:F,valueColor:h,classNames:c,filterNA:d,dimmedOpacity:a,precision:r,customLayers:t,timeline:s,naLabel:x})}function pt(fe){const{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,truncateBy:he,height:Q,width:q,footNote:ie,colorDomain:I,colorLegendTitle:oe,suffix:xe,prefix:C,showValues:U,padding:_,backgroundColor:Z,leftMargin:E,rightMargin:f,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,graphID:pe,maxValue:ce,minValue:S,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:D,labelOrder:N,minHeight:M,theme:z,maxBarThickness:V,ariaLabel:v,resetSelectionOnDoubleClick:j,detailsOnClick:X,barAxisTitle:$,noOfTicks:T,valueColor:ue,orientation:P="vertical",styles:B,classNames:re,filterNA:R,animate:F,precision:h,customLayers:k,showColorScale:y,timeline:c,naLabel:d}=fe;return P==="vertical"?e.jsxRuntimeExports.jsx(xt,{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,truncateBy:he,height:Q,width:q,footNote:ie,colorDomain:I,colorLegendTitle:oe,suffix:xe,prefix:C,showValues:U,padding:_,backgroundColor:Z,leftMargin:E,rightMargin:f,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,graphID:pe,maxValue:ce,minValue:S,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:D,labelOrder:N,minHeight:M,theme:z,maxBarThickness:V,ariaLabel:v,resetSelectionOnDoubleClick:j,styles:B,detailsOnClick:X,barAxisTitle:$,noOfTicks:T,valueColor:ue,classNames:re,filterNA:R,animate:F,precision:h,customLayers:k,showColorScale:y,timeline:c,naLabel:d}):e.jsxRuntimeExports.jsx(rt,{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,truncateBy:he,height:Q,width:q,footNote:ie,colorDomain:I,colorLegendTitle:oe,suffix:xe,prefix:C,showValues:U,padding:_,backgroundColor:Z,leftMargin:E,rightMargin:f,topMargin:L,bottomMargin:ae,showLabels:se,relativeHeight:J,tooltip:ee,onSeriesMouseOver:ne,refValues:W,graphID:pe,maxValue:ce,minValue:S,onSeriesMouseClick:b,graphDownload:g,dataDownload:w,language:D,labelOrder:N,minHeight:M,theme:z,maxBarThickness:V,ariaLabel:v,resetSelectionOnDoubleClick:j,styles:B,detailsOnClick:X,barAxisTitle:$,noOfTicks:T,valueColor:ue,classNames:re,filterNA:R,animate:F,precision:h,customLayers:k,showColorScale:y,timeline:c,naLabel:d})}function gt(fe){const{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,truncateBy:I,showLabels:oe,showValues:xe,backgroundColor:C,suffix:U,prefix:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:J,onSeriesMouseOver:ee,relativeHeight:ne,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:S,graphDownload:b,dataDownload:g,language:w,theme:D,labelOrder:N,minHeight:M,maxBarThickness:z,sortParameter:V,maxNumberOfBars:v,minBarThickness:j,ariaLabel:X,resetSelectionOnDoubleClick:$,detailsOnClick:T,barAxisTitle:ue,noOfTicks:P,valueColor:B,orientation:re="vertical",styles:R,classNames:F,filterNA:h,animate:k,precision:y,customLayers:c,showColorScale:d,timeline:o,naLabel:a}=fe;return re==="vertical"?e.jsxRuntimeExports.jsx(mt,{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,truncateBy:I,showLabels:oe,showValues:xe,backgroundColor:C,suffix:U,prefix:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:J,onSeriesMouseOver:ee,relativeHeight:ne,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:S,graphDownload:b,dataDownload:g,language:w,theme:D,labelOrder:N,minHeight:M,maxBarThickness:z,sortParameter:V,maxNumberOfBars:v,minBarThickness:j,ariaLabel:X,resetSelectionOnDoubleClick:$,styles:R,detailsOnClick:T,barAxisTitle:ue,noOfTicks:P,valueColor:B,classNames:F,filterNA:h,animate:k,precision:y,customLayers:c,showColorScale:d,timeline:o,naLabel:a}):e.jsxRuntimeExports.jsx(lt,{data:l,graphTitle:p,colors:H,sources:A,graphDescription:G,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Q,topMargin:q,bottomMargin:ie,truncateBy:I,showLabels:oe,showValues:xe,backgroundColor:C,suffix:U,prefix:_,height:Z,width:E,footNote:f,colorDomain:L,colorLegendTitle:ae,padding:se,tooltip:J,onSeriesMouseOver:ee,relativeHeight:ne,refValues:W,graphID:pe,maxValue:ce,onSeriesMouseClick:S,graphDownload:b,dataDownload:g,language:w,theme:D,labelOrder:N,minHeight:M,maxBarThickness:z,sortParameter:V,maxNumberOfBars:v,minBarThickness:j,ariaLabel:X,resetSelectionOnDoubleClick:$,styles:R,detailsOnClick:T,barAxisTitle:ue,noOfTicks:P,valueColor:B,classNames:F,filterNA:h,animate:k,precision:y,customLayers:c,showColorScale:d,timeline:o,naLabel:a})}exports.GroupedBarGraph=pt;exports.SimpleBarGraph=ht;exports.StackedBarGraph=gt;
|
|
2
2
|
//# sourceMappingURL=BarGraph.cjs.map
|
package/dist/BarGraph.js
CHANGED
|
@@ -5,22 +5,22 @@ import { s as Ae } from "./index-DxagiOHo.js";
|
|
|
5
5
|
import { p as Se, f as $e } from "./parse-DlCRUFh_.js";
|
|
6
6
|
import { s as Be, g as Fe, x as He } from "./getSliderMarks-C0jptXeP.js";
|
|
7
7
|
import { i as Pe } from "./index-27yTRcko.js";
|
|
8
|
-
import { X as We } from "./Modal-
|
|
8
|
+
import { X as We } from "./Modal-DVVwpKhP.js";
|
|
9
9
|
import { n as De } from "./numberFormattingFunction-14YCbkN2.js";
|
|
10
10
|
import { T as Ge } from "./Tooltip-DyM5snqx.js";
|
|
11
11
|
import { c as q } from "./checkIfNullOrUndefined-DmfiKkNw.js";
|
|
12
12
|
import { Colors as je } from "./Colors.js";
|
|
13
13
|
import { s as Xe } from "./string2HTML-CWHGfz_d.js";
|
|
14
14
|
import { X as st } from "./XTicksAndGridLines-Bn9u5gOM.js";
|
|
15
|
-
import { Y as rt } from "./YAxesLabels-
|
|
15
|
+
import { Y as rt } from "./YAxesLabels-CPGZjmZJ.js";
|
|
16
16
|
import { A as Ye } from "./AxisTitle-BmHLMRJZ.js";
|
|
17
17
|
import { A as _e } from "./Axis-Ddg-seDi.js";
|
|
18
|
-
import { a as ot, R as nt } from "./ReferenceLine-
|
|
19
|
-
import { u as Ee } from "./use-in-view-
|
|
18
|
+
import { a as ot, R as nt } from "./ReferenceLine-CfAW3vKJ.js";
|
|
19
|
+
import { u as Ee } from "./use-in-view-yS6jzJAp.js";
|
|
20
20
|
import { a as Re } from "./linear-DUdu7l2G.js";
|
|
21
21
|
import { b as Ie } from "./band-BEjh2CHI.js";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
22
|
+
import { A as qe } from "./index-CNvov0eg.js";
|
|
23
|
+
import { m as pe } from "./proxy-CkpFesk1.js";
|
|
24
24
|
import { GraphFooter as Ue } from "./GraphFooter.js";
|
|
25
25
|
import { GraphHeader as Je } from "./GraphHeader.js";
|
|
26
26
|
import { ColorLegendWithMouseOver as Ke } from "./ColorLegendWithMouseOver.js";
|
|
@@ -30,7 +30,7 @@ import { c as Le, d as Ve } from "./ensureCompleteData-BBDZbDCE.js";
|
|
|
30
30
|
import { c as tt } from "./init-BhZylTFx.js";
|
|
31
31
|
import { s as ke } from "./index-D7ltPi18.js";
|
|
32
32
|
import { g as lt } from "./getTextColorBasedOnBgColor-B6Nk2WBf.js";
|
|
33
|
-
import { X as ct } from "./XAxesLabels-
|
|
33
|
+
import { X as ct } from "./XAxesLabels-CaV2q-6H.js";
|
|
34
34
|
import { Y as dt } from "./YTicksAndGridLines-B6ah7CRf.js";
|
|
35
35
|
function ht(fe) {
|
|
36
36
|
const {
|