l)break;m.push(f)}}else for(;d<=h;++d)for(u=o-1,c=n(d);u>=1;--u)if(!((f=c*u)l)break;m.push(f)}2*m.length0?e>1?zc((function(t){t.setTime(Math.floor(t/e)*e)}),(function(t,n){t.setTime(+t+n*e)}),(function(t,n){return(n-t)/e})):Ev:null};const Cv=Ev;Ev.range;var jv=zc((function(e){e.setTime(e-e.getMilliseconds())}),(function(e,t){e.setTime(+e+t*Lc)}),(function(e,t){return(t-e)/Lc}),(function(e){return e.getUTCSeconds()}));const Mv=jv;jv.range;var Ov=zc((function(e){e.setTime(e-e.getMilliseconds()-e.getSeconds()*Lc)}),(function(e,t){e.setTime(+e+t*Ic)}),(function(e,t){return(t-e)/Ic}),(function(e){return e.getMinutes()}));const Tv=Ov;Ov.range;var Av=zc((function(e){e.setUTCSeconds(0,0)}),(function(e,t){e.setTime(+e+t*Ic)}),(function(e,t){return(t-e)/Ic}),(function(e){return e.getUTCMinutes()}));const Rv=Av;Av.range;var Pv=zc((function(e){e.setTime(e-e.getMilliseconds()-e.getSeconds()*Lc-e.getMinutes()*Ic)}),(function(e,t){e.setTime(+e+t*Fc)}),(function(e,t){return(t-e)/Fc}),(function(e){return e.getHours()}));const Nv=Pv;Pv.range;var zv=zc((function(e){e.setUTCMinutes(0,0,0)}),(function(e,t){e.setTime(+e+t*Fc)}),(function(e,t){return(t-e)/Fc}),(function(e){return e.getUTCHours()}));const Lv=zv;zv.range;var Iv=zc((function(e){e.setDate(1),e.setHours(0,0,0,0)}),(function(e,t){e.setMonth(e.getMonth()+t)}),(function(e,t){return t.getMonth()-e.getMonth()+12*(t.getFullYear()-e.getFullYear())}),(function(e){return e.getMonth()}));const Fv=Iv;Iv.range;var Dv=zc((function(e){e.setUTCDate(1),e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCMonth(e.getUTCMonth()+t)}),(function(e,t){return t.getUTCMonth()-e.getUTCMonth()+12*(t.getUTCFullYear()-e.getUTCFullYear())}),(function(e){return e.getUTCMonth()}));const Bv=Dv;Dv.range;function Uv(){return Uv=Object.assign?Object.assign.bind():function(e){for(var t=1;t0?(y=h.align[b?"left":"right"],v=h.baseline.center):("after"===i&&l>0||"before"===i&&l<0)&&(y=h.align[b?"right":"left"],v=h.baseline.center)):(t=function(e){var t;return{x:0,y:null!=(t=p(e))?t:0}},m.lineX=a*("after"===i?1:-1),g.textX=(a+s)*("after"===i?1:-1),y="after"===i?h.align.left:h.align.right),{ticks:d.map((function(e){var n="string"==typeof e?function(e){var t=String(e).length;return c&&c>0&&t>c?""+String(e).slice(0,c).concat("..."):""+e}(e):e;return ux({key:e instanceof Date?""+e.valueOf():""+e,value:n},t(e),m,g)})),textAlign:y,textBaseline:v}},dx=function(e,t){if(void 0===e||"function"==typeof e)return e;if("time"===t.type){var n=mu(e);return function(e){return n(e instanceof Date?e:new Date(e))}}return Mc(e)},hx=function(e){var t,n=e.width,r=e.height,i=e.scale,o=e.axis,a=e.values,s=(t=a,(Array.isArray(t)?a:void 0)||cx(i,a)),l="bandwidth"in i?ox(i):i,c="x"===o?s.map((function(e){var t,n;return{key:e instanceof Date?""+e.valueOf():""+e,x1:null!=(t=l(e))?t:0,x2:null!=(n=l(e))?n:0,y1:0,y2:r}})):s.map((function(e){var t,r;return{key:e instanceof Date?""+e.valueOf():""+e,x1:0,x2:n,y1:null!=(t=l(e))?t:0,y2:null!=(r=l(e))?r:0}}));return c},px=(0,r.memo)((function(e){var t,n=e.value,i=e.format,o=e.lineX,a=e.lineY,s=e.onClick,l=e.textBaseline,c=e.textAnchor,u=e.animatedProps,f=Od(),d=f.axis.ticks.line,h=f.axis.ticks.text,p=null!=(t=null==i?void 0:i(n))?t:n,m=(0,r.useMemo)((function(){var e={opacity:u.opacity};return s?{style:ux({},e,{cursor:"pointer"}),onClick:function(e){return s(e,p)}}:{style:e}}),[u.opacity,s,p]);return(0,Ne.jsxs)(aa.g,ux({transform:u.transform},m,{children:[(0,Ne.jsx)("line",{x1:0,x2:o,y1:0,y2:a,style:d}),h.outlineWidth>0&&(0,Ne.jsx)(aa.text,{dominantBaseline:l,textAnchor:c,transform:u.textTransform,style:h,strokeWidth:2*h.outlineWidth,stroke:h.outlineColor,strokeLinejoin:"round",children:""+p}),(0,Ne.jsx)(aa.text,{dominantBaseline:l,textAnchor:c,transform:u.textTransform,style:h,children:""+p})]}))})),mx=(0,r.memo)((function(e){var t=e.axis,n=e.scale,i=e.x,o=void 0===i?0:i,a=e.y,s=void 0===a?0:a,l=e.length,c=e.ticksPosition,u=e.tickValues,f=e.tickSize,d=void 0===f?5:f,h=e.tickPadding,p=void 0===h?5:h,m=e.tickRotation,g=void 0===m?0:m,b=e.format,y=e.renderTick,v=void 0===y?px:y,x=e.truncateTickAt,w=e.legend,_=e.legendPosition,k=void 0===_?"end":_,S=e.legendOffset,E=void 0===S?0:S,C=e.onClick,j=e.ariaHidden,M=Od(),O=M.axis.legend.text,T=(0,r.useMemo)((function(){return dx(b,n)}),[b,n]),A=fx({axis:t,scale:n,ticksPosition:c,tickValues:u,tickSize:d,tickPadding:p,tickRotation:g,truncateTickAt:x}),R=A.ticks,P=A.textAlign,N=A.textBaseline,z=null;if(void 0!==w){var L,I=0,F=0,D=0;"y"===t?(D=-90,I=E,"start"===k?(L="start",F=l):"middle"===k?(L="middle",F=l/2):"end"===k&&(L="end")):(F=E,"start"===k?L="start":"middle"===k?(L="middle",I=l/2):"end"===k&&(L="end",I=l)),z=(0,Ne.jsxs)(Ne.Fragment,{children:[O.outlineWidth>0&&(0,Ne.jsx)("text",{transform:"translate("+I+", "+F+") rotate("+D+")",textAnchor:L,style:ux({dominantBaseline:"central"},O),strokeWidth:2*O.outlineWidth,stroke:O.outlineColor,strokeLinejoin:"round",children:w}),(0,Ne.jsx)("text",{transform:"translate("+I+", "+F+") rotate("+D+")",textAnchor:L,style:ux({dominantBaseline:"central"},O),children:w})]})}var B=ad(),U=B.animate,q=B.config,W=Bo({transform:"translate("+o+","+s+")",lineX2:"x"===t?l:0,lineY2:"x"===t?0:l,config:q,immediate:!U}),V=(0,r.useCallback)((function(e){return{opacity:1,transform:"translate("+e.x+","+e.y+")",textTransform:"translate("+e.textX+","+e.textY+") rotate("+g+")"}}),[g]),H=Uo(R,{keys:function(e){return e.key},initial:V,from:(0,r.useCallback)((function(e){return{opacity:0,transform:"translate("+e.x+","+e.y+")",textTransform:"translate("+e.textX+","+e.textY+") rotate("+g+")"}}),[g]),enter:V,update:V,leave:{opacity:0},config:q,immediate:!U});return(0,Ne.jsxs)(aa.g,{transform:W.transform,"aria-hidden":j,children:[H((function(e,t,n,i){return r.createElement(v,ux({tickIndex:i,format:T,rotate:g,textBaseline:N,textAnchor:P,truncateTickAt:x,animatedProps:e},t,C?{onClick:C}:{}))})),(0,Ne.jsx)(aa.line,{style:M.axis.domain.line,x1:0,x2:W.lineX2,y1:0,y2:W.lineY2}),z]})})),gx={ticksPosition:wn().oneOf(["before","after"]),tickValues:wn().oneOfType([wn().number,wn().arrayOf(wn().oneOfType([wn().number,wn().string,wn().instanceOf(Date)])),wn().string]),rotateOnTickLength:wn().shape({angle:wn().number,length:wn().number}),tickSize:wn().number,tickPadding:wn().number,tickRotation:wn().number,format:wn().oneOfType([wn().func,wn().string]),renderTick:wn().func,legend:wn().node,legendPosition:wn().oneOf(["start","middle","end"]),legendOffset:wn().number,ariaHidden:wn().bool},bx=wn().shape(gx),yx=["top","right","bottom","left"],vx=(0,r.memo)((function(e){var t=e.xScale,n=e.yScale,r=e.width,i=e.height,o={top:e.top,right:e.right,bottom:e.bottom,left:e.left};return(0,Ne.jsx)(Ne.Fragment,{children:yx.map((function(e){var a=o[e];if(!a)return null;var s="top"===e||"bottom"===e;return(0,Ne.jsx)(mx,ux({},a,{axis:s?"x":"y",x:"right"===e?r:0,y:"bottom"===e?i:0,scale:s?t:n,length:s?r:i,ticksPosition:"top"===e||"left"===e?"before":"after",truncateTickAt:a.truncateTickAt}),e)}))})})),xx=(0,r.memo)((function(e){var t=e.animatedProps,n=Od();return(0,Ne.jsx)(aa.line,ux({},t,n.grid.line))})),wx=(0,r.memo)((function(e){var t=e.lines,n=ad(),i=n.animate,o=Uo(t,{keys:function(e){return e.key},initial:function(e){return{opacity:1,x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2}},from:function(e){return{opacity:0,x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2}},enter:function(e){return{opacity:1,x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2}},update:function(e){return{opacity:1,x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2}},leave:{opacity:0},config:n.config,immediate:!i});return(0,Ne.jsx)("g",{children:o((function(e,t){return(0,r.createElement)(xx,ux({},t,{key:t.key,animatedProps:e}))}))})})),_x=(0,r.memo)((function(e){var t=e.width,n=e.height,i=e.xScale,o=e.yScale,a=e.xValues,s=e.yValues,l=(0,r.useMemo)((function(){return!!i&&hx({width:t,height:n,scale:i,axis:"x",values:a})}),[i,a,t,n]),c=(0,r.useMemo)((function(){return!!o&&hx({width:t,height:n,scale:o,axis:"y",values:s})}),[n,t,o,s]);return(0,Ne.jsxs)(Ne.Fragment,{children:[l&&(0,Ne.jsx)(wx,{lines:l}),c&&(0,Ne.jsx)(wx,{lines:c})]})})),kx=function(e,t){var n=t.xScale,r=t.yScale,i=t.width,o=t.height,a=t.top,s=t.right,l=t.bottom,c=t.left,u=t.theme,f={top:a,right:s,bottom:l,left:c};yx.forEach((function(t){var a=f[t];if(!a)return null;var s="top"===t||"bottom"===t,l="top"===t||"left"===t?"before":"after",c=s?n:r,d=dx(a.format,c);!function(e,t){var n,r=t.axis,i=t.scale,o=t.x,a=void 0===o?0:o,s=t.y,l=void 0===s?0:s,c=t.length,u=t.ticksPosition,f=t.tickValues,d=t.tickSize,h=void 0===d?5:d,p=t.tickPadding,m=void 0===p?5:p,g=t.tickRotation,b=void 0===g?0:g,y=t.format,v=t.legend,x=t.legendPosition,w=void 0===x?"end":x,_=t.legendOffset,k=void 0===_?0:_,S=t.theme,E=fx({axis:r,scale:i,ticksPosition:u,tickValues:f,tickSize:h,tickPadding:m,tickRotation:b,engine:"canvas"}),C=E.ticks,j=E.textAlign,M=E.textBaseline;e.save(),e.translate(a,l),e.textAlign=j,e.textBaseline=M;var O=S.axis.ticks.text;e.font=(O.fontWeight?O.fontWeight+" ":"")+O.fontSize+"px "+O.fontFamily,(null!=(n=S.axis.domain.line.strokeWidth)?n:0)>0&&(e.lineWidth=Number(S.axis.domain.line.strokeWidth),e.lineCap="square",S.axis.domain.line.stroke&&(e.strokeStyle=S.axis.domain.line.stroke),e.beginPath(),e.moveTo(0,0),e.lineTo("x"===r?c:0,"x"===r?0:c),e.stroke());var T="function"==typeof y?y:function(e){return""+e};if(C.forEach((function(t){var n;(null!=(n=S.axis.ticks.line.strokeWidth)?n:0)>0&&(e.lineWidth=Number(S.axis.ticks.line.strokeWidth),e.lineCap="square",S.axis.ticks.line.stroke&&(e.strokeStyle=S.axis.ticks.line.stroke),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(t.x+t.lineX,t.y+t.lineY),e.stroke());var r=T(t.value);e.save(),e.translate(t.x+t.textX,t.y+t.textY),e.rotate(Fd(b)),O.outlineWidth>0&&(e.strokeStyle=O.outlineColor,e.lineWidth=2*O.outlineWidth,e.lineJoin="round",e.strokeText(""+r,0,0)),S.axis.ticks.text.fill&&(e.fillStyle=O.fill),e.fillText(""+r,0,0),e.restore()})),void 0!==v){var A=0,R=0,P=0,N="center";"y"===r?(P=-90,A=k,"start"===w?(N="start",R=c):"middle"===w?(N="center",R=c/2):"end"===w&&(N="end")):(R=k,"start"===w?N="start":"middle"===w?(N="center",A=c/2):"end"===w&&(N="end",A=c)),e.translate(A,R),e.rotate(Fd(P)),e.font=(S.axis.legend.text.fontWeight?S.axis.legend.text.fontWeight+" ":"")+S.axis.legend.text.fontSize+"px "+S.axis.legend.text.fontFamily,S.axis.legend.text.fill&&(e.fillStyle=S.axis.legend.text.fill),e.textAlign=N,e.textBaseline="middle",e.fillText(v,0,0)}e.restore()}(e,ux({},a,{axis:s?"x":"y",x:"right"===t?i:0,y:"bottom"===t?o:0,scale:c,format:d,length:s?i:o,ticksPosition:l,theme:u}))}))},Sx=function(e,t){var n=t.width,r=t.height,i=t.scale,o=t.axis,a=t.values;hx({width:n,height:r,scale:i,axis:o,values:a}).forEach((function(t){e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()}))};function Ex(){return Ex=Object.assign?Object.assign.bind():function(e){for(var t=1;tDx)if(Math.abs(u*s-l*c)>Dx&&i){var d=n-o,h=r-a,p=s*s+l*l,m=d*d+h*h,g=Math.sqrt(p),b=Math.sqrt(f),y=i*Math.tan((Ix-Math.acos((p+f-m)/(2*g*b)))/2),v=y/b,x=y/g;Math.abs(v-1)>Dx&&(this._+="L"+(e+v*c)+","+(t+v*u)),this._+="A"+i+","+i+",0,0,"+ +(u*d>c*h)+","+(this._x1=e+x*s)+","+(this._y1=t+x*l)}else this._+="L"+(this._x1=e)+","+(this._y1=t);else;},arc:function(e,t,n,r,i,o){e=+e,t=+t,o=!!o;var a=(n=+n)*Math.cos(r),s=n*Math.sin(r),l=e+a,c=t+s,u=1^o,f=o?r-i:i-r;if(n<0)throw new Error("negative radius: "+n);null===this._x1?this._+="M"+l+","+c:(Math.abs(this._x1-l)>Dx||Math.abs(this._y1-c)>Dx)&&(this._+="L"+l+","+c),n&&(f<0&&(f=f%Fx+Fx),f>Bx?this._+="A"+n+","+n+",0,1,"+u+","+(e-a)+","+(t-s)+"A"+n+","+n+",0,1,"+u+","+(this._x1=l)+","+(this._y1=c):f>Dx&&(this._+="A"+n+","+n+",0,"+ +(f>=Ix)+","+u+","+(this._x1=e+n*Math.cos(i))+","+(this._y1=t+n*Math.sin(i))))},rect:function(e,t,n,r){this._+="M"+(this._x0=this._x1=+e)+","+(this._y0=this._y1=+t)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},toString:function(){return this._}};const Wx=qx;function Vx(e){return function(){return e}}function Hx(e){return e[0]}function $x(e){return e[1]}function Yx(){var e=Hx,t=$x,n=Vx(!0),r=null,i=tc,o=null;function a(a){var s,l,c,u=a.length,f=!1;for(null==r&&(o=i(c=Wx())),s=0;s<=u;++s)!(s1&&void 0!==arguments[1]?arguments[1]:iw,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ow;const r=e.length,i=new Float64Array(2*r);for(let o=0;o>1;if(t>0&&"number"!==typeof e[0])throw new Error("Expected coords to contain numbers.");this.coords=e;const n=Math.max(2*t-5,0);this._triangles=new Uint32Array(3*n),this._halfedges=new Int32Array(3*n),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:i}=this,o=e.length>>1;let a=1/0,s=1/0,l=-1/0,c=-1/0;for(let E=0;El&&(l=t),n>c&&(c=n),this._ids[E]=E}const u=(a+l)/2,f=(s+c)/2;let d,h,p,m=1/0;for(let E=0;E0&&(h=E,m=t)}let y=e[2*h],v=e[2*h+1],x=1/0;for(let E=0;Er&&(t[n++]=i,r=this._dists[i])}return this.hull=t.subarray(0,n),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(Zx(g,b,y,v,w,_)){const e=h,t=y,n=v;h=p,y=w,v=_,p=e,w=t,_=n}const k=function(e,t,n,r,i,o){const a=n-e,s=r-t,l=i-e,c=o-t,u=a*a+s*s,f=l*l+c*c,d=.5/(a*c-s*l);return{x:e+(c*u-s*f)*d,y:t+(a*f-l*u)*d}}(g,b,y,v,w,_);this._cx=k.x,this._cy=k.y;for(let E=0;E0&&Math.abs(a-E)<=Gx&&Math.abs(s-C)<=Gx)continue;if(E=a,C=s,o===d||o===h||o===p)continue;let l=0;for(let e=0,t=this._hashKey(a,s);e0?3-n:1+n)/4}(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){const{_triangles:t,_halfedges:n,coords:r}=this;let i=0,o=0;for(;;){const a=n[e],s=e-e%3;if(o=s+(e+2)%3,-1===a){if(0===i)break;e=Xx[--i];continue}const l=a-a%3,c=s+(e+1)%3,u=l+(a+2)%3,f=t[o],d=t[e],h=t[c],p=t[u];if(ew(r[2*f],r[2*f+1],r[2*d],r[2*d+1],r[2*h],r[2*h+1],r[2*p],r[2*p+1])){t[e]=p,t[a]=f;const r=n[u];if(-1===r){let t=this._hullStart;do{if(this._hullTri[t]===u){this._hullTri[t]=e;break}t=this._hullPrev[t]}while(t!==this._hullStart)}this._link(e,r),this._link(a,n[o]),this._link(o,u);const s=l+(a+1)%3;i=33306690738754716e-32*Math.abs(a+s)?a-s:0}function Zx(e,t,n,r,i,o){return(Jx(i,o,e,t,n,r)||Jx(e,t,n,r,i,o)||Jx(n,r,i,o,e,t))<0}function ew(e,t,n,r,i,o,a,s){const l=e-a,c=t-s,u=n-a,f=r-s,d=i-a,h=o-s,p=u*u+f*f,m=d*d+h*h;return l*(f*m-p*h)-c*(u*m-p*d)+(l*l+c*c)*(u*h-f*d)<0}function tw(e,t,n,r,i,o){const a=n-e,s=r-t,l=i-e,c=o-t,u=a*a+s*s,f=l*l+c*c,d=.5/(a*c-s*l),h=(c*u-s*f)*d,p=(a*f-l*u)*d;return h*h+p*p}function nw(e,t,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){const r=e[i],o=t[r];let a=i-1;for(;a>=n&&t[e[a]]>o;)e[a+1]=e[a--];e[a+1]=r}else{let i=n+1,o=r;rw(e,n+r>>1,i),t[e[n]]>t[e[r]]&&rw(e,n,r),t[e[i]]>t[e[r]]&&rw(e,i,r),t[e[n]]>t[e[i]]&&rw(e,n,i);const a=e[i],s=t[a];for(;;){do{i++}while(t[e[i]]s);if(o=o-n?(nw(e,t,i,r),nw(e,t,n,o-1)):(nw(e,t,n,o-1),nw(e,t,i,r))}}function rw(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function iw(e){return e[0]}function ow(e){return e[1]}const aw=1e-6;class sw{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+="M".concat(this._x0=this._x1=+e,",").concat(this._y0=this._y1=+t)}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+="L".concat(this._x1=+e,",").concat(this._y1=+t)}arc(e,t,n){const r=(e=+e)+(n=+n),i=t=+t;if(n<0)throw new Error("negative radius");null===this._x1?this._+="M".concat(r,",").concat(i):(Math.abs(this._x1-r)>aw||Math.abs(this._y1-i)>aw)&&(this._+="L"+r+","+i),n&&(this._+="A".concat(n,",").concat(n,",0,1,1,").concat(e-n,",").concat(t,"A").concat(n,",").concat(n,",0,1,1,").concat(this._x1=r,",").concat(this._y1=i))}rect(e,t,n,r){this._+="M".concat(this._x0=this._x1=+e,",").concat(this._y0=this._y1=+t,"h").concat(+n,"v").concat(+r,"h").concat(-n,"Z")}value(){return this._||null}}class lw{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class cw{constructor(e){let[t,n,r,i]=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,960,500];if(!((r=+r)>=(t=+t))||!((i=+i)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(2*e.points.length),this.vectors=new Float64Array(2*e.points.length),this.xmax=r,this.xmin=t,this.ymax=i,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this,i=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let d,h,p=0,m=0,g=n.length;p1;)i-=2;for(let o=2;o4)for(let o=0;o0){if(t>=this.ymax)return null;(i=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(i=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}}const uw=2*Math.PI,fw=Math.pow;function dw(e){return e[0]}function hw(e){return e[1]}function pw(e,t,n){return[e+Math.sin(e+t)*n,t+Math.cos(e-t)*n]}class mw{static from(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dw,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:hw,r=arguments.length>3?arguments[3]:void 0;return new mw("length"in e?function(e,t,n,r){const i=e.length,o=new Float64Array(2*i);for(let a=0;a2&&function(e){const{triangles:t,coords:n}=e;for(let r=0;r1e-10)return!1}return!0}(e)){this.collinear=Int32Array.from({length:t.length/2},((e,t)=>t)).sort(((e,n)=>t[2*e]-t[2*n]||t[2*e+1]-t[2*n+1]));const e=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[t[2*e],t[2*e+1],t[2*n],t[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let o=0,a=t.length/2;o0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],this.triangles[1]=r[1],this.triangles[2]=r[1],o[r[0]]=1,2===r.length&&(o[r[1]]=0))}voronoi(e){return new cw(this,e)}*neighbors(e){const{inedges:t,hull:n,_hullIndex:r,halfedges:i,triangles:o,collinear:a}=this;if(a){const t=a.indexOf(e);return t>0&&(yield a[t-1]),void(t2&&void 0!==arguments[2]?arguments[2]:0;if((e=+e)!==e||(t=+t)!==t)return-1;const r=n;let i;for(;(i=this._step(n,e,t))>=0&&i!==n&&i!==r;)n=i;return i}_step(e,t,n){const{inedges:r,hull:i,_hullIndex:o,halfedges:a,triangles:s,points:l}=this;if(-1===r[e]||!l.length)return(e+1)%(l.length>>1);let c=e,u=fw(t-l[2*e],2)+fw(n-l[2*e+1],2);const f=r[e];let d=f;do{let r=s[d];const f=fw(t-l[2*r],2)+fw(n-l[2*r+1],2);if(f1&&void 0!==arguments[1]?arguments[1]:2;const n=null==e?e=new sw:void 0,{points:r}=this;for(let i=0,o=r.length;i=u;--f)s.point(g[f],b[f]);s.lineEnd(),s.areaEnd()}m&&(g[c]=+e(d,c,l),b[c]=+n(d,c,l),s.point(t?+t(d,c,l):g[c],r?+r(d,c,l):b[c]))}if(h)return s=null,h+""||null}function c(){return Yx().defined(i).curve(a).context(o)}return l.x=function(n){return arguments.length?(e="function"===typeof n?n:Vx(+n),t=null,l):e},l.x0=function(t){return arguments.length?(e="function"===typeof t?t:Vx(+t),l):e},l.x1=function(e){return arguments.length?(t=null==e?null:"function"===typeof e?e:Vx(+e),l):t},l.y=function(e){return arguments.length?(n="function"===typeof e?e:Vx(+e),r=null,l):n},l.y0=function(e){return arguments.length?(n="function"===typeof e?e:Vx(+e),l):n},l.y1=function(e){return arguments.length?(r=null==e?null:"function"===typeof e?e:Vx(+e),l):r},l.lineX0=l.lineY0=function(){return c().x(e).y(n)},l.lineY1=function(){return c().x(e).y(r)},l.lineX1=function(){return c().x(t).y(n)},l.defined=function(e){return arguments.length?(i="function"===typeof e?e:Vx(!!e),l):i},l.curve=function(e){return arguments.length?(a=e,null!=o&&(s=a(o)),l):a},l.context=function(e){return arguments.length?(null==e?o=s=null:s=a(o=e),l):o},l}().defined((function(e){return null!==e.x&&null!==e.y})).x((function(e){return e.x})).y1((function(e){return e.y})).curve(pd(t)).y0(n(i))}),[t,n,i])},Rw=function(e){var t=e.data,n=e.xScale,i=void 0===n?Mw.xScale:n,o=e.xFormat,a=e.yScale,s=void 0===a?Mw.yScale:a,l=e.yFormat,c=e.width,u=e.height,f=e.colors,d=void 0===f?Mw.colors:f,h=e.curve,p=void 0===h?Mw.curve:h,m=e.areaBaselineValue,g=void 0===m?Mw.areaBaselineValue:m,b=e.pointColor,y=void 0===b?Mw.pointColor:b,v=e.pointBorderColor,x=void 0===v?Mw.pointBorderColor:v,w=e.enableSlices,_=void 0===w?Mw.enableSlicesTooltip:w,k=Ed(o),S=Ed(l),E=function(e,t){return(0,r.useMemo)((function(){return zg(e,t)}),[e,t])}(d,"id"),C=Od(),j=Pg(y,C),M=Pg(x,C),O=(0,r.useState)([]),T=O[0],A=O[1],R=(0,r.useMemo)((function(){return function(e,t,n,r,i){var o=e.map((function(e){return function(e){return Uv({},e,{data:e.data.map((function(e){return{data:Uv({},e)}}))})}(e)})),a=ex(o,t,n);"stacked"in t&&!0===t.stacked&&rx(a,o),"stacked"in n&&!0===n.stacked&&ix(a,o);var s=Jv(t,a.x,r,"x"),l=Jv(n,a.y,i,"y"),c=o.map((function(e){return Uv({},e,{data:e.data.map((function(e){return Uv({},e,{position:{x:Zv(e,"x",s),y:Zv(e,"y",l)}})}))})}));return Uv({},a,{series:c,xScale:s,yScale:l})}(t.filter((function(e){return-1===T.indexOf(e.id)})),i,s,c,u)}),[t,T,i,s,c,u]),P=R.xScale,N=R.yScale,z=R.series,L=(0,r.useMemo)((function(){var e=t.map((function(e){return{id:e.id,label:e.id,color:E(e)}})),n=e.map((function(e){return vw({},z.find((function(t){return t.id===e.id})),{color:e.color})})).filter((function(e){return Boolean(e.id)}));return{legendData:e.map((function(e){return vw({},e,{hidden:!n.find((function(t){return t.id===e.id}))})})).reverse(),series:n}}),[t,z,E]),I=L.legendData,F=L.series,D=(0,r.useCallback)((function(e){A((function(t){return t.indexOf(e)>-1?t.filter((function(t){return t!==e})):[].concat(t,[e])}))}),[]),B=function(e){var t=e.series,n=e.getPointColor,i=e.getPointBorderColor,o=e.formatX,a=e.formatY;return(0,r.useMemo)((function(){return t.reduce((function(e,t){return[].concat(e,t.data.filter((function(e){return null!==e.position.x&&null!==e.position.y})).map((function(r,s){var l={id:t.id+"."+s,index:e.length+s,serieId:t.id,serieColor:t.color,x:r.position.x,y:r.position.y};return l.color=n(t),l.borderColor=i(l),l.data=vw({},r.data,{xFormatted:o(r.data.x),yFormatted:a(r.data.y)}),l})))}),[])}),[t,n,i,o,a])}({series:F,getPointColor:j,getPointBorderColor:M,formatX:k,formatY:S}),U=function(e){var t=e.enableSlices,n=e.points,i=e.width,o=e.height;return(0,r.useMemo)((function(){if(!1===t)return[];if("x"===t){var e=new Map;return n.forEach((function(t){null!==t.data.x&&null!==t.data.y&&(e.has(t.x)?e.get(t.x).push(t):e.set(t.x,[t]))})),Array.from(e.entries()).sort((function(e,t){return e[0]-t[0]})).map((function(e,t,n){var r,a=e[0],s=e[1],l=n[t-1],c=n[t+1];return{id:a,x0:r=l?a-(a-l[0])/2:a,x:a,y0:0,y:0,width:c?a-r+(c[0]-a)/2:i-r,height:o,points:s.reverse()}}))}if("y"===t){var r=new Map;return n.forEach((function(e){null!==e.data.x&&null!==e.data.y&&(r.has(e.y)?r.get(e.y).push(e):r.set(e.y,[e]))})),Array.from(r.entries()).sort((function(e,t){return e[0]-t[0]})).map((function(e,t,n){var r,a,s=e[0],l=e[1],c=n[t-1],u=n[t+1];return r=c?s-(s-c[0])/2:s,a=u?s-r+(u[0]-s)/2:o-r,{id:s,x0:0,x:0,y0:r,y:s,width:i,height:a,points:l.reverse()}}))}}),[t,n])}({enableSlices:_,points:B,width:c,height:u});return{legendData:I,toggleSerie:D,lineGenerator:Tw({curve:p}),areaGenerator:Aw({curve:p,yScale:N,areaBaselineValue:g}),getColor:E,series:F,xScale:P,yScale:N,slices:U,points:B}},Pw=function(e){var t=e.areaBlendMode,n=e.areaOpacity,r=e.color,i=e.fill,o=e.path,a=ad(),s=a.animate,l=a.config,c=sd(o),u=Bo({color:r,config:l,immediate:!s});return(0,Ne.jsx)(aa.path,{d:c,fill:i||u.color,fillOpacity:n,strokeWidth:0,style:{mixBlendMode:t}})};Pw.propTypes={areaBlendMode:xd.isRequired,areaOpacity:wn().number.isRequired,color:wn().string,fill:wn().string,path:wn().string.isRequired};var Nw=function(e){var t=e.areaGenerator,n=e.areaOpacity,r=e.areaBlendMode,i=e.lines.slice(0).reverse();return(0,Ne.jsx)("g",{children:i.map((function(e){return(0,Ne.jsx)(Pw,vw({path:t(e.data.map((function(e){return e.position})))},vw({areaOpacity:n,areaBlendMode:r},e)),e.id)}))})};Nw.propTypes={areaGenerator:wn().func.isRequired,areaOpacity:wn().number.isRequired,areaBlendMode:xd.isRequired,lines:wn().arrayOf(wn().object).isRequired};var zw=(0,r.memo)(Nw),Lw=function(e){var t=e.lineGenerator,n=e.points,i=e.color,o=e.thickness,a=(0,r.useMemo)((function(){return t(n)}),[t,n]),s=sd(a);return(0,Ne.jsx)(aa.path,{d:s,fill:"none",strokeWidth:o,stroke:i})};Lw.propTypes={points:wn().arrayOf(wn().shape({x:wn().oneOfType([wn().string,wn().number]),y:wn().oneOfType([wn().string,wn().number])})),lineGenerator:wn().func.isRequired,color:wn().string.isRequired,thickness:wn().number.isRequired};var Iw=(0,r.memo)(Lw),Fw=function(e){var t=e.lines,n=e.lineGenerator,r=e.lineWidth;return t.slice(0).reverse().map((function(e){var t=e.id,i=e.data,o=e.color;return(0,Ne.jsx)(Iw,{id:t,points:i.map((function(e){return e.position})),lineGenerator:n,color:o,thickness:r},t)}))};Fw.propTypes={lines:wn().arrayOf(wn().shape({id:wn().oneOfType([wn().string,wn().number]).isRequired,color:wn().string.isRequired,data:wn().arrayOf(wn().shape({data:wn().shape({x:wn().oneOfType([wn().string,wn().number,wn().instanceOf(Date)]),y:wn().oneOfType([wn().string,wn().number,wn().instanceOf(Date)])}).isRequired,position:wn().shape({x:wn().number,y:wn().number}).isRequired})).isRequired})).isRequired,lineWidth:wn().number.isRequired,lineGenerator:wn().func.isRequired};var Dw=(0,r.memo)(Fw),Bw=function(e){var t=e.slice,n=e.axis,i=e.debug,o=e.tooltip,a=e.isCurrent,s=e.setCurrent,l=e.onMouseEnter,c=e.onMouseMove,u=e.onMouseLeave,f=e.onClick,d=wa(),h=d.showTooltipFromEvent,p=d.hideTooltip,m=(0,r.useCallback)((function(e){h((0,r.createElement)(o,{slice:t,axis:n}),e,"right"),s(t),l&&l(t,e)}),[h,o,t,l]),g=(0,r.useCallback)((function(e){h((0,r.createElement)(o,{slice:t,axis:n}),e,"right"),c&&c(t,e)}),[h,o,t,c]),b=(0,r.useCallback)((function(e){p(),s(null),u&&u(t,e)}),[p,t,u]),y=(0,r.useCallback)((function(e){f&&f(t,e)}),[t,f]);return(0,Ne.jsx)("rect",{x:t.x0,y:t.y0,width:t.width,height:t.height,stroke:"red",strokeWidth:i?1:0,strokeOpacity:.75,fill:"red",fillOpacity:a&&i?.35:0,onMouseEnter:m,onMouseMove:g,onMouseLeave:b,onClick:y,"data-testid":"slice-"+t.id})};Bw.propTypes={slice:wn().object.isRequired,axis:wn().oneOf(["x","y"]).isRequired,debug:wn().bool.isRequired,height:wn().number.isRequired,tooltip:wn().oneOfType([wn().func,wn().object]),isCurrent:wn().bool.isRequired,setCurrent:wn().func.isRequired,onMouseEnter:wn().func,onMouseMove:wn().func,onMouseLeave:wn().func,onClick:wn().func};var Uw=(0,r.memo)(Bw),qw=function(e){var t=e.slices,n=e.axis,r=e.debug,i=e.height,o=e.tooltip,a=e.current,s=e.setCurrent,l=e.onMouseEnter,c=e.onMouseMove,u=e.onMouseLeave,f=e.onClick;return t.map((function(e){return(0,Ne.jsx)(Uw,{slice:e,axis:n,debug:r,height:i,tooltip:o,setCurrent:s,isCurrent:null!==a&&a.id===e.id,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:f},e.id)}))};qw.propTypes={slices:wn().arrayOf(wn().shape({id:wn().oneOfType([wn().number,wn().string,wn().instanceOf(Date)]).isRequired,x:wn().number.isRequired,y:wn().number.isRequired,points:wn().arrayOf(wn().object).isRequired})).isRequired,axis:wn().oneOf(["x","y"]).isRequired,debug:wn().bool.isRequired,height:wn().number.isRequired,tooltip:wn().oneOfType([wn().func,wn().object]).isRequired,current:wn().object,setCurrent:wn().func.isRequired,onMouseEnter:wn().func,onMouseMove:wn().func,onMouseLeave:wn().func,onClick:wn().func};var Ww=(0,r.memo)(qw),Vw=function(e){var t=e.points,n=e.symbol,r=e.size,i=e.borderWidth,o=e.enableLabel,a=e.label,s=e.labelYOffset,l=Od(),c=function(e,t){var n,r=Tl()(e)?e:function(t){return ja()(t,e)};return t&&(n=Tl()(t)?t:Mc(t)),n?function(e){return n(r(e))}:r}(a),u=t.slice(0).reverse().map((function(e){return{id:e.id,x:e.x,y:e.y,datum:e.data,fill:e.color,stroke:e.borderColor,label:o?c(e.data):null}}));return(0,Ne.jsx)("g",{children:u.map((function(e){return(0,Ne.jsx)(Qd,{x:e.x,y:e.y,datum:e.datum,symbol:n,size:r,color:e.fill,borderWidth:i,borderColor:e.stroke,label:e.label,labelYOffset:s,theme:l},e.id)}))})};Vw.propTypes={points:wn().arrayOf(wn().object),symbol:wn().func,size:wn().number.isRequired,color:wn().func.isRequired,borderWidth:wn().number.isRequired,borderColor:wn().func.isRequired,enableLabel:wn().bool.isRequired,label:wn().oneOfType([wn().string,wn().func]).isRequired,labelYOffset:wn().number};var Hw=(0,r.memo)(Vw),$w=function(e){var t=e.points,n=e.width,i=e.height,o=e.margin,a=e.setCurrent,s=e.onMouseEnter,l=e.onMouseMove,c=e.onMouseLeave,u=e.onClick,f=e.tooltip,d=e.debug,h=wa(),p=h.showTooltipAt,m=h.hideTooltip,g=(0,r.useCallback)((function(e,t){p((0,r.createElement)(f,{point:e}),[e.x+o.left,e.y+o.top],"top"),a(e),s&&s(e,t)}),[a,p,f,s,o]),b=(0,r.useCallback)((function(e,t){p((0,r.createElement)(f,{point:e}),[e.x+o.left,e.y+o.top],"top"),a(e),l&&l(e,t)}),[a,p,f,l]),y=(0,r.useCallback)((function(e,t){m(),a(null),c&&c(e,t)}),[m,a,c]),v=(0,r.useCallback)((function(e,t){u&&u(e,t)}),[u]);return(0,Ne.jsx)(yw,{nodes:t,width:n,height:i,onMouseEnter:g,onMouseMove:b,onMouseLeave:y,onClick:v,debug:d})};$w.propTypes={points:wn().arrayOf(wn().object).isRequired,width:wn().number.isRequired,height:wn().number.isRequired,margin:wn().object.isRequired,setCurrent:wn().func.isRequired,onMouseEnter:wn().func,onMouseMove:wn().func,onMouseLeave:wn().func,onClick:wn().func,tooltip:wn().oneOfType([wn().func,wn().object]).isRequired,debug:wn().bool.isRequired};var Yw=(0,r.memo)($w),Gw=function(e){var t=e.data,n=e.xScale,i=e.xFormat,o=e.yScale,a=e.yFormat,s=e.layers,l=e.curve,c=e.areaBaselineValue,u=e.colors,f=e.margin,d=e.width,h=e.height,p=e.axisTop,m=e.axisRight,g=e.axisBottom,b=e.axisLeft,y=e.enableGridX,v=e.enableGridY,x=e.gridXValues,w=e.gridYValues,_=e.lineWidth,k=e.enableArea,S=e.areaOpacity,E=e.areaBlendMode,C=e.enablePoints,j=e.pointSymbol,M=e.pointSize,O=e.pointColor,T=e.pointBorderWidth,A=e.pointBorderColor,R=e.enablePointLabel,P=e.pointLabel,N=e.pointLabelYOffset,z=e.defs,L=e.fill,I=e.markers,F=e.legends,D=e.isInteractive,B=e.useMesh,U=e.debugMesh,q=e.onMouseEnter,W=e.onMouseMove,V=e.onMouseLeave,H=e.onClick,$=e.tooltip,Y=e.enableSlices,G=e.debugSlices,X=e.sliceTooltip,K=e.enableCrosshair,Q=e.crosshairType,J=e.role,Z=_d(d,h,f),ee=Z.margin,te=Z.innerWidth,ne=Z.innerHeight,re=Z.outerWidth,ie=Z.outerHeight,oe=Rw({data:t,xScale:n,xFormat:i,yScale:o,yFormat:a,width:te,height:ne,colors:u,curve:l,areaBaselineValue:c,pointColor:O,pointBorderColor:A,enableSlices:Y}),ae=oe.legendData,se=oe.toggleSerie,le=oe.lineGenerator,ce=oe.areaGenerator,ue=oe.series,fe=oe.xScale,de=oe.yScale,he=oe.slices,pe=oe.points,me=Od(),ge=Pg(O,me),be=Pg(A,me),ye=(0,r.useState)(null),ve=ye[0],xe=ye[1],we=(0,r.useState)(null),_e=we[0],ke=we[1],Se={grid:(0,Ne.jsx)(_x,{theme:me,width:te,height:ne,xScale:y?fe:null,yScale:v?de:null,xValues:x,yValues:w},"grid"),markers:(0,Ne.jsx)(th,{markers:I,width:te,height:ne,xScale:fe,yScale:de,theme:me},"markers"),axes:(0,Ne.jsx)(vx,{xScale:fe,yScale:de,width:te,height:ne,theme:me,top:p,right:m,bottom:g,left:b},"axes"),areas:null,lines:(0,Ne.jsx)(Dw,{lines:ue,lineGenerator:le,lineWidth:_},"lines"),slices:null,points:null,crosshair:null,mesh:null,legends:F.map((function(e,t){return(0,Ne.jsx)(Px,vw({},e,{containerWidth:te,containerHeight:ne,data:e.data||ae,theme:me,toggleSerie:e.toggleSerie?se:void 0}),"legend."+t)}))},Ee=sh(z,ue,L);return k&&(Se.areas=(0,Ne.jsx)(zw,{areaGenerator:ce,areaOpacity:S,areaBlendMode:E,lines:ue},"areas")),D&&!1!==Y&&(Se.slices=(0,Ne.jsx)(Ww,{slices:he,axis:Y,debug:G,height:ne,tooltip:X,current:_e,setCurrent:ke,onMouseEnter:q,onMouseMove:W,onMouseLeave:V,onClick:H},"slices")),C&&(Se.points=(0,Ne.jsx)(Hw,{points:pe,symbol:j,size:M,color:ge,borderWidth:T,borderColor:be,enableLabel:R,label:P,labelYOffset:N},"points")),D&&K&&(null!==ve&&(Se.crosshair=(0,Ne.jsx)(ga,{width:te,height:ne,x:ve.x,y:ve.y,type:Q},"crosshair")),null!==_e&&(Se.crosshair=(0,Ne.jsx)(ga,{width:te,height:ne,x:_e.x,y:_e.y,type:Y},"crosshair"))),D&&B&&!1===Y&&(Se.mesh=(0,Ne.jsx)(Yw,{points:pe,width:te,height:ne,margin:ee,current:ve,setCurrent:xe,onMouseEnter:q,onMouseMove:W,onMouseLeave:V,onClick:H,tooltip:$,debug:U},"mesh")),(0,Ne.jsx)(Yd,{defs:Ee,width:re,height:ie,margin:ee,role:J,children:s.map((function(t,n){return"function"==typeof t?(0,Ne.jsx)(r.Fragment,{children:t(vw({},e,{innerWidth:te,innerHeight:ne,series:ue,slices:he,points:pe,xScale:fe,yScale:de,lineGenerator:le,areaGenerator:ce,currentPoint:ve,setCurrentPoint:xe,currentSlice:_e,setCurrentSlice:ke}))},n):Se[t]}))})};Gw.propTypes=Ew,Gw.defaultProps=Mw;var Xw=rh(Gw),Kw=function(e){return(0,Ne.jsx)(Pd,{children:function(t){var n=t.width,r=t.height;return(0,Ne.jsx)(Xw,vw({width:n,height:r},e))}})},Qw=function(e){var t=e.width,n=e.height,i=e.margin,o=e.pixelRatio,a=e.data,s=e.xScale,l=e.xFormat,c=e.yScale,u=e.yFormat,f=e.curve,d=e.layers,h=e.colors,p=e.lineWidth,m=e.enableArea,g=e.areaBaselineValue,b=e.areaOpacity,y=e.enablePoints,v=e.pointSize,x=e.pointColor,w=e.pointBorderWidth,_=e.pointBorderColor,k=e.enableGridX,S=e.gridXValues,E=e.enableGridY,C=e.gridYValues,j=e.axisTop,M=e.axisRight,O=e.axisBottom,T=e.axisLeft,A=e.legends,R=e.isInteractive,P=e.debugMesh,N=e.onMouseLeave,z=e.onClick,L=e.tooltip,I=e.canvasRef,F=(0,r.useRef)(null),D=_d(t,n,i),B=D.margin,U=D.innerWidth,q=D.innerHeight,W=D.outerWidth,V=D.outerHeight,H=Od(),$=(0,r.useState)(null),Y=$[0],G=$[1],X=Rw({data:a,xScale:s,xFormat:l,yScale:c,yFormat:u,width:U,height:q,colors:h,curve:f,areaBaselineValue:g,pointColor:x,pointBorderColor:_}),K=X.lineGenerator,Q=X.areaGenerator,J=X.series,Z=X.xScale,ee=X.yScale,te=X.points,ne=bw({points:te,width:U,height:q,debug:P}),re=ne.delaunay,ie=ne.voronoi;(0,r.useEffect)((function(){I&&(I.current=F.current),F.current.width=W*o,F.current.height=V*o;var e=F.current.getContext("2d");e.scale(o,o),e.fillStyle=H.background,e.fillRect(0,0,W,V),e.translate(B.left,B.top),d.forEach((function(t){if("function"==typeof t&&t({ctx:e,innerWidth:U,innerHeight:q,series:J,points:te,xScale:Z,yScale:ee,lineWidth:p,lineGenerator:K,areaGenerator:Q,currentPoint:Y,setCurrentPoint:G}),"grid"===t&&H.grid.line.strokeWidth>0&&(e.lineWidth=H.grid.line.strokeWidth,e.strokeStyle=H.grid.line.stroke,k&&Sx(e,{width:U,height:q,scale:Z,axis:"x",values:S}),E&&Sx(e,{width:U,height:q,scale:ee,axis:"y",values:C})),"axes"===t&&kx(e,{xScale:Z,yScale:ee,width:U,height:q,top:j,right:M,bottom:O,left:T,theme:H}),"areas"===t&&!0===m&&(e.save(),e.globalAlpha=b,Q.context(e),J.forEach((function(t){e.fillStyle=t.color,e.beginPath(),Q(t.data.map((function(e){return e.position}))),e.fill()})),e.restore()),"lines"===t&&(K.context(e),J.forEach((function(t){e.strokeStyle=t.color,e.lineWidth=p,e.beginPath(),K(t.data.map((function(e){return e.position}))),e.stroke()}))),"points"===t&&!0===y&&v>0&&te.forEach((function(t){e.fillStyle=t.color,e.beginPath(),e.arc(t.x,t.y,v/2,0,2*Math.PI),e.fill(),w>0&&(e.strokeStyle=t.borderColor,e.lineWidth=w,e.stroke())})),"mesh"===t&&!0===P&&(function(e,t){e.save(),e.globalAlpha=.75,e.beginPath(),t.render(e),e.strokeStyle="red",e.lineWidth=1,e.stroke(),e.restore()}(e,ie),Y&&function(e,t,n){e.save(),e.globalAlpha=.35,e.beginPath(),t.renderCell(n,e),e.fillStyle="red",e.fill(),e.restore()}(e,ie,Y.index)),"legends"===t){var n=J.map((function(e){return{id:e.id,label:e.id,color:e.color}})).reverse();A.forEach((function(t){zx(e,vw({},t,{data:t.data||n,containerWidth:U,containerHeight:q,theme:H}))}))}}))}),[F,W,V,d,H,K,J,Z,ee,k,S,E,C,j,M,O,T,A,te,y,v,Y]);var oe=(0,r.useCallback)((function(e){var t=ih(F.current,e),n=t[0],r=t[1];if(!function(e,t,n,r,i,o){return e<=i&&i<=e+n&&t<=o&&o<=t+r}(B.left,B.top,U,q,n,r))return null;var i=re.find(n-B.left,r-B.top);return te[i]}),[F,B,U,q,re]),ae=wa(),se=ae.showTooltipFromEvent,le=ae.hideTooltip,ce=(0,r.useCallback)((function(e){var t=oe(e);G(t),t?se((0,r.createElement)(L,{point:t}),e):le()}),[oe,G,se,le,L]),ue=(0,r.useCallback)((function(e){le(),G(null),Y&&N&&N(Y,e)}),[le,G,N]),fe=(0,r.useCallback)((function(e){if(z){var t=oe(e);t&&z(t,e)}}),[oe,z]);return(0,Ne.jsx)("canvas",{ref:F,width:W*o,height:V*o,style:{width:W,height:V,cursor:R?"auto":"normal"},onMouseEnter:R?ce:void 0,onMouseMove:R?ce:void 0,onMouseLeave:R?ue:void 0,onClick:R?fe:void 0})};Qw.propTypes=Cw,Qw.defaultProps=Ow;var Jw=rh(Qw),Zw=(0,r.forwardRef)((function(e,t){return(0,Ne.jsx)(Jw,vw({},e,{canvasRef:t}))}));(0,r.forwardRef)((function(e,t){return(0,Ne.jsx)(Pd,{children:function(n){var r=n.width,i=n.height;return(0,Ne.jsx)(Zw,vw({width:r,height:i},e,{ref:t}))}})}));const e_={text:{fontSize:12,fill:"#333333",outlineWidth:0,outlineColor:"transparent"},axis:{domain:{line:{stroke:"#777777",strokeWidth:1}},legend:{text:{fontSize:15,fill:"#c4c4c4",outlineWidth:3,outlineColor:"transparent"}},ticks:{line:{stroke:"#777777",strokeWidth:1},text:{fontSize:13,fill:"#c4c4c4",outlineWidth:0,outlineColor:"transparent"}}},grid:{line:{stroke:"#c4c4c4",strokeWidth:.5}},legends:{title:{text:{fontSize:13,fill:"#c4c4c4",outlineWidth:0,outlineColor:"transparent"}},text:{fontSize:13,fill:"#c4c4c4",outlineWidth:0,outlineColor:"transparent"},ticks:{line:{},text:{fontSize:10,fill:"#333333",outlineWidth:0,outlineColor:"transparent"}}},annotations:{text:{fontSize:13,fill:"#333333",outlineWidth:2,outlineColor:"#ffffff",outlineOpacity:1},link:{stroke:"#000000",strokeWidth:1,outlineWidth:2,outlineColor:"#ffffff",outlineOpacity:1},outline:{stroke:"#000000",strokeWidth:2,outlineWidth:2,outlineColor:"#ffffff",outlineOpacity:1},symbol:{fill:"#000000",outlineWidth:2,outlineColor:"#ffffff",outlineOpacity:1}},tooltip:{container:{background:"#ffffff",color:"#333333",fontSize:12},basic:{},chip:{},table:{},tableCell:{},tableCellValue:{}}},t_=e=>{var t;let{chartData:n,chartMaxData:i}=e;const{mvtGraphNo:o}=(0,r.useContext)(lt),{theme:a}=(0,r.useContext)(Et),s=a?e_:{...e_,axis:{...e_.axis,legend:{text:{...e_.axis.legend.text,fill:"#2c2e2d"}},ticks:{...e_.axis.ticks,text:{...e_.axis.ticks.text,fill:"#2c2e2d"}}},legends:{...e_.legends,text:{...e_.legends.text,fill:"#2c2e2d"}},grid:{line:{...e_.grid.line,stroke:"#5d5e5e"}}};return(0,Ne.jsx)(Kw,{data:n[o],margin:{top:50,right:120,bottom:50,left:60},xScale:{type:"linear",min:"auto",max:null!==(t=i[o]+100)&&void 0!==t?t:"auto",stacked:!1,reverse:!1},yScale:{type:"linear",min:"auto",max:"auto",stacked:!1,reverse:!1},xFormat:" >-.2f",yFormat:" >-.2f",axisTop:null,axisRight:null,axisBottom:{tickSize:5,tickPadding:5,tickRotation:0,legend:"Time Since Replica Started Accepting Messages(10^-5 seconds)",legendOffset:36,legendPosition:"middle"},axisLeft:{tickSize:5,tickPadding:5,tickRotation:0,legend:"Number of Messages",legendOffset:-40,legendPosition:"middle"},enablePoints:!0,pointSize:5,pointColor:{theme:"background"},pointBorderWidth:2,pointBorderColor:{from:"serieColor"},pointLabelYOffset:-12,useMesh:!0,legends:[{anchor:"bottom-right",direction:"column",justify:!1,translateX:100,translateY:0,itemsSpacing:0,itemDirection:"left-to-right",itemWidth:80,itemHeight:20,itemOpacity:.75,symbolSize:12,symbolShape:"circle",symbolBorderColor:"rgba(0, 0, 0, .5)",effects:[{on:"hover",style:{itemBackground:"rgba(0, 0, 0, .03)",itemOpacity:1}}]}],theme:s})},n_={17:{1:{commit_message_timestamps:[0x179e900d7bb97300,0x179e900d7c011c00,0x179e900d7c44f300,0x179e900d7c44f700],commit_time:0x179e900d7c450f00,execution_time:0x179e900d7c477500,ip:"127.0.0.1",port:10001,prepare_message_timestamps:[0x179e900d7b5e5000,0x179e900d7ba98800,0x179e900d7baab700,0x179e900d7bb85300],prepare_time:0x179e900d7baad500,primary_id:1,propose_pre_prepare_time:0x179e900d7b431c00,replica_id:2,txn_commands:["GET"],txn_keys:["test"],txn_number:17,txn_values:[""],reply_time:1702001829632},2:{commit_message_timestamps:[0x179e900d7bbfea00,0x179e900d7bfb2c00,0x179e900d7c614200,0x179e900d7c616d00],commit_time:0x179e900d7c616500,execution_time:0x179e900d7c6d8a00,ip:"127.0.0.1",port:10002,prepare_message_timestamps:[0x179e900d7b614a00,0x179e900d7bb16400,0x179e900d7bbfc800],prepare_time:0x179e900d7bb1a900,primary_id:1,propose_pre_prepare_time:0x179e900d7b216c00,replica_id:1,txn_commands:["GET"],txn_keys:["test"],txn_number:17,txn_values:[""],reply_time:1702001829629},4:{commit_message_timestamps:[0x179e900d7bbbe700,0x179e900d7c009c00,0x179e900d7c456800,0x179e900d7c467000],commit_time:170195609678653e4,execution_time:0x179e900d7c4c5500,ip:"127.0.0.1",port:10004,prepare_message_timestamps:[0x179e900d7b6f4c00,0x179e900d7ba93d00,0x179e900d7baa7c00,0x179e900d7bbab700],prepare_time:0x179e900d7baa8b00,primary_id:1,propose_pre_prepare_time:0x179e900d7b1d5b00,replica_id:4,txn_commands:["GET"],txn_keys:["test"],txn_number:17,txn_values:[""],reply_time:1702001829630}},18:{1:{commit_message_timestamps:[0x179e900d7bb97300,0x179e900d7c011c00,0x179e900d7c44f300,0x179e900d7c44f700],commit_time:0x179e900d7c450f00,execution_time:0x179e900d7c477500,ip:"127.0.0.1",port:10001,prepare_message_timestamps:[0x179e900d7b5e5000,0x179e900d7ba98800,0x179e900d7baab700,0x179e900d7bb85300],prepare_time:0x179e900d7baad500,primary_id:1,propose_pre_prepare_time:0x179e900d7b431c00,replica_id:1,txn_commands:["GET"],txn_keys:["test"],txn_number:17,txn_values:[""],reply_time:1702001829632},2:{commit_message_timestamps:[0x179e900d7bbfea00,0x179e900d7bfb2c00,0x179e900d7c614200,0x179e900d7c616d00],commit_time:0x179e900d7c616500,execution_time:0x179e900d7c6d8a00,ip:"127.0.0.1",port:10002,prepare_message_timestamps:[0x179e900d7b614a00,0x179e900d7bb16400,0x179e900d7bbfc800],prepare_time:0x179e900d7bb1a900,primary_id:1,propose_pre_prepare_time:0x179e900d7b216c00,replica_id:2,txn_commands:["GET"],txn_keys:["test"],txn_number:17,txn_values:[""],reply_time:1702001829629},3:{commit_message_timestamps:[0x179e900d7bba2700,0x179e900d7bfbd500,0x179e900d7c583a00,0x179e900d7c5b2000],commit_time:0x179e900d7c586a00,execution_time:0x179e900d7c5f6600,ip:"127.0.0.1",port:10003,prepare_message_timestamps:[0x179e900d7b6ff500,0x179e900d7bb4d400,0x179e900d7bb51f00,0x179e900d7bb81b00],prepare_time:0x179e900d7bb53700,primary_id:1,propose_pre_prepare_time:0x179e900d7b1d5900,replica_id:3,txn_commands:["GET"],txn_keys:["test"],txn_number:17,txn_values:[""],reply_time:1702001829631},4:{commit_message_timestamps:[0x179e900d7bbbe700,0x179e900d7c009c00,0x179e900d7c456800,0x179e900d7c467000],commit_time:170195609678653e4,execution_time:0x179e900d7c4c5500,ip:"127.0.0.1",port:10004,prepare_message_timestamps:[0x179e900d7b6f4c00,0x179e900d7ba93d00,0x179e900d7baa7c00,0x179e900d7bbab700],prepare_time:0x179e900d7baa8b00,primary_id:1,propose_pre_prepare_time:0x179e900d7b1d5b00,replica_id:4,txn_commands:["GET"],txn_keys:["test"],txn_number:17,txn_values:[""],reply_time:1702001829630}}},r_={"Replica 1":!0,"Replica 2":!0,"Replica 3":!0,"Replica 4":!0},i_={"Replica 1":!1,"Replica 2":!1,"Replica 3":!1,"Replica 4":!1},o_=e=>{let{messageHistory:t,currentTransaction:n=17}=e;const{resizing:i}=(0,r.useContext)(st),{toggleMvtGraphNoChange:o}=(0,r.useContext)(lt),[a,s]=(0,r.useState)([]),[l,c]=(0,r.useState)({}),[u,f]=(0,r.useState)(r_),[d,h]=(0,r.useState)(i_),[p,m]=(0,r.useState)(0),[g,b]=(0,r.useState)(!1),y=()=>{let e=p;e+=1,m(e)},v=e=>c(e),x=e=>s(e);return(0,r.useEffect)((()=>{((e,t,n,r)=>{let i=0,o=0,a=[],s=[],l=[],c=[],u=[];Object.keys(e).forEach((t=>{u.push("Replica "+t),e[t].primary_id!==e[t].replica_id&&a.push(Math.floor(e[t].propose_pre_prepare_time/1e4)),s.push(Math.floor(e[t].prepare_time/1e4));let n=[],r=[];e[t].prepare_message_timestamps.map((e=>n.push(Math.floor(e/1e4)))),e[t].commit_message_timestamps.map((e=>r.push(Math.floor(e/1e4)))),l.push(n),c.push(r)})),i=Math.min(...a),o=Math.min(...s);let f=[],d=[],h=0,p=0;for(const v of l){let e=[{x:0,y:0}];for(let t=0;t0){const n=v[t]-i;e.push({x:n,y:t}),e.push({x:n,y:t+1}),h=Math.max(h,n)}else if(t+10){const n=v[t]-o;e.push({x:n,y:t}),e.push({x:n,y:t+1}),p=Math.max(p,n)}else if(t+1o(1),graphNo:1}),(0,Ne.jsx)(gt,{title:"Commit Messages",onClick:()=>o(2),graphNo:2})]}),(0,Ne.jsxs)(bn,{children:[(0,Ne.jsx)("div",{className:"relative w-full h-full pl-4 pr-2 pb-6",children:i||g?(0,Ne.jsxs)("div",{class:"loader",children:[(0,Ne.jsx)("div",{children:"MVT"}),(0,Ne.jsx)("div",{class:"inner"})]}):(0,Ne.jsx)(t_,{chartData:a,chartMaxData:l})}),(0,Ne.jsx)("div",{className:"absolute bottom-0 right-0 rotate-45",children:(0,Ne.jsx)(St,{path:it,fill:"gray",height:"0.8em"})})]}),(0,Ne.jsx)("div",{className:"mt-10 mb-4 flex items-center justify-center",children:(0,Ne.jsx)(vn,{toggleFaulty:e=>{h((t=>{const n={...t};return n[e]=!n[e],n}));(async e=>{console.log(e);try{let t=await fetch("http://localhost:1850"+String(e.charAt(e.length-1))+"/make_faulty");console.log(t.body())}catch(t){}})(e),y()},toggleLine:e=>{f((t=>{const n={...t};return n[e]=!n[e],n})),y()},labelToggleFaulty:d,labelToggle:u})})]})};function a_(){}function s_(e){return null==e?a_:function(){return this.querySelector(e)}}function l_(){return[]}function c_(e){return null==e?l_:function(){return this.querySelectorAll(e)}}function u_(e){return function(){return function(e){return null==e?[]:Array.isArray(e)?e:Array.from(e)}(e.apply(this,arguments))}}function f_(e){return function(){return this.matches(e)}}function d_(e){return function(t){return t.matches(e)}}var h_=Array.prototype.find;function p_(){return this.firstElementChild}var m_=Array.prototype.filter;function g_(){return Array.from(this.children)}function b_(e){return new Array(e.length)}function y_(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function v_(e,t,n,r,i,o){for(var a,s=0,l=t.length,c=o.length;st?1:e>=t?0:NaN}y_.prototype={constructor:y_,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};var S_="http://www.w3.org/1999/xhtml";const E_={svg:"http://www.w3.org/2000/svg",xhtml:S_,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function C_(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),E_.hasOwnProperty(t)?{space:E_[t],local:e}:e}function j_(e){return function(){this.removeAttribute(e)}}function M_(e){return function(){this.removeAttributeNS(e.space,e.local)}}function O_(e,t){return function(){this.setAttribute(e,t)}}function T_(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function A_(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function R_(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function P_(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function N_(e){return function(){this.style.removeProperty(e)}}function z_(e,t,n){return function(){this.style.setProperty(e,t,n)}}function L_(e,t,n){return function(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function I_(e,t){return e.style.getPropertyValue(t)||P_(e).getComputedStyle(e,null).getPropertyValue(t)}function F_(e){return function(){delete this[e]}}function D_(e,t){return function(){this[e]=t}}function B_(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function U_(e){return e.trim().split(/^|\s+/)}function q_(e){return e.classList||new W_(e)}function W_(e){this._node=e,this._names=U_(e.getAttribute("class")||"")}function V_(e,t){for(var n=q_(e),r=-1,i=t.length;++r=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var mk=[null];function gk(e,t){this._groups=e,this._parents=t}function bk(){return new gk([[document.documentElement]],mk)}gk.prototype=bk.prototype={constructor:gk,select:function(e){"function"!==typeof e&&(e=s_(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=x&&(x=v+1);!(y=g[x])&&++x=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=k_);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o1?this.each((null==t?N_:"function"===typeof t?L_:z_)(e,t,null==n?"":n)):I_(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?F_:"function"===typeof t?B_:D_)(e,t)):this.node()[e]},classed:function(e,t){var n=U_(e+"");if(arguments.length<2){for(var r=q_(this.node()),i=-1,o=n.length;++i=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}(e+""),a=o.length;if(!(arguments.length<2)){for(s=t?fk:uk,r=0;r