ml-time-graph 1.9.0 → 1.10.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,13 +1,13 @@
1
- var se=class i{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:n}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-n.left-n.right,chartHeight:t-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(e=800,t=400){return new i({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};function ee(i){return i&&i.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}var Lt=(()=>{let i=new Array(256);for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;i[e]=t>>>0;}return i})();function Fe(i){let e=new TextEncoder().encode(i),t=4294967295;for(let n of e)t=Lt[(t^n)&255]^t>>>8;return (t^4294967295)>>>0}function Z(i,e){return e||"s-"+Fe(i??"").toString(16).padStart(8,"0")}var Je=new Map;function Mt(i,e){return `${i}|${JSON.stringify(e??{})}`}function Qe(i,e){let t=Mt(i,e),n=Je.get(t);return n||(n=new Intl.DateTimeFormat(i,e),Je.set(t,n)),n}var U=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,r]=this.#e,[o,s]=this.#t;return r===n?o:o+(t-n)/(r-n)*(s-o)}invert(e){let[t,n]=this.#e,[r,o]=this.#t;return o===r?t:t+(e-r)/(o-r)*(n-t)}domain(){return [...this.#e]}range(){return [...this.#t]}},q=[{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}],te=class{#e;#t;#n;constructor(e){this.#e=new U({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#n=e.timeZone;}map(e){return this.#e.map(Number(e))}invert(e){return this.#e.invert(e)}domain(){return this.#e.domain()}range(){return this.#e.range()}get timeZone(){return this.#n}get locale(){return this.#t}tickInterval(e,t=3,n=12){let[r,o]=this.#e.domain(),s=o-r;if(s<=0)return {interval:q[0].ms};let a=s/e,l=q[0].ms;for(let u of q)if(u.ms>=a){l=u.ms;break}let h=l,m=Math.round(s/h);for(;m>n&&h<q[q.length-1].ms;){let u=q.findIndex(d=>d.ms===h);h=q[Math.min(u+1,q.length-1)].ms,m=Math.round(s/h);}for(;m<t&&h>q[0].ms;){let u=q.findIndex(d=>d.ms===h);h=q[Math.max(u-1,0)].ms,m=Math.round(s/h);}return {interval:h}}ticks(e){let t=e?.minTicks??5,n=e?.maxTicks??12,{interval:r}=this.tickInterval((t+n)/2,t,n),[o,s]=this.#e.domain(),a=[],l=Math.ceil(o/r)*r;for(let h=l;h<=s;h+=r)a.push(h);return a}format(e,t){let n=this.#n?{...t,timeZone:this.#n}:t;return Qe(this.#t,n).format(new Date(e))}};var Re={fontFamily:"Liberation Sans, Arial, Helvetica, sans-serif",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 de={...Re};function Pt(i){de={...de,...i};}function ne(){return de}function Ft(){de={...Re};}function Rt(i){let e=i.trim();if(e.startsWith("#"))return e.length===9?e.slice(0,7):e.length===5?e.slice(0,4):e;if(e.toLowerCase().startsWith("rgba(")){let n=e.slice(5,e.lastIndexOf(")")).split(",");if(n.length===4)return `rgb(${n[0].trim()}, ${n[1].trim()}, ${n[2].trim()})`}return e}function Bt(i){let e=i.trim().toLowerCase();return e.startsWith("#")?e.length===9||e.length===5:e.startsWith("rgba(")||e.startsWith("hsla(")}function Be(i,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n,r=2){let o=Rt(t),s=Bt(t)?"":' fill-opacity="0.3"';if(e==="none")return `
1
+ var ye=class i{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:n}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-n.left-n.right,chartHeight:t-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(e=800,t=400){return new i({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};function le(i){return i&&i.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}var Jt=(()=>{let i=new Array(256);for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;i[e]=t>>>0;}return i})();function Ze(i){let e=new TextEncoder().encode(i),t=4294967295;for(let n of e)t=Jt[(t^n)&255]^t>>>8;return (t^4294967295)>>>0}function ie(i,e){return e||"s-"+Ze(i??"").toString(16).padStart(8,"0")}var ft=new Map;function Qt(i,e){return `${i}|${JSON.stringify(e??{})}`}function gt(i,e){let t=Qt(i,e),n=ft.get(t);return n||(n=new Intl.DateTimeFormat(i,e),ft.set(t,n)),n}var re=class{#t;#e;constructor(e){this.#t=[...e.domain],this.#e=[...e.range];}map(e){let t=Number(e),[n,r]=this.#t,[o,s]=this.#e;return r===n?o:o+(t-n)/(r-n)*(s-o)}invert(e){let[t,n]=this.#t,[r,o]=this.#e;return o===r?t:t+(e-r)/(o-r)*(n-t)}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}],he=class{#t;#e;#n;constructor(e){this.#t=new re({domain:e.domain,range:e.range}),this.#e=e.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#n=e.timeZone;}map(e){return this.#t.map(Number(e))}invert(e){return this.#t.invert(e)}domain(){return this.#t.domain()}range(){return this.#t.range()}get timeZone(){return this.#n}get locale(){return this.#e}tickInterval(e,t=3,n=12){let[r,o]=this.#t.domain(),s=o-r;if(s<=0)return {interval:Z[0].ms};let a=s/e,l=Z[0].ms;for(let u of Z)if(u.ms>=a){l=u.ms;break}let h=l,m=Math.round(s/h);for(;m>n&&h<Z[Z.length-1].ms;){let u=Z.findIndex(c=>c.ms===h);h=Z[Math.min(u+1,Z.length-1)].ms,m=Math.round(s/h);}for(;m<t&&h>Z[0].ms;){let u=Z.findIndex(c=>c.ms===h);h=Z[Math.max(u-1,0)].ms,m=Math.round(s/h);}return {interval:h}}ticks(e){let t=e?.minTicks??5,n=e?.maxTicks??12,{interval:r}=this.tickInterval((t+n)/2,t,n),[o,s]=this.#t.domain(),a=[],l=Math.ceil(o/r)*r;for(let h=l;h<=s;h+=r)a.push(h);return a}format(e,t){let n=this.#n?{...t,timeZone:this.#n}:t;return gt(this.#e,n).format(new Date(e))}};var Ke={fontFamily:"Liberation Sans, Arial, Helvetica, sans-serif",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,markerFontSize:11,statFontSize:10,tooltipTimeFontSize:10,tooltipValueFontSize: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 ve={...Ke};function en(i){ve={...ve,...i};}function me(){return ve}function tn(){ve={...Ke};}function nn(i){let e=i.trim();if(e.startsWith("#"))return e.length===9?e.slice(0,7):e.length===5?e.slice(0,4):e;if(e.toLowerCase().startsWith("rgba(")){let n=e.slice(5,e.lastIndexOf(")")).split(",");if(n.length===4)return `rgb(${n[0].trim()}, ${n[1].trim()}, ${n[2].trim()})`}return e}function rn(i){let e=i.trim().toLowerCase();return e.startsWith("#")?e.length===9||e.length===5:e.startsWith("rgba(")||e.startsWith("hsla(")}function Te(i,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n,r=2){let o=nn(t),s=rn(t)?"":' fill-opacity="0.3"';if(e==="none")return `
2
2
  <pattern id="${i}" width="10" height="10" patternUnits="userSpaceOnUse">
3
3
  <rect width="10" height="10" fill="${t}" />
4
4
  </pattern>
5
- `.trim();let a=12,l=12,h="rotate(0)",m="";switch(e){case "classic-diagonal":a=12,l=12,h="rotate(45)",m=`<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />`;break;case "dense-steep":a=6,l=6,h="rotate(30)",m=`<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />`;break;case "crosshatch":a=14,l=14,h="rotate(45)",m=`
5
+ `.trim();let a=12,l=12,h="rotate(0)",m="";switch(e){case "classic-diagonal":h="rotate(45)",m=`<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />`;break;case "dense-steep":a=6,l=6,h="rotate(30)",m=`<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />`;break;case "crosshatch":a=14,l=14,h="rotate(45)",m=`
6
6
  <line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
7
7
  <line x1="0" y1="0" x2="${a}" y2="0" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
8
- `;break;case "dots":a=12,l=12,m=`<circle cx="${a/2}" cy="${l/2}" r="${r*1.2}" fill="${o}" />`;break;case "waves":a=16,l=16,m=`
8
+ `;break;case "dots":m=`<circle cx="${a/2}" cy="${l/2}" r="${r*1.2}" fill="${o}" />`;break;case "waves":a=16,l=16,m=`
9
9
  <path d="M 0 ${l/2} Q ${a/4} 0, ${a/2} ${l/2} T ${a} ${l/2}" fill="none" stroke="${o}" stroke-width="${r}" stroke-linecap="round" />
10
- `;break;case "dashed":a=12,l=12,h="rotate(45)",m=`<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-dasharray="3,3" />`;break;case "herringbone":a=16,l=16,m=`
10
+ `;break;case "dashed":h="rotate(45)",m=`<line x1="0" y1="0" x2="0" y2="${l}" stroke="${o}" stroke-width="${r}" stroke-dasharray="3,3" />`;break;case "herringbone":a=16,l=16,m=`
11
11
  <path d="M 0 0 L ${a/2} ${l/2} L 0 ${l} M ${a} 0 L ${a/2} ${l/2} L ${a} ${l}" fill="none" stroke="${o}" stroke-width="${r}" stroke-linejoin="round" stroke-linecap="round" />
12
12
  `;break;case "brick":a=20,l=20,m=`
13
13
  <path d="M 0 ${l/2} L ${a} ${l/2} M 0 ${l} L ${a} ${l} M ${a/2} 0 L ${a/2} ${l/2} M 0 ${l/2} L 0 ${l}" fill="none" stroke="${o}" stroke-width="${r}" />
@@ -21,26 +21,26 @@ var se=class i{_config;constructor(e){this._config=e;}compute(){let{width:e,heig
21
21
  ${u}
22
22
  ${m}
23
23
  </pattern>
24
- `.trim()}function je(i,e=2,t=false){return i==="dashed"||!i&&t?{strokeDasharray:"4,4"}:i==="dotted"?{strokeDasharray:"2,4"}:!i||i==="solid"?null:et(i,e)}function et(i,e=2){let t=e;switch(i){case "dotted":return {strokeDasharray:`0, ${t*2}`,strokeLinecap:"round"};case "sparse-dots":return {strokeDasharray:`0, ${t*4}`,strokeLinecap:"round"};case "dashed":return {strokeDasharray:`${t*3}, ${t*2}`,strokeLinecap:"butt"};case "long-dash":return {strokeDasharray:`${t*6}, ${t*3}`,strokeLinecap:"butt"};case "dense-dash":return {strokeDasharray:`${t*1.5}, ${t*1.5}`,strokeLinecap:"butt"};case "dash-dot":return {strokeDasharray:`${t*4}, ${t*2}, 0, ${t*2}`,strokeLinecap:"round"};case "dash-dot-dot":return {strokeDasharray:`${t*5}, ${t*2}, 0, ${t*2}, 0, ${t*2}`,strokeLinecap:"round"};case "loose-dash":return {strokeDasharray:`${t*3}, ${t*4}`,strokeLinecap:"butt"};default:return {strokeDasharray:"none",strokeLinecap:"butt"}}}var p=new Proxy({},{get:(i,e)=>ne()[e],has:(i,e)=>e in ne(),ownKeys:()=>Reflect.ownKeys(ne()),getOwnPropertyDescriptor:(i,e)=>Reflect.getOwnPropertyDescriptor(ne(),e)});var ae={axisColor:p.axisColor,tickColor:p.tickColor,textColor:p.textColor,textSize:p.textSize},ie=class{#e;#t;constructor(e){this.#e=new te({domain:e.domain,range:e.xRange,locale:e.locale,timeZone:e.timeZone}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??ae).axisColor}get tickColor(){return (this.#t.colors??ae).tickColor}get textColor(){return (this.#t.colors??ae).textColor}get textSize(){return (this.#t.colors??ae).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,r=this.#e.ticks({minTicks:e,maxTicks:t}).map(o=>({time:o,x:this.#e.map(o),label:this.tickLabel(o)}));return this.antiOverlap(r)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,n=this.#t.maxTicks??12,{interval:r}=this.#e.tickInterval((t+n)/2,t,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.#e.format(e,o)}antiOverlap(e){if(e.length<=1)return e;let t=60,n=[e[0]];for(let r=1;r<e.length;r++){let o=n[n.length-1].x;Math.abs(e[r].x-o)>=t&&n.push(e[r]);}return n}render(){let e=this.generateTicks(),t=this.#t.colors??ae,n=this.#t.y??0,r=[],[o,s]=this.#e.range();r.push({type:"line",x1:o,y1:n,x2:s,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let a of e)r.push({type:"line",x1:a.x,y1:n,x2:a.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:a.label,x:a.x,y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}};var le={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function jt(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 It(i){let e=new Array(i.length).fill(false),t=0;for(;t<i.length;){let n=t;for(;n+1<i.length&&i[n+1].label===i[t].label;)n++;for(let r=t+1;r<n;r++)e[r]=true;t=n+1;}return e}var ce=class{#e;#t;constructor(e){this.#e=new U({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??le).axisColor}get tickColor(){return (this.#t.colors??le).tickColor}get textColor(){return (this.#t.colors??le).textColor}get textSize(){return (this.#t.colors??le).textSize}generateTicks(){let e=this.#t.format??jt,t=this.#t.ticks&&this.#t.ticks>0?this.#t.ticks:6,[n,r]=this.#e.domain(),o=Math.min(n,r),s=Math.max(n,r),a=s-o;if(a===0)return [{value:n,position:this.#e.map(n),label:e(n)}];let l=a/t,h=Math.pow(10,Math.floor(Math.log10(l))),m=l/h,u;if(m<=1.5?u=h:m<=3?u=2*h:m<=7?u=5*h:u=10*h,u<=0||!Number.isFinite(u))return [{value:n,position:this.#e.map(n),label:e(n)}];let d=[],c=Math.ceil(o/u)*u;for(let y=c;y<=s;y+=u)d.push({value:y,position:this.#e.map(y),label:e(y)});return d}render(){let e=this.generateTicks(),t=this.#t.colors??le,n=this.#t.x??0,r=this.#t.orientation??"vertical",o=this.#t.position??"left",s=this.#t.suppressLabelsNear??[],a=this.#t.suppressTolerancePx??8,l=m=>s.some(u=>Math.abs(u-m)<=a),h=[];if(r==="vertical"){let[m,u]=this.#e.range();h.push({type:"line",x1:n,y1:m,x2:n,y2:u,stroke:t.axisColor,strokeWidth:t.axisWidth});let d=It(e);e.forEach((c,y)=>{let g=l(c.position),x=d[y]?{opacity:0}:{};o==="left"?(h.push({type:"line",x1:n-4,y1:c.position,x2:n,y2:c.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||h.push({type:"text",content:c.label,x:n-8,y:c.position+4,anchor:"end",fontSize:11,fill:t.textColor,...x})):(h.push({type:"line",x1:n,y1:c.position,x2:n+4,y2:c.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||h.push({type:"text",content:c.label,x:n+8,y:c.position+4,anchor:"start",fontSize:11,fill:t.textColor,...x}));});}else {let[m,u]=this.#e.range();h.push({type:"line",x1:m,y1:n,x2:u,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let d of e)h.push({type:"line",x1:d.position,y1:n,x2:d.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),h.push({type:"text",content:d.label,x:d.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return h}};var V=class{static interpolateDataPoint(i,e,t){return {time:i.time+Math.round(t*(e.time-i.time)),value:(i.value??0)+t*((e.value??0)-(i.value??0))}}static interpolateAggregatedPoint(i,e,t){let n=(r,o)=>r!==null&&o!==null?r+t*(o-r):null;return {time:i.time+t*(e.time-i.time),min:n(i.min,e.min),max:n(i.max,e.max),avg:n(i.avg,e.avg),count:Math.round(i.count+t*(e.count-i.count))}}static getRuns(i,e,t=0){let n=[...i].sort((a,l)=>a.time-l.time),r=[],o=[],s=null;for(let a of n){let l=e(a),h=t>0&&s&&a.time-s.time>t;(l||h)&&o.length&&(r.push(o),o=[]),l||o.push(a),s=a;}return o.length&&r.push(o),r}static splitByBoundaries(i,e,t,n){if(i.length===0)return [];if(e.length===0)return [{data:i,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let r=[...e].sort((h,m)=>h-m),o=[],s=h=>h<=0?Number.NEGATIVE_INFINITY:r[h-1],a=h=>{let m=0;for(let u=0;u<r.length&&h>=r[u];u++)m=u+1;return m},l=[i[0]];for(let h=1;h<i.length;h++){let m=i[h-1],u=i[h],d=t(m),c=t(u),y;c>d?y=r.filter(x=>x>d&&x<=c):c<d?y=r.filter(x=>x>=c&&x<d).reverse():y=[];let g=d;for(let x of y){let k=(x-d)/(c-d),D=n(m,u,k);l.push(D);let R=a((g+x)/2);o.push({data:l,zoneIndex:R,zoneLow:s(R)}),l=[D],g=x;}(y.length===0||y[y.length-1]!==c)&&l.push(u);}if(l.length>1){let h=t(l[0]),m=t(l[l.length-1]),u=a((h+m)/2);o.push({data:l,zoneIndex:u,zoneLow:s(u)});}return o}static splitByThreshold(i,e,t,n){let r=this.splitByBoundaries(i,[e],t,n),o={above:[],below:[]};for(let s of r)s.zoneIndex===0?o.below.push(s.data):o.above.push(s.data);return o}};function tt(i,e=6e4){if(i.length<2)return [];let t=[...i].sort((r,o)=>r.time-o.time),n=[];for(let r=1;r<t.length;r++)t[r].time-t[r-1].time>e&&n.push({startTime:t[r-1].time,endTime:t[r].time});return n}function Ot(i,e=83144){let t=e/8.314,n=0,r=0;for(let s of i)s!==null&&(n+=Math.exp(-t/(s+273.15)),r++);if(r===0)return null;let o=n/r;return t/-Math.log(o)-273.15}function nt(i,e,t=83144){let n=new Array(i.length),r=0;for(let o=0;o<i.length;o++){let s=i[o].time,a=s-e;for(;r<o&&i[r].time<a;)r++;let l=i.slice(r,o+1).map(m=>m.value),h=Ot(l,t);n[o]={time:s,value:h,synthetic:true};}return n}function Wt(i){let e=0,t=0;for(let o of i)o!==null&&(e+=o,t++);if(t===0)return null;let n=e/t,r=0;for(let o of i){if(o===null)continue;let s=o-n;r+=s*s;}return Math.sqrt(r/t)}function Ht(i){let e=0,t=0;for(let o of i)o!==null&&(e+=o,t++);if(t<2)return null;let n=e/t,r=0;for(let o of i){if(o===null)continue;let s=o-n;r+=s*s;}return Math.sqrt(r/(t-1))}function it(i,e,t=false){let n=new Array(i.length),r=0,o=t?Ht:Wt;for(let s=0;s<i.length;s++){let a=i[s].time,l=a-e;for(;r<s&&i[r].time<l;)r++;let h=i.slice(r,s+1).map(u=>u.value),m=o(h);n[s]={time:a,value:m,synthetic:true};}return n}function Ie(i,e){let t=new Array(i.length),n=0;for(let r=0;r<i.length;r++){let o=i[r].time,s=o-e;for(;n<r&&i[n].time<s;)n++;let a=0,l=0;for(let h=n;h<=r;h++){let m=i[h].value;m!==null&&(a+=m,l++);}t[r]={time:o,value:l===0?null:a/l,synthetic:true};}return t}function rt(i,e){let t=new Array(i.length),n=null,r=0;for(let o=0;o<i.length;o++){let s=i[o].time,a=i[o].value;if(a===null){t[o]={time:s,value:n,synthetic:true};continue}if(n===null||e<=0)n=a;else {let l=1-Math.exp(-(s-r)/e);n=a*l+n*(1-l);}r=s,t[o]={time:s,value:n,synthetic:true};}return t}function ot(i){return {id:i.id,line:{stroke:i.stroke??p.stroke,strokeWidth:i.strokeWidth??p.strokeWidth,smoothing:i.smoothing??false,dashed:i.dashed??false},fill:i.fill??p.areaFillAlpha,markers:{type:i.pointStyle??"none",size:i.pointSize??p.pointSize,stroke:i.stroke??p.stroke,fill:"#ffffff"},shadow:{color:i.shadowColor??"transparent",blur:i.shadowBlur??0,offsetX:i.shadowOffsetX??0,offsetY:i.shadowOffsetY??0}}}function pe(i,e,t){let n=[],r=i.reduce((s,a)=>s+a.data.length,0),o=ot(t);for(let s=0;s<i.length;s++){let a=i[s];a.data.length>=2?n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${s}`:void 0,points:a.data.map(l=>({x:e.timeScale.map(l.time),y:e.valueScale.map(l.value)})),stroke:a.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"}):a.data.length===1&&r===1&&n.push({type:"circle",cx:e.timeScale.map(a.data[0].time),cy:e.valueScale.map(a.data[0].value),r:Math.max(o.markers.size,o.line.strokeWidth),fill:a.color??o.line.stroke,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur});}return n}function re(i){let e=[];for(let t of i)e.length>0&&e.push({...t,value:e[e.length-1].value}),e.push(t);return e}function Oe(i,e,t,n){if(i.length<2)return [];let r=V.splitByBoundaries(i,t.boundaries,t.getValue,t.interpolate),o=[];for(let s=0;s<r.length;s++){let a=r[s];if(a.data.length<2)continue;let l=t.getColor(a.zoneIndex);if(!l)continue;let h=a.data.map(u=>({x:e.timeScale.map(u.time),y:e.valueScale.map(t.yLow(u))})),m=a.data.map(u=>({x:e.timeScale.map(u.time),y:e.valueScale.map(t.yHigh(u))})).reverse();o.push({type:"path",cssClass:"series-fill",id:n?.id?`${n.id}-fill-${s}`:void 0,points:[...h,...m],fill:l,hatch:t.getHatch?.(a.zoneIndex),stroke:"none"});}return o}function st(i,e,t,n){let r=ot(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let s=0;s<i.length;s++){let a=i[s],l=e.timeScale.map(a.time),h=e.valueScale.map(a.value),m=n(a),u=t.pointStroke??m,d=t.pointFill??m,c=t.pointStrokeWidth??1.5,y=t.id?`${t.id}-marker-${s}`:void 0;fe(o,y,r.markers.type,l,h,r.markers.size,u,d,c);}return o}function fe(i,e,t,n,r,o,s,a,l){switch(t){case "circle":i.push({type:"circle",cx:n,cy:r,r:o,fill:a,stroke:s,strokeWidth:l,id:e});break;case "square":i.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:a,stroke:s,strokeWidth:l,id:e});break;case "cross":i.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:s,strokeWidth:l,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:s,strokeWidth:l,id:e});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}],closed:true,fill:a,stroke:s,strokeWidth:l,id:e});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}],closed:true,fill:a,stroke:s,strokeWidth:l,id:e});break;case "star":{let h=[];for(let m=0;m<10;m++){let u=m%2===0?o:o*.5,d=Math.PI/2*3+m*Math.PI/5;h.push({x:n+u*Math.cos(d),y:r+u*Math.sin(d)});}i.push({type:"path",points:h,closed:true,fill:a,stroke:s,strokeWidth:l,id:e});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:s,strokeWidth:l,fill:"none",id:e});break;case "plus":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:l,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:s,strokeWidth:l,id:e});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}],closed:true,fill:a,stroke:s,strokeWidth:l,id:e});break;case "hexagon":{let h=[];for(let m=0;m<6;m++){let u=m*(Math.PI/3);h.push({x:n+o*Math.cos(u),y:r+o*Math.sin(u)});}i.push({type:"path",points:h,closed:true,fill:a,stroke:s,strokeWidth:l,id:e});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}],closed:true,fill:a,stroke:s,strokeWidth:l,id:e});break;case "line-horizontal":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:l,id:e});break;default:i.push({type:"circle",cx:n,cy:r,r:o,fill:a,stroke:s,strokeWidth:l,id:e});}}var oe=class i{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"series-"+ ++i.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var ge=class extends oe{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??p.minColor,n=e.maxColor??p.maxColor,r=e.avgColor??p.avgColor,o=e.avgDashed??true,s=e.smoothing??false,a=e.strokeWidth??p.strokeWidth,l=V.getRuns(this.data,c=>c.min===null||c.max===null||c.avg===null);if(l.length===0)return [];let h={timeScale:this.timeScale,valueScale:e.valueScale},m=[];l.forEach((c,y)=>{c.length<2||(e.fillToMax&&m.push(...Oe(c,h,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.max,getValue:g=>g.avg,interpolate:V.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${y}`:void 0})),e.fillToMin&&m.push(...Oe(c,h,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.min,getValue:g=>g.avg,interpolate:V.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${y}`:void 0})));});let u=l.filter(c=>c.length>=2),d=c=>u.map(y=>({data:y.map(g=>({time:g.time,value:c(g)}))}));return m.push(...pe(d(c=>c.max),h,{stroke:n,strokeWidth:a,smoothing:s,id:this.id?`${this.id}-max`:void 0}),...pe(d(c=>c.min),h,{stroke:t,strokeWidth:a,smoothing:s,id:this.id?`${this.id}-min`:void 0}),...pe(d(c=>c.avg),h,{stroke:r,strokeWidth:a,smoothing:s,dashed:o,id:this.id?`${this.id}-avg`:void 0})),m}};var ye=class extends oe{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=0;for(let n of this.data)n.count>t&&(t=n.count);return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??p.bandFill,n=e.hatch,r=e.avgLine??false,o=e.avgLineColor??p.bandAvgLine,s=e.bandWidth??10,a=[];for(let l of this.data){if(l.min===null||l.max===null)continue;let h=this.timeScale.map(l.time),m=e.valueScale.map(l.max),u=e.valueScale.map(l.min),d=s,c=this.data.indexOf(l);if(a.push({type:"rect",x:h-d/2,y:m,w:d,h:u-m,fill:t,hatch:n,opacity:this.opacity(l.count),id:this.id?`${this.id}-slot-${c}`:void 0}),r&&l.avg!==null){let y=e.valueScale.map(l.avg);a.push({type:"line",x1:h-d/2,y1:y,x2:h+d/2,y2:y,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${c}`:void 0});}}return a}};function Et(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function at(i){let{thresholds:e,valueScale:t,xRange:n}=i,[r,o]=n,[s,a]=t.range(),l=Math.min(s,a),h=Math.max(s,a),m=[],u=[];for(let d of e){let c=d.color??p.thresholdColor,y=t.map(d.value);d.fill==="above"?m.push({type:"rect",x:r,y:l,w:o-r,h:Math.max(0,y-l),fill:c,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0}):d.fill==="below"&&m.push({type:"rect",x:r,y,w:o-r,h:Math.max(0,h-y),fill:c,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0});let g=d.line??p.thresholdLine;if(g!=="none"){let x=Et(g),k={type:"line",x1:r,y1:y,x2:o,y2:y,stroke:c,strokeWidth:1,...x,id:d.id?`${d.id}-line`:void 0};d.shadowColor&&(k.shadowColor=d.shadowColor,k.shadowBlur=d.shadowBlur??4,k.shadowOffsetX=d.shadowOffsetX??0,k.shadowOffsetY=d.shadowOffsetY??2),m.push(k);}if(d.label!==void 0&&d.label!==null&&d.label!==false){let x=typeof d.label=="object"?d.label:void 0,k=typeof d.label=="string"?d.label:x?.text??d.name,D=x?.position??"right";u.push({...Nt(k,D,r,o,y,c,x),id:d.id?`${d.id}-label`:void 0});}}return {inside:m,labels:u}}function Nt(i,e,t,n,r,o,s){let a=(t+n)/2,l={type:"text",content:i,fontSize:p.thresholdFontSize,fill:o},h=s?{...s.rotate!==void 0&&{rotate:s.rotate},...s.textBaseline!==void 0&&{textBaseline:s.textBaseline}}:{};switch(e){case "left":return {...l,...h,x:t+4,y:r-4,anchor:"start"};case "above":return {...l,...h,x:a,y:r-6,anchor:"middle"};case "below":return {...l,...h,x:a,y:r+14,anchor:"middle"};case "center":return {...l,...h,x:a,y:r-4,anchor:"middle"};case "outside-left":return {...l,...h,x:t-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 lt(i,e,t,n){switch(i){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":case "middle":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function be(i){let{ranges:e,timeScale:t,yRange:n,height:r}=i,[o,s]=n,a=[];for(let l of e){let h=t.map(l.startTime),m=t.map(l.endTime);if(l.fill!==void 0&&a.push({type:"rect",x:h,y:o,w:m-h,h:s-o,fill:l.fill,hatch:l.hatch,opacity:l.opacity}),l.edges)for(let u of [h,m])a.push({type:"line",x1:u,y1:o,x2:u,y2:s,stroke:l.edges.stroke,strokeWidth:l.edges.strokeWidth,dash:"dashed"});l.label&&a.push({type:"text",content:l.label,x:(h+m)/2,y:lt(l.labelPosition??"middle",o,s,r),anchor:"middle",fontSize:l.fontSize,fill:l.labelColor,rotate:l.rotate});}return a}function We(i){let{gaps:e,timeScale:t,yRange:n,height:r,fill:o=p.gapFill,hatch:s,fillOpacity:a=p.gapFillOpacity??.15,stroke:l=p.gapStroke,strokeWidth:h=p.gapStrokeWidth,dashed:m=true,fontSize:u=p.gapFontSize,fontFill:d=p.gapFontColor,labelBaseline:c="middle",labelRotate:y}=i;return be({timeScale:t,yRange:n,height:r,ranges:e.map(g=>{let x=g.style??"dashed_border",k=x==="filled"||x==="dashed_border",D=x==="dashed_border"&&m!==false;return {startTime:g.startTime,endTime:g.endTime,...k&&{fill:g.fill??o,hatch:g.hatch??s,opacity:g.fillOpacity??a},...D&&{edges:{stroke:l,strokeWidth:h}},label:g.label,labelPosition:g.labelBaseline??c,labelColor:d,fontSize:u,rotate:g.rotate??y}})})}var Gt=1,xe=class{#e;constructor(e,t,n,r){this.#e={...e,xRange:t,y:n,height:r};}render(){let{items:e,timeScale:t,background:n,hatch:r,showAxis:o,xRange:s,y:a,height:l}=this.#e,h=[];n&&h.push({type:"rect",x:s[0],y:a,w:s[1]-s[0],h:l,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let m of e){let u=t.map(m.startTime),d=t.map(m.endTime);if(d<s[0]||u>s[1])continue;let c=Math.max(s[0],Math.min(s[1],u)),y=Math.max(s[0],Math.min(s[1],d)),g=Math.max(y-c,Gt);c+g>s[1]&&(c=Math.max(s[0],s[1]-g));let x=c+g/2;if(h.push({type:"rect",x:c,y:a,w:g,h:l,hatch:m.hatch??r,fill:m.fill??"#6b728044",stroke:m.stroke,strokeWidth:m.strokeWidth??0,title:m.title}),m.label){let k=m.labelFontSize??10;h.push({type:"text",content:m.label,x,y:this.#t(m.labelBaseline,k),anchor:"middle",fontSize:k,fill:m.labelFill??"#333"});}}if(o){let m=new ie({domain:t.domain(),xRange:s,y:a+l+4});h.push({type:"group",cssClass:"annotation-band-axis",commands:m.render()});}return h}#t(e,t){let{y:n,height:r}=this.#e;switch(e){case "top":return n+t*.9;case "bottom":return n+r-t*.25;default:return n+r/2+t*.35}}};function ht(i){let{highlights:e,timeScale:t,yRange:n,height:r}=i;return be({timeScale:t,yRange:n,height:r,ranges:e.map(o=>({startTime:o.startTime,endTime:o.endTime,fill:o.color??p.highlightColor,opacity:o.opacity??p.highlightOpacity,label:o.label,labelPosition:o.labelPosition??"top",labelColor:o.color??p.highlightLabelColor,fontSize:p.annotationFontSize,rotate:o.rotate}))})}function mt(i){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=i,[o,s]=r,a=[];for(let l of e){let h=t.map(l.time),m=l.color??p.markerColor,u=l.pointStyle??(l.value!==void 0?"circle":"none"),d=l.lineStyle??"full";if(l.value!==void 0){let c=n.map(l.value);if(d==="to-value"?a.push({type:"line",x1:h,y1:s,x2:h,y2:c,stroke:m,strokeWidth:1,dashed:true}):d==="to-top"?a.push({type:"line",x1:h,y1:o,x2:h,y2:c,stroke:m,strokeWidth:1,dashed:true}):d==="full"&&a.push({type:"line",x1:h,y1:o,x2:h,y2:s,stroke:m,strokeWidth:1}),u!=="none"&&fe(a,void 0,u,h,c,p.markerSize,m,m,1.5),l.label){let y=d==="to-value"?c-10:o-6;a.push({type:"text",content:l.label,x:h,y,anchor:"middle",fontSize:11,fill:m});}}else d!=="none"&&a.push({type:"line",x1:h,y1:o,x2:h,y2:s,stroke:m,strokeWidth:1}),l.label&&a.push({type:"text",content:l.label,x:h,y:o-6,anchor:"middle",fontSize:11,fill:m});}return a}function ut(i){let{annotations:e,timeScale:t,valueScales:n}=i,r=[],o=s=>{let a=n.get(s.axis??0)??n.values().next().value;return {x:t.map(s.time),y:a?a.map(s.value):0}};for(let s of e){let a=[],l=h=>a.push(h);switch(s.type){case "line":{let h=o(s.from),m=o(s.to);l({type:"line",x1:h.x,y1:h.y,x2:m.x,y2:m.y,stroke:s.color??p.annotationColor,strokeWidth:s.width??p.annotationWidth,dash:s.dash});break}case "arrow":{let h=o(s.from),m=o(s.to),u=s.color??p.annotationColor,d=s.headSize??p.annotationHead;l({type:"line",x1:h.x,y1:h.y,x2:m.x,y2:m.y,stroke:u,strokeWidth:s.width??p.annotationWidth});let c=Math.hypot(m.x-h.x,m.y-h.y)||1,y=(m.x-h.x)/c,g=(m.y-h.y)/c,x=m.x-y*d,k=m.y-g*d;l({type:"path",points:[{x:m.x,y:m.y},{x:x-g*d*.5,y:k+y*d*.5},{x:x+g*d*.5,y:k-y*d*.5}],fill:u,stroke:"none"});break}case "rect":{let h=o(s.from),m=o(s.to);l({type:"rect",x:Math.min(h.x,m.x),y:Math.min(h.y,m.y),w:Math.abs(m.x-h.x),h:Math.abs(m.y-h.y),fill:s.fill??"none",hatch:s.hatch,stroke:s.stroke,opacity:s.opacity});break}case "point":{let h=o(s.at),m=s.color??"#334155",u=s.radius??p.annotationRadius,d=s.shape??"circle";d==="circle"?l({type:"circle",cx:h.x,cy:h.y,r:u,fill:m}):d==="square"?l({type:"rect",x:h.x-u,y:h.y-u,w:u*2,h:u*2,fill:m}):(l({type:"line",x1:h.x-u,y1:h.y-u,x2:h.x+u,y2:h.y+u,stroke:m,strokeWidth:1.5}),l({type:"line",x1:h.x-u,y1:h.y+u,x2:h.x+u,y2:h.y-u,stroke:m,strokeWidth:1.5}));break}case "label":{let h=o(s.at);l({type:"text",content:s.text,x:h.x+(s.dx??0),y:h.y+(s.dy??0),anchor:s.anchor??"middle",fontSize:p.annotationFontSize,fill:s.color??p.annotationColor,rotate:s.rotate});break}}if(s.id&&a.length>0){let h=ee(s.id);r.push({type:"group",cssClass:`annotation annotation--${h}`,commands:a});}else r.push(...a);}return r}var K=12,Se=8,He=20,Vt=11,Ee=18,Ne=i=>[...i].length*Vt*.6;function dt(i,e="vertical"){if(e==="horizontal"){let n=0;for(let r of i)n+=K+Se+Ne(r.name)+Ee;return {width:Math.max(0,n-Ee),height:He}}let t=0;for(let n of i)t=Math.max(t,Ne(n.name));return {width:K+Se+t,height:i.length*He}}function ct(i){let{items:e,x:t,y:n,orientation:r="vertical"}=i,o=[],s=t;return e.forEach((a,l)=>{let h=r==="horizontal"?s:t,m=r==="horizontal"?n:n+l*He;o.push({type:"rect",x:h,y:m,w:K,h:K,fill:a.color,stroke:p.legendStroke,strokeWidth:1},{type:"text",content:a.name,x:h+K+Se,y:m+K-2,fontSize:p.legendFont,fill:p.legendText}),r==="horizontal"&&(s+=K+Se+Ne(a.name)+Ee);}),{type:"group",cssClass:"chart-legend",commands:o}}function pt(i){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=p.gridStroke,strokeWidth:s=p.gridStrokeWidth,dashed:a=false,opacity:l=p.gridOpacity}=i,h=[];if(t)for(let m of t)h.push({type:"line",x1:n[0],y1:m,x2:n[1],y2:m,stroke:o,strokeWidth:s,dashed:a,opacity:l});if(e)for(let m of e)h.push({type:"line",x1:m,y1:r[0],x2:m,y2:r[1],stroke:o,strokeWidth:s,dashed:a,opacity:l});return h}function Ge(i){return i!==void 0&&typeof i=="object"&&"series"in i?i.series:null}function ft(i){let e=[...i].sort((n,r)=>n.time-r.time),t=0;return n=>{for(;t>0&&e[t].time>n;)t--;for(;t<e.length-1&&e[t+1].time<=n;)t++;let r=e[t];if(!r||n<r.time)return null;if(r.time===n)return r.value??null;let o=e[t+1];if(!o||n>o.time||r.value===null||o.value===null)return null;let s=o.time-r.time;return s===0?r.value:r.value+(o.value-r.value)*(n-r.time)/s}}function gt(i,e,t){let n=i??e;if(n==="series")return null;if(n==="chartTop")return t.chartTop;if(n==="chartBottom")return t.chartBottom;if(typeof n=="object"&&"threshold"in n){let r=t.thresholds.get(n.threshold);if(!r)throw new Error(`fillSpec region references unknown threshold '${n.threshold}'`);return t.valueScale.map(r.value)}return typeof n=="object"&&"value"in n?t.valueScale.map(n.value):null}function zt(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function yt(i,e,t){let n=gt(i.from,"chartBottom",e),r=gt(i.to,"series",e),{color:o,hatch:s}=zt(i.fill),a={type:"path",fill:o,hatch:s,stroke:"none",cssClass:"series-fill"},l=x=>e.idPrefix?{id:`${e.idPrefix}-fill-r${t}-${x}`}:{},h=Ge(i.from),m=Ge(i.to);if(h!==null||m!==null){if(!e.fremdeSerie)throw new Error(`fillSpec region references series '${h??m}', but no series lookup was provided`);let x=(R,T,B)=>{let j=R??T,M=Ge(j);if(M!==null){let $=e.fremdeSerie(M);if(!$)throw new Error(`fillSpec region references unknown series '${M}'`);let F=$.shape==="step"?re($.data):$.data;return {bei:ft(F),zeiten:F.map(_=>_.time)}}if(j==="series")return {bei:ft(B),zeiten:B.map($=>$.time)};let E=Ve(j,e),z=e.valueScale.domain(),S=E??(j==="chartBottom"?z[0]:z[1]);return {bei:()=>S,zeiten:[]}},k=e.shape==="step",D=[];for(let R of e.runs){if(R.length<2)continue;let T=k?re(R):R,B=x(i.from,"chartBottom",T),j=x(i.to,"series",T),M=T[0].time,E=T[T.length-1].time,z=[...new Set([...B.zeiten,...j.zeiten,...T.map(_=>_.time)])].filter(_=>_>=M&&_<=E).sort((_,L)=>_-L),S=[],$=[],F=()=>{if(S.length>=2){let _=[...$].reverse();D.push({...a,...l(D.length),smoothing:k?false:e.smoothing,smoothCount:S.length,points:[...S,..._]});}S=[],$=[];};for(let _ of z){let L=B.bei(_),O=j.bei(_);if(L===null||O===null){F();continue}let C=e.timeScale.map(_);S.push({x:C,y:e.valueScale.map(O)}),$.push({x:C,y:e.valueScale.map(L)});}F();}return D}if(n!==null&&r!==null){let x=e.timeScale.range(),k=x[0],D=x[1],R=Math.min(n,r),T=Math.max(n,r);return [{...a,...l(0),points:[{x:k,y:R},{x:D,y:R},{x:D,y:T},{x:k,y:T}]}]}let u=n??r,d=[],c=Yt(i,e);if(c===null){let x=e.valueScale.domain();c=(n??r)===e.chartBottom?x[0]:x[1];}let y=Ve(i.outer,e),g=e.shape==="step";for(let x of e.runs){if(x.length<2)continue;let k=g?re(x):x,D=V.splitByThreshold(k,c,T=>T.value??c,V.interpolateDataPoint),R=i.side==="above"?D.above:i.side==="below"?D.below:[...D.above,...D.below];if(y!==null&&i.side){let T=y,B=i.side==="above"?j=>Math.min(j,T):j=>Math.max(j,T);R=R.map(j=>j.map(M=>({...M,value:B(M.value??T)})));}for(let T of R){if(T.length<2)continue;let B=T.map(M=>({x:e.timeScale.map(M.time),y:e.valueScale.map(M.value)})),j=[];for(let M of [...B].reverse()){let E=j[j.length-1];g&&E&&E.x===M.x||j.push({x:M.x,y:u});}d.push({...a,...l(d.length),smoothing:g?false:e.smoothing,smoothCount:B.length,points:[...B,...j]});}}return d}function Yt(i,e){let t=i.from==="series"?i.to:i.from;return Ve(t,e)}function Ve(i,e){return i===void 0||i==="series"||i==="chartTop"||i==="chartBottom"?null:typeof i=="object"&&"threshold"in i?e.thresholds.get(i.threshold)?.value??null:typeof i=="object"&&"value"in i?i.value:null}function bt(i,e){if(typeof i=="string"||!("regions"in i))return yt({fill:i},e,0);let t=[];return i.regions.forEach((n,r)=>{t.push(...yt(n,e,r));}),t}function St(i){let e=i.style?.line,t=e&&!Array.isArray(e)?e:void 0;return {color:t?.color??p.stroke,width:t?.width??p.strokeWidth,dash:t?.style,smoothing:t?.smoothing??false}}function xt(i,e,t,n,r){let o=i.filter(h=>h.value!==null);if(o.length<2)return [];let s=o.map(h=>({x:e.timeScale.map(h.time),y:e.valueScale.map(h.value)})),a=St(t);return [{type:"path",cssClass:"series-line",id:e.idPrefix?`${e.idPrefix}-overlay-${r}-${n}`:`overlay-${r}-${n}`,points:s,stroke:a.color,strokeWidth:a.width,smoothing:a.smoothing,dash:a.dash,fill:"none"}]}function wt(i,e,t=0){switch(i.kind){case "movingAverage":{let n=i.type==="exponential"?rt(e.data,i.window):Ie(e.data,i.window);return xt(n,e,i,"movingAvg",t)}case "movingMkt":{let n=nt(e.data,i.window,i.activationEnergy);return xt(n,e,i,"movingMkt",t)}case "limits":{let n=[],r=e.timeScale.range(),o=r[0],s=r[1],a=St(i),l=a.color,h=a.width,m=a.dash??"dashed",u=e.idPrefix?`${e.idPrefix}-overlay-${t}-`:`overlay-${t}-`;return i.high!==void 0&&n.push({type:"line",id:`${u}limit-high`,x1:o,y1:e.valueScale.map(i.high),x2:s,y2:e.valueScale.map(i.high),stroke:l,strokeWidth:h,dash:m}),i.low!==void 0&&n.push({type:"line",id:`${u}limit-low`,x1:o,y1:e.valueScale.map(i.low),x2:s,y2:e.valueScale.map(i.low),stroke:l,strokeWidth:h,dash:m}),n}case "stdDevBand":{let n=i.multiplier??1,r=Ie(e.data,i.window),o=it(e.data,i.window),s=[],a=[];for(let x=0;x<r.length;x++){let k=r[x].value,D=o[x].value;if(k===null||D===null)continue;let R=e.timeScale.map(r[x].time);s.push({x:R,y:e.valueScale.map(k+n*D)}),a.push({x:R,y:e.valueScale.map(k-n*D)});}if(s.length<2)return [];let l=e.idPrefix?`${e.idPrefix}-overlay-${t}-`:`overlay-${t}-`,h=[],u=(typeof i.style?.fill=="string"||i.style?.fill&&!("regions"in i.style.fill)?i.style.fill:void 0)??"#94a3b833",{color:d,hatch:c}=qt(u);h.push({type:"path",cssClass:"series-fill",id:`${l}stdDevBand`,points:[...s,...[...a].reverse()],fill:d,hatch:c,stroke:"none"});let y=i.style?.line,g=y&&!Array.isArray(y)?y:void 0;if(g){let x=r.filter(k=>k.value!==null).map(k=>({x:e.timeScale.map(k.time),y:e.valueScale.map(k.value)}));x.length>=2&&h.push({type:"path",cssClass:"series-line",id:`${l}stdDevBand-mean`,points:x,stroke:g.color??p.stroke,strokeWidth:g.width??1.5,smoothing:g.smoothing,dash:g.style,fill:"none"});}return h}}}function qt(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function Xt(i){if(!i)return {gaps:[],autoDetect:false,minGapMs:6e4};if(Array.isArray(i))return {gaps:i,autoDetect:false,minGapMs:6e4};let e=i.regions??[],t=i.style;return {gaps:e.map(r=>{let o={...t,...r.style},s=o.fill,a,l;return typeof s=="string"?a=s:s&&(a=s.color,l=s.hatch),{startTime:r.startTime,endTime:r.endTime,label:r.label,fill:a,hatch:l,fillOpacity:o.opacity,labelBaseline:o.label?.baseline,rotate:o.label?.rotate,style:o.display==="bridge_line"?void 0:o.display}}),autoDetect:i.autoDetect??false,minGapMs:i.minGapMs??6e4}}function Zt(i,e,t,n){if(n===void 0)return [i,e];let r=typeof n=="number"?n:n.top??0,o=typeof n=="number"?n:n.bottom??0;if(r<=0&&o<=0)return [i,e];let s=t-r-o,a=e-i;if(s<=0||a<=0)return [i,e];let l=a/s;return [i-o*l,e+r*l]}function he(i){return "showAs"in i&&!!i.showAs}function _t(i,e){if(e)for(let t of i)t.type==="text"?t.fontFamily||(t.fontFamily=e):t.type==="group"&&Array.isArray(t.commands)&&_t(t.commands,e);}var J=class{_layout;_renderer;_locale;_timeZone;_fontFamily;_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(e={}){this._layout=new se({width:e.width??800,height:e.height??400,margin:e.margin??{top:20,right:20,bottom:40,left:60}}).compute(),this._renderer=e.renderer,this._locale=e.locale,this._timeZone=e.timeZone,this._fontFamily=e.fontFamily,this._legend=e.legend,this._clipSeries=e.clipSeries??true,this._markers=e.markers??[],this._thresholds=e.thresholds??[],this._highlights=e.highlights??[];let t=Xt(e.gaps);this._gaps=t.gaps,this._gapsAutoDetect=t.autoDetect,this._gapsMinGapMs=t.minGapMs,this._annotations=e.annotations??[],this._annotationBands=e.annotationBands??[],this._axes=e.axes,this._series=[],e.series&&this.setData(e.series);}getWidth(){return this._layout.totalWidth}getHeight(){return this._layout.totalHeight+this._annotationBandTotalHeight()}get series(){return this._series}_annotationBandTotalHeight(){let e=0;for(let t of this._annotationBands){let n=t.height??12,r=t.spacing??0;(t.showAxis??false)&&(e+=26+r),e+=n+r;}return e}setData(e){this._series=e.filter(t=>Array.isArray(t.data));}addAnnotation(e){let t=e.id??`anno-${++this._annotationSeq}`;return this._annotations.push({...e,id:t}),t}removeAnnotation(e){let t=this._annotations.length;return this._annotations=this._annotations.filter(n=>n.id!==e),this._disabledAnnotations.delete(e),this._annotations.length<t}setAnnotations(e){this._annotations=[...e],this._disabledAnnotations.clear();}clearAnnotations(){this._annotations=[],this._disabledAnnotations.clear();}getAnnotations(){return this._annotations}disableAnnotation(e){this._disabledAnnotations.add(e);}enableAnnotation(e){this._disabledAnnotations.delete(e);}_axisIndexOf(e){return e.yAxisIndex??0}_timesOf(e){return e.data.map(t=>t.time)}_valuesOf(e){if(he(e)){let t=[];for(let n of e.data)n.min!==null&&t.push(n.min),n.max!==null&&t.push(n.max);return t}return e.data.map(t=>t.value).filter(t=>t!==null)}renderCommands(){if(this._series.length===0)return [];let e=this._legendItems(),t=(this._legend?.show??false)&&e.length>0,n=this._legend?.position??"inside-right",r=this._legend?.orientation??"vertical",o=t?dt(e,r):{width:0},s=this._layout;if(t&&(n==="outside-right"||n==="outside-left")){let f=o.width+16,w={...this._layout.margin};n==="outside-right"?w.right+=f:w.left+=f,s=new se({width:this._layout.totalWidth,height:this._layout.totalHeight,margin:w}).compute();}let{chartX:a,chartY:l,chartWidth:h,chartHeight:m}=s,u=[a,a+h],d=[l,l+m],c=[];for(let f of this._series)f.data.sort((w,v)=>w.time-v.time);let y=new Map,g=1/0,x=-1/0,k=false;for(let f of this._series){let w=this._axisIndexOf(f),v=y.get(w);v?v.push(f):y.set(w,[f]);for(let P of this._timesOf(f))P<g&&(g=P),P>x&&(x=P),k=true;}if(!k)return [];let D=this._axes?.x?.domain,R=D&&D!=="auto"?D:[g,x];this._timeScale=new te({domain:R,range:u,locale:this._locale,timeZone:this._timeZone});let T=f=>({axisColor:f?.color??p.axisColor,tickColor:f?.color??p.tickColor,textColor:p.textColor,textSize:p.textSize,axisWidth:f?.width??1}),B=new ie({domain:R,xRange:u,y:l+m,locale:this._locale,timeZone:this._timeZone,format:this._axes?.x?.format,maxTicks:this._axes?.x?.ticks?.major,colors:T(this._axes?.x?.axis)});this._valueScales.clear();let j=Array.from(y.keys()).sort((f,w)=>f-w),M,E=0,z=0;for(let f of j){let w=y.get(f),v=1/0,P=-1/0,W=false;for(let N of w)for(let ue of this._valuesOf(N))ue<v&&(v=ue),ue>P&&(P=ue),W=true;if(!W)continue;v===P&&(v-=1,P+=1);let H;this._axes?.y&&this._axes.y.length>f?H=this._axes.y[f]:f===0?H=this._axes?.left:f===1&&(H=this._axes?.right);let Le=H?.domain,Q=Le&&Le!=="auto"?Le:Zt(v,P,m,H?.padding),Ze=new U({domain:Q,range:[l+m,l]});this._valueScales.set(f,Ze);let Ue=this._thresholds.filter(N=>(N.axisIndex??0)===f&&N.label!==void 0&&N.label!==null&&N.label!==false&&N.value>=Math.min(Q[0],Q[1])&&N.value<=Math.max(Q[0],Q[1])).map(N=>Ze.map(N.value)),Me=H?.position??(f===0?"left":"right"),Pe;if(Me==="right"){let N=H?.offset??z*50;Pe=a+h+N,z++;}else {let N=H?.offset??E*50;Pe=a-N,E++;}let Ke=new ce({domain:Q,range:[l+m,l],x:Pe,position:Me,format:H?.format,ticks:H?.ticks?.major,colors:T(H?.axis),suppressLabelsNear:Ue.length?Ue:void 0});f===0&&(M=Ke),c.push({type:"group",cssClass:`value-axis ${Me}`,commands:Ke.render()});}let S=this._valueScales.get(0)??this._valueScales.get(j[0]);c.push({type:"group",cssClass:"time-axis",commands:B.render()});let $=null,F=this._axes?.x?.grid?.major,_=this._axes?.left?.grid?.major;if(F!==void 0||_!==void 0){let f=F!==false,w=_!==false&&!!M,v=f?B.generateTicks().map(W=>W.x):void 0,P=w?M.generateTicks().map(W=>W.position):void 0;if(v||P){let W=(F&&typeof F=="object"?F:void 0)??(_&&typeof _=="object"?_:void 0);$={type:"group",cssClass:"chart-grid",commands:pt({xTicks:v,yTicks:P,xRange:u,yRange:d,stroke:W?.color,opacity:W?.opacity,dashed:W?.style==="dashed"})};}}if(this._highlights.length>0&&c.push({type:"group",cssClass:"highlights",commands:ht({highlights:this._highlights,timeScale:this._timeScale,yRange:d,height:s.totalHeight})}),this._thresholds.length>0&&S){let f=[],w=[];for(let v of this._thresholds){let P=v.id??ee(v.name),W=this._valueScales.get(v.axisIndex??0)??S,H=at({thresholds:[v],valueScale:W,xRange:u});H.inside.length&&f.push({type:"group",cssClass:`threshold threshold--${P}`,id:`threshold-${P}`,commands:H.inside}),H.labels.length&&w.push({type:"group",cssClass:`threshold-label threshold-label--${P}`,commands:H.labels});}f.length&&c.push({type:"group",cssClass:"thresholds",commands:f,clipRect:{x:a,y:l,w:h,h:m}}),w.length&&c.push({type:"group",cssClass:"threshold-labels",commands:w});}let L=this._gaps;if(this._gapsAutoDetect){let f=[];for(let w of this._series){if(he(w))continue;let v=w.data.filter(P=>P.value!==null);f.push(...tt(v,this._gapsMinGapMs));}f.length>0&&(L=[...this._gaps,...f]);}L.length>0&&c.push({type:"group",cssClass:"gaps",commands:We({gaps:L,timeScale:this._timeScale,yRange:d,height:s.totalHeight})});let O=new Map(this._thresholds.map(f=>[f.id??f.name,f]));for(let f of this._series){if(f.data.length===0)continue;let w=this._valueScales.get(this._axisIndexOf(f));if(!w)continue;let v=ee(f.id??f.name);c.push({type:"group",cssClass:`series series--${v}`,id:`series-${v}`,commands:this._renderSeries(f,w,O),...this._clipSeries?{clipRect:{x:a,y:l,w:h,h:m}}:{}});}$&&c.push($);let C=this._markers.map(f=>({...f}));for(let f of C)if(f.value===void 0&&(f.lineStyle==="to-value"||f.lineStyle==="to-top")){let w=this._series[f.seriesIndex??0];w&&!he(w)&&w.data.length>=2&&(f.value=this._interpolateValue(f.time,w.data));}if(C.length>0&&S){let f=[];for(let w of C){let v=S,P=this._series[w.seriesIndex??0];P&&(v=this._valueScales.get(this._axisIndexOf(P))??S),f.push(...mt({markers:[w],timeScale:this._timeScale,valueScale:v,yRange:d}));}c.push({type:"group",cssClass:"markers",commands:f});}let A=this._annotations.filter(f=>!f.id||!this._disabledAnnotations.has(f.id));if(A.length>0&&c.push({type:"group",cssClass:"annotations",commands:ut({annotations:A,timeScale:this._timeScale,valueScales:this._valueScales})}),this._annotationBands.length>0){let f=l+m+this._layout.margin.bottom,w=0;this._annotationBands.forEach(v=>{let P=v.height??12,W=v.spacing??0,H=f+w;(v.showAxis??false)&&(w+=26+W),w+=P+W,c.push({type:"group",cssClass:"annotation-band",commands:new xe({name:v.name,showAxis:v.showAxis??false,items:v.items,timeScale:this._timeScale,background:v.background,hatch:v.hatch},[a,a+h],H,P).render()});});}if(t&&n!=="separate"){let f,w;n==="inside-right"?(f=a+h-o.width-8,w=l+8):n==="inside-left"?(f=a+8,w=l+8):n==="outside-right"?(f=a+h+16,w=l):(f=8,w=l),c.push(ct({items:e,x:f,y:w,orientation:r}));}let I=this._axes?.left?.label,Y=this._axes?.right?.label,G=this._axes?.x?.label;if(I||Y||G){let f=[],w=l+m/2,v=this._axes?.left?.labels,P=this._axes?.right?.labels,W=this._axes?.x?.labels;I&&f.push({type:"text",content:I,x:14,y:w,anchor:"middle",fontSize:v?.fontSize??p.axisLabelSize,fill:v?.color??p.axisLabelColor,rotate:-90}),Y&&f.push({type:"text",content:Y,x:s.totalWidth-14,y:w,anchor:"middle",fontSize:P?.fontSize??p.axisLabelSize,fill:P?.color??p.axisLabelColor,rotate:90}),G&&f.push({type:"text",content:G,x:a+h/2,y:s.totalHeight-6,anchor:"middle",fontSize:W?.fontSize??p.axisLabelSize,fill:W?.color??p.axisLabelColor}),f.length&&c.push({type:"group",cssClass:"axis-labels",commands:f});}return _t(c,this._fontFamily??p.fontFamily),c}_renderSeries(e,t,n){let r=this._timeScale,o={timeScale:r,valueScale:t};if(he(e)){let S=e.style?.line&&!Array.isArray(e.style.line)?e.style.line:void 0,$=typeof e.style?.fill=="string"?e.style.fill:void 0;return e.showAs==="minmaxavg"?new ge({data:e.data,timeScale:r,valueScale:t,minColor:e.minColor,maxColor:e.maxColor,avgColor:e.avgColor,avgDashed:e.avgDashed,fillToMax:e.fillToMax,fillToMaxHatch:e.fillToMaxHatch,fillToMin:e.fillToMin,fillToMinHatch:e.fillToMinHatch,smoothing:S?.smoothing,strokeWidth:S?.width,id:Z(e.name,e.id)}).render():new ye({data:e.data,timeScale:r,valueScale:t,fill:$??S?.color,avgLine:e.avgLine,countOpacity:e.countOpacity,id:Z(e.name,e.id)}).render()}let s=e,a=e.style?.line&&!Array.isArray(e.style.line)?e.style.line:void 0,l=this._gapsAutoDetect?this._gapsMinGapMs:void 0,h=a?.gapThreshold??l??p.gapThreshold,m=V.getRuns(e.data,S=>S.value===null,h),u=m.reduce((S,$)=>S+$.length,0);if(u===0)return [];let d=[],c=e.style?.markers,y=e.style?.shadow,g={stroke:a?.color??p.stroke,strokeWidth:a?.width??p.strokeWidth,smoothing:a?.smoothing,dashed:a?.style==="dashed",pointStyle:c?.type,pointSize:c?.size,pointStroke:c?.stroke,pointFill:c?.fill,pointStrokeWidth:c?.strokeWidth,shadowColor:y?.color,shadowBlur:y?.blur,shadowOffsetX:y?.offsetX,shadowOffsetY:y?.offsetY,id:Z(e.name,e.id)},x=e.style?.line,D=((Array.isArray(x)?x[0]:a)?.shape??s.seriesType)==="step",R=e.style?.fill;if(R!==void 0){let S=t.range(),$=Math.min(S[0],S[1]),F=Math.max(S[0],S[1]);d.push(...bt(R,{runs:m,timeScale:r,valueScale:t,thresholds:n,chartTop:$,chartBottom:F,smoothing:a?.smoothing,shape:D?"step":"line",fremdeSerie:_=>{let L=this._series.find(G=>(G.id??G.name)===_||G.name===_);if(!L||!("data"in L))return;let O=L.data;if(O.length===0||!("value"in O[0]))return;let C=L.style?.line,A=Array.isArray(C)?C[0]:C,Y=(typeof A=="object"&&A!==null?A.shape:void 0)==="step"||L.seriesType==="step";return {data:O,shape:Y?"step":"line"}},idPrefix:Z(e.name,e.id)}));}let T=s.colorByThresholds??[],B=T.map(S=>n.get(S)).filter(S=>!!S).map(S=>S.value).sort((S,$)=>S-$),j=(S,$,F)=>{let _=F??g.stroke,L=Number.NEGATIVE_INFINITY;for(let O of $){let C=n.get(O);!C||S<C.value||C.value<L||(L=C.value,_=C.color??_);}return _},M=new Map;for(let S of m){let _=function(C){return V.splitByBoundaries(C==="step"?re(S):S,B,A=>A.value,V.interpolateDataPoint)};if(S.length<2)continue;let $=Z(s.name,s.id),F=new Map,L=C=>{let A=F.get(C);return A||(A=_(C),F.set(C,A)),A},O=(C,A,I)=>{let Y=L(C);for(let G=0;G<Y.length;G++){let f=Y[G],w=M.get(I)??0;if(M.set(I,w+1),f.data.length<2)continue;let v=f.zoneLow;d.push({type:"path",cssClass:"series-line",id:$?`${$}-line-${w}${I}`:void 0,points:f.data.map(P=>({x:r.map(P.time),y:t.map(P.value)})),stroke:j(v,T,A.color),strokeWidth:A.width??g.strokeWidth,smoothing:C==="step"?false:A.smoothing??g.smoothing,dash:A.style,opacity:A.opacity,fill:"none",shadowColor:g.shadowColor,shadowBlur:g.shadowBlur,shadowOffsetX:g.shadowOffsetX,shadowOffsetY:g.shadowOffsetY});}};x===false||(Array.isArray(x)?x.forEach((C,A)=>{O(C.shape??(s.seriesType==="step"?"step":"line"),C,`-${A}`);}):O(D?"step":"line",x??{},"")),g.pointStyle&&g.pointStyle!=="none"&&u<=(c?.threshold??p.pointThreshold)&&d.push(...st(S,o,g,C=>j(C.value,T)));}let E=e.overlays;if(E&&E.length>0){let S=t.range(),$={data:e.data,timeScale:r,valueScale:t,chartTop:Math.min(S[0],S[1]),chartBottom:Math.max(S[0],S[1]),idPrefix:Z(e.name,e.id)};E.forEach((F,_)=>{d.push(...wt(F,$,_));});}if(e.style?.gap&&m.length>1){let S=e.style.gap,$=S.bridge,F=[];for(let _=1;_<m.length;_++){let L=m[_-1][m[_-1].length-1],O=m[_][0];if(S.display==="bridge_line"){if(L.value===null||O.value===null)continue;d.push({type:"line",x1:r.map(L.time),y1:t.map(L.value),x2:r.map(O.time),y2:t.map(O.value),stroke:$?.color??(typeof e.style?.line=="object"&&!Array.isArray(e.style.line)?e.style.line.color:void 0)??p.stroke,strokeWidth:$?.width??1.5,dash:$?.style??"dotted"});}else F.push({startTime:L.time,endTime:O.time});}if(F.length>0){let _=S.display&&S.display!=="bridge_line"?S.display:"dashed_border",L=S.fill,O=typeof L=="string"?L:L?.color,C=t.range();d.push(...We({gaps:F.map(A=>({...A,style:_})),timeScale:r,yRange:[Math.min(C[0],C[1]),Math.max(C[0],C[1])],fill:O,hatch:typeof L=="object"?L.hatch:void 0,fillOpacity:S.opacity??.15,labelBaseline:S.label?.baseline,labelRotate:S.label?.rotate}));}}return d}_interpolateValue(e,t){for(let n=1;n<t.length;n++){let r=t[n-1],o=t[n];if(!(r.value===null||o.value===null)&&e>=r.time&&e<=o.time){if(o.time===r.time)return r.value;let s=(e-r.time)/(o.time-r.time);return r.value+s*(o.value-r.value)}}}legendItems(){return this._legendItems()}_legendItems(){return this._series.map(e=>{let t=e.style?.line&&!Array.isArray(e.style.line)?e.style.line:void 0,n=e.style?.markers,r=n?.type&&n.type!=="none"&&(n.threshold===void 0||(e.data?.length??0)<=n.threshold),o=he(e)?e.avgColor??p.avgColor:p.stroke;return {name:e.name,color:t?.color??o,line:t?.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(e){return this._timeScale?this._timeScale.invert(e):0}invertValue(e,t=0){let n=this._valueScales.get(t);return n?n.invert(e):0}project(e,t,n=0){let r=this._timeScale?this._timeScale.map(e):0,o=this._valueScales.get(n);return {x:r,y:o?o.map(t):0}}};var we=class{};var ze="1.9.0";var Ut=` <!-- MLTimeGraph ${ze} -->`,kt=1e3;function b(i){return String(Math.round(i*kt)/kt)}function Ye(i){return Fe(i).toString(16).padStart(8,"0")}function Kt(i){switch(i){case "top":return "text-top";case "bottom":return "text-bottom";default:return "middle"}}var X=class extends we{#e="100%";#t="100%";#n;#i=new Map;#r=new Map;#o=new Map;constructor(e){super(),e?.width!==void 0&&(this.#e=e.width),e?.height!==void 0&&(this.#t=e.height),e?.background!==void 0&&(this.#n=e.background);}setBackgroundColor(e){this.#n=e;}render(e){this.#i.clear(),this.#r.clear(),this.#o.clear();let t=e.map(h=>this._toSVG(h));this.#n&&t.unshift(`<rect width="100%" height="100%" fill="${this._esc(this.#n)}" />`);let n=t.join(`
24
+ `.trim()}function Je(i,e=2,t=false){return i==="dashed"||!i&&t?{strokeDasharray:"4,4"}:i==="dotted"?{strokeDasharray:"2,4"}:!i||i==="solid"?null:yt(i,e)}function yt(i,e=2){let t=e;switch(i){case "dotted":return {strokeDasharray:`0, ${t*2}`,strokeLinecap:"round"};case "sparse-dots":return {strokeDasharray:`0, ${t*4}`,strokeLinecap:"round"};case "dashed":return {strokeDasharray:`${t*3}, ${t*2}`,strokeLinecap:"butt"};case "long-dash":return {strokeDasharray:`${t*6}, ${t*3}`,strokeLinecap:"butt"};case "dense-dash":return {strokeDasharray:`${t*1.5}, ${t*1.5}`,strokeLinecap:"butt"};case "dash-dot":return {strokeDasharray:`${t*4}, ${t*2}, 0, ${t*2}`,strokeLinecap:"round"};case "dash-dot-dot":return {strokeDasharray:`${t*5}, ${t*2}, 0, ${t*2}, 0, ${t*2}`,strokeLinecap:"round"};case "loose-dash":return {strokeDasharray:`${t*3}, ${t*4}`,strokeLinecap:"butt"};default:return {strokeDasharray:"none",strokeLinecap:"butt"}}}var g=new Proxy({},{get:(i,e)=>me()[e],has:(i,e)=>e in me(),ownKeys:()=>Reflect.ownKeys(me()),getOwnPropertyDescriptor:(i,e)=>Reflect.getOwnPropertyDescriptor(me(),e)});function Ce(i,e){if(e<=0||i.length<2)return [];let t=[];for(let n=0;n<i.length-1;n++){let r=i[n],o=i[n+1];for(let s=1;s<=e;s++)t.push(r+(o-r)*s/(e+1));}return t}var be={axisColor:g.axisColor,tickColor:g.tickColor,textColor:g.textColor,textSize:g.textSize},ue=class{#t;#e;constructor(e){this.#t=new he({domain:e.domain,range:e.xRange,locale:e.locale,timeZone:e.timeZone}),this.#e=e;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??be).axisColor}get tickColor(){return (this.#e.colors??be).tickColor}get textColor(){return (this.#e.colors??be).textColor}get textSize(){return (this.#e.colors??be).textSize}generateTicks(){let e=this.#e.minTicks??5,t=this.#e.maxTicks??12,r=this.#t.ticks({minTicks:e,maxTicks:t}).map(o=>({time:o,x:this.#t.map(o),label:this.tickLabel(o)}));return this.antiOverlap(r)}tickLabel(e){if(this.#e.format)return this.#e.format(new Date(e));let t=this.#e.minTicks??5,n=this.#e.maxTicks??12,{interval:r}=this.#t.tickInterval((t+n)/2,t,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(e,o)}antiOverlap(e){if(e.length<=1)return e;let t=60,n=[e[0]];for(let r=1;r<e.length;r++){let o=n[n.length-1].x;Math.abs(e[r].x-o)>=t&&n.push(e[r]);}return n}render(){let e=this.generateTicks(),t=this.#e.colors??be,n=this.#e.y??0,r=[],[o,s]=this.#t.range();r.push({type:"line",x1:o,y1:n,x2:s,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let a of this.generateMinorTicks())r.push({type:"line",x1:a,y1:n,x2:a,y2:n+3,stroke:t.tickColor,strokeWidth:t.axisWidth});for(let a of e)r.push({type:"line",x1:a.x,y1:n,x2:a.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:a.label,x:this.#n(a.x,a.label,t.textSize),y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}generateMinorTicks(){return Ce(this.generateTicks().map(e=>e.x),this.#e.minorTicks??0)}#n(e,t,n){let r=this.#e.gesamtbreite,o=this.#e.metrics;if(r===void 0||o===void 0)return e;let s=o(t,n)/2;return Math.max(s+2,Math.min(r-s-2,e))}};var ce={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function bt(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 on(i){let e=new Array(i.length).fill(false),t=0;for(;t<i.length;){let n=t;for(;n+1<i.length&&i[n+1].label===i[t].label;)n++;for(let r=t+1;r<n;r++)e[r]=true;t=n+1;}return e}var Me=class{#t;#e;constructor(e){this.#t=new re({domain:e.domain,range:e.range}),this.#e=e;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??ce).axisColor}get tickColor(){return (this.#e.colors??ce).tickColor}get textColor(){return (this.#e.colors??ce).textColor}get textSize(){return (this.#e.colors??ce).textSize}generateTicks(){let e=this.#e.tickValues;if(e&&e.length>0){let b=this.#e.format??bt;return e.map(f=>({value:f,position:this.#t.map(f),label:b(f)}))}let t=this.#e.format??bt,n=this.#e.ticks&&this.#e.ticks>0?this.#e.ticks:6,[r,o]=this.#t.domain(),s=Math.min(r,o),a=Math.max(r,o),l=a-s;if(l===0)return [{value:r,position:this.#t.map(r),label:t(r)}];let h=l/n,m=Math.pow(10,Math.floor(Math.log10(h))),u=h/m,c;if(u<=1.5?c=m:u<=3?c=2*m:u<=7?c=5*m:c=10*m,c<=0||!Number.isFinite(c))return [{value:r,position:this.#t.map(r),label:t(r)}];let p=[],d=Math.ceil(s/c)*c;for(let b=d;b<=a;b+=c)p.push({value:b,position:this.#t.map(b),label:t(b)});return p}generateMinorTicks(){return Ce(this.generateTicks().map(e=>e.position),this.#e.minorTicks??0)}render(){let e=this.generateTicks(),t=this.#e.colors??ce,n=this.#e.x??0,r=this.#e.orientation??"vertical",o=this.#e.position??"left",s=this.#e.suppressLabelsNear??[],a=this.#e.suppressTolerancePx??8,l=u=>s.some(c=>Math.abs(c-u)<=a),h=[];if(r==="vertical"){let[u,c]=this.#t.range();h.push({type:"line",x1:n,y1:u,x2:n,y2:c,stroke:t.axisColor,strokeWidth:t.axisWidth});let p=on(e);e.forEach((d,b)=>{let f=l(d.position),_=p[b]?{opacity:0}:{};o==="left"?(h.push({type:"line",x1:n-4,y1:d.position,x2:n,y2:d.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),f||h.push({type:"text",content:d.label,x:this.#n(n-8,d.label,"end"),y:d.position+4,anchor:"end",fontSize:t.textSize,fill:t.textColor,..._})):(h.push({type:"line",x1:n,y1:d.position,x2:n+4,y2:d.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),f||h.push({type:"text",content:d.label,x:this.#n(n+8,d.label,"start"),y:d.position+4,anchor:"start",fontSize:t.textSize,fill:t.textColor,..._}));});}else {let[u,c]=this.#t.range();h.push({type:"line",x1:u,y1:n,x2:c,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let p of e)h.push({type:"line",x1:p.position,y1:n,x2:p.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),h.push({type:"text",content:p.label,x:p.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}let m=(this.#e.orientation??"vertical")==="vertical";for(let u of this.generateMinorTicks())h.push(m?{type:"line",x1:o==="right"?n:n-2,y1:u,x2:o==="right"?n+2:n,y2:u,stroke:t.tickColor,strokeWidth:t.axisWidth}:{type:"line",x1:u,y1:n,x2:u,y2:n+3,stroke:t.tickColor,strokeWidth:t.axisWidth});return h}#n(e,t,n){let r=this.#e.gesamtbreite,o=this.#e.metrics;if(r===void 0||o===void 0)return e;let s=o(t,(this.#e.colors??ce).textSize);return n==="end"?Math.max(s+2,Math.min(r-2,e)):Math.min(r-s-2,Math.max(2,e))}};var z=class{static interpolateDataPoint(i,e,t){return {time:i.time+Math.round(t*(e.time-i.time)),value:(i.value??0)+t*((e.value??0)-(i.value??0)),synthetic:true}}static interpolateAggregatedPoint(i,e,t){let n=(r,o)=>r!==null&&o!==null?r+t*(o-r):null;return {time:i.time+t*(e.time-i.time),min:n(i.min,e.min),max:n(i.max,e.max),avg:n(i.avg,e.avg),count:Math.round(i.count+t*(e.count-i.count))}}static getRuns(i,e,t=0){let n=[...i].sort((a,l)=>a.time-l.time),r=[],o=[],s=null;for(let a of n){let l=e(a),h=t>0&&s&&a.time-s.time>t;(l||h)&&o.length&&(r.push(o),o=[]),l||o.push(a),s=a;}return o.length&&r.push(o),r}static splitByBoundaries(i,e,t,n){if(i.length===0)return [];if(e.length===0)return [{data:i,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let r=[...e].sort((h,m)=>h-m),o=[],s=h=>h<=0?Number.NEGATIVE_INFINITY:r[h-1],a=h=>{let m=0;for(let u=0;u<r.length&&h>=r[u];u++)m=u+1;return m},l=[i[0]];for(let h=1;h<i.length;h++){let m=i[h-1],u=i[h],c=t(m),p=t(u),d;p>c?d=r.filter(f=>f>c&&f<=p):p<c?d=r.filter(f=>f>=p&&f<c).reverse():d=[];let b=c;for(let f of d){let _=(f-c)/(p-c),A=n(m,u,_);l.push(A);let v=a((b+f)/2);o.push({data:l,zoneIndex:v,zoneLow:s(v)}),l=[A],b=f;}(d.length===0||d[d.length-1]!==p)&&l.push(u);}if(l.length>1||i.length===1){let h=t(l[0]),m=t(l[l.length-1]),u=a((h+m)/2);o.push({data:l,zoneIndex:u,zoneLow:s(u)});}return o}static splitByThreshold(i,e,t,n){let r=this.splitByBoundaries(i,[e],t,n),o={above:[],below:[]};for(let s of r)s.zoneIndex===0?o.below.push(s.data):o.above.push(s.data);return o}};function xt(i,e=6e4){if(i.length<2)return [];let t=[...i].sort((r,o)=>r.time-o.time),n=[];for(let r=1;r<t.length;r++)t[r].time-t[r-1].time>e&&n.push({startTime:t[r-1].time,endTime:t[r].time});return n}function sn(i,e=83144){let t=e/8.314,n=0,r=0;for(let s of i)s!==null&&(n+=Math.exp(-t/(s+273.15)),r++);if(r===0)return null;let o=n/r;return t/-Math.log(o)-273.15}function St(i,e,t=83144){let n=new Array(i.length),r=0;for(let o=0;o<i.length;o++){let s=i[o].time,a=s-e;for(;r<o&&i[r].time<a;)r++;let l=i.slice(r,o+1).map(m=>m.value),h=sn(l,t);n[o]={time:s,value:h,synthetic:true};}return n}function an(i){let e=0,t=0;for(let o of i)o!==null&&(e+=o,t++);if(t===0)return null;let n=e/t,r=0;for(let o of i){if(o===null)continue;let s=o-n;r+=s*s;}return Math.sqrt(r/t)}function ln(i){let e=0,t=0;for(let o of i)o!==null&&(e+=o,t++);if(t<2)return null;let n=e/t,r=0;for(let o of i){if(o===null)continue;let s=o-n;r+=s*s;}return Math.sqrt(r/(t-1))}function _t(i,e,t=false){let n=new Array(i.length),r=0,o=t?ln:an;for(let s=0;s<i.length;s++){let a=i[s].time,l=a-e;for(;r<s&&i[r].time<l;)r++;let h=i.slice(r,s+1).map(u=>u.value),m=o(h);n[s]={time:a,value:m,synthetic:true};}return n}function Qe(i,e){let t=new Array(i.length),n=0;for(let r=0;r<i.length;r++){let o=i[r].time,s=o-e;for(;n<r&&i[n].time<s;)n++;let a=0,l=0;for(let h=n;h<=r;h++){let m=i[h].value;m!==null&&(a+=m,l++);}t[r]={time:o,value:l===0?null:a/l,synthetic:true};}return t}function kt(i,e){let t=new Array(i.length),n=null,r=0;for(let o=0;o<i.length;o++){let s=i[o].time,a=i[o].value;if(a===null){t[o]={time:s,value:n,synthetic:true};continue}if(n===null||e<=0)n=a;else {let l=1-Math.exp(-(s-r)/e);n=a*l+n*(1-l);}r=s,t[o]={time:s,value:n,synthetic:true};}return t}function de(i){let e=[];for(let t of i)e.length>0&&e.push({...t,value:e[e.length-1].value}),e.push(t);return e}var Ae=class{};function wt(i,e,t,n){let r=$e(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let s=0;s<i.length;s++){let a=i[s],l=e.timeScale.map(a.time),h=e.valueScale.map(a.value),m=n(a),u=t.pointStroke??m,c=t.pointFill??m,p=t.pointStrokeWidth??1.5,d=t.id?`${t.id}-marker-${s}`:void 0;Le(o,d,r.markers.type,l,h,r.markers.size,u,c,p);}return o}function Le(i,e,t,n,r,o,s,a,l){let h=m=>e===void 0?void 0:`${e}-${m}`;switch(t){case "circle":i.push({type:"circle",cx:n,cy:r,r:o,fill:a,stroke:s,strokeWidth:l,id:e});break;case "square":i.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:a,stroke:s,strokeWidth:l,id:e});break;case "cross":i.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:s,strokeWidth:l,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:s,strokeWidth:l,id:h(2)});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}],closed:true,fill:a,stroke:s,strokeWidth:l,id:e});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}],closed:true,fill:a,stroke:s,strokeWidth:l,id:e});break;case "star":{let m=[];for(let u=0;u<10;u++){let c=u%2===0?o:o*.5,p=Math.PI/2*3+u*Math.PI/5;m.push({x:n+c*Math.cos(p),y:r+c*Math.sin(p)});}i.push({type:"path",points:m,closed:true,fill:a,stroke:s,strokeWidth:l,id:e});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:s,strokeWidth:l,fill:"none",id:e});break;case "plus":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:l,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:s,strokeWidth:l,id:h(2)});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}],closed:true,fill:a,stroke:s,strokeWidth:l,id:e});break;case "hexagon":{let m=[];for(let u=0;u<6;u++){let c=u*(Math.PI/3);m.push({x:n+o*Math.cos(c),y:r+o*Math.sin(c)});}i.push({type:"path",points:m,closed:true,fill:a,stroke:s,strokeWidth:l,id:e});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}],closed:true,fill:a,stroke:s,strokeWidth:l,id:e});break;case "line-horizontal":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:s,strokeWidth:l,id:e});break;default:i.push({type:"circle",cx:n,cy:r,r:o,fill:a,stroke:s,strokeWidth:l,id:e});}}var hn=[[32,126,"278,278,355,556,556,889,667,191,333,333,389,584,278,333,278,278,556,556,556,556,556,556,556,556,556,556,278,278,584,584,584,556,1015,667,667,722,722,667,611,778,722,278,500,667,556,833,722,778,667,778,722,667,611,722,667,944,667,667,611,278,278,278,469,556,333,556,556,500,556,556,278,556,556,222,222,500,222,833,556,556,556,556,333,500,278,556,500,722,500,500,500,334,260,334,584"],[160,255,"278,333,556,556,556,556,260,556,333,737,370,556,584,333,737,552,400,549,333,333,333,576,537,333,333,333,365,556,834,834,834,611,667,667,667,667,667,667,1000,722,667,667,667,667,278,278,278,278,722,722,778,778,778,778,778,584,778,722,722,722,722,667,667,611,556,556,556,556,556,556,889,500,556,556,556,556,278,278,278,278,556,556,556,556,556,556,556,549,611,556,556,556,556,500,556,500"]],et=.6,mn=(()=>{let i=new Map;for(let[e,,t]of hn){let n=t.split(",");for(let r=0;r<n.length;r++)i.set(e+r,Number(n[r])/1e3);}return i})();function vt(i){return mn.get(i)??et}var pe=(i,e)=>{let t=0;for(let n of i)t+=vt(n.codePointAt(0)??0);return t*e},un=(i,e)=>[...i].length*e*et;function Tt(i,e,t){let n=0;for(let r of i)n=Math.max(n,t(r,e));return n}var oe=12,Pe=8,tt=20,cn=11,De=18,nt=(i,e)=>e(i,cn);function Ct(i,e,t){let n=a=>oe+Pe+nt(a.name,e);if(t===void 0){let a=i.reduce((l,h)=>l+n(h)+De,0)-De;return [{items:i,breite:Math.max(0,a)}]}let r=[],o=[],s=0;for(let a of i){let l=n(a),h=o.length===0?l:s+De+l;o.length>0&&h>t?(r.push({items:o,breite:s}),o=[a],s=l):(o=[...o,a],s=h);}return o.length>0&&r.push({items:o,breite:s}),r}function Mt(i,e="vertical",t=pe,n){if(e==="horizontal"){let o=Ct(i,t,n);return {width:o.reduce((s,a)=>Math.max(s,a.breite),0),height:o.length*tt}}let r=0;for(let o of i)r=Math.max(r,nt(o.name,t));return {width:oe+Pe+r,height:i.length*tt}}function At(i){let{items:e,x:t,y:n,orientation:r="vertical",metrics:o=pe,maxBreite:s}=i,a=[],l=r==="horizontal"?Ct(e,o,s):e.map(m=>({items:[m],breite:0})),h=new Map;return l.forEach((m,u)=>{let c=t;for(let p of m.items)h.set(p,{x:c,y:n+u*tt}),c+=oe+Pe+nt(p.name,o)+De;}),e.forEach(m=>{let u=h.get(m)??{x:t,y:n},c=u.x,p=u.y;a.push({type:"rect",x:c,y:p,w:oe,h:oe,fill:m.color,stroke:g.legendStroke,strokeWidth:1},{type:"text",content:m.name,x:c+oe+Pe,y:p+oe-2,fontSize:g.legendFont,fill:g.legendText});}),{type:"group",cssClass:"chart-legend",commands:a}}function it(i){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=g.gridStroke,strokeWidth:s=g.gridStrokeWidth,dashed:a=false,opacity:l=g.gridOpacity}=i,h=[];if(t)for(let m of t)h.push({type:"line",x1:n[0],y1:m,x2:n[1],y2:m,stroke:o,strokeWidth:s,dashed:a,opacity:l});if(e)for(let m of e)h.push({type:"line",x1:m,y1:r[0],x2:m,y2:r[1],stroke:o,strokeWidth:s,dashed:a,opacity:l});return h}function dn(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function Lt(i){let{thresholds:e,valueScale:t,xRange:n}=i,[r,o]=n,[s,a]=t.range(),l=Math.min(s,a),h=Math.max(s,a),m=[],u=[];for(let c of e){let p=c.color??g.thresholdColor,d=t.map(c.value);c.fill==="above"?m.push({type:"rect",x:r,y:l,w:o-r,h:Math.max(0,d-l),fill:p,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0}):c.fill==="below"&&m.push({type:"rect",x:r,y:d,w:o-r,h:Math.max(0,h-d),fill:p,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0});let b=c.line??g.thresholdLine;if(b!=="none"){let v=dn(b),w={type:"line",x1:r,y1:d,x2:o,y2:d,stroke:p,strokeWidth:1,...v,id:c.id?`${c.id}-line`:void 0};c.shadowColor&&(w.shadowColor=c.shadowColor,w.shadowBlur=c.shadowBlur??4,w.shadowOffsetX=c.shadowOffsetX??0,w.shadowOffsetY=c.shadowOffsetY??2),m.push(w);}let[f,_]=t.domain();if(c.value>=Math.min(f,_)&&c.value<=Math.max(f,_)&&c.label!==void 0&&c.label!==null&&c.label!==false){let v=typeof c.label=="object"?c.label:void 0,w=typeof c.label=="string"?c.label:v?.text??c.name,P=v?.position??"right",B=fn(w,P,r,o,d,p,v);u.push({...B,y:pn(B.y,Math.min(s,a),Math.max(s,a),g.thresholdFontSize),id:c.id?`${c.id}-label`:void 0});}}return {inside:m,labels:u}}function pn(i,e,t,n){return Math.max(e+n,Math.min(t-n/2,i))}function fn(i,e,t,n,r,o,s){let a=(t+n)/2,l={type:"text",content:i,fontSize:g.thresholdFontSize,fill:o},h=s?{...s.rotate!==void 0&&{rotate:s.rotate},...s.textBaseline!==void 0&&{textBaseline:s.textBaseline}}:{};switch(e){case "left":return {...l,...h,x:t+4,y:r-4,anchor:"start"};case "above":return {...l,...h,x:a,y:r-6,anchor:"middle"};case "below":return {...l,...h,x:a,y:r+14,anchor:"middle"};case "center":return {...l,...h,x:a,y:r-4,anchor:"middle"};case "outside-left":return {...l,...h,x:t-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 $t(i,e,t,n){switch(i){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":case "middle":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function je(i){let{ranges:e,timeScale:t,yRange:n,height:r}=i,[o,s]=n,a=[],[l,h]=t.range(),m=Math.min(l,h),u=Math.max(l,h),c=p=>Math.max(m,Math.min(u,p));for(let p of e){let d=c(t.map(p.startTime)),b=c(t.map(p.endTime));if(p.fill!==void 0&&a.push({type:"rect",x:d,y:o,w:b-d,h:s-o,fill:p.fill,hatch:p.hatch,opacity:p.opacity}),p.edges)for(let f of [d,b])a.push({type:"line",x1:f,y1:o,x2:f,y2:s,stroke:p.edges.stroke,strokeWidth:p.edges.strokeWidth,dash:"dashed"});p.label&&a.push({type:"text",content:p.label,x:(d+b)/2,y:$t(p.labelPosition??"middle",o,s,r),anchor:"middle",fontSize:p.fontSize,fill:p.labelColor,rotate:p.rotate});}return a}function rt(i){let{gaps:e,timeScale:t,yRange:n,height:r,fill:o=g.gapFill,hatch:s,fillOpacity:a=g.gapFillOpacity??.15,stroke:l=g.gapStroke,strokeWidth:h=g.gapStrokeWidth,dashed:m=true,fontSize:u=g.gapFontSize,fontFill:c=g.gapFontColor,labelBaseline:p="middle",labelRotate:d}=i;return je({timeScale:t,yRange:n,height:r,ranges:e.map(b=>{let f=b.style??"dashed_border",_=f==="filled"||f==="dashed_border",A=f==="dashed_border"&&m!==false;return {startTime:b.startTime,endTime:b.endTime,..._&&{fill:b.fill??o,hatch:b.hatch??s,opacity:b.fillOpacity??a},...A&&{edges:{stroke:l,strokeWidth:h}},label:b.label,labelPosition:b.labelBaseline??p,labelColor:c,fontSize:u,rotate:b.rotate??d}})})}function Dt(i){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=i,[o,s]=r,a=[];for(let l of e){let h=t.map(l.time),m=l.color??g.markerColor,u=l.pointStyle??(l.value!==void 0?"circle":"none"),c=l.lineStyle??"full";if(l.value!==void 0){let p=n.map(l.value);if(c==="to-value"?a.push({type:"line",x1:h,y1:s,x2:h,y2:p,stroke:m,strokeWidth:1,dashed:true}):c==="to-top"?a.push({type:"line",x1:h,y1:o,x2:h,y2:p,stroke:m,strokeWidth:1,dashed:true}):c==="full"&&a.push({type:"line",x1:h,y1:o,x2:h,y2:s,stroke:m,strokeWidth:1}),u!=="none"&&Le(a,void 0,u,h,p,g.markerSize,m,m,1.5),l.label){let d=c==="to-value"?p-10:o-6;a.push({type:"text",content:l.label,x:h,y:d,anchor:"middle",fontSize:g.markerFontSize,fill:m});}}else c!=="none"&&a.push({type:"line",x1:h,y1:o,x2:h,y2:s,stroke:m,strokeWidth:1}),l.label&&a.push({type:"text",content:l.label,x:h,y:o-6,anchor:"middle",fontSize:g.markerFontSize,fill:m});}return a}function Pt(i){let{highlights:e,timeScale:t,yRange:n,height:r}=i;return je({timeScale:t,yRange:n,height:r,ranges:e.map(o=>({startTime:o.startTime,endTime:o.endTime,fill:o.color??g.highlightColor,opacity:o.opacity??g.highlightOpacity,label:o.label,labelPosition:o.labelPosition??"top",labelColor:o.color??g.highlightLabelColor,fontSize:g.annotationFontSize,rotate:o.rotate}))})}function jt(i){let{annotations:e,timeScale:t,valueScales:n}=i,r=[],o=s=>{let a=n.get(s.axis??0)??n.values().next().value;return {x:t.map(s.time),y:a?a.map(s.value):0}};for(let s of e){let a=[],l=h=>a.push(h);switch(s.type){case "line":{let h=o(s.from),m=o(s.to);l({type:"line",x1:h.x,y1:h.y,x2:m.x,y2:m.y,stroke:s.color??g.annotationColor,strokeWidth:s.width??g.annotationWidth,dash:s.dash});break}case "arrow":{let h=o(s.from),m=o(s.to),u=s.color??g.annotationColor,c=s.headSize??g.annotationHead;l({type:"line",x1:h.x,y1:h.y,x2:m.x,y2:m.y,stroke:u,strokeWidth:s.width??g.annotationWidth});let p=Math.hypot(m.x-h.x,m.y-h.y)||1,d=(m.x-h.x)/p,b=(m.y-h.y)/p,f=m.x-d*c,_=m.y-b*c;l({type:"path",points:[{x:m.x,y:m.y},{x:f-b*c*.5,y:_+d*c*.5},{x:f+b*c*.5,y:_-d*c*.5}],fill:u,stroke:"none"});break}case "rect":{let h=o(s.from),m=o(s.to);l({type:"rect",x:Math.min(h.x,m.x),y:Math.min(h.y,m.y),w:Math.abs(m.x-h.x),h:Math.abs(m.y-h.y),fill:s.fill??"none",hatch:s.hatch,stroke:s.stroke,opacity:s.opacity});break}case "point":{let h=o(s.at),m=s.color??"#334155",u=s.radius??g.annotationRadius,c=s.shape??"circle";c==="circle"?l({type:"circle",cx:h.x,cy:h.y,r:u,fill:m}):c==="square"?l({type:"rect",x:h.x-u,y:h.y-u,w:u*2,h:u*2,fill:m}):(l({type:"line",x1:h.x-u,y1:h.y-u,x2:h.x+u,y2:h.y+u,stroke:m,strokeWidth:1.5}),l({type:"line",x1:h.x-u,y1:h.y+u,x2:h.x+u,y2:h.y-u,stroke:m,strokeWidth:1.5}));break}case "label":{let h=o(s.at);l({type:"text",content:s.text,x:h.x+(s.dx??0),y:h.y+(s.dy??0),anchor:s.anchor??gn(h.x+(s.dx??0),s.text,i),fontSize:g.annotationFontSize,fill:s.color??g.annotationColor,rotate:s.rotate});break}}if(s.id&&a.length>0){let h=le(s.id);r.push({type:"group",cssClass:`annotation annotation--${h}`,commands:a});}else r.push(...a);}return r}function gn(i,e,t){let{metrics:n,timeScale:r}=t;if(!n)return "middle";let[o,s]=r.range(),a=n(e,g.annotationFontSize)/2;return i-a<o?"start":i+a>s?"end":"middle"}var fe=class i{#t;#e;static uidcnt=0;#n;constructor(e,t=[]){this.#t=e.id??"series-"+ ++i.uidcnt,this.#e=e.timeScale,this.#n=t;}get id(){return this.#t}get timeScale(){return this.#e}get data(){return this.#n}};var Fe=class extends fe{#t;constructor(e){super(e,e.data),this.#t=e;}opacity(e){if(!(this.#t.countOpacity??false))return .6;let t=0;for(let n of this.data)n.count>t&&(t=n.count);return t===0?.2:.2+.8*e/t}render(){let e=this.#t,t=e.fill??g.bandFill,n=e.hatch,r=e.avgLine??false,o=e.avgLineColor??g.bandAvgLine,s=e.bandWidth??10,a=[];for(let l of this.data){if(l.min===null||l.max===null)continue;let h=this.timeScale.map(l.time),m=e.valueScale.map(l.max),u=e.valueScale.map(l.min),c=s,p=this.data.indexOf(l);if(a.push({type:"rect",x:h-c/2,y:m,w:c,h:u-m,fill:t,hatch:n,opacity:this.opacity(l.count),id:this.id?`${this.id}-slot-${p}`:void 0}),r&&l.avg!==null){let d=e.valueScale.map(l.avg);a.push({type:"line",x1:h-c/2,y1:d,x2:h+c/2,y2:d,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${p}`:void 0});}}return a}};var yn=1,Re=class{#t;constructor(e,t,n,r){this.#t={...e,xRange:t,y:n,height:r};}render(){let{items:e,timeScale:t,background:n,hatch:r,showAxis:o,xRange:s,y:a,height:l}=this.#t,h=[];n&&h.push({type:"rect",x:s[0],y:a,w:s[1]-s[0],h:l,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let m of e){let u=t.map(m.startTime),c=t.map(m.endTime);if(c<s[0]||u>s[1])continue;let p=Math.max(s[0],Math.min(s[1],u)),d=Math.max(s[0],Math.min(s[1],c)),b=Math.max(d-p,yn);p+b>s[1]&&(p=Math.max(s[0],s[1]-b));let f=p+b/2;if(h.push({type:"rect",x:p,y:a,w:b,h:l,hatch:m.hatch??r,fill:m.fill??"#6b728044",stroke:m.stroke,strokeWidth:m.strokeWidth??0,title:m.title}),m.label){let _=m.labelFontSize??10;h.push({type:"text",content:m.label,x:f,y:this.#e(m.labelBaseline,_),anchor:"middle",fontSize:_,fill:m.labelFill??"#333"});}}if(o){let m=new ue({domain:t.domain(),xRange:s,y:a+l+4});h.push({type:"group",cssClass:"annotation-band-axis",commands:m.render()});}return h}#e(e,t){let{y:n,height:r}=this.#t;switch(e){case "top":return n+t*.9;case "bottom":return n+r-t*.25;default:return n+r/2+t*.35}}};function $e(i){return {id:i.id,line:{stroke:i.stroke??g.stroke,strokeWidth:i.strokeWidth??g.strokeWidth,smoothing:i.smoothing??false,smoothingType:i.smoothingType,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 Be(i,e,t){let n=[],r=$e(t);for(let o=0;o<i.length;o++){let s=i[o];s.data.length>=2?n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${o}`:void 0,points:s.data.map(a=>({x:e.timeScale.map(a.time),y:e.valueScale.map(a.value)})),stroke:s.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"}):s.data.length===1&&n.push({type:"circle",id:t.id?`${t.id}-dot-${o}`:void 0,cx:e.timeScale.map(s.data[0].time),cy:e.valueScale.map(s.data[0].value),r:Math.max(r.markers.size,r.line.strokeWidth),fill:s.color??r.line.stroke,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur});}return n}function ot(i,e,t,n){if(i.length<2)return [];let r=z.splitByBoundaries(i,t.boundaries,t.getValue,t.interpolate),o=[];for(let s=0;s<r.length;s++){let a=r[s];if(a.data.length<2)continue;let l=t.getColor(a.zoneIndex);if(!l)continue;let h=a.data.map(u=>({x:e.timeScale.map(u.time),y:e.valueScale.map(t.yLow(u))})),m=a.data.map(u=>({x:e.timeScale.map(u.time),y:e.valueScale.map(t.yHigh(u))})).reverse();o.push({type:"path",cssClass:"series-fill",id:n?.id?`${n.id}-fill-${s}`:void 0,points:[...h,...m],fill:l,hatch:t.getHatch?.(a.zoneIndex),stroke:"none"});}return o}var Oe=class extends fe{#t;constructor(e){super(e,e.data),this.#t=e;}render(){let e=this.#t,t=e.minColor??g.minColor,n=e.maxColor??g.maxColor,r=e.avgColor??g.avgColor,o=e.avgDashed??true,s=e.smoothing??false,a=e.smoothingType,l=e.strokeWidth??g.strokeWidth,h=z.getRuns(this.data,d=>d.min===null||d.max===null||d.avg===null);if(h.length===0)return [];let m={timeScale:this.timeScale,valueScale:e.valueScale},u=[];h.forEach((d,b)=>{d.length<2||(e.fillToMax&&u.push(...ot(d,m,{boundaries:[],yLow:f=>f.avg,yHigh:f=>f.max,getValue:f=>f.avg,interpolate:z.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${b}`:void 0})),e.fillToMin&&u.push(...ot(d,m,{boundaries:[],yLow:f=>f.avg,yHigh:f=>f.min,getValue:f=>f.avg,interpolate:z.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${b}`:void 0})));});let c=h.filter(d=>d.length>=2),p=d=>c.map(b=>({data:b.map(f=>({time:f.time,value:d(f)}))}));return u.push(...Be(p(d=>d.max),m,{stroke:n,strokeWidth:l,smoothing:s,smoothingType:a,id:this.id?`${this.id}-max`:void 0}),...Be(p(d=>d.min),m,{stroke:t,strokeWidth:l,smoothing:s,id:this.id?`${this.id}-min`:void 0}),...Be(p(d=>d.avg),m,{stroke:r,strokeWidth:l,smoothing:s,dashed:o,id:this.id?`${this.id}-avg`:void 0})),u}};function st(i){return i!==void 0&&typeof i=="object"&&"series"in i?i.series:null}function Ft(i){let e=[...i].sort((n,r)=>n.time-r.time),t=0;return n=>{for(;t>0&&e[t].time>n;)t--;for(;t<e.length-1&&e[t+1].time<=n;)t++;let r=e[t];if(!r||n<r.time)return null;if(r.time===n)return r.value??null;let o=e[t+1];if(!o||n>o.time||r.value===null||o.value===null)return null;let s=o.time-r.time;return s===0?r.value:r.value+(o.value-r.value)*(n-r.time)/s}}function Rt(i,e,t){let n=i??e;if(n==="series")return null;if(n==="chartTop")return t.chartTop;if(n==="chartBottom")return t.chartBottom;if(typeof n=="object"&&"threshold"in n){let r=t.thresholds.get(n.threshold);if(!r)throw new Error(`fillSpec region references unknown threshold '${n.threshold}'`);return t.valueScale.map(r.value)}return typeof n=="object"&&"value"in n?t.valueScale.map(n.value):null}function bn(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function Bt(i,e,t){let n=Rt(i.from,"chartBottom",e),r=Rt(i.to,"series",e),{color:o,hatch:s}=bn(i.fill),a={type:"path",fill:o,hatch:s,stroke:"none",cssClass:"series-fill"},l=f=>e.idPrefix?{id:`${e.idPrefix}-fill-r${t}-${f}`}:{},h=st(i.from),m=st(i.to);if(h!==null||m!==null){if(!e.fremdeSerie)throw new Error(`fillSpec region references series '${h??m}', but no series lookup was provided`);let f=(v,w,P)=>{let B=v??w,R=st(B);if(R!==null){let S=e.fremdeSerie(R);if(!S)throw new Error(`fillSpec region references unknown series '${R}'`);let $=S.shape==="step"?de(S.data):S.data;return {bei:Ft($),zeiten:$.map(j=>j.time)}}if(B==="series")return {bei:Ft(P),zeiten:P.map(S=>S.time)};let E=at(B,e),G=e.valueScale.domain(),V=E??(B==="chartBottom"?G[0]:G[1]);return {bei:()=>V,zeiten:[]}},_=e.shape==="step",A=[];for(let v of e.runs){if(v.length<2)continue;let w=_?de(v):v,P=f(i.from,"chartBottom",w),B=f(i.to,"series",w),R=w[0].time,E=w[w.length-1].time,G=[...new Set([...P.zeiten,...B.zeiten,...w.map(j=>j.time)])].filter(j=>j>=R&&j<=E).sort((j,F)=>j-F),V=[],S=[],$=()=>{if(V.length>=2){let j=[...S].reverse();A.push({...a,...l(A.length),smoothing:_?false:e.smoothing,smoothingType:e.smoothingType,smoothCount:V.length,points:[...V,...j]});}V=[],S=[];};for(let j of G){let F=P.bei(j),D=B.bei(j);if(F===null||D===null){$();continue}let O=e.timeScale.map(j);V.push({x:O,y:e.valueScale.map(D)}),S.push({x:O,y:e.valueScale.map(F)});}$();}return A}if(n!==null&&r!==null){let f=e.timeScale.range(),_=f[0],A=f[1],v=Math.min(n,r),w=Math.max(n,r);return [{...a,...l(0),points:[{x:_,y:v},{x:A,y:v},{x:A,y:w},{x:_,y:w}]}]}let u=n??r,c=[],p=xn(i,e);if(p===null){let f=e.valueScale.domain();p=(n??r)===e.chartBottom?f[0]:f[1];}let d=at(i.outer,e),b=e.shape==="step";for(let f of e.runs){if(f.length<2)continue;let _=b?de(f):f,A=z.splitByThreshold(_,p,w=>w.value??p,z.interpolateDataPoint),v=i.side==="above"?A.above:i.side==="below"?A.below:[...A.above,...A.below];if(d!==null&&i.side){let w=d,P=i.side==="above"?B=>Math.min(B,w):B=>Math.max(B,w);v=v.map(B=>B.map(R=>({...R,value:P(R.value??w)})));}for(let w of v){if(w.length<2)continue;let P=w.map(R=>({x:e.timeScale.map(R.time),y:e.valueScale.map(R.value)})),B=[];for(let R of [...P].reverse()){let E=B[B.length-1];b&&E&&E.x===R.x||B.push({x:R.x,y:u});}c.push({...a,...l(c.length),smoothing:b?false:e.smoothing,smoothingType:e.smoothingType,smoothCount:P.length,points:[...P,...B]});}}return c}function xn(i,e){let t=i.from==="series"?i.to:i.from;return at(t,e)}function at(i,e){return i===void 0||i==="series"||i==="chartTop"||i==="chartBottom"?null:typeof i=="object"&&"threshold"in i?e.thresholds.get(i.threshold)?.value??null:typeof i=="object"&&"value"in i?i.value:null}function Ot(i,e){if(typeof i=="string"||!("regions"in i))return Bt({fill:i},e,0);let t=[];return i.regions.forEach((n,r)=>{t.push(...Bt(n,e,r));}),t}function Ht(i){let e=i.style?.line,t=e&&!Array.isArray(e)?e:void 0;return {color:t?.color??g.stroke,width:t?.width??g.strokeWidth,dash:t?.style,smoothing:t?.smoothing??false,smoothingType:t?.smoothingType}}function It(i,e,t,n,r){let o=i.filter(h=>h.value!==null);if(o.length<2)return [];let s=o.map(h=>({x:e.timeScale.map(h.time),y:e.valueScale.map(h.value)})),a=Ht(t);return [{type:"path",cssClass:"series-line",id:e.idPrefix?`${e.idPrefix}-overlay-${r}-${n}`:`overlay-${r}-${n}`,points:s,stroke:a.color,strokeWidth:a.width,smoothing:a.smoothing,smoothingType:a.smoothingType,dash:a.dash,fill:"none"}]}function Wt(i,e,t=0){switch(i.kind){case "movingAverage":{let n=i.type==="exponential"?kt(e.data,i.window):Qe(e.data,i.window);return It(n,e,i,"movingAvg",t)}case "movingMkt":{let n=St(e.data,i.window,i.activationEnergy);return It(n,e,i,"movingMkt",t)}case "limits":{let n=[],r=e.timeScale.range(),o=r[0],s=r[1],a=Ht(i),l=a.color,h=a.width,m=a.dash??"dashed",u=e.idPrefix?`${e.idPrefix}-overlay-${t}-`:`overlay-${t}-`;return i.high!==void 0&&n.push({type:"line",id:`${u}limit-high`,x1:o,y1:e.valueScale.map(i.high),x2:s,y2:e.valueScale.map(i.high),stroke:l,strokeWidth:h,dash:m}),i.low!==void 0&&n.push({type:"line",id:`${u}limit-low`,x1:o,y1:e.valueScale.map(i.low),x2:s,y2:e.valueScale.map(i.low),stroke:l,strokeWidth:h,dash:m}),n}case "stdDevBand":{let n=i.multiplier??1,r=Qe(e.data,i.window),o=_t(e.data,i.window),s=[],a=[];for(let f=0;f<r.length;f++){let _=r[f].value,A=o[f].value;if(_===null||A===null)continue;let v=e.timeScale.map(r[f].time);s.push({x:v,y:e.valueScale.map(_+n*A)}),a.push({x:v,y:e.valueScale.map(_-n*A)});}if(s.length<2)return [];let l=e.idPrefix?`${e.idPrefix}-overlay-${t}-`:`overlay-${t}-`,h=[],u=(typeof i.style?.fill=="string"||i.style?.fill&&!("regions"in i.style.fill)?i.style.fill:void 0)??"#94a3b833",{color:c,hatch:p}=Sn(u);h.push({type:"path",cssClass:"series-fill",id:`${l}stdDevBand`,points:[...s,...[...a].reverse()],fill:c,hatch:p,stroke:"none"});let d=i.style?.line,b=d&&!Array.isArray(d)?d:void 0;if(b){let f=r.filter(_=>_.value!==null).map(_=>({x:e.timeScale.map(_.time),y:e.valueScale.map(_.value)}));f.length>=2&&h.push({type:"path",cssClass:"series-line",id:`${l}stdDevBand-mean`,points:f,stroke:b.color??g.stroke,strokeWidth:b.width??1.5,smoothing:b.smoothing,smoothingType:b.smoothingType,dash:b.style,fill:"none"});}return h}}}function Sn(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function _n(i){if(!i)return {gaps:[],autoDetect:false,minGapMs:6e4};if(Array.isArray(i))return {gaps:i,autoDetect:false,minGapMs:6e4};let e=i.regions??[],t=i.style;return {gaps:e.map(r=>{let o={...t,...r.style},s=o.fill,a,l;return typeof s=="string"?a=s:s&&(a=s.color,l=s.hatch),{startTime:r.startTime,endTime:r.endTime,label:r.label,fill:a,hatch:l,fillOpacity:o.opacity,labelBaseline:o.label?.baseline,rotate:o.label?.rotate,style:o.display==="bridge_line"?void 0:o.display}}),autoDetect:i.autoDetect??false,minGapMs:i.minGapMs??6e4}}function kn(i,e,t,n){if(n===void 0)return [i,e];let r=typeof n=="number"?n:n.top??0,o=typeof n=="number"?n:n.bottom??0;if(r<=0&&o<=0)return [i,e];let s=t-r-o,a=e-i;if(s<=0||a<=0)return [i,e];let l=a/s;return [i-o*l,e+r*l]}function xe(i){return "showAs"in i&&!!i.showAs}function Nt(i,e){if(e)for(let t of i)t.type==="text"?t.fontFamily||(t.fontFamily=e):t.type==="group"&&Array.isArray(t.commands)&&Nt(t.commands,e);}function wn(i,e,t){let r=new Array(i.length),o=e.map(s=>({position:s.position,von:s.von,bis:s.bis}));for(let s of ["left","right"]){let a=s==="left",l=i.map((h,m)=>({t:h,i:m})).filter(h=>h.t.position===s).sort((h,m)=>a?m.t.achseX-h.t.achseX:h.t.achseX-m.t.achseX);for(let{t:h,i:m}of l){let u=h.schrift/2,c=o.filter(b=>b.position===s),p=h.kante,d=a?p-1-u:p+1+u;for(let b=0;b<=c.length;b++){let f=d-u-1,_=d+u+1,A=c.find(v=>f<v.bis&&v.von<_);if(!A)break;p=a?A.von:A.bis,d=a?p-1-u:p+1+u;}if(a?d-u<2:d+u>t-2){let b=o.filter(f=>f.position===s&&f.titel);d=a?u+2:t-u-2;for(let f=0;f<=b.length;f++){let _=d-u-1,A=d+u+1,v=b.find(w=>_<w.bis&&w.von<A);if(!v)break;d=a?v.bis+1+u:v.von-1-u;}}o.push({position:s,von:d-u-1,bis:d+u+1,titel:true}),r[m]=d;}}return {xs:r,belegt:o}}function Et(i,e){return i!==void 0?i:e!==void 0&&e!==false?1:0}var se=class{_layout;_renderer;_locale;_timeZone;_fontFamily;_legend;_textMetrics;_clipSeries;_markers;_thresholds;_highlights;_gaps;_gapsAutoDetect;_gapsMinGapMs;_annotations;_annotationBands;_disabledAnnotations=new Set;_annotationSeq=0;_axes;_series;readonly_annotationBandHeight=0;_timeScale;_valueScales=new Map;constructor(e={}){this._layout=new ye({width:e.width??800,height:e.height??400,margin:e.margin??{top:20,right:20,bottom:40,left:60}}).compute(),this._renderer=e.renderer,this._locale=e.locale,this._timeZone=e.timeZone,this._fontFamily=e.fontFamily,this._legend=e.legend,this._textMetrics=e.textMetrics??pe,this._clipSeries=e.clipSeries??true,this._markers=e.markers??[],this._thresholds=e.thresholds??[],this._highlights=e.highlights??[];let t=_n(e.gaps);this._gaps=t.gaps,this._gapsAutoDetect=t.autoDetect,this._gapsMinGapMs=t.minGapMs,this._annotations=e.annotations??[],this._annotationBands=e.annotationBands??[],this._axes=e.axes,this._series=[],e.series&&this.setData(e.series);}getWidth(){return this._layout.totalWidth}getHeight(){return this._layout.totalHeight+this._annotationBandTotalHeight()}get series(){return this._series}_annotationBandTotalHeight(){let e=0;for(let t of this._annotationBands){let n=t.height??12,r=t.spacing??0;(t.showAxis??false)&&(e+=26+r),e+=n+r;}return e}setData(e){this._series=e.filter(t=>Array.isArray(t.data));}addAnnotation(e){let t=e.id??`anno-${++this._annotationSeq}`;return this._annotations.push({...e,id:t}),t}removeAnnotation(e){let t=this._annotations.length;return this._annotations=this._annotations.filter(n=>n.id!==e),this._disabledAnnotations.delete(e),this._annotations.length<t}setAnnotations(e){this._annotations=[...e],this._disabledAnnotations.clear();}clearAnnotations(){this._annotations=[],this._disabledAnnotations.clear();}getAnnotations(){return this._annotations}disableAnnotation(e){this._disabledAnnotations.add(e);}enableAnnotation(e){this._disabledAnnotations.delete(e);}_axisIndexOf(e){return e.yAxisIndex??0}_timesOf(e){return e.data.map(t=>t.time)}_valuesOf(e){if(xe(e)){let t=[];for(let n of e.data)n.min!==null&&t.push(n.min),n.max!==null&&t.push(n.max);return t}return e.data.map(t=>t.value).filter(t=>t!==null)}renderCommands(){if(this._series.length===0)return [];let e=this._legendItems(),t=(this._legend?.show??false)&&e.length>0,n=this._legend?.position??"inside-right",r=this._legend?.orientation??(n==="above"||n==="below"?"horizontal":"vertical"),o=n==="above"||n==="below"?this._layout.totalWidth-16:void 0,s=t?Mt(e,r,this._textMetrics,o):{width:0,height:0},a=this._layout;if(t&&(n==="outside-right"||n==="outside-left"||n==="above"||n==="below")){let y={...this._layout.margin};n==="outside-right"?y.right+=s.width+16:n==="outside-left"?y.left+=s.width+16:n==="above"?y.top+=s.height+10:y.bottom+=s.height+10,a=new ye({width:this._layout.totalWidth,height:this._layout.totalHeight,margin:y}).compute();}let{chartX:l,chartY:h,chartWidth:m,chartHeight:u}=a,c=[l,l+m],p=[h,h+u],d=[];for(let y of this._series)y.data.sort((k,M)=>k.time-M.time);let b=new Map,f=1/0,_=-1/0,A=false;for(let y of this._series){let k=this._axisIndexOf(y),M=b.get(k);M?M.push(y):b.set(k,[y]);for(let L of this._timesOf(y))L<f&&(f=L),L>_&&(_=L),A=true;}if(!A)return [];let v=this._axes?.x?.domain,w=v&&v!=="auto"?v:[f,_];this._timeScale=new he({domain:w,range:c,locale:this._locale,timeZone:this._timeZone});let P=y=>({axisColor:y?.color??g.axisColor,tickColor:y?.color??g.tickColor,textColor:g.textColor,textSize:g.textSize,axisWidth:y?.width??1}),B=new ue({domain:w,xRange:c,y:h+u,locale:this._locale,timeZone:this._timeZone,format:this._axes?.x?.format,maxTicks:this._axes?.x?.ticks?.major,minorTicks:Et(this._axes?.x?.ticks?.minor,this._axes?.x?.grid?.minor),colors:P(this._axes?.x?.axis),gesamtbreite:a.totalWidth,metrics:this._textMetrics});this._valueScales.clear();let R=Array.from(b.keys()).sort((y,k)=>y-k),E,G=[],V=[],S=(this._axes?.y?.length??0)>0,$=0,j=0;for(let y of R){let k=b.get(y),M=1/0,L=-1/0,H=false;for(let W of k)for(let we of this._valuesOf(W))we<M&&(M=we),we>L&&(L=we),H=true;if(!H)continue;M===L&&(M-=1,L+=1);let I=y===0?this._axes?.left:y===1?this._axes?.right:void 0,U=this._axes?.y&&this._axes.y.length>y?this._axes.y[y]:void 0,N=U&&I?{...I,...U}:U??I,ke=N?.domain,ee=ke&&ke!=="auto"?ke:kn(M,L,u,N?.padding),q=this._zustaendeVon(k);if(q){let W=q.length>1?(q[q.length-1]-q[0])/(q.length-1):1;ee[0]=q[0]-W/2,ee[1]=q[q.length-1]+W/2;}let ct=new re({domain:ee,range:[h+u,h]});this._valueScales.set(y,ct);let dt=this._thresholds.filter(W=>(W.axisIndex??0)===y&&W.label!==void 0&&W.label!==null&&W.label!==false&&W.value>=Math.min(ee[0],ee[1])&&W.value<=Math.max(ee[0],ee[1])).map(W=>ct.map(W.value)),ae=N?.position??(y===0?"left":"right"),te;if(ae==="right"){let W=N?.offset??j*50;te=l+m+W,j++;}else {let W=N?.offset??$*50;te=l-W,$++;}let Ue=new Me({domain:ee,range:[h+u,h],x:te,position:ae,format:N?.format??(q?this._zustandName(k):void 0),tickValues:q,ticks:N?.ticks?.major,minorTicks:Et(N?.ticks?.minor,N?.grid?.minor),colors:P(N?.axis),suppressLabelsNear:dt.length?dt:void 0,gesamtbreite:a.totalWidth,metrics:this._textMetrics}),pt=8+Tt(Ue.generateTicks().map(W=>W.label),11,this._textMetrics),qe=ae==="right"?te+pt:te-pt;V.push({position:ae,von:Math.min(te,qe),bis:Math.max(te,qe)}),S&&N?.label&&G.push({text:N.label,achseX:te,kante:qe,position:ae,style:N.labels}),y===0&&(E=Ue),d.push({type:"group",cssClass:`value-axis ${ae}`,commands:Ue.render()});}let F=this._valueScales.get(0)??this._valueScales.get(R[0]);d.push({type:"group",cssClass:"time-axis",commands:B.render()});let D=null,O=this._axes?.x?.grid?.major,T=this._axes?.left?.grid?.major;if(O!==void 0||T!==void 0){let y=O!==false,k=T!==false&&!!E,M=y?B.generateTicks().map(H=>H.x):void 0,L=k?E.generateTicks().map(H=>H.position):void 0;if(M||L){let H=(O&&typeof O=="object"?O:void 0)??(T&&typeof T=="object"?T:void 0),I=this._axes?.x?.grid?.minor,U=this._axes?.left?.grid?.minor,N=(I&&typeof I=="object"?I:void 0)??(U&&typeof U=="object"?U:void 0);D={type:"group",cssClass:"chart-grid",commands:[...I!==void 0||U!==void 0?it({xTicks:I!==false&&y?B.generateMinorTicks():void 0,yTicks:U!==false&&k?E.generateMinorTicks():void 0,xRange:c,yRange:p,stroke:N?.color,opacity:N?.opacity??(g.gridOpacity??1)*.5,dashed:N?.style==="dashed"}):[],...it({xTicks:M,yTicks:L,xRange:c,yRange:p,stroke:H?.color,opacity:H?.opacity,dashed:H?.style==="dashed"})]};}}let C=(typeof this._axes?.x?.grid=="object"?this._axes.x.grid.layer:void 0)??(typeof this._axes?.left?.grid=="object"?this._axes.left.grid.layer:void 0)??"front";if(D&&C==="back"&&(d.push(D),D=null),this._highlights.length>0&&d.push({type:"group",cssClass:"highlights",commands:Pt({highlights:this._highlights,timeScale:this._timeScale,yRange:p,height:a.totalHeight})}),this._thresholds.length>0&&F){let y=[],k=[];for(let M of this._thresholds){let L=M.id??le(M.name),H=this._valueScales.get(M.axisIndex??0)??F,I=Lt({thresholds:[M],valueScale:H,xRange:c});I.inside.length&&y.push({type:"group",cssClass:`threshold threshold--${L}`,id:`threshold-${L}`,commands:I.inside}),I.labels.length&&k.push({type:"group",cssClass:`threshold-label threshold-label--${L}`,commands:I.labels});}y.length&&d.push({type:"group",cssClass:"thresholds",commands:y,clipRect:{x:l,y:h,w:m,h:u}}),k.length&&d.push({type:"group",cssClass:"threshold-labels",commands:k});}let Y=this._gaps;if(this._gapsAutoDetect){let y=[];for(let k of this._series){if(xe(k))continue;let M=k.data.filter(L=>L.value!==null);y.push(...xt(M,this._gapsMinGapMs));}y.length>0&&(Y=[...this._gaps,...y]);}Y.length>0&&d.push({type:"group",cssClass:"gaps",commands:rt({gaps:Y,timeScale:this._timeScale,yRange:p,height:a.totalHeight})});let J=new Map(this._thresholds.map(y=>[y.id??y.name,y]));for(let[y,k]of this._series.entries()){if(k.data.length===0)continue;let M=this._valueScales.get(this._axisIndexOf(k));if(!M)continue;let L=le(k.id??k.name);d.push({type:"group",cssClass:`series series--${L}`,id:`series-${L}`,commands:this._renderSeries(k,M,J,y),...this._clipSeries?{clipRect:{x:l,y:h,w:m,h:u}}:{}});}D&&d.push(D);let X=this._markers.map(y=>({...y}));for(let y of X)if(y.value===void 0&&(y.lineStyle==="to-value"||y.lineStyle==="to-top")){let k=this._series[y.seriesIndex??0];k&&!xe(k)&&k.data.length>=2&&(y.value=this._interpolateValue(y.time,k.data));}if(X.length>0&&F){let y=[];for(let k of X){let M=F,L=this._series[k.seriesIndex??0];L&&(M=this._valueScales.get(this._axisIndexOf(L))??F),y.push(...Dt({markers:[k],timeScale:this._timeScale,valueScale:M,yRange:p}));}d.push({type:"group",cssClass:"markers",commands:y});}let K=this._annotations.filter(y=>!y.id||!this._disabledAnnotations.has(y.id));if(K.length>0&&d.push({type:"group",cssClass:"annotations",commands:jt({annotations:K,timeScale:this._timeScale,valueScales:this._valueScales,metrics:this._textMetrics})}),this._annotationBands.length>0){let y=h+u+this._layout.margin.bottom,k=0;this._annotationBands.forEach(M=>{let L=M.height??12,H=M.spacing??0,I=y+k;(M.showAxis??false)&&(k+=26+H),k+=L+H,d.push({type:"group",cssClass:"annotation-band",commands:new Re({name:M.name,showAxis:M.showAxis??false,items:M.items,timeScale:this._timeScale,background:M.background,hatch:M.hatch},[l,l+m],I,L).render()});});}let{xs:ge,belegt:_e}=wn(G.map(y=>({achseX:y.achseX,kante:y.kante,position:y.position,schrift:y.style?.fontSize??g.axisLabelSize})),V,a.totalWidth);if(t&&n!=="separate"){let y,k;if(n==="inside-right")y=l+m-s.width-8,k=h+8;else if(n==="inside-left")y=l+8,k=h+8;else if(n==="outside-right"){let M=_e.filter(L=>L.position==="right").reduce((L,H)=>Math.max(L,H.bis),l+m);y=Math.min(Math.max(l+m+16,M+12),a.totalWidth-s.width-2),k=h;}else n==="above"||n==="below"?(y=Math.max(8,Math.min(a.totalWidth-s.width-8,l+(m-s.width)/2)),k=n==="above"?Math.max(4,h-s.height-10):a.totalHeight-s.height-4):(y=8,k=h);d.push(At({items:e,x:y,y:k,orientation:r,metrics:this._textMetrics,maxBreite:o}));}let Q=S?void 0:this._axes?.left?.label,Ye=S?void 0:this._axes?.right?.label,Xe=this._axes?.x?.label;if(Q||Ye||Xe||G.length){let y=[],k=h+u/2,M=this._axes?.left?.labels,L=this._axes?.right?.labels,H=this._axes?.x?.labels;Q&&y.push({type:"text",content:Q,x:14,y:k,anchor:"middle",fontSize:M?.fontSize??g.axisLabelSize,fill:M?.color??g.axisLabelColor,rotate:-90}),Ye&&y.push({type:"text",content:Ye,x:a.totalWidth-14,y:k,anchor:"middle",fontSize:L?.fontSize??g.axisLabelSize,fill:L?.color??g.axisLabelColor,rotate:90}),G.forEach((I,U)=>{y.push({type:"text",content:I.text,x:ge[U],y:k,anchor:"middle",fontSize:I.style?.fontSize??g.axisLabelSize,fill:I.style?.color??g.axisLabelColor,rotate:I.position==="right"?90:-90});}),Xe&&y.push({type:"text",content:Xe,x:l+m/2,y:a.totalHeight-6,anchor:"middle",fontSize:H?.fontSize??g.axisLabelSize,fill:H?.color??g.axisLabelColor}),y.length&&d.push({type:"group",cssClass:"axis-labels",commands:y});}return Nt(d,this._fontFamily??g.fontFamily),d}_renderSeries(e,t,n,r=0){let o=this._timeScale,s={timeScale:o,valueScale:t};if(xe(e)){let S=e.style?.line&&!Array.isArray(e.style.line)?e.style.line:void 0,$=typeof e.style?.fill=="string"?e.style.fill:void 0;return e.showAs==="minmaxavg"?new Oe({data:e.data,timeScale:o,valueScale:t,minColor:e.minColor,maxColor:e.maxColor,avgColor:e.avgColor,avgDashed:e.avgDashed,fillToMax:e.fillToMax,fillToMaxHatch:e.fillToMaxHatch,fillToMin:e.fillToMin,fillToMinHatch:e.fillToMinHatch,smoothing:S?.smoothing,smoothingType:S?.smoothingType,strokeWidth:S?.width,id:ie(e.name,e.id)}).render():new Fe({data:e.data,timeScale:o,valueScale:t,fill:$??S?.color,avgLine:e.avgLine,countOpacity:e.countOpacity,id:ie(e.name,e.id)}).render()}let a=e,l=e.style?.line&&!Array.isArray(e.style.line)?e.style.line:void 0,h=this._gapsAutoDetect?this._gapsMinGapMs:void 0,m=l?.gapThreshold??h??g.gapThreshold,u=z.getRuns(e.data,S=>S.value===null,m),c=u.reduce((S,$)=>S+$.length,0);if(c===0)return [];let p=[],d=e.style?.markers,b=e.style?.shadow,f={stroke:l?.color??this._palettenFarbe(r),strokeWidth:l?.width??g.strokeWidth,smoothing:l?.smoothing,smoothingType:l?.smoothingType,dashed:l?.style==="dashed",pointStyle:d?.type,pointSize:d?.size,pointStroke:d?.stroke,pointFill:d?.fill,pointStrokeWidth:d?.strokeWidth,shadowColor:b?.color,shadowBlur:b?.blur,shadowOffsetX:b?.offsetX,shadowOffsetY:b?.offsetY,id:ie(e.name,e.id)},_=e.style?.line,v=((Array.isArray(_)?_[0]:l)?.shape??a.seriesType)==="step",w=e.style?.fill;if(w!==void 0){let S=t.range(),$=Math.min(S[0],S[1]),j=Math.max(S[0],S[1]);p.push(...Ot(w,{runs:u,timeScale:o,valueScale:t,thresholds:n,chartTop:$,chartBottom:j,smoothing:l?.smoothing,smoothingType:l?.smoothingType,shape:v?"step":"line",fremdeSerie:F=>{let D=this._series.find(X=>(X.id??X.name)===F||X.name===F);if(!D||!("data"in D))return;let O=D.data;if(O.length===0||!("value"in O[0]))return;let T=D.style?.line,C=Array.isArray(T)?T[0]:T,J=(typeof C=="object"&&C!==null?C.shape:void 0)==="step"||D.seriesType==="step";return {data:O,shape:J?"step":"line"}},idPrefix:ie(e.name,e.id)}));}let P=a.colorByThresholds??[],B=P.map(S=>n.get(S)).filter(S=>!!S).map(S=>S.value).sort((S,$)=>S-$),R=(S,$,j)=>{let F=j??f.stroke,D=Number.NEGATIVE_INFINITY;for(let O of $){let T=n.get(O);!T||S<T.value||T.value<D||(D=T.value,F=T.color??F);}return F},E=new Map;for(let S of u){let F=function(T){return z.splitByBoundaries(T==="step"?de(S):S,B,C=>C.value,z.interpolateDataPoint)};if(S.length<1)continue;let $=ie(a.name,a.id),j=new Map,D=T=>{let C=j.get(T);return C||(C=F(T),j.set(T,C)),C},O=(T,C,Y)=>{let J=D(T);for(let X=0;X<J.length;X++){let K=J[X],ge=E.get(Y)??0;if(E.set(Y,ge+1),K.data.length<1)continue;let _e=K.zoneLow;if(K.data.length===1){let Q=R(_e,P,C.color);p.push({type:"circle",id:$?`${$}-dot-${ge}${Y}`:void 0,cx:o.map(K.data[0].time),cy:t.map(K.data[0].value),r:Math.max(f.pointSize??g.pointSize,C.width??f.strokeWidth??g.strokeWidth),fill:Q,shadowColor:f.shadowColor,shadowBlur:f.shadowBlur});continue}p.push({type:"path",cssClass:"series-line",id:$?`${$}-line-${ge}${Y}`:void 0,points:K.data.map(Q=>({x:o.map(Q.time),y:t.map(Q.value)})),stroke:R(_e,P,C.color),strokeWidth:C.width??f.strokeWidth,smoothing:T==="step"?false:C.smoothing??f.smoothing,smoothingType:C.smoothingType??f.smoothingType,dash:C.style,opacity:C.opacity,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY});}};_===false||(Array.isArray(_)?_.forEach((T,C)=>{O(T.shape??(a.seriesType==="step"?"step":"line"),T,`-${C}`);}):O(v?"step":"line",_??{},"")),f.pointStyle&&f.pointStyle!=="none"&&c<=(d?.threshold??g.pointThreshold)&&p.push(...wt(S,s,f,T=>R(T.value,P)));}let G=e.overlays;if(G&&G.length>0){let S=t.range(),$={data:e.data,timeScale:o,valueScale:t,chartTop:Math.min(S[0],S[1]),chartBottom:Math.max(S[0],S[1]),idPrefix:ie(e.name,e.id)};G.forEach((j,F)=>{p.push(...Wt(j,$,F));});}if(e.style?.gap&&u.length>1){let S=e.style.gap,$=S.bridge,j=[];for(let F=1;F<u.length;F++){let D=u[F-1][u[F-1].length-1],O=u[F][0];if(S.display==="bridge_line"){if(D.value===null||O.value===null)continue;p.push({type:"line",x1:o.map(D.time),y1:t.map(D.value),x2:o.map(O.time),y2:t.map(O.value),stroke:$?.color??(typeof e.style?.line=="object"&&!Array.isArray(e.style.line)?e.style.line.color:void 0)??g.stroke,strokeWidth:$?.width??1.5,dash:$?.style??"dotted"});}else j.push({startTime:D.time,endTime:O.time});}if(j.length>0){let F=S.display&&S.display!=="bridge_line"?S.display:"dashed_border",D=S.fill,O=typeof D=="string"?D:D?.color,T=t.range();p.push(...rt({gaps:j.map(C=>({...C,style:F})),timeScale:o,yRange:[Math.min(T[0],T[1]),Math.max(T[0],T[1])],fill:O,hatch:typeof D=="object"?D.hatch:void 0,fillOpacity:S.opacity??.15,labelBaseline:S.label?.baseline,labelRotate:S.label?.rotate}));}}return p}_interpolateValue(e,t){for(let n=1;n<t.length;n++){let r=t[n-1],o=t[n];if(!(r.value===null||o.value===null)&&e>=r.time&&e<=o.time){if(o.time===r.time)return r.value;let s=(e-r.time)/(o.time-r.time);return r.value+s*(o.value-r.value)}}}legendItems(){return this._legendItems()}_palettenFarbe(e){let t=g.palette;return t.length>0?t[e%t.length]:g.stroke}_zustaendeVon(e){let t=new Set;for(let n of e){let r=n.enumMap;if(r)for(let o of Object.keys(r))t.add(Number(o));}return t.size>0?[...t].sort((n,r)=>n-r):void 0}_zustandName(e){let t={};for(let n of e){let r=n.enumMap;if(r)for(let[o,s]of Object.entries(r))Number(o)in t||(t[Number(o)]=s);}return n=>t[n]??String(n)}_legendItems(){return this._series.map((e,t)=>{let n=e.style?.line&&!Array.isArray(e.style.line)?e.style.line:void 0,r=e.style?.markers,o=r?.type&&r.type!=="none"&&(r.threshold===void 0||(e.data?.length??0)<=r.threshold),s=xe(e)?e.avgColor??g.avgColor:this._palettenFarbe(t);return {name:e.name,color:n?.color??s,line:n?.style,marker:o?r.type:void 0}})}get renderer(){return this._renderer}get layout(){return this._layout}get timeScale(){return this._timeScale}get valueScales(){return this._valueScales}invertTime(e){return this._timeScale?this._timeScale.invert(e):0}invertValue(e,t=0){let n=this._valueScales.get(t);return n?n.invert(e):0}project(e,t,n=0){let r=this._timeScale?this._timeScale.map(e):0,o=this._valueScales.get(n);return {x:r,y:o?o.map(t):0}}};function Gt(i){let e=[];for(let t=0;t<i.length-1;t++){let n=i[t+1].x-i[t].x;e.push(n===0?0:(i[t+1].y-i[t].y)/n);}return e}function vn(i){let e=Gt(i),t=i.length,n=[...e];for(let r=1;r<t-1;r++)n[r]=e[r-1]*e[r]<=0?0:(e[r-1]+e[r])/2;n[t-1]=e[t-2];for(let r=0;r<t-1;r++){if(e[r]===0){n[r]=0,n[r+1]=0;continue}let o=n[r]/e[r],s=n[r+1]/e[r],a=o*o+s*s;if(a>9){let l=3/Math.sqrt(a);n[r]=l*o*e[r],n[r+1]=l*s*e[r];}}return n}function Tn(i){let e=Gt(i),t=i.length;if(e.length<2)return i.map(()=>e[0]??0);let n=e[0],r=e[1],o=e[e.length-1],s=e[e.length-2],a=2*n-r,l=2*o-s,h=[2*a-n,a,...e,l,2*l-o],m=[];for(let u=0;u<t;u++){let c=Math.abs(h[u+3]-h[u+2]),p=Math.abs(h[u+1]-h[u]);m.push(c+p===0?(h[u+1]+h[u+2])/2:(c*h[u+1]+p*h[u+2])/(c+p));}return m}function Cn(i,e){let t=[];for(let n=0;n<i.length-1;n++){let r=i[n],o=i[n+1],s=(o.x-r.x)/3;t.push({p0:r,c1:{x:r.x+s,y:r.y+e[n]*s},c2:{x:o.x-s,y:o.y-e[n+1]*s},p1:o});}return t}function Vt(i,e){if(i.length<2)return [];let t=e==="akima"?Tn(i):vn(i);return Cn(i,t)}var lt="1.10.0";var Mn=` <!-- MLTimeGraph ${lt} -->`,zt=1e3;function x(i){return String(Math.round(i*zt)/zt)}function ht(i){return Ze(i).toString(16).padStart(8,"0")}function An(i){switch(i){case "top":return "text-top";case "bottom":return "text-bottom";default:return "middle"}}var ne=class extends Ae{#t="100%";#e="100%";#n;#i=new Map;#r=new Map;#o=new Map;constructor(e){super(),e?.width!==void 0&&(this.#t=e.width),e?.height!==void 0&&(this.#e=e.height),e?.background!==void 0&&(this.#n=e.background);}setBackgroundColor(e){this.#n=e;}render(e){this.#i.clear(),this.#r.clear(),this.#o.clear();let t=e.map(h=>this._toSVG(h));this.#n&&t.unshift(`<rect width="100%" height="100%" fill="${this._esc(this.#n)}" />`);let n=t.join(`
25
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
26
  ${o.join(`
27
27
  `)}
28
28
  </defs>
29
- `);let s=typeof this.#e=="number"?`${this.#e}`:this.#e,a=typeof this.#t=="number"?`${this.#t}`:this.#t,l=typeof this.#e=="number"&&typeof this.#t=="number"?` viewBox="0 0 ${this.#e} ${this.#t}"`:"";return {type:"svg",content:`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"${l}>
30
- ${Ut}
29
+ `);let s=typeof this.#t=="number"?`${this.#t}`:this.#t,a=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="${s}" height="${a}"${l}>
30
+ ${Mn}
31
31
  ${r} ${n}
32
- </svg>`}}_toSVG(e){switch(e.type){case "path":return this._path(e);case "line":return this._line(e);case "rect":return this._rect(e);case "circle":return this._circle(e);case "text":return this.#m(e);case "gap":return this._gap(e);case "group":return this._group(e)}}#l(e,t,n){if(e.length===0)return "";if(!t||e.length<3)return e.map((s,a)=>`${a===0?"M":"L"}${b(s.x)},${b(s.y)}`).join(" ");let r=n!=null&&n<e.length?Math.max(n,2):e.length,o=`M${b(e[0].x)},${b(e[0].y)}`;for(let s=0;s<r-1;s++){let a=e[s-1]??e[s],l=e[s],h=e[s+1],m=e[s+2]&&s+2<r?e[s+2]:h,u=l.x+(h.x-a.x)/6,d=l.y+(h.y-a.y)/6,c=h.x-(m.x-l.x)/6,y=h.y-(m.y-l.y)/6;o+=` C${b(u)},${b(d)} ${b(c)},${b(y)} ${b(h.x)},${b(h.y)}`;}for(let s=r;s<e.length;s++)o+=` L${b(e[s].x)},${b(e[s].y)}`;return o}_hatchPattern(e,t){let n=`hatch-${e}-${Ye(t??"")}`;if(this.#o.has(n))return n;let r=Be(n,e,t??"rgba(200,220,255,0.3)");return this.#o.set(n,r),n}_path(e){let t=this.#l(e.points,e.smoothing,e.smoothCount)+(e.closed?" Z":""),n=[];if(e.hatch){let s=this._hatchPattern(e.hatch,e.fill);n.push(`fill="url(#${s})"`);}else n.push(`fill="${e.fill?this._esc(e.fill):"none"}"`);e.stroke&&n.push(`stroke="${this._esc(e.stroke)}"`),e.strokeWidth&&n.push(`stroke-width="${b(e.strokeWidth)}"`);let r=this.#a(e.dash,e.dashed,e.strokeWidth);r&&(n.push(`stroke-dasharray="${r.strokeDasharray}"`),r.strokeLinecap&&n.push(`stroke-linecap="${r.strokeLinecap}"`)),e.opacity!==void 0&&n.push(`opacity="${b(e.opacity)}"`),e.cssClass&&n.push(`class="${this._esc(e.cssClass)}"`),e.id&&n.push(`id="${this._esc(e.id)}"`);let o=this.#s(e);return o&&n.push(`filter="url(#${o})"`),`<path d="${t}" ${n.join(" ")} />`}_line(e){let t=[];e.stroke&&t.push(`stroke="${this._esc(e.stroke)}"`),e.strokeWidth&&t.push(`stroke-width="${b(e.strokeWidth)}"`);let n=this.#a(e.dash,e.dashed,e.strokeWidth);n&&(t.push(`stroke-dasharray="${n.strokeDasharray}"`),n.strokeLinecap&&t.push(`stroke-linecap="${n.strokeLinecap}"`)),e.opacity!==void 0&&t.push(`opacity="${b(e.opacity)}"`),e.id&&t.push(`id="${this._esc(e.id)}"`);let r=this.#s(e);return r&&t.push(`filter="url(#${r})"`),`<line x1="${b(e.x1)}" y1="${b(e.y1)}" x2="${b(e.x2)}" y2="${b(e.y2)}" ${t.join(" ")} />`}_rect(e){let t=[];if(e.hatch){let r=this._hatchPattern(e.hatch,e.fill);t.push(`fill="url(#${r})"`);}else e.fill!==void 0&&t.push(`fill="${this._esc(e.fill)}"`);e.stroke&&t.push(`stroke="${this._esc(e.stroke)}"`),e.strokeWidth&&t.push(`stroke-width="${b(e.strokeWidth)}"`),e.opacity!==void 0&&t.push(`opacity="${b(e.opacity)}"`),e.dashed&&t.push('stroke-dasharray="4,4"'),e.id&&t.push(`id="${this._esc(e.id)}"`);let n=this.#s(e);return n&&t.push(`filter="url(#${n})"`),e.title?`<rect x="${b(e.x)}" y="${b(e.y)}" width="${b(e.w)}" height="${b(e.h)}" ${t.join(" ")}><title>${this._esc(e.title)}</title></rect>`:`<rect x="${b(e.x)}" y="${b(e.y)}" width="${b(e.w)}" height="${b(e.h)}" ${t.join(" ")} />`}_circle(e){let t=[];if(e.hatch){let r=this._hatchPattern(e.hatch,e.fill);t.push(`fill="url(#${r})"`);}else e.fill&&t.push(`fill="${this._esc(e.fill)}"`);e.stroke&&t.push(`stroke="${this._esc(e.stroke)}"`),e.strokeWidth&&t.push(`stroke-width="${b(e.strokeWidth)}"`),e.id&&t.push(`id="${this._esc(e.id)}"`);let n=this.#s(e);return n&&t.push(`filter="url(#${n})"`),`<circle cx="${b(e.cx)}" cy="${b(e.cy)}" r="${b(e.r)}" ${t.join(" ")} />`}#a(e,t,n){return je(e,n??2,t)}#s(e){if(!e.shadowColor)return null;let t=e.shadowBlur??0,n=e.shadowOffsetX??0,r=e.shadowOffsetY??0;if(!t&&!n&&!r)return null;let o=`shadow-${Ye(`${e.shadowColor}|${b(t)}|${b(n)}|${b(r)}`)}`;if(this.#i.has(o))return o;let s=`<filter id="${o}" x="-50%" y="-50%" width="200%" height="200%">
33
- <feDropShadow dx="${b(n)}" dy="${b(r)}" stdDeviation="${b(t/2)}" flood-color="${this._esc(e.shadowColor)}" />
32
+ </svg>`}}_toSVG(e){switch(e.type){case "path":return this._path(e);case "line":return this._line(e);case "rect":return this._rect(e);case "circle":return this._circle(e);case "text":return this.#m(e);case "gap":return this._gap(e);case "group":return this._group(e)}}#l(e,t,n,r){if(e.length===0)return "";if(!t||e.length<3)return e.map((a,l)=>`${l===0?"M":"L"}${x(a.x)},${x(a.y)}`).join(" ");let o=n!=null&&n<e.length?Math.max(n,2):e.length;if(r&&r!=="catmull-rom"){let a=`M${x(e[0].x)},${x(e[0].y)}`;for(let l of Vt(e.slice(0,o),r))a+=` C${x(l.c1.x)},${x(l.c1.y)} ${x(l.c2.x)},${x(l.c2.y)} ${x(l.p1.x)},${x(l.p1.y)}`;for(let l=o;l<e.length;l++)a+=` L${x(e[l].x)},${x(e[l].y)}`;return a}let s=`M${x(e[0].x)},${x(e[0].y)}`;for(let a=0;a<o-1;a++){let l=e[a-1]??e[a],h=e[a],m=e[a+1],u=e[a+2]&&a+2<o?e[a+2]:m,c=Math.min(h.x,m.x),p=Math.max(h.x,m.x),d=v=>v<c?c:v>p?p:v,b=d(h.x+(m.x-l.x)/6),f=h.y+(m.y-l.y)/6,_=d(m.x-(u.x-h.x)/6),A=m.y-(u.y-h.y)/6;s+=` C${x(b)},${x(f)} ${x(_)},${x(A)} ${x(m.x)},${x(m.y)}`;}for(let a=o;a<e.length;a++)s+=` L${x(e[a].x)},${x(e[a].y)}`;return s}_hatchPattern(e,t){let n=`hatch-${e}-${ht(t??"")}`;if(this.#o.has(n))return n;let r=Te(n,e,t??"rgba(200,220,255,0.3)");return this.#o.set(n,r),n}_path(e){let t=this.#l(e.points,e.smoothing,e.smoothCount,e.smoothingType)+(e.closed?" Z":""),n=[];if(e.hatch){let s=this._hatchPattern(e.hatch,e.fill);n.push(`fill="url(#${s})"`);}else n.push(`fill="${e.fill?this._esc(e.fill):"none"}"`);e.stroke&&n.push(`stroke="${this._esc(e.stroke)}"`),e.strokeWidth&&n.push(`stroke-width="${x(e.strokeWidth)}"`);let r=this.#a(e.dash,e.dashed,e.strokeWidth);r&&(n.push(`stroke-dasharray="${r.strokeDasharray}"`),r.strokeLinecap&&n.push(`stroke-linecap="${r.strokeLinecap}"`)),e.opacity!==void 0&&n.push(`opacity="${x(e.opacity)}"`),e.cssClass&&n.push(`class="${this._esc(e.cssClass)}"`),e.id&&n.push(`id="${this._esc(e.id)}"`);let o=this.#s(e);return o&&n.push(`filter="url(#${o})"`),`<path d="${t}" ${n.join(" ")} />`}_line(e){let t=[];e.stroke&&t.push(`stroke="${this._esc(e.stroke)}"`),e.strokeWidth&&t.push(`stroke-width="${x(e.strokeWidth)}"`);let n=this.#a(e.dash,e.dashed,e.strokeWidth);n&&(t.push(`stroke-dasharray="${n.strokeDasharray}"`),n.strokeLinecap&&t.push(`stroke-linecap="${n.strokeLinecap}"`)),e.opacity!==void 0&&t.push(`opacity="${x(e.opacity)}"`),e.id&&t.push(`id="${this._esc(e.id)}"`);let r=this.#s(e);return r&&t.push(`filter="url(#${r})"`),`<line x1="${x(e.x1)}" y1="${x(e.y1)}" x2="${x(e.x2)}" y2="${x(e.y2)}" ${t.join(" ")} />`}_rect(e){let t=[];if(e.hatch){let r=this._hatchPattern(e.hatch,e.fill);t.push(`fill="url(#${r})"`);}else e.fill!==void 0&&t.push(`fill="${this._esc(e.fill)}"`);e.stroke&&t.push(`stroke="${this._esc(e.stroke)}"`),e.strokeWidth&&t.push(`stroke-width="${x(e.strokeWidth)}"`),e.opacity!==void 0&&t.push(`opacity="${x(e.opacity)}"`),e.dashed&&t.push('stroke-dasharray="4,4"'),e.id&&t.push(`id="${this._esc(e.id)}"`);let n=this.#s(e);return n&&t.push(`filter="url(#${n})"`),e.title?`<rect x="${x(e.x)}" y="${x(e.y)}" width="${x(e.w)}" height="${x(e.h)}" ${t.join(" ")}><title>${this._esc(e.title)}</title></rect>`:`<rect x="${x(e.x)}" y="${x(e.y)}" width="${x(e.w)}" height="${x(e.h)}" ${t.join(" ")} />`}_circle(e){let t=[];if(e.hatch){let r=this._hatchPattern(e.hatch,e.fill);t.push(`fill="url(#${r})"`);}else e.fill&&t.push(`fill="${this._esc(e.fill)}"`);e.stroke&&t.push(`stroke="${this._esc(e.stroke)}"`),e.strokeWidth&&t.push(`stroke-width="${x(e.strokeWidth)}"`),e.id&&t.push(`id="${this._esc(e.id)}"`);let n=this.#s(e);return n&&t.push(`filter="url(#${n})"`),`<circle cx="${x(e.cx)}" cy="${x(e.cy)}" r="${x(e.r)}" ${t.join(" ")} />`}#a(e,t,n){return Je(e,n??2,t)}#s(e){if(!e.shadowColor)return null;let t=e.shadowBlur??0,n=e.shadowOffsetX??0,r=e.shadowOffsetY??0;if(!t&&!n&&!r)return null;let o=`shadow-${ht(`${e.shadowColor}|${x(t)}|${x(n)}|${x(r)}`)}`;if(this.#i.has(o))return o;let s=`<filter id="${o}" x="-50%" y="-50%" width="200%" height="200%">
33
+ <feDropShadow dx="${x(n)}" dy="${x(r)}" stdDeviation="${x(t/2)}" flood-color="${this._esc(e.shadowColor)}" />
34
34
  </filter>`;return this.#i.set(o,s),o}#h(e,t,n,r,o){this.#r.has(e)||this.#r.set(e,`<clipPath id="${e}">
35
- <rect x="${b(t)}" y="${b(n)}" width="${b(r)}" height="${b(o)}" />
36
- </clipPath>`);}#m(e){let t=[];return e.anchor&&t.push(`text-anchor="${e.anchor}"`),e.fontSize&&t.push(`font-size="${b(e.fontSize)}"`),e.fontFamily&&t.push(`font-family="${this._esc(e.fontFamily)}"`),e.fill&&t.push(`fill="${this._esc(e.fill)}"`),e.opacity!=null&&t.push(`opacity="${b(e.opacity)}"`),e.rotate&&t.push(`transform="rotate(${b(e.rotate)} ${b(e.x)} ${b(e.y)})"`),e.textBaseline&&t.push(`dominant-baseline="${Kt(e.textBaseline)}"`),e.id&&t.push(`id="${this._esc(e.id)}"`),`<text x="${b(e.x)}" y="${b(e.y)}" ${t.join(" ")}>${this._esc(e.content)}</text>`}_gap(e){if(e.style==="empty")return "";let t=[`stroke="${this._esc("#999")}"`,'stroke-dasharray="4,4"','fill="none"'];return e.style==="label"&&e.label?`<g class="gap">
37
- <rect x="${b(e.x1)}" y="${b(e.y1)}" width="${b(e.x2-e.x1)}" height="${b(e.y2-e.y1)}" ${t.join(" ")} />
38
- <text x="${b(e.x1)}" y="${b(e.y1-4)}" fill="#999" font-size="10">${this._esc(e.label)}</text>
39
- </g>`:`<rect x="${b(e.x1)}" y="${b(e.y1)}" width="${b(e.x2-e.x1)}" height="${b(e.y2-e.y1)}" ${t.join(" ")} />`}_group(e){let t=null;if(e.clipRect){let{x:l,y:h,w:m,h:u}=e.clipRect;t=`clip-plot-${Ye(`${b(l)},${b(h)},${b(m)},${b(u)}`)}`,this.#h(t,l,h,m,u);}let n=e.commands.map(l=>` ${this._toSVG(l).replaceAll(/\n {3}/g,`
35
+ <rect x="${x(t)}" y="${x(n)}" width="${x(r)}" height="${x(o)}" />
36
+ </clipPath>`);}#m(e){let t=[];return e.anchor&&t.push(`text-anchor="${e.anchor}"`),e.fontSize&&t.push(`font-size="${x(e.fontSize)}"`),e.fontFamily&&t.push(`font-family="${this._esc(e.fontFamily)}"`),e.fill&&t.push(`fill="${this._esc(e.fill)}"`),e.opacity!=null&&t.push(`opacity="${x(e.opacity)}"`),e.rotate&&t.push(`transform="rotate(${x(e.rotate)} ${x(e.x)} ${x(e.y)})"`),e.textBaseline&&t.push(`dominant-baseline="${An(e.textBaseline)}"`),e.id&&t.push(`id="${this._esc(e.id)}"`),`<text x="${x(e.x)}" y="${x(e.y)}" ${t.join(" ")}>${this._esc(e.content)}</text>`}_gap(e){if(e.style==="empty")return "";let t=[`stroke="${this._esc("#999")}"`,'stroke-dasharray="4,4"','fill="none"'];return e.style==="label"&&e.label?`<g class="gap">
37
+ <rect x="${x(e.x1)}" y="${x(e.y1)}" width="${x(e.x2-e.x1)}" height="${x(e.y2-e.y1)}" ${t.join(" ")} />
38
+ <text x="${x(e.x1)}" y="${x(e.y1-4)}" fill="#999" font-size="10">${this._esc(e.label)}</text>
39
+ </g>`:`<rect x="${x(e.x1)}" y="${x(e.y1)}" width="${x(e.x2-e.x1)}" height="${x(e.y2-e.y1)}" ${t.join(" ")} />`}_group(e){let t=null;if(e.clipRect){let{x:l,y:h,w:m,h:u}=e.clipRect;t=`clip-plot-${ht(`${x(l)},${x(h)},${x(m)},${x(u)}`)}`,this.#h(t,l,h,m,u);}let n=e.commands.map(l=>` ${this._toSVG(l).replaceAll(/\n {3}/g,`
40
40
  `)}`).join(`
41
41
  `),r=e.cssClass?` class="${this._esc(e.cssClass)}"`:"",o=e.id?` id="${this._esc(e.id)}"`:"",s=e.plotClipId||t,a=s?` clip-path="url(#${this._esc(s)})"`:"";return `<g${r}${o}${a}>
42
42
  ${n}
43
- </g>`}_esc(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}};function Jt(i){return typeof requestAnimationFrame=="function"?requestAnimationFrame(i):setTimeout(()=>i(0),16)}function Qt(i){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(i):clearTimeout(i);}function vt(){let i=0,e=false;return {schedule:t=>{e||(e=true,i=Jt(()=>{e=false,t();}));},cancel:()=>{e&&(e=false,Qt(i));}}}var Tt="http://www.w3.org/2000/svg";function en(i){let e=i.style?.line;return e&&!Array.isArray(e)&&e.color?e.color:p.stroke}function Ct(i){return i.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}function tn(i){if(i.length===0)return "";let e=new Date(i[0].time).toLocaleString(),t=i.map(n=>`<div><span class="mlc-tooltip__name">${Ct(n.series.name)}:</span> ${n.value.toFixed(2)}</div>`);return `<div class="mlc-tooltip__time">${Ct(e)}</div>${t.join("")}`}function nn(i,e){if(i.length===0)return;let t=0,n=i.length-1;for(;t<n;){let s=t+n>>1;i[s].time<e?t=s+1:n=s;}let r=i[Math.max(0,t-1)],o=i[t];return Math.abs(r.time-e)<=Math.abs(o.time-e)?r:o}function rn(i){return "value"in i?i.value:i.avg}function me(i,e,t={}){let n=i.querySelector("svg");if(!n)throw new Error("attachTooltip: target has no <svg> child (did you mount the chart first?)");let r=t.format??tn,o=t.snapRadius??1/0,s=t.className??"mlc-tooltip",a=t.showPicks??true,l=t.pickRadius??5,h=t.picksClassName??"mlc-tooltip-picks",m=document.createElement("div");m.className=s,m.style.position="absolute",m.style.pointerEvents="none",m.style.display="none",getComputedStyle(i).position==="static"&&(i.style.position="relative"),i.appendChild(m);let u=null;a&&(u=document.createElementNS(Tt,"g"),u.setAttribute("class",h),u.setAttribute("pointer-events","none"),n.appendChild(u));let d=()=>{u&&u.replaceChildren();},c=e.series.map((T,B)=>({data:T.data.map(M=>({time:M.time,value:rn(M)})).filter(M=>M.value!==null).sort((M,E)=>M.time-E.time),series:T,index:B})),y=vt(),g=null,x=T=>{let B=n.getBoundingClientRect(),j=e.getWidth?.()??B.width,M=(T.clientX-B.left)*j/Math.max(1,B.width);e.getHeight?.()??B.height;let z=e.invertTime(M);if(!Number.isFinite(z)){m.style.display="none";return}let S=[];for(let A of c){let I=nn(A.data,z);if(!I)continue;let Y=e.project(I.time,I.value,A.series.yAxisIndex??0).x,G=e.project(I.time,I.value,A.series.yAxisIndex??0).y;Math.abs(Y-M)>o||S.push({seriesIndex:A.index,series:A.series,time:I.time,value:I.value,x:Y,y:G});}if(S.length===0){m.style.display="none",d();return}m.innerHTML=r(S);let $=i.getBoundingClientRect(),F=12,_=(T.clientX-B.left)/Math.max(1,B.width),L=(T.clientY-B.top)/Math.max(1,B.height),O=_<.5?`${F}px`:`calc(-100% - ${F}px)`,C=L<.5?`${F}px`:`calc(-100% - ${F}px)`;if(m.style.left=`${T.clientX-$.left}px`,m.style.top=`${T.clientY-$.top}px`,m.style.transform=`translate(${O}, ${C})`,m.style.display="",u){u.replaceChildren();for(let A of S){let I=document.createElementNS(Tt,"circle");I.setAttribute("cx",String(A.x)),I.setAttribute("cy",String(A.y)),I.setAttribute("r",String(l)),I.setAttribute("fill","#ffffff"),I.setAttribute("stroke",en(A.series)),I.setAttribute("stroke-width","2"),I.setAttribute("class",`${h}__dot`),u.appendChild(I);}}},k=T=>{g=T,y.schedule(()=>{g&&x(g);});},D=()=>{g=null,y.cancel(),m.style.display="none",d();};n.addEventListener("mousemove",k),n.addEventListener("mouseleave",D);let R=false;return ()=>{R||(R=true,g=null,y.cancel(),n.removeEventListener("mousemove",k),n.removeEventListener("mouseleave",D),m.remove(),u&&u.remove());}}function on(i,e={}){let t=typeof i=="string"?document.querySelector(i):i;if(!t)throw new Error(`mount: target ${typeof i=="string"?`'${i}'`:""} not found`);let{tooltip:n,...r}=e,o=r.width??t.clientWidth??800,s=r.height??350,a=new J({...r,width:o,height:s}),{content:l}=new X().render(a.renderCommands());t.innerHTML=l;let h=t.querySelector("svg");return h&&(h.setAttribute("viewBox",`0 0 ${o} ${a.getHeight()}`),h.setAttribute("width","100%"),h.setAttribute("height",String(a.getHeight()))),n?.show&&me(t,a,n),a}var _e=class{_opts;_series=[];_thresholds=[];_annotations=[];_highlights=[];_markers=[];_bands=[];_tooltip;constructor(e,t){this._opts={},e!==void 0&&(this._opts.width=e),t!==void 0&&(this._opts.height=t);}setWidth(e){return this._opts.width=e,this}setHeight(e){return this._opts.height=e,this}setSize(e,t){return this._opts.width=e,this._opts.height=t,this}setMargin(e,t,n,r){return typeof e=="object"?this._opts.margin=e:this._opts.margin={top:e,right:t??0,bottom:n??0,left:r??0},this}setLocale(e){return this._opts.locale=e,this}setAxes(e){return this._opts.axes=e,this}setXAxis(e){return this._opts.axes={...this._opts.axes,x:{...this._opts.axes?.x,...e}},this}setLeftAxis(e){return this._opts.axes={...this._opts.axes,left:{...this._opts.axes?.left,...e}},this}setRightAxis(e){return this._opts.axes={...this._opts.axes,right:{...this._opts.axes?.right,...e}},this}setYAxis(e,t){this._opts.axes??={},this._opts.axes.y??=[];let n=[...this._opts.axes.y];for(;n.length<=e;)n.push({});return n[e]={...n[e],...t},this._opts.axes.y=n,this}setLegend(e,t,n){return typeof e=="object"?this._opts.legend=e:this._opts.legend={show:e,position:t,orientation:n},this}setGaps(e){return this._opts.gaps=e,this}setTooltip(e){return this._tooltip={show:true,...e},this}addSeries(e){return this._series.push(e),this}addSeriesAll(e){return this._series.push(...e),this}addThreshold(e){return this._thresholds.push(e),this}addThresholds(e){return this._thresholds.push(...e),this}addAnnotation(e){return this._annotations.push(e),this}addAnnotations(e){return this._annotations.push(...e),this}addHighlight(e){return this._highlights.push(e),this}addMarker(e){return this._markers.push(e),this}addAnnotationBand(e){return this._bands.push(e),this}clear(e){return (!e||e==="series")&&(this._series=[]),(!e||e==="thresholds")&&(this._thresholds=[]),(!e||e==="annotations")&&(this._annotations=[]),(!e||e==="highlights")&&(this._highlights=[]),(!e||e==="markers")&&(this._markers=[]),(!e||e==="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 J(this.toOptions())}getSvg(){let e=this.build(),{content:t}=new X().render(e.renderCommands());return t}mount(e){let t=typeof e=="string"?document.querySelector(e):e;if(!t){let s=typeof e=="string"?`'${e}'`:"";throw new Error(`GraphBuilder.mount: target ${s} not found`)}this._opts.width||(this._opts.width=t.clientWidth||800);let n=this.build(),{content:r}=new X().render(n.renderCommands());t.innerHTML=r;let o=t.querySelector("svg");if(o){let s=this._opts.width??800;o.setAttribute("viewBox",`0 0 ${s} ${n.getHeight()}`),o.setAttribute("width","100%"),o.setAttribute("height",String(n.getHeight()));}return this._tooltip?.show&&me(t,n,this._tooltip),n}};var ke=class{_series;constructor(e){this._series={name:e,data:[]};}addPoint(e,t){return this._series.data.push({time:e,value:t}),this}setData(e){return this._series.data=[...e],this}addPoints(e){return this._series.data.push(...e),this}addFloats(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)this._series.data.push({time:e[r],value:t[r]});return this}addNullPoint(e){return this._series.data.push({time:e,value:null}),this}setYAxisIndex(e){return this._series.yAxisIndex=e,this}setColor(e){return this._series.style??={},!this._series.style.line||typeof this._series.style.line=="boolean"?this._series.style.line={color:e}:Array.isArray(this._series.style.line)?this._series.style.line.length===0?this._series.style.line=[{color:e}]:this._series.style.line[0].color=e:this._series.style.line.color=e,this}setStyle(e){return this._series.style=e,this}setLineStyle(e,t,n){return this._series.style??={},this._series.style.line={color:e,width:t,style:n},this}setSmoothing(e){return this._series.style??={},!this._series.style.line||typeof this._series.style.line=="boolean"?this._series.style.line={smoothing:e}:Array.isArray(this._series.style.line)?this._series.style.line.length===0?this._series.style.line=[{smoothing:e}]:this._series.style.line[0].smoothing=e:this._series.style.line.smoothing=e,this}setFill(e){return this._series.style??={},this._series.style.fill=e,this}setID(e){return this._series.id=e,this}setColorByThresholds(e){return this._series.colorByThresholds=e,this}build(){return this._series}};var ve=class{_threshold;constructor(e,t){this._threshold={name:e,value:t};}setColor(e){return this._threshold.color=e,this}setLine(e){return this._threshold.line=e,this}setFill(e,t){return this._threshold.fill=e,this._threshold.fillOpacity=t,this}setFillHatch(e){return this._threshold.fillHatch=e,this}setLabel(e,t){return this._threshold.label={text:e,position:t},this}setID(e){return this._threshold.id=e,this}build(){return this._threshold}};var Te=class{_marker;constructor(e){this._marker={time:e};}setValue(e){return this._marker.value=e,this}setLabel(e){return this._marker.label=e,this}setColor(e){return this._marker.color=e,this}setPointStyle(e){return this._marker.pointStyle=e,this}setLineStyle(e){return e==="none"?delete this._marker.lineStyle:this._marker.lineStyle=e,this}setSeriesIndex(e){return this._marker.seriesIndex=e,this}build(){return this._marker}};var Ce=class{_highlight;constructor(e,t){this._highlight={startTime:e,endTime:t};}setLabel(e){return this._highlight.label=e,this}setColor(e){return this._highlight.color=e,this}setOpacity(e){return this._highlight.opacity=e,this}setLabelPosition(e){return this._highlight.labelPosition=e,this}setRotate(e){return this._highlight.rotate=e,this}build(){return this._highlight}};var $e=class{_ann;constructor(e){this._ann={type:e};}setID(e){return this._ann.id=e,this}setTitle(e){return this._ann.title=e,this}setFrom(e,t,n){return this._ann.from={time:e,value:t,axis:n},this}setTo(e,t,n){return this._ann.to={time:e,value:t,axis:n},this}setAt(e,t,n){return this._ann.at={time:e,value:t,axis:n},this}setColor(e){return this._ann.color=e,this}setWidth(e){return this._ann.width=e,this}setDash(e){return this._ann.dash=e,this}setHeadSize(e){return this._ann.headSize=e,this}setFill(e){return this._ann.fill=e,this}setHatch(e){return this._ann.hatch=e,this}setStroke(e){return this._ann.stroke=e,this}setOpacity(e){return this._ann.opacity=e,this}setRadius(e){return this._ann.radius=e,this}setShape(e){return this._ann.shape=e,this}setText(e){return this._ann.text=e,this}setAnchor(e){return this._ann.anchor=e,this}setDx(e){return this._ann.dx=e,this}setDy(e){return this._ann.dy=e,this}setRotate(e){return this._ann.rotate=e,this}build(){return this._ann}};var Ae=class{_band;constructor(e){this._band={name:e,items:[]};}setHeight(e){return this._band.height=e,this}setSpacing(e){return this._band.spacing=e,this}setHatch(e){return this._band.hatch=e,this}setShowAxis(e){return this._band.showAxis=e,this}setShowInLegend(e){return this._band.showInLegend=e,this}setBackground(e){return this._band.background=e,this}addItem(e){return this._band.items.push(e),this}build(){return this._band}},De=class{_item;constructor(e,t){this._item={startTime:e,endTime:t};}setFill(e){return this._item.fill=e,this}setHatch(e){return this._item.hatch=e,this}setStroke(e){return this._item.stroke=e,this}setStrokeWidth(e){return this._item.strokeWidth=e,this}setLabel(e,t,n,r){return this._item.label=e,t!==void 0&&(this._item.labelFontSize=t),n!==void 0&&(this._item.labelFill=n),r!==void 0&&(this._item.labelBaseline=r),this}build(){return this._item}};function sn(i){let{thresholds:e,colors:t,hatches:n}=i;if(t.length!==e.length+1)throw new Error(`fillBetweenThresholds: expected ${e.length+1} colors for ${e.length} thresholds, got ${t.length}`);if(n!==void 0&&n.length!==t.length)throw new Error(`fillBetweenThresholds: hatches length (${n.length}) must equal colors length (${t.length})`);return {regions:t.map((o,s)=>{let a=n?.[s],l=a?{color:o,hatch:a}:o;return s===0?{to:{threshold:e[0]},fill:l}:s===t.length-1?{from:{threshold:e[e.length-1]},fill:l}:{from:{threshold:e[s-1]},to:{threshold:e[s]},fill:l}})}}function qe(i){if(!i||typeof i!="object")throw new Error("DataPoint: object expected");let{time:e,value:t,annotation:n}=i;if(typeof e!="number"||Number.isNaN(e))throw new TypeError(`DataPoint: invalid time=${e}`);if(t!==null&&(typeof t!="number"||Number.isNaN(t)))throw new Error(`DataPoint: invalid value=${t}`);return {time:e,value:t,annotation:n&&typeof n=="string"?n:void 0}}function an(i){if(Array.isArray(i))return i.map(qe);if(i&&typeof i=="object"){let e=i,t=e.name,n=e.data,r=e.sensorType,o=e.enumMap,s=e.color,a=e.lineWidth,l=e.smoothing,h=e.seriesType;if(!t||!t.length)throw new Error("Series: name required");if(!Array.isArray(n))throw new Error("Series: data must be an array");let m=s!==void 0||a!==void 0||l!==void 0?{color:s,width:a,smoothing:l}:void 0;return {name:t,data:n.map(qe),sensorType:r??"numeric",enumMap:o,seriesType:h,...m&&{style:{line:m}}}}throw new Error("parseSeries: object or DataPoint[] expected")}function ln(i){if(!i||typeof i!="object")throw new Error("parseAggregated: object expected");let e=i,t=e.name,n=e.data,r=e.showAs,o=e.avgLine,s=e.countOpacity,a=e.color;if(!t?.length)throw new Error("AggregatedSeries: name required");if(!Array.isArray(n))throw new Error("AggregatedSeries: data must be an array");return {name:t,data:hn(n),showAs:r,avgLine:o,countOpacity:s,...a!==void 0&&{style:{line:{color:a},fill:a}}}}function hn(i){let e=t=>typeof t=="number"?t:null;return i.map(t=>{let n=t;return {time:n.time??0,min:e(n.min),max:e(n.max),avg:e(n.avg),count:typeof n.count=="number"?n.count:0}})}function Xe(i,e,t){return typeof e=="function"?e(i):i[e??t]}function mn(i,e,t){if(i instanceof Date){let n=i.getTime();if(Number.isNaN(n))throw new TypeError(`toDataPoints: invalid Date at row ${t}`);return n}if(typeof i=="string"){let n=Date.parse(i);if(Number.isNaN(n))throw new TypeError(`toDataPoints: unparsable time string at row ${t}: ${i}`);return n}if(typeof i=="number"&&Number.isFinite(i))return e==="s"||e==="auto"&&Math.abs(i)>=1e8&&Math.abs(i)<1e11?i*1e3:i;throw new TypeError(`toDataPoints: missing or invalid time at row ${t}: ${String(i)}`)}function un(i,e){if(i==null)return null;if(typeof i=="number")return Number.isNaN(i)?null:i;if(typeof i=="string"){let t=i.trim();if(t==="")return null;let n=Number(t);if(Number.isNaN(n))throw new TypeError(`toDataPoints: value is not a number at row ${e}: ${i}`);return n}throw new TypeError(`toDataPoints: invalid value at row ${e}: ${String(i)}`)}function $t(i,e={}){let t=e.timeUnit??"ms",n=[];for(let r=0;r<i.length;r++){let o=i[r];if(o==null)throw new TypeError(`toDataPoints: empty row at ${r}`);let s=Array.isArray(o),a=s&&e.time===void 0?o[0]:Xe(o,e.time,"time"),l=s&&e.value===void 0?o[1]:Xe(o,e.value,"value"),h={time:mn(a,t,r),value:un(l,r)};if(e.annotation!==void 0){let m=Xe(o,e.annotation,"annotation");typeof m=="string"&&m!==""&&(h.annotation=m);}n.push(h);}return (e.sort??true)&&n.sort((r,o)=>r.time-o.time),n}function dn(i,e,t={}){return {name:i,data:$t(e,t)}}function At(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function Dt(i,e){if(!At(i)||!At(e))return e;let t={...i};for(let[n,r]of Object.entries(e))t[n]=Dt(t[n],r);return t}function cn(...i){let e;for(let t of i)t!==void 0&&(e=Dt(e,t));return e??{}}/*!
43
+ </g>`}_esc(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}};function Ln(i){return typeof requestAnimationFrame=="function"?requestAnimationFrame(i):setTimeout(()=>i(0),16)}function $n(i){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(i):clearTimeout(i);}function Yt(){let i=0,e=false;return {schedule:t=>{e||(e=true,i=Ln(()=>{e=false,t();}));},cancel:()=>{e&&(e=false,$n(i));}}}var Xt="http://www.w3.org/2000/svg";function Dn(i){let e=i.style?.line;return e&&!Array.isArray(e)&&e.color?e.color:g.stroke}function Ut(i){return i.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}function Pn(i){if(i.length===0)return "";let e=new Date(i[0].time).toLocaleString(),t=i.map(n=>`<div><span class="mlc-tooltip__name">${Ut(n.series.name)}:</span> ${n.value.toFixed(2)}</div>`);return `<div class="mlc-tooltip__time">${Ut(e)}</div>${t.join("")}`}function jn(i,e){if(i.length===0)return;let t=0,n=i.length-1;for(;t<n;){let s=t+n>>1;i[s].time<e?t=s+1:n=s;}let r=i[Math.max(0,t-1)],o=i[t];return Math.abs(r.time-e)<=Math.abs(o.time-e)?r:o}function Fn(i){return "value"in i?i.value:i.avg}function Se(i,e,t={}){let n=i.querySelector("svg");if(!n)throw new Error("attachTooltip: target has no <svg> child (did you mount the chart first?)");let r=t.format??Pn,o=t.snapRadius??1/0,s=t.className??"mlc-tooltip",a=t.showPicks??true,l=t.pickRadius??5,h=t.picksClassName??"mlc-tooltip-picks",m=document.createElement("div");m.className=s,m.style.position="absolute",m.style.pointerEvents="none",m.style.display="none",getComputedStyle(i).position==="static"&&(i.style.position="relative"),i.appendChild(m);let u=null;a&&(u=document.createElementNS(Xt,"g"),u.setAttribute("class",h),u.setAttribute("pointer-events","none"),n.appendChild(u));let c=()=>{u&&u.replaceChildren();},p=e.series.map((w,P)=>({data:w.data.map(R=>({time:R.time,value:Fn(R)})).filter(R=>R.value!==null).sort((R,E)=>R.time-E.time),series:w,index:P})),d=Yt(),b=null,f=w=>{let P=n.getBoundingClientRect(),B=e.getWidth?.()??P.width,R=(w.clientX-P.left)*B/Math.max(1,P.width);e.getHeight?.()??P.height;let G=e.invertTime(R);if(!Number.isFinite(G)){m.style.display="none";return}let V=[];for(let T of p){let C=jn(T.data,G);if(!C)continue;let Y=e.project(C.time,C.value,T.series.yAxisIndex??0).x,J=e.project(C.time,C.value,T.series.yAxisIndex??0).y;Math.abs(Y-R)>o||V.push({seriesIndex:T.index,series:T.series,time:C.time,value:C.value,x:Y,y:J});}if(V.length===0){m.style.display="none",c();return}m.innerHTML=r(V);let S=i.getBoundingClientRect(),$=12,j=(w.clientX-P.left)/Math.max(1,P.width),F=(w.clientY-P.top)/Math.max(1,P.height),D=j<.5?`${$}px`:`calc(-100% - ${$}px)`,O=F<.5?`${$}px`:`calc(-100% - ${$}px)`;if(m.style.left=`${w.clientX-S.left}px`,m.style.top=`${w.clientY-S.top}px`,m.style.transform=`translate(${D}, ${O})`,m.style.display="",u){u.replaceChildren();for(let T of V){let C=document.createElementNS(Xt,"circle");C.setAttribute("cx",String(T.x)),C.setAttribute("cy",String(T.y)),C.setAttribute("r",String(l)),C.setAttribute("fill","#ffffff"),C.setAttribute("stroke",Dn(T.series)),C.setAttribute("stroke-width","2"),C.setAttribute("class",`${h}__dot`),u.appendChild(C);}}},_=w=>{b=w,d.schedule(()=>{b&&f(b);});},A=()=>{b=null,d.cancel(),m.style.display="none",c();};n.addEventListener("mousemove",_),n.addEventListener("mouseleave",A);let v=false;return ()=>{v||(v=true,b=null,d.cancel(),n.removeEventListener("mousemove",_),n.removeEventListener("mouseleave",A),m.remove(),u&&u.remove());}}function Rn(i,e={}){let t=typeof i=="string"?document.querySelector(i):i;if(!t)throw new Error(`mount: target ${typeof i=="string"?`'${i}'`:""} not found`);let{tooltip:n,...r}=e,o=r.width??t.clientWidth??800,s=r.height??350,a=new se({...r,width:o,height:s}),{content:l}=new ne().render(a.renderCommands());t.innerHTML=l;let h=t.querySelector("svg");return h&&(h.setAttribute("viewBox",`0 0 ${o} ${a.getHeight()}`),h.setAttribute("width","100%"),h.setAttribute("height",String(a.getHeight()))),n?.show&&Se(t,a,n),a}var Ie=class{_opts;_series=[];_thresholds=[];_annotations=[];_highlights=[];_markers=[];_bands=[];_tooltip;constructor(e,t){this._opts={},e!==void 0&&(this._opts.width=e),t!==void 0&&(this._opts.height=t);}setWidth(e){return this._opts.width=e,this}setHeight(e){return this._opts.height=e,this}setSize(e,t){return this._opts.width=e,this._opts.height=t,this}setMargin(e,t,n,r){return typeof e=="object"?this._opts.margin=e:this._opts.margin={top:e,right:t??0,bottom:n??0,left:r??0},this}setLocale(e){return this._opts.locale=e,this}setAxes(e){return this._opts.axes=e,this}setXAxis(e){return this._opts.axes={...this._opts.axes,x:{...this._opts.axes?.x,...e}},this}setLeftAxis(e){return this._opts.axes={...this._opts.axes,left:{...this._opts.axes?.left,...e}},this}setRightAxis(e){return this._opts.axes={...this._opts.axes,right:{...this._opts.axes?.right,...e}},this}setYAxis(e,t){this._opts.axes??={},this._opts.axes.y??=[];let n=[...this._opts.axes.y];for(;n.length<=e;)n.push({});return n[e]={...n[e],...t},this._opts.axes.y=n,this}setLegend(e,t,n){return typeof e=="object"?this._opts.legend=e:this._opts.legend={show:e,position:t,orientation:n},this}setGaps(e){return this._opts.gaps=e,this}setTooltip(e){return this._tooltip={show:true,...e},this}addSeries(e){return this._series.push(e),this}addSeriesAll(e){return this._series.push(...e),this}addThreshold(e){return this._thresholds.push(e),this}addThresholds(e){return this._thresholds.push(...e),this}addAnnotation(e){return this._annotations.push(e),this}addAnnotations(e){return this._annotations.push(...e),this}addHighlight(e){return this._highlights.push(e),this}addMarker(e){return this._markers.push(e),this}addAnnotationBand(e){return this._bands.push(e),this}clear(e){return (!e||e==="series")&&(this._series=[]),(!e||e==="thresholds")&&(this._thresholds=[]),(!e||e==="annotations")&&(this._annotations=[]),(!e||e==="highlights")&&(this._highlights=[]),(!e||e==="markers")&&(this._markers=[]),(!e||e==="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 se(this.toOptions())}getSvg(){let e=this.build(),{content:t}=new ne().render(e.renderCommands());return t}mount(e){let t=typeof e=="string"?document.querySelector(e):e;if(!t){let s=typeof e=="string"?`'${e}'`:"";throw new Error(`GraphBuilder.mount: target ${s} not found`)}this._opts.width||(this._opts.width=t.clientWidth||800);let n=this.build(),{content:r}=new ne().render(n.renderCommands());t.innerHTML=r;let o=t.querySelector("svg");if(o){let s=this._opts.width??800;o.setAttribute("viewBox",`0 0 ${s} ${n.getHeight()}`),o.setAttribute("width","100%"),o.setAttribute("height",String(n.getHeight()));}return this._tooltip?.show&&Se(t,n,this._tooltip),n}};var He=class{_series;constructor(e){this._series={name:e,data:[]};}addPoint(e,t){return this._series.data.push({time:e,value:t}),this}setData(e){return this._series.data=[...e],this}addPoints(e){return this._series.data.push(...e),this}addFloats(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)this._series.data.push({time:e[r],value:t[r]});return this}addNullPoint(e){return this._series.data.push({time:e,value:null}),this}setYAxisIndex(e){return this._series.yAxisIndex=e,this}setColor(e){return this._series.style??={},!this._series.style.line||typeof this._series.style.line=="boolean"?this._series.style.line={color:e}:Array.isArray(this._series.style.line)?this._series.style.line.length===0?this._series.style.line=[{color:e}]:this._series.style.line[0].color=e:this._series.style.line.color=e,this}setStyle(e){return this._series.style=e,this}setLineStyle(e,t,n){return this._series.style??={},this._series.style.line={color:e,width:t,style:n},this}setSmoothing(e,t){return this._series.style??={},!this._series.style.line||typeof this._series.style.line=="boolean"?this._series.style.line={smoothing:e,smoothingType:t}:Array.isArray(this._series.style.line)?this._series.style.line.length===0?this._series.style.line=[{smoothing:e,smoothingType:t}]:(this._series.style.line[0].smoothing=e,this._series.style.line[0].smoothingType=t):(this._series.style.line.smoothing=e,this._series.style.line.smoothingType=t),this}setFill(e){return this._series.style??={},this._series.style.fill=e,this}setID(e){return this._series.id=e,this}setColorByThresholds(e){return this._series.colorByThresholds=e,this}build(){return this._series}};var We=class{_threshold;constructor(e,t){this._threshold={name:e,value:t};}setColor(e){return this._threshold.color=e,this}setLine(e){return this._threshold.line=e,this}setFill(e,t){return this._threshold.fill=e,this._threshold.fillOpacity=t,this}setFillHatch(e){return this._threshold.fillHatch=e,this}setLabel(e,t){return this._threshold.label={text:e,position:t},this}setID(e){return this._threshold.id=e,this}build(){return this._threshold}};var Ee=class{_marker;constructor(e){this._marker={time:e};}setValue(e){return this._marker.value=e,this}setLabel(e){return this._marker.label=e,this}setColor(e){return this._marker.color=e,this}setPointStyle(e){return this._marker.pointStyle=e,this}setLineStyle(e){return e==="none"?delete this._marker.lineStyle:this._marker.lineStyle=e,this}setSeriesIndex(e){return this._marker.seriesIndex=e,this}build(){return this._marker}};var Ne=class{_highlight;constructor(e,t){this._highlight={startTime:e,endTime:t};}setLabel(e){return this._highlight.label=e,this}setColor(e){return this._highlight.color=e,this}setOpacity(e){return this._highlight.opacity=e,this}setLabelPosition(e){return this._highlight.labelPosition=e,this}setRotate(e){return this._highlight.rotate=e,this}build(){return this._highlight}};var Ge=class{_ann;constructor(e){this._ann={type:e};}setID(e){return this._ann.id=e,this}setTitle(e){return this._ann.title=e,this}setFrom(e,t,n){return this._ann.from={time:e,value:t,axis:n},this}setTo(e,t,n){return this._ann.to={time:e,value:t,axis:n},this}setAt(e,t,n){return this._ann.at={time:e,value:t,axis:n},this}setColor(e){return this._ann.color=e,this}setWidth(e){return this._ann.width=e,this}setDash(e){return this._ann.dash=e,this}setHeadSize(e){return this._ann.headSize=e,this}setFill(e){return this._ann.fill=e,this}setHatch(e){return this._ann.hatch=e,this}setStroke(e){return this._ann.stroke=e,this}setOpacity(e){return this._ann.opacity=e,this}setRadius(e){return this._ann.radius=e,this}setShape(e){return this._ann.shape=e,this}setText(e){return this._ann.text=e,this}setAnchor(e){return this._ann.anchor=e,this}setDx(e){return this._ann.dx=e,this}setDy(e){return this._ann.dy=e,this}setRotate(e){return this._ann.rotate=e,this}build(){return this._ann}};var Ve=class{_band;constructor(e){this._band={name:e,items:[]};}setHeight(e){return this._band.height=e,this}setSpacing(e){return this._band.spacing=e,this}setHatch(e){return this._band.hatch=e,this}setShowAxis(e){return this._band.showAxis=e,this}setShowInLegend(e){return this._band.showInLegend=e,this}setBackground(e){return this._band.background=e,this}addItem(e){return this._band.items.push(e),this}build(){return this._band}},ze=class{_item;constructor(e,t){this._item={startTime:e,endTime:t};}setFill(e){return this._item.fill=e,this}setHatch(e){return this._item.hatch=e,this}setStroke(e){return this._item.stroke=e,this}setStrokeWidth(e){return this._item.strokeWidth=e,this}setLabel(e,t,n,r){return this._item.label=e,t!==void 0&&(this._item.labelFontSize=t),n!==void 0&&(this._item.labelFill=n),r!==void 0&&(this._item.labelBaseline=r),this}build(){return this._item}};function Bn(i){let{thresholds:e,colors:t,hatches:n}=i;if(t.length!==e.length+1)throw new Error(`fillBetweenThresholds: expected ${e.length+1} colors for ${e.length} thresholds, got ${t.length}`);if(n!==void 0&&n.length!==t.length)throw new Error(`fillBetweenThresholds: hatches length (${n.length}) must equal colors length (${t.length})`);return {regions:t.map((o,s)=>{let a=n?.[s],l=a?{color:o,hatch:a}:o;return s===0?{to:{threshold:e[0]},fill:l}:s===t.length-1?{from:{threshold:e[e.length-1]},fill:l}:{from:{threshold:e[s-1]},to:{threshold:e[s]},fill:l}})}}function mt(i){if(!i||typeof i!="object")throw new Error("DataPoint: object expected");let{time:e,value:t,annotation:n}=i;if(typeof e!="number"||Number.isNaN(e))throw new TypeError(`DataPoint: invalid time=${e}`);if(t!==null&&(typeof t!="number"||Number.isNaN(t)))throw t===void 0?new Error("DataPoint: missing value"):typeof t=="object"&&"value"in t?new Error("DataPoint: nested value object"):new Error(`DataPoint: invalid value=${t}`);return {time:e,value:t,annotation:n&&typeof n=="string"?n:void 0}}function On(i){if(Array.isArray(i))return i.map(mt);if(i&&typeof i=="object"){let e=i,t=e.name,n=e.data,r=e.sensorType,o=e.enumMap,s=e.color,a=e.lineWidth,l=e.smoothing,h=e.seriesType;if(!t?.length)throw new Error("Series: name required");if(!Array.isArray(n))throw new Error("Series: data must be an array");let m=s!==void 0||a!==void 0||l!==void 0?{color:s,width:a,smoothing:l}:void 0;return {name:t,data:n.map(mt),sensorType:r??"numeric",enumMap:o,seriesType:h,...m&&{style:{line:m}}}}throw new Error("parseSeries: object or DataPoint[] expected")}function In(i){if(!i||typeof i!="object")throw new Error("parseAggregated: object expected");let e=i,t=e.name,n=e.data,r=e.showAs,o=e.avgLine,s=e.countOpacity,a=e.color;if(!t?.length)throw new Error("AggregatedSeries: name required");if(!Array.isArray(n))throw new Error("AggregatedSeries: data must be an array");return {name:t,data:Hn(n),showAs:r,avgLine:o,countOpacity:s,...a!==void 0&&{style:{line:{color:a},fill:a}}}}function Hn(i){let e=t=>typeof t=="number"?t:null;return i.map(t=>{let n=t;return {time:n.time??0,min:e(n.min),max:e(n.max),avg:e(n.avg),count:typeof n.count=="number"?n.count:0}})}function ut(i,e,t){return typeof e=="function"?e(i):i[e??t]}function Wn(i,e,t){if(i instanceof Date){let n=i.getTime();if(Number.isNaN(n))throw new TypeError(`toDataPoints: invalid Date at row ${t}`);return n}if(typeof i=="string"){let n=Date.parse(i);if(Number.isNaN(n))throw new TypeError(`toDataPoints: unparsable time string at row ${t}: ${i}`);return n}if(typeof i=="number"&&Number.isFinite(i))return e==="s"||e==="auto"&&Math.abs(i)>=1e8&&Math.abs(i)<1e11?i*1e3:i;throw new TypeError(`toDataPoints: missing or invalid time at row ${t}: ${String(i)}`)}function En(i,e){if(i==null)return null;if(typeof i=="number")return Number.isNaN(i)?null:i;if(typeof i=="string"){let t=i.trim();if(t==="")return null;let n=Number(t);if(Number.isNaN(n))throw new TypeError(`toDataPoints: value is not a number at row ${e}: ${i}`);return n}throw new TypeError(`toDataPoints: invalid value at row ${e}: ${String(i)}`)}function qt(i,e={}){let t=e.timeUnit??"ms",n=[];for(let r=0;r<i.length;r++){let o=i[r];if(o==null)throw new TypeError(`toDataPoints: empty row at ${r}`);let s=Array.isArray(o),a=s&&e.time===void 0?o[0]:ut(o,e.time,"time"),l=s&&e.value===void 0?o[1]:ut(o,e.value,"value"),h={time:Wn(a,t,r),value:En(l,r)};if(e.annotation!==void 0){let m=ut(o,e.annotation,"annotation");typeof m=="string"&&m!==""&&(h.annotation=m);}n.push(h);}return (e.sort??true)&&n.sort((r,o)=>r.time-o.time),n}function Nn(i,e,t={}){return {name:i,data:qt(e,t)}}function Zt(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function Kt(i,e){if(!Zt(i)||!Zt(e))return e;let t={...i};for(let[n,r]of Object.entries(e))t[n]=Kt(t[n],r);return t}function Gn(...i){let e;for(let t of i)t!==void 0&&(e=Kt(e,t));return e??{}}/*!
44
44
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
45
45
  * MIT with Attribution: free use incl. commercial requires visible credit to
46
46
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
@@ -59,4 +59,4 @@ ${n}
59
59
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
60
60
  * MIT with Attribution: free use incl. commercial must have visible credit to
61
61
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
62
- */export{Ae as AnnotationBandBuilder,De as AnnotationBandItemBuilder,$e as AnnotationBuilder,_e as GraphBuilder,Ce as HighlightBuilder,J as MLTimeGraph,Te as MarkerBuilder,X as SVGRenderer,ve as ThresholdBuilder,ke as TimeSeriesBuilder,ze as VERSION,me as attachTooltip,fe as drawMarker,sn as fillBetweenThresholds,ne as getDefaultTheme,et as getLineStyle,cn as mergeOptions,on as mount,ln as parseAggregated,qe as parseDataPoint,an as parseSeries,Ft as resetDefaultTheme,je as resolveDash,Pt as setDefaultTheme,ee as slugify,$t as toDataPoints,dn as toSeries};
62
+ */export{Ve as AnnotationBandBuilder,ze as AnnotationBandItemBuilder,Ge as AnnotationBuilder,Ie as GraphBuilder,Ne as HighlightBuilder,se as MLTimeGraph,Ee as MarkerBuilder,ne as SVGRenderer,We as ThresholdBuilder,He as TimeSeriesBuilder,lt as VERSION,Se as attachTooltip,Le as drawMarker,un as estimateMetrics,Bn as fillBetweenThresholds,me as getDefaultTheme,yt as getLineStyle,pe as liberationMetrics,Gn as mergeOptions,Rn as mount,In as parseAggregated,mt as parseDataPoint,On as parseSeries,tn as resetDefaultTheme,Je as resolveDash,en as setDefaultTheme,le as slugify,qt as toDataPoints,Nn as toSeries};
@@ -1,4 +1,4 @@
1
- import { l as DataPoint, D as DrawCommand, d as TimeScale, e as LinearScale } from '../scale-CQhADkWB.js';
1
+ import { D as DataPoint, a as DrawCommand, T as TimeScale, L as LinearScale } from '../scale-B3MhoTu1.js';
2
2
 
3
3
  /*!
4
4
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -1,4 +1,4 @@
1
- var C=class{_config;_state;constructor(t,n){this._config={enabled:n?.enabled??true,zoomSpeed:n?.zoomSpeed??.1,minDomainMs:n?.minDomainMs??0,maxDomainMs:n?.maxDomainMs??365*24*60*60*1e3},this._state={domain:[...t],originalDomain:[...t],scale:1,offset:0};}get state(){return {...this._state,domain:[...this._state.domain]}}applyZoom(t,n,o){if(!this._config.enabled)return;let r=1+Math.sign(n)*this._config.zoomSpeed;if(r<=0)return;let[i,a]=this._state.domain,d=a-i,s=t/o,e=d/r,l=this._config.minDomainMs??0,m=this._config.maxDomainMs??1/0;e<l&&(e=l),e>m&&(e=m);let p=i+d*s,u=p-e*s,c=p+e*(1-s),[b,_]=this._state.originalDomain;c-u>_-b?(u=b,c=_,e=_-b):(u<b&&(c=_-(_-b)*((c-u)/(_-b)),u=b),c>_&&(u=b+(_-b)*((u-b)/(_-b)),c=_)),this._state.domain=[u,c],this._state.scale=(a-i)/e;}applyPan(t,n){if(!this._config.enabled)return;let[o,r]=this._state.domain,i=r-o,[a,d]=this._state.originalDomain,s=-(t/n)*i,e=o+s,l=r+s;e<a&&(s-=e-a),l>d&&(s-=l-d),this._state.domain=[o+s,r+s];}reset(){this._state.domain=[...this._state.originalDomain],this._state.scale=1,this._state.offset=0;}get enabled(){return this._config.enabled??true}};var w=new Map;function R(h,t){return `${h}|${JSON.stringify(t??{})}`}function k(h,t){let n=R(h,t),o=w.get(n);return o||(o=new Intl.DateTimeFormat(h,t),w.set(n,o)),o}var y=class{#t;#e;constructor(t){this.#t=[...t.domain],this.#e=[...t.range];}map(t){let n=Number(t),[o,r]=this.#t,[i,a]=this.#e;return r===o?i:i+(n-o)/(r-o)*(a-i)}invert(t){let[n,o]=this.#t,[r,i]=this.#e;return i===r?n:n+(t-r)/(i-r)*(o-n)}domain(){return [...this.#t]}range(){return [...this.#e]}},g=[{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}],x=class{#t;#e;#n;constructor(t){this.#t=new y({domain:t.domain,range:t.range}),this.#e=t.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#n=t.timeZone;}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 timeZone(){return this.#n}get locale(){return this.#e}tickInterval(t,n=3,o=12){let[r,i]=this.#t.domain(),a=i-r;if(a<=0)return {interval:g[0].ms};let d=a/t,s=g[0].ms;for(let m of g)if(m.ms>=d){s=m.ms;break}let e=s,l=Math.round(a/e);for(;l>o&&e<g[g.length-1].ms;){let m=g.findIndex(p=>p.ms===e);e=g[Math.min(m+1,g.length-1)].ms,l=Math.round(a/e);}for(;l<n&&e>g[0].ms;){let m=g.findIndex(p=>p.ms===e);e=g[Math.max(m-1,0)].ms,l=Math.round(a/e);}return {interval:e}}ticks(t){let n=t?.minTicks??5,o=t?.maxTicks??12,{interval:r}=this.tickInterval((n+o)/2,n,o),[i,a]=this.#t.domain(),d=[],s=Math.ceil(i/r)*r;for(let e=s;e<=a;e+=r)d.push(e);return d}format(t,n){let o=this.#n?{...n,timeZone:this.#n}:n;return k(this.#e,o).format(new Date(t))}};function v(h){let t=1/0,n=-1/0;for(let o=0;o<h.length;o++){let r=h[o];r<t&&(t=r),r>n&&(n=r);}return [t,n]}var M={fontFamily:"Liberation Sans, Arial, Helvetica, sans-serif",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 L={...M};function S(){return L}var f=new Proxy({},{get:(h,t)=>S()[t],has:(h,t)=>t in S(),ownKeys:()=>Reflect.ownKeys(S()),getOwnPropertyDescriptor:(h,t)=>Reflect.getOwnPropertyDescriptor(S(),t)});var D=class{_data;_width;_height;_x;_y;_zoom;_stroke;_bgColor;_brushColor;constructor(t){this._data=t.data,this._width=t.width,this._height=t.height,this._x=t.x,this._y=t.y,this._zoom=t.zoom,this._stroke=t.stroke??f.minimapStroke,this._bgColor=t.bgColor??f.minimapBg,this._brushColor=t.brushColor??f.minimapBrush;}render(){if(this._data.length===0)return [];let t=[],n=this._data.map(e=>e.time),o=this._data.map(e=>e.value).filter(e=>e!==null),r=v(n),i=v(o),a=new x({domain:r,range:[0,this._width]}),d=new y({domain:i,range:[this._height,0]});t.push({type:"rect",x:this._x,y:this._y,w:this._width,h:this._height,fill:this._bgColor});let s=this._data.map(e=>({x:this._x+a.map(e.time),y:this._y+d.map(e.value)}));if(t.push({type:"path",points:s,smoothing:false,stroke:this._stroke,strokeWidth:1}),this._zoom){let e=this._zoom.state,l=this._x+a.map(e.domain[0]),m=this._x+a.map(e.domain[1]),p=Math.max(2,m-l);t.push({type:"rect",x:l,y:this._y,w:p,h:this._height,fill:this._brushColor});}return t}navigateTo(t){let n=this._data.map(a=>a.time),o=v(n),r=new x({domain:o,range:[0,this._width]}),i=t-this._x;return r.invert(i)}};var T=class{_mouseX;_mouseY;_timeScale;_valueScale;_data;_xRange;_yRange;_snapRadius;_bgColor;_borderColor;_textColor;constructor(t){this._mouseX=t.mouseX,this._mouseY=t.mouseY,this._timeScale=t.timeScale,this._valueScale=t.valueScale,this._data=t.data,this._xRange=t.xRange,this._yRange=t.yRange,this._snapRadius=t.snapRadius??f.tooltipSnapRadius,this._bgColor=t.bgColor??f.tooltipBg,this._borderColor=t.borderColor??f.tooltipBorder,this._textColor=t.textColor??f.tooltipText;}compute(){let t=[...this._data].filter(u=>u.value!==null).sort((u,c)=>u.time-c.time),n,o=1/0;for(let u of t){let c=this._timeScale.map(u.time),b=Math.abs(this._mouseX-c);b<o&&(o=b,n=u);}if(!n||o>this._snapRadius)return {visible:false,commands:[]};let r=this._timeScale.map(n.time),i=this._valueScale.map(n.value),a=[];a.push({type:"line",x1:r,y1:this._yRange[0],x2:r,y2:this._yRange[1],stroke:"#94a3b8",strokeWidth:1},{type:"line",x1:this._xRange[0],y1:i,x2:this._xRange[1],y2:i,stroke:"#94a3b8",strokeWidth:1},{type:"circle",cx:r,cy:i,r:5,fill:"#3b82f6"});let d=new Date(n.time).toLocaleString(),s=n.value.toFixed(2),e=120,l=44,m=r+12,p=i-l-4;return m+e>this._xRange[1]&&(m=r-e-12),p<this._yRange[0]&&(p=i+12),a.push({type:"rect",x:m,y:p,w:e,h:l,fill:this._bgColor,stroke:this._borderColor,strokeWidth:1},{type:"text",content:d,x:m+8,y:p+16,fontSize:10,fill:this._textColor},{type:"text",content:`Value: ${s}`,x:m+8,y:p+32,fontSize:11,fill:"#3b82f6"}),{visible:true,commands:a,dataPoint:n,snapX:r}}};/*!
1
+ var C=class{_config;_state;constructor(t,n){this._config={enabled:n?.enabled??true,zoomSpeed:n?.zoomSpeed??.1,minDomainMs:n?.minDomainMs??0,maxDomainMs:n?.maxDomainMs??365*24*60*60*1e3},this._state={domain:[...t],originalDomain:[...t],scale:1,offset:0};}get state(){return {...this._state,domain:[...this._state.domain]}}applyZoom(t,n,o){if(!this._config.enabled)return;let i=1+Math.sign(n)*this._config.zoomSpeed;if(i<=0)return;let[r,a]=this._state.domain,d=a-r,s=t/o,e=d/i,l=this._config.minDomainMs??0,m=this._config.maxDomainMs??1/0;e<l&&(e=l),e>m&&(e=m);let p=r+d*s,u=p-e*s,c=p+e*(1-s),[b,f]=this._state.originalDomain;c-u>f-b?(u=b,c=f,e=f-b):(u<b&&(c=f-(f-b)*((c-u)/(f-b)),u=b),c>f&&(u=b+(f-b)*((u-b)/(f-b)),c=f)),this._state.domain=[u,c],this._state.scale=(a-r)/e;}applyPan(t,n){if(!this._config.enabled)return;let[o,i]=this._state.domain,r=i-o,[a,d]=this._state.originalDomain,s=-(t/n)*r,e=o+s,l=i+s;e<a&&(s-=e-a),l>d&&(s-=l-d),this._state.domain=[o+s,i+s];}reset(){this._state.domain=[...this._state.originalDomain],this._state.scale=1,this._state.offset=0;}get enabled(){return this._config.enabled??true}};var w=new Map;function F(h,t){return `${h}|${JSON.stringify(t??{})}`}function k(h,t){let n=F(h,t),o=w.get(n);return o||(o=new Intl.DateTimeFormat(h,t),w.set(n,o)),o}var y=class{#t;#e;constructor(t){this.#t=[...t.domain],this.#e=[...t.range];}map(t){let n=Number(t),[o,i]=this.#t,[r,a]=this.#e;return i===o?r:r+(n-o)/(i-o)*(a-r)}invert(t){let[n,o]=this.#t,[i,r]=this.#e;return r===i?n:n+(t-i)/(r-i)*(o-n)}domain(){return [...this.#t]}range(){return [...this.#e]}},g=[{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}],x=class{#t;#e;#n;constructor(t){this.#t=new y({domain:t.domain,range:t.range}),this.#e=t.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#n=t.timeZone;}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 timeZone(){return this.#n}get locale(){return this.#e}tickInterval(t,n=3,o=12){let[i,r]=this.#t.domain(),a=r-i;if(a<=0)return {interval:g[0].ms};let d=a/t,s=g[0].ms;for(let m of g)if(m.ms>=d){s=m.ms;break}let e=s,l=Math.round(a/e);for(;l>o&&e<g[g.length-1].ms;){let m=g.findIndex(p=>p.ms===e);e=g[Math.min(m+1,g.length-1)].ms,l=Math.round(a/e);}for(;l<n&&e>g[0].ms;){let m=g.findIndex(p=>p.ms===e);e=g[Math.max(m-1,0)].ms,l=Math.round(a/e);}return {interval:e}}ticks(t){let n=t?.minTicks??5,o=t?.maxTicks??12,{interval:i}=this.tickInterval((n+o)/2,n,o),[r,a]=this.#t.domain(),d=[],s=Math.ceil(r/i)*i;for(let e=s;e<=a;e+=i)d.push(e);return d}format(t,n){let o=this.#n?{...n,timeZone:this.#n}:n;return k(this.#e,o).format(new Date(t))}};function v(h){let t=1/0,n=-1/0;for(let o=0;o<h.length;o++){let i=h[o];i<t&&(t=i),i>n&&(n=i);}return [t,n]}var M={fontFamily:"Liberation Sans, Arial, Helvetica, sans-serif",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,markerFontSize:11,statFontSize:10,tooltipTimeFontSize:10,tooltipValueFontSize: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 R={...M};function S(){return R}var _=new Proxy({},{get:(h,t)=>S()[t],has:(h,t)=>t in S(),ownKeys:()=>Reflect.ownKeys(S()),getOwnPropertyDescriptor:(h,t)=>Reflect.getOwnPropertyDescriptor(S(),t)});var D=class{_data;_width;_height;_x;_y;_zoom;_stroke;_bgColor;_brushColor;constructor(t){this._data=t.data,this._width=t.width,this._height=t.height,this._x=t.x,this._y=t.y,this._zoom=t.zoom,this._stroke=t.stroke??_.minimapStroke,this._bgColor=t.bgColor??_.minimapBg,this._brushColor=t.brushColor??_.minimapBrush;}render(){if(this._data.length===0)return [];let t=[],n=this._data.map(e=>e.time),o=this._data.map(e=>e.value).filter(e=>e!==null),i=v(n),r=v(o),a=new x({domain:i,range:[0,this._width]}),d=new y({domain:r,range:[this._height,0]});t.push({type:"rect",x:this._x,y:this._y,w:this._width,h:this._height,fill:this._bgColor});let s=this._data.map(e=>({x:this._x+a.map(e.time),y:this._y+d.map(e.value)}));if(t.push({type:"path",points:s,smoothing:false,stroke:this._stroke,strokeWidth:1}),this._zoom){let e=this._zoom.state,l=this._x+a.map(e.domain[0]),m=this._x+a.map(e.domain[1]),p=Math.max(2,m-l);t.push({type:"rect",x:l,y:this._y,w:p,h:this._height,fill:this._brushColor});}return t}navigateTo(t){let n=this._data.map(a=>a.time),o=v(n),i=new x({domain:o,range:[0,this._width]}),r=t-this._x;return i.invert(r)}};var T=class{_mouseX;_mouseY;_timeScale;_valueScale;_data;_xRange;_yRange;_snapRadius;_bgColor;_borderColor;_textColor;constructor(t){this._mouseX=t.mouseX,this._mouseY=t.mouseY,this._timeScale=t.timeScale,this._valueScale=t.valueScale,this._data=t.data,this._xRange=t.xRange,this._yRange=t.yRange,this._snapRadius=t.snapRadius??_.tooltipSnapRadius,this._bgColor=t.bgColor??_.tooltipBg,this._borderColor=t.borderColor??_.tooltipBorder,this._textColor=t.textColor??_.tooltipText;}compute(){let t=[...this._data].filter(u=>u.value!==null).sort((u,c)=>u.time-c.time),n,o=1/0;for(let u of t){let c=this._timeScale.map(u.time),b=Math.abs(this._mouseX-c);b<o&&(o=b,n=u);}if(!n||o>this._snapRadius)return {visible:false,commands:[]};let i=this._timeScale.map(n.time),r=this._valueScale.map(n.value),a=[];a.push({type:"line",x1:i,y1:this._yRange[0],x2:i,y2:this._yRange[1],stroke:"#94a3b8",strokeWidth:1},{type:"line",x1:this._xRange[0],y1:r,x2:this._xRange[1],y2:r,stroke:"#94a3b8",strokeWidth:1},{type:"circle",cx:i,cy:r,r:5,fill:"#3b82f6"});let d=new Date(n.time).toLocaleString(),s=n.value.toFixed(2),e=120,l=44,m=i+12,p=r-l-4;return m+e>this._xRange[1]&&(m=i-e-12),p<this._yRange[0]&&(p=r+12),a.push({type:"rect",x:m,y:p,w:e,h:l,fill:this._bgColor,stroke:this._borderColor,strokeWidth:1},{type:"text",content:d,x:m+8,y:p+16,fontSize:_.tooltipTimeFontSize,fill:this._textColor},{type:"text",content:`Value: ${s}`,x:m+8,y:p+32,fontSize:_.tooltipValueFontSize,fill:"#3b82f6"}),{visible:true,commands:a,dataPoint:n,snapX:i}}};/*!
2
2
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
3
3
  * MIT with Attribution: free use incl. commercial requires visible credit to
4
4
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.