From 86302f7fc50c672366baf6df70ead825018823aa Mon Sep 17 00:00:00 2001 From: Leon Sorokin Date: Fri, 19 Jan 2024 08:46:22 -0600 Subject: [PATCH] allow deferring firing hooks in explicit u.batch() --- dist/uPlot.cjs.js | 30 +++++++++++++++++++++++++----- dist/uPlot.d.ts | 2 +- dist/uPlot.esm.js | 30 +++++++++++++++++++++++++----- dist/uPlot.iife.js | 30 +++++++++++++++++++++++++----- dist/uPlot.iife.min.js | 2 +- src/uPlot.js | 30 +++++++++++++++++++++++++----- 6 files changed, 102 insertions(+), 22 deletions(-) diff --git a/dist/uPlot.cjs.js b/dist/uPlot.cjs.js index c5b8fb42..7dbb59c3 100644 --- a/dist/uPlot.cjs.js +++ b/dist/uPlot.cjs.js @@ -4539,6 +4539,17 @@ function uPlot(opts, data, then) { } let queuedCommit = false; + let deferHooks = false; + let hooksQueue = []; + + function flushHooks() { + deferHooks = false; + + for (let i = 0; i < hooksQueue.length; i++) + fire(...hooksQueue[i]); + + hooksQueue.length = 0; + } function commit() { if (!queuedCommit) { @@ -4548,10 +4559,15 @@ function uPlot(opts, data, then) { } // manual batching (aka immediate mode), skips microtask queue - function batch(fn) { + function batch(fn, _deferHooks = false) { queuedCommit = true; + deferHooks = _deferHooks; + fn(self); _commit(); + + if (_deferHooks && hooksQueue.length > 0) + queueMicrotask(flushHooks); } self.batch = batch; @@ -5727,10 +5743,14 @@ function uPlot(opts, data, then) { const hooks = self.hooks = opts.hooks || {}; function fire(evName, a1, a2) { - if (evName in hooks) { - hooks[evName].forEach(fn => { - fn.call(null, self, a1, a2); - }); + if (deferHooks) + hooksQueue.push([evName, a1, a2]); + else { + if (evName in hooks) { + hooks[evName].forEach(fn => { + fn.call(null, self, a1, a2); + }); + } } } diff --git a/dist/uPlot.d.ts b/dist/uPlot.d.ts index ece79a1a..6baa0ff6 100644 --- a/dist/uPlot.d.ts +++ b/dist/uPlot.d.ts @@ -65,7 +65,7 @@ declare class uPlot { redraw(rebuildPaths?: boolean, recalcAxes?: boolean): void; /** manual batching of multiple ops (aka immediate mode that skips implicit microtask queue), ops, e.g. setScale('x', ...) && setScale('y', ...) */ - batch(txn: Function): void; + batch(txn: Function, deferHooks?: boolean): void; /** destroys DOM, removes resize & scroll listeners, etc. */ destroy(): void; diff --git a/dist/uPlot.esm.js b/dist/uPlot.esm.js index 0476adb9..8525ef8d 100644 --- a/dist/uPlot.esm.js +++ b/dist/uPlot.esm.js @@ -4537,6 +4537,17 @@ function uPlot(opts, data, then) { } let queuedCommit = false; + let deferHooks = false; + let hooksQueue = []; + + function flushHooks() { + deferHooks = false; + + for (let i = 0; i < hooksQueue.length; i++) + fire(...hooksQueue[i]); + + hooksQueue.length = 0; + } function commit() { if (!queuedCommit) { @@ -4546,10 +4557,15 @@ function uPlot(opts, data, then) { } // manual batching (aka immediate mode), skips microtask queue - function batch(fn) { + function batch(fn, _deferHooks = false) { queuedCommit = true; + deferHooks = _deferHooks; + fn(self); _commit(); + + if (_deferHooks && hooksQueue.length > 0) + queueMicrotask(flushHooks); } self.batch = batch; @@ -5725,10 +5741,14 @@ function uPlot(opts, data, then) { const hooks = self.hooks = opts.hooks || {}; function fire(evName, a1, a2) { - if (evName in hooks) { - hooks[evName].forEach(fn => { - fn.call(null, self, a1, a2); - }); + if (deferHooks) + hooksQueue.push([evName, a1, a2]); + else { + if (evName in hooks) { + hooks[evName].forEach(fn => { + fn.call(null, self, a1, a2); + }); + } } } diff --git a/dist/uPlot.iife.js b/dist/uPlot.iife.js index 76659cee..5293bde9 100644 --- a/dist/uPlot.iife.js +++ b/dist/uPlot.iife.js @@ -4540,6 +4540,17 @@ var uPlot = (function () { } let queuedCommit = false; + let deferHooks = false; + let hooksQueue = []; + + function flushHooks() { + deferHooks = false; + + for (let i = 0; i < hooksQueue.length; i++) + fire(...hooksQueue[i]); + + hooksQueue.length = 0; + } function commit() { if (!queuedCommit) { @@ -4549,10 +4560,15 @@ var uPlot = (function () { } // manual batching (aka immediate mode), skips microtask queue - function batch(fn) { + function batch(fn, _deferHooks = false) { queuedCommit = true; + deferHooks = _deferHooks; + fn(self); _commit(); + + if (_deferHooks && hooksQueue.length > 0) + queueMicrotask(flushHooks); } self.batch = batch; @@ -5728,10 +5744,14 @@ var uPlot = (function () { const hooks = self.hooks = opts.hooks || {}; function fire(evName, a1, a2) { - if (evName in hooks) { - hooks[evName].forEach(fn => { - fn.call(null, self, a1, a2); - }); + if (deferHooks) + hooksQueue.push([evName, a1, a2]); + else { + if (evName in hooks) { + hooks[evName].forEach(fn => { + fn.call(null, self, a1, a2); + }); + } } } diff --git a/dist/uPlot.iife.min.js b/dist/uPlot.iife.min.js index 0ae4ec64..8598483c 100644 --- a/dist/uPlot.iife.min.js +++ b/dist/uPlot.iife.min.js @@ -1,2 +1,2 @@ /*! https://github.com/leeoniya/uPlot (v1.6.28) */ -var uPlot=function(){"use strict";const e="u-off",l="u-label",t="width",n="height",i="top",o="bottom",s="left",r="right",u="#000",a=u+"0",f="mousemove",c="mousedown",h="mouseup",d="mouseenter",p="mouseleave",m="dblclick",g="change",w="dppxchange",x="--",_="undefined"!=typeof window,b=_?document:null,v=_?window:null,k=_?navigator:null;let y,M;function S(e,l){if(null!=l){let t=e.classList;!t.contains(l)&&t.add(l)}}function E(e,l){let t=e.classList;t.contains(l)&&t.remove(l)}function T(e,l,t){e.style[l]=t+"px"}function z(e,l,t,n){let i=b.createElement(e);return null!=l&&S(i,l),null!=t&&t.insertBefore(i,n),i}function D(e,l){return z("div",e,l)}const P=new WeakMap;function A(l,t,n,i,o){let s="translate("+t+"px,"+n+"px)";s!=P.get(l)&&(l.style.transform=s,P.set(l,s),0>t||0>n||t>i||n>o?S(l,e):E(l,e))}const W=new WeakMap;function Y(e,l,t){let n=l+t;n!=W.get(e)&&(W.set(e,n),e.style.background=l,e.style.borderColor=t)}const C=new WeakMap;function F(e,l,t,n){let i=l+""+t;i!=C.get(e)&&(C.set(e,i),e.style.height=t+"px",e.style.width=l+"px",e.style.marginLeft=n?-l/2+"px":0,e.style.marginTop=n?-t/2+"px":0)}const H={passive:!0},R={...H,capture:!0};function G(e,l,t,n){l.addEventListener(e,t,n?R:H)}function I(e,l,t,n){l.removeEventListener(e,t,n?R:H)}function L(e,l,t,n){let i;t=t||0;let o=2147483647>=(n=n||l.length-1);for(;n-t>1;)i=o?t+n>>1:te((t+n)/2),e>l[i]?t=i:n=i;return e-l[t]>l[n]-e?n:t}function O(e,l,t,n){for(let i=1==n?l:t;i>=l&&t>=i;i+=n)if(null!=e[i])return i;return-1}function N(e,l,t,n){let i=ue(e),o=ue(l);e==l&&(-1==i?(e*=t,l/=t):(e/=t,l*=t));let s=10==t?ae:fe,r=1==o?ie:te,u=(1==i?te:ie)(s(le(e))),a=r(s(le(l))),f=re(t,u),c=re(t,a);return 10==t&&(0>u&&(f=Se(f,-u)),0>a&&(c=Se(c,-a))),n||2==t?(e=f*i,l=c*o):(e=Me(e,f),l=ye(l,c)),[e,l]}function j(e,l,t,n){let i=N(e,l,t,n);return 0==e&&(i[0]=0),0==l&&(i[1]=0),i}_&&function e(){let l=devicePixelRatio;y!=l&&(y=l,M&&I(g,M,e),M=matchMedia(`(min-resolution: ${y-.001}dppx) and (max-resolution: ${y+.001}dppx)`),G(g,M,e),v.dispatchEvent(new CustomEvent(w)))}();const U=.1,B={mode:3,pad:U},V={pad:0,soft:null,mode:0},J={min:V,max:V};function q(e,l,t,n){return Fe(t)?X(e,l,t):(V.pad=t,V.soft=n?0:null,V.mode=n?3:0,X(e,l,J))}function K(e,l){return null==e?l:e}function X(e,l,t){let n=t.min,i=t.max,o=K(n.pad,0),s=K(i.pad,0),r=K(n.hard,-he),u=K(i.hard,he),a=K(n.soft,he),f=K(i.soft,-he),c=K(n.mode,0),h=K(i.mode,0),d=l-e,p=ae(d),m=se(le(e),le(l)),g=ae(m),w=le(g-p);(1e-9>d||w>10)&&(d=0,0!=e&&0!=l||(d=1e-9,2==c&&a!=he&&(o=0),2==h&&f!=-he&&(s=0)));let x=d||m||1e3,_=ae(x),b=re(10,te(_)),v=Se(Me(e-x*(0==d?0==e?.1:1:o),b/10),9),k=a>e||1!=c&&(3!=c||v>a)&&(2!=c||a>v)?he:a,y=se(r,k>v&&e>=k?k:oe(k,v)),M=Se(ye(l+x*(0==d?0==l?.1:1:s),b/10),9),S=l>f||1!=h&&(3!=h||f>M)&&(2!=h||M>f)?-he:f,E=oe(u,M>S&&S>=l?S:se(S,M));return y==E&&0==y&&(E=100),[y,E]}const Z=new Intl.NumberFormat(_?k.language:"en-US"),$=e=>Z.format(e),Q=Math,ee=Q.PI,le=Q.abs,te=Q.floor,ne=Q.round,ie=Q.ceil,oe=Q.min,se=Q.max,re=Q.pow,ue=Q.sign,ae=Q.log10,fe=Q.log2,ce=(e,l=1)=>Q.asinh(e/l),he=1/0;function de(e){return 1+(0|ae((e^e>>31)-(e>>31)))}function pe(e,l,t){return oe(se(e,l),t)}function me(e){return"function"==typeof e?e:()=>e}const ge=e=>e,we=(e,l)=>l,xe=()=>null,_e=()=>!0,be=(e,l)=>e==l,ve=e=>Se(e,14);function ke(e,l){return ve(Se(ve(e/l))*l)}function ye(e,l){return ve(ie(ve(e/l))*l)}function Me(e,l){return ve(te(ve(e/l))*l)}function Se(e,l=0){if(Ye(e))return e;let t=10**l;return ne(e*t*(1+Number.EPSILON))/t}const Ee=new Map;function Te(e){return((""+e).split(".")[1]||"").length}function ze(e,l,t,n){let i=[],o=n.map(Te);for(let s=l;t>s;s++){let l=le(s),t=Se(re(e,s),l);for(let e=0;n.length>e;e++){let r=n[e]*t,u=(0>r||0>s?l:0)+(o[e]>s?o[e]:0),a=Se(r,u);i.push(a),Ee.set(a,u)}}return i}const De={},Pe=[],Ae=[null,null],We=Array.isArray,Ye=Number.isInteger;function Ce(e){return"string"==typeof e}function Fe(e){let l=!1;if(null!=e){let t=e.constructor;l=null==t||t==Object}return l}function He(e){return null!=e&&"object"==typeof e}const Re=Object.getPrototypeOf(Uint8Array);function Ge(e,l=Fe){let t;if(We(e)){let n=e.find((e=>null!=e));if(We(n)||l(n)){t=Array(e.length);for(let n=0;e.length>n;n++)t[n]=Ge(e[n],l)}else t=e.slice()}else if(e instanceof Re)t=e.slice();else if(l(e)){t={};for(let n in e)t[n]=Ge(e[n],l)}else t=e;return t}function Ie(e){let l=arguments;for(let t=1;l.length>t;t++){let n=l[t];for(let l in n)Fe(e[l])?Ie(e[l],Ge(n[l])):e[l]=Ge(n[l])}return e}function Le(e,l,t){for(let n,i=0,o=-1;l.length>i;i++){let s=l[i];if(s>o){for(n=s-1;n>=0&&null==e[n];)e[n--]=null;for(n=s+1;t>n&&null==e[n];)e[o=n++]=null}}}const Oe="undefined"==typeof queueMicrotask?e=>Promise.resolve().then(e):queueMicrotask,Ne=["January","February","March","April","May","June","July","August","September","October","November","December"],je=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Ue(e){return e.slice(0,3)}const Be=je.map(Ue),Ve=Ne.map(Ue),Je={MMMM:Ne,MMM:Ve,WWWW:je,WWW:Be};function qe(e){return(10>e?"0":"")+e}const Ke={YYYY:e=>e.getFullYear(),YY:e=>(e.getFullYear()+"").slice(2),MMMM:(e,l)=>l.MMMM[e.getMonth()],MMM:(e,l)=>l.MMM[e.getMonth()],MM:e=>qe(e.getMonth()+1),M:e=>e.getMonth()+1,DD:e=>qe(e.getDate()),D:e=>e.getDate(),WWWW:(e,l)=>l.WWWW[e.getDay()],WWW:(e,l)=>l.WWW[e.getDay()],HH:e=>qe(e.getHours()),H:e=>e.getHours(),h:e=>{let l=e.getHours();return 0==l?12:l>12?l-12:l},AA:e=>12>e.getHours()?"AM":"PM",aa:e=>12>e.getHours()?"am":"pm",a:e=>12>e.getHours()?"a":"p",mm:e=>qe(e.getMinutes()),m:e=>e.getMinutes(),ss:e=>qe(e.getSeconds()),s:e=>e.getSeconds(),fff:e=>function(e){return(10>e?"00":100>e?"0":"")+e}(e.getMilliseconds())};function Xe(e,l){l=l||Je;let t,n=[],i=/\{([a-z]+)\}|[^{]+/gi;for(;t=i.exec(e);)n.push("{"==t[0][0]?Ke[t[1]]:t[0]);return e=>{let t="";for(let i=0;n.length>i;i++)t+="string"==typeof n[i]?n[i]:n[i](e,l);return t}}const Ze=(new Intl.DateTimeFormat).resolvedOptions().timeZone,$e=e=>e%1==0,Qe=[1,2,2.5,5],el=ze(10,-16,0,Qe),ll=ze(10,0,16,Qe),tl=ll.filter($e),nl=el.concat(ll),il="{YYYY}",ol="\n"+il,sl="{M}/{D}",rl="\n"+sl,ul=rl+"/{YY}",al="{aa}",fl="{h}:{mm}"+al,cl="\n"+fl,hl=":{ss}",dl=null;function pl(e){let l=1e3*e,t=60*l,n=60*t,i=24*n,o=30*i,s=365*i;return[(1==e?ze(10,0,3,Qe).filter($e):ze(10,-3,0,Qe)).concat([l,5*l,10*l,15*l,30*l,t,5*t,10*t,15*t,30*t,n,2*n,3*n,4*n,6*n,8*n,12*n,i,2*i,3*i,4*i,5*i,6*i,7*i,8*i,9*i,10*i,15*i,o,2*o,3*o,4*o,6*o,s,2*s,5*s,10*s,25*s,50*s,100*s]),[[s,il,dl,dl,dl,dl,dl,dl,1],[28*i,"{MMM}",ol,dl,dl,dl,dl,dl,1],[i,sl,ol,dl,dl,dl,dl,dl,1],[n,"{h}"+al,ul,dl,rl,dl,dl,dl,1],[t,fl,ul,dl,rl,dl,dl,dl,1],[l,hl,ul+" "+fl,dl,rl+" "+fl,dl,cl,dl,1],[e,hl+".{fff}",ul+" "+fl,dl,rl+" "+fl,dl,cl,dl,1]],function(l){return(r,u,a,f,c,h)=>{let d=[],p=c>=s,m=c>=o&&s>c,g=l(a),w=Se(g*e,3),x=yl(g.getFullYear(),p?0:g.getMonth(),m||p?1:g.getDate()),_=Se(x*e,3);if(m||p){let t=m?c/o:0,n=p?c/s:0,i=w==_?w:Se(yl(x.getFullYear()+n,x.getMonth()+t,1)*e,3),r=new Date(ne(i/e)),u=r.getFullYear(),a=r.getMonth();for(let o=0;f>=i;o++){let s=yl(u+n*o,a+t*o,1),r=s-l(Se(s*e,3));i=Se((+s+r)*e,3),i>f||d.push(i)}}else{let o=i>c?c:i,s=_+(te(a)-te(w))+ye(w-_,o);d.push(s);let p=l(s),m=p.getHours()+p.getMinutes()/t+p.getSeconds()/n,g=c/n,x=h/r.axes[u]._space;for(;s=Se(s+c,1==e?0:3),f>=s;)if(g>1){let e=te(Se(m+g,6))%24,t=l(s).getHours()-e;t>1&&(t=-1),s-=t*n,m=(m+g)%24,.7>Se((s-d[d.length-1])/c,3)*x||d.push(s)}else d.push(s)}return d}}]}const[ml,gl,wl]=pl(1),[xl,_l,bl]=pl(.001);function vl(e,l){return e.map((e=>e.map(((t,n)=>0==n||8==n||null==t?t:l(1==n||0==e[8]?t:e[1]+t)))))}function kl(e,l){return(t,n,i,o,s)=>{let r,u,a,f,c,h,d=l.find((e=>s>=e[0]))||l[l.length-1];return n.map((l=>{let t=e(l),n=t.getFullYear(),i=t.getMonth(),o=t.getDate(),s=t.getHours(),p=t.getMinutes(),m=t.getSeconds(),g=n!=r&&d[2]||i!=u&&d[3]||o!=a&&d[4]||s!=f&&d[5]||p!=c&&d[6]||m!=h&&d[7]||d[1];return r=n,u=i,a=o,f=s,c=p,h=m,g(t)}))}}function yl(e,l,t){return new Date(e,l,t)}function Ml(e,l){return l(e)}function Sl(e,l){return(t,n,i,o)=>null==o?x:l(e(n))}ze(2,-53,53,[1]);const El={show:!0,live:!0,isolate:!1,mount:()=>{},markers:{show:!0,width:2,stroke:function(e,l){let t=e.series[l];return t.width?t.stroke(e,l):t.points.width?t.points.stroke(e,l):null},fill:function(e,l){return e.series[l].fill(e,l)},dash:"solid"},idx:null,idxs:null,values:[]},Tl=[0,0];function zl(e,l,t,n=!0){return e=>{0==e.button&&(!n||e.target==l)&&t(e)}}function Dl(e,l,t,n=!0){return e=>{(!n||e.target==l)&&t(e)}}const Pl={show:!0,x:!0,y:!0,lock:!1,move:function(e,l,t){return Tl[0]=l,Tl[1]=t,Tl},points:{show:function(e,l){let i=e.cursor.points,o=D(),s=i.size(e,l);T(o,t,s),T(o,n,s);let r=s/-2;T(o,"marginLeft",r),T(o,"marginTop",r);let u=i.width(e,l,s);return u&&T(o,"borderWidth",u),o},size:function(e,l){return e.series[l].points.size},width:0,stroke:function(e,l){let t=e.series[l].points;return t._stroke||t._fill},fill:function(e,l){let t=e.series[l].points;return t._fill||t._stroke}},bind:{mousedown:zl,mouseup:zl,click:zl,dblclick:zl,mousemove:Dl,mouseleave:Dl,mouseenter:Dl},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(e,l)=>{l.stopPropagation(),l.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(e,l,t,n,i)=>n-i,prox:-1,bias:0},left:-10,top:-10,idx:null,dataIdx:function(e,l,t){return t},idxs:null,event:null},Al={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},Wl=Ie({},Al,{filter:we}),Yl=Ie({},Wl,{size:10}),Cl=Ie({},Al,{show:!1}),Fl='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',Hl="bold "+Fl,Rl={show:!0,scale:"x",stroke:u,space:50,gap:5,size:50,labelGap:0,labelSize:30,labelFont:Hl,side:2,grid:Wl,ticks:Yl,border:Cl,font:Fl,lineGap:1.5,rotate:0},Gl={show:!0,scale:"x",auto:!1,sorted:1,min:he,max:-he,idxs:[]};function Il(e,l){return l.map((e=>null==e?"":$(e)))}function Ll(e,l,t,n,i,o,s){let r=[],u=Ee.get(i)||0;for(let e=t=s?t:Se(ye(t,i),u);n>=e;e=Se(e+i,u))r.push(Object.is(e,-0)?0:e);return r}function Ol(e,l,t,n,i){const o=[],s=e.scales[e.axes[l].scale].log,r=te((10==s?ae:fe)(t));i=re(s,r),10==s&&0>r&&(i=Se(i,-r));let u=t;do{o.push(u),u+=i,10==s&&(u=Se(u,Ee.get(i))),i*s>u||(i=u)}while(n>=u);return o}function Nl(e,l,t,n,i){let o=e.scales[e.axes[l].scale].asinh,s=n>o?Ol(e,l,se(o,t),n,i):[o],r=0>n||t>0?[]:[0];return(-o>t?Ol(e,l,se(o,-n),-t,i):[o]).reverse().map((e=>-e)).concat(r,s)}const jl=/./,Ul=/[12357]/,Bl=/[125]/,Vl=/1/,Jl=(e,l,t,n)=>e.map(((e,i)=>4==l&&0==e||i%n==0&&t.test(e.toExponential()[0>e?1:0])?e:null));function ql(e,l,t){let n=e.axes[t],i=n.scale,o=e.scales[i],s=e.valToPos,r=n._space,u=s(10,i),a=s(9,i)-ue)return Jl(l.slice().reverse(),o.distr,a,ie(r/e)).reverse()}return Jl(l,o.distr,a,1)}function Kl(e,l,t){let n=e.axes[t],i=n.scale,o=n._space,s=e.valToPos,r=le(s(1,i)-s(2,i));return o>r?Jl(l.slice().reverse(),3,jl,ie(o/r)).reverse():l}function Xl(e,l,t,n){return null==n?x:null==l?"":$(l)}const Zl={show:!0,scale:"y",stroke:u,space:30,gap:5,size:50,labelGap:0,labelSize:30,labelFont:Hl,side:3,grid:Wl,ticks:Yl,border:Cl,font:Fl,lineGap:1.5,rotate:0},$l={scale:null,auto:!0,sorted:0,min:he,max:-he},Ql=(e,l,t,n,i)=>i,et={show:!0,auto:!0,sorted:0,gaps:Ql,alpha:1,facets:[Ie({},$l,{scale:"x"}),Ie({},$l,{scale:"y"})]},lt={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:Ql,alpha:1,points:{show:function(e,l){let{scale:t,idxs:n}=e.series[0],i=e._data[0],o=e.valToPos(i[n[0]],t,!0),s=e.valToPos(i[n[1]],t,!0);return le(s-o)/(e.series[l].points.space*y)>=n[1]-n[0]},filter:null},values:null,min:he,max:-he,idxs:[],path:null,clip:null};function tt(e,l,t){return t/10}const nt={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},it=Ie({},nt,{time:!1,ori:1}),ot={};function st(e){let l=ot[e];return l||(l={key:e,plots:[],sub(e){l.plots.push(e)},unsub(e){l.plots=l.plots.filter((l=>l!=e))},pub(e,t,n,i,o,s,r){for(let u=0;l.plots.length>u;u++)l.plots[u]!=t&&l.plots[u].pub(e,t,n,i,o,s,r)}},null!=e&&(ot[e]=l)),l}function rt(e,l,t){const n=e.mode,i=e.series[l],o=2==n?e._data[l]:e._data,s=e.scales,r=e.bbox;let u=o[0],a=2==n?o[1]:o[l],f=2==n?s[i.facets[0].scale]:s[e.series[0].scale],c=2==n?s[i.facets[1].scale]:s[i.scale],h=r.left,d=r.top,p=r.width,m=r.height,g=e.valToPosH,w=e.valToPosV;return 0==f.ori?t(i,u,a,f,c,g,w,h,d,p,m,mt,wt,_t,vt,yt):t(i,u,a,f,c,w,g,d,h,m,p,gt,xt,bt,kt,Mt)}function ut(e,l){let t=0,n=0,i=K(e.bands,Pe);for(let e=0;i.length>e;e++){let o=i[e];o.series[0]==l?t=o.dir:o.series[1]==l&&(n|=1==o.dir?1:2)}return[t,1==n?-1:2==n?1:3==n?2:0]}function at(e,l,t,n,i){let o=e.series[l],s=e.scales[2==e.mode?o.facets[1].scale:o.scale];return-1==i?s.min:1==i?s.max:3==s.distr?1==s.dir?s.min:s.max:0}function ft(e,l,t,n,i,o){return rt(e,l,((e,l,s,r,u,a,f,c,h,d,p)=>{let m=e.pxRound;const g=0==r.ori?wt:xt;let w,x;1==r.dir*(0==r.ori?1:-1)?(w=t,x=n):(w=n,x=t);let _=m(a(l[w],r,d,c)),b=m(f(s[w],u,p,h)),v=m(a(l[x],r,d,c)),k=m(f(1==o?u.max:u.min,u,p,h)),y=new Path2D(i);return g(y,v,k),g(y,_,k),g(y,_,b),y}))}function ct(e,l,t,n,i,o){let s=null;if(e.length>0){s=new Path2D;const r=0==l?_t:bt;let u=t;for(let l=0;e.length>l;l++){let t=e[l];if(t[1]>t[0]){let e=t[0]-u;e>0&&r(s,u,n,e,n+o),u=t[1]}}let a=t+i-u,f=10;a>0&&r(s,u,n-f/2,a,n+o+f)}return s}function ht(e,l,t,n,i,o,s){let r=[],u=e.length;for(let a=1==i?t:n;a>=t&&n>=a;a+=i)if(null===l[a]){let f=a,c=a;if(1==i)for(;++a<=n&&null===l[a];)c=a;else for(;--a>=t&&null===l[a];)c=a;let h=o(e[f]),d=c==f?h:o(e[c]),p=f-i;h=s>0||0>p||p>=u?h:o(e[p]);let m=c+i;d=0>s||0>m||m>=u?d:o(e[m]),h>d||r.push([h,d])}return r}function dt(e){return 0==e?ge:1==e?ne:l=>ke(l,e)}function pt(e){let l=0==e?mt:gt,t=0==e?(e,l,t,n,i,o)=>{e.arcTo(l,t,n,i,o)}:(e,l,t,n,i,o)=>{e.arcTo(t,l,i,n,o)},n=0==e?(e,l,t,n,i)=>{e.rect(l,t,n,i)}:(e,l,t,n,i)=>{e.rect(t,l,i,n)};return(e,i,o,s,r,u=0,a=0)=>{0==u&&0==a?n(e,i,o,s,r):(u=oe(u,s/2,r/2),a=oe(a,s/2,r/2),l(e,i+u,o),t(e,i+s,o,i+s,o+r,u),t(e,i+s,o+r,i,o+r,a),t(e,i,o+r,i,o,a),t(e,i,o,i+s,o,u),e.closePath())}}const mt=(e,l,t)=>{e.moveTo(l,t)},gt=(e,l,t)=>{e.moveTo(t,l)},wt=(e,l,t)=>{e.lineTo(l,t)},xt=(e,l,t)=>{e.lineTo(t,l)},_t=pt(0),bt=pt(1),vt=(e,l,t,n,i,o)=>{e.arc(l,t,n,i,o)},kt=(e,l,t,n,i,o)=>{e.arc(t,l,n,i,o)},yt=(e,l,t,n,i,o,s)=>{e.bezierCurveTo(l,t,n,i,o,s)},Mt=(e,l,t,n,i,o,s)=>{e.bezierCurveTo(t,l,i,n,s,o)};function St(){return(e,l,t,n,i)=>rt(e,l,((l,o,s,r,u,a,f,c,h,d,p)=>{let m,g,{pxRound:w,points:x}=l;0==r.ori?(m=mt,g=vt):(m=gt,g=kt);const _=Se(x.width*y,3);let b=(x.size-x.width)/2*y,v=Se(2*b,3),k=new Path2D,M=new Path2D,{left:S,top:E,width:T,height:z}=e.bbox;_t(M,S-v,E-v,T+2*v,z+2*v);const D=e=>{if(null!=s[e]){let l=w(a(o[e],r,d,c)),t=w(f(s[e],u,p,h));m(k,l+b,t),g(k,l,t,b,0,2*ee)}};if(i)i.forEach(D);else for(let e=t;n>=e;e++)D(e);return{stroke:_>0?k:null,fill:k,clip:M,flags:3}}))}function Et(e){return(l,t,n,i,o,s)=>{n!=i&&(o!=n&&s!=n&&e(l,t,n),o!=i&&s!=i&&e(l,t,i),e(l,t,s))}}const Tt=Et(wt),zt=Et(xt);function Dt(e){const l=K(e?.alignGaps,0);return(e,t,n,i)=>rt(e,t,((o,s,r,u,a,f,c,h,d,p,m)=>{let g,w,x=o.pxRound,_=e=>x(f(e,u,p,h)),b=e=>x(c(e,a,m,d));0==u.ori?(g=wt,w=Tt):(g=xt,w=zt);const v=u.dir*(0==u.ori?1:-1),k={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},y=k.stroke;let M,S,E,T=he,z=-he,D=_(s[1==v?n:i]),P=O(r,n,i,1*v),A=O(r,n,i,-1*v),W=_(s[P]),Y=_(s[A]),C=!1;for(let e=1==v?n:i;e>=n&&i>=e;e+=v){let l=_(s[e]),t=r[e];l==D?null!=t?(S=b(t),T==he&&(g(y,l,S),M=S),T=oe(S,T),z=se(S,z)):null===t&&(C=!0):(T!=he&&(w(y,D,T,z,M,S),E=D),null!=t?(S=b(t),g(y,l,S),T=z=M=S):(T=he,z=-he,null===t&&(C=!0)),D=l)}T!=he&&T!=z&&E!=D&&w(y,D,T,z,M,S);let[F,H]=ut(e,t);if(null!=o.fill||0!=F){let l=k.fill=new Path2D(y),n=b(o.fillTo(e,t,o.min,o.max,F));g(l,Y,n),g(l,W,n)}if(!o.spanGaps){let a=[];C&&a.push(...ht(s,r,n,i,v,_,l)),k.gaps=a=o.gaps(e,t,n,i,a),k.clip=ct(a,u.ori,h,d,p,m)}return 0!=H&&(k.band=2==H?[ft(e,t,n,i,y,-1),ft(e,t,n,i,y,1)]:ft(e,t,n,i,y,H)),k}))}function Pt(e,l,t,n,i,o,s=he){if(e.length>1){let r=null;for(let u=0,a=1/0;e.length>u;u++)if(void 0!==l[u]){if(null!=r){let l=le(e[u]-e[r]);a>l&&(a=l,s=le(t(e[u],n,i,o)-t(e[r],n,i,o)))}r=u}}return s}function At(e,l,t,n,i){const o=e.length;if(2>o)return null;const s=new Path2D;if(t(s,e[0],l[0]),2==o)n(s,e[1],l[1]);else{let t=Array(o),n=Array(o-1),r=Array(o-1),u=Array(o-1);for(let t=0;o-1>t;t++)r[t]=l[t+1]-l[t],u[t]=e[t+1]-e[t],n[t]=r[t]/u[t];t[0]=n[0];for(let e=1;o-1>e;e++)0===n[e]||0===n[e-1]||n[e-1]>0!=n[e]>0?t[e]=0:(t[e]=3*(u[e-1]+u[e])/((2*u[e]+u[e-1])/n[e-1]+(u[e]+2*u[e-1])/n[e]),isFinite(t[e])||(t[e]=0));t[o-1]=n[o-2];for(let n=0;o-1>n;n++)i(s,e[n]+u[n]/3,l[n]+t[n]*u[n]/3,e[n+1]-u[n]/3,l[n+1]-t[n+1]*u[n]/3,e[n+1],l[n+1])}return s}const Wt=new Set;function Yt(){for(let e of Wt)e.syncRect(!0)}_&&(G("resize",v,Yt),G("scroll",v,Yt,!0),G(w,v,(()=>{qt.pxRatio=y})));const Ct=Dt(),Ft=St();function Ht(e,l,t,n){return(n?[e[0],e[1]].concat(e.slice(2)):[e[0]].concat(e.slice(1))).map(((e,n)=>Rt(e,n,l,t)))}function Rt(e,l,t,n){return Ie({},0==l?t:n,e)}function Gt(e,l,t){return null==l?Ae:[l,t]}const It=Gt;function Lt(e,l,t){return null==l?Ae:q(l,t,U,!0)}function Ot(e,l,t,n){return null==l?Ae:N(l,t,e.scales[n].log,!1)}const Nt=Ot;function jt(e,l,t,n){return null==l?Ae:j(l,t,e.scales[n].log,!1)}const Ut=jt;function Bt(e,l,t,n,i){let o=se(de(e),de(l)),s=l-e,r=L(i/n*s,t);do{let e=t[r],l=n*e/s;if(l>=i&&17>=o+(5>e?Ee.get(e):0))return[e,l]}while(++r(l=ne((t=+n)*y))+"px")),l,t]}function Jt(e){e.show&&[e.font,e.labelFont].forEach((e=>{let l=Se(e[2]*y,1);e[0]=e[0].replace(/[0-9.]+px/,l+"px"),e[1]=l}))}function qt(u,g,_){const k={mode:K(u.mode,1)},M=k.mode;function P(e,l){return((3==l.distr?ae(e>0?e:l.clamp(k,e,l.min,l.max,l.key)):4==l.distr?ce(e,l.asinh):e)-l._min)/(l._max-l._min)}function W(e,l,t,n){let i=P(e,l);return n+t*(-1==l.dir?1-i:i)}function C(e,l,t,n){let i=P(e,l);return n+t*(-1==l.dir?i:1-i)}function H(e,l,t,n){return 0==l.ori?W(e,l,t,n):C(e,l,t,n)}k.valToPosH=W,k.valToPosV=C;let R=!1;k.status=0;const O=k.root=D("uplot");null!=u.id&&(O.id=u.id),S(O,u.class),u.title&&(D("u-title",O).textContent=u.title);const V=z("canvas"),J=k.ctx=V.getContext("2d"),X=D("u-wrap",O);G("click",X,(e=>{e.target===$&&(Fn!=An||Hn!=Wn)&&Nn.click(k,e)}),!0);const Z=k.under=D("u-under",X);X.appendChild(V);const $=k.over=D("u-over",X),te=+K((u=Ge(u)).pxAlign,1),ue=dt(te);(u.plugins||[]).forEach((e=>{e.opts&&(u=e.opts(k,u)||u)}));const fe=u.ms||.001,de=k.series=1==M?Ht(u.series||[],Gl,lt,!1):function(e,l){return e.map(((e,t)=>0==t?null:Ie({},l,e)))}(u.series||[null],et),ge=k.axes=Ht(u.axes||[],Rl,Zl,!0),ve=k.scales={},Me=k.bands=u.bands||[];Me.forEach((e=>{e.fill=me(e.fill||null),e.dir=K(e.dir,-1)}));const ze=2==M?de[1].facets[0].scale:de[0].scale,Ye={axes:function(){for(let e=0;ge.length>e;e++){let l=ge[e];if(!l.show||!l._show)continue;let t,n,u=l.side,a=u%2,f=l.stroke(k,e),c=0==u||3==u?-1:1;if(l.label){let e=ne((l._lpos+l.labelGap*c)*y);hn(l.labelFont[0],f,"center",2==u?i:o),J.save(),1==a?(t=n=0,J.translate(e,ne($l+ot/2)),J.rotate((3==u?-ee:ee)/2)):(t=ne(Jl+Ql/2),n=e),J.fillText(l.label,t,n),J.restore()}let[h,d]=l._found;if(0==d)continue;let p=ve[l.scale],m=0==a?Ql:ot,g=0==a?Jl:$l,w=ne(l.gap*y),x=l._splits,_=2==p.distr?x.map((e=>rn[e])):x,b=2==p.distr?rn[x[1]]-rn[x[0]]:h,v=l.ticks,M=l.border,S=v.show?ne(v.size*y):0,E=l._rotate*-ee/180,T=ue(l._pos*y),z=T+(S+w)*c;n=0==a?z:0,t=1==a?z:0,hn(l.font[0],f,1==l.align?s:2==l.align?r:E>0?s:0>E?r:0==a?"center":3==u?r:s,E||1==a?"middle":2==u?i:o);let D=l.font[1]*l.lineGap,P=x.map((e=>ue(H(e,p,m,g)))),A=l._values;for(let e=0;A.length>e;e++){let l=A[e];if(null!=l){0==a?t=P[e]:n=P[e],l=""+l;let i=-1==l.indexOf("\n")?[l]:l.split(/\n/gm);for(let e=0;i.length>e;e++){let l=i[e];E?(J.save(),J.translate(t,n+e*D),J.rotate(E),J.fillText(l,0,0),J.restore()):J.fillText(l,t,n+e*D)}}}v.show&&vn(P,v.filter(k,_,e,d,b),a,u,T,S,Se(v.width*y,3),v.stroke(k,e),v.dash,v.cap);let W=l.grid;W.show&&vn(P,W.filter(k,_,e,d,b),a,0==a?2:1,0==a?$l:Jl,0==a?ot:Ql,Se(W.width*y,3),W.stroke(k,e),W.dash,W.cap),M.show&&vn([T],[1],0==a?1:0,0==a?1:2,1==a?$l:Jl,1==a?ot:Ql,Se(M.width*y,3),M.stroke(k,e),M.dash,M.cap)}Mi("drawAxes")},series:function(){At>0&&(de.forEach(((e,l)=>{if(l>0&&e.show&&(mn(l,!1),mn(l,!0),null==e._paths)){sn!=e.alpha&&(J.globalAlpha=sn=e.alpha);let t=2==M?[0,g[l][0].length-1]:function(e){let l=pe(Yt-1,0,At-1),t=pe(qt+1,0,At-1);for(;null==e[l]&&l>0;)l--;for(;null==e[t]&&At-1>t;)t++;return[l,t]}(g[l]);e._paths=e.paths(k,l,t[0],t[1]),1!=sn&&(J.globalAlpha=sn=1)}})),de.forEach(((e,l)=>{if(l>0&&e.show){sn!=e.alpha&&(J.globalAlpha=sn=e.alpha),null!=e._paths&&gn(l,!1);{let t=null!=e._paths?e._paths.gaps:null,n=e.points.show(k,l,Yt,qt,t),i=e.points.filter(k,l,n,t);(n||i)&&(e.points._paths=e.points.paths(k,l,Yt,qt,i),gn(l,!0))}1!=sn&&(J.globalAlpha=sn=1),Mi("drawSeries",l)}})))}},Re=(u.drawOrder||["axes","series"]).map((e=>Ye[e]));function Le(e){let l=ve[e];if(null==l){let t=(u.scales||De)[e]||De;if(null!=t.from)Le(t.from),ve[e]=Ie({},ve[t.from],t,{key:e});else{l=ve[e]=Ie({},e==ze?nt:it,t),l.key=e;let n=l.time,i=l.range,o=We(i);if((e!=ze||2==M&&!n)&&(!o||null!=i[0]&&null!=i[1]||(i={min:null==i[0]?B:{mode:1,hard:i[0],soft:i[0]},max:null==i[1]?B:{mode:1,hard:i[1],soft:i[1]}},o=!1),!o&&Fe(i))){let e=i;i=(l,t,n)=>null==t?Ae:q(t,n,e)}l.range=me(i||(n?It:e==ze?3==l.distr?Nt:4==l.distr?Ut:Gt:3==l.distr?Ot:4==l.distr?jt:Lt)),l.auto=me(!o&&l.auto),l.clamp=me(l.clamp||tt),l._min=l._max=null}}}Le("x"),Le("y"),1==M&&de.forEach((e=>{Le(e.scale)})),ge.forEach((e=>{Le(e.scale)}));for(let e in u.scales)Le(e);const Ne=ve[ze],je=Ne.distr;let Ue,Be;0==Ne.ori?(S(O,"u-hz"),Ue=W,Be=C):(S(O,"u-vt"),Ue=C,Be=W);const Ve={};for(let e in ve){let l=ve[e];null==l.min&&null==l.max||(Ve[e]={min:l.min,max:l.max},l.min=l.max=null)}const Je=u.tzDate||(e=>new Date(ne(e/fe))),qe=u.fmtDate||Xe,Ke=1==fe?wl(Je):bl(Je),Ze=kl(Je,vl(1==fe?gl:_l,qe)),$e=Sl(Je,Ml("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",qe)),Qe=[],el=k.legend=Ie({},El,u.legend),ll=el.show,il=el.markers;let ol,sl,rl;el.idxs=Qe,il.width=me(il.width),il.dash=me(il.dash),il.stroke=me(il.stroke),il.fill=me(il.fill);let ul,al=[],fl=[],cl=!1,hl={};if(el.live){const e=de[1]?de[1].values:null;cl=null!=e,ul=cl?e(k,1,0):{_:0};for(let e in ul)hl[e]=x}if(ll)if(ol=z("table","u-legend",O),rl=z("tbody",null,ol),el.mount(k,ol),cl){sl=z("thead",null,ol,rl);let e=z("tr",null,sl);for(var dl in z("th",null,e),ul)z("th",l,e).textContent=dl}else S(ol,"u-inline"),el.live&&S(ol,"u-live");const pl={show:!0},yl={show:!1},Tl=new Map;function zl(e,l,t,n=!0){const i=Tl.get(l)||{},o=xt.bind[e](k,l,t,n);o&&(G(e,l,i[e]=o),Tl.set(l,i))}function Dl(e,l){const t=Tl.get(l)||{};for(let n in t)null!=e&&n!=e||(I(n,l,t[n]),delete t[n]);null==e&&Tl.delete(l)}let Al=0,Wl=0,Yl=0,Cl=0,Fl=0,Hl=0,jl=Fl,Ul=Hl,Bl=Yl,Vl=Cl,Jl=0,$l=0,Ql=0,ot=0;k.bbox={};let rt=!1,ut=!1,ft=!1,ct=!1,ht=!1,pt=!1;function mt(e,l,t){(t||e!=k.width||l!=k.height)&>(e,l),Mn(!1),ft=!0,ut=!0,Gn()}function gt(e,l){k.width=Al=Yl=e,k.height=Wl=Cl=l,Fl=Hl=0,function(){let e=!1,l=!1,t=!1,n=!1;ge.forEach((i=>{if(i.show&&i._show){let{side:o,_size:s}=i,r=s+(null!=i.label?i.labelSize:0);r>0&&(o%2?(Yl-=r,3==o?(Fl+=r,n=!0):t=!0):(Cl-=r,0==o?(Hl+=r,e=!0):l=!0))}})),Tt[0]=e,Tt[1]=t,Tt[2]=l,Tt[3]=n,Yl-=Pt[1]+Pt[3],Fl+=Pt[3],Cl-=Pt[2]+Pt[0],Hl+=Pt[0]}(),function(){let e=Fl+Yl,l=Hl+Cl,t=Fl,n=Hl;function i(i,o){switch(i){case 1:return e+=o,e-o;case 2:return l+=o,l-o;case 3:return t-=o,t+o;case 0:return n-=o,n+o}}ge.forEach((e=>{if(e.show&&e._show){let l=e.side;e._pos=i(l,e._size),null!=e.label&&(e._lpos=i(l,e.labelSize))}}))}();let t=k.bbox;Jl=t.left=ke(Fl*y,.5),$l=t.top=ke(Hl*y,.5),Ql=t.width=ke(Yl*y,.5),ot=t.height=ke(Cl*y,.5)}const wt=3;k.setSize=function({width:e,height:l}){mt(e,l)};const xt=k.cursor=Ie({},Pl,{drag:{y:2==M}},u.cursor),_t=e=>{xt.event=e};xt.idxs=Qe,xt._lock=!1;let bt=xt.points;bt.show=me(bt.show),bt.size=me(bt.size),bt.stroke=me(bt.stroke),bt.width=me(bt.width),bt.fill=me(bt.fill);const vt=k.focus=Ie({},u.focus||{alpha:.3},xt.focus),kt=vt.prox>=0;let yt=[null],Mt=[null],St=[null];function Et(t,n){if(1==M||n>0){let e=1==M&&ve[t.scale].time,l=t.value;t.value=e?Ce(l)?Sl(Je,Ml(l,qe)):l||$e:l||Xl,t.label=t.label||(e?"Time":"Value")}if(n>0){t.width=null==t.width?1:t.width,t.paths=t.paths||Ct||xe,t.fillTo=me(t.fillTo||at),t.pxAlign=+K(t.pxAlign,te),t.pxRound=dt(t.pxAlign),t.stroke=me(t.stroke||null),t.fill=me(t.fill||null),t._stroke=t._fill=t._paths=t._focus=null;let e=function(e){return Se(1*(3+2*(e||1)),3)}(se(1,t.width)),l=t.points=Ie({},{size:e,width:se(1,.2*e),stroke:t.stroke,space:2*e,paths:Ft,_stroke:null,_fill:null},t.points);l.show=me(l.show),l.filter=me(l.filter),l.fill=me(l.fill),l.stroke=me(l.stroke),l.paths=me(l.paths),l.pxAlign=t.pxAlign}if(ll){let i=function(t,n){if(0==n&&(cl||!el.live||2==M))return Ae;let i=[],o=z("tr","u-series",rl,rl.childNodes[n]);S(o,t.class),t.show||S(o,e);let s=z("th",null,o);if(il.show){let e=D("u-marker",s);if(n>0){let l=il.width(k,n);l&&(e.style.border=l+"px "+il.dash(k,n)+" "+il.stroke(k,n)),e.style.background=il.fill(k,n)}}let r=D(l,s);for(var u in r.textContent=t.label,n>0&&(il.show||(r.style.color=t.width>0?il.stroke(k,n):il.fill(k,n)),zl("click",s,(e=>{if(xt._lock)return;_t(e);let l=de.indexOf(t);if((e.ctrlKey||e.metaKey)!=el.isolate){let e=de.some(((e,t)=>t>0&&t!=l&&e.show));de.forEach(((t,n)=>{n>0&&Kn(n,e?n==l?pl:yl:pl,!0,Ei.setSeries)}))}else Kn(l,{show:!t.show},!0,Ei.setSeries)}),!1),kt&&zl(d,s,(e=>{xt._lock||(_t(e),Kn(de.indexOf(t),Qn,!0,Ei.setSeries))}),!1)),ul){let e=z("td","u-value",o);e.textContent="--",i.push(e)}return[o,i]}(t,n);al.splice(n,0,i[0]),fl.splice(n,0,i[1]),el.values.push(null)}if(xt.show){Qe.splice(n,0,null);let e=function(e,l){if(l>0){let t=xt.points.show(k,l);if(t)return S(t,"u-cursor-pt"),S(t,e.class),A(t,-10,-10,Yl,Cl),$.insertBefore(t,yt[l]),t}}(t,n);null!=e&&(yt.splice(n,0,e),Mt.splice(n,0,0),St.splice(n,0,0))}Mi("addSeries",n)}k.addSeries=function(e,l){l=null==l?de.length:l,e=1==M?Rt(e,l,Gl,lt):Rt(e,l,null,et),de.splice(l,0,e),Et(de[l],l)},k.delSeries=function(e){if(de.splice(e,1),ll){el.values.splice(e,1),fl.splice(e,1);let l=al.splice(e,1)[0];Dl(null,l.firstChild),l.remove()}xt.show&&(Qe.splice(e,1),yt.length>1&&(yt.splice(e,1)[0].remove(),Mt.splice(e,1),St.splice(e,1))),Mi("delSeries",e)};const Tt=[!1,!1,!1,!1];function zt(e,l,t){let[n,i,o,s]=t,r=l%2,u=0;return 0==r&&(s||i)&&(u=0==l&&!n||2==l&&!o?ne(Rl.size/3):0),1==r&&(n||o)&&(u=1==l&&!i||3==l&&!s?ne(Zl.size/2):0),u}const Dt=k.padding=(u.padding||[zt,zt,zt,zt]).map((e=>me(K(e,zt)))),Pt=k._padding=Dt.map(((e,l)=>e(k,l,Tt,0)));let At,Yt=null,qt=null;const Kt=1==M?de[0].idxs:null;let Xt,Zt,$t,Qt,en,ln,tn,nn,on,sn,rn=null,un=!1;function an(e,l){if(g=null==e?[]:e,2==M){At=0;for(let e=1;de.length>e;e++)At+=g[e][0].length;k._data=g}else{0==g.length&&(g=[[]]),rn=g[0],At=rn.length;let e=g;if(2==je){e=g.slice();let l=e[0]=Array(At);for(let e=0;At>e;e++)l[e]=e}k._data=g=e}if(k.data=g,Mn(!0),Mi("setData"),2==je&&(ft=!0),!1!==l){let e=Ne;e.auto(k,un)?fn():qn(ze,e.min,e.max),ct=ct||xt.left>=0,pt=!0,Gn()}}function fn(){let e,l;un=!0,1==M&&(At>0?(Yt=Kt[0]=0,qt=Kt[1]=At-1,e=g[0][Yt],l=g[0][qt],2==je?(e=Yt,l=qt):e==l&&(3==je?[e,l]=N(e,e,Ne.log,!1):4==je?[e,l]=j(e,e,Ne.log,!1):Ne.time?l=e+ne(86400/fe):[e,l]=q(e,l,U,!0))):(Yt=Kt[0]=e=null,qt=Kt[1]=l=null)),qn(ze,e,l)}function cn(e,l,t,n,i,o){e??=a,t??=Pe,n??="butt",i??=a,o??="round",e!=Xt&&(J.strokeStyle=Xt=e),i!=Zt&&(J.fillStyle=Zt=i),l!=$t&&(J.lineWidth=$t=l),o!=en&&(J.lineJoin=en=o),n!=ln&&(J.lineCap=ln=n),t!=Qt&&J.setLineDash(Qt=t)}function hn(e,l,t,n){l!=Zt&&(J.fillStyle=Zt=l),e!=tn&&(J.font=tn=e),t!=nn&&(J.textAlign=nn=t),n!=on&&(J.textBaseline=on=n)}function dn(e,l,t,n,i=0){if(n.length>0&&e.auto(k,un)&&(null==l||null==l.min)){let l=K(Yt,0),o=K(qt,n.length-1),s=null==t.min?3==e.distr?function(e,l,t){let n=he,i=-he;for(let o=l;t>=o;o++){let l=e[o];null!=l&&l>0&&(n>l&&(n=l),l>i&&(i=l))}return[n,i]}(n,l,o):function(e,l,t,n){let i=he,o=-he;if(1==n)i=e[l],o=e[t];else if(-1==n)i=e[t],o=e[l];else for(let n=l;t>=n;n++){let l=e[n];null!=l&&(i>l&&(i=l),l>o&&(o=l))}return[i,o]}(n,l,o,i):[t.min,t.max];e.min=oe(e.min,t.min=s[0]),e.max=se(e.max,t.max=s[1])}}k.setData=an;const pn={min:null,max:null};function mn(e,l){let t=l?de[e].points:de[e];t._stroke=t.stroke(k,e),t._fill=t.fill(k,e)}function gn(e,l){let t=l?de[e].points:de[e],{stroke:n,fill:i,clip:o,flags:s,_stroke:r=t._stroke,_fill:u=t._fill,_width:a=t.width}=t._paths;a=Se(a*y,3);let f=null,c=a%2/2;l&&null==u&&(u=a>0?"#fff":r);let h=1==t.pxAlign&&c>0;if(h&&J.translate(c,c),!l){let e=Jl-a/2,l=$l-a/2,t=Ql+a,n=ot+a;f=new Path2D,f.rect(e,l,t,n)}l?xn(r,a,t.dash,t.cap,u,n,i,s,o):function(e,l,t,n,i,o,s,r,u,a,f){let c=!1;0!=u&&Me.forEach(((h,d)=>{if(h.series[0]==e){let e,p=de[h.series[1]],m=g[h.series[1]],w=(p._paths||De).band;We(w)&&(w=1==h.dir?w[0]:w[1]);let x=null;p.show&&w&&function(e,l,t){for(l=K(l,0),t=K(t,e.length-1);t>=l;){if(null!=e[l])return!0;l++}return!1}(m,Yt,qt)?(x=h.fill(k,d)||o,e=p._paths.clip):w=null,xn(l,t,n,i,x,s,r,u,a,f,e,w),c=!0}})),c||xn(l,t,n,i,o,s,r,u,a,f)}(e,r,a,t.dash,t.cap,u,n,i,s,f,o),h&&J.translate(-c,-c)}const wn=3;function xn(e,l,t,n,i,o,s,r,u,a,f,c){cn(e,l,t,n,i),(u||a||c)&&(J.save(),u&&J.clip(u),a&&J.clip(a)),c?(r&wn)==wn?(J.clip(c),f&&J.clip(f),bn(i,s),_n(e,o,l)):2&r?(bn(i,s),J.clip(c),_n(e,o,l)):1&r&&(J.save(),J.clip(c),f&&J.clip(f),bn(i,s),J.restore(),_n(e,o,l)):(bn(i,s),_n(e,o,l)),(u||a||c)&&J.restore()}function _n(e,l,t){t>0&&(l instanceof Map?l.forEach(((e,l)=>{J.strokeStyle=Xt=l,J.stroke(e)})):null!=l&&e&&J.stroke(l))}function bn(e,l){l instanceof Map?l.forEach(((e,l)=>{J.fillStyle=Zt=l,J.fill(e)})):null!=l&&e&&J.fill(l)}function vn(e,l,t,n,i,o,s,r,u,a){let f=s%2/2;1==te&&J.translate(f,f),cn(r,s,u,a,r),J.beginPath();let c,h,d,p,m=i+(0==n||3==n?-o:o);0==t?(h=i,p=m):(c=i,d=m);for(let n=0;e.length>n;n++)null!=l[n]&&(0==t?c=d=e[n]:h=p=e[n],J.moveTo(c,h),J.lineTo(d,p));J.stroke(),1==te&&J.translate(-f,-f)}function kn(e){let l=!0;return ge.forEach(((t,n)=>{if(!t.show)return;let i=ve[t.scale];if(null==i.min)return void(t._show&&(l=!1,t._show=!1,Mn(!1)));t._show||(l=!1,t._show=!0,Mn(!1));let o=t.side,s=o%2,{min:r,max:u}=i,[a,f]=function(e,l,t,n){let i,o=ge[e];if(n>0){let s=o._space=o.space(k,e,l,t,n);i=Bt(l,t,o._incrs=o.incrs(k,e,l,t,n,s),n,s)}else i=[0,0];return o._found=i}(n,r,u,0==s?Yl:Cl);if(0==f)return;let c=t._splits=t.splits(k,n,r,u,a,f,2==i.distr),h=2==i.distr?c.map((e=>rn[e])):c,d=2==i.distr?rn[c[1]]-rn[c[0]]:a,p=t._values=t.values(k,t.filter(k,h,n,f,d),n,f,d);t._rotate=2==o?t.rotate(k,p,n,f):0;let m=t._size;t._size=ie(t.size(k,p,n,e)),null!=m&&t._size!=m&&(l=!1)})),l}function yn(e){let l=!0;return Dt.forEach(((t,n)=>{let i=t(k,n,Tt,e);i!=Pt[n]&&(l=!1),Pt[n]=i})),l}function Mn(e){de.forEach(((l,t)=>{t>0&&(l._paths=null,e&&(1==M?(l.min=null,l.max=null):l.facets.forEach((e=>{e.min=null,e.max=null}))))}))}let Sn,En,Tn,zn,Dn,Pn,An,Wn,Yn,Cn,Fn,Hn,Rn=!1;function Gn(){Rn||(Oe(In),Rn=!0)}function In(){if(rt&&(function(){for(let e in ve){let l=ve[e];null==Ve[e]&&(null==l.min||null!=Ve[ze]&&l.auto(k,un))&&(Ve[e]=pn)}for(let e in ve){let l=ve[e];null==Ve[e]&&null!=l.from&&null!=Ve[l.from]&&(Ve[e]=pn)}null!=Ve[ze]&&Mn(!0);let e={};for(let l in Ve){let t=Ve[l];if(null!=t){let n=e[l]=Ge(ve[l],He);if(null!=t.min)Ie(n,t);else if(l!=ze||2==M)if(0==At&&null==n.from){let e=n.range(k,null,null,l);n.min=e[0],n.max=e[1]}else n.min=he,n.max=-he}}if(At>0){de.forEach(((l,t)=>{if(1==M){let n=l.scale,i=Ve[n];if(null==i)return;let o=e[n];if(0==t){let e=o.range(k,o.min,o.max,n);o.min=e[0],o.max=e[1],Yt=L(o.min,g[0]),qt=L(o.max,g[0]),qt-Yt>1&&(o.min>g[0][Yt]&&Yt++,g[0][qt]>o.max&&qt--),l.min=rn[Yt],l.max=rn[qt]}else l.show&&l.auto&&dn(o,i,l,g[t],l.sorted);l.idxs[0]=Yt,l.idxs[1]=qt}else if(t>0&&l.show&&l.auto){let[n,i]=l.facets,o=n.scale,s=i.scale,[r,u]=g[t],a=e[o],f=e[s];null!=a&&dn(a,Ve[o],n,r,n.sorted),null!=f&&dn(f,Ve[s],i,u,i.sorted),l.min=i.min,l.max=i.max}}));for(let l in e){let t=e[l],n=Ve[l];if(null==t.from&&(null==n||null==n.min)){let e=t.range(k,t.min==he?null:t.min,t.max==-he?null:t.max,l);t.min=e[0],t.max=e[1]}}}for(let l in e){let t=e[l];if(null!=t.from){let n=e[t.from];if(null==n.min)t.min=t.max=null;else{let e=t.range(k,n.min,n.max,l);t.min=e[0],t.max=e[1]}}}let l={},t=!1;for(let n in e){let i=e[n],o=ve[n];if(o.min!=i.min||o.max!=i.max){o.min=i.min,o.max=i.max;let e=o.distr;o._min=3==e?ae(o.min):4==e?ce(o.min,o.asinh):o.min,o._max=3==e?ae(o.max):4==e?ce(o.max,o.asinh):o.max,l[n]=t=!0}}if(t){de.forEach(((e,t)=>{2==M?t>0&&l.y&&(e._paths=null):l[e.scale]&&(e._paths=null)}));for(let e in l)ft=!0,Mi("setScale",e);xt.show&&xt.left>=0&&(ct=pt=!0)}for(let e in Ve)Ve[e]=null}(),rt=!1),ft&&(function(){let e=!1,l=0;for(;!e;){l++;let t=kn(l),n=yn(l);e=l==wt||t&&n,e||(gt(k.width,k.height),ut=!0)}}(),ft=!1),ut){if(T(Z,s,Fl),T(Z,i,Hl),T(Z,t,Yl),T(Z,n,Cl),T($,s,Fl),T($,i,Hl),T($,t,Yl),T($,n,Cl),T(X,t,Al),T(X,n,Wl),V.width=ne(Al*y),V.height=ne(Wl*y),ge.forEach((({_el:l,_show:t,_size:n,_pos:i,side:o})=>{if(null!=l)if(t){let t=o%2==1;T(l,t?"left":"top",i-(3===o||0===o?n:0)),T(l,t?"width":"height",n),T(l,t?"top":"left",t?Hl:Fl),T(l,t?"height":"width",t?Cl:Yl),E(l,e)}else S(l,e)})),Xt=Zt=$t=en=ln=tn=nn=on=Qt=null,sn=1,ai(!0),Fl!=jl||Hl!=Ul||Yl!=Bl||Cl!=Vl){Mn(!1);let e=Yl/Bl,l=Cl/Vl;if(xt.show&&!ct&&xt.left>=0){xt.left*=e,xt.top*=l,Tn&&A(Tn,ne(xt.left),0,Yl,Cl),zn&&A(zn,0,ne(xt.top),Yl,Cl);for(let t=1;yt.length>t;t++)Mt[t]*=e,St[t]*=l,A(yt[t],ye(Mt[t],1),ye(St[t],1),Yl,Cl)}if(Bn.show&&!ht&&Bn.left>=0&&Bn.width>0){Bn.left*=e,Bn.width*=e,Bn.top*=l,Bn.height*=l;for(let e in hi)T(Vn,e,Bn[e])}jl=Fl,Ul=Hl,Bl=Yl,Vl=Cl}Mi("setSize"),ut=!1}Al>0&&Wl>0&&(J.clearRect(0,0,V.width,V.height),Mi("drawClear"),Re.forEach((e=>e())),Mi("draw")),Bn.show&&ht&&(Jn(Bn),ht=!1),xt.show&&ct&&(ri(null,!0,!1),ct=!1),el.show&&el.live&&pt&&(oi(),pt=!1),R||(R=!0,k.status=1,Mi("ready")),un=!1,Rn=!1}function Ln(e,l){let t=ve[e];if(null==t.from){if(0==At){let n=t.range(k,l.min,l.max,e);l.min=n[0],l.max=n[1]}if(l.min>l.max){let e=l.min;l.min=l.max,l.max=e}if(At>1&&null!=l.min&&null!=l.max&&1e-16>l.max-l.min)return;e==ze&&2==t.distr&&At>0&&(l.min=L(l.min,g[0]),l.max=L(l.max,g[0]),l.min==l.max&&l.max++),Ve[e]=l,rt=!0,Gn()}}k.batch=function(e){Rn=!0,e(k),In()},k.redraw=(e,l)=>{ft=l||!1,!1!==e?qn(ze,Ne.min,Ne.max):Gn()},k.setScale=Ln;let On=!1;const Nn=xt.drag;let jn=Nn.x,Un=Nn.y;xt.show&&(xt.x&&(Sn=D("u-cursor-x",$)),xt.y&&(En=D("u-cursor-y",$)),0==Ne.ori?(Tn=Sn,zn=En):(Tn=En,zn=Sn),Fn=xt.left,Hn=xt.top);const Bn=k.select=Ie({show:!0,over:!0,left:0,width:0,top:0,height:0},u.select),Vn=Bn.show?D("u-select",Bn.over?$:Z):null;function Jn(e,l){if(Bn.show){for(let l in e)Bn[l]=e[l],l in hi&&T(Vn,l,e[l]);!1!==l&&Mi("setSelect")}}function qn(e,l,t){Ln(e,{min:l,max:t})}function Kn(l,t,n,i){null!=t.focus&&function(e){if(e!=$n){let l=null==e,t=1!=vt.alpha;de.forEach(((n,i)=>{if(1==M||i>0){let o=l||0==i||i==e;n._focus=l?null:o,t&&function(e,l){de[e].alpha=l,xt.show&&yt[e]&&(yt[e].style.opacity=l),ll&&al[e]&&(al[e].style.opacity=l)}(i,o?1:vt.alpha)}})),$n=e,t&&Gn()}}(l),null!=t.show&&de.forEach(((n,i)=>{0>=i||l!=i&&null!=l||(n.show=t.show,function(l){let t=ll?al[l]:null;de[l].show?t&&E(t,e):(t&&S(t,e),yt.length>1&&A(yt[l],-10,-10,Yl,Cl))}(i),2==M?(qn(n.facets[0].scale,null,null),qn(n.facets[1].scale,null,null)):qn(n.scale,null,null),Gn())})),!1!==n&&Mi("setSeries",l,t),i&&Di("setSeries",k,l,t)}let Xn,Zn,$n;k.setSelect=Jn,k.setSeries=Kn,k.addBand=function(e,l){e.fill=me(e.fill||null),e.dir=K(e.dir,-1),Me.splice(l=null==l?Me.length:l,0,e)},k.setBand=function(e,l){Ie(Me[e],l)},k.delBand=function(e){null==e?Me.length=0:Me.splice(e,1)};const Qn={focus:!0};function ei(e,l,t){let n=ve[l];t&&(e=e/y-(1==n.ori?Hl:Fl));let i=Yl;1==n.ori&&(i=Cl,e=i-e),-1==n.dir&&(e=i-e);let o=n._min,s=o+e/i*(n._max-o),r=n.distr;return 3==r?re(10,s):4==r?((e,l=1)=>Q.sinh(e)*l)(s,n.asinh):s}function li(e,l){T(Vn,s,Bn.left=e),T(Vn,t,Bn.width=l)}function ti(e,l){T(Vn,i,Bn.top=e),T(Vn,n,Bn.height=l)}ll&&kt&&zl(p,ol,(e=>{xt._lock||(_t(e),null!=$n&&Kn(null,Qn,!0,Ei.setSeries))})),k.valToIdx=e=>L(e,g[0]),k.posToIdx=function(e,l){return L(ei(e,ze,l),g[0],Yt,qt)},k.posToVal=ei,k.valToPos=(e,l,t)=>0==ve[l].ori?W(e,ve[l],t?Ql:Yl,t?Jl:0):C(e,ve[l],t?ot:Cl,t?$l:0),k.setCursor=(e,l,t)=>{Fn=e.left,Hn=e.top,ri(null,l,t)};let ni=0==Ne.ori?li:ti,ii=1==Ne.ori?li:ti;function oi(e,l){null!=e&&(e.idxs?e.idxs.forEach(((e,l)=>{Qe[l]=e})):(e=>void 0===e)(e.idx)||Qe.fill(e.idx),el.idx=Qe[0]);for(let e=0;de.length>e;e++)(e>0||1==M&&!cl)&&si(e,Qe[e]);ll&&el.live&&function(){if(ll&&el.live)for(let e=2==M?1:0;de.length>e;e++){if(0==e&&cl)continue;let l=el.values[e],t=0;for(let n in l)fl[e][t++].firstChild.nodeValue=l[n]}}(),pt=!1,!1!==l&&Mi("setLegend")}function si(e,l){let t,n=de[e],i=0==e&&2==je?rn:g[e];cl?t=n.values(k,e,l)??hl:(t=n.value(k,null==l?null:i[l],e,l),t=null==t?hl:{_:t}),el.values[e]=t}function ri(e,l,t){let n;Yn=Fn,Cn=Hn,[Fn,Hn]=xt.move(k,Fn,Hn),xt.show&&(Tn&&A(Tn,ne(Fn),0,Yl,Cl),zn&&A(zn,0,ne(Hn),Yl,Cl)),Xn=he;let i=0==Ne.ori?Yl:Cl,o=1==Ne.ori?Yl:Cl;if(0>Fn||0==At||Yt>qt){n=null;for(let e=0;de.length>e;e++)e>0&&yt.length>1&&A(yt[e],-10,-10,Yl,Cl);kt&&Kn(null,Qn,!0,null==e&&Ei.setSeries),el.live&&(Qe.fill(n),pt=!0)}else{let e,l,t;1==M&&(e=0==Ne.ori?Fn:Hn,l=ei(e,ze),n=L(l,g[0],Yt,qt),t=Ue(g[0][n],Ne,i,0));for(let e=2==M?1:0;de.length>e;e++){let s=de[e],r=Qe[e],u=null==r?null:1==M?g[e][r]:g[e][1][r],a=xt.dataIdx(k,e,n,l),f=null==a?null:1==M?g[e][a]:g[e][1][a];pt=pt||f!=u||a!=r,Qe[e]=a;let c=a==n?t:Ue(1==M?g[0][a]:g[e][0][a],Ne,i,0);if(e>0&&s.show){let l,t,n=null==f?-10:Be(f,1==M?ve[s.scale]:ve[s.facets[1].scale],o,0);if(kt&&null!=f){let l=le(vt.dist(k,e,a,n,Hn));if(Xn>l){let t=vt.bias;if(0!=t){let n=ei(1==Ne.ori?Fn:Hn,s.scale),i=0>n?-1:1;i!=(0>f?-1:1)||(1==i?1==t?n>f:f>n:1==t?f>n:n>f)||(Xn=l,Zn=e)}else Xn=l,Zn=e}}if(0==Ne.ori?(l=c,t=n):(l=n,t=c),pt&&yt.length>1){Y(yt[e],xt.points.fill(k,e),xt.points.stroke(k,e));let n,i,o,s,r=!0,u=xt.points.bbox;if(null!=u){r=!1;let l=u(k,e);o=l.left,s=l.top,n=l.width,i=l.height}else o=l,s=t,n=i=xt.points.size(k,e);F(yt[e],n,i,r),Mt[e]=o,St[e]=s,A(yt[e],ye(o,1),ye(s,1),Yl,Cl)}}}}if(xt.idx=n,xt.left=Fn,xt.top=Hn,Bn.show&&On)if(null!=e){let[l,t]=Ei.scales,[n,s]=Ei.match,[r,u]=e.cursor.sync.scales,a=e.cursor.drag;if(jn=a._x,Un=a._y,jn||Un){let a,f,c,h,d,{left:p,top:m,width:g,height:w}=e.select,x=e.scales[l].ori,_=e.posToVal,b=null!=l&&n(l,r),v=null!=t&&s(t,u);b&&jn?(0==x?(a=p,f=g):(a=m,f=w),c=ve[l],h=Ue(_(a,r),c,i,0),d=Ue(_(a+f,r),c,i,0),ni(oe(h,d),le(d-h))):ni(0,i),v&&Un?(1==x?(a=p,f=g):(a=m,f=w),c=ve[t],h=Be(_(a,u),c,o,0),d=Be(_(a+f,u),c,o,0),ii(oe(h,d),le(d-h))):ii(0,o)}else di()}else{let e=le(Yn-Dn),l=le(Cn-Pn);if(1==Ne.ori){let t=e;e=l,l=t}jn=Nn.x&&e>=Nn.dist,Un=Nn.y&&l>=Nn.dist;let t,n,s=Nn.uni;null!=s?jn&&Un&&(jn=e>=s,Un=l>=s,jn||Un||(l>e?Un=!0:jn=!0)):Nn.x&&Nn.y&&(jn||Un)&&(jn=Un=!0),jn&&(0==Ne.ori?(t=An,n=Fn):(t=Wn,n=Hn),ni(oe(t,n),le(n-t)),Un||ii(0,o)),Un&&(1==Ne.ori?(t=An,n=Fn):(t=Wn,n=Hn),ii(oe(t,n),le(n-t)),jn||ni(0,i)),jn||Un||(ni(0,0),ii(0,0))}if(Nn._x=jn,Nn._y=Un,null==e){if(t){if(null!=Ti){let[e,l]=Ei.scales;Ei.values[0]=null!=e?ei(0==Ne.ori?Fn:Hn,e):null,Ei.values[1]=null!=l?ei(1==Ne.ori?Fn:Hn,l):null}Di(f,k,Fn,Hn,Yl,Cl,n)}if(kt){let e=t&&Ei.setSeries,l=vt.prox;null==$n?Xn>l||Kn(Zn,Qn,!0,e):Xn>l?Kn(null,Qn,!0,e):Zn!=$n&&Kn(Zn,Qn,!0,e)}}pt&&(el.idx=n,oi()),!1!==l&&Mi("setCursor")}k.setLegend=oi;let ui=null;function ai(e=!1){e?ui=null:(ui=$.getBoundingClientRect(),Mi("syncRect",ui))}function fi(e,l,t,n,i,o){xt._lock||On&&null!=e&&0==e.movementX&&0==e.movementY||(ci(e,l,t,n,i,o,0,!1,null!=e),null!=e?ri(null,!0,!0):ri(l,!0,!1))}function ci(e,l,t,n,i,o,s,r,u){if(null==ui&&ai(!1),_t(e),null!=e)t=e.clientX-ui.left,n=e.clientY-ui.top;else{if(0>t||0>n)return Fn=-10,void(Hn=-10);let[e,s]=Ei.scales,r=l.cursor.sync,[u,a]=r.values,[f,c]=r.scales,[h,d]=Ei.match,p=l.axes[0].side%2==1,m=0==Ne.ori?Yl:Cl,g=1==Ne.ori?Yl:Cl,w=p?o:i,x=p?i:o,_=p?n:t,b=p?t:n;if(t=null!=f?h(e,f)?H(u,ve[e],m,0):-10:m*(_/w),n=null!=c?d(s,c)?H(a,ve[s],g,0):-10:g*(b/x),1==Ne.ori){let e=t;t=n,n=e}}u&&(t>1&&Yl-1>t||(t=ke(t,Yl)),n>1&&Cl-1>n||(n=ke(n,Cl))),r?(Dn=t,Pn=n,[An,Wn]=xt.move(k,t,n)):(Fn=t,Hn=n)}Object.defineProperty(k,"rect",{get:()=>(null==ui&&ai(!1),ui)});const hi={width:0,height:0,left:0,top:0};function di(){Jn(hi,!1)}let pi,mi,gi,wi;function xi(e,l,t,n,i,o){On=!0,jn=Un=Nn._x=Nn._y=!1,ci(e,l,t,n,i,o,0,!0,!1),null!=e&&(zl(h,b,_i,!1),Di(c,k,An,Wn,Yl,Cl,null));let{left:s,top:r,width:u,height:a}=Bn;pi=s,mi=r,gi=u,wi=a,di()}function _i(e,l,t,n,i,o){On=Nn._x=Nn._y=!1,ci(e,l,t,n,i,o,0,!1,!0);let{left:s,top:r,width:u,height:a}=Bn,f=u>0||a>0,c=pi!=s||mi!=r||gi!=u||wi!=a;if(f&&c&&Jn(Bn),Nn.setScale&&f&&c){let e=s,l=u,t=r,n=a;if(1==Ne.ori&&(e=r,l=a,t=s,n=u),jn&&qn(ze,ei(e,ze),ei(e+l,ze)),Un)for(let e in ve){let l=ve[e];e!=ze&&null==l.from&&l.min!=he&&qn(e,ei(t+n,e),ei(t,e))}di()}else xt.lock&&(xt._lock=!xt._lock,xt._lock||ri(null,!0,!1));null!=e&&(Dl(h,b),Di(h,k,Fn,Hn,Yl,Cl,null))}function bi(e){xt._lock||(_t(e),fn(),di(),null!=e&&Di(m,k,Fn,Hn,Yl,Cl,null))}function vi(){ge.forEach(Jt),mt(k.width,k.height,!0)}G(w,v,vi);const ki={};ki.mousedown=xi,ki.mousemove=fi,ki.mouseup=_i,ki.dblclick=bi,ki.setSeries=(e,l,t,n)=>{-1!=(t=(0,Ei.match[2])(k,l,t))&&Kn(t,n,!0,!1)},xt.show&&(zl(c,$,xi),zl(f,$,fi),zl(d,$,(e=>{_t(e),ai(!1)})),zl(p,$,(function(e){if(xt._lock)return;_t(e);let l=On;if(On){let e,l,t=!0,n=!0,i=10;0==Ne.ori?(e=jn,l=Un):(e=Un,l=jn),e&&l&&(t=i>=Fn||Fn>=Yl-i,n=i>=Hn||Hn>=Cl-i),e&&t&&(Fn=An>Fn?0:Yl),l&&n&&(Hn=Wn>Hn?0:Cl),ri(null,!0,!0),On=!1}Fn=-10,Hn=-10,ri(null,!0,!0),l&&(On=l)})),zl(m,$,bi),Wt.add(k),k.syncRect=ai);const yi=k.hooks=u.hooks||{};function Mi(e,l,t){e in yi&&yi[e].forEach((e=>{e.call(null,k,l,t)}))}(u.plugins||[]).forEach((e=>{for(let l in e.hooks)yi[l]=(yi[l]||[]).concat(e.hooks[l])}));const Si=(e,l,t)=>t,Ei=Ie({key:null,setSeries:!1,filters:{pub:_e,sub:_e},scales:[ze,de[1]?de[1].scale:null],match:[be,be,Si],values:[null,null]},xt.sync);2==Ei.match.length&&Ei.match.push(Si),xt.sync=Ei;const Ti=Ei.key,zi=st(Ti);function Di(e,l,t,n,i,o,s){Ei.filters.pub(e,l,t,n,i,o,s)&&zi.pub(e,l,t,n,i,o,s)}function Pi(){Mi("init",u,g),an(g||u.data,!1),Ve[ze]?Ln(ze,Ve[ze]):fn(),ht=Bn.show&&(Bn.width>0||Bn.height>0),ct=pt=!0,mt(u.width,u.height)}return zi.sub(k),k.pub=function(e,l,t,n,i,o,s){Ei.filters.sub(e,l,t,n,i,o,s)&&ki[e](null,l,t,n,i,o,s)},k.destroy=function(){zi.unsub(k),Wt.delete(k),Tl.clear(),I(w,v,vi),O.remove(),ol?.remove(),Mi("destroy")},de.forEach(Et),ge.forEach((function(e,l){if(e._show=e.show,e.show){let t=ve[e.scale];null==t&&(e.scale=e.side%2?de[1].scale:ze,t=ve[e.scale]);let n=t.time;e.size=me(e.size),e.space=me(e.space),e.rotate=me(e.rotate),We(e.incrs)&&e.incrs.forEach((e=>{!Ee.has(e)&&Ee.set(e,Te(e))})),e.incrs=me(e.incrs||(2==t.distr?tl:n?1==fe?ml:xl:nl)),e.splits=me(e.splits||(n&&1==t.distr?Ke:3==t.distr?Ol:4==t.distr?Nl:Ll)),e.stroke=me(e.stroke),e.grid.stroke=me(e.grid.stroke),e.ticks.stroke=me(e.ticks.stroke),e.border.stroke=me(e.border.stroke);let i=e.values;e.values=We(i)&&!We(i[0])?me(i):n?We(i)?kl(Je,vl(i,qe)):Ce(i)?function(e,l){let t=Xe(l);return(l,n)=>n.map((l=>t(e(l))))}(Je,i):i||Ze:i||Il,e.filter=me(e.filter||(3>t.distr||10!=t.log?3==t.distr&&2==t.log?Kl:we:ql)),e.font=Vt(e.font),e.labelFont=Vt(e.labelFont),e._size=e.size(k,null,l,0),e._space=e._rotate=e._incrs=e._found=e._splits=e._values=null,e._size>0&&(Tt[l]=!0,e._el=D("u-axis",X))}})),_?_ instanceof HTMLElement?(_.appendChild(O),Pi()):_(k,Pi):Pi(),k}qt.assign=Ie,qt.fmtNum=$,qt.rangeNum=q,qt.rangeLog=N,qt.rangeAsinh=j,qt.orient=rt,qt.pxRatio=y,qt.join=function(e,l){if(function(e){let l=e[0][0],t=l.length;for(let n=1;e.length>n;n++){let i=e[n][0];if(i.length!=t)return!1;if(i!=l)for(let e=0;t>e;e++)if(i[e]!=l[e])return!1}return!0}(e)){let l=e[0].slice();for(let t=1;e.length>t;t++)l.push(...e[t].slice(1));return function(e,l=100){const t=e.length;if(1>=t)return!0;let n=0,i=t-1;for(;i>=n&&null==e[n];)n++;for(;i>=n&&null==e[i];)i--;if(n>=i)return!0;const o=se(1,te((i-n+1)/l));for(let l=e[n],t=n+o;i>=t;t+=o){const n=e[t];if(null!=n){if(l>=n)return!1;l=n}}return!0}(l[0])||(l=function(e){let l=e[0],t=l.length,n=Array(t);for(let e=0;n.length>e;e++)n[e]=e;n.sort(((e,t)=>l[e]-l[t]));let i=[];for(let l=0;e.length>l;l++){let o=e[l],s=Array(t);for(let e=0;t>e;e++)s[e]=o[n[e]];i.push(s)}return i}(l)),l}let t=new Set;for(let l=0;e.length>l;l++){let n=e[l][0],i=n.length;for(let e=0;i>e;e++)t.add(n[e])}let n=[Array.from(t).sort(((e,l)=>e-l))],i=n[0].length,o=new Map;for(let e=0;i>e;e++)o.set(n[0][e],e);for(let t=0;e.length>t;t++){let s=e[t],r=s[0];for(let e=1;s.length>e;e++){let u=s[e],a=Array(i).fill(void 0),f=l?l[t][e]:1,c=[];for(let e=0;u.length>e;e++){let l=u[e],t=o.get(r[e]);null===l?0!=f&&(a[t]=l,2==f&&c.push(t)):a[t]=l}Le(a,c,i),n.push(a)}}return n},qt.fmtDate=Xe,qt.tzDate=function(e,l){let t;return"UTC"==l||"Etc/UTC"==l?t=new Date(+e+6e4*e.getTimezoneOffset()):l==Ze?t=e:(t=new Date(e.toLocaleString("en-US",{timeZone:l})),t.setMilliseconds(e.getMilliseconds())),t},qt.sync=st;{qt.addGap=function(e,l,t){let n=e[e.length-1];n&&n[0]==l?n[1]=t:e.push([l,t])},qt.clipGaps=ct;let e=qt.paths={points:St};e.linear=Dt,e.stepped=function(e){const l=K(e.align,1),t=K(e.ascDesc,!1),n=K(e.alignGaps,0),i=K(e.extend,!1);return(e,o,s,r)=>rt(e,o,((u,a,f,c,h,d,p,m,g,w,x)=>{let _=u.pxRound,{left:b,width:v}=e.bbox,k=e=>_(d(e,c,w,m)),M=e=>_(p(e,h,x,g)),S=0==c.ori?wt:xt;const E={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},T=E.stroke,z=c.dir*(0==c.ori?1:-1);s=O(f,s,r,1),r=O(f,s,r,-1);let D=M(f[1==z?s:r]),P=k(a[1==z?s:r]),A=P,W=P;i&&-1==l&&(W=b,S(T,W,D)),S(T,P,D);for(let e=1==z?s:r;e>=s&&r>=e;e+=z){let t=f[e];if(null==t)continue;let n=k(a[e]),i=M(t);1==l?S(T,n,D):S(T,A,i),S(T,n,i),D=i,A=n}let Y=A;i&&1==l&&(Y=b+v,S(T,Y,D));let[C,F]=ut(e,o);if(null!=u.fill||0!=C){let l=E.fill=new Path2D(T),t=M(u.fillTo(e,o,u.min,u.max,C));S(l,Y,t),S(l,W,t)}if(!u.spanGaps){let i=[];i.push(...ht(a,f,s,r,z,k,n));let h=u.width*y/2,d=t||1==l?h:-h,p=t||-1==l?-h:h;i.forEach((e=>{e[0]+=d,e[1]+=p})),E.gaps=i=u.gaps(e,o,s,r,i),E.clip=ct(i,c.ori,m,g,w,x)}return 0!=F&&(E.band=2==F?[ft(e,o,s,r,T,-1),ft(e,o,s,r,T,1)]:ft(e,o,s,r,T,F)),E}))},e.bars=function(e){const l=K((e=e||De).size,[.6,he,1]),t=e.align||0,n=e.gap||0;let i=e.radius;i=null==i?[0,0]:"number"==typeof i?[i,0]:i;const o=me(i),s=1-l[0],r=K(l[1],he),u=K(l[2],1),a=K(e.disp,De),f=K(e.each,(()=>{})),{fill:c,stroke:h}=a;return(e,l,i,d)=>rt(e,l,((p,m,g,w,x,_,b,v,k,M,S)=>{let E,T,z=p.pxRound,D=n*y,P=r*y,A=u*y;0==w.ori?[E,T]=o(e,l):[T,E]=o(e,l);const W=w.dir*(0==w.ori?1:-1);let Y,C,F,H=0==w.ori?_t:bt,R=0==w.ori?f:(e,l,t,n,i,o,s)=>{f(e,l,t,i,n,s,o)},G=K(e.bands,Pe).find((e=>e.series[0]==l)),I=p.fillTo(e,l,p.min,p.max,null!=G?G.dir:0),L=z(b(I,x,S,k)),O=M,N=z(p.width*y),j=!1,U=null,B=null,V=null,J=null;null==c||0!=N&&null==h||(j=!0,U=c.values(e,l,i,d),B=new Map,new Set(U).forEach((e=>{null!=e&&B.set(e,new Path2D)})),N>0&&(V=h.values(e,l,i,d),J=new Map,new Set(V).forEach((e=>{null!=e&&J.set(e,new Path2D)}))));let{x0:q,size:X}=a;if(null!=q&&null!=X){m=q.values(e,l,i,d),2==q.unit&&(m=m.map((l=>e.posToVal(v+l*M,w.key,!0))));let t=X.values(e,l,i,d);C=2==X.unit?t[0]*M:_(t[0],w,M,v)-_(0,w,M,v),O=Pt(m,g,_,w,M,v,O),F=O-C+D}else O=Pt(m,g,_,w,M,v,O),F=O*s+D,C=O-F;1>F&&(F=0),C/2>N||(N=0),5>F&&(z=ge);let Z=F>0;C=z(pe(O-F-(Z?N:0),A,P)),Y=(0==t?C/2:t==W?0:C)-t*W*((0==t?D/2:0)+(Z?N/2:0));const $={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},Q=j?null:new Path2D;let ee=null;if(null!=G)ee=e.data[G.series[1]];else{let{y0:t,y1:n}=a;null!=t&&null!=n&&(g=n.values(e,l,i,d),ee=t.values(e,l,i,d))}let le=E*C,ne=T*C;for(let t=1==W?i:d;t>=i&&d>=t;t+=W){let n=g[t];if(null==n)continue;if(null!=ee){let e=ee[t]??0;if(n-e==0)continue;L=b(e,x,S,k)}let i=_(2!=w.distr||null!=a?m[t]:t,w,M,v),o=b(K(n,I),x,S,k),s=z(i-Y),r=z(se(o,L)),u=z(oe(o,L)),f=r-u;if(null!=n){let i=0>n?ne:le,o=0>n?le:ne;j?(N>0&&null!=V[t]&&H(J.get(V[t]),s,u+te(N/2),C,se(0,f-N),i,o),null!=U[t]&&H(B.get(U[t]),s,u+te(N/2),C,se(0,f-N),i,o)):H(Q,s,u+te(N/2),C,se(0,f-N),i,o),R(e,l,t,s-N/2,u,C+N,f)}}return N>0?$.stroke=j?J:Q:j||($._fill=0==p.width?p._fill:p._stroke??p._fill,$.width=0),$.fill=j?B:Q,$}))},e.spline=function(e){return function(e,l){const t=K(l?.alignGaps,0);return(l,n,i,o)=>rt(l,n,((s,r,u,a,f,c,h,d,p,m,g)=>{let w,x,_,b=s.pxRound,v=e=>b(c(e,a,m,d)),k=e=>b(h(e,f,g,p));0==a.ori?(w=mt,_=wt,x=yt):(w=gt,_=xt,x=Mt);const y=a.dir*(0==a.ori?1:-1);i=O(u,i,o,1),o=O(u,i,o,-1);let M=v(r[1==y?i:o]),S=M,E=[],T=[];for(let e=1==y?i:o;e>=i&&o>=e;e+=y)if(null!=u[e]){let l=v(r[e]);E.push(S=l),T.push(k(u[e]))}const z={stroke:e(E,T,w,_,x,b),fill:null,clip:null,band:null,gaps:null,flags:1},D=z.stroke;let[P,A]=ut(l,n);if(null!=s.fill||0!=P){let e=z.fill=new Path2D(D),t=k(s.fillTo(l,n,s.min,s.max,P));_(e,S,t),_(e,M,t)}if(!s.spanGaps){let e=[];e.push(...ht(r,u,i,o,y,v,t)),z.gaps=e=s.gaps(l,n,i,o,e),z.clip=ct(e,a.ori,d,p,m,g)}return 0!=A&&(z.band=2==A?[ft(l,n,i,o,D,-1),ft(l,n,i,o,D,1)]:ft(l,n,i,o,D,A)),z}))}(At,e)}}return qt}(); +var uPlot=function(){"use strict";const e="u-off",l="u-label",t="width",n="height",i="top",o="bottom",s="left",r="right",u="#000",a=u+"0",f="mousemove",c="mousedown",h="mouseup",d="mouseenter",p="mouseleave",m="dblclick",g="change",w="dppxchange",x="--",_="undefined"!=typeof window,b=_?document:null,v=_?window:null,k=_?navigator:null;let y,M;function S(e,l){if(null!=l){let t=e.classList;!t.contains(l)&&t.add(l)}}function E(e,l){let t=e.classList;t.contains(l)&&t.remove(l)}function T(e,l,t){e.style[l]=t+"px"}function z(e,l,t,n){let i=b.createElement(e);return null!=l&&S(i,l),null!=t&&t.insertBefore(i,n),i}function D(e,l){return z("div",e,l)}const P=new WeakMap;function A(l,t,n,i,o){let s="translate("+t+"px,"+n+"px)";s!=P.get(l)&&(l.style.transform=s,P.set(l,s),0>t||0>n||t>i||n>o?S(l,e):E(l,e))}const W=new WeakMap;function Y(e,l,t){let n=l+t;n!=W.get(e)&&(W.set(e,n),e.style.background=l,e.style.borderColor=t)}const C=new WeakMap;function F(e,l,t,n){let i=l+""+t;i!=C.get(e)&&(C.set(e,i),e.style.height=t+"px",e.style.width=l+"px",e.style.marginLeft=n?-l/2+"px":0,e.style.marginTop=n?-t/2+"px":0)}const H={passive:!0},R={...H,capture:!0};function G(e,l,t,n){l.addEventListener(e,t,n?R:H)}function I(e,l,t,n){l.removeEventListener(e,t,n?R:H)}function L(e,l,t,n){let i;t=t||0;let o=2147483647>=(n=n||l.length-1);for(;n-t>1;)i=o?t+n>>1:te((t+n)/2),e>l[i]?t=i:n=i;return e-l[t]>l[n]-e?n:t}function O(e,l,t,n){for(let i=1==n?l:t;i>=l&&t>=i;i+=n)if(null!=e[i])return i;return-1}function N(e,l,t,n){let i=ue(e),o=ue(l);e==l&&(-1==i?(e*=t,l/=t):(e/=t,l*=t));let s=10==t?ae:fe,r=1==o?ie:te,u=(1==i?te:ie)(s(le(e))),a=r(s(le(l))),f=re(t,u),c=re(t,a);return 10==t&&(0>u&&(f=Se(f,-u)),0>a&&(c=Se(c,-a))),n||2==t?(e=f*i,l=c*o):(e=Me(e,f),l=ye(l,c)),[e,l]}function j(e,l,t,n){let i=N(e,l,t,n);return 0==e&&(i[0]=0),0==l&&(i[1]=0),i}_&&function e(){let l=devicePixelRatio;y!=l&&(y=l,M&&I(g,M,e),M=matchMedia(`(min-resolution: ${y-.001}dppx) and (max-resolution: ${y+.001}dppx)`),G(g,M,e),v.dispatchEvent(new CustomEvent(w)))}();const U=.1,B={mode:3,pad:U},V={pad:0,soft:null,mode:0},J={min:V,max:V};function q(e,l,t,n){return Fe(t)?X(e,l,t):(V.pad=t,V.soft=n?0:null,V.mode=n?3:0,X(e,l,J))}function K(e,l){return null==e?l:e}function X(e,l,t){let n=t.min,i=t.max,o=K(n.pad,0),s=K(i.pad,0),r=K(n.hard,-he),u=K(i.hard,he),a=K(n.soft,he),f=K(i.soft,-he),c=K(n.mode,0),h=K(i.mode,0),d=l-e,p=ae(d),m=se(le(e),le(l)),g=ae(m),w=le(g-p);(1e-9>d||w>10)&&(d=0,0!=e&&0!=l||(d=1e-9,2==c&&a!=he&&(o=0),2==h&&f!=-he&&(s=0)));let x=d||m||1e3,_=ae(x),b=re(10,te(_)),v=Se(Me(e-x*(0==d?0==e?.1:1:o),b/10),9),k=a>e||1!=c&&(3!=c||v>a)&&(2!=c||a>v)?he:a,y=se(r,k>v&&e>=k?k:oe(k,v)),M=Se(ye(l+x*(0==d?0==l?.1:1:s),b/10),9),S=l>f||1!=h&&(3!=h||f>M)&&(2!=h||M>f)?-he:f,E=oe(u,M>S&&S>=l?S:se(S,M));return y==E&&0==y&&(E=100),[y,E]}const Z=new Intl.NumberFormat(_?k.language:"en-US"),$=e=>Z.format(e),Q=Math,ee=Q.PI,le=Q.abs,te=Q.floor,ne=Q.round,ie=Q.ceil,oe=Q.min,se=Q.max,re=Q.pow,ue=Q.sign,ae=Q.log10,fe=Q.log2,ce=(e,l=1)=>Q.asinh(e/l),he=1/0;function de(e){return 1+(0|ae((e^e>>31)-(e>>31)))}function pe(e,l,t){return oe(se(e,l),t)}function me(e){return"function"==typeof e?e:()=>e}const ge=e=>e,we=(e,l)=>l,xe=()=>null,_e=()=>!0,be=(e,l)=>e==l,ve=e=>Se(e,14);function ke(e,l){return ve(Se(ve(e/l))*l)}function ye(e,l){return ve(ie(ve(e/l))*l)}function Me(e,l){return ve(te(ve(e/l))*l)}function Se(e,l=0){if(Ye(e))return e;let t=10**l;return ne(e*t*(1+Number.EPSILON))/t}const Ee=new Map;function Te(e){return((""+e).split(".")[1]||"").length}function ze(e,l,t,n){let i=[],o=n.map(Te);for(let s=l;t>s;s++){let l=le(s),t=Se(re(e,s),l);for(let e=0;n.length>e;e++){let r=n[e]*t,u=(0>r||0>s?l:0)+(o[e]>s?o[e]:0),a=Se(r,u);i.push(a),Ee.set(a,u)}}return i}const De={},Pe=[],Ae=[null,null],We=Array.isArray,Ye=Number.isInteger;function Ce(e){return"string"==typeof e}function Fe(e){let l=!1;if(null!=e){let t=e.constructor;l=null==t||t==Object}return l}function He(e){return null!=e&&"object"==typeof e}const Re=Object.getPrototypeOf(Uint8Array);function Ge(e,l=Fe){let t;if(We(e)){let n=e.find((e=>null!=e));if(We(n)||l(n)){t=Array(e.length);for(let n=0;e.length>n;n++)t[n]=Ge(e[n],l)}else t=e.slice()}else if(e instanceof Re)t=e.slice();else if(l(e)){t={};for(let n in e)t[n]=Ge(e[n],l)}else t=e;return t}function Ie(e){let l=arguments;for(let t=1;l.length>t;t++){let n=l[t];for(let l in n)Fe(e[l])?Ie(e[l],Ge(n[l])):e[l]=Ge(n[l])}return e}function Le(e,l,t){for(let n,i=0,o=-1;l.length>i;i++){let s=l[i];if(s>o){for(n=s-1;n>=0&&null==e[n];)e[n--]=null;for(n=s+1;t>n&&null==e[n];)e[o=n++]=null}}}const Oe="undefined"==typeof queueMicrotask?e=>Promise.resolve().then(e):queueMicrotask,Ne=["January","February","March","April","May","June","July","August","September","October","November","December"],je=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Ue(e){return e.slice(0,3)}const Be=je.map(Ue),Ve=Ne.map(Ue),Je={MMMM:Ne,MMM:Ve,WWWW:je,WWW:Be};function qe(e){return(10>e?"0":"")+e}const Ke={YYYY:e=>e.getFullYear(),YY:e=>(e.getFullYear()+"").slice(2),MMMM:(e,l)=>l.MMMM[e.getMonth()],MMM:(e,l)=>l.MMM[e.getMonth()],MM:e=>qe(e.getMonth()+1),M:e=>e.getMonth()+1,DD:e=>qe(e.getDate()),D:e=>e.getDate(),WWWW:(e,l)=>l.WWWW[e.getDay()],WWW:(e,l)=>l.WWW[e.getDay()],HH:e=>qe(e.getHours()),H:e=>e.getHours(),h:e=>{let l=e.getHours();return 0==l?12:l>12?l-12:l},AA:e=>12>e.getHours()?"AM":"PM",aa:e=>12>e.getHours()?"am":"pm",a:e=>12>e.getHours()?"a":"p",mm:e=>qe(e.getMinutes()),m:e=>e.getMinutes(),ss:e=>qe(e.getSeconds()),s:e=>e.getSeconds(),fff:e=>function(e){return(10>e?"00":100>e?"0":"")+e}(e.getMilliseconds())};function Xe(e,l){l=l||Je;let t,n=[],i=/\{([a-z]+)\}|[^{]+/gi;for(;t=i.exec(e);)n.push("{"==t[0][0]?Ke[t[1]]:t[0]);return e=>{let t="";for(let i=0;n.length>i;i++)t+="string"==typeof n[i]?n[i]:n[i](e,l);return t}}const Ze=(new Intl.DateTimeFormat).resolvedOptions().timeZone,$e=e=>e%1==0,Qe=[1,2,2.5,5],el=ze(10,-16,0,Qe),ll=ze(10,0,16,Qe),tl=ll.filter($e),nl=el.concat(ll),il="{YYYY}",ol="\n"+il,sl="{M}/{D}",rl="\n"+sl,ul=rl+"/{YY}",al="{aa}",fl="{h}:{mm}"+al,cl="\n"+fl,hl=":{ss}",dl=null;function pl(e){let l=1e3*e,t=60*l,n=60*t,i=24*n,o=30*i,s=365*i;return[(1==e?ze(10,0,3,Qe).filter($e):ze(10,-3,0,Qe)).concat([l,5*l,10*l,15*l,30*l,t,5*t,10*t,15*t,30*t,n,2*n,3*n,4*n,6*n,8*n,12*n,i,2*i,3*i,4*i,5*i,6*i,7*i,8*i,9*i,10*i,15*i,o,2*o,3*o,4*o,6*o,s,2*s,5*s,10*s,25*s,50*s,100*s]),[[s,il,dl,dl,dl,dl,dl,dl,1],[28*i,"{MMM}",ol,dl,dl,dl,dl,dl,1],[i,sl,ol,dl,dl,dl,dl,dl,1],[n,"{h}"+al,ul,dl,rl,dl,dl,dl,1],[t,fl,ul,dl,rl,dl,dl,dl,1],[l,hl,ul+" "+fl,dl,rl+" "+fl,dl,cl,dl,1],[e,hl+".{fff}",ul+" "+fl,dl,rl+" "+fl,dl,cl,dl,1]],function(l){return(r,u,a,f,c,h)=>{let d=[],p=c>=s,m=c>=o&&s>c,g=l(a),w=Se(g*e,3),x=yl(g.getFullYear(),p?0:g.getMonth(),m||p?1:g.getDate()),_=Se(x*e,3);if(m||p){let t=m?c/o:0,n=p?c/s:0,i=w==_?w:Se(yl(x.getFullYear()+n,x.getMonth()+t,1)*e,3),r=new Date(ne(i/e)),u=r.getFullYear(),a=r.getMonth();for(let o=0;f>=i;o++){let s=yl(u+n*o,a+t*o,1),r=s-l(Se(s*e,3));i=Se((+s+r)*e,3),i>f||d.push(i)}}else{let o=i>c?c:i,s=_+(te(a)-te(w))+ye(w-_,o);d.push(s);let p=l(s),m=p.getHours()+p.getMinutes()/t+p.getSeconds()/n,g=c/n,x=h/r.axes[u]._space;for(;s=Se(s+c,1==e?0:3),f>=s;)if(g>1){let e=te(Se(m+g,6))%24,t=l(s).getHours()-e;t>1&&(t=-1),s-=t*n,m=(m+g)%24,.7>Se((s-d[d.length-1])/c,3)*x||d.push(s)}else d.push(s)}return d}}]}const[ml,gl,wl]=pl(1),[xl,_l,bl]=pl(.001);function vl(e,l){return e.map((e=>e.map(((t,n)=>0==n||8==n||null==t?t:l(1==n||0==e[8]?t:e[1]+t)))))}function kl(e,l){return(t,n,i,o,s)=>{let r,u,a,f,c,h,d=l.find((e=>s>=e[0]))||l[l.length-1];return n.map((l=>{let t=e(l),n=t.getFullYear(),i=t.getMonth(),o=t.getDate(),s=t.getHours(),p=t.getMinutes(),m=t.getSeconds(),g=n!=r&&d[2]||i!=u&&d[3]||o!=a&&d[4]||s!=f&&d[5]||p!=c&&d[6]||m!=h&&d[7]||d[1];return r=n,u=i,a=o,f=s,c=p,h=m,g(t)}))}}function yl(e,l,t){return new Date(e,l,t)}function Ml(e,l){return l(e)}function Sl(e,l){return(t,n,i,o)=>null==o?x:l(e(n))}ze(2,-53,53,[1]);const El={show:!0,live:!0,isolate:!1,mount:()=>{},markers:{show:!0,width:2,stroke:function(e,l){let t=e.series[l];return t.width?t.stroke(e,l):t.points.width?t.points.stroke(e,l):null},fill:function(e,l){return e.series[l].fill(e,l)},dash:"solid"},idx:null,idxs:null,values:[]},Tl=[0,0];function zl(e,l,t,n=!0){return e=>{0==e.button&&(!n||e.target==l)&&t(e)}}function Dl(e,l,t,n=!0){return e=>{(!n||e.target==l)&&t(e)}}const Pl={show:!0,x:!0,y:!0,lock:!1,move:function(e,l,t){return Tl[0]=l,Tl[1]=t,Tl},points:{show:function(e,l){let i=e.cursor.points,o=D(),s=i.size(e,l);T(o,t,s),T(o,n,s);let r=s/-2;T(o,"marginLeft",r),T(o,"marginTop",r);let u=i.width(e,l,s);return u&&T(o,"borderWidth",u),o},size:function(e,l){return e.series[l].points.size},width:0,stroke:function(e,l){let t=e.series[l].points;return t._stroke||t._fill},fill:function(e,l){let t=e.series[l].points;return t._fill||t._stroke}},bind:{mousedown:zl,mouseup:zl,click:zl,dblclick:zl,mousemove:Dl,mouseleave:Dl,mouseenter:Dl},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(e,l)=>{l.stopPropagation(),l.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(e,l,t,n,i)=>n-i,prox:-1,bias:0},left:-10,top:-10,idx:null,dataIdx:function(e,l,t){return t},idxs:null,event:null},Al={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},Wl=Ie({},Al,{filter:we}),Yl=Ie({},Wl,{size:10}),Cl=Ie({},Al,{show:!1}),Fl='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',Hl="bold "+Fl,Rl={show:!0,scale:"x",stroke:u,space:50,gap:5,size:50,labelGap:0,labelSize:30,labelFont:Hl,side:2,grid:Wl,ticks:Yl,border:Cl,font:Fl,lineGap:1.5,rotate:0},Gl={show:!0,scale:"x",auto:!1,sorted:1,min:he,max:-he,idxs:[]};function Il(e,l){return l.map((e=>null==e?"":$(e)))}function Ll(e,l,t,n,i,o,s){let r=[],u=Ee.get(i)||0;for(let e=t=s?t:Se(ye(t,i),u);n>=e;e=Se(e+i,u))r.push(Object.is(e,-0)?0:e);return r}function Ol(e,l,t,n,i){const o=[],s=e.scales[e.axes[l].scale].log,r=te((10==s?ae:fe)(t));i=re(s,r),10==s&&0>r&&(i=Se(i,-r));let u=t;do{o.push(u),u+=i,10==s&&(u=Se(u,Ee.get(i))),i*s>u||(i=u)}while(n>=u);return o}function Nl(e,l,t,n,i){let o=e.scales[e.axes[l].scale].asinh,s=n>o?Ol(e,l,se(o,t),n,i):[o],r=0>n||t>0?[]:[0];return(-o>t?Ol(e,l,se(o,-n),-t,i):[o]).reverse().map((e=>-e)).concat(r,s)}const jl=/./,Ul=/[12357]/,Bl=/[125]/,Vl=/1/,Jl=(e,l,t,n)=>e.map(((e,i)=>4==l&&0==e||i%n==0&&t.test(e.toExponential()[0>e?1:0])?e:null));function ql(e,l,t){let n=e.axes[t],i=n.scale,o=e.scales[i],s=e.valToPos,r=n._space,u=s(10,i),a=s(9,i)-ue)return Jl(l.slice().reverse(),o.distr,a,ie(r/e)).reverse()}return Jl(l,o.distr,a,1)}function Kl(e,l,t){let n=e.axes[t],i=n.scale,o=n._space,s=e.valToPos,r=le(s(1,i)-s(2,i));return o>r?Jl(l.slice().reverse(),3,jl,ie(o/r)).reverse():l}function Xl(e,l,t,n){return null==n?x:null==l?"":$(l)}const Zl={show:!0,scale:"y",stroke:u,space:30,gap:5,size:50,labelGap:0,labelSize:30,labelFont:Hl,side:3,grid:Wl,ticks:Yl,border:Cl,font:Fl,lineGap:1.5,rotate:0},$l={scale:null,auto:!0,sorted:0,min:he,max:-he},Ql=(e,l,t,n,i)=>i,et={show:!0,auto:!0,sorted:0,gaps:Ql,alpha:1,facets:[Ie({},$l,{scale:"x"}),Ie({},$l,{scale:"y"})]},lt={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:Ql,alpha:1,points:{show:function(e,l){let{scale:t,idxs:n}=e.series[0],i=e._data[0],o=e.valToPos(i[n[0]],t,!0),s=e.valToPos(i[n[1]],t,!0);return le(s-o)/(e.series[l].points.space*y)>=n[1]-n[0]},filter:null},values:null,min:he,max:-he,idxs:[],path:null,clip:null};function tt(e,l,t){return t/10}const nt={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},it=Ie({},nt,{time:!1,ori:1}),ot={};function st(e){let l=ot[e];return l||(l={key:e,plots:[],sub(e){l.plots.push(e)},unsub(e){l.plots=l.plots.filter((l=>l!=e))},pub(e,t,n,i,o,s,r){for(let u=0;l.plots.length>u;u++)l.plots[u]!=t&&l.plots[u].pub(e,t,n,i,o,s,r)}},null!=e&&(ot[e]=l)),l}function rt(e,l,t){const n=e.mode,i=e.series[l],o=2==n?e._data[l]:e._data,s=e.scales,r=e.bbox;let u=o[0],a=2==n?o[1]:o[l],f=2==n?s[i.facets[0].scale]:s[e.series[0].scale],c=2==n?s[i.facets[1].scale]:s[i.scale],h=r.left,d=r.top,p=r.width,m=r.height,g=e.valToPosH,w=e.valToPosV;return 0==f.ori?t(i,u,a,f,c,g,w,h,d,p,m,mt,wt,_t,vt,yt):t(i,u,a,f,c,w,g,d,h,m,p,gt,xt,bt,kt,Mt)}function ut(e,l){let t=0,n=0,i=K(e.bands,Pe);for(let e=0;i.length>e;e++){let o=i[e];o.series[0]==l?t=o.dir:o.series[1]==l&&(n|=1==o.dir?1:2)}return[t,1==n?-1:2==n?1:3==n?2:0]}function at(e,l,t,n,i){let o=e.series[l],s=e.scales[2==e.mode?o.facets[1].scale:o.scale];return-1==i?s.min:1==i?s.max:3==s.distr?1==s.dir?s.min:s.max:0}function ft(e,l,t,n,i,o){return rt(e,l,((e,l,s,r,u,a,f,c,h,d,p)=>{let m=e.pxRound;const g=0==r.ori?wt:xt;let w,x;1==r.dir*(0==r.ori?1:-1)?(w=t,x=n):(w=n,x=t);let _=m(a(l[w],r,d,c)),b=m(f(s[w],u,p,h)),v=m(a(l[x],r,d,c)),k=m(f(1==o?u.max:u.min,u,p,h)),y=new Path2D(i);return g(y,v,k),g(y,_,k),g(y,_,b),y}))}function ct(e,l,t,n,i,o){let s=null;if(e.length>0){s=new Path2D;const r=0==l?_t:bt;let u=t;for(let l=0;e.length>l;l++){let t=e[l];if(t[1]>t[0]){let e=t[0]-u;e>0&&r(s,u,n,e,n+o),u=t[1]}}let a=t+i-u,f=10;a>0&&r(s,u,n-f/2,a,n+o+f)}return s}function ht(e,l,t,n,i,o,s){let r=[],u=e.length;for(let a=1==i?t:n;a>=t&&n>=a;a+=i)if(null===l[a]){let f=a,c=a;if(1==i)for(;++a<=n&&null===l[a];)c=a;else for(;--a>=t&&null===l[a];)c=a;let h=o(e[f]),d=c==f?h:o(e[c]),p=f-i;h=s>0||0>p||p>=u?h:o(e[p]);let m=c+i;d=0>s||0>m||m>=u?d:o(e[m]),h>d||r.push([h,d])}return r}function dt(e){return 0==e?ge:1==e?ne:l=>ke(l,e)}function pt(e){let l=0==e?mt:gt,t=0==e?(e,l,t,n,i,o)=>{e.arcTo(l,t,n,i,o)}:(e,l,t,n,i,o)=>{e.arcTo(t,l,i,n,o)},n=0==e?(e,l,t,n,i)=>{e.rect(l,t,n,i)}:(e,l,t,n,i)=>{e.rect(t,l,i,n)};return(e,i,o,s,r,u=0,a=0)=>{0==u&&0==a?n(e,i,o,s,r):(u=oe(u,s/2,r/2),a=oe(a,s/2,r/2),l(e,i+u,o),t(e,i+s,o,i+s,o+r,u),t(e,i+s,o+r,i,o+r,a),t(e,i,o+r,i,o,a),t(e,i,o,i+s,o,u),e.closePath())}}const mt=(e,l,t)=>{e.moveTo(l,t)},gt=(e,l,t)=>{e.moveTo(t,l)},wt=(e,l,t)=>{e.lineTo(l,t)},xt=(e,l,t)=>{e.lineTo(t,l)},_t=pt(0),bt=pt(1),vt=(e,l,t,n,i,o)=>{e.arc(l,t,n,i,o)},kt=(e,l,t,n,i,o)=>{e.arc(t,l,n,i,o)},yt=(e,l,t,n,i,o,s)=>{e.bezierCurveTo(l,t,n,i,o,s)},Mt=(e,l,t,n,i,o,s)=>{e.bezierCurveTo(t,l,i,n,s,o)};function St(){return(e,l,t,n,i)=>rt(e,l,((l,o,s,r,u,a,f,c,h,d,p)=>{let m,g,{pxRound:w,points:x}=l;0==r.ori?(m=mt,g=vt):(m=gt,g=kt);const _=Se(x.width*y,3);let b=(x.size-x.width)/2*y,v=Se(2*b,3),k=new Path2D,M=new Path2D,{left:S,top:E,width:T,height:z}=e.bbox;_t(M,S-v,E-v,T+2*v,z+2*v);const D=e=>{if(null!=s[e]){let l=w(a(o[e],r,d,c)),t=w(f(s[e],u,p,h));m(k,l+b,t),g(k,l,t,b,0,2*ee)}};if(i)i.forEach(D);else for(let e=t;n>=e;e++)D(e);return{stroke:_>0?k:null,fill:k,clip:M,flags:3}}))}function Et(e){return(l,t,n,i,o,s)=>{n!=i&&(o!=n&&s!=n&&e(l,t,n),o!=i&&s!=i&&e(l,t,i),e(l,t,s))}}const Tt=Et(wt),zt=Et(xt);function Dt(e){const l=K(e?.alignGaps,0);return(e,t,n,i)=>rt(e,t,((o,s,r,u,a,f,c,h,d,p,m)=>{let g,w,x=o.pxRound,_=e=>x(f(e,u,p,h)),b=e=>x(c(e,a,m,d));0==u.ori?(g=wt,w=Tt):(g=xt,w=zt);const v=u.dir*(0==u.ori?1:-1),k={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},y=k.stroke;let M,S,E,T=he,z=-he,D=_(s[1==v?n:i]),P=O(r,n,i,1*v),A=O(r,n,i,-1*v),W=_(s[P]),Y=_(s[A]),C=!1;for(let e=1==v?n:i;e>=n&&i>=e;e+=v){let l=_(s[e]),t=r[e];l==D?null!=t?(S=b(t),T==he&&(g(y,l,S),M=S),T=oe(S,T),z=se(S,z)):null===t&&(C=!0):(T!=he&&(w(y,D,T,z,M,S),E=D),null!=t?(S=b(t),g(y,l,S),T=z=M=S):(T=he,z=-he,null===t&&(C=!0)),D=l)}T!=he&&T!=z&&E!=D&&w(y,D,T,z,M,S);let[F,H]=ut(e,t);if(null!=o.fill||0!=F){let l=k.fill=new Path2D(y),n=b(o.fillTo(e,t,o.min,o.max,F));g(l,Y,n),g(l,W,n)}if(!o.spanGaps){let a=[];C&&a.push(...ht(s,r,n,i,v,_,l)),k.gaps=a=o.gaps(e,t,n,i,a),k.clip=ct(a,u.ori,h,d,p,m)}return 0!=H&&(k.band=2==H?[ft(e,t,n,i,y,-1),ft(e,t,n,i,y,1)]:ft(e,t,n,i,y,H)),k}))}function Pt(e,l,t,n,i,o,s=he){if(e.length>1){let r=null;for(let u=0,a=1/0;e.length>u;u++)if(void 0!==l[u]){if(null!=r){let l=le(e[u]-e[r]);a>l&&(a=l,s=le(t(e[u],n,i,o)-t(e[r],n,i,o)))}r=u}}return s}function At(e,l,t,n,i){const o=e.length;if(2>o)return null;const s=new Path2D;if(t(s,e[0],l[0]),2==o)n(s,e[1],l[1]);else{let t=Array(o),n=Array(o-1),r=Array(o-1),u=Array(o-1);for(let t=0;o-1>t;t++)r[t]=l[t+1]-l[t],u[t]=e[t+1]-e[t],n[t]=r[t]/u[t];t[0]=n[0];for(let e=1;o-1>e;e++)0===n[e]||0===n[e-1]||n[e-1]>0!=n[e]>0?t[e]=0:(t[e]=3*(u[e-1]+u[e])/((2*u[e]+u[e-1])/n[e-1]+(u[e]+2*u[e-1])/n[e]),isFinite(t[e])||(t[e]=0));t[o-1]=n[o-2];for(let n=0;o-1>n;n++)i(s,e[n]+u[n]/3,l[n]+t[n]*u[n]/3,e[n+1]-u[n]/3,l[n+1]-t[n+1]*u[n]/3,e[n+1],l[n+1])}return s}const Wt=new Set;function Yt(){for(let e of Wt)e.syncRect(!0)}_&&(G("resize",v,Yt),G("scroll",v,Yt,!0),G(w,v,(()=>{qt.pxRatio=y})));const Ct=Dt(),Ft=St();function Ht(e,l,t,n){return(n?[e[0],e[1]].concat(e.slice(2)):[e[0]].concat(e.slice(1))).map(((e,n)=>Rt(e,n,l,t)))}function Rt(e,l,t,n){return Ie({},0==l?t:n,e)}function Gt(e,l,t){return null==l?Ae:[l,t]}const It=Gt;function Lt(e,l,t){return null==l?Ae:q(l,t,U,!0)}function Ot(e,l,t,n){return null==l?Ae:N(l,t,e.scales[n].log,!1)}const Nt=Ot;function jt(e,l,t,n){return null==l?Ae:j(l,t,e.scales[n].log,!1)}const Ut=jt;function Bt(e,l,t,n,i){let o=se(de(e),de(l)),s=l-e,r=L(i/n*s,t);do{let e=t[r],l=n*e/s;if(l>=i&&17>=o+(5>e?Ee.get(e):0))return[e,l]}while(++r(l=ne((t=+n)*y))+"px")),l,t]}function Jt(e){e.show&&[e.font,e.labelFont].forEach((e=>{let l=Se(e[2]*y,1);e[0]=e[0].replace(/[0-9.]+px/,l+"px"),e[1]=l}))}function qt(u,g,_){const k={mode:K(u.mode,1)},M=k.mode;function P(e,l){return((3==l.distr?ae(e>0?e:l.clamp(k,e,l.min,l.max,l.key)):4==l.distr?ce(e,l.asinh):e)-l._min)/(l._max-l._min)}function W(e,l,t,n){let i=P(e,l);return n+t*(-1==l.dir?1-i:i)}function C(e,l,t,n){let i=P(e,l);return n+t*(-1==l.dir?i:1-i)}function H(e,l,t,n){return 0==l.ori?W(e,l,t,n):C(e,l,t,n)}k.valToPosH=W,k.valToPosV=C;let R=!1;k.status=0;const O=k.root=D("uplot");null!=u.id&&(O.id=u.id),S(O,u.class),u.title&&(D("u-title",O).textContent=u.title);const V=z("canvas"),J=k.ctx=V.getContext("2d"),X=D("u-wrap",O);G("click",X,(e=>{e.target===$&&(Fn!=An||Hn!=Wn)&&Bn.click(k,e)}),!0);const Z=k.under=D("u-under",X);X.appendChild(V);const $=k.over=D("u-over",X),te=+K((u=Ge(u)).pxAlign,1),ue=dt(te);(u.plugins||[]).forEach((e=>{e.opts&&(u=e.opts(k,u)||u)}));const fe=u.ms||.001,de=k.series=1==M?Ht(u.series||[],Gl,lt,!1):function(e,l){return e.map(((e,t)=>0==t?null:Ie({},l,e)))}(u.series||[null],et),ge=k.axes=Ht(u.axes||[],Rl,Zl,!0),ve=k.scales={},Me=k.bands=u.bands||[];Me.forEach((e=>{e.fill=me(e.fill||null),e.dir=K(e.dir,-1)}));const ze=2==M?de[1].facets[0].scale:de[0].scale,Ye={axes:function(){for(let e=0;ge.length>e;e++){let l=ge[e];if(!l.show||!l._show)continue;let t,n,u=l.side,a=u%2,f=l.stroke(k,e),c=0==u||3==u?-1:1;if(l.label){let e=ne((l._lpos+l.labelGap*c)*y);hn(l.labelFont[0],f,"center",2==u?i:o),J.save(),1==a?(t=n=0,J.translate(e,ne($l+ot/2)),J.rotate((3==u?-ee:ee)/2)):(t=ne(Jl+Ql/2),n=e),J.fillText(l.label,t,n),J.restore()}let[h,d]=l._found;if(0==d)continue;let p=ve[l.scale],m=0==a?Ql:ot,g=0==a?Jl:$l,w=ne(l.gap*y),x=l._splits,_=2==p.distr?x.map((e=>rn[e])):x,b=2==p.distr?rn[x[1]]-rn[x[0]]:h,v=l.ticks,M=l.border,S=v.show?ne(v.size*y):0,E=l._rotate*-ee/180,T=ue(l._pos*y),z=T+(S+w)*c;n=0==a?z:0,t=1==a?z:0,hn(l.font[0],f,1==l.align?s:2==l.align?r:E>0?s:0>E?r:0==a?"center":3==u?r:s,E||1==a?"middle":2==u?i:o);let D=l.font[1]*l.lineGap,P=x.map((e=>ue(H(e,p,m,g)))),A=l._values;for(let e=0;A.length>e;e++){let l=A[e];if(null!=l){0==a?t=P[e]:n=P[e],l=""+l;let i=-1==l.indexOf("\n")?[l]:l.split(/\n/gm);for(let e=0;i.length>e;e++){let l=i[e];E?(J.save(),J.translate(t,n+e*D),J.rotate(E),J.fillText(l,0,0),J.restore()):J.fillText(l,t,n+e*D)}}}v.show&&vn(P,v.filter(k,_,e,d,b),a,u,T,S,Se(v.width*y,3),v.stroke(k,e),v.dash,v.cap);let W=l.grid;W.show&&vn(P,W.filter(k,_,e,d,b),a,0==a?2:1,0==a?$l:Jl,0==a?ot:Ql,Se(W.width*y,3),W.stroke(k,e),W.dash,W.cap),M.show&&vn([T],[1],0==a?1:0,0==a?1:2,1==a?$l:Jl,1==a?ot:Ql,Se(M.width*y,3),M.stroke(k,e),M.dash,M.cap)}Ti("drawAxes")},series:function(){At>0&&(de.forEach(((e,l)=>{if(l>0&&e.show&&(mn(l,!1),mn(l,!0),null==e._paths)){sn!=e.alpha&&(J.globalAlpha=sn=e.alpha);let t=2==M?[0,g[l][0].length-1]:function(e){let l=pe(Yt-1,0,At-1),t=pe(qt+1,0,At-1);for(;null==e[l]&&l>0;)l--;for(;null==e[t]&&At-1>t;)t++;return[l,t]}(g[l]);e._paths=e.paths(k,l,t[0],t[1]),1!=sn&&(J.globalAlpha=sn=1)}})),de.forEach(((e,l)=>{if(l>0&&e.show){sn!=e.alpha&&(J.globalAlpha=sn=e.alpha),null!=e._paths&&gn(l,!1);{let t=null!=e._paths?e._paths.gaps:null,n=e.points.show(k,l,Yt,qt,t),i=e.points.filter(k,l,n,t);(n||i)&&(e.points._paths=e.points.paths(k,l,Yt,qt,i),gn(l,!0))}1!=sn&&(J.globalAlpha=sn=1),Ti("drawSeries",l)}})))}},Re=(u.drawOrder||["axes","series"]).map((e=>Ye[e]));function Le(e){let l=ve[e];if(null==l){let t=(u.scales||De)[e]||De;if(null!=t.from)Le(t.from),ve[e]=Ie({},ve[t.from],t,{key:e});else{l=ve[e]=Ie({},e==ze?nt:it,t),l.key=e;let n=l.time,i=l.range,o=We(i);if((e!=ze||2==M&&!n)&&(!o||null!=i[0]&&null!=i[1]||(i={min:null==i[0]?B:{mode:1,hard:i[0],soft:i[0]},max:null==i[1]?B:{mode:1,hard:i[1],soft:i[1]}},o=!1),!o&&Fe(i))){let e=i;i=(l,t,n)=>null==t?Ae:q(t,n,e)}l.range=me(i||(n?It:e==ze?3==l.distr?Nt:4==l.distr?Ut:Gt:3==l.distr?Ot:4==l.distr?jt:Lt)),l.auto=me(!o&&l.auto),l.clamp=me(l.clamp||tt),l._min=l._max=null}}}Le("x"),Le("y"),1==M&&de.forEach((e=>{Le(e.scale)})),ge.forEach((e=>{Le(e.scale)}));for(let e in u.scales)Le(e);const Ne=ve[ze],je=Ne.distr;let Ue,Be;0==Ne.ori?(S(O,"u-hz"),Ue=W,Be=C):(S(O,"u-vt"),Ue=C,Be=W);const Ve={};for(let e in ve){let l=ve[e];null==l.min&&null==l.max||(Ve[e]={min:l.min,max:l.max},l.min=l.max=null)}const Je=u.tzDate||(e=>new Date(ne(e/fe))),qe=u.fmtDate||Xe,Ke=1==fe?wl(Je):bl(Je),Ze=kl(Je,vl(1==fe?gl:_l,qe)),$e=Sl(Je,Ml("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",qe)),Qe=[],el=k.legend=Ie({},El,u.legend),ll=el.show,il=el.markers;let ol,sl,rl;el.idxs=Qe,il.width=me(il.width),il.dash=me(il.dash),il.stroke=me(il.stroke),il.fill=me(il.fill);let ul,al=[],fl=[],cl=!1,hl={};if(el.live){const e=de[1]?de[1].values:null;cl=null!=e,ul=cl?e(k,1,0):{_:0};for(let e in ul)hl[e]=x}if(ll)if(ol=z("table","u-legend",O),rl=z("tbody",null,ol),el.mount(k,ol),cl){sl=z("thead",null,ol,rl);let e=z("tr",null,sl);for(var dl in z("th",null,e),ul)z("th",l,e).textContent=dl}else S(ol,"u-inline"),el.live&&S(ol,"u-live");const pl={show:!0},yl={show:!1},Tl=new Map;function zl(e,l,t,n=!0){const i=Tl.get(l)||{},o=xt.bind[e](k,l,t,n);o&&(G(e,l,i[e]=o),Tl.set(l,i))}function Dl(e,l){const t=Tl.get(l)||{};for(let n in t)null!=e&&n!=e||(I(n,l,t[n]),delete t[n]);null==e&&Tl.delete(l)}let Al=0,Wl=0,Yl=0,Cl=0,Fl=0,Hl=0,jl=Fl,Ul=Hl,Bl=Yl,Vl=Cl,Jl=0,$l=0,Ql=0,ot=0;k.bbox={};let rt=!1,ut=!1,ft=!1,ct=!1,ht=!1,pt=!1;function mt(e,l,t){(t||e!=k.width||l!=k.height)&>(e,l),Mn(!1),ft=!0,ut=!0,On()}function gt(e,l){k.width=Al=Yl=e,k.height=Wl=Cl=l,Fl=Hl=0,function(){let e=!1,l=!1,t=!1,n=!1;ge.forEach((i=>{if(i.show&&i._show){let{side:o,_size:s}=i,r=s+(null!=i.label?i.labelSize:0);r>0&&(o%2?(Yl-=r,3==o?(Fl+=r,n=!0):t=!0):(Cl-=r,0==o?(Hl+=r,e=!0):l=!0))}})),Tt[0]=e,Tt[1]=t,Tt[2]=l,Tt[3]=n,Yl-=Pt[1]+Pt[3],Fl+=Pt[3],Cl-=Pt[2]+Pt[0],Hl+=Pt[0]}(),function(){let e=Fl+Yl,l=Hl+Cl,t=Fl,n=Hl;function i(i,o){switch(i){case 1:return e+=o,e-o;case 2:return l+=o,l-o;case 3:return t-=o,t+o;case 0:return n-=o,n+o}}ge.forEach((e=>{if(e.show&&e._show){let l=e.side;e._pos=i(l,e._size),null!=e.label&&(e._lpos=i(l,e.labelSize))}}))}();let t=k.bbox;Jl=t.left=ke(Fl*y,.5),$l=t.top=ke(Hl*y,.5),Ql=t.width=ke(Yl*y,.5),ot=t.height=ke(Cl*y,.5)}const wt=3;k.setSize=function({width:e,height:l}){mt(e,l)};const xt=k.cursor=Ie({},Pl,{drag:{y:2==M}},u.cursor),_t=e=>{xt.event=e};xt.idxs=Qe,xt._lock=!1;let bt=xt.points;bt.show=me(bt.show),bt.size=me(bt.size),bt.stroke=me(bt.stroke),bt.width=me(bt.width),bt.fill=me(bt.fill);const vt=k.focus=Ie({},u.focus||{alpha:.3},xt.focus),kt=vt.prox>=0;let yt=[null],Mt=[null],St=[null];function Et(t,n){if(1==M||n>0){let e=1==M&&ve[t.scale].time,l=t.value;t.value=e?Ce(l)?Sl(Je,Ml(l,qe)):l||$e:l||Xl,t.label=t.label||(e?"Time":"Value")}if(n>0){t.width=null==t.width?1:t.width,t.paths=t.paths||Ct||xe,t.fillTo=me(t.fillTo||at),t.pxAlign=+K(t.pxAlign,te),t.pxRound=dt(t.pxAlign),t.stroke=me(t.stroke||null),t.fill=me(t.fill||null),t._stroke=t._fill=t._paths=t._focus=null;let e=function(e){return Se(1*(3+2*(e||1)),3)}(se(1,t.width)),l=t.points=Ie({},{size:e,width:se(1,.2*e),stroke:t.stroke,space:2*e,paths:Ft,_stroke:null,_fill:null},t.points);l.show=me(l.show),l.filter=me(l.filter),l.fill=me(l.fill),l.stroke=me(l.stroke),l.paths=me(l.paths),l.pxAlign=t.pxAlign}if(ll){let i=function(t,n){if(0==n&&(cl||!el.live||2==M))return Ae;let i=[],o=z("tr","u-series",rl,rl.childNodes[n]);S(o,t.class),t.show||S(o,e);let s=z("th",null,o);if(il.show){let e=D("u-marker",s);if(n>0){let l=il.width(k,n);l&&(e.style.border=l+"px "+il.dash(k,n)+" "+il.stroke(k,n)),e.style.background=il.fill(k,n)}}let r=D(l,s);for(var u in r.textContent=t.label,n>0&&(il.show||(r.style.color=t.width>0?il.stroke(k,n):il.fill(k,n)),zl("click",s,(e=>{if(xt._lock)return;_t(e);let l=de.indexOf(t);if((e.ctrlKey||e.metaKey)!=el.isolate){let e=de.some(((e,t)=>t>0&&t!=l&&e.show));de.forEach(((t,n)=>{n>0&&$n(n,e?n==l?pl:yl:pl,!0,Di.setSeries)}))}else $n(l,{show:!t.show},!0,Di.setSeries)}),!1),kt&&zl(d,s,(e=>{xt._lock||(_t(e),$n(de.indexOf(t),ti,!0,Di.setSeries))}),!1)),ul){let e=z("td","u-value",o);e.textContent="--",i.push(e)}return[o,i]}(t,n);al.splice(n,0,i[0]),fl.splice(n,0,i[1]),el.values.push(null)}if(xt.show){Qe.splice(n,0,null);let e=function(e,l){if(l>0){let t=xt.points.show(k,l);if(t)return S(t,"u-cursor-pt"),S(t,e.class),A(t,-10,-10,Yl,Cl),$.insertBefore(t,yt[l]),t}}(t,n);null!=e&&(yt.splice(n,0,e),Mt.splice(n,0,0),St.splice(n,0,0))}Ti("addSeries",n)}k.addSeries=function(e,l){l=null==l?de.length:l,e=1==M?Rt(e,l,Gl,lt):Rt(e,l,null,et),de.splice(l,0,e),Et(de[l],l)},k.delSeries=function(e){if(de.splice(e,1),ll){el.values.splice(e,1),fl.splice(e,1);let l=al.splice(e,1)[0];Dl(null,l.firstChild),l.remove()}xt.show&&(Qe.splice(e,1),yt.length>1&&(yt.splice(e,1)[0].remove(),Mt.splice(e,1),St.splice(e,1))),Ti("delSeries",e)};const Tt=[!1,!1,!1,!1];function zt(e,l,t){let[n,i,o,s]=t,r=l%2,u=0;return 0==r&&(s||i)&&(u=0==l&&!n||2==l&&!o?ne(Rl.size/3):0),1==r&&(n||o)&&(u=1==l&&!i||3==l&&!s?ne(Zl.size/2):0),u}const Dt=k.padding=(u.padding||[zt,zt,zt,zt]).map((e=>me(K(e,zt)))),Pt=k._padding=Dt.map(((e,l)=>e(k,l,Tt,0)));let At,Yt=null,qt=null;const Kt=1==M?de[0].idxs:null;let Xt,Zt,$t,Qt,en,ln,tn,nn,on,sn,rn=null,un=!1;function an(e,l){if(g=null==e?[]:e,2==M){At=0;for(let e=1;de.length>e;e++)At+=g[e][0].length;k._data=g}else{0==g.length&&(g=[[]]),rn=g[0],At=rn.length;let e=g;if(2==je){e=g.slice();let l=e[0]=Array(At);for(let e=0;At>e;e++)l[e]=e}k._data=g=e}if(k.data=g,Mn(!0),Ti("setData"),2==je&&(ft=!0),!1!==l){let e=Ne;e.auto(k,un)?fn():Zn(ze,e.min,e.max),ct=ct||xt.left>=0,pt=!0,On()}}function fn(){let e,l;un=!0,1==M&&(At>0?(Yt=Kt[0]=0,qt=Kt[1]=At-1,e=g[0][Yt],l=g[0][qt],2==je?(e=Yt,l=qt):e==l&&(3==je?[e,l]=N(e,e,Ne.log,!1):4==je?[e,l]=j(e,e,Ne.log,!1):Ne.time?l=e+ne(86400/fe):[e,l]=q(e,l,U,!0))):(Yt=Kt[0]=e=null,qt=Kt[1]=l=null)),Zn(ze,e,l)}function cn(e,l,t,n,i,o){e??=a,t??=Pe,n??="butt",i??=a,o??="round",e!=Xt&&(J.strokeStyle=Xt=e),i!=Zt&&(J.fillStyle=Zt=i),l!=$t&&(J.lineWidth=$t=l),o!=en&&(J.lineJoin=en=o),n!=ln&&(J.lineCap=ln=n),t!=Qt&&J.setLineDash(Qt=t)}function hn(e,l,t,n){l!=Zt&&(J.fillStyle=Zt=l),e!=tn&&(J.font=tn=e),t!=nn&&(J.textAlign=nn=t),n!=on&&(J.textBaseline=on=n)}function dn(e,l,t,n,i=0){if(n.length>0&&e.auto(k,un)&&(null==l||null==l.min)){let l=K(Yt,0),o=K(qt,n.length-1),s=null==t.min?3==e.distr?function(e,l,t){let n=he,i=-he;for(let o=l;t>=o;o++){let l=e[o];null!=l&&l>0&&(n>l&&(n=l),l>i&&(i=l))}return[n,i]}(n,l,o):function(e,l,t,n){let i=he,o=-he;if(1==n)i=e[l],o=e[t];else if(-1==n)i=e[t],o=e[l];else for(let n=l;t>=n;n++){let l=e[n];null!=l&&(i>l&&(i=l),l>o&&(o=l))}return[i,o]}(n,l,o,i):[t.min,t.max];e.min=oe(e.min,t.min=s[0]),e.max=se(e.max,t.max=s[1])}}k.setData=an;const pn={min:null,max:null};function mn(e,l){let t=l?de[e].points:de[e];t._stroke=t.stroke(k,e),t._fill=t.fill(k,e)}function gn(e,l){let t=l?de[e].points:de[e],{stroke:n,fill:i,clip:o,flags:s,_stroke:r=t._stroke,_fill:u=t._fill,_width:a=t.width}=t._paths;a=Se(a*y,3);let f=null,c=a%2/2;l&&null==u&&(u=a>0?"#fff":r);let h=1==t.pxAlign&&c>0;if(h&&J.translate(c,c),!l){let e=Jl-a/2,l=$l-a/2,t=Ql+a,n=ot+a;f=new Path2D,f.rect(e,l,t,n)}l?xn(r,a,t.dash,t.cap,u,n,i,s,o):function(e,l,t,n,i,o,s,r,u,a,f){let c=!1;0!=u&&Me.forEach(((h,d)=>{if(h.series[0]==e){let e,p=de[h.series[1]],m=g[h.series[1]],w=(p._paths||De).band;We(w)&&(w=1==h.dir?w[0]:w[1]);let x=null;p.show&&w&&function(e,l,t){for(l=K(l,0),t=K(t,e.length-1);t>=l;){if(null!=e[l])return!0;l++}return!1}(m,Yt,qt)?(x=h.fill(k,d)||o,e=p._paths.clip):w=null,xn(l,t,n,i,x,s,r,u,a,f,e,w),c=!0}})),c||xn(l,t,n,i,o,s,r,u,a,f)}(e,r,a,t.dash,t.cap,u,n,i,s,f,o),h&&J.translate(-c,-c)}const wn=3;function xn(e,l,t,n,i,o,s,r,u,a,f,c){cn(e,l,t,n,i),(u||a||c)&&(J.save(),u&&J.clip(u),a&&J.clip(a)),c?(r&wn)==wn?(J.clip(c),f&&J.clip(f),bn(i,s),_n(e,o,l)):2&r?(bn(i,s),J.clip(c),_n(e,o,l)):1&r&&(J.save(),J.clip(c),f&&J.clip(f),bn(i,s),J.restore(),_n(e,o,l)):(bn(i,s),_n(e,o,l)),(u||a||c)&&J.restore()}function _n(e,l,t){t>0&&(l instanceof Map?l.forEach(((e,l)=>{J.strokeStyle=Xt=l,J.stroke(e)})):null!=l&&e&&J.stroke(l))}function bn(e,l){l instanceof Map?l.forEach(((e,l)=>{J.fillStyle=Zt=l,J.fill(e)})):null!=l&&e&&J.fill(l)}function vn(e,l,t,n,i,o,s,r,u,a){let f=s%2/2;1==te&&J.translate(f,f),cn(r,s,u,a,r),J.beginPath();let c,h,d,p,m=i+(0==n||3==n?-o:o);0==t?(h=i,p=m):(c=i,d=m);for(let n=0;e.length>n;n++)null!=l[n]&&(0==t?c=d=e[n]:h=p=e[n],J.moveTo(c,h),J.lineTo(d,p));J.stroke(),1==te&&J.translate(-f,-f)}function kn(e){let l=!0;return ge.forEach(((t,n)=>{if(!t.show)return;let i=ve[t.scale];if(null==i.min)return void(t._show&&(l=!1,t._show=!1,Mn(!1)));t._show||(l=!1,t._show=!0,Mn(!1));let o=t.side,s=o%2,{min:r,max:u}=i,[a,f]=function(e,l,t,n){let i,o=ge[e];if(n>0){let s=o._space=o.space(k,e,l,t,n);i=Bt(l,t,o._incrs=o.incrs(k,e,l,t,n,s),n,s)}else i=[0,0];return o._found=i}(n,r,u,0==s?Yl:Cl);if(0==f)return;let c=t._splits=t.splits(k,n,r,u,a,f,2==i.distr),h=2==i.distr?c.map((e=>rn[e])):c,d=2==i.distr?rn[c[1]]-rn[c[0]]:a,p=t._values=t.values(k,t.filter(k,h,n,f,d),n,f,d);t._rotate=2==o?t.rotate(k,p,n,f):0;let m=t._size;t._size=ie(t.size(k,p,n,e)),null!=m&&t._size!=m&&(l=!1)})),l}function yn(e){let l=!0;return Dt.forEach(((t,n)=>{let i=t(k,n,Tt,e);i!=Pt[n]&&(l=!1),Pt[n]=i})),l}function Mn(e){de.forEach(((l,t)=>{t>0&&(l._paths=null,e&&(1==M?(l.min=null,l.max=null):l.facets.forEach((e=>{e.min=null,e.max=null}))))}))}let Sn,En,Tn,zn,Dn,Pn,An,Wn,Yn,Cn,Fn,Hn,Rn=!1,Gn=!1,In=[];function Ln(){Gn=!1;for(let e=0;In.length>e;e++)Ti(...In[e]);In.length=0}function On(){Rn||(Oe(Nn),Rn=!0)}function Nn(){if(rt&&(function(){for(let e in ve){let l=ve[e];null==Ve[e]&&(null==l.min||null!=Ve[ze]&&l.auto(k,un))&&(Ve[e]=pn)}for(let e in ve){let l=ve[e];null==Ve[e]&&null!=l.from&&null!=Ve[l.from]&&(Ve[e]=pn)}null!=Ve[ze]&&Mn(!0);let e={};for(let l in Ve){let t=Ve[l];if(null!=t){let n=e[l]=Ge(ve[l],He);if(null!=t.min)Ie(n,t);else if(l!=ze||2==M)if(0==At&&null==n.from){let e=n.range(k,null,null,l);n.min=e[0],n.max=e[1]}else n.min=he,n.max=-he}}if(At>0){de.forEach(((l,t)=>{if(1==M){let n=l.scale,i=Ve[n];if(null==i)return;let o=e[n];if(0==t){let e=o.range(k,o.min,o.max,n);o.min=e[0],o.max=e[1],Yt=L(o.min,g[0]),qt=L(o.max,g[0]),qt-Yt>1&&(o.min>g[0][Yt]&&Yt++,g[0][qt]>o.max&&qt--),l.min=rn[Yt],l.max=rn[qt]}else l.show&&l.auto&&dn(o,i,l,g[t],l.sorted);l.idxs[0]=Yt,l.idxs[1]=qt}else if(t>0&&l.show&&l.auto){let[n,i]=l.facets,o=n.scale,s=i.scale,[r,u]=g[t],a=e[o],f=e[s];null!=a&&dn(a,Ve[o],n,r,n.sorted),null!=f&&dn(f,Ve[s],i,u,i.sorted),l.min=i.min,l.max=i.max}}));for(let l in e){let t=e[l],n=Ve[l];if(null==t.from&&(null==n||null==n.min)){let e=t.range(k,t.min==he?null:t.min,t.max==-he?null:t.max,l);t.min=e[0],t.max=e[1]}}}for(let l in e){let t=e[l];if(null!=t.from){let n=e[t.from];if(null==n.min)t.min=t.max=null;else{let e=t.range(k,n.min,n.max,l);t.min=e[0],t.max=e[1]}}}let l={},t=!1;for(let n in e){let i=e[n],o=ve[n];if(o.min!=i.min||o.max!=i.max){o.min=i.min,o.max=i.max;let e=o.distr;o._min=3==e?ae(o.min):4==e?ce(o.min,o.asinh):o.min,o._max=3==e?ae(o.max):4==e?ce(o.max,o.asinh):o.max,l[n]=t=!0}}if(t){de.forEach(((e,t)=>{2==M?t>0&&l.y&&(e._paths=null):l[e.scale]&&(e._paths=null)}));for(let e in l)ft=!0,Ti("setScale",e);xt.show&&xt.left>=0&&(ct=pt=!0)}for(let e in Ve)Ve[e]=null}(),rt=!1),ft&&(function(){let e=!1,l=0;for(;!e;){l++;let t=kn(l),n=yn(l);e=l==wt||t&&n,e||(gt(k.width,k.height),ut=!0)}}(),ft=!1),ut){if(T(Z,s,Fl),T(Z,i,Hl),T(Z,t,Yl),T(Z,n,Cl),T($,s,Fl),T($,i,Hl),T($,t,Yl),T($,n,Cl),T(X,t,Al),T(X,n,Wl),V.width=ne(Al*y),V.height=ne(Wl*y),ge.forEach((({_el:l,_show:t,_size:n,_pos:i,side:o})=>{if(null!=l)if(t){let t=o%2==1;T(l,t?"left":"top",i-(3===o||0===o?n:0)),T(l,t?"width":"height",n),T(l,t?"top":"left",t?Hl:Fl),T(l,t?"height":"width",t?Cl:Yl),E(l,e)}else S(l,e)})),Xt=Zt=$t=en=ln=tn=nn=on=Qt=null,sn=1,hi(!0),Fl!=jl||Hl!=Ul||Yl!=Bl||Cl!=Vl){Mn(!1);let e=Yl/Bl,l=Cl/Vl;if(xt.show&&!ct&&xt.left>=0){xt.left*=e,xt.top*=l,Tn&&A(Tn,ne(xt.left),0,Yl,Cl),zn&&A(zn,0,ne(xt.top),Yl,Cl);for(let t=1;yt.length>t;t++)Mt[t]*=e,St[t]*=l,A(yt[t],ye(Mt[t],1),ye(St[t],1),Yl,Cl)}if(qn.show&&!ht&&qn.left>=0&&qn.width>0){qn.left*=e,qn.width*=e,qn.top*=l,qn.height*=l;for(let e in mi)T(Kn,e,qn[e])}jl=Fl,Ul=Hl,Bl=Yl,Vl=Cl}Ti("setSize"),ut=!1}Al>0&&Wl>0&&(J.clearRect(0,0,V.width,V.height),Ti("drawClear"),Re.forEach((e=>e())),Ti("draw")),qn.show&&ht&&(Xn(qn),ht=!1),xt.show&&ct&&(fi(null,!0,!1),ct=!1),el.show&&el.live&&pt&&(ui(),pt=!1),R||(R=!0,k.status=1,Ti("ready")),un=!1,Rn=!1}function jn(e,l){let t=ve[e];if(null==t.from){if(0==At){let n=t.range(k,l.min,l.max,e);l.min=n[0],l.max=n[1]}if(l.min>l.max){let e=l.min;l.min=l.max,l.max=e}if(At>1&&null!=l.min&&null!=l.max&&1e-16>l.max-l.min)return;e==ze&&2==t.distr&&At>0&&(l.min=L(l.min,g[0]),l.max=L(l.max,g[0]),l.min==l.max&&l.max++),Ve[e]=l,rt=!0,On()}}k.batch=function(e,l=!1){Rn=!0,Gn=l,e(k),Nn(),l&&In.length>0&&queueMicrotask(Ln)},k.redraw=(e,l)=>{ft=l||!1,!1!==e?Zn(ze,Ne.min,Ne.max):On()},k.setScale=jn;let Un=!1;const Bn=xt.drag;let Vn=Bn.x,Jn=Bn.y;xt.show&&(xt.x&&(Sn=D("u-cursor-x",$)),xt.y&&(En=D("u-cursor-y",$)),0==Ne.ori?(Tn=Sn,zn=En):(Tn=En,zn=Sn),Fn=xt.left,Hn=xt.top);const qn=k.select=Ie({show:!0,over:!0,left:0,width:0,top:0,height:0},u.select),Kn=qn.show?D("u-select",qn.over?$:Z):null;function Xn(e,l){if(qn.show){for(let l in e)qn[l]=e[l],l in mi&&T(Kn,l,e[l]);!1!==l&&Ti("setSelect")}}function Zn(e,l,t){jn(e,{min:l,max:t})}function $n(l,t,n,i){null!=t.focus&&function(e){if(e!=li){let l=null==e,t=1!=vt.alpha;de.forEach(((n,i)=>{if(1==M||i>0){let o=l||0==i||i==e;n._focus=l?null:o,t&&function(e,l){de[e].alpha=l,xt.show&&yt[e]&&(yt[e].style.opacity=l),ll&&al[e]&&(al[e].style.opacity=l)}(i,o?1:vt.alpha)}})),li=e,t&&On()}}(l),null!=t.show&&de.forEach(((n,i)=>{0>=i||l!=i&&null!=l||(n.show=t.show,function(l){let t=ll?al[l]:null;de[l].show?t&&E(t,e):(t&&S(t,e),yt.length>1&&A(yt[l],-10,-10,Yl,Cl))}(i),2==M?(Zn(n.facets[0].scale,null,null),Zn(n.facets[1].scale,null,null)):Zn(n.scale,null,null),On())})),!1!==n&&Ti("setSeries",l,t),i&&Wi("setSeries",k,l,t)}let Qn,ei,li;k.setSelect=Xn,k.setSeries=$n,k.addBand=function(e,l){e.fill=me(e.fill||null),e.dir=K(e.dir,-1),Me.splice(l=null==l?Me.length:l,0,e)},k.setBand=function(e,l){Ie(Me[e],l)},k.delBand=function(e){null==e?Me.length=0:Me.splice(e,1)};const ti={focus:!0};function ni(e,l,t){let n=ve[l];t&&(e=e/y-(1==n.ori?Hl:Fl));let i=Yl;1==n.ori&&(i=Cl,e=i-e),-1==n.dir&&(e=i-e);let o=n._min,s=o+e/i*(n._max-o),r=n.distr;return 3==r?re(10,s):4==r?((e,l=1)=>Q.sinh(e)*l)(s,n.asinh):s}function ii(e,l){T(Kn,s,qn.left=e),T(Kn,t,qn.width=l)}function oi(e,l){T(Kn,i,qn.top=e),T(Kn,n,qn.height=l)}ll&&kt&&zl(p,ol,(e=>{xt._lock||(_t(e),null!=li&&$n(null,ti,!0,Di.setSeries))})),k.valToIdx=e=>L(e,g[0]),k.posToIdx=function(e,l){return L(ni(e,ze,l),g[0],Yt,qt)},k.posToVal=ni,k.valToPos=(e,l,t)=>0==ve[l].ori?W(e,ve[l],t?Ql:Yl,t?Jl:0):C(e,ve[l],t?ot:Cl,t?$l:0),k.setCursor=(e,l,t)=>{Fn=e.left,Hn=e.top,fi(null,l,t)};let si=0==Ne.ori?ii:oi,ri=1==Ne.ori?ii:oi;function ui(e,l){null!=e&&(e.idxs?e.idxs.forEach(((e,l)=>{Qe[l]=e})):(e=>void 0===e)(e.idx)||Qe.fill(e.idx),el.idx=Qe[0]);for(let e=0;de.length>e;e++)(e>0||1==M&&!cl)&&ai(e,Qe[e]);ll&&el.live&&function(){if(ll&&el.live)for(let e=2==M?1:0;de.length>e;e++){if(0==e&&cl)continue;let l=el.values[e],t=0;for(let n in l)fl[e][t++].firstChild.nodeValue=l[n]}}(),pt=!1,!1!==l&&Ti("setLegend")}function ai(e,l){let t,n=de[e],i=0==e&&2==je?rn:g[e];cl?t=n.values(k,e,l)??hl:(t=n.value(k,null==l?null:i[l],e,l),t=null==t?hl:{_:t}),el.values[e]=t}function fi(e,l,t){let n;Yn=Fn,Cn=Hn,[Fn,Hn]=xt.move(k,Fn,Hn),xt.show&&(Tn&&A(Tn,ne(Fn),0,Yl,Cl),zn&&A(zn,0,ne(Hn),Yl,Cl)),Qn=he;let i=0==Ne.ori?Yl:Cl,o=1==Ne.ori?Yl:Cl;if(0>Fn||0==At||Yt>qt){n=null;for(let e=0;de.length>e;e++)e>0&&yt.length>1&&A(yt[e],-10,-10,Yl,Cl);kt&&$n(null,ti,!0,null==e&&Di.setSeries),el.live&&(Qe.fill(n),pt=!0)}else{let e,l,t;1==M&&(e=0==Ne.ori?Fn:Hn,l=ni(e,ze),n=L(l,g[0],Yt,qt),t=Ue(g[0][n],Ne,i,0));for(let e=2==M?1:0;de.length>e;e++){let s=de[e],r=Qe[e],u=null==r?null:1==M?g[e][r]:g[e][1][r],a=xt.dataIdx(k,e,n,l),f=null==a?null:1==M?g[e][a]:g[e][1][a];pt=pt||f!=u||a!=r,Qe[e]=a;let c=a==n?t:Ue(1==M?g[0][a]:g[e][0][a],Ne,i,0);if(e>0&&s.show){let l,t,n=null==f?-10:Be(f,1==M?ve[s.scale]:ve[s.facets[1].scale],o,0);if(kt&&null!=f){let l=le(vt.dist(k,e,a,n,Hn));if(Qn>l){let t=vt.bias;if(0!=t){let n=ni(1==Ne.ori?Fn:Hn,s.scale),i=0>n?-1:1;i!=(0>f?-1:1)||(1==i?1==t?n>f:f>n:1==t?f>n:n>f)||(Qn=l,ei=e)}else Qn=l,ei=e}}if(0==Ne.ori?(l=c,t=n):(l=n,t=c),pt&&yt.length>1){Y(yt[e],xt.points.fill(k,e),xt.points.stroke(k,e));let n,i,o,s,r=!0,u=xt.points.bbox;if(null!=u){r=!1;let l=u(k,e);o=l.left,s=l.top,n=l.width,i=l.height}else o=l,s=t,n=i=xt.points.size(k,e);F(yt[e],n,i,r),Mt[e]=o,St[e]=s,A(yt[e],ye(o,1),ye(s,1),Yl,Cl)}}}}if(xt.idx=n,xt.left=Fn,xt.top=Hn,qn.show&&Un)if(null!=e){let[l,t]=Di.scales,[n,s]=Di.match,[r,u]=e.cursor.sync.scales,a=e.cursor.drag;if(Vn=a._x,Jn=a._y,Vn||Jn){let a,f,c,h,d,{left:p,top:m,width:g,height:w}=e.select,x=e.scales[l].ori,_=e.posToVal,b=null!=l&&n(l,r),v=null!=t&&s(t,u);b&&Vn?(0==x?(a=p,f=g):(a=m,f=w),c=ve[l],h=Ue(_(a,r),c,i,0),d=Ue(_(a+f,r),c,i,0),si(oe(h,d),le(d-h))):si(0,i),v&&Jn?(1==x?(a=p,f=g):(a=m,f=w),c=ve[t],h=Be(_(a,u),c,o,0),d=Be(_(a+f,u),c,o,0),ri(oe(h,d),le(d-h))):ri(0,o)}else gi()}else{let e=le(Yn-Dn),l=le(Cn-Pn);if(1==Ne.ori){let t=e;e=l,l=t}Vn=Bn.x&&e>=Bn.dist,Jn=Bn.y&&l>=Bn.dist;let t,n,s=Bn.uni;null!=s?Vn&&Jn&&(Vn=e>=s,Jn=l>=s,Vn||Jn||(l>e?Jn=!0:Vn=!0)):Bn.x&&Bn.y&&(Vn||Jn)&&(Vn=Jn=!0),Vn&&(0==Ne.ori?(t=An,n=Fn):(t=Wn,n=Hn),si(oe(t,n),le(n-t)),Jn||ri(0,o)),Jn&&(1==Ne.ori?(t=An,n=Fn):(t=Wn,n=Hn),ri(oe(t,n),le(n-t)),Vn||si(0,i)),Vn||Jn||(si(0,0),ri(0,0))}if(Bn._x=Vn,Bn._y=Jn,null==e){if(t){if(null!=Pi){let[e,l]=Di.scales;Di.values[0]=null!=e?ni(0==Ne.ori?Fn:Hn,e):null,Di.values[1]=null!=l?ni(1==Ne.ori?Fn:Hn,l):null}Wi(f,k,Fn,Hn,Yl,Cl,n)}if(kt){let e=t&&Di.setSeries,l=vt.prox;null==li?Qn>l||$n(ei,ti,!0,e):Qn>l?$n(null,ti,!0,e):ei!=li&&$n(ei,ti,!0,e)}}pt&&(el.idx=n,ui()),!1!==l&&Ti("setCursor")}k.setLegend=ui;let ci=null;function hi(e=!1){e?ci=null:(ci=$.getBoundingClientRect(),Ti("syncRect",ci))}function di(e,l,t,n,i,o){xt._lock||Un&&null!=e&&0==e.movementX&&0==e.movementY||(pi(e,l,t,n,i,o,0,!1,null!=e),null!=e?fi(null,!0,!0):fi(l,!0,!1))}function pi(e,l,t,n,i,o,s,r,u){if(null==ci&&hi(!1),_t(e),null!=e)t=e.clientX-ci.left,n=e.clientY-ci.top;else{if(0>t||0>n)return Fn=-10,void(Hn=-10);let[e,s]=Di.scales,r=l.cursor.sync,[u,a]=r.values,[f,c]=r.scales,[h,d]=Di.match,p=l.axes[0].side%2==1,m=0==Ne.ori?Yl:Cl,g=1==Ne.ori?Yl:Cl,w=p?o:i,x=p?i:o,_=p?n:t,b=p?t:n;if(t=null!=f?h(e,f)?H(u,ve[e],m,0):-10:m*(_/w),n=null!=c?d(s,c)?H(a,ve[s],g,0):-10:g*(b/x),1==Ne.ori){let e=t;t=n,n=e}}u&&(t>1&&Yl-1>t||(t=ke(t,Yl)),n>1&&Cl-1>n||(n=ke(n,Cl))),r?(Dn=t,Pn=n,[An,Wn]=xt.move(k,t,n)):(Fn=t,Hn=n)}Object.defineProperty(k,"rect",{get:()=>(null==ci&&hi(!1),ci)});const mi={width:0,height:0,left:0,top:0};function gi(){Xn(mi,!1)}let wi,xi,_i,bi;function vi(e,l,t,n,i,o){Un=!0,Vn=Jn=Bn._x=Bn._y=!1,pi(e,l,t,n,i,o,0,!0,!1),null!=e&&(zl(h,b,ki,!1),Wi(c,k,An,Wn,Yl,Cl,null));let{left:s,top:r,width:u,height:a}=qn;wi=s,xi=r,_i=u,bi=a,gi()}function ki(e,l,t,n,i,o){Un=Bn._x=Bn._y=!1,pi(e,l,t,n,i,o,0,!1,!0);let{left:s,top:r,width:u,height:a}=qn,f=u>0||a>0,c=wi!=s||xi!=r||_i!=u||bi!=a;if(f&&c&&Xn(qn),Bn.setScale&&f&&c){let e=s,l=u,t=r,n=a;if(1==Ne.ori&&(e=r,l=a,t=s,n=u),Vn&&Zn(ze,ni(e,ze),ni(e+l,ze)),Jn)for(let e in ve){let l=ve[e];e!=ze&&null==l.from&&l.min!=he&&Zn(e,ni(t+n,e),ni(t,e))}gi()}else xt.lock&&(xt._lock=!xt._lock,xt._lock||fi(null,!0,!1));null!=e&&(Dl(h,b),Wi(h,k,Fn,Hn,Yl,Cl,null))}function yi(e){xt._lock||(_t(e),fn(),gi(),null!=e&&Wi(m,k,Fn,Hn,Yl,Cl,null))}function Mi(){ge.forEach(Jt),mt(k.width,k.height,!0)}G(w,v,Mi);const Si={};Si.mousedown=vi,Si.mousemove=di,Si.mouseup=ki,Si.dblclick=yi,Si.setSeries=(e,l,t,n)=>{-1!=(t=(0,Di.match[2])(k,l,t))&&$n(t,n,!0,!1)},xt.show&&(zl(c,$,vi),zl(f,$,di),zl(d,$,(e=>{_t(e),hi(!1)})),zl(p,$,(function(e){if(xt._lock)return;_t(e);let l=Un;if(Un){let e,l,t=!0,n=!0,i=10;0==Ne.ori?(e=Vn,l=Jn):(e=Jn,l=Vn),e&&l&&(t=i>=Fn||Fn>=Yl-i,n=i>=Hn||Hn>=Cl-i),e&&t&&(Fn=An>Fn?0:Yl),l&&n&&(Hn=Wn>Hn?0:Cl),fi(null,!0,!0),Un=!1}Fn=-10,Hn=-10,fi(null,!0,!0),l&&(Un=l)})),zl(m,$,yi),Wt.add(k),k.syncRect=hi);const Ei=k.hooks=u.hooks||{};function Ti(e,l,t){Gn?In.push([e,l,t]):e in Ei&&Ei[e].forEach((e=>{e.call(null,k,l,t)}))}(u.plugins||[]).forEach((e=>{for(let l in e.hooks)Ei[l]=(Ei[l]||[]).concat(e.hooks[l])}));const zi=(e,l,t)=>t,Di=Ie({key:null,setSeries:!1,filters:{pub:_e,sub:_e},scales:[ze,de[1]?de[1].scale:null],match:[be,be,zi],values:[null,null]},xt.sync);2==Di.match.length&&Di.match.push(zi),xt.sync=Di;const Pi=Di.key,Ai=st(Pi);function Wi(e,l,t,n,i,o,s){Di.filters.pub(e,l,t,n,i,o,s)&&Ai.pub(e,l,t,n,i,o,s)}function Yi(){Ti("init",u,g),an(g||u.data,!1),Ve[ze]?jn(ze,Ve[ze]):fn(),ht=qn.show&&(qn.width>0||qn.height>0),ct=pt=!0,mt(u.width,u.height)}return Ai.sub(k),k.pub=function(e,l,t,n,i,o,s){Di.filters.sub(e,l,t,n,i,o,s)&&Si[e](null,l,t,n,i,o,s)},k.destroy=function(){Ai.unsub(k),Wt.delete(k),Tl.clear(),I(w,v,Mi),O.remove(),ol?.remove(),Ti("destroy")},de.forEach(Et),ge.forEach((function(e,l){if(e._show=e.show,e.show){let t=ve[e.scale];null==t&&(e.scale=e.side%2?de[1].scale:ze,t=ve[e.scale]);let n=t.time;e.size=me(e.size),e.space=me(e.space),e.rotate=me(e.rotate),We(e.incrs)&&e.incrs.forEach((e=>{!Ee.has(e)&&Ee.set(e,Te(e))})),e.incrs=me(e.incrs||(2==t.distr?tl:n?1==fe?ml:xl:nl)),e.splits=me(e.splits||(n&&1==t.distr?Ke:3==t.distr?Ol:4==t.distr?Nl:Ll)),e.stroke=me(e.stroke),e.grid.stroke=me(e.grid.stroke),e.ticks.stroke=me(e.ticks.stroke),e.border.stroke=me(e.border.stroke);let i=e.values;e.values=We(i)&&!We(i[0])?me(i):n?We(i)?kl(Je,vl(i,qe)):Ce(i)?function(e,l){let t=Xe(l);return(l,n)=>n.map((l=>t(e(l))))}(Je,i):i||Ze:i||Il,e.filter=me(e.filter||(3>t.distr||10!=t.log?3==t.distr&&2==t.log?Kl:we:ql)),e.font=Vt(e.font),e.labelFont=Vt(e.labelFont),e._size=e.size(k,null,l,0),e._space=e._rotate=e._incrs=e._found=e._splits=e._values=null,e._size>0&&(Tt[l]=!0,e._el=D("u-axis",X))}})),_?_ instanceof HTMLElement?(_.appendChild(O),Yi()):_(k,Yi):Yi(),k}qt.assign=Ie,qt.fmtNum=$,qt.rangeNum=q,qt.rangeLog=N,qt.rangeAsinh=j,qt.orient=rt,qt.pxRatio=y,qt.join=function(e,l){if(function(e){let l=e[0][0],t=l.length;for(let n=1;e.length>n;n++){let i=e[n][0];if(i.length!=t)return!1;if(i!=l)for(let e=0;t>e;e++)if(i[e]!=l[e])return!1}return!0}(e)){let l=e[0].slice();for(let t=1;e.length>t;t++)l.push(...e[t].slice(1));return function(e,l=100){const t=e.length;if(1>=t)return!0;let n=0,i=t-1;for(;i>=n&&null==e[n];)n++;for(;i>=n&&null==e[i];)i--;if(n>=i)return!0;const o=se(1,te((i-n+1)/l));for(let l=e[n],t=n+o;i>=t;t+=o){const n=e[t];if(null!=n){if(l>=n)return!1;l=n}}return!0}(l[0])||(l=function(e){let l=e[0],t=l.length,n=Array(t);for(let e=0;n.length>e;e++)n[e]=e;n.sort(((e,t)=>l[e]-l[t]));let i=[];for(let l=0;e.length>l;l++){let o=e[l],s=Array(t);for(let e=0;t>e;e++)s[e]=o[n[e]];i.push(s)}return i}(l)),l}let t=new Set;for(let l=0;e.length>l;l++){let n=e[l][0],i=n.length;for(let e=0;i>e;e++)t.add(n[e])}let n=[Array.from(t).sort(((e,l)=>e-l))],i=n[0].length,o=new Map;for(let e=0;i>e;e++)o.set(n[0][e],e);for(let t=0;e.length>t;t++){let s=e[t],r=s[0];for(let e=1;s.length>e;e++){let u=s[e],a=Array(i).fill(void 0),f=l?l[t][e]:1,c=[];for(let e=0;u.length>e;e++){let l=u[e],t=o.get(r[e]);null===l?0!=f&&(a[t]=l,2==f&&c.push(t)):a[t]=l}Le(a,c,i),n.push(a)}}return n},qt.fmtDate=Xe,qt.tzDate=function(e,l){let t;return"UTC"==l||"Etc/UTC"==l?t=new Date(+e+6e4*e.getTimezoneOffset()):l==Ze?t=e:(t=new Date(e.toLocaleString("en-US",{timeZone:l})),t.setMilliseconds(e.getMilliseconds())),t},qt.sync=st;{qt.addGap=function(e,l,t){let n=e[e.length-1];n&&n[0]==l?n[1]=t:e.push([l,t])},qt.clipGaps=ct;let e=qt.paths={points:St};e.linear=Dt,e.stepped=function(e){const l=K(e.align,1),t=K(e.ascDesc,!1),n=K(e.alignGaps,0),i=K(e.extend,!1);return(e,o,s,r)=>rt(e,o,((u,a,f,c,h,d,p,m,g,w,x)=>{let _=u.pxRound,{left:b,width:v}=e.bbox,k=e=>_(d(e,c,w,m)),M=e=>_(p(e,h,x,g)),S=0==c.ori?wt:xt;const E={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},T=E.stroke,z=c.dir*(0==c.ori?1:-1);s=O(f,s,r,1),r=O(f,s,r,-1);let D=M(f[1==z?s:r]),P=k(a[1==z?s:r]),A=P,W=P;i&&-1==l&&(W=b,S(T,W,D)),S(T,P,D);for(let e=1==z?s:r;e>=s&&r>=e;e+=z){let t=f[e];if(null==t)continue;let n=k(a[e]),i=M(t);1==l?S(T,n,D):S(T,A,i),S(T,n,i),D=i,A=n}let Y=A;i&&1==l&&(Y=b+v,S(T,Y,D));let[C,F]=ut(e,o);if(null!=u.fill||0!=C){let l=E.fill=new Path2D(T),t=M(u.fillTo(e,o,u.min,u.max,C));S(l,Y,t),S(l,W,t)}if(!u.spanGaps){let i=[];i.push(...ht(a,f,s,r,z,k,n));let h=u.width*y/2,d=t||1==l?h:-h,p=t||-1==l?-h:h;i.forEach((e=>{e[0]+=d,e[1]+=p})),E.gaps=i=u.gaps(e,o,s,r,i),E.clip=ct(i,c.ori,m,g,w,x)}return 0!=F&&(E.band=2==F?[ft(e,o,s,r,T,-1),ft(e,o,s,r,T,1)]:ft(e,o,s,r,T,F)),E}))},e.bars=function(e){const l=K((e=e||De).size,[.6,he,1]),t=e.align||0,n=e.gap||0;let i=e.radius;i=null==i?[0,0]:"number"==typeof i?[i,0]:i;const o=me(i),s=1-l[0],r=K(l[1],he),u=K(l[2],1),a=K(e.disp,De),f=K(e.each,(()=>{})),{fill:c,stroke:h}=a;return(e,l,i,d)=>rt(e,l,((p,m,g,w,x,_,b,v,k,M,S)=>{let E,T,z=p.pxRound,D=n*y,P=r*y,A=u*y;0==w.ori?[E,T]=o(e,l):[T,E]=o(e,l);const W=w.dir*(0==w.ori?1:-1);let Y,C,F,H=0==w.ori?_t:bt,R=0==w.ori?f:(e,l,t,n,i,o,s)=>{f(e,l,t,i,n,s,o)},G=K(e.bands,Pe).find((e=>e.series[0]==l)),I=p.fillTo(e,l,p.min,p.max,null!=G?G.dir:0),L=z(b(I,x,S,k)),O=M,N=z(p.width*y),j=!1,U=null,B=null,V=null,J=null;null==c||0!=N&&null==h||(j=!0,U=c.values(e,l,i,d),B=new Map,new Set(U).forEach((e=>{null!=e&&B.set(e,new Path2D)})),N>0&&(V=h.values(e,l,i,d),J=new Map,new Set(V).forEach((e=>{null!=e&&J.set(e,new Path2D)}))));let{x0:q,size:X}=a;if(null!=q&&null!=X){m=q.values(e,l,i,d),2==q.unit&&(m=m.map((l=>e.posToVal(v+l*M,w.key,!0))));let t=X.values(e,l,i,d);C=2==X.unit?t[0]*M:_(t[0],w,M,v)-_(0,w,M,v),O=Pt(m,g,_,w,M,v,O),F=O-C+D}else O=Pt(m,g,_,w,M,v,O),F=O*s+D,C=O-F;1>F&&(F=0),C/2>N||(N=0),5>F&&(z=ge);let Z=F>0;C=z(pe(O-F-(Z?N:0),A,P)),Y=(0==t?C/2:t==W?0:C)-t*W*((0==t?D/2:0)+(Z?N/2:0));const $={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},Q=j?null:new Path2D;let ee=null;if(null!=G)ee=e.data[G.series[1]];else{let{y0:t,y1:n}=a;null!=t&&null!=n&&(g=n.values(e,l,i,d),ee=t.values(e,l,i,d))}let le=E*C,ne=T*C;for(let t=1==W?i:d;t>=i&&d>=t;t+=W){let n=g[t];if(null==n)continue;if(null!=ee){let e=ee[t]??0;if(n-e==0)continue;L=b(e,x,S,k)}let i=_(2!=w.distr||null!=a?m[t]:t,w,M,v),o=b(K(n,I),x,S,k),s=z(i-Y),r=z(se(o,L)),u=z(oe(o,L)),f=r-u;if(null!=n){let i=0>n?ne:le,o=0>n?le:ne;j?(N>0&&null!=V[t]&&H(J.get(V[t]),s,u+te(N/2),C,se(0,f-N),i,o),null!=U[t]&&H(B.get(U[t]),s,u+te(N/2),C,se(0,f-N),i,o)):H(Q,s,u+te(N/2),C,se(0,f-N),i,o),R(e,l,t,s-N/2,u,C+N,f)}}return N>0?$.stroke=j?J:Q:j||($._fill=0==p.width?p._fill:p._stroke??p._fill,$.width=0),$.fill=j?B:Q,$}))},e.spline=function(e){return function(e,l){const t=K(l?.alignGaps,0);return(l,n,i,o)=>rt(l,n,((s,r,u,a,f,c,h,d,p,m,g)=>{let w,x,_,b=s.pxRound,v=e=>b(c(e,a,m,d)),k=e=>b(h(e,f,g,p));0==a.ori?(w=mt,_=wt,x=yt):(w=gt,_=xt,x=Mt);const y=a.dir*(0==a.ori?1:-1);i=O(u,i,o,1),o=O(u,i,o,-1);let M=v(r[1==y?i:o]),S=M,E=[],T=[];for(let e=1==y?i:o;e>=i&&o>=e;e+=y)if(null!=u[e]){let l=v(r[e]);E.push(S=l),T.push(k(u[e]))}const z={stroke:e(E,T,w,_,x,b),fill:null,clip:null,band:null,gaps:null,flags:1},D=z.stroke;let[P,A]=ut(l,n);if(null!=s.fill||0!=P){let e=z.fill=new Path2D(D),t=k(s.fillTo(l,n,s.min,s.max,P));_(e,S,t),_(e,M,t)}if(!s.spanGaps){let e=[];e.push(...ht(r,u,i,o,y,v,t)),z.gaps=e=s.gaps(l,n,i,o,e),z.clip=ct(e,a.ori,d,p,m,g)}return 0!=A&&(z.band=2==A?[ft(l,n,i,o,D,-1),ft(l,n,i,o,D,1)]:ft(l,n,i,o,D,A)),z}))}(At,e)}}return qt}(); diff --git a/src/uPlot.js b/src/uPlot.js index a2cd0d3f..f258588a 100644 --- a/src/uPlot.js +++ b/src/uPlot.js @@ -2022,6 +2022,17 @@ export default function uPlot(opts, data, then) { } let queuedCommit = false; + let deferHooks = false; + let hooksQueue = []; + + function flushHooks() { + deferHooks = false; + + for (let i = 0; i < hooksQueue.length; i++) + fire(...hooksQueue[i]) + + hooksQueue.length = 0; + } function commit() { if (!queuedCommit) { @@ -2031,10 +2042,15 @@ export default function uPlot(opts, data, then) { } // manual batching (aka immediate mode), skips microtask queue - function batch(fn) { + function batch(fn, _deferHooks = false) { queuedCommit = true; + deferHooks = _deferHooks; + fn(self); _commit(); + + if (_deferHooks && hooksQueue.length > 0) + queueMicrotask(flushHooks); } self.batch = batch; @@ -3210,10 +3226,14 @@ export default function uPlot(opts, data, then) { const hooks = self.hooks = opts.hooks || {}; function fire(evName, a1, a2) { - if (evName in hooks) { - hooks[evName].forEach(fn => { - fn.call(null, self, a1, a2); - }); + if (deferHooks) + hooksQueue.push([evName, a1, a2]); + else { + if (evName in hooks) { + hooks[evName].forEach(fn => { + fn.call(null, self, a1, a2); + }); + } } }