@undp/data-viz 1.5.4 → 1.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/BarGraph.cjs CHANGED
@@ -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("./parse-hMnG_lRV.cjs"),Ie=require("./getSliderMarks-CRIbTGYV.cjs"),$e=require("./index-CQ3e6Ewi.cjs"),Ae=require("./index-DQA8q5sC.cjs"),ze=require("./Modal-tXZlLE5s.cjs"),Me=require("./numberFormattingFunction-02t-wJta.cjs"),Ve=require("./Tooltip-De16GWhY.cjs"),q=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ce=require("./Colors.cjs"),Le=require("./string2HTML-z7CwHXcx.cjs"),Ze=require("./XTicksAndGridLines-CCzXIV8d.cjs"),et=require("./YAxesLabels-CctDydGR.cjs"),Be=require("./AxisTitle-CK9YeovX.cjs"),Fe=require("./Axis-DE7dSn1_.cjs"),Pe=require("./ReferenceLine-CFVBBN__.cjs"),He=require("./use-in-view-sQJZ_xDO.cjs"),qe=require("./linear-BVckp9RD.cjs"),Te=require("./band-CAApY4Pd.cjs"),Ge=require("./index-BW8iNx7E.cjs"),fe=require("./proxy-BHRoeZgd.cjs"),Ue=require("./GraphFooter.cjs"),We=require("./GraphHeader.cjs"),Xe=require("./ColorLegendWithMouseOver.cjs"),Ye=require("./EmptyState-d8_8SxeW.cjs"),De=require("./index-BW_-wD2k.cjs"),Re=require("./ensureCompleteData-DkQYPeDa.cjs"),Se=require("./uniqBy-O05lp2S5.cjs"),_e=require("./sort-O96oMZLb.cjs"),Je=require("./init-DU0ybBc_.cjs"),ke=require("./index-CSNtgibC.cjs"),Qe=require("./getTextColorBasedOnBgColor-nqY-bsM_.cjs"),tt=require("./XAxesLabels-Drf7M3YK.cjs"),it=require("./YTicksAndGridLines-DBDuz6vb.cjs");function at(ye){const{data:o,barColor:p,suffix:G,prefix:$,barPadding:U,showValues:me,showTicks:de,leftMargin:he,truncateBy:Z,width:H,height:ie,colorDomain:N,rightMargin:ne,topMargin:ce,bottomMargin:C,showLabels:W,tooltip:J,onSeriesMouseOver:ee,refValues:j,selectedColor:y,highlightedDataPoints:V,maxValue:ae,minValue:se,onSeriesMouseClick:K,labelOrder:te,rtl:re,maxBarThickness:X,minBarThickness:pe,resetSelectionOnDoubleClick:oe,detailsOnClick:I,barAxisTitle:b,valueColor:g,noOfTicks:k,styles:D,classNames:M,animate:O,dimmedOpacity:T,precision:A,customLayers:v,naLabel:w}=ye,Y=d.useRef(null),S=He.useInView(Y,{once:O.once,amount:O.amount}),[L,le]=d.useState(void 0),[P,B]=d.useState(void 0),[Q,R]=d.useState(void 0),[F,m]=d.useState(void 0),E={top:b?ce+25:ce,bottom:C,left:he,right:ne},h=H-E.left-E.right,c=ie-E.top-E.bottom,x=o.map((s,f)=>({...s,id:te?`${s.label}`:`${f}`})),u=qe.linear().domain([se,ae]).range([0,h]).nice(),a=te||x.map(s=>`${s.id}`),r=Te.band().domain(a).range([0,pe?Math.max(c,pe*a.length):X?Math.min(c,X*a.length):c]).paddingInner(U),t=u.ticks(k);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{ref:Y,width:`${H}px`,height:`${ie}px`,viewBox:`0 0 ${H} ${ie}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${E.left},${E.top})`,children:[de?e.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:t.filter(s=>s!==0),x:t.filter(s=>s!==0).map(s=>u(s)),y1:0-ce,y2:c+E.bottom,styles:{gridLines:D?.xAxis?.gridLines,labels:D?.xAxis?.labels},classNames:{gridLines:M?.xAxis?.gridLines,labels:M?.xAxis?.labels},suffix:G,prefix:$,labelType:"secondary",showGridLines:!0,precision:A}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:h/2,y:0-E.top+15,style:D?.xAxis?.title,className:M?.xAxis?.title,text:b}),v.filter(s=>s.position==="before").map(s=>s.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[x.map(s=>q.checkIfNullOrUndefined(r(s.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{opacity:y?s.color&&p[N.indexOf(s.color)]===y?1:T:V.length!==0?V.indexOf(s.label)!==-1?.85:T:.85},whileInView:{opacity:y?s.color&&p[N.indexOf(s.color)]===y?1:T:V.length!==0?V.indexOf(s.label)!==-1?.85:T:.85,transition:{duration:O.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{opacity:0,transition:{duration:O.duration}},onMouseEnter:f=>{le(s),m(f.clientY),R(f.clientX),ee?.(s)},onClick:()=>{(K||I)&&(Ae.isEqual(P,s)&&oe?(B(void 0),K?.(void 0)):(B(s),K?.(s)))},onMouseMove:f=>{le(s),m(f.clientY),R(f.clientX)},onMouseLeave:()=>{le(void 0),R(void 0),m(void 0),ee?.(void 0)},children:[s.size?e.jsxRuntimeExports.jsx(fe.motion.rect,{variants:{initial:{width:0,x:u(0),y:r(`${s.id}`),fill:o.filter(f=>f.color).length===0?p[0]:s.color?p[N.indexOf(s.color)]:Ce.Colors.gray},whileInView:{width:s.size>=0?u(s.size)-u(0):u(0)-u(s.size),x:s.size>=0?u(0):u(s.size),y:r(`${s.id}`),fill:o.filter(f=>f.color).length===0?p[0]:s.color?p[N.indexOf(s.color)]:Ce.Colors.gray,transition:{duration:O.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{width:0,x:u(0),transition:{duration:O.duration}},height:r.bandwidth()}):null,W?e.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${s.label}`.length<Z?`${s.label}`:`${`${s.label}`.substring(0,Z)}...`,y:r(s.id)||0,x:(s.size||0)<0?u(0):0-E.left,width:(s.size||0)<0?H-u(0):u(0)+E.left,height:r.bandwidth(),alignment:s.size&&s.size<0?"left":"right",style:D?.yAxis?.labels,className:M?.yAxis?.labels,animate:O,isInView:S}):null,me?e.jsxRuntimeExports.jsx(fe.motion.text,{style:{textAnchor:s.size&&s.size<0?"end":"start",...D?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!g&&p.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",M?.graphObjectValues),dx:s.size&&s.size<0?-5:5,dy:"0.33em",variants:{initial:{x:u(0),y:r(`${s.id}`)+r.bandwidth()/2,opacity:0,fill:g||(o.filter(f=>f.color).length===0?p[0]:s.color?p[N.indexOf(s.color)]:Ce.Colors.gray)},whileInView:{x:s.size?u(s.size):u(0),opacity:1,y:r(`${s.id}`)+r.bandwidth()/2,fill:g||(o.filter(f=>f.color).length===0?p[0]:s.color?p[N.indexOf(s.color)]:Ce.Colors.gray),transition:{duration:O.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{opacity:0,transition:{duration:O.duration}},children:Me.numberFormattingFunction(s.size,w,A,$,G)}):null]},s.label)),e.jsxRuntimeExports.jsx(Fe.Axis,{x1:u(se<0?0:se),x2:u(se<0?0:se),y1:-2.5,y2:c+E.bottom,classNames:{axis:M?.yAxis?.axis},styles:{axis:D?.yAxis?.axis}}),j?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:j.map((s,f)=>e.jsxRuntimeExports.jsx(Pe.RefLineX,{text:s.text,color:s.color,x:u(s.value),y1:0-E.top,y2:c+E.bottom,textSide:u(s.value)>h*.75||re?"left":"right",classNames:s.classNames,styles:s.styles,animate:O,isInView:S},f))}):null]}),v.filter(s=>s.position==="after").map(s=>s.layer)]})}),L&&J&&Q&&F?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:L,body:J,xPos:Q,yPos:F,backgroundStyle:D?.tooltip,className:M?.tooltip}):null,I&&P!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:P!==void 0,onClose:()=>{B(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof I=="string"?{__html:Le.string2HTML(I,P)}:void 0,children:typeof I=="function"?I(P):null})}):null]})}function st(ye){const{data:o,graphTitle:p,colors:G,suffix:$="",sources:U,prefix:me="",graphDescription:de,barPadding:he=.25,showValues:Z=!0,showTicks:H=!0,leftMargin:ie=100,rightMargin:N=40,truncateBy:ne=999,height:ce,width:C,footNote:W,colorDomain:J,colorLegendTitle:ee,highlightedDataPoints:j=[],padding:y,backgroundColor:V=!1,topMargin:ae=25,bottomMargin:se=10,showLabels:K=!0,relativeHeight:te,tooltip:re,onSeriesMouseOver:X,refValues:pe,showColorScale:oe=!0,graphID:I,maxValue:b,minValue:g,onSeriesMouseClick:k,graphDownload:D=!1,dataDownload:M=!1,sortData:O,labelOrder:T,language:A="en",showNAColor:v=!0,minHeight:w=0,theme:Y="light",maxBarThickness:S,maxNumberOfBars:L,minBarThickness:le,ariaLabel:P,resetSelectionOnDoubleClick:B=!0,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F=5,valueColor:m,styles:E,classNames:h,filterNA:c=!0,animate:x=!1,dimmedOpacity:u=.3,precision:a=2,customLayers:r=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:s="NA"}=ye,[f,we]=d.useState(0),[ue,_]=d.useState(0),[ge,Oe]=d.useState(t.autoplay),xe=_e.sort(Se.uniqBy(o,"date",!0).map(n=>Ee.parse(`${n}`,t.dateFormat||"yyyy",new Date).getTime()),(n,je)=>Je.ascending(n,je)),[be,ve]=d.useState(t.autoplay?0:xe.length-1),[Ne,l]=d.useState(void 0),i=d.useRef(null),z=d.useRef(null);d.useEffect(()=>{const n=new ResizeObserver(je=>{we(C||je[0].target.clientWidth||620),_(ce||je[0].target.clientHeight||480)});return i.current&&(_(i.current.clientHeight||480),we(i.current.clientWidth||620),C||n.observe(i.current)),()=>n.disconnect()},[C,ce]),d.useEffect(()=>{const n=setInterval(()=>{ve(je=>je<xe.length-1?je+1:0)},(t.speed||2)*1e3);return ge||clearInterval(n),()=>clearInterval(n)},[xe,ge,t.speed]);const Ke=Ie.getSliderMarks(xe,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${Y||"light"} flex ${C?"w-fit grow-0":"w-full grow"}`,dir:A==="he"||A==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${V?V===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${A||"en"}`,C?"w-fit":"w-full",h?.graphContainer),style:{...E?.graphContainer||{},...V&&V!==!0?{backgroundColor:V}:{}},id:I,ref:z,"aria-label":P||`${p?`The graph shows ${p}. `:""}This is a bar chart. ${de?` ${de}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:V?y||"1rem":y||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||de||D||M?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:E?.title,description:E?.description},classNames:{title:h?.title,description:h?.description},graphTitle:p,graphDescription:de,width:C,graphDownload:D?z.current:void 0,dataDownload:M?o.map(n=>n.data).filter(n=>n!==void 0).length>0?o.map(n=>n.data).filter(n=>n!==void 0):o.filter(n=>n!==void 0):null}):null,t.enabled&&xe.length>0&&Ke?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Oe(!ge)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ge?"Click to pause animation":"Click to play animation",children:ge?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Ie.xr,{min:xe[0],max:xe[xe.length-1],marks:Ke,step:null,defaultValue:xe[xe.length-1],value:xe[be],onChangeComplete:n=>{ve(xe.indexOf(n))},onChange:n=>{ve(xe.indexOf(n))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[oe&&o.filter(n=>n.color).length!==0?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:C,colorLegendTitle:ee,colors:G||Ce.Colors[Y].categoricalColors.colors,colorDomain:J||Se.uniqBy(o,"color",!0),setSelectedColor:l,showNAColor:v}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:i,"aria-label":"Graph area",children:(C||f)&&(ce||ue)?e.jsxRuntimeExports.jsx(at,{data:O?$e.orderBy(Re.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(n=>t.enabled?n.date===Ee.format(new Date(xe[be]),t.dateFormat||"yyyy"):n).filter(n=>c?!q.checkIfNullOrUndefined(n.size):n),[n=>n.size===void 0?O==="asc"?1/0:-1/0:n.size],[O]).filter((n,je)=>L?je<L:!0):Re.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(n=>t.enabled?n.date===Ee.format(new Date(xe[be]),t.dateFormat||"yyyy"):n).filter(n=>c?!q.checkIfNullOrUndefined(n.size):n).filter((n,je)=>L?je<L:!0),barColor:o.filter(n=>n.color).length===0?G?[G]:[Ce.Colors.primaryColors["blue-600"]]:G||Ce.Colors[Y].categoricalColors.colors,colorDomain:o.filter(n=>n.color).length===0?[]:J||Se.uniqBy(o,"color",!0),width:C||f,selectedColor:Ne,height:Math.max(w,ce||(te?w?(C||f)*te>w?(C||f)*te:w:(C||f)*te:ue)),suffix:$,prefix:me,barPadding:he,showValues:Z,showTicks:H,leftMargin:ie,rightMargin:N,topMargin:ae,bottomMargin:se,truncateBy:ne,showLabels:K,tooltip:re,onSeriesMouseOver:X,refValues:pe,maxValue:q.checkIfNullOrUndefined(b)?Math.max(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size))<0?0:Math.max(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size)):b,minValue:q.checkIfNullOrUndefined(g)?Math.min(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size))>=0?0:Math.min(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size)):g,highlightedDataPoints:j,onSeriesMouseClick:k,labelOrder:T,rtl:A==="he"||A==="ar",maxBarThickness:S,minBarThickness:le,resetSelectionOnDoubleClick:B,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F,valueColor:m,classNames:h,styles:E,animate:x===!0?{duration:.5,once:!0,amount:.5}:x||{duration:0,once:!0,amount:0},dimmedOpacity:u,precision:a,customLayers:r,naLabel:s}):null})]})}),U||W?e.jsxRuntimeExports.jsx(Ue.GraphFooter,{sources:U,footNote:W,width:C,styles:{footnote:E?.footnote,source:E?.source},classNames:{footnote:h?.footnote,source:h?.source}}):null]})})})})}function rt(ye){const{data:o,barColors:p,barPadding:G,showTicks:$,leftMargin:U,truncateBy:me,width:de,height:he,suffix:Z,prefix:H,showValues:ie,rightMargin:N,topMargin:ne,bottomMargin:ce,showLabels:C,tooltip:W,onSeriesMouseOver:J,refValues:ee,maxValue:j,minValue:y,onSeriesMouseClick:V,selectedColor:ae,rtl:se,labelOrder:K,maxBarThickness:te,resetSelectionOnDoubleClick:re,detailsOnClick:X,barAxisTitle:pe,valueColor:oe,noOfTicks:I,styles:b,classNames:g,animate:k,colorDomain:D,precision:M,customLayers:O,naLabel:T}=ye,A=d.useRef(null),v=He.useInView(A,{once:k.once,amount:k.amount}),w={top:pe?ne+25:ne,bottom:ce,left:U,right:N},[Y,S]=d.useState(void 0),[L,le]=d.useState(void 0),[P,B]=d.useState(void 0),[Q,R]=d.useState(void 0),F=de-w.left-w.right,m=he-w.top-w.bottom,E=o.map((r,t)=>({...r,id:K?`${r.label}`:`${t}`})),h=K||E.map(r=>`${r.id}`),c=qe.linear().domain([y,j]).range([0,F]).nice(),x=Te.band().domain(h).range([0,te?Math.min(m,te*h.length):m]).paddingInner(G),u=Te.band().domain(o[0].size.map((r,t)=>`${t}`)).range([0,x.bandwidth()]).paddingInner(.1),a=c.ticks(I);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{ref:A,width:`${de}px`,height:`${he}px`,viewBox:`0 0 ${de} ${he}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${w.left},${w.top})`,children:[$?e.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:a.filter(r=>r!==0),x:a.filter(r=>r!==0).map(r=>c(r)),y1:0-ne,y2:m+w.bottom,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.xAxis?.labels},classNames:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},suffix:Z,prefix:H,labelType:"secondary",showGridLines:!0,precision:M}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:F/2,y:0-w.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),O.filter(r=>r.position==="before").map(r=>r.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[E.map(r=>q.checkIfNullOrUndefined(x(r.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{variants:{initial:{x:0,y:x(`${r.id}`)},whileInView:{x:0,y:x(`${r.id}`),transition:{duration:k.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:k.duration}},children:[r.size.map((t,s)=>e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?p[s]===ae?1:.3:.85,onMouseEnter:f=>{S({...r,sizeIndex:s}),R(f.clientY),B(f.clientX),J?.({...r,sizeIndex:s})},onMouseMove:f=>{S({...r,sizeIndex:s}),R(f.clientY),B(f.clientX)},onMouseLeave:()=>{S(void 0),B(void 0),R(void 0),J?.(void 0)},onClick:()=>{(V||X)&&(Ae.isEqual(L,{...r,sizeIndex:s})&&re?(le(void 0),V?.(void 0)):(le({...r,sizeIndex:s}),V&&V({...r,sizeIndex:s})))},children:[q.checkIfNullOrUndefined(t)?null:e.jsxRuntimeExports.jsx(fe.motion.rect,{y:u(`${s}`),variants:{initial:{width:0,x:c(0),fill:p[s]},whileInView:{width:q.checkIfNullOrUndefined(t)?0:t>=0?c(t)-c(0):c(0)-c(t),x:t>=0?c(0):c(t),fill:p[s],transition:{duration:k.duration}}},exit:{width:0,x:c(0),transition:{duration:k.duration}},height:u.bandwidth(),initial:"initial",animate:v?"whileInView":"initial"}),ie?e.jsxRuntimeExports.jsx(fe.motion.text,{y:u(`${s}`)+u.bandwidth()/2,style:{fill:oe||p[s],textAnchor:t&&t<0?"end":"start",...b?.graphObjectValues||{}},className:e.mo("graph-value text-sm",g?.graphObjectValues),dx:t&&t<0?-5:5,dy:"0.33em",variants:{initial:{x:c(0),opacity:0},whileInView:{x:c(t||0),opacity:1,transition:{duration:k.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:k.duration}},children:Me.numberFormattingFunction(t,T,M,H,Z)}):null]},`${r.label}-${D[s]||s}`)),C?e.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${r.label}`.length<me?`${r.label}`:`${`${r.label}`.substring(0,me)}...`,y:0,x:0-w.left,width:c(y<0?0:y)+w.left,height:x.bandwidth(),style:b?.yAxis?.labels,className:g?.yAxis?.labels,animate:k,isInView:v}):null]},r.label)),e.jsxRuntimeExports.jsx(Fe.Axis,{x1:c(y<0?0:y),x2:c(y<0?0:y),y1:-2.5,y2:m+w.bottom,classNames:{axis:g?.yAxis?.axis},styles:{axis:b?.yAxis?.axis}}),ee?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ee.map((r,t)=>e.jsxRuntimeExports.jsx(Pe.RefLineX,{text:r.text,color:r.color,x:c(r.value),y1:0-w.top,y2:m+w.bottom,textSide:c(r.value)>F*.75||se?"left":"right",classNames:r.classNames,styles:r.styles,animate:k,isInView:v},t))}):null]}),O.filter(r=>r.position==="after").map(r=>r.layer)]})}),Y&&W&&P&&Q?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:Y,body:W,xPos:P,yPos:Q,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,X&&L!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:L!==void 0,onClose:()=>{le(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof X=="string"?{__html:Le.string2HTML(X,L)}:void 0,children:typeof X=="function"?X(L):null})}):null]})}function nt(ye){const{data:o,graphTitle:p,colors:G=Ce.Colors.light.categoricalColors.colors,sources:$,graphDescription:U,barPadding:me=.25,showTicks:de=!0,truncateBy:he=999,height:Z,width:H,footNote:ie,colorDomain:N,colorLegendTitle:ne,suffix:ce="",prefix:C="",showValues:W=!0,showColorScale:J=!0,padding:ee,backgroundColor:j=!1,leftMargin:y=100,rightMargin:V=40,topMargin:ae=25,bottomMargin:se=10,showLabels:K=!0,relativeHeight:te,tooltip:re,onSeriesMouseOver:X,refValues:pe,graphID:oe,maxValue:I,minValue:b,onSeriesMouseClick:g,graphDownload:k=!1,dataDownload:D=!1,language:M="en",labelOrder:O,minHeight:T=0,theme:A="light",maxBarThickness:v,ariaLabel:w,resetSelectionOnDoubleClick:Y=!0,detailsOnClick:S,barAxisTitle:L,noOfTicks:le=5,valueColor:P,styles:B,classNames:Q,filterNA:R=!0,animate:F=!1,precision:m=2,customLayers:E=[],timeline:h={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:c="NA",sortParameter:x,sortData:u}=ye,[a,r]=d.useState(0),[t,s]=d.useState(0),[f,we]=d.useState(h.autoplay),ue=_e.sort(Se.uniqBy(o,"date",!0).map(l=>Ee.parse(`${l}`,h.dateFormat||"yyyy",new Date).getTime()),(l,i)=>Je.ascending(l,i)),[_,ge]=d.useState(h.autoplay?0:ue.length-1),[Oe,xe]=d.useState(void 0),be=d.useRef(null),ve=d.useRef(null);d.useEffect(()=>{const l=new ResizeObserver(i=>{r(H||i[0].target.clientWidth||620),s(Z||i[0].target.clientHeight||480)});return be.current&&(s(be.current.clientHeight||480),r(be.current.clientWidth||620),H||l.observe(be.current)),()=>l.disconnect()},[H,Z]),d.useEffect(()=>{const l=setInterval(()=>{ge(i=>i<ue.length-1?i+1:0)},(h.speed||2)*1e3);return f||clearInterval(l),()=>clearInterval(l)},[ue,f,h.speed]);const Ne=Ie.getSliderMarks(ue,_,h.showOnlyActiveDate,h.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${A||"light"} flex ${H?"w-fit grow-0":"w-full grow"}`,dir:M==="he"||M==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${j?j===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,H?"w-fit":"w-full",Q?.graphContainer),style:{...B?.graphContainer||{},...j&&j!==!0?{backgroundColor:j}:{}},id:oe,ref:ve,"aria-label":w||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${U?` ${U}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:j?ee||"1rem":ee||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[p||U||k||D?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:B?.title,description:B?.description},classNames:{title:Q?.title,description:Q?.description},graphTitle:p,graphDescription:U,width:H,graphDownload:k?ve.current:void 0,dataDownload:D?o.map(l=>l.data).filter(l=>l!==void 0).length>0?o.map(l=>l.data).filter(l=>l!==void 0):o.filter(l=>l!==void 0):null}):null,h.enabled&&ue.length>0&&Ne?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!f)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":f?"Click to pause animation":"Click to play animation",children:f?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Ie.xr,{min:ue[0],max:ue[ue.length-1],marks:Ne,step:null,defaultValue:ue[ue.length-1],value:ue[_],onChangeComplete:l=>{ge(ue.indexOf(l))},onChange:l=>{ge(ue.indexOf(l))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[J?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:H,colorDomain:N,colors:G,colorLegendTitle:ne,setSelectedColor:xe,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:be,"aria-label":"Graph area",children:(H||a)&&(Z||t)?e.jsxRuntimeExports.jsx(rt,{data:x!==void 0?x==="total"?$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>h.enabled?l.date===Ee.format(new Date(ue[_]),h.dateFormat||"yyyy"):l).filter(l=>R?!l.size.every(i=>i==null):l),l=>ke.sum(l.size.filter(i=>!q.checkIfNullOrUndefined(i))),[u||"asc"]):$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>h.enabled?l.date===Ee.format(new Date(ue[_]),h.dateFormat||"yyyy"):l).filter(l=>R?!l.size.every(i=>i==null):l),l=>q.checkIfNullOrUndefined(l.size[x])?-1/0:l.size[x],[u||"asc"]):Re.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>R?!l.size.every(i=>i==null):l),barColors:G,width:H||a,height:Math.max(T,Z||(te?T?(H||a)*te>T?(H||a)*te:T:(H||a)*te:t)),suffix:ce,prefix:C,showValues:W,barPadding:me,showTicks:de,leftMargin:y,rightMargin:V,topMargin:ae,bottomMargin:se,truncateBy:he,showLabels:K,tooltip:re,onSeriesMouseOver:X,refValues:pe,maxValue:q.checkIfNullOrUndefined(I)?Math.max(...o.map(l=>Math.max(...l.size.filter(i=>!q.checkIfNullOrUndefined(i)))))<0?0:Math.max(...o.map(l=>Math.max(...l.size.filter(i=>!q.checkIfNullOrUndefined(i))))):I,minValue:q.checkIfNullOrUndefined(b)?Math.min(...o.map(l=>Math.min(...l.size.filter(i=>!q.checkIfNullOrUndefined(i)))))>=0?0:Math.min(...o.map(l=>Math.min(...l.size.filter(i=>!q.checkIfNullOrUndefined(i))))):b,onSeriesMouseClick:g,selectedColor:Oe,labelOrder:O,rtl:M==="he"||M==="ar",maxBarThickness:v,resetSelectionOnDoubleClick:Y,detailsOnClick:S,barAxisTitle:L,noOfTicks:le,valueColor:P,styles:B,classNames:Q,colorDomain:N,animate:F===!0?{duration:.5,once:!0,amount:.5}:F||{duration:0,once:!0,amount:0},precision:m,customLayers:E,naLabel:c}):null})]})}),$||ie?e.jsxRuntimeExports.jsx(Ue.GraphFooter,{styles:{footnote:B?.footnote,source:B?.source},classNames:{footnote:Q?.footnote,source:Q?.source},sources:$,footNote:ie,width:H}):null]})})})})}function lt(ye){const{data:o,barColors:p,barPadding:G,showTicks:$,leftMargin:U,rightMargin:me,truncateBy:de,width:he,height:Z,topMargin:H,bottomMargin:ie,tooltip:N,onSeriesMouseOver:ne,showLabels:ce,suffix:C,prefix:W,showValues:J,refValues:ee,maxValue:j,onSeriesMouseClick:y,selectedColor:V,rtl:ae,labelOrder:se,maxBarThickness:K,minBarThickness:te,resetSelectionOnDoubleClick:re,detailsOnClick:X,barAxisTitle:pe,valueColor:oe,noOfTicks:I,styles:b,classNames:g,animate:k,colorDomain:D,precision:M,customLayers:O,naLabel:T}=ye,A=d.useRef(null),v=He.useInView(A,{once:k.once,amount:k.amount}),w={top:pe?H+25:H,bottom:ie,left:U,right:me},[Y,S]=d.useState(void 0),[L,le]=d.useState(void 0),[P,B]=d.useState(void 0),[Q,R]=d.useState(void 0),F=he-w.left-w.right,m=Z-w.top-w.bottom,E=o.map((a,r)=>({...a,id:se?`${a.label}`:`${r}`})),h=se||E.map(a=>`${a.id}`),c=qe.linear().domain([0,j]).range([0,F]).nice(),x=Te.band().domain(h).range([0,te?Math.max(m,te*h.length):K?Math.min(m,K*h.length):m]).paddingInner(G),u=c.ticks(I);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{ref:A,width:`${he}px`,height:`${Z}px`,viewBox:`0 0 ${he} ${Z}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${w.left},${w.top})`,children:[$?e.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:u.filter(a=>a!==0),x:u.filter(a=>a!==0).map(a=>c(a)),y1:0-H,y2:m+w.bottom,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.xAxis?.labels},classNames:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},suffix:C,prefix:W,labelType:"secondary",showGridLines:!0,precision:M}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:F/2,y:0-w.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),O.filter(a=>a.position==="before").map(a=>a.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[E.map(a=>q.checkIfNullOrUndefined(x(a.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",variants:{initial:{x:0,y:x(`${a.id}`)},whileInView:{x:0,y:x(`${a.id}`),transition:{duration:k.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:k.duration}},children:[a.size.map((r,t)=>e.jsxRuntimeExports.jsxs(fe.motion.g,{opacity:V?p[t]===V?1:.3:1,onMouseEnter:s=>{S({...a,sizeIndex:t}),R(s.clientY),B(s.clientX),ne?.({...a,sizeIndex:t})},onMouseMove:s=>{S({...a,sizeIndex:t}),R(s.clientY),B(s.clientX)},onMouseLeave:()=>{S(void 0),B(void 0),R(void 0),ne?.(void 0)},onClick:()=>{(y||X)&&(Ae.isEqual(L,{...a,sizeIndex:t})&&re?(le(void 0),y?.(void 0)):(le({...a,sizeIndex:t}),y&&y({...a,sizeIndex:t})))},children:[r?e.jsxRuntimeExports.jsx(fe.motion.rect,{y:0,style:{fill:p[t]},height:x.bandwidth(),exit:{width:0,x:c(0),transition:{duration:k.duration}},variants:{initial:{width:0,x:c(0),fill:p[t]},whileInView:{width:c(r||0),x:c(t===0?0:ke.sum(a.size.filter((s,f)=>f<t&&s))),fill:p[t],transition:{duration:k.duration}}},initial:"initial",animate:v?"whileInView":"initial"},t):null,J?e.jsxRuntimeExports.jsx(fe.motion.text,{y:x.bandwidth()/2,style:{textAnchor:"middle",...b?.graphObjectValues||{}},dy:"0.33em",className:e.mo("graph-value text-sm",g?.graphObjectValues),exit:{opacity:0,transition:{duration:k.duration}},variants:{initial:{x:c(0),opacity:0,fill:Qe.getTextColorBasedOnBgColor(p[t])},whileInView:{x:c(t===0?0:ke.sum(a.size.filter((s,f)=>f<t&&s)))+c(r||0)/2,opacity:r&&c(r)/Me.numberFormattingFunction(r,T,M,W,C).length>12?1:0,fill:Qe.getTextColorBasedOnBgColor(p[t]),transition:{duration:k.duration}}},initial:"initial",animate:v?"whileInView":"initial",children:Me.numberFormattingFunction(r,T,M,W,C)}):null]},`${a.label}-${D[t]||t}`)),ce?e.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${a.label}`.length<de?`${a.label}`:`${`${a.label}`.substring(0,de)}...`,y:0,x:0-w.left,width:0+w.left,height:x.bandwidth(),style:b?.yAxis?.labels,className:g?.yAxis?.labels,animate:k,isInView:v}):null,J?e.jsxRuntimeExports.jsx(fe.motion.text,{className:e.mo("graph-value graph-value-total text-sm",oe?"":" fill-primary-gray-700 dark:fill-primary-gray-300",g?.graphObjectValues),style:{...oe?{fill:oe}:{},textAnchor:"start",...b?.graphObjectValues||{}},y:x.bandwidth()/2,dx:5,dy:"0.33em",variants:{initial:{x:c(0),opacity:0},whileInView:{x:c(ke.sum(a.size.map(r=>r||0))),opacity:1,transition:{duration:k.duration}}},exit:{opacity:0,transition:{duration:k.duration}},initial:"initial",animate:v?"whileInView":"initial",children:Me.numberFormattingFunction(ke.sum(a.size.filter(r=>r)),T,M,W,C)}):null]},a.label)),e.jsxRuntimeExports.jsx(Fe.Axis,{x1:c(0),x2:c(0),y1:-2.5,y2:m+w.bottom,classNames:{axis:g?.yAxis?.axis},styles:{axis:b?.yAxis?.axis}}),ee?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ee.map((a,r)=>e.jsxRuntimeExports.jsx(Pe.RefLineX,{text:a.text,color:a.color,x:c(a.value),y1:0-w.top,y2:m+w.bottom,textSide:c(a.value)>F*.75||ae?"left":"right",classNames:a.classNames,styles:a.styles,animate:k,isInView:v},r))}):null]}),O.filter(a=>a.position==="after").map(a=>a.layer)]})}),Y&&N&&P&&Q?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:Y,body:N,xPos:P,yPos:Q,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,X&&L!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:L!==void 0,onClose:()=>{le(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof X=="string"?{__html:Le.string2HTML(X,L)}:void 0,children:typeof X=="function"?X(L):null})}):null]})}function ot(ye){const{data:o,graphTitle:p,colors:G=Ce.Colors.light.categoricalColors.colors,sources:$,graphDescription:U,barPadding:me=.25,showTicks:de=!0,leftMargin:he=100,rightMargin:Z=40,truncateBy:H=999,height:ie,width:N,footNote:ne,colorDomain:ce,colorLegendTitle:C,padding:W,backgroundColor:J=!1,topMargin:ee=25,bottomMargin:j=10,tooltip:y,onSeriesMouseOver:V,suffix:ae="",prefix:se="",showLabels:K=!0,relativeHeight:te,showValues:re=!0,refValues:X,graphID:pe,maxValue:oe,onSeriesMouseClick:I,graphDownload:b=!1,dataDownload:g=!1,language:k="en",labelOrder:D,minHeight:M=0,theme:O="light",maxBarThickness:T,sortParameter:A,maxNumberOfBars:v,minBarThickness:w,showColorScale:Y=!0,ariaLabel:S,resetSelectionOnDoubleClick:L=!0,detailsOnClick:le,barAxisTitle:P,noOfTicks:B=5,valueColor:Q,styles:R,classNames:F,filterNA:m=!0,animate:E=!1,precision:h=2,customLayers:c=[],timeline:x={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:u="NA",sortData:a}=ye,[r,t]=d.useState(0),[s,f]=d.useState(0),[we,ue]=d.useState(x.autoplay),_=_e.sort(Se.uniqBy(o,"date",!0).map(i=>Ee.parse(`${i}`,x.dateFormat||"yyyy",new Date).getTime()),(i,z)=>Je.ascending(i,z)),[ge,Oe]=d.useState(x.autoplay?0:_.length-1),[xe,be]=d.useState(void 0),ve=d.useRef(null),Ne=d.useRef(null);d.useEffect(()=>{const i=new ResizeObserver(z=>{t(N||z[0].target.clientWidth||620),f(ie||z[0].target.clientHeight||480)});return ve.current&&(f(ve.current.clientHeight||480),t(ve.current.clientWidth||620),N||i.observe(ve.current)),()=>i.disconnect()},[N,ie]),d.useEffect(()=>{const i=setInterval(()=>{Oe(z=>z<_.length-1?z+1:0)},(x.speed||2)*1e3);return we||clearInterval(i),()=>clearInterval(i)},[_,we,x.speed]);const l=Ie.getSliderMarks(_,ge,x.showOnlyActiveDate,x.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${O||"light"} flex ${N?"w-fit grow-0":"w-full grow"}`,dir:k==="he"||k==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${J?J===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${k||"en"}`,N?"w-fit":"w-full",F?.graphContainer),style:{...R?.graphContainer||{},...J&&J!==!0?{backgroundColor:J}:{}},id:pe,ref:Ne,"aria-label":S||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${U?` ${U}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:J?W||"1rem":W||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[p||U||b||g?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:R?.title,description:R?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:U,width:N,graphDownload:b?Ne.current:void 0,dataDownload:g?o.map(i=>i.data).filter(i=>i!==void 0).length>0?o.map(i=>i.data).filter(i=>i!==void 0):o.filter(i=>i!==void 0):null}):null,x.enabled&&_.length>0&&l?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{ue(!we)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":we?"Click to pause animation":"Click to play animation",children:we?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Ie.xr,{min:_[0],max:_[_.length-1],marks:l,step:null,defaultValue:_[_.length-1],value:_[ge],onChangeComplete:i=>{Oe(_.indexOf(i))},onChange:i=>{Oe(_.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[Y?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:N,colorDomain:ce,colors:G,colorLegendTitle:C,setSelectedColor:be,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:ve,"aria-label":"Graph area",children:(N||r)&&(ie||s)?e.jsxRuntimeExports.jsx(lt,{data:A!==void 0?A==="total"?$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===Ee.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(z=>z==null):i),i=>ke.sum(i.size.filter(z=>!q.checkIfNullOrUndefined(z))),[a||"asc"]).filter((i,z)=>v?z<v:!0):$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===Ee.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(z=>z==null):i),i=>q.checkIfNullOrUndefined(i.size[A])?-1/0:i.size[A],[a||"asc"]).filter((i,z)=>v?z<v:!0):Re.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===Ee.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(z=>z==null):i).filter((i,z)=>v?z<v:!0),barColors:G,width:N||r,height:Math.max(M,ie||(te?M?(N||r)*te>M?(N||r)*te:M:(N||r)*te:s)),barPadding:me,showTicks:de,leftMargin:he,rightMargin:Z,topMargin:ee,bottomMargin:j,truncateBy:H,showLabels:K,tooltip:y,onSeriesMouseOver:V,showValues:re,suffix:ae,prefix:se,refValues:X,maxValue:q.checkIfNullOrUndefined(oe)?Math.max(...o.map(i=>ke.sum(i.size.filter(z=>!q.checkIfNullOrUndefined(z)))||0)):oe,onSeriesMouseClick:I,selectedColor:xe,rtl:k==="he"||k==="ar",labelOrder:D,maxBarThickness:T,minBarThickness:w,resetSelectionOnDoubleClick:L,detailsOnClick:le,barAxisTitle:P,noOfTicks:B,valueColor:Q,classNames:F,styles:R,animate:E===!0?{duration:.5,once:!0,amount:.5}:E||{duration:0,once:!0,amount:0},colorDomain:ce,precision:h,customLayers:c,naLabel:u}):null})]})}),$||ne?e.jsxRuntimeExports.jsx(Ue.GraphFooter,{styles:{footnote:R?.footnote,source:R?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:$,footNote:ne,width:N}):null]})})})})}function ut(ye){const{data:o,width:p,height:G,barColor:$,suffix:U,prefix:me,barPadding:de,showLabels:he,showValues:Z,showTicks:H,colorDomain:ie,truncateBy:N,rightMargin:ne,topMargin:ce,bottomMargin:C,leftMargin:W,tooltip:J,onSeriesMouseOver:ee,refValues:j,selectedColor:y,maxValue:V,minValue:ae,highlightedDataPoints:se,onSeriesMouseClick:K,labelOrder:te,maxBarThickness:re,minBarThickness:X,resetSelectionOnDoubleClick:pe,detailsOnClick:oe,barAxisTitle:I,valueColor:b,noOfTicks:g,styles:k,classNames:D,dimmedOpacity:M,animate:O,precision:T,customLayers:A,naLabel:v}=ye,w=d.useRef(null),Y=He.useInView(w,{once:O.once,amount:O.amount}),S={top:ce,bottom:C,left:I?W+30:W,right:ne},[L,le]=d.useState(void 0),[P,B]=d.useState(void 0),[Q,R]=d.useState(void 0),[F,m]=d.useState(void 0),E=p-S.left-S.right,h=G-S.top-S.bottom,c=qe.linear().domain([ae,V]).range([h,0]).nice(),x=o.map((t,s)=>({...t,id:te?`${t.label}`:`${s}`})),u=te||x.map(t=>`${t.id}`),a=Te.band().domain(u).range([0,X?Math.max(E,X*u.length):re?Math.min(E,re*u.length):E]).paddingInner(de),r=c.ticks(g);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{ref:w,width:`${p}px`,height:`${G}px`,viewBox:`0 0 ${p} ${G}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${S.left},${S.top})`,children:[e.jsxRuntimeExports.jsx(Fe.Axis,{y1:c(ae<0?0:ae),y2:c(ae<0?0:ae),x1:0-W,x2:E+S.right,label:Me.numberFormattingFunction(ae<0?0:ae,v,T,me,U),labelPos:{x:0-W,dx:0,dy:V<0?"1em":-5,y:c(ae<0?0:ae)},classNames:{axis:D?.xAxis?.axis,label:D?.yAxis?.labels},styles:{axis:k?.xAxis?.axis,label:k?.yAxis?.labels}}),H?e.jsxRuntimeExports.jsx(it.YTicksAndGridLines,{values:r.filter(t=>t!==0),y:r.filter(t=>t!==0).map(t=>c(t)),x1:0-W,x2:E+S.right,styles:{gridLines:k?.yAxis?.gridLines,labels:k?.yAxis?.labels},classNames:{gridLines:D?.yAxis?.gridLines,labels:D?.yAxis?.labels},suffix:U,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:T}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:0-W-15,y:h/2,style:k?.yAxis?.title,className:D?.yAxis?.title,text:I,rotate90:!0}),A.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[x.map((t,s)=>q.checkIfNullOrUndefined(a(t.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-g-with-hover",initial:"initial",animate:Y?"whileInView":"initial",variants:{initial:{opacity:y?t.color&&$[ie.indexOf(t.color)]===y?1:M:se.length!==0?se.indexOf(t.label)!==-1?.85:M:.85},whileInView:{opacity:y?t.color&&$[ie.indexOf(t.color)]===y?1:M:se.length!==0?se.indexOf(t.label)!==-1?.85:M:.85,transition:{duration:O.duration}}},exit:{opacity:0,transition:{duration:O.duration}},onMouseEnter:f=>{le(t),m(f.clientY),R(f.clientX),ee?.(t)},onClick:()=>{(K||oe)&&(Ae.isEqual(P,t)&&pe?(B(void 0),K?.(void 0)):(B(t),K?.(t)))},onMouseMove:f=>{le(t),m(f.clientY),R(f.clientX)},onMouseLeave:()=>{le(void 0),R(void 0),m(void 0),ee?.(void 0)},children:[t.size?e.jsxRuntimeExports.jsx(fe.motion.rect,{width:a.bandwidth(),initial:"initial",animate:Y?"whileInView":"initial",variants:{initial:{height:0,x:a(`${t.id}`),y:c(0),fill:o.filter(f=>f.color).length===0?$[0]:t.color?$[ie.indexOf(t.color)]:Ce.Colors.gray},whileInView:{height:t.size?Math.abs(c(t.size)-c(0)):0,y:t.size&&t.size>0?c(t.size):c(0),x:a(`${t.id}`),fill:o.filter(f=>f.color).length===0?$[0]:t.color?$[ie.indexOf(t.color)]:Ce.Colors.gray,transition:{duration:O.duration}}},exit:{height:0,y:c(0),transition:{duration:O.duration}}}):null,he?e.jsxRuntimeExports.jsx(tt.XAxesLabels,{value:`${t.label}`.length<N?`${t.label}`:`${`${t.label}`.substring(0,N)}...`,y:(t.size||0)<0?0:c(0)+5,x:a(`${t.id}`),width:a.bandwidth(),height:(t.size||0)<0?c(0)-5:S.bottom,style:k?.xAxis?.labels,className:D?.xAxis?.labels,alignment:(t.size||0)<0?"bottom":"top",animate:O,isInView:Y}):null,Z?e.jsxRuntimeExports.jsx(fe.motion.text,{style:{textAnchor:"middle",...k?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!b&&$.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",D?.graphObjectValues),dy:t.size?t.size>=0?"-5px":"1em":"-5px",variants:{initial:{x:a(`${t.id}`)+a.bandwidth()/2,y:c(0),opacity:0,fill:b||(o.filter(f=>f.color).length===0?$[0]:t.color?$[ie.indexOf(t.color)]:Ce.Colors.gray)},whileInView:{x:a(`${t.id}`)+a.bandwidth()/2,y:c(t.size||0),fill:b||(o.filter(f=>f.color).length===0?$[0]:t.color?$[ie.indexOf(t.color)]:Ce.Colors.gray),opacity:1,transition:{duration:O.duration}}},initial:"initial",animate:Y?"whileInView":"initial",exit:{opacity:0,transition:{duration:O.duration}},children:Me.numberFormattingFunction(t.size,v,T,me,U)}):null]},t.label)),j?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:j.map((t,s)=>e.jsxRuntimeExports.jsx(Pe.RefLineY,{text:t.text,color:t.color,y:c(t.value),x1:0-W,x2:E+S.right,classNames:t.classNames,styles:t.styles,animate:O,isInView:Y},s))}):null]}),A.filter(t=>t.position==="after").map(t=>t.layer)]})}),L&&J&&Q&&F?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:L,body:J,xPos:Q,yPos:F,backgroundStyle:k?.tooltip,className:D?.tooltip}):null,oe&&P!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:P!==void 0,onClose:()=>{B(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof oe=="string"?{__html:Le.string2HTML(oe,P)}:void 0,children:typeof oe=="function"?oe(P):null})}):null]})}function ct(ye){const{data:o,graphTitle:p,colors:G,barPadding:$=.25,showTicks:U=!0,leftMargin:me=20,rightMargin:de=20,topMargin:he=20,bottomMargin:Z=25,truncateBy:H=999,showLabels:ie=!0,showValues:N=!0,backgroundColor:ne=!1,suffix:ce="",prefix:C="",sources:W,graphDescription:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,showColorScale:pe=!0,graphID:oe,maxValue:I,minValue:b,highlightedDataPoints:g=[],onSeriesMouseClick:k,graphDownload:D=!1,dataDownload:M=!1,language:O="en",theme:T="light",sortData:A,labelOrder:v,showNAColor:w=!0,minHeight:Y=0,maxBarThickness:S,maxNumberOfBars:L,minBarThickness:le,ariaLabel:P,resetSelectionOnDoubleClick:B=!0,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F=5,valueColor:m,styles:E,classNames:h,filterNA:c=!0,animate:x=!1,dimmedOpacity:u=.3,precision:a=2,customLayers:r=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:s="NA"}=ye,[f,we]=d.useState(0),[ue,_]=d.useState(0),[ge,Oe]=d.useState(t.autoplay),xe=_e.sort(Se.uniqBy(o,"date",!0).map(n=>Ee.parse(`${n}`,t.dateFormat||"yyyy",new Date).getTime()),(n,je)=>Je.ascending(n,je)),[be,ve]=d.useState(t.autoplay?0:xe.length-1),[Ne,l]=d.useState(void 0),i=d.useRef(null),z=d.useRef(null);d.useEffect(()=>{const n=new ResizeObserver(je=>{we(j||je[0].target.clientWidth||620),_(ee||je[0].target.clientHeight||480)});return i.current&&(_(i.current.clientHeight||480),we(i.current.clientWidth||620),j||n.observe(i.current)),()=>n.disconnect()},[j,ee]),d.useEffect(()=>{const n=setInterval(()=>{ve(je=>je<xe.length-1?je+1:0)},(t.speed||2)*1e3);return ge||clearInterval(n),()=>clearInterval(n)},[xe,ge,t.speed]);const Ke=Ie.getSliderMarks(xe,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${T||"light"} flex ${j?"w-fit grow-0":"w-full grow"}`,dir:O==="he"||O==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${ne?ne===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${O||"en"}`,j?"w-fit":"w-full",h?.graphContainer),style:{...E?.graphContainer||{},...ne&&ne!==!0?{backgroundColor:ne}:{}},id:oe,ref:z,"aria-label":P||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${J?` ${J}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:ne?se||"1rem":se||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||J||D||M?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:E?.title,description:E?.description},classNames:{title:h?.title,description:h?.description},graphTitle:p,graphDescription:J,width:j,graphDownload:D?z.current:void 0,dataDownload:M?o.map(n=>n.data).filter(n=>n!==void 0).length>0?o.map(n=>n.data).filter(n=>n!==void 0):o.filter(n=>n!==void 0):null}):null,t.enabled&&xe.length>0&&Ke?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Oe(!ge)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ge?"Click to pause animation":"Click to play animation",children:ge?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Ie.xr,{min:xe[0],max:xe[xe.length-1],marks:Ke,step:null,defaultValue:xe[xe.length-1],value:xe[be],onChangeComplete:n=>{ve(xe.indexOf(n))},onChange:n=>{ve(xe.indexOf(n))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[pe&&o.filter(n=>n.color).length!==0?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:j,colorLegendTitle:ae,colors:G||Ce.Colors[T].categoricalColors.colors,colorDomain:V||Se.uniqBy(o,"color",!0),setSelectedColor:l,showNAColor:w}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:i,"aria-label":"Graph area",children:(j||f)&&(ee||ue)?e.jsxRuntimeExports.jsx(ut,{data:A?$e.orderBy(Re.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(n=>t.enabled?n.date===Ee.format(new Date(xe[be]),t.dateFormat||"yyyy"):n).filter(n=>c?!q.checkIfNullOrUndefined(n.size):n),[n=>n.size===void 0?A==="asc"?-1/0:1/0:n.size],[A]).filter((n,je)=>L?je<L:!0):Re.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(n=>t.enabled?n.date===Ee.format(new Date(xe[be]),t.dateFormat||"yyyy"):n).filter(n=>c?!q.checkIfNullOrUndefined(n.size):n).filter((n,je)=>L?je<L:!0),barColor:o.filter(n=>n.color).length===0?G?[G]:[Ce.Colors.primaryColors["blue-600"]]:G||Ce.Colors[T].categoricalColors.colors,colorDomain:o.filter(n=>n.color).length===0?[]:V||Se.uniqBy(o,"color",!0),width:j||f,refValues:X,height:Math.max(Y,ee||(K?Y?(j||f)*K>Y?(j||f)*K:Y:(j||f)*K:ue)),suffix:ce,prefix:C,barPadding:$,showLabels:ie,showValues:N,showTicks:U,truncateBy:H,leftMargin:me,rightMargin:de,selectedColor:Ne,topMargin:he,bottomMargin:Z,tooltip:te,onSeriesMouseOver:re,maxValue:q.checkIfNullOrUndefined(I)?Math.max(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size))<0?0:Math.max(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size)):I,minValue:q.checkIfNullOrUndefined(b)?Math.min(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size))>=0?0:Math.min(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size)):b,highlightedDataPoints:g,onSeriesMouseClick:k,labelOrder:v,maxBarThickness:S,minBarThickness:le,resetSelectionOnDoubleClick:B,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F,valueColor:m,styles:E,classNames:h,animate:x===!0?{duration:.5,once:!0,amount:.5}:x||{duration:0,once:!0,amount:0},dimmedOpacity:u,precision:a,customLayers:r,naLabel:s}):null})]})}),W||y?e.jsxRuntimeExports.jsx(Ue.GraphFooter,{styles:{footnote:E?.footnote,source:E?.source},classNames:{footnote:h?.footnote,source:h?.source},sources:W,footNote:y,width:j}):null]})})})})}function xt(ye){const{data:o,width:p,height:G,barColors:$,suffix:U,prefix:me,barPadding:de,showLabels:he,showValues:Z,showTicks:H,truncateBy:ie,leftMargin:N,rightMargin:ne,topMargin:ce,bottomMargin:C,tooltip:W,onSeriesMouseOver:J,refValues:ee,maxValue:j,minValue:y,onSeriesMouseClick:V,selectedColor:ae,labelOrder:se,maxBarThickness:K,resetSelectionOnDoubleClick:te,detailsOnClick:re,barAxisTitle:X,valueColor:pe,noOfTicks:oe,styles:I,classNames:b,animate:g,colorDomain:k,precision:D,customLayers:M,naLabel:O}=ye,T=d.useRef(null),A=He.useInView(T,{once:g.once,amount:g.amount}),v={top:ce,bottom:C,left:X?N+30:N,right:ne},[w,Y]=d.useState(void 0),[S,L]=d.useState(void 0),[le,P]=d.useState(void 0),[B,Q]=d.useState(void 0),R=p-v.left-v.right,F=G-v.top-v.bottom,m=qe.linear().domain([y,j]).range([F,0]).nice(),E=o.map((a,r)=>({...a,id:se?`${a.label}`:`${r}`})),h=se||E.map(a=>`${a.id}`),c=Te.band().domain(h).range([0,K?Math.min(R,K*h.length):R]).paddingInner(de),x=Te.band().domain(o[0].size.map((a,r)=>`${r}`)).range([0,c.bandwidth()]).paddingInner(.1),u=m.ticks(oe);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{width:`${p}px`,height:`${G}px`,viewBox:`0 0 ${p} ${G}`,direction:"ltr",ref:T,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${v.left},${v.top})`,children:[e.jsxRuntimeExports.jsx(Fe.Axis,{y1:m(y<0?0:y),y2:m(y<0?0:y),x1:0-N,x2:R+v.right,label:Me.numberFormattingFunction(y<0?0:y,O,D,me,U),labelPos:{x:0-N,dx:0,dy:j<0?"1em":-5,y:m(y<0?0:y)},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:I?.xAxis?.axis,label:I?.yAxis?.labels}}),H?e.jsxRuntimeExports.jsx(it.YTicksAndGridLines,{values:u.filter(a=>a!==0),y:u.filter(a=>a!==0).map(a=>m(a)),x1:0-N,x2:R+v.right,styles:{gridLines:I?.yAxis?.gridLines,labels:I?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:U,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:D}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:0-N-15,y:F/2,style:I?.yAxis?.title,className:b?.yAxis?.title,text:X,rotate90:!0}),M.filter(a=>a.position==="before").map(a=>a.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[E.map(a=>q.checkIfNullOrUndefined(c(a.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{variants:{initial:{x:c(`${a.id}`),y:0},whileInView:{x:c(`${a.id}`),y:0,transition:{duration:g.duration}}},initial:"initial",animate:A?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[a.size.map((r,t)=>e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?$[t]===ae?1:.3:.85,onMouseEnter:s=>{Y({...a,sizeIndex:t}),Q(s.clientY),P(s.clientX),J?.({...a,sizeIndex:t})},onMouseMove:s=>{Y({...a,sizeIndex:t}),Q(s.clientY),P(s.clientX)},onMouseLeave:()=>{Y(void 0),P(void 0),Q(void 0),J?.(void 0)},onClick:()=>{(V||re)&&(Ae.isEqual(S,{...a,sizeIndex:t})&&te?(L(void 0),V?.(void 0)):(L({...a,sizeIndex:t}),V&&V({...a,sizeIndex:t})))},children:[e.jsxRuntimeExports.jsx(fe.motion.rect,{x:x(`${t}`),width:x.bandwidth(),variants:{initial:{height:0,y:m(0),fill:$[t]},whileInView:{height:q.checkIfNullOrUndefined(r)?0:Math.abs(m(r)-m(0)),y:q.checkIfNullOrUndefined(r)?m(0):r>0?m(r):m(0),fill:$[t],transition:{duration:g.duration}}},exit:{height:0,y:m(0),transition:{duration:g.duration}},initial:"initial",animate:A?"whileInView":"initial"}),Z?e.jsxRuntimeExports.jsx(fe.motion.text,{x:x(`${t}`)+x.bandwidth()/2,style:{fill:pe||$[t],textAnchor:"middle",...I?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:r?r>=0?"-5px":"1em":"-5px",variants:{initial:{y:m(0),opacity:0},whileInView:{y:m(r||0),opacity:1,transition:{duration:g.duration}}},initial:"initial",animate:A?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:Me.numberFormattingFunction(r,O,D,me,U)}):null]},`${a.label}-${k[t]||t}`)),he?e.jsxRuntimeExports.jsx(tt.XAxesLabels,{value:`${a.label}`.length<ie?`${a.label}`:`${`${a.label}`.substring(0,ie)}...`,y:m(0)+5,x:0,width:c.bandwidth(),height:v.bottom,style:I?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:A}):null]},a.label)),ee?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ee.map((a,r)=>e.jsxRuntimeExports.jsx(Pe.RefLineY,{text:a.text,color:a.color,y:m(a.value),x1:0-N,x2:R+v.right,classNames:a.classNames,styles:a.styles,animate:g,isInView:A},r))}):null]}),M.filter(a=>a.position==="after").map(a=>a.layer)]})}),w&&W&&le&&B?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:w,body:W,xPos:le,yPos:B,backgroundStyle:I?.tooltip,className:b?.tooltip}):null,re&&S!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:S!==void 0,onClose:()=>{L(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof re=="string"?{__html:Le.string2HTML(re,S)}:void 0,children:typeof re=="function"?re(S):null})}):null]})}function dt(ye){const{data:o,graphTitle:p,colors:G=Ce.Colors.light.categoricalColors.colors,sources:$,graphDescription:U,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:Z=20,topMargin:H=20,bottomMargin:ie=25,truncateBy:N=999,showLabels:ne=!0,showValues:ce=!0,backgroundColor:C=!1,suffix:W="",prefix:J="",height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,graphID:pe,maxValue:oe,minValue:I,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:k=!1,language:D="en",theme:M="light",labelOrder:O,minHeight:T=0,maxBarThickness:A,ariaLabel:v,resetSelectionOnDoubleClick:w=!0,detailsOnClick:Y,barAxisTitle:S,noOfTicks:L=5,valueColor:le,styles:P,classNames:B,filterNA:Q=!0,showColorScale:R=!0,animate:F=!1,precision:m=2,customLayers:E=[],timeline:h={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:c="NA",sortParameter:x,sortData:u}=ye,[a,r]=d.useState(0),[t,s]=d.useState(0),[f,we]=d.useState(h.autoplay),ue=_e.sort(Se.uniqBy(o,"date",!0).map(l=>Ee.parse(`${l}`,h.dateFormat||"yyyy",new Date).getTime()),(l,i)=>Je.ascending(l,i)),[_,ge]=d.useState(h.autoplay?0:ue.length-1),[Oe,xe]=d.useState(void 0),be=d.useRef(null),ve=d.useRef(null);d.useEffect(()=>{const l=new ResizeObserver(i=>{r(j||i[0].target.clientWidth||620),s(ee||i[0].target.clientHeight||480)});return be.current&&(s(be.current.clientHeight||480),r(be.current.clientWidth||620),j||l.observe(be.current)),()=>l.disconnect()},[j,ee]),d.useEffect(()=>{const l=setInterval(()=>{ge(i=>i<ue.length-1?i+1:0)},(h.speed||2)*1e3);return f||clearInterval(l),()=>clearInterval(l)},[ue,f,h.speed]);const Ne=Ie.getSliderMarks(ue,_,h.showOnlyActiveDate,h.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${M||"light"} flex ${j?"w-fit grow-0":"w-full grow"}`,dir:D==="he"||D==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${D||"en"}`,j?"w-fit":"w-full",B?.graphContainer),style:{...P?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:pe,ref:ve,"aria-label":v||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${U?` ${U}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:C?se||"1rem":se||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||U||g||k?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:P?.title,description:P?.description},classNames:{title:B?.title,description:B?.description},graphTitle:p,graphDescription:U,width:j,graphDownload:g?ve.current:void 0,dataDownload:k?o.map(l=>l.data).filter(l=>l!==void 0).length>0?o.map(l=>l.data).filter(l=>l!==void 0):o.filter(l=>l!==void 0):null}):null,h.enabled&&ue.length>0&&Ne?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!f)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":f?"Click to pause animation":"Click to play animation",children:f?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Ie.xr,{min:ue[0],max:ue[ue.length-1],marks:Ne,step:null,defaultValue:ue[ue.length-1],value:ue[_],onChangeComplete:l=>{ge(ue.indexOf(l))},onChange:l=>{ge(ue.indexOf(l))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[R?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:j,colorDomain:V,colors:G,colorLegendTitle:ae,setSelectedColor:xe,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:be,"aria-label":"Graph area",children:(j||a)&&(ee||t)?e.jsxRuntimeExports.jsx(xt,{data:x!==void 0?x==="total"?$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>h.enabled?l.date===Ee.format(new Date(ue[_]),h.dateFormat||"yyyy"):l).filter(l=>Q?!l.size.every(i=>i==null):l),l=>ke.sum(l.size.filter(i=>!q.checkIfNullOrUndefined(i))),[u||"asc"]):$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>h.enabled?l.date===Ee.format(new Date(ue[_]),h.dateFormat||"yyyy"):l).filter(l=>Q?!l.size.every(i=>i==null):l),l=>q.checkIfNullOrUndefined(l.size[x])?-1/0:l.size[x],[u||"asc"]):Re.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>Q?!l.size.every(i=>i==null):l),barColors:G,width:j||a,height:Math.max(T,ee||(K?T?(j||a)*K>T?(j||a)*K:T:(j||a)*K:t)),suffix:W,prefix:J,barPadding:me,showLabels:ne,showValues:ce,showTicks:de,truncateBy:N,leftMargin:he,rightMargin:Z,topMargin:H,bottomMargin:ie,tooltip:te,onSeriesMouseOver:re,refValues:X,maxValue:q.checkIfNullOrUndefined(oe)?Math.max(...o.map(l=>Math.max(...l.size.filter(i=>!q.checkIfNullOrUndefined(i)))))<0?0:Math.max(...o.map(l=>Math.max(...l.size.filter(i=>!q.checkIfNullOrUndefined(i))))):oe,minValue:q.checkIfNullOrUndefined(I)?Math.min(...o.map(l=>Math.min(...l.size.filter(i=>!q.checkIfNullOrUndefined(i)))))>=0?0:Math.min(...o.map(l=>Math.min(...l.size.filter(i=>!q.checkIfNullOrUndefined(i))))):I,onSeriesMouseClick:b,selectedColor:Oe,labelOrder:O,maxBarThickness:A,resetSelectionOnDoubleClick:w,detailsOnClick:Y,barAxisTitle:S,noOfTicks:L,valueColor:le,styles:P,classNames:B,animate:F===!0?{duration:.5,once:!0,amount:.5}:F||{duration:0,once:!0,amount:0},colorDomain:V,precision:m,customLayers:E,naLabel:c}):null})]})}),$||y?e.jsxRuntimeExports.jsx(Ue.GraphFooter,{styles:{footnote:P?.footnote,source:P?.source},classNames:{footnote:B?.footnote,source:B?.source},sources:$,footNote:y,width:j}):null]})})})})}function mt(ye){const{data:o,width:p,height:G,barColors:$,barPadding:U,showLabels:me,showTicks:de,truncateBy:he,leftMargin:Z,topMargin:H,bottomMargin:ie,rightMargin:N,tooltip:ne,onSeriesMouseOver:ce,suffix:C,prefix:W,showValues:J,refValues:ee,maxValue:j,onSeriesMouseClick:y,selectedColor:V,labelOrder:ae,maxBarThickness:se,minBarThickness:K,resetSelectionOnDoubleClick:te,detailsOnClick:re,barAxisTitle:X,valueColor:pe,noOfTicks:oe,styles:I,classNames:b,animate:g,colorDomain:k,precision:D,customLayers:M,naLabel:O}=ye,T=d.useRef(null),A=He.useInView(T,{once:g.once,amount:g.amount}),v={top:H,bottom:ie,left:X?Z+30:Z,right:N},[w,Y]=d.useState(void 0),[S,L]=d.useState(void 0),[le,P]=d.useState(void 0),[B,Q]=d.useState(void 0),R=p-v.left-v.right,F=G-v.top-v.bottom,m=qe.linear().domain([0,j]).range([F,0]).nice(),E=o.map((u,a)=>({...u,id:ae?`${u.label}`:`${a}`})),h=ae||E.map(u=>`${u.id}`),c=Te.band().domain(h).range([0,K?Math.max(R,K*h.length):se?Math.min(R,se*h.length):R]).paddingInner(U),x=m.ticks(oe);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{width:`${p}px`,height:`${G}px`,viewBox:`0 0 ${p} ${G}`,direction:"ltr",ref:T,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${v.left},${v.top})`,children:[e.jsxRuntimeExports.jsx(Fe.Axis,{y1:m(0),y2:m(0),x1:0-Z,x2:R+v.right,label:Me.numberFormattingFunction(0,O,D,W,C),labelPos:{x:0-Z,y:m(0),dx:0,dy:-5},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:I?.xAxis?.axis,label:I?.yAxis?.labels}}),de?e.jsxRuntimeExports.jsx(it.YTicksAndGridLines,{values:x.filter(u=>u!==0),y:x.filter(u=>u!==0).map(u=>m(u)),x1:0-Z,x2:R+v.right,styles:{gridLines:I?.yAxis?.gridLines,labels:I?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:C,prefix:W,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:D}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:0-Z-15,y:F/2,style:I?.yAxis?.title,className:b?.yAxis?.title,text:X,rotate90:!0}),M.filter(u=>u.position==="before").map(u=>u.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[E.map(u=>q.checkIfNullOrUndefined(c(u.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",variants:{initial:{x:c(`${u.id}`),y:0},whileInView:{x:c(`${u.id}`),y:0,transition:{duration:g.duration}}},transition:{duration:g.duration},initial:"initial",animate:A?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[u.size.map((a,r)=>e.jsxRuntimeExports.jsxs(fe.motion.g,{opacity:V?$[r]===V?1:.3:1,onMouseEnter:t=>{Y({...u,sizeIndex:r}),Q(t.clientY),P(t.clientX),ce?.({...u,sizeIndex:r})},onMouseMove:t=>{Y({...u,sizeIndex:r}),Q(t.clientY),P(t.clientX)},onMouseLeave:()=>{Y(void 0),P(void 0),Q(void 0),ce?.(void 0)},onClick:()=>{(y||re)&&(Ae.isEqual(S,{...u,sizeIndex:r})&&te?(L(void 0),y?.(void 0)):(L({...u,sizeIndex:r}),y&&y({...u,sizeIndex:r})))},children:[e.jsxRuntimeExports.jsx(fe.motion.rect,{x:0,width:c.bandwidth(),variants:{initial:{height:0,fill:$[r],y:m(0)},whileInView:{height:Math.abs(m(ke.sum(u.size.filter((t,s)=>s<=r&&t)))-m(ke.sum(u.size.filter((t,s)=>s<r&&t)))),y:m(ke.sum(u.size.filter((t,s)=>s<=r&&t))),fill:$[r],transition:{duration:g.duration}}},initial:"initial",animate:A?"whileInView":"initial",exit:{height:0,y:m(0),transition:{duration:g.duration}}}),J?e.jsxRuntimeExports.jsx(fe.motion.text,{x:c.bandwidth()/2,style:{fill:Qe.getTextColorBasedOnBgColor($[r]),textAnchor:"middle",...I?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:"0.33em",variants:{initial:{y:m(0),opacity:0,fill:Qe.getTextColorBasedOnBgColor($[r])},whileInView:{y:m(ke.sum(u.size.filter((t,s)=>s<=r&&t)))+Math.abs(m(ke.sum(u.size.filter((t,s)=>s<=r&&t)))-m(ke.sum(u.size.filter((t,s)=>s<r&&t))))/2,opacity:a&&Math.abs(m(ke.sum(u.size.filter((t,s)=>s<=r&&t)))-m(ke.sum(u.size.filter((t,s)=>s<r&&t))))>20?1:0,fill:Qe.getTextColorBasedOnBgColor($[r]),transition:{duration:g.duration}}},initial:"initial",animate:A?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:Me.numberFormattingFunction(a,O,D,W,C)}):null]},`${u.label}-${k[r]||r}`)),me?e.jsxRuntimeExports.jsx(tt.XAxesLabels,{value:`${u.label}`.length<he?`${u.label}`:`${`${u.label}`.substring(0,he)}...`,y:m(0)+5,x:0,width:c.bandwidth(),height:v.bottom,style:I?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:A}):null,J?e.jsxRuntimeExports.jsx(fe.motion.text,{style:{...pe&&{fill:pe},textAnchor:"middle",...I?.graphObjectValues||{}},x:c.bandwidth()/2,dy:-10,className:e.mo("graph-value graph-value-total",pe?"text-sm":"fill-primary-gray-700 dark:fill-primary-gray-300 text-sm",b?.graphObjectValues),variants:{initial:{y:m(0),opacity:0},whileInView:{y:m(ke.sum(u.size.map(a=>a||0))),opacity:1,transition:{duration:g.duration}}},exit:{opacity:0,transition:{duration:g.duration}},initial:"initial",animate:A?"whileInView":"initial",children:Me.numberFormattingFunction(ke.sum(u.size.filter(a=>a)),O,D,W,C)}):null]},u.label)),ee?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ee.map((u,a)=>e.jsxRuntimeExports.jsx(Pe.RefLineY,{text:u.text,color:u.color,y:m(u.value),x1:0-Z,x2:R+v.right,classNames:u.classNames,styles:u.styles,animate:g,isInView:A},a))}):null]}),M.filter(u=>u.position==="after").map(u=>u.layer)]})}),w&&ne&&le&&B?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:w,body:ne,xPos:le,yPos:B,backgroundStyle:I?.tooltip,className:b?.tooltip}):null,re&&S!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:S!==void 0,onClose:()=>{L(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof re=="string"?{__html:Le.string2HTML(re,S)}:void 0,children:typeof re=="function"?re(S):null})}):null]})}function ht(ye){const{data:o,graphTitle:p,colors:G=Ce.Colors.light.categoricalColors.colors,sources:$,graphDescription:U,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:Z=20,topMargin:H=20,bottomMargin:ie=25,truncateBy:N=999,showLabels:ne=!0,showValues:ce=!0,backgroundColor:C=!1,showColorScale:W=!0,suffix:J="",prefix:ee="",height:j,width:y,footNote:V,colorDomain:ae,colorLegendTitle:se,padding:K,tooltip:te,onSeriesMouseOver:re,relativeHeight:X,refValues:pe,graphID:oe,maxValue:I,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:k=!1,language:D="en",theme:M="light",labelOrder:O,minHeight:T=0,maxBarThickness:A,sortParameter:v,maxNumberOfBars:w,minBarThickness:Y,ariaLabel:S,resetSelectionOnDoubleClick:L=!0,detailsOnClick:le,barAxisTitle:P,noOfTicks:B=5,valueColor:Q,styles:R,classNames:F,filterNA:m=!0,animate:E=!1,precision:h=2,customLayers:c=[],timeline:x={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:u="NA",sortData:a}=ye,[r,t]=d.useState(0),[s,f]=d.useState(0),[we,ue]=d.useState(x.autoplay),_=_e.sort(Se.uniqBy(o,"date",!0).map(i=>Ee.parse(`${i}`,x.dateFormat||"yyyy",new Date).getTime()),(i,z)=>Je.ascending(i,z)),[ge,Oe]=d.useState(x.autoplay?0:_.length-1),[xe,be]=d.useState(void 0),ve=d.useRef(null),Ne=d.useRef(null);d.useEffect(()=>{const i=new ResizeObserver(z=>{t(y||z[0].target.clientWidth||620),f(j||z[0].target.clientHeight||480)});return ve.current&&(f(ve.current.clientHeight||480),t(ve.current.clientWidth||620),y||i.observe(ve.current)),()=>i.disconnect()},[y,j]),d.useEffect(()=>{const i=setInterval(()=>{Oe(z=>z<_.length-1?z+1:0)},(x.speed||2)*1e3);return we||clearInterval(i),()=>clearInterval(i)},[_,we,x.speed]);const l=Ie.getSliderMarks(_,ge,x.showOnlyActiveDate,x.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${M||"light"} flex ${y?"w-fit grow-0":"w-full grow"}`,dir:D==="he"||D==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${D||"en"}`,y?"w-fit":"w-full",F?.graphContainer),style:{...R?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:oe,ref:Ne,"aria-label":S||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${U?` ${U}`:""}`,children:e.jsxRuntimeExports.jsx("div",{style:{padding:C?K||"1rem":K||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||U||g||k?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:R?.title,description:R?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:U,width:y,graphDownload:g?Ne.current:void 0,dataDownload:k?o.map(i=>i.data).filter(i=>i!==void 0).length>0?o.map(i=>i.data).filter(i=>i!==void 0):o.filter(i=>i!==void 0):null}):null,x.enabled&&_.length>0&&l?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{ue(!we)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":we?"Click to pause animation":"Click to play animation",children:we?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Ie.xr,{min:_[0],max:_[_.length-1],marks:l,step:null,defaultValue:_[_.length-1],value:_[ge],onChangeComplete:i=>{Oe(_.indexOf(i))},onChange:i=>{Oe(_.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[W?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:y,colorDomain:ae,colors:G,colorLegendTitle:se,setSelectedColor:be,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:ve,"aria-label":"Graph area",children:(y||r)&&(j||s)?e.jsxRuntimeExports.jsx(mt,{data:v!==void 0?v==="total"?$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===Ee.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(z=>z==null):i),i=>ke.sum(i.size.filter(z=>!q.checkIfNullOrUndefined(z))),[a||"asc"]).filter((i,z)=>w?z<w:!0):$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===Ee.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(z=>z==null):i),i=>q.checkIfNullOrUndefined(i.size[v])?-1/0:i.size[v],[a||"asc"]).filter((i,z)=>w?z<w:!0):Re.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>m?!i.size.every(z=>z==null):i).filter((i,z)=>w?z<w:!0),barColors:G,width:y||r,height:Math.max(T,j||(X?T?(y||r)*X>T?(y||r)*X:T:(y||r)*X:s)),barPadding:me,showLabels:ne,showTicks:de,truncateBy:N,leftMargin:he,rightMargin:Z,topMargin:H,bottomMargin:ie,tooltip:te,onSeriesMouseOver:re,showValues:ce,suffix:J,prefix:ee,refValues:pe,maxValue:q.checkIfNullOrUndefined(I)?Math.max(...o.map(i=>ke.sum(i.size.filter(z=>!q.checkIfNullOrUndefined(z)))||0)):I,onSeriesMouseClick:b,selectedColor:xe,labelOrder:O,maxBarThickness:A,minBarThickness:Y,resetSelectionOnDoubleClick:L,detailsOnClick:le,barAxisTitle:P,noOfTicks:B,valueColor:Q,styles:R,classNames:F,animate:E===!0?{duration:.5,once:!0,amount:.5}:E||{duration:0,once:!0,amount:0},colorDomain:ae,precision:h,customLayers:c,naLabel:u}):null})]})}),$||V?e.jsxRuntimeExports.jsx(Ue.GraphFooter,{styles:{footnote:R?.footnote,source:R?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:$,footNote:V,width:y}):null]})})})})}function pt(ye){const{data:o,graphTitle:p,colors:G,barPadding:$,showTicks:U,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Z,truncateBy:H,showLabels:ie,showValues:N,backgroundColor:ne,suffix:ce,prefix:C,sources:W,graphDescription:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,showColorScale:pe,graphID:oe,maxValue:I,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:k,graphDownload:D,dataDownload:M,language:O,theme:T,sortData:A,labelOrder:v,showNAColor:w,minHeight:Y,maxBarThickness:S,maxNumberOfBars:L,minBarThickness:le,ariaLabel:P,resetSelectionOnDoubleClick:B,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F,valueColor:m,orientation:E="vertical",styles:h,classNames:c,filterNA:x,animate:u,dimmedOpacity:a,precision:r,customLayers:t,timeline:s,naLabel:f}=ye;return E==="vertical"?e.jsxRuntimeExports.jsx(ct,{data:o,graphTitle:p,colors:G,barPadding:$,showTicks:U,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Z,truncateBy:H,showLabels:ie,showValues:N,backgroundColor:ne,suffix:ce,prefix:C,sources:W,graphDescription:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,showColorScale:pe,graphID:oe,maxValue:I,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:k,graphDownload:D,dataDownload:M,language:O,theme:T,sortData:A,labelOrder:v,showNAColor:w,minHeight:Y,maxBarThickness:S,maxNumberOfBars:L,minBarThickness:le,ariaLabel:P,resetSelectionOnDoubleClick:B,styles:h,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F,valueColor:m,classNames:c,filterNA:x,animate:u,dimmedOpacity:a,precision:r,customLayers:t,timeline:s,naLabel:f}):e.jsxRuntimeExports.jsx(st,{data:o,graphTitle:p,colors:G,barPadding:$,showTicks:U,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Z,truncateBy:H,showLabels:ie,showValues:N,backgroundColor:ne,suffix:ce,prefix:C,sources:W,graphDescription:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,showColorScale:pe,graphID:oe,maxValue:I,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:k,graphDownload:D,dataDownload:M,language:O,theme:T,sortData:A,labelOrder:v,showNAColor:w,minHeight:Y,maxBarThickness:S,maxNumberOfBars:L,minBarThickness:le,ariaLabel:P,resetSelectionOnDoubleClick:B,styles:h,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F,valueColor:m,classNames:c,filterNA:x,animate:u,dimmedOpacity:a,precision:r,customLayers:t,timeline:s,naLabel:f})}function gt(ye){const{data:o,graphTitle:p,colors:G,sources:$,graphDescription:U,barPadding:me,showTicks:de,truncateBy:he,height:Z,width:H,footNote:ie,colorDomain:N,colorLegendTitle:ne,suffix:ce,prefix:C,showValues:W,padding:J,backgroundColor:ee,leftMargin:j,rightMargin:y,topMargin:V,bottomMargin:ae,showLabels:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,graphID:pe,maxValue:oe,minValue:I,onSeriesMouseClick:b,graphDownload:g,dataDownload:k,language:D,labelOrder:M,minHeight:O,theme:T,sortParameter:A,sortData:v,maxBarThickness:w,ariaLabel:Y,resetSelectionOnDoubleClick:S,detailsOnClick:L,barAxisTitle:le,noOfTicks:P,valueColor:B,orientation:Q="vertical",styles:R,classNames:F,filterNA:m,animate:E,precision:h,customLayers:c,showColorScale:x,timeline:u,naLabel:a}=ye;return Q==="vertical"?e.jsxRuntimeExports.jsx(dt,{data:o,graphTitle:p,colors:G,sources:$,graphDescription:U,barPadding:me,showTicks:de,truncateBy:he,height:Z,width:H,footNote:ie,colorDomain:N,colorLegendTitle:ne,suffix:ce,prefix:C,showValues:W,padding:J,backgroundColor:ee,leftMargin:j,rightMargin:y,sortParameter:A,sortData:v,topMargin:V,bottomMargin:ae,showLabels:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,graphID:pe,maxValue:oe,minValue:I,onSeriesMouseClick:b,graphDownload:g,dataDownload:k,language:D,labelOrder:M,minHeight:O,theme:T,maxBarThickness:w,ariaLabel:Y,resetSelectionOnDoubleClick:S,styles:R,detailsOnClick:L,barAxisTitle:le,noOfTicks:P,valueColor:B,classNames:F,filterNA:m,animate:E,precision:h,customLayers:c,showColorScale:x,timeline:u,naLabel:a}):e.jsxRuntimeExports.jsx(nt,{data:o,graphTitle:p,colors:G,sortParameter:A,sortData:v,sources:$,graphDescription:U,barPadding:me,showTicks:de,truncateBy:he,height:Z,width:H,footNote:ie,colorDomain:N,colorLegendTitle:ne,suffix:ce,prefix:C,showValues:W,padding:J,backgroundColor:ee,leftMargin:j,rightMargin:y,topMargin:V,bottomMargin:ae,showLabels:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,graphID:pe,maxValue:oe,minValue:I,onSeriesMouseClick:b,graphDownload:g,dataDownload:k,language:D,labelOrder:M,minHeight:O,theme:T,maxBarThickness:w,ariaLabel:Y,resetSelectionOnDoubleClick:S,styles:R,detailsOnClick:L,barAxisTitle:le,noOfTicks:P,valueColor:B,classNames:F,filterNA:m,animate:E,precision:h,customLayers:c,showColorScale:x,timeline:u,naLabel:a})}function ft(ye){const{data:o,graphTitle:p,colors:G,sources:$,graphDescription:U,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Z,topMargin:H,bottomMargin:ie,truncateBy:N,showLabels:ne,showValues:ce,backgroundColor:C,suffix:W,prefix:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,tooltip:K,onSeriesMouseOver:te,relativeHeight:re,refValues:X,graphID:pe,maxValue:oe,onSeriesMouseClick:I,graphDownload:b,dataDownload:g,language:k,theme:D,labelOrder:M,minHeight:O,maxBarThickness:T,sortParameter:A,sortData:v,maxNumberOfBars:w,minBarThickness:Y,ariaLabel:S,resetSelectionOnDoubleClick:L,detailsOnClick:le,barAxisTitle:P,noOfTicks:B,valueColor:Q,orientation:R="vertical",styles:F,classNames:m,filterNA:E,animate:h,precision:c,customLayers:x,showColorScale:u,timeline:a,naLabel:r}=ye;return R==="vertical"?e.jsxRuntimeExports.jsx(ht,{data:o,graphTitle:p,colors:G,sources:$,graphDescription:U,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Z,topMargin:H,bottomMargin:ie,truncateBy:N,showLabels:ne,showValues:ce,backgroundColor:C,suffix:W,prefix:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,tooltip:K,onSeriesMouseOver:te,relativeHeight:re,refValues:X,graphID:pe,maxValue:oe,onSeriesMouseClick:I,graphDownload:b,dataDownload:g,language:k,theme:D,labelOrder:M,minHeight:O,maxBarThickness:T,sortParameter:A,sortData:v,maxNumberOfBars:w,minBarThickness:Y,ariaLabel:S,resetSelectionOnDoubleClick:L,styles:F,detailsOnClick:le,barAxisTitle:P,noOfTicks:B,valueColor:Q,classNames:m,filterNA:E,animate:h,precision:c,customLayers:x,showColorScale:u,timeline:a,naLabel:r}):e.jsxRuntimeExports.jsx(ot,{data:o,graphTitle:p,colors:G,sources:$,graphDescription:U,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Z,topMargin:H,bottomMargin:ie,truncateBy:N,showLabels:ne,showValues:ce,backgroundColor:C,suffix:W,prefix:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,tooltip:K,onSeriesMouseOver:te,relativeHeight:re,refValues:X,graphID:pe,maxValue:oe,onSeriesMouseClick:I,graphDownload:b,dataDownload:g,language:k,theme:D,labelOrder:M,minHeight:O,maxBarThickness:T,sortParameter:A,sortData:v,maxNumberOfBars:w,minBarThickness:Y,ariaLabel:S,resetSelectionOnDoubleClick:L,styles:F,detailsOnClick:le,barAxisTitle:P,noOfTicks:B,valueColor:Q,classNames:m,filterNA:E,animate:h,precision:c,customLayers:x,showColorScale:u,timeline:a,naLabel:r})}exports.GroupedBarGraph=gt;exports.SimpleBarGraph=pt;exports.StackedBarGraph=ft;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),d=require("react"),Ee=require("./parse-hMnG_lRV.cjs"),Ie=require("./getSliderMarks-CRIbTGYV.cjs"),$e=require("./index-CQ3e6Ewi.cjs"),Ae=require("./index-DQA8q5sC.cjs"),ze=require("./Modal-tXZlLE5s.cjs"),Me=require("./numberFormattingFunction-02t-wJta.cjs"),Ve=require("./Tooltip-De16GWhY.cjs"),q=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ce=require("./Colors.cjs"),Le=require("./string2HTML-z7CwHXcx.cjs"),Ze=require("./XTicksAndGridLines-CCzXIV8d.cjs"),et=require("./YAxesLabels-yRFFdx1s.cjs"),Be=require("./AxisTitle-CK9YeovX.cjs"),Fe=require("./Axis-DE7dSn1_.cjs"),Pe=require("./ReferenceLine-CFVBBN__.cjs"),He=require("./use-in-view-sQJZ_xDO.cjs"),qe=require("./linear-BVckp9RD.cjs"),Te=require("./band-CAApY4Pd.cjs"),Ge=require("./index-BW8iNx7E.cjs"),fe=require("./proxy-BHRoeZgd.cjs"),Ue=require("./GraphFooter.cjs"),We=require("./GraphHeader.cjs"),Xe=require("./ColorLegendWithMouseOver.cjs"),Ye=require("./EmptyState-d8_8SxeW.cjs"),De=require("./index-BW_-wD2k.cjs"),Re=require("./ensureCompleteData-DkQYPeDa.cjs"),Se=require("./uniqBy-O05lp2S5.cjs"),_e=require("./sort-O96oMZLb.cjs"),Je=require("./init-DU0ybBc_.cjs"),ke=require("./index-CSNtgibC.cjs"),Qe=require("./getTextColorBasedOnBgColor-nqY-bsM_.cjs"),tt=require("./XAxesLabels-Drf7M3YK.cjs"),it=require("./YTicksAndGridLines-DBDuz6vb.cjs");function at(ye){const{data:o,barColor:p,suffix:G,prefix:$,barPadding:U,showValues:me,showTicks:de,leftMargin:he,truncateBy:Z,width:H,height:ie,colorDomain:N,rightMargin:ne,topMargin:ce,bottomMargin:C,showLabels:W,tooltip:J,onSeriesMouseOver:ee,refValues:j,selectedColor:y,highlightedDataPoints:V,maxValue:ae,minValue:se,onSeriesMouseClick:K,labelOrder:te,rtl:re,maxBarThickness:X,minBarThickness:pe,resetSelectionOnDoubleClick:oe,detailsOnClick:I,barAxisTitle:b,valueColor:g,noOfTicks:k,styles:D,classNames:M,animate:O,dimmedOpacity:T,precision:A,customLayers:v,naLabel:w}=ye,Y=d.useRef(null),S=He.useInView(Y,{once:O.once,amount:O.amount}),[L,le]=d.useState(void 0),[P,B]=d.useState(void 0),[Q,R]=d.useState(void 0),[F,m]=d.useState(void 0),E={top:b?ce+25:ce,bottom:C,left:he,right:ne},h=H-E.left-E.right,c=ie-E.top-E.bottom,x=o.map((s,f)=>({...s,id:te?`${s.label}`:`${f}`})),u=qe.linear().domain([se,ae]).range([0,h]).nice(),a=te||x.map(s=>`${s.id}`),r=Te.band().domain(a).range([0,pe?Math.max(c,pe*a.length):X?Math.min(c,X*a.length):c]).paddingInner(U),t=u.ticks(k);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{ref:Y,width:`${H}px`,height:`${ie}px`,viewBox:`0 0 ${H} ${ie}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${E.left},${E.top})`,children:[de?e.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:t.filter(s=>s!==0),x:t.filter(s=>s!==0).map(s=>u(s)),y1:0-ce,y2:c+E.bottom,styles:{gridLines:D?.xAxis?.gridLines,labels:D?.xAxis?.labels},classNames:{gridLines:M?.xAxis?.gridLines,labels:M?.xAxis?.labels},suffix:G,prefix:$,labelType:"secondary",showGridLines:!0,precision:A}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:h/2,y:0-E.top+15,style:D?.xAxis?.title,className:M?.xAxis?.title,text:b}),v.filter(s=>s.position==="before").map(s=>s.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[x.map(s=>q.checkIfNullOrUndefined(r(s.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{opacity:y?s.color&&p[N.indexOf(s.color)]===y?1:T:V.length!==0?V.indexOf(s.label)!==-1?.85:T:.85},whileInView:{opacity:y?s.color&&p[N.indexOf(s.color)]===y?1:T:V.length!==0?V.indexOf(s.label)!==-1?.85:T:.85,transition:{duration:O.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{opacity:0,transition:{duration:O.duration}},onMouseEnter:f=>{le(s),m(f.clientY),R(f.clientX),ee?.(s)},onClick:()=>{(K||I)&&(Ae.isEqual(P,s)&&oe?(B(void 0),K?.(void 0)):(B(s),K?.(s)))},onMouseMove:f=>{le(s),m(f.clientY),R(f.clientX)},onMouseLeave:()=>{le(void 0),R(void 0),m(void 0),ee?.(void 0)},children:[s.size?e.jsxRuntimeExports.jsx(fe.motion.rect,{variants:{initial:{width:0,x:u(0),y:r(`${s.id}`),fill:o.filter(f=>f.color).length===0?p[0]:s.color?p[N.indexOf(s.color)]:Ce.Colors.gray},whileInView:{width:s.size>=0?u(s.size)-u(0):u(0)-u(s.size),x:s.size>=0?u(0):u(s.size),y:r(`${s.id}`),fill:o.filter(f=>f.color).length===0?p[0]:s.color?p[N.indexOf(s.color)]:Ce.Colors.gray,transition:{duration:O.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{width:0,x:u(0),transition:{duration:O.duration}},height:r.bandwidth()}):null,W?e.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${s.label}`.length<Z?`${s.label}`:`${`${s.label}`.substring(0,Z)}...`,y:r(s.id)||0,x:(s.size||0)<0?u(0):0-E.left,width:(s.size||0)<0?H-u(0):u(0)+E.left,height:r.bandwidth(),alignment:s.size&&s.size<0?"left":"right",style:D?.yAxis?.labels,className:M?.yAxis?.labels,animate:O,isInView:S}):null,me?e.jsxRuntimeExports.jsx(fe.motion.text,{style:{textAnchor:s.size&&s.size<0?"end":"start",...D?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!g&&p.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",M?.graphObjectValues),dx:s.size&&s.size<0?-5:5,dy:"0.33em",variants:{initial:{x:u(0),y:r(`${s.id}`)+r.bandwidth()/2,opacity:0,fill:g||(o.filter(f=>f.color).length===0?p[0]:s.color?p[N.indexOf(s.color)]:Ce.Colors.gray)},whileInView:{x:s.size?u(s.size):u(0),opacity:1,y:r(`${s.id}`)+r.bandwidth()/2,fill:g||(o.filter(f=>f.color).length===0?p[0]:s.color?p[N.indexOf(s.color)]:Ce.Colors.gray),transition:{duration:O.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{opacity:0,transition:{duration:O.duration}},children:Me.numberFormattingFunction(s.size,w,A,$,G)}):null]},s.label)),e.jsxRuntimeExports.jsx(Fe.Axis,{x1:u(se<0?0:se),x2:u(se<0?0:se),y1:-2.5,y2:c+E.bottom,classNames:{axis:M?.yAxis?.axis},styles:{axis:D?.yAxis?.axis}}),j?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:j.map((s,f)=>e.jsxRuntimeExports.jsx(Pe.RefLineX,{text:s.text,color:s.color,x:u(s.value),y1:0-E.top,y2:c+E.bottom,textSide:u(s.value)>h*.75||re?"left":"right",classNames:s.classNames,styles:s.styles,animate:O,isInView:S},f))}):null]}),v.filter(s=>s.position==="after").map(s=>s.layer)]})}),L&&J&&Q&&F?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:L,body:J,xPos:Q,yPos:F,backgroundStyle:D?.tooltip,className:M?.tooltip}):null,I&&P!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:P!==void 0,onClose:()=>{B(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof I=="string"?{__html:Le.string2HTML(I,P)}:void 0,children:typeof I=="function"?I(P):null})}):null]})}function st(ye){const{data:o,graphTitle:p,colors:G,suffix:$="",sources:U,prefix:me="",graphDescription:de,barPadding:he=.25,showValues:Z=!0,showTicks:H=!0,leftMargin:ie=100,rightMargin:N=40,truncateBy:ne=999,height:ce,width:C,footNote:W,colorDomain:J,colorLegendTitle:ee,highlightedDataPoints:j=[],padding:y,backgroundColor:V=!1,topMargin:ae=25,bottomMargin:se=10,showLabels:K=!0,relativeHeight:te,tooltip:re,onSeriesMouseOver:X,refValues:pe,showColorScale:oe=!0,graphID:I,maxValue:b,minValue:g,onSeriesMouseClick:k,graphDownload:D=!1,dataDownload:M=!1,sortData:O,labelOrder:T,language:A="en",showNAColor:v=!0,minHeight:w=0,theme:Y="light",maxBarThickness:S,maxNumberOfBars:L,minBarThickness:le,ariaLabel:P,resetSelectionOnDoubleClick:B=!0,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F=5,valueColor:m,styles:E,classNames:h,filterNA:c=!0,animate:x=!1,dimmedOpacity:u=.3,precision:a=2,customLayers:r=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:s="NA"}=ye,[f,we]=d.useState(0),[ue,_]=d.useState(0),[ge,Oe]=d.useState(t.autoplay),xe=_e.sort(Se.uniqBy(o,"date",!0).map(n=>Ee.parse(`${n}`,t.dateFormat||"yyyy",new Date).getTime()),(n,je)=>Je.ascending(n,je)),[be,ve]=d.useState(t.autoplay?0:xe.length-1),[Ne,l]=d.useState(void 0),i=d.useRef(null),z=d.useRef(null);d.useEffect(()=>{const n=new ResizeObserver(je=>{we(C||je[0].target.clientWidth||620),_(ce||je[0].target.clientHeight||480)});return i.current&&(_(i.current.clientHeight||480),we(i.current.clientWidth||620),C||n.observe(i.current)),()=>n.disconnect()},[C,ce]),d.useEffect(()=>{const n=setInterval(()=>{ve(je=>je<xe.length-1?je+1:0)},(t.speed||2)*1e3);return ge||clearInterval(n),()=>clearInterval(n)},[xe,ge,t.speed]);const Ke=Ie.getSliderMarks(xe,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${Y||"light"} flex ${C?"w-fit grow-0":"w-full grow"}`,dir:A==="he"||A==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${V?V===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${A||"en"}`,C?"w-fit":"w-full",h?.graphContainer),style:{...E?.graphContainer||{},...V&&V!==!0?{backgroundColor:V}:{}},id:I,ref:z,"aria-label":P||`${p?`The graph shows ${p}. `:""}This is a bar chart. ${de?` ${de}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:V?y||"1rem":y||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||de||D||M?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:E?.title,description:E?.description},classNames:{title:h?.title,description:h?.description},graphTitle:p,graphDescription:de,width:C,graphDownload:D?z.current:void 0,dataDownload:M?o.map(n=>n.data).filter(n=>n!==void 0).length>0?o.map(n=>n.data).filter(n=>n!==void 0):o.filter(n=>n!==void 0):null}):null,t.enabled&&xe.length>0&&Ke?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Oe(!ge)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ge?"Click to pause animation":"Click to play animation",children:ge?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Ie.xr,{min:xe[0],max:xe[xe.length-1],marks:Ke,step:null,defaultValue:xe[xe.length-1],value:xe[be],onChangeComplete:n=>{ve(xe.indexOf(n))},onChange:n=>{ve(xe.indexOf(n))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[oe&&o.filter(n=>n.color).length!==0?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:C,colorLegendTitle:ee,colors:G||Ce.Colors[Y].categoricalColors.colors,colorDomain:J||Se.uniqBy(o,"color",!0),setSelectedColor:l,showNAColor:v}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:i,"aria-label":"Graph area",children:(C||f)&&(ce||ue)?e.jsxRuntimeExports.jsx(at,{data:O?$e.orderBy(Re.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(n=>t.enabled?n.date===Ee.format(new Date(xe[be]),t.dateFormat||"yyyy"):n).filter(n=>c?!q.checkIfNullOrUndefined(n.size):n),[n=>n.size===void 0?O==="asc"?1/0:-1/0:n.size],[O]).filter((n,je)=>L?je<L:!0):Re.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(n=>t.enabled?n.date===Ee.format(new Date(xe[be]),t.dateFormat||"yyyy"):n).filter(n=>c?!q.checkIfNullOrUndefined(n.size):n).filter((n,je)=>L?je<L:!0),barColor:o.filter(n=>n.color).length===0?G?[G]:[Ce.Colors.primaryColors["blue-600"]]:G||Ce.Colors[Y].categoricalColors.colors,colorDomain:o.filter(n=>n.color).length===0?[]:J||Se.uniqBy(o,"color",!0),width:C||f,selectedColor:Ne,height:Math.max(w,ce||(te?w?(C||f)*te>w?(C||f)*te:w:(C||f)*te:ue)),suffix:$,prefix:me,barPadding:he,showValues:Z,showTicks:H,leftMargin:ie,rightMargin:N,topMargin:ae,bottomMargin:se,truncateBy:ne,showLabels:K,tooltip:re,onSeriesMouseOver:X,refValues:pe,maxValue:q.checkIfNullOrUndefined(b)?Math.max(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size))<0?0:Math.max(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size)):b,minValue:q.checkIfNullOrUndefined(g)?Math.min(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size))>=0?0:Math.min(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size)):g,highlightedDataPoints:j,onSeriesMouseClick:k,labelOrder:T,rtl:A==="he"||A==="ar",maxBarThickness:S,minBarThickness:le,resetSelectionOnDoubleClick:B,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F,valueColor:m,classNames:h,styles:E,animate:x===!0?{duration:.5,once:!0,amount:.5}:x||{duration:0,once:!0,amount:0},dimmedOpacity:u,precision:a,customLayers:r,naLabel:s}):null})]})}),U||W?e.jsxRuntimeExports.jsx(Ue.GraphFooter,{sources:U,footNote:W,width:C,styles:{footnote:E?.footnote,source:E?.source},classNames:{footnote:h?.footnote,source:h?.source}}):null]})})})})}function rt(ye){const{data:o,barColors:p,barPadding:G,showTicks:$,leftMargin:U,truncateBy:me,width:de,height:he,suffix:Z,prefix:H,showValues:ie,rightMargin:N,topMargin:ne,bottomMargin:ce,showLabels:C,tooltip:W,onSeriesMouseOver:J,refValues:ee,maxValue:j,minValue:y,onSeriesMouseClick:V,selectedColor:ae,rtl:se,labelOrder:K,maxBarThickness:te,resetSelectionOnDoubleClick:re,detailsOnClick:X,barAxisTitle:pe,valueColor:oe,noOfTicks:I,styles:b,classNames:g,animate:k,colorDomain:D,precision:M,customLayers:O,naLabel:T}=ye,A=d.useRef(null),v=He.useInView(A,{once:k.once,amount:k.amount}),w={top:pe?ne+25:ne,bottom:ce,left:U,right:N},[Y,S]=d.useState(void 0),[L,le]=d.useState(void 0),[P,B]=d.useState(void 0),[Q,R]=d.useState(void 0),F=de-w.left-w.right,m=he-w.top-w.bottom,E=o.map((r,t)=>({...r,id:K?`${r.label}`:`${t}`})),h=K||E.map(r=>`${r.id}`),c=qe.linear().domain([y,j]).range([0,F]).nice(),x=Te.band().domain(h).range([0,te?Math.min(m,te*h.length):m]).paddingInner(G),u=Te.band().domain(o[0].size.map((r,t)=>`${t}`)).range([0,x.bandwidth()]).paddingInner(.1),a=c.ticks(I);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{ref:A,width:`${de}px`,height:`${he}px`,viewBox:`0 0 ${de} ${he}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${w.left},${w.top})`,children:[$?e.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:a.filter(r=>r!==0),x:a.filter(r=>r!==0).map(r=>c(r)),y1:0-ne,y2:m+w.bottom,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.xAxis?.labels},classNames:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},suffix:Z,prefix:H,labelType:"secondary",showGridLines:!0,precision:M}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:F/2,y:0-w.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),O.filter(r=>r.position==="before").map(r=>r.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[E.map(r=>q.checkIfNullOrUndefined(x(r.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{variants:{initial:{x:0,y:x(`${r.id}`)},whileInView:{x:0,y:x(`${r.id}`),transition:{duration:k.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:k.duration}},children:[r.size.map((t,s)=>e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?p[s]===ae?1:.3:.85,onMouseEnter:f=>{S({...r,sizeIndex:s}),R(f.clientY),B(f.clientX),J?.({...r,sizeIndex:s})},onMouseMove:f=>{S({...r,sizeIndex:s}),R(f.clientY),B(f.clientX)},onMouseLeave:()=>{S(void 0),B(void 0),R(void 0),J?.(void 0)},onClick:()=>{(V||X)&&(Ae.isEqual(L,{...r,sizeIndex:s})&&re?(le(void 0),V?.(void 0)):(le({...r,sizeIndex:s}),V&&V({...r,sizeIndex:s})))},children:[q.checkIfNullOrUndefined(t)?null:e.jsxRuntimeExports.jsx(fe.motion.rect,{y:u(`${s}`),variants:{initial:{width:0,x:c(0),fill:p[s]},whileInView:{width:q.checkIfNullOrUndefined(t)?0:t>=0?c(t)-c(0):c(0)-c(t),x:t>=0?c(0):c(t),fill:p[s],transition:{duration:k.duration}}},exit:{width:0,x:c(0),transition:{duration:k.duration}},height:u.bandwidth(),initial:"initial",animate:v?"whileInView":"initial"}),ie?e.jsxRuntimeExports.jsx(fe.motion.text,{y:u(`${s}`)+u.bandwidth()/2,style:{fill:oe||p[s],textAnchor:t&&t<0?"end":"start",...b?.graphObjectValues||{}},className:e.mo("graph-value text-sm",g?.graphObjectValues),dx:t&&t<0?-5:5,dy:"0.33em",variants:{initial:{x:c(0),opacity:0},whileInView:{x:c(t||0),opacity:1,transition:{duration:k.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:k.duration}},children:Me.numberFormattingFunction(t,T,M,H,Z)}):null]},`${r.label}-${D[s]||s}`)),C?e.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${r.label}`.length<me?`${r.label}`:`${`${r.label}`.substring(0,me)}...`,y:0,x:0-w.left,width:c(y<0?0:y)+w.left,height:x.bandwidth(),style:b?.yAxis?.labels,className:g?.yAxis?.labels,animate:k,isInView:v}):null]},r.label)),e.jsxRuntimeExports.jsx(Fe.Axis,{x1:c(y<0?0:y),x2:c(y<0?0:y),y1:-2.5,y2:m+w.bottom,classNames:{axis:g?.yAxis?.axis},styles:{axis:b?.yAxis?.axis}}),ee?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ee.map((r,t)=>e.jsxRuntimeExports.jsx(Pe.RefLineX,{text:r.text,color:r.color,x:c(r.value),y1:0-w.top,y2:m+w.bottom,textSide:c(r.value)>F*.75||se?"left":"right",classNames:r.classNames,styles:r.styles,animate:k,isInView:v},t))}):null]}),O.filter(r=>r.position==="after").map(r=>r.layer)]})}),Y&&W&&P&&Q?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:Y,body:W,xPos:P,yPos:Q,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,X&&L!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:L!==void 0,onClose:()=>{le(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof X=="string"?{__html:Le.string2HTML(X,L)}:void 0,children:typeof X=="function"?X(L):null})}):null]})}function nt(ye){const{data:o,graphTitle:p,colors:G=Ce.Colors.light.categoricalColors.colors,sources:$,graphDescription:U,barPadding:me=.25,showTicks:de=!0,truncateBy:he=999,height:Z,width:H,footNote:ie,colorDomain:N,colorLegendTitle:ne,suffix:ce="",prefix:C="",showValues:W=!0,showColorScale:J=!0,padding:ee,backgroundColor:j=!1,leftMargin:y=100,rightMargin:V=40,topMargin:ae=25,bottomMargin:se=10,showLabels:K=!0,relativeHeight:te,tooltip:re,onSeriesMouseOver:X,refValues:pe,graphID:oe,maxValue:I,minValue:b,onSeriesMouseClick:g,graphDownload:k=!1,dataDownload:D=!1,language:M="en",labelOrder:O,minHeight:T=0,theme:A="light",maxBarThickness:v,ariaLabel:w,resetSelectionOnDoubleClick:Y=!0,detailsOnClick:S,barAxisTitle:L,noOfTicks:le=5,valueColor:P,styles:B,classNames:Q,filterNA:R=!0,animate:F=!1,precision:m=2,customLayers:E=[],timeline:h={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:c="NA",sortParameter:x,sortData:u}=ye,[a,r]=d.useState(0),[t,s]=d.useState(0),[f,we]=d.useState(h.autoplay),ue=_e.sort(Se.uniqBy(o,"date",!0).map(l=>Ee.parse(`${l}`,h.dateFormat||"yyyy",new Date).getTime()),(l,i)=>Je.ascending(l,i)),[_,ge]=d.useState(h.autoplay?0:ue.length-1),[Oe,xe]=d.useState(void 0),be=d.useRef(null),ve=d.useRef(null);d.useEffect(()=>{const l=new ResizeObserver(i=>{r(H||i[0].target.clientWidth||620),s(Z||i[0].target.clientHeight||480)});return be.current&&(s(be.current.clientHeight||480),r(be.current.clientWidth||620),H||l.observe(be.current)),()=>l.disconnect()},[H,Z]),d.useEffect(()=>{const l=setInterval(()=>{ge(i=>i<ue.length-1?i+1:0)},(h.speed||2)*1e3);return f||clearInterval(l),()=>clearInterval(l)},[ue,f,h.speed]);const Ne=Ie.getSliderMarks(ue,_,h.showOnlyActiveDate,h.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${A||"light"} flex ${H?"w-fit grow-0":"w-full grow"}`,dir:M==="he"||M==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${j?j===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,H?"w-fit":"w-full",Q?.graphContainer),style:{...B?.graphContainer||{},...j&&j!==!0?{backgroundColor:j}:{}},id:oe,ref:ve,"aria-label":w||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${U?` ${U}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:j?ee||"1rem":ee||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[p||U||k||D?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:B?.title,description:B?.description},classNames:{title:Q?.title,description:Q?.description},graphTitle:p,graphDescription:U,width:H,graphDownload:k?ve.current:void 0,dataDownload:D?o.map(l=>l.data).filter(l=>l!==void 0).length>0?o.map(l=>l.data).filter(l=>l!==void 0):o.filter(l=>l!==void 0):null}):null,h.enabled&&ue.length>0&&Ne?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!f)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":f?"Click to pause animation":"Click to play animation",children:f?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Ie.xr,{min:ue[0],max:ue[ue.length-1],marks:Ne,step:null,defaultValue:ue[ue.length-1],value:ue[_],onChangeComplete:l=>{ge(ue.indexOf(l))},onChange:l=>{ge(ue.indexOf(l))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[J?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:H,colorDomain:N,colors:G,colorLegendTitle:ne,setSelectedColor:xe,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:be,"aria-label":"Graph area",children:(H||a)&&(Z||t)?e.jsxRuntimeExports.jsx(rt,{data:x!==void 0?x==="total"?$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>h.enabled?l.date===Ee.format(new Date(ue[_]),h.dateFormat||"yyyy"):l).filter(l=>R?!l.size.every(i=>i==null):l),l=>ke.sum(l.size.filter(i=>!q.checkIfNullOrUndefined(i))),[u||"asc"]):$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>h.enabled?l.date===Ee.format(new Date(ue[_]),h.dateFormat||"yyyy"):l).filter(l=>R?!l.size.every(i=>i==null):l),l=>q.checkIfNullOrUndefined(l.size[x])?-1/0:l.size[x],[u||"asc"]):Re.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>R?!l.size.every(i=>i==null):l),barColors:G,width:H||a,height:Math.max(T,Z||(te?T?(H||a)*te>T?(H||a)*te:T:(H||a)*te:t)),suffix:ce,prefix:C,showValues:W,barPadding:me,showTicks:de,leftMargin:y,rightMargin:V,topMargin:ae,bottomMargin:se,truncateBy:he,showLabels:K,tooltip:re,onSeriesMouseOver:X,refValues:pe,maxValue:q.checkIfNullOrUndefined(I)?Math.max(...o.map(l=>Math.max(...l.size.filter(i=>!q.checkIfNullOrUndefined(i)))))<0?0:Math.max(...o.map(l=>Math.max(...l.size.filter(i=>!q.checkIfNullOrUndefined(i))))):I,minValue:q.checkIfNullOrUndefined(b)?Math.min(...o.map(l=>Math.min(...l.size.filter(i=>!q.checkIfNullOrUndefined(i)))))>=0?0:Math.min(...o.map(l=>Math.min(...l.size.filter(i=>!q.checkIfNullOrUndefined(i))))):b,onSeriesMouseClick:g,selectedColor:Oe,labelOrder:O,rtl:M==="he"||M==="ar",maxBarThickness:v,resetSelectionOnDoubleClick:Y,detailsOnClick:S,barAxisTitle:L,noOfTicks:le,valueColor:P,styles:B,classNames:Q,colorDomain:N,animate:F===!0?{duration:.5,once:!0,amount:.5}:F||{duration:0,once:!0,amount:0},precision:m,customLayers:E,naLabel:c}):null})]})}),$||ie?e.jsxRuntimeExports.jsx(Ue.GraphFooter,{styles:{footnote:B?.footnote,source:B?.source},classNames:{footnote:Q?.footnote,source:Q?.source},sources:$,footNote:ie,width:H}):null]})})})})}function lt(ye){const{data:o,barColors:p,barPadding:G,showTicks:$,leftMargin:U,rightMargin:me,truncateBy:de,width:he,height:Z,topMargin:H,bottomMargin:ie,tooltip:N,onSeriesMouseOver:ne,showLabels:ce,suffix:C,prefix:W,showValues:J,refValues:ee,maxValue:j,onSeriesMouseClick:y,selectedColor:V,rtl:ae,labelOrder:se,maxBarThickness:K,minBarThickness:te,resetSelectionOnDoubleClick:re,detailsOnClick:X,barAxisTitle:pe,valueColor:oe,noOfTicks:I,styles:b,classNames:g,animate:k,colorDomain:D,precision:M,customLayers:O,naLabel:T}=ye,A=d.useRef(null),v=He.useInView(A,{once:k.once,amount:k.amount}),w={top:pe?H+25:H,bottom:ie,left:U,right:me},[Y,S]=d.useState(void 0),[L,le]=d.useState(void 0),[P,B]=d.useState(void 0),[Q,R]=d.useState(void 0),F=he-w.left-w.right,m=Z-w.top-w.bottom,E=o.map((a,r)=>({...a,id:se?`${a.label}`:`${r}`})),h=se||E.map(a=>`${a.id}`),c=qe.linear().domain([0,j]).range([0,F]).nice(),x=Te.band().domain(h).range([0,te?Math.max(m,te*h.length):K?Math.min(m,K*h.length):m]).paddingInner(G),u=c.ticks(I);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{ref:A,width:`${he}px`,height:`${Z}px`,viewBox:`0 0 ${he} ${Z}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${w.left},${w.top})`,children:[$?e.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:u.filter(a=>a!==0),x:u.filter(a=>a!==0).map(a=>c(a)),y1:0-H,y2:m+w.bottom,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.xAxis?.labels},classNames:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},suffix:C,prefix:W,labelType:"secondary",showGridLines:!0,precision:M}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:F/2,y:0-w.top+15,style:b?.xAxis?.title,className:g?.xAxis?.title,text:pe}),O.filter(a=>a.position==="before").map(a=>a.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[E.map(a=>q.checkIfNullOrUndefined(x(a.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",variants:{initial:{x:0,y:x(`${a.id}`)},whileInView:{x:0,y:x(`${a.id}`),transition:{duration:k.duration}}},initial:"initial",animate:v?"whileInView":"initial",exit:{opacity:0,transition:{duration:k.duration}},children:[a.size.map((r,t)=>e.jsxRuntimeExports.jsxs(fe.motion.g,{opacity:V?p[t]===V?1:.3:1,onMouseEnter:s=>{S({...a,sizeIndex:t}),R(s.clientY),B(s.clientX),ne?.({...a,sizeIndex:t})},onMouseMove:s=>{S({...a,sizeIndex:t}),R(s.clientY),B(s.clientX)},onMouseLeave:()=>{S(void 0),B(void 0),R(void 0),ne?.(void 0)},onClick:()=>{(y||X)&&(Ae.isEqual(L,{...a,sizeIndex:t})&&re?(le(void 0),y?.(void 0)):(le({...a,sizeIndex:t}),y&&y({...a,sizeIndex:t})))},children:[r?e.jsxRuntimeExports.jsx(fe.motion.rect,{y:0,style:{fill:p[t]},height:x.bandwidth(),exit:{width:0,x:c(0),transition:{duration:k.duration}},variants:{initial:{width:0,x:c(0),fill:p[t]},whileInView:{width:c(r||0),x:c(t===0?0:ke.sum(a.size.filter((s,f)=>f<t&&s))),fill:p[t],transition:{duration:k.duration}}},initial:"initial",animate:v?"whileInView":"initial"},t):null,J?e.jsxRuntimeExports.jsx(fe.motion.text,{y:x.bandwidth()/2,style:{textAnchor:"middle",...b?.graphObjectValues||{}},dy:"0.33em",className:e.mo("graph-value text-sm",g?.graphObjectValues),exit:{opacity:0,transition:{duration:k.duration}},variants:{initial:{x:c(0),opacity:0,fill:Qe.getTextColorBasedOnBgColor(p[t])},whileInView:{x:c(t===0?0:ke.sum(a.size.filter((s,f)=>f<t&&s)))+c(r||0)/2,opacity:r&&c(r)/Me.numberFormattingFunction(r,T,M,W,C).length>12?1:0,fill:Qe.getTextColorBasedOnBgColor(p[t]),transition:{duration:k.duration}}},initial:"initial",animate:v?"whileInView":"initial",children:Me.numberFormattingFunction(r,T,M,W,C)}):null]},`${a.label}-${D[t]||t}`)),ce?e.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${a.label}`.length<de?`${a.label}`:`${`${a.label}`.substring(0,de)}...`,y:0,x:0-w.left,width:0+w.left,height:x.bandwidth(),style:b?.yAxis?.labels,className:g?.yAxis?.labels,animate:k,isInView:v}):null,J?e.jsxRuntimeExports.jsx(fe.motion.text,{className:e.mo("graph-value graph-value-total text-sm",oe?"":" fill-primary-gray-700 dark:fill-primary-gray-300",g?.graphObjectValues),style:{...oe?{fill:oe}:{},textAnchor:"start",...b?.graphObjectValues||{}},y:x.bandwidth()/2,dx:5,dy:"0.33em",variants:{initial:{x:c(0),opacity:0},whileInView:{x:c(ke.sum(a.size.map(r=>r||0))),opacity:1,transition:{duration:k.duration}}},exit:{opacity:0,transition:{duration:k.duration}},initial:"initial",animate:v?"whileInView":"initial",children:Me.numberFormattingFunction(ke.sum(a.size.filter(r=>r)),T,M,W,C)}):null]},a.label)),e.jsxRuntimeExports.jsx(Fe.Axis,{x1:c(0),x2:c(0),y1:-2.5,y2:m+w.bottom,classNames:{axis:g?.yAxis?.axis},styles:{axis:b?.yAxis?.axis}}),ee?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ee.map((a,r)=>e.jsxRuntimeExports.jsx(Pe.RefLineX,{text:a.text,color:a.color,x:c(a.value),y1:0-w.top,y2:m+w.bottom,textSide:c(a.value)>F*.75||ae?"left":"right",classNames:a.classNames,styles:a.styles,animate:k,isInView:v},r))}):null]}),O.filter(a=>a.position==="after").map(a=>a.layer)]})}),Y&&N&&P&&Q?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:Y,body:N,xPos:P,yPos:Q,backgroundStyle:b?.tooltip,className:g?.tooltip}):null,X&&L!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:L!==void 0,onClose:()=>{le(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof X=="string"?{__html:Le.string2HTML(X,L)}:void 0,children:typeof X=="function"?X(L):null})}):null]})}function ot(ye){const{data:o,graphTitle:p,colors:G=Ce.Colors.light.categoricalColors.colors,sources:$,graphDescription:U,barPadding:me=.25,showTicks:de=!0,leftMargin:he=100,rightMargin:Z=40,truncateBy:H=999,height:ie,width:N,footNote:ne,colorDomain:ce,colorLegendTitle:C,padding:W,backgroundColor:J=!1,topMargin:ee=25,bottomMargin:j=10,tooltip:y,onSeriesMouseOver:V,suffix:ae="",prefix:se="",showLabels:K=!0,relativeHeight:te,showValues:re=!0,refValues:X,graphID:pe,maxValue:oe,onSeriesMouseClick:I,graphDownload:b=!1,dataDownload:g=!1,language:k="en",labelOrder:D,minHeight:M=0,theme:O="light",maxBarThickness:T,sortParameter:A,maxNumberOfBars:v,minBarThickness:w,showColorScale:Y=!0,ariaLabel:S,resetSelectionOnDoubleClick:L=!0,detailsOnClick:le,barAxisTitle:P,noOfTicks:B=5,valueColor:Q,styles:R,classNames:F,filterNA:m=!0,animate:E=!1,precision:h=2,customLayers:c=[],timeline:x={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:u="NA",sortData:a}=ye,[r,t]=d.useState(0),[s,f]=d.useState(0),[we,ue]=d.useState(x.autoplay),_=_e.sort(Se.uniqBy(o,"date",!0).map(i=>Ee.parse(`${i}`,x.dateFormat||"yyyy",new Date).getTime()),(i,z)=>Je.ascending(i,z)),[ge,Oe]=d.useState(x.autoplay?0:_.length-1),[xe,be]=d.useState(void 0),ve=d.useRef(null),Ne=d.useRef(null);d.useEffect(()=>{const i=new ResizeObserver(z=>{t(N||z[0].target.clientWidth||620),f(ie||z[0].target.clientHeight||480)});return ve.current&&(f(ve.current.clientHeight||480),t(ve.current.clientWidth||620),N||i.observe(ve.current)),()=>i.disconnect()},[N,ie]),d.useEffect(()=>{const i=setInterval(()=>{Oe(z=>z<_.length-1?z+1:0)},(x.speed||2)*1e3);return we||clearInterval(i),()=>clearInterval(i)},[_,we,x.speed]);const l=Ie.getSliderMarks(_,ge,x.showOnlyActiveDate,x.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${O||"light"} flex ${N?"w-fit grow-0":"w-full grow"}`,dir:k==="he"||k==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${J?J===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${k||"en"}`,N?"w-fit":"w-full",F?.graphContainer),style:{...R?.graphContainer||{},...J&&J!==!0?{backgroundColor:J}:{}},id:pe,ref:Ne,"aria-label":S||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${U?` ${U}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:J?W||"1rem":W||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[p||U||b||g?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:R?.title,description:R?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:U,width:N,graphDownload:b?Ne.current:void 0,dataDownload:g?o.map(i=>i.data).filter(i=>i!==void 0).length>0?o.map(i=>i.data).filter(i=>i!==void 0):o.filter(i=>i!==void 0):null}):null,x.enabled&&_.length>0&&l?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{ue(!we)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":we?"Click to pause animation":"Click to play animation",children:we?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Ie.xr,{min:_[0],max:_[_.length-1],marks:l,step:null,defaultValue:_[_.length-1],value:_[ge],onChangeComplete:i=>{Oe(_.indexOf(i))},onChange:i=>{Oe(_.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[Y?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:N,colorDomain:ce,colors:G,colorLegendTitle:C,setSelectedColor:be,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:ve,"aria-label":"Graph area",children:(N||r)&&(ie||s)?e.jsxRuntimeExports.jsx(lt,{data:A!==void 0?A==="total"?$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===Ee.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(z=>z==null):i),i=>ke.sum(i.size.filter(z=>!q.checkIfNullOrUndefined(z))),[a||"asc"]).filter((i,z)=>v?z<v:!0):$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===Ee.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(z=>z==null):i),i=>q.checkIfNullOrUndefined(i.size[A])?-1/0:i.size[A],[a||"asc"]).filter((i,z)=>v?z<v:!0):Re.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===Ee.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(z=>z==null):i).filter((i,z)=>v?z<v:!0),barColors:G,width:N||r,height:Math.max(M,ie||(te?M?(N||r)*te>M?(N||r)*te:M:(N||r)*te:s)),barPadding:me,showTicks:de,leftMargin:he,rightMargin:Z,topMargin:ee,bottomMargin:j,truncateBy:H,showLabels:K,tooltip:y,onSeriesMouseOver:V,showValues:re,suffix:ae,prefix:se,refValues:X,maxValue:q.checkIfNullOrUndefined(oe)?Math.max(...o.map(i=>ke.sum(i.size.filter(z=>!q.checkIfNullOrUndefined(z)))||0)):oe,onSeriesMouseClick:I,selectedColor:xe,rtl:k==="he"||k==="ar",labelOrder:D,maxBarThickness:T,minBarThickness:w,resetSelectionOnDoubleClick:L,detailsOnClick:le,barAxisTitle:P,noOfTicks:B,valueColor:Q,classNames:F,styles:R,animate:E===!0?{duration:.5,once:!0,amount:.5}:E||{duration:0,once:!0,amount:0},colorDomain:ce,precision:h,customLayers:c,naLabel:u}):null})]})}),$||ne?e.jsxRuntimeExports.jsx(Ue.GraphFooter,{styles:{footnote:R?.footnote,source:R?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:$,footNote:ne,width:N}):null]})})})})}function ut(ye){const{data:o,width:p,height:G,barColor:$,suffix:U,prefix:me,barPadding:de,showLabels:he,showValues:Z,showTicks:H,colorDomain:ie,truncateBy:N,rightMargin:ne,topMargin:ce,bottomMargin:C,leftMargin:W,tooltip:J,onSeriesMouseOver:ee,refValues:j,selectedColor:y,maxValue:V,minValue:ae,highlightedDataPoints:se,onSeriesMouseClick:K,labelOrder:te,maxBarThickness:re,minBarThickness:X,resetSelectionOnDoubleClick:pe,detailsOnClick:oe,barAxisTitle:I,valueColor:b,noOfTicks:g,styles:k,classNames:D,dimmedOpacity:M,animate:O,precision:T,customLayers:A,naLabel:v}=ye,w=d.useRef(null),Y=He.useInView(w,{once:O.once,amount:O.amount}),S={top:ce,bottom:C,left:I?W+30:W,right:ne},[L,le]=d.useState(void 0),[P,B]=d.useState(void 0),[Q,R]=d.useState(void 0),[F,m]=d.useState(void 0),E=p-S.left-S.right,h=G-S.top-S.bottom,c=qe.linear().domain([ae,V]).range([h,0]).nice(),x=o.map((t,s)=>({...t,id:te?`${t.label}`:`${s}`})),u=te||x.map(t=>`${t.id}`),a=Te.band().domain(u).range([0,X?Math.max(E,X*u.length):re?Math.min(E,re*u.length):E]).paddingInner(de),r=c.ticks(g);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{ref:w,width:`${p}px`,height:`${G}px`,viewBox:`0 0 ${p} ${G}`,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${S.left},${S.top})`,children:[e.jsxRuntimeExports.jsx(Fe.Axis,{y1:c(ae<0?0:ae),y2:c(ae<0?0:ae),x1:0-W,x2:E+S.right,label:Me.numberFormattingFunction(ae<0?0:ae,v,T,me,U),labelPos:{x:0-W,dx:0,dy:V<0?"1em":-5,y:c(ae<0?0:ae)},classNames:{axis:D?.xAxis?.axis,label:D?.yAxis?.labels},styles:{axis:k?.xAxis?.axis,label:k?.yAxis?.labels}}),H?e.jsxRuntimeExports.jsx(it.YTicksAndGridLines,{values:r.filter(t=>t!==0),y:r.filter(t=>t!==0).map(t=>c(t)),x1:0-W,x2:E+S.right,styles:{gridLines:k?.yAxis?.gridLines,labels:k?.yAxis?.labels},classNames:{gridLines:D?.yAxis?.gridLines,labels:D?.yAxis?.labels},suffix:U,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:T}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:0-W-15,y:h/2,style:k?.yAxis?.title,className:D?.yAxis?.title,text:I,rotate90:!0}),A.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[x.map((t,s)=>q.checkIfNullOrUndefined(a(t.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-g-with-hover",initial:"initial",animate:Y?"whileInView":"initial",variants:{initial:{opacity:y?t.color&&$[ie.indexOf(t.color)]===y?1:M:se.length!==0?se.indexOf(t.label)!==-1?.85:M:.85},whileInView:{opacity:y?t.color&&$[ie.indexOf(t.color)]===y?1:M:se.length!==0?se.indexOf(t.label)!==-1?.85:M:.85,transition:{duration:O.duration}}},exit:{opacity:0,transition:{duration:O.duration}},onMouseEnter:f=>{le(t),m(f.clientY),R(f.clientX),ee?.(t)},onClick:()=>{(K||oe)&&(Ae.isEqual(P,t)&&pe?(B(void 0),K?.(void 0)):(B(t),K?.(t)))},onMouseMove:f=>{le(t),m(f.clientY),R(f.clientX)},onMouseLeave:()=>{le(void 0),R(void 0),m(void 0),ee?.(void 0)},children:[t.size?e.jsxRuntimeExports.jsx(fe.motion.rect,{width:a.bandwidth(),initial:"initial",animate:Y?"whileInView":"initial",variants:{initial:{height:0,x:a(`${t.id}`),y:c(0),fill:o.filter(f=>f.color).length===0?$[0]:t.color?$[ie.indexOf(t.color)]:Ce.Colors.gray},whileInView:{height:t.size?Math.abs(c(t.size)-c(0)):0,y:t.size&&t.size>0?c(t.size):c(0),x:a(`${t.id}`),fill:o.filter(f=>f.color).length===0?$[0]:t.color?$[ie.indexOf(t.color)]:Ce.Colors.gray,transition:{duration:O.duration}}},exit:{height:0,y:c(0),transition:{duration:O.duration}}}):null,he?e.jsxRuntimeExports.jsx(tt.XAxesLabels,{value:`${t.label}`.length<N?`${t.label}`:`${`${t.label}`.substring(0,N)}...`,y:(t.size||0)<0?0:c(0)+5,x:a(`${t.id}`),width:a.bandwidth(),height:(t.size||0)<0?c(0)-5:S.bottom,style:k?.xAxis?.labels,className:D?.xAxis?.labels,alignment:(t.size||0)<0?"bottom":"top",animate:O,isInView:Y}):null,Z?e.jsxRuntimeExports.jsx(fe.motion.text,{style:{textAnchor:"middle",...k?.graphObjectValues||{}},className:e.mo("graph-value text-sm",!b&&$.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",D?.graphObjectValues),dy:t.size?t.size>=0?"-5px":"1em":"-5px",variants:{initial:{x:a(`${t.id}`)+a.bandwidth()/2,y:c(0),opacity:0,fill:b||(o.filter(f=>f.color).length===0?$[0]:t.color?$[ie.indexOf(t.color)]:Ce.Colors.gray)},whileInView:{x:a(`${t.id}`)+a.bandwidth()/2,y:c(t.size||0),fill:b||(o.filter(f=>f.color).length===0?$[0]:t.color?$[ie.indexOf(t.color)]:Ce.Colors.gray),opacity:1,transition:{duration:O.duration}}},initial:"initial",animate:Y?"whileInView":"initial",exit:{opacity:0,transition:{duration:O.duration}},children:Me.numberFormattingFunction(t.size,v,T,me,U)}):null]},t.label)),j?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:j.map((t,s)=>e.jsxRuntimeExports.jsx(Pe.RefLineY,{text:t.text,color:t.color,y:c(t.value),x1:0-W,x2:E+S.right,classNames:t.classNames,styles:t.styles,animate:O,isInView:Y},s))}):null]}),A.filter(t=>t.position==="after").map(t=>t.layer)]})}),L&&J&&Q&&F?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:L,body:J,xPos:Q,yPos:F,backgroundStyle:k?.tooltip,className:D?.tooltip}):null,oe&&P!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:P!==void 0,onClose:()=>{B(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof oe=="string"?{__html:Le.string2HTML(oe,P)}:void 0,children:typeof oe=="function"?oe(P):null})}):null]})}function ct(ye){const{data:o,graphTitle:p,colors:G,barPadding:$=.25,showTicks:U=!0,leftMargin:me=20,rightMargin:de=20,topMargin:he=20,bottomMargin:Z=25,truncateBy:H=999,showLabels:ie=!0,showValues:N=!0,backgroundColor:ne=!1,suffix:ce="",prefix:C="",sources:W,graphDescription:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,showColorScale:pe=!0,graphID:oe,maxValue:I,minValue:b,highlightedDataPoints:g=[],onSeriesMouseClick:k,graphDownload:D=!1,dataDownload:M=!1,language:O="en",theme:T="light",sortData:A,labelOrder:v,showNAColor:w=!0,minHeight:Y=0,maxBarThickness:S,maxNumberOfBars:L,minBarThickness:le,ariaLabel:P,resetSelectionOnDoubleClick:B=!0,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F=5,valueColor:m,styles:E,classNames:h,filterNA:c=!0,animate:x=!1,dimmedOpacity:u=.3,precision:a=2,customLayers:r=[],timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:s="NA"}=ye,[f,we]=d.useState(0),[ue,_]=d.useState(0),[ge,Oe]=d.useState(t.autoplay),xe=_e.sort(Se.uniqBy(o,"date",!0).map(n=>Ee.parse(`${n}`,t.dateFormat||"yyyy",new Date).getTime()),(n,je)=>Je.ascending(n,je)),[be,ve]=d.useState(t.autoplay?0:xe.length-1),[Ne,l]=d.useState(void 0),i=d.useRef(null),z=d.useRef(null);d.useEffect(()=>{const n=new ResizeObserver(je=>{we(j||je[0].target.clientWidth||620),_(ee||je[0].target.clientHeight||480)});return i.current&&(_(i.current.clientHeight||480),we(i.current.clientWidth||620),j||n.observe(i.current)),()=>n.disconnect()},[j,ee]),d.useEffect(()=>{const n=setInterval(()=>{ve(je=>je<xe.length-1?je+1:0)},(t.speed||2)*1e3);return ge||clearInterval(n),()=>clearInterval(n)},[xe,ge,t.speed]);const Ke=Ie.getSliderMarks(xe,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${T||"light"} flex ${j?"w-fit grow-0":"w-full grow"}`,dir:O==="he"||O==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${ne?ne===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${O||"en"}`,j?"w-fit":"w-full",h?.graphContainer),style:{...E?.graphContainer||{},...ne&&ne!==!0?{backgroundColor:ne}:{}},id:oe,ref:z,"aria-label":P||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${J?` ${J}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:ne?se||"1rem":se||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||J||D||M?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:E?.title,description:E?.description},classNames:{title:h?.title,description:h?.description},graphTitle:p,graphDescription:J,width:j,graphDownload:D?z.current:void 0,dataDownload:M?o.map(n=>n.data).filter(n=>n!==void 0).length>0?o.map(n=>n.data).filter(n=>n!==void 0):o.filter(n=>n!==void 0):null}):null,t.enabled&&xe.length>0&&Ke?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Oe(!ge)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ge?"Click to pause animation":"Click to play animation",children:ge?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Ie.xr,{min:xe[0],max:xe[xe.length-1],marks:Ke,step:null,defaultValue:xe[xe.length-1],value:xe[be],onChangeComplete:n=>{ve(xe.indexOf(n))},onChange:n=>{ve(xe.indexOf(n))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[pe&&o.filter(n=>n.color).length!==0?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:j,colorLegendTitle:ae,colors:G||Ce.Colors[T].categoricalColors.colors,colorDomain:V||Se.uniqBy(o,"color",!0),setSelectedColor:l,showNAColor:w}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:i,"aria-label":"Graph area",children:(j||f)&&(ee||ue)?e.jsxRuntimeExports.jsx(ut,{data:A?$e.orderBy(Re.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(n=>t.enabled?n.date===Ee.format(new Date(xe[be]),t.dateFormat||"yyyy"):n).filter(n=>c?!q.checkIfNullOrUndefined(n.size):n),[n=>n.size===void 0?A==="asc"?-1/0:1/0:n.size],[A]).filter((n,je)=>L?je<L:!0):Re.ensureCompleteDataForBarChart(o,t.dateFormat||"yyyy").filter(n=>t.enabled?n.date===Ee.format(new Date(xe[be]),t.dateFormat||"yyyy"):n).filter(n=>c?!q.checkIfNullOrUndefined(n.size):n).filter((n,je)=>L?je<L:!0),barColor:o.filter(n=>n.color).length===0?G?[G]:[Ce.Colors.primaryColors["blue-600"]]:G||Ce.Colors[T].categoricalColors.colors,colorDomain:o.filter(n=>n.color).length===0?[]:V||Se.uniqBy(o,"color",!0),width:j||f,refValues:X,height:Math.max(Y,ee||(K?Y?(j||f)*K>Y?(j||f)*K:Y:(j||f)*K:ue)),suffix:ce,prefix:C,barPadding:$,showLabels:ie,showValues:N,showTicks:U,truncateBy:H,leftMargin:me,rightMargin:de,selectedColor:Ne,topMargin:he,bottomMargin:Z,tooltip:te,onSeriesMouseOver:re,maxValue:q.checkIfNullOrUndefined(I)?Math.max(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size))<0?0:Math.max(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size)):I,minValue:q.checkIfNullOrUndefined(b)?Math.min(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size))>=0?0:Math.min(...o.filter(n=>!q.checkIfNullOrUndefined(n.size)).map(n=>n.size)):b,highlightedDataPoints:g,onSeriesMouseClick:k,labelOrder:v,maxBarThickness:S,minBarThickness:le,resetSelectionOnDoubleClick:B,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F,valueColor:m,styles:E,classNames:h,animate:x===!0?{duration:.5,once:!0,amount:.5}:x||{duration:0,once:!0,amount:0},dimmedOpacity:u,precision:a,customLayers:r,naLabel:s}):null})]})}),W||y?e.jsxRuntimeExports.jsx(Ue.GraphFooter,{styles:{footnote:E?.footnote,source:E?.source},classNames:{footnote:h?.footnote,source:h?.source},sources:W,footNote:y,width:j}):null]})})})})}function xt(ye){const{data:o,width:p,height:G,barColors:$,suffix:U,prefix:me,barPadding:de,showLabels:he,showValues:Z,showTicks:H,truncateBy:ie,leftMargin:N,rightMargin:ne,topMargin:ce,bottomMargin:C,tooltip:W,onSeriesMouseOver:J,refValues:ee,maxValue:j,minValue:y,onSeriesMouseClick:V,selectedColor:ae,labelOrder:se,maxBarThickness:K,resetSelectionOnDoubleClick:te,detailsOnClick:re,barAxisTitle:X,valueColor:pe,noOfTicks:oe,styles:I,classNames:b,animate:g,colorDomain:k,precision:D,customLayers:M,naLabel:O}=ye,T=d.useRef(null),A=He.useInView(T,{once:g.once,amount:g.amount}),v={top:ce,bottom:C,left:X?N+30:N,right:ne},[w,Y]=d.useState(void 0),[S,L]=d.useState(void 0),[le,P]=d.useState(void 0),[B,Q]=d.useState(void 0),R=p-v.left-v.right,F=G-v.top-v.bottom,m=qe.linear().domain([y,j]).range([F,0]).nice(),E=o.map((a,r)=>({...a,id:se?`${a.label}`:`${r}`})),h=se||E.map(a=>`${a.id}`),c=Te.band().domain(h).range([0,K?Math.min(R,K*h.length):R]).paddingInner(de),x=Te.band().domain(o[0].size.map((a,r)=>`${r}`)).range([0,c.bandwidth()]).paddingInner(.1),u=m.ticks(oe);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{width:`${p}px`,height:`${G}px`,viewBox:`0 0 ${p} ${G}`,direction:"ltr",ref:T,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${v.left},${v.top})`,children:[e.jsxRuntimeExports.jsx(Fe.Axis,{y1:m(y<0?0:y),y2:m(y<0?0:y),x1:0-N,x2:R+v.right,label:Me.numberFormattingFunction(y<0?0:y,O,D,me,U),labelPos:{x:0-N,dx:0,dy:j<0?"1em":-5,y:m(y<0?0:y)},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:I?.xAxis?.axis,label:I?.yAxis?.labels}}),H?e.jsxRuntimeExports.jsx(it.YTicksAndGridLines,{values:u.filter(a=>a!==0),y:u.filter(a=>a!==0).map(a=>m(a)),x1:0-N,x2:R+v.right,styles:{gridLines:I?.yAxis?.gridLines,labels:I?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:U,prefix:me,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:D}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:0-N-15,y:F/2,style:I?.yAxis?.title,className:b?.yAxis?.title,text:X,rotate90:!0}),M.filter(a=>a.position==="before").map(a=>a.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[E.map(a=>q.checkIfNullOrUndefined(c(a.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{variants:{initial:{x:c(`${a.id}`),y:0},whileInView:{x:c(`${a.id}`),y:0,transition:{duration:g.duration}}},initial:"initial",animate:A?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[a.size.map((r,t)=>e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-g-with-hover",opacity:ae?$[t]===ae?1:.3:.85,onMouseEnter:s=>{Y({...a,sizeIndex:t}),Q(s.clientY),P(s.clientX),J?.({...a,sizeIndex:t})},onMouseMove:s=>{Y({...a,sizeIndex:t}),Q(s.clientY),P(s.clientX)},onMouseLeave:()=>{Y(void 0),P(void 0),Q(void 0),J?.(void 0)},onClick:()=>{(V||re)&&(Ae.isEqual(S,{...a,sizeIndex:t})&&te?(L(void 0),V?.(void 0)):(L({...a,sizeIndex:t}),V&&V({...a,sizeIndex:t})))},children:[e.jsxRuntimeExports.jsx(fe.motion.rect,{x:x(`${t}`),width:x.bandwidth(),variants:{initial:{height:0,y:m(0),fill:$[t]},whileInView:{height:q.checkIfNullOrUndefined(r)?0:Math.abs(m(r)-m(0)),y:q.checkIfNullOrUndefined(r)?m(0):r>0?m(r):m(0),fill:$[t],transition:{duration:g.duration}}},exit:{height:0,y:m(0),transition:{duration:g.duration}},initial:"initial",animate:A?"whileInView":"initial"}),Z?e.jsxRuntimeExports.jsx(fe.motion.text,{x:x(`${t}`)+x.bandwidth()/2,style:{fill:pe||$[t],textAnchor:"middle",...I?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:r?r>=0?"-5px":"1em":"-5px",variants:{initial:{y:m(0),opacity:0},whileInView:{y:m(r||0),opacity:1,transition:{duration:g.duration}}},initial:"initial",animate:A?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:Me.numberFormattingFunction(r,O,D,me,U)}):null]},`${a.label}-${k[t]||t}`)),he?e.jsxRuntimeExports.jsx(tt.XAxesLabels,{value:`${a.label}`.length<ie?`${a.label}`:`${`${a.label}`.substring(0,ie)}...`,y:m(0)+5,x:0,width:c.bandwidth(),height:v.bottom,style:I?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:A}):null]},a.label)),ee?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ee.map((a,r)=>e.jsxRuntimeExports.jsx(Pe.RefLineY,{text:a.text,color:a.color,y:m(a.value),x1:0-N,x2:R+v.right,classNames:a.classNames,styles:a.styles,animate:g,isInView:A},r))}):null]}),M.filter(a=>a.position==="after").map(a=>a.layer)]})}),w&&W&&le&&B?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:w,body:W,xPos:le,yPos:B,backgroundStyle:I?.tooltip,className:b?.tooltip}):null,re&&S!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:S!==void 0,onClose:()=>{L(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof re=="string"?{__html:Le.string2HTML(re,S)}:void 0,children:typeof re=="function"?re(S):null})}):null]})}function dt(ye){const{data:o,graphTitle:p,colors:G=Ce.Colors.light.categoricalColors.colors,sources:$,graphDescription:U,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:Z=20,topMargin:H=20,bottomMargin:ie=25,truncateBy:N=999,showLabels:ne=!0,showValues:ce=!0,backgroundColor:C=!1,suffix:W="",prefix:J="",height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,graphID:pe,maxValue:oe,minValue:I,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:k=!1,language:D="en",theme:M="light",labelOrder:O,minHeight:T=0,maxBarThickness:A,ariaLabel:v,resetSelectionOnDoubleClick:w=!0,detailsOnClick:Y,barAxisTitle:S,noOfTicks:L=5,valueColor:le,styles:P,classNames:B,filterNA:Q=!0,showColorScale:R=!0,animate:F=!1,precision:m=2,customLayers:E=[],timeline:h={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:c="NA",sortParameter:x,sortData:u}=ye,[a,r]=d.useState(0),[t,s]=d.useState(0),[f,we]=d.useState(h.autoplay),ue=_e.sort(Se.uniqBy(o,"date",!0).map(l=>Ee.parse(`${l}`,h.dateFormat||"yyyy",new Date).getTime()),(l,i)=>Je.ascending(l,i)),[_,ge]=d.useState(h.autoplay?0:ue.length-1),[Oe,xe]=d.useState(void 0),be=d.useRef(null),ve=d.useRef(null);d.useEffect(()=>{const l=new ResizeObserver(i=>{r(j||i[0].target.clientWidth||620),s(ee||i[0].target.clientHeight||480)});return be.current&&(s(be.current.clientHeight||480),r(be.current.clientWidth||620),j||l.observe(be.current)),()=>l.disconnect()},[j,ee]),d.useEffect(()=>{const l=setInterval(()=>{ge(i=>i<ue.length-1?i+1:0)},(h.speed||2)*1e3);return f||clearInterval(l),()=>clearInterval(l)},[ue,f,h.speed]);const Ne=Ie.getSliderMarks(ue,_,h.showOnlyActiveDate,h.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${M||"light"} flex ${j?"w-fit grow-0":"w-full grow"}`,dir:D==="he"||D==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${D||"en"}`,j?"w-fit":"w-full",B?.graphContainer),style:{...P?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:pe,ref:ve,"aria-label":v||`${p?`The graph shows ${p}. `:""}This is a grouped bar chart. ${U?` ${U}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:C?se||"1rem":se||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||U||g||k?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:P?.title,description:P?.description},classNames:{title:B?.title,description:B?.description},graphTitle:p,graphDescription:U,width:j,graphDownload:g?ve.current:void 0,dataDownload:k?o.map(l=>l.data).filter(l=>l!==void 0).length>0?o.map(l=>l.data).filter(l=>l!==void 0):o.filter(l=>l!==void 0):null}):null,h.enabled&&ue.length>0&&Ne?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!f)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":f?"Click to pause animation":"Click to play animation",children:f?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Ie.xr,{min:ue[0],max:ue[ue.length-1],marks:Ne,step:null,defaultValue:ue[ue.length-1],value:ue[_],onChangeComplete:l=>{ge(ue.indexOf(l))},onChange:l=>{ge(ue.indexOf(l))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[R?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:j,colorDomain:V,colors:G,colorLegendTitle:ae,setSelectedColor:xe,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:be,"aria-label":"Graph area",children:(j||a)&&(ee||t)?e.jsxRuntimeExports.jsx(xt,{data:x!==void 0?x==="total"?$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>h.enabled?l.date===Ee.format(new Date(ue[_]),h.dateFormat||"yyyy"):l).filter(l=>Q?!l.size.every(i=>i==null):l),l=>ke.sum(l.size.filter(i=>!q.checkIfNullOrUndefined(i))),[u||"asc"]):$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>h.enabled?l.date===Ee.format(new Date(ue[_]),h.dateFormat||"yyyy"):l).filter(l=>Q?!l.size.every(i=>i==null):l),l=>q.checkIfNullOrUndefined(l.size[x])?-1/0:l.size[x],[u||"asc"]):Re.ensureCompleteDataForStackedBarChart(o,h.dateFormat||"yyyy").filter(l=>Q?!l.size.every(i=>i==null):l),barColors:G,width:j||a,height:Math.max(T,ee||(K?T?(j||a)*K>T?(j||a)*K:T:(j||a)*K:t)),suffix:W,prefix:J,barPadding:me,showLabels:ne,showValues:ce,showTicks:de,truncateBy:N,leftMargin:he,rightMargin:Z,topMargin:H,bottomMargin:ie,tooltip:te,onSeriesMouseOver:re,refValues:X,maxValue:q.checkIfNullOrUndefined(oe)?Math.max(...o.map(l=>Math.max(...l.size.filter(i=>!q.checkIfNullOrUndefined(i)))))<0?0:Math.max(...o.map(l=>Math.max(...l.size.filter(i=>!q.checkIfNullOrUndefined(i))))):oe,minValue:q.checkIfNullOrUndefined(I)?Math.min(...o.map(l=>Math.min(...l.size.filter(i=>!q.checkIfNullOrUndefined(i)))))>=0?0:Math.min(...o.map(l=>Math.min(...l.size.filter(i=>!q.checkIfNullOrUndefined(i))))):I,onSeriesMouseClick:b,selectedColor:Oe,labelOrder:O,maxBarThickness:A,resetSelectionOnDoubleClick:w,detailsOnClick:Y,barAxisTitle:S,noOfTicks:L,valueColor:le,styles:P,classNames:B,animate:F===!0?{duration:.5,once:!0,amount:.5}:F||{duration:0,once:!0,amount:0},colorDomain:V,precision:m,customLayers:E,naLabel:c}):null})]})}),$||y?e.jsxRuntimeExports.jsx(Ue.GraphFooter,{styles:{footnote:P?.footnote,source:P?.source},classNames:{footnote:B?.footnote,source:B?.source},sources:$,footNote:y,width:j}):null]})})})})}function mt(ye){const{data:o,width:p,height:G,barColors:$,barPadding:U,showLabels:me,showTicks:de,truncateBy:he,leftMargin:Z,topMargin:H,bottomMargin:ie,rightMargin:N,tooltip:ne,onSeriesMouseOver:ce,suffix:C,prefix:W,showValues:J,refValues:ee,maxValue:j,onSeriesMouseClick:y,selectedColor:V,labelOrder:ae,maxBarThickness:se,minBarThickness:K,resetSelectionOnDoubleClick:te,detailsOnClick:re,barAxisTitle:X,valueColor:pe,noOfTicks:oe,styles:I,classNames:b,animate:g,colorDomain:k,precision:D,customLayers:M,naLabel:O}=ye,T=d.useRef(null),A=He.useInView(T,{once:g.once,amount:g.amount}),v={top:H,bottom:ie,left:X?Z+30:Z,right:N},[w,Y]=d.useState(void 0),[S,L]=d.useState(void 0),[le,P]=d.useState(void 0),[B,Q]=d.useState(void 0),R=p-v.left-v.right,F=G-v.top-v.bottom,m=qe.linear().domain([0,j]).range([F,0]).nice(),E=o.map((u,a)=>({...u,id:ae?`${u.label}`:`${a}`})),h=ae||E.map(u=>`${u.id}`),c=Te.band().domain(h).range([0,K?Math.max(R,K*h.length):se?Math.min(R,se*h.length):R]).paddingInner(U),x=m.ticks(oe);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.motion.svg,{width:`${p}px`,height:`${G}px`,viewBox:`0 0 ${p} ${G}`,direction:"ltr",ref:T,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${v.left},${v.top})`,children:[e.jsxRuntimeExports.jsx(Fe.Axis,{y1:m(0),y2:m(0),x1:0-Z,x2:R+v.right,label:Me.numberFormattingFunction(0,O,D,W,C),labelPos:{x:0-Z,y:m(0),dx:0,dy:-5},classNames:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels},styles:{axis:I?.xAxis?.axis,label:I?.yAxis?.labels}}),de?e.jsxRuntimeExports.jsx(it.YTicksAndGridLines,{values:x.filter(u=>u!==0),y:x.filter(u=>u!==0).map(u=>m(u)),x1:0-Z,x2:R+v.right,styles:{gridLines:I?.yAxis?.gridLines,labels:I?.yAxis?.labels},classNames:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},suffix:C,prefix:W,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:D}):null,e.jsxRuntimeExports.jsx(Be.AxisTitle,{x:0-Z-15,y:F/2,style:I?.yAxis?.title,className:b?.yAxis?.title,text:X,rotate90:!0}),M.filter(u=>u.position==="before").map(u=>u.layer),e.jsxRuntimeExports.jsxs(Ge.AnimatePresence,{children:[E.map(u=>q.checkIfNullOrUndefined(c(u.id))?null:e.jsxRuntimeExports.jsxs(fe.motion.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",variants:{initial:{x:c(`${u.id}`),y:0},whileInView:{x:c(`${u.id}`),y:0,transition:{duration:g.duration}}},transition:{duration:g.duration},initial:"initial",animate:A?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:[u.size.map((a,r)=>e.jsxRuntimeExports.jsxs(fe.motion.g,{opacity:V?$[r]===V?1:.3:1,onMouseEnter:t=>{Y({...u,sizeIndex:r}),Q(t.clientY),P(t.clientX),ce?.({...u,sizeIndex:r})},onMouseMove:t=>{Y({...u,sizeIndex:r}),Q(t.clientY),P(t.clientX)},onMouseLeave:()=>{Y(void 0),P(void 0),Q(void 0),ce?.(void 0)},onClick:()=>{(y||re)&&(Ae.isEqual(S,{...u,sizeIndex:r})&&te?(L(void 0),y?.(void 0)):(L({...u,sizeIndex:r}),y&&y({...u,sizeIndex:r})))},children:[e.jsxRuntimeExports.jsx(fe.motion.rect,{x:0,width:c.bandwidth(),variants:{initial:{height:0,fill:$[r],y:m(0)},whileInView:{height:Math.abs(m(ke.sum(u.size.filter((t,s)=>s<=r&&t)))-m(ke.sum(u.size.filter((t,s)=>s<r&&t)))),y:m(ke.sum(u.size.filter((t,s)=>s<=r&&t))),fill:$[r],transition:{duration:g.duration}}},initial:"initial",animate:A?"whileInView":"initial",exit:{height:0,y:m(0),transition:{duration:g.duration}}}),J?e.jsxRuntimeExports.jsx(fe.motion.text,{x:c.bandwidth()/2,style:{fill:Qe.getTextColorBasedOnBgColor($[r]),textAnchor:"middle",...I?.graphObjectValues||{}},className:e.mo("graph-value text-sm",b?.graphObjectValues),dy:"0.33em",variants:{initial:{y:m(0),opacity:0,fill:Qe.getTextColorBasedOnBgColor($[r])},whileInView:{y:m(ke.sum(u.size.filter((t,s)=>s<=r&&t)))+Math.abs(m(ke.sum(u.size.filter((t,s)=>s<=r&&t)))-m(ke.sum(u.size.filter((t,s)=>s<r&&t))))/2,opacity:a&&Math.abs(m(ke.sum(u.size.filter((t,s)=>s<=r&&t)))-m(ke.sum(u.size.filter((t,s)=>s<r&&t))))>20?1:0,fill:Qe.getTextColorBasedOnBgColor($[r]),transition:{duration:g.duration}}},initial:"initial",animate:A?"whileInView":"initial",exit:{opacity:0,transition:{duration:g.duration}},children:Me.numberFormattingFunction(a,O,D,W,C)}):null]},`${u.label}-${k[r]||r}`)),me?e.jsxRuntimeExports.jsx(tt.XAxesLabels,{value:`${u.label}`.length<he?`${u.label}`:`${`${u.label}`.substring(0,he)}...`,y:m(0)+5,x:0,width:c.bandwidth(),height:v.bottom,style:I?.xAxis?.labels,className:b?.xAxis?.labels,alignment:"top",animate:g,isInView:A}):null,J?e.jsxRuntimeExports.jsx(fe.motion.text,{style:{...pe&&{fill:pe},textAnchor:"middle",...I?.graphObjectValues||{}},x:c.bandwidth()/2,dy:-10,className:e.mo("graph-value graph-value-total",pe?"text-sm":"fill-primary-gray-700 dark:fill-primary-gray-300 text-sm",b?.graphObjectValues),variants:{initial:{y:m(0),opacity:0},whileInView:{y:m(ke.sum(u.size.map(a=>a||0))),opacity:1,transition:{duration:g.duration}}},exit:{opacity:0,transition:{duration:g.duration}},initial:"initial",animate:A?"whileInView":"initial",children:Me.numberFormattingFunction(ke.sum(u.size.filter(a=>a)),O,D,W,C)}):null]},u.label)),ee?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ee.map((u,a)=>e.jsxRuntimeExports.jsx(Pe.RefLineY,{text:u.text,color:u.color,y:m(u.value),x1:0-Z,x2:R+v.right,classNames:u.classNames,styles:u.styles,animate:g,isInView:A},a))}):null]}),M.filter(u=>u.position==="after").map(u=>u.layer)]})}),w&&ne&&le&&B?e.jsxRuntimeExports.jsx(Ve.Tooltip,{data:w,body:ne,xPos:le,yPos:B,backgroundStyle:I?.tooltip,className:b?.tooltip}):null,re&&S!==void 0?e.jsxRuntimeExports.jsx(ze.X,{open:S!==void 0,onClose:()=>{L(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof re=="string"?{__html:Le.string2HTML(re,S)}:void 0,children:typeof re=="function"?re(S):null})}):null]})}function ht(ye){const{data:o,graphTitle:p,colors:G=Ce.Colors.light.categoricalColors.colors,sources:$,graphDescription:U,barPadding:me=.25,showTicks:de=!0,leftMargin:he=20,rightMargin:Z=20,topMargin:H=20,bottomMargin:ie=25,truncateBy:N=999,showLabels:ne=!0,showValues:ce=!0,backgroundColor:C=!1,showColorScale:W=!0,suffix:J="",prefix:ee="",height:j,width:y,footNote:V,colorDomain:ae,colorLegendTitle:se,padding:K,tooltip:te,onSeriesMouseOver:re,relativeHeight:X,refValues:pe,graphID:oe,maxValue:I,onSeriesMouseClick:b,graphDownload:g=!1,dataDownload:k=!1,language:D="en",theme:M="light",labelOrder:O,minHeight:T=0,maxBarThickness:A,sortParameter:v,maxNumberOfBars:w,minBarThickness:Y,ariaLabel:S,resetSelectionOnDoubleClick:L=!0,detailsOnClick:le,barAxisTitle:P,noOfTicks:B=5,valueColor:Q,styles:R,classNames:F,filterNA:m=!0,animate:E=!1,precision:h=2,customLayers:c=[],timeline:x={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:u="NA",sortData:a}=ye,[r,t]=d.useState(0),[s,f]=d.useState(0),[we,ue]=d.useState(x.autoplay),_=_e.sort(Se.uniqBy(o,"date",!0).map(i=>Ee.parse(`${i}`,x.dateFormat||"yyyy",new Date).getTime()),(i,z)=>Je.ascending(i,z)),[ge,Oe]=d.useState(x.autoplay?0:_.length-1),[xe,be]=d.useState(void 0),ve=d.useRef(null),Ne=d.useRef(null);d.useEffect(()=>{const i=new ResizeObserver(z=>{t(y||z[0].target.clientWidth||620),f(j||z[0].target.clientHeight||480)});return ve.current&&(f(ve.current.clientHeight||480),t(ve.current.clientWidth||620),y||i.observe(ve.current)),()=>i.disconnect()},[y,j]),d.useEffect(()=>{const i=setInterval(()=>{Oe(z=>z<_.length-1?z+1:0)},(x.speed||2)*1e3);return we||clearInterval(i),()=>clearInterval(i)},[_,we,x.speed]);const l=Ie.getSliderMarks(_,ge,x.showOnlyActiveDate,x.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${M||"light"} flex ${y?"w-fit grow-0":"w-full grow"}`,dir:D==="he"||D==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${D||"en"}`,y?"w-fit":"w-full",F?.graphContainer),style:{...R?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:oe,ref:Ne,"aria-label":S||`${p?`The graph shows ${p}. `:""}This is a stacked bar chart. ${U?` ${U}`:""}`,children:e.jsxRuntimeExports.jsx("div",{style:{padding:C?K||"1rem":K||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[p||U||g||k?e.jsxRuntimeExports.jsx(We.GraphHeader,{styles:{title:R?.title,description:R?.description},classNames:{title:F?.title,description:F?.description},graphTitle:p,graphDescription:U,width:y,graphDownload:g?Ne.current:void 0,dataDownload:k?o.map(i=>i.data).filter(i=>i!==void 0).length>0?o.map(i=>i.data).filter(i=>i!==void 0):o.filter(i=>i!==void 0):null}):null,x.enabled&&_.length>0&&l?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{ue(!we)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":we?"Click to pause animation":"Click to play animation",children:we?e.jsxRuntimeExports.jsx(De.Pause,{}):e.jsxRuntimeExports.jsx(De.Play,{})}),e.jsxRuntimeExports.jsx(Ie.xr,{min:_[0],max:_[_.length-1],marks:l,step:null,defaultValue:_[_.length-1],value:_[ge],onChangeComplete:i=>{Oe(_.indexOf(i))},onChange:i=>{Oe(_.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?e.jsxRuntimeExports.jsx(Ye.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[W?e.jsxRuntimeExports.jsx(Xe.ColorLegendWithMouseOver,{width:y,colorDomain:ae,colors:G,colorLegendTitle:se,setSelectedColor:be,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:ve,"aria-label":"Graph area",children:(y||r)&&(j||s)?e.jsxRuntimeExports.jsx(mt,{data:v!==void 0?v==="total"?$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===Ee.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(z=>z==null):i),i=>ke.sum(i.size.filter(z=>!q.checkIfNullOrUndefined(z))),[a||"asc"]).filter((i,z)=>w?z<w:!0):$e.orderBy(Re.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>x.enabled?i.date===Ee.format(new Date(_[ge]),x.dateFormat||"yyyy"):i).filter(i=>m?!i.size.every(z=>z==null):i),i=>q.checkIfNullOrUndefined(i.size[v])?-1/0:i.size[v],[a||"asc"]).filter((i,z)=>w?z<w:!0):Re.ensureCompleteDataForStackedBarChart(o,x.dateFormat||"yyyy").filter(i=>m?!i.size.every(z=>z==null):i).filter((i,z)=>w?z<w:!0),barColors:G,width:y||r,height:Math.max(T,j||(X?T?(y||r)*X>T?(y||r)*X:T:(y||r)*X:s)),barPadding:me,showLabels:ne,showTicks:de,truncateBy:N,leftMargin:he,rightMargin:Z,topMargin:H,bottomMargin:ie,tooltip:te,onSeriesMouseOver:re,showValues:ce,suffix:J,prefix:ee,refValues:pe,maxValue:q.checkIfNullOrUndefined(I)?Math.max(...o.map(i=>ke.sum(i.size.filter(z=>!q.checkIfNullOrUndefined(z)))||0)):I,onSeriesMouseClick:b,selectedColor:xe,labelOrder:O,maxBarThickness:A,minBarThickness:Y,resetSelectionOnDoubleClick:L,detailsOnClick:le,barAxisTitle:P,noOfTicks:B,valueColor:Q,styles:R,classNames:F,animate:E===!0?{duration:.5,once:!0,amount:.5}:E||{duration:0,once:!0,amount:0},colorDomain:ae,precision:h,customLayers:c,naLabel:u}):null})]})}),$||V?e.jsxRuntimeExports.jsx(Ue.GraphFooter,{styles:{footnote:R?.footnote,source:R?.source},classNames:{footnote:F?.footnote,source:F?.source},sources:$,footNote:V,width:y}):null]})})})})}function pt(ye){const{data:o,graphTitle:p,colors:G,barPadding:$,showTicks:U,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Z,truncateBy:H,showLabels:ie,showValues:N,backgroundColor:ne,suffix:ce,prefix:C,sources:W,graphDescription:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,showColorScale:pe,graphID:oe,maxValue:I,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:k,graphDownload:D,dataDownload:M,language:O,theme:T,sortData:A,labelOrder:v,showNAColor:w,minHeight:Y,maxBarThickness:S,maxNumberOfBars:L,minBarThickness:le,ariaLabel:P,resetSelectionOnDoubleClick:B,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F,valueColor:m,orientation:E="vertical",styles:h,classNames:c,filterNA:x,animate:u,dimmedOpacity:a,precision:r,customLayers:t,timeline:s,naLabel:f}=ye;return E==="vertical"?e.jsxRuntimeExports.jsx(ct,{data:o,graphTitle:p,colors:G,barPadding:$,showTicks:U,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Z,truncateBy:H,showLabels:ie,showValues:N,backgroundColor:ne,suffix:ce,prefix:C,sources:W,graphDescription:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,showColorScale:pe,graphID:oe,maxValue:I,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:k,graphDownload:D,dataDownload:M,language:O,theme:T,sortData:A,labelOrder:v,showNAColor:w,minHeight:Y,maxBarThickness:S,maxNumberOfBars:L,minBarThickness:le,ariaLabel:P,resetSelectionOnDoubleClick:B,styles:h,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F,valueColor:m,classNames:c,filterNA:x,animate:u,dimmedOpacity:a,precision:r,customLayers:t,timeline:s,naLabel:f}):e.jsxRuntimeExports.jsx(st,{data:o,graphTitle:p,colors:G,barPadding:$,showTicks:U,leftMargin:me,rightMargin:de,topMargin:he,bottomMargin:Z,truncateBy:H,showLabels:ie,showValues:N,backgroundColor:ne,suffix:ce,prefix:C,sources:W,graphDescription:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,showColorScale:pe,graphID:oe,maxValue:I,minValue:b,highlightedDataPoints:g,onSeriesMouseClick:k,graphDownload:D,dataDownload:M,language:O,theme:T,sortData:A,labelOrder:v,showNAColor:w,minHeight:Y,maxBarThickness:S,maxNumberOfBars:L,minBarThickness:le,ariaLabel:P,resetSelectionOnDoubleClick:B,styles:h,detailsOnClick:Q,barAxisTitle:R,noOfTicks:F,valueColor:m,classNames:c,filterNA:x,animate:u,dimmedOpacity:a,precision:r,customLayers:t,timeline:s,naLabel:f})}function gt(ye){const{data:o,graphTitle:p,colors:G,sources:$,graphDescription:U,barPadding:me,showTicks:de,truncateBy:he,height:Z,width:H,footNote:ie,colorDomain:N,colorLegendTitle:ne,suffix:ce,prefix:C,showValues:W,padding:J,backgroundColor:ee,leftMargin:j,rightMargin:y,topMargin:V,bottomMargin:ae,showLabels:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,graphID:pe,maxValue:oe,minValue:I,onSeriesMouseClick:b,graphDownload:g,dataDownload:k,language:D,labelOrder:M,minHeight:O,theme:T,sortParameter:A,sortData:v,maxBarThickness:w,ariaLabel:Y,resetSelectionOnDoubleClick:S,detailsOnClick:L,barAxisTitle:le,noOfTicks:P,valueColor:B,orientation:Q="vertical",styles:R,classNames:F,filterNA:m,animate:E,precision:h,customLayers:c,showColorScale:x,timeline:u,naLabel:a}=ye;return Q==="vertical"?e.jsxRuntimeExports.jsx(dt,{data:o,graphTitle:p,colors:G,sources:$,graphDescription:U,barPadding:me,showTicks:de,truncateBy:he,height:Z,width:H,footNote:ie,colorDomain:N,colorLegendTitle:ne,suffix:ce,prefix:C,showValues:W,padding:J,backgroundColor:ee,leftMargin:j,rightMargin:y,sortParameter:A,sortData:v,topMargin:V,bottomMargin:ae,showLabels:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,graphID:pe,maxValue:oe,minValue:I,onSeriesMouseClick:b,graphDownload:g,dataDownload:k,language:D,labelOrder:M,minHeight:O,theme:T,maxBarThickness:w,ariaLabel:Y,resetSelectionOnDoubleClick:S,styles:R,detailsOnClick:L,barAxisTitle:le,noOfTicks:P,valueColor:B,classNames:F,filterNA:m,animate:E,precision:h,customLayers:c,showColorScale:x,timeline:u,naLabel:a}):e.jsxRuntimeExports.jsx(nt,{data:o,graphTitle:p,colors:G,sortParameter:A,sortData:v,sources:$,graphDescription:U,barPadding:me,showTicks:de,truncateBy:he,height:Z,width:H,footNote:ie,colorDomain:N,colorLegendTitle:ne,suffix:ce,prefix:C,showValues:W,padding:J,backgroundColor:ee,leftMargin:j,rightMargin:y,topMargin:V,bottomMargin:ae,showLabels:se,relativeHeight:K,tooltip:te,onSeriesMouseOver:re,refValues:X,graphID:pe,maxValue:oe,minValue:I,onSeriesMouseClick:b,graphDownload:g,dataDownload:k,language:D,labelOrder:M,minHeight:O,theme:T,maxBarThickness:w,ariaLabel:Y,resetSelectionOnDoubleClick:S,styles:R,detailsOnClick:L,barAxisTitle:le,noOfTicks:P,valueColor:B,classNames:F,filterNA:m,animate:E,precision:h,customLayers:c,showColorScale:x,timeline:u,naLabel:a})}function ft(ye){const{data:o,graphTitle:p,colors:G,sources:$,graphDescription:U,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Z,topMargin:H,bottomMargin:ie,truncateBy:N,showLabels:ne,showValues:ce,backgroundColor:C,suffix:W,prefix:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,tooltip:K,onSeriesMouseOver:te,relativeHeight:re,refValues:X,graphID:pe,maxValue:oe,onSeriesMouseClick:I,graphDownload:b,dataDownload:g,language:k,theme:D,labelOrder:M,minHeight:O,maxBarThickness:T,sortParameter:A,sortData:v,maxNumberOfBars:w,minBarThickness:Y,ariaLabel:S,resetSelectionOnDoubleClick:L,detailsOnClick:le,barAxisTitle:P,noOfTicks:B,valueColor:Q,orientation:R="vertical",styles:F,classNames:m,filterNA:E,animate:h,precision:c,customLayers:x,showColorScale:u,timeline:a,naLabel:r}=ye;return R==="vertical"?e.jsxRuntimeExports.jsx(ht,{data:o,graphTitle:p,colors:G,sources:$,graphDescription:U,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Z,topMargin:H,bottomMargin:ie,truncateBy:N,showLabels:ne,showValues:ce,backgroundColor:C,suffix:W,prefix:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,tooltip:K,onSeriesMouseOver:te,relativeHeight:re,refValues:X,graphID:pe,maxValue:oe,onSeriesMouseClick:I,graphDownload:b,dataDownload:g,language:k,theme:D,labelOrder:M,minHeight:O,maxBarThickness:T,sortParameter:A,sortData:v,maxNumberOfBars:w,minBarThickness:Y,ariaLabel:S,resetSelectionOnDoubleClick:L,styles:F,detailsOnClick:le,barAxisTitle:P,noOfTicks:B,valueColor:Q,classNames:m,filterNA:E,animate:h,precision:c,customLayers:x,showColorScale:u,timeline:a,naLabel:r}):e.jsxRuntimeExports.jsx(ot,{data:o,graphTitle:p,colors:G,sources:$,graphDescription:U,barPadding:me,showTicks:de,leftMargin:he,rightMargin:Z,topMargin:H,bottomMargin:ie,truncateBy:N,showLabels:ne,showValues:ce,backgroundColor:C,suffix:W,prefix:J,height:ee,width:j,footNote:y,colorDomain:V,colorLegendTitle:ae,padding:se,tooltip:K,onSeriesMouseOver:te,relativeHeight:re,refValues:X,graphID:pe,maxValue:oe,onSeriesMouseClick:I,graphDownload:b,dataDownload:g,language:k,theme:D,labelOrder:M,minHeight:O,maxBarThickness:T,sortParameter:A,sortData:v,maxNumberOfBars:w,minBarThickness:Y,ariaLabel:S,resetSelectionOnDoubleClick:L,styles:F,detailsOnClick:le,barAxisTitle:P,noOfTicks:B,valueColor:Q,classNames:m,filterNA:E,animate:h,precision:c,customLayers:x,showColorScale:u,timeline:a,naLabel:r})}exports.GroupedBarGraph=gt;exports.SimpleBarGraph=pt;exports.StackedBarGraph=ft;
2
2
  //# sourceMappingURL=BarGraph.cjs.map
package/dist/BarGraph.js CHANGED
@@ -11,7 +11,7 @@ import { c as X } from "./checkIfNullOrUndefined-DmfiKkNw.js";
11
11
  import { Colors as je } from "./Colors.js";
12
12
  import { s as Ge } from "./string2HTML-oFCROsus.js";
13
13
  import { X as st } from "./XTicksAndGridLines-Bn9u5gOM.js";
14
- import { Y as rt } from "./YAxesLabels-DSm6I5zG.js";
14
+ import { Y as rt } from "./YAxesLabels-DECkMgq8.js";
15
15
  import { A as Xe } from "./AxisTitle-BmHLMRJZ.js";
16
16
  import { A as Ye } from "./Axis-Ddg-seDi.js";
17
17
  import { a as ot, R as nt } from "./ReferenceLine-CfAW3vKJ.js";
@@ -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 i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),x=require("react"),ve=require("./parse-hMnG_lRV.cjs"),Oe=require("./getSliderMarks-CRIbTGYV.cjs"),Me=require("./index-CQ3e6Ewi.cjs"),Le=require("./index-DQA8q5sC.cjs"),Ve=require("./Modal-tXZlLE5s.cjs"),Te=require("./numberFormattingFunction-02t-wJta.cjs"),$e=require("./Tooltip-De16GWhY.cjs"),A=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ae=require("./string2HTML-z7CwHXcx.cjs"),Ze=require("./XTicksAndGridLines-CCzXIV8d.cjs"),qe=require("./AxisTitle-CK9YeovX.cjs"),et=require("./YAxesLabels-CctDydGR.cjs"),Fe=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Pe=require("./ReferenceLine-CFVBBN__.cjs"),Be=require("./linear-BVckp9RD.cjs"),He=require("./band-CAApY4Pd.cjs"),We=require("./use-in-view-sQJZ_xDO.cjs"),le=require("./proxy-BHRoeZgd.cjs"),Ue=require("./index-BW8iNx7E.cjs"),Ge=require("./GraphHeader.cjs"),Xe=require("./GraphFooter.cjs"),Ye=require("./ColorLegendWithMouseOver.cjs"),_e=require("./Colors.cjs"),ze=require("./EmptyState-d8_8SxeW.cjs"),Ne=require("./index-BW_-wD2k.cjs"),je=require("./ensureCompleteData-DkQYPeDa.cjs"),Je=require("./uniqBy-O05lp2S5.cjs"),Ke=require("./sort-O96oMZLb.cjs"),Qe=require("./init-DU0ybBc_.cjs"),tt=require("./Axis-DE7dSn1_.cjs"),it=require("./XAxesLabels-Drf7M3YK.cjs");function at(ye){const{data:l,dotColors:g,suffix:_,prefix:z,barPadding:w,showValues:ue,showTicks:Z,leftMargin:ee,truncateBy:ce,width:te,height:ie,rightMargin:J,topMargin:N,bottomMargin:s,radius:q,showLabels:xe,tooltip:O,onSeriesMouseOver:F,maxValue:E,minValue:ae,onSeriesMouseClick:B,selectedColor:I,arrowConnector:R,connectorStrokeWidth:pe,maxBarThickness:re,minBarThickness:ne,resetSelectionOnDoubleClick:ge,detailsOnClick:v,axisTitle:U,noOfTicks:fe,valueColor:se,styles:d,classNames:h,labelOrder:D,refValues:oe,rtl:y,animate:u,precision:M,customLayers:G,highlightedDataPoints:X,dimmedOpacity:L}=ye,j=x.useRef(null),p=We.useInView(j,{once:u.once,amount:u.amount}),m={top:U?N+25:N,bottom:s,left:ee,right:J},H=te-m.left-m.right,W=ie-m.top-m.bottom,[K,P]=x.useState(void 0),[C,b]=x.useState(void 0),[S,Q]=x.useState(void 0),[V,$]=x.useState(void 0),Y=l.map((t,n)=>({...t,id:D?`${t.label}`:`${n}`})),k=D||Y.map(t=>`${t.id}`),f=Be.linear().domain([ae,E]).range([0,H]).nice(),T=He.band().domain(k).range([0,ne?Math.max(W,ne*Y.length):re?Math.min(W,re*Y.length):W]).paddingInner(w),a=f.ticks(fe);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsxs(le.motion.svg,{width:`${te}px`,height:`${ie}px`,viewBox:`0 0 ${te} ${ie}`,direction:"ltr",ref:j,children:[R?i.jsxRuntimeExports.jsx("defs",{children:i.jsxRuntimeExports.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsxRuntimeExports.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-primary-gray-600 dark:fill-primary-gray-300"})})}):null,i.jsxRuntimeExports.jsxs("g",{transform:`translate(${m.left},${m.top})`,children:[Z?i.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:a.filter((t,n)=>n!==0),x:a.filter((t,n)=>n!==0).map(t=>f(t)),y1:0-N,y2:W+m.bottom,styles:{gridLines:d?.xAxis?.gridLines,labels:d?.xAxis?.labels},classNames:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},suffix:_,prefix:z,labelType:"secondary",showGridLines:!0,precision:M}):null,i.jsxRuntimeExports.jsx(qe.AxisTitle,{x:H/2,y:0-m.top+15,style:d?.xAxis?.title,className:h?.xAxis?.title,text:U}),i.jsxRuntimeExports.jsx(Fe.YTicksAndGridLines,{y:Y.map(t=>T(`${t.id}`)+T.bandwidth()/2),x1:0,x2:H,styles:{gridLines:d?.yAxis?.gridLines},classNames:{gridLines:h?.yAxis?.gridLines},labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:M}),G.filter(t=>t.position==="before").map(t=>t.layer),i.jsxRuntimeExports.jsxs(Ue.AnimatePresence,{children:[Y.map(t=>i.jsxRuntimeExports.jsxs(le.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{x:0,y:T(`${t.id}`)+T.bandwidth()/2,opacity:X.length!==0?X.indexOf(t.label)!==-1?.85:L:.85},whileInView:{x:0,y:T(`${t.id}`)+T.bandwidth()/2,opacity:X.length!==0?X.indexOf(t.label)!==-1?.85:L:.85,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",exit:{opacity:0,transition:{duration:u.duration}},children:[xe?i.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${t.label}`.length<ce?`${t.label}`:`${`${t.label}`.substring(0,ce)}...`,y:0-T.bandwidth()/2,x:0-m.left,width:m.left,height:T.bandwidth(),alignment:"right",style:d?.yAxis?.labels,className:h?.yAxis?.labels,animate:u,isInView:p}):null,i.jsxRuntimeExports.jsx(le.motion.line,{y1:0,y2:0,style:{strokeWidth:pe,...d?.dataConnectors||{},opacity:I?.3:1},className:i.mo("stroke-primary-gray-600 dark:stroke-primary-gray-300",h?.dataConnectors),markerEnd:R&&t.x.indexOf(Math.min(...t.x.filter(n=>n!==null)))===0?"url(#arrow)":"",markerStart:R&&t.x.indexOf(Math.min(...t.x.filter(n=>n!==null)))===t.x.length-1?"url(#arrow)":"",exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{x1:0,x2:0},whileInView:{x1:f(Math.min(...t.x.filter(n=>n!==null)))+q,x2:f(Math.max(...t.x.filter(n=>n!==null)))-q,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial"}),t.x.map((n,o)=>i.jsxRuntimeExports.jsx(le.motion.g,{onMouseEnter:de=>{P({...t,xIndex:o}),$(de.clientY),Q(de.clientX),F?.({...t,xIndex:o})},onClick:()=>{(B||v)&&(Le.isEqual(C,{...t,xIndex:o})&&ge?(b(void 0),B?.(void 0)):(b({...t,xIndex:o}),B&&B({...t,xIndex:o})))},onMouseMove:de=>{P({...t,xIndex:o}),$(de.clientY),Q(de.clientX)},onMouseLeave:()=>{P(void 0),Q(void 0),$(void 0),F?.(void 0)},exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{opacity:I?g[o]===I?1:.3:1},whileInView:{opacity:I?g[o]===I?1:.3:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",children:A.checkIfNullOrUndefined(n)?null:i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(le.motion.circle,{cy:0,r:q,style:{fill:g[o],fillOpacity:.85,stroke:g[o],strokeWidth:1,opacity:A.checkIfNullOrUndefined(n)?0:1},exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{cx:f(0),opacity:0},whileInView:{cx:f(n||0),opacity:A.checkIfNullOrUndefined(n)?0:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial"}),ue?i.jsxRuntimeExports.jsx(le.motion.text,{y:0,style:{fill:se||g[o],textAnchor:"middle",...d?.graphObjectValues||{}},dx:0,dy:0-q-3,className:i.mo("graph-value text-sm font-bold",A.checkIfNullOrUndefined(n)?"0opacity-0":"opacity-100",h?.graphObjectValues),exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{x:f(0),opacity:0},whileInView:{x:f(n||0),opacity:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",children:Te.numberFormattingFunction(n,"NA",M,z,_)}):null]})},o))]},t.label)),oe?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:oe.map((t,n)=>i.jsxRuntimeExports.jsx(Pe.RefLineX,{text:t.text,color:t.color,x:f(t.value),y1:0-m.top,y2:W+m.bottom,textSide:f(t.value)>H*.75||y?"left":"right",classNames:t.classNames,styles:t.styles,animate:u,isInView:p},n))}):null]}),G.filter(t=>t.position==="after").map(t=>t.layer)]})]}),K&&O&&S&&V?i.jsxRuntimeExports.jsx($e.Tooltip,{data:K,body:O,xPos:S,yPos:V,backgroundStyle:d?.tooltip,className:h?.tooltip}):null,v&&C!==void 0?i.jsxRuntimeExports.jsx(Ve.X,{open:C!==void 0,onClose:()=>{b(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof v=="string"?{__html:Ae.string2HTML(v,C)}:void 0,children:typeof v=="function"?v(C):null})}):null]})}function rt(ye){const{data:l,graphTitle:g,colors:_=_e.Colors.light.categoricalColors.colors,sources:z,graphDescription:w,barPadding:ue=.25,showTicks:Z=!0,leftMargin:ee=100,rightMargin:ce=40,topMargin:te=20,bottomMargin:ie=10,truncateBy:J=999,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E=!1,radius:ae=3,showLabels:B=!0,tooltip:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne="",prefix:ge="",maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se=!1,dataDownload:d=!1,showValues:h=!0,sortParameter:D,arrowConnector:oe=!1,connectorStrokeWidth:y=2,language:u="en",minHeight:M=0,theme:G="light",labelOrder:X,maxBarThickness:L,maxNumberOfBars:j,minBarThickness:p,ariaLabel:m,resetSelectionOnDoubleClick:H=!0,detailsOnClick:W,axisTitle:K,noOfTicks:P=5,valueColor:C,styles:b,classNames:S,refValues:Q,filterNA:V=!0,animate:$=!1,precision:Y=2,customLayers:k=[],showColorScale:f=!0,highlightedDataPoints:T=[],dimmedOpacity:a=.3,timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},sortData:n}=ye,[o,de]=x.useState(0),[ke,Ee]=x.useState(0),[me,Ie]=x.useState(t.autoplay),c=Ke.sort(Je.uniqBy(l,"date",!0).map(e=>ve.parse(`${e}`,t.dateFormat||"yyyy",new Date).getTime()),(e,r)=>Qe.ascending(e,r)),[be,we]=x.useState(t.autoplay?0:c.length-1),[De,Se]=x.useState(void 0),he=x.useRef(null),Re=x.useRef(null);x.useEffect(()=>{const e=new ResizeObserver(r=>{de(s||r[0].target.clientWidth||620),Ee(N||r[0].target.clientHeight||480)});return he.current&&(Ee(he.current.clientHeight||480),de(he.current.clientWidth||620),s||e.observe(he.current)),()=>e.disconnect()},[s,N]),x.useEffect(()=>{const e=setInterval(()=>{we(r=>r<c.length-1?r+1:0)},(t.speed||2)*1e3);return me||clearInterval(e),()=>clearInterval(e)},[c,me,t.speed]);const Ce=Oe.getSliderMarks(c,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return i.jsxRuntimeExports.jsx("div",{className:`${G||"light"} flex ${s?"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"}`,s?"w-fit":"w-full",S?.graphContainer),style:{...b?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:re,ref:Re,"aria-label":m||`${g?`The graph shows ${g}. `:""}This is a dumbbell chart that shows comparisons between two or more data points across categories. ${w?` ${w}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?F||"1rem":F||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[g||w||se||d?i.jsxRuntimeExports.jsx(Ge.GraphHeader,{styles:{title:b?.title,description:b?.description},classNames:{title:S?.title,description:S?.description},graphTitle:g,graphDescription:w,width:s,graphDownload:se?Re.current:void 0,dataDownload:d?l.map(e=>e.data).filter(e=>e!==void 0).length>0?l.map(e=>e.data).filter(e=>e!==void 0):l.filter(e=>e!==void 0):null}):null,t.enabled&&c.length>0&&Ce?i.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[i.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Ie(!me)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":me?"Click to pause animation":"Click to play animation",children:me?i.jsxRuntimeExports.jsx(Ne.Pause,{}):i.jsxRuntimeExports.jsx(Ne.Play,{})}),i.jsxRuntimeExports.jsx(Oe.xr,{min:c[0],max:c[c.length-1],marks:Ce,step:null,defaultValue:c[c.length-1],value:c[be],onChangeComplete:e=>{we(c.indexOf(e))},onChange:e=>{we(c.indexOf(e))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?i.jsxRuntimeExports.jsx(ze.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[f?i.jsxRuntimeExports.jsx(Ye.ColorLegendWithMouseOver,{width:s,colorDomain:xe,colors:_,colorLegendTitle:O,setSelectedColor:Se,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow w-full justify-center leading-0",ref:he,"aria-label":"Graph area",children:(s||o)&&(N||ke)?i.jsxRuntimeExports.jsx(at,{data:D!==void 0?D==="diff"?Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[e.x.length-1])||A.checkIfNullOrUndefined(e.x[0])?-1/0:e.x[e.x.length-1]-e.x[0],[n||"asc"]).filter((e,r)=>j?r<j:!0):Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[D])?-1/0:e.x[D],[n||"asc"]).filter((e,r)=>j?r<j:!0):je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>V?!e.x.every(r=>r==null):e).filter((e,r)=>j?r<j:!0),dotColors:_,width:s||o,height:Math.max(M,N||(R?M?(s||o)*R>M?(s||o)*R:M:(s||o)*R:ke)),suffix:ne,prefix:ge,radius:ae,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,showLabels:B,showValues:h,tooltip:I,onSeriesMouseOver:pe,maxValue:A.checkIfNullOrUndefined(v)?Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null))))<0?0:Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null)))):v,minValue:A.checkIfNullOrUndefined(U)?Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null))))>0?0:Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null)))):U,onSeriesMouseClick:fe,selectedColor:De,arrowConnector:oe,connectorStrokeWidth:y,maxBarThickness:L,minBarThickness:p,resetSelectionOnDoubleClick:H,detailsOnClick:W,axisTitle:K,noOfTicks:P,valueColor:C,styles:b,classNames:S,labelOrder:X,refValues:Q,rtl:u==="he"||u==="ar",animate:$===!0?{duration:.5,once:!0,amount:.5}:$||{duration:0,once:!0,amount:0},precision:Y,customLayers:k,highlightedDataPoints:T,dimmedOpacity:a}):null})]})}),z||q?i.jsxRuntimeExports.jsx(Xe.GraphFooter,{styles:{footnote:b?.footnote,source:b?.source},classNames:{footnote:S?.footnote,source:S?.source},sources:z,footNote:q,width:s}):null]})})})})}function nt(ye){const{data:l,dotColors:g,barPadding:_,showTicks:z,leftMargin:w,truncateBy:ue,width:Z,height:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,radius:J,showLabels:N,tooltip:s,onSeriesMouseOver:q,maxValue:xe,minValue:O,onSeriesMouseClick:F,showValues:E,suffix:ae,prefix:B,selectedColor:I,arrowConnector:R,connectorStrokeWidth:pe,maxBarThickness:re,minBarThickness:ne,resetSelectionOnDoubleClick:ge,detailsOnClick:v,axisTitle:U,noOfTicks:fe,valueColor:se,styles:d,classNames:h,labelOrder:D,refValues:oe,animate:y,precision:u,customLayers:M,highlightedDataPoints:G,dimmedOpacity:X}=ye,L=x.useRef(null),j=We.useInView(L,{once:y.once,amount:y.amount}),p={top:te,bottom:ie,left:U?w+30:w,right:ce},m=Z-p.left-p.right,H=ee-p.top-p.bottom,[W,K]=x.useState(void 0),[P,C]=x.useState(void 0),[b,S]=x.useState(void 0),[Q,V]=x.useState(void 0),$=l.map((a,t)=>({...a,id:D?`${a.label}`:`${t}`})),Y=D||$.map(a=>`${a.id}`),k=Be.linear().domain([O,xe]).range([H,0]).nice(),f=He.band().domain(Y).range([0,ne?Math.max(m,ne*$.length):re?Math.min(m,re*$.length):m]).paddingInner(_),T=k.ticks(fe);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsxs(le.motion.svg,{width:`${Z}px`,height:`${ee}px`,viewBox:`0 0 ${Z} ${ee}`,direction:"ltr",ref:L,children:[R?i.jsxRuntimeExports.jsx("defs",{children:i.jsxRuntimeExports.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsxRuntimeExports.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-primary-gray-600 dark:fill-primary-gray-300"})})}):null,i.jsxRuntimeExports.jsxs("g",{transform:`translate(${p.left},${p.top})`,children:[i.jsxRuntimeExports.jsx(tt.Axis,{y1:k(O<0?0:O),y2:k(O<0?0:O),x1:0-w,x2:m+p.right,label:Te.numberFormattingFunction(O<0?0:O,"NA",u,B,ae),labelPos:{x:0-w,dx:0,dy:xe<0?"1em":-5,y:k(O<0?0:O)},classNames:{axis:h?.xAxis?.axis,label:h?.yAxis?.labels},styles:{axis:d?.xAxis?.axis,label:d?.yAxis?.labels}}),z?i.jsxRuntimeExports.jsx(Fe.YTicksAndGridLines,{values:T.filter(a=>a!==0),y:T.filter(a=>a!==0).map(a=>k(a)),x1:0-w,x2:m+p.right,styles:{gridLines:d?.yAxis?.gridLines,labels:d?.yAxis?.labels},classNames:{gridLines:h?.yAxis?.gridLines,labels:h?.yAxis?.labels},suffix:ae,prefix:B,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:u}):null,i.jsxRuntimeExports.jsx(qe.AxisTitle,{x:0-w-15,y:H/2,style:d?.yAxis?.title,className:h?.yAxis?.title,text:U,rotate90:!0}),M.filter(a=>a.position==="before").map(a=>a.layer),i.jsxRuntimeExports.jsxs(Ue.AnimatePresence,{children:[$.map(a=>i.jsxRuntimeExports.jsxs(le.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{x:f(`${a.id}`)+f.bandwidth()/2,y:0,opacity:G.length!==0?G.indexOf(a.label)!==-1?.85:X:.85},whileInView:{x:f(`${a.id}`)+f.bandwidth()/2,y:0,opacity:G.length!==0?G.indexOf(a.label)!==-1?.85:X:.85,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:y.duration}},children:[N?i.jsxRuntimeExports.jsx(it.XAxesLabels,{value:`${a.label}`.length<ue?`${a.label}`:`${`${a.label}`.substring(0,ue)}...`,y:H+5,x:0-f.bandwidth()/2,width:f.bandwidth(),height:p.bottom,style:d?.xAxis?.labels,className:h?.xAxis?.labels,alignment:"top",animate:y,isInView:j}):null,i.jsxRuntimeExports.jsx(le.motion.line,{x1:0,x2:0,style:{strokeWidth:pe,...d?.dataConnectors||{},opacity:I?.3:1},className:i.mo("stroke-primary-gray-600 dark:stroke-primary-gray-300",h?.dataConnectors),markerEnd:R&&a.x.indexOf(Math.min(...a.x.filter(t=>t!==null)))===0?"url(#arrow)":"",markerStart:R&&a.x.indexOf(Math.min(...a.x.filter(t=>t!==null)))===a.x.length-1?"url(#arrow)":"",exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{y1:0,y2:0},whileInView:{y1:k(Math.min(...a.x.filter(t=>t!==null)))+J,y2:k(Math.max(...a.x.filter(t=>t!==null)))-J,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial"}),a.x.map((t,n)=>i.jsxRuntimeExports.jsx(le.motion.g,{onMouseEnter:o=>{K({...a,xIndex:n}),V(o.clientY),S(o.clientX),q?.({...a,xIndex:n})},onClick:()=>{(F||v)&&(Le.isEqual(P,{...a,xIndex:n})&&ge?(C(void 0),F?.(void 0)):(C({...a,xIndex:n}),F&&F({...a,xIndex:n})))},onMouseMove:o=>{K({...a,xIndex:n}),V(o.clientY),S(o.clientX)},onMouseLeave:()=>{K(void 0),S(void 0),V(void 0),q?.(void 0)},exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{opacity:I?g[n]===I?1:.3:1},whileInView:{opacity:I?g[n]===I?1:.3:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",children:A.checkIfNullOrUndefined(t)?null:i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(le.motion.circle,{cx:0,r:J,style:{fill:g[n],fillOpacity:.85,stroke:g[n],strokeWidth:1},exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{cy:k(0),opacity:0},whileInView:{cy:k(t||0),opacity:A.checkIfNullOrUndefined(t)?0:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial"}),E?i.jsxRuntimeExports.jsx(le.motion.text,{x:0,style:{fill:se||g[n],textAnchor:"start",...d?.graphObjectValues||{}},className:i.mo("graph-value text-sm font-bold",A.checkIfNullOrUndefined(t)?"opacity-0":"opacity-100",h?.graphObjectValues),dx:J+3,dy:"0.33em",exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{y:k(0),opacity:0},whileInView:{y:k(t||0),opacity:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",children:Te.numberFormattingFunction(t,"NA",u,B,ae)}):null]})},n))]},a.label)),oe?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:oe.map((a,t)=>i.jsxRuntimeExports.jsx(Pe.RefLineY,{text:a.text,color:a.color,y:k(a.value),x1:0-w,x2:m+p.right,classNames:a.classNames,styles:a.styles,animate:y,isInView:j},t))}):null]}),M.filter(a=>a.position==="after").map(a=>a.layer)]})]}),W&&s&&b&&Q?i.jsxRuntimeExports.jsx($e.Tooltip,{data:W,body:s,xPos:b,yPos:Q,backgroundStyle:d?.tooltip,className:h?.tooltip}):null,v&&P!==void 0?i.jsxRuntimeExports.jsx(Ve.X,{open:P!==void 0,onClose:()=>{C(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof v=="string"?{__html:Ae.string2HTML(v,P)}:void 0,children:typeof v=="function"?v(P):null})}):null]})}function st(ye){const{data:l,graphTitle:g,colors:_=_e.Colors.light.categoricalColors.colors,sources:z,graphDescription:w,barPadding:ue=.25,showTicks:Z=!0,leftMargin:ee=20,rightMargin:ce=20,topMargin:te=20,bottomMargin:ie=25,truncateBy:J=999,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E=!1,radius:ae=3,tooltip:B,showLabels:I=!0,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne="",prefix:ge="",maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se=!1,dataDownload:d=!1,showValues:h=!0,sortParameter:D,arrowConnector:oe=!1,connectorStrokeWidth:y=2,language:u="en",minHeight:M=0,theme:G="light",maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m=!0,detailsOnClick:H,axisTitle:W,noOfTicks:K=5,valueColor:P,styles:C,classNames:b,labelOrder:S,refValues:Q,filterNA:V=!0,animate:$=!1,precision:Y=2,customLayers:k=[],showColorScale:f=!0,highlightedDataPoints:T=[],dimmedOpacity:a=.3,timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},sortData:n}=ye,[o,de]=x.useState(0),[ke,Ee]=x.useState(0),[me,Ie]=x.useState(t.autoplay),c=Ke.sort(Je.uniqBy(l,"date",!0).map(e=>ve.parse(`${e}`,t.dateFormat||"yyyy",new Date).getTime()),(e,r)=>Qe.ascending(e,r)),[be,we]=x.useState(t.autoplay?0:c.length-1),[De,Se]=x.useState(void 0),he=x.useRef(null),Re=x.useRef(null);x.useEffect(()=>{const e=new ResizeObserver(r=>{de(s||r[0].target.clientWidth||620),Ee(N||r[0].target.clientHeight||480)});return he.current&&(Ee(he.current.clientHeight||480),de(he.current.clientWidth||620),s||e.observe(he.current)),()=>e.disconnect()},[s,N]),x.useEffect(()=>{const e=setInterval(()=>{we(r=>r<c.length-1?r+1:0)},(t.speed||2)*1e3);return me||clearInterval(e),()=>clearInterval(e)},[c,me,t.speed]);const Ce=Oe.getSliderMarks(c,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return i.jsxRuntimeExports.jsx("div",{className:`${G||"light"} flex ${s?"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"}`,s?"w-fit":"w-full",b?.graphContainer),style:{...C?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:re,ref:Re,"aria-label":p||`${g?`The graph shows ${g}. `:""}This is a dumbbell chart that shows comparisons between two or more data points across categories. ${w?` ${w}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?F||"1rem":F||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[g||w||se||d?i.jsxRuntimeExports.jsx(Ge.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:b?.title,description:b?.description},graphTitle:g,graphDescription:w,width:s,graphDownload:se?Re.current:void 0,dataDownload:d?l.map(e=>e.data).filter(e=>e!==void 0).length>0?l.map(e=>e.data).filter(e=>e!==void 0):l.filter(e=>e!==void 0):null}):null,t.enabled&&c.length>0&&Ce?i.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[i.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Ie(!me)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":me?"Click to pause animation":"Click to play animation",children:me?i.jsxRuntimeExports.jsx(Ne.Pause,{}):i.jsxRuntimeExports.jsx(Ne.Play,{})}),i.jsxRuntimeExports.jsx(Oe.xr,{min:c[0],max:c[c.length-1],marks:Ce,step:null,defaultValue:c[c.length-1],value:c[be],onChangeComplete:e=>{we(c.indexOf(e))},onChange:e=>{we(c.indexOf(e))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?i.jsxRuntimeExports.jsx(ze.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[f?i.jsxRuntimeExports.jsx(Ye.ColorLegendWithMouseOver,{width:s,colorDomain:xe,colors:_,colorLegendTitle:O,setSelectedColor:Se,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow w-full justify-center leading-0",ref:he,"aria-label":"Graph area",children:(s||o)&&(N||ke)?i.jsxRuntimeExports.jsx(nt,{data:D!==void 0?D==="diff"?Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[e.x.length-1])||A.checkIfNullOrUndefined(e.x[0])?-1/0:e.x[e.x.length-1]-e.x[0],[n||"asc"]).filter((e,r)=>L?r<L:!0):Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[D])?-1/0:e.x[D],[n||"asc"]).filter((e,r)=>L?r<L:!0):je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>V?!e.x.every(r=>r==null):e).filter((e,r)=>L?r<L:!0),dotColors:_,width:s||o,height:Math.max(M,N||(R?M?(s||o)*R>M?(s||o)*R:M:(s||o)*R:ke)),radius:ae,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,showLabels:I,showValues:h,tooltip:B,suffix:ne,prefix:ge,onSeriesMouseOver:pe,maxValue:A.checkIfNullOrUndefined(v)?Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null))))<0?0:Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null)))):v,minValue:A.checkIfNullOrUndefined(U)?Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null))))>0?0:Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null)))):U,onSeriesMouseClick:fe,selectedColor:De,arrowConnector:oe,connectorStrokeWidth:y,maxBarThickness:X,minBarThickness:j,resetSelectionOnDoubleClick:m,detailsOnClick:H,axisTitle:W,noOfTicks:K,valueColor:P,styles:C,classNames:b,labelOrder:S,refValues:Q,animate:$===!0?{duration:.5,once:!0,amount:.5}:$||{duration:0,once:!0,amount:0},precision:Y,customLayers:k,highlightedDataPoints:T,dimmedOpacity:a}):null})]})}),z||q?i.jsxRuntimeExports.jsx(Xe.GraphFooter,{styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:b?.footnote,source:b?.source},sources:z,footNote:q,width:s}):null]})})})})}function ot(ye){const{data:l,graphTitle:g,colors:_,sources:z,graphDescription:w,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E,radius:ae,tooltip:B,showLabels:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne,prefix:ge,maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se,dataDownload:d,showValues:h,sortParameter:D,arrowConnector:oe,connectorStrokeWidth:y,language:u,minHeight:M,theme:G,maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m,detailsOnClick:H,axisTitle:W,noOfTicks:K,valueColor:P,orientation:C="vertical",styles:b,classNames:S,labelOrder:Q,refValues:V,filterNA:$,animate:Y,precision:k,showColorScale:f,customLayers:T,highlightedDataPoints:a,dimmedOpacity:t,timeline:n,sortData:o}=ye;return C==="vertical"?i.jsxRuntimeExports.jsx(st,{data:l,graphTitle:g,colors:_,sources:z,graphDescription:w,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E,radius:ae,tooltip:B,showLabels:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne,prefix:ge,maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se,dataDownload:d,showValues:h,sortParameter:D,arrowConnector:oe,connectorStrokeWidth:y,language:u,minHeight:M,theme:G,maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m,styles:b,detailsOnClick:H,axisTitle:W,noOfTicks:K,labelOrder:Q,valueColor:P,classNames:S,refValues:V,filterNA:$,animate:Y,precision:k,showColorScale:f,customLayers:T,highlightedDataPoints:a,dimmedOpacity:t,timeline:n,sortData:o}):i.jsxRuntimeExports.jsx(rt,{data:l,graphTitle:g,colors:_,sources:z,graphDescription:w,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E,radius:ae,tooltip:B,showLabels:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne,prefix:ge,maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se,dataDownload:d,showValues:h,sortParameter:D,arrowConnector:oe,connectorStrokeWidth:y,language:u,minHeight:M,theme:G,maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m,styles:b,detailsOnClick:H,axisTitle:W,noOfTicks:K,valueColor:P,classNames:S,labelOrder:Q,refValues:V,filterNA:$,animate:Y,precision:k,showColorScale:f,customLayers:T,highlightedDataPoints:a,dimmedOpacity:t,timeline:n,sortData:o})}exports.DumbbellChart=ot;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),x=require("react"),ve=require("./parse-hMnG_lRV.cjs"),Oe=require("./getSliderMarks-CRIbTGYV.cjs"),Me=require("./index-CQ3e6Ewi.cjs"),Le=require("./index-DQA8q5sC.cjs"),Ve=require("./Modal-tXZlLE5s.cjs"),Te=require("./numberFormattingFunction-02t-wJta.cjs"),$e=require("./Tooltip-De16GWhY.cjs"),A=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ae=require("./string2HTML-z7CwHXcx.cjs"),Ze=require("./XTicksAndGridLines-CCzXIV8d.cjs"),qe=require("./AxisTitle-CK9YeovX.cjs"),et=require("./YAxesLabels-yRFFdx1s.cjs"),Fe=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Pe=require("./ReferenceLine-CFVBBN__.cjs"),Be=require("./linear-BVckp9RD.cjs"),He=require("./band-CAApY4Pd.cjs"),We=require("./use-in-view-sQJZ_xDO.cjs"),le=require("./proxy-BHRoeZgd.cjs"),Ue=require("./index-BW8iNx7E.cjs"),Ge=require("./GraphHeader.cjs"),Xe=require("./GraphFooter.cjs"),Ye=require("./ColorLegendWithMouseOver.cjs"),_e=require("./Colors.cjs"),ze=require("./EmptyState-d8_8SxeW.cjs"),Ne=require("./index-BW_-wD2k.cjs"),je=require("./ensureCompleteData-DkQYPeDa.cjs"),Je=require("./uniqBy-O05lp2S5.cjs"),Ke=require("./sort-O96oMZLb.cjs"),Qe=require("./init-DU0ybBc_.cjs"),tt=require("./Axis-DE7dSn1_.cjs"),it=require("./XAxesLabels-Drf7M3YK.cjs");function at(ye){const{data:l,dotColors:g,suffix:_,prefix:z,barPadding:w,showValues:ue,showTicks:Z,leftMargin:ee,truncateBy:ce,width:te,height:ie,rightMargin:J,topMargin:N,bottomMargin:s,radius:q,showLabels:xe,tooltip:O,onSeriesMouseOver:F,maxValue:E,minValue:ae,onSeriesMouseClick:B,selectedColor:I,arrowConnector:R,connectorStrokeWidth:pe,maxBarThickness:re,minBarThickness:ne,resetSelectionOnDoubleClick:ge,detailsOnClick:v,axisTitle:U,noOfTicks:fe,valueColor:se,styles:d,classNames:h,labelOrder:D,refValues:oe,rtl:y,animate:u,precision:M,customLayers:G,highlightedDataPoints:X,dimmedOpacity:L}=ye,j=x.useRef(null),p=We.useInView(j,{once:u.once,amount:u.amount}),m={top:U?N+25:N,bottom:s,left:ee,right:J},H=te-m.left-m.right,W=ie-m.top-m.bottom,[K,P]=x.useState(void 0),[C,b]=x.useState(void 0),[S,Q]=x.useState(void 0),[V,$]=x.useState(void 0),Y=l.map((t,n)=>({...t,id:D?`${t.label}`:`${n}`})),k=D||Y.map(t=>`${t.id}`),f=Be.linear().domain([ae,E]).range([0,H]).nice(),T=He.band().domain(k).range([0,ne?Math.max(W,ne*Y.length):re?Math.min(W,re*Y.length):W]).paddingInner(w),a=f.ticks(fe);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsxs(le.motion.svg,{width:`${te}px`,height:`${ie}px`,viewBox:`0 0 ${te} ${ie}`,direction:"ltr",ref:j,children:[R?i.jsxRuntimeExports.jsx("defs",{children:i.jsxRuntimeExports.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsxRuntimeExports.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-primary-gray-600 dark:fill-primary-gray-300"})})}):null,i.jsxRuntimeExports.jsxs("g",{transform:`translate(${m.left},${m.top})`,children:[Z?i.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:a.filter((t,n)=>n!==0),x:a.filter((t,n)=>n!==0).map(t=>f(t)),y1:0-N,y2:W+m.bottom,styles:{gridLines:d?.xAxis?.gridLines,labels:d?.xAxis?.labels},classNames:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},suffix:_,prefix:z,labelType:"secondary",showGridLines:!0,precision:M}):null,i.jsxRuntimeExports.jsx(qe.AxisTitle,{x:H/2,y:0-m.top+15,style:d?.xAxis?.title,className:h?.xAxis?.title,text:U}),i.jsxRuntimeExports.jsx(Fe.YTicksAndGridLines,{y:Y.map(t=>T(`${t.id}`)+T.bandwidth()/2),x1:0,x2:H,styles:{gridLines:d?.yAxis?.gridLines},classNames:{gridLines:h?.yAxis?.gridLines},labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:M}),G.filter(t=>t.position==="before").map(t=>t.layer),i.jsxRuntimeExports.jsxs(Ue.AnimatePresence,{children:[Y.map(t=>i.jsxRuntimeExports.jsxs(le.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{x:0,y:T(`${t.id}`)+T.bandwidth()/2,opacity:X.length!==0?X.indexOf(t.label)!==-1?.85:L:.85},whileInView:{x:0,y:T(`${t.id}`)+T.bandwidth()/2,opacity:X.length!==0?X.indexOf(t.label)!==-1?.85:L:.85,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",exit:{opacity:0,transition:{duration:u.duration}},children:[xe?i.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${t.label}`.length<ce?`${t.label}`:`${`${t.label}`.substring(0,ce)}...`,y:0-T.bandwidth()/2,x:0-m.left,width:m.left,height:T.bandwidth(),alignment:"right",style:d?.yAxis?.labels,className:h?.yAxis?.labels,animate:u,isInView:p}):null,i.jsxRuntimeExports.jsx(le.motion.line,{y1:0,y2:0,style:{strokeWidth:pe,...d?.dataConnectors||{},opacity:I?.3:1},className:i.mo("stroke-primary-gray-600 dark:stroke-primary-gray-300",h?.dataConnectors),markerEnd:R&&t.x.indexOf(Math.min(...t.x.filter(n=>n!==null)))===0?"url(#arrow)":"",markerStart:R&&t.x.indexOf(Math.min(...t.x.filter(n=>n!==null)))===t.x.length-1?"url(#arrow)":"",exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{x1:0,x2:0},whileInView:{x1:f(Math.min(...t.x.filter(n=>n!==null)))+q,x2:f(Math.max(...t.x.filter(n=>n!==null)))-q,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial"}),t.x.map((n,o)=>i.jsxRuntimeExports.jsx(le.motion.g,{onMouseEnter:de=>{P({...t,xIndex:o}),$(de.clientY),Q(de.clientX),F?.({...t,xIndex:o})},onClick:()=>{(B||v)&&(Le.isEqual(C,{...t,xIndex:o})&&ge?(b(void 0),B?.(void 0)):(b({...t,xIndex:o}),B&&B({...t,xIndex:o})))},onMouseMove:de=>{P({...t,xIndex:o}),$(de.clientY),Q(de.clientX)},onMouseLeave:()=>{P(void 0),Q(void 0),$(void 0),F?.(void 0)},exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{opacity:I?g[o]===I?1:.3:1},whileInView:{opacity:I?g[o]===I?1:.3:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",children:A.checkIfNullOrUndefined(n)?null:i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(le.motion.circle,{cy:0,r:q,style:{fill:g[o],fillOpacity:.85,stroke:g[o],strokeWidth:1,opacity:A.checkIfNullOrUndefined(n)?0:1},exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{cx:f(0),opacity:0},whileInView:{cx:f(n||0),opacity:A.checkIfNullOrUndefined(n)?0:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial"}),ue?i.jsxRuntimeExports.jsx(le.motion.text,{y:0,style:{fill:se||g[o],textAnchor:"middle",...d?.graphObjectValues||{}},dx:0,dy:0-q-3,className:i.mo("graph-value text-sm font-bold",A.checkIfNullOrUndefined(n)?"0opacity-0":"opacity-100",h?.graphObjectValues),exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{x:f(0),opacity:0},whileInView:{x:f(n||0),opacity:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",children:Te.numberFormattingFunction(n,"NA",M,z,_)}):null]})},o))]},t.label)),oe?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:oe.map((t,n)=>i.jsxRuntimeExports.jsx(Pe.RefLineX,{text:t.text,color:t.color,x:f(t.value),y1:0-m.top,y2:W+m.bottom,textSide:f(t.value)>H*.75||y?"left":"right",classNames:t.classNames,styles:t.styles,animate:u,isInView:p},n))}):null]}),G.filter(t=>t.position==="after").map(t=>t.layer)]})]}),K&&O&&S&&V?i.jsxRuntimeExports.jsx($e.Tooltip,{data:K,body:O,xPos:S,yPos:V,backgroundStyle:d?.tooltip,className:h?.tooltip}):null,v&&C!==void 0?i.jsxRuntimeExports.jsx(Ve.X,{open:C!==void 0,onClose:()=>{b(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof v=="string"?{__html:Ae.string2HTML(v,C)}:void 0,children:typeof v=="function"?v(C):null})}):null]})}function rt(ye){const{data:l,graphTitle:g,colors:_=_e.Colors.light.categoricalColors.colors,sources:z,graphDescription:w,barPadding:ue=.25,showTicks:Z=!0,leftMargin:ee=100,rightMargin:ce=40,topMargin:te=20,bottomMargin:ie=10,truncateBy:J=999,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E=!1,radius:ae=3,showLabels:B=!0,tooltip:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne="",prefix:ge="",maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se=!1,dataDownload:d=!1,showValues:h=!0,sortParameter:D,arrowConnector:oe=!1,connectorStrokeWidth:y=2,language:u="en",minHeight:M=0,theme:G="light",labelOrder:X,maxBarThickness:L,maxNumberOfBars:j,minBarThickness:p,ariaLabel:m,resetSelectionOnDoubleClick:H=!0,detailsOnClick:W,axisTitle:K,noOfTicks:P=5,valueColor:C,styles:b,classNames:S,refValues:Q,filterNA:V=!0,animate:$=!1,precision:Y=2,customLayers:k=[],showColorScale:f=!0,highlightedDataPoints:T=[],dimmedOpacity:a=.3,timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},sortData:n}=ye,[o,de]=x.useState(0),[ke,Ee]=x.useState(0),[me,Ie]=x.useState(t.autoplay),c=Ke.sort(Je.uniqBy(l,"date",!0).map(e=>ve.parse(`${e}`,t.dateFormat||"yyyy",new Date).getTime()),(e,r)=>Qe.ascending(e,r)),[be,we]=x.useState(t.autoplay?0:c.length-1),[De,Se]=x.useState(void 0),he=x.useRef(null),Re=x.useRef(null);x.useEffect(()=>{const e=new ResizeObserver(r=>{de(s||r[0].target.clientWidth||620),Ee(N||r[0].target.clientHeight||480)});return he.current&&(Ee(he.current.clientHeight||480),de(he.current.clientWidth||620),s||e.observe(he.current)),()=>e.disconnect()},[s,N]),x.useEffect(()=>{const e=setInterval(()=>{we(r=>r<c.length-1?r+1:0)},(t.speed||2)*1e3);return me||clearInterval(e),()=>clearInterval(e)},[c,me,t.speed]);const Ce=Oe.getSliderMarks(c,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return i.jsxRuntimeExports.jsx("div",{className:`${G||"light"} flex ${s?"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"}`,s?"w-fit":"w-full",S?.graphContainer),style:{...b?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:re,ref:Re,"aria-label":m||`${g?`The graph shows ${g}. `:""}This is a dumbbell chart that shows comparisons between two or more data points across categories. ${w?` ${w}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?F||"1rem":F||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[g||w||se||d?i.jsxRuntimeExports.jsx(Ge.GraphHeader,{styles:{title:b?.title,description:b?.description},classNames:{title:S?.title,description:S?.description},graphTitle:g,graphDescription:w,width:s,graphDownload:se?Re.current:void 0,dataDownload:d?l.map(e=>e.data).filter(e=>e!==void 0).length>0?l.map(e=>e.data).filter(e=>e!==void 0):l.filter(e=>e!==void 0):null}):null,t.enabled&&c.length>0&&Ce?i.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[i.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Ie(!me)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":me?"Click to pause animation":"Click to play animation",children:me?i.jsxRuntimeExports.jsx(Ne.Pause,{}):i.jsxRuntimeExports.jsx(Ne.Play,{})}),i.jsxRuntimeExports.jsx(Oe.xr,{min:c[0],max:c[c.length-1],marks:Ce,step:null,defaultValue:c[c.length-1],value:c[be],onChangeComplete:e=>{we(c.indexOf(e))},onChange:e=>{we(c.indexOf(e))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?i.jsxRuntimeExports.jsx(ze.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[f?i.jsxRuntimeExports.jsx(Ye.ColorLegendWithMouseOver,{width:s,colorDomain:xe,colors:_,colorLegendTitle:O,setSelectedColor:Se,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow w-full justify-center leading-0",ref:he,"aria-label":"Graph area",children:(s||o)&&(N||ke)?i.jsxRuntimeExports.jsx(at,{data:D!==void 0?D==="diff"?Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[e.x.length-1])||A.checkIfNullOrUndefined(e.x[0])?-1/0:e.x[e.x.length-1]-e.x[0],[n||"asc"]).filter((e,r)=>j?r<j:!0):Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[D])?-1/0:e.x[D],[n||"asc"]).filter((e,r)=>j?r<j:!0):je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>V?!e.x.every(r=>r==null):e).filter((e,r)=>j?r<j:!0),dotColors:_,width:s||o,height:Math.max(M,N||(R?M?(s||o)*R>M?(s||o)*R:M:(s||o)*R:ke)),suffix:ne,prefix:ge,radius:ae,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,showLabels:B,showValues:h,tooltip:I,onSeriesMouseOver:pe,maxValue:A.checkIfNullOrUndefined(v)?Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null))))<0?0:Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null)))):v,minValue:A.checkIfNullOrUndefined(U)?Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null))))>0?0:Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null)))):U,onSeriesMouseClick:fe,selectedColor:De,arrowConnector:oe,connectorStrokeWidth:y,maxBarThickness:L,minBarThickness:p,resetSelectionOnDoubleClick:H,detailsOnClick:W,axisTitle:K,noOfTicks:P,valueColor:C,styles:b,classNames:S,labelOrder:X,refValues:Q,rtl:u==="he"||u==="ar",animate:$===!0?{duration:.5,once:!0,amount:.5}:$||{duration:0,once:!0,amount:0},precision:Y,customLayers:k,highlightedDataPoints:T,dimmedOpacity:a}):null})]})}),z||q?i.jsxRuntimeExports.jsx(Xe.GraphFooter,{styles:{footnote:b?.footnote,source:b?.source},classNames:{footnote:S?.footnote,source:S?.source},sources:z,footNote:q,width:s}):null]})})})})}function nt(ye){const{data:l,dotColors:g,barPadding:_,showTicks:z,leftMargin:w,truncateBy:ue,width:Z,height:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,radius:J,showLabels:N,tooltip:s,onSeriesMouseOver:q,maxValue:xe,minValue:O,onSeriesMouseClick:F,showValues:E,suffix:ae,prefix:B,selectedColor:I,arrowConnector:R,connectorStrokeWidth:pe,maxBarThickness:re,minBarThickness:ne,resetSelectionOnDoubleClick:ge,detailsOnClick:v,axisTitle:U,noOfTicks:fe,valueColor:se,styles:d,classNames:h,labelOrder:D,refValues:oe,animate:y,precision:u,customLayers:M,highlightedDataPoints:G,dimmedOpacity:X}=ye,L=x.useRef(null),j=We.useInView(L,{once:y.once,amount:y.amount}),p={top:te,bottom:ie,left:U?w+30:w,right:ce},m=Z-p.left-p.right,H=ee-p.top-p.bottom,[W,K]=x.useState(void 0),[P,C]=x.useState(void 0),[b,S]=x.useState(void 0),[Q,V]=x.useState(void 0),$=l.map((a,t)=>({...a,id:D?`${a.label}`:`${t}`})),Y=D||$.map(a=>`${a.id}`),k=Be.linear().domain([O,xe]).range([H,0]).nice(),f=He.band().domain(Y).range([0,ne?Math.max(m,ne*$.length):re?Math.min(m,re*$.length):m]).paddingInner(_),T=k.ticks(fe);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsxs(le.motion.svg,{width:`${Z}px`,height:`${ee}px`,viewBox:`0 0 ${Z} ${ee}`,direction:"ltr",ref:L,children:[R?i.jsxRuntimeExports.jsx("defs",{children:i.jsxRuntimeExports.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsxRuntimeExports.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-primary-gray-600 dark:fill-primary-gray-300"})})}):null,i.jsxRuntimeExports.jsxs("g",{transform:`translate(${p.left},${p.top})`,children:[i.jsxRuntimeExports.jsx(tt.Axis,{y1:k(O<0?0:O),y2:k(O<0?0:O),x1:0-w,x2:m+p.right,label:Te.numberFormattingFunction(O<0?0:O,"NA",u,B,ae),labelPos:{x:0-w,dx:0,dy:xe<0?"1em":-5,y:k(O<0?0:O)},classNames:{axis:h?.xAxis?.axis,label:h?.yAxis?.labels},styles:{axis:d?.xAxis?.axis,label:d?.yAxis?.labels}}),z?i.jsxRuntimeExports.jsx(Fe.YTicksAndGridLines,{values:T.filter(a=>a!==0),y:T.filter(a=>a!==0).map(a=>k(a)),x1:0-w,x2:m+p.right,styles:{gridLines:d?.yAxis?.gridLines,labels:d?.yAxis?.labels},classNames:{gridLines:h?.yAxis?.gridLines,labels:h?.yAxis?.labels},suffix:ae,prefix:B,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:u}):null,i.jsxRuntimeExports.jsx(qe.AxisTitle,{x:0-w-15,y:H/2,style:d?.yAxis?.title,className:h?.yAxis?.title,text:U,rotate90:!0}),M.filter(a=>a.position==="before").map(a=>a.layer),i.jsxRuntimeExports.jsxs(Ue.AnimatePresence,{children:[$.map(a=>i.jsxRuntimeExports.jsxs(le.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{x:f(`${a.id}`)+f.bandwidth()/2,y:0,opacity:G.length!==0?G.indexOf(a.label)!==-1?.85:X:.85},whileInView:{x:f(`${a.id}`)+f.bandwidth()/2,y:0,opacity:G.length!==0?G.indexOf(a.label)!==-1?.85:X:.85,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:y.duration}},children:[N?i.jsxRuntimeExports.jsx(it.XAxesLabels,{value:`${a.label}`.length<ue?`${a.label}`:`${`${a.label}`.substring(0,ue)}...`,y:H+5,x:0-f.bandwidth()/2,width:f.bandwidth(),height:p.bottom,style:d?.xAxis?.labels,className:h?.xAxis?.labels,alignment:"top",animate:y,isInView:j}):null,i.jsxRuntimeExports.jsx(le.motion.line,{x1:0,x2:0,style:{strokeWidth:pe,...d?.dataConnectors||{},opacity:I?.3:1},className:i.mo("stroke-primary-gray-600 dark:stroke-primary-gray-300",h?.dataConnectors),markerEnd:R&&a.x.indexOf(Math.min(...a.x.filter(t=>t!==null)))===0?"url(#arrow)":"",markerStart:R&&a.x.indexOf(Math.min(...a.x.filter(t=>t!==null)))===a.x.length-1?"url(#arrow)":"",exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{y1:0,y2:0},whileInView:{y1:k(Math.min(...a.x.filter(t=>t!==null)))+J,y2:k(Math.max(...a.x.filter(t=>t!==null)))-J,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial"}),a.x.map((t,n)=>i.jsxRuntimeExports.jsx(le.motion.g,{onMouseEnter:o=>{K({...a,xIndex:n}),V(o.clientY),S(o.clientX),q?.({...a,xIndex:n})},onClick:()=>{(F||v)&&(Le.isEqual(P,{...a,xIndex:n})&&ge?(C(void 0),F?.(void 0)):(C({...a,xIndex:n}),F&&F({...a,xIndex:n})))},onMouseMove:o=>{K({...a,xIndex:n}),V(o.clientY),S(o.clientX)},onMouseLeave:()=>{K(void 0),S(void 0),V(void 0),q?.(void 0)},exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{opacity:I?g[n]===I?1:.3:1},whileInView:{opacity:I?g[n]===I?1:.3:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",children:A.checkIfNullOrUndefined(t)?null:i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(le.motion.circle,{cx:0,r:J,style:{fill:g[n],fillOpacity:.85,stroke:g[n],strokeWidth:1},exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{cy:k(0),opacity:0},whileInView:{cy:k(t||0),opacity:A.checkIfNullOrUndefined(t)?0:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial"}),E?i.jsxRuntimeExports.jsx(le.motion.text,{x:0,style:{fill:se||g[n],textAnchor:"start",...d?.graphObjectValues||{}},className:i.mo("graph-value text-sm font-bold",A.checkIfNullOrUndefined(t)?"opacity-0":"opacity-100",h?.graphObjectValues),dx:J+3,dy:"0.33em",exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{y:k(0),opacity:0},whileInView:{y:k(t||0),opacity:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",children:Te.numberFormattingFunction(t,"NA",u,B,ae)}):null]})},n))]},a.label)),oe?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:oe.map((a,t)=>i.jsxRuntimeExports.jsx(Pe.RefLineY,{text:a.text,color:a.color,y:k(a.value),x1:0-w,x2:m+p.right,classNames:a.classNames,styles:a.styles,animate:y,isInView:j},t))}):null]}),M.filter(a=>a.position==="after").map(a=>a.layer)]})]}),W&&s&&b&&Q?i.jsxRuntimeExports.jsx($e.Tooltip,{data:W,body:s,xPos:b,yPos:Q,backgroundStyle:d?.tooltip,className:h?.tooltip}):null,v&&P!==void 0?i.jsxRuntimeExports.jsx(Ve.X,{open:P!==void 0,onClose:()=>{C(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof v=="string"?{__html:Ae.string2HTML(v,P)}:void 0,children:typeof v=="function"?v(P):null})}):null]})}function st(ye){const{data:l,graphTitle:g,colors:_=_e.Colors.light.categoricalColors.colors,sources:z,graphDescription:w,barPadding:ue=.25,showTicks:Z=!0,leftMargin:ee=20,rightMargin:ce=20,topMargin:te=20,bottomMargin:ie=25,truncateBy:J=999,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E=!1,radius:ae=3,tooltip:B,showLabels:I=!0,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne="",prefix:ge="",maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se=!1,dataDownload:d=!1,showValues:h=!0,sortParameter:D,arrowConnector:oe=!1,connectorStrokeWidth:y=2,language:u="en",minHeight:M=0,theme:G="light",maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m=!0,detailsOnClick:H,axisTitle:W,noOfTicks:K=5,valueColor:P,styles:C,classNames:b,labelOrder:S,refValues:Q,filterNA:V=!0,animate:$=!1,precision:Y=2,customLayers:k=[],showColorScale:f=!0,highlightedDataPoints:T=[],dimmedOpacity:a=.3,timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},sortData:n}=ye,[o,de]=x.useState(0),[ke,Ee]=x.useState(0),[me,Ie]=x.useState(t.autoplay),c=Ke.sort(Je.uniqBy(l,"date",!0).map(e=>ve.parse(`${e}`,t.dateFormat||"yyyy",new Date).getTime()),(e,r)=>Qe.ascending(e,r)),[be,we]=x.useState(t.autoplay?0:c.length-1),[De,Se]=x.useState(void 0),he=x.useRef(null),Re=x.useRef(null);x.useEffect(()=>{const e=new ResizeObserver(r=>{de(s||r[0].target.clientWidth||620),Ee(N||r[0].target.clientHeight||480)});return he.current&&(Ee(he.current.clientHeight||480),de(he.current.clientWidth||620),s||e.observe(he.current)),()=>e.disconnect()},[s,N]),x.useEffect(()=>{const e=setInterval(()=>{we(r=>r<c.length-1?r+1:0)},(t.speed||2)*1e3);return me||clearInterval(e),()=>clearInterval(e)},[c,me,t.speed]);const Ce=Oe.getSliderMarks(c,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return i.jsxRuntimeExports.jsx("div",{className:`${G||"light"} flex ${s?"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"}`,s?"w-fit":"w-full",b?.graphContainer),style:{...C?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:re,ref:Re,"aria-label":p||`${g?`The graph shows ${g}. `:""}This is a dumbbell chart that shows comparisons between two or more data points across categories. ${w?` ${w}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?F||"1rem":F||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[g||w||se||d?i.jsxRuntimeExports.jsx(Ge.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:b?.title,description:b?.description},graphTitle:g,graphDescription:w,width:s,graphDownload:se?Re.current:void 0,dataDownload:d?l.map(e=>e.data).filter(e=>e!==void 0).length>0?l.map(e=>e.data).filter(e=>e!==void 0):l.filter(e=>e!==void 0):null}):null,t.enabled&&c.length>0&&Ce?i.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[i.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Ie(!me)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":me?"Click to pause animation":"Click to play animation",children:me?i.jsxRuntimeExports.jsx(Ne.Pause,{}):i.jsxRuntimeExports.jsx(Ne.Play,{})}),i.jsxRuntimeExports.jsx(Oe.xr,{min:c[0],max:c[c.length-1],marks:Ce,step:null,defaultValue:c[c.length-1],value:c[be],onChangeComplete:e=>{we(c.indexOf(e))},onChange:e=>{we(c.indexOf(e))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?i.jsxRuntimeExports.jsx(ze.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[f?i.jsxRuntimeExports.jsx(Ye.ColorLegendWithMouseOver,{width:s,colorDomain:xe,colors:_,colorLegendTitle:O,setSelectedColor:Se,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow w-full justify-center leading-0",ref:he,"aria-label":"Graph area",children:(s||o)&&(N||ke)?i.jsxRuntimeExports.jsx(nt,{data:D!==void 0?D==="diff"?Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[e.x.length-1])||A.checkIfNullOrUndefined(e.x[0])?-1/0:e.x[e.x.length-1]-e.x[0],[n||"asc"]).filter((e,r)=>L?r<L:!0):Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[D])?-1/0:e.x[D],[n||"asc"]).filter((e,r)=>L?r<L:!0):je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>V?!e.x.every(r=>r==null):e).filter((e,r)=>L?r<L:!0),dotColors:_,width:s||o,height:Math.max(M,N||(R?M?(s||o)*R>M?(s||o)*R:M:(s||o)*R:ke)),radius:ae,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,showLabels:I,showValues:h,tooltip:B,suffix:ne,prefix:ge,onSeriesMouseOver:pe,maxValue:A.checkIfNullOrUndefined(v)?Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null))))<0?0:Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null)))):v,minValue:A.checkIfNullOrUndefined(U)?Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null))))>0?0:Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null)))):U,onSeriesMouseClick:fe,selectedColor:De,arrowConnector:oe,connectorStrokeWidth:y,maxBarThickness:X,minBarThickness:j,resetSelectionOnDoubleClick:m,detailsOnClick:H,axisTitle:W,noOfTicks:K,valueColor:P,styles:C,classNames:b,labelOrder:S,refValues:Q,animate:$===!0?{duration:.5,once:!0,amount:.5}:$||{duration:0,once:!0,amount:0},precision:Y,customLayers:k,highlightedDataPoints:T,dimmedOpacity:a}):null})]})}),z||q?i.jsxRuntimeExports.jsx(Xe.GraphFooter,{styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:b?.footnote,source:b?.source},sources:z,footNote:q,width:s}):null]})})})})}function ot(ye){const{data:l,graphTitle:g,colors:_,sources:z,graphDescription:w,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E,radius:ae,tooltip:B,showLabels:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne,prefix:ge,maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se,dataDownload:d,showValues:h,sortParameter:D,arrowConnector:oe,connectorStrokeWidth:y,language:u,minHeight:M,theme:G,maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m,detailsOnClick:H,axisTitle:W,noOfTicks:K,valueColor:P,orientation:C="vertical",styles:b,classNames:S,labelOrder:Q,refValues:V,filterNA:$,animate:Y,precision:k,showColorScale:f,customLayers:T,highlightedDataPoints:a,dimmedOpacity:t,timeline:n,sortData:o}=ye;return C==="vertical"?i.jsxRuntimeExports.jsx(st,{data:l,graphTitle:g,colors:_,sources:z,graphDescription:w,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E,radius:ae,tooltip:B,showLabels:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne,prefix:ge,maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se,dataDownload:d,showValues:h,sortParameter:D,arrowConnector:oe,connectorStrokeWidth:y,language:u,minHeight:M,theme:G,maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m,styles:b,detailsOnClick:H,axisTitle:W,noOfTicks:K,labelOrder:Q,valueColor:P,classNames:S,refValues:V,filterNA:$,animate:Y,precision:k,showColorScale:f,customLayers:T,highlightedDataPoints:a,dimmedOpacity:t,timeline:n,sortData:o}):i.jsxRuntimeExports.jsx(rt,{data:l,graphTitle:g,colors:_,sources:z,graphDescription:w,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E,radius:ae,tooltip:B,showLabels:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne,prefix:ge,maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se,dataDownload:d,showValues:h,sortParameter:D,arrowConnector:oe,connectorStrokeWidth:y,language:u,minHeight:M,theme:G,maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m,styles:b,detailsOnClick:H,axisTitle:W,noOfTicks:K,valueColor:P,classNames:S,labelOrder:Q,refValues:V,filterNA:$,animate:Y,precision:k,showColorScale:f,customLayers:T,highlightedDataPoints:a,dimmedOpacity:t,timeline:n,sortData:o})}exports.DumbbellChart=ot;
2
2
  //# sourceMappingURL=DumbbellChart.cjs.map
@@ -11,7 +11,7 @@ import { c as F } from "./checkIfNullOrUndefined-DmfiKkNw.js";
11
11
  import { s as Xe } from "./string2HTML-oFCROsus.js";
12
12
  import { X as rt } from "./XTicksAndGridLines-Bn9u5gOM.js";
13
13
  import { A as Ye } from "./AxisTitle-BmHLMRJZ.js";
14
- import { Y as lt } from "./YAxesLabels-DSm6I5zG.js";
14
+ import { Y as lt } from "./YAxesLabels-DECkMgq8.js";
15
15
  import { Y as Ee } from "./YTicksAndGridLines-B6ah7CRf.js";
16
16
  import { a as nt, R as ot } from "./ReferenceLine-CfAW3vKJ.js";
17
17
  import { a as _e } from "./linear-DUdu7l2G.js";
package/dist/HeatMap.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),x=require("react"),ue=require("./index-DQA8q5sC.cjs"),ce=require("./Modal-tXZlLE5s.cjs"),xe=require("./numberFormattingFunction-02t-wJta.cjs"),he=require("./Tooltip-De16GWhY.cjs"),de=require("./getTextColorBasedOnBgColor-nqY-bsM_.cjs"),re=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),ge=require("./string2HTML-z7CwHXcx.cjs"),me=require("./XAxesLabels-Drf7M3YK.cjs"),pe=require("./YAxesLabels-CctDydGR.cjs"),le=require("./uniqBy-O05lp2S5.cjs"),ae=require("./band-CAApY4Pd.cjs"),fe=require("./ordinal-BOeNbyae.cjs"),je=require("./threshold-DNsSUf8Q.cjs"),Ce=require("./linear-BVckp9RD.cjs"),ye=require("./use-in-view-sQJZ_xDO.cjs"),se=require("./proxy-BHRoeZgd.cjs"),ve=require("./GraphHeader.cjs"),we=require("./GraphFooter.cjs"),be=require("./ColorLegendWithMouseOver.cjs"),Ee=require("./LinearColorLegend.cjs"),Re=require("./ThresholdColorLegendWithMouseOver.cjs"),i=require("./Colors.cjs"),qe=require("./EmptyState-d8_8SxeW.cjs");function $e(U){const{data:m,showColumnLabels:N,leftMargin:O,rightMargin:F,truncateBy:p,width:H,height:I,topMargin:z,bottomMargin:_,tooltip:q,onSeriesMouseOver:r,suffix:J,prefix:s,showValues:G,colorDomain:$,colors:S,noDataColor:f,scaleType:X,showRowLabels:K,selectedColor:Y,onSeriesMouseClick:V,resetSelectionOnDoubleClick:Q,detailsOnClick:y,styles:L,classNames:j,animate:v,precision:Z}=U,W=x.useRef(null),D=ye.useInView(W,{once:v.once,amount:v.amount}),l={top:z,bottom:_,left:O,right:F},[w,T]=x.useState(void 0),[a,M]=x.useState(void 0),[A,b]=x.useState(void 0),[o,B]=x.useState(void 0),ee=H-l.left-l.right,te=I-l.top-l.bottom,h=le.uniqBy(m,"column",!0),d=le.uniqBy(m,"row",!0),E=ae.band().domain(d).range([0,te]),k=E.bandwidth(),u=ae.band().domain(h).range([0,ee]),R=u.bandwidth(),P=X==="categorical"?fe.ordinal().domain($).range(S):X==="threshold"?je.threshold().domain($).range(S):Ce.linear().domain($).range(S);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(se.motion.svg,{width:`${H}px`,height:`${I}px`,viewBox:`0 0 ${H} ${I}`,style:{marginLeft:"auto",marginRight:"auto"},direction:"ltr",ref:W,children:[e.jsxRuntimeExports.jsx("g",{transform:`translate(${l.left},0)`,children:N?h.map((t,C)=>e.jsxRuntimeExports.jsx(me.XAxesLabels,{y:0,x:u(t),width:R,height:l.top-5,value:`${t}`.length<p?`${t}`:`${`${t}`.substring(0,p)}...`,style:L?.xAxis?.labels,className:j?.xAxis?.labels,alignment:"bottom",animate:{duration:0,once:!0,amount:0},isInView:D},C)):null}),e.jsxRuntimeExports.jsx("g",{transform:`translate(0,${l.top})`,children:K?d.map((t,C)=>e.jsxRuntimeExports.jsx(pe.YAxesLabels,{value:`${t}`.length<p?`${t}`:`${`${t}`.substring(0,p)}...`,y:E(t),x:0,width:l.left,height:k,alignment:"right",style:L?.yAxis?.labels,className:j?.yAxis?.labels,animate:{duration:0,once:!0,amount:0},isInView:D},C)):null}),e.jsxRuntimeExports.jsxs("g",{transform:`translate(${l.left},${l.top})`,children:[d.map((t,C)=>e.jsxRuntimeExports.jsx("g",{transform:`translate(0,${E(t)})`,children:h.map(g=>e.jsxRuntimeExports.jsx("rect",{x:u(g),y:0,width:R,height:k,style:{fill:f},className:"stroke-1 stroke-primary-white dark:stroke-primary-gray-700"},`${t}-${g}`))},C)),m.filter(t=>!re.checkIfNullOrUndefined(t.value)).map((t,C)=>{const g=re.checkIfNullOrUndefined(t.value)?f:P(t.value);return e.jsxRuntimeExports.jsxs("g",{transform:`translate(${u(t.column)},${E(t.row)})`,onMouseEnter:c=>{M(t),B(c.clientY),b(c.clientX),r?.(t)},onClick:()=>{(V||y)&&(ue.isEqual(w,t)&&Q?(T(void 0),V?.(void 0)):(T(t),V?.(t)))},onMouseMove:c=>{M(t),B(c.clientY),b(c.clientX)},onMouseLeave:()=>{M(void 0),b(void 0),B(void 0),r?.(void 0)},opacity:Y?Y===g?1:.3:1,children:[e.jsxRuntimeExports.jsx(se.motion.rect,{x:0,y:0,width:R,height:k,className:"stroke-1 stroke-primary-white dark:stroke-primary-gray-700",exit:{opacity:0,transition:{duration:v.duration}},variants:{initial:{fill:g,opacity:0},whileInView:{fill:g,opacity:1,transition:{duration:v.duration}}},initial:"initial",animate:D?"whileInView":"initial"}),G&&!re.checkIfNullOrUndefined(t.value)?e.jsxRuntimeExports.jsx(se.motion.g,{variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:v.duration}}},initial:"initial",animate:D?"whileInView":"initial",exit:{opacity:0,transition:{duration:v.duration}},children:e.jsxRuntimeExports.jsx("foreignObject",{y:0,x:0,width:R,height:k,children:e.jsxRuntimeExports.jsx("div",{className:"flex flex-col justify-center items-center h-inherit p-1",children:e.jsxRuntimeExports.jsx("p",{className:e.mo("text-xs text-center m-0 leading-[1.25] graph-value",j?.graphObjectValues),style:{color:de.getTextColorBasedOnBgColor(g),...L?.graphObjectValues||{}},children:xe.numberFormattingFunction(t.value,"NA",Z,s,J)})})},C)}):null]},`${t.column}-${t.row}`)}),a?e.jsxRuntimeExports.jsx("rect",{x:u(a.column),y:E(a.row),width:R,height:k,style:{fill:"none",fillOpacity:0,strokeWidth:1.5},className:"stroke-primary-gray-700 dark:stroke-primary-gray-300"}):null]})]}),a&&q&&A&&o?e.jsxRuntimeExports.jsx(he.Tooltip,{data:a,body:q,xPos:A,yPos:o,backgroundStyle:L?.tooltip,className:j?.tooltip}):null,y&&w!==void 0?e.jsxRuntimeExports.jsx(ce.X,{open:w!==void 0,onClose:()=>{T(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof y=="string"?{__html:ge.string2HTML(y,w)}:void 0,children:typeof y=="function"?y(w):null})}):null]})}function Me(U){const{data:m,graphTitle:N,colors:O,sources:F,graphDescription:p,showColumnLabels:H=!0,leftMargin:I=100,rightMargin:z=10,truncateBy:_=999,height:q,width:r,scaleType:J,colorDomain:s,footNote:G,colorLegendTitle:$,padding:S,backgroundColor:f=!1,topMargin:X=30,bottomMargin:K=10,tooltip:Y,onSeriesMouseOver:V,suffix:Q="",prefix:y="",showRowLabels:L=!0,relativeHeight:j,showValues:v,graphID:Z,noDataColor:W=i.Colors.gray,showColorScale:D=!0,onSeriesMouseClick:l,graphDownload:w=!1,dataDownload:T=!1,fillContainer:a=!0,language:M="en",showNAColor:A=!0,minHeight:b=0,theme:o="light",ariaLabel:B,resetSelectionOnDoubleClick:ee=!0,detailsOnClick:te,styles:h,classNames:d,animate:E=!1,precision:k=2}=U,[u,R]=x.useState(0),[P,t]=x.useState(0),[C,g]=x.useState(void 0),c=x.useRef(null),ie=x.useRef(null);x.useEffect(()=>{const n=new ResizeObserver(ne=>{R(r||ne[0].target.clientWidth||620),t(q||ne[0].target.clientHeight||480)});return c.current&&(t(c.current.clientHeight||480),R(c.current.clientWidth||620),r||n.observe(c.current)),()=>n.disconnect()},[r,q]);const oe=J||(typeof s[0]=="string"?"categorical":s.length===2?"linear":"threshold");return e.jsxRuntimeExports.jsx("div",{className:`${o||"light"} flex ${r?"grow-0":"grow"} ${a?"w-full":"w-fit"}`,dir:M==="he"||M==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${f?f===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,a?"w-full":"w-fit",d?.graphContainer),style:{...h?.graphContainer||{},...f&&f!==!0?{backgroundColor:f}:{}},id:Z,ref:ie,"aria-label":B||`${N?`The graph shows ${N}. `:""}This is a heatmap. ${p?` ${p}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:f?S||"1rem":S||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[N||p||w||T?e.jsxRuntimeExports.jsx(ve.GraphHeader,{styles:{title:h?.title,description:h?.description},classNames:{title:d?.title,description:d?.description},graphTitle:N,graphDescription:p,width:r,graphDownload:w?ie.current:void 0,dataDownload:T?m.map(n=>n.data).filter(n=>n!==void 0).length>0?m.map(n=>n.data).filter(n=>n!==void 0):m.filter(n=>n!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:m.length===0?e.jsxRuntimeExports.jsx(qe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[D?oe==="categorical"?e.jsxRuntimeExports.jsx(be.ColorLegendWithMouseOver,{width:a?void 0:r,colorLegendTitle:$,colors:O||(typeof s[0]=="string"?i.Colors[o].categoricalColors.colors:s.length===2?[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]]:i.Colors[o].sequentialColors[`neutralColorsx0${s.length+1}`]),colorDomain:s.map(n=>`${n}`),setSelectedColor:g,showNAColor:A}):oe==="threshold"?e.jsxRuntimeExports.jsx(Re.ThresholdColorLegendWithMouseOver,{width:a?void 0:r,colorLegendTitle:$,colors:O||(typeof s[0]=="string"?i.Colors[o].categoricalColors.colors:s.length===2?[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]]:i.Colors[o].sequentialColors[`neutralColorsx0${s.length+1}`]),colorDomain:s,setSelectedColor:g,naColor:W,showNAColor:A}):e.jsxRuntimeExports.jsx(Ee.LinearColorLegend,{width:a?void 0:r,colorLegendTitle:$,colors:O||[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]],colorDomain:s}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:c,"aria-label":"Graph area",children:(r||u)&&(q||P)?e.jsxRuntimeExports.jsx($e,{data:m,colorDomain:s,width:r||u,colors:O||(typeof s[0]=="string"?i.Colors[o].categoricalColors.colors:s.length===2?[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]]:i.Colors[o].sequentialColors[`neutralColorsx0${s.length+1}`]),noDataColor:W,scaleType:oe,height:Math.max(b,q||(j?b?(r||u)*j>b?(r||u)*j:b:(r||u)*j:P)),showColumnLabels:H,leftMargin:I,rightMargin:z,topMargin:X,bottomMargin:K,selectedColor:C,truncateBy:_,showRowLabels:L,tooltip:Y,onSeriesMouseOver:V,showValues:v,suffix:Q,prefix:y,onSeriesMouseClick:l,resetSelectionOnDoubleClick:ee,detailsOnClick:te,styles:h,classNames:d,animate:E===!0?{duration:.5,once:!0,amount:.5}:E||{duration:0,once:!0,amount:0},precision:k}):null})]})}),F||G?e.jsxRuntimeExports.jsx(we.GraphFooter,{styles:{footnote:h?.footnote,source:h?.source},classNames:{footnote:d?.footnote,source:d?.source},sources:F,footNote:G,width:r}):null]})})})})}exports.HeatMap=Me;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),x=require("react"),ue=require("./index-DQA8q5sC.cjs"),ce=require("./Modal-tXZlLE5s.cjs"),xe=require("./numberFormattingFunction-02t-wJta.cjs"),he=require("./Tooltip-De16GWhY.cjs"),de=require("./getTextColorBasedOnBgColor-nqY-bsM_.cjs"),re=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),ge=require("./string2HTML-z7CwHXcx.cjs"),me=require("./XAxesLabels-Drf7M3YK.cjs"),pe=require("./YAxesLabels-yRFFdx1s.cjs"),le=require("./uniqBy-O05lp2S5.cjs"),ae=require("./band-CAApY4Pd.cjs"),fe=require("./ordinal-BOeNbyae.cjs"),je=require("./threshold-DNsSUf8Q.cjs"),Ce=require("./linear-BVckp9RD.cjs"),ye=require("./use-in-view-sQJZ_xDO.cjs"),se=require("./proxy-BHRoeZgd.cjs"),ve=require("./GraphHeader.cjs"),we=require("./GraphFooter.cjs"),be=require("./ColorLegendWithMouseOver.cjs"),Ee=require("./LinearColorLegend.cjs"),Re=require("./ThresholdColorLegendWithMouseOver.cjs"),i=require("./Colors.cjs"),qe=require("./EmptyState-d8_8SxeW.cjs");function $e(U){const{data:m,showColumnLabels:N,leftMargin:O,rightMargin:F,truncateBy:p,width:H,height:I,topMargin:z,bottomMargin:_,tooltip:q,onSeriesMouseOver:r,suffix:J,prefix:s,showValues:G,colorDomain:$,colors:S,noDataColor:f,scaleType:X,showRowLabels:K,selectedColor:Y,onSeriesMouseClick:V,resetSelectionOnDoubleClick:Q,detailsOnClick:y,styles:L,classNames:j,animate:v,precision:Z}=U,W=x.useRef(null),D=ye.useInView(W,{once:v.once,amount:v.amount}),l={top:z,bottom:_,left:O,right:F},[w,T]=x.useState(void 0),[a,M]=x.useState(void 0),[A,b]=x.useState(void 0),[o,B]=x.useState(void 0),ee=H-l.left-l.right,te=I-l.top-l.bottom,h=le.uniqBy(m,"column",!0),d=le.uniqBy(m,"row",!0),E=ae.band().domain(d).range([0,te]),k=E.bandwidth(),u=ae.band().domain(h).range([0,ee]),R=u.bandwidth(),P=X==="categorical"?fe.ordinal().domain($).range(S):X==="threshold"?je.threshold().domain($).range(S):Ce.linear().domain($).range(S);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(se.motion.svg,{width:`${H}px`,height:`${I}px`,viewBox:`0 0 ${H} ${I}`,style:{marginLeft:"auto",marginRight:"auto"},direction:"ltr",ref:W,children:[e.jsxRuntimeExports.jsx("g",{transform:`translate(${l.left},0)`,children:N?h.map((t,C)=>e.jsxRuntimeExports.jsx(me.XAxesLabels,{y:0,x:u(t),width:R,height:l.top-5,value:`${t}`.length<p?`${t}`:`${`${t}`.substring(0,p)}...`,style:L?.xAxis?.labels,className:j?.xAxis?.labels,alignment:"bottom",animate:{duration:0,once:!0,amount:0},isInView:D},C)):null}),e.jsxRuntimeExports.jsx("g",{transform:`translate(0,${l.top})`,children:K?d.map((t,C)=>e.jsxRuntimeExports.jsx(pe.YAxesLabels,{value:`${t}`.length<p?`${t}`:`${`${t}`.substring(0,p)}...`,y:E(t),x:0,width:l.left,height:k,alignment:"right",style:L?.yAxis?.labels,className:j?.yAxis?.labels,animate:{duration:0,once:!0,amount:0},isInView:D},C)):null}),e.jsxRuntimeExports.jsxs("g",{transform:`translate(${l.left},${l.top})`,children:[d.map((t,C)=>e.jsxRuntimeExports.jsx("g",{transform:`translate(0,${E(t)})`,children:h.map(g=>e.jsxRuntimeExports.jsx("rect",{x:u(g),y:0,width:R,height:k,style:{fill:f},className:"stroke-1 stroke-primary-white dark:stroke-primary-gray-700"},`${t}-${g}`))},C)),m.filter(t=>!re.checkIfNullOrUndefined(t.value)).map((t,C)=>{const g=re.checkIfNullOrUndefined(t.value)?f:P(t.value);return e.jsxRuntimeExports.jsxs("g",{transform:`translate(${u(t.column)},${E(t.row)})`,onMouseEnter:c=>{M(t),B(c.clientY),b(c.clientX),r?.(t)},onClick:()=>{(V||y)&&(ue.isEqual(w,t)&&Q?(T(void 0),V?.(void 0)):(T(t),V?.(t)))},onMouseMove:c=>{M(t),B(c.clientY),b(c.clientX)},onMouseLeave:()=>{M(void 0),b(void 0),B(void 0),r?.(void 0)},opacity:Y?Y===g?1:.3:1,children:[e.jsxRuntimeExports.jsx(se.motion.rect,{x:0,y:0,width:R,height:k,className:"stroke-1 stroke-primary-white dark:stroke-primary-gray-700",exit:{opacity:0,transition:{duration:v.duration}},variants:{initial:{fill:g,opacity:0},whileInView:{fill:g,opacity:1,transition:{duration:v.duration}}},initial:"initial",animate:D?"whileInView":"initial"}),G&&!re.checkIfNullOrUndefined(t.value)?e.jsxRuntimeExports.jsx(se.motion.g,{variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:v.duration}}},initial:"initial",animate:D?"whileInView":"initial",exit:{opacity:0,transition:{duration:v.duration}},children:e.jsxRuntimeExports.jsx("foreignObject",{y:0,x:0,width:R,height:k,children:e.jsxRuntimeExports.jsx("div",{className:"flex flex-col justify-center items-center h-inherit p-1",children:e.jsxRuntimeExports.jsx("p",{className:e.mo("text-xs text-center m-0 leading-[1.25] graph-value",j?.graphObjectValues),style:{color:de.getTextColorBasedOnBgColor(g),...L?.graphObjectValues||{}},children:xe.numberFormattingFunction(t.value,"NA",Z,s,J)})})},C)}):null]},`${t.column}-${t.row}`)}),a?e.jsxRuntimeExports.jsx("rect",{x:u(a.column),y:E(a.row),width:R,height:k,style:{fill:"none",fillOpacity:0,strokeWidth:1.5},className:"stroke-primary-gray-700 dark:stroke-primary-gray-300"}):null]})]}),a&&q&&A&&o?e.jsxRuntimeExports.jsx(he.Tooltip,{data:a,body:q,xPos:A,yPos:o,backgroundStyle:L?.tooltip,className:j?.tooltip}):null,y&&w!==void 0?e.jsxRuntimeExports.jsx(ce.X,{open:w!==void 0,onClose:()=>{T(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof y=="string"?{__html:ge.string2HTML(y,w)}:void 0,children:typeof y=="function"?y(w):null})}):null]})}function Me(U){const{data:m,graphTitle:N,colors:O,sources:F,graphDescription:p,showColumnLabels:H=!0,leftMargin:I=100,rightMargin:z=10,truncateBy:_=999,height:q,width:r,scaleType:J,colorDomain:s,footNote:G,colorLegendTitle:$,padding:S,backgroundColor:f=!1,topMargin:X=30,bottomMargin:K=10,tooltip:Y,onSeriesMouseOver:V,suffix:Q="",prefix:y="",showRowLabels:L=!0,relativeHeight:j,showValues:v,graphID:Z,noDataColor:W=i.Colors.gray,showColorScale:D=!0,onSeriesMouseClick:l,graphDownload:w=!1,dataDownload:T=!1,fillContainer:a=!0,language:M="en",showNAColor:A=!0,minHeight:b=0,theme:o="light",ariaLabel:B,resetSelectionOnDoubleClick:ee=!0,detailsOnClick:te,styles:h,classNames:d,animate:E=!1,precision:k=2}=U,[u,R]=x.useState(0),[P,t]=x.useState(0),[C,g]=x.useState(void 0),c=x.useRef(null),ie=x.useRef(null);x.useEffect(()=>{const n=new ResizeObserver(ne=>{R(r||ne[0].target.clientWidth||620),t(q||ne[0].target.clientHeight||480)});return c.current&&(t(c.current.clientHeight||480),R(c.current.clientWidth||620),r||n.observe(c.current)),()=>n.disconnect()},[r,q]);const oe=J||(typeof s[0]=="string"?"categorical":s.length===2?"linear":"threshold");return e.jsxRuntimeExports.jsx("div",{className:`${o||"light"} flex ${r?"grow-0":"grow"} ${a?"w-full":"w-fit"}`,dir:M==="he"||M==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${f?f===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,a?"w-full":"w-fit",d?.graphContainer),style:{...h?.graphContainer||{},...f&&f!==!0?{backgroundColor:f}:{}},id:Z,ref:ie,"aria-label":B||`${N?`The graph shows ${N}. `:""}This is a heatmap. ${p?` ${p}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:f?S||"1rem":S||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[N||p||w||T?e.jsxRuntimeExports.jsx(ve.GraphHeader,{styles:{title:h?.title,description:h?.description},classNames:{title:d?.title,description:d?.description},graphTitle:N,graphDescription:p,width:r,graphDownload:w?ie.current:void 0,dataDownload:T?m.map(n=>n.data).filter(n=>n!==void 0).length>0?m.map(n=>n.data).filter(n=>n!==void 0):m.filter(n=>n!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:m.length===0?e.jsxRuntimeExports.jsx(qe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[D?oe==="categorical"?e.jsxRuntimeExports.jsx(be.ColorLegendWithMouseOver,{width:a?void 0:r,colorLegendTitle:$,colors:O||(typeof s[0]=="string"?i.Colors[o].categoricalColors.colors:s.length===2?[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]]:i.Colors[o].sequentialColors[`neutralColorsx0${s.length+1}`]),colorDomain:s.map(n=>`${n}`),setSelectedColor:g,showNAColor:A}):oe==="threshold"?e.jsxRuntimeExports.jsx(Re.ThresholdColorLegendWithMouseOver,{width:a?void 0:r,colorLegendTitle:$,colors:O||(typeof s[0]=="string"?i.Colors[o].categoricalColors.colors:s.length===2?[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]]:i.Colors[o].sequentialColors[`neutralColorsx0${s.length+1}`]),colorDomain:s,setSelectedColor:g,naColor:W,showNAColor:A}):e.jsxRuntimeExports.jsx(Ee.LinearColorLegend,{width:a?void 0:r,colorLegendTitle:$,colors:O||[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]],colorDomain:s}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:c,"aria-label":"Graph area",children:(r||u)&&(q||P)?e.jsxRuntimeExports.jsx($e,{data:m,colorDomain:s,width:r||u,colors:O||(typeof s[0]=="string"?i.Colors[o].categoricalColors.colors:s.length===2?[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]]:i.Colors[o].sequentialColors[`neutralColorsx0${s.length+1}`]),noDataColor:W,scaleType:oe,height:Math.max(b,q||(j?b?(r||u)*j>b?(r||u)*j:b:(r||u)*j:P)),showColumnLabels:H,leftMargin:I,rightMargin:z,topMargin:X,bottomMargin:K,selectedColor:C,truncateBy:_,showRowLabels:L,tooltip:Y,onSeriesMouseOver:V,showValues:v,suffix:Q,prefix:y,onSeriesMouseClick:l,resetSelectionOnDoubleClick:ee,detailsOnClick:te,styles:h,classNames:d,animate:E===!0?{duration:.5,once:!0,amount:.5}:E||{duration:0,once:!0,amount:0},precision:k}):null})]})}),F||G?e.jsxRuntimeExports.jsx(we.GraphFooter,{styles:{footnote:h?.footnote,source:h?.source},classNames:{footnote:d?.footnote,source:d?.source},sources:F,footNote:G,width:r}):null]})})})})}exports.HeatMap=Me;
2
2
  //# sourceMappingURL=HeatMap.cjs.map
