ml-time-graph 1.3.3 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,49 +1,49 @@
1
- var nt=class i{_config;constructor(t){this._config=t;}compute(){let{width:t,height:e,margin:n}=this._config;return {totalWidth:t,totalHeight:e,chartWidth:t-n.left-n.right,chartHeight:e-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(t=800,e=400){return new i({width:t,height:e,margin:{top:20,right:20,bottom:40,left:60}})}};function it(i){return i&&i.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}var pe=(()=>{let i=new Array(256);for(let t=0;t<256;t++){let e=t;for(let n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;i[t]=e>>>0;}return i})();function fe(i){let t=new TextEncoder().encode(i),e=4294967295;for(let n of t)e=pe[(e^n)&255]^e>>>8;return (e^4294967295)>>>0}function rt(i,t){return t||"s-"+fe(i??"").toString(16).padStart(8,"0")}var It=new Map;function ge(i,t){return `${i}|${JSON.stringify(t??{})}`}function Gt(i,t){let e=ge(i,t),n=It.get(e);return n||(n=new Intl.DateTimeFormat(i,t),It.set(e,n)),n}var X=class{#t;#e;constructor(t){this.#t=[...t.domain],this.#e=[...t.range];}map(t){let e=Number(t),[n,o]=this.#t,[r,s]=this.#e;return o===n?r:r+(e-n)/(o-n)*(s-r)}invert(t){let[e,n]=this.#t,[o,r]=this.#e;return r===o?e:e+(t-o)/(r-o)*(n-e)}domain(){return [...this.#t]}range(){return [...this.#e]}},z=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],J=class{#t;#e;constructor(t){this.#t=new X({domain:t.domain,range:t.range}),this.#e=t.locale||(typeof navigator<"u"?navigator.language:"en-US");}map(t){return this.#t.map(Number(t))}invert(t){return this.#t.invert(t)}domain(){return this.#t.domain()}range(){return this.#t.range()}get locale(){return this.#e}tickInterval(t,e=3,n=12){let[o,r]=this.#t.domain(),s=r-o;if(s<=0)return {interval:z[0].ms};let a=s/t,h=z[0].ms;for(let u of z)if(u.ms>=a){h=u.ms;break}let l=h,d=Math.round(s/l);for(;d>n&&l<z[z.length-1].ms;){let u=z.findIndex(m=>m.ms===l);l=z[Math.min(u+1,z.length-1)].ms,d=Math.round(s/l);}for(;d<e&&l>z[0].ms;){let u=z.findIndex(m=>m.ms===l);l=z[Math.max(u-1,0)].ms,d=Math.round(s/l);}return {interval:l}}ticks(t){let e=t?.minTicks??5,n=t?.maxTicks??12,{interval:o}=this.tickInterval((e+n)/2,e,n),[r,s]=this.#t.domain(),a=[],h=Math.ceil(r/o)*o;for(let l=h;l<=s;l+=o)a.push(l);return a}format(t,e){return Gt(this.#e,e).format(new Date(t))}};var Mt={stroke:"#4285f4",strokeWidth:2,pointSize:4,pointThreshold:100,gapThreshold:0,fill:"none",hatch:null,bandFill:"#4285f4",bandOpacity:.6,bandAvgLine:"#e53e3e",minColor:"#3b82f6",maxColor:"#ef4444",avgColor:"#64748b",areaFillAlpha:"4285f433",axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:11,axisLabelColor:"#444",axisLabelSize:12,gridStroke:"#e2e8f0",gridStrokeWidth:1,gridOpacity:1,legendStroke:"#ccc",legendText:"#333",legendFont:11,annotationColor:"#334155",annotationWidth:1.5,annotationHead:9,annotationRadius:4,annotationFontSize:11,thresholdColor:"#666",thresholdLine:"dashed",thresholdFillOpacity:.12,thresholdFontSize:10,highlightColor:"#fbbf24",highlightOpacity:.2,highlightLabelColor:"#92400e",markerColor:"#f59e0b",markerSize:5,gapFill:"#fff",gapStroke:"#ccc",gapStrokeWidth:1,gapFontColor:"#999",gapFontSize:10,gapFillOpacity:.15,tooltipBg:"#fff",tooltipBorder:"#cbd5e1",tooltipText:"#1e293b",tooltipValue:"#3b82f6",tooltipCrosshair:"#94a3b8",tooltipSnapRadius:20,statsLineColor:"#94a3b8",statsLabelColor:"#64748b",minimapStroke:"#94a3b8",minimapBg:"#f8f9fa",minimapBrush:"#3b82f644",palette:["#4285f4","#ea4335","#22c55e","#fbbc05","#9334ea","#12b5e5","#fb923c","#6366f1"]};var ht={...Mt};function ye(i){ht={...ht,...i};}function Q(){return ht}function be(){ht={...Mt};}function Lt(i,t="classic-diagonal",e="rgba(200, 220, 255, 0.3)",n="#4D88FF",o=2){if(t==="none")return `
1
+ var nt=class i{_config;constructor(t){this._config=t;}compute(){let{width:t,height:e,margin:n}=this._config;return {totalWidth:t,totalHeight:e,chartWidth:t-n.left-n.right,chartHeight:e-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(t=800,e=400){return new i({width:t,height:e,margin:{top:20,right:20,bottom:40,left:60}})}};function it(i){return i&&i.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}var fe=(()=>{let i=new Array(256);for(let t=0;t<256;t++){let e=t;for(let n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;i[t]=e>>>0;}return i})();function ge(i){let t=new TextEncoder().encode(i),e=4294967295;for(let n of t)e=fe[(e^n)&255]^e>>>8;return (e^4294967295)>>>0}function rt(i,t){return t||"s-"+ge(i??"").toString(16).padStart(8,"0")}var Gt=new Map;function ye(i,t){return `${i}|${JSON.stringify(t??{})}`}function Et(i,t){let e=ye(i,t),n=Gt.get(e);return n||(n=new Intl.DateTimeFormat(i,t),Gt.set(e,n)),n}var X=class{#t;#e;constructor(t){this.#t=[...t.domain],this.#e=[...t.range];}map(t){let e=Number(t),[n,r]=this.#t,[o,a]=this.#e;return r===n?o:o+(e-n)/(r-n)*(a-o)}invert(t){let[e,n]=this.#t,[r,o]=this.#e;return o===r?e:e+(t-r)/(o-r)*(n-e)}domain(){return [...this.#t]}range(){return [...this.#e]}},z=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],J=class{#t;#e;constructor(t){this.#t=new X({domain:t.domain,range:t.range}),this.#e=t.locale||(typeof navigator<"u"?navigator.language:"en-US");}map(t){return this.#t.map(Number(t))}invert(t){return this.#t.invert(t)}domain(){return this.#t.domain()}range(){return this.#t.range()}get locale(){return this.#e}tickInterval(t,e=3,n=12){let[r,o]=this.#t.domain(),a=o-r;if(a<=0)return {interval:z[0].ms};let s=a/t,l=z[0].ms;for(let u of z)if(u.ms>=s){l=u.ms;break}let h=l,d=Math.round(a/h);for(;d>n&&h<z[z.length-1].ms;){let u=z.findIndex(m=>m.ms===h);h=z[Math.min(u+1,z.length-1)].ms,d=Math.round(a/h);}for(;d<e&&h>z[0].ms;){let u=z.findIndex(m=>m.ms===h);h=z[Math.max(u-1,0)].ms,d=Math.round(a/h);}return {interval:h}}ticks(t){let e=t?.minTicks??5,n=t?.maxTicks??12,{interval:r}=this.tickInterval((e+n)/2,e,n),[o,a]=this.#t.domain(),s=[],l=Math.ceil(o/r)*r;for(let h=l;h<=a;h+=r)s.push(h);return s}format(t,e){return Et(this.#e,e).format(new Date(t))}};var Mt={stroke:"#4285f4",strokeWidth:2,pointSize:4,pointThreshold:100,gapThreshold:0,fill:"none",hatch:null,bandFill:"#4285f4",bandOpacity:.6,bandAvgLine:"#e53e3e",minColor:"#3b82f6",maxColor:"#ef4444",avgColor:"#64748b",areaFillAlpha:"4285f433",axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:11,axisLabelColor:"#444",axisLabelSize:12,gridStroke:"#e2e8f0",gridStrokeWidth:1,gridOpacity:1,legendStroke:"#ccc",legendText:"#333",legendFont:11,annotationColor:"#334155",annotationWidth:1.5,annotationHead:9,annotationRadius:4,annotationFontSize:11,thresholdColor:"#666",thresholdLine:"dashed",thresholdFillOpacity:.12,thresholdFontSize:10,highlightColor:"#fbbf24",highlightOpacity:.2,highlightLabelColor:"#92400e",markerColor:"#f59e0b",markerSize:5,gapFill:"#fff",gapStroke:"#ccc",gapStrokeWidth:1,gapFontColor:"#999",gapFontSize:10,gapFillOpacity:.15,tooltipBg:"#fff",tooltipBorder:"#cbd5e1",tooltipText:"#1e293b",tooltipValue:"#3b82f6",tooltipCrosshair:"#94a3b8",tooltipSnapRadius:20,statsLineColor:"#94a3b8",statsLabelColor:"#64748b",minimapStroke:"#94a3b8",minimapBg:"#f8f9fa",minimapBrush:"#3b82f644",palette:["#4285f4","#ea4335","#22c55e","#fbbc05","#9334ea","#12b5e5","#fb923c","#6366f1"]};var ht={...Mt};function be(i){ht={...ht,...i};}function Q(){return ht}function xe(){ht={...Mt};}function Se(i){let t=i.trim();if(t.startsWith("#"))return t.length===9?t.slice(0,7):t.length===5?t.slice(0,4):t;if(t.toLowerCase().startsWith("rgba(")){let n=t.slice(5,t.lastIndexOf(")")).split(",");if(n.length===4)return `rgb(${n[0].trim()}, ${n[1].trim()}, ${n[2].trim()})`}return t}function _e(i){let t=i.trim().toLowerCase();return t.startsWith("#")?t.length===9||t.length===5:t.startsWith("rgba(")||t.startsWith("hsla(")}function Dt(i,t="classic-diagonal",e="rgba(200, 220, 255, 0.3)",n,r=2){let o=Se(e),a=_e(e)?"":' fill-opacity="0.3"';if(t==="none")return `
2
2
  <pattern id="${i}" width="10" height="10" patternUnits="userSpaceOnUse">
3
3
  <rect width="10" height="10" fill="${e}" />
4
4
  </pattern>
5
- `.trim();let r=12,s=12,a="rotate(0)",h="";switch(t){case "classic-diagonal":r=12,s=12,a="rotate(45)",h=`<line x1="0" y1="0" x2="0" y2="${s}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />`;break;case "dense-steep":r=6,s=6,a="rotate(30)",h=`<line x1="0" y1="0" x2="0" y2="${s}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />`;break;case "crosshatch":r=14,s=14,a="rotate(45)",h=`
6
- <line x1="0" y1="0" x2="0" y2="${s}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />
7
- <line x1="0" y1="0" x2="${r}" y2="0" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />
8
- `;break;case "dots":r=12,s=12,h=`<circle cx="${r/2}" cy="${s/2}" r="${o*1.2}" fill="${n}" />`;break;case "waves":r=16,s=16,h=`
9
- <path d="M 0 ${s/2} Q ${r/4} 0, ${r/2} ${s/2} T ${r} ${s/2}" fill="none" stroke="${n}" stroke-width="${o}" stroke-linecap="round" />
10
- `;break;case "dashed":r=12,s=12,a="rotate(45)",h=`<line x1="0" y1="0" x2="0" y2="${s}" stroke="${n}" stroke-width="${o}" stroke-dasharray="3,3" />`;break;case "herringbone":r=16,s=16,h=`
11
- <path d="M 0 0 L ${r/2} ${s/2} L 0 ${s} M ${r} 0 L ${r/2} ${s/2} L ${r} ${s}" fill="none" stroke="${n}" stroke-width="${o}" stroke-linejoin="round" stroke-linecap="round" />
12
- `;break;case "brick":r=20,s=20,h=`
13
- <path d="M 0 ${s/2} L ${r} ${s/2} M 0 ${s} L ${r} ${s} M ${r/2} 0 L ${r/2} ${s/2} M 0 ${s/2} L 0 ${s}" fill="none" stroke="${n}" stroke-width="${o}" />
14
- `;break;case "double-stripe":r=16,s=16,a="rotate(45)",h=`
15
- <line x1="0" y1="0" x2="0" y2="${s}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />
16
- <line x1="${r/2}" y1="0" x2="${r/2}" y2="${s}" stroke="${n}" stroke-width="${o/2}" stroke-linecap="square" />
17
- `;break;case "honeycomb":r=18,s=32,h=`
18
- <path d="M 0 0 L ${r/2} 5 L ${r} 0 M 0 16 L ${r/2} 11 L ${r} 16 M 0 16 L 0 32 M ${r/2} 5 L ${r/2} 11 M ${r} 16 L ${r} 32 M 0 32 L ${r/2} 27 L ${r} 32 M ${r/2} 27 L ${r/2} 32" fill="none" stroke="${n}" stroke-width="${o}" stroke-linejoin="round" stroke-linecap="round" />
19
- `;break}let l=`<rect width="${r}" height="${s}" fill="${e}" />`;return `
20
- <pattern id="${i}" width="${r}" height="${s}" patternTransform="${a}" patternUnits="userSpaceOnUse">
21
- ${l}
22
- ${h}
5
+ `.trim();let s=12,l=12,h="rotate(0)",d="";switch(t){case "classic-diagonal":s=12,l=12,h="rotate(45)",d=`<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />`;break;case "dense-steep":s=6,l=6,h="rotate(30)",d=`<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />`;break;case "crosshatch":s=14,l=14,h="rotate(45)",d=`
6
+ <line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
7
+ <line x1="0" y1="0" x2="${s}" y2="0" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
8
+ `;break;case "dots":s=12,l=12,d=`<circle cx="${s/2}" cy="${l/2}" r="${r*1.2}" fill="${o}" />`;break;case "waves":s=16,l=16,d=`
9
+ <path d="M 0 ${l/2} Q ${s/4} 0, ${s/2} ${l/2} T ${s} ${l/2}" fill="none" stroke="${o}" stroke-width="${r}" stroke-linecap="round" />
10
+ `;break;case "dashed":s=12,l=12,h="rotate(45)",d=`<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-dasharray="3,3" />`;break;case "herringbone":s=16,l=16,d=`
11
+ <path d="M 0 0 L ${s/2} ${l/2} L 0 ${l} M ${s} 0 L ${s/2} ${l/2} L ${s} ${l}" fill="none" stroke="${o}" stroke-width="${r}" stroke-linejoin="round" stroke-linecap="round" />
12
+ `;break;case "brick":s=20,l=20,d=`
13
+ <path d="M 0 ${l/2} L ${s} ${l/2} M 0 ${l} L ${s} ${l} M ${s/2} 0 L ${s/2} ${l/2} M 0 ${l/2} L 0 ${l}" fill="none" stroke="${o}" stroke-width="${r}" />
14
+ `;break;case "double-stripe":s=16,l=16,h="rotate(45)",d=`
15
+ <line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
16
+ <line x1="${s/2}" y1="0" x2="${s/2}" y2="${l}" stroke="${o}" stroke-width="${r/2}" stroke-linecap="square" />
17
+ `;break;case "honeycomb":s=18,l=32,d=`
18
+ <path d="M 0 0 L ${s/2} 5 L ${s} 0 M 0 16 L ${s/2} 11 L ${s} 16 M 0 16 L 0 32 M ${s/2} 5 L ${s/2} 11 M ${s} 16 L ${s} 32 M 0 32 L ${s/2} 27 L ${s} 32 M ${s/2} 27 L ${s/2} 32" fill="none" stroke="${o}" stroke-width="${r}" stroke-linejoin="round" stroke-linecap="round" />
19
+ `;break}let u=`<rect width="${s}" height="${l}" fill="${e}"${a} />`;return `
20
+ <pattern id="${i}" width="${s}" height="${l}" patternTransform="${h}" patternUnits="userSpaceOnUse">
21
+ ${u}
22
+ ${d}
23
23
  </pattern>
24
- `.trim()}function Et(i,t=2){let e=t;switch(i){case "dotted":return {strokeDasharray:`0, ${e*2}`,strokeLinecap:"round"};case "sparse-dots":return {strokeDasharray:`0, ${e*4}`,strokeLinecap:"round"};case "dashed":return {strokeDasharray:`${e*3}, ${e*2}`,strokeLinecap:"butt"};case "long-dash":return {strokeDasharray:`${e*6}, ${e*3}`,strokeLinecap:"butt"};case "dense-dash":return {strokeDasharray:`${e*1.5}, ${e*1.5}`,strokeLinecap:"butt"};case "dash-dot":return {strokeDasharray:`${e*4}, ${e*2}, 0, ${e*2}`,strokeLinecap:"round"};case "dash-dot-dot":return {strokeDasharray:`${e*5}, ${e*2}, 0, ${e*2}, 0, ${e*2}`,strokeLinecap:"round"};case "loose-dash":return {strokeDasharray:`${e*3}, ${e*4}`,strokeLinecap:"butt"};default:return {strokeDasharray:"none",strokeLinecap:"butt"}}}var g=new Proxy({},{get:(i,t)=>Q()[t],has:(i,t)=>t in Q(),ownKeys:()=>Reflect.ownKeys(Q()),getOwnPropertyDescriptor:(i,t)=>Reflect.getOwnPropertyDescriptor(Q(),t)});var ot={axisColor:g.axisColor,tickColor:g.tickColor,textColor:g.textColor,textSize:g.textSize},tt=class{#t;#e;constructor(t){this.#t=new J({domain:t.domain,range:t.xRange,locale:t.locale}),this.#e=t;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??ot).axisColor}get tickColor(){return (this.#e.colors??ot).tickColor}get textColor(){return (this.#e.colors??ot).textColor}get textSize(){return (this.#e.colors??ot).textSize}generateTicks(){let t=this.#e.minTicks??5,e=this.#e.maxTicks??12,o=this.#t.ticks({minTicks:t,maxTicks:e}).map(r=>({time:r,x:this.#t.map(r),label:this.tickLabel(r)}));return this.antiOverlap(o)}tickLabel(t){if(this.#e.format)return this.#e.format(new Date(t));let e=this.#e.minTicks??5,n=this.#e.maxTicks??12,{interval:o}=this.#t.tickInterval((e+n)/2,e,n),r={};return o<6e4?(r.hour="2-digit",r.minute="2-digit",r.second="2-digit"):o<36e5||o<864e5?(r.hour="2-digit",r.minute="2-digit"):o<31536e6?(r.day="numeric",r.month="short",o>=2592e6&&(r.day=void 0,r.month="long")):(r.year="numeric",o<2*31536e6&&(r.month="short")),this.#t.format(t,r)}antiOverlap(t){if(t.length<=1)return t;let e=60,n=[t[0]];for(let o=1;o<t.length;o++){let r=n[n.length-1].x;Math.abs(t[o].x-r)>=e&&n.push(t[o]);}return n}render(){let t=this.generateTicks(),e=this.#e.colors??ot,n=this.#e.y??0,o=[],[r,s]=this.#t.range();o.push({type:"line",x1:r,y1:n,x2:s,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let a of t)o.push({type:"line",x1:a.x,y1:n,x2:a.x,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),o.push({type:"text",content:a.label,x:a.x,y:n+e.textSize+6,anchor:"middle",fontSize:e.textSize,fill:e.textColor});return o}};var st={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function xe(i){return Math.abs(i)>=1e6?`${(i/1e6).toFixed(1)}M`:Math.abs(i)>=1e3?`${(i/1e3).toFixed(1)}k`:Number.isInteger(i)?String(i):i.toFixed(1)}function Se(i){let t=new Array(i.length).fill(false),e=0;for(;e<i.length;){let n=e;for(;n+1<i.length&&i[n+1].label===i[e].label;)n++;for(let o=e+1;o<n;o++)t[o]=true;e=n+1;}return t}var dt=class{#t;#e;constructor(t){this.#t=new X({domain:t.domain,range:t.range}),this.#e=t;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??st).axisColor}get tickColor(){return (this.#e.colors??st).tickColor}get textColor(){return (this.#e.colors??st).textColor}get textSize(){return (this.#e.colors??st).textSize}generateTicks(){let t=this.#e.format??xe,e=6,[n,o]=this.#t.domain(),r=o-n;if(r===0)return [{value:n,position:this.#t.map(n),label:t(n)}];let s=r/e,a=Math.pow(10,Math.floor(Math.log10(s))),h=s/a,l;h<=1.5?l=a:h<=3?l=2*a:h<=7?l=5*a:l=10*a;let d=[],u=Math.ceil(n/l)*l;for(let m=u;m<=o;m+=l)d.push({value:m,position:this.#t.map(m),label:t(m)});return d}render(){let t=this.generateTicks(),e=this.#e.colors??st,n=this.#e.x??0,o=this.#e.orientation??"vertical",r=this.#e.position??"left",s=this.#e.suppressLabelsNear??[],a=this.#e.suppressTolerancePx??8,h=d=>s.some(u=>Math.abs(u-d)<=a),l=[];if(o==="vertical"){let[d,u]=this.#t.range();l.push({type:"line",x1:n,y1:d,x2:n,y2:u,stroke:e.axisColor,strokeWidth:e.axisWidth});let m=Se(t);t.forEach((c,f)=>{let y=h(c.position),b=m[f]?{opacity:0}:{};r==="left"?(l.push({type:"line",x1:n-4,y1:c.position,x2:n,y2:c.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||l.push({type:"text",content:c.label,x:n-8,y:c.position+4,anchor:"end",fontSize:11,fill:e.textColor,...b})):(l.push({type:"line",x1:n,y1:c.position,x2:n+4,y2:c.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||l.push({type:"text",content:c.label,x:n+8,y:c.position+4,anchor:"start",fontSize:11,fill:e.textColor,...b}));});}else {let[d,u]=this.#t.range();l.push({type:"line",x1:d,y1:n,x2:u,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let m of t)l.push({type:"line",x1:m.position,y1:n,x2:m.position,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),l.push({type:"text",content:m.label,x:m.position,y:n+18,anchor:"middle",fontSize:e.textSize,fill:e.textColor});}return l}};var R=class{static interpolateDataPoint(i,t,e){return {time:i.time+Math.round(e*(t.time-i.time)),value:(i.value??0)+e*((t.value??0)-(i.value??0))}}static interpolateAggregatedPoint(i,t,e){let n=(o,r)=>o!==null&&r!==null?o+e*(r-o):null;return {time:i.time+e*(t.time-i.time),min:n(i.min,t.min),max:n(i.max,t.max),avg:n(i.avg,t.avg),count:Math.round(i.count+e*(t.count-i.count))}}static getRuns(i,t,e=0){let n=[...i].sort((a,h)=>a.time-h.time),o=[],r=[],s=null;for(let a of n){let h=t(a),l=e>0&&s&&a.time-s.time>e;(h||l)&&r.length&&(o.push(r),r=[]),h||r.push(a),s=a;}return r.length&&o.push(r),o}static splitByBoundaries(i,t,e,n){if(i.length===0)return [];if(t.length===0)return [{data:i,zoneIndex:0}];let o=[...t].sort((h,l)=>h-l),r=[],s=h=>{let l=0;for(let d=0;d<o.length&&h>=o[d];d++)l=d+1;return l},a=[i[0]];for(let h=1;h<i.length;h++){let l=i[h-1],d=i[h],u=e(l),m=e(d),c;m>u?c=o.filter(f=>f>u&&f<=m):m<u?c=o.filter(f=>f>=m&&f<u).reverse():c=[];for(let f of c){let y=(f-u)/(m-u),b=n(l,d,y);a.push(b),r.push({data:a,zoneIndex:s((u+f)/2)}),a=[b];}a.push(d);}if(a.length>0){let h=e(a[0]),l=e(a[a.length-1]);r.push({data:a,zoneIndex:s((h+l)/2)});}return r}static splitByThreshold(i,t,e,n){let o=this.splitByBoundaries(i,[t],e,n),r={above:[],below:[]};for(let s of o)s.zoneIndex===0?r.below.push(s.data):r.above.push(s.data);return r}};function Vt(i,t=6e4){if(i.length<2)return [];let e=[...i].sort((o,r)=>o.time-r.time),n=[];for(let o=1;o<e.length;o++)e[o].time-e[o-1].time>t&&n.push({startTime:e[o-1].time,endTime:e[o].time});return n}function _e(i,t=83144){let e=t/8.314,n=0,o=0;for(let s of i)s!==null&&(n+=Math.exp(-e/(s+273.15)),o++);if(o===0)return null;let r=n/o;return e/-Math.log(r)-273.15}function Nt(i,t,e=83144){let n=new Array(i.length),o=0;for(let r=0;r<i.length;r++){let s=i[r].time,a=s-t;for(;o<r&&i[o].time<a;)o++;let h=i.slice(o,r+1).map(d=>d.value),l=_e(h,e);n[r]={time:s,value:l,synthetic:true};}return n}function we(i){let t=0,e=0;for(let r of i)r!==null&&(t+=r,e++);if(e===0)return null;let n=t/e,o=0;for(let r of i){if(r===null)continue;let s=r-n;o+=s*s;}return Math.sqrt(o/e)}function ve(i){let t=0,e=0;for(let r of i)r!==null&&(t+=r,e++);if(e<2)return null;let n=t/e,o=0;for(let r of i){if(r===null)continue;let s=r-n;o+=s*s;}return Math.sqrt(o/(e-1))}function Yt(i,t,e=false){let n=new Array(i.length),o=0,r=e?ve:we;for(let s=0;s<i.length;s++){let a=i[s].time,h=a-t;for(;o<s&&i[o].time<h;)o++;let l=i.slice(o,s+1).map(u=>u.value),d=r(l);n[s]={time:a,value:d,synthetic:true};}return n}function zt(i){return {id:i.id,line:{stroke:i.stroke??g.stroke,strokeWidth:i.strokeWidth??g.strokeWidth,smoothing:i.smoothing??false,dashed:i.dashed??false},fill:i.fill??g.areaFillAlpha,markers:{type:i.pointStyle??"none",size:i.pointSize??g.pointSize,stroke:i.stroke??g.stroke,fill:"#ffffff"},shadow:{color:i.shadowColor??"transparent",blur:i.shadowBlur??0,offsetX:i.shadowOffsetX??0,offsetY:i.shadowOffsetY??0}}}function mt(i,t,e){let n=[],o=i.reduce((s,a)=>s+a.data.length,0),r=zt(e);for(let s=0;s<i.length;s++){let a=i[s];a.data.length>=2?n.push({type:"path",id:e.id?`${e.id}-line-${s}`:void 0,points:a.data.map(h=>({x:t.timeScale.map(h.time),y:t.valueScale.map(h.value)})),stroke:a.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:r.line.smoothing,dashed:r.line.dashed,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur,shadowOffsetX:r.shadow.offsetX,shadowOffsetY:r.shadow.offsetY,fill:"none"}):a.data.length===1&&o===1&&n.push({type:"circle",cx:t.timeScale.map(a.data[0].time),cy:t.valueScale.map(a.data[0].value),r:Math.max(r.markers.size,r.line.strokeWidth),fill:a.color??r.line.stroke,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur});}return n}function qt(i){let t=[];for(let e of i)t.length===0?t.push(e):t.push({x:e.x,y:t[t.length-1].y},e);return t}function Dt(i,t,e,n){if(i.length<2)return [];let o=R.splitByBoundaries(i,e.boundaries,e.getValue,e.interpolate),r=[];for(let s=0;s<o.length;s++){let a=o[s];if(a.data.length<2)continue;let h=e.getColor(a.zoneIndex);if(!h)continue;let l=a.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yLow(u))})),d=a.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yHigh(u))})).reverse();r.push({type:"path",id:n?.id?`${n.id}-fill-${s}`:void 0,points:[...l,...d],fill:h,hatch:e.getHatch?.(a.zoneIndex),stroke:"none"});}return r}function Xt(i,t,e,n){let o=zt(e);if(!o.markers.type||o.markers.type==="none")return [];let r=[];for(let s=0;s<i.length;s++){let a=i[s],h=t.timeScale.map(a.time),l=t.valueScale.map(a.value),d=n(a),u=e.pointStroke??d,m=e.pointFill??d,c=e.pointStrokeWidth??1.5,f=e.id?`${e.id}-marker-${s}`:void 0;Pt(r,f,o.markers.type,h,l,o.markers.size,u,m,c);}return r}function Pt(i,t,e,n,o,r,s,a,h){switch(e){case "circle":i.push({type:"circle",cx:n,cy:o,r,fill:a,stroke:s,strokeWidth:h,id:t});break;case "square":i.push({type:"rect",x:n-r,y:o-r,w:r*2,h:r*2,fill:a,stroke:s,strokeWidth:h,id:t});break;case "cross":i.push({type:"line",x1:n-r,y1:o-r,x2:n+r,y2:o+r,stroke:s,strokeWidth:h,id:t},{type:"line",x1:n-r,y1:o+r,x2:n+r,y2:o-r,stroke:s,strokeWidth:h,id:t});break;case "diamond":i.push({type:"path",points:[{x:n,y:o-r},{x:n+r,y:o},{x:n,y:o+r},{x:n-r,y:o}],fill:a,stroke:s,strokeWidth:h,id:t});break;case "triangle":i.push({type:"path",points:[{x:n,y:o-r},{x:n+r,y:o+r},{x:n-r,y:o+r}],fill:a,stroke:s,strokeWidth:h,id:t});break;case "star":{let l=[];for(let d=0;d<10;d++){let u=d%2===0?r:r*.5,m=Math.PI/2*3+d*Math.PI/5;l.push({x:n+u*Math.cos(m),y:o+u*Math.sin(m)});}i.push({type:"path",points:l,fill:a,stroke:s,strokeWidth:h,id:t});break}case "arrow":i.push({type:"path",points:[{x:n-r,y:o+r},{x:n,y:o-r},{x:n+r,y:o+r}],stroke:s,strokeWidth:h,fill:"none",id:t});break;case "plus":i.push({type:"line",x1:n-r,y1:o,x2:n+r,y2:o,stroke:s,strokeWidth:h,id:t},{type:"line",x1:n,y1:o-r,x2:n,y2:o+r,stroke:s,strokeWidth:h,id:t});break;case "triangle-down":i.push({type:"path",points:[{x:n,y:o+r},{x:n+r,y:o-r},{x:n-r,y:o-r}],fill:a,stroke:s,strokeWidth:h,id:t});break;case "hexagon":{let l=[];for(let d=0;d<6;d++){let u=d*(Math.PI/3);l.push({x:n+r*Math.cos(u),y:o+r*Math.sin(u)});}i.push({type:"path",points:l,fill:a,stroke:s,strokeWidth:h,id:t});break}case "hourglass":i.push({type:"path",points:[{x:n-r,y:o-r},{x:n+r,y:o-r},{x:n-r,y:o+r},{x:n+r,y:o+r}],fill:a,stroke:s,strokeWidth:h,id:t});break;case "line-horizontal":i.push({type:"line",x1:n-r,y1:o,x2:n+r,y2:o,stroke:s,strokeWidth:h,id:t});break;default:i.push({type:"circle",cx:n,cy:o,r,fill:a,stroke:s,strokeWidth:h,id:t});}}var et=class i{#t;#e;static uidcnt=0;#n;constructor(t,e=[]){this.#t=t.id??"series-"+ ++i.uidcnt,this.#e=t.timeScale,this.#n=e;}get id(){return this.#t}get timeScale(){return this.#e}get data(){return this.#n}};var ut=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}render(){let t=this.#t,e=t.minColor??g.minColor,n=t.maxColor??g.maxColor,o=t.avgColor??g.avgColor,r=t.avgDashed??true,s=t.smoothing??false,a=t.strokeWidth??g.strokeWidth,h=R.getRuns(this.data,c=>c.min===null||c.max===null||c.avg===null);if(h.length===0)return [];let l={timeScale:this.timeScale,valueScale:t.valueScale},d=[];h.forEach((c,f)=>{c.length<2||(t.fillToMax&&d.push(...Dt(c,l,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.max,getValue:y=>y.avg,interpolate:R.interpolateAggregatedPoint,getColor:()=>t.fillToMax,getHatch:()=>t.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${f}`:void 0})),t.fillToMin&&d.push(...Dt(c,l,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.min,getValue:y=>y.avg,interpolate:R.interpolateAggregatedPoint,getColor:()=>t.fillToMin,getHatch:()=>t.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${f}`:void 0})));});let u=h.filter(c=>c.length>=2),m=c=>u.map(f=>({data:f.map(y=>({time:y.time,value:c(y)}))}));return d.push(...mt(m(c=>c.max),l,{stroke:n,strokeWidth:a,smoothing:s,id:this.id?`${this.id}-max`:void 0}),...mt(m(c=>c.min),l,{stroke:e,strokeWidth:a,smoothing:s,id:this.id?`${this.id}-min`:void 0}),...mt(m(c=>c.avg),l,{stroke:o,strokeWidth:a,smoothing:s,dashed:r,id:this.id?`${this.id}-avg`:void 0})),d}};var ct=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}opacity(t){if(!(this.#t.countOpacity??false))return .6;let e=0;for(let n of this.data)n.count>e&&(e=n.count);return e===0?.2:.2+.8*t/e}render(){let t=this.#t,e=t.fill??g.bandFill,n=t.hatch,o=t.avgLine??false,r=t.avgLineColor??g.bandAvgLine,s=t.bandWidth??10,a=[];for(let h of this.data){if(h.min===null||h.max===null)continue;let l=this.timeScale.map(h.time),d=t.valueScale.map(h.max),u=t.valueScale.map(h.min),m=s,c=this.data.indexOf(h);if(a.push({type:"rect",x:l-m/2,y:d,w:m,h:u-d,fill:e,hatch:n,opacity:this.opacity(h.count),id:this.id?`${this.id}-slot-${c}`:void 0}),o&&h.avg!==null){let f=t.valueScale.map(h.avg);a.push({type:"line",x1:l-m/2,y1:f,x2:l+m/2,y2:f,stroke:r,strokeWidth:1,id:this.id?`${this.id}-avg-${c}`:void 0});}}return a}};function ke(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function Ut(i){let{thresholds:t,valueScale:e,xRange:n}=i,[o,r]=n,[s,a]=e.range(),h=Math.min(s,a),l=Math.max(s,a),d=[],u=[];for(let m of t){let c=m.color??g.thresholdColor,f=e.map(m.value);m.fill==="above"?d.push({type:"rect",x:o,y:h,w:r-o,h:Math.max(0,f-h),fill:c,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0}):m.fill==="below"&&d.push({type:"rect",x:o,y:f,w:r-o,h:Math.max(0,l-f),fill:c,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0});let y=m.line??g.thresholdLine;if(y!=="none"){let b=ke(y),_={type:"line",x1:o,y1:f,x2:r,y2:f,stroke:c,strokeWidth:1,...b,id:m.id?`${m.id}-line`:void 0};m.shadowColor&&(_.shadowColor=m.shadowColor,_.shadowBlur=m.shadowBlur??4,_.shadowOffsetX=m.shadowOffsetX??0,_.shadowOffsetY=m.shadowOffsetY??2),d.push(_);}if(m.label!==false){let b=m.label&&typeof m.label=="object"?m.label:void 0,_=typeof m.label=="string"?m.label:b?.text??m.name,C=b?.position??"right";u.push({...Ce(_,C,o,r,f,c,b),id:m.id?`${m.id}-label`:void 0});}}return {inside:d,labels:u}}function Ce(i,t,e,n,o,r,s){let a=(e+n)/2,h={type:"text",content:i,fontSize:g.thresholdFontSize,fill:r},l=s?{...s.rotate!==void 0&&{rotate:s.rotate},...s.textBaseline!==void 0&&{textBaseline:s.textBaseline}}:{};switch(t){case "left":return {...h,...l,x:e+4,y:o-4,anchor:"start"};case "above":return {...h,...l,x:a,y:o-6,anchor:"middle"};case "below":return {...h,...l,x:a,y:o+14,anchor:"middle"};case "center":return {...h,...l,x:a,y:o-4,anchor:"middle"};case "outside-left":return {...h,...l,x:e-6,y:o+3,anchor:"end",textBaseline:l.textBaseline??"middle"};case "outside-right":return {...h,...l,x:n+6,y:o+3,anchor:"start",textBaseline:l.textBaseline??"middle"};default:return {...h,...l,x:n-4,y:o-4,anchor:"end"}}}function Kt(i){let{gaps:t,timeScale:e,yRange:n,fill:o=g.gapFill,hatch:r,fillOpacity:s=g.gapFillOpacity??.15,stroke:a=g.gapStroke,strokeWidth:h=g.gapStrokeWidth,dashed:l=true,fontSize:d=g.gapFontSize,fontFill:u=g.gapFontColor,labelBaseline:m="middle",labelRotate:c}=i,[f,y]=n,b=[];for(let _ of t){let C=e.map(_.startTime),N=e.map(_.endTime),P=_.fill??o,L=_.hatch??r,W=_.fillOpacity??s,B=_.label??"",G=_.rotate??c,I=_.labelBaseline??m;if(_.style==="dashed_border"||!_.style?b.push({type:"rect",x:C,y:f,w:N-C,h:y-f,fill:P,hatch:L,opacity:W,stroke:a,strokeWidth:h,dashed:l}):_.style==="empty"&&b.push({type:"rect",x:C,y:f,w:N-C,h:y-f,fill:P,hatch:L,opacity:W}),B){let S=Te(f,y,I),v=I==="above"?"top":I==="below"?"bottom":"middle";b.push({type:"text",content:B,x:(C+N)/2,y:S,anchor:"middle",fontSize:d,fill:u,textBaseline:v,rotate:G});}}return b}function Te(i,t,e){switch(e){case "above":return i-12;case "below":return t+4;default:return (i+t)/2}}var pt=class{#t;constructor(t,e,n,o){this.#t={...t,xRange:e,y:n,height:o};}render(){let{items:t,timeScale:e,background:n,hatch:o,showAxis:r,xRange:s,y:a,height:h}=this.#t,l=[];n&&l.push({type:"rect",x:s[0],y:a,w:s[1]-s[0],h,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let d of t){let u=e.map(d.startTime),m=e.map(d.endTime);if(!(m-u<1)&&(l.push({type:"rect",x:u,y:a,w:m-u,h,hatch:d.hatch??o,fill:d.fill??"#6b728044",stroke:d.stroke,strokeWidth:d.strokeWidth??0}),d.label)){let c=d.labelFontSize??10;l.push({type:"text",content:d.label,x:(u+m)/2,y:this.#e(d.labelBaseline,c),anchor:"middle",fontSize:c,fill:d.labelFill??"#333"});}}if(r){let d=new tt({domain:e.domain(),xRange:s,y:a+h+4});l.push({type:"group",cssClass:"annotation-band-axis",commands:d.render()});}return l}#e(t,e){let{y:n,height:o}=this.#t;switch(t){case "top":return n+e*.9;case "bottom":return n+o-e*.25;default:return n+o/2+e*.35}}};function Zt(i){let{highlights:t,timeScale:e,yRange:n,height:o}=i,[r,s]=n,a=[];for(let h of t){let l=e.map(h.startTime),d=e.map(h.endTime);a.push({type:"rect",x:l,y:r,w:d-l,h:s-r,fill:h.color??g.highlightColor,opacity:h.opacity??g.highlightOpacity}),h.label&&a.push({type:"text",content:h.label,x:(l+d)/2,y:$e(h.labelPosition??"top",r,s,o),anchor:"middle",fontSize:g.annotationFontSize,fill:h.color??g.highlightLabelColor,rotate:h.rotate});}return a}function $e(i,t,e,n){switch(i){case "above":return t-5;case "below":return n!==void 0?n-5:e+14;case "center":return (t+e)/2+4;case "bottom":return e-6;default:return t+14}}function Jt(i){let{markers:t,timeScale:e,valueScale:n,yRange:o=[0,300]}=i,[r,s]=o,a=[];for(let h of t){let l=e.map(h.time),d=h.color??g.markerColor,u=h.pointStyle??(h.value!==void 0?"circle":"none"),m=h.lineStyle??"full";if(h.value!==void 0){let c=n.map(h.value);if(m==="to-value"?a.push({type:"line",x1:l,y1:s,x2:l,y2:c,stroke:d,strokeWidth:1,dashed:true}):m==="to-top"?a.push({type:"line",x1:l,y1:r,x2:l,y2:c,stroke:d,strokeWidth:1,dashed:true}):m==="full"&&a.push({type:"line",x1:l,y1:r,x2:l,y2:s,stroke:d,strokeWidth:1}),u!=="none"&&Pt(a,void 0,u,l,c,g.markerSize,d,d,1.5),h.label){let f=m==="to-value"?c-10:r-6;a.push({type:"text",content:h.label,x:l,y:f,anchor:"middle",fontSize:11,fill:d});}}else a.push({type:"line",x1:l,y1:r,x2:l,y2:s,stroke:d,strokeWidth:1}),h.label&&a.push({type:"text",content:h.label,x:l,y:r-6,anchor:"middle",fontSize:11,fill:d});}return a}function Qt(i){let{annotations:t,timeScale:e,valueScales:n}=i,o=[],r=s=>{let a=n.get(s.axis??0)??n.values().next().value;return {x:e.map(s.time),y:a?a.map(s.value):0}};for(let s of t){let a=[],h=l=>a.push(l);switch(s.type){case "line":{let l=r(s.from),d=r(s.to);h({type:"line",x1:l.x,y1:l.y,x2:d.x,y2:d.y,stroke:s.color??g.annotationColor,strokeWidth:s.width??g.annotationWidth,dash:s.dash});break}case "arrow":{let l=r(s.from),d=r(s.to),u=s.color??g.annotationColor,m=s.headSize??g.annotationHead;h({type:"line",x1:l.x,y1:l.y,x2:d.x,y2:d.y,stroke:u,strokeWidth:s.width??g.annotationWidth});let c=Math.hypot(d.x-l.x,d.y-l.y)||1,f=(d.x-l.x)/c,y=(d.y-l.y)/c,b=d.x-f*m,_=d.y-y*m;h({type:"path",points:[{x:d.x,y:d.y},{x:b-y*m*.5,y:_+f*m*.5},{x:b+y*m*.5,y:_-f*m*.5}],fill:u,stroke:"none"});break}case "rect":{let l=r(s.from),d=r(s.to);h({type:"rect",x:Math.min(l.x,d.x),y:Math.min(l.y,d.y),w:Math.abs(d.x-l.x),h:Math.abs(d.y-l.y),fill:s.fill??"none",stroke:s.stroke,opacity:s.opacity});break}case "point":{let l=r(s.at),d=s.color??"#334155",u=s.radius??g.annotationRadius,m=s.shape??"circle";m==="circle"?h({type:"circle",cx:l.x,cy:l.y,r:u,fill:d}):m==="square"?h({type:"rect",x:l.x-u,y:l.y-u,w:u*2,h:u*2,fill:d}):(h({type:"line",x1:l.x-u,y1:l.y-u,x2:l.x+u,y2:l.y+u,stroke:d,strokeWidth:1.5}),h({type:"line",x1:l.x-u,y1:l.y+u,x2:l.x+u,y2:l.y-u,stroke:d,strokeWidth:1.5}));break}case "label":{let l=r(s.at);h({type:"text",content:s.text,x:l.x+(s.dx??0),y:l.y+(s.dy??0),anchor:s.anchor??"middle",fontSize:g.annotationFontSize,fill:s.color??g.annotationColor,rotate:s.rotate});break}}if(s.id&&a.length>0){let l=it(s.id);o.push({type:"group",cssClass:`annotation annotation--${l}`,commands:a});}else o.push(...a);}return o}var U=12,ft=8,Bt=20,Ae=11,Ft=18,jt=i=>i.length*Ae*.6;function te(i,t="vertical"){if(t==="horizontal"){let n=0;for(let o of i)n+=U+ft+jt(o.name)+Ft;return {width:Math.max(0,n-Ft),height:Bt}}let e=0;for(let n of i)e=Math.max(e,jt(n.name));return {width:U+ft+e,height:i.length*Bt}}function ee(i){let{items:t,x:e,y:n,orientation:o="vertical"}=i,r=[],s=e;return t.forEach((a,h)=>{let l=o==="horizontal"?s:e,d=o==="horizontal"?n:n+h*Bt;r.push({type:"rect",x:l,y:d,w:U,h:U,fill:a.color,stroke:g.legendStroke,strokeWidth:1},{type:"text",content:a.name,x:l+U+ft,y:d+U-2,fontSize:g.legendFont,fill:g.legendText}),o==="horizontal"&&(s+=U+ft+jt(a.name)+Ft);}),{type:"group",cssClass:"chart-legend",commands:r}}function ne(i){let{xTicks:t,yTicks:e,xRange:n,yRange:o,stroke:r=g.gridStroke,strokeWidth:s=g.gridStrokeWidth,dashed:a=false,opacity:h=g.gridOpacity}=i,l=[];if(e)for(let d of e)l.push({type:"line",x1:n[0],y1:d,x2:n[1],y2:d,stroke:r,strokeWidth:s,dashed:a,opacity:h});if(t)for(let d of t)l.push({type:"line",x1:d,y1:o[0],x2:d,y2:o[1],stroke:r,strokeWidth:s,dashed:a,opacity:h});return l}function ie(i,t,e){let n=i??t;if(n==="series")return null;if(n==="chartTop")return e.chartTop;if(n==="chartBottom")return e.chartBottom;if(typeof n=="object"&&"threshold"in n){let o=e.thresholds.get(n.threshold);if(!o)throw new Error(`fillSpec region references unknown threshold '${n.threshold}'`);return e.valueScale.map(o.value)}return typeof n=="object"&&"value"in n?e.valueScale.map(n.value):null}function Me(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function re(i,t,e){let n=ie(i.from,"chartBottom",t),o=ie(i.to,"series",t),{color:r,hatch:s}=Me(i.fill),a={type:"path",fill:r,hatch:s,stroke:"none",...t.idPrefix&&{id:`${t.idPrefix}-fill-r${e}`}};if(n!==null&&o!==null){let m=t.timeScale.range(),c=m[0],f=m[1],y=Math.min(n,o),b=Math.max(n,o);return [{...a,points:[{x:c,y},{x:f,y},{x:f,y:b},{x:c,y:b}]}]}let h=n??o,l=[],d=Le(i,t);if(d===null){let m=t.valueScale.domain();d=(n??o)===t.chartBottom?m[0]:m[1];}let u=oe(i.outer,t);for(let m of t.runs){if(m.length<2)continue;let c=R.splitByThreshold(m,d,y=>y.value??d,R.interpolateDataPoint),f=i.side==="above"?c.above:i.side==="below"?c.below:[...c.above,...c.below];if(u!==null&&i.side){let y=i.side==="above"?"below":"above";f=f.flatMap(b=>{if(b.length<2)return [];let _=R.splitByThreshold(b,u,C=>C.value??u,R.interpolateDataPoint);return y==="above"?_.above:_.below});}for(let y of f){if(y.length<2)continue;let b=y.map(C=>({x:t.timeScale.map(C.time),y:t.valueScale.map(C.value)})),_=[...b].reverse().map(C=>({x:C.x,y:h}));l.push({...a,smoothing:t.smoothing,smoothCount:b.length,points:[...b,..._]});}}return l}function Le(i,t){let e=i.from==="series"?i.to:i.from;return oe(e,t)}function oe(i,t){return i===void 0||i==="series"||i==="chartTop"||i==="chartBottom"?null:typeof i=="object"&&"threshold"in i?t.thresholds.get(i.threshold)?.value??null:typeof i=="object"&&"value"in i?i.value:null}function se(i,t){if(typeof i=="string"||!("regions"in i))return re({fill:i},t,0);let e=[];return i.regions.forEach((n,o)=>{e.push(...re(n,t,o));}),e}function ae(i,t){let e=new Array(i.length),n=0;for(let o=0;o<i.length;o++){let r=i[o].time,s=r-t;for(;n<o&&i[n].time<s;)n++;let a=0,h=0;for(let l=n;l<=o;l++){let d=i[l].value;d!==null&&(a+=d,h++);}e[o]={time:r,value:h===0?null:a/h,synthetic:true};}return e}function he(i){let t=i.style?.line,e=t&&!Array.isArray(t)?t:void 0;return {color:e?.color??g.stroke,width:e?.width??g.strokeWidth,dash:e?.style,smoothing:e?.smoothing??false}}function le(i,t,e,n){let o=i.filter(h=>h.value!==null);if(o.length<2)return [];let r=o.map(h=>({x:t.timeScale.map(h.time),y:t.valueScale.map(h.value)})),s=he(e);return [{type:"path",id:t.idPrefix?`${t.idPrefix}-overlay-${n}`:`overlay-${n}`,points:r,stroke:s.color,strokeWidth:s.width,smoothing:s.smoothing,dash:s.dash,fill:"none"}]}function de(i,t){switch(i.kind){case "movingAverage":{i.type;let e=ae(t.data,i.window);return le(e,t,i,"movingAvg")}case "movingMkt":{let e=Nt(t.data,i.window,i.activationEnergy);return le(e,t,i,"movingMkt")}case "limits":{let e=[],n=t.timeScale.range(),o=n[0],r=n[1],s=he(i),a=s.color,h=s.width,l=s.dash??"dashed",d=t.idPrefix?`${t.idPrefix}-`:"";return i.high!==void 0&&e.push({type:"line",id:`${d}overlay-limit-high`,x1:o,y1:t.valueScale.map(i.high),x2:r,y2:t.valueScale.map(i.high),stroke:a,strokeWidth:h,dash:l}),i.low!==void 0&&e.push({type:"line",id:`${d}overlay-limit-low`,x1:o,y1:t.valueScale.map(i.low),x2:r,y2:t.valueScale.map(i.low),stroke:a,strokeWidth:h,dash:l}),e}case "stdDevBand":{let e=i.multiplier??1,n=ae(t.data,i.window),o=Yt(t.data,i.window),r=[],s=[];for(let y=0;y<n.length;y++){let b=n[y].value,_=o[y].value;if(b===null||_===null)continue;let C=t.timeScale.map(n[y].time);r.push({x:C,y:t.valueScale.map(b+e*_)}),s.push({x:C,y:t.valueScale.map(b-e*_)});}if(r.length<2)return [];let a=t.idPrefix?`${t.idPrefix}-`:"",h=[],d=(typeof i.style?.fill=="string"||i.style?.fill&&!("regions"in i.style.fill)?i.style.fill:void 0)??"#94a3b833",{color:u,hatch:m}=De(d);h.push({type:"path",id:`${a}overlay-stdDevBand`,points:[...r,...[...s].reverse()],fill:u,hatch:m,stroke:"none"});let c=i.style?.line,f=c&&!Array.isArray(c)?c:void 0;if(f){let y=n.filter(b=>b.value!==null).map(b=>({x:t.timeScale.map(b.time),y:t.valueScale.map(b.value)}));y.length>=2&&h.push({type:"path",id:`${a}overlay-stdDevBand-mean`,points:y,stroke:f.color??g.stroke,strokeWidth:f.width??1.5,smoothing:f.smoothing,dash:f.style,fill:"none"});}return h}}}function De(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function Pe(i){if(!i)return {gaps:[],autoDetect:false,minGapMs:6e4};if(Array.isArray(i))return {gaps:i,autoDetect:false,minGapMs:6e4};let t=i.regions??[],e=i.style;return {gaps:t.map(o=>{let r={...e,...o.style},s=r.fill,a,h;return typeof s=="string"?a=s:s&&(a=s.color,h=s.hatch),{startTime:o.startTime,endTime:o.endTime,label:o.label,fill:a,hatch:h,fillOpacity:r.opacity,labelBaseline:r.label?.baseline,rotate:r.label?.rotate,style:r.display==="filled"||r.display==="bridge_line"?void 0:r.display}}),autoDetect:i.autoDetect??false,minGapMs:i.minGapMs??6e4}}function gt(i){return "showAs"in i&&!!i.showAs}var K=class{_layout;_renderer;_locale;_legend;_markers;_thresholds;_highlights;_gaps;_gapsAutoDetect;_gapsMinGapMs;_annotations;_annotationBands;_disabledAnnotations=new Set;_annotationSeq=0;_axes;_series;readonly_annotationBandHeight=0;_timeScale;_valueScales=new Map;constructor(t={}){this._layout=new nt({width:t.width??800,height:t.height??400,margin:t.margin??{top:20,right:20,bottom:40,left:60}}).compute(),this._renderer=t.renderer,this._locale=t.locale,this._legend=t.legend,this._markers=t.markers??[],this._thresholds=t.thresholds??[],this._highlights=t.highlights??[];let e=Pe(t.gaps);this._gaps=e.gaps,this._gapsAutoDetect=e.autoDetect,this._gapsMinGapMs=e.minGapMs,this._annotations=t.annotations??[],this._annotationBands=t.annotationBands??[],this._axes=t.axes,this._series=[],t.series&&this.setData(t.series);}getWidth(){return this._layout.totalWidth}getHeight(){return this._layout.totalHeight+this._annotationBandTotalHeight()}get series(){return this._series}_annotationBandTotalHeight(){let t=0;for(let e of this._annotationBands){let n=e.height??12,o=e.spacing??0;(e.showAxis??false)&&(t+=26+o),t+=n+o;}return t}setData(t){this._series=t.filter(e=>Array.isArray(e.data));}addAnnotation(t){let e=t.id??`anno-${++this._annotationSeq}`;return this._annotations.push({...t,id:e}),e}removeAnnotation(t){let e=this._annotations.length;return this._annotations=this._annotations.filter(n=>n.id!==t),this._disabledAnnotations.delete(t),this._annotations.length<e}setAnnotations(t){this._annotations=[...t],this._disabledAnnotations.clear();}clearAnnotations(){this._annotations=[],this._disabledAnnotations.clear();}getAnnotations(){return this._annotations}disableAnnotation(t){this._disabledAnnotations.add(t);}enableAnnotation(t){this._disabledAnnotations.delete(t);}_axisIndexOf(t){return t.yAxisIndex??0}_timesOf(t){return t.data.map(e=>e.time)}_valuesOf(t){if(gt(t)){let e=[];for(let n of t.data)n.min!==null&&e.push(n.min),n.max!==null&&e.push(n.max);return e}return t.data.map(e=>e.value).filter(e=>e!==null)}renderCommands(){if(this._series.length===0)return [];let t=this._legendItems(),e=(this._legend?.show??false)&&t.length>0,n=this._legend?.position??"inside-right",o=this._legend?.orientation??"vertical",r=e?te(t,o):{width:0},s=this._layout;if(e&&(n==="outside-right"||n==="outside-left")){let p=r.width+16,x={...this._layout.margin};n==="outside-right"?x.right+=p:x.left+=p,s=new nt({width:this._layout.totalWidth,height:this._layout.totalHeight,margin:x}).compute();}let{chartX:a,chartY:h,chartWidth:l,chartHeight:d}=s,u=[a,a+l],m=[h,h+d],c=[];for(let p of this._series)p.data.sort((x,w)=>x.time-w.time);let f=new Map,y=1/0,b=-1/0,_=false;for(let p of this._series){let x=this._axisIndexOf(p),w=f.get(x);w?w.push(p):f.set(x,[p]);for(let A of this._timesOf(p))A<y&&(y=A),A>b&&(b=A),_=true;}if(!_)return [];let C=this._axes?.x?.domain,N=C&&C!=="auto"?C:[y,b];this._timeScale=new J({domain:N,range:u,locale:this._locale});let P=p=>({axisColor:p?.color??g.axisColor,tickColor:p?.color??g.tickColor,textColor:g.textColor,textSize:g.textSize,axisWidth:p?.width??1}),L=new tt({domain:N,xRange:u,y:h+d,locale:this._locale,format:this._axes?.x?.format,maxTicks:this._axes?.x?.ticks?.major,colors:P(this._axes?.x?.axis)});this._valueScales.clear();let W=Array.from(f.keys()).sort((p,x)=>p-x),B,G=0,I=0;for(let p of W){let x=f.get(p),w=1/0,A=-1/0,M=false;for(let V of x)for(let lt of this._valuesOf(V))lt<w&&(w=lt),lt>A&&(A=lt),M=true;if(!M)continue;let D;this._axes?.y&&this._axes.y.length>p?D=this._axes.y[p]:p===0?D=this._axes?.left:p===1&&(D=this._axes?.right);let Tt=D?.domain,Z=Tt&&Tt!=="auto"?Tt:[w,A],Ht=new X({domain:Z,range:[h+d,h]});this._valueScales.set(p,Ht);let Rt=this._thresholds.filter(V=>(V.axisIndex??0)===p&&V.label!==false&&V.value>=Math.min(Z[0],Z[1])&&V.value<=Math.max(Z[0],Z[1])).map(V=>Ht.map(V.value)),$t=D?.position??(p===0?"left":"right"),At;if($t==="right"){let V=D?.offset!==void 0?D.offset:I*50;At=a+l+V,I++;}else {let V=D?.offset!==void 0?D.offset:G*50;At=a-V,G++;}let Wt=new dt({domain:Z,range:[h+d,h],x:At,position:$t,format:D?.format,ticks:D?.ticks?.major,colors:P(D?.axis),suppressLabelsNear:Rt.length?Rt:void 0});p===0&&(B=Wt),c.push({type:"group",cssClass:`value-axis ${$t}`,commands:Wt.render()});}let S=this._valueScales.get(0)??this._valueScales.get(W[0]);c.push({type:"group",cssClass:"time-axis",commands:L.render()});let v=null,k=this._axes?.x?.grid?.major,$=this._axes?.left?.grid?.major;if(k!==void 0||$!==void 0){let p=k!==false,x=$!==false&&!!B,w=p?L.generateTicks().map(M=>M.x):void 0,A=x?B.generateTicks().map(M=>M.position):void 0;if(w||A){let M=(k&&typeof k=="object"?k:void 0)??($&&typeof $=="object"?$:void 0);v={type:"group",cssClass:"chart-grid",commands:ne({xTicks:w,yTicks:A,xRange:u,yRange:m,stroke:M?.color,opacity:M?.opacity,dashed:M?.style==="dashed"})};}}if(this._highlights.length>0&&c.push({type:"group",cssClass:"highlights",commands:Zt({highlights:this._highlights,timeScale:this._timeScale,yRange:m,height:s.totalHeight})}),this._thresholds.length>0&&S){let p=[],x=[];for(let w of this._thresholds){let A=w.id??it(w.name),M=this._valueScales.get(w.axisIndex??0)??S,D=Ut({thresholds:[w],valueScale:M,xRange:u});D.inside.length&&p.push({type:"group",cssClass:`threshold threshold--${A}`,id:`threshold-${A}`,commands:D.inside}),D.labels.length&&x.push({type:"group",cssClass:`threshold-label threshold-label--${A}`,commands:D.labels});}p.length&&c.push({type:"group",cssClass:"thresholds",commands:p,clipRect:{x:a,y:h,w:l,h:d}}),x.length&&c.push({type:"group",cssClass:"threshold-labels",commands:x});}let j=this._gaps;if(this._gapsAutoDetect){let p=[];for(let x of this._series)gt(x)||p.push(...Vt(x.data,this._gapsMinGapMs));p.length>0&&(j=[...this._gaps,...p]);}j.length>0&&c.push({type:"group",cssClass:"gaps",commands:Kt({gaps:j,timeScale:this._timeScale,yRange:m})});let H=new Map(this._thresholds.map(p=>[p.id??p.name,p]));for(let p of this._series){if(p.data.length===0)continue;let x=this._valueScales.get(this._axisIndexOf(p));if(!x)continue;let w=it(p.id??p.name);c.push({type:"group",cssClass:`series series--${w}`,id:`series-${w}`,commands:this._renderSeries(p,x,H)});}v&&c.push(v);let Y=this._markers.map(p=>({...p}));for(let p of Y)if(p.value===void 0&&(p.lineStyle==="to-value"||p.lineStyle==="to-top")){let x=this._series[p.seriesIndex??0];x&&!gt(x)&&x.data.length>=2&&(p.value=this._interpolateValue(p.time,x.data));}Y.length>0&&S&&c.push({type:"group",cssClass:"markers",commands:Jt({markers:Y,timeScale:this._timeScale,valueScale:S,yRange:m})});let F=this._annotations.filter(p=>!p.id||!this._disabledAnnotations.has(p.id));if(F.length>0&&c.push({type:"group",cssClass:"annotations",commands:Qt({annotations:F,timeScale:this._timeScale,valueScales:this._valueScales})}),this._annotationBands.length>0){let p=h+d+this._layout.margin.bottom,x=0;this._annotationBands.forEach(w=>{let A=w.height??12,M=w.spacing??0,D=p+x;(w.showAxis??false)&&(x+=26+M),x+=A+M,c.push({type:"group",cssClass:"annotation-band",commands:new pt({name:w.name,showAxis:w.showAxis??false,items:w.items,timeScale:this._timeScale,background:w.background,hatch:w.hatch},[a,a+l],D,A).render()});});}if(e&&n!=="separate"){let p,x;n==="inside-right"?(p=a+l-r.width-8,x=h+8):n==="inside-left"?(p=a+8,x=h+8):n==="outside-right"?(p=a+l+16,x=h):(p=8,x=h),c.push(ee({items:t,x:p,y:x,orientation:o}));}let T=this._axes?.left?.label,O=this._axes?.right?.label,E=this._axes?.x?.label;if(T||O||E){let p=[],x=h+d/2,w=this._axes?.left?.labels,A=this._axes?.right?.labels,M=this._axes?.x?.labels;T&&p.push({type:"text",content:T,x:14,y:x,anchor:"middle",fontSize:w?.fontSize??g.axisLabelSize,fill:w?.color??g.axisLabelColor,rotate:-90}),O&&p.push({type:"text",content:O,x:s.totalWidth-14,y:x,anchor:"middle",fontSize:A?.fontSize??g.axisLabelSize,fill:A?.color??g.axisLabelColor,rotate:90}),E&&p.push({type:"text",content:E,x:a+l/2,y:s.totalHeight-6,anchor:"middle",fontSize:M?.fontSize??g.axisLabelSize,fill:M?.color??g.axisLabelColor}),p.length&&c.push({type:"group",cssClass:"axis-labels",commands:p});}return c}_renderSeries(t,e,n){let o=this._timeScale,r={timeScale:o,valueScale:e};if(gt(t)){let S=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,v=typeof t.style?.fill=="string"?t.style.fill:void 0;return t.showAs==="minmaxavg"?new ut({data:t.data,timeScale:o,valueScale:e,minColor:t.minColor,maxColor:t.maxColor,avgColor:t.avgColor,avgDashed:t.avgDashed,fillToMax:t.fillToMax,fillToMaxHatch:t.fillToMaxHatch,fillToMin:t.fillToMin,fillToMinHatch:t.fillToMinHatch,smoothing:S?.smoothing,strokeWidth:S?.width,id:rt(t.name,t.id)}).render():new ct({data:t.data,timeScale:o,valueScale:e,fill:v??S?.color,avgLine:t.avgLine,countOpacity:t.countOpacity,id:rt(t.name,t.id)}).render()}let s=t,a=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,h=a?.gapThreshold??g.gapThreshold,l=R.getRuns(t.data,S=>S.value===null,h),d=l.reduce((S,v)=>S+v.length,0);if(d===0)return [];let u=[],m=t.style?.markers,c=t.style?.shadow,f={stroke:a?.color??g.stroke,strokeWidth:a?.width??g.strokeWidth,smoothing:a?.smoothing,dashed:a?.style==="dashed",pointStyle:m?.type,pointSize:m?.size,pointStroke:m?.stroke,pointFill:m?.fill,pointStrokeWidth:m?.strokeWidth,shadowColor:c?.color,shadowBlur:c?.blur,shadowOffsetX:c?.offsetX,shadowOffsetY:c?.offsetY,id:rt(t.name,t.id)},y=t.style?.line,b=y&&!Array.isArray(y)?y:void 0,_=b?.color,C=b?.width,N=b?.style,P=b?.smoothing,L=t.style?.fill;if(L!==void 0){let S=e.range(),v=Math.min(S[0],S[1]),k=Math.max(S[0],S[1]);u.push(...se(L,{runs:l,timeScale:o,valueScale:e,thresholds:n,chartTop:v,chartBottom:k,smoothing:a?.smoothing,idPrefix:t.id}));}let W=s.colorByThresholds??[],B=W.map(S=>n.get(S)).filter(S=>!!S).map(S=>S.value).sort((S,v)=>S-v),G=(S,v,k)=>{let $=k??f.stroke;for(let j of v){let H=n.get(j);H&&S>=H.value&&($=H.color??$);}return $};for(let S of l){if(S.length<2)continue;let v=R.splitByBoundaries(S,B,k=>k.value,R.interpolateDataPoint);for(let k=0;k<v.length;k++){let $=v[k];if($.data.length<2)continue;let j=($.data[0].value+$.data[$.data.length-1].value)/2,H=rt(s.name,s.id),Y=$.data.map(p=>({x:o.map(p.time),y:e.map(p.value)})),F=H?`${H}-line-${k}`:void 0,O=(b?.shape??a?.shape??s.seriesType)==="step",E=O?qt(Y):Y;y===false||(y&&Array.isArray(y)?y.forEach((p,x)=>{u.push({type:"path",id:F?`${F}-${x}`:void 0,points:E,stroke:G(j,W,p.color),strokeWidth:p.width??f.strokeWidth,smoothing:O?false:p.smoothing??f.smoothing,dash:p.style,opacity:p.opacity,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY});}):u.push({type:"path",id:F,points:E,stroke:G(j,W,_),strokeWidth:C??f.strokeWidth,smoothing:O?false:P??f.smoothing,dash:N,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY}));}f.pointStyle&&f.pointStyle!=="none"&&d<=(m?.threshold??g.pointThreshold)&&u.push(...Xt(S,r,f,k=>G(k.value,W)));}let I=t.overlays;if(I&&I.length>0){let S=e.range(),v={data:t.data,timeScale:o,valueScale:e,chartTop:Math.min(S[0],S[1]),chartBottom:Math.max(S[0],S[1]),idPrefix:t.id};for(let k of I)u.push(...de(k,v));}if(t.style?.gap&&l.length>1){let S=e.range(),v=Math.min(S[0],S[1]),k=Math.max(S[0],S[1]),$=t.style.gap,j=$.fill,H,Y;typeof j=="string"?H=j:j&&(H=j.color,Y=j.hatch);let F=$.opacity??.15,T=$.bridge;for(let O=1;O<l.length;O++){let E=l[O-1][l[O-1].length-1],p=l[O][0],x=o.map(E.time),w=o.map(p.time);if($.display==="bridge_line"){if(E.value===null||p.value===null)continue;let A=e.map(E.value),M=e.map(p.value);u.push({type:"line",x1:x,y1:A,x2:w,y2:M,stroke:T?.color??(typeof t.style?.line=="object"&&!Array.isArray(t.style.line)?t.style.line.color:void 0)??g.stroke,strokeWidth:T?.width??1.5,dash:T?.style??"dotted"});}else H!==void 0?u.push({type:"rect",x,y:v,w:w-x,h:k-v,fill:H,hatch:Y,opacity:F,stroke:"none"}):$.display!=="empty"&&u.push({type:"rect",x,y:v,w:w-x,h:k-v,stroke:g.gapStroke,strokeWidth:1,dashed:true,fill:"none"});}}return u}_interpolateValue(t,e){for(let n=1;n<e.length;n++){let o=e[n-1],r=e[n];if(!(o.value===null||r.value===null)&&t>=o.time&&t<=r.time){let s=(t-o.time)/(r.time-o.time);return o.value+s*(r.value-o.value)}}}legendItems(){return this._legendItems()}_legendItems(){return this._series.map(t=>{let e=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0;return {name:t.name,color:e?.color??g.stroke}})}get renderer(){return this._renderer}get layout(){return this._layout}get timeScale(){return this._timeScale}get valueScales(){return this._valueScales}invertTime(t){return this._timeScale?this._timeScale.invert(t):0}invertValue(t,e=0){let n=this._valueScales.get(e);return n?n.invert(t):0}project(t,e,n=0){let o=this._timeScale?this._timeScale.map(t):0,r=this._valueScales.get(n);return {x:o,y:r?r.map(e):0}}};var yt=class{};function Be(i){switch(i){case "top":return "text-top";case "bottom":return "text-bottom";default:return "middle"}}var q=class extends yt{#t="100%";#e="100%";#n;#i=new Map;#r=new Map;#o=new Map;constructor(t){super(),t?.width!==void 0&&(this.#t=t.width),t?.height!==void 0&&(this.#e=t.height),t?.background!==void 0&&(this.#n=t.background);}setBackgroundColor(t){this.#n=t;}render(t){this.#i.clear(),this.#r.clear(),this.#o.clear();let e=t.map(l=>this._toSVG(l));this.#n&&e.unshift(`<rect width="100%" height="100%" fill="${this._esc(this.#n)}" />`);let n=e.join(`
25
- `),o="",r=[];for(let[,l]of this.#i)r.push(l);for(let[,l]of this.#r)r.push(l);for(let[,l]of this.#o)r.push(l);r.length>0&&(o=` <defs>
26
- ${r.join(`
24
+ `.trim()}function Pt(i,t=2,e=false){return i==="dashed"||!i&&e?{strokeDasharray:"4,4"}:i==="dotted"?{strokeDasharray:"2,4"}:!i||i==="solid"?null:Vt(i,t)}function Vt(i,t=2){let e=t;switch(i){case "dotted":return {strokeDasharray:`0, ${e*2}`,strokeLinecap:"round"};case "sparse-dots":return {strokeDasharray:`0, ${e*4}`,strokeLinecap:"round"};case "dashed":return {strokeDasharray:`${e*3}, ${e*2}`,strokeLinecap:"butt"};case "long-dash":return {strokeDasharray:`${e*6}, ${e*3}`,strokeLinecap:"butt"};case "dense-dash":return {strokeDasharray:`${e*1.5}, ${e*1.5}`,strokeLinecap:"butt"};case "dash-dot":return {strokeDasharray:`${e*4}, ${e*2}, 0, ${e*2}`,strokeLinecap:"round"};case "dash-dot-dot":return {strokeDasharray:`${e*5}, ${e*2}, 0, ${e*2}, 0, ${e*2}`,strokeLinecap:"round"};case "loose-dash":return {strokeDasharray:`${e*3}, ${e*4}`,strokeLinecap:"butt"};default:return {strokeDasharray:"none",strokeLinecap:"butt"}}}var g=new Proxy({},{get:(i,t)=>Q()[t],has:(i,t)=>t in Q(),ownKeys:()=>Reflect.ownKeys(Q()),getOwnPropertyDescriptor:(i,t)=>Reflect.getOwnPropertyDescriptor(Q(),t)});var ot={axisColor:g.axisColor,tickColor:g.tickColor,textColor:g.textColor,textSize:g.textSize},tt=class{#t;#e;constructor(t){this.#t=new J({domain:t.domain,range:t.xRange,locale:t.locale}),this.#e=t;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??ot).axisColor}get tickColor(){return (this.#e.colors??ot).tickColor}get textColor(){return (this.#e.colors??ot).textColor}get textSize(){return (this.#e.colors??ot).textSize}generateTicks(){let t=this.#e.minTicks??5,e=this.#e.maxTicks??12,r=this.#t.ticks({minTicks:t,maxTicks:e}).map(o=>({time:o,x:this.#t.map(o),label:this.tickLabel(o)}));return this.antiOverlap(r)}tickLabel(t){if(this.#e.format)return this.#e.format(new Date(t));let e=this.#e.minTicks??5,n=this.#e.maxTicks??12,{interval:r}=this.#t.tickInterval((e+n)/2,e,n),o={};return r<6e4?(o.hour="2-digit",o.minute="2-digit",o.second="2-digit"):r<36e5||r<864e5?(o.hour="2-digit",o.minute="2-digit"):r<31536e6?(o.day="numeric",o.month="short",r>=2592e6&&(o.day=void 0,o.month="long")):(o.year="numeric",r<2*31536e6&&(o.month="short")),this.#t.format(t,o)}antiOverlap(t){if(t.length<=1)return t;let e=60,n=[t[0]];for(let r=1;r<t.length;r++){let o=n[n.length-1].x;Math.abs(t[r].x-o)>=e&&n.push(t[r]);}return n}render(){let t=this.generateTicks(),e=this.#e.colors??ot,n=this.#e.y??0,r=[],[o,a]=this.#t.range();r.push({type:"line",x1:o,y1:n,x2:a,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let s of t)r.push({type:"line",x1:s.x,y1:n,x2:s.x,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),r.push({type:"text",content:s.label,x:s.x,y:n+e.textSize+6,anchor:"middle",fontSize:e.textSize,fill:e.textColor});return r}};var st={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function we(i){return Math.abs(i)>=1e6?`${(i/1e6).toFixed(1)}M`:Math.abs(i)>=1e3?`${(i/1e3).toFixed(1)}k`:Number.isInteger(i)?String(i):i.toFixed(1)}function ve(i){let t=new Array(i.length).fill(false),e=0;for(;e<i.length;){let n=e;for(;n+1<i.length&&i[n+1].label===i[e].label;)n++;for(let r=e+1;r<n;r++)t[r]=true;e=n+1;}return t}var dt=class{#t;#e;constructor(t){this.#t=new X({domain:t.domain,range:t.range}),this.#e=t;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??st).axisColor}get tickColor(){return (this.#e.colors??st).tickColor}get textColor(){return (this.#e.colors??st).textColor}get textSize(){return (this.#e.colors??st).textSize}generateTicks(){let t=this.#e.format??we,e=6,[n,r]=this.#t.domain(),o=r-n;if(o===0)return [{value:n,position:this.#t.map(n),label:t(n)}];let a=o/e,s=Math.pow(10,Math.floor(Math.log10(a))),l=a/s,h;l<=1.5?h=s:l<=3?h=2*s:l<=7?h=5*s:h=10*s;let d=[],u=Math.ceil(n/h)*h;for(let m=u;m<=r;m+=h)d.push({value:m,position:this.#t.map(m),label:t(m)});return d}render(){let t=this.generateTicks(),e=this.#e.colors??st,n=this.#e.x??0,r=this.#e.orientation??"vertical",o=this.#e.position??"left",a=this.#e.suppressLabelsNear??[],s=this.#e.suppressTolerancePx??8,l=d=>a.some(u=>Math.abs(u-d)<=s),h=[];if(r==="vertical"){let[d,u]=this.#t.range();h.push({type:"line",x1:n,y1:d,x2:n,y2:u,stroke:e.axisColor,strokeWidth:e.axisWidth});let m=ve(t);t.forEach((c,f)=>{let y=l(c.position),b=m[f]?{opacity:0}:{};o==="left"?(h.push({type:"line",x1:n-4,y1:c.position,x2:n,y2:c.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||h.push({type:"text",content:c.label,x:n-8,y:c.position+4,anchor:"end",fontSize:11,fill:e.textColor,...b})):(h.push({type:"line",x1:n,y1:c.position,x2:n+4,y2:c.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||h.push({type:"text",content:c.label,x:n+8,y:c.position+4,anchor:"start",fontSize:11,fill:e.textColor,...b}));});}else {let[d,u]=this.#t.range();h.push({type:"line",x1:d,y1:n,x2:u,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let m of t)h.push({type:"line",x1:m.position,y1:n,x2:m.position,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),h.push({type:"text",content:m.label,x:m.position,y:n+18,anchor:"middle",fontSize:e.textSize,fill:e.textColor});}return h}};var H=class{static interpolateDataPoint(i,t,e){return {time:i.time+Math.round(e*(t.time-i.time)),value:(i.value??0)+e*((t.value??0)-(i.value??0))}}static interpolateAggregatedPoint(i,t,e){let n=(r,o)=>r!==null&&o!==null?r+e*(o-r):null;return {time:i.time+e*(t.time-i.time),min:n(i.min,t.min),max:n(i.max,t.max),avg:n(i.avg,t.avg),count:Math.round(i.count+e*(t.count-i.count))}}static getRuns(i,t,e=0){let n=[...i].sort((s,l)=>s.time-l.time),r=[],o=[],a=null;for(let s of n){let l=t(s),h=e>0&&a&&s.time-a.time>e;(l||h)&&o.length&&(r.push(o),o=[]),l||o.push(s),a=s;}return o.length&&r.push(o),r}static splitByBoundaries(i,t,e,n){if(i.length===0)return [];if(t.length===0)return [{data:i,zoneIndex:0}];let r=[...t].sort((l,h)=>l-h),o=[],a=l=>{let h=0;for(let d=0;d<r.length&&l>=r[d];d++)h=d+1;return h},s=[i[0]];for(let l=1;l<i.length;l++){let h=i[l-1],d=i[l],u=e(h),m=e(d),c;m>u?c=r.filter(f=>f>u&&f<=m):m<u?c=r.filter(f=>f>=m&&f<u).reverse():c=[];for(let f of c){let y=(f-u)/(m-u),b=n(h,d,y);s.push(b),o.push({data:s,zoneIndex:a((u+f)/2)}),s=[b];}s.push(d);}if(s.length>0){let l=e(s[0]),h=e(s[s.length-1]);o.push({data:s,zoneIndex:a((l+h)/2)});}return o}static splitByThreshold(i,t,e,n){let r=this.splitByBoundaries(i,[t],e,n),o={above:[],below:[]};for(let a of r)a.zoneIndex===0?o.below.push(a.data):o.above.push(a.data);return o}};function Nt(i,t=6e4){if(i.length<2)return [];let e=[...i].sort((r,o)=>r.time-o.time),n=[];for(let r=1;r<e.length;r++)e[r].time-e[r-1].time>t&&n.push({startTime:e[r-1].time,endTime:e[r].time});return n}function ke(i,t=83144){let e=t/8.314,n=0,r=0;for(let a of i)a!==null&&(n+=Math.exp(-e/(a+273.15)),r++);if(r===0)return null;let o=n/r;return e/-Math.log(o)-273.15}function Yt(i,t,e=83144){let n=new Array(i.length),r=0;for(let o=0;o<i.length;o++){let a=i[o].time,s=a-t;for(;r<o&&i[r].time<s;)r++;let l=i.slice(r,o+1).map(d=>d.value),h=ke(l,e);n[o]={time:a,value:h,synthetic:true};}return n}function Ce(i){let t=0,e=0;for(let o of i)o!==null&&(t+=o,e++);if(e===0)return null;let n=t/e,r=0;for(let o of i){if(o===null)continue;let a=o-n;r+=a*a;}return Math.sqrt(r/e)}function Te(i){let t=0,e=0;for(let o of i)o!==null&&(t+=o,e++);if(e<2)return null;let n=t/e,r=0;for(let o of i){if(o===null)continue;let a=o-n;r+=a*a;}return Math.sqrt(r/(e-1))}function zt(i,t,e=false){let n=new Array(i.length),r=0,o=e?Te:Ce;for(let a=0;a<i.length;a++){let s=i[a].time,l=s-t;for(;r<a&&i[r].time<l;)r++;let h=i.slice(r,a+1).map(u=>u.value),d=o(h);n[a]={time:s,value:d,synthetic:true};}return n}function qt(i){return {id:i.id,line:{stroke:i.stroke??g.stroke,strokeWidth:i.strokeWidth??g.strokeWidth,smoothing:i.smoothing??false,dashed:i.dashed??false},fill:i.fill??g.areaFillAlpha,markers:{type:i.pointStyle??"none",size:i.pointSize??g.pointSize,stroke:i.stroke??g.stroke,fill:"#ffffff"},shadow:{color:i.shadowColor??"transparent",blur:i.shadowBlur??0,offsetX:i.shadowOffsetX??0,offsetY:i.shadowOffsetY??0}}}function mt(i,t,e){let n=[],r=i.reduce((a,s)=>a+s.data.length,0),o=qt(e);for(let a=0;a<i.length;a++){let s=i[a];s.data.length>=2?n.push({type:"path",id:e.id?`${e.id}-line-${a}`:void 0,points:s.data.map(l=>({x:t.timeScale.map(l.time),y:t.valueScale.map(l.value)})),stroke:s.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:o.line.smoothing,dashed:o.line.dashed,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur,shadowOffsetX:o.shadow.offsetX,shadowOffsetY:o.shadow.offsetY,fill:"none"}):s.data.length===1&&r===1&&n.push({type:"circle",cx:t.timeScale.map(s.data[0].time),cy:t.valueScale.map(s.data[0].value),r:Math.max(o.markers.size,o.line.strokeWidth),fill:s.color??o.line.stroke,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur});}return n}function Xt(i){let t=[];for(let e of i)t.length===0?t.push(e):t.push({x:e.x,y:t[t.length-1].y},e);return t}function Bt(i,t,e,n){if(i.length<2)return [];let r=H.splitByBoundaries(i,e.boundaries,e.getValue,e.interpolate),o=[];for(let a=0;a<r.length;a++){let s=r[a];if(s.data.length<2)continue;let l=e.getColor(s.zoneIndex);if(!l)continue;let h=s.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yLow(u))})),d=s.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yHigh(u))})).reverse();o.push({type:"path",id:n?.id?`${n.id}-fill-${a}`:void 0,points:[...h,...d],fill:l,hatch:e.getHatch?.(s.zoneIndex),stroke:"none"});}return o}function Ut(i,t,e,n){let r=qt(e);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let a=0;a<i.length;a++){let s=i[a],l=t.timeScale.map(s.time),h=t.valueScale.map(s.value),d=n(s),u=e.pointStroke??d,m=e.pointFill??d,c=e.pointStrokeWidth??1.5,f=e.id?`${e.id}-marker-${a}`:void 0;ut(o,f,r.markers.type,l,h,r.markers.size,u,m,c);}return o}function ut(i,t,e,n,r,o,a,s,l){switch(e){case "circle":i.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:a,strokeWidth:l,id:t});break;case "square":i.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:s,stroke:a,strokeWidth:l,id:t});break;case "cross":i.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:a,strokeWidth:l,id:t},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:a,strokeWidth:l,id:t});break;case "diamond":i.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r},{x:n,y:r+o},{x:n-o,y:r}],fill:s,stroke:a,strokeWidth:l,id:t});break;case "triangle":i.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r+o},{x:n-o,y:r+o}],fill:s,stroke:a,strokeWidth:l,id:t});break;case "star":{let h=[];for(let d=0;d<10;d++){let u=d%2===0?o:o*.5,m=Math.PI/2*3+d*Math.PI/5;h.push({x:n+u*Math.cos(m),y:r+u*Math.sin(m)});}i.push({type:"path",points:h,fill:s,stroke:a,strokeWidth:l,id:t});break}case "arrow":i.push({type:"path",points:[{x:n-o,y:r+o},{x:n,y:r-o},{x:n+o,y:r+o}],stroke:a,strokeWidth:l,fill:"none",id:t});break;case "plus":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:a,strokeWidth:l,id:t},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:a,strokeWidth:l,id:t});break;case "triangle-down":i.push({type:"path",points:[{x:n,y:r+o},{x:n+o,y:r-o},{x:n-o,y:r-o}],fill:s,stroke:a,strokeWidth:l,id:t});break;case "hexagon":{let h=[];for(let d=0;d<6;d++){let u=d*(Math.PI/3);h.push({x:n+o*Math.cos(u),y:r+o*Math.sin(u)});}i.push({type:"path",points:h,fill:s,stroke:a,strokeWidth:l,id:t});break}case "hourglass":i.push({type:"path",points:[{x:n-o,y:r-o},{x:n+o,y:r-o},{x:n-o,y:r+o},{x:n+o,y:r+o}],fill:s,stroke:a,strokeWidth:l,id:t});break;case "line-horizontal":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:a,strokeWidth:l,id:t});break;default:i.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:a,strokeWidth:l,id:t});}}var et=class i{#t;#e;static uidcnt=0;#n;constructor(t,e=[]){this.#t=t.id??"series-"+ ++i.uidcnt,this.#e=t.timeScale,this.#n=e;}get id(){return this.#t}get timeScale(){return this.#e}get data(){return this.#n}};var ct=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}render(){let t=this.#t,e=t.minColor??g.minColor,n=t.maxColor??g.maxColor,r=t.avgColor??g.avgColor,o=t.avgDashed??true,a=t.smoothing??false,s=t.strokeWidth??g.strokeWidth,l=H.getRuns(this.data,c=>c.min===null||c.max===null||c.avg===null);if(l.length===0)return [];let h={timeScale:this.timeScale,valueScale:t.valueScale},d=[];l.forEach((c,f)=>{c.length<2||(t.fillToMax&&d.push(...Bt(c,h,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.max,getValue:y=>y.avg,interpolate:H.interpolateAggregatedPoint,getColor:()=>t.fillToMax,getHatch:()=>t.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${f}`:void 0})),t.fillToMin&&d.push(...Bt(c,h,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.min,getValue:y=>y.avg,interpolate:H.interpolateAggregatedPoint,getColor:()=>t.fillToMin,getHatch:()=>t.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${f}`:void 0})));});let u=l.filter(c=>c.length>=2),m=c=>u.map(f=>({data:f.map(y=>({time:y.time,value:c(y)}))}));return d.push(...mt(m(c=>c.max),h,{stroke:n,strokeWidth:s,smoothing:a,id:this.id?`${this.id}-max`:void 0}),...mt(m(c=>c.min),h,{stroke:e,strokeWidth:s,smoothing:a,id:this.id?`${this.id}-min`:void 0}),...mt(m(c=>c.avg),h,{stroke:r,strokeWidth:s,smoothing:a,dashed:o,id:this.id?`${this.id}-avg`:void 0})),d}};var pt=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}opacity(t){if(!(this.#t.countOpacity??false))return .6;let e=0;for(let n of this.data)n.count>e&&(e=n.count);return e===0?.2:.2+.8*t/e}render(){let t=this.#t,e=t.fill??g.bandFill,n=t.hatch,r=t.avgLine??false,o=t.avgLineColor??g.bandAvgLine,a=t.bandWidth??10,s=[];for(let l of this.data){if(l.min===null||l.max===null)continue;let h=this.timeScale.map(l.time),d=t.valueScale.map(l.max),u=t.valueScale.map(l.min),m=a,c=this.data.indexOf(l);if(s.push({type:"rect",x:h-m/2,y:d,w:m,h:u-d,fill:e,hatch:n,opacity:this.opacity(l.count),id:this.id?`${this.id}-slot-${c}`:void 0}),r&&l.avg!==null){let f=t.valueScale.map(l.avg);s.push({type:"line",x1:h-m/2,y1:f,x2:h+m/2,y2:f,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${c}`:void 0});}}return s}};function $e(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function Kt(i){let{thresholds:t,valueScale:e,xRange:n}=i,[r,o]=n,[a,s]=e.range(),l=Math.min(a,s),h=Math.max(a,s),d=[],u=[];for(let m of t){let c=m.color??g.thresholdColor,f=e.map(m.value);m.fill==="above"?d.push({type:"rect",x:r,y:l,w:o-r,h:Math.max(0,f-l),fill:c,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0}):m.fill==="below"&&d.push({type:"rect",x:r,y:f,w:o-r,h:Math.max(0,h-f),fill:c,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0});let y=m.line??g.thresholdLine;if(y!=="none"){let b=$e(y),_={type:"line",x1:r,y1:f,x2:o,y2:f,stroke:c,strokeWidth:1,...b,id:m.id?`${m.id}-line`:void 0};m.shadowColor&&(_.shadowColor=m.shadowColor,_.shadowBlur=m.shadowBlur??4,_.shadowOffsetX=m.shadowOffsetX??0,_.shadowOffsetY=m.shadowOffsetY??2),d.push(_);}if(m.label!==void 0&&m.label!==null&&m.label!==false){let b=typeof m.label=="object"?m.label:void 0,_=typeof m.label=="string"?m.label:b?.text??m.name,C=b?.position??"right";u.push({...Ae(_,C,r,o,f,c,b),id:m.id?`${m.id}-label`:void 0});}}return {inside:d,labels:u}}function Ae(i,t,e,n,r,o,a){let s=(e+n)/2,l={type:"text",content:i,fontSize:g.thresholdFontSize,fill:o},h=a?{...a.rotate!==void 0&&{rotate:a.rotate},...a.textBaseline!==void 0&&{textBaseline:a.textBaseline}}:{};switch(t){case "left":return {...l,...h,x:e+4,y:r-4,anchor:"start"};case "above":return {...l,...h,x:s,y:r-6,anchor:"middle"};case "below":return {...l,...h,x:s,y:r+14,anchor:"middle"};case "center":return {...l,...h,x:s,y:r-4,anchor:"middle"};case "outside-left":return {...l,...h,x:e-6,y:r+3,anchor:"end",textBaseline:h.textBaseline??"middle"};case "outside-right":return {...l,...h,x:n+6,y:r+3,anchor:"start",textBaseline:h.textBaseline??"middle"};default:return {...l,...h,x:n-4,y:r-4,anchor:"end"}}}function Zt(i){let{gaps:t,timeScale:e,yRange:n,fill:r=g.gapFill,hatch:o,fillOpacity:a=g.gapFillOpacity??.15,stroke:s=g.gapStroke,strokeWidth:l=g.gapStrokeWidth,dashed:h=true,fontSize:d=g.gapFontSize,fontFill:u=g.gapFontColor,labelBaseline:m="middle",labelRotate:c}=i,[f,y]=n,b=[];for(let _ of t){let C=e.map(_.startTime),N=e.map(_.endTime),P=_.fill??r,M=_.hatch??o,R=_.fillOpacity??a,B=_.label??"",G=_.rotate??c,I=_.labelBaseline??m;if(_.style==="dashed_border"||!_.style?b.push({type:"rect",x:C,y:f,w:N-C,h:y-f,fill:P,hatch:M,opacity:R,stroke:s,strokeWidth:l,dashed:h}):_.style==="empty"&&b.push({type:"rect",x:C,y:f,w:N-C,h:y-f,fill:P,hatch:M,opacity:R}),B){let S=Le(f,y,I),v=I==="above"?"top":I==="below"?"bottom":"middle";b.push({type:"text",content:B,x:(C+N)/2,y:S,anchor:"middle",fontSize:d,fill:u,textBaseline:v,rotate:G});}}return b}function Le(i,t,e){switch(e){case "above":return i-12;case "below":return t+4;default:return (i+t)/2}}var ft=class{#t;constructor(t,e,n,r){this.#t={...t,xRange:e,y:n,height:r};}render(){let{items:t,timeScale:e,background:n,hatch:r,showAxis:o,xRange:a,y:s,height:l}=this.#t,h=[];n&&h.push({type:"rect",x:a[0],y:s,w:a[1]-a[0],h:l,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let d of t){let u=e.map(d.startTime),m=e.map(d.endTime);if(!(m-u<1)&&(h.push({type:"rect",x:u,y:s,w:m-u,h:l,hatch:d.hatch??r,fill:d.fill??"#6b728044",stroke:d.stroke,strokeWidth:d.strokeWidth??0}),d.label)){let c=d.labelFontSize??10;h.push({type:"text",content:d.label,x:(u+m)/2,y:this.#e(d.labelBaseline,c),anchor:"middle",fontSize:c,fill:d.labelFill??"#333"});}}if(o){let d=new tt({domain:e.domain(),xRange:a,y:s+l+4});h.push({type:"group",cssClass:"annotation-band-axis",commands:d.render()});}return h}#e(t,e){let{y:n,height:r}=this.#t;switch(t){case "top":return n+e*.9;case "bottom":return n+r-e*.25;default:return n+r/2+e*.35}}};function Jt(i){let{highlights:t,timeScale:e,yRange:n,height:r}=i,[o,a]=n,s=[];for(let l of t){let h=e.map(l.startTime),d=e.map(l.endTime);s.push({type:"rect",x:h,y:o,w:d-h,h:a-o,fill:l.color??g.highlightColor,opacity:l.opacity??g.highlightOpacity}),l.label&&s.push({type:"text",content:l.label,x:(h+d)/2,y:Me(l.labelPosition??"top",o,a,r),anchor:"middle",fontSize:g.annotationFontSize,fill:l.color??g.highlightLabelColor,rotate:l.rotate});}return s}function Me(i,t,e,n){switch(i){case "above":return t-5;case "below":return n!==void 0?n-5:e+14;case "center":return (t+e)/2+4;case "bottom":return e-6;default:return t+14}}function Qt(i){let{markers:t,timeScale:e,valueScale:n,yRange:r=[0,300]}=i,[o,a]=r,s=[];for(let l of t){let h=e.map(l.time),d=l.color??g.markerColor,u=l.pointStyle??(l.value!==void 0?"circle":"none"),m=l.lineStyle??"full";if(l.value!==void 0){let c=n.map(l.value);if(m==="to-value"?s.push({type:"line",x1:h,y1:a,x2:h,y2:c,stroke:d,strokeWidth:1,dashed:true}):m==="to-top"?s.push({type:"line",x1:h,y1:o,x2:h,y2:c,stroke:d,strokeWidth:1,dashed:true}):m==="full"&&s.push({type:"line",x1:h,y1:o,x2:h,y2:a,stroke:d,strokeWidth:1}),u!=="none"&&ut(s,void 0,u,h,c,g.markerSize,d,d,1.5),l.label){let f=m==="to-value"?c-10:o-6;s.push({type:"text",content:l.label,x:h,y:f,anchor:"middle",fontSize:11,fill:d});}}else s.push({type:"line",x1:h,y1:o,x2:h,y2:a,stroke:d,strokeWidth:1}),l.label&&s.push({type:"text",content:l.label,x:h,y:o-6,anchor:"middle",fontSize:11,fill:d});}return s}function te(i){let{annotations:t,timeScale:e,valueScales:n}=i,r=[],o=a=>{let s=n.get(a.axis??0)??n.values().next().value;return {x:e.map(a.time),y:s?s.map(a.value):0}};for(let a of t){let s=[],l=h=>s.push(h);switch(a.type){case "line":{let h=o(a.from),d=o(a.to);l({type:"line",x1:h.x,y1:h.y,x2:d.x,y2:d.y,stroke:a.color??g.annotationColor,strokeWidth:a.width??g.annotationWidth,dash:a.dash});break}case "arrow":{let h=o(a.from),d=o(a.to),u=a.color??g.annotationColor,m=a.headSize??g.annotationHead;l({type:"line",x1:h.x,y1:h.y,x2:d.x,y2:d.y,stroke:u,strokeWidth:a.width??g.annotationWidth});let c=Math.hypot(d.x-h.x,d.y-h.y)||1,f=(d.x-h.x)/c,y=(d.y-h.y)/c,b=d.x-f*m,_=d.y-y*m;l({type:"path",points:[{x:d.x,y:d.y},{x:b-y*m*.5,y:_+f*m*.5},{x:b+y*m*.5,y:_-f*m*.5}],fill:u,stroke:"none"});break}case "rect":{let h=o(a.from),d=o(a.to);l({type:"rect",x:Math.min(h.x,d.x),y:Math.min(h.y,d.y),w:Math.abs(d.x-h.x),h:Math.abs(d.y-h.y),fill:a.fill??"none",stroke:a.stroke,opacity:a.opacity});break}case "point":{let h=o(a.at),d=a.color??"#334155",u=a.radius??g.annotationRadius,m=a.shape??"circle";m==="circle"?l({type:"circle",cx:h.x,cy:h.y,r:u,fill:d}):m==="square"?l({type:"rect",x:h.x-u,y:h.y-u,w:u*2,h:u*2,fill:d}):(l({type:"line",x1:h.x-u,y1:h.y-u,x2:h.x+u,y2:h.y+u,stroke:d,strokeWidth:1.5}),l({type:"line",x1:h.x-u,y1:h.y+u,x2:h.x+u,y2:h.y-u,stroke:d,strokeWidth:1.5}));break}case "label":{let h=o(a.at);l({type:"text",content:a.text,x:h.x+(a.dx??0),y:h.y+(a.dy??0),anchor:a.anchor??"middle",fontSize:g.annotationFontSize,fill:a.color??g.annotationColor,rotate:a.rotate});break}}if(a.id&&s.length>0){let h=it(a.id);r.push({type:"group",cssClass:`annotation annotation--${h}`,commands:s});}else r.push(...s);}return r}var U=12,gt=8,Ft=20,De=11,jt=18,Ot=i=>i.length*De*.6;function ee(i,t="vertical"){if(t==="horizontal"){let n=0;for(let r of i)n+=U+gt+Ot(r.name)+jt;return {width:Math.max(0,n-jt),height:Ft}}let e=0;for(let n of i)e=Math.max(e,Ot(n.name));return {width:U+gt+e,height:i.length*Ft}}function ne(i){let{items:t,x:e,y:n,orientation:r="vertical"}=i,o=[],a=e;return t.forEach((s,l)=>{let h=r==="horizontal"?a:e,d=r==="horizontal"?n:n+l*Ft;o.push({type:"rect",x:h,y:d,w:U,h:U,fill:s.color,stroke:g.legendStroke,strokeWidth:1},{type:"text",content:s.name,x:h+U+gt,y:d+U-2,fontSize:g.legendFont,fill:g.legendText}),r==="horizontal"&&(a+=U+gt+Ot(s.name)+jt);}),{type:"group",cssClass:"chart-legend",commands:o}}function ie(i){let{xTicks:t,yTicks:e,xRange:n,yRange:r,stroke:o=g.gridStroke,strokeWidth:a=g.gridStrokeWidth,dashed:s=false,opacity:l=g.gridOpacity}=i,h=[];if(e)for(let d of e)h.push({type:"line",x1:n[0],y1:d,x2:n[1],y2:d,stroke:o,strokeWidth:a,dashed:s,opacity:l});if(t)for(let d of t)h.push({type:"line",x1:d,y1:r[0],x2:d,y2:r[1],stroke:o,strokeWidth:a,dashed:s,opacity:l});return h}function re(i,t,e){let n=i??t;if(n==="series")return null;if(n==="chartTop")return e.chartTop;if(n==="chartBottom")return e.chartBottom;if(typeof n=="object"&&"threshold"in n){let r=e.thresholds.get(n.threshold);if(!r)throw new Error(`fillSpec region references unknown threshold '${n.threshold}'`);return e.valueScale.map(r.value)}return typeof n=="object"&&"value"in n?e.valueScale.map(n.value):null}function Pe(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function oe(i,t,e){let n=re(i.from,"chartBottom",t),r=re(i.to,"series",t),{color:o,hatch:a}=Pe(i.fill),s={type:"path",fill:o,hatch:a,stroke:"none",...t.idPrefix&&{id:`${t.idPrefix}-fill-r${e}`}};if(n!==null&&r!==null){let m=t.timeScale.range(),c=m[0],f=m[1],y=Math.min(n,r),b=Math.max(n,r);return [{...s,points:[{x:c,y},{x:f,y},{x:f,y:b},{x:c,y:b}]}]}let l=n??r,h=[],d=Be(i,t);if(d===null){let m=t.valueScale.domain();d=(n??r)===t.chartBottom?m[0]:m[1];}let u=se(i.outer,t);for(let m of t.runs){if(m.length<2)continue;let c=H.splitByThreshold(m,d,y=>y.value??d,H.interpolateDataPoint),f=i.side==="above"?c.above:i.side==="below"?c.below:[...c.above,...c.below];if(u!==null&&i.side){let y=i.side==="above"?"below":"above";f=f.flatMap(b=>{if(b.length<2)return [];let _=H.splitByThreshold(b,u,C=>C.value??u,H.interpolateDataPoint);return y==="above"?_.above:_.below});}for(let y of f){if(y.length<2)continue;let b=y.map(C=>({x:t.timeScale.map(C.time),y:t.valueScale.map(C.value)})),_=[...b].reverse().map(C=>({x:C.x,y:l}));h.push({...s,smoothing:t.smoothing,smoothCount:b.length,points:[...b,..._]});}}return h}function Be(i,t){let e=i.from==="series"?i.to:i.from;return se(e,t)}function se(i,t){return i===void 0||i==="series"||i==="chartTop"||i==="chartBottom"?null:typeof i=="object"&&"threshold"in i?t.thresholds.get(i.threshold)?.value??null:typeof i=="object"&&"value"in i?i.value:null}function ae(i,t){if(typeof i=="string"||!("regions"in i))return oe({fill:i},t,0);let e=[];return i.regions.forEach((n,r)=>{e.push(...oe(n,t,r));}),e}function le(i,t){let e=new Array(i.length),n=0;for(let r=0;r<i.length;r++){let o=i[r].time,a=o-t;for(;n<r&&i[n].time<a;)n++;let s=0,l=0;for(let h=n;h<=r;h++){let d=i[h].value;d!==null&&(s+=d,l++);}e[r]={time:o,value:l===0?null:s/l,synthetic:true};}return e}function de(i){let t=i.style?.line,e=t&&!Array.isArray(t)?t:void 0;return {color:e?.color??g.stroke,width:e?.width??g.strokeWidth,dash:e?.style,smoothing:e?.smoothing??false}}function he(i,t,e,n){let r=i.filter(l=>l.value!==null);if(r.length<2)return [];let o=r.map(l=>({x:t.timeScale.map(l.time),y:t.valueScale.map(l.value)})),a=de(e);return [{type:"path",id:t.idPrefix?`${t.idPrefix}-overlay-${n}`:`overlay-${n}`,points:o,stroke:a.color,strokeWidth:a.width,smoothing:a.smoothing,dash:a.dash,fill:"none"}]}function me(i,t){switch(i.kind){case "movingAverage":{i.type;let e=le(t.data,i.window);return he(e,t,i,"movingAvg")}case "movingMkt":{let e=Yt(t.data,i.window,i.activationEnergy);return he(e,t,i,"movingMkt")}case "limits":{let e=[],n=t.timeScale.range(),r=n[0],o=n[1],a=de(i),s=a.color,l=a.width,h=a.dash??"dashed",d=t.idPrefix?`${t.idPrefix}-`:"";return i.high!==void 0&&e.push({type:"line",id:`${d}overlay-limit-high`,x1:r,y1:t.valueScale.map(i.high),x2:o,y2:t.valueScale.map(i.high),stroke:s,strokeWidth:l,dash:h}),i.low!==void 0&&e.push({type:"line",id:`${d}overlay-limit-low`,x1:r,y1:t.valueScale.map(i.low),x2:o,y2:t.valueScale.map(i.low),stroke:s,strokeWidth:l,dash:h}),e}case "stdDevBand":{let e=i.multiplier??1,n=le(t.data,i.window),r=zt(t.data,i.window),o=[],a=[];for(let y=0;y<n.length;y++){let b=n[y].value,_=r[y].value;if(b===null||_===null)continue;let C=t.timeScale.map(n[y].time);o.push({x:C,y:t.valueScale.map(b+e*_)}),a.push({x:C,y:t.valueScale.map(b-e*_)});}if(o.length<2)return [];let s=t.idPrefix?`${t.idPrefix}-`:"",l=[],d=(typeof i.style?.fill=="string"||i.style?.fill&&!("regions"in i.style.fill)?i.style.fill:void 0)??"#94a3b833",{color:u,hatch:m}=Fe(d);l.push({type:"path",id:`${s}overlay-stdDevBand`,points:[...o,...[...a].reverse()],fill:u,hatch:m,stroke:"none"});let c=i.style?.line,f=c&&!Array.isArray(c)?c:void 0;if(f){let y=n.filter(b=>b.value!==null).map(b=>({x:t.timeScale.map(b.time),y:t.valueScale.map(b.value)}));y.length>=2&&l.push({type:"path",id:`${s}overlay-stdDevBand-mean`,points:y,stroke:f.color??g.stroke,strokeWidth:f.width??1.5,smoothing:f.smoothing,dash:f.style,fill:"none"});}return l}}}function Fe(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function je(i){if(!i)return {gaps:[],autoDetect:false,minGapMs:6e4};if(Array.isArray(i))return {gaps:i,autoDetect:false,minGapMs:6e4};let t=i.regions??[],e=i.style;return {gaps:t.map(r=>{let o={...e,...r.style},a=o.fill,s,l;return typeof a=="string"?s=a:a&&(s=a.color,l=a.hatch),{startTime:r.startTime,endTime:r.endTime,label:r.label,fill:s,hatch:l,fillOpacity:o.opacity,labelBaseline:o.label?.baseline,rotate:o.label?.rotate,style:o.display==="filled"||o.display==="bridge_line"?void 0:o.display}}),autoDetect:i.autoDetect??false,minGapMs:i.minGapMs??6e4}}function yt(i){return "showAs"in i&&!!i.showAs}var K=class{_layout;_renderer;_locale;_legend;_clipSeries;_markers;_thresholds;_highlights;_gaps;_gapsAutoDetect;_gapsMinGapMs;_annotations;_annotationBands;_disabledAnnotations=new Set;_annotationSeq=0;_axes;_series;readonly_annotationBandHeight=0;_timeScale;_valueScales=new Map;constructor(t={}){this._layout=new nt({width:t.width??800,height:t.height??400,margin:t.margin??{top:20,right:20,bottom:40,left:60}}).compute(),this._renderer=t.renderer,this._locale=t.locale,this._legend=t.legend,this._clipSeries=t.clipSeries??true,this._markers=t.markers??[],this._thresholds=t.thresholds??[],this._highlights=t.highlights??[];let e=je(t.gaps);this._gaps=e.gaps,this._gapsAutoDetect=e.autoDetect,this._gapsMinGapMs=e.minGapMs,this._annotations=t.annotations??[],this._annotationBands=t.annotationBands??[],this._axes=t.axes,this._series=[],t.series&&this.setData(t.series);}getWidth(){return this._layout.totalWidth}getHeight(){return this._layout.totalHeight+this._annotationBandTotalHeight()}get series(){return this._series}_annotationBandTotalHeight(){let t=0;for(let e of this._annotationBands){let n=e.height??12,r=e.spacing??0;(e.showAxis??false)&&(t+=26+r),t+=n+r;}return t}setData(t){this._series=t.filter(e=>Array.isArray(e.data));}addAnnotation(t){let e=t.id??`anno-${++this._annotationSeq}`;return this._annotations.push({...t,id:e}),e}removeAnnotation(t){let e=this._annotations.length;return this._annotations=this._annotations.filter(n=>n.id!==t),this._disabledAnnotations.delete(t),this._annotations.length<e}setAnnotations(t){this._annotations=[...t],this._disabledAnnotations.clear();}clearAnnotations(){this._annotations=[],this._disabledAnnotations.clear();}getAnnotations(){return this._annotations}disableAnnotation(t){this._disabledAnnotations.add(t);}enableAnnotation(t){this._disabledAnnotations.delete(t);}_axisIndexOf(t){return t.yAxisIndex??0}_timesOf(t){return t.data.map(e=>e.time)}_valuesOf(t){if(yt(t)){let e=[];for(let n of t.data)n.min!==null&&e.push(n.min),n.max!==null&&e.push(n.max);return e}return t.data.map(e=>e.value).filter(e=>e!==null)}renderCommands(){if(this._series.length===0)return [];let t=this._legendItems(),e=(this._legend?.show??false)&&t.length>0,n=this._legend?.position??"inside-right",r=this._legend?.orientation??"vertical",o=e?ee(t,r):{width:0},a=this._layout;if(e&&(n==="outside-right"||n==="outside-left")){let p=o.width+16,x={...this._layout.margin};n==="outside-right"?x.right+=p:x.left+=p,a=new nt({width:this._layout.totalWidth,height:this._layout.totalHeight,margin:x}).compute();}let{chartX:s,chartY:l,chartWidth:h,chartHeight:d}=a,u=[s,s+h],m=[l,l+d],c=[];for(let p of this._series)p.data.sort((x,w)=>x.time-w.time);let f=new Map,y=1/0,b=-1/0,_=false;for(let p of this._series){let x=this._axisIndexOf(p),w=f.get(x);w?w.push(p):f.set(x,[p]);for(let A of this._timesOf(p))A<y&&(y=A),A>b&&(b=A),_=true;}if(!_)return [];let C=this._axes?.x?.domain,N=C&&C!=="auto"?C:[y,b];this._timeScale=new J({domain:N,range:u,locale:this._locale});let P=p=>({axisColor:p?.color??g.axisColor,tickColor:p?.color??g.tickColor,textColor:g.textColor,textSize:g.textSize,axisWidth:p?.width??1}),M=new tt({domain:N,xRange:u,y:l+d,locale:this._locale,format:this._axes?.x?.format,maxTicks:this._axes?.x?.ticks?.major,colors:P(this._axes?.x?.axis)});this._valueScales.clear();let R=Array.from(f.keys()).sort((p,x)=>p-x),B,G=0,I=0;for(let p of R){let x=f.get(p),w=1/0,A=-1/0,L=false;for(let V of x)for(let lt of this._valuesOf(V))lt<w&&(w=lt),lt>A&&(A=lt),L=true;if(!L)continue;let D;this._axes?.y&&this._axes.y.length>p?D=this._axes.y[p]:p===0?D=this._axes?.left:p===1&&(D=this._axes?.right);let $t=D?.domain,Z=$t&&$t!=="auto"?$t:[w,A],Ht=new X({domain:Z,range:[l+d,l]});this._valueScales.set(p,Ht);let Rt=this._thresholds.filter(V=>(V.axisIndex??0)===p&&V.label!==false&&V.value>=Math.min(Z[0],Z[1])&&V.value<=Math.max(Z[0],Z[1])).map(V=>Ht.map(V.value)),At=D?.position??(p===0?"left":"right"),Lt;if(At==="right"){let V=D?.offset!==void 0?D.offset:I*50;Lt=s+h+V,I++;}else {let V=D?.offset!==void 0?D.offset:G*50;Lt=s-V,G++;}let It=new dt({domain:Z,range:[l+d,l],x:Lt,position:At,format:D?.format,ticks:D?.ticks?.major,colors:P(D?.axis),suppressLabelsNear:Rt.length?Rt:void 0});p===0&&(B=It),c.push({type:"group",cssClass:`value-axis ${At}`,commands:It.render()});}let S=this._valueScales.get(0)??this._valueScales.get(R[0]);c.push({type:"group",cssClass:"time-axis",commands:M.render()});let v=null,k=this._axes?.x?.grid?.major,$=this._axes?.left?.grid?.major;if(k!==void 0||$!==void 0){let p=k!==false,x=$!==false&&!!B,w=p?M.generateTicks().map(L=>L.x):void 0,A=x?B.generateTicks().map(L=>L.position):void 0;if(w||A){let L=(k&&typeof k=="object"?k:void 0)??($&&typeof $=="object"?$:void 0);v={type:"group",cssClass:"chart-grid",commands:ie({xTicks:w,yTicks:A,xRange:u,yRange:m,stroke:L?.color,opacity:L?.opacity,dashed:L?.style==="dashed"})};}}if(this._highlights.length>0&&c.push({type:"group",cssClass:"highlights",commands:Jt({highlights:this._highlights,timeScale:this._timeScale,yRange:m,height:a.totalHeight})}),this._thresholds.length>0&&S){let p=[],x=[];for(let w of this._thresholds){let A=w.id??it(w.name),L=this._valueScales.get(w.axisIndex??0)??S,D=Kt({thresholds:[w],valueScale:L,xRange:u});D.inside.length&&p.push({type:"group",cssClass:`threshold threshold--${A}`,id:`threshold-${A}`,commands:D.inside}),D.labels.length&&x.push({type:"group",cssClass:`threshold-label threshold-label--${A}`,commands:D.labels});}p.length&&c.push({type:"group",cssClass:"thresholds",commands:p,clipRect:{x:s,y:l,w:h,h:d}}),x.length&&c.push({type:"group",cssClass:"threshold-labels",commands:x});}let j=this._gaps;if(this._gapsAutoDetect){let p=[];for(let x of this._series)yt(x)||p.push(...Nt(x.data,this._gapsMinGapMs));p.length>0&&(j=[...this._gaps,...p]);}j.length>0&&c.push({type:"group",cssClass:"gaps",commands:Zt({gaps:j,timeScale:this._timeScale,yRange:m})});let W=new Map(this._thresholds.map(p=>[p.id??p.name,p]));for(let p of this._series){if(p.data.length===0)continue;let x=this._valueScales.get(this._axisIndexOf(p));if(!x)continue;let w=it(p.id??p.name);c.push({type:"group",cssClass:`series series--${w}`,id:`series-${w}`,commands:this._renderSeries(p,x,W),...this._clipSeries?{clipRect:{x:s,y:l,w:h,h:d}}:{}});}v&&c.push(v);let Y=this._markers.map(p=>({...p}));for(let p of Y)if(p.value===void 0&&(p.lineStyle==="to-value"||p.lineStyle==="to-top")){let x=this._series[p.seriesIndex??0];x&&!yt(x)&&x.data.length>=2&&(p.value=this._interpolateValue(p.time,x.data));}Y.length>0&&S&&c.push({type:"group",cssClass:"markers",commands:Qt({markers:Y,timeScale:this._timeScale,valueScale:S,yRange:m})});let F=this._annotations.filter(p=>!p.id||!this._disabledAnnotations.has(p.id));if(F.length>0&&c.push({type:"group",cssClass:"annotations",commands:te({annotations:F,timeScale:this._timeScale,valueScales:this._valueScales})}),this._annotationBands.length>0){let p=l+d+this._layout.margin.bottom,x=0;this._annotationBands.forEach(w=>{let A=w.height??12,L=w.spacing??0,D=p+x;(w.showAxis??false)&&(x+=26+L),x+=A+L,c.push({type:"group",cssClass:"annotation-band",commands:new ft({name:w.name,showAxis:w.showAxis??false,items:w.items,timeScale:this._timeScale,background:w.background,hatch:w.hatch},[s,s+h],D,A).render()});});}if(e&&n!=="separate"){let p,x;n==="inside-right"?(p=s+h-o.width-8,x=l+8):n==="inside-left"?(p=s+8,x=l+8):n==="outside-right"?(p=s+h+16,x=l):(p=8,x=l),c.push(ne({items:t,x:p,y:x,orientation:r}));}let T=this._axes?.left?.label,O=this._axes?.right?.label,E=this._axes?.x?.label;if(T||O||E){let p=[],x=l+d/2,w=this._axes?.left?.labels,A=this._axes?.right?.labels,L=this._axes?.x?.labels;T&&p.push({type:"text",content:T,x:14,y:x,anchor:"middle",fontSize:w?.fontSize??g.axisLabelSize,fill:w?.color??g.axisLabelColor,rotate:-90}),O&&p.push({type:"text",content:O,x:a.totalWidth-14,y:x,anchor:"middle",fontSize:A?.fontSize??g.axisLabelSize,fill:A?.color??g.axisLabelColor,rotate:90}),E&&p.push({type:"text",content:E,x:s+h/2,y:a.totalHeight-6,anchor:"middle",fontSize:L?.fontSize??g.axisLabelSize,fill:L?.color??g.axisLabelColor}),p.length&&c.push({type:"group",cssClass:"axis-labels",commands:p});}return c}_renderSeries(t,e,n){let r=this._timeScale,o={timeScale:r,valueScale:e};if(yt(t)){let S=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,v=typeof t.style?.fill=="string"?t.style.fill:void 0;return t.showAs==="minmaxavg"?new ct({data:t.data,timeScale:r,valueScale:e,minColor:t.minColor,maxColor:t.maxColor,avgColor:t.avgColor,avgDashed:t.avgDashed,fillToMax:t.fillToMax,fillToMaxHatch:t.fillToMaxHatch,fillToMin:t.fillToMin,fillToMinHatch:t.fillToMinHatch,smoothing:S?.smoothing,strokeWidth:S?.width,id:rt(t.name,t.id)}).render():new pt({data:t.data,timeScale:r,valueScale:e,fill:v??S?.color,avgLine:t.avgLine,countOpacity:t.countOpacity,id:rt(t.name,t.id)}).render()}let a=t,s=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,l=s?.gapThreshold??g.gapThreshold,h=H.getRuns(t.data,S=>S.value===null,l),d=h.reduce((S,v)=>S+v.length,0);if(d===0)return [];let u=[],m=t.style?.markers,c=t.style?.shadow,f={stroke:s?.color??g.stroke,strokeWidth:s?.width??g.strokeWidth,smoothing:s?.smoothing,dashed:s?.style==="dashed",pointStyle:m?.type,pointSize:m?.size,pointStroke:m?.stroke,pointFill:m?.fill,pointStrokeWidth:m?.strokeWidth,shadowColor:c?.color,shadowBlur:c?.blur,shadowOffsetX:c?.offsetX,shadowOffsetY:c?.offsetY,id:rt(t.name,t.id)},y=t.style?.line,b=y&&!Array.isArray(y)?y:void 0,_=b?.color,C=b?.width,N=b?.style,P=b?.smoothing,M=t.style?.fill;if(M!==void 0){let S=e.range(),v=Math.min(S[0],S[1]),k=Math.max(S[0],S[1]);u.push(...ae(M,{runs:h,timeScale:r,valueScale:e,thresholds:n,chartTop:v,chartBottom:k,smoothing:s?.smoothing,idPrefix:t.id}));}let R=a.colorByThresholds??[],B=R.map(S=>n.get(S)).filter(S=>!!S).map(S=>S.value).sort((S,v)=>S-v),G=(S,v,k)=>{let $=k??f.stroke;for(let j of v){let W=n.get(j);W&&S>=W.value&&($=W.color??$);}return $};for(let S of h){if(S.length<2)continue;let v=H.splitByBoundaries(S,B,k=>k.value,H.interpolateDataPoint);for(let k=0;k<v.length;k++){let $=v[k];if($.data.length<2)continue;let j=($.data[0].value+$.data[$.data.length-1].value)/2,W=rt(a.name,a.id),Y=$.data.map(p=>({x:r.map(p.time),y:e.map(p.value)})),F=W?`${W}-line-${k}`:void 0,O=(b?.shape??s?.shape??a.seriesType)==="step",E=O?Xt(Y):Y;y===false||(y&&Array.isArray(y)?y.forEach((p,x)=>{u.push({type:"path",id:F?`${F}-${x}`:void 0,points:E,stroke:G(j,R,p.color),strokeWidth:p.width??f.strokeWidth,smoothing:O?false:p.smoothing??f.smoothing,dash:p.style,opacity:p.opacity,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY});}):u.push({type:"path",id:F,points:E,stroke:G(j,R,_),strokeWidth:C??f.strokeWidth,smoothing:O?false:P??f.smoothing,dash:N,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY}));}f.pointStyle&&f.pointStyle!=="none"&&d<=(m?.threshold??g.pointThreshold)&&u.push(...Ut(S,o,f,k=>G(k.value,R)));}let I=t.overlays;if(I&&I.length>0){let S=e.range(),v={data:t.data,timeScale:r,valueScale:e,chartTop:Math.min(S[0],S[1]),chartBottom:Math.max(S[0],S[1]),idPrefix:t.id};for(let k of I)u.push(...me(k,v));}if(t.style?.gap&&h.length>1){let S=e.range(),v=Math.min(S[0],S[1]),k=Math.max(S[0],S[1]),$=t.style.gap,j=$.fill,W,Y;typeof j=="string"?W=j:j&&(W=j.color,Y=j.hatch);let F=$.opacity??.15,T=$.bridge;for(let O=1;O<h.length;O++){let E=h[O-1][h[O-1].length-1],p=h[O][0],x=r.map(E.time),w=r.map(p.time);if($.display==="bridge_line"){if(E.value===null||p.value===null)continue;let A=e.map(E.value),L=e.map(p.value);u.push({type:"line",x1:x,y1:A,x2:w,y2:L,stroke:T?.color??(typeof t.style?.line=="object"&&!Array.isArray(t.style.line)?t.style.line.color:void 0)??g.stroke,strokeWidth:T?.width??1.5,dash:T?.style??"dotted"});}else W!==void 0?u.push({type:"rect",x,y:v,w:w-x,h:k-v,fill:W,hatch:Y,opacity:F,stroke:"none"}):$.display!=="empty"&&u.push({type:"rect",x,y:v,w:w-x,h:k-v,stroke:g.gapStroke,strokeWidth:1,dashed:true,fill:"none"});}}return u}_interpolateValue(t,e){for(let n=1;n<e.length;n++){let r=e[n-1],o=e[n];if(!(r.value===null||o.value===null)&&t>=r.time&&t<=o.time){let a=(t-r.time)/(o.time-r.time);return r.value+a*(o.value-r.value)}}}legendItems(){return this._legendItems()}_legendItems(){return this._series.map(t=>{let e=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,n=t.style?.markers,r=n?.type&&n.type!=="none"&&(n.threshold===void 0||(t.data?.length??0)<=n.threshold);return {name:t.name,color:e?.color??g.stroke,line:e?.style,marker:r?n.type:void 0}})}get renderer(){return this._renderer}get layout(){return this._layout}get timeScale(){return this._timeScale}get valueScales(){return this._valueScales}invertTime(t){return this._timeScale?this._timeScale.invert(t):0}invertValue(t,e=0){let n=this._valueScales.get(e);return n?n.invert(t):0}project(t,e,n=0){let r=this._timeScale?this._timeScale.map(t):0,o=this._valueScales.get(n);return {x:r,y:o?o.map(e):0}}};var bt=class{};function Oe(i){switch(i){case "top":return "text-top";case "bottom":return "text-bottom";default:return "middle"}}var q=class extends bt{#t="100%";#e="100%";#n;#i=new Map;#r=new Map;#o=new Map;constructor(t){super(),t?.width!==void 0&&(this.#t=t.width),t?.height!==void 0&&(this.#e=t.height),t?.background!==void 0&&(this.#n=t.background);}setBackgroundColor(t){this.#n=t;}render(t){this.#i.clear(),this.#r.clear(),this.#o.clear();let e=t.map(h=>this._toSVG(h));this.#n&&e.unshift(`<rect width="100%" height="100%" fill="${this._esc(this.#n)}" />`);let n=e.join(`
25
+ `),r="",o=[];for(let[,h]of this.#i)o.push(h);for(let[,h]of this.#r)o.push(h);for(let[,h]of this.#o)o.push(h);o.length>0&&(r=` <defs>
26
+ ${o.join(`
27
27
  `)}
28
28
  </defs>
29
- `);let s=typeof this.#t=="number"?`${this.#t}`:this.#t,a=typeof this.#e=="number"?`${this.#e}`:this.#e,h=typeof this.#t=="number"&&typeof this.#e=="number"?` viewBox="0 0 ${this.#t} ${this.#e}"`:"";return {type:"svg",content:`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"${h}>
30
- ${o} ${n}
31
- </svg>`}}_toSVG(t){switch(t.type){case "path":return this._path(t);case "line":return this._line(t);case "rect":return this._rect(t);case "circle":return this._circle(t);case "text":return this.#d(t);case "gradient":return this._gradient(t);case "gap":return this._gap(t);case "group":return this._group(t)}}#l(t,e,n){if(t.length===0)return "";if(!e||t.length<3)return t.map((a,h)=>`${h===0?"M":"L"}${a.x},${a.y}`).join(" ");let o=n!=null&&n<t.length?Math.max(n,2):t.length,r=a=>Math.round(a*100)/100,s=`M${t[0].x},${t[0].y}`;for(let a=0;a<o-1;a++){let h=t[a-1]??t[a],l=t[a],d=t[a+1],u=t[a+2]&&a+2<o?t[a+2]:d,m=r(l.x+(d.x-h.x)/6),c=r(l.y+(d.y-h.y)/6),f=r(d.x-(u.x-l.x)/6),y=r(d.y-(u.y-l.y)/6);s+=` C${m},${c} ${f},${y} ${d.x},${d.y}`;}for(let a=o;a<t.length;a++)s+=` L${t[a].x},${t[a].y}`;return s}_hatchPattern(t,e){let n=`hatch-${t}-${this._hatchIndex++}`;if(this.#o.has(n))return n;let o=Lt(n,t,e??"rgba(200,220,255,0.3)");return this.#o.set(n,o),n}_hatchIndex=0;_path(t){let e=this.#l(t.points,t.smoothing,t.smoothCount),n=[];if(t.hatch){let s=this._hatchPattern(t.hatch,t.fill);n.push(`fill="url(#${s})"`);}else n.push(`fill="${t.fill?this._esc(t.fill):"none"}"`);t.stroke&&n.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&n.push(`stroke-width="${t.strokeWidth}"`);let o=this.#a(t.dash,t.dashed,t.strokeWidth);o&&(n.push(`stroke-dasharray="${o.strokeDasharray}"`),o.strokeLinecap&&n.push(`stroke-linecap="${o.strokeLinecap}"`)),t.opacity!==void 0&&n.push(`opacity="${t.opacity}"`),t.id&&n.push(`id="${this._esc(t.id)}"`);let r=this.#s(t);return r&&n.push(`filter="url(#${r})"`),`<path d="${e}" ${n.join(" ")} />`}_line(t){let e=[];t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`);let n=this.#a(t.dash,t.dashed,t.strokeWidth);n&&(e.push(`stroke-dasharray="${n.strokeDasharray}"`),n.strokeLinecap&&e.push(`stroke-linecap="${n.strokeLinecap}"`)),t.opacity!==void 0&&e.push(`opacity="${t.opacity}"`),t.id&&e.push(`id="${this._esc(t.id)}"`);let o=this.#s(t);return o&&e.push(`filter="url(#${o})"`),`<line x1="${t.x1}" y1="${t.y1}" x2="${t.x2}" y2="${t.y2}" ${e.join(" ")} />`}_rect(t){let e=[];if(t.hatch){let o=this._hatchPattern(t.hatch,t.fill);e.push(`fill="url(#${o})"`);}else t.fill!==void 0&&e.push(`fill="${this._esc(t.fill)}"`);t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`),t.opacity!==void 0&&e.push(`opacity="${t.opacity}"`),t.dashed&&e.push('stroke-dasharray="4,4"'),t.id&&e.push(`id="${this._esc(t.id)}"`);let n=this.#s(t);return n&&e.push(`filter="url(#${n})"`),`<rect x="${t.x}" y="${t.y}" width="${t.w}" height="${t.h}" ${e.join(" ")} />`}_circle(t){let e=[];if(t.hatch){let o=this._hatchPattern(t.hatch,t.fill);e.push(`fill="url(#${o})"`);}else t.fill&&e.push(`fill="${this._esc(t.fill)}"`);t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`),t.id&&e.push(`id="${this._esc(t.id)}"`);let n=this.#s(t);return n&&e.push(`filter="url(#${n})"`),`<circle cx="${t.cx}" cy="${t.cy}" r="${t.r}" ${e.join(" ")} />`}#a(t,e,n){return t==="dashed"||!t&&e?{strokeDasharray:"4,4"}:t==="dotted"?{strokeDasharray:"2,4"}:!t||t==="solid"?null:Et(t,n??2)}#s(t){if(!t.shadowColor)return null;let e=t.shadowBlur??0,n=t.shadowOffsetX??0,o=t.shadowOffsetY??0;if(!e&&!n&&!o)return null;let r=`shadow_${e}_${n}_${o}`;if(this.#i.has(r))return r;let s=`<filter id="${r}" x="-50%" y="-50%" width="200%" height="200%">
32
- <feDropShadow dx="${n}" dy="${o}" stdDeviation="${e/2}" flood-color="${this._esc(t.shadowColor)}" />
33
- </filter>`;return this.#i.set(r,s),r}#h(t,e,n,o,r){this.#r.has(t)||this.#r.set(t,`<clipPath id="${t}">
34
- <rect x="${e}" y="${n}" width="${o}" height="${r}" />
35
- </clipPath>`);}#d(t){let e=[];return t.anchor&&e.push(`text-anchor="${t.anchor}"`),t.fontSize&&e.push(`font-size="${t.fontSize}"`),t.fontFamily&&e.push(`font-family="${this._esc(t.fontFamily)}"`),t.fill&&e.push(`fill="${this._esc(t.fill)}"`),t.opacity!=null&&e.push(`opacity="${t.opacity}"`),t.rotate&&e.push(`transform="rotate(${t.rotate} ${t.x} ${t.y})"`),t.textBaseline&&e.push(`dominant-baseline="${Be(t.textBaseline)}"`),t.id&&e.push(`id="${this._esc(t.id)}"`),`<text x="${t.x}" y="${t.y}" ${e.join(" ")}>${this._esc(t.content)}</text>`}_gradient(t){let e=`grad-${Math.random().toString(36).slice(2,8)}`,n=t.stops.map(o=>` <stop offset="${o.offset}" stop-color="${this._esc(o.color)}" />`).join(`
29
+ `);let a=typeof this.#t=="number"?`${this.#t}`:this.#t,s=typeof this.#e=="number"?`${this.#e}`:this.#e,l=typeof this.#t=="number"&&typeof this.#e=="number"?` viewBox="0 0 ${this.#t} ${this.#e}"`:"";return {type:"svg",content:`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${s}"${l}>
30
+ ${r} ${n}
31
+ </svg>`}}_toSVG(t){switch(t.type){case "path":return this._path(t);case "line":return this._line(t);case "rect":return this._rect(t);case "circle":return this._circle(t);case "text":return this.#d(t);case "gradient":return this._gradient(t);case "gap":return this._gap(t);case "group":return this._group(t)}}#l(t,e,n){if(t.length===0)return "";if(!e||t.length<3)return t.map((s,l)=>`${l===0?"M":"L"}${s.x},${s.y}`).join(" ");let r=n!=null&&n<t.length?Math.max(n,2):t.length,o=s=>Math.round(s*100)/100,a=`M${t[0].x},${t[0].y}`;for(let s=0;s<r-1;s++){let l=t[s-1]??t[s],h=t[s],d=t[s+1],u=t[s+2]&&s+2<r?t[s+2]:d,m=o(h.x+(d.x-l.x)/6),c=o(h.y+(d.y-l.y)/6),f=o(d.x-(u.x-h.x)/6),y=o(d.y-(u.y-h.y)/6);a+=` C${m},${c} ${f},${y} ${d.x},${d.y}`;}for(let s=r;s<t.length;s++)a+=` L${t[s].x},${t[s].y}`;return a}_hatchPattern(t,e){let n=`hatch-${t}-${this._hatchIndex++}`;if(this.#o.has(n))return n;let r=Dt(n,t,e??"rgba(200,220,255,0.3)");return this.#o.set(n,r),n}_hatchIndex=0;_path(t){let e=this.#l(t.points,t.smoothing,t.smoothCount),n=[];if(t.hatch){let a=this._hatchPattern(t.hatch,t.fill);n.push(`fill="url(#${a})"`);}else n.push(`fill="${t.fill?this._esc(t.fill):"none"}"`);t.stroke&&n.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&n.push(`stroke-width="${t.strokeWidth}"`);let r=this.#a(t.dash,t.dashed,t.strokeWidth);r&&(n.push(`stroke-dasharray="${r.strokeDasharray}"`),r.strokeLinecap&&n.push(`stroke-linecap="${r.strokeLinecap}"`)),t.opacity!==void 0&&n.push(`opacity="${t.opacity}"`),t.id&&n.push(`id="${this._esc(t.id)}"`);let o=this.#s(t);return o&&n.push(`filter="url(#${o})"`),`<path d="${e}" ${n.join(" ")} />`}_line(t){let e=[];t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`);let n=this.#a(t.dash,t.dashed,t.strokeWidth);n&&(e.push(`stroke-dasharray="${n.strokeDasharray}"`),n.strokeLinecap&&e.push(`stroke-linecap="${n.strokeLinecap}"`)),t.opacity!==void 0&&e.push(`opacity="${t.opacity}"`),t.id&&e.push(`id="${this._esc(t.id)}"`);let r=this.#s(t);return r&&e.push(`filter="url(#${r})"`),`<line x1="${t.x1}" y1="${t.y1}" x2="${t.x2}" y2="${t.y2}" ${e.join(" ")} />`}_rect(t){let e=[];if(t.hatch){let r=this._hatchPattern(t.hatch,t.fill);e.push(`fill="url(#${r})"`);}else t.fill!==void 0&&e.push(`fill="${this._esc(t.fill)}"`);t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`),t.opacity!==void 0&&e.push(`opacity="${t.opacity}"`),t.dashed&&e.push('stroke-dasharray="4,4"'),t.id&&e.push(`id="${this._esc(t.id)}"`);let n=this.#s(t);return n&&e.push(`filter="url(#${n})"`),`<rect x="${t.x}" y="${t.y}" width="${t.w}" height="${t.h}" ${e.join(" ")} />`}_circle(t){let e=[];if(t.hatch){let r=this._hatchPattern(t.hatch,t.fill);e.push(`fill="url(#${r})"`);}else t.fill&&e.push(`fill="${this._esc(t.fill)}"`);t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`),t.id&&e.push(`id="${this._esc(t.id)}"`);let n=this.#s(t);return n&&e.push(`filter="url(#${n})"`),`<circle cx="${t.cx}" cy="${t.cy}" r="${t.r}" ${e.join(" ")} />`}#a(t,e,n){return Pt(t,n??2,e)}#s(t){if(!t.shadowColor)return null;let e=t.shadowBlur??0,n=t.shadowOffsetX??0,r=t.shadowOffsetY??0;if(!e&&!n&&!r)return null;let o=`shadow_${e}_${n}_${r}`;if(this.#i.has(o))return o;let a=`<filter id="${o}" x="-50%" y="-50%" width="200%" height="200%">
32
+ <feDropShadow dx="${n}" dy="${r}" stdDeviation="${e/2}" flood-color="${this._esc(t.shadowColor)}" />
33
+ </filter>`;return this.#i.set(o,a),o}#h(t,e,n,r,o){this.#r.has(t)||this.#r.set(t,`<clipPath id="${t}">
34
+ <rect x="${e}" y="${n}" width="${r}" height="${o}" />
35
+ </clipPath>`);}#d(t){let e=[];return t.anchor&&e.push(`text-anchor="${t.anchor}"`),t.fontSize&&e.push(`font-size="${t.fontSize}"`),t.fontFamily&&e.push(`font-family="${this._esc(t.fontFamily)}"`),t.fill&&e.push(`fill="${this._esc(t.fill)}"`),t.opacity!=null&&e.push(`opacity="${t.opacity}"`),t.rotate&&e.push(`transform="rotate(${t.rotate} ${t.x} ${t.y})"`),t.textBaseline&&e.push(`dominant-baseline="${Oe(t.textBaseline)}"`),t.id&&e.push(`id="${this._esc(t.id)}"`),`<text x="${t.x}" y="${t.y}" ${e.join(" ")}>${this._esc(t.content)}</text>`}_gradient(t){let e=`grad-${Math.random().toString(36).slice(2,8)}`,n=t.stops.map(r=>` <stop offset="${r.offset}" stop-color="${this._esc(r.color)}" />`).join(`
36
36
  `);return `<linearGradient id="${e}" gradientUnits="userSpaceOnUse">
37
37
  ${n}
38
38
  </linearGradient>
39
- <path d="${t.points.map(o=>`${o.x},${o.y}`).join(" ")}" fill="url(#${e})" />`}_gap(t){if(t.style==="empty")return "";let e=[`stroke="${this._esc("#999")}"`,'stroke-dasharray="4,4"','fill="none"'];return t.style==="label"&&t.label?`<g class="gap">
39
+ <path d="${t.points.map(r=>`${r.x},${r.y}`).join(" ")}" fill="url(#${e})" />`}_gap(t){if(t.style==="empty")return "";let e=[`stroke="${this._esc("#999")}"`,'stroke-dasharray="4,4"','fill="none"'];return t.style==="label"&&t.label?`<g class="gap">
40
40
  <rect x="${t.x1}" y="${t.y1}" width="${t.x2-t.x1}" height="${t.y2-t.y1}" ${e.join(" ")} />
41
41
  <text x="${t.x1}" y="${t.y1-4}" fill="#999" font-size="10">${this._esc(t.label)}</text>
42
- </g>`:`<rect x="${t.x1}" y="${t.y1}" width="${t.x2-t.x1}" height="${t.y2-t.y1}" ${e.join(" ")} />`}_group(t){t.clipRect&&this.#h("clip-plot",t.clipRect.x,t.clipRect.y,t.clipRect.w,t.clipRect.h);let e=t.commands.map(a=>` ${this._toSVG(a).replaceAll(/\n {3}/g,`
42
+ </g>`:`<rect x="${t.x1}" y="${t.y1}" width="${t.x2-t.x1}" height="${t.y2-t.y1}" ${e.join(" ")} />`}_group(t){t.clipRect&&this.#h("clip-plot",t.clipRect.x,t.clipRect.y,t.clipRect.w,t.clipRect.h);let e=t.commands.map(s=>` ${this._toSVG(s).replaceAll(/\n {3}/g,`
43
43
  `)}`).join(`
44
- `),n=t.cssClass?` class="${this._esc(t.cssClass)}"`:"",o=t.id?` id="${this._esc(t.id)}"`:"",r=t.plotClipId||(t.clipRect?"clip-plot":null),s=r?` clip-path="url(#${this._esc(r)})"`:"";return `<g${n}${o}${s}>
44
+ `),n=t.cssClass?` class="${this._esc(t.cssClass)}"`:"",r=t.id?` id="${this._esc(t.id)}"`:"",o=t.plotClipId||(t.clipRect?"clip-plot":null),a=o?` clip-path="url(#${this._esc(o)})"`:"";return `<g${n}${r}${a}>
45
45
  ${e}
46
- </g>`}_esc(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}};function Fe(i){return typeof requestAnimationFrame=="function"?requestAnimationFrame(i):setTimeout(()=>i(0),16)}function je(i){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(i):clearTimeout(i);}function me(){let i=0,t=false;return {schedule:e=>{t||(t=true,i=Fe(()=>{t=false,e();}));},cancel:()=>{t&&(t=false,je(i));}}}var ue="http://www.w3.org/2000/svg";function Oe(i){let t=i.style?.line;return t&&!Array.isArray(t)&&t.color?t.color:g.stroke}function ce(i){return i.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function He(i){if(i.length===0)return "";let t=new Date(i[0].time).toLocaleString(),e=i.map(n=>`<div><span class="mlc-tooltip__name">${ce(n.series.name)}:</span> ${n.value.toFixed(2)}</div>`);return `<div class="mlc-tooltip__time">${ce(t)}</div>${e.join("")}`}function Re(i,t){if(i.length===0)return;let e=0,n=i.length-1;for(;e<n;){let s=e+n>>1;i[s].time<t?e=s+1:n=s;}let o=i[Math.max(0,e-1)],r=i[e];return Math.abs(o.time-t)<=Math.abs(r.time-t)?o:r}function We(i){return "value"in i?i.value:i.avg}function at(i,t,e={}){let n=i.querySelector("svg");if(!n)throw new Error("attachTooltip: target has no <svg> child (did you mount the chart first?)");let o=e.format??He,r=e.snapRadius??1/0,s=e.className??"mlc-tooltip",a=e.showPicks??true,h=e.pickRadius??5,l=e.picksClassName??"mlc-tooltip-picks",d=document.createElement("div");d.className=s,d.style.position="absolute",d.style.pointerEvents="none",d.style.display="none",getComputedStyle(i).position==="static"&&(i.style.position="relative"),i.appendChild(d);let u=null;a&&(u=document.createElementNS(ue,"g"),u.setAttribute("class",l),u.setAttribute("pointer-events","none"),n.appendChild(u));let m=()=>{u&&u.replaceChildren();},c=t.series.map((P,L)=>({data:P.data.map(B=>({time:B.time,value:We(B)})).filter(B=>B.value!==null).sort((B,G)=>B.time-G.time),series:P,index:L})),f=me(),y=null,b=P=>{let L=n.getBoundingClientRect(),W=t.getWidth?.()??L.width,B=(P.clientX-L.left)*W/Math.max(1,L.width);t.getHeight?.()??L.height;let I=t.invertTime(B);if(!Number.isFinite(I)){d.style.display="none";return}let S=[];for(let F of c){let T=Re(F.data,I);if(!T)continue;let O=t.project(T.time,T.value,F.series.yAxisIndex??0).x,E=t.project(T.time,T.value,F.series.yAxisIndex??0).y;Math.abs(O-B)>r||S.push({seriesIndex:F.index,series:F.series,time:T.time,value:T.value,x:O,y:E});}if(S.length===0){d.style.display="none",m();return}d.innerHTML=o(S);let v=i.getBoundingClientRect(),k=12,$=(P.clientX-L.left)/Math.max(1,L.width),j=(P.clientY-L.top)/Math.max(1,L.height),H=$<.5?`${k}px`:`calc(-100% - ${k}px)`,Y=j<.5?`${k}px`:`calc(-100% - ${k}px)`;if(d.style.left=`${P.clientX-v.left}px`,d.style.top=`${P.clientY-v.top}px`,d.style.transform=`translate(${H}, ${Y})`,d.style.display="",u){u.replaceChildren();for(let F of S){let T=document.createElementNS(ue,"circle");T.setAttribute("cx",String(F.x)),T.setAttribute("cy",String(F.y)),T.setAttribute("r",String(h)),T.setAttribute("fill","#ffffff"),T.setAttribute("stroke",Oe(F.series)),T.setAttribute("stroke-width","2"),T.setAttribute("class",`${l}__dot`),u.appendChild(T);}}},_=P=>{y=P,f.schedule(()=>{y&&b(y);});},C=()=>{y=null,f.cancel(),d.style.display="none",m();};n.addEventListener("mousemove",_),n.addEventListener("mouseleave",C);let N=false;return ()=>{N||(N=true,y=null,f.cancel(),n.removeEventListener("mousemove",_),n.removeEventListener("mouseleave",C),d.remove(),u&&u.remove());}}function Ie(i,t={}){let e=typeof i=="string"?document.querySelector(i):i;if(!e)throw new Error(`mount: target ${typeof i=="string"?`'${i}'`:""} not found`);let{tooltip:n,...o}=t,r=o.width??e.clientWidth??800,s=o.height??350,a=new K({...o,width:r,height:s}),{content:h}=new q().render(a.renderCommands());e.innerHTML=h;let l=e.querySelector("svg");return l&&(l.setAttribute("viewBox",`0 0 ${r} ${a.getHeight()}`),l.setAttribute("width","100%"),l.setAttribute("height",String(a.getHeight()))),n?.show&&at(e,a,n),a}var bt=class{_opts;_series=[];_thresholds=[];_annotations=[];_highlights=[];_markers=[];_bands=[];_tooltip;constructor(t,e){this._opts={},t!==void 0&&(this._opts.width=t),e!==void 0&&(this._opts.height=e);}setWidth(t){return this._opts.width=t,this}setHeight(t){return this._opts.height=t,this}setSize(t,e){return this._opts.width=t,this._opts.height=e,this}setMargin(t,e,n,o){return typeof t=="object"?this._opts.margin=t:this._opts.margin={top:t,right:e??0,bottom:n??0,left:o??0},this}setLocale(t){return this._opts.locale=t,this}setAxes(t){return this._opts.axes=t,this}setXAxis(t){return this._opts.axes={...this._opts.axes,x:{...this._opts.axes?.x,...t}},this}setLeftAxis(t){return this._opts.axes={...this._opts.axes,left:{...this._opts.axes?.left,...t}},this}setRightAxis(t){return this._opts.axes={...this._opts.axes,right:{...this._opts.axes?.right,...t}},this}setYAxis(t,e){this._opts.axes??={},this._opts.axes.y??=[];let n=[...this._opts.axes.y];for(;n.length<=t;)n.push({});return n[t]={...n[t],...e},this._opts.axes.y=n,this}setLegend(t,e,n){return typeof t=="object"?this._opts.legend=t:this._opts.legend={show:t,position:e,orientation:n},this}setGaps(t){return this._opts.gaps=t,this}setTooltip(t){return this._tooltip={show:true,...t},this}addSeries(t){return this._series.push(t),this}addSeriesAll(t){return this._series.push(...t),this}addThreshold(t){return this._thresholds.push(t),this}addThresholds(t){return this._thresholds.push(...t),this}addAnnotation(t){return this._annotations.push(t),this}addAnnotations(t){return this._annotations.push(...t),this}addHighlight(t){return this._highlights.push(t),this}addMarker(t){return this._markers.push(t),this}addAnnotationBand(t){return this._bands.push(t),this}clear(t){return (!t||t==="series")&&(this._series=[]),(!t||t==="thresholds")&&(this._thresholds=[]),(!t||t==="annotations")&&(this._annotations=[]),(!t||t==="highlights")&&(this._highlights=[]),(!t||t==="markers")&&(this._markers=[]),(!t||t==="bands")&&(this._bands=[]),this}toOptions(){return {...this._opts,series:this._series.length?this._series:this._opts.series,thresholds:this._thresholds.length?this._thresholds:this._opts.thresholds,annotations:this._annotations.length?this._annotations:this._opts.annotations,highlights:this._highlights.length?this._highlights:this._opts.highlights,markers:this._markers.length?this._markers:this._opts.markers,annotationBands:this._bands.length?this._bands:this._opts.annotationBands}}build(){return new K(this.toOptions())}getSvg(){let t=this.build(),{content:e}=new q().render(t.renderCommands());return e}mount(t){let e=typeof t=="string"?document.querySelector(t):t;if(!e){let s=typeof t=="string"?`'${t}'`:"";throw new Error(`GraphBuilder.mount: target ${s} not found`)}this._opts.width||(this._opts.width=e.clientWidth||800);let n=this.build(),{content:o}=new q().render(n.renderCommands());e.innerHTML=o;let r=e.querySelector("svg");if(r){let s=this._opts.width??800;r.setAttribute("viewBox",`0 0 ${s} ${n.getHeight()}`),r.setAttribute("width","100%"),r.setAttribute("height",String(n.getHeight()));}return this._tooltip?.show&&at(e,n,this._tooltip),n}};var xt=class{_series;constructor(t){this._series={name:t,data:[]};}addPoint(t,e){return this._series.data.push({time:t,value:e}),this}setData(t){return this._series.data=[...t],this}addPoints(t){return this._series.data.push(...t),this}addFloats(t,e){let n=Math.min(t.length,e.length);for(let o=0;o<n;o++)this._series.data.push({time:t[o],value:e[o]});return this}addNullPoint(t){return this._series.data.push({time:t,value:null}),this}setYAxisIndex(t){return this._series.yAxisIndex=t,this}setColor(t){return this._series.style??={},!this._series.style.line||typeof this._series.style.line=="boolean"?this._series.style.line={color:t}:Array.isArray(this._series.style.line)?this._series.style.line.length===0?this._series.style.line=[{color:t}]:this._series.style.line[0].color=t:this._series.style.line.color=t,this}setStyle(t){return this._series.style=t,this}setLineStyle(t,e,n){return this._series.style??={},this._series.style.line={color:t,width:e,style:n},this}setSmoothing(t){return this._series.style??={},!this._series.style.line||typeof this._series.style.line=="boolean"?this._series.style.line={smoothing:t}:Array.isArray(this._series.style.line)?this._series.style.line.length===0?this._series.style.line=[{smoothing:t}]:this._series.style.line[0].smoothing=t:this._series.style.line.smoothing=t,this}setFill(t){return this._series.style??={},this._series.style.fill=t,this}setID(t){return this._series.id=t,this}setColorByThresholds(t){return this._series.colorByThresholds=t,this}build(){return this._series}};var St=class{_threshold;constructor(t,e){this._threshold={name:t,value:e};}setColor(t){return this._threshold.color=t,this}setLine(t){return this._threshold.line=t,this}setFill(t,e){return this._threshold.fill=t,this._threshold.fillOpacity=e,this}setFillHatch(t){return this._threshold.fillHatch=t,this}setLabel(t,e){return this._threshold.label={text:t,position:e},this}setID(t){return this._threshold.id=t,this}build(){return this._threshold}};var _t=class{_marker;constructor(t){this._marker={time:t};}setValue(t){return this._marker.value=t,this}setLabel(t){return this._marker.label=t,this}setColor(t){return this._marker.color=t,this}setPointStyle(t){return this._marker.pointStyle=t,this}setLineStyle(t){return t==="none"?delete this._marker.lineStyle:this._marker.lineStyle=t,this}setSeriesIndex(t){return this._marker.seriesIndex=t,this}build(){return this._marker}};var wt=class{_highlight;constructor(t,e){this._highlight={startTime:t,endTime:e};}setLabel(t){return this._highlight.label=t,this}setColor(t){return this._highlight.color=t,this}setOpacity(t){return this._highlight.opacity=t,this}setLabelPosition(t){return this._highlight.labelPosition=t,this}setRotate(t){return this._highlight.rotate=t,this}build(){return this._highlight}};var vt=class{_ann;constructor(t){this._ann={type:t};}setID(t){return this._ann.id=t,this}setTitle(t){return this._ann.title=t,this}setFrom(t,e,n){return this._ann.from={time:t,value:e,axis:n},this}setTo(t,e,n){return this._ann.to={time:t,value:e,axis:n},this}setAt(t,e,n){return this._ann.at={time:t,value:e,axis:n},this}setColor(t){return this._ann.color=t,this}setWidth(t){return this._ann.width=t,this}setDash(t){return this._ann.dash=t,this}setHeadSize(t){return this._ann.headSize=t,this}setFill(t){return this._ann.fill=t,this}setHatch(t){return this._ann.hatch=t,this}setStroke(t){return this._ann.stroke=t,this}setOpacity(t){return this._ann.opacity=t,this}setRadius(t){return this._ann.radius=t,this}setShape(t){return this._ann.shape=t,this}setText(t){return this._ann.text=t,this}setAnchor(t){return this._ann.anchor=t,this}setDx(t){return this._ann.dx=t,this}setDy(t){return this._ann.dy=t,this}setRotate(t){return this._ann.rotate=t,this}build(){return this._ann}};var kt=class{_band;constructor(t){this._band={name:t,items:[]};}setHeight(t){return this._band.height=t,this}setSpacing(t){return this._band.spacing=t,this}setHatch(t){return this._band.hatch=t,this}setShowAxis(t){return this._band.showAxis=t,this}setShowInLegend(t){return this._band.showInLegend=t,this}setBackground(t){return this._band.background=t,this}addItem(t){return this._band.items.push(t),this}build(){return this._band}},Ct=class{_item;constructor(t,e){this._item={startTime:t,endTime:e};}setFill(t){return this._item.fill=t,this}setHatch(t){return this._item.hatch=t,this}setStroke(t){return this._item.stroke=t,this}setStrokeWidth(t){return this._item.strokeWidth=t,this}setLabel(t,e,n,o){return this._item.label=t,e!==void 0&&(this._item.labelFontSize=e),n!==void 0&&(this._item.labelFill=n),o!==void 0&&(this._item.labelBaseline=o),this}build(){return this._item}};function Ge(i){let{thresholds:t,colors:e,hatches:n}=i;if(e.length!==t.length+1)throw new Error(`fillBetweenThresholds: expected ${t.length+1} colors for ${t.length} thresholds, got ${e.length}`);if(n!==void 0&&n.length!==e.length)throw new Error(`fillBetweenThresholds: hatches length (${n.length}) must equal colors length (${e.length})`);return {regions:e.map((r,s)=>{let a=n?.[s],h=a?{color:r,hatch:a}:r;return s===0?{to:{threshold:t[0]},fill:h}:s===e.length-1?{from:{threshold:t[t.length-1]},fill:h}:{from:{threshold:t[s-1]},to:{threshold:t[s]},fill:h}})}}function Ot(i){if(!i||typeof i!="object")throw new Error("DataPoint: object expected");let{time:t,value:e,annotation:n}=i;if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`DataPoint: invalid time=${t}`);if(e!==null&&(typeof e!="number"||Number.isNaN(e)))throw new Error(`DataPoint: invalid value=${e}`);return {time:t,value:e,annotation:n&&typeof n=="string"?n:void 0}}function Ee(i){if(Array.isArray(i))return i.map(Ot);if(i&&typeof i=="object"){let t=i,e=t.name,n=t.data,o=t.sensorType,r=t.enumMap,s=t.color,a=t.lineWidth,h=t.smoothing,l=t.seriesType;if(!e||!e.length)throw new Error("Series: name required");if(!Array.isArray(n))throw new Error("Series: data must be an array");let d=s!==void 0||a!==void 0||h!==void 0?{color:s,width:a,smoothing:h}:void 0;return {name:e,data:n.map(Ot),sensorType:o??"numeric",enumMap:r,seriesType:l,...d&&{style:{line:d}}}}throw new Error("parseSeries: object or DataPoint[] expected")}function Ve(i){if(!i||typeof i!="object")throw new Error("parseAggregated: object expected");let t=i,e=t.name,n=t.data,o=t.showAs,r=t.avgLine,s=t.countOpacity,a=t.color;if(!e?.length)throw new Error("AggregatedSeries: name required");if(!Array.isArray(n))throw new Error("AggregatedSeries: data must be an array");return {name:e,data:Ne(n),showAs:o,avgLine:r,countOpacity:s,...a!==void 0&&{style:{line:{color:a},fill:a}}}}function Ne(i){let t=e=>typeof e=="number"?e:null;return i.map(e=>{let n=e;return {time:n.time??0,min:t(n.min),max:t(n.max),avg:t(n.avg),count:typeof n.count=="number"?n.count:0}})}/*!
46
+ </g>`}_esc(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}};function We(i){return typeof requestAnimationFrame=="function"?requestAnimationFrame(i):setTimeout(()=>i(0),16)}function He(i){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(i):clearTimeout(i);}function ue(){let i=0,t=false;return {schedule:e=>{t||(t=true,i=We(()=>{t=false,e();}));},cancel:()=>{t&&(t=false,He(i));}}}var ce="http://www.w3.org/2000/svg";function Re(i){let t=i.style?.line;return t&&!Array.isArray(t)&&t.color?t.color:g.stroke}function pe(i){return i.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function Ie(i){if(i.length===0)return "";let t=new Date(i[0].time).toLocaleString(),e=i.map(n=>`<div><span class="mlc-tooltip__name">${pe(n.series.name)}:</span> ${n.value.toFixed(2)}</div>`);return `<div class="mlc-tooltip__time">${pe(t)}</div>${e.join("")}`}function Ge(i,t){if(i.length===0)return;let e=0,n=i.length-1;for(;e<n;){let a=e+n>>1;i[a].time<t?e=a+1:n=a;}let r=i[Math.max(0,e-1)],o=i[e];return Math.abs(r.time-t)<=Math.abs(o.time-t)?r:o}function Ee(i){return "value"in i?i.value:i.avg}function at(i,t,e={}){let n=i.querySelector("svg");if(!n)throw new Error("attachTooltip: target has no <svg> child (did you mount the chart first?)");let r=e.format??Ie,o=e.snapRadius??1/0,a=e.className??"mlc-tooltip",s=e.showPicks??true,l=e.pickRadius??5,h=e.picksClassName??"mlc-tooltip-picks",d=document.createElement("div");d.className=a,d.style.position="absolute",d.style.pointerEvents="none",d.style.display="none",getComputedStyle(i).position==="static"&&(i.style.position="relative"),i.appendChild(d);let u=null;s&&(u=document.createElementNS(ce,"g"),u.setAttribute("class",h),u.setAttribute("pointer-events","none"),n.appendChild(u));let m=()=>{u&&u.replaceChildren();},c=t.series.map((P,M)=>({data:P.data.map(B=>({time:B.time,value:Ee(B)})).filter(B=>B.value!==null).sort((B,G)=>B.time-G.time),series:P,index:M})),f=ue(),y=null,b=P=>{let M=n.getBoundingClientRect(),R=t.getWidth?.()??M.width,B=(P.clientX-M.left)*R/Math.max(1,M.width);t.getHeight?.()??M.height;let I=t.invertTime(B);if(!Number.isFinite(I)){d.style.display="none";return}let S=[];for(let F of c){let T=Ge(F.data,I);if(!T)continue;let O=t.project(T.time,T.value,F.series.yAxisIndex??0).x,E=t.project(T.time,T.value,F.series.yAxisIndex??0).y;Math.abs(O-B)>o||S.push({seriesIndex:F.index,series:F.series,time:T.time,value:T.value,x:O,y:E});}if(S.length===0){d.style.display="none",m();return}d.innerHTML=r(S);let v=i.getBoundingClientRect(),k=12,$=(P.clientX-M.left)/Math.max(1,M.width),j=(P.clientY-M.top)/Math.max(1,M.height),W=$<.5?`${k}px`:`calc(-100% - ${k}px)`,Y=j<.5?`${k}px`:`calc(-100% - ${k}px)`;if(d.style.left=`${P.clientX-v.left}px`,d.style.top=`${P.clientY-v.top}px`,d.style.transform=`translate(${W}, ${Y})`,d.style.display="",u){u.replaceChildren();for(let F of S){let T=document.createElementNS(ce,"circle");T.setAttribute("cx",String(F.x)),T.setAttribute("cy",String(F.y)),T.setAttribute("r",String(l)),T.setAttribute("fill","#ffffff"),T.setAttribute("stroke",Re(F.series)),T.setAttribute("stroke-width","2"),T.setAttribute("class",`${h}__dot`),u.appendChild(T);}}},_=P=>{y=P,f.schedule(()=>{y&&b(y);});},C=()=>{y=null,f.cancel(),d.style.display="none",m();};n.addEventListener("mousemove",_),n.addEventListener("mouseleave",C);let N=false;return ()=>{N||(N=true,y=null,f.cancel(),n.removeEventListener("mousemove",_),n.removeEventListener("mouseleave",C),d.remove(),u&&u.remove());}}function Ve(i,t={}){let e=typeof i=="string"?document.querySelector(i):i;if(!e)throw new Error(`mount: target ${typeof i=="string"?`'${i}'`:""} not found`);let{tooltip:n,...r}=t,o=r.width??e.clientWidth??800,a=r.height??350,s=new K({...r,width:o,height:a}),{content:l}=new q().render(s.renderCommands());e.innerHTML=l;let h=e.querySelector("svg");return h&&(h.setAttribute("viewBox",`0 0 ${o} ${s.getHeight()}`),h.setAttribute("width","100%"),h.setAttribute("height",String(s.getHeight()))),n?.show&&at(e,s,n),s}var xt=class{_opts;_series=[];_thresholds=[];_annotations=[];_highlights=[];_markers=[];_bands=[];_tooltip;constructor(t,e){this._opts={},t!==void 0&&(this._opts.width=t),e!==void 0&&(this._opts.height=e);}setWidth(t){return this._opts.width=t,this}setHeight(t){return this._opts.height=t,this}setSize(t,e){return this._opts.width=t,this._opts.height=e,this}setMargin(t,e,n,r){return typeof t=="object"?this._opts.margin=t:this._opts.margin={top:t,right:e??0,bottom:n??0,left:r??0},this}setLocale(t){return this._opts.locale=t,this}setAxes(t){return this._opts.axes=t,this}setXAxis(t){return this._opts.axes={...this._opts.axes,x:{...this._opts.axes?.x,...t}},this}setLeftAxis(t){return this._opts.axes={...this._opts.axes,left:{...this._opts.axes?.left,...t}},this}setRightAxis(t){return this._opts.axes={...this._opts.axes,right:{...this._opts.axes?.right,...t}},this}setYAxis(t,e){this._opts.axes??={},this._opts.axes.y??=[];let n=[...this._opts.axes.y];for(;n.length<=t;)n.push({});return n[t]={...n[t],...e},this._opts.axes.y=n,this}setLegend(t,e,n){return typeof t=="object"?this._opts.legend=t:this._opts.legend={show:t,position:e,orientation:n},this}setGaps(t){return this._opts.gaps=t,this}setTooltip(t){return this._tooltip={show:true,...t},this}addSeries(t){return this._series.push(t),this}addSeriesAll(t){return this._series.push(...t),this}addThreshold(t){return this._thresholds.push(t),this}addThresholds(t){return this._thresholds.push(...t),this}addAnnotation(t){return this._annotations.push(t),this}addAnnotations(t){return this._annotations.push(...t),this}addHighlight(t){return this._highlights.push(t),this}addMarker(t){return this._markers.push(t),this}addAnnotationBand(t){return this._bands.push(t),this}clear(t){return (!t||t==="series")&&(this._series=[]),(!t||t==="thresholds")&&(this._thresholds=[]),(!t||t==="annotations")&&(this._annotations=[]),(!t||t==="highlights")&&(this._highlights=[]),(!t||t==="markers")&&(this._markers=[]),(!t||t==="bands")&&(this._bands=[]),this}toOptions(){return {...this._opts,series:this._series.length?this._series:this._opts.series,thresholds:this._thresholds.length?this._thresholds:this._opts.thresholds,annotations:this._annotations.length?this._annotations:this._opts.annotations,highlights:this._highlights.length?this._highlights:this._opts.highlights,markers:this._markers.length?this._markers:this._opts.markers,annotationBands:this._bands.length?this._bands:this._opts.annotationBands}}build(){return new K(this.toOptions())}getSvg(){let t=this.build(),{content:e}=new q().render(t.renderCommands());return e}mount(t){let e=typeof t=="string"?document.querySelector(t):t;if(!e){let a=typeof t=="string"?`'${t}'`:"";throw new Error(`GraphBuilder.mount: target ${a} not found`)}this._opts.width||(this._opts.width=e.clientWidth||800);let n=this.build(),{content:r}=new q().render(n.renderCommands());e.innerHTML=r;let o=e.querySelector("svg");if(o){let a=this._opts.width??800;o.setAttribute("viewBox",`0 0 ${a} ${n.getHeight()}`),o.setAttribute("width","100%"),o.setAttribute("height",String(n.getHeight()));}return this._tooltip?.show&&at(e,n,this._tooltip),n}};var St=class{_series;constructor(t){this._series={name:t,data:[]};}addPoint(t,e){return this._series.data.push({time:t,value:e}),this}setData(t){return this._series.data=[...t],this}addPoints(t){return this._series.data.push(...t),this}addFloats(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++)this._series.data.push({time:t[r],value:e[r]});return this}addNullPoint(t){return this._series.data.push({time:t,value:null}),this}setYAxisIndex(t){return this._series.yAxisIndex=t,this}setColor(t){return this._series.style??={},!this._series.style.line||typeof this._series.style.line=="boolean"?this._series.style.line={color:t}:Array.isArray(this._series.style.line)?this._series.style.line.length===0?this._series.style.line=[{color:t}]:this._series.style.line[0].color=t:this._series.style.line.color=t,this}setStyle(t){return this._series.style=t,this}setLineStyle(t,e,n){return this._series.style??={},this._series.style.line={color:t,width:e,style:n},this}setSmoothing(t){return this._series.style??={},!this._series.style.line||typeof this._series.style.line=="boolean"?this._series.style.line={smoothing:t}:Array.isArray(this._series.style.line)?this._series.style.line.length===0?this._series.style.line=[{smoothing:t}]:this._series.style.line[0].smoothing=t:this._series.style.line.smoothing=t,this}setFill(t){return this._series.style??={},this._series.style.fill=t,this}setID(t){return this._series.id=t,this}setColorByThresholds(t){return this._series.colorByThresholds=t,this}build(){return this._series}};var _t=class{_threshold;constructor(t,e){this._threshold={name:t,value:e};}setColor(t){return this._threshold.color=t,this}setLine(t){return this._threshold.line=t,this}setFill(t,e){return this._threshold.fill=t,this._threshold.fillOpacity=e,this}setFillHatch(t){return this._threshold.fillHatch=t,this}setLabel(t,e){return this._threshold.label={text:t,position:e},this}setID(t){return this._threshold.id=t,this}build(){return this._threshold}};var wt=class{_marker;constructor(t){this._marker={time:t};}setValue(t){return this._marker.value=t,this}setLabel(t){return this._marker.label=t,this}setColor(t){return this._marker.color=t,this}setPointStyle(t){return this._marker.pointStyle=t,this}setLineStyle(t){return t==="none"?delete this._marker.lineStyle:this._marker.lineStyle=t,this}setSeriesIndex(t){return this._marker.seriesIndex=t,this}build(){return this._marker}};var vt=class{_highlight;constructor(t,e){this._highlight={startTime:t,endTime:e};}setLabel(t){return this._highlight.label=t,this}setColor(t){return this._highlight.color=t,this}setOpacity(t){return this._highlight.opacity=t,this}setLabelPosition(t){return this._highlight.labelPosition=t,this}setRotate(t){return this._highlight.rotate=t,this}build(){return this._highlight}};var kt=class{_ann;constructor(t){this._ann={type:t};}setID(t){return this._ann.id=t,this}setTitle(t){return this._ann.title=t,this}setFrom(t,e,n){return this._ann.from={time:t,value:e,axis:n},this}setTo(t,e,n){return this._ann.to={time:t,value:e,axis:n},this}setAt(t,e,n){return this._ann.at={time:t,value:e,axis:n},this}setColor(t){return this._ann.color=t,this}setWidth(t){return this._ann.width=t,this}setDash(t){return this._ann.dash=t,this}setHeadSize(t){return this._ann.headSize=t,this}setFill(t){return this._ann.fill=t,this}setHatch(t){return this._ann.hatch=t,this}setStroke(t){return this._ann.stroke=t,this}setOpacity(t){return this._ann.opacity=t,this}setRadius(t){return this._ann.radius=t,this}setShape(t){return this._ann.shape=t,this}setText(t){return this._ann.text=t,this}setAnchor(t){return this._ann.anchor=t,this}setDx(t){return this._ann.dx=t,this}setDy(t){return this._ann.dy=t,this}setRotate(t){return this._ann.rotate=t,this}build(){return this._ann}};var Ct=class{_band;constructor(t){this._band={name:t,items:[]};}setHeight(t){return this._band.height=t,this}setSpacing(t){return this._band.spacing=t,this}setHatch(t){return this._band.hatch=t,this}setShowAxis(t){return this._band.showAxis=t,this}setShowInLegend(t){return this._band.showInLegend=t,this}setBackground(t){return this._band.background=t,this}addItem(t){return this._band.items.push(t),this}build(){return this._band}},Tt=class{_item;constructor(t,e){this._item={startTime:t,endTime:e};}setFill(t){return this._item.fill=t,this}setHatch(t){return this._item.hatch=t,this}setStroke(t){return this._item.stroke=t,this}setStrokeWidth(t){return this._item.strokeWidth=t,this}setLabel(t,e,n,r){return this._item.label=t,e!==void 0&&(this._item.labelFontSize=e),n!==void 0&&(this._item.labelFill=n),r!==void 0&&(this._item.labelBaseline=r),this}build(){return this._item}};function Ne(i){let{thresholds:t,colors:e,hatches:n}=i;if(e.length!==t.length+1)throw new Error(`fillBetweenThresholds: expected ${t.length+1} colors for ${t.length} thresholds, got ${e.length}`);if(n!==void 0&&n.length!==e.length)throw new Error(`fillBetweenThresholds: hatches length (${n.length}) must equal colors length (${e.length})`);return {regions:e.map((o,a)=>{let s=n?.[a],l=s?{color:o,hatch:s}:o;return a===0?{to:{threshold:t[0]},fill:l}:a===e.length-1?{from:{threshold:t[t.length-1]},fill:l}:{from:{threshold:t[a-1]},to:{threshold:t[a]},fill:l}})}}function Wt(i){if(!i||typeof i!="object")throw new Error("DataPoint: object expected");let{time:t,value:e,annotation:n}=i;if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`DataPoint: invalid time=${t}`);if(e!==null&&(typeof e!="number"||Number.isNaN(e)))throw new Error(`DataPoint: invalid value=${e}`);return {time:t,value:e,annotation:n&&typeof n=="string"?n:void 0}}function Ye(i){if(Array.isArray(i))return i.map(Wt);if(i&&typeof i=="object"){let t=i,e=t.name,n=t.data,r=t.sensorType,o=t.enumMap,a=t.color,s=t.lineWidth,l=t.smoothing,h=t.seriesType;if(!e||!e.length)throw new Error("Series: name required");if(!Array.isArray(n))throw new Error("Series: data must be an array");let d=a!==void 0||s!==void 0||l!==void 0?{color:a,width:s,smoothing:l}:void 0;return {name:e,data:n.map(Wt),sensorType:r??"numeric",enumMap:o,seriesType:h,...d&&{style:{line:d}}}}throw new Error("parseSeries: object or DataPoint[] expected")}function ze(i){if(!i||typeof i!="object")throw new Error("parseAggregated: object expected");let t=i,e=t.name,n=t.data,r=t.showAs,o=t.avgLine,a=t.countOpacity,s=t.color;if(!e?.length)throw new Error("AggregatedSeries: name required");if(!Array.isArray(n))throw new Error("AggregatedSeries: data must be an array");return {name:e,data:qe(n),showAs:r,avgLine:o,countOpacity:a,...s!==void 0&&{style:{line:{color:s},fill:s}}}}function qe(i){let t=e=>typeof e=="number"?e:null;return i.map(e=>{let n=e;return {time:n.time??0,min:t(n.min),max:t(n.max),avg:t(n.avg),count:typeof n.count=="number"?n.count:0}})}/*!
47
47
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
48
48
  * MIT with Attribution: free use incl. commercial requires visible credit to
49
49
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
@@ -62,4 +62,4 @@ ${e}
62
62
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
63
63
  * MIT with Attribution: free use incl. commercial must have visible credit to
64
64
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
65
- */export{kt as AnnotationBandBuilder,Ct as AnnotationBandItemBuilder,vt as AnnotationBuilder,bt as GraphBuilder,wt as HighlightBuilder,K as MLTimeGraph,_t as MarkerBuilder,q as SVGRenderer,St as ThresholdBuilder,xt as TimeSeriesBuilder,at as attachTooltip,Ge as fillBetweenThresholds,Q as getDefaultTheme,Ie as mount,Ve as parseAggregated,Ot as parseDataPoint,Ee as parseSeries,be as resetDefaultTheme,ye as setDefaultTheme};
65
+ */export{Ct as AnnotationBandBuilder,Tt as AnnotationBandItemBuilder,kt as AnnotationBuilder,xt as GraphBuilder,vt as HighlightBuilder,K as MLTimeGraph,wt as MarkerBuilder,q as SVGRenderer,_t as ThresholdBuilder,St as TimeSeriesBuilder,at as attachTooltip,ut as drawMarker,Ne as fillBetweenThresholds,Q as getDefaultTheme,Vt as getLineStyle,Ve as mount,ze as parseAggregated,Wt as parseDataPoint,Ye as parseSeries,xe as resetDefaultTheme,Pt as resolveDash,be as setDefaultTheme};
@@ -1,4 +1,4 @@
1
- import { l as DataPoint, D as DrawCommand, d as TimeScale, e as LinearScale } from '../scale-CWAa8-uO.js';
1
+ import { l as DataPoint, D as DrawCommand, d as TimeScale, e as LinearScale } from '../scale-ByGpczxS.js';
2
2
 
3
3
  /*!
4
4
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -1,7 +1,7 @@
1
- import { T as Theme, M as Marker } from './layout-3caueyKS.js';
2
- export { d as Layout, e as LayoutConfig, b as LayoutResult, f as LegendConfig, a as LegendItem, L as LegendOrientation, R as Renderer, m as measureLegend, h as renderLegend } from './layout-3caueyKS.js';
3
- import { j as AggregatedPoint, d as TimeScale, e as LinearScale, P as PointStyleType, D as DrawCommand, l as DataPoint, T as Threshold, G as Gap, g as HatchVariant, H as Highlight, b as Annotation, E as EnumMap, O as BandScale, Q as Point, i as AnnotationBandItem, L as LineVariant, F as FillSpec, x as GapStyle, f as TimeSeries } from './scale-CWAa8-uO.js';
4
- export { R as AxisOrientation, U as AxisPosition, V as BandScaleConfig, W as CircleParams, X as Dashstyle_t, Y as DomainScaleConfig, Z as DrawCircle, _ as DrawGap, $ as DrawGapType_t, a0 as DrawGradient, a1 as DrawGroup, a2 as DrawLine, a3 as DrawPath, a4 as DrawRect, a5 as DrawText, a6 as LabelAnchor, a7 as LineParams, a8 as LinearScaleConfig, a9 as PathParams, aa as RectParams, ab as Scale, ac as ScaleConfig, ad as TIME_INTERVALS, ae as TextParams, af as TimeScaleConfig, ag as getHatch } from './scale-CWAa8-uO.js';
1
+ import { T as Theme, M as Marker } from './series_renderer-BxGvCHMY.js';
2
+ export { e as Layout, f as LayoutConfig, b as LayoutResult, h as LegendConfig, a as LegendItem, L as LegendOrientation, R as Renderer, m as measureLegend, i as renderArea, j as renderLegend, k as renderLine, l as renderSeriesMarkers, n as renderSplitLine, o as renderStep, p as renderZonedArea } from './series_renderer-BxGvCHMY.js';
3
+ import { D as DrawCommand, T as Threshold, e as LinearScale, G as Gap, d as TimeScale, g as HatchVariant, H as Highlight, b as Annotation, E as EnumMap, U as BandScale, l as DataPoint, P as PointStyleType, V as Point, j as AggregatedPoint, i as AnnotationBandItem, L as LineVariant, F as FillSpec, x as GapStyle, f as TimeSeries } from './scale-ByGpczxS.js';
4
+ export { W as AxisOrientation, X as AxisPosition, Y as BandScaleConfig, Z as CircleParams, _ as Dashstyle_t, $ as DomainScaleConfig, a0 as DrawCircle, a1 as DrawGap, a2 as DrawGapType_t, a3 as DrawGradient, a4 as DrawGroup, a5 as DrawLine, a6 as DrawPath, a7 as DrawRect, a8 as DrawText, a9 as LabelAnchor, aa as LineParams, ab as LinearScaleConfig, ac as PathParams, ad as RectParams, ae as Scale, af as ScaleConfig, ag as TIME_INTERVALS, ah as TextParams, ai as TimeScaleConfig, aj as getHatch } from './scale-ByGpczxS.js';
5
5
 
6
6
  /*!
7
7
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -11,94 +11,6 @@ export { R as AxisOrientation, U as AxisPosition, V as BandScaleConfig, W as Cir
11
11
 
12
12
  declare const theme: Theme;
13
13
 
14
- /*!
15
- * MLTimeGraph — Copyright (c) 2026 Michael Lechner
16
- * MIT with Attribution: free use incl. commercial requires visible credit to
17
- * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
18
- */
19
-
20
- /**
21
- * Flat style configuration for series rendering.
22
- * All fields are optional — defaults are applied internally via `resolveStyle()`.
23
- */
24
- interface SeriesStyle {
25
- /** Stroke color. */
26
- stroke?: string;
27
- /** Stroke width in pixels. */
28
- strokeWidth?: number;
29
- /** Enable Catmull-Rom smoothing. */
30
- smoothing?: boolean;
31
- /** Enable dashed line style. */
32
- dashed?: boolean;
33
- /** Fill colour (hex, rgba, or `url(#gradient-id)`). */
34
- fill?: string;
35
- /** Hatch pattern for fill (default: none). */
36
- hatch?: string;
37
- /** Data-point marker style. */
38
- pointStyle?: PointStyleType;
39
- /** Marker size (radius or half-width). */
40
- pointSize?: number;
41
- /** Marker outline colour. Default: same as the line's stroke (per-point). */
42
- pointStroke?: string;
43
- /** Marker fill colour. Default: same as the line's stroke. */
44
- pointFill?: string;
45
- /** Marker outline width. Default: 1.5. */
46
- pointStrokeWidth?: number;
47
- /** Shadow color. */
48
- shadowColor?: string;
49
- /** Shadow blur in pixels. */
50
- shadowBlur?: number;
51
- /** Shadow X offset. */
52
- shadowOffsetX?: number;
53
- /** Shadow Y offset. */
54
- shadowOffsetY?: number;
55
- /** SVG id prefix for all elements generated by this style. */
56
- id?: string;
57
- }
58
- interface RenderingContext {
59
- timeScale: TimeScale;
60
- valueScale: LinearScale;
61
- }
62
- /** Render segments as continuous lines (standard or smoothed). */
63
- declare function renderLine(segments: {
64
- data: DataPoint[];
65
- color?: string;
66
- }[], ctx: RenderingContext, style: SeriesStyle): DrawCommand[];
67
- declare function renderStep(segments: {
68
- data: DataPoint[];
69
- color?: string;
70
- }[], ctx: RenderingContext, style: SeriesStyle): DrawCommand[];
71
- /** Render segments as a filled area between two values (e.g. min/max band). */
72
- declare function renderArea(segments: {
73
- data: AggregatedPoint[];
74
- color?: string;
75
- }[], ctx: RenderingContext, style: SeriesStyle, yLow: (p: AggregatedPoint) => number, yHigh: (p: AggregatedPoint) => number): DrawCommand[];
76
- /**
77
- * Complex area renderer that splits a run by value boundaries (thresholds)
78
- * and renders the resulting zones as separate filled areas.
79
- */
80
- declare function renderZonedArea<T extends {
81
- time: number;
82
- }>(run: T[], ctx: RenderingContext, options: {
83
- boundaries: number[];
84
- yLow: (p: T) => number;
85
- yHigh: (p: T) => number;
86
- getValue: (p: T) => number;
87
- interpolate: (p1: T, p2: T, t: number) => T;
88
- getColor: (zoneIndex: number) => string | undefined;
89
- getHatch?: (zoneIndex: number) => string | undefined;
90
- }, style?: SeriesStyle): DrawCommand[];
91
- /**
92
- * Render a line series split by a threshold value, allowing different styles
93
- * for parts above and below that value.
94
- */
95
- declare function renderSplitLine(run: DataPoint[], threshold: number, ctx: RenderingContext, styles: {
96
- above?: SeriesStyle;
97
- below?: SeriesStyle;
98
- }): DrawCommand[];
99
- /** Render point markers for segments. */
100
- declare function renderMarkers$1(points: DataPoint[], ctx: RenderingContext, style: SeriesStyle, getColor: (p: DataPoint) => string): DrawCommand[];
101
-
102
14
  /*!
103
15
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
104
16
  * MIT with Attribution: free use incl. commercial requires visible credit to
@@ -916,4 +828,4 @@ declare function resolveSeriesStyle(series: TimeSeries): ResolvedSeriesStyle;
916
828
  */
917
829
  declare function slugify(s: string | undefined | null): string;
918
830
 
919
- export { AnnotationBandSeries, type AnnotationRenderConfig, BandScale, BandSeries, type BandSeriesConfig, Clip, type ClipRegion, DrawCommand, EnumAxis, type EnumAxisConfig, EnumFormatter, type EnumFormatterOptions, type EnumTickInfo, Formatters, type GapRenderConfig, type GridConfig, type HighlightRenderConfig, LineSeries, type LineSeriesConfig, LinearScale, type MarkerRenderConfig, type MinMaxAvgConfig, MinMaxAvgSeries, type ResolvedLine, type ResolvedMarker, type ResolvedSeriesStyle, type ResolvedShadow, type StatLabelPosition, StatsOverlay, type StatsOverlayConfig, StepSeries, type StepSeriesConfig, type ThresholdRenderConfig, type TickInfo, TimeAxis, type TimeAxisConfig, type TimeFormatOptions, TimeFormatter, TimeScale, ValueAxis, type ValueAxisConfig, type ValueFormatOptions, ValueFormatter, type ValueTickInfo, type Zone, type ZonedFill, type ZonedLineConfig, ZonedLineSeries, renderAnnotations, renderArea, renderGaps, renderGrid, renderHighlights, renderLine, renderMarkers, renderMarkers$1 as renderSeriesMarkers, renderSplitLine, renderStep, renderThresholds, renderZonedArea, resolveFill, resolveGap, resolveLines, resolveMarkers, resolveSeriesStyle, resolveShadow, slugify, theme };
831
+ export { AnnotationBandSeries, type AnnotationRenderConfig, BandScale, BandSeries, type BandSeriesConfig, Clip, type ClipRegion, DrawCommand, EnumAxis, type EnumAxisConfig, EnumFormatter, type EnumFormatterOptions, type EnumTickInfo, Formatters, type GapRenderConfig, type GridConfig, type HighlightRenderConfig, LineSeries, type LineSeriesConfig, LinearScale, type MarkerRenderConfig, type MinMaxAvgConfig, MinMaxAvgSeries, type ResolvedLine, type ResolvedMarker, type ResolvedSeriesStyle, type ResolvedShadow, type StatLabelPosition, StatsOverlay, type StatsOverlayConfig, StepSeries, type StepSeriesConfig, type ThresholdRenderConfig, type TickInfo, TimeAxis, type TimeAxisConfig, type TimeFormatOptions, TimeFormatter, TimeScale, ValueAxis, type ValueAxisConfig, type ValueFormatOptions, ValueFormatter, type ValueTickInfo, type Zone, type ZonedFill, type ZonedLineConfig, ZonedLineSeries, renderAnnotations, renderGaps, renderGrid, renderHighlights, renderMarkers, renderThresholds, resolveFill, resolveGap, resolveLines, resolveMarkers, resolveSeriesStyle, resolveShadow, slugify, theme };