uplot-plus 0.5.10 → 0.5.14

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.
Files changed (36) hide show
  1. package/dist/components/Chart.d.ts.map +1 -1
  2. package/dist/components/FloatingLegend.d.ts +1 -0
  3. package/dist/components/FloatingLegend.d.ts.map +1 -1
  4. package/dist/components/HoverLabel.d.ts.map +1 -1
  5. package/dist/components/Legend.d.ts.map +1 -1
  6. package/dist/components/Tooltip.d.ts +6 -3
  7. package/dist/components/Tooltip.d.ts.map +1 -1
  8. package/dist/components/ZoomRanger.d.ts +23 -0
  9. package/dist/components/ZoomRanger.d.ts.map +1 -1
  10. package/dist/components/overlay/SeriesPanel.d.ts +9 -0
  11. package/dist/components/overlay/SeriesPanel.d.ts.map +1 -1
  12. package/dist/hooks/useChartStore.d.ts +2 -0
  13. package/dist/hooks/useChartStore.d.ts.map +1 -1
  14. package/dist/hooks/useDraggableOverlay.d.ts +89 -0
  15. package/dist/hooks/useDraggableOverlay.d.ts.map +1 -0
  16. package/dist/index.cjs +1 -1
  17. package/dist/index.js +2200 -2015
  18. package/dist/rendering/drawAxes.d.ts +2 -1
  19. package/dist/rendering/drawAxes.d.ts.map +1 -1
  20. package/dist/rendering/drawCursor.d.ts +2 -1
  21. package/dist/rendering/drawCursor.d.ts.map +1 -1
  22. package/dist/rendering/drawSelect.d.ts +2 -1
  23. package/dist/rendering/drawSelect.d.ts.map +1 -1
  24. package/dist/rendering/theme.d.ts +13 -0
  25. package/dist/rendering/theme.d.ts.map +1 -0
  26. package/dist/types/index.d.ts +1 -0
  27. package/dist/types/index.d.ts.map +1 -1
  28. package/dist/types/series.d.ts +5 -0
  29. package/dist/types/series.d.ts.map +1 -1
  30. package/dist/types/tooltip.d.ts +9 -0
  31. package/dist/types/tooltip.d.ts.map +1 -1
  32. package/dist/utils/estimatePanelSize.d.ts +12 -0
  33. package/dist/utils/estimatePanelSize.d.ts.map +1 -0
  34. package/dist/utils/textMeasure.d.ts +2 -0
  35. package/dist/utils/textMeasure.d.ts.map +1 -0
  36. package/package.json +13 -4
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var yn=Object.defineProperty;var Mn=(t,e,n)=>e in t?yn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Y=(t,e,n)=>Mn(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("react/jsx-runtime"),R=require("react");function Cn(t=.15){return e=>{e.focusAlpha=t}}const Bt=[["leftDrag","zoomX"],["leftDblclick","reset"],["wheel","zoomX"],["xGutterDrag","panX"],["yGutterDrag","panY"],["pinch","zoomX"],["touchDrag","zoomX"]];var j=(t=>(t[t.Top=0]="Top",t[t.Right=1]="Right",t[t.Bottom=2]="Bottom",t[t.Left=3]="Left",t))(j||{}),$=(t=>(t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical",t))($||{}),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||{}),At=(t=>(t[t.Ascending=1]="Ascending",t[t.Descending=-1]="Descending",t[t.Unsorted=0]="Unsorted",t))(At||{});function Mt(t){return t%2}var st=(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))(st||{});const et=Math,Kt=et.PI,it=et.abs,at=et.floor,B=et.round,Dt=et.ceil,ie=et.min,Lt=et.max,bt=et.pow,Ce=et.sign,rt=et.log10,Pt=et.log2,kn=(t,e=1)=>et.sinh(t)*e,le=(t,e=1)=>et.asinh(t/e),J=1/0,Oe=Number.isInteger;function qt(t,e){return t[e]??0}function mt(t,e,n=0,o=e.length-1){let s;const r=o<=2147483647;for(;o-n>1;)s=r?n+o>>1:at((n+o)/2),qt(e,s)<t?n=s:o=s;return t-qt(e,n)<=qt(e,o)-t?n:o}const Ke=t=>t!=null,qe=t=>t!=null&&t>0;function Ze(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 Xt=Ze(Ke),Je=Ze(qe);function Tn(t,e,n,o=At.Unsorted,s=!1){const r=s?Je:Xt,i=s?qe:Ke,[l,a]=r(t,e,n);let f=t[l]??J,c=t[l]??-J;if(l>-1)if(o===At.Ascending)f=t[l]??J,c=t[a]??-J;else if(o===At.Descending)f=t[a]??J,c=t[l]??-J;else for(let d=l;d<=a;d++){const u=t[d];u!=null&&i(u)&&(u<f?f=u:u>c&&(c=u))}return[f,c]}function ct(t,e=0){if(Oe(t))return t;const n=10**e,o=t*n*(1+Number.EPSILON);return B(o)/n}const It=new Map;function An(t){return(String(t).split(".")[1]??"").length}const Ln=/\.\d*?(?=9{6,}|0{6,})/gm;function yt(t){if(Oe(t)||It.has(t))return t;const e=`${t}`,n=e.match(Ln);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+`${yt(+r)}e${i}`}return ct(t,o)}function In(t,e,n=!0){return n?yt(ct(yt(t/e))*e):ct(t/e)*e}function ae(t,e,n=!0){return n?yt(Dt(yt(t/e))*e):Dt(t/e)*e}function Qe(t,e,n=!0){return n?yt(at(yt(t/e))*e):at(t/e)*e}function Pn(t){return t===0?e=>e:t===1?B:e=>In(e,t)}function tn(t,e,n,o){const s=[],r=o.map(An);for(let i=e;i<n;i++){const l=it(i);for(let a=0;a<o.length;a++){const f=o[a]??0,c=r[a]??0,d=+`${f}e${i}`,u=(i>=0?0:l)+(i>=c?0:c),h=d;s.push(h),It.set(h,u)}}return s}function Q(t,e,n){return ie(Lt(t,e),n)}const En=new Intl.NumberFormat,en=t=>En.format(t);function ke(t,e,n){for(;e<=n;){if(t[e]!=null)return!0;e++}return!1}const _n=.1,dt={mode:3,pad:_n,soft:null},_t={pad:0,soft:null,mode:0},Dn={min:_t,max:_t};function Zt(t,e,n,o){let s;typeof n=="number"?(_t.pad=n,_t.soft=null,_t.mode=0,s=Dn):s=n;const r=s.min,i=s.max,l=r.pad,a=i.pad,f=r.hard??-J,c=i.hard??J,d=r.soft??J,u=i.soft??-J,h=r.mode,g=i.mode;let w=e-t;const v=rt(w),b=Lt(it(t),it(e)),x=rt(b),p=it(x-v);(w<1e-24||p>10)&&(w=0,(t===0||e===0)&&(w=1e-24));const m=w||b||1e3,T=rt(m),A=bt(10,at(T)),y=m*(w===0?t===0?.1:1:l),M=ct(Qe(t-y,A/10),24),I=h===1||h===3&&M<=d||h===2&&M>=d,P=t>=d&&I?d:J,F=Lt(f,M<P&&t>=P?P:ie(P,M)),L=m*(w===0?e===0?.1:1:a),C=ct(ae(e+L,A/10),24),D=g===1||g===3&&C>=u||g===2&&C<=u,z=e<=u&&D?u:-J,S=ie(c,C>z&&e<=z?z:Lt(z,C));return F===S&&F===0?[-1,1]:[F,S]}function nn(t,e,n,o){n===2&&(o=!0);const s=Ce(t),r=Ce(e);t===e&&(s===-1?(t*=n,e/=n):(t/=n,e*=n));const i=n===10?rt:Pt,l=s===1?at:Dt,a=r===1?Dt:at,f=i(it(t)),c=i(it(e)),d=l(f),u=a(c);let h=bt(n,d),g=bt(n,u);return n===10&&(d<0&&(h=ct(h,-d)),u<0&&(g=ct(g,-u))),o?(t=h*s,e=g*r):(t=Qe(t,bt(n,at(f)),!1),e=ae(e,bt(n,at(c)),!1)),[t,e]}function Fn(t,e,n,o){const s=nn(t,e,n,o);return t===0&&(s[0]=0),e===0&&(s[1]=0),s}function Te(t){return(rt((t^t>>31)-(t>>31))|0)+1}function Rn(t,e,n,o,s){const r=Lt(Te(t),Te(e)),i=e-t;let l=Lt(0,mt(s/o*i,n)-1);do{const a=n[l]??0,f=o*a/i;if(f>=s*.9&&r+(a<5?It.get(a)??0:0)<=17)return[a,f]}while(++l<n.length);return[0,0]}function Hn(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"?$.Horizontal:$.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 U(t){return t.min!=null&&t.max!=null}function ut(t){t._min=null,t._max=null}function on(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?rt:Pt)(o)}else n===K.Asinh?t._min=le(e,t.asinh):t._min=e;return t._min}function sn(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?rt:Pt)(o)}else n===K.Asinh?t._max=le(e,t.asinh):t._max=e;return t._max}function zn(t,e){if(e.min==null||e.max==null)return 0;const n=on(e),s=sn(e)-n;if(s===0)return 0;const{distr:r}=e;if(r===K.Log){const i=e.log===10?rt:Pt,l=t>0?t:1e-10;return(i(l)-n)/s}return r===K.Asinh?(le(t,e.asinh)-n)/s:(t-n)/s}function Wn(t,e){if(e.min==null||e.max==null)return 0;const n=on(e),o=sn(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?kn(n+t*(o-n),e.asinh):n+t*(o-n)}function X(t,e,n,o){const s=zn(t,e);let r;return e.ori===$.Horizontal?r=e.dir===O.Forward?s:1-s:r=e.dir===O.Forward?1-s:s,o+r*n}function ft(t,e,n,o){if(n===0)return e.min??0;let s=(t-o)/n;return e.ori===$.Horizontal?e.dir===O.Backward&&(s=1-s):e.dir!==O.Backward&&(s=1-s),Wn(s,e)}class $n{constructor(){Y(this,"scales",new Map);Y(this,"groupXScales",new Map)}addScale(e){this.scales.set(e.id,Hn(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,ut(s))}autoRangeX(e){var o,s,r,i,l,a;const n=new Map;for(const[f,c]of this.groupXScales){const d=this.scales.get(c);if(!d||!d.auto)continue;const u=e[f];if(!u||u.x.length===0)continue;const h=u.x[0],g=u.x[u.x.length-1];if(h==null||g==null)continue;const w=n.get(c);w?(w.dataMin=Math.min(w.dataMin,h),w.dataMax=Math.max(w.dataMax,g),w.groups.push(f)):n.set(c,{dataMin:h,dataMax:g,groups:[f]})}for(const[f,{dataMin:c,dataMax:d,groups:u}]of n){const h=this.scales.get(f);if(!h)continue;let g=!0,w=J;for(const v of u){const b=e[v];if(b){for(let x=0;x<b.x.length;x++)if(Number.isInteger(b.x[x])||(g=!1),x>0){const p=b.x[x]-b.x[x-1];p>0&&p<w&&(w=p)}}}if(h._discrete=g,h.range){const[v,b]=Zt(c,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:((a=h.range.max)==null?void 0:a.mode)??0}});h.min=v,h.max=b}else if(c===d)[h.min,h.max]=Zt(c,d,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}});else if(w<J){const v=w/2;h.min=c-v,h.max=d+v}else h.min=c,h.max=d;h._cfgMin!=null&&(h.min=h._cfgMin),h._cfgMax!=null&&(h.max=h._cfgMax),ut(h)}}autoRange(e,n,o){var i,l,a,f,c,d;const s=new Map,r=new Map;for(const{group:u,index:h,yScale:g}of n){const w=e[u];if(!w)continue;const v=w.series[h];if(!v||v.length===0)continue;const b=o.windows.get(u),x=b?b[0]:0,p=b?b[1]:v.length-1,m=this.scales.get(g),T=(m==null?void 0:m.distr)===K.Log,[A,y]=o.getCachedMinMax(u,h,x,p,0,T),M=s.get(g),I=r.get(g);s.set(g,M!=null?Math.min(M,A):A),r.set(g,I!=null?Math.max(I,y):y)}for(const[u,h]of s){const g=this.scales.get(u);if(!g||!g.auto)continue;const w=r.get(u)??-J;if(h===J)continue;let v,b;if(g.distr===K.Log)[v,b]=nn(h,w,g.log,!1);else if(g.distr===K.Asinh)[v,b]=Fn(h,w,g.log,!1);else{const x=g.range??{min:dt,max:dt};[v,b]=Zt(h,w,{min:{pad:((i=x.min)==null?void 0:i.pad)??dt.pad,soft:((l=x.min)==null?void 0:l.soft)??dt.soft,mode:((a=x.min)==null?void 0:a.mode)??dt.mode},max:{pad:((f=x.max)==null?void 0:f.pad)??dt.pad,soft:((c=x.max)==null?void 0:c.soft)??dt.soft,mode:((d=x.max)==null?void 0:d.mode)??dt.mode}})}g._cfgMin!=null&&(v=g._cfgMin),g._cfgMax!=null&&(b=g._cfgMax),g.min=v,g.max=b,ut(g)}}}const Gn=1024;class Bn{constructor(e,n=Gn){Y(this,"blocks");Y(this,"nBlocks");Y(this,"blockSize");Y(this,"data");Y(this,"len");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,a=Math.min(l+n,r);let f=1/0,c=-1/0;for(let d=l;d<a;d++){const u=e[d];u!=null&&(u<f&&(f=u),u>c&&(c=u))}s[i*2]=f,s[i*2+1]=c}}rangeMinMax(e,n){const{data:o,blockSize:s,blocks:r}=this;let i=1/0,l=-1/0;const a=Math.floor(e/s),f=Math.floor(n/s);if(a===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 c=(a+1)*s-1;for(let u=e;u<=c;u++){const h=o[u];h!=null&&(h<i&&(i=h),h>l&&(l=h))}for(let u=a+1;u<f;u++){const h=r[u*2]??1/0,g=r[u*2+1]??-1/0;h<i&&(i=h),g>l&&(l=g)}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 a=1/0,f=-1/0;for(let c=i;c<l;c++){const d=n[c];d!=null&&(d<a&&(a=d),d>f&&(f=d))}s[e*2]=a,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 Vn{constructor(){Y(this,"data",[]);Y(this,"windows",new Map);Y(this,"minMaxCache",new Map);Y(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 Bn(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 a,f;if(!r||!i||!U(i))a=0,f=Math.max(0,((r==null?void 0:r.x.length)??1)-1);else{const c=r.x;if(c.length===0)a=0,f=0;else{a=mt(i.min,c),f=mt(i.max,c);const d=c[a],u=c[f];a>0&&d!=null&&d>i.min&&a--,f<c.length-1&&u!=null&&u<i.max&&f++}}(!l||l[0]!==a||l[1]!==f)&&(n=!0,(o=this.minMaxCache.get(s))==null||o.clear()),this.windows.set(s,[a,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 a=`${n}:${o}:${s}`;if(l){const h=l.get(a);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 c=f.series[n];if(!c||c.length===0)return[1/0,-1/0];let d;const u=!i&&r===At.Unsorted?this.getOrBuildTree(e,n):void 0;return u?d=u.rangeMinMax(o,s):d=Tn(c,o,s,r,i),l.set(a,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 a=n[l];a!=null&&r.push(a)}for(let l=0;l<s.series.length;l++){let a=s.series[l];if(!a)continue;Array.isArray(a)||(a=Array.from(a),s.series[l]=a);const f=o[l];if(f){const d=a;for(let u=0;u<f.length;u++)d.push(f[u]??null)}const c=this.blockTrees.get(`${e}:${l}`);c&&(c.setData(a),c.grow(a.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 Ht=-10;class Xn{constructor(){Y(this,"state",{left:Ht,top:Ht,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1});Y(this,"_groupedConfigs",new Map);Y(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=Ht,this.state.top=Ht,this.state.activeGroup=-1,this.state.activeSeriesIdx=-1,this.state.activeDataIdx=-1}update(e,n,o,s,r,i,l,a){this.state.left=e,this.state.top=n;let f=1/0,c=-1,d=-1,u=-1;const h=this.getGroupedConfigs(r);for(let g=0;g<s.length;g++){const w=s[g];if(w==null)continue;const v=w.x;if(v.length===0)continue;const b=a(g);if(b==null)continue;const x=i(b);if(x==null||!U(x))continue;const[p,m]=l(g),T=o.width,A=o.left,y=ft(e+A,x,T,A),M=mt(y,v,p,m),I=[M];M>p&&I.push(M-1),M<m&&I.push(M+1);const P=new Map;for(const F of I){const L=v[F];if(L==null)continue;const C=X(L,x,T,A);for(const D of h.get(g)??[]){const z=w.series[D.index];if(z==null)continue;const S=z[F];if(S==null)continue;let k=P.get(D.yScale);if(k==null&&!P.has(D.yScale)&&(k=i(D.yScale),P.set(D.yScale,k)),k==null||!U(k))continue;const E=o.height,_=o.top,W=X(S,k,E,_),H=e+A-C,V=n+_-W,N=H*H+V*V;if(N<f&&(f=N,c=g,d=D.index,u=F,N===0))break}if(f===0)break}}this.state.activeGroup=c,this.state.activeSeriesIdx=d,this.state.activeDataIdx=u}syncToValue(e,n,o=0){const s=n.dataStore.data;if(s.length===0)return;const r=o<s.length?o:0,i=s[r];if(i==null)return;const l=n.scaleManager.getGroupXScaleKey(r);if(l==null)return;const a=n.scaleManager.getScale(l);if(a==null||!U(a))return;const[f,c]=n.dataStore.getWindow(r),d=mt(e,i.x,f,c),u=i.x[d];if(u==null)return;const h=X(u,a,n.plotBox.width,n.plotBox.left);this.state.left=h-n.plotBox.left,this.state.activeGroup=r,this.state.activeDataIdx=d;let g=0,w=n.plotBox.height/2;for(const v of n.seriesConfigs){if(v.group!==r||v.show===!1)continue;const b=i.series[v.index];if(b==null)continue;const x=b[d];if(x==null)continue;const p=n.scaleManager.getScale(v.yScale);if(!(p==null||!U(p))){w=X(x,p,n.plotBox.height,n.plotBox.top)-n.plotBox.top,g=v.index;break}}this.state.top=w,this.state.activeSeriesIdx=g}}class Yn{constructor(){Y(this,"flags",st.None);Y(this,"frameId",null);Y(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=st.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=st.None}}const Yt={width:1},jn={width:0,fill:"auto",fillTo:0,points:{show:!1},cursor:{show:!1}},Nn={width:0,cursor:{show:!1}};function jt(t,e,n){t.lineTo(e,n)}function Nt(t,e,n){t.lineTo(n,e)}function ce(t,e,n,o,s,r){const i=[];let l=-1;const a=s===O.Forward?n:o,f=s===O.Forward?o:n,c=s;for(let d=a;s===O.Forward?d<=f:d>=f;d+=c)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 ue(t,e,n,o,s,r){const i=new Path2D;let l=e===$.Horizontal?n:o;const a=e===$.Horizontal?n+s:o+r,f=e===$.Horizontal?o:n,c=e===$.Horizontal?r:s;for(const[d,u]of t)d>l&&(e===$.Horizontal?i.rect(l,f,d-l,c):i.rect(f,l,c,d-l)),l=u;return l<a&&(e===$.Horizontal?i.rect(l,f,a-l,c):i.rect(f,l,c,a-l)),i}function rn(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 Un=rn(jt),On=rn(Nt);function ln(){const t=(e,n,o,s,r,i,l,a,f,c,d,u,h)=>{const g=(h==null?void 0:h.spanGaps)??!1;if([f,c]=(s.distr===K.Log?Je:Xt)(n,f,c),f===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const v=M=>u(X(M,o,r,l)),b=M=>u(X(M,s,i,a));let x,p;o.ori===$.Horizontal?(x=jt,p=Un):(x=Nt,p=On);const m={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},T=m.stroke;let A=!1;if(c-f>=r*4){const M=k=>ft(k,o,r,l);let I=null,P=0,F=0,L=0,C=v(e[d===O.Forward?f:c]);const D=v(e[f]),z=v(e[c]);let S=M(d===O.Forward?D+1:z-1);for(let k=d===O.Forward?f:c;k>=f&&k<=c;k+=d){const E=e[k],W=(d===O.Forward?E<S:E>S)?C:v(E),H=n[k];W===C?H!=null?(L=H,I==null?(x(T,W,b(L)),F=I=P=L):L<I?I=L:L>P&&(P=L)):H===null&&!g&&(A=!0):(I!=null&&p(T,C,b(I),b(P),b(F),b(L)),H!=null?(L=H,x(T,W,b(L)),I=P=F=L):(I=null,P=0,H===null&&!g&&(A=!0)),C=W,S=M(C+d))}I!=null&&(I!==P?p(T,C,b(I),b(P),b(F),b(L)):x(T,C,b(L)))}else for(let M=d===O.Forward?f:c;M>=f&&M<=c;M+=d){const I=n[M];I===null&&!g?A=!0:I!=null&&x(T,v(e[M]),b(I))}{const M=m.fill=new Path2D(T),I=(h==null?void 0:h.fillTo)??s.min??0,P=b(I);let F=v(e[f]),L=v(e[c]);d===O.Backward&&([L,F]=[F,L]),x(M,L,P),x(M,F,P)}if(A){const M=ce(e,n,f,c,d,v);m.gaps=M,m.clip=ue(M,o.ori,l,a,r,i)}return m};return t.defaults=Yt,t}function fe(t,e,n){const o=t.length;if(n=Math.max(2,Math.round(n)),o<=n){const u=new Uint32Array(o),h=new Float64Array(o),g=new Array(o);for(let w=0;w<o;w++)u[w]=w,h[w]=t[w],g[w]=e[w]??null;return{indices:u,x:h,y:g}}const s=[];let r=-1,i=0;for(let u=0;u<o;u++)e[u]!=null?(r===-1&&(r=u),i++):r!==-1&&(s.push([r,u-1]),r=-1);if(r!==-1&&s.push([r,o-1]),i===0)return{indices:new Uint32Array(0),x:new Float64Array(0),y:[]};if(i<=n){const u=new Uint32Array(i),h=new Float64Array(i),g=new Array(i);let w=0;for(let v=0;v<o;v++)e[v]!=null&&(u[w]=v,h[w]=t[v],g[w]=e[v],w++);return{indices:u,x:h,y:g}}const l=[];for(const[u,h]of s){const g=h-u+1,w=Math.max(2,Math.round(n*(g/i))),v=Kn(t,e,u,h,w);for(const b of v)l.push(b)}const a=l.length,f=new Uint32Array(a),c=new Float64Array(a),d=new Array(a);for(let u=0;u<a;u++){const h=l[u];f[u]=h,c[u]=t[h],d[u]=e[h]}return{indices:f,x:c,y:d}}function Kn(t,e,n,o,s){const r=o-n+1;if(r<=s){const c=[];for(let d=n;d<=o;d++)c.push(d);return c}const i=[];i.push(n);const l=s-2,a=(r-2)/l;let f=n;for(let c=0;c<l;c++){const d=n+1+Math.floor(c*a),u=Math.min(n+1+Math.floor((c+1)*a)-1,o-1);let h=0,g=0,w=0;if(c<l-1){const m=n+1+Math.floor((c+1)*a),T=Math.min(n+1+Math.floor((c+2)*a)-1,o-1);for(let A=m;A<=T;A++)h+=t[A],g+=e[A],w++}else h=t[o],g=e[o],w=1;w>0&&(h/=w,g/=w);const v=t[f],b=e[f];let x=d,p=-1;for(let m=d;m<=u;m++){const T=t[m],A=e[m],y=Math.abs(v*(A-g)+T*(g-b)+h*(b-A));y>p&&(p=y,x=m)}i.push(x),f=x}return i.push(o),i}function qn(t,e){const n=t.x.length;if(e=Math.max(2,Math.round(e)),n<=e)return t;const o=new Set;for(const a of t.series){const f=fe(t.x,a,e);for(let c=0;c<f.indices.length;c++)o.add(f.indices[c])}const s=Array.from(o).sort((a,f)=>a-f),r=s.length,i=new Float64Array(r);for(let a=0;a<r;a++)i[a]=t.x[s[a]];const l=[];for(const a of t.series)if(Array.isArray(a)&&a.some(c=>c===null)){const c=new Array(r);for(let d=0;d<r;d++)c[d]=a[s[d]]??null;l.push(c)}else{const c=new Float64Array(r);for(let d=0;d<r;d++)c[d]=a[s[d]];l.push(c)}return{x:i,series:l}}function Zn(t){const n=ln(),o=(s,r,i,l,a,f,c,d,u,h,g,w,v)=>{const b=h-u+1,x=Math.round(a*1);if(b>x*2){const p=h-u+1,m=new Float64Array(p),T=new Array(p);for(let y=0;y<p;y++)m[y]=s[u+y],T[y]=r[u+y]??null;const A=fe(m,T,x);return n(A.x,A.y,i,l,a,f,c,d,0,A.x.length-1,g,w,v)}return n(s,r,i,l,a,f,c,d,u,h,g,w,v)};return o.defaults=Yt,o}const Ae=new WeakMap;function Le(t,e,n){return typeof e=="string"?e:Jn(t,e,n)}function Jn(t,e,n){const o=Ae.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 Ae.set(e,{grad:s,left:n.left,top:n.top,width:n.width,height:n.height}),s}function Qn(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=Le(t,e.fill,i),t.fill(n.fill)),e.stroke){const l=(e.width??1)*o;t.strokeStyle=Le(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 a=e.pxAlign??0,f=l%2/2;a===1&&f>0&&t.translate(f,f),t.stroke(n.stroke)}t.restore()}const to=Zn(),Ie=64;class eo{constructor(){Y(this,"ctx",null);Y(this,"pxRatio",1);Y(this,"pathCache",new Map);Y(this,"bandCache",new Map);Y(this,"scaleStamp","");Y(this,"snapshotCanvas",null);Y(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[a,f]of this.pathCache){if(!a.startsWith(l))continue;const c=a.slice(l.length),d=c.indexOf(":"),u=+c.slice(0,d),h=+c.slice(d+1);if(u<=o&&h>=s)return this.promote(a,f),f}}setCachedPaths(e,n,o,s,r){if(this.pathCache.size>=Ie){const l=Ie>>2,a=this.pathCache.keys();for(let f=0;f<l;f++){const c=a.next().value;c!=null&&this.pathCache.delete(c)}}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,a]=e.window;let f=this.getCachedPaths(r,i,l,a);if(f==null){const c=e.config.paths??to,d=e.xScale.dir,u=Pn(e.config.pxAlign??0),h=a-l,g=Math.max(1,Math.ceil(h*.1)),w=e.dataX.length,v=Math.max(0,l-g),b=Math.min(w-1,a+g),x=e.config.fillTo;let p;typeof x=="function"?p=x(e.yScale.min??0,e.yScale.max??0):x===0&&e.yScale.distr===K.Log?p=1:p=x,f=c(e.dataX,e.dataY,e.xScale,e.yScale,n.width,n.height,n.left,n.top,v,b,d,u,{fillTo:p,spanGaps:e.config.spanGaps}),this.setCachedPaths(r,i,v,b,f)}Qn(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 an=[1,2,2.5,5],no=tn(10,-32,0,an),oo=tn(10,0,32,an),St=no.concat(oo);function so(t,e,n,o,s){if(n<=0||e<t)return[];const r=[],i=It.get(n)??0,l=s?Math.ceil(t/n)*n:ct(ae(t,n),i);for(let a=l;a<=e;a=ct(a+n,i))r.push(Object.is(a,-0)?0:a);return r}function Jt(t){return t.map(e=>en(e))}function io(t,e,n){if(t<=0||e<=0||t>=e)return[];const o=[],r=at((n===10?rt:Pt)(t));let i=bt(n,r);n===10&&(i=St[mt(i,St)]??i);let l=i,a=i*n;n===10&&(a=St[mt(a,St)]??a);let f=0;do{if(l>=t&&o.push(l),l=l+i,n===10&&!It.has(l)){const c=It.get(i)??0;l=ct(l,c)}l>=a*(1-1e-10)&&(i=l,a=i*n,n===10&&(a=St[mt(a,St)]??a))}while(l<=e&&++f<1e4);return o}function ro(t,e,n=1){const o=[];if(Math.max(it(t),it(e))===0)return[0];if(t<0){const i=it(t);let l=bt(10,at(rt(Math.max(i,n))));for(;l>=n;){const a=-l;a>=t&&a<=e&&o.push(a),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&&it(i-l)>1e-10)&&r.push(i)}return r}function lo(t,e){const n=e===10?rt:Pt;return t.map(o=>{if(o===0)return!0;if(o<0)return!1;const s=n(o);return it(s-Math.round(s))<1e-10})}const ao=7,co=50,uo=16;function fo(t,e){const o=en(Math.max(Math.abs(t),Math.abs(e))).length*ao;return Math.max(co,o+uo)}function ho(t,e,n,o){if(o<=0)return[0,0];const s=Mt(t.side)===$.Vertical,r=t.space??(s?30:fo(e,n)),i=t.incrs??St;return Rn(e,n,i,o,r)}const go=50;function po(t,e,n){var l,a;if(t.size!=null)return t.size;const o=((l=t.ticks)==null?void 0:l.show)!==!1?((a=t.ticks)==null?void 0:a.size)??10:0,s=t.gap??5,r=12;if(Mt(t.side)===$.Vertical&&e!=null){let f=0;for(const d of e)d.length>f&&(f=d.length);const c=f*7;return Math.max(50,o+s+c+4)}return Math.max(50,o+s+r+3)}function mo(t){return{config:t,_show:t.show!==!1,_size:t.size??go,_pos:0,_lpos:0,_splits:null,_values:null,_incr:0,_space:0,_rotate:0}}const wo=1,Tt=60,vt=3600,pt=86400,So=604800,xt=2592e3,Ft=31536e3,vo=[wo,5,10,15,30,Tt,5*Tt,10*Tt,15*Tt,30*Tt,vt,2*vt,3*vt,4*vt,6*vt,12*vt,pt,2*pt,3*pt,7*pt,14*pt,xt,2*xt,3*xt,6*xt,Ft];function bo(t,e,n){const o=[];if(n<=0||t>=e)return o;let s;if(n>=Ft){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/Ft)),s=r.getTime()/1e3;return o}if(n>=xt){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/xt));if(s<t&&(r.setUTCMonth(r.getUTCMonth()+1),s=r.getTime()/1e3),i>1){const l=r.getUTCMonth(),a=Math.ceil((l+1)/i)*i;r.setUTCMonth(a-1),s=r.getTime()/1e3}for(;s<=e;)o.push(s),r.setUTCMonth(r.getUTCMonth()+i),s=r.getTime()/1e3;return o}if(n>=pt){const r=new Date(t*1e3);r.setUTCHours(0,0,0,0),s=r.getTime()/1e3,s<t&&(s+=pt)}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 Pe=new Map;function xo(t,e){const n=JSON.stringify(t)+(e??"");let o=Pe.get(n);return o==null&&(o=new Intl.DateTimeFormat(void 0,{...t,timeZone:e}),Pe.set(n,o)),o}function lt(t,e,n){const o=new Date(t*1e3);return xo(e,n).format(o)}function yo(t,e){return lt(t,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},e)}function Mo(t,e){return lt(t,{year:"numeric",month:"2-digit",day:"2-digit"},e)}function Co(t,e){return lt(t,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},e)}function ko(t,e){return lt(t,{hour:"2-digit",minute:"2-digit",hour12:!1},e)}function To(t,e){return lt(t,{month:"short",day:"numeric"},e)}function Ao(t,e){return lt(t,{year:"numeric"},e)}function Lo(t,e){return lt(t,{year:"numeric",month:"short"},e)}function Io(t,e,n){let o;return e>=Ft?o=Ao:e>=xt?o=Lo:e>=So?o=Mo:e>=pt?o=To:e>=vt?o=ko:e>=Tt?o=Co:o=yo,t.map(s=>o(s,n))}function Po(t,e,n,o,s){const r=e-t;if(r<=0||o<=0)return[0,0];for(const l of n){const a=r/l,f=o/a;if(f>=s)return[l,f]}const i=n[n.length-1]??Ft;return[i,o/(r/i)]}const Eo=3;function _o(t,e,n,o,s){let r=!0;for(const i of t){const l=i.config;if(l.show===!1)continue;const a=e(l.scale);if(!a||!U(a)){i._show&&(r=!1,i._show=!1);continue}else i._show||(r=!1,i._show=!0);const f=l.side,d=Mt(f)===$.Horizontal?n:o,u=a.min,h=a.max;let g,w;if(a.time){const b=l.space??80;[g,w]=Po(u,h,vo,d,b)}else[g,w]=ho(l,u,h,d);if(a._discrete&&g>0&&g<1&&(g=1),i._incr=g,i._space=w,w===0)continue;if(l.splits)i._splits=l.splits(u,h,g,w);else if(a.time)i._splits=bo(u,h,g);else if(a.distr===K.Log)i._splits=io(u,h,a.log);else if(a.distr===K.Asinh)i._splits=ro(u,h,a.asinh);else{const b=a.distr===K.Ordinal||a._discrete;i._splits=so(u,h,g,w,b)}if(l.values)i._values=l.values(i._splits,w,g);else if(a.time)i._values=Io(i._splits,g);else if(a.distr===K.Log){const b=lo(i._splits,a.log),x=Jt(i._splits);i._values=x.map((p,m)=>b[m]?p:"")}else a.distr,K.Asinh,i._values=Jt(i._splits);i._rotate=f===j.Bottom?l.rotate??0:0;const v=i._size;i._size=Dt(po(l,i._values)),v!==i._size&&(r=!1)}return r}function Ee(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 c=f.config.side,d=Mt(c)===$.Vertical,u=f.config.label!=null?f.config.labelSize??20:0,h=f._size+u;h>0&&(d?(s-=h,c===j.Left&&(i+=h)):(r-=h,c===j.Top&&(l+=h)))}return!n.some(f=>f._show&&f.config.side===j.Top)&&l<=o&&(l+=8,r-=8),{left:i,top:l,width:Math.max(s,0),height:Math.max(r,0)}}function Do(t,e){let n=e.top,o=e.left+e.width,s=e.top+e.height,r=e.left;function i(l,a){switch(l){case j.Top:return n-=a,n+a;case j.Right:{const f=o;return o+=a,f}case j.Bottom:{const f=s;return s+=a,f}case j.Left:return r-=a,r+a;default:return 0}}for(const l of t){if(!l._show)continue;const a=l.config.side;if(l._pos=i(a,l._size),l.config.label!=null){const f=l.config.labelSize??20;l._lpos=i(a,f)}}}function Fo(t,e,n,o,s=0){for(const a of n)a._size=0;let r=!1,i=0,l={left:0,top:0,width:t,height:e};for(;!r;){i++;const a=_o(n,o,l.width,l.height);r=i===Eo||a,r||(l=Ee(t,e,n,s))}return l=Ee(t,e,n,s),Do(n,l),l}const _e="top",De="bottom",Ro="left",Ho="right";function Qt(t,e){return e===1?t:t.replace(/(\d+(?:\.\d+)?)px/,(n,o)=>`${Math.round(Number(o)*e)}px`)}function Fe(t,e,n,o,s,r,i,l,a,f,c){const d=l%2/2;t.save(),t.translate(d,d),t.strokeStyle=a,t.lineWidth=l,f.length>0&&t.setLineDash(f),t.beginPath();let u=0,h=0,g=0,w=0;const v=r+(s===j.Top||s===j.Left?-i:i);o===$.Horizontal?(h=r,w=v):(u=r,g=v);for(let b=0;b<e.length;b++)n[b]!=null&&(o===$.Horizontal?u=g=e[b]??0:h=w=e[b]??0,t.moveTo(u,h),t.lineTo(g,w));t.stroke(),t.restore()}function zo(t,e,n,o,s,r){const i=B(o.left*s),l=B(o.top*s),a=B(o.width*s),f=B(o.height*s);for(const c of e){if(!c._show)continue;const d=c.config,u=d.side,h=Mt(u),g=n(d.scale);if(!g||!U(g))continue;const w=d.stroke??"#000",v=u===j.Top||u===j.Left?-1:1,b=c._splits,x=c._values;if(!b||!x||c._space===0)continue;const p=h===$.Horizontal?o.width:o.height,m=h===$.Horizontal?o.left:o.top,T=b.map(P=>B(X(P,g,p,m)*s)),A=x.map(P=>P===""?null:P),y=d.grid;if((y==null?void 0:y.show)!==!1){const P=(y==null?void 0:y.stroke)??"rgba(0,0,0,0.12)",F=B(((y==null?void 0:y.width)??2)*s),L=((y==null?void 0:y.dash)??[]).map(z=>z*s),C=h===$.Horizontal?l:i,D=h===$.Horizontal?f:a;Fe(t,T,A,h,2,C,D,F,P,L)}const M=d.ticks;if((M==null?void 0:M.show)!==!1){const P=(M==null?void 0:M.stroke)??w,F=B(((M==null?void 0:M.width)??1)*s),L=B(((M==null?void 0:M.size)??10)*s),C=((M==null?void 0:M.dash)??[]).map(z=>z*s),D=B(c._pos*s);Fe(t,T,A,h,u,D,L,F,P,C)}{const P=(M==null?void 0:M.show)!==!1?((M==null?void 0:M.size)??10)*s:0,F=B((d.gap??5)*s),L=B(c._pos*s),C=(P+F)*v,D=L+C,z=Qt(d.font??"12px system-ui, sans-serif",s),S=h===$.Horizontal?"center":u===j.Left?Ho:Ro,k=h===$.Horizontal?u===j.Bottom?_e:De:"middle";t.font=z,t.fillStyle=w,t.textAlign=S,t.textBaseline=k;const E=c._rotate*-Kt/180;if(E!==0){const _=Math.cos(E),W=Math.sin(E);for(let H=0;H<x.length;H++){const V=x[H];if(V==null||V==="")continue;const N=T[H]??0;t.setTransform(_,W,-W,_,N,D),t.fillText(V,0,0)}t.setTransform(1,0,0,1,0,0)}else for(let _=0;_<x.length;_++){const W=x[_];if(W==null||W==="")continue;const H=T[_]??0,V=h===$.Horizontal?H:D,N=h===$.Horizontal?D:H;t.fillText(W,V,N)}}if(d.label!=null){const P=Qt(d.labelFont??"bold 12px system-ui, sans-serif",s);t.font=P,t.fillStyle=w,t.textAlign="center",t.textBaseline=u===j.Bottom?_e:De;const F=B((c._lpos+(d.labelGap??0)*v)*s);h===$.Vertical?(t.save(),t.translate(F,B(l+f/2)),t.rotate((u===j.Left?-Kt:Kt)/2),t.fillText(d.label,0,0),t.restore()):t.fillText(d.label,B(i+a/2),F)}const I=d.border;if((I==null?void 0:I.show)!==!1&&I!=null){const P=I.stroke??w,F=B((I.width??1)*s),L=(I.dash??[]).map(D=>D*s),C=B(c._pos*s);t.strokeStyle=P,t.lineWidth=F,L.length>0&&t.setLineDash(L),t.beginPath(),h===$.Horizontal?(t.moveTo(i,C),t.lineTo(i+a,C)):(t.moveTo(C,l),t.lineTo(C,l+f)),t.stroke(),L.length>0&&t.setLineDash([])}}if(r!=null){const c=Qt("bold 14px system-ui, sans-serif",s);t.font=c,t.fillStyle="#000",t.textAlign="center",t.textBaseline="top",t.fillText(r,B(i+a/2),B(4*s))}}const Wo=2,$o="#fff",Go={stroke:"#607D8B",width:1,dash:[5,3],pointRadius:4,showX:!0,showY:!0};function Re(t,e,n,o,s,r,i,l,a,f){var m;if(e.left<0||e.top<0)return;const c={...Go,...a},d=o,u=B(n.left*d),h=B(n.top*d),g=B(n.width*d),w=B(n.height*d),v=B(c.width*d),b=v%2/2,x=B((n.left+e.left)*d)+b,p=B((n.top+e.top)*d)+b;if(t.save(),t.strokeStyle=c.stroke,t.lineWidth=v,t.setLineDash(c.dash.map(T=>T*d)),c.showX&&(t.beginPath(),t.moveTo(x,h),t.lineTo(x,h+w),t.stroke()),c.showY&&(t.beginPath(),t.moveTo(u,p),t.lineTo(u+g,p),t.stroke()),t.setLineDash([]),e.activeGroup>=0&&e.activeDataIdx>=0){const T=e.activeGroup,A=e.activeSeriesIdx,y=e.activeDataIdx,M=s[T];if(M!=null&&A>=0&&A<M.series.length&&y<M.x.length){const I=M.x[y],P=M.series[A],F=P!=null?P[y]:null;if(I!=null&&F!=null){let L=c.stroke,C=!0;const D=f==null?void 0:f.get(`${T}:${A}`);if(D!=null){const z=D.stroke;L=(typeof z=="string"?z:void 0)??c.stroke,C=((m=D.cursor)==null?void 0:m.show)!==!1}if(C){const z=l(T),S=z!=null?i(z):void 0,k=(D==null?void 0:D.yScale)??Bo(r,T,A),E=k!=null?i(k):void 0;if(S!=null&&E!=null&&U(S)&&U(E)){const _=B(X(I,S,n.width,n.left)*d),W=B(X(F,E,n.height,n.top)*d),H=c.pointRadius*d,V=B(Wo*d);t.beginPath(),t.arc(_,W,H,0,Math.PI*2),t.fillStyle=$o,t.fill(),t.strokeStyle=L,t.lineWidth=V,t.stroke()}}}}}t.restore()}function Bo(t,e,n){for(const o of t)if(o.group===e&&o.index===n)return o.yScale}const Vo={fill:"rgba(0,0,0,0.07)",stroke:"rgba(0,0,0,0.15)",width:1};function He(t,e,n,o,s){if(!e.show||e.width<=0)return;const r={...Vo,...s},i=o,l=B((n.left+e.left)*i),a=B((n.top+e.top)*i),f=B(e.width*i),c=B(e.height*i);t.save(),t.fillStyle=r.fill,t.fillRect(l,a,f,c),r.width>0&&(t.strokeStyle=r.stroke,t.lineWidth=B(r.width*i),t.strokeRect(l,a,f,c)),t.restore()}function Xo(t,e,n,o,s,r,i,l,a,f,c,d){const u=c/2*i,h=Math.max(1,B(c*.2))*i,g=(f==null?void 0:f.stroke)??d,w=(f==null?void 0:f.fill)??"#fff";t.save(),t.strokeStyle=g,t.fillStyle=w,t.lineWidth=h,(f==null?void 0:f.dash)!=null&&t.setLineDash(f.dash.map(v=>v*i));for(let v=l;v<=a;v++){const b=n[v];if(b==null)continue;const x=e[v];if(x==null)continue;const p=B(X(x,o,r.width,r.left)*i),m=B(X(b,s,r.height,r.top)*i);t.beginPath(),t.arc(p,m,u,0,Math.PI*2),t.fill(),t.stroke()}t.restore()}function Yo(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 jo(t,e,n,o,s,r,i,l,a){if(l>a||l<0||!ke(e,l,a)&&!ke(n,l,a))return null;const f=h=>X(h,o,r.width,r.left)*i,c=h=>X(h,s,r.height,r.top)*i,d=new Path2D;let u=!1;for(let h=l;h<=a;h++){const g=e[h],w=t[h];if(g==null||w==null)continue;const v=f(w),b=c(g);u?d.lineTo(v,b):(d.moveTo(v,b),u=!0)}if(!u)return null;for(let h=a;h>=l;h--){const g=n[h],w=t[h];g==null||w==null||d.lineTo(f(w),c(g))}return d.closePath(),d}function No(t,e,n){t.save(),t.fillStyle=e.fill??"rgba(0, 120, 255, 0.1)",t.fill(n),t.restore()}function Uo(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)}if(!t.axisConfigs.some(i=>i.scale==="x"))t.axisConfigs.push({scale:"x",side:j.Bottom,show:!0,label:t.xlabel??"X Axis",_default:!0});else{const i=t.axisConfigs.find(l=>l.scale==="x"&&l._default===!0);i!=null&&(i.label=t.xlabel??"X Axis")}const r=new Set(t.axisConfigs.map(i=>i.scale));for(const i of o)if(!r.has(i))t.axisConfigs.push({scale:i,side:j.Left,show:!0,label:t.ylabel??"Y Axis",_default:!0}),r.add(i);else{const l=t.axisConfigs.find(a=>a.scale===i&&a._default===!0);l!=null&&(l.label=t.ylabel??"Y Axis")}}function zt(t,e,n,o){return{ctx:t,plotBox:e,pxRatio:n,getScale:o,valToX:(i,l="x")=>{const a=o(l);return a==null||!U(a)?null:X(i,a,e.width,e.left)},valToY:(i,l)=>{const a=o(l);return a==null||!U(a)?null:X(i,a,e.height,e.top)}}}const Oo={left:-10,top:-10,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1,plotLeft:0,plotTop:0,plotWidth:0,plotHeight:0,seriesCount:0,revision:-1};function ze(t){const{left:e,top:n,activeGroup:o,activeSeriesIdx:s,activeDataIdx:r}=t.cursorManager.state,{left:i,top:l,width:a,height:f}=t.plotBox,c=t.seriesConfigs.length,{revision:d}=t,u=t.snapshot;u.left===e&&u.top===n&&u.activeGroup===o&&u.activeSeriesIdx===s&&u.activeDataIdx===r&&u.plotLeft===i&&u.plotTop===l&&u.plotWidth===a&&u.plotHeight===f&&u.seriesCount===c&&u.revision===d||(t.snapshot={left:e,top:n,activeGroup:o,activeSeriesIdx:s,activeDataIdx:r,plotLeft:i,plotTop:l,plotWidth:a,plotHeight:f,seriesCount:c,revision:d})}function te(t){t.seriesConfigMap.clear();for(const e of t.seriesConfigs)t.seriesConfigMap.set(`${e.group}:${e.index}`,e)}function Ko(){const t={scaleManager:new $n,dataStore:new Vn,renderer:new eo,cursorManager:new Xn,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 Yn,drawHooks:new Set,unclippedDrawHooks:new Set,cursorDrawHooks:new Set,focusedSeries:null,focusAlpha:1,actionMap:new Map(Bt),title:void 0,xlabel:void 0,ylabel:void 0,snapshot:Oo,revision:0,eventCallbacks:{},_prevScaleRanges:new Map,_prevPlotBox:null,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),te(t),t.renderer.clearGroupCache(e.group)},unregisterSeries(e,n){t.seriesConfigs=t.seriesConfigs.filter(o=>!(o.group===e&&o.index===n)),te(t),t.renderer.clearGroupCache(e)},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,o){const s=o??t.pxRatio;t.width===e&&t.height===n&&t.pxRatio===s||(t.pxRatio=s,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())},scheduleRedraw(){t.scheduler.mark(st.Full)},scheduleCursorRedraw(){t.scheduler.mark(st.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:a,scheduler:f}=t;if(a==null||r===0||i===0)return;const c=a.getContext("2d");if(c==null)return;o.setContext(c,l);const u=(f.dirty&~(st.Cursor|st.Select))===0,h=p=>e.getScale(p);if(u&&o.restoreSnapshot(c)){if(Re(c,t.cursorManager.state,t.plotBox,l,n.data,s,h,p=>e.getGroupXScaleKey(p),void 0,t.seriesConfigMap),He(c,t.selectState,t.plotBox,l),t.cursorDrawHooks.size>0){c.save(),c.scale(l,l);const p=zt(c,t.plotBox,l,h);for(const m of t.cursorDrawHooks)try{m(p,t.cursorManager.state)}catch(T){console.warn("[uPlot+] draw hook error:",T)}c.restore()}ze(t);for(const p of t.cursorListeners)p();return}Uo(t),e.autoRangeX(n.data),n.updateWindows(p=>{const m=e.getGroupXScaleKey(p);return m!=null?e.getScale(m):void 0});const g=s.map(p=>({group:p.group,index:p.index,yScale:p.yScale}));if(e.autoRange(n.data,g,n),qo(t),t.axisStates.length>0){const p=t.title!=null?20:0;t.plotBox=Fo(r,i,t.axisStates,h,p)}else t.plotBox={left:10,top:10,width:r-20,height:i-20};const w=t._prevPlotBox,v=t.plotBox;w!=null&&(w.left!==v.left||w.top!==v.top||w.width!==v.width||w.height!==v.height)&&o.clearCache(),t._prevPlotBox={...v},c.clearRect(0,0,r*l,i*l),t.axisStates.length>0&&zo(c,t.axisStates,h,t.plotBox,l,t.title);const b=[];for(const p of s){const m=e.getGroupXScaleKey(p.group),T=m!=null?e.getScale(m):void 0,A=e.getScale(p.yScale);T==null||A==null||b.push({config:p,dataX:n.getXValues(p.group),dataY:n.getYValues(p.group,p.index),xScale:T,yScale:A,window:n.getWindow(p.group)})}o.checkScaleStamp(b),c.save(),c.scale(l,l),c.beginPath(),c.rect(t.plotBox.left,t.plotBox.top,t.plotBox.width,t.plotBox.height),c.clip();for(let p=0;p<b.length;p++){const m=b[p];m!=null&&(t.focusedSeries!=null&&p!==t.focusedSeries?(c.globalAlpha=t.focusAlpha,o.drawSeries(m,t.plotBox,1),c.globalAlpha=1):o.drawSeries(m,t.plotBox,1))}const x=new Map;for(const p of s)x.set(`${p.group}-${p.index}`,p);for(const p of t.bandConfigs){const m=e.getGroupXScaleKey(p.group),T=m!=null?e.getScale(m):void 0,A=x.get(`${p.group}-${p.series[0]}`),y=x.get(`${p.group}-${p.series[1]}`);if(T==null||A==null||y==null)continue;const M=e.getScale(A.yScale);if(M==null)continue;const[I,P]=n.getWindow(p.group),F=p.series[0],L=p.series[1];let C=o.getCachedBandPath(p.group,F,L,I,P);C==null&&(C=jo(n.getXValues(p.group),n.getYValues(p.group,F),n.getYValues(p.group,L),T,M,t.plotBox,l,I,P)??void 0,C!=null&&o.setCachedBandPath(p.group,F,L,I,P,C)),C!=null&&No(c,p,C)}for(const p of b){const m=p.config;if(m.show===!1)continue;const T=m.points,A=m.width??1,y=(T==null?void 0:T.size)??3+A*2,M=(T==null?void 0:T.space)??y*2,[I,P]=p.window;Yo(T==null?void 0:T.show,m.group,m.index,I,P,t.plotBox.width,M)&&Xo(c,p.dataX,p.dataY,p.xScale,p.yScale,t.plotBox,l,I,P,T,y,(typeof m.stroke=="string"?m.stroke:null)??"#000")}if(c.restore(),t.drawHooks.size>0){c.save(),c.beginPath(),c.rect(t.plotBox.left*l,t.plotBox.top*l,t.plotBox.width*l,t.plotBox.height*l),c.clip(),c.scale(l,l);const p=zt(c,t.plotBox,l,h);for(const m of t.drawHooks)try{m(p)}catch(T){console.warn("[uPlot+] draw hook error:",T)}c.restore()}if(t.unclippedDrawHooks.size>0){c.save(),c.scale(l,l);const p=zt(c,t.plotBox,l,h);for(const m of t.unclippedDrawHooks)try{m(p)}catch(T){console.warn("[uPlot+] draw hook error:",T)}c.restore()}if(t.cursorManager.state.left>=0&&(o.saveSnapshot(c,r*l,i*l),t.cursorManager.update(t.cursorManager.state.left,t.cursorManager.state.top,t.plotBox,n.data,s,h,p=>n.getWindow(p),p=>e.getGroupXScaleKey(p))),Re(c,t.cursorManager.state,t.plotBox,l,n.data,s,h,p=>e.getGroupXScaleKey(p),void 0,t.seriesConfigMap),He(c,t.selectState,t.plotBox,l),t.cursorDrawHooks.size>0){c.save(),c.scale(l,l);const p=zt(c,t.plotBox,l,h);for(const m of t.cursorDrawHooks)try{m(p,t.cursorManager.state)}catch(T){console.warn("[uPlot+] draw hook error:",T)}c.restore()}ze(t);for(const p of t.listeners)p();for(const p of t.cursorListeners)p();if(t._prevScaleRanges.size>0&&t.eventCallbacks.onScaleChange!=null)for(const p of e.getAllScales()){if(!U(p))continue;const m=t._prevScaleRanges.get(p.id);if(m==null||m.min!==p.min||m.max!==p.max)try{t.eventCallbacks.onScaleChange(p.id,p.min,p.max)}catch(T){console.warn("[uPlot+] event callback error:",T)}}t._prevScaleRanges.clear();for(const p of e.getAllScales())U(p)&&t._prevScaleRanges.set(p.id,{min:p.min,max:p.max})},getSnapshot:()=>t.snapshot,updateScale(e){t.scaleConfigs=t.scaleConfigs.map(n=>n.id===e.id?e:n),t.scaleManager.addScale(e),t.renderer.clearCache()},updateSeries(e){t.seriesConfigs=t.seriesConfigs.map(n=>n.group===e.group&&n.index===e.index?e:n),te(t),t.renderer.invalidateSeries(e.group,e.index)},registerAxis(e){t.axisConfigs=t.axisConfigs.filter(n=>!(n.scale===e.scale&&n.side===e.side)),t.axisConfigs.push(e)},unregisterAxis(e,n){t.axisConfigs=t.axisConfigs.filter(o=>!(o.scale===e&&o.side===n))},updateAxis(e){t.axisConfigs=t.axisConfigs.map(n=>n.scale===e.scale&&n.side===e.side?e:n)},registerBand(e){t.bandConfigs.push(e)},unregisterBand(e){t.bandConfigs=t.bandConfigs.filter(n=>n!==e)},setData(e){t.dataStore.setData(e),t.renderer.clearCache()},setCanvas(e){t.canvas=e},setLabels(e,n,o){t.title=e,t.xlabel=n,t.ylabel=o,t.scheduleRedraw()},redrawSync(){t.scheduler.cancel(),t.scheduler.mark(st.Full),t.redraw(),t.scheduler.clear()}};return t.scheduler.onRedraw(()=>t.redraw()),t}function qo(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):mo(s)})}function Zo(){const t=R.useRef(null);return t.current===null&&(t.current=Ko()),t.current}const cn=R.createContext(null);function ot(){const t=R.useContext(cn);if(!t)throw new Error("useChart must be used within a <Chart> component");return t}function Jo(t="cursor"){const e=ot(),n=t==="full"?e.subscribe:e.subscribeCursor,o=R.useSyncExternalStore(n,e.getSnapshot);return{left:o.left,top:o.top,activeGroup:o.activeGroup,activeSeriesIdx:o.activeSeriesIdx,activeDataIdx:o.activeDataIdx,plotLeft:o.plotLeft,plotTop:o.plotTop,plotWidth:o.plotWidth,plotHeight:o.plotHeight,seriesCount:o.seriesCount,revision:o.revision,getScale:s=>e.scaleManager.getScale(s),getPlotBox:()=>e.plotBox,getSeriesConfigs:()=>e.seriesConfigs,getDataX:s=>e.dataStore.getXValues(s),getDataY:(s,r)=>e.dataStore.getYValues(s,r),toggleSeries:(s,r)=>e.toggleSeries(s,r),setFocus:s=>e.setFocus(s)}}const We=5,un=.001,Qo=.1,ts=10;function he(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 es(t){return he(t,"Drag")}function ns(t){return he(t,"Click")}function os(t){return he(t,"Dblclick")}function ss(t){const e=t.shiftKey?"shift":t.altKey?"alt":t.ctrlKey?"ctrl":"";return e?`${e}Wheel`:"wheel"}function is(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 rs(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 ls(t,e){const n=[];for(const o of t.scaleManager.getAllScales())U(o)&&(e!=null&&!e(o.ori)||n.push({id:o.id,ori:o.ori,dir:o.dir,startMin:o.min,startMax:o.max}));return n}function Et(t){const e=t.eventCallbacks.onScaleChange;if(e!=null)for(const n of t.scaleManager.getAllScales()){if(!U(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 ee(t,e,n,o){if(!(e instanceof WheelEvent))return;const s=Q(1-e.deltaY*un,Qo,ts),r=t.plotBox;for(const i of t.scaleManager.getAllScales()){if(!U(i)||!o(i.ori))continue;const l=i.ori===$.Horizontal,a=l?r.width:r.height,f=l?r.left:r.top,c=l?n.cx+r.left:n.cy+r.top,d=ft(c,i,a,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,ut(i)}t.scheduleRedraw(),Et(t)}function ne(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,a){const f=t.plotBox,c=Q(a.cx,0,f.width),d=Q(a.cy,0,f.height);o.show=!0,o.left=Math.min(s,c),o.top=Math.min(r,d),o.width=Math.abs(c-s),o.height=Math.abs(d-r),n($.Vertical)||(o.top=0,o.height=f.height),n($.Horizontal)||(o.left=0,o.width=f.width),t.selectState=o,t.scheduler.mark(st.Cursor|st.Select)},onEnd(i,l,a){const f=n($.Horizontal)&&o.width>We,c=n($.Vertical)&&o.height>We;if(f||c){let d=!0;if(t.eventCallbacks.onSelect!=null){const u=us(t,o);let h;try{h=t.eventCallbacks.onSelect(u)}catch(g){console.warn("[uPlot+] event callback error:",g)}h===!1&&(d=!1)}d&&(as(t,o,n),Et(t))}o.show=!1,o.left=0,o.width=0,t.selectState=o,t.scheduleRedraw()}}}function as(t,e,n){const o=t.plotBox;for(const s of t.scaleManager.getAllScales()){if(!U(s)||!n(s.ori))continue;const r=s.ori===$.Horizontal,i=r?o.width:o.height,l=r?o.left:o.top,a=r?e.left:e.top,f=r?e.width:e.height,c=a/i,d=(a+f)/i,u=ft(l+c*i,s,i,l),h=ft(l+d*i,s,i,l);s.min=Math.min(u,h),s.max=Math.max(u,h),s.auto=!1,ut(s)}}function oe(t,e,n,o){const s=ls(t,n),r=e.clientX,i=e.clientY;return{onMove(l,a){const f=t.plotBox,c=a;for(const d of s){const u=t.scaleManager.getScale(d.id);if(u==null)continue;const h=d.ori===$.Horizontal,g=h?f.width:f.height,w=h?c.clientX-r:c.clientY-i,v=(h?-1:1)*d.dir,b=d.startMax-d.startMin;u.min=d.startMin+v*(w/g)*b,u.max=d.startMax+v*(w/g)*b,u.auto=!1,ut(u)}t.renderer.clearCache(),t.scheduleRedraw()},onEnd(){Et(t)}}}function $e(t,e,n){var c;if(n.scaleId==null||n.ori==null)return;const o=t.scaleManager.getScale(n.scaleId);if(o==null||!U(o))return;const s=n.ori===$.Vertical,r=(c=e.target.closest("div"))==null?void 0:c.getBoundingClientRect();if(r==null)return;const i=s?e.clientY-r.top:e.clientX-r.left,l=o.min,a=o.max,f=n.scaleId;return{onMove(d,u){const h=t.plotBox,g=u,w=s?h.height:h.width,b=((s?g.clientY-r.top:g.clientX-r.left)-i)/w,x=(s?1:-1)*o.dir,p=a-l,m=t.scaleManager.getScale(f);m!=null&&(m.min=l+x*b*p,m.max=a+x*b*p,m.auto=!1,ut(m),t.renderer.clearCache(),t.scheduleRedraw())},onEnd(){Et(t)}}}function se(t,e,n){if(!(e instanceof WheelEvent))return;const o=e.deltaY*un*10;for(const s of t.scaleManager.getAllScales()){if(!U(s)||!n(s.ori))continue;const r=s.max-s.min;s.min+=o*r,s.max+=o*r,s.auto=!1,ut(s)}t.renderer.clearCache(),t.scheduleRedraw(),Et(t)}const Wt=t=>t===$.Horizontal,$t=t=>t===$.Vertical,Gt=()=>!0;function cs(t){switch(t){case"zoomX":return(e,n,o)=>{if(n instanceof WheelEvent){ee(e,n,o,Wt);return}return ne(e,o,Wt)};case"zoomY":return(e,n,o)=>{if(n instanceof WheelEvent){ee(e,n,o,$t);return}return ne(e,o,$t)};case"zoomXY":return(e,n,o)=>{if(n instanceof WheelEvent){ee(e,n,o,Gt);return}return ne(e,o,Gt)};case"panX":return(e,n,o)=>{if(n instanceof WheelEvent){se(e,n,Wt);return}return o.scaleId!=null?$e(e,n,o):oe(e,n,Wt)};case"panY":return(e,n,o)=>{if(n instanceof WheelEvent){se(e,n,$t);return}return o.scaleId!=null?$e(e,n,o):oe(e,n,$t)};case"panXY":return(e,n,o)=>{if(n instanceof WheelEvent){se(e,n,Gt);return}return oe(e,n,Gt)};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 Ge(t){return typeof t=="function"?t:cs(t)}function us(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!==$.Horizontal||!U(i))continue;const l=ft(n.left+o*n.width,i,n.width,n.left),a=ft(n.left+s*n.width,i,n.width,n.left);r[i.id]={min:Math.min(l,a),max:Math.max(l,a)}}return{left:o,right:s,ranges:r}}function fs(t,e){R.useEffect(()=>{if(e!=null)return hs(t,e)},[t,e])}function hs(t,e){let n=null,o=!1,s=null,r=-1,i=-1;function l(S){const k=e.getBoundingClientRect(),E=t.plotBox;return{cx:S.clientX-k.left-E.left,cy:S.clientY-k.top-E.top}}function a(S,k){const E=t.plotBox;return S>=0&&S<=E.width&&k>=0&&k<=E.height}function f(S,k){const E=e.getBoundingClientRect(),_=S-E.left,W=k-E.top,H=t.plotBox;for(const V of t.axisStates){const N=V.config,q=N.side;if(V._size<=0)continue;const nt=W>=H.top&&W<=H.top+H.height,Z=_>=H.left&&_<=H.left+H.width;if(q===j.Left&&_<H.left&&nt||q===j.Right&&_>H.left+H.width&&nt||q===j.Top&&W<H.top&&Z||q===j.Bottom&&W>H.top+H.height&&Z)return{scaleId:N.scale,ori:Mt(q)}}return null}function c(S){const{cx:k,cy:E}=l(S);return{cx:k,cy:E,inPlot:a(k,E)}}function d(S){if(n==null){g();return}e.contains(S.target)||(o=!0,n.onMove(t,S,c(S)),x(S,S))}function u(S){g(),n!=null&&(e.contains(S.target)||(n.onEnd(t,S,c(S)),n=null,r=-1,i=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw()))}function h(){document.addEventListener("mousemove",d),document.addEventListener("mouseup",u)}function g(){document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",u)}function w(){n!=null&&(n=null,g(),t.cursorManager.hide(),t.scheduleCursorRedraw())}function v(S,k,E){const _=t.cursorManager.state;let W=null;if(_.activeGroup>=0&&_.activeDataIdx>=0){const H=t.dataStore.data[_.activeGroup];if(H!=null){const V=H.x[_.activeDataIdx],N=H.series[_.activeSeriesIdx],q=N!=null?N[_.activeDataIdx]:void 0;if(V!=null&&q!=null){const tt=t.plotBox,nt=t.scaleManager.getGroupXScaleKey(_.activeGroup),Z=nt!=null?t.scaleManager.getScale(nt):void 0,ht=t.seriesConfigMap.get(`${_.activeGroup}:${_.activeSeriesIdx}`),Ct=ht!=null?t.scaleManager.getScale(ht.yScale):void 0;let kt=k,Ot=E;Z!=null&&U(Z)&&(kt=X(V,Z,tt.width,tt.left)-tt.left),Ct!=null&&U(Ct)&&(Ot=X(q,Ct,tt.height,tt.top)-tt.top);const ye=k-kt,Me=E-Ot;W={group:_.activeGroup,seriesIdx:_.activeSeriesIdx,dataIdx:_.activeDataIdx,xVal:V,yVal:q,pxX:kt,pxY:Ot,dist:Math.sqrt(ye*ye+Me*Me)}}}}return{plotX:k,plotY:E,point:W,srcEvent:S}}function b(S,k,E,_=!0){const W=rs(t.actionMap,S,k,E,_);if(!(W==null||W==="none"))return Ge(W)}function x(S,k){const{cx:E,cy:_}=l(S);if(!a(E,_)&&n==null){r=-1,i=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw();return}const W=E!==r||_!==i;if(r=E,i=_,t.cursorManager.update(E,_,t.plotBox,t.dataStore.data,t.seriesConfigs,H=>t.scaleManager.getScale(H),H=>t.dataStore.getWindow(H),H=>t.scaleManager.getGroupXScaleKey(H)),W){const H={cx:E,cy:_,inPlot:a(E,_)},V=t.actionMap.get("hover");if(V!=null&&V!=="none"){const N=Ge(V);if(N!=null&&N(t,k??S,H),t.focusAlpha<1){const q=t.cursorManager.state;if(q.activeGroup>=0&&q.activeSeriesIdx>=0){const tt=t.seriesConfigs.findIndex(nt=>nt.group===q.activeGroup&&nt.index===q.activeSeriesIdx);tt>=0&&t.focusedSeries!==tt&&(t.focusedSeries=tt,t.scheduleRedraw())}}}}if(k!=null&&t.eventCallbacks.onCursorMove!=null&&a(E,_))try{t.eventCallbacks.onCursorMove(v(k,E,_))}catch(H){console.warn("[uPlot+] event callback error:",H)}t.scheduleCursorRedraw()}function p(){document.activeElement!==e&&e.focus()}function m(S){const k=c(S),E=f(S.clientX,S.clientY);let _;if(E!=null&&S.button===0)_=E.ori===$.Horizontal?"xGutterDrag":"yGutterDrag",k.scaleId=E.scaleId,k.ori=E.ori;else if(_=es(S),!k.inPlot)return;k.action=_;const W=b(_,S,k,!1);if(W==null)return;(S.button!==0||E!=null)&&S.preventDefault();const H=W(t,S,k);H!=null&&(n=H,o=!1,h())}function T(S){if(n!=null){o=!0,n.onMove(t,S,c(S)),x(S,S);return}x(S,S)}function A(S){if(n!=null){n.onEnd(t,S,c(S)),n=null;return}}function y(S){if(o){o=!1;return}const k=c(S);if(!k.inPlot)return;const E=ns(S);k.action=E;const _=b(E,S,k);_!=null&&_(t,S,k);const W=t.eventCallbacks.onClick;if(W!=null)try{W(v(S,k.cx,k.cy))}catch(H){console.warn("[uPlot+] event callback error:",H)}}function M(S){if(n!=null){S.preventDefault();return}const k=c(S);if(!k.inPlot)return;S.preventDefault(),k.action="rightClick";const E=b("rightClick",S,k);E!=null&&E(t,S,k);const _=t.eventCallbacks.onContextMenu;if(_!=null)try{_(v(S,k.cx,k.cy))}catch(W){console.warn("[uPlot+] event callback error:",W)}}function I(S){var k,E;if(n==null){r=-1,i=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw();try{(E=(k=t.eventCallbacks).onCursorLeave)==null||E.call(k)}catch(_){console.warn("[uPlot+] event callback error:",_)}}}function P(S){const k=c(S);if(!k.inPlot)return;if(t.eventCallbacks.onDblClick!=null){let W;try{W=t.eventCallbacks.onDblClick(v(S,k.cx,k.cy))}catch(H){console.warn("[uPlot+] event callback error:",H)}if(W===!1)return}const E=os(S);k.action=E;const _=b(E,S,k,!1);_!=null&&_(t,S,k)}function F(S){const k=c(S);if(!k.inPlot)return;const E=ss(S);k.action=E;const _=b(E,S,k);_!=null&&(S.preventDefault(),_(t,S,k))}function L(S){if(S.touches.length===2){const H=S.touches[0],V=S.touches[1],N=V.clientX-H.clientX,q=V.clientY-H.clientY;s={dist:Math.sqrt(N*N+q*q),midX:(H.clientX+V.clientX)/2,midY:(H.clientY+V.clientY)/2},n=null;return}const k=S.touches[0];if(k==null)return;const E=c(k);if(!E.inPlot)return;const _=b("touchDrag",S,E);if(_==null)return;const W=_(t,S,E);W!=null&&(n=W,o=!1)}function C(S){if(S.touches.length===2&&s!=null){S.preventDefault();const E=S.touches[0],_=S.touches[1],W=_.clientX-E.clientX,H=_.clientY-E.clientY,V=Math.sqrt(W*W+H*H),N=c({clientX:s.midX,clientY:s.midY});if(b("pinch",S,N)!=null){const tt=V/s.dist,nt=t.plotBox;for(const Z of t.scaleManager.getAllScales()){if(Z.ori!==$.Horizontal||!U(Z))continue;const ht=ft(N.cx+nt.left,Z,nt.width,nt.left),Ct=ht-(ht-Z.min)/tt,kt=ht+(Z.max-ht)/tt;Z.min=Math.min(Ct,kt),Z.max=Math.max(Ct,kt),Z.auto=!1,ut(Z)}s.dist=V,t.renderer.clearCache(),t.scheduleRedraw(),Et(t)}return}const k=S.touches[0];if(k!=null){if(n!=null){o=!0,n.onMove(t,S,c(k)),x(k,S),S.preventDefault();return}x(k,S)}}function D(S){if(s!=null){s=null;return}const k=S.changedTouches[0];k!=null&&n!=null&&(n.onEnd(t,S,c(k)),n=null)}function z(S){const k={cx:r,cy:i,inPlot:r>=0&&i>=0},E=is(S);k.action=E;const _=b(E,S,k);_!=null&&(S.preventDefault(),_(t,S,k))}return e.addEventListener("mouseenter",p),e.addEventListener("mousemove",T),e.addEventListener("mousedown",m),e.addEventListener("mouseup",A),e.addEventListener("click",y),e.addEventListener("contextmenu",M),e.addEventListener("mouseleave",I),e.addEventListener("dblclick",P),e.addEventListener("wheel",F,{passive:!1}),e.addEventListener("touchstart",L,{passive:!0}),e.addEventListener("touchmove",C,{passive:!1}),e.addEventListener("touchend",D),e.addEventListener("keydown",z),window.addEventListener("blur",w),()=>{g(),e.removeEventListener("mouseenter",p),e.removeEventListener("mousemove",T),e.removeEventListener("mousedown",m),e.removeEventListener("mouseup",A),e.removeEventListener("click",y),e.removeEventListener("contextmenu",M),e.removeEventListener("mouseleave",I),e.removeEventListener("dblclick",P),e.removeEventListener("wheel",F),e.removeEventListener("touchstart",L),e.removeEventListener("touchmove",C),e.removeEventListener("touchend",D),e.removeEventListener("keydown",z),window.removeEventListener("blur",w)}}const re=new Map;function ds(t){let e=re.get(t);return e==null&&(e=new gs(t),re.set(t,e)),e}class gs{constructor(e){Y(this,"key");Y(this,"members",new Set);Y(this,"publishing",!1);Y(this,"syncedStores",new WeakSet);this.key=e}join(e){this.members.add(e)}leave(e){this.members.delete(e),this.members.size===0&&re.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,o),l.scheduleCursorRedraw());this.publishing=!1}}function ps(t,e){R.useEffect(()=>{if(e==null)return;const n=ds(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 fn(t){return t instanceof Float64Array?t:new Float64Array(t)}function hn(t){return t instanceof Float64Array||t.some(e=>e==null)?t:new Float64Array(t)}function Be(t){return{x:fn(t.x),series:[hn(t.y)]}}function ms(t){return{x:fn(t.x),series:t.series.map(hn)}}function dn(t){if(!Array.isArray(t))return[Be(t)];if(t.length===0)return[];const e=t[0];return e==null?[]:"series"in e?t.map(ms):t.map(Be)}function de({width:t,height:e,data:n,children:o,className:s,pxRatio:r,title:i,xlabel:l,ylabel:a,onDraw:f,onCursorDraw:c,syncKey:d,actions:u,onClick:h,onContextMenu:g,onDblClick:w,onCursorMove:v,onCursorLeave:b,onScaleChange:x,onSelect:p}){const m=Zo(),[T,A]=R.useState(null),y=r??(typeof window<"u"&&window.devicePixelRatio||1);R.useEffect(()=>{m.actionMap=u!=null?new Map([...Bt,...u]):new Map(Bt)},[m,u]),R.useLayoutEffect(()=>{m.setLabels(i,l,a)},[m,i,l,a]),R.useEffect(()=>{const S=m.eventCallbacks;S.onClick=h,S.onContextMenu=g,S.onDblClick=w,S.onCursorMove=v,S.onCursorLeave=b,S.onScaleChange=x,S.onSelect=p},[m,h,g,w,v,b,x,p]),fs(m,T),ps(m,d);const M=R.useRef(null),I=R.useCallback(S=>{M.current!==S&&(M.current=S,m.setCanvas(S),S&&m.scheduleRedraw())},[m]),P=R.useRef(null),F=R.useCallback(S=>{P.current!==S&&(P.current=S,A(S))},[]),L=R.useRef(f);R.useLayoutEffect(()=>{L.current=f});const C=R.useRef(c);R.useLayoutEffect(()=>{C.current=c});const D=R.useRef(!1),z=R.useRef(n);return R.useLayoutEffect(()=>{n===z.current&&m.dataStore.data.length>0||(z.current=n,D.current=!0,m.setData(dn(n)),m.scheduleRedraw())},[m,n]),R.useLayoutEffect(()=>{m.setSize(t,e,y),D.current&&m.redrawSync()},[m,t,e,y]),R.useEffect(()=>()=>{m.setCanvas(null),m.scheduler.cancel(),m.focusedSeries=null,m.eventCallbacks={}},[m]),R.useEffect(()=>{if(T==null||typeof ResizeObserver>"u")return;const S=new ResizeObserver(k=>{const E=k[0];if(E==null)return;const{width:_,height:W}=E.contentRect;_>0&&W>0&&(_!==m.width||W!==m.height)&&(m.setSize(Math.round(_),Math.round(W)),m.scheduleRedraw())});return S.observe(T),()=>{S.disconnect()}},[m,T]),R.useLayoutEffect(()=>{const S=k=>{var E;(E=L.current)==null||E.call(L,k)};return m.drawHooks.add(S),()=>{m.drawHooks.delete(S)}},[m]),R.useLayoutEffect(()=>{const S=(k,E)=>{var _;(_=C.current)==null||_.call(C,k,E)};return m.cursorDrawHooks.add(S),()=>{m.cursorDrawHooks.delete(S)}},[m]),G.jsx(cn.Provider,{value:m,children:G.jsxs("div",{className:s,style:{position:"relative",display:"flex",flexDirection:"column",width:`${t}px`},children:[G.jsx("div",{ref:F,tabIndex:0,style:{position:"relative",width:`${t}px`,height:`${e}px`,cursor:"crosshair",outline:"none",order:0},children:G.jsx("canvas",{ref:I,style:{position:"absolute",left:0,top:0}})}),o]})})}function Ve(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}function ws(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 Ss(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],a=o[i];if(l!==a)if(Ve(l)&&Ve(a)){if(!ws(l,a))return!1}else return!1}return!0}function ge(t,e,n,o,s){const r=ot(),i=R.useRef(t);R.useLayoutEffect(()=>{i.current=t}),R.useLayoutEffect(()=>{const a=i.current;return n(r,a),r.scheduleRedraw(),()=>{o(r,a),r.scheduleRedraw()}},[r,...e]);const l=R.useRef(t);R.useLayoutEffect(()=>{Ss(l.current,t)||(l.current=t,s(r,t),r.scheduleRedraw())})}function vs(t){return ge(t,[t.id],(e,n)=>e.registerScale(n),(e,n)=>e.unregisterScale(n.id),(e,n)=>e.updateScale(n)),null}function bs(t,e,n){e/=100,n/=100;const o=(1-Math.abs(2*n-1))*e,s=o*(1-Math.abs(t/60%2-1)),r=n-o/2;let i=0,l=0,a=0;return t<60?(i=o,l=s):t<120?(i=s,l=o):t<180?(l=o,a=s):t<240?(l=s,a=o):t<300?(i=s,a=o):(i=o,a=s),[Math.round((i+r)*255),Math.round((l+r)*255),Math.round((a+r)*255)]}function gn(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);if(o)return[Number(o[1]),Number(o[2]),Number(o[3])];const s=/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%/i.exec(t);return s?bs(Number(s[1]),Number(s[2]),Number(s[3])):null}function xs(t,e=.8,n=0){const o=gn(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 pn(t,e){const n=gn(t);if(n==null)return t;const[o,s,r]=n;return`rgba(${o},${s},${r},${e})`}function ys(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 Xe=["#e74c3c","#3498db","#2ecc71","#f39c12","#9b59b6","#1abc9c","#e67e22","#34495e","#16a085","#c0392b","#2980b9","#27ae60","#f1c40f","#8e44ad","#d35400"];function Ye(t,e){var i;const n=(i=t.paths)==null?void 0:i.defaults,o=t.stroke??Xe[e%Xe.length]??"#000",s=t.fill??(n==null?void 0:n.fill),r=s==="auto"&&typeof o=="string"?pn(o,.5):s==="auto"?void 0:s;return{...n,...t,yScale:t.yScale??"y",show:t.show??!0,stroke:o,fill:r}}function pe(t){return ge(t,[t.group,t.index],(e,n)=>e.registerSeries(Ye(n,e.seriesConfigs.length)),(e,n)=>e.unregisterSeries(n.group,n.index),(e,n)=>{const o=e.seriesConfigs.findIndex(s=>s.group===n.group&&s.index===n.index);e.updateSeries(Ye(n,o>=0?o:e.seriesConfigs.length))}),null}function Ms(t){return{...t,side:t.side??(t.scale==="x"?j.Bottom:j.Left),show:t.show??!0}}function Rt(t){const e=Ms(t);return ge(e,[e.scale,e.side],(n,o)=>n.registerAxis(o),(n,o)=>n.unregisterAxis(o.scale,o.side),(n,o)=>n.updateAxis(o)),null}function Cs({series:t,group:e,fill:n,dir:o}){const s=ot(),r=R.useRef(null),i=t[0],l=t[1];return R.useEffect(()=>{const a={series:[i,l],group:e,fill:n,dir:o};return r.current!=null&&s.unregisterBand(r.current),r.current=a,s.registerBand(a),s.scheduleRedraw(),()=>{r.current!=null&&s.unregisterBand(r.current),r.current=null,s.scheduleRedraw()}},[s,i,l,e,n,o]),null}const ks={width:12,height:3,borderRadius:1,display:"inline-block"},Ts={fontWeight:600},mn={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",cursor:"pointer",fontSize:12,fontFamily:"sans-serif"},As={...mn,opacity:1},Ls={...mn,opacity:.4},je=new Map,Is={display:"flex",flexWrap:"wrap",justifyContent:"center",order:-1,padding:"4px 0"},Ps={display:"flex",flexWrap:"wrap",justifyContent:"center",order:1,padding:"4px 0"};function Es({group:t,index:e,label:n,color:o,isHidden:s,valueStr:r,store:i}){let l=je.get(o);return l==null&&(l={...ks,backgroundColor:o},je.set(o,l)),G.jsxs("span",{onClick:()=>i.toggleSeries(t,e),style:s?Ls:As,children:[G.jsx("span",{style:l}),G.jsx("span",{children:n}),r&&G.jsx("span",{style:Ts,children:r})]})}function _s({show:t=!0,position:e="bottom",className:n}){const o=ot(),s=R.useSyncExternalStore(o.subscribeCursor,o.getSnapshot);if(!t)return null;const{activeGroup:r,activeDataIdx:i}=s;return G.jsx("div",{className:n,style:e==="top"?Is:Ps,children:o.seriesConfigs.map(l=>{if(l.legend===!1)return null;const a=typeof l.stroke=="string"?l.stroke:"#000";let f="";if(i>=0&&r>=0&&l.group===r){const d=o.dataStore.getYValues(l.group,l.index)[i];d!=null&&(f=typeof d=="number"?d.toPrecision(4):String(d))}return G.jsx(Es,{group:l.group,index:l.index,label:l.label??`Series ${l.index}`,color:a,isHidden:l.show===!1,valueStr:f,store:o},`${l.group}:${l.index}`)})})}const Ds={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"},Fs={width:12,height:3,borderRadius:1,display:"inline-block",flexShrink:0},Rs={fontWeight:600},Ut={display:"flex",alignItems:"center",gap:4,padding:"1px 4px"},Hs={...Ut,opacity:1,cursor:"pointer"},zs={...Ut,opacity:1,cursor:"default"},Ws={...Ut,opacity:.4,cursor:"pointer"},$s={...Ut,opacity:.4,cursor:"default"},Ne=new Map;function Gs(t){let e=Ne.get(t);return e==null&&(e={...Fs,backgroundColor:t},Ne.set(t,e)),e}function me({label:t,color:e,value:n,isHidden:o,onClick:s}){const r=o?s?Ws:$s:s?Hs:zs;return G.jsxs("div",{onClick:s,style:r,children:[G.jsx("span",{style:Gs(e)}),G.jsx("span",{children:t}),n&&G.jsx("span",{style:Rs,children:n})]})}const Vt=R.forwardRef(function({left:e,top:n,children:o,className:s,style:r,onMouseDown:i,onMouseEnter:l,onMouseLeave:a},f){return G.jsx("div",{ref:f,className:s,onMouseDown:i,onMouseEnter:l,onMouseLeave:a,style:{...Ds,left:e,top:n,...r},children:o})});function Bs(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)}const Vs={},Xs={pointerEvents:"none",zIndex:100},Ys={fontWeight:600,marginBottom:2,padding:"0 4px"};function js({show:t=!0,className:e,children:n,offset:o=Vs,precision:s=2}){const r=ot(),i=R.useSyncExternalStore(r.subscribeCursor,r.getSnapshot),l=R.useRef(null),[a,f]=R.useState({w:0,h:0});if(R.useLayoutEffect(()=>{const L=l.current;if(!L)return;const C=L.offsetWidth,D=L.offsetHeight;(C!==a.w||D!==a.h)&&f({w:C,h:D})}),!t||i.activeDataIdx<0||i.activeGroup<0||i.left<0)return null;const{activeGroup:c,activeDataIdx:d}=i,u=r.plotBox,h=r.dataStore.data[c],g=h!=null?h.x[d]??null:null,w=g!=null?parseFloat(g.toFixed(s)).toString():"",v=[];for(const L of r.seriesConfigs){if(L.show===!1||L.legend===!1)continue;const C=r.dataStore.getYValues(L.group,L.index),D=L.group===c?C[d]:null;v.push({label:L.label??`Series ${L.index}`,value:D,color:typeof L.stroke=="string"?L.stroke:"#000",group:L.group,index:L.index})}const b={x:g,xLabel:w,items:v,left:i.left+u.left,top:i.top+u.top},x=o.x??12,p=o.y??-12,m=a.w,T=a.h,A=i.left+u.left,y=i.top+u.top,M=u.left+u.width,I=u.top+u.height,P=Q(A+x,u.left,M-m),F=Q(y+p,u.top,I-T);return n?G.jsx("div",{ref:l,className:e,style:{position:"absolute",left:P,top:F,whiteSpace:"nowrap",pointerEvents:"none",zIndex:100},children:n(b)}):G.jsxs(Vt,{ref:l,left:P,top:F,className:e,style:Xs,children:[G.jsx("div",{style:Ys,children:w}),v.map(L=>G.jsx(me,{label:L.label,color:L.color,value:L.value!=null?L.value.toPrecision(4):"—"},`${L.group}:${L.index}`))]})}const Ns=8,Ue=.01,Us=[.25,.75];function Os({width:t,height:e,data:n,onRangeChange:o,initialRange:s,className:r,colors:i,grips:l=!1}){const a=R.useRef(null),f=R.useMemo(()=>dn(n),[n]),[c,d]=R.useState(()=>{if(s!=null&&f.length>0){const A=f[0];if(A!=null&&A.x.length>1){const y=A.x[0],I=A.x[A.x.length-1]-y;if(I>0)return[Math.max(0,(s[0]-y)/I),Math.min(1,(s[1]-y)/I)]}}return Us}),u=R.useRef(null);R.useEffect(()=>{if(o==null||f.length===0)return;const A=f[0];if(A==null||A.x.length<2)return;const y=A.x[0],I=A.x[A.x.length-1]-y,P=y+c[0]*I,F=y+c[1]*I,L=u.current,C=Math.max(1e-10,Math.abs(F-P)*1e-12);L!=null&&Math.abs(L[0]-P)<C&&Math.abs(L[1]-F)<C||(u.current=[P,F],o(P,F))},[c,f,o]);const h=R.useRef(null),g=R.useCallback(A=>{const y=a.current;if(y==null)return 0;const M=y.getBoundingClientRect();return Q((A-M.left)/M.width,0,1)},[]),w=R.useCallback(A=>{const y=a.current;if(y==null)return;const M=g(A.clientX),I=y.getBoundingClientRect().width,P=I>0?Ns/I:0;let F;if(Math.abs(M-c[0])<P)F="left";else if(Math.abs(M-c[1])<P)F="right";else if(M>=c[0]&&M<=c[1])F="move";else{const L=c[1]-c[0],C=L/2,D=Q(M-C,0,1-L),z=[D,D+L];d(z),h.current={mode:"move",startX:A.clientX,startFrac:z},y.setPointerCapture(A.pointerId),A.preventDefault();return}h.current={mode:F,startX:A.clientX,startFrac:[...c]},y.setPointerCapture(A.pointerId),A.preventDefault()},[c,g]),v=R.useCallback(A=>{const y=h.current;if(y==null)return;const M=g(A.clientX),I=g(y.startX),P=M-I;if(y.mode==="move"){const F=y.startFrac[1]-y.startFrac[0],L=Q(y.startFrac[0]+P,0,1-F);d([L,L+F])}else if(y.mode==="left"){const F=Q(y.startFrac[0]+P,0,y.startFrac[1]-Ue);d([F,y.startFrac[1]])}else{const F=Q(y.startFrac[1]+P,y.startFrac[0]+Ue,1);d([y.startFrac[0],F])}},[g]),b=R.useCallback(A=>{h.current=null;const y=a.current;y!=null&&y.releasePointerCapture(A.pointerId)},[]),x=`${c[0]*100}%`,p=`${(c[1]-c[0])*100}%`,m=f[0],T=m!=null?m.series.length:0;return G.jsxs("div",{className:r,style:{position:"relative",width:t,height:e},children:[G.jsxs(de,{width:t,height:e,data:n,children:[G.jsx(Rt,{scale:"x",show:!1}),G.jsx(Rt,{scale:"y",show:!1}),Array.from({length:T},(A,y)=>G.jsx(pe,{group:0,index:y,yScale:"y",stroke:i!=null&&i[y]!=null?i[y]:`hsl(${y*137}, 60%, 50%)`,width:1},`0:${y}`))]}),G.jsxs("div",{ref:a,onPointerDown:w,onPointerMove:v,onPointerUp:b,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[G.jsx("div",{style:{position:"absolute",top:0,left:0,width:x,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),G.jsx("div",{style:{position:"absolute",top:0,left:`${c[1]*100}%`,right:0,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),G.jsx("div",{style:{position:"absolute",top:0,left:x,width:p,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&&G.jsxs(G.Fragment,{children:[G.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"}}),G.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 wt(t,e){const n=ot(),o=R.useRef(t);R.useLayoutEffect(()=>{o.current=t});const s=(e==null?void 0:e.clipped)!==!1;R.useLayoutEffect(()=>{const r=l=>o.current(l),i=s?n.drawHooks:n.unclippedDrawHooks;return i.add(r),()=>{i.delete(r)}},[n,s])}function Ks(t){const e=ot(),n=R.useRef(t);R.useLayoutEffect(()=>{n.current=t}),R.useLayoutEffect(()=>{const o=(s,r)=>n.current(s,r);return e.cursorDrawHooks.add(o),()=>{e.cursorDrawHooks.delete(o)}},[e])}function qs({lanes:t,laneHeight:e=24,gap:n=2,scaleId:o="x"}){const s=ot();return wt(({ctx:r,plotBox:i,pxRatio:l})=>{const a=s.scaleManager.getScale(o);if(a==null||!U(a))return;r.save();const f=(e+n)*l,c=e*l,d=i.top*l;r.fillStyle="#666",r.font=`${11*l}px sans-serif`,r.textAlign="right",r.textBaseline="middle";for(let u=0;u<t.length;u++){const h=t[u];if(h==null)continue;const g=d+u*f;r.fillText(h.label,(i.left-6)*l,g+c/2)}r.beginPath(),r.rect(i.left*l,i.top*l,i.width*l,i.height*l),r.clip();for(let u=0;u<t.length;u++){const h=t[u];if(h==null)continue;const g=d+u*f;for(const w of h.segments){const v=X(w.start,a,i.width,i.left)*l,x=X(w.end,a,i.width,i.left)*l-v;x<=0||(r.fillStyle=w.color??"#4dabf7",r.fillRect(v,g,x,c),w.label!=null&&x>20*l&&(r.fillStyle="#fff",r.font=`${10*l}px sans-serif`,r.textAlign="center",r.textBaseline="middle",r.fillText(w.label,v+x/2,g+c/2,x-4*l)))}}r.restore()},{clipped:!1}),null}function Zs({data:t,width:e=150,height:n=30,stroke:o="#03a9f4",fill:s,lineWidth:r=1,paths:i,fillTo:l,className:a}){return G.jsx("div",{style:{pointerEvents:"none"},className:a,children:G.jsxs(de,{width:e,height:n,data:t,children:[G.jsx(Rt,{scale:"x",show:!1}),G.jsx(Rt,{scale:"y",show:!1}),G.jsx(pe,{group:0,index:0,yScale:"y",stroke:o,fill:s,width:r,paths:i,fillTo:l})]})})}const gt=8,Js={x:12,y:-12},Qs={pointerEvents:"none"};function ti(t,e,n,o){if(t!=null&&typeof t=="object")return t;switch(t){case"top-left":return{x:e.left+gt,y:e.top+gt};case"bottom-left":return{x:e.left+gt,y:e.top+e.height-o-gt};case"bottom-right":return{x:e.left+e.width-n-gt,y:e.top+e.height-o-gt};case"top-right":default:return{x:e.left+e.width-n-gt,y:e.top+gt}}}function ei({mode:t="draggable",position:e="top-right",offset:n=Js,idleOpacity:o=.3,show:s=!0,className:r}){const i=ot(),l=R.useSyncExternalStore(i.subscribeCursor,i.getSnapshot),[a,f]=R.useState(null),[c,d]=R.useState(!1),[u,h]=R.useState(!1),g=R.useRef(!1),w=R.useRef(!1),v=R.useRef({dx:0,dy:0}),[b,x]=R.useState(!1),p=R.useRef(null),[m,T]=R.useState({w:0,h:0});R.useLayoutEffect(()=>{if(t!=="cursor")return;const C=p.current;if(!C)return;const D=C.offsetWidth,z=C.offsetHeight;(D!==m.w||z!==m.h)&&T({w:D,h:z})}),R.useLayoutEffect(()=>{if(t!=="draggable"||b||l.plotWidth<=0)return;x(!0);const C=p.current,D=(C==null?void 0:C.offsetWidth)??0,z=(C==null?void 0:C.offsetHeight)??0;f(ti(e,i.plotBox,D,z))},[t,b,l.plotWidth,e,i.plotBox]);const A=(C,D)=>{w.current||i.toggleSeries(C,D)},y=C=>{if(t!=="draggable")return;C.stopPropagation(),C.preventDefault(),g.current=!0,h(!0),w.current=!1;const D=C.currentTarget.getBoundingClientRect();v.current={dx:C.clientX-D.left,dy:C.clientY-D.top}};if(R.useEffect(()=>{if(!s||t!=="draggable")return;const C=z=>{var E;if(!g.current)return;w.current=!0;const S=(E=i.canvas)==null?void 0:E.parentElement;if(!S)return;const k=S.getBoundingClientRect();f({x:z.clientX-k.left-v.current.dx,y:z.clientY-k.top-v.current.dy})},D=()=>{g.current=!1,h(!1)};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",D),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",D)}},[i,s,t]),!s)return null;const{activeGroup:M,activeDataIdx:I,left:P,top:F}=l,L=i.seriesConfigs.filter(C=>C.legend!==!1).map(C=>{const D=typeof C.stroke=="string"?C.stroke:"#000",z=Bs(i,C.group,C.index,M,I),S=t==="draggable";return G.jsx(me,{label:C.label??`Series ${C.index}`,color:D,value:z,isHidden:C.show===!1,onClick:S?()=>A(C.group,C.index):void 0},`${C.group}:${C.index}`)});if(t==="cursor"){if(P<0)return null;const C=m.w,D=m.h,z=l.plotLeft+l.plotWidth,S=l.plotTop+l.plotHeight,k=Q(P+l.plotLeft+n.x,l.plotLeft,z-C),E=Q(F+l.plotTop+n.y,l.plotTop,S-D);return G.jsx(Vt,{ref:p,left:k,top:E,className:r,style:Qs,children:L})}return a==null?null:G.jsx(Vt,{ref:p,left:a.x,top:a.y,className:r,onMouseDown:y,onMouseEnter:()=>d(!0),onMouseLeave:()=>{d(!1),w.current=!1},style:{pointerEvents:"auto",cursor:u?"grabbing":"grab",opacity:c||u?1:o,transition:"opacity 0.2s ease"},children:L})}const ni={pointerEvents:"none"};function oi({delay:t=1e3,show:e=!0,className:n}){const o=ot(),s=R.useSyncExternalStore(o.subscribeCursor,o.getSnapshot),[r,i]=R.useState(!1),l=R.useRef(-1),a=R.useRef(0),f=R.useRef(null),[c,d]=R.useState({w:0,h:0});if(R.useLayoutEffect(()=>{const m=f.current;if(!m)return;const T=m.offsetWidth,A=m.offsetHeight;(T!==c.w||A!==c.h)&&d({w:T,h:A})}),R.useEffect(()=>{const m=s.activeSeriesIdx;m!==l.current&&(l.current=m,i(!1),window.clearTimeout(a.current),m>=0&&(a.current=window.setTimeout(()=>i(!0),t)))},[s.activeSeriesIdx,t]),R.useEffect(()=>()=>{window.clearTimeout(a.current)},[]),!e||!r||s.left<0)return null;const u=o.seriesConfigs.find(m=>m.group===s.activeGroup&&m.index===s.activeSeriesIdx);if(!(u!=null&&u.label)||u.legend===!1)return null;const h=typeof u.stroke=="string"?u.stroke:"#000",g=c.w,w=c.h,v=s.left+s.plotLeft,b=s.top+s.plotTop,x=Q(v-g/2,s.plotLeft,s.plotLeft+s.plotWidth-g),p=Q(b-w-12,s.plotTop,s.plotTop+s.plotHeight-w);return G.jsx(Vt,{ref:f,left:x,top:p,className:n,style:ni,children:G.jsx(me,{label:u.label,color:h})})}function wn(t,e,n,o,s,r,i,l,a){const f=i/2;if(a.wickColor!=null&&(t.strokeStyle=a.wickColor,t.lineWidth=a.wickWidth??1,t.beginPath(),t.moveTo(e,n),t.lineTo(e,o),t.stroke()),a.capWidth!=null&&a.capWidth>0){const u=a.capWidth/2;t.strokeStyle=a.wickColor??"#555",t.lineWidth=a.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 c=Math.min(s,r),d=Math.abs(r-s);t.fillStyle=a.bodyFill,t.fillRect(e-f,c,i,d),a.bodyStroke!=null&&(t.strokeStyle=a.bodyStroke,t.lineWidth=a.bodyStrokeWidth??1.5,t.strokeRect(e-f,c,i,d)),l!=null&&a.midColor!=null&&(t.strokeStyle=a.midColor,t.lineWidth=a.midWidth??2.5,t.beginPath(),t.moveTo(e-f,l),t.lineTo(e+f,l),t.stroke())}function si({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 wt(({ctx:l,plotBox:a,valToX:f,valToY:c})=>{const d=a.width/t.length*n,u=d*.3;for(let h=0;h<t.length;h++){const g=t[h];if(g==null)continue;const w=f(h+1),v=c(g.min,e),b=c(g.q1,e),x=c(g.median,e),p=c(g.q3,e),m=c(g.max,e);w==null||v==null||b==null||x==null||p==null||m==null||wn(l,w,v,m,b,p,d,x,{wickColor:i,bodyFill:o,bodyStroke:s,capWidth:u,midColor:r})}}),null}function ii(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 c=n[f],d=n[f+1];if(c!=null&&d!=null&&e>=c[0]&&e<=d[0]){o=c,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])),a=Math.round(o[3]+r*(s[3]-o[3]));return`rgb(${i},${l},${a})`}function ri({grid:t,xRange:e,yRange:n,colorMap:o=ii,yScale:s="y"}){return wt(({ctx:r,valToX:i,valToY:l})=>{var b;if(t.length===0)return;const a=t.length,f=((b=t[0])==null?void 0:b.length)??0;if(f===0)return;const c=(e==null?void 0:e[0])??0,d=(e==null?void 0:e[1])??a,u=(n==null?void 0:n[0])??0,h=(n==null?void 0:n[1])??f,g=(d-c)/a,w=(h-u)/f;let v=0;for(const x of t)for(const p of x)p>v&&(v=p);if(v!==0)for(let x=0;x<a;x++){const p=t[x];if(p==null)continue;const m=i(c+x*g),T=i(c+(x+1)*g);if(m==null||T==null)continue;const A=T-m;for(let y=0;y<f;y++){const M=p[y]??0,I=u+y*w,P=u+(y+1)*w,F=l(P,s),L=l(I,s);if(F==null||L==null)continue;const C=L-F;r.fillStyle=o(M/v),r.fillRect(m,F,A,C)}}}),null}function li(t,e,n,o,s){const r=(o-90)*(Math.PI/180),i=s,l=i*.35,a=Math.PI/6,f=e+Math.cos(r)*i,c=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,c),t.stroke(),t.beginPath(),t.moveTo(f,c),t.lineTo(f-l*Math.cos(r-a),c-l*Math.sin(r-a)),t.moveTo(f,c),t.lineTo(f-l*Math.cos(r+a),c-l*Math.sin(r+a)),t.stroke()}function ai({directions:t,group:e=0,index:n=0,color:o="#c0392b",minSize:s=4,maxSize:r=10}){const i=ot();return wt(({ctx:l,valToX:a,valToY:f})=>{var b;const c=i.dataStore.data[e];if(c==null)return;const d=c.x,u=c.series[n];if(u==null)return;let h=1/0,g=-1/0;for(let x=0;x<u.length;x++){const p=u[x];p!=null&&(p<h&&(h=p),p>g&&(g=p))}const w=g-h||1,v=((b=i.seriesConfigs.find(x=>x.group===e&&x.index===n))==null?void 0:b.yScale)??"y";l.strokeStyle=o,l.lineWidth=1.5,l.lineCap="round";for(let x=0;x<d.length;x++){const p=u[x],m=t[x];if(p==null||m==null)continue;const T=a(d[x]),A=f(p,v);if(T==null||A==null)continue;const y=(p-h)/w,M=s+y*(r-s);li(l,T,A,m,M)}}),null}const ci=4;function we(t,e){t.strokeStyle=e.stroke??"red",t.lineWidth=e.width??1,e.dash&&t.setLineDash(e.dash)}function Se(t,e){e.dash&&t.setLineDash([])}function Sn(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),we(s,o),s.stroke(),Se(s,o)}function vn(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),we(s,o),s.stroke(),Se(s,o)}function ui(t,e,n,o,s,r,i={}){const{ctx:l,plotBox:a}=t,f=X(o,e,a.width,a.left),c=X(s,n,a.height,a.top);l.font=i.font??"12px sans-serif",l.fillStyle=i.fill??"#000",l.textBaseline="bottom",l.fillText(r,f,c-ci)}function bn(t,e,n,o,s={}){const{ctx:r,plotBox:i}=t,l=X(o,e,i.height,i.top),a=X(n,e,i.height,i.top);r.fillStyle=s.fill??"rgba(255,0,0,0.1)",r.fillRect(i.left,Math.min(l,a),i.width,Math.abs(a-l)),s.stroke&&(we(r,s),r.strokeRect(i.left,Math.min(l,a),i.width,Math.abs(a-l)),Se(r,s))}function ve(t,e,n){const o=R.useRef(t);R.useLayoutEffect(()=>{o.current=t},[t]),wt(s=>{const r=s.getScale(e);r!=null&&n(s,r,o.current)})}function fi(t){return ve(t,t.yScale??"y",(e,n,o)=>{if(Sn(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 hi(t){return ve(t,t.xScale??"x",(e,n,o)=>{if(vn(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 di(t){return ve(t,t.yScale??"y",(e,n,o)=>{bn(e,n,o.yMin,o.yMax,{fill:o.fill,stroke:o.stroke,width:o.strokeWidth,dash:o.dash})}),null}function gi(t){const e=R.useRef(t);return R.useLayoutEffect(()=>{e.current=t}),wt(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 pi(t){const e=(n,o,s,r,i,l,a,f,c,d,u,h,g)=>{const w=(g==null?void 0:g.align)??t??1,v=(g==null?void 0:g.spanGaps)??!1;if([c,d]=Xt(o,c,d),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const b=P=>h(X(P,s,i,a)),x=P=>h(X(P,r,l,f)),p=s.ori===$.Horizontal?jt:Nt,m={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},T=m.stroke;let A=!1;const y=u===O.Forward?c:d;let M=x(o[y]),I=b(n[y]);p(T,I,M);for(let P=y;P>=c&&P<=d;P+=u){const F=o[P];if(F==null){F===null&&!v&&(A=!0);continue}const L=b(n[P]),C=x(F);if(w===1)p(T,L,M);else if(w===-1)p(T,I,C);else{const D=h((I+L)/2);p(T,D,M),p(T,D,C)}p(T,L,C),M=C,I=L}{const P=m.fill=new Path2D(T),F=(g==null?void 0:g.fillTo)??r.min??0,L=x(F);let C=b(n[c]),D=b(n[d]);u===O.Backward&&([D,C]=[C,D]),p(P,D,L),p(P,C,L)}if(A){const P=ce(n,o,c,d,u,b);m.gaps=P,m.clip=ue(P,s.ori,a,f,i,l)}return m};return e.defaults=Yt,e}function be(t){return t.defaults=jn,t}function xe(){return be((e,n,o,s,r,i,l,a,f,c,d,u,h)=>{const g=(h==null?void 0:h.barWidth)??.6,w=(h==null?void 0:h.barGap)??0,v=(h==null?void 0:h.barRadius)??0,b=(h==null?void 0:h.barGroupIdx)??0,x=(h==null?void 0:h.barGroupCount)??1,p=D=>u(X(D,o,r,l)),m=D=>u(X(D,s,i,a));let T=r;if(c>f){let D=1/0,z=-1;for(let S=f;S<=c;S++)if(n[S]!=null){if(z>=0){const k=e[S],E=e[z],_=Math.abs(p(k)-p(E));_<D&&(D=_)}z=S}D<1/0&&(T=D)}const A=T*(1-g),y=Math.max(0,A+w),M=Math.max(1,u(T-y)),I=x>1?Math.max(1,u(M/Math.max(1,x))):M,P=(h==null?void 0:h.fillTo)??s.min??0,F=m(P),L=new Path2D,C=o.ori===$.Horizontal;for(let D=d===O.Forward?f:c;D>=f&&D<=c;D+=d){const z=n[D];if(z==null)continue;const S=p(e[D]),k=m(z),E=x>1?(b-(x-1)/2)*I:0,_=u(S-I/2+E),W=Math.min(k,F),V=Math.max(k,F)-W;if(V!==0)if(v>0){const N=Math.min(v*I,V/2);Si(L,C,_,W,I,V,N,z<P)}else C?L.rect(_,W,I,V):L.rect(W,_,V,I)}return{stroke:L,fill:L,clip:null,band:null,gaps:null}})}function mi(t,e){const n=xe();return be((s,r,i,l,a,f,c,d,u,h,g,w,v)=>{const b={...v,barGroupIdx:t,barGroupCount:e};return n(s,r,i,l,a,f,c,d,u,h,g,w,b)})}function wi(){const t=xe();return be((n,o,s,r,i,l,a,f,c,d,u,h,g)=>{const w={barWidth:.8,...g};return t(n,o,s,r,i,l,a,f,c,d,u,h,w)})}function Si(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 xn(t){const e=(n,o,s,r,i,l,a,f,c,d,u,h,g)=>{const w=(g==null?void 0:g.spanGaps)??!1;if([c,d]=Xt(o,c,d),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const v=I=>h(X(I,s,i,a)),b=I=>h(X(I,r,l,f)),x=s.ori===$.Horizontal?jt:Nt,p=[],m=[];let T=!1;for(let I=u===O.Forward?c:d;I>=c&&I<=d;I+=u){const P=o[I];P!=null?(p.push(v(n[I])),m.push(b(P))):P===null&&!w&&(T=!0)}const A=s.ori===$.Horizontal,y=t(p,m,A,h),M={stroke:y??new Path2D,fill:null,clip:null,band:null,gaps:null};if(y!=null){const I=M.fill=new Path2D(y),P=(g==null?void 0:g.fillTo)??r.min??0,F=b(P);let L=v(n[c]),C=v(n[d]);u===O.Backward&&([C,L]=[L,C]),x(I,C,F),x(I,L,F)}if(T){const I=ce(n,o,c,d,u,v);M.gaps=I,M.clip=ue(I,s.ori,a,f,i,l)}return M};return e.defaults=Yt,e}function vi(){return xn(bi)}const bi=(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 a=new Array(s),f=new Array(s-1),c=new Array(s-1),d=new Array(s-1);for(let u=0;u<s-1;u++)c[u]=(e[u+1]??0)-(e[u]??0),d[u]=(t[u+1]??0)-(t[u]??0),f[u]=d[u]!==0?(c[u]??0)/(d[u]??1):0;a[0]=f[0]??0;for(let u=1;u<s-1;u++){const h=f[u]??0,g=f[u-1]??0;if(h===0||g===0||g>0!=h>0)a[u]=0;else{const w=d[u]??1,v=d[u-1]??1;a[u]=3*(v+w)/((2*w+v)/g+(w+2*v)/h),isFinite(a[u]??0)||(a[u]=0)}}a[s-1]=f[s-2]??0;for(let u=0;u<s-1;u++){const h=d[u]??1,g=t[u]??0,w=e[u]??0,v=t[u+1]??0,b=e[u+1]??0,x=a[u]??0,p=a[u+1]??0,m=g+h/3,T=w+x*h/3,A=v-h/3,y=b-p*h/3;n?r.bezierCurveTo(m,T,A,y,v,b):r.bezierCurveTo(T,m,y,A,b,v)}return r};function xi(){return xn(yi)}const yi=(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 a=o(t[1]??0),f=o(e[1]??0);return n?r.lineTo(a,f):r.lineTo(f,a),r}for(let a=0;a<s-1;a++){const f=a===0?0:a-1,c=t[f]??0,d=e[f]??0,u=t[a]??0,h=e[a]??0,g=t[a+1]??0,w=e[a+1]??0,v=a+2<s?t[a+2]??0:g,b=a+2<s?e[a+2]??0:w,x=Math.hypot(c-u,d-h),p=Math.hypot(u-g,h-w),m=Math.hypot(g-v,w-b),T=Math.sqrt(m),A=m,y=Math.sqrt(p),M=p,I=Math.sqrt(x),P=x,F=2*P+3*I*y+M,L=2*A+3*T*y+M,C=3*I*(I+y),D=3*T*(T+y);let z,S,k,E;if(C>0){const _=1/C;z=(-M*c+F*u+P*g)*_,S=(-M*d+F*h+P*w)*_}else z=u,S=h;if(D>0){const _=1/D;k=(A*u+L*g-M*v)*_,E=(A*h+L*w-M*b)*_}else k=g,E=w;n?r.bezierCurveTo(z,S,k,E,g,w):r.bezierCurveTo(S,z,E,k,w,g)}return r};function Mi(t=4){const e=(n,o,s,r,i,l,a,f,c,d,u,h,g)=>{const w=m=>h(X(m,s,i,a)),v=m=>h(X(m,r,l,f)),b=t/2,x=new Path2D,p=s.ori===$.Horizontal;for(let m=u===O.Forward?c:d;m>=c&&m<=d;m+=u){const T=o[m];if(T==null)continue;const A=w(n[m]),y=v(T);p?(x.moveTo(A+b,y),x.arc(A,y,b,0,Math.PI*2)):(x.moveTo(y+b,A),x.arc(y,A,b,0,Math.PI*2))}return{stroke:x,fill:x,clip:null,band:null,gaps:null}};return e.defaults=Nn,e}function Ci({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=ot();return wt(({ctx:a,plotBox:f,valToX:c,valToY:d})=>{const u=l.dataStore.data[t];if(u==null)return;const h=u.x,g=u.series[e[0]],w=u.series[e[1]],v=u.series[e[2]],b=u.series[e[3]];if(g==null||w==null||v==null||b==null)return;const x=h.length;if(x===0)return;const p=Math.max(2,f.width/x*r);for(let m=0;m<x;m++){const T=h[m],A=g[m],y=w[m],M=v[m],I=b[m];if(T==null||A==null||y==null||M==null||I==null)continue;const P=c(T),F=d(y,n),L=d(M,n),C=d(A,n),D=d(I,n);if(P==null||F==null||L==null||C==null||D==null)continue;const S=I>=A?o:s;wn(a,P,F,L,C,D,p,null,{wickColor:S,wickWidth:i,bodyFill:S})}}),null}function ki(t,e,n=0){const o=e??t.series.map((c,d)=>d),s=t.x.length,r=[],i=new Float64Array(s);for(let c=0;c<o.length;c++){const d=o[c];if(d==null)continue;const u=t.series[d];if(u==null)continue;const h=new Array(s);for(let g=0;g<s;g++){const w=u[g];w!=null?(i[g]=i[g]+w,h[g]=i[g]):h[g]=null}r.push(h)}const l=new Map;for(let c=0;c<o.length;c++){const d=o[c];d!=null&&l.set(d,c)}const a=[];for(let c=0;c<t.series.length;c++){const d=l.get(c)??-1,u=d>=0?r[d]:void 0;u!=null?a.push(u):a.push(t.series[c]??[])}const f=[];for(let c=o.length-1;c>0;c--){const d=o[c],u=o[c-1];d!=null&&u!=null&&f.push({group:n,series:[d,u]})}return{group:{x:t.x,series:a},bands:f}}function Ti(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 a=0;a<r.length;a++){const f=r[a];if(f==null)continue;const c=o.get(f);c!=null&&(l[c]=i[a]??null)}s.push(l)}return[{x:n,series:s}]}function Ai(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 Li(t,e=0){return n=>n.map(o=>o.toFixed(e)+t)}function Ii(t,e=0){return n=>n.map(o=>t+o.toFixed(e))}function Pi(t,e,n=0){return o=>o.map(s=>t+s.toFixed(n)+e)}function Ei(t){const e=(t==null?void 0:t.utc)??!1;return n=>n.map(o=>e?lt(o,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC"):lt(o,{hour:"2-digit",minute:"2-digit",hour12:!1}))}function _i(t){const e=t!=null&&t.utc?"UTC":void 0,n=(t==null?void 0:t.format)??"short";return o=>o.map(s=>lt(s,{month:n},e))}function Di(t){const{tz:e,...n}=t??{};return o=>o.map(s=>lt(s,n,e))}function Fi(t,e=0){return n=>n.map(o=>{const s=Math.round(o)-e;return t[s]??String(o)})}exports.AnnotationLabel=gi;exports.Axis=Rt;exports.Band=Cs;exports.BoxWhisker=si;exports.Candlestick=Ci;exports.Chart=de;exports.DEFAULT_ACTIONS=Bt;exports.Direction=O;exports.Distribution=K;exports.FloatingLegend=ei;exports.HLine=fi;exports.Heatmap=ri;exports.HoverLabel=oi;exports.Legend=_s;exports.Orientation=$;exports.Region=di;exports.Scale=vs;exports.Series=pe;exports.Side=j;exports.SortOrder=At;exports.Sparkline=Zs;exports.Timeline=qs;exports.Tooltip=js;exports.VLine=hi;exports.Vector=ai;exports.ZoomRanger=Os;exports.alignData=Ti;exports.bars=xe;exports.catmullRom=xi;exports.drawHLine=Sn;exports.drawLabel=ui;exports.drawRegion=bn;exports.drawVLine=vn;exports.fadeGradient=xs;exports.fmtCompact=Ai;exports.fmtDateStr=Di;exports.fmtHourMin=Ei;exports.fmtLabels=Fi;exports.fmtMonthName=_i;exports.fmtPrefix=Ii;exports.fmtSuffix=Li;exports.fmtWrap=Pi;exports.focus=Cn;exports.groupedBars=mi;exports.linear=ln;exports.lttb=fe;exports.lttbGroup=qn;exports.monotoneCubic=vi;exports.palette=ys;exports.points=Mi;exports.posToVal=ft;exports.sideOrientation=Mt;exports.stackGroup=ki;exports.stackedBars=wi;exports.stepped=pi;exports.useChart=Jo;exports.useCursorDrawHook=Ks;exports.useDrawHook=wt;exports.valToPos=X;exports.withAlpha=pn;
1
+ "use strict";var zn=Object.defineProperty;var $n=(t,e,n)=>e in t?zn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Y=(t,e,n)=>$n(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),_=require("react"),Pe=require("@chenglou/pretext");function Bn(t=.15){return e=>{e.focusAlpha=t}}const Xt=[["leftDrag","zoomX"],["leftDblclick","reset"],["wheel","zoomX"],["xGutterDrag","panX"],["yGutterDrag","panY"],["pinch","zoomX"],["touchDrag","zoomX"]];var j=(t=>(t[t.Top=0]="Top",t[t.Right=1]="Right",t[t.Bottom=2]="Bottom",t[t.Left=3]="Left",t))(j||{}),$=(t=>(t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical",t))($||{}),K=(t=>(t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward",t))(K||{}),q=(t=>(t[t.Linear=1]="Linear",t[t.Ordinal=2]="Ordinal",t[t.Log=3]="Log",t[t.Asinh=4]="Asinh",t))(q||{}),Lt=(t=>(t[t.Ascending=1]="Ascending",t[t.Descending=-1]="Descending",t[t.Unsorted=0]="Unsorted",t))(Lt||{});function Ct(t){return t%2}var st=(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))(st||{});function Ee(t){if(t==="transparent")return!0;const e=t.match(/,\s*([\d.]+)\s*\)$/);return!!(e!=null&&e[1]!=null&&parseFloat(e[1])===0||t.startsWith("#")&&(t.length===5&&t[4]==="0"||t.length===9&&t.slice(7)==="00"))}function Ft(t){var r,i;const e=typeof t.stroke=="string"?t.stroke:null,n=typeof t.fill=="string"?t.fill:null,o=e!=null&&!Ee(e),s=n!=null&&!Ee(n);return((i=(r=t.paths)==null?void 0:r.defaults)==null?void 0:i.width)===0&&s||!o&&s?n:e??"#000"}const et=Math,qt=et.PI,rt=et.abs,at=et.floor,G=et.round,Rt=et.ceil,ae=et.min,It=et.max,yt=et.pow,_e=et.sign,lt=et.log10,Et=et.log2,Gn=(t,e=1)=>et.sinh(t)*e,fe=(t,e=1)=>et.asinh(t/e),Q=1/0,un=Number.isInteger;function Zt(t,e){return t[e]??0}function wt(t,e,n=0,o=e.length-1){let s;const l=o<=2147483647;for(;o-n>1;)s=l?n+o>>1:at((n+o)/2),Zt(e,s)<t?n=s:o=s;return t-Zt(e,n)<=Zt(e,o)-t?n:o}const fn=t=>t!=null,dn=t=>t!=null&&t>0;function hn(t){return(e,n,o)=>{let s=-1,l=-1;for(let r=n;r<=o;r++)if(t(e[r])){s=r;break}for(let r=o;r>=n;r--)if(t(e[r])){l=r;break}return[s,l]}}const Nt=hn(fn),gn=hn(dn);function Vn(t,e,n,o=Lt.Unsorted,s=!1){const l=s?gn:Nt,r=s?dn:fn,[i,a]=l(t,e,n);let d=t[i]??Q,c=t[i]??-Q;if(i>-1)if(o===Lt.Ascending)d=t[i]??Q,c=t[a]??-Q;else if(o===Lt.Descending)d=t[a]??Q,c=t[i]??-Q;else for(let h=i;h<=a;h++){const u=t[h];u!=null&&r(u)&&(u<d?d=u:u>c&&(c=u))}return[d,c]}function ct(t,e=0){if(un(t))return t;const n=10**e,o=t*n*(1+Number.EPSILON);return G(o)/n}const Pt=new Map;function Xn(t){return(String(t).split(".")[1]??"").length}const Nn=/\.\d*?(?=9{6,}|0{6,})/gm;function Mt(t){if(un(t)||Pt.has(t))return t;const e=`${t}`,n=e.match(Nn);if(n==null)return t;const o=n[0].length-1;if(e.indexOf("e-")!==-1){const s=e.split("e"),l=s[0]??"0",r=s[1]??"0";return+`${Mt(+l)}e${r}`}return ct(t,o)}function Yn(t,e,n=!0){return n?Mt(ct(Mt(t/e))*e):ct(t/e)*e}function de(t,e,n=!0){return n?Mt(Rt(Mt(t/e))*e):Rt(t/e)*e}function pn(t,e,n=!0){return n?Mt(at(Mt(t/e))*e):at(t/e)*e}function On(t){return t===0?e=>e:t===1?G:e=>Yn(e,t)}function mn(t,e,n,o){const s=[],l=o.map(Xn);for(let r=e;r<n;r++){const i=rt(r);for(let a=0;a<o.length;a++){const d=o[a]??0,c=l[a]??0,h=+`${d}e${r}`,u=(r>=0?0:i)+(r>=c?0:c),f=h;s.push(f),Pt.set(f,u)}}return s}function tt(t,e,n){return ae(It(t,e),n)}const jn=new Intl.NumberFormat,wn=t=>jn.format(t);function De(t,e,n){for(;e<=n;){if(t[e]!=null)return!0;e++}return!1}const Un=.1,ht={mode:3,pad:Un,soft:null},Dt={pad:0,soft:null,mode:0},Kn={min:Dt,max:Dt};function Jt(t,e,n,o){let s;typeof n=="number"?(Dt.pad=n,Dt.soft=null,Dt.mode=0,s=Kn):s=n;const l=s.min,r=s.max,i=l.pad,a=r.pad,d=l.hard??-Q,c=r.hard??Q,h=l.soft??Q,u=r.soft??-Q,f=l.mode,g=r.mode;let w=e-t;const v=lt(w),b=It(rt(t),rt(e)),y=lt(b),p=rt(y-v);(w<1e-24||p>10)&&(w=0,(t===0||e===0)&&(w=1e-24));const m=w||b||1e3,T=lt(m),M=yt(10,at(T)),C=m*(w===0?t===0?.1:1:i),I=ct(pn(t-C,M/10),24),A=f===1||f===3&&I<=h||f===2&&I>=h,x=t>=h&&A?h:Q,D=It(d,I<x&&t>=x?x:ae(x,I)),L=m*(w===0?e===0?.1:1:a),F=ct(de(e+L,M/10),24),R=g===1||g===3&&F>=u||g===2&&F<=u,z=e<=u&&R?u:-Q,S=ae(c,F>z&&e<=z?z:It(z,F));return D===S&&D===0?[-1,1]:[D,S]}function Sn(t,e,n,o){n===2&&(o=!0);const s=_e(t),l=_e(e);t===e&&(s===-1?(t*=n,e/=n):(t/=n,e*=n));const r=n===10?lt:Et,i=s===1?at:Rt,a=l===1?Rt:at,d=r(rt(t)),c=r(rt(e)),h=i(d),u=a(c);let f=yt(n,h),g=yt(n,u);return n===10&&(h<0&&(f=ct(f,-h)),u<0&&(g=ct(g,-u))),o?(t=f*s,e=g*l):(t=pn(t,yt(n,at(d)),!1),e=de(e,yt(n,at(c)),!1)),[t,e]}function qn(t,e,n,o){const s=Sn(t,e,n,o);return t===0&&(s[0]=0),e===0&&(s[1]=0),s}function Fe(t){return(lt((t^t>>31)-(t>>31))|0)+1}function Zn(t,e,n,o,s){const l=It(Fe(t),Fe(e)),r=e-t;let i=It(0,wt(s/o*r,n)-1);do{const a=n[i]??0,d=o*a/r;if(d>=s*.9&&l+(a<5?Pt.get(a)??0:0)<=17)return[a,d]}while(++i<n.length);return[0,0]}function Jn(t){return{id:t.id,min:t.min??null,max:t.max??null,distr:t.distr??q.Linear,log:t.log??10,asinh:t.asinh??1,ori:t.ori??(t.id==="x"?$.Horizontal:$.Vertical),dir:t.dir??K.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 U(t){return t.min!=null&&t.max!=null}function ut(t){t._min=null,t._max=null}function vn(t){if(t._min!=null)return t._min;const{min:e,distr:n}=t;if(e==null)return 0;if(n===q.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?lt:Et)(o)}else n===q.Asinh?t._min=fe(e,t.asinh):t._min=e;return t._min}function bn(t){if(t._max!=null)return t._max;const{max:e,distr:n}=t;if(e==null)return 0;if(n===q.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?lt:Et)(o)}else n===q.Asinh?t._max=fe(e,t.asinh):t._max=e;return t._max}function Qn(t,e){if(e.min==null||e.max==null)return 0;const n=vn(e),s=bn(e)-n;if(s===0)return 0;const{distr:l}=e;if(l===q.Log){const r=e.log===10?lt:Et,i=t>0?t:1e-10;return(r(i)-n)/s}return l===q.Asinh?(fe(t,e.asinh)-n)/s:(t-n)/s}function to(t,e){if(e.min==null||e.max==null)return 0;const n=vn(e),o=bn(e);if(o===n)return e.min;const{distr:s}=e;return s===q.Log?Math.pow(e.log,n+t*(o-n)):s===q.Asinh?Gn(n+t*(o-n),e.asinh):n+t*(o-n)}function X(t,e,n,o){const s=Qn(t,e);let l;return e.ori===$.Horizontal?l=e.dir===K.Forward?s:1-s:l=e.dir===K.Forward?1-s:s,o+l*n}function ft(t,e,n,o){if(n===0)return e.min??0;let s=(t-o)/n;return e.ori===$.Horizontal?e.dir===K.Backward&&(s=1-s):e.dir!==K.Backward&&(s=1-s),to(s,e)}class eo{constructor(){Y(this,"scales",new Map);Y(this,"groupXScales",new Map)}addScale(e){this.scales.set(e.id,Jn(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,ut(s))}autoRangeX(e){var o,s,l,r,i,a;const n=new Map;for(const[d,c]of this.groupXScales){const h=this.scales.get(c);if(!h||!h.auto)continue;const u=e[d];if(!u||u.x.length===0)continue;const f=u.x[0],g=u.x[u.x.length-1];if(f==null||g==null)continue;const w=n.get(c);w?(w.dataMin=Math.min(w.dataMin,f),w.dataMax=Math.max(w.dataMax,g),w.groups.push(d)):n.set(c,{dataMin:f,dataMax:g,groups:[d]})}for(const[d,{dataMin:c,dataMax:h,groups:u}]of n){const f=this.scales.get(d);if(!f)continue;let g=!0,w=Q;for(const v of u){const b=e[v];if(b){for(let y=0;y<b.x.length;y++)if(Number.isInteger(b.x[y])||(g=!1),y>0){const p=b.x[y]-b.x[y-1];p>0&&p<w&&(w=p)}}}if(f._discrete=g,f.range){const[v,b]=Jt(c,h,{min:{pad:((o=f.range.min)==null?void 0:o.pad)??0,soft:((s=f.range.min)==null?void 0:s.soft)??null,mode:((l=f.range.min)==null?void 0:l.mode)??0},max:{pad:((r=f.range.max)==null?void 0:r.pad)??0,soft:((i=f.range.max)==null?void 0:i.soft)??null,mode:((a=f.range.max)==null?void 0:a.mode)??0}});f.min=v,f.max=b}else if(c===h)[f.min,f.max]=Jt(c,h,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}});else if(w<Q){const v=w/2;f.min=c-v,f.max=h+v}else f.min=c,f.max=h;f._cfgMin!=null&&(f.min=f._cfgMin),f._cfgMax!=null&&(f.max=f._cfgMax),ut(f)}}autoRange(e,n,o){var r,i,a,d,c,h;const s=new Map,l=new Map;for(const{group:u,index:f,yScale:g}of n){const w=e[u];if(!w)continue;const v=w.series[f];if(!v||v.length===0)continue;const b=o.windows.get(u),y=b?b[0]:0,p=b?b[1]:v.length-1,m=this.scales.get(g),T=(m==null?void 0:m.distr)===q.Log,[M,C]=o.getCachedMinMax(u,f,y,p,0,T),I=s.get(g),A=l.get(g);s.set(g,I!=null?Math.min(I,M):M),l.set(g,A!=null?Math.max(A,C):C)}for(const[u,f]of s){const g=this.scales.get(u);if(!g||!g.auto)continue;const w=l.get(u)??-Q;if(f===Q)continue;let v,b;if(g.distr===q.Log)[v,b]=Sn(f,w,g.log,!1);else if(g.distr===q.Asinh)[v,b]=qn(f,w,g.log,!1);else{const y=g.range??{min:ht,max:ht};[v,b]=Jt(f,w,{min:{pad:((r=y.min)==null?void 0:r.pad)??ht.pad,soft:((i=y.min)==null?void 0:i.soft)??ht.soft,mode:((a=y.min)==null?void 0:a.mode)??ht.mode},max:{pad:((d=y.max)==null?void 0:d.pad)??ht.pad,soft:((c=y.max)==null?void 0:c.soft)??ht.soft,mode:((h=y.max)==null?void 0:h.mode)??ht.mode}})}g._cfgMin!=null&&(v=g._cfgMin),g._cfgMax!=null&&(b=g._cfgMax),g.min=v,g.max=b,ut(g)}}}const no=1024;class oo{constructor(e,n=no){Y(this,"blocks");Y(this,"nBlocks");Y(this,"blockSize");Y(this,"data");Y(this,"len");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:l}=this;for(let r=0;r<o;r++){const i=r*n,a=Math.min(i+n,l);let d=1/0,c=-1/0;for(let h=i;h<a;h++){const u=e[h];u!=null&&(u<d&&(d=u),u>c&&(c=u))}s[r*2]=d,s[r*2+1]=c}}rangeMinMax(e,n){const{data:o,blockSize:s,blocks:l}=this;let r=1/0,i=-1/0;const a=Math.floor(e/s),d=Math.floor(n/s);if(a===d){for(let u=e;u<=n;u++){const f=o[u];f!=null&&(f<r&&(r=f),f>i&&(i=f))}return[r,i]}const c=(a+1)*s-1;for(let u=e;u<=c;u++){const f=o[u];f!=null&&(f<r&&(r=f),f>i&&(i=f))}for(let u=a+1;u<d;u++){const f=l[u*2]??1/0,g=l[u*2+1]??-1/0;f<r&&(r=f),g>i&&(i=g)}const h=d*s;for(let u=h;u<=n;u++){const f=o[u];f!=null&&(f<r&&(r=f),f>i&&(i=f))}return[r,i]}updateBlock(e){const{data:n,blockSize:o,blocks:s,len:l}=this;if(e>=this.nBlocks)return;const r=e*o,i=Math.min(r+o,l);let a=1/0,d=-1/0;for(let c=r;c<i;c++){const h=n[c];h!=null&&(h<a&&(a=h),h>d&&(d=h))}s[e*2]=a,s[e*2+1]=d}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 so{constructor(){Y(this,"data",[]);Y(this,"windows",new Map);Y(this,"minMaxCache",new Map);Y(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 l=this.data[e];if(!l)return;const r=l.series[n];if(!(!r||r.length===0))return s=new oo(r),this.blockTrees.set(o,s),s}updateWindows(e){var o;let n=!1;for(let s=0;s<this.data.length;s++){const l=this.data[s],r=e(s),i=this.windows.get(s);let a,d;if(!l||!r||!U(r))a=0,d=Math.max(0,((l==null?void 0:l.x.length)??1)-1);else{const c=l.x;if(c.length===0)a=0,d=0;else{a=wt(r.min,c),d=wt(r.max,c);const h=c[a],u=c[d];a>0&&h!=null&&h>r.min&&a--,d<c.length-1&&u!=null&&u<r.max&&d++}}(!i||i[0]!==a||i[1]!==d)&&(n=!0,(o=this.minMaxCache.get(s))==null||o.clear()),this.windows.set(s,[a,d])}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,l,r){let i=this.minMaxCache.get(e);const a=`${n}:${o}:${s}`;if(i){const f=i.get(a);if(f!=null)return f}else i=new Map,this.minMaxCache.set(e,i);const d=this.data[e];if(!d)return[1/0,-1/0];const c=d.series[n];if(!c||c.length===0)return[1/0,-1/0];let h;const u=!r&&l===Lt.Unsorted?this.getOrBuildTree(e,n):void 0;return u?h=u.rangeMinMax(o,s):h=Vn(c,o,s,l,r),i.set(a,h),h}getBlockTree(e,n){return this.getOrBuildTree(e,n)}appendData(e,n,o){var r;const s=this.data[e];if(!s)return;let l;Array.isArray(s.x)?l=s.x:(l=Array.from(s.x),s.x=l);for(let i=0;i<n.length;i++){const a=n[i];a!=null&&l.push(a)}for(let i=0;i<s.series.length;i++){let a=s.series[i];if(!a)continue;Array.isArray(a)||(a=Array.from(a),s.series[i]=a);const d=o[i];if(d){const h=a;for(let u=0;u<d.length;u++)h.push(d[u]??null)}const c=this.blockTrees.get(`${e}:${i}`);c&&(c.setData(a),c.grow(a.length))}(r=this.minMaxCache.get(e))==null||r.clear()}static toTypedX(e){for(const n of e)Array.isArray(n.x)&&(n.x=Float64Array.from(n.x));return e}}const zt=-10;class ro{constructor(){Y(this,"state",{left:zt,top:zt,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1});Y(this,"_groupedConfigs",new Map);Y(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=zt,this.state.top=zt,this.state.activeGroup=-1,this.state.activeSeriesIdx=-1,this.state.activeDataIdx=-1}update(e,n,o,s,l,r,i,a){this.state.left=e,this.state.top=n;let d=1/0,c=-1,h=-1,u=-1;const f=this.getGroupedConfigs(l);for(let g=0;g<s.length;g++){const w=s[g];if(w==null)continue;const v=w.x;if(v.length===0)continue;const b=a(g);if(b==null)continue;const y=r(b);if(y==null||!U(y))continue;const[p,m]=i(g),T=o.width,M=o.left,C=ft(e+M,y,T,M),I=wt(C,v,p,m),A=[I];I>p&&A.push(I-1),I<m&&A.push(I+1);const x=new Map;for(const D of A){const L=v[D];if(L==null)continue;const F=X(L,y,T,M);for(const R of f.get(g)??[]){const z=w.series[R.index];if(z==null)continue;const S=z[D];if(S==null)continue;let k=x.get(R.yScale);if(k==null&&!x.has(R.yScale)&&(k=r(R.yScale),x.set(R.yScale,k)),k==null||!U(k))continue;const P=o.height,E=o.top,W=X(S,k,P,E),H=e+M-F,V=n+E-W,N=H*H+V*V;if(N<d&&(d=N,c=g,h=R.index,u=D,N===0))break}if(d===0)break}}this.state.activeGroup=c,this.state.activeSeriesIdx=h,this.state.activeDataIdx=u}syncToValue(e,n,o=0){const s=n.dataStore.data;if(s.length===0)return;const l=o<s.length?o:0,r=s[l];if(r==null)return;const i=n.scaleManager.getGroupXScaleKey(l);if(i==null)return;const a=n.scaleManager.getScale(i);if(a==null||!U(a))return;const[d,c]=n.dataStore.getWindow(l),h=wt(e,r.x,d,c),u=r.x[h];if(u==null)return;const f=X(u,a,n.plotBox.width,n.plotBox.left);this.state.left=f-n.plotBox.left,this.state.activeGroup=l,this.state.activeDataIdx=h;let g=0,w=n.plotBox.height/2;for(const v of n.seriesConfigs){if(v.group!==l||v.show===!1)continue;const b=r.series[v.index];if(b==null)continue;const y=b[h];if(y==null)continue;const p=n.scaleManager.getScale(v.yScale);if(!(p==null||!U(p))){w=X(y,p,n.plotBox.height,n.plotBox.top)-n.plotBox.top,g=v.index;break}}this.state.top=w,this.state.activeSeriesIdx=g}}class lo{constructor(){Y(this,"flags",st.None);Y(this,"frameId",null);Y(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=st.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=st.None}}const Yt={width:1},io={width:0,fill:"auto",fillTo:0,points:{show:!1},cursor:{show:!1}},ao={width:0,cursor:{show:!1}};function Ot(t,e,n){t.lineTo(e,n)}function jt(t,e,n){t.lineTo(n,e)}function he(t,e,n,o,s,l){const r=[];let i=-1;const a=s===K.Forward?n:o,d=s===K.Forward?o:n,c=s;for(let h=a;s===K.Forward?h<=d:h>=d;h+=c)if(e[h]===null||e[h]===void 0){if(i===-1){const u=tt(h-s,n,o);i=l(t[u])}}else i!==-1&&(r.push([i,l(t[h])]),i=-1);return i!==-1&&r.push([i,l(t[o])]),r}function ge(t,e,n,o,s,l){const r=new Path2D;let i=e===$.Horizontal?n:o;const a=e===$.Horizontal?n+s:o+l,d=e===$.Horizontal?o:n,c=e===$.Horizontal?l:s;for(const[h,u]of t)h>i&&(e===$.Horizontal?r.rect(i,d,h-i,c):r.rect(d,i,c,h-i)),i=u;return i<a&&(e===$.Horizontal?r.rect(i,d,a-i,c):r.rect(d,i,c,a-i)),r}function yn(t){return(e,n,o,s,l,r)=>{o!==s&&(l!==o&&r!==o&&t(e,n,o),l!==s&&r!==s&&t(e,n,s),t(e,n,r))}}const co=yn(Ot),uo=yn(jt);function xn(){const t=(e,n,o,s,l,r,i,a,d,c,h,u,f)=>{const g=(f==null?void 0:f.spanGaps)??!1;if([d,c]=(s.distr===q.Log?gn:Nt)(n,d,c),d===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const v=I=>u(X(I,o,l,i)),b=I=>u(X(I,s,r,a));let y,p;o.ori===$.Horizontal?(y=Ot,p=co):(y=jt,p=uo);const m={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},T=m.stroke;let M=!1;if(c-d>=l*4){const I=k=>ft(k,o,l,i);let A=null,x=0,D=0,L=0,F=v(e[h===K.Forward?d:c]);const R=v(e[d]),z=v(e[c]);let S=I(h===K.Forward?R+1:z-1);for(let k=h===K.Forward?d:c;k>=d&&k<=c;k+=h){const P=e[k],W=(h===K.Forward?P<S:P>S)?F:v(P),H=n[k];W===F?H!=null?(L=H,A==null?(y(T,W,b(L)),D=A=x=L):L<A?A=L:L>x&&(x=L)):H===null&&!g&&(M=!0):(A!=null&&p(T,F,b(A),b(x),b(D),b(L)),H!=null?(L=H,y(T,W,b(L)),A=x=D=L):(A=null,x=0,H===null&&!g&&(M=!0)),F=W,S=I(F+h))}A!=null&&(A!==x?p(T,F,b(A),b(x),b(D),b(L)):y(T,F,b(L)))}else for(let I=h===K.Forward?d:c;I>=d&&I<=c;I+=h){const A=n[I];A===null&&!g?M=!0:A!=null&&y(T,v(e[I]),b(A))}{const I=m.fill=new Path2D(T),A=(f==null?void 0:f.fillTo)??s.min??0,x=b(A);let D=v(e[d]),L=v(e[c]);h===K.Backward&&([L,D]=[D,L]),y(I,L,x),y(I,D,x)}if(M){const I=he(e,n,d,c,h,v);m.gaps=I,m.clip=ge(I,o.ori,i,a,l,r)}return m};return t.defaults=Yt,t}function pe(t,e,n){const o=t.length;if(n=Math.max(2,Math.round(n)),o<=n){const u=new Uint32Array(o),f=new Float64Array(o),g=new Array(o);for(let w=0;w<o;w++)u[w]=w,f[w]=t[w],g[w]=e[w]??null;return{indices:u,x:f,y:g}}const s=[];let l=-1,r=0;for(let u=0;u<o;u++)e[u]!=null?(l===-1&&(l=u),r++):l!==-1&&(s.push([l,u-1]),l=-1);if(l!==-1&&s.push([l,o-1]),r===0)return{indices:new Uint32Array(0),x:new Float64Array(0),y:[]};if(r<=n){const u=new Uint32Array(r),f=new Float64Array(r),g=new Array(r);let w=0;for(let v=0;v<o;v++)e[v]!=null&&(u[w]=v,f[w]=t[v],g[w]=e[v],w++);return{indices:u,x:f,y:g}}const i=[];for(const[u,f]of s){const g=f-u+1,w=Math.max(2,Math.round(n*(g/r))),v=fo(t,e,u,f,w);for(const b of v)i.push(b)}const a=i.length,d=new Uint32Array(a),c=new Float64Array(a),h=new Array(a);for(let u=0;u<a;u++){const f=i[u];d[u]=f,c[u]=t[f],h[u]=e[f]}return{indices:d,x:c,y:h}}function fo(t,e,n,o,s){const l=o-n+1;if(l<=s){const c=[];for(let h=n;h<=o;h++)c.push(h);return c}const r=[];r.push(n);const i=s-2,a=(l-2)/i;let d=n;for(let c=0;c<i;c++){const h=n+1+Math.floor(c*a),u=Math.min(n+1+Math.floor((c+1)*a)-1,o-1);let f=0,g=0,w=0;if(c<i-1){const m=n+1+Math.floor((c+1)*a),T=Math.min(n+1+Math.floor((c+2)*a)-1,o-1);for(let M=m;M<=T;M++)f+=t[M],g+=e[M],w++}else f=t[o],g=e[o],w=1;w>0&&(f/=w,g/=w);const v=t[d],b=e[d];let y=h,p=-1;for(let m=h;m<=u;m++){const T=t[m],M=e[m],C=Math.abs(v*(M-g)+T*(g-b)+f*(b-M));C>p&&(p=C,y=m)}r.push(y),d=y}return r.push(o),r}function ho(t,e){const n=t.x.length;if(e=Math.max(2,Math.round(e)),n<=e)return t;const o=new Set;for(const a of t.series){const d=pe(t.x,a,e);for(let c=0;c<d.indices.length;c++)o.add(d.indices[c])}const s=Array.from(o).sort((a,d)=>a-d),l=s.length,r=new Float64Array(l);for(let a=0;a<l;a++)r[a]=t.x[s[a]];const i=[];for(const a of t.series)if(Array.isArray(a)&&a.some(c=>c===null)){const c=new Array(l);for(let h=0;h<l;h++)c[h]=a[s[h]]??null;i.push(c)}else{const c=new Float64Array(l);for(let h=0;h<l;h++)c[h]=a[s[h]];i.push(c)}return{x:r,series:i}}function go(t){const n=xn(),o=(s,l,r,i,a,d,c,h,u,f,g,w,v)=>{const b=f-u+1,y=Math.round(a*1);if(b>y*2){const p=f-u+1,m=new Float64Array(p),T=new Array(p);for(let C=0;C<p;C++)m[C]=s[u+C],T[C]=l[u+C]??null;const M=pe(m,T,y);return n(M.x,M.y,r,i,a,d,c,h,0,M.x.length-1,g,w,v)}return n(s,l,r,i,a,d,c,h,u,f,g,w,v)};return o.defaults=Yt,o}const Re=new WeakMap;function He(t,e,n){return typeof e=="string"?e:po(t,e,n)}function po(t,e,n){const o=Re.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[l,r]of e.stops)s.addColorStop(l,r);return Re.set(e,{grad:s,left:n.left,top:n.top,width:n.width,height:n.height}),s}function mo(t,e,n,o,s){if(e.show===!1)return;const l=e.alpha??1;t.save(),l<1&&(t.globalAlpha=l),n.clip&&t.clip(n.clip);const r=s??{left:0,top:0,width:t.canvas.width/o,height:t.canvas.height/o};if(e.fill&&n.fill&&(t.fillStyle=He(t,e.fill,r),t.fill(n.fill)),e.stroke){const i=(e.width??1)*o;t.strokeStyle=He(t,e.stroke,r),t.lineWidth=i,t.lineJoin=e.join??"round",t.lineCap=e.cap??"butt",e.dash&&t.setLineDash(e.dash.map(h=>h*o));const a=e.pxAlign??0,d=i%2/2;a===1&&d>0&&t.translate(d,d),t.stroke(n.stroke)}t.restore()}const wo=go(),We=64;class So{constructor(){Y(this,"ctx",null);Y(this,"pxRatio",1);Y(this,"pathCache",new Map);Y(this,"bandCache",new Map);Y(this,"scaleStamp","");Y(this,"snapshotCanvas",null);Y(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 l=this.snapshotCanvas.getContext("2d");l!=null&&typeof l.drawImage=="function"&&(l.clearRect(0,0,n,o),l.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 l of[s.xScale,s.yScale])o.has(l.id)||(o.add(l.id),n+=`${l.id}:${l.min}:${l.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 l=this.cacheKey(e,n,o,s),r=this.pathCache.get(l);if(r!=null)return this.promote(l,r),r;const i=`${e}:${n}:`;for(const[a,d]of this.pathCache){if(!a.startsWith(i))continue;const c=a.slice(i.length),h=c.indexOf(":"),u=+c.slice(0,h),f=+c.slice(h+1);if(u<=o&&f>=s)return this.promote(a,d),d}}setCachedPaths(e,n,o,s,l){if(this.pathCache.size>=We){const i=We>>2,a=this.pathCache.keys();for(let d=0;d<i;d++){const c=a.next().value;c!=null&&this.pathCache.delete(c)}}const r=this.cacheKey(e,n,o,s);this.pathCache.delete(r),this.pathCache.set(r,l)}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,l){return`${e}:${n}:${o}:${s}:${l}`}getCachedBandPath(e,n,o,s,l){return this.bandCache.get(this.bandKey(e,n,o,s,l))}setCachedBandPath(e,n,o,s,l,r){this.bandCache.set(this.bandKey(e,n,o,s,l),r)}drawSeries(e,n,o){const s=this.ctx;if(s==null||e.config.show===!1)return;const l=e.config.group,r=e.config.index,[i,a]=e.window;let d=this.getCachedPaths(l,r,i,a);if(d==null){const c=e.config.paths??wo,h=e.xScale.dir,u=On(e.config.pxAlign??0),f=a-i,g=Math.max(1,Math.ceil(f*.1)),w=e.dataX.length,v=Math.max(0,i-g),b=Math.min(w-1,a+g),y=e.config.fillTo;let p;typeof y=="function"?p=y(e.yScale.min??0,e.yScale.max??0):y===0&&e.yScale.distr===q.Log?p=1:p=y,d=c(e.dataX,e.dataY,e.xScale,e.yScale,n.width,n.height,n.left,n.top,v,b,h,u,{fillTo:p,spanGaps:e.config.spanGaps}),this.setCachedPaths(l,r,v,b,d)}mo(s,e.config,d,o,n)}draw(e,n,o,s){const l=this.ctx;if(l==null)return;const r=this.pxRatio;l.clearRect(0,0,e*r,n*r),l.save(),l.scale(r,r),l.beginPath(),l.rect(o.left,o.top,o.width,o.height),l.clip();for(const i of s)this.drawSeries(i,o,1);l.restore()}}const Mn=[1,2,2.5,5],vo=mn(10,-32,0,Mn),bo=mn(10,0,32,Mn),vt=vo.concat(bo);function yo(t,e,n,o,s){if(n<=0||e<t)return[];const l=[],r=Pt.get(n)??0,i=s?Math.ceil(t/n)*n:ct(de(t,n),r);for(let a=i;a<=e;a=ct(a+n,r))l.push(Object.is(a,-0)?0:a);return l}function Qt(t){return t.map(e=>wn(e))}function xo(t,e,n){if(t<=0||e<=0||t>=e)return[];const o=[],l=at((n===10?lt:Et)(t));let r=yt(n,l);n===10&&(r=vt[wt(r,vt)]??r);let i=r,a=r*n;n===10&&(a=vt[wt(a,vt)]??a);let d=0;do{if(i>=t&&o.push(i),i=i+r,n===10&&!Pt.has(i)){const c=Pt.get(r)??0;i=ct(i,c)}i>=a*(1-1e-10)&&(r=i,a=r*n,n===10&&(a=vt[wt(a,vt)]??a))}while(i<=e&&++d<1e4);return o}function Mo(t,e,n=1){const o=[];if(Math.max(rt(t),rt(e))===0)return[0];if(t<0){const r=rt(t);let i=yt(10,at(lt(Math.max(r,n))));for(;i>=n;){const a=-i;a>=t&&a<=e&&o.push(a),i/=10}}if(t<=0&&e>=0&&o.push(0),e>0){let r=n;const i=e;for(;r<=i;)r>=t&&r<=e&&o.push(r),r*=10}o.sort((r,i)=>r-i);const l=[];for(const r of o){const i=l[l.length-1];(l.length===0||i!=null&&rt(r-i)>1e-10)&&l.push(r)}return l}function Co(t,e){const n=e===10?lt:Et;return t.map(o=>{if(o===0)return!0;if(o<0)return!1;const s=n(o);return rt(s-Math.round(s))<1e-10})}const ko=7,To=50,Ao=16;function Lo(t,e){const o=wn(Math.max(Math.abs(t),Math.abs(e))).length*ko;return Math.max(To,o+Ao)}function Io(t,e,n,o){if(o<=0)return[0,0];const s=Ct(t.side)===$.Vertical,l=t.space??(s?30:Lo(e,n)),r=t.incrs??vt;return Zn(e,n,r,o,l)}const Po=50;function Eo(t,e,n){var i,a;if(t.size!=null)return t.size;const o=((i=t.ticks)==null?void 0:i.show)!==!1?((a=t.ticks)==null?void 0:a.size)??10:0,s=t.gap??5,l=12;if(Ct(t.side)===$.Vertical&&e!=null){let d=0;for(const h of e)h.length>d&&(d=h.length);const c=d*7;return Math.max(50,o+s+c+4)}return Math.max(50,o+s+l+3)}function _o(t){return{config:t,_show:t.show!==!1,_size:t.size??Po,_pos:0,_lpos:0,_splits:null,_values:null,_incr:0,_space:0,_rotate:0}}const Do=1,At=60,bt=3600,mt=86400,Fo=604800,xt=2592e3,Ht=31536e3,Ro=[Do,5,10,15,30,At,5*At,10*At,15*At,30*At,bt,2*bt,3*bt,4*bt,6*bt,12*bt,mt,2*mt,3*mt,7*mt,14*mt,xt,2*xt,3*xt,6*xt,Ht];function Ho(t,e,n){const o=[];if(n<=0||t>=e)return o;let s;if(n>=Ht){const l=new Date(t*1e3);for(l.setUTCMonth(0,1),l.setUTCHours(0,0,0,0),s=l.getTime()/1e3,s<t&&(l.setUTCFullYear(l.getUTCFullYear()+1),s=l.getTime()/1e3);s<=e;)o.push(s),l.setUTCFullYear(l.getUTCFullYear()+Math.round(n/Ht)),s=l.getTime()/1e3;return o}if(n>=xt){const l=new Date(t*1e3);l.setUTCDate(1),l.setUTCHours(0,0,0,0),s=l.getTime()/1e3;const r=Math.max(1,Math.round(n/xt));if(s<t&&(l.setUTCMonth(l.getUTCMonth()+1),s=l.getTime()/1e3),r>1){const i=l.getUTCMonth(),a=Math.ceil((i+1)/r)*r;l.setUTCMonth(a-1),s=l.getTime()/1e3}for(;s<=e;)o.push(s),l.setUTCMonth(l.getUTCMonth()+r),s=l.getTime()/1e3;return o}if(n>=mt){const l=new Date(t*1e3);l.setUTCHours(0,0,0,0),s=l.getTime()/1e3,s<t&&(s+=mt)}else s=Math.ceil(t/n)*n;for(let l=0;;l++){const r=s+l*n;if(r>e)break;o.push(r)}return o}const ze=new Map;function Wo(t,e){const n=JSON.stringify(t)+(e??"");let o=ze.get(n);return o==null&&(o=new Intl.DateTimeFormat(void 0,{...t,timeZone:e}),ze.set(n,o)),o}function it(t,e,n){const o=new Date(t*1e3);return Wo(e,n).format(o)}function zo(t,e){return it(t,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},e)}function $o(t,e){return it(t,{year:"numeric",month:"2-digit",day:"2-digit"},e)}function Bo(t,e){return it(t,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},e)}function Go(t,e){return it(t,{hour:"2-digit",minute:"2-digit",hour12:!1},e)}function Vo(t,e){return it(t,{month:"short",day:"numeric"},e)}function Xo(t,e){return it(t,{year:"numeric"},e)}function No(t,e){return it(t,{year:"numeric",month:"short"},e)}function Yo(t,e,n){let o;return e>=Ht?o=Xo:e>=xt?o=No:e>=Fo?o=$o:e>=mt?o=Vo:e>=bt?o=Go:e>=At?o=Bo:o=zo,t.map(s=>o(s,n))}function Oo(t,e,n,o,s){const l=e-t;if(l<=0||o<=0)return[0,0];for(const i of n){const a=l/i,d=o/a;if(d>=s)return[i,d]}const r=n[n.length-1]??Ht;return[r,o/(l/r)]}const jo=3;function Uo(t,e,n,o,s){let l=!0;for(const r of t){const i=r.config;if(i.show===!1)continue;const a=e(i.scale);if(!a||!U(a)){r._show&&(l=!1,r._show=!1);continue}else r._show||(l=!1,r._show=!0);const d=i.side,h=Ct(d)===$.Horizontal?n:o,u=a.min,f=a.max;let g,w;if(a.time){const b=i.space??80;[g,w]=Oo(u,f,Ro,h,b)}else[g,w]=Io(i,u,f,h);if(a._discrete&&g>0&&g<1&&(g=1),r._incr=g,r._space=w,w===0)continue;if(i.splits)r._splits=i.splits(u,f,g,w);else if(a.time)r._splits=Ho(u,f,g);else if(a.distr===q.Log)r._splits=xo(u,f,a.log);else if(a.distr===q.Asinh)r._splits=Mo(u,f,a.asinh);else{const b=a.distr===q.Ordinal||a._discrete;r._splits=yo(u,f,g,w,b)}if(i.values)r._values=i.values(r._splits,w,g);else if(a.time)r._values=Yo(r._splits,g);else if(a.distr===q.Log){const b=Co(r._splits,a.log),y=Qt(r._splits);r._values=y.map((p,m)=>b[m]?p:"")}else a.distr,q.Asinh,r._values=Qt(r._splits);r._rotate=d===j.Bottom?i.rotate??0:0;const v=r._size;r._size=Rt(Eo(i,r._values)),v!==r._size&&(l=!1)}return l}function $e(t,e,n,o=0){let s=t,l=e-o,r=0,i=o;for(const d of n){if(!d._show)continue;const c=d.config.side,h=Ct(c)===$.Vertical,u=d.config.label!=null?d.config.labelSize??20:0,f=d._size+u;f>0&&(h?(s-=f,c===j.Left&&(r+=f)):(l-=f,c===j.Top&&(i+=f)))}return!n.some(d=>d._show&&d.config.side===j.Top)&&i<=o&&(i+=8,l-=8),{left:r,top:i,width:Math.max(s,0),height:Math.max(l,0)}}function Ko(t,e){let n=e.top,o=e.left+e.width,s=e.top+e.height,l=e.left;function r(i,a){switch(i){case j.Top:return n-=a,n+a;case j.Right:{const d=o;return o+=a,d}case j.Bottom:{const d=s;return s+=a,d}case j.Left:return l-=a,l+a;default:return 0}}for(const i of t){if(!i._show)continue;const a=i.config.side;if(i._pos=r(a,i._size),i.config.label!=null){const d=i.config.labelSize??20;i._lpos=r(a,d)}}}function qo(t,e,n,o,s=0){for(const a of n)a._size=0;let l=!1,r=0,i={left:0,top:0,width:t,height:e};for(;!l;){r++;const a=Uo(n,o,i.width,i.height);l=r===jo||a,l||(i=$e(t,e,n,s))}return i=$e(t,e,n,s),Ko(n,i),i}const Be="top",Ge="bottom",Zo="left",Jo="right";function te(t,e){return e===1?t:t.replace(/(\d+(?:\.\d+)?)px/,(n,o)=>`${Math.round(Number(o)*e)}px`)}function Ve(t,e,n,o,s,l,r,i,a,d,c){const h=i%2/2;t.save(),t.translate(h,h),t.strokeStyle=a,t.lineWidth=i,d.length>0&&t.setLineDash(d),t.beginPath();let u=0,f=0,g=0,w=0;const v=l+(s===j.Top||s===j.Left?-r:r);o===$.Horizontal?(f=l,w=v):(u=l,g=v);for(let b=0;b<e.length;b++)n[b]!=null&&(o===$.Horizontal?u=g=e[b]??0:f=w=e[b]??0,t.moveTo(u,f),t.lineTo(g,w));t.stroke(),t.restore()}function Qo(t,e,n,o,s,l,r){const i=r??{axisStroke:"#000",gridStroke:"rgba(0,0,0,0.12)",titleFill:"#000"},a=G(o.left*s),d=G(o.top*s),c=G(o.width*s),h=G(o.height*s);for(const u of e){if(!u._show)continue;const f=u.config,g=f.side,w=Ct(g),v=n(f.scale);if(!v||!U(v))continue;const b=f.stroke??i.axisStroke,y=g===j.Top||g===j.Left?-1:1,p=u._splits,m=u._values;if(!p||!m||u._space===0)continue;const T=w===$.Horizontal?o.width:o.height,M=w===$.Horizontal?o.left:o.top,C=p.map(L=>G(X(L,v,T,M)*s)),I=m.map(L=>L===""?null:L),A=f.grid;if((A==null?void 0:A.show)!==!1){const L=(A==null?void 0:A.stroke)??i.gridStroke,F=G(((A==null?void 0:A.width)??2)*s),R=((A==null?void 0:A.dash)??[]).map(k=>k*s),z=w===$.Horizontal?d:a,S=w===$.Horizontal?h:c;Ve(t,C,I,w,2,z,S,F,L,R)}const x=f.ticks;if((x==null?void 0:x.show)!==!1){const L=(x==null?void 0:x.stroke)??b,F=G(((x==null?void 0:x.width)??1)*s),R=G(((x==null?void 0:x.size)??10)*s),z=((x==null?void 0:x.dash)??[]).map(k=>k*s),S=G(u._pos*s);Ve(t,C,I,w,g,S,R,F,L,z)}{const L=(x==null?void 0:x.show)!==!1?((x==null?void 0:x.size)??10)*s:0,F=G((f.gap??5)*s),R=G(u._pos*s),z=(L+F)*y,S=R+z,k=te(f.font??"12px system-ui, sans-serif",s),P=w===$.Horizontal?"center":g===j.Left?Jo:Zo,E=w===$.Horizontal?g===j.Bottom?Be:Ge:"middle";t.font=k,t.fillStyle=b,t.textAlign=P,t.textBaseline=E;const W=u._rotate*-qt/180;if(W!==0){const H=Math.cos(W),V=Math.sin(W);for(let N=0;N<m.length;N++){const O=m[N];if(O==null||O==="")continue;const Z=C[N]??0;t.setTransform(H,V,-V,H,Z,S),t.fillText(O,0,0)}t.setTransform(1,0,0,1,0,0)}else for(let H=0;H<m.length;H++){const V=m[H];if(V==null||V==="")continue;const N=C[H]??0,O=w===$.Horizontal?N:S,Z=w===$.Horizontal?S:N;t.fillText(V,O,Z)}}if(f.label!=null){const L=te(f.labelFont??"bold 12px system-ui, sans-serif",s);t.font=L,t.fillStyle=b,t.textAlign="center",t.textBaseline=g===j.Bottom?Be:Ge;const F=G((u._lpos+(f.labelGap??0)*y)*s);w===$.Vertical?(t.save(),t.translate(F,G(d+h/2)),t.rotate((g===j.Left?-qt:qt)/2),t.fillText(f.label,0,0),t.restore()):t.fillText(f.label,G(a+c/2),F)}const D=f.border;if((D==null?void 0:D.show)!==!1&&D!=null){const L=D.stroke??b,F=G((D.width??1)*s),R=(D.dash??[]).map(S=>S*s),z=G(u._pos*s);t.strokeStyle=L,t.lineWidth=F,R.length>0&&t.setLineDash(R),t.beginPath(),w===$.Horizontal?(t.moveTo(a,z),t.lineTo(a+c,z)):(t.moveTo(z,d),t.lineTo(z,d+h)),t.stroke(),R.length>0&&t.setLineDash([])}}if(l!=null){const u=te("bold 14px system-ui, sans-serif",s);t.font=u,t.fillStyle=i.titleFill,t.textAlign="center",t.textBaseline="top",t.fillText(l,G(a+c/2),G(4*s))}}const ts=2,es="#fff",Xe={stroke:"#607D8B",width:1,dash:[5,3],pointRadius:4,showX:!0,showY:!0};function Ne(t,e,n,o,s,l,r,i,a,d,c){var M;if(e.left<0||e.top<0)return;const h={stroke:(c==null?void 0:c.cursorStroke)??Xe.stroke},u={...Xe,...h,...a},f=o,g=G(n.left*f),w=G(n.top*f),v=G(n.width*f),b=G(n.height*f),y=G(u.width*f),p=y%2/2,m=G((n.left+e.left)*f)+p,T=G((n.top+e.top)*f)+p;if(t.save(),t.strokeStyle=u.stroke,t.lineWidth=y,t.setLineDash(u.dash.map(C=>C*f)),u.showX&&(t.beginPath(),t.moveTo(m,w),t.lineTo(m,w+b),t.stroke()),u.showY&&(t.beginPath(),t.moveTo(g,T),t.lineTo(g+v,T),t.stroke()),t.setLineDash([]),e.activeGroup>=0&&e.activeDataIdx>=0){const C=e.activeGroup,I=e.activeSeriesIdx,A=e.activeDataIdx,x=s[C];if(x!=null&&I>=0&&I<x.series.length&&A<x.x.length){const D=x.x[A],L=x.series[I],F=L!=null?L[A]:null;if(D!=null&&F!=null){let R=u.stroke,z=!0;const S=d==null?void 0:d.get(`${C}:${I}`);if(S!=null){const k=S.stroke;R=(typeof k=="string"?k:void 0)??u.stroke,z=((M=S.cursor)==null?void 0:M.show)!==!1}if(z){const k=i(C),P=k!=null?r(k):void 0,E=(S==null?void 0:S.yScale)??ns(l,C,I),W=E!=null?r(E):void 0;if(P!=null&&W!=null&&U(P)&&U(W)){const H=G(X(D,P,n.width,n.left)*f),V=G(X(F,W,n.height,n.top)*f),N=u.pointRadius*f,O=G(ts*f);t.beginPath(),t.arc(H,V,N,0,Math.PI*2),t.fillStyle=(c==null?void 0:c.pointFill)??es,t.fill(),t.strokeStyle=R,t.lineWidth=O,t.stroke()}}}}}t.restore()}function ns(t,e,n){for(const o of t)if(o.group===e&&o.index===n)return o.yScale}const ee={fill:"rgba(0,0,0,0.07)",stroke:"rgba(0,0,0,0.15)",width:1};function Ye(t,e,n,o,s,l){if(!e.show||e.width<=0)return;const r={fill:(l==null?void 0:l.selectFill)??ee.fill,stroke:(l==null?void 0:l.selectStroke)??ee.stroke},i={...ee,...r,...s},a=o,d=G((n.left+e.left)*a),c=G((n.top+e.top)*a),h=G(e.width*a),u=G(e.height*a);t.save(),t.fillStyle=i.fill,t.fillRect(d,c,h,u),i.width>0&&(t.strokeStyle=i.stroke,t.lineWidth=G(i.width*a),t.strokeRect(d,c,h,u)),t.restore()}const gt={axisStroke:"#000",gridStroke:"rgba(0,0,0,0.12)",titleFill:"#000",cursorStroke:"#607D8B",pointFill:"#fff",selectFill:"rgba(0,0,0,0.07)",selectStroke:"rgba(0,0,0,0.15)"};function Oe(t){if(t==null)return gt;const e=getComputedStyle(t),n=(o,s)=>e.getPropertyValue(o).trim()||s;return{axisStroke:n("--uplot-axis-stroke",gt.axisStroke),gridStroke:n("--uplot-grid-stroke",gt.gridStroke),titleFill:n("--uplot-title-fill",gt.titleFill),cursorStroke:n("--uplot-cursor-stroke",gt.cursorStroke),pointFill:n("--uplot-point-fill",gt.pointFill),selectFill:n("--uplot-select-fill",gt.selectFill),selectStroke:n("--uplot-select-stroke",gt.selectStroke)}}function os(t,e,n,o,s,l,r,i,a,d,c,h){const u=c/2*r,f=Math.max(1,G(c*.2))*r,g=(d==null?void 0:d.stroke)??h,w=(d==null?void 0:d.fill)??"#fff";t.save(),t.strokeStyle=g,t.fillStyle=w,t.lineWidth=f,(d==null?void 0:d.dash)!=null&&t.setLineDash(d.dash.map(v=>v*r));for(let v=i;v<=a;v++){const b=n[v];if(b==null)continue;const y=e[v];if(y==null)continue;const p=G(X(y,o,l.width,l.left)*r),m=G(X(b,s,l.height,l.top)*r);t.beginPath(),t.arc(p,m,u,0,Math.PI*2),t.fill(),t.stroke()}t.restore()}function ss(t,e,n,o,s,l,r){if(typeof t=="function")return t(e,n,o,s,l);if(t===!0)return!0;if(t===!1)return!1;const i=s-o;return i>0&&i<=l/r}function rs(t,e,n,o,s,l,r,i,a){if(i>a||i<0||!De(e,i,a)&&!De(n,i,a))return null;const d=f=>X(f,o,l.width,l.left)*r,c=f=>X(f,s,l.height,l.top)*r,h=new Path2D;let u=!1;for(let f=i;f<=a;f++){const g=e[f],w=t[f];if(g==null||w==null)continue;const v=d(w),b=c(g);u?h.lineTo(v,b):(h.moveTo(v,b),u=!0)}if(!u)return null;for(let f=a;f>=i;f--){const g=n[f],w=t[f];g==null||w==null||h.lineTo(d(w),c(g))}return h.closePath(),h}function ls(t,e,n){t.save(),t.fillStyle=e.fill??"rgba(0, 120, 255, 0.1)",t.fill(n),t.restore()}function is(t){const e=t.dataStore.data;if(e.length===0)return;if(!t.scaleManager.getScale("x")){const r={id:"x",auto:!0};t.scaleConfigs.push(r),t.scaleManager.addScale(r)}for(let r=0;r<e.length;r++)t.scaleManager.getGroupXScaleKey(r)||t.scaleManager.setGroupXScale(r,"x");const n=new Set(t.scaleConfigs.map(r=>r.id)),o=new Set;for(const r of t.seriesConfigs)o.add(r.yScale);o.size===0&&!n.has("y")&&o.add("y");for(const r of o)if(!n.has(r)){const i={id:r,auto:!0};t.scaleConfigs.push(i),t.scaleManager.addScale(i),n.add(r)}if(!t.axisConfigs.some(r=>r.scale==="x"))t.axisConfigs.push({scale:"x",side:j.Bottom,show:!0,label:t.xlabel??"X Axis",_default:!0});else{const r=t.axisConfigs.find(i=>i.scale==="x"&&i._default===!0);r!=null&&(r.label=t.xlabel??"X Axis")}const l=new Set(t.axisConfigs.map(r=>r.scale));for(const r of o)if(!l.has(r))t.axisConfigs.push({scale:r,side:j.Left,show:!0,label:t.ylabel??"Y Axis",_default:!0}),l.add(r);else{const i=t.axisConfigs.find(a=>a.scale===r&&a._default===!0);i!=null&&(i.label=t.ylabel??"Y Axis")}}function $t(t,e,n,o){return{ctx:t,plotBox:e,pxRatio:n,getScale:o,valToX:(r,i="x")=>{const a=o(i);return a==null||!U(a)?null:X(r,a,e.width,e.left)},valToY:(r,i)=>{const a=o(i);return a==null||!U(a)?null:X(r,a,e.height,e.top)}}}const as={left:-10,top:-10,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1,plotLeft:0,plotTop:0,plotWidth:0,plotHeight:0,seriesCount:0,revision:-1};function je(t){const{left:e,top:n,activeGroup:o,activeSeriesIdx:s,activeDataIdx:l}=t.cursorManager.state,{left:r,top:i,width:a,height:d}=t.plotBox,c=t.seriesConfigs.length,{revision:h}=t,u=t.snapshot;u.left===e&&u.top===n&&u.activeGroup===o&&u.activeSeriesIdx===s&&u.activeDataIdx===l&&u.plotLeft===r&&u.plotTop===i&&u.plotWidth===a&&u.plotHeight===d&&u.seriesCount===c&&u.revision===h||(t.snapshot={left:e,top:n,activeGroup:o,activeSeriesIdx:s,activeDataIdx:l,plotLeft:r,plotTop:i,plotWidth:a,plotHeight:d,seriesCount:c,revision:h})}function ne(t){t.seriesConfigMap.clear();for(const e of t.seriesConfigs)t.seriesConfigMap.set(`${e.group}:${e.index}`,e)}function cs(){const t={scaleManager:new eo,dataStore:new so,renderer:new So,cursorManager:new ro,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 lo,drawHooks:new Set,unclippedDrawHooks:new Set,cursorDrawHooks:new Set,focusedSeries:null,focusAlpha:1,actionMap:new Map(Xt),title:void 0,xlabel:void 0,ylabel:void 0,snapshot:as,revision:0,eventCallbacks:{},themeCache:Oe(null),_prevScaleRanges:new Map,_prevPlotBox:null,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),ne(t),t.renderer.clearGroupCache(e.group)},unregisterSeries(e,n){t.seriesConfigs=t.seriesConfigs.filter(o=>!(o.group===e&&o.index===n)),ne(t),t.renderer.clearGroupCache(e)},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,o){const s=o??t.pxRatio;t.width===e&&t.height===n&&t.pxRatio===s||(t.pxRatio=s,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())},scheduleRedraw(){t.scheduler.mark(st.Full)},scheduleCursorRedraw(){t.scheduler.mark(st.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:l,height:r,pxRatio:i,canvas:a,scheduler:d}=t;if(a==null||l===0||r===0)return;const c=a.getContext("2d");if(c==null)return;o.setContext(c,i);const u=(d.dirty&~(st.Cursor|st.Select))===0,f=p=>e.getScale(p);if(u&&o.restoreSnapshot(c)){if(Ne(c,t.cursorManager.state,t.plotBox,i,n.data,s,f,p=>e.getGroupXScaleKey(p),void 0,t.seriesConfigMap,t.themeCache),Ye(c,t.selectState,t.plotBox,i,void 0,t.themeCache),t.cursorDrawHooks.size>0){c.save(),c.scale(i,i);const p=$t(c,t.plotBox,i,f);for(const m of t.cursorDrawHooks)try{m(p,t.cursorManager.state)}catch(T){console.warn("[uPlot+] draw hook error:",T)}c.restore()}je(t);for(const p of t.cursorListeners)p();return}t.themeCache=Oe(a),is(t),e.autoRangeX(n.data),n.updateWindows(p=>{const m=e.getGroupXScaleKey(p);return m!=null?e.getScale(m):void 0});const g=s.map(p=>({group:p.group,index:p.index,yScale:p.yScale}));if(e.autoRange(n.data,g,n),us(t),t.axisStates.length>0){const p=t.title!=null?20:0;t.plotBox=qo(l,r,t.axisStates,f,p)}else t.plotBox={left:10,top:10,width:l-20,height:r-20};const w=t._prevPlotBox,v=t.plotBox;w!=null&&(w.left!==v.left||w.top!==v.top||w.width!==v.width||w.height!==v.height)&&o.clearCache(),t._prevPlotBox={...v},c.clearRect(0,0,l*i,r*i),t.axisStates.length>0&&Qo(c,t.axisStates,f,t.plotBox,i,t.title,t.themeCache);const b=[];for(const p of s){const m=e.getGroupXScaleKey(p.group),T=m!=null?e.getScale(m):void 0,M=e.getScale(p.yScale);T==null||M==null||b.push({config:p,dataX:n.getXValues(p.group),dataY:n.getYValues(p.group,p.index),xScale:T,yScale:M,window:n.getWindow(p.group)})}o.checkScaleStamp(b),c.save(),c.scale(i,i),c.beginPath(),c.rect(t.plotBox.left,t.plotBox.top,t.plotBox.width,t.plotBox.height),c.clip();for(let p=0;p<b.length;p++){const m=b[p];m!=null&&(t.focusedSeries!=null&&p!==t.focusedSeries?(c.globalAlpha=t.focusAlpha,o.drawSeries(m,t.plotBox,1),c.globalAlpha=1):o.drawSeries(m,t.plotBox,1))}const y=new Map;for(const p of s)y.set(`${p.group}-${p.index}`,p);for(const p of t.bandConfigs){const m=e.getGroupXScaleKey(p.group),T=m!=null?e.getScale(m):void 0,M=y.get(`${p.group}-${p.series[0]}`),C=y.get(`${p.group}-${p.series[1]}`);if(T==null||M==null||C==null)continue;const I=e.getScale(M.yScale);if(I==null)continue;const[A,x]=n.getWindow(p.group),D=p.series[0],L=p.series[1];let F=o.getCachedBandPath(p.group,D,L,A,x);F==null&&(F=rs(n.getXValues(p.group),n.getYValues(p.group,D),n.getYValues(p.group,L),T,I,t.plotBox,i,A,x)??void 0,F!=null&&o.setCachedBandPath(p.group,D,L,A,x,F)),F!=null&&ls(c,p,F)}for(const p of b){const m=p.config;if(m.show===!1)continue;const T=m.points,M=m.width??1,C=(T==null?void 0:T.size)??3+M*2,I=(T==null?void 0:T.space)??C*2,[A,x]=p.window;ss(T==null?void 0:T.show,m.group,m.index,A,x,t.plotBox.width,I)&&os(c,p.dataX,p.dataY,p.xScale,p.yScale,t.plotBox,i,A,x,T,C,(typeof m.stroke=="string"?m.stroke:null)??"#000")}if(c.restore(),t.drawHooks.size>0){c.save(),c.beginPath(),c.rect(t.plotBox.left*i,t.plotBox.top*i,t.plotBox.width*i,t.plotBox.height*i),c.clip(),c.scale(i,i);const p=$t(c,t.plotBox,i,f);for(const m of t.drawHooks)try{m(p)}catch(T){console.warn("[uPlot+] draw hook error:",T)}c.restore()}if(t.unclippedDrawHooks.size>0){c.save(),c.scale(i,i);const p=$t(c,t.plotBox,i,f);for(const m of t.unclippedDrawHooks)try{m(p)}catch(T){console.warn("[uPlot+] draw hook error:",T)}c.restore()}if(t.cursorManager.state.left>=0&&(o.saveSnapshot(c,l*i,r*i),t.cursorManager.update(t.cursorManager.state.left,t.cursorManager.state.top,t.plotBox,n.data,s,f,p=>n.getWindow(p),p=>e.getGroupXScaleKey(p))),Ne(c,t.cursorManager.state,t.plotBox,i,n.data,s,f,p=>e.getGroupXScaleKey(p),void 0,t.seriesConfigMap,t.themeCache),Ye(c,t.selectState,t.plotBox,i,void 0,t.themeCache),t.cursorDrawHooks.size>0){c.save(),c.scale(i,i);const p=$t(c,t.plotBox,i,f);for(const m of t.cursorDrawHooks)try{m(p,t.cursorManager.state)}catch(T){console.warn("[uPlot+] draw hook error:",T)}c.restore()}je(t);for(const p of t.listeners)p();for(const p of t.cursorListeners)p();if(t._prevScaleRanges.size>0&&t.eventCallbacks.onScaleChange!=null)for(const p of e.getAllScales()){if(!U(p))continue;const m=t._prevScaleRanges.get(p.id);if(m==null||m.min!==p.min||m.max!==p.max)try{t.eventCallbacks.onScaleChange(p.id,p.min,p.max)}catch(T){console.warn("[uPlot+] event callback error:",T)}}t._prevScaleRanges.clear();for(const p of e.getAllScales())U(p)&&t._prevScaleRanges.set(p.id,{min:p.min,max:p.max})},getSnapshot:()=>t.snapshot,updateScale(e){t.scaleConfigs=t.scaleConfigs.map(n=>n.id===e.id?e:n),t.scaleManager.addScale(e),t.renderer.clearCache()},updateSeries(e){t.seriesConfigs=t.seriesConfigs.map(n=>n.group===e.group&&n.index===e.index?e:n),ne(t),t.renderer.invalidateSeries(e.group,e.index)},registerAxis(e){t.axisConfigs=t.axisConfigs.filter(n=>!(n.scale===e.scale&&n.side===e.side)),t.axisConfigs.push(e)},unregisterAxis(e,n){t.axisConfigs=t.axisConfigs.filter(o=>!(o.scale===e&&o.side===n))},updateAxis(e){t.axisConfigs=t.axisConfigs.map(n=>n.scale===e.scale&&n.side===e.side?e:n)},registerBand(e){t.bandConfigs.push(e)},unregisterBand(e){t.bandConfigs=t.bandConfigs.filter(n=>n!==e)},setData(e){t.dataStore.setData(e),t.renderer.clearCache()},setCanvas(e){t.canvas=e},setLabels(e,n,o){t.title=e,t.xlabel=n,t.ylabel=o,t.scheduleRedraw()},redrawSync(){t.scheduler.cancel(),t.scheduler.mark(st.Full),t.redraw(),t.scheduler.clear()}};return t.scheduler.onRedraw(()=>t.redraw()),t}function us(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 l=`${s.scale}:${s.side}`,r=o.get(l);return r!=null?(r.config=s,r):_o(s)})}function fs(){const t=_.useRef(null);return t.current??(t.current=cs()),t.current}const Cn=_.createContext(null);function nt(){const t=_.useContext(Cn);if(!t)throw new Error("useChart must be used within a <Chart> component");return t}function ds(t="cursor"){const e=nt(),n=t==="full"?e.subscribe:e.subscribeCursor,o=_.useSyncExternalStore(n,e.getSnapshot);return{left:o.left,top:o.top,activeGroup:o.activeGroup,activeSeriesIdx:o.activeSeriesIdx,activeDataIdx:o.activeDataIdx,plotLeft:o.plotLeft,plotTop:o.plotTop,plotWidth:o.plotWidth,plotHeight:o.plotHeight,seriesCount:o.seriesCount,revision:o.revision,getScale:s=>e.scaleManager.getScale(s),getPlotBox:()=>e.plotBox,getSeriesConfigs:()=>e.seriesConfigs,getDataX:s=>e.dataStore.getXValues(s),getDataY:(s,l)=>e.dataStore.getYValues(s,l),toggleSeries:(s,l)=>e.toggleSeries(s,l),setFocus:s=>e.setFocus(s)}}const Ue=5,kn=.001,hs=.1,gs=10;function me(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 ps(t){return me(t,"Drag")}function ms(t){return me(t,"Click")}function ws(t){return me(t,"Dblclick")}function Ss(t){const e=t.shiftKey?"shift":t.altKey?"alt":t.ctrlKey?"ctrl":"";return e?`${e}Wheel`:"wheel"}function vs(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 bs(t,e,n,o,s=!0){const l=t.get(e);if(l!=null)return l;if(s){for(const[r,i]of t)if(typeof r=="function"&&r(n,o))return i}}function ys(t,e){const n=[];for(const o of t.scaleManager.getAllScales())U(o)&&(e!=null&&!e(o.ori)||n.push({id:o.id,ori:o.ori,dir:o.dir,startMin:o.min,startMax:o.max}));return n}function _t(t){const e=t.eventCallbacks.onScaleChange;if(e!=null)for(const n of t.scaleManager.getAllScales()){if(!U(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 oe(t,e,n,o){if(!(e instanceof WheelEvent))return;const s=tt(1-e.deltaY*kn,hs,gs),l=t.plotBox;for(const r of t.scaleManager.getAllScales()){if(!U(r)||!o(r.ori))continue;const i=r.ori===$.Horizontal,a=i?l.width:l.height,d=i?l.left:l.top,c=i?n.cx+l.left:n.cy+l.top,h=ft(c,r,a,d),u=h-(h-r.min)*s,f=h+(r.max-h)*s;r.min=Math.min(u,f),r.max=Math.max(u,f),r.auto=!1,ut(r)}t.scheduleRedraw(),_t(t)}function se(t,e,n){const o={show:!1,left:0,top:0,width:0,height:0},s=e.cx,l=e.cy;return{onMove(r,i,a){const d=t.plotBox,c=tt(a.cx,0,d.width),h=tt(a.cy,0,d.height);o.show=!0,o.left=Math.min(s,c),o.top=Math.min(l,h),o.width=Math.abs(c-s),o.height=Math.abs(h-l),n($.Vertical)||(o.top=0,o.height=d.height),n($.Horizontal)||(o.left=0,o.width=d.width),t.selectState=o,t.scheduler.mark(st.Cursor|st.Select)},onEnd(r,i,a){const d=n($.Horizontal)&&o.width>Ue,c=n($.Vertical)&&o.height>Ue;if(d||c){let h=!0;if(t.eventCallbacks.onSelect!=null){const u=Cs(t,o);let f;try{f=t.eventCallbacks.onSelect(u)}catch(g){console.warn("[uPlot+] event callback error:",g)}f===!1&&(h=!1)}h&&(xs(t,o,n),_t(t))}o.show=!1,o.left=0,o.width=0,t.selectState=o,t.scheduleRedraw()}}}function xs(t,e,n){const o=t.plotBox;for(const s of t.scaleManager.getAllScales()){if(!U(s)||!n(s.ori))continue;const l=s.ori===$.Horizontal,r=l?o.width:o.height,i=l?o.left:o.top,a=l?e.left:e.top,d=l?e.width:e.height,c=a/r,h=(a+d)/r,u=ft(i+c*r,s,r,i),f=ft(i+h*r,s,r,i);s.min=Math.min(u,f),s.max=Math.max(u,f),s.auto=!1,ut(s)}}function re(t,e,n,o){const s=ys(t,n),l=e.clientX,r=e.clientY;return{onMove(i,a){const d=t.plotBox,c=a;for(const h of s){const u=t.scaleManager.getScale(h.id);if(u==null)continue;const f=h.ori===$.Horizontal,g=f?d.width:d.height,w=f?c.clientX-l:c.clientY-r,v=(f?-1:1)*h.dir,b=h.startMax-h.startMin;u.min=h.startMin+v*(w/g)*b,u.max=h.startMax+v*(w/g)*b,u.auto=!1,ut(u)}t.renderer.clearCache(),t.scheduleRedraw()},onEnd(){_t(t)}}}function Ke(t,e,n){var c;if(n.scaleId==null||n.ori==null)return;const o=t.scaleManager.getScale(n.scaleId);if(o==null||!U(o))return;const s=n.ori===$.Vertical,l=(c=e.target.closest("div"))==null?void 0:c.getBoundingClientRect();if(l==null)return;const r=s?e.clientY-l.top:e.clientX-l.left,i=o.min,a=o.max,d=n.scaleId;return{onMove(h,u){const f=t.plotBox,g=u,w=s?f.height:f.width,b=((s?g.clientY-l.top:g.clientX-l.left)-r)/w,y=(s?1:-1)*o.dir,p=a-i,m=t.scaleManager.getScale(d);m!=null&&(m.min=i+y*b*p,m.max=a+y*b*p,m.auto=!1,ut(m),t.renderer.clearCache(),t.scheduleRedraw())},onEnd(){_t(t)}}}function le(t,e,n){if(!(e instanceof WheelEvent))return;const o=e.deltaY*kn*10;for(const s of t.scaleManager.getAllScales()){if(!U(s)||!n(s.ori))continue;const l=s.max-s.min;s.min+=o*l,s.max+=o*l,s.auto=!1,ut(s)}t.renderer.clearCache(),t.scheduleRedraw(),_t(t)}const Bt=t=>t===$.Horizontal,Gt=t=>t===$.Vertical,Vt=()=>!0;function Ms(t){switch(t){case"zoomX":return(e,n,o)=>{if(n instanceof WheelEvent){oe(e,n,o,Bt);return}return se(e,o,Bt)};case"zoomY":return(e,n,o)=>{if(n instanceof WheelEvent){oe(e,n,o,Gt);return}return se(e,o,Gt)};case"zoomXY":return(e,n,o)=>{if(n instanceof WheelEvent){oe(e,n,o,Vt);return}return se(e,o,Vt)};case"panX":return(e,n,o)=>{if(n instanceof WheelEvent){le(e,n,Bt);return}return o.scaleId!=null?Ke(e,n,o):re(e,n,Bt)};case"panY":return(e,n,o)=>{if(n instanceof WheelEvent){le(e,n,Gt);return}return o.scaleId!=null?Ke(e,n,o):re(e,n,Gt)};case"panXY":return(e,n,o)=>{if(n instanceof WheelEvent){le(e,n,Vt);return}return re(e,n,Vt)};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 qe(t){return typeof t=="function"?t:Ms(t)}function Cs(t,e){const n=t.plotBox,o=e.left/n.width,s=(e.left+e.width)/n.width,l={};for(const r of t.scaleManager.getAllScales()){if(r.ori!==$.Horizontal||!U(r))continue;const i=ft(n.left+o*n.width,r,n.width,n.left),a=ft(n.left+s*n.width,r,n.width,n.left);l[r.id]={min:Math.min(i,a),max:Math.max(i,a)}}return{left:o,right:s,ranges:l}}function ks(t,e){_.useEffect(()=>{if(e!=null)return Ts(t,e)},[t,e])}function Ts(t,e){let n=null,o=!1,s=null,l=-1,r=-1;function i(S){const k=e.getBoundingClientRect(),P=t.plotBox;return{cx:S.clientX-k.left-P.left,cy:S.clientY-k.top-P.top}}function a(S,k){const P=t.plotBox;return S>=0&&S<=P.width&&k>=0&&k<=P.height}function d(S,k){const P=e.getBoundingClientRect(),E=S-P.left,W=k-P.top,H=t.plotBox;for(const V of t.axisStates){const N=V.config,O=N.side;if(V._size<=0)continue;const ot=W>=H.top&&W<=H.top+H.height,J=E>=H.left&&E<=H.left+H.width;if(O===j.Left&&E<H.left&&ot||O===j.Right&&E>H.left+H.width&&ot||O===j.Top&&W<H.top&&J||O===j.Bottom&&W>H.top+H.height&&J)return{scaleId:N.scale,ori:Ct(O)}}return null}function c(S){const{cx:k,cy:P}=i(S);return{cx:k,cy:P,inPlot:a(k,P)}}function h(S){if(n==null){g();return}e.contains(S.target)||(o=!0,n.onMove(t,S,c(S)),y(S,S))}function u(S){g(),n!=null&&(e.contains(S.target)||(n.onEnd(t,S,c(S)),n=null,l=-1,r=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw()))}function f(){document.addEventListener("mousemove",h),document.addEventListener("mouseup",u)}function g(){document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)}function w(){n!=null&&(n=null,g(),t.cursorManager.hide(),t.scheduleCursorRedraw())}function v(S,k,P){const E=t.cursorManager.state;let W=null;if(E.activeGroup>=0&&E.activeDataIdx>=0){const H=t.dataStore.data[E.activeGroup];if(H!=null){const V=H.x[E.activeDataIdx],N=H.series[E.activeSeriesIdx],O=N!=null?N[E.activeDataIdx]:void 0;if(V!=null&&O!=null){const Z=t.plotBox,ot=t.scaleManager.getGroupXScaleKey(E.activeGroup),J=ot!=null?t.scaleManager.getScale(ot):void 0,dt=t.seriesConfigMap.get(`${E.activeGroup}:${E.activeSeriesIdx}`),kt=dt!=null?t.scaleManager.getScale(dt.yScale):void 0;let Tt=k,Kt=P;J!=null&&U(J)&&(Tt=X(V,J,Z.width,Z.left)-Z.left),kt!=null&&U(kt)&&(Kt=X(O,kt,Z.height,Z.top)-Z.top);const Le=k-Tt,Ie=P-Kt;W={group:E.activeGroup,seriesIdx:E.activeSeriesIdx,dataIdx:E.activeDataIdx,xVal:V,yVal:O,pxX:Tt,pxY:Kt,dist:Math.sqrt(Le*Le+Ie*Ie)}}}}return{plotX:k,plotY:P,point:W,srcEvent:S}}function b(S,k,P,E=!0){const W=bs(t.actionMap,S,k,P,E);if(!(W==null||W==="none"))return qe(W)}function y(S,k){const{cx:P,cy:E}=i(S);if(!a(P,E)&&n==null){l=-1,r=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw();return}const W=P!==l||E!==r;if(l=P,r=E,t.cursorManager.update(P,E,t.plotBox,t.dataStore.data,t.seriesConfigs,H=>t.scaleManager.getScale(H),H=>t.dataStore.getWindow(H),H=>t.scaleManager.getGroupXScaleKey(H)),W){const H={cx:P,cy:E,inPlot:a(P,E)},V=t.actionMap.get("hover");if(V!=null&&V!=="none"){const N=qe(V);if(N!=null&&N(t,k??S,H),t.focusAlpha<1){const O=t.cursorManager.state;if(O.activeGroup>=0&&O.activeSeriesIdx>=0){const Z=t.seriesConfigs.findIndex(ot=>ot.group===O.activeGroup&&ot.index===O.activeSeriesIdx);Z>=0&&t.focusedSeries!==Z&&(t.focusedSeries=Z,t.scheduleRedraw())}}}}if(k!=null&&t.eventCallbacks.onCursorMove!=null&&a(P,E))try{t.eventCallbacks.onCursorMove(v(k,P,E))}catch(H){console.warn("[uPlot+] event callback error:",H)}t.scheduleCursorRedraw()}function p(){document.activeElement!==e&&e.focus()}function m(S){const k=c(S),P=d(S.clientX,S.clientY);let E;if(P!=null&&S.button===0)E=P.ori===$.Horizontal?"xGutterDrag":"yGutterDrag",k.scaleId=P.scaleId,k.ori=P.ori;else if(E=ps(S),!k.inPlot)return;k.action=E;const W=b(E,S,k,!1);if(W==null)return;(S.button!==0||P!=null)&&S.preventDefault();const H=W(t,S,k);H!=null&&(n=H,o=!1,f())}function T(S){if(n!=null){o=!0,n.onMove(t,S,c(S)),y(S,S);return}y(S,S)}function M(S){if(n!=null){n.onEnd(t,S,c(S)),n=null;return}}function C(S){if(o){o=!1;return}const k=c(S);if(!k.inPlot)return;const P=ms(S);k.action=P;const E=b(P,S,k);E!=null&&E(t,S,k);const W=t.eventCallbacks.onClick;if(W!=null)try{W(v(S,k.cx,k.cy))}catch(H){console.warn("[uPlot+] event callback error:",H)}}function I(S){if(n!=null){S.preventDefault();return}const k=c(S);if(!k.inPlot)return;S.preventDefault(),k.action="rightClick";const P=b("rightClick",S,k);P!=null&&P(t,S,k);const E=t.eventCallbacks.onContextMenu;if(E!=null)try{E(v(S,k.cx,k.cy))}catch(W){console.warn("[uPlot+] event callback error:",W)}}function A(S){var k,P;if(n==null){l=-1,r=-1,t.cursorManager.hide(),t.focusedSeries!=null&&t.setFocus(null),t.scheduleCursorRedraw();try{(P=(k=t.eventCallbacks).onCursorLeave)==null||P.call(k)}catch(E){console.warn("[uPlot+] event callback error:",E)}}}function x(S){const k=c(S);if(!k.inPlot)return;if(t.eventCallbacks.onDblClick!=null){let W;try{W=t.eventCallbacks.onDblClick(v(S,k.cx,k.cy))}catch(H){console.warn("[uPlot+] event callback error:",H)}if(W===!1)return}const P=ws(S);k.action=P;const E=b(P,S,k,!1);E!=null&&E(t,S,k)}function D(S){const k=c(S);if(!k.inPlot)return;const P=Ss(S);k.action=P;const E=b(P,S,k);E!=null&&(S.preventDefault(),E(t,S,k))}function L(S){if(S.touches.length===2){const H=S.touches[0],V=S.touches[1],N=V.clientX-H.clientX,O=V.clientY-H.clientY;s={dist:Math.sqrt(N*N+O*O),midX:(H.clientX+V.clientX)/2,midY:(H.clientY+V.clientY)/2},n=null;return}const k=S.touches[0];if(k==null)return;const P=c(k);if(!P.inPlot)return;const E=b("touchDrag",S,P);if(E==null)return;const W=E(t,S,P);W!=null&&(n=W,o=!1)}function F(S){if(S.touches.length===2&&s!=null){S.preventDefault();const P=S.touches[0],E=S.touches[1],W=E.clientX-P.clientX,H=E.clientY-P.clientY,V=Math.sqrt(W*W+H*H),N=c({clientX:s.midX,clientY:s.midY});if(b("pinch",S,N)!=null){const Z=V/s.dist,ot=t.plotBox;for(const J of t.scaleManager.getAllScales()){if(J.ori!==$.Horizontal||!U(J))continue;const dt=ft(N.cx+ot.left,J,ot.width,ot.left),kt=dt-(dt-J.min)/Z,Tt=dt+(J.max-dt)/Z;J.min=Math.min(kt,Tt),J.max=Math.max(kt,Tt),J.auto=!1,ut(J)}s.dist=V,t.renderer.clearCache(),t.scheduleRedraw(),_t(t)}return}const k=S.touches[0];if(k!=null){if(n!=null){o=!0,n.onMove(t,S,c(k)),y(k,S),S.preventDefault();return}y(k,S)}}function R(S){if(s!=null){s=null;return}const k=S.changedTouches[0];k!=null&&n!=null&&(n.onEnd(t,S,c(k)),n=null)}function z(S){const k={cx:l,cy:r,inPlot:l>=0&&r>=0},P=vs(S);k.action=P;const E=b(P,S,k);E!=null&&(S.preventDefault(),E(t,S,k))}return e.addEventListener("mouseenter",p),e.addEventListener("mousemove",T),e.addEventListener("mousedown",m),e.addEventListener("mouseup",M),e.addEventListener("click",C),e.addEventListener("contextmenu",I),e.addEventListener("mouseleave",A),e.addEventListener("dblclick",x),e.addEventListener("wheel",D,{passive:!1}),e.addEventListener("touchstart",L,{passive:!0}),e.addEventListener("touchmove",F,{passive:!1}),e.addEventListener("touchend",R),e.addEventListener("keydown",z),window.addEventListener("blur",w),()=>{g(),e.removeEventListener("mouseenter",p),e.removeEventListener("mousemove",T),e.removeEventListener("mousedown",m),e.removeEventListener("mouseup",M),e.removeEventListener("click",C),e.removeEventListener("contextmenu",I),e.removeEventListener("mouseleave",A),e.removeEventListener("dblclick",x),e.removeEventListener("wheel",D),e.removeEventListener("touchstart",L),e.removeEventListener("touchmove",F),e.removeEventListener("touchend",R),e.removeEventListener("keydown",z),window.removeEventListener("blur",w)}}const ce=new Map;function As(t){let e=ce.get(t);return e==null&&(e=new Ls(t),ce.set(t,e)),e}class Ls{constructor(e){Y(this,"key");Y(this,"members",new Set);Y(this,"publishing",!1);Y(this,"syncedStores",new WeakSet);this.key=e}join(e){this.members.add(e)}leave(e){this.members.delete(e),this.members.size===0&&ce.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 i of this.members)i!==e&&(this.syncedStores.add(i),i.cursorManager.hide(),i.scheduleCursorRedraw());this.publishing=!1;return}const r=e.dataStore.getXValues(o)[s];if(r==null){this.publishing=!1;return}for(const i of this.members)i!==e&&(this.syncedStores.add(i),i.cursorManager.syncToValue(r,i,o),i.scheduleCursorRedraw());this.publishing=!1}}function Is(t,e){_.useEffect(()=>{if(e==null)return;const n=As(e);n.join(t);let o=-1,s=-1;const l=t.subscribeCursor(()=>{const{activeGroup:r,activeDataIdx:i}=t.cursorManager.state;r===o&&i===s||(o=r,s=i,n.pub(t))});return()=>{l(),n.leave(t)}},[t,e])}function Tn(t){return t instanceof Float64Array?t:new Float64Array(t)}function An(t){return t instanceof Float64Array||t.some(e=>e==null)?t:new Float64Array(t)}function Ze(t){return{x:Tn(t.x),series:[An(t.y)]}}function Ps(t){return{x:Tn(t.x),series:t.series.map(An)}}function Ln(t){if(!Array.isArray(t))return[Ze(t)];if(t.length===0)return[];const e=t[0];return e==null?[]:"series"in e?t.map(Ps):t.map(Ze)}function we({width:t,height:e,data:n,children:o,className:s,pxRatio:l,title:r,xlabel:i,ylabel:a,onDraw:d,onCursorDraw:c,syncKey:h,actions:u,onClick:f,onContextMenu:g,onDblClick:w,onCursorMove:v,onCursorLeave:b,onScaleChange:y,onSelect:p}){const m=fs(),[T,M]=_.useState(null),C=l??(typeof window<"u"&&window.devicePixelRatio||1);_.useEffect(()=>{m.actionMap=u!=null?new Map([...Xt,...u]):new Map(Xt)},[m,u]),_.useLayoutEffect(()=>{m.setLabels(r,i,a)},[m,r,i,a]),_.useEffect(()=>{const S=m.eventCallbacks;S.onClick=f,S.onContextMenu=g,S.onDblClick=w,S.onCursorMove=v,S.onCursorLeave=b,S.onScaleChange=y,S.onSelect=p},[m,f,g,w,v,b,y,p]),ks(m,T),Is(m,h);const I=_.useRef(null),A=_.useCallback(S=>{I.current!==S&&(I.current=S,m.setCanvas(S),S&&m.scheduleRedraw())},[m]),x=_.useRef(null),D=_.useCallback(S=>{x.current!==S&&(x.current=S,M(S))},[]),L=_.useRef(d);_.useLayoutEffect(()=>{L.current=d});const F=_.useRef(c);_.useLayoutEffect(()=>{F.current=c});const R=_.useRef(!1),z=_.useRef(n);return _.useLayoutEffect(()=>{n===z.current&&m.dataStore.data.length>0||(z.current=n,R.current=!0,m.setData(Ln(n)),m.scheduleRedraw())},[m,n]),_.useLayoutEffect(()=>{m.setSize(t,e,C),R.current&&m.redrawSync()},[m,t,e,C]),_.useEffect(()=>()=>{m.setCanvas(null),m.scheduler.cancel(),m.focusedSeries=null,m.eventCallbacks={}},[m]),_.useEffect(()=>{if(T==null||typeof ResizeObserver>"u")return;const S=new ResizeObserver(k=>{const P=k[0];if(P==null)return;const{width:E,height:W}=P.contentRect;E>0&&W>0&&(E!==m.width||W!==m.height)&&(m.setSize(Math.round(E),Math.round(W)),m.scheduleRedraw())});return S.observe(T),()=>{S.disconnect()}},[m,T]),_.useEffect(()=>{if(typeof MutationObserver>"u")return;const S=document.documentElement,k=new MutationObserver(()=>{m.renderer.invalidateSnapshot(),m.scheduleRedraw()});return k.observe(S,{attributes:!0,attributeFilter:["class"]}),()=>{k.disconnect()}},[m]),_.useLayoutEffect(()=>{const S=k=>{var P;(P=L.current)==null||P.call(L,k)};return m.drawHooks.add(S),()=>{m.drawHooks.delete(S)}},[m]),_.useLayoutEffect(()=>{const S=(k,P)=>{var E;(E=F.current)==null||E.call(F,k,P)};return m.cursorDrawHooks.add(S),()=>{m.cursorDrawHooks.delete(S)}},[m]),B.jsx(Cn.Provider,{value:m,children:B.jsxs("div",{className:s,style:{position:"relative",display:"flex",flexDirection:"column",width:`${t}px`},children:[B.jsx("div",{ref:D,tabIndex:0,style:{position:"relative",width:`${t}px`,height:`${e}px`,cursor:"crosshair",outline:"none",order:0},children:B.jsx("canvas",{ref:A,style:{position:"absolute",left:0,top:0}})}),o]})})}function Je(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}function Es(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 _s(t,e){if(t===null)return!1;const n=t,o=e,s=Object.keys(n),l=Object.keys(o);if(s.length!==l.length)return!1;for(const r of l){const i=n[r],a=o[r];if(i!==a)if(Je(i)&&Je(a)){if(!Es(i,a))return!1}else return!1}return!0}function Se(t,e,n,o,s){const l=nt(),r=_.useRef(t);_.useLayoutEffect(()=>{r.current=t}),_.useLayoutEffect(()=>{const a=r.current;return n(l,a),l.scheduleRedraw(),()=>{o(l,a),l.scheduleRedraw()}},[l,...e]);const i=_.useRef(t);_.useLayoutEffect(()=>{_s(i.current,t)||(i.current=t,s(l,t),l.scheduleRedraw())})}function Ds(t){return Se(t,[t.id],(e,n)=>e.registerScale(n),(e,n)=>e.unregisterScale(n.id),(e,n)=>e.updateScale(n)),null}function Fs(t,e,n){e/=100,n/=100;const o=(1-Math.abs(2*n-1))*e,s=o*(1-Math.abs(t/60%2-1)),l=n-o/2;let r=0,i=0,a=0;return t<60?(r=o,i=s):t<120?(r=s,i=o):t<180?(i=o,a=s):t<240?(i=s,a=o):t<300?(r=s,a=o):(r=o,a=s),[Math.round((r+l)*255),Math.round((i+l)*255),Math.round((a+l)*255)]}function In(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);if(o)return[Number(o[1]),Number(o[2]),Number(o[3])];const s=/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%/i.exec(t);return s?Fs(Number(s[1]),Number(s[2]),Number(s[3])):null}function Rs(t,e=.8,n=0){const o=In(t);if(o==null)return{type:"linear",stops:[[0,t],[1,t]]};const[s,l,r]=o;return{type:"linear",stops:[[0,`rgba(${s},${l},${r},${e})`],[1,`rgba(${s},${l},${r},${n})`]]}}function Pn(t,e){const n=In(t);if(n==null)return t;const[o,s,l]=n;return`rgba(${o},${s},${l},${e})`}function Hs(t,e=65,n=50){const o=[];for(let l=0;l<t;l++){const r=l*137.508%360;o.push(`hsl(${r.toFixed(1)},${e}%,${n}%)`)}return o}const Qe=["#e74c3c","#3498db","#2ecc71","#f39c12","#9b59b6","#1abc9c","#e67e22","#34495e","#16a085","#c0392b","#2980b9","#27ae60","#f1c40f","#8e44ad","#d35400"];function tn(t,e){var r;const n=(r=t.paths)==null?void 0:r.defaults,o=t.stroke??Qe[e%Qe.length]??"#000",s=t.fill??(n==null?void 0:n.fill),l=s==="auto"&&typeof o=="string"?Pn(o,.5):s==="auto"?void 0:s;return{...n,...t,yScale:t.yScale??"y",show:t.show??!0,stroke:o,fill:l}}function ve(t){return Se(t,[t.group,t.index],(e,n)=>e.registerSeries(tn(n,e.seriesConfigs.length)),(e,n)=>e.unregisterSeries(n.group,n.index),(e,n)=>{const o=e.seriesConfigs.findIndex(s=>s.group===n.group&&s.index===n.index);e.updateSeries(tn(n,o>=0?o:e.seriesConfigs.length))}),null}function Ws(t){return{...t,side:t.side??(t.scale==="x"?j.Bottom:j.Left),show:t.show??!0}}function Wt(t){const e=Ws(t);return Se(e,[e.scale,e.side],(n,o)=>n.registerAxis(o),(n,o)=>n.unregisterAxis(o.scale,o.side),(n,o)=>n.updateAxis(o)),null}function zs({series:t,group:e,fill:n,dir:o}){const s=nt(),l=_.useRef(null),r=t[0],i=t[1];return _.useEffect(()=>{const a={series:[r,i],group:e,fill:n,dir:o};return l.current!=null&&s.unregisterBand(l.current),l.current=a,s.registerBand(a),s.scheduleRedraw(),()=>{l.current!=null&&s.unregisterBand(l.current),l.current=null,s.scheduleRedraw()}},[s,r,i,e,n,o]),null}const $s={width:12,height:3,borderRadius:1,display:"inline-block"},Bs={fontWeight:600},En={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",cursor:"pointer",fontSize:12,fontFamily:"sans-serif"},Gs={...En,opacity:1},Vs={...En,opacity:.4},en=new Map,Xs={display:"flex",flexWrap:"wrap",justifyContent:"center",order:-1,padding:"4px 0"},Ns={display:"flex",flexWrap:"wrap",justifyContent:"center",order:1,padding:"4px 0"};function Ys({group:t,index:e,label:n,color:o,isHidden:s,valueStr:l,store:r}){let i=en.get(o);return i==null&&(i={...$s,backgroundColor:o},en.set(o,i)),B.jsxs("span",{onClick:()=>r.toggleSeries(t,e),style:s?Vs:Gs,children:[B.jsx("span",{style:i}),B.jsx("span",{children:n}),l&&B.jsx("span",{style:Bs,children:l})]})}function Os({show:t=!0,position:e="bottom",className:n}){const o=nt(),s=_.useSyncExternalStore(o.subscribeCursor,o.getSnapshot);if(!t)return null;const{activeGroup:l,activeDataIdx:r}=s;return B.jsx("div",{className:n,style:e==="top"?Xs:Ns,children:o.seriesConfigs.map(i=>{if(i.legend===!1)return null;const a=Ft(i);let d="";if(r>=0&&l>=0&&i.group===l){const h=o.dataStore.getYValues(i.group,i.index)[r];h!=null&&(d=typeof h=="number"?h.toPrecision(4):String(h))}return B.jsx(Ys,{group:i.group,index:i.index,label:i.label??`Series ${i.index}`,color:a,isHidden:i.show===!1,valueStr:d,store:o},`${i.group}:${i.index}`)})})}const pt=8;function js(t,e,n,o){if(t!=null&&typeof t=="object")return t;switch(t){case"top-left":return{x:e.left+pt,y:e.top+pt};case"bottom-left":return{x:e.left+pt,y:e.top+e.height-o-pt};case"bottom-right":return{x:e.left+e.width-n-pt,y:e.top+e.height-o-pt};case"top-right":case void 0:default:return{x:e.left+e.width-n-pt,y:e.top+pt}}}function Us(t,e,n,o,s,l,r,i,a,d){if(t<0)return null;const c=tt(t+n+r,n,n+s-a),h=tt(e+o+i,o,o+l-d);return{x:c,y:h}}function nn(t,e,n,o,s,l,r){const i=Math.max(e,Math.min(t.x,e+o-l)),a=Math.max(n,Math.min(t.y,n+s-r));return i===t.x&&a===t.y?t:{x:i,y:a}}const Ks={pointerEvents:"none"};function qs(t,e,n){return{pointerEvents:"auto",cursor:t?"grabbing":"grab",opacity:e||t?1:n,transition:"opacity 0.2s ease"}}const Zs={};function _n({mode:t,show:e,position:n,offset:o,idleOpacity:s,estimatedSize:l}){const r=nt(),i=_.useSyncExternalStore(r.subscribeCursor,r.getSnapshot),[a,d]=_.useState(null),[c,h]=_.useState(!1),[u,f]=_.useState(!1),g=_.useRef(!1),w=_.useRef(!1),v=_.useRef({dx:0,dy:0}),[b,y]=_.useState(!1),p=_.useRef(null),[m,T]=_.useState({w:0,h:0});_.useLayoutEffect(()=>{if(t!=="cursor")return;const x=p.current;if(!x)return;const D=x.offsetWidth,L=x.offsetHeight;(D!==m.w||L!==m.h)&&T({w:D,h:L})}),_.useLayoutEffect(()=>{if(t!=="draggable"||b||i.plotWidth<=0)return;y(!0);const x=p.current,D=(x==null?void 0:x.offsetWidth)??l.w,L=(x==null?void 0:x.offsetHeight)??l.h;d(js(n,r.plotBox,D,L))},[t,b,i.plotWidth,n,r.plotBox,l]),_.useLayoutEffect(()=>{if(t!=="draggable"||!b||a==null||u||i.plotWidth<=0)return;const x=p.current;if(!x)return;const D=x.offsetWidth,L=x.offsetHeight,F=nn(a,i.plotLeft,i.plotTop,i.plotWidth,i.plotHeight,D,L);F!==a&&d(F)}),_.useEffect(()=>{if(!e||t!=="draggable")return;const x=L=>{var z;if(!g.current)return;w.current=!0;const F=(z=r.canvas)==null?void 0:z.parentElement;if(!F)return;const R=F.getBoundingClientRect();d({x:L.clientX-R.left-v.current.dx,y:L.clientY-R.top-v.current.dy})},D=()=>{g.current=!1,f(!1)};return window.addEventListener("mousemove",x),window.addEventListener("mouseup",D),()=>{window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",D)}},[r,e,t]);const M=x=>{if(t!=="draggable")return;x.stopPropagation(),x.preventDefault(),g.current=!0,f(!0),w.current=!1;const D=x.currentTarget.getBoundingClientRect();v.current={dx:x.clientX-D.left,dy:x.clientY-D.top}};let C=null;if(e)if(t==="cursor"){const x=m.w||l.w,D=m.h||l.h;C=Us(i.left,i.top,i.plotLeft,i.plotTop,i.plotWidth,i.plotHeight,o.x,o.y,x,D)}else a!=null&&(u?C=a:C=nn(a,i.plotLeft,i.plotTop,i.plotWidth,i.plotHeight,l.w,l.h));const I=t==="draggable"?qs(u,c,s):Ks;return{panelRef:p,renderPos:C,isDragging:u,hovered:c,didDrag:w,panelStyle:I,panelHandlers:t==="draggable"?{onMouseDown:M,onMouseEnter:()=>h(!0),onMouseLeave:()=>{h(!1),w.current=!1}}:Zs}}const on=1,Js=6,Qs=4,tr=4,er=12,sn=4,nr="12px sans-serif",rn="bold 12px sans-serif",ln=16,or={position:"absolute",zIndex:50,background:"var(--uplot-panel-bg, rgba(255,255,255,0.92))",border:"1px solid var(--uplot-panel-border, #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"},sr={width:12,height:3,borderRadius:1,display:"inline-block",flexShrink:0},rr={fontWeight:600},Ut={display:"flex",alignItems:"center",gap:4,padding:"1px 4px"},lr={...Ut,opacity:1,cursor:"pointer"},ir={...Ut,opacity:1,cursor:"default"},ar={...Ut,opacity:.4,cursor:"pointer"},cr={...Ut,opacity:.4,cursor:"default"},an=new Map;function ur(t){let e=an.get(t);return e==null&&(e={...sr,backgroundColor:t},an.set(t,e)),e}function be({label:t,color:e,value:n,isHidden:o,onClick:s}){const l=o?s?ar:cr:s?lr:ir;return B.jsxs("div",{onClick:s,style:l,children:[B.jsx("span",{style:ur(e)}),B.jsx("span",{children:t}),n&&B.jsx("span",{style:rr,children:n})]})}const ye=_.forwardRef(function({left:e,top:n,children:o,className:s,style:l,onMouseDown:r,onMouseEnter:i,onMouseLeave:a},d){return B.jsx("div",{ref:d,className:s,onMouseDown:r,onMouseEnter:i,onMouseLeave:a,style:{...or,left:e,top:n,...l},children:o})});function fr(t,e,n,o,s){if(s<0||o<0)return"";const r=t.dataStore.getYValues(e,n)[s];return r==null?"":typeof r=="number"?r.toPrecision(4):String(r)}function ie(t,e){const n=Pe.prepareWithSegments(t,e);let o=0;return Pe.walkLineRanges(n,Number.POSITIVE_INFINITY,s=>{s.width>o&&(o=s.width)}),o}function xe(t){let e=0;for(const s of t.rows){const l=ie(s.label,nr),r=s.value?ie(s.value,rn):0,i=tr*2+er+sn+l+(s.value?sn+r:0);i>e&&(e=i)}let n=0,o=0;return t.header&&(n=ie(t.header,rn)+8,o=ln+2),{w:on*2+Js*2+Math.max(e,n),h:on*2+Qs*2+o+t.rows.length*ln}}const dr={x:12,y:-12},hr={w:0,h:0},gr={zIndex:100},pr={fontWeight:600,marginBottom:2,padding:"0 4px"};function mr({show:t=!0,className:e,children:n,offset:o=dr,precision:s=2,mode:l="cursor",position:r="top-right",idleOpacity:i=.8}){const a=nt(),d=_.useSyncExternalStore(a.subscribeCursor,a.getSnapshot),{activeGroup:c,activeDataIdx:h}=d,u=a.plotBox,f=h>=0&&c>=0&&d.left>=0,g={x:o.x??12,y:o.y??-12};let w=null,v="";const b=[];if(f){const M=a.dataStore.data[c];w=M!=null?M.x[h]??null:null,v=w!=null?parseFloat(w.toFixed(s)).toString():"";for(const C of a.seriesConfigs){if(C.show===!1||C.legend===!1)continue;const I=a.dataStore.getYValues(C.group,C.index),A=C.group===c?I[h]:null;b.push({label:C.label??`Series ${C.index}`,value:A,color:Ft(C),group:C.group,index:C.index})}}else if(l==="draggable")for(const M of a.seriesConfigs)M.show===!1||M.legend===!1||b.push({label:M.label??`Series ${M.index}`,value:null,color:Ft(M),group:M.group,index:M.index});const y=b.length>0?xe({header:v||void 0,rows:b.map(M=>({label:M.label,value:M.value!=null?M.value.toPrecision(4):"—"}))}):hr,p=_n({mode:l,show:t,position:r,offset:g,idleOpacity:i,estimatedSize:y});if(!t||l==="cursor"&&!f||p.renderPos==null)return null;const m={x:w,xLabel:v,items:b,left:d.left+u.left,top:d.top+u.top},T={...p.panelStyle,...gr};return n?B.jsx("div",{ref:p.panelRef,className:e,style:{position:"absolute",left:p.renderPos.x,top:p.renderPos.y,whiteSpace:"nowrap",...T},...p.panelHandlers,children:n(m)}):B.jsxs(ye,{ref:p.panelRef,left:p.renderPos.x,top:p.renderPos.y,className:e,style:T,...p.panelHandlers,children:[v&&B.jsx("div",{style:pr,children:v}),b.map(M=>B.jsx(be,{label:M.label,color:M.color,value:M.value!=null?M.value.toPrecision(4):"—"},`${M.group}:${M.index}`))]})}const wr=8,cn=.01,ue=[.25,.75];function Sr(t,e,n){if(t==null)return ue;const o=n-e;return o<=0?ue:[Math.max(0,(t[0]-e)/o),Math.min(1,(t[1]-e)/o)]}function vr(t,e,n){const o=n-e;return[e+t[0]*o,e+t[1]*o]}function br(t,e,n){return Math.abs(t-e[0])<n?"left":Math.abs(t-e[1])<n?"right":t>=e[0]&&t<=e[1]?"move":"outside"}function yr(t,e,n){if(t==="move"){const s=e[1]-e[0],l=tt(e[0]+n,0,1-s);return[l,l+s]}if(t==="left")return[tt(e[0]+n,0,e[1]-cn),e[1]];const o=tt(e[1]+n,e[0]+cn,1);return[e[0],o]}function xr({width:t,height:e,data:n,onRangeChange:o,initialRange:s,className:l,colors:r,grips:i=!1}){const a=_.useRef(null),d=_.useMemo(()=>Ln(n),[n]),[c,h]=_.useState(()=>{if(s!=null&&d.length>0){const M=d[0];if(M!=null&&M.x.length>1)return Sr(s,M.x[0],M.x[M.x.length-1])}return ue}),u=_.useRef(null);_.useEffect(()=>{if(o==null||d.length===0)return;const M=d[0];if(M==null||M.x.length<2)return;const C=M.x[0],I=M.x[M.x.length-1],[A,x]=vr(c,C,I),D=u.current,L=Math.max(1e-10,Math.abs(x-A)*1e-12);D!=null&&Math.abs(D[0]-A)<L&&Math.abs(D[1]-x)<L||(u.current=[A,x],o(A,x))},[c,d,o]);const f=_.useRef(null),g=_.useCallback(M=>{const C=a.current;if(C==null)return 0;const I=C.getBoundingClientRect();return tt((M-I.left)/I.width,0,1)},[]),w=_.useCallback(M=>{const C=a.current;if(C==null)return;const I=g(M.clientX),A=C.getBoundingClientRect().width,x=A>0?wr/A:0,D=br(I,c,x);if(D==="outside"){const L=c[1]-c[0],F=L/2,R=tt(I-F,0,1-L),z=[R,R+L];h(z),f.current={mode:"move",startX:M.clientX,startFrac:z},C.setPointerCapture(M.pointerId),M.preventDefault();return}f.current={mode:D,startX:M.clientX,startFrac:[...c]},C.setPointerCapture(M.pointerId),M.preventDefault()},[c,g]),v=_.useCallback(M=>{const C=f.current;if(C==null)return;const I=g(M.clientX),A=g(C.startX),x=I-A;h(yr(C.mode,C.startFrac,x))},[g]),b=_.useCallback(M=>{f.current=null;const C=a.current;C!=null&&C.releasePointerCapture(M.pointerId)},[]),y=`${c[0]*100}%`,p=`${(c[1]-c[0])*100}%`,m=d[0],T=m!=null?m.series.length:0;return B.jsxs("div",{className:l,style:{position:"relative",width:t,height:e},children:[B.jsxs(we,{width:t,height:e,data:d,children:[B.jsx(Wt,{scale:"x",show:!1}),B.jsx(Wt,{scale:"y",show:!1}),Array.from({length:T},(M,C)=>B.jsx(ve,{group:0,index:C,yScale:"y",stroke:r!=null&&r[C]!=null?r[C]:`hsl(${C*137}, 60%, 50%)`,width:1},`0:${C}`))]}),B.jsxs("div",{ref:a,onPointerDown:w,onPointerMove:v,onPointerUp:b,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[B.jsx("div",{style:{position:"absolute",top:0,left:0,width:y,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),B.jsx("div",{style:{position:"absolute",top:0,left:`${c[1]*100}%`,right:0,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),B.jsx("div",{style:{position:"absolute",top:0,left:y,width:p,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:i&&B.jsxs(B.Fragment,{children:[B.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"}}),B.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 St(t,e){const n=nt(),o=_.useRef(t);_.useLayoutEffect(()=>{o.current=t});const s=(e==null?void 0:e.clipped)!==!1;_.useLayoutEffect(()=>{const l=i=>o.current(i),r=s?n.drawHooks:n.unclippedDrawHooks;return r.add(l),()=>{r.delete(l)}},[n,s])}function Mr(t){const e=nt(),n=_.useRef(t);_.useLayoutEffect(()=>{n.current=t}),_.useLayoutEffect(()=>{const o=(s,l)=>n.current(s,l);return e.cursorDrawHooks.add(o),()=>{e.cursorDrawHooks.delete(o)}},[e])}function Cr({lanes:t,laneHeight:e=24,gap:n=2,scaleId:o="x"}){const s=nt();return St(({ctx:l,plotBox:r,pxRatio:i})=>{const a=s.scaleManager.getScale(o);if(a==null||!U(a))return;l.save();const d=(e+n)*i,c=e*i,h=r.top*i;l.fillStyle="#666",l.font=`${11*i}px sans-serif`,l.textAlign="right",l.textBaseline="middle";for(let u=0;u<t.length;u++){const f=t[u];if(f==null)continue;const g=h+u*d;l.fillText(f.label,(r.left-6)*i,g+c/2)}l.beginPath(),l.rect(r.left*i,r.top*i,r.width*i,r.height*i),l.clip();for(let u=0;u<t.length;u++){const f=t[u];if(f==null)continue;const g=h+u*d;for(const w of f.segments){const v=X(w.start,a,r.width,r.left)*i,y=X(w.end,a,r.width,r.left)*i-v;y<=0||(l.fillStyle=w.color??"#4dabf7",l.fillRect(v,g,y,c),w.label!=null&&y>20*i&&(l.fillStyle="#fff",l.font=`${10*i}px sans-serif`,l.textAlign="center",l.textBaseline="middle",l.fillText(w.label,v+y/2,g+c/2,y-4*i)))}}l.restore()},{clipped:!1}),null}function kr({data:t,width:e=150,height:n=30,stroke:o="#03a9f4",fill:s,lineWidth:l=1,paths:r,fillTo:i,className:a}){return B.jsx("div",{style:{pointerEvents:"none"},className:a,children:B.jsxs(we,{width:e,height:n,data:t,children:[B.jsx(Wt,{scale:"x",show:!1}),B.jsx(Wt,{scale:"y",show:!1}),B.jsx(ve,{group:0,index:0,yScale:"y",stroke:o,fill:s,width:l,paths:r,fillTo:i})]})})}const Tr={x:12,y:-12},Ar={w:0,h:0};function Lr({mode:t="draggable",position:e="top-right",offset:n=Tr,idleOpacity:o=.3,show:s=!0,className:l}){const r=nt(),i=_.useSyncExternalStore(r.subscribeCursor,r.getSnapshot),{activeGroup:a,activeDataIdx:d}=i,c=[],h=r.seriesConfigs.filter(v=>v.legend!==!1).map(v=>{const b=Ft(v),y=fr(r,v.group,v.index,a,d),p=v.label??`Series ${v.index}`;return c.push({label:p,value:y}),{cfg:v,color:b,value:y,label:p}}),u=h.length>0?xe({rows:c}):Ar,f=_n({mode:t,show:s,position:e,offset:n,idleOpacity:o,estimatedSize:u});if(!s||f.renderPos==null)return null;const g=(v,b)=>{f.didDrag.current||r.toggleSeries(v,b)},w=t==="draggable";return B.jsx(ye,{ref:f.panelRef,left:f.renderPos.x,top:f.renderPos.y,className:l,style:f.panelStyle,...f.panelHandlers,children:h.map(({cfg:v,color:b,value:y,label:p})=>B.jsx(be,{label:p,color:b,value:y,isHidden:v.show===!1,onClick:w?()=>g(v.group,v.index):void 0},`${v.group}:${v.index}`))})}const Ir={pointerEvents:"none"};function Pr({delay:t=1e3,show:e=!0,className:n}){const o=nt(),s=_.useSyncExternalStore(o.subscribeCursor,o.getSnapshot),[l,r]=_.useState(!1),i=_.useRef(-1),a=_.useRef(0),d=_.useRef(null),[c,h]=_.useState({w:0,h:0});if(_.useLayoutEffect(()=>{const T=d.current;if(!T)return;const M=T.offsetWidth,C=T.offsetHeight;(M!==c.w||C!==c.h)&&h({w:M,h:C})}),_.useEffect(()=>{const T=s.activeSeriesIdx;T!==i.current&&(i.current=T,r(!1),window.clearTimeout(a.current),T>=0&&(a.current=window.setTimeout(()=>r(!0),t)))},[s.activeSeriesIdx,t]),_.useEffect(()=>()=>{window.clearTimeout(a.current)},[]),!e||!l||s.left<0)return null;const u=o.seriesConfigs.find(T=>T.group===s.activeGroup&&T.index===s.activeSeriesIdx);if(!(u!=null&&u.label)||u.legend===!1)return null;const f=Ft(u),g=xe({rows:[{label:u.label}]}),w=c.w||g.w,v=c.h||g.h,b=s.left+s.plotLeft,y=s.top+s.plotTop,p=tt(b-w/2,s.plotLeft,s.plotLeft+s.plotWidth-w),m=tt(y-v-12,s.plotTop,s.plotTop+s.plotHeight-v);return B.jsx(ye,{ref:d,left:p,top:m,className:n,style:Ir,children:B.jsx(be,{label:u.label,color:f})})}function Dn(t,e,n,o,s,l,r,i,a){const d=r/2;if(a.wickColor!=null&&(t.strokeStyle=a.wickColor,t.lineWidth=a.wickWidth??1,t.beginPath(),t.moveTo(e,n),t.lineTo(e,o),t.stroke()),a.capWidth!=null&&a.capWidth>0){const u=a.capWidth/2;t.strokeStyle=a.wickColor??"#555",t.lineWidth=a.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 c=Math.min(s,l),h=Math.abs(l-s);t.fillStyle=a.bodyFill,t.fillRect(e-d,c,r,h),a.bodyStroke!=null&&(t.strokeStyle=a.bodyStroke,t.lineWidth=a.bodyStrokeWidth??1.5,t.strokeRect(e-d,c,r,h)),i!=null&&a.midColor!=null&&(t.strokeStyle=a.midColor,t.lineWidth=a.midWidth??2.5,t.beginPath(),t.moveTo(e-d,i),t.lineTo(e+d,i),t.stroke())}function Er({boxes:t,yScale:e="y",boxWidth:n=.5,fill:o="rgba(52, 152, 219, 0.4)",stroke:s="#2980b9",medianColor:l="#e74c3c",whiskerColor:r="#555"}){return St(({ctx:i,plotBox:a,valToX:d,valToY:c})=>{const h=a.width/t.length*n,u=h*.3;for(let f=0;f<t.length;f++){const g=t[f];if(g==null)continue;const w=d(f+1),v=c(g.min,e),b=c(g.q1,e),y=c(g.median,e),p=c(g.q3,e),m=c(g.max,e);w==null||v==null||b==null||y==null||p==null||m==null||Dn(i,w,v,m,b,p,h,y,{wickColor:r,bodyFill:o,bodyStroke:s,capWidth:u,midColor:l})}}),null}function _r(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 d=0;d<n.length-1;d++){const c=n[d],h=n[d+1];if(c!=null&&h!=null&&e>=c[0]&&e<=h[0]){o=c,s=h;break}}const l=s[0]===o[0]?0:(e-o[0])/(s[0]-o[0]),r=Math.round(o[1]+l*(s[1]-o[1])),i=Math.round(o[2]+l*(s[2]-o[2])),a=Math.round(o[3]+l*(s[3]-o[3]));return`rgb(${r},${i},${a})`}function Dr({grid:t,xRange:e,yRange:n,colorMap:o=_r,yScale:s="y"}){return St(({ctx:l,valToX:r,valToY:i})=>{var b;if(t.length===0)return;const a=t.length,d=((b=t[0])==null?void 0:b.length)??0;if(d===0)return;const c=(e==null?void 0:e[0])??0,h=(e==null?void 0:e[1])??a,u=(n==null?void 0:n[0])??0,f=(n==null?void 0:n[1])??d,g=(h-c)/a,w=(f-u)/d;let v=0;for(const y of t)for(const p of y)p>v&&(v=p);if(v!==0)for(let y=0;y<a;y++){const p=t[y];if(p==null)continue;const m=r(c+y*g),T=r(c+(y+1)*g);if(m==null||T==null)continue;const M=T-m;for(let C=0;C<d;C++){const I=p[C]??0,A=u+C*w,x=u+(C+1)*w,D=i(x,s),L=i(A,s);if(D==null||L==null)continue;const F=L-D;l.fillStyle=o(I/v),l.fillRect(m,D,M,F)}}}),null}function Fr(t,e,n,o,s){const l=(o-90)*(Math.PI/180),r=s,i=r*.35,a=Math.PI/6,d=e+Math.cos(l)*r,c=n+Math.sin(l)*r,h=e-Math.cos(l)*r*.5,u=n-Math.sin(l)*r*.5;t.beginPath(),t.moveTo(h,u),t.lineTo(d,c),t.stroke(),t.beginPath(),t.moveTo(d,c),t.lineTo(d-i*Math.cos(l-a),c-i*Math.sin(l-a)),t.moveTo(d,c),t.lineTo(d-i*Math.cos(l+a),c-i*Math.sin(l+a)),t.stroke()}function Rr({directions:t,group:e=0,index:n=0,color:o="#c0392b",minSize:s=4,maxSize:l=10}){const r=nt();return St(({ctx:i,valToX:a,valToY:d})=>{var b;const c=r.dataStore.data[e];if(c==null)return;const h=c.x,u=c.series[n];if(u==null)return;let f=1/0,g=-1/0;for(let y=0;y<u.length;y++){const p=u[y];p!=null&&(p<f&&(f=p),p>g&&(g=p))}const w=g-f||1,v=((b=r.seriesConfigs.find(y=>y.group===e&&y.index===n))==null?void 0:b.yScale)??"y";i.strokeStyle=o,i.lineWidth=1.5,i.lineCap="round";for(let y=0;y<h.length;y++){const p=u[y],m=t[y];if(p==null||m==null)continue;const T=a(h[y]),M=d(p,v);if(T==null||M==null)continue;const C=(p-f)/w,I=s+C*(l-s);Fr(i,T,M,m,I)}}),null}const Hr=4;function Me(t,e){t.strokeStyle=e.stroke??"red",t.lineWidth=e.width??1,e.dash&&t.setLineDash(e.dash)}function Ce(t,e){e.dash&&t.setLineDash([])}function Fn(t,e,n,o={}){const{ctx:s,plotBox:l}=t,r=X(n,e,l.height,l.top);s.beginPath(),s.moveTo(l.left,r),s.lineTo(l.left+l.width,r),Me(s,o),s.stroke(),Ce(s,o)}function Rn(t,e,n,o={}){const{ctx:s,plotBox:l}=t,r=X(n,e,l.width,l.left);s.beginPath(),s.moveTo(r,l.top),s.lineTo(r,l.top+l.height),Me(s,o),s.stroke(),Ce(s,o)}function Wr(t,e,n,o,s,l,r={}){const{ctx:i,plotBox:a}=t,d=X(o,e,a.width,a.left),c=X(s,n,a.height,a.top);i.font=r.font??"12px sans-serif",i.fillStyle=r.fill??"#000",i.textBaseline="bottom",i.fillText(l,d,c-Hr)}function Hn(t,e,n,o,s={}){const{ctx:l,plotBox:r}=t,i=X(o,e,r.height,r.top),a=X(n,e,r.height,r.top);l.fillStyle=s.fill??"rgba(255,0,0,0.1)",l.fillRect(r.left,Math.min(i,a),r.width,Math.abs(a-i)),s.stroke&&(Me(l,s),l.strokeRect(r.left,Math.min(i,a),r.width,Math.abs(a-i)),Ce(l,s))}function ke(t,e,n){const o=_.useRef(t);_.useLayoutEffect(()=>{o.current=t},[t]),St(s=>{const l=s.getScale(e);l!=null&&n(s,l,o.current)})}function zr(t){return ke(t,t.yScale??"y",(e,n,o)=>{if(Fn(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:l,plotBox:r}=e;l.font=o.labelFont??"11px sans-serif",l.fillStyle=o.stroke??"red",l.textAlign="left",l.textBaseline="bottom",l.fillText(o.label,r.left+4,s-4)}}),null}function $r(t){return ke(t,t.xScale??"x",(e,n,o)=>{if(Rn(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:l,plotBox:r}=e;l.font=o.labelFont??"11px sans-serif",l.fillStyle=o.stroke??"red",l.textAlign="center",l.textBaseline="bottom",l.fillText(o.label,s,r.top-4)}}),null}function Br(t){return ke(t,t.yScale??"y",(e,n,o)=>{Hn(e,n,o.yMin,o.yMax,{fill:o.fill,stroke:o.stroke,width:o.strokeWidth,dash:o.dash})}),null}function Gr(t){const e=_.useRef(t);return _.useLayoutEffect(()=>{e.current=t}),St(n=>{const o=e.current,s=n.valToX(o.x,o.xScale??"x"),l=n.valToY(o.y,o.yScale??"y");if(s==null||l==null)return;const{ctx:r}=n;r.font=o.font??"12px sans-serif",r.fillStyle=o.fill??"#000",r.textAlign=o.align??"left",r.textBaseline=o.baseline??"bottom",r.fillText(o.text,s,l-4)}),null}function Vr(t){const e=(n,o,s,l,r,i,a,d,c,h,u,f,g)=>{const w=(g==null?void 0:g.align)??t??1,v=(g==null?void 0:g.spanGaps)??!1;if([c,h]=Nt(o,c,h),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const b=x=>f(X(x,s,r,a)),y=x=>f(X(x,l,i,d)),p=s.ori===$.Horizontal?Ot:jt,m={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},T=m.stroke;let M=!1;const C=u===K.Forward?c:h;let I=y(o[C]),A=b(n[C]);p(T,A,I);for(let x=C;x>=c&&x<=h;x+=u){const D=o[x];if(D==null){D===null&&!v&&(M=!0);continue}const L=b(n[x]),F=y(D);if(w===1)p(T,L,I);else if(w===-1)p(T,A,F);else{const R=f((A+L)/2);p(T,R,I),p(T,R,F)}p(T,L,F),I=F,A=L}{const x=m.fill=new Path2D(T),D=(g==null?void 0:g.fillTo)??l.min??0,L=y(D);let F=b(n[c]),R=b(n[h]);u===K.Backward&&([R,F]=[F,R]),p(x,R,L),p(x,F,L)}if(M){const x=he(n,o,c,h,u,b);m.gaps=x,m.clip=ge(x,s.ori,a,d,r,i)}return m};return e.defaults=Yt,e}function Te(t){return t.defaults=io,t}function Ae(){return Te((e,n,o,s,l,r,i,a,d,c,h,u,f)=>{const g=(f==null?void 0:f.barWidth)??.6,w=(f==null?void 0:f.barGap)??0,v=(f==null?void 0:f.barRadius)??0,b=(f==null?void 0:f.barGroupIdx)??0,y=(f==null?void 0:f.barGroupCount)??1,p=R=>u(X(R,o,l,i)),m=R=>u(X(R,s,r,a));let T=l;if(c>d){let R=1/0,z=-1;for(let S=d;S<=c;S++)if(n[S]!=null){if(z>=0){const k=e[S],P=e[z],E=Math.abs(p(k)-p(P));E<R&&(R=E)}z=S}R<1/0&&(T=R)}const M=T*(1-g),C=Math.max(0,M+w),I=Math.max(1,u(T-C)),A=y>1?Math.max(1,u(I/Math.max(1,y))):I,x=(f==null?void 0:f.fillTo)??s.min??0,D=m(x),L=new Path2D,F=o.ori===$.Horizontal;for(let R=h===K.Forward?d:c;R>=d&&R<=c;R+=h){const z=n[R];if(z==null)continue;const S=p(e[R]),k=m(z),P=y>1?(b-(y-1)/2)*A:0,E=u(S-A/2+P),W=Math.min(k,D),V=Math.max(k,D)-W;if(V!==0)if(v>0){const N=Math.min(v*A,V/2);Yr(L,F,E,W,A,V,N,z<x)}else F?L.rect(E,W,A,V):L.rect(W,E,V,A)}return{stroke:L,fill:L,clip:null,band:null,gaps:null}})}function Xr(t,e){const n=Ae();return Te((s,l,r,i,a,d,c,h,u,f,g,w,v)=>{const b={...v,barGroupIdx:t,barGroupCount:e};return n(s,l,r,i,a,d,c,h,u,f,g,w,b)})}function Nr(){const t=Ae();return Te((n,o,s,l,r,i,a,d,c,h,u,f,g)=>{const w={barWidth:.8,...g};return t(n,o,s,l,r,i,a,d,c,h,u,f,w)})}function Yr(t,e,n,o,s,l,r,i){r=Math.min(r,s/2,l/2),e?i?(t.moveTo(n,o),t.lineTo(n+s,o),t.lineTo(n+s,o+l-r),t.arc(n+s-r,o+l-r,r,0,Math.PI/2),t.lineTo(n+r,o+l),t.arc(n+r,o+l-r,r,Math.PI/2,Math.PI),t.closePath()):(t.moveTo(n,o+l),t.lineTo(n,o+r),t.arc(n+r,o+r,r,Math.PI,Math.PI*1.5),t.lineTo(n+s-r,o),t.arc(n+s-r,o+r,r,Math.PI*1.5,0),t.lineTo(n+s,o+l),t.closePath()):i?(t.moveTo(o,n),t.lineTo(o,n+s),t.lineTo(o+l-r,n+s),t.arc(o+l-r,n+s-r,r,Math.PI/2,0,!0),t.lineTo(o+l,n+r),t.arc(o+l-r,n+r,r,0,-Math.PI/2,!0),t.closePath()):(t.moveTo(o+l,n),t.lineTo(o+r,n),t.arc(o+r,n+r,r,-Math.PI/2,Math.PI,!0),t.lineTo(o,n+s-r),t.arc(o+r,n+s-r,r,Math.PI,Math.PI/2,!0),t.lineTo(o+l,n+s),t.closePath())}function Wn(t){const e=(n,o,s,l,r,i,a,d,c,h,u,f,g)=>{const w=(g==null?void 0:g.spanGaps)??!1;if([c,h]=Nt(o,c,h),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const v=A=>f(X(A,s,r,a)),b=A=>f(X(A,l,i,d)),y=s.ori===$.Horizontal?Ot:jt,p=[],m=[];let T=!1;for(let A=u===K.Forward?c:h;A>=c&&A<=h;A+=u){const x=o[A];x!=null?(p.push(v(n[A])),m.push(b(x))):x===null&&!w&&(T=!0)}const M=s.ori===$.Horizontal,C=t(p,m,M,f),I={stroke:C??new Path2D,fill:null,clip:null,band:null,gaps:null};if(C!=null){const A=I.fill=new Path2D(C),x=(g==null?void 0:g.fillTo)??l.min??0,D=b(x);let L=v(n[c]),F=v(n[h]);u===K.Backward&&([F,L]=[L,F]),y(A,F,D),y(A,L,D)}if(T){const A=he(n,o,c,h,u,v);I.gaps=A,I.clip=ge(A,s.ori,a,d,r,i)}return I};return e.defaults=Yt,e}function Or(){return Wn(jr)}const jr=(t,e,n,o)=>{const s=t.length;if(s<2)return null;const l=new Path2D,r=t[0]??0,i=e[0]??0;if(n?l.moveTo(r,i):l.moveTo(i,r),s===2){const u=t[1]??0,f=e[1]??0;return n?l.lineTo(u,f):l.lineTo(f,u),l}const a=new Array(s),d=new Array(s-1),c=new Array(s-1),h=new Array(s-1);for(let u=0;u<s-1;u++)c[u]=(e[u+1]??0)-(e[u]??0),h[u]=(t[u+1]??0)-(t[u]??0),d[u]=h[u]!==0?(c[u]??0)/(h[u]??1):0;a[0]=d[0]??0;for(let u=1;u<s-1;u++){const f=d[u]??0,g=d[u-1]??0;if(f===0||g===0||g>0!=f>0)a[u]=0;else{const w=h[u]??1,v=h[u-1]??1;a[u]=3*(v+w)/((2*w+v)/g+(w+2*v)/f),isFinite(a[u]??0)||(a[u]=0)}}a[s-1]=d[s-2]??0;for(let u=0;u<s-1;u++){const f=h[u]??1,g=t[u]??0,w=e[u]??0,v=t[u+1]??0,b=e[u+1]??0,y=a[u]??0,p=a[u+1]??0,m=g+f/3,T=w+y*f/3,M=v-f/3,C=b-p*f/3;n?l.bezierCurveTo(m,T,M,C,v,b):l.bezierCurveTo(T,m,C,M,b,v)}return l};function Ur(){return Wn(Kr)}const Kr=(t,e,n,o)=>{const s=t.length;if(s<2)return null;const l=new Path2D,r=o(t[0]??0),i=o(e[0]??0);if(n?l.moveTo(r,i):l.moveTo(i,r),s===2){const a=o(t[1]??0),d=o(e[1]??0);return n?l.lineTo(a,d):l.lineTo(d,a),l}for(let a=0;a<s-1;a++){const d=a===0?0:a-1,c=t[d]??0,h=e[d]??0,u=t[a]??0,f=e[a]??0,g=t[a+1]??0,w=e[a+1]??0,v=a+2<s?t[a+2]??0:g,b=a+2<s?e[a+2]??0:w,y=Math.hypot(c-u,h-f),p=Math.hypot(u-g,f-w),m=Math.hypot(g-v,w-b),T=Math.sqrt(m),M=m,C=Math.sqrt(p),I=p,A=Math.sqrt(y),x=y,D=2*x+3*A*C+I,L=2*M+3*T*C+I,F=3*A*(A+C),R=3*T*(T+C);let z,S,k,P;if(F>0){const E=1/F;z=(-I*c+D*u+x*g)*E,S=(-I*h+D*f+x*w)*E}else z=u,S=f;if(R>0){const E=1/R;k=(M*u+L*g-I*v)*E,P=(M*f+L*w-I*b)*E}else k=g,P=w;n?l.bezierCurveTo(z,S,k,P,g,w):l.bezierCurveTo(S,z,P,k,w,g)}return l};function qr(t=4){const e=(n,o,s,l,r,i,a,d,c,h,u,f,g)=>{const w=m=>f(X(m,s,r,a)),v=m=>f(X(m,l,i,d)),b=t/2,y=new Path2D,p=s.ori===$.Horizontal;for(let m=u===K.Forward?c:h;m>=c&&m<=h;m+=u){const T=o[m];if(T==null)continue;const M=w(n[m]),C=v(T);p?(y.moveTo(M+b,C),y.arc(M,C,b,0,Math.PI*2)):(y.moveTo(C+b,M),y.arc(C,M,b,0,Math.PI*2))}return{stroke:y,fill:y,clip:null,band:null,gaps:null}};return e.defaults=ao,e}function Zr({group:t=0,series:e=[0,1,2,3],yScale:n="y",upColor:o="#26a69a",downColor:s="#ef5350",bodyWidth:l=.6,wickWidth:r=1}){const i=nt();return St(({ctx:a,plotBox:d,valToX:c,valToY:h})=>{const u=i.dataStore.data[t];if(u==null)return;const f=u.x,g=u.series[e[0]],w=u.series[e[1]],v=u.series[e[2]],b=u.series[e[3]];if(g==null||w==null||v==null||b==null)return;const y=f.length;if(y===0)return;const p=Math.max(2,d.width/y*l);for(let m=0;m<y;m++){const T=f[m],M=g[m],C=w[m],I=v[m],A=b[m];if(T==null||M==null||C==null||I==null||A==null)continue;const x=c(T),D=h(C,n),L=h(I,n),F=h(M,n),R=h(A,n);if(x==null||D==null||L==null||F==null||R==null)continue;const S=A>=M?o:s;Dn(a,x,D,L,F,R,p,null,{wickColor:S,wickWidth:r,bodyFill:S})}}),null}function Jr(t,e,n=0){const o=e??t.series.map((c,h)=>h),s=t.x.length,l=[],r=new Float64Array(s);for(let c=0;c<o.length;c++){const h=o[c];if(h==null)continue;const u=t.series[h];if(u==null)continue;const f=new Array(s);for(let g=0;g<s;g++){const w=u[g];w!=null?(r[g]=r[g]+w,f[g]=r[g]):f[g]=null}l.push(f)}const i=new Map;for(let c=0;c<o.length;c++){const h=o[c];h!=null&&i.set(h,c)}const a=[];for(let c=0;c<t.series.length;c++){const h=i.get(c)??-1,u=h>=0?l[h]:void 0;u!=null?a.push(u):a.push(t.series[c]??[])}const d=[];for(let c=o.length-1;c>0;c--){const h=o[c],u=o[c-1];h!=null&&u!=null&&d.push({group:n,series:[h,u]})}return{group:{x:t.x,series:a},bands:d}}function Qr(t){const e=new Set;for(const[l]of t)for(let r=0;r<l.length;r++){const i=l[r];i!=null&&e.add(i)}const n=Float64Array.from([...e].sort((l,r)=>l-r)),o=new Map;for(let l=0;l<n.length;l++){const r=n[l];r!=null&&o.set(r,l)}const s=[];for(const[l,r]of t){const i=new Array(n.length).fill(null);for(let a=0;a<l.length;a++){const d=l[a];if(d==null)continue;const c=o.get(d);c!=null&&(i[c]=r[a]??null)}s.push(i)}return[{x:n,series:s}]}function tl(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 el(t,e=0){return n=>n.map(o=>o.toFixed(e)+t)}function nl(t,e=0){return n=>n.map(o=>t+o.toFixed(e))}function ol(t,e,n=0){return o=>o.map(s=>t+s.toFixed(n)+e)}function sl(t){const e=(t==null?void 0:t.utc)??!1;return n=>n.map(o=>e?it(o,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC"):it(o,{hour:"2-digit",minute:"2-digit",hour12:!1}))}function rl(t){const e=t!=null&&t.utc?"UTC":void 0,n=(t==null?void 0:t.format)??"short";return o=>o.map(s=>it(s,{month:n},e))}function ll(t){const{tz:e,...n}=t??{};return o=>o.map(s=>it(s,n,e))}function il(t,e=0){return n=>n.map(o=>{const s=Math.round(o)-e;return t[s]??String(o)})}exports.AnnotationLabel=Gr;exports.Axis=Wt;exports.Band=zs;exports.BoxWhisker=Er;exports.Candlestick=Zr;exports.Chart=we;exports.DEFAULT_ACTIONS=Xt;exports.Direction=K;exports.Distribution=q;exports.FloatingLegend=Lr;exports.HLine=zr;exports.Heatmap=Dr;exports.HoverLabel=Pr;exports.Legend=Os;exports.Orientation=$;exports.Region=Br;exports.Scale=Ds;exports.Series=ve;exports.Side=j;exports.SortOrder=Lt;exports.Sparkline=kr;exports.Timeline=Cr;exports.Tooltip=mr;exports.VLine=$r;exports.Vector=Rr;exports.ZoomRanger=xr;exports.alignData=Qr;exports.bars=Ae;exports.catmullRom=Ur;exports.drawHLine=Fn;exports.drawLabel=Wr;exports.drawRegion=Hn;exports.drawVLine=Rn;exports.fadeGradient=Rs;exports.fmtCompact=tl;exports.fmtDateStr=ll;exports.fmtHourMin=sl;exports.fmtLabels=il;exports.fmtMonthName=rl;exports.fmtPrefix=nl;exports.fmtSuffix=el;exports.fmtWrap=ol;exports.focus=Bn;exports.groupedBars=Xr;exports.linear=xn;exports.lttb=pe;exports.lttbGroup=ho;exports.monotoneCubic=Or;exports.palette=Hs;exports.points=qr;exports.posToVal=ft;exports.sideOrientation=Ct;exports.stackGroup=Jr;exports.stackedBars=Nr;exports.stepped=Vr;exports.useChart=ds;exports.useCursorDrawHook=Mr;exports.useDrawHook=St;exports.valToPos=X;exports.withAlpha=Pn;