package/dist/HeatMap.js CHANGED
@@ -8,7 +8,7 @@ import { g as fe } from "./getTextColorBasedOnBgColor-B6Nk2WBf.js";
8
8
  import { c as re } from "./checkIfNullOrUndefined-DmfiKkNw.js";
9
9
  import { s as xe } from "./string2HTML-oFCROsus.js";
10
10
  import { X as ye } from "./XAxesLabels-loO78vUO.js";
11
- import { Y as ve } from "./YAxesLabels-DSm6I5zG.js";
11
+ import { Y as ve } from "./YAxesLabels-DECkMgq8.js";
12
12
  import { u as ne } from "./uniqBy-BHy4I8PK.js";
13
13
  import { b as ce } from "./band-BEjh2CHI.js";
14
14
  import { o as we } from "./ordinal-w9Lu4Stb.js";
@@ -3,8 +3,8 @@ import { m as h } from "./proxy-CkpFesk1.js";
3
3
  function f(e) {
4
4
  const {
5
5
  value: r,
6
- y: t,
7
- x: a,
6
+ y: a,
7
+ x: t,
8
8
  style: s,
9
9
  className: l,
10
10
  width: o,
@@ -18,12 +18,12 @@ function f(e) {
18
18
  {
19
19
  variants: {
20
20
  initial: {
21
- y: t,
22
- x: a
21
+ y: a,
22
+ x: t
23
23
  },
24
24
  whileInView: {
25
- y: t,
26
- x: a,
25
+ y: a,
26
+ x: t,
27
27
  transition: { duration: n.duration }
28
28
  }
29
29
  },
@@ -42,10 +42,11 @@ function f(e) {
42
42
  children: r
43
43
  }
44
44
  ) }) })
