@undp/data-viz 0.0.72 → 0.0.73
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/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -275,7 +275,7 @@ License: MIT
|
|
|
275
275
|
To pick up a draggable item, press the space bar.
|
|
276
276
|
While dragging, use the arrow keys to move the item.
|
|
277
277
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
278
|
-
`},Pme={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:r}=t;return r?"Draggable item "+e.id+" was moved over droppable area "+r.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:r}=t;return r?"Draggable item "+e.id+" was dropped over droppable area "+r.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function Rme(t){let{announcements:e=Pme,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=Ime}=t;const{announce:i,announcement:o}=jme(),l=sw("DndLiveRegion"),[s,f]=I.useState(!1);if(I.useEffect(()=>{f(!0)},[]),Lme(I.useMemo(()=>({onDragStart(h){let{active:d}=h;i(e.onDragStart({active:d}))},onDragMove(h){let{active:d,over:m}=h;e.onDragMove&&i(e.onDragMove({active:d,over:m}))},onDragOver(h){let{active:d,over:m}=h;i(e.onDragOver({active:d,over:m}))},onDragEnd(h){let{active:d,over:m}=h;i(e.onDragEnd({active:d,over:m}))},onDragCancel(h){let{active:d,over:m}=h;i(e.onDragCancel({active:d,over:m}))}}),[i,e])),!s)return null;const c=I.createElement(I.Fragment,null,I.createElement(Mme,{id:n,value:a.draggable}),I.createElement(Eme,{id:l,announcement:o}));return r?a0.createPortal(c,r):c}var $1;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})($1||($1={}));function Nc(){}function $me(t,e){return I.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Bme(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return I.useMemo(()=>[...e].filter(n=>n!=null),[...e])}const Ro=Object.freeze({x:0,y:0});function Vme(t,e){let{data:{value:r}}=t,{data:{value:n}}=e;return n-r}function Fme(t,e){if(!t||t.length===0)return null;const[r]=t;return r[e]}function zme(t,e){const r=Math.max(e.top,t.top),n=Math.max(e.left,t.left),a=Math.min(e.left+e.width,t.left+t.width),i=Math.min(e.top+e.height,t.top+t.height),o=a-n,l=i-r;if(n<a&&r<i){const s=e.width*e.height,f=t.width*t.height,c=o*l,h=c/(s+f-c);return Number(h.toFixed(4))}return 0}const Hme=t=>{let{collisionRect:e,droppableRects:r,droppableContainers:n}=t;const a=[];for(const i of n){const{id:o}=i,l=r.get(o);if(l){const s=zme(l,e);s>0&&a.push({id:o,data:{droppableContainer:i,value:s}})}}return a.sort(Vme)};function qme(t,e,r){return{...t,scaleX:e&&r?e.width/r.width:1,scaleY:e&&r?e.height/r.height:1}}function DH(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Ro}function Wme(t){return function(r){for(var n=arguments.length,a=new Array(n>1?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];return a.reduce((o,l)=>({...o,top:o.top+t*l.y,bottom:o.bottom+t*l.y,left:o.left+t*l.x,right:o.right+t*l.x}),{...r})}}const Ume=Wme(1);function Gme(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function Yme(t,e,r){const n=Gme(e);if(!n)return t;const{scaleX:a,scaleY:i,x:o,y:l}=n,s=t.left-o-(1-a)*parseFloat(r),f=t.top-l-(1-i)*parseFloat(r.slice(r.indexOf(" ")+1)),c=a?t.width/a:t.width,h=i?t.height/i:t.height;return{width:c,height:h,top:f,right:s+c,bottom:f+h,left:s}}const Xme={ignoreTransform:!1};function c9(t,e){e===void 0&&(e=Xme);let r=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:f,transformOrigin:c}=xi(t).getComputedStyle(t);f&&(r=Yme(r,f,c))}const{top:n,left:a,width:i,height:o,bottom:l,right:s}=r;return{top:n,left:a,width:i,height:o,bottom:l,right:s}}function TM(t){return c9(t,{ignoreTransform:!0})}function Kme(t){const e=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:e,bottom:r,width:e,height:r}}function Jme(t,e){return e===void 0&&(e=xi(t).getComputedStyle(t)),e.position==="fixed"}function Zme(t,e){e===void 0&&(e=xi(t).getComputedStyle(t));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const i=e[a];return typeof i=="string"?r.test(i):!1})}function uw(t,e){const r=[];function n(a){if(e!=null&&r.length>=e||!a)return r;if(iw(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!s9(a)||CH(a)||r.includes(a))return r;const i=xi(t).getComputedStyle(a);return a!==t&&Zme(a,i)&&r.push(a),Jme(a,i)?r:n(a.parentNode)}return t?n(t):r}function AH(t){const[e]=uw(t,1);return e??null}function xm(t){return!Bf||!t?null:v7(t)?t:aw(t)?iw(t)||t===b7(t).scrollingElement?window:s9(t)?t:null:null}function TH(t){return v7(t)?t.scrollX:t.scrollLeft}function MH(t){return v7(t)?t.scrollY:t.scrollTop}function Zy(t){return{x:TH(t),y:MH(t)}}var l1;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(l1||(l1={}));function EH(t){return!Bf||!t?!1:t===document.scrollingElement}function jH(t){const e={x:0,y:0},r=EH(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},n={x:t.scrollWidth-r.width,y:t.scrollHeight-r.height},a=t.scrollTop<=e.y,i=t.scrollLeft<=e.x,o=t.scrollTop>=n.y,l=t.scrollLeft>=n.x;return{isTop:a,isLeft:i,isBottom:o,isRight:l,maxScroll:n,minScroll:e}}const Qme={x:.2,y:.2};function ege(t,e,r,n,a){let{top:i,left:o,right:l,bottom:s}=r;n===void 0&&(n=10),a===void 0&&(a=Qme);const{isTop:f,isBottom:c,isLeft:h,isRight:d}=jH(t),m={x:0,y:0},g={x:0,y:0},y={height:e.height*a.y,width:e.width*a.x};return!f&&i<=e.top+y.height?(m.y=l1.Backward,g.y=n*Math.abs((e.top+y.height-i)/y.height)):!c&&s>=e.bottom-y.height&&(m.y=l1.Forward,g.y=n*Math.abs((e.bottom-y.height-s)/y.height)),!d&&l>=e.right-y.width?(m.x=l1.Forward,g.x=n*Math.abs((e.right-y.width-l)/y.width)):!h&&o<=e.left+y.width&&(m.x=l1.Backward,g.x=n*Math.abs((e.left+y.width-o)/y.width)),{direction:m,speed:g}}function tge(t){if(t===document.scrollingElement){const{innerWidth:i,innerHeight:o}=window;return{top:0,left:0,right:i,bottom:o,width:i,height:o}}const{top:e,left:r,right:n,bottom:a}=t.getBoundingClientRect();return{top:e,left:r,right:n,bottom:a,width:t.clientWidth,height:t.clientHeight}}function LH(t){return t.reduce((e,r)=>k6(e,Zy(r)),Ro)}function rge(t){return t.reduce((e,r)=>e+TH(r),0)}function nge(t){return t.reduce((e,r)=>e+MH(r),0)}function age(t,e){if(e===void 0&&(e=c9),!t)return;const{top:r,left:n,bottom:a,right:i}=e(t);AH(t)&&(a<=0||i<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const ige=[["x",["left","right"],rge],["y",["top","bottom"],nge]];class cw{constructor(e,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=uw(r),a=LH(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[i,o,l]of ige)for(const s of o)Object.defineProperty(this,s,{get:()=>{const f=l(n),c=a[i]-f;return this.rect[s]+c},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class os{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=e}add(e,r,n){var a;(a=this.target)==null||a.addEventListener(e,r,n),this.listeners.push([e,r,n])}}function oge(t){const{EventTarget:e}=xi(t);return t instanceof e?t:b7(t)}function wm(t,e){const r=Math.abs(t.x),n=Math.abs(t.y);return typeof e=="number"?Math.sqrt(r**2+n**2)>e:"x"in e&&"y"in e?r>e.x&&n>e.y:"x"in e?r>e.x:"y"in e?n>e.y:!1}var ao;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(ao||(ao={}));function MM(t){t.preventDefault()}function lge(t){t.stopPropagation()}var Pn;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Pn||(Pn={}));const NH={start:[Pn.Space,Pn.Enter],cancel:[Pn.Esc],end:[Pn.Space,Pn.Enter,Pn.Tab]},sge=(t,e)=>{let{currentCoordinates:r}=e;switch(t.code){case Pn.Right:return{...r,x:r.x+25};case Pn.Left:return{...r,x:r.x-25};case Pn.Down:return{...r,y:r.y+25};case Pn.Up:return{...r,y:r.y-25}}};class IH{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:r}}=e;this.props=e,this.listeners=new os(b7(r)),this.windowListeners=new os(xi(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ao.Resize,this.handleCancel),this.windowListeners.add(ao.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ao.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:r}=this.props,n=e.node.current;n&&age(n),r(Ro)}handleKeyDown(e){if(_H(e)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:i=NH,coordinateGetter:o=sge,scrollBehavior:l="smooth"}=a,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}const{collisionRect:f}=n.current,c=f?{x:f.left,y:f.top}:Ro;this.referenceCoordinates||(this.referenceCoordinates=c);const h=o(e,{active:r,context:n.current,currentCoordinates:c});if(h){const d=Lc(h,c),m={x:0,y:0},{scrollableAncestors:g}=n.current;for(const y of g){const b=e.code,{isTop:S,isRight:w,isLeft:C,isBottom:k,maxScroll:_,minScroll:D}=jH(y),T=tge(y),A={x:Math.min(b===Pn.Right?T.right-T.width/2:T.right,Math.max(b===Pn.Right?T.left:T.left+T.width/2,h.x)),y:Math.min(b===Pn.Down?T.bottom-T.height/2:T.bottom,Math.max(b===Pn.Down?T.top:T.top+T.height/2,h.y))},M=b===Pn.Right&&!w||b===Pn.Left&&!C,E=b===Pn.Down&&!k||b===Pn.Up&&!S;if(M&&A.x!==h.x){const N=y.scrollLeft+d.x,Y=b===Pn.Right&&N<=_.x||b===Pn.Left&&N>=D.x;if(Y&&!d.y){y.scrollTo({left:N,behavior:l});return}Y?m.x=y.scrollLeft-N:m.x=b===Pn.Right?y.scrollLeft-_.x:y.scrollLeft-D.x,m.x&&y.scrollBy({left:-m.x,behavior:l});break}else if(E&&A.y!==h.y){const N=y.scrollTop+d.y,Y=b===Pn.Down&&N<=_.y||b===Pn.Up&&N>=D.y;if(Y&&!d.x){y.scrollTo({top:N,behavior:l});return}Y?m.y=y.scrollTop-N:m.y=b===Pn.Down?y.scrollTop-_.y:y.scrollTop-D.y,m.y&&y.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(e,k6(Lc(h,this.referenceCoordinates),m))}}}handleMove(e,r){const{onMove:n}=this.props;e.preventDefault(),n(r)}handleEnd(e){const{onEnd:r}=this.props;e.preventDefault(),this.detach(),r()}handleCancel(e){const{onCancel:r}=this.props;e.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}IH.activators=[{eventName:"onKeyDown",handler:(t,e,r)=>{let{keyboardCodes:n=NH,onActivation:a}=e,{active:i}=r;const{code:o}=t.nativeEvent;if(n.start.includes(o)){const l=i.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),a==null||a({event:t.nativeEvent}),!0)}return!1}}];function EM(t){return!!(t&&"distance"in t)}function jM(t){return!!(t&&"delay"in t)}class fw{constructor(e,r,n){var a;n===void 0&&(n=oge(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=r;const{event:i}=e,{target:o}=i;this.props=e,this.events=r,this.document=b7(o),this.documentListeners=new os(this.document),this.listeners=new os(n),this.windowListeners=new os(xi(o)),this.initialCoordinates=(a=Jy(i))!=null?a:Ro,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(ao.Resize,this.handleCancel),this.windowListeners.add(ao.DragStart,MM),this.windowListeners.add(ao.VisibilityChange,this.handleCancel),this.windowListeners.add(ao.ContextMenu,MM),this.documentListeners.add(ao.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(jM(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(EM(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,r){const{active:n,onPending:a}=this.props;a(n,e,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:e}=this,{onStart:r}=this.props;e&&(this.activated=!0,this.documentListeners.add(ao.Click,lge,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ao.SelectionChange,this.removeTextSelection),r(e))}handleMove(e){var r;const{activated:n,initialCoordinates:a,props:i}=this,{onMove:o,options:{activationConstraint:l}}=i;if(!a)return;const s=(r=Jy(e))!=null?r:Ro,f=Lc(a,s);if(!n&&l){if(EM(l)){if(l.tolerance!=null&&wm(f,l.tolerance))return this.handleCancel();if(wm(f,l.distance))return this.handleStart()}if(jM(l)&&wm(f,l.tolerance))return this.handleCancel();this.handlePending(l,f);return}e.cancelable&&e.preventDefault(),o(s)}handleEnd(){const{onAbort:e,onEnd:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleCancel(){const{onAbort:e,onCancel:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleKeydown(e){e.code===Pn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const uge={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class dw extends fw{constructor(e){const{event:r}=e,n=b7(r.target);super(e,uge,n)}}dw.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:r}=t,{onActivation:n}=e;return!r.isPrimary||r.button!==0?!1:(n==null||n({event:r}),!0)}}];const cge={move:{name:"mousemove"},end:{name:"mouseup"}};var Qy;(function(t){t[t.RightClick=2]="RightClick"})(Qy||(Qy={}));class fge extends fw{constructor(e){super(e,cge,b7(e.event.target))}}fge.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:r}=t,{onActivation:n}=e;return r.button===Qy.RightClick?!1:(n==null||n({event:r}),!0)}}];const Sm={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class dge extends fw{constructor(e){super(e,Sm)}static setup(){return window.addEventListener(Sm.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Sm.move.name,e)};function e(){}}}dge.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:r}=t,{onActivation:n}=e;const{touches:a}=r;return a.length>1?!1:(n==null||n({event:r}),!0)}}];var ls;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(ls||(ls={}));var Ic;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ic||(Ic={}));function hge(t){let{acceleration:e,activator:r=ls.Pointer,canScroll:n,draggingRect:a,enabled:i,interval:o=5,order:l=Ic.TreeOrder,pointerCoordinates:s,scrollableAncestors:f,scrollableAncestorRects:c,delta:h,threshold:d}=t;const m=mge({delta:h,disabled:!i}),[g,y]=_me(),b=I.useRef({x:0,y:0}),S=I.useRef({x:0,y:0}),w=I.useMemo(()=>{switch(r){case ls.Pointer:return s?{top:s.y,bottom:s.y,left:s.x,right:s.x}:null;case ls.DraggableRect:return a}},[r,a,s]),C=I.useRef(null),k=I.useCallback(()=>{const D=C.current;if(!D)return;const T=b.current.x*S.current.x,A=b.current.y*S.current.y;D.scrollBy(T,A)},[]),_=I.useMemo(()=>l===Ic.TreeOrder?[...f].reverse():f,[l,f]);I.useEffect(()=>{if(!i||!f.length||!w){y();return}for(const D of _){if((n==null?void 0:n(D))===!1)continue;const T=f.indexOf(D),A=c[T];if(!A)continue;const{direction:M,speed:E}=ege(D,A,w,e,d);for(const N of["x","y"])m[N][M[N]]||(E[N]=0,M[N]=0);if(E.x>0||E.y>0){y(),C.current=D,g(k,o),b.current=E,S.current=M;return}}b.current={x:0,y:0},S.current={x:0,y:0},y()},[e,k,n,y,i,o,JSON.stringify(w),JSON.stringify(m),g,f,_,c,JSON.stringify(d)])}const pge={x:{[l1.Backward]:!1,[l1.Forward]:!1},y:{[l1.Backward]:!1,[l1.Forward]:!1}};function mge(t){let{delta:e,disabled:r}=t;const n=Ky(e);return u9(a=>{if(r||!n||!a)return pge;const i={x:Math.sign(e.x-n.x),y:Math.sign(e.y-n.y)};return{x:{[l1.Backward]:a.x[l1.Backward]||i.x===-1,[l1.Forward]:a.x[l1.Forward]||i.x===1},y:{[l1.Backward]:a.y[l1.Backward]||i.y===-1,[l1.Forward]:a.y[l1.Forward]||i.y===1}}},[r,e,n])}function gge(t,e){const r=e!=null?t.get(e):void 0,n=r?r.node.current:null;return u9(a=>{var i;return e==null?null:(i=n??a)!=null?i:null},[n,e])}function yge(t,e){return I.useMemo(()=>t.reduce((r,n)=>{const{sensor:a}=n,i=a.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,n)}));return[...r,...i]},[]),[t,e])}var Ls;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Ls||(Ls={}));var ev;(function(t){t.Optimized="optimized"})(ev||(ev={}));const LM=new Map;function vge(t,e){let{dragging:r,dependencies:n,config:a}=e;const[i,o]=I.useState(null),{frequency:l,measure:s,strategy:f}=a,c=I.useRef(t),h=b(),d=lw(h),m=I.useCallback(function(S){S===void 0&&(S=[]),!d.current&&o(w=>w===null?S:w.concat(S.filter(C=>!w.includes(C))))},[d]),g=I.useRef(null),y=u9(S=>{if(h&&!r)return LM;if(!S||S===LM||c.current!==t||i!=null){const w=new Map;for(let C of t){if(!C)continue;if(i&&i.length>0&&!i.includes(C.id)&&C.rect.current){w.set(C.id,C.rect.current);continue}const k=C.node.current,_=k?new cw(s(k),k):null;C.rect.current=_,_&&w.set(C.id,_)}return w}return S},[t,i,r,h,s]);return I.useEffect(()=>{c.current=t},[t]),I.useEffect(()=>{h||m()},[r,h]),I.useEffect(()=>{i&&i.length>0&&o(null)},[JSON.stringify(i)]),I.useEffect(()=>{h||typeof l!="number"||g.current!==null||(g.current=setTimeout(()=>{m(),g.current=null},l))},[l,h,m,...n]),{droppableRects:y,measureDroppableContainers:m,measuringScheduled:i!=null};function b(){switch(f){case Ls.Always:return!1;case Ls.BeforeDragging:return r;default:return!r}}}function PH(t,e){return u9(r=>t?r||(typeof e=="function"?e(t):t):null,[e,t])}function bge(t,e){return PH(t,e)}function xge(t){let{callback:e,disabled:r}=t;const n=ow(e),a=I.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(n)},[n,r]);return I.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function hw(t){let{callback:e,disabled:r}=t;const n=ow(e),a=I.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(n)},[r]);return I.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function wge(t){return new cw(c9(t),t)}function NM(t,e,r){e===void 0&&(e=wge);const[n,a]=I.useState(null);function i(){a(s=>{if(!t)return null;if(t.isConnected===!1){var f;return(f=s??r)!=null?f:null}const c=e(t);return JSON.stringify(s)===JSON.stringify(c)?s:c})}const o=xge({callback(s){if(t)for(const f of s){const{type:c,target:h}=f;if(c==="childList"&&h instanceof HTMLElement&&h.contains(t)){i();break}}}}),l=hw({callback:i});return F2(()=>{i(),t?(l==null||l.observe(t),o==null||o.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),o==null||o.disconnect())},[t]),n}function Sge(t){const e=PH(t);return DH(t,e)}const IM=[];function Cge(t){const e=I.useRef(t),r=u9(n=>t?n&&n!==IM&&t&&e.current&&t.parentNode===e.current.parentNode?n:uw(t):IM,[t]);return I.useEffect(()=>{e.current=t},[t]),r}function kge(t){const[e,r]=I.useState(null),n=I.useRef(t),a=I.useCallback(i=>{const o=xm(i.target);o&&r(l=>l?(l.set(o,Zy(o)),new Map(l)):null)},[]);return I.useEffect(()=>{const i=n.current;if(t!==i){o(i);const l=t.map(s=>{const f=xm(s);return f?(f.addEventListener("scroll",a,{passive:!0}),[f,Zy(f)]):null}).filter(s=>s!=null);r(l.length?new Map(l):null),n.current=t}return()=>{o(t),o(i)};function o(l){l.forEach(s=>{const f=xm(s);f==null||f.removeEventListener("scroll",a)})}},[a,t]),I.useMemo(()=>t.length?e?Array.from(e.values()).reduce((i,o)=>k6(i,o),Ro):LH(t):Ro,[t,e])}function PM(t,e){e===void 0&&(e=[]);const r=I.useRef(null);return I.useEffect(()=>{r.current=null},e),I.useEffect(()=>{const n=t!==Ro;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?Lc(t,r.current):Ro}function _ge(t){I.useEffect(()=>{if(!Bf)return;const e=t.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of e)r==null||r()}},t.map(e=>{let{sensor:r}=e;return r}))}function Oge(t,e){return I.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:i}=n;return r[a]=o=>{i(o,e)},r},{}),[t,e])}function RH(t){return I.useMemo(()=>t?Kme(t):null,[t])}const RM=[];function Dge(t,e){e===void 0&&(e=c9);const[r]=t,n=RH(r?xi(r):null),[a,i]=I.useState(RM);function o(){i(()=>t.length?t.map(s=>EH(s)?n:new cw(e(s),s)):RM)}const l=hw({callback:o});return F2(()=>{l==null||l.disconnect(),o(),t.forEach(s=>l==null?void 0:l.observe(s))},[t]),a}function Age(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return s9(e)?e:t}function Tge(t){let{measure:e}=t;const[r,n]=I.useState(null),a=I.useCallback(f=>{for(const{target:c}of f)if(s9(c)){n(h=>{const d=e(c);return h?{...h,width:d.width,height:d.height}:d});break}},[e]),i=hw({callback:a}),o=I.useCallback(f=>{const c=Age(f);i==null||i.disconnect(),c&&(i==null||i.observe(c)),n(c?e(c):null)},[e,i]),[l,s]=Xy(o);return I.useMemo(()=>({nodeRef:l,rect:r,setRef:s}),[r,l,s])}const Mge=[{sensor:dw,options:{}},{sensor:IH,options:{}}],Ege={current:{}},ju={draggable:{measure:TM},droppable:{measure:TM,strategy:Ls.WhileDragging,frequency:ev.Optimized},dragOverlay:{measure:c9}};class ss extends Map{get(e){var r;return e!=null&&(r=super.get(e))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:r}=e;return!r})}getNodeFor(e){var r,n;return(r=(n=this.get(e))==null?void 0:n.node.current)!=null?r:void 0}}const jge={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ss,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Nc},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ju,measureDroppableContainers:Nc,windowRect:null,measuringScheduled:!1},Lge={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Nc,draggableNodes:new Map,over:null,measureDroppableContainers:Nc},pw=I.createContext(Lge),Nge=I.createContext(jge);function Ige(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ss}}}function Pge(t,e){switch(e.type){case $1.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case $1.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case $1.DragEnd:case $1.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case $1.RegisterDroppable:{const{element:r}=e,{id:n}=r,a=new ss(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case $1.SetDroppableDisabled:{const{id:r,key:n,disabled:a}=e,i=t.droppable.containers.get(r);if(!i||n!==i.key)return t;const o=new ss(t.droppable.containers);return o.set(r,{...i,disabled:a}),{...t,droppable:{...t.droppable,containers:o}}}case $1.UnregisterDroppable:{const{id:r,key:n}=e,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const i=new ss(t.droppable.containers);return i.delete(r),{...t,droppable:{...t.droppable,containers:i}}}default:return t}}function Rge(t){let{disabled:e}=t;const{active:r,activatorEvent:n,draggableNodes:a}=I.useContext(pw),i=Ky(n),o=Ky(r==null?void 0:r.id);return I.useEffect(()=>{if(!e&&!n&&i&&o!=null){if(!_H(i)||document.activeElement===i.target)return;const l=a.get(o);if(!l)return;const{activatorNode:s,node:f}=l;if(!s.current&&!f.current)return;requestAnimationFrame(()=>{for(const c of[s.current,f.current]){if(!c)continue;const h=Ame(c);if(h){h.focus();break}}})}},[n,e,a,o,i]),null}function $ge(t,e){let{transform:r,...n}=e;return t!=null&&t.length?t.reduce((a,i)=>i({transform:a,...n}),r):r}function Bge(t){return I.useMemo(()=>({draggable:{...ju.draggable,...t==null?void 0:t.draggable},droppable:{...ju.droppable,...t==null?void 0:t.droppable},dragOverlay:{...ju.dragOverlay,...t==null?void 0:t.dragOverlay}}),[t==null?void 0:t.draggable,t==null?void 0:t.droppable,t==null?void 0:t.dragOverlay])}function Vge(t){let{activeNode:e,measure:r,initialRect:n,config:a=!0}=t;const i=I.useRef(!1),{x:o,y:l}=typeof a=="boolean"?{x:a,y:a}:a;F2(()=>{if(!o&&!l||!e){i.current=!1;return}if(i.current||!n)return;const f=e==null?void 0:e.node.current;if(!f||f.isConnected===!1)return;const c=r(f),h=DH(c,n);if(o||(h.x=0),l||(h.y=0),i.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const d=AH(f);d&&d.scrollBy({top:h.y,left:h.x})}},[e,o,l,n,r])}const $H=I.createContext({...Ro,scaleX:1,scaleY:1});var E2;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(E2||(E2={}));const Fge=I.memo(function(e){var r,n,a,i;let{id:o,accessibility:l,autoScroll:s=!0,children:f,sensors:c=Mge,collisionDetection:h=Hme,measuring:d,modifiers:m,...g}=e;const y=I.useReducer(Pge,void 0,Ige),[b,S]=y,[w,C]=Nme(),[k,_]=I.useState(E2.Uninitialized),D=k===E2.Initialized,{draggable:{active:T,nodes:A,translate:M},droppable:{containers:E}}=b,N=T!=null?A.get(T):null,Y=I.useRef({initial:null,translated:null}),ne=I.useMemo(()=>{var St;return T!=null?{id:T,data:(St=N==null?void 0:N.data)!=null?St:Ege,rect:Y}:null},[T,N]),K=I.useRef(null),[B,j]=I.useState(null),[$,V]=I.useState(null),z=lw(g,Object.values(g)),W=sw("DndDescribedBy",o),G=I.useMemo(()=>E.getEnabled(),[E]),ae=Bge(d),{droppableRects:U,measureDroppableContainers:H,measuringScheduled:R}=vge(G,{dragging:D,dependencies:[M.x,M.y],config:ae.droppable}),ee=gge(A,T),J=I.useMemo(()=>$?Jy($):null,[$]),Z=Tt(),re=bge(ee,ae.draggable.measure);Vge({activeNode:T!=null?A.get(T):null,config:Z.layoutShiftCompensation,initialRect:re,measure:ae.draggable.measure});const te=NM(ee,ae.draggable.measure,re),F=NM(ee?ee.parentElement:null),q=I.useRef({activatorEvent:null,active:null,activeNode:ee,collisionRect:null,collisions:null,droppableRects:U,draggableNodes:A,draggingNode:null,draggingNodeRect:null,droppableContainers:E,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),X=E.getNodeFor((r=q.current.over)==null?void 0:r.id),ie=Tge({measure:ae.dragOverlay.measure}),ce=(n=ie.nodeRef.current)!=null?n:ee,de=D?(a=ie.rect)!=null?a:te:null,he=!!(ie.nodeRef.current&&ie.rect),Oe=Sge(he?null:te),Ne=RH(ce?xi(ce):null),Te=Cge(D?X??ee:null),_e=Dge(Te),xe=$ge(m,{transform:{x:M.x-Oe.x,y:M.y-Oe.y,scaleX:1,scaleY:1},activatorEvent:$,active:ne,activeNodeRect:te,containerNodeRect:F,draggingNodeRect:de,over:q.current.over,overlayNodeRect:ie.rect,scrollableAncestors:Te,scrollableAncestorRects:_e,windowRect:Ne}),we=J?k6(J,M):null,ge=kge(Te),ve=PM(ge),le=PM(ge,[te]),ue=k6(xe,ve),Ce=de?Ume(de,xe):null,pe=ne&&Ce?h({active:ne,collisionRect:Ce,droppableRects:U,droppableContainers:G,pointerCoordinates:we}):null,ye=Fme(pe,"id"),[be,je]=I.useState(null),$e=he?xe:k6(xe,le),ut=qme($e,(i=be==null?void 0:be.rect)!=null?i:null,te),Ie=I.useRef(null),Ze=I.useCallback((St,tt)=>{let{sensor:Mt,options:Dt}=tt;if(K.current==null)return;const Ye=A.get(K.current);if(!Ye)return;const Lt=St.nativeEvent,Et=new Mt({active:K.current,activeNode:Ye,event:Lt,options:Dt,context:q,onAbort(He){if(!A.get(He))return;const{onDragAbort:Ge}=z.current,Rt={id:He};Ge==null||Ge(Rt),w({type:"onDragAbort",event:Rt})},onPending(He,It,Ge,Rt){if(!A.get(He))return;const{onDragPending:dr}=z.current,xr={id:He,constraint:It,initialCoordinates:Ge,offset:Rt};dr==null||dr(xr),w({type:"onDragPending",event:xr})},onStart(He){const It=K.current;if(It==null)return;const Ge=A.get(It);if(!Ge)return;const{onDragStart:Rt}=z.current,$t={activatorEvent:Lt,active:{id:It,data:Ge.data,rect:Y}};a0.unstable_batchedUpdates(()=>{Rt==null||Rt($t),_(E2.Initializing),S({type:$1.DragStart,initialCoordinates:He,active:It}),w({type:"onDragStart",event:$t}),j(Ie.current),V(Lt)})},onMove(He){S({type:$1.DragMove,coordinates:He})},onEnd:Xt($1.DragEnd),onCancel:Xt($1.DragCancel)});Ie.current=Et;function Xt(He){return async function(){const{active:Ge,collisions:Rt,over:$t,scrollAdjustedTranslate:dr}=q.current;let xr=null;if(Ge&&dr){const{cancelDrop:Mr}=z.current;xr={activatorEvent:Lt,active:Ge,collisions:Rt,delta:dr,over:$t},He===$1.DragEnd&&typeof Mr=="function"&&await Promise.resolve(Mr(xr))&&(He=$1.DragCancel)}K.current=null,a0.unstable_batchedUpdates(()=>{S({type:He}),_(E2.Uninitialized),je(null),j(null),V(null),Ie.current=null;const Mr=He===$1.DragEnd?"onDragEnd":"onDragCancel";if(xr){const Er=z.current[Mr];Er==null||Er(xr),w({type:Mr,event:xr})}})}}},[A]),Ke=I.useCallback((St,tt)=>(Mt,Dt)=>{const Ye=Mt.nativeEvent,Lt=A.get(Dt);if(K.current!==null||!Lt||Ye.dndKit||Ye.defaultPrevented)return;const Et={active:Lt};St(Mt,tt.options,Et)===!0&&(Ye.dndKit={capturedBy:tt.sensor},K.current=Dt,Ze(Mt,tt))},[A,Ze]),et=yge(c,Ke);_ge(c),F2(()=>{te&&k===E2.Initializing&&_(E2.Initialized)},[te,k]),I.useEffect(()=>{const{onDragMove:St}=z.current,{active:tt,activatorEvent:Mt,collisions:Dt,over:Ye}=q.current;if(!tt||!Mt)return;const Lt={active:tt,activatorEvent:Mt,collisions:Dt,delta:{x:ue.x,y:ue.y},over:Ye};a0.unstable_batchedUpdates(()=>{St==null||St(Lt),w({type:"onDragMove",event:Lt})})},[ue.x,ue.y]),I.useEffect(()=>{const{active:St,activatorEvent:tt,collisions:Mt,droppableContainers:Dt,scrollAdjustedTranslate:Ye}=q.current;if(!St||K.current==null||!tt||!Ye)return;const{onDragOver:Lt}=z.current,Et=Dt.get(ye),Xt=Et&&Et.rect.current?{id:Et.id,rect:Et.rect.current,data:Et.data,disabled:Et.disabled}:null,He={active:St,activatorEvent:tt,collisions:Mt,delta:{x:Ye.x,y:Ye.y},over:Xt};a0.unstable_batchedUpdates(()=>{je(Xt),Lt==null||Lt(He),w({type:"onDragOver",event:He})})},[ye]),F2(()=>{q.current={activatorEvent:$,active:ne,activeNode:ee,collisionRect:Ce,collisions:pe,droppableRects:U,draggableNodes:A,draggingNode:ce,draggingNodeRect:de,droppableContainers:E,over:be,scrollableAncestors:Te,scrollAdjustedTranslate:ue},Y.current={initial:de,translated:Ce}},[ne,ee,pe,Ce,A,ce,de,U,E,be,Te,ue]),hge({...Z,delta:M,draggingRect:Ce,pointerCoordinates:we,scrollableAncestors:Te,scrollableAncestorRects:_e});const Pt=I.useMemo(()=>({active:ne,activeNode:ee,activeNodeRect:te,activatorEvent:$,collisions:pe,containerNodeRect:F,dragOverlay:ie,draggableNodes:A,droppableContainers:E,droppableRects:U,over:be,measureDroppableContainers:H,scrollableAncestors:Te,scrollableAncestorRects:_e,measuringConfiguration:ae,measuringScheduled:R,windowRect:Ne}),[ne,ee,te,$,pe,F,ie,A,E,U,be,H,Te,_e,ae,R,Ne]),jt=I.useMemo(()=>({activatorEvent:$,activators:et,active:ne,activeNodeRect:te,ariaDescribedById:{draggable:W},dispatch:S,draggableNodes:A,over:be,measureDroppableContainers:H}),[$,et,ne,te,S,W,A,be,H]);return I.createElement(OH.Provider,{value:C},I.createElement(pw.Provider,{value:jt},I.createElement(Nge.Provider,{value:Pt},I.createElement($H.Provider,{value:ut},f)),I.createElement(Rge,{disabled:(l==null?void 0:l.restoreFocus)===!1})),I.createElement(Rme,{...l,hiddenTextDescribedById:W}));function Tt(){const St=(B==null?void 0:B.autoScrollEnabled)===!1,tt=typeof s=="object"?s.enabled===!1:s===!1,Mt=D&&!St&&!tt;return typeof s=="object"?{...s,enabled:Mt}:{enabled:Mt}}}),zge=I.createContext(null),$M="button",Hge="Draggable";function qge(t){let{id:e,data:r,disabled:n=!1,attributes:a}=t;const i=sw(Hge),{activators:o,activatorEvent:l,active:s,activeNodeRect:f,ariaDescribedById:c,draggableNodes:h,over:d}=I.useContext(pw),{role:m=$M,roleDescription:g="draggable",tabIndex:y=0}=a??{},b=(s==null?void 0:s.id)===e,S=I.useContext(b?$H:zge),[w,C]=Xy(),[k,_]=Xy(),D=Oge(o,e),T=lw(r);F2(()=>(h.set(e,{id:e,key:i,node:w,activatorNode:k,data:T}),()=>{const M=h.get(e);M&&M.key===i&&h.delete(e)}),[h,e]);const A=I.useMemo(()=>({role:m,tabIndex:y,"aria-disabled":n,"aria-pressed":b&&m===$M?!0:void 0,"aria-roledescription":g,"aria-describedby":c.draggable}),[n,m,y,b,g,c.draggable]);return{active:s,activatorEvent:l,activeNodeRect:f,attributes:A,isDragging:b,listeners:n?void 0:D,node:w,over:d,setNodeRef:C,setActivatorNodeRef:_,transform:S}}const Wge=t=>{let{transform:e}=t;return{...e,y:0}};function Uge(t,e){let r=!1;function n(a,i){if(!r){r=!0;const o=a.getCenter(),l=a.getZoom(),s=a.getBearing(),f=a.getPitch();i.jumpTo({center:o,zoom:l,bearing:s,pitch:f}),r=!1}}t.on("move",()=>{n(t,e)}),e.on("move",()=>{n(e,t)})}function Gge(t){const{height:e,width:r,mapStyles:n,center:a,zoomLevel:i}=t,[o,l]=I.useState(50),[s,f]=I.useState(!1),c=I.useRef(null),h=I.useRef(50),d=I.useRef(0),m=Bme($me(dw,{activationConstraint:{distance:0}})),g=()=>{f(!0),h.current=o,c.current&&(d.current=c.current.getBoundingClientRect().width)},y=D=>{if(!c.current||d.current===0)return;const T=D.delta.x/d.current*100,A=Math.max(0,Math.min(100,h.current+T));l(A)},b=()=>{f(!1)},S=D=>{if(s||!c.current)return;const T=c.current.getBoundingClientRect(),M=(D.clientX-T.left)/T.width*100;l(Math.max(0,Math.min(100,M)))},w=I.useRef(null),C=I.useRef(null),k=I.useRef(null),_=I.useRef(null);return I.useEffect(()=>{if(_.current&&C.current&&k.current&&r){Qr(_.current).selectAll(".maplibregl-compare").remove(),Qr(C.current).selectAll("div").remove(),Qr(k.current).selectAll("div").remove();const M=new Rf;y3.addProtocol("pmtiles",M.tile);const E=new y3.Map({container:C.current,style:n[0],center:a||[0,0],zoom:i||4}),N=new y3.Map({container:k.current,style:n[1],center:a||[0,0],zoom:i||4});N.addControl(new y3.NavigationControl({visualizePitch:!0,showZoom:!0,showCompass:!0}),"bottom-right"),E.addControl(new y3.ScaleControl,"bottom-left"),E.addControl(new y3.NavigationControl({visualizePitch:!0,showZoom:!0,showCompass:!0}),"bottom-right"),N.addControl(new y3.ScaleControl,"bottom-left"),Uge(E,N)}},[r,n,a,i]),v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:w,"aria-label":"Map area",children:v.jsx("div",{style:{width:r,height:e},children:v.jsx("div",{ref:_,className:"map maplibre-show-control relative w-full h-full",style:{inset:0},children:v.jsx(Fge,{sensors:m,modifiers:[Wge],onDragStart:g,onDragMove:y,onDragEnd:b,children:v.jsxs("div",{ref:c,style:{position:"relative",width:r,height:e,overflow:"hidden",cursor:s?"grabbing":"col-resize",userSelect:"none"},onClick:S,children:[v.jsx("div",{ref:k,className:"absolute h-full rightMap w-full",style:{position:"absolute",top:0,left:0,clipPath:`polygon(${o}% 0%, ${o}% 100%, 100% 100%, 100% 0%)`}}),v.jsx("div",{ref:C,className:"absolute h-full leftMap w-full",style:{position:"absolute",top:0,left:0,inset:0,clipPath:`polygon(0% 0%, ${o}% 0%, ${o}% 100%, 0% 100%)`}}),v.jsx(Yge,{position:o})]})})})})})}function Yge(t){const{position:e}=t,{attributes:r,listeners:n,setNodeRef:a}=qge({id:"slider-handle"});return v.jsxs("div",{ref:a,style:{position:"absolute",left:`${e}%`,top:0,bottom:0,width:"40px",transform:"translateX(-50%)",cursor:"col-resize",display:"flex",justifyContent:"center",alignItems:"center",zIndex:10,touchAction:"none"},...n,...r,children:[v.jsx("div",{className:"h-full bg-primary-blue-600 dark:bg-primary-blue-400",style:{width:"2px"}}),v.jsx("div",{className:"flex bg-primary-blue-600 dark:bg-primary-blue-400 rounded-full absolute items-center justify-center text-primary-white font-primary-white",style:{boxShadow:"inset 0 0 0 1px #fff",width:"42px",height:"42px",top:"calc(50% - 21px)",left:"0",cursor:"col-resize"},children:v.jsx(U3e,{})})]})}function BH(t){const{graphTitle:e,height:r,width:n,relativeHeight:a,sources:i,graphDescription:o,footNote:l,padding:s,backgroundColor:f=!1,graphID:c,mapStyles:h,center:d=[0,0],zoomLevel:m=3,language:g="en",minHeight:y=0,theme:b="light",ariaLabel:S,styles:w,classNames:C}=t,[k,_]=I.useState(0),[D,T]=I.useState(0),A=I.useRef(null);return I.useEffect(()=>{const M=new ResizeObserver(E=>{_(n||E[0].target.clientWidth||620),T(r||E[0].target.clientHeight||480)});return A.current&&(T(A.current.clientHeight||480),_(A.current.clientWidth||620),n||M.observe(A.current)),()=>M.disconnect()},[n,r]),v.jsx("div",{className:`${b||"light"} flex ${n?"w-fit grow-0":"w-full grow"}`,dir:g==="he"||g==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${f?f===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${g||"en"}`,C==null?void 0:C.graphContainer),style:{...(w==null?void 0:w.graphContainer)||{},...f&&f!==!0?{backgroundColor:f}:{}},id:c,"aria-label":S||`${e?`The graph shows ${e}. `:""}This is a comparison between two maps.${o?` ${o}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:f?s||"1rem":s||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[e||o?v.jsx(Zt,{styles:{title:w==null?void 0:w.title,description:w==null?void 0:w.description},classNames:{title:C==null?void 0:C.title,description:C==null?void 0:C.description},graphTitle:e,graphDescription:o,width:n}):null,v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:A,"aria-label":"map area",children:(n||k)&&(r||D)?v.jsx(Gge,{width:n||k,height:Math.max(y,r||(a?y?(n||k)*a>y?(n||k)*a:y:(n||k)*a:D)),mapStyles:h,center:d,zoomLevel:m}):null}),i||l?v.jsx(tr,{styles:{footnote:w==null?void 0:w.footnote,source:w==null?void 0:w.source},classNames:{footnote:C==null?void 0:C.footnote,source:C==null?void 0:C.source},sources:i,footNote:l,width:n}):null]})})})})}function Xge(t){const{mapStyle:e,height:r,width:n,relativeHeight:a,center:i,zoomLevel:o,minHeight:l,selectedLayer:s,layerIdList:f,excludeLayers:c}=t,[h,d]=I.useState(0),[m,g]=I.useState(0),[y,b]=I.useState(void 0),S=I.useRef(null),w=I.useRef(null),C=I.useRef(null);return I.useEffect(()=>{const k=new ResizeObserver(_=>{d(n||_[0].target.clientWidth||620),g(r||_[0].target.clientHeight||480)});return S.current&&(g(S.current.clientHeight||480),d(S.current.clientWidth||620),n||k.observe(S.current)),()=>k.disconnect()},[n,r]),I.useEffect(()=>{w.current&&h&&!C.current&&ka(e).then(k=>{b(k),Qr(w.current).selectAll("div").remove();const D=new Rf;Pi.addProtocol("pmtiles",D.tile);const T={container:w.current,style:{...k,layers:po(k.layers,[{column:"id",excludeValues:[...c,...f.filter(A=>s.indexOf(A)===-1)]}])}};i&&(T.center=i),o&&(T.zoom=o),C.current=new Pi.Map(T),C.current.addControl(new Pi.NavigationControl({visualizePitch:!0,showZoom:!0,showCompass:!0}),"bottom-right"),C.current.addControl(new Pi.ScaleControl,"bottom-left")})},[h,i,o,f,e,c,s]),I.useEffect(()=>{if(C.current)if(y){const k={...y,layers:po(y.layers,[{column:"id",excludeValues:[...c,...f.filter(_=>s.indexOf(_)===-1)]}])};C.current.setStyle(k)}else ka(e).then(k=>{const _={...k,layers:po(k.layers,[{column:"id",excludeValues:[...c,...f.filter(D=>s.indexOf(D)===-1)]}])};C.current.setStyle(_)})},[c,f,e,y,s]),v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:S,"aria-label":"Map area",children:(n||h)&&(r||m)?v.jsx("div",{style:{width:n||h,height:Math.max(l,r||(a?l?(n||h)*a>l?(n||h)*a:l:(n||h)*a:m))},children:v.jsx("div",{ref:w,className:"map maplibre-show-control w-full h-full"})}):null})}function VH(t){const{mapStyle:e,graphTitle:r,height:n,width:a,relativeHeight:i,sources:o,graphDescription:l,footNote:s,padding:f,backgroundColor:c=!1,center:h,zoomLevel:d,graphID:m,language:g="en",minHeight:y=0,theme:b="light",layerSelection:S,excludeLayers:w=[],ariaLabel:C,uiMode:k="normal",styles:_,classNames:D}=t,[T,A]=I.useState(S[0].layerID);I.useEffect(()=>{A(S[0].layerID)},[S]);const M=I.useMemo(()=>({ignoreCase:!0,ignoreAccents:!0,trim:!0}),[]);return v.jsx("div",{className:`${b||"light"} flex ${a?"w-fit grow-0":"w-full grow"}`,dir:g==="he"||g==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${c?c===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${g||"en"}`,D==null?void 0:D.graphContainer),style:{...(_==null?void 0:_.graphContainer)||{},...c&&c!==!0?{backgroundColor:c}:{}},id:m,"aria-label":C||`${r?`The graph shows ${r}. `:""}This is a map.${l?` ${l}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:c?f||"1rem":f||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||l?v.jsx(Zt,{styles:{title:_==null?void 0:_.title,description:_==null?void 0:_.description},classNames:{title:D==null?void 0:D.title,description:D==null?void 0:D.description},graphTitle:r,graphDescription:l,width:a}):null,v.jsx(s1,{options:S.map(E=>({label:E.name,value:E.layerID})),size:"sm",isClearable:!1,variant:k,isRtl:g==="he"||g==="ar",isSearchable:!0,filterOption:Z1(M),defaultValue:{label:S[0].name,value:S[0].layerID},controlShouldRenderValue:!0,onChange:E=>{E&&A(E.value)}}),v.jsx(Xge,{mapStyle:e,center:h,zoomLevel:d,width:a,height:n,relativeHeight:i,minHeight:y,selectedLayer:T,layerIdList:f1(S.map(E=>E.layerID)),excludeLayers:w}),o||s?v.jsx(tr,{styles:{footnote:_==null?void 0:_.footnote,source:_==null?void 0:_.source},classNames:{footnote:D==null?void 0:D.footnote,source:D==null?void 0:D.source},sources:o,footNote:s,width:a}):null]})})})})}function Kge(t){var ye,be,je,$e,ut,Ie,Ze,Ke,et,Pt,jt,Tt,St,tt,Mt,Dt,Ye,Lt,Et,Xt,He,It,Ge,Rt,$t,dr,xr,Mr,Er;const{data:e,width:r,height:n,showLabels:a,colors:i,colorDomain:o,radius:l,xAxisTitle:s,yAxisTitle:f,leftMargin:c,rightMargin:h,topMargin:d,bottomMargin:m,tooltip:g,onSeriesMouseOver:y,refXValues:b,refYValues:S,highlightAreaSettings:w,selectedColor:C,highlightedDataPoints:k,maxRadiusValue:_,maxXValue:D,minXValue:T,maxYValue:A,minYValue:M,onSeriesMouseClick:E,rtl:N,annotations:Y,customHighlightAreaSettings:ne,regressionLine:K,resetSelectionOnDoubleClick:B,detailsOnClick:j,noOfXTicks:$,noOfYTicks:V,labelColor:z,xSuffix:W,ySuffix:G,xPrefix:ae,yPrefix:U,styles:H,classNames:R}=t,[ee,J]=I.useState(void 0),[Z,re]=I.useState(void 0),[te,F]=I.useState(void 0),[q,X]=I.useState(void 0),ie={top:d,bottom:s?m+50:m,left:f?c+30:c,right:h},ce=e.map((it,Xe)=>({...it,id:`${Xe}`})),de=r-ie.left-ie.right,he=n-ie.top-ie.bottom,Oe=e.filter(it=>it.radius===void 0).length!==e.length?l4().domain([0,Fe(_)?(ye=Vr(e,"radius"))==null?void 0:ye.radius:_]).range([.25,l]).nice():void 0,Ne=ce.filter(it=>!Fe(it.radius)).length===0?ce:a7(ce.filter(it=>!Fe(it.radius)),"radius","desc"),Te=Fe(T)?((be=Br(e,"x"))==null?void 0:be.x)>0?0:(je=Br(e,"x"))==null?void 0:je.x:T,_e=Fe(D)?(($e=Vr(e,"x"))==null?void 0:$e.x)>0?(ut=Vr(e,"x"))==null?void 0:ut.x:0:D,xe=br().domain([Te,_e]).range([0,de]).nice(),we=Fe(M)?((Ie=Br(e,"y"))==null?void 0:Ie.y)>0?0:(Ze=Br(e,"y"))==null?void 0:Ze.y:M,ge=Fe(A)?((Ke=Vr(e,"y"))==null?void 0:Ke.y)>0?(et=Vr(e,"y"))==null?void 0:et.y:0:A,ve=br().domain([we,ge]).range([he,0]).nice(),le=xe.ticks($),ue=ve.ticks(V),Ce=i9.from(Ne.filter(it=>!Fe(it.x)&&!Fe(it.y)),it=>xe(it.x),it=>ve(it.y)).voronoi([0,0,de<0?0:de,he<0?0:he]),pe=Hx(e.filter(it=>!Fe(it.x)&&!Fe(it.y)).map(it=>[xe(it.x),ve(it.y)]));return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${ie.left},${ie.top})`,children:[v.jsx(Az,{areaSettings:w,width:de,height:he,scaleX:xe,scaleY:ve}),v.jsx(Z2,{areaSettings:ne,scaleX:xe,scaleY:ve}),v.jsxs("g",{children:[v.jsx(v1,{values:ue.filter(it=>it!==0),y:ue.filter(it=>it!==0).map(it=>ve(it)),x1:0-c,x2:de+ie.right,styles:{gridLines:(Pt=H==null?void 0:H.yAxis)==null?void 0:Pt.gridLines,labels:(jt=H==null?void 0:H.yAxis)==null?void 0:jt.labels},classNames:{gridLines:(Tt=R==null?void 0:R.yAxis)==null?void 0:Tt.gridLines,labels:(St=R==null?void 0:R.yAxis)==null?void 0:St.labels},suffix:G,prefix:U,labelType:"secondary",showGridLines:!0,labelPos:"side"}),v.jsx(Nr,{y1:ve(we<0?0:we),y2:ve(we<0?0:we),x1:0-c,x2:de+ie.right,label:_t(we<0?0:we,U,G),labelPos:{x:0,y:ve(we<0?0:we),dy:"0.33em",dx:-4},classNames:{axis:(tt=R==null?void 0:R.xAxis)==null?void 0:tt.axis,label:(Mt=R==null?void 0:R.yAxis)==null?void 0:Mt.labels},styles:{axis:(Dt=H==null?void 0:H.xAxis)==null?void 0:Dt.axis,label:{textAnchor:"end",...((Ye=H==null?void 0:H.yAxis)==null?void 0:Ye.labels)||{}}}}),v.jsx(nn,{x:0-c-15,y:he/2,style:(Lt=H==null?void 0:H.yAxis)==null?void 0:Lt.title,className:(Et=R==null?void 0:R.yAxis)==null?void 0:Et.title,text:f,rotate90:!0})]}),v.jsxs("g",{children:[v.jsx(La,{values:le.filter(it=>it!==0),x:le.filter(it=>it!==0).map(it=>xe(it)),y1:0,y2:he,styles:{gridLines:(Xt=H==null?void 0:H.xAxis)==null?void 0:Xt.gridLines,labels:(He=H==null?void 0:H.xAxis)==null?void 0:He.labels},classNames:{gridLines:(It=R==null?void 0:R.xAxis)==null?void 0:It.gridLines,labels:(Ge=R==null?void 0:R.xAxis)==null?void 0:Ge.labels},suffix:W,prefix:ae,labelType:"primary",showGridLines:!0}),v.jsx(Nr,{x1:xe(Te<0?0:Te),x2:xe(Te<0?0:Te),y1:0,y2:he,label:_t(Te<0?0:Te,ae,W),labelPos:{x:xe(Te<0?0:Te),y:he,dy:"1em",dx:0},classNames:{axis:(Rt=R==null?void 0:R.xAxis)==null?void 0:Rt.axis,label:($t=R==null?void 0:R.yAxis)==null?void 0:$t.labels},styles:{axis:(dr=H==null?void 0:H.xAxis)==null?void 0:dr.axis,label:{textAnchor:"middle",...((xr=H==null?void 0:H.yAxis)==null?void 0:xr.labels)||{}}}}),v.jsx(nn,{x:de/2,y:he+30,style:(Mr=H==null?void 0:H.xAxis)==null?void 0:Mr.title,className:(Er=R==null?void 0:R.xAxis)==null?void 0:Er.title,text:s})]}),Ne.filter(it=>!Fe(it.x)&&!Fe(it.y)).map((it,Xe)=>v.jsx("g",{children:v.jsx("path",{d:Ce.renderCell(Ne.findIndex(Vt=>Vt.id===it.id)),opacity:0,onMouseEnter:Vt=>{J(it),X(Vt.clientY),F(Vt.clientX),y&&y(it)},onMouseMove:Vt=>{J(it),X(Vt.clientY),F(Vt.clientX)},onMouseLeave:()=>{J(void 0),F(void 0),X(void 0),y&&y(void 0)},onClick:()=>{(E||j)&&(Sr(Z,it)&&B?(re(void 0),E==null||E(void 0)):(re(it),E==null||E(it)))}})},Xe)),Ne.filter(it=>!Fe(it.x)&&!Fe(it.y)).map((it,Xe)=>v.jsx("g",{children:v.jsxs("g",{opacity:C?it.color&&i[o.indexOf(`${it.color}`)]===C?1:.3:ee?ee.id===it.id?1:.3:k.length!==0?k.indexOf(it.label||"")!==-1?1:.5:1,transform:`translate(${xe(it.x)},${ve(it.y)})`,onMouseEnter:Vt=>{J(it),X(Vt.clientY),F(Vt.clientX),y&&y(it)},onMouseMove:Vt=>{J(it),X(Vt.clientY),F(Vt.clientX)},onMouseLeave:()=>{J(void 0),F(void 0),X(void 0),y&&y(void 0)},onClick:()=>{(E||j)&&(Sr(Z,it)&&B?(re(void 0),E==null||E(void 0)):(re(it),E==null||E(it)))},children:[v.jsx("circle",{cx:0,cy:0,r:Oe?Oe(it.radius||0):l,style:{fill:e.filter(Vt=>Vt.color).length===0?i[0]:it.color?i[o.indexOf(`${it.color}`)]:Qe.gray,stroke:e.filter(Vt=>Vt.color).length===0?i[0]:it.color?i[o.indexOf(`${it.color}`)]:Qe.gray,fillOpacity:.6}}),a&&!Fe(it.label)?v.jsx("text",{style:{fill:z||(e.filter(Vt=>Vt.color).length===0?i[0]:it.color?i[o.indexOf(`${it.color}`)]:Qe.gray),...(H==null?void 0:H.graphObjectValues)||{}},className:Be("graph-value text-sm",R==null?void 0:R.graphObjectValues),y:0,x:Oe?Oe(it.radius||0):l,dy:"0.33em",dx:3,children:it.label}):k.length!==0&&!Fe(it.label)&&k.indexOf(it.label)!==-1?v.jsx("text",{style:{fill:z||(e.filter(Vt=>Vt.color).length===0?i[0]:it.color?i[o.indexOf(`${it.color}`)]:Qe.gray),...(H==null?void 0:H.graphObjectValues)||{}},className:Be("graph-value text-sm",R==null?void 0:R.graphObjectValues),y:0,x:Oe?Oe(it.radius||0):l,dy:"0.33em",dx:3,children:it.label}):null]})},Xe)),b.map((it,Xe)=>v.jsx(ti,{text:it.text,color:it.color,x:xe(it.value),y1:0,y2:he,textSide:xe(it.value)>de*.75||N?"left":"right",classNames:it.classNames,styles:it.styles},Xe)),S.map((it,Xe)=>v.jsx(h1,{text:it.text,color:it.color,y:ve(it.value),x1:0,x2:de,classNames:it.classNames,styles:it.styles},Xe)),v.jsx("g",{children:Y.map((it,Xe)=>{const Vt=K2({x:it.xCoordinate?xe(it.xCoordinate)+(it.xOffset||0):0+(it.xOffset||0),y:it.yCoordinate?ve(it.yCoordinate)+(it.yOffset||0)-8:0+(it.yOffset||0)-8},{x:it.xCoordinate?xe(it.xCoordinate):0,y:it.yCoordinate?ve(it.yCoordinate):0},Fe(it.connectorRadius)?3.5:it.connectorRadius),Yt=it.showConnector?{y1:Vt.y,x1:Vt.x,y2:it.yCoordinate?ve(it.yCoordinate)+(it.yOffset||0):0+(it.yOffset||0),x2:it.xCoordinate?xe(it.xCoordinate)+(it.xOffset||0):0+(it.xOffset||0),cy:it.yCoordinate?ve(it.yCoordinate):0,cx:it.xCoordinate?xe(it.xCoordinate):0,circleRadius:Fe(it.connectorRadius)?3.5:it.connectorRadius,strokeWidth:it.showConnector===!0?2:Math.min(it.showConnector||0,1)}:void 0,at={y:it.yCoordinate?ve(it.yCoordinate)+(it.yOffset||0)-8:0+(it.yOffset||0)-8,x:N?0:it.xCoordinate?xe(it.xCoordinate)+(it.xOffset||0):0+(it.xOffset||0),width:N?it.xCoordinate?xe(it.xCoordinate)+(it.xOffset||0):0+(it.xOffset||0):de-(it.xCoordinate?xe(it.xCoordinate)+(it.xOffset||0):0+(it.xOffset||0)),maxWidth:it.maxWidth,fontWeight:it.fontWeight,align:it.align};return v.jsx(J2,{color:it.color,connectorsSettings:Yt,labelSettings:at,text:it.text,classNames:it.classNames,styles:it.styles},Xe)})}),K?v.jsx(qx,{x1:pe.b>he?(he-pe.b)/pe.m:0,x2:de,y1:pe.b>he?he:pe.b,y2:pe.m*de+pe.b,className:R==null?void 0:R.regLine,style:H==null?void 0:H.regLine,color:typeof K=="string"?K:void 0}):null]})}),ee&&g&&te&&q?v.jsx(yr,{data:ee,body:g,xPos:te,yPos:q,backgroundStyle:H==null?void 0:H.tooltip,className:R==null?void 0:R.tooltip}):null,j?v.jsx(Tr,{open:Z!==void 0,onClose:()=>{re(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(j,Z)}})}):null]})}function FH(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,showLabels:o=!1,height:l,width:s,footNote:f,colorDomain:c,colorLegendTitle:h,radius:d=5,xAxisTitle:m="X Axis",yAxisTitle:g="Y Axis",padding:y,backgroundColor:b=!1,leftMargin:S=0,rightMargin:w=10,topMargin:C=20,bottomMargin:k=50,tooltip:_,relativeHeight:D,onSeriesMouseOver:T,refXValues:A=[],refYValues:M=[],highlightAreaSettings:E=[],showColorScale:N=!0,highlightedDataPoints:Y=[],graphID:ne,maxRadiusValue:K,maxXValue:B,minXValue:j,maxYValue:$,minYValue:V,xSuffix:z="",ySuffix:W="",xPrefix:G="",yPrefix:ae="",onSeriesMouseClick:U,graphDownload:H=!1,dataDownload:R=!1,language:ee="en",showNAColor:J=!0,minHeight:Z=0,annotations:re=[],customHighlightAreaSettings:te=[],theme:F="light",regressionLine:q=!1,ariaLabel:X,resetSelectionOnDoubleClick:ie=!0,detailsOnClick:ce,noOfXTicks:de=5,noOfYTicks:he=5,labelColor:Oe,styles:Ne,classNames:Te}=t,[_e,xe]=I.useState(0),[we,ge]=I.useState(0),[ve,le]=I.useState(void 0),ue=I.useRef(null),Ce=I.useRef(null);return I.useEffect(()=>{const pe=new ResizeObserver(ye=>{xe(s||ye[0].target.clientWidth||620),ge(l||ye[0].target.clientHeight||480)});return ue.current&&(ge(ue.current.clientHeight||480),xe(ue.current.clientWidth||620),s||pe.observe(ue.current)),()=>pe.disconnect()},[s,l]),v.jsx("div",{className:`${F||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:ee==="he"||ee==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${b?b===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${ee||"en"}`,Te==null?void 0:Te.graphContainer),style:{...(Ne==null?void 0:Ne.graphContainer)||{},...b&&b!==!0?{backgroundColor:b}:{}},id:ne,ref:Ce,"aria-label":X||`${r?`The graph shows ${r}. `:""}This is a scatter plot that shows correlation between two variables.${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:b?y||"1rem":y||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||H||R?v.jsx(Zt,{styles:{title:Ne==null?void 0:Ne.title,description:Ne==null?void 0:Ne.description},classNames:{title:Te==null?void 0:Te.title,description:Te==null?void 0:Te.description},graphTitle:r,graphDescription:i,width:s,graphDownload:H?Ce.current:void 0,dataDownload:R?e.map(pe=>pe.data).filter(pe=>pe!==void 0).length>0?e.map(pe=>pe.data).filter(pe=>pe!==void 0):e.filter(pe=>pe!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[N&&e.filter(pe=>pe.color).length!==0?v.jsx(Cn,{width:s,colorLegendTitle:h,colors:n||Qe[F].categoricalColors.colors,colorDomain:c||Bt(e.filter(pe=>pe.color),"color").map(pe=>pe.color),setSelectedColor:le,showNAColor:J}):null,v.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:ue,"aria-label":"Graph area",children:(s||_e)&&(l||we)?v.jsx(Kge,{data:e,width:s||_e,height:Math.max(Z,l||(D?Z?(s||_e)*D>Z?(s||_e)*D:Z:(s||_e)*D:we)),colorDomain:e.filter(pe=>pe.color).length===0?[]:c||Bt(e.filter(pe=>pe.color),"color").map(pe=>pe.color),colors:e.filter(pe=>pe.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[F].categoricalColors.colors,xAxisTitle:m,yAxisTitle:g,refXValues:A,refYValues:M,showLabels:o,radius:d,leftMargin:S,rightMargin:w,topMargin:C,bottomMargin:k,tooltip:_,onSeriesMouseOver:T,highlightAreaSettings:E,highlightedDataPoints:e.filter(pe=>pe.label).length===0?[]:Y,selectedColor:ve,maxRadiusValue:K,maxXValue:B,minXValue:j,maxYValue:$,minYValue:V,onSeriesMouseClick:U,rtl:ee==="he"||ee==="ar",annotations:re,customHighlightAreaSettings:te,regressionLine:q,resetSelectionOnDoubleClick:ie,detailsOnClick:ce,noOfXTicks:de,noOfYTicks:he,labelColor:Oe,xSuffix:z,ySuffix:W,xPrefix:G,yPrefix:ae,styles:Ne,classNames:Te}):null})]})}),a||f?v.jsx(tr,{styles:{footnote:Ne==null?void 0:Ne.footnote,source:Ne==null?void 0:Ne.source},classNames:{footnote:Te==null?void 0:Te.footnote,source:Te==null?void 0:Te.source},sources:a,footNote:f,width:s}):null]})})})})}function Jge(t){var ae,U,H,R,ee,J,Z,re,te,F;const{data:e,width:r,height:n,showLabels:a,colors:i,colorDomain:o,radius:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,tooltip:d,onSeriesMouseOver:m,axisTitles:g,highlightedDataPoints:y,selectedColor:b,minValue:S,maxValue:w,onSeriesMouseClick:C,resetSelectionOnDoubleClick:k,detailsOnClick:_,styles:D,classNames:T}=t,[A,M]=I.useState(void 0),[E,N]=I.useState(void 0),[Y,ne]=I.useState(void 0),[K,B]=I.useState(void 0),j={top:c,bottom:h,left:s,right:f},$=r-j.left-j.right,V=n-j.top-j.bottom,z=Math.min((ae=Br(e,"y1"))==null?void 0:ae.y1,(U=Br(e,"y2"))==null?void 0:U.y2),W=Math.max((H=Vr(e,"y1"))==null?void 0:H.y1,(R=Vr(e,"y2"))==null?void 0:R.y2),G=br().domain([Fe(S)?z>0?0:z:S,Fe(w)?W>0?W:0:w]).range([V,0]).nice();return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,className:"mx-auto",direction:"ltr",children:v.jsxs("g",{transform:`translate(${j.left},${j.top})`,children:[v.jsxs("g",{children:[v.jsx(Nr,{y1:0,y2:V,x1:l,x2:l,classNames:{axis:Be("stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550",(ee=T==null?void 0:T.yAxis)==null?void 0:ee.axis)}}),v.jsx(nn,{x:l,y:V+15,style:(J=D==null?void 0:D.yAxis)==null?void 0:J.title,className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(Z=T==null?void 0:T.yAxis)==null?void 0:Z.title),text:g[0]})]}),v.jsxs("g",{children:[v.jsx(Nr,{y1:0,y2:V,x1:$-l,x2:$-l,classNames:{axis:Be("stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550",(re=T==null?void 0:T.yAxis)==null?void 0:re.axis)}}),v.jsx(nn,{x:$-l,y:V+15,style:(te=D==null?void 0:D.yAxis)==null?void 0:te.title,className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(F=T==null?void 0:T.yAxis)==null?void 0:F.title),text:g[1]})]}),e.map((q,X)=>{var ie,ce,de,he,Oe,Ne,Te,_e;return v.jsxs("g",{opacity:b?q.color&&i[o.indexOf(`${q.color}`)]===b?1:.3:A?A.label===q.label?1:.3:y.length!==0?y.indexOf(q.label)!==-1?1:.5:1,onMouseEnter:xe=>{M(q),B(xe.clientY),ne(xe.clientX),m&&m(q)},onMouseMove:xe=>{M(q),B(xe.clientY),ne(xe.clientX)},onMouseLeave:()=>{M(void 0),ne(void 0),B(void 0),m&&m(void 0)},onClick:()=>{(C||_)&&(Sr(E,q)&&k?(N(void 0),C==null||C(void 0)):(N(q),C==null||C(q)))},children:[v.jsx("circle",{cx:l,cy:G(q.y1),r:l,style:{fill:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,stroke:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,fillOpacity:.6}}),a?v.jsx("text",{style:{fill:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,textAnchor:"end",...((ie=D==null?void 0:D.yAxis)==null?void 0:ie.labels)||{}},className:Be("text-xs",(ce=T==null?void 0:T.yAxis)==null?void 0:ce.labels),y:G(q.y1),x:5,dy:"0.33em",dx:-3,children:q.label}):y.length!==0&&y.indexOf(q.label)!==-1?v.jsx("text",{style:{fill:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,textAnchor:"end",...((de=D==null?void 0:D.yAxis)==null?void 0:de.labels)||{}},className:Be("text-xs",(he=T==null?void 0:T.yAxis)==null?void 0:he.labels),y:G(q.y1),x:5,dy:"0.33em",dx:-3,children:q.label}):null,v.jsx("circle",{cx:$-l,cy:G(q.y2),r:l,style:{fill:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,stroke:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,fillOpacity:.6}}),a?v.jsx("text",{style:{fill:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,textAnchor:"start",...((Oe=D==null?void 0:D.yAxis)==null?void 0:Oe.labels)||{}},className:Be("text-xs",(Ne=T==null?void 0:T.yAxis)==null?void 0:Ne.labels),y:G(q.y2),x:$-5,dy:"0.33em",dx:3,children:q.label}):y.length!==0&&y.indexOf(q.label)!==-1?v.jsx("text",{style:{fill:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,textAnchor:"start",...((Te=D==null?void 0:D.yAxis)==null?void 0:Te.labels)||{}},className:Be("text-xs",(_e=T==null?void 0:T.yAxis)==null?void 0:_e.labels),y:G(q.y2),x:$-5,dy:"0.33em",dx:3,children:q.label}):null,v.jsx("line",{x1:l,x2:$-l,y1:G(q.y1),y2:G(q.y2),className:T==null?void 0:T.dataConnectors,style:{fill:"none",stroke:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,strokeWidth:1,...D==null?void 0:D.dataConnectors}})]},X)})]})}),A&&d&&Y&&K?v.jsx(yr,{data:A,body:d,xPos:Y,yPos:K,backgroundStyle:D==null?void 0:D.tooltip,className:T==null?void 0:T.tooltip}):null,_?v.jsx(Tr,{open:E!==void 0,onClose:()=>{N(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(_,E)}})}):null]})}function zH(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,showLabels:o=!1,height:l,width:s,footNote:f,colorDomain:c,colorLegendTitle:h,radius:d=5,axisTitles:m=["",""],padding:g,backgroundColor:y=!1,leftMargin:b=50,rightMargin:S=50,topMargin:w=20,bottomMargin:C=20,tooltip:k,relativeHeight:_,onSeriesMouseOver:D,showColorScale:T=!0,highlightedDataPoints:A=[],graphID:M,minValue:E,maxValue:N,onSeriesMouseClick:Y,graphDownload:ne=!1,dataDownload:K=!1,fillContainer:B=!0,language:j="en",showNAColor:$=!0,minHeight:V=0,theme:z="light",ariaLabel:W,resetSelectionOnDoubleClick:G=!0,detailsOnClick:ae,styles:U,classNames:H}=t,[R,ee]=I.useState(0),[J,Z]=I.useState(0),[re,te]=I.useState(void 0),F=I.useRef(null),q=I.useRef(null);return I.useEffect(()=>{const X=new ResizeObserver(ie=>{ee(s||ie[0].target.clientWidth||620),Z(l||ie[0].target.clientHeight||480)});return F.current&&(Z(F.current.clientHeight||480),ee(F.current.clientWidth||620),s||X.observe(F.current)),()=>X.disconnect()},[s,l]),v.jsx("div",{className:`${z||"light"} flex ${s?"grow-0":"grow"} ${B?"w-full":"w-fit"} `,dir:j==="he"||j==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${y?y===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${j||"en"}`,H==null?void 0:H.graphContainer),style:{...(U==null?void 0:U.graphContainer)||{},...y&&y!==!0?{backgroundColor:y}:{}},id:M,ref:q,"aria-label":W||`${r?`The graph shows ${r}. `:""}This is a slope chart showing changes in data between two category or starting and ending time. Each line represents a different row in data, with lines sloping up or down to show increase or decrease over two categories or time.${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:y?g||"1rem":g||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||ne||K?v.jsx(Zt,{styles:{title:U==null?void 0:U.title,description:U==null?void 0:U.description},classNames:{title:H==null?void 0:H.title,description:H==null?void 0:H.description},graphTitle:r,graphDescription:i,width:s,graphDownload:ne?q.current:void 0,dataDownload:K?e.map(X=>X.data).filter(X=>X!==void 0).length>0?e.map(X=>X.data).filter(X=>X!==void 0):e.filter(X=>X!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[T&&e.filter(X=>X.color).length!==0?v.jsx(Cn,{width:s,colorLegendTitle:h,colors:n||Qe[z].categoricalColors.colors,colorDomain:c||Bt(e.filter(X=>X.color),"color").map(X=>X.color),setSelectedColor:te,showNAColor:$}):null,v.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:F,"aria-label":"Graph area",children:(s||R)&&(l||J)?v.jsx(Jge,{data:e.filter(X=>!Fe(X.y1)&&!Fe(X.y2)),width:s||R,height:Math.max(V,l||(_?V?(s||R)*_>V?(s||R)*_:V:(s||R)*_:J)),colorDomain:e.filter(X=>X.color).length===0?[]:c||Bt(e.filter(X=>X.color),"color").map(X=>X.color),colors:e.filter(X=>X.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[z].categoricalColors.colors,selectedColor:re,axisTitles:m,showLabels:o,radius:d,leftMargin:b,rightMargin:S,topMargin:w,bottomMargin:C,tooltip:k,onSeriesMouseOver:D,highlightedDataPoints:A,minValue:E,maxValue:N,onSeriesMouseClick:Y,resetSelectionOnDoubleClick:G,detailsOnClick:ae,styles:U,classNames:H}):null})]})}),a||f?v.jsx(tr,{styles:{footnote:U==null?void 0:U.footnote,source:U==null?void 0:U.source},classNames:{footnote:H==null?void 0:H.footnote,source:H==null?void 0:H.source},sources:a,footNote:f,width:s}):null]})})})})}function Zge(t){var ce,de,he,Oe,Ne,Te,_e,xe,we,ge,ve,le,ue,Ce;const{data:e,width:r,height:n,colors:a,dateFormat:i,noOfXTicks:o,rightMargin:l,leftMargin:s,topMargin:f,bottomMargin:c,yAxisTitle:h,tooltip:d,onSeriesMouseOver:m,highlightAreaSettings:g,refValues:y,minValue:b,maxValue:S,rtl:w,annotations:C,customHighlightAreaSettings:k,noOfYTicks:_,prefix:D,suffix:T,curveType:A,styles:M,classNames:E}=t,N=A==="linear"?yo:A==="step"?e2:A==="stepAfter"?r2:A==="stepBefore"?t2:Q0,[Y,ne]=I.useState(void 0),[K,B]=I.useState(void 0),[j,$]=I.useState(void 0),V={top:f,bottom:c,left:h?s+30:s,right:l},z=I.useRef(null),W=Ut(e.map(pe=>({...pe,date:bt(`${pe.date}`,i,new Date)})),"date"),G=g.map(pe=>({...pe,coordinates:[pe.coordinates[0]===null?null:bt(`${pe.coordinates[0]}`,i,new Date),pe.coordinates[1]===null?null:bt(`${pe.coordinates[1]}`,i,new Date)]})),ae=k.map(pe=>({...pe,coordinates:pe.coordinates.map((ye,be)=>be%2===0?bt(`${ye}`,i,new Date):ye)})),U=W[0].y.map((pe,ye)=>W.map(be=>({date:be.date,y0:ye===0?0:fr(be.y.filter((je,$e)=>$e<ye)),y1:fr(be.y.filter((je,$e)=>$e<=ye))}))),H=r-V.left-V.right,R=n-V.top-V.bottom,ee=W[0].date,J=W[W.length-1].date,Z=Fe(b)?0:b,re=Fe(S)?Math.max(...e.map(pe=>fr(pe.y)||0)):S,te=G2().domain([ee,J]).range([0,H]),F=br().domain([Z,re]).range([R,0]).nice(),q=C6().x(pe=>te(pe.date)).y0(pe=>F(pe.y0)).y1(pe=>F(pe.y1)).curve(N),X=F.ticks(_),ie=te.ticks(o);return I.useEffect(()=>{const pe=be=>{const je=W[U2(W.map($e=>$e.date),te.invert(K1(be)[0]),1)];ne(je||W[W.length-1]),m&&m(je||W[W.length-1]),$(be.clientY),B(be.clientX)},ye=()=>{ne(void 0),B(void 0),$(void 0),m&&m(void 0)};Qr(z.current).on("mousemove",pe).on("mouseout",ye)},[te,W,m]),v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${V.left},${V.top})`,children:[v.jsx(h4,{areaSettings:G,width:H,height:R,scale:te}),v.jsx(Z2,{areaSettings:ae,scaleX:te,scaleY:F}),v.jsxs("g",{children:[v.jsx(v1,{values:X.filter(pe=>pe!==0),y:X.filter(pe=>pe!==0).map(pe=>F(pe)),x1:0-s,x2:H+V.right,styles:{gridLines:(ce=M==null?void 0:M.yAxis)==null?void 0:ce.gridLines,labels:(de=M==null?void 0:M.yAxis)==null?void 0:de.labels},classNames:{gridLines:(he=E==null?void 0:E.yAxis)==null?void 0:he.gridLines,labels:(Oe=E==null?void 0:E.yAxis)==null?void 0:Oe.labels},suffix:T,prefix:D,labelType:"secondary",showGridLines:!0,labelPos:"vertical"}),v.jsx(Nr,{y1:F(Z<0?0:Z),y2:F(Z<0?0:Z),x1:0-s,x2:H+V.right,label:_t(Z<0?0:Z,D,T),labelPos:{x:0-s,dx:0,dy:re<0?"1em":-5,y:F(Z<0?0:Z)},classNames:{axis:(Ne=E==null?void 0:E.xAxis)==null?void 0:Ne.axis,label:(Te=E==null?void 0:E.yAxis)==null?void 0:Te.labels},styles:{axis:(_e=M==null?void 0:M.xAxis)==null?void 0:_e.axis,label:(xe=M==null?void 0:M.yAxis)==null?void 0:xe.labels}}),v.jsx(nn,{x:0-s-15,y:R/2,style:(we=M==null?void 0:M.yAxis)==null?void 0:we.title,className:(ge=E==null?void 0:E.yAxis)==null?void 0:ge.title,text:h,rotate90:!0})]}),v.jsx(La,{values:ie.map(pe=>Sa(pe,i)),x:ie.map(pe=>te(pe)),y1:0,y2:R,styles:{gridLines:(ve=M==null?void 0:M.xAxis)==null?void 0:ve.gridLines,labels:(le=M==null?void 0:M.xAxis)==null?void 0:le.labels},classNames:{gridLines:Be("opacity-0",(ue=E==null?void 0:E.xAxis)==null?void 0:ue.gridLines),labels:Be("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[8px] sm:text-[9px] md:text-[10px] lg:text-xs",(Ce=E==null?void 0:E.xAxis)==null?void 0:Ce.labels)},suffix:T,prefix:D,labelType:"primary",showGridLines:!0}),v.jsxs("g",{children:[U.map((pe,ye)=>v.jsx("path",{d:q(pe),style:{fill:a[ye],opacity:.8}},ye)),Y?v.jsx("line",{y1:0,y2:R,x1:te(Y.date),x2:te(Y.date),className:Be("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",E==null?void 0:E.mouseOverLine),style:M==null?void 0:M.mouseOverLine}):null]}),y?v.jsx(v.Fragment,{children:y.map((pe,ye)=>v.jsx(h1,{text:pe.text,color:pe.color,y:F(pe.value),x1:0-s,x2:H+V.right,classNames:pe.classNames,styles:pe.styles},ye))}):null,v.jsx("g",{children:C.map((pe,ye)=>{const be=K2({x:pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date))+(pe.xOffset||0):0+(pe.xOffset||0),y:pe.yCoordinate?F(pe.yCoordinate)+(pe.yOffset||0)-8:0+(pe.yOffset||0)-8},{x:pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date)):0,y:pe.yCoordinate?F(pe.yCoordinate):0},Fe(pe.connectorRadius)?3.5:pe.connectorRadius),je=pe.showConnector?{y1:be.y,x1:be.x,y2:pe.yCoordinate?F(pe.yCoordinate)+(pe.yOffset||0):0+(pe.yOffset||0),x2:pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date))+(pe.xOffset||0):0+(pe.xOffset||0),cx:pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date)):0,cy:pe.yCoordinate?F(pe.yCoordinate):0,circleRadius:Fe(pe.connectorRadius)?3.5:pe.connectorRadius,strokeWidth:pe.showConnector===!0?2:Math.min(pe.showConnector||0,1)}:void 0,$e={y:pe.yCoordinate?F(pe.yCoordinate)+(pe.yOffset||0)-8:0+(pe.yOffset||0)-8,x:w?0:pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date))+(pe.xOffset||0):0+(pe.xOffset||0),width:w?pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date))+(pe.xOffset||0):0+(pe.xOffset||0):H-(pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date))+(pe.xOffset||0):0+(pe.xOffset||0)),maxWidth:pe.maxWidth,fontWeight:pe.fontWeight,align:pe.align};return v.jsx(J2,{color:pe.color,connectorsSettings:je,labelSettings:$e,text:pe.text,classNames:pe.classNames,styles:pe.styles},ye)})}),v.jsx("rect",{ref:z,style:{fill:"none",pointerEvents:"all"},width:H,height:R})]})}),Y&&d&&K&&j?v.jsx(yr,{data:Y,body:d,xPos:K,yPos:j,backgroundStyle:M==null?void 0:M.tooltip,className:E==null?void 0:E.tooltip}):null]})}function HH(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,sources:a,graphDescription:i,height:o,width:l,footNote:s,noOfXTicks:f=10,dateFormat:c="yyyy",colorDomain:h,padding:d,backgroundColor:m=!1,colorLegendTitle:g,leftMargin:y=50,rightMargin:b=20,topMargin:S=20,bottomMargin:w=25,highlightAreaSettings:C=[],tooltip:k,relativeHeight:_,onSeriesMouseOver:D,refValues:T=[],graphID:A,minValue:M,maxValue:E,graphDownload:N=!1,dataDownload:Y=!1,showColorScale:ne=!0,language:K="en",minHeight:B=0,annotations:j=[],customHighlightAreaSettings:$=[],theme:V="light",ariaLabel:z,yAxisTitle:W,noOfYTicks:G=5,prefix:ae="",suffix:U="",curveType:H="curve",styles:R,classNames:ee}=t,[J,Z]=I.useState(0),[re,te]=I.useState(0),F=I.useRef(null),q=I.useRef(null);return I.useEffect(()=>{const X=new ResizeObserver(ie=>{Z(l||ie[0].target.clientWidth||620),te(o||ie[0].target.clientHeight||480)});return F.current&&(te(F.current.clientHeight||480),Z(F.current.clientWidth||620),l||X.observe(F.current)),()=>X.disconnect()},[l,o]),v.jsx("div",{className:`${V||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:K==="he"||K==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${m?m===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${K||"en"}`,ee==null?void 0:ee.graphContainer),style:{...(R==null?void 0:R.graphContainer)||{},...m&&m!==!0?{backgroundColor:m}:{}},id:A,ref:q,"aria-label":z||`${r?`The graph shows ${r}. `:""}This is a stacked area chart that shows trends over time.${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:m?d||"1rem":d||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||N||Y?v.jsx(Zt,{styles:{title:R==null?void 0:R.title,description:R==null?void 0:R.description},classNames:{title:ee==null?void 0:ee.title,description:ee==null?void 0:ee.description},graphTitle:r,graphDescription:i,width:l,graphDownload:N?q.current:void 0,dataDownload:Y?e.map(X=>X.data).filter(X=>X!==void 0).length>0?e.map(X=>X.data).filter(X=>X!==void 0):e.filter(X=>X!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[ne!==!1?v.jsx(g0,{colorDomain:h,colors:n,colorLegendTitle:g,showNAColor:!1}):null,v.jsx("div",{className:"w-full grow leading-0",ref:F,"aria-label":"Graph area",children:(l||J)&&(o||re)?v.jsx(Zge,{data:e,colors:n,width:l||J,height:Math.max(B,o||(_?B?(l||J)*_>B?(l||J)*_:B:(l||J)*_:re)),dateFormat:c,noOfXTicks:f,leftMargin:y,rightMargin:b,topMargin:S,bottomMargin:w,tooltip:k,onSeriesMouseOver:D,highlightAreaSettings:C,refValues:T,minValue:M,maxValue:E,rtl:K==="he"||K==="ar",annotations:j,customHighlightAreaSettings:$,yAxisTitle:W,noOfYTicks:G,prefix:ae,suffix:U,curveType:H,styles:R,classNames:ee}):null})]})}),a||s?v.jsx(tr,{styles:{footnote:R==null?void 0:R.footnote,source:R==null?void 0:R.source},classNames:{footnote:ee==null?void 0:ee.footnote,source:ee==null?void 0:ee.source},sources:a,footNote:s,width:l}):null]})})})})}function Qge(t){const{year:e,value:r,graphTitle:n,suffix:a="",sources:i,prefix:o="",graphDescription:l,footNote:s,padding:f,backgroundColor:c=!1,graphID:h,language:d="en",theme:m="light",ariaLabel:g,textBackground:y=!1,headingFontSize:b="4.375rem",centerAlign:S=!1,verticalAlign:w="center",styles:C,classNames:k}=t;return v.jsx("div",{className:`${m||"light"} flex w-full`,dir:d==="he"||d==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${c?c===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}flex flex-col w-full h-inherit ${d||"en"}`,k==null?void 0:k.graphContainer),style:{...(C==null?void 0:C.graphContainer)||{},...c&&c!==!0?{backgroundColor:c}:{}},id:h,"aria-label":g||`${n?`The graph shows ${n}. `:""}This is a statistic card.${l?` ${l}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:c?f||"1rem":f||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-12 justify-between grow",children:[n||l?v.jsx(Zt,{styles:{title:C==null?void 0:C.title,description:C==null?void 0:C.description},classNames:{title:k==null?void 0:k.title,description:k==null?void 0:k.description},graphTitle:n,graphDescription:l}):null,v.jsx("div",{className:`flex flex-col justify-between grow ${w==="top"?"justify-start":w==="bottom"?"justify-end":"justify-center"}`,children:v.jsxs(rP,{marginBottom:"base",className:`leading-none text-outline font-heading ${S?"text-center":d==="he"||d==="ar"?"text-right":"text-left"} ${y?"text-primary-black dark:text-primary-white":"transparent"}`,style:{fontSize:b,letterSpacing:"0.05rem"},children:[typeof r=="string"?`${o}${r}${a}`:_t(r,o,a)," ",e?v.jsxs("span",{className:"text-lg font-normal mt-0 mb-4 text-primary-gray-550 dark:text-primary-gray-400",style:{marginLeft:"-8px",lineHeight:"1.09",textShadow:"none",WebkitTextStrokeWidth:0},children:["(",e,")"]}):null]})}),i||s?v.jsx(tr,{styles:{footnote:C==null?void 0:C.footnote,source:C==null?void 0:C.source},classNames:{footnote:k==null?void 0:k.footnote,source:k==null?void 0:k.source},sources:i,footNote:s}):null]})})})})}function qH(t){var T,A;const{year:e,data:r,graphTitle:n,suffix:a="",sources:i,prefix:o="",graphDescription:l,footNote:s,padding:f,backgroundColor:c=!1,graphID:h,aggregationMethod:d="count",language:m="en",countOnly:g,theme:y="light",ariaLabel:b,textBackground:S=!1,headingFontSize:w="4.375rem",centerAlign:C=!1,verticalAlign:k="center",styles:_,classNames:D}=t;return v.jsx("div",{className:`${y||"light"} flex w-full`,dir:m==="he"||m==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${c?c===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}flex flex-col w-full h-inherit ${m||"en"}`,D==null?void 0:D.graphContainer),style:{...(_==null?void 0:_.graphContainer)||{},...c&&c!==!0?{backgroundColor:c}:{}},id:h,"aria-label":b||`${n?`The graph shows ${n}. `:""}This is a statistic card.${l?` ${l}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:c?f||"1rem":f||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-12 justify-between grow",children:[n||l?v.jsx(Zt,{styles:{title:_==null?void 0:_.title,description:_==null?void 0:_.description},classNames:{title:D==null?void 0:D.title,description:D==null?void 0:D.description},graphTitle:n,graphDescription:l}):null,v.jsx("div",{className:`flex flex-col justify-between grow ${k==="top"?"justify-start":k==="bottom"?"justify-end":"justify-center"}`,children:v.jsxs(rP,{marginBottom:"base",className:`leading-none text-outline font-heading ${C?"text-center":m==="he"||m==="ar"?"text-right":"text-left"} ${S?"text-primary-black dark:text-primary-white":"transparent"}`,style:{fontSize:w,letterSpacing:"0.05rem"},children:[r.filter(M=>typeof M.value=="string").length>0||d==="count"?g&&(g==null?void 0:g.length)!==0?r.filter(M=>g.indexOf(M.value)!==-1).length:r.length:_t(d==="sum"?fr(r.map(M=>M.value)):d==="average"?parseFloat((fr(r.map(M=>M.value))/r.length).toFixed(2)):d==="max"?(T=Vr(r,M=>M.value))==null?void 0:T.value:(A=Br(r,M=>M.value))==null?void 0:A.value,o,a)," ",e?v.jsxs("span",{className:"text-lg font-normal mt-0 mb-4 text-primary-gray-550 dark:text-primary-gray-400",style:{marginLeft:"-8px",lineHeight:"1.09",textShadow:"none",WebkitTextStrokeWidth:0},children:["(",e,")"]}):null]})}),i||s?v.jsx(tr,{styles:{footnote:_==null?void 0:_.footnote,source:_==null?void 0:_.source},classNames:{footnote:D==null?void 0:D.footnote,source:D==null?void 0:D.source},sources:i,footNote:s}):null]})})})})}function eye(t){var e=0,r=t.children,n=r&&r.length;if(!n)e=1;else for(;--n>=0;)e+=r[n].value;t.value=e}function tye(){return this.eachAfter(eye)}function rye(t,e){let r=-1;for(const n of this)t.call(e,n,++r,this);return this}function nye(t,e){for(var r=this,n=[r],a,i,o=-1;r=n.pop();)if(t.call(e,r,++o,this),a=r.children)for(i=a.length-1;i>=0;--i)n.push(a[i]);return this}function aye(t,e){for(var r=this,n=[r],a=[],i,o,l,s=-1;r=n.pop();)if(a.push(r),i=r.children)for(o=0,l=i.length;o<l;++o)n.push(i[o]);for(;r=a.pop();)t.call(e,r,++s,this);return this}function iye(t,e){let r=-1;for(const n of this)if(t.call(e,n,++r,this))return n}function oye(t){return this.eachAfter(function(e){for(var r=+t(e.data)||0,n=e.children,a=n&&n.length;--a>=0;)r+=n[a].value;e.value=r})}function lye(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})}function sye(t){for(var e=this,r=uye(e,t),n=[e];e!==r;)e=e.parent,n.push(e);for(var a=n.length;t!==r;)n.splice(a,0,t),t=t.parent;return n}function uye(t,e){if(t===e)return t;var r=t.ancestors(),n=e.ancestors(),a=null;for(t=r.pop(),e=n.pop();t===e;)a=t,t=r.pop(),e=n.pop();return a}function cye(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e}function fye(){return Array.from(this)}function dye(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t}function hye(){var t=this,e=[];return t.each(function(r){r!==t&&e.push({source:r.parent,target:r})}),e}function*pye(){var t=this,e,r=[t],n,a,i;do for(e=r.reverse(),r=[];t=e.pop();)if(yield t,n=t.children)for(a=0,i=n.length;a<i;++a)r.push(n[a]);while(r.length)}function WH(t,e){t instanceof Map?(t=[void 0,t],e===void 0&&(e=yye)):e===void 0&&(e=gye);for(var r=new Ns(t),n,a=[r],i,o,l,s;n=a.pop();)if((o=e(n.data))&&(s=(o=Array.from(o)).length))for(n.children=o,l=s-1;l>=0;--l)a.push(i=o[l]=new Ns(o[l])),i.parent=n,i.depth=n.depth+1;return r.eachBefore(UH)}function mye(){return WH(this).eachBefore(vye)}function gye(t){return t.children}function yye(t){return Array.isArray(t)?t[1]:null}function vye(t){t.data.value!==void 0&&(t.value=t.data.value),t.data=t.data.data}function UH(t){var e=0;do t.height=e;while((t=t.parent)&&t.height<++e)}function Ns(t){this.data=t,this.depth=this.height=0,this.parent=null}Ns.prototype=WH.prototype={constructor:Ns,count:tye,each:rye,eachAfter:aye,eachBefore:nye,find:iye,sum:oye,sort:lye,path:sye,ancestors:cye,descendants:fye,leaves:dye,links:hye,copy:mye,[Symbol.iterator]:pye};function Cm(t){return t==null?null:GH(t)}function GH(t){if(typeof t!="function")throw new Error;return t}function Dl(){return 0}function Al(t){return function(){return t}}function bye(t){t.x0=Math.round(t.x0),t.y0=Math.round(t.y0),t.x1=Math.round(t.x1),t.y1=Math.round(t.y1)}function xye(t,e,r,n,a){for(var i=t.children,o,l=-1,s=i.length,f=t.value&&(n-e)/t.value;++l<s;)o=i[l],o.y0=r,o.y1=a,o.x0=e,o.x1=e+=o.value*f}var wye={depth:-1},BM={},km={};function Sye(t){return t.id}function Cye(t){return t.parentId}function kye(){var t=Sye,e=Cye,r;function n(a){var i=Array.from(a),o=t,l=e,s,f,c,h,d,m,g,y,b=new Map;if(r!=null){const S=i.map((k,_)=>_ye(r(k,_,a))),w=S.map(VM),C=new Set(S).add("");for(const k of w)C.has(k)||(C.add(k),S.push(k),w.push(VM(k)),i.push(km));o=(k,_)=>S[_],l=(k,_)=>w[_]}for(c=0,s=i.length;c<s;++c)f=i[c],m=i[c]=new Ns(f),(g=o(f,c,a))!=null&&(g+="")&&(y=m.id=g,b.set(y,b.has(y)?BM:m)),(g=l(f,c,a))!=null&&(g+="")&&(m.parent=g);for(c=0;c<s;++c)if(m=i[c],g=m.parent){if(d=b.get(g),!d)throw new Error("missing: "+g);if(d===BM)throw new Error("ambiguous: "+g);d.children?d.children.push(m):d.children=[m],m.parent=d}else{if(h)throw new Error("multiple roots");h=m}if(!h)throw new Error("no root");if(r!=null){for(;h.data===km&&h.children.length===1;)h=h.children[0],--s;for(let S=i.length-1;S>=0&&(m=i[S],m.data===km);--S)m.data=null}if(h.parent=wye,h.eachBefore(function(S){S.depth=S.parent.depth+1,--s}).eachBefore(UH),h.parent=null,s>0)throw new Error("cycle");return h}return n.id=function(a){return arguments.length?(t=Cm(a),n):t},n.parentId=function(a){return arguments.length?(e=Cm(a),n):e},n.path=function(a){return arguments.length?(r=Cm(a),n):r},n}function _ye(t){t=`${t}`;let e=t.length;return tv(t,e-1)&&!tv(t,e-2)&&(t=t.slice(0,-1)),t[0]==="/"?t:`/${t}`}function VM(t){let e=t.length;if(e<2)return"";for(;--e>1&&!tv(t,e););return t.slice(0,e)}function tv(t,e){if(t[e]==="/"){let r=0;for(;e>0&&t[--e]==="\\";)++r;if((r&1)===0)return!0}return!1}function Oye(t,e,r,n,a){for(var i=t.children,o,l=-1,s=i.length,f=t.value&&(a-r)/t.value;++l<s;)o=i[l],o.x0=e,o.x1=n,o.y0=r,o.y1=r+=o.value*f}var Dye=(1+Math.sqrt(5))/2;function Aye(t,e,r,n,a,i){for(var o=[],l=e.children,s,f,c=0,h=0,d=l.length,m,g,y=e.value,b,S,w,C,k,_,D;c<d;){m=a-r,g=i-n;do b=l[h++].value;while(!b&&h<d);for(S=w=b,_=Math.max(g/m,m/g)/(y*t),D=b*b*_,k=Math.max(w/D,D/S);h<d;++h){if(b+=f=l[h].value,f<S&&(S=f),f>w&&(w=f),D=b*b*_,C=Math.max(w/D,D/S),C>k){b-=f;break}k=C}o.push(s={value:b,dice:m<g,children:l.slice(c,h)}),s.dice?xye(s,r,n,a,y?n+=g*b/y:i):Oye(s,r,n,y?r+=m*b/y:a,i),y-=b,c=h}return o}const Tye=function t(e){function r(n,a,i,o,l){Aye(e,n,a,i,o,l)}return r.ratio=function(n){return t((n=+n)>1?n:1)},r}(Dye);function Mye(){var t=Tye,e=!1,r=1,n=1,a=[0],i=Dl,o=Dl,l=Dl,s=Dl,f=Dl;function c(d){return d.x0=d.y0=0,d.x1=r,d.y1=n,d.eachBefore(h),a=[0],e&&d.eachBefore(bye),d}function h(d){var m=a[d.depth],g=d.x0+m,y=d.y0+m,b=d.x1-m,S=d.y1-m;b<g&&(g=b=(g+b)/2),S<y&&(y=S=(y+S)/2),d.x0=g,d.y0=y,d.x1=b,d.y1=S,d.children&&(m=a[d.depth+1]=i(d)/2,g+=f(d)-m,y+=o(d)-m,b-=l(d)-m,S-=s(d)-m,b<g&&(g=b=(g+b)/2),S<y&&(y=S=(y+S)/2),t(d,g,y,b,S))}return c.round=function(d){return arguments.length?(e=!!d,c):e},c.size=function(d){return arguments.length?(r=+d[0],n=+d[1],c):[r,n]},c.tile=function(d){return arguments.length?(t=GH(d),c):t},c.padding=function(d){return arguments.length?c.paddingInner(d).paddingOuter(d):c.paddingInner()},c.paddingInner=function(d){return arguments.length?(i=typeof d=="function"?d:Al(+d),c):i},c.paddingOuter=function(d){return arguments.length?c.paddingTop(d).paddingRight(d).paddingBottom(d).paddingLeft(d):c.paddingTop()},c.paddingTop=function(d){return arguments.length?(o=typeof d=="function"?d:Al(+d),c):o},c.paddingRight=function(d){return arguments.length?(l=typeof d=="function"?d:Al(+d),c):l},c.paddingBottom=function(d){return arguments.length?(s=typeof d=="function"?d:Al(+d),c):s},c.paddingLeft=function(d){return arguments.length?(f=typeof d=="function"?d:Al(+d),c):f},c}function Eye(t){var ae;const{data:e,colors:r,leftMargin:n,width:a,height:i,colorDomain:o,rightMargin:l,topMargin:s,bottomMargin:f,showLabels:c,tooltip:h,onSeriesMouseOver:d,selectedColor:m,showValues:g,suffix:y,prefix:b,highlightedDataPoints:S,onSeriesMouseClick:w,resetSelectionOnDoubleClick:C,detailsOnClick:k,language:_,styles:D,classNames:T}=t,[A,M]=I.useState(void 0),[E,N]=I.useState(void 0),[Y,ne]=I.useState(void 0),[K,B]=I.useState(void 0),j={top:s,bottom:f,left:n,right:l},$=a-j.left-j.right,V=i-j.top-j.bottom,z=[{id:"root",parent:void 0,value:void 0,data:void 0},...e.map(U=>({id:U.label,value:U.size,parent:"root",data:U}))],W=kye().id(U=>U.id).parentId(U=>U.parent)(z);W.sum(U=>U.value);const G=Mye().size([$,V]).padding(2)(W);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${a}px`,height:`${i}px`,viewBox:`0 0 ${a} ${i}`,direction:"ltr",children:v.jsx("g",{transform:`translate(${j.left},${j.top})`,children:(ae=G.children)==null?void 0:ae.map((U,H)=>v.jsxs("g",{className:"undp-viz-g-with-hover",opacity:m?U.data.data.color&&r[o.indexOf(U.data.data.color)]===m?1:.3:S.length!==0?S.indexOf(U.data.id)!==-1?.85:.3:.85,transform:`translate(${U.x0},${U.y0})`,onMouseEnter:R=>{M(U.data.data),B(R.clientY),ne(R.clientX),d==null||d(U.data.data)},onClick:()=>{(w||k)&&(E===U.data.id&&C?(N(void 0),w==null||w(void 0)):(N(U.data.id),w==null||w(U.data.data)))},onMouseMove:R=>{M(U.data.data),B(R.clientY),ne(R.clientX)},onMouseLeave:()=>{M(void 0),ne(void 0),B(void 0),d&&d(void 0)},children:[v.jsx("rect",{x:0,y:0,width:U.x1-U.x0,height:U.y1-U.y0,style:{fill:e.filter(R=>R.color).length===0?r[0]:U.data.data.color?r[o.indexOf(U.data.data.color)]:Qe.gray}},H),U.x1-U.x0>50&&U.y1-U.y0>25&&(c||g)?v.jsx("foreignObject",{y:0,x:0,width:U.x1-U.x0,height:U.y1-U.y0,children:v.jsxs("div",{className:"flex flex-col gap-0.5 p-2 w-full",style:{color:Bi(e.filter(R=>R.color).length===0?r[0]:U.data.data.color?r[o.indexOf(U.data.data.color)]:Qe.gray)},children:[c?v.jsx(or,{marginBottom:"none",size:"sm",leading:"none",className:Be("w-full treemap-label",_==="ar"||_==="he"?"text-right":"text-left",T==null?void 0:T.graphObjectValues),style:{WebkitLineClamp:U.y1-U.y0>50?U.y1-U.y0>100?U.y1-U.y0>150?void 0:3:2:1,display:"-webkit-box",WebkitBoxOrient:"vertical",overflow:"hidden",color:Bi(e.filter(R=>R.color).length===0?r[0]:U.data.data.color?r[o.indexOf(U.data.data.color)]:Qe.gray),...(D==null?void 0:D.graphObjectValues)||{}},children:U.data.id}):null,g?v.jsx(or,{marginBottom:"none",size:"sm",leading:"none",className:Be("w-full font-bold treemap-value",_==="ar"||_==="he"?"text-right":"text-left",T==null?void 0:T.graphObjectValues),style:{color:Bi(e.filter(R=>R.color).length===0?r[0]:U.data.data.color?r[o.indexOf(U.data.data.color)]:Qe.gray),...(D==null?void 0:D.graphObjectValues)||{}},children:_t(U.data.value,b,y)}):null]})}):null]},H))})}),A&&h&&Y&&K?v.jsx(yr,{data:A,body:h,xPos:Y,yPos:K,backgroundStyle:D==null?void 0:D.tooltip,className:T==null?void 0:T.tooltip}):null,k?v.jsx(Tr,{open:E!==void 0,onClose:()=>{N(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(k,E)}})}):null]})}function mw(t){const{data:e,graphTitle:r,colors:n,suffix:a="",sources:i,prefix:o="",graphDescription:l,leftMargin:s=0,rightMargin:f=0,topMargin:c=0,bottomMargin:h=0,height:d,width:m,footNote:g,colorDomain:y,colorLegendTitle:b,padding:S,backgroundColor:w=!1,showLabels:C=!0,relativeHeight:k,tooltip:_,onSeriesMouseOver:D,showColorScale:T=!0,showValues:A=!0,graphID:M,highlightedDataPoints:E=[],onSeriesMouseClick:N,graphDownload:Y=!1,dataDownload:ne=!1,language:K="en",showNAColor:B=!0,minHeight:j=0,theme:$="light",ariaLabel:V,resetSelectionOnDoubleClick:z=!0,detailsOnClick:W,styles:G,classNames:ae}=t,[U,H]=I.useState(0),[R,ee]=I.useState(0),[J,Z]=I.useState(void 0),re=I.useRef(null),te=I.useRef(null);return I.useEffect(()=>{const F=new ResizeObserver(q=>{H(m||q[0].target.clientWidth||620),ee(d||q[0].target.clientHeight||480)});return re.current&&(ee(re.current.clientHeight||480),H(re.current.clientWidth||620),m||F.observe(re.current)),()=>F.disconnect()},[m,d]),v.jsx("div",{className:`${$||"light"} flex ${m?"w-fit grow-0":"w-full grow"}`,dir:K==="he"||K==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${w?w===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${K||"en"}`,ae==null?void 0:ae.graphContainer),style:{...(G==null?void 0:G.graphContainer)||{},...w&&w!==!0?{backgroundColor:w}:{}},id:M,ref:te,"aria-label":V||`${r?`The graph shows ${r}. `:""}This is a chart where data points are represented by squares, and their sizes reflect their values. ${l?` ${l}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:w?S||"1rem":S||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||l||Y||ne?v.jsx(Zt,{styles:{title:G==null?void 0:G.title,description:G==null?void 0:G.description},classNames:{title:ae==null?void 0:ae.title,description:ae==null?void 0:ae.description},graphTitle:r,graphDescription:l,width:m,graphDownload:Y?te.current:void 0,dataDownload:ne?e.map(F=>F.data).filter(F=>F!==void 0).length>0?e.map(F=>F.data).filter(F=>F!==void 0):e.filter(F=>F!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[T&&e.filter(F=>F.color).length!==0?v.jsx(Cn,{width:m,colorLegendTitle:b,colors:n||Qe[$].categoricalColors.colors,colorDomain:y||Bt(e.filter(F=>F.color),"color").map(F=>F.color),setSelectedColor:Z,showNAColor:B}):null,v.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:re,"aria-label":"Graph area",children:(m||U)&&(d||R)?v.jsx(Eye,{data:e.filter(F=>!Fe(F.size)),colors:e.filter(F=>F.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[$].categoricalColors.colors,colorDomain:e.filter(F=>F.color).length===0?[]:y||Bt(e.filter(F=>F.color),"color").map(F=>F.color),width:m||U,height:Math.max(j,d||(k?j?(m||U)*k>j?(m||U)*k:j:(m||U)*k:R)),leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,showLabels:C,showValues:A,suffix:a,prefix:o,selectedColor:J,tooltip:_,onSeriesMouseOver:D,onSeriesMouseClick:N,highlightedDataPoints:E,resetSelectionOnDoubleClick:z,detailsOnClick:W,styles:G,classNames:ae,language:K}):null})]})}),i||g?v.jsx(tr,{styles:{footnote:G==null?void 0:G.footnote,source:G==null?void 0:G.source},classNames:{footnote:ae==null?void 0:ae.footnote,source:ae==null?void 0:ae.source},sources:i,footNote:g,width:m}):null]})})})})}function YH(t){const{data:e,size:r=200,graphTitle:n,sources:a,colors:i=Qe.light.categoricalColors.colors,graphDescription:o,totalNoOfDots:l=100,unitPadding:s=3,gridSize:f=10,footNote:c,padding:h,backgroundColor:d=!1,graphID:m,graphDownload:g=!1,language:y="en",showColorScale:b=!0,showStrokeForWhiteDots:S=!0,note:w,dataDownload:C=!1,theme:k="light",width:_,height:D,minHeight:T=0,relativeHeight:A,ariaLabel:M,styles:E,classNames:N}=t,Y=fr(e.map($=>$.value)),ne=I.useRef(null),K=r/f,B=(K-s*2)/2;if(B<=0)return console.error("The size of single unit is less than or equal to zero. Check values for ((dimension / gridSize) - (padding * 2)) / 2 is not less than or equal to 0."),null;const j=[];return e.forEach(($,V)=>{const z=Math.round($.value/Y*l);for(let W=0;W<z;W+=1)j.push({color:i[V]})}),v.jsx("div",{className:`${k||"light"} flex ${_?"w-fit grow-0":"w-full grow"}`,dir:y==="he"||y==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${d?d===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${y||"en"}`,N==null?void 0:N.graphContainer),style:{...(E==null?void 0:E.graphContainer)||{},minHeight:"inherit",...d&&d!==!0?{backgroundColor:d}:{}},id:m,ref:ne,"aria-label":M||`${n?`The graph shows ${n}. `:""}${o?` ${o}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:d?h||"1rem":h||0},children:v.jsxs("div",{className:"flex flex-col gap-3 w-full grow",children:[n||o||g?v.jsx(Zt,{styles:{title:E==null?void 0:E.title,description:E==null?void 0:E.description},classNames:{title:N==null?void 0:N.title,description:N==null?void 0:N.description},graphTitle:n,graphDescription:o,width:_,graphDownload:g?ne.current:void 0,dataDownload:C?e.map($=>$.data).filter($=>$!==void 0).length>0?e.map($=>$.data).filter($=>$!==void 0):e.filter($=>$!==void 0):null}):null,w?v.jsx(tP,{marginBottom:"2xs",className:"text-primary-gray-700 dark:text-primary-gray-100 font-bold",style:{width:_?`${_}px`:"100%"},children:w}):null,v.jsxs("div",{className:"flex grow flex-col gap-4 justify-between",children:[v.jsxs("div",{children:[b?v.jsx("div",{className:"mb-4 leading-0",style:{width:_?`${_}px`:"100%"},"aria-label":"Color legend",children:v.jsx("div",{className:"flex mb-0 flex-wrap gap-x-1 gap-y-4",children:e.map(($,V)=>v.jsxs("div",{className:"flex gap-2 items-center",children:[v.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:i[V]}}),v.jsxs(or,{marginBottom:"none",size:"sm",className:"text-primary-gray-700 dark:text-primary-gray-100",children:[$.label,":"," ",v.jsx("span",{className:"font-bold",children:_t($.value)})]})]},V))})}):null,v.jsx("div",{"aria-label":"Graph area",children:v.jsx("svg",{width:`${_||r}px`,height:`${Math.max(T,D?A&&_?T?_*A>T?_*A:T:_*A:D:Math.floor((l-1)/f)*K+K/2+B+5)}px`,direction:"ltr",viewBox:`0 0 ${_||r} ${Math.max(T,D?A&&_?T?_*A>T?_*A:T:_*A:D:Math.floor((l-1)/f)*K+K/2+B+5)}`,children:v.jsx("g",{children:j.map(($,V)=>v.jsx("circle",{cx:V%f*K+K/2,cy:Math.floor(V/f)*K+K/2,style:{fill:$.color,...S?{}:{stroke:$.color},strokeWidth:1},className:($.color.toLowerCase()==="#fff"||$.color.toLowerCase()==="#ffffff"||$.color.toLowerCase()==="white")&&S?"stroke-primary-gray-400 dark:stroke-primary-gray-500":"",r:B},V))})})})]}),a||c?v.jsx(tr,{styles:{footnote:E==null?void 0:E.footnote,source:E==null?void 0:E.source},sources:a,footNote:c,width:_}):null]})]})})})})}function jye(t){const{data:e,showColumnLabels:r,leftMargin:n,rightMargin:a,truncateBy:i,width:o,height:l,topMargin:s,bottomMargin:f,tooltip:c,onSeriesMouseOver:h,suffix:d,prefix:m,showValues:g,colorDomain:y,colors:b,noDataColor:S,scaleType:w,showRowLabels:C,selectedColor:k,onSeriesMouseClick:_,resetSelectionOnDoubleClick:D,detailsOnClick:T,styles:A,classNames:M}=t,E={top:s,bottom:f,left:n,right:a},[N,Y]=I.useState(void 0),[ne,K]=I.useState(void 0),[B,j]=I.useState(void 0),[$,V]=I.useState(void 0),z=o-E.left-E.right,W=l-E.top-E.bottom,G=Bt(e,Z=>Z.column).map(Z=>Z.column),ae=Bt(e,Z=>Z.row).map(Z=>Z.row),U=Un().domain(ae).range([0,W]),H=U.bandwidth(),R=Un().domain(G).range([0,z]),ee=R.bandwidth(),J=w==="categorical"?Ys().domain(y).range(b):w==="threshold"?P2().domain(y).range(b):br().domain(y).range(b);return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{width:`${o}px`,height:`${l}px`,viewBox:`0 0 ${o} ${l}`,style:{marginLeft:"auto",marginRight:"auto"},direction:"ltr",children:[v.jsx("g",{transform:`translate(${E.left},0)`,children:r?G.map((Z,re)=>{var te,F;return v.jsx(f4,{y:0,x:R(Z),width:ee,height:E.top-5,value:`${Z}`.length<i?`${Z}`:`${`${Z}`.substring(0,i)}...`,style:(te=A==null?void 0:A.xAxis)==null?void 0:te.labels,className:(F=M==null?void 0:M.xAxis)==null?void 0:F.labels,alignment:"bottom"},re)}):null}),v.jsx("g",{transform:`translate(0,${E.top})`,children:C?ae.map((Z,re)=>{var te,F;return v.jsx(Y2,{value:`${Z}`.length<i?`${Z}`:`${`${Z}`.substring(0,i)}...`,y:U(Z),x:0,width:E.left,height:H,alignment:"right",style:(te=A==null?void 0:A.yAxis)==null?void 0:te.labels,className:(F=M==null?void 0:M.yAxis)==null?void 0:F.labels},re)}):null}),v.jsxs("g",{transform:`translate(${E.left},${E.top})`,children:[ae.map((Z,re)=>v.jsx("g",{transform:`translate(0,${U(Z)})`,children:G.map((te,F)=>v.jsx("rect",{x:R(te),y:0,width:ee,height:H,style:{fill:S},className:"stroke-1 stroke-primary-white dark:stroke-primary-gray-700"},F))},re)),e.filter(Z=>!Fe(Z.value)).map((Z,re)=>{const te=Fe(Z.value)?S:J(Z.value);return v.jsxs("g",{transform:`translate(${R(Z.column)},${U(Z.row)})`,onMouseEnter:F=>{K(Z),V(F.clientY),j(F.clientX),h&&h(Z)},onClick:()=>{(_||T)&&(Sr(N,Z)&&D?(Y(void 0),_==null||_(void 0)):(Y(Z),_==null||_(Z)))},onMouseMove:F=>{K(Z),V(F.clientY),j(F.clientX)},onMouseLeave:()=>{K(void 0),j(void 0),V(void 0),h&&h(void 0)},opacity:k?k===te?1:.3:1,children:[v.jsx("rect",{x:0,y:0,width:ee,height:H,style:{fill:te},className:"stroke-1 stroke-primary-white dark:stroke-primary-gray-700"}),g&&!Fe(Z.value)?v.jsx("foreignObject",{y:0,x:0,width:ee,height:H,children:v.jsx("div",{className:"flex flex-col justify-center items-center h-inherit p-1",children:v.jsx("p",{className:Be("text-xs text-center m-0 leading-[1.25] graph-value",M==null?void 0:M.graphObjectValues),style:{color:Bi(te),...(A==null?void 0:A.graphObjectValues)||{}},children:typeof Z.value=="string"?`${m} ${Z.value} ${d}`:_t(Z.value,m,d)})})},re):null]},re)}),ne?v.jsx("rect",{x:R(ne.column),y:U(ne.row),width:ee,height:H,style:{fill:"none",fillOpacity:0,strokeWidth:1.5},className:"stroke-primary-gray-700 dark:stroke-primary-gray-300"}):null]})]}),ne&&c&&B&&$?v.jsx(yr,{data:ne,body:c,xPos:B,yPos:$,backgroundStyle:A==null?void 0:A.tooltip,className:M==null?void 0:M.tooltip}):null,T?v.jsx(Tr,{open:N!==void 0,onClose:()=>{Y(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(T,N)}})}):null]})}function XH(t){const{colorLegendTitle:e,colorDomain:r,colors:n,width:a,className:i}=t;return v.jsxs("div",{className:Be("flex gap-0 flex-wrap justify-center leading-0",i),style:{maxWidth:a?`${a}px`:"none"},"aria-label":"Color legend",children:[e&&e!==""?v.jsx(or,{size:"sm",marginBottom:"2xs",className:"w-full text-center",children:e}):null,v.jsxs("div",{className:"flex gap-0 flex-wrap justify-center w-full min-w-[360px] leading-0",children:[v.jsx("div",{className:"h-4 mb-1 w-full min-w-[360px]",style:{background:`linear-gradient(90deg, ${n[0]} 0%, ${n[1]} 100%)`}}),v.jsxs("div",{className:"flex justify-between w-full min-w-[360px]",children:[v.jsx(or,{marginBottom:"none",size:"sm",children:_t(r[0],"","")}),v.jsx(or,{marginBottom:"none",size:"sm",children:_t(r[1],"","")})]})]})]})}function KH(t){const{colorLegendTitle:e,colorDomain:r,colors:n,setSelectedColor:a,width:i,naColor:o,className:l,showNAColor:s}=t,[f,c]=I.useState(void 0),h=o?320:360;return v.jsxs("div",{className:Be("flex flex-wrap gap-0 justify-center leading-0",l),style:{maxWidth:i?`${i}px`:"none"},"aria-label":"Color legend",children:[e&&e!==""?v.jsx(or,{size:"sm",marginBottom:"2xs",className:"w-full text-center",children:e}):null,v.jsx("svg",{width:"100%",viewBox:"0 0 360 30",style:{maxWidth:"360px"},direction:"ltr",children:v.jsxs("g",{children:[r.map((d,m)=>v.jsxs("g",{onMouseOver:()=>{c(n[m]),a(n[m])},onMouseLeave:()=>{c(void 0),a(void 0)},className:"cursor-pointer",children:[v.jsx("rect",{x:m*h/n.length+1,y:1,width:h/n.length-2,height:8,className:`stroke-1 ${f===n[m]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:n[m],...f!==n[m]?{stroke:n[m]}:{}}}),v.jsx("text",{x:(m+1)*h/n.length,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-sm",style:{textAnchor:"middle"},children:_t(d,"","")})]},m)),v.jsx("g",{children:v.jsx("rect",{onMouseOver:()=>{c(n[r.length]),a(n[r.length])},onMouseLeave:()=>{c(void 0),a(void 0)},x:r.length*h/n.length+1,y:1,width:h/n.length-2,height:8,className:`cursor-pointer stroke-1 ${f===n[r.length]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:n[r.length],...f!==n[r.length]?{stroke:n[r.length]}:{}}})}),s?v.jsxs("g",{onMouseOver:()=>{c(o||"#D4D6D8"),a(o||"#D4D6D8")},onMouseLeave:()=>{c(void 0),a(void 0)},className:"cursor-pointer",children:[v.jsx("rect",{x:335,y:1,width:24,height:8,className:`stroke-1 ${f===o?"stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:o||"#D4D6D8",...f!==o?{stroke:o}:{},strokeWidth:1}}),v.jsx("text",{x:337.5,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-sm",style:{textAnchor:"start"},children:"NA"})]}):null]})})]})}function JH(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,showColumnLabels:o=!0,leftMargin:l=100,rightMargin:s=10,truncateBy:f=999,height:c,width:h,scaleType:d,colorDomain:m,footNote:g,colorLegendTitle:y,padding:b,backgroundColor:S=!1,topMargin:w=30,bottomMargin:C=10,tooltip:k,onSeriesMouseOver:_,suffix:D="",prefix:T="",showRowLabels:A=!0,relativeHeight:M,showValues:E,graphID:N,noDataColor:Y=Qe.gray,showColorScale:ne=!0,onSeriesMouseClick:K,graphDownload:B=!1,dataDownload:j=!1,fillContainer:$=!0,language:V="en",showNAColor:z=!0,minHeight:W=0,theme:G="light",ariaLabel:ae,resetSelectionOnDoubleClick:U=!0,detailsOnClick:H,styles:R,classNames:ee}=t,[J,Z]=I.useState(0),[re,te]=I.useState(0),[F,q]=I.useState(void 0),X=I.useRef(null),ie=I.useRef(null);I.useEffect(()=>{const de=new ResizeObserver(he=>{Z(h||he[0].target.clientWidth||620),te(c||he[0].target.clientHeight||480)});return X.current&&(te(X.current.clientHeight||480),Z(X.current.clientWidth||620),h||de.observe(X.current)),()=>de.disconnect()},[h,c]);const ce=d||(typeof m[0]=="string"?"categorical":m.length===2?"linear":"threshold");return v.jsx("div",{className:`${G||"light"} flex ${h?"grow-0":"grow"} ${$?"w-full":"w-fit"}`,dir:V==="he"||V==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${S?S===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${V||"en"}`,ee==null?void 0:ee.graphContainer),style:{...(R==null?void 0:R.graphContainer)||{},...S&&S!==!0?{backgroundColor:S}:{}},id:N,ref:ie,"aria-label":ae||`${r?`The graph shows ${r}. `:""}This is a heatmap. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:S?b||"1rem":b||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||B||j?v.jsx(Zt,{styles:{title:R==null?void 0:R.title,description:R==null?void 0:R.description},classNames:{title:ee==null?void 0:ee.title,description:ee==null?void 0:ee.description},graphTitle:r,graphDescription:i,width:h,graphDownload:B?ie.current:void 0,dataDownload:j?e.map(de=>de.data).filter(de=>de!==void 0).length>0?e.map(de=>de.data).filter(de=>de!==void 0):e.filter(de=>de!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[ne?ce==="categorical"?v.jsx(Cn,{width:$?void 0:h,colorLegendTitle:y,colors:n||(typeof m[0]=="string"?Qe[G].categoricalColors.colors:m.length===2?[Qe[G].sequentialColors.neutralColorsx09[0],Qe[G].sequentialColors.neutralColorsx09[8]]:Qe[G].sequentialColors[`neutralColorsx0${m.length+1}`]),colorDomain:m.map(de=>`${de}`),setSelectedColor:q,showNAColor:z}):ce==="threshold"?v.jsx(KH,{width:$?void 0:h,colorLegendTitle:y,colors:n||(typeof m[0]=="string"?Qe[G].categoricalColors.colors:m.length===2?[Qe[G].sequentialColors.neutralColorsx09[0],Qe[G].sequentialColors.neutralColorsx09[8]]:Qe[G].sequentialColors[`neutralColorsx0${m.length+1}`]),colorDomain:m,setSelectedColor:q,naColor:Y,showNAColor:z}):v.jsx(XH,{width:$?void 0:h,colorLegendTitle:y,colors:n||[Qe[G].sequentialColors.neutralColorsx09[0],Qe[G].sequentialColors.neutralColorsx09[8]],colorDomain:m}):null,v.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:X,"aria-label":"Graph area",children:(h||J)&&(c||re)?v.jsx(jye,{data:e,colorDomain:m,width:h||J,colors:n||(typeof m[0]=="string"?Qe[G].categoricalColors.colors:m.length===2?[Qe[G].sequentialColors.neutralColorsx09[0],Qe[G].sequentialColors.neutralColorsx09[8]]:Qe[G].sequentialColors[`neutralColorsx0${m.length+1}`]),noDataColor:Y,scaleType:ce,height:Math.max(W,c||(M?W?(h||J)*M>W?(h||J)*M:W:(h||J)*M:re)),showColumnLabels:o,leftMargin:l,rightMargin:s,topMargin:w,bottomMargin:C,selectedColor:F,truncateBy:f,showRowLabels:A,tooltip:k,onSeriesMouseOver:_,showValues:E,suffix:D,prefix:T,onSeriesMouseClick:K,resetSelectionOnDoubleClick:U,detailsOnClick:H}):null})]})}),a||g?v.jsx(tr,{styles:{footnote:R==null?void 0:R.footnote,source:R==null?void 0:R.source},classNames:{footnote:ee==null?void 0:ee.footnote,source:ee==null?void 0:ee.source},sources:a,footNote:g,width:h}):null]})})})})}const FM=t=>t.map(n=>n||1).reduce((n,a)=>n+a,0);function ZH(t){var $;const{width:e,height:r,graphTitle:n,sources:a,graphDescription:i,footNote:o,graphID:l,data:s,columnData:f,onSeriesMouseClick:c,language:h="en",theme:d="light",ariaLabel:m,backgroundColor:g=!1,padding:y,resetSelectionOnDoubleClick:b=!0,styles:S,classNames:w}=t,[C,k]=I.useState(void 0),[_,D]=I.useState(void 0),[T,A]=I.useState("asc"),[M,E]=I.useState(void 0),[N,Y]=I.useState({}),[ne,K]=I.useState(f.filter(V=>V.filterOptions&&V.filterOptions.length>0).map(V=>({id:V.columnId,option:V.filterOptions}))),[B,j]=I.useState(s);return I.useEffect(()=>{const V=[];s.forEach(z=>{let W=!0;ne.forEach(G=>{if(typeof z[G.id]!="object"&&typeof z[G.id]!="function"&&typeof z[G.id]!="symbol")if(f[f.findIndex(ae=>ae.columnId===G.id)].separator){const ae=z[G.id].split(f[f.findIndex(U=>U.columnId===G.id)].separator);K3(ae,G.option).length===0&&(W=!1)}else G.option.indexOf(z[G.id])===-1&&(W=!1)}),W&&V.push(z)}),j(C&&s?T==="asc"?Ut(V,[C]):Ut(V,[C]).reverse():V)},[C,T,s,ne,f]),v.jsx("div",{className:`${d||"light"} flex ${e?"w-fit grow-0":"w-full grow"}`,dir:h==="he"||h==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${g?g===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${h||"en"}`,w==null?void 0:w.graphContainer),style:{...(S==null?void 0:S.graphContainer)||{},...g&&g!==!0?{backgroundColor:g}:{}},id:l,"aria-label":m||`${n?`The graph shows ${n}. `:""}This is an data table. ${i?` ${i}`:""}`,children:v.jsxs("div",{className:"flex grow",style:{padding:g?y||"1rem":y||0},children:[v.jsxs("div",{className:"flex flex-col gap-3 w-full justify-between grow",children:[n||i?v.jsx(Zt,{styles:{title:S==null?void 0:S.title,description:S==null?void 0:S.description},classNames:{title:w==null?void 0:w.title,description:w==null?void 0:w.description},graphTitle:n,graphDescription:i,width:e}):null,v.jsx("div",{className:"grow flex flex-col justify-center",children:v.jsx("div",{className:"undp-scrollbar",style:{width:e?`${e}px`:"100%",height:r?`${r}px`:"auto"},children:s?v.jsxs("table",{className:"w-full",style:{borderCollapse:"collapse"},children:[v.jsx("thead",{className:"text-left bg-primary-gray-300 dark:bg-primary-gray-550",children:v.jsx("tr",{children:f==null?void 0:f.map((V,z)=>{var W;return v.jsx("th",{className:"text-primary-gray-700 dark:text-primary-gray-100 text-sm",style:{width:`calc(${100*(V.columnWidth||1)/FM(f.map(G=>G.columnWidth||1))}%`},children:v.jsxs("div",{className:"flex gap-2 justify-between items-center p-4",children:[v.jsx(or,{size:"sm",marginBottom:"none",className:`w-fit grow text-${V.align||"left"} font-bold`,children:V.columnTitle||V.columnId}),V.sortable?v.jsx("button",{type:"button",className:"bg-transparent cursor-pointer p-0 m-0 border-0",onClick:()=>{C===V.columnId?(T==="asc"&&A("desc"),T==="desc"&&k(void 0)):(k(V.columnId),A("asc"))},children:C===V.columnId?T==="asc"?v.jsx(H3e,{}):v.jsx(z3e,{}):v.jsx(F3e,{})}):null,V.filterOptions&&V.filterOptions.length?v.jsx("button",{type:"button",className:"bg-transparent cursor-pointer m-0 p-0 border-0",onClick:G=>{if(M===V.columnId)E(void 0);else if(G.currentTarget){E(V.columnId);const ae=G.currentTarget.getBoundingClientRect();Y({top:ae.bottom+window.scrollY,left:ae.left+window.scrollX-160<0?ae.left+window.scrollX:ae.left+window.scrollX-160,width:"10rem"})}},children:ne[ne.findIndex(G=>G.id===V.columnId)].option.length===((W=V.filterOptions)==null?void 0:W.length)?v.jsx(q3e,{}):v.jsx(W3e,{})}):null]})},z)})})}),v.jsx("tbody",{children:B==null?void 0:B.map((V,z)=>v.jsx("tr",{className:`cursor-${c?"pointer":"auto"} border-b border-b-primary-gray-400 dark:border-b-primary-gray-500 ${Sr(_,V)?"bg-primary-gray-200 dark:bg-primary-gray-600":"bg-transparent"}`,onClick:()=>{c&&(Sr(_,V)&&b?(D(void 0),c(void 0)):(D(V),c(V)))},children:f.map((W,G)=>v.jsx("td",{className:`text-primary-gray-700 dark:text-primary-gray-100 text-sm text-${W.align||"left"}`,style:{width:`calc(${100*(V.columnWidth||1)/FM(f.map(ae=>ae.columnWidth||1))}%`},children:v.jsx("div",{className:`text-primary-gray-700 dark:text-primary-gray-100 flex p-4 ${W.align==="right"?"justify-end":W.align==="center"?"justify-center":"justify-start"}`,children:typeof V[W.columnId]=="number"?v.jsx(or,{marginBottom:"none",size:"sm",className:`text-primary-gray-700 dark:text-primary-gray-100 w-fit ${W.chip?"grow-0 rounded-sm p-2":"grow rounded-none p-0"} text-${W.align||"left"} ${W.chip?W.chipColors?"":"bg-primary-gray-300 dark:bg-primary-gray-500":"bg-transparent"}`,style:{...W.chip&&W.chipColors?{backgroundColor:W.chipColors[W.chipColors.findIndex(ae=>ae.value===V[W.columnId])].color}:{}},children:_t(V[W.columnId],W.prefix,W.suffix)}):typeof V[W.columnId]=="string"?W.separator?v.jsx("div",{className:"text-primary-gray-700 dark:text-primary-gray-100 flex flex-wrap gap-2",children:V[W.columnId].split(W.separator).map((ae,U)=>v.jsx(or,{marginBottom:"none",size:"sm",className:`text-primary-gray-700 dark:text-primary-gray-100 w-fit ${W.chip?"grow-0 rounded-sm p-2":"grow rounded-none p-0"} text-${W.align||"left"} ${W.chip?W.chipColors?"":"bg-primary-gray-300 dark:bg-primary-gray-500":"bg-transparent"}`,style:{...W.chip&&W.chipColors?{backgroundColor:W.chipColors[W.chipColors.findIndex(H=>H.value===V[W.columnId])].color}:{}},children:`${W.prefix||""}${ae}${W.suffix||""}`},U))}):v.jsx(or,{marginBottom:"none",size:"sm",className:`text-primary-gray-700 dark:text-primary-gray-100 w-fit ${W.chip?"grow-0 rounded-sm p-2":"grow rounded-none p-0"} text-${W.align||"left"} ${W.chip?W.chipColors?"":"bg-primary-gray-300 dark:bg-primary-gray-500":"bg-transparent"}`,style:{...W.chip&&W.chipColors?{backgroundColor:W.chipColors[W.chipColors.findIndex(ae=>ae.value===V[W.columnId])].color}:{}},children:`${W.prefix||""}${V[W.columnId]}${W.suffix||""}`}):v.jsx("div",{children:V[W.columnId]})})},G))},z))})]}):null})}),a||o?v.jsx(tr,{styles:{footnote:S==null?void 0:S.footnote,source:S==null?void 0:S.source},classNames:{footnote:w==null?void 0:w.footnote,source:w==null?void 0:w.source},sources:a,footNote:o,width:e}):null]}),M&&v.jsx("div",{style:N,className:"absolute p-3 border z-[1000] rounded-sm bg-primary-white dark:bg-primary-gray-700 border-primary-gray-300 dark:border-primary-gray-550",children:v.jsxs("div",{className:"max-w-60",children:[v.jsx(or,{size:"sm",marginBottom:"2xs",className:"font-bold",children:"Filter data by"}),v.jsx("div",{className:"flex flex-col gap-2",children:($=f[f.findIndex(V=>V.columnId===M)].filterOptions)==null?void 0:$.map((V,z)=>v.jsx("div",{children:v.jsxs("label",{className:"undp-viz-label",children:[v.jsx("input",{type:"checkbox",className:"undp-viz-checkbox",checked:ne[ne.findIndex(W=>W.id===M)].option.indexOf(V)!==-1,onChange:()=>{const W=ne.findIndex(ae=>ae.id===M),G=[...ne[W].option];if(G.indexOf(V)!==-1){G.splice(G.indexOf(V),1);const ae=[...ne];ae[W].option=G,K(ae)}else{G.push(V);const ae=[...ne];ae[W].option=G,K(ae)}}}),V]},z)},z))})]})})]})})})}function J3(t){if(t!==void 0)return Array.isArray(t)?t.map(e=>({value:e,label:e})):{value:t,label:t}}const Lye=t=>t?Object.entries(t).map(([r,n])=>Array.isArray(n)?{" ":r,value:`"${n.join("; ")}"`}:{" ":r,value:`"${n}"`}):{},zM=(t,e,r)=>e.length===0?t:t.filter(n=>e.some(a=>{var i;return(i=n[a])==null?void 0:i.toLowerCase().includes(r.toLowerCase())}));function QH(t){const{width:e,height:r,graphTitle:n,sources:a,graphDescription:i,footNote:o,graphID:l,data:s,onSeriesMouseClick:f,language:c="en",theme:h="light",ariaLabel:d,cardTemplate:m,cardBackgroundColor:g,cardFilters:y=[],cardSortingOptions:b,cardSearchColumns:S=[],cardMinWidth:w=320,backgroundColor:C=!1,padding:k,detailsOnClick:_,allowDataDownloadOnDetail:D=!1,noOfItemsInAPage:T,uiMode:A="normal",styles:M,classNames:E}=t,[N,Y]=I.useState(s),[ne,K]=I.useState(1),[B,j]=I.useState(void 0),[$,V]=I.useState(""),[z,W]=I.useState([]),[G,ae]=I.useState(b?!b.defaultValue||b.options.findIndex(R=>R.label===b.defaultValue)===-1?b.options[0]:b.options[b.options.findIndex(R=>R.label===b.defaultValue)]:void 0),U=I.useMemo(()=>({ignoreCase:!0,ignoreAccents:!0,trim:!0}),[]);I.useEffect(()=>{ae(b?!b.defaultValue||b.options.findIndex(R=>R.label===b.defaultValue)===-1?b.options[0]:b.options[b.options.findIndex(R=>R.label===b.defaultValue)]:void 0)},[b]),I.useEffect(()=>{const R=y.map(ee=>({filter:ee.column,label:ee.label||`Filter by ${ee.column}`,singleSelect:!0,clearable:!0,defaultValue:J3(ee.defaultValue),availableValues:J0(s,ee.column).filter(J=>{var Z;return!((Z=ee.excludeValues)!=null&&Z.includes(`${J}`))}).map(J=>({value:J,label:J})),width:ee.width}));W(R)},[s,y]);const H=I.useCallback((R,ee)=>{W(J=>J.map(Z=>Z.filter===R?{...Z,value:ee}:Z))},[]);return I.useEffect(()=>{const R=s.filter(ee=>z.every(J=>J.value&&f1([J.value]).length>0?K3(f1([ee[J.filter]]),f1([J.value]).map(Z=>Z.value)).length>0:!0));Y(G?Ut(R,G==null?void 0:G.value,G==null?void 0:G.type):R)},[z,s,G]),I.useEffect(()=>{K(1)},[N,S,$]),v.jsx("div",{className:`${h||"light"} flex ${e?"w-fit grow-0":"w-full grow"}`,dir:c==="he"||c==="ar"?"rtl":void 0,children:v.jsxs("div",{className:Be(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${c||"en"}`,E==null?void 0:E.graphContainer),style:{...(M==null?void 0:M.graphContainer)||{},...C&&C!==!0?{backgroundColor:C}:{}},id:l,"aria-label":d||`${n?`The graph shows ${n}. `:""}This is an list of cards. ${i?` ${i}`:""}`,children:[v.jsx("div",{className:"flex grow",style:{padding:C?k||"1rem":k||0},children:v.jsxs("div",{className:"flex flex-col grow gap-3 w-full justify-between",children:[n||i?v.jsx(Zt,{styles:{title:M==null?void 0:M.title,description:M==null?void 0:M.description},classNames:{title:E==null?void 0:E.title,description:E==null?void 0:E.description},graphTitle:n,graphDescription:i,width:e}):null,b||z.length>0?v.jsxs("div",{className:"flex gap-4 flex-wrap items-start w-full",children:[b?v.jsxs("div",{className:"grow shrink-0 min-w-[240px]",style:{width:b.width||"calc(25% - 0.75rem)"},children:[v.jsx(or,{marginBottom:"xs",size:"sm",className:"text-primary-gray-700 dark:text-primary-gray-100",children:"Sort by"}),v.jsx(s1,{options:b.options,isRtl:c==="he"||c==="ar",isSearchable:!0,filterOption:Z1(U),onChange:R=>{ae(R||void 0)},variant:A,size:"sm",defaultValue:!b.defaultValue||b.options.findIndex(R=>R.label===b.defaultValue)===-1?b.options[0]:b.options[b.options.findIndex(R=>R.label===b.defaultValue)]})]}):null,z==null?void 0:z.map((R,ee)=>v.jsxs("div",{className:"grow shrink-0 min-w-[240px]",style:{width:R.width||"calc(25% - 0.75rem)"},children:[v.jsx(or,{marginBottom:"xs",size:"sm",className:"text-primary-gray-700 dark:text-primary-gray-100",children:R.label}),v.jsx(s1,{options:R.availableValues,isClearable:R.clearable===void 0?!0:R.clearable,isRtl:c==="he"||c==="ar",isSearchable:!0,variant:A,size:"sm",controlShouldRenderValue:!0,filterOption:Z1(U),onChange:J=>{H(R.filter,J)},defaultValue:R.defaultValue})]},ee))]}):null,S.length>0?v.jsx(cP,{placeholder:"Search...",value:$,onChange:R=>{V(R.target.value)},buttonVariant:"icon",inputVariant:A,showSearchButton:!1,inputSize:"sm"}):null,v.jsx("div",{className:"undp-scrollbar w-full my-0 mx-auto grid gap-4 undp-viz-data-cards-container",style:{width:e?`${e}px`:"100%",height:r?`${r}px`:"auto",gridTemplateColumns:`repeat(auto-fit, minmax(${w}px, 1fr))`},children:zM(N,S,$).filter((R,ee)=>T?ee<ne*T&&ee>=(ne-1)*T:!0).map((R,ee)=>v.jsx("div",{style:{...(M==null?void 0:M.dataCards)||{},...g&&{backgroundColor:g}},className:`w-full flex flex-col ${f||_?"cursor-pointer":"cursor-auto"}${g?"":"bg-primary-gray-200 dark:bg-primary-gray-600"} ${(E==null?void 0:E.dataCards)||""}`,onClick:()=>{f==null||f(R),_&&j(R)},dangerouslySetInnerHTML:{__html:Cr(m,R)}},ee))}),T?v.jsx(Hne,{total:zM(N,S,$).length,defaultPage:0,pageSize:T,onChange:K}):null,a||o?v.jsx(tr,{styles:{footnote:M==null?void 0:M.footnote,source:M==null?void 0:M.source},classNames:{footnote:E==null?void 0:E.footnote,source:E==null?void 0:E.source},sources:a,footNote:o,width:e}):null]})}),v.jsx(Tr,{open:B!==void 0,onClose:()=>{j(void 0)},children:_?v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(_,B)}}),D?v.jsx("div",{className:"flex",children:v.jsx(Vb,{csvData:Lye(B),headers:[{label:" ",key:" "},{label:"value",key:"value"}],buttonContent:v.jsxs("div",{className:"flex items-center gap-4",children:[typeof D=="string"?D:null,v.jsx(Bb,{})]})})}):null]}):null})]})})}function Nye(t){var re,te,F,q;const{data:e,width:r,height:n,colors:a,colorDomain:i,radius:o,leftMargin:l,rightMargin:s,topMargin:f,bottomMargin:c,tooltip:h,onSeriesMouseOver:d,highlightedDataPoints:m,selectedColor:g,minValue:y,maxValue:b,onSeriesMouseClick:S,showAxis:w,prefix:C,suffix:k,stripType:_,highlightColor:D,dotOpacity:T,resetSelectionOnDoubleClick:A,detailsOnClick:M,styles:E,classNames:N,valueColor:Y}=t,[ne,K]=I.useState(void 0),[B,j]=I.useState(void 0),[$,V]=I.useState(void 0),[z,W]=I.useState(void 0),G={top:f,bottom:c,left:l,right:s},ae=r-G.left-G.right,U=n-G.top-G.bottom,H=e.map((X,ie)=>({...X,id:`${ie}`})),R=Ut(H,X=>{const ie=(m||[]).indexOf(X.label);return ie===-1?1/0:ie}).reverse(),ee=Fe(b)?Math.max(...e.filter(X=>!Fe(X.position)).map(X=>X.position))<0?0:Math.max(...e.filter(X=>!Fe(X.position)).map(X=>X.position)):b,J=Fe(y)?Math.min(...e.filter(X=>!Fe(X.position)).map(X=>X.position))>=0?0:Math.min(...e.filter(X=>!Fe(X.position)).map(X=>X.position)):y,Z=br().domain([J,ee]).range([0,ae]).nice();return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${G.left},${G.top})`,children:[R.map((X,ie)=>v.jsxs("g",{className:"undp-viz-g-with-hover",transform:`translate(${Z(X.position)},${U/2})`,opacity:g?X.color&&a[i.indexOf(X.color)]===g?1:T:m.length!==0&&m.indexOf(X.label)!==-1?.85:T,onMouseEnter:ce=>{K(X),W(ce.clientY),V(ce.clientX),d&&d(X)},onClick:()=>{(S||M)&&(Sr(B,X)&&A?(j(void 0),S==null||S(void 0)):(j(X),S==null||S(X)))},onMouseMove:ce=>{K(X),W(ce.clientY),V(ce.clientX)},onMouseLeave:()=>{K(void 0),V(void 0),W(void 0),d&&d(void 0)},children:[_==="dot"?v.jsx("circle",{cy:0,cx:0,style:{fill:D&&m?m.indexOf(X.label)!==-1?D:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray},r:o}):v.jsx("rect",{y:0-o,x:-1,height:o*2,width:2,style:{fill:D&&m?m.indexOf(X.label)!==-1?D:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray}}),m.length!==0&&m.indexOf(X.label)!==-1?v.jsx("text",{x:0,y:0-o-5,style:{fill:Y||(D&&m?m.indexOf(X.label)!==-1?D:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray),textAnchor:"middle",...(E==null?void 0:E.graphObjectValues)||{}},className:Be("graph-value text-sm font-bold",N==null?void 0:N.graphObjectValues),children:_t(X.position,C,k)}):null]},ie)),w?v.jsxs(v.Fragment,{children:[v.jsx("text",{x:0,y:U/2+o,style:{textAnchor:"start",...((re=E==null?void 0:E.yAxis)==null?void 0:re.labels)||{}},className:Be("fill-primary-gray-550 dark:fill-primary-gray-500 text-xs",(te=N==null?void 0:N.yAxis)==null?void 0:te.labels),dy:"1em",children:_t(Z.invert(0),C,k)}),v.jsx("text",{x:ae,y:U/2+o,style:{textAnchor:"end",...((F=E==null?void 0:E.yAxis)==null?void 0:F.labels)||{}},className:Be("fill-primary-gray-550 dark:fill-primary-gray-500 text-xs",(q=N==null?void 0:N.yAxis)==null?void 0:q.labels),dy:"1em",children:_t(Z.invert(ae),C,k)})]}):null]})}),ne&&h&&$&&z?v.jsx(yr,{data:ne,body:h,xPos:$,yPos:z,backgroundStyle:E==null?void 0:E.tooltip,className:N==null?void 0:N.tooltip}):null,M?v.jsx(Tr,{open:B!==void 0,onClose:()=>{j(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(M,B)}})}):null]})}function Iye(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,height:o,width:l,footNote:s,colorDomain:f,colorLegendTitle:c,radius:h=5,padding:d,backgroundColor:m=!1,leftMargin:g=5,rightMargin:y=5,topMargin:b=10,bottomMargin:S=10,tooltip:w,relativeHeight:C,onSeriesMouseOver:k,showColorScale:_=!0,highlightedDataPoints:D=[],graphID:T,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N=!0,graphDownload:Y=!1,dataDownload:ne=!1,prefix:K="",suffix:B="",stripType:j="dot",language:$="en",highlightColor:V,dotOpacity:z=.3,showNAColor:W=!0,minHeight:G=0,theme:ae="light",ariaLabel:U,resetSelectionOnDoubleClick:H=!0,detailsOnClick:R,styles:ee,classNames:J,valueColor:Z}=t,[re,te]=I.useState(0),[F,q]=I.useState(0),[X,ie]=I.useState(void 0),ce=I.useRef(null),de=I.useRef(null);return I.useEffect(()=>{const he=new ResizeObserver(Oe=>{te(l||Oe[0].target.clientWidth||620),q(o||Oe[0].target.clientHeight||480)});return ce.current&&(q(ce.current.clientHeight||480),te(ce.current.clientWidth||620),l||he.observe(ce.current)),()=>he.disconnect()},[l,o]),v.jsx("div",{className:`${ae||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:$==="he"||$==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${m?m===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${$||"en"}`,J==null?void 0:J.graphContainer),style:{...(ee==null?void 0:ee.graphContainer)||{},...m&&m!==!0?{backgroundColor:m}:{}},id:T,ref:de,"aria-label":U||`${r?`The graph shows ${r}. `:""}This is a strip chart showing distribution of data along the horizontal axis. Each dot represents an individual data point, helping to visualize the spread and clustering of values.${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:m?d||"1rem":d||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||Y||ne?v.jsx(Zt,{styles:{title:ee==null?void 0:ee.title,description:ee==null?void 0:ee.description},classNames:{title:J==null?void 0:J.title,description:J==null?void 0:J.description},graphTitle:r,graphDescription:i,width:l,graphDownload:Y?de.current:void 0,dataDownload:ne?e.map(he=>he.data).filter(he=>he!==void 0).length>0?e.map(he=>he.data).filter(he=>he!==void 0):e.filter(he=>he!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[_!==!1&&e.filter(he=>he.color).length!==0?v.jsx(Cn,{width:l,colorLegendTitle:c,colors:n||Qe[ae].categoricalColors.colors,colorDomain:f||Bt(e.filter(he=>he.color),"color").map(he=>he.color),setSelectedColor:ie,showNAColor:W??!0}):null,v.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:ce,"aria-label":"Graph area",children:(l||re)&&(o||F)?v.jsx(Nye,{data:e,width:l||re,height:Math.max(G,o||(C?G?(l||re)*C>G?(l||re)*C:G:(l||re)*C:F)),colorDomain:e.filter(he=>he.color).length===0?[]:f||Bt(e.filter(he=>he.color),"color").map(he=>he.color),colors:e.filter(he=>he.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[ae].categoricalColors.colors,selectedColor:X,radius:h,leftMargin:g,rightMargin:y,topMargin:b,bottomMargin:S,tooltip:w,onSeriesMouseOver:k,highlightedDataPoints:D,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N,prefix:K,suffix:B,stripType:j,highlightColor:V,dotOpacity:z,resetSelectionOnDoubleClick:H,detailsOnClick:R,styles:ee,classNames:J,valueColor:Z}):null})]})}),a||s?v.jsx(tr,{styles:{footnote:ee==null?void 0:ee.footnote,source:ee==null?void 0:ee.source},classNames:{footnote:J==null?void 0:J.footnote,source:J==null?void 0:J.source},sources:a,footNote:s,width:l}):null]})})})})}function Pye(t){var re,te,F,q;const{data:e,width:r,height:n,colors:a,colorDomain:i,radius:o,leftMargin:l,rightMargin:s,topMargin:f,bottomMargin:c,tooltip:h,onSeriesMouseOver:d,highlightedDataPoints:m,selectedColor:g,minValue:y,maxValue:b,onSeriesMouseClick:S,showAxis:w,prefix:C,suffix:k,stripType:_,highlightColor:D,dotOpacity:T,resetSelectionOnDoubleClick:A,detailsOnClick:M,styles:E,classNames:N,valueColor:Y}=t,[ne,K]=I.useState(void 0),[B,j]=I.useState(void 0),[$,V]=I.useState(void 0),[z,W]=I.useState(void 0),G={top:f,bottom:c,left:l,right:s},ae=r-G.left-G.right,U=n-G.top-G.bottom,H=e.map((X,ie)=>({...X,id:`${ie}`})),R=Ut(H,X=>{const ie=(m||[]).indexOf(X.label);return ie===-1?1/0:ie}).reverse(),ee=Fe(b)?Math.max(...e.filter(X=>!Fe(X.position)).map(X=>X.position))<0?0:Math.max(...e.filter(X=>!Fe(X.position)).map(X=>X.position)):b,J=Fe(y)?Math.min(...e.filter(X=>!Fe(X.position)).map(X=>X.position))>=0?0:Math.min(...e.filter(X=>!Fe(X.position)).map(X=>X.position)):y,Z=br().domain([J,ee]).range([U,0]).nice();return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${G.left},${G.top})`,children:[R.map((X,ie)=>v.jsxs("g",{className:"undp-viz-g-with-hover",transform:`translate(${ae/2},${Z(X.position)})`,opacity:g?X.color&&a[i.indexOf(X.color)]===g?1:T:m.length!==0&&m.indexOf(X.label)!==-1?.85:T,onMouseEnter:ce=>{K(X),W(ce.clientY),V(ce.clientX),d&&d(X)},onClick:()=>{(S||M)&&(Sr(B,X)&&A?(j(void 0),S==null||S(void 0)):(j(X),S==null||S(X)))},onMouseMove:ce=>{K(X),W(ce.clientY),V(ce.clientX)},onMouseLeave:()=>{K(void 0),V(void 0),W(void 0),d&&d(void 0)},children:[_==="dot"?v.jsx("circle",{cy:0,cx:0,style:{fill:D&&m?m.indexOf(X.label)!==-1?D:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray},r:o}):v.jsx("rect",{x:0-o,y:-1,width:o*2,height:2,style:{fill:D&&m?m.indexOf(X.label)!==-1?D:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray}}),m.length!==0&&m.indexOf(X.label)!==-1?v.jsx("text",{y:0,dy:"0.33em",x:0+o+3,style:{fill:Y||(D&&m?m.indexOf(X.label)!==-1?D:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray),textAnchor:"start",...(E==null?void 0:E.graphObjectValues)||{}},className:Be("graph-value text-sm font-bold",N==null?void 0:N.graphObjectValues),children:_t(X.position,C,k)}):null]},ie)),w?v.jsxs(v.Fragment,{children:[v.jsx("text",{y:0,x:ae/2+o+5,style:{textAnchor:"start",...((re=E==null?void 0:E.yAxis)==null?void 0:re.labels)||{}},className:Be("fill-primary-gray-550 dark:fill-primary-gray-500 text-xs",(te=N==null?void 0:N.yAxis)==null?void 0:te.labels),children:_t(Z.invert(0),C,k)}),v.jsx("text",{y:U,x:ae/2+o+5,style:{textAnchor:"start",...((F=E==null?void 0:E.yAxis)==null?void 0:F.labels)||{}},className:Be("fill-primary-gray-550 dark:fill-primary-gray-500 text-xs",(q=N==null?void 0:N.yAxis)==null?void 0:q.labels),children:_t(Z.invert(U),C,k)})]}):null]})}),ne&&h&&$&&z?v.jsx(yr,{data:ne,body:h,xPos:$,yPos:z,backgroundStyle:E==null?void 0:E.tooltip,className:N==null?void 0:N.tooltip}):null,M?v.jsx(Tr,{open:B!==void 0,onClose:()=>{j(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(M,B)}})}):null]})}function Rye(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,height:o,width:l,footNote:s,colorDomain:f,colorLegendTitle:c,radius:h=5,padding:d,backgroundColor:m=!1,leftMargin:g=20,rightMargin:y=20,topMargin:b=10,bottomMargin:S=10,tooltip:w,relativeHeight:C,onSeriesMouseOver:k,showColorScale:_=!0,highlightedDataPoints:D=[],graphID:T,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N=!0,graphDownload:Y=!1,dataDownload:ne=!1,prefix:K="",suffix:B="",stripType:j="dot",language:$="en",highlightColor:V,dotOpacity:z=.3,showNAColor:W=!0,minHeight:G=0,theme:ae="light",ariaLabel:U,resetSelectionOnDoubleClick:H=!0,detailsOnClick:R,styles:ee,classNames:J,valueColor:Z}=t,[re,te]=I.useState(0),[F,q]=I.useState(0),[X,ie]=I.useState(void 0),ce=I.useRef(null),de=I.useRef(null);return I.useEffect(()=>{const he=new ResizeObserver(Oe=>{te(l||Oe[0].target.clientWidth||620),q(o||Oe[0].target.clientHeight||480)});return ce.current&&(q(ce.current.clientHeight||480),te(ce.current.clientWidth||620),l||he.observe(ce.current)),()=>he.disconnect()},[l,o]),v.jsx("div",{className:`${ae||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:$==="he"||$==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${m?m===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${$||"en"}`,J==null?void 0:J.graphContainer),style:{...(ee==null?void 0:ee.graphContainer)||{},...m&&m!==!0?{backgroundColor:m}:{}},id:T,ref:de,"aria-label":U||`${r?`The graph shows ${r}. `:""}This is a strip chart showing distribution of data along the vertical axis. Each dot represents an individual data point, helping to visualize the spread and clustering of values.${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:m?d||"1rem":d||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||Y||ne?v.jsx(Zt,{styles:{title:ee==null?void 0:ee.title,description:ee==null?void 0:ee.description},classNames:{title:J==null?void 0:J.title,description:J==null?void 0:J.description},graphTitle:r,graphDescription:i,width:l,graphDownload:Y?de.current:void 0,dataDownload:ne?e.map(he=>he.data).filter(he=>he!==void 0).length>0?e.map(he=>he.data).filter(he=>he!==void 0):e.filter(he=>he!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[_!==!1&&e.filter(he=>he.color).length!==0?v.jsx(Cn,{width:l,colorLegendTitle:c,colors:n||Qe[ae].categoricalColors.colors,colorDomain:f||Bt(e.filter(he=>he.color),"color").map(he=>he.color),setSelectedColor:ie,showNAColor:W}):null,v.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:ce,children:(l||re)&&(o||F)?v.jsx(Pye,{data:e,width:l||re,height:Math.max(G,o||(C?G?(l||re)*C>G?(l||re)*C:G:(l||re)*C:F)),colorDomain:e.filter(he=>he.color).length===0?[]:f||Bt(e.filter(he=>he.color),"color").map(he=>he.color),colors:e.filter(he=>he.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[ae].categoricalColors.colors,selectedColor:X,radius:h,leftMargin:g,rightMargin:y,topMargin:b,bottomMargin:S,tooltip:w,onSeriesMouseOver:k,highlightedDataPoints:D,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N,prefix:K,suffix:B,stripType:j,highlightColor:V,dotOpacity:z,resetSelectionOnDoubleClick:H,detailsOnClick:R,styles:ee,classNames:J,valueColor:Z}):null})]})}),a||s?v.jsx(tr,{styles:{footnote:ee==null?void 0:ee.footnote,source:ee==null?void 0:ee.source},classNames:{footnote:J==null?void 0:J.footnote,source:J==null?void 0:J.source},sources:a,footNote:s,width:l}):null]})})})})}function eq(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,height:o,width:l,footNote:s,colorDomain:f,colorLegendTitle:c,radius:h,padding:d,backgroundColor:m,leftMargin:g,rightMargin:y,topMargin:b,bottomMargin:S,tooltip:w,relativeHeight:C,onSeriesMouseOver:k,showColorScale:_,highlightedDataPoints:D,graphID:T,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N,graphDownload:Y,dataDownload:ne,prefix:K,suffix:B,stripType:j,language:$,highlightColor:V,dotOpacity:z,showNAColor:W,minHeight:G,theme:ae,ariaLabel:U,valueColor:H,resetSelectionOnDoubleClick:R,detailsOnClick:ee,orientation:J="vertical",styles:Z,classNames:re}=t;return J==="vertical"?v.jsx(Rye,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,height:o,width:l,footNote:s,colorDomain:f,colorLegendTitle:c,radius:h,padding:d,backgroundColor:m,leftMargin:g,rightMargin:y,topMargin:b,bottomMargin:S,tooltip:w,relativeHeight:C,onSeriesMouseOver:k,showColorScale:_,highlightedDataPoints:D,graphID:T,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N,graphDownload:Y,dataDownload:ne,prefix:K,suffix:B,stripType:j,language:$,highlightColor:V,dotOpacity:z,showNAColor:W,minHeight:G,theme:ae,ariaLabel:U,resetSelectionOnDoubleClick:R,styles:Z,valueColor:H,detailsOnClick:ee,classNames:re}):v.jsx(Iye,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,height:o,width:l,footNote:s,colorDomain:f,colorLegendTitle:c,radius:h,padding:d,backgroundColor:m,leftMargin:g,rightMargin:y,topMargin:b,bottomMargin:S,tooltip:w,relativeHeight:C,onSeriesMouseOver:k,showColorScale:_,highlightedDataPoints:D,graphID:T,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N,graphDownload:Y,dataDownload:ne,prefix:K,suffix:B,stripType:j,language:$,highlightColor:V,dotOpacity:z,showNAColor:W,minHeight:G,theme:ae,ariaLabel:U,resetSelectionOnDoubleClick:R,styles:Z,valueColor:H,detailsOnClick:ee,classNames:re})}function $ye(t){var Oe,Ne,Te,_e,xe,we,ge,ve,le,ue,Ce,pe,ye,be,je,$e,ut,Ie,Ze,Ke;const{data:e,width:r,height:n,barColor:a,lineColor:i,axisTitles:o,sameAxes:l,rightMargin:s,leftMargin:f,topMargin:c,bottomMargin:h,tooltip:d,showValues:m,onSeriesMouseOver:g,barPadding:y,truncateBy:b,showLabels:S,onSeriesMouseClick:w,resetSelectionOnDoubleClick:C,detailsOnClick:k,noOfTicks:_,lineSuffix:D,barSuffix:T,linePrefix:A,barPrefix:M,curveType:E,styles:N,classNames:Y}=t,ne=E==="linear"?yo:E==="step"?e2:E==="stepAfter"?r2:E==="stepBefore"?t2:Q0,[K,B]=I.useState(void 0),[j,$]=I.useState(void 0),[V,z]=I.useState(void 0),[W,G]=I.useState(void 0),ae={top:c,bottom:h,left:f+50,right:s+65},U=r-ae.left-ae.right,H=n-ae.top-ae.bottom,R=e.map((et,Pt)=>({...et,id:`${Pt}`})),ee=Un().domain(R.map(et=>`${et.id}`)).range([0,U]).paddingInner(y),J=(Oe=Br(R,et=>et.bar))!=null&&Oe.bar?((Ne=Br(R,et=>et.bar))==null?void 0:Ne.bar)>0?0:(Te=Br(R,et=>et.bar))==null?void 0:Te.bar:0,Z=(_e=Br(R,et=>et.line))!=null&&_e.line?((xe=Br(R,et=>et.line))==null?void 0:xe.line)>0?0:(we=Br(R,et=>et.line))==null?void 0:we.line:0,re=(ge=Vr(R,et=>et.bar))!=null&&ge.bar?(ve=Vr(R,et=>et.bar))==null?void 0:ve.bar:0,te=(le=Vr(R,et=>et.line))!=null&&le.line?(ue=Vr(R,et=>et.line))==null?void 0:ue.line:0,F=J<Z?J:Z,q=re>te?re:te,X=br().domain([l?F:J,l?q>0?q:0:re>0?re:0]).range([H,0]).nice(),ie=br().domain([l?F:Z,l?q>0?q:0:te>0?te:0]).range([H,0]).nice(),ce=gi().defined(et=>!Fe(et.line)).x(et=>ee(`${et.id}`)+ee.bandwidth()/2).y(et=>ie(et.line)).curve(ne),de=X.ticks(_),he=ie.ticks(_);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${ae.left},${ae.top})`,children:[v.jsxs("g",{children:[de.map((et,Pt)=>{var jt,Tt,St,tt;return v.jsxs("g",{children:[v.jsx("line",{y1:X(et),y2:X(et),x1:-15,x2:-20,style:{stroke:a,strokeWidth:1,...((jt=N==null?void 0:N.yAxis)==null?void 0:jt.gridLines)||{}},className:(Tt=Y==null?void 0:Y.yAxis)==null?void 0:Tt.gridLines}),v.jsx("text",{x:-25,y:X(et),dy:"0.33em",className:Be("text-xs",(St=Y==null?void 0:Y.yAxis)==null?void 0:St.labels),style:{textAnchor:"end",fill:a,...((tt=N==null?void 0:N.yAxis)==null?void 0:tt.labels)||{}},children:_t(et,M,T)})]},Pt)}),v.jsx(Nr,{y1:0,y2:H,x1:-15,x2:-15,classNames:{axis:(Ce=Y==null?void 0:Y.xAxis)==null?void 0:Ce.axis},styles:{axis:{stroke:a,...((pe=N==null?void 0:N.xAxis)==null?void 0:pe.axis)||{}}}}),v.jsx(nn,{x:10-ae.left,y:H/2,style:{fill:a,...((ye=N==null?void 0:N.yAxis)==null?void 0:ye.title)||{}},className:(be=Y==null?void 0:Y.yAxis)==null?void 0:be.title,text:o[0].length>100?`${o[0].substring(0,100)}...`:o[0],rotate90:!0})]}),v.jsxs("g",{children:[he.map((et,Pt)=>{var jt,Tt,St,tt;return v.jsxs("g",{children:[v.jsx("line",{y1:ie(et),y2:ie(et),x1:U+15,x2:U+20,style:{stroke:i,strokeWidth:1,...((jt=N==null?void 0:N.yAxis)==null?void 0:jt.gridLines)||{}},className:(Tt=Y==null?void 0:Y.yAxis)==null?void 0:Tt.gridLines}),v.jsx("text",{x:U+25,y:ie(et),dy:"0.33em",dx:-2,style:{textAnchor:"start",fill:i,...((St=N==null?void 0:N.yAxis)==null?void 0:St.labels)||{}},className:Be("text-xs",(tt=Y==null?void 0:Y.yAxis)==null?void 0:tt.labels),children:_t(et,A,D)})]},Pt)}),v.jsx(Nr,{y1:0,y2:H,x1:U+15,x2:U+15,classNames:{axis:(je=Y==null?void 0:Y.xAxis)==null?void 0:je.axis},styles:{axis:{stroke:i,...(($e=N==null?void 0:N.xAxis)==null?void 0:$e.axis)||{}}}}),v.jsx(nn,{x:U+ae.right-15,y:H/2,style:{fill:i,...((ut=N==null?void 0:N.yAxis)==null?void 0:ut.title)||{}},className:(Ie=Y==null?void 0:Y.yAxis)==null?void 0:Ie.title,text:o[1].length>100?`${o[1].substring(0,100)}...`:o[1],rotate90:!0})]}),v.jsx(Nr,{y1:l?X(0):H,y2:l?X(0):H,x1:-15,x2:U+15,classNames:{axis:(Ze=Y==null?void 0:Y.xAxis)==null?void 0:Ze.axis},styles:{axis:(Ke=N==null?void 0:N.xAxis)==null?void 0:Ke.axis}}),R.map((et,Pt)=>{var jt,Tt;return v.jsxs("g",{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:St=>{B(et),G(St.clientY),z(St.clientX),g&&g(et)},onClick:()=>{(w||k)&&(Sr(j,et)&&C?($(void 0),w==null||w(void 0)):($(et),w==null||w(et)))},onMouseMove:St=>{B(et),G(St.clientY),z(St.clientX)},onMouseLeave:()=>{B(void 0),z(void 0),G(void 0),g&&g(void 0)},children:[v.jsx("rect",{x:ee(`${Pt}`),y:et.bar?et.bar>0?X(et.bar):X(0):0,width:ee.bandwidth(),style:{fill:a},height:et.bar?Math.abs(X(et.bar)-X(0)):0}),m&&!Fe(et.bar)?v.jsx("text",{x:ee(`${et.id}`)+ee.bandwidth()/2,y:X(et.bar||0),style:{fill:a,textAnchor:"middle",...(N==null?void 0:N.graphObjectValues)||{}},className:Be("graph-value text-sm",Y==null?void 0:Y.graphObjectValues),dy:et.bar?et.bar>=0?"-5px":"1em":"-5px",children:_t(et.bar,M,T)}):null,S?v.jsx(f4,{value:`${et.label}`.length<b?`${et.label}`:`${`${et.label}`.substring(0,b)}...`,y:H+5,x:ee(`${et.id}`),width:ee.bandwidth(),height:ae.bottom,style:(jt=N==null?void 0:N.xAxis)==null?void 0:jt.labels,className:(Tt=Y==null?void 0:Y.xAxis)==null?void 0:Tt.labels,alignment:"top"}):null]},Pt)}),v.jsx("path",{d:ce(R),style:{stroke:i,fill:"none",strokeWidth:2}}),R.map((et,Pt)=>v.jsx("g",{children:Fe(et.line)?null:v.jsxs("g",{onMouseEnter:jt=>{B(et),G(jt.clientY),z(jt.clientX),g&&g(et)},onClick:()=>{(w||k)&&(Sr(j,et)&&C?($(void 0),w==null||w(void 0)):($(et),w==null||w(et)))},onMouseMove:jt=>{B(et),G(jt.clientY),z(jt.clientX)},onMouseLeave:()=>{B(void 0),z(void 0),G(void 0),g&&g(void 0)},children:[v.jsx("circle",{cx:ee(et.id)+ee.bandwidth()/2,cy:ie(et.line),r:U/R.length<5?0:U/R.length<20?2:4,style:{fill:i}}),m?v.jsx("text",{x:ee(`${et.id}`)+ee.bandwidth()/2,y:ie(et.line),style:{fill:i,textAnchor:"middle",...(N==null?void 0:N.graphObjectValues)||{}},className:Be("graph-value text-sm",Y==null?void 0:Y.graphObjectValues),dy:"-5px",children:_t(et.line,A,D)}):null]})},Pt))]})}),K&&d&&V&&W?v.jsx(yr,{data:K,body:d,xPos:V,yPos:W,backgroundStyle:N==null?void 0:N.tooltip,className:Y==null?void 0:Y.tooltip}):null,k?v.jsx(Tr,{open:j!==void 0,onClose:()=>{$(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(k,j)}})}):null]})}function tq(t){const{data:e,graphTitle:r,sources:n,graphDescription:a,height:i,width:o,footNote:l,padding:s,lineColor:f=Qe.light.categoricalColors.colors[1],barColor:c=Qe.light.categoricalColors.colors[0],sameAxes:h=!1,backgroundColor:d=!1,leftMargin:m=80,rightMargin:g=80,topMargin:y=20,bottomMargin:b=25,lineAxisTitle:S="Line chart",barAxisTitle:w="Bar graph",tooltip:C,relativeHeight:k,onSeriesMouseOver:_,graphID:D,graphDownload:T=!1,dataDownload:A=!1,barPadding:M=.25,truncateBy:E=999,showLabels:N=!0,onSeriesMouseClick:Y,language:ne="en",colorLegendTitle:K,minHeight:B=0,theme:j="light",ariaLabel:$,resetSelectionOnDoubleClick:V=!0,detailsOnClick:z,showValues:W=!0,noOfTicks:G=5,lineSuffix:ae="",barSuffix:U="",linePrefix:H="",barPrefix:R="",curveType:ee="curve",styles:J,classNames:Z}=t,[re,te]=I.useState(0),[F,q]=I.useState(0),X=I.useRef(null),ie=I.useRef(null);return I.useEffect(()=>{const ce=new ResizeObserver(de=>{te(o||de[0].target.clientWidth||620),q(i||de[0].target.clientHeight||480)});return X.current&&(q(X.current.clientHeight||480),te(X.current.clientWidth||620),o||ce.observe(X.current)),()=>ce.disconnect()},[o,i]),v.jsx("div",{className:`${j||"light"} flex ${o?"w-fit grow-0":"w-full grow"}`,dir:ne==="he"||ne==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${d?d===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${ne||"en"}`,Z==null?void 0:Z.graphContainer),style:{...(J==null?void 0:J.graphContainer)||{},...d&&d!==!0?{backgroundColor:d}:{}},id:D,ref:ie,"aria-label":$||`${r?`The graph shows ${r}. `:""}This is a pareto chart that shows a variable as bars and another as line chart.${a?` ${a}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:d?s||"1rem":s||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||a||T||A?v.jsx(Zt,{styles:{title:J==null?void 0:J.title,description:J==null?void 0:J.description},classNames:{title:Z==null?void 0:Z.title,description:Z==null?void 0:Z.description},graphTitle:r,graphDescription:a,width:o,graphDownload:T?ie.current:void 0,dataDownload:A?e.map(ce=>ce.data).filter(ce=>ce!==void 0).length>0?e.map(ce=>ce.data).filter(ce=>ce!==void 0):e.filter(ce=>ce!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[v.jsx(g0,{colorDomain:[w,S],colors:[c||Qe[j].categoricalColors.colors[0],f||Qe[j].categoricalColors.colors[1]],colorLegendTitle:K,showNAColor:!1}),v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:X,"aria-label":"Graph area",children:(o||re)&&(i||F)?v.jsx($ye,{data:e,sameAxes:h,lineColor:f,barColor:c,width:o||re,height:Math.max(B,i||(k?B?(o||re)*k>B?(o||re)*k:B:(o||re)*k:F)),truncateBy:E,leftMargin:m,rightMargin:g,topMargin:y,bottomMargin:b,axisTitles:[w,S],tooltip:C,onSeriesMouseOver:_,barPadding:M,showLabels:N,onSeriesMouseClick:Y,resetSelectionOnDoubleClick:V,detailsOnClick:z,noOfTicks:G,lineSuffix:ae,barSuffix:U,linePrefix:H,barPrefix:R,curveType:ee,showValues:W,styles:J,classNames:Z}):null})]})}),n||l?v.jsx(tr,{styles:{footnote:J==null?void 0:J.footnote,source:J==null?void 0:J.source},classNames:{footnote:Z==null?void 0:Z.footnote,source:Z==null?void 0:Z.source},sources:n,footNote:l,width:o}):null]})})})})}function Bye(t){var ce,de,he,Oe,Ne,Te,_e,xe,we,ge,ve,le,ue,Ce,pe,ye;const{data:e,width:r,height:n,barColors:a,centerGap:i,refValues:o,maxValue:l,minValue:s,showValues:f,axisTitles:c,rightMargin:h,leftMargin:d,topMargin:m,bottomMargin:g,tooltip:y,onSeriesMouseOver:b,barPadding:S,truncateBy:w,onSeriesMouseClick:C,showTicks:k,suffix:_,prefix:D,resetSelectionOnDoubleClick:T,detailsOnClick:A,styles:M,classNames:E,noOfTicks:N}=t,[Y,ne]=I.useState(void 0),[K,B]=I.useState(void 0),[j,$]=I.useState(void 0),[V,z]=I.useState(void 0),W={top:m,bottom:g,left:d,right:h},G=r-W.left-W.right,ae=n-W.top-W.bottom,U=e.map((be,je)=>({...be,id:`${je}`})),H=Un().domain(U.map(be=>`${be.id}`)).range([ae,0]).paddingInner(S),R=Fe(l)?Math.max(...e.filter(be=>!Fe(be.leftBar)).map(be=>be.leftBar))<0?0:Math.max(...e.filter(be=>!Fe(be.leftBar)).map(be=>be.leftBar)):l,ee=Fe(s)?Math.min(...e.filter(be=>!Fe(be.leftBar)).map(be=>be.leftBar))>=0?0:Math.min(...e.filter(be=>!Fe(be.leftBar)).map(be=>be.leftBar)):s,J=Fe(l)?Math.max(...e.filter(be=>!Fe(be.rightBar)).map(be=>be.rightBar))<0?0:Math.max(...e.filter(be=>!Fe(be.rightBar)).map(be=>be.rightBar)):l,Z=Fe(s)?Math.min(...e.filter(be=>!Fe(be.rightBar)).map(be=>be.rightBar))>=0?0:Math.min(...e.filter(be=>!Fe(be.rightBar)).map(be=>be.rightBar)):s,re=ee<Z?ee:Z,te=R>J?R:J,F=br().domain([re,te]).range([0,(G-i)/2]).nice(),q=F.ticks(N),X=br().domain([re,te]).range([(G-i)/2,0]).nice(),ie=X.ticks(N);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${W.left},${W.top})`,children:[v.jsxs("g",{transform:"translate(0,0)",children:[k?v.jsx(La,{values:ie.filter(be=>be!==0),x:ie.filter(be=>be!==0).map(be=>X(be)),y1:0-m,y2:ae+W.bottom,styles:{gridLines:(ce=M==null?void 0:M.xAxis)==null?void 0:ce.gridLines,labels:(de=M==null?void 0:M.xAxis)==null?void 0:de.labels},classNames:{gridLines:(he=E==null?void 0:E.xAxis)==null?void 0:he.gridLines,labels:(Oe=E==null?void 0:E.xAxis)==null?void 0:Oe.labels},suffix:_,prefix:D,labelType:"secondary",showGridLines:!0,leftLabel:!0}):null,U.map((be,je)=>v.jsxs("g",{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:$e=>{ne(be),z($e.clientY),$($e.clientX),b&&b(be)},onClick:()=>{(C||A)&&(Sr(K,be)&&T?(B(void 0),C==null||C(void 0)):(B(be),C==null||C(be)))},onMouseMove:$e=>{ne(be),z($e.clientY),$($e.clientX)},onMouseLeave:()=>{ne(void 0),$(void 0),z(void 0),b&&b(void 0)},children:[be.leftBar?v.jsx("rect",{x:be.leftBar<0?X(0):X(be.leftBar),y:H(`${je}`),width:be.leftBar<0?X(be.leftBar)-X(0):X(0)-X(be.leftBar),style:{fill:a[0]},height:H.bandwidth()}):null,f?v.jsx("text",{x:be.leftBar?X(be.leftBar):X(ee<0?0:ee),y:H(`${je}`)+H.bandwidth()/2,style:{fill:a[0],textAnchor:be.rightBar&&be.rightBar>0?"end":"start",...(M==null?void 0:M.graphObjectValues)||{}},dx:be.rightBar&&be.rightBar>0?-5:5,dy:"0.33em",className:Be("graph-value text-sm",E==null?void 0:E.graphObjectValues),children:_t(be.rightBar,D,_)}):null]},je)),v.jsx(Nr,{y1:-2.5,y2:ae+W.bottom,x1:X(ee<0?0:ee),x2:X(ee<0?0:ee),classNames:{axis:(Ne=E==null?void 0:E.yAxis)==null?void 0:Ne.axis},styles:{axis:(Te=M==null?void 0:M.yAxis)==null?void 0:Te.axis}}),o?v.jsx(v.Fragment,{children:o.map((be,je)=>v.jsx(ti,{text:be.text,color:be.color,x:X(be.value),y1:0-W.top,y2:ae+W.bottom,textSide:"left",classNames:be.classNames,styles:be.styles},je))}):null]}),v.jsxs("g",{transform:`translate(${(G+i)/2},0)`,children:[k?v.jsx(La,{values:q.filter(be=>be!==0),x:q.filter(be=>be!==0).map(be=>F(be)),y1:0-m,y2:ae+W.bottom,styles:{gridLines:(_e=M==null?void 0:M.xAxis)==null?void 0:_e.gridLines,labels:(xe=M==null?void 0:M.xAxis)==null?void 0:xe.labels},classNames:{gridLines:(we=E==null?void 0:E.xAxis)==null?void 0:we.gridLines,labels:(ge=E==null?void 0:E.xAxis)==null?void 0:ge.labels},suffix:_,prefix:D,labelType:"secondary",showGridLines:!0}):null,U.map((be,je)=>v.jsxs("g",{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:$e=>{ne(be),z($e.clientY),$($e.clientX),b&&b(be)},onClick:()=>{(C||A)&&(Sr(K,be)&&T?(B(void 0),C==null||C(void 0)):(B(be),C==null||C(be)))},onMouseMove:$e=>{ne(be),z($e.clientY),$($e.clientX)},onMouseLeave:()=>{ne(void 0),$(void 0),z(void 0),b&&b(void 0)},children:[be.rightBar?v.jsx("rect",{x:be.rightBar>=0?F(0):F(be.rightBar),y:H(`${je}`),width:be.rightBar>=0?F(be.rightBar)-F(0):F(0)-F(be.rightBar),style:{fill:a[1]},height:H.bandwidth()}):null,f?v.jsx("text",{x:be.rightBar?F(be.rightBar):F(Z<0?0:Z),y:H(`${je}`)+H.bandwidth()/2,style:{fill:a[1],textAnchor:be.rightBar&&be.rightBar<0?"end":"start",...(M==null?void 0:M.graphObjectValues)||{}},className:Be("graph-value text-sm",E==null?void 0:E.graphObjectValues),dx:be.rightBar&&be.rightBar<0?-5:5,dy:"0.33em",children:_t(be.rightBar,D,_)}):null]},je)),v.jsx(Nr,{y1:-2.5,y2:ae+W.bottom,x1:F(Z<0?0:Z),x2:F(Z<0?0:Z),classNames:{axis:(ve=E==null?void 0:E.yAxis)==null?void 0:ve.axis},styles:{axis:(le=M==null?void 0:M.yAxis)==null?void 0:le.axis}}),o?v.jsx(v.Fragment,{children:o.map((be,je)=>v.jsx(ti,{text:be.text,color:be.color,x:F(be.value),y1:0-W.top,y2:ae+W.bottom,textSide:"right",classNames:be.classNames,styles:be.styles},je))}):null]}),v.jsx("g",{transform:`translate(${G/2},0)`,children:U.map((be,je)=>{var $e,ut;return v.jsx(Y2,{value:`${be.label}`.length<w?`${be.label}`:`${`${be.label}`.substring(0,w)}...`,y:H(`${be.id}`),x:0-i/2,width:i,height:H.bandwidth(),alignment:"center",style:($e=M==null?void 0:M.yAxis)==null?void 0:$e.labels,className:(ut=E==null?void 0:E.yAxis)==null?void 0:ut.labels},je)})}),v.jsxs("g",{transform:`translate(0,${ae})`,children:[v.jsx("text",{style:{fill:a[0],textAnchor:"end",...(ue=M==null?void 0:M.yAxis)==null?void 0:ue.title},className:Be("text-base",(Ce=E==null?void 0:E.yAxis)==null?void 0:Ce.title),x:G/2-i/2,y:0,dx:-5,dy:20,children:c[0]}),v.jsx("text",{style:{fill:a[1],textAnchor:"start",...(pe=M==null?void 0:M.yAxis)==null?void 0:pe.title},className:Be("text-base",(ye=E==null?void 0:E.yAxis)==null?void 0:ye.title),x:G/2+i/2,y:0,dx:5,dy:20,children:c[1]})]})]})}),Y&&y&&j&&V?v.jsx(yr,{data:Y,body:y,xPos:j,yPos:V,backgroundStyle:M==null?void 0:M.tooltip,className:E==null?void 0:E.tooltip}):null,A?v.jsx(Tr,{open:K!==void 0,onClose:()=>{B(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(A,K)}})}):null]})}function rq(t){const{data:e,graphTitle:r,sources:n,graphDescription:a,height:i,width:o,footNote:l,padding:s,leftBarColor:f=Qe.light.categoricalColors.colors[0],rightBarColor:c=Qe.light.categoricalColors.colors[1],backgroundColor:h=!1,leftMargin:d=20,rightMargin:m=20,topMargin:g=25,bottomMargin:y=30,rightBarTitle:b="Right bar graph",leftBarTitle:S="Left bar graph",tooltip:w,relativeHeight:C,onSeriesMouseOver:k,graphID:_,barPadding:D=.25,truncateBy:T=999,onSeriesMouseClick:A,centerGap:M=100,showValues:E=!0,maxValue:N,minValue:Y,refValues:ne=[],suffix:K="",prefix:B="",showTicks:j=!0,showColorScale:$=!1,graphDownload:V=!1,dataDownload:z=!1,language:W="en",colorLegendTitle:G,minHeight:ae=0,theme:U="light",ariaLabel:H,resetSelectionOnDoubleClick:R=!0,detailsOnClick:ee,styles:J,classNames:Z,noOfTicks:re=5}=t,[te,F]=I.useState(0),[q,X]=I.useState(0),ie=I.useRef(null),ce=I.useRef(null);return I.useEffect(()=>{const de=new ResizeObserver(he=>{F(o||he[0].target.clientWidth||620),X(i||he[0].target.clientHeight||480)});return ie.current&&(X(ie.current.clientHeight||480),F(ie.current.clientWidth||620),o||de.observe(ie.current)),()=>de.disconnect()},[o,i]),v.jsx("div",{className:`${U||"light"} flex ${o?"w-fit grow-0":"w-full grow"}`,dir:W==="he"||W==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${h?h===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${W||"en"}`,Z==null?void 0:Z.graphContainer),style:{...(J==null?void 0:J.graphContainer)||{},...h&&h!==!0?{backgroundColor:h}:{}},id:_,ref:ce,"aria-label":H||`${r?`The graph shows ${r}. `:""}This is a diverging bar chart. ${a?` ${a}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:h?s||"1rem":s||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||a||V||z?v.jsx(Zt,{styles:{title:J==null?void 0:J.title,description:J==null?void 0:J.description},classNames:{title:Z==null?void 0:Z.title,description:Z==null?void 0:Z.description},graphTitle:r,graphDescription:a,width:o,graphDownload:V?ce.current:void 0,dataDownload:z?e.map(de=>de.data).filter(de=>de!==void 0).length>0?e.map(de=>de.data).filter(de=>de!==void 0):e.filter(de=>de!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[$?v.jsx(g0,{colorLegendTitle:G,colorDomain:[S,b],colors:[f,c],showNAColor:!1}):null,v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:ie,"aria-label":"Graph area",children:(o||te)&&(i||q)?v.jsx(Bye,{data:e,barColors:[f,c],width:o||te,centerGap:M,height:Math.max(ae,i||(C?ae?(o||te)*C>ae?(o||te)*C:ae:(o||te)*C:q)),truncateBy:T,leftMargin:d,rightMargin:m,topMargin:g,bottomMargin:y,axisTitles:[S,b],tooltip:w,onSeriesMouseOver:k,barPadding:D,refValues:ne,maxValue:N,minValue:Y,showValues:E,onSeriesMouseClick:A,showTicks:j,suffix:K,prefix:B,resetSelectionOnDoubleClick:R,detailsOnClick:ee,styles:J,classNames:Z,noOfTicks:re}):null})]})}),n||l?v.jsx(tr,{styles:{footnote:J==null?void 0:J.footnote,source:J==null?void 0:J.source},classNames:{footnote:Z==null?void 0:Z.footnote,source:Z==null?void 0:Z.source},sources:n,footNote:l,width:o}):null]})})})})}function nq(t){const{data:e,graphTitle:r,sources:n,graphDescription:a,barPadding:i,showValues:o,showTicks:l,leftMargin:s,rightMargin:f,height:c,width:h,footNote:d,colors:m,padding:g,backgroundColor:y,topMargin:b,bottomMargin:S,showLabels:w,relativeHeight:C,tooltip:k,onSeriesMouseOver:_,refValues:D,graphID:T,maxValue:A,onSeriesMouseClick:M,graphDownload:E,dataDownload:N,numberOfBins:Y,truncateBy:ne,graphType:K,barGraphLayout:B,donutStrokeWidth:j,sortData:$,language:V,minHeight:z,theme:W="light",maxBarThickness:G,ariaLabel:ae,detailsOnClick:U,styles:H,classNames:R}=t,[ee,J]=I.useState([]);return I.useEffect(()=>{const re=Lie().thresholds(Y||10).value(te=>te.value)(e).map(te=>({label:`${te.x0}-${te.x1}`,size:te.length,data:{options:`${te.x0}-${te.x1}`,frequency:te.length}}));J(re)},[e,Y]),ee.length===0?v.jsx("div",{style:{width:`${h}px`,height:`${c}px`,margin:"auto"},children:v.jsx("div",{className:"flex m-auto items-center justify-center p-0 leading-none text-base h-40",children:v.jsx(Fo,{})})}):K==="circlePacking"?v.jsx(Qb,{colors:m||Qe.graphMainColor,graphTitle:r,graphDescription:a,footNote:d,width:h,height:c,sources:n,leftMargin:s,rightMargin:f,backgroundColor:y,padding:g,topMargin:b,bottomMargin:S,relativeHeight:C,showLabels:w,tooltip:k,onSeriesMouseOver:_,showColorScale:!1,showValues:o,graphID:T,onSeriesMouseClick:M,graphDownload:E,dataDownload:N,data:ee,language:V,minHeight:z,theme:W,ariaLabel:ae,detailsOnClick:U,styles:H,classNames:R}):K==="treeMap"?v.jsx(mw,{colors:m||Qe.graphMainColor,graphTitle:r,graphDescription:a,footNote:d,width:h,height:c,sources:n,leftMargin:s,rightMargin:f,backgroundColor:y,padding:g,topMargin:b,bottomMargin:S,relativeHeight:C,showLabels:w,tooltip:k,onSeriesMouseOver:_,showColorScale:!1,showValues:o,graphID:T,onSeriesMouseClick:M,graphDownload:E,dataDownload:N,data:ee,language:V,minHeight:z,theme:W,ariaLabel:ae,detailsOnClick:U,styles:H,classNames:R}):K==="donutChart"?v.jsx(rx,{colors:m||Qe[W].categoricalColors.colors,graphTitle:r,graphDescription:a,footNote:d,radius:h&&c?h<c?h:c:h||c||void 0,sources:n,backgroundColor:y,padding:g,tooltip:k,onSeriesMouseOver:_,graphID:T,onSeriesMouseClick:M,graphDownload:E,dataDownload:N,data:ee,strokeWidth:j,showColorScale:!0,sortData:$,language:V,theme:W,ariaLabel:ae,detailsOnClick:U,styles:H,classNames:R}):v.jsx(Hb,{colors:m||Qe.graphMainColor,graphTitle:r,graphDescription:a,footNote:d,width:h,height:c,sources:n,leftMargin:s,rightMargin:f,backgroundColor:y,padding:g,topMargin:b,bottomMargin:S,relativeHeight:C,showLabels:w,tooltip:k,onSeriesMouseOver:_,showColorScale:!1,showValues:o,graphID:T,onSeriesMouseClick:M,graphDownload:E,dataDownload:N,data:ee,barPadding:i,refValues:D,truncateBy:ne,maxValue:A,showTicks:l,sortData:$,language:V,minHeight:z,theme:W,maxBarThickness:G,ariaLabel:ae,orientation:B,detailsOnClick:U,styles:H,classNames:R})}function HM(t,e){let r;if(e===void 0)for(const n of t)n!=null&&(r<n||r===void 0&&n>=n)&&(r=n);else{let n=-1;for(let a of t)(a=e(a,++n,t))!=null&&(r<a||r===void 0&&a>=a)&&(r=a)}return r}function aq(t,e){let r;if(e===void 0)for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);else{let n=-1;for(let a of t)(a=e(a,++n,t))!=null&&(r>a||r===void 0&&a>=a)&&(r=a)}return r}function _m(t,e){let r=0;if(e===void 0)for(let n of t)(n=+n)&&(r+=n);else{let n=-1;for(let a of t)(a=+e(a,++n,t))&&(r+=a)}return r}function Vye(t){return t.target.depth}function Fye(t,e){return t.sourceLinks.length?t.depth:e-1}function Om(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?aq(t.sourceLinks,Vye)-1:0}function x5(t){return function(){return t}}function qM(t,e){return Pc(t.source,e.source)||t.index-e.index}function WM(t,e){return Pc(t.target,e.target)||t.index-e.index}function Pc(t,e){return t.y0-e.y0}function Dm(t){return t.value}function zye(t){return t.index}function Hye(t){return t.nodes}function qye(t){return t.links}function UM(t,e){const r=t.get(e);if(!r)throw new Error("missing: "+e);return r}function GM({nodes:t}){for(const e of t){let r=e.y0,n=r;for(const a of e.sourceLinks)a.y0=r+a.width/2,r+=a.width;for(const a of e.targetLinks)a.y1=n+a.width/2,n+=a.width}}function Am(){let t=0,e=0,r=1,n=1,a=24,i=8,o,l=zye,s=Fye,f,c,h=Hye,d=qye,m=6;function g(){const B={nodes:h.apply(null,arguments),links:d.apply(null,arguments)};return y(B),b(B),S(B),w(B),_(B),GM(B),B}g.update=function(B){return GM(B),B},g.nodeId=function(B){return arguments.length?(l=typeof B=="function"?B:x5(B),g):l},g.nodeAlign=function(B){return arguments.length?(s=typeof B=="function"?B:x5(B),g):s},g.nodeSort=function(B){return arguments.length?(f=B,g):f},g.nodeWidth=function(B){return arguments.length?(a=+B,g):a},g.nodePadding=function(B){return arguments.length?(i=o=+B,g):i},g.nodes=function(B){return arguments.length?(h=typeof B=="function"?B:x5(B),g):h},g.links=function(B){return arguments.length?(d=typeof B=="function"?B:x5(B),g):d},g.linkSort=function(B){return arguments.length?(c=B,g):c},g.size=function(B){return arguments.length?(t=e=0,r=+B[0],n=+B[1],g):[r-t,n-e]},g.extent=function(B){return arguments.length?(t=+B[0][0],r=+B[1][0],e=+B[0][1],n=+B[1][1],g):[[t,e],[r,n]]},g.iterations=function(B){return arguments.length?(m=+B,g):m};function y({nodes:B,links:j}){for(const[V,z]of B.entries())z.index=V,z.sourceLinks=[],z.targetLinks=[];const $=new Map(B.map((V,z)=>[l(V,z,B),V]));for(const[V,z]of j.entries()){z.index=V;let{source:W,target:G}=z;typeof W!="object"&&(W=z.source=UM($,W)),typeof G!="object"&&(G=z.target=UM($,G)),W.sourceLinks.push(z),G.targetLinks.push(z)}if(c!=null)for(const{sourceLinks:V,targetLinks:z}of B)V.sort(c),z.sort(c)}function b({nodes:B}){for(const j of B)j.value=j.fixedValue===void 0?Math.max(_m(j.sourceLinks,Dm),_m(j.targetLinks,Dm)):j.fixedValue}function S({nodes:B}){const j=B.length;let $=new Set(B),V=new Set,z=0;for(;$.size;){for(const W of $){W.depth=z;for(const{target:G}of W.sourceLinks)V.add(G)}if(++z>j)throw new Error("circular link");$=V,V=new Set}}function w({nodes:B}){const j=B.length;let $=new Set(B),V=new Set,z=0;for(;$.size;){for(const W of $){W.height=z;for(const{source:G}of W.targetLinks)V.add(G)}if(++z>j)throw new Error("circular link");$=V,V=new Set}}function C({nodes:B}){const j=HM(B,z=>z.depth)+1,$=(r-t-a)/(j-1),V=new Array(j);for(const z of B){const W=Math.max(0,Math.min(j-1,Math.floor(s.call(null,z,j))));z.layer=W,z.x0=t+W*$,z.x1=z.x0+a,V[W]?V[W].push(z):V[W]=[z]}if(f)for(const z of V)z.sort(f);return V}function k(B){const j=aq(B,$=>(n-e-($.length-1)*o)/_m($,Dm));for(const $ of B){let V=e;for(const z of $){z.y0=V,z.y1=V+z.value*j,V=z.y1+o;for(const W of z.sourceLinks)W.width=W.value*j}V=(n-V+o)/($.length+1);for(let z=0;z<$.length;++z){const W=$[z];W.y0+=V*(z+1),W.y1+=V*(z+1)}Y($)}}function _(B){const j=C(B);o=Math.min(i,(n-e)/(HM(j,$=>$.length)-1)),k(j);for(let $=0;$<m;++$){const V=Math.pow(.99,$),z=Math.max(1-V,($+1)/m);T(j,V,z),D(j,V,z)}}function D(B,j,$){for(let V=1,z=B.length;V<z;++V){const W=B[V];for(const G of W){let ae=0,U=0;for(const{source:R,value:ee}of G.targetLinks){let J=ee*(G.layer-R.layer);ae+=ne(R,G)*J,U+=J}if(!(U>0))continue;let H=(ae/U-G.y0)*j;G.y0+=H,G.y1+=H,N(G)}f===void 0&&W.sort(Pc),A(W,$)}}function T(B,j,$){for(let V=B.length,z=V-2;z>=0;--z){const W=B[z];for(const G of W){let ae=0,U=0;for(const{target:R,value:ee}of G.sourceLinks){let J=ee*(R.layer-G.layer);ae+=K(G,R)*J,U+=J}if(!(U>0))continue;let H=(ae/U-G.y0)*j;G.y0+=H,G.y1+=H,N(G)}f===void 0&&W.sort(Pc),A(W,$)}}function A(B,j){const $=B.length>>1,V=B[$];E(B,V.y0-o,$-1,j),M(B,V.y1+o,$+1,j),E(B,n,B.length-1,j),M(B,e,0,j)}function M(B,j,$,V){for(;$<B.length;++$){const z=B[$],W=(j-z.y0)*V;W>1e-6&&(z.y0+=W,z.y1+=W),j=z.y1+o}}function E(B,j,$,V){for(;$>=0;--$){const z=B[$],W=(z.y1-j)*V;W>1e-6&&(z.y0-=W,z.y1-=W),j=z.y0-o}}function N({sourceLinks:B,targetLinks:j}){if(c===void 0){for(const{source:{sourceLinks:$}}of j)$.sort(WM);for(const{target:{targetLinks:$}}of B)$.sort(qM)}}function Y(B){if(c===void 0)for(const{sourceLinks:j,targetLinks:$}of B)j.sort(WM),$.sort(qM)}function ne(B,j){let $=B.y0-(B.sourceLinks.length-1)*o/2;for(const{target:V,width:z}of B.sourceLinks){if(V===j)break;$+=z+o}for(const{source:V,width:z}of j.targetLinks){if(V===B)break;$-=z}return $}function K(B,j){let $=j.y0-(j.targetLinks.length-1)*o/2;for(const{source:V,width:z}of j.targetLinks){if(V===B)break;$+=z+o}for(const{target:V,width:z}of B.sourceLinks){if(V===j)break;$-=z}return $}return g}var rv=Math.PI,nv=2*rv,T3=1e-6,Wye=nv-T3;function av(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function iq(){return new av}av.prototype=iq.prototype={constructor:av,moveTo:function(t,e){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(t,e){this._+="L"+(this._x1=+t)+","+(this._y1=+e)},quadraticCurveTo:function(t,e,r,n){this._+="Q"+ +t+","+ +e+","+(this._x1=+r)+","+(this._y1=+n)},bezierCurveTo:function(t,e,r,n,a,i){this._+="C"+ +t+","+ +e+","+ +r+","+ +n+","+(this._x1=+a)+","+(this._y1=+i)},arcTo:function(t,e,r,n,a){t=+t,e=+e,r=+r,n=+n,a=+a;var i=this._x1,o=this._y1,l=r-t,s=n-e,f=i-t,c=o-e,h=f*f+c*c;if(a<0)throw new Error("negative radius: "+a);if(this._x1===null)this._+="M"+(this._x1=t)+","+(this._y1=e);else if(h>T3)if(!(Math.abs(c*l-s*f)>T3)||!a)this._+="L"+(this._x1=t)+","+(this._y1=e);else{var d=r-i,m=n-o,g=l*l+s*s,y=d*d+m*m,b=Math.sqrt(g),S=Math.sqrt(h),w=a*Math.tan((rv-Math.acos((g+h-y)/(2*b*S)))/2),C=w/S,k=w/b;Math.abs(C-1)>T3&&(this._+="L"+(t+C*f)+","+(e+C*c)),this._+="A"+a+","+a+",0,0,"+ +(c*d>f*m)+","+(this._x1=t+k*l)+","+(this._y1=e+k*s)}},arc:function(t,e,r,n,a,i){t=+t,e=+e,r=+r,i=!!i;var o=r*Math.cos(n),l=r*Math.sin(n),s=t+o,f=e+l,c=1^i,h=i?n-a:a-n;if(r<0)throw new Error("negative radius: "+r);this._x1===null?this._+="M"+s+","+f:(Math.abs(this._x1-s)>T3||Math.abs(this._y1-f)>T3)&&(this._+="L"+s+","+f),r&&(h<0&&(h=h%nv+nv),h>Wye?this._+="A"+r+","+r+",0,1,"+c+","+(t-o)+","+(e-l)+"A"+r+","+r+",0,1,"+c+","+(this._x1=s)+","+(this._y1=f):h>T3&&(this._+="A"+r+","+r+",0,"+ +(h>=rv)+","+c+","+(this._x1=t+r*Math.cos(a))+","+(this._y1=e+r*Math.sin(a))))},rect:function(t,e,r,n){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)+"h"+ +r+"v"+ +n+"h"+-r+"Z"},toString:function(){return this._}};function YM(t){return function(){return t}}function Uye(t){return t[0]}function Gye(t){return t[1]}var Yye=Array.prototype.slice;function Xye(t){return t.source}function Kye(t){return t.target}function Jye(t){var e=Xye,r=Kye,n=Uye,a=Gye,i=null;function o(){var l,s=Yye.call(arguments),f=e.apply(this,s),c=r.apply(this,s);if(i||(i=l=iq()),t(i,+n.apply(this,(s[0]=f,s)),+a.apply(this,s),+n.apply(this,(s[0]=c,s)),+a.apply(this,s)),l)return i=null,l+""||null}return o.source=function(l){return arguments.length?(e=l,o):e},o.target=function(l){return arguments.length?(r=l,o):r},o.x=function(l){return arguments.length?(n=typeof l=="function"?l:YM(+l),o):n},o.y=function(l){return arguments.length?(a=typeof l=="function"?l:YM(+l),o):a},o.context=function(l){return arguments.length?(i=l??null,o):i},o}function Zye(t,e,r,n,a){t.moveTo(e,r),t.bezierCurveTo(e=(e+n)/2,r,e,a,n,a)}function Qye(){return Jye(Zye)}function eve(t){return[t.source.x1,t.y0]}function tve(t){return[t.target.x0,t.y1]}function rve(){return Qye().source(eve).target(tve)}function nve(t){const{data:e,showLabels:r,leftMargin:n,rightMargin:a,truncateBy:i,width:o,height:l,topMargin:s,bottomMargin:f,tooltip:c,onSeriesMouseOver:h,suffix:d,prefix:m,showValues:g,onSeriesMouseClick:y,nodePadding:b,nodeWidth:S,id:w,highlightedSourceDataPoints:C,highlightedTargetDataPoints:k,defaultLinkOpacity:_,sourceTitle:D,targetTitle:T,animateLinks:A,sortNodes:M,resetSelectionOnDoubleClick:E,detailsOnClick:N,styles:Y,classNames:ne}=t,[K,B]=Xa(),j=d4(K);I.useEffect(()=>{j&&e&&B("path",{pathLength:[0,1]},{duration:A===!0?5:A||0})},[j,e,B,A]);const[$,V]=I.useState(void 0),[z,W]=I.useState(void 0),[G,ae]=I.useState(void 0),[U,H]=I.useState(void 0),[R,ee]=I.useState(void 0),J={top:s,bottom:f,left:n,right:a},Z=o-J.left-J.right,re=l-J.top-J.bottom,te=M==="mostReadable"?Am().nodeWidth(S).nodePadding(b).size([Z,re]).nodeAlign(Om):M==="none"?Am().nodeWidth(S).nodePadding(b).size([Z,re]).nodeAlign(Om).nodeSort(()=>null).linkSort(()=>null):Am().nodeWidth(S).nodePadding(b).size([Z,re]).nodeAlign(Om).nodeSort(M==="desc"?(ie,ce)=>(ce.value||0)-(ie.value||0):(ie,ce)=>(ie.value||0)-(ce.value||0)),{nodes:F,links:q}=te(e),X=rve();return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{width:`${o}px`,height:`${l}px`,viewBox:`0 0 ${o} ${l}`,style:{marginLeft:"auto",marginRight:"auto"},direction:"ltr",children:[D?v.jsx("text",{x:J.left,y:J.top-10,className:"text-base font-bold fill-primary-gray-700 dark:fill-primary-gray-100",style:{textAnchor:"start"},children:D}):null,T?v.jsx("text",{x:o-J.right,y:J.top-10,className:"text-base font-bold fill-primary-gray-700 dark:fill-primary-gray-100",style:{textAnchor:"end"},children:T}):null,v.jsxs("g",{transform:`translate(${J.left},${J.top})`,children:[F.filter(ie=>ie.type==="source").map((ie,ce)=>v.jsx("g",{onMouseEnter:()=>{ae(ie)},onMouseLeave:()=>{ae(void 0)},children:v.jsxs("g",{transform:`translate(${ie.x0},${ie.y0})`,children:[v.jsx("rect",{x:0,y:0,width:(ie.x1||0)-(ie.x0||0),height:(ie.y1||0)-(ie.y0||0),style:{fill:ie.color}}),r||g?v.jsx("foreignObject",{y:0-b/2,x:0-n,width:n,height:(ie.y1||0)-(ie.y0||0)+b,children:v.jsxs("div",{className:"flex flex-col gap-0.5 justify-center py-0 px-1.5",style:{height:`${(ie.y1||0)-(ie.y0||0)+b}px`,overflow:"visible"},children:[r?v.jsx(or,{marginBottom:g?"3xs":"none",size:"sm",leading:"none",className:Be("sankey-right-label text-right",ne==null?void 0:ne.graphObjectValues),style:{hyphens:"auto",color:ie.color,...Y==null?void 0:Y.graphObjectValues},children:`${ie.label}`.length<i?`${ie.label}`:`${`${ie.label}`.substring(0,i)}...`}):null,g?v.jsx(or,{marginBottom:"none",size:"sm",leading:"none",className:Be("sankey-right-value text-right font-bold",ne==null?void 0:ne.graphObjectValues),style:{hyphens:"auto",color:ie.color,...Y==null?void 0:Y.graphObjectValues},children:_t(ie.value,m,d)}):null]})}):null]})},ce)),F.filter(ie=>ie.type==="target").map((ie,ce)=>v.jsx("g",{onMouseEnter:()=>{ae(ie)},onMouseLeave:()=>{ae(void 0)},children:v.jsxs("g",{transform:`translate(${ie.x0},${ie.y0})`,children:[v.jsx("rect",{x:0,y:0,width:(ie.x1||0)-(ie.x0||0),height:(ie.y1||0)-(ie.y0||0),style:{fill:ie.color}}),r||g?v.jsx("foreignObject",{y:0-b/2,x:S,width:a-S,height:(ie.y1||0)-(ie.y0||0)+b,children:v.jsxs("div",{className:"flex flex-col gap-0.5 justify-center py-0 px-1.5",style:{height:`${(ie.y1||0)-(ie.y0||0)+b}px`},children:[r?v.jsx(or,{marginBottom:g?"3xs":"none",size:"sm",leading:"none",className:Be("sankey-left-label text-left",ne==null?void 0:ne.graphObjectValues),style:{hyphens:"auto",color:ie.color,...Y==null?void 0:Y.graphObjectValues},children:`${ie.label}`.length<i?`${ie.label}`:`${`${ie.label}`.substring(0,i)}...`}):null,g?v.jsx(or,{size:"sm",leading:"none",marginBottom:"none",className:Be("sankey-left-value text-left font-bold",ne==null?void 0:ne.graphObjectValues),style:{hyphens:"auto",color:ie.color,...Y==null?void 0:Y.graphObjectValues},children:_t(ie.value,m,d)}):null]})}):null]})},ce)),v.jsx("defs",{children:q.map((ie,ce)=>v.jsxs("linearGradient",{id:`${w}-gradient-${ce}`,x1:"0%",y1:"0%",x2:"100%",y2:"0%",gradientUnits:"userSpaceOnUse",children:[v.jsx("stop",{offset:"0%",style:{stopColor:ie.source.color,stopOpacity:1}}),v.jsx("stop",{offset:"100%",style:{stopColor:ie.target.color,stopOpacity:1}})]},ce))}),v.jsx("g",{ref:K,children:q.map((ie,ce)=>v.jsx("g",{className:"undp-viz-g-with-hover",onMouseEnter:de=>{V(ie.data),ee(de.clientY),H(de.clientX),h==null||h(ie.data)},onMouseMove:de=>{V(ie.data),ee(de.clientY),H(de.clientX)},onClick:()=>{(y||N)&&(Sr(z,ie.data)&&E?(W(void 0),y==null||y(void 0)):(W(ie.data),y==null||y(ie.data)))},onMouseLeave:()=>{V(void 0),H(void 0),ee(void 0),h&&h(void 0)},opacity:G?ie.source.name===G.name||ie.target.name===G.name?.85:_:(C.length!==0||k.length!==0)&&(C.indexOf(ie.source.label)!==-1||k.indexOf(ie.target.label)!==-1)?.85:_,children:v.jsx("path",{d:X(ie)||"",style:{stroke:`url(#${w}-gradient-${ce})`,strokeWidth:ie.width,fill:"none"}})},ce))})]})]}),$&&c&&U&&R?v.jsx(yr,{data:$,body:c,xPos:U,yPos:R,backgroundStyle:Y==null?void 0:Y.tooltip,className:ne==null?void 0:ne.tooltip}):null,N?v.jsx(Tr,{open:z!==void 0,onClose:()=>{W(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(N,z)}})}):null]})}function oq(t){const{data:e,graphTitle:r,sources:n,graphDescription:a,showLabels:i=!0,leftMargin:o=75,rightMargin:l=75,topMargin:s=30,bottomMargin:f=10,truncateBy:c=999,height:h,width:d,footNote:m,padding:g,backgroundColor:y,tooltip:b,onSeriesMouseOver:S,suffix:w="",prefix:C="",relativeHeight:k,showValues:_=!0,graphID:D,onSeriesMouseClick:T,graphDownload:A=!1,dataDownload:M=!1,fillContainer:E=!0,language:N="en",minHeight:Y=0,theme:ne="light",ariaLabel:K,sourceColors:B,targetColors:j,sourceColorDomain:$,targetColorDomain:V,nodePadding:z=5,nodeWidth:W=5,highlightedSourceDataPoints:G=[],highlightedTargetDataPoints:ae=[],defaultLinkOpacity:U=.3,sourceTitle:H,targetTitle:R,animateLinks:ee,sortNodes:J="mostReadable",resetSelectionOnDoubleClick:Z=!0,detailsOnClick:re,styles:te,classNames:F}=t,[q,X]=I.useState(0),[ie,ce]=I.useState(0),[de,he]=I.useState(void 0),Oe=I.useRef(null),Ne=I.useRef(null);return I.useEffect(()=>{const Te=Bt(e,"source").map(ve=>({name:`source_${ve.source}`,type:"source",label:`${ve.source}`,color:typeof B=="string"||!B?B||Qe.graphMainColor:B[($||Bt(e,"source").map(le=>`${le.source}`)).findIndex(le=>`${le}`==`${ve.source}`)>B.length?B.length-1:($||Bt(e,"source").map(le=>`${le.source}`)).findIndex(le=>`${le}`==`${ve.source}`)],totalValue:fr(e.filter(le=>`${le.source}`==`${ve.source}`).map(le=>le.value))})),_e=J==="asc"?Ut(Te,ve=>ve.totalValue):J==="desc"?Ut(Te,ve=>ve.totalValue).reverse():Te,xe=Bt(e,"target").map(ve=>({name:`target_${ve.target}`,type:"target",label:`${ve.target}`,color:typeof j=="string"||!j?j||Qe.graphMainColor:j[(V||Bt(e,"target").map(le=>`${le.target}`)).findIndex(le=>`${le}`==`${ve.target}`)>j.length?j.length-1:(V||Bt(e,"target").map(le=>`${le.target}`)).findIndex(le=>`${le}`==`${ve.target}`)],totalValue:fr(e.filter(le=>`${le.target}`==`${ve.target}`).map(le=>le.value))})),we=J==="asc"?Ut(xe,ve=>ve.totalValue):J==="desc"?Ut(xe,ve=>ve.totalValue).reverse():xe,ge=[..._e,...we];he({nodes:ge,links:e.map(ve=>({source:ge.findIndex(le=>le.name===`source_${ve.source}`),target:ge.findIndex(le=>le.name===`target_${ve.target}`),value:ve.value,data:{...ve}}))})},[e,J,$,B,V,j]),I.useEffect(()=>{const Te=new ResizeObserver(_e=>{X(d||_e[0].target.clientWidth||620),ce(h||_e[0].target.clientHeight||480)});return Oe.current&&(ce(Oe.current.clientHeight||480),X(Oe.current.clientWidth||620),d||Te.observe(Oe.current)),()=>Te.disconnect()},[d,h]),v.jsx("div",{className:`${ne||"light"} flex ${d?"grow-0":"grow"} ${E?"w-full":"w-fit"} `,dir:N==="he"||N==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${y?y===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${N||"en"}`,F==null?void 0:F.graphContainer),style:{...(te==null?void 0:te.graphContainer)||{},...y&&y!==!0?{backgroundColor:y}:{}},id:D,ref:Ne,"aria-label":K||`${r?`The graph shows ${r}. `:""}This is a sankey chart showing flow. ${a?` ${a}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:y?g||"1rem":g||0},children:v.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[r||a||A||M?v.jsx(Zt,{styles:{title:te==null?void 0:te.title,description:te==null?void 0:te.description},classNames:{title:F==null?void 0:F.title,description:F==null?void 0:F.description},graphTitle:r,graphDescription:a,width:d,graphDownload:A?Ne.current:void 0,dataDownload:M?e.map(Te=>Te.data).filter(Te=>Te!==void 0).length>0?e.map(Te=>Te.data).filter(Te=>Te!==void 0):e.filter(Te=>Te!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsx("div",{className:"flex flex-col grow justify-center gap-3 w-full leading-0",ref:Oe,"aria-label":"Graph area",children:(d||q)&&(h||ie)&&de?v.jsx(nve,{data:de,width:d||q,nodePadding:z,nodeWidth:W,height:Math.max(Y,h||(k?Y?(d||q)*k>Y?(d||q)*k:Y:(d||q)*k:ie)),showLabels:i,leftMargin:o,rightMargin:l,topMargin:s,bottomMargin:f,truncateBy:c,tooltip:b,onSeriesMouseOver:S,showValues:_,suffix:w,prefix:C,onSeriesMouseClick:T,id:Wx(8),highlightedSourceDataPoints:G.map(Te=>`${Te}`),highlightedTargetDataPoints:ae.map(Te=>`${Te}`),defaultLinkOpacity:U,sourceTitle:H,targetTitle:R,animateLinks:ee,sortNodes:J,resetSelectionOnDoubleClick:Z,styles:te,classNames:F,detailsOnClick:re}):null})}),n||m?v.jsx(tr,{styles:{footnote:te==null?void 0:te.footnote,source:te==null?void 0:te.source},classNames:{footnote:F==null?void 0:F.footnote,source:F==null?void 0:F.source},sources:n,footNote:m,width:d}):null]})})})})}function ave(t){const{data:e,radius:r,lineColors:n,tooltip:a,onSeriesMouseOver:i,onSeriesMouseClick:o,colorDomain:l,detailsOnClick:s,styles:f,classNames:c,selectedColor:h,axisLabels:d,strokeWidth:m,showValues:g,showDots:y,rightMargin:b,topMargin:S,bottomMargin:w,leftMargin:C,curveType:k,noOfTicks:_,minValue:D,maxValue:T,resetSelectionOnDoubleClick:A,fillShape:M,highlightedLines:E}=t,N=k==="linear"?u7e:s7e,Y={top:S,left:C},ne=Math.min((2*r-C-b)/2,(2*r-S-w)/2),[K,B]=I.useState(void 0),[j,$]=I.useState(void 0),[V,z]=I.useState(void 0),[W,G]=I.useState(void 0),ae=br().domain([0,e[0].values.length]).range([0,2*Math.PI]),U=Fe(T)?Math.max(...e.map(Z=>Mn(Z.values.filter(re=>!Fe(re)))||0))<0?0:Math.max(...e.map(Z=>Mn(Z.values.filter(re=>!Fe(re)))||0)):T,H=Fe(D)?Math.min(...e.map(Z=>gr(Z.values.filter(re=>!Fe(re)))||0))>=0?0:Math.min(...e.map(Z=>gr(Z.values.filter(re=>!Fe(re)))||0)):D,R=br().domain([H,U]).range([0,ne]).nice(),ee=R.ticks(_),J=l7e().radius((Z,re)=>R(Z)).angle((Z,re)=>ae(re)).curve(N);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r*2}px`,height:`${r*2}px`,viewBox:`0 0 ${r*2} ${r*2}`,direction:"ltr",children:v.jsx("g",{transform:`translate(${Y.left},${Y.top})`,children:v.jsxs("g",{transform:`translate(${ne},${ne})`,children:[d.map((Z,re)=>{var te,F,q,X;return v.jsxs("g",{children:[v.jsx("line",{x1:0,y1:0,x2:Math.cos(ae(re)-Math.PI/2)*ne,y2:Math.sin(ae(re)-Math.PI/2)*ne,className:Be("stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550",(te=c==null?void 0:c.xAxis)==null?void 0:te.axis),style:(F=f==null?void 0:f.xAxis)==null?void 0:F.axis},re),v.jsx("text",{x:Math.cos(ae(re)-Math.PI/2)*(ne+6),y:Math.sin(ae(re)-Math.PI/2)*(ne+6),style:{textAnchor:Math.cos(ae(re)-Math.PI/2)<0?"end":Math.cos(ae(re)-Math.PI/2)<1e-5?"middle":"start",...((q=f==null?void 0:f.xAxis)==null?void 0:q.labels)||""},dy:Math.sin(ae(re)-Math.PI/2)<0?0:Math.sin(ae(re)-Math.PI/2)<1e-5?5:10,className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(X=c==null?void 0:c.xAxis)==null?void 0:X.labels),children:Z})]},re)}),ee.map((Z,re)=>{var te,F,q,X;return v.jsxs("g",{children:[v.jsx("path",{d:J(Array(d.length).fill(Z))||"",className:Be("stroke-primary-gray-500 dark:stroke-primary-gray-550",(te=c==null?void 0:c.xAxis)==null?void 0:te.gridLines),style:{...(F=f==null?void 0:f.xAxis)==null?void 0:F.gridLines,fill:"none"}}),v.jsx("foreignObject",{x:-25,y:Math.sin(-Math.PI/2)*R(Z)>-1e-4?Math.sin(-Math.PI/2)*R(Z)-7:Math.sin(-Math.PI/2)*R(Z)-5,width:50,height:12,children:v.jsx("div",{className:"flex justify-center",children:v.jsx("p",{className:Be("fill-primary-gray-500 dark:fill-primary-gray-550 text-xs m-0 py-0 px-1.5 text-center leading-none bg-primary-white dark:bg-primary-gray-700",(q=c==null?void 0:c.xAxis)==null?void 0:q.labels),style:(X=f==null?void 0:f.xAxis)==null?void 0:X.labels,children:Z})})})]},re)}),e.map((Z,re)=>v.jsxs("g",{opacity:K?Z.label===K.label?1:.3:h?Z.color&&n[l.indexOf(Z.color)]===h?1:.3:E.length!==0?Z.label&&E.indexOf(Z.label)!==-1?1:.3:1,onMouseEnter:te=>{B(Z),G(te.clientY),z(te.clientX),i&&i(Z)},onMouseMove:te=>{B(Z),G(te.clientY),z(te.clientX)},onMouseLeave:()=>{B(void 0),z(void 0),G(void 0),i&&i(void 0)},onClick:()=>{(o||s)&&(Sr(j,Z)&&A?($(void 0),o==null||o(void 0)):($(Z),o==null||o(Z)))},children:[v.jsx("path",{d:J(Z.values)||"",style:{stroke:e.filter(te=>te.color).length===0?n[0]:Z.color?n[l.indexOf(Z.color)]:Qe.gray,fill:M?e.filter(te=>te.color).length===0?n[0]:Z.color?n[l.indexOf(Z.color)]:Qe.gray:"none",fillOpacity:.1,strokeWidth:m}}),v.jsx("g",{children:Z.values.map((te,F)=>v.jsx("g",{children:Fe(te)?null:v.jsxs(v.Fragment,{children:[y?v.jsx("circle",{cx:Math.cos(ae(F)-Math.PI/2)*R(te),cy:Math.sin(ae(F)-Math.PI/2)*R(te),r:4,style:{fill:e.filter(q=>q.color).length===0?n[0]:Z.color?n[l.indexOf(Z.color)]:Qe.gray}}):null,g?v.jsx("text",{cx:Math.cos(ae(F)-Math.PI/2)*(R(te)+6),cy:Math.sin(ae(F)-Math.PI/2)*(R(te)+6),style:{fill:n[re],textAnchor:Math.cos(ae(F)-Math.PI/2)<0?"end":Math.cos(ae(F)-Math.PI/2)<1e-5?"middle":"start",...(f==null?void 0:f.graphObjectValues)||{}},dy:Math.sin(ae(F)-Math.PI/2)<0?10:(Math.sin(ae(F)-Math.PI/2)<1e-5,0),className:Be("graph-value text-xs font-bold",c==null?void 0:c.graphObjectValues),children:_t(te)}):null]})},F))})]},re))]})})}),K&&a&&V&&W?v.jsx(yr,{data:K,body:a,xPos:V,yPos:W,backgroundStyle:f==null?void 0:f.tooltip,className:c==null?void 0:c.tooltip}):null,s?v.jsx(Tr,{open:j!==void 0,onClose:()=>{$(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(s,j)}})}):null]})}function lq(t){const{graphTitle:e,colors:r,sources:n,graphDescription:a,footNote:i,radius:o,data:l,showColorScale:s=!0,padding:f,backgroundColor:c=!1,tooltip:h,onSeriesMouseOver:d,graphID:m,onSeriesMouseClick:g,topMargin:y=75,bottomMargin:b=75,leftMargin:S=75,rightMargin:w=75,graphDownload:C=!1,dataDownload:k=!1,colorDomain:_,language:D="en",theme:T="light",highlightedLines:A=[],width:M,height:E,minHeight:N=0,strokeWidth:Y=2,relativeHeight:ne,ariaLabel:K,colorLegendTitle:B,detailsOnClick:j,styles:$,classNames:V,showNAColor:z=!0,axisLabels:W,showDots:G=!0,showValues:ae=!1,curveType:U="curve",noOfTicks:H=5,minValue:R,maxValue:ee,fillShape:J=!1,resetSelectionOnDoubleClick:Z=!0}=t,[re,te]=I.useState(0),[F,q]=I.useState(0),[X,ie]=I.useState(0),[ce,de]=I.useState(void 0),he=I.useRef(null),Oe=I.useRef(null);return I.useEffect(()=>{const Ne=new ResizeObserver(Te=>{q(M||Te[0].target.clientWidth||420),ie(E||Te[0].target.clientHeight||420),te((gr([M||Te[0].target.clientWidth||620,E||Te[0].target.clientHeight||480])||420)/2)});return he.current&&(ie(he.current.clientHeight||420),q(he.current.clientWidth||420),te((gr([he.current.clientWidth,he.current.clientHeight])||420)/2),(!M||!o)&&Ne.observe(he.current)),()=>Ne.disconnect()},[M,E,o]),v.jsx("div",{className:`${T||"light"} flex ${M?"w-fit grow-0":"w-full grow"}`,dir:D==="he"||D==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${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"}`,V==null?void 0:V.graphContainer),style:{...($==null?void 0:$.graphContainer)||{},minHeight:"inherit",...c&&c!==!0?{backgroundColor:c}:{}},id:m,ref:Oe,"aria-label":K||`${e?`The graph shows ${e}. `:""}This is a donut or pie chart chart. ${a?` ${a}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:c?f||"1rem":f||0},children:v.jsxs("div",{className:"flex flex-col gap-2 w-full grow justify-between",children:[e||a||C||k?v.jsx(Zt,{styles:{title:$==null?void 0:$.title,description:$==null?void 0:$.description},classNames:{title:V==null?void 0:V.title,description:V==null?void 0:V.description},graphTitle:e,graphDescription:a,width:M,graphDownload:C?Oe.current:void 0,dataDownload:k?l.map(Ne=>Ne.data).filter(Ne=>Ne!==void 0).length>0?l.map(Ne=>Ne.data).filter(Ne=>Ne!==void 0):l.filter(Ne=>Ne!==void 0):null}):null,v.jsx("div",{className:"flex grow flex-col justify-center items-stretch gap-8 flex-wrap",style:{width:M?`${M}px`:"100%"},children:l.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[s&&l.filter(Ne=>Ne.color).length!==0?v.jsx(Cn,{width:M,colorLegendTitle:B,colors:r||Qe[T].categoricalColors.colors,colorDomain:_||Bt(l.filter(Ne=>Ne.color),"color").map(Ne=>Ne.color),setSelectedColor:de,showNAColor:z}):null,v.jsx("div",{className:`flex ${M?"grow-0":"grow"} items-center justify-center leading-0`,style:{width:M?`${M}px`:"100%",height:E?`${Math.max(N,E||(ne?N?(M||F)*ne>N?(M||F)*ne:N:(M||F)*ne:X))}px`:"auto"},ref:he,"aria-label":"Graph area",children:v.jsx("div",{className:"w-full flex justify-center leading-0",children:o||re?v.jsx(ave,{data:l,lineColors:l.filter(Ne=>Ne.color).length===0?r?[r]:[Qe.primaryColors["blue-600"]]:r||Qe[T].categoricalColors.colors,radius:o||re,tooltip:h,colorDomain:_||Bt(l.filter(Ne=>Ne.color),"color").map(Ne=>Ne.color),onSeriesMouseOver:d,onSeriesMouseClick:g,styles:$,detailsOnClick:j,selectedColor:ce,axisLabels:W,strokeWidth:Y,showValues:ae,showDots:G,topMargin:y,bottomMargin:b,leftMargin:S,rightMargin:w,curveType:U,noOfTicks:H,minValue:R,maxValue:ee,fillShape:J,highlightedLines:A,resetSelectionOnDoubleClick:Z}):null})})]})}),n||i?v.jsx(tr,{styles:{footnote:$==null?void 0:$.footnote,source:$==null?void 0:$.source},classNames:{footnote:V==null?void 0:V.footnote,source:V==null?void 0:V.source},sources:n,footNote:i,width:M}):v.jsx("div",{})]})})})})}function sq(t,e){const r=Array.from(new Set(t.map(l=>l.label))),n=Array.from(new Set(t.map(l=>l.date))),a=new Set(t.map(l=>`${l.label}-${l.date}`)),i=t.reduce((l,s)=>(l[s.label]||(l[s.label]=s.color),l),{}),o=[...t];return r.forEach(l=>{n.forEach(s=>{a.has(`${l}-${s}`)||o.push({label:l,color:i[l],size:void 0,date:s})})}),Ut(o,l=>bt(`${l.date}`,e||"yyyy",new Date))}function Vf(t,e){const r=Array.from(new Set(t.map(o=>o.label))),n=Array.from(new Set(t.map(o=>o.date))),a=new Set(t.map(o=>`${o.label}-${o.date}`)),i=[...t];return r.forEach(o=>{n.forEach(l=>{a.has(`${o}-${l}`)||i.push({label:o,size:t[0].size.map(s=>null),date:l})})}),Ut(i,o=>bt(`${o.date}`,e||"yyyy",new Date))}function ive(t,e){const r=Array.from(new Set(t.map(o=>o.label))),n=Array.from(new Set(t.map(o=>o.date))),a=new Set(t.map(o=>`${o.label}-${o.date}`)),i=[...t];return r.forEach(o=>{n.forEach(l=>{a.has(`${o}-${l}`)||i.push({label:o,leftBar:void 0,rightBar:void 0,date:l})})}),Ut(i,o=>bt(`${o.date}`,e,new Date))}function ove(t,e){const r=Array.from(new Set(t.map(l=>l.label))),n=Array.from(new Set(t.map(l=>l.date))),a=new Set(t.map(l=>`${l.label}-${l.date}`)),i=t.reduce((l,s)=>(l[s.label]||(l[s.label]=s.color),l),{}),o=[...t];return r.forEach(l=>{n.forEach(s=>{a.has(`${l}-${s}`)||o.push({label:l,color:i[l],x:void 0,y:void 0,radius:void 0,date:s})})}),Ut(o,l=>bt(`${l.date}`,e,new Date))}function uq(t,e){const r=Array.from(new Set(t.map(o=>o.label))),n=Array.from(new Set(t.map(o=>o.date))),a=new Set(t.map(o=>`${o.label}-${o.date}`)),i=[...t];return r.forEach(o=>{n.forEach(l=>{a.has(`${o}-${l}`)||i.push({label:o,x:t[0].x.map(s=>null),date:l})})}),Ut(i,o=>bt(`${o.date}`,e||"yyyy",new Date))}function lve(t){var Ne,Te,_e,xe,we,ge,ve,le,ue,Ce,pe,ye,be,je,$e,ut;const{data:e,width:r,height:n,barColors:a,centerGap:i,refValues:o,maxValue:l,minValue:s,showValues:f,axisTitles:c,rightMargin:h,leftMargin:d,topMargin:m,bottomMargin:g,tooltip:y,onSeriesMouseOver:b,barPadding:S,truncateBy:w,onSeriesMouseClick:C,showTicks:k,suffix:_,prefix:D,dateFormat:T,indx:A,resetSelectionOnDoubleClick:M,detailsOnClick:E,styles:N,classNames:Y,noOfTicks:ne}=t,K=Ut(e.map(Ie=>({...Ie,date:bt(`${Ie.date}`,T,new Date)})),"date"),B=Bt(K,Ie=>Ie.label).map(Ie=>Ie.label),j=Array.from(Hi(ive(e,T||"yyyy"),Ie=>Ie.date),([Ie,Ze])=>({date:Ie,values:B.map(Ke=>Ze.find(et=>et.label===Ke)).map(Ke=>({...Ke,id:Ke.label}))})),[$,V]=I.useState(void 0),[z,W]=I.useState(void 0),[G,ae]=I.useState(void 0),[U,H]=I.useState(void 0),R={top:m,bottom:g,left:d,right:h},ee=r-R.left-R.right,J=n-R.top-R.bottom,Z=Un().domain(B.map(Ie=>`${Ie}`)).range([J,0]).paddingInner(S),re=Fe(l)?Math.max(...e.filter(Ie=>!Fe(Ie.leftBar)).map(Ie=>Ie.leftBar))<0?0:Math.max(...e.filter(Ie=>!Fe(Ie.leftBar)).map(Ie=>Ie.leftBar)):l,te=Fe(s)?Math.min(...e.filter(Ie=>!Fe(Ie.leftBar)).map(Ie=>Ie.leftBar))>=0?0:Math.min(...e.filter(Ie=>!Fe(Ie.leftBar)).map(Ie=>Ie.leftBar)):s,F=Fe(l)?Math.max(...e.filter(Ie=>!Fe(Ie.rightBar)).map(Ie=>Ie.rightBar))<0?0:Math.max(...e.filter(Ie=>!Fe(Ie.rightBar)).map(Ie=>Ie.rightBar)):l,q=Fe(s)?Math.min(...e.filter(Ie=>!Fe(Ie.rightBar)).map(Ie=>Ie.rightBar))>=0?0:Math.min(...e.filter(Ie=>!Fe(Ie.rightBar)).map(Ie=>Ie.rightBar)):s,X=te<q?te:q,ie=re>F?re:F,ce=br().domain([X,ie]).range([0,(ee-i)/2]).nice(),de=ce.ticks(ne),he=br().domain([X,ie]).range([(ee-i)/2,0]).nice(),Oe=he.ticks(ne);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${R.left},${R.top})`,children:[v.jsxs("g",{transform:"translate(0,0)",children:[k?v.jsx(La,{values:Oe.filter(Ie=>Ie!==0),x:Oe.filter(Ie=>Ie!==0).map(Ie=>he(Ie)),y1:0-m,y2:J+R.bottom,styles:{gridLines:(Ne=N==null?void 0:N.xAxis)==null?void 0:Ne.gridLines,labels:(Te=N==null?void 0:N.xAxis)==null?void 0:Te.labels},classNames:{gridLines:(_e=Y==null?void 0:Y.xAxis)==null?void 0:_e.gridLines,labels:(xe=Y==null?void 0:Y.xAxis)==null?void 0:xe.labels},suffix:_,prefix:D,labelType:"secondary",showGridLines:!0,leftLabel:!0}):null,v.jsx(mo,{children:j[A].values.map((Ie,Ze)=>v.jsxs(ur.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:Ke=>{V(Ie),H(Ke.clientY),ae(Ke.clientX),b&&b(Ie)},onClick:()=>{(C||E)&&(Sr(z,Ie)&&M?(W(void 0),C==null||C(void 0)):(W(Ie),C==null||C(Ie)))},onMouseMove:Ke=>{V(Ie),H(Ke.clientY),ae(Ke.clientX)},onMouseLeave:()=>{V(void 0),ae(void 0),H(void 0),b&&b(void 0)},children:[v.jsx(ur.rect,{style:{fill:a[0]},height:Z.bandwidth(),animate:{width:Ie.leftBar?Ie.leftBar<0?he(Ie.leftBar)-he(0):he(0)-he(Ie.leftBar):0,attrY:Z(`${Ie.label}`),attrX:Ie.leftBar?Ie.leftBar<0?he(0):he(Ie.leftBar):he(0)},transition:{duration:.5}}),f?v.jsx(ur.text,{style:{fill:a[0],textAnchor:Ie.rightBar&&Ie.rightBar>0?"end":"start",...(N==null?void 0:N.graphObjectValues)||{}},dx:Ie.leftBar&&Ie.leftBar>0?-5:5,dy:"0.33em",animate:{attrX:Ie.leftBar?he(Ie.leftBar):he(te<0?0:te),attrY:Z(`${Ie.label}`)+Z.bandwidth()/2},transition:{duration:.5},className:Be("graph-value text-sm",Y==null?void 0:Y.graphObjectValues),children:_t(Ie.leftBar,D,_)}):null]},Ie.label))}),v.jsx(Nr,{y1:-2.5,y2:J+R.bottom,x1:he(te<0?0:te),x2:he(te<0?0:te),classNames:{axis:(we=Y==null?void 0:Y.yAxis)==null?void 0:we.axis},styles:{axis:(ge=N==null?void 0:N.yAxis)==null?void 0:ge.axis}}),o?v.jsx(v.Fragment,{children:o.map((Ie,Ze)=>v.jsx(ti,{text:Ie.text,color:Ie.color,x:he(Ie.value),y1:0-R.top,y2:J+R.bottom,textSide:"left",classNames:Ie.classNames,styles:Ie.styles},Ze))}):null]}),v.jsxs("g",{transform:`translate(${(ee+i)/2},0)`,children:[k?v.jsx(La,{values:de.filter(Ie=>Ie!==0),x:de.filter(Ie=>Ie!==0).map(Ie=>ce(Ie)),y1:0-m,y2:J+R.bottom,styles:{gridLines:(ve=N==null?void 0:N.xAxis)==null?void 0:ve.gridLines,labels:(le=N==null?void 0:N.xAxis)==null?void 0:le.labels},classNames:{gridLines:(ue=Y==null?void 0:Y.xAxis)==null?void 0:ue.gridLines,labels:(Ce=Y==null?void 0:Y.xAxis)==null?void 0:Ce.labels},suffix:_,prefix:D,labelType:"secondary",showGridLines:!0}):null,v.jsx(mo,{children:j[A].values.map((Ie,Ze)=>v.jsxs(ur.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:Ke=>{V(Ie),H(Ke.clientY),ae(Ke.clientX),b&&b(Ie)},onClick:()=>{(C||E)&&(Sr(z,Ie)&&M?(W(void 0),C==null||C(void 0)):(W(Ie),C==null||C(Ie)))},onMouseMove:Ke=>{V(Ie),H(Ke.clientY),ae(Ke.clientX)},onMouseLeave:()=>{V(void 0),ae(void 0),H(void 0),b&&b(void 0)},children:[v.jsx(ur.rect,{style:{fill:a[1]},height:Z.bandwidth(),animate:{width:Ie.rightBar?Ie.rightBar>=0?ce(Ie.rightBar)-ce(0):ce(0)-ce(Ie.rightBar):0,attrY:Z(`${Ie.label}`),attrX:Ie.rightBar?Ie.rightBar>=0?ce(0):ce(Ie.rightBar):ce(0)},transition:{duration:.5}}),f?v.jsx(ur.text,{style:{fill:a[1],textAnchor:Ie.rightBar&&Ie.rightBar<0?"end":"start",...(N==null?void 0:N.graphObjectValues)||{}},className:Be("graph-value text-sm",Y==null?void 0:Y.graphObjectValues),dx:Ie.rightBar&&Ie.rightBar<0?-5:5,dy:"0.33em",animate:{attrX:Ie.rightBar?ce(Ie.rightBar):ce(q<0?0:q),attrY:Z(`${Ie.label}`)+Z.bandwidth()/2},transition:{duration:.5},children:_t(Ie.rightBar,D,_)}):null]},Ze))}),v.jsx(Nr,{y1:-2.5,y2:J+R.bottom,x1:ce(q<0?0:q),x2:ce(q<0?0:q),classNames:{axis:(pe=Y==null?void 0:Y.yAxis)==null?void 0:pe.axis},styles:{axis:(ye=N==null?void 0:N.yAxis)==null?void 0:ye.axis}}),o?v.jsx(v.Fragment,{children:o.map((Ie,Ze)=>v.jsx(ti,{text:Ie.text,color:Ie.color,x:ce(Ie.value),y1:0-R.top,y2:J+R.bottom,textSide:"right",classNames:Ie.classNames,styles:Ie.styles},Ze))}):null]}),v.jsx("g",{transform:`translate(${ee/2},0)`,children:j[A].values.map((Ie,Ze)=>{var Ke,et;return v.jsx(Y2,{value:`${Ie.label}`.length<w?`${Ie.label}`:`${`${Ie.label}`.substring(0,w)}...`,y:Z(`${Ie.id}`),x:0-i/2,width:i,height:Z.bandwidth(),alignment:"center",style:(Ke=N==null?void 0:N.yAxis)==null?void 0:Ke.labels,className:(et=Y==null?void 0:Y.yAxis)==null?void 0:et.labels},Ze)})}),v.jsxs("g",{transform:`translate(0,${J})`,children:[v.jsx("text",{style:{fill:a[0],textAnchor:"end",...(be=N==null?void 0:N.yAxis)==null?void 0:be.title},className:Be("text-base",(je=Y==null?void 0:Y.yAxis)==null?void 0:je.title),x:ee/2-i/2,y:0,dx:-5,dy:20,children:c[0]}),v.jsx("text",{style:{fill:a[1],textAnchor:"start",...($e=N==null?void 0:N.yAxis)==null?void 0:$e.title},className:Be("text-base",(ut=Y==null?void 0:Y.yAxis)==null?void 0:ut.title),x:ee/2+i/2,y:0,dx:5,dy:20,children:c[1]})]})]})}),$&&y&&G&&U?v.jsx(yr,{data:$,body:y,xPos:G,yPos:U,backgroundStyle:N==null?void 0:N.tooltip,className:Y==null?void 0:Y.tooltip}):null,E?v.jsx(Tr,{open:z!==void 0,onClose:()=>{W(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(E,z)}})}):null]})}function cq(t){const{data:e,graphTitle:r,sources:n,graphDescription:a,height:i,width:o,footNote:l,padding:s,leftBarColor:f=Qe.light.categoricalColors.colors[0],rightBarColor:c=Qe.light.categoricalColors.colors[1],backgroundColor:h=!1,leftMargin:d=20,rightMargin:m=20,topMargin:g=25,bottomMargin:y=30,rightBarTitle:b="Right bar graph",leftBarTitle:S="Left bar graph",barPadding:w=.25,truncateBy:C=999,onSeriesMouseClick:k,centerGap:_=100,showValues:D=!0,tooltip:T,relativeHeight:A,onSeriesMouseOver:M,graphID:E,refValues:N=[],suffix:Y="",prefix:ne="",showTicks:K=!0,showColorScale:B=!1,graphDownload:j=!1,dataDownload:$=!1,language:V="en",maxValue:z,minValue:W,dateFormat:G="yyyy",showOnlyActiveDate:ae=!1,autoPlay:U=!1,colorLegendTitle:H,minHeight:R=0,theme:ee="light",ariaLabel:J,resetSelectionOnDoubleClick:Z=!0,detailsOnClick:re,styles:te,classNames:F,noOfTicks:q=5}=t,[X,ie]=I.useState(0),[ce,de]=I.useState(0),he=I.useRef(null),Oe=I.useRef(null);I.useEffect(()=>{const ve=new ResizeObserver(le=>{ie(o||le[0].target.clientWidth||620),de(i||le[0].target.clientHeight||480)});return he.current&&(de(he.current.clientHeight||480),ie(he.current.clientWidth||620),o||ve.observe(he.current)),()=>ve.disconnect()},[o,i]);const[Ne,Te]=I.useState(U),_e=qi(Bt(e,ve=>ve.date).map(ve=>bt(`${ve.date}`,G,new Date).getTime()),(ve,le)=>Ka(ve,le)),[xe,we]=I.useState(U?0:_e.length-1),ge={};return _e.forEach((ve,le)=>{ge[`${ve}`]={style:{color:le===xe?"#232E3D":"#A9B1B7",fontWeight:le===xe?"bold":"normal",display:le===xe||!ae?"inline":"none"},label:Sa(new Date(ve),G)}}),I.useEffect(()=>{const ve=setInterval(()=>{we(le=>le<_e.length-1?le+1:0)},2e3);return Ne||clearInterval(ve),()=>clearInterval(ve)},[_e,Ne]),v.jsx("div",{className:`${ee||"light"} flex ${o?"w-fit grow-0":"w-full grow"}`,dir:V==="he"||V==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${h?h===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${V||"en"}`,F==null?void 0:F.graphContainer),style:{...(te==null?void 0:te.graphContainer)||{},...h&&h!==!0?{backgroundColor:h}:{}},id:E,ref:Oe,"aria-label":J||`${r?`The graph shows ${r}. `:""}This is an animated diverging bar chart showing data changes over time. ${a?` ${a}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:h?s||"1rem":s||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||a||j||$?v.jsx(Zt,{styles:{title:te==null?void 0:te.title,description:te==null?void 0:te.description},classNames:{title:F==null?void 0:F.title,description:F==null?void 0:F.description},graphTitle:r,graphDescription:a,width:o,graphDownload:j?Oe.current:void 0,dataDownload:$?e.map(ve=>ve.data).filter(ve=>ve!==void 0).length>0?e.map(ve=>ve.data).filter(ve=>ve!==void 0):e.filter(ve=>ve!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{Te(!Ne)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":Ne?"Click to pause animation":"Click to play animation",children:Ne?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:_e[0],max:_e[_e.length-1],marks:ge,step:null,defaultValue:_e[_e.length-1],value:_e[xe],onChangeComplete:ve=>{we(_e.indexOf(ve))},onChange:ve=>{we(_e.indexOf(ve))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[B?v.jsx(g0,{colorLegendTitle:H,colorDomain:[S,b],colors:[f,c],showNAColor:!1}):null,v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:he,"aria-label":"Graph area",children:(o||X)&&(i||ce)?v.jsx(lve,{data:e,barColors:[f,c],width:o||X,centerGap:_,height:Math.max(R,i||(A?R?(o||X)*A>R?(o||X)*A:R:(o||X)*A:ce)),truncateBy:C,leftMargin:d,rightMargin:m,topMargin:g,bottomMargin:y,axisTitles:[S,b],tooltip:T,onSeriesMouseOver:M,barPadding:w,refValues:N,maxValue:z,minValue:W,showValues:Fe(D)?!0:D,onSeriesMouseClick:k,showTicks:K,suffix:Y,prefix:ne,dateFormat:G,indx:xe,resetSelectionOnDoubleClick:Z,detailsOnClick:re,styles:te,classNames:F,noOfTicks:q}):null})]}),n||l?v.jsx(tr,{styles:{footnote:te==null?void 0:te.footnote,source:te==null?void 0:te.source},classNames:{footnote:F==null?void 0:F.footnote,source:F==null?void 0:F.source},sources:n,footNote:l,width:o}):null]})})})})}function sve(t){const{data:e,xDomain:r,mapData:n,xColorLegendTitle:a,yDomain:i,yColorLegendTitle:o,width:l,height:s,colors:f,scale:c,centerPoint:h,mapBorderWidth:d,mapNoDataColor:m,mapBorderColor:g,tooltip:y,onSeriesMouseOver:b,zoomScaleExtend:S,zoomTranslateExtend:w,highlightedIds:C,onSeriesMouseClick:k,mapProperty:_,dateFormat:D,indx:T,resetSelectionOnDoubleClick:A,detailsOnClick:M,showColorScale:E,styles:N,classNames:Y,mapProjection:ne}=t,K=Array.from(Hi(Ut(e,ge=>bt(`${ge.date}`,D||"yyyy",new Date)),ge=>ge.date),([ge,ve])=>({date:ge,values:ve})),[B,j]=I.useState(!(l<680)),$=I.useRef(null),[V,z]=I.useState(50),[W,G]=I.useState(void 0),[ae,U]=I.useState(void 0),[H,R]=I.useState(void 0),[ee,J]=I.useState(void 0),[Z,re]=I.useState(void 0),te=I.useRef(null),F=I.useRef(null),q=Array.from({length:r.length},(ge,ve)=>ve),X=Array.from({length:i.length},(ge,ve)=>ve),ie=P2().domain(r).range(q),ce=P2().domain(i).range(X);I.useEffect(()=>{const ge=Qr(F.current),ve=Qr(te.current),le=g7().scaleExtent(S).translateExtent(w||[[-20,-20],[l+20,s+20]]).on("zoom",({transform:ue})=>{ge.attr("transform",ue)});ve.call(le)},[s,l]),I.useEffect(()=>{(()=>{if($.current){const ve=$.current.getBoundingClientRect().height;z(ve+16)}})()},[]);const de=c7(n),he=Pz(n),Oe=de[2]-de[0],Ne=de[3]-de[1],Te=l*190/960*360/Oe,_e=s*190/678*180/Ne,xe=c*Math.min(Te,_e),we=ne==="mercator"?d7().rotate([0,0]).center(h||he.geometry.coordinates).translate([l/2,s/2]).scale(xe):ne==="equalEarth"?h7().rotate([0,0]).center(h||he.geometry.coordinates).translate([l/2,s/2]).scale(xe):ne==="naturalEarth"?p7().rotate([0,0]).center(h||he.geometry.coordinates).translate([l/2,s/2]).scale(xe):ne==="orthographic"?m7().rotate([0,0]).center(h||he.geometry.coordinates).translate([l/2,s/2]).scale(xe):f7().rotate([0,0]).center(h||he.geometry.coordinates).translate([l/2,s/2]).scale(xe);return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{viewBox:`0 0 ${l} ${s}`,width:`${l}px`,height:`${s}px`,ref:te,direction:"ltr",children:[v.jsxs("g",{ref:F,children:[n.features.map((ge,ve)=>K[T].values.findIndex(ue=>ue.id===ge.properties[_])!==-1?null:v.jsx("g",{opacity:W?.3:C.length!==0?C.indexOf(ge.properties[_])!==-1?1:.3:1,children:ge.geometry.type==="MultiPolygon"?ge.geometry.coordinates.map((ue,Ce)=>{let pe="";return ue.forEach(ye=>{let be=" M";ye.forEach((je,$e)=>{const ut=we([je[0],je[1]]);$e!==ye.length-1?be=`${be}${ut[0]} ${ut[1]}L`:be=`${be}${ut[0]} ${ut[1]}`}),pe+=be}),v.jsx("path",{d:pe,style:{stroke:g,strokeWidth:d,fill:m}},Ce)}):ge.geometry.coordinates.map((ue,Ce)=>{let pe="M";return ue.forEach((ye,be)=>{const je=we([ye[0],ye[1]]);be!==ue.length-1?pe=`${pe}${je[0]} ${je[1]}L`:pe=`${pe}${je[0]} ${je[1]}`}),v.jsx("path",{d:pe,style:{stroke:g,strokeWidth:d,fill:m}},Ce)})},ve)),K[T].values.map((ge,ve)=>{const le=n.features.findIndex(ye=>ge.id===ye.properties[_]),ue=Fe(ge.x)?void 0:ie(ge.x),Ce=Fe(ge.y)?void 0:ce(ge.y),pe=ue!==void 0&&Ce!==void 0?f[Ce][ue]:m;return v.jsx("g",{opacity:W?W===pe?1:.3:C.length!==0?C.indexOf(ge.id)!==-1?1:.3:1,onMouseEnter:ye=>{R(ge),re(ye.clientY),J(ye.clientX),b&&b(ge)},onClick:()=>{(k||M)&&(Sr(ae,ge)&&A?(U(void 0),k==null||k(void 0)):(U(ge),k==null||k(ge)))},onMouseMove:ye=>{R(ge),re(ye.clientY),J(ye.clientX)},onMouseLeave:()=>{R(void 0),J(void 0),re(void 0),b&&b(void 0)},children:le===-1?null:n.features[le].geometry.type==="MultiPolygon"?n.features[le].geometry.coordinates.map((ye,be)=>{let je="";return ye.forEach($e=>{let ut=" M";$e.forEach((Ie,Ze)=>{const Ke=we([Ie[0],Ie[1]]);Ze!==$e.length-1?ut=`${ut}${Ke[0]} ${Ke[1]}L`:ut=`${ut}${Ke[0]} ${Ke[1]}`}),je+=ut}),v.jsx("path",{d:je,className:`${pe===m?"stroke-primary-gray-400 dark:stroke-primary-gray-500":"stroke-primary-white dark:stroke-primary-gray-650"}`,style:{strokeWidth:d,fill:pe}},be)}):n.features[le].geometry.coordinates.map((ye,be)=>{let je="M";return ye.forEach(($e,ut)=>{const Ie=we([$e[0],$e[1]]);ut!==ye.length-1?je=`${je}${Ie[0]} ${Ie[1]}L`:je=`${je}${Ie[0]} ${Ie[1]}`}),v.jsx("path",{d:je,className:`${pe===m?"stroke-primary-gray-400 dark:stroke-primary-gray-500":"stroke-primary-white dark:stroke-primary-gray-650"}`,style:{strokeWidth:d,fill:pe}},be)})},ve)}),H?n.features.filter(ge=>ge.properties[_]===H.id).map((ge,ve)=>v.jsx("g",{children:ge.geometry.type==="MultiPolygon"?ge.geometry.coordinates.map((le,ue)=>{let Ce="";return le.forEach(pe=>{let ye=" M";pe.forEach((be,je)=>{const $e=we([be[0],be[1]]);je!==pe.length-1?ye=`${ye}${$e[0]} ${$e[1]}L`:ye=`${ye}${$e[0]} ${$e[1]}`}),Ce+=ye}),v.jsx("path",{d:Ce,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},ue)}):ge.geometry.coordinates.map((le,ue)=>{let Ce="M";return le.forEach((pe,ye)=>{const be=we([pe[0],pe[1]]);ye!==le.length-1?Ce=`${Ce}${be[0]} ${be[1]}L`:Ce=`${Ce}${be[0]} ${be[1]}`}),v.jsx("path",{d:Ce,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},ue)})},ve)):null]}),v.jsx("foreignObject",{x:10,y:B?s-V-5:s-46,width:B?189:101,height:B?V:36,children:E?B?v.jsxs("div",{ref:$,children:[v.jsx("div",{style:{marginBottom:"-0.75rem",marginLeft:"164px",backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"relative"},onClick:()=>{j(!1)},children:v.jsx(n7,{})}),v.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.5",width:"175px"},children:[v.jsxs("div",{className:"flex gap-1 items-center",children:[v.jsx("svg",{width:"136px",viewBox:"0 0 136 136",className:"shrink-0",children:v.jsxs("g",{children:[f.map((ge,ve)=>v.jsx("g",{transform:`translate(0,${100-ve*25})`,children:ge.map((le,ue)=>v.jsx("rect",{y:1,x:ue*25+1,fill:le,width:23,height:23,strokeWidth:W===le?2:.25,style:{cursor:"pointer"},onMouseOver:()=>{G(le)},onMouseLeave:()=>{G(void 0)}},ue))},ve)),v.jsx("g",{transform:"translate(0,125)",children:r.map((ge,ve)=>v.jsx("text",{y:10,x:(ve+1)*25,fontSize:10,textAnchor:"middle",children:typeof ge=="string"||ge<1?ge:_t(ge,"","")},ve))}),i.map((ge,ve)=>v.jsx("g",{transform:`translate(${Math.max(Math.min(r.length+1,5),4)*25+10},${100-ve*25})`,children:v.jsx("text",{x:0,transform:"rotate(-90)",y:0,fontSize:10,textAnchor:"middle",children:typeof ge=="string"||ge<1?ge:_t(ge,"","")})},ve))]})}),v.jsx(or,{marginBottom:"none",size:"xs",className:"leading-normal text-center shrink-0",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical",overflow:"hidden",writingMode:"vertical-rl",height:"8.5rem",transform:"rotate(180deg)"},children:o})]}),v.jsx(or,{marginBottom:"none",size:"xs",className:"mt-1 leading-normal text-center",style:{display:"-webkit-box",WebkitLineClamp:"1",width:"8.5rem",WebkitBoxOrient:"vertical",overflow:"hidden"},children:a})]})]}):v.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{j(!0)},children:v.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})}):null})]}),H&&y&&ee&&Z?v.jsx(yr,{data:H,body:y,xPos:ee,yPos:Z,backgroundStyle:N==null?void 0:N.tooltip,className:Y==null?void 0:Y.tooltip}):null,M?v.jsx(Tr,{open:ae!==void 0,onClose:()=>{U(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(M,ae)}})}):null]})}function fq(t){const{data:e,mapData:r,graphTitle:n,colors:a=Qe.light.bivariateColors.colors05x05,sources:i,graphDescription:o,height:l,width:s,footNote:f,xDomain:c,yDomain:h,xColorLegendTitle:d="X Color key",yColorLegendTitle:m="Y Color key",tooltip:g,scale:y=.95,centerPoint:b,padding:S,mapBorderWidth:w=.5,showColorScale:C=!0,mapNoDataColor:k=Qe.light.graphNoData,backgroundColor:_=!1,mapBorderColor:D=Qe.light.grays["gray-500"],relativeHeight:T,onSeriesMouseOver:A,isWorldMap:M=!0,zoomScaleExtend:E=[.8,6],zoomTranslateExtend:N,graphID:Y,highlightedIds:ne=[],onSeriesMouseClick:K,mapProperty:B="ISO3",graphDownload:j=!1,dataDownload:$=!1,showAntarctica:V=!1,language:z="en",minHeight:W=0,theme:G="light",dateFormat:ae="yyyy",showOnlyActiveDate:U=!1,autoPlay:H=!1,ariaLabel:R,resetSelectionOnDoubleClick:ee=!0,detailsOnClick:J,styles:Z,classNames:re,mapProjection:te}=t,[F,q]=I.useState(0),[X,ie]=I.useState(0),[ce,de]=I.useState(void 0),he=I.useRef(null),Oe=I.useRef(null);I.useEffect(()=>{const ve=new ResizeObserver(le=>{q(s||le[0].target.clientWidth||760),ie(l||le[0].target.clientHeight||480)});return he.current&&(ie(he.current.clientHeight||480),q(he.current.clientWidth||760),s||ve.observe(he.current)),()=>ve.disconnect()},[s,l]);const[Ne,Te]=I.useState(H),_e=qi(Bt(e,ve=>ve.date).map(ve=>bt(`${ve.date}`,ae,new Date).getTime()),(ve,le)=>Ka(ve,le)),[xe,we]=I.useState(H?0:_e.length-1),ge={};return _e.forEach((ve,le)=>{ge[`${ve}`]={style:{color:le===xe?"#232E3D":"#A9B1B7",fontWeight:le===xe?"bold":"normal",display:le===xe||!U?"inline":"none"},label:Sa(new Date(ve),ae)}}),I.useEffect(()=>{const ve=setInterval(()=>{we(le=>le<_e.length-1?le+1:0)},2e3);return Ne||clearInterval(ve),()=>clearInterval(ve)},[_e,Ne]),I.useEffect(()=>{typeof r=="string"?ka(r).then(le=>{de(le)}):de(r||u7)},[r]),c&&h&&(c.length!==a[0].length-1||h.length!==a.length-1)?(console.error("the xDomain and yDomain array length don't match to the color array length"),null):v.jsx("div",{className:`${G||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:z==="he"||z==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${_?_===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${z||"en"}`,re==null?void 0:re.graphContainer),style:{...(Z==null?void 0:Z.graphContainer)||{},..._&&_!==!0?{backgroundColor:_}:{}},id:Y,ref:Oe,"aria-label":R||`${n?`The graph shows ${n}. `:""}This is bi-variate choropleth map where geographic areas are colored in proportion to two variables showing data changes over time.${o?` ${o}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:_?S||"1rem":S||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[n||o||j||$?v.jsx(Zt,{styles:{title:Z==null?void 0:Z.title,description:Z==null?void 0:Z.description},classNames:{title:re==null?void 0:re.title,description:re==null?void 0:re.description},graphTitle:n,graphDescription:o,width:s,graphDownload:j?Oe.current:void 0,dataDownload:$?e.map(ve=>ve.data).filter(ve=>ve!==void 0).length>0?e.map(ve=>ve.data).filter(ve=>ve!==void 0):e.filter(ve=>ve!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{Te(!Ne)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":Ne?"Click to pause animation":"Click to play animation",children:Ne?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:_e[0],max:_e[_e.length-1],marks:ge,step:null,defaultValue:_e[_e.length-1],value:_e[xe],onChangeComplete:ve=>{we(_e.indexOf(ve))},onChange:ve=>{we(_e.indexOf(ve))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:he,"aria-label":"Map area",children:(s||F)&&(l||X)&&ce?v.jsx(sve,{data:e,mapData:V?ce:{...ce,features:ce.features.filter(ve=>ve.properties.NAME!=="Antarctica")},xDomain:c||X3(e.map(ve=>ve.x),a[0].length),yDomain:h||X3(e.map(ve=>ve.y),a.length),width:s||F,height:Math.max(W,l||(T?W?(s||F)*T>W?(s||F)*T:W:(s||F)*T:X)),scale:y,centerPoint:b,colors:a,xColorLegendTitle:d,yColorLegendTitle:m,mapBorderWidth:Fe(w)?.5:w,mapNoDataColor:k,mapBorderColor:D,tooltip:g,showColorScale:C,onSeriesMouseOver:A,isWorldMap:M,zoomScaleExtend:E,zoomTranslateExtend:N,onSeriesMouseClick:K,mapProperty:B,highlightedIds:ne,dateFormat:ae,indx:xe,resetSelectionOnDoubleClick:ee,styles:Z,classNames:re,detailsOnClick:J,mapProjection:te||(M?"naturalEarth":"mercator")}):null}),i||f?v.jsx(tr,{styles:{footnote:Z==null?void 0:Z.footnote,source:Z==null?void 0:Z.source},classNames:{footnote:re==null?void 0:re.footnote,source:re==null?void 0:re.source},sources:i,footNote:f,width:s}):null]})})})})}function uve(t){const{data:e,colorDomain:r,colors:n,mapData:a,colorLegendTitle:i,categorical:o,height:l,width:s,scale:f,centerPoint:c,tooltip:h,mapBorderWidth:d,mapBorderColor:m,mapNoDataColor:g,onSeriesMouseOver:y,showColorScale:b,zoomScaleExtend:S,zoomTranslateExtend:w,highlightedIds:C,onSeriesMouseClick:k,mapProperty:_,dateFormat:D,indx:T,resetSelectionOnDoubleClick:A,detailsOnClick:M,styles:E,classNames:N,mapProjection:Y}=t,ne=Array.from(Hi(Ut(e,Te=>bt(`${Te.date}`,D||"yyyy",new Date)),Te=>Te.date),([Te,_e])=>({date:Te,values:_e})),[K,B]=I.useState(void 0),[j,$]=I.useState(!(s<680)),V=I.useRef(null),[z,W]=I.useState(50),[G,ae]=I.useState(void 0),[U,H]=I.useState(void 0),[R,ee]=I.useState(void 0),[J,Z]=I.useState(void 0),re=I.useRef(null),te=I.useRef(null),F=o?Ys().domain(r).range(n):P2().domain(r).range(n);I.useEffect(()=>{const Te=Qr(te.current),_e=Qr(re.current),xe=g7().scaleExtent(S).translateExtent(w||[[-20,-20],[s+20,l+20]]).on("zoom",({transform:we})=>{Te.attr("transform",we)});_e.call(xe)},[l,s]),I.useEffect(()=>{(()=>{if(V.current){const _e=V.current.getBoundingClientRect().height;W(_e+16)}})()},[]);const q=c7(a),X=o9(a),ie=q[2]-q[0],ce=q[3]-q[1],de=s*190/960*360/ie,he=l*190/678*180/ce,Oe=f*Math.min(de,he),Ne=Y==="mercator"?d7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):Y==="equalEarth"?h7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):Y==="naturalEarth"?p7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):Y==="orthographic"?m7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):f7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe);return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{width:`${s}px`,height:`${l}px`,viewBox:`0 0 ${s} ${l}`,ref:re,direction:"ltr",children:[v.jsxs("g",{ref:te,children:[a.features.map((Te,_e)=>ne[T].values.findIndex(we=>we.id===Te.properties[_])!==-1?null:v.jsx("g",{opacity:K?.3:C.length!==0?C.indexOf(Te.properties[_])!==-1?1:.3:1,children:Te.geometry.type==="MultiPolygon"?Te.geometry.coordinates.map((we,ge)=>{let ve="";return we.forEach(le=>{let ue=" M";le.forEach((Ce,pe)=>{const ye=Ne([Ce[0],Ce[1]]);pe!==le.length-1?ue=`${ue}${ye[0]} ${ye[1]}L`:ue=`${ue}${ye[0]} ${ye[1]}`}),ve+=ue}),v.jsx("path",{d:ve,style:{stroke:m,fill:g,strokeWidth:d}},ge)}):Te.geometry.coordinates.map((we,ge)=>{let ve="M";return we.forEach((le,ue)=>{const Ce=Ne([le[0],le[1]]);ue!==we.length-1?ve=`${ve}${Ce[0]} ${Ce[1]}L`:ve=`${ve}${Ce[0]} ${Ce[1]}`}),v.jsx("path",{d:ve,style:{stroke:m,strokeWidth:d,fill:g}},ge)})},_e)),ne[T].values.map((Te,_e)=>{const xe=a.features.findIndex(ge=>Te.id===ge.properties[_]),we=Fe(Te.x)?g:F(Te.x);return v.jsx("g",{opacity:K?K===we?1:.3:C.length!==0?C.indexOf(Te.id)!==-1?1:.3:1,onMouseEnter:ge=>{H(Te),Z(ge.clientY),ee(ge.clientX),y&&y(Te)},onMouseMove:ge=>{H(Te),Z(ge.clientY),ee(ge.clientX)},onMouseLeave:()=>{H(void 0),ee(void 0),Z(void 0),y&&y(void 0)},onClick:()=>{(k||M)&&(Sr(G,Te)&&A?(ae(void 0),k==null||k(void 0)):(ae(Te),k==null||k(Te)))},children:xe===-1?null:a.features[xe].geometry.type==="MultiPolygon"?a.features[xe].geometry.coordinates.map((ge,ve)=>{let le="";return ge.forEach(ue=>{let Ce=" M";ue.forEach((pe,ye)=>{const be=Ne([pe[0],pe[1]]);ye!==ue.length-1?Ce=`${Ce}${be[0]} ${be[1]}L`:Ce=`${Ce}${be[0]} ${be[1]}`}),le+=Ce}),v.jsx("path",{d:le,style:{stroke:m,strokeWidth:d,fill:we}},ve)}):a.features[xe].geometry.coordinates.map((ge,ve)=>{let le="M";return ge.forEach((ue,Ce)=>{const pe=Ne([ue[0],ue[1]]);Ce!==ge.length-1?le=`${le}${pe[0]} ${pe[1]}L`:le=`${le}${pe[0]} ${pe[1]}`}),v.jsx("path",{d:le,style:{stroke:m,strokeWidth:d,fill:we}},ve)})},_e)}),U?a.features.filter(Te=>Te.properties[_]===U.id).map((Te,_e)=>v.jsx("g",{children:Te.geometry.type==="MultiPolygon"?Te.geometry.coordinates.map((xe,we)=>{let ge="";return xe.forEach(ve=>{let le=" M";ve.forEach((ue,Ce)=>{const pe=Ne([ue[0],ue[1]]);Ce!==ve.length-1?le=`${le}${pe[0]} ${pe[1]}L`:le=`${le}${pe[0]} ${pe[1]}`}),ge+=le}),v.jsx("path",{d:ge,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},we)}):Te.geometry.coordinates.map((xe,we)=>{let ge="M";return xe.forEach((ve,le)=>{const ue=Ne([ve[0],ve[1]]);le!==xe.length-1?ge=`${ge}${ue[0]} ${ue[1]}L`:ge=`${ge}${ue[0]} ${ue[1]}`}),v.jsx("path",{d:ge,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},we)})},_e)):null]}),b===!1?null:v.jsx("foreignObject",{x:10,y:j?l-z-5:l-46,width:j?o?150:352:101,height:j?z:36,children:j?v.jsxs("div",{ref:V,children:[v.jsx("div",{style:{marginBottom:"-0.75rem",marginLeft:o?"126px":"328px",backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"relative"},onClick:()=>{$(!1)},children:v.jsx(n7,{})}),v.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.5",width:o?"138px":"340px"},children:[i&&i!==""?v.jsx(or,{size:"xs",marginBottom:"xs",className:"p-0 leading-normal overflow-hidden text-primary-gray-700 dark:text-primary-gray-300",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical"},children:i}):null,o?v.jsx("div",{className:"flex flex-col gap-3",children:r.map((Te,_e)=>v.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{B(n[_e%n.length])},onMouseLeave:()=>{B(void 0)},children:[v.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:n[_e%n.length]}}),v.jsx(or,{size:"sm",marginBottom:"none",leading:"none",children:Te})]},_e))}):v.jsx("svg",{width:"100%",viewBox:"0 0 320 30",direction:"ltr",children:v.jsxs("g",{children:[r.map((Te,_e)=>v.jsxs("g",{onMouseOver:()=>{B(n[_e])},onMouseLeave:()=>{B(void 0)},className:"cursor-pointer",children:[v.jsx("rect",{x:_e*320/n.length+1,y:1,width:320/n.length-2,height:8,className:K===n[_e]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":"",style:{fill:n[_e],...K===n[_e]?{}:{stroke:n[_e]}}}),v.jsx("text",{x:(_e+1)*320/n.length,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",style:{textAnchor:"middle"},children:_t(Te,"","")})]},_e)),v.jsx("g",{children:v.jsx("rect",{onMouseOver:()=>{B(n[r.length])},onMouseLeave:()=>{B(void 0)},x:r.length*320/n.length+1,y:1,width:320/n.length-2,height:8,className:`cursor-pointer ${K===n[r.length]?"stroke-1 stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:n[r.length],...K===n[r.length]?{}:{stroke:n[r.length]}}})})]})})]})]}):v.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{$(!0)},children:v.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})})})]}),U&&h&&R&&J?v.jsx(yr,{data:U,body:h,xPos:R,yPos:J,backgroundStyle:E==null?void 0:E.tooltip,className:N==null?void 0:N.tooltip}):null,M?v.jsx(Tr,{open:G!==void 0,onClose:()=>{ae(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(M,G)}})}):null]})}function dq(t){const{data:e,mapData:r,graphTitle:n,colors:a,sources:i,graphDescription:o,height:l,width:s,footNote:f,colorDomain:c,colorLegendTitle:h,scaleType:d="threshold",scale:m=.95,centerPoint:g,padding:y,mapBorderWidth:b=.5,mapNoDataColor:S=Qe.light.graphNoData,backgroundColor:w=!1,mapBorderColor:C=Qe.light.grays["gray-500"],relativeHeight:k,tooltip:_,onSeriesMouseOver:D,isWorldMap:T=!0,showColorScale:A=!0,zoomScaleExtend:M=[.8,6],zoomTranslateExtend:E,graphID:N,highlightedIds:Y=[],onSeriesMouseClick:ne,mapProperty:K="ISO3",graphDownload:B=!1,dataDownload:j=!1,showAntarctica:$=!1,language:V="en",minHeight:z=0,theme:W="light",dateFormat:G="yyyy",showOnlyActiveDate:ae=!1,autoPlay:U=!1,ariaLabel:H,resetSelectionOnDoubleClick:R=!0,detailsOnClick:ee,styles:J,classNames:Z,mapProjection:re}=t,[te,F]=I.useState(0),[q,X]=I.useState(0),[ie,ce]=I.useState(void 0),de=I.useRef(null),he=I.useRef(null);I.useEffect(()=>{const ve=new ResizeObserver(le=>{F(s||le[0].target.clientWidth||760),X(l||le[0].target.clientHeight||480)});return de.current&&(X(de.current.clientHeight||480),F(de.current.clientWidth||760),s||ve.observe(de.current)),()=>ve.disconnect()},[s,l]),I.useEffect(()=>{typeof r=="string"?ka(r).then(le=>{ce(le)}):ce(r||u7)},[r]);const Oe=c||(d==="categorical"?J0(e,"x"):X3(e.map(ve=>ve.x),(a==null?void 0:a.length)||4)),[Ne,Te]=I.useState(U),_e=qi(Bt(e,ve=>ve.date).map(ve=>bt(`${ve.date}`,G,new Date).getTime()),(ve,le)=>Ka(ve,le)),[xe,we]=I.useState(U?0:_e.length-1),ge={};return _e.forEach((ve,le)=>{ge[`${ve}`]={style:{color:le===xe?"#232E3D":"#A9B1B7",fontWeight:le===xe?"bold":"normal",display:le===xe||!ae?"inline":"none"},label:Sa(new Date(ve),G)}}),I.useEffect(()=>{const ve=setInterval(()=>{we(le=>le<_e.length-1?le+1:0)},2e3);return Ne||clearInterval(ve),()=>clearInterval(ve)},[_e,Ne]),v.jsx("div",{className:`${W||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:V==="he"||V==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${w?w===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${V||"en"}`,Z==null?void 0:Z.graphContainer),style:{...(J==null?void 0:J.graphContainer)||{},...w&&w!==!0?{backgroundColor:w}:{}},id:N,ref:he,"aria-label":H||`${n?`The graph shows ${n}. `:""}This is a choropleth map where geographic areas are colored in proportion to a specific variable showing data changes over time.${o?` ${o}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:w?y||"1rem":y||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[n||o||B||j?v.jsx(Zt,{styles:{title:J==null?void 0:J.title,description:J==null?void 0:J.description},classNames:{title:Z==null?void 0:Z.title,description:Z==null?void 0:Z.description},graphTitle:n,graphDescription:o,width:s,graphDownload:B?he.current:void 0,dataDownload:j?e.map(ve=>ve.data).filter(ve=>ve!==void 0).length>0?e.map(ve=>ve.data).filter(ve=>ve!==void 0):e.filter(ve=>ve!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{Te(!Ne)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":Ne?"Click to pause animation":"Click to play animation",children:Ne?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:_e[0],max:_e[_e.length-1],marks:ge,step:null,defaultValue:_e[_e.length-1],value:_e[xe],onChangeComplete:ve=>{we(_e.indexOf(ve))},onChange:ve=>{we(_e.indexOf(ve))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:de,"aria-label":"Map area",children:(s||te)&&(l||q)&&ie?v.jsx(uve,{data:e,mapData:$?ie:{...ie,features:ie.features.filter(ve=>ve.properties.NAME!=="Antarctica")},colorDomain:Oe,width:s||te,height:Math.max(z,l||(k?z?(s||te)*k>z?(s||te)*k:z:(s||te)*k:q)),scale:m,centerPoint:g,colors:a||(d==="categorical"?Qe[W].sequentialColors[`neutralColorsx0${Oe.length}`]:Qe[W].sequentialColors[`neutralColorsx0${Oe.length+1}`]),colorLegendTitle:h,mapBorderWidth:b,mapNoDataColor:S,categorical:d==="categorical",mapBorderColor:C,tooltip:_,onSeriesMouseOver:D,isWorldMap:T,showColorScale:A,zoomScaleExtend:M,zoomTranslateExtend:E,onSeriesMouseClick:ne,mapProperty:K,highlightedIds:Y,dateFormat:G,indx:xe,resetSelectionOnDoubleClick:R,styles:J,classNames:Z,detailsOnClick:ee,mapProjection:re||(T?"naturalEarth":"mercator")}):null}),i||f?v.jsx(tr,{styles:{footnote:J==null?void 0:J.footnote,source:J==null?void 0:J.source},classNames:{footnote:Z==null?void 0:Z.footnote,source:Z==null?void 0:Z.source},sources:i,footNote:f,width:s}):null]})})})})}function cve(t){var Te;const{data:e,colors:r,mapData:n,colorLegendTitle:a,colorDomain:i,radius:o,height:l,width:s,scale:f,centerPoint:c,tooltip:h,showLabels:d,mapBorderWidth:m,mapBorderColor:g,mapNoDataColor:y,onSeriesMouseOver:b,showColorScale:S,zoomScaleExtend:w,zoomTranslateExtend:C,highlightedDataPoints:k,onSeriesMouseClick:_,dateFormat:D,indx:T,resetSelectionOnDoubleClick:A,detailsOnClick:M,styles:E,classNames:N,mapProjection:Y}=t,ne=Array.from(Hi(Ut(e,_e=>bt(`${_e.date}`,D||"yyyy",new Date)),_e=>_e.date),([_e,xe])=>({date:_e,values:xe})),[K,B]=I.useState(void 0),[j,$]=I.useState(!(s<680)),V=I.useRef(null),[z,W]=I.useState(50),[G,ae]=I.useState(void 0),[U,H]=I.useState(void 0),[R,ee]=I.useState(void 0),[J,Z]=I.useState(void 0),re=I.useRef(null),te=I.useRef(null),F=e.filter(_e=>_e.radius===void 0).length!==e.length?l4().domain([0,(Te=Vr(e,"radius"))==null?void 0:Te.radius]).range([.25,o]).nice():void 0;I.useEffect(()=>{const _e=Qr(te.current),xe=Qr(re.current),we=g7().scaleExtent(w).translateExtent(C||[[-20,-20],[s+20,l+20]]).on("zoom",({transform:ge})=>{_e.attr("transform",ge)});xe.call(we)},[l,s]),I.useEffect(()=>{(()=>{if(V.current){const xe=V.current.getBoundingClientRect().height;W(xe+16)}})()},[]);const q=c7(n),X=o9(n),ie=q[2]-q[0],ce=q[3]-q[1],de=s*190/960*360/ie,he=l*190/678*180/ce,Oe=f*Math.min(de,he),Ne=Y==="mercator"?d7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):Y==="equalEarth"?h7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):Y==="naturalEarth"?p7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):Y==="orthographic"?m7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):f7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe);return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{width:`${s}px`,height:`${l}px`,viewBox:`0 0 ${s} ${l}`,ref:re,direction:"ltr",children:[v.jsxs("g",{ref:te,children:[n.features.map((_e,xe)=>v.jsx("g",{children:_e.geometry.type==="MultiPolygon"?_e.geometry.coordinates.map((we,ge)=>{let ve="";return we.forEach(le=>{let ue=" M";le.forEach((Ce,pe)=>{const ye=Ne([Ce[0],Ce[1]]);pe!==le.length-1?ue=`${ue}${ye[0]} ${ye[1]}L`:ue=`${ue}${ye[0]} ${ye[1]}`}),ve+=ue}),v.jsx("path",{d:ve,style:{stroke:g,strokeWidth:m,fill:y}},ge)}):_e.geometry.coordinates.map((we,ge)=>{let ve="M";return we.forEach((le,ue)=>{const Ce=Ne([le[0],le[1]]);ue!==we.length-1?ve=`${ve}${Ce[0]} ${Ce[1]}L`:ve=`${ve}${Ce[0]} ${Ce[1]}`}),v.jsx("path",{d:ve,style:{stroke:g,strokeWidth:m,fill:y}},ge)})},xe)),v.jsx(mo,{children:ne[T].values.map((_e,xe)=>{const we=e.filter(ge=>ge.color).length===0?r[0]:_e.color?r[i.indexOf(`${_e.color}`)]:Qe.gray;return v.jsxs("g",{opacity:K?K===we?1:.3:k.length!==0?k.indexOf(_e.data.id)!==-1?1:.3:1,onMouseEnter:ge=>{H(_e),Z(ge.clientY),ee(ge.clientX),b&&b(_e)},onMouseMove:ge=>{H(_e),Z(ge.clientY),ee(ge.clientX)},onMouseLeave:()=>{H(void 0),ee(void 0),Z(void 0),b&&b(void 0)},onClick:()=>{(_||M)&&(Sr(G,_e)&&A?(ae(void 0),_==null||_(void 0)):(ae(_e),_==null||_(_e)))},children:[v.jsx(ur.circle,{cx:Ne([_e.long,_e.lat])[0],cy:Ne([_e.long,_e.lat])[1],style:{fillOpacity:.8},animate:{r:F?F(_e.radius||0):o,fill:e.filter(ge=>ge.color).length===0?r[0]:_e.color?r[i.indexOf(`${_e.color}`)]:Qe.gray,stroke:e.filter(ge=>ge.color).length===0?r[0]:_e.color?r[i.indexOf(`${_e.color}`)]:Qe.gray},transition:{duration:.5}}),d&&_e.label?v.jsx(ur.text,{x:F?Ne([_e.long,_e.lat])[0]+F(_e.radius||0):Ne([_e.long,_e.lat])[0]+o,y:Ne([_e.long,_e.lat])[1],className:"fill-primary-gray-600 dark:fill-primary-gray-300 text-sm",style:{textAnchor:"start"},dx:4,dy:5,animate:{opacity:1},transition:{duration:.5},children:_e.label}):null]},xe)})})]}),v.jsx("foreignObject",{x:10,y:j?l-z-5:l-46,width:j?150:101,height:j?z:36,children:e.filter(_e=>_e.color).length===0||S===!1?null:j?v.jsxs("div",{ref:V,children:[v.jsx("div",{style:{marginBottom:"-0.75rem",marginLeft:"126px",backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"relative"},onClick:()=>{$(!1)},children:v.jsx(n7,{})}),v.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.5",width:"138px"},children:[a&&a!==""?v.jsx(or,{size:"xs",marginBottom:"xs",className:"p-0 leading-normal overflow-hidden text-primary-gray-700 dark:text-primary-gray-300",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical"},children:a}):null,v.jsx("div",{className:"flex flex-col gap-3",children:i.map((_e,xe)=>v.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{B(r[xe%r.length])},onMouseLeave:()=>{B(void 0)},children:[v.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:r[xe%r.length]}}),v.jsx(or,{size:"sm",marginBottom:"none",leading:"none",children:_e})]},xe))})]})]}):v.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{$(!0)},children:v.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})})})]}),U&&h&&R&&J?v.jsx(yr,{data:U,body:h,xPos:R,yPos:J,backgroundStyle:E==null?void 0:E.tooltip,className:N==null?void 0:N.tooltip}):null,M?v.jsx(Tr,{open:G!==void 0,onClose:()=>{ae(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(M,G)}})}):null]})}function hq(t){const{data:e,mapData:r,graphTitle:n,colors:a,sources:i,graphDescription:o,height:l,width:s,footNote:f,colorLegendTitle:c,colorDomain:h,radius:d=5,scale:m=.95,centerPoint:g,padding:y,mapBorderWidth:b=.5,mapNoDataColor:S=Qe.light.graphNoData,backgroundColor:w=!1,showLabels:C=!1,mapBorderColor:k=Qe.light.grays["gray-500"],tooltip:_,relativeHeight:D,onSeriesMouseOver:T,isWorldMap:A=!0,showColorScale:M=!0,zoomScaleExtend:E=[.8,6],zoomTranslateExtend:N,graphID:Y,dateFormat:ne="yyyy",showOnlyActiveDate:K=!1,autoPlay:B=!1,highlightedDataPoints:j=[],onSeriesMouseClick:$,graphDownload:V=!1,dataDownload:z=!1,showAntarctica:W=!1,language:G="en",minHeight:ae=0,theme:U="light",ariaLabel:H,resetSelectionOnDoubleClick:R=!0,detailsOnClick:ee,styles:J,classNames:Z,mapProjection:re}=t,[te,F]=I.useState(0),[q,X]=I.useState(0),[ie,ce]=I.useState(void 0),de=I.useRef(null),he=I.useRef(null);I.useEffect(()=>{const ge=new ResizeObserver(ve=>{F(s||ve[0].target.clientWidth||760),X(l||ve[0].target.clientHeight||480)});return de.current&&(X(de.current.clientHeight||480),F(de.current.clientWidth||760),s||ge.observe(de.current)),()=>ge.disconnect()},[s,l]);const[Oe,Ne]=I.useState(B),Te=qi(Bt(e,ge=>ge.date).map(ge=>bt(`${ge.date}`,ne,new Date).getTime()),(ge,ve)=>Ka(ge,ve)),[_e,xe]=I.useState(B?0:Te.length-1),we={};return Te.forEach((ge,ve)=>{we[`${ge}`]={style:{color:ve===_e?"#232E3D":"#A9B1B7",fontWeight:ve===_e?"bold":"normal",display:ve===_e||!K?"inline":"none"},label:Sa(new Date(ge),ne)}}),I.useEffect(()=>{const ge=setInterval(()=>{xe(ve=>ve<Te.length-1?ve+1:0)},2e3);return Oe||clearInterval(ge),()=>clearInterval(ge)},[Te,Oe]),I.useEffect(()=>{typeof r=="string"?ka(r).then(ve=>{ce(ve)}):ce(r||u7)},[r]),v.jsx("div",{className:`${U||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:G==="he"||G==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${w?w===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${G||"en"}`,Z==null?void 0:Z.graphContainer),style:{...(J==null?void 0:J.graphContainer)||{},...w&&w!==!0?{backgroundColor:w}:{}},id:Y,ref:he,"aria-label":H||`${n?`The graph shows ${n}. `:""}This is an animated dot density map showing the distribution of a variable across a region or world, with each dot representing a data point and changes over time.${o?` ${o}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:w?y||"1rem":y||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[n||o||V||z?v.jsx(Zt,{styles:{title:J==null?void 0:J.title,description:J==null?void 0:J.description},classNames:{title:Z==null?void 0:Z.title,description:Z==null?void 0:Z.description},graphTitle:n,graphDescription:o,width:s,graphDownload:V?he.current:void 0,dataDownload:z?e.map(ge=>ge.data).filter(ge=>ge!==void 0).length>0?e.map(ge=>ge.data).filter(ge=>ge!==void 0):e.filter(ge=>ge!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{Ne(!Oe)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":Oe?"Click to pause animation":"Click to play animation",children:Oe?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:Te[0],max:Te[Te.length-1],marks:we,step:null,defaultValue:Te[Te.length-1],value:Te[_e],onChangeComplete:ge=>{xe(Te.indexOf(ge))},onChange:ge=>{xe(Te.indexOf(ge))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:de,"aria-label":"Map area",children:(s||te)&&(l||q)&&ie?v.jsx(cve,{data:e,mapData:W?ie:{...ie,features:ie.features.filter(ge=>ge.properties.NAME!=="Antarctica")},colorDomain:e.filter(ge=>ge.color).length===0?[]:h||Bt(e.filter(ge=>!Fe(ge.color)),"color").map(ge=>`${ge.color}`),width:s||te,height:Math.max(ae,l||(D?ae?(s||te)*D>ae?(s||te)*D:ae:(s||te)*D:q)),scale:m,centerPoint:g,colors:e.filter(ge=>ge.color).length===0?a?[a]:[Qe.primaryColors["blue-600"]]:a||Qe[U].categoricalColors.colors,colorLegendTitle:c,radius:d,mapBorderWidth:b,mapNoDataColor:S,mapBorderColor:k,tooltip:_,onSeriesMouseOver:T,showLabels:C,isWorldMap:A,showColorScale:M,zoomScaleExtend:E,zoomTranslateExtend:N,onSeriesMouseClick:$,highlightedDataPoints:j,dateFormat:ne,indx:_e,resetSelectionOnDoubleClick:R,styles:J,classNames:Z,detailsOnClick:ee,mapProjection:re||(A?"naturalEarth":"mercator")}):null}),i||f?v.jsx(tr,{styles:{footnote:J==null?void 0:J.footnote,source:J==null?void 0:J.source},classNames:{footnote:Z==null?void 0:Z.footnote,source:Z==null?void 0:Z.source},sources:i,footNote:f,width:s}):null]})})})})}function fve(t){var be,je,$e,ut,Ie,Ze,Ke,et,Pt,jt,Tt,St,tt,Mt,Dt,Ye,Lt,Et,Xt,He,It,Ge,Rt,$t,dr,xr,Mr,Er,it;const{data:e,width:r,height:n,showLabels:a,colors:i,colorDomain:o,radius:l,xAxisTitle:s,yAxisTitle:f,leftMargin:c,rightMargin:h,topMargin:d,bottomMargin:m,tooltip:g,onSeriesMouseOver:y,refXValues:b,refYValues:S,highlightAreaSettings:w,selectedColor:C,highlightedDataPoints:k,maxRadiusValue:_,maxXValue:D,minXValue:T,maxYValue:A,minYValue:M,onSeriesMouseClick:E,dateFormat:N,indx:Y,rtl:ne,annotations:K,customHighlightAreaSettings:B,resetSelectionOnDoubleClick:j,detailsOnClick:$,noOfXTicks:V,noOfYTicks:z,labelColor:W,xSuffix:G,ySuffix:ae,xPrefix:U,yPrefix:H,styles:R,classNames:ee}=t,J=Ut(e.map(Xe=>({...Xe,date:bt(`${Xe.date}`,N,new Date)})),"date"),Z=Bt(J,Xe=>Xe.label).map(Xe=>Xe.label),re=Array.from(Hi(ove(e,N||"yyyy"),Xe=>Xe.date),([Xe,Vt])=>({date:Xe,values:Z.map(Yt=>Vt.find(at=>at.label===Yt)).map(Yt=>({...Yt,id:Yt.label}))})),[te,F]=I.useState(void 0),[q,X]=I.useState(void 0),[ie,ce]=I.useState(void 0),[de,he]=I.useState(void 0),Oe={top:d,bottom:m,left:f?c+40:c,right:h},Ne=r-Oe.left-Oe.right,Te=n-Oe.top-Oe.bottom,_e=e.filter(Xe=>Xe.radius===void 0).length!==e.length?l4().domain([0,Fe(_)?(be=Vr(e,"radius"))==null?void 0:be.radius:_]).range([.25,l]).nice():void 0,xe=Fe(T)?((je=Br(e,"x"))==null?void 0:je.x)>0?0:($e=Br(e,"x"))==null?void 0:$e.x:T,we=Fe(D)?((ut=Vr(e,"x"))==null?void 0:ut.x)>0?(Ie=Vr(e,"x"))==null?void 0:Ie.x:0:D,ge=br().domain([xe,we]).range([0,Ne]).nice(),ve=Fe(M)?((Ze=Br(e,"y"))==null?void 0:Ze.y)>0?0:(Ke=Br(e,"y"))==null?void 0:Ke.y:M,le=Fe(A)?((et=Vr(e,"y"))==null?void 0:et.y)>0?(Pt=Vr(e,"y"))==null?void 0:Pt.y:0:A,ue=br().domain([ve,le]).range([Te,0]).nice(),Ce=ge.ticks(V),pe=ue.ticks(z),ye=i9.from(re[Y].values.filter(Xe=>!Fe(Xe.x)&&!Fe(Xe.y)),Xe=>ge(Xe.x),Xe=>ue(Xe.y)).voronoi([0,0,Ne<0?0:Ne,Te<0?0:Te]);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${Oe.left},${Oe.top})`,children:[v.jsx(Az,{areaSettings:w,width:Ne,height:Te,scaleX:ge,scaleY:ue}),v.jsx(Z2,{areaSettings:B,scaleX:ge,scaleY:ue}),v.jsxs("g",{children:[v.jsx(v1,{values:pe.filter(Xe=>Xe!==0),y:pe.filter(Xe=>Xe!==0).map(Xe=>ue(Xe)),x1:0,x2:Ne+Oe.right,styles:{gridLines:(jt=R==null?void 0:R.yAxis)==null?void 0:jt.gridLines,labels:(Tt=R==null?void 0:R.yAxis)==null?void 0:Tt.labels},classNames:{gridLines:(St=ee==null?void 0:ee.yAxis)==null?void 0:St.gridLines,labels:(tt=ee==null?void 0:ee.yAxis)==null?void 0:tt.labels},suffix:ae,prefix:H,labelType:"primary",showGridLines:!0,labelPos:"side"}),v.jsx(Nr,{y1:ue(ve<0?0:ve),y2:ue(ve<0?0:ve),x1:0,x2:Ne,label:_t(ve<0?0:ve,H,ae),labelPos:{x:0,y:ue(ve<0?0:ve),dy:"0.33em",dx:-4},classNames:{axis:(Mt=ee==null?void 0:ee.xAxis)==null?void 0:Mt.axis,label:(Dt=ee==null?void 0:ee.yAxis)==null?void 0:Dt.labels},styles:{axis:(Ye=R==null?void 0:R.xAxis)==null?void 0:Ye.axis,label:{textAnchor:"end",...((Lt=R==null?void 0:R.yAxis)==null?void 0:Lt.labels)||{}}}}),v.jsx(nn,{x:0-Oe.left+15,y:Te/2,style:(Et=R==null?void 0:R.yAxis)==null?void 0:Et.title,className:(Xt=ee==null?void 0:ee.yAxis)==null?void 0:Xt.title,text:f,rotate90:!0})]}),v.jsxs("g",{children:[v.jsx(La,{values:Ce.filter(Xe=>Xe!==0),x:Ce.filter(Xe=>Xe!==0).map(Xe=>ge(Xe)),y1:0,y2:Te,styles:{gridLines:(He=R==null?void 0:R.xAxis)==null?void 0:He.gridLines,labels:(It=R==null?void 0:R.xAxis)==null?void 0:It.labels},classNames:{gridLines:(Ge=ee==null?void 0:ee.xAxis)==null?void 0:Ge.gridLines,labels:(Rt=ee==null?void 0:ee.xAxis)==null?void 0:Rt.labels},suffix:G,prefix:U,labelType:"primary",showGridLines:!0}),v.jsx(Nr,{x1:ge(xe<0?0:xe),x2:ge(xe<0?0:xe),y1:0,y2:Te,label:_t(xe<0?0:xe,U,G),labelPos:{x:ge(xe<0?0:xe),y:Te,dy:"1em",dx:0},classNames:{axis:($t=ee==null?void 0:ee.xAxis)==null?void 0:$t.axis,label:(dr=ee==null?void 0:ee.yAxis)==null?void 0:dr.labels},styles:{axis:(xr=R==null?void 0:R.xAxis)==null?void 0:xr.axis,label:{textAnchor:"middle",...((Mr=R==null?void 0:R.yAxis)==null?void 0:Mr.labels)||{}}}}),v.jsx(nn,{x:Ne/2,y:Te+30,style:(Er=R==null?void 0:R.xAxis)==null?void 0:Er.title,className:(it=ee==null?void 0:ee.xAxis)==null?void 0:it.title,text:s})]}),v.jsxs(mo,{children:[re[Y].values.map((Xe,Vt)=>v.jsx("g",{children:v.jsx("path",{d:ye.renderCell(re[Y].values.findIndex(Yt=>Yt.id===Xe.id)),className:"opacity-0",onMouseEnter:Yt=>{F(Xe),he(Yt.clientY),ce(Yt.clientX),y&&y(Xe)},onMouseMove:Yt=>{F(Xe),he(Yt.clientY),ce(Yt.clientX)},onMouseLeave:()=>{F(void 0),ce(void 0),he(void 0),y&&y(void 0)},onClick:()=>{(E||$)&&(Sr(q,Xe)&&j?(X(void 0),E==null||E(void 0)):(X(Xe),E==null||E(Xe)))}})},Vt)),re[Y].values.map((Xe,Vt)=>v.jsx("g",{children:v.jsxs(ur.g,{opacity:C?Xe.color&&i[o.indexOf(`${Xe.color}`)]===C?1:.3:te?te.label===Xe.label?1:.3:k.length!==0?k.indexOf(Xe.label||"")!==-1?1:.5:1,onMouseEnter:Yt=>{F(Xe),he(Yt.clientY),ce(Yt.clientX),y&&y(Xe)},onMouseMove:Yt=>{F(Xe),he(Yt.clientY),ce(Yt.clientX)},onMouseLeave:()=>{F(void 0),ce(void 0),he(void 0),y&&y(void 0)},onClick:()=>{(E||$)&&(Sr(q,Xe)&&j?(X(void 0),E==null||E(void 0)):(X(Xe),E==null||E(Xe)))},children:[v.jsx(ur.circle,{cx:0,cy:0,style:{fill:e.filter(Yt=>Yt.color).length===0?i[0]:Xe.color?i[o.indexOf(`${Xe.color}`)]:Qe.gray,stroke:e.filter(Yt=>Yt.color).length===0?i[0]:Xe.color?i[o.indexOf(`${Xe.color}`)]:Qe.gray,fillOpacity:.6},animate:{cx:ge(Xe.x||0),cy:ue(Xe.y||0),r:Fe(Xe.x)||Fe(Xe.y)?0:_e?_e(Xe.radius||0):l},transition:{duration:.5}}),a&&!Fe(Xe.label)?v.jsx(ur.text,{className:Be("graph-value text-sm",ee==null?void 0:ee.graphObjectValues),style:{fill:W||(e.filter(Yt=>Yt.color).length===0?i[0]:Xe.color?i[o.indexOf(`${Xe.color}`)]:Qe.gray),...(R==null?void 0:R.graphObjectValues)||{}},dy:"0.33em",dx:3,animate:{attrY:ue(Xe.y||0),attrX:_e?ge(Xe.x||0)+_e(Xe.radius||0):ge(Xe.x||0)+l,opacity:Fe(Xe.x)||Fe(Xe.y)?0:1},transition:{duration:.5},children:Xe.label}):k.length!==0&&!Fe(Xe.label)&&k.indexOf(Xe.label)!==-1?v.jsx(ur.text,{className:Be("graph-value text-sm",ee==null?void 0:ee.graphObjectValues),style:{fill:W||(e.filter(Yt=>Yt.color).length===0?i[0]:Xe.color?i[o.indexOf(`${Xe.color}`)]:Qe.gray),...(R==null?void 0:R.graphObjectValues)||{}},dy:"0.33em",dx:3,animate:{attrY:ue(Xe.y||0),attrX:_e?ge(Xe.x||0)+_e(Xe.radius||0):ge(Xe.x||0)+l,opacity:Fe(Xe.x)||Fe(Xe.y)?0:1},transition:{duration:.5},children:Xe.label}):null]})},Vt))]}),b.map((Xe,Vt)=>v.jsx(ti,{text:Xe.text,color:Xe.color,x:ge(Xe.value),y1:0,y2:Te,textSide:ge(Xe.value)>Ne*.75||ne?"left":"right",classNames:Xe.classNames,styles:Xe.styles},Vt)),S.map((Xe,Vt)=>v.jsx(h1,{text:Xe.text,color:Xe.color,y:ue(Xe.value),x1:0,x2:Ne,classNames:Xe.classNames,styles:Xe.styles},Vt)),v.jsx("g",{children:K.map((Xe,Vt)=>{const Yt=K2({x:Xe.xCoordinate?ge(Xe.xCoordinate)+(Xe.xOffset||0):0+(Xe.xOffset||0),y:Xe.yCoordinate?ue(Xe.yCoordinate)+(Xe.yOffset||0)-8:0+(Xe.yOffset||0)-8},{x:Xe.xCoordinate?ge(Xe.xCoordinate):0,y:Xe.yCoordinate?ue(Xe.yCoordinate):0},Fe(Xe.connectorRadius)?3.5:Xe.connectorRadius),at=Xe.showConnector?{y1:Yt.y,x1:Yt.x,y2:Xe.yCoordinate?ue(Xe.yCoordinate)+(Xe.yOffset||0):0+(Xe.yOffset||0),x2:Xe.xCoordinate?ge(Xe.xCoordinate)+(Xe.xOffset||0):0+(Xe.xOffset||0),cy:Xe.yCoordinate?ue(Xe.yCoordinate):0,cx:Xe.xCoordinate?ge(Xe.xCoordinate):0,circleRadius:Fe(Xe.connectorRadius)?3.5:Xe.connectorRadius,strokeWidth:Xe.showConnector===!0?2:Math.min(Xe.showConnector||0,1)}:void 0,cr={y:Xe.yCoordinate?ue(Xe.yCoordinate)+(Xe.yOffset||0)-8:0+(Xe.yOffset||0)-8,x:ne?0:Xe.xCoordinate?ge(Xe.xCoordinate)+(Xe.xOffset||0):0+(Xe.xOffset||0),width:ne?Xe.xCoordinate?ge(Xe.xCoordinate)+(Xe.xOffset||0):0+(Xe.xOffset||0):Ne-(Xe.xCoordinate?ge(Xe.xCoordinate)+(Xe.xOffset||0):0+(Xe.xOffset||0)),maxWidth:Xe.maxWidth,fontWeight:Xe.fontWeight,align:Xe.align};return v.jsx(J2,{color:Xe.color,connectorsSettings:at,labelSettings:cr,text:Xe.text,classNames:Xe.classNames,styles:Xe.styles},Vt)})})]})}),te&&g&&ie&&de?v.jsx(yr,{data:te,body:g,xPos:ie,yPos:de,backgroundStyle:R==null?void 0:R.tooltip,className:ee==null?void 0:ee.tooltip}):null,$?v.jsx(Tr,{open:q!==void 0,onClose:()=>{X(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr($,q)}})}):null]})}function pq(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,showLabels:o=!1,height:l,width:s,footNote:f,colorDomain:c,colorLegendTitle:h,radius:d=5,xAxisTitle:m="X Axis",yAxisTitle:g="Y Axis",padding:y,backgroundColor:b=!1,leftMargin:S=50,rightMargin:w=20,topMargin:C=20,bottomMargin:k=50,tooltip:_,relativeHeight:D,onSeriesMouseOver:T,refXValues:A=[],refYValues:M=[],highlightAreaSettings:E=[],showColorScale:N=!0,highlightedDataPoints:Y=[],graphID:ne,maxRadiusValue:K,maxXValue:B,minXValue:j,maxYValue:$,minYValue:V,onSeriesMouseClick:z,graphDownload:W=!1,dataDownload:G=!1,language:ae="en",showNAColor:U=!0,minHeight:H=0,annotations:R=[],customHighlightAreaSettings:ee=[],theme:J="light",ariaLabel:Z,resetSelectionOnDoubleClick:re=!0,dateFormat:te="yyyy",showOnlyActiveDate:F=!1,autoPlay:q=!1,detailsOnClick:X,noOfXTicks:ie=5,noOfYTicks:ce=5,labelColor:de,xSuffix:he="",ySuffix:Oe="",xPrefix:Ne="",yPrefix:Te="",styles:_e,classNames:xe}=t,[we,ge]=I.useState(0),[ve,le]=I.useState(0),[ue,Ce]=I.useState(void 0),pe=I.useRef(null),ye=I.useRef(null);I.useEffect(()=>{const Ke=new ResizeObserver(et=>{ge(s||et[0].target.clientWidth||620),le(l||et[0].target.clientHeight||480)});return pe.current&&(le(pe.current.clientHeight||480),ge(pe.current.clientWidth||620),s||Ke.observe(pe.current)),()=>Ke.disconnect()},[s,l]);const[be,je]=I.useState(q),$e=qi(Bt(e,Ke=>Ke.date).map(Ke=>bt(`${Ke.date}`,te,new Date).getTime()),(Ke,et)=>Ka(Ke,et)),[ut,Ie]=I.useState(q?0:$e.length-1),Ze={};return $e.forEach((Ke,et)=>{Ze[`${Ke}`]={style:{color:et===ut?"#232E3D":"#A9B1B7",fontWeight:et===ut?"bold":"normal",display:et===ut||!F?"inline":"none"},label:Sa(new Date(Ke),te)}}),I.useEffect(()=>{const Ke=setInterval(()=>{Ie(et=>et<$e.length-1?et+1:0)},2e3);return be||clearInterval(Ke),()=>clearInterval(Ke)},[$e,be]),v.jsx("div",{className:`${J||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:ae==="he"||ae==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${b?b===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${ae||"en"}`,xe==null?void 0:xe.graphContainer),style:{...(_e==null?void 0:_e.graphContainer)||{},...b&&b!==!0?{backgroundColor:b}:{}},id:ne,ref:ye,"aria-label":Z||`${r?`The graph shows ${r}. `:""}This is an animated scatter plot that shows correlation between two variables showing data changes over time.${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:b?y||"1rem":y||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||W||G?v.jsx(Zt,{styles:{title:_e==null?void 0:_e.title,description:_e==null?void 0:_e.description},classNames:{title:xe==null?void 0:xe.title,description:xe==null?void 0:xe.description},graphTitle:r,graphDescription:i,width:s,graphDownload:W?ye.current:void 0,dataDownload:G?e.map(Ke=>Ke.data).filter(Ke=>Ke!==void 0).length>0?e.map(Ke=>Ke.data).filter(Ke=>Ke!==void 0):e.filter(Ke=>Ke!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{je(!be)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":be?"Click to pause animation":"Click to play animation",children:be?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:$e[0],max:$e[$e.length-1],marks:Ze,step:null,defaultValue:$e[$e.length-1],value:$e[ut],onChangeComplete:Ke=>{Ie($e.indexOf(Ke))},onChange:Ke=>{Ie($e.indexOf(Ke))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[N&&e.filter(Ke=>Ke.color).length!==0?v.jsx(Cn,{width:s,colorLegendTitle:h,colors:n||Qe[J].categoricalColors.colors,colorDomain:c||Bt(e.filter(Ke=>Ke.color),"color").map(Ke=>Ke.color),setSelectedColor:Ce,showNAColor:U}):null,v.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:pe,"aria-label":"Graph area",children:(s||we)&&(l||ve)?v.jsx(fve,{data:e,width:s||we,height:Math.max(H,l||(D?H?(s||we)*D>H?(s||we)*D:H:(s||we)*D:ve)),colorDomain:e.filter(Ke=>Ke.color).length===0?[]:c||Bt(e.filter(Ke=>Ke.color),"color").map(Ke=>Ke.color),colors:e.filter(Ke=>Ke.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[J].categoricalColors.colors,xAxisTitle:m,yAxisTitle:g,refXValues:A,refYValues:M,showLabels:o,radius:d,leftMargin:S,rightMargin:w,topMargin:C,bottomMargin:k,tooltip:_,onSeriesMouseOver:T,highlightAreaSettings:E,highlightedDataPoints:e.filter(Ke=>Ke.label).length===0?[]:Y,selectedColor:ue,maxRadiusValue:K,maxXValue:B,minXValue:j,maxYValue:$,minYValue:V,onSeriesMouseClick:z,dateFormat:te,indx:ut,rtl:ae==="he"||ae==="ar",annotations:R,customHighlightAreaSettings:ee,resetSelectionOnDoubleClick:re,detailsOnClick:X,noOfXTicks:ie,noOfYTicks:ce,labelColor:de,xSuffix:he,ySuffix:Oe,xPrefix:Ne,yPrefix:Te,styles:_e,classNames:xe}):null})]}),a||f?v.jsx(tr,{styles:{footnote:_e==null?void 0:_e.footnote,source:_e==null?void 0:_e.source},classNames:{footnote:xe==null?void 0:xe.footnote,source:xe==null?void 0:xe.source},sources:a,footNote:f,width:s}):null]})})})})}function dve(t){var xe,we,ge,ve,le,ue;const{data:e,dotColors:r,suffix:n,prefix:a,barPadding:i,showValues:o,showTicks:l,leftMargin:s,truncateBy:f,width:c,height:h,rightMargin:d,topMargin:m,bottomMargin:g,radius:y,showLabels:b,tooltip:S,onSeriesMouseOver:w,maxPositionValue:C,minPositionValue:k,onSeriesMouseClick:_,selectedColor:D,dateFormat:T,indx:A,sortParameter:M,connectorStrokeWidth:E,arrowConnector:N,maxBarThickness:Y,minBarThickness:ne,resetSelectionOnDoubleClick:K,detailsOnClick:B,axisTitle:j,noOfTicks:$,valueColor:V,styles:z,classNames:W,refValues:G,rtl:ae}=t,U=Ut(e.map(Ce=>({...Ce,date:bt(`${Ce.date}`,T,new Date)})),"date"),H=Bt(U,Ce=>Ce.label).map(Ce=>Ce.label),R=Array.from(Hi(uq(e,T||"yyyy"),Ce=>Ce.date),([Ce,pe])=>({date:Ce,values:M!==void 0?M==="diff"?Ut(pe,ye=>Fe(ye.x[ye.x.length-1])||Fe(ye.x[0])?-1/0:ye.x[ye.x.length-1]-ye.x[0]).reverse().map((ye,be)=>({...ye,id:`${be}`})):Ut(pe,ye=>Fe(ye.x[M])?-1/0:ye.x[M]).reverse().map((ye,be)=>({...ye,id:`${be}`})):H.map(ye=>pe.find(be=>be.label===ye)).map((ye,be)=>({...ye,id:`${be}`}))})),ee={top:j?m+25:m,bottom:g,left:s,right:d},J=c-ee.left-ee.right,Z=h-ee.top-ee.bottom,[re,te]=I.useState(void 0),[F,q]=I.useState(void 0),[X,ie]=I.useState(void 0),[ce,de]=I.useState(void 0),he=Fe(C)?Math.max(...e.map(Ce=>Mn(Ce.x)||0))<0?0:Math.max(...e.map(Ce=>Mn(Ce.x)||0)):C,Oe=Fe(k)?Math.min(...e.map(Ce=>gr(Ce.x)||0))>0?0:Math.min(...e.map(Ce=>gr(Ce.x)||0)):k,Ne=br().domain([Oe,he]).range([0,J]).nice(),Te=Un().domain(H.map((Ce,pe)=>`${pe}`)).range([0,ne?Math.max(Z,ne*H.length):Y?Math.min(Z,Y*H.length):Z]).paddingInner(i),_e=Ne.ticks($);return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{width:`${c}px`,height:`${h}px`,viewBox:`0 0 ${c} ${h}`,direction:"ltr",children:[N?v.jsx("defs",{children:v.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:v.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-primary-gray-600 dark:fill-primary-gray-300"})})}):null,v.jsxs("g",{transform:`translate(${ee.left},${ee.top})`,children:[l?v.jsx(La,{values:_e.filter(Ce=>Ce!==0),x:_e.filter(Ce=>Ce!==0).map(Ce=>Ne(Ce)),y1:0-m,y2:Z+ee.bottom,styles:{gridLines:(xe=z==null?void 0:z.xAxis)==null?void 0:xe.gridLines,labels:(we=z==null?void 0:z.xAxis)==null?void 0:we.labels},classNames:{gridLines:(ge=W==null?void 0:W.xAxis)==null?void 0:ge.gridLines,labels:(ve=W==null?void 0:W.xAxis)==null?void 0:ve.labels},suffix:n,prefix:a,labelType:"secondary",showGridLines:!0}):null,v.jsx(nn,{x:J/2,y:0-ee.top+15,style:(le=z==null?void 0:z.xAxis)==null?void 0:le.title,className:(ue=W==null?void 0:W.xAxis)==null?void 0:ue.title,text:j}),v.jsx(mo,{children:R[A].values.map((Ce,pe)=>{var ye,be,je,$e;return v.jsxs(ur.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",children:[b?v.jsx(ur.text,{style:{textAnchor:"end",...((ye=z==null?void 0:z.yAxis)==null?void 0:ye.labels)||{}},x:0,dx:-10,dy:"0.33em",className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(be=W==null?void 0:W.yAxis)==null?void 0:be.labels),animate:{attrY:Te(`${pe}`)+Te.bandwidth()/2},transition:{duration:.5},children:`${Ce.label}`.length<f?Ce.label:`${`${Ce.label}`.substring(0,f)}...`}):null,v.jsx(ur.line,{x1:0,x2:J,className:Be("undp-tick-line stroke-primary-gray-400 dark:stroke-primary-gray-600",(je=W==null?void 0:W.yAxis)==null?void 0:je.gridLines),style:($e=z==null?void 0:z.yAxis)==null?void 0:$e.gridLines,animate:{y1:Te(`${pe}`)+Te.bandwidth()/2,y2:Te(`${pe}`)+Te.bandwidth()/2},transition:{duration:.5}}),v.jsx(ur.line,{style:{strokeWidth:E,...(z==null?void 0:z.dataConnectors)||{},opacity:D?.3:1},className:Be("stroke-primary-gray-600 dark:stroke-primary-gray-300",W==null?void 0:W.dataConnectors),animate:{y1:Te(`${pe}`)+Te.bandwidth()/2,y2:Te(`${pe}`)+Te.bandwidth()/2,x1:Ne(gr(Ce.x))+y,x2:Ne(Mn(Ce.x))-y},markerEnd:N&&Ce.x.indexOf(gr(Ce.x))===0?"url(#arrow)":"",markerStart:N&&Ce.x.indexOf(gr(Ce.x))===Ce.x.length-1?"url(#arrow)":""}),Ce.x.map((ut,Ie)=>v.jsxs(ur.g,{opacity:D?r[Ie]===D?1:.3:1,onMouseEnter:Ze=>{te({...Ce,xIndex:Ie}),de(Ze.clientY),ie(Ze.clientX),w&&w({...Ce,xIndex:Ie})},onClick:()=>{(_||B)&&(Sr(F,{...Ce,xIndex:Ie})&&K?(q(void 0),_==null||_(void 0)):(q({...Ce,xIndex:Ie}),_&&_({...Ce,xIndex:Ie})))},onMouseMove:Ze=>{te({...Ce,xIndex:Ie}),de(Ze.clientY),ie(Ze.clientX)},onMouseLeave:()=>{te(void 0),ie(void 0),de(void 0),w&&w(void 0)},children:[v.jsx(ur.circle,{r:y,style:{fill:r[Ie],fillOpacity:.85,stroke:r[Ie],strokeWidth:1},animate:{cy:Te(`${pe}`)+Te.bandwidth()/2,cx:Ne(ut||0),opacity:Fe(ut)?0:1},transition:{duration:.5}}),o?v.jsx(ur.text,{style:{fill:V||r[Ie],textAnchor:"middle",opacity:Fe(ut)?0:1,...(z==null?void 0:z.graphObjectValues)||{}},className:Be("graph-value text-sm font-bold",W==null?void 0:W.graphObjectValues),dx:0,dy:0-y-3,animate:{attrY:Te(`${pe}`)+Te.bandwidth()/2,attrX:Ne(ut||0),opacity:Fe(ut)?0:1},transition:{duration:.5},children:_t(ut,a,n)}):null]},Ie))]},pe)})}),G?v.jsx(v.Fragment,{children:G.map((Ce,pe)=>v.jsx(ti,{text:Ce.text,color:Ce.color,x:Ne(Ce.value),y1:0-ee.top,y2:Z+ee.bottom,textSide:Ne(Ce.value)>J*.75||ae?"left":"right",classNames:Ce.classNames,styles:Ce.styles},pe))}):null]})]}),re&&S&&X&&ce?v.jsx(yr,{data:re,body:S,xPos:X,yPos:ce,backgroundStyle:z==null?void 0:z.tooltip,className:W==null?void 0:W.tooltip}):null,B?v.jsx(Tr,{open:F!==void 0,onClose:()=>{q(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(B,F)}})}):null]})}function hve(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,suffix:a="",prefix:i="",sources:o,graphDescription:l,barPadding:s=.25,showTicks:f=!0,leftMargin:c=100,rightMargin:h=40,topMargin:d=20,bottomMargin:m=10,truncateBy:g=999,showValues:y=!0,height:b,width:S,footNote:w,colorDomain:C,colorLegendTitle:k,padding:_,backgroundColor:D=!1,radius:T=3,showLabels:A=!0,tooltip:M,relativeHeight:E,onSeriesMouseOver:N,graphID:Y,maxPositionValue:ne,minPositionValue:K,onSeriesMouseClick:B,graphDownload:j=!1,dataDownload:$=!1,sortParameter:V,showOnlyActiveDate:z=!1,autoPlay:W=!1,dateFormat:G="yyyy",arrowConnector:ae=!1,connectorStrokeWidth:U=2,language:H="en",minHeight:R=0,theme:ee="light",maxBarThickness:J,minBarThickness:Z,ariaLabel:re,resetSelectionOnDoubleClick:te=!0,detailsOnClick:F,axisTitle:q,noOfTicks:X=5,valueColor:ie,styles:ce,classNames:de,refValues:he}=t,[Oe,Ne]=I.useState(0),[Te,_e]=I.useState(0),[xe,we]=I.useState(void 0),ge=I.useRef(null),ve=I.useRef(null);I.useEffect(()=>{const je=new ResizeObserver($e=>{Ne(S||$e[0].target.clientWidth||620),_e(b||$e[0].target.clientHeight||480)});return ge.current&&(_e(ge.current.clientHeight||480),Ne(ge.current.clientWidth||620),S||je.observe(ge.current)),()=>je.disconnect()},[S,b]);const[le,ue]=I.useState(W),Ce=qi(Bt(e,je=>je.date).map(je=>bt(`${je.date}`,G,new Date).getTime()),(je,$e)=>Ka(je,$e)),[pe,ye]=I.useState(W?0:Ce.length-1),be={};return Ce.forEach((je,$e)=>{be[`${je}`]={style:{color:$e===pe?"#232E3D":"#A9B1B7",fontWeight:$e===pe?"bold":"normal",display:$e===pe||!z?"inline":"none"},label:Sa(new Date(je),G)}}),I.useEffect(()=>{const je=setInterval(()=>{ye($e=>$e<Ce.length-1?$e+1:0)},2e3);return le||clearInterval(je),()=>clearInterval(je)},[Ce,le]),v.jsx("div",{className:`${ee||"light"} flex ${S?"w-fit grow-0":"w-full grow"}`,dir:H==="he"||H==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${D?D===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${H||"en"}`,de==null?void 0:de.graphContainer),style:{...(ce==null?void 0:ce.graphContainer)||{},...D&&D!==!0?{backgroundColor:D}:{}},id:Y,ref:ve,"aria-label":re||`${r?`The graph shows ${r}. `:""}This is an animated dumbbell chart that shows comparisons between two or more data points across categories. ${l?` ${l}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:D?_||"1rem":_||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||l||j||$?v.jsx(Zt,{styles:{title:ce==null?void 0:ce.title,description:ce==null?void 0:ce.description},classNames:{title:de==null?void 0:de.title,description:de==null?void 0:de.description},graphTitle:r,graphDescription:l,width:S,graphDownload:j?ve.current:void 0,dataDownload:$?e.map(je=>je.data).filter(je=>je!==void 0).length>0?e.map(je=>je.data).filter(je=>je!==void 0):e.filter(je=>je!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{ue(!le)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":le?"Click to pause animation":"Click to play animation",children:le?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:Ce[0],max:Ce[Ce.length-1],marks:be,step:null,defaultValue:Ce[Ce.length-1],value:Ce[pe],onChangeComplete:je=>{ye(Ce.indexOf(je))},onChange:je=>{ye(Ce.indexOf(je))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[v.jsx(Cn,{width:S,colorDomain:C,colors:n,colorLegendTitle:k,setSelectedColor:we,showNAColor:!1}),v.jsx("div",{className:"flex grow w-full justify-center leading-0",ref:ge,"aria-label":"Graph area",children:(S||Oe)&&(b||Te)?v.jsx(dve,{data:e,dotColors:n,width:S||Oe,height:Math.max(R,b||(E?R?(S||Oe)*E>R?(S||Oe)*E:R:(S||Oe)*E:Te)),suffix:a,prefix:i,radius:T,barPadding:s,showTicks:f,leftMargin:c,rightMargin:h,topMargin:d,bottomMargin:m,truncateBy:g,showLabels:A,showValues:y,tooltip:M,onSeriesMouseOver:N,maxPositionValue:ne,minPositionValue:K,onSeriesMouseClick:B,selectedColor:xe,dateFormat:G,indx:pe,sortParameter:V,arrowConnector:ae,connectorStrokeWidth:U,maxBarThickness:J,minBarThickness:Z,resetSelectionOnDoubleClick:te,detailsOnClick:F,axisTitle:q,noOfTicks:X,valueColor:ie,styles:ce,classNames:de,refValues:he,rtl:H==="he"||H==="ar"}):null})]}),o||w?v.jsx(tr,{styles:{footnote:ce==null?void 0:ce.footnote,source:ce==null?void 0:ce.source},classNames:{footnote:de==null?void 0:de.footnote,source:de==null?void 0:de.source},sources:o,footNote:w,width:S}):null]})})})})}function pve(t){var _e,xe,we,ge,ve,le,ue,Ce,pe,ye;const{data:e,dotColors:r,barPadding:n,showTicks:a,leftMargin:i,truncateBy:o,width:l,height:s,rightMargin:f,topMargin:c,bottomMargin:h,radius:d,showLabels:m,tooltip:g,onSeriesMouseOver:y,maxPositionValue:b,minPositionValue:S,onSeriesMouseClick:w,showValues:C,suffix:k,prefix:_,selectedColor:D,dateFormat:T,indx:A,sortParameter:M,arrowConnector:E,connectorStrokeWidth:N,maxBarThickness:Y,minBarThickness:ne,resetSelectionOnDoubleClick:K,detailsOnClick:B,axisTitle:j,noOfTicks:$,valueColor:V,styles:z,classNames:W,refValues:G}=t,ae=Ut(e.map(be=>({...be,date:bt(`${be.date}`,T,new Date)})),"date"),U=Bt(ae,be=>be.label).map(be=>be.label),H=Array.from(Hi(uq(e,T||"yyyy"),be=>be.date),([be,je])=>({date:be,values:M!==void 0?M==="diff"?Ut(je,$e=>Fe($e.x[$e.x.length-1])||Fe($e.x[0])?-1/0:$e.x[$e.x.length-1]-$e.x[0]).map(($e,ut)=>({...$e,id:`${ut}`})):Ut(je,$e=>Fe($e.x[M])?-1/0:$e.x[M]).map(($e,ut)=>({...$e,id:`${ut}`})):U.map($e=>je.find(ut=>ut.label===$e)).map(($e,ut)=>({...$e,id:`${ut}`}))})),R={top:c,bottom:h,left:j?i+30:i,right:f},ee=l-R.left-R.right,J=s-R.top-R.bottom,[Z,re]=I.useState(void 0),[te,F]=I.useState(void 0),[q,X]=I.useState(void 0),[ie,ce]=I.useState(void 0),de=Fe(b)?Math.max(...e.map(be=>Mn(be.x)||0))<0?0:Math.max(...e.map(be=>Mn(be.x)||0)):b,he=Fe(S)?Math.min(...e.map(be=>gr(be.x)||0))>0?0:Math.min(...e.map(be=>gr(be.x)||0)):S,Oe=br().domain([he,de]).range([J,0]).nice(),Ne=Un().domain(U.map((be,je)=>`${je}`)).range([0,ne?Math.max(ee,ne*U.length):Y?Math.min(ee,Y*U.length):ee]).paddingInner(n),Te=Oe.ticks($);return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{width:`${l}px`,height:`${s}px`,viewBox:`0 0 ${l} ${s}`,direction:"ltr",children:[E?v.jsx("defs",{children:v.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:v.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-primary-gray-600 dark:fill-primary-gray-300"})})}):null,v.jsxs("g",{transform:`translate(${R.left},${R.top})`,children:[v.jsx(Nr,{y1:Oe(he<0?0:he),y2:Oe(he<0?0:he),x1:0-i,x2:ee+R.right,label:_t(he<0?0:he,_,k),labelPos:{x:0-i,y:de<0?0:Oe(he<0?0:he),dx:0,dy:de<0?"1em":-5},classNames:{axis:(_e=W==null?void 0:W.xAxis)==null?void 0:_e.axis,label:(xe=W==null?void 0:W.yAxis)==null?void 0:xe.labels},styles:{axis:(we=z==null?void 0:z.xAxis)==null?void 0:we.axis,label:(ge=z==null?void 0:z.yAxis)==null?void 0:ge.labels}}),a?v.jsx(v1,{values:Te.filter(be=>be!==0),y:Te.filter(be=>be!==0).map(be=>Oe(be)),x1:0-i,x2:ee+R.right,styles:{gridLines:(ve=z==null?void 0:z.yAxis)==null?void 0:ve.gridLines,labels:(le=z==null?void 0:z.yAxis)==null?void 0:le.labels},classNames:{gridLines:(ue=W==null?void 0:W.yAxis)==null?void 0:ue.gridLines,labels:(Ce=W==null?void 0:W.yAxis)==null?void 0:Ce.labels},suffix:k,prefix:_,labelType:"secondary",showGridLines:!0,labelPos:"vertical"}):null,v.jsx(nn,{x:0-i-15,y:J/2,style:(pe=z==null?void 0:z.yAxis)==null?void 0:pe.title,className:(ye=W==null?void 0:W.yAxis)==null?void 0:ye.title,text:j,rotate90:!0}),v.jsx(mo,{children:H[A].values.map((be,je)=>{var $e,ut;return v.jsxs(ur.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",children:[m?v.jsx(ur.text,{style:{textAnchor:"middle",...(($e=z==null?void 0:z.xAxis)==null?void 0:$e.labels)||{}},y:J+5,dy:"1em",animate:{attrX:Ne(`${je}`)+Ne.bandwidth()/2},transition:{duration:.5},className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(ut=W==null?void 0:W.xAxis)==null?void 0:ut.labels),children:`${be.label}`.length<o?be.label:`${`${be.label}`.substring(0,o)}...`}):null,v.jsx(ur.line,{style:{strokeWidth:N,...(z==null?void 0:z.dataConnectors)||{},opacity:D?.3:1},className:Be("stroke-primary-gray-600 dark:stroke-primary-gray-300",W==null?void 0:W.dataConnectors),markerEnd:E&&be.x.indexOf(gr(be.x))===0?"url(#arrow)":"",markerStart:E&&be.x.indexOf(gr(be.x))===be.x.length-1?"url(#arrow)":"",animate:{x1:Ne(`${je}`)+Ne.bandwidth()/2,y1:Oe(gr(be.x))-d,x2:Ne(`${je}`)+Ne.bandwidth()/2,y2:Oe(Mn(be.x))+d},transition:{duration:.5}}),be.x.map((Ie,Ze)=>v.jsxs("g",{opacity:D?r[Ze]===D?1:.3:1,onMouseEnter:Ke=>{re({...be,xIndex:Ze}),ce(Ke.clientY),X(Ke.clientX),y&&y({...be,xIndex:Ze})},onClick:()=>{(w||B)&&(Sr(te,{...be,xIndex:Ze})&&K?(F(void 0),w==null||w(void 0)):(F({...be,xIndex:Ze}),w&&w({...be,xIndex:Ze})))},onMouseMove:Ke=>{re({...be,xIndex:Ze}),ce(Ke.clientY),X(Ke.clientX)},onMouseLeave:()=>{re(void 0),X(void 0),ce(void 0),y&&y(void 0)},children:[v.jsx(ur.circle,{r:d,style:{fill:r[Ze],fillOpacity:.85,stroke:r[Ze],strokeWidth:1},animate:{cx:Ne(`${je}`)+Ne.bandwidth()/2,cy:Oe(Ie||0),opacity:Fe(Ie)?0:1},transition:{duration:.5}}),C?v.jsx(ur.text,{style:{fill:V||r[Ze],textAnchor:"start",...(z==null?void 0:z.graphObjectValues)||{}},className:Be("graph-value text-sm font-bold",W==null?void 0:W.graphObjectValues),dx:d+3,dy:"0.33em",animate:{attrX:Ne(`${je}`)+Ne.bandwidth()/2,attrY:Oe(Ie||0),opacity:Fe(Ie)?0:1},transition:{duration:.5},children:_t(Ie,_,k)}):null]},Ze))]},be.label)})}),G?v.jsx(v.Fragment,{children:G.map((be,je)=>v.jsx(h1,{text:be.text,color:be.color,y:Oe(be.value),x1:0-i,x2:ee+R.right,classNames:be.classNames,styles:be.styles},je))}):null]})]}),Z&&g&&q&&ie?v.jsx(yr,{data:Z,body:g,xPos:q,yPos:ie,backgroundStyle:z==null?void 0:z.tooltip,className:W==null?void 0:W.tooltip}):null,B?v.jsx(Tr,{open:te!==void 0,onClose:()=>{F(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(B,te)}})}):null]})}function mve(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,sources:a,graphDescription:i,barPadding:o=.25,showTicks:l=!0,leftMargin:s=20,rightMargin:f=20,topMargin:c=20,bottomMargin:h=25,truncateBy:d=999,height:m,width:g,footNote:y,colorDomain:b,colorLegendTitle:S,padding:w,backgroundColor:C=!1,radius:k=3,tooltip:_,showLabels:D=!0,relativeHeight:T,onSeriesMouseOver:A,graphID:M,suffix:E="",prefix:N="",maxPositionValue:Y,minPositionValue:ne,onSeriesMouseClick:K,graphDownload:B=!1,dataDownload:j=!1,showValues:$=!0,sortParameter:V,arrowConnector:z=!1,connectorStrokeWidth:W=2,language:G="en",minHeight:ae=0,theme:U="light",showOnlyActiveDate:H=!1,autoPlay:R=!1,dateFormat:ee="yyyy",maxBarThickness:J,minBarThickness:Z,ariaLabel:re,resetSelectionOnDoubleClick:te=!0,detailsOnClick:F,axisTitle:q,noOfTicks:X=5,valueColor:ie,styles:ce,classNames:de,refValues:he}=t,[Oe,Ne]=I.useState(0),[Te,_e]=I.useState(0),[xe,we]=I.useState(void 0),ge=I.useRef(null),ve=I.useRef(null);I.useEffect(()=>{const je=new ResizeObserver($e=>{Ne(g||$e[0].target.clientWidth||620),_e(m||$e[0].target.clientHeight||480)});return ge.current&&(_e(ge.current.clientHeight||480),Ne(ge.current.clientWidth||620),g||je.observe(ge.current)),()=>je.disconnect()},[g,m]);const[le,ue]=I.useState(R),Ce=qi(Bt(e,je=>je.date).map(je=>bt(`${je.date}`,ee,new Date).getTime()),(je,$e)=>Ka(je,$e)),[pe,ye]=I.useState(R?0:Ce.length-1),be={};return Ce.forEach((je,$e)=>{be[`${je}`]={style:{color:$e===pe?"#232E3D":"#A9B1B7",fontWeight:$e===pe?"bold":"normal",display:$e===pe||!H?"inline":"none"},label:Sa(new Date(je),ee)}}),I.useEffect(()=>{const je=setInterval(()=>{ye($e=>$e<Ce.length-1?$e+1:0)},2e3);return le||clearInterval(je),()=>clearInterval(je)},[Ce,le]),v.jsx("div",{className:`${U||"light"} flex ${g?"w-fit grow-0":"w-full grow"}`,dir:G==="he"||G==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${G||"en"}`,de==null?void 0:de.graphContainer),style:{...(ce==null?void 0:ce.graphContainer)||{},...C&&C!==!0?{backgroundColor:C}:{}},id:M,ref:ve,"aria-label":re||`${r?`The graph shows ${r}. `:""}This is a dumbbell chart that shows comparisons between two or more data points across categories. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:C?w||"1rem":w||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||B||j?v.jsx(Zt,{styles:{title:ce==null?void 0:ce.title,description:ce==null?void 0:ce.description},classNames:{title:de==null?void 0:de.title,description:de==null?void 0:de.description},graphTitle:r,graphDescription:i,width:g,graphDownload:B?ve.current:void 0,dataDownload:j?e.map(je=>je.data).filter(je=>je!==void 0).length>0?e.map(je=>je.data).filter(je=>je!==void 0):e.filter(je=>je!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{ue(!le)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":le?"Click to pause animation":"Click to play animation",children:le?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:Ce[0],max:Ce[Ce.length-1],marks:be,step:null,defaultValue:Ce[Ce.length-1],value:Ce[pe],onChangeComplete:je=>{ye(Ce.indexOf(je))},onChange:je=>{ye(Ce.indexOf(je))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[v.jsx(Cn,{width:g,colorDomain:b,colors:n,colorLegendTitle:S,setSelectedColor:we,showNAColor:!1}),v.jsx("div",{className:"flex grow w-full justify-center leading-0",ref:ge,"aria-label":"Graph area",children:(g||Oe)&&(m||Te)?v.jsx(pve,{data:e,dotColors:n,width:g||Oe,height:Math.max(ae,m||(T?ae?(g||Oe)*T>ae?(g||Oe)*T:ae:(g||Oe)*T:Te)),radius:k,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:D,showValues:$,tooltip:_,suffix:E,prefix:N,onSeriesMouseOver:A,maxPositionValue:Y,minPositionValue:ne,onSeriesMouseClick:K,selectedColor:xe,dateFormat:ee,indx:pe,sortParameter:V,arrowConnector:z,connectorStrokeWidth:W,maxBarThickness:J,minBarThickness:Z,resetSelectionOnDoubleClick:te,detailsOnClick:F,axisTitle:q,noOfTicks:X,valueColor:ie,styles:ce,classNames:de,refValues:he}):null})]}),a||y?v.jsx(tr,{styles:{footnote:ce==null?void 0:ce.footnote,source:ce==null?void 0:ce.source},classNames:{footnote:de==null?void 0:de.footnote,source:de==null?void 0:de.source},sources:a,footNote:y,width:g}):null]})})})})}function mq(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,height:m,width:g,footNote:y,colorDomain:b,colorLegendTitle:S,padding:w,backgroundColor:C,radius:k,tooltip:_,showLabels:D,relativeHeight:T,onSeriesMouseOver:A,graphID:M,suffix:E,prefix:N,maxPositionValue:Y,minPositionValue:ne,onSeriesMouseClick:K,graphDownload:B,dataDownload:j,showValues:$,sortParameter:V,arrowConnector:z,connectorStrokeWidth:W,language:G,minHeight:ae,theme:U,showOnlyActiveDate:H,autoPlay:R,dateFormat:ee,maxBarThickness:J,minBarThickness:Z,ariaLabel:re,resetSelectionOnDoubleClick:te,detailsOnClick:F,axisTitle:q,noOfTicks:X,valueColor:ie,orientation:ce="vertical",refValues:de,styles:he,classNames:Oe}=t;return ce==="vertical"?v.jsx(mve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,height:m,width:g,footNote:y,colorDomain:b,colorLegendTitle:S,padding:w,backgroundColor:C,radius:k,tooltip:_,showLabels:D,relativeHeight:T,onSeriesMouseOver:A,graphID:M,suffix:E,prefix:N,maxPositionValue:Y,minPositionValue:ne,onSeriesMouseClick:K,graphDownload:B,dataDownload:j,showValues:$,sortParameter:V,arrowConnector:z,connectorStrokeWidth:W,language:G,minHeight:ae,theme:U,showOnlyActiveDate:H,autoPlay:R,dateFormat:ee,maxBarThickness:J,minBarThickness:Z,ariaLabel:re,resetSelectionOnDoubleClick:te,styles:he,detailsOnClick:F,axisTitle:q,noOfTicks:X,refValues:de,valueColor:ie,classNames:Oe}):v.jsx(hve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,height:m,width:g,footNote:y,colorDomain:b,colorLegendTitle:S,padding:w,backgroundColor:C,radius:k,tooltip:_,showLabels:D,relativeHeight:T,onSeriesMouseOver:A,graphID:M,suffix:E,prefix:N,maxPositionValue:Y,minPositionValue:ne,onSeriesMouseClick:K,graphDownload:B,dataDownload:j,showValues:$,sortParameter:V,arrowConnector:z,connectorStrokeWidth:W,language:G,minHeight:ae,theme:U,showOnlyActiveDate:H,autoPlay:R,dateFormat:ee,maxBarThickness:J,minBarThickness:Z,ariaLabel:re,resetSelectionOnDoubleClick:te,styles:he,detailsOnClick:F,axisTitle:q,noOfTicks:X,refValues:de,valueColor:ie,classNames:Oe})}function gve(t){var _e,xe,we,ge,ve,le,ue,Ce;const{data:e,barColor:r,suffix:n,prefix:a,barPadding:i,showValues:o,showTicks:l,leftMargin:s,truncateBy:f,width:c,height:h,colorDomain:d,rightMargin:m,topMargin:g,bottomMargin:y,showLabels:b,tooltip:S,onSeriesMouseOver:w,refValues:C,selectedColor:k,highlightedDataPoints:_,maxValue:D,minValue:T,onSeriesMouseClick:A,dateFormat:M,indx:E,autoSort:N,rtl:Y,maxBarThickness:ne,minBarThickness:K,resetSelectionOnDoubleClick:B,detailsOnClick:j,barAxisTitle:$,valueColor:V,noOfTicks:z,styles:W,classNames:G}=t,[ae,U]=I.useState(void 0),[H,R]=I.useState(void 0),[ee,J]=I.useState(void 0),[Z,re]=I.useState(void 0),te={top:$?g+25:g,bottom:y,left:s,right:m},F=c-te.left-te.right,q=h-te.top-te.bottom,X=Ut(e.map(pe=>({...pe,date:bt(`${pe.date}`,M,new Date)})),"date"),ie=Bt(X,pe=>pe.label).map(pe=>pe.label),ce=Array.from(Hi(sq(e,M||"yyyy"),pe=>pe.date),([pe,ye])=>({date:pe,values:N?a7(ye,[be=>be.size===void 0,"size"],["asc","desc"]).map((be,je)=>({...be,id:`${je}`})):ie.map(be=>ye.find(je=>je.label===be)).map((be,je)=>({...be,id:`${je}`}))})),de=Fe(D)?Math.max(...e.filter(pe=>!Fe(pe.size)).map(pe=>pe.size))<0?0:Math.max(...e.filter(pe=>!Fe(pe.size)).map(pe=>pe.size)):D,he=Fe(T)?Math.min(...e.filter(pe=>!Fe(pe.size)).map(pe=>pe.size))>=0?0:Math.min(...e.filter(pe=>!Fe(pe.size)).map(pe=>pe.size)):T,Oe=br().domain([he,de]).range([0,F]).nice(),Ne=Un().domain(ie.map((pe,ye)=>`${ye}`)).range([0,K?Math.max(q,K*ie.length):ne?Math.min(q,ne*ie.length):q]).paddingInner(i),Te=Oe.ticks(z);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${c}px`,height:`${h}px`,viewBox:`0 0 ${c} ${h}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${te.left},${te.top})`,children:[l?v.jsx(La,{values:Te.filter(pe=>pe!==0),x:Te.filter(pe=>pe!==0).map(pe=>Oe(pe)),y1:0-g,y2:q+te.bottom,styles:{gridLines:(_e=W==null?void 0:W.xAxis)==null?void 0:_e.gridLines,labels:(xe=W==null?void 0:W.xAxis)==null?void 0:xe.labels},classNames:{gridLines:(we=G==null?void 0:G.xAxis)==null?void 0:we.gridLines,labels:(ge=G==null?void 0:G.xAxis)==null?void 0:ge.labels},suffix:n,prefix:a,labelType:"secondary",showGridLines:!0}):null,v.jsx(nn,{x:F/2,y:0-te.top+15,style:(ve=W==null?void 0:W.xAxis)==null?void 0:ve.title,className:(le=G==null?void 0:G.xAxis)==null?void 0:le.title,text:$}),v.jsx(mo,{children:ce[E].values.map(pe=>{var ye,be;return v.jsxs(ur.g,{transition:{duration:.5},className:"undp-viz-g-with-hover",opacity:k?pe.color&&r[d.indexOf(pe.color)]===k?1:.3:_.length!==0?_.indexOf(pe.label)!==-1?.85:.3:.85,onMouseEnter:je=>{U(pe),J(je.clientY),R(je.clientX),w&&w(pe)},onClick:()=>{(A||j)&&(Sr(Z,pe)&&B?(re(void 0),A==null||A(void 0)):(re(pe),A==null||A(pe)))},onMouseMove:je=>{U(pe),J(je.clientY),R(je.clientX)},onMouseLeave:()=>{U(void 0),R(void 0),J(void 0),w&&w(void 0)},children:[v.jsx(ur.rect,{style:{fill:e.filter(je=>je.color).length===0?r[0]:pe.color?r[d.indexOf(pe.color)]:Qe.gray},height:Ne.bandwidth(),animate:{width:pe.size?pe.size>=0?Oe(pe.size)-Oe(0):Oe(0)-Oe(pe.size):0,attrX:pe.size?pe.size>=0?Oe(0):Oe(pe.size):0,attrY:Ne(pe.id),fill:e.filter(je=>je.color).length===0?r[0]:pe.color?r[d.indexOf(pe.color)]:Qe.gray},transition:{duration:.5}}),b?v.jsx(ur.text,{style:{textAnchor:pe.size&&pe.size<0?"start":"end",...((ye=W==null?void 0:W.yAxis)==null?void 0:ye.labels)||{}},className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(be=G==null?void 0:G.yAxis)==null?void 0:be.labels),x:0,y:0,dx:pe.size&&pe.size<0?10:-10,dy:"0.33em",animate:{attrX:Oe(he<0?0:he),attrY:Ne(pe.id)+Ne.bandwidth()/2},transition:{duration:.5},children:`${pe.label}`.length<f?`${pe.label}`:`${`${pe.label}`.substring(0,f)}...`}):null,o?v.jsx(ur.text,{y:0,style:{...V?{fill:V}:r.length>1?{}:{fill:r[0]},textAnchor:pe.size&&pe.size<0?"end":"start",...(W==null?void 0:W.graphObjectValues)||{}},className:Be("graph-value text-sm",!V&&r.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",G==null?void 0:G.graphObjectValues),dx:pe.size&&pe.size<0?-5:5,animate:{attrX:pe.size?Oe(pe.size):Oe(0),attrY:Ne(pe.id)+Ne.bandwidth()/2},dy:"0.33em",transition:{duration:.5},children:_t(pe.size,a,n)}):null]},pe.label)})}),v.jsx(Nr,{x1:Oe(he<0?0:he),x2:Oe(he<0?0:he),y1:-2.5,y2:q+te.bottom,classNames:{axis:(ue=G==null?void 0:G.yAxis)==null?void 0:ue.axis},styles:{axis:(Ce=W==null?void 0:W.yAxis)==null?void 0:Ce.axis}}),C?v.jsx(v.Fragment,{children:C.map((pe,ye)=>v.jsx(ti,{text:pe.text,color:pe.color,x:Oe(pe.value),y1:0-te.top,y2:q+te.bottom,textSide:Oe(pe.value)>F*.75||Y?"left":"right",classNames:pe.classNames,styles:pe.styles},ye))}):null]})}),ae&&S&&H&&ee?v.jsx(yr,{data:ae,body:S,xPos:H,yPos:ee,backgroundStyle:W==null?void 0:W.tooltip,className:G==null?void 0:G.tooltip}):null,j?v.jsx(Tr,{open:Z!==void 0,onClose:()=>{re(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(j,Z)}})}):null]})}function yve(t){const{data:e,graphTitle:r,colors:n,suffix:a="",sources:i,prefix:o="",graphDescription:l,barPadding:s=.25,showValues:f=!0,showTicks:c=!0,leftMargin:h=100,rightMargin:d=40,truncateBy:m=999,height:g,width:y,footNote:b,colorDomain:S,colorLegendTitle:w,highlightedDataPoints:C=[],padding:k,backgroundColor:_=!1,topMargin:D=25,bottomMargin:T=10,showLabels:A=!0,relativeHeight:M,tooltip:E,onSeriesMouseOver:N,refValues:Y,showColorScale:ne=!0,graphID:K,maxValue:B,minValue:j,onSeriesMouseClick:$,graphDownload:V=!1,dataDownload:z=!1,dateFormat:W="yyyy",showOnlyActiveDate:G=!1,autoPlay:ae=!1,autoSort:U=!0,language:H="en",showNAColor:R=!0,minHeight:ee=0,theme:J="light",maxBarThickness:Z,minBarThickness:re,ariaLabel:te,resetSelectionOnDoubleClick:F=!0,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie=5,valueColor:ce,styles:de,classNames:he}=t,[Oe,Ne]=I.useState(0),[Te,_e]=I.useState(0),[xe,we]=I.useState(void 0),[ge,ve]=I.useState(ae),le=I.useRef(null),ue=I.useRef(null);I.useEffect(()=>{const je=new ResizeObserver($e=>{Ne(y||$e[0].target.clientWidth||620),_e(g||$e[0].target.clientHeight||480)});return le.current&&(_e(le.current.clientHeight||480),Ne(le.current.clientWidth||620),y||je.observe(le.current)),()=>je.disconnect()},[y,g]);const Ce=qi(Bt(e,je=>je.date).map(je=>bt(`${je.date}`,W,new Date).getTime()),(je,$e)=>Ka(je,$e)),[pe,ye]=I.useState(ae?0:Ce.length-1),be={};return Ce.forEach((je,$e)=>{be[`${je}`]={style:{color:$e===pe?"#232E3D":"#A9B1B7",fontWeight:$e===pe?"bold":"normal",display:$e===pe||!G?"inline":"none"},label:Sa(new Date(je),W)}}),I.useEffect(()=>{const je=setInterval(()=>{ye($e=>$e<Ce.length-1?$e+1:0)},2e3);return ge||clearInterval(je),()=>clearInterval(je)},[Ce,ge]),v.jsx("div",{className:`${J||"light"} flex ${y?"w-fit grow-0":"w-full grow"}`,dir:H==="he"||H==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${_?_===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${H||"en"}`,he==null?void 0:he.graphContainer),style:{...(de==null?void 0:de.graphContainer)||{},..._&&_!==!0?{backgroundColor:_}:{}},id:K,ref:ue,"aria-label":te||`${r?`The graph shows ${r}. `:""}This is an animated bar chart showing data changes over time. ${l?` ${l}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:_?k||"1rem":k||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||l||V||z?v.jsx(Zt,{styles:{title:de==null?void 0:de.title,description:de==null?void 0:de.description},classNames:{title:he==null?void 0:he.title,description:he==null?void 0:he.description},graphTitle:r,graphDescription:l,width:y,graphDownload:V?ue.current:void 0,dataDownload:z?e.map(je=>je.data).filter(je=>je!==void 0).length>0?e.map(je=>je.data).filter(je=>je!==void 0):e.filter(je=>je!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{ve(!ge)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ge?"Click to pause animation":"Click to play animation",children:ge?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:Ce[0],max:Ce[Ce.length-1],marks:be,step:null,defaultValue:Ce[Ce.length-1],value:Ce[pe],onChangeComplete:je=>{ye(Ce.indexOf(je))},onChange:je=>{ye(Ce.indexOf(je))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[ne&&e.filter(je=>je.color).length!==0?v.jsx(Cn,{width:y,colorLegendTitle:w,colors:n||Qe[J].categoricalColors.colors,colorDomain:S||Bt(e.filter(je=>je.color),"color").map(je=>je.color),setSelectedColor:we,showNAColor:R}):null,v.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:le,"aria-label":"Graph area",children:(y||Oe)&&(g||Te)?v.jsx(gve,{data:e,barColor:e.filter(je=>je.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[J].categoricalColors.colors,colorDomain:e.filter(je=>je.color).length===0?[]:S||Bt(e.filter(je=>je.color),"color").map(je=>je.color),width:y||Oe,selectedColor:xe,height:Math.max(ee,g||(M?ee?(y||Oe)*M>ee?(y||Oe)*M:ee:(y||Oe)*M:Te)),suffix:a,prefix:o,barPadding:s,showValues:f,showTicks:c,leftMargin:h,rightMargin:d,topMargin:D,bottomMargin:T,truncateBy:m,showLabels:A,tooltip:E,onSeriesMouseOver:N,refValues:Y,maxValue:B,minValue:j,highlightedDataPoints:C,onSeriesMouseClick:$,dateFormat:W,indx:pe,autoSort:U,rtl:H==="he"||H==="ar",maxBarThickness:Z,minBarThickness:re,resetSelectionOnDoubleClick:F,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie,valueColor:ce,styles:de,classNames:he}):null})]}),i||b?v.jsx(tr,{styles:{footnote:de==null?void 0:de.footnote,source:de==null?void 0:de.source},classNames:{footnote:he==null?void 0:he.footnote,source:he==null?void 0:he.source},sources:i,footNote:b,width:y}):null]})})})})}function vve(t){var Oe,Ne,Te,_e,xe,we,ge,ve;const{data:e,barColors:r,barPadding:n,showTicks:a,leftMargin:i,truncateBy:o,width:l,height:s,suffix:f,prefix:c,showValues:h,rightMargin:d,topMargin:m,bottomMargin:g,showLabels:y,tooltip:b,onSeriesMouseOver:S,refValues:w,maxValue:C,minValue:k,onSeriesMouseClick:_,selectedColor:D,dateFormat:T,indx:A,rtl:M,maxBarThickness:E,resetSelectionOnDoubleClick:N,detailsOnClick:Y,barAxisTitle:ne,valueColor:K,noOfTicks:B,styles:j,classNames:$}=t,V=Ut(e.map(le=>({...le,date:bt(`${le.date}`,T,new Date)})),"date"),z=Bt(V,le=>le.label).map(le=>le.label),W=Array.from(Hi(Vf(e,T||"yyyy"),le=>le.date),([le,ue])=>({date:le,values:z.map(Ce=>ue.find(pe=>pe.label===Ce)).map((Ce,pe)=>({...Ce,id:`${pe}`}))})),G={top:ne?m+25:m,bottom:g,left:i,right:d},[ae,U]=I.useState(void 0),[H,R]=I.useState(void 0),[ee,J]=I.useState(void 0),[Z,re]=I.useState(void 0),te=l-G.left-G.right,F=s-G.top-G.bottom,q=Fe(C)?Math.max(...e.map(le=>Mn(le.size.filter(ue=>!Fe(ue)))||0))<0?0:Math.max(...e.map(le=>Mn(le.size.filter(ue=>!Fe(ue)))||0)):C,X=Fe(k)?Math.min(...e.map(le=>gr(le.size.filter(ue=>!Fe(ue)))||0))>=0?0:Math.min(...e.map(le=>gr(le.size.filter(ue=>!Fe(ue)))||0)):k,ie=br().domain([X,q]).range([0,te]).nice(),ce=Un().domain(z.map((le,ue)=>`${ue}`)).range([0,E?Math.min(te,E*z.length):F]).paddingInner(n),de=Un().domain(e[0].size.map((le,ue)=>`${ue}`)).range([0,ce.bandwidth()]).paddingInner(.1),he=ie.ticks(B);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${l}px`,height:`${s}px`,viewBox:`0 0 ${l} ${s}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${G.left},${G.top})`,children:[a?v.jsx(La,{values:he.filter(le=>le!==0),x:he.filter(le=>le!==0).map(le=>ie(le)),y1:0-m,y2:F+G.bottom,styles:{gridLines:(Oe=j==null?void 0:j.xAxis)==null?void 0:Oe.gridLines,labels:(Ne=j==null?void 0:j.xAxis)==null?void 0:Ne.labels},classNames:{gridLines:(Te=$==null?void 0:$.xAxis)==null?void 0:Te.gridLines,labels:(_e=$==null?void 0:$.xAxis)==null?void 0:_e.labels},suffix:f,prefix:c,labelType:"secondary",showGridLines:!0}):null,v.jsx(nn,{x:te/2,y:0-G.top+15,style:(xe=j==null?void 0:j.xAxis)==null?void 0:xe.title,className:(we=$==null?void 0:$.xAxis)==null?void 0:we.title,text:ne}),v.jsx(mo,{children:W[A].values.map((le,ue)=>{var Ce,pe;return v.jsxs(ur.g,{transform:`translate(0,${ce(`${ue}`)})`,children:[le.size.map((ye,be)=>v.jsxs(ur.g,{className:"undp-viz-g-with-hover",opacity:D?r[be]===D?1:.3:.85,onMouseEnter:je=>{U({...le,sizeIndex:be}),re(je.clientY),J(je.clientX),S&&S({...le,sizeIndex:be})},onMouseMove:je=>{U({...le,sizeIndex:be}),re(je.clientY),J(je.clientX)},onMouseLeave:()=>{U(void 0),J(void 0),re(void 0),S&&S(void 0)},onClick:()=>{(_||Y)&&(Sr(H,{...le,sizeIndex:be})&&N?(R(void 0),_&&_(void 0)):(R({...le,sizeIndex:be}),_&&_({...le,sizeIndex:be})))},children:[v.jsx(ur.rect,{y:de(`${be}`),style:{fill:r[be]},height:de.bandwidth(),animate:{width:Fe(ye)?0:ye>=0?ie(ye)-ie(0):ie(0)-ie(ye),attrX:ye>=0?ie(0):ie(ye)},transition:{duration:.5}},be),h?v.jsx(ur.text,{y:de(`${be}`)+de.bandwidth()/2,style:{fill:K||r[be],textAnchor:ye&&ye<0?"end":"start",...(j==null?void 0:j.graphObjectValues)||{}},className:Be("graph-value text-sm",$==null?void 0:$.graphObjectValues),dx:ye&&ye<0?-5:5,dy:"0.33em",animate:{attrX:ie(ye||0)},transition:{duration:.5},children:_t(ye,c,f)}):null]},be)),y?v.jsx(Y2,{value:`${le.label}`.length<o?`${le.label}`:`${`${le.label}`.substring(0,o)}...`,y:0,x:0-G.left,width:ie(X<0?0:X)+G.left,height:ce.bandwidth(),style:(Ce=j==null?void 0:j.yAxis)==null?void 0:Ce.labels,className:(pe=$==null?void 0:$.yAxis)==null?void 0:pe.labels}):null]},ue)})}),v.jsx(Nr,{x1:ie(X<0?0:X),x2:ie(X<0?0:X),y1:-2.5,y2:F+G.bottom,classNames:{axis:(ge=$==null?void 0:$.yAxis)==null?void 0:ge.axis},styles:{axis:(ve=j==null?void 0:j.yAxis)==null?void 0:ve.axis}}),w?v.jsx(v.Fragment,{children:w.map((le,ue)=>v.jsx(ti,{text:le.text,color:le.color,x:ie(le.value),y1:0-G.top,y2:F+G.bottom,textSide:ie(le.value)>te*.75||M?"left":"right",classNames:le.classNames,styles:le.styles},ue))}):null]})}),ae&&b&&ee&&Z?v.jsx(yr,{data:ae,body:b,xPos:ee,yPos:Z,backgroundStyle:j==null?void 0:j.tooltip,className:$==null?void 0:$.tooltip}):null,Y?v.jsx(Tr,{open:H!==void 0,onClose:()=>{R(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(Y,H)}})}):null]})}function bve(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,sources:a,graphDescription:i,barPadding:o=.25,showTicks:l=!0,truncateBy:s=999,height:f,width:c,footNote:h,colorDomain:d,colorLegendTitle:m,suffix:g="",prefix:y="",showValues:b=!0,padding:S,backgroundColor:w=!1,leftMargin:C=100,rightMargin:k=40,topMargin:_=25,showLabels:D=!0,bottomMargin:T=10,relativeHeight:A,tooltip:M,onSeriesMouseOver:E,refValues:N,graphID:Y,maxValue:ne,minValue:K,onSeriesMouseClick:B,graphDownload:j=!1,dataDownload:$=!1,dateFormat:V="yyyy",showOnlyActiveDate:z=!1,autoPlay:W=!1,language:G="en",minHeight:ae=0,theme:U="light",maxBarThickness:H,ariaLabel:R,resetSelectionOnDoubleClick:ee=!0,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re=5,valueColor:te,styles:F,classNames:q}=t,[X,ie]=I.useState(0),[ce,de]=I.useState(0),[he,Oe]=I.useState(void 0),Ne=I.useRef(null),Te=I.useRef(null);I.useEffect(()=>{const ue=new ResizeObserver(Ce=>{ie(c||Ce[0].target.clientWidth||620),de(f||Ce[0].target.clientHeight||480)});return Ne.current&&(de(Ne.current.clientHeight||480),ie(Ne.current.clientWidth||620),c||ue.observe(Ne.current)),()=>ue.disconnect()},[c,f]);const[_e,xe]=I.useState(W),we=qi(Bt(e,ue=>ue.date).map(ue=>bt(`${ue.date}`,V,new Date).getTime()),(ue,Ce)=>Ka(ue,Ce)),[ge,ve]=I.useState(W?0:we.length-1),le={};return we.forEach((ue,Ce)=>{le[`${ue}`]={style:{color:Ce===ge?"#232E3D":"#A9B1B7",fontWeight:Ce===ge?"bold":"normal",display:Ce===ge||!z?"inline":"none"},label:Sa(new Date(ue),V)}}),I.useEffect(()=>{const ue=setInterval(()=>{ve(Ce=>Ce<we.length-1?Ce+1:0)},2e3);return _e||clearInterval(ue),()=>clearInterval(ue)},[we,_e]),v.jsx("div",{className:`${U||"light"} flex ${c?"w-fit grow-0":"w-full grow"}`,dir:G==="he"||G==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${w?w===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${G||"en"}`,q==null?void 0:q.graphContainer),style:{...(F==null?void 0:F.graphContainer)||{},...w&&w!==!0?{backgroundColor:w}:{}},id:Y,ref:Te,"aria-label":R||`${r?`The graph shows ${r}. `:""}This is an animated grouped bar chart showing data changes over time. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:w?S||"1rem":S||0},children:v.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[r||i||j||$?v.jsx(Zt,{styles:{title:F==null?void 0:F.title,description:F==null?void 0:F.description},classNames:{title:q==null?void 0:q.title,description:q==null?void 0:q.description},graphTitle:r,graphDescription:i,width:c,graphDownload:j?Te.current:void 0,dataDownload:$?e.map(ue=>ue.data).filter(ue=>ue!==void 0).length>0?e.map(ue=>ue.data).filter(ue=>ue!==void 0):e.filter(ue=>ue!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{xe(!_e)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":_e?"Click to pause animation":"Click to play animation",children:_e?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:we[0],max:we[we.length-1],marks:le,step:null,defaultValue:we[we.length-1],value:we[ge],onChangeComplete:ue=>{ve(we.indexOf(ue))},onChange:ue=>{ve(we.indexOf(ue))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[v.jsx(Cn,{width:c,colorDomain:d,colors:n,colorLegendTitle:m,setSelectedColor:Oe,showNAColor:!1}),v.jsx("div",{className:"w-full grow leading-0",ref:Ne,"aria-label":"Graph area",children:(c||X)&&(f||ce)?v.jsx(vve,{data:e,barColors:n,width:c||X,height:Math.max(ae,f||(A?ae?(c||X)*A>ae?(c||X)*A:ae:(c||X)*A:ce)),suffix:g,prefix:y,showValues:b,barPadding:o,showTicks:l,leftMargin:C,rightMargin:k,topMargin:_,bottomMargin:T,truncateBy:s,showLabels:D,tooltip:M,onSeriesMouseOver:E,refValues:N,maxValue:ne,minValue:K,onSeriesMouseClick:B,selectedColor:he,dateFormat:V,indx:ge,rtl:G==="he"||G==="ar",maxBarThickness:H,resetSelectionOnDoubleClick:ee,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re,valueColor:te,styles:F,classNames:q}):null})]}),a||h?v.jsx(tr,{styles:{footnote:F==null?void 0:F.footnote,source:F==null?void 0:F.source},classNames:{footnote:q==null?void 0:q.footnote,source:q==null?void 0:q.source},sources:a,footNote:h,width:c}):null]})})})})}function xve(t){var Oe,Ne,Te,_e,xe,we,ge,ve;const{data:e,barColors:r,barPadding:n,showTicks:a,leftMargin:i,rightMargin:o,truncateBy:l,width:s,height:f,topMargin:c,bottomMargin:h,tooltip:d,onSeriesMouseOver:m,showLabels:g,suffix:y,prefix:b,showValues:S,refValues:w,maxValue:C,onSeriesMouseClick:k,selectedColor:_,dateFormat:D,indx:T,autoSort:A,rtl:M,sortParameter:E,maxBarThickness:N,minBarThickness:Y,resetSelectionOnDoubleClick:ne,detailsOnClick:K,barAxisTitle:B,valueColor:j,noOfTicks:$,styles:V,classNames:z}=t,[W,G]=I.useState(void 0),ae=Ut(e.map(le=>({...le,date:bt(`${le.date}`,D,new Date)})),"date"),U=Bt(ae,le=>le.label).map(le=>le.label),H=Array.from(Hi(Vf(e,D||"yyyy"),le=>le.date),([le,ue])=>({date:le,values:E!==void 0||A?E==="total"||E===void 0?Ut(e,Ce=>fr(Ce.size.filter(pe=>!Fe(pe)))).reverse().map((Ce,pe)=>({...Ce,id:`${pe}`})):Ut(e,Ce=>Fe(Ce.size[E])?-1/0:Ce.size[E]).reverse().map((Ce,pe)=>({...Ce,id:`${pe}`})):U.map(Ce=>ue.find(pe=>pe.label===Ce)).map((Ce,pe)=>({...Ce,id:`${pe}`}))})),R={top:B?c+25:c,bottom:h,left:i,right:o},[ee,J]=I.useState(void 0),[Z,re]=I.useState(void 0),[te,F]=I.useState(void 0),q=s-R.left-R.right,X=f-R.top-R.bottom,ie=Fe(C)?Math.max(...e.map(le=>fr(le.size.filter(ue=>!Fe(ue)))||0)):C,ce=br().domain([0,ie]).range([0,q]).nice(),de=Un().domain(U.map((le,ue)=>`${ue}`)).range([0,Y?Math.max(X,Y*U.length):N?Math.min(X,N*U.length):X]).paddingInner(n),he=ce.ticks($);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${s}px`,height:`${f}px`,viewBox:`0 0 ${s} ${f}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${R.left},${R.top})`,children:[a?v.jsx(La,{values:he.filter(le=>le!==0),x:he.filter(le=>le!==0).map(le=>ce(le)),y1:0-c,y2:X+R.bottom,styles:{gridLines:(Oe=V==null?void 0:V.xAxis)==null?void 0:Oe.gridLines,labels:(Ne=V==null?void 0:V.xAxis)==null?void 0:Ne.labels},classNames:{gridLines:(Te=z==null?void 0:z.xAxis)==null?void 0:Te.gridLines,labels:(_e=z==null?void 0:z.xAxis)==null?void 0:_e.labels},suffix:y,prefix:b,labelType:"secondary",showGridLines:!0}):null,v.jsx(nn,{x:q/2,y:0-R.top+15,style:(xe=V==null?void 0:V.xAxis)==null?void 0:xe.title,className:(we=z==null?void 0:z.xAxis)==null?void 0:we.title,text:B}),v.jsx(mo,{children:H[T].values.map(le=>v.jsxs("g",{className:"undp-viz-low-opacity undp-viz-g-with-hover",children:[le.size.map((ue,Ce)=>{var pe,ye;return v.jsxs(ur.g,{opacity:_?r[Ce]===_?1:.3:1,onMouseEnter:be=>{J({...le,sizeIndex:Ce}),F(be.clientY),re(be.clientX),m&&m({...le,sizeIndex:Ce})},onMouseMove:be=>{J({...le,sizeIndex:Ce}),F(be.clientY),re(be.clientX)},onMouseLeave:()=>{J(void 0),re(void 0),F(void 0),m&&m(void 0)},onClick:()=>{(k||K)&&(Sr(W,{...le,sizeIndex:Ce})&&ne?(G(void 0),k&&k(void 0)):(G({...le,sizeIndex:Ce}),k&&k({...le,sizeIndex:Ce})))},children:[v.jsx(ur.rect,{style:{fill:r[Ce]},height:de.bandwidth(),animate:{width:ce(ue||0),attrX:ce(Ce===0?0:fr(le.size.filter((be,je)=>je<Ce&&be))),attrY:de(le.id)},transition:{duration:.5}},Ce),g?v.jsx(ur.text,{style:{textAnchor:"end",...((pe=V==null?void 0:V.yAxis)==null?void 0:pe.labels)||{}},className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(ye=z==null?void 0:z.yAxis)==null?void 0:ye.labels),dx:-10,dy:"0.33em",animate:{attrX:ce(0),attrY:(de(le.id)||0)+de.bandwidth()/2},transition:{duration:.5},children:`${le.label}`.length<l?`${le.label}`:`${`${le.label}`.substring(0,l)}...`}):null,S?v.jsx(ur.text,{style:{fill:Bi(r[Ce]),textAnchor:"middle",...(V==null?void 0:V.graphObjectValues)||{}},className:Be("graph-value text-sm",z==null?void 0:z.graphObjectValues),dy:"0.33em",animate:{attrX:ce(Ce===0?0:fr(le.size.filter((be,je)=>je<Ce&&be)))+ce(ue||0)/2,attrY:(de(le.id)||0)+de.bandwidth()/2,opacity:ue&&ce(ue)/_t(ue,b,y).length>12?1:0},transition:{duration:.5},children:_t(ue,b,y)}):null]},Ce)}),S?v.jsx(ur.text,{style:{...j&&{fill:j},textAnchor:"start",...(V==null?void 0:V.graphObjectValues)||{}},className:Be("graph-value graph-value-total text-sm",j?"":" fill-primary-gray-700 dark:fill-primary-gray-300",z==null?void 0:z.graphObjectValues),dx:5,dy:"0.33em",animate:{attrX:ce(fr(le.size.map(ue=>ue||0))),attrY:(de(le.id)||0)+de.bandwidth()/2},transition:{duration:.5},children:_t(fr(le.size.filter(ue=>ue)),b,y)}):null]},le.label))}),v.jsx(Nr,{x1:ce(0),x2:ce(0),y1:-2.5,y2:X+R.bottom,classNames:{axis:(ge=z==null?void 0:z.yAxis)==null?void 0:ge.axis},styles:{axis:(ve=V==null?void 0:V.yAxis)==null?void 0:ve.axis}}),w?v.jsx(v.Fragment,{children:w.map((le,ue)=>v.jsx(ti,{text:le.text,color:le.color,x:ce(le.value),y1:0-R.top,y2:X+R.bottom,textSide:ce(le.value)>q*.75||M?"left":"right",classNames:le.classNames,styles:le.styles},ue))}):null]})}),ee&&d&&Z&&te?v.jsx(yr,{data:ee,body:d,xPos:Z,yPos:te,backgroundStyle:V==null?void 0:V.tooltip,className:z==null?void 0:z.tooltip}):null,K?v.jsx(Tr,{open:W!==void 0,onClose:()=>{G(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(K,W)}})}):null]})}function wve(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,sources:a,graphDescription:i,barPadding:o=.25,showTicks:l=!0,leftMargin:s=100,rightMargin:f=40,truncateBy:c=999,height:h,width:d,footNote:m,colorDomain:g,colorLegendTitle:y,padding:b,backgroundColor:S=!1,topMargin:w=25,bottomMargin:C=10,tooltip:k,onSeriesMouseOver:_,suffix:D="",prefix:T="",showLabels:A=!0,relativeHeight:M,showValues:E,refValues:N,graphID:Y,maxValue:ne,onSeriesMouseClick:K,graphDownload:B=!1,dataDownload:j=!1,dateFormat:$="yyyy",showOnlyActiveDate:V=!1,autoPlay:z=!1,autoSort:W=!0,language:G="en",minHeight:ae=0,theme:U="light",sortParameter:H,maxBarThickness:R,minBarThickness:ee,ariaLabel:J,resetSelectionOnDoubleClick:Z=!0,detailsOnClick:re,barAxisTitle:te,noOfTicks:F=5,valueColor:q,styles:X,classNames:ie}=t,[ce,de]=I.useState(0),[he,Oe]=I.useState(0),[Ne,Te]=I.useState(void 0),_e=I.useRef(null),xe=I.useRef(null);I.useEffect(()=>{const pe=new ResizeObserver(ye=>{de(d||ye[0].target.clientWidth||620),Oe(h||ye[0].target.clientHeight||480)});return _e.current&&(Oe(_e.current.clientHeight||480),de(_e.current.clientWidth||620),d||pe.observe(_e.current)),()=>pe.disconnect()},[d,h]);const[we,ge]=I.useState(z),ve=qi(Bt(e,pe=>pe.date).map(pe=>bt(`${pe.date}`,$,new Date).getTime()),(pe,ye)=>Ka(pe,ye)),[le,ue]=I.useState(z?0:ve.length-1),Ce={};return ve.forEach((pe,ye)=>{Ce[`${pe}`]={style:{color:ye===le?"#232E3D":"#A9B1B7",fontWeight:ye===le?"bold":"normal",display:ye===le||!V?"inline":"none"},label:Sa(new Date(pe),$)}}),I.useEffect(()=>{const pe=setInterval(()=>{ue(ye=>ye<ve.length-1?ye+1:0)},2e3);return we||clearInterval(pe),()=>clearInterval(pe)},[ve,we]),v.jsx("div",{className:`${U||"light"} flex ${d?"w-fit grow-0":"w-full grow"}`,dir:G==="he"||G==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${S?S===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${G||"en"}`,ie==null?void 0:ie.graphContainer),style:{...(X==null?void 0:X.graphContainer)||{},...S&&S!==!0?{backgroundColor:S}:{}},id:Y,ref:xe,"aria-label":J||`${r?`The graph shows ${r}. `:""}This is an animated stacked bar chart showing data changes over time. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:S?b||"1rem":b||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||B||j?v.jsx(Zt,{styles:{title:X==null?void 0:X.title,description:X==null?void 0:X.description},classNames:{title:ie==null?void 0:ie.title,description:ie==null?void 0:ie.description},graphTitle:r,graphDescription:i,width:d,graphDownload:B?xe.current:void 0,dataDownload:j?e.map(pe=>pe.data).filter(pe=>pe!==void 0).length>0?e.map(pe=>pe.data).filter(pe=>pe!==void 0):e.filter(pe=>pe!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{ge(!we)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":we?"Click to pause animation":"Click to play animation",children:we?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:ve[0],max:ve[ve.length-1],marks:Ce,step:null,defaultValue:ve[ve.length-1],value:ve[le],onChangeComplete:pe=>{ue(ve.indexOf(pe))},onChange:pe=>{ue(ve.indexOf(pe))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[v.jsx(Cn,{width:d,colorDomain:g,colors:n,colorLegendTitle:y,setSelectedColor:Te,showNAColor:!1}),v.jsx("div",{className:"w-full grow leading-0",ref:_e,"aria-label":"Graph area",children:(d||ce)&&(h||he)?v.jsx(xve,{data:e,barColors:n,width:d||ce,height:Math.max(ae,h||(M?ae?(d||ce)*M>ae?(d||ce)*M:ae:(d||ce)*M:he)),barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:w,bottomMargin:C,truncateBy:c,showLabels:A,tooltip:k,onSeriesMouseOver:_,showValues:E,suffix:D,prefix:T,refValues:N,maxValue:ne,onSeriesMouseClick:K,selectedColor:Ne,dateFormat:$,indx:le,sortParameter:H,autoSort:W,rtl:G==="he"||G==="ar",maxBarThickness:R,minBarThickness:ee,resetSelectionOnDoubleClick:Z,detailsOnClick:re,barAxisTitle:te,noOfTicks:F,valueColor:q,styles:X,classNames:ie}):null})]}),a||m?v.jsx(tr,{styles:{footnote:X==null?void 0:X.footnote,source:X==null?void 0:X.source},classNames:{footnote:ie==null?void 0:ie.footnote,source:ie==null?void 0:ie.source},sources:a,footNote:m,width:d}):null]})})})})}function Sve(t){var Te,_e,xe,we,ge,ve,le,ue,Ce,pe;const{data:e,barColor:r,suffix:n,prefix:a,barPadding:i,showValues:o,showTicks:l,leftMargin:s,truncateBy:f,width:c,height:h,colorDomain:d,rightMargin:m,topMargin:g,bottomMargin:y,showLabels:b,tooltip:S,onSeriesMouseOver:w,refValues:C,selectedColor:k,highlightedDataPoints:_,maxValue:D,minValue:T,onSeriesMouseClick:A,dateFormat:M,indx:E,autoSort:N,maxBarThickness:Y,minBarThickness:ne,resetSelectionOnDoubleClick:K,detailsOnClick:B,barAxisTitle:j,valueColor:$,noOfTicks:V,styles:z,classNames:W}=t,[G,ae]=I.useState(void 0),[U,H]=I.useState(void 0),[R,ee]=I.useState(void 0),[J,Z]=I.useState(void 0),re={top:g,bottom:y,left:j?s+30:s,right:m},te=c-re.left-re.right,F=h-re.top-re.bottom,q=Ut(e.map(ye=>({...ye,date:bt(`${ye.date}`,M,new Date)})),"date"),X=Bt(q,ye=>ye.label).map(ye=>ye.label),ie=Array.from(Hi(sq(e,M||"yyyy"),ye=>ye.date),([ye,be])=>{const je=N?a7(be.filter($e=>!Fe($e.size)),["size"],["desc"]):X.map($e=>be.find(ut=>ut.label===$e));return be.filter($e=>$e.size===void 0).forEach($e=>{je.push($e)}),{date:ye,values:N?je.reverse().map(($e,ut)=>({...$e,id:`${ut}`})):je.map(($e,ut)=>({...$e,id:`${ut}`}))}}),ce=Fe(D)?Math.max(...e.filter(ye=>!Fe(ye.size)).map(ye=>ye.size))<0?0:Math.max(...e.filter(ye=>!Fe(ye.size)).map(ye=>ye.size)):D,de=Fe(T)?Math.min(...e.filter(ye=>!Fe(ye.size)).map(ye=>ye.size))>=0?0:Math.min(...e.filter(ye=>!Fe(ye.size)).map(ye=>ye.size)):T,he=br().domain([de,ce]).range([F,0]).nice(),Oe=Un().domain(X.map((ye,be)=>`${be}`)).range([0,ne?Math.max(te,ne*X.length):Y?Math.min(te,Y*X.length):te]).paddingInner(i),Ne=he.ticks(V);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${c}px`,height:`${h}px`,viewBox:`0 0 ${c} ${h}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${re.left},${re.top})`,children:[v.jsx(Nr,{y1:he(de<0?0:de),y2:he(de<0?0:de),x1:0-s,x2:te+re.right,label:_t(de<0?0:de,a,n),labelPos:{x:0-s,y:ce<0?-15:he(de<0?0:de),dy:ce<0?"1em":-5,dx:0},classNames:{axis:(Te=W==null?void 0:W.xAxis)==null?void 0:Te.axis,label:(_e=W==null?void 0:W.yAxis)==null?void 0:_e.labels},styles:{axis:(xe=z==null?void 0:z.xAxis)==null?void 0:xe.axis,label:(we=z==null?void 0:z.yAxis)==null?void 0:we.labels}}),l?v.jsx(v1,{values:Ne.filter(ye=>ye!==0),y:Ne.filter(ye=>ye!==0).map(ye=>he(ye)),x1:0-s,x2:te+re.right,styles:{gridLines:(ge=z==null?void 0:z.yAxis)==null?void 0:ge.gridLines,labels:(ve=z==null?void 0:z.yAxis)==null?void 0:ve.labels},classNames:{gridLines:(le=W==null?void 0:W.yAxis)==null?void 0:le.gridLines,labels:(ue=W==null?void 0:W.yAxis)==null?void 0:ue.labels},suffix:n,prefix:a,labelType:"secondary",showGridLines:!0,labelPos:"vertical"}):null,v.jsx(nn,{x:0-s-15,y:F/2,style:(Ce=z==null?void 0:z.yAxis)==null?void 0:Ce.title,className:(pe=W==null?void 0:W.yAxis)==null?void 0:pe.title,text:j,rotate90:!0}),v.jsx(mo,{children:ie[E].values.map(ye=>{var be,je;return v.jsxs(ur.g,{transition:{duration:.5},className:"undp-viz-g-with-hover",opacity:k?ye.color&&r[d.indexOf(ye.color)]===k?1:.3:_.length!==0?_.indexOf(ye.label)!==-1?.85:.3:.85,onMouseEnter:$e=>{H(ye),Z($e.clientY),ee($e.clientX),w&&w(ye)},onClick:()=>{(A||B)&&(Sr(G,ye)&&K?(ae(void 0),A==null||A(void 0)):(ae(ye),A==null||A(ye)))},onMouseMove:$e=>{H(ye),Z($e.clientY),ee($e.clientX)},onMouseLeave:()=>{H(void 0),ee(void 0),Z(void 0),w&&w(void 0)},children:[v.jsx(ur.rect,{style:{fill:e.filter($e=>$e.color).length===0?r[0]:ye.color?r[d.indexOf(ye.color)]:Qe.gray},height:ye.size?Math.abs(he(ye.size)-he(0)):0,width:Oe.bandwidth(),animate:{height:ye.size?Math.abs(he(ye.size)-he(0)):0,attrY:ye.size&&ye.size>0?he(ye.size):he(0),attrX:Oe(`${ye.id}`),fill:e.filter($e=>$e.color).length===0?r[0]:ye.color?r[d.indexOf(ye.color)]:Qe.gray},transition:{duration:.5}}),b?v.jsx(ur.text,{style:{textAnchor:"middle",...((be=z==null?void 0:z.xAxis)==null?void 0:be.labels)||{}},dy:ye.size?ye.size>=0?"1em":"-5px":"1em",animate:{attrX:Oe(`${ye.id}`)+Oe.bandwidth()/2,attrY:ye.size?ye.size>=0?he(0)+4:he(0):he(0)+4},transition:{duration:.5},className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(je=W==null?void 0:W.xAxis)==null?void 0:je.labels),children:`${ye.label}`.length<f?`${ye.label}`:`${`${ye.label}`.substring(0,f)}...`}):null,o?v.jsx(ur.text,{style:{...$?{fill:$}:r.length>1?{}:{fill:r[0]},textAnchor:"middle",...(z==null?void 0:z.graphObjectValues)||{}},className:Be("graph-value text-sm",!$&&r.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",W==null?void 0:W.graphObjectValues),animate:{attrX:Oe(`${ye.id}`)+Oe.bandwidth()/2,attrY:he(ye.size||0)},dy:ye.size?ye.size>=0?"-5px":"1em":"-5px",transition:{duration:.5},children:_t(ye.size,a,n)}):null]},ye.label)})}),C?v.jsx(v.Fragment,{children:C.map((ye,be)=>v.jsx(h1,{text:ye.text,color:ye.color,y:he(ye.value),x1:0-s,x2:te+re.right,classNames:ye.classNames,styles:ye.styles},be))}):null]})}),U&&S&&R&&J?v.jsx(yr,{data:U,body:S,xPos:R,yPos:J,backgroundStyle:z==null?void 0:z.tooltip,className:W==null?void 0:W.tooltip}):null,B?v.jsx(Tr,{open:G!==void 0,onClose:()=>{ae(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(B,G)}})}):null]})}function Cve(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o=.25,showTicks:l=!0,leftMargin:s=20,rightMargin:f=20,topMargin:c=20,bottomMargin:h=25,truncateBy:d=999,showLabels:m=!0,showValues:g=!0,backgroundColor:y=!1,suffix:b="",prefix:S="",height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,highlightedDataPoints:T=[],padding:A,relativeHeight:M,tooltip:E,onSeriesMouseOver:N,refValues:Y,showColorScale:ne,graphID:K,maxValue:B,minValue:j,onSeriesMouseClick:$,dateFormat:V="yyyy",showOnlyActiveDate:z=!1,autoPlay:W=!1,autoSort:G=!0,graphDownload:ae=!1,dataDownload:U=!1,language:H="en",theme:R="light",showNAColor:ee=!0,minHeight:J=0,maxBarThickness:Z,minBarThickness:re,ariaLabel:te,resetSelectionOnDoubleClick:F=!0,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie=5,valueColor:ce,styles:de,classNames:he}=t,[Oe,Ne]=I.useState(0),[Te,_e]=I.useState(0),[xe,we]=I.useState(void 0),[ge,ve]=I.useState(W),le=I.useRef(null),ue=I.useRef(null);I.useEffect(()=>{const je=new ResizeObserver($e=>{Ne(C||$e[0].target.clientWidth||620),_e(w||$e[0].target.clientHeight||480)});return le.current&&(_e(le.current.clientHeight||480),Ne(le.current.clientWidth||620),C||je.observe(le.current)),()=>je.disconnect()},[C,w]);const Ce=qi(Bt(e,je=>je.date).map(je=>bt(`${je.date}`,V,new Date).getTime()),(je,$e)=>Ka(je,$e)),[pe,ye]=I.useState(W?0:Ce.length-1),be={};return Ce.forEach((je,$e)=>{be[`${je}`]={style:{color:$e===pe?"#232E3D":"#A9B1B7",fontWeight:$e===pe?"bold":"normal",display:$e===pe||!z?"inline":"none"},label:Sa(new Date(je),V)}}),I.useEffect(()=>{const je=setInterval(()=>{ye($e=>$e<Ce.length-1?$e+1:0)},2e3);return ge||clearInterval(je),()=>clearInterval(je)},[Ce,ge]),v.jsx("div",{className:`${R||"light"} flex ${C?"w-fit grow-0":"w-full grow"}`,dir:H==="he"||H==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${y?y===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${H||"en"}`,he==null?void 0:he.graphContainer),style:{...(de==null?void 0:de.graphContainer)||{},...y&&y!==!0?{backgroundColor:y}:{}},id:K,ref:ue,"aria-label":te||`${r?`The graph shows ${r}. `:""}This is an animated bar chart showing data changes over time. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:y?A||"1rem":A||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||ae||U?v.jsx(Zt,{styles:{title:de==null?void 0:de.title,description:de==null?void 0:de.description},classNames:{title:he==null?void 0:he.title,description:he==null?void 0:he.description},graphTitle:r,graphDescription:i,width:C,graphDownload:ae?ue.current:void 0,dataDownload:U?e.map(je=>je.data).filter(je=>je!==void 0).length>0?e.map(je=>je.data).filter(je=>je!==void 0):e.filter(je=>je!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{ve(!ge)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ge?"Click to pause animation":"Click to play animation",children:ge?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:Ce[0],max:Ce[Ce.length-1],marks:be,step:null,defaultValue:Ce[Ce.length-1],value:Ce[pe],onChangeComplete:je=>{ye(Ce.indexOf(je))},onChange:je=>{ye(Ce.indexOf(je))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[ne!==!1&&e.filter(je=>je.color).length!==0?v.jsx(Cn,{width:C,colorLegendTitle:D,colors:n||Qe[R].categoricalColors.colors,colorDomain:_||Bt(e.filter(je=>je.color),"color").map(je=>je.color),setSelectedColor:we,showNAColor:ee}):null,v.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:le,"aria-label":"Graph area",children:(C||Oe)&&(w||Te)?v.jsx(Sve,{data:e,barColor:e.filter(je=>je.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[R].categoricalColors.colors,colorDomain:e.filter(je=>je.color).length===0?[]:_||Bt(e.filter(je=>je.color),"color").map(je=>je.color),width:C||Oe,selectedColor:xe,height:Math.max(J,w||(M?J?(C||Oe)*M>J?(C||Oe)*M:J:(C||Oe)*M:Te)),suffix:b,prefix:S,barPadding:o,showValues:g,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,tooltip:E,onSeriesMouseOver:N,refValues:Y,maxValue:B,minValue:j,highlightedDataPoints:T,onSeriesMouseClick:$,dateFormat:V,indx:pe,autoSort:G,maxBarThickness:Z,minBarThickness:re,resetSelectionOnDoubleClick:F,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie,valueColor:ce,styles:de,classNames:he}):null})]}),a||k?v.jsx(tr,{styles:{footnote:de==null?void 0:de.footnote,source:de==null?void 0:de.source},classNames:{footnote:he==null?void 0:he.footnote,source:he==null?void 0:he.source},sources:a,footNote:k,width:C}):null]})})})})}function kve(t){var he,Oe,Ne,Te,_e,xe,we,ge,ve,le;const{data:e,width:r,height:n,barColors:a,suffix:i,prefix:o,barPadding:l,showLabels:s,showValues:f,showTicks:c,truncateBy:h,leftMargin:d,rightMargin:m,topMargin:g,bottomMargin:y,tooltip:b,onSeriesMouseOver:S,refValues:w,maxValue:C,minValue:k,onSeriesMouseClick:_,selectedColor:D,dateFormat:T,indx:A,maxBarThickness:M,resetSelectionOnDoubleClick:E,detailsOnClick:N,barAxisTitle:Y,valueColor:ne,noOfTicks:K,styles:B,classNames:j}=t,$=Ut(e.map(ue=>({...ue,date:bt(`${ue.date}`,T,new Date)})),"date"),V=Bt($,ue=>ue.label).map(ue=>ue.label),z=Array.from(Hi(Vf(e,T||"yyyy"),ue=>ue.date),([ue,Ce])=>({date:ue,values:V.map(pe=>Ce.find(ye=>ye.label===pe)).map((pe,ye)=>({...pe,id:`${ye}`}))})),W={top:g,bottom:y,left:Y?d+30:d,right:m},[G,ae]=I.useState(void 0),[U,H]=I.useState(void 0),[R,ee]=I.useState(void 0),[J,Z]=I.useState(void 0),re=r-W.left-W.right,te=n-W.top-W.bottom,F=Fe(C)?Math.max(...e.map(ue=>Mn(ue.size.filter(Ce=>!Fe(Ce)))||0))<0?0:Math.max(...e.map(ue=>Mn(ue.size.filter(Ce=>!Fe(Ce)))||0)):C,q=Fe(k)?Math.min(...e.map(ue=>gr(ue.size.filter(Ce=>!Fe(Ce)))||0))>=0?0:Math.min(...e.map(ue=>gr(ue.size.filter(Ce=>!Fe(Ce)))||0)):k,X=br().domain([q,F]).range([te,0]).nice(),ie=Un().domain(V.map((ue,Ce)=>`${Ce}`)).range([0,M?Math.min(re,M*V.length):re]).paddingInner(l),ce=Un().domain(e[0].size.map((ue,Ce)=>`${Ce}`)).range([0,ie.bandwidth()]).paddingInner(.1),de=X.ticks(K);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${W.left},${W.top})`,children:[v.jsx(Nr,{y1:X(q<0?0:q),y2:X(q<0?0:q),x1:0-d,x2:re+W.right,label:_t(q<0?0:q,o,i),labelPos:{x:0-d,dx:0,dy:F<0?"1em":-5,y:X(q<0?0:q)},classNames:{axis:(he=j==null?void 0:j.xAxis)==null?void 0:he.axis,label:(Oe=j==null?void 0:j.yAxis)==null?void 0:Oe.labels},styles:{axis:(Ne=B==null?void 0:B.xAxis)==null?void 0:Ne.axis,label:(Te=B==null?void 0:B.yAxis)==null?void 0:Te.labels}}),c?v.jsx(v1,{values:de.filter(ue=>ue!==0),y:de.filter(ue=>ue!==0).map(ue=>X(ue)),x1:0-d,x2:re+W.right,styles:{gridLines:(_e=B==null?void 0:B.yAxis)==null?void 0:_e.gridLines,labels:(xe=B==null?void 0:B.yAxis)==null?void 0:xe.labels},classNames:{gridLines:(we=j==null?void 0:j.yAxis)==null?void 0:we.gridLines,labels:(ge=j==null?void 0:j.yAxis)==null?void 0:ge.labels},suffix:i,prefix:o,labelType:"secondary",showGridLines:!0,labelPos:"vertical"}):null,v.jsx(nn,{x:0-d-15,y:te/2,style:(ve=B==null?void 0:B.yAxis)==null?void 0:ve.title,className:(le=j==null?void 0:j.yAxis)==null?void 0:le.title,text:Y,rotate90:!0}),v.jsx(mo,{children:z[A].values.map((ue,Ce)=>{var pe,ye;return v.jsxs(ur.g,{transform:`translate(${ie(`${ue.id}`)},0)`,children:[ue.size.map((be,je)=>v.jsxs(ur.g,{className:"undp-viz-g-with-hover",opacity:D?a[je]===D?1:.3:.85,onMouseEnter:$e=>{ae({...ue,sizeIndex:je}),Z($e.clientY),ee($e.clientX),S&&S({...ue,sizeIndex:je})},onMouseMove:$e=>{ae({...ue,sizeIndex:je}),Z($e.clientY),ee($e.clientX)},onMouseLeave:()=>{ae(void 0),ee(void 0),Z(void 0),S&&S(void 0)},onClick:()=>{(_||N)&&(Sr(U,{...ue,sizeIndex:je})&&E?(H(void 0),_&&_(void 0)):(H({...ue,sizeIndex:je}),_&&_({...ue,sizeIndex:je})))},children:[v.jsx(ur.rect,{x:ce(`${je}`),width:ce.bandwidth(),style:{fill:a[je]},animate:{height:Fe(be)?0:Math.abs(X(be)-X(0)),attrY:Fe(be)?X(0):be>0?X(be):X(0)},transition:{duration:.5}}),f?v.jsx(ur.text,{x:ce(`${je}`)+ce.bandwidth()/2,style:{fill:ne||a[je],textAnchor:"middle",...(B==null?void 0:B.graphObjectValues)||{}},className:Be("graph-value text-sm",j==null?void 0:j.graphObjectValues),dy:be?be>=0?"-5px":"1em":"-5px",animate:{attrY:X(be||0)},transition:{duration:.5},children:_t(be,o,i)}):null]},je)),s?v.jsx(f4,{value:`${ue.label}`.length<h?`${ue.label}`:`${`${ue.label}`.substring(0,h)}...`,y:X(0)+5,x:0,width:ie.bandwidth(),height:W.bottom,style:(pe=B==null?void 0:B.xAxis)==null?void 0:pe.labels,className:(ye=j==null?void 0:j.xAxis)==null?void 0:ye.labels,alignment:"top"}):null]},Ce)})}),w?v.jsx(v.Fragment,{children:w.map((ue,Ce)=>v.jsx(h1,{text:ue.text,color:ue.color,y:X(ue.value),x1:0-d,x2:re+W.right,classNames:ue.classNames,styles:ue.styles},Ce))}):null]})}),G&&b&&R&&J?v.jsx(yr,{data:G,body:b,xPos:R,yPos:J,backgroundStyle:B==null?void 0:B.tooltip,className:j==null?void 0:j.tooltip}):null,N?v.jsx(Tr,{open:U!==void 0,onClose:()=>{H(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(N,U)}})}):null]})}function _ve(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,sources:a,graphDescription:i,barPadding:o=.25,showTicks:l=!0,leftMargin:s=20,rightMargin:f=20,topMargin:c=20,bottomMargin:h=25,truncateBy:d=999,showLabels:m=!0,showValues:g=!0,backgroundColor:y=!1,suffix:b="",prefix:S="",height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,padding:T,relativeHeight:A,tooltip:M,onSeriesMouseOver:E,refValues:N,graphID:Y,maxValue:ne,minValue:K,onSeriesMouseClick:B,dateFormat:j="yyyy",showOnlyActiveDate:$=!1,autoPlay:V=!1,graphDownload:z=!1,dataDownload:W=!1,language:G="en",theme:ae="light",minHeight:U=0,maxBarThickness:H,ariaLabel:R,resetSelectionOnDoubleClick:ee=!0,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re=5,valueColor:te,styles:F,classNames:q}=t,[X,ie]=I.useState(0),[ce,de]=I.useState(0),[he,Oe]=I.useState(void 0),Ne=I.useRef(null),Te=I.useRef(null);I.useEffect(()=>{const ue=new ResizeObserver(Ce=>{ie(C||Ce[0].target.clientWidth||620),de(w||Ce[0].target.clientHeight||480)});return Ne.current&&(de(Ne.current.clientHeight||480),ie(Ne.current.clientWidth||620),C||ue.observe(Ne.current)),()=>ue.disconnect()},[C,w]);const[_e,xe]=I.useState(V),we=qi(Bt(e,ue=>ue.date).map(ue=>bt(`${ue.date}`,j,new Date).getTime()),(ue,Ce)=>Ka(ue,Ce)),[ge,ve]=I.useState(V?0:we.length-1),le={};return we.forEach((ue,Ce)=>{le[`${ue}`]={style:{color:Ce===ge?"#232E3D":"#A9B1B7",fontWeight:Ce===ge?"bold":"normal",display:Ce===ge||!$?"inline":"none"},label:Sa(new Date(ue),j)}}),I.useEffect(()=>{const ue=setInterval(()=>{ve(Ce=>Ce<we.length-1?Ce+1:0)},2e3);return _e||clearInterval(ue),()=>clearInterval(ue)},[we,_e]),v.jsx("div",{className:`${ae||"light"} flex ${C?"w-fit grow-0":"w-full grow"}`,dir:G==="he"||G==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${y?y===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${G||"en"}`,q==null?void 0:q.graphContainer),style:{...(F==null?void 0:F.graphContainer)||{},...y&&y!==!0?{backgroundColor:y}:{}},id:Y,ref:Te,"aria-label":R||`${r?`The graph shows ${r}. `:""}This is an animated grouped bar chart showing data changes over time. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:y?T||"1rem":T||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||z||W?v.jsx(Zt,{styles:{title:F==null?void 0:F.title,description:F==null?void 0:F.description},classNames:{title:q==null?void 0:q.title,description:q==null?void 0:q.description},graphTitle:r,graphDescription:i,width:C,graphDownload:z?Te.current:void 0,dataDownload:W?e.map(ue=>ue.data).filter(ue=>ue!==void 0).length>0?e.map(ue=>ue.data).filter(ue=>ue!==void 0):e.filter(ue=>ue!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{xe(!_e)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":_e?"Click to pause animation":"Click to play animation",children:_e?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:we[0],max:we[we.length-1],marks:le,step:null,defaultValue:we[we.length-1],value:we[ge],onChangeComplete:ue=>{ve(we.indexOf(ue))},onChange:ue=>{ve(we.indexOf(ue))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[v.jsx(Cn,{width:C,colorDomain:_,colors:n,colorLegendTitle:D,setSelectedColor:Oe,showNAColor:!1}),v.jsx("div",{className:"w-full grow leading-0",ref:Ne,"aria-label":"Graph area",children:(C||X)&&(w||ce)?v.jsx(kve,{data:e,barColors:n,width:C||X,height:Math.max(U,w||(A?U?(C||X)*A>U?(C||X)*A:U:(C||X)*A:ce)),suffix:b,prefix:S,barPadding:o,showLabels:m,showValues:g,showTicks:l,truncateBy:d,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,tooltip:M,onSeriesMouseOver:E,refValues:N,maxValue:ne,minValue:K,onSeriesMouseClick:B,selectedColor:he,dateFormat:j,indx:ge,maxBarThickness:H,resetSelectionOnDoubleClick:ee,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re,valueColor:te,styles:F,classNames:q}):null})]}),a||k?v.jsx(tr,{styles:{footnote:F==null?void 0:F.footnote,source:F==null?void 0:F.source},classNames:{footnote:q==null?void 0:q.footnote,source:q==null?void 0:q.source},sources:a,footNote:k,width:C}):null]})})})})}function Ove(t){var he,Oe,Ne,Te,_e,xe,we,ge,ve,le;const{data:e,barColors:r,barPadding:n,showTicks:a,leftMargin:i,rightMargin:o,truncateBy:l,width:s,height:f,topMargin:c,bottomMargin:h,tooltip:d,onSeriesMouseOver:m,showLabels:g,suffix:y,prefix:b,showValues:S,refValues:w,maxValue:C,onSeriesMouseClick:k,selectedColor:_,dateFormat:D,indx:T,autoSort:A,sortParameter:M,maxBarThickness:E,minBarThickness:N,resetSelectionOnDoubleClick:Y,detailsOnClick:ne,barAxisTitle:K,valueColor:B,noOfTicks:j,styles:$,classNames:V}=t,[z,W]=I.useState(void 0),G=Ut(e.map(ue=>({...ue,date:bt(`${ue.date}`,D,new Date)})),"date"),ae=Bt(G,ue=>ue.label).map(ue=>ue.label),U=Array.from(Hi(Vf(e,D||"yyyy"),ue=>ue.date),([ue,Ce])=>({date:ue,values:M!==void 0||A?M==="total"||M===void 0?Ut(e.filter(pe=>pe.date===ue),pe=>fr(pe.size.filter(ye=>!Fe(ye)))).map((pe,ye)=>({...pe,id:`${ye}`})):Ut(e.filter(pe=>pe.date===ue),pe=>Fe(pe.size[M])?-1/0:pe.size[M]).map((pe,ye)=>({...pe,id:`${ye}`})):ae.map(pe=>Ce.find(ye=>ye.label===pe)).map((pe,ye)=>({...pe,id:`${ye}`}))})),H={top:c,bottom:h,left:i,right:o},[R,ee]=I.useState(void 0),[J,Z]=I.useState(void 0),[re,te]=I.useState(void 0),F=s-H.left-H.right,q=f-H.top-H.bottom,X=Fe(C)?Math.max(...e.map(ue=>fr(ue.size.filter(Ce=>!Fe(Ce)))||0)):C,ie=br().domain([0,X]).range([q,0]).nice(),ce=Un().domain(ae.map((ue,Ce)=>`${Ce}`)).range([0,N?Math.max(F,N*ae.length):E?Math.min(F,E*ae.length):F]).paddingInner(n),de=ie.ticks(j);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${s}px`,height:`${f}px`,viewBox:`0 0 ${s} ${f}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${H.left},${H.top})`,children:[v.jsx(Nr,{y1:ie(0),y2:ie(0),x1:0-i,x2:F+H.right,label:_t(0,b,y),labelPos:{x:0-i,y:ie(0),dx:0,dy:-5},classNames:{axis:(he=V==null?void 0:V.xAxis)==null?void 0:he.axis,label:(Oe=V==null?void 0:V.yAxis)==null?void 0:Oe.labels},styles:{axis:(Ne=$==null?void 0:$.xAxis)==null?void 0:Ne.axis,label:(Te=$==null?void 0:$.yAxis)==null?void 0:Te.labels}}),a?v.jsx(v1,{values:de.filter(ue=>ue!==0),y:de.filter(ue=>ue!==0).map(ue=>ie(ue)),x1:0-i,x2:F+H.right,styles:{gridLines:(_e=$==null?void 0:$.yAxis)==null?void 0:_e.gridLines,labels:(xe=$==null?void 0:$.yAxis)==null?void 0:xe.labels},classNames:{gridLines:(we=V==null?void 0:V.yAxis)==null?void 0:we.gridLines,labels:(ge=V==null?void 0:V.yAxis)==null?void 0:ge.labels},suffix:y,prefix:b,labelType:"secondary",showGridLines:!0,labelPos:"vertical"}):null,v.jsx(nn,{x:0-i-15,y:q/2,style:(ve=$==null?void 0:$.yAxis)==null?void 0:ve.title,className:(le=V==null?void 0:V.yAxis)==null?void 0:le.title,text:K,rotate90:!0}),v.jsx(mo,{children:U[T].values.map(ue=>{var Ce,pe;return v.jsxs("g",{className:"undp-viz-low-opacity undp-viz-g-with-hover",transform:"translate(0,0)",children:[ue.size.map((ye,be)=>v.jsxs(ur.g,{opacity:_?r[be]===_?1:.3:1,onMouseEnter:je=>{ee({...ue,sizeIndex:be}),te(je.clientY),Z(je.clientX),m&&m({...ue,sizeIndex:be})},onMouseMove:je=>{ee({...ue,sizeIndex:be}),te(je.clientY),Z(je.clientX)},onMouseLeave:()=>{ee(void 0),Z(void 0),te(void 0),m&&m(void 0)},onClick:()=>{(k||ne)&&(Sr(z,{...ue,sizeIndex:be})&&Y?(W(void 0),k&&k(void 0)):(W({...ue,sizeIndex:be}),k&&k({...ue,sizeIndex:be})))},children:[v.jsx(ur.rect,{style:{fill:r[be]},width:ce.bandwidth(),animate:{height:Math.abs(ie(fr(ue.size.filter((je,$e)=>$e<=be&&je)))-ie(fr(ue.size.filter((je,$e)=>$e<be&&je)))),attrY:ie(fr(ue.size.filter((je,$e)=>$e<=be&&je))),attrX:ce(ue.id)},transition:{duration:.5}},be),S?v.jsx(ur.text,{style:{fill:Bi(r[be]),textAnchor:"middle",...($==null?void 0:$.graphObjectValues)||{}},className:Be("graph-value text-sm",V==null?void 0:V.graphObjectValues),dy:"0.33em",animate:{attrY:ie(fr(ue.size.filter((je,$e)=>$e<=be&&je)))+Math.abs(ie(fr(ue.size.filter((je,$e)=>$e<=be&&je)))-ie(fr(ue.size.filter((je,$e)=>$e<be&&je))))/2,attrX:(ce(ue.id)||0)+ce.bandwidth()/2,opacity:ye&&Math.abs(ie(fr(ue.size.filter((je,$e)=>$e<=be&&je)))-ie(fr(ue.size.filter((je,$e)=>$e<be&&je))))>20?1:0},transition:{duration:.5},children:_t(ye,b,y)}):null]},be)),g?v.jsx(ur.text,{style:{textAnchor:"middle",...((Ce=$==null?void 0:$.xAxis)==null?void 0:Ce.labels)||{}},className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(pe=V==null?void 0:V.xAxis)==null?void 0:pe.labels),dy:"1em",animate:{attrY:ie(0)+5,attrX:(ce(ue.id)||0)+ce.bandwidth()/2},transition:{duration:.5},children:`${ue.label}`.length<l?`${ue.label}`:`${`${ue.label}`.substring(0,l)}...`}):null,S?v.jsx(ur.text,{style:{...B&&{fill:B},textAnchor:"middle",...($==null?void 0:$.graphObjectValues)||{}},className:Be("graph-value graph-value-total",B?"text-sm":"fill-primary-gray-700 dark:fill-primary-gray-300 text-sm",V==null?void 0:V.graphObjectValues),dy:-10,animate:{attrY:ie(fr(ue.size.map(ye=>ye||0))),attrX:(ce(ue.id)||0)+ce.bandwidth()/2},transition:{duration:.5},children:_t(fr(ue.size.filter(ye=>ye)),b,y)}):null]},ue.label)})}),w?v.jsx(v.Fragment,{children:w.map((ue,Ce)=>v.jsx(h1,{text:ue.text,color:ue.color,y:ie(ue.value),x1:0-i,x2:F+H.right,classNames:ue.classNames,styles:ue.styles},Ce))}):null]})}),R&&d&&J&&re?v.jsx(yr,{data:R,body:d,xPos:J,yPos:re,backgroundStyle:$==null?void 0:$.tooltip,className:V==null?void 0:V.tooltip}):null,ne?v.jsx(Tr,{open:z!==void 0,onClose:()=>{W(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(ne,z)}})}):null]})}function Dve(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,sources:a,graphDescription:i,barPadding:o=.25,showTicks:l=!0,leftMargin:s=20,rightMargin:f=20,topMargin:c=20,bottomMargin:h=25,truncateBy:d=999,showLabels:m=!0,showValues:g=!0,backgroundColor:y=!1,suffix:b="",prefix:S="",height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,padding:T,tooltip:A,onSeriesMouseOver:M,relativeHeight:E,refValues:N,graphID:Y,maxValue:ne,onSeriesMouseClick:K,dateFormat:B="yyyy",showOnlyActiveDate:j=!1,autoPlay:$=!1,autoSort:V=!0,graphDownload:z=!1,dataDownload:W=!1,language:G="en",theme:ae="light",minHeight:U=0,sortParameter:H,maxBarThickness:R,minBarThickness:ee,ariaLabel:J,resetSelectionOnDoubleClick:Z=!0,detailsOnClick:re,barAxisTitle:te,noOfTicks:F=5,valueColor:q,styles:X,classNames:ie}=t,[ce,de]=I.useState(0),[he,Oe]=I.useState(0),[Ne,Te]=I.useState(void 0),_e=I.useRef(null),xe=I.useRef(null);I.useEffect(()=>{const pe=new ResizeObserver(ye=>{de(C||ye[0].target.clientWidth||620),Oe(w||ye[0].target.clientHeight||480)});return _e.current&&(Oe(_e.current.clientHeight||480),de(_e.current.clientWidth||620),C||pe.observe(_e.current)),()=>pe.disconnect()},[C,w]);const[we,ge]=I.useState($),ve=qi(Bt(e,pe=>pe.date).map(pe=>bt(`${pe.date}`,B,new Date).getTime()),(pe,ye)=>Ka(pe,ye)),[le,ue]=I.useState($?0:ve.length-1),Ce={};return ve.forEach((pe,ye)=>{Ce[`${pe}`]={style:{color:ye===le?"#232E3D":"#A9B1B7",fontWeight:ye===le?"bold":"normal",display:ye===le||!j?"inline":"none"},label:Sa(new Date(pe),B)}}),I.useEffect(()=>{const pe=setInterval(()=>{ue(ye=>ye<ve.length-1?ye+1:0)},2e3);return we||clearInterval(pe),()=>clearInterval(pe)},[ve,we]),v.jsx("div",{className:`${ae||"light"} flex ${C?"w-fit grow-0":"w-full grow"}`,dir:G==="he"||G==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${y?y===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${G||"en"}`,ie==null?void 0:ie.graphContainer),style:{...(X==null?void 0:X.graphContainer)||{},...y&&y!==!0?{backgroundColor:y}:{}},id:Y,ref:xe,"aria-label":J||`${r?`The graph shows ${r}. `:""}This is an animated stacked bar chart showing data changes over time. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:y?T||"1rem":T||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||z||W?v.jsx(Zt,{styles:{title:X==null?void 0:X.title,description:X==null?void 0:X.description},classNames:{title:ie==null?void 0:ie.title,description:ie==null?void 0:ie.description},graphTitle:r,graphDescription:i,width:C,graphDownload:z?xe.current:void 0,dataDownload:W?e.map(pe=>pe.data).filter(pe=>pe!==void 0).length>0?e.map(pe=>pe.data).filter(pe=>pe!==void 0):e.filter(pe=>pe!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{ge(!we)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":we?"Click to pause animation":"Click to play animation",children:we?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:ve[0],max:ve[ve.length-1],marks:Ce,step:null,defaultValue:ve[ve.length-1],value:ve[le],onChangeComplete:pe=>{ue(ve.indexOf(pe))},onChange:pe=>{ue(ve.indexOf(pe))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[v.jsx(Cn,{width:C,colorDomain:_,colors:n,colorLegendTitle:D,setSelectedColor:Te,showNAColor:!1}),v.jsx("div",{className:"w-full grow leading-0",ref:_e,"aria-label":"Graph area",children:(C||ce)&&(w||he)?v.jsx(Ove,{data:e,barColors:n,width:C||ce,height:Math.max(U,w||(E?U?(C||ce)*E>U?(C||ce)*E:U:(C||ce)*E:he)),suffix:b,prefix:S,barPadding:o,showLabels:m,showValues:g,showTicks:l,truncateBy:d,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,tooltip:A,onSeriesMouseOver:M,refValues:N,maxValue:ne,onSeriesMouseClick:K,selectedColor:Ne,dateFormat:B,indx:le,sortParameter:H,autoSort:V,maxBarThickness:R,minBarThickness:ee,resetSelectionOnDoubleClick:Z,detailsOnClick:re,barAxisTitle:te,noOfTicks:F,valueColor:q,styles:X,classNames:ie}):null})]}),a||k?v.jsx(tr,{styles:{footnote:X==null?void 0:X.footnote,source:X==null?void 0:X.source},classNames:{footnote:ie==null?void 0:ie.footnote,source:ie==null?void 0:ie.source},sources:a,footNote:k,width:C}):null]})})})})}function gq(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,showValues:g,backgroundColor:y,suffix:b,prefix:S,height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,highlightedDataPoints:T,padding:A,relativeHeight:M,tooltip:E,onSeriesMouseOver:N,refValues:Y,showColorScale:ne,graphID:K,maxValue:B,minValue:j,onSeriesMouseClick:$,dateFormat:V,showOnlyActiveDate:z,autoPlay:W,autoSort:G,graphDownload:ae,dataDownload:U,language:H,theme:R,showNAColor:ee,minHeight:J,maxBarThickness:Z,minBarThickness:re,ariaLabel:te,resetSelectionOnDoubleClick:F,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie,valueColor:ce,orientation:de="vertical",styles:he,classNames:Oe}=t;return de==="vertical"?v.jsx(Cve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,showValues:g,backgroundColor:y,suffix:b,prefix:S,height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,highlightedDataPoints:T,padding:A,relativeHeight:M,tooltip:E,onSeriesMouseOver:N,refValues:Y,showColorScale:ne,graphID:K,maxValue:B,minValue:j,onSeriesMouseClick:$,dateFormat:V,showOnlyActiveDate:z,autoPlay:W,autoSort:G,graphDownload:ae,dataDownload:U,language:H,theme:R,showNAColor:ee,minHeight:J,maxBarThickness:Z,minBarThickness:re,ariaLabel:te,resetSelectionOnDoubleClick:F,styles:he,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie,valueColor:ce,classNames:Oe}):v.jsx(yve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,showValues:g,backgroundColor:y,suffix:b,prefix:S,height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,highlightedDataPoints:T,padding:A,relativeHeight:M,tooltip:E,onSeriesMouseOver:N,refValues:Y,showColorScale:ne,graphID:K,maxValue:B,minValue:j,onSeriesMouseClick:$,dateFormat:V,showOnlyActiveDate:z,autoPlay:W,autoSort:G,graphDownload:ae,dataDownload:U,language:H,theme:R,showNAColor:ee,minHeight:J,maxBarThickness:Z,minBarThickness:re,ariaLabel:te,resetSelectionOnDoubleClick:F,styles:he,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie,valueColor:ce,classNames:Oe})}function yq(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,truncateBy:s,height:f,width:c,footNote:h,colorDomain:d,colorLegendTitle:m,suffix:g,prefix:y,showValues:b,padding:S,backgroundColor:w,leftMargin:C,rightMargin:k,topMargin:_,showLabels:D,bottomMargin:T,relativeHeight:A,tooltip:M,onSeriesMouseOver:E,refValues:N,graphID:Y,maxValue:ne,minValue:K,onSeriesMouseClick:B,graphDownload:j,dataDownload:$,dateFormat:V,showOnlyActiveDate:z,autoPlay:W,language:G,minHeight:ae,theme:U,maxBarThickness:H,ariaLabel:R,resetSelectionOnDoubleClick:ee,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re,valueColor:te,orientation:F="vertical",styles:q,classNames:X}=t;return F==="vertical"?v.jsx(_ve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,truncateBy:s,height:f,width:c,footNote:h,colorDomain:d,colorLegendTitle:m,suffix:g,prefix:y,showValues:b,padding:S,backgroundColor:w,leftMargin:C,rightMargin:k,topMargin:_,showLabels:D,bottomMargin:T,relativeHeight:A,tooltip:M,onSeriesMouseOver:E,refValues:N,graphID:Y,maxValue:ne,minValue:K,onSeriesMouseClick:B,graphDownload:j,dataDownload:$,dateFormat:V,showOnlyActiveDate:z,autoPlay:W,language:G,minHeight:ae,theme:U,maxBarThickness:H,ariaLabel:R,resetSelectionOnDoubleClick:ee,styles:q,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re,valueColor:te,classNames:X}):v.jsx(bve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,truncateBy:s,height:f,width:c,footNote:h,colorDomain:d,colorLegendTitle:m,suffix:g,prefix:y,showValues:b,padding:S,backgroundColor:w,leftMargin:C,rightMargin:k,topMargin:_,showLabels:D,bottomMargin:T,relativeHeight:A,tooltip:M,onSeriesMouseOver:E,refValues:N,graphID:Y,maxValue:ne,minValue:K,onSeriesMouseClick:B,graphDownload:j,dataDownload:$,dateFormat:V,showOnlyActiveDate:z,autoPlay:W,language:G,minHeight:ae,theme:U,maxBarThickness:H,ariaLabel:R,resetSelectionOnDoubleClick:ee,styles:q,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re,valueColor:te,classNames:X})}function vq(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,showValues:g,backgroundColor:y,suffix:b,prefix:S,height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,padding:T,tooltip:A,onSeriesMouseOver:M,relativeHeight:E,refValues:N,graphID:Y,maxValue:ne,onSeriesMouseClick:K,dateFormat:B,showOnlyActiveDate:j,autoPlay:$,autoSort:V,graphDownload:z,dataDownload:W,language:G,theme:ae,minHeight:U,sortParameter:H,maxBarThickness:R,minBarThickness:ee,ariaLabel:J,resetSelectionOnDoubleClick:Z,detailsOnClick:re,barAxisTitle:te,noOfTicks:F,valueColor:q,orientation:X="vertical",styles:ie,classNames:ce}=t;return X==="vertical"?v.jsx(Dve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,showValues:g,backgroundColor:y,suffix:b,prefix:S,height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,padding:T,tooltip:A,onSeriesMouseOver:M,relativeHeight:E,refValues:N,graphID:Y,maxValue:ne,onSeriesMouseClick:K,dateFormat:B,showOnlyActiveDate:j,autoPlay:$,autoSort:V,graphDownload:z,dataDownload:W,language:G,theme:ae,minHeight:U,sortParameter:H,maxBarThickness:R,minBarThickness:ee,ariaLabel:J,resetSelectionOnDoubleClick:Z,styles:ie,detailsOnClick:re,barAxisTitle:te,noOfTicks:F,valueColor:q,classNames:ce}):v.jsx(wve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,showValues:g,backgroundColor:y,suffix:b,prefix:S,height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,padding:T,tooltip:A,onSeriesMouseOver:M,relativeHeight:E,refValues:N,graphID:Y,maxValue:ne,onSeriesMouseClick:K,dateFormat:B,showOnlyActiveDate:j,autoPlay:$,autoSort:V,graphDownload:z,dataDownload:W,language:G,theme:ae,minHeight:U,sortParameter:H,maxBarThickness:R,minBarThickness:ee,ariaLabel:J,resetSelectionOnDoubleClick:Z,styles:ie,detailsOnClick:re,barAxisTitle:te,noOfTicks:F,valueColor:q,classNames:ce})}function Lr(t,e,r){return e.findIndex(n=>n.chartConfigId===t)===-1?void 0:typeof e[e.findIndex(n=>n.chartConfigId===t)].columnId=="object"?e[e.findIndex(n=>n.chartConfigId===t)].columnId.map(n=>r.findIndex(a=>a.value===n)===-1?n:r[r.findIndex(a=>a.value===n)].label):r.findIndex(n=>n.value===e[e.findIndex(a=>a.chartConfigId===t)].columnId)===-1?e[e.findIndex(n=>n.chartConfigId===t)].columnId:r[r.findIndex(n=>n.value===e[e.findIndex(a=>a.chartConfigId===t)].columnId)].label}var w5={exports:{}},Tm={},I0={},S3={},Mm={},Em={},jm={},XM;function Rc(){return XM||(XM=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class e{}t._CodeOrName=e,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends e{constructor(w){if(super(),!t.IDENTIFIER.test(w))throw new Error("CodeGen: name must be a valid identifier");this.str=w}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class n extends e{constructor(w){super(),this._items=typeof w=="string"?[w]:w}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const w=this._items[0];return w===""||w==='""'}get str(){var w;return(w=this._str)!==null&&w!==void 0?w:this._str=this._items.reduce((C,k)=>`${C}${k}`,"")}get names(){var w;return(w=this._names)!==null&&w!==void 0?w:this._names=this._items.reduce((C,k)=>(k instanceof r&&(C[k.str]=(C[k.str]||0)+1),C),{})}}t._Code=n,t.nil=new n("");function a(S,...w){const C=[S[0]];let k=0;for(;k<w.length;)l(C,w[k]),C.push(S[++k]);return new n(C)}t._=a;const i=new n("+");function o(S,...w){const C=[m(S[0])];let k=0;for(;k<w.length;)C.push(i),l(C,w[k]),C.push(i,m(S[++k]));return s(C),new n(C)}t.str=o;function l(S,w){w instanceof n?S.push(...w._items):w instanceof r?S.push(w):S.push(h(w))}t.addCodeArg=l;function s(S){let w=1;for(;w<S.length-1;){if(S[w]===i){const C=f(S[w-1],S[w+1]);if(C!==void 0){S.splice(w-1,3,C);continue}S[w++]="+"}w++}}function f(S,w){if(w==='""')return S;if(S==='""')return w;if(typeof S=="string")return w instanceof r||S[S.length-1]!=='"'?void 0:typeof w!="string"?`${S.slice(0,-1)}${w}"`:w[0]==='"'?S.slice(0,-1)+w.slice(1):void 0;if(typeof w=="string"&&w[0]==='"'&&!(S instanceof r))return`"${S}${w.slice(1)}`}function c(S,w){return w.emptyStr()?S:S.emptyStr()?w:o`${S}${w}`}t.strConcat=c;function h(S){return typeof S=="number"||typeof S=="boolean"||S===null?S:m(Array.isArray(S)?S.join(","):S)}function d(S){return new n(m(S))}t.stringify=d;function m(S){return JSON.stringify(S).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=m;function g(S){return typeof S=="string"&&t.IDENTIFIER.test(S)?new n(`.${S}`):a`[${S}]`}t.getProperty=g;function y(S){if(typeof S=="string"&&t.IDENTIFIER.test(S))return new n(`${S}`);throw new Error(`CodeGen: invalid export name: ${S}, use explicit $id name mapping`)}t.getEsmExportName=y;function b(S){return new n(S.toString())}t.regexpCode=b}(jm)),jm}var Lm={},KM;function JM(){return KM||(KM=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=Rc();class r extends Error{constructor(f){super(`CodeGen: "code" for ${f} not defined`),this.value=f.value}}var n;(function(s){s[s.Started=0]="Started",s[s.Completed=1]="Completed"})(n||(t.UsedValueState=n={})),t.varKinds={const:new e.Name("const"),let:new e.Name("let"),var:new e.Name("var")};class a{constructor({prefixes:f,parent:c}={}){this._names={},this._prefixes=f,this._parent=c}toName(f){return f instanceof e.Name?f:this.name(f)}name(f){return new e.Name(this._newName(f))}_newName(f){const c=this._names[f]||this._nameGroup(f);return`${f}${c.index++}`}_nameGroup(f){var c,h;if(!((h=(c=this._parent)===null||c===void 0?void 0:c._prefixes)===null||h===void 0)&&h.has(f)||this._prefixes&&!this._prefixes.has(f))throw new Error(`CodeGen: prefix "${f}" is not allowed in this scope`);return this._names[f]={prefix:f,index:0}}}t.Scope=a;class i extends e.Name{constructor(f,c){super(c),this.prefix=f}setValue(f,{property:c,itemIndex:h}){this.value=f,this.scopePath=(0,e._)`.${new e.Name(c)}[${h}]`}}t.ValueScopeName=i;const o=(0,e._)`\n`;class l extends a{constructor(f){super(f),this._values={},this._scope=f.scope,this.opts={...f,_n:f.lines?o:e.nil}}get(){return this._scope}name(f){return new i(f,this._newName(f))}value(f,c){var h;if(c.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const d=this.toName(f),{prefix:m}=d,g=(h=c.key)!==null&&h!==void 0?h:c.ref;let y=this._values[m];if(y){const w=y.get(g);if(w)return w}else y=this._values[m]=new Map;y.set(g,d);const b=this._scope[m]||(this._scope[m]=[]),S=b.length;return b[S]=c.ref,d.setValue(c,{property:m,itemIndex:S}),d}getValue(f,c){const h=this._values[f];if(h)return h.get(c)}scopeRefs(f,c=this._values){return this._reduceValues(c,h=>{if(h.scopePath===void 0)throw new Error(`CodeGen: name "${h}" has no value`);return(0,e._)`${f}${h.scopePath}`})}scopeCode(f=this._values,c,h){return this._reduceValues(f,d=>{if(d.value===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return d.value.code},c,h)}_reduceValues(f,c,h={},d){let m=e.nil;for(const g in f){const y=f[g];if(!y)continue;const b=h[g]=h[g]||new Map;y.forEach(S=>{if(b.has(S))return;b.set(S,n.Started);let w=c(S);if(w){const C=this.opts.es5?t.varKinds.var:t.varKinds.const;m=(0,e._)`${m}${C} ${S} = ${w};${this.opts._n}`}else if(w=d==null?void 0:d(S))m=(0,e._)`${m}${w}${this.opts._n}`;else throw new r(S);b.set(S,n.Completed)})}return m}}t.ValueScope=l}(Lm)),Lm}var ZM;function Fr(){return ZM||(ZM=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const e=Rc(),r=JM();var n=Rc();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return n.Name}});var a=JM();Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return a.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return a.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return a.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return a.varKinds}}),t.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class i{optimizeNodes(){return this}optimizeNames(H,R){return this}}class o extends i{constructor(H,R,ee){super(),this.varKind=H,this.name=R,this.rhs=ee}render({es5:H,_n:R}){const ee=H?r.varKinds.var:this.varKind,J=this.rhs===void 0?"":` = ${this.rhs}`;return`${ee} ${this.name}${J};`+R}optimizeNames(H,R){if(H[this.name.str])return this.rhs&&(this.rhs=K(this.rhs,H,R)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class l extends i{constructor(H,R,ee){super(),this.lhs=H,this.rhs=R,this.sideEffects=ee}render({_n:H}){return`${this.lhs} = ${this.rhs};`+H}optimizeNames(H,R){if(!(this.lhs instanceof e.Name&&!H[this.lhs.str]&&!this.sideEffects))return this.rhs=K(this.rhs,H,R),this}get names(){const H=this.lhs instanceof e.Name?{}:{...this.lhs.names};return ne(H,this.rhs)}}class s extends l{constructor(H,R,ee,J){super(H,ee,J),this.op=R}render({_n:H}){return`${this.lhs} ${this.op}= ${this.rhs};`+H}}class f extends i{constructor(H){super(),this.label=H,this.names={}}render({_n:H}){return`${this.label}:`+H}}class c extends i{constructor(H){super(),this.label=H,this.names={}}render({_n:H}){return`break${this.label?` ${this.label}`:""};`+H}}class h extends i{constructor(H){super(),this.error=H}render({_n:H}){return`throw ${this.error};`+H}get names(){return this.error.names}}class d extends i{constructor(H){super(),this.code=H}render({_n:H}){return`${this.code};`+H}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(H,R){return this.code=K(this.code,H,R),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class m extends i{constructor(H=[]){super(),this.nodes=H}render(H){return this.nodes.reduce((R,ee)=>R+ee.render(H),"")}optimizeNodes(){const{nodes:H}=this;let R=H.length;for(;R--;){const ee=H[R].optimizeNodes();Array.isArray(ee)?H.splice(R,1,...ee):ee?H[R]=ee:H.splice(R,1)}return H.length>0?this:void 0}optimizeNames(H,R){const{nodes:ee}=this;let J=ee.length;for(;J--;){const Z=ee[J];Z.optimizeNames(H,R)||(B(H,Z.names),ee.splice(J,1))}return ee.length>0?this:void 0}get names(){return this.nodes.reduce((H,R)=>Y(H,R.names),{})}}class g extends m{render(H){return"{"+H._n+super.render(H)+"}"+H._n}}class y extends m{}class b extends g{}b.kind="else";class S extends g{constructor(H,R){super(R),this.condition=H}render(H){let R=`if(${this.condition})`+super.render(H);return this.else&&(R+="else "+this.else.render(H)),R}optimizeNodes(){super.optimizeNodes();const H=this.condition;if(H===!0)return this.nodes;let R=this.else;if(R){const ee=R.optimizeNodes();R=this.else=Array.isArray(ee)?new b(ee):ee}if(R)return H===!1?R instanceof S?R:R.nodes:this.nodes.length?this:new S(j(H),R instanceof S?[R]:R.nodes);if(!(H===!1||!this.nodes.length))return this}optimizeNames(H,R){var ee;if(this.else=(ee=this.else)===null||ee===void 0?void 0:ee.optimizeNames(H,R),!!(super.optimizeNames(H,R)||this.else))return this.condition=K(this.condition,H,R),this}get names(){const H=super.names;return ne(H,this.condition),this.else&&Y(H,this.else.names),H}}S.kind="if";class w extends g{}w.kind="for";class C extends w{constructor(H){super(),this.iteration=H}render(H){return`for(${this.iteration})`+super.render(H)}optimizeNames(H,R){if(super.optimizeNames(H,R))return this.iteration=K(this.iteration,H,R),this}get names(){return Y(super.names,this.iteration.names)}}class k extends w{constructor(H,R,ee,J){super(),this.varKind=H,this.name=R,this.from=ee,this.to=J}render(H){const R=H.es5?r.varKinds.var:this.varKind,{name:ee,from:J,to:Z}=this;return`for(${R} ${ee}=${J}; ${ee}<${Z}; ${ee}++)`+super.render(H)}get names(){const H=ne(super.names,this.from);return ne(H,this.to)}}class _ extends w{constructor(H,R,ee,J){super(),this.loop=H,this.varKind=R,this.name=ee,this.iterable=J}render(H){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(H)}optimizeNames(H,R){if(super.optimizeNames(H,R))return this.iterable=K(this.iterable,H,R),this}get names(){return Y(super.names,this.iterable.names)}}class D extends g{constructor(H,R,ee){super(),this.name=H,this.args=R,this.async=ee}render(H){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(H)}}D.kind="func";class T extends m{render(H){return"return "+super.render(H)}}T.kind="return";class A extends g{render(H){let R="try"+super.render(H);return this.catch&&(R+=this.catch.render(H)),this.finally&&(R+=this.finally.render(H)),R}optimizeNodes(){var H,R;return super.optimizeNodes(),(H=this.catch)===null||H===void 0||H.optimizeNodes(),(R=this.finally)===null||R===void 0||R.optimizeNodes(),this}optimizeNames(H,R){var ee,J;return super.optimizeNames(H,R),(ee=this.catch)===null||ee===void 0||ee.optimizeNames(H,R),(J=this.finally)===null||J===void 0||J.optimizeNames(H,R),this}get names(){const H=super.names;return this.catch&&Y(H,this.catch.names),this.finally&&Y(H,this.finally.names),H}}class M extends g{constructor(H){super(),this.error=H}render(H){return`catch(${this.error})`+super.render(H)}}M.kind="catch";class E extends g{render(H){return"finally"+super.render(H)}}E.kind="finally";class N{constructor(H,R={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...R,_n:R.lines?`
|
|
278
|
+
`},Pme={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:r}=t;return r?"Draggable item "+e.id+" was moved over droppable area "+r.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:r}=t;return r?"Draggable item "+e.id+" was dropped over droppable area "+r.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function Rme(t){let{announcements:e=Pme,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=Ime}=t;const{announce:i,announcement:o}=jme(),l=sw("DndLiveRegion"),[s,f]=I.useState(!1);if(I.useEffect(()=>{f(!0)},[]),Lme(I.useMemo(()=>({onDragStart(h){let{active:d}=h;i(e.onDragStart({active:d}))},onDragMove(h){let{active:d,over:m}=h;e.onDragMove&&i(e.onDragMove({active:d,over:m}))},onDragOver(h){let{active:d,over:m}=h;i(e.onDragOver({active:d,over:m}))},onDragEnd(h){let{active:d,over:m}=h;i(e.onDragEnd({active:d,over:m}))},onDragCancel(h){let{active:d,over:m}=h;i(e.onDragCancel({active:d,over:m}))}}),[i,e])),!s)return null;const c=I.createElement(I.Fragment,null,I.createElement(Mme,{id:n,value:a.draggable}),I.createElement(Eme,{id:l,announcement:o}));return r?a0.createPortal(c,r):c}var $1;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})($1||($1={}));function Nc(){}function $me(t,e){return I.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Bme(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return I.useMemo(()=>[...e].filter(n=>n!=null),[...e])}const Ro=Object.freeze({x:0,y:0});function Vme(t,e){let{data:{value:r}}=t,{data:{value:n}}=e;return n-r}function Fme(t,e){if(!t||t.length===0)return null;const[r]=t;return r[e]}function zme(t,e){const r=Math.max(e.top,t.top),n=Math.max(e.left,t.left),a=Math.min(e.left+e.width,t.left+t.width),i=Math.min(e.top+e.height,t.top+t.height),o=a-n,l=i-r;if(n<a&&r<i){const s=e.width*e.height,f=t.width*t.height,c=o*l,h=c/(s+f-c);return Number(h.toFixed(4))}return 0}const Hme=t=>{let{collisionRect:e,droppableRects:r,droppableContainers:n}=t;const a=[];for(const i of n){const{id:o}=i,l=r.get(o);if(l){const s=zme(l,e);s>0&&a.push({id:o,data:{droppableContainer:i,value:s}})}}return a.sort(Vme)};function qme(t,e,r){return{...t,scaleX:e&&r?e.width/r.width:1,scaleY:e&&r?e.height/r.height:1}}function DH(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Ro}function Wme(t){return function(r){for(var n=arguments.length,a=new Array(n>1?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];return a.reduce((o,l)=>({...o,top:o.top+t*l.y,bottom:o.bottom+t*l.y,left:o.left+t*l.x,right:o.right+t*l.x}),{...r})}}const Ume=Wme(1);function Gme(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function Yme(t,e,r){const n=Gme(e);if(!n)return t;const{scaleX:a,scaleY:i,x:o,y:l}=n,s=t.left-o-(1-a)*parseFloat(r),f=t.top-l-(1-i)*parseFloat(r.slice(r.indexOf(" ")+1)),c=a?t.width/a:t.width,h=i?t.height/i:t.height;return{width:c,height:h,top:f,right:s+c,bottom:f+h,left:s}}const Xme={ignoreTransform:!1};function c9(t,e){e===void 0&&(e=Xme);let r=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:f,transformOrigin:c}=xi(t).getComputedStyle(t);f&&(r=Yme(r,f,c))}const{top:n,left:a,width:i,height:o,bottom:l,right:s}=r;return{top:n,left:a,width:i,height:o,bottom:l,right:s}}function TM(t){return c9(t,{ignoreTransform:!0})}function Kme(t){const e=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:e,bottom:r,width:e,height:r}}function Jme(t,e){return e===void 0&&(e=xi(t).getComputedStyle(t)),e.position==="fixed"}function Zme(t,e){e===void 0&&(e=xi(t).getComputedStyle(t));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const i=e[a];return typeof i=="string"?r.test(i):!1})}function uw(t,e){const r=[];function n(a){if(e!=null&&r.length>=e||!a)return r;if(iw(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!s9(a)||CH(a)||r.includes(a))return r;const i=xi(t).getComputedStyle(a);return a!==t&&Zme(a,i)&&r.push(a),Jme(a,i)?r:n(a.parentNode)}return t?n(t):r}function AH(t){const[e]=uw(t,1);return e??null}function xm(t){return!Bf||!t?null:v7(t)?t:aw(t)?iw(t)||t===b7(t).scrollingElement?window:s9(t)?t:null:null}function TH(t){return v7(t)?t.scrollX:t.scrollLeft}function MH(t){return v7(t)?t.scrollY:t.scrollTop}function Zy(t){return{x:TH(t),y:MH(t)}}var l1;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(l1||(l1={}));function EH(t){return!Bf||!t?!1:t===document.scrollingElement}function jH(t){const e={x:0,y:0},r=EH(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},n={x:t.scrollWidth-r.width,y:t.scrollHeight-r.height},a=t.scrollTop<=e.y,i=t.scrollLeft<=e.x,o=t.scrollTop>=n.y,l=t.scrollLeft>=n.x;return{isTop:a,isLeft:i,isBottom:o,isRight:l,maxScroll:n,minScroll:e}}const Qme={x:.2,y:.2};function ege(t,e,r,n,a){let{top:i,left:o,right:l,bottom:s}=r;n===void 0&&(n=10),a===void 0&&(a=Qme);const{isTop:f,isBottom:c,isLeft:h,isRight:d}=jH(t),m={x:0,y:0},g={x:0,y:0},y={height:e.height*a.y,width:e.width*a.x};return!f&&i<=e.top+y.height?(m.y=l1.Backward,g.y=n*Math.abs((e.top+y.height-i)/y.height)):!c&&s>=e.bottom-y.height&&(m.y=l1.Forward,g.y=n*Math.abs((e.bottom-y.height-s)/y.height)),!d&&l>=e.right-y.width?(m.x=l1.Forward,g.x=n*Math.abs((e.right-y.width-l)/y.width)):!h&&o<=e.left+y.width&&(m.x=l1.Backward,g.x=n*Math.abs((e.left+y.width-o)/y.width)),{direction:m,speed:g}}function tge(t){if(t===document.scrollingElement){const{innerWidth:i,innerHeight:o}=window;return{top:0,left:0,right:i,bottom:o,width:i,height:o}}const{top:e,left:r,right:n,bottom:a}=t.getBoundingClientRect();return{top:e,left:r,right:n,bottom:a,width:t.clientWidth,height:t.clientHeight}}function LH(t){return t.reduce((e,r)=>k6(e,Zy(r)),Ro)}function rge(t){return t.reduce((e,r)=>e+TH(r),0)}function nge(t){return t.reduce((e,r)=>e+MH(r),0)}function age(t,e){if(e===void 0&&(e=c9),!t)return;const{top:r,left:n,bottom:a,right:i}=e(t);AH(t)&&(a<=0||i<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const ige=[["x",["left","right"],rge],["y",["top","bottom"],nge]];class cw{constructor(e,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=uw(r),a=LH(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[i,o,l]of ige)for(const s of o)Object.defineProperty(this,s,{get:()=>{const f=l(n),c=a[i]-f;return this.rect[s]+c},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class os{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=e}add(e,r,n){var a;(a=this.target)==null||a.addEventListener(e,r,n),this.listeners.push([e,r,n])}}function oge(t){const{EventTarget:e}=xi(t);return t instanceof e?t:b7(t)}function wm(t,e){const r=Math.abs(t.x),n=Math.abs(t.y);return typeof e=="number"?Math.sqrt(r**2+n**2)>e:"x"in e&&"y"in e?r>e.x&&n>e.y:"x"in e?r>e.x:"y"in e?n>e.y:!1}var ao;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(ao||(ao={}));function MM(t){t.preventDefault()}function lge(t){t.stopPropagation()}var Pn;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Pn||(Pn={}));const NH={start:[Pn.Space,Pn.Enter],cancel:[Pn.Esc],end:[Pn.Space,Pn.Enter,Pn.Tab]},sge=(t,e)=>{let{currentCoordinates:r}=e;switch(t.code){case Pn.Right:return{...r,x:r.x+25};case Pn.Left:return{...r,x:r.x-25};case Pn.Down:return{...r,y:r.y+25};case Pn.Up:return{...r,y:r.y-25}}};class IH{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:r}}=e;this.props=e,this.listeners=new os(b7(r)),this.windowListeners=new os(xi(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ao.Resize,this.handleCancel),this.windowListeners.add(ao.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ao.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:r}=this.props,n=e.node.current;n&&age(n),r(Ro)}handleKeyDown(e){if(_H(e)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:i=NH,coordinateGetter:o=sge,scrollBehavior:l="smooth"}=a,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}const{collisionRect:f}=n.current,c=f?{x:f.left,y:f.top}:Ro;this.referenceCoordinates||(this.referenceCoordinates=c);const h=o(e,{active:r,context:n.current,currentCoordinates:c});if(h){const d=Lc(h,c),m={x:0,y:0},{scrollableAncestors:g}=n.current;for(const y of g){const b=e.code,{isTop:S,isRight:w,isLeft:C,isBottom:k,maxScroll:_,minScroll:D}=jH(y),T=tge(y),A={x:Math.min(b===Pn.Right?T.right-T.width/2:T.right,Math.max(b===Pn.Right?T.left:T.left+T.width/2,h.x)),y:Math.min(b===Pn.Down?T.bottom-T.height/2:T.bottom,Math.max(b===Pn.Down?T.top:T.top+T.height/2,h.y))},M=b===Pn.Right&&!w||b===Pn.Left&&!C,E=b===Pn.Down&&!k||b===Pn.Up&&!S;if(M&&A.x!==h.x){const N=y.scrollLeft+d.x,Y=b===Pn.Right&&N<=_.x||b===Pn.Left&&N>=D.x;if(Y&&!d.y){y.scrollTo({left:N,behavior:l});return}Y?m.x=y.scrollLeft-N:m.x=b===Pn.Right?y.scrollLeft-_.x:y.scrollLeft-D.x,m.x&&y.scrollBy({left:-m.x,behavior:l});break}else if(E&&A.y!==h.y){const N=y.scrollTop+d.y,Y=b===Pn.Down&&N<=_.y||b===Pn.Up&&N>=D.y;if(Y&&!d.x){y.scrollTo({top:N,behavior:l});return}Y?m.y=y.scrollTop-N:m.y=b===Pn.Down?y.scrollTop-_.y:y.scrollTop-D.y,m.y&&y.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(e,k6(Lc(h,this.referenceCoordinates),m))}}}handleMove(e,r){const{onMove:n}=this.props;e.preventDefault(),n(r)}handleEnd(e){const{onEnd:r}=this.props;e.preventDefault(),this.detach(),r()}handleCancel(e){const{onCancel:r}=this.props;e.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}IH.activators=[{eventName:"onKeyDown",handler:(t,e,r)=>{let{keyboardCodes:n=NH,onActivation:a}=e,{active:i}=r;const{code:o}=t.nativeEvent;if(n.start.includes(o)){const l=i.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),a==null||a({event:t.nativeEvent}),!0)}return!1}}];function EM(t){return!!(t&&"distance"in t)}function jM(t){return!!(t&&"delay"in t)}class fw{constructor(e,r,n){var a;n===void 0&&(n=oge(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=r;const{event:i}=e,{target:o}=i;this.props=e,this.events=r,this.document=b7(o),this.documentListeners=new os(this.document),this.listeners=new os(n),this.windowListeners=new os(xi(o)),this.initialCoordinates=(a=Jy(i))!=null?a:Ro,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(ao.Resize,this.handleCancel),this.windowListeners.add(ao.DragStart,MM),this.windowListeners.add(ao.VisibilityChange,this.handleCancel),this.windowListeners.add(ao.ContextMenu,MM),this.documentListeners.add(ao.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(jM(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(EM(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,r){const{active:n,onPending:a}=this.props;a(n,e,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:e}=this,{onStart:r}=this.props;e&&(this.activated=!0,this.documentListeners.add(ao.Click,lge,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ao.SelectionChange,this.removeTextSelection),r(e))}handleMove(e){var r;const{activated:n,initialCoordinates:a,props:i}=this,{onMove:o,options:{activationConstraint:l}}=i;if(!a)return;const s=(r=Jy(e))!=null?r:Ro,f=Lc(a,s);if(!n&&l){if(EM(l)){if(l.tolerance!=null&&wm(f,l.tolerance))return this.handleCancel();if(wm(f,l.distance))return this.handleStart()}if(jM(l)&&wm(f,l.tolerance))return this.handleCancel();this.handlePending(l,f);return}e.cancelable&&e.preventDefault(),o(s)}handleEnd(){const{onAbort:e,onEnd:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleCancel(){const{onAbort:e,onCancel:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleKeydown(e){e.code===Pn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const uge={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class dw extends fw{constructor(e){const{event:r}=e,n=b7(r.target);super(e,uge,n)}}dw.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:r}=t,{onActivation:n}=e;return!r.isPrimary||r.button!==0?!1:(n==null||n({event:r}),!0)}}];const cge={move:{name:"mousemove"},end:{name:"mouseup"}};var Qy;(function(t){t[t.RightClick=2]="RightClick"})(Qy||(Qy={}));class fge extends fw{constructor(e){super(e,cge,b7(e.event.target))}}fge.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:r}=t,{onActivation:n}=e;return r.button===Qy.RightClick?!1:(n==null||n({event:r}),!0)}}];const Sm={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class dge extends fw{constructor(e){super(e,Sm)}static setup(){return window.addEventListener(Sm.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Sm.move.name,e)};function e(){}}}dge.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:r}=t,{onActivation:n}=e;const{touches:a}=r;return a.length>1?!1:(n==null||n({event:r}),!0)}}];var ls;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(ls||(ls={}));var Ic;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ic||(Ic={}));function hge(t){let{acceleration:e,activator:r=ls.Pointer,canScroll:n,draggingRect:a,enabled:i,interval:o=5,order:l=Ic.TreeOrder,pointerCoordinates:s,scrollableAncestors:f,scrollableAncestorRects:c,delta:h,threshold:d}=t;const m=mge({delta:h,disabled:!i}),[g,y]=_me(),b=I.useRef({x:0,y:0}),S=I.useRef({x:0,y:0}),w=I.useMemo(()=>{switch(r){case ls.Pointer:return s?{top:s.y,bottom:s.y,left:s.x,right:s.x}:null;case ls.DraggableRect:return a}},[r,a,s]),C=I.useRef(null),k=I.useCallback(()=>{const D=C.current;if(!D)return;const T=b.current.x*S.current.x,A=b.current.y*S.current.y;D.scrollBy(T,A)},[]),_=I.useMemo(()=>l===Ic.TreeOrder?[...f].reverse():f,[l,f]);I.useEffect(()=>{if(!i||!f.length||!w){y();return}for(const D of _){if((n==null?void 0:n(D))===!1)continue;const T=f.indexOf(D),A=c[T];if(!A)continue;const{direction:M,speed:E}=ege(D,A,w,e,d);for(const N of["x","y"])m[N][M[N]]||(E[N]=0,M[N]=0);if(E.x>0||E.y>0){y(),C.current=D,g(k,o),b.current=E,S.current=M;return}}b.current={x:0,y:0},S.current={x:0,y:0},y()},[e,k,n,y,i,o,JSON.stringify(w),JSON.stringify(m),g,f,_,c,JSON.stringify(d)])}const pge={x:{[l1.Backward]:!1,[l1.Forward]:!1},y:{[l1.Backward]:!1,[l1.Forward]:!1}};function mge(t){let{delta:e,disabled:r}=t;const n=Ky(e);return u9(a=>{if(r||!n||!a)return pge;const i={x:Math.sign(e.x-n.x),y:Math.sign(e.y-n.y)};return{x:{[l1.Backward]:a.x[l1.Backward]||i.x===-1,[l1.Forward]:a.x[l1.Forward]||i.x===1},y:{[l1.Backward]:a.y[l1.Backward]||i.y===-1,[l1.Forward]:a.y[l1.Forward]||i.y===1}}},[r,e,n])}function gge(t,e){const r=e!=null?t.get(e):void 0,n=r?r.node.current:null;return u9(a=>{var i;return e==null?null:(i=n??a)!=null?i:null},[n,e])}function yge(t,e){return I.useMemo(()=>t.reduce((r,n)=>{const{sensor:a}=n,i=a.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,n)}));return[...r,...i]},[]),[t,e])}var Ls;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Ls||(Ls={}));var ev;(function(t){t.Optimized="optimized"})(ev||(ev={}));const LM=new Map;function vge(t,e){let{dragging:r,dependencies:n,config:a}=e;const[i,o]=I.useState(null),{frequency:l,measure:s,strategy:f}=a,c=I.useRef(t),h=b(),d=lw(h),m=I.useCallback(function(S){S===void 0&&(S=[]),!d.current&&o(w=>w===null?S:w.concat(S.filter(C=>!w.includes(C))))},[d]),g=I.useRef(null),y=u9(S=>{if(h&&!r)return LM;if(!S||S===LM||c.current!==t||i!=null){const w=new Map;for(let C of t){if(!C)continue;if(i&&i.length>0&&!i.includes(C.id)&&C.rect.current){w.set(C.id,C.rect.current);continue}const k=C.node.current,_=k?new cw(s(k),k):null;C.rect.current=_,_&&w.set(C.id,_)}return w}return S},[t,i,r,h,s]);return I.useEffect(()=>{c.current=t},[t]),I.useEffect(()=>{h||m()},[r,h]),I.useEffect(()=>{i&&i.length>0&&o(null)},[JSON.stringify(i)]),I.useEffect(()=>{h||typeof l!="number"||g.current!==null||(g.current=setTimeout(()=>{m(),g.current=null},l))},[l,h,m,...n]),{droppableRects:y,measureDroppableContainers:m,measuringScheduled:i!=null};function b(){switch(f){case Ls.Always:return!1;case Ls.BeforeDragging:return r;default:return!r}}}function PH(t,e){return u9(r=>t?r||(typeof e=="function"?e(t):t):null,[e,t])}function bge(t,e){return PH(t,e)}function xge(t){let{callback:e,disabled:r}=t;const n=ow(e),a=I.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(n)},[n,r]);return I.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function hw(t){let{callback:e,disabled:r}=t;const n=ow(e),a=I.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(n)},[r]);return I.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function wge(t){return new cw(c9(t),t)}function NM(t,e,r){e===void 0&&(e=wge);const[n,a]=I.useState(null);function i(){a(s=>{if(!t)return null;if(t.isConnected===!1){var f;return(f=s??r)!=null?f:null}const c=e(t);return JSON.stringify(s)===JSON.stringify(c)?s:c})}const o=xge({callback(s){if(t)for(const f of s){const{type:c,target:h}=f;if(c==="childList"&&h instanceof HTMLElement&&h.contains(t)){i();break}}}}),l=hw({callback:i});return F2(()=>{i(),t?(l==null||l.observe(t),o==null||o.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),o==null||o.disconnect())},[t]),n}function Sge(t){const e=PH(t);return DH(t,e)}const IM=[];function Cge(t){const e=I.useRef(t),r=u9(n=>t?n&&n!==IM&&t&&e.current&&t.parentNode===e.current.parentNode?n:uw(t):IM,[t]);return I.useEffect(()=>{e.current=t},[t]),r}function kge(t){const[e,r]=I.useState(null),n=I.useRef(t),a=I.useCallback(i=>{const o=xm(i.target);o&&r(l=>l?(l.set(o,Zy(o)),new Map(l)):null)},[]);return I.useEffect(()=>{const i=n.current;if(t!==i){o(i);const l=t.map(s=>{const f=xm(s);return f?(f.addEventListener("scroll",a,{passive:!0}),[f,Zy(f)]):null}).filter(s=>s!=null);r(l.length?new Map(l):null),n.current=t}return()=>{o(t),o(i)};function o(l){l.forEach(s=>{const f=xm(s);f==null||f.removeEventListener("scroll",a)})}},[a,t]),I.useMemo(()=>t.length?e?Array.from(e.values()).reduce((i,o)=>k6(i,o),Ro):LH(t):Ro,[t,e])}function PM(t,e){e===void 0&&(e=[]);const r=I.useRef(null);return I.useEffect(()=>{r.current=null},e),I.useEffect(()=>{const n=t!==Ro;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?Lc(t,r.current):Ro}function _ge(t){I.useEffect(()=>{if(!Bf)return;const e=t.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of e)r==null||r()}},t.map(e=>{let{sensor:r}=e;return r}))}function Oge(t,e){return I.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:i}=n;return r[a]=o=>{i(o,e)},r},{}),[t,e])}function RH(t){return I.useMemo(()=>t?Kme(t):null,[t])}const RM=[];function Dge(t,e){e===void 0&&(e=c9);const[r]=t,n=RH(r?xi(r):null),[a,i]=I.useState(RM);function o(){i(()=>t.length?t.map(s=>EH(s)?n:new cw(e(s),s)):RM)}const l=hw({callback:o});return F2(()=>{l==null||l.disconnect(),o(),t.forEach(s=>l==null?void 0:l.observe(s))},[t]),a}function Age(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return s9(e)?e:t}function Tge(t){let{measure:e}=t;const[r,n]=I.useState(null),a=I.useCallback(f=>{for(const{target:c}of f)if(s9(c)){n(h=>{const d=e(c);return h?{...h,width:d.width,height:d.height}:d});break}},[e]),i=hw({callback:a}),o=I.useCallback(f=>{const c=Age(f);i==null||i.disconnect(),c&&(i==null||i.observe(c)),n(c?e(c):null)},[e,i]),[l,s]=Xy(o);return I.useMemo(()=>({nodeRef:l,rect:r,setRef:s}),[r,l,s])}const Mge=[{sensor:dw,options:{}},{sensor:IH,options:{}}],Ege={current:{}},ju={draggable:{measure:TM},droppable:{measure:TM,strategy:Ls.WhileDragging,frequency:ev.Optimized},dragOverlay:{measure:c9}};class ss extends Map{get(e){var r;return e!=null&&(r=super.get(e))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:r}=e;return!r})}getNodeFor(e){var r,n;return(r=(n=this.get(e))==null?void 0:n.node.current)!=null?r:void 0}}const jge={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ss,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Nc},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ju,measureDroppableContainers:Nc,windowRect:null,measuringScheduled:!1},Lge={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Nc,draggableNodes:new Map,over:null,measureDroppableContainers:Nc},pw=I.createContext(Lge),Nge=I.createContext(jge);function Ige(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ss}}}function Pge(t,e){switch(e.type){case $1.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case $1.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case $1.DragEnd:case $1.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case $1.RegisterDroppable:{const{element:r}=e,{id:n}=r,a=new ss(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case $1.SetDroppableDisabled:{const{id:r,key:n,disabled:a}=e,i=t.droppable.containers.get(r);if(!i||n!==i.key)return t;const o=new ss(t.droppable.containers);return o.set(r,{...i,disabled:a}),{...t,droppable:{...t.droppable,containers:o}}}case $1.UnregisterDroppable:{const{id:r,key:n}=e,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const i=new ss(t.droppable.containers);return i.delete(r),{...t,droppable:{...t.droppable,containers:i}}}default:return t}}function Rge(t){let{disabled:e}=t;const{active:r,activatorEvent:n,draggableNodes:a}=I.useContext(pw),i=Ky(n),o=Ky(r==null?void 0:r.id);return I.useEffect(()=>{if(!e&&!n&&i&&o!=null){if(!_H(i)||document.activeElement===i.target)return;const l=a.get(o);if(!l)return;const{activatorNode:s,node:f}=l;if(!s.current&&!f.current)return;requestAnimationFrame(()=>{for(const c of[s.current,f.current]){if(!c)continue;const h=Ame(c);if(h){h.focus();break}}})}},[n,e,a,o,i]),null}function $ge(t,e){let{transform:r,...n}=e;return t!=null&&t.length?t.reduce((a,i)=>i({transform:a,...n}),r):r}function Bge(t){return I.useMemo(()=>({draggable:{...ju.draggable,...t==null?void 0:t.draggable},droppable:{...ju.droppable,...t==null?void 0:t.droppable},dragOverlay:{...ju.dragOverlay,...t==null?void 0:t.dragOverlay}}),[t==null?void 0:t.draggable,t==null?void 0:t.droppable,t==null?void 0:t.dragOverlay])}function Vge(t){let{activeNode:e,measure:r,initialRect:n,config:a=!0}=t;const i=I.useRef(!1),{x:o,y:l}=typeof a=="boolean"?{x:a,y:a}:a;F2(()=>{if(!o&&!l||!e){i.current=!1;return}if(i.current||!n)return;const f=e==null?void 0:e.node.current;if(!f||f.isConnected===!1)return;const c=r(f),h=DH(c,n);if(o||(h.x=0),l||(h.y=0),i.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const d=AH(f);d&&d.scrollBy({top:h.y,left:h.x})}},[e,o,l,n,r])}const $H=I.createContext({...Ro,scaleX:1,scaleY:1});var E2;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(E2||(E2={}));const Fge=I.memo(function(e){var r,n,a,i;let{id:o,accessibility:l,autoScroll:s=!0,children:f,sensors:c=Mge,collisionDetection:h=Hme,measuring:d,modifiers:m,...g}=e;const y=I.useReducer(Pge,void 0,Ige),[b,S]=y,[w,C]=Nme(),[k,_]=I.useState(E2.Uninitialized),D=k===E2.Initialized,{draggable:{active:T,nodes:A,translate:M},droppable:{containers:E}}=b,N=T!=null?A.get(T):null,Y=I.useRef({initial:null,translated:null}),ne=I.useMemo(()=>{var St;return T!=null?{id:T,data:(St=N==null?void 0:N.data)!=null?St:Ege,rect:Y}:null},[T,N]),K=I.useRef(null),[B,j]=I.useState(null),[$,V]=I.useState(null),z=lw(g,Object.values(g)),W=sw("DndDescribedBy",o),G=I.useMemo(()=>E.getEnabled(),[E]),ae=Bge(d),{droppableRects:U,measureDroppableContainers:H,measuringScheduled:R}=vge(G,{dragging:D,dependencies:[M.x,M.y],config:ae.droppable}),ee=gge(A,T),J=I.useMemo(()=>$?Jy($):null,[$]),Z=Tt(),re=bge(ee,ae.draggable.measure);Vge({activeNode:T!=null?A.get(T):null,config:Z.layoutShiftCompensation,initialRect:re,measure:ae.draggable.measure});const te=NM(ee,ae.draggable.measure,re),F=NM(ee?ee.parentElement:null),q=I.useRef({activatorEvent:null,active:null,activeNode:ee,collisionRect:null,collisions:null,droppableRects:U,draggableNodes:A,draggingNode:null,draggingNodeRect:null,droppableContainers:E,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),X=E.getNodeFor((r=q.current.over)==null?void 0:r.id),ie=Tge({measure:ae.dragOverlay.measure}),ce=(n=ie.nodeRef.current)!=null?n:ee,de=D?(a=ie.rect)!=null?a:te:null,he=!!(ie.nodeRef.current&&ie.rect),Oe=Sge(he?null:te),Ne=RH(ce?xi(ce):null),Te=Cge(D?X??ee:null),_e=Dge(Te),xe=$ge(m,{transform:{x:M.x-Oe.x,y:M.y-Oe.y,scaleX:1,scaleY:1},activatorEvent:$,active:ne,activeNodeRect:te,containerNodeRect:F,draggingNodeRect:de,over:q.current.over,overlayNodeRect:ie.rect,scrollableAncestors:Te,scrollableAncestorRects:_e,windowRect:Ne}),we=J?k6(J,M):null,ge=kge(Te),ve=PM(ge),le=PM(ge,[te]),ue=k6(xe,ve),Ce=de?Ume(de,xe):null,pe=ne&&Ce?h({active:ne,collisionRect:Ce,droppableRects:U,droppableContainers:G,pointerCoordinates:we}):null,ye=Fme(pe,"id"),[be,je]=I.useState(null),$e=he?xe:k6(xe,le),ut=qme($e,(i=be==null?void 0:be.rect)!=null?i:null,te),Ie=I.useRef(null),Ze=I.useCallback((St,tt)=>{let{sensor:Mt,options:Dt}=tt;if(K.current==null)return;const Ye=A.get(K.current);if(!Ye)return;const Lt=St.nativeEvent,Et=new Mt({active:K.current,activeNode:Ye,event:Lt,options:Dt,context:q,onAbort(He){if(!A.get(He))return;const{onDragAbort:Ge}=z.current,Rt={id:He};Ge==null||Ge(Rt),w({type:"onDragAbort",event:Rt})},onPending(He,It,Ge,Rt){if(!A.get(He))return;const{onDragPending:dr}=z.current,xr={id:He,constraint:It,initialCoordinates:Ge,offset:Rt};dr==null||dr(xr),w({type:"onDragPending",event:xr})},onStart(He){const It=K.current;if(It==null)return;const Ge=A.get(It);if(!Ge)return;const{onDragStart:Rt}=z.current,$t={activatorEvent:Lt,active:{id:It,data:Ge.data,rect:Y}};a0.unstable_batchedUpdates(()=>{Rt==null||Rt($t),_(E2.Initializing),S({type:$1.DragStart,initialCoordinates:He,active:It}),w({type:"onDragStart",event:$t}),j(Ie.current),V(Lt)})},onMove(He){S({type:$1.DragMove,coordinates:He})},onEnd:Xt($1.DragEnd),onCancel:Xt($1.DragCancel)});Ie.current=Et;function Xt(He){return async function(){const{active:Ge,collisions:Rt,over:$t,scrollAdjustedTranslate:dr}=q.current;let xr=null;if(Ge&&dr){const{cancelDrop:Mr}=z.current;xr={activatorEvent:Lt,active:Ge,collisions:Rt,delta:dr,over:$t},He===$1.DragEnd&&typeof Mr=="function"&&await Promise.resolve(Mr(xr))&&(He=$1.DragCancel)}K.current=null,a0.unstable_batchedUpdates(()=>{S({type:He}),_(E2.Uninitialized),je(null),j(null),V(null),Ie.current=null;const Mr=He===$1.DragEnd?"onDragEnd":"onDragCancel";if(xr){const Er=z.current[Mr];Er==null||Er(xr),w({type:Mr,event:xr})}})}}},[A]),Ke=I.useCallback((St,tt)=>(Mt,Dt)=>{const Ye=Mt.nativeEvent,Lt=A.get(Dt);if(K.current!==null||!Lt||Ye.dndKit||Ye.defaultPrevented)return;const Et={active:Lt};St(Mt,tt.options,Et)===!0&&(Ye.dndKit={capturedBy:tt.sensor},K.current=Dt,Ze(Mt,tt))},[A,Ze]),et=yge(c,Ke);_ge(c),F2(()=>{te&&k===E2.Initializing&&_(E2.Initialized)},[te,k]),I.useEffect(()=>{const{onDragMove:St}=z.current,{active:tt,activatorEvent:Mt,collisions:Dt,over:Ye}=q.current;if(!tt||!Mt)return;const Lt={active:tt,activatorEvent:Mt,collisions:Dt,delta:{x:ue.x,y:ue.y},over:Ye};a0.unstable_batchedUpdates(()=>{St==null||St(Lt),w({type:"onDragMove",event:Lt})})},[ue.x,ue.y]),I.useEffect(()=>{const{active:St,activatorEvent:tt,collisions:Mt,droppableContainers:Dt,scrollAdjustedTranslate:Ye}=q.current;if(!St||K.current==null||!tt||!Ye)return;const{onDragOver:Lt}=z.current,Et=Dt.get(ye),Xt=Et&&Et.rect.current?{id:Et.id,rect:Et.rect.current,data:Et.data,disabled:Et.disabled}:null,He={active:St,activatorEvent:tt,collisions:Mt,delta:{x:Ye.x,y:Ye.y},over:Xt};a0.unstable_batchedUpdates(()=>{je(Xt),Lt==null||Lt(He),w({type:"onDragOver",event:He})})},[ye]),F2(()=>{q.current={activatorEvent:$,active:ne,activeNode:ee,collisionRect:Ce,collisions:pe,droppableRects:U,draggableNodes:A,draggingNode:ce,draggingNodeRect:de,droppableContainers:E,over:be,scrollableAncestors:Te,scrollAdjustedTranslate:ue},Y.current={initial:de,translated:Ce}},[ne,ee,pe,Ce,A,ce,de,U,E,be,Te,ue]),hge({...Z,delta:M,draggingRect:Ce,pointerCoordinates:we,scrollableAncestors:Te,scrollableAncestorRects:_e});const Pt=I.useMemo(()=>({active:ne,activeNode:ee,activeNodeRect:te,activatorEvent:$,collisions:pe,containerNodeRect:F,dragOverlay:ie,draggableNodes:A,droppableContainers:E,droppableRects:U,over:be,measureDroppableContainers:H,scrollableAncestors:Te,scrollableAncestorRects:_e,measuringConfiguration:ae,measuringScheduled:R,windowRect:Ne}),[ne,ee,te,$,pe,F,ie,A,E,U,be,H,Te,_e,ae,R,Ne]),jt=I.useMemo(()=>({activatorEvent:$,activators:et,active:ne,activeNodeRect:te,ariaDescribedById:{draggable:W},dispatch:S,draggableNodes:A,over:be,measureDroppableContainers:H}),[$,et,ne,te,S,W,A,be,H]);return I.createElement(OH.Provider,{value:C},I.createElement(pw.Provider,{value:jt},I.createElement(Nge.Provider,{value:Pt},I.createElement($H.Provider,{value:ut},f)),I.createElement(Rge,{disabled:(l==null?void 0:l.restoreFocus)===!1})),I.createElement(Rme,{...l,hiddenTextDescribedById:W}));function Tt(){const St=(B==null?void 0:B.autoScrollEnabled)===!1,tt=typeof s=="object"?s.enabled===!1:s===!1,Mt=D&&!St&&!tt;return typeof s=="object"?{...s,enabled:Mt}:{enabled:Mt}}}),zge=I.createContext(null),$M="button",Hge="Draggable";function qge(t){let{id:e,data:r,disabled:n=!1,attributes:a}=t;const i=sw(Hge),{activators:o,activatorEvent:l,active:s,activeNodeRect:f,ariaDescribedById:c,draggableNodes:h,over:d}=I.useContext(pw),{role:m=$M,roleDescription:g="draggable",tabIndex:y=0}=a??{},b=(s==null?void 0:s.id)===e,S=I.useContext(b?$H:zge),[w,C]=Xy(),[k,_]=Xy(),D=Oge(o,e),T=lw(r);F2(()=>(h.set(e,{id:e,key:i,node:w,activatorNode:k,data:T}),()=>{const M=h.get(e);M&&M.key===i&&h.delete(e)}),[h,e]);const A=I.useMemo(()=>({role:m,tabIndex:y,"aria-disabled":n,"aria-pressed":b&&m===$M?!0:void 0,"aria-roledescription":g,"aria-describedby":c.draggable}),[n,m,y,b,g,c.draggable]);return{active:s,activatorEvent:l,activeNodeRect:f,attributes:A,isDragging:b,listeners:n?void 0:D,node:w,over:d,setNodeRef:C,setActivatorNodeRef:_,transform:S}}const Wge=t=>{let{transform:e}=t;return{...e,y:0}};function Uge(t,e){let r=!1;function n(a,i){if(!r){r=!0;const o=a.getCenter(),l=a.getZoom(),s=a.getBearing(),f=a.getPitch();i.jumpTo({center:o,zoom:l,bearing:s,pitch:f}),r=!1}}t.on("move",()=>{n(t,e)}),e.on("move",()=>{n(e,t)})}function Gge(t){const{height:e,width:r,mapStyles:n,center:a,zoomLevel:i}=t,[o,l]=I.useState(50),[s,f]=I.useState(!1),c=I.useRef(null),h=I.useRef(50),d=I.useRef(0),m=Bme($me(dw,{activationConstraint:{distance:0}})),g=()=>{f(!0),h.current=o,c.current&&(d.current=c.current.getBoundingClientRect().width)},y=D=>{if(!c.current||d.current===0)return;const T=D.delta.x/d.current*100,A=Math.max(0,Math.min(100,h.current+T));l(A)},b=()=>{f(!1)},S=D=>{if(s||!c.current)return;const T=c.current.getBoundingClientRect(),M=(D.clientX-T.left)/T.width*100;l(Math.max(0,Math.min(100,M)))},w=I.useRef(null),C=I.useRef(null),k=I.useRef(null),_=I.useRef(null);return I.useEffect(()=>{if(_.current&&C.current&&k.current&&r){Qr(_.current).selectAll(".maplibregl-compare").remove(),Qr(C.current).selectAll("div").remove(),Qr(k.current).selectAll("div").remove();const M=new Rf;y3.addProtocol("pmtiles",M.tile);const E=new y3.Map({container:C.current,style:n[0],center:a||[0,0],zoom:i||4}),N=new y3.Map({container:k.current,style:n[1],center:a||[0,0],zoom:i||4});N.addControl(new y3.NavigationControl({visualizePitch:!0,showZoom:!0,showCompass:!0}),"bottom-right"),E.addControl(new y3.ScaleControl,"bottom-left"),E.addControl(new y3.NavigationControl({visualizePitch:!0,showZoom:!0,showCompass:!0}),"bottom-right"),N.addControl(new y3.ScaleControl,"bottom-left"),Uge(E,N)}},[r,n,a,i]),v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:w,"aria-label":"Map area",children:v.jsx("div",{style:{width:r,height:e},children:v.jsx("div",{ref:_,className:"map maplibre-show-control relative w-full h-full",style:{inset:0},children:v.jsx(Fge,{sensors:m,modifiers:[Wge],onDragStart:g,onDragMove:y,onDragEnd:b,children:v.jsxs("div",{ref:c,style:{position:"relative",width:r,height:e,overflow:"hidden",cursor:s?"grabbing":"col-resize",userSelect:"none"},onClick:S,children:[v.jsx("div",{ref:k,className:"absolute h-full rightMap w-full",style:{position:"absolute",top:0,left:0,clipPath:`polygon(${o}% 0%, ${o}% 100%, 100% 100%, 100% 0%)`}}),v.jsx("div",{ref:C,className:"absolute h-full leftMap w-full",style:{position:"absolute",top:0,left:0,inset:0,clipPath:`polygon(0% 0%, ${o}% 0%, ${o}% 100%, 0% 100%)`}}),v.jsx(Yge,{position:o})]})})})})})}function Yge(t){const{position:e}=t,{attributes:r,listeners:n,setNodeRef:a}=qge({id:"slider-handle"});return v.jsxs("div",{ref:a,style:{position:"absolute",left:`${e}%`,top:0,bottom:0,width:"40px",transform:"translateX(-50%)",cursor:"col-resize",display:"flex",justifyContent:"center",alignItems:"center",zIndex:10,touchAction:"none"},...n,...r,children:[v.jsx("div",{className:"h-full bg-primary-blue-600 dark:bg-primary-blue-400",style:{width:"2px"}}),v.jsx("div",{className:"flex bg-primary-blue-600 dark:bg-primary-blue-400 rounded-full absolute items-center justify-center text-primary-white font-primary-white",style:{boxShadow:"inset 0 0 0 1px #fff",width:"42px",height:"42px",top:"calc(50% - 21px)",left:"0",cursor:"col-resize"},children:v.jsx(U3e,{})})]})}function BH(t){const{graphTitle:e,height:r,width:n,relativeHeight:a,sources:i,graphDescription:o,footNote:l,padding:s,backgroundColor:f=!1,graphID:c,mapStyles:h,center:d=[0,0],zoomLevel:m=3,language:g="en",minHeight:y=0,theme:b="light",ariaLabel:S,styles:w,classNames:C}=t,[k,_]=I.useState(0),[D,T]=I.useState(0),A=I.useRef(null);return I.useEffect(()=>{const M=new ResizeObserver(E=>{_(n||E[0].target.clientWidth||620),T(r||E[0].target.clientHeight||480)});return A.current&&(T(A.current.clientHeight||480),_(A.current.clientWidth||620),n||M.observe(A.current)),()=>M.disconnect()},[n,r]),v.jsx("div",{className:`${b||"light"} flex ${n?"w-fit grow-0":"w-full grow"}`,dir:g==="he"||g==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${f?f===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${g||"en"}`,C==null?void 0:C.graphContainer),style:{...(w==null?void 0:w.graphContainer)||{},...f&&f!==!0?{backgroundColor:f}:{}},id:c,"aria-label":S||`${e?`The graph shows ${e}. `:""}This is a comparison between two maps.${o?` ${o}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:f?s||"1rem":s||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[e||o?v.jsx(Zt,{styles:{title:w==null?void 0:w.title,description:w==null?void 0:w.description},classNames:{title:C==null?void 0:C.title,description:C==null?void 0:C.description},graphTitle:e,graphDescription:o,width:n}):null,v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:A,"aria-label":"map area",children:(n||k)&&(r||D)?v.jsx(Gge,{width:n||k,height:Math.max(y,r||(a?y?(n||k)*a>y?(n||k)*a:y:(n||k)*a:D)),mapStyles:h,center:d,zoomLevel:m}):null}),i||l?v.jsx(tr,{styles:{footnote:w==null?void 0:w.footnote,source:w==null?void 0:w.source},classNames:{footnote:C==null?void 0:C.footnote,source:C==null?void 0:C.source},sources:i,footNote:l,width:n}):null]})})})})}function Xge(t){const{mapStyle:e,height:r,width:n,relativeHeight:a,center:i,zoomLevel:o,minHeight:l,selectedLayer:s,layerIdList:f,excludeLayers:c}=t,[h,d]=I.useState(0),[m,g]=I.useState(0),[y,b]=I.useState(void 0),S=I.useRef(null),w=I.useRef(null),C=I.useRef(null);return I.useEffect(()=>{const k=new ResizeObserver(_=>{d(n||_[0].target.clientWidth||620),g(r||_[0].target.clientHeight||480)});return S.current&&(g(S.current.clientHeight||480),d(S.current.clientWidth||620),n||k.observe(S.current)),()=>k.disconnect()},[n,r]),I.useEffect(()=>{w.current&&h&&!C.current&&ka(e).then(k=>{b(k),Qr(w.current).selectAll("div").remove();const D=new Rf;Pi.addProtocol("pmtiles",D.tile);const T={container:w.current,style:{...k,layers:po(k.layers,[{column:"id",excludeValues:[...c,...f.filter(A=>s.indexOf(A)===-1)]}])}};i&&(T.center=i),o&&(T.zoom=o),C.current=new Pi.Map(T),C.current.addControl(new Pi.NavigationControl({visualizePitch:!0,showZoom:!0,showCompass:!0}),"bottom-right"),C.current.addControl(new Pi.ScaleControl,"bottom-left")})},[h,i,o,f,e,c,s]),I.useEffect(()=>{if(C.current)if(y){const k={...y,layers:po(y.layers,[{column:"id",excludeValues:[...c,...f.filter(_=>s.indexOf(_)===-1)]}])};C.current.setStyle(k)}else ka(e).then(k=>{const _={...k,layers:po(k.layers,[{column:"id",excludeValues:[...c,...f.filter(D=>s.indexOf(D)===-1)]}])};C.current.setStyle(_)})},[c,f,e,y,s]),v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:S,"aria-label":"Map area",children:(n||h)&&(r||m)?v.jsx("div",{style:{width:n||h,height:Math.max(l,r||(a?l?(n||h)*a>l?(n||h)*a:l:(n||h)*a:m))},children:v.jsx("div",{ref:w,className:"map maplibre-show-control w-full h-full"})}):null})}function VH(t){const{mapStyle:e,graphTitle:r,height:n,width:a,relativeHeight:i,sources:o,graphDescription:l,footNote:s,padding:f,backgroundColor:c=!1,center:h,zoomLevel:d,graphID:m,language:g="en",minHeight:y=0,theme:b="light",layerSelection:S,excludeLayers:w=[],ariaLabel:C,uiMode:k="normal",styles:_,classNames:D}=t,[T,A]=I.useState(S[0].layerID);I.useEffect(()=>{A(S[0].layerID)},[S]);const M=I.useMemo(()=>({ignoreCase:!0,ignoreAccents:!0,trim:!0}),[]);return v.jsx("div",{className:`${b||"light"} flex ${a?"w-fit grow-0":"w-full grow"}`,dir:g==="he"||g==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${c?c===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${g||"en"}`,D==null?void 0:D.graphContainer),style:{...(_==null?void 0:_.graphContainer)||{},...c&&c!==!0?{backgroundColor:c}:{}},id:m,"aria-label":C||`${r?`The graph shows ${r}. `:""}This is a map.${l?` ${l}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:c?f||"1rem":f||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||l?v.jsx(Zt,{styles:{title:_==null?void 0:_.title,description:_==null?void 0:_.description},classNames:{title:D==null?void 0:D.title,description:D==null?void 0:D.description},graphTitle:r,graphDescription:l,width:a}):null,v.jsx(s1,{options:S.map(E=>({label:E.name,value:E.layerID})),size:"sm",isClearable:!1,variant:k,isRtl:g==="he"||g==="ar",isSearchable:!0,filterOption:Z1(M),defaultValue:{label:S[0].name,value:S[0].layerID},controlShouldRenderValue:!0,onChange:E=>{E&&A(E.value)}}),v.jsx(Xge,{mapStyle:e,center:h,zoomLevel:d,width:a,height:n,relativeHeight:i,minHeight:y,selectedLayer:T,layerIdList:f1(S.map(E=>E.layerID)),excludeLayers:w}),o||s?v.jsx(tr,{styles:{footnote:_==null?void 0:_.footnote,source:_==null?void 0:_.source},classNames:{footnote:D==null?void 0:D.footnote,source:D==null?void 0:D.source},sources:o,footNote:s,width:a}):null]})})})})}function Kge(t){var ye,be,je,$e,ut,Ie,Ze,Ke,et,Pt,jt,Tt,St,tt,Mt,Dt,Ye,Lt,Et,Xt,He,It,Ge,Rt,$t,dr,xr,Mr,Er;const{data:e,width:r,height:n,showLabels:a,colors:i,colorDomain:o,radius:l,xAxisTitle:s,yAxisTitle:f,leftMargin:c,rightMargin:h,topMargin:d,bottomMargin:m,tooltip:g,onSeriesMouseOver:y,refXValues:b,refYValues:S,highlightAreaSettings:w,selectedColor:C,highlightedDataPoints:k,maxRadiusValue:_,maxXValue:D,minXValue:T,maxYValue:A,minYValue:M,onSeriesMouseClick:E,rtl:N,annotations:Y,customHighlightAreaSettings:ne,regressionLine:K,resetSelectionOnDoubleClick:B,detailsOnClick:j,noOfXTicks:$,noOfYTicks:V,labelColor:z,xSuffix:W,ySuffix:G,xPrefix:ae,yPrefix:U,styles:H,classNames:R}=t,[ee,J]=I.useState(void 0),[Z,re]=I.useState(void 0),[te,F]=I.useState(void 0),[q,X]=I.useState(void 0),ie={top:d,bottom:s?m+50:m,left:f?c+30:c,right:h},ce=e.map((it,Xe)=>({...it,id:`${Xe}`})),de=r-ie.left-ie.right,he=n-ie.top-ie.bottom,Oe=e.filter(it=>it.radius===void 0).length!==e.length?l4().domain([0,Fe(_)?(ye=Vr(e,"radius"))==null?void 0:ye.radius:_]).range([.25,l]).nice():void 0,Ne=ce.filter(it=>!Fe(it.radius)).length===0?ce:a7(ce.filter(it=>!Fe(it.radius)),"radius","desc"),Te=Fe(T)?((be=Br(e,"x"))==null?void 0:be.x)>0?0:(je=Br(e,"x"))==null?void 0:je.x:T,_e=Fe(D)?(($e=Vr(e,"x"))==null?void 0:$e.x)>0?(ut=Vr(e,"x"))==null?void 0:ut.x:0:D,xe=br().domain([Te,_e]).range([0,de]).nice(),we=Fe(M)?((Ie=Br(e,"y"))==null?void 0:Ie.y)>0?0:(Ze=Br(e,"y"))==null?void 0:Ze.y:M,ge=Fe(A)?((Ke=Vr(e,"y"))==null?void 0:Ke.y)>0?(et=Vr(e,"y"))==null?void 0:et.y:0:A,ve=br().domain([we,ge]).range([he,0]).nice(),le=xe.ticks($),ue=ve.ticks(V),Ce=i9.from(Ne.filter(it=>!Fe(it.x)&&!Fe(it.y)),it=>xe(it.x),it=>ve(it.y)).voronoi([0,0,de<0?0:de,he<0?0:he]),pe=Hx(e.filter(it=>!Fe(it.x)&&!Fe(it.y)).map(it=>[xe(it.x),ve(it.y)]));return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${ie.left},${ie.top})`,children:[v.jsx(Az,{areaSettings:w,width:de,height:he,scaleX:xe,scaleY:ve}),v.jsx(Z2,{areaSettings:ne,scaleX:xe,scaleY:ve}),v.jsxs("g",{children:[v.jsx(v1,{values:ue.filter(it=>it!==0),y:ue.filter(it=>it!==0).map(it=>ve(it)),x1:0-c,x2:de+ie.right,styles:{gridLines:(Pt=H==null?void 0:H.yAxis)==null?void 0:Pt.gridLines,labels:(jt=H==null?void 0:H.yAxis)==null?void 0:jt.labels},classNames:{gridLines:(Tt=R==null?void 0:R.yAxis)==null?void 0:Tt.gridLines,labels:(St=R==null?void 0:R.yAxis)==null?void 0:St.labels},suffix:G,prefix:U,labelType:"secondary",showGridLines:!0,labelPos:"side"}),v.jsx(Nr,{y1:ve(we<0?0:we),y2:ve(we<0?0:we),x1:0-c,x2:de+ie.right,label:_t(we<0?0:we,U,G),labelPos:{x:0,y:ve(we<0?0:we),dy:"0.33em",dx:-4},classNames:{axis:(tt=R==null?void 0:R.xAxis)==null?void 0:tt.axis,label:(Mt=R==null?void 0:R.yAxis)==null?void 0:Mt.labels},styles:{axis:(Dt=H==null?void 0:H.xAxis)==null?void 0:Dt.axis,label:{textAnchor:"end",...((Ye=H==null?void 0:H.yAxis)==null?void 0:Ye.labels)||{}}}}),v.jsx(nn,{x:0-c-15,y:he/2,style:(Lt=H==null?void 0:H.yAxis)==null?void 0:Lt.title,className:(Et=R==null?void 0:R.yAxis)==null?void 0:Et.title,text:f,rotate90:!0})]}),v.jsxs("g",{children:[v.jsx(La,{values:le.filter(it=>it!==0),x:le.filter(it=>it!==0).map(it=>xe(it)),y1:0,y2:he,styles:{gridLines:(Xt=H==null?void 0:H.xAxis)==null?void 0:Xt.gridLines,labels:(He=H==null?void 0:H.xAxis)==null?void 0:He.labels},classNames:{gridLines:(It=R==null?void 0:R.xAxis)==null?void 0:It.gridLines,labels:(Ge=R==null?void 0:R.xAxis)==null?void 0:Ge.labels},suffix:W,prefix:ae,labelType:"primary",showGridLines:!0}),v.jsx(Nr,{x1:xe(Te<0?0:Te),x2:xe(Te<0?0:Te),y1:0,y2:he,label:_t(Te<0?0:Te,ae,W),labelPos:{x:xe(Te<0?0:Te),y:he,dy:"1em",dx:0},classNames:{axis:(Rt=R==null?void 0:R.xAxis)==null?void 0:Rt.axis,label:($t=R==null?void 0:R.yAxis)==null?void 0:$t.labels},styles:{axis:(dr=H==null?void 0:H.xAxis)==null?void 0:dr.axis,label:{textAnchor:"middle",...((xr=H==null?void 0:H.yAxis)==null?void 0:xr.labels)||{}}}}),v.jsx(nn,{x:de/2,y:he+30,style:(Mr=H==null?void 0:H.xAxis)==null?void 0:Mr.title,className:(Er=R==null?void 0:R.xAxis)==null?void 0:Er.title,text:s})]}),Ne.filter(it=>!Fe(it.x)&&!Fe(it.y)).map((it,Xe)=>v.jsx("g",{children:v.jsx("path",{d:Ce.renderCell(Ne.findIndex(Vt=>Vt.id===it.id)),opacity:0,onMouseEnter:Vt=>{J(it),X(Vt.clientY),F(Vt.clientX),y&&y(it)},onMouseMove:Vt=>{J(it),X(Vt.clientY),F(Vt.clientX)},onMouseLeave:()=>{J(void 0),F(void 0),X(void 0),y&&y(void 0)},onClick:()=>{(E||j)&&(Sr(Z,it)&&B?(re(void 0),E==null||E(void 0)):(re(it),E==null||E(it)))}})},Xe)),Ne.filter(it=>!Fe(it.x)&&!Fe(it.y)).map((it,Xe)=>v.jsx("g",{children:v.jsxs("g",{opacity:C?it.color&&i[o.indexOf(`${it.color}`)]===C?1:.3:ee?ee.id===it.id?1:.3:k.length!==0?k.indexOf(it.label||"")!==-1?1:.5:1,transform:`translate(${xe(it.x)},${ve(it.y)})`,onMouseEnter:Vt=>{J(it),X(Vt.clientY),F(Vt.clientX),y&&y(it)},onMouseMove:Vt=>{J(it),X(Vt.clientY),F(Vt.clientX)},onMouseLeave:()=>{J(void 0),F(void 0),X(void 0),y&&y(void 0)},onClick:()=>{(E||j)&&(Sr(Z,it)&&B?(re(void 0),E==null||E(void 0)):(re(it),E==null||E(it)))},children:[v.jsx("circle",{cx:0,cy:0,r:Oe?Oe(it.radius||0):l,style:{fill:e.filter(Vt=>Vt.color).length===0?i[0]:it.color?i[o.indexOf(`${it.color}`)]:Qe.gray,stroke:e.filter(Vt=>Vt.color).length===0?i[0]:it.color?i[o.indexOf(`${it.color}`)]:Qe.gray,fillOpacity:.6}}),a&&!Fe(it.label)?v.jsx("text",{style:{fill:z||(e.filter(Vt=>Vt.color).length===0?i[0]:it.color?i[o.indexOf(`${it.color}`)]:Qe.gray),...(H==null?void 0:H.graphObjectValues)||{}},className:Be("graph-value text-sm",R==null?void 0:R.graphObjectValues),y:0,x:Oe?Oe(it.radius||0):l,dy:"0.33em",dx:3,children:it.label}):k.length!==0&&!Fe(it.label)&&k.indexOf(it.label)!==-1?v.jsx("text",{style:{fill:z||(e.filter(Vt=>Vt.color).length===0?i[0]:it.color?i[o.indexOf(`${it.color}`)]:Qe.gray),...(H==null?void 0:H.graphObjectValues)||{}},className:Be("graph-value text-sm",R==null?void 0:R.graphObjectValues),y:0,x:Oe?Oe(it.radius||0):l,dy:"0.33em",dx:3,children:it.label}):null]})},Xe)),b.map((it,Xe)=>v.jsx(ti,{text:it.text,color:it.color,x:xe(it.value),y1:0,y2:he,textSide:xe(it.value)>de*.75||N?"left":"right",classNames:it.classNames,styles:it.styles},Xe)),S.map((it,Xe)=>v.jsx(h1,{text:it.text,color:it.color,y:ve(it.value),x1:0,x2:de,classNames:it.classNames,styles:it.styles},Xe)),v.jsx("g",{children:Y.map((it,Xe)=>{const Vt=K2({x:it.xCoordinate?xe(it.xCoordinate)+(it.xOffset||0):0+(it.xOffset||0),y:it.yCoordinate?ve(it.yCoordinate)+(it.yOffset||0)-8:0+(it.yOffset||0)-8},{x:it.xCoordinate?xe(it.xCoordinate):0,y:it.yCoordinate?ve(it.yCoordinate):0},Fe(it.connectorRadius)?3.5:it.connectorRadius),Yt=it.showConnector?{y1:Vt.y,x1:Vt.x,y2:it.yCoordinate?ve(it.yCoordinate)+(it.yOffset||0):0+(it.yOffset||0),x2:it.xCoordinate?xe(it.xCoordinate)+(it.xOffset||0):0+(it.xOffset||0),cy:it.yCoordinate?ve(it.yCoordinate):0,cx:it.xCoordinate?xe(it.xCoordinate):0,circleRadius:Fe(it.connectorRadius)?3.5:it.connectorRadius,strokeWidth:it.showConnector===!0?2:Math.min(it.showConnector||0,1)}:void 0,at={y:it.yCoordinate?ve(it.yCoordinate)+(it.yOffset||0)-8:0+(it.yOffset||0)-8,x:N?0:it.xCoordinate?xe(it.xCoordinate)+(it.xOffset||0):0+(it.xOffset||0),width:N?it.xCoordinate?xe(it.xCoordinate)+(it.xOffset||0):0+(it.xOffset||0):de-(it.xCoordinate?xe(it.xCoordinate)+(it.xOffset||0):0+(it.xOffset||0)),maxWidth:it.maxWidth,fontWeight:it.fontWeight,align:it.align};return v.jsx(J2,{color:it.color,connectorsSettings:Yt,labelSettings:at,text:it.text,classNames:it.classNames,styles:it.styles},Xe)})}),K?v.jsx(qx,{x1:pe.b>he?(he-pe.b)/pe.m:0,x2:de,y1:pe.b>he?he:pe.b,y2:pe.m*de+pe.b,className:R==null?void 0:R.regLine,style:H==null?void 0:H.regLine,color:typeof K=="string"?K:void 0}):null]})}),ee&&g&&te&&q?v.jsx(yr,{data:ee,body:g,xPos:te,yPos:q,backgroundStyle:H==null?void 0:H.tooltip,className:R==null?void 0:R.tooltip}):null,j?v.jsx(Tr,{open:Z!==void 0,onClose:()=>{re(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(j,Z)}})}):null]})}function FH(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,showLabels:o=!1,height:l,width:s,footNote:f,colorDomain:c,colorLegendTitle:h,radius:d=5,xAxisTitle:m="X Axis",yAxisTitle:g="Y Axis",padding:y,backgroundColor:b=!1,leftMargin:S=0,rightMargin:w=10,topMargin:C=20,bottomMargin:k=50,tooltip:_,relativeHeight:D,onSeriesMouseOver:T,refXValues:A=[],refYValues:M=[],highlightAreaSettings:E=[],showColorScale:N=!0,highlightedDataPoints:Y=[],graphID:ne,maxRadiusValue:K,maxXValue:B,minXValue:j,maxYValue:$,minYValue:V,xSuffix:z="",ySuffix:W="",xPrefix:G="",yPrefix:ae="",onSeriesMouseClick:U,graphDownload:H=!1,dataDownload:R=!1,language:ee="en",showNAColor:J=!0,minHeight:Z=0,annotations:re=[],customHighlightAreaSettings:te=[],theme:F="light",regressionLine:q=!1,ariaLabel:X,resetSelectionOnDoubleClick:ie=!0,detailsOnClick:ce,noOfXTicks:de=5,noOfYTicks:he=5,labelColor:Oe,styles:Ne,classNames:Te}=t,[_e,xe]=I.useState(0),[we,ge]=I.useState(0),[ve,le]=I.useState(void 0),ue=I.useRef(null),Ce=I.useRef(null);return I.useEffect(()=>{const pe=new ResizeObserver(ye=>{xe(s||ye[0].target.clientWidth||620),ge(l||ye[0].target.clientHeight||480)});return ue.current&&(ge(ue.current.clientHeight||480),xe(ue.current.clientWidth||620),s||pe.observe(ue.current)),()=>pe.disconnect()},[s,l]),v.jsx("div",{className:`${F||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:ee==="he"||ee==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${b?b===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${ee||"en"}`,Te==null?void 0:Te.graphContainer),style:{...(Ne==null?void 0:Ne.graphContainer)||{},...b&&b!==!0?{backgroundColor:b}:{}},id:ne,ref:Ce,"aria-label":X||`${r?`The graph shows ${r}. `:""}This is a scatter plot that shows correlation between two variables.${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:b?y||"1rem":y||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||H||R?v.jsx(Zt,{styles:{title:Ne==null?void 0:Ne.title,description:Ne==null?void 0:Ne.description},classNames:{title:Te==null?void 0:Te.title,description:Te==null?void 0:Te.description},graphTitle:r,graphDescription:i,width:s,graphDownload:H?Ce.current:void 0,dataDownload:R?e.map(pe=>pe.data).filter(pe=>pe!==void 0).length>0?e.map(pe=>pe.data).filter(pe=>pe!==void 0):e.filter(pe=>pe!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[N&&e.filter(pe=>pe.color).length!==0?v.jsx(Cn,{width:s,colorLegendTitle:h,colors:n||Qe[F].categoricalColors.colors,colorDomain:c||Bt(e.filter(pe=>pe.color),"color").map(pe=>pe.color),setSelectedColor:le,showNAColor:J}):null,v.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:ue,"aria-label":"Graph area",children:(s||_e)&&(l||we)?v.jsx(Kge,{data:e,width:s||_e,height:Math.max(Z,l||(D?Z?(s||_e)*D>Z?(s||_e)*D:Z:(s||_e)*D:we)),colorDomain:e.filter(pe=>pe.color).length===0?[]:c||Bt(e.filter(pe=>pe.color),"color").map(pe=>pe.color),colors:e.filter(pe=>pe.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[F].categoricalColors.colors,xAxisTitle:m,yAxisTitle:g,refXValues:A,refYValues:M,showLabels:o,radius:d,leftMargin:S,rightMargin:w,topMargin:C,bottomMargin:k,tooltip:_,onSeriesMouseOver:T,highlightAreaSettings:E,highlightedDataPoints:e.filter(pe=>pe.label).length===0?[]:Y,selectedColor:ve,maxRadiusValue:K,maxXValue:B,minXValue:j,maxYValue:$,minYValue:V,onSeriesMouseClick:U,rtl:ee==="he"||ee==="ar",annotations:re,customHighlightAreaSettings:te,regressionLine:q,resetSelectionOnDoubleClick:ie,detailsOnClick:ce,noOfXTicks:de,noOfYTicks:he,labelColor:Oe,xSuffix:z,ySuffix:W,xPrefix:G,yPrefix:ae,styles:Ne,classNames:Te}):null})]})}),a||f?v.jsx(tr,{styles:{footnote:Ne==null?void 0:Ne.footnote,source:Ne==null?void 0:Ne.source},classNames:{footnote:Te==null?void 0:Te.footnote,source:Te==null?void 0:Te.source},sources:a,footNote:f,width:s}):null]})})})})}function Jge(t){var ae,U,H,R,ee,J,Z,re,te,F;const{data:e,width:r,height:n,showLabels:a,colors:i,colorDomain:o,radius:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,tooltip:d,onSeriesMouseOver:m,axisTitles:g,highlightedDataPoints:y,selectedColor:b,minValue:S,maxValue:w,onSeriesMouseClick:C,resetSelectionOnDoubleClick:k,detailsOnClick:_,styles:D,classNames:T}=t,[A,M]=I.useState(void 0),[E,N]=I.useState(void 0),[Y,ne]=I.useState(void 0),[K,B]=I.useState(void 0),j={top:c,bottom:h,left:s,right:f},$=r-j.left-j.right,V=n-j.top-j.bottom,z=Math.min((ae=Br(e,"y1"))==null?void 0:ae.y1,(U=Br(e,"y2"))==null?void 0:U.y2),W=Math.max((H=Vr(e,"y1"))==null?void 0:H.y1,(R=Vr(e,"y2"))==null?void 0:R.y2),G=br().domain([Fe(S)?z>0?0:z:S,Fe(w)?W>0?W:0:w]).range([V,0]).nice();return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,className:"mx-auto",direction:"ltr",children:v.jsxs("g",{transform:`translate(${j.left},${j.top})`,children:[v.jsxs("g",{children:[v.jsx(Nr,{y1:0,y2:V,x1:l,x2:l,classNames:{axis:Be("stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550",(ee=T==null?void 0:T.yAxis)==null?void 0:ee.axis)}}),v.jsx(nn,{x:l,y:V+15,style:(J=D==null?void 0:D.yAxis)==null?void 0:J.title,className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(Z=T==null?void 0:T.yAxis)==null?void 0:Z.title),text:g[0]})]}),v.jsxs("g",{children:[v.jsx(Nr,{y1:0,y2:V,x1:$-l,x2:$-l,classNames:{axis:Be("stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550",(re=T==null?void 0:T.yAxis)==null?void 0:re.axis)}}),v.jsx(nn,{x:$-l,y:V+15,style:(te=D==null?void 0:D.yAxis)==null?void 0:te.title,className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(F=T==null?void 0:T.yAxis)==null?void 0:F.title),text:g[1]})]}),e.map((q,X)=>{var ie,ce,de,he,Oe,Ne,Te,_e;return v.jsxs("g",{opacity:b?q.color&&i[o.indexOf(`${q.color}`)]===b?1:.3:A?A.label===q.label?1:.3:y.length!==0?y.indexOf(q.label)!==-1?1:.5:1,onMouseEnter:xe=>{M(q),B(xe.clientY),ne(xe.clientX),m&&m(q)},onMouseMove:xe=>{M(q),B(xe.clientY),ne(xe.clientX)},onMouseLeave:()=>{M(void 0),ne(void 0),B(void 0),m&&m(void 0)},onClick:()=>{(C||_)&&(Sr(E,q)&&k?(N(void 0),C==null||C(void 0)):(N(q),C==null||C(q)))},children:[v.jsx("circle",{cx:l,cy:G(q.y1),r:l,style:{fill:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,stroke:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,fillOpacity:.6}}),a?v.jsx("text",{style:{fill:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,textAnchor:"end",...((ie=D==null?void 0:D.yAxis)==null?void 0:ie.labels)||{}},className:Be("text-xs",(ce=T==null?void 0:T.yAxis)==null?void 0:ce.labels),y:G(q.y1),x:5,dy:"0.33em",dx:-3,children:q.label}):y.length!==0&&y.indexOf(q.label)!==-1?v.jsx("text",{style:{fill:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,textAnchor:"end",...((de=D==null?void 0:D.yAxis)==null?void 0:de.labels)||{}},className:Be("text-xs",(he=T==null?void 0:T.yAxis)==null?void 0:he.labels),y:G(q.y1),x:5,dy:"0.33em",dx:-3,children:q.label}):null,v.jsx("circle",{cx:$-l,cy:G(q.y2),r:l,style:{fill:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,stroke:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,fillOpacity:.6}}),a?v.jsx("text",{style:{fill:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,textAnchor:"start",...((Oe=D==null?void 0:D.yAxis)==null?void 0:Oe.labels)||{}},className:Be("text-xs",(Ne=T==null?void 0:T.yAxis)==null?void 0:Ne.labels),y:G(q.y2),x:$-5,dy:"0.33em",dx:3,children:q.label}):y.length!==0&&y.indexOf(q.label)!==-1?v.jsx("text",{style:{fill:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,textAnchor:"start",...((Te=D==null?void 0:D.yAxis)==null?void 0:Te.labels)||{}},className:Be("text-xs",(_e=T==null?void 0:T.yAxis)==null?void 0:_e.labels),y:G(q.y2),x:$-5,dy:"0.33em",dx:3,children:q.label}):null,v.jsx("line",{x1:l,x2:$-l,y1:G(q.y1),y2:G(q.y2),className:T==null?void 0:T.dataConnectors,style:{fill:"none",stroke:e.filter(xe=>xe.color).length===0?i[0]:q.color?i[o.indexOf(`${q.color}`)]:Qe.gray,strokeWidth:1,...D==null?void 0:D.dataConnectors}})]},X)})]})}),A&&d&&Y&&K?v.jsx(yr,{data:A,body:d,xPos:Y,yPos:K,backgroundStyle:D==null?void 0:D.tooltip,className:T==null?void 0:T.tooltip}):null,_?v.jsx(Tr,{open:E!==void 0,onClose:()=>{N(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(_,E)}})}):null]})}function zH(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,showLabels:o=!1,height:l,width:s,footNote:f,colorDomain:c,colorLegendTitle:h,radius:d=5,axisTitles:m=["",""],padding:g,backgroundColor:y=!1,leftMargin:b=50,rightMargin:S=50,topMargin:w=20,bottomMargin:C=20,tooltip:k,relativeHeight:_,onSeriesMouseOver:D,showColorScale:T=!0,highlightedDataPoints:A=[],graphID:M,minValue:E,maxValue:N,onSeriesMouseClick:Y,graphDownload:ne=!1,dataDownload:K=!1,fillContainer:B=!0,language:j="en",showNAColor:$=!0,minHeight:V=0,theme:z="light",ariaLabel:W,resetSelectionOnDoubleClick:G=!0,detailsOnClick:ae,styles:U,classNames:H}=t,[R,ee]=I.useState(0),[J,Z]=I.useState(0),[re,te]=I.useState(void 0),F=I.useRef(null),q=I.useRef(null);return I.useEffect(()=>{const X=new ResizeObserver(ie=>{ee(s||ie[0].target.clientWidth||620),Z(l||ie[0].target.clientHeight||480)});return F.current&&(Z(F.current.clientHeight||480),ee(F.current.clientWidth||620),s||X.observe(F.current)),()=>X.disconnect()},[s,l]),v.jsx("div",{className:`${z||"light"} flex ${s?"grow-0":"grow"} ${B?"w-full":"w-fit"} `,dir:j==="he"||j==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${y?y===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${j||"en"}`,H==null?void 0:H.graphContainer),style:{...(U==null?void 0:U.graphContainer)||{},...y&&y!==!0?{backgroundColor:y}:{}},id:M,ref:q,"aria-label":W||`${r?`The graph shows ${r}. `:""}This is a slope chart showing changes in data between two category or starting and ending time. Each line represents a different row in data, with lines sloping up or down to show increase or decrease over two categories or time.${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:y?g||"1rem":g||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||ne||K?v.jsx(Zt,{styles:{title:U==null?void 0:U.title,description:U==null?void 0:U.description},classNames:{title:H==null?void 0:H.title,description:H==null?void 0:H.description},graphTitle:r,graphDescription:i,width:s,graphDownload:ne?q.current:void 0,dataDownload:K?e.map(X=>X.data).filter(X=>X!==void 0).length>0?e.map(X=>X.data).filter(X=>X!==void 0):e.filter(X=>X!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[T&&e.filter(X=>X.color).length!==0?v.jsx(Cn,{width:s,colorLegendTitle:h,colors:n||Qe[z].categoricalColors.colors,colorDomain:c||Bt(e.filter(X=>X.color),"color").map(X=>X.color),setSelectedColor:te,showNAColor:$}):null,v.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:F,"aria-label":"Graph area",children:(s||R)&&(l||J)?v.jsx(Jge,{data:e.filter(X=>!Fe(X.y1)&&!Fe(X.y2)),width:s||R,height:Math.max(V,l||(_?V?(s||R)*_>V?(s||R)*_:V:(s||R)*_:J)),colorDomain:e.filter(X=>X.color).length===0?[]:c||Bt(e.filter(X=>X.color),"color").map(X=>X.color),colors:e.filter(X=>X.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[z].categoricalColors.colors,selectedColor:re,axisTitles:m,showLabels:o,radius:d,leftMargin:b,rightMargin:S,topMargin:w,bottomMargin:C,tooltip:k,onSeriesMouseOver:D,highlightedDataPoints:A,minValue:E,maxValue:N,onSeriesMouseClick:Y,resetSelectionOnDoubleClick:G,detailsOnClick:ae,styles:U,classNames:H}):null})]})}),a||f?v.jsx(tr,{styles:{footnote:U==null?void 0:U.footnote,source:U==null?void 0:U.source},classNames:{footnote:H==null?void 0:H.footnote,source:H==null?void 0:H.source},sources:a,footNote:f,width:s}):null]})})})})}function Zge(t){var ce,de,he,Oe,Ne,Te,_e,xe,we,ge,ve,le,ue,Ce;const{data:e,width:r,height:n,colors:a,dateFormat:i,noOfXTicks:o,rightMargin:l,leftMargin:s,topMargin:f,bottomMargin:c,yAxisTitle:h,tooltip:d,onSeriesMouseOver:m,highlightAreaSettings:g,refValues:y,minValue:b,maxValue:S,rtl:w,annotations:C,customHighlightAreaSettings:k,noOfYTicks:_,prefix:D,suffix:T,curveType:A,styles:M,classNames:E}=t,N=A==="linear"?yo:A==="step"?e2:A==="stepAfter"?r2:A==="stepBefore"?t2:Q0,[Y,ne]=I.useState(void 0),[K,B]=I.useState(void 0),[j,$]=I.useState(void 0),V={top:f,bottom:c,left:h?s+30:s,right:l},z=I.useRef(null),W=Ut(e.map(pe=>({...pe,date:bt(`${pe.date}`,i,new Date)})),"date"),G=g.map(pe=>({...pe,coordinates:[pe.coordinates[0]===null?null:bt(`${pe.coordinates[0]}`,i,new Date),pe.coordinates[1]===null?null:bt(`${pe.coordinates[1]}`,i,new Date)]})),ae=k.map(pe=>({...pe,coordinates:pe.coordinates.map((ye,be)=>be%2===0?bt(`${ye}`,i,new Date):ye)})),U=W[0].y.map((pe,ye)=>W.map(be=>({date:be.date,y0:ye===0?0:fr(be.y.filter((je,$e)=>$e<ye)),y1:fr(be.y.filter((je,$e)=>$e<=ye))}))),H=r-V.left-V.right,R=n-V.top-V.bottom,ee=W[0].date,J=W[W.length-1].date,Z=Fe(b)?0:b,re=Fe(S)?Math.max(...e.map(pe=>fr(pe.y)||0)):S,te=G2().domain([ee,J]).range([0,H]),F=br().domain([Z,re]).range([R,0]).nice(),q=C6().x(pe=>te(pe.date)).y0(pe=>F(pe.y0)).y1(pe=>F(pe.y1)).curve(N),X=F.ticks(_),ie=te.ticks(o);return I.useEffect(()=>{const pe=be=>{const je=W[U2(W.map($e=>$e.date),te.invert(K1(be)[0]),1)];ne(je||W[W.length-1]),m&&m(je||W[W.length-1]),$(be.clientY),B(be.clientX)},ye=()=>{ne(void 0),B(void 0),$(void 0),m&&m(void 0)};Qr(z.current).on("mousemove",pe).on("mouseout",ye)},[te,W,m]),v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${V.left},${V.top})`,children:[v.jsx(h4,{areaSettings:G,width:H,height:R,scale:te}),v.jsx(Z2,{areaSettings:ae,scaleX:te,scaleY:F}),v.jsxs("g",{children:[v.jsx(v1,{values:X.filter(pe=>pe!==0),y:X.filter(pe=>pe!==0).map(pe=>F(pe)),x1:0-s,x2:H+V.right,styles:{gridLines:(ce=M==null?void 0:M.yAxis)==null?void 0:ce.gridLines,labels:(de=M==null?void 0:M.yAxis)==null?void 0:de.labels},classNames:{gridLines:(he=E==null?void 0:E.yAxis)==null?void 0:he.gridLines,labels:(Oe=E==null?void 0:E.yAxis)==null?void 0:Oe.labels},suffix:T,prefix:D,labelType:"secondary",showGridLines:!0,labelPos:"vertical"}),v.jsx(Nr,{y1:F(Z<0?0:Z),y2:F(Z<0?0:Z),x1:0-s,x2:H+V.right,label:_t(Z<0?0:Z,D,T),labelPos:{x:0-s,dx:0,dy:re<0?"1em":-5,y:F(Z<0?0:Z)},classNames:{axis:(Ne=E==null?void 0:E.xAxis)==null?void 0:Ne.axis,label:(Te=E==null?void 0:E.yAxis)==null?void 0:Te.labels},styles:{axis:(_e=M==null?void 0:M.xAxis)==null?void 0:_e.axis,label:(xe=M==null?void 0:M.yAxis)==null?void 0:xe.labels}}),v.jsx(nn,{x:0-s-15,y:R/2,style:(we=M==null?void 0:M.yAxis)==null?void 0:we.title,className:(ge=E==null?void 0:E.yAxis)==null?void 0:ge.title,text:h,rotate90:!0})]}),v.jsx(La,{values:ie.map(pe=>Sa(pe,i)),x:ie.map(pe=>te(pe)),y1:0,y2:R,styles:{gridLines:(ve=M==null?void 0:M.xAxis)==null?void 0:ve.gridLines,labels:(le=M==null?void 0:M.xAxis)==null?void 0:le.labels},classNames:{gridLines:Be("opacity-0",(ue=E==null?void 0:E.xAxis)==null?void 0:ue.gridLines),labels:Be("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[8px] sm:text-[9px] md:text-[10px] lg:text-xs",(Ce=E==null?void 0:E.xAxis)==null?void 0:Ce.labels)},suffix:T,prefix:D,labelType:"primary",showGridLines:!0}),v.jsxs("g",{children:[U.map((pe,ye)=>v.jsx("path",{d:q(pe),style:{fill:a[ye],opacity:.8}},ye)),Y?v.jsx("line",{y1:0,y2:R,x1:te(Y.date),x2:te(Y.date),className:Be("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",E==null?void 0:E.mouseOverLine),style:M==null?void 0:M.mouseOverLine}):null]}),y?v.jsx(v.Fragment,{children:y.map((pe,ye)=>v.jsx(h1,{text:pe.text,color:pe.color,y:F(pe.value),x1:0-s,x2:H+V.right,classNames:pe.classNames,styles:pe.styles},ye))}):null,v.jsx("g",{children:C.map((pe,ye)=>{const be=K2({x:pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date))+(pe.xOffset||0):0+(pe.xOffset||0),y:pe.yCoordinate?F(pe.yCoordinate)+(pe.yOffset||0)-8:0+(pe.yOffset||0)-8},{x:pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date)):0,y:pe.yCoordinate?F(pe.yCoordinate):0},Fe(pe.connectorRadius)?3.5:pe.connectorRadius),je=pe.showConnector?{y1:be.y,x1:be.x,y2:pe.yCoordinate?F(pe.yCoordinate)+(pe.yOffset||0):0+(pe.yOffset||0),x2:pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date))+(pe.xOffset||0):0+(pe.xOffset||0),cx:pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date)):0,cy:pe.yCoordinate?F(pe.yCoordinate):0,circleRadius:Fe(pe.connectorRadius)?3.5:pe.connectorRadius,strokeWidth:pe.showConnector===!0?2:Math.min(pe.showConnector||0,1)}:void 0,$e={y:pe.yCoordinate?F(pe.yCoordinate)+(pe.yOffset||0)-8:0+(pe.yOffset||0)-8,x:w?0:pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date))+(pe.xOffset||0):0+(pe.xOffset||0),width:w?pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date))+(pe.xOffset||0):0+(pe.xOffset||0):H-(pe.xCoordinate?te(bt(`${pe.xCoordinate}`,i,new Date))+(pe.xOffset||0):0+(pe.xOffset||0)),maxWidth:pe.maxWidth,fontWeight:pe.fontWeight,align:pe.align};return v.jsx(J2,{color:pe.color,connectorsSettings:je,labelSettings:$e,text:pe.text,classNames:pe.classNames,styles:pe.styles},ye)})}),v.jsx("rect",{ref:z,style:{fill:"none",pointerEvents:"all"},width:H,height:R})]})}),Y&&d&&K&&j?v.jsx(yr,{data:Y,body:d,xPos:K,yPos:j,backgroundStyle:M==null?void 0:M.tooltip,className:E==null?void 0:E.tooltip}):null]})}function HH(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,sources:a,graphDescription:i,height:o,width:l,footNote:s,noOfXTicks:f=10,dateFormat:c="yyyy",colorDomain:h,padding:d,backgroundColor:m=!1,colorLegendTitle:g,leftMargin:y=50,rightMargin:b=20,topMargin:S=20,bottomMargin:w=25,highlightAreaSettings:C=[],tooltip:k,relativeHeight:_,onSeriesMouseOver:D,refValues:T=[],graphID:A,minValue:M,maxValue:E,graphDownload:N=!1,dataDownload:Y=!1,showColorScale:ne=!0,language:K="en",minHeight:B=0,annotations:j=[],customHighlightAreaSettings:$=[],theme:V="light",ariaLabel:z,yAxisTitle:W,noOfYTicks:G=5,prefix:ae="",suffix:U="",curveType:H="curve",styles:R,classNames:ee}=t,[J,Z]=I.useState(0),[re,te]=I.useState(0),F=I.useRef(null),q=I.useRef(null);return I.useEffect(()=>{const X=new ResizeObserver(ie=>{Z(l||ie[0].target.clientWidth||620),te(o||ie[0].target.clientHeight||480)});return F.current&&(te(F.current.clientHeight||480),Z(F.current.clientWidth||620),l||X.observe(F.current)),()=>X.disconnect()},[l,o]),v.jsx("div",{className:`${V||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:K==="he"||K==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${m?m===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${K||"en"}`,ee==null?void 0:ee.graphContainer),style:{...(R==null?void 0:R.graphContainer)||{},...m&&m!==!0?{backgroundColor:m}:{}},id:A,ref:q,"aria-label":z||`${r?`The graph shows ${r}. `:""}This is a stacked area chart that shows trends over time.${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:m?d||"1rem":d||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||N||Y?v.jsx(Zt,{styles:{title:R==null?void 0:R.title,description:R==null?void 0:R.description},classNames:{title:ee==null?void 0:ee.title,description:ee==null?void 0:ee.description},graphTitle:r,graphDescription:i,width:l,graphDownload:N?q.current:void 0,dataDownload:Y?e.map(X=>X.data).filter(X=>X!==void 0).length>0?e.map(X=>X.data).filter(X=>X!==void 0):e.filter(X=>X!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[ne!==!1?v.jsx(g0,{colorDomain:h,colors:n,colorLegendTitle:g,showNAColor:!1}):null,v.jsx("div",{className:"w-full grow leading-0",ref:F,"aria-label":"Graph area",children:(l||J)&&(o||re)?v.jsx(Zge,{data:e,colors:n,width:l||J,height:Math.max(B,o||(_?B?(l||J)*_>B?(l||J)*_:B:(l||J)*_:re)),dateFormat:c,noOfXTicks:f,leftMargin:y,rightMargin:b,topMargin:S,bottomMargin:w,tooltip:k,onSeriesMouseOver:D,highlightAreaSettings:C,refValues:T,minValue:M,maxValue:E,rtl:K==="he"||K==="ar",annotations:j,customHighlightAreaSettings:$,yAxisTitle:W,noOfYTicks:G,prefix:ae,suffix:U,curveType:H,styles:R,classNames:ee}):null})]})}),a||s?v.jsx(tr,{styles:{footnote:R==null?void 0:R.footnote,source:R==null?void 0:R.source},classNames:{footnote:ee==null?void 0:ee.footnote,source:ee==null?void 0:ee.source},sources:a,footNote:s,width:l}):null]})})})})}function Qge(t){const{year:e,value:r,graphTitle:n,suffix:a="",sources:i,prefix:o="",graphDescription:l,footNote:s,padding:f,backgroundColor:c=!1,graphID:h,language:d="en",theme:m="light",ariaLabel:g,textBackground:y=!1,headingFontSize:b="4.375rem",centerAlign:S=!1,verticalAlign:w="center",styles:C,classNames:k}=t;return v.jsx("div",{className:`${m||"light"} flex w-full`,dir:d==="he"||d==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${c?c===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}flex flex-col w-full h-inherit ${d||"en"}`,k==null?void 0:k.graphContainer),style:{...(C==null?void 0:C.graphContainer)||{},...c&&c!==!0?{backgroundColor:c}:{}},id:h,"aria-label":g||`${n?`The graph shows ${n}. `:""}This is a statistic card.${l?` ${l}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:c?f||"1rem":f||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-12 justify-between grow",children:[n||l?v.jsx(Zt,{styles:{title:C==null?void 0:C.title,description:C==null?void 0:C.description},classNames:{title:k==null?void 0:k.title,description:k==null?void 0:k.description},graphTitle:n,graphDescription:l}):null,v.jsx("div",{className:`flex flex-col justify-between grow ${w==="top"?"justify-start":w==="bottom"?"justify-end":"justify-center"}`,children:v.jsxs(rP,{marginBottom:"base",className:`leading-none text-outline font-heading ${S?"text-center":d==="he"||d==="ar"?"text-right":"text-left"} ${y?"text-primary-black dark:text-primary-white":"transparent"}`,style:{fontSize:b,letterSpacing:"0.05rem"},children:[typeof r=="string"?`${o}${r}${a}`:_t(r,o,a)," ",e?v.jsxs("span",{className:"text-lg font-normal mt-0 mb-4 text-primary-gray-550 dark:text-primary-gray-400",style:{marginLeft:"-8px",lineHeight:"1.09",textShadow:"none",WebkitTextStrokeWidth:0},children:["(",e,")"]}):null]})}),i||s?v.jsx(tr,{styles:{footnote:C==null?void 0:C.footnote,source:C==null?void 0:C.source},classNames:{footnote:k==null?void 0:k.footnote,source:k==null?void 0:k.source},sources:i,footNote:s}):null]})})})})}function qH(t){var T,A;const{year:e,data:r,graphTitle:n,suffix:a="",sources:i,prefix:o="",graphDescription:l,footNote:s,padding:f,backgroundColor:c=!1,graphID:h,aggregationMethod:d="count",language:m="en",countOnly:g,theme:y="light",ariaLabel:b,textBackground:S=!1,headingFontSize:w="4.375rem",centerAlign:C=!1,verticalAlign:k="center",styles:_,classNames:D}=t;return v.jsx("div",{className:`${y||"light"} flex w-full`,dir:m==="he"||m==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${c?c===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}flex flex-col w-full h-inherit ${m||"en"}`,D==null?void 0:D.graphContainer),style:{...(_==null?void 0:_.graphContainer)||{},...c&&c!==!0?{backgroundColor:c}:{}},id:h,"aria-label":b||`${n?`The graph shows ${n}. `:""}This is a statistic card.${l?` ${l}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:c?f||"1rem":f||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-12 justify-between grow",children:[n||l?v.jsx(Zt,{styles:{title:_==null?void 0:_.title,description:_==null?void 0:_.description},classNames:{title:D==null?void 0:D.title,description:D==null?void 0:D.description},graphTitle:n,graphDescription:l}):null,v.jsx("div",{className:`flex flex-col justify-between grow ${k==="top"?"justify-start":k==="bottom"?"justify-end":"justify-center"}`,children:v.jsxs(rP,{marginBottom:"base",className:`leading-none text-outline font-heading ${C?"text-center":m==="he"||m==="ar"?"text-right":"text-left"} ${S?"text-primary-black dark:text-primary-white":"transparent"}`,style:{fontSize:w,letterSpacing:"0.05rem"},children:[r.filter(M=>typeof M.value=="string").length>0||d==="count"?g&&(g==null?void 0:g.length)!==0?r.filter(M=>g.indexOf(M.value)!==-1).length:r.length:_t(d==="sum"?fr(r.map(M=>M.value)):d==="average"?parseFloat((fr(r.map(M=>M.value))/r.length).toFixed(2)):d==="max"?(T=Vr(r,M=>M.value))==null?void 0:T.value:(A=Br(r,M=>M.value))==null?void 0:A.value,o,a)," ",e?v.jsxs("span",{className:"text-lg font-normal mt-0 mb-4 text-primary-gray-550 dark:text-primary-gray-400",style:{marginLeft:"-8px",lineHeight:"1.09",textShadow:"none",WebkitTextStrokeWidth:0},children:["(",e,")"]}):null]})}),i||s?v.jsx(tr,{styles:{footnote:_==null?void 0:_.footnote,source:_==null?void 0:_.source},classNames:{footnote:D==null?void 0:D.footnote,source:D==null?void 0:D.source},sources:i,footNote:s}):null]})})})})}function eye(t){var e=0,r=t.children,n=r&&r.length;if(!n)e=1;else for(;--n>=0;)e+=r[n].value;t.value=e}function tye(){return this.eachAfter(eye)}function rye(t,e){let r=-1;for(const n of this)t.call(e,n,++r,this);return this}function nye(t,e){for(var r=this,n=[r],a,i,o=-1;r=n.pop();)if(t.call(e,r,++o,this),a=r.children)for(i=a.length-1;i>=0;--i)n.push(a[i]);return this}function aye(t,e){for(var r=this,n=[r],a=[],i,o,l,s=-1;r=n.pop();)if(a.push(r),i=r.children)for(o=0,l=i.length;o<l;++o)n.push(i[o]);for(;r=a.pop();)t.call(e,r,++s,this);return this}function iye(t,e){let r=-1;for(const n of this)if(t.call(e,n,++r,this))return n}function oye(t){return this.eachAfter(function(e){for(var r=+t(e.data)||0,n=e.children,a=n&&n.length;--a>=0;)r+=n[a].value;e.value=r})}function lye(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})}function sye(t){for(var e=this,r=uye(e,t),n=[e];e!==r;)e=e.parent,n.push(e);for(var a=n.length;t!==r;)n.splice(a,0,t),t=t.parent;return n}function uye(t,e){if(t===e)return t;var r=t.ancestors(),n=e.ancestors(),a=null;for(t=r.pop(),e=n.pop();t===e;)a=t,t=r.pop(),e=n.pop();return a}function cye(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e}function fye(){return Array.from(this)}function dye(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t}function hye(){var t=this,e=[];return t.each(function(r){r!==t&&e.push({source:r.parent,target:r})}),e}function*pye(){var t=this,e,r=[t],n,a,i;do for(e=r.reverse(),r=[];t=e.pop();)if(yield t,n=t.children)for(a=0,i=n.length;a<i;++a)r.push(n[a]);while(r.length)}function WH(t,e){t instanceof Map?(t=[void 0,t],e===void 0&&(e=yye)):e===void 0&&(e=gye);for(var r=new Ns(t),n,a=[r],i,o,l,s;n=a.pop();)if((o=e(n.data))&&(s=(o=Array.from(o)).length))for(n.children=o,l=s-1;l>=0;--l)a.push(i=o[l]=new Ns(o[l])),i.parent=n,i.depth=n.depth+1;return r.eachBefore(UH)}function mye(){return WH(this).eachBefore(vye)}function gye(t){return t.children}function yye(t){return Array.isArray(t)?t[1]:null}function vye(t){t.data.value!==void 0&&(t.value=t.data.value),t.data=t.data.data}function UH(t){var e=0;do t.height=e;while((t=t.parent)&&t.height<++e)}function Ns(t){this.data=t,this.depth=this.height=0,this.parent=null}Ns.prototype=WH.prototype={constructor:Ns,count:tye,each:rye,eachAfter:aye,eachBefore:nye,find:iye,sum:oye,sort:lye,path:sye,ancestors:cye,descendants:fye,leaves:dye,links:hye,copy:mye,[Symbol.iterator]:pye};function Cm(t){return t==null?null:GH(t)}function GH(t){if(typeof t!="function")throw new Error;return t}function Dl(){return 0}function Al(t){return function(){return t}}function bye(t){t.x0=Math.round(t.x0),t.y0=Math.round(t.y0),t.x1=Math.round(t.x1),t.y1=Math.round(t.y1)}function xye(t,e,r,n,a){for(var i=t.children,o,l=-1,s=i.length,f=t.value&&(n-e)/t.value;++l<s;)o=i[l],o.y0=r,o.y1=a,o.x0=e,o.x1=e+=o.value*f}var wye={depth:-1},BM={},km={};function Sye(t){return t.id}function Cye(t){return t.parentId}function kye(){var t=Sye,e=Cye,r;function n(a){var i=Array.from(a),o=t,l=e,s,f,c,h,d,m,g,y,b=new Map;if(r!=null){const S=i.map((k,_)=>_ye(r(k,_,a))),w=S.map(VM),C=new Set(S).add("");for(const k of w)C.has(k)||(C.add(k),S.push(k),w.push(VM(k)),i.push(km));o=(k,_)=>S[_],l=(k,_)=>w[_]}for(c=0,s=i.length;c<s;++c)f=i[c],m=i[c]=new Ns(f),(g=o(f,c,a))!=null&&(g+="")&&(y=m.id=g,b.set(y,b.has(y)?BM:m)),(g=l(f,c,a))!=null&&(g+="")&&(m.parent=g);for(c=0;c<s;++c)if(m=i[c],g=m.parent){if(d=b.get(g),!d)throw new Error("missing: "+g);if(d===BM)throw new Error("ambiguous: "+g);d.children?d.children.push(m):d.children=[m],m.parent=d}else{if(h)throw new Error("multiple roots");h=m}if(!h)throw new Error("no root");if(r!=null){for(;h.data===km&&h.children.length===1;)h=h.children[0],--s;for(let S=i.length-1;S>=0&&(m=i[S],m.data===km);--S)m.data=null}if(h.parent=wye,h.eachBefore(function(S){S.depth=S.parent.depth+1,--s}).eachBefore(UH),h.parent=null,s>0)throw new Error("cycle");return h}return n.id=function(a){return arguments.length?(t=Cm(a),n):t},n.parentId=function(a){return arguments.length?(e=Cm(a),n):e},n.path=function(a){return arguments.length?(r=Cm(a),n):r},n}function _ye(t){t=`${t}`;let e=t.length;return tv(t,e-1)&&!tv(t,e-2)&&(t=t.slice(0,-1)),t[0]==="/"?t:`/${t}`}function VM(t){let e=t.length;if(e<2)return"";for(;--e>1&&!tv(t,e););return t.slice(0,e)}function tv(t,e){if(t[e]==="/"){let r=0;for(;e>0&&t[--e]==="\\";)++r;if((r&1)===0)return!0}return!1}function Oye(t,e,r,n,a){for(var i=t.children,o,l=-1,s=i.length,f=t.value&&(a-r)/t.value;++l<s;)o=i[l],o.x0=e,o.x1=n,o.y0=r,o.y1=r+=o.value*f}var Dye=(1+Math.sqrt(5))/2;function Aye(t,e,r,n,a,i){for(var o=[],l=e.children,s,f,c=0,h=0,d=l.length,m,g,y=e.value,b,S,w,C,k,_,D;c<d;){m=a-r,g=i-n;do b=l[h++].value;while(!b&&h<d);for(S=w=b,_=Math.max(g/m,m/g)/(y*t),D=b*b*_,k=Math.max(w/D,D/S);h<d;++h){if(b+=f=l[h].value,f<S&&(S=f),f>w&&(w=f),D=b*b*_,C=Math.max(w/D,D/S),C>k){b-=f;break}k=C}o.push(s={value:b,dice:m<g,children:l.slice(c,h)}),s.dice?xye(s,r,n,a,y?n+=g*b/y:i):Oye(s,r,n,y?r+=m*b/y:a,i),y-=b,c=h}return o}const Tye=function t(e){function r(n,a,i,o,l){Aye(e,n,a,i,o,l)}return r.ratio=function(n){return t((n=+n)>1?n:1)},r}(Dye);function Mye(){var t=Tye,e=!1,r=1,n=1,a=[0],i=Dl,o=Dl,l=Dl,s=Dl,f=Dl;function c(d){return d.x0=d.y0=0,d.x1=r,d.y1=n,d.eachBefore(h),a=[0],e&&d.eachBefore(bye),d}function h(d){var m=a[d.depth],g=d.x0+m,y=d.y0+m,b=d.x1-m,S=d.y1-m;b<g&&(g=b=(g+b)/2),S<y&&(y=S=(y+S)/2),d.x0=g,d.y0=y,d.x1=b,d.y1=S,d.children&&(m=a[d.depth+1]=i(d)/2,g+=f(d)-m,y+=o(d)-m,b-=l(d)-m,S-=s(d)-m,b<g&&(g=b=(g+b)/2),S<y&&(y=S=(y+S)/2),t(d,g,y,b,S))}return c.round=function(d){return arguments.length?(e=!!d,c):e},c.size=function(d){return arguments.length?(r=+d[0],n=+d[1],c):[r,n]},c.tile=function(d){return arguments.length?(t=GH(d),c):t},c.padding=function(d){return arguments.length?c.paddingInner(d).paddingOuter(d):c.paddingInner()},c.paddingInner=function(d){return arguments.length?(i=typeof d=="function"?d:Al(+d),c):i},c.paddingOuter=function(d){return arguments.length?c.paddingTop(d).paddingRight(d).paddingBottom(d).paddingLeft(d):c.paddingTop()},c.paddingTop=function(d){return arguments.length?(o=typeof d=="function"?d:Al(+d),c):o},c.paddingRight=function(d){return arguments.length?(l=typeof d=="function"?d:Al(+d),c):l},c.paddingBottom=function(d){return arguments.length?(s=typeof d=="function"?d:Al(+d),c):s},c.paddingLeft=function(d){return arguments.length?(f=typeof d=="function"?d:Al(+d),c):f},c}function Eye(t){var ae;const{data:e,colors:r,leftMargin:n,width:a,height:i,colorDomain:o,rightMargin:l,topMargin:s,bottomMargin:f,showLabels:c,tooltip:h,onSeriesMouseOver:d,selectedColor:m,showValues:g,suffix:y,prefix:b,highlightedDataPoints:S,onSeriesMouseClick:w,resetSelectionOnDoubleClick:C,detailsOnClick:k,language:_,styles:D,classNames:T}=t,[A,M]=I.useState(void 0),[E,N]=I.useState(void 0),[Y,ne]=I.useState(void 0),[K,B]=I.useState(void 0),j={top:s,bottom:f,left:n,right:l},$=a-j.left-j.right,V=i-j.top-j.bottom,z=[{id:"root",parent:void 0,value:void 0,data:void 0},...e.map(U=>({id:U.label,value:U.size,parent:"root",data:U}))],W=kye().id(U=>U.id).parentId(U=>U.parent)(z);W.sum(U=>U.value);const G=Mye().size([$,V]).padding(2)(W);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${a}px`,height:`${i}px`,viewBox:`0 0 ${a} ${i}`,direction:"ltr",children:v.jsx("g",{transform:`translate(${j.left},${j.top})`,children:(ae=G.children)==null?void 0:ae.map((U,H)=>v.jsxs("g",{className:"undp-viz-g-with-hover",opacity:m?U.data.data.color&&r[o.indexOf(U.data.data.color)]===m?1:.3:S.length!==0?S.indexOf(U.data.id)!==-1?.85:.3:.85,transform:`translate(${U.x0},${U.y0})`,onMouseEnter:R=>{M(U.data.data),B(R.clientY),ne(R.clientX),d==null||d(U.data.data)},onClick:()=>{(w||k)&&(E===U.data.id&&C?(N(void 0),w==null||w(void 0)):(N(U.data.id),w==null||w(U.data.data)))},onMouseMove:R=>{M(U.data.data),B(R.clientY),ne(R.clientX)},onMouseLeave:()=>{M(void 0),ne(void 0),B(void 0),d&&d(void 0)},children:[v.jsx("rect",{x:0,y:0,width:U.x1-U.x0,height:U.y1-U.y0,style:{fill:e.filter(R=>R.color).length===0?r[0]:U.data.data.color?r[o.indexOf(U.data.data.color)]:Qe.gray}},H),U.x1-U.x0>50&&U.y1-U.y0>25&&(c||g)?v.jsx("foreignObject",{y:0,x:0,width:U.x1-U.x0,height:U.y1-U.y0,children:v.jsxs("div",{className:"flex flex-col gap-0.5 p-2 w-full",style:{color:Bi(e.filter(R=>R.color).length===0?r[0]:U.data.data.color?r[o.indexOf(U.data.data.color)]:Qe.gray)},children:[c?v.jsx(or,{marginBottom:"none",size:"sm",leading:"none",className:Be("w-full treemap-label",_==="ar"||_==="he"?"text-right":"text-left",T==null?void 0:T.graphObjectValues),style:{WebkitLineClamp:U.y1-U.y0>50?U.y1-U.y0>100?U.y1-U.y0>150?void 0:3:2:1,display:"-webkit-box",WebkitBoxOrient:"vertical",overflow:"hidden",color:Bi(e.filter(R=>R.color).length===0?r[0]:U.data.data.color?r[o.indexOf(U.data.data.color)]:Qe.gray),...(D==null?void 0:D.graphObjectValues)||{}},children:U.data.id}):null,g?v.jsx(or,{marginBottom:"none",size:"sm",leading:"none",className:Be("w-full font-bold treemap-value",_==="ar"||_==="he"?"text-right":"text-left",T==null?void 0:T.graphObjectValues),style:{color:Bi(e.filter(R=>R.color).length===0?r[0]:U.data.data.color?r[o.indexOf(U.data.data.color)]:Qe.gray),...(D==null?void 0:D.graphObjectValues)||{}},children:_t(U.data.value,b,y)}):null]})}):null]},H))})}),A&&h&&Y&&K?v.jsx(yr,{data:A,body:h,xPos:Y,yPos:K,backgroundStyle:D==null?void 0:D.tooltip,className:T==null?void 0:T.tooltip}):null,k?v.jsx(Tr,{open:E!==void 0,onClose:()=>{N(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(k,E)}})}):null]})}function mw(t){const{data:e,graphTitle:r,colors:n,suffix:a="",sources:i,prefix:o="",graphDescription:l,leftMargin:s=0,rightMargin:f=0,topMargin:c=0,bottomMargin:h=0,height:d,width:m,footNote:g,colorDomain:y,colorLegendTitle:b,padding:S,backgroundColor:w=!1,showLabels:C=!0,relativeHeight:k,tooltip:_,onSeriesMouseOver:D,showColorScale:T=!0,showValues:A=!0,graphID:M,highlightedDataPoints:E=[],onSeriesMouseClick:N,graphDownload:Y=!1,dataDownload:ne=!1,language:K="en",showNAColor:B=!0,minHeight:j=0,theme:$="light",ariaLabel:V,resetSelectionOnDoubleClick:z=!0,detailsOnClick:W,styles:G,classNames:ae}=t,[U,H]=I.useState(0),[R,ee]=I.useState(0),[J,Z]=I.useState(void 0),re=I.useRef(null),te=I.useRef(null);return I.useEffect(()=>{const F=new ResizeObserver(q=>{H(m||q[0].target.clientWidth||620),ee(d||q[0].target.clientHeight||480)});return re.current&&(ee(re.current.clientHeight||480),H(re.current.clientWidth||620),m||F.observe(re.current)),()=>F.disconnect()},[m,d]),v.jsx("div",{className:`${$||"light"} flex ${m?"w-fit grow-0":"w-full grow"}`,dir:K==="he"||K==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${w?w===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${K||"en"}`,ae==null?void 0:ae.graphContainer),style:{...(G==null?void 0:G.graphContainer)||{},...w&&w!==!0?{backgroundColor:w}:{}},id:M,ref:te,"aria-label":V||`${r?`The graph shows ${r}. `:""}This is a chart where data points are represented by squares, and their sizes reflect their values. ${l?` ${l}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:w?S||"1rem":S||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||l||Y||ne?v.jsx(Zt,{styles:{title:G==null?void 0:G.title,description:G==null?void 0:G.description},classNames:{title:ae==null?void 0:ae.title,description:ae==null?void 0:ae.description},graphTitle:r,graphDescription:l,width:m,graphDownload:Y?te.current:void 0,dataDownload:ne?e.map(F=>F.data).filter(F=>F!==void 0).length>0?e.map(F=>F.data).filter(F=>F!==void 0):e.filter(F=>F!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[T&&e.filter(F=>F.color).length!==0?v.jsx(Cn,{width:m,colorLegendTitle:b,colors:n||Qe[$].categoricalColors.colors,colorDomain:y||Bt(e.filter(F=>F.color),"color").map(F=>F.color),setSelectedColor:Z,showNAColor:B}):null,v.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:re,"aria-label":"Graph area",children:(m||U)&&(d||R)?v.jsx(Eye,{data:e.filter(F=>!Fe(F.size)),colors:e.filter(F=>F.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[$].categoricalColors.colors,colorDomain:e.filter(F=>F.color).length===0?[]:y||Bt(e.filter(F=>F.color),"color").map(F=>F.color),width:m||U,height:Math.max(j,d||(k?j?(m||U)*k>j?(m||U)*k:j:(m||U)*k:R)),leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,showLabels:C,showValues:A,suffix:a,prefix:o,selectedColor:J,tooltip:_,onSeriesMouseOver:D,onSeriesMouseClick:N,highlightedDataPoints:E,resetSelectionOnDoubleClick:z,detailsOnClick:W,styles:G,classNames:ae,language:K}):null})]})}),i||g?v.jsx(tr,{styles:{footnote:G==null?void 0:G.footnote,source:G==null?void 0:G.source},classNames:{footnote:ae==null?void 0:ae.footnote,source:ae==null?void 0:ae.source},sources:i,footNote:g,width:m}):null]})})})})}function YH(t){const{data:e,size:r=200,graphTitle:n,sources:a,colors:i=Qe.light.categoricalColors.colors,graphDescription:o,totalNoOfDots:l=100,unitPadding:s=3,gridSize:f=10,footNote:c,padding:h,backgroundColor:d=!1,graphID:m,graphDownload:g=!1,language:y="en",showColorScale:b=!0,showStrokeForWhiteDots:S=!0,note:w,dataDownload:C=!1,theme:k="light",width:_,height:D,minHeight:T=0,relativeHeight:A,ariaLabel:M,styles:E,classNames:N}=t,Y=fr(e.map($=>$.value)),ne=I.useRef(null),K=r/f,B=(K-s*2)/2;if(B<=0)return console.error("The size of single unit is less than or equal to zero. Check values for ((dimension / gridSize) - (padding * 2)) / 2 is not less than or equal to 0."),null;const j=[];return e.forEach(($,V)=>{const z=Math.round($.value/Y*l);for(let W=0;W<z;W+=1)j.push({color:i[V]})}),v.jsx("div",{className:`${k||"light"} flex ${_?"w-fit grow-0":"w-full grow"}`,dir:y==="he"||y==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${d?d===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${y||"en"}`,N==null?void 0:N.graphContainer),style:{...(E==null?void 0:E.graphContainer)||{},minHeight:"inherit",...d&&d!==!0?{backgroundColor:d}:{}},id:m,ref:ne,"aria-label":M||`${n?`The graph shows ${n}. `:""}${o?` ${o}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:d?h||"1rem":h||0},children:v.jsxs("div",{className:"flex flex-col gap-3 w-full grow",children:[n||o||g?v.jsx(Zt,{styles:{title:E==null?void 0:E.title,description:E==null?void 0:E.description},classNames:{title:N==null?void 0:N.title,description:N==null?void 0:N.description},graphTitle:n,graphDescription:o,width:_,graphDownload:g?ne.current:void 0,dataDownload:C?e.map($=>$.data).filter($=>$!==void 0).length>0?e.map($=>$.data).filter($=>$!==void 0):e.filter($=>$!==void 0):null}):null,w?v.jsx(tP,{marginBottom:"2xs",className:"text-primary-gray-700 dark:text-primary-gray-100 font-bold",style:{width:_?`${_}px`:"100%"},children:w}):null,v.jsxs("div",{className:"flex grow flex-col gap-4 justify-between",children:[v.jsxs("div",{children:[b?v.jsx("div",{className:"mb-4 leading-0",style:{width:_?`${_}px`:"100%"},"aria-label":"Color legend",children:v.jsx("div",{className:"flex mb-0 flex-wrap gap-x-1 gap-y-4",children:e.map(($,V)=>v.jsxs("div",{className:"flex gap-2 items-center",children:[v.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:i[V]}}),v.jsxs(or,{marginBottom:"none",size:"sm",className:"text-primary-gray-700 dark:text-primary-gray-100",children:[$.label,":"," ",v.jsx("span",{className:"font-bold",children:_t($.value)})]})]},V))})}):null,v.jsx("div",{"aria-label":"Graph area",children:v.jsx("svg",{width:`${_||r}px`,height:`${Math.max(T,D?A&&_?T?_*A>T?_*A:T:_*A:D:Math.floor((l-1)/f)*K+K/2+B+5)}px`,direction:"ltr",viewBox:`0 0 ${_||r} ${Math.max(T,D?A&&_?T?_*A>T?_*A:T:_*A:D:Math.floor((l-1)/f)*K+K/2+B+5)}`,children:v.jsx("g",{children:j.map(($,V)=>v.jsx("circle",{cx:V%f*K+K/2,cy:Math.floor(V/f)*K+K/2,style:{fill:$.color,...S?{}:{stroke:$.color},strokeWidth:1},className:($.color.toLowerCase()==="#fff"||$.color.toLowerCase()==="#ffffff"||$.color.toLowerCase()==="white")&&S?"stroke-primary-gray-400 dark:stroke-primary-gray-500":"",r:B},V))})})})]}),a||c?v.jsx(tr,{styles:{footnote:E==null?void 0:E.footnote,source:E==null?void 0:E.source},sources:a,footNote:c,width:_}):null]})]})})})})}function jye(t){const{data:e,showColumnLabels:r,leftMargin:n,rightMargin:a,truncateBy:i,width:o,height:l,topMargin:s,bottomMargin:f,tooltip:c,onSeriesMouseOver:h,suffix:d,prefix:m,showValues:g,colorDomain:y,colors:b,noDataColor:S,scaleType:w,showRowLabels:C,selectedColor:k,onSeriesMouseClick:_,resetSelectionOnDoubleClick:D,detailsOnClick:T,styles:A,classNames:M}=t,E={top:s,bottom:f,left:n,right:a},[N,Y]=I.useState(void 0),[ne,K]=I.useState(void 0),[B,j]=I.useState(void 0),[$,V]=I.useState(void 0),z=o-E.left-E.right,W=l-E.top-E.bottom,G=Bt(e,Z=>Z.column).map(Z=>Z.column),ae=Bt(e,Z=>Z.row).map(Z=>Z.row),U=Un().domain(ae).range([0,W]),H=U.bandwidth(),R=Un().domain(G).range([0,z]),ee=R.bandwidth(),J=w==="categorical"?Ys().domain(y).range(b):w==="threshold"?P2().domain(y).range(b):br().domain(y).range(b);return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{width:`${o}px`,height:`${l}px`,viewBox:`0 0 ${o} ${l}`,style:{marginLeft:"auto",marginRight:"auto"},direction:"ltr",children:[v.jsx("g",{transform:`translate(${E.left},0)`,children:r?G.map((Z,re)=>{var te,F;return v.jsx(f4,{y:0,x:R(Z),width:ee,height:E.top-5,value:`${Z}`.length<i?`${Z}`:`${`${Z}`.substring(0,i)}...`,style:(te=A==null?void 0:A.xAxis)==null?void 0:te.labels,className:(F=M==null?void 0:M.xAxis)==null?void 0:F.labels,alignment:"bottom"},re)}):null}),v.jsx("g",{transform:`translate(0,${E.top})`,children:C?ae.map((Z,re)=>{var te,F;return v.jsx(Y2,{value:`${Z}`.length<i?`${Z}`:`${`${Z}`.substring(0,i)}...`,y:U(Z),x:0,width:E.left,height:H,alignment:"right",style:(te=A==null?void 0:A.yAxis)==null?void 0:te.labels,className:(F=M==null?void 0:M.yAxis)==null?void 0:F.labels},re)}):null}),v.jsxs("g",{transform:`translate(${E.left},${E.top})`,children:[ae.map((Z,re)=>v.jsx("g",{transform:`translate(0,${U(Z)})`,children:G.map((te,F)=>v.jsx("rect",{x:R(te),y:0,width:ee,height:H,style:{fill:S},className:"stroke-1 stroke-primary-white dark:stroke-primary-gray-700"},F))},re)),e.filter(Z=>!Fe(Z.value)).map((Z,re)=>{const te=Fe(Z.value)?S:J(Z.value);return v.jsxs("g",{transform:`translate(${R(Z.column)},${U(Z.row)})`,onMouseEnter:F=>{K(Z),V(F.clientY),j(F.clientX),h&&h(Z)},onClick:()=>{(_||T)&&(Sr(N,Z)&&D?(Y(void 0),_==null||_(void 0)):(Y(Z),_==null||_(Z)))},onMouseMove:F=>{K(Z),V(F.clientY),j(F.clientX)},onMouseLeave:()=>{K(void 0),j(void 0),V(void 0),h&&h(void 0)},opacity:k?k===te?1:.3:1,children:[v.jsx("rect",{x:0,y:0,width:ee,height:H,style:{fill:te},className:"stroke-1 stroke-primary-white dark:stroke-primary-gray-700"}),g&&!Fe(Z.value)?v.jsx("foreignObject",{y:0,x:0,width:ee,height:H,children:v.jsx("div",{className:"flex flex-col justify-center items-center h-inherit p-1",children:v.jsx("p",{className:Be("text-xs text-center m-0 leading-[1.25] graph-value",M==null?void 0:M.graphObjectValues),style:{color:Bi(te),...(A==null?void 0:A.graphObjectValues)||{}},children:typeof Z.value=="string"?`${m} ${Z.value} ${d}`:_t(Z.value,m,d)})})},re):null]},re)}),ne?v.jsx("rect",{x:R(ne.column),y:U(ne.row),width:ee,height:H,style:{fill:"none",fillOpacity:0,strokeWidth:1.5},className:"stroke-primary-gray-700 dark:stroke-primary-gray-300"}):null]})]}),ne&&c&&B&&$?v.jsx(yr,{data:ne,body:c,xPos:B,yPos:$,backgroundStyle:A==null?void 0:A.tooltip,className:M==null?void 0:M.tooltip}):null,T?v.jsx(Tr,{open:N!==void 0,onClose:()=>{Y(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(T,N)}})}):null]})}function XH(t){const{colorLegendTitle:e,colorDomain:r,colors:n,width:a,className:i}=t;return v.jsxs("div",{className:Be("flex gap-0 flex-wrap justify-center leading-0",i),style:{maxWidth:a?`${a}px`:"none"},"aria-label":"Color legend",children:[e&&e!==""?v.jsx(or,{size:"sm",marginBottom:"2xs",className:"w-full text-center",children:e}):null,v.jsxs("div",{className:"flex gap-0 flex-wrap justify-center w-full min-w-[360px] leading-0",children:[v.jsx("div",{className:"h-4 mb-1 w-full min-w-[360px]",style:{background:`linear-gradient(90deg, ${n[0]} 0%, ${n[1]} 100%)`}}),v.jsxs("div",{className:"flex justify-between w-full min-w-[360px]",children:[v.jsx(or,{marginBottom:"none",size:"sm",children:_t(r[0],"","")}),v.jsx(or,{marginBottom:"none",size:"sm",children:_t(r[1],"","")})]})]})]})}function KH(t){const{colorLegendTitle:e,colorDomain:r,colors:n,setSelectedColor:a,width:i,naColor:o,className:l,showNAColor:s}=t,[f,c]=I.useState(void 0),h=o?320:360;return v.jsxs("div",{className:Be("flex flex-wrap gap-0 justify-center leading-0",l),style:{maxWidth:i?`${i}px`:"none"},"aria-label":"Color legend",children:[e&&e!==""?v.jsx(or,{size:"sm",marginBottom:"2xs",className:"w-full text-center",children:e}):null,v.jsx("svg",{width:"100%",viewBox:"0 0 360 30",style:{maxWidth:"360px"},direction:"ltr",children:v.jsxs("g",{children:[r.map((d,m)=>v.jsxs("g",{onMouseOver:()=>{c(n[m]),a(n[m])},onMouseLeave:()=>{c(void 0),a(void 0)},className:"cursor-pointer",children:[v.jsx("rect",{x:m*h/n.length+1,y:1,width:h/n.length-2,height:8,className:`stroke-1 ${f===n[m]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:n[m],...f!==n[m]?{stroke:n[m]}:{}}}),v.jsx("text",{x:(m+1)*h/n.length,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-sm",style:{textAnchor:"middle"},children:_t(d,"","")})]},m)),v.jsx("g",{children:v.jsx("rect",{onMouseOver:()=>{c(n[r.length]),a(n[r.length])},onMouseLeave:()=>{c(void 0),a(void 0)},x:r.length*h/n.length+1,y:1,width:h/n.length-2,height:8,className:`cursor-pointer stroke-1 ${f===n[r.length]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:n[r.length],...f!==n[r.length]?{stroke:n[r.length]}:{}}})}),s?v.jsxs("g",{onMouseOver:()=>{c(o||"#D4D6D8"),a(o||"#D4D6D8")},onMouseLeave:()=>{c(void 0),a(void 0)},className:"cursor-pointer",children:[v.jsx("rect",{x:335,y:1,width:24,height:8,className:`stroke-1 ${f===o?"stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:o||"#D4D6D8",...f!==o?{stroke:o}:{},strokeWidth:1}}),v.jsx("text",{x:337.5,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-sm",style:{textAnchor:"start"},children:"NA"})]}):null]})})]})}function JH(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,showColumnLabels:o=!0,leftMargin:l=100,rightMargin:s=10,truncateBy:f=999,height:c,width:h,scaleType:d,colorDomain:m,footNote:g,colorLegendTitle:y,padding:b,backgroundColor:S=!1,topMargin:w=30,bottomMargin:C=10,tooltip:k,onSeriesMouseOver:_,suffix:D="",prefix:T="",showRowLabels:A=!0,relativeHeight:M,showValues:E,graphID:N,noDataColor:Y=Qe.gray,showColorScale:ne=!0,onSeriesMouseClick:K,graphDownload:B=!1,dataDownload:j=!1,fillContainer:$=!0,language:V="en",showNAColor:z=!0,minHeight:W=0,theme:G="light",ariaLabel:ae,resetSelectionOnDoubleClick:U=!0,detailsOnClick:H,styles:R,classNames:ee}=t,[J,Z]=I.useState(0),[re,te]=I.useState(0),[F,q]=I.useState(void 0),X=I.useRef(null),ie=I.useRef(null);I.useEffect(()=>{const de=new ResizeObserver(he=>{Z(h||he[0].target.clientWidth||620),te(c||he[0].target.clientHeight||480)});return X.current&&(te(X.current.clientHeight||480),Z(X.current.clientWidth||620),h||de.observe(X.current)),()=>de.disconnect()},[h,c]);const ce=d||(typeof m[0]=="string"?"categorical":m.length===2?"linear":"threshold");return v.jsx("div",{className:`${G||"light"} flex ${h?"grow-0":"grow"} ${$?"w-full":"w-fit"}`,dir:V==="he"||V==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${S?S===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${V||"en"}`,ee==null?void 0:ee.graphContainer),style:{...(R==null?void 0:R.graphContainer)||{},...S&&S!==!0?{backgroundColor:S}:{}},id:N,ref:ie,"aria-label":ae||`${r?`The graph shows ${r}. `:""}This is a heatmap. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:S?b||"1rem":b||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||B||j?v.jsx(Zt,{styles:{title:R==null?void 0:R.title,description:R==null?void 0:R.description},classNames:{title:ee==null?void 0:ee.title,description:ee==null?void 0:ee.description},graphTitle:r,graphDescription:i,width:h,graphDownload:B?ie.current:void 0,dataDownload:j?e.map(de=>de.data).filter(de=>de!==void 0).length>0?e.map(de=>de.data).filter(de=>de!==void 0):e.filter(de=>de!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[ne?ce==="categorical"?v.jsx(Cn,{width:$?void 0:h,colorLegendTitle:y,colors:n||(typeof m[0]=="string"?Qe[G].categoricalColors.colors:m.length===2?[Qe[G].sequentialColors.neutralColorsx09[0],Qe[G].sequentialColors.neutralColorsx09[8]]:Qe[G].sequentialColors[`neutralColorsx0${m.length+1}`]),colorDomain:m.map(de=>`${de}`),setSelectedColor:q,showNAColor:z}):ce==="threshold"?v.jsx(KH,{width:$?void 0:h,colorLegendTitle:y,colors:n||(typeof m[0]=="string"?Qe[G].categoricalColors.colors:m.length===2?[Qe[G].sequentialColors.neutralColorsx09[0],Qe[G].sequentialColors.neutralColorsx09[8]]:Qe[G].sequentialColors[`neutralColorsx0${m.length+1}`]),colorDomain:m,setSelectedColor:q,naColor:Y,showNAColor:z}):v.jsx(XH,{width:$?void 0:h,colorLegendTitle:y,colors:n||[Qe[G].sequentialColors.neutralColorsx09[0],Qe[G].sequentialColors.neutralColorsx09[8]],colorDomain:m}):null,v.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:X,"aria-label":"Graph area",children:(h||J)&&(c||re)?v.jsx(jye,{data:e,colorDomain:m,width:h||J,colors:n||(typeof m[0]=="string"?Qe[G].categoricalColors.colors:m.length===2?[Qe[G].sequentialColors.neutralColorsx09[0],Qe[G].sequentialColors.neutralColorsx09[8]]:Qe[G].sequentialColors[`neutralColorsx0${m.length+1}`]),noDataColor:Y,scaleType:ce,height:Math.max(W,c||(M?W?(h||J)*M>W?(h||J)*M:W:(h||J)*M:re)),showColumnLabels:o,leftMargin:l,rightMargin:s,topMargin:w,bottomMargin:C,selectedColor:F,truncateBy:f,showRowLabels:A,tooltip:k,onSeriesMouseOver:_,showValues:E,suffix:D,prefix:T,onSeriesMouseClick:K,resetSelectionOnDoubleClick:U,detailsOnClick:H,styles:R,classNames:ee}):null})]})}),a||g?v.jsx(tr,{styles:{footnote:R==null?void 0:R.footnote,source:R==null?void 0:R.source},classNames:{footnote:ee==null?void 0:ee.footnote,source:ee==null?void 0:ee.source},sources:a,footNote:g,width:h}):null]})})})})}const FM=t=>t.map(n=>n||1).reduce((n,a)=>n+a,0);function ZH(t){var $;const{width:e,height:r,graphTitle:n,sources:a,graphDescription:i,footNote:o,graphID:l,data:s,columnData:f,onSeriesMouseClick:c,language:h="en",theme:d="light",ariaLabel:m,backgroundColor:g=!1,padding:y,resetSelectionOnDoubleClick:b=!0,styles:S,classNames:w}=t,[C,k]=I.useState(void 0),[_,D]=I.useState(void 0),[T,A]=I.useState("asc"),[M,E]=I.useState(void 0),[N,Y]=I.useState({}),[ne,K]=I.useState(f.filter(V=>V.filterOptions&&V.filterOptions.length>0).map(V=>({id:V.columnId,option:V.filterOptions}))),[B,j]=I.useState(s);return I.useEffect(()=>{const V=[];s.forEach(z=>{let W=!0;ne.forEach(G=>{if(typeof z[G.id]!="object"&&typeof z[G.id]!="function"&&typeof z[G.id]!="symbol")if(f[f.findIndex(ae=>ae.columnId===G.id)].separator){const ae=z[G.id].split(f[f.findIndex(U=>U.columnId===G.id)].separator);K3(ae,G.option).length===0&&(W=!1)}else G.option.indexOf(z[G.id])===-1&&(W=!1)}),W&&V.push(z)}),j(C&&s?T==="asc"?Ut(V,[C]):Ut(V,[C]).reverse():V)},[C,T,s,ne,f]),v.jsx("div",{className:`${d||"light"} flex ${e?"w-fit grow-0":"w-full grow"}`,dir:h==="he"||h==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${g?g===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${h||"en"}`,w==null?void 0:w.graphContainer),style:{...(S==null?void 0:S.graphContainer)||{},...g&&g!==!0?{backgroundColor:g}:{}},id:l,"aria-label":m||`${n?`The graph shows ${n}. `:""}This is an data table. ${i?` ${i}`:""}`,children:v.jsxs("div",{className:"flex grow",style:{padding:g?y||"1rem":y||0},children:[v.jsxs("div",{className:"flex flex-col gap-3 w-full justify-between grow",children:[n||i?v.jsx(Zt,{styles:{title:S==null?void 0:S.title,description:S==null?void 0:S.description},classNames:{title:w==null?void 0:w.title,description:w==null?void 0:w.description},graphTitle:n,graphDescription:i,width:e}):null,v.jsx("div",{className:"grow flex flex-col justify-center",children:v.jsx("div",{className:"undp-scrollbar",style:{width:e?`${e}px`:"100%",height:r?`${r}px`:"auto"},children:s?v.jsxs("table",{className:"w-full",style:{borderCollapse:"collapse"},children:[v.jsx("thead",{className:"text-left bg-primary-gray-300 dark:bg-primary-gray-550",children:v.jsx("tr",{children:f==null?void 0:f.map((V,z)=>{var W;return v.jsx("th",{className:"text-primary-gray-700 dark:text-primary-gray-100 text-sm",style:{width:`calc(${100*(V.columnWidth||1)/FM(f.map(G=>G.columnWidth||1))}%`},children:v.jsxs("div",{className:"flex gap-2 justify-between items-center p-4",children:[v.jsx(or,{size:"sm",marginBottom:"none",className:`w-fit grow text-${V.align||"left"} font-bold`,children:V.columnTitle||V.columnId}),V.sortable?v.jsx("button",{type:"button",className:"bg-transparent cursor-pointer p-0 m-0 border-0",onClick:()=>{C===V.columnId?(T==="asc"&&A("desc"),T==="desc"&&k(void 0)):(k(V.columnId),A("asc"))},children:C===V.columnId?T==="asc"?v.jsx(H3e,{}):v.jsx(z3e,{}):v.jsx(F3e,{})}):null,V.filterOptions&&V.filterOptions.length?v.jsx("button",{type:"button",className:"bg-transparent cursor-pointer m-0 p-0 border-0",onClick:G=>{if(M===V.columnId)E(void 0);else if(G.currentTarget){E(V.columnId);const ae=G.currentTarget.getBoundingClientRect();Y({top:ae.bottom+window.scrollY,left:ae.left+window.scrollX-160<0?ae.left+window.scrollX:ae.left+window.scrollX-160,width:"10rem"})}},children:ne[ne.findIndex(G=>G.id===V.columnId)].option.length===((W=V.filterOptions)==null?void 0:W.length)?v.jsx(q3e,{}):v.jsx(W3e,{})}):null]})},z)})})}),v.jsx("tbody",{children:B==null?void 0:B.map((V,z)=>v.jsx("tr",{className:`cursor-${c?"pointer":"auto"} border-b border-b-primary-gray-400 dark:border-b-primary-gray-500 ${Sr(_,V)?"bg-primary-gray-200 dark:bg-primary-gray-600":"bg-transparent"}`,onClick:()=>{c&&(Sr(_,V)&&b?(D(void 0),c(void 0)):(D(V),c(V)))},children:f.map((W,G)=>v.jsx("td",{className:`text-primary-gray-700 dark:text-primary-gray-100 text-sm text-${W.align||"left"}`,style:{width:`calc(${100*(V.columnWidth||1)/FM(f.map(ae=>ae.columnWidth||1))}%`},children:v.jsx("div",{className:`text-primary-gray-700 dark:text-primary-gray-100 flex p-4 ${W.align==="right"?"justify-end":W.align==="center"?"justify-center":"justify-start"}`,children:typeof V[W.columnId]=="number"?v.jsx(or,{marginBottom:"none",size:"sm",className:`text-primary-gray-700 dark:text-primary-gray-100 w-fit ${W.chip?"grow-0 rounded-sm p-2":"grow rounded-none p-0"} text-${W.align||"left"} ${W.chip?W.chipColors?"":"bg-primary-gray-300 dark:bg-primary-gray-500":"bg-transparent"}`,style:{...W.chip&&W.chipColors?{backgroundColor:W.chipColors[W.chipColors.findIndex(ae=>ae.value===V[W.columnId])].color}:{}},children:_t(V[W.columnId],W.prefix,W.suffix)}):typeof V[W.columnId]=="string"?W.separator?v.jsx("div",{className:"text-primary-gray-700 dark:text-primary-gray-100 flex flex-wrap gap-2",children:V[W.columnId].split(W.separator).map((ae,U)=>v.jsx(or,{marginBottom:"none",size:"sm",className:`text-primary-gray-700 dark:text-primary-gray-100 w-fit ${W.chip?"grow-0 rounded-sm p-2":"grow rounded-none p-0"} text-${W.align||"left"} ${W.chip?W.chipColors?"":"bg-primary-gray-300 dark:bg-primary-gray-500":"bg-transparent"}`,style:{...W.chip&&W.chipColors?{backgroundColor:W.chipColors[W.chipColors.findIndex(H=>H.value===V[W.columnId])].color}:{}},children:`${W.prefix||""}${ae}${W.suffix||""}`},U))}):v.jsx(or,{marginBottom:"none",size:"sm",className:`text-primary-gray-700 dark:text-primary-gray-100 w-fit ${W.chip?"grow-0 rounded-sm p-2":"grow rounded-none p-0"} text-${W.align||"left"} ${W.chip?W.chipColors?"":"bg-primary-gray-300 dark:bg-primary-gray-500":"bg-transparent"}`,style:{...W.chip&&W.chipColors?{backgroundColor:W.chipColors[W.chipColors.findIndex(ae=>ae.value===V[W.columnId])].color}:{}},children:`${W.prefix||""}${V[W.columnId]}${W.suffix||""}`}):v.jsx("div",{children:V[W.columnId]})})},G))},z))})]}):null})}),a||o?v.jsx(tr,{styles:{footnote:S==null?void 0:S.footnote,source:S==null?void 0:S.source},classNames:{footnote:w==null?void 0:w.footnote,source:w==null?void 0:w.source},sources:a,footNote:o,width:e}):null]}),M&&v.jsx("div",{style:N,className:"absolute p-3 border z-[1000] rounded-sm bg-primary-white dark:bg-primary-gray-700 border-primary-gray-300 dark:border-primary-gray-550",children:v.jsxs("div",{className:"max-w-60",children:[v.jsx(or,{size:"sm",marginBottom:"2xs",className:"font-bold",children:"Filter data by"}),v.jsx("div",{className:"flex flex-col gap-2",children:($=f[f.findIndex(V=>V.columnId===M)].filterOptions)==null?void 0:$.map((V,z)=>v.jsx("div",{children:v.jsxs("label",{className:"undp-viz-label",children:[v.jsx("input",{type:"checkbox",className:"undp-viz-checkbox",checked:ne[ne.findIndex(W=>W.id===M)].option.indexOf(V)!==-1,onChange:()=>{const W=ne.findIndex(ae=>ae.id===M),G=[...ne[W].option];if(G.indexOf(V)!==-1){G.splice(G.indexOf(V),1);const ae=[...ne];ae[W].option=G,K(ae)}else{G.push(V);const ae=[...ne];ae[W].option=G,K(ae)}}}),V]},z)},z))})]})})]})})})}function J3(t){if(t!==void 0)return Array.isArray(t)?t.map(e=>({value:e,label:e})):{value:t,label:t}}const Lye=t=>t?Object.entries(t).map(([r,n])=>Array.isArray(n)?{" ":r,value:`"${n.join("; ")}"`}:{" ":r,value:`"${n}"`}):{},zM=(t,e,r)=>e.length===0?t:t.filter(n=>e.some(a=>{var i;return(i=n[a])==null?void 0:i.toLowerCase().includes(r.toLowerCase())}));function QH(t){const{width:e,height:r,graphTitle:n,sources:a,graphDescription:i,footNote:o,graphID:l,data:s,onSeriesMouseClick:f,language:c="en",theme:h="light",ariaLabel:d,cardTemplate:m,cardBackgroundColor:g,cardFilters:y=[],cardSortingOptions:b,cardSearchColumns:S=[],cardMinWidth:w=320,backgroundColor:C=!1,padding:k,detailsOnClick:_,allowDataDownloadOnDetail:D=!1,noOfItemsInAPage:T,uiMode:A="normal",styles:M,classNames:E}=t,[N,Y]=I.useState(s),[ne,K]=I.useState(1),[B,j]=I.useState(void 0),[$,V]=I.useState(""),[z,W]=I.useState([]),[G,ae]=I.useState(b?!b.defaultValue||b.options.findIndex(R=>R.label===b.defaultValue)===-1?b.options[0]:b.options[b.options.findIndex(R=>R.label===b.defaultValue)]:void 0),U=I.useMemo(()=>({ignoreCase:!0,ignoreAccents:!0,trim:!0}),[]);I.useEffect(()=>{ae(b?!b.defaultValue||b.options.findIndex(R=>R.label===b.defaultValue)===-1?b.options[0]:b.options[b.options.findIndex(R=>R.label===b.defaultValue)]:void 0)},[b]),I.useEffect(()=>{const R=y.map(ee=>({filter:ee.column,label:ee.label||`Filter by ${ee.column}`,singleSelect:!0,clearable:!0,defaultValue:J3(ee.defaultValue),availableValues:J0(s,ee.column).filter(J=>{var Z;return!((Z=ee.excludeValues)!=null&&Z.includes(`${J}`))}).map(J=>({value:J,label:J})),width:ee.width}));W(R)},[s,y]);const H=I.useCallback((R,ee)=>{W(J=>J.map(Z=>Z.filter===R?{...Z,value:ee}:Z))},[]);return I.useEffect(()=>{const R=s.filter(ee=>z.every(J=>J.value&&f1([J.value]).length>0?K3(f1([ee[J.filter]]),f1([J.value]).map(Z=>Z.value)).length>0:!0));Y(G?Ut(R,G==null?void 0:G.value,G==null?void 0:G.type):R)},[z,s,G]),I.useEffect(()=>{K(1)},[N,S,$]),v.jsx("div",{className:`${h||"light"} flex ${e?"w-fit grow-0":"w-full grow"}`,dir:c==="he"||c==="ar"?"rtl":void 0,children:v.jsxs("div",{className:Be(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${c||"en"}`,E==null?void 0:E.graphContainer),style:{...(M==null?void 0:M.graphContainer)||{},...C&&C!==!0?{backgroundColor:C}:{}},id:l,"aria-label":d||`${n?`The graph shows ${n}. `:""}This is an list of cards. ${i?` ${i}`:""}`,children:[v.jsx("div",{className:"flex grow",style:{padding:C?k||"1rem":k||0},children:v.jsxs("div",{className:"flex flex-col grow gap-3 w-full justify-between",children:[n||i?v.jsx(Zt,{styles:{title:M==null?void 0:M.title,description:M==null?void 0:M.description},classNames:{title:E==null?void 0:E.title,description:E==null?void 0:E.description},graphTitle:n,graphDescription:i,width:e}):null,b||z.length>0?v.jsxs("div",{className:"flex gap-4 flex-wrap items-start w-full",children:[b?v.jsxs("div",{className:"grow shrink-0 min-w-[240px]",style:{width:b.width||"calc(25% - 0.75rem)"},children:[v.jsx(or,{marginBottom:"xs",size:"sm",className:"text-primary-gray-700 dark:text-primary-gray-100",children:"Sort by"}),v.jsx(s1,{options:b.options,isRtl:c==="he"||c==="ar",isSearchable:!0,filterOption:Z1(U),onChange:R=>{ae(R||void 0)},variant:A,size:"sm",defaultValue:!b.defaultValue||b.options.findIndex(R=>R.label===b.defaultValue)===-1?b.options[0]:b.options[b.options.findIndex(R=>R.label===b.defaultValue)]})]}):null,z==null?void 0:z.map((R,ee)=>v.jsxs("div",{className:"grow shrink-0 min-w-[240px]",style:{width:R.width||"calc(25% - 0.75rem)"},children:[v.jsx(or,{marginBottom:"xs",size:"sm",className:"text-primary-gray-700 dark:text-primary-gray-100",children:R.label}),v.jsx(s1,{options:R.availableValues,isClearable:R.clearable===void 0?!0:R.clearable,isRtl:c==="he"||c==="ar",isSearchable:!0,variant:A,size:"sm",controlShouldRenderValue:!0,filterOption:Z1(U),onChange:J=>{H(R.filter,J)},defaultValue:R.defaultValue})]},ee))]}):null,S.length>0?v.jsx(cP,{placeholder:"Search...",value:$,onChange:R=>{V(R.target.value)},buttonVariant:"icon",inputVariant:A,showSearchButton:!1,inputSize:"sm"}):null,v.jsx("div",{className:"undp-scrollbar w-full my-0 mx-auto grid gap-4 undp-viz-data-cards-container",style:{width:e?`${e}px`:"100%",height:r?`${r}px`:"auto",gridTemplateColumns:`repeat(auto-fit, minmax(${w}px, 1fr))`},children:zM(N,S,$).filter((R,ee)=>T?ee<ne*T&&ee>=(ne-1)*T:!0).map((R,ee)=>v.jsx("div",{style:{...(M==null?void 0:M.dataCards)||{},...g&&{backgroundColor:g}},className:`w-full flex flex-col ${f||_?"cursor-pointer":"cursor-auto"}${g?"":"bg-primary-gray-200 dark:bg-primary-gray-600"} ${(E==null?void 0:E.dataCards)||""}`,onClick:()=>{f==null||f(R),_&&j(R)},dangerouslySetInnerHTML:{__html:Cr(m,R)}},ee))}),T?v.jsx(Hne,{total:zM(N,S,$).length,defaultPage:0,pageSize:T,onChange:K}):null,a||o?v.jsx(tr,{styles:{footnote:M==null?void 0:M.footnote,source:M==null?void 0:M.source},classNames:{footnote:E==null?void 0:E.footnote,source:E==null?void 0:E.source},sources:a,footNote:o,width:e}):null]})}),v.jsx(Tr,{open:B!==void 0,onClose:()=>{j(void 0)},children:_?v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(_,B)}}),D?v.jsx("div",{className:"flex",children:v.jsx(Vb,{csvData:Lye(B),headers:[{label:" ",key:" "},{label:"value",key:"value"}],buttonContent:v.jsxs("div",{className:"flex items-center gap-4",children:[typeof D=="string"?D:null,v.jsx(Bb,{})]})})}):null]}):null})]})})}function Nye(t){var re,te,F,q;const{data:e,width:r,height:n,colors:a,colorDomain:i,radius:o,leftMargin:l,rightMargin:s,topMargin:f,bottomMargin:c,tooltip:h,onSeriesMouseOver:d,highlightedDataPoints:m,selectedColor:g,minValue:y,maxValue:b,onSeriesMouseClick:S,showAxis:w,prefix:C,suffix:k,stripType:_,highlightColor:D,dotOpacity:T,resetSelectionOnDoubleClick:A,detailsOnClick:M,styles:E,classNames:N,valueColor:Y}=t,[ne,K]=I.useState(void 0),[B,j]=I.useState(void 0),[$,V]=I.useState(void 0),[z,W]=I.useState(void 0),G={top:f,bottom:c,left:l,right:s},ae=r-G.left-G.right,U=n-G.top-G.bottom,H=e.map((X,ie)=>({...X,id:`${ie}`})),R=Ut(H,X=>{const ie=(m||[]).indexOf(X.label);return ie===-1?1/0:ie}).reverse(),ee=Fe(b)?Math.max(...e.filter(X=>!Fe(X.position)).map(X=>X.position))<0?0:Math.max(...e.filter(X=>!Fe(X.position)).map(X=>X.position)):b,J=Fe(y)?Math.min(...e.filter(X=>!Fe(X.position)).map(X=>X.position))>=0?0:Math.min(...e.filter(X=>!Fe(X.position)).map(X=>X.position)):y,Z=br().domain([J,ee]).range([0,ae]).nice();return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${G.left},${G.top})`,children:[R.map((X,ie)=>v.jsxs("g",{className:"undp-viz-g-with-hover",transform:`translate(${Z(X.position)},${U/2})`,opacity:g?X.color&&a[i.indexOf(X.color)]===g?1:T:m.length!==0&&m.indexOf(X.label)!==-1?.85:T,onMouseEnter:ce=>{K(X),W(ce.clientY),V(ce.clientX),d&&d(X)},onClick:()=>{(S||M)&&(Sr(B,X)&&A?(j(void 0),S==null||S(void 0)):(j(X),S==null||S(X)))},onMouseMove:ce=>{K(X),W(ce.clientY),V(ce.clientX)},onMouseLeave:()=>{K(void 0),V(void 0),W(void 0),d&&d(void 0)},children:[_==="dot"?v.jsx("circle",{cy:0,cx:0,style:{fill:D&&m?m.indexOf(X.label)!==-1?D:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray},r:o}):v.jsx("rect",{y:0-o,x:-1,height:o*2,width:2,style:{fill:D&&m?m.indexOf(X.label)!==-1?D:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray}}),m.length!==0&&m.indexOf(X.label)!==-1?v.jsx("text",{x:0,y:0-o-5,style:{fill:Y||(D&&m?m.indexOf(X.label)!==-1?D:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray),textAnchor:"middle",...(E==null?void 0:E.graphObjectValues)||{}},className:Be("graph-value text-sm font-bold",N==null?void 0:N.graphObjectValues),children:_t(X.position,C,k)}):null]},ie)),w?v.jsxs(v.Fragment,{children:[v.jsx("text",{x:0,y:U/2+o,style:{textAnchor:"start",...((re=E==null?void 0:E.yAxis)==null?void 0:re.labels)||{}},className:Be("fill-primary-gray-550 dark:fill-primary-gray-500 text-xs",(te=N==null?void 0:N.yAxis)==null?void 0:te.labels),dy:"1em",children:_t(Z.invert(0),C,k)}),v.jsx("text",{x:ae,y:U/2+o,style:{textAnchor:"end",...((F=E==null?void 0:E.yAxis)==null?void 0:F.labels)||{}},className:Be("fill-primary-gray-550 dark:fill-primary-gray-500 text-xs",(q=N==null?void 0:N.yAxis)==null?void 0:q.labels),dy:"1em",children:_t(Z.invert(ae),C,k)})]}):null]})}),ne&&h&&$&&z?v.jsx(yr,{data:ne,body:h,xPos:$,yPos:z,backgroundStyle:E==null?void 0:E.tooltip,className:N==null?void 0:N.tooltip}):null,M?v.jsx(Tr,{open:B!==void 0,onClose:()=>{j(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(M,B)}})}):null]})}function Iye(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,height:o,width:l,footNote:s,colorDomain:f,colorLegendTitle:c,radius:h=5,padding:d,backgroundColor:m=!1,leftMargin:g=5,rightMargin:y=5,topMargin:b=10,bottomMargin:S=10,tooltip:w,relativeHeight:C,onSeriesMouseOver:k,showColorScale:_=!0,highlightedDataPoints:D=[],graphID:T,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N=!0,graphDownload:Y=!1,dataDownload:ne=!1,prefix:K="",suffix:B="",stripType:j="dot",language:$="en",highlightColor:V,dotOpacity:z=.3,showNAColor:W=!0,minHeight:G=0,theme:ae="light",ariaLabel:U,resetSelectionOnDoubleClick:H=!0,detailsOnClick:R,styles:ee,classNames:J,valueColor:Z}=t,[re,te]=I.useState(0),[F,q]=I.useState(0),[X,ie]=I.useState(void 0),ce=I.useRef(null),de=I.useRef(null);return I.useEffect(()=>{const he=new ResizeObserver(Oe=>{te(l||Oe[0].target.clientWidth||620),q(o||Oe[0].target.clientHeight||480)});return ce.current&&(q(ce.current.clientHeight||480),te(ce.current.clientWidth||620),l||he.observe(ce.current)),()=>he.disconnect()},[l,o]),v.jsx("div",{className:`${ae||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:$==="he"||$==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${m?m===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${$||"en"}`,J==null?void 0:J.graphContainer),style:{...(ee==null?void 0:ee.graphContainer)||{},...m&&m!==!0?{backgroundColor:m}:{}},id:T,ref:de,"aria-label":U||`${r?`The graph shows ${r}. `:""}This is a strip chart showing distribution of data along the horizontal axis. Each dot represents an individual data point, helping to visualize the spread and clustering of values.${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:m?d||"1rem":d||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||Y||ne?v.jsx(Zt,{styles:{title:ee==null?void 0:ee.title,description:ee==null?void 0:ee.description},classNames:{title:J==null?void 0:J.title,description:J==null?void 0:J.description},graphTitle:r,graphDescription:i,width:l,graphDownload:Y?de.current:void 0,dataDownload:ne?e.map(he=>he.data).filter(he=>he!==void 0).length>0?e.map(he=>he.data).filter(he=>he!==void 0):e.filter(he=>he!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[_!==!1&&e.filter(he=>he.color).length!==0?v.jsx(Cn,{width:l,colorLegendTitle:c,colors:n||Qe[ae].categoricalColors.colors,colorDomain:f||Bt(e.filter(he=>he.color),"color").map(he=>he.color),setSelectedColor:ie,showNAColor:W??!0}):null,v.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:ce,"aria-label":"Graph area",children:(l||re)&&(o||F)?v.jsx(Nye,{data:e,width:l||re,height:Math.max(G,o||(C?G?(l||re)*C>G?(l||re)*C:G:(l||re)*C:F)),colorDomain:e.filter(he=>he.color).length===0?[]:f||Bt(e.filter(he=>he.color),"color").map(he=>he.color),colors:e.filter(he=>he.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[ae].categoricalColors.colors,selectedColor:X,radius:h,leftMargin:g,rightMargin:y,topMargin:b,bottomMargin:S,tooltip:w,onSeriesMouseOver:k,highlightedDataPoints:D,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N,prefix:K,suffix:B,stripType:j,highlightColor:V,dotOpacity:z,resetSelectionOnDoubleClick:H,detailsOnClick:R,styles:ee,classNames:J,valueColor:Z}):null})]})}),a||s?v.jsx(tr,{styles:{footnote:ee==null?void 0:ee.footnote,source:ee==null?void 0:ee.source},classNames:{footnote:J==null?void 0:J.footnote,source:J==null?void 0:J.source},sources:a,footNote:s,width:l}):null]})})})})}function Pye(t){var re,te,F,q;const{data:e,width:r,height:n,colors:a,colorDomain:i,radius:o,leftMargin:l,rightMargin:s,topMargin:f,bottomMargin:c,tooltip:h,onSeriesMouseOver:d,highlightedDataPoints:m,selectedColor:g,minValue:y,maxValue:b,onSeriesMouseClick:S,showAxis:w,prefix:C,suffix:k,stripType:_,highlightColor:D,dotOpacity:T,resetSelectionOnDoubleClick:A,detailsOnClick:M,styles:E,classNames:N,valueColor:Y}=t,[ne,K]=I.useState(void 0),[B,j]=I.useState(void 0),[$,V]=I.useState(void 0),[z,W]=I.useState(void 0),G={top:f,bottom:c,left:l,right:s},ae=r-G.left-G.right,U=n-G.top-G.bottom,H=e.map((X,ie)=>({...X,id:`${ie}`})),R=Ut(H,X=>{const ie=(m||[]).indexOf(X.label);return ie===-1?1/0:ie}).reverse(),ee=Fe(b)?Math.max(...e.filter(X=>!Fe(X.position)).map(X=>X.position))<0?0:Math.max(...e.filter(X=>!Fe(X.position)).map(X=>X.position)):b,J=Fe(y)?Math.min(...e.filter(X=>!Fe(X.position)).map(X=>X.position))>=0?0:Math.min(...e.filter(X=>!Fe(X.position)).map(X=>X.position)):y,Z=br().domain([J,ee]).range([U,0]).nice();return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${G.left},${G.top})`,children:[R.map((X,ie)=>v.jsxs("g",{className:"undp-viz-g-with-hover",transform:`translate(${ae/2},${Z(X.position)})`,opacity:g?X.color&&a[i.indexOf(X.color)]===g?1:T:m.length!==0&&m.indexOf(X.label)!==-1?.85:T,onMouseEnter:ce=>{K(X),W(ce.clientY),V(ce.clientX),d&&d(X)},onClick:()=>{(S||M)&&(Sr(B,X)&&A?(j(void 0),S==null||S(void 0)):(j(X),S==null||S(X)))},onMouseMove:ce=>{K(X),W(ce.clientY),V(ce.clientX)},onMouseLeave:()=>{K(void 0),V(void 0),W(void 0),d&&d(void 0)},children:[_==="dot"?v.jsx("circle",{cy:0,cx:0,style:{fill:D&&m?m.indexOf(X.label)!==-1?D:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray},r:o}):v.jsx("rect",{x:0-o,y:-1,width:o*2,height:2,style:{fill:D&&m?m.indexOf(X.label)!==-1?D:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray}}),m.length!==0&&m.indexOf(X.label)!==-1?v.jsx("text",{y:0,dy:"0.33em",x:0+o+3,style:{fill:Y||(D&&m?m.indexOf(X.label)!==-1?D:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray:e.filter(ce=>ce.color).length===0?a[0]:X.color?a[i.indexOf(X.color)]:Qe.gray),textAnchor:"start",...(E==null?void 0:E.graphObjectValues)||{}},className:Be("graph-value text-sm font-bold",N==null?void 0:N.graphObjectValues),children:_t(X.position,C,k)}):null]},ie)),w?v.jsxs(v.Fragment,{children:[v.jsx("text",{y:0,x:ae/2+o+5,style:{textAnchor:"start",...((re=E==null?void 0:E.yAxis)==null?void 0:re.labels)||{}},className:Be("fill-primary-gray-550 dark:fill-primary-gray-500 text-xs",(te=N==null?void 0:N.yAxis)==null?void 0:te.labels),children:_t(Z.invert(0),C,k)}),v.jsx("text",{y:U,x:ae/2+o+5,style:{textAnchor:"start",...((F=E==null?void 0:E.yAxis)==null?void 0:F.labels)||{}},className:Be("fill-primary-gray-550 dark:fill-primary-gray-500 text-xs",(q=N==null?void 0:N.yAxis)==null?void 0:q.labels),children:_t(Z.invert(U),C,k)})]}):null]})}),ne&&h&&$&&z?v.jsx(yr,{data:ne,body:h,xPos:$,yPos:z,backgroundStyle:E==null?void 0:E.tooltip,className:N==null?void 0:N.tooltip}):null,M?v.jsx(Tr,{open:B!==void 0,onClose:()=>{j(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(M,B)}})}):null]})}function Rye(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,height:o,width:l,footNote:s,colorDomain:f,colorLegendTitle:c,radius:h=5,padding:d,backgroundColor:m=!1,leftMargin:g=20,rightMargin:y=20,topMargin:b=10,bottomMargin:S=10,tooltip:w,relativeHeight:C,onSeriesMouseOver:k,showColorScale:_=!0,highlightedDataPoints:D=[],graphID:T,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N=!0,graphDownload:Y=!1,dataDownload:ne=!1,prefix:K="",suffix:B="",stripType:j="dot",language:$="en",highlightColor:V,dotOpacity:z=.3,showNAColor:W=!0,minHeight:G=0,theme:ae="light",ariaLabel:U,resetSelectionOnDoubleClick:H=!0,detailsOnClick:R,styles:ee,classNames:J,valueColor:Z}=t,[re,te]=I.useState(0),[F,q]=I.useState(0),[X,ie]=I.useState(void 0),ce=I.useRef(null),de=I.useRef(null);return I.useEffect(()=>{const he=new ResizeObserver(Oe=>{te(l||Oe[0].target.clientWidth||620),q(o||Oe[0].target.clientHeight||480)});return ce.current&&(q(ce.current.clientHeight||480),te(ce.current.clientWidth||620),l||he.observe(ce.current)),()=>he.disconnect()},[l,o]),v.jsx("div",{className:`${ae||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:$==="he"||$==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${m?m===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${$||"en"}`,J==null?void 0:J.graphContainer),style:{...(ee==null?void 0:ee.graphContainer)||{},...m&&m!==!0?{backgroundColor:m}:{}},id:T,ref:de,"aria-label":U||`${r?`The graph shows ${r}. `:""}This is a strip chart showing distribution of data along the vertical axis. Each dot represents an individual data point, helping to visualize the spread and clustering of values.${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:m?d||"1rem":d||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||Y||ne?v.jsx(Zt,{styles:{title:ee==null?void 0:ee.title,description:ee==null?void 0:ee.description},classNames:{title:J==null?void 0:J.title,description:J==null?void 0:J.description},graphTitle:r,graphDescription:i,width:l,graphDownload:Y?de.current:void 0,dataDownload:ne?e.map(he=>he.data).filter(he=>he!==void 0).length>0?e.map(he=>he.data).filter(he=>he!==void 0):e.filter(he=>he!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[_!==!1&&e.filter(he=>he.color).length!==0?v.jsx(Cn,{width:l,colorLegendTitle:c,colors:n||Qe[ae].categoricalColors.colors,colorDomain:f||Bt(e.filter(he=>he.color),"color").map(he=>he.color),setSelectedColor:ie,showNAColor:W}):null,v.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:ce,children:(l||re)&&(o||F)?v.jsx(Pye,{data:e,width:l||re,height:Math.max(G,o||(C?G?(l||re)*C>G?(l||re)*C:G:(l||re)*C:F)),colorDomain:e.filter(he=>he.color).length===0?[]:f||Bt(e.filter(he=>he.color),"color").map(he=>he.color),colors:e.filter(he=>he.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[ae].categoricalColors.colors,selectedColor:X,radius:h,leftMargin:g,rightMargin:y,topMargin:b,bottomMargin:S,tooltip:w,onSeriesMouseOver:k,highlightedDataPoints:D,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N,prefix:K,suffix:B,stripType:j,highlightColor:V,dotOpacity:z,resetSelectionOnDoubleClick:H,detailsOnClick:R,styles:ee,classNames:J,valueColor:Z}):null})]})}),a||s?v.jsx(tr,{styles:{footnote:ee==null?void 0:ee.footnote,source:ee==null?void 0:ee.source},classNames:{footnote:J==null?void 0:J.footnote,source:J==null?void 0:J.source},sources:a,footNote:s,width:l}):null]})})})})}function eq(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,height:o,width:l,footNote:s,colorDomain:f,colorLegendTitle:c,radius:h,padding:d,backgroundColor:m,leftMargin:g,rightMargin:y,topMargin:b,bottomMargin:S,tooltip:w,relativeHeight:C,onSeriesMouseOver:k,showColorScale:_,highlightedDataPoints:D,graphID:T,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N,graphDownload:Y,dataDownload:ne,prefix:K,suffix:B,stripType:j,language:$,highlightColor:V,dotOpacity:z,showNAColor:W,minHeight:G,theme:ae,ariaLabel:U,valueColor:H,resetSelectionOnDoubleClick:R,detailsOnClick:ee,orientation:J="vertical",styles:Z,classNames:re}=t;return J==="vertical"?v.jsx(Rye,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,height:o,width:l,footNote:s,colorDomain:f,colorLegendTitle:c,radius:h,padding:d,backgroundColor:m,leftMargin:g,rightMargin:y,topMargin:b,bottomMargin:S,tooltip:w,relativeHeight:C,onSeriesMouseOver:k,showColorScale:_,highlightedDataPoints:D,graphID:T,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N,graphDownload:Y,dataDownload:ne,prefix:K,suffix:B,stripType:j,language:$,highlightColor:V,dotOpacity:z,showNAColor:W,minHeight:G,theme:ae,ariaLabel:U,resetSelectionOnDoubleClick:R,styles:Z,valueColor:H,detailsOnClick:ee,classNames:re}):v.jsx(Iye,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,height:o,width:l,footNote:s,colorDomain:f,colorLegendTitle:c,radius:h,padding:d,backgroundColor:m,leftMargin:g,rightMargin:y,topMargin:b,bottomMargin:S,tooltip:w,relativeHeight:C,onSeriesMouseOver:k,showColorScale:_,highlightedDataPoints:D,graphID:T,minValue:A,maxValue:M,onSeriesMouseClick:E,showAxis:N,graphDownload:Y,dataDownload:ne,prefix:K,suffix:B,stripType:j,language:$,highlightColor:V,dotOpacity:z,showNAColor:W,minHeight:G,theme:ae,ariaLabel:U,resetSelectionOnDoubleClick:R,styles:Z,valueColor:H,detailsOnClick:ee,classNames:re})}function $ye(t){var Oe,Ne,Te,_e,xe,we,ge,ve,le,ue,Ce,pe,ye,be,je,$e,ut,Ie,Ze,Ke;const{data:e,width:r,height:n,barColor:a,lineColor:i,axisTitles:o,sameAxes:l,rightMargin:s,leftMargin:f,topMargin:c,bottomMargin:h,tooltip:d,showValues:m,onSeriesMouseOver:g,barPadding:y,truncateBy:b,showLabels:S,onSeriesMouseClick:w,resetSelectionOnDoubleClick:C,detailsOnClick:k,noOfTicks:_,lineSuffix:D,barSuffix:T,linePrefix:A,barPrefix:M,curveType:E,styles:N,classNames:Y}=t,ne=E==="linear"?yo:E==="step"?e2:E==="stepAfter"?r2:E==="stepBefore"?t2:Q0,[K,B]=I.useState(void 0),[j,$]=I.useState(void 0),[V,z]=I.useState(void 0),[W,G]=I.useState(void 0),ae={top:c,bottom:h,left:f+50,right:s+65},U=r-ae.left-ae.right,H=n-ae.top-ae.bottom,R=e.map((et,Pt)=>({...et,id:`${Pt}`})),ee=Un().domain(R.map(et=>`${et.id}`)).range([0,U]).paddingInner(y),J=(Oe=Br(R,et=>et.bar))!=null&&Oe.bar?((Ne=Br(R,et=>et.bar))==null?void 0:Ne.bar)>0?0:(Te=Br(R,et=>et.bar))==null?void 0:Te.bar:0,Z=(_e=Br(R,et=>et.line))!=null&&_e.line?((xe=Br(R,et=>et.line))==null?void 0:xe.line)>0?0:(we=Br(R,et=>et.line))==null?void 0:we.line:0,re=(ge=Vr(R,et=>et.bar))!=null&&ge.bar?(ve=Vr(R,et=>et.bar))==null?void 0:ve.bar:0,te=(le=Vr(R,et=>et.line))!=null&&le.line?(ue=Vr(R,et=>et.line))==null?void 0:ue.line:0,F=J<Z?J:Z,q=re>te?re:te,X=br().domain([l?F:J,l?q>0?q:0:re>0?re:0]).range([H,0]).nice(),ie=br().domain([l?F:Z,l?q>0?q:0:te>0?te:0]).range([H,0]).nice(),ce=gi().defined(et=>!Fe(et.line)).x(et=>ee(`${et.id}`)+ee.bandwidth()/2).y(et=>ie(et.line)).curve(ne),de=X.ticks(_),he=ie.ticks(_);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${ae.left},${ae.top})`,children:[v.jsxs("g",{children:[de.map((et,Pt)=>{var jt,Tt,St,tt;return v.jsxs("g",{children:[v.jsx("line",{y1:X(et),y2:X(et),x1:-15,x2:-20,style:{stroke:a,strokeWidth:1,...((jt=N==null?void 0:N.yAxis)==null?void 0:jt.gridLines)||{}},className:(Tt=Y==null?void 0:Y.yAxis)==null?void 0:Tt.gridLines}),v.jsx("text",{x:-25,y:X(et),dy:"0.33em",className:Be("text-xs",(St=Y==null?void 0:Y.yAxis)==null?void 0:St.labels),style:{textAnchor:"end",fill:a,...((tt=N==null?void 0:N.yAxis)==null?void 0:tt.labels)||{}},children:_t(et,M,T)})]},Pt)}),v.jsx(Nr,{y1:0,y2:H,x1:-15,x2:-15,classNames:{axis:(Ce=Y==null?void 0:Y.xAxis)==null?void 0:Ce.axis},styles:{axis:{stroke:a,...((pe=N==null?void 0:N.xAxis)==null?void 0:pe.axis)||{}}}}),v.jsx(nn,{x:10-ae.left,y:H/2,style:{fill:a,...((ye=N==null?void 0:N.yAxis)==null?void 0:ye.title)||{}},className:(be=Y==null?void 0:Y.yAxis)==null?void 0:be.title,text:o[0].length>100?`${o[0].substring(0,100)}...`:o[0],rotate90:!0})]}),v.jsxs("g",{children:[he.map((et,Pt)=>{var jt,Tt,St,tt;return v.jsxs("g",{children:[v.jsx("line",{y1:ie(et),y2:ie(et),x1:U+15,x2:U+20,style:{stroke:i,strokeWidth:1,...((jt=N==null?void 0:N.yAxis)==null?void 0:jt.gridLines)||{}},className:(Tt=Y==null?void 0:Y.yAxis)==null?void 0:Tt.gridLines}),v.jsx("text",{x:U+25,y:ie(et),dy:"0.33em",dx:-2,style:{textAnchor:"start",fill:i,...((St=N==null?void 0:N.yAxis)==null?void 0:St.labels)||{}},className:Be("text-xs",(tt=Y==null?void 0:Y.yAxis)==null?void 0:tt.labels),children:_t(et,A,D)})]},Pt)}),v.jsx(Nr,{y1:0,y2:H,x1:U+15,x2:U+15,classNames:{axis:(je=Y==null?void 0:Y.xAxis)==null?void 0:je.axis},styles:{axis:{stroke:i,...(($e=N==null?void 0:N.xAxis)==null?void 0:$e.axis)||{}}}}),v.jsx(nn,{x:U+ae.right-15,y:H/2,style:{fill:i,...((ut=N==null?void 0:N.yAxis)==null?void 0:ut.title)||{}},className:(Ie=Y==null?void 0:Y.yAxis)==null?void 0:Ie.title,text:o[1].length>100?`${o[1].substring(0,100)}...`:o[1],rotate90:!0})]}),v.jsx(Nr,{y1:l?X(0):H,y2:l?X(0):H,x1:-15,x2:U+15,classNames:{axis:(Ze=Y==null?void 0:Y.xAxis)==null?void 0:Ze.axis},styles:{axis:(Ke=N==null?void 0:N.xAxis)==null?void 0:Ke.axis}}),R.map((et,Pt)=>{var jt,Tt;return v.jsxs("g",{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:St=>{B(et),G(St.clientY),z(St.clientX),g&&g(et)},onClick:()=>{(w||k)&&(Sr(j,et)&&C?($(void 0),w==null||w(void 0)):($(et),w==null||w(et)))},onMouseMove:St=>{B(et),G(St.clientY),z(St.clientX)},onMouseLeave:()=>{B(void 0),z(void 0),G(void 0),g&&g(void 0)},children:[v.jsx("rect",{x:ee(`${Pt}`),y:et.bar?et.bar>0?X(et.bar):X(0):0,width:ee.bandwidth(),style:{fill:a},height:et.bar?Math.abs(X(et.bar)-X(0)):0}),m&&!Fe(et.bar)?v.jsx("text",{x:ee(`${et.id}`)+ee.bandwidth()/2,y:X(et.bar||0),style:{fill:a,textAnchor:"middle",...(N==null?void 0:N.graphObjectValues)||{}},className:Be("graph-value text-sm",Y==null?void 0:Y.graphObjectValues),dy:et.bar?et.bar>=0?"-5px":"1em":"-5px",children:_t(et.bar,M,T)}):null,S?v.jsx(f4,{value:`${et.label}`.length<b?`${et.label}`:`${`${et.label}`.substring(0,b)}...`,y:H+5,x:ee(`${et.id}`),width:ee.bandwidth(),height:ae.bottom,style:(jt=N==null?void 0:N.xAxis)==null?void 0:jt.labels,className:(Tt=Y==null?void 0:Y.xAxis)==null?void 0:Tt.labels,alignment:"top"}):null]},Pt)}),v.jsx("path",{d:ce(R),style:{stroke:i,fill:"none",strokeWidth:2}}),R.map((et,Pt)=>v.jsx("g",{children:Fe(et.line)?null:v.jsxs("g",{onMouseEnter:jt=>{B(et),G(jt.clientY),z(jt.clientX),g&&g(et)},onClick:()=>{(w||k)&&(Sr(j,et)&&C?($(void 0),w==null||w(void 0)):($(et),w==null||w(et)))},onMouseMove:jt=>{B(et),G(jt.clientY),z(jt.clientX)},onMouseLeave:()=>{B(void 0),z(void 0),G(void 0),g&&g(void 0)},children:[v.jsx("circle",{cx:ee(et.id)+ee.bandwidth()/2,cy:ie(et.line),r:U/R.length<5?0:U/R.length<20?2:4,style:{fill:i}}),m?v.jsx("text",{x:ee(`${et.id}`)+ee.bandwidth()/2,y:ie(et.line),style:{fill:i,textAnchor:"middle",...(N==null?void 0:N.graphObjectValues)||{}},className:Be("graph-value text-sm",Y==null?void 0:Y.graphObjectValues),dy:"-5px",children:_t(et.line,A,D)}):null]})},Pt))]})}),K&&d&&V&&W?v.jsx(yr,{data:K,body:d,xPos:V,yPos:W,backgroundStyle:N==null?void 0:N.tooltip,className:Y==null?void 0:Y.tooltip}):null,k?v.jsx(Tr,{open:j!==void 0,onClose:()=>{$(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(k,j)}})}):null]})}function tq(t){const{data:e,graphTitle:r,sources:n,graphDescription:a,height:i,width:o,footNote:l,padding:s,lineColor:f=Qe.light.categoricalColors.colors[1],barColor:c=Qe.light.categoricalColors.colors[0],sameAxes:h=!1,backgroundColor:d=!1,leftMargin:m=80,rightMargin:g=80,topMargin:y=20,bottomMargin:b=25,lineAxisTitle:S="Line chart",barAxisTitle:w="Bar graph",tooltip:C,relativeHeight:k,onSeriesMouseOver:_,graphID:D,graphDownload:T=!1,dataDownload:A=!1,barPadding:M=.25,truncateBy:E=999,showLabels:N=!0,onSeriesMouseClick:Y,language:ne="en",colorLegendTitle:K,minHeight:B=0,theme:j="light",ariaLabel:$,resetSelectionOnDoubleClick:V=!0,detailsOnClick:z,showValues:W=!0,noOfTicks:G=5,lineSuffix:ae="",barSuffix:U="",linePrefix:H="",barPrefix:R="",curveType:ee="curve",styles:J,classNames:Z}=t,[re,te]=I.useState(0),[F,q]=I.useState(0),X=I.useRef(null),ie=I.useRef(null);return I.useEffect(()=>{const ce=new ResizeObserver(de=>{te(o||de[0].target.clientWidth||620),q(i||de[0].target.clientHeight||480)});return X.current&&(q(X.current.clientHeight||480),te(X.current.clientWidth||620),o||ce.observe(X.current)),()=>ce.disconnect()},[o,i]),v.jsx("div",{className:`${j||"light"} flex ${o?"w-fit grow-0":"w-full grow"}`,dir:ne==="he"||ne==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${d?d===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${ne||"en"}`,Z==null?void 0:Z.graphContainer),style:{...(J==null?void 0:J.graphContainer)||{},...d&&d!==!0?{backgroundColor:d}:{}},id:D,ref:ie,"aria-label":$||`${r?`The graph shows ${r}. `:""}This is a pareto chart that shows a variable as bars and another as line chart.${a?` ${a}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:d?s||"1rem":s||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||a||T||A?v.jsx(Zt,{styles:{title:J==null?void 0:J.title,description:J==null?void 0:J.description},classNames:{title:Z==null?void 0:Z.title,description:Z==null?void 0:Z.description},graphTitle:r,graphDescription:a,width:o,graphDownload:T?ie.current:void 0,dataDownload:A?e.map(ce=>ce.data).filter(ce=>ce!==void 0).length>0?e.map(ce=>ce.data).filter(ce=>ce!==void 0):e.filter(ce=>ce!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[v.jsx(g0,{colorDomain:[w,S],colors:[c||Qe[j].categoricalColors.colors[0],f||Qe[j].categoricalColors.colors[1]],colorLegendTitle:K,showNAColor:!1}),v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:X,"aria-label":"Graph area",children:(o||re)&&(i||F)?v.jsx($ye,{data:e,sameAxes:h,lineColor:f,barColor:c,width:o||re,height:Math.max(B,i||(k?B?(o||re)*k>B?(o||re)*k:B:(o||re)*k:F)),truncateBy:E,leftMargin:m,rightMargin:g,topMargin:y,bottomMargin:b,axisTitles:[w,S],tooltip:C,onSeriesMouseOver:_,barPadding:M,showLabels:N,onSeriesMouseClick:Y,resetSelectionOnDoubleClick:V,detailsOnClick:z,noOfTicks:G,lineSuffix:ae,barSuffix:U,linePrefix:H,barPrefix:R,curveType:ee,showValues:W,styles:J,classNames:Z}):null})]})}),n||l?v.jsx(tr,{styles:{footnote:J==null?void 0:J.footnote,source:J==null?void 0:J.source},classNames:{footnote:Z==null?void 0:Z.footnote,source:Z==null?void 0:Z.source},sources:n,footNote:l,width:o}):null]})})})})}function Bye(t){var ce,de,he,Oe,Ne,Te,_e,xe,we,ge,ve,le,ue,Ce,pe,ye;const{data:e,width:r,height:n,barColors:a,centerGap:i,refValues:o,maxValue:l,minValue:s,showValues:f,axisTitles:c,rightMargin:h,leftMargin:d,topMargin:m,bottomMargin:g,tooltip:y,onSeriesMouseOver:b,barPadding:S,truncateBy:w,onSeriesMouseClick:C,showTicks:k,suffix:_,prefix:D,resetSelectionOnDoubleClick:T,detailsOnClick:A,styles:M,classNames:E,noOfTicks:N}=t,[Y,ne]=I.useState(void 0),[K,B]=I.useState(void 0),[j,$]=I.useState(void 0),[V,z]=I.useState(void 0),W={top:m,bottom:g,left:d,right:h},G=r-W.left-W.right,ae=n-W.top-W.bottom,U=e.map((be,je)=>({...be,id:`${je}`})),H=Un().domain(U.map(be=>`${be.id}`)).range([ae,0]).paddingInner(S),R=Fe(l)?Math.max(...e.filter(be=>!Fe(be.leftBar)).map(be=>be.leftBar))<0?0:Math.max(...e.filter(be=>!Fe(be.leftBar)).map(be=>be.leftBar)):l,ee=Fe(s)?Math.min(...e.filter(be=>!Fe(be.leftBar)).map(be=>be.leftBar))>=0?0:Math.min(...e.filter(be=>!Fe(be.leftBar)).map(be=>be.leftBar)):s,J=Fe(l)?Math.max(...e.filter(be=>!Fe(be.rightBar)).map(be=>be.rightBar))<0?0:Math.max(...e.filter(be=>!Fe(be.rightBar)).map(be=>be.rightBar)):l,Z=Fe(s)?Math.min(...e.filter(be=>!Fe(be.rightBar)).map(be=>be.rightBar))>=0?0:Math.min(...e.filter(be=>!Fe(be.rightBar)).map(be=>be.rightBar)):s,re=ee<Z?ee:Z,te=R>J?R:J,F=br().domain([re,te]).range([0,(G-i)/2]).nice(),q=F.ticks(N),X=br().domain([re,te]).range([(G-i)/2,0]).nice(),ie=X.ticks(N);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${W.left},${W.top})`,children:[v.jsxs("g",{transform:"translate(0,0)",children:[k?v.jsx(La,{values:ie.filter(be=>be!==0),x:ie.filter(be=>be!==0).map(be=>X(be)),y1:0-m,y2:ae+W.bottom,styles:{gridLines:(ce=M==null?void 0:M.xAxis)==null?void 0:ce.gridLines,labels:(de=M==null?void 0:M.xAxis)==null?void 0:de.labels},classNames:{gridLines:(he=E==null?void 0:E.xAxis)==null?void 0:he.gridLines,labels:(Oe=E==null?void 0:E.xAxis)==null?void 0:Oe.labels},suffix:_,prefix:D,labelType:"secondary",showGridLines:!0,leftLabel:!0}):null,U.map((be,je)=>v.jsxs("g",{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:$e=>{ne(be),z($e.clientY),$($e.clientX),b&&b(be)},onClick:()=>{(C||A)&&(Sr(K,be)&&T?(B(void 0),C==null||C(void 0)):(B(be),C==null||C(be)))},onMouseMove:$e=>{ne(be),z($e.clientY),$($e.clientX)},onMouseLeave:()=>{ne(void 0),$(void 0),z(void 0),b&&b(void 0)},children:[be.leftBar?v.jsx("rect",{x:be.leftBar<0?X(0):X(be.leftBar),y:H(`${je}`),width:be.leftBar<0?X(be.leftBar)-X(0):X(0)-X(be.leftBar),style:{fill:a[0]},height:H.bandwidth()}):null,f?v.jsx("text",{x:be.leftBar?X(be.leftBar):X(ee<0?0:ee),y:H(`${je}`)+H.bandwidth()/2,style:{fill:a[0],textAnchor:be.rightBar&&be.rightBar>0?"end":"start",...(M==null?void 0:M.graphObjectValues)||{}},dx:be.rightBar&&be.rightBar>0?-5:5,dy:"0.33em",className:Be("graph-value text-sm",E==null?void 0:E.graphObjectValues),children:_t(be.rightBar,D,_)}):null]},je)),v.jsx(Nr,{y1:-2.5,y2:ae+W.bottom,x1:X(ee<0?0:ee),x2:X(ee<0?0:ee),classNames:{axis:(Ne=E==null?void 0:E.yAxis)==null?void 0:Ne.axis},styles:{axis:(Te=M==null?void 0:M.yAxis)==null?void 0:Te.axis}}),o?v.jsx(v.Fragment,{children:o.map((be,je)=>v.jsx(ti,{text:be.text,color:be.color,x:X(be.value),y1:0-W.top,y2:ae+W.bottom,textSide:"left",classNames:be.classNames,styles:be.styles},je))}):null]}),v.jsxs("g",{transform:`translate(${(G+i)/2},0)`,children:[k?v.jsx(La,{values:q.filter(be=>be!==0),x:q.filter(be=>be!==0).map(be=>F(be)),y1:0-m,y2:ae+W.bottom,styles:{gridLines:(_e=M==null?void 0:M.xAxis)==null?void 0:_e.gridLines,labels:(xe=M==null?void 0:M.xAxis)==null?void 0:xe.labels},classNames:{gridLines:(we=E==null?void 0:E.xAxis)==null?void 0:we.gridLines,labels:(ge=E==null?void 0:E.xAxis)==null?void 0:ge.labels},suffix:_,prefix:D,labelType:"secondary",showGridLines:!0}):null,U.map((be,je)=>v.jsxs("g",{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:$e=>{ne(be),z($e.clientY),$($e.clientX),b&&b(be)},onClick:()=>{(C||A)&&(Sr(K,be)&&T?(B(void 0),C==null||C(void 0)):(B(be),C==null||C(be)))},onMouseMove:$e=>{ne(be),z($e.clientY),$($e.clientX)},onMouseLeave:()=>{ne(void 0),$(void 0),z(void 0),b&&b(void 0)},children:[be.rightBar?v.jsx("rect",{x:be.rightBar>=0?F(0):F(be.rightBar),y:H(`${je}`),width:be.rightBar>=0?F(be.rightBar)-F(0):F(0)-F(be.rightBar),style:{fill:a[1]},height:H.bandwidth()}):null,f?v.jsx("text",{x:be.rightBar?F(be.rightBar):F(Z<0?0:Z),y:H(`${je}`)+H.bandwidth()/2,style:{fill:a[1],textAnchor:be.rightBar&&be.rightBar<0?"end":"start",...(M==null?void 0:M.graphObjectValues)||{}},className:Be("graph-value text-sm",E==null?void 0:E.graphObjectValues),dx:be.rightBar&&be.rightBar<0?-5:5,dy:"0.33em",children:_t(be.rightBar,D,_)}):null]},je)),v.jsx(Nr,{y1:-2.5,y2:ae+W.bottom,x1:F(Z<0?0:Z),x2:F(Z<0?0:Z),classNames:{axis:(ve=E==null?void 0:E.yAxis)==null?void 0:ve.axis},styles:{axis:(le=M==null?void 0:M.yAxis)==null?void 0:le.axis}}),o?v.jsx(v.Fragment,{children:o.map((be,je)=>v.jsx(ti,{text:be.text,color:be.color,x:F(be.value),y1:0-W.top,y2:ae+W.bottom,textSide:"right",classNames:be.classNames,styles:be.styles},je))}):null]}),v.jsx("g",{transform:`translate(${G/2},0)`,children:U.map((be,je)=>{var $e,ut;return v.jsx(Y2,{value:`${be.label}`.length<w?`${be.label}`:`${`${be.label}`.substring(0,w)}...`,y:H(`${be.id}`),x:0-i/2,width:i,height:H.bandwidth(),alignment:"center",style:($e=M==null?void 0:M.yAxis)==null?void 0:$e.labels,className:(ut=E==null?void 0:E.yAxis)==null?void 0:ut.labels},je)})}),v.jsxs("g",{transform:`translate(0,${ae})`,children:[v.jsx("text",{style:{fill:a[0],textAnchor:"end",...(ue=M==null?void 0:M.yAxis)==null?void 0:ue.title},className:Be("text-base",(Ce=E==null?void 0:E.yAxis)==null?void 0:Ce.title),x:G/2-i/2,y:0,dx:-5,dy:20,children:c[0]}),v.jsx("text",{style:{fill:a[1],textAnchor:"start",...(pe=M==null?void 0:M.yAxis)==null?void 0:pe.title},className:Be("text-base",(ye=E==null?void 0:E.yAxis)==null?void 0:ye.title),x:G/2+i/2,y:0,dx:5,dy:20,children:c[1]})]})]})}),Y&&y&&j&&V?v.jsx(yr,{data:Y,body:y,xPos:j,yPos:V,backgroundStyle:M==null?void 0:M.tooltip,className:E==null?void 0:E.tooltip}):null,A?v.jsx(Tr,{open:K!==void 0,onClose:()=>{B(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(A,K)}})}):null]})}function rq(t){const{data:e,graphTitle:r,sources:n,graphDescription:a,height:i,width:o,footNote:l,padding:s,leftBarColor:f=Qe.light.categoricalColors.colors[0],rightBarColor:c=Qe.light.categoricalColors.colors[1],backgroundColor:h=!1,leftMargin:d=20,rightMargin:m=20,topMargin:g=25,bottomMargin:y=30,rightBarTitle:b="Right bar graph",leftBarTitle:S="Left bar graph",tooltip:w,relativeHeight:C,onSeriesMouseOver:k,graphID:_,barPadding:D=.25,truncateBy:T=999,onSeriesMouseClick:A,centerGap:M=100,showValues:E=!0,maxValue:N,minValue:Y,refValues:ne=[],suffix:K="",prefix:B="",showTicks:j=!0,showColorScale:$=!1,graphDownload:V=!1,dataDownload:z=!1,language:W="en",colorLegendTitle:G,minHeight:ae=0,theme:U="light",ariaLabel:H,resetSelectionOnDoubleClick:R=!0,detailsOnClick:ee,styles:J,classNames:Z,noOfTicks:re=5}=t,[te,F]=I.useState(0),[q,X]=I.useState(0),ie=I.useRef(null),ce=I.useRef(null);return I.useEffect(()=>{const de=new ResizeObserver(he=>{F(o||he[0].target.clientWidth||620),X(i||he[0].target.clientHeight||480)});return ie.current&&(X(ie.current.clientHeight||480),F(ie.current.clientWidth||620),o||de.observe(ie.current)),()=>de.disconnect()},[o,i]),v.jsx("div",{className:`${U||"light"} flex ${o?"w-fit grow-0":"w-full grow"}`,dir:W==="he"||W==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${h?h===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${W||"en"}`,Z==null?void 0:Z.graphContainer),style:{...(J==null?void 0:J.graphContainer)||{},...h&&h!==!0?{backgroundColor:h}:{}},id:_,ref:ce,"aria-label":H||`${r?`The graph shows ${r}. `:""}This is a diverging bar chart. ${a?` ${a}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:h?s||"1rem":s||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||a||V||z?v.jsx(Zt,{styles:{title:J==null?void 0:J.title,description:J==null?void 0:J.description},classNames:{title:Z==null?void 0:Z.title,description:Z==null?void 0:Z.description},graphTitle:r,graphDescription:a,width:o,graphDownload:V?ce.current:void 0,dataDownload:z?e.map(de=>de.data).filter(de=>de!==void 0).length>0?e.map(de=>de.data).filter(de=>de!==void 0):e.filter(de=>de!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[$?v.jsx(g0,{colorLegendTitle:G,colorDomain:[S,b],colors:[f,c],showNAColor:!1}):null,v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:ie,"aria-label":"Graph area",children:(o||te)&&(i||q)?v.jsx(Bye,{data:e,barColors:[f,c],width:o||te,centerGap:M,height:Math.max(ae,i||(C?ae?(o||te)*C>ae?(o||te)*C:ae:(o||te)*C:q)),truncateBy:T,leftMargin:d,rightMargin:m,topMargin:g,bottomMargin:y,axisTitles:[S,b],tooltip:w,onSeriesMouseOver:k,barPadding:D,refValues:ne,maxValue:N,minValue:Y,showValues:E,onSeriesMouseClick:A,showTicks:j,suffix:K,prefix:B,resetSelectionOnDoubleClick:R,detailsOnClick:ee,styles:J,classNames:Z,noOfTicks:re}):null})]})}),n||l?v.jsx(tr,{styles:{footnote:J==null?void 0:J.footnote,source:J==null?void 0:J.source},classNames:{footnote:Z==null?void 0:Z.footnote,source:Z==null?void 0:Z.source},sources:n,footNote:l,width:o}):null]})})})})}function nq(t){const{data:e,graphTitle:r,sources:n,graphDescription:a,barPadding:i,showValues:o,showTicks:l,leftMargin:s,rightMargin:f,height:c,width:h,footNote:d,colors:m,padding:g,backgroundColor:y,topMargin:b,bottomMargin:S,showLabels:w,relativeHeight:C,tooltip:k,onSeriesMouseOver:_,refValues:D,graphID:T,maxValue:A,onSeriesMouseClick:M,graphDownload:E,dataDownload:N,numberOfBins:Y,truncateBy:ne,graphType:K,barGraphLayout:B,donutStrokeWidth:j,sortData:$,language:V,minHeight:z,theme:W="light",maxBarThickness:G,ariaLabel:ae,detailsOnClick:U,styles:H,classNames:R}=t,[ee,J]=I.useState([]);return I.useEffect(()=>{const re=Lie().thresholds(Y||10).value(te=>te.value)(e).map(te=>({label:`${te.x0}-${te.x1}`,size:te.length,data:{options:`${te.x0}-${te.x1}`,frequency:te.length}}));J(re)},[e,Y]),ee.length===0?v.jsx("div",{style:{width:`${h}px`,height:`${c}px`,margin:"auto"},children:v.jsx("div",{className:"flex m-auto items-center justify-center p-0 leading-none text-base h-40",children:v.jsx(Fo,{})})}):K==="circlePacking"?v.jsx(Qb,{colors:m||Qe.graphMainColor,graphTitle:r,graphDescription:a,footNote:d,width:h,height:c,sources:n,leftMargin:s,rightMargin:f,backgroundColor:y,padding:g,topMargin:b,bottomMargin:S,relativeHeight:C,showLabels:w,tooltip:k,onSeriesMouseOver:_,showColorScale:!1,showValues:o,graphID:T,onSeriesMouseClick:M,graphDownload:E,dataDownload:N,data:ee,language:V,minHeight:z,theme:W,ariaLabel:ae,detailsOnClick:U,styles:H,classNames:R}):K==="treeMap"?v.jsx(mw,{colors:m||Qe.graphMainColor,graphTitle:r,graphDescription:a,footNote:d,width:h,height:c,sources:n,leftMargin:s,rightMargin:f,backgroundColor:y,padding:g,topMargin:b,bottomMargin:S,relativeHeight:C,showLabels:w,tooltip:k,onSeriesMouseOver:_,showColorScale:!1,showValues:o,graphID:T,onSeriesMouseClick:M,graphDownload:E,dataDownload:N,data:ee,language:V,minHeight:z,theme:W,ariaLabel:ae,detailsOnClick:U,styles:H,classNames:R}):K==="donutChart"?v.jsx(rx,{colors:m||Qe[W].categoricalColors.colors,graphTitle:r,graphDescription:a,footNote:d,radius:h&&c?h<c?h:c:h||c||void 0,sources:n,backgroundColor:y,padding:g,tooltip:k,onSeriesMouseOver:_,graphID:T,onSeriesMouseClick:M,graphDownload:E,dataDownload:N,data:ee,strokeWidth:j,showColorScale:!0,sortData:$,language:V,theme:W,ariaLabel:ae,detailsOnClick:U,styles:H,classNames:R}):v.jsx(Hb,{colors:m||Qe.graphMainColor,graphTitle:r,graphDescription:a,footNote:d,width:h,height:c,sources:n,leftMargin:s,rightMargin:f,backgroundColor:y,padding:g,topMargin:b,bottomMargin:S,relativeHeight:C,showLabels:w,tooltip:k,onSeriesMouseOver:_,showColorScale:!1,showValues:o,graphID:T,onSeriesMouseClick:M,graphDownload:E,dataDownload:N,data:ee,barPadding:i,refValues:D,truncateBy:ne,maxValue:A,showTicks:l,sortData:$,language:V,minHeight:z,theme:W,maxBarThickness:G,ariaLabel:ae,orientation:B,detailsOnClick:U,styles:H,classNames:R})}function HM(t,e){let r;if(e===void 0)for(const n of t)n!=null&&(r<n||r===void 0&&n>=n)&&(r=n);else{let n=-1;for(let a of t)(a=e(a,++n,t))!=null&&(r<a||r===void 0&&a>=a)&&(r=a)}return r}function aq(t,e){let r;if(e===void 0)for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);else{let n=-1;for(let a of t)(a=e(a,++n,t))!=null&&(r>a||r===void 0&&a>=a)&&(r=a)}return r}function _m(t,e){let r=0;if(e===void 0)for(let n of t)(n=+n)&&(r+=n);else{let n=-1;for(let a of t)(a=+e(a,++n,t))&&(r+=a)}return r}function Vye(t){return t.target.depth}function Fye(t,e){return t.sourceLinks.length?t.depth:e-1}function Om(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?aq(t.sourceLinks,Vye)-1:0}function x5(t){return function(){return t}}function qM(t,e){return Pc(t.source,e.source)||t.index-e.index}function WM(t,e){return Pc(t.target,e.target)||t.index-e.index}function Pc(t,e){return t.y0-e.y0}function Dm(t){return t.value}function zye(t){return t.index}function Hye(t){return t.nodes}function qye(t){return t.links}function UM(t,e){const r=t.get(e);if(!r)throw new Error("missing: "+e);return r}function GM({nodes:t}){for(const e of t){let r=e.y0,n=r;for(const a of e.sourceLinks)a.y0=r+a.width/2,r+=a.width;for(const a of e.targetLinks)a.y1=n+a.width/2,n+=a.width}}function Am(){let t=0,e=0,r=1,n=1,a=24,i=8,o,l=zye,s=Fye,f,c,h=Hye,d=qye,m=6;function g(){const B={nodes:h.apply(null,arguments),links:d.apply(null,arguments)};return y(B),b(B),S(B),w(B),_(B),GM(B),B}g.update=function(B){return GM(B),B},g.nodeId=function(B){return arguments.length?(l=typeof B=="function"?B:x5(B),g):l},g.nodeAlign=function(B){return arguments.length?(s=typeof B=="function"?B:x5(B),g):s},g.nodeSort=function(B){return arguments.length?(f=B,g):f},g.nodeWidth=function(B){return arguments.length?(a=+B,g):a},g.nodePadding=function(B){return arguments.length?(i=o=+B,g):i},g.nodes=function(B){return arguments.length?(h=typeof B=="function"?B:x5(B),g):h},g.links=function(B){return arguments.length?(d=typeof B=="function"?B:x5(B),g):d},g.linkSort=function(B){return arguments.length?(c=B,g):c},g.size=function(B){return arguments.length?(t=e=0,r=+B[0],n=+B[1],g):[r-t,n-e]},g.extent=function(B){return arguments.length?(t=+B[0][0],r=+B[1][0],e=+B[0][1],n=+B[1][1],g):[[t,e],[r,n]]},g.iterations=function(B){return arguments.length?(m=+B,g):m};function y({nodes:B,links:j}){for(const[V,z]of B.entries())z.index=V,z.sourceLinks=[],z.targetLinks=[];const $=new Map(B.map((V,z)=>[l(V,z,B),V]));for(const[V,z]of j.entries()){z.index=V;let{source:W,target:G}=z;typeof W!="object"&&(W=z.source=UM($,W)),typeof G!="object"&&(G=z.target=UM($,G)),W.sourceLinks.push(z),G.targetLinks.push(z)}if(c!=null)for(const{sourceLinks:V,targetLinks:z}of B)V.sort(c),z.sort(c)}function b({nodes:B}){for(const j of B)j.value=j.fixedValue===void 0?Math.max(_m(j.sourceLinks,Dm),_m(j.targetLinks,Dm)):j.fixedValue}function S({nodes:B}){const j=B.length;let $=new Set(B),V=new Set,z=0;for(;$.size;){for(const W of $){W.depth=z;for(const{target:G}of W.sourceLinks)V.add(G)}if(++z>j)throw new Error("circular link");$=V,V=new Set}}function w({nodes:B}){const j=B.length;let $=new Set(B),V=new Set,z=0;for(;$.size;){for(const W of $){W.height=z;for(const{source:G}of W.targetLinks)V.add(G)}if(++z>j)throw new Error("circular link");$=V,V=new Set}}function C({nodes:B}){const j=HM(B,z=>z.depth)+1,$=(r-t-a)/(j-1),V=new Array(j);for(const z of B){const W=Math.max(0,Math.min(j-1,Math.floor(s.call(null,z,j))));z.layer=W,z.x0=t+W*$,z.x1=z.x0+a,V[W]?V[W].push(z):V[W]=[z]}if(f)for(const z of V)z.sort(f);return V}function k(B){const j=aq(B,$=>(n-e-($.length-1)*o)/_m($,Dm));for(const $ of B){let V=e;for(const z of $){z.y0=V,z.y1=V+z.value*j,V=z.y1+o;for(const W of z.sourceLinks)W.width=W.value*j}V=(n-V+o)/($.length+1);for(let z=0;z<$.length;++z){const W=$[z];W.y0+=V*(z+1),W.y1+=V*(z+1)}Y($)}}function _(B){const j=C(B);o=Math.min(i,(n-e)/(HM(j,$=>$.length)-1)),k(j);for(let $=0;$<m;++$){const V=Math.pow(.99,$),z=Math.max(1-V,($+1)/m);T(j,V,z),D(j,V,z)}}function D(B,j,$){for(let V=1,z=B.length;V<z;++V){const W=B[V];for(const G of W){let ae=0,U=0;for(const{source:R,value:ee}of G.targetLinks){let J=ee*(G.layer-R.layer);ae+=ne(R,G)*J,U+=J}if(!(U>0))continue;let H=(ae/U-G.y0)*j;G.y0+=H,G.y1+=H,N(G)}f===void 0&&W.sort(Pc),A(W,$)}}function T(B,j,$){for(let V=B.length,z=V-2;z>=0;--z){const W=B[z];for(const G of W){let ae=0,U=0;for(const{target:R,value:ee}of G.sourceLinks){let J=ee*(R.layer-G.layer);ae+=K(G,R)*J,U+=J}if(!(U>0))continue;let H=(ae/U-G.y0)*j;G.y0+=H,G.y1+=H,N(G)}f===void 0&&W.sort(Pc),A(W,$)}}function A(B,j){const $=B.length>>1,V=B[$];E(B,V.y0-o,$-1,j),M(B,V.y1+o,$+1,j),E(B,n,B.length-1,j),M(B,e,0,j)}function M(B,j,$,V){for(;$<B.length;++$){const z=B[$],W=(j-z.y0)*V;W>1e-6&&(z.y0+=W,z.y1+=W),j=z.y1+o}}function E(B,j,$,V){for(;$>=0;--$){const z=B[$],W=(z.y1-j)*V;W>1e-6&&(z.y0-=W,z.y1-=W),j=z.y0-o}}function N({sourceLinks:B,targetLinks:j}){if(c===void 0){for(const{source:{sourceLinks:$}}of j)$.sort(WM);for(const{target:{targetLinks:$}}of B)$.sort(qM)}}function Y(B){if(c===void 0)for(const{sourceLinks:j,targetLinks:$}of B)j.sort(WM),$.sort(qM)}function ne(B,j){let $=B.y0-(B.sourceLinks.length-1)*o/2;for(const{target:V,width:z}of B.sourceLinks){if(V===j)break;$+=z+o}for(const{source:V,width:z}of j.targetLinks){if(V===B)break;$-=z}return $}function K(B,j){let $=j.y0-(j.targetLinks.length-1)*o/2;for(const{source:V,width:z}of j.targetLinks){if(V===B)break;$+=z+o}for(const{target:V,width:z}of B.sourceLinks){if(V===j)break;$-=z}return $}return g}var rv=Math.PI,nv=2*rv,T3=1e-6,Wye=nv-T3;function av(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function iq(){return new av}av.prototype=iq.prototype={constructor:av,moveTo:function(t,e){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(t,e){this._+="L"+(this._x1=+t)+","+(this._y1=+e)},quadraticCurveTo:function(t,e,r,n){this._+="Q"+ +t+","+ +e+","+(this._x1=+r)+","+(this._y1=+n)},bezierCurveTo:function(t,e,r,n,a,i){this._+="C"+ +t+","+ +e+","+ +r+","+ +n+","+(this._x1=+a)+","+(this._y1=+i)},arcTo:function(t,e,r,n,a){t=+t,e=+e,r=+r,n=+n,a=+a;var i=this._x1,o=this._y1,l=r-t,s=n-e,f=i-t,c=o-e,h=f*f+c*c;if(a<0)throw new Error("negative radius: "+a);if(this._x1===null)this._+="M"+(this._x1=t)+","+(this._y1=e);else if(h>T3)if(!(Math.abs(c*l-s*f)>T3)||!a)this._+="L"+(this._x1=t)+","+(this._y1=e);else{var d=r-i,m=n-o,g=l*l+s*s,y=d*d+m*m,b=Math.sqrt(g),S=Math.sqrt(h),w=a*Math.tan((rv-Math.acos((g+h-y)/(2*b*S)))/2),C=w/S,k=w/b;Math.abs(C-1)>T3&&(this._+="L"+(t+C*f)+","+(e+C*c)),this._+="A"+a+","+a+",0,0,"+ +(c*d>f*m)+","+(this._x1=t+k*l)+","+(this._y1=e+k*s)}},arc:function(t,e,r,n,a,i){t=+t,e=+e,r=+r,i=!!i;var o=r*Math.cos(n),l=r*Math.sin(n),s=t+o,f=e+l,c=1^i,h=i?n-a:a-n;if(r<0)throw new Error("negative radius: "+r);this._x1===null?this._+="M"+s+","+f:(Math.abs(this._x1-s)>T3||Math.abs(this._y1-f)>T3)&&(this._+="L"+s+","+f),r&&(h<0&&(h=h%nv+nv),h>Wye?this._+="A"+r+","+r+",0,1,"+c+","+(t-o)+","+(e-l)+"A"+r+","+r+",0,1,"+c+","+(this._x1=s)+","+(this._y1=f):h>T3&&(this._+="A"+r+","+r+",0,"+ +(h>=rv)+","+c+","+(this._x1=t+r*Math.cos(a))+","+(this._y1=e+r*Math.sin(a))))},rect:function(t,e,r,n){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)+"h"+ +r+"v"+ +n+"h"+-r+"Z"},toString:function(){return this._}};function YM(t){return function(){return t}}function Uye(t){return t[0]}function Gye(t){return t[1]}var Yye=Array.prototype.slice;function Xye(t){return t.source}function Kye(t){return t.target}function Jye(t){var e=Xye,r=Kye,n=Uye,a=Gye,i=null;function o(){var l,s=Yye.call(arguments),f=e.apply(this,s),c=r.apply(this,s);if(i||(i=l=iq()),t(i,+n.apply(this,(s[0]=f,s)),+a.apply(this,s),+n.apply(this,(s[0]=c,s)),+a.apply(this,s)),l)return i=null,l+""||null}return o.source=function(l){return arguments.length?(e=l,o):e},o.target=function(l){return arguments.length?(r=l,o):r},o.x=function(l){return arguments.length?(n=typeof l=="function"?l:YM(+l),o):n},o.y=function(l){return arguments.length?(a=typeof l=="function"?l:YM(+l),o):a},o.context=function(l){return arguments.length?(i=l??null,o):i},o}function Zye(t,e,r,n,a){t.moveTo(e,r),t.bezierCurveTo(e=(e+n)/2,r,e,a,n,a)}function Qye(){return Jye(Zye)}function eve(t){return[t.source.x1,t.y0]}function tve(t){return[t.target.x0,t.y1]}function rve(){return Qye().source(eve).target(tve)}function nve(t){const{data:e,showLabels:r,leftMargin:n,rightMargin:a,truncateBy:i,width:o,height:l,topMargin:s,bottomMargin:f,tooltip:c,onSeriesMouseOver:h,suffix:d,prefix:m,showValues:g,onSeriesMouseClick:y,nodePadding:b,nodeWidth:S,id:w,highlightedSourceDataPoints:C,highlightedTargetDataPoints:k,defaultLinkOpacity:_,sourceTitle:D,targetTitle:T,animateLinks:A,sortNodes:M,resetSelectionOnDoubleClick:E,detailsOnClick:N,styles:Y,classNames:ne}=t,[K,B]=Xa(),j=d4(K);I.useEffect(()=>{j&&e&&B("path",{pathLength:[0,1]},{duration:A===!0?5:A||0})},[j,e,B,A]);const[$,V]=I.useState(void 0),[z,W]=I.useState(void 0),[G,ae]=I.useState(void 0),[U,H]=I.useState(void 0),[R,ee]=I.useState(void 0),J={top:s,bottom:f,left:n,right:a},Z=o-J.left-J.right,re=l-J.top-J.bottom,te=M==="mostReadable"?Am().nodeWidth(S).nodePadding(b).size([Z,re]).nodeAlign(Om):M==="none"?Am().nodeWidth(S).nodePadding(b).size([Z,re]).nodeAlign(Om).nodeSort(()=>null).linkSort(()=>null):Am().nodeWidth(S).nodePadding(b).size([Z,re]).nodeAlign(Om).nodeSort(M==="desc"?(ie,ce)=>(ce.value||0)-(ie.value||0):(ie,ce)=>(ie.value||0)-(ce.value||0)),{nodes:F,links:q}=te(e),X=rve();return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{width:`${o}px`,height:`${l}px`,viewBox:`0 0 ${o} ${l}`,style:{marginLeft:"auto",marginRight:"auto"},direction:"ltr",children:[D?v.jsx("text",{x:J.left,y:J.top-10,className:"text-base font-bold fill-primary-gray-700 dark:fill-primary-gray-100",style:{textAnchor:"start"},children:D}):null,T?v.jsx("text",{x:o-J.right,y:J.top-10,className:"text-base font-bold fill-primary-gray-700 dark:fill-primary-gray-100",style:{textAnchor:"end"},children:T}):null,v.jsxs("g",{transform:`translate(${J.left},${J.top})`,children:[F.filter(ie=>ie.type==="source").map((ie,ce)=>v.jsx("g",{onMouseEnter:()=>{ae(ie)},onMouseLeave:()=>{ae(void 0)},children:v.jsxs("g",{transform:`translate(${ie.x0},${ie.y0})`,children:[v.jsx("rect",{x:0,y:0,width:(ie.x1||0)-(ie.x0||0),height:(ie.y1||0)-(ie.y0||0),style:{fill:ie.color}}),r||g?v.jsx("foreignObject",{y:0-b/2,x:0-n,width:n,height:(ie.y1||0)-(ie.y0||0)+b,children:v.jsxs("div",{className:"flex flex-col gap-0.5 justify-center py-0 px-1.5",style:{height:`${(ie.y1||0)-(ie.y0||0)+b}px`,overflow:"visible"},children:[r?v.jsx(or,{marginBottom:g?"3xs":"none",size:"sm",leading:"none",className:Be("sankey-right-label text-right",ne==null?void 0:ne.graphObjectValues),style:{hyphens:"auto",color:ie.color,...Y==null?void 0:Y.graphObjectValues},children:`${ie.label}`.length<i?`${ie.label}`:`${`${ie.label}`.substring(0,i)}...`}):null,g?v.jsx(or,{marginBottom:"none",size:"sm",leading:"none",className:Be("sankey-right-value text-right font-bold",ne==null?void 0:ne.graphObjectValues),style:{hyphens:"auto",color:ie.color,...Y==null?void 0:Y.graphObjectValues},children:_t(ie.value,m,d)}):null]})}):null]})},ce)),F.filter(ie=>ie.type==="target").map((ie,ce)=>v.jsx("g",{onMouseEnter:()=>{ae(ie)},onMouseLeave:()=>{ae(void 0)},children:v.jsxs("g",{transform:`translate(${ie.x0},${ie.y0})`,children:[v.jsx("rect",{x:0,y:0,width:(ie.x1||0)-(ie.x0||0),height:(ie.y1||0)-(ie.y0||0),style:{fill:ie.color}}),r||g?v.jsx("foreignObject",{y:0-b/2,x:S,width:a-S,height:(ie.y1||0)-(ie.y0||0)+b,children:v.jsxs("div",{className:"flex flex-col gap-0.5 justify-center py-0 px-1.5",style:{height:`${(ie.y1||0)-(ie.y0||0)+b}px`},children:[r?v.jsx(or,{marginBottom:g?"3xs":"none",size:"sm",leading:"none",className:Be("sankey-left-label text-left",ne==null?void 0:ne.graphObjectValues),style:{hyphens:"auto",color:ie.color,...Y==null?void 0:Y.graphObjectValues},children:`${ie.label}`.length<i?`${ie.label}`:`${`${ie.label}`.substring(0,i)}...`}):null,g?v.jsx(or,{size:"sm",leading:"none",marginBottom:"none",className:Be("sankey-left-value text-left font-bold",ne==null?void 0:ne.graphObjectValues),style:{hyphens:"auto",color:ie.color,...Y==null?void 0:Y.graphObjectValues},children:_t(ie.value,m,d)}):null]})}):null]})},ce)),v.jsx("defs",{children:q.map((ie,ce)=>v.jsxs("linearGradient",{id:`${w}-gradient-${ce}`,x1:"0%",y1:"0%",x2:"100%",y2:"0%",gradientUnits:"userSpaceOnUse",children:[v.jsx("stop",{offset:"0%",style:{stopColor:ie.source.color,stopOpacity:1}}),v.jsx("stop",{offset:"100%",style:{stopColor:ie.target.color,stopOpacity:1}})]},ce))}),v.jsx("g",{ref:K,children:q.map((ie,ce)=>v.jsx("g",{className:"undp-viz-g-with-hover",onMouseEnter:de=>{V(ie.data),ee(de.clientY),H(de.clientX),h==null||h(ie.data)},onMouseMove:de=>{V(ie.data),ee(de.clientY),H(de.clientX)},onClick:()=>{(y||N)&&(Sr(z,ie.data)&&E?(W(void 0),y==null||y(void 0)):(W(ie.data),y==null||y(ie.data)))},onMouseLeave:()=>{V(void 0),H(void 0),ee(void 0),h&&h(void 0)},opacity:G?ie.source.name===G.name||ie.target.name===G.name?.85:_:(C.length!==0||k.length!==0)&&(C.indexOf(ie.source.label)!==-1||k.indexOf(ie.target.label)!==-1)?.85:_,children:v.jsx("path",{d:X(ie)||"",style:{stroke:`url(#${w}-gradient-${ce})`,strokeWidth:ie.width,fill:"none"}})},ce))})]})]}),$&&c&&U&&R?v.jsx(yr,{data:$,body:c,xPos:U,yPos:R,backgroundStyle:Y==null?void 0:Y.tooltip,className:ne==null?void 0:ne.tooltip}):null,N?v.jsx(Tr,{open:z!==void 0,onClose:()=>{W(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(N,z)}})}):null]})}function oq(t){const{data:e,graphTitle:r,sources:n,graphDescription:a,showLabels:i=!0,leftMargin:o=75,rightMargin:l=75,topMargin:s=30,bottomMargin:f=10,truncateBy:c=999,height:h,width:d,footNote:m,padding:g,backgroundColor:y,tooltip:b,onSeriesMouseOver:S,suffix:w="",prefix:C="",relativeHeight:k,showValues:_=!0,graphID:D,onSeriesMouseClick:T,graphDownload:A=!1,dataDownload:M=!1,fillContainer:E=!0,language:N="en",minHeight:Y=0,theme:ne="light",ariaLabel:K,sourceColors:B,targetColors:j,sourceColorDomain:$,targetColorDomain:V,nodePadding:z=5,nodeWidth:W=5,highlightedSourceDataPoints:G=[],highlightedTargetDataPoints:ae=[],defaultLinkOpacity:U=.3,sourceTitle:H,targetTitle:R,animateLinks:ee,sortNodes:J="mostReadable",resetSelectionOnDoubleClick:Z=!0,detailsOnClick:re,styles:te,classNames:F}=t,[q,X]=I.useState(0),[ie,ce]=I.useState(0),[de,he]=I.useState(void 0),Oe=I.useRef(null),Ne=I.useRef(null);return I.useEffect(()=>{const Te=Bt(e,"source").map(ve=>({name:`source_${ve.source}`,type:"source",label:`${ve.source}`,color:typeof B=="string"||!B?B||Qe.graphMainColor:B[($||Bt(e,"source").map(le=>`${le.source}`)).findIndex(le=>`${le}`==`${ve.source}`)>B.length?B.length-1:($||Bt(e,"source").map(le=>`${le.source}`)).findIndex(le=>`${le}`==`${ve.source}`)],totalValue:fr(e.filter(le=>`${le.source}`==`${ve.source}`).map(le=>le.value))})),_e=J==="asc"?Ut(Te,ve=>ve.totalValue):J==="desc"?Ut(Te,ve=>ve.totalValue).reverse():Te,xe=Bt(e,"target").map(ve=>({name:`target_${ve.target}`,type:"target",label:`${ve.target}`,color:typeof j=="string"||!j?j||Qe.graphMainColor:j[(V||Bt(e,"target").map(le=>`${le.target}`)).findIndex(le=>`${le}`==`${ve.target}`)>j.length?j.length-1:(V||Bt(e,"target").map(le=>`${le.target}`)).findIndex(le=>`${le}`==`${ve.target}`)],totalValue:fr(e.filter(le=>`${le.target}`==`${ve.target}`).map(le=>le.value))})),we=J==="asc"?Ut(xe,ve=>ve.totalValue):J==="desc"?Ut(xe,ve=>ve.totalValue).reverse():xe,ge=[..._e,...we];he({nodes:ge,links:e.map(ve=>({source:ge.findIndex(le=>le.name===`source_${ve.source}`),target:ge.findIndex(le=>le.name===`target_${ve.target}`),value:ve.value,data:{...ve}}))})},[e,J,$,B,V,j]),I.useEffect(()=>{const Te=new ResizeObserver(_e=>{X(d||_e[0].target.clientWidth||620),ce(h||_e[0].target.clientHeight||480)});return Oe.current&&(ce(Oe.current.clientHeight||480),X(Oe.current.clientWidth||620),d||Te.observe(Oe.current)),()=>Te.disconnect()},[d,h]),v.jsx("div",{className:`${ne||"light"} flex ${d?"grow-0":"grow"} ${E?"w-full":"w-fit"} `,dir:N==="he"||N==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${y?y===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${N||"en"}`,F==null?void 0:F.graphContainer),style:{...(te==null?void 0:te.graphContainer)||{},...y&&y!==!0?{backgroundColor:y}:{}},id:D,ref:Ne,"aria-label":K||`${r?`The graph shows ${r}. `:""}This is a sankey chart showing flow. ${a?` ${a}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:y?g||"1rem":g||0},children:v.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[r||a||A||M?v.jsx(Zt,{styles:{title:te==null?void 0:te.title,description:te==null?void 0:te.description},classNames:{title:F==null?void 0:F.title,description:F==null?void 0:F.description},graphTitle:r,graphDescription:a,width:d,graphDownload:A?Ne.current:void 0,dataDownload:M?e.map(Te=>Te.data).filter(Te=>Te!==void 0).length>0?e.map(Te=>Te.data).filter(Te=>Te!==void 0):e.filter(Te=>Te!==void 0):null}):null,v.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:e.length===0?v.jsx(kn,{}):v.jsx("div",{className:"flex flex-col grow justify-center gap-3 w-full leading-0",ref:Oe,"aria-label":"Graph area",children:(d||q)&&(h||ie)&&de?v.jsx(nve,{data:de,width:d||q,nodePadding:z,nodeWidth:W,height:Math.max(Y,h||(k?Y?(d||q)*k>Y?(d||q)*k:Y:(d||q)*k:ie)),showLabels:i,leftMargin:o,rightMargin:l,topMargin:s,bottomMargin:f,truncateBy:c,tooltip:b,onSeriesMouseOver:S,showValues:_,suffix:w,prefix:C,onSeriesMouseClick:T,id:Wx(8),highlightedSourceDataPoints:G.map(Te=>`${Te}`),highlightedTargetDataPoints:ae.map(Te=>`${Te}`),defaultLinkOpacity:U,sourceTitle:H,targetTitle:R,animateLinks:ee,sortNodes:J,resetSelectionOnDoubleClick:Z,styles:te,classNames:F,detailsOnClick:re}):null})}),n||m?v.jsx(tr,{styles:{footnote:te==null?void 0:te.footnote,source:te==null?void 0:te.source},classNames:{footnote:F==null?void 0:F.footnote,source:F==null?void 0:F.source},sources:n,footNote:m,width:d}):null]})})})})}function ave(t){const{data:e,radius:r,lineColors:n,tooltip:a,onSeriesMouseOver:i,onSeriesMouseClick:o,colorDomain:l,detailsOnClick:s,styles:f,classNames:c,selectedColor:h,axisLabels:d,strokeWidth:m,showValues:g,showDots:y,rightMargin:b,topMargin:S,bottomMargin:w,leftMargin:C,curveType:k,noOfTicks:_,minValue:D,maxValue:T,resetSelectionOnDoubleClick:A,fillShape:M,highlightedLines:E}=t,N=k==="linear"?u7e:s7e,Y={top:S,left:C},ne=Math.min((2*r-C-b)/2,(2*r-S-w)/2),[K,B]=I.useState(void 0),[j,$]=I.useState(void 0),[V,z]=I.useState(void 0),[W,G]=I.useState(void 0),ae=br().domain([0,e[0].values.length]).range([0,2*Math.PI]),U=Fe(T)?Math.max(...e.map(Z=>Mn(Z.values.filter(re=>!Fe(re)))||0))<0?0:Math.max(...e.map(Z=>Mn(Z.values.filter(re=>!Fe(re)))||0)):T,H=Fe(D)?Math.min(...e.map(Z=>gr(Z.values.filter(re=>!Fe(re)))||0))>=0?0:Math.min(...e.map(Z=>gr(Z.values.filter(re=>!Fe(re)))||0)):D,R=br().domain([H,U]).range([0,ne]).nice(),ee=R.ticks(_),J=l7e().radius((Z,re)=>R(Z)).angle((Z,re)=>ae(re)).curve(N);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r*2}px`,height:`${r*2}px`,viewBox:`0 0 ${r*2} ${r*2}`,direction:"ltr",children:v.jsx("g",{transform:`translate(${Y.left},${Y.top})`,children:v.jsxs("g",{transform:`translate(${ne},${ne})`,children:[d.map((Z,re)=>{var te,F,q,X;return v.jsxs("g",{children:[v.jsx("line",{x1:0,y1:0,x2:Math.cos(ae(re)-Math.PI/2)*ne,y2:Math.sin(ae(re)-Math.PI/2)*ne,className:Be("stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550",(te=c==null?void 0:c.xAxis)==null?void 0:te.axis),style:(F=f==null?void 0:f.xAxis)==null?void 0:F.axis},re),v.jsx("text",{x:Math.cos(ae(re)-Math.PI/2)*(ne+6),y:Math.sin(ae(re)-Math.PI/2)*(ne+6),style:{textAnchor:Math.cos(ae(re)-Math.PI/2)<0?"end":Math.cos(ae(re)-Math.PI/2)<1e-5?"middle":"start",...((q=f==null?void 0:f.xAxis)==null?void 0:q.labels)||""},dy:Math.sin(ae(re)-Math.PI/2)<0?0:Math.sin(ae(re)-Math.PI/2)<1e-5?5:10,className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(X=c==null?void 0:c.xAxis)==null?void 0:X.labels),children:Z})]},re)}),ee.map((Z,re)=>{var te,F,q,X;return v.jsxs("g",{children:[v.jsx("path",{d:J(Array(d.length).fill(Z))||"",className:Be("stroke-primary-gray-500 dark:stroke-primary-gray-550",(te=c==null?void 0:c.xAxis)==null?void 0:te.gridLines),style:{...(F=f==null?void 0:f.xAxis)==null?void 0:F.gridLines,fill:"none"}}),v.jsx("foreignObject",{x:-25,y:Math.sin(-Math.PI/2)*R(Z)>-1e-4?Math.sin(-Math.PI/2)*R(Z)-7:Math.sin(-Math.PI/2)*R(Z)-5,width:50,height:12,children:v.jsx("div",{className:"flex justify-center",children:v.jsx("p",{className:Be("fill-primary-gray-500 dark:fill-primary-gray-550 text-xs m-0 py-0 px-1.5 text-center leading-none bg-primary-white dark:bg-primary-gray-700",(q=c==null?void 0:c.xAxis)==null?void 0:q.labels),style:(X=f==null?void 0:f.xAxis)==null?void 0:X.labels,children:Z})})})]},re)}),e.map((Z,re)=>v.jsxs("g",{opacity:K?Z.label===K.label?1:.3:h?Z.color&&n[l.indexOf(Z.color)]===h?1:.3:E.length!==0?Z.label&&E.indexOf(Z.label)!==-1?1:.3:1,onMouseEnter:te=>{B(Z),G(te.clientY),z(te.clientX),i&&i(Z)},onMouseMove:te=>{B(Z),G(te.clientY),z(te.clientX)},onMouseLeave:()=>{B(void 0),z(void 0),G(void 0),i&&i(void 0)},onClick:()=>{(o||s)&&(Sr(j,Z)&&A?($(void 0),o==null||o(void 0)):($(Z),o==null||o(Z)))},children:[v.jsx("path",{d:J(Z.values)||"",style:{stroke:e.filter(te=>te.color).length===0?n[0]:Z.color?n[l.indexOf(Z.color)]:Qe.gray,fill:M?e.filter(te=>te.color).length===0?n[0]:Z.color?n[l.indexOf(Z.color)]:Qe.gray:"none",fillOpacity:.1,strokeWidth:m}}),v.jsx("g",{children:Z.values.map((te,F)=>v.jsx("g",{children:Fe(te)?null:v.jsxs(v.Fragment,{children:[y?v.jsx("circle",{cx:Math.cos(ae(F)-Math.PI/2)*R(te),cy:Math.sin(ae(F)-Math.PI/2)*R(te),r:4,style:{fill:e.filter(q=>q.color).length===0?n[0]:Z.color?n[l.indexOf(Z.color)]:Qe.gray}}):null,g?v.jsx("text",{cx:Math.cos(ae(F)-Math.PI/2)*(R(te)+6),cy:Math.sin(ae(F)-Math.PI/2)*(R(te)+6),style:{fill:n[re],textAnchor:Math.cos(ae(F)-Math.PI/2)<0?"end":Math.cos(ae(F)-Math.PI/2)<1e-5?"middle":"start",...(f==null?void 0:f.graphObjectValues)||{}},dy:Math.sin(ae(F)-Math.PI/2)<0?10:(Math.sin(ae(F)-Math.PI/2)<1e-5,0),className:Be("graph-value text-xs font-bold",c==null?void 0:c.graphObjectValues),children:_t(te)}):null]})},F))})]},re))]})})}),K&&a&&V&&W?v.jsx(yr,{data:K,body:a,xPos:V,yPos:W,backgroundStyle:f==null?void 0:f.tooltip,className:c==null?void 0:c.tooltip}):null,s?v.jsx(Tr,{open:j!==void 0,onClose:()=>{$(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(s,j)}})}):null]})}function lq(t){const{graphTitle:e,colors:r,sources:n,graphDescription:a,footNote:i,radius:o,data:l,showColorScale:s=!0,padding:f,backgroundColor:c=!1,tooltip:h,onSeriesMouseOver:d,graphID:m,onSeriesMouseClick:g,topMargin:y=75,bottomMargin:b=75,leftMargin:S=75,rightMargin:w=75,graphDownload:C=!1,dataDownload:k=!1,colorDomain:_,language:D="en",theme:T="light",highlightedLines:A=[],width:M,height:E,minHeight:N=0,strokeWidth:Y=2,relativeHeight:ne,ariaLabel:K,colorLegendTitle:B,detailsOnClick:j,styles:$,classNames:V,showNAColor:z=!0,axisLabels:W,showDots:G=!0,showValues:ae=!1,curveType:U="curve",noOfTicks:H=5,minValue:R,maxValue:ee,fillShape:J=!1,resetSelectionOnDoubleClick:Z=!0}=t,[re,te]=I.useState(0),[F,q]=I.useState(0),[X,ie]=I.useState(0),[ce,de]=I.useState(void 0),he=I.useRef(null),Oe=I.useRef(null);return I.useEffect(()=>{const Ne=new ResizeObserver(Te=>{q(M||Te[0].target.clientWidth||420),ie(E||Te[0].target.clientHeight||420),te((gr([M||Te[0].target.clientWidth||620,E||Te[0].target.clientHeight||480])||420)/2)});return he.current&&(ie(he.current.clientHeight||420),q(he.current.clientWidth||420),te((gr([he.current.clientWidth,he.current.clientHeight])||420)/2),(!M||!o)&&Ne.observe(he.current)),()=>Ne.disconnect()},[M,E,o]),v.jsx("div",{className:`${T||"light"} flex ${M?"w-fit grow-0":"w-full grow"}`,dir:D==="he"||D==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${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"}`,V==null?void 0:V.graphContainer),style:{...($==null?void 0:$.graphContainer)||{},minHeight:"inherit",...c&&c!==!0?{backgroundColor:c}:{}},id:m,ref:Oe,"aria-label":K||`${e?`The graph shows ${e}. `:""}This is a donut or pie chart chart. ${a?` ${a}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:c?f||"1rem":f||0},children:v.jsxs("div",{className:"flex flex-col gap-2 w-full grow justify-between",children:[e||a||C||k?v.jsx(Zt,{styles:{title:$==null?void 0:$.title,description:$==null?void 0:$.description},classNames:{title:V==null?void 0:V.title,description:V==null?void 0:V.description},graphTitle:e,graphDescription:a,width:M,graphDownload:C?Oe.current:void 0,dataDownload:k?l.map(Ne=>Ne.data).filter(Ne=>Ne!==void 0).length>0?l.map(Ne=>Ne.data).filter(Ne=>Ne!==void 0):l.filter(Ne=>Ne!==void 0):null}):null,v.jsx("div",{className:"flex grow flex-col justify-center items-stretch gap-8 flex-wrap",style:{width:M?`${M}px`:"100%"},children:l.length===0?v.jsx(kn,{}):v.jsxs(v.Fragment,{children:[s&&l.filter(Ne=>Ne.color).length!==0?v.jsx(Cn,{width:M,colorLegendTitle:B,colors:r||Qe[T].categoricalColors.colors,colorDomain:_||Bt(l.filter(Ne=>Ne.color),"color").map(Ne=>Ne.color),setSelectedColor:de,showNAColor:z}):null,v.jsx("div",{className:`flex ${M?"grow-0":"grow"} items-center justify-center leading-0`,style:{width:M?`${M}px`:"100%",height:E?`${Math.max(N,E||(ne?N?(M||F)*ne>N?(M||F)*ne:N:(M||F)*ne:X))}px`:"auto"},ref:he,"aria-label":"Graph area",children:v.jsx("div",{className:"w-full flex justify-center leading-0",children:o||re?v.jsx(ave,{data:l,lineColors:l.filter(Ne=>Ne.color).length===0?r?[r]:[Qe.primaryColors["blue-600"]]:r||Qe[T].categoricalColors.colors,radius:o||re,tooltip:h,colorDomain:_||Bt(l.filter(Ne=>Ne.color),"color").map(Ne=>Ne.color),onSeriesMouseOver:d,onSeriesMouseClick:g,styles:$,detailsOnClick:j,selectedColor:ce,axisLabels:W,strokeWidth:Y,showValues:ae,showDots:G,topMargin:y,bottomMargin:b,leftMargin:S,rightMargin:w,curveType:U,noOfTicks:H,minValue:R,maxValue:ee,fillShape:J,highlightedLines:A,resetSelectionOnDoubleClick:Z}):null})})]})}),n||i?v.jsx(tr,{styles:{footnote:$==null?void 0:$.footnote,source:$==null?void 0:$.source},classNames:{footnote:V==null?void 0:V.footnote,source:V==null?void 0:V.source},sources:n,footNote:i,width:M}):v.jsx("div",{})]})})})})}function sq(t,e){const r=Array.from(new Set(t.map(l=>l.label))),n=Array.from(new Set(t.map(l=>l.date))),a=new Set(t.map(l=>`${l.label}-${l.date}`)),i=t.reduce((l,s)=>(l[s.label]||(l[s.label]=s.color),l),{}),o=[...t];return r.forEach(l=>{n.forEach(s=>{a.has(`${l}-${s}`)||o.push({label:l,color:i[l],size:void 0,date:s})})}),Ut(o,l=>bt(`${l.date}`,e||"yyyy",new Date))}function Vf(t,e){const r=Array.from(new Set(t.map(o=>o.label))),n=Array.from(new Set(t.map(o=>o.date))),a=new Set(t.map(o=>`${o.label}-${o.date}`)),i=[...t];return r.forEach(o=>{n.forEach(l=>{a.has(`${o}-${l}`)||i.push({label:o,size:t[0].size.map(s=>null),date:l})})}),Ut(i,o=>bt(`${o.date}`,e||"yyyy",new Date))}function ive(t,e){const r=Array.from(new Set(t.map(o=>o.label))),n=Array.from(new Set(t.map(o=>o.date))),a=new Set(t.map(o=>`${o.label}-${o.date}`)),i=[...t];return r.forEach(o=>{n.forEach(l=>{a.has(`${o}-${l}`)||i.push({label:o,leftBar:void 0,rightBar:void 0,date:l})})}),Ut(i,o=>bt(`${o.date}`,e,new Date))}function ove(t,e){const r=Array.from(new Set(t.map(l=>l.label))),n=Array.from(new Set(t.map(l=>l.date))),a=new Set(t.map(l=>`${l.label}-${l.date}`)),i=t.reduce((l,s)=>(l[s.label]||(l[s.label]=s.color),l),{}),o=[...t];return r.forEach(l=>{n.forEach(s=>{a.has(`${l}-${s}`)||o.push({label:l,color:i[l],x:void 0,y:void 0,radius:void 0,date:s})})}),Ut(o,l=>bt(`${l.date}`,e,new Date))}function uq(t,e){const r=Array.from(new Set(t.map(o=>o.label))),n=Array.from(new Set(t.map(o=>o.date))),a=new Set(t.map(o=>`${o.label}-${o.date}`)),i=[...t];return r.forEach(o=>{n.forEach(l=>{a.has(`${o}-${l}`)||i.push({label:o,x:t[0].x.map(s=>null),date:l})})}),Ut(i,o=>bt(`${o.date}`,e||"yyyy",new Date))}function lve(t){var Ne,Te,_e,xe,we,ge,ve,le,ue,Ce,pe,ye,be,je,$e,ut;const{data:e,width:r,height:n,barColors:a,centerGap:i,refValues:o,maxValue:l,minValue:s,showValues:f,axisTitles:c,rightMargin:h,leftMargin:d,topMargin:m,bottomMargin:g,tooltip:y,onSeriesMouseOver:b,barPadding:S,truncateBy:w,onSeriesMouseClick:C,showTicks:k,suffix:_,prefix:D,dateFormat:T,indx:A,resetSelectionOnDoubleClick:M,detailsOnClick:E,styles:N,classNames:Y,noOfTicks:ne}=t,K=Ut(e.map(Ie=>({...Ie,date:bt(`${Ie.date}`,T,new Date)})),"date"),B=Bt(K,Ie=>Ie.label).map(Ie=>Ie.label),j=Array.from(Hi(ive(e,T||"yyyy"),Ie=>Ie.date),([Ie,Ze])=>({date:Ie,values:B.map(Ke=>Ze.find(et=>et.label===Ke)).map(Ke=>({...Ke,id:Ke.label}))})),[$,V]=I.useState(void 0),[z,W]=I.useState(void 0),[G,ae]=I.useState(void 0),[U,H]=I.useState(void 0),R={top:m,bottom:g,left:d,right:h},ee=r-R.left-R.right,J=n-R.top-R.bottom,Z=Un().domain(B.map(Ie=>`${Ie}`)).range([J,0]).paddingInner(S),re=Fe(l)?Math.max(...e.filter(Ie=>!Fe(Ie.leftBar)).map(Ie=>Ie.leftBar))<0?0:Math.max(...e.filter(Ie=>!Fe(Ie.leftBar)).map(Ie=>Ie.leftBar)):l,te=Fe(s)?Math.min(...e.filter(Ie=>!Fe(Ie.leftBar)).map(Ie=>Ie.leftBar))>=0?0:Math.min(...e.filter(Ie=>!Fe(Ie.leftBar)).map(Ie=>Ie.leftBar)):s,F=Fe(l)?Math.max(...e.filter(Ie=>!Fe(Ie.rightBar)).map(Ie=>Ie.rightBar))<0?0:Math.max(...e.filter(Ie=>!Fe(Ie.rightBar)).map(Ie=>Ie.rightBar)):l,q=Fe(s)?Math.min(...e.filter(Ie=>!Fe(Ie.rightBar)).map(Ie=>Ie.rightBar))>=0?0:Math.min(...e.filter(Ie=>!Fe(Ie.rightBar)).map(Ie=>Ie.rightBar)):s,X=te<q?te:q,ie=re>F?re:F,ce=br().domain([X,ie]).range([0,(ee-i)/2]).nice(),de=ce.ticks(ne),he=br().domain([X,ie]).range([(ee-i)/2,0]).nice(),Oe=he.ticks(ne);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${R.left},${R.top})`,children:[v.jsxs("g",{transform:"translate(0,0)",children:[k?v.jsx(La,{values:Oe.filter(Ie=>Ie!==0),x:Oe.filter(Ie=>Ie!==0).map(Ie=>he(Ie)),y1:0-m,y2:J+R.bottom,styles:{gridLines:(Ne=N==null?void 0:N.xAxis)==null?void 0:Ne.gridLines,labels:(Te=N==null?void 0:N.xAxis)==null?void 0:Te.labels},classNames:{gridLines:(_e=Y==null?void 0:Y.xAxis)==null?void 0:_e.gridLines,labels:(xe=Y==null?void 0:Y.xAxis)==null?void 0:xe.labels},suffix:_,prefix:D,labelType:"secondary",showGridLines:!0,leftLabel:!0}):null,v.jsx(mo,{children:j[A].values.map((Ie,Ze)=>v.jsxs(ur.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:Ke=>{V(Ie),H(Ke.clientY),ae(Ke.clientX),b&&b(Ie)},onClick:()=>{(C||E)&&(Sr(z,Ie)&&M?(W(void 0),C==null||C(void 0)):(W(Ie),C==null||C(Ie)))},onMouseMove:Ke=>{V(Ie),H(Ke.clientY),ae(Ke.clientX)},onMouseLeave:()=>{V(void 0),ae(void 0),H(void 0),b&&b(void 0)},children:[v.jsx(ur.rect,{style:{fill:a[0]},height:Z.bandwidth(),animate:{width:Ie.leftBar?Ie.leftBar<0?he(Ie.leftBar)-he(0):he(0)-he(Ie.leftBar):0,attrY:Z(`${Ie.label}`),attrX:Ie.leftBar?Ie.leftBar<0?he(0):he(Ie.leftBar):he(0)},transition:{duration:.5}}),f?v.jsx(ur.text,{style:{fill:a[0],textAnchor:Ie.rightBar&&Ie.rightBar>0?"end":"start",...(N==null?void 0:N.graphObjectValues)||{}},dx:Ie.leftBar&&Ie.leftBar>0?-5:5,dy:"0.33em",animate:{attrX:Ie.leftBar?he(Ie.leftBar):he(te<0?0:te),attrY:Z(`${Ie.label}`)+Z.bandwidth()/2},transition:{duration:.5},className:Be("graph-value text-sm",Y==null?void 0:Y.graphObjectValues),children:_t(Ie.leftBar,D,_)}):null]},Ie.label))}),v.jsx(Nr,{y1:-2.5,y2:J+R.bottom,x1:he(te<0?0:te),x2:he(te<0?0:te),classNames:{axis:(we=Y==null?void 0:Y.yAxis)==null?void 0:we.axis},styles:{axis:(ge=N==null?void 0:N.yAxis)==null?void 0:ge.axis}}),o?v.jsx(v.Fragment,{children:o.map((Ie,Ze)=>v.jsx(ti,{text:Ie.text,color:Ie.color,x:he(Ie.value),y1:0-R.top,y2:J+R.bottom,textSide:"left",classNames:Ie.classNames,styles:Ie.styles},Ze))}):null]}),v.jsxs("g",{transform:`translate(${(ee+i)/2},0)`,children:[k?v.jsx(La,{values:de.filter(Ie=>Ie!==0),x:de.filter(Ie=>Ie!==0).map(Ie=>ce(Ie)),y1:0-m,y2:J+R.bottom,styles:{gridLines:(ve=N==null?void 0:N.xAxis)==null?void 0:ve.gridLines,labels:(le=N==null?void 0:N.xAxis)==null?void 0:le.labels},classNames:{gridLines:(ue=Y==null?void 0:Y.xAxis)==null?void 0:ue.gridLines,labels:(Ce=Y==null?void 0:Y.xAxis)==null?void 0:Ce.labels},suffix:_,prefix:D,labelType:"secondary",showGridLines:!0}):null,v.jsx(mo,{children:j[A].values.map((Ie,Ze)=>v.jsxs(ur.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:Ke=>{V(Ie),H(Ke.clientY),ae(Ke.clientX),b&&b(Ie)},onClick:()=>{(C||E)&&(Sr(z,Ie)&&M?(W(void 0),C==null||C(void 0)):(W(Ie),C==null||C(Ie)))},onMouseMove:Ke=>{V(Ie),H(Ke.clientY),ae(Ke.clientX)},onMouseLeave:()=>{V(void 0),ae(void 0),H(void 0),b&&b(void 0)},children:[v.jsx(ur.rect,{style:{fill:a[1]},height:Z.bandwidth(),animate:{width:Ie.rightBar?Ie.rightBar>=0?ce(Ie.rightBar)-ce(0):ce(0)-ce(Ie.rightBar):0,attrY:Z(`${Ie.label}`),attrX:Ie.rightBar?Ie.rightBar>=0?ce(0):ce(Ie.rightBar):ce(0)},transition:{duration:.5}}),f?v.jsx(ur.text,{style:{fill:a[1],textAnchor:Ie.rightBar&&Ie.rightBar<0?"end":"start",...(N==null?void 0:N.graphObjectValues)||{}},className:Be("graph-value text-sm",Y==null?void 0:Y.graphObjectValues),dx:Ie.rightBar&&Ie.rightBar<0?-5:5,dy:"0.33em",animate:{attrX:Ie.rightBar?ce(Ie.rightBar):ce(q<0?0:q),attrY:Z(`${Ie.label}`)+Z.bandwidth()/2},transition:{duration:.5},children:_t(Ie.rightBar,D,_)}):null]},Ze))}),v.jsx(Nr,{y1:-2.5,y2:J+R.bottom,x1:ce(q<0?0:q),x2:ce(q<0?0:q),classNames:{axis:(pe=Y==null?void 0:Y.yAxis)==null?void 0:pe.axis},styles:{axis:(ye=N==null?void 0:N.yAxis)==null?void 0:ye.axis}}),o?v.jsx(v.Fragment,{children:o.map((Ie,Ze)=>v.jsx(ti,{text:Ie.text,color:Ie.color,x:ce(Ie.value),y1:0-R.top,y2:J+R.bottom,textSide:"right",classNames:Ie.classNames,styles:Ie.styles},Ze))}):null]}),v.jsx("g",{transform:`translate(${ee/2},0)`,children:j[A].values.map((Ie,Ze)=>{var Ke,et;return v.jsx(Y2,{value:`${Ie.label}`.length<w?`${Ie.label}`:`${`${Ie.label}`.substring(0,w)}...`,y:Z(`${Ie.id}`),x:0-i/2,width:i,height:Z.bandwidth(),alignment:"center",style:(Ke=N==null?void 0:N.yAxis)==null?void 0:Ke.labels,className:(et=Y==null?void 0:Y.yAxis)==null?void 0:et.labels},Ze)})}),v.jsxs("g",{transform:`translate(0,${J})`,children:[v.jsx("text",{style:{fill:a[0],textAnchor:"end",...(be=N==null?void 0:N.yAxis)==null?void 0:be.title},className:Be("text-base",(je=Y==null?void 0:Y.yAxis)==null?void 0:je.title),x:ee/2-i/2,y:0,dx:-5,dy:20,children:c[0]}),v.jsx("text",{style:{fill:a[1],textAnchor:"start",...($e=N==null?void 0:N.yAxis)==null?void 0:$e.title},className:Be("text-base",(ut=Y==null?void 0:Y.yAxis)==null?void 0:ut.title),x:ee/2+i/2,y:0,dx:5,dy:20,children:c[1]})]})]})}),$&&y&&G&&U?v.jsx(yr,{data:$,body:y,xPos:G,yPos:U,backgroundStyle:N==null?void 0:N.tooltip,className:Y==null?void 0:Y.tooltip}):null,E?v.jsx(Tr,{open:z!==void 0,onClose:()=>{W(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(E,z)}})}):null]})}function cq(t){const{data:e,graphTitle:r,sources:n,graphDescription:a,height:i,width:o,footNote:l,padding:s,leftBarColor:f=Qe.light.categoricalColors.colors[0],rightBarColor:c=Qe.light.categoricalColors.colors[1],backgroundColor:h=!1,leftMargin:d=20,rightMargin:m=20,topMargin:g=25,bottomMargin:y=30,rightBarTitle:b="Right bar graph",leftBarTitle:S="Left bar graph",barPadding:w=.25,truncateBy:C=999,onSeriesMouseClick:k,centerGap:_=100,showValues:D=!0,tooltip:T,relativeHeight:A,onSeriesMouseOver:M,graphID:E,refValues:N=[],suffix:Y="",prefix:ne="",showTicks:K=!0,showColorScale:B=!1,graphDownload:j=!1,dataDownload:$=!1,language:V="en",maxValue:z,minValue:W,dateFormat:G="yyyy",showOnlyActiveDate:ae=!1,autoPlay:U=!1,colorLegendTitle:H,minHeight:R=0,theme:ee="light",ariaLabel:J,resetSelectionOnDoubleClick:Z=!0,detailsOnClick:re,styles:te,classNames:F,noOfTicks:q=5}=t,[X,ie]=I.useState(0),[ce,de]=I.useState(0),he=I.useRef(null),Oe=I.useRef(null);I.useEffect(()=>{const ve=new ResizeObserver(le=>{ie(o||le[0].target.clientWidth||620),de(i||le[0].target.clientHeight||480)});return he.current&&(de(he.current.clientHeight||480),ie(he.current.clientWidth||620),o||ve.observe(he.current)),()=>ve.disconnect()},[o,i]);const[Ne,Te]=I.useState(U),_e=qi(Bt(e,ve=>ve.date).map(ve=>bt(`${ve.date}`,G,new Date).getTime()),(ve,le)=>Ka(ve,le)),[xe,we]=I.useState(U?0:_e.length-1),ge={};return _e.forEach((ve,le)=>{ge[`${ve}`]={style:{color:le===xe?"#232E3D":"#A9B1B7",fontWeight:le===xe?"bold":"normal",display:le===xe||!ae?"inline":"none"},label:Sa(new Date(ve),G)}}),I.useEffect(()=>{const ve=setInterval(()=>{we(le=>le<_e.length-1?le+1:0)},2e3);return Ne||clearInterval(ve),()=>clearInterval(ve)},[_e,Ne]),v.jsx("div",{className:`${ee||"light"} flex ${o?"w-fit grow-0":"w-full grow"}`,dir:V==="he"||V==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${h?h===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${V||"en"}`,F==null?void 0:F.graphContainer),style:{...(te==null?void 0:te.graphContainer)||{},...h&&h!==!0?{backgroundColor:h}:{}},id:E,ref:Oe,"aria-label":J||`${r?`The graph shows ${r}. `:""}This is an animated diverging bar chart showing data changes over time. ${a?` ${a}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:h?s||"1rem":s||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||a||j||$?v.jsx(Zt,{styles:{title:te==null?void 0:te.title,description:te==null?void 0:te.description},classNames:{title:F==null?void 0:F.title,description:F==null?void 0:F.description},graphTitle:r,graphDescription:a,width:o,graphDownload:j?Oe.current:void 0,dataDownload:$?e.map(ve=>ve.data).filter(ve=>ve!==void 0).length>0?e.map(ve=>ve.data).filter(ve=>ve!==void 0):e.filter(ve=>ve!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{Te(!Ne)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":Ne?"Click to pause animation":"Click to play animation",children:Ne?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:_e[0],max:_e[_e.length-1],marks:ge,step:null,defaultValue:_e[_e.length-1],value:_e[xe],onChangeComplete:ve=>{we(_e.indexOf(ve))},onChange:ve=>{we(_e.indexOf(ve))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[B?v.jsx(g0,{colorLegendTitle:H,colorDomain:[S,b],colors:[f,c],showNAColor:!1}):null,v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:he,"aria-label":"Graph area",children:(o||X)&&(i||ce)?v.jsx(lve,{data:e,barColors:[f,c],width:o||X,centerGap:_,height:Math.max(R,i||(A?R?(o||X)*A>R?(o||X)*A:R:(o||X)*A:ce)),truncateBy:C,leftMargin:d,rightMargin:m,topMargin:g,bottomMargin:y,axisTitles:[S,b],tooltip:T,onSeriesMouseOver:M,barPadding:w,refValues:N,maxValue:z,minValue:W,showValues:Fe(D)?!0:D,onSeriesMouseClick:k,showTicks:K,suffix:Y,prefix:ne,dateFormat:G,indx:xe,resetSelectionOnDoubleClick:Z,detailsOnClick:re,styles:te,classNames:F,noOfTicks:q}):null})]}),n||l?v.jsx(tr,{styles:{footnote:te==null?void 0:te.footnote,source:te==null?void 0:te.source},classNames:{footnote:F==null?void 0:F.footnote,source:F==null?void 0:F.source},sources:n,footNote:l,width:o}):null]})})})})}function sve(t){const{data:e,xDomain:r,mapData:n,xColorLegendTitle:a,yDomain:i,yColorLegendTitle:o,width:l,height:s,colors:f,scale:c,centerPoint:h,mapBorderWidth:d,mapNoDataColor:m,mapBorderColor:g,tooltip:y,onSeriesMouseOver:b,zoomScaleExtend:S,zoomTranslateExtend:w,highlightedIds:C,onSeriesMouseClick:k,mapProperty:_,dateFormat:D,indx:T,resetSelectionOnDoubleClick:A,detailsOnClick:M,showColorScale:E,styles:N,classNames:Y,mapProjection:ne}=t,K=Array.from(Hi(Ut(e,ge=>bt(`${ge.date}`,D||"yyyy",new Date)),ge=>ge.date),([ge,ve])=>({date:ge,values:ve})),[B,j]=I.useState(!(l<680)),$=I.useRef(null),[V,z]=I.useState(50),[W,G]=I.useState(void 0),[ae,U]=I.useState(void 0),[H,R]=I.useState(void 0),[ee,J]=I.useState(void 0),[Z,re]=I.useState(void 0),te=I.useRef(null),F=I.useRef(null),q=Array.from({length:r.length},(ge,ve)=>ve),X=Array.from({length:i.length},(ge,ve)=>ve),ie=P2().domain(r).range(q),ce=P2().domain(i).range(X);I.useEffect(()=>{const ge=Qr(F.current),ve=Qr(te.current),le=g7().scaleExtent(S).translateExtent(w||[[-20,-20],[l+20,s+20]]).on("zoom",({transform:ue})=>{ge.attr("transform",ue)});ve.call(le)},[s,l]),I.useEffect(()=>{(()=>{if($.current){const ve=$.current.getBoundingClientRect().height;z(ve+16)}})()},[]);const de=c7(n),he=Pz(n),Oe=de[2]-de[0],Ne=de[3]-de[1],Te=l*190/960*360/Oe,_e=s*190/678*180/Ne,xe=c*Math.min(Te,_e),we=ne==="mercator"?d7().rotate([0,0]).center(h||he.geometry.coordinates).translate([l/2,s/2]).scale(xe):ne==="equalEarth"?h7().rotate([0,0]).center(h||he.geometry.coordinates).translate([l/2,s/2]).scale(xe):ne==="naturalEarth"?p7().rotate([0,0]).center(h||he.geometry.coordinates).translate([l/2,s/2]).scale(xe):ne==="orthographic"?m7().rotate([0,0]).center(h||he.geometry.coordinates).translate([l/2,s/2]).scale(xe):f7().rotate([0,0]).center(h||he.geometry.coordinates).translate([l/2,s/2]).scale(xe);return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{viewBox:`0 0 ${l} ${s}`,width:`${l}px`,height:`${s}px`,ref:te,direction:"ltr",children:[v.jsxs("g",{ref:F,children:[n.features.map((ge,ve)=>K[T].values.findIndex(ue=>ue.id===ge.properties[_])!==-1?null:v.jsx("g",{opacity:W?.3:C.length!==0?C.indexOf(ge.properties[_])!==-1?1:.3:1,children:ge.geometry.type==="MultiPolygon"?ge.geometry.coordinates.map((ue,Ce)=>{let pe="";return ue.forEach(ye=>{let be=" M";ye.forEach((je,$e)=>{const ut=we([je[0],je[1]]);$e!==ye.length-1?be=`${be}${ut[0]} ${ut[1]}L`:be=`${be}${ut[0]} ${ut[1]}`}),pe+=be}),v.jsx("path",{d:pe,style:{stroke:g,strokeWidth:d,fill:m}},Ce)}):ge.geometry.coordinates.map((ue,Ce)=>{let pe="M";return ue.forEach((ye,be)=>{const je=we([ye[0],ye[1]]);be!==ue.length-1?pe=`${pe}${je[0]} ${je[1]}L`:pe=`${pe}${je[0]} ${je[1]}`}),v.jsx("path",{d:pe,style:{stroke:g,strokeWidth:d,fill:m}},Ce)})},ve)),K[T].values.map((ge,ve)=>{const le=n.features.findIndex(ye=>ge.id===ye.properties[_]),ue=Fe(ge.x)?void 0:ie(ge.x),Ce=Fe(ge.y)?void 0:ce(ge.y),pe=ue!==void 0&&Ce!==void 0?f[Ce][ue]:m;return v.jsx("g",{opacity:W?W===pe?1:.3:C.length!==0?C.indexOf(ge.id)!==-1?1:.3:1,onMouseEnter:ye=>{R(ge),re(ye.clientY),J(ye.clientX),b&&b(ge)},onClick:()=>{(k||M)&&(Sr(ae,ge)&&A?(U(void 0),k==null||k(void 0)):(U(ge),k==null||k(ge)))},onMouseMove:ye=>{R(ge),re(ye.clientY),J(ye.clientX)},onMouseLeave:()=>{R(void 0),J(void 0),re(void 0),b&&b(void 0)},children:le===-1?null:n.features[le].geometry.type==="MultiPolygon"?n.features[le].geometry.coordinates.map((ye,be)=>{let je="";return ye.forEach($e=>{let ut=" M";$e.forEach((Ie,Ze)=>{const Ke=we([Ie[0],Ie[1]]);Ze!==$e.length-1?ut=`${ut}${Ke[0]} ${Ke[1]}L`:ut=`${ut}${Ke[0]} ${Ke[1]}`}),je+=ut}),v.jsx("path",{d:je,className:`${pe===m?"stroke-primary-gray-400 dark:stroke-primary-gray-500":"stroke-primary-white dark:stroke-primary-gray-650"}`,style:{strokeWidth:d,fill:pe}},be)}):n.features[le].geometry.coordinates.map((ye,be)=>{let je="M";return ye.forEach(($e,ut)=>{const Ie=we([$e[0],$e[1]]);ut!==ye.length-1?je=`${je}${Ie[0]} ${Ie[1]}L`:je=`${je}${Ie[0]} ${Ie[1]}`}),v.jsx("path",{d:je,className:`${pe===m?"stroke-primary-gray-400 dark:stroke-primary-gray-500":"stroke-primary-white dark:stroke-primary-gray-650"}`,style:{strokeWidth:d,fill:pe}},be)})},ve)}),H?n.features.filter(ge=>ge.properties[_]===H.id).map((ge,ve)=>v.jsx("g",{children:ge.geometry.type==="MultiPolygon"?ge.geometry.coordinates.map((le,ue)=>{let Ce="";return le.forEach(pe=>{let ye=" M";pe.forEach((be,je)=>{const $e=we([be[0],be[1]]);je!==pe.length-1?ye=`${ye}${$e[0]} ${$e[1]}L`:ye=`${ye}${$e[0]} ${$e[1]}`}),Ce+=ye}),v.jsx("path",{d:Ce,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},ue)}):ge.geometry.coordinates.map((le,ue)=>{let Ce="M";return le.forEach((pe,ye)=>{const be=we([pe[0],pe[1]]);ye!==le.length-1?Ce=`${Ce}${be[0]} ${be[1]}L`:Ce=`${Ce}${be[0]} ${be[1]}`}),v.jsx("path",{d:Ce,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},ue)})},ve)):null]}),v.jsx("foreignObject",{x:10,y:B?s-V-5:s-46,width:B?189:101,height:B?V:36,children:E?B?v.jsxs("div",{ref:$,children:[v.jsx("div",{style:{marginBottom:"-0.75rem",marginLeft:"164px",backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"relative"},onClick:()=>{j(!1)},children:v.jsx(n7,{})}),v.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.5",width:"175px"},children:[v.jsxs("div",{className:"flex gap-1 items-center",children:[v.jsx("svg",{width:"136px",viewBox:"0 0 136 136",className:"shrink-0",children:v.jsxs("g",{children:[f.map((ge,ve)=>v.jsx("g",{transform:`translate(0,${100-ve*25})`,children:ge.map((le,ue)=>v.jsx("rect",{y:1,x:ue*25+1,fill:le,width:23,height:23,strokeWidth:W===le?2:.25,style:{cursor:"pointer"},onMouseOver:()=>{G(le)},onMouseLeave:()=>{G(void 0)}},ue))},ve)),v.jsx("g",{transform:"translate(0,125)",children:r.map((ge,ve)=>v.jsx("text",{y:10,x:(ve+1)*25,fontSize:10,textAnchor:"middle",children:typeof ge=="string"||ge<1?ge:_t(ge,"","")},ve))}),i.map((ge,ve)=>v.jsx("g",{transform:`translate(${Math.max(Math.min(r.length+1,5),4)*25+10},${100-ve*25})`,children:v.jsx("text",{x:0,transform:"rotate(-90)",y:0,fontSize:10,textAnchor:"middle",children:typeof ge=="string"||ge<1?ge:_t(ge,"","")})},ve))]})}),v.jsx(or,{marginBottom:"none",size:"xs",className:"leading-normal text-center shrink-0",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical",overflow:"hidden",writingMode:"vertical-rl",height:"8.5rem",transform:"rotate(180deg)"},children:o})]}),v.jsx(or,{marginBottom:"none",size:"xs",className:"mt-1 leading-normal text-center",style:{display:"-webkit-box",WebkitLineClamp:"1",width:"8.5rem",WebkitBoxOrient:"vertical",overflow:"hidden"},children:a})]})]}):v.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{j(!0)},children:v.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})}):null})]}),H&&y&&ee&&Z?v.jsx(yr,{data:H,body:y,xPos:ee,yPos:Z,backgroundStyle:N==null?void 0:N.tooltip,className:Y==null?void 0:Y.tooltip}):null,M?v.jsx(Tr,{open:ae!==void 0,onClose:()=>{U(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(M,ae)}})}):null]})}function fq(t){const{data:e,mapData:r,graphTitle:n,colors:a=Qe.light.bivariateColors.colors05x05,sources:i,graphDescription:o,height:l,width:s,footNote:f,xDomain:c,yDomain:h,xColorLegendTitle:d="X Color key",yColorLegendTitle:m="Y Color key",tooltip:g,scale:y=.95,centerPoint:b,padding:S,mapBorderWidth:w=.5,showColorScale:C=!0,mapNoDataColor:k=Qe.light.graphNoData,backgroundColor:_=!1,mapBorderColor:D=Qe.light.grays["gray-500"],relativeHeight:T,onSeriesMouseOver:A,isWorldMap:M=!0,zoomScaleExtend:E=[.8,6],zoomTranslateExtend:N,graphID:Y,highlightedIds:ne=[],onSeriesMouseClick:K,mapProperty:B="ISO3",graphDownload:j=!1,dataDownload:$=!1,showAntarctica:V=!1,language:z="en",minHeight:W=0,theme:G="light",dateFormat:ae="yyyy",showOnlyActiveDate:U=!1,autoPlay:H=!1,ariaLabel:R,resetSelectionOnDoubleClick:ee=!0,detailsOnClick:J,styles:Z,classNames:re,mapProjection:te}=t,[F,q]=I.useState(0),[X,ie]=I.useState(0),[ce,de]=I.useState(void 0),he=I.useRef(null),Oe=I.useRef(null);I.useEffect(()=>{const ve=new ResizeObserver(le=>{q(s||le[0].target.clientWidth||760),ie(l||le[0].target.clientHeight||480)});return he.current&&(ie(he.current.clientHeight||480),q(he.current.clientWidth||760),s||ve.observe(he.current)),()=>ve.disconnect()},[s,l]);const[Ne,Te]=I.useState(H),_e=qi(Bt(e,ve=>ve.date).map(ve=>bt(`${ve.date}`,ae,new Date).getTime()),(ve,le)=>Ka(ve,le)),[xe,we]=I.useState(H?0:_e.length-1),ge={};return _e.forEach((ve,le)=>{ge[`${ve}`]={style:{color:le===xe?"#232E3D":"#A9B1B7",fontWeight:le===xe?"bold":"normal",display:le===xe||!U?"inline":"none"},label:Sa(new Date(ve),ae)}}),I.useEffect(()=>{const ve=setInterval(()=>{we(le=>le<_e.length-1?le+1:0)},2e3);return Ne||clearInterval(ve),()=>clearInterval(ve)},[_e,Ne]),I.useEffect(()=>{typeof r=="string"?ka(r).then(le=>{de(le)}):de(r||u7)},[r]),c&&h&&(c.length!==a[0].length-1||h.length!==a.length-1)?(console.error("the xDomain and yDomain array length don't match to the color array length"),null):v.jsx("div",{className:`${G||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:z==="he"||z==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${_?_===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${z||"en"}`,re==null?void 0:re.graphContainer),style:{...(Z==null?void 0:Z.graphContainer)||{},..._&&_!==!0?{backgroundColor:_}:{}},id:Y,ref:Oe,"aria-label":R||`${n?`The graph shows ${n}. `:""}This is bi-variate choropleth map where geographic areas are colored in proportion to two variables showing data changes over time.${o?` ${o}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:_?S||"1rem":S||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[n||o||j||$?v.jsx(Zt,{styles:{title:Z==null?void 0:Z.title,description:Z==null?void 0:Z.description},classNames:{title:re==null?void 0:re.title,description:re==null?void 0:re.description},graphTitle:n,graphDescription:o,width:s,graphDownload:j?Oe.current:void 0,dataDownload:$?e.map(ve=>ve.data).filter(ve=>ve!==void 0).length>0?e.map(ve=>ve.data).filter(ve=>ve!==void 0):e.filter(ve=>ve!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{Te(!Ne)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":Ne?"Click to pause animation":"Click to play animation",children:Ne?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:_e[0],max:_e[_e.length-1],marks:ge,step:null,defaultValue:_e[_e.length-1],value:_e[xe],onChangeComplete:ve=>{we(_e.indexOf(ve))},onChange:ve=>{we(_e.indexOf(ve))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:he,"aria-label":"Map area",children:(s||F)&&(l||X)&&ce?v.jsx(sve,{data:e,mapData:V?ce:{...ce,features:ce.features.filter(ve=>ve.properties.NAME!=="Antarctica")},xDomain:c||X3(e.map(ve=>ve.x),a[0].length),yDomain:h||X3(e.map(ve=>ve.y),a.length),width:s||F,height:Math.max(W,l||(T?W?(s||F)*T>W?(s||F)*T:W:(s||F)*T:X)),scale:y,centerPoint:b,colors:a,xColorLegendTitle:d,yColorLegendTitle:m,mapBorderWidth:Fe(w)?.5:w,mapNoDataColor:k,mapBorderColor:D,tooltip:g,showColorScale:C,onSeriesMouseOver:A,isWorldMap:M,zoomScaleExtend:E,zoomTranslateExtend:N,onSeriesMouseClick:K,mapProperty:B,highlightedIds:ne,dateFormat:ae,indx:xe,resetSelectionOnDoubleClick:ee,styles:Z,classNames:re,detailsOnClick:J,mapProjection:te||(M?"naturalEarth":"mercator")}):null}),i||f?v.jsx(tr,{styles:{footnote:Z==null?void 0:Z.footnote,source:Z==null?void 0:Z.source},classNames:{footnote:re==null?void 0:re.footnote,source:re==null?void 0:re.source},sources:i,footNote:f,width:s}):null]})})})})}function uve(t){const{data:e,colorDomain:r,colors:n,mapData:a,colorLegendTitle:i,categorical:o,height:l,width:s,scale:f,centerPoint:c,tooltip:h,mapBorderWidth:d,mapBorderColor:m,mapNoDataColor:g,onSeriesMouseOver:y,showColorScale:b,zoomScaleExtend:S,zoomTranslateExtend:w,highlightedIds:C,onSeriesMouseClick:k,mapProperty:_,dateFormat:D,indx:T,resetSelectionOnDoubleClick:A,detailsOnClick:M,styles:E,classNames:N,mapProjection:Y}=t,ne=Array.from(Hi(Ut(e,Te=>bt(`${Te.date}`,D||"yyyy",new Date)),Te=>Te.date),([Te,_e])=>({date:Te,values:_e})),[K,B]=I.useState(void 0),[j,$]=I.useState(!(s<680)),V=I.useRef(null),[z,W]=I.useState(50),[G,ae]=I.useState(void 0),[U,H]=I.useState(void 0),[R,ee]=I.useState(void 0),[J,Z]=I.useState(void 0),re=I.useRef(null),te=I.useRef(null),F=o?Ys().domain(r).range(n):P2().domain(r).range(n);I.useEffect(()=>{const Te=Qr(te.current),_e=Qr(re.current),xe=g7().scaleExtent(S).translateExtent(w||[[-20,-20],[s+20,l+20]]).on("zoom",({transform:we})=>{Te.attr("transform",we)});_e.call(xe)},[l,s]),I.useEffect(()=>{(()=>{if(V.current){const _e=V.current.getBoundingClientRect().height;W(_e+16)}})()},[]);const q=c7(a),X=o9(a),ie=q[2]-q[0],ce=q[3]-q[1],de=s*190/960*360/ie,he=l*190/678*180/ce,Oe=f*Math.min(de,he),Ne=Y==="mercator"?d7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):Y==="equalEarth"?h7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):Y==="naturalEarth"?p7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):Y==="orthographic"?m7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):f7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe);return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{width:`${s}px`,height:`${l}px`,viewBox:`0 0 ${s} ${l}`,ref:re,direction:"ltr",children:[v.jsxs("g",{ref:te,children:[a.features.map((Te,_e)=>ne[T].values.findIndex(we=>we.id===Te.properties[_])!==-1?null:v.jsx("g",{opacity:K?.3:C.length!==0?C.indexOf(Te.properties[_])!==-1?1:.3:1,children:Te.geometry.type==="MultiPolygon"?Te.geometry.coordinates.map((we,ge)=>{let ve="";return we.forEach(le=>{let ue=" M";le.forEach((Ce,pe)=>{const ye=Ne([Ce[0],Ce[1]]);pe!==le.length-1?ue=`${ue}${ye[0]} ${ye[1]}L`:ue=`${ue}${ye[0]} ${ye[1]}`}),ve+=ue}),v.jsx("path",{d:ve,style:{stroke:m,fill:g,strokeWidth:d}},ge)}):Te.geometry.coordinates.map((we,ge)=>{let ve="M";return we.forEach((le,ue)=>{const Ce=Ne([le[0],le[1]]);ue!==we.length-1?ve=`${ve}${Ce[0]} ${Ce[1]}L`:ve=`${ve}${Ce[0]} ${Ce[1]}`}),v.jsx("path",{d:ve,style:{stroke:m,strokeWidth:d,fill:g}},ge)})},_e)),ne[T].values.map((Te,_e)=>{const xe=a.features.findIndex(ge=>Te.id===ge.properties[_]),we=Fe(Te.x)?g:F(Te.x);return v.jsx("g",{opacity:K?K===we?1:.3:C.length!==0?C.indexOf(Te.id)!==-1?1:.3:1,onMouseEnter:ge=>{H(Te),Z(ge.clientY),ee(ge.clientX),y&&y(Te)},onMouseMove:ge=>{H(Te),Z(ge.clientY),ee(ge.clientX)},onMouseLeave:()=>{H(void 0),ee(void 0),Z(void 0),y&&y(void 0)},onClick:()=>{(k||M)&&(Sr(G,Te)&&A?(ae(void 0),k==null||k(void 0)):(ae(Te),k==null||k(Te)))},children:xe===-1?null:a.features[xe].geometry.type==="MultiPolygon"?a.features[xe].geometry.coordinates.map((ge,ve)=>{let le="";return ge.forEach(ue=>{let Ce=" M";ue.forEach((pe,ye)=>{const be=Ne([pe[0],pe[1]]);ye!==ue.length-1?Ce=`${Ce}${be[0]} ${be[1]}L`:Ce=`${Ce}${be[0]} ${be[1]}`}),le+=Ce}),v.jsx("path",{d:le,style:{stroke:m,strokeWidth:d,fill:we}},ve)}):a.features[xe].geometry.coordinates.map((ge,ve)=>{let le="M";return ge.forEach((ue,Ce)=>{const pe=Ne([ue[0],ue[1]]);Ce!==ge.length-1?le=`${le}${pe[0]} ${pe[1]}L`:le=`${le}${pe[0]} ${pe[1]}`}),v.jsx("path",{d:le,style:{stroke:m,strokeWidth:d,fill:we}},ve)})},_e)}),U?a.features.filter(Te=>Te.properties[_]===U.id).map((Te,_e)=>v.jsx("g",{children:Te.geometry.type==="MultiPolygon"?Te.geometry.coordinates.map((xe,we)=>{let ge="";return xe.forEach(ve=>{let le=" M";ve.forEach((ue,Ce)=>{const pe=Ne([ue[0],ue[1]]);Ce!==ve.length-1?le=`${le}${pe[0]} ${pe[1]}L`:le=`${le}${pe[0]} ${pe[1]}`}),ge+=le}),v.jsx("path",{d:ge,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},we)}):Te.geometry.coordinates.map((xe,we)=>{let ge="M";return xe.forEach((ve,le)=>{const ue=Ne([ve[0],ve[1]]);le!==xe.length-1?ge=`${ge}${ue[0]} ${ue[1]}L`:ge=`${ge}${ue[0]} ${ue[1]}`}),v.jsx("path",{d:ge,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},we)})},_e)):null]}),b===!1?null:v.jsx("foreignObject",{x:10,y:j?l-z-5:l-46,width:j?o?150:352:101,height:j?z:36,children:j?v.jsxs("div",{ref:V,children:[v.jsx("div",{style:{marginBottom:"-0.75rem",marginLeft:o?"126px":"328px",backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"relative"},onClick:()=>{$(!1)},children:v.jsx(n7,{})}),v.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.5",width:o?"138px":"340px"},children:[i&&i!==""?v.jsx(or,{size:"xs",marginBottom:"xs",className:"p-0 leading-normal overflow-hidden text-primary-gray-700 dark:text-primary-gray-300",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical"},children:i}):null,o?v.jsx("div",{className:"flex flex-col gap-3",children:r.map((Te,_e)=>v.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{B(n[_e%n.length])},onMouseLeave:()=>{B(void 0)},children:[v.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:n[_e%n.length]}}),v.jsx(or,{size:"sm",marginBottom:"none",leading:"none",children:Te})]},_e))}):v.jsx("svg",{width:"100%",viewBox:"0 0 320 30",direction:"ltr",children:v.jsxs("g",{children:[r.map((Te,_e)=>v.jsxs("g",{onMouseOver:()=>{B(n[_e])},onMouseLeave:()=>{B(void 0)},className:"cursor-pointer",children:[v.jsx("rect",{x:_e*320/n.length+1,y:1,width:320/n.length-2,height:8,className:K===n[_e]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":"",style:{fill:n[_e],...K===n[_e]?{}:{stroke:n[_e]}}}),v.jsx("text",{x:(_e+1)*320/n.length,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",style:{textAnchor:"middle"},children:_t(Te,"","")})]},_e)),v.jsx("g",{children:v.jsx("rect",{onMouseOver:()=>{B(n[r.length])},onMouseLeave:()=>{B(void 0)},x:r.length*320/n.length+1,y:1,width:320/n.length-2,height:8,className:`cursor-pointer ${K===n[r.length]?"stroke-1 stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:n[r.length],...K===n[r.length]?{}:{stroke:n[r.length]}}})})]})})]})]}):v.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{$(!0)},children:v.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})})})]}),U&&h&&R&&J?v.jsx(yr,{data:U,body:h,xPos:R,yPos:J,backgroundStyle:E==null?void 0:E.tooltip,className:N==null?void 0:N.tooltip}):null,M?v.jsx(Tr,{open:G!==void 0,onClose:()=>{ae(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(M,G)}})}):null]})}function dq(t){const{data:e,mapData:r,graphTitle:n,colors:a,sources:i,graphDescription:o,height:l,width:s,footNote:f,colorDomain:c,colorLegendTitle:h,scaleType:d="threshold",scale:m=.95,centerPoint:g,padding:y,mapBorderWidth:b=.5,mapNoDataColor:S=Qe.light.graphNoData,backgroundColor:w=!1,mapBorderColor:C=Qe.light.grays["gray-500"],relativeHeight:k,tooltip:_,onSeriesMouseOver:D,isWorldMap:T=!0,showColorScale:A=!0,zoomScaleExtend:M=[.8,6],zoomTranslateExtend:E,graphID:N,highlightedIds:Y=[],onSeriesMouseClick:ne,mapProperty:K="ISO3",graphDownload:B=!1,dataDownload:j=!1,showAntarctica:$=!1,language:V="en",minHeight:z=0,theme:W="light",dateFormat:G="yyyy",showOnlyActiveDate:ae=!1,autoPlay:U=!1,ariaLabel:H,resetSelectionOnDoubleClick:R=!0,detailsOnClick:ee,styles:J,classNames:Z,mapProjection:re}=t,[te,F]=I.useState(0),[q,X]=I.useState(0),[ie,ce]=I.useState(void 0),de=I.useRef(null),he=I.useRef(null);I.useEffect(()=>{const ve=new ResizeObserver(le=>{F(s||le[0].target.clientWidth||760),X(l||le[0].target.clientHeight||480)});return de.current&&(X(de.current.clientHeight||480),F(de.current.clientWidth||760),s||ve.observe(de.current)),()=>ve.disconnect()},[s,l]),I.useEffect(()=>{typeof r=="string"?ka(r).then(le=>{ce(le)}):ce(r||u7)},[r]);const Oe=c||(d==="categorical"?J0(e,"x"):X3(e.map(ve=>ve.x),(a==null?void 0:a.length)||4)),[Ne,Te]=I.useState(U),_e=qi(Bt(e,ve=>ve.date).map(ve=>bt(`${ve.date}`,G,new Date).getTime()),(ve,le)=>Ka(ve,le)),[xe,we]=I.useState(U?0:_e.length-1),ge={};return _e.forEach((ve,le)=>{ge[`${ve}`]={style:{color:le===xe?"#232E3D":"#A9B1B7",fontWeight:le===xe?"bold":"normal",display:le===xe||!ae?"inline":"none"},label:Sa(new Date(ve),G)}}),I.useEffect(()=>{const ve=setInterval(()=>{we(le=>le<_e.length-1?le+1:0)},2e3);return Ne||clearInterval(ve),()=>clearInterval(ve)},[_e,Ne]),v.jsx("div",{className:`${W||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:V==="he"||V==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${w?w===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${V||"en"}`,Z==null?void 0:Z.graphContainer),style:{...(J==null?void 0:J.graphContainer)||{},...w&&w!==!0?{backgroundColor:w}:{}},id:N,ref:he,"aria-label":H||`${n?`The graph shows ${n}. `:""}This is a choropleth map where geographic areas are colored in proportion to a specific variable showing data changes over time.${o?` ${o}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:w?y||"1rem":y||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[n||o||B||j?v.jsx(Zt,{styles:{title:J==null?void 0:J.title,description:J==null?void 0:J.description},classNames:{title:Z==null?void 0:Z.title,description:Z==null?void 0:Z.description},graphTitle:n,graphDescription:o,width:s,graphDownload:B?he.current:void 0,dataDownload:j?e.map(ve=>ve.data).filter(ve=>ve!==void 0).length>0?e.map(ve=>ve.data).filter(ve=>ve!==void 0):e.filter(ve=>ve!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{Te(!Ne)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":Ne?"Click to pause animation":"Click to play animation",children:Ne?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:_e[0],max:_e[_e.length-1],marks:ge,step:null,defaultValue:_e[_e.length-1],value:_e[xe],onChangeComplete:ve=>{we(_e.indexOf(ve))},onChange:ve=>{we(_e.indexOf(ve))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:de,"aria-label":"Map area",children:(s||te)&&(l||q)&&ie?v.jsx(uve,{data:e,mapData:$?ie:{...ie,features:ie.features.filter(ve=>ve.properties.NAME!=="Antarctica")},colorDomain:Oe,width:s||te,height:Math.max(z,l||(k?z?(s||te)*k>z?(s||te)*k:z:(s||te)*k:q)),scale:m,centerPoint:g,colors:a||(d==="categorical"?Qe[W].sequentialColors[`neutralColorsx0${Oe.length}`]:Qe[W].sequentialColors[`neutralColorsx0${Oe.length+1}`]),colorLegendTitle:h,mapBorderWidth:b,mapNoDataColor:S,categorical:d==="categorical",mapBorderColor:C,tooltip:_,onSeriesMouseOver:D,isWorldMap:T,showColorScale:A,zoomScaleExtend:M,zoomTranslateExtend:E,onSeriesMouseClick:ne,mapProperty:K,highlightedIds:Y,dateFormat:G,indx:xe,resetSelectionOnDoubleClick:R,styles:J,classNames:Z,detailsOnClick:ee,mapProjection:re||(T?"naturalEarth":"mercator")}):null}),i||f?v.jsx(tr,{styles:{footnote:J==null?void 0:J.footnote,source:J==null?void 0:J.source},classNames:{footnote:Z==null?void 0:Z.footnote,source:Z==null?void 0:Z.source},sources:i,footNote:f,width:s}):null]})})})})}function cve(t){var Te;const{data:e,colors:r,mapData:n,colorLegendTitle:a,colorDomain:i,radius:o,height:l,width:s,scale:f,centerPoint:c,tooltip:h,showLabels:d,mapBorderWidth:m,mapBorderColor:g,mapNoDataColor:y,onSeriesMouseOver:b,showColorScale:S,zoomScaleExtend:w,zoomTranslateExtend:C,highlightedDataPoints:k,onSeriesMouseClick:_,dateFormat:D,indx:T,resetSelectionOnDoubleClick:A,detailsOnClick:M,styles:E,classNames:N,mapProjection:Y}=t,ne=Array.from(Hi(Ut(e,_e=>bt(`${_e.date}`,D||"yyyy",new Date)),_e=>_e.date),([_e,xe])=>({date:_e,values:xe})),[K,B]=I.useState(void 0),[j,$]=I.useState(!(s<680)),V=I.useRef(null),[z,W]=I.useState(50),[G,ae]=I.useState(void 0),[U,H]=I.useState(void 0),[R,ee]=I.useState(void 0),[J,Z]=I.useState(void 0),re=I.useRef(null),te=I.useRef(null),F=e.filter(_e=>_e.radius===void 0).length!==e.length?l4().domain([0,(Te=Vr(e,"radius"))==null?void 0:Te.radius]).range([.25,o]).nice():void 0;I.useEffect(()=>{const _e=Qr(te.current),xe=Qr(re.current),we=g7().scaleExtent(w).translateExtent(C||[[-20,-20],[s+20,l+20]]).on("zoom",({transform:ge})=>{_e.attr("transform",ge)});xe.call(we)},[l,s]),I.useEffect(()=>{(()=>{if(V.current){const xe=V.current.getBoundingClientRect().height;W(xe+16)}})()},[]);const q=c7(n),X=o9(n),ie=q[2]-q[0],ce=q[3]-q[1],de=s*190/960*360/ie,he=l*190/678*180/ce,Oe=f*Math.min(de,he),Ne=Y==="mercator"?d7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):Y==="equalEarth"?h7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):Y==="naturalEarth"?p7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):Y==="orthographic"?m7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe):f7().rotate([0,0]).center(c||X.geometry.coordinates).translate([s/2,l/2]).scale(Oe);return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{width:`${s}px`,height:`${l}px`,viewBox:`0 0 ${s} ${l}`,ref:re,direction:"ltr",children:[v.jsxs("g",{ref:te,children:[n.features.map((_e,xe)=>v.jsx("g",{children:_e.geometry.type==="MultiPolygon"?_e.geometry.coordinates.map((we,ge)=>{let ve="";return we.forEach(le=>{let ue=" M";le.forEach((Ce,pe)=>{const ye=Ne([Ce[0],Ce[1]]);pe!==le.length-1?ue=`${ue}${ye[0]} ${ye[1]}L`:ue=`${ue}${ye[0]} ${ye[1]}`}),ve+=ue}),v.jsx("path",{d:ve,style:{stroke:g,strokeWidth:m,fill:y}},ge)}):_e.geometry.coordinates.map((we,ge)=>{let ve="M";return we.forEach((le,ue)=>{const Ce=Ne([le[0],le[1]]);ue!==we.length-1?ve=`${ve}${Ce[0]} ${Ce[1]}L`:ve=`${ve}${Ce[0]} ${Ce[1]}`}),v.jsx("path",{d:ve,style:{stroke:g,strokeWidth:m,fill:y}},ge)})},xe)),v.jsx(mo,{children:ne[T].values.map((_e,xe)=>{const we=e.filter(ge=>ge.color).length===0?r[0]:_e.color?r[i.indexOf(`${_e.color}`)]:Qe.gray;return v.jsxs("g",{opacity:K?K===we?1:.3:k.length!==0?k.indexOf(_e.data.id)!==-1?1:.3:1,onMouseEnter:ge=>{H(_e),Z(ge.clientY),ee(ge.clientX),b&&b(_e)},onMouseMove:ge=>{H(_e),Z(ge.clientY),ee(ge.clientX)},onMouseLeave:()=>{H(void 0),ee(void 0),Z(void 0),b&&b(void 0)},onClick:()=>{(_||M)&&(Sr(G,_e)&&A?(ae(void 0),_==null||_(void 0)):(ae(_e),_==null||_(_e)))},children:[v.jsx(ur.circle,{cx:Ne([_e.long,_e.lat])[0],cy:Ne([_e.long,_e.lat])[1],style:{fillOpacity:.8},animate:{r:F?F(_e.radius||0):o,fill:e.filter(ge=>ge.color).length===0?r[0]:_e.color?r[i.indexOf(`${_e.color}`)]:Qe.gray,stroke:e.filter(ge=>ge.color).length===0?r[0]:_e.color?r[i.indexOf(`${_e.color}`)]:Qe.gray},transition:{duration:.5}}),d&&_e.label?v.jsx(ur.text,{x:F?Ne([_e.long,_e.lat])[0]+F(_e.radius||0):Ne([_e.long,_e.lat])[0]+o,y:Ne([_e.long,_e.lat])[1],className:"fill-primary-gray-600 dark:fill-primary-gray-300 text-sm",style:{textAnchor:"start"},dx:4,dy:5,animate:{opacity:1},transition:{duration:.5},children:_e.label}):null]},xe)})})]}),v.jsx("foreignObject",{x:10,y:j?l-z-5:l-46,width:j?150:101,height:j?z:36,children:e.filter(_e=>_e.color).length===0||S===!1?null:j?v.jsxs("div",{ref:V,children:[v.jsx("div",{style:{marginBottom:"-0.75rem",marginLeft:"126px",backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"relative"},onClick:()=>{$(!1)},children:v.jsx(n7,{})}),v.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.5",width:"138px"},children:[a&&a!==""?v.jsx(or,{size:"xs",marginBottom:"xs",className:"p-0 leading-normal overflow-hidden text-primary-gray-700 dark:text-primary-gray-300",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical"},children:a}):null,v.jsx("div",{className:"flex flex-col gap-3",children:i.map((_e,xe)=>v.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{B(r[xe%r.length])},onMouseLeave:()=>{B(void 0)},children:[v.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:r[xe%r.length]}}),v.jsx(or,{size:"sm",marginBottom:"none",leading:"none",children:_e})]},xe))})]})]}):v.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{$(!0)},children:v.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})})})]}),U&&h&&R&&J?v.jsx(yr,{data:U,body:h,xPos:R,yPos:J,backgroundStyle:E==null?void 0:E.tooltip,className:N==null?void 0:N.tooltip}):null,M?v.jsx(Tr,{open:G!==void 0,onClose:()=>{ae(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(M,G)}})}):null]})}function hq(t){const{data:e,mapData:r,graphTitle:n,colors:a,sources:i,graphDescription:o,height:l,width:s,footNote:f,colorLegendTitle:c,colorDomain:h,radius:d=5,scale:m=.95,centerPoint:g,padding:y,mapBorderWidth:b=.5,mapNoDataColor:S=Qe.light.graphNoData,backgroundColor:w=!1,showLabels:C=!1,mapBorderColor:k=Qe.light.grays["gray-500"],tooltip:_,relativeHeight:D,onSeriesMouseOver:T,isWorldMap:A=!0,showColorScale:M=!0,zoomScaleExtend:E=[.8,6],zoomTranslateExtend:N,graphID:Y,dateFormat:ne="yyyy",showOnlyActiveDate:K=!1,autoPlay:B=!1,highlightedDataPoints:j=[],onSeriesMouseClick:$,graphDownload:V=!1,dataDownload:z=!1,showAntarctica:W=!1,language:G="en",minHeight:ae=0,theme:U="light",ariaLabel:H,resetSelectionOnDoubleClick:R=!0,detailsOnClick:ee,styles:J,classNames:Z,mapProjection:re}=t,[te,F]=I.useState(0),[q,X]=I.useState(0),[ie,ce]=I.useState(void 0),de=I.useRef(null),he=I.useRef(null);I.useEffect(()=>{const ge=new ResizeObserver(ve=>{F(s||ve[0].target.clientWidth||760),X(l||ve[0].target.clientHeight||480)});return de.current&&(X(de.current.clientHeight||480),F(de.current.clientWidth||760),s||ge.observe(de.current)),()=>ge.disconnect()},[s,l]);const[Oe,Ne]=I.useState(B),Te=qi(Bt(e,ge=>ge.date).map(ge=>bt(`${ge.date}`,ne,new Date).getTime()),(ge,ve)=>Ka(ge,ve)),[_e,xe]=I.useState(B?0:Te.length-1),we={};return Te.forEach((ge,ve)=>{we[`${ge}`]={style:{color:ve===_e?"#232E3D":"#A9B1B7",fontWeight:ve===_e?"bold":"normal",display:ve===_e||!K?"inline":"none"},label:Sa(new Date(ge),ne)}}),I.useEffect(()=>{const ge=setInterval(()=>{xe(ve=>ve<Te.length-1?ve+1:0)},2e3);return Oe||clearInterval(ge),()=>clearInterval(ge)},[Te,Oe]),I.useEffect(()=>{typeof r=="string"?ka(r).then(ve=>{ce(ve)}):ce(r||u7)},[r]),v.jsx("div",{className:`${U||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:G==="he"||G==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${w?w===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${G||"en"}`,Z==null?void 0:Z.graphContainer),style:{...(J==null?void 0:J.graphContainer)||{},...w&&w!==!0?{backgroundColor:w}:{}},id:Y,ref:he,"aria-label":H||`${n?`The graph shows ${n}. `:""}This is an animated dot density map showing the distribution of a variable across a region or world, with each dot representing a data point and changes over time.${o?` ${o}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:w?y||"1rem":y||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[n||o||V||z?v.jsx(Zt,{styles:{title:J==null?void 0:J.title,description:J==null?void 0:J.description},classNames:{title:Z==null?void 0:Z.title,description:Z==null?void 0:Z.description},graphTitle:n,graphDescription:o,width:s,graphDownload:V?he.current:void 0,dataDownload:z?e.map(ge=>ge.data).filter(ge=>ge!==void 0).length>0?e.map(ge=>ge.data).filter(ge=>ge!==void 0):e.filter(ge=>ge!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{Ne(!Oe)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":Oe?"Click to pause animation":"Click to play animation",children:Oe?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:Te[0],max:Te[Te.length-1],marks:we,step:null,defaultValue:Te[Te.length-1],value:Te[_e],onChangeComplete:ge=>{xe(Te.indexOf(ge))},onChange:ge=>{xe(Te.indexOf(ge))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:de,"aria-label":"Map area",children:(s||te)&&(l||q)&&ie?v.jsx(cve,{data:e,mapData:W?ie:{...ie,features:ie.features.filter(ge=>ge.properties.NAME!=="Antarctica")},colorDomain:e.filter(ge=>ge.color).length===0?[]:h||Bt(e.filter(ge=>!Fe(ge.color)),"color").map(ge=>`${ge.color}`),width:s||te,height:Math.max(ae,l||(D?ae?(s||te)*D>ae?(s||te)*D:ae:(s||te)*D:q)),scale:m,centerPoint:g,colors:e.filter(ge=>ge.color).length===0?a?[a]:[Qe.primaryColors["blue-600"]]:a||Qe[U].categoricalColors.colors,colorLegendTitle:c,radius:d,mapBorderWidth:b,mapNoDataColor:S,mapBorderColor:k,tooltip:_,onSeriesMouseOver:T,showLabels:C,isWorldMap:A,showColorScale:M,zoomScaleExtend:E,zoomTranslateExtend:N,onSeriesMouseClick:$,highlightedDataPoints:j,dateFormat:ne,indx:_e,resetSelectionOnDoubleClick:R,styles:J,classNames:Z,detailsOnClick:ee,mapProjection:re||(A?"naturalEarth":"mercator")}):null}),i||f?v.jsx(tr,{styles:{footnote:J==null?void 0:J.footnote,source:J==null?void 0:J.source},classNames:{footnote:Z==null?void 0:Z.footnote,source:Z==null?void 0:Z.source},sources:i,footNote:f,width:s}):null]})})})})}function fve(t){var be,je,$e,ut,Ie,Ze,Ke,et,Pt,jt,Tt,St,tt,Mt,Dt,Ye,Lt,Et,Xt,He,It,Ge,Rt,$t,dr,xr,Mr,Er,it;const{data:e,width:r,height:n,showLabels:a,colors:i,colorDomain:o,radius:l,xAxisTitle:s,yAxisTitle:f,leftMargin:c,rightMargin:h,topMargin:d,bottomMargin:m,tooltip:g,onSeriesMouseOver:y,refXValues:b,refYValues:S,highlightAreaSettings:w,selectedColor:C,highlightedDataPoints:k,maxRadiusValue:_,maxXValue:D,minXValue:T,maxYValue:A,minYValue:M,onSeriesMouseClick:E,dateFormat:N,indx:Y,rtl:ne,annotations:K,customHighlightAreaSettings:B,resetSelectionOnDoubleClick:j,detailsOnClick:$,noOfXTicks:V,noOfYTicks:z,labelColor:W,xSuffix:G,ySuffix:ae,xPrefix:U,yPrefix:H,styles:R,classNames:ee}=t,J=Ut(e.map(Xe=>({...Xe,date:bt(`${Xe.date}`,N,new Date)})),"date"),Z=Bt(J,Xe=>Xe.label).map(Xe=>Xe.label),re=Array.from(Hi(ove(e,N||"yyyy"),Xe=>Xe.date),([Xe,Vt])=>({date:Xe,values:Z.map(Yt=>Vt.find(at=>at.label===Yt)).map(Yt=>({...Yt,id:Yt.label}))})),[te,F]=I.useState(void 0),[q,X]=I.useState(void 0),[ie,ce]=I.useState(void 0),[de,he]=I.useState(void 0),Oe={top:d,bottom:m,left:f?c+40:c,right:h},Ne=r-Oe.left-Oe.right,Te=n-Oe.top-Oe.bottom,_e=e.filter(Xe=>Xe.radius===void 0).length!==e.length?l4().domain([0,Fe(_)?(be=Vr(e,"radius"))==null?void 0:be.radius:_]).range([.25,l]).nice():void 0,xe=Fe(T)?((je=Br(e,"x"))==null?void 0:je.x)>0?0:($e=Br(e,"x"))==null?void 0:$e.x:T,we=Fe(D)?((ut=Vr(e,"x"))==null?void 0:ut.x)>0?(Ie=Vr(e,"x"))==null?void 0:Ie.x:0:D,ge=br().domain([xe,we]).range([0,Ne]).nice(),ve=Fe(M)?((Ze=Br(e,"y"))==null?void 0:Ze.y)>0?0:(Ke=Br(e,"y"))==null?void 0:Ke.y:M,le=Fe(A)?((et=Vr(e,"y"))==null?void 0:et.y)>0?(Pt=Vr(e,"y"))==null?void 0:Pt.y:0:A,ue=br().domain([ve,le]).range([Te,0]).nice(),Ce=ge.ticks(V),pe=ue.ticks(z),ye=i9.from(re[Y].values.filter(Xe=>!Fe(Xe.x)&&!Fe(Xe.y)),Xe=>ge(Xe.x),Xe=>ue(Xe.y)).voronoi([0,0,Ne<0?0:Ne,Te<0?0:Te]);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${Oe.left},${Oe.top})`,children:[v.jsx(Az,{areaSettings:w,width:Ne,height:Te,scaleX:ge,scaleY:ue}),v.jsx(Z2,{areaSettings:B,scaleX:ge,scaleY:ue}),v.jsxs("g",{children:[v.jsx(v1,{values:pe.filter(Xe=>Xe!==0),y:pe.filter(Xe=>Xe!==0).map(Xe=>ue(Xe)),x1:0,x2:Ne+Oe.right,styles:{gridLines:(jt=R==null?void 0:R.yAxis)==null?void 0:jt.gridLines,labels:(Tt=R==null?void 0:R.yAxis)==null?void 0:Tt.labels},classNames:{gridLines:(St=ee==null?void 0:ee.yAxis)==null?void 0:St.gridLines,labels:(tt=ee==null?void 0:ee.yAxis)==null?void 0:tt.labels},suffix:ae,prefix:H,labelType:"primary",showGridLines:!0,labelPos:"side"}),v.jsx(Nr,{y1:ue(ve<0?0:ve),y2:ue(ve<0?0:ve),x1:0,x2:Ne,label:_t(ve<0?0:ve,H,ae),labelPos:{x:0,y:ue(ve<0?0:ve),dy:"0.33em",dx:-4},classNames:{axis:(Mt=ee==null?void 0:ee.xAxis)==null?void 0:Mt.axis,label:(Dt=ee==null?void 0:ee.yAxis)==null?void 0:Dt.labels},styles:{axis:(Ye=R==null?void 0:R.xAxis)==null?void 0:Ye.axis,label:{textAnchor:"end",...((Lt=R==null?void 0:R.yAxis)==null?void 0:Lt.labels)||{}}}}),v.jsx(nn,{x:0-Oe.left+15,y:Te/2,style:(Et=R==null?void 0:R.yAxis)==null?void 0:Et.title,className:(Xt=ee==null?void 0:ee.yAxis)==null?void 0:Xt.title,text:f,rotate90:!0})]}),v.jsxs("g",{children:[v.jsx(La,{values:Ce.filter(Xe=>Xe!==0),x:Ce.filter(Xe=>Xe!==0).map(Xe=>ge(Xe)),y1:0,y2:Te,styles:{gridLines:(He=R==null?void 0:R.xAxis)==null?void 0:He.gridLines,labels:(It=R==null?void 0:R.xAxis)==null?void 0:It.labels},classNames:{gridLines:(Ge=ee==null?void 0:ee.xAxis)==null?void 0:Ge.gridLines,labels:(Rt=ee==null?void 0:ee.xAxis)==null?void 0:Rt.labels},suffix:G,prefix:U,labelType:"primary",showGridLines:!0}),v.jsx(Nr,{x1:ge(xe<0?0:xe),x2:ge(xe<0?0:xe),y1:0,y2:Te,label:_t(xe<0?0:xe,U,G),labelPos:{x:ge(xe<0?0:xe),y:Te,dy:"1em",dx:0},classNames:{axis:($t=ee==null?void 0:ee.xAxis)==null?void 0:$t.axis,label:(dr=ee==null?void 0:ee.yAxis)==null?void 0:dr.labels},styles:{axis:(xr=R==null?void 0:R.xAxis)==null?void 0:xr.axis,label:{textAnchor:"middle",...((Mr=R==null?void 0:R.yAxis)==null?void 0:Mr.labels)||{}}}}),v.jsx(nn,{x:Ne/2,y:Te+30,style:(Er=R==null?void 0:R.xAxis)==null?void 0:Er.title,className:(it=ee==null?void 0:ee.xAxis)==null?void 0:it.title,text:s})]}),v.jsxs(mo,{children:[re[Y].values.map((Xe,Vt)=>v.jsx("g",{children:v.jsx("path",{d:ye.renderCell(re[Y].values.findIndex(Yt=>Yt.id===Xe.id)),className:"opacity-0",onMouseEnter:Yt=>{F(Xe),he(Yt.clientY),ce(Yt.clientX),y&&y(Xe)},onMouseMove:Yt=>{F(Xe),he(Yt.clientY),ce(Yt.clientX)},onMouseLeave:()=>{F(void 0),ce(void 0),he(void 0),y&&y(void 0)},onClick:()=>{(E||$)&&(Sr(q,Xe)&&j?(X(void 0),E==null||E(void 0)):(X(Xe),E==null||E(Xe)))}})},Vt)),re[Y].values.map((Xe,Vt)=>v.jsx("g",{children:v.jsxs(ur.g,{opacity:C?Xe.color&&i[o.indexOf(`${Xe.color}`)]===C?1:.3:te?te.label===Xe.label?1:.3:k.length!==0?k.indexOf(Xe.label||"")!==-1?1:.5:1,onMouseEnter:Yt=>{F(Xe),he(Yt.clientY),ce(Yt.clientX),y&&y(Xe)},onMouseMove:Yt=>{F(Xe),he(Yt.clientY),ce(Yt.clientX)},onMouseLeave:()=>{F(void 0),ce(void 0),he(void 0),y&&y(void 0)},onClick:()=>{(E||$)&&(Sr(q,Xe)&&j?(X(void 0),E==null||E(void 0)):(X(Xe),E==null||E(Xe)))},children:[v.jsx(ur.circle,{cx:0,cy:0,style:{fill:e.filter(Yt=>Yt.color).length===0?i[0]:Xe.color?i[o.indexOf(`${Xe.color}`)]:Qe.gray,stroke:e.filter(Yt=>Yt.color).length===0?i[0]:Xe.color?i[o.indexOf(`${Xe.color}`)]:Qe.gray,fillOpacity:.6},animate:{cx:ge(Xe.x||0),cy:ue(Xe.y||0),r:Fe(Xe.x)||Fe(Xe.y)?0:_e?_e(Xe.radius||0):l},transition:{duration:.5}}),a&&!Fe(Xe.label)?v.jsx(ur.text,{className:Be("graph-value text-sm",ee==null?void 0:ee.graphObjectValues),style:{fill:W||(e.filter(Yt=>Yt.color).length===0?i[0]:Xe.color?i[o.indexOf(`${Xe.color}`)]:Qe.gray),...(R==null?void 0:R.graphObjectValues)||{}},dy:"0.33em",dx:3,animate:{attrY:ue(Xe.y||0),attrX:_e?ge(Xe.x||0)+_e(Xe.radius||0):ge(Xe.x||0)+l,opacity:Fe(Xe.x)||Fe(Xe.y)?0:1},transition:{duration:.5},children:Xe.label}):k.length!==0&&!Fe(Xe.label)&&k.indexOf(Xe.label)!==-1?v.jsx(ur.text,{className:Be("graph-value text-sm",ee==null?void 0:ee.graphObjectValues),style:{fill:W||(e.filter(Yt=>Yt.color).length===0?i[0]:Xe.color?i[o.indexOf(`${Xe.color}`)]:Qe.gray),...(R==null?void 0:R.graphObjectValues)||{}},dy:"0.33em",dx:3,animate:{attrY:ue(Xe.y||0),attrX:_e?ge(Xe.x||0)+_e(Xe.radius||0):ge(Xe.x||0)+l,opacity:Fe(Xe.x)||Fe(Xe.y)?0:1},transition:{duration:.5},children:Xe.label}):null]})},Vt))]}),b.map((Xe,Vt)=>v.jsx(ti,{text:Xe.text,color:Xe.color,x:ge(Xe.value),y1:0,y2:Te,textSide:ge(Xe.value)>Ne*.75||ne?"left":"right",classNames:Xe.classNames,styles:Xe.styles},Vt)),S.map((Xe,Vt)=>v.jsx(h1,{text:Xe.text,color:Xe.color,y:ue(Xe.value),x1:0,x2:Ne,classNames:Xe.classNames,styles:Xe.styles},Vt)),v.jsx("g",{children:K.map((Xe,Vt)=>{const Yt=K2({x:Xe.xCoordinate?ge(Xe.xCoordinate)+(Xe.xOffset||0):0+(Xe.xOffset||0),y:Xe.yCoordinate?ue(Xe.yCoordinate)+(Xe.yOffset||0)-8:0+(Xe.yOffset||0)-8},{x:Xe.xCoordinate?ge(Xe.xCoordinate):0,y:Xe.yCoordinate?ue(Xe.yCoordinate):0},Fe(Xe.connectorRadius)?3.5:Xe.connectorRadius),at=Xe.showConnector?{y1:Yt.y,x1:Yt.x,y2:Xe.yCoordinate?ue(Xe.yCoordinate)+(Xe.yOffset||0):0+(Xe.yOffset||0),x2:Xe.xCoordinate?ge(Xe.xCoordinate)+(Xe.xOffset||0):0+(Xe.xOffset||0),cy:Xe.yCoordinate?ue(Xe.yCoordinate):0,cx:Xe.xCoordinate?ge(Xe.xCoordinate):0,circleRadius:Fe(Xe.connectorRadius)?3.5:Xe.connectorRadius,strokeWidth:Xe.showConnector===!0?2:Math.min(Xe.showConnector||0,1)}:void 0,cr={y:Xe.yCoordinate?ue(Xe.yCoordinate)+(Xe.yOffset||0)-8:0+(Xe.yOffset||0)-8,x:ne?0:Xe.xCoordinate?ge(Xe.xCoordinate)+(Xe.xOffset||0):0+(Xe.xOffset||0),width:ne?Xe.xCoordinate?ge(Xe.xCoordinate)+(Xe.xOffset||0):0+(Xe.xOffset||0):Ne-(Xe.xCoordinate?ge(Xe.xCoordinate)+(Xe.xOffset||0):0+(Xe.xOffset||0)),maxWidth:Xe.maxWidth,fontWeight:Xe.fontWeight,align:Xe.align};return v.jsx(J2,{color:Xe.color,connectorsSettings:at,labelSettings:cr,text:Xe.text,classNames:Xe.classNames,styles:Xe.styles},Vt)})})]})}),te&&g&&ie&&de?v.jsx(yr,{data:te,body:g,xPos:ie,yPos:de,backgroundStyle:R==null?void 0:R.tooltip,className:ee==null?void 0:ee.tooltip}):null,$?v.jsx(Tr,{open:q!==void 0,onClose:()=>{X(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr($,q)}})}):null]})}function pq(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,showLabels:o=!1,height:l,width:s,footNote:f,colorDomain:c,colorLegendTitle:h,radius:d=5,xAxisTitle:m="X Axis",yAxisTitle:g="Y Axis",padding:y,backgroundColor:b=!1,leftMargin:S=50,rightMargin:w=20,topMargin:C=20,bottomMargin:k=50,tooltip:_,relativeHeight:D,onSeriesMouseOver:T,refXValues:A=[],refYValues:M=[],highlightAreaSettings:E=[],showColorScale:N=!0,highlightedDataPoints:Y=[],graphID:ne,maxRadiusValue:K,maxXValue:B,minXValue:j,maxYValue:$,minYValue:V,onSeriesMouseClick:z,graphDownload:W=!1,dataDownload:G=!1,language:ae="en",showNAColor:U=!0,minHeight:H=0,annotations:R=[],customHighlightAreaSettings:ee=[],theme:J="light",ariaLabel:Z,resetSelectionOnDoubleClick:re=!0,dateFormat:te="yyyy",showOnlyActiveDate:F=!1,autoPlay:q=!1,detailsOnClick:X,noOfXTicks:ie=5,noOfYTicks:ce=5,labelColor:de,xSuffix:he="",ySuffix:Oe="",xPrefix:Ne="",yPrefix:Te="",styles:_e,classNames:xe}=t,[we,ge]=I.useState(0),[ve,le]=I.useState(0),[ue,Ce]=I.useState(void 0),pe=I.useRef(null),ye=I.useRef(null);I.useEffect(()=>{const Ke=new ResizeObserver(et=>{ge(s||et[0].target.clientWidth||620),le(l||et[0].target.clientHeight||480)});return pe.current&&(le(pe.current.clientHeight||480),ge(pe.current.clientWidth||620),s||Ke.observe(pe.current)),()=>Ke.disconnect()},[s,l]);const[be,je]=I.useState(q),$e=qi(Bt(e,Ke=>Ke.date).map(Ke=>bt(`${Ke.date}`,te,new Date).getTime()),(Ke,et)=>Ka(Ke,et)),[ut,Ie]=I.useState(q?0:$e.length-1),Ze={};return $e.forEach((Ke,et)=>{Ze[`${Ke}`]={style:{color:et===ut?"#232E3D":"#A9B1B7",fontWeight:et===ut?"bold":"normal",display:et===ut||!F?"inline":"none"},label:Sa(new Date(Ke),te)}}),I.useEffect(()=>{const Ke=setInterval(()=>{Ie(et=>et<$e.length-1?et+1:0)},2e3);return be||clearInterval(Ke),()=>clearInterval(Ke)},[$e,be]),v.jsx("div",{className:`${J||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:ae==="he"||ae==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${b?b===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${ae||"en"}`,xe==null?void 0:xe.graphContainer),style:{...(_e==null?void 0:_e.graphContainer)||{},...b&&b!==!0?{backgroundColor:b}:{}},id:ne,ref:ye,"aria-label":Z||`${r?`The graph shows ${r}. `:""}This is an animated scatter plot that shows correlation between two variables showing data changes over time.${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:b?y||"1rem":y||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||W||G?v.jsx(Zt,{styles:{title:_e==null?void 0:_e.title,description:_e==null?void 0:_e.description},classNames:{title:xe==null?void 0:xe.title,description:xe==null?void 0:xe.description},graphTitle:r,graphDescription:i,width:s,graphDownload:W?ye.current:void 0,dataDownload:G?e.map(Ke=>Ke.data).filter(Ke=>Ke!==void 0).length>0?e.map(Ke=>Ke.data).filter(Ke=>Ke!==void 0):e.filter(Ke=>Ke!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{je(!be)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":be?"Click to pause animation":"Click to play animation",children:be?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:$e[0],max:$e[$e.length-1],marks:Ze,step:null,defaultValue:$e[$e.length-1],value:$e[ut],onChangeComplete:Ke=>{Ie($e.indexOf(Ke))},onChange:Ke=>{Ie($e.indexOf(Ke))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[N&&e.filter(Ke=>Ke.color).length!==0?v.jsx(Cn,{width:s,colorLegendTitle:h,colors:n||Qe[J].categoricalColors.colors,colorDomain:c||Bt(e.filter(Ke=>Ke.color),"color").map(Ke=>Ke.color),setSelectedColor:Ce,showNAColor:U}):null,v.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:pe,"aria-label":"Graph area",children:(s||we)&&(l||ve)?v.jsx(fve,{data:e,width:s||we,height:Math.max(H,l||(D?H?(s||we)*D>H?(s||we)*D:H:(s||we)*D:ve)),colorDomain:e.filter(Ke=>Ke.color).length===0?[]:c||Bt(e.filter(Ke=>Ke.color),"color").map(Ke=>Ke.color),colors:e.filter(Ke=>Ke.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[J].categoricalColors.colors,xAxisTitle:m,yAxisTitle:g,refXValues:A,refYValues:M,showLabels:o,radius:d,leftMargin:S,rightMargin:w,topMargin:C,bottomMargin:k,tooltip:_,onSeriesMouseOver:T,highlightAreaSettings:E,highlightedDataPoints:e.filter(Ke=>Ke.label).length===0?[]:Y,selectedColor:ue,maxRadiusValue:K,maxXValue:B,minXValue:j,maxYValue:$,minYValue:V,onSeriesMouseClick:z,dateFormat:te,indx:ut,rtl:ae==="he"||ae==="ar",annotations:R,customHighlightAreaSettings:ee,resetSelectionOnDoubleClick:re,detailsOnClick:X,noOfXTicks:ie,noOfYTicks:ce,labelColor:de,xSuffix:he,ySuffix:Oe,xPrefix:Ne,yPrefix:Te,styles:_e,classNames:xe}):null})]}),a||f?v.jsx(tr,{styles:{footnote:_e==null?void 0:_e.footnote,source:_e==null?void 0:_e.source},classNames:{footnote:xe==null?void 0:xe.footnote,source:xe==null?void 0:xe.source},sources:a,footNote:f,width:s}):null]})})})})}function dve(t){var xe,we,ge,ve,le,ue;const{data:e,dotColors:r,suffix:n,prefix:a,barPadding:i,showValues:o,showTicks:l,leftMargin:s,truncateBy:f,width:c,height:h,rightMargin:d,topMargin:m,bottomMargin:g,radius:y,showLabels:b,tooltip:S,onSeriesMouseOver:w,maxPositionValue:C,minPositionValue:k,onSeriesMouseClick:_,selectedColor:D,dateFormat:T,indx:A,sortParameter:M,connectorStrokeWidth:E,arrowConnector:N,maxBarThickness:Y,minBarThickness:ne,resetSelectionOnDoubleClick:K,detailsOnClick:B,axisTitle:j,noOfTicks:$,valueColor:V,styles:z,classNames:W,refValues:G,rtl:ae}=t,U=Ut(e.map(Ce=>({...Ce,date:bt(`${Ce.date}`,T,new Date)})),"date"),H=Bt(U,Ce=>Ce.label).map(Ce=>Ce.label),R=Array.from(Hi(uq(e,T||"yyyy"),Ce=>Ce.date),([Ce,pe])=>({date:Ce,values:M!==void 0?M==="diff"?Ut(pe,ye=>Fe(ye.x[ye.x.length-1])||Fe(ye.x[0])?-1/0:ye.x[ye.x.length-1]-ye.x[0]).reverse().map((ye,be)=>({...ye,id:`${be}`})):Ut(pe,ye=>Fe(ye.x[M])?-1/0:ye.x[M]).reverse().map((ye,be)=>({...ye,id:`${be}`})):H.map(ye=>pe.find(be=>be.label===ye)).map((ye,be)=>({...ye,id:`${be}`}))})),ee={top:j?m+25:m,bottom:g,left:s,right:d},J=c-ee.left-ee.right,Z=h-ee.top-ee.bottom,[re,te]=I.useState(void 0),[F,q]=I.useState(void 0),[X,ie]=I.useState(void 0),[ce,de]=I.useState(void 0),he=Fe(C)?Math.max(...e.map(Ce=>Mn(Ce.x)||0))<0?0:Math.max(...e.map(Ce=>Mn(Ce.x)||0)):C,Oe=Fe(k)?Math.min(...e.map(Ce=>gr(Ce.x)||0))>0?0:Math.min(...e.map(Ce=>gr(Ce.x)||0)):k,Ne=br().domain([Oe,he]).range([0,J]).nice(),Te=Un().domain(H.map((Ce,pe)=>`${pe}`)).range([0,ne?Math.max(Z,ne*H.length):Y?Math.min(Z,Y*H.length):Z]).paddingInner(i),_e=Ne.ticks($);return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{width:`${c}px`,height:`${h}px`,viewBox:`0 0 ${c} ${h}`,direction:"ltr",children:[N?v.jsx("defs",{children:v.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:v.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-primary-gray-600 dark:fill-primary-gray-300"})})}):null,v.jsxs("g",{transform:`translate(${ee.left},${ee.top})`,children:[l?v.jsx(La,{values:_e.filter(Ce=>Ce!==0),x:_e.filter(Ce=>Ce!==0).map(Ce=>Ne(Ce)),y1:0-m,y2:Z+ee.bottom,styles:{gridLines:(xe=z==null?void 0:z.xAxis)==null?void 0:xe.gridLines,labels:(we=z==null?void 0:z.xAxis)==null?void 0:we.labels},classNames:{gridLines:(ge=W==null?void 0:W.xAxis)==null?void 0:ge.gridLines,labels:(ve=W==null?void 0:W.xAxis)==null?void 0:ve.labels},suffix:n,prefix:a,labelType:"secondary",showGridLines:!0}):null,v.jsx(nn,{x:J/2,y:0-ee.top+15,style:(le=z==null?void 0:z.xAxis)==null?void 0:le.title,className:(ue=W==null?void 0:W.xAxis)==null?void 0:ue.title,text:j}),v.jsx(mo,{children:R[A].values.map((Ce,pe)=>{var ye,be,je,$e;return v.jsxs(ur.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",children:[b?v.jsx(ur.text,{style:{textAnchor:"end",...((ye=z==null?void 0:z.yAxis)==null?void 0:ye.labels)||{}},x:0,dx:-10,dy:"0.33em",className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(be=W==null?void 0:W.yAxis)==null?void 0:be.labels),animate:{attrY:Te(`${pe}`)+Te.bandwidth()/2},transition:{duration:.5},children:`${Ce.label}`.length<f?Ce.label:`${`${Ce.label}`.substring(0,f)}...`}):null,v.jsx(ur.line,{x1:0,x2:J,className:Be("undp-tick-line stroke-primary-gray-400 dark:stroke-primary-gray-600",(je=W==null?void 0:W.yAxis)==null?void 0:je.gridLines),style:($e=z==null?void 0:z.yAxis)==null?void 0:$e.gridLines,animate:{y1:Te(`${pe}`)+Te.bandwidth()/2,y2:Te(`${pe}`)+Te.bandwidth()/2},transition:{duration:.5}}),v.jsx(ur.line,{style:{strokeWidth:E,...(z==null?void 0:z.dataConnectors)||{},opacity:D?.3:1},className:Be("stroke-primary-gray-600 dark:stroke-primary-gray-300",W==null?void 0:W.dataConnectors),animate:{y1:Te(`${pe}`)+Te.bandwidth()/2,y2:Te(`${pe}`)+Te.bandwidth()/2,x1:Ne(gr(Ce.x))+y,x2:Ne(Mn(Ce.x))-y},markerEnd:N&&Ce.x.indexOf(gr(Ce.x))===0?"url(#arrow)":"",markerStart:N&&Ce.x.indexOf(gr(Ce.x))===Ce.x.length-1?"url(#arrow)":""}),Ce.x.map((ut,Ie)=>v.jsxs(ur.g,{opacity:D?r[Ie]===D?1:.3:1,onMouseEnter:Ze=>{te({...Ce,xIndex:Ie}),de(Ze.clientY),ie(Ze.clientX),w&&w({...Ce,xIndex:Ie})},onClick:()=>{(_||B)&&(Sr(F,{...Ce,xIndex:Ie})&&K?(q(void 0),_==null||_(void 0)):(q({...Ce,xIndex:Ie}),_&&_({...Ce,xIndex:Ie})))},onMouseMove:Ze=>{te({...Ce,xIndex:Ie}),de(Ze.clientY),ie(Ze.clientX)},onMouseLeave:()=>{te(void 0),ie(void 0),de(void 0),w&&w(void 0)},children:[v.jsx(ur.circle,{r:y,style:{fill:r[Ie],fillOpacity:.85,stroke:r[Ie],strokeWidth:1},animate:{cy:Te(`${pe}`)+Te.bandwidth()/2,cx:Ne(ut||0),opacity:Fe(ut)?0:1},transition:{duration:.5}}),o?v.jsx(ur.text,{style:{fill:V||r[Ie],textAnchor:"middle",opacity:Fe(ut)?0:1,...(z==null?void 0:z.graphObjectValues)||{}},className:Be("graph-value text-sm font-bold",W==null?void 0:W.graphObjectValues),dx:0,dy:0-y-3,animate:{attrY:Te(`${pe}`)+Te.bandwidth()/2,attrX:Ne(ut||0),opacity:Fe(ut)?0:1},transition:{duration:.5},children:_t(ut,a,n)}):null]},Ie))]},pe)})}),G?v.jsx(v.Fragment,{children:G.map((Ce,pe)=>v.jsx(ti,{text:Ce.text,color:Ce.color,x:Ne(Ce.value),y1:0-ee.top,y2:Z+ee.bottom,textSide:Ne(Ce.value)>J*.75||ae?"left":"right",classNames:Ce.classNames,styles:Ce.styles},pe))}):null]})]}),re&&S&&X&&ce?v.jsx(yr,{data:re,body:S,xPos:X,yPos:ce,backgroundStyle:z==null?void 0:z.tooltip,className:W==null?void 0:W.tooltip}):null,B?v.jsx(Tr,{open:F!==void 0,onClose:()=>{q(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(B,F)}})}):null]})}function hve(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,suffix:a="",prefix:i="",sources:o,graphDescription:l,barPadding:s=.25,showTicks:f=!0,leftMargin:c=100,rightMargin:h=40,topMargin:d=20,bottomMargin:m=10,truncateBy:g=999,showValues:y=!0,height:b,width:S,footNote:w,colorDomain:C,colorLegendTitle:k,padding:_,backgroundColor:D=!1,radius:T=3,showLabels:A=!0,tooltip:M,relativeHeight:E,onSeriesMouseOver:N,graphID:Y,maxPositionValue:ne,minPositionValue:K,onSeriesMouseClick:B,graphDownload:j=!1,dataDownload:$=!1,sortParameter:V,showOnlyActiveDate:z=!1,autoPlay:W=!1,dateFormat:G="yyyy",arrowConnector:ae=!1,connectorStrokeWidth:U=2,language:H="en",minHeight:R=0,theme:ee="light",maxBarThickness:J,minBarThickness:Z,ariaLabel:re,resetSelectionOnDoubleClick:te=!0,detailsOnClick:F,axisTitle:q,noOfTicks:X=5,valueColor:ie,styles:ce,classNames:de,refValues:he}=t,[Oe,Ne]=I.useState(0),[Te,_e]=I.useState(0),[xe,we]=I.useState(void 0),ge=I.useRef(null),ve=I.useRef(null);I.useEffect(()=>{const je=new ResizeObserver($e=>{Ne(S||$e[0].target.clientWidth||620),_e(b||$e[0].target.clientHeight||480)});return ge.current&&(_e(ge.current.clientHeight||480),Ne(ge.current.clientWidth||620),S||je.observe(ge.current)),()=>je.disconnect()},[S,b]);const[le,ue]=I.useState(W),Ce=qi(Bt(e,je=>je.date).map(je=>bt(`${je.date}`,G,new Date).getTime()),(je,$e)=>Ka(je,$e)),[pe,ye]=I.useState(W?0:Ce.length-1),be={};return Ce.forEach((je,$e)=>{be[`${je}`]={style:{color:$e===pe?"#232E3D":"#A9B1B7",fontWeight:$e===pe?"bold":"normal",display:$e===pe||!z?"inline":"none"},label:Sa(new Date(je),G)}}),I.useEffect(()=>{const je=setInterval(()=>{ye($e=>$e<Ce.length-1?$e+1:0)},2e3);return le||clearInterval(je),()=>clearInterval(je)},[Ce,le]),v.jsx("div",{className:`${ee||"light"} flex ${S?"w-fit grow-0":"w-full grow"}`,dir:H==="he"||H==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${D?D===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${H||"en"}`,de==null?void 0:de.graphContainer),style:{...(ce==null?void 0:ce.graphContainer)||{},...D&&D!==!0?{backgroundColor:D}:{}},id:Y,ref:ve,"aria-label":re||`${r?`The graph shows ${r}. `:""}This is an animated dumbbell chart that shows comparisons between two or more data points across categories. ${l?` ${l}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:D?_||"1rem":_||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||l||j||$?v.jsx(Zt,{styles:{title:ce==null?void 0:ce.title,description:ce==null?void 0:ce.description},classNames:{title:de==null?void 0:de.title,description:de==null?void 0:de.description},graphTitle:r,graphDescription:l,width:S,graphDownload:j?ve.current:void 0,dataDownload:$?e.map(je=>je.data).filter(je=>je!==void 0).length>0?e.map(je=>je.data).filter(je=>je!==void 0):e.filter(je=>je!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{ue(!le)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":le?"Click to pause animation":"Click to play animation",children:le?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:Ce[0],max:Ce[Ce.length-1],marks:be,step:null,defaultValue:Ce[Ce.length-1],value:Ce[pe],onChangeComplete:je=>{ye(Ce.indexOf(je))},onChange:je=>{ye(Ce.indexOf(je))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[v.jsx(Cn,{width:S,colorDomain:C,colors:n,colorLegendTitle:k,setSelectedColor:we,showNAColor:!1}),v.jsx("div",{className:"flex grow w-full justify-center leading-0",ref:ge,"aria-label":"Graph area",children:(S||Oe)&&(b||Te)?v.jsx(dve,{data:e,dotColors:n,width:S||Oe,height:Math.max(R,b||(E?R?(S||Oe)*E>R?(S||Oe)*E:R:(S||Oe)*E:Te)),suffix:a,prefix:i,radius:T,barPadding:s,showTicks:f,leftMargin:c,rightMargin:h,topMargin:d,bottomMargin:m,truncateBy:g,showLabels:A,showValues:y,tooltip:M,onSeriesMouseOver:N,maxPositionValue:ne,minPositionValue:K,onSeriesMouseClick:B,selectedColor:xe,dateFormat:G,indx:pe,sortParameter:V,arrowConnector:ae,connectorStrokeWidth:U,maxBarThickness:J,minBarThickness:Z,resetSelectionOnDoubleClick:te,detailsOnClick:F,axisTitle:q,noOfTicks:X,valueColor:ie,styles:ce,classNames:de,refValues:he,rtl:H==="he"||H==="ar"}):null})]}),o||w?v.jsx(tr,{styles:{footnote:ce==null?void 0:ce.footnote,source:ce==null?void 0:ce.source},classNames:{footnote:de==null?void 0:de.footnote,source:de==null?void 0:de.source},sources:o,footNote:w,width:S}):null]})})})})}function pve(t){var _e,xe,we,ge,ve,le,ue,Ce,pe,ye;const{data:e,dotColors:r,barPadding:n,showTicks:a,leftMargin:i,truncateBy:o,width:l,height:s,rightMargin:f,topMargin:c,bottomMargin:h,radius:d,showLabels:m,tooltip:g,onSeriesMouseOver:y,maxPositionValue:b,minPositionValue:S,onSeriesMouseClick:w,showValues:C,suffix:k,prefix:_,selectedColor:D,dateFormat:T,indx:A,sortParameter:M,arrowConnector:E,connectorStrokeWidth:N,maxBarThickness:Y,minBarThickness:ne,resetSelectionOnDoubleClick:K,detailsOnClick:B,axisTitle:j,noOfTicks:$,valueColor:V,styles:z,classNames:W,refValues:G}=t,ae=Ut(e.map(be=>({...be,date:bt(`${be.date}`,T,new Date)})),"date"),U=Bt(ae,be=>be.label).map(be=>be.label),H=Array.from(Hi(uq(e,T||"yyyy"),be=>be.date),([be,je])=>({date:be,values:M!==void 0?M==="diff"?Ut(je,$e=>Fe($e.x[$e.x.length-1])||Fe($e.x[0])?-1/0:$e.x[$e.x.length-1]-$e.x[0]).map(($e,ut)=>({...$e,id:`${ut}`})):Ut(je,$e=>Fe($e.x[M])?-1/0:$e.x[M]).map(($e,ut)=>({...$e,id:`${ut}`})):U.map($e=>je.find(ut=>ut.label===$e)).map(($e,ut)=>({...$e,id:`${ut}`}))})),R={top:c,bottom:h,left:j?i+30:i,right:f},ee=l-R.left-R.right,J=s-R.top-R.bottom,[Z,re]=I.useState(void 0),[te,F]=I.useState(void 0),[q,X]=I.useState(void 0),[ie,ce]=I.useState(void 0),de=Fe(b)?Math.max(...e.map(be=>Mn(be.x)||0))<0?0:Math.max(...e.map(be=>Mn(be.x)||0)):b,he=Fe(S)?Math.min(...e.map(be=>gr(be.x)||0))>0?0:Math.min(...e.map(be=>gr(be.x)||0)):S,Oe=br().domain([he,de]).range([J,0]).nice(),Ne=Un().domain(U.map((be,je)=>`${je}`)).range([0,ne?Math.max(ee,ne*U.length):Y?Math.min(ee,Y*U.length):ee]).paddingInner(n),Te=Oe.ticks($);return v.jsxs(v.Fragment,{children:[v.jsxs("svg",{width:`${l}px`,height:`${s}px`,viewBox:`0 0 ${l} ${s}`,direction:"ltr",children:[E?v.jsx("defs",{children:v.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:v.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-primary-gray-600 dark:fill-primary-gray-300"})})}):null,v.jsxs("g",{transform:`translate(${R.left},${R.top})`,children:[v.jsx(Nr,{y1:Oe(he<0?0:he),y2:Oe(he<0?0:he),x1:0-i,x2:ee+R.right,label:_t(he<0?0:he,_,k),labelPos:{x:0-i,y:de<0?0:Oe(he<0?0:he),dx:0,dy:de<0?"1em":-5},classNames:{axis:(_e=W==null?void 0:W.xAxis)==null?void 0:_e.axis,label:(xe=W==null?void 0:W.yAxis)==null?void 0:xe.labels},styles:{axis:(we=z==null?void 0:z.xAxis)==null?void 0:we.axis,label:(ge=z==null?void 0:z.yAxis)==null?void 0:ge.labels}}),a?v.jsx(v1,{values:Te.filter(be=>be!==0),y:Te.filter(be=>be!==0).map(be=>Oe(be)),x1:0-i,x2:ee+R.right,styles:{gridLines:(ve=z==null?void 0:z.yAxis)==null?void 0:ve.gridLines,labels:(le=z==null?void 0:z.yAxis)==null?void 0:le.labels},classNames:{gridLines:(ue=W==null?void 0:W.yAxis)==null?void 0:ue.gridLines,labels:(Ce=W==null?void 0:W.yAxis)==null?void 0:Ce.labels},suffix:k,prefix:_,labelType:"secondary",showGridLines:!0,labelPos:"vertical"}):null,v.jsx(nn,{x:0-i-15,y:J/2,style:(pe=z==null?void 0:z.yAxis)==null?void 0:pe.title,className:(ye=W==null?void 0:W.yAxis)==null?void 0:ye.title,text:j,rotate90:!0}),v.jsx(mo,{children:H[A].values.map((be,je)=>{var $e,ut;return v.jsxs(ur.g,{className:"undp-viz-low-opacity undp-viz-g-with-hover",children:[m?v.jsx(ur.text,{style:{textAnchor:"middle",...(($e=z==null?void 0:z.xAxis)==null?void 0:$e.labels)||{}},y:J+5,dy:"1em",animate:{attrX:Ne(`${je}`)+Ne.bandwidth()/2},transition:{duration:.5},className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(ut=W==null?void 0:W.xAxis)==null?void 0:ut.labels),children:`${be.label}`.length<o?be.label:`${`${be.label}`.substring(0,o)}...`}):null,v.jsx(ur.line,{style:{strokeWidth:N,...(z==null?void 0:z.dataConnectors)||{},opacity:D?.3:1},className:Be("stroke-primary-gray-600 dark:stroke-primary-gray-300",W==null?void 0:W.dataConnectors),markerEnd:E&&be.x.indexOf(gr(be.x))===0?"url(#arrow)":"",markerStart:E&&be.x.indexOf(gr(be.x))===be.x.length-1?"url(#arrow)":"",animate:{x1:Ne(`${je}`)+Ne.bandwidth()/2,y1:Oe(gr(be.x))-d,x2:Ne(`${je}`)+Ne.bandwidth()/2,y2:Oe(Mn(be.x))+d},transition:{duration:.5}}),be.x.map((Ie,Ze)=>v.jsxs("g",{opacity:D?r[Ze]===D?1:.3:1,onMouseEnter:Ke=>{re({...be,xIndex:Ze}),ce(Ke.clientY),X(Ke.clientX),y&&y({...be,xIndex:Ze})},onClick:()=>{(w||B)&&(Sr(te,{...be,xIndex:Ze})&&K?(F(void 0),w==null||w(void 0)):(F({...be,xIndex:Ze}),w&&w({...be,xIndex:Ze})))},onMouseMove:Ke=>{re({...be,xIndex:Ze}),ce(Ke.clientY),X(Ke.clientX)},onMouseLeave:()=>{re(void 0),X(void 0),ce(void 0),y&&y(void 0)},children:[v.jsx(ur.circle,{r:d,style:{fill:r[Ze],fillOpacity:.85,stroke:r[Ze],strokeWidth:1},animate:{cx:Ne(`${je}`)+Ne.bandwidth()/2,cy:Oe(Ie||0),opacity:Fe(Ie)?0:1},transition:{duration:.5}}),C?v.jsx(ur.text,{style:{fill:V||r[Ze],textAnchor:"start",...(z==null?void 0:z.graphObjectValues)||{}},className:Be("graph-value text-sm font-bold",W==null?void 0:W.graphObjectValues),dx:d+3,dy:"0.33em",animate:{attrX:Ne(`${je}`)+Ne.bandwidth()/2,attrY:Oe(Ie||0),opacity:Fe(Ie)?0:1},transition:{duration:.5},children:_t(Ie,_,k)}):null]},Ze))]},be.label)})}),G?v.jsx(v.Fragment,{children:G.map((be,je)=>v.jsx(h1,{text:be.text,color:be.color,y:Oe(be.value),x1:0-i,x2:ee+R.right,classNames:be.classNames,styles:be.styles},je))}):null]})]}),Z&&g&&q&&ie?v.jsx(yr,{data:Z,body:g,xPos:q,yPos:ie,backgroundStyle:z==null?void 0:z.tooltip,className:W==null?void 0:W.tooltip}):null,B?v.jsx(Tr,{open:te!==void 0,onClose:()=>{F(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(B,te)}})}):null]})}function mve(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,sources:a,graphDescription:i,barPadding:o=.25,showTicks:l=!0,leftMargin:s=20,rightMargin:f=20,topMargin:c=20,bottomMargin:h=25,truncateBy:d=999,height:m,width:g,footNote:y,colorDomain:b,colorLegendTitle:S,padding:w,backgroundColor:C=!1,radius:k=3,tooltip:_,showLabels:D=!0,relativeHeight:T,onSeriesMouseOver:A,graphID:M,suffix:E="",prefix:N="",maxPositionValue:Y,minPositionValue:ne,onSeriesMouseClick:K,graphDownload:B=!1,dataDownload:j=!1,showValues:$=!0,sortParameter:V,arrowConnector:z=!1,connectorStrokeWidth:W=2,language:G="en",minHeight:ae=0,theme:U="light",showOnlyActiveDate:H=!1,autoPlay:R=!1,dateFormat:ee="yyyy",maxBarThickness:J,minBarThickness:Z,ariaLabel:re,resetSelectionOnDoubleClick:te=!0,detailsOnClick:F,axisTitle:q,noOfTicks:X=5,valueColor:ie,styles:ce,classNames:de,refValues:he}=t,[Oe,Ne]=I.useState(0),[Te,_e]=I.useState(0),[xe,we]=I.useState(void 0),ge=I.useRef(null),ve=I.useRef(null);I.useEffect(()=>{const je=new ResizeObserver($e=>{Ne(g||$e[0].target.clientWidth||620),_e(m||$e[0].target.clientHeight||480)});return ge.current&&(_e(ge.current.clientHeight||480),Ne(ge.current.clientWidth||620),g||je.observe(ge.current)),()=>je.disconnect()},[g,m]);const[le,ue]=I.useState(R),Ce=qi(Bt(e,je=>je.date).map(je=>bt(`${je.date}`,ee,new Date).getTime()),(je,$e)=>Ka(je,$e)),[pe,ye]=I.useState(R?0:Ce.length-1),be={};return Ce.forEach((je,$e)=>{be[`${je}`]={style:{color:$e===pe?"#232E3D":"#A9B1B7",fontWeight:$e===pe?"bold":"normal",display:$e===pe||!H?"inline":"none"},label:Sa(new Date(je),ee)}}),I.useEffect(()=>{const je=setInterval(()=>{ye($e=>$e<Ce.length-1?$e+1:0)},2e3);return le||clearInterval(je),()=>clearInterval(je)},[Ce,le]),v.jsx("div",{className:`${U||"light"} flex ${g?"w-fit grow-0":"w-full grow"}`,dir:G==="he"||G==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${G||"en"}`,de==null?void 0:de.graphContainer),style:{...(ce==null?void 0:ce.graphContainer)||{},...C&&C!==!0?{backgroundColor:C}:{}},id:M,ref:ve,"aria-label":re||`${r?`The graph shows ${r}. `:""}This is a dumbbell chart that shows comparisons between two or more data points across categories. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:C?w||"1rem":w||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||B||j?v.jsx(Zt,{styles:{title:ce==null?void 0:ce.title,description:ce==null?void 0:ce.description},classNames:{title:de==null?void 0:de.title,description:de==null?void 0:de.description},graphTitle:r,graphDescription:i,width:g,graphDownload:B?ve.current:void 0,dataDownload:j?e.map(je=>je.data).filter(je=>je!==void 0).length>0?e.map(je=>je.data).filter(je=>je!==void 0):e.filter(je=>je!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{ue(!le)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":le?"Click to pause animation":"Click to play animation",children:le?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:Ce[0],max:Ce[Ce.length-1],marks:be,step:null,defaultValue:Ce[Ce.length-1],value:Ce[pe],onChangeComplete:je=>{ye(Ce.indexOf(je))},onChange:je=>{ye(Ce.indexOf(je))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[v.jsx(Cn,{width:g,colorDomain:b,colors:n,colorLegendTitle:S,setSelectedColor:we,showNAColor:!1}),v.jsx("div",{className:"flex grow w-full justify-center leading-0",ref:ge,"aria-label":"Graph area",children:(g||Oe)&&(m||Te)?v.jsx(pve,{data:e,dotColors:n,width:g||Oe,height:Math.max(ae,m||(T?ae?(g||Oe)*T>ae?(g||Oe)*T:ae:(g||Oe)*T:Te)),radius:k,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:D,showValues:$,tooltip:_,suffix:E,prefix:N,onSeriesMouseOver:A,maxPositionValue:Y,minPositionValue:ne,onSeriesMouseClick:K,selectedColor:xe,dateFormat:ee,indx:pe,sortParameter:V,arrowConnector:z,connectorStrokeWidth:W,maxBarThickness:J,minBarThickness:Z,resetSelectionOnDoubleClick:te,detailsOnClick:F,axisTitle:q,noOfTicks:X,valueColor:ie,styles:ce,classNames:de,refValues:he}):null})]}),a||y?v.jsx(tr,{styles:{footnote:ce==null?void 0:ce.footnote,source:ce==null?void 0:ce.source},classNames:{footnote:de==null?void 0:de.footnote,source:de==null?void 0:de.source},sources:a,footNote:y,width:g}):null]})})})})}function mq(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,height:m,width:g,footNote:y,colorDomain:b,colorLegendTitle:S,padding:w,backgroundColor:C,radius:k,tooltip:_,showLabels:D,relativeHeight:T,onSeriesMouseOver:A,graphID:M,suffix:E,prefix:N,maxPositionValue:Y,minPositionValue:ne,onSeriesMouseClick:K,graphDownload:B,dataDownload:j,showValues:$,sortParameter:V,arrowConnector:z,connectorStrokeWidth:W,language:G,minHeight:ae,theme:U,showOnlyActiveDate:H,autoPlay:R,dateFormat:ee,maxBarThickness:J,minBarThickness:Z,ariaLabel:re,resetSelectionOnDoubleClick:te,detailsOnClick:F,axisTitle:q,noOfTicks:X,valueColor:ie,orientation:ce="vertical",refValues:de,styles:he,classNames:Oe}=t;return ce==="vertical"?v.jsx(mve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,height:m,width:g,footNote:y,colorDomain:b,colorLegendTitle:S,padding:w,backgroundColor:C,radius:k,tooltip:_,showLabels:D,relativeHeight:T,onSeriesMouseOver:A,graphID:M,suffix:E,prefix:N,maxPositionValue:Y,minPositionValue:ne,onSeriesMouseClick:K,graphDownload:B,dataDownload:j,showValues:$,sortParameter:V,arrowConnector:z,connectorStrokeWidth:W,language:G,minHeight:ae,theme:U,showOnlyActiveDate:H,autoPlay:R,dateFormat:ee,maxBarThickness:J,minBarThickness:Z,ariaLabel:re,resetSelectionOnDoubleClick:te,styles:he,detailsOnClick:F,axisTitle:q,noOfTicks:X,refValues:de,valueColor:ie,classNames:Oe}):v.jsx(hve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,height:m,width:g,footNote:y,colorDomain:b,colorLegendTitle:S,padding:w,backgroundColor:C,radius:k,tooltip:_,showLabels:D,relativeHeight:T,onSeriesMouseOver:A,graphID:M,suffix:E,prefix:N,maxPositionValue:Y,minPositionValue:ne,onSeriesMouseClick:K,graphDownload:B,dataDownload:j,showValues:$,sortParameter:V,arrowConnector:z,connectorStrokeWidth:W,language:G,minHeight:ae,theme:U,showOnlyActiveDate:H,autoPlay:R,dateFormat:ee,maxBarThickness:J,minBarThickness:Z,ariaLabel:re,resetSelectionOnDoubleClick:te,styles:he,detailsOnClick:F,axisTitle:q,noOfTicks:X,refValues:de,valueColor:ie,classNames:Oe})}function gve(t){var _e,xe,we,ge,ve,le,ue,Ce;const{data:e,barColor:r,suffix:n,prefix:a,barPadding:i,showValues:o,showTicks:l,leftMargin:s,truncateBy:f,width:c,height:h,colorDomain:d,rightMargin:m,topMargin:g,bottomMargin:y,showLabels:b,tooltip:S,onSeriesMouseOver:w,refValues:C,selectedColor:k,highlightedDataPoints:_,maxValue:D,minValue:T,onSeriesMouseClick:A,dateFormat:M,indx:E,autoSort:N,rtl:Y,maxBarThickness:ne,minBarThickness:K,resetSelectionOnDoubleClick:B,detailsOnClick:j,barAxisTitle:$,valueColor:V,noOfTicks:z,styles:W,classNames:G}=t,[ae,U]=I.useState(void 0),[H,R]=I.useState(void 0),[ee,J]=I.useState(void 0),[Z,re]=I.useState(void 0),te={top:$?g+25:g,bottom:y,left:s,right:m},F=c-te.left-te.right,q=h-te.top-te.bottom,X=Ut(e.map(pe=>({...pe,date:bt(`${pe.date}`,M,new Date)})),"date"),ie=Bt(X,pe=>pe.label).map(pe=>pe.label),ce=Array.from(Hi(sq(e,M||"yyyy"),pe=>pe.date),([pe,ye])=>({date:pe,values:N?a7(ye,[be=>be.size===void 0,"size"],["asc","desc"]).map((be,je)=>({...be,id:`${je}`})):ie.map(be=>ye.find(je=>je.label===be)).map((be,je)=>({...be,id:`${je}`}))})),de=Fe(D)?Math.max(...e.filter(pe=>!Fe(pe.size)).map(pe=>pe.size))<0?0:Math.max(...e.filter(pe=>!Fe(pe.size)).map(pe=>pe.size)):D,he=Fe(T)?Math.min(...e.filter(pe=>!Fe(pe.size)).map(pe=>pe.size))>=0?0:Math.min(...e.filter(pe=>!Fe(pe.size)).map(pe=>pe.size)):T,Oe=br().domain([he,de]).range([0,F]).nice(),Ne=Un().domain(ie.map((pe,ye)=>`${ye}`)).range([0,K?Math.max(q,K*ie.length):ne?Math.min(q,ne*ie.length):q]).paddingInner(i),Te=Oe.ticks(z);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${c}px`,height:`${h}px`,viewBox:`0 0 ${c} ${h}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${te.left},${te.top})`,children:[l?v.jsx(La,{values:Te.filter(pe=>pe!==0),x:Te.filter(pe=>pe!==0).map(pe=>Oe(pe)),y1:0-g,y2:q+te.bottom,styles:{gridLines:(_e=W==null?void 0:W.xAxis)==null?void 0:_e.gridLines,labels:(xe=W==null?void 0:W.xAxis)==null?void 0:xe.labels},classNames:{gridLines:(we=G==null?void 0:G.xAxis)==null?void 0:we.gridLines,labels:(ge=G==null?void 0:G.xAxis)==null?void 0:ge.labels},suffix:n,prefix:a,labelType:"secondary",showGridLines:!0}):null,v.jsx(nn,{x:F/2,y:0-te.top+15,style:(ve=W==null?void 0:W.xAxis)==null?void 0:ve.title,className:(le=G==null?void 0:G.xAxis)==null?void 0:le.title,text:$}),v.jsx(mo,{children:ce[E].values.map(pe=>{var ye,be;return v.jsxs(ur.g,{transition:{duration:.5},className:"undp-viz-g-with-hover",opacity:k?pe.color&&r[d.indexOf(pe.color)]===k?1:.3:_.length!==0?_.indexOf(pe.label)!==-1?.85:.3:.85,onMouseEnter:je=>{U(pe),J(je.clientY),R(je.clientX),w&&w(pe)},onClick:()=>{(A||j)&&(Sr(Z,pe)&&B?(re(void 0),A==null||A(void 0)):(re(pe),A==null||A(pe)))},onMouseMove:je=>{U(pe),J(je.clientY),R(je.clientX)},onMouseLeave:()=>{U(void 0),R(void 0),J(void 0),w&&w(void 0)},children:[v.jsx(ur.rect,{style:{fill:e.filter(je=>je.color).length===0?r[0]:pe.color?r[d.indexOf(pe.color)]:Qe.gray},height:Ne.bandwidth(),animate:{width:pe.size?pe.size>=0?Oe(pe.size)-Oe(0):Oe(0)-Oe(pe.size):0,attrX:pe.size?pe.size>=0?Oe(0):Oe(pe.size):0,attrY:Ne(pe.id),fill:e.filter(je=>je.color).length===0?r[0]:pe.color?r[d.indexOf(pe.color)]:Qe.gray},transition:{duration:.5}}),b?v.jsx(ur.text,{style:{textAnchor:pe.size&&pe.size<0?"start":"end",...((ye=W==null?void 0:W.yAxis)==null?void 0:ye.labels)||{}},className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(be=G==null?void 0:G.yAxis)==null?void 0:be.labels),x:0,y:0,dx:pe.size&&pe.size<0?10:-10,dy:"0.33em",animate:{attrX:Oe(he<0?0:he),attrY:Ne(pe.id)+Ne.bandwidth()/2},transition:{duration:.5},children:`${pe.label}`.length<f?`${pe.label}`:`${`${pe.label}`.substring(0,f)}...`}):null,o?v.jsx(ur.text,{y:0,style:{...V?{fill:V}:r.length>1?{}:{fill:r[0]},textAnchor:pe.size&&pe.size<0?"end":"start",...(W==null?void 0:W.graphObjectValues)||{}},className:Be("graph-value text-sm",!V&&r.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",G==null?void 0:G.graphObjectValues),dx:pe.size&&pe.size<0?-5:5,animate:{attrX:pe.size?Oe(pe.size):Oe(0),attrY:Ne(pe.id)+Ne.bandwidth()/2},dy:"0.33em",transition:{duration:.5},children:_t(pe.size,a,n)}):null]},pe.label)})}),v.jsx(Nr,{x1:Oe(he<0?0:he),x2:Oe(he<0?0:he),y1:-2.5,y2:q+te.bottom,classNames:{axis:(ue=G==null?void 0:G.yAxis)==null?void 0:ue.axis},styles:{axis:(Ce=W==null?void 0:W.yAxis)==null?void 0:Ce.axis}}),C?v.jsx(v.Fragment,{children:C.map((pe,ye)=>v.jsx(ti,{text:pe.text,color:pe.color,x:Oe(pe.value),y1:0-te.top,y2:q+te.bottom,textSide:Oe(pe.value)>F*.75||Y?"left":"right",classNames:pe.classNames,styles:pe.styles},ye))}):null]})}),ae&&S&&H&&ee?v.jsx(yr,{data:ae,body:S,xPos:H,yPos:ee,backgroundStyle:W==null?void 0:W.tooltip,className:G==null?void 0:G.tooltip}):null,j?v.jsx(Tr,{open:Z!==void 0,onClose:()=>{re(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(j,Z)}})}):null]})}function yve(t){const{data:e,graphTitle:r,colors:n,suffix:a="",sources:i,prefix:o="",graphDescription:l,barPadding:s=.25,showValues:f=!0,showTicks:c=!0,leftMargin:h=100,rightMargin:d=40,truncateBy:m=999,height:g,width:y,footNote:b,colorDomain:S,colorLegendTitle:w,highlightedDataPoints:C=[],padding:k,backgroundColor:_=!1,topMargin:D=25,bottomMargin:T=10,showLabels:A=!0,relativeHeight:M,tooltip:E,onSeriesMouseOver:N,refValues:Y,showColorScale:ne=!0,graphID:K,maxValue:B,minValue:j,onSeriesMouseClick:$,graphDownload:V=!1,dataDownload:z=!1,dateFormat:W="yyyy",showOnlyActiveDate:G=!1,autoPlay:ae=!1,autoSort:U=!0,language:H="en",showNAColor:R=!0,minHeight:ee=0,theme:J="light",maxBarThickness:Z,minBarThickness:re,ariaLabel:te,resetSelectionOnDoubleClick:F=!0,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie=5,valueColor:ce,styles:de,classNames:he}=t,[Oe,Ne]=I.useState(0),[Te,_e]=I.useState(0),[xe,we]=I.useState(void 0),[ge,ve]=I.useState(ae),le=I.useRef(null),ue=I.useRef(null);I.useEffect(()=>{const je=new ResizeObserver($e=>{Ne(y||$e[0].target.clientWidth||620),_e(g||$e[0].target.clientHeight||480)});return le.current&&(_e(le.current.clientHeight||480),Ne(le.current.clientWidth||620),y||je.observe(le.current)),()=>je.disconnect()},[y,g]);const Ce=qi(Bt(e,je=>je.date).map(je=>bt(`${je.date}`,W,new Date).getTime()),(je,$e)=>Ka(je,$e)),[pe,ye]=I.useState(ae?0:Ce.length-1),be={};return Ce.forEach((je,$e)=>{be[`${je}`]={style:{color:$e===pe?"#232E3D":"#A9B1B7",fontWeight:$e===pe?"bold":"normal",display:$e===pe||!G?"inline":"none"},label:Sa(new Date(je),W)}}),I.useEffect(()=>{const je=setInterval(()=>{ye($e=>$e<Ce.length-1?$e+1:0)},2e3);return ge||clearInterval(je),()=>clearInterval(je)},[Ce,ge]),v.jsx("div",{className:`${J||"light"} flex ${y?"w-fit grow-0":"w-full grow"}`,dir:H==="he"||H==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${_?_===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${H||"en"}`,he==null?void 0:he.graphContainer),style:{...(de==null?void 0:de.graphContainer)||{},..._&&_!==!0?{backgroundColor:_}:{}},id:K,ref:ue,"aria-label":te||`${r?`The graph shows ${r}. `:""}This is an animated bar chart showing data changes over time. ${l?` ${l}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:_?k||"1rem":k||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||l||V||z?v.jsx(Zt,{styles:{title:de==null?void 0:de.title,description:de==null?void 0:de.description},classNames:{title:he==null?void 0:he.title,description:he==null?void 0:he.description},graphTitle:r,graphDescription:l,width:y,graphDownload:V?ue.current:void 0,dataDownload:z?e.map(je=>je.data).filter(je=>je!==void 0).length>0?e.map(je=>je.data).filter(je=>je!==void 0):e.filter(je=>je!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{ve(!ge)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ge?"Click to pause animation":"Click to play animation",children:ge?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:Ce[0],max:Ce[Ce.length-1],marks:be,step:null,defaultValue:Ce[Ce.length-1],value:Ce[pe],onChangeComplete:je=>{ye(Ce.indexOf(je))},onChange:je=>{ye(Ce.indexOf(je))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[ne&&e.filter(je=>je.color).length!==0?v.jsx(Cn,{width:y,colorLegendTitle:w,colors:n||Qe[J].categoricalColors.colors,colorDomain:S||Bt(e.filter(je=>je.color),"color").map(je=>je.color),setSelectedColor:we,showNAColor:R}):null,v.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:le,"aria-label":"Graph area",children:(y||Oe)&&(g||Te)?v.jsx(gve,{data:e,barColor:e.filter(je=>je.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[J].categoricalColors.colors,colorDomain:e.filter(je=>je.color).length===0?[]:S||Bt(e.filter(je=>je.color),"color").map(je=>je.color),width:y||Oe,selectedColor:xe,height:Math.max(ee,g||(M?ee?(y||Oe)*M>ee?(y||Oe)*M:ee:(y||Oe)*M:Te)),suffix:a,prefix:o,barPadding:s,showValues:f,showTicks:c,leftMargin:h,rightMargin:d,topMargin:D,bottomMargin:T,truncateBy:m,showLabels:A,tooltip:E,onSeriesMouseOver:N,refValues:Y,maxValue:B,minValue:j,highlightedDataPoints:C,onSeriesMouseClick:$,dateFormat:W,indx:pe,autoSort:U,rtl:H==="he"||H==="ar",maxBarThickness:Z,minBarThickness:re,resetSelectionOnDoubleClick:F,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie,valueColor:ce,styles:de,classNames:he}):null})]}),i||b?v.jsx(tr,{styles:{footnote:de==null?void 0:de.footnote,source:de==null?void 0:de.source},classNames:{footnote:he==null?void 0:he.footnote,source:he==null?void 0:he.source},sources:i,footNote:b,width:y}):null]})})})})}function vve(t){var Oe,Ne,Te,_e,xe,we,ge,ve;const{data:e,barColors:r,barPadding:n,showTicks:a,leftMargin:i,truncateBy:o,width:l,height:s,suffix:f,prefix:c,showValues:h,rightMargin:d,topMargin:m,bottomMargin:g,showLabels:y,tooltip:b,onSeriesMouseOver:S,refValues:w,maxValue:C,minValue:k,onSeriesMouseClick:_,selectedColor:D,dateFormat:T,indx:A,rtl:M,maxBarThickness:E,resetSelectionOnDoubleClick:N,detailsOnClick:Y,barAxisTitle:ne,valueColor:K,noOfTicks:B,styles:j,classNames:$}=t,V=Ut(e.map(le=>({...le,date:bt(`${le.date}`,T,new Date)})),"date"),z=Bt(V,le=>le.label).map(le=>le.label),W=Array.from(Hi(Vf(e,T||"yyyy"),le=>le.date),([le,ue])=>({date:le,values:z.map(Ce=>ue.find(pe=>pe.label===Ce)).map((Ce,pe)=>({...Ce,id:`${pe}`}))})),G={top:ne?m+25:m,bottom:g,left:i,right:d},[ae,U]=I.useState(void 0),[H,R]=I.useState(void 0),[ee,J]=I.useState(void 0),[Z,re]=I.useState(void 0),te=l-G.left-G.right,F=s-G.top-G.bottom,q=Fe(C)?Math.max(...e.map(le=>Mn(le.size.filter(ue=>!Fe(ue)))||0))<0?0:Math.max(...e.map(le=>Mn(le.size.filter(ue=>!Fe(ue)))||0)):C,X=Fe(k)?Math.min(...e.map(le=>gr(le.size.filter(ue=>!Fe(ue)))||0))>=0?0:Math.min(...e.map(le=>gr(le.size.filter(ue=>!Fe(ue)))||0)):k,ie=br().domain([X,q]).range([0,te]).nice(),ce=Un().domain(z.map((le,ue)=>`${ue}`)).range([0,E?Math.min(te,E*z.length):F]).paddingInner(n),de=Un().domain(e[0].size.map((le,ue)=>`${ue}`)).range([0,ce.bandwidth()]).paddingInner(.1),he=ie.ticks(B);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${l}px`,height:`${s}px`,viewBox:`0 0 ${l} ${s}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${G.left},${G.top})`,children:[a?v.jsx(La,{values:he.filter(le=>le!==0),x:he.filter(le=>le!==0).map(le=>ie(le)),y1:0-m,y2:F+G.bottom,styles:{gridLines:(Oe=j==null?void 0:j.xAxis)==null?void 0:Oe.gridLines,labels:(Ne=j==null?void 0:j.xAxis)==null?void 0:Ne.labels},classNames:{gridLines:(Te=$==null?void 0:$.xAxis)==null?void 0:Te.gridLines,labels:(_e=$==null?void 0:$.xAxis)==null?void 0:_e.labels},suffix:f,prefix:c,labelType:"secondary",showGridLines:!0}):null,v.jsx(nn,{x:te/2,y:0-G.top+15,style:(xe=j==null?void 0:j.xAxis)==null?void 0:xe.title,className:(we=$==null?void 0:$.xAxis)==null?void 0:we.title,text:ne}),v.jsx(mo,{children:W[A].values.map((le,ue)=>{var Ce,pe;return v.jsxs(ur.g,{transform:`translate(0,${ce(`${ue}`)})`,children:[le.size.map((ye,be)=>v.jsxs(ur.g,{className:"undp-viz-g-with-hover",opacity:D?r[be]===D?1:.3:.85,onMouseEnter:je=>{U({...le,sizeIndex:be}),re(je.clientY),J(je.clientX),S&&S({...le,sizeIndex:be})},onMouseMove:je=>{U({...le,sizeIndex:be}),re(je.clientY),J(je.clientX)},onMouseLeave:()=>{U(void 0),J(void 0),re(void 0),S&&S(void 0)},onClick:()=>{(_||Y)&&(Sr(H,{...le,sizeIndex:be})&&N?(R(void 0),_&&_(void 0)):(R({...le,sizeIndex:be}),_&&_({...le,sizeIndex:be})))},children:[v.jsx(ur.rect,{y:de(`${be}`),style:{fill:r[be]},height:de.bandwidth(),animate:{width:Fe(ye)?0:ye>=0?ie(ye)-ie(0):ie(0)-ie(ye),attrX:ye>=0?ie(0):ie(ye)},transition:{duration:.5}},be),h?v.jsx(ur.text,{y:de(`${be}`)+de.bandwidth()/2,style:{fill:K||r[be],textAnchor:ye&&ye<0?"end":"start",...(j==null?void 0:j.graphObjectValues)||{}},className:Be("graph-value text-sm",$==null?void 0:$.graphObjectValues),dx:ye&&ye<0?-5:5,dy:"0.33em",animate:{attrX:ie(ye||0)},transition:{duration:.5},children:_t(ye,c,f)}):null]},be)),y?v.jsx(Y2,{value:`${le.label}`.length<o?`${le.label}`:`${`${le.label}`.substring(0,o)}...`,y:0,x:0-G.left,width:ie(X<0?0:X)+G.left,height:ce.bandwidth(),style:(Ce=j==null?void 0:j.yAxis)==null?void 0:Ce.labels,className:(pe=$==null?void 0:$.yAxis)==null?void 0:pe.labels}):null]},ue)})}),v.jsx(Nr,{x1:ie(X<0?0:X),x2:ie(X<0?0:X),y1:-2.5,y2:F+G.bottom,classNames:{axis:(ge=$==null?void 0:$.yAxis)==null?void 0:ge.axis},styles:{axis:(ve=j==null?void 0:j.yAxis)==null?void 0:ve.axis}}),w?v.jsx(v.Fragment,{children:w.map((le,ue)=>v.jsx(ti,{text:le.text,color:le.color,x:ie(le.value),y1:0-G.top,y2:F+G.bottom,textSide:ie(le.value)>te*.75||M?"left":"right",classNames:le.classNames,styles:le.styles},ue))}):null]})}),ae&&b&&ee&&Z?v.jsx(yr,{data:ae,body:b,xPos:ee,yPos:Z,backgroundStyle:j==null?void 0:j.tooltip,className:$==null?void 0:$.tooltip}):null,Y?v.jsx(Tr,{open:H!==void 0,onClose:()=>{R(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(Y,H)}})}):null]})}function bve(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,sources:a,graphDescription:i,barPadding:o=.25,showTicks:l=!0,truncateBy:s=999,height:f,width:c,footNote:h,colorDomain:d,colorLegendTitle:m,suffix:g="",prefix:y="",showValues:b=!0,padding:S,backgroundColor:w=!1,leftMargin:C=100,rightMargin:k=40,topMargin:_=25,showLabels:D=!0,bottomMargin:T=10,relativeHeight:A,tooltip:M,onSeriesMouseOver:E,refValues:N,graphID:Y,maxValue:ne,minValue:K,onSeriesMouseClick:B,graphDownload:j=!1,dataDownload:$=!1,dateFormat:V="yyyy",showOnlyActiveDate:z=!1,autoPlay:W=!1,language:G="en",minHeight:ae=0,theme:U="light",maxBarThickness:H,ariaLabel:R,resetSelectionOnDoubleClick:ee=!0,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re=5,valueColor:te,styles:F,classNames:q}=t,[X,ie]=I.useState(0),[ce,de]=I.useState(0),[he,Oe]=I.useState(void 0),Ne=I.useRef(null),Te=I.useRef(null);I.useEffect(()=>{const ue=new ResizeObserver(Ce=>{ie(c||Ce[0].target.clientWidth||620),de(f||Ce[0].target.clientHeight||480)});return Ne.current&&(de(Ne.current.clientHeight||480),ie(Ne.current.clientWidth||620),c||ue.observe(Ne.current)),()=>ue.disconnect()},[c,f]);const[_e,xe]=I.useState(W),we=qi(Bt(e,ue=>ue.date).map(ue=>bt(`${ue.date}`,V,new Date).getTime()),(ue,Ce)=>Ka(ue,Ce)),[ge,ve]=I.useState(W?0:we.length-1),le={};return we.forEach((ue,Ce)=>{le[`${ue}`]={style:{color:Ce===ge?"#232E3D":"#A9B1B7",fontWeight:Ce===ge?"bold":"normal",display:Ce===ge||!z?"inline":"none"},label:Sa(new Date(ue),V)}}),I.useEffect(()=>{const ue=setInterval(()=>{ve(Ce=>Ce<we.length-1?Ce+1:0)},2e3);return _e||clearInterval(ue),()=>clearInterval(ue)},[we,_e]),v.jsx("div",{className:`${U||"light"} flex ${c?"w-fit grow-0":"w-full grow"}`,dir:G==="he"||G==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${w?w===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${G||"en"}`,q==null?void 0:q.graphContainer),style:{...(F==null?void 0:F.graphContainer)||{},...w&&w!==!0?{backgroundColor:w}:{}},id:Y,ref:Te,"aria-label":R||`${r?`The graph shows ${r}. `:""}This is an animated grouped bar chart showing data changes over time. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:w?S||"1rem":S||0},children:v.jsxs("div",{className:"flex flex-col gap-4 w-full grow justify-between",children:[r||i||j||$?v.jsx(Zt,{styles:{title:F==null?void 0:F.title,description:F==null?void 0:F.description},classNames:{title:q==null?void 0:q.title,description:q==null?void 0:q.description},graphTitle:r,graphDescription:i,width:c,graphDownload:j?Te.current:void 0,dataDownload:$?e.map(ue=>ue.data).filter(ue=>ue!==void 0).length>0?e.map(ue=>ue.data).filter(ue=>ue!==void 0):e.filter(ue=>ue!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{xe(!_e)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":_e?"Click to pause animation":"Click to play animation",children:_e?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:we[0],max:we[we.length-1],marks:le,step:null,defaultValue:we[we.length-1],value:we[ge],onChangeComplete:ue=>{ve(we.indexOf(ue))},onChange:ue=>{ve(we.indexOf(ue))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[v.jsx(Cn,{width:c,colorDomain:d,colors:n,colorLegendTitle:m,setSelectedColor:Oe,showNAColor:!1}),v.jsx("div",{className:"w-full grow leading-0",ref:Ne,"aria-label":"Graph area",children:(c||X)&&(f||ce)?v.jsx(vve,{data:e,barColors:n,width:c||X,height:Math.max(ae,f||(A?ae?(c||X)*A>ae?(c||X)*A:ae:(c||X)*A:ce)),suffix:g,prefix:y,showValues:b,barPadding:o,showTicks:l,leftMargin:C,rightMargin:k,topMargin:_,bottomMargin:T,truncateBy:s,showLabels:D,tooltip:M,onSeriesMouseOver:E,refValues:N,maxValue:ne,minValue:K,onSeriesMouseClick:B,selectedColor:he,dateFormat:V,indx:ge,rtl:G==="he"||G==="ar",maxBarThickness:H,resetSelectionOnDoubleClick:ee,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re,valueColor:te,styles:F,classNames:q}):null})]}),a||h?v.jsx(tr,{styles:{footnote:F==null?void 0:F.footnote,source:F==null?void 0:F.source},classNames:{footnote:q==null?void 0:q.footnote,source:q==null?void 0:q.source},sources:a,footNote:h,width:c}):null]})})})})}function xve(t){var Oe,Ne,Te,_e,xe,we,ge,ve;const{data:e,barColors:r,barPadding:n,showTicks:a,leftMargin:i,rightMargin:o,truncateBy:l,width:s,height:f,topMargin:c,bottomMargin:h,tooltip:d,onSeriesMouseOver:m,showLabels:g,suffix:y,prefix:b,showValues:S,refValues:w,maxValue:C,onSeriesMouseClick:k,selectedColor:_,dateFormat:D,indx:T,autoSort:A,rtl:M,sortParameter:E,maxBarThickness:N,minBarThickness:Y,resetSelectionOnDoubleClick:ne,detailsOnClick:K,barAxisTitle:B,valueColor:j,noOfTicks:$,styles:V,classNames:z}=t,[W,G]=I.useState(void 0),ae=Ut(e.map(le=>({...le,date:bt(`${le.date}`,D,new Date)})),"date"),U=Bt(ae,le=>le.label).map(le=>le.label),H=Array.from(Hi(Vf(e,D||"yyyy"),le=>le.date),([le,ue])=>({date:le,values:E!==void 0||A?E==="total"||E===void 0?Ut(e,Ce=>fr(Ce.size.filter(pe=>!Fe(pe)))).reverse().map((Ce,pe)=>({...Ce,id:`${pe}`})):Ut(e,Ce=>Fe(Ce.size[E])?-1/0:Ce.size[E]).reverse().map((Ce,pe)=>({...Ce,id:`${pe}`})):U.map(Ce=>ue.find(pe=>pe.label===Ce)).map((Ce,pe)=>({...Ce,id:`${pe}`}))})),R={top:B?c+25:c,bottom:h,left:i,right:o},[ee,J]=I.useState(void 0),[Z,re]=I.useState(void 0),[te,F]=I.useState(void 0),q=s-R.left-R.right,X=f-R.top-R.bottom,ie=Fe(C)?Math.max(...e.map(le=>fr(le.size.filter(ue=>!Fe(ue)))||0)):C,ce=br().domain([0,ie]).range([0,q]).nice(),de=Un().domain(U.map((le,ue)=>`${ue}`)).range([0,Y?Math.max(X,Y*U.length):N?Math.min(X,N*U.length):X]).paddingInner(n),he=ce.ticks($);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${s}px`,height:`${f}px`,viewBox:`0 0 ${s} ${f}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${R.left},${R.top})`,children:[a?v.jsx(La,{values:he.filter(le=>le!==0),x:he.filter(le=>le!==0).map(le=>ce(le)),y1:0-c,y2:X+R.bottom,styles:{gridLines:(Oe=V==null?void 0:V.xAxis)==null?void 0:Oe.gridLines,labels:(Ne=V==null?void 0:V.xAxis)==null?void 0:Ne.labels},classNames:{gridLines:(Te=z==null?void 0:z.xAxis)==null?void 0:Te.gridLines,labels:(_e=z==null?void 0:z.xAxis)==null?void 0:_e.labels},suffix:y,prefix:b,labelType:"secondary",showGridLines:!0}):null,v.jsx(nn,{x:q/2,y:0-R.top+15,style:(xe=V==null?void 0:V.xAxis)==null?void 0:xe.title,className:(we=z==null?void 0:z.xAxis)==null?void 0:we.title,text:B}),v.jsx(mo,{children:H[T].values.map(le=>v.jsxs("g",{className:"undp-viz-low-opacity undp-viz-g-with-hover",children:[le.size.map((ue,Ce)=>{var pe,ye;return v.jsxs(ur.g,{opacity:_?r[Ce]===_?1:.3:1,onMouseEnter:be=>{J({...le,sizeIndex:Ce}),F(be.clientY),re(be.clientX),m&&m({...le,sizeIndex:Ce})},onMouseMove:be=>{J({...le,sizeIndex:Ce}),F(be.clientY),re(be.clientX)},onMouseLeave:()=>{J(void 0),re(void 0),F(void 0),m&&m(void 0)},onClick:()=>{(k||K)&&(Sr(W,{...le,sizeIndex:Ce})&&ne?(G(void 0),k&&k(void 0)):(G({...le,sizeIndex:Ce}),k&&k({...le,sizeIndex:Ce})))},children:[v.jsx(ur.rect,{style:{fill:r[Ce]},height:de.bandwidth(),animate:{width:ce(ue||0),attrX:ce(Ce===0?0:fr(le.size.filter((be,je)=>je<Ce&&be))),attrY:de(le.id)},transition:{duration:.5}},Ce),g?v.jsx(ur.text,{style:{textAnchor:"end",...((pe=V==null?void 0:V.yAxis)==null?void 0:pe.labels)||{}},className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(ye=z==null?void 0:z.yAxis)==null?void 0:ye.labels),dx:-10,dy:"0.33em",animate:{attrX:ce(0),attrY:(de(le.id)||0)+de.bandwidth()/2},transition:{duration:.5},children:`${le.label}`.length<l?`${le.label}`:`${`${le.label}`.substring(0,l)}...`}):null,S?v.jsx(ur.text,{style:{fill:Bi(r[Ce]),textAnchor:"middle",...(V==null?void 0:V.graphObjectValues)||{}},className:Be("graph-value text-sm",z==null?void 0:z.graphObjectValues),dy:"0.33em",animate:{attrX:ce(Ce===0?0:fr(le.size.filter((be,je)=>je<Ce&&be)))+ce(ue||0)/2,attrY:(de(le.id)||0)+de.bandwidth()/2,opacity:ue&&ce(ue)/_t(ue,b,y).length>12?1:0},transition:{duration:.5},children:_t(ue,b,y)}):null]},Ce)}),S?v.jsx(ur.text,{style:{...j&&{fill:j},textAnchor:"start",...(V==null?void 0:V.graphObjectValues)||{}},className:Be("graph-value graph-value-total text-sm",j?"":" fill-primary-gray-700 dark:fill-primary-gray-300",z==null?void 0:z.graphObjectValues),dx:5,dy:"0.33em",animate:{attrX:ce(fr(le.size.map(ue=>ue||0))),attrY:(de(le.id)||0)+de.bandwidth()/2},transition:{duration:.5},children:_t(fr(le.size.filter(ue=>ue)),b,y)}):null]},le.label))}),v.jsx(Nr,{x1:ce(0),x2:ce(0),y1:-2.5,y2:X+R.bottom,classNames:{axis:(ge=z==null?void 0:z.yAxis)==null?void 0:ge.axis},styles:{axis:(ve=V==null?void 0:V.yAxis)==null?void 0:ve.axis}}),w?v.jsx(v.Fragment,{children:w.map((le,ue)=>v.jsx(ti,{text:le.text,color:le.color,x:ce(le.value),y1:0-R.top,y2:X+R.bottom,textSide:ce(le.value)>q*.75||M?"left":"right",classNames:le.classNames,styles:le.styles},ue))}):null]})}),ee&&d&&Z&&te?v.jsx(yr,{data:ee,body:d,xPos:Z,yPos:te,backgroundStyle:V==null?void 0:V.tooltip,className:z==null?void 0:z.tooltip}):null,K?v.jsx(Tr,{open:W!==void 0,onClose:()=>{G(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(K,W)}})}):null]})}function wve(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,sources:a,graphDescription:i,barPadding:o=.25,showTicks:l=!0,leftMargin:s=100,rightMargin:f=40,truncateBy:c=999,height:h,width:d,footNote:m,colorDomain:g,colorLegendTitle:y,padding:b,backgroundColor:S=!1,topMargin:w=25,bottomMargin:C=10,tooltip:k,onSeriesMouseOver:_,suffix:D="",prefix:T="",showLabels:A=!0,relativeHeight:M,showValues:E,refValues:N,graphID:Y,maxValue:ne,onSeriesMouseClick:K,graphDownload:B=!1,dataDownload:j=!1,dateFormat:$="yyyy",showOnlyActiveDate:V=!1,autoPlay:z=!1,autoSort:W=!0,language:G="en",minHeight:ae=0,theme:U="light",sortParameter:H,maxBarThickness:R,minBarThickness:ee,ariaLabel:J,resetSelectionOnDoubleClick:Z=!0,detailsOnClick:re,barAxisTitle:te,noOfTicks:F=5,valueColor:q,styles:X,classNames:ie}=t,[ce,de]=I.useState(0),[he,Oe]=I.useState(0),[Ne,Te]=I.useState(void 0),_e=I.useRef(null),xe=I.useRef(null);I.useEffect(()=>{const pe=new ResizeObserver(ye=>{de(d||ye[0].target.clientWidth||620),Oe(h||ye[0].target.clientHeight||480)});return _e.current&&(Oe(_e.current.clientHeight||480),de(_e.current.clientWidth||620),d||pe.observe(_e.current)),()=>pe.disconnect()},[d,h]);const[we,ge]=I.useState(z),ve=qi(Bt(e,pe=>pe.date).map(pe=>bt(`${pe.date}`,$,new Date).getTime()),(pe,ye)=>Ka(pe,ye)),[le,ue]=I.useState(z?0:ve.length-1),Ce={};return ve.forEach((pe,ye)=>{Ce[`${pe}`]={style:{color:ye===le?"#232E3D":"#A9B1B7",fontWeight:ye===le?"bold":"normal",display:ye===le||!V?"inline":"none"},label:Sa(new Date(pe),$)}}),I.useEffect(()=>{const pe=setInterval(()=>{ue(ye=>ye<ve.length-1?ye+1:0)},2e3);return we||clearInterval(pe),()=>clearInterval(pe)},[ve,we]),v.jsx("div",{className:`${U||"light"} flex ${d?"w-fit grow-0":"w-full grow"}`,dir:G==="he"||G==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${S?S===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${G||"en"}`,ie==null?void 0:ie.graphContainer),style:{...(X==null?void 0:X.graphContainer)||{},...S&&S!==!0?{backgroundColor:S}:{}},id:Y,ref:xe,"aria-label":J||`${r?`The graph shows ${r}. `:""}This is an animated stacked bar chart showing data changes over time. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:S?b||"1rem":b||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||B||j?v.jsx(Zt,{styles:{title:X==null?void 0:X.title,description:X==null?void 0:X.description},classNames:{title:ie==null?void 0:ie.title,description:ie==null?void 0:ie.description},graphTitle:r,graphDescription:i,width:d,graphDownload:B?xe.current:void 0,dataDownload:j?e.map(pe=>pe.data).filter(pe=>pe!==void 0).length>0?e.map(pe=>pe.data).filter(pe=>pe!==void 0):e.filter(pe=>pe!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{ge(!we)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":we?"Click to pause animation":"Click to play animation",children:we?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:ve[0],max:ve[ve.length-1],marks:Ce,step:null,defaultValue:ve[ve.length-1],value:ve[le],onChangeComplete:pe=>{ue(ve.indexOf(pe))},onChange:pe=>{ue(ve.indexOf(pe))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[v.jsx(Cn,{width:d,colorDomain:g,colors:n,colorLegendTitle:y,setSelectedColor:Te,showNAColor:!1}),v.jsx("div",{className:"w-full grow leading-0",ref:_e,"aria-label":"Graph area",children:(d||ce)&&(h||he)?v.jsx(xve,{data:e,barColors:n,width:d||ce,height:Math.max(ae,h||(M?ae?(d||ce)*M>ae?(d||ce)*M:ae:(d||ce)*M:he)),barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:w,bottomMargin:C,truncateBy:c,showLabels:A,tooltip:k,onSeriesMouseOver:_,showValues:E,suffix:D,prefix:T,refValues:N,maxValue:ne,onSeriesMouseClick:K,selectedColor:Ne,dateFormat:$,indx:le,sortParameter:H,autoSort:W,rtl:G==="he"||G==="ar",maxBarThickness:R,minBarThickness:ee,resetSelectionOnDoubleClick:Z,detailsOnClick:re,barAxisTitle:te,noOfTicks:F,valueColor:q,styles:X,classNames:ie}):null})]}),a||m?v.jsx(tr,{styles:{footnote:X==null?void 0:X.footnote,source:X==null?void 0:X.source},classNames:{footnote:ie==null?void 0:ie.footnote,source:ie==null?void 0:ie.source},sources:a,footNote:m,width:d}):null]})})})})}function Sve(t){var Te,_e,xe,we,ge,ve,le,ue,Ce,pe;const{data:e,barColor:r,suffix:n,prefix:a,barPadding:i,showValues:o,showTicks:l,leftMargin:s,truncateBy:f,width:c,height:h,colorDomain:d,rightMargin:m,topMargin:g,bottomMargin:y,showLabels:b,tooltip:S,onSeriesMouseOver:w,refValues:C,selectedColor:k,highlightedDataPoints:_,maxValue:D,minValue:T,onSeriesMouseClick:A,dateFormat:M,indx:E,autoSort:N,maxBarThickness:Y,minBarThickness:ne,resetSelectionOnDoubleClick:K,detailsOnClick:B,barAxisTitle:j,valueColor:$,noOfTicks:V,styles:z,classNames:W}=t,[G,ae]=I.useState(void 0),[U,H]=I.useState(void 0),[R,ee]=I.useState(void 0),[J,Z]=I.useState(void 0),re={top:g,bottom:y,left:j?s+30:s,right:m},te=c-re.left-re.right,F=h-re.top-re.bottom,q=Ut(e.map(ye=>({...ye,date:bt(`${ye.date}`,M,new Date)})),"date"),X=Bt(q,ye=>ye.label).map(ye=>ye.label),ie=Array.from(Hi(sq(e,M||"yyyy"),ye=>ye.date),([ye,be])=>{const je=N?a7(be.filter($e=>!Fe($e.size)),["size"],["desc"]):X.map($e=>be.find(ut=>ut.label===$e));return be.filter($e=>$e.size===void 0).forEach($e=>{je.push($e)}),{date:ye,values:N?je.reverse().map(($e,ut)=>({...$e,id:`${ut}`})):je.map(($e,ut)=>({...$e,id:`${ut}`}))}}),ce=Fe(D)?Math.max(...e.filter(ye=>!Fe(ye.size)).map(ye=>ye.size))<0?0:Math.max(...e.filter(ye=>!Fe(ye.size)).map(ye=>ye.size)):D,de=Fe(T)?Math.min(...e.filter(ye=>!Fe(ye.size)).map(ye=>ye.size))>=0?0:Math.min(...e.filter(ye=>!Fe(ye.size)).map(ye=>ye.size)):T,he=br().domain([de,ce]).range([F,0]).nice(),Oe=Un().domain(X.map((ye,be)=>`${be}`)).range([0,ne?Math.max(te,ne*X.length):Y?Math.min(te,Y*X.length):te]).paddingInner(i),Ne=he.ticks(V);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${c}px`,height:`${h}px`,viewBox:`0 0 ${c} ${h}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${re.left},${re.top})`,children:[v.jsx(Nr,{y1:he(de<0?0:de),y2:he(de<0?0:de),x1:0-s,x2:te+re.right,label:_t(de<0?0:de,a,n),labelPos:{x:0-s,y:ce<0?-15:he(de<0?0:de),dy:ce<0?"1em":-5,dx:0},classNames:{axis:(Te=W==null?void 0:W.xAxis)==null?void 0:Te.axis,label:(_e=W==null?void 0:W.yAxis)==null?void 0:_e.labels},styles:{axis:(xe=z==null?void 0:z.xAxis)==null?void 0:xe.axis,label:(we=z==null?void 0:z.yAxis)==null?void 0:we.labels}}),l?v.jsx(v1,{values:Ne.filter(ye=>ye!==0),y:Ne.filter(ye=>ye!==0).map(ye=>he(ye)),x1:0-s,x2:te+re.right,styles:{gridLines:(ge=z==null?void 0:z.yAxis)==null?void 0:ge.gridLines,labels:(ve=z==null?void 0:z.yAxis)==null?void 0:ve.labels},classNames:{gridLines:(le=W==null?void 0:W.yAxis)==null?void 0:le.gridLines,labels:(ue=W==null?void 0:W.yAxis)==null?void 0:ue.labels},suffix:n,prefix:a,labelType:"secondary",showGridLines:!0,labelPos:"vertical"}):null,v.jsx(nn,{x:0-s-15,y:F/2,style:(Ce=z==null?void 0:z.yAxis)==null?void 0:Ce.title,className:(pe=W==null?void 0:W.yAxis)==null?void 0:pe.title,text:j,rotate90:!0}),v.jsx(mo,{children:ie[E].values.map(ye=>{var be,je;return v.jsxs(ur.g,{transition:{duration:.5},className:"undp-viz-g-with-hover",opacity:k?ye.color&&r[d.indexOf(ye.color)]===k?1:.3:_.length!==0?_.indexOf(ye.label)!==-1?.85:.3:.85,onMouseEnter:$e=>{H(ye),Z($e.clientY),ee($e.clientX),w&&w(ye)},onClick:()=>{(A||B)&&(Sr(G,ye)&&K?(ae(void 0),A==null||A(void 0)):(ae(ye),A==null||A(ye)))},onMouseMove:$e=>{H(ye),Z($e.clientY),ee($e.clientX)},onMouseLeave:()=>{H(void 0),ee(void 0),Z(void 0),w&&w(void 0)},children:[v.jsx(ur.rect,{style:{fill:e.filter($e=>$e.color).length===0?r[0]:ye.color?r[d.indexOf(ye.color)]:Qe.gray},height:ye.size?Math.abs(he(ye.size)-he(0)):0,width:Oe.bandwidth(),animate:{height:ye.size?Math.abs(he(ye.size)-he(0)):0,attrY:ye.size&&ye.size>0?he(ye.size):he(0),attrX:Oe(`${ye.id}`),fill:e.filter($e=>$e.color).length===0?r[0]:ye.color?r[d.indexOf(ye.color)]:Qe.gray},transition:{duration:.5}}),b?v.jsx(ur.text,{style:{textAnchor:"middle",...((be=z==null?void 0:z.xAxis)==null?void 0:be.labels)||{}},dy:ye.size?ye.size>=0?"1em":"-5px":"1em",animate:{attrX:Oe(`${ye.id}`)+Oe.bandwidth()/2,attrY:ye.size?ye.size>=0?he(0)+4:he(0):he(0)+4},transition:{duration:.5},className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(je=W==null?void 0:W.xAxis)==null?void 0:je.labels),children:`${ye.label}`.length<f?`${ye.label}`:`${`${ye.label}`.substring(0,f)}...`}):null,o?v.jsx(ur.text,{style:{...$?{fill:$}:r.length>1?{}:{fill:r[0]},textAnchor:"middle",...(z==null?void 0:z.graphObjectValues)||{}},className:Be("graph-value text-sm",!$&&r.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",W==null?void 0:W.graphObjectValues),animate:{attrX:Oe(`${ye.id}`)+Oe.bandwidth()/2,attrY:he(ye.size||0)},dy:ye.size?ye.size>=0?"-5px":"1em":"-5px",transition:{duration:.5},children:_t(ye.size,a,n)}):null]},ye.label)})}),C?v.jsx(v.Fragment,{children:C.map((ye,be)=>v.jsx(h1,{text:ye.text,color:ye.color,y:he(ye.value),x1:0-s,x2:te+re.right,classNames:ye.classNames,styles:ye.styles},be))}):null]})}),U&&S&&R&&J?v.jsx(yr,{data:U,body:S,xPos:R,yPos:J,backgroundStyle:z==null?void 0:z.tooltip,className:W==null?void 0:W.tooltip}):null,B?v.jsx(Tr,{open:G!==void 0,onClose:()=>{ae(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(B,G)}})}):null]})}function Cve(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o=.25,showTicks:l=!0,leftMargin:s=20,rightMargin:f=20,topMargin:c=20,bottomMargin:h=25,truncateBy:d=999,showLabels:m=!0,showValues:g=!0,backgroundColor:y=!1,suffix:b="",prefix:S="",height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,highlightedDataPoints:T=[],padding:A,relativeHeight:M,tooltip:E,onSeriesMouseOver:N,refValues:Y,showColorScale:ne,graphID:K,maxValue:B,minValue:j,onSeriesMouseClick:$,dateFormat:V="yyyy",showOnlyActiveDate:z=!1,autoPlay:W=!1,autoSort:G=!0,graphDownload:ae=!1,dataDownload:U=!1,language:H="en",theme:R="light",showNAColor:ee=!0,minHeight:J=0,maxBarThickness:Z,minBarThickness:re,ariaLabel:te,resetSelectionOnDoubleClick:F=!0,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie=5,valueColor:ce,styles:de,classNames:he}=t,[Oe,Ne]=I.useState(0),[Te,_e]=I.useState(0),[xe,we]=I.useState(void 0),[ge,ve]=I.useState(W),le=I.useRef(null),ue=I.useRef(null);I.useEffect(()=>{const je=new ResizeObserver($e=>{Ne(C||$e[0].target.clientWidth||620),_e(w||$e[0].target.clientHeight||480)});return le.current&&(_e(le.current.clientHeight||480),Ne(le.current.clientWidth||620),C||je.observe(le.current)),()=>je.disconnect()},[C,w]);const Ce=qi(Bt(e,je=>je.date).map(je=>bt(`${je.date}`,V,new Date).getTime()),(je,$e)=>Ka(je,$e)),[pe,ye]=I.useState(W?0:Ce.length-1),be={};return Ce.forEach((je,$e)=>{be[`${je}`]={style:{color:$e===pe?"#232E3D":"#A9B1B7",fontWeight:$e===pe?"bold":"normal",display:$e===pe||!z?"inline":"none"},label:Sa(new Date(je),V)}}),I.useEffect(()=>{const je=setInterval(()=>{ye($e=>$e<Ce.length-1?$e+1:0)},2e3);return ge||clearInterval(je),()=>clearInterval(je)},[Ce,ge]),v.jsx("div",{className:`${R||"light"} flex ${C?"w-fit grow-0":"w-full grow"}`,dir:H==="he"||H==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${y?y===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${H||"en"}`,he==null?void 0:he.graphContainer),style:{...(de==null?void 0:de.graphContainer)||{},...y&&y!==!0?{backgroundColor:y}:{}},id:K,ref:ue,"aria-label":te||`${r?`The graph shows ${r}. `:""}This is an animated bar chart showing data changes over time. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:y?A||"1rem":A||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||ae||U?v.jsx(Zt,{styles:{title:de==null?void 0:de.title,description:de==null?void 0:de.description},classNames:{title:he==null?void 0:he.title,description:he==null?void 0:he.description},graphTitle:r,graphDescription:i,width:C,graphDownload:ae?ue.current:void 0,dataDownload:U?e.map(je=>je.data).filter(je=>je!==void 0).length>0?e.map(je=>je.data).filter(je=>je!==void 0):e.filter(je=>je!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{ve(!ge)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":ge?"Click to pause animation":"Click to play animation",children:ge?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:Ce[0],max:Ce[Ce.length-1],marks:be,step:null,defaultValue:Ce[Ce.length-1],value:Ce[pe],onChangeComplete:je=>{ye(Ce.indexOf(je))},onChange:je=>{ye(Ce.indexOf(je))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[ne!==!1&&e.filter(je=>je.color).length!==0?v.jsx(Cn,{width:C,colorLegendTitle:D,colors:n||Qe[R].categoricalColors.colors,colorDomain:_||Bt(e.filter(je=>je.color),"color").map(je=>je.color),setSelectedColor:we,showNAColor:ee}):null,v.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:le,"aria-label":"Graph area",children:(C||Oe)&&(w||Te)?v.jsx(Sve,{data:e,barColor:e.filter(je=>je.color).length===0?n?[n]:[Qe.primaryColors["blue-600"]]:n||Qe[R].categoricalColors.colors,colorDomain:e.filter(je=>je.color).length===0?[]:_||Bt(e.filter(je=>je.color),"color").map(je=>je.color),width:C||Oe,selectedColor:xe,height:Math.max(J,w||(M?J?(C||Oe)*M>J?(C||Oe)*M:J:(C||Oe)*M:Te)),suffix:b,prefix:S,barPadding:o,showValues:g,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,tooltip:E,onSeriesMouseOver:N,refValues:Y,maxValue:B,minValue:j,highlightedDataPoints:T,onSeriesMouseClick:$,dateFormat:V,indx:pe,autoSort:G,maxBarThickness:Z,minBarThickness:re,resetSelectionOnDoubleClick:F,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie,valueColor:ce,styles:de,classNames:he}):null})]}),a||k?v.jsx(tr,{styles:{footnote:de==null?void 0:de.footnote,source:de==null?void 0:de.source},classNames:{footnote:he==null?void 0:he.footnote,source:he==null?void 0:he.source},sources:a,footNote:k,width:C}):null]})})})})}function kve(t){var he,Oe,Ne,Te,_e,xe,we,ge,ve,le;const{data:e,width:r,height:n,barColors:a,suffix:i,prefix:o,barPadding:l,showLabels:s,showValues:f,showTicks:c,truncateBy:h,leftMargin:d,rightMargin:m,topMargin:g,bottomMargin:y,tooltip:b,onSeriesMouseOver:S,refValues:w,maxValue:C,minValue:k,onSeriesMouseClick:_,selectedColor:D,dateFormat:T,indx:A,maxBarThickness:M,resetSelectionOnDoubleClick:E,detailsOnClick:N,barAxisTitle:Y,valueColor:ne,noOfTicks:K,styles:B,classNames:j}=t,$=Ut(e.map(ue=>({...ue,date:bt(`${ue.date}`,T,new Date)})),"date"),V=Bt($,ue=>ue.label).map(ue=>ue.label),z=Array.from(Hi(Vf(e,T||"yyyy"),ue=>ue.date),([ue,Ce])=>({date:ue,values:V.map(pe=>Ce.find(ye=>ye.label===pe)).map((pe,ye)=>({...pe,id:`${ye}`}))})),W={top:g,bottom:y,left:Y?d+30:d,right:m},[G,ae]=I.useState(void 0),[U,H]=I.useState(void 0),[R,ee]=I.useState(void 0),[J,Z]=I.useState(void 0),re=r-W.left-W.right,te=n-W.top-W.bottom,F=Fe(C)?Math.max(...e.map(ue=>Mn(ue.size.filter(Ce=>!Fe(Ce)))||0))<0?0:Math.max(...e.map(ue=>Mn(ue.size.filter(Ce=>!Fe(Ce)))||0)):C,q=Fe(k)?Math.min(...e.map(ue=>gr(ue.size.filter(Ce=>!Fe(Ce)))||0))>=0?0:Math.min(...e.map(ue=>gr(ue.size.filter(Ce=>!Fe(Ce)))||0)):k,X=br().domain([q,F]).range([te,0]).nice(),ie=Un().domain(V.map((ue,Ce)=>`${Ce}`)).range([0,M?Math.min(re,M*V.length):re]).paddingInner(l),ce=Un().domain(e[0].size.map((ue,Ce)=>`${Ce}`)).range([0,ie.bandwidth()]).paddingInner(.1),de=X.ticks(K);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${r}px`,height:`${n}px`,viewBox:`0 0 ${r} ${n}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${W.left},${W.top})`,children:[v.jsx(Nr,{y1:X(q<0?0:q),y2:X(q<0?0:q),x1:0-d,x2:re+W.right,label:_t(q<0?0:q,o,i),labelPos:{x:0-d,dx:0,dy:F<0?"1em":-5,y:X(q<0?0:q)},classNames:{axis:(he=j==null?void 0:j.xAxis)==null?void 0:he.axis,label:(Oe=j==null?void 0:j.yAxis)==null?void 0:Oe.labels},styles:{axis:(Ne=B==null?void 0:B.xAxis)==null?void 0:Ne.axis,label:(Te=B==null?void 0:B.yAxis)==null?void 0:Te.labels}}),c?v.jsx(v1,{values:de.filter(ue=>ue!==0),y:de.filter(ue=>ue!==0).map(ue=>X(ue)),x1:0-d,x2:re+W.right,styles:{gridLines:(_e=B==null?void 0:B.yAxis)==null?void 0:_e.gridLines,labels:(xe=B==null?void 0:B.yAxis)==null?void 0:xe.labels},classNames:{gridLines:(we=j==null?void 0:j.yAxis)==null?void 0:we.gridLines,labels:(ge=j==null?void 0:j.yAxis)==null?void 0:ge.labels},suffix:i,prefix:o,labelType:"secondary",showGridLines:!0,labelPos:"vertical"}):null,v.jsx(nn,{x:0-d-15,y:te/2,style:(ve=B==null?void 0:B.yAxis)==null?void 0:ve.title,className:(le=j==null?void 0:j.yAxis)==null?void 0:le.title,text:Y,rotate90:!0}),v.jsx(mo,{children:z[A].values.map((ue,Ce)=>{var pe,ye;return v.jsxs(ur.g,{transform:`translate(${ie(`${ue.id}`)},0)`,children:[ue.size.map((be,je)=>v.jsxs(ur.g,{className:"undp-viz-g-with-hover",opacity:D?a[je]===D?1:.3:.85,onMouseEnter:$e=>{ae({...ue,sizeIndex:je}),Z($e.clientY),ee($e.clientX),S&&S({...ue,sizeIndex:je})},onMouseMove:$e=>{ae({...ue,sizeIndex:je}),Z($e.clientY),ee($e.clientX)},onMouseLeave:()=>{ae(void 0),ee(void 0),Z(void 0),S&&S(void 0)},onClick:()=>{(_||N)&&(Sr(U,{...ue,sizeIndex:je})&&E?(H(void 0),_&&_(void 0)):(H({...ue,sizeIndex:je}),_&&_({...ue,sizeIndex:je})))},children:[v.jsx(ur.rect,{x:ce(`${je}`),width:ce.bandwidth(),style:{fill:a[je]},animate:{height:Fe(be)?0:Math.abs(X(be)-X(0)),attrY:Fe(be)?X(0):be>0?X(be):X(0)},transition:{duration:.5}}),f?v.jsx(ur.text,{x:ce(`${je}`)+ce.bandwidth()/2,style:{fill:ne||a[je],textAnchor:"middle",...(B==null?void 0:B.graphObjectValues)||{}},className:Be("graph-value text-sm",j==null?void 0:j.graphObjectValues),dy:be?be>=0?"-5px":"1em":"-5px",animate:{attrY:X(be||0)},transition:{duration:.5},children:_t(be,o,i)}):null]},je)),s?v.jsx(f4,{value:`${ue.label}`.length<h?`${ue.label}`:`${`${ue.label}`.substring(0,h)}...`,y:X(0)+5,x:0,width:ie.bandwidth(),height:W.bottom,style:(pe=B==null?void 0:B.xAxis)==null?void 0:pe.labels,className:(ye=j==null?void 0:j.xAxis)==null?void 0:ye.labels,alignment:"top"}):null]},Ce)})}),w?v.jsx(v.Fragment,{children:w.map((ue,Ce)=>v.jsx(h1,{text:ue.text,color:ue.color,y:X(ue.value),x1:0-d,x2:re+W.right,classNames:ue.classNames,styles:ue.styles},Ce))}):null]})}),G&&b&&R&&J?v.jsx(yr,{data:G,body:b,xPos:R,yPos:J,backgroundStyle:B==null?void 0:B.tooltip,className:j==null?void 0:j.tooltip}):null,N?v.jsx(Tr,{open:U!==void 0,onClose:()=>{H(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(N,U)}})}):null]})}function _ve(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,sources:a,graphDescription:i,barPadding:o=.25,showTicks:l=!0,leftMargin:s=20,rightMargin:f=20,topMargin:c=20,bottomMargin:h=25,truncateBy:d=999,showLabels:m=!0,showValues:g=!0,backgroundColor:y=!1,suffix:b="",prefix:S="",height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,padding:T,relativeHeight:A,tooltip:M,onSeriesMouseOver:E,refValues:N,graphID:Y,maxValue:ne,minValue:K,onSeriesMouseClick:B,dateFormat:j="yyyy",showOnlyActiveDate:$=!1,autoPlay:V=!1,graphDownload:z=!1,dataDownload:W=!1,language:G="en",theme:ae="light",minHeight:U=0,maxBarThickness:H,ariaLabel:R,resetSelectionOnDoubleClick:ee=!0,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re=5,valueColor:te,styles:F,classNames:q}=t,[X,ie]=I.useState(0),[ce,de]=I.useState(0),[he,Oe]=I.useState(void 0),Ne=I.useRef(null),Te=I.useRef(null);I.useEffect(()=>{const ue=new ResizeObserver(Ce=>{ie(C||Ce[0].target.clientWidth||620),de(w||Ce[0].target.clientHeight||480)});return Ne.current&&(de(Ne.current.clientHeight||480),ie(Ne.current.clientWidth||620),C||ue.observe(Ne.current)),()=>ue.disconnect()},[C,w]);const[_e,xe]=I.useState(V),we=qi(Bt(e,ue=>ue.date).map(ue=>bt(`${ue.date}`,j,new Date).getTime()),(ue,Ce)=>Ka(ue,Ce)),[ge,ve]=I.useState(V?0:we.length-1),le={};return we.forEach((ue,Ce)=>{le[`${ue}`]={style:{color:Ce===ge?"#232E3D":"#A9B1B7",fontWeight:Ce===ge?"bold":"normal",display:Ce===ge||!$?"inline":"none"},label:Sa(new Date(ue),j)}}),I.useEffect(()=>{const ue=setInterval(()=>{ve(Ce=>Ce<we.length-1?Ce+1:0)},2e3);return _e||clearInterval(ue),()=>clearInterval(ue)},[we,_e]),v.jsx("div",{className:`${ae||"light"} flex ${C?"w-fit grow-0":"w-full grow"}`,dir:G==="he"||G==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${y?y===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${G||"en"}`,q==null?void 0:q.graphContainer),style:{...(F==null?void 0:F.graphContainer)||{},...y&&y!==!0?{backgroundColor:y}:{}},id:Y,ref:Te,"aria-label":R||`${r?`The graph shows ${r}. `:""}This is an animated grouped bar chart showing data changes over time. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:y?T||"1rem":T||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||z||W?v.jsx(Zt,{styles:{title:F==null?void 0:F.title,description:F==null?void 0:F.description},classNames:{title:q==null?void 0:q.title,description:q==null?void 0:q.description},graphTitle:r,graphDescription:i,width:C,graphDownload:z?Te.current:void 0,dataDownload:W?e.map(ue=>ue.data).filter(ue=>ue!==void 0).length>0?e.map(ue=>ue.data).filter(ue=>ue!==void 0):e.filter(ue=>ue!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{xe(!_e)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":_e?"Click to pause animation":"Click to play animation",children:_e?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:we[0],max:we[we.length-1],marks:le,step:null,defaultValue:we[we.length-1],value:we[ge],onChangeComplete:ue=>{ve(we.indexOf(ue))},onChange:ue=>{ve(we.indexOf(ue))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[v.jsx(Cn,{width:C,colorDomain:_,colors:n,colorLegendTitle:D,setSelectedColor:Oe,showNAColor:!1}),v.jsx("div",{className:"w-full grow leading-0",ref:Ne,"aria-label":"Graph area",children:(C||X)&&(w||ce)?v.jsx(kve,{data:e,barColors:n,width:C||X,height:Math.max(U,w||(A?U?(C||X)*A>U?(C||X)*A:U:(C||X)*A:ce)),suffix:b,prefix:S,barPadding:o,showLabels:m,showValues:g,showTicks:l,truncateBy:d,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,tooltip:M,onSeriesMouseOver:E,refValues:N,maxValue:ne,minValue:K,onSeriesMouseClick:B,selectedColor:he,dateFormat:j,indx:ge,maxBarThickness:H,resetSelectionOnDoubleClick:ee,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re,valueColor:te,styles:F,classNames:q}):null})]}),a||k?v.jsx(tr,{styles:{footnote:F==null?void 0:F.footnote,source:F==null?void 0:F.source},classNames:{footnote:q==null?void 0:q.footnote,source:q==null?void 0:q.source},sources:a,footNote:k,width:C}):null]})})})})}function Ove(t){var he,Oe,Ne,Te,_e,xe,we,ge,ve,le;const{data:e,barColors:r,barPadding:n,showTicks:a,leftMargin:i,rightMargin:o,truncateBy:l,width:s,height:f,topMargin:c,bottomMargin:h,tooltip:d,onSeriesMouseOver:m,showLabels:g,suffix:y,prefix:b,showValues:S,refValues:w,maxValue:C,onSeriesMouseClick:k,selectedColor:_,dateFormat:D,indx:T,autoSort:A,sortParameter:M,maxBarThickness:E,minBarThickness:N,resetSelectionOnDoubleClick:Y,detailsOnClick:ne,barAxisTitle:K,valueColor:B,noOfTicks:j,styles:$,classNames:V}=t,[z,W]=I.useState(void 0),G=Ut(e.map(ue=>({...ue,date:bt(`${ue.date}`,D,new Date)})),"date"),ae=Bt(G,ue=>ue.label).map(ue=>ue.label),U=Array.from(Hi(Vf(e,D||"yyyy"),ue=>ue.date),([ue,Ce])=>({date:ue,values:M!==void 0||A?M==="total"||M===void 0?Ut(e.filter(pe=>pe.date===ue),pe=>fr(pe.size.filter(ye=>!Fe(ye)))).map((pe,ye)=>({...pe,id:`${ye}`})):Ut(e.filter(pe=>pe.date===ue),pe=>Fe(pe.size[M])?-1/0:pe.size[M]).map((pe,ye)=>({...pe,id:`${ye}`})):ae.map(pe=>Ce.find(ye=>ye.label===pe)).map((pe,ye)=>({...pe,id:`${ye}`}))})),H={top:c,bottom:h,left:i,right:o},[R,ee]=I.useState(void 0),[J,Z]=I.useState(void 0),[re,te]=I.useState(void 0),F=s-H.left-H.right,q=f-H.top-H.bottom,X=Fe(C)?Math.max(...e.map(ue=>fr(ue.size.filter(Ce=>!Fe(Ce)))||0)):C,ie=br().domain([0,X]).range([q,0]).nice(),ce=Un().domain(ae.map((ue,Ce)=>`${Ce}`)).range([0,N?Math.max(F,N*ae.length):E?Math.min(F,E*ae.length):F]).paddingInner(n),de=ie.ticks(j);return v.jsxs(v.Fragment,{children:[v.jsx("svg",{width:`${s}px`,height:`${f}px`,viewBox:`0 0 ${s} ${f}`,direction:"ltr",children:v.jsxs("g",{transform:`translate(${H.left},${H.top})`,children:[v.jsx(Nr,{y1:ie(0),y2:ie(0),x1:0-i,x2:F+H.right,label:_t(0,b,y),labelPos:{x:0-i,y:ie(0),dx:0,dy:-5},classNames:{axis:(he=V==null?void 0:V.xAxis)==null?void 0:he.axis,label:(Oe=V==null?void 0:V.yAxis)==null?void 0:Oe.labels},styles:{axis:(Ne=$==null?void 0:$.xAxis)==null?void 0:Ne.axis,label:(Te=$==null?void 0:$.yAxis)==null?void 0:Te.labels}}),a?v.jsx(v1,{values:de.filter(ue=>ue!==0),y:de.filter(ue=>ue!==0).map(ue=>ie(ue)),x1:0-i,x2:F+H.right,styles:{gridLines:(_e=$==null?void 0:$.yAxis)==null?void 0:_e.gridLines,labels:(xe=$==null?void 0:$.yAxis)==null?void 0:xe.labels},classNames:{gridLines:(we=V==null?void 0:V.yAxis)==null?void 0:we.gridLines,labels:(ge=V==null?void 0:V.yAxis)==null?void 0:ge.labels},suffix:y,prefix:b,labelType:"secondary",showGridLines:!0,labelPos:"vertical"}):null,v.jsx(nn,{x:0-i-15,y:q/2,style:(ve=$==null?void 0:$.yAxis)==null?void 0:ve.title,className:(le=V==null?void 0:V.yAxis)==null?void 0:le.title,text:K,rotate90:!0}),v.jsx(mo,{children:U[T].values.map(ue=>{var Ce,pe;return v.jsxs("g",{className:"undp-viz-low-opacity undp-viz-g-with-hover",transform:"translate(0,0)",children:[ue.size.map((ye,be)=>v.jsxs(ur.g,{opacity:_?r[be]===_?1:.3:1,onMouseEnter:je=>{ee({...ue,sizeIndex:be}),te(je.clientY),Z(je.clientX),m&&m({...ue,sizeIndex:be})},onMouseMove:je=>{ee({...ue,sizeIndex:be}),te(je.clientY),Z(je.clientX)},onMouseLeave:()=>{ee(void 0),Z(void 0),te(void 0),m&&m(void 0)},onClick:()=>{(k||ne)&&(Sr(z,{...ue,sizeIndex:be})&&Y?(W(void 0),k&&k(void 0)):(W({...ue,sizeIndex:be}),k&&k({...ue,sizeIndex:be})))},children:[v.jsx(ur.rect,{style:{fill:r[be]},width:ce.bandwidth(),animate:{height:Math.abs(ie(fr(ue.size.filter((je,$e)=>$e<=be&&je)))-ie(fr(ue.size.filter((je,$e)=>$e<be&&je)))),attrY:ie(fr(ue.size.filter((je,$e)=>$e<=be&&je))),attrX:ce(ue.id)},transition:{duration:.5}},be),S?v.jsx(ur.text,{style:{fill:Bi(r[be]),textAnchor:"middle",...($==null?void 0:$.graphObjectValues)||{}},className:Be("graph-value text-sm",V==null?void 0:V.graphObjectValues),dy:"0.33em",animate:{attrY:ie(fr(ue.size.filter((je,$e)=>$e<=be&&je)))+Math.abs(ie(fr(ue.size.filter((je,$e)=>$e<=be&&je)))-ie(fr(ue.size.filter((je,$e)=>$e<be&&je))))/2,attrX:(ce(ue.id)||0)+ce.bandwidth()/2,opacity:ye&&Math.abs(ie(fr(ue.size.filter((je,$e)=>$e<=be&&je)))-ie(fr(ue.size.filter((je,$e)=>$e<be&&je))))>20?1:0},transition:{duration:.5},children:_t(ye,b,y)}):null]},be)),g?v.jsx(ur.text,{style:{textAnchor:"middle",...((Ce=$==null?void 0:$.xAxis)==null?void 0:Ce.labels)||{}},className:Be("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",(pe=V==null?void 0:V.xAxis)==null?void 0:pe.labels),dy:"1em",animate:{attrY:ie(0)+5,attrX:(ce(ue.id)||0)+ce.bandwidth()/2},transition:{duration:.5},children:`${ue.label}`.length<l?`${ue.label}`:`${`${ue.label}`.substring(0,l)}...`}):null,S?v.jsx(ur.text,{style:{...B&&{fill:B},textAnchor:"middle",...($==null?void 0:$.graphObjectValues)||{}},className:Be("graph-value graph-value-total",B?"text-sm":"fill-primary-gray-700 dark:fill-primary-gray-300 text-sm",V==null?void 0:V.graphObjectValues),dy:-10,animate:{attrY:ie(fr(ue.size.map(ye=>ye||0))),attrX:(ce(ue.id)||0)+ce.bandwidth()/2},transition:{duration:.5},children:_t(fr(ue.size.filter(ye=>ye)),b,y)}):null]},ue.label)})}),w?v.jsx(v.Fragment,{children:w.map((ue,Ce)=>v.jsx(h1,{text:ue.text,color:ue.color,y:ie(ue.value),x1:0-i,x2:F+H.right,classNames:ue.classNames,styles:ue.styles},Ce))}):null]})}),R&&d&&J&&re?v.jsx(yr,{data:R,body:d,xPos:J,yPos:re,backgroundStyle:$==null?void 0:$.tooltip,className:V==null?void 0:V.tooltip}):null,ne?v.jsx(Tr,{open:z!==void 0,onClose:()=>{W(void 0)},children:v.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:{__html:Cr(ne,z)}})}):null]})}function Dve(t){const{data:e,graphTitle:r,colors:n=Qe.light.categoricalColors.colors,sources:a,graphDescription:i,barPadding:o=.25,showTicks:l=!0,leftMargin:s=20,rightMargin:f=20,topMargin:c=20,bottomMargin:h=25,truncateBy:d=999,showLabels:m=!0,showValues:g=!0,backgroundColor:y=!1,suffix:b="",prefix:S="",height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,padding:T,tooltip:A,onSeriesMouseOver:M,relativeHeight:E,refValues:N,graphID:Y,maxValue:ne,onSeriesMouseClick:K,dateFormat:B="yyyy",showOnlyActiveDate:j=!1,autoPlay:$=!1,autoSort:V=!0,graphDownload:z=!1,dataDownload:W=!1,language:G="en",theme:ae="light",minHeight:U=0,sortParameter:H,maxBarThickness:R,minBarThickness:ee,ariaLabel:J,resetSelectionOnDoubleClick:Z=!0,detailsOnClick:re,barAxisTitle:te,noOfTicks:F=5,valueColor:q,styles:X,classNames:ie}=t,[ce,de]=I.useState(0),[he,Oe]=I.useState(0),[Ne,Te]=I.useState(void 0),_e=I.useRef(null),xe=I.useRef(null);I.useEffect(()=>{const pe=new ResizeObserver(ye=>{de(C||ye[0].target.clientWidth||620),Oe(w||ye[0].target.clientHeight||480)});return _e.current&&(Oe(_e.current.clientHeight||480),de(_e.current.clientWidth||620),C||pe.observe(_e.current)),()=>pe.disconnect()},[C,w]);const[we,ge]=I.useState($),ve=qi(Bt(e,pe=>pe.date).map(pe=>bt(`${pe.date}`,B,new Date).getTime()),(pe,ye)=>Ka(pe,ye)),[le,ue]=I.useState($?0:ve.length-1),Ce={};return ve.forEach((pe,ye)=>{Ce[`${pe}`]={style:{color:ye===le?"#232E3D":"#A9B1B7",fontWeight:ye===le?"bold":"normal",display:ye===le||!j?"inline":"none"},label:Sa(new Date(pe),B)}}),I.useEffect(()=>{const pe=setInterval(()=>{ue(ye=>ye<ve.length-1?ye+1:0)},2e3);return we||clearInterval(pe),()=>clearInterval(pe)},[ve,we]),v.jsx("div",{className:`${ae||"light"} flex ${C?"w-fit grow-0":"w-full grow"}`,dir:G==="he"||G==="ar"?"rtl":void 0,children:v.jsx("div",{className:Be(`${y?y===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${G||"en"}`,ie==null?void 0:ie.graphContainer),style:{...(X==null?void 0:X.graphContainer)||{},...y&&y!==!0?{backgroundColor:y}:{}},id:Y,ref:xe,"aria-label":J||`${r?`The graph shows ${r}. `:""}This is an animated stacked bar chart showing data changes over time. ${i?` ${i}`:""}`,children:v.jsx("div",{className:"flex grow",style:{padding:y?T||"1rem":T||0},children:v.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[r||i||z||W?v.jsx(Zt,{styles:{title:X==null?void 0:X.title,description:X==null?void 0:X.description},classNames:{title:ie==null?void 0:ie.title,description:ie==null?void 0:ie.description},graphTitle:r,graphDescription:i,width:C,graphDownload:z?xe.current:void 0,dataDownload:W?e.map(pe=>pe.data).filter(pe=>pe!==void 0).length>0?e.map(pe=>pe.data).filter(pe=>pe!==void 0):e.filter(pe=>pe!==void 0):null}):null,v.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[v.jsx("button",{type:"button",onClick:()=>{ge(!we)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":we?"Click to pause animation":"Click to play animation",children:we?v.jsx(Ui,{}):v.jsx(Wi,{})}),v.jsx(zi,{min:ve[0],max:ve[ve.length-1],marks:Ce,step:null,defaultValue:ve[ve.length-1],value:ve[le],onChangeComplete:pe=>{ue(ve.indexOf(pe))},onChange:pe=>{ue(ve.indexOf(pe))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}),v.jsxs("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:[v.jsx(Cn,{width:C,colorDomain:_,colors:n,colorLegendTitle:D,setSelectedColor:Te,showNAColor:!1}),v.jsx("div",{className:"w-full grow leading-0",ref:_e,"aria-label":"Graph area",children:(C||ce)&&(w||he)?v.jsx(Ove,{data:e,barColors:n,width:C||ce,height:Math.max(U,w||(E?U?(C||ce)*E>U?(C||ce)*E:U:(C||ce)*E:he)),suffix:b,prefix:S,barPadding:o,showLabels:m,showValues:g,showTicks:l,truncateBy:d,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,tooltip:A,onSeriesMouseOver:M,refValues:N,maxValue:ne,onSeriesMouseClick:K,selectedColor:Ne,dateFormat:B,indx:le,sortParameter:H,autoSort:V,maxBarThickness:R,minBarThickness:ee,resetSelectionOnDoubleClick:Z,detailsOnClick:re,barAxisTitle:te,noOfTicks:F,valueColor:q,styles:X,classNames:ie}):null})]}),a||k?v.jsx(tr,{styles:{footnote:X==null?void 0:X.footnote,source:X==null?void 0:X.source},classNames:{footnote:ie==null?void 0:ie.footnote,source:ie==null?void 0:ie.source},sources:a,footNote:k,width:C}):null]})})})})}function gq(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,showValues:g,backgroundColor:y,suffix:b,prefix:S,height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,highlightedDataPoints:T,padding:A,relativeHeight:M,tooltip:E,onSeriesMouseOver:N,refValues:Y,showColorScale:ne,graphID:K,maxValue:B,minValue:j,onSeriesMouseClick:$,dateFormat:V,showOnlyActiveDate:z,autoPlay:W,autoSort:G,graphDownload:ae,dataDownload:U,language:H,theme:R,showNAColor:ee,minHeight:J,maxBarThickness:Z,minBarThickness:re,ariaLabel:te,resetSelectionOnDoubleClick:F,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie,valueColor:ce,orientation:de="vertical",styles:he,classNames:Oe}=t;return de==="vertical"?v.jsx(Cve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,showValues:g,backgroundColor:y,suffix:b,prefix:S,height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,highlightedDataPoints:T,padding:A,relativeHeight:M,tooltip:E,onSeriesMouseOver:N,refValues:Y,showColorScale:ne,graphID:K,maxValue:B,minValue:j,onSeriesMouseClick:$,dateFormat:V,showOnlyActiveDate:z,autoPlay:W,autoSort:G,graphDownload:ae,dataDownload:U,language:H,theme:R,showNAColor:ee,minHeight:J,maxBarThickness:Z,minBarThickness:re,ariaLabel:te,resetSelectionOnDoubleClick:F,styles:he,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie,valueColor:ce,classNames:Oe}):v.jsx(yve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,showValues:g,backgroundColor:y,suffix:b,prefix:S,height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,highlightedDataPoints:T,padding:A,relativeHeight:M,tooltip:E,onSeriesMouseOver:N,refValues:Y,showColorScale:ne,graphID:K,maxValue:B,minValue:j,onSeriesMouseClick:$,dateFormat:V,showOnlyActiveDate:z,autoPlay:W,autoSort:G,graphDownload:ae,dataDownload:U,language:H,theme:R,showNAColor:ee,minHeight:J,maxBarThickness:Z,minBarThickness:re,ariaLabel:te,resetSelectionOnDoubleClick:F,styles:he,detailsOnClick:q,barAxisTitle:X,noOfTicks:ie,valueColor:ce,classNames:Oe})}function yq(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,truncateBy:s,height:f,width:c,footNote:h,colorDomain:d,colorLegendTitle:m,suffix:g,prefix:y,showValues:b,padding:S,backgroundColor:w,leftMargin:C,rightMargin:k,topMargin:_,showLabels:D,bottomMargin:T,relativeHeight:A,tooltip:M,onSeriesMouseOver:E,refValues:N,graphID:Y,maxValue:ne,minValue:K,onSeriesMouseClick:B,graphDownload:j,dataDownload:$,dateFormat:V,showOnlyActiveDate:z,autoPlay:W,language:G,minHeight:ae,theme:U,maxBarThickness:H,ariaLabel:R,resetSelectionOnDoubleClick:ee,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re,valueColor:te,orientation:F="vertical",styles:q,classNames:X}=t;return F==="vertical"?v.jsx(_ve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,truncateBy:s,height:f,width:c,footNote:h,colorDomain:d,colorLegendTitle:m,suffix:g,prefix:y,showValues:b,padding:S,backgroundColor:w,leftMargin:C,rightMargin:k,topMargin:_,showLabels:D,bottomMargin:T,relativeHeight:A,tooltip:M,onSeriesMouseOver:E,refValues:N,graphID:Y,maxValue:ne,minValue:K,onSeriesMouseClick:B,graphDownload:j,dataDownload:$,dateFormat:V,showOnlyActiveDate:z,autoPlay:W,language:G,minHeight:ae,theme:U,maxBarThickness:H,ariaLabel:R,resetSelectionOnDoubleClick:ee,styles:q,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re,valueColor:te,classNames:X}):v.jsx(bve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,truncateBy:s,height:f,width:c,footNote:h,colorDomain:d,colorLegendTitle:m,suffix:g,prefix:y,showValues:b,padding:S,backgroundColor:w,leftMargin:C,rightMargin:k,topMargin:_,showLabels:D,bottomMargin:T,relativeHeight:A,tooltip:M,onSeriesMouseOver:E,refValues:N,graphID:Y,maxValue:ne,minValue:K,onSeriesMouseClick:B,graphDownload:j,dataDownload:$,dateFormat:V,showOnlyActiveDate:z,autoPlay:W,language:G,minHeight:ae,theme:U,maxBarThickness:H,ariaLabel:R,resetSelectionOnDoubleClick:ee,styles:q,detailsOnClick:J,barAxisTitle:Z,noOfTicks:re,valueColor:te,classNames:X})}function vq(t){const{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,showValues:g,backgroundColor:y,suffix:b,prefix:S,height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,padding:T,tooltip:A,onSeriesMouseOver:M,relativeHeight:E,refValues:N,graphID:Y,maxValue:ne,onSeriesMouseClick:K,dateFormat:B,showOnlyActiveDate:j,autoPlay:$,autoSort:V,graphDownload:z,dataDownload:W,language:G,theme:ae,minHeight:U,sortParameter:H,maxBarThickness:R,minBarThickness:ee,ariaLabel:J,resetSelectionOnDoubleClick:Z,detailsOnClick:re,barAxisTitle:te,noOfTicks:F,valueColor:q,orientation:X="vertical",styles:ie,classNames:ce}=t;return X==="vertical"?v.jsx(Dve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,showValues:g,backgroundColor:y,suffix:b,prefix:S,height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,padding:T,tooltip:A,onSeriesMouseOver:M,relativeHeight:E,refValues:N,graphID:Y,maxValue:ne,onSeriesMouseClick:K,dateFormat:B,showOnlyActiveDate:j,autoPlay:$,autoSort:V,graphDownload:z,dataDownload:W,language:G,theme:ae,minHeight:U,sortParameter:H,maxBarThickness:R,minBarThickness:ee,ariaLabel:J,resetSelectionOnDoubleClick:Z,styles:ie,detailsOnClick:re,barAxisTitle:te,noOfTicks:F,valueColor:q,classNames:ce}):v.jsx(wve,{data:e,graphTitle:r,colors:n,sources:a,graphDescription:i,barPadding:o,showTicks:l,leftMargin:s,rightMargin:f,topMargin:c,bottomMargin:h,truncateBy:d,showLabels:m,showValues:g,backgroundColor:y,suffix:b,prefix:S,height:w,width:C,footNote:k,colorDomain:_,colorLegendTitle:D,padding:T,tooltip:A,onSeriesMouseOver:M,relativeHeight:E,refValues:N,graphID:Y,maxValue:ne,onSeriesMouseClick:K,dateFormat:B,showOnlyActiveDate:j,autoPlay:$,autoSort:V,graphDownload:z,dataDownload:W,language:G,theme:ae,minHeight:U,sortParameter:H,maxBarThickness:R,minBarThickness:ee,ariaLabel:J,resetSelectionOnDoubleClick:Z,styles:ie,detailsOnClick:re,barAxisTitle:te,noOfTicks:F,valueColor:q,classNames:ce})}function Lr(t,e,r){return e.findIndex(n=>n.chartConfigId===t)===-1?void 0:typeof e[e.findIndex(n=>n.chartConfigId===t)].columnId=="object"?e[e.findIndex(n=>n.chartConfigId===t)].columnId.map(n=>r.findIndex(a=>a.value===n)===-1?n:r[r.findIndex(a=>a.value===n)].label):r.findIndex(n=>n.value===e[e.findIndex(a=>a.chartConfigId===t)].columnId)===-1?e[e.findIndex(n=>n.chartConfigId===t)].columnId:r[r.findIndex(n=>n.value===e[e.findIndex(a=>a.chartConfigId===t)].columnId)].label}var w5={exports:{}},Tm={},I0={},S3={},Mm={},Em={},jm={},XM;function Rc(){return XM||(XM=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class e{}t._CodeOrName=e,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends e{constructor(w){if(super(),!t.IDENTIFIER.test(w))throw new Error("CodeGen: name must be a valid identifier");this.str=w}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class n extends e{constructor(w){super(),this._items=typeof w=="string"?[w]:w}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const w=this._items[0];return w===""||w==='""'}get str(){var w;return(w=this._str)!==null&&w!==void 0?w:this._str=this._items.reduce((C,k)=>`${C}${k}`,"")}get names(){var w;return(w=this._names)!==null&&w!==void 0?w:this._names=this._items.reduce((C,k)=>(k instanceof r&&(C[k.str]=(C[k.str]||0)+1),C),{})}}t._Code=n,t.nil=new n("");function a(S,...w){const C=[S[0]];let k=0;for(;k<w.length;)l(C,w[k]),C.push(S[++k]);return new n(C)}t._=a;const i=new n("+");function o(S,...w){const C=[m(S[0])];let k=0;for(;k<w.length;)C.push(i),l(C,w[k]),C.push(i,m(S[++k]));return s(C),new n(C)}t.str=o;function l(S,w){w instanceof n?S.push(...w._items):w instanceof r?S.push(w):S.push(h(w))}t.addCodeArg=l;function s(S){let w=1;for(;w<S.length-1;){if(S[w]===i){const C=f(S[w-1],S[w+1]);if(C!==void 0){S.splice(w-1,3,C);continue}S[w++]="+"}w++}}function f(S,w){if(w==='""')return S;if(S==='""')return w;if(typeof S=="string")return w instanceof r||S[S.length-1]!=='"'?void 0:typeof w!="string"?`${S.slice(0,-1)}${w}"`:w[0]==='"'?S.slice(0,-1)+w.slice(1):void 0;if(typeof w=="string"&&w[0]==='"'&&!(S instanceof r))return`"${S}${w.slice(1)}`}function c(S,w){return w.emptyStr()?S:S.emptyStr()?w:o`${S}${w}`}t.strConcat=c;function h(S){return typeof S=="number"||typeof S=="boolean"||S===null?S:m(Array.isArray(S)?S.join(","):S)}function d(S){return new n(m(S))}t.stringify=d;function m(S){return JSON.stringify(S).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=m;function g(S){return typeof S=="string"&&t.IDENTIFIER.test(S)?new n(`.${S}`):a`[${S}]`}t.getProperty=g;function y(S){if(typeof S=="string"&&t.IDENTIFIER.test(S))return new n(`${S}`);throw new Error(`CodeGen: invalid export name: ${S}, use explicit $id name mapping`)}t.getEsmExportName=y;function b(S){return new n(S.toString())}t.regexpCode=b}(jm)),jm}var Lm={},KM;function JM(){return KM||(KM=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=Rc();class r extends Error{constructor(f){super(`CodeGen: "code" for ${f} not defined`),this.value=f.value}}var n;(function(s){s[s.Started=0]="Started",s[s.Completed=1]="Completed"})(n||(t.UsedValueState=n={})),t.varKinds={const:new e.Name("const"),let:new e.Name("let"),var:new e.Name("var")};class a{constructor({prefixes:f,parent:c}={}){this._names={},this._prefixes=f,this._parent=c}toName(f){return f instanceof e.Name?f:this.name(f)}name(f){return new e.Name(this._newName(f))}_newName(f){const c=this._names[f]||this._nameGroup(f);return`${f}${c.index++}`}_nameGroup(f){var c,h;if(!((h=(c=this._parent)===null||c===void 0?void 0:c._prefixes)===null||h===void 0)&&h.has(f)||this._prefixes&&!this._prefixes.has(f))throw new Error(`CodeGen: prefix "${f}" is not allowed in this scope`);return this._names[f]={prefix:f,index:0}}}t.Scope=a;class i extends e.Name{constructor(f,c){super(c),this.prefix=f}setValue(f,{property:c,itemIndex:h}){this.value=f,this.scopePath=(0,e._)`.${new e.Name(c)}[${h}]`}}t.ValueScopeName=i;const o=(0,e._)`\n`;class l extends a{constructor(f){super(f),this._values={},this._scope=f.scope,this.opts={...f,_n:f.lines?o:e.nil}}get(){return this._scope}name(f){return new i(f,this._newName(f))}value(f,c){var h;if(c.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const d=this.toName(f),{prefix:m}=d,g=(h=c.key)!==null&&h!==void 0?h:c.ref;let y=this._values[m];if(y){const w=y.get(g);if(w)return w}else y=this._values[m]=new Map;y.set(g,d);const b=this._scope[m]||(this._scope[m]=[]),S=b.length;return b[S]=c.ref,d.setValue(c,{property:m,itemIndex:S}),d}getValue(f,c){const h=this._values[f];if(h)return h.get(c)}scopeRefs(f,c=this._values){return this._reduceValues(c,h=>{if(h.scopePath===void 0)throw new Error(`CodeGen: name "${h}" has no value`);return(0,e._)`${f}${h.scopePath}`})}scopeCode(f=this._values,c,h){return this._reduceValues(f,d=>{if(d.value===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return d.value.code},c,h)}_reduceValues(f,c,h={},d){let m=e.nil;for(const g in f){const y=f[g];if(!y)continue;const b=h[g]=h[g]||new Map;y.forEach(S=>{if(b.has(S))return;b.set(S,n.Started);let w=c(S);if(w){const C=this.opts.es5?t.varKinds.var:t.varKinds.const;m=(0,e._)`${m}${C} ${S} = ${w};${this.opts._n}`}else if(w=d==null?void 0:d(S))m=(0,e._)`${m}${w}${this.opts._n}`;else throw new r(S);b.set(S,n.Completed)})}return m}}t.ValueScope=l}(Lm)),Lm}var ZM;function Fr(){return ZM||(ZM=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const e=Rc(),r=JM();var n=Rc();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return n.Name}});var a=JM();Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return a.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return a.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return a.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return a.varKinds}}),t.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class i{optimizeNodes(){return this}optimizeNames(H,R){return this}}class o extends i{constructor(H,R,ee){super(),this.varKind=H,this.name=R,this.rhs=ee}render({es5:H,_n:R}){const ee=H?r.varKinds.var:this.varKind,J=this.rhs===void 0?"":` = ${this.rhs}`;return`${ee} ${this.name}${J};`+R}optimizeNames(H,R){if(H[this.name.str])return this.rhs&&(this.rhs=K(this.rhs,H,R)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class l extends i{constructor(H,R,ee){super(),this.lhs=H,this.rhs=R,this.sideEffects=ee}render({_n:H}){return`${this.lhs} = ${this.rhs};`+H}optimizeNames(H,R){if(!(this.lhs instanceof e.Name&&!H[this.lhs.str]&&!this.sideEffects))return this.rhs=K(this.rhs,H,R),this}get names(){const H=this.lhs instanceof e.Name?{}:{...this.lhs.names};return ne(H,this.rhs)}}class s extends l{constructor(H,R,ee,J){super(H,ee,J),this.op=R}render({_n:H}){return`${this.lhs} ${this.op}= ${this.rhs};`+H}}class f extends i{constructor(H){super(),this.label=H,this.names={}}render({_n:H}){return`${this.label}:`+H}}class c extends i{constructor(H){super(),this.label=H,this.names={}}render({_n:H}){return`break${this.label?` ${this.label}`:""};`+H}}class h extends i{constructor(H){super(),this.error=H}render({_n:H}){return`throw ${this.error};`+H}get names(){return this.error.names}}class d extends i{constructor(H){super(),this.code=H}render({_n:H}){return`${this.code};`+H}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(H,R){return this.code=K(this.code,H,R),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class m extends i{constructor(H=[]){super(),this.nodes=H}render(H){return this.nodes.reduce((R,ee)=>R+ee.render(H),"")}optimizeNodes(){const{nodes:H}=this;let R=H.length;for(;R--;){const ee=H[R].optimizeNodes();Array.isArray(ee)?H.splice(R,1,...ee):ee?H[R]=ee:H.splice(R,1)}return H.length>0?this:void 0}optimizeNames(H,R){const{nodes:ee}=this;let J=ee.length;for(;J--;){const Z=ee[J];Z.optimizeNames(H,R)||(B(H,Z.names),ee.splice(J,1))}return ee.length>0?this:void 0}get names(){return this.nodes.reduce((H,R)=>Y(H,R.names),{})}}class g extends m{render(H){return"{"+H._n+super.render(H)+"}"+H._n}}class y extends m{}class b extends g{}b.kind="else";class S extends g{constructor(H,R){super(R),this.condition=H}render(H){let R=`if(${this.condition})`+super.render(H);return this.else&&(R+="else "+this.else.render(H)),R}optimizeNodes(){super.optimizeNodes();const H=this.condition;if(H===!0)return this.nodes;let R=this.else;if(R){const ee=R.optimizeNodes();R=this.else=Array.isArray(ee)?new b(ee):ee}if(R)return H===!1?R instanceof S?R:R.nodes:this.nodes.length?this:new S(j(H),R instanceof S?[R]:R.nodes);if(!(H===!1||!this.nodes.length))return this}optimizeNames(H,R){var ee;if(this.else=(ee=this.else)===null||ee===void 0?void 0:ee.optimizeNames(H,R),!!(super.optimizeNames(H,R)||this.else))return this.condition=K(this.condition,H,R),this}get names(){const H=super.names;return ne(H,this.condition),this.else&&Y(H,this.else.names),H}}S.kind="if";class w extends g{}w.kind="for";class C extends w{constructor(H){super(),this.iteration=H}render(H){return`for(${this.iteration})`+super.render(H)}optimizeNames(H,R){if(super.optimizeNames(H,R))return this.iteration=K(this.iteration,H,R),this}get names(){return Y(super.names,this.iteration.names)}}class k extends w{constructor(H,R,ee,J){super(),this.varKind=H,this.name=R,this.from=ee,this.to=J}render(H){const R=H.es5?r.varKinds.var:this.varKind,{name:ee,from:J,to:Z}=this;return`for(${R} ${ee}=${J}; ${ee}<${Z}; ${ee}++)`+super.render(H)}get names(){const H=ne(super.names,this.from);return ne(H,this.to)}}class _ extends w{constructor(H,R,ee,J){super(),this.loop=H,this.varKind=R,this.name=ee,this.iterable=J}render(H){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(H)}optimizeNames(H,R){if(super.optimizeNames(H,R))return this.iterable=K(this.iterable,H,R),this}get names(){return Y(super.names,this.iterable.names)}}class D extends g{constructor(H,R,ee){super(),this.name=H,this.args=R,this.async=ee}render(H){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(H)}}D.kind="func";class T extends m{render(H){return"return "+super.render(H)}}T.kind="return";class A extends g{render(H){let R="try"+super.render(H);return this.catch&&(R+=this.catch.render(H)),this.finally&&(R+=this.finally.render(H)),R}optimizeNodes(){var H,R;return super.optimizeNodes(),(H=this.catch)===null||H===void 0||H.optimizeNodes(),(R=this.finally)===null||R===void 0||R.optimizeNodes(),this}optimizeNames(H,R){var ee,J;return super.optimizeNames(H,R),(ee=this.catch)===null||ee===void 0||ee.optimizeNames(H,R),(J=this.finally)===null||J===void 0||J.optimizeNames(H,R),this}get names(){const H=super.names;return this.catch&&Y(H,this.catch.names),this.finally&&Y(H,this.finally.names),H}}class M extends g{constructor(H){super(),this.error=H}render(H){return`catch(${this.error})`+super.render(H)}}M.kind="catch";class E extends g{render(H){return"finally"+super.render(H)}}E.kind="finally";class N{constructor(H,R={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...R,_n:R.lines?`
|
|
279
279
|
`:""},this._extScope=H,this._scope=new r.Scope({parent:H}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(H){return this._scope.name(H)}scopeName(H){return this._extScope.name(H)}scopeValue(H,R){const ee=this._extScope.value(H,R);return(this._values[ee.prefix]||(this._values[ee.prefix]=new Set)).add(ee),ee}getScopeValue(H,R){return this._extScope.getValue(H,R)}scopeRefs(H){return this._extScope.scopeRefs(H,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(H,R,ee,J){const Z=this._scope.toName(R);return ee!==void 0&&J&&(this._constants[Z.str]=ee),this._leafNode(new o(H,Z,ee)),Z}const(H,R,ee){return this._def(r.varKinds.const,H,R,ee)}let(H,R,ee){return this._def(r.varKinds.let,H,R,ee)}var(H,R,ee){return this._def(r.varKinds.var,H,R,ee)}assign(H,R,ee){return this._leafNode(new l(H,R,ee))}add(H,R){return this._leafNode(new s(H,t.operators.ADD,R))}code(H){return typeof H=="function"?H():H!==e.nil&&this._leafNode(new d(H)),this}object(...H){const R=["{"];for(const[ee,J]of H)R.length>1&&R.push(","),R.push(ee),(ee!==J||this.opts.es5)&&(R.push(":"),(0,e.addCodeArg)(R,J));return R.push("}"),new e._Code(R)}if(H,R,ee){if(this._blockNode(new S(H)),R&&ee)this.code(R).else().code(ee).endIf();else if(R)this.code(R).endIf();else if(ee)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(H){return this._elseNode(new S(H))}else(){return this._elseNode(new b)}endIf(){return this._endBlockNode(S,b)}_for(H,R){return this._blockNode(H),R&&this.code(R).endFor(),this}for(H,R){return this._for(new C(H),R)}forRange(H,R,ee,J,Z=this.opts.es5?r.varKinds.var:r.varKinds.let){const re=this._scope.toName(H);return this._for(new k(Z,re,R,ee),()=>J(re))}forOf(H,R,ee,J=r.varKinds.const){const Z=this._scope.toName(H);if(this.opts.es5){const re=R instanceof e.Name?R:this.var("_arr",R);return this.forRange("_i",0,(0,e._)`${re}.length`,te=>{this.var(Z,(0,e._)`${re}[${te}]`),ee(Z)})}return this._for(new _("of",J,Z,R),()=>ee(Z))}forIn(H,R,ee,J=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(H,(0,e._)`Object.keys(${R})`,ee);const Z=this._scope.toName(H);return this._for(new _("in",J,Z,R),()=>ee(Z))}endFor(){return this._endBlockNode(w)}label(H){return this._leafNode(new f(H))}break(H){return this._leafNode(new c(H))}return(H){const R=new T;if(this._blockNode(R),this.code(H),R.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(T)}try(H,R,ee){if(!R&&!ee)throw new Error('CodeGen: "try" without "catch" and "finally"');const J=new A;if(this._blockNode(J),this.code(H),R){const Z=this.name("e");this._currNode=J.catch=new M(Z),R(Z)}return ee&&(this._currNode=J.finally=new E,this.code(ee)),this._endBlockNode(M,E)}throw(H){return this._leafNode(new h(H))}block(H,R){return this._blockStarts.push(this._nodes.length),H&&this.code(H).endBlock(R),this}endBlock(H){const R=this._blockStarts.pop();if(R===void 0)throw new Error("CodeGen: not in self-balancing block");const ee=this._nodes.length-R;if(ee<0||H!==void 0&&ee!==H)throw new Error(`CodeGen: wrong number of nodes: ${ee} vs ${H} expected`);return this._nodes.length=R,this}func(H,R=e.nil,ee,J){return this._blockNode(new D(H,R,ee)),J&&this.code(J).endFunc(),this}endFunc(){return this._endBlockNode(D)}optimize(H=1){for(;H-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(H){return this._currNode.nodes.push(H),this}_blockNode(H){this._currNode.nodes.push(H),this._nodes.push(H)}_endBlockNode(H,R){const ee=this._currNode;if(ee instanceof H||R&&ee instanceof R)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${R?`${H.kind}/${R.kind}`:H.kind}"`)}_elseNode(H){const R=this._currNode;if(!(R instanceof S))throw new Error('CodeGen: "else" without "if"');return this._currNode=R.else=H,this}get _root(){return this._nodes[0]}get _currNode(){const H=this._nodes;return H[H.length-1]}set _currNode(H){const R=this._nodes;R[R.length-1]=H}}t.CodeGen=N;function Y(U,H){for(const R in H)U[R]=(U[R]||0)+(H[R]||0);return U}function ne(U,H){return H instanceof e._CodeOrName?Y(U,H.names):U}function K(U,H,R){if(U instanceof e.Name)return ee(U);if(!J(U))return U;return new e._Code(U._items.reduce((Z,re)=>(re instanceof e.Name&&(re=ee(re)),re instanceof e._Code?Z.push(...re._items):Z.push(re),Z),[]));function ee(Z){const re=R[Z.str];return re===void 0||H[Z.str]!==1?Z:(delete H[Z.str],re)}function J(Z){return Z instanceof e._Code&&Z._items.some(re=>re instanceof e.Name&&H[re.str]===1&&R[re.str]!==void 0)}}function B(U,H){for(const R in H)U[R]=(U[R]||0)-(H[R]||0)}function j(U){return typeof U=="boolean"||typeof U=="number"||U===null?!U:(0,e._)`!${ae(U)}`}t.not=j;const $=G(t.operators.AND);function V(...U){return U.reduce($)}t.and=V;const z=G(t.operators.OR);function W(...U){return U.reduce(z)}t.or=W;function G(U){return(H,R)=>H===e.nil?R:R===e.nil?H:(0,e._)`${ae(H)} ${U} ${ae(R)}`}function ae(U){return U instanceof e.Name?U:(0,e._)`(${U})`}}(Em)),Em}var Dr={},QM;function an(){if(QM)return Dr;QM=1,Object.defineProperty(Dr,"__esModule",{value:!0}),Dr.checkStrictMode=Dr.getErrorPath=Dr.Type=Dr.useFunc=Dr.setEvaluated=Dr.evaluatedPropsToName=Dr.mergeEvaluated=Dr.eachItem=Dr.unescapeJsonPointer=Dr.escapeJsonPointer=Dr.escapeFragment=Dr.unescapeFragment=Dr.schemaRefOrVal=Dr.schemaHasRulesButRef=Dr.schemaHasRules=Dr.checkUnknownRules=Dr.alwaysValidSchema=Dr.toHash=void 0;const t=Fr(),e=Rc();function r(_){const D={};for(const T of _)D[T]=!0;return D}Dr.toHash=r;function n(_,D){return typeof D=="boolean"?D:Object.keys(D).length===0?!0:(a(_,D),!i(D,_.self.RULES.all))}Dr.alwaysValidSchema=n;function a(_,D=_.schema){const{opts:T,self:A}=_;if(!T.strictSchema||typeof D=="boolean")return;const M=A.RULES.keywords;for(const E in D)M[E]||k(_,`unknown keyword: "${E}"`)}Dr.checkUnknownRules=a;function i(_,D){if(typeof _=="boolean")return!_;for(const T in _)if(D[T])return!0;return!1}Dr.schemaHasRules=i;function o(_,D){if(typeof _=="boolean")return!_;for(const T in _)if(T!=="$ref"&&D.all[T])return!0;return!1}Dr.schemaHasRulesButRef=o;function l({topSchemaRef:_,schemaPath:D},T,A,M){if(!M){if(typeof T=="number"||typeof T=="boolean")return T;if(typeof T=="string")return(0,t._)`${T}`}return(0,t._)`${_}${D}${(0,t.getProperty)(A)}`}Dr.schemaRefOrVal=l;function s(_){return h(decodeURIComponent(_))}Dr.unescapeFragment=s;function f(_){return encodeURIComponent(c(_))}Dr.escapeFragment=f;function c(_){return typeof _=="number"?`${_}`:_.replace(/~/g,"~0").replace(/\//g,"~1")}Dr.escapeJsonPointer=c;function h(_){return _.replace(/~1/g,"/").replace(/~0/g,"~")}Dr.unescapeJsonPointer=h;function d(_,D){if(Array.isArray(_))for(const T of _)D(T);else D(_)}Dr.eachItem=d;function m({mergeNames:_,mergeToName:D,mergeValues:T,resultToName:A}){return(M,E,N,Y)=>{const ne=N===void 0?E:N instanceof t.Name?(E instanceof t.Name?_(M,E,N):D(M,E,N),N):E instanceof t.Name?(D(M,N,E),E):T(E,N);return Y===t.Name&&!(ne instanceof t.Name)?A(M,ne):ne}}Dr.mergeEvaluated={props:m({mergeNames:(_,D,T)=>_.if((0,t._)`${T} !== true && ${D} !== undefined`,()=>{_.if((0,t._)`${D} === true`,()=>_.assign(T,!0),()=>_.assign(T,(0,t._)`${T} || {}`).code((0,t._)`Object.assign(${T}, ${D})`))}),mergeToName:(_,D,T)=>_.if((0,t._)`${T} !== true`,()=>{D===!0?_.assign(T,!0):(_.assign(T,(0,t._)`${T} || {}`),y(_,T,D))}),mergeValues:(_,D)=>_===!0?!0:{..._,...D},resultToName:g}),items:m({mergeNames:(_,D,T)=>_.if((0,t._)`${T} !== true && ${D} !== undefined`,()=>_.assign(T,(0,t._)`${D} === true ? true : ${T} > ${D} ? ${T} : ${D}`)),mergeToName:(_,D,T)=>_.if((0,t._)`${T} !== true`,()=>_.assign(T,D===!0?!0:(0,t._)`${T} > ${D} ? ${T} : ${D}`)),mergeValues:(_,D)=>_===!0?!0:Math.max(_,D),resultToName:(_,D)=>_.var("items",D)})};function g(_,D){if(D===!0)return _.var("props",!0);const T=_.var("props",(0,t._)`{}`);return D!==void 0&&y(_,T,D),T}Dr.evaluatedPropsToName=g;function y(_,D,T){Object.keys(T).forEach(A=>_.assign((0,t._)`${D}${(0,t.getProperty)(A)}`,!0))}Dr.setEvaluated=y;const b={};function S(_,D){return _.scopeValue("func",{ref:D,code:b[D.code]||(b[D.code]=new e._Code(D.code))})}Dr.useFunc=S;var w;(function(_){_[_.Num=0]="Num",_[_.Str=1]="Str"})(w||(Dr.Type=w={}));function C(_,D,T){if(_ instanceof t.Name){const A=D===w.Num;return T?A?(0,t._)`"[" + ${_} + "]"`:(0,t._)`"['" + ${_} + "']"`:A?(0,t._)`"/" + ${_}`:(0,t._)`"/" + ${_}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return T?(0,t.getProperty)(_).toString():"/"+c(_)}Dr.getErrorPath=C;function k(_,D,T=_.opts.strictSchema){if(T){if(D=`strict mode: ${D}`,T===!0)throw new Error(D);_.self.logger.warn(D)}}return Dr.checkStrictMode=k,Dr}var S5={},eE;function Q2(){if(eE)return S5;eE=1,Object.defineProperty(S5,"__esModule",{value:!0});const t=Fr(),e={data:new t.Name("data"),valCxt:new t.Name("valCxt"),instancePath:new t.Name("instancePath"),parentData:new t.Name("parentData"),parentDataProperty:new t.Name("parentDataProperty"),rootData:new t.Name("rootData"),dynamicAnchors:new t.Name("dynamicAnchors"),vErrors:new t.Name("vErrors"),errors:new t.Name("errors"),this:new t.Name("this"),self:new t.Name("self"),scope:new t.Name("scope"),json:new t.Name("json"),jsonPos:new t.Name("jsonPos"),jsonLen:new t.Name("jsonLen"),jsonPart:new t.Name("jsonPart")};return S5.default=e,S5}var tE;function Ff(){return tE||(tE=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.extendErrors=t.resetErrorsCount=t.reportExtraError=t.reportError=t.keyword$DataError=t.keywordError=void 0;const e=Fr(),r=an(),n=Q2();t.keywordError={message:({keyword:b})=>(0,e.str)`must pass "${b}" keyword validation`},t.keyword$DataError={message:({keyword:b,schemaType:S})=>S?(0,e.str)`"${b}" keyword must be ${S} ($data)`:(0,e.str)`"${b}" keyword is invalid ($data)`};function a(b,S=t.keywordError,w,C){const{it:k}=b,{gen:_,compositeRule:D,allErrors:T}=k,A=h(b,S,w);C??(D||T)?s(_,A):f(k,(0,e._)`[${A}]`)}t.reportError=a;function i(b,S=t.keywordError,w){const{it:C}=b,{gen:k,compositeRule:_,allErrors:D}=C,T=h(b,S,w);s(k,T),_||D||f(C,n.default.vErrors)}t.reportExtraError=i;function o(b,S){b.assign(n.default.errors,S),b.if((0,e._)`${n.default.vErrors} !== null`,()=>b.if(S,()=>b.assign((0,e._)`${n.default.vErrors}.length`,S),()=>b.assign(n.default.vErrors,null)))}t.resetErrorsCount=o;function l({gen:b,keyword:S,schemaValue:w,data:C,errsCount:k,it:_}){if(k===void 0)throw new Error("ajv implementation error");const D=b.name("err");b.forRange("i",k,n.default.errors,T=>{b.const(D,(0,e._)`${n.default.vErrors}[${T}]`),b.if((0,e._)`${D}.instancePath === undefined`,()=>b.assign((0,e._)`${D}.instancePath`,(0,e.strConcat)(n.default.instancePath,_.errorPath))),b.assign((0,e._)`${D}.schemaPath`,(0,e.str)`${_.errSchemaPath}/${S}`),_.opts.verbose&&(b.assign((0,e._)`${D}.schema`,w),b.assign((0,e._)`${D}.data`,C))})}t.extendErrors=l;function s(b,S){const w=b.const("err",S);b.if((0,e._)`${n.default.vErrors} === null`,()=>b.assign(n.default.vErrors,(0,e._)`[${w}]`),(0,e._)`${n.default.vErrors}.push(${w})`),b.code((0,e._)`${n.default.errors}++`)}function f(b,S){const{gen:w,validateName:C,schemaEnv:k}=b;k.$async?w.throw((0,e._)`new ${b.ValidationError}(${S})`):(w.assign((0,e._)`${C}.errors`,S),w.return(!1))}const c={keyword:new e.Name("keyword"),schemaPath:new e.Name("schemaPath"),params:new e.Name("params"),propertyName:new e.Name("propertyName"),message:new e.Name("message"),schema:new e.Name("schema"),parentSchema:new e.Name("parentSchema")};function h(b,S,w){const{createErrors:C}=b.it;return C===!1?(0,e._)`{}`:d(b,S,w)}function d(b,S,w={}){const{gen:C,it:k}=b,_=[m(k,w),g(b,w)];return y(b,S,_),C.object(..._)}function m({errorPath:b},{instancePath:S}){const w=S?(0,e.str)`${b}${(0,r.getErrorPath)(S,r.Type.Str)}`:b;return[n.default.instancePath,(0,e.strConcat)(n.default.instancePath,w)]}function g({keyword:b,it:{errSchemaPath:S}},{schemaPath:w,parentSchema:C}){let k=C?S:(0,e.str)`${S}/${b}`;return w&&(k=(0,e.str)`${k}${(0,r.getErrorPath)(w,r.Type.Str)}`),[c.schemaPath,k]}function y(b,{params:S,message:w},C){const{keyword:k,data:_,schemaValue:D,it:T}=b,{opts:A,propertyName:M,topSchemaRef:E,schemaPath:N}=T;C.push([c.keyword,k],[c.params,typeof S=="function"?S(b):S||(0,e._)`{}`]),A.messages&&C.push([c.message,typeof w=="function"?w(b):w]),A.verbose&&C.push([c.schema,D],[c.parentSchema,(0,e._)`${E}${N}`],[n.default.data,_]),M&&C.push([c.propertyName,M])}}(Mm)),Mm}var rE;function Ave(){if(rE)return S3;rE=1,Object.defineProperty(S3,"__esModule",{value:!0}),S3.boolOrEmptySchema=S3.topBoolOrEmptySchema=void 0;const t=Ff(),e=Fr(),r=Q2(),n={message:"boolean schema is false"};function a(l){const{gen:s,schema:f,validateName:c}=l;f===!1?o(l,!1):typeof f=="object"&&f.$async===!0?s.return(r.default.data):(s.assign((0,e._)`${c}.errors`,null),s.return(!0))}S3.topBoolOrEmptySchema=a;function i(l,s){const{gen:f,schema:c}=l;c===!1?(f.var(s,!1),o(l)):f.var(s,!0)}S3.boolOrEmptySchema=i;function o(l,s){const{gen:f,data:c}=l,h={gen:f,keyword:"false schema",data:c,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:l};(0,t.reportError)(h,n,void 0,s)}return S3}var S1={},C3={},nE;function bq(){if(nE)return C3;nE=1,Object.defineProperty(C3,"__esModule",{value:!0}),C3.getRules=C3.isJSONType=void 0;const t=["string","number","integer","boolean","null","object","array"],e=new Set(t);function r(a){return typeof a=="string"&&e.has(a)}C3.isJSONType=r;function n(){const a={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...a,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},a.number,a.string,a.array,a.object],post:{rules:[]},all:{},keywords:{}}}return C3.getRules=n,C3}var P0={},aE;function xq(){if(aE)return P0;aE=1,Object.defineProperty(P0,"__esModule",{value:!0}),P0.shouldUseRule=P0.shouldUseGroup=P0.schemaHasRulesForType=void 0;function t({schema:n,self:a},i){const o=a.RULES.types[i];return o&&o!==!0&&e(n,o)}P0.schemaHasRulesForType=t;function e(n,a){return a.rules.some(i=>r(n,i))}P0.shouldUseGroup=e;function r(n,a){var i;return n[a.keyword]!==void 0||((i=a.definition.implements)===null||i===void 0?void 0:i.some(o=>n[o]!==void 0))}return P0.shouldUseRule=r,P0}var iE;function $c(){if(iE)return S1;iE=1,Object.defineProperty(S1,"__esModule",{value:!0}),S1.reportTypeError=S1.checkDataTypes=S1.checkDataType=S1.coerceAndCheckDataType=S1.getJSONTypes=S1.getSchemaTypes=S1.DataType=void 0;const t=bq(),e=xq(),r=Ff(),n=Fr(),a=an();var i;(function(w){w[w.Correct=0]="Correct",w[w.Wrong=1]="Wrong"})(i||(S1.DataType=i={}));function o(w){const C=l(w.type);if(C.includes("null")){if(w.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!C.length&&w.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');w.nullable===!0&&C.push("null")}return C}S1.getSchemaTypes=o;function l(w){const C=Array.isArray(w)?w:w?[w]:[];if(C.every(t.isJSONType))return C;throw new Error("type must be JSONType or JSONType[]: "+C.join(","))}S1.getJSONTypes=l;function s(w,C){const{gen:k,data:_,opts:D}=w,T=c(C,D.coerceTypes),A=C.length>0&&!(T.length===0&&C.length===1&&(0,e.schemaHasRulesForType)(w,C[0]));if(A){const M=g(C,_,D.strictNumbers,i.Wrong);k.if(M,()=>{T.length?h(w,C,T):b(w)})}return A}S1.coerceAndCheckDataType=s;const f=new Set(["string","number","integer","boolean","null"]);function c(w,C){return C?w.filter(k=>f.has(k)||C==="array"&&k==="array"):[]}function h(w,C,k){const{gen:_,data:D,opts:T}=w,A=_.let("dataType",(0,n._)`typeof ${D}`),M=_.let("coerced",(0,n._)`undefined`);T.coerceTypes==="array"&&_.if((0,n._)`${A} == 'object' && Array.isArray(${D}) && ${D}.length == 1`,()=>_.assign(D,(0,n._)`${D}[0]`).assign(A,(0,n._)`typeof ${D}`).if(g(C,D,T.strictNumbers),()=>_.assign(M,D))),_.if((0,n._)`${M} !== undefined`);for(const N of k)(f.has(N)||N==="array"&&T.coerceTypes==="array")&&E(N);_.else(),b(w),_.endIf(),_.if((0,n._)`${M} !== undefined`,()=>{_.assign(D,M),d(w,M)});function E(N){switch(N){case"string":_.elseIf((0,n._)`${A} == "number" || ${A} == "boolean"`).assign(M,(0,n._)`"" + ${D}`).elseIf((0,n._)`${D} === null`).assign(M,(0,n._)`""`);return;case"number":_.elseIf((0,n._)`${A} == "boolean" || ${D} === null
|
|
280
280
|
|| (${A} == "string" && ${D} && ${D} == +${D})`).assign(M,(0,n._)`+${D}`);return;case"integer":_.elseIf((0,n._)`${A} === "boolean" || ${D} === null
|
|
281
281
|
|| (${A} === "string" && ${D} && ${D} == +${D} && !(${D} % 1))`).assign(M,(0,n._)`+${D}`);return;case"boolean":_.elseIf((0,n._)`${D} === "false" || ${D} === 0 || ${D} === null`).assign(M,!1).elseIf((0,n._)`${D} === "true" || ${D} === 1`).assign(M,!0);return;case"null":_.elseIf((0,n._)`${D} === "" || ${D} === 0 || ${D} === false`),_.assign(M,null);return;case"array":_.elseIf((0,n._)`${A} === "string" || ${A} === "number"
|