radiant-charts-core 0.2.0

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.mjs ADDED
@@ -0,0 +1,9 @@
1
+ import W,{useRef as _t,useEffect as Rt,useLayoutEffect as re,useState as Pt,useMemo as Gt,useImperativeHandle as ae,forwardRef as oe}from"react";var H=class{constructor(){this.id=Math.random().toString(36).substr(2,9);this.x=0;this.y=0;this.visible=!0;this.opacity=1;this.translation={x:0,y:0};this.rotation=0;this.scaling={x:1,y:1};this.parent=null;this.children=[];this.pointerEvents=!0;this.clipRect=null;this.datum=null;this.seriesId="";this.shadow=null}add(t){t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t)}remove(t){let e=this.children.indexOf(t);e!==-1&&(this.children.splice(e,1),t.parent=null)}clear(){this.children.forEach(t=>t.parent=null),this.children=[]}render(t){if(!this.visible||this.opacity===0)return;let e=this.translation.x!==0||this.translation.y!==0||this.rotation!==0||this.scaling.x!==1||this.scaling.y!==1,i=this.shadow!==null,s=this.opacity!==1||this.clipRect!==null||i;if(!e&&!s){this.renderShape(t);for(let n of this.children)n.render(t);return}t.save(),(this.translation.x!==0||this.translation.y!==0)&&t.translate(this.translation.x,this.translation.y),this.rotation!==0&&t.rotate(this.rotation),(this.scaling.x!==1||this.scaling.y!==1)&&t.scale(this.scaling.x,this.scaling.y),this.opacity!==1&&(t.globalAlpha*=this.opacity),this.clipRect&&(t.beginPath(),t.rect(this.clipRect.x,this.clipRect.y,this.clipRect.width,this.clipRect.height),t.clip()),this.shadow&&(t.shadowColor=this.shadow.color??"rgba(0,0,0,0.25)",t.shadowBlur=this.shadow.blur??4,t.shadowOffsetX=this.shadow.offsetX??0,t.shadowOffsetY=this.shadow.offsetY??2),this.renderShape(t),this.shadow&&(t.shadowColor="rgba(0,0,0,0)",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0);for(let n of this.children)n.render(t);t.restore()}pickNode(t,e){if(!this.visible||!this.pointerEvents)return null;let i=(t-this.translation.x)/this.scaling.x,s=(e-this.translation.y)/this.scaling.y;for(let n=this.children.length-1;n>=0;n--){let r=this.children[n].pickNode(i,s);if(r)return r}return this.isPointInNode(i,s)?this:null}};var B=class extends H{renderShape(t){}isPointInNode(t,e){return!1}getBBox(){if(this.children.length===0)return{x:0,y:0,width:0,height:0};let t=1/0,e=1/0,i=-1/0,s=-1/0;for(let n of this.children){let r=n.getBBox();t=Math.min(t,r.x+n.translation.x),e=Math.min(e,r.y+n.translation.y),i=Math.max(i,r.x+r.width+n.translation.x),s=Math.max(s,r.y+r.height+n.translation.y)}return{x:t,y:e,width:i-t,height:s-e}}},Q=class extends H{constructor(){super(...arguments);this.width=0;this.height=0;this.fill="transparent";this.stroke="transparent";this.strokeWidth=1;this.cornerRadius=0;this.lineDash=[]}renderShape(e){if(!(this.width<=0||this.height<=0)){if(e.beginPath(),this.cornerRadius>0){let i=Math.min(this.cornerRadius,this.width/2,this.height/2);e.moveTo(this.x+i,this.y),e.arcTo(this.x+this.width,this.y,this.x+this.width,this.y+this.height,i),e.arcTo(this.x+this.width,this.y+this.height,this.x,this.y+this.height,i),e.arcTo(this.x,this.y+this.height,this.x,this.y,i),e.arcTo(this.x,this.y,this.x+this.width,this.y,i)}else e.rect(this.x,this.y,this.width,this.height);e.closePath(),this.fill!=="transparent"&&(e.fillStyle=this.fill,e.fill()),this.stroke!=="transparent"&&this.strokeWidth>0&&(e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,this.lineDash.length>0&&e.setLineDash(this.lineDash),e.stroke(),this.lineDash.length>0&&e.setLineDash([]))}}isPointInNode(e,i){let s=Math.min(this.x,this.x+this.width),n=Math.max(this.x,this.x+this.width),r=Math.min(this.y,this.y+this.height),o=Math.max(this.y,this.y+this.height);return e>=s&&e<=n&&i>=r&&i<=o}getBBox(){return{x:this.x,y:this.y,width:this.width,height:this.height}}},q=class extends H{constructor(){super(...arguments);this.x1=0;this.y1=0;this.x2=0;this.y2=0;this.stroke="black";this.strokeWidth=1}renderShape(e){e.save(),this.lineDash&&e.setLineDash(this.lineDash),e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,e.beginPath(),e.moveTo(this.x1,this.y1),e.lineTo(this.x2,this.y2),e.stroke(),e.restore()}isPointInNode(e,i){return!1}getBBox(){return{x:Math.min(this.x1,this.x2),y:Math.min(this.y1,this.y2),width:Math.abs(this.x2-this.x1),height:Math.abs(this.y2-this.y1)}}},ht=class extends H{constructor(){super(...arguments);this.centerX=0;this.centerY=0;this.radius=5;this.fill="blue";this.stroke="transparent";this.strokeWidth=1}renderShape(e){e.beginPath(),e.arc(this.centerX,this.centerY,this.radius,0,Math.PI*2),e.closePath(),this.fill!=="transparent"&&(e.fillStyle=this.fill,e.fill()),this.stroke!=="transparent"&&this.strokeWidth>0&&(e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,e.stroke())}isPointInNode(e,i){let s=e-this.centerX,n=i-this.centerY;return s*s+n*n<=this.radius*this.radius}getBBox(){return{x:this.centerX-this.radius,y:this.centerY-this.radius,width:this.radius*2,height:this.radius*2}}},rt=class extends H{constructor(){super(...arguments);this.pathData=[];this.fill="transparent";this.stroke="transparent";this.strokeWidth=1;this.closed=!1;this.lineDashOffset=0}renderShape(e){if(this.pathData.length!==0){e.save(),this.lineDash&&(e.setLineDash(this.lineDash),e.lineDashOffset=this.lineDashOffset),e.beginPath();for(let i of this.pathData)i.command==="M"?e.moveTo(i.x,i.y):i.command==="L"?e.lineTo(i.x,i.y):i.command==="C"&&i.cp1x!==void 0&&i.cp2x!==void 0&&e.bezierCurveTo(i.cp1x,i.cp1y,i.cp2x,i.cp2y,i.x,i.y);this.closed&&e.closePath(),this.fill!=="transparent"&&(e.fillStyle=this.fill,e.fill()),this.stroke!=="transparent"&&this.strokeWidth>0&&(e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,e.stroke()),e.restore()}}isPointInNode(e,i){return!1}getBBox(){if(this.pathData.length===0)return{x:0,y:0,width:0,height:0};let e=1/0,i=1/0,s=-1/0,n=-1/0;for(let r of this.pathData)e=Math.min(e,r.x),i=Math.min(i,r.y),s=Math.max(s,r.x),n=Math.max(n,r.y),r.cp1x!==void 0&&(e=Math.min(e,r.cp1x,r.cp2x),i=Math.min(i,r.cp1y,r.cp2y),s=Math.max(s,r.cp1x,r.cp2x),n=Math.max(n,r.cp1y,r.cp2y));return{x:e,y:i,width:s-e,height:n-i}}},tt=class extends H{constructor(){super(...arguments);this.centerX=0;this.centerY=0;this.radius=5;this.fill="blue";this.stroke="transparent";this.strokeWidth=1;this.shape="circle"}renderShape(e){let i=this.centerX,s=this.centerY,n=this.radius;if(!(n<=0)){switch(e.beginPath(),this.shape){case"circle":e.arc(i,s,n,0,Math.PI*2),e.closePath();break;case"square":e.rect(i-n,s-n,n*2,n*2),e.closePath();break;case"diamond":e.moveTo(i,s-n),e.lineTo(i+n,s),e.lineTo(i,s+n),e.lineTo(i-n,s),e.closePath();break;case"triangle":e.moveTo(i,s-n),e.lineTo(i+n*.866,s+n*.5),e.lineTo(i-n*.866,s+n*.5),e.closePath();break;case"cross":{let r=n*.4;e.moveTo(i-n,s-n+r),e.lineTo(i-n+r,s-n),e.lineTo(i,s-r),e.lineTo(i+n-r,s-n),e.lineTo(i+n,s-n+r),e.lineTo(i+r,s),e.lineTo(i+n,s+n-r),e.lineTo(i+n-r,s+n),e.lineTo(i,s+r),e.lineTo(i-n+r,s+n),e.lineTo(i-n,s+n-r),e.lineTo(i-r,s),e.closePath();break}case"plus":{let r=n*.4;e.moveTo(i-r,s-n),e.lineTo(i+r,s-n),e.lineTo(i+r,s-r),e.lineTo(i+n,s-r),e.lineTo(i+n,s+r),e.lineTo(i+r,s+r),e.lineTo(i+r,s+n),e.lineTo(i-r,s+n),e.lineTo(i-r,s+r),e.lineTo(i-n,s+r),e.lineTo(i-n,s-r),e.lineTo(i-r,s-r),e.closePath();break}}this.fill!=="transparent"&&(e.fillStyle=this.fill,e.fill()),this.stroke!=="transparent"&&this.strokeWidth>0&&(e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,e.stroke())}}isPointInNode(e,i){let s=e-this.centerX,n=i-this.centerY;return Math.abs(s)<=this.radius&&Math.abs(n)<=this.radius}getBBox(){return{x:this.centerX-this.radius,y:this.centerY-this.radius,width:this.radius*2,height:this.radius*2}}},bt=class extends H{constructor(){super(...arguments);this.centerX=0;this.centerY=0;this.innerRadius=0;this.outerRadius=0;this.startAngle=0;this.endAngle=0;this.fill="blue";this.stroke="transparent";this.strokeWidth=1}renderShape(e){e.beginPath(),e.arc(this.centerX,this.centerY,this.outerRadius,this.startAngle,this.endAngle),this.innerRadius>0?e.arc(this.centerX,this.centerY,this.innerRadius,this.endAngle,this.startAngle,!0):e.lineTo(this.centerX,this.centerY),e.closePath(),this.fill!=="transparent"&&(e.fillStyle=this.fill,e.fill()),this.stroke!=="transparent"&&this.strokeWidth>0&&(e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,e.stroke())}isPointInNode(e,i){let s=e-this.centerX,n=i-this.centerY,r=Math.sqrt(s*s+n*n);if(r<this.innerRadius||r>this.outerRadius)return!1;let o=Math.atan2(n,s);o<0&&(o+=Math.PI*2);let l=this.startAngle%(Math.PI*2);l<0&&(l+=Math.PI*2);let y=this.endAngle%(Math.PI*2);return y<0&&(y+=Math.PI*2),l<y?o>=l&&o<=y:o>=l||o<=y}getBBox(){return{x:this.centerX-this.outerRadius,y:this.centerY-this.outerRadius,width:this.outerRadius*2,height:this.outerRadius*2}}},K=class extends H{constructor(){super(...arguments);this.text="";this.fontSize=12;this.fontFamily="sans-serif";this.fontWeight="normal";this.fill="black";this.textAlign="start";this.textBaseline="alphabetic"}renderShape(e){e.font=`${this.fontWeight} ${this.fontSize}px ${this.fontFamily}`,e.fillStyle=this.fill,e.textAlign=this.textAlign,e.textBaseline=this.textBaseline,this.shadowColor&&(e.shadowColor=this.shadowColor),this.shadowBlur!==void 0&&(e.shadowBlur=this.shadowBlur),this.maxWidth!==void 0&&this.maxWidth>0?e.fillText(this.text,this.x,this.y,this.maxWidth):e.fillText(this.text,this.x,this.y),this.shadowColor&&(e.shadowColor="transparent"),this.shadowBlur!==void 0&&(e.shadowBlur=0)}isPointInNode(e,i){return!1}getBBox(){return{x:this.x,y:this.y-this.fontSize,width:this.text.length*(this.fontSize*.55),height:this.fontSize}}};var xt=class{constructor(t){this.root=new B;this.width=0;this.height=0;this.pixelRatio=1;this._longPressTimer=null;this._longPressFired=!1;this.backgroundColor="";this.container=t,this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.top="0",this.canvas.style.left="0",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.display="block",this.canvas.style.zIndex="1",t.appendChild(this.canvas);let e=this.canvas.getContext("2d");if(!e)throw new Error("Could not get Canvas 2D context");this.ctx=e,this.resize(),this.setupEvents()}setupEvents(){this.canvas.addEventListener("mousemove",t=>{let e=this.canvas.getBoundingClientRect(),i=t.clientX-e.left,s=t.clientY-e.top,n=this.root.pickNode(i,s);this.onHover&&this.onHover(n,t)}),this.canvas.addEventListener("mouseleave",t=>{this.onHover&&this.onHover(null,t)}),this.canvas.addEventListener("click",t=>{let e=this.canvas.getBoundingClientRect(),i=t.clientX-e.left,s=t.clientY-e.top,n=this.root.pickNode(i,s);this.onClick&&this.onClick(n,t)}),this.canvas.addEventListener("dblclick",t=>{let e=this.canvas.getBoundingClientRect(),i=t.clientX-e.left,s=t.clientY-e.top,n=this.root.pickNode(i,s);this.onDblClick&&this.onDblClick(n,t)}),this.canvas.addEventListener("touchstart",t=>{if(t.touches.length!==1)return;let e=t.touches[0],i=this.canvas.getBoundingClientRect(),s=e.clientX-i.left,n=e.clientY-i.top,r=this.root.pickNode(s,n),o=new MouseEvent("mousemove",{clientX:e.clientX,clientY:e.clientY});this.onHover&&this.onHover(r,o),this._longPressFired=!1,this._longPressTimer&&clearTimeout(this._longPressTimer),this._longPressTimer=setTimeout(()=>{this._longPressFired=!0;let l=new MouseEvent("click",{clientX:e.clientX,clientY:e.clientY});this.onLongPress&&this.onLongPress(r,l)},500)},{passive:!0}),this.canvas.addEventListener("touchend",t=>{if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),t.changedTouches.length!==1)return;if(this._longPressFired){this._longPressFired=!1;return}let e=t.changedTouches[0],i=this.canvas.getBoundingClientRect(),s=e.clientX-i.left,n=e.clientY-i.top,r=this.root.pickNode(s,n),o=new MouseEvent("click",{clientX:e.clientX,clientY:e.clientY});this.onClick&&this.onClick(r,o)},{passive:!0}),this.canvas.addEventListener("touchmove",t=>{if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),t.touches.length!==1)return;let e=t.touches[0],i=this.canvas.getBoundingClientRect(),s=e.clientX-i.left,n=e.clientY-i.top,r=this.root.pickNode(s,n),o=new MouseEvent("mousemove",{clientX:e.clientX,clientY:e.clientY});this.onHover&&this.onHover(r,o)},{passive:!0})}resize(){let t=this.container.getBoundingClientRect();this.width=t.width,this.height=t.height,!(this.width===0||this.height===0)&&(this.pixelRatio=window.devicePixelRatio||1,this.canvas.width=this.width*this.pixelRatio,this.canvas.height=this.height*this.pixelRatio,this.ctx.resetTransform(),this.ctx.scale(this.pixelRatio,this.pixelRatio),this.render())}render(){this.width===0||this.height===0||(this.ctx.clearRect(0,0,this.width,this.height),this.backgroundColor&&(this.ctx.fillStyle=this.backgroundColor,this.ctx.fillRect(0,0,this.width,this.height)),this.root.render(this.ctx))}getCanvas(){return this.canvas}getContext(){return this.ctx}destroy(){this._longPressTimer&&clearTimeout(this._longPressTimer),this.canvas.remove()}};var et=class{constructor(){this.domain=[0,1];this.range=[0,1]}convert(t){let[e,i]=this.domain,[s,n]=this.range;return i===e?s:s+(t-e)/(i-e)*(n-s)}invert(t){let[e,i]=this.domain,[s,n]=this.range;return n===s?e:e+(t-s)/(n-s)*(i-e)}ticks(t=5){let[e,i]=this.domain,s=(i-e)/t,n=Math.pow(10,Math.floor(Math.log10(s))),r=s/n,o;r<1.5?o=1:r<3?o=2:r<7?o=5:o=10;let l=o*n,y=Math.ceil(e/l)*l,c=Math.floor(i/l)*l,x=[];for(let d=y;d<=c;d+=l)x.push(d);return x}},it=class{constructor(){this.domain=[];this.range=[0,1];this.padding=.1}convert(t){let e=this.domain.indexOf(t);if(e===-1)return 0;let[i,s]=this.range,n=(s-i)/this.domain.length;return i+e*n+n*this.padding/2}invert(t){let[e,i]=this.range,s=(i-e)/this.domain.length,n=Math.floor((t-e)/s);return this.domain[n]||""}getBandwidth(){let[t,e]=this.range,i=(e-t)/this.domain.length;return Math.abs(i*(1-this.padding))}ticks(){return this.domain}};function j(m){return typeof m.getBandwidth=="function"?m.getBandwidth():0}function J(m){if(m instanceof Date)return`${m.getMonth()+1}/${m.getDate()}/${String(m.getFullYear()).slice(-2)}`;if(typeof m!="number")return String(m);let t=Math.abs(m);if(t>1e11&&t<1e14){let e=new Date(m);if(!isNaN(e.getTime()))return`${e.getMonth()+1}/${e.getDate()}/${String(e.getFullYear()).slice(-2)}`}return t>=1e9?(m/1e9).toFixed(1).replace(/\.0$/,"")+"B":t>=1e6?(m/1e6).toFixed(1).replace(/\.0$/,"")+"M":t>=1e3?(m/1e3).toFixed(1).replace(/\.0$/,"")+"K":m%1!==0?t>0&&t<1?Number(m.toPrecision(3)).toString():m.toFixed(1):String(m)}var st=class{constructor(t,e){this.group=new B;this.theme=null;this._measuredLabelMaxW=0;this._layoutMaxWidth=0;this.scale=t,this.options=e}setLayoutMaxWidth(t){this._layoutMaxWidth=t}getGroup(){return this.group}setTheme(t){this.theme=t}updateOptions(t){this.options={...this.options,...t}}getRequiredSpace(t){let{position:e,rotation:i=0}=this.options,s=this.options.fontFamily||this.theme?.fontFamily||"sans-serif",n=this.options.fontSize??10,r=this.options.tickLength??4,o=this.options.labelGap??2,l=this._tickCount,y=this._labelFormatter,c=this.scale.ticks?this.scale.ticks(l):[];t.font=`${n}px ${s}`;let x=i*Math.PI/180,d=Math.abs(Math.cos(x)),p=Math.abs(Math.sin(x));if(e==="bottom"||e==="top"){let b=n;if(i!==0)for(let u=0;u<c.length;u++){let S=c[u],w=y?y({value:S,index:u}):J(S),g=t.measureText(w).width*p+n*d;g>b&&(b=g)}let k=r+o+b+4;return this.options.title&&(k+=18),{size:Math.ceil(k)}}let a=0;for(let b=0;b<c.length;b++){let k=c[b],u=y?y({value:k,index:b}):J(k),S=t.measureText(u).width,w=i!==0?S*d+n*p:S;w>a&&(a=w)}this._measuredLabelMaxW=Math.ceil(a);let f=o+this._measuredLabelMaxW+8;return this.options.title&&(f+=22),c.length>0&&(f=Math.max(f,32)),{size:Math.ceil(f)}}update(t,e=0,i=!0,s=0,n=0){this.group.clear();let{position:r,rotation:o=0}=this.options,l=this.theme?.subtextColor??"#6b7280",y=this.theme?.gridColor??"rgba(107,114,128,0.12)",c=this.theme?.axisColor??"#d1d5db",x=this.options.fontFamily||this.theme?.fontFamily||"sans-serif",d=this.options.fontSize??10,p=this.options.tickLength??4,a=this.options.labelGap??2;if(r==="bottom"||r==="top"?this.scale.range=[s,t-s]:this.scale.range=[t-s,s],!i)return;if(r==="bottom"||r==="top"){let v=new q;v.x1=0,v.y1=0,v.x2=t,v.y2=0,v.stroke=c,v.strokeWidth=1,this.group.add(v)}let f=this._tickCount,b=this._labelFormatter,k=this._gridStyle,u=this.scale.ticks?this.scale.ticks(f):[],S=this.options.gridLines!==!1,{labelAlignment:w="center"}=this.options,h=this.scale.getBandwidth?.bind(this.scale),g=r==="bottom"||r==="top",C=r==="left"||r==="right",A=d*.5,R=g?-1/0:1/0;if(u.forEach((v,_)=>{let Y=this.scale.convert(v);if(h){let L=h(),[z,O]=this.scale.range,F=O>=z?1:-1;w==="center"?Y+=F*L/2:w==="end"&&(Y+=F*L)}let P=b?b({value:v,index:_}):J(v);if(g&&o===0){let L=d*.6*P.length;if(Y-L/2<R+A){if(r==="bottom"){let O=new q;O.x1=Y,O.y1=0,O.x2=Y,O.y2=p,O.stroke=c,O.strokeWidth=1,this.group.add(O)}return}R=Y+L/2}if(C){if(Math.abs(Y-R)<d+2)return;R=Y}let T=new K;T.text=P,T.fontSize=d,T.fill=l,T.fontFamily=x;let M=o*Math.PI/180;if(T.rotation=M,r==="bottom"){let L=new q;L.x1=Y,L.y1=0,L.x2=Y,L.y2=p,L.stroke=c,L.strokeWidth=1,this.group.add(L),T.translation={x:Y,y:p+a},T.x=0,T.y=0,o===0?(T.textAlign="center",T.textBaseline="top"):(T.textAlign=o>0?"left":"right",T.textBaseline="middle"),this.group.add(T)}else if(r==="left"||r==="right"){let L=r==="right",z=L?1:-1;if(T.textAlign=L?"left":"right",T.textBaseline="middle",T.maxWidth=this._layoutMaxWidth>0?this._layoutMaxWidth-a-8:void 0,T.translation={x:z*a,y:Y},T.x=0,T.y=0,this.group.add(T),S&&e>0&&r==="left"){let O=new q;O.x1=n,O.y1=Y,O.x2=e,O.y2=Y;let F=k&&k.length>0?k[_%k.length]:void 0;O.stroke=F?.stroke??y,O.strokeWidth=1,O.lineDash=F?.lineDash?[...F.lineDash]:[4,6],this.group.add(O)}}}),this.options.title){let v=new K;v.text=this.options.title,v.fontSize=11,v.fill=l,v.fontFamily=x,r==="bottom"?(v.x=t/2,v.y=p+a+this._measuredLabelMaxW+12,v.textAlign="center"):r==="left"?(v.x=-(a+(this._layoutMaxWidth||this._measuredLabelMaxW)+14),v.y=t/2,v.rotation=-Math.PI/2,v.textAlign="center"):r==="right"&&(v.x=a+(this._layoutMaxWidth||this._measuredLabelMaxW)+14,v.y=t/2,v.rotation=Math.PI/2,v.textAlign="center"),this.group.add(v)}}};function te(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}var D=class D{constructor(t){this.startTime=0;this.requestId=null;this.loop=()=>{let t=performance.now(),e=Math.min((t-this.startTime)/this.duration,1);this.onUpdate(this.easing(e)),e<1?this.requestId=requestAnimationFrame(this.loop):(this.requestId=null,this.onComplete?.())};this.duration=t.duration??420,this.easing=t.easing??D.easeOutQuart,this.onUpdate=t.onUpdate,this.onComplete=t.onComplete}static getEasing(t){switch(t){case"linear":return D.linear;case"easeIn":return D.easeInQuad;case"easeOut":return D.easeOutQuad;case"easeInOut":return D.easeInOutQuad;case"easeInCubic":return D.easeInCubic;case"easeOutCubic":return D.easeOutCubic;case"easeInOutCubic":return D.easeInOutCubic;case"easeInQuart":return D.easeInQuart;case"easeOutQuart":return D.easeOutQuart;case"easeInOutQuart":return D.easeInOutQuart;case"bounce":return D.easeOutBounce;case"elastic":return D.easeOutElastic;case"back":return D.easeOutBack;default:return D.easeOutQuart}}start(){if(this.stop(),te()){this.onUpdate(1),this.onComplete?.();return}this.startTime=performance.now(),this.loop()}stop(){this.requestId!==null&&(cancelAnimationFrame(this.requestId),this.requestId=null)}};D.linear=t=>t,D.easeInQuad=t=>t*t,D.easeOutQuad=t=>t*(2-t),D.easeInOutQuad=t=>t<.5?2*t*t:-1+(4-2*t)*t,D.easeInCubic=t=>t*t*t,D.easeOutCubic=t=>--t*t*t+1,D.easeInOutCubic=t=>t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1,D.easeInQuart=t=>t*t*t*t,D.easeOutQuart=t=>1- --t*t*t*t,D.easeInOutQuart=t=>t<.5?8*t*t*t*t:1-8*--t*t*t*t,D.easeOutBack=t=>1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2),D.easeOutBounce=t=>t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,D.easeOutElastic=t=>{let e=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*e)+1};var X=D;var Ot=class extends H{constructor(){super(...arguments);this.bars=[];this.fill="";this.stroke="transparent";this.cornerRadius=0}renderShape(e){if(this.bars.length!==0){e.fillStyle=this.fill,e.beginPath();for(let i of this.bars)if(this.cornerRadius>0&&i.width>8&&i.height>8){let s=Math.min(this.cornerRadius,i.width/2,i.height/2);e.moveTo(i.x+s,i.y),e.arcTo(i.x+i.width,i.y,i.x+i.width,i.y+i.height,s),e.arcTo(i.x+i.width,i.y+i.height,i.x,i.y+i.height,s),e.arcTo(i.x,i.y+i.height,i.x,i.y,s),e.arcTo(i.x,i.y,i.x+i.width,i.y,s)}else e.rect(i.x,i.y,i.width,i.height);e.fill(),this.stroke!=="transparent"&&(e.strokeStyle=this.stroke,e.stroke())}}isPointInNode(e,i){for(let s=this.bars.length-1;s>=0;s--){let n=this.bars[s];if(e>=n.x&&e<=n.x+n.width&&i>=n.y&&i<=n.y+n.height)return this.datum=n.datum,!0}return!1}getBBox(){return this.bars.length===0?{x:0,y:0,width:0,height:0}:{x:0,y:0,width:1e3,height:1e3}}},pt=class{constructor(t){this.group=new B;this.fill="#4e79a7";this.stroke="transparent";this.grouped=!1;this.stacked=!1;this.normalized=!1;this.direction="vertical";this.cornerRadius=3;this.batchNode=null;this.bars=[];this.xKey=t.xKey,this.yKey=t.yKey,this.grouped=t.grouped??!1,this.stacked=t.stacked??!1,this.normalized=t.normalized??!1,this.direction=t.direction??"vertical",this.cornerRadius=t.cornerRadius??3,this.labelsOpts=t.labels,this.animationOpts=t.animation,this.shadowOpts=t.shadow,t.fill&&(this.fill=t.fill),t.stroke&&(this.stroke=t.stroke)}getGroup(){return this.group}update(t,e,i,s,n=!0,r=0,o=1,l,y,c){c&&(this.xKey=c.xKey,this.yKey=c.yKey,c.fill&&(this.fill=c.fill),c.stroke&&(this.stroke=c.stroke),c.grouped!==void 0&&(this.grouped=c.grouped),c.stacked!==void 0&&(this.stacked=c.stacked),c.normalized!==void 0&&(this.normalized=c.normalized),c.direction!==void 0&&(this.direction=c.direction),c.cornerRadius!==void 0&&(this.cornerRadius=c.cornerRadius),c.labels&&(this.labelsOpts=c.labels),c.animation&&(this.animationOpts=c.animation),c.shadow!==void 0&&(this.shadowOpts=c.shadow));let x=this.bars.length===0,d=this.direction==="horizontal",p=this.animationOpts?.type||"grow",a=this.bars.length,f=t.length;if(f>1e3){this.group.clear(),this.bars=[],this.batchNode||(this.batchNode=new Ot),this.batchNode.fill=this.fill,this.batchNode.stroke=this.stroke,this.batchNode.cornerRadius=this.cornerRadius,this.batchNode.seriesId=this.yKey,this.batchNode.shadow=this.shadowOpts??null,this.group.add(this.batchNode);let u=[];if(t.forEach((S,w)=>{let h=S[this.yKey];this.normalized&&y&&y[w]&&(h=h/y[w]*100);let g=j(e);if(d){let C=e.convert(S[this.xKey]),A=g;this.grouped&&o>1&&(A=g/o,C+=r*A);let R=i.convert(this.stacked&&l?l[w]??0:0),v=i.convert((this.stacked&&l?l[w]??0:0)+h)-R;u.push({x:R,y:C,width:v,height:A,datum:S})}else{let C=e.convert(S[this.xKey]),A=g;this.grouped&&o>1&&(A=g/o,C+=r*A);let R=i.convert((this.stacked&&l?l[w]??0:0)+h),v=i.convert(this.stacked&&l?l[w]??0:0)-R;u.push({x:C,y:R,width:A,height:v,datum:S})}}),this.batchNode.bars=u,this.labelsOpts?.enabled){let S=Math.max(1,Math.ceil(f/100));for(let w=0;w<u.length;w+=S){let h=u[w],g=new Q;g.x=h.x,g.y=h.y,g.width=h.width,g.height=h.height;let C=new K;this.group.add(C),this.placeLabel(C,g,h.datum[this.yKey])}}return}this.batchNode&&(this.group.remove(this.batchNode),this.batchNode=null);let k=[];if(t.forEach((u,S)=>{let w=u[this.yKey];this.normalized&&y&&y[S]&&(w=w/y[S]*100);let h=j(e),g,C,A,R;if(d){let v=e.convert(u[this.xKey]),_=h;if(this.grouped&&o>1&&(_=h/o,v+=r*_),C=v,R=_,this.stacked&&l){let Y=l[S]??0;g=i.convert(Y),A=i.convert(Y+w)-g}else g=i.convert(0),A=i.convert(w)-g}else{let v=e.convert(u[this.xKey]),_=h;if(this.grouped&&o>1&&(_=h/o,v+=r*_),g=v,A=_,this.stacked&&l){let Y=l[S]??0,P=this.normalized&&y?.[S]?Y/y[S]*100:Y;C=i.convert(P+w),R=i.convert(P)-C}else C=i.convert(w),R=i.convert(0)-C}k.push({datum:u,rawY:u[this.yKey],tx:g,ty:C,tw:A,th:R})}),f<a){for(let u=f;u<a;u++){let S=this.bars[u];this.group.remove(S.rect),S.label&&this.group.remove(S.label)}this.bars.length=f}for(let u=0;u<f;u++){let{datum:S,rawY:w,tx:h,ty:g,tw:C,th:A}=k[u],R,v,_,Y,P,T,M=1,L=1,z=1,O=1,F=1,nt=1;if(u<a){let G=this.bars[u];R=G.rect,v=G.label,_=R.x,Y=R.y,P=R.width,T=R.height,M=R.opacity,z=R.scaling.x,F=R.scaling.y}else R=new Q,this.group.add(R),_=h,Y=g,P=C,T=A,p==="grow"?d?(_=0,P=0):(Y=s.height,T=0):p==="fade"?M=0:p==="slide"?d?_=-50:Y=s.height+50:p==="pop"&&(z=0,F=0),this.labelsOpts?.enabled&&(v=new K,this.group.add(v));R.fill=this.fill,R.stroke=this.stroke,R.cornerRadius=this.cornerRadius,R.datum=S,R.seriesId=this.yKey,R.opacity=M,R.scaling={x:z,y:F},R.shadow=this.shadowOpts??null;let U=h,V=g;p==="pop"?(R.translation={x:h+C/2,y:g+A/2},U=-C/2,V=-A/2,_=-C/2,Y=-A/2):R.translation={x:0,y:0};let $={rect:R,label:v,rawY:w,targetY:V,targetHeight:A,startY:Y,startHeight:T,targetX:U,targetWidth:C,startX:_,startWidth:P,targetOpacity:L,startOpacity:M,targetScaleX:O,startScaleX:z,targetScaleY:nt,startScaleY:F};u<a?this.bars[u]=$:this.bars.push($)}if(n&&this.animationOpts?.enabled!==!1){this.animator?.stop();let u=this.animationOpts?.duration??500,S=X.getEasing(this.animationOpts?.easing);this.animator=new X({duration:u,easing:S,onUpdate:w=>{this.bars.forEach(h=>{h.rect.y=h.startY+(h.targetY-h.startY)*w,h.rect.height=h.startHeight+(h.targetHeight-h.startHeight)*w,h.rect.x=h.startX+(h.targetX-h.startX)*w,h.rect.width=h.startWidth+(h.targetWidth-h.startWidth)*w,h.rect.opacity=h.startOpacity+(h.targetOpacity-h.startOpacity)*w,h.rect.scaling={x:h.startScaleX+(h.targetScaleX-h.startScaleX)*w,y:h.startScaleY+(h.targetScaleY-h.startScaleY)*w},h.label&&this.placeLabel(h.label,h.rect,h.rawY)})}}),this.animator.start()}else this.bars.forEach(u=>{u.rect.y=u.targetY,u.rect.height=u.targetHeight,u.rect.x=u.targetX,u.rect.width=u.targetWidth,u.rect.opacity=u.targetOpacity,u.rect.scaling={x:u.targetScaleX,y:u.targetScaleY},u.label&&this.placeLabel(u.label,u.rect,u.rawY)})}placeLabel(t,e,i){let s=this.labelsOpts?.position||"inside",n=this.direction==="horizontal",r=String(i);if(typeof i=="number"){let y=Math.abs(i);y>=1e9?r=(i/1e9).toFixed(1).replace(/\.0$/,"")+"B":y>=1e6?r=(i/1e6).toFixed(1).replace(/\.0$/,"")+"M":y>=1e3?r=(i/1e3).toFixed(1).replace(/\.0$/,"")+"K":r=i.toLocaleString()}t.text=r,t.fontSize=this.labelsOpts?.fontSize||10,t.fontFamily=this.labelsOpts?.fontFamily||"sans-serif",t.fontWeight=this.labelsOpts?.fontWeight||"600",t.rotation=(this.labelsOpts?.rotation||0)*Math.PI/180,t.fill=this.labelsOpts?.fill||(s==="inside"||s==="center"?"#fff":"#6b7280"),t.textAlign="center",t.textBaseline="middle";let o=0,l=0;n?(l=e.y+e.height/2,s==="inside"?(o=e.x+e.width-12,t.textAlign="right"):s==="right"||s==="outside"?(o=e.x+e.width+6,t.textAlign="left",t.fill=this.labelsOpts?.fill||"#6b7280"):s==="center"?o=e.x+e.width/2:s==="left"&&(o=e.x+8,t.textAlign="left")):(o=e.x+e.width/2,s==="inside"?l=e.y+12:s==="top"||s==="outside"?(l=e.y-8,t.textBaseline="bottom",t.fill=this.labelsOpts?.fill||"#6b7280"):s==="center"?l=e.y+e.height/2:s==="bottom"&&(l=e.y+e.height-10)),t.translation={x:o,y:l},t.x=0,t.y=0,(s==="inside"||s==="center")&&(!n&&(e.width<14||e.height<14)&&(t.text=""),n&&(e.height<14||e.width<14)&&(t.text=""))}};function ee(m){if(m.length===0)return[];let t=[{command:"M",x:m[0].x,y:m[0].y}];for(let e=1;e<m.length;e++){let i=m[Math.max(e-2,0)],s=m[e-1],n=m[e],r=m[Math.min(e+1,m.length-1)];t.push({command:"C",cp1x:s.x+(n.x-i.x)/6,cp1y:s.y+(n.y-i.y)/6,cp2x:n.x-(r.x-s.x)/6,cp2y:n.y-(r.y-s.y)/6,x:n.x,y:n.y})}return t}var mt=class{constructor(t){this.group=new B;this.stroke="#4e79a7";this.strokeWidth=2;this.markerOpts={enabled:!0,size:6,fill:""};this.connectMissingData=!0;this.markerShape="circle";this.linePath=new rt;this.xKey=t.xKey,this.yKey=t.yKey;let e=t.step?"step":"linear";this.interpolation=t.interpolation??e,t.stroke&&(this.stroke=t.stroke),t.strokeWidth&&(this.strokeWidth=t.strokeWidth),t.marker&&(this.markerOpts={...this.markerOpts,...t.marker}),this.markerOpts.fill=this.markerOpts.fill||this.stroke,this.labelsOpts=t.labels,this.animationOpts=t.animation,this.shadowOpts=t.shadow,this.connectMissingData=t.connectMissingData??!0,this.markerShape=t.markerShape??"circle"}getGroup(){return this.group}update(t,e,i,s,n=!0,r){if(r&&(this.xKey=r.xKey,this.yKey=r.yKey,r.stroke&&(this.stroke=r.stroke),r.strokeWidth!==void 0&&(this.strokeWidth=r.strokeWidth),r.interpolation&&(this.interpolation=r.interpolation),r.marker&&(this.markerOpts={...this.markerOpts,...r.marker}),r.labels&&(this.labelsOpts=r.labels),r.animation&&(this.animationOpts=r.animation),r.shadow!==void 0&&(this.shadowOpts=r.shadow),r.connectMissingData!==void 0&&(this.connectMissingData=r.connectMissingData),r.markerShape&&(this.markerShape=r.markerShape)),this.group.clear(),t.length===0)return;let o=t.map(x=>{let d=x[this.yKey],p=d==null||typeof d=="number"&&isNaN(d),a=j(e);return{x:e.convert(x[this.xKey])+a/2,y:i.convert(p?0:d),datum:x,missing:p}}),l=this.linePath;l.pathData=[],l.stroke=this.stroke,l.strokeWidth=this.strokeWidth,l.shadow=this.shadowOpts??null;let y=[];if(this.connectMissingData)y.push(o.filter(x=>!x.missing));else{let x=[];o.forEach(d=>{d.missing?x.length>0&&(y.push(x),x=[]):x.push(d)}),x.length>0&&y.push(x)}y.forEach(x=>{x.length!==0&&(this.interpolation==="smooth"?l.pathData.push(...ee(x)):this.interpolation==="step"?x.forEach((d,p)=>{if(p===0)l.pathData.push({command:"M",x:d.x,y:d.y});else{let a=l.pathData[l.pathData.length-1];l.pathData.push({command:"L",x:d.x,y:a.y}),l.pathData.push({command:"L",x:d.x,y:d.y})}}):x.forEach((d,p)=>l.pathData.push({command:p===0?"M":"L",x:d.x,y:d.y})))}),this.group.add(l);let c=new B;if(this.group.add(c),(this.markerOpts.enabled||this.labelsOpts?.enabled)&&o.forEach(x=>{if(!x.missing){if(this.markerOpts.enabled){let d=new tt;d.centerX=x.x,d.centerY=x.y,d.radius=(this.markerOpts.size||6)/2,d.shape=this.markerShape,d.fill=this.markerOpts.fill||this.stroke,d.stroke="#fff",d.strokeWidth=1.5,d.shadow=this.shadowOpts??null,d.datum=x.datum,d.seriesId=this.yKey,c.add(d)}if(this.labelsOpts?.enabled){let d=new K;d.text=J(x.datum[this.yKey]),d.fontSize=this.labelsOpts.fontSize||10,d.fontFamily=this.labelsOpts.fontFamily||"sans-serif",d.fontWeight=this.labelsOpts.fontWeight||"600",d.rotation=(this.labelsOpts.rotation||0)*Math.PI/180,d.fill=this.labelsOpts.fill||this.stroke;let p=this.labelsOpts.position||"top",a=(this.markerOpts.enabled?this.markerOpts.size||6:0)/2+5,f=x.x,b=x.y;p==="top"?(b=x.y-a,d.textAlign="center",d.textBaseline="bottom"):p==="bottom"?(b=x.y+a+2,d.textAlign="center",d.textBaseline="top"):p==="left"?(f=x.x-a-4,d.textAlign="right",d.textBaseline="middle"):p==="right"?(f=x.x+a+4,d.textAlign="left",d.textBaseline="middle"):(d.textAlign="center",d.textBaseline="middle",this.markerOpts.enabled&&(d.fill="#fff")),d.translation={x:f,y:b},d.x=0,d.y=0,c.add(d)}}}),n&&this.animationOpts?.enabled!==!1){this.animator?.stop();let x=this.animationOpts?.type||"draw",d=this.animationOpts?.duration??800,p=X.getEasing(this.animationOpts?.easing);if(x==="draw"){let a=0;for(let f=1;f<o.length;f++)a+=Math.sqrt(Math.pow(o[f].x-o[f-1].x,2)+Math.pow(o[f].y-o[f-1].y,2));this.interpolation==="step"&&(a*=1.5),l.lineDash=[a,a],l.lineDashOffset=a,c.opacity=0,this.animator=new X({duration:d,easing:p,onUpdate:f=>{l.lineDashOffset=a*(1-f),f>.8&&(c.opacity=(f-.8)*5)},onComplete:()=>{l.lineDash=void 0,c.opacity=1}})}else this.group.opacity=0,this.animator=new X({duration:d,easing:p,onUpdate:a=>{this.group.opacity=a}});this.animator.start()}}};var Kt=Math.PI/180,dt=class{constructor(t){this.group=new B;this.innerRadius=0;this.fills=["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];this.strokes=["#fff"];this.startAngleDeg=-90;this.endAngleDeg=270;this.padAngle=.008;this.slices=[];this.angleKey=t.angleKey,this.labelKey=t.labelKey,t.innerRadius!==void 0&&(this.innerRadius=t.innerRadius),t.outerRadius!==void 0&&(this.outerRadius=t.outerRadius),t.fills&&(this.fills=t.fills),t.strokes&&(this.strokes=t.strokes),t.startAngle!==void 0&&(this.startAngleDeg=t.startAngle),t.endAngle!==void 0&&(this.endAngleDeg=t.endAngle),t.padAngle!==void 0&&(this.padAngle=t.padAngle),this.labelsOpts=t.labels,this.animationOpts=t.animation}getGroup(){return this.group}update(t,e,i=!0,s){if(s&&(this.angleKey=s.angleKey,this.labelKey=s.labelKey,s.innerRadius!==void 0&&(this.innerRadius=s.innerRadius),s.outerRadius!==void 0&&(this.outerRadius=s.outerRadius),s.fills&&(this.fills=s.fills),s.strokes&&(this.strokes=s.strokes),s.startAngle!==void 0&&(this.startAngleDeg=s.startAngle),s.endAngle!==void 0&&(this.endAngleDeg=s.endAngle),s.padAngle!==void 0&&(this.padAngle=s.padAngle),s.labels&&(this.labelsOpts=s.labels),s.animation&&(this.animationOpts=s.animation)),this.group.clear(),!t||t.length===0)return;let n=t.reduce((a,f)=>a+(f[this.angleKey]||0),0);if(n===0)return;let r=e.x+e.width/2,o=e.y+e.height/2,l=this.labelsOpts?.enabled!==!1?.72:.88,y=this.outerRadius??Math.min(e.width,e.height)/2*l,c=this.innerRadius>0&&this.innerRadius<=1?this.innerRadius*y:this.innerRadius,x=this.startAngleDeg*Kt,d=(this.endAngleDeg-this.startAngleDeg)*Kt;this.slices=[];let p=x;if(t.forEach((a,f)=>{let k=(a[this.angleKey]||0)/n*d-this.padAngle,u=new bt;u.centerX=r,u.centerY=o,u.innerRadius=c,u.outerRadius=y,u.startAngle=p,u.endAngle=p+k,u.fill=this.fills[f%this.fills.length],u.stroke=this.strokes[f%this.strokes.length],u.strokeWidth=2,u.datum=a,u.seriesId=this.angleKey,this.group.add(u);let S;if(this.labelsOpts?.enabled!==!1){let w=p+k/2,h=this.labelsOpts?.position||"outside",g=h==="inside"||h==="center",C=g?c+(y-c)/2:y+18,A=r+Math.cos(w)*C,R=o+Math.sin(w)*C;S=new K,S.text=String(a[this.labelKey]??""),S.fontSize=this.labelsOpts?.fontSize||10,S.fontFamily=this.labelsOpts?.fontFamily||"sans-serif",S.fontWeight=this.labelsOpts?.fontWeight||"normal",S.rotation=(this.labelsOpts?.rotation||0)*Math.PI/180,S.fill=this.labelsOpts?.fill||(g?"#fff":"#6b7280");let v=Math.cos(w);if(S.textAlign=g?"center":v>.05?"start":v<-.05?"end":"center",S.textBaseline="middle",S.translation={x:A,y:R},S.x=0,S.y=0,!g){let _=v>0?e.x+e.width-A-10:A-e.x-10;S.maxWidth=Math.max(40,Math.min(_,e.width/3))}g&&k<.1&&(S.text=""),this.group.add(S)}this.slices.push({arc:u,targetStart:p,targetEnd:p+k,label:S}),p+=k+this.padAngle}),i&&this.animationOpts?.enabled!==!1){this.animator?.stop();let a=this.animationOpts?.type||"grow",f=this.animationOpts?.duration??600,b=X.getEasing(this.animationOpts?.easing||(a==="grow"?"back":"easeOut"));a==="grow"?(this.slices.forEach(k=>{k.arc.outerRadius=0,k.label&&(k.label.opacity=0)}),this.animator=new X({duration:f,easing:b,onUpdate:k=>{this.slices.forEach(u=>{u.arc.outerRadius=y*k,u.label&&k>.8&&(u.label.opacity=(k-.8)*5)})}})):a==="radial"?(this.slices.forEach(k=>{k.arc.endAngle=k.arc.startAngle,k.label&&(k.label.opacity=0)}),this.animator=new X({duration:f,easing:b,onUpdate:k=>{this.slices.forEach(u=>{let S=u.targetEnd-u.targetStart;u.arc.endAngle=u.targetStart+S*k,u.label&&k>.8&&(u.label.opacity=(k-.8)*5)})}})):(this.group.opacity=0,this.animator=new X({duration:f,easing:b,onUpdate:k=>{this.group.opacity=k}})),this.animator.start()}}getLegendData(t,e){return e?e.map((i,s)=>({id:`${this.angleKey}-${s}`,label:String(i[this.labelKey]??`Item ${s+1}`),fill:this.fills[s%this.fills.length],markerType:"square"})):[]}};function ie(m){if(m.length===0)return[];let t=[{command:"M",x:m[0].x,y:m[0].y}];for(let e=1;e<m.length;e++){let i=m[Math.max(e-2,0)],s=m[e-1],n=m[e],r=m[Math.min(e+1,m.length-1)];t.push({command:"C",cp1x:s.x+(n.x-i.x)/6,cp1y:s.y+(n.y-i.y)/6,cp2x:n.x-(r.x-s.x)/6,cp2y:n.y-(r.y-s.y)/6,x:n.x,y:n.y})}return t}var ft=class{constructor(t){this.group=new B;this.fill="#4e79a7";this.stroke="#4e79a7";this.strokeWidth=2;this.fillOpacity=.25;this.stacked=!1;this.normalized=!1;this.connectMissingData=!0;this.markerOpts={enabled:!1,size:6,fill:""};this.path=new rt;this.markers=[];this.points=[];this.xKey=t.xKey,this.yKey=t.yKey,this.stacked=t.stacked??!1,this.normalized=t.normalized??!1,this.connectMissingData=t.connectMissingData??!0,this.interpolation=t.interpolation??"linear",t.fill&&(this.fill=t.fill),t.stroke&&(this.stroke=t.stroke),t.strokeWidth!==void 0&&(this.strokeWidth=t.strokeWidth),t.fillOpacity!==void 0&&(this.fillOpacity=t.fillOpacity),t.marker&&(this.markerOpts={...this.markerOpts,...t.marker}),this.markerOpts.fill=this.markerOpts.fill||this.fill,this.labelsOpts=t.labels,this.animationOpts=t.animation,this.shadowOpts=t.shadow}getGroup(){return this.group}update(t,e,i,s,n=!0,r,o,l){o&&(this.xKey=o.xKey,this.yKey=o.yKey,o.fill&&(this.fill=o.fill),o.stroke&&(this.stroke=o.stroke),o.strokeWidth!==void 0&&(this.strokeWidth=o.strokeWidth),o.fillOpacity!==void 0&&(this.fillOpacity=o.fillOpacity),o.stacked!==void 0&&(this.stacked=o.stacked),o.normalized!==void 0&&(this.normalized=o.normalized),o.connectMissingData!==void 0&&(this.connectMissingData=o.connectMissingData),o.interpolation&&(this.interpolation=o.interpolation),o.marker&&(this.markerOpts={...this.markerOpts,...o.marker}),o.labels&&(this.labelsOpts=o.labels),o.animation&&(this.animationOpts=o.animation),o.shadow!==void 0&&(this.shadowOpts=o.shadow));let y=this.points.length===0;if(this.group.clear(),t.length===0)return;this.path=new rt,this.path.fill=this.fill,this.path.stroke=this.stroke,this.path.strokeWidth=this.strokeWidth,this.path.opacity=this.fillOpacity,this.path.shadow=this.shadowOpts??null,this.group.add(this.path);let c=[];if(this.markers=[],t.forEach((x,d)=>{let p=e.convert(x[this.xKey])+j(e)/2,a=x[this.yKey],f=a==null||typeof a=="number"&&isNaN(a),b,k;if(this.stacked&&r){let h=r[d]??0,g=l?.[d]??0;if(this.normalized&&g>0){let C=h/g*100,A=(a??0)/g*100;k=i.convert(C),b=i.convert(C+A)}else k=i.convert(h),b=i.convert(h+(a??0))}else b=i.convert(a??0),k=i.convert(0);let u=y?i.convert(0):this.points[d]?.currentY??i.convert(0),S=y?i.convert(0):this.points[d]?.currentBottomY??i.convert(0),w;if(this.labelsOpts?.enabled&&(w=new K,this.group.add(w)),c.push({x:p,targetY:b,startY:u,currentY:u,targetBottomY:k,startBottomY:S,currentBottomY:S,label:w,datum:x,missing:f}),this.markerOpts.enabled){let h=new tt;h.shape=this.markerOpts.shape||"circle",h.centerX=p,h.centerY=b,h.radius=(this.markerOpts.size||6)/2,h.fill=this.markerOpts.fill,this.markerOpts.stroke&&(h.stroke=this.markerOpts.stroke),this.markerOpts.strokeWidth!==void 0&&(h.strokeWidth=this.markerOpts.strokeWidth),h.shadow=this.shadowOpts??null,h.datum=x,h.seriesId=this.yKey,this.markers.push(h),this.group.add(h)}}),this.points=c,n&&this.animationOpts?.enabled!==!1){this.animator?.stop();let x=this.animationOpts?.type||"grow",d=this.animationOpts?.duration??500,p=X.getEasing(this.animationOpts?.easing);x==="fade"?(this.group.opacity=0,this.animator=new X({duration:d,easing:p,onUpdate:a=>{this.buildPath(1),this.group.opacity=a*this.fillOpacity,this.labelsOpts?.enabled&&this.renderLabels()}})):this.animator=new X({duration:d,easing:p,onUpdate:a=>{this.buildPath(a),this.labelsOpts?.enabled&&this.renderLabels()}}),this.animator.start()}else this.points.forEach((x,d)=>{x.label=c[d].label,x.targetY=c[d].targetY,x.targetBottomY=c[d].targetBottomY,x.startY=x.currentY,x.startBottomY=x.currentBottomY}),this.buildPath(1),this.labelsOpts?.enabled&&this.renderLabels()}renderLabels(){this.points.forEach(t=>{if(!t.label)return;let e=t.label;e.text=J(t.datum[this.yKey]),e.fontSize=this.labelsOpts?.fontSize||10,e.fontFamily=this.labelsOpts?.fontFamily||"sans-serif",e.fontWeight=this.labelsOpts?.fontWeight||"600",e.rotation=(this.labelsOpts?.rotation||0)*Math.PI/180,e.fill=this.labelsOpts?.fill||this.stroke,e.textAlign="center",e.textBaseline="bottom",e.translation={x:t.x,y:t.currentY-8},e.x=0,e.y=0})}buildPath(t){this.points.forEach((s,n)=>{s.currentY=s.startY+(s.targetY-s.startY)*t,s.currentBottomY=s.startBottomY+(s.targetBottomY-s.startBottomY)*t,this.markers[n]&&(this.markers[n].centerY=s.currentY)});let e=[];if(this.connectMissingData)e.push(this.points);else{let s=[];this.points.forEach(n=>{n.missing?s.length>0&&(e.push(s),s=[]):s.push(n)}),s.length>0&&e.push(s)}let i=[];e.forEach(s=>{let n=s.map(l=>({x:l.x,y:l.currentY}));if(n.length===0)return;let r;this.interpolation==="smooth"?r=ie(n):this.interpolation==="step"?(r=[],n.forEach((l,y)=>{if(y===0)r.push({command:"M",x:l.x,y:l.y});else{let c=r[r.length-1];r.push({command:"L",x:l.x,y:c.y}),r.push({command:"L",x:l.x,y:l.y})}})):r=n.map((l,y)=>({command:y===0?"M":"L",x:l.x,y:l.y}));let o=[];for(let l=s.length-1;l>=0;l--)o.push({command:"L",x:s[l].x,y:s[l].currentBottomY});o.push({command:"L",x:n[0].x,y:n[0].y}),i.push(...r,...o)}),this.path.pathData=i,this.path.closed=!0}};var gt=class{constructor(t){this.group=new B;this.fill="#4e79a7";this.stroke="#fff";this.strokeWidth=1;this.markerSize=8;this.markers=[];this.markerShape="circle";this.labelTexts=[];this.points=[];this.jitter=0;this.jitterOffsets=[];this.xKey=t.xKey,this.yKey=t.yKey,this.sizeKey=t.sizeKey,this.jitter=t.jitter??0,t.fill&&(this.fill=t.fill),t.stroke&&(this.stroke=t.stroke),t.strokeWidth!==void 0&&(this.strokeWidth=t.strokeWidth),t.marker?.size!==void 0&&(this.markerSize=t.marker.size),this.labelsOpts=t.labels,this.animationOpts=t.animation,this.shadowOpts=t.shadow,t.markerShape&&(this.markerShape=t.markerShape)}getGroup(){return this.group}update(t,e,i,s,n=!0,r){if(r&&(this.xKey=r.xKey,this.yKey=r.yKey,r.sizeKey!==void 0&&(this.sizeKey=r.sizeKey),r.fill&&(this.fill=r.fill),r.stroke&&(this.stroke=r.stroke),r.strokeWidth!==void 0&&(this.strokeWidth=r.strokeWidth),r.marker?.size!==void 0&&(this.markerSize=r.marker.size),r.jitter!==void 0&&(this.jitter=r.jitter),r.labels&&(this.labelsOpts=r.labels),r.animation&&(this.animationOpts=r.animation),r.shadow!==void 0&&(this.shadowOpts=r.shadow),r.markerShape&&(this.markerShape=r.markerShape)),this.animator&&this.animator.stop(),t.length===0){for(let p of this.markers)this.group.remove(p);for(let p of this.labelTexts)this.group.remove(p);this.markers=[],this.labelTexts=[],this.points=[];return}for(;this.jitterOffsets.length<t.length;)this.jitterOffsets.push((Math.random()-.5)*2);this.jitterOffsets.length>t.length&&(this.jitterOffsets.length=t.length);let o=p=>this.markerSize/2;if(this.sizeKey){let p=t.map(f=>f[this.sizeKey]||0),a=Math.max(...p);o=f=>f/(a||1)*this.markerSize}let l=this.animationOpts?.type||"pop",y=this.points.length===0,c=[];if(t.forEach((p,a)=>{let f=p[this.xKey],b=p[this.yKey],k=this.sizeKey?p[this.sizeKey]:0,u;if("getBandwidth"in e){let v=j(e),_=this.jitterOffsets[a]*(v*this.jitter/2);u=e.convert(f)+v/2+_}else u=e.convert(f);let S=i.convert(b),w=o(k),h,g,C,A,R;a<this.markers.length?(h=this.markers[a],g=h.centerX,C=h.centerY,A=h.radius,R=h.opacity,h.fill=this.fill,h.stroke=this.stroke,h.strokeWidth=this.strokeWidth,h.shape=this.markerShape,h.datum=p,h.seriesId=this.yKey,h.shadow=this.shadowOpts??null):(h=new tt,h.fill=this.fill,h.stroke=this.stroke,h.strokeWidth=this.strokeWidth,h.shape=this.markerShape,h.datum=p,h.seriesId=this.yKey,h.shadow=this.shadowOpts??null,this.markers.push(h),this.group.add(h),y&&l==="grow"?(g=u,C=s.height,A=w,R=1):y&&l==="fade"?(g=u,C=S,A=w,R=0):y&&l==="slide"?(g=u,C=s.height+20,A=w,R=1):(g=u,C=S,A=0,R=0),h.centerX=g,h.centerY=C,h.radius=A,h.opacity=R),c.push({startX:g,targetX:u,startY:C,targetY:S,startRadius:A,targetRadius:w,startOpacity:R,targetOpacity:1})}),this.markers.length>t.length){for(let p=t.length;p<this.markers.length;p++)this.group.remove(this.markers[p]);this.markers.length=t.length}let x=this.labelsOpts?.enabled??!1;if(x){for(;this.labelTexts.length<t.length;){let p=new K;p.textAlign="center",p.textBaseline="bottom",p.x=0,p.y=0,this.labelTexts.push(p),this.group.add(p)}if(this.labelTexts.length>t.length){for(let p=t.length;p<this.labelTexts.length;p++)this.group.remove(this.labelTexts[p]);this.labelTexts.length=t.length}this.labelTexts.forEach((p,a)=>{let f=t[a][this.yKey];p.text=J(f),p.fontSize=this.labelsOpts?.fontSize??10,p.fontFamily=this.labelsOpts?.fontFamily??"sans-serif",p.fontWeight=this.labelsOpts?.fontWeight??"600",p.rotation=(this.labelsOpts?.rotation??0)*Math.PI/180,p.fill=this.labelsOpts?.fill??this.fill})}else if(this.labelTexts.length>0){for(let p of this.labelTexts)this.group.remove(p);this.labelTexts=[]}this.points=c;let d=p=>{this.points.forEach((a,f)=>{let b=this.markers[f];if(!b)return;let k=a.startX+(a.targetX-a.startX)*p,u=a.startY+(a.targetY-a.startY)*p,S=a.startRadius+(a.targetRadius-a.startRadius)*p;b.centerX=k,b.centerY=u,b.radius=S,b.opacity=a.startOpacity+(a.targetOpacity-a.startOpacity)*p,x&&this.labelTexts[f]&&(this.labelTexts[f].translation={x:k,y:u-(S+5)})})};if(n&&this.animationOpts?.enabled!==!1){let p=this.animationOpts?.duration??600,a=X.getEasing(this.animationOpts?.easing??(l==="pop"?"back":"easeOut"));this.animator=new X({duration:p,easing:a,onUpdate:d}),this.animator.start()}else d(1)}};var Mt={active:!1,pointerX:0,pointerY:0,anchorX:0,anchorY:0,localX:0,localY:0,entries:[],sharedLabel:null};var vt=class{constructor(){this._state={...Mt};this._listeners=new Set;this._options={};this._showTimer=null;this._hideTimer=null;this._pendingActivation=null}getState(){return this._state}getOptions(){return this._options}setOptions(t){this._options=t}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}activate(t,e,i,s,n){if(this._options.enabled===!1)return;this._clearHideTimer();let r=()=>{this._setState({active:!0,pointerX:e.x,pointerY:e.y,anchorX:i.x,anchorY:i.y,localX:s.x,localY:s.y,entries:t,sharedLabel:n})},o=this._options.delay?.show??0;o>0?(this._clearShowTimer(),this._pendingActivation=r,this._showTimer=setTimeout(()=>{this._pendingActivation?.(),this._pendingActivation=null,this._showTimer=null},o)):r()}deactivate(){this._clearShowTimer(),this._pendingActivation=null;let t=this._options.delay?.hide??0;t>0&&this._state.active?this._hideTimer=setTimeout(()=>{this._doDeactivate(),this._hideTimer=null},t):this._doDeactivate()}updatePointer(t,e){this._state.active&&this._setState({...this._state,pointerX:t,pointerY:e})}notifyResize(){this._state.active&&this._notify()}hide(){this._clearShowTimer(),this._clearHideTimer(),this._pendingActivation=null,this._doDeactivate(!0)}destroy(){this.hide(),this._listeners.clear()}_setState(t){this._state=t,this._notify()}_notify(){for(let t of this._listeners)t()}_doDeactivate(t=!1){!this._state.active&&!t||this._setState({...Mt})}_clearShowTimer(){this._showTimer!==null&&(clearTimeout(this._showTimer),this._showTimer=null)}_clearHideTimer(){this._hideTimer!==null&&(clearTimeout(this._hideTimer),this._hideTimer=null)}};var It=["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],zt=["#80b1d3","#fdb462","#fb8072","#bebada","#b3de69","#fccde5","#8dd3c7","#ffffb3","#bc80bd","#ccebc5"],Lt={backgroundColor:"#ffffff",textColor:"#1a1a2e",subtextColor:"#6b7280",axisColor:"#d1d5db",gridColor:"rgba(107,114,128,0.12)",palette:It,palettes:{categorical:It},fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},Et={backgroundColor:"#020617",textColor:"#e2e8f0",subtextColor:"#94a3b8",axisColor:"#334155",gridColor:"rgba(148,163,184,0.08)",palette:zt,palettes:{categorical:zt},fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'};function Xt(){return typeof window>"u"?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}var ct=class{constructor(){this.currentTheme=Lt}setTheme(t){t==="light"?this.currentTheme=Lt:t==="dark"?this.currentTheme=Et:t==="system"?this.currentTheme=Xt()?Et:Lt:this.currentTheme=t}get theme(){return this.currentTheme}static resolveIsDark(t){return t==="dark"?!0:t==="system"?Xt():!1}};var kt=class{constructor(){this.group=new B;this.items=[];this.hiddenSeries=[];this.pages=[];this.currentPage=0;this.ROW_H=24;this.NAV_H=22;this.MARKER=12;this.GAP=6;this.SPACING=20;this.CHAR_W=7.5;this.lastMaxWidth=0;this.lastMaxRows=2}getGroup(){return this.group}setHiddenSeries(t){this.hiddenSeries=t}getHiddenSeries(){return this.hiddenSeries}update(t,e,i,s,n="bottom"){this.items=t,this.theme=e,this.lastMaxWidth=i;let r=n==="left"||n==="right",o=.85,l=.25;this.lastMaxRows=Math.max(1,Math.floor(s*(r?o:l)/this.ROW_H)),this.pages=this._buildPages(t,i,this.lastMaxRows),this.currentPage=Math.min(this.currentPage,Math.max(0,this.pages.length-1)),this._renderCurrentPage()}paginate(t){this.currentPage=Math.max(0,Math.min(this.pages.length-1,this.currentPage+t)),this._renderCurrentPage()}getBBox(){return this.group.getBBox()}_buildPages(t,e,i){let s=[],n=[],r=0;for(let l of t){let y=this.MARKER+this.GAP+l.label.length*this.CHAR_W+this.SPACING;r+y>e&&n.length>0&&(s.push(n),n=[],r=0),n.push(l),r+=y}n.length>0&&s.push(n);let o=[];for(let l=0;l<s.length;l+=i)o.push(s.slice(l,l+i).flat());return o.length>0?o:[[]]}_renderCurrentPage(){if(this.group.clear(),!this.theme)return;let t=this.theme,e=this.pages[this.currentPage]??[],i=this.pages.length>1,s=0,n=0;for(let x of e){let d=x.label.length*this.CHAR_W,p=this.MARKER+this.GAP+d;s+p>this.lastMaxWidth&&s>0&&(s=0,n+=this.ROW_H);let a=new B;if(a.translation={x:s,y:n},a.seriesId=x.id,a.opacity=this.hiddenSeries.includes(x.id)?.4:1,a.pointerEvents=!0,x.markerType==="circle"){let b=new ht;b.centerX=this.MARKER/2,b.centerY=this.MARKER/2,b.radius=this.MARKER/2,b.fill=x.fill,a.add(b)}else if(x.markerType==="line"){let b=new q;b.x1=0,b.y1=this.MARKER/2,b.x2=this.MARKER,b.y2=this.MARKER/2,b.stroke=x.fill,b.strokeWidth=3,a.add(b)}else{let b=new Q;b.width=this.MARKER,b.height=this.MARKER,b.fill=x.fill,b.cornerRadius=2,a.add(b)}let f=new K;f.text=x.label,f.x=this.MARKER+this.GAP,f.y=this.MARKER/2,f.fontSize=11,f.fontFamily=t.fontFamily,f.fill=t.textColor,f.textBaseline="middle",a.add(f),this.group.add(a),s+=p+this.SPACING}if(!i)return;let r=n+(e.length>0?this.ROW_H:0),o=t.subtextColor,l=this.NAV_H,y=28;this.currentPage>0&&this.group.add(this._makeNavButton("\u25C0","__legend_prev__",0,r,y,l,o,t,"start"));let c=new K;c.text=`${this.currentPage+1} / ${this.pages.length}`,c.x=this.lastMaxWidth/2,c.y=r+l/2,c.fontSize=10,c.fontFamily=t.fontFamily,c.fill=o,c.textAlign="center",c.textBaseline="middle",c.pointerEvents=!1,this.group.add(c),this.currentPage<this.pages.length-1&&this.group.add(this._makeNavButton("\u25B6","__legend_next__",this.lastMaxWidth-y,r,y,l,o,t,"end"))}_makeNavButton(t,e,i,s,n,r,o,l,y){let c=new B;c.translation={x:i,y:s},c.seriesId=e,c.pointerEvents=!0;let x=new Q;x.x=0,x.y=0,x.width=n,x.height=r,x.fill="transparent",c.add(x);let d=new K;return d.text=t,d.x=y==="end"?n:0,d.y=r/2,d.fontSize=11,d.fontFamily=l.fontFamily,d.fill=o,d.textAlign=y,d.textBaseline="middle",c.add(d),c}};var St=class St{constructor(){this.group=new B;this.xLine=new q;this.yLine=new q;this.snapDot=new ht;this.bandHighlight=new Q;this.enabledX=!1;this.enabledY=!1;this.seriesSnapDots=[];this.seriesSnapTargets=[];this.spikeXLabel=new K;this.spikeYLabel=new K;this.spikeXBg=new Q;this.spikeYBg=new Q;this._targetX=0;this._targetY=0;this._currentX=0;this._currentY=0;this._lerpActive=!1;this._reducedMotion=typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;this.group.visible=!1,this.xLine.strokeWidth=1,this.yLine.strokeWidth=1,this.snapDot.radius=5,this.snapDot.fill="transparent",this.snapDot.strokeWidth=2,this.bandHighlight.fill="rgba(128,128,128,0.06)",this.bandHighlight.visible=!1,this.spikeXLabel.fontSize=10,this.spikeXLabel.textAlign="center",this.spikeXLabel.textBaseline="top",this.spikeXLabel.visible=!1,this.spikeXBg.cornerRadius=3,this.spikeXBg.visible=!1,this.spikeYLabel.fontSize=10,this.spikeYLabel.textAlign="right",this.spikeYLabel.textBaseline="middle",this.spikeYLabel.visible=!1,this.spikeYBg.cornerRadius=3,this.spikeYBg.visible=!1,this.group.add(this.bandHighlight),this.group.add(this.xLine),this.group.add(this.yLine),this.group.add(this.snapDot),this.group.add(this.spikeXBg),this.group.add(this.spikeXLabel),this.group.add(this.spikeYBg),this.group.add(this.spikeYLabel)}getGroup(){return this.group}updateOptions(t){this.enabledX=t.x??!1,this.enabledY=t.y??!1}show(t,e,i,s,n,r,o){if(!this.enabledX&&!this.enabledY){this.group.visible=!1;return}this.group.visible=!0;let l=s.axisColor,y=t,c=e;if(this.snapDot.visible=!1,this.bandHighlight.visible=!1,n&&r&&o){let x=1/0,d=t,p=0;for(let a of r){let b=n.convert(a[o])+j(n)/2+i.x,k=Math.abs(b-t);k<x&&(x=k,d=b,p=n.convert(a[o]))}if(y=d,this.enabledX){this.bandHighlight.visible=!0,this.bandHighlight.x=p+i.x,this.bandHighlight.y=i.y,this.bandHighlight.width=j(n),this.bandHighlight.height=i.height;let a=s.backgroundColor.includes("2")||s.backgroundColor.includes("0");this.bandHighlight.fill=a?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.04)"}this.enabledX&&(this.snapDot.visible=!0,this.snapDot.centerX=y,this.snapDot.centerY=e,this.snapDot.fill=s.backgroundColor,this.snapDot.stroke=l)}this._targetX=y,this._targetY=c,!this._lerpActive&&this._currentX===0&&this._currentY===0?(this._currentX=y,this._currentY=c):this._lerpActive=!0,this.enabledX?(this.xLine.visible=!0,this.xLine.x1=this._currentX,this.xLine.y1=i.y,this.xLine.x2=this._currentX,this.xLine.y2=i.y+i.height,this.xLine.stroke=l,this.xLine.lineDash=[4,4]):this.xLine.visible=!1,this.enabledY?(this.yLine.visible=!0,this.yLine.x1=i.x,this.yLine.y1=this._currentY,this.yLine.x2=i.x+i.width,this.yLine.y2=this._currentY,this.yLine.stroke=l,this.yLine.lineDash=[4,4]):this.yLine.visible=!1,this.spikeXLabel.visible=!1,this.spikeXBg.visible=!1,this.spikeYLabel.visible=!1,this.spikeYBg.visible=!1}showSpikeLabels(t,e,i,s,n,r){let o=r.backgroundColor.includes("2")||r.backgroundColor.includes("0");if(t&&this.enabledX){this.spikeXLabel.visible=!0,this.spikeXLabel.text=t,this.spikeXLabel.x=i,this.spikeXLabel.y=n.y+n.height+4,this.spikeXLabel.fill=o?"#e2e8f0":"#1e293b",this.spikeXLabel.fontFamily=r.fontFamily;let l=t.length*6+12;this.spikeXBg.visible=!0,this.spikeXBg.x=i-l/2,this.spikeXBg.y=n.y+n.height+2,this.spikeXBg.width=l,this.spikeXBg.height=18,this.spikeXBg.fill=o?"#1e293b":"#f1f5f9",this.spikeXBg.stroke=r.axisColor,this.spikeXBg.strokeWidth=1}if(e&&this.enabledY){this.spikeYLabel.visible=!0,this.spikeYLabel.text=e,this.spikeYLabel.x=n.x-4,this.spikeYLabel.y=s,this.spikeYLabel.fill=o?"#e2e8f0":"#1e293b",this.spikeYLabel.fontFamily=r.fontFamily;let l=e.length*6+12;this.spikeYBg.visible=!0,this.spikeYBg.x=n.x-l-4,this.spikeYBg.y=s-9,this.spikeYBg.width=l,this.spikeYBg.height=18,this.spikeYBg.fill=o?"#1e293b":"#f1f5f9",this.spikeYBg.stroke=r.axisColor,this.spikeYBg.strokeWidth=1}}tick(){if(!this.group.visible)return!1;let t=this.seriesSnapDots.some((n,r)=>Math.abs((this.seriesSnapTargets[r]??0)-n.radius)>.2);if(!this._lerpActive&&!t)return!1;if(this._reducedMotion){this._currentX=this._targetX,this._currentY=this._targetY,this._lerpActive=!1,this.enabledX&&(this.xLine.x1=this._currentX,this.xLine.x2=this._currentX),this.enabledY&&(this.yLine.y1=this._currentY,this.yLine.y2=this._currentY);for(let n=0;n<this.seriesSnapDots.length;n++){let r=this.seriesSnapDots[n],o=this.seriesSnapTargets[n]??0;r.radius=o,o===0&&(r.visible=!1)}return!0}let e=St.LERP_SPEED,i=this._targetX-this._currentX,s=this._targetY-this._currentY;Math.abs(i)<.5&&Math.abs(s)<.5?(this._currentX=this._targetX,this._currentY=this._targetY,this._lerpActive=!1):(this._currentX+=i*e,this._currentY+=s*e),this.enabledX&&(this.xLine.x1=this._currentX,this.xLine.x2=this._currentX),this.enabledY&&(this.yLine.y1=this._currentY,this.yLine.y2=this._currentY);for(let n=0;n<this.seriesSnapDots.length;n++){let r=this.seriesSnapDots[n],o=this.seriesSnapTargets[n]??0,l=o-r.radius;Math.abs(l)<.2?(r.radius=o,o===0&&(r.visible=!1)):r.radius+=l*.35}return!0}hideSeriesSnaps(){for(let t=0;t<this.seriesSnapDots.length;t++)this.seriesSnapTargets[t]=0}hide(){this.group.visible=!1,this.bandHighlight.visible=!1,this.hideSeriesSnaps(),this.spikeXLabel.visible=!1,this.spikeXBg.visible=!1,this.spikeYLabel.visible=!1,this.spikeYBg.visible=!1,this._lerpActive=!1,this._currentX=0,this._currentY=0}};St.LERP_SPEED=.25;var wt=St;var Ft=new Set(["pie"]),At=class{constructor(t,e){this.tooltipStore=new vt;this.themeManager=new ct;this.legend=new kt;this.crosshair=new wt;this.mediaQuery=null;this._onSystemThemeChange=()=>{if(this.options.theme!=="system")return;this.themeManager.setTheme("system");let t=this.themeManager.theme.backgroundColor;this.container.style.backgroundColor=t,this.scene.backgroundColor=t,this.processData(),this.performLayout(),this.render()};this.titleGroup=new B;this.subtitleGroup=new B;this.legendGroup=new B;this.seriesGroup=new B;this.axesGroup=new B;this.crosshairGroup=new B;this.emptyGroup=new B;this.categoryScale=new it;this.valueScale=new et;this.valueScaleRight=new et;this.series=[];this.seriesInstances=new Map;this.isCartesian=!0;this.seriesRect={x:0,y:0,width:0,height:0};this.initialized=!1;this.animRafId=null;this.hoveredSeriesId=null;this.hiddenSeries=[];this.minY=0;this.maxY=0;this.lastDataRef=null;this._kbIndex=-1;this.container=t,this.options=e,this.scene=new xt(t),this.tooltipStore.setOptions(e.tooltip??{}),this.container.setAttribute("tabindex","0"),this._onKeyDown=this._handleKeyboard.bind(this),this.container.addEventListener("keydown",this._onKeyDown),this._onPointerLeave=()=>{this.tooltipStore.deactivate(),this.crosshair.hide(),this.crosshair.hideSeriesSnaps(),this.hoveredSeriesId=null,this.series.forEach(i=>{i.getGroup().opacity=1})},this.container.addEventListener("pointerleave",this._onPointerLeave),this.scene.root.add(this.titleGroup),this.scene.root.add(this.subtitleGroup),this.scene.root.add(this.axesGroup),this.scene.root.add(this.seriesGroup),this.scene.root.add(this.legendGroup),this.scene.root.add(this.crosshairGroup),this.scene.root.add(this.emptyGroup),this.legendGroup.add(this.legend.getGroup()),this.crosshairGroup.add(this.crosshair.getGroup()),this.legendProxy=document.createElement("div"),this.legendProxy.className="radiant-chart-legend",this.legendProxy.style.position="absolute",this.legendProxy.style.pointerEvents="none",this.legendProxy.style.display="none",this.container.appendChild(this.legendProxy),this.setupInteractivity(),this.startLoop(),this.resizeObserver=new ResizeObserver(i=>{for(let s of i)s.contentRect.width>0&&s.contentRect.height>0&&(this.scene.resize(),this.performLayout(),this.render(),this.initialized=!0,this.tooltipStore.notifyResize())}),this.resizeObserver.observe(t),this._syncMediaQueryListener(),this.update(e)}startLoop(){let t=()=>{this.crosshair.tick(),this.render(),this.animRafId=requestAnimationFrame(t)};this.animRafId=requestAnimationFrame(t)}stopLoop(){this.animRafId!==null&&(cancelAnimationFrame(this.animRafId),this.animRafId=null)}setupInteractivity(){this.scene.onHover=(t,e)=>{if(!this.initialized)return;if(t===null){this.tooltipStore.deactivate(),this.crosshair.hide(),this.crosshair.hideSeriesSnaps(),this.hoveredSeriesId=null,this.series.forEach(c=>{c.getGroup().opacity=1});return}let i=this.container.getBoundingClientRect(),s=e.clientX-i.left,n=e.clientY-i.top,r=this.themeManager.theme,o=this.seriesRect,l=r.palette;if(this.isCartesian&&s>=o.x&&s<=o.x+o.width&&n>=o.y&&n<=o.y+o.height){let c=this.options.series[0]?.xKey;this.crosshair.show(s,n,o,r,c?this.categoryScale:void 0,c?this.options.data:void 0,c)}else this.crosshair.hide();this.options.tooltip?.enabled!==!1&&(this.isCartesian&&s>=o.x&&s<=o.x+o.width&&n>=o.y&&n<=o.y+o.height?this.tooltipStore.activate([],{x:e.clientX,y:e.clientY},{x:e.clientX,y:e.clientY},{x:s,y:n},null):t?.datum&&!this.isCartesian?this.tooltipStore.activate([],{x:e.clientX,y:e.clientY},{x:e.clientX,y:e.clientY},{x:s,y:n},null):(this.tooltipStore.deactivate(),this.crosshair.hide(),this.crosshair.hideSeriesSnaps()));let y=t?.seriesId??null;t?.datum&&y!==this.hoveredSeriesId?(this.hoveredSeriesId=y,this.series.forEach((c,x)=>{let d=this.options.series[x]?.yKey??this.options.series[x]?.angleKey??`s${x}`;c.getGroup().opacity=d===y||this.series.length===1?1:.15})):!t?.datum&&this.hoveredSeriesId!==null&&(this.hoveredSeriesId=null,this.series.forEach(c=>{c.getGroup().opacity=1}))},this.scene.onClick=(t,e)=>{if(!t)return;let i=t,s=null,n=!1;for(;i;){if(i.seriesId&&!s&&(s=i.seriesId),i===this.legendGroup||i===this.legend.getGroup()){n=!0;break}i=i.parent}if(!n&&t.datum&&this.options.listeners?.nodeClick){let o=this.options.series.find(l=>(l.yKey??l.angleKey??"")===s);this.options.listeners.nodeClick({seriesId:s??"",datum:t.datum,xKey:o?.xKey,yKey:o?.yKey,type:o?.type})}if(!n||!s)return;if(s==="__legend_prev__"||s==="__legend_next__"){this.legend.paginate(s==="__legend_next__"?1:-1),this.performLayout(),this.render();return}let r=this.hiddenSeries.indexOf(s);r>=0?this.hiddenSeries.splice(r,1):this.hiddenSeries.push(s),this.options.legend?.listeners?.legendItemClick?.({seriesId:s,visible:!this.hiddenSeries.includes(s)}),this.legend.setHiddenSeries([...this.hiddenSeries]),this.processData(),this.performLayout(),this.render()},this.scene.onDblClick=(t,e)=>{if(!t)return;let i=t,s=null,n=!1;for(;i;){if(i.seriesId&&!s&&(s=i.seriesId),i===this.legendGroup||i===this.legend.getGroup()){n=!0;break}i=i.parent}if(n){if(!s||s==="__legend_prev__"||s==="__legend_next__")return;let o=this.options.series.map((y,c)=>y.yKey??y.angleKey??`s${c}`).filter(y=>y!==s),l=o.every(y=>this.hiddenSeries.includes(y));l?this.hiddenSeries=[]:this.hiddenSeries=o,this.options.legend?.listeners?.legendItemDoubleClick?.({seriesId:s,isolated:!l}),this.legend.setHiddenSeries([...this.hiddenSeries]),this.processData(),this.performLayout(),this.render();return}if(t.datum&&this.options.listeners?.nodeDoubleClick){let r=this.options.series.find(o=>(o.yKey??o.angleKey??"")===s);this.options.listeners.nodeDoubleClick({seriesId:s??"",datum:t.datum,xKey:r?.xKey,yKey:r?.yKey,type:r?.type})}}}getTooltipStore(){return this.tooltipStore}_handleKeyboard(t){if(!this.initialized||!this.isCartesian)return;let e=this.options.data;if(!e?.length)return;let i=this.options.series[0]?.xKey;if(i)if(t.key==="ArrowRight"||t.key==="ArrowLeft"){t.preventDefault();let s=t.key==="ArrowRight"?1:-1;this._kbIndex=Math.max(0,Math.min(e.length-1,this._kbIndex+s));let n=this.seriesRect,r=this.themeManager.theme,o=r.palette;this.crosshair.show(n.x+n.width/2,n.y+n.height/2,n,r,this.categoryScale instanceof it?this.categoryScale:void 0,e,i),this.options.onFocusChange?.(this._kbIndex)}else t.key==="Escape"?(t.preventDefault(),this.tooltipStore.deactivate(),this.crosshair.hide(),this.crosshair.hideSeriesSnaps(),this._kbIndex=-1,this.options.onFocusChange?.(null)):t.key==="Home"?(t.preventDefault(),this._kbIndex=0,this._handleKeyboard(new KeyboardEvent("keydown",{key:"ArrowLeft"})),this._kbIndex=0):t.key==="End"&&(t.preventDefault(),this._kbIndex=e.length-1,this._handleKeyboard(new KeyboardEvent("keydown",{key:"ArrowRight"})),this._kbIndex=e.length-1)}update(t){let e=t.data!==this.lastDataRef;this.lastDataRef=t.data,this.options=t,t.theme&&this.themeManager.setTheme(t.theme);let i=this.themeManager.theme.backgroundColor;this.container.style.backgroundColor=i,this.scene.backgroundColor=i,this.container.style.transition="background-color 0.3s",this.crosshair.updateOptions(t.crosshair??{}),this.tooltipStore.setOptions(t.tooltip??{}),this._syncMediaQueryListener(),this.processData(),this.performLayout(e),this.render()}_syncMediaQueryListener(){if(typeof window>"u")return;let t=this.options.theme==="system";t&&!this.mediaQuery?(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.mediaQuery.addEventListener("change",this._onSystemThemeChange)):!t&&this.mediaQuery&&(this.mediaQuery.removeEventListener("change",this._onSystemThemeChange),this.mediaQuery=null)}processData(){let t=(this.options.series||[]).map(i=>{let s=(i.type||"").toLowerCase().replace(/[-_ ]/g,""),n=i.yAxisId;return!n&&s==="line"&&i.yKey&&/percent|cumulative|pareto/i.test(i.yKey)&&(n="right"),{...i,type:s,yAxisId:n}});this.options={...this.options,series:t};let{data:e}=this.options;if(this.emptyGroup.clear(),!e?.length||!t?.length){this.isCartesian=!1,this.initialized=!0,this.axesGroup.visible=!1,this.seriesGroup.clear(),this.legendGroup.visible=!1,this.legend.getGroup().visible=!1,this.series=[],this.seriesInstances.clear();return}if(this.isCartesian=t.every(i=>!Ft.has(i.type??"")),this.isCartesian){let i=new Set;this.minY=1/0,this.maxY=-1/0,t.some(a=>a.type==="scatter")?(this.categoryScale=new et,this.valueScale=new et):(this.categoryScale=new it,this.valueScale=new et);let n=t.filter(a=>a.type==="bar"&&(a.stacked||a.normalized)),r=t.filter(a=>a.type==="area"&&(a.stacked||a.normalized)),o=e.map(a=>n.reduce((f,b)=>f+(a[b.yKey]??0),0)),l=e.map(a=>r.reduce((f,b)=>f+(a[b.yKey]??0),0));n.length>0&&(t.some(a=>a.type==="bar"&&a.normalized)?this.maxY=100:e.forEach((a,f)=>{this.maxY=Math.max(this.maxY,o[f])})),r.length>0&&(t.some(a=>a.type==="area"&&a.normalized)?this.maxY=Math.max(this.maxY,100):e.forEach((a,f)=>{this.maxY=Math.max(this.maxY,l[f])}));let y=new Set,c=new Set;if(t.forEach(a=>{a.xKey&&y.add(a.xKey)}),t.forEach((a,f)=>{let b=a.yKey??a.angleKey??`s${f}`;!this.hiddenSeries.includes(b)&&a.yKey&&!a.stacked&&!a.normalized&&a.type!=="histogram"&&c.add(a.yKey)}),e.forEach(a=>{y.forEach(f=>{a[f]!==void 0&&i.add(a[f])}),c.forEach(f=>{let b=a[f];b>this.maxY&&(this.maxY=b),b<this.minY&&(this.minY=b)})}),this.categoryScale instanceof it)this.categoryScale.domain=Array.from(i);else{let a=Array.from(i).map(f=>typeof f=="number"?f:Number(new Date(f))).filter(f=>!isNaN(f));if(a.length>0){let f=Math.min(...a),b=Math.max(...a);this.categoryScale.domain=[f,b]}}if(this.valueScale instanceof it){let a=new Set;t.forEach(f=>{f.yKey&&e.forEach(b=>a.add(b[f.yKey]))}),this.valueScale.domain=Array.from(a)}else{let f=t.some(k=>k.type==="bar"||k.type==="area")?Math.min(0,this.minY):this.minY,b=this.maxY===-1/0?100:this.maxY;this.valueScale.domain=[f*(f<0?1.1:.98),b*1.05]}if(t.some(a=>a.yAxisId==="right")){let a=0,f=-1/0;t.forEach(b=>{b.yAxisId==="right"&&b.yKey&&e.forEach(k=>{let u=k[b.yKey];u>f&&(f=u),u<a&&(a=u)})}),this.valueScaleRight.domain=[a,(f===-1/0?100:f)*1.12]}let d=t.some(a=>a.type==="bar"&&a.direction==="horizontal"),p=this.themeManager.theme;this.axesGroup.clear(),d?(this.xAxis=new st(this.valueScale,{position:"bottom",fontSize:this.options.xAxisFontSize,fontFamily:this.options.xAxisFontFamily,rotation:this.options.xAxisRotation,labelAlignment:this.options.xAxisLabelAlignment}),this.yAxis=new st(this.categoryScale,{position:"left",fontSize:this.options.yAxisFontSize,fontFamily:this.options.yAxisFontFamily,rotation:this.options.yAxisRotation,labelAlignment:this.options.yAxisLabelAlignment}),this.yAxisRight=void 0):(this.xAxis=new st(this.categoryScale,{position:"bottom",fontSize:this.options.xAxisFontSize,fontFamily:this.options.xAxisFontFamily,rotation:this.options.xAxisRotation,labelAlignment:this.options.xAxisLabelAlignment}),this.yAxis=new st(this.valueScale,{position:"left",fontSize:this.options.yAxisFontSize,fontFamily:this.options.yAxisFontFamily,rotation:this.options.yAxisRotation,labelAlignment:this.options.yAxisLabelAlignment}),t.some(a=>a.yAxisId==="right")?this.yAxisRight=new st(this.valueScaleRight,{position:"right",fontSize:this.options.yAxisRightFontSize??this.options.yAxisFontSize,fontFamily:this.options.yAxisRightFontFamily??this.options.yAxisFontFamily,rotation:this.options.yAxisRightRotation??this.options.yAxisRotation,labelAlignment:this.options.yAxisRightLabelAlignment??this.options.yAxisLabelAlignment}):this.yAxisRight=void 0),this.xAxis.setTheme(p),this.yAxis.setTheme(p),this.axesGroup.add(this.xAxis.getGroup()),this.axesGroup.add(this.yAxis.getGroup()),this.yAxisRight&&(this.yAxisRight.setTheme(p),this.axesGroup.add(this.yAxisRight.getGroup())),this.axesGroup.visible=!0}else this.axesGroup.visible=!1}createSeriesInstance(t,e){let i=this.themeManager.theme.palette,s=t.fill??i[e%i.length],n={...this.options.animation,...t.animation},r={...t,fill:s,stroke:t.stroke??s,animation:n};switch(t.type){case"bar":return new pt(r);case"line":return new mt(r);case"pie":return new dt({...t,fills:t.fills??i});case"donut":return new dt({...t,fills:t.fills??i,innerRadius:t.innerRadius??.6});case"area":return new ft(r);case"scatter":return new gt({...r,jitter:t.jitter});default:return null}}renderEmpty(){let{width:t,height:e}=this.container.getBoundingClientRect();if(!t||!e)return;let i=this.themeManager.theme,s=new K;s.text="\u2B1C",s.x=t/2,s.y=e/2-20,s.fontSize=26,s.fill=i.axisColor,s.textAlign="center",s.textBaseline="middle",this.emptyGroup.add(s);let n=new K;n.text="No data available",n.x=t/2,n.y=e/2+16,n.fontSize=13,n.fill=i.subtextColor,n.fontFamily=i.fontFamily,n.textAlign="center",n.textBaseline="middle",this.emptyGroup.add(n)}performLayout(t=!1){let{width:e,height:i}=this.container.getBoundingClientRect();if(!e||!i)return;this.axesGroup.opacity=1,this.seriesGroup.opacity=1;let s=this.options.padding??{top:4,right:4,bottom:0,left:4},n=s.top??4,r=i-(s.bottom??0),o=s.left??4,l=e-(s.right??4),y=s.inner??0,c=this.themeManager.theme;if(this.titleGroup.clear(),this.subtitleGroup.clear(),this.options.title){let A=new K;A.text=this.options.title.text,A.fontSize=this.options.title.fontSize??16,A.fontWeight="600",A.fill=c.textColor,A.fontFamily=c.fontFamily,A.x=e/2,A.y=n+A.fontSize,A.textAlign="center",this.titleGroup.add(A),n+=A.fontSize+8}if(this.options.subtitle){let A=new K;A.text=this.options.subtitle.text,A.fontSize=this.options.subtitle.fontSize??12,A.fill=c.subtextColor,A.fontFamily=c.fontFamily,A.x=e/2,A.y=n+A.fontSize,A.textAlign="center",this.subtitleGroup.add(A),n+=A.fontSize+6}let x=this.options.legend;if(x?.enabled!==!1&&this.options.series.length>1){let A=[],R=new Set(Ft);this.options.series.forEach((M,L)=>{let z=null;for(let[O,F]of this.seriesInstances.entries())if(O.startsWith(`${M.type}-${L}-`)){z=F;break}if(z||(z=this.createSeriesInstance(M,L),z&&R.has(M.type)&&this.seriesInstances.set(`${M.type}-${L}-null`,z)),z&&typeof z.getLegendData=="function"){let O=z.getLegendData(c,this.options.data);Array.isArray(O)&&O.length>0?A.push(...O):A.push({id:M.yKey??M.angleKey??`s${L}`,label:M.title??M.yKey??M.angleKey??`Series ${L+1}`,fill:M.fill??c.palette[L%c.palette.length],markerType:M.type==="line"||M.type==="scatter"?"circle":"square"})}else A.push({id:M.yKey??M.angleKey??`s${L}`,label:M.title??M.yKey??M.angleKey??`Series ${L+1}`,fill:M.fill??c.palette[L%c.palette.length],markerType:M.type==="line"||M.type==="scatter"?"circle":"square"})}),this.legend.setHiddenSeries([...this.hiddenSeries]);let v=x?.position??"bottom",Y=v==="left"||v==="right"?Math.min(e*.3,200):e;this.legend.update(A,c,Y,i,v),this.legendGroup.visible=!0,this.legendGroup.opacity=1;let P=this.legend.getGroup();P.visible=!0,P.opacity=1;let T=this.legend.getBBox();if(T.width>0&&T.height>0){let M=0,L=0;v==="bottom"?(M=(e-T.width)/2-T.x,L=r-T.height-T.y,r-=T.height+10):v==="top"?(M=(e-T.width)/2-T.x,L=n-T.y,n+=T.height+10):v==="left"?(M=o-T.x,L=(i-T.height)/2-T.y,o+=T.width+10):v==="right"&&(M=l-T.width-T.x,L=(i-T.height)/2-T.y,l-=T.width+10),P.translation={x:M,y:L},this.legendProxy&&(this.legendProxy.style.display="block",this.legendProxy.style.left=`${M+T.x}px`,this.legendProxy.style.top=`${L+T.y}px`,this.legendProxy.style.width=`${T.width}px`,this.legendProxy.style.height=`${T.height}px`)}else v==="bottom"?(P.translation={x:0,y:r-24},r-=24):v==="top"&&(P.translation={x:0,y:n},n+=24),this.legendProxy&&(this.legendProxy.style.display="none")}else this.legendGroup.visible=!1,this.legendProxy&&(this.legendProxy.style.display="none");let p=this.options.showXAxis!==!1,a=this.options.showYAxis!==!1,f=this.options.showYAxisRight!==!1,b=this.scene.getContext(),k=0,u=0,S=0,w=0,h=12;if(this.isCartesian&&this.yAxis&&a){this.yAxis.setTheme(c),this.yAxis.updateOptions({fontSize:this.options.yAxisFontSize,fontFamily:this.options.yAxisFontFamily,rotation:this.options.yAxisRotation,labelAlignment:this.options.yAxisLabelAlignment}),k=this.yAxis.getRequiredSpace(b).size+h;let A=e*.4;k>A?(k=A,this.yAxis.setLayoutMaxWidth(k-h)):this.yAxis.setLayoutMaxWidth(0)}this.isCartesian&&this.yAxisRight&&f&&(this.yAxisRight.setTheme(c),this.yAxisRight.updateOptions({fontSize:this.options.yAxisRightFontSize??this.options.yAxisFontSize,fontFamily:this.options.yAxisRightFontFamily??this.options.yAxisFontFamily,rotation:this.options.yAxisRightRotation??this.options.yAxisRotation,labelAlignment:this.options.yAxisRightLabelAlignment??this.options.yAxisLabelAlignment}),u=this.yAxisRight.getRequiredSpace(b).size+h),this.isCartesian&&this.xAxis&&p&&(this.xAxis.setTheme(c),this.xAxis.updateOptions({fontSize:this.options.xAxisFontSize,fontFamily:this.options.xAxisFontFamily,rotation:this.options.xAxisRotation,labelAlignment:this.options.xAxisLabelAlignment}),S=this.xAxis.getRequiredSpace(b).size),this.seriesRect={x:o+k,y:n+w,width:l-o-k-u,height:r-n-S-w};let g=this.seriesRect,C={x:g.x+y,y:g.y+y,width:g.width-y*2,height:g.height-y*2};if(this.isCartesian&&this.xAxis&&this.yAxis){this.xAxis.setTheme(c),this.yAxis.setTheme(c),this.xAxis.getGroup().translation={x:g.x,y:g.y+g.height},this.xAxis.update(g.width,0,p,y),this.yAxis.getGroup().translation={x:g.x-h,y:g.y},this.yAxis.update(g.height,g.width+h,a,y,h),this.yAxisRight&&(this.yAxisRight.getGroup().translation={x:g.x+g.width+h,y:g.y},this.yAxisRight.update(g.height,g.width+h,f,y)),this.seriesGroup.translation={x:g.x,y:g.y},this.seriesGroup.clipRect={x:0,y:0,width:g.width,height:g.height},this.seriesGroup.clear();let A=[],R=this.options.data;this.options.series.forEach((v,_)=>{let Y=v.yKey??v.angleKey??`s${_}`;if(this.hiddenSeries.includes(Y))return;let P=v.type==="bar"&&v.direction==="horizontal",T=P?this.yAxis?.scale:this.xAxis?.scale,M=v.yAxisId==="right"&&this.yAxisRight?this.yAxisRight.scale:P?this.xAxis?.scale:this.yAxis?.scale,L=v.type==="line"||v.type==="area",z=`${v.type}-${_}-null`,O=this.seriesInstances.get(z);if(O||(O=this.createSeriesInstance(v,_),O&&this.seriesInstances.set(z,O)),!O)return;A.push(O),this.seriesGroup.add(O.getGroup());let F={x:0,y:0,width:g.width,height:g.height},nt=L&&R.length>1e3?{...v,marker:{...v.marker,enabled:!1}}:v;if(O instanceof pt){let U=this.options.series.filter(G=>G.type==="bar"),V,$;if(v.stacked||v.normalized){let G=U.filter(I=>I.stacked||I.normalized),N=G.indexOf(v);V=R.map(I=>G.slice(0,N).reduce((E,Ct)=>E+(I[Ct.yKey]??0),0)),$=R.map(I=>G.reduce((E,Ct)=>E+(I[Ct.yKey]??0),0))}O.update(R,T,M,F,!0,_,U.length,V,$,v)}else if(O instanceof ft){let U,V;if(v.stacked||v.normalized){let $=this.options.series.filter(N=>N.type==="area"&&(N.stacked||N.normalized)),G=$.indexOf(v);U=R.map(N=>$.slice(0,G).reduce((I,E)=>I+(N[E.yKey]??0),0)),V=R.map(N=>$.reduce((I,E)=>I+(N[E.yKey]??0),0))}O.update(R,T,M,F,!0,U,nt,V)}else(O instanceof mt||O instanceof gt)&&O.update(R,T,M,F,!0,nt)}),this.series=A}else{this.seriesGroup.translation={x:0,y:0},this.seriesGroup.clipRect={x:g.x-y,y:g.y-y,width:g.width+y*2,height:g.height+y*2},this.seriesGroup.clear();let A=[];this.options.series.forEach((R,v)=>{let _=R.yKey??R.angleKey??`s${v}`;if(this.hiddenSeries.includes(_))return;let Y=`${R.type}-${v}-null`,P=this.seriesInstances.get(Y);P||(P=this.createSeriesInstance(R,v),P&&this.seriesInstances.set(Y,P)),P&&(A.push(P),this.seriesGroup.add(P.getGroup()),P instanceof dt&&P.update(this.options.data,g,t,R))}),this.series=A}}render(){this.scene.render()}exportToPng(t="chart.png"){let i=this.scene.getCanvas().toDataURL("image/png"),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s)}destroy(){this.stopLoop(),this.resizeObserver.disconnect(),this.mediaQuery&&(this.mediaQuery.removeEventListener("change",this._onSystemThemeChange),this.mediaQuery=null),this.container.removeEventListener("keydown",this._onKeyDown),this.container.removeEventListener("pointerleave",this._onPointerLeave),this.scene.destroy(),this.tooltipStore.destroy(),this.legendProxy&&(this.legendProxy.remove(),this.legendProxy=void 0)}};import{createContext as se,useContext as ne}from"react";var Yt=se(null);function Wt(){let m=ne(Yt);if(!m)throw new Error("useTooltipStore must be used within a RadiantChart or Chart component. Make sure your component is wrapped in a chart provider.");return m}var le=["xKey","yKey","labelKey","angleKey","sizeKey"];function he(m){let t=new Set;for(let e of m)for(let i of le){let s=e[i];typeof s=="string"&&t.add(s)}return Array.from(t)}var de=oe(function({options:t,width:e="100%",height:i="100%",className:s,style:n},r){let o=_t(null),l=_t(null),y=_t(null),[c,x]=Pt(!1),[d,p]=Pt(null);ae(r,()=>({exportToPng(w){l.current?.exportToPng(w)}}),[]);let a=Gt(()=>({...t,series:t.series||[],data:t.data||[],onFocusChange:w=>p(w)}),[t]);re(()=>(o.current&&!l.current&&(l.current=new At(o.current,{...a,onFocusChange:w=>p(w)}),y.current=l.current.getTooltipStore()),()=>{l.current?.destroy(),l.current=null}),[]),Rt(()=>{if(c)return;if(typeof window>"u"){x(!0);return}let w=!1,h=window.requestAnimationFrame(()=>{w||x(!0)});return()=>{w=!0,window.cancelAnimationFrame(h)}},[c]),Rt(()=>{l.current?.update(a)},[a,c]),Rt(()=>{l.current?.update(a)},[t.theme]);let[f,b]=Pt(()=>ct.resolveIsDark(t.theme));Rt(()=>{if(t.theme!=="system"||typeof window>"u")return;let w=window.matchMedia("(prefers-color-scheme: dark)"),h=()=>b(w.matches);return b(w.matches),w.addEventListener("change",h),()=>w.removeEventListener("change",h)},[t.theme]);let k=t.theme==="system"?f:t.theme==="dark",u=Gt(()=>he(a.series),[a.series]),S=s||"";return W.createElement(Yt.Provider,{value:y.current},W.createElement("div",{ref:o,"data-radiant-chart":!0,className:S,style:{position:"relative",width:e,height:i,minHeight:typeof i=="number"?void 0:"100px",display:"block",overflow:"hidden",backgroundColor:k?"#020617":"#ffffff",...n}},!c&&W.createElement("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",gap:8,padding:"8px 10px 4px 4px",background:k?"#020617":"#ffffff"}},W.createElement("div",{style:{height:14,width:"35%",borderRadius:4,background:k?"#1e293b":"#f1f5f9",animation:"radiant-pulse 1.4s ease-in-out infinite"}}),W.createElement("div",{style:{flex:1,display:"flex",gap:6,alignItems:"flex-end",paddingTop:8}},[65,45,80,55,70,40,60].map((w,h)=>W.createElement("div",{key:h,style:{flex:1,height:`${w}%`,borderRadius:"3px 3px 0 0",background:k?"#1e293b":"#f1f5f9",animation:`radiant-pulse 1.4s ease-in-out ${h*.1}s infinite`}}))),W.createElement("div",{style:{height:8,borderRadius:4,background:k?"#1e293b":"#f1f5f9",animation:"radiant-pulse 1.4s ease-in-out infinite"}})),W.createElement("style",null,`
2
+ @keyframes radiant-pulse {
3
+ 0%, 100% { opacity: 1; }
4
+ 50% { opacity: 0.4; }
5
+ }
6
+ [data-radiant-chart] .radiant-toolbar { opacity: 0; transition: opacity 0.15s ease; }
7
+ [data-radiant-chart]:hover .radiant-toolbar { opacity: 1; }
8
+ `),t.toolbar?.showExport&&W.createElement("div",{className:"radiant-toolbar",style:{position:"absolute",top:8,right:8,zIndex:10,display:"flex",gap:4}},W.createElement("button",{type:"button",title:"Export as PNG","aria-label":"Export chart as PNG",onClick:()=>l.current?.exportToPng(t.title?.text?`${t.title.text.replace(/\s+/g,"-").toLowerCase()}.png`:"radiant-chart.png"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:6,border:k?"1px solid rgba(255,255,255,0.12)":"1px solid rgba(0,0,0,0.10)",background:k?"rgba(15,23,42,0.85)":"rgba(255,255,255,0.90)",color:k?"#94a3b8":"#64748b",cursor:"pointer",backdropFilter:"blur(4px)",boxShadow:k?"0 1px 4px rgba(0,0,0,0.4)":"0 1px 4px rgba(0,0,0,0.10)",padding:0,transition:"background 0.15s, color 0.15s"},onMouseEnter:w=>{w.currentTarget.style.background=k?"rgba(30,41,59,0.95)":"rgba(241,245,249,0.98)",w.currentTarget.style.color=k?"#e2e8f0":"#0f172a"},onMouseLeave:w=>{w.currentTarget.style.background=k?"rgba(15,23,42,0.85)":"rgba(255,255,255,0.90)",w.currentTarget.style.color=k?"#94a3b8":"#64748b"}},W.createElement("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},W.createElement("path",{d:"M8 1v9M5 7l3 3 3-3",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),W.createElement("path",{d:"M2 12v1.5A1.5 1.5 0 003.5 15h9A1.5 1.5 0 0014 13.5V12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})))),u.length>0&&a.data.length>0&&W.createElement("table",{className:"sr-only","aria-label":t.title?.text??"Chart data","aria-rowcount":a.data.length+1},W.createElement("thead",null,W.createElement("tr",{"aria-rowindex":1},u.map(w=>W.createElement("th",{key:w,scope:"col"},w)))),W.createElement("tbody",null,(()=>{let h=a.data.length,g=d===null?0:Math.max(0,d-Math.floor(10/2)),C=Math.min(h,g+10);return a.data.slice(g,C).map((A,R)=>{let v=g+R;return W.createElement("tr",{key:v,"aria-rowindex":v+2,"aria-selected":v===d},u.map(_=>W.createElement("td",{key:_},A[_]??"")))})})()))))}),Bt=de;import Nt,{useRef as Ht,useLayoutEffect as ce,useState as ue,useCallback as $t}from"react";var pe=({width:m="100%",height:t=300,minHeight:e=100,minWidth:i=0,aspect:s,debounce:n=0,className:r,style:o,children:l})=>{let y=Ht(null),[c,x]=ue(null),d=Ht(null),p=$t((b,k)=>{x({width:b,height:k})},[]),a=$t(b=>{for(let k of b){let{width:u,height:S}=k.contentRect;u===0&&S===0||(n>0?(d.current&&clearTimeout(d.current),d.current=setTimeout(()=>p(u,S),n)):p(u,S))}},[n,p]);ce(()=>{let b=y.current;if(!b)return;let k=b.getBoundingClientRect();(k.width>0||k.height>0)&&p(k.width,k.height);let u=new ResizeObserver(a);return u.observe(b),()=>{u.disconnect(),d.current&&clearTimeout(d.current)}},[a,p]);let f=s&&c?Math.max(e,c.width/s):t;return Nt.createElement("div",{ref:y,className:r,style:{position:"relative",width:m,height:f,minHeight:e,minWidth:i,overflow:"hidden",...o}},Nt.createElement("div",{style:{position:"absolute",inset:0}},l))},me=pe;import Tt,{createContext as fe,useContext as ge,useCallback as ye,useRef as yt,useEffect as at,useMemo as Z,useState as be}from"react";var Qt=fe(null);function ot(){let m=ge(Qt);if(!m)throw new Error("Radiant declarative components must be children of <Chart>.");return m}var xe=0;function lt(m){let t=yt("");return t.current===""&&(t.current=`${m}-${xe++}`),t.current}var ve=({data:m,theme:t,width:e,height:i,animation:s,padding:n,crosshair:r,tooltip:o,showExport:l,className:y,style:c,chartRef:x,children:d})=>{let p=yt(new Map),a=yt(new Map),f=yt(new Map),b=yt(new Map),[k,u]=be(0),S=ye(()=>u(g=>g+1),[]),w=Z(()=>({registerSeries:(g,C)=>{p.current.set(g,C),S()},unregisterSeries:g=>{p.current.delete(g),S()},registerAxis:(g,C)=>{a.current.set(g,C),S()},unregisterAxis:g=>{a.current.delete(g),S()},registerTitle:(g,C)=>{f.current.set(g,C),S()},unregisterTitle:g=>{f.current.delete(g),S()},registerLegend:(g,C)=>{b.current.set(g,C),S()},unregisterLegend:g=>{b.current.delete(g),S()}}),[S]),h=Z(()=>{let g=[];p.current.forEach(I=>{g.push(I)}),g.length===0&&g.push({type:"bar",xKey:"x",yKey:"y"});let C,A,R,v,_,Y,P,T,M,L,z,O,F,nt,U;a.current.forEach(({axis:I,props:E})=>{I==="x"?(C=E.show??!0,v=E.fontSize,_=E.fontFamily,Y=E.rotation,P=E.labelAlignment):I==="y"?(A=E.show??!0,T=E.fontSize,M=E.fontFamily,L=E.rotation,z=E.labelAlignment):I==="y-right"&&(R=E.show??!0,O=E.fontSize,F=E.fontFamily,nt=E.rotation,U=E.labelAlignment)});let V,$;f.current.forEach(I=>{I.kind==="title"?V=I.props:$=I.props});let G;b.current.forEach(I=>{G={enabled:I.enabled??!0,position:I.position}});let N;return Tt.Children.forEach(d,I=>{Tt.isValidElement(I)&&I.type===Dt&&(N=I.props)}),{data:m,theme:t,animation:s,padding:n,crosshair:r,tooltip:N?{...o,...N}:o,toolbar:l?{showExport:!0}:void 0,title:V,subtitle:$,legend:G,showXAxis:C,showYAxis:A,showYAxisRight:R,xAxisFontSize:v,xAxisFontFamily:_,xAxisRotation:Y,xAxisLabelAlignment:P,yAxisFontSize:T,yAxisFontFamily:M,yAxisRotation:L,yAxisLabelAlignment:z,yAxisRightFontSize:O,yAxisRightFontFamily:F,yAxisRightRotation:nt,yAxisRightLabelAlignment:U,series:g}},[m,t,s,n,r,o,l,d,k]);return Tt.createElement(Qt.Provider,{value:w},d,Tt.createElement(Bt,{ref:x,options:h,width:e,height:i,className:y,style:c}))};function ut(m,t){let e=i=>{let s=lt(m),n=ot(),r=Z(()=>({type:m,...i}),[JSON.stringify(i)]);return at(()=>(n.registerSeries(s,r),()=>n.unregisterSeries(s)),[n,s,r]),null};return e.displayName=t,e}var ke=ut("bar","Bar"),we=ut("line","Line"),Se=ut("area","Area"),Ae=ut("scatter","Scatter"),Re=ut("pie","Pie"),Te=ut("donut","Donut"),qt=m=>{let t=lt("x-axis"),e=ot(),i=Z(()=>({axis:"x",props:m}),[JSON.stringify(m)]);return at(()=>(e.registerAxis(t,i),()=>e.unregisterAxis(t)),[e,t,i]),null};qt.displayName="XAxis";var jt=m=>{let t=lt("y-axis"),e=ot(),i=Z(()=>({axis:"y",props:m}),[JSON.stringify(m)]);return at(()=>(e.registerAxis(t,i),()=>e.unregisterAxis(t)),[e,t,i]),null};jt.displayName="YAxis";var Ut=m=>{let t=lt("y-axis-right"),e=ot(),i=Z(()=>({axis:"y-right",props:m}),[JSON.stringify(m)]);return at(()=>(e.registerAxis(t,i),()=>e.unregisterAxis(t)),[e,t,i]),null};Ut.displayName="YAxisRight";var Vt=m=>{let t=lt("title"),e=ot(),i=Z(()=>({kind:"title",props:m}),[JSON.stringify(m)]);return at(()=>(e.registerTitle(t,i),()=>e.unregisterTitle(t)),[e,t,i]),null};Vt.displayName="Title";var Jt=m=>{let t=lt("subtitle"),e=ot(),i=Z(()=>({kind:"subtitle",props:m}),[JSON.stringify(m)]);return at(()=>(e.registerTitle(t,i),()=>e.unregisterTitle(t)),[e,t,i]),null};Jt.displayName="Subtitle";var Zt=m=>{let t=lt("legend"),e=ot(),i=Z(()=>({enabled:m.enabled,position:m.position}),[m.enabled,m.position]);return at(()=>(e.registerLegend(t,i),()=>e.unregisterLegend(t)),[e,t,i]),null};Zt.displayName="Legend";var Dt=()=>null;Dt.displayName="Tooltip";import{useSyncExternalStore as Ce,useCallback as Oe}from"react";function Me(){let m=Wt(),t=Ce(m.subscribe.bind(m),m.getState.bind(m),()=>m.getState()),e=Oe(()=>m.hide(),[m]);return{active:t.active,entries:t.entries,sharedLabel:t.sharedLabel,pointerX:t.pointerX,pointerY:t.pointerY,anchorX:t.anchorX,anchorY:t.anchorY,localX:t.localX,localY:t.localY,hide:e}}export{Se as Area,ke as Bar,ve as Chart,Te as Donut,Zt as Legend,we as Line,Re as Pie,Bt as RadiantChart,me as ResponsiveContainer,Ae as Scatter,Jt as Subtitle,Vt as Title,Dt as Tooltip,qt as XAxis,jt as YAxis,Ut as YAxisRight,Me as useChartTooltip};
9
+ //# sourceMappingURL=index.mjs.map