45
- }
45
+ },
46
+ t
46
47
  );
47
48
  }
48
49
  export {
49
50
  f as Y
50
51
  };
51
- //# sourceMappingURL=YAxesLabels-DSm6I5zG.js.map
52
+ //# sourceMappingURL=YAxesLabels-DECkMgq8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"YAxesLabels-DECkMgq8.js","sources":["../src/Components/Elements/Axes/YAxesLabels.tsx"],"sourcesContent":["import { cn } from '@undp/design-system-react/cn';\r\nimport { motion } from 'motion/react';\r\n\r\nimport { AnimateDataType } from '@/Types';\r\n\r\ninterface Props {\r\n value: number | string;\r\n y: number;\r\n x: number;\r\n width: number;\r\n height: number;\r\n style?: React.CSSProperties;\r\n className?: string;\r\n alignment?: 'left' | 'right' | 'center';\r\n animate: AnimateDataType;\r\n isInView: boolean;\r\n}\r\n\r\nexport function YAxesLabels(props: Props) {\r\n const {\r\n value,\r\n y,\r\n x,\r\n style,\r\n className,\r\n width,\r\n height,\r\n alignment = 'right',\r\n animate,\r\n isInView,\r\n } = props;\r\n return (\r\n <motion.g\r\n key={x}\r\n variants={{\r\n initial: {\r\n y,\r\n x,\r\n },\r\n whileInView: {\r\n y,\r\n x,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n >\r\n <foreignObject y={0} x={0} width={width} height={height}>\r\n <div className='flex flex-col justify-center h-inherit'>\r\n <p\r\n className={cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 text-xs m-0 py-0 px-1.5 leading-none',\r\n `text-${alignment}`,\r\n className,\r\n )}\r\n style={style}\r\n >\r\n {value}\r\n </p>\r\n </div>\r\n </foreignObject>\r\n </motion.g>\r\n );\r\n}\r\n"],"names":["YAxesLabels","props","value","y","x","style","className","width","height","alignment","animate","isInView","jsx","motion","cn"],"mappings":";;AAkBO,SAASA,EAAYC,GAAc;AACxC,QAAM;AAAA,IACJ,OAAAC;AAAA,IACA,GAAAC;AAAA,IACA,GAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,SAAAC;AAAA,IACA,UAAAC;AAAA,EAAA,IACEV;AACJ,SACEW,gBAAAA,EAAAA;AAAAA,IAACC,EAAO;AAAA,IAAP;AAAA,MAEC,UAAU;AAAA,QACR,SAAS;AAAA,UACP,GAAAV;AAAA,UACA,GAAAC;AAAA,QAAA;AAAA,QAEF,aAAa;AAAA,UACX,GAAAD;AAAA,UACA,GAAAC;AAAA,UACA,YAAY,EAAE,UAAUM,EAAQ,SAAA;AAAA,QAAS;AAAA,MAC3C;AAAA,MAEF,SAAQ;AAAA,MACR,SAASC,IAAW,gBAAgB;AAAA,MACpC,MAAM,EAAE,SAAS,GAAG,YAAY,EAAE,UAAUD,EAAQ,WAAS;AAAA,MAE7D,UAAAE,gBAAAA,EAAAA,IAAC,iBAAA,EAAc,GAAG,GAAG,GAAG,GAAG,OAAAL,GAAc,QAAAC,GACvC,UAAAI,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,0CACb,UAAAA,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWE;AAAAA,YACT;AAAA,YACA,QAAQL,CAAS;AAAA,YACjBH;AAAA,UAAA;AAAA,UAEF,OAAAD;AAAA,UAEC,UAAAH;AAAA,QAAA;AAAA,MAAA,GAEL,EAAA,CACF;AAAA,IAAA;AAAA,IA7BKE;AAAA,EAAA;AAgCX;"}
@@ -1,2 +1,2 @@
1
- "use strict";const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),u=require("./proxy-BHRoeZgd.cjs");function d(r){const{value:s,y:t,x:e,style:a,className:l,width:x,height:o,alignment:c="right",animate:n,isInView:m}=r;return i.jsxRuntimeExports.jsx(u.motion.g,{variants:{initial:{y:t,x:e},whileInView:{y:t,x:e,transition:{duration:n.duration}}},initial:"initial",animate:m?"whileInView":"initial",exit:{opacity:0,transition:{duration:n.duration}},children:i.jsxRuntimeExports.jsx("foreignObject",{y:0,x:0,width:x,height:o,children:i.jsxRuntimeExports.jsx("div",{className:"flex flex-col justify-center h-inherit",children:i.jsxRuntimeExports.jsx("p",{className:i.mo("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs m-0 py-0 px-1.5 leading-none",`text-${c}`,l),style:a,children:s})})})})}exports.YAxesLabels=d;
2
- //# sourceMappingURL=YAxesLabels-CctDydGR.cjs.map
1
+ "use strict";const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),u=require("./proxy-BHRoeZgd.cjs");function d(r){const{value:s,y:e,x:t,style:a,className:l,width:x,height:o,alignment:c="right",animate:n,isInView:m}=r;return i.jsxRuntimeExports.jsx(u.motion.g,{variants:{initial:{y:e,x:t},whileInView:{y:e,x:t,transition:{duration:n.duration}}},initial:"initial",animate:m?"whileInView":"initial",exit:{opacity:0,transition:{duration:n.duration}},children:i.jsxRuntimeExports.jsx("foreignObject",{y:0,x:0,width:x,height:o,children:i.jsxRuntimeExports.jsx("div",{className:"flex flex-col justify-center h-inherit",children:i.jsxRuntimeExports.jsx("p",{className:i.mo("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs m-0 py-0 px-1.5 leading-none",`text-${c}`,l),style:a,children:s})})})},t)}exports.YAxesLabels=d;
2
+ //# sourceMappingURL=YAxesLabels-yRFFdx1s.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"YAxesLabels-yRFFdx1s.cjs","sources":["../src/Components/Elements/Axes/YAxesLabels.tsx"],"sourcesContent":["import { cn } from '@undp/design-system-react/cn';\r\nimport { motion } from 'motion/react';\r\n\r\nimport { AnimateDataType } from '@/Types';\r\n\r\ninterface Props {\r\n value: number | string;\r\n y: number;\r\n x: number;\r\n width: number;\r\n height: number;\r\n style?: React.CSSProperties;\r\n className?: string;\r\n alignment?: 'left' | 'right' | 'center';\r\n animate: AnimateDataType;\r\n isInView: boolean;\r\n}\r\n\r\nexport function YAxesLabels(props: Props) {\r\n const {\r\n value,\r\n y,\r\n x,\r\n style,\r\n className,\r\n width,\r\n height,\r\n alignment = 'right',\r\n animate,\r\n isInView,\r\n } = props;\r\n return (\r\n <motion.g\r\n key={x}\r\n variants={{\r\n initial: {\r\n y,\r\n x,\r\n },\r\n whileInView: {\r\n y,\r\n x,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n >\r\n <foreignObject y={0} x={0} width={width} height={height}>\r\n <div className='flex flex-col justify-center h-inherit'>\r\n <p\r\n className={cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 text-xs m-0 py-0 px-1.5 leading-none',\r\n `text-${alignment}`,\r\n className,\r\n )}\r\n style={style}\r\n >\r\n {value}\r\n </p>\r\n </div>\r\n </foreignObject>\r\n </motion.g>\r\n );\r\n}\r\n"],"names":["YAxesLabels","props","value","y","x","style","className","width","height","alignment","animate","isInView","jsx","motion","cn"],"mappings":"gGAkBO,SAASA,EAAYC,EAAc,CACxC,KAAM,CACJ,MAAAC,EACA,EAAAC,EACA,EAAAC,EACA,MAAAC,EACA,UAAAC,EACA,MAAAC,EACA,OAAAC,EACA,UAAAC,EAAY,QACZ,QAAAC,EACA,SAAAC,CAAA,EACEV,EACJ,OACEW,EAAAA,kBAAAA,IAACC,EAAAA,OAAO,EAAP,CAEC,SAAU,CACR,QAAS,CACP,EAAAV,EACA,EAAAC,CAAA,EAEF,YAAa,CACX,EAAAD,EACA,EAAAC,EACA,WAAY,CAAE,SAAUM,EAAQ,QAAA,CAAS,CAC3C,EAEF,QAAQ,UACR,QAASC,EAAW,cAAgB,UACpC,KAAM,CAAE,QAAS,EAAG,WAAY,CAAE,SAAUD,EAAQ,SAAS,EAE7D,SAAAE,EAAAA,kBAAAA,IAAC,gBAAA,CAAc,EAAG,EAAG,EAAG,EAAG,MAAAL,EAAc,OAAAC,EACvC,SAAAI,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,yCACb,SAAAA,EAAAA,kBAAAA,IAAC,IAAA,CACC,UAAWE,EAAAA,GACT,wFACA,QAAQL,CAAS,GACjBH,CAAA,EAEF,MAAAD,EAEC,SAAAH,CAAA,CAAA,EAEL,CAAA,CACF,CAAA,EA7BKE,CAAA,CAgCX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@undp/data-viz",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "main": "./dist/index.cjs",
5
5
  "module": "./dist/index.js",
