ml-time-graph 1.10.0 → 1.11.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/internals.js CHANGED
@@ -1,4 +1,4 @@
1
- var Y=class{};var x=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((l,s)=>l.time-s.time),r=[],o=[],a=null;for(let l of n){let s=e(l),m=t>0&&a&&l.time-a.time>t;(s||m)&&o.length&&(r.push(o),o=[]),s||o.push(l),a=l;}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((m,u)=>m-u),o=[],a=m=>m<=0?Number.NEGATIVE_INFINITY:r[m-1],l=m=>{let u=0;for(let c=0;c<r.length&&m>=r[c];c++)u=c+1;return u},s=[i[0]];for(let m=1;m<i.length;m++){let u=i[m-1],c=i[m],h=t(u),f=t(c),p;f>h?p=r.filter(g=>g>h&&g<=f):f<h?p=r.filter(g=>g>=f&&g<h).reverse():p=[];let y=h;for(let g of p){let b=(g-h)/(f-h),S=n(u,c,b);s.push(S);let w=l((y+g)/2);o.push({data:s,zoneIndex:w,zoneLow:a(w)}),s=[S],y=g;}(p.length===0||p[p.length-1]!==f)&&s.push(c);}if(s.length>1||i.length===1){let m=t(s[0]),u=t(s[s.length-1]),c=l((m+u)/2);o.push({data:s,zoneIndex:c,zoneLow:a(c)});}return o}static splitByThreshold(i,e,t,n){let r=this.splitByBoundaries(i,[e],t,n),o={above:[],below:[]};for(let a of r)a.zoneIndex===0?o.below.push(a.data):o.above.push(a.data);return o}};var pe=class{static compute(i){let e=i.map(l=>l.value).filter(l=>l!==null).sort((l,s)=>l-s);if(e.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let t=e.length,n=e.reduce((l,s)=>l+s,0)/t,r=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,o=e.reduce((l,s)=>l+Math.pow(s-n,2),0)/t,a=Math.sqrt(o);return {min:e[0],max:e[t-1],avg:n,mean:n,median:r,stdDev:a,count:t}}static computeInRange(i,e,t){let n=i.filter(r=>r.time>=e&&r.time<=t);return this.compute(n)}};function Z(i){let e=[];for(let t of i)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}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}function D(i){return {id:i.id,line:{stroke:i.stroke??d.stroke,strokeWidth:i.strokeWidth??d.strokeWidth,smoothing:i.smoothing??false,smoothingType:i.smoothingType,dashed:i.dashed??false},fill:i.fill??d.areaFillAlpha,markers:{type:i.pointStyle??"none",size:i.pointSize??d.pointSize,stroke:i.stroke??d.stroke,fill:"#ffffff"},shadow:{color:i.shadowColor??"transparent",blur:i.shadowBlur??0,offsetX:i.shadowOffsetX??0,offsetY:i.shadowOffsetY??0}}}function _e(i,e,t,n){let r=x.splitByThreshold(i,e,a=>a.value,x.interpolateDataPoint),o=[];return n.below&&o.push(...v(r.below.map(a=>({data:a})),t,n.below)),n.above&&o.push(...v(r.above.map(a=>({data:a})),t,n.above)),o}function v(i,e,t){let n=[],r=D(t);for(let o=0;o<i.length;o++){let a=i[o];a.data.length>=2?n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${o}`:void 0,points:a.data.map(l=>({x:e.timeScale.map(l.time),y:e.valueScale.map(l.value)})),stroke:a.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:r.line.smoothing,dashed:r.line.dashed,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur,shadowOffsetX:r.shadow.offsetX,shadowOffsetY:r.shadow.offsetY,fill:"none"}):a.data.length===1&&n.push({type:"circle",id:t.id?`${t.id}-dot-${o}`:void 0,cx:e.timeScale.map(a.data[0].time),cy:e.valueScale.map(a.data[0].value),r:Math.max(r.markers.size,r.line.strokeWidth),fill:a.color??r.line.stroke,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur});}return n}function X(i,e,t){let n=[],r=D(t);for(let o=0;o<i.length;o++){let a=i[o];if(a.data.length<2)continue;let l=Z(a.data.map(s=>({x:e.timeScale.map(s.time),y:e.valueScale.map(s.value)})));n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${o}`:void 0,points:l,stroke:a.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:false,fill:"none"});}return n}function $e(i,e,t,n,r){let o=[],a=D(t);for(let l=0;l<i.length;l++){let s=i[l];if(s.data.length<2)continue;let m=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(n(c))})),u=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(r(c))})).reverse();o.push({type:"path",cssClass:"series-fill",id:t.id?`${t.id}-fill-${l}`:void 0,points:[...m,...u],fill:s.color??a.fill,hatch:t.hatch,stroke:"none"});}return o}function E(i,e,t,n){if(i.length<2)return [];let r=x.splitByBoundaries(i,t.boundaries,t.getValue,t.interpolate),o=[];for(let a=0;a<r.length;a++){let l=r[a];if(l.data.length<2)continue;let s=t.getColor(l.zoneIndex);if(!s)continue;let m=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yLow(c))})),u=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yHigh(c))})).reverse();o.push({type:"path",cssClass:"series-fill",id:n?.id?`${n.id}-fill-${a}`:void 0,points:[...m,...u],fill:s,hatch:t.getHatch?.(l.zoneIndex),stroke:"none"});}return o}function R(i,e,t,n){let r=D(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let a=0;a<i.length;a++){let l=i[a],s=e.timeScale.map(l.time),m=e.valueScale.map(l.value),u=n(l),c=t.pointStroke??u,h=t.pointFill??u,f=t.pointStrokeWidth??1.5,p=t.id?`${t.id}-marker-${a}`:void 0;U(o,p,r.markers.type,s,m,r.markers.size,c,h,f);}return o}function U(i,e,t,n,r,o,a,l,s){let m=u=>e===void 0?void 0:`${e}-${u}`;switch(t){case "circle":i.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:a,strokeWidth:s,id:e});break;case "square":i.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:l,stroke:a,strokeWidth:s,id:e});break;case "cross":i.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:a,strokeWidth:s,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:a,strokeWidth:s,id:m(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:l,stroke:a,strokeWidth:s,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:l,stroke:a,strokeWidth:s,id:e});break;case "star":{let u=[];for(let c=0;c<10;c++){let h=c%2===0?o:o*.5,f=Math.PI/2*3+c*Math.PI/5;u.push({x:n+h*Math.cos(f),y:r+h*Math.sin(f)});}i.push({type:"path",points:u,closed:true,fill:l,stroke:a,strokeWidth:s,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:a,strokeWidth:s,fill:"none",id:e});break;case "plus":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:a,strokeWidth:s,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:a,strokeWidth:s,id:m(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:l,stroke:a,strokeWidth:s,id:e});break;case "hexagon":{let u=[];for(let c=0;c<6;c++){let h=c*(Math.PI/3);u.push({x:n+o*Math.cos(h),y:r+o*Math.sin(h)});}i.push({type:"path",points:u,closed:true,fill:l,stroke:a,strokeWidth:s,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:l,stroke:a,strokeWidth:s,id:e});break;case "line-horizontal":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:a,strokeWidth:s,id:e});break;default:i.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:a,strokeWidth:s,id:e});}}var Pe=[[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"]],fe=.6,Fe=(()=>{let i=new Map;for(let[e,,t]of Pe){let n=t.split(",");for(let r=0;r<n.length;r++)i.set(e+r,Number(n[r])/1e3);}return i})();function ge(i){return Fe.get(i)??fe}var q=(i,e)=>{let t=0;for(let n of i)t+=ge(n.codePointAt(0)??0);return t*e};var ye={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 Ae={...ye};function M(){return Ae}function Re(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 We(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=n??Re(t),a=We(t)?"":' fill-opacity="0.3"';if(e==="none")return `
1
+ var Y=class{};var x=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((l,s)=>l.time-s.time),r=[],o=[],a=null;for(let l of n){let s=e(l),m=t>0&&a&&l.time-a.time>t;(s||m)&&o.length&&(r.push(o),o=[]),s||o.push(l),a=l;}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((m,u)=>m-u),o=[],a=m=>m<=0?Number.NEGATIVE_INFINITY:r[m-1],l=m=>{let u=0;for(let c=0;c<r.length&&m>=r[c];c++)u=c+1;return u},s=[i[0]];for(let m=1;m<i.length;m++){let u=i[m-1],c=i[m],h=t(u),f=t(c),d;f>h?d=r.filter(y=>y>h&&y<=f):f<h?d=r.filter(y=>y>=f&&y<h).reverse():d=[];let g=h;for(let y of d){let b=(y-h)/(f-h),S=n(u,c,b);s.push(S);let C=l((g+y)/2);o.push({data:s,zoneIndex:C,zoneLow:a(C)}),s=[S],g=y;}(d.length===0||d[d.length-1]!==f)&&s.push(c);}if(s.length>1||i.length===1){let m=t(s[0]),u=t(s[s.length-1]),c=l((m+u)/2);o.push({data:s,zoneIndex:c,zoneLow:a(c)});}return o}static splitByThreshold(i,e,t,n){let r=this.splitByBoundaries(i,[e],t,n),o={above:[],below:[]};for(let a of r)a.zoneIndex===0?o.below.push(a.data):o.above.push(a.data);return o}};var fe=class{static compute(i){let e=i.map(l=>l.value).filter(l=>l!==null).sort((l,s)=>l-s);if(e.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let t=e.length,n=e.reduce((l,s)=>l+s,0)/t,r=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,o=e.reduce((l,s)=>l+Math.pow(s-n,2),0)/t,a=Math.sqrt(o);return {min:e[0],max:e[t-1],avg:n,mean:n,median:r,stdDev:a,count:t}}static computeInRange(i,e,t){let n=i.filter(r=>r.time>=e&&r.time<=t);return this.compute(n)}};function U(i){let e=[];for(let t of i)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}function Pe(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 D(i){return {id:i.id,line:{stroke:i.stroke??p.stroke,strokeWidth:i.strokeWidth??p.strokeWidth,smoothing:i.smoothing??false,smoothingType:i.smoothingType,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 $e(i,e,t,n){let r=x.splitByThreshold(i,e,a=>a.value,x.interpolateDataPoint),o=[];return n.below&&o.push(...v(r.below.map(a=>({data:a})),t,n.below)),n.above&&o.push(...v(r.above.map(a=>({data:a})),t,n.above)),o}function v(i,e,t){let n=[],r=D(t);for(let o=0;o<i.length;o++){let a=i[o];a.data.length>=2?n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${o}`:void 0,points:a.data.map(l=>({x:e.timeScale.map(l.time),y:e.valueScale.map(l.value)})),stroke:a.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:r.line.smoothing,dashed:r.line.dashed,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur,shadowOffsetX:r.shadow.offsetX,shadowOffsetY:r.shadow.offsetY,fill:"none"}):a.data.length===1&&n.push({type:"circle",id:t.id?`${t.id}-dot-${o}`:void 0,cx:e.timeScale.map(a.data[0].time),cy:e.valueScale.map(a.data[0].value),r:Math.max(r.markers.size,r.line.strokeWidth),fill:a.color??r.line.stroke,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur});}return n}function q(i,e,t){let n=[],r=D(t);for(let o=0;o<i.length;o++){let a=i[o];if(a.data.length<2)continue;let l=U(a.data.map(s=>({x:e.timeScale.map(s.time),y:e.valueScale.map(s.value)})));n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${o}`:void 0,points:l,stroke:a.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:false,fill:"none"});}return n}function Ae(i,e,t,n,r){let o=[],a=D(t);for(let l=0;l<i.length;l++){let s=i[l];if(s.data.length<2)continue;let m=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(n(c))})),u=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(r(c))})).reverse();o.push({type:"path",cssClass:"series-fill",id:t.id?`${t.id}-fill-${l}`:void 0,points:[...m,...u],fill:s.color??a.fill,hatch:t.hatch,stroke:"none"});}return o}function z(i,e,t,n){if(i.length<2)return [];let r=x.splitByBoundaries(i,t.boundaries,t.getValue,t.interpolate),o=[];for(let a=0;a<r.length;a++){let l=r[a];if(l.data.length<2)continue;let s=t.getColor(l.zoneIndex);if(!s)continue;let m=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yLow(c))})),u=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yHigh(c))})).reverse();o.push({type:"path",cssClass:"series-fill",id:n?.id?`${n.id}-fill-${a}`:void 0,points:[...m,...u],fill:s,hatch:t.getHatch?.(l.zoneIndex),stroke:"none"});}return o}function R(i,e,t,n){let r=D(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let a=0;a<i.length;a++){let l=i[a],s=e.timeScale.map(l.time),m=e.valueScale.map(l.value),u=n(l),c=t.pointStroke??u,h=t.pointFill??u,f=t.pointStrokeWidth??1.5,d=t.id?`${t.id}-marker-${a}`:void 0;K(o,d,r.markers.type,s,m,r.markers.size,c,h,f);}return o}function K(i,e,t,n,r,o,a,l,s){let m=u=>e===void 0?void 0:`${e}-${u}`;switch(t){case "circle":i.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:a,strokeWidth:s,id:e});break;case "square":i.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:l,stroke:a,strokeWidth:s,id:e});break;case "cross":i.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:a,strokeWidth:s,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:a,strokeWidth:s,id:m(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:l,stroke:a,strokeWidth:s,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:l,stroke:a,strokeWidth:s,id:e});break;case "star":{let u=[];for(let c=0;c<10;c++){let h=c%2===0?o:o*.5,f=Math.PI/2*3+c*Math.PI/5;u.push({x:n+h*Math.cos(f),y:r+h*Math.sin(f)});}i.push({type:"path",points:u,closed:true,fill:l,stroke:a,strokeWidth:s,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:a,strokeWidth:s,fill:"none",id:e});break;case "plus":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:a,strokeWidth:s,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:a,strokeWidth:s,id:m(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:l,stroke:a,strokeWidth:s,id:e});break;case "hexagon":{let u=[];for(let c=0;c<6;c++){let h=c*(Math.PI/3);u.push({x:n+o*Math.cos(h),y:r+o*Math.sin(h)});}i.push({type:"path",points:u,closed:true,fill:l,stroke:a,strokeWidth:s,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:l,stroke:a,strokeWidth:s,id:e});break;case "line-horizontal":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:a,strokeWidth:s,id:e});break;default:i.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:a,strokeWidth:s,id:e});}}var Fe=[[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"]],ge=.6,Re=(()=>{let i=new Map;for(let[e,,t]of Fe){let n=t.split(",");for(let r=0;r<n.length;r++)i.set(e+r,Number(n[r])/1e3);}return i})();function ye(i){return Re.get(i)??ge}var J=(i,e)=>{let t=0;for(let n of i)t+=ye(n.codePointAt(0)??0);return t*e};var be={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 We={...be};function M(){return We}function je(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 Oe(i){let e=i.trim().toLowerCase();return e.startsWith("#")?e.length===9||e.length===5:e.startsWith("rgba(")||e.startsWith("hsla(")}function xe(i,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n,r=2){let o=n??je(t),a=Oe(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>
@@ -21,10 +21,10 @@ var Y=class{};var x=class{static interpolateDataPoint(i,e,t){return {time:i.time
21
21
  ${c}
22
22
  ${u}
23
23
  </pattern>
24
- `.trim()}var d=new Proxy({},{get:(i,e)=>M()[e],has:(i,e)=>e in M(),ownKeys:()=>Reflect.ownKeys(M()),getOwnPropertyDescriptor:(i,e)=>Reflect.getOwnPropertyDescriptor(M(),e)});var L=12,z=8,K=20,je=11,V=18,J=(i,e)=>e(i,je);function xe(i,e,t){let n=l=>L+z+J(l.name,e);if(t===void 0){let l=i.reduce((s,m)=>s+n(m)+V,0)-V;return [{items:i,breite:Math.max(0,l)}]}let r=[],o=[],a=0;for(let l of i){let s=n(l),m=o.length===0?s:a+V+s;o.length>0&&m>t?(r.push({items:o,breite:a}),o=[l],a=s):(o=[...o,l],a=m);}return o.length>0&&r.push({items:o,breite:a}),r}function Ie(i,e="vertical",t=q,n){if(e==="horizontal"){let o=xe(i,t,n);return {width:o.reduce((a,l)=>Math.max(a,l.breite),0),height:o.length*K}}let r=0;for(let o of i)r=Math.max(r,J(o.name,t));return {width:L+z+r,height:i.length*K}}function Oe(i){let{items:e,x:t,y:n,orientation:r="vertical",metrics:o=q,maxBreite:a}=i,l=[],s=r==="horizontal"?xe(e,o,a):e.map(u=>({items:[u],breite:0})),m=new Map;return s.forEach((u,c)=>{let h=t;for(let f of u.items)m.set(f,{x:h,y:n+c*K}),h+=L+z+J(f.name,o)+V;}),e.forEach(u=>{let c=m.get(u)??{x:t,y:n},h=c.x,f=c.y;l.push({type:"rect",x:h,y:f,w:L,h:L,fill:u.color,stroke:d.legendStroke,strokeWidth:1},{type:"text",content:u.name,x:h+L+z,y:f+L-2,fontSize:d.legendFont,fill:d.legendText});}),{type:"group",cssClass:"chart-legend",commands:l}}function He(i){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=d.gridStroke,strokeWidth:a=d.gridStrokeWidth,dashed:l=false,opacity:s=d.gridOpacity}=i,m=[];if(t)for(let u of t)m.push({type:"line",x1:n[0],y1:u,x2:n[1],y2:u,stroke:o,strokeWidth:a,dashed:l,opacity:s});if(e)for(let u of e)m.push({type:"line",x1:u,y1:r[0],x2:u,y2:r[1],stroke:o,strokeWidth:a,dashed:l,opacity:s});return m}var Se=new Map;function Be(i,e){return `${i}|${JSON.stringify(e??{})}`}function W(i,e){let t=Be(i,e),n=Se.get(t);return n||(n=new Intl.DateTimeFormat(i,e),Se.set(t,n)),n}var _=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,r]=this.#e,[o,a]=this.#t;return r===n?o:o+(t-n)/(r-n)*(a-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]}},T=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],j=class{#e;#t;#n;constructor(e){this.#e=new _({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(),a=o-r;if(a<=0)return {interval:T[0].ms};let l=a/e,s=T[0].ms;for(let c of T)if(c.ms>=l){s=c.ms;break}let m=s,u=Math.round(a/m);for(;u>n&&m<T[T.length-1].ms;){let c=T.findIndex(h=>h.ms===m);m=T[Math.min(c+1,T.length-1)].ms,u=Math.round(a/m);}for(;u<t&&m>T[0].ms;){let c=T.findIndex(h=>h.ms===m);m=T[Math.max(c-1,0)].ms,u=Math.round(a/m);}return {interval:m}}ticks(e){let t=e?.minTicks??5,n=e?.maxTicks??12,{interval:r}=this.tickInterval((t+n)/2,t,n),[o,a]=this.#e.domain(),l=[],s=Math.ceil(o/r)*r;for(let m=s;m<=a;m+=r)l.push(m);return l}format(e,t){let n=this.#n?{...t,timeZone:this.#n}:t;return W(this.#t,n).format(new Date(e))}},I=class{#e;#t;#n;#r;constructor(e){this.#e=[...e.domain],this.#t=[...e.range],this.#n=e.paddingInner??.1,this.#r=e.paddingOuter??.05;}get step(){let[e,t]=this.#t,n=this.#e.length;return n<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/n+Math.abs(t-e)*this.#n*2/n}get bandwidth(){let[e,t]=this.#t,n=this.#e.length;if(n<=1)return Math.abs(t-e)*(1-this.#r*2);let r=this.#r*2*Math.abs(t-e);return (Math.abs(t-e)-r)/n*(1-this.#n)}map(e){let t=this.#e.findIndex(c=>String(c)===String(e));if(t===-1)return this.#t[0];let[n,r]=this.#t,o=this.#e.length;if(o<=1)return (n+r)/2;let a=this.#r*2*Math.abs(r-n),l=Math.abs(r-n)-a,s=r>=n?1:-1,m=l/o;return n+this.#r*Math.abs(r-n)*s+t*m}invert(e){let t=0,n=1/0;for(let r=0;r<this.#e.length;r++){let o=this.map(this.#e[r]),a=Math.abs(e-o);a<n&&(n=a,t=r);}return this.#e[t]}domain(){return this.#e.length===0?["",""]:[this.#e[0],this.#e[this.#e.length-1]]}range(){return [...this.#t]}positions(){let e=new Map;for(let t of this.#e)e.set(t,this.map(t));return e}};function Ee(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function Ve(i){let{thresholds:e,valueScale:t,xRange:n}=i,[r,o]=n,[a,l]=t.range(),s=Math.min(a,l),m=Math.max(a,l),u=[],c=[];for(let h of e){let f=h.color??d.thresholdColor,p=t.map(h.value);h.fill==="above"?u.push({type:"rect",x:r,y:s,w:o-r,h:Math.max(0,p-s),fill:f,hatch:h.fillHatch,opacity:h.fillOpacity??.12,id:h.id?`${h.id}-fill`:void 0}):h.fill==="below"&&u.push({type:"rect",x:r,y:p,w:o-r,h:Math.max(0,m-p),fill:f,hatch:h.fillHatch,opacity:h.fillOpacity??.12,id:h.id?`${h.id}-fill`:void 0});let y=h.line??d.thresholdLine;if(y!=="none"){let w=Ee(y),k={type:"line",x1:r,y1:p,x2:o,y2:p,stroke:f,strokeWidth:1,...w,id:h.id?`${h.id}-line`:void 0};h.shadowColor&&(k.shadowColor=h.shadowColor,k.shadowBlur=h.shadowBlur??4,k.shadowOffsetX=h.shadowOffsetX??0,k.shadowOffsetY=h.shadowOffsetY??2),u.push(k);}let[g,b]=t.domain();if(h.value>=Math.min(g,b)&&h.value<=Math.max(g,b)&&h.label!==void 0&&h.label!==null&&h.label!==false){let w=typeof h.label=="object"?h.label:void 0,k=typeof h.label=="string"?h.label:w?.text??h.name,B=w?.position??"right",de=Ge(k,B,r,o,p,f,w);c.push({...de,y:Ne(de.y,Math.min(a,l),Math.max(a,l),d.thresholdFontSize),id:h.id?`${h.id}-label`:void 0});}}return {inside:u,labels:c}}function ze(i){let e=Ve(i);return [...e.inside,...e.labels]}function Ne(i,e,t,n){return Math.max(e+n,Math.min(t-n/2,i))}function Ge(i,e,t,n,r,o,a){let l=(t+n)/2,s={type:"text",content:i,fontSize:d.thresholdFontSize,fill:o},m=a?{...a.rotate!==void 0&&{rotate:a.rotate},...a.textBaseline!==void 0&&{textBaseline:a.textBaseline}}:{};switch(e){case "left":return {...s,...m,x:t+4,y:r-4,anchor:"start"};case "above":return {...s,...m,x:l,y:r-6,anchor:"middle"};case "below":return {...s,...m,x:l,y:r+14,anchor:"middle"};case "center":return {...s,...m,x:l,y:r-4,anchor:"middle"};case "outside-left":return {...s,...m,x:t-6,y:r+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...s,...m,x:n+6,y:r+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...s,...m,x:n-4,y:r-4,anchor:"end"}}}function ke(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 N(i){let{ranges:e,timeScale:t,yRange:n,height:r}=i,[o,a]=n,l=[],[s,m]=t.range(),u=Math.min(s,m),c=Math.max(s,m),h=f=>Math.max(u,Math.min(c,f));for(let f of e){let p=h(t.map(f.startTime)),y=h(t.map(f.endTime));if(f.fill!==void 0&&l.push({type:"rect",x:p,y:o,w:y-p,h:a-o,fill:f.fill,hatch:f.hatch,opacity:f.opacity}),f.edges)for(let g of [p,y])l.push({type:"line",x1:g,y1:o,x2:g,y2:a,stroke:f.edges.stroke,strokeWidth:f.edges.strokeWidth,dash:"dashed"});f.label&&l.push({type:"text",content:f.label,x:(p+y)/2,y:ke(f.labelPosition??"middle",o,a,r),anchor:"middle",fontSize:f.fontSize,fill:f.labelColor,rotate:f.rotate});}return l}function Ye(i){let{gaps:e,timeScale:t,yRange:n,height:r,fill:o=d.gapFill,hatch:a,fillOpacity:l=d.gapFillOpacity??.15,stroke:s=d.gapStroke,strokeWidth:m=d.gapStrokeWidth,dashed:u=true,fontSize:c=d.gapFontSize,fontFill:h=d.gapFontColor,labelBaseline:f="middle",labelRotate:p}=i;return N({timeScale:t,yRange:n,height:r,ranges:e.map(y=>{let g=y.style??"dashed_border",b=g==="filled"||g==="dashed_border",S=g==="dashed_border"&&u!==false;return {startTime:y.startTime,endTime:y.endTime,...b&&{fill:y.fill??o,hatch:y.hatch??a,opacity:y.fillOpacity??l},...S&&{edges:{stroke:s,strokeWidth:m}},label:y.label,labelPosition:y.labelBaseline??f,labelColor:h,fontSize:c,rotate:y.rotate??p}})})}function Ze(i){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=i,[o,a]=r,l=[];for(let s of e){let m=t.map(s.time),u=s.color??d.markerColor,c=s.pointStyle??(s.value!==void 0?"circle":"none"),h=s.lineStyle??"full";if(s.value!==void 0){let f=n.map(s.value);if(h==="to-value"?l.push({type:"line",x1:m,y1:a,x2:m,y2:f,stroke:u,strokeWidth:1,dashed:true}):h==="to-top"?l.push({type:"line",x1:m,y1:o,x2:m,y2:f,stroke:u,strokeWidth:1,dashed:true}):h==="full"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:a,stroke:u,strokeWidth:1}),c!=="none"&&U(l,void 0,c,m,f,d.markerSize,u,u,1.5),s.label){let p=h==="to-value"?f-10:o-6;l.push({type:"text",content:s.label,x:m,y:p,anchor:"middle",fontSize:d.markerFontSize,fill:u});}}else h!=="none"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:a,stroke:u,strokeWidth:1}),s.label&&l.push({type:"text",content:s.label,x:m,y:o-6,anchor:"middle",fontSize:d.markerFontSize,fill:u});}return l}function Xe(i){let{highlights:e,timeScale:t,yRange:n,height:r}=i;return N({timeScale:t,yRange:n,height:r,ranges:e.map(o=>({startTime:o.startTime,endTime:o.endTime,fill:o.color??d.highlightColor,opacity:o.opacity??d.highlightOpacity,label:o.label,labelPosition:o.labelPosition??"top",labelColor:o.color??d.highlightLabelColor,fontSize:d.annotationFontSize,rotate:o.rotate}))})}function Q(i){return i&&i.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function Ue(i){let{annotations:e,timeScale:t,valueScales:n}=i,r=[],o=a=>{let l=n.get(a.axis??0)??n.values().next().value;return {x:t.map(a.time),y:l?l.map(a.value):0}};for(let a of e){let l=[],s=m=>l.push(m);switch(a.type){case "line":{let m=o(a.from),u=o(a.to);s({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:a.color??d.annotationColor,strokeWidth:a.width??d.annotationWidth,dash:a.dash});break}case "arrow":{let m=o(a.from),u=o(a.to),c=a.color??d.annotationColor,h=a.headSize??d.annotationHead;s({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:c,strokeWidth:a.width??d.annotationWidth});let f=Math.hypot(u.x-m.x,u.y-m.y)||1,p=(u.x-m.x)/f,y=(u.y-m.y)/f,g=u.x-p*h,b=u.y-y*h;s({type:"path",points:[{x:u.x,y:u.y},{x:g-y*h*.5,y:b+p*h*.5},{x:g+y*h*.5,y:b-p*h*.5}],fill:c,stroke:"none"});break}case "rect":{let m=o(a.from),u=o(a.to);s({type:"rect",x:Math.min(m.x,u.x),y:Math.min(m.y,u.y),w:Math.abs(u.x-m.x),h:Math.abs(u.y-m.y),fill:a.fill??"none",hatch:a.hatch,stroke:a.stroke,opacity:a.opacity});break}case "point":{let m=o(a.at),u=a.color??"#334155",c=a.radius??d.annotationRadius,h=a.shape??"circle";h==="circle"?s({type:"circle",cx:m.x,cy:m.y,r:c,fill:u}):h==="square"?s({type:"rect",x:m.x-c,y:m.y-c,w:c*2,h:c*2,fill:u}):(s({type:"line",x1:m.x-c,y1:m.y-c,x2:m.x+c,y2:m.y+c,stroke:u,strokeWidth:1.5}),s({type:"line",x1:m.x-c,y1:m.y+c,x2:m.x+c,y2:m.y-c,stroke:u,strokeWidth:1.5}));break}case "label":{let m=o(a.at);s({type:"text",content:a.text,x:m.x+(a.dx??0),y:m.y+(a.dy??0),anchor:a.anchor??qe(m.x+(a.dx??0),a.text,i),fontSize:d.annotationFontSize,fill:a.color??d.annotationColor,rotate:a.rotate});break}}if(a.id&&l.length>0){let m=Q(a.id);r.push({type:"group",cssClass:`annotation annotation--${m}`,commands:l});}else r.push(...l);}return r}function qe(i,e,t){let{metrics:n,timeScale:r}=t;if(!n)return "middle";let[o,a]=r.range(),l=n(e,d.annotationFontSize)/2;return i-l<o?"start":i+l>a?"end":"middle"}var ee=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}})}};var te=class{#e;constructor(){this.#e=[];}add(e){this.#e.push(e);}clear(){this.#e=[];}isInside(e,t){return this.#e.length===0?true:this.#e.some(n=>e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(n=>`<rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" />`).join(`
24
+ `.trim()}var p=new Proxy({},{get:(i,e)=>M()[e],has:(i,e)=>e in M(),ownKeys:()=>Reflect.ownKeys(M()),getOwnPropertyDescriptor:(i,e)=>Reflect.getOwnPropertyDescriptor(M(),e)});var W=class i{#e=[];get commands(){return [...this.#e]}get length(){return this.#e.length}line(e){return this.#e.push({type:"line",...e}),this}path(e){return this.#e.push({type:"path",...e}),this}rect(e){return this.#e.push({type:"rect",...e}),this}circle(e){return this.#e.push({type:"circle",...e}),this}text(e){return this.#e.push({type:"text",...e}),this}gap(e){return this.#e.push({type:"gap",...e}),this}push(...e){return this.#e.push(...e),this}group(e,t){let n=new i;return t(n),n.length===0?this:(this.#e.push({type:"group",...e,commands:n.commands}),this)}toGroup(e={}){return {type:"group",...e,commands:this.commands}}};var Ie="#ffffff",Be="#cccccc",He=6,Ee=.85,L=12,G=8,j=20,Ve=11,N=18,Q=(i,e)=>e(i,Ve);function Se(i,e,t){let n=l=>L+G+Q(l.name,e);if(t===void 0){let l=i.reduce((s,m)=>s+n(m)+N,0)-N;return [{items:i,breite:Math.max(0,l)}]}let r=[],o=[],a=0;for(let l of i){let s=n(l),m=o.length===0?s:a+N+s;o.length>0&&m>t?(r.push({items:o,breite:a}),o=[l],a=s):(o=[...o,l],a=m);}return o.length>0&&r.push({items:o,breite:a}),r}function ke(i,e="vertical",t=J,n){if(e==="horizontal"){let o=Se(i,t,n);return {width:o.reduce((a,l)=>Math.max(a,l.breite),0),height:o.length*j}}let r=0;for(let o of i)r=Math.max(r,Q(o.name,t));return {width:L+G+r,height:i.length*j}}function ze(i){let{items:e,x:t,y:n,orientation:r="vertical",metrics:o=J,maxBreite:a,box:l}=i,s=new W;if(l&&e.length>0){let c=ke(e,r,o,a),f=((r==="horizontal"?c.height/j:e.length)-1)*j+L,d=l.padding??He,g=l.stroke??Be;s.rect({x:t-d,y:n-d,w:c.width+2*d,h:f+2*d,fill:l.fill??Ie,...g==="none"?{}:{stroke:g,strokeWidth:l.strokeWidth??1},opacity:l.opacity??Ee});}let m=r==="horizontal"?Se(e,o,a):e.map(c=>({items:[c],breite:0})),u=new Map;return m.forEach((c,h)=>{let f=t;for(let d of c.items)u.set(d,{x:f,y:n+h*j}),f+=L+G+Q(d.name,o)+N;}),e.forEach(c=>{let h=u.get(c)??{x:t,y:n},f=h.x,d=h.y;s.rect({x:f,y:d,w:L,h:L,fill:c.color,stroke:p.legendStroke,strokeWidth:1}).text({content:c.name,x:f+L+G,y:d+L-2,fontSize:p.legendFont,fill:p.legendText});}),s.toGroup({cssClass:"chart-legend"})}function Ne(i){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=p.gridStroke,strokeWidth:a=p.gridStrokeWidth,dashed:l=false,opacity:s=p.gridOpacity}=i,m=[];if(t)for(let u of t)m.push({type:"line",x1:n[0],y1:u,x2:n[1],y2:u,stroke:o,strokeWidth:a,dashed:l,opacity:s});if(e)for(let u of e)m.push({type:"line",x1:u,y1:r[0],x2:u,y2:r[1],stroke:o,strokeWidth:a,dashed:l,opacity:s});return m}var ve=new Map;function Ge(i,e){return `${i}|${JSON.stringify(e??{})}`}function O(i,e){let t=Ge(i,e),n=ve.get(t);return n||(n=new Intl.DateTimeFormat(i,e),ve.set(t,n)),n}var _=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,r]=this.#e,[o,a]=this.#t;return r===n?o:o+(t-n)/(r-n)*(a-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]}},T=[{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}],I=class{#e;#t;#n;constructor(e){this.#e=new _({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(),a=o-r;if(a<=0)return {interval:T[0].ms};let l=a/e,s=T[0].ms;for(let c of T)if(c.ms>=l){s=c.ms;break}let m=s,u=Math.round(a/m);for(;u>n&&m<T[T.length-1].ms;){let c=T.findIndex(h=>h.ms===m);m=T[Math.min(c+1,T.length-1)].ms,u=Math.round(a/m);}for(;u<t&&m>T[0].ms;){let c=T.findIndex(h=>h.ms===m);m=T[Math.max(c-1,0)].ms,u=Math.round(a/m);}return {interval:m}}ticks(e){let t=e?.minTicks??5,n=e?.maxTicks??12,{interval:r}=this.tickInterval((t+n)/2,t,n),[o,a]=this.#e.domain(),l=[],s=Math.ceil(o/r)*r;for(let m=s;m<=a;m+=r)l.push(m);return l}format(e,t){let n=this.#n?{...t,timeZone:this.#n}:t;return O(this.#t,n).format(new Date(e))}},B=class{#e;#t;#n;#r;constructor(e){this.#e=[...e.domain],this.#t=[...e.range],this.#n=e.paddingInner??.1,this.#r=e.paddingOuter??.05;}get step(){let[e,t]=this.#t,n=this.#e.length;return n<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/n+Math.abs(t-e)*this.#n*2/n}get bandwidth(){let[e,t]=this.#t,n=this.#e.length;if(n<=1)return Math.abs(t-e)*(1-this.#r*2);let r=this.#r*2*Math.abs(t-e);return (Math.abs(t-e)-r)/n*(1-this.#n)}map(e){let t=this.#e.findIndex(c=>String(c)===String(e));if(t===-1)return this.#t[0];let[n,r]=this.#t,o=this.#e.length;if(o<=1)return (n+r)/2;let a=this.#r*2*Math.abs(r-n),l=Math.abs(r-n)-a,s=r>=n?1:-1,m=l/o;return n+this.#r*Math.abs(r-n)*s+t*m}invert(e){let t=0,n=1/0;for(let r=0;r<this.#e.length;r++){let o=this.map(this.#e[r]),a=Math.abs(e-o);a<n&&(n=a,t=r);}return this.#e[t]}domain(){return this.#e.length===0?["",""]:[this.#e[0],this.#e[this.#e.length-1]]}range(){return [...this.#t]}positions(){let e=new Map;for(let t of this.#e)e.set(t,this.map(t));return e}};function Xe(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function Ze(i){let{thresholds:e,valueScale:t,xRange:n}=i,[r,o]=n,[a,l]=t.range(),s=Math.min(a,l),m=Math.max(a,l),u=[],c=[];for(let h of e){let f=h.color??p.thresholdColor,d=t.map(h.value);h.fill==="above"?u.push({type:"rect",x:r,y:s,w:o-r,h:Math.max(0,d-s),fill:f,hatch:h.fillHatch,opacity:h.fillOpacity??.12,id:h.id?`${h.id}-fill`:void 0}):h.fill==="below"&&u.push({type:"rect",x:r,y:d,w:o-r,h:Math.max(0,m-d),fill:f,hatch:h.fillHatch,opacity:h.fillOpacity??.12,id:h.id?`${h.id}-fill`:void 0});let g=h.line??p.thresholdLine;if(g!=="none"){let C=Xe(g),k={type:"line",x1:r,y1:d,x2:o,y2:d,stroke:f,strokeWidth:1,...C,id:h.id?`${h.id}-line`:void 0};h.shadowColor&&(k.shadowColor=h.shadowColor,k.shadowBlur=h.shadowBlur??4,k.shadowOffsetX=h.shadowOffsetX??0,k.shadowOffsetY=h.shadowOffsetY??2),u.push(k);}let[y,b]=t.domain();if(h.value>=Math.min(y,b)&&h.value<=Math.max(y,b)&&h.label!==void 0&&h.label!==null&&h.label!==false){let C=typeof h.label=="object"?h.label:void 0,k=typeof h.label=="string"?h.label:C?.text??h.name,V=C?.position??"right",pe=qe(k,V,r,o,d,f,C);c.push({...pe,y:Ue(pe.y,Math.min(a,l),Math.max(a,l),p.thresholdFontSize),id:h.id?`${h.id}-label`:void 0});}}return {inside:u,labels:c}}function Ye(i){let e=Ze(i);return [...e.inside,...e.labels]}function Ue(i,e,t,n){return Math.max(e+n,Math.min(t-n/2,i))}function qe(i,e,t,n,r,o,a){let l=(t+n)/2,s={type:"text",content:i,fontSize:p.thresholdFontSize,fill:o},m=a?{...a.rotate!==void 0&&{rotate:a.rotate},...a.textBaseline!==void 0&&{textBaseline:a.textBaseline}}:{};switch(e){case "left":return {...s,...m,x:t+4,y:r-4,anchor:"start"};case "above":return {...s,...m,x:l,y:r-6,anchor:"middle"};case "below":return {...s,...m,x:l,y:r+14,anchor:"middle"};case "center":return {...s,...m,x:l,y:r-4,anchor:"middle"};case "outside-left":return {...s,...m,x:t-6,y:r+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...s,...m,x:n+6,y:r+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...s,...m,x:n-4,y:r-4,anchor:"end"}}}function Te(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 X(i){let{ranges:e,timeScale:t,yRange:n,height:r}=i,[o,a]=n,l=[],[s,m]=t.range(),u=Math.min(s,m),c=Math.max(s,m),h=f=>Math.max(u,Math.min(c,f));for(let f of e){let d=h(t.map(f.startTime)),g=h(t.map(f.endTime));if(f.fill!==void 0&&l.push({type:"rect",x:d,y:o,w:g-d,h:a-o,fill:f.fill,hatch:f.hatch,opacity:f.opacity}),f.edges)for(let y of [d,g])l.push({type:"line",x1:y,y1:o,x2:y,y2:a,stroke:f.edges.stroke,strokeWidth:f.edges.strokeWidth,dash:"dashed"});f.label&&l.push({type:"text",content:f.label,x:(d+g)/2,y:Te(f.labelPosition??"middle",o,a,r),anchor:"middle",fontSize:f.fontSize,fill:f.labelColor,rotate:f.rotate});}return l}function Ke(i){let{gaps:e,timeScale:t,yRange:n,height:r,fill:o=p.gapFill,hatch:a,fillOpacity:l=p.gapFillOpacity??.15,stroke:s=p.gapStroke,strokeWidth:m=p.gapStrokeWidth,dashed:u=true,fontSize:c=p.gapFontSize,fontFill:h=p.gapFontColor,labelBaseline:f="middle",labelRotate:d}=i;return X({timeScale:t,yRange:n,height:r,ranges:e.map(g=>{let y=g.style??"dashed_border",b=y==="filled"||y==="dashed_border",S=y==="dashed_border"&&u!==false;return {startTime:g.startTime,endTime:g.endTime,...b&&{fill:g.fill??o,hatch:g.hatch??a,opacity:g.fillOpacity??l},...S&&{edges:{stroke:s,strokeWidth:m}},label:g.label,labelPosition:g.labelBaseline??f,labelColor:h,fontSize:c,rotate:g.rotate??d}})})}function Je(i){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=i,[o,a]=r,l=[];for(let s of e){let m=t.map(s.time),u=s.color??p.markerColor,c=s.pointStyle??(s.value!==void 0?"circle":"none"),h=s.lineStyle??"full";if(s.value!==void 0){let f=n.map(s.value);if(h==="to-value"?l.push({type:"line",x1:m,y1:a,x2:m,y2:f,stroke:u,strokeWidth:1,dashed:true}):h==="to-top"?l.push({type:"line",x1:m,y1:o,x2:m,y2:f,stroke:u,strokeWidth:1,dashed:true}):h==="full"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:a,stroke:u,strokeWidth:1}),c!=="none"&&K(l,void 0,c,m,f,p.markerSize,u,u,1.5),s.label){let d=h==="to-value"?f-10:o-6;l.push({type:"text",content:s.label,x:m,y:d,anchor:"middle",fontSize:p.markerFontSize,fill:u});}}else h!=="none"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:a,stroke:u,strokeWidth:1}),s.label&&l.push({type:"text",content:s.label,x:m,y:o-6,anchor:"middle",fontSize:p.markerFontSize,fill:u});}return l}function Qe(i){let{highlights:e,timeScale:t,yRange:n,height:r}=i;return X({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 ee(i){return i&&i.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function et(i){let{annotations:e,timeScale:t,valueScales:n}=i,r=[],o=a=>{let l=n.get(a.axis??0)??n.values().next().value;return {x:t.map(a.time),y:l?l.map(a.value):0}};for(let a of e){let l=[],s=m=>l.push(m);switch(a.type){case "line":{let m=o(a.from),u=o(a.to);s({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:a.color??p.annotationColor,strokeWidth:a.width??p.annotationWidth,dash:a.dash});break}case "arrow":{let m=o(a.from),u=o(a.to),c=a.color??p.annotationColor,h=a.headSize??p.annotationHead;s({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:c,strokeWidth:a.width??p.annotationWidth});let f=Math.hypot(u.x-m.x,u.y-m.y)||1,d=(u.x-m.x)/f,g=(u.y-m.y)/f,y=u.x-d*h,b=u.y-g*h;s({type:"path",points:[{x:u.x,y:u.y},{x:y-g*h*.5,y:b+d*h*.5},{x:y+g*h*.5,y:b-d*h*.5}],fill:c,stroke:"none"});break}case "rect":{let m=o(a.from),u=o(a.to);s({type:"rect",x:Math.min(m.x,u.x),y:Math.min(m.y,u.y),w:Math.abs(u.x-m.x),h:Math.abs(u.y-m.y),fill:a.fill??"none",hatch:a.hatch,stroke:a.stroke,opacity:a.opacity});break}case "point":{let m=o(a.at),u=a.color??"#334155",c=a.radius??p.annotationRadius,h=a.shape??"circle";h==="circle"?s({type:"circle",cx:m.x,cy:m.y,r:c,fill:u}):h==="square"?s({type:"rect",x:m.x-c,y:m.y-c,w:c*2,h:c*2,fill:u}):(s({type:"line",x1:m.x-c,y1:m.y-c,x2:m.x+c,y2:m.y+c,stroke:u,strokeWidth:1.5}),s({type:"line",x1:m.x-c,y1:m.y+c,x2:m.x+c,y2:m.y-c,stroke:u,strokeWidth:1.5}));break}case "label":{let m=o(a.at);s({type:"text",content:a.text,x:m.x+(a.dx??0),y:m.y+(a.dy??0),anchor:a.anchor??tt(m.x+(a.dx??0),a.text,i),fontSize:p.annotationFontSize,fill:a.color??p.annotationColor,rotate:a.rotate});break}}if(a.id&&l.length>0){let m=ee(a.id);r.push({type:"group",cssClass:`annotation annotation--${m}`,commands:l});}else r.push(...l);}return r}function tt(i,e,t){let{metrics:n,timeScale:r}=t;if(!n)return "middle";let[o,a]=r.range(),l=n(e,p.annotationFontSize)/2;return i-l<o?"start":i+l>a?"end":"middle"}var te=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}})}};var ne=class{#e;constructor(){this.#e=[];}add(e){this.#e.push(e);}clear(){this.#e=[];}isInside(e,t){return this.#e.length===0?true:this.#e.some(n=>e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(n=>`<rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" />`).join(`
25
25
  `);return `<clipPath id="${e}">
26
26
  ${t}
27
- </clipPath>`}get regions(){return [...this.#e]}};function G(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 a=1;a<=e;a++)t.push(r+(o-r)*a/(e+1));}return t}var O={axisColor:d.axisColor,tickColor:d.tickColor,textColor:d.textColor,textSize:d.textSize},H=class{#e;#t;constructor(e){this.#e=new j({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??O).axisColor}get tickColor(){return (this.#t.colors??O).tickColor}get textColor(){return (this.#t.colors??O).textColor}get textSize(){return (this.#t.colors??O).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??O,n=this.#t.y??0,r=[],[o,a]=this.#e.range();r.push({type:"line",x1:o,y1:n,x2:a,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let l of this.generateMinorTicks())r.push({type:"line",x1:l,y1:n,x2:l,y2:n+3,stroke:t.tickColor,strokeWidth:t.axisWidth});for(let l of e)r.push({type:"line",x1:l.x,y1:n,x2:l.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:l.label,x:this.#n(l.x,l.label,t.textSize),y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}generateMinorTicks(){return G(this.generateTicks().map(e=>e.x),this.#t.minorTicks??0)}#n(e,t,n){let r=this.#t.gesamtbreite,o=this.#t.metrics;if(r===void 0||o===void 0)return e;let a=o(t,n)/2;return Math.max(a+2,Math.min(r-a-2,e))}};var $={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function ve(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 Ke(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 ne=class{#e;#t;constructor(e){this.#e=new _({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??$).axisColor}get tickColor(){return (this.#t.colors??$).tickColor}get textColor(){return (this.#t.colors??$).textColor}get textSize(){return (this.#t.colors??$).textSize}generateTicks(){let e=this.#t.tickValues;if(e&&e.length>0){let y=this.#t.format??ve;return e.map(g=>({value:g,position:this.#e.map(g),label:y(g)}))}let t=this.#t.format??ve,n=this.#t.ticks&&this.#t.ticks>0?this.#t.ticks:6,[r,o]=this.#e.domain(),a=Math.min(r,o),l=Math.max(r,o),s=l-a;if(s===0)return [{value:r,position:this.#e.map(r),label:t(r)}];let m=s/n,u=Math.pow(10,Math.floor(Math.log10(m))),c=m/u,h;if(c<=1.5?h=u:c<=3?h=2*u:c<=7?h=5*u:h=10*u,h<=0||!Number.isFinite(h))return [{value:r,position:this.#e.map(r),label:t(r)}];let f=[],p=Math.ceil(a/h)*h;for(let y=p;y<=l;y+=h)f.push({value:y,position:this.#e.map(y),label:t(y)});return f}generateMinorTicks(){return G(this.generateTicks().map(e=>e.position),this.#t.minorTicks??0)}render(){let e=this.generateTicks(),t=this.#t.colors??$,n=this.#t.x??0,r=this.#t.orientation??"vertical",o=this.#t.position??"left",a=this.#t.suppressLabelsNear??[],l=this.#t.suppressTolerancePx??8,s=c=>a.some(h=>Math.abs(h-c)<=l),m=[];if(r==="vertical"){let[c,h]=this.#e.range();m.push({type:"line",x1:n,y1:c,x2:n,y2:h,stroke:t.axisColor,strokeWidth:t.axisWidth});let f=Ke(e);e.forEach((p,y)=>{let g=s(p.position),b=f[y]?{opacity:0}:{};o==="left"?(m.push({type:"line",x1:n-4,y1:p.position,x2:n,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:this.#n(n-8,p.label,"end"),y:p.position+4,anchor:"end",fontSize:t.textSize,fill:t.textColor,...b})):(m.push({type:"line",x1:n,y1:p.position,x2:n+4,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:this.#n(n+8,p.label,"start"),y:p.position+4,anchor:"start",fontSize:t.textSize,fill:t.textColor,...b}));});}else {let[c,h]=this.#e.range();m.push({type:"line",x1:c,y1:n,x2:h,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let f of e)m.push({type:"line",x1:f.position,y1:n,x2:f.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),m.push({type:"text",content:f.label,x:f.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}let u=(this.#t.orientation??"vertical")==="vertical";for(let c of this.generateMinorTicks())m.push(u?{type:"line",x1:o==="right"?n:n-2,y1:c,x2:o==="right"?n+2:n,y2:c,stroke:t.tickColor,strokeWidth:t.axisWidth}:{type:"line",x1:c,y1:n,x2:c,y2:n+3,stroke:t.tickColor,strokeWidth:t.axisWidth});return m}#n(e,t,n){let r=this.#t.gesamtbreite,o=this.#t.metrics;if(r===void 0||o===void 0)return e;let a=o(t,(this.#t.colors??$).textSize);return n==="end"?Math.max(a+2,Math.min(r-2,e)):Math.min(r-a-2,Math.max(2,e))}};var re=class i{#e;#t;#n;#r;#a;#o;#i;constructor(e){this.#e=[...e.data].sort((t,n)=>t.time-n.time),this.#t=e.windowSize,this.#n=e.type??"simple",this.#r=e.timeScale,this.#a=e.valueScale,this.#o=e.stroke??"#e53e3e",this.#i=e.strokeWidth??2;}static simple(e,t){let n=[...e].filter(o=>o.value!==null).sort((o,a)=>o.time-a.time),r=[];for(let o=0;o<n.length;o++){let a=Math.max(0,o-t+1),l=n.slice(a,o+1),s=l.reduce((m,u)=>m+u.value,0)/l.length;r.push({time:n[o].time,value:s});}return r}static exponential(e,t){let n=[...e].filter(l=>l.value!==null).sort((l,s)=>l.time-s.time);if(n.length===0)return [];let r=2/(t+1),o=[],a=n[0].value;o.push({time:n[0].time,value:a});for(let l=1;l<n.length;l++)a=n[l].value*r+a*(1-r),o.push({time:n[l].time,value:a});return o}points(){return (this.#n==="exponential"?i.exponential(this.#e,this.#t):i.simple(this.#e,this.#t)).map(t=>({x:this.#r.map(t.time),y:this.#a.map(t.value)}))}render(){let e=this.points();return e.length<2?e.map(t=>({type:"circle",cx:t.x,cy:t.y,r:this.#i,fill:this.#o})):[{type:"path",points:e,smoothing:true,stroke:this.#o,strokeWidth:this.#i}]}};var oe=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((n,r)=>n-r).map(String);this.#t=t,this.#e=new I({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:n=true,gapValues:r}=this.#n,o=new Set(r??[]);return this.#t.map((a,l)=>{let s=Number(a),m=t?e[s]??String(s):String(s),u=this.#e.map(s),c=n?d.palette[l%d.palette.length]:void 0;return {value:s,label:m,y:u,color:c,isGap:o.has(s)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return d.palette[t%d.palette.length]}render(){let e=this.generateTicks(),t=this.#n.x??0,n=[];for(let r of e)r.isGap||n.push({type:"text",content:r.label,x:t,y:r.y+4,anchor:"end",fontSize:d.textSize,fill:r.color??d.textColor});return n}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var C=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 ie=class extends C{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale;return this.data.filter(t=>t.value!==null).map(t=>({x:this.timeScale.map(t.time),y:e.map(t.value),time:t.time})).sort((t,n)=>t.x-n.x)}render(){let e=this.#e,t={smoothing:e.smoothing??false,smoothingType:e.smoothingType,stroke:e.stroke??d.stroke,strokeWidth:e.strokeWidth??d.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??d.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},n=e.pointThreshold??d.pointThreshold,r=e.gapThreshold??d.gapThreshold,o=e.id,a=x.getRuns(this.data,c=>c.value===null,r),l=a.reduce((c,h)=>c+h.length,0);if(l===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},m=a.map(c=>({data:c})),u=[];if(u.push(...v(m,s,{...t,id:o?`${o}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&l<=n)for(let c of a)u.push(...R(c,s,{...t,id:o?`${o}-marker`:void 0},()=>t.stroke));return u}};var ae=class extends C{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale,t=[...this.data].filter(r=>r.value!==null).sort((r,o)=>r.time-o.time),n=[];for(let r=0;r<t.length;r++){let o=this.timeScale.map(t[r].time),a=e.map(t[r].value);r===0?n.push({x:o,y:a}):n.push({x:o,y:n[n.length-1].y},{x:o,y:a});}return n}render(){let e=x.getRuns(this.data,r=>r.value===null);if(e.length===0)return [];let t={timeScale:this.timeScale,valueScale:this.#e.valueScale},n=e.map(r=>({data:r}));return X(n,t,{stroke:this.#e.stroke??d.stroke,strokeWidth:this.#e.strokeWidth??d.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var se=class extends C{#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??d.bandFill,n=e.hatch,r=e.avgLine??false,o=e.avgLineColor??d.bandAvgLine,a=e.bandWidth??10,l=[];for(let s of this.data){if(s.min===null||s.max===null)continue;let m=this.timeScale.map(s.time),u=e.valueScale.map(s.max),c=e.valueScale.map(s.min),h=a,f=this.data.indexOf(s);if(l.push({type:"rect",x:m-h/2,y:u,w:h,h:c-u,fill:t,hatch:n,opacity:this.opacity(s.count),id:this.id?`${this.id}-slot-${f}`:void 0}),r&&s.avg!==null){let p=e.valueScale.map(s.avg);l.push({type:"line",x1:m-h/2,y1:p,x2:m+h/2,y2:p,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${f}`:void 0});}}return l}};var le=class extends C{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??d.minColor,n=e.maxColor??d.maxColor,r=e.avgColor??d.avgColor,o=e.avgDashed??true,a=e.smoothing??false,l=e.smoothingType,s=e.strokeWidth??d.strokeWidth,m=x.getRuns(this.data,p=>p.min===null||p.max===null||p.avg===null);if(m.length===0)return [];let u={timeScale:this.timeScale,valueScale:e.valueScale},c=[];m.forEach((p,y)=>{p.length<2||(e.fillToMax&&c.push(...E(p,u,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.max,getValue:g=>g.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${y}`:void 0})),e.fillToMin&&c.push(...E(p,u,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.min,getValue:g=>g.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${y}`:void 0})));});let h=m.filter(p=>p.length>=2),f=p=>h.map(y=>({data:y.map(g=>({time:g.time,value:p(g)}))}));return c.push(...v(f(p=>p.max),u,{stroke:n,strokeWidth:s,smoothing:a,smoothingType:l,id:this.id?`${this.id}-max`:void 0}),...v(f(p=>p.min),u,{stroke:t,strokeWidth:s,smoothing:a,id:this.id?`${this.id}-min`:void 0}),...v(f(p=>p.avg),u,{stroke:r,strokeWidth:s,smoothing:a,dashed:o,id:this.id?`${this.id}-avg`:void 0})),c}};var me=class extends C{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,n)=>t.value-n.value);}#n(e){return e===0?this.#e.baseColor??d.stroke:this.#t[e-1].color}render(){let e=this.#e,t=e.baseColor??d.stroke,n={stroke:t,strokeWidth:e.strokeWidth??d.strokeWidth,smoothing:e.smoothing??false,smoothingType:e.smoothingType,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??d.pointSize},r=e.gapThreshold??d.gapThreshold,o=e.pointThreshold??d.pointThreshold,a=x.getRuns(this.data,u=>u.value===null,r),l=a.reduce((u,c)=>u+c.length,0);if(l===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},m=[];for(let u of a){if(u.length<2)continue;if(e.fill){let p=e.fill.value,y=x.splitByBoundaries(u,[p],b=>b.value,x.interpolateDataPoint),g=e.valueScale.map(p);for(let b=0;b<y.length;b++){let S=y[b];if(S.data.length<2)continue;let w=S.zoneIndex>0;if(e.fill.side==="above"===w){let k=S.data.map(B=>({x:this.timeScale.map(B.time),y:e.valueScale.map(B.value)}));m.push({type:"path",cssClass:"series-fill",id:this.id?`${this.id}-fill-${b}`:void 0,points:[...k,{x:k[k.length-1].x,y:g},{x:k[0].x,y:g}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let c=this.#t.map(p=>p.value),f=x.splitByBoundaries(u,c,p=>p.value,x.interpolateDataPoint).map(p=>({data:p.data,color:this.#n(p.zoneIndex)}));m.push(...v(f,s,{...n,id:this.id?`${this.id}-line`:void 0})),n.pointStyle&&n.pointStyle!=="none"&&l<=o&&m.push(...R(u,s,{...n,id:this.id?`${this.id}-marker`:void 0},p=>{let y=t;for(let g of this.#t)p.value>=g.value&&(y=g.color);return y}));}return m}};var Je=1,ue=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:a,y:l,height:s}=this.#e,m=[];n&&m.push({type:"rect",x:a[0],y:l,w:a[1]-a[0],h:s,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let c=t.map(u.startTime),h=t.map(u.endTime);if(h<a[0]||c>a[1])continue;let f=Math.max(a[0],Math.min(a[1],c)),p=Math.max(a[0],Math.min(a[1],h)),y=Math.max(p-f,Je);f+y>a[1]&&(f=Math.max(a[0],a[1]-y));let g=f+y/2;if(m.push({type:"rect",x:f,y:l,w:y,h:s,hatch:u.hatch??r,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0,title:u.title}),u.label){let b=u.labelFontSize??10;m.push({type:"text",content:u.label,x:g,y:this.#t(u.labelBaseline,b),anchor:"middle",fontSize:b,fill:u.labelFill??"#333"});}}if(o){let u=new H({domain:t.domain(),xRange:a,y:l+s+4});m.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return m}#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}}};var ce=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:r=false,showMax:o=false,showAvg:a=true,showMedian:l=false,labelPosition:s="end",lineColor:m=d.statsLineColor,labelColor:u=d.statsLabelColor}=this.#e,c=pe.compute(e),h=[{name:"min",value:c.min,enabled:r},{name:"max",value:c.max,enabled:o},{name:"avg",value:c.avg,enabled:a},{name:"median",value:c.median,enabled:l}],f=[],[p,y]=n;for(let g of h.filter(b=>b.enabled)){let b=t.map(g.value);f.push({type:"line",x1:p,y1:b,x2:y,y2:b,stroke:m,strokeWidth:1});let S=`${g.name}: ${g.value.toFixed(1)}`;(s==="start"||s==="both")&&f.push({type:"text",content:S,x:p+4,y:b-4,anchor:"start",fontSize:d.statFontSize,fill:u}),(s==="end"||s==="both")&&f.push({type:"text",content:S,x:y-4,y:b-4,anchor:"end",fontSize:d.statFontSize,fill:u}),s==="center"&&f.push({type:"text",content:S,x:(p+y)/2,y:b-4,anchor:"middle",fontSize:d.statFontSize,fill:u});}return f}};var P=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#t=e?.fallbackLocales??["en-US"],this.#n=e?.autoFormat??true;}format(e,t,n){try{let r=this.#n&&n?this.#r(e,n,t):t;return W(this.#e,r).format(new Date(e))}catch{for(let r of this.#t)try{return W(r,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let n=this.format(e),r=this.format(t);return `${n} \u2014 ${r}`}#r(e,t,n){let r=Math.abs(e-t),o=864e5,a=36e5,l=6e4,s={};return r<l?(s.second="2-digit",s.minute="2-digit",s.hour="2-digit"):r<a?(s.minute="2-digit",s.hour="2-digit"):r<o?(s.hour="2-digit",s.minute="2-digit"):r<7*o?(s.weekday="short",s.day="numeric"):r<365*o?(s.month="short",s.day="numeric"):(s.month="short",s.year="numeric"),{...n,...s}}};var F=class i{#e;#t;_compact;#n;constructor(e){this.#e=e?.unit??"",this.#t=e?.decimals??1,this._compact=e?.compact??false,this.#n=e?.custom;}format(e){if(this.#n)return this.#n(e);let t;return this._compact&&Math.abs(e)>=1e6?t=`${(e/1e6).toFixed(this.#t)}M`:this._compact&&Math.abs(e)>=1e3?t=`${(e/1e3).toFixed(this.#t)}k`:t=e.toFixed(this.#t),this.#e?`${t}${this.#e}`:t}formatRange(e,t){return `${this.format(e)} \u2014 ${this.format(t)}`}static unit(e,t=1){return new i({unit:e,decimals:t})}static temperature(e="\xB0C"){return new i({unit:e,decimals:1})}static percentage(){return new i({unit:"%",decimals:0})}};var A=class i{#e;#t;#n;constructor(e){this.#e=e?.map??{},this.#t=e?.fallback??(t=>String(t)),this.#n=e?.showValue??false;}format(e){let t=this.#e[e]??this.#t(e);return this.#n?`(${e}) ${t}`:t}has(e){return e in this.#e}labels(){return Object.values(this.#e)}values(){return Object.keys(this.#e).map(Number)}static fromLabels(e,t=false){let n={};return e.forEach((r,o)=>{n[o]=r;}),new i({map:n,showValue:t})}};var Qe={time:new P,value:new F,enum:new A};function he(i,e){let t=M();return {color:i.color??t.stroke,width:i.width??t.strokeWidth,style:i.style??"solid",smoothing:i.smoothing??false,smoothingType:i.smoothingType,shape:i.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:i.gapThreshold??t.gapThreshold,opacity:i.opacity??1}}function Te(i){let e=i.style?.line;return e===false?[]:e===void 0?[he({},i)]:Array.isArray(e)?e.map(t=>he(t,i)):[he(e,i)]}function Ce(i){let e=i.style?.markers;if(!e?.type||e.type==="none")return;let t=M(),r=(i.style?.line&&!Array.isArray(i.style.line)?i.style.line.color:void 0)??t.stroke;return {type:e.type,size:e.size??t.pointSize,stroke:e.stroke??r,fill:e.fill??"#ffffff",strokeWidth:e.strokeWidth??1,threshold:e.threshold}}function we(i){let e=i.style?.shadow;if(!(!e?.color||e.color==="transparent"||e.color==="none"))return {color:e.color,blur:e.blur??4,offsetX:e.offsetX??0,offsetY:e.offsetY??0}}function Me(i){return i.style?.gap}function Le(i){return i.style?.fill}function et(i){return {lines:Te(i),fill:Le(i),markers:Ce(i),shadow:we(i),gap:Me(i),id:i.style?.id??i.id}}/*!
27
+ </clipPath>`}get regions(){return [...this.#e]}};function Z(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 a=1;a<=e;a++)t.push(r+(o-r)*a/(e+1));}return t}var H={axisColor:p.axisColor,tickColor:p.tickColor,textColor:p.textColor,textSize:p.textSize},E=class{#e;#t;constructor(e){this.#e=new I({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??H).axisColor}get tickColor(){return (this.#t.colors??H).tickColor}get textColor(){return (this.#t.colors??H).textColor}get textSize(){return (this.#t.colors??H).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??H,n=this.#t.y??0,r=[],[o,a]=this.#e.range();r.push({type:"line",x1:o,y1:n,x2:a,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let l of this.generateMinorTicks())r.push({type:"line",x1:l,y1:n,x2:l,y2:n+3,stroke:t.tickColor,strokeWidth:t.axisWidth});for(let l of e)r.push({type:"line",x1:l.x,y1:n,x2:l.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:l.label,x:this.#n(l.x,l.label,t.textSize),y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}generateMinorTicks(){return Z(this.generateTicks().map(e=>e.x),this.#t.minorTicks??0)}#n(e,t,n){let r=this.#t.gesamtbreite,o=this.#t.metrics;if(r===void 0||o===void 0)return e;let a=o(t,n)/2;return Math.max(a+2,Math.min(r-a-2,e))}};var P={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function we(i){return Math.abs(i)>=1e6?`${(i/1e6).toFixed(1)}M`:Math.abs(i)>=1e3?`${(i/1e3).toFixed(1)}k`:Number.isInteger(i)?String(i):i.toFixed(1)}function nt(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 re=class{#e;#t;constructor(e){this.#e=new _({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??P).axisColor}get tickColor(){return (this.#t.colors??P).tickColor}get textColor(){return (this.#t.colors??P).textColor}get textSize(){return (this.#t.colors??P).textSize}generateTicks(){let e=this.#t.tickValues;if(e&&e.length>0){let g=this.#t.format??we;return e.map(y=>({value:y,position:this.#e.map(y),label:g(y)}))}let t=this.#t.format??we,n=this.#t.ticks&&this.#t.ticks>0?this.#t.ticks:6,[r,o]=this.#e.domain(),a=Math.min(r,o),l=Math.max(r,o),s=l-a;if(s===0)return [{value:r,position:this.#e.map(r),label:t(r)}];let m=s/n,u=Math.pow(10,Math.floor(Math.log10(m))),c=m/u,h;if(c<=1.5?h=u:c<=3?h=2*u:c<=7?h=5*u:h=10*u,h<=0||!Number.isFinite(h))return [{value:r,position:this.#e.map(r),label:t(r)}];let f=[],d=Math.ceil(a/h)*h;for(let g=d;g<=l;g+=h)f.push({value:g,position:this.#e.map(g),label:t(g)});return f}generateMinorTicks(){return Z(this.generateTicks().map(e=>e.position),this.#t.minorTicks??0)}render(){let e=this.generateTicks(),t=this.#t.colors??P,n=this.#t.x??0,r=this.#t.orientation??"vertical",o=this.#t.position??"left",a=this.#t.suppressLabelsNear??[],l=this.#t.suppressTolerancePx??8,s=c=>a.some(h=>Math.abs(h-c)<=l),m=[];if(r==="vertical"){let[c,h]=this.#e.range();m.push({type:"line",x1:n,y1:c,x2:n,y2:h,stroke:t.axisColor,strokeWidth:t.axisWidth});let f=nt(e);e.forEach((d,g)=>{let y=s(d.position),b=f[g]?{opacity:0}:{};o==="left"?(m.push({type:"line",x1:n-4,y1:d.position,x2:n,y2:d.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),y||m.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,...b})):(m.push({type:"line",x1:n,y1:d.position,x2:n+4,y2:d.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),y||m.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,...b}));});}else {let[c,h]=this.#e.range();m.push({type:"line",x1:c,y1:n,x2:h,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let f of e)m.push({type:"line",x1:f.position,y1:n,x2:f.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),m.push({type:"text",content:f.label,x:f.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}let u=(this.#t.orientation??"vertical")==="vertical";for(let c of this.generateMinorTicks())m.push(u?{type:"line",x1:o==="right"?n:n-2,y1:c,x2:o==="right"?n+2:n,y2:c,stroke:t.tickColor,strokeWidth:t.axisWidth}:{type:"line",x1:c,y1:n,x2:c,y2:n+3,stroke:t.tickColor,strokeWidth:t.axisWidth});return m}#n(e,t,n){let r=this.#t.gesamtbreite,o=this.#t.metrics;if(r===void 0||o===void 0)return e;let a=o(t,(this.#t.colors??P).textSize);return n==="end"?Math.max(a+2,Math.min(r-2,e)):Math.min(r-a-2,Math.max(2,e))}};var oe=class i{#e;#t;#n;#r;#a;#o;#i;constructor(e){this.#e=[...e.data].sort((t,n)=>t.time-n.time),this.#t=e.windowSize,this.#n=e.type??"simple",this.#r=e.timeScale,this.#a=e.valueScale,this.#o=e.stroke??"#e53e3e",this.#i=e.strokeWidth??2;}static simple(e,t){let n=[...e].filter(o=>o.value!==null).sort((o,a)=>o.time-a.time),r=[];for(let o=0;o<n.length;o++){let a=Math.max(0,o-t+1),l=n.slice(a,o+1),s=l.reduce((m,u)=>m+u.value,0)/l.length;r.push({time:n[o].time,value:s});}return r}static exponential(e,t){let n=[...e].filter(l=>l.value!==null).sort((l,s)=>l.time-s.time);if(n.length===0)return [];let r=2/(t+1),o=[],a=n[0].value;o.push({time:n[0].time,value:a});for(let l=1;l<n.length;l++)a=n[l].value*r+a*(1-r),o.push({time:n[l].time,value:a});return o}points(){return (this.#n==="exponential"?i.exponential(this.#e,this.#t):i.simple(this.#e,this.#t)).map(t=>({x:this.#r.map(t.time),y:this.#a.map(t.value)}))}render(){let e=this.points();return e.length<2?e.map(t=>({type:"circle",cx:t.x,cy:t.y,r:this.#i,fill:this.#o})):[{type:"path",points:e,smoothing:true,stroke:this.#o,strokeWidth:this.#i}]}};var ie=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((n,r)=>n-r).map(String);this.#t=t,this.#e=new B({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:n=true,gapValues:r}=this.#n,o=new Set(r??[]);return this.#t.map((a,l)=>{let s=Number(a),m=t?e[s]??String(s):String(s),u=this.#e.map(s),c=n?p.palette[l%p.palette.length]:void 0;return {value:s,label:m,y:u,color:c,isGap:o.has(s)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return p.palette[t%p.palette.length]}render(){let e=this.generateTicks(),t=this.#n.x??0,n=[];for(let r of e)r.isGap||n.push({type:"text",content:r.label,x:t,y:r.y+4,anchor:"end",fontSize:p.textSize,fill:r.color??p.textColor});return n}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var w=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 ae=class extends w{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale;return this.data.filter(t=>t.value!==null).map(t=>({x:this.timeScale.map(t.time),y:e.map(t.value),time:t.time})).sort((t,n)=>t.x-n.x)}render(){let e=this.#e,t={smoothing:e.smoothing??false,smoothingType:e.smoothingType,stroke:e.stroke??p.stroke,strokeWidth:e.strokeWidth??p.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??p.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},n=e.pointThreshold??p.pointThreshold,r=e.gapThreshold??p.gapThreshold,o=e.id,a=x.getRuns(this.data,c=>c.value===null,r),l=a.reduce((c,h)=>c+h.length,0);if(l===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},m=a.map(c=>({data:c})),u=[];if(u.push(...v(m,s,{...t,id:o?`${o}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&l<=n)for(let c of a)u.push(...R(c,s,{...t,id:o?`${o}-marker`:void 0},()=>t.stroke));return u}};var se=class extends w{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale,t=[...this.data].filter(r=>r.value!==null).sort((r,o)=>r.time-o.time),n=[];for(let r=0;r<t.length;r++){let o=this.timeScale.map(t[r].time),a=e.map(t[r].value);r===0?n.push({x:o,y:a}):n.push({x:o,y:n[n.length-1].y},{x:o,y:a});}return n}render(){let e=x.getRuns(this.data,r=>r.value===null);if(e.length===0)return [];let t={timeScale:this.timeScale,valueScale:this.#e.valueScale},n=e.map(r=>({data:r}));return q(n,t,{stroke:this.#e.stroke??p.stroke,strokeWidth:this.#e.strokeWidth??p.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var le=class extends w{#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,a=e.bandWidth??10,l=[];for(let s of this.data){if(s.min===null||s.max===null)continue;let m=this.timeScale.map(s.time),u=e.valueScale.map(s.max),c=e.valueScale.map(s.min),h=a,f=this.data.indexOf(s);if(l.push({type:"rect",x:m-h/2,y:u,w:h,h:c-u,fill:t,hatch:n,opacity:this.opacity(s.count),id:this.id?`${this.id}-slot-${f}`:void 0}),r&&s.avg!==null){let d=e.valueScale.map(s.avg);l.push({type:"line",x1:m-h/2,y1:d,x2:m+h/2,y2:d,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${f}`:void 0});}}return l}};var me=class extends w{#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,a=e.smoothing??false,l=e.smoothingType,s=e.strokeWidth??p.strokeWidth,m=x.getRuns(this.data,d=>d.min===null||d.max===null||d.avg===null);if(m.length===0)return [];let u={timeScale:this.timeScale,valueScale:e.valueScale},c=[];m.forEach((d,g)=>{d.length<2||(e.fillToMax&&c.push(...z(d,u,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.max,getValue:y=>y.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${g}`:void 0})),e.fillToMin&&c.push(...z(d,u,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.min,getValue:y=>y.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${g}`:void 0})));});let h=m.filter(d=>d.length>=2),f=d=>h.map(g=>({data:g.map(y=>({time:y.time,value:d(y)}))}));return c.push(...v(f(d=>d.max),u,{stroke:n,strokeWidth:s,smoothing:a,smoothingType:l,id:this.id?`${this.id}-max`:void 0}),...v(f(d=>d.min),u,{stroke:t,strokeWidth:s,smoothing:a,id:this.id?`${this.id}-min`:void 0}),...v(f(d=>d.avg),u,{stroke:r,strokeWidth:s,smoothing:a,dashed:o,id:this.id?`${this.id}-avg`:void 0})),c}};var ue=class extends w{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,n)=>t.value-n.value);}#n(e){return e===0?this.#e.baseColor??p.stroke:this.#t[e-1].color}render(){let e=this.#e,t=e.baseColor??p.stroke,n={stroke:t,strokeWidth:e.strokeWidth??p.strokeWidth,smoothing:e.smoothing??false,smoothingType:e.smoothingType,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??p.pointSize},r=e.gapThreshold??p.gapThreshold,o=e.pointThreshold??p.pointThreshold,a=x.getRuns(this.data,u=>u.value===null,r),l=a.reduce((u,c)=>u+c.length,0);if(l===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},m=[];for(let u of a){if(u.length<2)continue;if(e.fill){let d=e.fill.value,g=x.splitByBoundaries(u,[d],b=>b.value,x.interpolateDataPoint),y=e.valueScale.map(d);for(let b=0;b<g.length;b++){let S=g[b];if(S.data.length<2)continue;let C=S.zoneIndex>0;if(e.fill.side==="above"===C){let k=S.data.map(V=>({x:this.timeScale.map(V.time),y:e.valueScale.map(V.value)}));m.push({type:"path",cssClass:"series-fill",id:this.id?`${this.id}-fill-${b}`:void 0,points:[...k,{x:k[k.length-1].x,y},{x:k[0].x,y}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let c=this.#t.map(d=>d.value),f=x.splitByBoundaries(u,c,d=>d.value,x.interpolateDataPoint).map(d=>({data:d.data,color:this.#n(d.zoneIndex)}));m.push(...v(f,s,{...n,id:this.id?`${this.id}-line`:void 0})),n.pointStyle&&n.pointStyle!=="none"&&l<=o&&m.push(...R(u,s,{...n,id:this.id?`${this.id}-marker`:void 0},d=>{let g=t;for(let y of this.#t)d.value>=y.value&&(g=y.color);return g}));}return m}};var rt=1,ce=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:a,y:l,height:s}=this.#e,m=[];n&&m.push({type:"rect",x:a[0],y:l,w:a[1]-a[0],h:s,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let c=t.map(u.startTime),h=t.map(u.endTime);if(h<a[0]||c>a[1])continue;let f=Math.max(a[0],Math.min(a[1],c)),d=Math.max(a[0],Math.min(a[1],h)),g=Math.max(d-f,rt);f+g>a[1]&&(f=Math.max(a[0],a[1]-g));let y=f+g/2;if(m.push({type:"rect",x:f,y:l,w:g,h:s,hatch:u.hatch??r,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0,title:u.title}),u.label){let b=u.labelFontSize??10;m.push({type:"text",content:u.label,x:y,y:this.#t(u.labelBaseline,b),anchor:"middle",fontSize:b,fill:u.labelFill??"#333"});}}if(o){let u=new E({domain:t.domain(),xRange:a,y:l+s+4});m.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return m}#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}}};var he=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:r=false,showMax:o=false,showAvg:a=true,showMedian:l=false,labelPosition:s="end",lineColor:m=p.statsLineColor,labelColor:u=p.statsLabelColor}=this.#e,c=fe.compute(e),h=[{name:"min",value:c.min,enabled:r},{name:"max",value:c.max,enabled:o},{name:"avg",value:c.avg,enabled:a},{name:"median",value:c.median,enabled:l}],f=[],[d,g]=n;for(let y of h.filter(b=>b.enabled)){let b=t.map(y.value);f.push({type:"line",x1:d,y1:b,x2:g,y2:b,stroke:m,strokeWidth:1});let S=`${y.name}: ${y.value.toFixed(1)}`;(s==="start"||s==="both")&&f.push({type:"text",content:S,x:d+4,y:b-4,anchor:"start",fontSize:p.statFontSize,fill:u}),(s==="end"||s==="both")&&f.push({type:"text",content:S,x:g-4,y:b-4,anchor:"end",fontSize:p.statFontSize,fill:u}),s==="center"&&f.push({type:"text",content:S,x:(d+g)/2,y:b-4,anchor:"middle",fontSize:p.statFontSize,fill:u});}return f}};var $=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#t=e?.fallbackLocales??["en-US"],this.#n=e?.autoFormat??true;}format(e,t,n){try{let r=this.#n&&n?this.#r(e,n,t):t;return O(this.#e,r).format(new Date(e))}catch{for(let r of this.#t)try{return O(r,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let n=this.format(e),r=this.format(t);return `${n} \u2014 ${r}`}#r(e,t,n){let r=Math.abs(e-t),o=864e5,a=36e5,l=6e4,s={};return r<l?(s.second="2-digit",s.minute="2-digit",s.hour="2-digit"):r<a?(s.minute="2-digit",s.hour="2-digit"):r<o?(s.hour="2-digit",s.minute="2-digit"):r<7*o?(s.weekday="short",s.day="numeric"):r<365*o?(s.month="short",s.day="numeric"):(s.month="short",s.year="numeric"),{...n,...s}}};var A=class i{#e;#t;_compact;#n;constructor(e){this.#e=e?.unit??"",this.#t=e?.decimals??1,this._compact=e?.compact??false,this.#n=e?.custom;}format(e){if(this.#n)return this.#n(e);let t;return this._compact&&Math.abs(e)>=1e6?t=`${(e/1e6).toFixed(this.#t)}M`:this._compact&&Math.abs(e)>=1e3?t=`${(e/1e3).toFixed(this.#t)}k`:t=e.toFixed(this.#t),this.#e?`${t}${this.#e}`:t}formatRange(e,t){return `${this.format(e)} \u2014 ${this.format(t)}`}static unit(e,t=1){return new i({unit:e,decimals:t})}static temperature(e="\xB0C"){return new i({unit:e,decimals:1})}static percentage(){return new i({unit:"%",decimals:0})}};var F=class i{#e;#t;#n;constructor(e){this.#e=e?.map??{},this.#t=e?.fallback??(t=>String(t)),this.#n=e?.showValue??false;}format(e){let t=this.#e[e]??this.#t(e);return this.#n?`(${e}) ${t}`:t}has(e){return e in this.#e}labels(){return Object.values(this.#e)}values(){return Object.keys(this.#e).map(Number)}static fromLabels(e,t=false){let n={};return e.forEach((r,o)=>{n[o]=r;}),new i({map:n,showValue:t})}};var ot={time:new $,value:new A,enum:new F};function de(i,e){let t=M();return {color:i.color??t.stroke,width:i.width??t.strokeWidth,style:i.style??"solid",smoothing:i.smoothing??false,smoothingType:i.smoothingType,shape:i.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:i.gapThreshold??t.gapThreshold,opacity:i.opacity??1}}function Ce(i){let e=i.style?.line;return e===false?[]:e===void 0?[de({},i)]:Array.isArray(e)?e.map(t=>de(t,i)):[de(e,i)]}function Me(i){let e=i.style?.markers;if(!e?.type||e.type==="none")return;let t=M(),r=(i.style?.line&&!Array.isArray(i.style.line)?i.style.line.color:void 0)??t.stroke;return {type:e.type,size:e.size??t.pointSize,stroke:e.stroke??r,fill:e.fill??"#ffffff",strokeWidth:e.strokeWidth??1,threshold:e.threshold}}function Le(i){let e=i.style?.shadow;if(!(!e?.color||e.color==="transparent"||e.color==="none"))return {color:e.color,blur:e.blur??4,offsetX:e.offsetX??0,offsetY:e.offsetY??0}}function De(i){return i.style?.gap}function _e(i){return i.style?.fill}function it(i){return {lines:Ce(i),fill:_e(i),markers:Me(i),shadow:Le(i),gap:De(i),id:i.style?.id??i.id}}/*!
28
28
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
29
29
  * MIT with Attribution: free use incl. commercial requires visible credit to
30
30
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
@@ -43,4 +43,4 @@ var Y=class{};var x=class{static interpolateDataPoint(i,e,t){return {time:i.time
43
43
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
44
44
  * MIT with Attribution: free use incl. commercial must have visible credit to
45
45
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
46
- */export{ue as AnnotationBandSeries,I as BandScale,se as BandSeries,te as Clip,oe as EnumAxis,A as EnumFormatter,Qe as Formatters,ee as Layout,ie as LineSeries,_ as LinearScale,le as MinMaxAvgSeries,re as MovingAvg,Y as Renderer,ce as StatsOverlay,ae as StepSeries,T as TIME_INTERVALS,H as TimeAxis,P as TimeFormatter,j as TimeScale,ne as ValueAxis,F as ValueFormatter,me as ZonedLineSeries,be as getHatch,Ie as measureLegend,Ue as renderAnnotations,$e as renderArea,Ye as renderGaps,He as renderGrid,Xe as renderHighlights,Oe as renderLegend,v as renderLine,Ze as renderMarkers,R as renderSeriesMarkers,_e as renderSplitLine,X as renderStep,ze as renderThresholds,E as renderZonedArea,Le as resolveFill,Me as resolveGap,Te as resolveLines,Ce as resolveMarkers,et as resolveSeriesStyle,we as resolveShadow,Q as slugify,d as theme,De as toStepData,Z as toStepPoints};
46
+ */export{ce as AnnotationBandSeries,B as BandScale,le as BandSeries,ne as Clip,W as CommandBuilder,ie as EnumAxis,F as EnumFormatter,ot as Formatters,te as Layout,ae as LineSeries,_ as LinearScale,me as MinMaxAvgSeries,oe as MovingAvg,Y as Renderer,he as StatsOverlay,se as StepSeries,T as TIME_INTERVALS,E as TimeAxis,$ as TimeFormatter,I as TimeScale,re as ValueAxis,A as ValueFormatter,ue as ZonedLineSeries,xe as getHatch,ke as measureLegend,et as renderAnnotations,Ae as renderArea,Ke as renderGaps,Ne as renderGrid,Qe as renderHighlights,ze as renderLegend,v as renderLine,Je as renderMarkers,R as renderSeriesMarkers,$e as renderSplitLine,q as renderStep,Ye as renderThresholds,z as renderZonedArea,_e as resolveFill,De as resolveGap,Ce as resolveLines,Me as resolveMarkers,it as resolveSeriesStyle,Le as resolveShadow,ee as slugify,p as theme,Pe as toStepData,U as toStepPoints};
@@ -1,4 +1,4 @@
1
- import { a as DrawCommand, b as LineVariant, P as PointStyleType, c as DrawGroup, M as MarkerLineStyle, T as TimeScale, L as LinearScale, S as SmoothingType, H as HatchVariant, D as DataPoint } from './scale-B3MhoTu1.js';
1
+ import { a as DrawCommand, b as LineVariant, P as PointStyleType, c as DrawGroup, M as MarkerLineStyle, G as GridLayer, A as AxisPosition, d as AnySeries, e as Threshold, H as Highlight, f as Gap, g as GapsConfig, h as Annotation, i as AnnotationBandConfig, T as TimeScale, L as LinearScale, S as SmoothingType, j as HatchVariant, D as DataPoint } from './scale-DQ-IdB6t.js';
2
2
 
3
3
  /** Output format type for the renderer (SVG string, Canvas, or nothing). */
4
4
  type RenderType = "svg" | "canvas" | "none";
@@ -285,6 +285,8 @@ interface LegendConfig {
285
285
  metrics?: TextMetrics;
286
286
  /** Hoechstbreite einer waagerechten Zeile; darueber wird umgebrochen. */
287
287
  maxBreite?: number;
288
+ /** Feld hinter der Legende -- Hintergrund und Rahmen. Ohne Angabe keines. */
289
+ box?: LegendBox;
288
290
  }
289
291
  /** Estimated pixel size of the legend box (for layout reservation). */
290
292
  declare function measureLegend(items: LegendItem[], orientation?: LegendOrientation, metrics?: TextMetrics, maxBreite?: number): {
@@ -305,6 +307,320 @@ interface Marker {
305
307
  seriesIndex?: number;
306
308
  }
307
309
 
310
+ /*!
311
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
312
+ * MIT with Attribution: free use incl. commercial requires visible credit to
313
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
314
+ */
315
+
316
+ /** Tick density / sizing for one axis. */
317
+ interface TickConfig {
318
+ /** Target number of major (labelled) ticks. */
319
+ major?: number;
320
+ /** How many minor ticks to place between two major ticks. Default 0 = off. */
321
+ minor?: number;
322
+ /** Tick mark length in px. */
323
+ size?: number;
324
+ }
325
+ /** Grid line styling for one tick level. `false` disables that grid level. */
326
+ interface GridLineStyle {
327
+ color?: string;
328
+ width?: number;
329
+ style?: LineVariant;
330
+ opacity?: number;
331
+ }
332
+ /**
333
+ * Per-axis grid configuration. Each tick level (major / minor) can be styled
334
+ * independently or disabled. Defaults: major grid shown with theme colours,
335
+ * minor grid off.
336
+ */
337
+ interface GridStyle {
338
+ major?: GridLineStyle | false;
339
+ /**
340
+ * Zwischengitter -- die Linien zwischen den Hauptlinien.
341
+ *
342
+ * Wieviele es sind, sagt `ticks.minor`; steht dort nichts, ist EINE je
343
+ * Hauptabstand gemeint. Ohne eigene `opacity` sind sie halb so kraeftig wie
344
+ * das Hauptgitter: ein Zwischengitter in voller Staerke macht aus der
345
+ * Orientierung ein zweites Raster.
346
+ *
347
+ * **Eine Angabe gilt fuer beide Richtungen.** Wie beim Hauptgitter gewinnt
348
+ * `axes.x.grid.minor`, sonst `axes.left.grid.minor` -- ein Gitter mit zwei
349
+ * Stilen waere zwei Gitter.
350
+ */
351
+ minor?: GridLineStyle | false;
352
+ /**
353
+ * Wann das Gitter gezeichnet wird.
354
+ *
355
+ * `'front'` (Vorgabe) heisst: NACH den Serien -- eine Flaeche bis zur
356
+ * Grundlinie verdeckt es dann nicht, und die Linien des Gitters liegen
357
+ * sichtbar ueber der Kurve. Marker, Annotationen und Beschriftungen kommen
358
+ * trotzdem darueber.
359
+ *
360
+ * `'back'` zeichnet es als ERSTES, noch vor Highlights und Schwellenwerten.
361
+ * Das ist die Wahl, wenn eine deckende Flaeche das Gitter verschlucken SOLL
362
+ * -- oder wenn ein feines Raster hinter den Daten genuegt.
363
+ *
364
+ * Eine Angabe gilt fuer das ganze Gitter; wie beim Stil gewinnt `axes.x`
365
+ * vor `axes.left`.
366
+ */
367
+ layer?: GridLayer;
368
+ }
369
+ /** Axis baseline + tick marks styling. */
370
+ interface AxisStyle {
371
+ color?: string;
372
+ width?: number;
373
+ }
374
+ /** Tick / axis-label text styling. */
375
+ interface AxisLabelsStyle {
376
+ color?: string;
377
+ fontSize?: number;
378
+ }
379
+ /** Configuration for one Y-axis (left or right). */
380
+ interface YAxisConfig {
381
+ /** Position is 'left' or 'right' to determine placement side. Defaults to 'left'. */
382
+ position?: AxisPosition;
383
+ /** Optional explicit horizontal pixel offset from chart edge (defaults to index * 50px). */
384
+ offset?: number;
385
+ /** Rotated label drawn next to the axis. */
386
+ label?: string;
387
+ /** Override the value domain. `'auto'` lets the chart compute it from data. */
388
+ domain?: [number, number] | "auto";
389
+ /**
390
+ * Extra room above and below the data, **in pixels**. Ignored when `domain`
391
+ * is set explicitly — then you decide the range.
392
+ *
393
+ * The computed domain ends exactly at the smallest and largest reading, and
394
+ * the plot is clipped to its rectangle. A line of width 10 at the maximum
395
+ * therefore loses half its stroke, and a marker half its disc. That is right
396
+ * for the *value* and wrong for the *picture*.
397
+ *
398
+ * Pixels rather than a share of the range: the cause is in pixels
399
+ * (`style.line.width`, `markers.size`), and the same number then works for a
400
+ * series in °C and one in kW. A rule of thumb is half the widest stroke plus
401
+ * a little — `padding: 8` covers a 10 px line and a size-6 marker.
402
+ *
403
+ * ```ts
404
+ * axes: { left: { padding: 8 } }
405
+ * axes: { left: { padding: { top: 24, bottom: 4 } } } // room for a label
406
+ * ```
407
+ */
408
+ padding?: number | {
409
+ top?: number;
410
+ bottom?: number;
411
+ };
412
+ /** Format a tick value into its label text. */
413
+ format?: (value: number) => string;
414
+ /** Tick density / sizing. */
415
+ ticks?: TickConfig;
416
+ /** Per-tick-level grid styling. */
417
+ grid?: GridStyle;
418
+ /** Axis baseline + tick marks styling. */
419
+ axis?: AxisStyle;
420
+ /** Tick label text styling. */
421
+ labels?: AxisLabelsStyle;
422
+ }
423
+ /** Configuration for the X (time) axis. */
424
+ interface XAxisConfig {
425
+ /** Label drawn below the axis. */
426
+ label?: string;
427
+ /** Override the time domain. `'auto'` lets the chart compute it from data. */
428
+ domain?: [number, number] | "auto";
429
+ /** Custom formatter for tick labels (called with a `Date`). */
430
+ format?: (d: Date) => string;
431
+ /** Tick density / sizing. */
432
+ ticks?: TickConfig;
433
+ /** Per-tick-level grid styling. */
434
+ grid?: GridStyle;
435
+ /** Axis baseline + tick marks styling. */
436
+ axis?: AxisStyle;
437
+ /** Tick label text styling. */
438
+ labels?: AxisLabelsStyle;
439
+ }
440
+ /**
441
+ * Top-level axes container on {@link MLTimeGraphOptions}.
442
+ * `left` and `right` correspond to `yAxisIndex: 0` and `yAxisIndex: 1` series.
443
+ * Additional axes can be defined in the `y` array, with indices mapping to series via `yAxisIndex`.
444
+ */
445
+ interface AxesConfig {
446
+ x?: XAxisConfig;
447
+ left?: YAxisConfig;
448
+ right?: YAxisConfig;
449
+ /** Y specifies an arbitrary number of vertical axes, each mapped by its slice index. */
450
+ y?: YAxisConfig[];
451
+ }
452
+
453
+ /*!
454
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
455
+ * MIT with Attribution: free use incl. commercial requires visible credit to
456
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
457
+ */
458
+
459
+ /** Chart margins in pixels. */
460
+ interface Margin {
461
+ top: number;
462
+ right: number;
463
+ bottom: number;
464
+ left: number;
465
+ }
466
+ /** Legend placement position — inside or outside the chart area. */
467
+ type LegendPosition = "inside-right" | "inside-left" | "outside-right" | "outside-left"
468
+ /**
469
+ * Ueber bzw. unter der Zeichenflaeche, waagerecht und ueber mehrere Zeilen
470
+ * umgebrochen. Bis 1.10.0 gab es beides nicht, und zwar aus einem Grund: Ohne
471
+ * echte Textbreiten laesst sich nicht ausrechnen, wieviele Eintraege in eine
472
+ * Zeile passen und wieviel Hoehe zu reservieren ist.
473
+ */
474
+ | "above" | "below" | "separate";
475
+ /**
476
+ * Ein Feld hinter der Legende: Hintergrund und Rahmen.
477
+ *
478
+ * Gedacht fuer `inside-left` / `inside-right`. Dort liegt die Legende ueber den
479
+ * Daten, und ueber einer dichten Kurve oder einer gefuellten Flaeche ist sie
480
+ * schwer zu lesen -- genau dann traegt ein ruhiges Feld darunter.
481
+ *
482
+ * Wie beim Gitter entsteht es nur, wenn eines VERLANGT ist: `box: {}` genuegt
483
+ * und nimmt die Vorgaben.
484
+ */
485
+ interface LegendBox {
486
+ /** Fuellfarbe (Vorgabe `#ffffff`). */
487
+ fill?: string;
488
+ /** Rahmenfarbe (Vorgabe `#cccccc`). `'none'` laesst den Rahmen weg. */
489
+ stroke?: string;
490
+ /** Rahmenstaerke in px (Vorgabe 1). */
491
+ strokeWidth?: number;
492
+ /** Abstand zwischen Feldrand und Eintraegen in px (Vorgabe 6). */
493
+ padding?: number;
494
+ /**
495
+ * Deckkraft des Feldes (Vorgabe 0,85).
496
+ *
497
+ * Nicht 1: unter einer Legende im Bild liegen Daten, und die sollen
498
+ * durchscheinen duerfen. Wer sie ganz verdecken will, setzt 1.
499
+ */
500
+ opacity?: number;
501
+ }
502
+ interface LegendOptions {
503
+ /** Show the legend (default false). */
504
+ show?: boolean;
505
+ /** Placement (default 'inside-right'). 'separate' draws nothing — read chart.legendItems() and render your own. */
506
+ position?: LegendPosition;
507
+ /** Item layout direction (default 'vertical'). */
508
+ orientation?: LegendOrientation;
509
+ /**
510
+ * Hintergrund und Rahmen hinter der Legende. Ohne Angabe gibt es keines --
511
+ * so sah jede Legende vor 1.11.0 aus.
512
+ */
513
+ box?: LegendBox;
514
+ }
515
+ interface MLTimeGraphOptions {
516
+ /**
517
+ * Womit Textbreiten gerechnet werden (Legende, Achsentitel, Raender).
518
+ *
519
+ * Vorgabe ist `liberationMetrics` -- die mitgelieferte Vorschubtabelle des
520
+ * Stapels `Liberation Sans, Arial, Helvetica`. Sie liegt BEI, statt gemessen
521
+ * zu werden: eine Messung im Browser (Canvas `measureText`) und eine im
522
+ * Go-Port stimmen nicht aufs Pixel ueberein, und dann haengt das Bild davon
523
+ * ab, wer es zeichnet.
524
+ *
525
+ * Eigene Schrift? Dann entweder die Tabelle dafuer erzeugen
526
+ * (`node scripts/gen-text-metrics.mjs --font deine.ttf`) oder hier messen --
527
+ * etwa ueber Canvas im Browser. Mit dem zweiten Weg verlaesst du die
528
+ * Paritaet zwischen den beiden Bibliotheken, und zwar bewusst: eine Funktion
529
+ * steht in keinem JSON, der Go-Port kann sie nicht nachbilden.
530
+ */
531
+ textMetrics?: TextMetrics;
532
+ /** Chart dimensions */
533
+ width?: number;
534
+ height?: number;
535
+ /** Margins */
536
+ margin?: Margin;
537
+ /** Renderer (injected) */
538
+ renderer?: Renderer;
539
+ /** Time series data (raw or aggregated min/max/avg) */
540
+ series?: AnySeries[];
541
+ /**
542
+ * Clip series drawing to the plot area (default `true`).
543
+ *
544
+ * It matters only when data lies outside the axis domain — which happens as soon as you
545
+ * fix `axes.x.domain` and hand over a reading from just outside the window, so the curve
546
+ * runs to the edge instead of starting in mid-air. Without clipping, line and markers
547
+ * paint over the axis labels.
548
+ *
549
+ * Turn it off if you deliberately want a series to reach beyond the plot, or if the
550
+ * clip costs you: every clipped group gets a `clip-path`, and a browser may promote each
551
+ * to its own layer. With a handful of series that is nothing; with dozens on a slow
552
+ * machine it can be worth measuring.
553
+ */
554
+ clipSeries?: boolean;
555
+ /** Locale for i18n (e.g. 'de-DE') */
556
+ locale?: string;
557
+ /**
558
+ * IANA time zone for the time axis, e.g. `'Europe/Berlin'` or `'UTC'`.
559
+ *
560
+ * Unset means the machine's zone — the behaviour up to 1.8.1, kept so that
561
+ * nothing changes for callers who never thought about it. But a browser sits
562
+ * in the reader's zone and a server almost always in UTC, so the *same* JSON
563
+ * labelled the same reading with different times depending on where it was
564
+ * drawn. That is the opposite of what a DOM-free renderer is for; set this
565
+ * whenever a chart is produced in one place and read in another.
566
+ *
567
+ * The tick *positions* never depended on it — they are epoch arithmetic. Only
568
+ * the labels do.
569
+ */
570
+ timeZone?: string;
571
+ /**
572
+ * Font for every text in the chart, written into the SVG as `font-family`.
573
+ *
574
+ * Unset means the default stack below. Why name one at all: the SVG says
575
+ * nothing about fonts today, so a viewer picks its own, and the same chart
576
+ * has different label widths in a browser, in an email client and in a
577
+ * rasteriser. Naming a stack removes that variance.
578
+ *
579
+ * The default is chosen for **metric compatibility**, not looks: Liberation
580
+ * Sans was designed with the same advance widths as Arial, so Linux lands on
581
+ * Liberation, Windows and macOS on Arial or Helvetica, and the labels occupy
582
+ * the same space. A stack with DejaVu Sans would not do that — it is
583
+ * noticeably wider, and labels would collide differently.
584
+ *
585
+ * A CSS stack *is* "use it if installed, otherwise ours" — no extra
586
+ * mechanism needed.
587
+ *
588
+ * Note that the library never **measures** text (it renders DOM-free), so
589
+ * this does not change the layout: anchors and `text-anchor` stay where they
590
+ * are. It changes what the viewer draws. A much wider house font will
591
+ * therefore collide differently; that is on you.
592
+ */
593
+ fontFamily?: string;
594
+ /** Integrated legend configuration */
595
+ legend?: LegendOptions;
596
+ /** Markers */
597
+ markers?: Marker[];
598
+ /** Threshold bands / lines / fills drawn behind the series */
599
+ thresholds?: Threshold[];
600
+ /** Highlighted time regions drawn behind the series */
601
+ highlights?: Highlight[];
602
+ /**
603
+ * Data-gap configuration. Two equivalent forms:
604
+ * - `Gap[]` — legacy: array of region objects with flat
605
+ * fill/hatch/labelBaseline/rotate fields.
606
+ * - {@link GapsConfig} — new (preferred): `{ regions?, autoDetect?,
607
+ * minGapMs?, style? }`, where `style` provides
608
+ * per-region fallbacks and `autoDetect` (TODO)
609
+ * will derive gaps from time spacing in
610
+ * Phase 3+. For now: typed but not yet acted on.
611
+ */
612
+ gaps?: Gap[] | GapsConfig;
613
+ /** Free-form overlays (arrow, line, rect, point, label) in data coordinates */
614
+ annotations?: Annotation[];
615
+ /** Horizontal annotation bands below the chart (colored time ranges + labels) */
616
+ annotationBands?: AnnotationBandConfig[];
617
+ /**
618
+ * First-class axes configuration: per-axis `label`, `format`, `ticks`, `grid`,
619
+ * `axis`, `labels` (see USAGE.md, "Axes").
620
+ */
621
+ axes?: AxesConfig;
622
+ }
623
+
308
624
  /*!
309
625
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
310
626
  * MIT with Attribution: free use incl. commercial requires visible credit to
@@ -415,4 +731,4 @@ declare function renderMarkers(points: DataPoint[], ctx: RenderingContext, style
415
731
  declare function drawMarker(// NOSONAR
416
732
  commands: DrawCommand[], id: string | undefined, shape: Exclude<PointStyleType, "none">, x: number, y: number, size: number, stroke: string, fill: string, sw: number): void;
417
733
 
418
- export { type LegendOrientation as L, type Marker as M, Renderer as R, type SeriesStyle as S, type TextMetrics as T, type LegendItem as a, type LayoutResult as b, type RenderOutput as c, type Theme as d, drawMarker as e, estimateMetrics as f, getDefaultTheme as g, slugify as h, type RenderingContext as i, Layout as j, type LayoutConfig as k, liberationMetrics as l, type LegendConfig as m, measureLegend as n, renderLegend as o, renderMarkers as p, resetDefaultTheme as r, setDefaultTheme as s };
734
+ export { type AxesConfig as A, type GridLineStyle as G, type LegendItem as L, type MLTimeGraphOptions as M, Renderer as R, type SeriesStyle as S, type TextMetrics as T, type XAxisConfig as X, type YAxisConfig as Y, type LayoutResult as a, type Margin as b, type LegendOptions as c, type LegendPosition as d, type LegendOrientation as e, type Marker as f, type RenderOutput as g, type AxisLabelsStyle as h, type AxisStyle as i, type GridStyle as j, type Theme as k, type TickConfig as l, drawMarker as m, estimateMetrics as n, getDefaultTheme as o, liberationMetrics as p, slugify as q, resetDefaultTheme as r, setDefaultTheme as s, type RenderingContext as t, Layout as u, type LayoutConfig as v, type LegendConfig as w, measureLegend as x, renderLegend as y, renderMarkers as z };
@@ -331,6 +331,7 @@ type PathParams = Omit<DrawPath, "type">;
331
331
  type RectParams = Omit<DrawRect, "type">;
332
332
  type CircleParams = Omit<DrawCircle, "type">;
333
333
  type TextParams = Omit<DrawText, "type">;
334
+ type GapParams = Omit<DrawGap, "type">;
334
335
 
335
336
  /*!
336
337
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -1053,4 +1054,4 @@ declare class BandScale implements Scale {
1053
1054
  positions(): Map<string, number>;
1054
1055
  }
1055
1056
 
1056
- export { type SeriesOverlay as $, type AxisPosition as A, type DataPointRef as B, type FillBound as C, type DataPoint as D, type EnumMap as E, type FillSpec as F, type GridLayer as G, type HatchVariant as H, type FillRegion as I, type FillSide as J, type FillStyle as K, LinearScale as L, type MarkerLineStyle as M, type GapConfig as N, type GapLabel as O, type PointStyleType as P, type GapRegion as Q, type RangeLabelPosition as R, type SmoothingType as S, TimeScale as T, type GapStyle as U, type LineShape as V, type LineStyle as W, type MarkerStyle as X, type MovingAverageType as Y, type SVGLineStyle as Z, type SensorType as _, type DrawCommand as a, type SeriesOverlayKind as a0, type SeriesType as a1, type ShadowStyle as a2, type SolidDashStyle as a3, type ThresholdLabelConfig as a4, getLineStyle as a5, resolveDash as a6, type Point as a7, BandScale as a8, type BandScaleConfig as a9, type CircleParams as aa, type Dashstyle_t as ab, type DomainScaleConfig as ac, type DrawCircle as ad, type DrawGap as ae, type DrawGapType_t$1 as af, type DrawLine as ag, type DrawPath as ah, type DrawRect as ai, type DrawText as aj, type LineParams as ak, type LinearScaleConfig as al, type PathParams as am, type RectParams as an, type Scale as ao, type ScaleConfig as ap, TIME_INTERVALS as aq, type TextParams as ar, type TimeScaleConfig as as, getHatch as at, type LineVariant as b, type DrawGroup as c, type AnySeries as d, type Threshold as e, type Highlight as f, type Gap as g, type GapsConfig as h, type Annotation as i, type AnnotationBandConfig as j, type SeriesStyle as k, type TimeSeries as l, type LineDashStyle as m, type ThresholdFill as n, type ThresholdLabelPosition as o, type AnnotationPointShape as p, type LabelAnchor as q, type AnnotationBandItem as r, type TextBaseline as s, type AggregatedPoint as t, type AggregatedSeries as u, type AggregatedShowAs as v, type AggregationConfig as w, type AggregationMode as x, type AnnotationKind as y, type AxisOrientation as z };
1057
+ export { type SeriesOverlay as $, type AxisPosition as A, type DataPointRef as B, type FillBound as C, type DataPoint as D, type EnumMap as E, type FillSpec as F, type GridLayer as G, type Highlight as H, type FillRegion as I, type FillSide as J, type FillStyle as K, LinearScale as L, type MarkerLineStyle as M, type GapConfig as N, type GapLabel as O, type PointStyleType as P, type GapRegion as Q, type RangeLabelPosition as R, type SmoothingType as S, TimeScale as T, type GapStyle as U, type LineShape as V, type LineStyle as W, type MarkerStyle as X, type MovingAverageType as Y, type SVGLineStyle as Z, type SensorType as _, type DrawCommand as a, type SeriesOverlayKind as a0, type SeriesType as a1, type ShadowStyle as a2, type SolidDashStyle as a3, type ThresholdLabelConfig as a4, getLineStyle as a5, resolveDash as a6, type LineParams as a7, type PathParams as a8, type RectParams as a9, type CircleParams as aa, type TextParams as ab, type GapParams as ac, type Point as ad, BandScale as ae, type BandScaleConfig as af, type Dashstyle_t as ag, type DomainScaleConfig as ah, type DrawCircle as ai, type DrawGap as aj, type DrawGapType_t$1 as ak, type DrawLine as al, type DrawPath as am, type DrawRect as an, type DrawText as ao, type LinearScaleConfig as ap, type Scale as aq, type ScaleConfig as ar, TIME_INTERVALS as as, type TimeScaleConfig as at, getHatch as au, type LineVariant as b, type DrawGroup as c, type AnySeries as d, type Threshold as e, type Gap as f, type GapsConfig as g, type Annotation as h, type AnnotationBandConfig as i, type HatchVariant as j, type SeriesStyle as k, type TimeSeries as l, type LineDashStyle as m, type ThresholdFill as n, type ThresholdLabelPosition as o, type AnnotationPointShape as p, type LabelAnchor as q, type AnnotationBandItem as r, type TextBaseline as s, type AggregatedPoint as t, type AggregatedSeries as u, type AggregatedShowAs as v, type AggregationConfig as w, type AggregationMode as x, type AnnotationKind as y, type AxisOrientation as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ml-time-graph",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "TypeScript library for time-series charts with rich contextual annotation — telemetry, sensors, metrics, logs, finance. DOM-free SVG output, identical in the browser and on the server.",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",