@undp/data-viz 1.5.4 → 1.5.6

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.
Files changed (72) hide show
  1. package/dist/BarGraph.cjs +1 -1
  2. package/dist/BarGraph.js +1 -1
  3. package/dist/BiVariateChoroplethMap.cjs +1 -1
  4. package/dist/BiVariateChoroplethMap.js +2 -2
  5. package/dist/BulletChart.cjs +1 -1
  6. package/dist/BulletChart.js +1 -1
  7. package/dist/ButterflyChart.cjs +1 -1
  8. package/dist/ButterflyChart.js +1 -1
  9. package/dist/ChoroplethMap.cjs +1 -1
  10. package/dist/ChoroplethMap.cjs.map +1 -1
  11. package/dist/ChoroplethMap.d.ts +0 -2
  12. package/dist/ChoroplethMap.js +2 -2
  13. package/dist/ChoroplethMap.js.map +1 -1
  14. package/dist/DotDensityMap.cjs +1 -1
  15. package/dist/DotDensityMap.js +2 -2
  16. package/dist/DumbbellChart.cjs +1 -1
  17. package/dist/DumbbellChart.js +1 -1
  18. package/dist/GraphEl-C6yjl1VM.cjs +2 -0
  19. package/dist/GraphEl-C6yjl1VM.cjs.map +1 -0
  20. package/dist/{GraphEl-CMWeARJ3.js → GraphEl-CqWzvOyr.js} +1 -2
  21. package/dist/GraphEl-CqWzvOyr.js.map +1 -0
  22. package/dist/GriddedGraphs.cjs +1 -1
  23. package/dist/GriddedGraphs.d.ts +1 -1
  24. package/dist/GriddedGraphs.js +1 -1
  25. package/dist/GriddedGraphsFromConfig.d.ts +1 -1
  26. package/dist/HeatMap.cjs +1 -1
  27. package/dist/HeatMap.js +1 -1
  28. package/dist/MultiGraphDashboard.d.ts +1 -1
  29. package/dist/MultiGraphDashboardFromConfig.d.ts +1 -1
  30. package/dist/PerformanceIntensiveMultiGraphDashboard.d.ts +1 -1
  31. package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.d.ts +1 -1
  32. package/dist/PerformanceIntensiveScrollStory.d.ts +1 -1
  33. package/dist/ScrollStory.d.ts +1 -1
  34. package/dist/SingleGraphDashboard.cjs +1 -1
  35. package/dist/SingleGraphDashboard.d.ts +1 -1
  36. package/dist/SingleGraphDashboard.js +1 -1
  37. package/dist/SingleGraphDashboardFromConfig.d.ts +1 -1
  38. package/dist/SingleGraphDashboardGeoHubMaps.d.ts +1 -1
  39. package/dist/SingleGraphDashboardGeoHubMapsFromConfig.d.ts +1 -1
  40. package/dist/SingleGraphDashboardThreeDGraphs.cjs +1 -1
  41. package/dist/SingleGraphDashboardThreeDGraphs.cjs.map +1 -1
  42. package/dist/SingleGraphDashboardThreeDGraphs.d.ts +1 -1
  43. package/dist/SingleGraphDashboardThreeDGraphs.js +2 -2
  44. package/dist/SingleGraphDashboardThreeDGraphs.js.map +1 -1
  45. package/dist/SingleGraphDashboardThreeDGraphsFromConfig.d.ts +1 -1
  46. package/dist/ThreeDGlobe.cjs +1 -1
  47. package/dist/ThreeDGlobe.cjs.map +1 -1
  48. package/dist/ThreeDGlobe.d.ts +2 -2
  49. package/dist/ThreeDGlobe.js +394 -333
  50. package/dist/ThreeDGlobe.js.map +1 -1
  51. package/dist/Types.d.ts +1 -1
  52. package/dist/{YAxesLabels-DSm6I5zG.js → YAxesLabels-DECkMgq8.js} +9 -8
  53. package/dist/YAxesLabels-DECkMgq8.js.map +1 -0
  54. package/dist/{YAxesLabels-CctDydGR.cjs → YAxesLabels-yRFFdx1s.cjs} +2 -2
  55. package/dist/YAxesLabels-yRFFdx1s.cjs.map +1 -0
  56. package/dist/index-9tDEUqOZ.js +752 -0
  57. package/dist/{index-qfWCwobm.js.map → index-9tDEUqOZ.js.map} +1 -1
  58. package/dist/index-CoZbeNM9.cjs +2 -0
  59. package/dist/{index-D05lK1Te.cjs.map → index-CoZbeNM9.cjs.map} +1 -1
  60. package/dist/index.d.ts +3 -5
  61. package/dist/{zoom-Bsbhil-K.cjs → zoom-BiMNsz72.cjs} +2 -2
  62. package/dist/{zoom-Bsbhil-K.cjs.map → zoom-BiMNsz72.cjs.map} +1 -1
  63. package/dist/{zoom-DAu91HKr.js → zoom-QipiAl5W.js} +2 -2
  64. package/dist/{zoom-DAu91HKr.js.map → zoom-QipiAl5W.js.map} +1 -1
  65. package/package.json +2 -1
  66. package/dist/GraphEl-BcYgMnN2.cjs +0 -2
  67. package/dist/GraphEl-BcYgMnN2.cjs.map +0 -1
  68. package/dist/GraphEl-CMWeARJ3.js.map +0 -1
  69. package/dist/YAxesLabels-CctDydGR.cjs.map +0 -1
  70. package/dist/YAxesLabels-DSm6I5zG.js.map +0 -1
  71. package/dist/index-D05lK1Te.cjs +0 -2
  72. package/dist/index-qfWCwobm.js +0 -682
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),j=require("react"),Ne=require("./index-CQ3e6Ewi.cjs"),ke=require("./index-DQA8q5sC.cjs"),Ce=require("./Modal-tXZlLE5s.cjs"),Re=require("./index-CSNtgibC.cjs"),Me=require("./numberFormattingFunction-02t-wJta.cjs"),Ee=require("./Tooltip-De16GWhY.cjs"),c=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Oe=require("./string2HTML-z7CwHXcx.cjs"),Ue=require("./XTicksAndGridLines-CCzXIV8d.cjs"),He=require("./YAxesLabels-CctDydGR.cjs"),Ie=require("./AxisTitle-CK9YeovX.cjs"),Ve=require("./Axis-DE7dSn1_.cjs"),ze=require("./ReferenceLine-CFVBBN__.cjs"),Te=require("./linear-BVckp9RD.cjs"),qe=require("./band-CAApY4Pd.cjs"),Ae=require("./use-in-view-sQJZ_xDO.cjs"),_=require("./proxy-BHRoeZgd.cjs"),Le=require("./index-BW8iNx7E.cjs"),$e=require("./GraphFooter.cjs"),Se=require("./GraphHeader.cjs"),ve=require("./Colors.cjs"),De=require("./EmptyState-d8_8SxeW.cjs"),Be=require("./ColorLegend.cjs"),Pe=require("./XAxesLabels-Drf7M3YK.cjs"),Ge=require("./YTicksAndGridLines-DBDuz6vb.cjs");function We(we){const{data:s,barColor:y,suffix:J,prefix:K,barPadding:Q,showValues:re,showTicks:Z,leftMargin:ye,truncateBy:de,width:ee,height:te,rightMargin:be,topMargin:E,bottomMargin:ie,showLabels:o,tooltip:S,onSeriesMouseOver:V,refValues:T,highlightedDataPoints:h,maxValue:D,minValue:b,onSeriesMouseClick:B,labelOrder:ae,rtl:F,maxBarThickness:q,minBarThickness:me,resetSelectionOnDoubleClick:A,detailsOnClick:z,barAxisTitle:ne,valueColor:le,noOfTicks:O,styles:g,classNames:M,targetStyle:se,targetColor:U,qualitativeRangeColors:L,measureBarWidthFactor:u,animate:l,dimmedOpacity:N,precision:H,customLayers:$,naLabel:P}=we,p=j.useRef(null),d=Ae.useInView(p,{once:l.once,amount:l.amount}),[oe,G]=j.useState(void 0),[k,W]=j.useState(void 0),[ue,C]=j.useState(void 0),[f,w]=j.useState(void 0),x={top:ne?E+25:E,bottom:ie,left:ye,right:be},X=ee-x.left-x.right,I=te-x.top-x.bottom,ce=Math.max(...s.filter(e=>!c.checkIfNullOrUndefined(e.size)).map(e=>e.size))<0?0:Math.max(...s.filter(e=>!c.checkIfNullOrUndefined(e.size)).map(e=>e.size)),Y=Math.max(...s.filter(e=>!c.checkIfNullOrUndefined(e.target)).map(e=>e.target))<0?0:Math.max(...s.filter(e=>!c.checkIfNullOrUndefined(e.target)).map(e=>e.target)),xe=Math.max(...s.map(e=>Re.sum((e.qualitativeRange||[]).filter(r=>!c.checkIfNullOrUndefined(r)))||0)),ge=c.checkIfNullOrUndefined(D)?Math.max(...[ce,Y,xe].filter(Number.isFinite))<0?0:Math.max(...[ce,Y,xe].filter(Number.isFinite)):D,he=Math.min(...s.filter(e=>!c.checkIfNullOrUndefined(e.size)).map(e=>e.size))>=0?0:Math.min(...s.filter(e=>!c.checkIfNullOrUndefined(e.size)).map(e=>e.size)),R=Math.min(...s.filter(e=>!c.checkIfNullOrUndefined(e.target)).map(e=>e.target))>=0?0:Math.min(...s.filter(e=>!c.checkIfNullOrUndefined(e.target)).map(e=>e.target)),a=c.checkIfNullOrUndefined(b)?Math.min(...[he,R].filter(Number.isFinite))>=0?0:Math.min(...[he,R].filter(Number.isFinite)):b,fe=s.map((e,r)=>({...e,id:ae?`${e.label}`:`${r}`})),n=Te.linear().domain([a,ge]).range([0,X]).nice(),v=ae||fe.map(e=>`${e.id}`),m=qe.band().domain(v).range([0,me?Math.max(I,me*v.length):q?Math.min(I,q*v.length):I]).paddingInner(Q),t=n.ticks(O);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(_.motion.svg,{width:`${ee}px`,height:`${te}px`,viewBox:`0 0 ${ee} ${te}`,direction:"ltr",ref:p,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${x.left},${x.top})`,children:[Z?i.jsxRuntimeExports.jsx(Ue.XTicksAndGridLines,{values:t.filter(e=>e!==0),x:t.filter(e=>e!==0).map(e=>n(e)),y1:0-E,y2:I+x.bottom,styles:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},classNames:{gridLines:M?.xAxis?.gridLines,labels:M?.xAxis?.labels},suffix:J,prefix:K,labelType:"secondary",showGridLines:!0,precision:H}):null,i.jsxRuntimeExports.jsx(Ie.AxisTitle,{x:X/2,y:0-x.top+15,style:g?.xAxis?.title,className:M?.xAxis?.title,text:ne}),i.jsxRuntimeExports.jsx(Ve.Axis,{x1:n(a<0?0:a),x2:n(a<0?0:a),y1:-2.5,y2:I+x.bottom,classNames:{axis:M?.yAxis?.axis},styles:{axis:g?.yAxis?.axis}}),$.filter(e=>e.position==="before").map(e=>e.layer),i.jsxRuntimeExports.jsxs(Le.AnimatePresence,{children:[fe.map(e=>c.checkIfNullOrUndefined(m(e.id))?null:i.jsxRuntimeExports.jsxs(_.motion.g,{className:"undp-viz-g-with-hover",onMouseEnter:r=>{G(e),w(r.clientY),C(r.clientX),V?.(e)},onClick:()=>{(B||z)&&(ke.isEqual(k,e)&&A?(W(void 0),B?.(void 0)):(W(e),B?.(e)))},onMouseMove:r=>{G(e),w(r.clientY),C(r.clientX)},onMouseLeave:()=>{G(void 0),C(void 0),w(void 0),V?.(void 0)},exit:{opacity:0,transition:{duration:l.duration}},variants:{initial:{x:0,y:m(`${e.id}`),opacity:h.length!==0?h.indexOf(e.label)!==-1?.85:N:.85},whileInView:{x:0,y:m(`${e.id}`),opacity:h.length!==0?h.indexOf(e.label)!==-1?.85:N:.85,transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial",children:[e.qualitativeRange?e.qualitativeRange.map((r,pe)=>i.jsxRuntimeExports.jsx(_.motion.rect,{exit:{width:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),width:0,fill:L[pe]},whileInView:{x:n(pe===0?0:Re.sum(e.qualitativeRange.filter((je,Fe)=>Fe<pe&&je))),width:n(r),fill:L[pe],transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial",y:0,height:m.bandwidth()},pe)):null,e.target&&se==="background"?i.jsxRuntimeExports.jsx(_.motion.rect,{y:0,x:e.target>=0?n(0):n(e.target),height:m.bandwidth(),style:{fill:U},exit:{width:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),width:0},whileInView:{x:e.target>=0?n(0):n(e.target),width:e.target>=0?n(e.target)-n(0):n(0)-n(e.target),transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial"}):null,e.size?i.jsxRuntimeExports.jsx(_.motion.rect,{y:m.bandwidth()*((1-u)/2),style:{fill:y},height:m.bandwidth()*u,exit:{width:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),width:0},whileInView:{x:e.size>=0?n(0):n(e.size),width:e.size>=0?n(e.size)-n(0):n(0)-n(e.size),transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial"}):null,e.target&&se==="line"?i.jsxRuntimeExports.jsx(_.motion.rect,{y:0,height:m.bandwidth(),style:{fill:U},width:2,exit:{opacity:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),opacity:0},whileInView:{x:n(e.target)-1,opacity:1,transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial"}):null,o?i.jsxRuntimeExports.jsx(He.YAxesLabels,{value:`${e.label}`.length<de?`${e.label}`:`${`${e.label}`.substring(0,de)}...`,y:0,x:(e.size||0)<0?n(0):0-x.left,width:(e.size||0)<0?ee-n(0):n(0)+x.left,height:m.bandwidth(),alignment:e.size&&e.size<0?"left":"right",style:g?.yAxis?.labels,className:M?.yAxis?.labels,animate:l,isInView:d}):null,re?i.jsxRuntimeExports.jsx(_.motion.text,{y:m.bandwidth()/2,style:{...le?{fill:le}:{fill:y},textAnchor:e.size&&e.size<0?"end":"start",...g?.graphObjectValues||{}},className:i.mo("graph-value text-sm",!le&&y.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",M?.graphObjectValues),dx:e.size&&e.size<0?-5:5,dy:"0.33em",exit:{opacity:0,transition:{duration:l.duration}},variants:{initial:{x:n(0),opacity:0},whileInView:{x:e.size?n(e.size):n(0),opacity:1,transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial",children:Me.numberFormattingFunction(e.size,P,H,K,J)}):null]},e.label)),T?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:T.map((e,r)=>i.jsxRuntimeExports.jsx(ze.RefLineX,{text:e.text,color:e.color,x:n(e.value),y1:0-x.top,y2:I+x.bottom,textSide:n(e.value)>X*.75||F?"left":"right",classNames:e.classNames,styles:e.styles,animate:l,isInView:d},r))}):null]}),$.filter(e=>e.position==="after").map(e=>e.layer)]})}),oe&&S&&ue&&f?i.jsxRuntimeExports.jsx(Ee.Tooltip,{data:oe,body:S,xPos:ue,yPos:f,backgroundStyle:g?.tooltip,className:M?.tooltip}):null,z&&k!==void 0?i.jsxRuntimeExports.jsx(Ce.X,{open:k!==void 0,onClose:()=>{W(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof z=="string"?{__html:Oe.string2HTML(z,k)}:void 0,children:typeof z=="function"?z(k):null})}):null]})}function Xe(we){const{data:s,graphTitle:y,barColor:J=ve.Colors.primaryColors["blue-600"],suffix:K="",sources:Q,prefix:re="",graphDescription:Z,barPadding:ye=.25,showValues:de=!0,showTicks:ee=!0,leftMargin:te=100,rightMargin:be=40,truncateBy:E=999,height:ie,width:o,footNote:S,colorDomain:V,colorLegendTitle:T,highlightedDataPoints:h=[],padding:D,backgroundColor:b=!1,topMargin:B=25,bottomMargin:ae=10,showLabels:F=!0,relativeHeight:q,tooltip:me,onSeriesMouseOver:A,refValues:z,showColorScale:ne=!0,graphID:le,maxValue:O,minValue:g,onSeriesMouseClick:M,graphDownload:se=!1,dataDownload:U=!1,sortData:L,labelOrder:u,language:l="en",minHeight:N=0,theme:H="light",maxBarThickness:$,maxNumberOfBars:P,minBarThickness:p,ariaLabel:d,resetSelectionOnDoubleClick:oe=!0,detailsOnClick:G,barAxisTitle:k,noOfTicks:W=5,valueColor:ue,styles:C,classNames:f,filterNA:w=!0,targetStyle:x="line",targetColor:X=ve.Colors.light.grays["gray-700"],qualitativeRangeColors:I,measureBarWidthFactor:ce=.4,animate:Y=!1,dimmedOpacity:xe=.3,precision:ge=2,customLayers:he=[],naLabel:R="NA"}=we,[a,fe]=j.useState(0),[n,v]=j.useState(0),m=j.useRef(null),t=j.useRef(null);return j.useEffect(()=>{const e=new ResizeObserver(r=>{fe(o||r[0].target.clientWidth||620),v(ie||r[0].target.clientHeight||480)});return m.current&&(v(m.current.clientHeight||480),fe(m.current.clientWidth||620),o||e.observe(m.current)),()=>e.disconnect()},[o,ie]),i.jsxRuntimeExports.jsx("div",{className:`${H||"light"} flex ${o?"w-fit grow-0":"w-full grow"}`,dir:l==="he"||l==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${b?b===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${l||"en"}`,o?"w-fit":"w-full",f?.graphContainer),style:{...C?.graphContainer||{},...b&&b!==!0?{backgroundColor:b}:{}},id:le,ref:t,"aria-label":d||`${y?`The graph shows ${y}. `:""}This is a bar chart. ${Z?` ${Z}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:b?D||"1rem":D||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[y||Z||se||U?i.jsxRuntimeExports.jsx(Se.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:f?.title,description:f?.description},graphTitle:y,graphDescription:Z,width:o,graphDownload:se?t.current:void 0,dataDownload:U?s.map(e=>e.data).filter(e=>e!==void 0).length>0?s.map(e=>e.data).filter(e=>e!==void 0):s.filter(e=>e!==void 0):null}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:s.length===0?i.jsxRuntimeExports.jsx(De.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[ne&&s.filter(e=>e.qualitativeRange).length!==0&&V?i.jsxRuntimeExports.jsx(Be.ColorLegend,{width:o,colorLegendTitle:T,colors:I||ve.Colors[H].sequentialColors.positiveColorsx10,colorDomain:V,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:m,"aria-label":"Graph area",children:(o||a)&&(ie||n)?i.jsxRuntimeExports.jsx(We,{data:L?Ne.orderBy(s.filter(e=>w?!c.checkIfNullOrUndefined(e.size):e),[e=>e.size===void 0?L==="asc"?-1/0:1/0:e.size],[L]).filter((e,r)=>P?r<P:!0):s.filter(e=>w?!c.checkIfNullOrUndefined(e.size):e).filter((e,r)=>P?r<P:!0),barColor:J,targetColor:X,width:o||a,height:Math.max(N,ie||(q?N?(o||a)*q>N?(o||a)*q:N:(o||a)*q:n)),suffix:K,prefix:re,barPadding:ye,showValues:de,showTicks:ee,leftMargin:te,rightMargin:be,topMargin:B,bottomMargin:ae,truncateBy:E,showLabels:F,tooltip:me,onSeriesMouseOver:A,refValues:z,maxValue:O,minValue:g,highlightedDataPoints:h,onSeriesMouseClick:M,labelOrder:u,rtl:l==="he"||l==="ar",maxBarThickness:$,minBarThickness:p,resetSelectionOnDoubleClick:oe,detailsOnClick:G,barAxisTitle:k,noOfTicks:W,valueColor:ue,classNames:f,styles:C,targetStyle:x,qualitativeRangeColors:I||ve.Colors[H].sequentialColors.positiveColorsx10,measureBarWidthFactor:ce,animate:Y===!0?{duration:.5,once:!0,amount:.5}:Y||{duration:0,once:!0,amount:0},dimmedOpacity:xe,precision:ge,customLayers:he,naLabel:R}):null})]})}),Q||S?i.jsxRuntimeExports.jsx($e.GraphFooter,{sources:Q,footNote:S,width:o,styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:f?.footnote,source:f?.source}}):null]})})})})}function Ye(we){const{data:s,width:y,height:J,barColor:K,suffix:Q,prefix:re,barPadding:Z,showLabels:ye,showValues:de,showTicks:ee,truncateBy:te,rightMargin:be,topMargin:E,bottomMargin:ie,leftMargin:o,tooltip:S,onSeriesMouseOver:V,refValues:T,maxValue:h,minValue:D,highlightedDataPoints:b,onSeriesMouseClick:B,labelOrder:ae,maxBarThickness:F,minBarThickness:q,resetSelectionOnDoubleClick:me,detailsOnClick:A,barAxisTitle:z,valueColor:ne,noOfTicks:le,styles:O,classNames:g,targetStyle:M,targetColor:se,qualitativeRangeColors:U,measureBarWidthFactor:L,animate:u,dimmedOpacity:l,precision:N,customLayers:H,naLabel:$}=we,P=j.useRef(null),p=Ae.useInView(P,{once:u.once,amount:u.amount}),d={top:E,bottom:ie,left:z?o+30:o,right:be},[oe,G]=j.useState(void 0),[k,W]=j.useState(void 0),[ue,C]=j.useState(void 0),[f,w]=j.useState(void 0),x=y-d.left-d.right,X=J-d.top-d.bottom,I=Math.max(...s.filter(t=>!c.checkIfNullOrUndefined(t.size)).map(t=>t.size))<0?0:Math.max(...s.filter(t=>!c.checkIfNullOrUndefined(t.size)).map(t=>t.size)),ce=Math.max(...s.filter(t=>!c.checkIfNullOrUndefined(t.target)).map(t=>t.target))<0?0:Math.max(...s.filter(t=>!c.checkIfNullOrUndefined(t.size)).map(t=>t.target)),Y=Math.max(...s.map(t=>Re.sum((t.qualitativeRange||[]).filter(e=>!c.checkIfNullOrUndefined(e)))||0)),xe=c.checkIfNullOrUndefined(h)?Math.max(...[I,ce,Y].filter(Number.isFinite))<0?0:Math.max(...[I,ce,Y].filter(Number.isFinite)):h,ge=Math.min(...s.filter(t=>!c.checkIfNullOrUndefined(t.size)).map(t=>t.size))>=0?0:Math.min(...s.filter(t=>!c.checkIfNullOrUndefined(t.size)).map(t=>t.size)),he=Math.min(...s.filter(t=>!c.checkIfNullOrUndefined(t.target)).map(t=>t.target))>=0?0:Math.min(...s.filter(t=>!c.checkIfNullOrUndefined(t.target)).map(t=>t.target)),R=c.checkIfNullOrUndefined(D)?Math.min(...[ge,he].filter(Number.isFinite))>=0?0:Math.min(...[ge,he].filter(Number.isFinite)):D,a=Te.linear().domain([R,xe]).range([X,0]).nice(),fe=s.map((t,e)=>({...t,id:ae?`${t.label}`:`${e}`})),n=ae||fe.map(t=>`${t.id}`),v=qe.band().domain(n).range([0,q?Math.max(x,q*n.length):F?Math.min(x,F*n.length):x]).paddingInner(Z),m=a.ticks(le);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(_.motion.svg,{width:`${y}px`,height:`${J}px`,viewBox:`0 0 ${y} ${J}`,direction:"ltr",ref:P,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[i.jsxRuntimeExports.jsx(Ve.Axis,{y1:a(R<0?0:R),y2:a(R<0?0:R),x1:0-o,x2:x+d.right,label:Me.numberFormattingFunction(R<0?0:R,$,N,re,Q),labelPos:{x:0-o,dx:0,dy:xe<0?"1em":-5,y:a(R<0?0:R)},classNames:{axis:g?.xAxis?.axis,label:g?.yAxis?.labels},styles:{axis:O?.xAxis?.axis,label:O?.yAxis?.labels}}),ee?i.jsxRuntimeExports.jsx(Ge.YTicksAndGridLines,{values:m.filter(t=>t!==0),y:m.filter(t=>t!==0).map(t=>a(t)),x1:0-o,x2:x+d.right,styles:{gridLines:O?.yAxis?.gridLines,labels:O?.yAxis?.labels},classNames:{gridLines:g?.yAxis?.gridLines,labels:g?.yAxis?.labels},suffix:Q,prefix:re,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:N}):null,i.jsxRuntimeExports.jsx(Ie.AxisTitle,{x:0-o-15,y:X/2,style:O?.yAxis?.title,className:g?.yAxis?.title,text:z,rotate90:!0}),H.filter(t=>t.position==="before").map(t=>t.layer),i.jsxRuntimeExports.jsxs(Le.AnimatePresence,{children:[fe.map(t=>c.checkIfNullOrUndefined(v(t.id))?null:i.jsxRuntimeExports.jsxs(_.motion.g,{className:"undp-viz-g-with-hover",onMouseEnter:e=>{G(t),w(e.clientY),C(e.clientX),V?.(t)},onClick:()=>{(B||A)&&(ke.isEqual(k,t)&&me?(W(void 0),B?.(void 0)):(W(t),B?.(t)))},onMouseMove:e=>{G(t),w(e.clientY),C(e.clientX)},onMouseLeave:()=>{G(void 0),C(void 0),w(void 0),V?.(void 0)},exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{x:v(`${t.id}`),y:0,opacity:b.length!==0?b.indexOf(t.label)!==-1?.85:l:.85},whileInView:{x:v(`${t.id}`),y:0,opacity:b.length!==0?b.indexOf(t.label)!==-1?.85:l:.85,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",children:[t.qualitativeRange?t.qualitativeRange.map((e,r)=>i.jsxRuntimeExports.jsx(_.motion.rect,{x:0,exit:{height:0,y:a(0),transition:{duration:u.duration}},variants:{initial:{height:0,y:a(0),fill:U[r]},whileInView:{height:Math.abs(a(Re.sum(t.qualitativeRange.filter((pe,je)=>je<=r&&pe)))-a(Re.sum(t.qualitativeRange.filter((pe,je)=>je<r&&pe)))),y:a(Re.sum(t.qualitativeRange.filter((pe,je)=>je<=r&&pe))),fill:U[r],transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",width:v.bandwidth()},r)):null,t.target&&M==="background"?i.jsxRuntimeExports.jsx(_.motion.rect,{x:0,width:v.bandwidth(),style:{fill:se},exit:{height:0,y:a(0),transition:{duration:u.duration}},variants:{initial:{height:0,y:a(0)},whileInView:{height:Math.abs(a(t.target)-a(0)),y:t.target>0?a(t.target):a(0),transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial"}):null,t.size?i.jsxRuntimeExports.jsx(_.motion.rect,{x:v.bandwidth()*((1-L)/2),width:v.bandwidth()*L,style:{fill:K},exit:{height:0,y:a(0),transition:{duration:u.duration}},variants:{initial:{height:0,y:a(0)},whileInView:{height:Math.abs(a(t.size)-a(0)),y:t.size>0?a(t.size):a(0),transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial"}):null,t.target&&M==="line"?i.jsxRuntimeExports.jsx(_.motion.rect,{x:0,width:v.bandwidth(),style:{fill:se},exit:{y:a(0),opacity:0,transition:{duration:u.duration}},variants:{initial:{y:a(0),opacity:0},whileInView:{y:a(t.target)-1,opacity:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",height:2}):null,ye?i.jsxRuntimeExports.jsx(Pe.XAxesLabels,{value:`${t.label}`.length<te?`${t.label}`:`${`${t.label}`.substring(0,te)}...`,y:(t.size||0)<0?0:a(0)+5,x:0,width:v.bandwidth(),height:(t.size||0)<0?a(0)-5:d.bottom,style:O?.xAxis?.labels,className:g?.xAxis?.labels,alignment:(t.size||0)<0?"bottom":"top",animate:u,isInView:p}):null,de?i.jsxRuntimeExports.jsx(_.motion.text,{x:v.bandwidth()/2,style:{...ne?{fill:ne}:{fill:K},textAnchor:"middle",...O?.graphObjectValues||{}},className:i.mo("graph-value text-sm",!ne&&K.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",g?.graphObjectValues),dy:t.size?t.size>=0?"-5px":"1em":"-5px",exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{y:a(0),opacity:0},whileInView:{y:a(t.size||0),opacity:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",children:Me.numberFormattingFunction(t.size,$,N,re,Q)}):null]},t.label)),T?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:T.map((t,e)=>i.jsxRuntimeExports.jsx(ze.RefLineY,{text:t.text,color:t.color,y:a(t.value),x1:0-o,x2:x+d.right,classNames:t.classNames,styles:t.styles,animate:u,isInView:p},e))}):null]}),H.filter(t=>t.position==="after").map(t=>t.layer)]})}),oe&&S&&ue&&f?i.jsxRuntimeExports.jsx(Ee.Tooltip,{data:oe,body:S,xPos:ue,yPos:f,backgroundStyle:O?.tooltip,className:g?.tooltip}):null,A&&k!==void 0?i.jsxRuntimeExports.jsx(Ce.X,{open:k!==void 0,onClose:()=>{W(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof A=="string"?{__html:Oe.string2HTML(A,k)}:void 0,children:typeof A=="function"?A(k):null})}):null]})}function _e(we){const{data:s,graphTitle:y,barColor:J=ve.Colors.primaryColors["blue-600"],barPadding:K=.25,showTicks:Q=!0,leftMargin:re=20,rightMargin:Z=20,topMargin:ye=20,bottomMargin:de=25,truncateBy:ee=999,showLabels:te=!0,showValues:be=!0,backgroundColor:E=!1,suffix:ie="",prefix:o="",sources:S,graphDescription:V,height:T,width:h,footNote:D,colorDomain:b,colorLegendTitle:B,padding:ae,relativeHeight:F,tooltip:q,onSeriesMouseOver:me,refValues:A,showColorScale:z=!0,graphID:ne,maxValue:le,minValue:O,highlightedDataPoints:g=[],qualitativeRangeColors:M,onSeriesMouseClick:se,graphDownload:U=!1,dataDownload:L=!1,language:u="en",theme:l="light",sortData:N,labelOrder:H,minHeight:$=0,maxBarThickness:P,maxNumberOfBars:p,minBarThickness:d,ariaLabel:oe,resetSelectionOnDoubleClick:G=!0,detailsOnClick:k,barAxisTitle:W,noOfTicks:ue=5,valueColor:C,styles:f,classNames:w,targetColor:x=ve.Colors.light.grays["gray-700"],filterNA:X=!0,targetStyle:I="line",measureBarWidthFactor:ce=.4,animate:Y=!1,dimmedOpacity:xe=.3,precision:ge=2,customLayers:he=[],naLabel:R="NA"}=we,[a,fe]=j.useState(0),[n,v]=j.useState(0),m=j.useRef(null),t=j.useRef(null);return j.useEffect(()=>{const e=new ResizeObserver(r=>{fe(h||r[0].target.clientWidth||620),v(T||r[0].target.clientHeight||480)});return m.current&&(v(m.current.clientHeight||480),fe(m.current.clientWidth||620),h||e.observe(m.current)),()=>e.disconnect()},[h,T]),i.jsxRuntimeExports.jsx("div",{className:`${l||"light"} flex ${h?"w-fit grow-0":"w-full grow"}`,dir:u==="he"||u==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.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 ${u||"en"}`,h?"w-fit":"w-full",w?.graphContainer),style:{...f?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:ne,ref:t,"aria-label":oe||`${y?`The graph shows ${y}. `:""}This is a grouped bar chart. ${V?` ${V}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?ae||"1rem":ae||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[y||V||U||L?i.jsxRuntimeExports.jsx(Se.GraphHeader,{styles:{title:f?.title,description:f?.description},classNames:{title:w?.title,description:w?.description},graphTitle:y,graphDescription:V,width:h,graphDownload:U?t.current:void 0,dataDownload:L?s.map(e=>e.data).filter(e=>e!==void 0).length>0?s.map(e=>e.data).filter(e=>e!==void 0):s.filter(e=>e!==void 0):null}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:s.length===0?i.jsxRuntimeExports.jsx(De.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[z&&s.filter(e=>e.qualitativeRange).length!==0&&b?i.jsxRuntimeExports.jsx(Be.ColorLegend,{width:h,colorLegendTitle:B,colors:M||ve.Colors[l].sequentialColors.positiveColorsx10,colorDomain:b,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:m,"aria-label":"Graph area",children:(h||a)&&(T||n)?i.jsxRuntimeExports.jsx(Ye,{data:N?Ne.orderBy(s.filter(e=>X?!c.checkIfNullOrUndefined(e.size):e),[e=>e.size===void 0?N==="asc"?-1/0:1/0:e.size],[N]).filter((e,r)=>p?r<p:!0):s.filter(e=>X?!c.checkIfNullOrUndefined(e.size):e).filter((e,r)=>p?r<p:!0),barColor:J,targetColor:x,width:h||a,refValues:A,height:Math.max($,T||(F?$?(h||a)*F>$?(h||a)*F:$:(h||a)*F:n)),suffix:ie,prefix:o,barPadding:K,showLabels:te,showValues:be,showTicks:Q,truncateBy:ee,leftMargin:re,rightMargin:Z,qualitativeRangeColors:M||ve.Colors[l].sequentialColors.positiveColorsx10,topMargin:ye,bottomMargin:de,tooltip:q,onSeriesMouseOver:me,maxValue:le,minValue:O,highlightedDataPoints:g,onSeriesMouseClick:se,labelOrder:H,maxBarThickness:P,minBarThickness:d,resetSelectionOnDoubleClick:G,detailsOnClick:k,barAxisTitle:W,noOfTicks:ue,valueColor:C,styles:f,classNames:w,targetStyle:I,dimmedOpacity:xe,measureBarWidthFactor:ce,animate:Y===!0?{duration:.5,once:!0,amount:.5}:Y||{duration:0,once:!0,amount:0},precision:ge,customLayers:he,naLabel:R}):null})]})}),S||D?i.jsxRuntimeExports.jsx($e.GraphFooter,{styles:{footnote:f?.footnote,source:f?.source},classNames:{footnote:w?.footnote,source:w?.source},sources:S,footNote:D,width:h}):null]})})})})}function Je(we){const{data:s,graphTitle:y,barColor:J,barPadding:K,showTicks:Q,leftMargin:re,rightMargin:Z,topMargin:ye,bottomMargin:de,truncateBy:ee,showLabels:te,showValues:be,backgroundColor:E,suffix:ie,prefix:o,sources:S,graphDescription:V,height:T,width:h,footNote:D,colorDomain:b,colorLegendTitle:B,padding:ae,relativeHeight:F,tooltip:q,onSeriesMouseOver:me,refValues:A,showColorScale:z,graphID:ne,maxValue:le,minValue:O,highlightedDataPoints:g,onSeriesMouseClick:M,graphDownload:se,dataDownload:U,language:L,theme:u,sortData:l,labelOrder:N,minHeight:H,maxBarThickness:$,maxNumberOfBars:P,minBarThickness:p,ariaLabel:d,resetSelectionOnDoubleClick:oe,detailsOnClick:G,barAxisTitle:k,noOfTicks:W,valueColor:ue,orientation:C="vertical",styles:f,classNames:w,filterNA:x,targetStyle:X,targetColor:I,qualitativeRangeColors:ce,measureBarWidthFactor:Y,animate:xe,dimmedOpacity:ge,precision:he,naLabel:R}=we;return C==="vertical"?i.jsxRuntimeExports.jsx(_e,{data:s,graphTitle:y,barColor:J,barPadding:K,showTicks:Q,leftMargin:re,rightMargin:Z,topMargin:ye,bottomMargin:de,truncateBy:ee,showLabels:te,showValues:be,backgroundColor:E,suffix:ie,prefix:o,sources:S,graphDescription:V,height:T,width:h,footNote:D,colorDomain:b,colorLegendTitle:B,padding:ae,relativeHeight:F,tooltip:q,onSeriesMouseOver:me,refValues:A,showColorScale:z,graphID:ne,maxValue:le,minValue:O,highlightedDataPoints:g,onSeriesMouseClick:M,graphDownload:se,dataDownload:U,language:L,theme:u,sortData:l,labelOrder:N,minHeight:H,maxBarThickness:$,maxNumberOfBars:P,minBarThickness:p,ariaLabel:d,resetSelectionOnDoubleClick:oe,styles:f,detailsOnClick:G,barAxisTitle:k,noOfTicks:W,valueColor:ue,classNames:w,filterNA:x,targetStyle:X,targetColor:I,measureBarWidthFactor:Y,qualitativeRangeColors:ce,animate:xe,dimmedOpacity:ge,precision:he,naLabel:R}):i.jsxRuntimeExports.jsx(Xe,{data:s,graphTitle:y,barColor:J,barPadding:K,showTicks:Q,leftMargin:re,rightMargin:Z,topMargin:ye,bottomMargin:de,truncateBy:ee,showLabels:te,showValues:be,backgroundColor:E,suffix:ie,prefix:o,sources:S,graphDescription:V,height:T,width:h,footNote:D,colorDomain:b,colorLegendTitle:B,padding:ae,relativeHeight:F,tooltip:q,onSeriesMouseOver:me,refValues:A,showColorScale:z,graphID:ne,maxValue:le,minValue:O,highlightedDataPoints:g,onSeriesMouseClick:M,graphDownload:se,dataDownload:U,language:L,theme:u,sortData:l,labelOrder:N,minHeight:H,maxBarThickness:$,maxNumberOfBars:P,minBarThickness:p,ariaLabel:d,resetSelectionOnDoubleClick:oe,styles:f,detailsOnClick:G,barAxisTitle:k,noOfTicks:W,valueColor:ue,classNames:w,filterNA:x,targetStyle:X,targetColor:I,measureBarWidthFactor:Y,qualitativeRangeColors:ce,animate:xe,dimmedOpacity:ge,precision:he,naLabel:R})}exports.BulletChart=Je;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),j=require("react"),Ne=require("./index-CQ3e6Ewi.cjs"),ke=require("./index-DQA8q5sC.cjs"),Ce=require("./Modal-tXZlLE5s.cjs"),Re=require("./index-CSNtgibC.cjs"),Me=require("./numberFormattingFunction-02t-wJta.cjs"),Ee=require("./Tooltip-De16GWhY.cjs"),c=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Oe=require("./string2HTML-z7CwHXcx.cjs"),Ue=require("./XTicksAndGridLines-CCzXIV8d.cjs"),He=require("./YAxesLabels-yRFFdx1s.cjs"),Ie=require("./AxisTitle-CK9YeovX.cjs"),Ve=require("./Axis-DE7dSn1_.cjs"),ze=require("./ReferenceLine-CFVBBN__.cjs"),Te=require("./linear-BVckp9RD.cjs"),qe=require("./band-CAApY4Pd.cjs"),Ae=require("./use-in-view-sQJZ_xDO.cjs"),_=require("./proxy-BHRoeZgd.cjs"),Le=require("./index-BW8iNx7E.cjs"),$e=require("./GraphFooter.cjs"),Se=require("./GraphHeader.cjs"),ve=require("./Colors.cjs"),De=require("./EmptyState-d8_8SxeW.cjs"),Be=require("./ColorLegend.cjs"),Pe=require("./XAxesLabels-Drf7M3YK.cjs"),Ge=require("./YTicksAndGridLines-DBDuz6vb.cjs");function We(we){const{data:s,barColor:y,suffix:J,prefix:K,barPadding:Q,showValues:re,showTicks:Z,leftMargin:ye,truncateBy:de,width:ee,height:te,rightMargin:be,topMargin:E,bottomMargin:ie,showLabels:o,tooltip:S,onSeriesMouseOver:V,refValues:T,highlightedDataPoints:h,maxValue:D,minValue:b,onSeriesMouseClick:B,labelOrder:ae,rtl:F,maxBarThickness:q,minBarThickness:me,resetSelectionOnDoubleClick:A,detailsOnClick:z,barAxisTitle:ne,valueColor:le,noOfTicks:O,styles:g,classNames:M,targetStyle:se,targetColor:U,qualitativeRangeColors:L,measureBarWidthFactor:u,animate:l,dimmedOpacity:N,precision:H,customLayers:$,naLabel:P}=we,p=j.useRef(null),d=Ae.useInView(p,{once:l.once,amount:l.amount}),[oe,G]=j.useState(void 0),[k,W]=j.useState(void 0),[ue,C]=j.useState(void 0),[f,w]=j.useState(void 0),x={top:ne?E+25:E,bottom:ie,left:ye,right:be},X=ee-x.left-x.right,I=te-x.top-x.bottom,ce=Math.max(...s.filter(e=>!c.checkIfNullOrUndefined(e.size)).map(e=>e.size))<0?0:Math.max(...s.filter(e=>!c.checkIfNullOrUndefined(e.size)).map(e=>e.size)),Y=Math.max(...s.filter(e=>!c.checkIfNullOrUndefined(e.target)).map(e=>e.target))<0?0:Math.max(...s.filter(e=>!c.checkIfNullOrUndefined(e.target)).map(e=>e.target)),xe=Math.max(...s.map(e=>Re.sum((e.qualitativeRange||[]).filter(r=>!c.checkIfNullOrUndefined(r)))||0)),ge=c.checkIfNullOrUndefined(D)?Math.max(...[ce,Y,xe].filter(Number.isFinite))<0?0:Math.max(...[ce,Y,xe].filter(Number.isFinite)):D,he=Math.min(...s.filter(e=>!c.checkIfNullOrUndefined(e.size)).map(e=>e.size))>=0?0:Math.min(...s.filter(e=>!c.checkIfNullOrUndefined(e.size)).map(e=>e.size)),R=Math.min(...s.filter(e=>!c.checkIfNullOrUndefined(e.target)).map(e=>e.target))>=0?0:Math.min(...s.filter(e=>!c.checkIfNullOrUndefined(e.target)).map(e=>e.target)),a=c.checkIfNullOrUndefined(b)?Math.min(...[he,R].filter(Number.isFinite))>=0?0:Math.min(...[he,R].filter(Number.isFinite)):b,fe=s.map((e,r)=>({...e,id:ae?`${e.label}`:`${r}`})),n=Te.linear().domain([a,ge]).range([0,X]).nice(),v=ae||fe.map(e=>`${e.id}`),m=qe.band().domain(v).range([0,me?Math.max(I,me*v.length):q?Math.min(I,q*v.length):I]).paddingInner(Q),t=n.ticks(O);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(_.motion.svg,{width:`${ee}px`,height:`${te}px`,viewBox:`0 0 ${ee} ${te}`,direction:"ltr",ref:p,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${x.left},${x.top})`,children:[Z?i.jsxRuntimeExports.jsx(Ue.XTicksAndGridLines,{values:t.filter(e=>e!==0),x:t.filter(e=>e!==0).map(e=>n(e)),y1:0-E,y2:I+x.bottom,styles:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},classNames:{gridLines:M?.xAxis?.gridLines,labels:M?.xAxis?.labels},suffix:J,prefix:K,labelType:"secondary",showGridLines:!0,precision:H}):null,i.jsxRuntimeExports.jsx(Ie.AxisTitle,{x:X/2,y:0-x.top+15,style:g?.xAxis?.title,className:M?.xAxis?.title,text:ne}),i.jsxRuntimeExports.jsx(Ve.Axis,{x1:n(a<0?0:a),x2:n(a<0?0:a),y1:-2.5,y2:I+x.bottom,classNames:{axis:M?.yAxis?.axis},styles:{axis:g?.yAxis?.axis}}),$.filter(e=>e.position==="before").map(e=>e.layer),i.jsxRuntimeExports.jsxs(Le.AnimatePresence,{children:[fe.map(e=>c.checkIfNullOrUndefined(m(e.id))?null:i.jsxRuntimeExports.jsxs(_.motion.g,{className:"undp-viz-g-with-hover",onMouseEnter:r=>{G(e),w(r.clientY),C(r.clientX),V?.(e)},onClick:()=>{(B||z)&&(ke.isEqual(k,e)&&A?(W(void 0),B?.(void 0)):(W(e),B?.(e)))},onMouseMove:r=>{G(e),w(r.clientY),C(r.clientX)},onMouseLeave:()=>{G(void 0),C(void 0),w(void 0),V?.(void 0)},exit:{opacity:0,transition:{duration:l.duration}},variants:{initial:{x:0,y:m(`${e.id}`),opacity:h.length!==0?h.indexOf(e.label)!==-1?.85:N:.85},whileInView:{x:0,y:m(`${e.id}`),opacity:h.length!==0?h.indexOf(e.label)!==-1?.85:N:.85,transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial",children:[e.qualitativeRange?e.qualitativeRange.map((r,pe)=>i.jsxRuntimeExports.jsx(_.motion.rect,{exit:{width:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),width:0,fill:L[pe]},whileInView:{x:n(pe===0?0:Re.sum(e.qualitativeRange.filter((je,Fe)=>Fe<pe&&je))),width:n(r),fill:L[pe],transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial",y:0,height:m.bandwidth()},pe)):null,e.target&&se==="background"?i.jsxRuntimeExports.jsx(_.motion.rect,{y:0,x:e.target>=0?n(0):n(e.target),height:m.bandwidth(),style:{fill:U},exit:{width:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),width:0},whileInView:{x:e.target>=0?n(0):n(e.target),width:e.target>=0?n(e.target)-n(0):n(0)-n(e.target),transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial"}):null,e.size?i.jsxRuntimeExports.jsx(_.motion.rect,{y:m.bandwidth()*((1-u)/2),style:{fill:y},height:m.bandwidth()*u,exit:{width:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),width:0},whileInView:{x:e.size>=0?n(0):n(e.size),width:e.size>=0?n(e.size)-n(0):n(0)-n(e.size),transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial"}):null,e.target&&se==="line"?i.jsxRuntimeExports.jsx(_.motion.rect,{y:0,height:m.bandwidth(),style:{fill:U},width:2,exit:{opacity:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),opacity:0},whileInView:{x:n(e.target)-1,opacity:1,transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial"}):null,o?i.jsxRuntimeExports.jsx(He.YAxesLabels,{value:`${e.label}`.length<de?`${e.label}`:`${`${e.label}`.substring(0,de)}...`,y:0,x:(e.size||0)<0?n(0):0-x.left,width:(e.size||0)<0?ee-n(0):n(0)+x.left,height:m.bandwidth(),alignment:e.size&&e.size<0?"left":"right",style:g?.yAxis?.labels,className:M?.yAxis?.labels,animate:l,isInView:d}):null,re?i.jsxRuntimeExports.jsx(_.motion.text,{y:m.bandwidth()/2,style:{...le?{fill:le}:{fill:y},textAnchor:e.size&&e.size<0?"end":"start",...g?.graphObjectValues||{}},className:i.mo("graph-value text-sm",!le&&y.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",M?.graphObjectValues),dx:e.size&&e.size<0?-5:5,dy:"0.33em",exit:{opacity:0,transition:{duration:l.duration}},variants:{initial:{x:n(0),opacity:0},whileInView:{x:e.size?n(e.size):n(0),opacity:1,transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial",children:Me.numberFormattingFunction(e.size,P,H,K,J)}):null]},e.label)),T?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:T.map((e,r)=>i.jsxRuntimeExports.jsx(ze.RefLineX,{text:e.text,color:e.color,x:n(e.value),y1:0-x.top,y2:I+x.bottom,textSide:n(e.value)>X*.75||F?"left":"right",classNames:e.classNames,styles:e.styles,animate:l,isInView:d},r))}):null]}),$.filter(e=>e.position==="after").map(e=>e.layer)]})}),oe&&S&&ue&&f?i.jsxRuntimeExports.jsx(Ee.Tooltip,{data:oe,body:S,xPos:ue,yPos:f,backgroundStyle:g?.tooltip,className:M?.tooltip}):null,z&&k!==void 0?i.jsxRuntimeExports.jsx(Ce.X,{open:k!==void 0,onClose:()=>{W(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof z=="string"?{__html:Oe.string2HTML(z,k)}:void 0,children:typeof z=="function"?z(k):null})}):null]})}function Xe(we){const{data:s,graphTitle:y,barColor:J=ve.Colors.primaryColors["blue-600"],suffix:K="",sources:Q,prefix:re="",graphDescription:Z,barPadding:ye=.25,showValues:de=!0,showTicks:ee=!0,leftMargin:te=100,rightMargin:be=40,truncateBy:E=999,height:ie,width:o,footNote:S,colorDomain:V,colorLegendTitle:T,highlightedDataPoints:h=[],padding:D,backgroundColor:b=!1,topMargin:B=25,bottomMargin:ae=10,showLabels:F=!0,relativeHeight:q,tooltip:me,onSeriesMouseOver:A,refValues:z,showColorScale:ne=!0,graphID:le,maxValue:O,minValue:g,onSeriesMouseClick:M,graphDownload:se=!1,dataDownload:U=!1,sortData:L,labelOrder:u,language:l="en",minHeight:N=0,theme:H="light",maxBarThickness:$,maxNumberOfBars:P,minBarThickness:p,ariaLabel:d,resetSelectionOnDoubleClick:oe=!0,detailsOnClick:G,barAxisTitle:k,noOfTicks:W=5,valueColor:ue,styles:C,classNames:f,filterNA:w=!0,targetStyle:x="line",targetColor:X=ve.Colors.light.grays["gray-700"],qualitativeRangeColors:I,measureBarWidthFactor:ce=.4,animate:Y=!1,dimmedOpacity:xe=.3,precision:ge=2,customLayers:he=[],naLabel:R="NA"}=we,[a,fe]=j.useState(0),[n,v]=j.useState(0),m=j.useRef(null),t=j.useRef(null);return j.useEffect(()=>{const e=new ResizeObserver(r=>{fe(o||r[0].target.clientWidth||620),v(ie||r[0].target.clientHeight||480)});return m.current&&(v(m.current.clientHeight||480),fe(m.current.clientWidth||620),o||e.observe(m.current)),()=>e.disconnect()},[o,ie]),i.jsxRuntimeExports.jsx("div",{className:`${H||"light"} flex ${o?"w-fit grow-0":"w-full grow"}`,dir:l==="he"||l==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${b?b===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${l||"en"}`,o?"w-fit":"w-full",f?.graphContainer),style:{...C?.graphContainer||{},...b&&b!==!0?{backgroundColor:b}:{}},id:le,ref:t,"aria-label":d||`${y?`The graph shows ${y}. `:""}This is a bar chart. ${Z?` ${Z}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:b?D||"1rem":D||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[y||Z||se||U?i.jsxRuntimeExports.jsx(Se.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:f?.title,description:f?.description},graphTitle:y,graphDescription:Z,width:o,graphDownload:se?t.current:void 0,dataDownload:U?s.map(e=>e.data).filter(e=>e!==void 0).length>0?s.map(e=>e.data).filter(e=>e!==void 0):s.filter(e=>e!==void 0):null}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:s.length===0?i.jsxRuntimeExports.jsx(De.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[ne&&s.filter(e=>e.qualitativeRange).length!==0&&V?i.jsxRuntimeExports.jsx(Be.ColorLegend,{width:o,colorLegendTitle:T,colors:I||ve.Colors[H].sequentialColors.positiveColorsx10,colorDomain:V,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:m,"aria-label":"Graph area",children:(o||a)&&(ie||n)?i.jsxRuntimeExports.jsx(We,{data:L?Ne.orderBy(s.filter(e=>w?!c.checkIfNullOrUndefined(e.size):e),[e=>e.size===void 0?L==="asc"?-1/0:1/0:e.size],[L]).filter((e,r)=>P?r<P:!0):s.filter(e=>w?!c.checkIfNullOrUndefined(e.size):e).filter((e,r)=>P?r<P:!0),barColor:J,targetColor:X,width:o||a,height:Math.max(N,ie||(q?N?(o||a)*q>N?(o||a)*q:N:(o||a)*q:n)),suffix:K,prefix:re,barPadding:ye,showValues:de,showTicks:ee,leftMargin:te,rightMargin:be,topMargin:B,bottomMargin:ae,truncateBy:E,showLabels:F,tooltip:me,onSeriesMouseOver:A,refValues:z,maxValue:O,minValue:g,highlightedDataPoints:h,onSeriesMouseClick:M,labelOrder:u,rtl:l==="he"||l==="ar",maxBarThickness:$,minBarThickness:p,resetSelectionOnDoubleClick:oe,detailsOnClick:G,barAxisTitle:k,noOfTicks:W,valueColor:ue,classNames:f,styles:C,targetStyle:x,qualitativeRangeColors:I||ve.Colors[H].sequentialColors.positiveColorsx10,measureBarWidthFactor:ce,animate:Y===!0?{duration:.5,once:!0,amount:.5}:Y||{duration:0,once:!0,amount:0},dimmedOpacity:xe,precision:ge,customLayers:he,naLabel:R}):null})]})}),Q||S?i.jsxRuntimeExports.jsx($e.GraphFooter,{sources:Q,footNote:S,width:o,styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:f?.footnote,source:f?.source}}):null]})})})})}function Ye(we){const{data:s,width:y,height:J,barColor:K,suffix:Q,prefix:re,barPadding:Z,showLabels:ye,showValues:de,showTicks:ee,truncateBy:te,rightMargin:be,topMargin:E,bottomMargin:ie,leftMargin:o,tooltip:S,onSeriesMouseOver:V,refValues:T,maxValue:h,minValue:D,highlightedDataPoints:b,onSeriesMouseClick:B,labelOrder:ae,maxBarThickness:F,minBarThickness:q,resetSelectionOnDoubleClick:me,detailsOnClick:A,barAxisTitle:z,valueColor:ne,noOfTicks:le,styles:O,classNames:g,targetStyle:M,targetColor:se,qualitativeRangeColors:U,measureBarWidthFactor:L,animate:u,dimmedOpacity:l,precision:N,customLayers:H,naLabel:$}=we,P=j.useRef(null),p=Ae.useInView(P,{once:u.once,amount:u.amount}),d={top:E,bottom:ie,left:z?o+30:o,right:be},[oe,G]=j.useState(void 0),[k,W]=j.useState(void 0),[ue,C]=j.useState(void 0),[f,w]=j.useState(void 0),x=y-d.left-d.right,X=J-d.top-d.bottom,I=Math.max(...s.filter(t=>!c.checkIfNullOrUndefined(t.size)).map(t=>t.size))<0?0:Math.max(...s.filter(t=>!c.checkIfNullOrUndefined(t.size)).map(t=>t.size)),ce=Math.max(...s.filter(t=>!c.checkIfNullOrUndefined(t.target)).map(t=>t.target))<0?0:Math.max(...s.filter(t=>!c.checkIfNullOrUndefined(t.size)).map(t=>t.target)),Y=Math.max(...s.map(t=>Re.sum((t.qualitativeRange||[]).filter(e=>!c.checkIfNullOrUndefined(e)))||0)),xe=c.checkIfNullOrUndefined(h)?Math.max(...[I,ce,Y].filter(Number.isFinite))<0?0:Math.max(...[I,ce,Y].filter(Number.isFinite)):h,ge=Math.min(...s.filter(t=>!c.checkIfNullOrUndefined(t.size)).map(t=>t.size))>=0?0:Math.min(...s.filter(t=>!c.checkIfNullOrUndefined(t.size)).map(t=>t.size)),he=Math.min(...s.filter(t=>!c.checkIfNullOrUndefined(t.target)).map(t=>t.target))>=0?0:Math.min(...s.filter(t=>!c.checkIfNullOrUndefined(t.target)).map(t=>t.target)),R=c.checkIfNullOrUndefined(D)?Math.min(...[ge,he].filter(Number.isFinite))>=0?0:Math.min(...[ge,he].filter(Number.isFinite)):D,a=Te.linear().domain([R,xe]).range([X,0]).nice(),fe=s.map((t,e)=>({...t,id:ae?`${t.label}`:`${e}`})),n=ae||fe.map(t=>`${t.id}`),v=qe.band().domain(n).range([0,q?Math.max(x,q*n.length):F?Math.min(x,F*n.length):x]).paddingInner(Z),m=a.ticks(le);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(_.motion.svg,{width:`${y}px`,height:`${J}px`,viewBox:`0 0 ${y} ${J}`,direction:"ltr",ref:P,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[i.jsxRuntimeExports.jsx(Ve.Axis,{y1:a(R<0?0:R),y2:a(R<0?0:R),x1:0-o,x2:x+d.right,label:Me.numberFormattingFunction(R<0?0:R,$,N,re,Q),labelPos:{x:0-o,dx:0,dy:xe<0?"1em":-5,y:a(R<0?0:R)},classNames:{axis:g?.xAxis?.axis,label:g?.yAxis?.labels},styles:{axis:O?.xAxis?.axis,label:O?.yAxis?.labels}}),ee?i.jsxRuntimeExports.jsx(Ge.YTicksAndGridLines,{values:m.filter(t=>t!==0),y:m.filter(t=>t!==0).map(t=>a(t)),x1:0-o,x2:x+d.right,styles:{gridLines:O?.yAxis?.gridLines,labels:O?.yAxis?.labels},classNames:{gridLines:g?.yAxis?.gridLines,labels:g?.yAxis?.labels},suffix:Q,prefix:re,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:N}):null,i.jsxRuntimeExports.jsx(Ie.AxisTitle,{x:0-o-15,y:X/2,style:O?.yAxis?.title,className:g?.yAxis?.title,text:z,rotate90:!0}),H.filter(t=>t.position==="before").map(t=>t.layer),i.jsxRuntimeExports.jsxs(Le.AnimatePresence,{children:[fe.map(t=>c.checkIfNullOrUndefined(v(t.id))?null:i.jsxRuntimeExports.jsxs(_.motion.g,{className:"undp-viz-g-with-hover",onMouseEnter:e=>{G(t),w(e.clientY),C(e.clientX),V?.(t)},onClick:()=>{(B||A)&&(ke.isEqual(k,t)&&me?(W(void 0),B?.(void 0)):(W(t),B?.(t)))},onMouseMove:e=>{G(t),w(e.clientY),C(e.clientX)},onMouseLeave:()=>{G(void 0),C(void 0),w(void 0),V?.(void 0)},exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{x:v(`${t.id}`),y:0,opacity:b.length!==0?b.indexOf(t.label)!==-1?.85:l:.85},whileInView:{x:v(`${t.id}`),y:0,opacity:b.length!==0?b.indexOf(t.label)!==-1?.85:l:.85,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",children:[t.qualitativeRange?t.qualitativeRange.map((e,r)=>i.jsxRuntimeExports.jsx(_.motion.rect,{x:0,exit:{height:0,y:a(0),transition:{duration:u.duration}},variants:{initial:{height:0,y:a(0),fill:U[r]},whileInView:{height:Math.abs(a(Re.sum(t.qualitativeRange.filter((pe,je)=>je<=r&&pe)))-a(Re.sum(t.qualitativeRange.filter((pe,je)=>je<r&&pe)))),y:a(Re.sum(t.qualitativeRange.filter((pe,je)=>je<=r&&pe))),fill:U[r],transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",width:v.bandwidth()},r)):null,t.target&&M==="background"?i.jsxRuntimeExports.jsx(_.motion.rect,{x:0,width:v.bandwidth(),style:{fill:se},exit:{height:0,y:a(0),transition:{duration:u.duration}},variants:{initial:{height:0,y:a(0)},whileInView:{height:Math.abs(a(t.target)-a(0)),y:t.target>0?a(t.target):a(0),transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial"}):null,t.size?i.jsxRuntimeExports.jsx(_.motion.rect,{x:v.bandwidth()*((1-L)/2),width:v.bandwidth()*L,style:{fill:K},exit:{height:0,y:a(0),transition:{duration:u.duration}},variants:{initial:{height:0,y:a(0)},whileInView:{height:Math.abs(a(t.size)-a(0)),y:t.size>0?a(t.size):a(0),transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial"}):null,t.target&&M==="line"?i.jsxRuntimeExports.jsx(_.motion.rect,{x:0,width:v.bandwidth(),style:{fill:se},exit:{y:a(0),opacity:0,transition:{duration:u.duration}},variants:{initial:{y:a(0),opacity:0},whileInView:{y:a(t.target)-1,opacity:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",height:2}):null,ye?i.jsxRuntimeExports.jsx(Pe.XAxesLabels,{value:`${t.label}`.length<te?`${t.label}`:`${`${t.label}`.substring(0,te)}...`,y:(t.size||0)<0?0:a(0)+5,x:0,width:v.bandwidth(),height:(t.size||0)<0?a(0)-5:d.bottom,style:O?.xAxis?.labels,className:g?.xAxis?.labels,alignment:(t.size||0)<0?"bottom":"top",animate:u,isInView:p}):null,de?i.jsxRuntimeExports.jsx(_.motion.text,{x:v.bandwidth()/2,style:{...ne?{fill:ne}:{fill:K},textAnchor:"middle",...O?.graphObjectValues||{}},className:i.mo("graph-value text-sm",!ne&&K.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",g?.graphObjectValues),dy:t.size?t.size>=0?"-5px":"1em":"-5px",exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{y:a(0),opacity:0},whileInView:{y:a(t.size||0),opacity:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",children:Me.numberFormattingFunction(t.size,$,N,re,Q)}):null]},t.label)),T?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:T.map((t,e)=>i.jsxRuntimeExports.jsx(ze.RefLineY,{text:t.text,color:t.color,y:a(t.value),x1:0-o,x2:x+d.right,classNames:t.classNames,styles:t.styles,animate:u,isInView:p},e))}):null]}),H.filter(t=>t.position==="after").map(t=>t.layer)]})}),oe&&S&&ue&&f?i.jsxRuntimeExports.jsx(Ee.Tooltip,{data:oe,body:S,xPos:ue,yPos:f,backgroundStyle:O?.tooltip,className:g?.tooltip}):null,A&&k!==void 0?i.jsxRuntimeExports.jsx(Ce.X,{open:k!==void 0,onClose:()=>{W(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof A=="string"?{__html:Oe.string2HTML(A,k)}:void 0,children:typeof A=="function"?A(k):null})}):null]})}function _e(we){const{data:s,graphTitle:y,barColor:J=ve.Colors.primaryColors["blue-600"],barPadding:K=.25,showTicks:Q=!0,leftMargin:re=20,rightMargin:Z=20,topMargin:ye=20,bottomMargin:de=25,truncateBy:ee=999,showLabels:te=!0,showValues:be=!0,backgroundColor:E=!1,suffix:ie="",prefix:o="",sources:S,graphDescription:V,height:T,width:h,footNote:D,colorDomain:b,colorLegendTitle:B,padding:ae,relativeHeight:F,tooltip:q,onSeriesMouseOver:me,refValues:A,showColorScale:z=!0,graphID:ne,maxValue:le,minValue:O,highlightedDataPoints:g=[],qualitativeRangeColors:M,onSeriesMouseClick:se,graphDownload:U=!1,dataDownload:L=!1,language:u="en",theme:l="light",sortData:N,labelOrder:H,minHeight:$=0,maxBarThickness:P,maxNumberOfBars:p,minBarThickness:d,ariaLabel:oe,resetSelectionOnDoubleClick:G=!0,detailsOnClick:k,barAxisTitle:W,noOfTicks:ue=5,valueColor:C,styles:f,classNames:w,targetColor:x=ve.Colors.light.grays["gray-700"],filterNA:X=!0,targetStyle:I="line",measureBarWidthFactor:ce=.4,animate:Y=!1,dimmedOpacity:xe=.3,precision:ge=2,customLayers:he=[],naLabel:R="NA"}=we,[a,fe]=j.useState(0),[n,v]=j.useState(0),m=j.useRef(null),t=j.useRef(null);return j.useEffect(()=>{const e=new ResizeObserver(r=>{fe(h||r[0].target.clientWidth||620),v(T||r[0].target.clientHeight||480)});return m.current&&(v(m.current.clientHeight||480),fe(m.current.clientWidth||620),h||e.observe(m.current)),()=>e.disconnect()},[h,T]),i.jsxRuntimeExports.jsx("div",{className:`${l||"light"} flex ${h?"w-fit grow-0":"w-full grow"}`,dir:u==="he"||u==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.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 ${u||"en"}`,h?"w-fit":"w-full",w?.graphContainer),style:{...f?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:ne,ref:t,"aria-label":oe||`${y?`The graph shows ${y}. `:""}This is a grouped bar chart. ${V?` ${V}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?ae||"1rem":ae||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[y||V||U||L?i.jsxRuntimeExports.jsx(Se.GraphHeader,{styles:{title:f?.title,description:f?.description},classNames:{title:w?.title,description:w?.description},graphTitle:y,graphDescription:V,width:h,graphDownload:U?t.current:void 0,dataDownload:L?s.map(e=>e.data).filter(e=>e!==void 0).length>0?s.map(e=>e.data).filter(e=>e!==void 0):s.filter(e=>e!==void 0):null}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:s.length===0?i.jsxRuntimeExports.jsx(De.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[z&&s.filter(e=>e.qualitativeRange).length!==0&&b?i.jsxRuntimeExports.jsx(Be.ColorLegend,{width:h,colorLegendTitle:B,colors:M||ve.Colors[l].sequentialColors.positiveColorsx10,colorDomain:b,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:m,"aria-label":"Graph area",children:(h||a)&&(T||n)?i.jsxRuntimeExports.jsx(Ye,{data:N?Ne.orderBy(s.filter(e=>X?!c.checkIfNullOrUndefined(e.size):e),[e=>e.size===void 0?N==="asc"?-1/0:1/0:e.size],[N]).filter((e,r)=>p?r<p:!0):s.filter(e=>X?!c.checkIfNullOrUndefined(e.size):e).filter((e,r)=>p?r<p:!0),barColor:J,targetColor:x,width:h||a,refValues:A,height:Math.max($,T||(F?$?(h||a)*F>$?(h||a)*F:$:(h||a)*F:n)),suffix:ie,prefix:o,barPadding:K,showLabels:te,showValues:be,showTicks:Q,truncateBy:ee,leftMargin:re,rightMargin:Z,qualitativeRangeColors:M||ve.Colors[l].sequentialColors.positiveColorsx10,topMargin:ye,bottomMargin:de,tooltip:q,onSeriesMouseOver:me,maxValue:le,minValue:O,highlightedDataPoints:g,onSeriesMouseClick:se,labelOrder:H,maxBarThickness:P,minBarThickness:d,resetSelectionOnDoubleClick:G,detailsOnClick:k,barAxisTitle:W,noOfTicks:ue,valueColor:C,styles:f,classNames:w,targetStyle:I,dimmedOpacity:xe,measureBarWidthFactor:ce,animate:Y===!0?{duration:.5,once:!0,amount:.5}:Y||{duration:0,once:!0,amount:0},precision:ge,customLayers:he,naLabel:R}):null})]})}),S||D?i.jsxRuntimeExports.jsx($e.GraphFooter,{styles:{footnote:f?.footnote,source:f?.source},classNames:{footnote:w?.footnote,source:w?.source},sources:S,footNote:D,width:h}):null]})})})})}function Je(we){const{data:s,graphTitle:y,barColor:J,barPadding:K,showTicks:Q,leftMargin:re,rightMargin:Z,topMargin:ye,bottomMargin:de,truncateBy:ee,showLabels:te,showValues:be,backgroundColor:E,suffix:ie,prefix:o,sources:S,graphDescription:V,height:T,width:h,footNote:D,colorDomain:b,colorLegendTitle:B,padding:ae,relativeHeight:F,tooltip:q,onSeriesMouseOver:me,refValues:A,showColorScale:z,graphID:ne,maxValue:le,minValue:O,highlightedDataPoints:g,onSeriesMouseClick:M,graphDownload:se,dataDownload:U,language:L,theme:u,sortData:l,labelOrder:N,minHeight:H,maxBarThickness:$,maxNumberOfBars:P,minBarThickness:p,ariaLabel:d,resetSelectionOnDoubleClick:oe,detailsOnClick:G,barAxisTitle:k,noOfTicks:W,valueColor:ue,orientation:C="vertical",styles:f,classNames:w,filterNA:x,targetStyle:X,targetColor:I,qualitativeRangeColors:ce,measureBarWidthFactor:Y,animate:xe,dimmedOpacity:ge,precision:he,naLabel:R}=we;return C==="vertical"?i.jsxRuntimeExports.jsx(_e,{data:s,graphTitle:y,barColor:J,barPadding:K,showTicks:Q,leftMargin:re,rightMargin:Z,topMargin:ye,bottomMargin:de,truncateBy:ee,showLabels:te,showValues:be,backgroundColor:E,suffix:ie,prefix:o,sources:S,graphDescription:V,height:T,width:h,footNote:D,colorDomain:b,colorLegendTitle:B,padding:ae,relativeHeight:F,tooltip:q,onSeriesMouseOver:me,refValues:A,showColorScale:z,graphID:ne,maxValue:le,minValue:O,highlightedDataPoints:g,onSeriesMouseClick:M,graphDownload:se,dataDownload:U,language:L,theme:u,sortData:l,labelOrder:N,minHeight:H,maxBarThickness:$,maxNumberOfBars:P,minBarThickness:p,ariaLabel:d,resetSelectionOnDoubleClick:oe,styles:f,detailsOnClick:G,barAxisTitle:k,noOfTicks:W,valueColor:ue,classNames:w,filterNA:x,targetStyle:X,targetColor:I,measureBarWidthFactor:Y,qualitativeRangeColors:ce,animate:xe,dimmedOpacity:ge,precision:he,naLabel:R}):i.jsxRuntimeExports.jsx(Xe,{data:s,graphTitle:y,barColor:J,barPadding:K,showTicks:Q,leftMargin:re,rightMargin:Z,topMargin:ye,bottomMargin:de,truncateBy:ee,showLabels:te,showValues:be,backgroundColor:E,suffix:ie,prefix:o,sources:S,graphDescription:V,height:T,width:h,footNote:D,colorDomain:b,colorLegendTitle:B,padding:ae,relativeHeight:F,tooltip:q,onSeriesMouseOver:me,refValues:A,showColorScale:z,graphID:ne,maxValue:le,minValue:O,highlightedDataPoints:g,onSeriesMouseClick:M,graphDownload:se,dataDownload:U,language:L,theme:u,sortData:l,labelOrder:N,minHeight:H,maxBarThickness:$,maxNumberOfBars:P,minBarThickness:p,ariaLabel:d,resetSelectionOnDoubleClick:oe,styles:f,detailsOnClick:G,barAxisTitle:k,noOfTicks:W,valueColor:ue,classNames:w,filterNA:x,targetStyle:X,targetColor:I,measureBarWidthFactor:Y,qualitativeRangeColors:ce,animate:xe,dimmedOpacity:ge,precision:he,naLabel:R})}exports.BulletChart=Je;
2
2
  //# sourceMappingURL=BulletChart.cjs.map