6
6
  "browser": "./dist/index.umd.js",
@@ -1 +0,0 @@
1
- {"version":3,"file":"YAxesLabels-CctDydGR.cjs","sources":["../src/Components/Elements/Axes/YAxesLabels.tsx"],"sourcesContent":["import { cn } from '@undp/design-system-react/cn';\r\nimport { motion } from 'motion/react';\r\n\r\nimport { AnimateDataType } from '@/Types';\r\n\r\ninterface Props {\r\n value: number | string;\r\n y: number;\r\n x: number;\r\n width: number;\r\n height: number;\r\n style?: React.CSSProperties;\r\n className?: string;\r\n alignment?: 'left' | 'right' | 'center';\r\n animate: AnimateDataType;\r\n isInView: boolean;\r\n}\r\n\r\nexport function YAxesLabels(props: Props) {\r\n const {\r\n value,\r\n y,\r\n x,\r\n style,\r\n className,\r\n width,\r\n height,\r\n alignment = 'right',\r\n animate,\r\n isInView,\r\n } = props;\r\n return (\r\n <motion.g\r\n variants={{\r\n initial: {\r\n y,\r\n x,\r\n },\r\n whileInView: {\r\n y,\r\n x,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n >\r\n <foreignObject y={0} x={0} width={width} height={height}>\r\n <div className='flex flex-col justify-center h-inherit'>\r\n <p\r\n className={cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 text-xs m-0 py-0 px-1.5 leading-none',\r\n `text-${alignment}`,\r\n className,\r\n )}\r\n style={style}\r\n >\r\n {value}\r\n </p>\r\n </div>\r\n </foreignObject>\r\n </motion.g>\r\n );\r\n}\r\n"],"names":["YAxesLabels","props","value","y","x","style","className","width","height","alignment","animate","isInView","jsx","motion","cn"],"mappings":"gGAkBO,SAASA,EAAYC,EAAc,CACxC,KAAM,CACJ,MAAAC,EACA,EAAAC,EACA,EAAAC,EACA,MAAAC,EACA,UAAAC,EACA,MAAAC,EACA,OAAAC,EACA,UAAAC,EAAY,QACZ,QAAAC,EACA,SAAAC,CAAA,EACEV,EACJ,OACEW,EAAAA,kBAAAA,IAACC,EAAAA,OAAO,EAAP,CACC,SAAU,CACR,QAAS,CACP,EAAAV,EACA,EAAAC,CAAA,EAEF,YAAa,CACX,EAAAD,EACA,EAAAC,EACA,WAAY,CAAE,SAAUM,EAAQ,QAAA,CAAS,CAC3C,EAEF,QAAQ,UACR,QAASC,EAAW,cAAgB,UACpC,KAAM,CAAE,QAAS,EAAG,WAAY,CAAE,SAAUD,EAAQ,SAAS,EAE7D,SAAAE,EAAAA,kBAAAA,IAAC,gBAAA,CAAc,EAAG,EAAG,EAAG,EAAG,MAAAL,EAAc,OAAAC,EACvC,SAAAI,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,yCACb,SAAAA,EAAAA,kBAAAA,IAAC,IAAA,CACC,UAAWE,EAAAA,GACT,wFACA,QAAQL,CAAS,GACjBH,CAAA,EAEF,MAAAD,EAEC,SAAAH,CAAA,CAAA,EAEL,CAAA,CACF,CAAA,CAAA,CAGN"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"YAxesLabels-DSm6I5zG.js","sources":["../src/Components/Elements/Axes/YAxesLabels.tsx"],"sourcesContent":["import { cn } from '@undp/design-system-react/cn';\r\nimport { motion } from 'motion/react';\r\n\r\nimport { AnimateDataType } from '@/Types';\r\n\r\ninterface Props {\r\n value: number | string;\r\n y: number;\r\n x: number;\r\n width: number;\r\n height: number;\r\n style?: React.CSSProperties;\r\n className?: string;\r\n alignment?: 'left' | 'right' | 'center';\r\n animate: AnimateDataType;\r\n isInView: boolean;\r\n}\r\n\r\nexport function YAxesLabels(props: Props) {\r\n const {\r\n value,\r\n y,\r\n x,\r\n style,\r\n className,\r\n width,\r\n height,\r\n alignment = 'right',\r\n animate,\r\n isInView,\r\n } = props;\r\n return (\r\n <motion.g\r\n variants={{\r\n initial: {\r\n y,\r\n x,\r\n },\r\n whileInView: {\r\n y,\r\n x,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n >\r\n <foreignObject y={0} x={0} width={width} height={height}>\r\n <div className='flex flex-col justify-center h-inherit'>\r\n <p\r\n className={cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 text-xs m-0 py-0 px-1.5 leading-none',\r\n `text-${alignment}`,\r\n className,\r\n )}\r\n style={style}\r\n >\r\n {value}\r\n </p>\r\n </div>\r\n </foreignObject>\r\n </motion.g>\r\n );\r\n}\r\n"],"names":["YAxesLabels","props","value","y","x","style","className","width","height","alignment","animate","isInView","jsx","motion","cn"],"mappings":";;AAkBO,SAASA,EAAYC,GAAc;AACxC,QAAM;AAAA,IACJ,OAAAC;AAAA,IACA,GAAAC;AAAA,IACA,GAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,SAAAC;AAAA,IACA,UAAAC;AAAA,EAAA,IACEV;AACJ,SACEW,gBAAAA,EAAAA;AAAAA,IAACC,EAAO;AAAA,IAAP;AAAA,MACC,UAAU;AAAA,QACR,SAAS;AAAA,UACP,GAAAV;AAAA,UACA,GAAAC;AAAA,QAAA;AAAA,QAEF,aAAa;AAAA,UACX,GAAAD;AAAA,UACA,GAAAC;AAAA,UACA,YAAY,EAAE,UAAUM,EAAQ,SAAA;AAAA,QAAS;AAAA,MAC3C;AAAA,MAEF,SAAQ;AAAA,MACR,SAASC,IAAW,gBAAgB;AAAA,MACpC,MAAM,EAAE,SAAS,GAAG,YAAY,EAAE,UAAUD,EAAQ,WAAS;AAAA,MAE7D,UAAAE,gBAAAA,EAAAA,IAAC,iBAAA,EAAc,GAAG,GAAG,GAAG,GAAG,OAAAL,GAAc,QAAAC,GACvC,UAAAI,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,0CACb,UAAAA,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWE;AAAAA,YACT;AAAA,YACA,QAAQL,CAAS;AAAA,YACjBH;AAAA,UAAA;AAAA,UAEF,OAAAD;AAAA,UAEC,UAAAH;AAAA,QAAA;AAAA,MAAA,GAEL,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}