uplot-plus 0.3.1 → 0.4.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/README.md +107 -225
- package/dist/index.cjs +1 -1
- package/dist/index.js +2583 -2314
- package/dist/src/annotations.d.ts.map +1 -1
- package/dist/src/axes/layout.d.ts.map +1 -1
- package/dist/src/components/Axis.d.ts +0 -3
- package/dist/src/components/Axis.d.ts.map +1 -1
- package/dist/src/components/BoxWhisker.d.ts +24 -0
- package/dist/src/components/BoxWhisker.d.ts.map +1 -0
- package/dist/src/components/Candlestick.d.ts +18 -0
- package/dist/src/components/Candlestick.d.ts.map +1 -0
- package/dist/src/components/Chart.d.ts +1 -1
- package/dist/src/components/Chart.d.ts.map +1 -1
- package/dist/src/components/FloatingLegend.d.ts.map +1 -1
- package/dist/src/components/Heatmap.d.ts +14 -0
- package/dist/src/components/Heatmap.d.ts.map +1 -0
- package/dist/src/components/Scale.d.ts +0 -3
- package/dist/src/components/Scale.d.ts.map +1 -1
- package/dist/src/components/Series.d.ts +0 -3
- package/dist/src/components/Series.d.ts.map +1 -1
- package/dist/src/components/Sparkline.d.ts.map +1 -1
- package/dist/src/components/Vector.d.ts +16 -0
- package/dist/src/components/Vector.d.ts.map +1 -0
- package/dist/src/components/ZoomRanger.d.ts.map +1 -1
- package/dist/src/components/annotations/HLine.d.ts.map +1 -1
- package/dist/src/components/annotations/Region.d.ts.map +1 -1
- package/dist/src/components/annotations/VLine.d.ts.map +1 -1
- package/dist/src/components/annotations/useAnnotationDraw.d.ts +8 -0
- package/dist/src/components/annotations/useAnnotationDraw.d.ts.map +1 -0
- package/dist/src/core/CursorManager.d.ts +0 -5
- package/dist/src/core/CursorManager.d.ts.map +1 -1
- package/dist/src/core/DataStore.d.ts.map +1 -1
- package/dist/src/core/Scale.d.ts +5 -0
- package/dist/src/core/Scale.d.ts.map +1 -1
- package/dist/src/core/ScaleManager.d.ts.map +1 -1
- package/dist/src/hooks/useChartStore.d.ts +6 -4
- package/dist/src/hooks/useChartStore.d.ts.map +1 -1
- package/dist/src/hooks/useInteraction.d.ts +1 -2
- package/dist/src/hooks/useInteraction.d.ts.map +1 -1
- package/dist/src/hooks/useRegisterConfig.d.ts +16 -0
- package/dist/src/hooks/useRegisterConfig.d.ts.map +1 -0
- package/dist/src/index.d.ts +10 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/paths/bars.d.ts +2 -0
- package/dist/src/paths/bars.d.ts.map +1 -1
- package/dist/src/paths/linear.d.ts.map +1 -1
- package/dist/src/paths/points.d.ts.map +1 -1
- package/dist/src/paths/spline.d.ts.map +1 -1
- package/dist/src/paths/stepped.d.ts.map +1 -1
- package/dist/src/paths/types.d.ts +10 -1
- package/dist/src/paths/types.d.ts.map +1 -1
- package/dist/src/paths/utils.d.ts +0 -5
- package/dist/src/paths/utils.d.ts.map +1 -1
- package/dist/src/rendering/CanvasRenderer.d.ts +3 -33
- package/dist/src/rendering/CanvasRenderer.d.ts.map +1 -1
- package/dist/src/rendering/drawCursor.d.ts.map +1 -1
- package/dist/src/rendering/drawRangeBox.d.ts +29 -0
- package/dist/src/rendering/drawRangeBox.d.ts.map +1 -0
- package/dist/src/time/timeIncrs.d.ts.map +1 -1
- package/dist/src/time/timeSplits.d.ts +1 -1
- package/dist/src/time/timeSplits.d.ts.map +1 -1
- package/dist/src/types/chart.d.ts +6 -31
- package/dist/src/types/chart.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +3 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/interaction.d.ts +62 -0
- package/dist/src/types/interaction.d.ts.map +1 -0
- package/package.json +2 -3
- package/dist/src/paths/candlestick.d.ts +0 -35
- package/dist/src/paths/candlestick.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("react/jsx-runtime"),A=require("react");var Y=(e=>(e[e.Top=0]="Top",e[e.Right=1]="Right",e[e.Bottom=2]="Bottom",e[e.Left=3]="Left",e))(Y||{}),B=(e=>(e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e))(B||{}),K=(e=>(e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward",e))(K||{}),N=(e=>(e[e.Linear=1]="Linear",e[e.Ordinal=2]="Ordinal",e[e.Log=3]="Log",e[e.Asinh=4]="Asinh",e))(N||{}),xe=(e=>(e[e.Ascending=1]="Ascending",e[e.Descending=-1]="Descending",e[e.Unsorted=0]="Unsorted",e))(xe||{});function ge(e){return e%2}var te=(e=>(e[e.None=0]="None",e[e.Scales=1]="Scales",e[e.Axes=2]="Axes",e[e.Paths=4]="Paths",e[e.Cursor=8]="Cursor",e[e.Select=16]="Select",e[e.Size=32]="Size",e[e.Full=63]="Full",e))(te||{});const Z=Math,ze=Z.PI,de=Z.abs,oe=Z.floor,X=Z.round,Ce=Z.ceil,Ge=Z.min,be=Z.max,we=Z.pow,Ze=Z.sign,ne=Z.log10,Se=Z.log2,Vt=(e,t=1)=>Z.sinh(e)*t,We=(e,t=1)=>Z.asinh(e/t),O=1/0,wt=Number.isInteger;function Fe(e,t){return e[t]??0}function re(e,t,n=0,s=t.length-1){let l;const i=s<=2147483647;for(;s-n>1;)l=i?n+s>>1:oe((n+s)/2),Fe(t,l)<e?n=l:s=l;return e-Fe(t,n)<=Fe(t,s)-e?n:s}const xt=e=>e!=null,bt=e=>e!=null&&e>0;function vt(e){return(t,n,s)=>{let l=-1,i=-1;for(let o=n;o<=s;o++)if(e(t[o])){l=o;break}for(let o=s;o>=n;o--)if(e(t[o])){i=o;break}return[l,i]}}const Pe=vt(xt),St=vt(bt);function jt(e,t,n,s=xe.Unsorted,l=!1){const i=l?St:Pe,o=l?bt:xt,[r,a]=i(e,t,n);let f=e[r]??O,u=e[r]??-O;if(r>-1)if(s===xe.Ascending)f=e[r]??O,u=e[a]??-O;else if(s===xe.Descending)f=e[a]??O,u=e[r]??-O;else for(let d=r;d<=a;d++){const c=e[d];c!=null&&o(c)&&(c<f?f=c:c>u&&(u=c))}return[f,u]}function ae(e,t=0){if(wt(e))return e;const n=10**t,s=e*n*(1+Number.EPSILON);return X(s)/n}const ve=new Map;function Bt(e){return(String(e).split(".")[1]??"").length}const Xt=/\.\d*?(?=9{6,}|0{6,})/gm;function ke(e){if(wt(e)||ve.has(e))return e;const t=`${e}`,n=t.match(Xt);if(n==null)return e;const s=n[0].length-1;if(t.indexOf("e-")!==-1){const l=t.split("e"),i=l[0]??"0",o=l[1]??"0";return+`${ke(+i)}e${o}`}return ae(e,s)}function Ve(e,t,n=!0){return n?ke(Ce(ke(e/t))*t):Ce(e/t)*t}function Mt(e,t,n=!0){return n?ke(oe(ke(e/t))*t):oe(e/t)*t}function yt(e,t,n,s){const l=[],i=s.map(Bt);for(let o=t;o<n;o++){const r=de(o);for(let a=0;a<s.length;a++){const f=s[a]??0,u=i[a]??0,d=+`${f}e${o}`,c=(o>=0?0:r)+(o>=u?0:u),h=d;l.push(h),ve.set(h,c)}}return l}function q(e,t,n){return Ge(be(e,t),n)}const Yt=new Intl.NumberFormat,Ct=e=>Yt.format(e);function Je(e,t,n){for(;t<=n;){if(e[t]!=null)return!0;t++}return!1}const Kt=.1,le={mode:3,pad:Kt,soft:null},ye={pad:0,soft:null,mode:0},Ut={min:ye,max:ye};function _e(e,t,n,s){let l;typeof n=="number"?(ye.pad=n,ye.soft=null,ye.mode=0,l=Ut):l=n;const i=l.min,o=l.max,r=i.pad,a=o.pad,f=i.hard??-O,u=o.hard??O,d=i.soft??O,c=o.soft??-O,h=i.mode,m=o.mode;let v=t-e;const C=ne(v),g=be(de(e),de(t)),y=ne(g),L=de(y-C);(v<1e-24||L>10)&&(v=0,(e===0||t===0)&&(v=1e-24));const T=v||g||1e3,E=ne(T),D=we(10,oe(E)),S=T*(v===0?e===0?.1:1:r),M=ae(Mt(e-S,D/10),24),P=h===1||h===3&&M<=d||h===2&&M>=d,R=e>=d&&P?d:O,p=be(f,M<R&&e>=R?R:Ge(R,M)),w=T*(v===0?t===0?.1:1:a),x=ae(Ve(t+w,D/10),24),b=m===1||m===3&&x>=c||m===2&&x<=c,k=t<=c&&b?c:-O,I=Ge(u,x>k&&t<=k?k:be(k,x));return p===I&&p===0?[-1,1]:[p,I]}function Nt(e,t,n,s){n===2&&(s=!0);const l=Ze(e),i=Ze(t);e===t&&(l===-1?(e*=n,t/=n):(e/=n,t*=n));const o=n===10?ne:Se,r=l===1?oe:Ce,a=i===1?Ce:oe,f=o(de(e)),u=o(de(t)),d=r(f),c=a(u);let h=we(n,d),m=we(n,c);return n===10&&(d<0&&(h=ae(h,-d)),c<0&&(m=ae(m,-c))),s?(e=h*l,t=m*i):(e=Mt(e,we(n,oe(f)),!1),t=Ve(t,we(n,oe(u)),!1)),[e,t]}function Qe(e){return(ne((e^e>>31)-(e>>31))|0)+1}function Ot(e,t,n,s,l){const i=be(Qe(e),Qe(t)),o=t-e;let r=be(0,re(l/s*o,n)-1);do{const a=n[r]??0,f=s*a/o;if(f>=l*.9&&i+(a<5?ve.get(a)??0:0)<=17)return[a,f]}while(++r<n.length);return[0,0]}function qt(e){return{id:e.id,min:e.min??null,max:e.max??null,distr:e.distr??N.Linear,log:e.log??10,asinh:e.asinh??1,ori:e.ori??(e.id==="x"?B.Horizontal:B.Vertical),dir:e.dir??K.Forward,time:e.time??!1,auto:e.auto??!0,range:e.range??null,_discrete:!1,_cfgMin:e.min??null,_cfgMax:e.max??null,_min:null,_max:null}}function fe(e){e._min=null,e._max=null}function kt(e){if(e._min!=null)return e._min;const{min:t,distr:n}=e;if(t==null)return 0;if(n===N.Log){t<=0&&console.warn(`[uPlot+] Log scale "${e.id}": min value ${t} <= 0, clamping to 1e-10`);const s=t>0?t:1e-10;e._min=(e.log===10?ne:Se)(s)}else n===N.Asinh?e._min=We(t,e.asinh):e._min=t;return e._min}function Tt(e){if(e._max!=null)return e._max;const{max:t,distr:n}=e;if(t==null)return 0;if(n===N.Log){t<=0&&console.warn(`[uPlot+] Log scale "${e.id}": max value ${t} <= 0, clamping to 1e-10`);const s=t>0?t:1e-10;e._max=(e.log===10?ne:Se)(s)}else n===N.Asinh?e._max=We(t,e.asinh):e._max=t;return e._max}function Zt(e,t){if(t.min==null||t.max==null)return 0;const n=kt(t),l=Tt(t)-n;if(l===0)return 0;const{distr:i}=t;if(i===N.Log){const o=t.log===10?ne:Se,r=e>0?e:1e-10;return(o(r)-n)/l}return i===N.Asinh?(We(e,t.asinh)-n)/l:(e-n)/l}function Jt(e,t){if(t.min==null||t.max==null)return 0;const n=kt(t),s=Tt(t);if(s===n)return t.min;const{distr:l}=t;return l===N.Log?Math.pow(t.log,n+e*(s-n)):l===N.Asinh?Vt(n+e*(s-n),t.asinh):n+e*(s-n)}function j(e,t,n,s){const l=Zt(e,t);let i;return t.ori===B.Horizontal?i=t.dir===K.Forward?l:1-l:i=t.dir===K.Forward?1-l:l,s+i*n}function se(e,t,n,s){if(n===0)return t.min??0;let l=(e-s)/n;return t.ori===B.Horizontal?t.dir===K.Backward&&(l=1-l):t.dir!==K.Backward&&(l=1-l),Jt(l,t)}class Qt{constructor(){this.scales=new Map,this.groupXScales=new Map}addScale(t){this.scales.set(t.id,qt(t))}removeScale(t){this.scales.delete(t)}getScale(t){return this.scales.get(t)}getAllScales(){return this.scales.values()}setGroupXScale(t,n){this.groupXScales.set(t,n)}getGroupXScaleKey(t){return this.groupXScales.get(t)}setRange(t,n,s){const l=this.scales.get(t);l&&(l.min=n,l.max=s,fe(l))}autoRangeX(t){var s,l,i,o,r,a;const n=new Map;for(const[f,u]of this.groupXScales){const d=this.scales.get(u);if(!d||!d.auto)continue;const c=t[f];if(!c||c.x.length===0)continue;const h=c.x[0],m=c.x[c.x.length-1];if(h==null||m==null)continue;const v=n.get(u);v?(v.dataMin=Math.min(v.dataMin,h),v.dataMax=Math.max(v.dataMax,m),v.groups.push(f)):n.set(u,{dataMin:h,dataMax:m,groups:[f]})}for(const[f,{dataMin:u,dataMax:d,groups:c}]of n){const h=this.scales.get(f);if(!h)continue;let m=!0,v=O;for(const C of c){const g=t[C];if(g){for(let y=0;y<g.x.length;y++)if(Number.isInteger(g.x[y])||(m=!1),y>0){const L=g.x[y]-g.x[y-1];L>0&&L<v&&(v=L)}}}if(h._discrete=m,h.range){const[C,g]=_e(u,d,{min:{pad:((s=h.range.min)==null?void 0:s.pad)??0,soft:((l=h.range.min)==null?void 0:l.soft)??null,mode:((i=h.range.min)==null?void 0:i.mode)??0},max:{pad:((o=h.range.max)==null?void 0:o.pad)??0,soft:((r=h.range.max)==null?void 0:r.soft)??null,mode:((a=h.range.max)==null?void 0:a.mode)??0}});h.min=C,h.max=g}else if(u===d)[h.min,h.max]=_e(u,d,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}});else if(v<O){const C=v/2;h.min=u-C,h.max=d+C}else h.min=u,h.max=d;h._cfgMin!=null&&(h.min=h._cfgMin),h._cfgMax!=null&&(h.max=h._cfgMax),fe(h)}}autoRange(t,n,s){var o,r,a,f,u,d;const l=new Map,i=new Map;for(const{group:c,index:h,yScale:m}of n){const v=t[c];if(!v)continue;const C=v.series[h];if(!C||C.length===0)continue;const g=s.windows.get(c),y=g?g[0]:0,L=g?g[1]:C.length-1,T=this.scales.get(m),E=(T==null?void 0:T.distr)===N.Log,[D,S]=s.getCachedMinMax(c,h,y,L,0,E),M=l.get(m),P=i.get(m);l.set(m,M!=null?Math.min(M,D):D),i.set(m,P!=null?Math.max(P,S):S)}for(const[c,h]of l){const m=this.scales.get(c);if(!m||!m.auto)continue;const v=i.get(c)??-O;if(h===O)continue;let C,g;if(m.distr===N.Log)[C,g]=Nt(h,v,m.log,!1);else{const y=m.range??{min:le,max:le};[C,g]=_e(h,v,{min:{pad:((o=y.min)==null?void 0:o.pad)??le.pad,soft:((r=y.min)==null?void 0:r.soft)??le.soft,mode:((a=y.min)==null?void 0:a.mode)??le.mode},max:{pad:((f=y.max)==null?void 0:f.pad)??le.pad,soft:((u=y.max)==null?void 0:u.soft)??le.soft,mode:((d=y.max)==null?void 0:d.mode)??le.mode}})}m._cfgMin!=null&&(C=m._cfgMin),m._cfgMax!=null&&(g=m._cfgMax),m.min=C,m.max=g,fe(m)}}}const en=1024;class tn{constructor(t,n=en){this.data=t,this.len=t.length,this.blockSize=n,this.nBlocks=Math.ceil(t.length/n),this.blocks=new Float64Array(this.nBlocks*2),this.buildAll()}buildAll(){const{data:t,blockSize:n,nBlocks:s,blocks:l,len:i}=this;for(let o=0;o<s;o++){const r=o*n,a=Math.min(r+n,i);let f=1/0,u=-1/0;for(let d=r;d<a;d++){const c=t[d];c!=null&&(c<f&&(f=c),c>u&&(u=c))}l[o*2]=f,l[o*2+1]=u}}rangeMinMax(t,n){const{data:s,blockSize:l,blocks:i}=this;let o=1/0,r=-1/0;const a=Math.floor(t/l),f=Math.floor(n/l);if(a===f){for(let c=t;c<=n;c++){const h=s[c];h!=null&&(h<o&&(o=h),h>r&&(r=h))}return[o,r]}const u=(a+1)*l-1;for(let c=t;c<=u;c++){const h=s[c];h!=null&&(h<o&&(o=h),h>r&&(r=h))}for(let c=a+1;c<f;c++){const h=i[c*2]??1/0,m=i[c*2+1]??-1/0;h<o&&(o=h),m>r&&(r=m)}const d=f*l;for(let c=d;c<=n;c++){const h=s[c];h!=null&&(h<o&&(o=h),h>r&&(r=h))}return[o,r]}updateBlock(t){const{data:n,blockSize:s,blocks:l,len:i}=this;if(t>=this.nBlocks)return;const o=t*s,r=Math.min(o+s,i);let a=1/0,f=-1/0;for(let u=o;u<r;u++){const d=n[u];d!=null&&(d<a&&(a=d),d>f&&(f=d))}l[t*2]=a,l[t*2+1]=f}grow(t){const n=this.nBlocks;if(this.len=t,this.nBlocks=Math.ceil(t/this.blockSize),this.nBlocks>n){const l=new Float64Array(this.nBlocks*2);l.set(this.blocks),this.blocks=l}const s=Math.max(0,n-1);for(let l=s;l<this.nBlocks;l++)this.updateBlock(l)}setData(t){this.data=t}}class nn{constructor(){this.data=[],this.windows=new Map,this.minMaxCache=new Map,this.blockTrees=new Map}setData(t){this.data=t,this.windows.clear();for(const n of this.minMaxCache.values())n.clear();this.minMaxCache.clear(),this.blockTrees.clear()}getOrBuildTree(t,n){const s=`${t}:${n}`;let l=this.blockTrees.get(s);if(l)return l;const i=this.data[t];if(!i)return;const o=i.series[n];if(!(!o||o.length===0))return l=new tn(o),this.blockTrees.set(s,l),l}updateWindows(t){var s;let n=!1;for(let l=0;l<this.data.length;l++){const i=this.data[l],o=t(l),r=this.windows.get(l);let a,f;if(!i||!o||o.min==null||o.max==null)a=0,f=Math.max(0,((i==null?void 0:i.x.length)??1)-1);else{const u=i.x;if(u.length===0)a=0,f=0;else{a=re(o.min,u),f=re(o.max,u);const d=u[a],c=u[f];a>0&&d!=null&&d>o.min&&a--,f<u.length-1&&c!=null&&c<o.max&&f++}}(!r||r[0]!==a||r[1]!==f)&&(n=!0,(s=this.minMaxCache.get(l))==null||s.clear()),this.windows.set(l,[a,f])}return n}getWindow(t){var n;return this.windows.get(t)??[0,(((n=this.data[t])==null?void 0:n.x.length)||1)-1]}getXValues(t){var n;return((n=this.data[t])==null?void 0:n.x)??[]}getYValues(t,n){var s;return((s=this.data[t])==null?void 0:s.series[n])??[]}getCachedMinMax(t,n,s,l,i,o){let r=this.minMaxCache.get(t);const a=`${n}:${s}:${l}`;if(r){const h=r.get(a);if(h!=null)return h}else r=new Map,this.minMaxCache.set(t,r);const f=this.data[t];if(!f)return[1/0,-1/0];const u=f.series[n];if(!u||u.length===0)return[1/0,-1/0];let d;const c=!o&&i===xe.Unsorted?this.getOrBuildTree(t,n):void 0;return c?d=c.rangeMinMax(s,l):d=jt(u,s,l,i,o),r.set(a,d),d}getBlockTree(t,n){return this.getOrBuildTree(t,n)}appendData(t,n,s){var o;const l=this.data[t];if(!l)return;let i;Array.isArray(l.x)?i=l.x:(i=Array.from(l.x),l.x=i);for(let r=0;r<n.length;r++){const a=n[r];a!=null&&i.push(a)}for(let r=0;r<l.series.length;r++){let a=l.series[r];if(!a)continue;Array.isArray(a)||(a=Array.from(a),l.series[r]=a);const f=s[r];if(f){const d=a;for(let c=0;c<f.length;c++)d.push(f[c]??null)}const u=this.blockTrees.get(`${t}:${r}`);u&&(u.setData(a),u.grow(a.length))}(o=this.minMaxCache.get(t))==null||o.clear()}static toTypedX(t){for(const n of t)Array.isArray(n.x)&&(n.x=Float64Array.from(n.x));return t}}class sn{constructor(){this.state={left:-10,top:-10,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1},this._groupedConfigs=new Map,this._groupedConfigsSource=null}getGroupedConfigs(t){if(this._groupedConfigsSource!==t){this._groupedConfigsSource=t,this._groupedConfigs.clear();for(const n of t){if(n.show===!1)continue;let s=this._groupedConfigs.get(n.group);s==null&&(s=[],this._groupedConfigs.set(n.group,s)),s.push(n)}}return this._groupedConfigs}invalidateGroupedConfigs(){this._groupedConfigsSource=null}hide(){this.state.left=-10,this.state.top=-10,this.state.activeGroup=-1,this.state.activeSeriesIdx=-1,this.state.activeDataIdx=-1}update(t,n,s,l,i,o,r,a){this.state.left=t,this.state.top=n;let f=1/0,u=-1,d=-1,c=-1;const h=this.getGroupedConfigs(i);for(let m=0;m<l.length;m++){const v=l[m];if(v==null)continue;const C=v.x;if(C.length===0)continue;const g=a(m);if(g==null)continue;const y=o(g);if(y==null||y.min==null||y.max==null)continue;const[L,T]=r(m),E=s.width,D=s.left,S=se(t+D,y,E,D),M=re(S,C,L,T),P=[M];M>L&&P.push(M-1),M<T&&P.push(M+1);const R=new Map;for(const p of P){const w=C[p];if(w==null)continue;const x=j(w,y,E,D);for(const b of h.get(m)??[]){const k=v.series[b.index];if(k==null)continue;const I=k[p];if(I==null)continue;let z=R.get(b.yScale);if(z==null&&!R.has(b.yScale)&&(z=o(b.yScale),R.set(b.yScale,z)),z==null||z.min==null||z.max==null)continue;const _=s.height,F=s.top,H=j(I,z,_,F),G=t+D-x,$=n+F-H,V=G*G+$*$;if(V<f&&(f=V,u=m,d=b.index,c=p,V===0))break}if(f===0)break}}this.state.activeGroup=u,this.state.activeSeriesIdx=d,this.state.activeDataIdx=c}syncToValue(t,n){const s=n.dataStore.data;if(s.length===0)return;const l=s[0];if(l==null)return;const i=n.scaleManager.getGroupXScaleKey(0);if(i==null)return;const o=n.scaleManager.getScale(i);if(o==null||o.min==null||o.max==null)return;const[r,a]=n.dataStore.getWindow(0),f=re(t,l.x,r,a),u=l.x[f];if(u==null)return;const d=j(u,o,n.plotBox.width,n.plotBox.left);this.state.left=d-n.plotBox.left,this.state.activeGroup=0,this.state.activeDataIdx=f;let c=0,h=n.plotBox.height/2;for(const m of n.seriesConfigs){if(m.group!==0||m.show===!1)continue;const v=l.series[m.index];if(v==null)continue;const C=v[f];if(C==null)continue;const g=n.scaleManager.getScale(m.yScale);if(!(g==null||g.min==null||g.max==null)){h=j(C,g,n.plotBox.height,n.plotBox.top)-n.plotBox.top,c=m.index;break}}this.state.top=h,this.state.activeSeriesIdx=c}}class on{constructor(){this.flags=te.None,this.frameId=null,this.callback=null}mark(t){this.flags|=t,this.scheduleFrame()}has(t){return(this.flags&t)!==0}get dirty(){return this.flags}clear(){this.flags=te.None}onRedraw(t){this.callback=t}scheduleFrame(){this.frameId==null&&(this.frameId=requestAnimationFrame(()=>{this.frameId=null;const t=this.callback;t!=null&&t(),this.clear()}))}cancel(){this.frameId!=null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}dispose(){this.cancel(),this.callback=null,this.flags=te.None}}function Re(e,t,n){e.lineTo(t,n)}function De(e,t,n){e.lineTo(n,t)}function je(e,t,n,s,l,i){const o=[];let r=-1;const a=l===K.Forward?n:s,f=l===K.Forward?s:n,u=l;for(let d=a;l===K.Forward?d<=f:d>=f;d+=u)if(t[d]===null||t[d]===void 0){if(r===-1){const c=q(d-l,n,s);r=i(e[c])}}else r!==-1&&(o.push([r,i(e[d])]),r=-1);return r!==-1&&o.push([r,i(e[s])]),o}function Be(e,t,n,s,l,i){const o=new Path2D;let r=t===B.Horizontal?n:s;const a=t===B.Horizontal?n+l:s+i,f=t===B.Horizontal?s:n,u=t===B.Horizontal?i:l;for(const[d,c]of e)d>r&&(t===B.Horizontal?o.rect(r,f,d-r,u):o.rect(f,r,u,d-r)),r=c;return r<a&&(t===B.Horizontal?o.rect(r,f,a-r,u):o.rect(f,r,u,a-r)),o}function It(e){return(t,n,s,l,i,o)=>{s!==l&&(i!==s&&o!==s&&e(t,n,s),i!==l&&o!==l&&e(t,n,l),e(t,n,o))}}const ln=It(Re),rn=It(De);function At(){return(e,t,n,s,l,i,o,r,a,f,u,d,c)=>{const h=(c==null?void 0:c.spanGaps)??!1;if([a,f]=(s.distr===N.Log?St:Pe)(t,a,f),a===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const v=S=>d(j(S,n,l,o)),C=S=>d(j(S,s,i,r));let g,y;n.ori===B.Horizontal?(g=Re,y=ln):(g=De,y=rn);const L={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},T=L.stroke;let E=!1;if(f-a>=l*4){const S=I=>se(I,n,l,o);let M=null,P=0,R=0,p=0,w=v(e[u===K.Forward?a:f]);const x=v(e[a]),b=v(e[f]);let k=S(u===K.Forward?x+1:b-1);for(let I=u===K.Forward?a:f;I>=a&&I<=f;I+=u){const z=e[I],F=(u===K.Forward?z<k:z>k)?w:v(z),H=t[I];F===w?H!=null?(p=H,M==null?(g(T,F,C(p)),R=M=P=p):p<M?M=p:p>P&&(P=p)):H===null&&!h&&(E=!0):(M!=null&&y(T,w,C(M),C(P),C(R),C(p)),H!=null?(p=H,g(T,F,C(p)),M=P=R=p):(M=null,P=0,H===null&&!h&&(E=!0)),w=F,k=S(w+u))}M!=null&&(M!==P?y(T,w,C(M),C(P),C(R),C(p)):g(T,w,C(p)))}else for(let S=u===K.Forward?a:f;S>=a&&S<=f;S+=u){const M=t[S];M===null&&!h?E=!0:M!=null&&g(T,v(e[S]),C(M))}{const S=L.fill=new Path2D(T),M=(c==null?void 0:c.fillTo)??s.min??0,P=C(M);let R=o,p=o+l;u===K.Backward&&([p,R]=[R,p]),g(S,p,P),g(S,R,P)}if(E){const S=je(e,t,a,f,u,v);L.gaps=S,L.clip=Be(S,n.ori,o,r,l,i)}return L}}const et=new WeakMap;function tt(e,t,n){return typeof t=="string"?t:an(e,t,n)}function an(e,t,n){const s=et.get(t);if(s!=null&&s.left===n.left&&s.top===n.top&&s.width===n.width&&s.height===n.height)return s.grad;const l=e.createLinearGradient(0,n.top,0,n.top+n.height);for(const[i,o]of t.stops)l.addColorStop(i,o);return et.set(t,{grad:l,left:n.left,top:n.top,width:n.width,height:n.height}),l}function cn(e,t,n,s,l){if(t.show===!1)return;const i=t.alpha??1;e.save(),i<1&&(e.globalAlpha=i),n.clip&&e.clip(n.clip);const o=l??{left:0,top:0,width:e.canvas.width/s,height:e.canvas.height/s};if(t.fill&&n.fill&&(e.fillStyle=tt(e,t.fill,o),e.fill(n.fill)),t.stroke){const r=(t.width??1)*s;e.strokeStyle=tt(e,t.stroke,o),e.lineWidth=r,e.lineJoin=t.join??"round",e.lineCap=t.cap??"butt",t.dash&&e.setLineDash(t.dash.map(d=>d*s));const a=t.pxAlign??1,f=r%2/2;a===1&&f>0&&e.translate(f,f),e.stroke(n.stroke)}e.restore()}const un=At(),nt=64;class fn{constructor(){this.ctx=null,this.pxRatio=1,this.pathCache=new Map,this.pathCacheSize=0,this.bandCache=new Map,this.scaleStamp="",this.lruHead=null,this.lruTail=null,this.lruMap=new Map,this.snapshotCanvas=null,this.snapshotValid=!1,this.cachedFillStyle="",this.cachedStrokeStyle="",this.cachedLineWidth=-1,this.cachedFont="",this.cachedTextAlign="",this.cachedTextBaseline="",this.cachedGlobalAlpha=-1}lruKey(t,n,s){return`${t}:${n}:${s}`}lruUnlink(t){t.prev!=null?t.prev.next=t.next:this.lruHead=t.next,t.next!=null?t.next.prev=t.prev:this.lruTail=t.prev,t.prev=null,t.next=null}lruAppend(t){t.prev=this.lruTail,t.next=null,this.lruTail!=null?this.lruTail.next=t:this.lruHead=t,this.lruTail=t}setContext(t,n){this.ctx=t,this.pxRatio=n,this.resetPropertyCache()}resetPropertyCache(){this.cachedFillStyle="",this.cachedStrokeStyle="",this.cachedLineWidth=-1,this.cachedFont="",this.cachedTextAlign="",this.cachedTextBaseline="",this.cachedGlobalAlpha=-1}setFillStyle(t,n){n!==this.cachedFillStyle&&(t.fillStyle=n,this.cachedFillStyle=n)}setStrokeStyle(t,n){n!==this.cachedStrokeStyle&&(t.strokeStyle=n,this.cachedStrokeStyle=n)}setLineWidth(t,n){n!==this.cachedLineWidth&&(t.lineWidth=n,this.cachedLineWidth=n)}setFont(t,n){n!==this.cachedFont&&(t.font=n,this.cachedFont=n)}setTextAlign(t,n){n!==this.cachedTextAlign&&(t.textAlign=n,this.cachedTextAlign=n)}setTextBaseline(t,n){n!==this.cachedTextBaseline&&(t.textBaseline=n,this.cachedTextBaseline=n)}setGlobalAlpha(t,n){n!==this.cachedGlobalAlpha&&(t.globalAlpha=n,this.cachedGlobalAlpha=n)}saveSnapshot(t,n,s){const l=t.canvas;(this.snapshotCanvas==null||this.snapshotCanvas.width!==n||this.snapshotCanvas.height!==s)&&(this.snapshotCanvas=typeof OffscreenCanvas<"u"?new OffscreenCanvas(n,s):document.createElement("canvas"),this.snapshotCanvas.width=n,this.snapshotCanvas.height=s);const i=this.snapshotCanvas.getContext("2d");i!=null&&typeof i.drawImage=="function"&&(i.clearRect(0,0,n,s),i.drawImage(l,0,0),this.snapshotValid=!0)}restoreSnapshot(t){return!this.snapshotValid||this.snapshotCanvas==null||typeof t.drawImage!="function"?!1:(t.clearRect(0,0,t.canvas.width,t.canvas.height),t.drawImage(this.snapshotCanvas,0,0),!0)}invalidateSnapshot(){this.snapshotValid=!1}checkScaleStamp(t){let n="";const s=new Set;for(const l of t)for(const i of[l.xScale,l.yScale])s.has(i.id)||(s.add(i.id),n+=`${i.id}:${i.min}:${i.max};`);n!==this.scaleStamp&&(this.scaleStamp!==""&&this.clearCache(),this.scaleStamp=n)}windowKey(t,n){return`${t}:${n}`}getCachedPaths(t,n,s,l){const i=this.pathCache.get(t);if(i==null)return;const o=i.get(n);if(o==null)return;const r=this.windowKey(s,l);let a=o.get(r);if(a==null)for(const[f,u]of o){const d=f.indexOf(":"),c=+f.slice(0,d),h=+f.slice(d+1);if(c<=s&&h>=l){a=u;const m=this.lruMap.get(this.lruKey(t,n,f));m!=null&&m!==this.lruTail&&(this.lruUnlink(m),this.lruAppend(m));break}}else{const f=this.lruMap.get(this.lruKey(t,n,r));f!=null&&f!==this.lruTail&&(this.lruUnlink(f),this.lruAppend(f))}return a}setCachedPaths(t,n,s,l,i){if(this.pathCacheSize>=nt){const u=nt>>2;let d=this.lruHead;for(let c=0;c<u&&d!=null;c++){const h=d.next,m=this.pathCache.get(d.group);if(m!=null){const v=m.get(d.index);v!=null&&(v.delete(d.key),this.pathCacheSize--,v.size===0&&m.delete(d.index),m.size===0&&this.pathCache.delete(d.group))}this.lruMap.delete(this.lruKey(d.group,d.index,d.key)),d=h}this.lruHead=d,d!=null?d.prev=null:this.lruTail=null}let o=this.pathCache.get(t);o==null&&(o=new Map,this.pathCache.set(t,o));let r=o.get(n);r==null&&(r=new Map,o.set(n,r));const a=this.windowKey(s,l),f=this.lruKey(t,n,a);if(!r.has(a)){this.pathCacheSize++;const u={group:t,index:n,key:a,prev:null,next:null};this.lruAppend(u),this.lruMap.set(f,u)}r.set(a,i)}invalidateSeries(t,n){const s=this.pathCache.get(t);if(s==null)return;const l=s.get(n);if(l!=null){this.pathCacheSize-=l.size;for(const i of l.keys()){const o=this.lruKey(t,n,i),r=this.lruMap.get(o);r!=null&&(this.lruUnlink(r),this.lruMap.delete(o))}s.delete(n)}}clearGroupCache(t){const n=this.pathCache.get(t);if(n!=null){for(const[s,l]of n.entries()){this.pathCacheSize-=l.size;for(const i of l.keys()){const o=this.lruKey(t,s,i),r=this.lruMap.get(o);r!=null&&(this.lruUnlink(r),this.lruMap.delete(o))}}this.pathCache.delete(t)}for(const s of this.bandCache.keys())s.startsWith(`${t}:`)&&this.bandCache.delete(s);this.invalidateSnapshot()}clearCache(){this.pathCache.clear(),this.pathCacheSize=0,this.lruHead=null,this.lruTail=null,this.lruMap.clear(),this.bandCache.clear(),this.invalidateSnapshot()}bandKey(t,n,s,l,i){return`${t}:${n}:${s}:${l}:${i}`}getCachedBandPath(t,n,s,l,i){return this.bandCache.get(this.bandKey(t,n,s,l,i))}setCachedBandPath(t,n,s,l,i,o){this.bandCache.set(this.bandKey(t,n,s,l,i),o)}drawSeries(t,n,s){const l=this.ctx;if(l==null||t.config.show===!1)return;const i=t.config.group,o=t.config.index,[r,a]=t.window;let f=this.getCachedPaths(i,o,r,a);if(f==null){const u=t.config.paths??un,d=t.xScale.dir,c=T=>X(T),h=a-r,m=Math.max(1,Math.ceil(h*.1)),v=t.dataX.length,C=Math.max(0,r-m),g=Math.min(v-1,a+m),y=t.config.fillTo,L=typeof y=="function"?y(t.yScale.min??0,t.yScale.max??0):y;f=u(t.dataX,t.dataY,t.xScale,t.yScale,n.width,n.height,n.left,n.top,C,g,d,c,{fillTo:L,spanGaps:t.config.spanGaps}),this.setCachedPaths(i,o,C,g,f)}cn(l,t.config,f,s,n)}draw(t,n,s,l){const i=this.ctx;if(i==null)return;const o=this.pxRatio;i.clearRect(0,0,t*o,n*o),i.save(),i.scale(o,o),i.beginPath(),i.rect(s.left,s.top,s.width,s.height),i.clip();for(const r of l)this.drawSeries(r,s,1);i.restore(),this.resetPropertyCache()}}const Lt=[1,2,2.5,5],hn=yt(10,-32,0,Lt),dn=yt(10,0,32,Lt),ce=hn.concat(dn);function gn(e,t,n,s,l){if(n<=0||t<e)return[];const i=[],o=ve.get(n)??0,r=l?Math.ceil(e/n)*n:ae(Ve(e,n),o);for(let a=r;a<=t;a=ae(a+n,o))i.push(Object.is(a,-0)?0:a);return i}function st(e){return e.map(t=>Ct(t))}function pn(e,t,n){if(e<=0||t<=0||e>=t)return[];const s=[],i=oe((n===10?ne:Se)(e));let o=we(n,i);n===10&&(o=ce[re(o,ce)]??o);let r=o,a=o*n;n===10&&(a=ce[re(a,ce)]??a);let f=0;do{if(r>=e&&s.push(r),r=r+o,n===10&&!ve.has(r)){const u=ve.get(o)??0;r=ae(r,u)}r>=a*(1-1e-10)&&(o=r,a=o*n,n===10&&(a=ce[re(a,ce)]??a))}while(r<=t&&++f<1e4);return s}function mn(e,t){const n=t===10?ne:Se;return e.map(s=>{if(s===0)return!0;if(s<0)return!1;const l=n(s);return de(l-Math.round(l))<1e-10})}const wn=7,xn=50,bn=16;function vn(e,t){const s=Ct(Math.max(Math.abs(e),Math.abs(t))).length*wn;return Math.max(xn,s+bn)}function Sn(e,t,n,s){if(s<=0)return[0,0];const l=ge(e.side)===B.Vertical,i=e.space??(l?30:vn(t,n)),o=e.incrs??ce;return Ot(t,n,o,s,i)}const Mn=50;function yn(e,t,n){var r,a;if(e.size!=null)return e.size;const s=((r=e.ticks)==null?void 0:r.show)!==!1?((a=e.ticks)==null?void 0:a.size)??10:0,l=e.gap??5,i=12;if(ge(e.side)===B.Vertical&&t!=null){let f=0;for(const d of t)d.length>f&&(f=d.length);const u=f*7;return Math.max(50,s+l+u+4)}return Math.max(50,s+l+i+3)}function Cn(e){return{config:e,_show:e.show!==!1,_size:e.size??Mn,_pos:0,_lpos:0,_splits:null,_values:null,_incr:0,_space:0,_rotate:0}}const me=60,ue=3600,ie=86400,kn=604800,he=2592e3,Te=31536e3,Tn=[1,5,10,15,30,me,5*me,10*me,15*me,30*me,ue,2*ue,3*ue,4*ue,6*ue,12*ue,ie,2*ie,3*ie,7*ie,14*ie,he,2*he,3*he,6*he,Te];function In(e,t,n,s){const l=[];if(n<=0||e>=t)return l;let i;if(n>=Te){const o=new Date(e*1e3);for(o.setUTCMonth(0,1),o.setUTCHours(0,0,0,0),i=o.getTime()/1e3,i<e&&(o.setUTCFullYear(o.getUTCFullYear()+1),i=o.getTime()/1e3);i<=t;)l.push(i),o.setUTCFullYear(o.getUTCFullYear()+Math.round(n/Te)),i=o.getTime()/1e3;return l}if(n>=he){const o=new Date(e*1e3);o.setUTCDate(1),o.setUTCHours(0,0,0,0),i=o.getTime()/1e3;const r=Math.max(1,Math.round(n/he));if(i<e&&(o.setUTCMonth(o.getUTCMonth()+1),i=o.getTime()/1e3),r>1){const a=o.getUTCMonth(),f=Math.ceil((a+1)/r)*r;o.setUTCMonth(f-1),i=o.getTime()/1e3}for(;i<=t;)l.push(i),o.setUTCMonth(o.getUTCMonth()+r),i=o.getTime()/1e3;return l}if(n>=ie){const o=new Date(e*1e3);o.setUTCHours(0,0,0,0),i=o.getTime()/1e3,i<e&&(i+=ie)}else i=Math.ceil(e/n)*n;for(let o=0;;o++){const r=i+o*n;if(r>t)break;l.push(r)}return l}const ot=new Map;function An(e,t){const n=JSON.stringify(e)+(t??"");let s=ot.get(n);return s==null&&(s=new Intl.DateTimeFormat(void 0,{...e,timeZone:t}),ot.set(n,s)),s}function ee(e,t,n){const s=new Date(e*1e3);return An(t,n).format(s)}function Ln(e,t){return ee(e,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function Pn(e,t){return ee(e,{year:"numeric",month:"2-digit",day:"2-digit"},t)}function Rn(e,t){return ee(e,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function Dn(e,t){return ee(e,{hour:"2-digit",minute:"2-digit",hour12:!1},t)}function zn(e,t){return ee(e,{month:"short",day:"numeric"},t)}function Fn(e,t){return ee(e,{year:"numeric"},t)}function _n(e,t){return ee(e,{year:"numeric",month:"short"},t)}function En(e,t,n){let s;return t>=Te?s=Fn:t>=he?s=_n:t>=kn?s=Pn:t>=ie?s=zn:t>=ue?s=Dn:t>=me?s=Rn:s=Ln,e.map(l=>s(l,n))}function Hn(e,t,n,s,l){const i=t-e;if(i<=0||s<=0)return[0,0];for(const r of n){const a=i/r,f=s/a;if(f>=l)return[r,f]}const o=n[n.length-1]??Te;return[o,s/(i/o)]}const Gn=3;function $n(e,t,n,s,l){let i=!0;for(const o of e){const r=o.config;if(r.show===!1)continue;const a=t(r.scale);if(!a||a.min==null||a.max==null){o._show&&(i=!1,o._show=!1);continue}else o._show||(i=!1,o._show=!0);const f=r.side,d=ge(f)===B.Horizontal?n:s,{min:c,max:h}=a;let m,v;if(a.time){const g=r.space??80;[m,v]=Hn(c,h,Tn,d,g)}else[m,v]=Sn(r,c,h,d);if(a._discrete&&m>0&&m<1&&(m=1),o._incr=m,o._space=v,v===0)continue;if(r.splits)o._splits=r.splits(c,h,m,v);else if(a.time)o._splits=In(c,h,m);else if(a.distr===N.Log)o._splits=pn(c,h,a.log);else{const g=a.distr===N.Ordinal||a._discrete;o._splits=gn(c,h,m,v,g)}if(r.values)o._values=r.values(o._splits,v,m);else if(a.time)o._values=En(o._splits,m);else if(a.distr===N.Log){const g=mn(o._splits,a.log),y=st(o._splits);o._values=y.map((L,T)=>g[T]?L:"")}else o._values=st(o._splits);o._rotate=f===Y.Bottom?r.rotate??0:0;const C=o._size;o._size=Ce(yn(r,o._values)),C!==o._size&&(i=!1)}return i}function lt(e,t,n,s=0){let l=e,i=t-s,o=0,r=s;for(const f of n){if(!f._show)continue;const u=f.config.side,d=ge(u)===B.Vertical,c=f.config.label!=null?f.config.labelSize??20:0,h=f._size+c;h>0&&(d?(l-=h,u===Y.Left&&(o+=h)):(i-=h,u===Y.Top&&(r+=h)))}return!n.some(f=>f._show&&f.config.side===Y.Top)&&r<=s&&(r+=8,i-=8),{left:o,top:r,width:Math.max(l,0),height:Math.max(i,0)}}function Wn(e,t){let n=t.top,s=t.left+t.width,l=t.top+t.height,i=t.left;function o(r,a){switch(r){case Y.Top:return n-=a,n+a;case Y.Right:{const f=s;return s+=a,f}case Y.Bottom:{const f=l;return l+=a,f}case Y.Left:return i-=a,i+a;default:return 0}}for(const r of e){if(!r._show)continue;const a=r.config.side;if(r._pos=o(a,r._size),r.config.label!=null){const f=r.config.labelSize??20;r._lpos=o(a,f)}}}function Vn(e,t,n,s,l=0){for(const a of n)a._size=0;let i=!1,o=0,r={left:0,top:0,width:e,height:t};for(;!i;){o++;const a=$n(n,s,r.width,r.height);i=o===Gn||a,i||(r=lt(e,t,n,l))}return r=lt(e,t,n,l),Wn(n,r),r}const it="top",rt="bottom",jn="left",Bn="right";function Ee(e,t){return t===1?e:e.replace(/(\d+(?:\.\d+)?)px/,(n,s)=>`${Math.round(Number(s)*t)}px`)}function at(e,t,n,s,l,i,o,r,a,f,u){const d=r%2/2;e.save(),e.translate(d,d),e.strokeStyle=a,e.lineWidth=r,f.length>0&&e.setLineDash(f),e.beginPath();let c=0,h=0,m=0,v=0;const C=i+(l===Y.Top||l===Y.Left?-o:o);s===B.Horizontal?(h=i,v=C):(c=i,m=C);for(let g=0;g<t.length;g++)n[g]!=null&&(s===B.Horizontal?c=m=t[g]??0:h=v=t[g]??0,e.moveTo(c,h),e.lineTo(m,v));e.stroke(),e.restore()}function Xn(e,t,n,s,l,i){const o=X(s.left*l),r=X(s.top*l),a=X(s.width*l),f=X(s.height*l);for(const u of t){if(!u._show)continue;const d=u.config,c=d.side,h=ge(c),m=n(d.scale);if(!m||m.min==null||m.max==null)continue;const v=d.stroke??"#000",C=c===Y.Top||c===Y.Left?-1:1,g=u._splits,y=u._values;if(!g||!y||u._space===0)continue;const L=h===B.Horizontal?s.width:s.height,T=h===B.Horizontal?s.left:s.top,E=g.map(R=>X(j(R,m,L,T)*l)),D=y.map(R=>R===""?null:R),S=d.grid;if((S==null?void 0:S.show)!==!1){const R=(S==null?void 0:S.stroke)??"rgba(0,0,0,0.12)",p=X(((S==null?void 0:S.width)??2)*l),w=((S==null?void 0:S.dash)??[]).map(k=>k*l),x=h===B.Horizontal?r:o,b=h===B.Horizontal?f:a;at(e,E,D,h,2,x,b,p,R,w)}const M=d.ticks;if((M==null?void 0:M.show)!==!1){const R=(M==null?void 0:M.stroke)??v,p=X(((M==null?void 0:M.width)??1)*l),w=X(((M==null?void 0:M.size)??10)*l),x=((M==null?void 0:M.dash)??[]).map(k=>k*l),b=X(u._pos*l);at(e,E,D,h,c,b,w,p,R,x)}{const R=(M==null?void 0:M.show)!==!1?((M==null?void 0:M.size)??10)*l:0,p=X((d.gap??5)*l),w=X(u._pos*l),x=(R+p)*C,b=w+x,k=Ee(d.font??"12px system-ui, sans-serif",l),I=h===B.Horizontal?"center":c===Y.Left?Bn:jn,z=h===B.Horizontal?c===Y.Bottom?it:rt:"middle";e.font=k,e.fillStyle=v,e.textAlign=I,e.textBaseline=z;const _=u._rotate*-ze/180;if(_!==0){const F=Math.cos(_),H=Math.sin(_);for(let G=0;G<y.length;G++){const $=y[G];if($==null||$==="")continue;const V=E[G]??0;e.setTransform(F,H,-H,F,V,b),e.fillText($,0,0)}e.setTransform(1,0,0,1,0,0)}else for(let F=0;F<y.length;F++){const H=y[F];if(H==null||H==="")continue;const G=E[F]??0,$=h===B.Horizontal?G:b,V=h===B.Horizontal?b:G;e.fillText(H,$,V)}}if(d.label!=null){const R=Ee(d.labelFont??"bold 12px system-ui, sans-serif",l);e.font=R,e.fillStyle=v,e.textAlign="center",e.textBaseline=c===Y.Bottom?it:rt;const p=X((u._lpos+(d.labelGap??0)*C)*l);h===B.Vertical?(e.save(),e.translate(p,X(r+f/2)),e.rotate((c===Y.Left?-ze:ze)/2),e.fillText(d.label,0,0),e.restore()):e.fillText(d.label,X(o+a/2),p)}const P=d.border;if((P==null?void 0:P.show)!==!1&&P!=null){const R=P.stroke??v,p=X((P.width??1)*l),w=(P.dash??[]).map(b=>b*l),x=X(u._pos*l);e.strokeStyle=R,e.lineWidth=p,w.length>0&&e.setLineDash(w),e.beginPath(),h===B.Horizontal?(e.moveTo(o,x),e.lineTo(o+a,x)):(e.moveTo(x,r),e.lineTo(x,r+f)),e.stroke(),w.length>0&&e.setLineDash([])}}if(i!=null){const u=Ee("bold 14px system-ui, sans-serif",l);e.font=u,e.fillStyle="#000",e.textAlign="center",e.textBaseline="top",e.fillText(i,X(o+a/2),X(4*l))}}const Yn={stroke:"#607D8B",width:1,dash:[5,3],pointRadius:4,showX:!0,showY:!0};function ct(e,t,n,s,l,i,o,r,a,f){var T,E;if(t.left<0||t.top<0)return;const u={...Yn,...a},d=s,c=X(n.left*d),h=X(n.top*d),m=X(n.width*d),v=X(n.height*d),C=X(u.width*d),g=C%2/2,y=X((n.left+t.left)*d)+g,L=X((n.top+t.top)*d)+g;if(e.save(),e.strokeStyle=u.stroke,e.lineWidth=C,e.setLineDash(u.dash.map(D=>D*d)),u.showX&&(e.beginPath(),e.moveTo(y,h),e.lineTo(y,h+v),e.stroke()),u.showY&&(e.beginPath(),e.moveTo(c,L),e.lineTo(c+m,L),e.stroke()),e.setLineDash([]),t.activeGroup>=0&&t.activeDataIdx>=0){const D=t.activeGroup,S=t.activeSeriesIdx,M=t.activeDataIdx,P=l[D];if(P!=null&&S>=0&&S<P.series.length&&M<P.x.length){const R=P.x[M],p=P.series[S],w=p!=null?p[M]:null;if(R!=null&&w!=null){let x=u.stroke,b=!0;const k=f==null?void 0:f.get(`${D}:${S}`);if(k!=null){const I=k.stroke;x=(typeof I=="string"?I:void 0)??u.stroke,b=((T=k.cursor)==null?void 0:T.show)!==!1}if(b){const I=r(D),z=I!=null?o(I):void 0,_=((E=f==null?void 0:f.get(`${D}:${S}`))==null?void 0:E.yScale)??Kn(i,D,S),F=_!=null?o(_):void 0;if(z!=null&&F!=null&&z.min!=null&&z.max!=null&&F.min!=null&&F.max!=null){const H=X(j(R,z,n.width,n.left)*d),G=X(j(w,F,n.height,n.top)*d),$=u.pointRadius*d,V=X(2*d);e.beginPath(),e.arc(H,G,$,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.strokeStyle=x,e.lineWidth=V,e.stroke()}}}}}e.restore()}function Kn(e,t,n){for(const s of e)if(s.group===t&&s.index===n)return s.yScale}const Un={fill:"rgba(0,0,0,0.07)",stroke:"rgba(0,0,0,0.15)",width:1};function ut(e,t,n,s,l){if(!t.show||t.width<=0)return;const i={...Un,...l},o=s,r=X((n.left+t.left)*o),a=X((n.top+t.top)*o),f=X(t.width*o),u=X(t.height*o);e.save(),e.fillStyle=i.fill,e.fillRect(r,a,f,u),i.width>0&&(e.strokeStyle=i.stroke,e.lineWidth=X(i.width*o),e.strokeRect(r,a,f,u)),e.restore()}function Nn(e,t,n,s,l,i,o,r,a,f,u,d){const c=u/2*o,h=Math.max(1,X(u*.2))*o,m=(f==null?void 0:f.stroke)??d,v=(f==null?void 0:f.fill)??"#fff";e.save(),e.strokeStyle=m,e.fillStyle=v,e.lineWidth=h,(f==null?void 0:f.dash)!=null&&e.setLineDash(f.dash.map(C=>C*o));for(let C=r;C<=a;C++){const g=n[C];if(g==null)continue;const y=t[C];if(y==null)continue;const L=X(j(y,s,i.width,i.left)*o),T=X(j(g,l,i.height,i.top)*o);e.beginPath(),e.arc(L,T,c,0,Math.PI*2),e.fill(),e.stroke()}e.restore()}function On(e,t,n,s,l,i,o){if(typeof e=="function")return e(t,n,s,l,i);if(e===!0)return!0;if(e===!1)return!1;const r=l-s;return r>0&&r<=i/o}function qn(e,t,n,s,l,i,o,r,a){if(r>a||r<0||!Je(t,r,a)&&!Je(n,r,a))return null;const f=h=>j(h,s,i.width,i.left)*o,u=h=>j(h,l,i.height,i.top)*o,d=new Path2D;let c=!1;for(let h=r;h<=a;h++){const m=t[h],v=e[h];if(m==null||v==null)continue;const C=f(v),g=u(m);c?d.lineTo(C,g):(d.moveTo(C,g),c=!0)}if(!c)return null;for(let h=a;h>=r;h--){const m=n[h],v=e[h];m==null||v==null||d.lineTo(f(v),u(m))}return d.closePath(),d}function Zn(e,t,n){e.save(),e.fillStyle=t.fill??"rgba(0, 120, 255, 0.1)",e.fill(n),e.restore()}function Jn(e){const t=e.dataStore.data;if(t.length===0)return;if(!e.scaleManager.getScale("x")){const o={id:"x",auto:!0};e.scaleConfigs.push(o),e.scaleManager.addScale(o)}for(let o=0;o<t.length;o++)e.scaleManager.getGroupXScaleKey(o)||e.scaleManager.setGroupXScale(o,"x");const n=new Set(e.scaleConfigs.map(o=>o.id)),s=new Set;for(const o of e.seriesConfigs)s.add(o.yScale);s.size===0&&!n.has("y")&&s.add("y");for(const o of s)if(!n.has(o)){const r={id:o,auto:!0};e.scaleConfigs.push(r),e.scaleManager.addScale(r),n.add(o)}e.axisConfigs.some(o=>o.scale==="x")||e.axisConfigs.push({scale:"x",side:Y.Bottom,show:!0,label:e.xlabel??"X Axis"});const i=new Set(e.axisConfigs.map(o=>o.scale));for(const o of s)i.has(o)||(e.axisConfigs.push({scale:o,side:Y.Left,show:!0,label:e.ylabel??"Y Axis"}),i.add(o))}function He(e,t,n,s){return{ctx:e,plotBox:t,pxRatio:n,getScale:s,valToX:(o,r="x")=>{const a=s(r);return a==null||a.min==null||a.max==null?null:j(o,a,t.width,t.left)},valToY:(o,r)=>{const a=s(r);return a==null||a.min==null||a.max==null?null:j(o,a,t.height,t.top)}}}function ft(e){e.seriesConfigMap.clear();for(const t of e.seriesConfigs)e.seriesConfigMap.set(`${t.group}:${t.index}`,t)}function Qn(){const e={scaleManager:new Qt,dataStore:new nn,renderer:new fn,cursorManager:new sn,selectState:{show:!1,left:0,top:0,width:0,height:0},scaleConfigs:[],seriesConfigs:[],axisConfigs:[],bandConfigs:[],axisStates:[],width:0,height:0,pxRatio:typeof window<"u"&&window.devicePixelRatio||1,plotBox:{left:0,top:0,width:0,height:0},canvas:null,listeners:new Set,cursorListeners:new Set,scheduler:new on,drawHooks:new Set,cursorDrawHooks:new Set,focusedSeries:null,focusAlpha:.15,wheelZoom:!1,title:void 0,xlabel:void 0,ylabel:void 0,revision:0,eventCallbacks:{},_prevScaleRanges:new Map,seriesConfigMap:new Map,registerScale(t){e.scaleConfigs=e.scaleConfigs.filter(n=>n.id!==t.id),e.scaleConfigs.push(t),e.scaleManager.addScale(t)},unregisterScale(t){e.scaleConfigs=e.scaleConfigs.filter(n=>n.id!==t),e.scaleManager.removeScale(t)},registerSeries(t){e.seriesConfigs=e.seriesConfigs.filter(n=>!(n.group===t.group&&n.index===t.index)),e.seriesConfigs.push(t),ft(e)},unregisterSeries(t,n){e.seriesConfigs=e.seriesConfigs.filter(s=>!(s.group===t&&s.index===n)),ft(e)},toggleSeries(t,n){const s=e.seriesConfigMap.get(`${t}:${n}`);s!=null&&(s.show=s.show===!1,e.revision++,e.cursorManager.invalidateGroupedConfigs(),e.renderer.invalidateSeries(t,n),e.renderer.invalidateSnapshot(),e.scheduleRedraw())},setFocus(t){e.focusedSeries=t,e.scheduleRedraw()},setSize(t,n){e.width=t,e.height=n,e.canvas&&(e.canvas.width=t*e.pxRatio,e.canvas.height=n*e.pxRatio,e.canvas.style.width=`${t}px`,e.canvas.style.height=`${n}px`),e.renderer.clearCache(),e.scheduleRedraw()},scheduleRedraw(){e.scheduler.mark(te.Full)},scheduleCursorRedraw(){e.scheduler.mark(te.Cursor)},subscribe(t){return e.listeners.add(t),()=>{e.listeners.delete(t)}},subscribeCursor(t){return e.cursorListeners.add(t),()=>{e.cursorListeners.delete(t)}},redraw(){const{scaleManager:t,dataStore:n,renderer:s,seriesConfigs:l,width:i,height:o,pxRatio:r,canvas:a,scheduler:f}=e;if(a==null||i===0||o===0)return;const u=a.getContext("2d");if(u==null)return;s.setContext(u,r);const c=(f.dirty&~(te.Cursor|te.Select))===0,h=g=>t.getScale(g);if(c&&s.restoreSnapshot(u)){if(ct(u,e.cursorManager.state,e.plotBox,r,n.data,l,h,g=>t.getGroupXScaleKey(g),void 0,e.seriesConfigMap),ut(u,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){u.save(),u.scale(r,r);const g=He(u,e.plotBox,r,h);for(const y of e.cursorDrawHooks)try{y(g,e.cursorManager.state)}catch(L){console.warn("[uPlot+] draw hook error:",L)}u.restore()}for(const g of e.cursorListeners)g();return}Jn(e),t.autoRangeX(n.data),n.updateWindows(g=>{const y=t.getGroupXScaleKey(g);return y!=null?t.getScale(y):void 0});const m=l.map(g=>({group:g.group,index:g.index,yScale:g.yScale}));if(t.autoRange(n.data,m,n),es(e),e.axisStates.length>0){const g=e.title!=null?20:0;e.plotBox=Vn(i,o,e.axisStates,h,g)}else e.plotBox={left:10,top:10,width:i-20,height:o-20};u.clearRect(0,0,i*r,o*r),e.axisStates.length>0&&Xn(u,e.axisStates,h,e.plotBox,r,e.title);const v=[];for(const g of l){const y=t.getGroupXScaleKey(g.group),L=y!=null?t.getScale(y):void 0,T=t.getScale(g.yScale);L==null||T==null||v.push({config:g,dataX:n.getXValues(g.group),dataY:n.getYValues(g.group,g.index),xScale:L,yScale:T,window:n.getWindow(g.group)})}s.checkScaleStamp(v),u.save(),u.scale(r,r),u.beginPath(),u.rect(e.plotBox.left,e.plotBox.top,e.plotBox.width,e.plotBox.height),u.clip();for(let g=0;g<v.length;g++){const y=v[g];y!=null&&(e.focusedSeries!=null&&g!==e.focusedSeries?(u.globalAlpha=e.focusAlpha,s.drawSeries(y,e.plotBox,1),u.globalAlpha=1):s.drawSeries(y,e.plotBox,1))}const C=new Map;for(const g of l)C.set(`${g.group}-${g.index}`,g);for(const g of e.bandConfigs){const y=t.getGroupXScaleKey(g.group),L=y!=null?t.getScale(y):void 0,T=C.get(`${g.group}-${g.series[0]}`),E=C.get(`${g.group}-${g.series[1]}`);if(L==null||T==null||E==null)continue;const D=t.getScale(T.yScale);if(D==null)continue;const[S,M]=n.getWindow(g.group),P=g.series[0],R=g.series[1];let p=s.getCachedBandPath(g.group,P,R,S,M);p==null&&(p=qn(n.getXValues(g.group),n.getYValues(g.group,P),n.getYValues(g.group,R),L,D,e.plotBox,r,S,M)??void 0,p!=null&&s.setCachedBandPath(g.group,P,R,S,M,p)),p!=null&&Zn(u,g,p)}for(const g of v){const y=g.config;if(y.show===!1)continue;const L=y.points,T=y.width??1,E=(L==null?void 0:L.size)??3+T*2,D=(L==null?void 0:L.space)??E*2,[S,M]=g.window;On(L==null?void 0:L.show,y.group,y.index,S,M,e.plotBox.width,D)&&Nn(u,g.dataX,g.dataY,g.xScale,g.yScale,e.plotBox,r,S,M,L,E,(typeof y.stroke=="string"?y.stroke:null)??"#000")}if(u.restore(),e.drawHooks.size>0){u.save(),u.beginPath(),u.rect(e.plotBox.left*r,e.plotBox.top*r,e.plotBox.width*r,e.plotBox.height*r),u.clip(),u.scale(r,r);const g=He(u,e.plotBox,r,h);for(const y of e.drawHooks)try{y(g)}catch(L){console.warn("[uPlot+] draw hook error:",L)}u.restore()}if(e.cursorManager.state.left>=0&&(s.saveSnapshot(u,i*r,o*r),e.cursorManager.update(e.cursorManager.state.left,e.cursorManager.state.top,e.plotBox,n.data,l,h,g=>n.getWindow(g),g=>t.getGroupXScaleKey(g))),ct(u,e.cursorManager.state,e.plotBox,r,n.data,l,h,g=>t.getGroupXScaleKey(g),void 0,e.seriesConfigMap),ut(u,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){u.save(),u.scale(r,r);const g=He(u,e.plotBox,r,h);for(const y of e.cursorDrawHooks)try{y(g,e.cursorManager.state)}catch(L){console.warn("[uPlot+] draw hook error:",L)}u.restore()}for(const g of e.listeners)g();for(const g of e.cursorListeners)g();if(e._prevScaleRanges.size>0&&e.eventCallbacks.onScaleChange!=null)for(const g of t.getAllScales()){if(g.min==null||g.max==null)continue;const y=e._prevScaleRanges.get(g.id);if(y==null||y.min!==g.min||y.max!==g.max)try{e.eventCallbacks.onScaleChange(g.id,g.min,g.max)}catch(L){console.warn("[uPlot+] event callback error:",L)}}e._prevScaleRanges.clear();for(const g of t.getAllScales())g.min!=null&&g.max!=null&&e._prevScaleRanges.set(g.id,{min:g.min,max:g.max})}};return e.scheduler.onRedraw(()=>e.redraw()),e}function es(e){const{axisConfigs:t,axisStates:n}=e,s=new Map;for(const l of n)s.set(`${l.config.scale}:${l.config.side}`,l);e.axisStates=t.map(l=>{const i=`${l.scale}:${l.side}`,o=s.get(i);return o!=null?(o.config=l,o):Cn(l)})}function ts(){const e=A.useRef(null);return e.current===null&&(e.current=Qn()),e.current}const Pt=A.createContext(null);function Q(){const e=A.useContext(Pt);if(!e)throw new Error("useChart must be used within a <Chart> component");return e}function ns(e,t){A.useEffect(()=>{if(t!=null)return ss(e,t)},[e,t])}function ss(e,t){let n=null;const s={show:!1,left:0,top:0,width:0,height:0};let l=null,i=null,o=!1;function r(p){const w=t.getBoundingClientRect(),x=e.plotBox,b=p.clientX-w.left-x.left,k=p.clientY-w.top-x.top;return{cx:b,cy:k}}function a(p,w){const x=e.plotBox;return p>=0&&p<=x.width&&w>=0&&w<=x.height}function f(p,w){const x=t.getBoundingClientRect(),b=p-x.left,k=w-x.top,I=e.plotBox;for(const z of e.axisStates){const _=z.config,F=_.side;if(z._size<=0)continue;const G=k>=I.top&&k<=I.top+I.height,$=b>=I.left&&b<=I.left+I.width;if(F===Y.Left&&b<I.left&&G||F===Y.Right&&b>I.left+I.width&&G||F===Y.Top&&k<I.top&&$||F===Y.Bottom&&k>I.top+I.height&&$){const U=ge(F);return{scaleId:_.scale,ori:U}}}return null}function u(p,w,x){const b=e.cursorManager.state;let k=null;if(b.activeGroup>=0&&b.activeDataIdx>=0){const I=e.dataStore.data[b.activeGroup];if(I!=null){const z=I.x[b.activeDataIdx],_=I.series[b.activeSeriesIdx],F=_!=null?_[b.activeDataIdx]:void 0;if(z!=null&&F!=null){const H=e.plotBox,G=e.scaleManager.getGroupXScaleKey(b.activeGroup),$=G!=null?e.scaleManager.getScale(G):void 0,V=e.seriesConfigMap.get(`${b.activeGroup}:${b.activeSeriesIdx}`),U=V!=null?e.scaleManager.getScale(V.yScale):void 0;let J=w,pe=x;($==null?void 0:$.min)!=null&&$.max!=null&&(J=j(z,$,H.width,H.left)-H.left),(U==null?void 0:U.min)!=null&&U.max!=null&&(pe=j(F,U,H.height,H.top)-H.top);const Oe=w-J,qe=x-pe;k={group:b.activeGroup,seriesIdx:b.activeSeriesIdx,dataIdx:b.activeDataIdx,xVal:z,yVal:F,pxX:J,pxY:pe,dist:Math.sqrt(Oe*Oe+qe*qe)}}}}return{plotX:w,plotY:x,point:k,srcEvent:p}}function d(p){const w=e.plotBox,x=p.left/w.width,b=(p.left+p.width)/w.width,k={};for(const I of e.scaleManager.getAllScales()){if(I.ori!==B.Horizontal||I.min==null||I.max==null)continue;const z=se(w.left+x*w.width,I,w.width,w.left),_=se(w.left+b*w.width,I,w.width,w.left);k[I.id]={min:Math.min(z,_),max:Math.max(z,_)}}return{left:x,right:b,ranges:k}}function c(){const p=e.eventCallbacks.onScaleChange;if(p!=null)for(const w of e.scaleManager.getAllScales()){if(w.min==null||w.max==null)continue;const x=e._prevScaleRanges.get(w.id);(x==null||x.min!==w.min||x.max!==w.max)&&p(w.id,w.min,w.max)}}function h(p,w){if(i!=null){const I=t.getBoundingClientRect(),z=p.clientY-I.top,_=e.plotBox,F=(z-i.startY)/_.height,H=i.startMax-i.startMin,G=e.scaleManager.getScale(i.scaleId);G!=null&&(G.min=i.startMin+F*H,G.max=i.startMax+F*H,G.auto=!1,fe(G),e.renderer.clearCache(),e.scheduleRedraw());return}const x=r(p);if(x==null)return;const{cx:b,cy:k}=x;if(!a(b,k)&&n==null){e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),e.scheduleCursorRedraw();return}if(e.cursorManager.update(b,k,e.plotBox,e.dataStore.data,e.seriesConfigs,I=>e.scaleManager.getScale(I),I=>e.dataStore.getWindow(I),I=>e.scaleManager.getGroupXScaleKey(I)),e.focusAlpha<1){const I=e.cursorManager.state;if(I.activeGroup>=0&&I.activeSeriesIdx>=0){const z=e.seriesConfigs.findIndex(_=>_.group===I.activeGroup&&_.index===I.activeSeriesIdx);z>=0&&e.focusedSeries!==z&&(e.focusedSeries=z,e.scheduleRedraw())}}if(w!=null&&e.eventCallbacks.onCursorMove!=null&&a(b,k))try{e.eventCallbacks.onCursorMove(u(w,b,k))}catch(I){console.warn("[uPlot+] event callback error:",I)}if(n!=null){const I=n.x,z=e.plotBox,_=q(b,0,z.width);s.show=!0,s.left=Math.min(I,_),s.top=0,s.width=Math.abs(_-I),s.height=z.height,e.selectState=s}n!=null?e.scheduler.mark(te.Cursor|te.Select):e.scheduleCursorRedraw()}function m(p){h(p,p)}function v(p){if(p.button!==0)return;const w=f(p.clientX,p.clientY);if(w!=null&&w.ori===B.Vertical){const b=e.scaleManager.getScale(w.scaleId);if(b!=null&&b.min!=null&&b.max!=null){const k=t.getBoundingClientRect();i={scaleId:w.scaleId,startY:p.clientY-k.top,startMin:b.min,startMax:b.max},p.preventDefault();return}}const x=r(p);x!=null&&a(x.cx,x.cy)&&(n={x:x.cx,y:x.cy},o=!1,s.show=!1,s.left=0,s.width=0,e.selectState=s)}function C(p){if(i!=null){c(),i=null;return}if(n!=null){if(s.width>5){o=!0;let w=!0;if(e.eventCallbacks.onSelect!=null){const x=d(s);let b;try{b=e.eventCallbacks.onSelect(x)}catch(k){console.warn("[uPlot+] event callback error:",k)}b===!1&&(w=!1)}w&&(S(s),c())}n=null,s.show=!1,s.left=0,s.width=0,e.selectState=s,e.scheduleRedraw()}}function g(p){C()}function y(p){if(o){o=!1;return}const w=e.eventCallbacks.onClick;if(w==null)return;const x=r(p);if(x!=null&&a(x.cx,x.cy))try{w(u(p,x.cx,x.cy))}catch(b){console.warn("[uPlot+] event callback error:",b)}}function L(p){const w=e.eventCallbacks.onContextMenu;if(w==null)return;const x=r(p);if(x!=null&&a(x.cx,x.cy)){p.preventDefault();try{w(u(p,x.cx,x.cy))}catch(b){console.warn("[uPlot+] event callback error:",b)}}}function T(p){var w,x;e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),n!=null&&(n=null,s.show=!1,s.width=0,e.selectState=s),i!=null&&(i=null),e.scheduleCursorRedraw();try{(x=(w=e.eventCallbacks).onCursorLeave)==null||x.call(w)}catch(b){console.warn("[uPlot+] event callback error:",b)}}function E(p){if(e.eventCallbacks.onDblClick!=null){const w=r(p);if(w!=null&&a(w.cx,w.cy)){let x;try{x=e.eventCallbacks.onDblClick(u(p,w.cx,w.cy))}catch(b){console.warn("[uPlot+] event callback error:",b)}if(x===!1)return}}for(const w of e.scaleConfigs)e.scaleManager.addScale(w);e.renderer.clearCache(),e.scheduleRedraw()}function D(p){const w=e.wheelZoom;if(!w)return;let x=!1,b=!1;if(w===!0||w==="x")x=!0;else if(w==="y")b=!0;else if(w==="xy")x=!0,b=!0;else if(typeof w=="object"){if(w.x){const _=typeof w.x=="object"?w.x.key:void 0;x=_==null||p[`${_}Key`]}if(w.y){const _=typeof w.y=="object"?w.y.key:void 0;b=_==null||p[`${_}Key`]}}if(!x&&!b)return;const k=r(p);if(k==null||!a(k.cx,k.cy))return;p.preventDefault();const I=q(1-p.deltaY*.001,.1,10),z=e.plotBox;for(const _ of e.scaleManager.getAllScales()){if(_.min==null||_.max==null)continue;const F=_.ori===B.Horizontal;if(F&&!x||!F&&!b)continue;const H=F?z.width:z.height,G=F?z.left:z.top,$=F?k.cx+z.left:k.cy+z.top,V=se($,_,H,G),U=V-(V-_.min)*I,J=V+(_.max-V)*I;_.min=Math.min(U,J),_.max=Math.max(U,J),_.auto=!1,fe(_)}e.scheduleRedraw(),c()}function S(p){const w=e.plotBox,x=p.left/w.width,b=(p.left+p.width)/w.width;for(const k of e.scaleManager.getAllScales()){if(k.ori!==B.Horizontal||k.min==null||k.max==null)continue;const I=se(w.left+x*w.width,k,w.width,w.left),z=se(w.left+b*w.width,k,w.width,w.left);k.min=Math.min(I,z),k.max=Math.max(I,z),k.auto=!1,fe(k)}}function M(p){if(p.touches.length===2){const b=p.touches[0],k=p.touches[1],I=k.clientX-b.clientX,z=k.clientY-b.clientY;l={dist:Math.sqrt(I*I+z*z),midX:(b.clientX+k.clientX)/2,midY:(b.clientY+k.clientY)/2},n=null;return}const w=p.touches[0];if(w==null)return;const x=r(w);x!=null&&a(x.cx,x.cy)&&(n={x:x.cx,y:x.cy},o=!1)}function P(p){if(p.touches.length===2&&l!=null){p.preventDefault();const x=p.touches[0],b=p.touches[1],k=b.clientX-x.clientX,I=b.clientY-x.clientY,z=Math.sqrt(k*k+I*I),_=z/l.dist,F=t.getBoundingClientRect(),H=e.plotBox,G=l.midX-F.left-H.left;for(const $ of e.scaleManager.getAllScales()){if($.ori!==B.Horizontal||$.min==null||$.max==null)continue;const V=se(G+H.left,$,H.width,H.left),U=V-(V-$.min)/_,J=V+($.max-V)/_;$.min=Math.min(U,J),$.max=Math.max(U,J),$.auto=!1,fe($)}l.dist=z,e.renderer.clearCache(),e.scheduleRedraw(),c();return}const w=p.touches[0];w!=null&&(h(w,p),n!=null&&p.preventDefault())}function R(p){if(l!=null){l=null;return}p.changedTouches[0]!=null&&C()}return t.addEventListener("mousemove",m),t.addEventListener("mousedown",v),t.addEventListener("mouseup",g),t.addEventListener("click",y),t.addEventListener("contextmenu",L),t.addEventListener("mouseleave",T),t.addEventListener("dblclick",E),t.addEventListener("wheel",D,{passive:!1}),t.addEventListener("touchstart",M,{passive:!0}),t.addEventListener("touchmove",P,{passive:!1}),t.addEventListener("touchend",R),()=>{t.removeEventListener("mousemove",m),t.removeEventListener("mousedown",v),t.removeEventListener("mouseup",g),t.removeEventListener("click",y),t.removeEventListener("contextmenu",L),t.removeEventListener("mouseleave",T),t.removeEventListener("dblclick",E),t.removeEventListener("wheel",D),t.removeEventListener("touchstart",M),t.removeEventListener("touchmove",P),t.removeEventListener("touchend",R)}}const $e=new Map;function os(e){let t=$e.get(e);return t==null&&(t=new ls(e),$e.set(e,t)),t}class ls{constructor(t){this.members=new Set,this.publishing=!1,this.syncedStores=new WeakSet,this.key=t}join(t){this.members.add(t)}leave(t){this.members.delete(t),this.members.size===0&&$e.delete(this.key)}pub(t){if(this.publishing)return;if(this.syncedStores.has(t)){this.syncedStores.delete(t);return}this.publishing=!0;const n=t.cursorManager.state,{activeGroup:s,activeDataIdx:l}=n;if(s<0||l<0){for(const r of this.members)r!==t&&(this.syncedStores.add(r),r.cursorManager.hide(),r.scheduleCursorRedraw());this.publishing=!1;return}const o=t.dataStore.getXValues(s)[l];if(o==null){this.publishing=!1;return}for(const r of this.members)r!==t&&(this.syncedStores.add(r),r.cursorManager.syncToValue(o,r),r.scheduleCursorRedraw());this.publishing=!1}}function is(e,t){A.useEffect(()=>{if(t==null)return;const n=os(t);n.join(e);let s=-1,l=-1;const i=e.subscribe(()=>{const{activeGroup:o,activeDataIdx:r}=e.cursorManager.state;o===s&&r===l||(s=o,l=r,n.pub(e))});return()=>{i(),n.leave(e)}},[e,t])}function Rt(e){return e instanceof Float64Array?e:new Float64Array(e)}function Dt(e){return e instanceof Float64Array||e.some(t=>t==null)?e:new Float64Array(e)}function ht(e){return{x:Rt(e.x),series:[Dt(e.y)]}}function rs(e){return{x:Rt(e.x),series:e.series.map(Dt)}}function Xe(e){if(!Array.isArray(e))return[ht(e)];if(e.length===0)return[];const t=e[0];return t==null?[]:"series"in t?e.map(rs):e.map(ht)}function Ye({width:e,height:t,data:n,children:s,className:l,pxRatio:i,title:o,xlabel:r,ylabel:a,onDraw:f,onCursorDraw:u,syncKey:d,cursor:c,onClick:h,onContextMenu:m,onDblClick:v,onCursorMove:C,onCursorLeave:g,onScaleChange:y,onSelect:L}){var _;const T=ts(),[E,D]=A.useState(null),S=i??(typeof window<"u"&&window.devicePixelRatio||1),M=c==null?void 0:c.wheelZoom,P=typeof M=="object"?JSON.stringify(M):M,R=((_=c==null?void 0:c.focus)==null?void 0:_.alpha)??((c==null?void 0:c.focus)!=null?.15:1);A.useEffect(()=>{T.wheelZoom=M,T.focusAlpha=R},[T,P,R]),A.useEffect(()=>{T.title=o,T.xlabel=r,T.ylabel=a},[T,o,r,a]);const p=A.useRef(T.eventCallbacks);p.current=T.eventCallbacks,A.useEffect(()=>{const F=p.current;F.onClick=h,F.onContextMenu=m,F.onDblClick=v,F.onCursorMove=C,F.onCursorLeave=g,F.onScaleChange=y,F.onSelect=L}),ns(T,E),is(T,d);const w=A.useCallback(F=>{T.canvas=F,F&&T.scheduleRedraw()},[T]),x=A.useCallback(F=>{D(F)},[]);A.useEffect(()=>{T.pxRatio=S,T.setSize(e,t)},[T,e,t,S]),A.useEffect(()=>()=>{T.canvas=null,T.scheduler.cancel(),T.focusedSeries=null},[T]),A.useEffect(()=>{if(E==null||typeof ResizeObserver>"u")return;const F=new ResizeObserver(H=>{const G=H[0];if(G==null)return;const{width:$,height:V}=G.contentRect;$>0&&V>0&&($!==T.width||V!==T.height)&&T.setSize(Math.round($),Math.round(V))});return F.observe(E),()=>{F.disconnect()}},[T,E]);const b=A.useMemo(()=>Xe(n),[n]),k=A.useRef(n);A.useEffect(()=>{n===k.current&&T.dataStore.data.length>0||(k.current=n,T.dataStore.setData(b),T.renderer.clearCache(),T.scheduleRedraw())},[T,n,b]);const I=A.useRef(f);I.current=f,A.useEffect(()=>{const F=H=>{var G;(G=I.current)==null||G.call(I,H)};return T.drawHooks.add(F),()=>{T.drawHooks.delete(F)}},[T]);const z=A.useRef(u);return z.current=u,A.useEffect(()=>{const F=(H,G)=>{var $;($=z.current)==null||$.call(z,H,G)};return T.cursorDrawHooks.add(F),()=>{T.cursorDrawHooks.delete(F)}},[T]),W.jsx(Pt.Provider,{value:T,children:W.jsxs("div",{className:l,style:{position:"relative",display:"flex",flexDirection:"column",width:`${e}px`},children:[W.jsx("div",{ref:x,style:{position:"relative",width:`${e}px`,height:`${t}px`,cursor:"crosshair",order:0},children:W.jsx("canvas",{ref:w,style:{position:"absolute",left:0,top:0}})}),s]})})}function dt(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function as(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const l of s)if(e[l]!==t[l])return!1;return!0}function Ke(e,t){if(e===null)return!1;const n=e,s=t,l=Object.keys(n),i=Object.keys(s);if(l.length!==i.length)return!1;for(const o of i){const r=n[o],a=s[o];if(r!==a)if(dt(r)&&dt(a)){if(!as(r,a))return!1}else return!1}return!0}function Ie(e){const t=Q(),n=A.useRef(e);n.current=e,A.useEffect(()=>{const l=n.current;return t.registerScale({...l}),t.scheduleRedraw(),()=>{t.unregisterScale(l.id),t.scheduleRedraw()}},[t,e.id]);const s=A.useRef(null);return A.useEffect(()=>{Ke(s.current,e)||(s.current=e,t.scaleConfigs=t.scaleConfigs.map(l=>l.id===e.id?{...e}:l),t.scaleManager.addScale({...e}),t.renderer.clearCache(),t.scheduleRedraw())}),null}const gt=["#e74c3c","#3498db","#2ecc71","#f39c12","#9b59b6","#1abc9c","#e67e22","#34495e","#16a085","#c0392b","#2980b9","#27ae60","#f1c40f","#8e44ad","#d35400"];function pt(e,t){return{...e,yScale:e.yScale??"y",show:e.show??!0,stroke:e.stroke??gt[t%gt.length]}}function Ue(e){const t=Q(),n=A.useRef(e);n.current=e,A.useEffect(()=>{const l=n.current;return t.registerSeries(pt(l,t.seriesConfigs.length)),t.renderer.clearGroupCache(l.group),t.scheduleRedraw(),()=>{t.unregisterSeries(l.group,l.index),t.renderer.clearGroupCache(l.group),t.scheduleRedraw()}},[t,e.group,e.index]);const s=A.useRef(null);return A.useEffect(()=>{if(!Ke(s.current,e)){s.current=e,t.seriesConfigs=t.seriesConfigs.map((l,i)=>l.group===e.group&&l.index===e.index?pt(e,i):l),t.seriesConfigMap.clear();for(const l of t.seriesConfigs)t.seriesConfigMap.set(`${l.group}:${l.index}`,l);t.renderer.invalidateSeries(e.group,e.index),t.scheduleRedraw()}}),null}function cs(e){return{...e,side:e.side??(e.scale==="x"?Y.Bottom:Y.Left),show:e.show??!0}}function Ae(e){const t=Q(),n=cs(e),s=A.useRef(n);s.current=n,A.useEffect(()=>{const i=s.current;return t.axisConfigs=t.axisConfigs.filter(o=>!(o.scale===i.scale&&o.side===i.side)),t.axisConfigs.push(i),t.scheduleRedraw(),()=>{t.axisConfigs=t.axisConfigs.filter(o=>!(o.scale===i.scale&&o.side===i.side)),t.scheduleRedraw()}},[t,n.scale,n.side]);const l=A.useRef(null);return A.useEffect(()=>{Ke(l.current,e)||(l.current=e,t.axisConfigs=t.axisConfigs.map(i=>i.scale===n.scale&&i.side===n.side?n:i),t.scheduleRedraw())}),null}function us({series:e,group:t,fill:n,dir:s}){const l=Q(),i=A.useRef(null),o=e[0],r=e[1];return A.useEffect(()=>{const a={series:[o,r],group:t,fill:n,dir:s};return i.current!=null&&(l.bandConfigs=l.bandConfigs.filter(f=>f!==i.current)),i.current=a,l.bandConfigs.push(a),l.scheduleRedraw(),()=>{l.bandConfigs=l.bandConfigs.filter(f=>f!==i.current),i.current=null,l.scheduleRedraw()}},[l,o,r,t,n,s]),null}const fs={width:12,height:3,borderRadius:1,display:"inline-block"},hs={fontWeight:600},zt={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",cursor:"pointer",fontSize:12,fontFamily:"sans-serif"},ds={...zt,opacity:1},gs={...zt,opacity:.4},mt=new Map,ps=A.memo(function({group:t,index:n,label:s,color:l,isHidden:i,valueStr:o,store:r}){const a=A.useCallback(()=>{r.toggleSeries(t,n)},[r,t,n]);let f=mt.get(l);return f==null&&(f={...fs,backgroundColor:l},mt.set(l,f)),W.jsxs("span",{onClick:a,style:i?gs:ds,children:[W.jsx("span",{style:f}),W.jsx("span",{children:s}),o&&W.jsx("span",{style:hs,children:o})]})});function ms({show:e=!0,position:t="bottom",className:n}){const s=Q(),l=A.useRef({activeGroup:-1,activeDataIdx:-1,seriesCount:0,revision:-1}),i=A.useCallback(u=>s.subscribeCursor(u),[s]),o=A.useCallback(()=>{const{activeGroup:u,activeDataIdx:d}=s.cursorManager.state,c=s.seriesConfigs.length,{revision:h}=s,m=l.current;if(m.activeGroup===u&&m.activeDataIdx===d&&m.seriesCount===c&&m.revision===h)return m;const v={activeGroup:u,activeDataIdx:d,seriesCount:c,revision:h};return l.current=v,v},[s]),r=A.useSyncExternalStore(i,o);if(!e)return null;const{activeGroup:a,activeDataIdx:f}=r;return W.jsx("div",{className:n,style:{display:"flex",flexWrap:"wrap",justifyContent:"center",order:t==="top"?-1:1,padding:"4px 0"},children:s.seriesConfigs.map(u=>{if(u.legend===!1)return null;const d=typeof u.stroke=="string"?u.stroke:"#000";let c="";if(f>=0&&a>=0&&u.group===a){const m=s.dataStore.getYValues(u.group,u.index)[f];m!=null&&(c=typeof m=="number"?m.toPrecision(4):String(m))}return W.jsx(ps,{group:u.group,index:u.index,label:u.label??`Series ${u.index}`,color:d,isHidden:u.show===!1,valueStr:c,store:s},`${u.group}:${u.index}`)})})}const ws={position:"absolute",zIndex:50,background:"rgba(255,255,255,0.92)",border:"1px solid #ccc",borderRadius:4,padding:"4px 6px",fontSize:12,fontFamily:"sans-serif",userSelect:"none",boxShadow:"0 1px 4px rgba(0,0,0,0.12)",whiteSpace:"nowrap"},xs={width:12,height:3,borderRadius:1,display:"inline-block",flexShrink:0},bs={fontWeight:600},vs={display:"flex",alignItems:"center",gap:4,padding:"1px 4px"},Ne=A.memo(function({label:t,color:n,value:s,isHidden:l,onClick:i}){return W.jsxs("div",{onClick:i,style:{...vs,opacity:l?.4:1,cursor:i?"pointer":"default"},children:[W.jsx("span",{style:{...xs,backgroundColor:n}}),W.jsx("span",{children:t}),s&&W.jsx("span",{style:bs,children:s})]})}),Le=A.forwardRef(function({left:t,top:n,children:s,className:l,style:i,onMouseDown:o,onMouseEnter:r,onMouseLeave:a},f){return W.jsx("div",{ref:f,className:l,onMouseDown:o,onMouseEnter:r,onMouseLeave:a,style:{...ws,left:t,top:n,...i},children:s})});function Ss(e,t,n,s,l){if(l<0||s<0)return"";const o=e.dataStore.getYValues(t,n)[l];return o==null?"":typeof o=="number"?o.toPrecision(4):String(o)}function Ms({show:e=!0,className:t,children:n,offset:s={}}){var w,x;const l=Q(),i=A.useRef({left:-10,top:-10,activeGroup:-1,activeDataIdx:-1,revision:-1}),o=A.useRef(null),r=A.useCallback(b=>l.subscribeCursor(b),[l]),a=A.useCallback(()=>{const b=l.cursorManager.state,{revision:k}=l,I=i.current;if(I.left===b.left&&I.top===b.top&&I.activeGroup===b.activeGroup&&I.activeDataIdx===b.activeDataIdx&&I.revision===k)return I;const z={left:b.left,top:b.top,activeGroup:b.activeGroup,activeDataIdx:b.activeDataIdx,revision:k};return i.current=z,z},[l]),f=A.useSyncExternalStore(r,a);if(!e||f.activeDataIdx<0||f.activeGroup<0||f.left<0)return null;const{activeGroup:u,activeDataIdx:d}=f,c=l.plotBox,h=l.dataStore.data[u],m=h!=null?h.x[d]??null:null,v=m!=null?parseFloat(m.toPrecision(6)).toString():"",C=[];for(const b of l.seriesConfigs){if(b.show===!1||b.legend===!1)continue;const k=l.dataStore.getYValues(b.group,b.index),I=b.group===u?k[d]:null;C.push({label:b.label??`Series ${b.index}`,value:I,color:typeof b.stroke=="string"?b.stroke:"#000",group:b.group,index:b.index})}const g={x:m,xLabel:v,items:C,left:f.left+c.left,top:f.top+c.top},y=s.x??12,L=s.y??-12,T=((w=o.current)==null?void 0:w.offsetWidth)??0,E=((x=o.current)==null?void 0:x.offsetHeight)??0,D=f.left+c.left,S=f.top+c.top,M=c.left+c.width,P=c.top+c.height,R=q(D+y,c.left,M-T),p=q(S+L,c.top,P-E);return n?W.jsx("div",{ref:o,className:t,style:{position:"absolute",left:R,top:p,whiteSpace:"nowrap",pointerEvents:"none",zIndex:100},children:n(g)}):W.jsxs(Le,{ref:o,left:R,top:p,className:t,style:{pointerEvents:"none",zIndex:100},children:[W.jsx("div",{style:{fontWeight:600,marginBottom:2,padding:"0 4px"},children:v}),C.map(b=>W.jsx(Ne,{label:b.label,color:b.color,value:b.value!=null?b.value.toPrecision(4):"—"},`${b.group}:${b.index}`))]})}function ys({width:e,height:t,data:n,onRangeChange:s,initialRange:l,className:i,colors:o,grips:r=!1}){const a=A.useRef(null),f=A.useMemo(()=>Xe(n),[n]),[u,d]=A.useState(()=>{if(l!=null&&f.length>0){const D=f[0];if(D!=null&&D.x.length>1){const S=D.x[0],P=D.x[D.x.length-1]-S;if(P>0)return[Math.max(0,(l[0]-S)/P),Math.min(1,(l[1]-S)/P)]}}return[.25,.75]}),c=A.useRef(null);A.useEffect(()=>{if(s==null||f.length===0)return;const D=f[0];if(D==null||D.x.length<2)return;const S=D.x[0],P=D.x[D.x.length-1]-S,R=S+u[0]*P,p=S+u[1]*P,w=c.current,x=Math.max(1e-10,Math.abs(p-R)*1e-12);w!=null&&Math.abs(w[0]-R)<x&&Math.abs(w[1]-p)<x||(c.current=[R,p],s(R,p))},[u,f,s]);const h=A.useRef(null),m=A.useCallback(D=>{const S=a.current;if(S==null)return 0;const M=S.getBoundingClientRect();return q((D-M.left)/M.width,0,1)},[]),v=A.useCallback(D=>{const S=a.current;if(S==null)return;const M=m(D.clientX),P=S.getBoundingClientRect().width,R=P>0?8/P:0;let p;if(Math.abs(M-u[0])<R)p="left";else if(Math.abs(M-u[1])<R)p="right";else if(M>=u[0]&&M<=u[1])p="move";else{const w=u[1]-u[0],x=w/2,b=q(M-x,0,1-w);d([b,b+w]),p="move"}h.current={mode:p,startX:D.clientX,startFrac:[...u]},S.setPointerCapture(D.pointerId),D.preventDefault()},[u,m]),C=A.useCallback(D=>{const S=h.current;if(S==null)return;const M=m(D.clientX),P=m(S.startX),R=M-P;if(S.mode==="move"){const p=S.startFrac[1]-S.startFrac[0],w=q(S.startFrac[0]+R,0,1-p);d([w,w+p])}else if(S.mode==="left"){const p=q(S.startFrac[0]+R,0,S.startFrac[1]-.01);d([p,S.startFrac[1]])}else{const p=q(S.startFrac[1]+R,S.startFrac[0]+.01,1);d([S.startFrac[0],p])}},[m]),g=A.useCallback(D=>{h.current=null;const S=a.current;S!=null&&S.releasePointerCapture(D.pointerId)},[]),y=`${u[0]*100}%`,L=`${(u[1]-u[0])*100}%`,T=f[0],E=T!=null?T.series.length:0;return W.jsxs("div",{className:i,style:{position:"relative",width:e,height:t},children:[W.jsxs(Ye,{width:e,height:t,data:n,children:[W.jsx(Ie,{id:"x"}),W.jsx(Ie,{id:"y"}),W.jsx(Ae,{scale:"x",show:!1}),W.jsx(Ae,{scale:"y",show:!1}),Array.from({length:E},(D,S)=>W.jsx(Ue,{group:0,index:S,yScale:"y",stroke:o!=null&&o[S]!=null?o[S]:`hsl(${S*137}, 60%, 50%)`,width:1},S))]}),W.jsxs("div",{ref:a,onPointerDown:v,onPointerMove:C,onPointerUp:g,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[W.jsx("div",{style:{position:"absolute",top:0,left:0,width:y,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),W.jsx("div",{style:{position:"absolute",top:0,left:`${u[1]*100}%`,right:0,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),W.jsx("div",{style:{position:"absolute",top:0,left:y,width:L,height:"100%",borderLeft:"2px solid rgba(0,100,255,0.8)",borderRight:"2px solid rgba(0,100,255,0.8)",boxSizing:"border-box",cursor:"grab",pointerEvents:"none"},children:r&&W.jsxs(W.Fragment,{children:[W.jsx("div",{style:{position:"absolute",left:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:"rgba(0,100,255,0.8)",cursor:"ew-resize",pointerEvents:"auto"}}),W.jsx("div",{style:{position:"absolute",right:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:"rgba(0,100,255,0.8)",cursor:"ew-resize",pointerEvents:"auto"}})]})})]})]})}function Me(e){const t=Q(),n=A.useRef(e);n.current=e,A.useEffect(()=>{const s=l=>n.current(l);return t.drawHooks.add(s),()=>{t.drawHooks.delete(s)}},[t])}function Cs(e){const t=Q(),n=A.useRef(e);n.current=e,A.useEffect(()=>{const s=(l,i)=>n.current(l,i);return t.cursorDrawHooks.add(s),()=>{t.cursorDrawHooks.delete(s)}},[t])}function ks({lanes:e,laneHeight:t=24,gap:n=2,scaleId:s="x"}){const l=Q();return Me(({ctx:i,plotBox:o,pxRatio:r})=>{const a=l.scaleManager.getScale(s);if(a==null||a.min==null||a.max==null)return;i.save(),i.beginPath(),i.rect(o.left*r,o.top*r,o.width*r,o.height*r),i.clip();const f=(t+n)*r,u=t*r,d=o.top*r;for(let c=0;c<e.length;c++){const h=e[c];if(h==null)continue;const m=d+c*f;i.fillStyle="#666",i.font=`${11*r}px sans-serif`,i.textAlign="right",i.textBaseline="middle",i.fillText(h.label,(o.left-6)*r,m+u/2);for(const v of h.segments){const C=j(v.start,a,o.width,o.left)*r,y=j(v.end,a,o.width,o.left)*r-C;y<=0||(i.fillStyle=v.color??"#4dabf7",i.fillRect(C,m,y,u),v.label!=null&&y>20*r&&(i.fillStyle="#fff",i.font=`${10*r}px sans-serif`,i.textAlign="center",i.textBaseline="middle",i.fillText(v.label,C+y/2,m+u/2,y-4*r)))}}i.restore()}),null}function Ts({data:e,width:t=150,height:n=30,stroke:s="#03a9f4",fill:l,lineWidth:i=1,paths:o,fillTo:r,className:a}){return W.jsx("div",{style:{pointerEvents:"none"},className:a,children:W.jsxs(Ye,{width:t,height:n,data:e,children:[W.jsx(Ie,{id:"x"}),W.jsx(Ie,{id:"y"}),W.jsx(Ae,{scale:"x",show:!1}),W.jsx(Ae,{scale:"y",show:!1}),W.jsx(Ue,{group:0,index:0,yScale:"y",stroke:s,fill:l,width:i,paths:o,fillTo:r})]})})}function Is(e,t){if(e!=null&&typeof e=="object")return e;const n=8;switch(e){case"top-left":return{x:t.left+n,y:t.top+n};case"bottom-left":return{x:t.left+n,y:t.top+t.height-60};case"bottom-right":return{x:t.left+t.width-140,y:t.top+t.height-60};case"top-right":default:return{x:t.left+t.width-140,y:t.top+n}}}function As({mode:e="draggable",position:t="top-right",offset:n={x:12,y:-12},idleOpacity:s=.3,show:l=!0,className:i}){var p,w;const o=Q(),r=A.useRef(null),[a,f]=A.useState(null),[u,d]=A.useState(!1),c=A.useRef(!1),h=A.useRef(!1),m=A.useRef({dx:0,dy:0}),v=A.useRef(!1),C=A.useRef(null),g=A.useCallback(x=>o.subscribeCursor(x),[o]),y=A.useCallback(()=>{const{activeGroup:x,activeDataIdx:b,left:k,top:I}=o.cursorManager.state,z=o.seriesConfigs.length,{revision:_}=o,{left:F,top:H,width:G,height:$}=o.plotBox,V=r.current;if(V!=null&&V.activeGroup===x&&V.activeDataIdx===b&&V.cursorLeft===k&&V.cursorTop===I&&V.seriesCount===z&&V.revision===_&&V.plotLeft===F&&V.plotTop===H&&V.plotWidth===G&&V.plotHeight===$)return V;const U={activeGroup:x,activeDataIdx:b,cursorLeft:k,cursorTop:I,seriesCount:z,revision:_,plotLeft:F,plotTop:H,plotWidth:G,plotHeight:$};return r.current=U,U},[o]),L=A.useSyncExternalStore(g,y);e==="draggable"&&!v.current&&L.plotWidth>0&&(v.current=!0,a==null&&f(Is(t,o.plotBox)));const T=A.useCallback((x,b)=>{h.current||o.toggleSeries(x,b)},[o]),E=A.useCallback(x=>{if(e!=="draggable")return;x.stopPropagation(),x.preventDefault(),c.current=!0,h.current=!1;const b=x.currentTarget.getBoundingClientRect();m.current={dx:x.clientX-b.left,dy:x.clientY-b.top}},[e]);if(A.useEffect(()=>{if(!l||e!=="draggable")return;const x=k=>{var _;if(!c.current)return;h.current=!0;const I=(_=o.canvas)==null?void 0:_.parentElement;if(!I)return;const z=I.getBoundingClientRect();f({x:k.clientX-z.left-m.current.dx,y:k.clientY-z.top-m.current.dy})},b=()=>{c.current=!1};return window.addEventListener("mousemove",x),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",b)}},[o,l,e]),!l)return null;const{activeGroup:D,activeDataIdx:S,cursorLeft:M,cursorTop:P}=L,R=o.seriesConfigs.filter(x=>x.legend!==!1).map(x=>{const b=typeof x.stroke=="string"?x.stroke:"#000",k=Ss(o,x.group,x.index,D,S),I=e==="draggable";return W.jsx(Ne,{label:x.label??`Series ${x.index}`,color:b,value:k,isHidden:x.show===!1,onClick:I?()=>T(x.group,x.index):void 0},`${x.group}:${x.index}`)});if(e==="cursor"){if(M<0)return null;const x=((p=C.current)==null?void 0:p.offsetWidth)??0,b=((w=C.current)==null?void 0:w.offsetHeight)??0,k=L.plotLeft+L.plotWidth,I=L.plotTop+L.plotHeight,z=q(M+L.plotLeft+n.x,L.plotLeft,k-x),_=q(P+L.plotTop+n.y,L.plotTop,I-b);return W.jsx(Le,{ref:C,left:z,top:_,className:i,style:{pointerEvents:"none"},children:R})}return a==null?null:W.jsx(Le,{ref:C,left:a.x,top:a.y,className:i,onMouseDown:E,onMouseEnter:()=>d(!0),onMouseLeave:()=>{d(!1),h.current=!1},style:{pointerEvents:"auto",cursor:c.current?"grabbing":"grab",opacity:u||c.current?1:s,transition:"opacity 0.2s ease"},children:R})}function Ls({delay:e=1e3,show:t=!0,className:n}){var E,D;const s=Q(),l=A.useRef(null),[i,o]=A.useState(!1),r=A.useRef(-1),a=A.useRef(0),f=A.useRef(null),u=A.useCallback(S=>s.subscribe(S),[s]),d=A.useCallback(()=>{const{left:S,top:M,activeSeriesIdx:P,activeGroup:R}=s.cursorManager.state,{left:p,top:w,width:x,height:b}=s.plotBox,k=l.current;if(k!=null&&k.cursorLeft===S&&k.cursorTop===M&&k.activeSeriesIdx===P&&k.activeGroup===R&&k.plotLeft===p&&k.plotTop===w&&k.plotWidth===x&&k.plotHeight===b)return k;const I={cursorLeft:S,cursorTop:M,activeSeriesIdx:P,activeGroup:R,plotLeft:p,plotTop:w,plotWidth:x,plotHeight:b};return l.current=I,I},[s]),c=A.useSyncExternalStore(u,d);if(A.useEffect(()=>{const S=c.activeSeriesIdx;S!==r.current&&(r.current=S,o(!1),window.clearTimeout(a.current),S>=0&&(a.current=window.setTimeout(()=>o(!0),e)))},[c.activeSeriesIdx,e]),A.useEffect(()=>()=>{window.clearTimeout(a.current)},[]),!t||!i||c.cursorLeft<0)return null;const h=s.seriesConfigs.find(S=>S.group===c.activeGroup&&S.index===c.activeSeriesIdx);if(!(h!=null&&h.label)||h.legend===!1)return null;const m=typeof h.stroke=="string"?h.stroke:"#000",v=((E=f.current)==null?void 0:E.offsetWidth)??80,C=((D=f.current)==null?void 0:D.offsetHeight)??24,g=c.cursorLeft+c.plotLeft,y=c.cursorTop+c.plotTop,L=q(g-v/2,c.plotLeft,c.plotLeft+c.plotWidth-v),T=q(y-C-12,c.plotTop,c.plotTop+c.plotHeight-C);return W.jsx(Le,{ref:f,left:L,top:T,className:n,style:{pointerEvents:"none"},children:W.jsx(Ne,{label:h.label,color:m})})}function Ft(e,t,n,s={}){const{ctx:l,plotBox:i}=e,o=j(n,t,i.height,i.top);l.beginPath(),l.moveTo(i.left,o),l.lineTo(i.left+i.width,o),l.strokeStyle=s.stroke??"red",l.lineWidth=s.width??1,s.dash&&l.setLineDash(s.dash),l.stroke(),s.dash&&l.setLineDash([])}function _t(e,t,n,s={}){const{ctx:l,plotBox:i}=e,o=j(n,t,i.width,i.left);l.beginPath(),l.moveTo(o,i.top),l.lineTo(o,i.top+i.height),l.strokeStyle=s.stroke??"red",l.lineWidth=s.width??1,s.dash&&l.setLineDash(s.dash),l.stroke(),s.dash&&l.setLineDash([])}function Ps(e,t,n,s,l,i,o={}){const{ctx:r,plotBox:a}=e,f=j(s,t,a.width,a.left),u=j(l,n,a.height,a.top);r.font=o.font??"12px sans-serif",r.fillStyle=o.fill??"#000",r.textBaseline="bottom",r.fillText(i,f,u-4)}function Et(e,t,n,s,l={}){const{ctx:i,plotBox:o}=e,r=j(s,t,o.height,o.top),a=j(n,t,o.height,o.top);i.fillStyle=l.fill??"rgba(255,0,0,0.1)",i.fillRect(o.left,Math.min(r,a),o.width,Math.abs(a-r)),l.stroke&&(i.strokeStyle=l.stroke,i.lineWidth=l.width??1,l.dash&&i.setLineDash(l.dash),i.strokeRect(o.left,Math.min(r,a),o.width,Math.abs(a-r)),l.dash&&i.setLineDash([]))}function Rs(e){const t=A.useRef(e);return A.useLayoutEffect(()=>{t.current=e}),Me(n=>{const s=t.current,l=s.yScale??"y",i=n.getScale(l);if(i!=null&&(Ft(n,i,s.value,{stroke:s.stroke,width:s.width,dash:s.dash}),s.label!=null)){const o=n.valToY(s.value,l);if(o==null)return;const{ctx:r,plotBox:a}=n;r.font=s.labelFont??"11px sans-serif",r.fillStyle=s.stroke??"red",r.textAlign="left",r.textBaseline="bottom",r.fillText(s.label,a.left+4,o-4)}}),null}function Ds(e){const t=A.useRef(e);return A.useLayoutEffect(()=>{t.current=e}),Me(n=>{const s=t.current,l=s.xScale??"x",i=n.getScale(l);if(i!=null&&(_t(n,i,s.value,{stroke:s.stroke,width:s.width,dash:s.dash}),s.label!=null)){const o=n.valToX(s.value,l);if(o==null)return;const{ctx:r,plotBox:a}=n;r.font=s.labelFont??"11px sans-serif",r.fillStyle=s.stroke??"red",r.textAlign="center",r.textBaseline="bottom",r.fillText(s.label,o,a.top-4)}}),null}function zs(e){const t=A.useRef(e);return A.useLayoutEffect(()=>{t.current=e}),Me(n=>{const s=t.current,l=n.getScale(s.yScale??"y");l!=null&&Et(n,l,s.yMin,s.yMax,{fill:s.fill,stroke:s.stroke,width:s.strokeWidth,dash:s.dash})}),null}function Fs(e){const t=A.useRef(e);return A.useLayoutEffect(()=>{t.current=e}),Me(n=>{const s=t.current,l=n.valToX(s.x,s.xScale??"x"),i=n.valToY(s.y,s.yScale??"y");if(l==null||i==null)return;const{ctx:o}=n;o.font=s.font??"12px sans-serif",o.fillStyle=s.fill??"#000",o.textAlign=s.align??"left",o.textBaseline=s.baseline??"bottom",o.fillText(s.text,l,i-4)}),null}function _s(e,t){const{window:n,batchSize:s=1}=t,l=t.autoStart??!0,[i,o]=A.useState(()=>Xe(e)),[r,a]=A.useState(!1),[f,u]=A.useState(0),d=A.useRef(0),c=A.useRef(0),h=A.useRef(0),m=A.useRef(new Map),v=A.useRef(0),C=A.useRef(n);C.current=n;const g=A.useRef(s);g.current=s;const y=A.useCallback((D,S,...M)=>{let P=m.current.get(D);P==null&&(P={x:[],series:M.map(()=>[])},m.current.set(D,P)),P.x.push(...S);for(let p=0;p<M.length;p++){let w=P.series[p];w==null&&(w=[],P.series[p]=w),w.push(...M[p]??[])}const R=P.x.length;v.current===0&&R>=g.current&&(v.current=requestAnimationFrame(()=>{v.current=0;const p=m.current;m.current=new Map;const w=C.current;o(x=>{const b=x.slice();for(const[k,{x:I,series:z}]of p){const _=b[k];if(_==null)continue;const F=_.x,H=Math.max(0,F.length+I.length-w),G=H>0?F.slice(H).concat(I):F.concat(I),$=_.series.map((V,U)=>{const J=V,pe=z[U]??[];return H>0?J.slice(H).concat(pe):J.concat(pe)});b[k]={x:G,series:$}}return b})}))},[]),L=A.useCallback((D,...S)=>{y(0,D,...S)},[y]),T=A.useCallback(()=>{a(!0)},[]),E=A.useCallback(()=>{a(!1)},[]);return A.useEffect(()=>{if(!r){d.current!==0&&(cancelAnimationFrame(d.current),d.current=0);return}h.current=performance.now(),c.current=0;const D=S=>{c.current++;const M=S-h.current;M>=1e3&&(u(Math.round(c.current*1e3/M)),c.current=0,h.current=S),d.current=requestAnimationFrame(D)};return d.current=requestAnimationFrame(D),()=>{d.current!==0&&(cancelAnimationFrame(d.current),d.current=0)}},[r]),A.useEffect(()=>()=>{v.current!==0&&cancelAnimationFrame(v.current)},[]),A.useEffect(()=>{l&&a(!0)},[l]),{data:i,push:L,pushGroup:y,start:T,stop:E,running:r,fps:f}}function Es(e){return(t,n,s,l,i,o,r,a,f,u,d,c,h)=>{const m=(h==null?void 0:h.align)??e??1,v=(h==null?void 0:h.spanGaps)??!1;if([f,u]=Pe(n,f,u),f===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const C=P=>c(j(P,s,i,r)),g=P=>c(j(P,l,o,a)),y=s.ori===B.Horizontal?Re:De,L={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},T=L.stroke;let E=!1;const D=d===K.Forward?f:u;let S=g(n[D]),M=C(t[D]);y(T,M,S);for(let P=D;P>=f&&P<=u;P+=d){const R=n[P];if(R==null){R===null&&!v&&(E=!0);continue}const p=C(t[P]),w=g(R);if(m===1)y(T,p,S);else if(m===-1)y(T,M,w);else{const x=c((M+p)/2);y(T,x,S),y(T,x,w)}y(T,p,w),S=w,M=p}{const P=L.fill=new Path2D(T),R=(h==null?void 0:h.fillTo)??l.min??0,p=g(R);let w=r,x=r+i;d===K.Backward&&([x,w]=[w,x]),y(P,x,p),y(P,w,p)}if(E){const P=je(t,n,f,u,d,C);L.gaps=P,L.clip=Be(P,s.ori,r,a,i,o)}return L}}function Ht(){return(e,t,n,s,l,i,o,r,a,f,u,d,c)=>{const h=(c==null?void 0:c.barWidth)??.6,m=(c==null?void 0:c.barGap)??0,v=(c==null?void 0:c.barRadius)??0,C=(c==null?void 0:c.barGroupIdx)??0,g=(c==null?void 0:c.barGroupCount)??1,y=x=>d(j(x,n,l,o)),L=x=>d(j(x,s,i,r));let T=l;if(f>a){let x=1/0,b=-1;for(let k=a;k<=f;k++)if(t[k]!=null){if(b>=0){const I=e[k],z=e[b],_=Math.abs(y(I)-y(z));_<x&&(x=_)}b=k}x<1/0&&(T=x)}const E=T*(1-h),D=Math.max(0,E+m),S=Math.max(1,d(T-D)),M=g>1?Math.max(1,d(S/Math.max(1,g))):S,P=(c==null?void 0:c.fillTo)??s.min??0,R=L(P),p=new Path2D,w=n.ori===B.Horizontal;for(let x=u===K.Forward?a:f;x>=a&&x<=f;x+=u){const b=t[x];if(b==null)continue;const k=y(e[x]),I=L(b),z=g>1?(C-(g-1)/2)*M:0,_=d(k-M/2+z),F=Math.min(I,R),G=Math.max(I,R)-F;if(G!==0)if(v>0){const $=Math.min(v*M,G/2);Gt(p,w,_,F,M,G,$,b<P)}else w?p.rect(_,F,M,G):p.rect(F,_,G,M)}return{stroke:p,fill:p,clip:null,band:null,gaps:null}}}function Hs(e,t){const n=Ht();return(s,l,i,o,r,a,f,u,d,c,h,m,v)=>{const C={...v,barGroupIdx:e,barGroupCount:t};return n(s,l,i,o,r,a,f,u,d,c,h,m,C)}}function Gs(){return(e,t,n,s,l,i,o,r,a,f,u,d,c)=>{const h=(c==null?void 0:c.barWidth)??.8,m=(c==null?void 0:c.barGap)??0,v=(c==null?void 0:c.barRadius)??0,C=R=>d(j(R,n,l,o)),g=R=>d(j(R,s,i,r));let y=l;if(f>a){let R=1/0,p=-1;for(let w=a;w<=f;w++)if(t[w]!=null){if(p>=0){const x=e[w],b=e[p],k=Math.abs(C(x)-C(b));k<R&&(R=k)}p=w}R<1/0&&(y=R)}const L=y*(1-h),T=Math.max(0,L+m),E=Math.max(1,d(y-T)),D=(c==null?void 0:c.fillTo)??s.min??0,S=g(D),M=new Path2D,P=n.ori===B.Horizontal;for(let R=u===K.Forward?a:f;R>=a&&R<=f;R+=u){const p=t[R];if(p==null)continue;const w=C(e[R]),x=g(p),b=d(w-E/2),k=Math.min(x,S),z=Math.max(x,S)-k;if(z!==0)if(v>0){const _=Math.min(v*E,z/2);Gt(M,P,b,k,E,z,_,p<D)}else P?M.rect(b,k,E,z):M.rect(k,b,z,E)}return{stroke:M,fill:M,clip:null,band:null,gaps:null}}}function Gt(e,t,n,s,l,i,o,r){o=Math.min(o,l/2,i/2),t?r?(e.moveTo(n,s),e.lineTo(n+l,s),e.lineTo(n+l,s+i-o),e.arc(n+l-o,s+i-o,o,0,Math.PI/2),e.lineTo(n+o,s+i),e.arc(n+o,s+i-o,o,Math.PI/2,Math.PI),e.closePath()):(e.moveTo(n,s+i),e.lineTo(n,s+o),e.arc(n+o,s+o,o,Math.PI,Math.PI*1.5),e.lineTo(n+l-o,s),e.arc(n+l-o,s+o,o,Math.PI*1.5,0),e.lineTo(n+l,s+i),e.closePath()):r?(e.moveTo(s,n),e.lineTo(s,n+l),e.lineTo(s+i-o,n+l),e.arc(s+i-o,n+l-o,o,Math.PI/2,0,!0),e.lineTo(s+i,n+o),e.arc(s+i-o,n+o,o,0,-Math.PI/2,!0),e.closePath()):(e.moveTo(s+i,n),e.lineTo(s+o,n),e.arc(s+o,n+o,o,-Math.PI/2,Math.PI,!0),e.lineTo(s,n+l-o),e.arc(s+o,n+l-o,o,Math.PI,Math.PI/2,!0),e.lineTo(s+i,n+l),e.closePath())}function $t(e){return(t,n,s,l,i,o,r,a,f,u,d,c,h)=>{const m=(h==null?void 0:h.spanGaps)??!1;if([f,u]=Pe(n,f,u),f===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const v=M=>c(j(M,s,i,r)),C=M=>c(j(M,l,o,a)),g=s.ori===B.Horizontal?Re:De,y=[],L=[];let T=!1;for(let M=d===K.Forward?f:u;M>=f&&M<=u;M+=d){const P=n[M];P!=null?(y.push(v(t[M])),L.push(C(P))):P===null&&!m&&(T=!0)}const E=s.ori===B.Horizontal,D=e(y,L,E,c),S={stroke:D??new Path2D,fill:null,clip:null,band:null,gaps:null};if(D!=null){const M=S.fill=new Path2D(D),P=(h==null?void 0:h.fillTo)??l.min??0,R=C(P);let p=r,w=r+i;d===K.Backward&&([w,p]=[p,w]),g(M,w,R),g(M,p,R)}if(T){const M=je(t,n,f,u,d,v);S.gaps=M,S.clip=Be(M,s.ori,r,a,i,o)}return S}}function $s(){return $t(Ws)}const Ws=(e,t,n,s)=>{const l=e.length;if(l<2)return null;const i=new Path2D,o=e[0]??0,r=t[0]??0;if(n?i.moveTo(o,r):i.moveTo(r,o),l===2){const c=e[1]??0,h=t[1]??0;return n?i.lineTo(c,h):i.lineTo(h,c),i}const a=new Array(l),f=new Array(l-1),u=new Array(l-1),d=new Array(l-1);for(let c=0;c<l-1;c++)u[c]=(t[c+1]??0)-(t[c]??0),d[c]=(e[c+1]??0)-(e[c]??0),f[c]=d[c]!==0?(u[c]??0)/(d[c]??1):0;a[0]=f[0]??0;for(let c=1;c<l-1;c++){const h=f[c]??0,m=f[c-1]??0;if(h===0||m===0||m>0!=h>0)a[c]=0;else{const v=d[c]??1,C=d[c-1]??1;a[c]=3*(C+v)/((2*v+C)/m+(v+2*C)/h),isFinite(a[c]??0)||(a[c]=0)}}a[l-1]=f[l-2]??0;for(let c=0;c<l-1;c++){const h=d[c]??1,m=e[c]??0,v=t[c]??0,C=e[c+1]??0,g=t[c+1]??0,y=a[c]??0,L=a[c+1]??0,T=m+h/3,E=v+y*h/3,D=C-h/3,S=g-L*h/3;n?i.bezierCurveTo(T,E,D,S,C,g):i.bezierCurveTo(E,T,S,D,g,C)}return i};function Vs(){return $t(js)}const js=(e,t,n,s)=>{const l=e.length;if(l<2)return null;const i=new Path2D,o=s(e[0]??0),r=s(t[0]??0);if(n?i.moveTo(o,r):i.moveTo(r,o),l===2){const a=s(e[1]??0),f=s(t[1]??0);return n?i.lineTo(a,f):i.lineTo(f,a),i}for(let a=0;a<l-1;a++){const f=a===0?0:a-1,u=e[f]??0,d=t[f]??0,c=e[a]??0,h=t[a]??0,m=e[a+1]??0,v=t[a+1]??0,C=a+2<l?e[a+2]??0:m,g=a+2<l?t[a+2]??0:v,y=Math.hypot(u-c,d-h),L=Math.hypot(c-m,h-v),T=Math.hypot(m-C,v-g),E=Math.sqrt(T),D=T,S=Math.sqrt(L),M=L,P=Math.sqrt(y),R=y,p=2*R+3*P*S+M,w=2*D+3*E*S+M,x=3*P*(P+S),b=3*E*(E+S);let k,I,z,_;if(x>0){const F=1/x;k=(-M*u+p*c+R*m)*F,I=(-M*d+p*h+R*v)*F}else k=c,I=h;if(b>0){const F=1/b;z=(D*c+w*m-M*C)*F,_=(D*h+w*v-M*g)*F}else z=m,_=v;n?i.bezierCurveTo(k,I,z,_,m,v):i.bezierCurveTo(I,k,_,z,v,m)}return i};function Bs(e=4){return(t,n,s,l,i,o,r,a,f,u,d,c,h)=>{const m=L=>c(j(L,s,i,r)),v=L=>c(j(L,l,o,a)),C=e/2,g=new Path2D,y=s.ori===B.Horizontal;for(let L=d===K.Forward?f:u;L>=f&&L<=u;L+=d){const T=n[L];if(T==null)continue;const E=m(t[L]),D=v(T);y?(g.moveTo(E+C,D),g.arc(E,D,C,0,Math.PI*2)):(g.moveTo(D+C,E),g.arc(D,E,C,0,Math.PI*2))}return{stroke:g,fill:g,clip:null,band:null,gaps:null}}}function Xs(e){return({ctx:t,plotBox:n,pxRatio:s})=>{const{xValues:l,open:i,high:o,low:r,close:a,xScale:f,yScale:u,upColor:d="#26a69a",downColor:c="#ef5350",bodyWidth:h=.6,wickWidth:m=1}=e;if(f.min==null||f.max==null||u.min==null||u.max==null)return;const v=l.length;if(v===0)return;const g=Math.max(2,n.width/v*h)*s/2;t.save();for(let y=0;y<v;y++){const L=l[y],T=i[y],E=o[y],D=r[y],S=a[y];if(L==null||T==null||E==null||D==null||S==null)continue;const M=j(L,f,n.width,n.left)*s,P=j(T,u,n.height,n.top)*s,R=j(E,u,n.height,n.top)*s,p=j(D,u,n.height,n.top)*s,w=j(S,u,n.height,n.top)*s,b=S>=T?d:c;t.strokeStyle=b,t.lineWidth=m*s,t.beginPath(),t.moveTo(M,R),t.lineTo(M,p),t.stroke();const k=Math.min(P,w),I=Math.abs(w-P);t.fillStyle=b,t.fillRect(M-g,k,g*2,Math.max(I,1*s))}t.restore()}}function Ys(e,t,n=0){const s=t??e.series.map((u,d)=>d),l=e.x.length,i=[],o=new Float64Array(l);for(let u=0;u<s.length;u++){const d=s[u];if(d==null)continue;const c=e.series[d];if(c==null)continue;const h=new Array(l);for(let m=0;m<l;m++){const v=c[m];v!=null?(o[m]=o[m]+v,h[m]=o[m]):h[m]=null}i.push(h)}const r=new Map;for(let u=0;u<s.length;u++){const d=s[u];d!=null&&r.set(d,u)}const a=[];for(let u=0;u<e.series.length;u++){const d=r.get(u)??-1,c=d>=0?i[d]:void 0;c!=null?a.push(c):a.push(e.series[u]??[])}const f=[];for(let u=s.length-1;u>0;u--){const d=s[u],c=s[u-1];d!=null&&c!=null&&f.push({group:n,series:[d,c]})}return{group:{x:e.x,series:a},bands:f}}function Ks(e){const t=new Set;for(const[i]of e)for(let o=0;o<i.length;o++){const r=i[o];r!=null&&t.add(r)}const n=Float64Array.from([...t].sort((i,o)=>i-o)),s=new Map;for(let i=0;i<n.length;i++){const o=n[i];o!=null&&s.set(o,i)}const l=[];for(const[i,o]of e){const r=new Array(n.length).fill(null);for(let a=0;a<i.length;a++){const f=i[a];if(f==null)continue;const u=s.get(f);u!=null&&(r[u]=o[a]??null)}l.push(r)}return[{x:n,series:l}]}function Us(e){const t=(e==null?void 0:e.decimals)??1;return n=>n.map(s=>{const l=Math.abs(s);return l>=1e9?(s/1e9).toFixed(t)+"B":l>=1e6?(s/1e6).toFixed(t)+"M":l>=1e3?(s/1e3).toFixed(t)+"K":s.toFixed(l>=1?0:t)})}function Ns(e,t=0){return n=>n.map(s=>s.toFixed(t)+e)}function Os(e,t=0){return n=>n.map(s=>e+s.toFixed(t))}function qs(e,t,n=0){return s=>s.map(l=>e+l.toFixed(n)+t)}function Zs(e){const t=(e==null?void 0:e.utc)??!1;return n=>n.map(s=>t?ee(s,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC"):ee(s,{hour:"2-digit",minute:"2-digit",hour12:!1}))}function Js(e){const t=e!=null&&e.utc?"UTC":void 0,n=(e==null?void 0:e.format)??"short";return s=>s.map(l=>ee(l,{month:n},t))}function Qs(e){const{tz:t,...n}=e??{};return s=>s.map(l=>ee(l,n,t))}function eo(e,t=0){return n=>n.map(s=>{const l=Math.round(s)-t;return e[l]??String(s)})}function Wt(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(e);if(t)return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)];const n=/^#([0-9a-f])([0-9a-f])([0-9a-f])/i.exec(e);if(n)return[parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];const s=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i.exec(e);return s?[Number(s[1]),Number(s[2]),Number(s[3])]:null}function to(e,t=.8,n=0){const s=Wt(e);if(s==null)return{type:"linear",stops:[[0,e],[1,e]]};const[l,i,o]=s;return{type:"linear",stops:[[0,`rgba(${l},${i},${o},${t})`],[1,`rgba(${l},${i},${o},${n})`]]}}function no(e,t){const n=Wt(e);if(n==null)return e;const[s,l,i]=n;return`rgba(${s},${l},${i},${t})`}function so(e,t=65,n=50){const s=[];for(let i=0;i<e;i++){const o=i*137.508%360;s.push(`hsl(${o.toFixed(1)},${t}%,${n}%)`)}return s}exports.AnnotationLabel=Fs;exports.Axis=Ae;exports.Band=us;exports.Chart=Ye;exports.Direction=K;exports.Distribution=N;exports.FloatingLegend=As;exports.HLine=Rs;exports.HoverLabel=Ls;exports.Legend=ms;exports.Orientation=B;exports.Region=zs;exports.Scale=Ie;exports.Series=Ue;exports.Side=Y;exports.SortOrder=xe;exports.Sparkline=Ts;exports.Timeline=ks;exports.Tooltip=Ms;exports.VLine=Ds;exports.ZoomRanger=ys;exports.alignData=Ks;exports.bars=Ht;exports.catmullRom=Vs;exports.drawCandlesticks=Xs;exports.drawHLine=Ft;exports.drawLabel=Ps;exports.drawRegion=Et;exports.drawVLine=_t;exports.fadeGradient=to;exports.fmtCompact=Us;exports.fmtDateStr=Qs;exports.fmtHourMin=Zs;exports.fmtLabels=eo;exports.fmtMonthName=Js;exports.fmtPrefix=Os;exports.fmtSuffix=Ns;exports.fmtWrap=qs;exports.groupedBars=Hs;exports.linear=At;exports.monotoneCubic=$s;exports.palette=so;exports.points=Bs;exports.posToVal=se;exports.sideOrientation=ge;exports.stackGroup=Ys;exports.stackedBars=Gs;exports.stepped=Es;exports.useChart=Q;exports.useCursorDrawHook=Cs;exports.useDrawHook=Me;exports.useStreamingData=_s;exports.valToPos=j;exports.withAlpha=no;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("react/jsx-runtime"),E=require("react");function dn(t=.15){return e=>{e.focusAlpha=t}}const Ft=[["leftDrag","zoomX"],["leftDblclick","reset"],["wheel","zoomX"],["xGutterDrag","panX"],["yGutterDrag","panY"],["pinch","zoomX"],["touchDrag","zoomX"]];var Y=(t=>(t[t.Top=0]="Top",t[t.Right=1]="Right",t[t.Bottom=2]="Bottom",t[t.Left=3]="Left",t))(Y||{}),H=(t=>(t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical",t))(H||{}),O=(t=>(t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward",t))(O||{}),K=(t=>(t[t.Linear=1]="Linear",t[t.Ordinal=2]="Ordinal",t[t.Log=3]="Log",t[t.Asinh=4]="Asinh",t))(K||{}),xt=(t=>(t[t.Ascending=1]="Ascending",t[t.Descending=-1]="Descending",t[t.Unsorted=0]="Unsorted",t))(xt||{});function vt(t){return t%2}var ot=(t=>(t[t.None=0]="None",t[t.Scales=1]="Scales",t[t.Axes=2]="Axes",t[t.Paths=4]="Paths",t[t.Cursor=8]="Cursor",t[t.Select=16]="Select",t[t.Size=32]="Size",t[t.Full=63]="Full",t))(ot||{});const Z=Math,$t=Z.PI,tt=Z.abs,st=Z.floor,B=Z.round,It=Z.ceil,qt=Z.min,Mt=Z.max,mt=Z.pow,we=Z.sign,et=Z.log10,Ct=Z.log2,gn=(t,e=1)=>Z.sinh(t)*e,Qt=(t,e=1)=>Z.asinh(t/e),U=1/0,$e=Number.isInteger;function Vt(t,e){return t[e]??0}function ft(t,e,n=0,o=e.length-1){let s;const r=o<=2147483647;for(;o-n>1;)s=r?n+o>>1:st((n+o)/2),Vt(e,s)<t?n=s:o=s;return t-Vt(e,n)<=Vt(e,o)-t?n:o}const Ve=t=>t!=null,Be=t=>t!=null&&t>0;function Xe(t){return(e,n,o)=>{let s=-1,r=-1;for(let i=n;i<=o;i++)if(t(e[i])){s=i;break}for(let i=o;i>=n;i--)if(t(e[i])){r=i;break}return[s,r]}}const Ht=Xe(Ve),je=Xe(Be);function pn(t,e,n,o=xt.Unsorted,s=!1){const r=s?je:Ht,i=s?Be:Ve,[l,c]=r(t,e,n);let f=t[l]??U,a=t[l]??-U;if(l>-1)if(o===xt.Ascending)f=t[l]??U,a=t[c]??-U;else if(o===xt.Descending)f=t[c]??U,a=t[l]??-U;else for(let d=l;d<=c;d++){const u=t[d];u!=null&&i(u)&&(u<f?f=u:u>a&&(a=u))}return[f,a]}function ht(t,e=0){if($e(t))return t;const n=10**e,o=t*n*(1+Number.EPSILON);return B(o)/n}const yt=new Map;function mn(t){return(String(t).split(".")[1]??"").length}const wn=/\.\d*?(?=9{6,}|0{6,})/gm;function At(t){if($e(t)||yt.has(t))return t;const e=`${t}`,n=e.match(wn);if(n==null)return t;const o=n[0].length-1;if(e.indexOf("e-")!==-1){const s=e.split("e"),r=s[0]??"0",i=s[1]??"0";return+`${At(+r)}e${i}`}return ht(t,o)}function te(t,e,n=!0){return n?At(It(At(t/e))*e):It(t/e)*e}function Ye(t,e,n=!0){return n?At(st(At(t/e))*e):st(t/e)*e}function Ne(t,e,n,o){const s=[],r=o.map(mn);for(let i=e;i<n;i++){const l=tt(i);for(let c=0;c<o.length;c++){const f=o[c]??0,a=r[c]??0,d=+`${f}e${i}`,u=(i>=0?0:l)+(i>=a?0:a),h=d;s.push(h),yt.set(h,u)}}return s}function q(t,e,n){return qt(Mt(t,e),n)}const vn=new Intl.NumberFormat,Oe=t=>vn.format(t);function ve(t,e,n){for(;e<=n;){if(t[e]!=null)return!0;e++}return!1}const bn=.1,ct={mode:3,pad:bn,soft:null},Tt={pad:0,soft:null,mode:0},Sn={min:Tt,max:Tt};function Bt(t,e,n,o){let s;typeof n=="number"?(Tt.pad=n,Tt.soft=null,Tt.mode=0,s=Sn):s=n;const r=s.min,i=s.max,l=r.pad,c=i.pad,f=r.hard??-U,a=i.hard??U,d=r.soft??U,u=i.soft??-U,h=r.mode,p=i.mode;let x=e-t;const y=et(x),g=Mt(tt(t),tt(e)),S=et(g),T=tt(S-y);(x<1e-24||T>10)&&(x=0,(t===0||e===0)&&(x=1e-24));const M=x||g||1e3,_=et(M),P=mt(10,st(_)),C=M*(x===0?t===0?.1:1:l),k=ht(Ye(t-C,P/10),24),A=h===1||h===3&&k<=d||h===2&&k>=d,D=t>=d&&A?d:U,m=Mt(f,k<D&&t>=D?D:qt(D,k)),v=M*(x===0?e===0?.1:1:c),b=ht(te(e+v,P/10),24),w=p===1||p===3&&b>=u||p===2&&b<=u,I=e<=u&&w?u:-U,L=qt(a,b>I&&e<=I?I:Mt(I,b));return m===L&&m===0?[-1,1]:[m,L]}function Ke(t,e,n,o){n===2&&(o=!0);const s=we(t),r=we(e);t===e&&(s===-1?(t*=n,e/=n):(t/=n,e*=n));const i=n===10?et:Ct,l=s===1?st:It,c=r===1?It:st,f=i(tt(t)),a=i(tt(e)),d=l(f),u=c(a);let h=mt(n,d),p=mt(n,u);return n===10&&(d<0&&(h=ht(h,-d)),u<0&&(p=ht(p,-u))),o?(t=h*s,e=p*r):(t=Ye(t,mt(n,st(f)),!1),e=te(e,mt(n,st(a)),!1)),[t,e]}function xn(t,e,n,o){const s=Ke(t,e,n,o);return t===0&&(s[0]=0),e===0&&(s[1]=0),s}function be(t){return(et((t^t>>31)-(t>>31))|0)+1}function Mn(t,e,n,o,s){const r=Mt(be(t),be(e)),i=e-t;let l=Mt(0,ft(s/o*i,n)-1);do{const c=n[l]??0,f=o*c/i;if(f>=s*.9&&r+(c<5?yt.get(c)??0:0)<=17)return[c,f]}while(++l<n.length);return[0,0]}function yn(t){return{id:t.id,min:t.min??null,max:t.max??null,distr:t.distr??K.Linear,log:t.log??10,asinh:t.asinh??1,ori:t.ori??(t.id==="x"?H.Horizontal:H.Vertical),dir:t.dir??O.Forward,time:t.time??!1,auto:t.auto??!0,range:t.range??null,_discrete:!1,_cfgMin:t.min??null,_cfgMax:t.max??null,_min:null,_max:null}}function N(t){return t.min!=null&&t.max!=null}function rt(t){t._min=null,t._max=null}function Ue(t){if(t._min!=null)return t._min;const{min:e,distr:n}=t;if(e==null)return 0;if(n===K.Log){e<=0&&console.warn(`[uPlot+] Log scale "${t.id}": min value ${e} <= 0, clamping to 1e-10`);const o=e>0?e:1e-10;t._min=(t.log===10?et:Ct)(o)}else n===K.Asinh?t._min=Qt(e,t.asinh):t._min=e;return t._min}function qe(t){if(t._max!=null)return t._max;const{max:e,distr:n}=t;if(e==null)return 0;if(n===K.Log){e<=0&&console.warn(`[uPlot+] Log scale "${t.id}": max value ${e} <= 0, clamping to 1e-10`);const o=e>0?e:1e-10;t._max=(t.log===10?et:Ct)(o)}else n===K.Asinh?t._max=Qt(e,t.asinh):t._max=e;return t._max}function Cn(t,e){if(e.min==null||e.max==null)return 0;const n=Ue(e),s=qe(e)-n;if(s===0)return 0;const{distr:r}=e;if(r===K.Log){const i=e.log===10?et:Ct,l=t>0?t:1e-10;return(i(l)-n)/s}return r===K.Asinh?(Qt(t,e.asinh)-n)/s:(t-n)/s}function kn(t,e){if(e.min==null||e.max==null)return 0;const n=Ue(e),o=qe(e);if(o===n)return e.min;const{distr:s}=e;return s===K.Log?Math.pow(e.log,n+t*(o-n)):s===K.Asinh?gn(n+t*(o-n),e.asinh):n+t*(o-n)}function X(t,e,n,o){const s=Cn(t,e);let r;return e.ori===H.Horizontal?r=e.dir===O.Forward?s:1-s:r=e.dir===O.Forward?1-s:s,o+r*n}function lt(t,e,n,o){if(n===0)return e.min??0;let s=(t-o)/n;return e.ori===H.Horizontal?e.dir===O.Backward&&(s=1-s):e.dir!==O.Backward&&(s=1-s),kn(s,e)}class Tn{constructor(){this.scales=new Map,this.groupXScales=new Map}addScale(e){this.scales.set(e.id,yn(e))}removeScale(e){this.scales.delete(e)}getScale(e){return this.scales.get(e)}getAllScales(){return this.scales.values()}setGroupXScale(e,n){this.groupXScales.set(e,n)}getGroupXScaleKey(e){return this.groupXScales.get(e)}setRange(e,n,o){const s=this.scales.get(e);s&&(s.min=n,s.max=o,rt(s))}autoRangeX(e){var o,s,r,i,l,c;const n=new Map;for(const[f,a]of this.groupXScales){const d=this.scales.get(a);if(!d||!d.auto)continue;const u=e[f];if(!u||u.x.length===0)continue;const h=u.x[0],p=u.x[u.x.length-1];if(h==null||p==null)continue;const x=n.get(a);x?(x.dataMin=Math.min(x.dataMin,h),x.dataMax=Math.max(x.dataMax,p),x.groups.push(f)):n.set(a,{dataMin:h,dataMax:p,groups:[f]})}for(const[f,{dataMin:a,dataMax:d,groups:u}]of n){const h=this.scales.get(f);if(!h)continue;let p=!0,x=U;for(const y of u){const g=e[y];if(g){for(let S=0;S<g.x.length;S++)if(Number.isInteger(g.x[S])||(p=!1),S>0){const T=g.x[S]-g.x[S-1];T>0&&T<x&&(x=T)}}}if(h._discrete=p,h.range){const[y,g]=Bt(a,d,{min:{pad:((o=h.range.min)==null?void 0:o.pad)??0,soft:((s=h.range.min)==null?void 0:s.soft)??null,mode:((r=h.range.min)==null?void 0:r.mode)??0},max:{pad:((i=h.range.max)==null?void 0:i.pad)??0,soft:((l=h.range.max)==null?void 0:l.soft)??null,mode:((c=h.range.max)==null?void 0:c.mode)??0}});h.min=y,h.max=g}else if(a===d)[h.min,h.max]=Bt(a,d,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}});else if(x<U){const y=x/2;h.min=a-y,h.max=d+y}else h.min=a,h.max=d;h._cfgMin!=null&&(h.min=h._cfgMin),h._cfgMax!=null&&(h.max=h._cfgMax),rt(h)}}autoRange(e,n,o){var i,l,c,f,a,d;const s=new Map,r=new Map;for(const{group:u,index:h,yScale:p}of n){const x=e[u];if(!x)continue;const y=x.series[h];if(!y||y.length===0)continue;const g=o.windows.get(u),S=g?g[0]:0,T=g?g[1]:y.length-1,M=this.scales.get(p),_=(M==null?void 0:M.distr)===K.Log,[P,C]=o.getCachedMinMax(u,h,S,T,0,_),k=s.get(p),A=r.get(p);s.set(p,k!=null?Math.min(k,P):P),r.set(p,A!=null?Math.max(A,C):C)}for(const[u,h]of s){const p=this.scales.get(u);if(!p||!p.auto)continue;const x=r.get(u)??-U;if(h===U)continue;let y,g;if(p.distr===K.Log)[y,g]=Ke(h,x,p.log,!1);else if(p.distr===K.Asinh)[y,g]=xn(h,x,p.log,!1);else{const S=p.range??{min:ct,max:ct};[y,g]=Bt(h,x,{min:{pad:((i=S.min)==null?void 0:i.pad)??ct.pad,soft:((l=S.min)==null?void 0:l.soft)??ct.soft,mode:((c=S.min)==null?void 0:c.mode)??ct.mode},max:{pad:((f=S.max)==null?void 0:f.pad)??ct.pad,soft:((a=S.max)==null?void 0:a.soft)??ct.soft,mode:((d=S.max)==null?void 0:d.mode)??ct.mode}})}p._cfgMin!=null&&(y=p._cfgMin),p._cfgMax!=null&&(g=p._cfgMax),p.min=y,p.max=g,rt(p)}}}const In=1024;class An{constructor(e,n=In){this.data=e,this.len=e.length,this.blockSize=n,this.nBlocks=Math.ceil(e.length/n),this.blocks=new Float64Array(this.nBlocks*2),this.buildAll()}buildAll(){const{data:e,blockSize:n,nBlocks:o,blocks:s,len:r}=this;for(let i=0;i<o;i++){const l=i*n,c=Math.min(l+n,r);let f=1/0,a=-1/0;for(let d=l;d<c;d++){const u=e[d];u!=null&&(u<f&&(f=u),u>a&&(a=u))}s[i*2]=f,s[i*2+1]=a}}rangeMinMax(e,n){const{data:o,blockSize:s,blocks:r}=this;let i=1/0,l=-1/0;const c=Math.floor(e/s),f=Math.floor(n/s);if(c===f){for(let u=e;u<=n;u++){const h=o[u];h!=null&&(h<i&&(i=h),h>l&&(l=h))}return[i,l]}const a=(c+1)*s-1;for(let u=e;u<=a;u++){const h=o[u];h!=null&&(h<i&&(i=h),h>l&&(l=h))}for(let u=c+1;u<f;u++){const h=r[u*2]??1/0,p=r[u*2+1]??-1/0;h<i&&(i=h),p>l&&(l=p)}const d=f*s;for(let u=d;u<=n;u++){const h=o[u];h!=null&&(h<i&&(i=h),h>l&&(l=h))}return[i,l]}updateBlock(e){const{data:n,blockSize:o,blocks:s,len:r}=this;if(e>=this.nBlocks)return;const i=e*o,l=Math.min(i+o,r);let c=1/0,f=-1/0;for(let a=i;a<l;a++){const d=n[a];d!=null&&(d<c&&(c=d),d>f&&(f=d))}s[e*2]=c,s[e*2+1]=f}grow(e){const n=this.nBlocks;if(this.len=e,this.nBlocks=Math.ceil(e/this.blockSize),this.nBlocks>n){const s=new Float64Array(this.nBlocks*2);s.set(this.blocks),this.blocks=s}const o=Math.max(0,n-1);for(let s=o;s<this.nBlocks;s++)this.updateBlock(s)}setData(e){this.data=e}}class Ln{constructor(){this.data=[],this.windows=new Map,this.minMaxCache=new Map,this.blockTrees=new Map}setData(e){this.data=e,this.windows.clear();for(const n of this.minMaxCache.values())n.clear();this.minMaxCache.clear(),this.blockTrees.clear()}getOrBuildTree(e,n){const o=`${e}:${n}`;let s=this.blockTrees.get(o);if(s)return s;const r=this.data[e];if(!r)return;const i=r.series[n];if(!(!i||i.length===0))return s=new An(i),this.blockTrees.set(o,s),s}updateWindows(e){var o;let n=!1;for(let s=0;s<this.data.length;s++){const r=this.data[s],i=e(s),l=this.windows.get(s);let c,f;if(!r||!i||!N(i))c=0,f=Math.max(0,((r==null?void 0:r.x.length)??1)-1);else{const a=r.x;if(a.length===0)c=0,f=0;else{c=ft(i.min,a),f=ft(i.max,a);const d=a[c],u=a[f];c>0&&d!=null&&d>i.min&&c--,f<a.length-1&&u!=null&&u<i.max&&f++}}(!l||l[0]!==c||l[1]!==f)&&(n=!0,(o=this.minMaxCache.get(s))==null||o.clear()),this.windows.set(s,[c,f])}return n}getWindow(e){var n;return this.windows.get(e)??[0,(((n=this.data[e])==null?void 0:n.x.length)||1)-1]}getXValues(e){var n;return((n=this.data[e])==null?void 0:n.x)??[]}getYValues(e,n){var o;return((o=this.data[e])==null?void 0:o.series[n])??[]}getCachedMinMax(e,n,o,s,r,i){let l=this.minMaxCache.get(e);const c=`${n}:${o}:${s}`;if(l){const h=l.get(c);if(h!=null)return h}else l=new Map,this.minMaxCache.set(e,l);const f=this.data[e];if(!f)return[1/0,-1/0];const a=f.series[n];if(!a||a.length===0)return[1/0,-1/0];let d;const u=!i&&r===xt.Unsorted?this.getOrBuildTree(e,n):void 0;return u?d=u.rangeMinMax(o,s):d=pn(a,o,s,r,i),l.set(c,d),d}getBlockTree(e,n){return this.getOrBuildTree(e,n)}appendData(e,n,o){var i;const s=this.data[e];if(!s)return;let r;Array.isArray(s.x)?r=s.x:(r=Array.from(s.x),s.x=r);for(let l=0;l<n.length;l++){const c=n[l];c!=null&&r.push(c)}for(let l=0;l<s.series.length;l++){let c=s.series[l];if(!c)continue;Array.isArray(c)||(c=Array.from(c),s.series[l]=c);const f=o[l];if(f){const d=c;for(let u=0;u<f.length;u++)d.push(f[u]??null)}const a=this.blockTrees.get(`${e}:${l}`);a&&(a.setData(c),a.grow(c.length))}(i=this.minMaxCache.get(e))==null||i.clear()}static toTypedX(e){for(const n of e)Array.isArray(n.x)&&(n.x=Float64Array.from(n.x));return e}}const Dt=-10;class Pn{constructor(){this.state={left:Dt,top:Dt,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1},this._groupedConfigs=new Map,this._groupedConfigsSource=null}getGroupedConfigs(e){if(this._groupedConfigsSource!==e){this._groupedConfigsSource=e,this._groupedConfigs.clear();for(const n of e){if(n.show===!1)continue;let o=this._groupedConfigs.get(n.group);o==null&&(o=[],this._groupedConfigs.set(n.group,o)),o.push(n)}}return this._groupedConfigs}invalidateGroupedConfigs(){this._groupedConfigsSource=null}hide(){this.state.left=Dt,this.state.top=Dt,this.state.activeGroup=-1,this.state.activeSeriesIdx=-1,this.state.activeDataIdx=-1}update(e,n,o,s,r,i,l,c){this.state.left=e,this.state.top=n;let f=1/0,a=-1,d=-1,u=-1;const h=this.getGroupedConfigs(r);for(let p=0;p<s.length;p++){const x=s[p];if(x==null)continue;const y=x.x;if(y.length===0)continue;const g=c(p);if(g==null)continue;const S=i(g);if(S==null||!N(S))continue;const[T,M]=l(p),_=o.width,P=o.left,C=lt(e+P,S,_,P),k=ft(C,y,T,M),A=[k];k>T&&A.push(k-1),k<M&&A.push(k+1);const D=new Map;for(const m of A){const v=y[m];if(v==null)continue;const b=X(v,S,_,P);for(const w of h.get(p)??[]){const I=x.series[w.index];if(I==null)continue;const L=I[m];if(L==null)continue;let R=D.get(w.yScale);if(R==null&&!D.has(w.yScale)&&(R=i(w.yScale),D.set(w.yScale,R)),R==null||!N(R))continue;const F=o.height,z=o.top,G=X(L,R,F,z),$=e+P-b,V=n+z-G,j=$*$+V*V;if(j<f&&(f=j,a=p,d=w.index,u=m,j===0))break}if(f===0)break}}this.state.activeGroup=a,this.state.activeSeriesIdx=d,this.state.activeDataIdx=u}syncToValue(e,n){const o=n.dataStore.data;if(o.length===0)return;const s=o[0];if(s==null)return;const r=n.scaleManager.getGroupXScaleKey(0);if(r==null)return;const i=n.scaleManager.getScale(r);if(i==null||!N(i))return;const[l,c]=n.dataStore.getWindow(0),f=ft(e,s.x,l,c),a=s.x[f];if(a==null)return;const d=X(a,i,n.plotBox.width,n.plotBox.left);this.state.left=d-n.plotBox.left,this.state.activeGroup=0,this.state.activeDataIdx=f;let u=0,h=n.plotBox.height/2;for(const p of n.seriesConfigs){if(p.group!==0||p.show===!1)continue;const x=s.series[p.index];if(x==null)continue;const y=x[f];if(y==null)continue;const g=n.scaleManager.getScale(p.yScale);if(!(g==null||!N(g))){h=X(y,g,n.plotBox.height,n.plotBox.top)-n.plotBox.top,u=p.index;break}}this.state.top=h,this.state.activeSeriesIdx=u}}class Dn{constructor(){this.flags=ot.None,this.frameId=null,this.callback=null}mark(e){this.flags|=e,this.scheduleFrame()}has(e){return(this.flags&e)!==0}get dirty(){return this.flags}clear(){this.flags=ot.None}onRedraw(e){this.callback=e}scheduleFrame(){this.frameId==null&&(this.frameId=requestAnimationFrame(()=>{this.frameId=null;const e=this.callback;e!=null&&e(),this.clear()}))}cancel(){this.frameId!=null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}dispose(){this.cancel(),this.callback=null,this.flags=ot.None}}const ee={width:1},En={width:0,fill:"auto",fillTo:0,points:{show:!1},cursor:{show:!1}},_n={width:0,cursor:{show:!1}};function Gt(t,e,n){t.lineTo(e,n)}function Wt(t,e,n){t.lineTo(n,e)}function ne(t,e,n,o,s,r){const i=[];let l=-1;const c=s===O.Forward?n:o,f=s===O.Forward?o:n,a=s;for(let d=c;s===O.Forward?d<=f:d>=f;d+=a)if(e[d]===null||e[d]===void 0){if(l===-1){const u=q(d-s,n,o);l=r(t[u])}}else l!==-1&&(i.push([l,r(t[d])]),l=-1);return l!==-1&&i.push([l,r(t[o])]),i}function oe(t,e,n,o,s,r){const i=new Path2D;let l=e===H.Horizontal?n:o;const c=e===H.Horizontal?n+s:o+r,f=e===H.Horizontal?o:n,a=e===H.Horizontal?r:s;for(const[d,u]of t)d>l&&(e===H.Horizontal?i.rect(l,f,d-l,a):i.rect(f,l,a,d-l)),l=u;return l<c&&(e===H.Horizontal?i.rect(l,f,c-l,a):i.rect(f,l,a,c-l)),i}function Ze(t){return(e,n,o,s,r,i)=>{o!==s&&(r!==o&&i!==o&&t(e,n,o),r!==s&&i!==s&&t(e,n,s),t(e,n,i))}}const Rn=Ze(Gt),Fn=Ze(Wt);function Je(){const t=(e,n,o,s,r,i,l,c,f,a,d,u,h)=>{const p=(h==null?void 0:h.spanGaps)??!1;if([f,a]=(s.distr===K.Log?je:Ht)(n,f,a),f===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const y=k=>u(X(k,o,r,l)),g=k=>u(X(k,s,i,c));let S,T;o.ori===H.Horizontal?(S=Gt,T=Rn):(S=Wt,T=Fn);const M={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},_=M.stroke;let P=!1;if(a-f>=r*4){const k=R=>lt(R,o,r,l);let A=null,D=0,m=0,v=0,b=y(e[d===O.Forward?f:a]);const w=y(e[f]),I=y(e[a]);let L=k(d===O.Forward?w+1:I-1);for(let R=d===O.Forward?f:a;R>=f&&R<=a;R+=d){const F=e[R],G=(d===O.Forward?F<L:F>L)?b:y(F),$=n[R];G===b?$!=null?(v=$,A==null?(S(_,G,g(v)),m=A=D=v):v<A?A=v:v>D&&(D=v)):$===null&&!p&&(P=!0):(A!=null&&T(_,b,g(A),g(D),g(m),g(v)),$!=null?(v=$,S(_,G,g(v)),A=D=m=v):(A=null,D=0,$===null&&!p&&(P=!0)),b=G,L=k(b+d))}A!=null&&(A!==D?T(_,b,g(A),g(D),g(m),g(v)):S(_,b,g(v)))}else for(let k=d===O.Forward?f:a;k>=f&&k<=a;k+=d){const A=n[k];A===null&&!p?P=!0:A!=null&&S(_,y(e[k]),g(A))}{const k=M.fill=new Path2D(_),A=(h==null?void 0:h.fillTo)??s.min??0,D=g(A);let m=y(e[f]),v=y(e[a]);d===O.Backward&&([v,m]=[m,v]),S(k,v,D),S(k,m,D)}if(P){const k=ne(e,n,f,a,d,y);M.gaps=k,M.clip=oe(k,o.ori,l,c,r,i)}return M};return t.defaults=ee,t}const Se=new WeakMap;function xe(t,e,n){return typeof e=="string"?e:zn(t,e,n)}function zn(t,e,n){const o=Se.get(e);if(o!=null&&o.left===n.left&&o.top===n.top&&o.width===n.width&&o.height===n.height)return o.grad;const s=t.createLinearGradient(0,n.top,0,n.top+n.height);for(const[r,i]of e.stops)s.addColorStop(r,i);return Se.set(e,{grad:s,left:n.left,top:n.top,width:n.width,height:n.height}),s}function Hn(t,e,n,o,s){if(e.show===!1)return;const r=e.alpha??1;t.save(),r<1&&(t.globalAlpha=r),n.clip&&t.clip(n.clip);const i=s??{left:0,top:0,width:t.canvas.width/o,height:t.canvas.height/o};if(e.fill&&n.fill&&(t.fillStyle=xe(t,e.fill,i),t.fill(n.fill)),e.stroke){const l=(e.width??1)*o;t.strokeStyle=xe(t,e.stroke,i),t.lineWidth=l,t.lineJoin=e.join??"round",t.lineCap=e.cap??"butt",e.dash&&t.setLineDash(e.dash.map(d=>d*o));const c=e.pxAlign??1,f=l%2/2;c===1&&f>0&&t.translate(f,f),t.stroke(n.stroke)}t.restore()}const Gn=Je(),Me=64;class Wn{constructor(){this.ctx=null,this.pxRatio=1,this.pathCache=new Map,this.bandCache=new Map,this.scaleStamp="",this.snapshotCanvas=null,this.snapshotValid=!1}setContext(e,n){this.ctx=e,this.pxRatio=n}saveSnapshot(e,n,o){const s=e.canvas;(this.snapshotCanvas==null||this.snapshotCanvas.width!==n||this.snapshotCanvas.height!==o)&&(this.snapshotCanvas=typeof OffscreenCanvas<"u"?new OffscreenCanvas(n,o):document.createElement("canvas"),this.snapshotCanvas.width=n,this.snapshotCanvas.height=o);const r=this.snapshotCanvas.getContext("2d");r!=null&&typeof r.drawImage=="function"&&(r.clearRect(0,0,n,o),r.drawImage(s,0,0),this.snapshotValid=!0)}restoreSnapshot(e){return!this.snapshotValid||this.snapshotCanvas==null||typeof e.drawImage!="function"?!1:(e.clearRect(0,0,e.canvas.width,e.canvas.height),e.drawImage(this.snapshotCanvas,0,0),!0)}invalidateSnapshot(){this.snapshotValid=!1}checkScaleStamp(e){let n="";const o=new Set;for(const s of e)for(const r of[s.xScale,s.yScale])o.has(r.id)||(o.add(r.id),n+=`${r.id}:${r.min}:${r.max};`);n!==this.scaleStamp&&(this.scaleStamp!==""&&this.clearCache(),this.scaleStamp=n)}cacheKey(e,n,o,s){return`${e}:${n}:${o}:${s}`}promote(e,n){this.pathCache.delete(e),this.pathCache.set(e,n)}getCachedPaths(e,n,o,s){const r=this.cacheKey(e,n,o,s),i=this.pathCache.get(r);if(i!=null)return this.promote(r,i),i;const l=`${e}:${n}:`;for(const[c,f]of this.pathCache){if(!c.startsWith(l))continue;const a=c.slice(l.length),d=a.indexOf(":"),u=+a.slice(0,d),h=+a.slice(d+1);if(u<=o&&h>=s)return this.promote(c,f),f}}setCachedPaths(e,n,o,s,r){if(this.pathCache.size>=Me){const l=Me>>2,c=this.pathCache.keys();for(let f=0;f<l;f++){const a=c.next().value;a!=null&&this.pathCache.delete(a)}}const i=this.cacheKey(e,n,o,s);this.pathCache.delete(i),this.pathCache.set(i,r)}invalidateSeries(e,n){const o=`${e}:${n}:`;for(const s of this.pathCache.keys())s.startsWith(o)&&this.pathCache.delete(s)}clearGroupCache(e){const n=`${e}:`;for(const o of this.pathCache.keys())o.startsWith(n)&&this.pathCache.delete(o);for(const o of this.bandCache.keys())o.startsWith(n)&&this.bandCache.delete(o);this.invalidateSnapshot()}clearCache(){this.pathCache.clear(),this.bandCache.clear(),this.invalidateSnapshot()}bandKey(e,n,o,s,r){return`${e}:${n}:${o}:${s}:${r}`}getCachedBandPath(e,n,o,s,r){return this.bandCache.get(this.bandKey(e,n,o,s,r))}setCachedBandPath(e,n,o,s,r,i){this.bandCache.set(this.bandKey(e,n,o,s,r),i)}drawSeries(e,n,o){const s=this.ctx;if(s==null||e.config.show===!1)return;const r=e.config.group,i=e.config.index,[l,c]=e.window;let f=this.getCachedPaths(r,i,l,c);if(f==null){const a=e.config.paths??Gn,d=e.xScale.dir,u=M=>B(M),h=c-l,p=Math.max(1,Math.ceil(h*.1)),x=e.dataX.length,y=Math.max(0,l-p),g=Math.min(x-1,c+p),S=e.config.fillTo;let T;typeof S=="function"?T=S(e.yScale.min??0,e.yScale.max??0):S===0&&e.yScale.distr===K.Log?T=1:T=S,f=a(e.dataX,e.dataY,e.xScale,e.yScale,n.width,n.height,n.left,n.top,y,g,d,u,{fillTo:T,spanGaps:e.config.spanGaps}),this.setCachedPaths(r,i,y,g,f)}Hn(s,e.config,f,o,n)}draw(e,n,o,s){const r=this.ctx;if(r==null)return;const i=this.pxRatio;r.clearRect(0,0,e*i,n*i),r.save(),r.scale(i,i),r.beginPath(),r.rect(o.left,o.top,o.width,o.height),r.clip();for(const l of s)this.drawSeries(l,o,1);r.restore()}}const Qe=[1,2,2.5,5],$n=Ne(10,-32,0,Qe),Vn=Ne(10,0,32,Qe),gt=$n.concat(Vn);function Bn(t,e,n,o,s){if(n<=0||e<t)return[];const r=[],i=yt.get(n)??0,l=s?Math.ceil(t/n)*n:ht(te(t,n),i);for(let c=l;c<=e;c=ht(c+n,i))r.push(Object.is(c,-0)?0:c);return r}function Xt(t){return t.map(e=>Oe(e))}function Xn(t,e,n){if(t<=0||e<=0||t>=e)return[];const o=[],r=st((n===10?et:Ct)(t));let i=mt(n,r);n===10&&(i=gt[ft(i,gt)]??i);let l=i,c=i*n;n===10&&(c=gt[ft(c,gt)]??c);let f=0;do{if(l>=t&&o.push(l),l=l+i,n===10&&!yt.has(l)){const a=yt.get(i)??0;l=ht(l,a)}l>=c*(1-1e-10)&&(i=l,c=i*n,n===10&&(c=gt[ft(c,gt)]??c))}while(l<=e&&++f<1e4);return o}function jn(t,e,n=1){const o=[];if(Math.max(tt(t),tt(e))===0)return[0];if(t<0){const i=tt(t);let l=mt(10,st(et(Math.max(i,n))));for(;l>=n;){const c=-l;c>=t&&c<=e&&o.push(c),l/=10}}if(t<=0&&e>=0&&o.push(0),e>0){let i=n;const l=e;for(;i<=l;)i>=t&&i<=e&&o.push(i),i*=10}o.sort((i,l)=>i-l);const r=[];for(const i of o){const l=r[r.length-1];(r.length===0||l!=null&&tt(i-l)>1e-10)&&r.push(i)}return r}function Yn(t,e){const n=e===10?et:Ct;return t.map(o=>{if(o===0)return!0;if(o<0)return!1;const s=n(o);return tt(s-Math.round(s))<1e-10})}const Nn=7,On=50,Kn=16;function Un(t,e){const o=Oe(Math.max(Math.abs(t),Math.abs(e))).length*Nn;return Math.max(On,o+Kn)}function qn(t,e,n,o){if(o<=0)return[0,0];const s=vt(t.side)===H.Vertical,r=t.space??(s?30:Un(e,n)),i=t.incrs??gt;return Mn(e,n,i,o,r)}const Zn=50;function Jn(t,e,n){var l,c;if(t.size!=null)return t.size;const o=((l=t.ticks)==null?void 0:l.show)!==!1?((c=t.ticks)==null?void 0:c.size)??10:0,s=t.gap??5,r=12;if(vt(t.side)===H.Vertical&&e!=null){let f=0;for(const d of e)d.length>f&&(f=d.length);const a=f*7;return Math.max(50,o+s+a+4)}return Math.max(50,o+s+r+3)}function Qn(t){return{config:t,_show:t.show!==!1,_size:t.size??Zn,_pos:0,_lpos:0,_splits:null,_values:null,_incr:0,_space:0,_rotate:0}}const to=1,St=60,pt=3600,ut=86400,eo=604800,wt=2592e3,Lt=31536e3,no=[to,5,10,15,30,St,5*St,10*St,15*St,30*St,pt,2*pt,3*pt,4*pt,6*pt,12*pt,ut,2*ut,3*ut,7*ut,14*ut,wt,2*wt,3*wt,6*wt,Lt];function oo(t,e,n){const o=[];if(n<=0||t>=e)return o;let s;if(n>=Lt){const r=new Date(t*1e3);for(r.setUTCMonth(0,1),r.setUTCHours(0,0,0,0),s=r.getTime()/1e3,s<t&&(r.setUTCFullYear(r.getUTCFullYear()+1),s=r.getTime()/1e3);s<=e;)o.push(s),r.setUTCFullYear(r.getUTCFullYear()+Math.round(n/Lt)),s=r.getTime()/1e3;return o}if(n>=wt){const r=new Date(t*1e3);r.setUTCDate(1),r.setUTCHours(0,0,0,0),s=r.getTime()/1e3;const i=Math.max(1,Math.round(n/wt));if(s<t&&(r.setUTCMonth(r.getUTCMonth()+1),s=r.getTime()/1e3),i>1){const l=r.getUTCMonth(),c=Math.ceil((l+1)/i)*i;r.setUTCMonth(c-1),s=r.getTime()/1e3}for(;s<=e;)o.push(s),r.setUTCMonth(r.getUTCMonth()+i),s=r.getTime()/1e3;return o}if(n>=ut){const r=new Date(t*1e3);r.setUTCHours(0,0,0,0),s=r.getTime()/1e3,s<t&&(s+=ut)}else s=Math.ceil(t/n)*n;for(let r=0;;r++){const i=s+r*n;if(i>e)break;o.push(i)}return o}const ye=new Map;function so(t,e){const n=JSON.stringify(t)+(e??"");let o=ye.get(n);return o==null&&(o=new Intl.DateTimeFormat(void 0,{...t,timeZone:e}),ye.set(n,o)),o}function nt(t,e,n){const o=new Date(t*1e3);return so(e,n).format(o)}function io(t,e){return nt(t,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},e)}function ro(t,e){return nt(t,{year:"numeric",month:"2-digit",day:"2-digit"},e)}function lo(t,e){return nt(t,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},e)}function co(t,e){return nt(t,{hour:"2-digit",minute:"2-digit",hour12:!1},e)}function ao(t,e){return nt(t,{month:"short",day:"numeric"},e)}function uo(t,e){return nt(t,{year:"numeric"},e)}function fo(t,e){return nt(t,{year:"numeric",month:"short"},e)}function ho(t,e,n){let o;return e>=Lt?o=uo:e>=wt?o=fo:e>=eo?o=ro:e>=ut?o=ao:e>=pt?o=co:e>=St?o=lo:o=io,t.map(s=>o(s,n))}function go(t,e,n,o,s){const r=e-t;if(r<=0||o<=0)return[0,0];for(const l of n){const c=r/l,f=o/c;if(f>=s)return[l,f]}const i=n[n.length-1]??Lt;return[i,o/(r/i)]}const po=3;function mo(t,e,n,o,s){let r=!0;for(const i of t){const l=i.config;if(l.show===!1)continue;const c=e(l.scale);if(!c||!N(c)){i._show&&(r=!1,i._show=!1);continue}else i._show||(r=!1,i._show=!0);const f=l.side,d=vt(f)===H.Horizontal?n:o,u=c.min,h=c.max;let p,x;if(c.time){const g=l.space??80;[p,x]=go(u,h,no,d,g)}else[p,x]=qn(l,u,h,d);if(c._discrete&&p>0&&p<1&&(p=1),i._incr=p,i._space=x,x===0)continue;if(l.splits)i._splits=l.splits(u,h,p,x);else if(c.time)i._splits=oo(u,h,p);else if(c.distr===K.Log)i._splits=Xn(u,h,c.log);else if(c.distr===K.Asinh)i._splits=jn(u,h,c.asinh);else{const g=c.distr===K.Ordinal||c._discrete;i._splits=Bn(u,h,p,x,g)}if(l.values)i._values=l.values(i._splits,x,p);else if(c.time)i._values=ho(i._splits,p);else if(c.distr===K.Log){const g=Yn(i._splits,c.log),S=Xt(i._splits);i._values=S.map((T,M)=>g[M]?T:"")}else c.distr,K.Asinh,i._values=Xt(i._splits);i._rotate=f===Y.Bottom?l.rotate??0:0;const y=i._size;i._size=It(Jn(l,i._values)),y!==i._size&&(r=!1)}return r}function Ce(t,e,n,o=0){let s=t,r=e-o,i=0,l=o;for(const f of n){if(!f._show)continue;const a=f.config.side,d=vt(a)===H.Vertical,u=f.config.label!=null?f.config.labelSize??20:0,h=f._size+u;h>0&&(d?(s-=h,a===Y.Left&&(i+=h)):(r-=h,a===Y.Top&&(l+=h)))}return!n.some(f=>f._show&&f.config.side===Y.Top)&&l<=o&&(l+=8,r-=8),{left:i,top:l,width:Math.max(s,0),height:Math.max(r,0)}}function wo(t,e){let n=e.top,o=e.left+e.width,s=e.top+e.height,r=e.left;function i(l,c){switch(l){case Y.Top:return n-=c,n+c;case Y.Right:{const f=o;return o+=c,f}case Y.Bottom:{const f=s;return s+=c,f}case Y.Left:return r-=c,r+c;default:return 0}}for(const l of t){if(!l._show)continue;const c=l.config.side;if(l._pos=i(c,l._size),l.config.label!=null){const f=l.config.labelSize??20;l._lpos=i(c,f)}}}function vo(t,e,n,o,s=0){for(const c of n)c._size=0;let r=!1,i=0,l={left:0,top:0,width:t,height:e};for(;!r;){i++;const c=mo(n,o,l.width,l.height);r=i===po||c,r||(l=Ce(t,e,n,s))}return l=Ce(t,e,n,s),wo(n,l),l}const ke="top",Te="bottom",bo="left",So="right";function jt(t,e){return e===1?t:t.replace(/(\d+(?:\.\d+)?)px/,(n,o)=>`${Math.round(Number(o)*e)}px`)}function Ie(t,e,n,o,s,r,i,l,c,f,a){const d=l%2/2;t.save(),t.translate(d,d),t.strokeStyle=c,t.lineWidth=l,f.length>0&&t.setLineDash(f),t.beginPath();let u=0,h=0,p=0,x=0;const y=r+(s===Y.Top||s===Y.Left?-i:i);o===H.Horizontal?(h=r,x=y):(u=r,p=y);for(let g=0;g<e.length;g++)n[g]!=null&&(o===H.Horizontal?u=p=e[g]??0:h=x=e[g]??0,t.moveTo(u,h),t.lineTo(p,x));t.stroke(),t.restore()}function xo(t,e,n,o,s,r){const i=B(o.left*s),l=B(o.top*s),c=B(o.width*s),f=B(o.height*s);for(const a of e){if(!a._show)continue;const d=a.config,u=d.side,h=vt(u),p=n(d.scale);if(!p||!N(p))continue;const x=d.stroke??"#000",y=u===Y.Top||u===Y.Left?-1:1,g=a._splits,S=a._values;if(!g||!S||a._space===0)continue;const T=h===H.Horizontal?o.width:o.height,M=h===H.Horizontal?o.left:o.top,_=g.map(D=>B(X(D,p,T,M)*s)),P=S.map(D=>D===""?null:D),C=d.grid;if((C==null?void 0:C.show)!==!1){const D=(C==null?void 0:C.stroke)??"rgba(0,0,0,0.12)",m=B(((C==null?void 0:C.width)??2)*s),v=((C==null?void 0:C.dash)??[]).map(I=>I*s),b=h===H.Horizontal?l:i,w=h===H.Horizontal?f:c;Ie(t,_,P,h,2,b,w,m,D,v)}const k=d.ticks;if((k==null?void 0:k.show)!==!1){const D=(k==null?void 0:k.stroke)??x,m=B(((k==null?void 0:k.width)??1)*s),v=B(((k==null?void 0:k.size)??10)*s),b=((k==null?void 0:k.dash)??[]).map(I=>I*s),w=B(a._pos*s);Ie(t,_,P,h,u,w,v,m,D,b)}{const D=(k==null?void 0:k.show)!==!1?((k==null?void 0:k.size)??10)*s:0,m=B((d.gap??5)*s),v=B(a._pos*s),b=(D+m)*y,w=v+b,I=jt(d.font??"12px system-ui, sans-serif",s),L=h===H.Horizontal?"center":u===Y.Left?So:bo,R=h===H.Horizontal?u===Y.Bottom?ke:Te:"middle";t.font=I,t.fillStyle=x,t.textAlign=L,t.textBaseline=R;const F=a._rotate*-$t/180;if(F!==0){const z=Math.cos(F),G=Math.sin(F);for(let $=0;$<S.length;$++){const V=S[$];if(V==null||V==="")continue;const j=_[$]??0;t.setTransform(z,G,-G,z,j,w),t.fillText(V,0,0)}t.setTransform(1,0,0,1,0,0)}else for(let z=0;z<S.length;z++){const G=S[z];if(G==null||G==="")continue;const $=_[z]??0,V=h===H.Horizontal?$:w,j=h===H.Horizontal?w:$;t.fillText(G,V,j)}}if(d.label!=null){const D=jt(d.labelFont??"bold 12px system-ui, sans-serif",s);t.font=D,t.fillStyle=x,t.textAlign="center",t.textBaseline=u===Y.Bottom?ke:Te;const m=B((a._lpos+(d.labelGap??0)*y)*s);h===H.Vertical?(t.save(),t.translate(m,B(l+f/2)),t.rotate((u===Y.Left?-$t:$t)/2),t.fillText(d.label,0,0),t.restore()):t.fillText(d.label,B(i+c/2),m)}const A=d.border;if((A==null?void 0:A.show)!==!1&&A!=null){const D=A.stroke??x,m=B((A.width??1)*s),v=(A.dash??[]).map(w=>w*s),b=B(a._pos*s);t.strokeStyle=D,t.lineWidth=m,v.length>0&&t.setLineDash(v),t.beginPath(),h===H.Horizontal?(t.moveTo(i,b),t.lineTo(i+c,b)):(t.moveTo(b,l),t.lineTo(b,l+f)),t.stroke(),v.length>0&&t.setLineDash([])}}if(r!=null){const a=jt("bold 14px system-ui, sans-serif",s);t.font=a,t.fillStyle="#000",t.textAlign="center",t.textBaseline="top",t.fillText(r,B(i+c/2),B(4*s))}}const Mo=2,yo="#fff",Co={stroke:"#607D8B",width:1,dash:[5,3],pointRadius:4,showX:!0,showY:!0};function Ae(t,e,n,o,s,r,i,l,c,f){var M;if(e.left<0||e.top<0)return;const a={...Co,...c},d=o,u=B(n.left*d),h=B(n.top*d),p=B(n.width*d),x=B(n.height*d),y=B(a.width*d),g=y%2/2,S=B((n.left+e.left)*d)+g,T=B((n.top+e.top)*d)+g;if(t.save(),t.strokeStyle=a.stroke,t.lineWidth=y,t.setLineDash(a.dash.map(_=>_*d)),a.showX&&(t.beginPath(),t.moveTo(S,h),t.lineTo(S,h+x),t.stroke()),a.showY&&(t.beginPath(),t.moveTo(u,T),t.lineTo(u+p,T),t.stroke()),t.setLineDash([]),e.activeGroup>=0&&e.activeDataIdx>=0){const _=e.activeGroup,P=e.activeSeriesIdx,C=e.activeDataIdx,k=s[_];if(k!=null&&P>=0&&P<k.series.length&&C<k.x.length){const A=k.x[C],D=k.series[P],m=D!=null?D[C]:null;if(A!=null&&m!=null){let v=a.stroke,b=!0;const w=f==null?void 0:f.get(`${_}:${P}`);if(w!=null){const I=w.stroke;v=(typeof I=="string"?I:void 0)??a.stroke,b=((M=w.cursor)==null?void 0:M.show)!==!1}if(b){const I=l(_),L=I!=null?i(I):void 0,R=(w==null?void 0:w.yScale)??ko(r,_,P),F=R!=null?i(R):void 0;if(L!=null&&F!=null&&N(L)&&N(F)){const z=B(X(A,L,n.width,n.left)*d),G=B(X(m,F,n.height,n.top)*d),$=a.pointRadius*d,V=B(Mo*d);t.beginPath(),t.arc(z,G,$,0,Math.PI*2),t.fillStyle=yo,t.fill(),t.strokeStyle=v,t.lineWidth=V,t.stroke()}}}}}t.restore()}function ko(t,e,n){for(const o of t)if(o.group===e&&o.index===n)return o.yScale}const To={fill:"rgba(0,0,0,0.07)",stroke:"rgba(0,0,0,0.15)",width:1};function Le(t,e,n,o,s){if(!e.show||e.width<=0)return;const r={...To,...s},i=o,l=B((n.left+e.left)*i),c=B((n.top+e.top)*i),f=B(e.width*i),a=B(e.height*i);t.save(),t.fillStyle=r.fill,t.fillRect(l,c,f,a),r.width>0&&(t.strokeStyle=r.stroke,t.lineWidth=B(r.width*i),t.strokeRect(l,c,f,a)),t.restore()}function Io(t,e,n,o,s,r,i,l,c,f,a,d){const u=a/2*i,h=Math.max(1,B(a*.2))*i,p=(f==null?void 0:f.stroke)??d,x=(f==null?void 0:f.fill)??"#fff";t.save(),t.strokeStyle=p,t.fillStyle=x,t.lineWidth=h,(f==null?void 0:f.dash)!=null&&t.setLineDash(f.dash.map(y=>y*i));for(let y=l;y<=c;y++){const g=n[y];if(g==null)continue;const S=e[y];if(S==null)continue;const T=B(X(S,o,r.width,r.left)*i),M=B(X(g,s,r.height,r.top)*i);t.beginPath(),t.arc(T,M,u,0,Math.PI*2),t.fill(),t.stroke()}t.restore()}function Ao(t,e,n,o,s,r,i){if(typeof t=="function")return t(e,n,o,s,r);if(t===!0)return!0;if(t===!1)return!1;const l=s-o;return l>0&&l<=r/i}function Lo(t,e,n,o,s,r,i,l,c){if(l>c||l<0||!ve(e,l,c)&&!ve(n,l,c))return null;const f=h=>X(h,o,r.width,r.left)*i,a=h=>X(h,s,r.height,r.top)*i,d=new Path2D;let u=!1;for(let h=l;h<=c;h++){const p=e[h],x=t[h];if(p==null||x==null)continue;const y=f(x),g=a(p);u?d.lineTo(y,g):(d.moveTo(y,g),u=!0)}if(!u)return null;for(let h=c;h>=l;h--){const p=n[h],x=t[h];p==null||x==null||d.lineTo(f(x),a(p))}return d.closePath(),d}function Po(t,e,n){t.save(),t.fillStyle=e.fill??"rgba(0, 120, 255, 0.1)",t.fill(n),t.restore()}function Do(t){const e=t.dataStore.data;if(e.length===0)return;if(!t.scaleManager.getScale("x")){const i={id:"x",auto:!0};t.scaleConfigs.push(i),t.scaleManager.addScale(i)}for(let i=0;i<e.length;i++)t.scaleManager.getGroupXScaleKey(i)||t.scaleManager.setGroupXScale(i,"x");const n=new Set(t.scaleConfigs.map(i=>i.id)),o=new Set;for(const i of t.seriesConfigs)o.add(i.yScale);o.size===0&&!n.has("y")&&o.add("y");for(const i of o)if(!n.has(i)){const l={id:i,auto:!0};t.scaleConfigs.push(l),t.scaleManager.addScale(l),n.add(i)}t.axisConfigs.some(i=>i.scale==="x")||t.axisConfigs.push({scale:"x",side:Y.Bottom,show:!0,label:t.xlabel??"X Axis"});const r=new Set(t.axisConfigs.map(i=>i.scale));for(const i of o)r.has(i)||(t.axisConfigs.push({scale:i,side:Y.Left,show:!0,label:t.ylabel??"Y Axis"}),r.add(i))}function Yt(t,e,n,o){return{ctx:t,plotBox:e,pxRatio:n,getScale:o,valToX:(i,l="x")=>{const c=o(l);return c==null||!N(c)?null:X(i,c,e.width,e.left)},valToY:(i,l)=>{const c=o(l);return c==null||!N(c)?null:X(i,c,e.height,e.top)}}}function Zt(t){t.seriesConfigMap.clear();for(const e of t.seriesConfigs)t.seriesConfigMap.set(`${e.group}:${e.index}`,e)}function Eo(){const t={scaleManager:new Tn,dataStore:new Ln,renderer:new Wn,cursorManager:new Pn,selectState:{show:!1,left:0,top:0,width:0,height:0},scaleConfigs:[],seriesConfigs:[],axisConfigs:[],bandConfigs:[],axisStates:[],width:0,height:0,pxRatio:typeof window<"u"&&window.devicePixelRatio||1,plotBox:{left:0,top:0,width:0,height:0},canvas:null,listeners:new Set,cursorListeners:new Set,scheduler:new Dn,drawHooks:new Set,cursorDrawHooks:new Set,focusedSeries:null,focusAlpha:1,actionMap:new Map(Ft),title:void 0,xlabel:void 0,ylabel:void 0,revision:0,eventCallbacks:{},_prevScaleRanges:new Map,seriesConfigMap:new Map,registerScale(e){t.scaleConfigs=t.scaleConfigs.filter(n=>n.id!==e.id),t.scaleConfigs.push(e),t.scaleManager.addScale(e)},unregisterScale(e){t.scaleConfigs=t.scaleConfigs.filter(n=>n.id!==e),t.scaleManager.removeScale(e)},registerSeries(e){t.seriesConfigs=t.seriesConfigs.filter(n=>!(n.group===e.group&&n.index===e.index)),t.seriesConfigs.push(e),Zt(t)},unregisterSeries(e,n){t.seriesConfigs=t.seriesConfigs.filter(o=>!(o.group===e&&o.index===n)),Zt(t)},toggleSeries(e,n){const o=t.seriesConfigMap.get(`${e}:${n}`);o!=null&&(o.show=o.show===!1,t.revision++,t.cursorManager.invalidateGroupedConfigs(),t.renderer.invalidateSeries(e,n),t.renderer.invalidateSnapshot(),t.scheduleRedraw())},setFocus(e){t.focusedSeries=e,t.scheduleRedraw()},setSize(e,n){t.width=e,t.height=n,t.canvas&&(t.canvas.width=e*t.pxRatio,t.canvas.height=n*t.pxRatio,t.canvas.style.width=`${e}px`,t.canvas.style.height=`${n}px`),t.renderer.clearCache(),t.scheduleRedraw()},scheduleRedraw(){t.scheduler.mark(ot.Full)},scheduleCursorRedraw(){t.scheduler.mark(ot.Cursor)},subscribe(e){return t.listeners.add(e),()=>{t.listeners.delete(e)}},subscribeCursor(e){return t.cursorListeners.add(e),()=>{t.cursorListeners.delete(e)}},redraw(){const{scaleManager:e,dataStore:n,renderer:o,seriesConfigs:s,width:r,height:i,pxRatio:l,canvas:c,scheduler:f}=t;if(c==null||r===0||i===0)return;const a=c.getContext("2d");if(a==null)return;o.setContext(a,l);const u=(f.dirty&~(ot.Cursor|ot.Select))===0,h=g=>e.getScale(g);if(u&&o.restoreSnapshot(a)){if(Ae(a,t.cursorManager.state,t.plotBox,l,n.data,s,h,g=>e.getGroupXScaleKey(g),void 0,t.seriesConfigMap),Le(a,t.selectState,t.plotBox,l),t.cursorDrawHooks.size>0){a.save(),a.scale(l,l);const g=Yt(a,t.plotBox,l,h);for(const S of t.cursorDrawHooks)try{S(g,t.cursorManager.state)}catch(T){console.warn("[uPlot+] draw hook error:",T)}a.restore()}for(const g of t.cursorListeners)g();return}Do(t),e.autoRangeX(n.data),n.updateWindows(g=>{const S=e.getGroupXScaleKey(g);return S!=null?e.getScale(S):void 0});const p=s.map(g=>({group:g.group,index:g.index,yScale:g.yScale}));if(e.autoRange(n.data,p,n),_o(t),t.axisStates.length>0){const g=t.title!=null?20:0;t.plotBox=vo(r,i,t.axisStates,h,g)}else t.plotBox={left:10,top:10,width:r-20,height:i-20};a.clearRect(0,0,r*l,i*l),t.axisStates.length>0&&xo(a,t.axisStates,h,t.plotBox,l,t.title);const x=[];for(const g of s){const S=e.getGroupXScaleKey(g.group),T=S!=null?e.getScale(S):void 0,M=e.getScale(g.yScale);T==null||M==null||x.push({config:g,dataX:n.getXValues(g.group),dataY:n.getYValues(g.group,g.index),xScale:T,yScale:M,window:n.getWindow(g.group)})}o.checkScaleStamp(x),a.save(),a.scale(l,l),a.beginPath(),a.rect(t.plotBox.left,t.plotBox.top,t.plotBox.width,t.plotBox.height),a.clip();for(let g=0;g<x.length;g++){const S=x[g];S!=null&&(t.focusedSeries!=null&&g!==t.focusedSeries?(a.globalAlpha=t.focusAlpha,o.drawSeries(S,t.plotBox,1),a.globalAlpha=1):o.drawSeries(S,t.plotBox,1))}const y=new Map;for(const g of s)y.set(`${g.group}-${g.index}`,g);for(const g of t.bandConfigs){const S=e.getGroupXScaleKey(g.group),T=S!=null?e.getScale(S):void 0,M=y.get(`${g.group}-${g.series[0]}`),_=y.get(`${g.group}-${g.series[1]}`);if(T==null||M==null||_==null)continue;const P=e.getScale(M.yScale);if(P==null)continue;const[C,k]=n.getWindow(g.group),A=g.series[0],D=g.series[1];let m=o.getCachedBandPath(g.group,A,D,C,k);m==null&&(m=Lo(n.getXValues(g.group),n.getYValues(g.group,A),n.getYValues(g.group,D),T,P,t.plotBox,l,C,k)??void 0,m!=null&&o.setCachedBandPath(g.group,A,D,C,k,m)),m!=null&&Po(a,g,m)}for(const g of x){const S=g.config;if(S.show===!1)continue;const T=S.points,M=S.width??1,_=(T==null?void 0:T.size)??3+M*2,P=(T==null?void 0:T.space)??_*2,[C,k]=g.window;Ao(T==null?void 0:T.show,S.group,S.index,C,k,t.plotBox.width,P)&&Io(a,g.dataX,g.dataY,g.xScale,g.yScale,t.plotBox,l,C,k,T,_,(typeof S.stroke=="string"?S.stroke:null)??"#000")}if(a.restore(),t.drawHooks.size>0){a.save(),a.beginPath(),a.rect(t.plotBox.left*l,t.plotBox.top*l,t.plotBox.width*l,t.plotBox.height*l),a.clip(),a.scale(l,l);const g=Yt(a,t.plotBox,l,h);for(const S of t.drawHooks)try{S(g)}catch(T){console.warn("[uPlot+] draw hook error:",T)}a.restore()}if(t.cursorManager.state.left>=0&&(o.saveSnapshot(a,r*l,i*l),t.cursorManager.update(t.cursorManager.state.left,t.cursorManager.state.top,t.plotBox,n.data,s,h,g=>n.getWindow(g),g=>e.getGroupXScaleKey(g))),Ae(a,t.cursorManager.state,t.plotBox,l,n.data,s,h,g=>e.getGroupXScaleKey(g),void 0,t.seriesConfigMap),Le(a,t.selectState,t.plotBox,l),t.cursorDrawHooks.size>0){a.save(),a.scale(l,l);const g=Yt(a,t.plotBox,l,h);for(const S of t.cursorDrawHooks)try{S(g,t.cursorManager.state)}catch(T){console.warn("[uPlot+] draw hook error:",T)}a.restore()}for(const g of t.listeners)g();for(const g of t.cursorListeners)g();if(t._prevScaleRanges.size>0&&t.eventCallbacks.onScaleChange!=null)for(const g of e.getAllScales()){if(!N(g))continue;const S=t._prevScaleRanges.get(g.id);if(S==null||S.min!==g.min||S.max!==g.max)try{t.eventCallbacks.onScaleChange(g.id,g.min,g.max)}catch(T){console.warn("[uPlot+] event callback error:",T)}}t._prevScaleRanges.clear();for(const g of e.getAllScales())N(g)&&t._prevScaleRanges.set(g.id,{min:g.min,max:g.max})}};return t.scheduler.onRedraw(()=>t.redraw()),t}function _o(t){const{axisConfigs:e,axisStates:n}=t,o=new Map;for(const s of n)o.set(`${s.config.scale}:${s.config.side}`,s);t.axisStates=e.map(s=>{const r=`${s.scale}:${s.side}`,i=o.get(r);return i!=null?(i.config=s,i):Qn(s)})}function Ro(){const t=E.useRef(null);return t.current===null&&(t.current=Eo()),t.current}const tn=E.createContext(null);function J(){const t=E.useContext(tn);if(!t)throw new Error("useChart must be used within a <Chart> component");return t}const Pe=5,en=.001,Fo=.1,zo=10;function se(t,e){const n=t.shiftKey?"shift":t.altKey?"alt":t.ctrlKey?"ctrl":"",o=t.button===1?"Middle":t.button===2?"Right":"Left";return n?`${n}${o}${e}`:`${o.toLowerCase()}${e}`}function Ho(t){return se(t,"Drag")}function Go(t){return se(t,"Click")}function Wo(t){return se(t,"Dblclick")}function $o(t){const e=t.shiftKey?"shift":t.altKey?"alt":t.ctrlKey?"ctrl":"";return e?`${e}Wheel`:"wheel"}function Vo(t){const e=t.shiftKey?"shift":t.altKey?"alt":t.ctrlKey?"ctrl":"",n=t.key.length===1?t.key.toUpperCase():t.key;return e?`${e}Key${n}`:`key${n}`}function Bo(t,e,n,o,s=!0){const r=t.get(e);if(r!=null)return r;if(s){for(const[i,l]of t)if(typeof i=="function"&&i(n,o))return l}}function Xo(t,e){const n=[];for(const o of t.scaleManager.getAllScales())N(o)&&(e!=null&&!e(o.ori)||n.push({id:o.id,ori:o.ori,startMin:o.min,startMax:o.max}));return n}function kt(t){const e=t.eventCallbacks.onScaleChange;if(e!=null)for(const n of t.scaleManager.getAllScales()){if(!N(n))continue;const o=t._prevScaleRanges.get(n.id);(o==null||o.min!==n.min||o.max!==n.max)&&e(n.id,n.min,n.max)}}function Nt(t,e,n,o){if(!(e instanceof WheelEvent))return;const s=q(1-e.deltaY*en,Fo,zo),r=t.plotBox;for(const i of t.scaleManager.getAllScales()){if(!N(i)||!o(i.ori))continue;const l=i.ori===H.Horizontal,c=l?r.width:r.height,f=l?r.left:r.top,a=l?n.cx+r.left:n.cy+r.top,d=lt(a,i,c,f),u=d-(d-i.min)*s,h=d+(i.max-d)*s;i.min=Math.min(u,h),i.max=Math.max(u,h),i.auto=!1,rt(i)}t.scheduleRedraw(),kt(t)}function Ot(t,e,n){const o={show:!1,left:0,top:0,width:0,height:0},s=e.cx,r=e.cy;return{onMove(i,l,c){const f=t.plotBox,a=q(c.cx,0,f.width),d=q(c.cy,0,f.height);o.show=!0,o.left=Math.min(s,a),o.top=Math.min(r,d),o.width=Math.abs(a-s),o.height=Math.abs(d-r),n(H.Vertical)||(o.top=0,o.height=f.height),n(H.Horizontal)||(o.left=0,o.width=f.width),t.selectState=o,t.scheduler.mark(ot.Cursor|ot.Select)},onEnd(i,l,c){const f=n(H.Horizontal)&&o.width>Pe,a=n(H.Vertical)&&o.height>Pe;if(f||a){let d=!0;if(t.eventCallbacks.onSelect!=null){const u=No(t,o);let h;try{h=t.eventCallbacks.onSelect(u)}catch(p){console.warn("[uPlot+] event callback error:",p)}h===!1&&(d=!1)}d&&(jo(t,o,n),kt(t))}o.show=!1,o.left=0,o.width=0,t.selectState=o,t.scheduleRedraw()}}}function jo(t,e,n){const o=t.plotBox;for(const s of t.scaleManager.getAllScales()){if(!N(s)||!n(s.ori))continue;const r=s.ori===H.Horizontal,i=r?o.width:o.height,l=r?o.left:o.top,c=r?e.left:e.top,f=r?e.width:e.height,a=c/i,d=(c+f)/i,u=lt(l+a*i,s,i,l),h=lt(l+d*i,s,i,l);s.min=Math.min(u,h),s.max=Math.max(u,h),s.auto=!1,rt(s)}}function Kt(t,e,n,o){const s=Xo(t,n),r=e.clientX,i=e.clientY;return{onMove(l,c){const f=t.plotBox,a=c;for(const d of s){const u=t.scaleManager.getScale(d.id);if(u==null)continue;const h=d.ori===H.Horizontal,p=h?f.width:f.height,x=h?a.clientX-r:a.clientY-i,y=h?-1:1,g=d.startMax-d.startMin;u.min=d.startMin+y*(x/p)*g,u.max=d.startMax+y*(x/p)*g,u.auto=!1,rt(u)}t.renderer.clearCache(),t.scheduleRedraw()},onEnd(){kt(t)}}}function De(t,e,n){var a;if(n.scaleId==null||n.ori==null)return;const o=t.scaleManager.getScale(n.scaleId);if(o==null||!N(o))return;const s=n.ori===H.Vertical,r=(a=e.target.closest("div"))==null?void 0:a.getBoundingClientRect();if(r==null)return;const i=s?e.clientY-r.top:e.clientX-r.left,l=o.min,c=o.max,f=n.scaleId;return{onMove(d,u){var P;const h=t.plotBox,p=u,x=(P=p.target.closest("div"))==null?void 0:P.getBoundingClientRect();if(x==null)return;const y=s?h.height:h.width,S=((s?p.clientY-x.top:p.clientX-x.left)-i)/y,T=s?1:-1,M=c-l,_=t.scaleManager.getScale(f);_!=null&&(_.min=l+T*S*M,_.max=c+T*S*M,_.auto=!1,rt(_),t.renderer.clearCache(),t.scheduleRedraw())},onEnd(){kt(t)}}}function Ut(t,e,n){if(!(e instanceof WheelEvent))return;const o=e.deltaY*en*10;for(const s of t.scaleManager.getAllScales()){if(!N(s)||!n(s.ori))continue;const r=s.max-s.min;s.min+=o*r,s.max+=o*r,s.auto=!1,rt(s)}t.renderer.clearCache(),t.scheduleRedraw(),kt(t)}const Et=t=>t===H.Horizontal,_t=t=>t===H.Vertical,Rt=()=>!0;function Yo(t){switch(t){case"zoomX":return(e,n,o)=>{if(n instanceof WheelEvent){Nt(e,n,o,Et);return}return Ot(e,o,Et)};case"zoomY":return(e,n,o)=>{if(n instanceof WheelEvent){Nt(e,n,o,_t);return}return Ot(e,o,_t)};case"zoomXY":return(e,n,o)=>{if(n instanceof WheelEvent){Nt(e,n,o,Rt);return}return Ot(e,o,Rt)};case"panX":return(e,n,o)=>{if(n instanceof WheelEvent){Ut(e,n,Et);return}return o.scaleId!=null?De(e,n,o):Kt(e,n,Et)};case"panY":return(e,n,o)=>{if(n instanceof WheelEvent){Ut(e,n,_t);return}return o.scaleId!=null?De(e,n,o):Kt(e,n,_t)};case"panXY":return(e,n,o)=>{if(n instanceof WheelEvent){Ut(e,n,Rt);return}return Kt(e,n,Rt)};case"reset":return e=>{for(const n of e.scaleConfigs)e.scaleManager.addScale(n);e.renderer.clearCache(),e.scheduleRedraw()};case"none":return()=>{};default:return}}function Ee(t){return typeof t=="function"?t:Yo(t)}function No(t,e){const n=t.plotBox,o=e.left/n.width,s=(e.left+e.width)/n.width,r={};for(const i of t.scaleManager.getAllScales()){if(i.ori!==H.Horizontal||!N(i))continue;const l=lt(n.left+o*n.width,i,n.width,n.left),c=lt(n.left+s*n.width,i,n.width,n.left);r[i.id]={min:Math.min(l,c),max:Math.max(l,c)}}return{left:o,right:s,ranges:r}}function Oo(t,e){E.useEffect(()=>{if(e!=null)return Ko(t,e)},[t,e])}function Ko(t,e){let n=null,o=!1,s=null,r=-1,i=-1;function l(m){const v=e.getBoundingClientRect(),b=t.plotBox;return{cx:m.clientX-v.left-b.left,cy:m.clientY-v.top-b.top}}function c(m,v){const b=t.plotBox;return m>=0&&m<=b.width&&v>=0&&v<=b.height}function f(m,v){const b=e.getBoundingClientRect(),w=m-b.left,I=v-b.top,L=t.plotBox;for(const R of t.axisStates){const F=R.config,z=F.side;if(R._size<=0)continue;const $=I>=L.top&&I<=L.top+L.height,V=w>=L.left&&w<=L.left+L.width;if(z===Y.Left&&w<L.left&&$||z===Y.Right&&w>L.left+L.width&&$||z===Y.Top&&I<L.top&&V||z===Y.Bottom&&I>L.top+L.height&&V)return{scaleId:F.scale,ori:vt(z)}}return null}function a(m){const{cx:v,cy:b}=l(m);return{cx:v,cy:b,inPlot:c(v,b)}}function d(m,v,b){const w=t.cursorManager.state;let I=null;if(w.activeGroup>=0&&w.activeDataIdx>=0){const L=t.dataStore.data[w.activeGroup];if(L!=null){const R=L.x[w.activeDataIdx],F=L.series[w.activeSeriesIdx],z=F!=null?F[w.activeDataIdx]:void 0;if(R!=null&&z!=null){const G=t.plotBox,$=t.scaleManager.getGroupXScaleKey(w.activeGroup),V=$!=null?t.scaleManager.getScale($):void 0,j=t.seriesConfigMap.get(`${w.activeGroup}:${w.activeSeriesIdx}`),Q=j!=null?t.scaleManager.getScale(j.yScale):void 0;let it=v,bt=b;V!=null&&N(V)&&(it=X(R,V,G.width,G.left)-G.left),Q!=null&&N(Q)&&(bt=X(z,Q,G.height,G.top)-G.top);const pe=v-it,me=b-bt;I={group:w.activeGroup,seriesIdx:w.activeSeriesIdx,dataIdx:w.activeDataIdx,xVal:R,yVal:z,pxX:it,pxY:bt,dist:Math.sqrt(pe*pe+me*me)}}}}return{plotX:v,plotY:b,point:I,srcEvent:m}}function u(m,v,b,w=!0){const I=Bo(t.actionMap,m,v,b,w);if(!(I==null||I==="none"))return Ee(I)}function h(m,v){const{cx:b,cy:w}=l(m);if(!c(b,w)&&n==null){r=-1,i=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw();return}const I=b!==r||w!==i;if(r=b,i=w,t.cursorManager.update(b,w,t.plotBox,t.dataStore.data,t.seriesConfigs,L=>t.scaleManager.getScale(L),L=>t.dataStore.getWindow(L),L=>t.scaleManager.getGroupXScaleKey(L)),I){const L={cx:b,cy:w,inPlot:c(b,w)},R=t.actionMap.get("hover");if(R!=null&&R!=="none"){const F=Ee(R);if(F!=null&&F(t,v??m,L),t.focusAlpha<1){const z=t.cursorManager.state;if(z.activeGroup>=0&&z.activeSeriesIdx>=0){const G=t.seriesConfigs.findIndex($=>$.group===z.activeGroup&&$.index===z.activeSeriesIdx);G>=0&&t.focusedSeries!==G&&(t.focusedSeries=G,t.scheduleRedraw())}}}}if(v!=null&&t.eventCallbacks.onCursorMove!=null&&c(b,w))try{t.eventCallbacks.onCursorMove(d(v,b,w))}catch(L){console.warn("[uPlot+] event callback error:",L)}t.scheduleCursorRedraw()}function p(){document.activeElement!==e&&e.focus()}function x(m){const v=a(m),b=f(m.clientX,m.clientY);let w;if(b!=null&&m.button===0)w=b.ori===H.Horizontal?"xGutterDrag":"yGutterDrag",v.scaleId=b.scaleId,v.ori=b.ori;else if(w=Ho(m),!v.inPlot)return;v.action=w;const I=u(w,m,v,!1);if(I==null)return;(m.button!==0||b!=null)&&m.preventDefault();const L=I(t,m,v);L!=null&&(n=L,o=!1)}function y(m){if(n!=null){o=!0,n.onMove(t,m,a(m)),h(m,m);return}h(m,m)}function g(m){if(n!=null){n.onEnd(t,m,a(m)),n=null;return}}function S(m){if(o){o=!1;return}const v=a(m);if(!v.inPlot)return;const b=Go(m);v.action=b;const w=u(b,m,v);w!=null&&w(t,m,v);const I=t.eventCallbacks.onClick;if(I!=null)try{I(d(m,v.cx,v.cy))}catch(L){console.warn("[uPlot+] event callback error:",L)}}function T(m){if(n!=null){m.preventDefault();return}const v=a(m);if(!v.inPlot)return;m.preventDefault(),v.action="rightClick";const b=u("rightClick",m,v);b!=null&&b(t,m,v);const w=t.eventCallbacks.onContextMenu;if(w!=null)try{w(d(m,v.cx,v.cy))}catch(I){console.warn("[uPlot+] event callback error:",I)}}function M(m){var v,b;r=-1,i=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),n!=null&&(n=null),t.scheduleCursorRedraw();try{(b=(v=t.eventCallbacks).onCursorLeave)==null||b.call(v)}catch(w){console.warn("[uPlot+] event callback error:",w)}}function _(m){const v=a(m);if(!v.inPlot)return;if(t.eventCallbacks.onDblClick!=null){let I;try{I=t.eventCallbacks.onDblClick(d(m,v.cx,v.cy))}catch(L){console.warn("[uPlot+] event callback error:",L)}if(I===!1)return}const b=Wo(m);v.action=b;const w=u(b,m,v,!1);w!=null&&w(t,m,v)}function P(m){const v=a(m);if(!v.inPlot)return;const b=$o(m);v.action=b;const w=u(b,m,v);w!=null&&(m.preventDefault(),w(t,m,v))}function C(m){if(m.touches.length===2){const L=m.touches[0],R=m.touches[1],F=R.clientX-L.clientX,z=R.clientY-L.clientY;s={dist:Math.sqrt(F*F+z*z),midX:(L.clientX+R.clientX)/2,midY:(L.clientY+R.clientY)/2},n=null;return}const v=m.touches[0];if(v==null)return;const b=a(v);if(!b.inPlot)return;const w=u("touchDrag",m,b);if(w==null)return;const I=w(t,m,b);I!=null&&(n=I,o=!1)}function k(m){if(m.touches.length===2&&s!=null){m.preventDefault();const b=m.touches[0],w=m.touches[1],I=w.clientX-b.clientX,L=w.clientY-b.clientY,R=Math.sqrt(I*I+L*L),F=a({clientX:s.midX,clientY:s.midY});if(u("pinch",m,F)!=null){const G=R/s.dist,$=t.plotBox;for(const V of t.scaleManager.getAllScales()){if(V.ori!==H.Horizontal||!N(V))continue;const j=lt(F.cx+$.left,V,$.width,$.left),Q=j-(j-V.min)/G,it=j+(V.max-j)/G;V.min=Math.min(Q,it),V.max=Math.max(Q,it),V.auto=!1,rt(V)}s.dist=R,t.renderer.clearCache(),t.scheduleRedraw(),kt(t)}return}const v=m.touches[0];if(v!=null){if(n!=null){o=!0,n.onMove(t,m,a(v)),h(v,m),m.preventDefault();return}h(v,m)}}function A(m){if(s!=null){s=null;return}const v=m.changedTouches[0];v!=null&&n!=null&&(n.onEnd(t,m,a(v)),n=null)}function D(m){const v={cx:r,cy:i,inPlot:r>=0&&i>=0},b=Vo(m);v.action=b;const w=u(b,m,v);w!=null&&(m.preventDefault(),w(t,m,v))}return e.addEventListener("mouseenter",p),e.addEventListener("mousemove",y),e.addEventListener("mousedown",x),e.addEventListener("mouseup",g),e.addEventListener("click",S),e.addEventListener("contextmenu",T),e.addEventListener("mouseleave",M),e.addEventListener("dblclick",_),e.addEventListener("wheel",P,{passive:!1}),e.addEventListener("touchstart",C,{passive:!0}),e.addEventListener("touchmove",k,{passive:!1}),e.addEventListener("touchend",A),e.addEventListener("keydown",D),()=>{e.removeEventListener("mouseenter",p),e.removeEventListener("mousemove",y),e.removeEventListener("mousedown",x),e.removeEventListener("mouseup",g),e.removeEventListener("click",S),e.removeEventListener("contextmenu",T),e.removeEventListener("mouseleave",M),e.removeEventListener("dblclick",_),e.removeEventListener("wheel",P),e.removeEventListener("touchstart",C),e.removeEventListener("touchmove",k),e.removeEventListener("touchend",A),e.removeEventListener("keydown",D)}}const Jt=new Map;function Uo(t){let e=Jt.get(t);return e==null&&(e=new qo(t),Jt.set(t,e)),e}class qo{constructor(e){this.members=new Set,this.publishing=!1,this.syncedStores=new WeakSet,this.key=e}join(e){this.members.add(e)}leave(e){this.members.delete(e),this.members.size===0&&Jt.delete(this.key)}pub(e){if(this.publishing)return;if(this.syncedStores.has(e)){this.syncedStores.delete(e);return}this.publishing=!0;const n=e.cursorManager.state,{activeGroup:o,activeDataIdx:s}=n;if(o<0||s<0){for(const l of this.members)l!==e&&(this.syncedStores.add(l),l.cursorManager.hide(),l.scheduleCursorRedraw());this.publishing=!1;return}const i=e.dataStore.getXValues(o)[s];if(i==null){this.publishing=!1;return}for(const l of this.members)l!==e&&(this.syncedStores.add(l),l.cursorManager.syncToValue(i,l),l.scheduleCursorRedraw());this.publishing=!1}}function Zo(t,e){E.useEffect(()=>{if(e==null)return;const n=Uo(e);n.join(t);let o=-1,s=-1;const r=t.subscribeCursor(()=>{const{activeGroup:i,activeDataIdx:l}=t.cursorManager.state;i===o&&l===s||(o=i,s=l,n.pub(t))});return()=>{r(),n.leave(t)}},[t,e])}function nn(t){return t instanceof Float64Array?t:new Float64Array(t)}function on(t){return t instanceof Float64Array||t.some(e=>e==null)?t:new Float64Array(t)}function _e(t){return{x:nn(t.x),series:[on(t.y)]}}function Jo(t){return{x:nn(t.x),series:t.series.map(on)}}function ie(t){if(!Array.isArray(t))return[_e(t)];if(t.length===0)return[];const e=t[0];return e==null?[]:"series"in e?t.map(Jo):t.map(_e)}function re({width:t,height:e,data:n,children:o,className:s,pxRatio:r,title:i,xlabel:l,ylabel:c,onDraw:f,onCursorDraw:a,syncKey:d,actions:u,onClick:h,onContextMenu:p,onDblClick:x,onCursorMove:y,onCursorLeave:g,onScaleChange:S,onSelect:T}){const M=Ro(),[_,P]=E.useState(null),C=r??(typeof window<"u"&&window.devicePixelRatio||1);E.useEffect(()=>{M.actionMap=u!=null?new Map([...Ft,...u]):new Map(Ft)},[M,u]),E.useEffect(()=>{M.title=i,M.xlabel=l,M.ylabel=c},[M,i,l,c]);const k=E.useRef(M.eventCallbacks);k.current=M.eventCallbacks,E.useEffect(()=>{const I=k.current;I.onClick=h,I.onContextMenu=p,I.onDblClick=x,I.onCursorMove=y,I.onCursorLeave=g,I.onScaleChange=S,I.onSelect=T}),Oo(M,_),Zo(M,d);const A=E.useCallback(I=>{M.canvas=I,I&&M.scheduleRedraw()},[M]),D=E.useCallback(I=>{P(I)},[]);E.useEffect(()=>{M.pxRatio=C,M.setSize(t,e)},[M,t,e,C]),E.useEffect(()=>()=>{M.canvas=null,M.scheduler.cancel(),M.focusedSeries=null},[M]),E.useEffect(()=>{if(_==null||typeof ResizeObserver>"u")return;const I=new ResizeObserver(L=>{const R=L[0];if(R==null)return;const{width:F,height:z}=R.contentRect;F>0&&z>0&&(F!==M.width||z!==M.height)&&M.setSize(Math.round(F),Math.round(z))});return I.observe(_),()=>{I.disconnect()}},[M,_]);const m=E.useMemo(()=>ie(n),[n]),v=E.useRef(n);E.useEffect(()=>{n===v.current&&M.dataStore.data.length>0||(v.current=n,M.dataStore.setData(m),M.renderer.clearCache(),M.scheduleRedraw())},[M,n,m]);const b=E.useRef(f);b.current=f,E.useEffect(()=>{const I=L=>{var R;(R=b.current)==null||R.call(b,L)};return M.drawHooks.add(I),()=>{M.drawHooks.delete(I)}},[M]);const w=E.useRef(a);return w.current=a,E.useEffect(()=>{const I=(L,R)=>{var F;(F=w.current)==null||F.call(w,L,R)};return M.cursorDrawHooks.add(I),()=>{M.cursorDrawHooks.delete(I)}},[M]),W.jsx(tn.Provider,{value:M,children:W.jsxs("div",{className:s,style:{position:"relative",display:"flex",flexDirection:"column",width:`${t}px`},children:[W.jsx("div",{ref:D,tabIndex:-1,style:{position:"relative",width:`${t}px`,height:`${e}px`,cursor:"crosshair",outline:"none",order:0},children:W.jsx("canvas",{ref:A,style:{position:"absolute",left:0,top:0}})}),o]})})}function Re(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}function Qo(t,e){const n=Object.keys(t),o=Object.keys(e);if(n.length!==o.length)return!1;for(const s of o)if(t[s]!==e[s])return!1;return!0}function ts(t,e){if(t===null)return!1;const n=t,o=e,s=Object.keys(n),r=Object.keys(o);if(s.length!==r.length)return!1;for(const i of r){const l=n[i],c=o[i];if(l!==c)if(Re(l)&&Re(c)){if(!Qo(l,c))return!1}else return!1}return!0}function le(t,e,n,o,s){const r=J(),i=E.useRef(t);i.current=t,E.useEffect(()=>{const c=i.current;return n(r,c),r.scheduleRedraw(),()=>{o(r,c),r.scheduleRedraw()}},[r,...e]);const l=E.useRef(null);E.useEffect(()=>{ts(l.current,t)||(l.current=t,s(r,t),r.scheduleRedraw())})}function es(t){return le({...t},[t.id],(e,n)=>e.registerScale(n),(e,n)=>e.unregisterScale(n.id),(e,n)=>{e.scaleConfigs=e.scaleConfigs.map(o=>o.id===n.id?n:o),e.scaleManager.addScale(n),e.renderer.clearCache()}),null}function sn(t){const e=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(t);if(e)return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)];const n=/^#([0-9a-f])([0-9a-f])([0-9a-f])/i.exec(t);if(n)return[parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];const o=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i.exec(t);return o?[Number(o[1]),Number(o[2]),Number(o[3])]:null}function ns(t,e=.8,n=0){const o=sn(t);if(o==null)return{type:"linear",stops:[[0,t],[1,t]]};const[s,r,i]=o;return{type:"linear",stops:[[0,`rgba(${s},${r},${i},${e})`],[1,`rgba(${s},${r},${i},${n})`]]}}function rn(t,e){const n=sn(t);if(n==null)return t;const[o,s,r]=n;return`rgba(${o},${s},${r},${e})`}function os(t,e=65,n=50){const o=[];for(let r=0;r<t;r++){const i=r*137.508%360;o.push(`hsl(${i.toFixed(1)},${e}%,${n}%)`)}return o}const Fe=["#e74c3c","#3498db","#2ecc71","#f39c12","#9b59b6","#1abc9c","#e67e22","#34495e","#16a085","#c0392b","#2980b9","#27ae60","#f1c40f","#8e44ad","#d35400"];function ze(t,e){var i;const n=(i=t.paths)==null?void 0:i.defaults,o=t.stroke??Fe[e%Fe.length]??"#000",s=t.fill??(n==null?void 0:n.fill),r=s==="auto"&&typeof o=="string"?rn(o,.5):s==="auto"?void 0:s;return{...n,...t,yScale:t.yScale??"y",show:t.show??!0,stroke:o,fill:r}}function ce(t){return le(t,[t.group,t.index],(e,n)=>{e.registerSeries(ze(n,e.seriesConfigs.length)),e.renderer.clearGroupCache(n.group)},(e,n)=>{e.unregisterSeries(n.group,n.index),e.renderer.clearGroupCache(n.group)},(e,n)=>{e.seriesConfigs=e.seriesConfigs.map((o,s)=>o.group===n.group&&o.index===n.index?ze(n,s):o),Zt(e),e.renderer.invalidateSeries(n.group,n.index)}),null}function ss(t){return{...t,side:t.side??(t.scale==="x"?Y.Bottom:Y.Left),show:t.show??!0}}function Pt(t){const e=ss(t);return le(e,[e.scale,e.side],(n,o)=>{n.axisConfigs=n.axisConfigs.filter(s=>!(s.scale===o.scale&&s.side===o.side)),n.axisConfigs.push(o)},(n,o)=>{n.axisConfigs=n.axisConfigs.filter(s=>!(s.scale===o.scale&&s.side===o.side))},(n,o)=>{n.axisConfigs=n.axisConfigs.map(s=>s.scale===o.scale&&s.side===o.side?o:s)}),null}function is({series:t,group:e,fill:n,dir:o}){const s=J(),r=E.useRef(null),i=t[0],l=t[1];return E.useEffect(()=>{const c={series:[i,l],group:e,fill:n,dir:o};return r.current!=null&&(s.bandConfigs=s.bandConfigs.filter(f=>f!==r.current)),r.current=c,s.bandConfigs.push(c),s.scheduleRedraw(),()=>{s.bandConfigs=s.bandConfigs.filter(f=>f!==r.current),r.current=null,s.scheduleRedraw()}},[s,i,l,e,n,o]),null}const rs={width:12,height:3,borderRadius:1,display:"inline-block"},ls={fontWeight:600},ln={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",cursor:"pointer",fontSize:12,fontFamily:"sans-serif"},cs={...ln,opacity:1},as={...ln,opacity:.4},He=new Map,us=E.memo(function({group:e,index:n,label:o,color:s,isHidden:r,valueStr:i,store:l}){const c=E.useCallback(()=>{l.toggleSeries(e,n)},[l,e,n]);let f=He.get(s);return f==null&&(f={...rs,backgroundColor:s},He.set(s,f)),W.jsxs("span",{onClick:c,style:r?as:cs,children:[W.jsx("span",{style:f}),W.jsx("span",{children:o}),i&&W.jsx("span",{style:ls,children:i})]})});function fs({show:t=!0,position:e="bottom",className:n}){const o=J(),s=E.useRef({activeGroup:-1,activeDataIdx:-1,seriesCount:0,revision:-1}),r=E.useCallback(a=>o.subscribeCursor(a),[o]),i=E.useCallback(()=>{const{activeGroup:a,activeDataIdx:d}=o.cursorManager.state,u=o.seriesConfigs.length,{revision:h}=o,p=s.current;if(p.activeGroup===a&&p.activeDataIdx===d&&p.seriesCount===u&&p.revision===h)return p;const x={activeGroup:a,activeDataIdx:d,seriesCount:u,revision:h};return s.current=x,x},[o]),l=E.useSyncExternalStore(r,i);if(!t)return null;const{activeGroup:c,activeDataIdx:f}=l;return W.jsx("div",{className:n,style:{display:"flex",flexWrap:"wrap",justifyContent:"center",order:e==="top"?-1:1,padding:"4px 0"},children:o.seriesConfigs.map(a=>{if(a.legend===!1)return null;const d=typeof a.stroke=="string"?a.stroke:"#000";let u="";if(f>=0&&c>=0&&a.group===c){const p=o.dataStore.getYValues(a.group,a.index)[f];p!=null&&(u=typeof p=="number"?p.toPrecision(4):String(p))}return W.jsx(us,{group:a.group,index:a.index,label:a.label??`Series ${a.index}`,color:d,isHidden:a.show===!1,valueStr:u,store:o},`${a.group}:${a.index}`)})})}const hs={position:"absolute",zIndex:50,background:"rgba(255,255,255,0.92)",border:"1px solid #ccc",borderRadius:4,padding:"4px 6px",fontSize:12,fontFamily:"sans-serif",userSelect:"none",boxShadow:"0 1px 4px rgba(0,0,0,0.12)",whiteSpace:"nowrap"},ds={width:12,height:3,borderRadius:1,display:"inline-block",flexShrink:0},gs={fontWeight:600},ps={display:"flex",alignItems:"center",gap:4,padding:"1px 4px"},ae=E.memo(function({label:e,color:n,value:o,isHidden:s,onClick:r}){return W.jsxs("div",{onClick:r,style:{...ps,opacity:s?.4:1,cursor:r?"pointer":"default"},children:[W.jsx("span",{style:{...ds,backgroundColor:n}}),W.jsx("span",{children:e}),o&&W.jsx("span",{style:gs,children:o})]})}),zt=E.forwardRef(function({left:e,top:n,children:o,className:s,style:r,onMouseDown:i,onMouseEnter:l,onMouseLeave:c},f){return W.jsx("div",{ref:f,className:s,onMouseDown:i,onMouseEnter:l,onMouseLeave:c,style:{...hs,left:e,top:n,...r},children:o})});function ms(t,e,n,o,s){if(s<0||o<0)return"";const i=t.dataStore.getYValues(e,n)[s];return i==null?"":typeof i=="number"?i.toPrecision(4):String(i)}function ws({show:t=!0,className:e,children:n,offset:o={}}){var v,b;const s=J(),r=E.useRef({left:-10,top:-10,activeGroup:-1,activeDataIdx:-1,revision:-1}),i=E.useRef(null),l=E.useCallback(w=>s.subscribeCursor(w),[s]),c=E.useCallback(()=>{const w=s.cursorManager.state,{revision:I}=s,L=r.current;if(L.left===w.left&&L.top===w.top&&L.activeGroup===w.activeGroup&&L.activeDataIdx===w.activeDataIdx&&L.revision===I)return L;const R={left:w.left,top:w.top,activeGroup:w.activeGroup,activeDataIdx:w.activeDataIdx,revision:I};return r.current=R,R},[s]),f=E.useSyncExternalStore(l,c);if(!t||f.activeDataIdx<0||f.activeGroup<0||f.left<0)return null;const{activeGroup:a,activeDataIdx:d}=f,u=s.plotBox,h=s.dataStore.data[a],p=h!=null?h.x[d]??null:null,x=p!=null?parseFloat(p.toPrecision(6)).toString():"",y=[];for(const w of s.seriesConfigs){if(w.show===!1||w.legend===!1)continue;const I=s.dataStore.getYValues(w.group,w.index),L=w.group===a?I[d]:null;y.push({label:w.label??`Series ${w.index}`,value:L,color:typeof w.stroke=="string"?w.stroke:"#000",group:w.group,index:w.index})}const g={x:p,xLabel:x,items:y,left:f.left+u.left,top:f.top+u.top},S=o.x??12,T=o.y??-12,M=((v=i.current)==null?void 0:v.offsetWidth)??0,_=((b=i.current)==null?void 0:b.offsetHeight)??0,P=f.left+u.left,C=f.top+u.top,k=u.left+u.width,A=u.top+u.height,D=q(P+S,u.left,k-M),m=q(C+T,u.top,A-_);return n?W.jsx("div",{ref:i,className:e,style:{position:"absolute",left:D,top:m,whiteSpace:"nowrap",pointerEvents:"none",zIndex:100},children:n(g)}):W.jsxs(zt,{ref:i,left:D,top:m,className:e,style:{pointerEvents:"none",zIndex:100},children:[W.jsx("div",{style:{fontWeight:600,marginBottom:2,padding:"0 4px"},children:x}),y.map(w=>W.jsx(ae,{label:w.label,color:w.color,value:w.value!=null?w.value.toPrecision(4):"—"},`${w.group}:${w.index}`))]})}const vs=8,Ge=.01,bs=[.25,.75];function Ss({width:t,height:e,data:n,onRangeChange:o,initialRange:s,className:r,colors:i,grips:l=!1}){const c=E.useRef(null),f=E.useMemo(()=>ie(n),[n]),[a,d]=E.useState(()=>{if(s!=null&&f.length>0){const P=f[0];if(P!=null&&P.x.length>1){const C=P.x[0],A=P.x[P.x.length-1]-C;if(A>0)return[Math.max(0,(s[0]-C)/A),Math.min(1,(s[1]-C)/A)]}}return bs}),u=E.useRef(null);E.useEffect(()=>{if(o==null||f.length===0)return;const P=f[0];if(P==null||P.x.length<2)return;const C=P.x[0],A=P.x[P.x.length-1]-C,D=C+a[0]*A,m=C+a[1]*A,v=u.current,b=Math.max(1e-10,Math.abs(m-D)*1e-12);v!=null&&Math.abs(v[0]-D)<b&&Math.abs(v[1]-m)<b||(u.current=[D,m],o(D,m))},[a,f,o]);const h=E.useRef(null),p=E.useCallback(P=>{const C=c.current;if(C==null)return 0;const k=C.getBoundingClientRect();return q((P-k.left)/k.width,0,1)},[]),x=E.useCallback(P=>{const C=c.current;if(C==null)return;const k=p(P.clientX),A=C.getBoundingClientRect().width,D=A>0?vs/A:0;let m;if(Math.abs(k-a[0])<D)m="left";else if(Math.abs(k-a[1])<D)m="right";else if(k>=a[0]&&k<=a[1])m="move";else{const v=a[1]-a[0],b=v/2,w=q(k-b,0,1-v);d([w,w+v]),m="move"}h.current={mode:m,startX:P.clientX,startFrac:[...a]},C.setPointerCapture(P.pointerId),P.preventDefault()},[a,p]),y=E.useCallback(P=>{const C=h.current;if(C==null)return;const k=p(P.clientX),A=p(C.startX),D=k-A;if(C.mode==="move"){const m=C.startFrac[1]-C.startFrac[0],v=q(C.startFrac[0]+D,0,1-m);d([v,v+m])}else if(C.mode==="left"){const m=q(C.startFrac[0]+D,0,C.startFrac[1]-Ge);d([m,C.startFrac[1]])}else{const m=q(C.startFrac[1]+D,C.startFrac[0]+Ge,1);d([C.startFrac[0],m])}},[p]),g=E.useCallback(P=>{h.current=null;const C=c.current;C!=null&&C.releasePointerCapture(P.pointerId)},[]),S=`${a[0]*100}%`,T=`${(a[1]-a[0])*100}%`,M=f[0],_=M!=null?M.series.length:0;return W.jsxs("div",{className:r,style:{position:"relative",width:t,height:e},children:[W.jsxs(re,{width:t,height:e,data:n,children:[W.jsx(Pt,{scale:"x",show:!1}),W.jsx(Pt,{scale:"y",show:!1}),Array.from({length:_},(P,C)=>W.jsx(ce,{group:0,index:C,yScale:"y",stroke:i!=null&&i[C]!=null?i[C]:`hsl(${C*137}, 60%, 50%)`,width:1},C))]}),W.jsxs("div",{ref:c,onPointerDown:x,onPointerMove:y,onPointerUp:g,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[W.jsx("div",{style:{position:"absolute",top:0,left:0,width:S,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),W.jsx("div",{style:{position:"absolute",top:0,left:`${a[1]*100}%`,right:0,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),W.jsx("div",{style:{position:"absolute",top:0,left:S,width:T,height:"100%",borderLeft:"2px solid rgba(0,100,255,0.8)",borderRight:"2px solid rgba(0,100,255,0.8)",boxSizing:"border-box",cursor:"grab",pointerEvents:"none"},children:l&&W.jsxs(W.Fragment,{children:[W.jsx("div",{style:{position:"absolute",left:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:"rgba(0,100,255,0.8)",cursor:"ew-resize",pointerEvents:"auto"}}),W.jsx("div",{style:{position:"absolute",right:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:"rgba(0,100,255,0.8)",cursor:"ew-resize",pointerEvents:"auto"}})]})})]})]})}function dt(t){const e=J(),n=E.useRef(t);n.current=t,E.useEffect(()=>{const o=s=>n.current(s);return e.drawHooks.add(o),()=>{e.drawHooks.delete(o)}},[e])}function xs(t){const e=J(),n=E.useRef(t);n.current=t,E.useEffect(()=>{const o=(s,r)=>n.current(s,r);return e.cursorDrawHooks.add(o),()=>{e.cursorDrawHooks.delete(o)}},[e])}function Ms({lanes:t,laneHeight:e=24,gap:n=2,scaleId:o="x"}){const s=J();return dt(({ctx:r,plotBox:i,pxRatio:l})=>{const c=s.scaleManager.getScale(o);if(c==null||!N(c))return;r.save(),r.beginPath(),r.rect(i.left*l,i.top*l,i.width*l,i.height*l),r.clip();const f=(e+n)*l,a=e*l,d=i.top*l;for(let u=0;u<t.length;u++){const h=t[u];if(h==null)continue;const p=d+u*f;r.fillStyle="#666",r.font=`${11*l}px sans-serif`,r.textAlign="right",r.textBaseline="middle",r.fillText(h.label,(i.left-6)*l,p+a/2);for(const x of h.segments){const y=X(x.start,c,i.width,i.left)*l,S=X(x.end,c,i.width,i.left)*l-y;S<=0||(r.fillStyle=x.color??"#4dabf7",r.fillRect(y,p,S,a),x.label!=null&&S>20*l&&(r.fillStyle="#fff",r.font=`${10*l}px sans-serif`,r.textAlign="center",r.textBaseline="middle",r.fillText(x.label,y+S/2,p+a/2,S-4*l)))}}r.restore()}),null}function ys({data:t,width:e=150,height:n=30,stroke:o="#03a9f4",fill:s,lineWidth:r=1,paths:i,fillTo:l,className:c}){return W.jsx("div",{style:{pointerEvents:"none"},className:c,children:W.jsxs(re,{width:e,height:n,data:t,children:[W.jsx(Pt,{scale:"x",show:!1}),W.jsx(Pt,{scale:"y",show:!1}),W.jsx(ce,{group:0,index:0,yScale:"y",stroke:o,fill:s,width:r,paths:i,fillTo:l})]})})}const at=8;function We(t,e,n,o){if(t!=null&&typeof t=="object")return t;switch(t){case"top-left":return{x:e.left+at,y:e.top+at};case"bottom-left":return{x:e.left+at,y:e.top+e.height-o-at};case"bottom-right":return{x:e.left+e.width-n-at,y:e.top+e.height-o-at};case"top-right":default:return{x:e.left+e.width-n-at,y:e.top+at}}}function Cs({mode:t="draggable",position:e="top-right",offset:n={x:12,y:-12},idleOpacity:o=.3,show:s=!0,className:r}){var m,v;const i=J(),l=E.useRef(null),[c,f]=E.useState(null),[a,d]=E.useState(!1),u=E.useRef(!1),h=E.useRef(!1),p=E.useRef({dx:0,dy:0}),x=E.useRef(!1),y=E.useRef(null),g=E.useCallback(b=>i.subscribeCursor(b),[i]),S=E.useCallback(()=>{const{activeGroup:b,activeDataIdx:w,left:I,top:L}=i.cursorManager.state,R=i.seriesConfigs.length,{revision:F}=i,{left:z,top:G,width:$,height:V}=i.plotBox,j=l.current;if(j!=null&&j.activeGroup===b&&j.activeDataIdx===w&&j.cursorLeft===I&&j.cursorTop===L&&j.seriesCount===R&&j.revision===F&&j.plotLeft===z&&j.plotTop===G&&j.plotWidth===$&&j.plotHeight===V)return j;const Q={activeGroup:b,activeDataIdx:w,cursorLeft:I,cursorTop:L,seriesCount:R,revision:F,plotLeft:z,plotTop:G,plotWidth:$,plotHeight:V};return l.current=Q,Q},[i]),T=E.useSyncExternalStore(g,S);t==="draggable"&&!x.current&&T.plotWidth>0&&(x.current=!0,c==null&&f(We(e,i.plotBox,0,0))),E.useLayoutEffect(()=>{if(t!=="draggable"||!x.current||y.current==null)return;const b=y.current,w=b.offsetWidth,I=b.offsetHeight;w===0&&I===0||typeof e!="object"&&f(We(e,i.plotBox,w,I))},[x.current]);const M=E.useCallback((b,w)=>{h.current||i.toggleSeries(b,w)},[i]),_=E.useCallback(b=>{if(t!=="draggable")return;b.stopPropagation(),b.preventDefault(),u.current=!0,h.current=!1;const w=b.currentTarget.getBoundingClientRect();p.current={dx:b.clientX-w.left,dy:b.clientY-w.top}},[t]);if(E.useEffect(()=>{if(!s||t!=="draggable")return;const b=I=>{var F;if(!u.current)return;h.current=!0;const L=(F=i.canvas)==null?void 0:F.parentElement;if(!L)return;const R=L.getBoundingClientRect();f({x:I.clientX-R.left-p.current.dx,y:I.clientY-R.top-p.current.dy})},w=()=>{u.current=!1};return window.addEventListener("mousemove",b),window.addEventListener("mouseup",w),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",w)}},[i,s,t]),!s)return null;const{activeGroup:P,activeDataIdx:C,cursorLeft:k,cursorTop:A}=T,D=i.seriesConfigs.filter(b=>b.legend!==!1).map(b=>{const w=typeof b.stroke=="string"?b.stroke:"#000",I=ms(i,b.group,b.index,P,C),L=t==="draggable";return W.jsx(ae,{label:b.label??`Series ${b.index}`,color:w,value:I,isHidden:b.show===!1,onClick:L?()=>M(b.group,b.index):void 0},`${b.group}:${b.index}`)});if(t==="cursor"){if(k<0)return null;const b=((m=y.current)==null?void 0:m.offsetWidth)??0,w=((v=y.current)==null?void 0:v.offsetHeight)??0,I=T.plotLeft+T.plotWidth,L=T.plotTop+T.plotHeight,R=q(k+T.plotLeft+n.x,T.plotLeft,I-b),F=q(A+T.plotTop+n.y,T.plotTop,L-w);return W.jsx(zt,{ref:y,left:R,top:F,className:r,style:{pointerEvents:"none"},children:D})}return c==null?null:W.jsx(zt,{ref:y,left:c.x,top:c.y,className:r,onMouseDown:_,onMouseEnter:()=>d(!0),onMouseLeave:()=>{d(!1),h.current=!1},style:{pointerEvents:"auto",cursor:u.current?"grabbing":"grab",opacity:a||u.current?1:o,transition:"opacity 0.2s ease"},children:D})}function ks({delay:t=1e3,show:e=!0,className:n}){var _,P;const o=J(),s=E.useRef(null),[r,i]=E.useState(!1),l=E.useRef(-1),c=E.useRef(0),f=E.useRef(null),a=E.useCallback(C=>o.subscribe(C),[o]),d=E.useCallback(()=>{const{left:C,top:k,activeSeriesIdx:A,activeGroup:D}=o.cursorManager.state,{left:m,top:v,width:b,height:w}=o.plotBox,I=s.current;if(I!=null&&I.cursorLeft===C&&I.cursorTop===k&&I.activeSeriesIdx===A&&I.activeGroup===D&&I.plotLeft===m&&I.plotTop===v&&I.plotWidth===b&&I.plotHeight===w)return I;const L={cursorLeft:C,cursorTop:k,activeSeriesIdx:A,activeGroup:D,plotLeft:m,plotTop:v,plotWidth:b,plotHeight:w};return s.current=L,L},[o]),u=E.useSyncExternalStore(a,d);if(E.useEffect(()=>{const C=u.activeSeriesIdx;C!==l.current&&(l.current=C,i(!1),window.clearTimeout(c.current),C>=0&&(c.current=window.setTimeout(()=>i(!0),t)))},[u.activeSeriesIdx,t]),E.useEffect(()=>()=>{window.clearTimeout(c.current)},[]),!e||!r||u.cursorLeft<0)return null;const h=o.seriesConfigs.find(C=>C.group===u.activeGroup&&C.index===u.activeSeriesIdx);if(!(h!=null&&h.label)||h.legend===!1)return null;const p=typeof h.stroke=="string"?h.stroke:"#000",x=((_=f.current)==null?void 0:_.offsetWidth)??80,y=((P=f.current)==null?void 0:P.offsetHeight)??24,g=u.cursorLeft+u.plotLeft,S=u.cursorTop+u.plotTop,T=q(g-x/2,u.plotLeft,u.plotLeft+u.plotWidth-x),M=q(S-y-12,u.plotTop,u.plotTop+u.plotHeight-y);return W.jsx(zt,{ref:f,left:T,top:M,className:n,style:{pointerEvents:"none"},children:W.jsx(ae,{label:h.label,color:p})})}function cn(t,e,n,o,s,r,i,l,c){const f=i/2;if(c.wickColor!=null&&(t.strokeStyle=c.wickColor,t.lineWidth=c.wickWidth??1,t.beginPath(),t.moveTo(e,n),t.lineTo(e,o),t.stroke()),c.capWidth!=null&&c.capWidth>0){const u=c.capWidth/2;t.strokeStyle=c.wickColor??"#555",t.lineWidth=c.wickWidth??1,t.beginPath(),t.moveTo(e-u,n),t.lineTo(e+u,n),t.moveTo(e-u,o),t.lineTo(e+u,o),t.stroke()}const a=Math.min(s,r),d=Math.abs(r-s);t.fillStyle=c.bodyFill,t.fillRect(e-f,a,i,d),c.bodyStroke!=null&&(t.strokeStyle=c.bodyStroke,t.lineWidth=c.bodyStrokeWidth??1.5,t.strokeRect(e-f,a,i,d)),l!=null&&c.midColor!=null&&(t.strokeStyle=c.midColor,t.lineWidth=c.midWidth??2.5,t.beginPath(),t.moveTo(e-f,l),t.lineTo(e+f,l),t.stroke())}function Ts({boxes:t,yScale:e="y",boxWidth:n=.5,fill:o="rgba(52, 152, 219, 0.4)",stroke:s="#2980b9",medianColor:r="#e74c3c",whiskerColor:i="#555"}){return dt(({ctx:l,plotBox:c,valToX:f,valToY:a})=>{const d=c.width/t.length*n,u=d*.3;for(let h=0;h<t.length;h++){const p=t[h];if(p==null)continue;const x=f(h+1),y=a(p.min,e),g=a(p.q1,e),S=a(p.median,e),T=a(p.q3,e),M=a(p.max,e);x==null||y==null||g==null||S==null||T==null||M==null||cn(l,x,y,M,g,T,d,S,{wickColor:i,bodyFill:o,bodyStroke:s,capWidth:u,midColor:r})}}),null}function Is(t){const e=Math.max(0,Math.min(1,t)),n=[[0,15,30,80],[.15,30,100,200],[.3,40,190,210],[.45,50,200,80],[.6,230,220,40],[.75,240,140,30],[.9,220,40,30],[1,120,10,10]];let o=n[0],s=n[n.length-1];for(let f=0;f<n.length-1;f++){const a=n[f],d=n[f+1];if(a!=null&&d!=null&&e>=a[0]&&e<=d[0]){o=a,s=d;break}}const r=s[0]===o[0]?0:(e-o[0])/(s[0]-o[0]),i=Math.round(o[1]+r*(s[1]-o[1])),l=Math.round(o[2]+r*(s[2]-o[2])),c=Math.round(o[3]+r*(s[3]-o[3]));return`rgb(${i},${l},${c})`}function As({grid:t,xRange:e,yRange:n,colorMap:o=Is,yScale:s="y"}){return dt(({ctx:r,valToX:i,valToY:l})=>{var g;if(t.length===0)return;const c=t.length,f=((g=t[0])==null?void 0:g.length)??0;if(f===0)return;const a=(e==null?void 0:e[0])??0,d=(e==null?void 0:e[1])??c,u=(n==null?void 0:n[0])??0,h=(n==null?void 0:n[1])??f,p=(d-a)/c,x=(h-u)/f;let y=0;for(const S of t)for(const T of S)T>y&&(y=T);if(y!==0)for(let S=0;S<c;S++){const T=t[S];if(T==null)continue;const M=i(a+S*p),_=i(a+(S+1)*p);if(M==null||_==null)continue;const P=_-M;for(let C=0;C<f;C++){const k=T[C]??0,A=u+C*x,D=u+(C+1)*x,m=l(D,s),v=l(A,s);if(m==null||v==null)continue;const b=v-m;r.fillStyle=o(k/y),r.fillRect(M,m,P,b)}}}),null}function Ls(t,e,n,o,s){const r=(o-90)*(Math.PI/180),i=s,l=i*.35,c=Math.PI/6,f=e+Math.cos(r)*i,a=n+Math.sin(r)*i,d=e-Math.cos(r)*i*.5,u=n-Math.sin(r)*i*.5;t.beginPath(),t.moveTo(d,u),t.lineTo(f,a),t.stroke(),t.beginPath(),t.moveTo(f,a),t.lineTo(f-l*Math.cos(r-c),a-l*Math.sin(r-c)),t.moveTo(f,a),t.lineTo(f-l*Math.cos(r+c),a-l*Math.sin(r+c)),t.stroke()}function Ps({directions:t,group:e=0,index:n=0,color:o="#c0392b",minSize:s=4,maxSize:r=10}){const i=J();return dt(({ctx:l,valToX:c,valToY:f})=>{var g;const a=i.dataStore.data[e];if(a==null)return;const d=a.x,u=a.series[n];if(u==null)return;let h=1/0,p=-1/0;for(let S=0;S<u.length;S++){const T=u[S];T!=null&&(T<h&&(h=T),T>p&&(p=T))}const x=p-h||1,y=((g=i.seriesConfigs.find(S=>S.group===e&&S.index===n))==null?void 0:g.yScale)??"y";l.strokeStyle=o,l.lineWidth=1.5,l.lineCap="round";for(let S=0;S<d.length;S++){const T=u[S],M=t[S];if(T==null||M==null)continue;const _=c(d[S]),P=f(T,y);if(_==null||P==null)continue;const C=(T-h)/x,k=s+C*(r-s);Ls(l,_,P,M,k)}}),null}const Ds=4;function ue(t,e){t.strokeStyle=e.stroke??"red",t.lineWidth=e.width??1,e.dash&&t.setLineDash(e.dash)}function fe(t,e){e.dash&&t.setLineDash([])}function an(t,e,n,o={}){const{ctx:s,plotBox:r}=t,i=X(n,e,r.height,r.top);s.beginPath(),s.moveTo(r.left,i),s.lineTo(r.left+r.width,i),ue(s,o),s.stroke(),fe(s,o)}function un(t,e,n,o={}){const{ctx:s,plotBox:r}=t,i=X(n,e,r.width,r.left);s.beginPath(),s.moveTo(i,r.top),s.lineTo(i,r.top+r.height),ue(s,o),s.stroke(),fe(s,o)}function Es(t,e,n,o,s,r,i={}){const{ctx:l,plotBox:c}=t,f=X(o,e,c.width,c.left),a=X(s,n,c.height,c.top);l.font=i.font??"12px sans-serif",l.fillStyle=i.fill??"#000",l.textBaseline="bottom",l.fillText(r,f,a-Ds)}function fn(t,e,n,o,s={}){const{ctx:r,plotBox:i}=t,l=X(o,e,i.height,i.top),c=X(n,e,i.height,i.top);r.fillStyle=s.fill??"rgba(255,0,0,0.1)",r.fillRect(i.left,Math.min(l,c),i.width,Math.abs(c-l)),s.stroke&&(ue(r,s),r.strokeRect(i.left,Math.min(l,c),i.width,Math.abs(c-l)),fe(r,s))}function he(t,e,n){const o=E.useRef(t);E.useLayoutEffect(()=>{o.current=t}),dt(s=>{const r=s.getScale(e);r!=null&&n(s,r,o.current)})}function _s(t){return he(t,t.yScale??"y",(e,n,o)=>{if(an(e,n,o.value,{stroke:o.stroke,width:o.width,dash:o.dash}),o.label!=null){const s=e.valToY(o.value,o.yScale??"y");if(s==null)return;const{ctx:r,plotBox:i}=e;r.font=o.labelFont??"11px sans-serif",r.fillStyle=o.stroke??"red",r.textAlign="left",r.textBaseline="bottom",r.fillText(o.label,i.left+4,s-4)}}),null}function Rs(t){return he(t,t.xScale??"x",(e,n,o)=>{if(un(e,n,o.value,{stroke:o.stroke,width:o.width,dash:o.dash}),o.label!=null){const s=e.valToX(o.value,o.xScale??"x");if(s==null)return;const{ctx:r,plotBox:i}=e;r.font=o.labelFont??"11px sans-serif",r.fillStyle=o.stroke??"red",r.textAlign="center",r.textBaseline="bottom",r.fillText(o.label,s,i.top-4)}}),null}function Fs(t){return he(t,t.yScale??"y",(e,n,o)=>{fn(e,n,o.yMin,o.yMax,{fill:o.fill,stroke:o.stroke,width:o.strokeWidth,dash:o.dash})}),null}function zs(t){const e=E.useRef(t);return E.useLayoutEffect(()=>{e.current=t}),dt(n=>{const o=e.current,s=n.valToX(o.x,o.xScale??"x"),r=n.valToY(o.y,o.yScale??"y");if(s==null||r==null)return;const{ctx:i}=n;i.font=o.font??"12px sans-serif",i.fillStyle=o.fill??"#000",i.textAlign=o.align??"left",i.textBaseline=o.baseline??"bottom",i.fillText(o.text,s,r-4)}),null}function Hs(t,e){const{window:n,batchSize:o=1}=e,s=e.autoStart??!0,[r,i]=E.useState(()=>ie(t)),[l,c]=E.useState(!1),[f,a]=E.useState(0),d=E.useRef(0),u=E.useRef(0),h=E.useRef(0),p=E.useRef(new Map),x=E.useRef(0),y=E.useRef(n);y.current=n;const g=E.useRef(o);g.current=o;const S=E.useCallback((P,C,...k)=>{let A=p.current.get(P);A==null&&(A={x:[],series:k.map(()=>[])},p.current.set(P,A)),A.x.push(...C);for(let m=0;m<k.length;m++){let v=A.series[m];v==null&&(v=[],A.series[m]=v),v.push(...k[m]??[])}const D=A.x.length;x.current===0&&D>=g.current&&(x.current=requestAnimationFrame(()=>{x.current=0;const m=p.current;p.current=new Map;const v=y.current;i(b=>{const w=b.slice();for(const[I,{x:L,series:R}]of m){const F=w[I];if(F==null)continue;const z=F.x,G=Math.max(0,z.length+L.length-v),$=G>0?z.slice(G).concat(L):z.concat(L),V=F.series.map((j,Q)=>{const it=j,bt=R[Q]??[];return G>0?it.slice(G).concat(bt):it.concat(bt)});w[I]={x:$,series:V}}return w})}))},[]),T=E.useCallback((P,...C)=>{S(0,P,...C)},[S]),M=E.useCallback(()=>{c(!0)},[]),_=E.useCallback(()=>{c(!1)},[]);return E.useEffect(()=>{if(!l){d.current!==0&&(cancelAnimationFrame(d.current),d.current=0);return}h.current=performance.now(),u.current=0;const P=C=>{u.current++;const k=C-h.current;k>=1e3&&(a(Math.round(u.current*1e3/k)),u.current=0,h.current=C),d.current=requestAnimationFrame(P)};return d.current=requestAnimationFrame(P),()=>{d.current!==0&&(cancelAnimationFrame(d.current),d.current=0)}},[l]),E.useEffect(()=>()=>{x.current!==0&&cancelAnimationFrame(x.current)},[]),E.useEffect(()=>{s&&c(!0)},[s]),{data:r,push:T,pushGroup:S,start:M,stop:_,running:l,fps:f}}function Gs(t){const e=(n,o,s,r,i,l,c,f,a,d,u,h,p)=>{const x=(p==null?void 0:p.align)??t??1,y=(p==null?void 0:p.spanGaps)??!1;if([a,d]=Ht(o,a,d),a===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const g=D=>h(X(D,s,i,c)),S=D=>h(X(D,r,l,f)),T=s.ori===H.Horizontal?Gt:Wt,M={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},_=M.stroke;let P=!1;const C=u===O.Forward?a:d;let k=S(o[C]),A=g(n[C]);T(_,A,k);for(let D=C;D>=a&&D<=d;D+=u){const m=o[D];if(m==null){m===null&&!y&&(P=!0);continue}const v=g(n[D]),b=S(m);if(x===1)T(_,v,k);else if(x===-1)T(_,A,b);else{const w=h((A+v)/2);T(_,w,k),T(_,w,b)}T(_,v,b),k=b,A=v}{const D=M.fill=new Path2D(_),m=(p==null?void 0:p.fillTo)??r.min??0,v=S(m);let b=g(n[a]),w=g(n[d]);u===O.Backward&&([w,b]=[b,w]),T(D,w,v),T(D,b,v)}if(P){const D=ne(n,o,a,d,u,g);M.gaps=D,M.clip=oe(D,s.ori,c,f,i,l)}return M};return e.defaults=ee,e}function de(t){return t.defaults=En,t}function ge(){return de((e,n,o,s,r,i,l,c,f,a,d,u,h)=>{const p=(h==null?void 0:h.barWidth)??.6,x=(h==null?void 0:h.barGap)??0,y=(h==null?void 0:h.barRadius)??0,g=(h==null?void 0:h.barGroupIdx)??0,S=(h==null?void 0:h.barGroupCount)??1,T=w=>u(X(w,o,r,l)),M=w=>u(X(w,s,i,c));let _=r;if(a>f){let w=1/0,I=-1;for(let L=f;L<=a;L++)if(n[L]!=null){if(I>=0){const R=e[L],F=e[I],z=Math.abs(T(R)-T(F));z<w&&(w=z)}I=L}w<1/0&&(_=w)}const P=_*(1-p),C=Math.max(0,P+x),k=Math.max(1,u(_-C)),A=S>1?Math.max(1,u(k/Math.max(1,S))):k,D=(h==null?void 0:h.fillTo)??s.min??0,m=M(D),v=new Path2D,b=o.ori===H.Horizontal;for(let w=d===O.Forward?f:a;w>=f&&w<=a;w+=d){const I=n[w];if(I==null)continue;const L=T(e[w]),R=M(I),F=S>1?(g-(S-1)/2)*A:0,z=u(L-A/2+F),G=Math.min(R,m),V=Math.max(R,m)-G;if(V!==0)if(y>0){const j=Math.min(y*A,V/2);Vs(v,b,z,G,A,V,j,I<D)}else b?v.rect(z,G,A,V):v.rect(G,z,V,A)}return{stroke:v,fill:v,clip:null,band:null,gaps:null}})}function Ws(t,e){const n=ge();return de((s,r,i,l,c,f,a,d,u,h,p,x,y)=>{const g={...y,barGroupIdx:t,barGroupCount:e};return n(s,r,i,l,c,f,a,d,u,h,p,x,g)})}function $s(){const t=ge();return de((n,o,s,r,i,l,c,f,a,d,u,h,p)=>{const x={barWidth:.8,...p};return t(n,o,s,r,i,l,c,f,a,d,u,h,x)})}function Vs(t,e,n,o,s,r,i,l){i=Math.min(i,s/2,r/2),e?l?(t.moveTo(n,o),t.lineTo(n+s,o),t.lineTo(n+s,o+r-i),t.arc(n+s-i,o+r-i,i,0,Math.PI/2),t.lineTo(n+i,o+r),t.arc(n+i,o+r-i,i,Math.PI/2,Math.PI),t.closePath()):(t.moveTo(n,o+r),t.lineTo(n,o+i),t.arc(n+i,o+i,i,Math.PI,Math.PI*1.5),t.lineTo(n+s-i,o),t.arc(n+s-i,o+i,i,Math.PI*1.5,0),t.lineTo(n+s,o+r),t.closePath()):l?(t.moveTo(o,n),t.lineTo(o,n+s),t.lineTo(o+r-i,n+s),t.arc(o+r-i,n+s-i,i,Math.PI/2,0,!0),t.lineTo(o+r,n+i),t.arc(o+r-i,n+i,i,0,-Math.PI/2,!0),t.closePath()):(t.moveTo(o+r,n),t.lineTo(o+i,n),t.arc(o+i,n+i,i,-Math.PI/2,Math.PI,!0),t.lineTo(o,n+s-i),t.arc(o+i,n+s-i,i,Math.PI,Math.PI/2,!0),t.lineTo(o+r,n+s),t.closePath())}function hn(t){const e=(n,o,s,r,i,l,c,f,a,d,u,h,p)=>{const x=(p==null?void 0:p.spanGaps)??!1;if([a,d]=Ht(o,a,d),a===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const y=A=>h(X(A,s,i,c)),g=A=>h(X(A,r,l,f)),S=s.ori===H.Horizontal?Gt:Wt,T=[],M=[];let _=!1;for(let A=u===O.Forward?a:d;A>=a&&A<=d;A+=u){const D=o[A];D!=null?(T.push(y(n[A])),M.push(g(D))):D===null&&!x&&(_=!0)}const P=s.ori===H.Horizontal,C=t(T,M,P,h),k={stroke:C??new Path2D,fill:null,clip:null,band:null,gaps:null};if(C!=null){const A=k.fill=new Path2D(C),D=(p==null?void 0:p.fillTo)??r.min??0,m=g(D);let v=y(n[a]),b=y(n[d]);u===O.Backward&&([b,v]=[v,b]),S(A,b,m),S(A,v,m)}if(_){const A=ne(n,o,a,d,u,y);k.gaps=A,k.clip=oe(A,s.ori,c,f,i,l)}return k};return e.defaults=ee,e}function Bs(){return hn(Xs)}const Xs=(t,e,n,o)=>{const s=t.length;if(s<2)return null;const r=new Path2D,i=t[0]??0,l=e[0]??0;if(n?r.moveTo(i,l):r.moveTo(l,i),s===2){const u=t[1]??0,h=e[1]??0;return n?r.lineTo(u,h):r.lineTo(h,u),r}const c=new Array(s),f=new Array(s-1),a=new Array(s-1),d=new Array(s-1);for(let u=0;u<s-1;u++)a[u]=(e[u+1]??0)-(e[u]??0),d[u]=(t[u+1]??0)-(t[u]??0),f[u]=d[u]!==0?(a[u]??0)/(d[u]??1):0;c[0]=f[0]??0;for(let u=1;u<s-1;u++){const h=f[u]??0,p=f[u-1]??0;if(h===0||p===0||p>0!=h>0)c[u]=0;else{const x=d[u]??1,y=d[u-1]??1;c[u]=3*(y+x)/((2*x+y)/p+(x+2*y)/h),isFinite(c[u]??0)||(c[u]=0)}}c[s-1]=f[s-2]??0;for(let u=0;u<s-1;u++){const h=d[u]??1,p=t[u]??0,x=e[u]??0,y=t[u+1]??0,g=e[u+1]??0,S=c[u]??0,T=c[u+1]??0,M=p+h/3,_=x+S*h/3,P=y-h/3,C=g-T*h/3;n?r.bezierCurveTo(M,_,P,C,y,g):r.bezierCurveTo(_,M,C,P,g,y)}return r};function js(){return hn(Ys)}const Ys=(t,e,n,o)=>{const s=t.length;if(s<2)return null;const r=new Path2D,i=o(t[0]??0),l=o(e[0]??0);if(n?r.moveTo(i,l):r.moveTo(l,i),s===2){const c=o(t[1]??0),f=o(e[1]??0);return n?r.lineTo(c,f):r.lineTo(f,c),r}for(let c=0;c<s-1;c++){const f=c===0?0:c-1,a=t[f]??0,d=e[f]??0,u=t[c]??0,h=e[c]??0,p=t[c+1]??0,x=e[c+1]??0,y=c+2<s?t[c+2]??0:p,g=c+2<s?e[c+2]??0:x,S=Math.hypot(a-u,d-h),T=Math.hypot(u-p,h-x),M=Math.hypot(p-y,x-g),_=Math.sqrt(M),P=M,C=Math.sqrt(T),k=T,A=Math.sqrt(S),D=S,m=2*D+3*A*C+k,v=2*P+3*_*C+k,b=3*A*(A+C),w=3*_*(_+C);let I,L,R,F;if(b>0){const z=1/b;I=(-k*a+m*u+D*p)*z,L=(-k*d+m*h+D*x)*z}else I=u,L=h;if(w>0){const z=1/w;R=(P*u+v*p-k*y)*z,F=(P*h+v*x-k*g)*z}else R=p,F=x;n?r.bezierCurveTo(I,L,R,F,p,x):r.bezierCurveTo(L,I,F,R,x,p)}return r};function Ns(t=4){const e=(n,o,s,r,i,l,c,f,a,d,u,h,p)=>{const x=M=>h(X(M,s,i,c)),y=M=>h(X(M,r,l,f)),g=t/2,S=new Path2D,T=s.ori===H.Horizontal;for(let M=u===O.Forward?a:d;M>=a&&M<=d;M+=u){const _=o[M];if(_==null)continue;const P=x(n[M]),C=y(_);T?(S.moveTo(P+g,C),S.arc(P,C,g,0,Math.PI*2)):(S.moveTo(C+g,P),S.arc(C,P,g,0,Math.PI*2))}return{stroke:S,fill:S,clip:null,band:null,gaps:null}};return e.defaults=_n,e}function Os({group:t=0,series:e=[0,1,2,3],yScale:n="y",upColor:o="#26a69a",downColor:s="#ef5350",bodyWidth:r=.6,wickWidth:i=1}){const l=J();return dt(({ctx:c,plotBox:f,valToX:a,valToY:d})=>{const u=l.dataStore.data[t];if(u==null)return;const h=u.x,p=u.series[e[0]],x=u.series[e[1]],y=u.series[e[2]],g=u.series[e[3]];if(p==null||x==null||y==null||g==null)return;const S=h.length;if(S===0)return;const T=Math.max(2,f.width/S*r);for(let M=0;M<S;M++){const _=h[M],P=p[M],C=x[M],k=y[M],A=g[M];if(_==null||P==null||C==null||k==null||A==null)continue;const D=a(_),m=d(C,n),v=d(k,n),b=d(P,n),w=d(A,n);if(D==null||m==null||v==null||b==null||w==null)continue;const L=A>=P?o:s;cn(c,D,m,v,b,w,T,null,{wickColor:L,wickWidth:i,bodyFill:L})}}),null}function Ks(t,e,n=0){const o=e??t.series.map((a,d)=>d),s=t.x.length,r=[],i=new Float64Array(s);for(let a=0;a<o.length;a++){const d=o[a];if(d==null)continue;const u=t.series[d];if(u==null)continue;const h=new Array(s);for(let p=0;p<s;p++){const x=u[p];x!=null?(i[p]=i[p]+x,h[p]=i[p]):h[p]=null}r.push(h)}const l=new Map;for(let a=0;a<o.length;a++){const d=o[a];d!=null&&l.set(d,a)}const c=[];for(let a=0;a<t.series.length;a++){const d=l.get(a)??-1,u=d>=0?r[d]:void 0;u!=null?c.push(u):c.push(t.series[a]??[])}const f=[];for(let a=o.length-1;a>0;a--){const d=o[a],u=o[a-1];d!=null&&u!=null&&f.push({group:n,series:[d,u]})}return{group:{x:t.x,series:c},bands:f}}function Us(t){const e=new Set;for(const[r]of t)for(let i=0;i<r.length;i++){const l=r[i];l!=null&&e.add(l)}const n=Float64Array.from([...e].sort((r,i)=>r-i)),o=new Map;for(let r=0;r<n.length;r++){const i=n[r];i!=null&&o.set(i,r)}const s=[];for(const[r,i]of t){const l=new Array(n.length).fill(null);for(let c=0;c<r.length;c++){const f=r[c];if(f==null)continue;const a=o.get(f);a!=null&&(l[a]=i[c]??null)}s.push(l)}return[{x:n,series:s}]}function qs(t){const e=(t==null?void 0:t.decimals)??1;return n=>n.map(o=>{const s=Math.abs(o);return s>=1e9?(o/1e9).toFixed(e)+"B":s>=1e6?(o/1e6).toFixed(e)+"M":s>=1e3?(o/1e3).toFixed(e)+"K":o.toFixed(s>=1?0:e)})}function Zs(t,e=0){return n=>n.map(o=>o.toFixed(e)+t)}function Js(t,e=0){return n=>n.map(o=>t+o.toFixed(e))}function Qs(t,e,n=0){return o=>o.map(s=>t+s.toFixed(n)+e)}function ti(t){const e=(t==null?void 0:t.utc)??!1;return n=>n.map(o=>e?nt(o,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC"):nt(o,{hour:"2-digit",minute:"2-digit",hour12:!1}))}function ei(t){const e=t!=null&&t.utc?"UTC":void 0,n=(t==null?void 0:t.format)??"short";return o=>o.map(s=>nt(s,{month:n},e))}function ni(t){const{tz:e,...n}=t??{};return o=>o.map(s=>nt(s,n,e))}function oi(t,e=0){return n=>n.map(o=>{const s=Math.round(o)-e;return t[s]??String(o)})}exports.AnnotationLabel=zs;exports.Axis=Pt;exports.Band=is;exports.BoxWhisker=Ts;exports.Candlestick=Os;exports.Chart=re;exports.DEFAULT_ACTIONS=Ft;exports.Direction=O;exports.Distribution=K;exports.FloatingLegend=Cs;exports.HLine=_s;exports.Heatmap=As;exports.HoverLabel=ks;exports.Legend=fs;exports.Orientation=H;exports.Region=Fs;exports.Scale=es;exports.Series=ce;exports.Side=Y;exports.SortOrder=xt;exports.Sparkline=ys;exports.Timeline=Ms;exports.Tooltip=ws;exports.VLine=Rs;exports.Vector=Ps;exports.ZoomRanger=Ss;exports.alignData=Us;exports.bars=ge;exports.catmullRom=js;exports.drawHLine=an;exports.drawLabel=Es;exports.drawRegion=fn;exports.drawVLine=un;exports.fadeGradient=ns;exports.fmtCompact=qs;exports.fmtDateStr=ni;exports.fmtHourMin=ti;exports.fmtLabels=oi;exports.fmtMonthName=ei;exports.fmtPrefix=Js;exports.fmtSuffix=Zs;exports.fmtWrap=Qs;exports.focus=dn;exports.groupedBars=Ws;exports.linear=Je;exports.monotoneCubic=Bs;exports.palette=os;exports.points=Ns;exports.posToVal=lt;exports.sideOrientation=vt;exports.stackGroup=Ks;exports.stackedBars=$s;exports.stepped=Gs;exports.useChart=J;exports.useCursorDrawHook=xs;exports.useDrawHook=dt;exports.useStreamingData=Hs;exports.valToPos=X;exports.withAlpha=rn;
|