@@ -9,7 +9,7 @@ import { T as $i } from "./Tooltip-CVCGWyzw.js";
9
9
  import { c } from "./checkIfNullOrUndefined-DmfiKkNw.js";
10
10
  import { s as Ai } from "./string2HTML-oFCROsus.js";
11
11
  import { X as Xi } from "./XTicksAndGridLines-Bn9u5gOM.js";
12
- import { Y as Yi } from "./YAxesLabels-DSm6I5zG.js";
12
+ import { Y as Yi } from "./YAxesLabels-DECkMgq8.js";
13
13
  import { A as Di } from "./AxisTitle-BmHLMRJZ.js";
14
14
  import { A as Li } from "./Axis-Ddg-seDi.js";
15
15
  import { a as Ei, R as Gi } from "./ReferenceLine-CfAW3vKJ.js";
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),y=require("react"),pe=require("./getSliderMarks-CRIbTGYV.cjs"),fe=require("./parse-hMnG_lRV.cjs"),ye=require("./index-DQA8q5sC.cjs"),Me=require("./Modal-tXZlLE5s.cjs"),je=require("./numberFormattingFunction-02t-wJta.cjs"),Ae=require("./Tooltip-De16GWhY.cjs"),Ce=require("./string2HTML-z7CwHXcx.cjs"),be=require("./XTicksAndGridLines-CCzXIV8d.cjs"),ve=require("./Axis-DE7dSn1_.cjs"),Le=require("./YAxesLabels-CctDydGR.cjs"),we=require("./ReferenceLine-CFVBBN__.cjs"),ke=require("./band-CAApY4Pd.cjs"),Re=require("./linear-BVckp9RD.cjs"),Ne=require("./use-in-view-sQJZ_xDO.cjs"),T=require("./proxy-BHRoeZgd.cjs"),me=require("./index-BW8iNx7E.cjs"),$e=require("./GraphFooter.cjs"),qe=require("./GraphHeader.cjs"),Ve=require("./ColorLegend.cjs"),Ee=require("./Colors.cjs"),Se=require("./EmptyState-d8_8SxeW.cjs"),Be=require("./index-BW_-wD2k.cjs"),de=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Te=require("./ensureCompleteData-DkQYPeDa.cjs"),Oe=require("./uniqBy-O05lp2S5.cjs"),Ie=require("./sort-O96oMZLb.cjs"),De=require("./init-DU0ybBc_.cjs");function Fe(W){const{data:x,width:j,height:R,barColors:u,centerGap:d,refValues:a,maxValue:E,minValue:U,showValues:z,axisTitles:B,rightMargin:ne,leftMargin:oe,topMargin:_,bottomMargin:le,tooltip:J,onSeriesMouseOver:O,barPadding:xe,truncateBy:I,onSeriesMouseClick:k,showTicks:te,suffix:G,prefix:H,resetSelectionOnDoubleClick:ie,detailsOnClick:M,styles:h,classNames:n,noOfTicks:A,animate:m,precision:P,customLayers:se,minValueLeftBar:N,minValueRightBar:$,naLabel:K}=W,Q=y.useRef(null),b=Ne.useInView(Q,{once:m.once,amount:m.amount}),[re,v]=y.useState(void 0),[q,D]=y.useState(void 0),[ae,V]=y.useState(void 0),[C,p]=y.useState(void 0),c={top:_,bottom:le,left:oe,right:ne},L=j-c.left-c.right,w=R-c.top-c.bottom,X=x.map((e,r)=>({...e,id:`${r}`})),s=ke.band().domain(X.map(e=>`${e.id}`)).range([w,0]).paddingInner(xe),l=Re.linear().domain([U,E]).range([0,(L-d)/2]).nice(),S=l.ticks(A),o=Re.linear().domain([U,E]).range([(L-d)/2,0]).nice(),Z=o.ticks(A);return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(T.motion.svg,{width:`${j}px`,height:`${R}px`,viewBox:`0 0 ${j} ${R}`,direction:"ltr",ref:Q,children:t.jsxRuntimeExports.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[se.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs("g",{transform:"translate(0,0)",children:[te?t.jsxRuntimeExports.jsx(be.XTicksAndGridLines,{values:Z.filter(e=>e!==0),x:Z.filter(e=>e!==0).map(e=>o(e)),y1:0-_,y2:w+c.bottom,styles:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},classNames:{gridLines:n?.xAxis?.gridLines,labels:n?.xAxis?.labels},suffix:G,prefix:H,labelType:"secondary",showGridLines:!0,leftLabel:!0,precision:P}):null,t.jsxRuntimeExports.jsxs(me.AnimatePresence,{children:[X.map((e,r)=>t.jsxRuntimeExports.jsxs(T.motion.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:f=>{v(e),p(f.clientY),V(f.clientX),O?.(e)},onClick:()=>{(k||M)&&(ye.isEqual(q,e)&&ie?(D(void 0),k?.(void 0)):(D(e),k?.(e)))},onMouseMove:f=>{v(e),p(f.clientY),V(f.clientX)},onMouseLeave:()=>{v(void 0),V(void 0),p(void 0),O?.(void 0)},children:[e.leftBar?t.jsxRuntimeExports.jsx(T.motion.rect,{y:s(`${r}`),style:{fill:u[0]},height:s.bandwidth(),variants:{initial:{x:o(0),width:0},whileInView:{x:e.leftBar<0?o(0):o(e.leftBar),width:e.leftBar<0?o(e.leftBar)-o(0):o(0)-o(e.leftBar),transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial",exit:{x:o(0),width:0,transition:{duration:m.duration}}}):null,z?t.jsxRuntimeExports.jsx(T.motion.text,{y:s(`${r}`)+s.bandwidth()/2,style:{fill:u[0],textAnchor:e.rightBar&&e.rightBar>0?"end":"start",...h?.graphObjectValues||{}},dx:e.rightBar&&e.rightBar>0?-5:5,dy:"0.33em",className:t.mo("graph-value text-sm",n?.graphObjectValues),exit:{opacity:0,transition:{duration:m.duration}},variants:{initial:{x:o(0),opacity:0},whileInView:{x:e.leftBar?o(e.leftBar):o(N<0?0:N),opacity:1,transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial",children:je.numberFormattingFunction(e.rightBar,K,P,H,G)}):null]},e.label)),t.jsxRuntimeExports.jsx(ve.Axis,{y1:-2.5,y2:w+c.bottom,x1:o(N<0?0:N),x2:o(N<0?0:N),classNames:{axis:n?.yAxis?.axis},styles:{axis:h?.yAxis?.axis}}),a?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:a.map((e,r)=>t.jsxRuntimeExports.jsx(we.RefLineX,{text:e.text,color:e.color,x:o(e.value),y1:0-c.top,y2:w+c.bottom,textSide:"left",classNames:e.classNames,styles:e.styles,animate:m,isInView:b},r))}):null]})]}),t.jsxRuntimeExports.jsxs("g",{transform:`translate(${(L+d)/2},0)`,children:[te?t.jsxRuntimeExports.jsx(be.XTicksAndGridLines,{values:S.filter(e=>e!==0),x:S.filter(e=>e!==0).map(e=>l(e)),y1:0-_,y2:w+c.bottom,styles:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},classNames:{gridLines:n?.xAxis?.gridLines,labels:n?.xAxis?.labels},suffix:G,prefix:H,labelType:"secondary",showGridLines:!0,precision:P}):null,t.jsxRuntimeExports.jsxs(me.AnimatePresence,{children:[X.map((e,r)=>t.jsxRuntimeExports.jsxs(T.motion.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:f=>{v(e),p(f.clientY),V(f.clientX),O?.(e)},onClick:()=>{(k||M)&&(ye.isEqual(q,e)&&ie?(D(void 0),k?.(void 0)):(D(e),k?.(e)))},onMouseMove:f=>{v(e),p(f.clientY),V(f.clientX)},onMouseLeave:()=>{v(void 0),V(void 0),p(void 0),O?.(void 0)},children:[e.rightBar?t.jsxRuntimeExports.jsx(T.motion.rect,{y:s(`${r}`),style:{fill:u[1]},height:s.bandwidth(),exit:{x:l(0),width:0,transition:{duration:m.duration}},variants:{initial:{x:l(0),width:0},whileInView:{x:e.rightBar>=0?l(0):l(e.rightBar),width:e.rightBar>=0?l(e.rightBar)-l(0):l(0)-l(e.rightBar),transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial"}):null,z?t.jsxRuntimeExports.jsx(T.motion.text,{y:s(`${r}`)+s.bandwidth()/2,style:{fill:u[1],textAnchor:e.rightBar&&e.rightBar<0?"end":"start",...h?.graphObjectValues||{}},className:t.mo("graph-value text-sm",n?.graphObjectValues),dx:e.rightBar&&e.rightBar<0?-5:5,dy:"0.33em",exit:{opacity:0,transition:{duration:m.duration}},variants:{initial:{x:l(0),opacity:0},whileInView:{x:e.rightBar?l(e.rightBar):l($<0?0:$),opacity:1,transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial",children:je.numberFormattingFunction(e.rightBar,K,P,H,G)}):null]},r)),t.jsxRuntimeExports.jsx(ve.Axis,{y1:-2.5,y2:w+c.bottom,x1:l($<0?0:$),x2:l($<0?0:$),classNames:{axis:n?.yAxis?.axis},styles:{axis:h?.yAxis?.axis}}),a?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:a.map((e,r)=>t.jsxRuntimeExports.jsx(we.RefLineX,{text:e.text,color:e.color,x:l(e.value),y1:0-c.top,y2:w+c.bottom,textSide:"right",classNames:e.classNames,styles:e.styles,animate:m,isInView:b},r))}):null]})]}),t.jsxRuntimeExports.jsx(me.AnimatePresence,{children:t.jsxRuntimeExports.jsx(T.motion.g,{transform:`translate(${L/2},0)`,children:X.map((e,r)=>t.jsxRuntimeExports.jsx(Le.YAxesLabels,{value:`${e.label}`.length<I?`${e.label}`:`${`${e.label}`.substring(0,I)}...`,y:s(`${e.id}`),x:0-d/2,width:d,height:s.bandwidth(),alignment:"center",style:h?.yAxis?.labels,className:n?.yAxis?.labels,animate:m,isInView:b},r))})}),t.jsxRuntimeExports.jsxs("g",{transform:`translate(0,${w})`,children:[t.jsxRuntimeExports.jsx("text",{style:{fill:u[0],textAnchor:"end",...h?.yAxis?.title},className:t.mo("text-base",n?.yAxis?.title),x:L/2-d/2,y:0,dx:-5,dy:20,children:B[0]}),t.jsxRuntimeExports.jsx("text",{style:{fill:u[1],textAnchor:"start",...h?.yAxis?.title},className:t.mo("text-base",n?.yAxis?.title),x:L/2+d/2,y:0,dx:5,dy:20,children:B[1]})]}),se.filter(e=>e.position==="after").map(e=>e.layer)]})}),re&&J&&ae&&C?t.jsxRuntimeExports.jsx(Ae.Tooltip,{data:re,body:J,xPos:ae,yPos:C,backgroundStyle:h?.tooltip,className:n?.tooltip}):null,M&&q!==void 0?t.jsxRuntimeExports.jsx(Me.X,{open:q!==void 0,onClose:()=>{D(void 0)},children:t.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof M=="string"?{__html:Ce.string2HTML(M,q)}:void 0,children:typeof M=="function"?M(q):null})}):null]})}function Y(W,x,j,R){const u=W.map(E=>E[x]).filter(E=>!de.checkIfNullOrUndefined(E)),d=de.checkIfNullOrUndefined(j)?Math.min(...u)>=0?0:Math.min(...u):j,a=de.checkIfNullOrUndefined(R)?Math.max(...u)<0?0:Math.max(...u):R;return{min:d,max:a}}function Ge(W){const{data:x,graphTitle:j,sources:R,graphDescription:u,height:d,width:a,footNote:E,padding:U,barColors:z=[Ee.Colors.light.categoricalColors.colors[0],Ee.Colors.light.categoricalColors.colors[1]],backgroundColor:B=!1,leftMargin:ne=20,rightMargin:oe=20,topMargin:_=25,bottomMargin:le=30,rightBarTitle:J="Right bar graph",leftBarTitle:O="Left bar graph",tooltip:xe,relativeHeight:I,onSeriesMouseOver:k,graphID:te,barPadding:G=.25,truncateBy:H=999,onSeriesMouseClick:ie,centerGap:M=100,showValues:h=!0,maxValue:n,minValue:A,refValues:m=[],suffix:P="",prefix:se="",showTicks:N=!0,showColorScale:$=!1,graphDownload:K=!1,dataDownload:Q=!1,language:b="en",colorLegendTitle:re,minHeight:v=0,theme:q="light",ariaLabel:D,resetSelectionOnDoubleClick:ae=!0,detailsOnClick:V,styles:C,classNames:p,noOfTicks:c=5,animate:L=!1,precision:w=2,customLayers:X=[],timeline:s={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:l="NA"}=W,[S,o]=y.useState(0),[Z,e]=y.useState(0),[r,f]=y.useState(s.autoplay),g=Ie.sort(Oe.uniqBy(x,"date",!0).map(i=>fe.parse(`${i}`,s.dateFormat||"yyyy",new Date).getTime()),(i,F)=>De.ascending(i,F)),[ue,ce]=y.useState(s.autoplay?0:g.length-1),ee=y.useRef(null),he=y.useRef(null);y.useEffect(()=>{const i=new ResizeObserver(F=>{o(a||F[0].target.clientWidth||620),e(d||F[0].target.clientHeight||480)});return ee.current&&(e(ee.current.clientHeight||480),o(ee.current.clientWidth||620),a||i.observe(ee.current)),()=>i.disconnect()},[a,d]),y.useEffect(()=>{const i=setInterval(()=>{ce(F=>F<g.length-1?F+1:0)},(s.speed||2)*1e3);return r||clearInterval(i),()=>clearInterval(i)},[g,r,s.speed]);const ge=pe.getSliderMarks(g,ue,s.showOnlyActiveDate,s.dateFormat||"yyyy");return t.jsxRuntimeExports.jsx("div",{className:`${q||"light"} flex ${a?"w-fit grow-0":"w-full grow"}`,dir:b==="he"||b==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${B?B===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${b||"en"}`,a?"w-fit":"w-full",p?.graphContainer),style:{...C?.graphContainer||{},...B&&B!==!0?{backgroundColor:B}:{}},id:te,ref:he,"aria-label":D||`${j?`The graph shows ${j}. `:""}This is a diverging bar chart. ${u?` ${u}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:B?U||"1rem":U||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[j||u||K||Q?t.jsxRuntimeExports.jsx(qe.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:p?.title,description:p?.description},graphTitle:j,graphDescription:u,width:a,graphDownload:K?he.current:void 0,dataDownload:Q?x.map(i=>i.data).filter(i=>i!==void 0).length>0?x.map(i=>i.data).filter(i=>i!==void 0):x.filter(i=>i!==void 0):null}):null,s.enabled&&g.length>0&&ge?t.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[t.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{f(!r)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":r?"Click to pause animation":"Click to play animation",children:r?t.jsxRuntimeExports.jsx(Be.Pause,{}):t.jsxRuntimeExports.jsx(Be.Play,{})}),t.jsxRuntimeExports.jsx(pe.xr,{min:g[0],max:g[g.length-1],marks:ge,step:null,defaultValue:g[g.length-1],value:g[ue],onChangeComplete:i=>{ce(g.indexOf(i))},onChange:i=>{ce(g.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:x.length===0?t.jsxRuntimeExports.jsx(Se.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[$?t.jsxRuntimeExports.jsx(Ve.ColorLegend,{colorLegendTitle:re,colorDomain:[O,J],colors:z,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:ee,"aria-label":"Graph area",children:(a||S)&&(d||Z)?t.jsxRuntimeExports.jsx(Fe,{data:Te.ensureCompleteDataForButterFlyChart(x,s.dateFormat||"yyyy").filter(i=>s.enabled?i.date===fe.format(new Date(g[ue]),s.dateFormat||"yyyy"):i),barColors:z,width:a||S,centerGap:M,height:Math.max(v,d||(I?v?(a||S)*I>v?(a||S)*I:v:(a||S)*I:Z)),truncateBy:H,leftMargin:ne,rightMargin:oe,topMargin:_,bottomMargin:le,axisTitles:[O,J],tooltip:xe,onSeriesMouseOver:k,barPadding:G,refValues:m,maxValue:Math.max(Y(x,"leftBar",A,n).max,Y(x,"rightBar",A,n).max),minValue:Math.min(Y(x,"leftBar",A,n).min,Y(x,"rightBar",A,n).min),minValueLeftBar:Y(x,"leftBar",A,n).min,minValueRightBar:Y(x,"rightBar",A,n).min,showValues:h,onSeriesMouseClick:ie,showTicks:N,suffix:P,prefix:se,resetSelectionOnDoubleClick:ae,detailsOnClick:V,styles:C,classNames:p,noOfTicks:c,animate:L===!0?{duration:.5,once:!0,amount:.5}:L||{duration:0,once:!0,amount:0},precision:w,customLayers:X,naLabel:l}):null})]})}),R||E?t.jsxRuntimeExports.jsx($e.GraphFooter,{styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:p?.footnote,source:p?.source},sources:R,footNote:E,width:a}):null]})})})})}exports.ButterflyChart=Ge;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),y=require("react"),pe=require("./getSliderMarks-CRIbTGYV.cjs"),fe=require("./parse-hMnG_lRV.cjs"),ye=require("./index-DQA8q5sC.cjs"),Me=require("./Modal-tXZlLE5s.cjs"),je=require("./numberFormattingFunction-02t-wJta.cjs"),Ae=require("./Tooltip-De16GWhY.cjs"),Ce=require("./string2HTML-z7CwHXcx.cjs"),be=require("./XTicksAndGridLines-CCzXIV8d.cjs"),ve=require("./Axis-DE7dSn1_.cjs"),Le=require("./YAxesLabels-yRFFdx1s.cjs"),we=require("./ReferenceLine-CFVBBN__.cjs"),ke=require("./band-CAApY4Pd.cjs"),Re=require("./linear-BVckp9RD.cjs"),Ne=require("./use-in-view-sQJZ_xDO.cjs"),T=require("./proxy-BHRoeZgd.cjs"),me=require("./index-BW8iNx7E.cjs"),$e=require("./GraphFooter.cjs"),qe=require("./GraphHeader.cjs"),Ve=require("./ColorLegend.cjs"),Ee=require("./Colors.cjs"),Se=require("./EmptyState-d8_8SxeW.cjs"),Be=require("./index-BW_-wD2k.cjs"),de=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Te=require("./ensureCompleteData-DkQYPeDa.cjs"),Oe=require("./uniqBy-O05lp2S5.cjs"),Ie=require("./sort-O96oMZLb.cjs"),De=require("./init-DU0ybBc_.cjs");function Fe(W){const{data:x,width:j,height:R,barColors:u,centerGap:d,refValues:a,maxValue:E,minValue:U,showValues:z,axisTitles:B,rightMargin:ne,leftMargin:oe,topMargin:_,bottomMargin:le,tooltip:J,onSeriesMouseOver:O,barPadding:xe,truncateBy:I,onSeriesMouseClick:k,showTicks:te,suffix:G,prefix:H,resetSelectionOnDoubleClick:ie,detailsOnClick:M,styles:h,classNames:n,noOfTicks:A,animate:m,precision:P,customLayers:se,minValueLeftBar:N,minValueRightBar:$,naLabel:K}=W,Q=y.useRef(null),b=Ne.useInView(Q,{once:m.once,amount:m.amount}),[re,v]=y.useState(void 0),[q,D]=y.useState(void 0),[ae,V]=y.useState(void 0),[C,p]=y.useState(void 0),c={top:_,bottom:le,left:oe,right:ne},L=j-c.left-c.right,w=R-c.top-c.bottom,X=x.map((e,r)=>({...e,id:`${r}`})),s=ke.band().domain(X.map(e=>`${e.id}`)).range([w,0]).paddingInner(xe),l=Re.linear().domain([U,E]).range([0,(L-d)/2]).nice(),S=l.ticks(A),o=Re.linear().domain([U,E]).range([(L-d)/2,0]).nice(),Z=o.ticks(A);return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(T.motion.svg,{width:`${j}px`,height:`${R}px`,viewBox:`0 0 ${j} ${R}`,direction:"ltr",ref:Q,children:t.jsxRuntimeExports.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[se.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs("g",{transform:"translate(0,0)",children:[te?t.jsxRuntimeExports.jsx(be.XTicksAndGridLines,{values:Z.filter(e=>e!==0),x:Z.filter(e=>e!==0).map(e=>o(e)),y1:0-_,y2:w+c.bottom,styles:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},classNames:{gridLines:n?.xAxis?.gridLines,labels:n?.xAxis?.labels},suffix:G,prefix:H,labelType:"secondary",showGridLines:!0,leftLabel:!0,precision:P}):null,t.jsxRuntimeExports.jsxs(me.AnimatePresence,{children:[X.map((e,r)=>t.jsxRuntimeExports.jsxs(T.motion.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:f=>{v(e),p(f.clientY),V(f.clientX),O?.(e)},onClick:()=>{(k||M)&&(ye.isEqual(q,e)&&ie?(D(void 0),k?.(void 0)):(D(e),k?.(e)))},onMouseMove:f=>{v(e),p(f.clientY),V(f.clientX)},onMouseLeave:()=>{v(void 0),V(void 0),p(void 0),O?.(void 0)},children:[e.leftBar?t.jsxRuntimeExports.jsx(T.motion.rect,{y:s(`${r}`),style:{fill:u[0]},height:s.bandwidth(),variants:{initial:{x:o(0),width:0},whileInView:{x:e.leftBar<0?o(0):o(e.leftBar),width:e.leftBar<0?o(e.leftBar)-o(0):o(0)-o(e.leftBar),transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial",exit:{x:o(0),width:0,transition:{duration:m.duration}}}):null,z?t.jsxRuntimeExports.jsx(T.motion.text,{y:s(`${r}`)+s.bandwidth()/2,style:{fill:u[0],textAnchor:e.rightBar&&e.rightBar>0?"end":"start",...h?.graphObjectValues||{}},dx:e.rightBar&&e.rightBar>0?-5:5,dy:"0.33em",className:t.mo("graph-value text-sm",n?.graphObjectValues),exit:{opacity:0,transition:{duration:m.duration}},variants:{initial:{x:o(0),opacity:0},whileInView:{x:e.leftBar?o(e.leftBar):o(N<0?0:N),opacity:1,transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial",children:je.numberFormattingFunction(e.rightBar,K,P,H,G)}):null]},e.label)),t.jsxRuntimeExports.jsx(ve.Axis,{y1:-2.5,y2:w+c.bottom,x1:o(N<0?0:N),x2:o(N<0?0:N),classNames:{axis:n?.yAxis?.axis},styles:{axis:h?.yAxis?.axis}}),a?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:a.map((e,r)=>t.jsxRuntimeExports.jsx(we.RefLineX,{text:e.text,color:e.color,x:o(e.value),y1:0-c.top,y2:w+c.bottom,textSide:"left",classNames:e.classNames,styles:e.styles,animate:m,isInView:b},r))}):null]})]}),t.jsxRuntimeExports.jsxs("g",{transform:`translate(${(L+d)/2},0)`,children:[te?t.jsxRuntimeExports.jsx(be.XTicksAndGridLines,{values:S.filter(e=>e!==0),x:S.filter(e=>e!==0).map(e=>l(e)),y1:0-_,y2:w+c.bottom,styles:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},classNames:{gridLines:n?.xAxis?.gridLines,labels:n?.xAxis?.labels},suffix:G,prefix:H,labelType:"secondary",showGridLines:!0,precision:P}):null,t.jsxRuntimeExports.jsxs(me.AnimatePresence,{children:[X.map((e,r)=>t.jsxRuntimeExports.jsxs(T.motion.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:f=>{v(e),p(f.clientY),V(f.clientX),O?.(e)},onClick:()=>{(k||M)&&(ye.isEqual(q,e)&&ie?(D(void 0),k?.(void 0)):(D(e),k?.(e)))},onMouseMove:f=>{v(e),p(f.clientY),V(f.clientX)},onMouseLeave:()=>{v(void 0),V(void 0),p(void 0),O?.(void 0)},children:[e.rightBar?t.jsxRuntimeExports.jsx(T.motion.rect,{y:s(`${r}`),style:{fill:u[1]},height:s.bandwidth(),exit:{x:l(0),width:0,transition:{duration:m.duration}},variants:{initial:{x:l(0),width:0},whileInView:{x:e.rightBar>=0?l(0):l(e.rightBar),width:e.rightBar>=0?l(e.rightBar)-l(0):l(0)-l(e.rightBar),transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial"}):null,z?t.jsxRuntimeExports.jsx(T.motion.text,{y:s(`${r}`)+s.bandwidth()/2,style:{fill:u[1],textAnchor:e.rightBar&&e.rightBar<0?"end":"start",...h?.graphObjectValues||{}},className:t.mo("graph-value text-sm",n?.graphObjectValues),dx:e.rightBar&&e.rightBar<0?-5:5,dy:"0.33em",exit:{opacity:0,transition:{duration:m.duration}},variants:{initial:{x:l(0),opacity:0},whileInView:{x:e.rightBar?l(e.rightBar):l($<0?0:$),opacity:1,transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial",children:je.numberFormattingFunction(e.rightBar,K,P,H,G)}):null]},r)),t.jsxRuntimeExports.jsx(ve.Axis,{y1:-2.5,y2:w+c.bottom,x1:l($<0?0:$),x2:l($<0?0:$),classNames:{axis:n?.yAxis?.axis},styles:{axis:h?.yAxis?.axis}}),a?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:a.map((e,r)=>t.jsxRuntimeExports.jsx(we.RefLineX,{text:e.text,color:e.color,x:l(e.value),y1:0-c.top,y2:w+c.bottom,textSide:"right",classNames:e.classNames,styles:e.styles,animate:m,isInView:b},r))}):null]})]}),t.jsxRuntimeExports.jsx(me.AnimatePresence,{children:t.jsxRuntimeExports.jsx(T.motion.g,{transform:`translate(${L/2},0)`,children:X.map((e,r)=>t.jsxRuntimeExports.jsx(Le.YAxesLabels,{value:`${e.label}`.length<I?`${e.label}`:`${`${e.label}`.substring(0,I)}...`,y:s(`${e.id}`),x:0-d/2,width:d,height:s.bandwidth(),alignment:"center",style:h?.yAxis?.labels,className:n?.yAxis?.labels,animate:m,isInView:b},r))})}),t.jsxRuntimeExports.jsxs("g",{transform:`translate(0,${w})`,children:[t.jsxRuntimeExports.jsx("text",{style:{fill:u[0],textAnchor:"end",...h?.yAxis?.title},className:t.mo("text-base",n?.yAxis?.title),x:L/2-d/2,y:0,dx:-5,dy:20,children:B[0]}),t.jsxRuntimeExports.jsx("text",{style:{fill:u[1],textAnchor:"start",...h?.yAxis?.title},className:t.mo("text-base",n?.yAxis?.title),x:L/2+d/2,y:0,dx:5,dy:20,children:B[1]})]}),se.filter(e=>e.position==="after").map(e=>e.layer)]})}),re&&J&&ae&&C?t.jsxRuntimeExports.jsx(Ae.Tooltip,{data:re,body:J,xPos:ae,yPos:C,backgroundStyle:h?.tooltip,className:n?.tooltip}):null,M&&q!==void 0?t.jsxRuntimeExports.jsx(Me.X,{open:q!==void 0,onClose:()=>{D(void 0)},children:t.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof M=="string"?{__html:Ce.string2HTML(M,q)}:void 0,children:typeof M=="function"?M(q):null})}):null]})}function Y(W,x,j,R){const u=W.map(E=>E[x]).filter(E=>!de.checkIfNullOrUndefined(E)),d=de.checkIfNullOrUndefined(j)?Math.min(...u)>=0?0:Math.min(...u):j,a=de.checkIfNullOrUndefined(R)?Math.max(...u)<0?0:Math.max(...u):R;return{min:d,max:a}}function Ge(W){const{data:x,graphTitle:j,sources:R,graphDescription:u,height:d,width:a,footNote:E,padding:U,barColors:z=[Ee.Colors.light.categoricalColors.colors[0],Ee.Colors.light.categoricalColors.colors[1]],backgroundColor:B=!1,leftMargin:ne=20,rightMargin:oe=20,topMargin:_=25,bottomMargin:le=30,rightBarTitle:J="Right bar graph",leftBarTitle:O="Left bar graph",tooltip:xe,relativeHeight:I,onSeriesMouseOver:k,graphID:te,barPadding:G=.25,truncateBy:H=999,onSeriesMouseClick:ie,centerGap:M=100,showValues:h=!0,maxValue:n,minValue:A,refValues:m=[],suffix:P="",prefix:se="",showTicks:N=!0,showColorScale:$=!1,graphDownload:K=!1,dataDownload:Q=!1,language:b="en",colorLegendTitle:re,minHeight:v=0,theme:q="light",ariaLabel:D,resetSelectionOnDoubleClick:ae=!0,detailsOnClick:V,styles:C,classNames:p,noOfTicks:c=5,animate:L=!1,precision:w=2,customLayers:X=[],timeline:s={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:l="NA"}=W,[S,o]=y.useState(0),[Z,e]=y.useState(0),[r,f]=y.useState(s.autoplay),g=Ie.sort(Oe.uniqBy(x,"date",!0).map(i=>fe.parse(`${i}`,s.dateFormat||"yyyy",new Date).getTime()),(i,F)=>De.ascending(i,F)),[ue,ce]=y.useState(s.autoplay?0:g.length-1),ee=y.useRef(null),he=y.useRef(null);y.useEffect(()=>{const i=new ResizeObserver(F=>{o(a||F[0].target.clientWidth||620),e(d||F[0].target.clientHeight||480)});return ee.current&&(e(ee.current.clientHeight||480),o(ee.current.clientWidth||620),a||i.observe(ee.current)),()=>i.disconnect()},[a,d]),y.useEffect(()=>{const i=setInterval(()=>{ce(F=>F<g.length-1?F+1:0)},(s.speed||2)*1e3);return r||clearInterval(i),()=>clearInterval(i)},[g,r,s.speed]);const ge=pe.getSliderMarks(g,ue,s.showOnlyActiveDate,s.dateFormat||"yyyy");return t.jsxRuntimeExports.jsx("div",{className:`${q||"light"} flex ${a?"w-fit grow-0":"w-full grow"}`,dir:b==="he"||b==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${B?B===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${b||"en"}`,a?"w-fit":"w-full",p?.graphContainer),style:{...C?.graphContainer||{},...B&&B!==!0?{backgroundColor:B}:{}},id:te,ref:he,"aria-label":D||`${j?`The graph shows ${j}. `:""}This is a diverging bar chart. ${u?` ${u}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:B?U||"1rem":U||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[j||u||K||Q?t.jsxRuntimeExports.jsx(qe.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:p?.title,description:p?.description},graphTitle:j,graphDescription:u,width:a,graphDownload:K?he.current:void 0,dataDownload:Q?x.map(i=>i.data).filter(i=>i!==void 0).length>0?x.map(i=>i.data).filter(i=>i!==void 0):x.filter(i=>i!==void 0):null}):null,s.enabled&&g.length>0&&ge?t.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[t.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{f(!r)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":r?"Click to pause animation":"Click to play animation",children:r?t.jsxRuntimeExports.jsx(Be.Pause,{}):t.jsxRuntimeExports.jsx(Be.Play,{})}),t.jsxRuntimeExports.jsx(pe.xr,{min:g[0],max:g[g.length-1],marks:ge,step:null,defaultValue:g[g.length-1],value:g[ue],onChangeComplete:i=>{ce(g.indexOf(i))},onChange:i=>{ce(g.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:x.length===0?t.jsxRuntimeExports.jsx(Se.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[$?t.jsxRuntimeExports.jsx(Ve.ColorLegend,{colorLegendTitle:re,colorDomain:[O,J],colors:z,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:ee,"aria-label":"Graph area",children:(a||S)&&(d||Z)?t.jsxRuntimeExports.jsx(Fe,{data:Te.ensureCompleteDataForButterFlyChart(x,s.dateFormat||"yyyy").filter(i=>s.enabled?i.date===fe.format(new Date(g[ue]),s.dateFormat||"yyyy"):i),barColors:z,width:a||S,centerGap:M,height:Math.max(v,d||(I?v?(a||S)*I>v?(a||S)*I:v:(a||S)*I:Z)),truncateBy:H,leftMargin:ne,rightMargin:oe,topMargin:_,bottomMargin:le,axisTitles:[O,J],tooltip:xe,onSeriesMouseOver:k,barPadding:G,refValues:m,maxValue:Math.max(Y(x,"leftBar",A,n).max,Y(x,"rightBar",A,n).max),minValue:Math.min(Y(x,"leftBar",A,n).min,Y(x,"rightBar",A,n).min),minValueLeftBar:Y(x,"leftBar",A,n).min,minValueRightBar:Y(x,"rightBar",A,n).min,showValues:h,onSeriesMouseClick:ie,showTicks:N,suffix:P,prefix:se,resetSelectionOnDoubleClick:ae,detailsOnClick:V,styles:C,classNames:p,noOfTicks:c,animate:L===!0?{duration:.5,once:!0,amount:.5}:L||{duration:0,once:!0,amount:0},precision:w,customLayers:X,naLabel:l}):null})]})}),R||E?t.jsxRuntimeExports.jsx($e.GraphFooter,{styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:p?.footnote,source:p?.source},sources:R,footNote:E,width:a}):null]})})})})}exports.ButterflyChart=Ge;
2
2
  //# sourceMappingURL=ButterflyChart.cjs.map
@@ -9,7 +9,7 @@ import { T as Vt } from "./Tooltip-CVCGWyzw.js";
9
9
  import { s as Tt } from "./string2HTML-oFCROsus.js";
10
10
  import { X as wt } from "./XTicksAndGridLines-Bn9u5gOM.js";
11
11
  import { A as jt } from "./Axis-Ddg-seDi.js";
12
- import { Y as Ot } from "./YAxesLabels-DSm6I5zG.js";
12
+ import { Y as Ot } from "./YAxesLabels-DECkMgq8.js";
13
13
  import { a as Bt } from "./ReferenceLine-CfAW3vKJ.js";
14
14
  import { b as Dt } from "./band-BEjh2CHI.js";
15
15
  import { a as Mt } from "./linear-DUdu7l2G.js";
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),d=require("react"),Ee=require("./getSliderMarks-CRIbTGYV.cjs"),we=require("./Spinner-DA6Z5E4n.cjs"),be=require("./parse-hMnG_lRV.cjs"),Re=require("./index-DQA8q5sC.cjs"),V=require("./zoom-Bsbhil-K.cjs"),$e=require("./Modal-tXZlLE5s.cjs"),ke=require("./Typography-k-kOjICQ.cjs"),Ce=require("./index-D05lK1Te.cjs"),Ne=require("./numberFormattingFunction-02t-wJta.cjs"),Se=require("./Tooltip-De16GWhY.cjs"),Me=require("./string2HTML-z7CwHXcx.cjs"),qe=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),ve=require("./index-BW_-wD2k.cjs"),De=require("./ordinal-BOeNbyae.cjs"),Oe=require("./threshold-DNsSUf8Q.cjs"),je=require("./select-Bnfk0lJx.cjs"),Pe=require("./use-in-view-sQJZ_xDO.cjs"),ue=require("./proxy-BHRoeZgd.cjs"),Ie=require("./index-BW8iNx7E.cjs"),Le=require("./GraphFooter.cjs"),Te=require("./GraphHeader.cjs"),de=require("./Colors.cjs"),ze=require("./fetchAndParseData-Ba-_CgxS.cjs"),We=require("./getUniqValue-RViz8tTw.cjs"),Ve=require("./getJenks-GYmdwBqm.cjs"),Be=require("./uniqBy-O05lp2S5.cjs"),Fe=require("./sort-O96oMZLb.cjs"),He=require("./init-DU0ybBc_.cjs");function Ae(pe){const{data:E,colorDomain:h,colors:c,mapData:j,colorLegendTitle:B,categorical:q,height:x,width:n,scale:ae,centerPoint:T,tooltip:se,mapBorderWidth:D,mapBorderColor:F,mapNoDataColor:Y,onSeriesMouseOver:J,showColorScale:me,zoomScaleExtend:xe,zoomTranslateExtend:O,highlightedIds:H,onSeriesMouseClick:y,mapProperty:A,resetSelectionOnDoubleClick:he,detailsOnClick:$,styles:ge,classNames:ye,mapProjection:U,zoomInteraction:z,animate:b,dimmedOpacity:G,customLayers:ie}=pe,[k,C]=d.useState(void 0),K=d.useRef(null),[Z,v]=d.useState(!(n<680)),[N,Q]=d.useState(void 0),[_,ee]=d.useState(void 0),[S,w]=d.useState(void 0),[ne,te]=d.useState(void 0),P=d.useRef(null),re=Pe.useInView(P,{once:b.once,amount:b.amount}),le=d.useRef(null),f=q?De.ordinal().domain(h).range(c):Oe.threshold().domain(h).range(c);d.useEffect(()=>{const r=je.select(le.current),l=je.select(P.current),p=a=>{if(z==="noZoom")return!1;if(z==="button")return!a.type.includes("wheel");const i=a.type==="wheel",t=a.type.startsWith("touch"),o=a.type==="mousedown"||a.type==="mousemove";return t?!0:i?z==="scroll"?!0:a.ctrlKey:o&&!a.button&&!a.ctrlKey},s=V.zoom().scaleExtent(xe).translateExtent(O||[[-20,-20],[n+20,x+20]]).filter(p).on("zoom",({transform:a})=>{r.attr("transform",a)});l.call(s),K.current=s},[x,n,z]);const g=V.turf_bbox_default(j),I=Ce.turf_center_of_mass_default(j),oe=g[2]-g[0],ce=g[3]-g[1],W=n*190/960*360/oe,fe=x*190/678*180/ce,u=ae*Math.min(W,fe),R=U==="mercator"?V.geoMercator().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="equalEarth"?V.geoEqualEarth().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="naturalEarth"?V.geoNaturalEarth1().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="orthographic"?V.geoOrthographic().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):V.geoAlbersUsa().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u),X=r=>{if(!P.current||!K.current)return;je.select(P.current).call(K.current.scaleBy,r==="in"?1.2:1/1.2)};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"relative",children:[e.jsxRuntimeExports.jsx(ue.motion.svg,{width:`${n}px`,height:`${x}px`,viewBox:`0 0 ${n} ${x}`,ref:P,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{ref:le,children:[ie.filter(r=>r.position==="before").map(r=>r.layer),j.features.map((r,l)=>E.findIndex(s=>s.id===r.properties[A])!==-1?null:e.jsxRuntimeExports.jsx("g",{opacity:k?G:H.length!==0?H.indexOf(r.properties[A])!==-1?1:G:1,children:r.geometry.type==="MultiPolygon"?r.geometry.coordinates.map((s,a)=>{let i="";return s.forEach(t=>{let o=" M";t.forEach((m,L)=>{const M=R([m[0],m[1]]);L!==t.length-1?o=`${o}${M[0]} ${M[1]}L`:o=`${o}${M[0]} ${M[1]}`}),i+=o}),e.jsxRuntimeExports.jsx("path",{d:i,style:{stroke:F,strokeWidth:D,fill:Y}},a)}):r.geometry.coordinates.map((s,a)=>{let i="M";return s.forEach((t,o)=>{const m=R([t[0],t[1]]);o!==s.length-1?i=`${i}${m[0]} ${m[1]}L`:i=`${i}${m[0]} ${m[1]}`}),e.jsxRuntimeExports.jsx("path",{d:i,style:{stroke:F,strokeWidth:D,fill:Y}},a)})},l)),e.jsxRuntimeExports.jsx(Ie.AnimatePresence,{children:E.map(r=>{const l=j.features.findIndex(s=>r.id===s.properties[A]),p=qe.checkIfNullOrUndefined(r.x)?Y:f(r.x);return e.jsxRuntimeExports.jsx(ue.motion.g,{variants:{initial:{opacity:0},whileInView:{opacity:k?k===p?1:G:H.length!==0?H.indexOf(r.id)!==-1?1:G:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},onMouseEnter:s=>{ee(r),te(s.clientY),w(s.clientX),J?.(r)},onMouseMove:s=>{ee(r),te(s.clientY),w(s.clientX)},onMouseLeave:()=>{ee(void 0),w(void 0),te(void 0),J?.(void 0)},onClick:()=>{(y||$)&&(Re.isEqual(N,r)&&he?(Q(void 0),y?.(void 0)):(Q(r),y?.(r)))},children:l===-1?null:j.features[l].geometry.type==="MultiPolygon"?j.features[l].geometry.coordinates.map((s,a)=>{let i="";return s.forEach(t=>{let o=" M";t.forEach((m,L)=>{const M=R([m[0],m[1]]);L!==t.length-1?o=`${o}${M[0]} ${M[1]}L`:o=`${o}${M[0]} ${M[1]}`}),i+=o}),e.jsxRuntimeExports.jsx(ue.motion.path,{d:i,variants:{initial:{fill:p,opacity:0},whileInView:{fill:p,opacity:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},style:{stroke:F,strokeWidth:D}},`${r.id}-${a}`)}):j.features[l].geometry.coordinates.map((s,a)=>{let i="M";return s.forEach((t,o)=>{const m=R([t[0],t[1]]);o!==s.length-1?i=`${i}${m[0]} ${m[1]}L`:i=`${i}${m[0]} ${m[1]}`}),e.jsxRuntimeExports.jsx(ue.motion.path,{d:i,variants:{initial:{fill:p,opacity:0},whileInView:{fill:p,opacity:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},style:{stroke:F,strokeWidth:D}},`${r.id}-${a}`)})},r.id)})}),_?j.features.filter(r=>r.properties[A]===_.id).map((r,l)=>e.jsxRuntimeExports.jsx("g",{children:r.geometry.type==="MultiPolygon"?r.geometry.coordinates.map((p,s)=>{let a="";return p.forEach(i=>{let t=" M";i.forEach((o,m)=>{const L=R([o[0],o[1]]);m!==i.length-1?t=`${t}${L[0]} ${L[1]}L`:t=`${t}${L[0]} ${L[1]}`}),a+=t}),e.jsxRuntimeExports.jsx("path",{d:a,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},s)}):r.geometry.coordinates.map((p,s)=>{let a="M";return p.forEach((i,t)=>{const o=R([i[0],i[1]]);t!==p.length-1?a=`${a}${o[0]} ${o[1]}L`:a=`${a}${o[0]} ${o[1]}`}),e.jsxRuntimeExports.jsx("path",{d:a,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},s)})},l)):null,ie.filter(r=>r.position==="after").map(r=>r.layer)]})}),me===!1?null:e.jsxRuntimeExports.jsx("div",{className:"absolute left-4 bottom-4",children:Z?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{style:{backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"absolute",right:"-0.75rem",top:"-0.75rem"},onClick:()=>{v(!1)},children:e.jsxRuntimeExports.jsx(ve.X,{})}),e.jsxRuntimeExports.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.7)",width:q?void 0:"340px"},children:[B&&B!==""?e.jsxRuntimeExports.jsx(ke.u,{size:"xs",marginBottom:"xs",className:"p-0 leading-normal overflow-hidden text-primary-gray-700 dark:text-primary-gray-300",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical"},children:B}):null,q?e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-3",children:h.map((r,l)=>e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{C(c[l%c.length])},onMouseLeave:()=>{C(void 0)},children:[e.jsxRuntimeExports.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:c[l%c.length]}}),e.jsxRuntimeExports.jsx(ke.u,{size:"sm",marginBottom:"none",leading:"none",children:r})]},l))}):e.jsxRuntimeExports.jsx("svg",{width:"100%",viewBox:"0 0 320 30",direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{children:[h.map((r,l)=>e.jsxRuntimeExports.jsxs("g",{onMouseOver:()=>{C(c[l])},onMouseLeave:()=>{C(void 0)},className:"cursor-pointer",children:[e.jsxRuntimeExports.jsx("rect",{x:l*320/c.length+1,y:1,width:320/c.length-2,height:8,className:k===c[l]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":"",style:{fill:c[l],...k===c[l]?{}:{stroke:c[l]}}}),e.jsxRuntimeExports.jsx("text",{x:(l+1)*320/c.length,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",style:{textAnchor:"middle"},children:Ne.numberFormattingFunction(r,"NA")})]},l)),e.jsxRuntimeExports.jsx("g",{children:e.jsxRuntimeExports.jsx("rect",{onMouseOver:()=>{C(c[h.length])},onMouseLeave:()=>{C(void 0)},x:h.length*320/c.length+1,y:1,width:320/c.length-2,height:8,className:`cursor-pointer ${k===c[h.length]?"stroke-1 stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:c[h.length],...k===c[h.length]?{}:{stroke:c[h.length]}}})})]})})]})]}):e.jsxRuntimeExports.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{v(!0)},children:e.jsxRuntimeExports.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})})}),z==="button"&&e.jsxRuntimeExports.jsxs("div",{className:"absolute left-4 top-4 flex flex-col",children:[e.jsxRuntimeExports.jsx("button",{onClick:()=>X("in"),className:"leading-0 px-2 py-3.5 text-primary-gray-700 border border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"+"}),e.jsxRuntimeExports.jsx("button",{onClick:()=>X("out"),className:"leading-0 px-2 py-3.5 text-primary-gray-700 border border-t-0 border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"–"})]})]}),$&&N!==void 0?e.jsxRuntimeExports.jsx($e.X,{open:N!==void 0,onClose:()=>{Q(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof $=="string"?{__html:Me.string2HTML($,N)}:void 0,children:typeof $=="function"?$(N):null})}):null,_&&se&&S&&ne?e.jsxRuntimeExports.jsx(Se.Tooltip,{data:_,body:se,xPos:S,yPos:ne,backgroundStyle:ge?.tooltip,className:ye?.tooltip}):null]})}function Ue(pe){const{data:E,mapData:h="https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap.json",graphTitle:c,colors:j,sources:B,graphDescription:q,height:x,width:n,footNote:ae="The designations employed and the presentation of material on this map do not imply the expression of any opinion whatsoever on the part of the Secretariat of the United Nations or UNDP concerning the legal status of any country, territory, city or area or its authorities, or concerning the delimitation of its frontiers or boundaries.",colorDomain:T,colorLegendTitle:se,scaleType:D="threshold",scale:F=.95,centerPoint:Y,padding:J,mapBorderWidth:me=.5,mapNoDataColor:xe=de.Colors.light.graphNoData,backgroundColor:O=!1,mapBorderColor:H=de.Colors.light.grays["gray-500"],relativeHeight:y,tooltip:A,onSeriesMouseOver:he,isWorldMap:$=!0,showColorScale:ge=!0,zoomScaleExtend:ye=[.8,6],zoomTranslateExtend:U,graphID:z,highlightedIds:b=[],onSeriesMouseClick:G,mapProperty:ie="ISO3",graphDownload:k=!1,dataDownload:C=!1,showAntarctica:K=!1,language:Z="en",minHeight:v=0,theme:N="light",ariaLabel:Q,resetSelectionOnDoubleClick:_=!0,detailsOnClick:ee,styles:S,classNames:w,mapProjection:ne,zoomInteraction:te="button",animate:P=!1,dimmedOpacity:re=.3,customLayers:le=[],timeline:f={enabled:!1,autoplay:!1,showOnlyActiveDate:!0}}=pe,[g,I]=d.useState(0),[oe,ce]=d.useState(0),[W,fe]=d.useState(f.autoplay),u=Fe.sort(Be.uniqBy(E,"date",!0).map(t=>be.parse(`${t}`,f.dateFormat||"yyyy",new Date).getTime()),(t,o)=>He.ascending(t,o)),[R,X]=d.useState(f.autoplay?0:u.length-1),[r,l]=d.useState(void 0),p=d.useRef(null),s=d.useRef(null);d.useEffect(()=>{const t=new ResizeObserver(o=>{I(n||o[0].target.clientWidth||760),ce(x||o[0].target.clientHeight||480)});return p.current&&(ce(p.current.clientHeight||480),I(p.current.clientWidth||760),n||t.observe(p.current)),()=>t.disconnect()},[n,x]),d.useEffect(()=>{typeof h=="string"?ze.fetchAndParseJSON(h).then(o=>{l(o)}):l(h)},[h]);const a=T||(D==="categorical"?We.getUniqValue(E,"x"):Ve.getJenks(E.map(t=>t.x),j?.length||4));d.useEffect(()=>{const t=setInterval(()=>{X(o=>o<u.length-1?o+1:0)},(f.speed||2)*1e3);return W||clearInterval(t),()=>clearInterval(t)},[u,W,f.speed]);const i=Ee.getSliderMarks(u,R,f.showOnlyActiveDate,f.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${N||"light"} flex ${n?"w-fit grow-0":"w-full grow"}`,dir:Z==="he"||Z==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${O?O===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${Z||"en"}`,n?"w-fit":"w-full",w?.graphContainer),style:{...S?.graphContainer||{},...O&&O!==!0?{backgroundColor:O}:{}},id:z,ref:s,"aria-label":Q||`${c?`The graph shows ${c}. `:""}This is a choropleth map where geographic areas are colored in proportion to a specific variable.${q?` ${q}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:O?J||"1rem":J||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[c||q||k||C?e.jsxRuntimeExports.jsx(Te.GraphHeader,{styles:{title:S?.title,description:S?.description},classNames:{title:w?.title,description:w?.description},graphTitle:c,graphDescription:q,width:n,graphDownload:k?s.current:void 0,dataDownload:C?E.map(t=>t.data).filter(t=>t!==void 0).length>0?E.map(t=>t.data).filter(t=>t!==void 0):E.filter(t=>t!==void 0):null}):null,f.enabled&&u.length>0&&i?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{fe(!W)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":W?"Click to pause animation":"Click to play animation",children:W?e.jsxRuntimeExports.jsx(ve.Pause,{}):e.jsxRuntimeExports.jsx(ve.Play,{})}),e.jsxRuntimeExports.jsx(Ee.xr,{min:u[0],max:u[u.length-1],marks:i,step:null,defaultValue:u[u.length-1],value:u[R],onChangeComplete:t=>{X(u.indexOf(t))},onChange:t=>{X(u.indexOf(t))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:p,"aria-label":"Map area",children:(n||g)&&(x||oe)&&r?e.jsxRuntimeExports.jsx(Ae,{data:E.filter(t=>f.enabled?t.date===be.format(new Date(u[R]),f.dateFormat||"yyyy"):t),mapData:K?r:{...r,features:r.features.filter(t=>t.properties.NAME!=="Antarctica")},colorDomain:a,width:n||g,height:Math.max(v,x||(y?v?(n||g)*y>v?(n||g)*y:v:(n||g)*y:oe)),scale:F,centerPoint:Y,colors:j||(D==="categorical"?de.Colors[N].sequentialColors[`neutralColorsx0${a.length}`]:de.Colors[N].sequentialColors[`neutralColorsx0${a.length+1}`]),colorLegendTitle:se,mapBorderWidth:me,mapNoDataColor:xe,categorical:D==="categorical",mapBorderColor:H,tooltip:A,onSeriesMouseOver:he,isWorldMap:$,showColorScale:ge,zoomScaleExtend:ye,zoomTranslateExtend:U,onSeriesMouseClick:G,mapProperty:ie,highlightedIds:b,resetSelectionOnDoubleClick:_,styles:S,classNames:w,detailsOnClick:ee,mapProjection:ne||($?"naturalEarth":"mercator"),zoomInteraction:te,dimmedOpacity:re,animate:P===!0?{duration:.5,once:!0,amount:.5}:P||{duration:0,once:!0,amount:0},customLayers:le}):e.jsxRuntimeExports.jsx("div",{style:{height:`${Math.max(v,x||(y?v?(n||g)*y>v?(n||g)*y:v:(n||g)*y:oe))}px`},className:"flex items-center justify-center",children:e.jsxRuntimeExports.jsx(we.y,{"aria-label":"Loading graph"})})}),B||ae?e.jsxRuntimeExports.jsx(Le.GraphFooter,{styles:{footnote:S?.footnote,source:S?.source},classNames:{footnote:w?.footnote,source:w?.source},sources:B,footNote:ae,width:n}):null]})})})})}exports.ChoroplethMap=Ue;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),d=require("react"),Ee=require("./getSliderMarks-CRIbTGYV.cjs"),we=require("./Spinner-DA6Z5E4n.cjs"),be=require("./parse-hMnG_lRV.cjs"),Re=require("./index-DQA8q5sC.cjs"),V=require("./zoom-BiMNsz72.cjs"),$e=require("./Modal-tXZlLE5s.cjs"),ke=require("./Typography-k-kOjICQ.cjs"),Ce=require("./index-CoZbeNM9.cjs"),Ne=require("./numberFormattingFunction-02t-wJta.cjs"),Se=require("./Tooltip-De16GWhY.cjs"),Me=require("./string2HTML-z7CwHXcx.cjs"),qe=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),ve=require("./index-BW_-wD2k.cjs"),De=require("./ordinal-BOeNbyae.cjs"),Oe=require("./threshold-DNsSUf8Q.cjs"),je=require("./select-Bnfk0lJx.cjs"),Pe=require("./use-in-view-sQJZ_xDO.cjs"),ue=require("./proxy-BHRoeZgd.cjs"),Ie=require("./index-BW8iNx7E.cjs"),Le=require("./GraphFooter.cjs"),Te=require("./GraphHeader.cjs"),de=require("./Colors.cjs"),ze=require("./fetchAndParseData-Ba-_CgxS.cjs"),We=require("./getUniqValue-RViz8tTw.cjs"),Ve=require("./getJenks-GYmdwBqm.cjs"),Be=require("./uniqBy-O05lp2S5.cjs"),Fe=require("./sort-O96oMZLb.cjs"),He=require("./init-DU0ybBc_.cjs");function Ae(pe){const{data:E,colorDomain:h,colors:c,mapData:j,colorLegendTitle:B,categorical:q,height:x,width:n,scale:ae,centerPoint:T,tooltip:se,mapBorderWidth:D,mapBorderColor:F,mapNoDataColor:Y,onSeriesMouseOver:J,showColorScale:me,zoomScaleExtend:xe,zoomTranslateExtend:O,highlightedIds:H,onSeriesMouseClick:y,mapProperty:A,resetSelectionOnDoubleClick:he,detailsOnClick:$,styles:ge,classNames:ye,mapProjection:U,zoomInteraction:z,animate:b,dimmedOpacity:G,customLayers:ie}=pe,[k,C]=d.useState(void 0),K=d.useRef(null),[Z,v]=d.useState(!(n<680)),[N,Q]=d.useState(void 0),[_,ee]=d.useState(void 0),[S,w]=d.useState(void 0),[ne,te]=d.useState(void 0),P=d.useRef(null),re=Pe.useInView(P,{once:b.once,amount:b.amount}),le=d.useRef(null),f=q?De.ordinal().domain(h).range(c):Oe.threshold().domain(h).range(c);d.useEffect(()=>{const r=je.select(le.current),l=je.select(P.current),p=a=>{if(z==="noZoom")return!1;if(z==="button")return!a.type.includes("wheel");const i=a.type==="wheel",t=a.type.startsWith("touch"),o=a.type==="mousedown"||a.type==="mousemove";return t?!0:i?z==="scroll"?!0:a.ctrlKey:o&&!a.button&&!a.ctrlKey},s=V.zoom().scaleExtent(xe).translateExtent(O||[[-20,-20],[n+20,x+20]]).filter(p).on("zoom",({transform:a})=>{r.attr("transform",a)});l.call(s),K.current=s},[x,n,z]);const g=V.turf_bbox_default(j),I=Ce.turf_center_of_mass_default(j),oe=g[2]-g[0],ce=g[3]-g[1],W=n*190/960*360/oe,fe=x*190/678*180/ce,u=ae*Math.min(W,fe),R=U==="mercator"?V.geoMercator().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="equalEarth"?V.geoEqualEarth().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="naturalEarth"?V.geoNaturalEarth1().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="orthographic"?V.geoOrthographic().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):V.geoAlbersUsa().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u),X=r=>{if(!P.current||!K.current)return;je.select(P.current).call(K.current.scaleBy,r==="in"?1.2:1/1.2)};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"relative",children:[e.jsxRuntimeExports.jsx(ue.motion.svg,{width:`${n}px`,height:`${x}px`,viewBox:`0 0 ${n} ${x}`,ref:P,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{ref:le,children:[ie.filter(r=>r.position==="before").map(r=>r.layer),j.features.map((r,l)=>E.findIndex(s=>s.id===r.properties[A])!==-1?null:e.jsxRuntimeExports.jsx("g",{opacity:k?G:H.length!==0?H.indexOf(r.properties[A])!==-1?1:G:1,children:r.geometry.type==="MultiPolygon"?r.geometry.coordinates.map((s,a)=>{let i="";return s.forEach(t=>{let o=" M";t.forEach((m,L)=>{const M=R([m[0],m[1]]);L!==t.length-1?o=`${o}${M[0]} ${M[1]}L`:o=`${o}${M[0]} ${M[1]}`}),i+=o}),e.jsxRuntimeExports.jsx("path",{d:i,style:{stroke:F,strokeWidth:D,fill:Y}},a)}):r.geometry.coordinates.map((s,a)=>{let i="M";return s.forEach((t,o)=>{const m=R([t[0],t[1]]);o!==s.length-1?i=`${i}${m[0]} ${m[1]}L`:i=`${i}${m[0]} ${m[1]}`}),e.jsxRuntimeExports.jsx("path",{d:i,style:{stroke:F,strokeWidth:D,fill:Y}},a)})},l)),e.jsxRuntimeExports.jsx(Ie.AnimatePresence,{children:E.map(r=>{const l=j.features.findIndex(s=>r.id===s.properties[A]),p=qe.checkIfNullOrUndefined(r.x)?Y:f(r.x);return e.jsxRuntimeExports.jsx(ue.motion.g,{variants:{initial:{opacity:0},whileInView:{opacity:k?k===p?1:G:H.length!==0?H.indexOf(r.id)!==-1?1:G:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},onMouseEnter:s=>{ee(r),te(s.clientY),w(s.clientX),J?.(r)},onMouseMove:s=>{ee(r),te(s.clientY),w(s.clientX)},onMouseLeave:()=>{ee(void 0),w(void 0),te(void 0),J?.(void 0)},onClick:()=>{(y||$)&&(Re.isEqual(N,r)&&he?(Q(void 0),y?.(void 0)):(Q(r),y?.(r)))},children:l===-1?null:j.features[l].geometry.type==="MultiPolygon"?j.features[l].geometry.coordinates.map((s,a)=>{let i="";return s.forEach(t=>{let o=" M";t.forEach((m,L)=>{const M=R([m[0],m[1]]);L!==t.length-1?o=`${o}${M[0]} ${M[1]}L`:o=`${o}${M[0]} ${M[1]}`}),i+=o}),e.jsxRuntimeExports.jsx(ue.motion.path,{d:i,variants:{initial:{fill:p,opacity:0},whileInView:{fill:p,opacity:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},style:{stroke:F,strokeWidth:D}},`${r.id}-${a}`)}):j.features[l].geometry.coordinates.map((s,a)=>{let i="M";return s.forEach((t,o)=>{const m=R([t[0],t[1]]);o!==s.length-1?i=`${i}${m[0]} ${m[1]}L`:i=`${i}${m[0]} ${m[1]}`}),e.jsxRuntimeExports.jsx(ue.motion.path,{d:i,variants:{initial:{fill:p,opacity:0},whileInView:{fill:p,opacity:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},style:{stroke:F,strokeWidth:D}},`${r.id}-${a}`)})},r.id)})}),_?j.features.filter(r=>r.properties[A]===_.id).map((r,l)=>e.jsxRuntimeExports.jsx("g",{children:r.geometry.type==="MultiPolygon"?r.geometry.coordinates.map((p,s)=>{let a="";return p.forEach(i=>{let t=" M";i.forEach((o,m)=>{const L=R([o[0],o[1]]);m!==i.length-1?t=`${t}${L[0]} ${L[1]}L`:t=`${t}${L[0]} ${L[1]}`}),a+=t}),e.jsxRuntimeExports.jsx("path",{d:a,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},s)}):r.geometry.coordinates.map((p,s)=>{let a="M";return p.forEach((i,t)=>{const o=R([i[0],i[1]]);t!==p.length-1?a=`${a}${o[0]} ${o[1]}L`:a=`${a}${o[0]} ${o[1]}`}),e.jsxRuntimeExports.jsx("path",{d:a,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},s)})},l)):null,ie.filter(r=>r.position==="after").map(r=>r.layer)]})}),me===!1?null:e.jsxRuntimeExports.jsx("div",{className:"absolute left-4 bottom-4",children:Z?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{style:{backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"absolute",right:"-0.75rem",top:"-0.75rem"},onClick:()=>{v(!1)},children:e.jsxRuntimeExports.jsx(ve.X,{})}),e.jsxRuntimeExports.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.7)",width:q?void 0:"340px"},children:[B&&B!==""?e.jsxRuntimeExports.jsx(ke.u,{size:"xs",marginBottom:"xs",className:"p-0 leading-normal overflow-hidden text-primary-gray-700 dark:text-primary-gray-300",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical"},children:B}):null,q?e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-3",children:h.map((r,l)=>e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{C(c[l%c.length])},onMouseLeave:()=>{C(void 0)},children:[e.jsxRuntimeExports.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:c[l%c.length]}}),e.jsxRuntimeExports.jsx(ke.u,{size:"sm",marginBottom:"none",leading:"none",children:r})]},l))}):e.jsxRuntimeExports.jsx("svg",{width:"100%",viewBox:"0 0 320 30",direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{children:[h.map((r,l)=>e.jsxRuntimeExports.jsxs("g",{onMouseOver:()=>{C(c[l])},onMouseLeave:()=>{C(void 0)},className:"cursor-pointer",children:[e.jsxRuntimeExports.jsx("rect",{x:l*320/c.length+1,y:1,width:320/c.length-2,height:8,className:k===c[l]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":"",style:{fill:c[l],...k===c[l]?{}:{stroke:c[l]}}}),e.jsxRuntimeExports.jsx("text",{x:(l+1)*320/c.length,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",style:{textAnchor:"middle"},children:Ne.numberFormattingFunction(r,"NA")})]},l)),e.jsxRuntimeExports.jsx("g",{children:e.jsxRuntimeExports.jsx("rect",{onMouseOver:()=>{C(c[h.length])},onMouseLeave:()=>{C(void 0)},x:h.length*320/c.length+1,y:1,width:320/c.length-2,height:8,className:`cursor-pointer ${k===c[h.length]?"stroke-1 stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:c[h.length],...k===c[h.length]?{}:{stroke:c[h.length]}}})})]})})]})]}):e.jsxRuntimeExports.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{v(!0)},children:e.jsxRuntimeExports.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})})}),z==="button"&&e.jsxRuntimeExports.jsxs("div",{className:"absolute left-4 top-4 flex flex-col",children:[e.jsxRuntimeExports.jsx("button",{onClick:()=>X("in"),className:"leading-0 px-2 py-3.5 text-primary-gray-700 border border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"+"}),e.jsxRuntimeExports.jsx("button",{onClick:()=>X("out"),className:"leading-0 px-2 py-3.5 text-primary-gray-700 border border-t-0 border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"–"})]})]}),$&&N!==void 0?e.jsxRuntimeExports.jsx($e.X,{open:N!==void 0,onClose:()=>{Q(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof $=="string"?{__html:Me.string2HTML($,N)}:void 0,children:typeof $=="function"?$(N):null})}):null,_&&se&&S&&ne?e.jsxRuntimeExports.jsx(Se.Tooltip,{data:_,body:se,xPos:S,yPos:ne,backgroundStyle:ge?.tooltip,className:ye?.tooltip}):null]})}function Ue(pe){const{data:E,mapData:h="https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap.json",graphTitle:c,colors:j,sources:B,graphDescription:q,height:x,width:n,footNote:ae="The designations employed and the presentation of material on this map do not imply the expression of any opinion whatsoever on the part of the Secretariat of the United Nations or UNDP concerning the legal status of any country, territory, city or area or its authorities, or concerning the delimitation of its frontiers or boundaries.",colorDomain:T,colorLegendTitle:se,scaleType:D="threshold",scale:F=.95,centerPoint:Y,padding:J,mapBorderWidth:me=.5,mapNoDataColor:xe=de.Colors.light.graphNoData,backgroundColor:O=!1,mapBorderColor:H=de.Colors.light.grays["gray-500"],relativeHeight:y,tooltip:A,onSeriesMouseOver:he,isWorldMap:$=!0,showColorScale:ge=!0,zoomScaleExtend:ye=[.8,6],zoomTranslateExtend:U,graphID:z,highlightedIds:b=[],onSeriesMouseClick:G,mapProperty:ie="ISO3",graphDownload:k=!1,dataDownload:C=!1,showAntarctica:K=!1,language:Z="en",minHeight:v=0,theme:N="light",ariaLabel:Q,resetSelectionOnDoubleClick:_=!0,detailsOnClick:ee,styles:S,classNames:w,mapProjection:ne,zoomInteraction:te="button",animate:P=!1,dimmedOpacity:re=.3,customLayers:le=[],timeline:f={enabled:!1,autoplay:!1,showOnlyActiveDate:!0}}=pe,[g,I]=d.useState(0),[oe,ce]=d.useState(0),[W,fe]=d.useState(f.autoplay),u=Fe.sort(Be.uniqBy(E,"date",!0).map(t=>be.parse(`${t}`,f.dateFormat||"yyyy",new Date).getTime()),(t,o)=>He.ascending(t,o)),[R,X]=d.useState(f.autoplay?0:u.length-1),[r,l]=d.useState(void 0),p=d.useRef(null),s=d.useRef(null);d.useEffect(()=>{const t=new ResizeObserver(o=>{I(n||o[0].target.clientWidth||760),ce(x||o[0].target.clientHeight||480)});return p.current&&(ce(p.current.clientHeight||480),I(p.current.clientWidth||760),n||t.observe(p.current)),()=>t.disconnect()},[n,x]),d.useEffect(()=>{typeof h=="string"?ze.fetchAndParseJSON(h).then(o=>{l(o)}):l(h)},[h]);const a=T||(D==="categorical"?We.getUniqValue(E,"x"):Ve.getJenks(E.map(t=>t.x),j?.length||4));d.useEffect(()=>{const t=setInterval(()=>{X(o=>o<u.length-1?o+1:0)},(f.speed||2)*1e3);return W||clearInterval(t),()=>clearInterval(t)},[u,W,f.speed]);const i=Ee.getSliderMarks(u,R,f.showOnlyActiveDate,f.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${N||"light"} flex ${n?"w-fit grow-0":"w-full grow"}`,dir:Z==="he"||Z==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${O?O===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${Z||"en"}`,n?"w-fit":"w-full",w?.graphContainer),style:{...S?.graphContainer||{},...O&&O!==!0?{backgroundColor:O}:{}},id:z,ref:s,"aria-label":Q||`${c?`The graph shows ${c}. `:""}This is a choropleth map where geographic areas are colored in proportion to a specific variable.${q?` ${q}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:O?J||"1rem":J||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[c||q||k||C?e.jsxRuntimeExports.jsx(Te.GraphHeader,{styles:{title:S?.title,description:S?.description},classNames:{title:w?.title,description:w?.description},graphTitle:c,graphDescription:q,width:n,graphDownload:k?s.current:void 0,dataDownload:C?E.map(t=>t.data).filter(t=>t!==void 0).length>0?E.map(t=>t.data).filter(t=>t!==void 0):E.filter(t=>t!==void 0):null}):null,f.enabled&&u.length>0&&i?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{fe(!W)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":W?"Click to pause animation":"Click to play animation",children:W?e.jsxRuntimeExports.jsx(ve.Pause,{}):e.jsxRuntimeExports.jsx(ve.Play,{})}),e.jsxRuntimeExports.jsx(Ee.xr,{min:u[0],max:u[u.length-1],marks:i,step:null,defaultValue:u[u.length-1],value:u[R],onChangeComplete:t=>{X(u.indexOf(t))},onChange:t=>{X(u.indexOf(t))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:p,"aria-label":"Map area",children:(n||g)&&(x||oe)&&r?e.jsxRuntimeExports.jsx(Ae,{data:E.filter(t=>f.enabled?t.date===be.format(new Date(u[R]),f.dateFormat||"yyyy"):t),mapData:K?r:{...r,features:r.features.filter(t=>t.properties.NAME!=="Antarctica")},colorDomain:a,width:n||g,height:Math.max(v,x||(y?v?(n||g)*y>v?(n||g)*y:v:(n||g)*y:oe)),scale:F,centerPoint:Y,colors:j||(D==="categorical"?de.Colors[N].sequentialColors[`neutralColorsx0${a.length}`]:de.Colors[N].sequentialColors[`neutralColorsx0${a.length+1}`]),colorLegendTitle:se,mapBorderWidth:me,mapNoDataColor:xe,categorical:D==="categorical",mapBorderColor:H,tooltip:A,onSeriesMouseOver:he,isWorldMap:$,showColorScale:ge,zoomScaleExtend:ye,zoomTranslateExtend:U,onSeriesMouseClick:G,mapProperty:ie,highlightedIds:b,resetSelectionOnDoubleClick:_,styles:S,classNames:w,detailsOnClick:ee,mapProjection:ne||($?"naturalEarth":"mercator"),zoomInteraction:te,dimmedOpacity:re,animate:P===!0?{duration:.5,once:!0,amount:.5}:P||{duration:0,once:!0,amount:0},customLayers:le}):e.jsxRuntimeExports.jsx("div",{style:{height:`${Math.max(v,x||(y?v?(n||g)*y>v?(n||g)*y:v:(n||g)*y:oe))}px`},className:"flex items-center justify-center",children:e.jsxRuntimeExports.jsx(we.y,{"aria-label":"Loading graph"})})}),B||ae?e.jsxRuntimeExports.jsx(Le.GraphFooter,{styles:{footnote:S?.footnote,source:S?.source},classNames:{footnote:w?.footnote,source:w?.source},sources:B,footNote:ae,width:n}):null]})})})})}exports.ChoroplethMap=Ue;
2
2
  //# sourceMappingURL=ChoroplethMap.cjs.map