ml-time-graph 1.20.1 → 1.20.2

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/CHANGELOG.md CHANGED
@@ -19,6 +19,15 @@ release notes, and every change is in `git log` in full.
19
19
 
20
20
  ---
21
21
 
22
+ ## [1.20.2] - 2026-10-22
23
+
24
+ ### Fixed
25
+ - **Go: axis domains survive `json.Marshal`** — `AxisDomain` now writes `"auto"` or `[min, max]`,
26
+ the form both runtimes read. Until now a fixed domain went out as `{"Auto":…,"Min":…,"Max":…}`,
27
+ so options built in Go could not be handed to the browser (or read back by Go). Every template in
28
+ `go-time-graph/test_data` is now checked to round-trip Go → JSON → Go → JSON unchanged.
29
+ (B-TGRAF-20261022-01)
30
+
22
31
  ## [1.20.1] - 2026-10-20
23
32
 
24
33
  ### Fixed
package/dist/index.d.ts CHANGED
@@ -1157,7 +1157,7 @@ declare function mergeOptions(...layers: (OptionsLayer | undefined)[]): MLTimeGr
1157
1157
  * Monate spaeter eine Datei aus einem Stapel von Berichten in der Hand haelt,
1158
1158
  * kann sonst nicht feststellen, welcher Stand sie gezeichnet hat.
1159
1159
  */
1160
- declare const VERSION = "1.20.1";
1160
+ declare const VERSION = "1.20.2";
1161
1161
 
1162
1162
  export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnnotationPointShape, AnySeries, AxesConfig, DataPoint, DrawCommand, FillSpec, Gap, GapsConfig, GraphBuilder, HatchVariant, Highlight, HighlightBuilder, LabelAnchor, LegendItem, LegendOptions, LegendOrientation, LegendPosition, LineDashStyle, LineVariant, MLTimeGraph, MLTimeGraphOptions, Margin, Marker, MarkerBuilder, MarkerLineStyle, PointStyleType, RangeLabelPosition, RenderOutput, SVGRenderer, SeriesStyle, SmoothingType, TextBaseline, Threshold, ThresholdBuilder, ThresholdFill, ThresholdLabelPosition, TimeSeries, TimeSeriesBuilder, VERSION, XAxisConfig, YAxisConfig, attachTooltip, autoMargin, axisGroups, fillBetweenThresholds, mergeOptions, mount, parseAggregated, parseDataPoint, parseSeries, toDataPoints, toSeries, zeigerImSvg };
1163
1163
  export type { AutoMarginOptions, AxisGroupInput, AxisGroups, FieldAccessor, FillBetweenThresholdsInput, LimitStatsPoint, MktPoint, OptionsLayer, PointAt, PointsAtOptions, StatsAggregatedPoint, StdDevPoint, TimeInput, ToDataPointsSpec, TooltipOptions, TooltipSample };
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ function Z(n){return n===true?{major:{}}:n===false?{major:false}:n}function He(n
24
24
  `.trim()}function Xe(n,e=2,t=false){if(n==="dashed"||!n&&t)return {strokeDasharray:"4,4"};if(n==="dotted")return {strokeDasharray:"2,4"};if(!n||n==="solid")return null;let r=yt(n,e);return r.strokeDasharray==="none"?null:r}function yt(n,e=2){let t=e;switch(n){case "dotted":return {strokeDasharray:`0, ${t*2}`,strokeLinecap:"round"};case "sparse-dots":return {strokeDasharray:`0, ${t*4}`,strokeLinecap:"round"};case "dashed":return {strokeDasharray:`${t*3}, ${t*2}`,strokeLinecap:"butt"};case "long-dash":return {strokeDasharray:`${t*6}, ${t*3}`,strokeLinecap:"butt"};case "dense-dash":return {strokeDasharray:`${t*1.5}, ${t*1.5}`,strokeLinecap:"butt"};case "dash-dot":return {strokeDasharray:`${t*4}, ${t*2}, 0, ${t*2}`,strokeLinecap:"round"};case "dash-dot-dot":return {strokeDasharray:`${t*5}, ${t*2}, 0, ${t*2}, 0, ${t*2}`,strokeLinecap:"round"};case "loose-dash":return {strokeDasharray:`${t*3}, ${t*4}`,strokeLinecap:"butt"};default:return {strokeDasharray:"none",strokeLinecap:"butt"}}}var S=new Proxy({},{get:(n,e)=>ae()[e],has:(n,e)=>e in ae(),ownKeys:()=>Reflect.ownKeys(ae()),getOwnPropertyDescriptor:(n,e)=>Reflect.getOwnPropertyDescriptor(ae(),e)});function ge(n,e){if(e<=0||n.length<2)return [];let t=[];for(let r=0;r<n.length-1;r++){let i=n[r],o=n[r+1];for(let s=1;s<=e;s++)t.push(i+(o-i)*s/(e+1));}return t}var me={axisColor:S.axisColor,tickColor:S.tickColor,textColor:S.textColor,textSize:S.textSize},ne=class{#e;#t;constructor(e){this.#e=new ee({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??me).axisColor}get tickColor(){return (this.#t.colors??me).tickColor}get textColor(){return (this.#t.colors??me).textColor}get textSize(){return (this.#t.colors??me).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,i=this.#e.ticks({minTicks:e,maxTicks:t}).map(o=>({time:o,x:this.#e.map(o),label:this.tickLabel(o)}));return this.antiOverlap(i)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,r=this.#t.maxTicks??12,{interval:i}=this.#e.tickInterval((t+r)/2,t,r),o={};return i<6e4?(o.hour="2-digit",o.minute="2-digit",o.second="2-digit"):i<36e5||i<864e5?(o.hour="2-digit",o.minute="2-digit"):i<31536e6?(o.day="numeric",o.month="short",i>=2592e6&&(o.day=void 0,o.month="long")):(o.year="numeric",i<2*31536e6&&(o.month="short")),this.#e.format(e,o)}antiOverlap(e){if(e.length<=1)return e;let t=60,r=[e[0]];for(let i=1;i<e.length;i++){let o=r[r.length-1].x;Math.abs(e[i].x-o)>=t&&r.push(e[i]);}return r}render(){let e=this.generateTicks(),t=this.#t.colors??me,r=this.#t.y??0,i=[],[o,s]=this.#e.range();i.push({type:"line",x1:o,y1:r,x2:s,y2:r,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let a of this.generateMinorTicks())i.push({type:"line",x1:a,y1:r,x2:a,y2:r+3,stroke:t.tickColor,strokeWidth:t.axisWidth});for(let a of e)i.push({type:"line",x1:a.x,y1:r,x2:a.x,y2:r+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),i.push({type:"text",content:a.label,x:this.#n(a.x,a.label,t.textSize),y:r+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return i}generateMinorTicks(){return ge(this.generateTicks().map(e=>e.x),this.#t.minorTicks??0)}#n(e,t,r){let i=this.#t.gesamtbreite,o=this.#t.metrics;if(i===void 0||o===void 0)return e;let s=o(t,r)/2;return Math.max(s+2,Math.min(i-s-2,e))}};function O(n){return "showAs"in n&&!!n.showAs}function bt(n){if(O(n)){let e=[];for(let t of n.data)t.min!==null&&e.push(t.min),t.max!==null&&e.push(t.max);return e}return n.data.map(e=>e.value).filter(e=>e!==null)}function ye(n,e){return {axisColor:n?.color??S.axisColor,tickColor:n?.color??S.tickColor,textColor:e?.color??S.textColor,textSize:e?.fontSize??S.textSize,axisWidth:n?.width??1}}function xt(n,e,t,r){if(r===void 0)return [n,e];let i=typeof r=="number"?r:r.top??0,o=typeof r=="number"?r:r.bottom??0;if(i<=0&&o<=0)return [n,e];let s=t-i-o,a=e-n;if(s<=0||a<=0)return [n,e];let l=a/s;return [n-o*l,e+i*l]}function be(n,e){return n!==void 0?n:e!==void 0&&e!==false?1:0}var er=[[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"]],Ze=.6,tr=(()=>{let n=new Map;for(let[e,,t]of er){let r=t.split(",");for(let i=0;i<r.length;i++)n.set(e+i,Number(r[i])/1e3);}return n})();function St(n){return tr.get(n)??Ze}var G=(n,e)=>{let t=0;for(let r of n)t+=St(r.codePointAt(0)??0);return t*e},nr=(n,e)=>[...n].length*e*Ze;function wt(n,e,t){let r=0;for(let i of n)r=Math.max(r,t(i,e));return r}var re={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function Ue(n,e){let t=r=>e===void 0||e>=r;return Math.abs(n)>=1e6&&t(1e5)?`${(n/1e6).toFixed(1)}M`:Math.abs(n)>=1e3&&t(100)?`${(n/1e3).toFixed(1)}k`:Number.isInteger(n)?String(n):n.toFixed(1)}function rr(n){let e=new Array(n.length).fill(false),t=0;for(;t<n.length;){let r=t;for(;r+1<n.length&&n[r+1].label===n[t].label;)r++;for(let i=t+1;i<r;i++)e[i]=true;t=r+1;}return e}var xe=class{#e;#t;constructor(e){this.#e=new U({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??re).axisColor}get tickColor(){return (this.#t.colors??re).tickColor}get textColor(){return (this.#t.colors??re).textColor}get textSize(){return (this.#t.colors??re).textSize}generateTicks(){let e=this.#t.tickValues;if(e&&e.length>0){let g=this.#t.format??Ue;return e.map(f=>({value:f,position:this.#e.map(f),label:g(f)}))}let t=this.#t.format??Ue,r=this.#t.ticks&&this.#t.ticks>0?this.#t.ticks:6,[i,o]=this.#e.domain(),s=Math.min(i,o),a=Math.max(i,o),l=a-s;if(l===0)return [{value:i,position:this.#e.map(i),label:t(i)}];let m=l/r,u=Math.pow(10,Math.floor(Math.log10(m))),h=m/u,c;if(h<=1.5?c=u:h<=3?c=2*u:h<=7?c=5*u:c=10*u,c<=0||!Number.isFinite(c))return [{value:i,position:this.#e.map(i),label:t(i)}];this.#t.format||(t=g=>Ue(g,c));let p=[],d=Math.ceil(s/c)*c;for(let g=d;g<=a;g+=c)p.push({value:g,position:this.#e.map(g),label:t(g)});return p}generateMinorTicks(){return ge(this.generateTicks().map(e=>e.position),this.#t.minorTicks??0)}render(){let e=this.generateTicks(),t=this.#t.colors??re,r=this.#t.x??0,i=this.#t.orientation??"vertical",o=this.#t.position??"left",s=this.#t.suppressLabelsNear??[],a=this.#t.suppressTolerancePx??8,l=h=>s.some(c=>Math.abs(c-h)<=a),m=[];if(i==="vertical"){let[h,c]=this.#e.range();m.push({type:"line",x1:r,y1:h,x2:r,y2:c,stroke:t.axisColor,strokeWidth:t.axisWidth});let p=rr(e);e.forEach((d,g)=>{let f=l(d.position),y=p[g]?{opacity:0}:{};o==="left"?(m.push({type:"line",x1:r-4,y1:d.position,x2:r,y2:d.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),f||m.push({type:"text",content:d.label,x:this.#n(r-8,d.label,"end"),y:d.position+4,anchor:"end",fontSize:t.textSize,fill:t.textColor,...y})):(m.push({type:"line",x1:r,y1:d.position,x2:r+4,y2:d.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),f||m.push({type:"text",content:d.label,x:this.#n(r+8,d.label,"start"),y:d.position+4,anchor:"start",fontSize:t.textSize,fill:t.textColor,...y}));});}else {let[h,c]=this.#e.range();m.push({type:"line",x1:h,y1:r,x2:c,y2:r,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let p of e)m.push({type:"line",x1:p.position,y1:r,x2:p.position,y2:r+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),m.push({type:"text",content:p.label,x:p.position,y:r+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}let u=(this.#t.orientation??"vertical")==="vertical";for(let h of this.generateMinorTicks())m.push(u?{type:"line",x1:o==="right"?r:r-2,y1:h,x2:o==="right"?r+2:r,y2:h,stroke:t.tickColor,strokeWidth:t.axisWidth}:{type:"line",x1:h,y1:r,x2:h,y2:r+3,stroke:t.tickColor,strokeWidth:t.axisWidth});return m}#n(e,t,r){let i=this.#t.gesamtbreite,o=this.#t.metrics;if(i===void 0||o===void 0)return e;let s=o(t,(this.#t.colors??re).textSize);return r==="end"?Math.max(s+2,Math.min(i-2,e)):Math.min(i-s-2,Math.max(2,e))}};function vt(n){let e=new Set,t={};for(let r of n){let i=r.enumMap;if(i)for(let[o,s]of Object.entries(i)){let a=Number(o);e.add(a),a in t||(t[a]=s);}}return {werte:e.size>0?[...e].sort((r,i)=>r-i):void 0,name:r=>t[r]??String(r)}}function Tt(n){let{axes:e,indices:t,seriesByIndex:r,layout:i,thresholds:o,metrics:s}=n,{chartX:a,chartY:l,chartWidth:m,chartHeight:u}=i,h=[],c=new Map,p,d=[],g=[],f=(e?.y?.length??0)>0,y=0,b=0;for(let x of t){let v=r.get(x),w=1/0,k=-1/0,R=false;for(let P of v)for(let Q of bt(P))Q<w&&(w=Q),Q>k&&(k=Q),R=true;if(!R)continue;if(Se(e,x)?.includeThresholds)for(let P of o)(P.axisIndex??0)!==x||P.line==="none"||(w=Math.min(w,P.value),k=Math.max(k,P.value));w===k&&(w-=1,k+=1);let M=Se(e,x),_=M?.domain,C=_&&_!=="auto"?_:xt(w,k,u,M?.padding),{werte:$,name:I}=vt(v);if($){let P=$.length>1?($[$.length-1]-$[0])/($.length-1):1;C[0]=$[0]-P/2,C[1]=$[$.length-1]+P/2;}let j=new U({domain:C,range:[l+u,l]});c.set(x,j);let B=M?.position??(x===0?"left":"right"),H=B==="right"?"outside-right":"outside-left",V=o.filter(P=>(P.axisIndex??0)===x&&typeof P.label=="object"&&P.label!==null&&P.label.position===H&&P.value>=Math.min(C[0],C[1])&&P.value<=Math.max(C[0],C[1])).map(P=>j.map(P.value)),A;if(B==="right"){let P=M?.offset??b*50;A=a+m+P,b++;}else {let P=M?.offset??y*50;A=a-P,y++;}let L=new xe({domain:C,range:[l+u,l],x:A,position:B,format:M?.format??($?I:void 0),tickValues:$,ticks:M?.ticks?.major,minorTicks:be(M?.ticks?.minor,Z(M?.grid)?.minor),colors:ye(M?.axis,M?.labels),suppressLabelsNear:V.length?V:void 0,gesamtbreite:i.totalWidth,metrics:s}),D=8+wt(L.generateTicks().map(P=>P.label),11,s),F=B==="right"?A+D:A-D;g.push({position:B,von:Math.min(A,F),bis:Math.max(A,F),achse:x}),f&&M?.label&&d.push({text:M.label,achseX:A,kante:F,position:B,style:M.labels,fest:M.labelOffset}),x===0&&(p=L),h.push({type:"group",cssClass:`value-axis ${B}`,sharedStyles:true,commands:L.render()});}return {commands:h,titel:d,baender:g,neueForm:f,primary:p,scales:c}}function Se(n,e){let t=e===0?n?.left:e===1?n?.right:void 0,r=n?.y&&n.y.length>e?n.y[e]:void 0;return r&&t?{...t,...r}:r??t}var kt=6;function ir(n){let e=typeof n.label=="object"&&n.label!==null?n.label.position:void 0;return e==="outside-right"?"right":e==="outside-left"?"left":null}function or(n,e,t,r,i){let o=r.filter(a=>a.position===e&&a.achse!==void 0&&a.achse!==t),s=false;if(e==="right"){for(let a of [...o].sort((l,m)=>l.von-m.von))n.x<a.bis&&n.x+i>a.von&&(n.x=a.bis+kt,s=true);return {band:{position:e,von:n.x,bis:n.x+i,achse:t},verschoben:s}}for(let a of [...o].sort((l,m)=>m.bis-l.bis))n.x-i<a.bis&&n.x>a.von&&(n.x=a.von-kt,s=true);return {band:{position:e,von:n.x-i,bis:n.x,achse:t},verschoben:s}}function sr(n){return n==="dotted"?{dash:"dotted"}:n==="dashed"?{dash:"dashed"}:{}}function ar(n){let{thresholds:e,valueScale:t,xRange:r}=n,[i,o]=r,[s,a]=t.range(),l=Math.min(s,a),m=Math.max(s,a),u=[],h=[];for(let c of e){let p=c.color??S.thresholdColor,d=t.map(c.value);c.fill==="above"?u.push({type:"rect",x:i,y:l,w:o-i,h:Math.max(0,d-l),fill:p,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0}):c.fill==="below"&&u.push({type:"rect",x:i,y:d,w:o-i,h:Math.max(0,m-d),fill:p,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0});let g=c.line??S.thresholdLine;if(g!=="none"){let x=sr(g),v={type:"line",x1:i,y1:d,x2:o,y2:d,stroke:p,strokeWidth:1,...x,id:c.id?`${c.id}-line`:void 0};c.shadowColor&&(v.shadowColor=c.shadowColor,v.shadowBlur=c.shadowBlur??4,v.shadowOffsetX=c.shadowOffsetX??0,v.shadowOffsetY=c.shadowOffsetY??2),u.push(v);}let[f,y]=t.domain();if(c.value>=Math.min(f,y)&&c.value<=Math.max(f,y)&&c.label!==void 0&&c.label!==null&&c.label!==false){let x=typeof c.label=="object"?c.label:void 0,v=typeof c.label=="string"?c.label:x?.text??c.name,w=x?.position??"right",k=mr(v,w,i,o,d,p,x);h.push({...k,y:lr(k.y,Math.min(s,a),Math.max(s,a),S.thresholdFontSize),id:c.id?`${c.id}-label`:void 0});}}return {inside:u,labels:h}}function lr(n,e,t,r){return Math.max(e+r,Math.min(t-r/2,n))}function mr(n,e,t,r,i,o,s){let a=(t+r)/2,l={type:"text",content:n,fontSize:S.thresholdFontSize,fill:o},m=s?{...s.rotate!==void 0&&{rotate:s.rotate},...s.textBaseline!==void 0&&{textBaseline:s.textBaseline}}:{};switch(e){case "left":return {...l,...m,x:t+4,y:i-4,anchor:"start"};case "above":return {...l,...m,x:a,y:i-6,anchor:"middle"};case "below":return {...l,...m,x:a,y:i+14,anchor:"middle"};case "center":return {...l,...m,x:a,y:i-4,anchor:"middle"};case "outside-left":return {...l,...m,x:t-6,y:i+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...l,...m,x:r+6,y:i+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...l,...m,x:r-4,y:i-4,anchor:"end"}}}function _t(n){let{thresholds:e,valueScales:t,primaryScale:r,xRange:i,layout:o}=n,s=n.metrics??G,{chartX:a,chartY:l,chartWidth:m,chartHeight:u}=o,h=[];if(e.length===0)return h;let c=[],p=[];for(let d of e){let g=d.id??Y(d.name),f=t.get(d.axisIndex??0),y=f??r,b=f?d.axisIndex??0:0,x=ar({thresholds:[d],valueScale:y,xRange:i}),v=ir(d);if(v&&n.baender)for(let w of x.labels){if(w.type!=="text")continue;let{band:k}=or(w,v,b,n.baender,s(w.content,S.thresholdFontSize));n.belegt?.push(k);}x.inside.length&&c.push({type:"group",cssClass:`threshold threshold--${g}`,id:`threshold-${g}`,commands:x.inside}),x.labels.length&&p.push({type:"group",cssClass:`threshold-label threshold-label--${g}`,commands:x.labels});}return c.length&&h.push({type:"group",cssClass:"thresholds",commands:c,clipRect:{x:a,y:l,w:m,h:u}}),p.length&&h.push({type:"group",cssClass:"threshold-labels",commands:p}),h}function At(n,e,t,r){switch(n){case "above":return e-5;case "below":return r!==void 0?r-5:t+14;case "center":case "middle":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function we(n){let{ranges:e,timeScale:t,yRange:r,height:i,metrics:o=G}=n,[s,a]=r,l=[],[m,u]=t.range(),h=Math.min(m,u),c=Math.max(m,u),p=d=>Math.max(h,Math.min(c,d));for(let d of e){let g=p(t.map(d.startTime)),f=p(t.map(d.endTime));if(d.fill!==void 0&&l.push({type:"rect",x:g,y:s,w:f-g,h:a-s,fill:d.fill,hatch:d.hatch,opacity:d.opacity}),d.edges)for(let y of [g,f])l.push({type:"line",x1:y,y1:s,x2:y,y2:a,stroke:d.edges.stroke,strokeWidth:d.edges.strokeWidth,dash:"dashed"});if(d.label){let y=d.labelPosition??"middle",b=d.rotate,x=true;if(b==="auto"){let v=y!=="above"&&y!=="below",w=o(d.label,d.fontSize??11);b=v&&w>Math.abs(f-g)-4?-90:void 0,x=b===void 0||w<=Math.abs(a-s)-4;}x&&l.push({type:"text",content:d.label,x:(g+f)/2,y:At(y,s,a,i),anchor:"middle",fontSize:d.fontSize,fill:d.labelColor,rotate:b});}}return l}function qe(n){let{gaps:e,timeScale:t,yRange:r,height:i,fill:o=S.gapFill,hatch:s,fillOpacity:a=S.gapFillOpacity??.15,stroke:l=S.gapStroke,strokeWidth:m=S.gapStrokeWidth,dashed:u=true,fontSize:h=S.gapFontSize,fontFill:c=S.gapFontColor,labelBaseline:p="middle",labelRotate:d,metrics:g,band:f}=n,y=()=>{if(!f)return [];let b=f.height??6,[x,v]=r,w=Math.max(x,v);return e.map(k=>{let R=t.map(k.startTime),M=t.map(k.endTime);return {type:"rect",x:Math.min(R,M),y:w-b+(f.offset??0),w:Math.abs(M-R),h:b,fill:f.fill??l,opacity:f.opacity??.75}})};return we({timeScale:t,yRange:r,height:i,metrics:g,ranges:e.map(b=>{let x=b.style??"dashed_border",v=x==="filled"||x==="dashed_border",w=x==="dashed_border"&&u!==false;return {startTime:b.startTime,endTime:b.endTime,...v&&{fill:b.fill??o,hatch:b.hatch??s,opacity:b.fillOpacity??a},...w&&{edges:{stroke:l,strokeWidth:m}},label:b.label,labelPosition:b.labelBaseline??p,labelColor:c,fontSize:h,rotate:b.rotate??d}})}).concat(y())}function Mt(n){let{gap:e,runs:t,timeScale:r,valueScale:i,metrics:o,lineColor:s}=n,a=[],l=e.bridge,m=[];for(let u=1;u<t.length;u++){let h=t[u-1][t[u-1].length-1],c=t[u][0];if(e.display==="bridge_line"){if(h.value===null||c.value===null)continue;a.push({type:"line",x1:r.map(h.time),y1:i.map(h.value),x2:r.map(c.time),y2:i.map(c.value),stroke:l?.color??s??S.stroke,strokeWidth:l?.width??1.5,dash:l?.style??"dotted"});}else m.push({startTime:h.time,endTime:c.time});}if(m.length>0){let u=e.display&&e.display!=="bridge_line"?e.display:"dashed_border",h=e.fill,c=typeof h=="string"?h:h?.color,p=i.range();a.push(...qe({gaps:m.map(d=>({...d,style:u})),timeScale:r,yRange:[Math.min(p[0],p[1]),Math.max(p[0],p[1])],fill:c,hatch:typeof h=="object"?h.hatch:void 0,fillOpacity:e.opacity??.15,labelBaseline:e.label?.baseline,labelRotate:e.label?.rotate,metrics:o,band:e.band}));}return a}var Ct={display:"dashed_border",fill:{color:"#94a3b8",hatch:"classic-diagonal"},opacity:.5,label:{rotate:"auto"}},Lt=6e4,ur=60*Lt,hr=24*ur;function cr(n){let e=Math.floor(n/Lt);if(e<60)return `${e} min`;if(n<hr){let i=Math.floor(e/60),o=e%60;return o===0?`${i} h`:`${i} h ${o} min`}let t=Math.floor(e/1440),r=Math.floor(e%1440/60);return r===0?`${t} d`:`${t} d ${r} h`}function dr(n,e,t){let r=n.format(e,{hour:"2-digit",minute:"2-digit"}),i=o=>n.format(o,{year:"numeric",month:"2-digit",day:"2-digit"});return i(e)===i(t)?r:`${n.format(e,{day:"numeric",month:"short"})} ${r}`}function pr(n,e,t){let r=null;for(let i of n)i.value===null||i.time<e||i.time>t||(r===null||i.time>r)&&(r=i.time);return r}function Dt(n){let{atEnd:e,series:t,timeScale:r}=n,[i,o]=r.domain(),s=e.now??o,a=new Set;for(let m of t){if(!("data"in m)||m.data.length===0||!("value"in m.data[0]))continue;let u="gaps"in m?m.gaps?.atEnd:void 0;if(u===false||"holdToEnd"in m&&m.holdToEnd)continue;let h=u?.afterMs??e.afterMs,c=pr(m.data,i,s);c!==null&&s-c>h&&a.add(c);}let l={...Ct,...e.style,label:{...Ct.label,...e.style?.label}};return [...a].sort((m,u)=>m-u).map(m=>{let u=s-m,h=e.label,c=typeof h=="function"?h(m,u):h?.replaceAll("{since}",dr(r,m,s)).replaceAll("{duration}",cr(u));return {startTime:m,endTime:s,label:c,style:l}})}var fr=1,$t=4;function gr(n,e="last"){let t=[...n].sort((o,s)=>o.time-s.time||o.index-s.index),r=[],i=o=>r.every(s=>o.right+$t<=s.left||s.right+$t<=o.left);t.length>0&&r.push(e==="first"?t[0]:t[t.length-1]);for(let o of t)o!==r[0]&&i(o)&&r.push(o);return new Set(r.map(o=>o.index))}function yr(n){let e=typeof n=="object"&&n!==null?n.mode:n,t=typeof n=="object"&&n!==null&&n.keep==="first"?"first":"last";return {fit:e==="fit",keep:t}}var ve=class{#e;constructor(e,t,r,i){this.#e={...e,xRange:t,y:r,height:i};}render(){let{items:e,timeScale:t,background:r,hatch:i,showAxis:o,xRange:s,y:a,height:l}=this.#e,m=[];r&&m.push({type:"rect",x:s[0],y:a,w:s[1]-s[0],h:l,fill:r,opacity:.04,stroke:"#ddd",strokeWidth:.25});let u=this.#n();if(e.forEach((h,c)=>{let p=this.#t(h);if(!p)return;let{startX:d,w:g}=p,f=d+g/2;if(m.push({type:"rect",x:d,y:a,w:g,h:l,hatch:h.hatch??i,fill:h.fill??"#6b728044",stroke:h.stroke,strokeWidth:h.strokeWidth??0,title:h.title}),h.label&&(!u||u.has(c))){let y=h.labelFontSize??10;m.push({type:"text",content:h.label,x:f,y:this.#r(h.labelBaseline,y),anchor:"middle",fontSize:y,fill:h.labelFill??"#333"});}}),o){let h=new ne({domain:t.domain(),xRange:s,y:a+l+4});m.push({type:"group",cssClass:"annotation-band-axis",commands:h.render()});}return m}#t(e){let{timeScale:t,xRange:r}=this.#e,i=t.map(e.startTime),o=t.map(e.endTime);if(o<r[0]||i>r[1])return null;let s=Math.max(r[0],Math.min(r[1],i)),a=Math.max(r[0],Math.min(r[1],o)),l=Math.max(a-s,fr);return s+l>r[1]&&(s=Math.max(r[0],r[1]-l)),{startX:s,w:l}}#n(){let{fit:e,keep:t}=yr(this.#e.labels);if(!e)return null;let r=this.#e.metrics??G,i=[];return this.#e.items.forEach((o,s)=>{let a=o.label?this.#t(o):null;if(!a||!o.label)return;let l=a.startX+a.w/2,m=r(o.label,o.labelFontSize??10)/2;i.push({index:s,time:o.startTime,left:l-m,right:l+m});}),gr(i,t)}#r(e,t){let{y:r,height:i}=this.#e;switch(e){case "top":return r+t*.9;case "bottom":return r+i-t*.25;default:return r+i/2+t*.35}}};function Pt(n){let{highlights:e,timeScale:t,yRange:r,height:i}=n;return we({metrics:n.metrics,timeScale:t,yRange:r,height:i,ranges:e.map(o=>({startTime:o.startTime,endTime:o.endTime,fill:o.color??S.highlightColor,opacity:o.opacity??S.highlightOpacity,label:o.label,labelPosition:o.labelPosition??"top",labelColor:o.color??S.highlightLabelColor,fontSize:S.annotationFontSize,rotate:o.rotate}))})}var Rt=n=>n==="chartTop"||n==="chartBottom"||typeof n=="object"&&("threshold"in n||"value"in n);function Bt(n,e){let t=new Set(e.map(o=>o.id??o.name)),r=o=>n.some(s=>(s.id??s.name)===o||s.name===o),i=[];return n.forEach((o,s)=>{let a="colorByThresholds"in o?o.colorByThresholds:void 0;for(let u of a??[])t.has(u)||i.push(`series ${s} colorByThresholds names unknown threshold "${u}"`);let l=o.style?.fill;(l&&typeof l=="object"&&"regions"in l?l.regions??[]:[]).forEach((u,h)=>{let c=`series ${s} fill region ${h}`;for(let f of [u.from,u.to,u.outer])f&&typeof f=="object"&&"threshold"in f&&!t.has(f.threshold)&&i.push(`${c} references unknown threshold "${f.threshold}"`),f&&typeof f=="object"&&"series"in f&&!r(f.series)&&i.push(`${c} references unknown series "${f.series}"`);let p=u.from??"chartBottom",d=u.to??"series",g=p==="series"&&Rt(d)||d==="series"&&Rt(p);u.side&&!g&&i.push(`${c} sets side, which only applies between the line and a fixed bound`),u.outer&&!u.side&&i.push(`${c} sets outer without side -- outer has no effect`);});}),i}function jt(n){return [...wr(n.series.map(e=>e.id??e.name)),...br(n.series,n.linienGrundlage),...xr(n.gaps.map(e=>e.style)),...Sr(n.series.map(e=>!O(e)&&!!e.style?.gap?.label)),...vr(n.series.map(e=>"sensorType"in e?e.sensorType:void 0)),...Bt(n.series,n.thresholds)]}function br(n,e){let t=[],r=i=>n.find(o=>(o.id??o.name)===i||o.name===i);return n.forEach((i,o)=>{if(O(i))return;let s=i.style?.fill,a=s&&typeof s=="object"&&"regions"in s?s.regions:[],l=new Set;for(let m of a)if(m.where)for(let u of [m.from??"chartBottom",m.to??"series"]){let h=u==="series"?i:typeof u=="object"&&"series"in u?r(u.series):void 0;if(!h||O(h))continue;let{grundLinie:c,stepShape:p}=e(h),d=c?.smoothingType??"catmull-rom";p||!c?.smoothing||d==="monotone"||l.has(h.name)||(l.add(h.name),t.push(`series ${o}: fill where decides on the readings, but "${h.name}" is smoothed with ${d}, which can overshoot them -- the area may miss the line at its edges; smoothingType 'monotone' does not overshoot`));}}),t}function xr(n){let e=n.flatMap((t,r)=>t==="label"?[String(r)]:[]);return e.length?[`gap ${e.join(", ")} uses style "label" -- deprecated, removed before 2.0; use style "empty" with a label`]:[]}function Sr(n){let e=n.flatMap((t,r)=>t?[String(r)]:[]);return e.length?[`series ${e.join(", ")} set style.gap.label -- deprecated, removed before 2.0; set the label style on gaps.style.label`]:[]}function wr(n){let e=new Map;return n.forEach((t,r)=>{e.set(t,[...e.get(t)??[],r]);}),[...e].filter(([,t])=>t.length>1).map(([t,r])=>`series ${r.join(", ")} share the id "${t}" -- hidden and pointsAt cannot tell them apart; give each a unique id`)}function vr(n){let e=n.flatMap((t,r)=>t&&t!=="numeric"?[String(r)]:[]);return e.length?[`series ${e.join(", ")} set sensorType -- deprecated, removed before 2.0; it has no effect on the chart, use enumMap for state series`]:[]}var Te=class{};var E=class{static interpolateDataPoint(n,e,t){return {time:n.time+Math.round(t*(e.time-n.time)),value:(n.value??0)+t*((e.value??0)-(n.value??0)),synthetic:true}}static interpolateAggregatedPoint(n,e,t){let r=(i,o)=>i!==null&&o!==null?i+t*(o-i):null;return {time:n.time+t*(e.time-n.time),min:r(n.min,e.min),max:r(n.max,e.max),avg:r(n.avg,e.avg),count:Math.round(n.count+t*(e.count-n.count))}}static getRuns(n,e,t=0){let r=[...n].sort((a,l)=>a.time-l.time),i=[],o=[],s=null;for(let a of r){let l=e(a),m=t>0&&s&&a.time-s.time>t;(l||m)&&o.length&&(i.push(o),o=[]),l||o.push(a),s=a;}return o.length&&i.push(o),i}static splitByBoundaries(n,e,t,r){if(n.length===0)return [];if(e.length===0)return [{data:n,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let i=[...e].sort((m,u)=>m-u),o=[],s=m=>m<=0?Number.NEGATIVE_INFINITY:i[m-1],a=m=>{let u=0;for(let h=0;h<i.length&&m>=i[h];h++)u=h+1;return u},l=[n[0]];for(let m=1;m<n.length;m++){let u=n[m-1],h=n[m],c=t(u),p=t(h),d;p>c?d=i.filter(f=>f>c&&f<=p):p<c?d=i.filter(f=>f>=p&&f<c).reverse():d=[];let g=c;for(let f of d){let y=(f-c)/(p-c),b=r(u,h,y);l.push(b);let x=a((g+f)/2);o.push({data:l,zoneIndex:x,zoneLow:s(x)}),l=[b],g=f;}(d.length===0||d[d.length-1]!==p)&&l.push(h);}if(l.length>1||n.length===1){let m=t(l[0]),u=t(l[l.length-1]),h=a((m+u)/2);o.push({data:l,zoneIndex:h,zoneLow:s(h)});}return o}static splitByThreshold(n,e,t,r){let i=this.splitByBoundaries(n,[e],t,r),o={above:[],below:[]};for(let s of i)s.zoneIndex===0?o.below.push(s.data):o.above.push(s.data);return o}};function Et(n,e=6e4){if(n.length<2)return [];let t=[...n].sort((i,o)=>i.time-o.time),r=[];for(let i=1;i<t.length;i++)t[i].time-t[i-1].time>e&&r.push({startTime:t[i-1].time,endTime:t[i].time});return r}function Gt(n,e,t){let r=new Array(n.length),i=0;for(let o=0;o<n.length;o++){let s=n[o].time,a=s-e;for(;i<o&&n[i].time<a;)i++;let l=n.slice(i,o+1).map(m=>m.value);r[o]={time:s,value:t(l),synthetic:true};}return r}var Tr=8.314,Ft=273.15,Ot=83144;function kr(n,e=Ot){let t=e/Tr,r=0,i=0;for(let s of n)s!==null&&(r+=Math.exp(-t/(s+Ft)),i++);if(i===0)return null;let o=r/i;return t/-Math.log(o)-Ft}function It(n,e,t=Ot){return Gt(n,e,r=>kr(r,t))}function _r(n){let e=0,t=0;for(let o of n)o!==null&&(e+=o,t++);if(t===0)return null;let r=e/t,i=0;for(let o of n){if(o===null)continue;let s=o-r;i+=s*s;}return Math.sqrt(i/t)}function Ar(n){let e=0,t=0;for(let o of n)o!==null&&(e+=o,t++);if(t<2)return null;let r=e/t,i=0;for(let o of n){if(o===null)continue;let s=o-r;i+=s*s;}return Math.sqrt(i/(t-1))}function Wt(n,e,t=false){return Gt(n,e,t?Ar:_r)}function Je(n,e){let t=new Array(n.length),r=0;for(let i=0;i<n.length;i++){let o=n[i].time,s=o-e;for(;r<i&&n[r].time<s;)r++;let a=0,l=0;for(let m=r;m<=i;m++){let u=n[m].value;u!==null&&(a+=u,l++);}t[i]={time:o,value:l===0?null:a/l,synthetic:true};}return t}function zt(n,e){let t=new Array(n.length),r=null,i=0;for(let o=0;o<n.length;o++){let s=n[o].time,a=n[o].value;if(a===null){t[o]={time:s,value:r,synthetic:true};continue}if(r===null||e<=0)r=a;else {let l=1-Math.exp(-(s-i)/e);r=a*l+r*(1-l);}i=s,t[o]={time:s,value:r,synthetic:true};}return t}function X(n){let e=[];for(let t of n)e.length>0&&e.push({...t,value:e[e.length-1].value}),e.push(t);return e}function Ht(n,e,t){let r=[],i=ke(t);for(let o=0;o<n.length;o++){let s=n[o];s.data.length>=2?r.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${o}`:void 0,points:s.data.map(a=>({x:e.timeScale.map(a.time),y:e.valueScale.map(a.value)})),stroke:s.color??i.line.stroke,strokeWidth:i.line.strokeWidth,smoothing:i.line.smoothing,smoothingType:i.line.smoothingType,dashed:i.line.dashed,shadowColor:i.shadow.color,shadowBlur:i.shadow.blur,shadowOffsetX:i.shadow.offsetX,shadowOffsetY:i.shadow.offsetY,fill:"none"}):s.data.length===1&&r.push({type:"circle",id:t.id?`${t.id}-dot-${o}`:void 0,cx:e.timeScale.map(s.data[0].time),cy:e.valueScale.map(s.data[0].value),r:Math.max(i.markers.size,i.line.strokeWidth),fill:s.color??i.line.stroke,shadowColor:i.shadow.color,shadowBlur:i.shadow.blur});}return r}function Vt(n,e,t,r){if(n.length<2)return [];let i=E.splitByBoundaries(n,t.boundaries,t.getValue,t.interpolate),o=[];for(let s=0;s<i.length;s++){let a=i[s];if(a.data.length<2)continue;let l=t.getColor(a.zoneIndex);if(!l)continue;let m=a.data.map(h=>({x:e.timeScale.map(h.time),y:e.valueScale.map(t.yLow(h))})),u=a.data.map(h=>({x:e.timeScale.map(h.time),y:e.valueScale.map(t.yHigh(h))})).reverse();o.push({type:"path",cssClass:"series-fill",id:r?.id?`${r.id}-fill-${s}`:void 0,points:[...m,...u],fill:l,hatch:t.getHatch?.(a.zoneIndex),stroke:"none",...r?.smoothing?{smoothing:true,smoothingType:r.smoothingType,smoothCount:a.data.length,smoothTail:a.data.length}:{}});}return o}var _e=class n{#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 r=new n;return t(r),r.length===0?this:(this.#e.push({type:"group",...e,commands:r.commands}),this)}toGroup(e={}){return {type:"group",...e,commands:this.commands}}};var Mr="#ffffff",Cr="#cccccc",Lr=6,Dr=.85,z=12,Me=8,ue=20,$r=11,Ae=18,Qe=(n,e)=>e(n,$r);function Nt(n,e,t){let r=a=>z+Me+Qe(a.name,e);if(t===void 0){let a=n.reduce((l,m)=>l+r(m)+Ae,0)-Ae;return [{items:n,breite:Math.max(0,a)}]}let i=[],o=[],s=0;for(let a of n){let l=r(a),m=o.length===0?l:s+Ae+l;o.length>0&&m>t?(i.push({items:o,breite:s}),o=[a],s=l):(o=[...o,a],s=m);}return o.length>0&&i.push({items:o,breite:s}),i}function Kt(n,e="vertical",t=G,r){if(e==="horizontal"){let o=Nt(n,t,r);return {width:o.reduce((s,a)=>Math.max(s,a.breite),0),height:o.length*ue}}let i=0;for(let o of n)i=Math.max(i,Qe(o.name,t));return {width:z+Me+i,height:n.length*ue}}function Pr(n){let{items:e,x:t,y:r,orientation:i="vertical",metrics:o=G,maxBreite:s,box:a,itemClass:l}=n,m=new _e;if(a&&e.length>0){let p=Kt(e,i,o,s),g=((i==="horizontal"?p.height/ue:e.length)-1)*ue+z,f=a.padding??Lr,y=a.stroke??Cr;m.rect({x:t-f,y:r-f,w:p.width+2*f,h:g+2*f,fill:a.fill??Mr,...y==="none"?{}:{stroke:y,strokeWidth:a.strokeWidth??1},opacity:a.opacity??Dr});}let u=i==="horizontal"?Nt(e,o,s):e.map(p=>({items:[p],breite:0})),h=new Map;u.forEach((p,d)=>{let g=t;for(let f of p.items)h.set(f,{x:g,y:r+d*ue}),g+=z+Me+Qe(f.name,o)+Ae;});let c=e.some(p=>p.line!==void 0&&p.line!=="solid");return e.forEach(p=>{let d=h.get(p)??{x:t,y:r},g=d.x,f=d.y,y=["legend-item"];p.id&&y.push(`legend-item--${p.id}`),l&&y.push(l),m.group({cssClass:y.join(" "),...p.id?{id:`legend-${p.id}`}:{}},b=>{c?b.line({x1:g,y1:f+z/2,x2:g+z,y2:f+z/2,stroke:p.color,strokeWidth:Rr(p.width),...p.line&&p.line!=="solid"?{dash:p.line}:{}}):b.rect({x:g,y:f,w:z,h:z,fill:p.color,stroke:S.legendStroke,strokeWidth:1}),b.text({content:p.name,x:g+z+Me,y:f+z-2,fontSize:S.legendFont,fill:S.legendText});});}),m.toGroup({cssClass:"chart-legend"})}function Yt(n){let{legend:e,items:t,gesamtbreite:r,metrics:i}=n,o=(e?.show??false)&&t.length>0,s=e?.position??"inside-right",a=e?.orientation??(s==="above"||s==="below"?"horizontal":"vertical"),l=s==="above"||s==="below"?r-16:void 0;return {items:t,show:o,position:s,orientation:a,maxBreite:l,size:o?Kt(t,a,i,l):{width:0,height:0},boxRand:o&&e?.box?e.box.padding??6:0,box:e?.box,itemClass:e?.itemClass}}function Xt(n,e){let t=n.position==="outside-right"||n.position==="outside-left"||n.position==="above"||n.position==="below";if(!n.show||!t)return null;let r={...e},i=2*n.boxRand;return n.position==="outside-right"?r.right+=n.size.width+i+16:n.position==="outside-left"?r.left+=n.size.width+i+16:n.position==="above"?r.top+=n.size.height+i+10:r.bottom+=n.size.height+i+10,r}function Zt(n){let{legende:e,layout:t,randBelegt:r,metrics:i}=n;if(!e.show||e.position==="separate")return [];let{chartX:o,chartY:s,chartWidth:a}=t,l,m;if(e.position==="inside-right")l=o+a-e.size.width-8-e.boxRand,m=s+8+e.boxRand;else if(e.position==="inside-left")l=o+8+e.boxRand,m=s+8+e.boxRand;else if(e.position==="outside-right"){let u=r.filter(h=>h.position==="right").reduce((h,c)=>Math.max(h,c.bis),o+a);l=Math.min(Math.max(o+a+16,u+12),t.totalWidth-e.size.width-2),m=s;}else e.position==="above"||e.position==="below"?(l=Math.max(8,Math.min(t.totalWidth-e.size.width-8,o+(a-e.size.width)/2)),m=e.position==="above"?Math.max(4,s-e.size.height-10):t.totalHeight-e.size.height-4):(l=8,m=s);return [Pr({items:e.items,x:l,y:m,orientation:e.orientation,metrics:i,maxBreite:e.maxBreite,box:e.box,itemClass:e.itemClass})]}function Rr(n){return Math.min(Math.max(n??2,1.5),3)}function Ut(n){let{xTicks:e,yTicks:t,xRange:r,yRange:i,stroke:o=S.gridStroke,strokeWidth:s=S.gridStrokeWidth,dashed:a=false,opacity:l=S.gridOpacity}=n,m=[];if(t)for(let u of t)m.push({type:"line",x1:r[0],y1:u,x2:r[1],y2:u,stroke:o,strokeWidth:s,dashed:a,opacity:l});if(e)for(let u of e)m.push({type:"line",x1:u,y1:i[0],x2:u,y2:i[1],stroke:o,strokeWidth:s,dashed:a,opacity:l});return m}function qt(n){let{axes:e,timeAxis:t,primaryValueAxis:r,xRange:i,yRange:o}=n,s=Z(e?.x?.grid),a=Z(e?.left?.grid),l=s?.layer??a?.layer??"front",m=s?.major,u=a?.major,h=w=>w!==void 0&&w!==false;if(!h(m)&&!h(u))return {group:null,layer:l};let c=m!==false,p=u!==false&&!!r,d=c?t.generateTicks().map(w=>w.x):void 0,g=p?r.generateTicks().map(w=>w.position):void 0;if(!d&&!g)return {group:null,layer:l};let f=(m&&typeof m=="object"?m:void 0)??(u&&typeof u=="object"?u:void 0),y=s?.minor,b=a?.minor,x=(y&&typeof y=="object"?y:void 0)??(b&&typeof b=="object"?b:void 0);return {group:{type:"group",cssClass:"chart-grid",sharedStyles:true,commands:[...y!==void 0||b!==void 0?Ut({xTicks:y!==false&&c?t.generateMinorTicks():void 0,yTicks:b!==false&&p?r.generateMinorTicks():void 0,xRange:i,yRange:o,stroke:x?.color,opacity:x?.opacity??(S.gridOpacity??1)*.5,dashed:x?.style==="dashed"}):[],...Ut({xTicks:d,yTicks:g,xRange:i,yRange:o,stroke:f?.color,opacity:f?.opacity,dashed:f?.style==="dashed"})]},layer:l}}function Jt(n){let e=[],t=r=>{r.type==="group"?r.commands.forEach(t):r.type==="line"&&r.y1===r.y2&&r.x1!==r.x2&&e.push(r.y1);};return n.forEach(t),e}function Qt(n,e){if(e.length===0||n.type!=="group")return n;let t=r=>r.type==="line"&&r.y1===r.y2&&r.x1!==r.x2&&e.some(i=>Math.abs(i-r.y1)<.5);return {...n,commands:n.commands.filter(r=>!t(r))}}function et(n,e,t){let r=(o,[s,a])=>o>=Math.min(s,a)&&o<=Math.max(s,a);if(!r(n.time,e.domain()))return false;if(n.value===void 0||!t)return true;let i=t.get(n.axis??0)??t.values().next().value;return !i||r(n.value,i.domain())}function en(n){let{annotations:e,timeScale:t,valueScales:r,plot:i}=n,o=[],s=l=>!i||et(l,t,r),a=l=>{let m=r.get(l.axis??0)??r.values().next().value;return {x:t.map(l.time),y:m?m.map(l.value):0}};for(let l of e){let m=[],u=p=>m.push(p);if((l.type==="point"||l.type==="label")&&!s(l.at))continue;let h=i!==void 0&&(l.type==="line"||l.type==="arrow"||l.type==="rect")&&!(s(l.from)&&s(l.to)),c=h?{clipRect:i}:{};switch(l.type){case "line":{let p=a(l.from),d=a(l.to);u({type:"line",x1:p.x,y1:p.y,x2:d.x,y2:d.y,stroke:l.color??S.annotationColor,strokeWidth:l.width??S.annotationWidth,dash:l.dash});break}case "arrow":{let p=a(l.from),d=a(l.to),g=l.color??S.annotationColor,f=l.headSize??S.annotationHead;u({type:"line",x1:p.x,y1:p.y,x2:d.x,y2:d.y,stroke:g,strokeWidth:l.width??S.annotationWidth});let y=Math.hypot(d.x-p.x,d.y-p.y)||1,b=(d.x-p.x)/y,x=(d.y-p.y)/y,v=d.x-b*f,w=d.y-x*f;u({type:"path",points:[{x:d.x,y:d.y},{x:v-x*f*.5,y:w+b*f*.5},{x:v+x*f*.5,y:w-b*f*.5}],fill:g,stroke:"none"});break}case "rect":{let p=a(l.from),d=a(l.to);u({type:"rect",x:Math.min(p.x,d.x),y:Math.min(p.y,d.y),w:Math.abs(d.x-p.x),h:Math.abs(d.y-p.y),fill:l.fill??"none",hatch:l.hatch,stroke:l.stroke,opacity:l.opacity});break}case "point":{let p=a(l.at),d=l.color??"#334155",g=l.radius??S.annotationRadius,f=l.shape??"circle";f==="circle"?u({type:"circle",cx:p.x,cy:p.y,r:g,fill:d}):f==="square"?u({type:"rect",x:p.x-g,y:p.y-g,w:g*2,h:g*2,fill:d}):(u({type:"line",x1:p.x-g,y1:p.y-g,x2:p.x+g,y2:p.y+g,stroke:d,strokeWidth:1.5}),u({type:"line",x1:p.x-g,y1:p.y+g,x2:p.x+g,y2:p.y-g,stroke:d,strokeWidth:1.5}));break}case "label":{let p=a(l.at);u({type:"text",content:l.text,x:p.x+(l.dx??0),y:p.y+(l.dy??0),anchor:l.anchor??Br(p.x+(l.dx??0),l.text,n),fontSize:S.annotationFontSize,fill:l.color??S.annotationColor,rotate:l.rotate});break}}if(l.id&&m.length>0){let p=Y(l.id);o.push({type:"group",cssClass:`annotation annotation--${p}`,...c,commands:m});}else h&&m.length>0?o.push({type:"group",cssClass:"annotation",...c,commands:m}):o.push(...m);}return o}function Br(n,e,t){let{metrics:r,timeScale:i}=t;if(!r)return "middle";let[o,s]=i.range(),a=r(e,S.annotationFontSize)/2;return n-a<o?"start":n+a>s?"end":"middle"}var ie=class n{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"series-"+ ++n.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var Ce=class extends ie{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=0;for(let r of this.data)r.count>t&&(t=r.count);return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??S.bandFill,r=e.hatch,i=e.avgLine??false,o=e.avgLineColor??S.bandAvgLine,s=e.bandWidth??10,a=[];for(let l of this.data){if(l.min===null||l.max===null)continue;let m=this.timeScale.map(l.time),u=e.valueScale.map(l.max),h=e.valueScale.map(l.min),c=s,p=this.data.indexOf(l);if(a.push({type:"rect",x:m-c/2,y:u,w:c,h:h-u,fill:t,hatch:r,opacity:this.opacity(l.count),id:this.id?`${this.id}-slot-${p}`:void 0}),i&&l.avg!==null){let d=e.valueScale.map(l.avg);a.push({type:"line",x1:m-c/2,y1:d,x2:m+c/2,y2:d,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${p}`:void 0});}}return a}};function tn(n,e,t,r,i,o,s){return Vt(n,e,{boundaries:[],yLow:a=>a.avg,yHigh:t,getValue:a=>a.avg,interpolate:E.interpolateAggregatedPoint,getColor:()=>r,getHatch:()=>i},{id:o,...s})}var Le=class extends ie{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??S.minColor,r=e.maxColor??S.maxColor,i=e.avgColor??S.avgColor,o=e.avgDashed??true,s=e.smoothing??false,a=e.smoothingType,l=e.strokeWidth??S.strokeWidth,m=E.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},h=[];m.forEach((d,g)=>{if(d.length<2)return;let f=y=>this.id?`${this.id}-${y}-${g}`:void 0;if(e.fillToMax){let y=tn(d,u,b=>b.max,e.fillToMax,e.fillToMaxHatch,f("fillToMax"),{smoothing:s,smoothingType:a});h.push(...y);}if(e.fillToMin){let y=tn(d,u,b=>b.min,e.fillToMin,e.fillToMinHatch,f("fillToMin"),{smoothing:s,smoothingType:a});h.push(...y);}});let c=m.filter(d=>d.length>=2),p=(d,g,f,y=false)=>Ht(c.map(b=>({data:b.map(x=>({time:x.time,value:d(x)}))})),u,{stroke:g,strokeWidth:l,smoothing:s,smoothingType:a,dashed:y,id:this.id?`${this.id}-${f}`:void 0});return h.push(...p(d=>d.max,r,"max"),...p(d=>d.min,t,"min"),...p(d=>d.avg,i,"avg",o)),h}};function ke(n){return {id:n.id,line:{stroke:n.stroke??S.stroke,strokeWidth:n.strokeWidth??S.strokeWidth,smoothing:n.smoothing??false,smoothingType:n.smoothingType,dashed:n.dashed??false},fill:n.fill??S.areaFillAlpha,markers:{type:n.pointStyle??"none",size:n.pointSize??S.pointSize,stroke:n.stroke??S.stroke,fill:"#ffffff"},shadow:{color:n.shadowColor??"transparent",blur:n.shadowBlur??0,offsetX:n.shadowOffsetX??0,offsetY:n.shadowOffsetY??0}}}function nn(n,e,t,r){let i=ke(t);if(!i.markers.type||i.markers.type==="none")return [];let o=[];for(let s=0;s<n.length;s++){let a=n[s],l=e.timeScale.map(a.time),m=e.valueScale.map(a.value),u=r(a),h=t.pointStroke??u,c=t.pointFill??u,p=t.pointStrokeWidth??1.5,d=t.id?`${t.id}-marker-${s}`:void 0;De(o,d,i.markers.type,l,m,i.markers.size,h,c,p);}return o.length===0?[]:[{type:"group",cssClass:"series-markers",sharedStyles:true,commands:o}]}function De(n,e,t,r,i,o,s,a,l){let m=u=>e===void 0?void 0:`${e}-${u}`;switch(t){case "circle":n.push({type:"circle",cx:r,cy:i,r:o,fill:a,stroke:s,strokeWidth:l,id:e});break;case "square":n.push({type:"rect",x:r-o,y:i-o,w:o*2,h:o*2,fill:a,stroke:s,strokeWidth:l,id:e});break;case "cross":n.push({type:"line",x1:r-o,y1:i-o,x2:r+o,y2:i+o,stroke:s,strokeWidth:l,id:e},{type:"line",x1:r-o,y1:i+o,x2:r+o,y2:i-o,stroke:s,strokeWidth:l,id:m(2)});break;case "diamond":n.push({type:"path",points:[{x:r,y:i-o},{x:r+o,y:i},{x:r,y:i+o},{x:r-o,y:i}],closed:true,fill:a,stroke:s,strokeWidth:l,id:e});break;case "triangle":n.push({type:"path",points:[{x:r,y:i-o},{x:r+o,y:i+o},{x:r-o,y:i+o}],closed:true,fill:a,stroke:s,strokeWidth:l,id:e});break;case "star":{let u=[];for(let h=0;h<10;h++){let c=h%2===0?o:o*.5,p=Math.PI/2*3+h*Math.PI/5;u.push({x:r+c*Math.cos(p),y:i+c*Math.sin(p)});}n.push({type:"path",points:u,closed:true,fill:a,stroke:s,strokeWidth:l,id:e});break}case "arrow":n.push({type:"path",points:[{x:r-o,y:i+o},{x:r,y:i-o},{x:r+o,y:i+o}],stroke:s,strokeWidth:l,fill:"none",id:e});break;case "plus":n.push({type:"line",x1:r-o,y1:i,x2:r+o,y2:i,stroke:s,strokeWidth:l,id:e},{type:"line",x1:r,y1:i-o,x2:r,y2:i+o,stroke:s,strokeWidth:l,id:m(2)});break;case "triangle-down":n.push({type:"path",points:[{x:r,y:i+o},{x:r+o,y:i-o},{x:r-o,y:i-o}],closed:true,fill:a,stroke:s,strokeWidth:l,id:e});break;case "hexagon":{let u=[];for(let h=0;h<6;h++){let c=h*(Math.PI/3);u.push({x:r+o*Math.cos(c),y:i+o*Math.sin(c)});}n.push({type:"path",points:u,closed:true,fill:a,stroke:s,strokeWidth:l,id:e});break}case "hourglass":n.push({type:"path",points:[{x:r-o,y:i-o},{x:r+o,y:i-o},{x:r-o,y:i+o},{x:r+o,y:i+o}],closed:true,fill:a,stroke:s,strokeWidth:l,id:e});break;case "line-horizontal":n.push({type:"line",x1:r-o,y1:i,x2:r+o,y2:i,stroke:s,strokeWidth:l,id:e});break;default:n.push({type:"circle",cx:r,cy:i,r:o,fill:a,stroke:s,strokeWidth:l,id:e});}}function rn(n){let{markers:e,timeScale:t,valueScale:r,yRange:i=[0,300]}=n,[o,s]=i,a=[];for(let l of e){let m=t.map(l.time),u=l.color??S.markerColor,h=l.pointStyle??(l.value!==void 0?"circle":"none"),c=l.lineStyle??"full";if(l.value!==void 0){let p=r.map(l.value);if(c==="to-value"?a.push({type:"line",x1:m,y1:s,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):c==="to-top"?a.push({type:"line",x1:m,y1:o,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):c==="full"&&a.push({type:"line",x1:m,y1:o,x2:m,y2:s,stroke:u,strokeWidth:1}),h!=="none"&&De(a,void 0,h,m,p,S.markerSize,u,u,1.5),l.label){let d=c==="to-value"?p-10:o-6;a.push({type:"text",content:l.label,x:m,y:d,anchor:"middle",fontSize:S.markerFontSize,fill:u});}}else c!=="none"&&a.push({type:"line",x1:m,y1:o,x2:m,y2:s,stroke:u,strokeWidth:1}),l.label&&a.push({type:"text",content:l.label,x:m,y:o-6,anchor:"middle",fontSize:S.markerFontSize,fill:u});}return a}function on(n){let e=[],t=n.markers.filter(i=>et({time:i.time},n.timeScale)).map(i=>({...i}));for(let i of t)if(i.value===void 0&&(i.lineStyle==="to-value"||i.lineStyle==="to-top")){let o=n.series[i.seriesIndex??0];o&&!O(o)&&o.data.length>=2&&(i.value=jr(i.time,o.data));}if(t.length>0&&n.primaryScale){let i=[];for(let o of t){let s=n.primaryScale,a=n.series[o.seriesIndex??0];a&&(s=n.valueScales.get(n.achseVon(a))??n.primaryScale),i.push(...rn({markers:[o],timeScale:n.timeScale,valueScale:s,yRange:n.yRange}));}e.push({type:"group",cssClass:"markers",commands:i});}let r=n.annotations;return r.length>0&&e.push({type:"group",cssClass:"annotations",commands:en({annotations:r,timeScale:n.timeScale,valueScales:n.valueScales,metrics:n.metrics,plot:n.plot})}),e}function jr(n,e){for(let t=1;t<e.length;t++){let r=e[t-1],i=e[t];if(!(r.value===null||i.value===null)&&n>=r.time&&n<=i.time){if(i.time===r.time)return r.value;let o=(n-r.time)/(i.time-r.time);return r.value+o*(i.value-r.value)}}}var Fr=(()=>{let n=new Array(256);for(let e=0;e<256;e++){let t=e;for(let r=0;r<8;r++)t=t&1?3988292384^t>>>1:t>>>1;n[e]=t>>>0;}return n})();function tt(n){let e=new TextEncoder().encode(n),t=4294967295;for(let r of e)t=Fr[(t^r)&255]^t>>>8;return (t^4294967295)>>>0}function N(n,e){return e||"s-"+tt(n??"").toString(16).padStart(8,"0")}function sn(n,e,t){let r=n.style?.line&&!Array.isArray(n.style.line)?n.style.line:void 0,i=typeof n.style?.fill=="string"?n.style.fill:void 0;return n.showAs==="minmaxavg"?new Le({data:n.data,timeScale:e,valueScale:t,minColor:n.minColor,maxColor:n.maxColor,avgColor:n.avgColor,avgDashed:n.avgDashed,fillToMax:n.fillToMax,fillToMaxHatch:n.fillToMaxHatch,fillToMin:n.fillToMin,fillToMinHatch:n.fillToMinHatch,smoothing:r?.smoothing,smoothingType:r?.smoothingType,strokeWidth:r?.width,id:N(n.name,n.id)}).render():new Ce({data:n.data,timeScale:e,valueScale:t,fill:i??r?.color,avgLine:n.avgLine,countOpacity:n.countOpacity,id:N(n.name,n.id)}).render()}function an(n,e,t){let r=n??[];return {grenzen:r.map(o=>e.get(o)).filter(o=>!!o).map(o=>o.value).sort((o,s)=>o-s),farbe(o,s){let a=s??t,l=Number.NEGATIVE_INFINITY;for(let m of r){let u=e.get(m);!u||o<u.value||u.value<l||(l=u.value,a=u.color??a);}return a}}}function ln(n,e,t){if(!n.holdToEnd)return;let r=n.data.at(-1);if(!r||r.value===null)return;let i=t??e.domain()[1],o=typeof n.holdToEnd=="object"?n.holdToEnd.maxAgeMs:void 0;return o!==void 0&&(i=Math.min(i,r.time+o)),i>r.time?i:void 0}function $e(n,e){if(e===void 0||n.length===0)return n;let t=n[n.length-1],r=t[t.length-1];return [...n.slice(0,-1),[...t,{time:e,value:r.value}]]}function mn(n){let{series:e,ctx:t,runs:r,haltBis:i,totalPoints:o,style:s,styleLine:a,styleMarkers:l,stepShape:m,thresholds:u}=n,{timeScale:h,valueScale:c}=t,p=[],d=an(e.colorByThresholds,u,s.stroke),g=d.grenzen,f=new Map,y=[];for(let x of r){let k=function(_){let C=x===r[r.length-1]?$e([x],i)[0]:x;return E.splitByBoundaries(_==="step"?X(C):C,g,$=>$.value,E.interpolateDataPoint)};if(x.length<1)continue;let v=N(e.name,e.id),w=new Map,R=_=>{let C=w.get(_);return C||(C=k(_),w.set(_,C)),C},M=(_,C,$)=>{let I=R(_);for(let j of I){let B=j,H=f.get($)??0;if(f.set($,H+1),B.data.length<1)continue;let V=B.zoneLow;if(B.data.length===1){let A=d.farbe(V,C.color);p.push({type:"circle",id:v?`${v}-dot-${H}${$}`:void 0,cx:h.map(B.data[0].time),cy:c.map(B.data[0].value),r:Math.max(s.pointSize??S.pointSize,C.width??s.strokeWidth??S.strokeWidth),fill:A,shadowColor:s.shadowColor,shadowBlur:s.shadowBlur});continue}p.push({type:"path",cssClass:"series-line",id:v?`${v}-line-${H}${$}`:void 0,points:B.data.map(A=>({x:h.map(A.time),y:c.map(A.value)})),stroke:d.farbe(V,C.color),strokeWidth:C.width??s.strokeWidth,smoothing:_==="step"?false:C.smoothing??s.smoothing,smoothingType:C.smoothingType??s.smoothingType,dash:C.style,opacity:C.opacity,fill:"none",shadowColor:s.shadowColor,shadowBlur:s.shadowBlur,shadowOffsetX:s.shadowOffsetX,shadowOffsetY:s.shadowOffsetY});}};a===false||(Array.isArray(a)?a.forEach((_,C)=>{M(_.shape??(e.seriesType==="step"?"step":"line"),_,`-${C}`);}):M(m?"step":"line",a??{},"")),y.push(...x);}return s.pointStyle&&s.pointStyle!=="none"&&o<=(l?.threshold??S.pointThreshold)&&p.push(...nn(y,t,s,x=>d.farbe(x.value))),p}function hn(n,e){for(let t of n){if(t.length===0||e<t[0].time||e>t[t.length-1].time)continue;let r=0;for(;r<t.length-1&&t[r+1].time<=e;)r++;return {lauf:t,i:r}}return null}function Pe(n,e,t){if(n.art==="fest")return n.wert;let r=hn(n.laeufe,e);if(!r)return null;let{lauf:i,i:o}=r,s=i[o];if(n.stufe)return t&&s.time===e&&o>0?i[o-1].value:s.value;if(s.time===e||o===i.length-1)return s.value;let a=i[o+1];return s.value+(a.value-s.value)*(e-s.time)/(a.time-s.time)}function un(n,e,t){if(n.art==="fest")return true;let r=hn(n.laeufe,e);return r?t===void 0||e-r.lauf[r.i].time<=t:false}function cn(n,e,t){let r=t.exceeds,i=t.side??"both",o=new Set;for(let m of [n,e])if(m.art==="laeufe")for(let u of m.laeufe)for(let h of u)o.add(h.time),t.maxAgeMs!==void 0&&o.add(h.time+t.maxAgeMs);let s=[...o].sort((m,u)=>m-u),a=[];for(let m=0;m+1<s.length;m++){let[u,h]=[s[m],s[m+1]],c=(u+h)/2;if(!un(n,c,t.maxAgeMs)||!un(e,c,t.maxAgeMs))continue;let p=Pe(e,u,false)-Pe(n,u,false),d=Pe(e,h,true)-Pe(n,h,true),g=(f,y)=>{if(f<=0&&y<=0)return null;if(f>0&&y>0)return [u,h];let b=u+(0-f)/(y-f)*(h-u);return f>0?[u,b]:[b,h]};if(i!=="below"){let f=g(p-r,d-r);f&&f[1]>f[0]&&a.push(f);}if(i!=="above"){let f=g(-p-r,-d-r);f&&f[1]>f[0]&&a.push(f);}}a.sort((m,u)=>m[0]-u[0]);let l=[];for(let m of a){let u=l[l.length-1];u&&m[0]<=u[1]?u[1]=Math.max(u[1],m[1]):l.push([m[0],m[1]]);}return l}function dn(n,e,t,r,i,o){let s=0,a=l=>l.type==="group"?{...l,commands:l.commands.map(a)}:"id"in l&&l.id!==void 0?{...l,...o(s++)}:l;return e.map(([l,m])=>{let u=t.map(l);return {type:"group",clipRect:{x:u,y:r,w:t.map(m)-u,h:i-r},commands:n.map(a)}})}function q(n){return n!==void 0&&typeof n=="object"&&"series"in n?n.series:null}function pn(n){let e=[...n].sort((r,i)=>r.time-i.time),t=0;return r=>{for(;t>0&&e[t].time>r;)t--;for(;t<e.length-1&&e[t+1].time<=r;)t++;let i=e[t];if(!i||r<i.time)return null;if(i.time===r)return i.value??null;let o=e[t+1];if(!o||r>o.time||i.value===null||o.value===null)return null;let s=o.time-i.time;return s===0?i.value:i.value+(o.value-i.value)*(r-i.time)/s}}function fn(n){let e=[...n].sort((r,i)=>r.time-i.time),t=new Map;for(let r=1;r<e.length;r++){let[i,o]=[e[r-1],e[r]];i.time===o.time&&i.value!==null&&!t.has(i.time)&&t.set(i.time,i.value);}return t}function gn(n,e,t){let r=n??e;if(r==="series")return null;if(r==="chartTop")return t.chartTop;if(r==="chartBottom")return t.chartBottom;if(typeof r=="object"&&"threshold"in r){let i=t.thresholds.get(r.threshold);if(!i)throw new Error(`fillSpec region references unknown threshold '${r.threshold}'`);return t.valueScale.map(i.value)}return typeof r=="object"&&"value"in r?t.valueScale.map(r.value):null}function Er(n){return typeof n=="string"?{color:n}:{color:n.color,hatch:n.hatch}}function yn(n,e){let t=q(n);if(t!==null){let i=e.fremdeSerie?.(t);return i?{art:"laeufe",laeufe:E.getRuns(i.data,o=>o.value===null,i.gapThreshold),stufe:i.shape==="step"}:null}if(n==="series")return {art:"laeufe",laeufe:e.runs,stufe:e.shape==="step"};let r=e.valueScale.domain();return {art:"fest",wert:he(n,e)??(n==="chartBottom"?r[0]:r[1])}}function bn(n,e,t){let r=Gr(n,e,t);if(!n.where||r.length===0)return r;let i=yn(n.from??"chartBottom",e),o=yn(n.to??"series",e);return !i||!o?r:dn(r,cn(i,o,n.where),e.timeScale,e.chartTop,e.chartBottom,s=>e.idPrefix?{id:`${e.idPrefix}-fill-r${t}-${s}`}:{})}function Gr(n,e,t){let r=gn(n.from,"chartBottom",e),i=gn(n.to,"series",e),{color:o,hatch:s}=Er(n.fill),m={attrs:{type:"path",fill:o,hatch:s,stroke:"none",cssClass:"series-fill"},teilId:u=>e.idPrefix?{id:`${e.idPrefix}-fill-r${t}-${u}`}:{}};return q(n.from)!==null||q(n.to)!==null?Ir(n,e,m):r!==null&&i!==null?Wr(r,i,e,m):zr(n,e,r,i,m)}function Or(n,e,t){let r=e.shape==="step",i=(c,p)=>{let d=c??p,g=q(d);if(g!==null){let b=e.fremdeSerie(g);if(!b)return null;let x=b.shape==="step",v=E.getRuns(b.data,w=>w.value===null,b.gapThreshold).map(w=>x?X(w):w);return {art:"fremd",skala:b.valueScale??e.valueScale,laeufe:v,glatt:!x&&!!b.smoothing,verfahren:b.smoothingType}}if(d==="series")return {art:"eigene",glatt:!r&&!!e.smoothing,verfahren:e.smoothingType};let f=he(d,e),y=e.valueScale.domain();return {art:"fest",wert:f??(d==="chartBottom"?y[0]:y[1]),glatt:false}},o=i(n.from,"chartBottom"),s=i(n.to,"series");if(!o||!s||!o.glatt&&!s.glatt)return null;let a=c=>c.art==="fremd"?c.skala:e.valueScale,l=c=>p=>({x:e.timeScale.map(p.time),y:c.map(p.value)}),m=(c,p)=>c.art==="eigene"?[p]:c.art==="fremd"?c.laeufe.filter(d=>d.length>=2):[null],u=(c,p,d,g)=>p?p.map(l(a(c))):[d,g].map(f=>({x:e.timeScale.map(f),y:e.valueScale.map(c.wert)})),h=[];for(let c of e.runs){if(c.length<2)continue;let p=r?X(c):c;for(let d of m(o,p))for(let g of m(s,p)){let f=Math.max(p[0].time,d?.[0].time??-1/0,g?.[0].time??-1/0),y=Math.min(p.at(-1).time,d?.at(-1)?.time??1/0,g?.at(-1)?.time??1/0);if(!(y>f))continue;let b={k:o,pts:u(o,d,f,y)},x={k:s,pts:u(s,g,f,y)};b.k.glatt||([b,x]=[x,b]);let v=k=>(k.art==="fest"?void 0:k.verfahren)??"catmull-rom",w=e.timeScale.map(f);h.push({type:"group",clipRect:{x:w,y:e.chartTop,w:e.timeScale.map(y)-w,h:e.chartBottom-e.chartTop},commands:[{...t.attrs,...t.teilId(h.length),points:[...b.pts,...[...x.pts].reverse()],smoothing:true,smoothingType:v(b.k),smoothCount:b.pts.length,...x.k.glatt?{smoothTail:x.pts.length,smoothTailType:v(x.k)}:{}}]});}}return h}function Ir(n,e,t){if(!e.fremdeSerie){let a=q(n.from)??q(n.to);throw new Error(`fillSpec region references series '${a}', but no series lookup was provided`)}let r=Or(n,e,t);if(r)return r;let i=(a,l,m)=>{let u=a??l,h=q(u);if(h!==null){let g=e.fremdeSerie(h);if(!g)throw new Error(`fillSpec region references unknown series '${h}'`);let f=g.shape==="step"?X(g.data):g.data;return {bei:pn(f),davor:fn(f),zeiten:f.map(y=>y.time),skala:g.valueScale??e.valueScale}}if(u==="series")return {bei:pn(m),davor:fn(m),zeiten:m.map(g=>g.time),skala:e.valueScale};let c=he(u,e),p=e.valueScale.domain(),d=c??(u==="chartBottom"?p[0]:p[1]);return {bei:()=>d,zeiten:[],skala:e.valueScale}},o=e.shape==="step",s=[];for(let a of e.runs){if(a.length<2)continue;let l=o?X(a):a,m=i(n.from,"chartBottom",l),u=i(n.to,"series",l),h=l[0].time,c=l[l.length-1].time,p=[...new Set([...m.zeiten,...u.zeiten,...l.map(y=>y.time)])].filter(y=>y>=h&&y<=c).sort((y,b)=>y-b),d=[],g=[],f=()=>{if(d.length>=2){let y=[...g].reverse();s.push({...t.attrs,...t.teilId(s.length),smoothing:o?false:e.smoothing,smoothingType:e.smoothingType,smoothCount:d.length,points:[...d,...y]});}d=[],g=[];};for(let y of p){let b=m.bei(y),x=u.bei(y);if(b===null||x===null){f();continue}let v=e.timeScale.map(y),w=m.davor?.get(y)??b,k=u.davor?.get(y)??x;(w!==b||k!==x)&&(d.push({x:v,y:u.skala.map(k)}),g.push({x:v,y:m.skala.map(w)})),d.push({x:v,y:u.skala.map(x)}),g.push({x:v,y:m.skala.map(b)});}f();}return s}function Wr(n,e,t,r){let i=t.timeScale.range(),o=i[0],s=i[1],a=Math.min(n,e),l=Math.max(n,e);return [{...r.attrs,...r.teilId(0),points:[{x:o,y:a},{x:s,y:a},{x:s,y:l},{x:o,y:l}]}]}function zr(n,e,t,r,i){let o=t??r,s=[],a=Hr(n,e);if(a===null){let u=e.valueScale.domain();a=(t??r)===e.chartBottom?u[0]:u[1];}let l=he(n.outer,e),m=e.shape==="step";for(let u of e.runs){if(u.length<2)continue;let h=m?X(u):u,c=E.splitByThreshold(h,a,d=>d.value??a,E.interpolateDataPoint),p=n.side==="above"?c.above:n.side==="below"?c.below:[...c.above,...c.below];if(l!==null&&n.side){let d=l,g=n.side==="above"?f=>Math.min(f,d):f=>Math.max(f,d);p=p.map(f=>f.map(y=>({...y,value:g(y.value??d)})));}for(let d of p){if(d.length<2)continue;let g=d.map(y=>({x:e.timeScale.map(y.time),y:e.valueScale.map(y.value)})),f=[];for(let y of [...g].reverse()){let b=f[f.length-1];m&&b&&b.x===y.x||f.push({x:y.x,y:o});}s.push({...i.attrs,...i.teilId(s.length),smoothing:m?false:e.smoothing,smoothingType:e.smoothingType,smoothCount:g.length,points:[...g,...f]});}}return s}function Hr(n,e){let t=n.from==="series"?n.to:n.from;return he(t,e)}function he(n,e){return n===void 0||n==="series"||n==="chartTop"||n==="chartBottom"?null:typeof n=="object"&&"threshold"in n?e.thresholds.get(n.threshold)?.value??null:typeof n=="object"&&"value"in n?n.value:null}function xn(n,e){if(typeof n=="string"||!("regions"in n))return bn({fill:n},e,0);let t=[];return n.regions.forEach((r,i)=>{t.push(...bn(r,e,i));}),t}function wn(n){let e=n.style?.line,t=e&&!Array.isArray(e)?e:void 0;return {color:t?.color??S.stroke,width:t?.width??S.strokeWidth,dash:t?.style,smoothing:t?.smoothing??false,smoothingType:t?.smoothingType}}function Sn(n,e,t,r,i){let o=n.filter(m=>m.value!==null);if(o.length<2)return [];let s=wn(t);e.merke?.({index:i,kind:t.kind,punkte:o.map(m=>({time:m.time,value:m.value})),farbe:s.color,...s.dash?{linie:s.dash}:{}});let a=o.map(m=>({x:e.timeScale.map(m.time),y:e.valueScale.map(m.value)}));return [{type:"path",cssClass:"series-line",id:e.idPrefix?`${e.idPrefix}-overlay-${i}-${r}`:`overlay-${i}-${r}`,points:a,stroke:s.color,strokeWidth:s.width,smoothing:s.smoothing,smoothingType:s.smoothingType,dash:s.dash,fill:"none"}]}function vn(n,e,t=0){switch(n.kind){case "movingAverage":{let r=n.type==="exponential"?zt(e.data,n.window):Je(e.data,n.window);return Sn(r,e,n,"movingAvg",t)}case "movingMkt":{let r=It(e.data,n.window,n.activationEnergy);return Sn(r,e,n,"movingMkt",t)}case "limits":{let r=[],i=e.timeScale.range(),o=i[0],s=i[1],a=wn(n),l=a.color,m=a.width,u=a.dash??"dashed",h=e.idPrefix?`${e.idPrefix}-overlay-${t}-`:`overlay-${t}-`;return n.high!==void 0&&r.push({type:"line",id:`${h}limit-high`,x1:o,y1:e.valueScale.map(n.high),x2:s,y2:e.valueScale.map(n.high),stroke:l,strokeWidth:m,dash:u}),n.low!==void 0&&r.push({type:"line",id:`${h}limit-low`,x1:o,y1:e.valueScale.map(n.low),x2:s,y2:e.valueScale.map(n.low),stroke:l,strokeWidth:m,dash:u}),r}case "stdDevBand":{let r=n.multiplier??1,i=Je(e.data,n.window),o=Wt(e.data,n.window),s=[],a=[],l=[];for(let y=0;y<i.length;y++){let b=i[y].value,x=o[y].value;if(b===null||x===null)continue;let v=e.timeScale.map(i[y].time);s.push({x:v,y:e.valueScale.map(b+r*x)}),a.push({x:v,y:e.valueScale.map(b-r*x)}),l.push({time:i[y].time,value:b,low:b-r*x,high:b+r*x});}if(s.length<2)return [];let m=e.idPrefix?`${e.idPrefix}-overlay-${t}-`:`overlay-${t}-`,u=[],c=(typeof n.style?.fill=="string"||n.style?.fill&&!("regions"in n.style.fill)?n.style.fill:void 0)??"#94a3b833",{color:p,hatch:d}=Vr(c);u.push({type:"path",cssClass:"series-fill",id:`${m}stdDevBand`,points:[...s,...[...a].reverse()],fill:p,hatch:d,stroke:"none"});let g=n.style?.line,f=g&&!Array.isArray(g)?g:void 0;if(e.merke?.({index:t,kind:"stdDevBand",punkte:l,farbe:f?f.color??S.stroke:p,...f?.style?{linie:f.style}:{}}),f){let y=i.filter(b=>b.value!==null).map(b=>({x:e.timeScale.map(b.time),y:e.valueScale.map(b.value)}));y.length>=2&&u.push({type:"path",cssClass:"series-line",id:`${m}stdDevBand-mean`,points:y,stroke:f.color??S.stroke,strokeWidth:f.width??1.5,smoothing:f.smoothing,smoothingType:f.smoothingType,dash:f.style,fill:"none"});}return u}}}function Vr(n){return typeof n=="string"?{color:n}:{color:n.color,hatch:n.hatch}}function Tn(n,e){let t=n.style?.line,r=t&&!Array.isArray(t)?t:void 0,i=Array.isArray(t)?t[0]:r,o=(i?.shape??n.seriesType)==="step",s=i||void 0,a=s?.gapThreshold??e??S.gapThreshold;return {styleLine:t,lineDefaults:r,gapThreshold:a,grundLinie:s,stepShape:o}}function kn(n,e,t,r,i=0){let o=n.timeScale,s={timeScale:o,valueScale:t};if(O(e))return sn(e,o,t);let{lineDefaults:a,gapThreshold:l}=n.linienGrundlage(e),m=E.getRuns(e.data,k=>k.value===null,l),u=m.reduce((k,R)=>k+R.length,0);if(u===0)return [];let h=[],c=e.style?.markers,p=e.style?.shadow,d={stroke:a?.color??n.palettenFarbe(i),strokeWidth:a?.width??S.strokeWidth,smoothing:a?.smoothing,smoothingType:a?.smoothingType,dashed:a?.style==="dashed",pointStyle:c?.type,pointSize:c?.size,pointStroke:c?.stroke,pointFill:c?.fill,pointStrokeWidth:c?.strokeWidth,shadowColor:p?.color,shadowBlur:p?.blur,shadowOffsetX:p?.offsetX,shadowOffsetY:p?.offsetY,id:N(e.name,e.id)},{styleLine:g,grundLinie:f,stepShape:y}=n.linienGrundlage(e),b=ln(e,o,n.jetzt),x=$e(m,b),v=e.style?.fill;if(v!==void 0){let k=t.range(),R=Math.min(k[0],k[1]),M=Math.max(k[0],k[1]);h.push(...xn(v,{runs:x,timeScale:o,valueScale:t,thresholds:r,chartTop:R,chartBottom:M,smoothing:f?.smoothing,smoothingType:f?.smoothingType,shape:y?"step":"line",fremdeSerie:_=>{let C=n.alleReihen.find(B=>(B.id??B.name)===_||B.name===_);if(!C||!("data"in C))return;let $=C.data;if($.length===0||!("value"in $[0]))return;let I=n.linienGrundlage(C),j=I.grundLinie;return {data:$,shape:I.stepShape?"step":"line",smoothing:j?.smoothing,smoothingType:j?.smoothingType,gapThreshold:I.gapThreshold,valueScale:n.valueScales.get(n.achseVon(C))}},idPrefix:N(e.name,e.id)}));}h.push(...mn({series:e,ctx:s,runs:m,haltBis:b,totalPoints:u,style:d,styleLine:g,styleMarkers:c,stepShape:y,thresholds:r}));let w=e.overlays;if(w&&w.length>0){let k=t.range(),R={data:e.data,timeScale:o,valueScale:t,chartTop:Math.min(k[0],k[1]),chartBottom:Math.max(k[0],k[1]),idPrefix:N(e.name,e.id),merke:M=>{n.merkeOverlay(i,M);}};w.forEach((M,_)=>{h.push(...vn(M,R,_));});}return e.style?.gap&&m.length>1&&h.push(...Mt({gap:e.style.gap,runs:m,timeScale:o,valueScale:t,metrics:n.textMetrics,lineColor:a?.color})),h}function _n(n,e,t){if(!e)return n;let r=`${e}-`,i=s=>s.split(/\s+/).filter(Boolean).map(a=>t.has(a)?a:r+a).join(" "),o=s=>{let a={...s};return a.cssClass&&(a.cssClass=i(a.cssClass)),a.type==="group"&&(a.commands=a.commands.map(o)),a};return n.map(o)}function An(n,e,t){let i=new Array(n.length),o=e.map(s=>({position:s.position,von:s.von,bis:s.bis}));n.forEach((s,a)=>{if(s.fest===void 0)return;let l=s.position==="left"?s.achseX-s.fest:s.achseX+s.fest,m=s.schrift/2;o.push({position:s.position,von:l-m-1,bis:l+m+1,titel:true}),i[a]=l;});for(let s of ["left","right"]){let a=s==="left",l=n.map((m,u)=>({t:m,i:u})).filter(m=>m.t.position===s&&m.t.fest===void 0).sort((m,u)=>a?u.t.achseX-m.t.achseX:m.t.achseX-u.t.achseX);for(let{t:m,i:u}of l){let h=m.schrift/2,c=o.filter(g=>g.position===s),p=m.kante,d=a?p-1-h:p+1+h;for(let g=0;g<=c.length;g++){let f=d-h-1,y=d+h+1,b=c.find(x=>f<x.bis&&x.von<y);if(!b)break;p=a?b.von:b.bis,d=a?p-1-h:p+1+h;}if(a?d-h<2:d+h>t-2){let g=o.filter(f=>f.position===s&&f.titel);d=a?h+2:t-h-2;for(let f=0;f<=g.length;f++){let y=d-h-1,b=d+h+1,x=g.find(v=>y<v.bis&&v.von<b);if(!x)break;d=a?x.bis+1+h:x.von-1-h;}}o.push({position:s,von:d-h-1,bis:d+h+1,titel:true}),i[u]=d;}}return {xs:i,belegt:o}}function Mn(n){let{axes:e,neueForm:t,achsenTitel:r,titelSpuren:i,layout:o}=n,{chartX:s,chartY:a,chartWidth:l,chartHeight:m}=o,u=t?void 0:e?.left?.label,h=t?void 0:e?.right?.label,c=e?.x?.label;if(!u&&!h&&!c&&r.length===0)return [];let p=[],d=a+m/2,g=e?.left?.labels,f=e?.right?.labels,y=e?.x?.labels,b=e?.left?.labelOffset,x=e?.right?.labelOffset;return u&&p.push({type:"text",content:u,x:b===void 0?14:s-(e?.left?.offset??0)-b,y:d,anchor:"middle",fontSize:g?.fontSize??S.axisLabelSize,fill:g?.color??S.axisLabelColor,rotate:-90}),h&&p.push({type:"text",content:h,x:x===void 0?o.totalWidth-14:s+l+(e?.right?.offset??0)+x,y:d,anchor:"middle",fontSize:f?.fontSize??S.axisLabelSize,fill:f?.color??S.axisLabelColor,rotate:90}),r.forEach((v,w)=>{p.push({type:"text",content:v.text,x:i[w],y:d,anchor:"middle",fontSize:v.style?.fontSize??S.axisLabelSize,fill:v.style?.color??S.axisLabelColor,rotate:v.position==="right"?90:-90});}),c&&p.push({type:"text",content:c,x:s+l/2,y:o.totalHeight-6-(n.untenBelegt??0),anchor:"middle",fontSize:y?.fontSize??S.axisLabelSize,fill:y?.color??S.axisLabelColor}),p.length===0?[]:[{type:"group",cssClass:"axis-labels",commands:p}]}var K=class{_layout;_idPraefix;_klassenPraefix;_renderer;_locale;_timeZone;_fontFamily;_legend;_textMetrics;_theme;_overlayWerte=new Map;_clipSeries;_markers;_thresholds;_highlights;_gaps;_gapsBand;_gapsAutoDetect;_gapsMinGapMs;_gapsAtEnd;_annotations;_annotationBands;_disabledAnnotations=new Set;_annotationSeq=0;_axes;_series;_timeScale;_valueScales=new Map;constructor(e={}){this._layout=new se({width:e.width??800,height:e.height??400,margin:e.margin??{top:20,right:20,bottom:40,left:60}}).compute(),this._renderer=e.renderer,this._locale=e.locale,this._timeZone=e.timeZone,this._fontFamily=e.fontFamily,this._idPraefix=e.idPrefix,this._klassenPraefix=e.classPrefix,this._legend=e.legend,this._textMetrics=e.textMetrics??G,this._theme=e.theme,this._clipSeries=e.clipSeries??true,this._markers=e.markers??[],this._thresholds=e.thresholds??[],this._highlights=e.highlights??[];let t=dt(e.gaps);this._gaps=t.gaps,this._gapsAutoDetect=t.autoDetect,this._gapsMinGapMs=t.minGapMs,this._gapsBand=t.band,this._gapsAtEnd=t.atEnd,this._annotations=e.annotations??[],this._annotationBands=e.annotationBands??[],this._axes=e.axes,this._series=[],e.series&&this.setData(e.series);}getWidth(){return this._layout.totalWidth}getHeight(){return this._layout.totalHeight+this._annotationBandTotalHeight()}get series(){return this._series}_annotationBandTotalHeight(){let e=0;for(let t of this._annotationBands){let r=t.height??12,i=t.spacing??0;(t.showAxis??false)&&(e+=26+i),e+=r+i;}return e}setData(e){this._series=e.filter(t=>Array.isArray(t.data));}addAnnotation(e){let t=e.id??`anno-${++this._annotationSeq}`;return this._annotations.push({...e,id:t}),t}removeAnnotation(e){let t=this._annotations.length;return this._annotations=this._annotations.filter(r=>r.id!==e),this._disabledAnnotations.delete(e),this._annotations.length<t}setAnnotations(e){this._annotations=[...e],this._disabledAnnotations.clear();}clearAnnotations(){this._annotations=[],this._disabledAnnotations.clear();}getAnnotations(){return this._annotations}disableAnnotation(e){this._disabledAnnotations.add(e);}enableAnnotation(e){this._disabledAnnotations.delete(e);}_axisIndexOf(e){return e.yAxisIndex??0}_timesOf(e){return e.data.map(t=>t.time)}_layoutMitLegende(){let e=Yt({legend:this._legend,items:this._legendItems(),gesamtbreite:this._layout.totalWidth,metrics:this._textMetrics}),t=this._layout,r=Xt(e,this._layout.margin);return r&&(t=new se({width:this._layout.totalWidth,height:this._layout.totalHeight,margin:r}).compute()),{layout:t,legende:e}}renderCommands(){let e=this._klassenPraefix,t=new Set((this._legend?.itemClass??"").split(/\s+/).filter(Boolean));return le(this._theme,()=>_n(this._zeichne(),e,t))}_zeichne(){if(this._overlayWerte.clear(),this._series.length===0)return [];let{layout:e,legende:t}=this._layoutMitLegende(),{chartX:r,chartY:i,chartWidth:o,chartHeight:s}=e,a=[r,r+o],l=[i,i+s],m=[];for(let A of this._series)A.data.sort((L,D)=>L.time-D.time);let u=new Map,h=1/0,c=-1/0,p=false;for(let A of this._series){let L=this._axisIndexOf(A),D=u.get(L);D?D.push(A):u.set(L,[A]);for(let F of this._timesOf(A))F<h&&(h=F),F>c&&(c=F),p=true;}if(!p)return [];let d=this._axes?.x?.domain,g=d&&d!=="auto"?d:[h,c];this._timeScale=new ee({domain:g,range:a,locale:this._locale,timeZone:this._timeZone});let f=new ne({domain:g,xRange:a,y:i+s,locale:this._locale,timeZone:this._timeZone,format:this._axes?.x?.format,maxTicks:this._axes?.x?.ticks?.major,minorTicks:be(this._axes?.x?.ticks?.minor,Z(this._axes?.x?.grid)?.minor),colors:ye(this._axes?.x?.axis,this._axes?.x?.labels),gesamtbreite:e.totalWidth,metrics:this._textMetrics});this._valueScales.clear();let y=Array.from(u.keys()).sort((A,L)=>A-L),b=Tt({axes:this._axes,indices:y,seriesByIndex:u,layout:e,thresholds:this._thresholds,metrics:this._textMetrics});m.push(...b.commands);let{titel:x,baender:v,neueForm:w}=b,k=b.primary;for(let[A,L]of b.scales)this._valueScales.set(A,L);let R=this._valueScales.get(0)??this._valueScales.get(y[0]);m.push({type:"group",cssClass:"time-axis",sharedStyles:true,commands:f.render()});let M=qt({axes:this._axes,timeAxis:f,primaryValueAxis:k,xRange:a,yRange:l}),_=M.group;_&&M.layer==="back"&&(m.push(_),_=null),this._highlights.length>0&&m.push({type:"group",cssClass:"highlights",commands:Pt({metrics:this._textMetrics,highlights:this._highlights,timeScale:this._timeScale,yRange:l,height:e.totalHeight})});let C=[],$=R?_t({thresholds:this._thresholds,valueScales:this._valueScales,primaryScale:R,xRange:a,layout:e,baender:b.baender,belegt:C,metrics:this._textMetrics}):[];m.push(...$);let I=this._gapsAtEnd?Dt({atEnd:this._gapsAtEnd,series:this._series,timeScale:this._timeScale}).map(A=>Ke(A,void 0)):[],j=[...this._gaps,...I];if(this._gapsAutoDetect){let A=[];for(let L of this._series){if(O(L))continue;let D=L.data.filter(F=>F.value!==null);A.push(...Et(D,this._gapsMinGapMs));}A.length>0&&(j=[...j,...A]);}j.length>0&&m.push({type:"group",cssClass:"gaps",commands:qe({gaps:j,timeScale:this._timeScale,yRange:l,height:e.totalHeight,metrics:this._textMetrics,band:this._gapsBand})});let B=new Map(this._thresholds.map(A=>[A.id??A.name,A]));for(let[A,L]of this._series.entries()){if(L.data.length===0)continue;let D=this._valueScales.get(this._axisIndexOf(L));if(!D)continue;let F=Y(L.id??L.name);m.push({type:"group",cssClass:`series series--${F}`,id:`series-${F}`,commands:kn(this._reihenKontext(),L,D,B,A),...this._clipSeries?{clipRect:{x:r,y:i,w:o,h:s}}:{}});}if(_&&m.push(Qt(_,Jt($))),m.push(...on({markers:this._markers,annotations:this._annotations.filter(A=>!A.id||!this._disabledAnnotations.has(A.id)),series:this._series,timeScale:this._timeScale,valueScales:this._valueScales,achseVon:A=>this._axisIndexOf(A),primaryScale:R,yRange:l,metrics:this._textMetrics,plot:{x:r,y:i,w:o,h:s}})),this._annotationBands.length>0){let A=i+s+this._layout.margin.bottom,L=0;this._annotationBands.forEach(D=>{let F=D.height??12,P=D.spacing??0,Q=A+L;(D.showAxis??false)&&(L+=26+P),L+=F+P,m.push({type:"group",cssClass:"annotation-band",commands:new ve({name:D.name,showAxis:D.showAxis??false,items:D.items,timeScale:this._timeScale,background:D.background,hatch:D.hatch,labels:D.labels,metrics:this._textMetrics},[r,r+o],Q,F).render()});});}let{xs:H,belegt:V}=An(x.map(A=>({achseX:A.achseX,kante:A.kante,position:A.position,schrift:A.style?.fontSize??S.axisLabelSize,fest:A.fest})),[...v,...C],e.totalWidth);return m.push(...Zt({legende:t,layout:e,randBelegt:V,metrics:this._textMetrics})),m.push(...Mn({axes:this._axes,neueForm:w,achsenTitel:x,titelSpuren:H,layout:e,untenBelegt:e.margin.bottom-this._layout.margin.bottom})),Ve(m,this._fontFamily??S.fontFamily),Ne(m,this._idPraefix),m}_linienGrundlage(e){return Tn(e,this._gapsAutoDetect?this._gapsMinGapMs:void 0)}_reihenKontext(){return {timeScale:this._timeScale,alleReihen:this._series,valueScales:this._valueScales,achseVon:e=>this._axisIndexOf(e),linienGrundlage:e=>this._linienGrundlage(e),palettenFarbe:e=>this._palettenFarbe(e),jetzt:this._gapsAtEnd?.now,textMetrics:this._textMetrics,merkeOverlay:(e,t)=>{let r=this._overlayWerte.get(e)??[];r.push(t),this._overlayWerte.set(e,r);}}}legendItems(){return le(this._theme,()=>this._legendeneintraege())}_legendeneintraege(){return this._legendItems()}_palettenFarbe(e){let t=S.palette;return t.length>0?t[e%t.length]:S.stroke}_legendItems(){return this._series.map((e,t)=>{let r=e.style?.line,i=Array.isArray(r)?r:r?[r]:[],o=e.style?.markers,s=o?.type&&o.type!=="none"&&(o.threshold===void 0||(e.data?.length??0)<=o.threshold),a=O(e)?e.avgColor??S.avgColor:this._palettenFarbe(t);return {name:e.name,color:i[0]?.color??a,line:i.length===1?i[0].style:void 0,width:i.length<=1?i[0]?.width??S.strokeWidth:void 0,marker:s?o.type:void 0,id:Y(e.id??e.name),seriesId:e.id??e.name}})}get renderer(){return this._renderer}get layout(){return le(this._theme,()=>this._layoutMitLegende().layout)}get plotRect(){let{chartX:e,chartY:t,chartWidth:r,chartHeight:i}=this.layout;return {x:e,y:t,width:r,height:i}}get timeScale(){return this._timeScale}get valueScales(){return this._valueScales}warnings(){return jt({series:this._series,gaps:this._gaps,thresholds:this._thresholds,linienGrundlage:e=>this._linienGrundlage(e)})}pointsAt(e,t,r={}){return le(this._theme,()=>this._punkteAm(e,t,r))}_punkteAm(e,t,r={}){if(!this._timeScale)return [];let i=this._legendItems();return ct(this._series,this._timeScale,(o,s)=>{let a=this._axisIndexOf(o),l=this._valueScales.get(a);if(!l)return;let m=O(o)?void 0:this._linienGrundlage(o);return {skala:l,achse:a,stufe:m?.stepShape??false,gapThreshold:m?.gapThreshold??0,farbe:i[s].color,linie:i[s].line,format:Nr(o)??Se(this._axes,a)?.format,overlays:this._overlayWerte.get(s)}},this.plotRect,e,t,{...r,radius:r.radius??S.tooltipSnapRadius})}invertTime(e){return this._timeScale?this._timeScale.invert(e):0}invertValue(e,t=0){let r=this._valueScales.get(t);return r?r.invert(e):0}project(e,t,r=0){let i=this._timeScale?this._timeScale.map(e):0,o=this._valueScales.get(r);return {x:i,y:o?o.map(t):0}}};function Nr(n){let e=n.enumMap;return e?t=>e[t]??String(t):void 0}var Yr=.2,ce=4,oe=1e-6,Xr=6,Zr=.4;function Ur(n){return n?.map(e=>{let t=e.data;if(t.length<=4)return e;let r=(m,u)=>"avg"in m?u?m.max:m.min:m.value,i=new Set,o=0,s=0,a=-1,l=-1;t.forEach((m,u)=>{m.time<t[o].time&&(o=u),m.time>t[s].time&&(s=u);let h=r(m,false),c=r(m,true);h!==null&&(a<0||h<r(t[a],false))&&(a=u),c!==null&&(l<0||c>r(t[l],true))&&(l=u);});for(let m of [o,s,a,l])m>=0&&i.add(m);return {...e,data:t.filter((m,u)=>i.has(u))}})}function qr(n,e){if(!n.content)return null;let t=n.fontSize??11,r=e(n.content,t),i=n.anchor==="middle"?-r/2:n.anchor==="end"?-r:0,[o,s]=n.textBaseline==="middle"?[-t/2,t/2]:n.textBaseline==="top"?[0,t]:n.textBaseline==="bottom"?[-t,0]:[-0.8*t,Yr*t],a=[[i,o],[i+r,o],[i,s],[i+r,s]],l=(n.rotate??0)*Math.PI/180,m=Math.cos(l),u=Math.sin(l),h=a.map(([p,d])=>n.x+p*m-d*u),c=a.map(([p,d])=>n.y+p*u+d*m);return {x0:Math.min(...h),y0:Math.min(...c),x1:Math.max(...h),y1:Math.max(...c)}}function de(n,e){return {x0:Math.min(...n),y0:Math.min(...e),x1:Math.max(...n),y1:Math.max(...e)}}function Cn(n,e,t=[]){for(let r of n)switch(r.type){case "group":{let i=r.cssClass??"";if(r.clipRect||r.plotClipId||i.startsWith("chart-legend")||i.startsWith("annotation-band"))break;Cn(r.commands,e,t);break}case "text":{let i=qr(r,e);i&&t.push(i);break}case "line":t.push(de([r.x1,r.x2],[r.y1,r.y2]));break;case "rect":t.push(de([r.x,r.x+r.w],[r.y,r.y+r.h]));break;case "circle":t.push(de([r.cx-r.r,r.cx+r.r],[r.cy-r.r,r.cy+r.r]));break;case "path":r.points.length>0&&t.push(de(r.points.map(i=>i.x),r.points.map(i=>i.y)));break;case "gap":t.push(de([r.x1,r.x2],[r.y1,r.y2]));break}return t}function Jr(n,e={}){return Qr(n,e)}function Qr(n,e,t){let r=e.padding||4,i=Math.max(e.minimum||8,ce),o=n.textMetrics??G,s=Ur(n.series),a=h=>{let c=new K({...n,series:s,margin:h}),p=c.renderCommands();return {kaesten:Cn(p,o),plot:c.plotRect,breite:c.layout.totalWidth,hoehe:c.layout.totalHeight}},l=n.margin,m={top:Math.max(i,l?.top??20),right:Math.max(i,l?.right??20),bottom:Math.max(i,l?.bottom??40),left:Math.max(i,l?.left??60)},u;for(let h=0;h<Xr;h++){let c=a(m),p=a({...m,left:m.left+ce,right:m.right-ce}),d=a({...m,top:m.top+ce,bottom:m.bottom-ce}),g=p.kaesten.length===c.kaesten.length&&d.kaesten.length===c.kaesten.length,f=_=>g&&Math.abs(p.kaesten[_].x0-c.kaesten[_].x0)<oe,y=_=>g&&Math.abs(d.kaesten[_].y0-c.kaesten[_].y0)<oe,{plot:b}=c,x=b.x+b.width,v=b.y+b.height,w={left:0,right:0,top:0,bottom:0},k={left:0,right:0,top:0,bottom:0};c.kaesten.forEach((_,C)=>{f(C)?(_.x0<b.x-oe&&(k.left=Math.max(k.left,_.x1)),_.x1>x+oe&&(k.right=Math.max(k.right,c.breite-_.x0))):(w.left=Math.max(w.left,b.x-_.x0),w.right=Math.max(w.right,_.x1-x)),y(C)?(_.y0<b.y-oe&&(k.top=Math.max(k.top,_.y1)),_.y1>v+oe&&(k.bottom=Math.max(k.bottom,c.hoehe-_.y0))):(w.top=Math.max(w.top,b.y-_.y0),w.bottom=Math.max(w.bottom,_.y1-v));});let R=_=>k[_]>0?k[_]+r+w[_]:w[_]>0?w[_]+r:0,M={top:0,right:0,bottom:0,left:0};for(let _ of ["top","right","bottom","left"]){let C=_==="top"||_==="bottom"?c.hoehe:c.breite,$=Math.max(i,Math.floor(C*Zr));M[_]=Math.min(Math.max(i,Math.ceil(R(_)-1e-9)),$);}if(M.top===m.top&&M.right===m.right&&M.bottom===m.bottom&&M.left===m.left)return M;if(u&&M.top===u.top&&M.right===u.right&&M.bottom===u.bottom&&M.left===u.left)return {top:Math.max(M.top,m.top),right:Math.max(M.right,m.right),bottom:Math.max(M.bottom,m.bottom),left:Math.max(M.left,m.left)};u=m,m=M;}return m}function ei(n){if(n.min!==void 0&&n.max!==void 0)return {unit:n.unit,min:n.min,max:n.max};let e=1/0,t=-1/0;for(let r of n.data??[])r.value===null||r.value===void 0||(r.value<e&&(e=r.value),r.value>t&&(t=r.value));return {unit:n.unit,min:e,max:t}}var Ln=n=>Math.abs(n.max-n.min);function ti(n,e){return n.max>=e.min&&e.max>=n.min?0:n.max<e.min?e.min-n.max:n.min-e.max}function ni(n,e){if(n.unit!==e.unit)return false;let t=Math.max(Math.abs(n.min),Math.abs(n.max),Math.abs(e.min),Math.abs(e.max)),r=Math.max(Ln(n),Ln(e),t*.05);return ti(n,e)<=r}function ri(n){let e=[],t=n.map(i=>{let o=ei(i);if(!Number.isFinite(o.min)||!Number.isFinite(o.max)){let a=e.findIndex(l=>l.unit===o.unit);return a>=0?a:(e.push({unit:o.unit,min:0,max:0}),e.length-1)}let s=e.findIndex(a=>ni(a,o));return s>=0?(e[s]={unit:e[s].unit,min:Math.min(e[s].min,o.min),max:Math.max(e[s].max,o.max)},s):(e.push({...o}),e.length-1)}),r=e.map((i,o)=>({position:o===0?"left":"right",...i.unit?{label:i.unit}:{}}));return {indices:t,axes:r}}function Dn(n){let e=[];for(let t=0;t<n.length-1;t++){let r=n[t+1].x-n[t].x;e.push(r===0?0:(n[t+1].y-n[t].y)/r);}return e}function ii(n){let e=Dn(n),t=n.length,r=[...e];for(let i=1;i<t-1;i++)r[i]=e[i-1]*e[i]<=0?0:(e[i-1]+e[i])/2;r[t-1]=e[t-2];for(let i=0;i<t-1;i++){if(e[i]===0){r[i]=0,r[i+1]=0;continue}let o=r[i]/e[i],s=r[i+1]/e[i],a=o*o+s*s;if(a>9){let l=3/Math.sqrt(a);r[i]=l*o*e[i],r[i+1]=l*s*e[i];}}return r}function oi(n){let e=Dn(n),t=n.length;if(e.length<2)return n.map(()=>e[0]??0);let r=e[0],i=e[1],o=e[e.length-1],s=e[e.length-2],a=2*r-i,l=2*o-s,m=[2*a-r,a,...e,l,2*l-o],u=[];for(let h=0;h<t;h++){let c=Math.abs(m[h+3]-m[h+2]),p=Math.abs(m[h+1]-m[h]);u.push(c+p===0?(m[h+1]+m[h+2])/2:(c*m[h+1]+p*m[h+2])/(c+p));}return u}function si(n,e){let t=[];for(let r=0;r<n.length-1;r++){let i=n[r],o=n[r+1],s=(o.x-i.x)/3;t.push({p0:i,c1:{x:i.x+s,y:i.y+e[r]*s},c2:{x:o.x-s,y:o.y-e[r+1]*s},p1:o});}return t}function ai(n,e){if(n.length<2)return [];let t=e==="akima"?oi(n):ii(n);return si(n,t)}function li(n){let e=[];for(let t=0;t<n.length-1;t++){let r=n[t-1]??n[t],i=n[t],o=n[t+1],s=n[t+2]??o,a=Math.min(i.x,o.x),l=Math.max(i.x,o.x),m=u=>u<a?a:u>l?l:u;e.push({p0:i,c1:{x:m(i.x+(o.x-r.x)/6),y:i.y+(o.y-r.y)/6},c2:{x:m(o.x-(s.x-i.x)/6),y:o.y-(s.y-i.y)/6},p1:o});}return e}function nt(n,e){return e&&e!=="catmull-rom"?ai(n,e):li(n)}var rt=["fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","fill-opacity","stroke-opacity"],mi={line:["stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-opacity"],text:["text-anchor","font-size","font-family","fill","fill-opacity"],circle:rt,rect:rt,path:rt},ui={line:"stroke-opacity",text:"fill-opacity"},hi=/ ([a-z-]+)="([^"]*)"/g;function ci(n){let e=/^<(line|text|circle|rect|path) /.exec(n)?.[1];if(!e||n.includes(`
25
25
  `))return null;let t=e==="text"?n.indexOf(">")+1:n.length,r=n.slice(0,t),i=/ opacity="([^"]*)"/.exec(r),o=ui[e];i&&i[1]==="1"?r=r.replace(i[0],""):i&&o&&!r.includes(` ${o}="`)&&(r=r.replace(i[0],` ${o}="${i[1]}"`));let s=new Map;for(let[,a,l]of r.matchAll(hi))s.set(a,l);return {art:e,kopf:r,rest:n.slice(t),attrs:s}}function $n(n){let e=[];for(let r of mi[n[0].art]){if(!n.every(a=>a.attrs.has(r)))continue;let i=new Map;for(let a of n){let l=a.attrs.get(r);i.set(l,(i.get(l)??0)+1);}let o="",s=0;for(let[a,l]of i)l>s&&([o,s]=[a,l]);e.push([r,o]);}let t=n.map(r=>{let i=r.kopf;for(let[o,s]of e)i=i.replace(` ${o}="${s}"`,"");return i+r.rest});return {attrs:e.map(([r,i])=>` ${r}="${i}"`).join(""),kinder:t}}function Pn(n,e=" "){let t=[];for(let o of n){let s=ci(o);if(!s)return null;t.push(s);}if(t.length===0)return null;let r=new Set(t.map(o=>o.art));if(r.size===1){let o=$n(t);return {attrs:o.attrs,inhalt:o.kinder.map(s=>e+s).join(`
26
26
  `)}}if(r.size!==2||!r.has("line")||!r.has("text"))return null;let i=[];for(let o of ["line","text"]){let s=t.filter(l=>l.art===o);if(s.length===1){i.push(e+s[0].kopf+s[0].rest);continue}let a=$n(s);i.push(`${e}<g${a.attrs}>`);for(let l of a.kinder)i.push(e+e+l);i.push(`${e}</g>`);}return {attrs:"",inhalt:i.join(`
27
- `)}}var it="1.20.1";var di=` <!-- MLTimeGraph ${it} -->`,Rn=1e3;function T(n){return String(Math.round(n*Rn)/Rn)}function ot(n){return tt(n).toString(16).padStart(8,"0")}function pi(n){switch(n){case "top":return "text-top";case "bottom":return "text-bottom";default:return "middle"}}var J=class extends Te{#e="100%";#t="100%";#n;#r="";#m="";#i=new Map;#o=new Map;#s=new Map;constructor(e){super(),e?.width!==void 0&&(this.#e=e.width),e?.height!==void 0&&(this.#t=e.height),e?.background!==void 0&&(this.#n=e.background),e?.idPrefix&&(this.#r=`${e.idPrefix}-`),e?.classPrefix&&(this.#m=`${e.classPrefix}-`);}setBackgroundColor(e){this.#n=e;}render(e){this.#i.clear(),this.#o.clear(),this.#s.clear();let t=e.map(m=>this._toSVG(m));this.#n&&t.unshift(`<rect width="100%" height="100%" fill="${this._esc(this.#n)}" />`);let r=t.join(`
27
+ `)}}var it="1.20.2";var di=` <!-- MLTimeGraph ${it} -->`,Rn=1e3;function T(n){return String(Math.round(n*Rn)/Rn)}function ot(n){return tt(n).toString(16).padStart(8,"0")}function pi(n){switch(n){case "top":return "text-top";case "bottom":return "text-bottom";default:return "middle"}}var J=class extends Te{#e="100%";#t="100%";#n;#r="";#m="";#i=new Map;#o=new Map;#s=new Map;constructor(e){super(),e?.width!==void 0&&(this.#e=e.width),e?.height!==void 0&&(this.#t=e.height),e?.background!==void 0&&(this.#n=e.background),e?.idPrefix&&(this.#r=`${e.idPrefix}-`),e?.classPrefix&&(this.#m=`${e.classPrefix}-`);}setBackgroundColor(e){this.#n=e;}render(e){this.#i.clear(),this.#o.clear(),this.#s.clear();let t=e.map(m=>this._toSVG(m));this.#n&&t.unshift(`<rect width="100%" height="100%" fill="${this._esc(this.#n)}" />`);let r=t.join(`
28
28
  `),i="",o=[];for(let[,m]of this.#i)o.push(m);for(let[,m]of this.#o)o.push(m);for(let[,m]of this.#s)o.push(m);o.length>0&&(i=` <defs>
29
29
  ${o.join(`
30
30
  `)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ml-time-graph",
3
- "version": "1.20.1",
3
+ "version": "1.20.2",
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",