ml-time-graph 1.4.0 → 1.5.1

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/README.de.md CHANGED
@@ -7,6 +7,15 @@ schnell und unkompliziert aufbereiten, mit Fokus auf Reporting und Incident-Anal
7
7
 
8
8
  > Voll typisiert · i18n-aware · DOM-freier SVG-Renderer (Browser & serverseitig) · keine Laufzeit-Abhängigkeiten · ESM-only
9
9
 
10
+ > 🤖 **Sie arbeiten mit einem KI-Assistenten?** Geben Sie ihm
11
+ > **[SKILLS.md](SKILLS.md)** — die Datei wird mitgeliefert und liegt nach
12
+ > `npm install` unter `node_modules/ml-time-graph/SKILLS.md`. Eine Seite: der
13
+ > kürzeste Weg zum Diagramm, die vier Einstiegspunkte, die üblichen Aufgaben und
14
+ > ein Abschnitt **Traps** für die Stellen, an denen ein Modell danebengreift
15
+ > (Zeitstempel sind Millisekunden, Ränder werden nicht aus den Beschriftungen
16
+ > gemessen, `resolveDash` statt `getLineStyle`). Das ist der Unterschied zwischen
17
+ > Code, der übersetzt, und Code, der zeichnet, was gemeint war.
18
+
10
19
  ## Installation
11
20
 
12
21
  ```bash
package/README.md CHANGED
@@ -7,6 +7,15 @@ clear, readable charts quickly, with a focus on reporting and incident analysis.
7
7
 
8
8
  > Fully typed · i18n-aware · DOM-free SVG output (browser & server) · zero runtime dependencies · ESM-only
9
9
 
10
+ > 🤖 **Working with an AI coding assistant?** Point it at
11
+ > **[SKILLS.md](SKILLS.md)** — it ships inside the package, so after
12
+ > `npm install` it sits at `node_modules/ml-time-graph/SKILLS.md`. One page:
13
+ > the shortest path to a chart, the four entry points, the recipes, and a
14
+ > **Traps** section for the places a model guesses wrong (timestamps are epoch
15
+ > milliseconds, margins are not measured from the labels, `resolveDash` vs
16
+ > `getLineStyle`). It is the difference between code that compiles and code
17
+ > that draws what you meant.
18
+
10
19
  ## Install
11
20
 
12
21
  ```bash
package/USAGE.md CHANGED
@@ -107,7 +107,7 @@ Define named thresholds once and reference them from a series:
107
107
  ```ts
108
108
  new MLTimeGraph({
109
109
  thresholds: [
110
- { name: 'warn', value: 22, color: '#f59e0b' },
110
+ { name: 'warn', value: 22, color: '#f59e0b', label: 'Warning' },
111
111
  { name: 'crit', value: 28, color: '#ef4444', fill: 'above', label: 'Critical' },
112
112
  ],
113
113
  series: [
@@ -118,10 +118,37 @@ new MLTimeGraph({
118
118
 
119
119
  - A threshold draws a `line: 'solid' | 'dashed' | 'dotted' | 'none'`, an optional
120
120
  half-plane `fill: 'above' | 'below'`, and a `label`
121
- (`false | string | { text?, position? }`; position `left | right | above | below | center`).
121
+ (`true | string | { text?, position? }`; position `left | right | above | below | center`).
122
+ - **A threshold is not labelled unless you ask for one** (since 1.5.0). `name` is an
123
+ identifier — it wires `colorByThresholds`, fill regions and CSS classes — so painting it
124
+ into the chart by default leaked internal names next to real captions, loudest on an
125
+ invisible anchor (`line: 'none'`). Pass `label: true` to get the name, a string or
126
+ `{ text }` for your own caption. `label: false` still works and now means the same as
127
+ leaving it out.
122
128
  - `colorByThresholds: string[]` colours the line by zone — base colour below the
123
129
  lowest threshold, then each threshold's colour for values above it.
124
130
 
131
+ ### Data outside the axis range
132
+
133
+ A series is **clipped to the plot area** (`clipSeries`, default `true`). It only matters
134
+ once you fix the range yourself:
135
+
136
+ ```ts
137
+ new MLTimeGraph({
138
+ axes: { x: { domain: [windowFrom, windowTo] } }, // range is FIXED
139
+ series: [{ name: 'Temp', data }], // data reaches beyond it
140
+ // clipSeries: true — the default; the curve ends at the frame
141
+ });
142
+ ```
143
+
144
+ Handing over a reading from just outside the window is the normal way to make a curve *run
145
+ to the edge* instead of starting in mid-air — the last value before an incident is what
146
+ explains where it came from. Without clipping, line and markers paint over the axis labels.
147
+
148
+ Set `clipSeries: false` if a series should deliberately reach past the plot, or if the clip
149
+ costs you: every clipped group carries a `clip-path`, which a browser may render as its own
150
+ layer. With a handful of series that is nothing; with dozens, measure before you decide.
151
+
125
152
  ### Fill regions (the structured way)
126
153
 
127
154
  The new `style.fill` model handles every shape of "fill area":
@@ -262,6 +289,11 @@ new MLTimeGraph({
262
289
  });
263
290
  ```
264
291
 
292
+ **A grid is drawn only when you ask for one.** Set `grid: { major: {} }` on either axis and
293
+ both get one; leave it out and there is none. (Before 1.5.1 the Go port drew a grid when
294
+ nothing was configured while the TypeScript side drew none — the same JSON gave two
295
+ different charts.)
296
+
265
297
  ### Multi-Axis Layout (N Stacked Y-Axes)
266
298
 
267
299
  To support 3 or more vertical axes (or arbitrary left/right positioning), define `axes.y: YAxisConfig[]` and assign series using `yAxisIndex`:
package/dist/index.d.ts CHANGED
@@ -128,6 +128,20 @@ interface MLTimeGraphOptions {
128
128
  renderer?: Renderer;
129
129
  /** Time series data (raw or aggregated min/max/avg) */
130
130
  series?: AnySeries[];
131
+ /**
132
+ * Clip series drawing to the plot area (default `true`).
133
+ *
134
+ * It matters only when data lies outside the axis domain — which happens as soon as you
135
+ * fix `axes.x.domain` and hand over a reading from just outside the window, so the curve
136
+ * runs to the edge instead of starting in mid-air. Without clipping, line and markers
137
+ * paint over the axis labels.
138
+ *
139
+ * Turn it off if you deliberately want a series to reach beyond the plot, or if the
140
+ * clip costs you: every clipped group gets a `clip-path`, and a browser may promote each
141
+ * to its own layer. With a handful of series that is nothing; with dozens on a slow
142
+ * machine it can be worth measuring.
143
+ */
144
+ clipSeries?: boolean;
131
145
  /** Locale for i18n (e.g. 'de-DE') */
132
146
  locale?: string;
133
147
  /** Integrated legend configuration */
@@ -177,6 +191,8 @@ declare class MLTimeGraph {
177
191
  private readonly _renderer?;
178
192
  private readonly _locale?;
179
193
  private readonly _legend?;
194
+ /** Serien auf die Zeichenflaeche beschneiden (Vorgabe: ja) — siehe options.ts. */
195
+ private readonly _clipSeries;
180
196
  private readonly _markers;
181
197
  private readonly _thresholds;
182
198
  private readonly _highlights;
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ var nt=class i{_config;constructor(t){this._config=t;}compute(){let{width:t,heig
21
21
  ${u}
22
22
  ${d}
23
23
  </pattern>
24
- `.trim()}function Pt(i,t=2,e=false){return i==="dashed"||!i&&e?{strokeDasharray:"4,4"}:i==="dotted"?{strokeDasharray:"2,4"}:!i||i==="solid"?null:Vt(i,t)}function Vt(i,t=2){let e=t;switch(i){case "dotted":return {strokeDasharray:`0, ${e*2}`,strokeLinecap:"round"};case "sparse-dots":return {strokeDasharray:`0, ${e*4}`,strokeLinecap:"round"};case "dashed":return {strokeDasharray:`${e*3}, ${e*2}`,strokeLinecap:"butt"};case "long-dash":return {strokeDasharray:`${e*6}, ${e*3}`,strokeLinecap:"butt"};case "dense-dash":return {strokeDasharray:`${e*1.5}, ${e*1.5}`,strokeLinecap:"butt"};case "dash-dot":return {strokeDasharray:`${e*4}, ${e*2}, 0, ${e*2}`,strokeLinecap:"round"};case "dash-dot-dot":return {strokeDasharray:`${e*5}, ${e*2}, 0, ${e*2}, 0, ${e*2}`,strokeLinecap:"round"};case "loose-dash":return {strokeDasharray:`${e*3}, ${e*4}`,strokeLinecap:"butt"};default:return {strokeDasharray:"none",strokeLinecap:"butt"}}}var g=new Proxy({},{get:(i,t)=>Q()[t],has:(i,t)=>t in Q(),ownKeys:()=>Reflect.ownKeys(Q()),getOwnPropertyDescriptor:(i,t)=>Reflect.getOwnPropertyDescriptor(Q(),t)});var ot={axisColor:g.axisColor,tickColor:g.tickColor,textColor:g.textColor,textSize:g.textSize},tt=class{#t;#e;constructor(t){this.#t=new J({domain:t.domain,range:t.xRange,locale:t.locale}),this.#e=t;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??ot).axisColor}get tickColor(){return (this.#e.colors??ot).tickColor}get textColor(){return (this.#e.colors??ot).textColor}get textSize(){return (this.#e.colors??ot).textSize}generateTicks(){let t=this.#e.minTicks??5,e=this.#e.maxTicks??12,r=this.#t.ticks({minTicks:t,maxTicks:e}).map(o=>({time:o,x:this.#t.map(o),label:this.tickLabel(o)}));return this.antiOverlap(r)}tickLabel(t){if(this.#e.format)return this.#e.format(new Date(t));let e=this.#e.minTicks??5,n=this.#e.maxTicks??12,{interval:r}=this.#t.tickInterval((e+n)/2,e,n),o={};return r<6e4?(o.hour="2-digit",o.minute="2-digit",o.second="2-digit"):r<36e5||r<864e5?(o.hour="2-digit",o.minute="2-digit"):r<31536e6?(o.day="numeric",o.month="short",r>=2592e6&&(o.day=void 0,o.month="long")):(o.year="numeric",r<2*31536e6&&(o.month="short")),this.#t.format(t,o)}antiOverlap(t){if(t.length<=1)return t;let e=60,n=[t[0]];for(let r=1;r<t.length;r++){let o=n[n.length-1].x;Math.abs(t[r].x-o)>=e&&n.push(t[r]);}return n}render(){let t=this.generateTicks(),e=this.#e.colors??ot,n=this.#e.y??0,r=[],[o,a]=this.#t.range();r.push({type:"line",x1:o,y1:n,x2:a,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let s of t)r.push({type:"line",x1:s.x,y1:n,x2:s.x,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),r.push({type:"text",content:s.label,x:s.x,y:n+e.textSize+6,anchor:"middle",fontSize:e.textSize,fill:e.textColor});return r}};var st={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function we(i){return Math.abs(i)>=1e6?`${(i/1e6).toFixed(1)}M`:Math.abs(i)>=1e3?`${(i/1e3).toFixed(1)}k`:Number.isInteger(i)?String(i):i.toFixed(1)}function ve(i){let t=new Array(i.length).fill(false),e=0;for(;e<i.length;){let n=e;for(;n+1<i.length&&i[n+1].label===i[e].label;)n++;for(let r=e+1;r<n;r++)t[r]=true;e=n+1;}return t}var dt=class{#t;#e;constructor(t){this.#t=new X({domain:t.domain,range:t.range}),this.#e=t;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??st).axisColor}get tickColor(){return (this.#e.colors??st).tickColor}get textColor(){return (this.#e.colors??st).textColor}get textSize(){return (this.#e.colors??st).textSize}generateTicks(){let t=this.#e.format??we,e=6,[n,r]=this.#t.domain(),o=r-n;if(o===0)return [{value:n,position:this.#t.map(n),label:t(n)}];let a=o/e,s=Math.pow(10,Math.floor(Math.log10(a))),l=a/s,h;l<=1.5?h=s:l<=3?h=2*s:l<=7?h=5*s:h=10*s;let d=[],u=Math.ceil(n/h)*h;for(let m=u;m<=r;m+=h)d.push({value:m,position:this.#t.map(m),label:t(m)});return d}render(){let t=this.generateTicks(),e=this.#e.colors??st,n=this.#e.x??0,r=this.#e.orientation??"vertical",o=this.#e.position??"left",a=this.#e.suppressLabelsNear??[],s=this.#e.suppressTolerancePx??8,l=d=>a.some(u=>Math.abs(u-d)<=s),h=[];if(r==="vertical"){let[d,u]=this.#t.range();h.push({type:"line",x1:n,y1:d,x2:n,y2:u,stroke:e.axisColor,strokeWidth:e.axisWidth});let m=ve(t);t.forEach((c,f)=>{let y=l(c.position),b=m[f]?{opacity:0}:{};o==="left"?(h.push({type:"line",x1:n-4,y1:c.position,x2:n,y2:c.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||h.push({type:"text",content:c.label,x:n-8,y:c.position+4,anchor:"end",fontSize:11,fill:e.textColor,...b})):(h.push({type:"line",x1:n,y1:c.position,x2:n+4,y2:c.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||h.push({type:"text",content:c.label,x:n+8,y:c.position+4,anchor:"start",fontSize:11,fill:e.textColor,...b}));});}else {let[d,u]=this.#t.range();h.push({type:"line",x1:d,y1:n,x2:u,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let m of t)h.push({type:"line",x1:m.position,y1:n,x2:m.position,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),h.push({type:"text",content:m.label,x:m.position,y:n+18,anchor:"middle",fontSize:e.textSize,fill:e.textColor});}return h}};var H=class{static interpolateDataPoint(i,t,e){return {time:i.time+Math.round(e*(t.time-i.time)),value:(i.value??0)+e*((t.value??0)-(i.value??0))}}static interpolateAggregatedPoint(i,t,e){let n=(r,o)=>r!==null&&o!==null?r+e*(o-r):null;return {time:i.time+e*(t.time-i.time),min:n(i.min,t.min),max:n(i.max,t.max),avg:n(i.avg,t.avg),count:Math.round(i.count+e*(t.count-i.count))}}static getRuns(i,t,e=0){let n=[...i].sort((s,l)=>s.time-l.time),r=[],o=[],a=null;for(let s of n){let l=t(s),h=e>0&&a&&s.time-a.time>e;(l||h)&&o.length&&(r.push(o),o=[]),l||o.push(s),a=s;}return o.length&&r.push(o),r}static splitByBoundaries(i,t,e,n){if(i.length===0)return [];if(t.length===0)return [{data:i,zoneIndex:0}];let r=[...t].sort((l,h)=>l-h),o=[],a=l=>{let h=0;for(let d=0;d<r.length&&l>=r[d];d++)h=d+1;return h},s=[i[0]];for(let l=1;l<i.length;l++){let h=i[l-1],d=i[l],u=e(h),m=e(d),c;m>u?c=r.filter(f=>f>u&&f<=m):m<u?c=r.filter(f=>f>=m&&f<u).reverse():c=[];for(let f of c){let y=(f-u)/(m-u),b=n(h,d,y);s.push(b),o.push({data:s,zoneIndex:a((u+f)/2)}),s=[b];}s.push(d);}if(s.length>0){let l=e(s[0]),h=e(s[s.length-1]);o.push({data:s,zoneIndex:a((l+h)/2)});}return o}static splitByThreshold(i,t,e,n){let r=this.splitByBoundaries(i,[t],e,n),o={above:[],below:[]};for(let a of r)a.zoneIndex===0?o.below.push(a.data):o.above.push(a.data);return o}};function Nt(i,t=6e4){if(i.length<2)return [];let e=[...i].sort((r,o)=>r.time-o.time),n=[];for(let r=1;r<e.length;r++)e[r].time-e[r-1].time>t&&n.push({startTime:e[r-1].time,endTime:e[r].time});return n}function ke(i,t=83144){let e=t/8.314,n=0,r=0;for(let a of i)a!==null&&(n+=Math.exp(-e/(a+273.15)),r++);if(r===0)return null;let o=n/r;return e/-Math.log(o)-273.15}function Yt(i,t,e=83144){let n=new Array(i.length),r=0;for(let o=0;o<i.length;o++){let a=i[o].time,s=a-t;for(;r<o&&i[r].time<s;)r++;let l=i.slice(r,o+1).map(d=>d.value),h=ke(l,e);n[o]={time:a,value:h,synthetic:true};}return n}function Ce(i){let t=0,e=0;for(let o of i)o!==null&&(t+=o,e++);if(e===0)return null;let n=t/e,r=0;for(let o of i){if(o===null)continue;let a=o-n;r+=a*a;}return Math.sqrt(r/e)}function Te(i){let t=0,e=0;for(let o of i)o!==null&&(t+=o,e++);if(e<2)return null;let n=t/e,r=0;for(let o of i){if(o===null)continue;let a=o-n;r+=a*a;}return Math.sqrt(r/(e-1))}function zt(i,t,e=false){let n=new Array(i.length),r=0,o=e?Te:Ce;for(let a=0;a<i.length;a++){let s=i[a].time,l=s-t;for(;r<a&&i[r].time<l;)r++;let h=i.slice(r,a+1).map(u=>u.value),d=o(h);n[a]={time:s,value:d,synthetic:true};}return n}function qt(i){return {id:i.id,line:{stroke:i.stroke??g.stroke,strokeWidth:i.strokeWidth??g.strokeWidth,smoothing:i.smoothing??false,dashed:i.dashed??false},fill:i.fill??g.areaFillAlpha,markers:{type:i.pointStyle??"none",size:i.pointSize??g.pointSize,stroke:i.stroke??g.stroke,fill:"#ffffff"},shadow:{color:i.shadowColor??"transparent",blur:i.shadowBlur??0,offsetX:i.shadowOffsetX??0,offsetY:i.shadowOffsetY??0}}}function mt(i,t,e){let n=[],r=i.reduce((a,s)=>a+s.data.length,0),o=qt(e);for(let a=0;a<i.length;a++){let s=i[a];s.data.length>=2?n.push({type:"path",id:e.id?`${e.id}-line-${a}`:void 0,points:s.data.map(l=>({x:t.timeScale.map(l.time),y:t.valueScale.map(l.value)})),stroke:s.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:o.line.smoothing,dashed:o.line.dashed,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur,shadowOffsetX:o.shadow.offsetX,shadowOffsetY:o.shadow.offsetY,fill:"none"}):s.data.length===1&&r===1&&n.push({type:"circle",cx:t.timeScale.map(s.data[0].time),cy:t.valueScale.map(s.data[0].value),r:Math.max(o.markers.size,o.line.strokeWidth),fill:s.color??o.line.stroke,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur});}return n}function Xt(i){let t=[];for(let e of i)t.length===0?t.push(e):t.push({x:e.x,y:t[t.length-1].y},e);return t}function Bt(i,t,e,n){if(i.length<2)return [];let r=H.splitByBoundaries(i,e.boundaries,e.getValue,e.interpolate),o=[];for(let a=0;a<r.length;a++){let s=r[a];if(s.data.length<2)continue;let l=e.getColor(s.zoneIndex);if(!l)continue;let h=s.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yLow(u))})),d=s.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yHigh(u))})).reverse();o.push({type:"path",id:n?.id?`${n.id}-fill-${a}`:void 0,points:[...h,...d],fill:l,hatch:e.getHatch?.(s.zoneIndex),stroke:"none"});}return o}function Ut(i,t,e,n){let r=qt(e);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let a=0;a<i.length;a++){let s=i[a],l=t.timeScale.map(s.time),h=t.valueScale.map(s.value),d=n(s),u=e.pointStroke??d,m=e.pointFill??d,c=e.pointStrokeWidth??1.5,f=e.id?`${e.id}-marker-${a}`:void 0;ut(o,f,r.markers.type,l,h,r.markers.size,u,m,c);}return o}function ut(i,t,e,n,r,o,a,s,l){switch(e){case "circle":i.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:a,strokeWidth:l,id:t});break;case "square":i.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:s,stroke:a,strokeWidth:l,id:t});break;case "cross":i.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:a,strokeWidth:l,id:t},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:a,strokeWidth:l,id:t});break;case "diamond":i.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r},{x:n,y:r+o},{x:n-o,y:r}],fill:s,stroke:a,strokeWidth:l,id:t});break;case "triangle":i.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r+o},{x:n-o,y:r+o}],fill:s,stroke:a,strokeWidth:l,id:t});break;case "star":{let h=[];for(let d=0;d<10;d++){let u=d%2===0?o:o*.5,m=Math.PI/2*3+d*Math.PI/5;h.push({x:n+u*Math.cos(m),y:r+u*Math.sin(m)});}i.push({type:"path",points:h,fill:s,stroke:a,strokeWidth:l,id:t});break}case "arrow":i.push({type:"path",points:[{x:n-o,y:r+o},{x:n,y:r-o},{x:n+o,y:r+o}],stroke:a,strokeWidth:l,fill:"none",id:t});break;case "plus":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:a,strokeWidth:l,id:t},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:a,strokeWidth:l,id:t});break;case "triangle-down":i.push({type:"path",points:[{x:n,y:r+o},{x:n+o,y:r-o},{x:n-o,y:r-o}],fill:s,stroke:a,strokeWidth:l,id:t});break;case "hexagon":{let h=[];for(let d=0;d<6;d++){let u=d*(Math.PI/3);h.push({x:n+o*Math.cos(u),y:r+o*Math.sin(u)});}i.push({type:"path",points:h,fill:s,stroke:a,strokeWidth:l,id:t});break}case "hourglass":i.push({type:"path",points:[{x:n-o,y:r-o},{x:n+o,y:r-o},{x:n-o,y:r+o},{x:n+o,y:r+o}],fill:s,stroke:a,strokeWidth:l,id:t});break;case "line-horizontal":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:a,strokeWidth:l,id:t});break;default:i.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:a,strokeWidth:l,id:t});}}var et=class i{#t;#e;static uidcnt=0;#n;constructor(t,e=[]){this.#t=t.id??"series-"+ ++i.uidcnt,this.#e=t.timeScale,this.#n=e;}get id(){return this.#t}get timeScale(){return this.#e}get data(){return this.#n}};var ct=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}render(){let t=this.#t,e=t.minColor??g.minColor,n=t.maxColor??g.maxColor,r=t.avgColor??g.avgColor,o=t.avgDashed??true,a=t.smoothing??false,s=t.strokeWidth??g.strokeWidth,l=H.getRuns(this.data,c=>c.min===null||c.max===null||c.avg===null);if(l.length===0)return [];let h={timeScale:this.timeScale,valueScale:t.valueScale},d=[];l.forEach((c,f)=>{c.length<2||(t.fillToMax&&d.push(...Bt(c,h,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.max,getValue:y=>y.avg,interpolate:H.interpolateAggregatedPoint,getColor:()=>t.fillToMax,getHatch:()=>t.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${f}`:void 0})),t.fillToMin&&d.push(...Bt(c,h,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.min,getValue:y=>y.avg,interpolate:H.interpolateAggregatedPoint,getColor:()=>t.fillToMin,getHatch:()=>t.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${f}`:void 0})));});let u=l.filter(c=>c.length>=2),m=c=>u.map(f=>({data:f.map(y=>({time:y.time,value:c(y)}))}));return d.push(...mt(m(c=>c.max),h,{stroke:n,strokeWidth:s,smoothing:a,id:this.id?`${this.id}-max`:void 0}),...mt(m(c=>c.min),h,{stroke:e,strokeWidth:s,smoothing:a,id:this.id?`${this.id}-min`:void 0}),...mt(m(c=>c.avg),h,{stroke:r,strokeWidth:s,smoothing:a,dashed:o,id:this.id?`${this.id}-avg`:void 0})),d}};var pt=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}opacity(t){if(!(this.#t.countOpacity??false))return .6;let e=0;for(let n of this.data)n.count>e&&(e=n.count);return e===0?.2:.2+.8*t/e}render(){let t=this.#t,e=t.fill??g.bandFill,n=t.hatch,r=t.avgLine??false,o=t.avgLineColor??g.bandAvgLine,a=t.bandWidth??10,s=[];for(let l of this.data){if(l.min===null||l.max===null)continue;let h=this.timeScale.map(l.time),d=t.valueScale.map(l.max),u=t.valueScale.map(l.min),m=a,c=this.data.indexOf(l);if(s.push({type:"rect",x:h-m/2,y:d,w:m,h:u-d,fill:e,hatch:n,opacity:this.opacity(l.count),id:this.id?`${this.id}-slot-${c}`:void 0}),r&&l.avg!==null){let f=t.valueScale.map(l.avg);s.push({type:"line",x1:h-m/2,y1:f,x2:h+m/2,y2:f,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${c}`:void 0});}}return s}};function $e(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function Kt(i){let{thresholds:t,valueScale:e,xRange:n}=i,[r,o]=n,[a,s]=e.range(),l=Math.min(a,s),h=Math.max(a,s),d=[],u=[];for(let m of t){let c=m.color??g.thresholdColor,f=e.map(m.value);m.fill==="above"?d.push({type:"rect",x:r,y:l,w:o-r,h:Math.max(0,f-l),fill:c,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0}):m.fill==="below"&&d.push({type:"rect",x:r,y:f,w:o-r,h:Math.max(0,h-f),fill:c,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0});let y=m.line??g.thresholdLine;if(y!=="none"){let b=$e(y),_={type:"line",x1:r,y1:f,x2:o,y2:f,stroke:c,strokeWidth:1,...b,id:m.id?`${m.id}-line`:void 0};m.shadowColor&&(_.shadowColor=m.shadowColor,_.shadowBlur=m.shadowBlur??4,_.shadowOffsetX=m.shadowOffsetX??0,_.shadowOffsetY=m.shadowOffsetY??2),d.push(_);}if(m.label!==false){let b=m.label&&typeof m.label=="object"?m.label:void 0,_=typeof m.label=="string"?m.label:b?.text??m.name,C=b?.position??"right";u.push({...Ae(_,C,r,o,f,c,b),id:m.id?`${m.id}-label`:void 0});}}return {inside:d,labels:u}}function Ae(i,t,e,n,r,o,a){let s=(e+n)/2,l={type:"text",content:i,fontSize:g.thresholdFontSize,fill:o},h=a?{...a.rotate!==void 0&&{rotate:a.rotate},...a.textBaseline!==void 0&&{textBaseline:a.textBaseline}}:{};switch(t){case "left":return {...l,...h,x:e+4,y:r-4,anchor:"start"};case "above":return {...l,...h,x:s,y:r-6,anchor:"middle"};case "below":return {...l,...h,x:s,y:r+14,anchor:"middle"};case "center":return {...l,...h,x:s,y:r-4,anchor:"middle"};case "outside-left":return {...l,...h,x:e-6,y:r+3,anchor:"end",textBaseline:h.textBaseline??"middle"};case "outside-right":return {...l,...h,x:n+6,y:r+3,anchor:"start",textBaseline:h.textBaseline??"middle"};default:return {...l,...h,x:n-4,y:r-4,anchor:"end"}}}function Zt(i){let{gaps:t,timeScale:e,yRange:n,fill:r=g.gapFill,hatch:o,fillOpacity:a=g.gapFillOpacity??.15,stroke:s=g.gapStroke,strokeWidth:l=g.gapStrokeWidth,dashed:h=true,fontSize:d=g.gapFontSize,fontFill:u=g.gapFontColor,labelBaseline:m="middle",labelRotate:c}=i,[f,y]=n,b=[];for(let _ of t){let C=e.map(_.startTime),N=e.map(_.endTime),P=_.fill??r,M=_.hatch??o,R=_.fillOpacity??a,B=_.label??"",G=_.rotate??c,I=_.labelBaseline??m;if(_.style==="dashed_border"||!_.style?b.push({type:"rect",x:C,y:f,w:N-C,h:y-f,fill:P,hatch:M,opacity:R,stroke:s,strokeWidth:l,dashed:h}):_.style==="empty"&&b.push({type:"rect",x:C,y:f,w:N-C,h:y-f,fill:P,hatch:M,opacity:R}),B){let S=Le(f,y,I),v=I==="above"?"top":I==="below"?"bottom":"middle";b.push({type:"text",content:B,x:(C+N)/2,y:S,anchor:"middle",fontSize:d,fill:u,textBaseline:v,rotate:G});}}return b}function Le(i,t,e){switch(e){case "above":return i-12;case "below":return t+4;default:return (i+t)/2}}var ft=class{#t;constructor(t,e,n,r){this.#t={...t,xRange:e,y:n,height:r};}render(){let{items:t,timeScale:e,background:n,hatch:r,showAxis:o,xRange:a,y:s,height:l}=this.#t,h=[];n&&h.push({type:"rect",x:a[0],y:s,w:a[1]-a[0],h:l,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let d of t){let u=e.map(d.startTime),m=e.map(d.endTime);if(!(m-u<1)&&(h.push({type:"rect",x:u,y:s,w:m-u,h:l,hatch:d.hatch??r,fill:d.fill??"#6b728044",stroke:d.stroke,strokeWidth:d.strokeWidth??0}),d.label)){let c=d.labelFontSize??10;h.push({type:"text",content:d.label,x:(u+m)/2,y:this.#e(d.labelBaseline,c),anchor:"middle",fontSize:c,fill:d.labelFill??"#333"});}}if(o){let d=new tt({domain:e.domain(),xRange:a,y:s+l+4});h.push({type:"group",cssClass:"annotation-band-axis",commands:d.render()});}return h}#e(t,e){let{y:n,height:r}=this.#t;switch(t){case "top":return n+e*.9;case "bottom":return n+r-e*.25;default:return n+r/2+e*.35}}};function Jt(i){let{highlights:t,timeScale:e,yRange:n,height:r}=i,[o,a]=n,s=[];for(let l of t){let h=e.map(l.startTime),d=e.map(l.endTime);s.push({type:"rect",x:h,y:o,w:d-h,h:a-o,fill:l.color??g.highlightColor,opacity:l.opacity??g.highlightOpacity}),l.label&&s.push({type:"text",content:l.label,x:(h+d)/2,y:Me(l.labelPosition??"top",o,a,r),anchor:"middle",fontSize:g.annotationFontSize,fill:l.color??g.highlightLabelColor,rotate:l.rotate});}return s}function Me(i,t,e,n){switch(i){case "above":return t-5;case "below":return n!==void 0?n-5:e+14;case "center":return (t+e)/2+4;case "bottom":return e-6;default:return t+14}}function Qt(i){let{markers:t,timeScale:e,valueScale:n,yRange:r=[0,300]}=i,[o,a]=r,s=[];for(let l of t){let h=e.map(l.time),d=l.color??g.markerColor,u=l.pointStyle??(l.value!==void 0?"circle":"none"),m=l.lineStyle??"full";if(l.value!==void 0){let c=n.map(l.value);if(m==="to-value"?s.push({type:"line",x1:h,y1:a,x2:h,y2:c,stroke:d,strokeWidth:1,dashed:true}):m==="to-top"?s.push({type:"line",x1:h,y1:o,x2:h,y2:c,stroke:d,strokeWidth:1,dashed:true}):m==="full"&&s.push({type:"line",x1:h,y1:o,x2:h,y2:a,stroke:d,strokeWidth:1}),u!=="none"&&ut(s,void 0,u,h,c,g.markerSize,d,d,1.5),l.label){let f=m==="to-value"?c-10:o-6;s.push({type:"text",content:l.label,x:h,y:f,anchor:"middle",fontSize:11,fill:d});}}else s.push({type:"line",x1:h,y1:o,x2:h,y2:a,stroke:d,strokeWidth:1}),l.label&&s.push({type:"text",content:l.label,x:h,y:o-6,anchor:"middle",fontSize:11,fill:d});}return s}function te(i){let{annotations:t,timeScale:e,valueScales:n}=i,r=[],o=a=>{let s=n.get(a.axis??0)??n.values().next().value;return {x:e.map(a.time),y:s?s.map(a.value):0}};for(let a of t){let s=[],l=h=>s.push(h);switch(a.type){case "line":{let h=o(a.from),d=o(a.to);l({type:"line",x1:h.x,y1:h.y,x2:d.x,y2:d.y,stroke:a.color??g.annotationColor,strokeWidth:a.width??g.annotationWidth,dash:a.dash});break}case "arrow":{let h=o(a.from),d=o(a.to),u=a.color??g.annotationColor,m=a.headSize??g.annotationHead;l({type:"line",x1:h.x,y1:h.y,x2:d.x,y2:d.y,stroke:u,strokeWidth:a.width??g.annotationWidth});let c=Math.hypot(d.x-h.x,d.y-h.y)||1,f=(d.x-h.x)/c,y=(d.y-h.y)/c,b=d.x-f*m,_=d.y-y*m;l({type:"path",points:[{x:d.x,y:d.y},{x:b-y*m*.5,y:_+f*m*.5},{x:b+y*m*.5,y:_-f*m*.5}],fill:u,stroke:"none"});break}case "rect":{let h=o(a.from),d=o(a.to);l({type:"rect",x:Math.min(h.x,d.x),y:Math.min(h.y,d.y),w:Math.abs(d.x-h.x),h:Math.abs(d.y-h.y),fill:a.fill??"none",stroke:a.stroke,opacity:a.opacity});break}case "point":{let h=o(a.at),d=a.color??"#334155",u=a.radius??g.annotationRadius,m=a.shape??"circle";m==="circle"?l({type:"circle",cx:h.x,cy:h.y,r:u,fill:d}):m==="square"?l({type:"rect",x:h.x-u,y:h.y-u,w:u*2,h:u*2,fill:d}):(l({type:"line",x1:h.x-u,y1:h.y-u,x2:h.x+u,y2:h.y+u,stroke:d,strokeWidth:1.5}),l({type:"line",x1:h.x-u,y1:h.y+u,x2:h.x+u,y2:h.y-u,stroke:d,strokeWidth:1.5}));break}case "label":{let h=o(a.at);l({type:"text",content:a.text,x:h.x+(a.dx??0),y:h.y+(a.dy??0),anchor:a.anchor??"middle",fontSize:g.annotationFontSize,fill:a.color??g.annotationColor,rotate:a.rotate});break}}if(a.id&&s.length>0){let h=it(a.id);r.push({type:"group",cssClass:`annotation annotation--${h}`,commands:s});}else r.push(...s);}return r}var U=12,gt=8,Ft=20,De=11,jt=18,Ot=i=>i.length*De*.6;function ee(i,t="vertical"){if(t==="horizontal"){let n=0;for(let r of i)n+=U+gt+Ot(r.name)+jt;return {width:Math.max(0,n-jt),height:Ft}}let e=0;for(let n of i)e=Math.max(e,Ot(n.name));return {width:U+gt+e,height:i.length*Ft}}function ne(i){let{items:t,x:e,y:n,orientation:r="vertical"}=i,o=[],a=e;return t.forEach((s,l)=>{let h=r==="horizontal"?a:e,d=r==="horizontal"?n:n+l*Ft;o.push({type:"rect",x:h,y:d,w:U,h:U,fill:s.color,stroke:g.legendStroke,strokeWidth:1},{type:"text",content:s.name,x:h+U+gt,y:d+U-2,fontSize:g.legendFont,fill:g.legendText}),r==="horizontal"&&(a+=U+gt+Ot(s.name)+jt);}),{type:"group",cssClass:"chart-legend",commands:o}}function ie(i){let{xTicks:t,yTicks:e,xRange:n,yRange:r,stroke:o=g.gridStroke,strokeWidth:a=g.gridStrokeWidth,dashed:s=false,opacity:l=g.gridOpacity}=i,h=[];if(e)for(let d of e)h.push({type:"line",x1:n[0],y1:d,x2:n[1],y2:d,stroke:o,strokeWidth:a,dashed:s,opacity:l});if(t)for(let d of t)h.push({type:"line",x1:d,y1:r[0],x2:d,y2:r[1],stroke:o,strokeWidth:a,dashed:s,opacity:l});return h}function re(i,t,e){let n=i??t;if(n==="series")return null;if(n==="chartTop")return e.chartTop;if(n==="chartBottom")return e.chartBottom;if(typeof n=="object"&&"threshold"in n){let r=e.thresholds.get(n.threshold);if(!r)throw new Error(`fillSpec region references unknown threshold '${n.threshold}'`);return e.valueScale.map(r.value)}return typeof n=="object"&&"value"in n?e.valueScale.map(n.value):null}function Pe(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function oe(i,t,e){let n=re(i.from,"chartBottom",t),r=re(i.to,"series",t),{color:o,hatch:a}=Pe(i.fill),s={type:"path",fill:o,hatch:a,stroke:"none",...t.idPrefix&&{id:`${t.idPrefix}-fill-r${e}`}};if(n!==null&&r!==null){let m=t.timeScale.range(),c=m[0],f=m[1],y=Math.min(n,r),b=Math.max(n,r);return [{...s,points:[{x:c,y},{x:f,y},{x:f,y:b},{x:c,y:b}]}]}let l=n??r,h=[],d=Be(i,t);if(d===null){let m=t.valueScale.domain();d=(n??r)===t.chartBottom?m[0]:m[1];}let u=se(i.outer,t);for(let m of t.runs){if(m.length<2)continue;let c=H.splitByThreshold(m,d,y=>y.value??d,H.interpolateDataPoint),f=i.side==="above"?c.above:i.side==="below"?c.below:[...c.above,...c.below];if(u!==null&&i.side){let y=i.side==="above"?"below":"above";f=f.flatMap(b=>{if(b.length<2)return [];let _=H.splitByThreshold(b,u,C=>C.value??u,H.interpolateDataPoint);return y==="above"?_.above:_.below});}for(let y of f){if(y.length<2)continue;let b=y.map(C=>({x:t.timeScale.map(C.time),y:t.valueScale.map(C.value)})),_=[...b].reverse().map(C=>({x:C.x,y:l}));h.push({...s,smoothing:t.smoothing,smoothCount:b.length,points:[...b,..._]});}}return h}function Be(i,t){let e=i.from==="series"?i.to:i.from;return se(e,t)}function se(i,t){return i===void 0||i==="series"||i==="chartTop"||i==="chartBottom"?null:typeof i=="object"&&"threshold"in i?t.thresholds.get(i.threshold)?.value??null:typeof i=="object"&&"value"in i?i.value:null}function ae(i,t){if(typeof i=="string"||!("regions"in i))return oe({fill:i},t,0);let e=[];return i.regions.forEach((n,r)=>{e.push(...oe(n,t,r));}),e}function le(i,t){let e=new Array(i.length),n=0;for(let r=0;r<i.length;r++){let o=i[r].time,a=o-t;for(;n<r&&i[n].time<a;)n++;let s=0,l=0;for(let h=n;h<=r;h++){let d=i[h].value;d!==null&&(s+=d,l++);}e[r]={time:o,value:l===0?null:s/l,synthetic:true};}return e}function de(i){let t=i.style?.line,e=t&&!Array.isArray(t)?t:void 0;return {color:e?.color??g.stroke,width:e?.width??g.strokeWidth,dash:e?.style,smoothing:e?.smoothing??false}}function he(i,t,e,n){let r=i.filter(l=>l.value!==null);if(r.length<2)return [];let o=r.map(l=>({x:t.timeScale.map(l.time),y:t.valueScale.map(l.value)})),a=de(e);return [{type:"path",id:t.idPrefix?`${t.idPrefix}-overlay-${n}`:`overlay-${n}`,points:o,stroke:a.color,strokeWidth:a.width,smoothing:a.smoothing,dash:a.dash,fill:"none"}]}function me(i,t){switch(i.kind){case "movingAverage":{i.type;let e=le(t.data,i.window);return he(e,t,i,"movingAvg")}case "movingMkt":{let e=Yt(t.data,i.window,i.activationEnergy);return he(e,t,i,"movingMkt")}case "limits":{let e=[],n=t.timeScale.range(),r=n[0],o=n[1],a=de(i),s=a.color,l=a.width,h=a.dash??"dashed",d=t.idPrefix?`${t.idPrefix}-`:"";return i.high!==void 0&&e.push({type:"line",id:`${d}overlay-limit-high`,x1:r,y1:t.valueScale.map(i.high),x2:o,y2:t.valueScale.map(i.high),stroke:s,strokeWidth:l,dash:h}),i.low!==void 0&&e.push({type:"line",id:`${d}overlay-limit-low`,x1:r,y1:t.valueScale.map(i.low),x2:o,y2:t.valueScale.map(i.low),stroke:s,strokeWidth:l,dash:h}),e}case "stdDevBand":{let e=i.multiplier??1,n=le(t.data,i.window),r=zt(t.data,i.window),o=[],a=[];for(let y=0;y<n.length;y++){let b=n[y].value,_=r[y].value;if(b===null||_===null)continue;let C=t.timeScale.map(n[y].time);o.push({x:C,y:t.valueScale.map(b+e*_)}),a.push({x:C,y:t.valueScale.map(b-e*_)});}if(o.length<2)return [];let s=t.idPrefix?`${t.idPrefix}-`:"",l=[],d=(typeof i.style?.fill=="string"||i.style?.fill&&!("regions"in i.style.fill)?i.style.fill:void 0)??"#94a3b833",{color:u,hatch:m}=Fe(d);l.push({type:"path",id:`${s}overlay-stdDevBand`,points:[...o,...[...a].reverse()],fill:u,hatch:m,stroke:"none"});let c=i.style?.line,f=c&&!Array.isArray(c)?c:void 0;if(f){let y=n.filter(b=>b.value!==null).map(b=>({x:t.timeScale.map(b.time),y:t.valueScale.map(b.value)}));y.length>=2&&l.push({type:"path",id:`${s}overlay-stdDevBand-mean`,points:y,stroke:f.color??g.stroke,strokeWidth:f.width??1.5,smoothing:f.smoothing,dash:f.style,fill:"none"});}return l}}}function Fe(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function je(i){if(!i)return {gaps:[],autoDetect:false,minGapMs:6e4};if(Array.isArray(i))return {gaps:i,autoDetect:false,minGapMs:6e4};let t=i.regions??[],e=i.style;return {gaps:t.map(r=>{let o={...e,...r.style},a=o.fill,s,l;return typeof a=="string"?s=a:a&&(s=a.color,l=a.hatch),{startTime:r.startTime,endTime:r.endTime,label:r.label,fill:s,hatch:l,fillOpacity:o.opacity,labelBaseline:o.label?.baseline,rotate:o.label?.rotate,style:o.display==="filled"||o.display==="bridge_line"?void 0:o.display}}),autoDetect:i.autoDetect??false,minGapMs:i.minGapMs??6e4}}function yt(i){return "showAs"in i&&!!i.showAs}var K=class{_layout;_renderer;_locale;_legend;_markers;_thresholds;_highlights;_gaps;_gapsAutoDetect;_gapsMinGapMs;_annotations;_annotationBands;_disabledAnnotations=new Set;_annotationSeq=0;_axes;_series;readonly_annotationBandHeight=0;_timeScale;_valueScales=new Map;constructor(t={}){this._layout=new nt({width:t.width??800,height:t.height??400,margin:t.margin??{top:20,right:20,bottom:40,left:60}}).compute(),this._renderer=t.renderer,this._locale=t.locale,this._legend=t.legend,this._markers=t.markers??[],this._thresholds=t.thresholds??[],this._highlights=t.highlights??[];let e=je(t.gaps);this._gaps=e.gaps,this._gapsAutoDetect=e.autoDetect,this._gapsMinGapMs=e.minGapMs,this._annotations=t.annotations??[],this._annotationBands=t.annotationBands??[],this._axes=t.axes,this._series=[],t.series&&this.setData(t.series);}getWidth(){return this._layout.totalWidth}getHeight(){return this._layout.totalHeight+this._annotationBandTotalHeight()}get series(){return this._series}_annotationBandTotalHeight(){let t=0;for(let e of this._annotationBands){let n=e.height??12,r=e.spacing??0;(e.showAxis??false)&&(t+=26+r),t+=n+r;}return t}setData(t){this._series=t.filter(e=>Array.isArray(e.data));}addAnnotation(t){let e=t.id??`anno-${++this._annotationSeq}`;return this._annotations.push({...t,id:e}),e}removeAnnotation(t){let e=this._annotations.length;return this._annotations=this._annotations.filter(n=>n.id!==t),this._disabledAnnotations.delete(t),this._annotations.length<e}setAnnotations(t){this._annotations=[...t],this._disabledAnnotations.clear();}clearAnnotations(){this._annotations=[],this._disabledAnnotations.clear();}getAnnotations(){return this._annotations}disableAnnotation(t){this._disabledAnnotations.add(t);}enableAnnotation(t){this._disabledAnnotations.delete(t);}_axisIndexOf(t){return t.yAxisIndex??0}_timesOf(t){return t.data.map(e=>e.time)}_valuesOf(t){if(yt(t)){let e=[];for(let n of t.data)n.min!==null&&e.push(n.min),n.max!==null&&e.push(n.max);return e}return t.data.map(e=>e.value).filter(e=>e!==null)}renderCommands(){if(this._series.length===0)return [];let t=this._legendItems(),e=(this._legend?.show??false)&&t.length>0,n=this._legend?.position??"inside-right",r=this._legend?.orientation??"vertical",o=e?ee(t,r):{width:0},a=this._layout;if(e&&(n==="outside-right"||n==="outside-left")){let p=o.width+16,x={...this._layout.margin};n==="outside-right"?x.right+=p:x.left+=p,a=new nt({width:this._layout.totalWidth,height:this._layout.totalHeight,margin:x}).compute();}let{chartX:s,chartY:l,chartWidth:h,chartHeight:d}=a,u=[s,s+h],m=[l,l+d],c=[];for(let p of this._series)p.data.sort((x,w)=>x.time-w.time);let f=new Map,y=1/0,b=-1/0,_=false;for(let p of this._series){let x=this._axisIndexOf(p),w=f.get(x);w?w.push(p):f.set(x,[p]);for(let A of this._timesOf(p))A<y&&(y=A),A>b&&(b=A),_=true;}if(!_)return [];let C=this._axes?.x?.domain,N=C&&C!=="auto"?C:[y,b];this._timeScale=new J({domain:N,range:u,locale:this._locale});let P=p=>({axisColor:p?.color??g.axisColor,tickColor:p?.color??g.tickColor,textColor:g.textColor,textSize:g.textSize,axisWidth:p?.width??1}),M=new tt({domain:N,xRange:u,y:l+d,locale:this._locale,format:this._axes?.x?.format,maxTicks:this._axes?.x?.ticks?.major,colors:P(this._axes?.x?.axis)});this._valueScales.clear();let R=Array.from(f.keys()).sort((p,x)=>p-x),B,G=0,I=0;for(let p of R){let x=f.get(p),w=1/0,A=-1/0,L=false;for(let V of x)for(let lt of this._valuesOf(V))lt<w&&(w=lt),lt>A&&(A=lt),L=true;if(!L)continue;let D;this._axes?.y&&this._axes.y.length>p?D=this._axes.y[p]:p===0?D=this._axes?.left:p===1&&(D=this._axes?.right);let $t=D?.domain,Z=$t&&$t!=="auto"?$t:[w,A],Ht=new X({domain:Z,range:[l+d,l]});this._valueScales.set(p,Ht);let Rt=this._thresholds.filter(V=>(V.axisIndex??0)===p&&V.label!==false&&V.value>=Math.min(Z[0],Z[1])&&V.value<=Math.max(Z[0],Z[1])).map(V=>Ht.map(V.value)),At=D?.position??(p===0?"left":"right"),Lt;if(At==="right"){let V=D?.offset!==void 0?D.offset:I*50;Lt=s+h+V,I++;}else {let V=D?.offset!==void 0?D.offset:G*50;Lt=s-V,G++;}let It=new dt({domain:Z,range:[l+d,l],x:Lt,position:At,format:D?.format,ticks:D?.ticks?.major,colors:P(D?.axis),suppressLabelsNear:Rt.length?Rt:void 0});p===0&&(B=It),c.push({type:"group",cssClass:`value-axis ${At}`,commands:It.render()});}let S=this._valueScales.get(0)??this._valueScales.get(R[0]);c.push({type:"group",cssClass:"time-axis",commands:M.render()});let v=null,k=this._axes?.x?.grid?.major,$=this._axes?.left?.grid?.major;if(k!==void 0||$!==void 0){let p=k!==false,x=$!==false&&!!B,w=p?M.generateTicks().map(L=>L.x):void 0,A=x?B.generateTicks().map(L=>L.position):void 0;if(w||A){let L=(k&&typeof k=="object"?k:void 0)??($&&typeof $=="object"?$:void 0);v={type:"group",cssClass:"chart-grid",commands:ie({xTicks:w,yTicks:A,xRange:u,yRange:m,stroke:L?.color,opacity:L?.opacity,dashed:L?.style==="dashed"})};}}if(this._highlights.length>0&&c.push({type:"group",cssClass:"highlights",commands:Jt({highlights:this._highlights,timeScale:this._timeScale,yRange:m,height:a.totalHeight})}),this._thresholds.length>0&&S){let p=[],x=[];for(let w of this._thresholds){let A=w.id??it(w.name),L=this._valueScales.get(w.axisIndex??0)??S,D=Kt({thresholds:[w],valueScale:L,xRange:u});D.inside.length&&p.push({type:"group",cssClass:`threshold threshold--${A}`,id:`threshold-${A}`,commands:D.inside}),D.labels.length&&x.push({type:"group",cssClass:`threshold-label threshold-label--${A}`,commands:D.labels});}p.length&&c.push({type:"group",cssClass:"thresholds",commands:p,clipRect:{x:s,y:l,w:h,h:d}}),x.length&&c.push({type:"group",cssClass:"threshold-labels",commands:x});}let j=this._gaps;if(this._gapsAutoDetect){let p=[];for(let x of this._series)yt(x)||p.push(...Nt(x.data,this._gapsMinGapMs));p.length>0&&(j=[...this._gaps,...p]);}j.length>0&&c.push({type:"group",cssClass:"gaps",commands:Zt({gaps:j,timeScale:this._timeScale,yRange:m})});let W=new Map(this._thresholds.map(p=>[p.id??p.name,p]));for(let p of this._series){if(p.data.length===0)continue;let x=this._valueScales.get(this._axisIndexOf(p));if(!x)continue;let w=it(p.id??p.name);c.push({type:"group",cssClass:`series series--${w}`,id:`series-${w}`,commands:this._renderSeries(p,x,W)});}v&&c.push(v);let Y=this._markers.map(p=>({...p}));for(let p of Y)if(p.value===void 0&&(p.lineStyle==="to-value"||p.lineStyle==="to-top")){let x=this._series[p.seriesIndex??0];x&&!yt(x)&&x.data.length>=2&&(p.value=this._interpolateValue(p.time,x.data));}Y.length>0&&S&&c.push({type:"group",cssClass:"markers",commands:Qt({markers:Y,timeScale:this._timeScale,valueScale:S,yRange:m})});let F=this._annotations.filter(p=>!p.id||!this._disabledAnnotations.has(p.id));if(F.length>0&&c.push({type:"group",cssClass:"annotations",commands:te({annotations:F,timeScale:this._timeScale,valueScales:this._valueScales})}),this._annotationBands.length>0){let p=l+d+this._layout.margin.bottom,x=0;this._annotationBands.forEach(w=>{let A=w.height??12,L=w.spacing??0,D=p+x;(w.showAxis??false)&&(x+=26+L),x+=A+L,c.push({type:"group",cssClass:"annotation-band",commands:new ft({name:w.name,showAxis:w.showAxis??false,items:w.items,timeScale:this._timeScale,background:w.background,hatch:w.hatch},[s,s+h],D,A).render()});});}if(e&&n!=="separate"){let p,x;n==="inside-right"?(p=s+h-o.width-8,x=l+8):n==="inside-left"?(p=s+8,x=l+8):n==="outside-right"?(p=s+h+16,x=l):(p=8,x=l),c.push(ne({items:t,x:p,y:x,orientation:r}));}let T=this._axes?.left?.label,O=this._axes?.right?.label,E=this._axes?.x?.label;if(T||O||E){let p=[],x=l+d/2,w=this._axes?.left?.labels,A=this._axes?.right?.labels,L=this._axes?.x?.labels;T&&p.push({type:"text",content:T,x:14,y:x,anchor:"middle",fontSize:w?.fontSize??g.axisLabelSize,fill:w?.color??g.axisLabelColor,rotate:-90}),O&&p.push({type:"text",content:O,x:a.totalWidth-14,y:x,anchor:"middle",fontSize:A?.fontSize??g.axisLabelSize,fill:A?.color??g.axisLabelColor,rotate:90}),E&&p.push({type:"text",content:E,x:s+h/2,y:a.totalHeight-6,anchor:"middle",fontSize:L?.fontSize??g.axisLabelSize,fill:L?.color??g.axisLabelColor}),p.length&&c.push({type:"group",cssClass:"axis-labels",commands:p});}return c}_renderSeries(t,e,n){let r=this._timeScale,o={timeScale:r,valueScale:e};if(yt(t)){let S=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,v=typeof t.style?.fill=="string"?t.style.fill:void 0;return t.showAs==="minmaxavg"?new ct({data:t.data,timeScale:r,valueScale:e,minColor:t.minColor,maxColor:t.maxColor,avgColor:t.avgColor,avgDashed:t.avgDashed,fillToMax:t.fillToMax,fillToMaxHatch:t.fillToMaxHatch,fillToMin:t.fillToMin,fillToMinHatch:t.fillToMinHatch,smoothing:S?.smoothing,strokeWidth:S?.width,id:rt(t.name,t.id)}).render():new pt({data:t.data,timeScale:r,valueScale:e,fill:v??S?.color,avgLine:t.avgLine,countOpacity:t.countOpacity,id:rt(t.name,t.id)}).render()}let a=t,s=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,l=s?.gapThreshold??g.gapThreshold,h=H.getRuns(t.data,S=>S.value===null,l),d=h.reduce((S,v)=>S+v.length,0);if(d===0)return [];let u=[],m=t.style?.markers,c=t.style?.shadow,f={stroke:s?.color??g.stroke,strokeWidth:s?.width??g.strokeWidth,smoothing:s?.smoothing,dashed:s?.style==="dashed",pointStyle:m?.type,pointSize:m?.size,pointStroke:m?.stroke,pointFill:m?.fill,pointStrokeWidth:m?.strokeWidth,shadowColor:c?.color,shadowBlur:c?.blur,shadowOffsetX:c?.offsetX,shadowOffsetY:c?.offsetY,id:rt(t.name,t.id)},y=t.style?.line,b=y&&!Array.isArray(y)?y:void 0,_=b?.color,C=b?.width,N=b?.style,P=b?.smoothing,M=t.style?.fill;if(M!==void 0){let S=e.range(),v=Math.min(S[0],S[1]),k=Math.max(S[0],S[1]);u.push(...ae(M,{runs:h,timeScale:r,valueScale:e,thresholds:n,chartTop:v,chartBottom:k,smoothing:s?.smoothing,idPrefix:t.id}));}let R=a.colorByThresholds??[],B=R.map(S=>n.get(S)).filter(S=>!!S).map(S=>S.value).sort((S,v)=>S-v),G=(S,v,k)=>{let $=k??f.stroke;for(let j of v){let W=n.get(j);W&&S>=W.value&&($=W.color??$);}return $};for(let S of h){if(S.length<2)continue;let v=H.splitByBoundaries(S,B,k=>k.value,H.interpolateDataPoint);for(let k=0;k<v.length;k++){let $=v[k];if($.data.length<2)continue;let j=($.data[0].value+$.data[$.data.length-1].value)/2,W=rt(a.name,a.id),Y=$.data.map(p=>({x:r.map(p.time),y:e.map(p.value)})),F=W?`${W}-line-${k}`:void 0,O=(b?.shape??s?.shape??a.seriesType)==="step",E=O?Xt(Y):Y;y===false||(y&&Array.isArray(y)?y.forEach((p,x)=>{u.push({type:"path",id:F?`${F}-${x}`:void 0,points:E,stroke:G(j,R,p.color),strokeWidth:p.width??f.strokeWidth,smoothing:O?false:p.smoothing??f.smoothing,dash:p.style,opacity:p.opacity,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY});}):u.push({type:"path",id:F,points:E,stroke:G(j,R,_),strokeWidth:C??f.strokeWidth,smoothing:O?false:P??f.smoothing,dash:N,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY}));}f.pointStyle&&f.pointStyle!=="none"&&d<=(m?.threshold??g.pointThreshold)&&u.push(...Ut(S,o,f,k=>G(k.value,R)));}let I=t.overlays;if(I&&I.length>0){let S=e.range(),v={data:t.data,timeScale:r,valueScale:e,chartTop:Math.min(S[0],S[1]),chartBottom:Math.max(S[0],S[1]),idPrefix:t.id};for(let k of I)u.push(...me(k,v));}if(t.style?.gap&&h.length>1){let S=e.range(),v=Math.min(S[0],S[1]),k=Math.max(S[0],S[1]),$=t.style.gap,j=$.fill,W,Y;typeof j=="string"?W=j:j&&(W=j.color,Y=j.hatch);let F=$.opacity??.15,T=$.bridge;for(let O=1;O<h.length;O++){let E=h[O-1][h[O-1].length-1],p=h[O][0],x=r.map(E.time),w=r.map(p.time);if($.display==="bridge_line"){if(E.value===null||p.value===null)continue;let A=e.map(E.value),L=e.map(p.value);u.push({type:"line",x1:x,y1:A,x2:w,y2:L,stroke:T?.color??(typeof t.style?.line=="object"&&!Array.isArray(t.style.line)?t.style.line.color:void 0)??g.stroke,strokeWidth:T?.width??1.5,dash:T?.style??"dotted"});}else W!==void 0?u.push({type:"rect",x,y:v,w:w-x,h:k-v,fill:W,hatch:Y,opacity:F,stroke:"none"}):$.display!=="empty"&&u.push({type:"rect",x,y:v,w:w-x,h:k-v,stroke:g.gapStroke,strokeWidth:1,dashed:true,fill:"none"});}}return u}_interpolateValue(t,e){for(let n=1;n<e.length;n++){let r=e[n-1],o=e[n];if(!(r.value===null||o.value===null)&&t>=r.time&&t<=o.time){let a=(t-r.time)/(o.time-r.time);return r.value+a*(o.value-r.value)}}}legendItems(){return this._legendItems()}_legendItems(){return this._series.map(t=>{let e=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,n=t.style?.markers,r=n?.type&&n.type!=="none"&&(n.threshold===void 0||(t.data?.length??0)<=n.threshold);return {name:t.name,color:e?.color??g.stroke,line:e?.style,marker:r?n.type:void 0}})}get renderer(){return this._renderer}get layout(){return this._layout}get timeScale(){return this._timeScale}get valueScales(){return this._valueScales}invertTime(t){return this._timeScale?this._timeScale.invert(t):0}invertValue(t,e=0){let n=this._valueScales.get(e);return n?n.invert(t):0}project(t,e,n=0){let r=this._timeScale?this._timeScale.map(t):0,o=this._valueScales.get(n);return {x:r,y:o?o.map(e):0}}};var bt=class{};function Oe(i){switch(i){case "top":return "text-top";case "bottom":return "text-bottom";default:return "middle"}}var q=class extends bt{#t="100%";#e="100%";#n;#i=new Map;#r=new Map;#o=new Map;constructor(t){super(),t?.width!==void 0&&(this.#t=t.width),t?.height!==void 0&&(this.#e=t.height),t?.background!==void 0&&(this.#n=t.background);}setBackgroundColor(t){this.#n=t;}render(t){this.#i.clear(),this.#r.clear(),this.#o.clear();let e=t.map(h=>this._toSVG(h));this.#n&&e.unshift(`<rect width="100%" height="100%" fill="${this._esc(this.#n)}" />`);let n=e.join(`
24
+ `.trim()}function Pt(i,t=2,e=false){return i==="dashed"||!i&&e?{strokeDasharray:"4,4"}:i==="dotted"?{strokeDasharray:"2,4"}:!i||i==="solid"?null:Vt(i,t)}function Vt(i,t=2){let e=t;switch(i){case "dotted":return {strokeDasharray:`0, ${e*2}`,strokeLinecap:"round"};case "sparse-dots":return {strokeDasharray:`0, ${e*4}`,strokeLinecap:"round"};case "dashed":return {strokeDasharray:`${e*3}, ${e*2}`,strokeLinecap:"butt"};case "long-dash":return {strokeDasharray:`${e*6}, ${e*3}`,strokeLinecap:"butt"};case "dense-dash":return {strokeDasharray:`${e*1.5}, ${e*1.5}`,strokeLinecap:"butt"};case "dash-dot":return {strokeDasharray:`${e*4}, ${e*2}, 0, ${e*2}`,strokeLinecap:"round"};case "dash-dot-dot":return {strokeDasharray:`${e*5}, ${e*2}, 0, ${e*2}, 0, ${e*2}`,strokeLinecap:"round"};case "loose-dash":return {strokeDasharray:`${e*3}, ${e*4}`,strokeLinecap:"butt"};default:return {strokeDasharray:"none",strokeLinecap:"butt"}}}var g=new Proxy({},{get:(i,t)=>Q()[t],has:(i,t)=>t in Q(),ownKeys:()=>Reflect.ownKeys(Q()),getOwnPropertyDescriptor:(i,t)=>Reflect.getOwnPropertyDescriptor(Q(),t)});var ot={axisColor:g.axisColor,tickColor:g.tickColor,textColor:g.textColor,textSize:g.textSize},tt=class{#t;#e;constructor(t){this.#t=new J({domain:t.domain,range:t.xRange,locale:t.locale}),this.#e=t;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??ot).axisColor}get tickColor(){return (this.#e.colors??ot).tickColor}get textColor(){return (this.#e.colors??ot).textColor}get textSize(){return (this.#e.colors??ot).textSize}generateTicks(){let t=this.#e.minTicks??5,e=this.#e.maxTicks??12,r=this.#t.ticks({minTicks:t,maxTicks:e}).map(o=>({time:o,x:this.#t.map(o),label:this.tickLabel(o)}));return this.antiOverlap(r)}tickLabel(t){if(this.#e.format)return this.#e.format(new Date(t));let e=this.#e.minTicks??5,n=this.#e.maxTicks??12,{interval:r}=this.#t.tickInterval((e+n)/2,e,n),o={};return r<6e4?(o.hour="2-digit",o.minute="2-digit",o.second="2-digit"):r<36e5||r<864e5?(o.hour="2-digit",o.minute="2-digit"):r<31536e6?(o.day="numeric",o.month="short",r>=2592e6&&(o.day=void 0,o.month="long")):(o.year="numeric",r<2*31536e6&&(o.month="short")),this.#t.format(t,o)}antiOverlap(t){if(t.length<=1)return t;let e=60,n=[t[0]];for(let r=1;r<t.length;r++){let o=n[n.length-1].x;Math.abs(t[r].x-o)>=e&&n.push(t[r]);}return n}render(){let t=this.generateTicks(),e=this.#e.colors??ot,n=this.#e.y??0,r=[],[o,a]=this.#t.range();r.push({type:"line",x1:o,y1:n,x2:a,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let s of t)r.push({type:"line",x1:s.x,y1:n,x2:s.x,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),r.push({type:"text",content:s.label,x:s.x,y:n+e.textSize+6,anchor:"middle",fontSize:e.textSize,fill:e.textColor});return r}};var st={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function we(i){return Math.abs(i)>=1e6?`${(i/1e6).toFixed(1)}M`:Math.abs(i)>=1e3?`${(i/1e3).toFixed(1)}k`:Number.isInteger(i)?String(i):i.toFixed(1)}function ve(i){let t=new Array(i.length).fill(false),e=0;for(;e<i.length;){let n=e;for(;n+1<i.length&&i[n+1].label===i[e].label;)n++;for(let r=e+1;r<n;r++)t[r]=true;e=n+1;}return t}var dt=class{#t;#e;constructor(t){this.#t=new X({domain:t.domain,range:t.range}),this.#e=t;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??st).axisColor}get tickColor(){return (this.#e.colors??st).tickColor}get textColor(){return (this.#e.colors??st).textColor}get textSize(){return (this.#e.colors??st).textSize}generateTicks(){let t=this.#e.format??we,e=6,[n,r]=this.#t.domain(),o=r-n;if(o===0)return [{value:n,position:this.#t.map(n),label:t(n)}];let a=o/e,s=Math.pow(10,Math.floor(Math.log10(a))),l=a/s,h;l<=1.5?h=s:l<=3?h=2*s:l<=7?h=5*s:h=10*s;let d=[],u=Math.ceil(n/h)*h;for(let m=u;m<=r;m+=h)d.push({value:m,position:this.#t.map(m),label:t(m)});return d}render(){let t=this.generateTicks(),e=this.#e.colors??st,n=this.#e.x??0,r=this.#e.orientation??"vertical",o=this.#e.position??"left",a=this.#e.suppressLabelsNear??[],s=this.#e.suppressTolerancePx??8,l=d=>a.some(u=>Math.abs(u-d)<=s),h=[];if(r==="vertical"){let[d,u]=this.#t.range();h.push({type:"line",x1:n,y1:d,x2:n,y2:u,stroke:e.axisColor,strokeWidth:e.axisWidth});let m=ve(t);t.forEach((c,f)=>{let y=l(c.position),b=m[f]?{opacity:0}:{};o==="left"?(h.push({type:"line",x1:n-4,y1:c.position,x2:n,y2:c.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||h.push({type:"text",content:c.label,x:n-8,y:c.position+4,anchor:"end",fontSize:11,fill:e.textColor,...b})):(h.push({type:"line",x1:n,y1:c.position,x2:n+4,y2:c.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),y||h.push({type:"text",content:c.label,x:n+8,y:c.position+4,anchor:"start",fontSize:11,fill:e.textColor,...b}));});}else {let[d,u]=this.#t.range();h.push({type:"line",x1:d,y1:n,x2:u,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let m of t)h.push({type:"line",x1:m.position,y1:n,x2:m.position,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),h.push({type:"text",content:m.label,x:m.position,y:n+18,anchor:"middle",fontSize:e.textSize,fill:e.textColor});}return h}};var H=class{static interpolateDataPoint(i,t,e){return {time:i.time+Math.round(e*(t.time-i.time)),value:(i.value??0)+e*((t.value??0)-(i.value??0))}}static interpolateAggregatedPoint(i,t,e){let n=(r,o)=>r!==null&&o!==null?r+e*(o-r):null;return {time:i.time+e*(t.time-i.time),min:n(i.min,t.min),max:n(i.max,t.max),avg:n(i.avg,t.avg),count:Math.round(i.count+e*(t.count-i.count))}}static getRuns(i,t,e=0){let n=[...i].sort((s,l)=>s.time-l.time),r=[],o=[],a=null;for(let s of n){let l=t(s),h=e>0&&a&&s.time-a.time>e;(l||h)&&o.length&&(r.push(o),o=[]),l||o.push(s),a=s;}return o.length&&r.push(o),r}static splitByBoundaries(i,t,e,n){if(i.length===0)return [];if(t.length===0)return [{data:i,zoneIndex:0}];let r=[...t].sort((l,h)=>l-h),o=[],a=l=>{let h=0;for(let d=0;d<r.length&&l>=r[d];d++)h=d+1;return h},s=[i[0]];for(let l=1;l<i.length;l++){let h=i[l-1],d=i[l],u=e(h),m=e(d),c;m>u?c=r.filter(f=>f>u&&f<=m):m<u?c=r.filter(f=>f>=m&&f<u).reverse():c=[];for(let f of c){let y=(f-u)/(m-u),b=n(h,d,y);s.push(b),o.push({data:s,zoneIndex:a((u+f)/2)}),s=[b];}s.push(d);}if(s.length>0){let l=e(s[0]),h=e(s[s.length-1]);o.push({data:s,zoneIndex:a((l+h)/2)});}return o}static splitByThreshold(i,t,e,n){let r=this.splitByBoundaries(i,[t],e,n),o={above:[],below:[]};for(let a of r)a.zoneIndex===0?o.below.push(a.data):o.above.push(a.data);return o}};function Nt(i,t=6e4){if(i.length<2)return [];let e=[...i].sort((r,o)=>r.time-o.time),n=[];for(let r=1;r<e.length;r++)e[r].time-e[r-1].time>t&&n.push({startTime:e[r-1].time,endTime:e[r].time});return n}function ke(i,t=83144){let e=t/8.314,n=0,r=0;for(let a of i)a!==null&&(n+=Math.exp(-e/(a+273.15)),r++);if(r===0)return null;let o=n/r;return e/-Math.log(o)-273.15}function Yt(i,t,e=83144){let n=new Array(i.length),r=0;for(let o=0;o<i.length;o++){let a=i[o].time,s=a-t;for(;r<o&&i[r].time<s;)r++;let l=i.slice(r,o+1).map(d=>d.value),h=ke(l,e);n[o]={time:a,value:h,synthetic:true};}return n}function Ce(i){let t=0,e=0;for(let o of i)o!==null&&(t+=o,e++);if(e===0)return null;let n=t/e,r=0;for(let o of i){if(o===null)continue;let a=o-n;r+=a*a;}return Math.sqrt(r/e)}function Te(i){let t=0,e=0;for(let o of i)o!==null&&(t+=o,e++);if(e<2)return null;let n=t/e,r=0;for(let o of i){if(o===null)continue;let a=o-n;r+=a*a;}return Math.sqrt(r/(e-1))}function zt(i,t,e=false){let n=new Array(i.length),r=0,o=e?Te:Ce;for(let a=0;a<i.length;a++){let s=i[a].time,l=s-t;for(;r<a&&i[r].time<l;)r++;let h=i.slice(r,a+1).map(u=>u.value),d=o(h);n[a]={time:s,value:d,synthetic:true};}return n}function qt(i){return {id:i.id,line:{stroke:i.stroke??g.stroke,strokeWidth:i.strokeWidth??g.strokeWidth,smoothing:i.smoothing??false,dashed:i.dashed??false},fill:i.fill??g.areaFillAlpha,markers:{type:i.pointStyle??"none",size:i.pointSize??g.pointSize,stroke:i.stroke??g.stroke,fill:"#ffffff"},shadow:{color:i.shadowColor??"transparent",blur:i.shadowBlur??0,offsetX:i.shadowOffsetX??0,offsetY:i.shadowOffsetY??0}}}function mt(i,t,e){let n=[],r=i.reduce((a,s)=>a+s.data.length,0),o=qt(e);for(let a=0;a<i.length;a++){let s=i[a];s.data.length>=2?n.push({type:"path",id:e.id?`${e.id}-line-${a}`:void 0,points:s.data.map(l=>({x:t.timeScale.map(l.time),y:t.valueScale.map(l.value)})),stroke:s.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:o.line.smoothing,dashed:o.line.dashed,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur,shadowOffsetX:o.shadow.offsetX,shadowOffsetY:o.shadow.offsetY,fill:"none"}):s.data.length===1&&r===1&&n.push({type:"circle",cx:t.timeScale.map(s.data[0].time),cy:t.valueScale.map(s.data[0].value),r:Math.max(o.markers.size,o.line.strokeWidth),fill:s.color??o.line.stroke,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur});}return n}function Xt(i){let t=[];for(let e of i)t.length===0?t.push(e):t.push({x:e.x,y:t[t.length-1].y},e);return t}function Bt(i,t,e,n){if(i.length<2)return [];let r=H.splitByBoundaries(i,e.boundaries,e.getValue,e.interpolate),o=[];for(let a=0;a<r.length;a++){let s=r[a];if(s.data.length<2)continue;let l=e.getColor(s.zoneIndex);if(!l)continue;let h=s.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yLow(u))})),d=s.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yHigh(u))})).reverse();o.push({type:"path",id:n?.id?`${n.id}-fill-${a}`:void 0,points:[...h,...d],fill:l,hatch:e.getHatch?.(s.zoneIndex),stroke:"none"});}return o}function Ut(i,t,e,n){let r=qt(e);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let a=0;a<i.length;a++){let s=i[a],l=t.timeScale.map(s.time),h=t.valueScale.map(s.value),d=n(s),u=e.pointStroke??d,m=e.pointFill??d,c=e.pointStrokeWidth??1.5,f=e.id?`${e.id}-marker-${a}`:void 0;ut(o,f,r.markers.type,l,h,r.markers.size,u,m,c);}return o}function ut(i,t,e,n,r,o,a,s,l){switch(e){case "circle":i.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:a,strokeWidth:l,id:t});break;case "square":i.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:s,stroke:a,strokeWidth:l,id:t});break;case "cross":i.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:a,strokeWidth:l,id:t},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:a,strokeWidth:l,id:t});break;case "diamond":i.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r},{x:n,y:r+o},{x:n-o,y:r}],fill:s,stroke:a,strokeWidth:l,id:t});break;case "triangle":i.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r+o},{x:n-o,y:r+o}],fill:s,stroke:a,strokeWidth:l,id:t});break;case "star":{let h=[];for(let d=0;d<10;d++){let u=d%2===0?o:o*.5,m=Math.PI/2*3+d*Math.PI/5;h.push({x:n+u*Math.cos(m),y:r+u*Math.sin(m)});}i.push({type:"path",points:h,fill:s,stroke:a,strokeWidth:l,id:t});break}case "arrow":i.push({type:"path",points:[{x:n-o,y:r+o},{x:n,y:r-o},{x:n+o,y:r+o}],stroke:a,strokeWidth:l,fill:"none",id:t});break;case "plus":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:a,strokeWidth:l,id:t},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:a,strokeWidth:l,id:t});break;case "triangle-down":i.push({type:"path",points:[{x:n,y:r+o},{x:n+o,y:r-o},{x:n-o,y:r-o}],fill:s,stroke:a,strokeWidth:l,id:t});break;case "hexagon":{let h=[];for(let d=0;d<6;d++){let u=d*(Math.PI/3);h.push({x:n+o*Math.cos(u),y:r+o*Math.sin(u)});}i.push({type:"path",points:h,fill:s,stroke:a,strokeWidth:l,id:t});break}case "hourglass":i.push({type:"path",points:[{x:n-o,y:r-o},{x:n+o,y:r-o},{x:n-o,y:r+o},{x:n+o,y:r+o}],fill:s,stroke:a,strokeWidth:l,id:t});break;case "line-horizontal":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:a,strokeWidth:l,id:t});break;default:i.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:a,strokeWidth:l,id:t});}}var et=class i{#t;#e;static uidcnt=0;#n;constructor(t,e=[]){this.#t=t.id??"series-"+ ++i.uidcnt,this.#e=t.timeScale,this.#n=e;}get id(){return this.#t}get timeScale(){return this.#e}get data(){return this.#n}};var ct=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}render(){let t=this.#t,e=t.minColor??g.minColor,n=t.maxColor??g.maxColor,r=t.avgColor??g.avgColor,o=t.avgDashed??true,a=t.smoothing??false,s=t.strokeWidth??g.strokeWidth,l=H.getRuns(this.data,c=>c.min===null||c.max===null||c.avg===null);if(l.length===0)return [];let h={timeScale:this.timeScale,valueScale:t.valueScale},d=[];l.forEach((c,f)=>{c.length<2||(t.fillToMax&&d.push(...Bt(c,h,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.max,getValue:y=>y.avg,interpolate:H.interpolateAggregatedPoint,getColor:()=>t.fillToMax,getHatch:()=>t.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${f}`:void 0})),t.fillToMin&&d.push(...Bt(c,h,{boundaries:[],yLow:y=>y.avg,yHigh:y=>y.min,getValue:y=>y.avg,interpolate:H.interpolateAggregatedPoint,getColor:()=>t.fillToMin,getHatch:()=>t.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${f}`:void 0})));});let u=l.filter(c=>c.length>=2),m=c=>u.map(f=>({data:f.map(y=>({time:y.time,value:c(y)}))}));return d.push(...mt(m(c=>c.max),h,{stroke:n,strokeWidth:s,smoothing:a,id:this.id?`${this.id}-max`:void 0}),...mt(m(c=>c.min),h,{stroke:e,strokeWidth:s,smoothing:a,id:this.id?`${this.id}-min`:void 0}),...mt(m(c=>c.avg),h,{stroke:r,strokeWidth:s,smoothing:a,dashed:o,id:this.id?`${this.id}-avg`:void 0})),d}};var pt=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}opacity(t){if(!(this.#t.countOpacity??false))return .6;let e=0;for(let n of this.data)n.count>e&&(e=n.count);return e===0?.2:.2+.8*t/e}render(){let t=this.#t,e=t.fill??g.bandFill,n=t.hatch,r=t.avgLine??false,o=t.avgLineColor??g.bandAvgLine,a=t.bandWidth??10,s=[];for(let l of this.data){if(l.min===null||l.max===null)continue;let h=this.timeScale.map(l.time),d=t.valueScale.map(l.max),u=t.valueScale.map(l.min),m=a,c=this.data.indexOf(l);if(s.push({type:"rect",x:h-m/2,y:d,w:m,h:u-d,fill:e,hatch:n,opacity:this.opacity(l.count),id:this.id?`${this.id}-slot-${c}`:void 0}),r&&l.avg!==null){let f=t.valueScale.map(l.avg);s.push({type:"line",x1:h-m/2,y1:f,x2:h+m/2,y2:f,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${c}`:void 0});}}return s}};function $e(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function Kt(i){let{thresholds:t,valueScale:e,xRange:n}=i,[r,o]=n,[a,s]=e.range(),l=Math.min(a,s),h=Math.max(a,s),d=[],u=[];for(let m of t){let c=m.color??g.thresholdColor,f=e.map(m.value);m.fill==="above"?d.push({type:"rect",x:r,y:l,w:o-r,h:Math.max(0,f-l),fill:c,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0}):m.fill==="below"&&d.push({type:"rect",x:r,y:f,w:o-r,h:Math.max(0,h-f),fill:c,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0});let y=m.line??g.thresholdLine;if(y!=="none"){let b=$e(y),_={type:"line",x1:r,y1:f,x2:o,y2:f,stroke:c,strokeWidth:1,...b,id:m.id?`${m.id}-line`:void 0};m.shadowColor&&(_.shadowColor=m.shadowColor,_.shadowBlur=m.shadowBlur??4,_.shadowOffsetX=m.shadowOffsetX??0,_.shadowOffsetY=m.shadowOffsetY??2),d.push(_);}if(m.label!==void 0&&m.label!==null&&m.label!==false){let b=typeof m.label=="object"?m.label:void 0,_=typeof m.label=="string"?m.label:b?.text??m.name,C=b?.position??"right";u.push({...Ae(_,C,r,o,f,c,b),id:m.id?`${m.id}-label`:void 0});}}return {inside:d,labels:u}}function Ae(i,t,e,n,r,o,a){let s=(e+n)/2,l={type:"text",content:i,fontSize:g.thresholdFontSize,fill:o},h=a?{...a.rotate!==void 0&&{rotate:a.rotate},...a.textBaseline!==void 0&&{textBaseline:a.textBaseline}}:{};switch(t){case "left":return {...l,...h,x:e+4,y:r-4,anchor:"start"};case "above":return {...l,...h,x:s,y:r-6,anchor:"middle"};case "below":return {...l,...h,x:s,y:r+14,anchor:"middle"};case "center":return {...l,...h,x:s,y:r-4,anchor:"middle"};case "outside-left":return {...l,...h,x:e-6,y:r+3,anchor:"end",textBaseline:h.textBaseline??"middle"};case "outside-right":return {...l,...h,x:n+6,y:r+3,anchor:"start",textBaseline:h.textBaseline??"middle"};default:return {...l,...h,x:n-4,y:r-4,anchor:"end"}}}function Zt(i){let{gaps:t,timeScale:e,yRange:n,fill:r=g.gapFill,hatch:o,fillOpacity:a=g.gapFillOpacity??.15,stroke:s=g.gapStroke,strokeWidth:l=g.gapStrokeWidth,dashed:h=true,fontSize:d=g.gapFontSize,fontFill:u=g.gapFontColor,labelBaseline:m="middle",labelRotate:c}=i,[f,y]=n,b=[];for(let _ of t){let C=e.map(_.startTime),N=e.map(_.endTime),P=_.fill??r,M=_.hatch??o,R=_.fillOpacity??a,B=_.label??"",G=_.rotate??c,I=_.labelBaseline??m;if(_.style==="dashed_border"||!_.style?b.push({type:"rect",x:C,y:f,w:N-C,h:y-f,fill:P,hatch:M,opacity:R,stroke:s,strokeWidth:l,dashed:h}):_.style==="empty"&&b.push({type:"rect",x:C,y:f,w:N-C,h:y-f,fill:P,hatch:M,opacity:R}),B){let S=Le(f,y,I),v=I==="above"?"top":I==="below"?"bottom":"middle";b.push({type:"text",content:B,x:(C+N)/2,y:S,anchor:"middle",fontSize:d,fill:u,textBaseline:v,rotate:G});}}return b}function Le(i,t,e){switch(e){case "above":return i-12;case "below":return t+4;default:return (i+t)/2}}var ft=class{#t;constructor(t,e,n,r){this.#t={...t,xRange:e,y:n,height:r};}render(){let{items:t,timeScale:e,background:n,hatch:r,showAxis:o,xRange:a,y:s,height:l}=this.#t,h=[];n&&h.push({type:"rect",x:a[0],y:s,w:a[1]-a[0],h:l,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let d of t){let u=e.map(d.startTime),m=e.map(d.endTime);if(!(m-u<1)&&(h.push({type:"rect",x:u,y:s,w:m-u,h:l,hatch:d.hatch??r,fill:d.fill??"#6b728044",stroke:d.stroke,strokeWidth:d.strokeWidth??0}),d.label)){let c=d.labelFontSize??10;h.push({type:"text",content:d.label,x:(u+m)/2,y:this.#e(d.labelBaseline,c),anchor:"middle",fontSize:c,fill:d.labelFill??"#333"});}}if(o){let d=new tt({domain:e.domain(),xRange:a,y:s+l+4});h.push({type:"group",cssClass:"annotation-band-axis",commands:d.render()});}return h}#e(t,e){let{y:n,height:r}=this.#t;switch(t){case "top":return n+e*.9;case "bottom":return n+r-e*.25;default:return n+r/2+e*.35}}};function Jt(i){let{highlights:t,timeScale:e,yRange:n,height:r}=i,[o,a]=n,s=[];for(let l of t){let h=e.map(l.startTime),d=e.map(l.endTime);s.push({type:"rect",x:h,y:o,w:d-h,h:a-o,fill:l.color??g.highlightColor,opacity:l.opacity??g.highlightOpacity}),l.label&&s.push({type:"text",content:l.label,x:(h+d)/2,y:Me(l.labelPosition??"top",o,a,r),anchor:"middle",fontSize:g.annotationFontSize,fill:l.color??g.highlightLabelColor,rotate:l.rotate});}return s}function Me(i,t,e,n){switch(i){case "above":return t-5;case "below":return n!==void 0?n-5:e+14;case "center":return (t+e)/2+4;case "bottom":return e-6;default:return t+14}}function Qt(i){let{markers:t,timeScale:e,valueScale:n,yRange:r=[0,300]}=i,[o,a]=r,s=[];for(let l of t){let h=e.map(l.time),d=l.color??g.markerColor,u=l.pointStyle??(l.value!==void 0?"circle":"none"),m=l.lineStyle??"full";if(l.value!==void 0){let c=n.map(l.value);if(m==="to-value"?s.push({type:"line",x1:h,y1:a,x2:h,y2:c,stroke:d,strokeWidth:1,dashed:true}):m==="to-top"?s.push({type:"line",x1:h,y1:o,x2:h,y2:c,stroke:d,strokeWidth:1,dashed:true}):m==="full"&&s.push({type:"line",x1:h,y1:o,x2:h,y2:a,stroke:d,strokeWidth:1}),u!=="none"&&ut(s,void 0,u,h,c,g.markerSize,d,d,1.5),l.label){let f=m==="to-value"?c-10:o-6;s.push({type:"text",content:l.label,x:h,y:f,anchor:"middle",fontSize:11,fill:d});}}else s.push({type:"line",x1:h,y1:o,x2:h,y2:a,stroke:d,strokeWidth:1}),l.label&&s.push({type:"text",content:l.label,x:h,y:o-6,anchor:"middle",fontSize:11,fill:d});}return s}function te(i){let{annotations:t,timeScale:e,valueScales:n}=i,r=[],o=a=>{let s=n.get(a.axis??0)??n.values().next().value;return {x:e.map(a.time),y:s?s.map(a.value):0}};for(let a of t){let s=[],l=h=>s.push(h);switch(a.type){case "line":{let h=o(a.from),d=o(a.to);l({type:"line",x1:h.x,y1:h.y,x2:d.x,y2:d.y,stroke:a.color??g.annotationColor,strokeWidth:a.width??g.annotationWidth,dash:a.dash});break}case "arrow":{let h=o(a.from),d=o(a.to),u=a.color??g.annotationColor,m=a.headSize??g.annotationHead;l({type:"line",x1:h.x,y1:h.y,x2:d.x,y2:d.y,stroke:u,strokeWidth:a.width??g.annotationWidth});let c=Math.hypot(d.x-h.x,d.y-h.y)||1,f=(d.x-h.x)/c,y=(d.y-h.y)/c,b=d.x-f*m,_=d.y-y*m;l({type:"path",points:[{x:d.x,y:d.y},{x:b-y*m*.5,y:_+f*m*.5},{x:b+y*m*.5,y:_-f*m*.5}],fill:u,stroke:"none"});break}case "rect":{let h=o(a.from),d=o(a.to);l({type:"rect",x:Math.min(h.x,d.x),y:Math.min(h.y,d.y),w:Math.abs(d.x-h.x),h:Math.abs(d.y-h.y),fill:a.fill??"none",stroke:a.stroke,opacity:a.opacity});break}case "point":{let h=o(a.at),d=a.color??"#334155",u=a.radius??g.annotationRadius,m=a.shape??"circle";m==="circle"?l({type:"circle",cx:h.x,cy:h.y,r:u,fill:d}):m==="square"?l({type:"rect",x:h.x-u,y:h.y-u,w:u*2,h:u*2,fill:d}):(l({type:"line",x1:h.x-u,y1:h.y-u,x2:h.x+u,y2:h.y+u,stroke:d,strokeWidth:1.5}),l({type:"line",x1:h.x-u,y1:h.y+u,x2:h.x+u,y2:h.y-u,stroke:d,strokeWidth:1.5}));break}case "label":{let h=o(a.at);l({type:"text",content:a.text,x:h.x+(a.dx??0),y:h.y+(a.dy??0),anchor:a.anchor??"middle",fontSize:g.annotationFontSize,fill:a.color??g.annotationColor,rotate:a.rotate});break}}if(a.id&&s.length>0){let h=it(a.id);r.push({type:"group",cssClass:`annotation annotation--${h}`,commands:s});}else r.push(...s);}return r}var U=12,gt=8,Ft=20,De=11,jt=18,Ot=i=>i.length*De*.6;function ee(i,t="vertical"){if(t==="horizontal"){let n=0;for(let r of i)n+=U+gt+Ot(r.name)+jt;return {width:Math.max(0,n-jt),height:Ft}}let e=0;for(let n of i)e=Math.max(e,Ot(n.name));return {width:U+gt+e,height:i.length*Ft}}function ne(i){let{items:t,x:e,y:n,orientation:r="vertical"}=i,o=[],a=e;return t.forEach((s,l)=>{let h=r==="horizontal"?a:e,d=r==="horizontal"?n:n+l*Ft;o.push({type:"rect",x:h,y:d,w:U,h:U,fill:s.color,stroke:g.legendStroke,strokeWidth:1},{type:"text",content:s.name,x:h+U+gt,y:d+U-2,fontSize:g.legendFont,fill:g.legendText}),r==="horizontal"&&(a+=U+gt+Ot(s.name)+jt);}),{type:"group",cssClass:"chart-legend",commands:o}}function ie(i){let{xTicks:t,yTicks:e,xRange:n,yRange:r,stroke:o=g.gridStroke,strokeWidth:a=g.gridStrokeWidth,dashed:s=false,opacity:l=g.gridOpacity}=i,h=[];if(e)for(let d of e)h.push({type:"line",x1:n[0],y1:d,x2:n[1],y2:d,stroke:o,strokeWidth:a,dashed:s,opacity:l});if(t)for(let d of t)h.push({type:"line",x1:d,y1:r[0],x2:d,y2:r[1],stroke:o,strokeWidth:a,dashed:s,opacity:l});return h}function re(i,t,e){let n=i??t;if(n==="series")return null;if(n==="chartTop")return e.chartTop;if(n==="chartBottom")return e.chartBottom;if(typeof n=="object"&&"threshold"in n){let r=e.thresholds.get(n.threshold);if(!r)throw new Error(`fillSpec region references unknown threshold '${n.threshold}'`);return e.valueScale.map(r.value)}return typeof n=="object"&&"value"in n?e.valueScale.map(n.value):null}function Pe(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function oe(i,t,e){let n=re(i.from,"chartBottom",t),r=re(i.to,"series",t),{color:o,hatch:a}=Pe(i.fill),s={type:"path",fill:o,hatch:a,stroke:"none",...t.idPrefix&&{id:`${t.idPrefix}-fill-r${e}`}};if(n!==null&&r!==null){let m=t.timeScale.range(),c=m[0],f=m[1],y=Math.min(n,r),b=Math.max(n,r);return [{...s,points:[{x:c,y},{x:f,y},{x:f,y:b},{x:c,y:b}]}]}let l=n??r,h=[],d=Be(i,t);if(d===null){let m=t.valueScale.domain();d=(n??r)===t.chartBottom?m[0]:m[1];}let u=se(i.outer,t);for(let m of t.runs){if(m.length<2)continue;let c=H.splitByThreshold(m,d,y=>y.value??d,H.interpolateDataPoint),f=i.side==="above"?c.above:i.side==="below"?c.below:[...c.above,...c.below];if(u!==null&&i.side){let y=i.side==="above"?"below":"above";f=f.flatMap(b=>{if(b.length<2)return [];let _=H.splitByThreshold(b,u,C=>C.value??u,H.interpolateDataPoint);return y==="above"?_.above:_.below});}for(let y of f){if(y.length<2)continue;let b=y.map(C=>({x:t.timeScale.map(C.time),y:t.valueScale.map(C.value)})),_=[...b].reverse().map(C=>({x:C.x,y:l}));h.push({...s,smoothing:t.smoothing,smoothCount:b.length,points:[...b,..._]});}}return h}function Be(i,t){let e=i.from==="series"?i.to:i.from;return se(e,t)}function se(i,t){return i===void 0||i==="series"||i==="chartTop"||i==="chartBottom"?null:typeof i=="object"&&"threshold"in i?t.thresholds.get(i.threshold)?.value??null:typeof i=="object"&&"value"in i?i.value:null}function ae(i,t){if(typeof i=="string"||!("regions"in i))return oe({fill:i},t,0);let e=[];return i.regions.forEach((n,r)=>{e.push(...oe(n,t,r));}),e}function le(i,t){let e=new Array(i.length),n=0;for(let r=0;r<i.length;r++){let o=i[r].time,a=o-t;for(;n<r&&i[n].time<a;)n++;let s=0,l=0;for(let h=n;h<=r;h++){let d=i[h].value;d!==null&&(s+=d,l++);}e[r]={time:o,value:l===0?null:s/l,synthetic:true};}return e}function de(i){let t=i.style?.line,e=t&&!Array.isArray(t)?t:void 0;return {color:e?.color??g.stroke,width:e?.width??g.strokeWidth,dash:e?.style,smoothing:e?.smoothing??false}}function he(i,t,e,n){let r=i.filter(l=>l.value!==null);if(r.length<2)return [];let o=r.map(l=>({x:t.timeScale.map(l.time),y:t.valueScale.map(l.value)})),a=de(e);return [{type:"path",id:t.idPrefix?`${t.idPrefix}-overlay-${n}`:`overlay-${n}`,points:o,stroke:a.color,strokeWidth:a.width,smoothing:a.smoothing,dash:a.dash,fill:"none"}]}function me(i,t){switch(i.kind){case "movingAverage":{i.type;let e=le(t.data,i.window);return he(e,t,i,"movingAvg")}case "movingMkt":{let e=Yt(t.data,i.window,i.activationEnergy);return he(e,t,i,"movingMkt")}case "limits":{let e=[],n=t.timeScale.range(),r=n[0],o=n[1],a=de(i),s=a.color,l=a.width,h=a.dash??"dashed",d=t.idPrefix?`${t.idPrefix}-`:"";return i.high!==void 0&&e.push({type:"line",id:`${d}overlay-limit-high`,x1:r,y1:t.valueScale.map(i.high),x2:o,y2:t.valueScale.map(i.high),stroke:s,strokeWidth:l,dash:h}),i.low!==void 0&&e.push({type:"line",id:`${d}overlay-limit-low`,x1:r,y1:t.valueScale.map(i.low),x2:o,y2:t.valueScale.map(i.low),stroke:s,strokeWidth:l,dash:h}),e}case "stdDevBand":{let e=i.multiplier??1,n=le(t.data,i.window),r=zt(t.data,i.window),o=[],a=[];for(let y=0;y<n.length;y++){let b=n[y].value,_=r[y].value;if(b===null||_===null)continue;let C=t.timeScale.map(n[y].time);o.push({x:C,y:t.valueScale.map(b+e*_)}),a.push({x:C,y:t.valueScale.map(b-e*_)});}if(o.length<2)return [];let s=t.idPrefix?`${t.idPrefix}-`:"",l=[],d=(typeof i.style?.fill=="string"||i.style?.fill&&!("regions"in i.style.fill)?i.style.fill:void 0)??"#94a3b833",{color:u,hatch:m}=Fe(d);l.push({type:"path",id:`${s}overlay-stdDevBand`,points:[...o,...[...a].reverse()],fill:u,hatch:m,stroke:"none"});let c=i.style?.line,f=c&&!Array.isArray(c)?c:void 0;if(f){let y=n.filter(b=>b.value!==null).map(b=>({x:t.timeScale.map(b.time),y:t.valueScale.map(b.value)}));y.length>=2&&l.push({type:"path",id:`${s}overlay-stdDevBand-mean`,points:y,stroke:f.color??g.stroke,strokeWidth:f.width??1.5,smoothing:f.smoothing,dash:f.style,fill:"none"});}return l}}}function Fe(i){return typeof i=="string"?{color:i}:{color:i.color,hatch:i.hatch}}function je(i){if(!i)return {gaps:[],autoDetect:false,minGapMs:6e4};if(Array.isArray(i))return {gaps:i,autoDetect:false,minGapMs:6e4};let t=i.regions??[],e=i.style;return {gaps:t.map(r=>{let o={...e,...r.style},a=o.fill,s,l;return typeof a=="string"?s=a:a&&(s=a.color,l=a.hatch),{startTime:r.startTime,endTime:r.endTime,label:r.label,fill:s,hatch:l,fillOpacity:o.opacity,labelBaseline:o.label?.baseline,rotate:o.label?.rotate,style:o.display==="filled"||o.display==="bridge_line"?void 0:o.display}}),autoDetect:i.autoDetect??false,minGapMs:i.minGapMs??6e4}}function yt(i){return "showAs"in i&&!!i.showAs}var K=class{_layout;_renderer;_locale;_legend;_clipSeries;_markers;_thresholds;_highlights;_gaps;_gapsAutoDetect;_gapsMinGapMs;_annotations;_annotationBands;_disabledAnnotations=new Set;_annotationSeq=0;_axes;_series;readonly_annotationBandHeight=0;_timeScale;_valueScales=new Map;constructor(t={}){this._layout=new nt({width:t.width??800,height:t.height??400,margin:t.margin??{top:20,right:20,bottom:40,left:60}}).compute(),this._renderer=t.renderer,this._locale=t.locale,this._legend=t.legend,this._clipSeries=t.clipSeries??true,this._markers=t.markers??[],this._thresholds=t.thresholds??[],this._highlights=t.highlights??[];let e=je(t.gaps);this._gaps=e.gaps,this._gapsAutoDetect=e.autoDetect,this._gapsMinGapMs=e.minGapMs,this._annotations=t.annotations??[],this._annotationBands=t.annotationBands??[],this._axes=t.axes,this._series=[],t.series&&this.setData(t.series);}getWidth(){return this._layout.totalWidth}getHeight(){return this._layout.totalHeight+this._annotationBandTotalHeight()}get series(){return this._series}_annotationBandTotalHeight(){let t=0;for(let e of this._annotationBands){let n=e.height??12,r=e.spacing??0;(e.showAxis??false)&&(t+=26+r),t+=n+r;}return t}setData(t){this._series=t.filter(e=>Array.isArray(e.data));}addAnnotation(t){let e=t.id??`anno-${++this._annotationSeq}`;return this._annotations.push({...t,id:e}),e}removeAnnotation(t){let e=this._annotations.length;return this._annotations=this._annotations.filter(n=>n.id!==t),this._disabledAnnotations.delete(t),this._annotations.length<e}setAnnotations(t){this._annotations=[...t],this._disabledAnnotations.clear();}clearAnnotations(){this._annotations=[],this._disabledAnnotations.clear();}getAnnotations(){return this._annotations}disableAnnotation(t){this._disabledAnnotations.add(t);}enableAnnotation(t){this._disabledAnnotations.delete(t);}_axisIndexOf(t){return t.yAxisIndex??0}_timesOf(t){return t.data.map(e=>e.time)}_valuesOf(t){if(yt(t)){let e=[];for(let n of t.data)n.min!==null&&e.push(n.min),n.max!==null&&e.push(n.max);return e}return t.data.map(e=>e.value).filter(e=>e!==null)}renderCommands(){if(this._series.length===0)return [];let t=this._legendItems(),e=(this._legend?.show??false)&&t.length>0,n=this._legend?.position??"inside-right",r=this._legend?.orientation??"vertical",o=e?ee(t,r):{width:0},a=this._layout;if(e&&(n==="outside-right"||n==="outside-left")){let p=o.width+16,x={...this._layout.margin};n==="outside-right"?x.right+=p:x.left+=p,a=new nt({width:this._layout.totalWidth,height:this._layout.totalHeight,margin:x}).compute();}let{chartX:s,chartY:l,chartWidth:h,chartHeight:d}=a,u=[s,s+h],m=[l,l+d],c=[];for(let p of this._series)p.data.sort((x,w)=>x.time-w.time);let f=new Map,y=1/0,b=-1/0,_=false;for(let p of this._series){let x=this._axisIndexOf(p),w=f.get(x);w?w.push(p):f.set(x,[p]);for(let A of this._timesOf(p))A<y&&(y=A),A>b&&(b=A),_=true;}if(!_)return [];let C=this._axes?.x?.domain,N=C&&C!=="auto"?C:[y,b];this._timeScale=new J({domain:N,range:u,locale:this._locale});let P=p=>({axisColor:p?.color??g.axisColor,tickColor:p?.color??g.tickColor,textColor:g.textColor,textSize:g.textSize,axisWidth:p?.width??1}),M=new tt({domain:N,xRange:u,y:l+d,locale:this._locale,format:this._axes?.x?.format,maxTicks:this._axes?.x?.ticks?.major,colors:P(this._axes?.x?.axis)});this._valueScales.clear();let R=Array.from(f.keys()).sort((p,x)=>p-x),B,G=0,I=0;for(let p of R){let x=f.get(p),w=1/0,A=-1/0,L=false;for(let V of x)for(let lt of this._valuesOf(V))lt<w&&(w=lt),lt>A&&(A=lt),L=true;if(!L)continue;let D;this._axes?.y&&this._axes.y.length>p?D=this._axes.y[p]:p===0?D=this._axes?.left:p===1&&(D=this._axes?.right);let $t=D?.domain,Z=$t&&$t!=="auto"?$t:[w,A],Ht=new X({domain:Z,range:[l+d,l]});this._valueScales.set(p,Ht);let Rt=this._thresholds.filter(V=>(V.axisIndex??0)===p&&V.label!==false&&V.value>=Math.min(Z[0],Z[1])&&V.value<=Math.max(Z[0],Z[1])).map(V=>Ht.map(V.value)),At=D?.position??(p===0?"left":"right"),Lt;if(At==="right"){let V=D?.offset!==void 0?D.offset:I*50;Lt=s+h+V,I++;}else {let V=D?.offset!==void 0?D.offset:G*50;Lt=s-V,G++;}let It=new dt({domain:Z,range:[l+d,l],x:Lt,position:At,format:D?.format,ticks:D?.ticks?.major,colors:P(D?.axis),suppressLabelsNear:Rt.length?Rt:void 0});p===0&&(B=It),c.push({type:"group",cssClass:`value-axis ${At}`,commands:It.render()});}let S=this._valueScales.get(0)??this._valueScales.get(R[0]);c.push({type:"group",cssClass:"time-axis",commands:M.render()});let v=null,k=this._axes?.x?.grid?.major,$=this._axes?.left?.grid?.major;if(k!==void 0||$!==void 0){let p=k!==false,x=$!==false&&!!B,w=p?M.generateTicks().map(L=>L.x):void 0,A=x?B.generateTicks().map(L=>L.position):void 0;if(w||A){let L=(k&&typeof k=="object"?k:void 0)??($&&typeof $=="object"?$:void 0);v={type:"group",cssClass:"chart-grid",commands:ie({xTicks:w,yTicks:A,xRange:u,yRange:m,stroke:L?.color,opacity:L?.opacity,dashed:L?.style==="dashed"})};}}if(this._highlights.length>0&&c.push({type:"group",cssClass:"highlights",commands:Jt({highlights:this._highlights,timeScale:this._timeScale,yRange:m,height:a.totalHeight})}),this._thresholds.length>0&&S){let p=[],x=[];for(let w of this._thresholds){let A=w.id??it(w.name),L=this._valueScales.get(w.axisIndex??0)??S,D=Kt({thresholds:[w],valueScale:L,xRange:u});D.inside.length&&p.push({type:"group",cssClass:`threshold threshold--${A}`,id:`threshold-${A}`,commands:D.inside}),D.labels.length&&x.push({type:"group",cssClass:`threshold-label threshold-label--${A}`,commands:D.labels});}p.length&&c.push({type:"group",cssClass:"thresholds",commands:p,clipRect:{x:s,y:l,w:h,h:d}}),x.length&&c.push({type:"group",cssClass:"threshold-labels",commands:x});}let j=this._gaps;if(this._gapsAutoDetect){let p=[];for(let x of this._series)yt(x)||p.push(...Nt(x.data,this._gapsMinGapMs));p.length>0&&(j=[...this._gaps,...p]);}j.length>0&&c.push({type:"group",cssClass:"gaps",commands:Zt({gaps:j,timeScale:this._timeScale,yRange:m})});let W=new Map(this._thresholds.map(p=>[p.id??p.name,p]));for(let p of this._series){if(p.data.length===0)continue;let x=this._valueScales.get(this._axisIndexOf(p));if(!x)continue;let w=it(p.id??p.name);c.push({type:"group",cssClass:`series series--${w}`,id:`series-${w}`,commands:this._renderSeries(p,x,W),...this._clipSeries?{clipRect:{x:s,y:l,w:h,h:d}}:{}});}v&&c.push(v);let Y=this._markers.map(p=>({...p}));for(let p of Y)if(p.value===void 0&&(p.lineStyle==="to-value"||p.lineStyle==="to-top")){let x=this._series[p.seriesIndex??0];x&&!yt(x)&&x.data.length>=2&&(p.value=this._interpolateValue(p.time,x.data));}Y.length>0&&S&&c.push({type:"group",cssClass:"markers",commands:Qt({markers:Y,timeScale:this._timeScale,valueScale:S,yRange:m})});let F=this._annotations.filter(p=>!p.id||!this._disabledAnnotations.has(p.id));if(F.length>0&&c.push({type:"group",cssClass:"annotations",commands:te({annotations:F,timeScale:this._timeScale,valueScales:this._valueScales})}),this._annotationBands.length>0){let p=l+d+this._layout.margin.bottom,x=0;this._annotationBands.forEach(w=>{let A=w.height??12,L=w.spacing??0,D=p+x;(w.showAxis??false)&&(x+=26+L),x+=A+L,c.push({type:"group",cssClass:"annotation-band",commands:new ft({name:w.name,showAxis:w.showAxis??false,items:w.items,timeScale:this._timeScale,background:w.background,hatch:w.hatch},[s,s+h],D,A).render()});});}if(e&&n!=="separate"){let p,x;n==="inside-right"?(p=s+h-o.width-8,x=l+8):n==="inside-left"?(p=s+8,x=l+8):n==="outside-right"?(p=s+h+16,x=l):(p=8,x=l),c.push(ne({items:t,x:p,y:x,orientation:r}));}let T=this._axes?.left?.label,O=this._axes?.right?.label,E=this._axes?.x?.label;if(T||O||E){let p=[],x=l+d/2,w=this._axes?.left?.labels,A=this._axes?.right?.labels,L=this._axes?.x?.labels;T&&p.push({type:"text",content:T,x:14,y:x,anchor:"middle",fontSize:w?.fontSize??g.axisLabelSize,fill:w?.color??g.axisLabelColor,rotate:-90}),O&&p.push({type:"text",content:O,x:a.totalWidth-14,y:x,anchor:"middle",fontSize:A?.fontSize??g.axisLabelSize,fill:A?.color??g.axisLabelColor,rotate:90}),E&&p.push({type:"text",content:E,x:s+h/2,y:a.totalHeight-6,anchor:"middle",fontSize:L?.fontSize??g.axisLabelSize,fill:L?.color??g.axisLabelColor}),p.length&&c.push({type:"group",cssClass:"axis-labels",commands:p});}return c}_renderSeries(t,e,n){let r=this._timeScale,o={timeScale:r,valueScale:e};if(yt(t)){let S=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,v=typeof t.style?.fill=="string"?t.style.fill:void 0;return t.showAs==="minmaxavg"?new ct({data:t.data,timeScale:r,valueScale:e,minColor:t.minColor,maxColor:t.maxColor,avgColor:t.avgColor,avgDashed:t.avgDashed,fillToMax:t.fillToMax,fillToMaxHatch:t.fillToMaxHatch,fillToMin:t.fillToMin,fillToMinHatch:t.fillToMinHatch,smoothing:S?.smoothing,strokeWidth:S?.width,id:rt(t.name,t.id)}).render():new pt({data:t.data,timeScale:r,valueScale:e,fill:v??S?.color,avgLine:t.avgLine,countOpacity:t.countOpacity,id:rt(t.name,t.id)}).render()}let a=t,s=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,l=s?.gapThreshold??g.gapThreshold,h=H.getRuns(t.data,S=>S.value===null,l),d=h.reduce((S,v)=>S+v.length,0);if(d===0)return [];let u=[],m=t.style?.markers,c=t.style?.shadow,f={stroke:s?.color??g.stroke,strokeWidth:s?.width??g.strokeWidth,smoothing:s?.smoothing,dashed:s?.style==="dashed",pointStyle:m?.type,pointSize:m?.size,pointStroke:m?.stroke,pointFill:m?.fill,pointStrokeWidth:m?.strokeWidth,shadowColor:c?.color,shadowBlur:c?.blur,shadowOffsetX:c?.offsetX,shadowOffsetY:c?.offsetY,id:rt(t.name,t.id)},y=t.style?.line,b=y&&!Array.isArray(y)?y:void 0,_=b?.color,C=b?.width,N=b?.style,P=b?.smoothing,M=t.style?.fill;if(M!==void 0){let S=e.range(),v=Math.min(S[0],S[1]),k=Math.max(S[0],S[1]);u.push(...ae(M,{runs:h,timeScale:r,valueScale:e,thresholds:n,chartTop:v,chartBottom:k,smoothing:s?.smoothing,idPrefix:t.id}));}let R=a.colorByThresholds??[],B=R.map(S=>n.get(S)).filter(S=>!!S).map(S=>S.value).sort((S,v)=>S-v),G=(S,v,k)=>{let $=k??f.stroke;for(let j of v){let W=n.get(j);W&&S>=W.value&&($=W.color??$);}return $};for(let S of h){if(S.length<2)continue;let v=H.splitByBoundaries(S,B,k=>k.value,H.interpolateDataPoint);for(let k=0;k<v.length;k++){let $=v[k];if($.data.length<2)continue;let j=($.data[0].value+$.data[$.data.length-1].value)/2,W=rt(a.name,a.id),Y=$.data.map(p=>({x:r.map(p.time),y:e.map(p.value)})),F=W?`${W}-line-${k}`:void 0,O=(b?.shape??s?.shape??a.seriesType)==="step",E=O?Xt(Y):Y;y===false||(y&&Array.isArray(y)?y.forEach((p,x)=>{u.push({type:"path",id:F?`${F}-${x}`:void 0,points:E,stroke:G(j,R,p.color),strokeWidth:p.width??f.strokeWidth,smoothing:O?false:p.smoothing??f.smoothing,dash:p.style,opacity:p.opacity,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY});}):u.push({type:"path",id:F,points:E,stroke:G(j,R,_),strokeWidth:C??f.strokeWidth,smoothing:O?false:P??f.smoothing,dash:N,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY}));}f.pointStyle&&f.pointStyle!=="none"&&d<=(m?.threshold??g.pointThreshold)&&u.push(...Ut(S,o,f,k=>G(k.value,R)));}let I=t.overlays;if(I&&I.length>0){let S=e.range(),v={data:t.data,timeScale:r,valueScale:e,chartTop:Math.min(S[0],S[1]),chartBottom:Math.max(S[0],S[1]),idPrefix:t.id};for(let k of I)u.push(...me(k,v));}if(t.style?.gap&&h.length>1){let S=e.range(),v=Math.min(S[0],S[1]),k=Math.max(S[0],S[1]),$=t.style.gap,j=$.fill,W,Y;typeof j=="string"?W=j:j&&(W=j.color,Y=j.hatch);let F=$.opacity??.15,T=$.bridge;for(let O=1;O<h.length;O++){let E=h[O-1][h[O-1].length-1],p=h[O][0],x=r.map(E.time),w=r.map(p.time);if($.display==="bridge_line"){if(E.value===null||p.value===null)continue;let A=e.map(E.value),L=e.map(p.value);u.push({type:"line",x1:x,y1:A,x2:w,y2:L,stroke:T?.color??(typeof t.style?.line=="object"&&!Array.isArray(t.style.line)?t.style.line.color:void 0)??g.stroke,strokeWidth:T?.width??1.5,dash:T?.style??"dotted"});}else W!==void 0?u.push({type:"rect",x,y:v,w:w-x,h:k-v,fill:W,hatch:Y,opacity:F,stroke:"none"}):$.display!=="empty"&&u.push({type:"rect",x,y:v,w:w-x,h:k-v,stroke:g.gapStroke,strokeWidth:1,dashed:true,fill:"none"});}}return u}_interpolateValue(t,e){for(let n=1;n<e.length;n++){let r=e[n-1],o=e[n];if(!(r.value===null||o.value===null)&&t>=r.time&&t<=o.time){let a=(t-r.time)/(o.time-r.time);return r.value+a*(o.value-r.value)}}}legendItems(){return this._legendItems()}_legendItems(){return this._series.map(t=>{let e=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,n=t.style?.markers,r=n?.type&&n.type!=="none"&&(n.threshold===void 0||(t.data?.length??0)<=n.threshold);return {name:t.name,color:e?.color??g.stroke,line:e?.style,marker:r?n.type:void 0}})}get renderer(){return this._renderer}get layout(){return this._layout}get timeScale(){return this._timeScale}get valueScales(){return this._valueScales}invertTime(t){return this._timeScale?this._timeScale.invert(t):0}invertValue(t,e=0){let n=this._valueScales.get(e);return n?n.invert(t):0}project(t,e,n=0){let r=this._timeScale?this._timeScale.map(t):0,o=this._valueScales.get(n);return {x:r,y:o?o.map(e):0}}};var bt=class{};function Oe(i){switch(i){case "top":return "text-top";case "bottom":return "text-bottom";default:return "middle"}}var q=class extends bt{#t="100%";#e="100%";#n;#i=new Map;#r=new Map;#o=new Map;constructor(t){super(),t?.width!==void 0&&(this.#t=t.width),t?.height!==void 0&&(this.#e=t.height),t?.background!==void 0&&(this.#n=t.background);}setBackgroundColor(t){this.#n=t;}render(t){this.#i.clear(),this.#r.clear(),this.#o.clear();let e=t.map(h=>this._toSVG(h));this.#n&&e.unshift(`<rect width="100%" height="100%" fill="${this._esc(this.#n)}" />`);let n=e.join(`
25
25
  `),r="",o=[];for(let[,h]of this.#i)o.push(h);for(let[,h]of this.#r)o.push(h);for(let[,h]of this.#o)o.push(h);o.length>0&&(r=` <defs>
26
26
  ${o.join(`
27
27
  `)}
package/dist/internals.js CHANGED
@@ -21,7 +21,7 @@ var G=class{};var x=class{static interpolateDataPoint(a,e,t){return {time:a.time
21
21
  ${c}
22
22
  ${u}
23
23
  </pattern>
24
- `.trim()}var h=new Proxy({},{get:(a,e)=>C()[e],has:(a,e)=>e in C(),ownKeys:()=>Reflect.ownKeys(C()),getOwnPropertyDescriptor:(a,e)=>Reflect.getOwnPropertyDescriptor(C(),e)});function H(a){return {id:a.id,line:{stroke:a.stroke??h.stroke,strokeWidth:a.strokeWidth??h.strokeWidth,smoothing:a.smoothing??false,dashed:a.dashed??false},fill:a.fill??h.areaFillAlpha,markers:{type:a.pointStyle??"none",size:a.pointSize??h.pointSize,stroke:a.stroke??h.stroke,fill:"#ffffff"},shadow:{color:a.shadowColor??"transparent",blur:a.shadowBlur??0,offsetX:a.shadowOffsetX??0,offsetY:a.shadowOffsetY??0}}}function w(a,e,t){let n=[],r=a.reduce((l,s)=>l+s.data.length,0),o=H(t);for(let l=0;l<a.length;l++){let s=a[l];s.data.length>=2?n.push({type:"path",id:t.id?`${t.id}-line-${l}`:void 0,points:s.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})),stroke:s.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:o.line.smoothing,dashed:o.line.dashed,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur,shadowOffsetX:o.shadow.offsetX,shadowOffsetY:o.shadow.offsetY,fill:"none"}):s.data.length===1&&r===1&&n.push({type:"circle",cx:e.timeScale.map(s.data[0].time),cy:e.valueScale.map(s.data[0].value),r:Math.max(o.markers.size,o.line.strokeWidth),fill:s.color??o.line.stroke,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur});}return n}function Le(a){let e=[];for(let t of a)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}function z(a,e,t){let n=[],r=H(t);for(let o=0;o<a.length;o++){let l=a[o];if(l.data.length<2)continue;let s=Le(l.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})));n.push({type:"path",id:t.id?`${t.id}-line-${o}`:void 0,points:s,stroke:l.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:false,fill:"none"});}return n}function De(a,e,t,n,r){let o=[],l=H(t);for(let s=0;s<a.length;s++){let i=a[s];if(i.data.length<2)continue;let m=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(n(c))})),u=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(r(c))})).reverse();o.push({type:"path",id:t.id?`${t.id}-fill-${s}`:void 0,points:[...m,...u],fill:i.color??l.fill,hatch:t.hatch,stroke:"none"});}return o}function V(a,e,t,n){if(a.length<2)return [];let r=x.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),o=[];for(let l=0;l<r.length;l++){let s=r[l];if(s.data.length<2)continue;let i=t.getColor(s.zoneIndex);if(!i)continue;let m=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yLow(c))})),u=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yHigh(c))})).reverse();o.push({type:"path",id:n?.id?`${n.id}-fill-${l}`:void 0,points:[...m,...u],fill:i,hatch:t.getHatch?.(s.zoneIndex),stroke:"none"});}return o}function Me(a,e,t,n){let r=x.splitByThreshold(a,e,l=>l.value,x.interpolateDataPoint),o=[];return n.below&&o.push(...w(r.below.map(l=>({data:l})),t,n.below)),n.above&&o.push(...w(r.above.map(l=>({data:l})),t,n.above)),o}function W(a,e,t,n){let r=H(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let l=0;l<a.length;l++){let s=a[l],i=e.timeScale.map(s.time),m=e.valueScale.map(s.value),u=n(s),c=t.pointStroke??u,d=t.pointFill??u,p=t.pointStrokeWidth??1.5,f=t.id?`${t.id}-marker-${l}`:void 0;Y(o,f,r.markers.type,i,m,r.markers.size,c,d,p);}return o}function Y(a,e,t,n,r,o,l,s,i){switch(t){case "circle":a.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:l,strokeWidth:i,id:e});break;case "square":a.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:s,stroke:l,strokeWidth:i,id:e});break;case "cross":a.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:l,strokeWidth:i,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:l,strokeWidth:i,id:e});break;case "diamond":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r},{x:n,y:r+o},{x:n-o,y:r}],fill:s,stroke:l,strokeWidth:i,id:e});break;case "triangle":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r+o},{x:n-o,y:r+o}],fill:s,stroke:l,strokeWidth:i,id:e});break;case "star":{let m=[];for(let u=0;u<10;u++){let c=u%2===0?o:o*.5,d=Math.PI/2*3+u*Math.PI/5;m.push({x:n+c*Math.cos(d),y:r+c*Math.sin(d)});}a.push({type:"path",points:m,fill:s,stroke:l,strokeWidth:i,id:e});break}case "arrow":a.push({type:"path",points:[{x:n-o,y:r+o},{x:n,y:r-o},{x:n+o,y:r+o}],stroke:l,strokeWidth:i,fill:"none",id:e});break;case "plus":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:l,strokeWidth:i,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:l,strokeWidth:i,id:e});break;case "triangle-down":a.push({type:"path",points:[{x:n,y:r+o},{x:n+o,y:r-o},{x:n-o,y:r-o}],fill:s,stroke:l,strokeWidth:i,id:e});break;case "hexagon":{let m=[];for(let u=0;u<6;u++){let c=u*(Math.PI/3);m.push({x:n+o*Math.cos(c),y:r+o*Math.sin(c)});}a.push({type:"path",points:m,fill:s,stroke:l,strokeWidth:i,id:e});break}case "hourglass":a.push({type:"path",points:[{x:n-o,y:r-o},{x:n+o,y:r-o},{x:n-o,y:r+o},{x:n+o,y:r+o}],fill:s,stroke:l,strokeWidth:i,id:e});break;case "line-horizontal":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:l,strokeWidth:i,id:e});break;default:a.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:l,strokeWidth:i,id:e});}}var L=12,E=8,X=20,_e=11,Z=18,U=a=>a.length*_e*.6;function $e(a,e="vertical"){if(e==="horizontal"){let n=0;for(let r of a)n+=L+E+U(r.name)+Z;return {width:Math.max(0,n-Z),height:X}}let t=0;for(let n of a)t=Math.max(t,U(n.name));return {width:L+E+t,height:a.length*X}}function Fe(a){let{items:e,x:t,y:n,orientation:r="vertical"}=a,o=[],l=t;return e.forEach((s,i)=>{let m=r==="horizontal"?l:t,u=r==="horizontal"?n:n+i*X;o.push({type:"rect",x:m,y:u,w:L,h:L,fill:s.color,stroke:h.legendStroke,strokeWidth:1},{type:"text",content:s.name,x:m+L+E,y:u+L-2,fontSize:h.legendFont,fill:h.legendText}),r==="horizontal"&&(l+=L+E+U(s.name)+Z);}),{type:"group",cssClass:"chart-legend",commands:o}}function Pe(a){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=h.gridStroke,strokeWidth:l=h.gridStrokeWidth,dashed:s=false,opacity:i=h.gridOpacity}=a,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:l,dashed:s,opacity:i});if(e)for(let u of e)m.push({type:"line",x1:u,y1:r[0],x2:u,y2:r[1],stroke:o,strokeWidth:l,dashed:s,opacity:i});return m}var pe=new Map;function We(a,e){return `${a}|${JSON.stringify(e??{})}`}function A(a,e){let t=We(a,e),n=pe.get(t);return n||(n=new Intl.DateTimeFormat(a,e),pe.set(t,n)),n}var D=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,r]=this.#e,[o,l]=this.#t;return r===n?o:o+(t-n)/(r-n)*(l-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]}},k=[{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}],R=class{#e;#t;constructor(e){this.#e=new D({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US");}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 locale(){return this.#t}tickInterval(e,t=3,n=12){let[r,o]=this.#e.domain(),l=o-r;if(l<=0)return {interval:k[0].ms};let s=l/e,i=k[0].ms;for(let c of k)if(c.ms>=s){i=c.ms;break}let m=i,u=Math.round(l/m);for(;u>n&&m<k[k.length-1].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.min(c+1,k.length-1)].ms,u=Math.round(l/m);}for(;u<t&&m>k[0].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.max(c-1,0)].ms,u=Math.round(l/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,l]=this.#e.domain(),s=[],i=Math.ceil(o/r)*r;for(let m=i;m<=l;m+=r)s.push(m);return s}format(e,t){return A(this.#t,t).format(new Date(e))}},O=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 l=this.#r*2*Math.abs(r-n),s=Math.abs(r-n)-l,i=r>=n?1:-1,m=s/o;return n+this.#r*Math.abs(r-n)*i+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]),l=Math.abs(e-o);l<n&&(n=l,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 Ae(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Re(a){let{thresholds:e,valueScale:t,xRange:n}=a,[r,o]=n,[l,s]=t.range(),i=Math.min(l,s),m=Math.max(l,s),u=[],c=[];for(let d of e){let p=d.color??h.thresholdColor,f=t.map(d.value);d.fill==="above"?u.push({type:"rect",x:r,y:i,w:o-r,h:Math.max(0,f-i),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0}):d.fill==="below"&&u.push({type:"rect",x:r,y:f,w:o-r,h:Math.max(0,m-f),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0});let g=d.line??h.thresholdLine;if(g!=="none"){let b=Ae(g),y={type:"line",x1:r,y1:f,x2:o,y2:f,stroke:p,strokeWidth:1,...b,id:d.id?`${d.id}-line`:void 0};d.shadowColor&&(y.shadowColor=d.shadowColor,y.shadowBlur=d.shadowBlur??4,y.shadowOffsetX=d.shadowOffsetX??0,y.shadowOffsetY=d.shadowOffsetY??2),u.push(y);}if(d.label!==false){let b=d.label&&typeof d.label=="object"?d.label:void 0,y=typeof d.label=="string"?d.label:b?.text??d.name,S=b?.position??"right";c.push({...je(y,S,r,o,f,p,b),id:d.id?`${d.id}-label`:void 0});}}return {inside:u,labels:c}}function Oe(a){let e=Re(a);return [...e.inside,...e.labels]}function je(a,e,t,n,r,o,l){let s=(t+n)/2,i={type:"text",content:a,fontSize:h.thresholdFontSize,fill:o},m=l?{...l.rotate!==void 0&&{rotate:l.rotate},...l.textBaseline!==void 0&&{textBaseline:l.textBaseline}}:{};switch(e){case "left":return {...i,...m,x:t+4,y:r-4,anchor:"start"};case "above":return {...i,...m,x:s,y:r-6,anchor:"middle"};case "below":return {...i,...m,x:s,y:r+14,anchor:"middle"};case "center":return {...i,...m,x:s,y:r-4,anchor:"middle"};case "outside-left":return {...i,...m,x:t-6,y:r+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...i,...m,x:n+6,y:r+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...i,...m,x:n-4,y:r-4,anchor:"end"}}}function Ie(a){let{gaps:e,timeScale:t,yRange:n,fill:r=h.gapFill,hatch:o,fillOpacity:l=h.gapFillOpacity??.15,stroke:s=h.gapStroke,strokeWidth:i=h.gapStrokeWidth,dashed:m=true,fontSize:u=h.gapFontSize,fontFill:c=h.gapFontColor,labelBaseline:d="middle",labelRotate:p}=a,[f,g]=n,b=[];for(let y of e){let S=t.map(y.startTime),F=t.map(y.endTime),T=y.fill??r,P=y.hatch??o,me=y.fillOpacity??l,ue=y.label??"",Se=y.rotate??p,N=y.labelBaseline??d;if(y.style==="dashed_border"||!y.style?b.push({type:"rect",x:S,y:f,w:F-S,h:g-f,fill:T,hatch:P,opacity:me,stroke:s,strokeWidth:i,dashed:m}):y.style==="empty"&&b.push({type:"rect",x:S,y:f,w:F-S,h:g-f,fill:T,hatch:P,opacity:me}),ue){let ke=Be(f,g,N),ve=N==="above"?"top":N==="below"?"bottom":"middle";b.push({type:"text",content:ue,x:(S+F)/2,y:ke,anchor:"middle",fontSize:u,fill:c,textBaseline:ve,rotate:Se});}}return b}function Be(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function He(a){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=a,[o,l]=r,s=[];for(let i of e){let m=t.map(i.time),u=i.color??h.markerColor,c=i.pointStyle??(i.value!==void 0?"circle":"none"),d=i.lineStyle??"full";if(i.value!==void 0){let p=n.map(i.value);if(d==="to-value"?s.push({type:"line",x1:m,y1:l,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="to-top"?s.push({type:"line",x1:m,y1:o,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="full"&&s.push({type:"line",x1:m,y1:o,x2:m,y2:l,stroke:u,strokeWidth:1}),c!=="none"&&Y(s,void 0,c,m,p,h.markerSize,u,u,1.5),i.label){let f=d==="to-value"?p-10:o-6;s.push({type:"text",content:i.label,x:m,y:f,anchor:"middle",fontSize:11,fill:u});}}else s.push({type:"line",x1:m,y1:o,x2:m,y2:l,stroke:u,strokeWidth:1}),i.label&&s.push({type:"text",content:i.label,x:m,y:o-6,anchor:"middle",fontSize:11,fill:u});}return s}function Ve(a){let{highlights:e,timeScale:t,yRange:n,height:r}=a,[o,l]=n,s=[];for(let i of e){let m=t.map(i.startTime),u=t.map(i.endTime);s.push({type:"rect",x:m,y:o,w:u-m,h:l-o,fill:i.color??h.highlightColor,opacity:i.opacity??h.highlightOpacity}),i.label&&s.push({type:"text",content:i.label,x:(m+u)/2,y:Ee(i.labelPosition??"top",o,l,r),anchor:"middle",fontSize:h.annotationFontSize,fill:i.color??h.highlightLabelColor,rotate:i.rotate});}return s}function Ee(a,e,t,n){switch(a){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function q(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function Ne(a){let{annotations:e,timeScale:t,valueScales:n}=a,r=[],o=l=>{let s=n.get(l.axis??0)??n.values().next().value;return {x:t.map(l.time),y:s?s.map(l.value):0}};for(let l of e){let s=[],i=m=>s.push(m);switch(l.type){case "line":{let m=o(l.from),u=o(l.to);i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:l.color??h.annotationColor,strokeWidth:l.width??h.annotationWidth,dash:l.dash});break}case "arrow":{let m=o(l.from),u=o(l.to),c=l.color??h.annotationColor,d=l.headSize??h.annotationHead;i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:c,strokeWidth:l.width??h.annotationWidth});let p=Math.hypot(u.x-m.x,u.y-m.y)||1,f=(u.x-m.x)/p,g=(u.y-m.y)/p,b=u.x-f*d,y=u.y-g*d;i({type:"path",points:[{x:u.x,y:u.y},{x:b-g*d*.5,y:y+f*d*.5},{x:b+g*d*.5,y:y-f*d*.5}],fill:c,stroke:"none"});break}case "rect":{let m=o(l.from),u=o(l.to);i({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:l.fill??"none",stroke:l.stroke,opacity:l.opacity});break}case "point":{let m=o(l.at),u=l.color??"#334155",c=l.radius??h.annotationRadius,d=l.shape??"circle";d==="circle"?i({type:"circle",cx:m.x,cy:m.y,r:c,fill:u}):d==="square"?i({type:"rect",x:m.x-c,y:m.y-c,w:c*2,h:c*2,fill:u}):(i({type:"line",x1:m.x-c,y1:m.y-c,x2:m.x+c,y2:m.y+c,stroke:u,strokeWidth:1.5}),i({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(l.at);i({type:"text",content:l.text,x:m.x+(l.dx??0),y:m.y+(l.dy??0),anchor:l.anchor??"middle",fontSize:h.annotationFontSize,fill:l.color??h.annotationColor,rotate:l.rotate});break}}if(l.id&&s.length>0){let m=q(l.id);r.push({type:"group",cssClass:`annotation annotation--${m}`,commands:s});}else r.push(...s);}return r}var K=class a{_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 a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var J=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 h=new Proxy({},{get:(a,e)=>C()[e],has:(a,e)=>e in C(),ownKeys:()=>Reflect.ownKeys(C()),getOwnPropertyDescriptor:(a,e)=>Reflect.getOwnPropertyDescriptor(C(),e)});function H(a){return {id:a.id,line:{stroke:a.stroke??h.stroke,strokeWidth:a.strokeWidth??h.strokeWidth,smoothing:a.smoothing??false,dashed:a.dashed??false},fill:a.fill??h.areaFillAlpha,markers:{type:a.pointStyle??"none",size:a.pointSize??h.pointSize,stroke:a.stroke??h.stroke,fill:"#ffffff"},shadow:{color:a.shadowColor??"transparent",blur:a.shadowBlur??0,offsetX:a.shadowOffsetX??0,offsetY:a.shadowOffsetY??0}}}function w(a,e,t){let n=[],r=a.reduce((l,s)=>l+s.data.length,0),o=H(t);for(let l=0;l<a.length;l++){let s=a[l];s.data.length>=2?n.push({type:"path",id:t.id?`${t.id}-line-${l}`:void 0,points:s.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})),stroke:s.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:o.line.smoothing,dashed:o.line.dashed,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur,shadowOffsetX:o.shadow.offsetX,shadowOffsetY:o.shadow.offsetY,fill:"none"}):s.data.length===1&&r===1&&n.push({type:"circle",cx:e.timeScale.map(s.data[0].time),cy:e.valueScale.map(s.data[0].value),r:Math.max(o.markers.size,o.line.strokeWidth),fill:s.color??o.line.stroke,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur});}return n}function Le(a){let e=[];for(let t of a)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}function z(a,e,t){let n=[],r=H(t);for(let o=0;o<a.length;o++){let l=a[o];if(l.data.length<2)continue;let s=Le(l.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})));n.push({type:"path",id:t.id?`${t.id}-line-${o}`:void 0,points:s,stroke:l.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:false,fill:"none"});}return n}function De(a,e,t,n,r){let o=[],l=H(t);for(let s=0;s<a.length;s++){let i=a[s];if(i.data.length<2)continue;let m=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(n(c))})),u=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(r(c))})).reverse();o.push({type:"path",id:t.id?`${t.id}-fill-${s}`:void 0,points:[...m,...u],fill:i.color??l.fill,hatch:t.hatch,stroke:"none"});}return o}function V(a,e,t,n){if(a.length<2)return [];let r=x.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),o=[];for(let l=0;l<r.length;l++){let s=r[l];if(s.data.length<2)continue;let i=t.getColor(s.zoneIndex);if(!i)continue;let m=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yLow(c))})),u=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yHigh(c))})).reverse();o.push({type:"path",id:n?.id?`${n.id}-fill-${l}`:void 0,points:[...m,...u],fill:i,hatch:t.getHatch?.(s.zoneIndex),stroke:"none"});}return o}function Me(a,e,t,n){let r=x.splitByThreshold(a,e,l=>l.value,x.interpolateDataPoint),o=[];return n.below&&o.push(...w(r.below.map(l=>({data:l})),t,n.below)),n.above&&o.push(...w(r.above.map(l=>({data:l})),t,n.above)),o}function W(a,e,t,n){let r=H(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let l=0;l<a.length;l++){let s=a[l],i=e.timeScale.map(s.time),m=e.valueScale.map(s.value),u=n(s),c=t.pointStroke??u,d=t.pointFill??u,p=t.pointStrokeWidth??1.5,f=t.id?`${t.id}-marker-${l}`:void 0;Y(o,f,r.markers.type,i,m,r.markers.size,c,d,p);}return o}function Y(a,e,t,n,r,o,l,s,i){switch(t){case "circle":a.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:l,strokeWidth:i,id:e});break;case "square":a.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:s,stroke:l,strokeWidth:i,id:e});break;case "cross":a.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:l,strokeWidth:i,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:l,strokeWidth:i,id:e});break;case "diamond":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r},{x:n,y:r+o},{x:n-o,y:r}],fill:s,stroke:l,strokeWidth:i,id:e});break;case "triangle":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r+o},{x:n-o,y:r+o}],fill:s,stroke:l,strokeWidth:i,id:e});break;case "star":{let m=[];for(let u=0;u<10;u++){let c=u%2===0?o:o*.5,d=Math.PI/2*3+u*Math.PI/5;m.push({x:n+c*Math.cos(d),y:r+c*Math.sin(d)});}a.push({type:"path",points:m,fill:s,stroke:l,strokeWidth:i,id:e});break}case "arrow":a.push({type:"path",points:[{x:n-o,y:r+o},{x:n,y:r-o},{x:n+o,y:r+o}],stroke:l,strokeWidth:i,fill:"none",id:e});break;case "plus":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:l,strokeWidth:i,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:l,strokeWidth:i,id:e});break;case "triangle-down":a.push({type:"path",points:[{x:n,y:r+o},{x:n+o,y:r-o},{x:n-o,y:r-o}],fill:s,stroke:l,strokeWidth:i,id:e});break;case "hexagon":{let m=[];for(let u=0;u<6;u++){let c=u*(Math.PI/3);m.push({x:n+o*Math.cos(c),y:r+o*Math.sin(c)});}a.push({type:"path",points:m,fill:s,stroke:l,strokeWidth:i,id:e});break}case "hourglass":a.push({type:"path",points:[{x:n-o,y:r-o},{x:n+o,y:r-o},{x:n-o,y:r+o},{x:n+o,y:r+o}],fill:s,stroke:l,strokeWidth:i,id:e});break;case "line-horizontal":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:l,strokeWidth:i,id:e});break;default:a.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:l,strokeWidth:i,id:e});}}var L=12,E=8,X=20,_e=11,Z=18,U=a=>a.length*_e*.6;function $e(a,e="vertical"){if(e==="horizontal"){let n=0;for(let r of a)n+=L+E+U(r.name)+Z;return {width:Math.max(0,n-Z),height:X}}let t=0;for(let n of a)t=Math.max(t,U(n.name));return {width:L+E+t,height:a.length*X}}function Fe(a){let{items:e,x:t,y:n,orientation:r="vertical"}=a,o=[],l=t;return e.forEach((s,i)=>{let m=r==="horizontal"?l:t,u=r==="horizontal"?n:n+i*X;o.push({type:"rect",x:m,y:u,w:L,h:L,fill:s.color,stroke:h.legendStroke,strokeWidth:1},{type:"text",content:s.name,x:m+L+E,y:u+L-2,fontSize:h.legendFont,fill:h.legendText}),r==="horizontal"&&(l+=L+E+U(s.name)+Z);}),{type:"group",cssClass:"chart-legend",commands:o}}function Pe(a){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=h.gridStroke,strokeWidth:l=h.gridStrokeWidth,dashed:s=false,opacity:i=h.gridOpacity}=a,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:l,dashed:s,opacity:i});if(e)for(let u of e)m.push({type:"line",x1:u,y1:r[0],x2:u,y2:r[1],stroke:o,strokeWidth:l,dashed:s,opacity:i});return m}var pe=new Map;function We(a,e){return `${a}|${JSON.stringify(e??{})}`}function A(a,e){let t=We(a,e),n=pe.get(t);return n||(n=new Intl.DateTimeFormat(a,e),pe.set(t,n)),n}var D=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,r]=this.#e,[o,l]=this.#t;return r===n?o:o+(t-n)/(r-n)*(l-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]}},k=[{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}],R=class{#e;#t;constructor(e){this.#e=new D({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US");}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 locale(){return this.#t}tickInterval(e,t=3,n=12){let[r,o]=this.#e.domain(),l=o-r;if(l<=0)return {interval:k[0].ms};let s=l/e,i=k[0].ms;for(let c of k)if(c.ms>=s){i=c.ms;break}let m=i,u=Math.round(l/m);for(;u>n&&m<k[k.length-1].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.min(c+1,k.length-1)].ms,u=Math.round(l/m);}for(;u<t&&m>k[0].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.max(c-1,0)].ms,u=Math.round(l/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,l]=this.#e.domain(),s=[],i=Math.ceil(o/r)*r;for(let m=i;m<=l;m+=r)s.push(m);return s}format(e,t){return A(this.#t,t).format(new Date(e))}},O=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 l=this.#r*2*Math.abs(r-n),s=Math.abs(r-n)-l,i=r>=n?1:-1,m=s/o;return n+this.#r*Math.abs(r-n)*i+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]),l=Math.abs(e-o);l<n&&(n=l,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 Ae(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Re(a){let{thresholds:e,valueScale:t,xRange:n}=a,[r,o]=n,[l,s]=t.range(),i=Math.min(l,s),m=Math.max(l,s),u=[],c=[];for(let d of e){let p=d.color??h.thresholdColor,f=t.map(d.value);d.fill==="above"?u.push({type:"rect",x:r,y:i,w:o-r,h:Math.max(0,f-i),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0}):d.fill==="below"&&u.push({type:"rect",x:r,y:f,w:o-r,h:Math.max(0,m-f),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0});let g=d.line??h.thresholdLine;if(g!=="none"){let b=Ae(g),y={type:"line",x1:r,y1:f,x2:o,y2:f,stroke:p,strokeWidth:1,...b,id:d.id?`${d.id}-line`:void 0};d.shadowColor&&(y.shadowColor=d.shadowColor,y.shadowBlur=d.shadowBlur??4,y.shadowOffsetX=d.shadowOffsetX??0,y.shadowOffsetY=d.shadowOffsetY??2),u.push(y);}if(d.label!==void 0&&d.label!==null&&d.label!==false){let b=typeof d.label=="object"?d.label:void 0,y=typeof d.label=="string"?d.label:b?.text??d.name,S=b?.position??"right";c.push({...je(y,S,r,o,f,p,b),id:d.id?`${d.id}-label`:void 0});}}return {inside:u,labels:c}}function Oe(a){let e=Re(a);return [...e.inside,...e.labels]}function je(a,e,t,n,r,o,l){let s=(t+n)/2,i={type:"text",content:a,fontSize:h.thresholdFontSize,fill:o},m=l?{...l.rotate!==void 0&&{rotate:l.rotate},...l.textBaseline!==void 0&&{textBaseline:l.textBaseline}}:{};switch(e){case "left":return {...i,...m,x:t+4,y:r-4,anchor:"start"};case "above":return {...i,...m,x:s,y:r-6,anchor:"middle"};case "below":return {...i,...m,x:s,y:r+14,anchor:"middle"};case "center":return {...i,...m,x:s,y:r-4,anchor:"middle"};case "outside-left":return {...i,...m,x:t-6,y:r+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...i,...m,x:n+6,y:r+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...i,...m,x:n-4,y:r-4,anchor:"end"}}}function Ie(a){let{gaps:e,timeScale:t,yRange:n,fill:r=h.gapFill,hatch:o,fillOpacity:l=h.gapFillOpacity??.15,stroke:s=h.gapStroke,strokeWidth:i=h.gapStrokeWidth,dashed:m=true,fontSize:u=h.gapFontSize,fontFill:c=h.gapFontColor,labelBaseline:d="middle",labelRotate:p}=a,[f,g]=n,b=[];for(let y of e){let S=t.map(y.startTime),F=t.map(y.endTime),T=y.fill??r,P=y.hatch??o,me=y.fillOpacity??l,ue=y.label??"",Se=y.rotate??p,N=y.labelBaseline??d;if(y.style==="dashed_border"||!y.style?b.push({type:"rect",x:S,y:f,w:F-S,h:g-f,fill:T,hatch:P,opacity:me,stroke:s,strokeWidth:i,dashed:m}):y.style==="empty"&&b.push({type:"rect",x:S,y:f,w:F-S,h:g-f,fill:T,hatch:P,opacity:me}),ue){let ke=Be(f,g,N),ve=N==="above"?"top":N==="below"?"bottom":"middle";b.push({type:"text",content:ue,x:(S+F)/2,y:ke,anchor:"middle",fontSize:u,fill:c,textBaseline:ve,rotate:Se});}}return b}function Be(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function He(a){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=a,[o,l]=r,s=[];for(let i of e){let m=t.map(i.time),u=i.color??h.markerColor,c=i.pointStyle??(i.value!==void 0?"circle":"none"),d=i.lineStyle??"full";if(i.value!==void 0){let p=n.map(i.value);if(d==="to-value"?s.push({type:"line",x1:m,y1:l,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="to-top"?s.push({type:"line",x1:m,y1:o,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="full"&&s.push({type:"line",x1:m,y1:o,x2:m,y2:l,stroke:u,strokeWidth:1}),c!=="none"&&Y(s,void 0,c,m,p,h.markerSize,u,u,1.5),i.label){let f=d==="to-value"?p-10:o-6;s.push({type:"text",content:i.label,x:m,y:f,anchor:"middle",fontSize:11,fill:u});}}else s.push({type:"line",x1:m,y1:o,x2:m,y2:l,stroke:u,strokeWidth:1}),i.label&&s.push({type:"text",content:i.label,x:m,y:o-6,anchor:"middle",fontSize:11,fill:u});}return s}function Ve(a){let{highlights:e,timeScale:t,yRange:n,height:r}=a,[o,l]=n,s=[];for(let i of e){let m=t.map(i.startTime),u=t.map(i.endTime);s.push({type:"rect",x:m,y:o,w:u-m,h:l-o,fill:i.color??h.highlightColor,opacity:i.opacity??h.highlightOpacity}),i.label&&s.push({type:"text",content:i.label,x:(m+u)/2,y:Ee(i.labelPosition??"top",o,l,r),anchor:"middle",fontSize:h.annotationFontSize,fill:i.color??h.highlightLabelColor,rotate:i.rotate});}return s}function Ee(a,e,t,n){switch(a){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function q(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function Ne(a){let{annotations:e,timeScale:t,valueScales:n}=a,r=[],o=l=>{let s=n.get(l.axis??0)??n.values().next().value;return {x:t.map(l.time),y:s?s.map(l.value):0}};for(let l of e){let s=[],i=m=>s.push(m);switch(l.type){case "line":{let m=o(l.from),u=o(l.to);i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:l.color??h.annotationColor,strokeWidth:l.width??h.annotationWidth,dash:l.dash});break}case "arrow":{let m=o(l.from),u=o(l.to),c=l.color??h.annotationColor,d=l.headSize??h.annotationHead;i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:c,strokeWidth:l.width??h.annotationWidth});let p=Math.hypot(u.x-m.x,u.y-m.y)||1,f=(u.x-m.x)/p,g=(u.y-m.y)/p,b=u.x-f*d,y=u.y-g*d;i({type:"path",points:[{x:u.x,y:u.y},{x:b-g*d*.5,y:y+f*d*.5},{x:b+g*d*.5,y:y-f*d*.5}],fill:c,stroke:"none"});break}case "rect":{let m=o(l.from),u=o(l.to);i({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:l.fill??"none",stroke:l.stroke,opacity:l.opacity});break}case "point":{let m=o(l.at),u=l.color??"#334155",c=l.radius??h.annotationRadius,d=l.shape??"circle";d==="circle"?i({type:"circle",cx:m.x,cy:m.y,r:c,fill:u}):d==="square"?i({type:"rect",x:m.x-c,y:m.y-c,w:c*2,h:c*2,fill:u}):(i({type:"line",x1:m.x-c,y1:m.y-c,x2:m.x+c,y2:m.y+c,stroke:u,strokeWidth:1.5}),i({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(l.at);i({type:"text",content:l.text,x:m.x+(l.dx??0),y:m.y+(l.dy??0),anchor:l.anchor??"middle",fontSize:h.annotationFontSize,fill:l.color??h.annotationColor,rotate:l.rotate});break}}if(l.id&&s.length>0){let m=q(l.id);r.push({type:"group",cssClass:`annotation annotation--${m}`,commands:s});}else r.push(...s);}return r}var K=class a{_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 a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var J=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
27
  </clipPath>`}get regions(){return [...this.#e]}};var j={axisColor:h.axisColor,tickColor:h.tickColor,textColor:h.textColor,textSize:h.textSize},I=class{#e;#t;constructor(e){this.#e=new R({domain:e.domain,range:e.xRange,locale:e.locale}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??j).axisColor}get tickColor(){return (this.#t.colors??j).tickColor}get textColor(){return (this.#t.colors??j).textColor}get textSize(){return (this.#t.colors??j).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??j,n=this.#t.y??0,r=[],[o,l]=this.#e.range();r.push({type:"line",x1:o,y1:n,x2:l,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let s of e)r.push({type:"line",x1:s.x,y1:n,x2:s.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:s.label,x:s.x,y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}};var B={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function Ge(a){return Math.abs(a)>=1e6?`${(a/1e6).toFixed(1)}M`:Math.abs(a)>=1e3?`${(a/1e3).toFixed(1)}k`:Number.isInteger(a)?String(a):a.toFixed(1)}function ze(a){let e=new Array(a.length).fill(false),t=0;for(;t<a.length;){let n=t;for(;n+1<a.length&&a[n+1].label===a[t].label;)n++;for(let r=t+1;r<n;r++)e[r]=true;t=n+1;}return e}var Q=class{#e;#t;constructor(e){this.#e=new D({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??B).axisColor}get tickColor(){return (this.#t.colors??B).tickColor}get textColor(){return (this.#t.colors??B).textColor}get textSize(){return (this.#t.colors??B).textSize}generateTicks(){let e=this.#t.format??Ge,t=6,[n,r]=this.#e.domain(),o=r-n;if(o===0)return [{value:n,position:this.#e.map(n),label:e(n)}];let l=o/t,s=Math.pow(10,Math.floor(Math.log10(l))),i=l/s,m;i<=1.5?m=s:i<=3?m=2*s:i<=7?m=5*s:m=10*s;let u=[],c=Math.ceil(n/m)*m;for(let d=c;d<=r;d+=m)u.push({value:d,position:this.#e.map(d),label:e(d)});return u}render(){let e=this.generateTicks(),t=this.#t.colors??B,n=this.#t.x??0,r=this.#t.orientation??"vertical",o=this.#t.position??"left",l=this.#t.suppressLabelsNear??[],s=this.#t.suppressTolerancePx??8,i=u=>l.some(c=>Math.abs(c-u)<=s),m=[];if(r==="vertical"){let[u,c]=this.#e.range();m.push({type:"line",x1:n,y1:u,x2:n,y2:c,stroke:t.axisColor,strokeWidth:t.axisWidth});let d=ze(e);e.forEach((p,f)=>{let g=i(p.position),b=d[f]?{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:n-8,y:p.position+4,anchor:"end",fontSize:11,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:n+8,y:p.position+4,anchor:"start",fontSize:11,fill:t.textColor,...b}));});}else {let[u,c]=this.#e.range();m.push({type:"line",x1:u,y1:n,x2:c,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let d of e)m.push({type:"line",x1:d.position,y1:n,x2:d.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),m.push({type:"text",content:d.label,x:d.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return m}};var ee=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 O({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((l,s)=>{let i=Number(l),m=t?e[i]??String(i):String(i),u=this.#e.map(i),c=n?h.palette[s%h.palette.length]:void 0;return {value:i,label:m,y:u,color:c,isGap:o.has(i)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return h.palette[t%h.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:11,fill:r.color??h.textColor});return n}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var v=class a{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"series-"+ ++a.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var te=class extends v{#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,stroke:e.stroke??h.stroke,strokeWidth:e.strokeWidth??h.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},n=e.pointThreshold??h.pointThreshold,r=e.gapThreshold??h.gapThreshold,o=e.id,l=x.getRuns(this.data,c=>c.value===null,r),s=l.reduce((c,d)=>c+d.length,0);if(s===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=l.map(c=>({data:c})),u=[];if(u.push(...w(m,i,{...t,id:o?`${o}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&s<=n)for(let c of l)u.push(...W(c,i,{...t,id:o?`${o}-marker`:void 0},()=>t.stroke));return u}};var ne=class extends v{#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),l=e.map(t[r].value);r===0?n.push({x:o,y:l}):n.push({x:o,y:n[n.length-1].y},{x:o,y:l});}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 z(n,t,{stroke:this.#e.stroke??h.stroke,strokeWidth:this.#e.strokeWidth??h.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var re=class extends v{#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??h.bandFill,n=e.hatch,r=e.avgLine??false,o=e.avgLineColor??h.bandAvgLine,l=e.bandWidth??10,s=[];for(let i of this.data){if(i.min===null||i.max===null)continue;let m=this.timeScale.map(i.time),u=e.valueScale.map(i.max),c=e.valueScale.map(i.min),d=l,p=this.data.indexOf(i);if(s.push({type:"rect",x:m-d/2,y:u,w:d,h:c-u,fill:t,hatch:n,opacity:this.opacity(i.count),id:this.id?`${this.id}-slot-${p}`:void 0}),r&&i.avg!==null){let f=e.valueScale.map(i.avg);s.push({type:"line",x1:m-d/2,y1:f,x2:m+d/2,y2:f,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${p}`:void 0});}}return s}};var oe=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??h.minColor,n=e.maxColor??h.maxColor,r=e.avgColor??h.avgColor,o=e.avgDashed??true,l=e.smoothing??false,s=e.strokeWidth??h.strokeWidth,i=x.getRuns(this.data,p=>p.min===null||p.max===null||p.avg===null);if(i.length===0)return [];let m={timeScale:this.timeScale,valueScale:e.valueScale},u=[];i.forEach((p,f)=>{p.length<2||(e.fillToMax&&u.push(...V(p,m,{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-${f}`:void 0})),e.fillToMin&&u.push(...V(p,m,{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-${f}`:void 0})));});let c=i.filter(p=>p.length>=2),d=p=>c.map(f=>({data:f.map(g=>({time:g.time,value:p(g)}))}));return u.push(...w(d(p=>p.max),m,{stroke:n,strokeWidth:s,smoothing:l,id:this.id?`${this.id}-max`:void 0}),...w(d(p=>p.min),m,{stroke:t,strokeWidth:s,smoothing:l,id:this.id?`${this.id}-min`:void 0}),...w(d(p=>p.avg),m,{stroke:r,strokeWidth:s,smoothing:l,dashed:o,id:this.id?`${this.id}-avg`:void 0})),u}};var ie=class extends v{#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??h.stroke:this.#t[e-1].color}render(){let e=this.#e,t=e.baseColor??h.stroke,n={stroke:t,strokeWidth:e.strokeWidth??h.strokeWidth,smoothing:e.smoothing??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize},r=e.gapThreshold??h.gapThreshold,o=e.pointThreshold??h.pointThreshold,l=x.getRuns(this.data,u=>u.value===null,r),s=l.reduce((u,c)=>u+c.length,0);if(s===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=[];for(let u of l){if(u.length<2)continue;if(e.fill){let f=e.fill.value,g=x.splitByBoundaries(u,[f],y=>y.value,x.interpolateDataPoint),b=e.valueScale.map(f);for(let y=0;y<g.length;y++){let S=g[y],F=(S.data[0].value+S.data[S.data.length-1].value)/2;if(e.fill.side==="above"==F>=f){let T=S.data.map(P=>({x:this.timeScale.map(P.time),y:e.valueScale.map(P.value)}));m.push({type:"path",id:this.id?`${this.id}-fill-${y}`:void 0,points:[...T,{x:T[T.length-1].x,y:b},{x:T[0].x,y:b}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let c=this.#t.map(f=>f.value),p=x.splitByBoundaries(u,c,f=>f.value,x.interpolateDataPoint).map(f=>({data:f.data,color:this.#n(f.zoneIndex)}));m.push(...w(p,i,{...n,id:this.id?`${this.id}-line`:void 0})),n.pointStyle&&n.pointStyle!=="none"&&s<=o&&m.push(...W(u,i,{...n,id:this.id?`${this.id}-marker`:void 0},f=>{let g=t;for(let b of this.#t)f.value>=b.value&&(g=b.color);return g}));}return m}};var ae=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:l,y:s,height:i}=this.#e,m=[];n&&m.push({type:"rect",x:l[0],y:s,w:l[1]-l[0],h:i,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let c=t.map(u.startTime),d=t.map(u.endTime);if(!(d-c<1)&&(m.push({type:"rect",x:c,y:s,w:d-c,h:i,hatch:u.hatch??r,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0}),u.label)){let p=u.labelFontSize??10;m.push({type:"text",content:u.label,x:(c+d)/2,y:this.#t(u.labelBaseline,p),anchor:"middle",fontSize:p,fill:u.labelFill??"#333"});}}if(o){let u=new I({domain:t.domain(),xRange:l,y:s+i+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 se=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:r=false,showMax:o=false,showAvg:l=true,showMedian:s=false,labelPosition:i="end",lineColor:m=h.statsLineColor,labelColor:u=h.statsLabelColor}=this.#e,c=ce.compute(e),d=[{name:"min",value:c.min,enabled:r},{name:"max",value:c.max,enabled:o},{name:"avg",value:c.avg,enabled:l},{name:"median",value:c.median,enabled:s}],p=[],[f,g]=n;for(let b of d.filter(y=>y.enabled)){let y=t.map(b.value);p.push({type:"line",x1:f,y1:y,x2:g,y2:y,stroke:m,strokeWidth:1});let S=`${b.name}: ${b.value.toFixed(1)}`;(i==="start"||i==="both")&&p.push({type:"text",content:S,x:f+4,y:y-4,anchor:"start",fontSize:10,fill:u}),(i==="end"||i==="both")&&p.push({type:"text",content:S,x:g-4,y:y-4,anchor:"end",fontSize:10,fill:u}),i==="center"&&p.push({type:"text",content:S,x:(f+g)/2,y:y-4,anchor:"middle",fontSize:10,fill:u});}return p}};var M=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 A(this.#e,r).format(new Date(e))}catch{for(let r of this.#t)try{return A(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,l=36e5,s=6e4,i={};return r<s?(i.second="2-digit",i.minute="2-digit",i.hour="2-digit"):r<l?(i.minute="2-digit",i.hour="2-digit"):r<o?(i.hour="2-digit",i.minute="2-digit"):r<7*o?(i.weekday="short",i.day="numeric"):r<365*o?(i.month="short",i.day="numeric"):(i.month="short",i.year="numeric"),{...n,...i}}};var _=class a{#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 a({unit:e,decimals:t})}static temperature(e="\xB0C"){return new a({unit:e,decimals:1})}static percentage(){return new a({unit:"%",decimals:0})}};var $=class a{#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 a({map:n,showValue:t})}};var Ye={time:new M,value:new _,enum:new $};function le(a,e){let t=C();return {color:a.color??t.stroke,width:a.width??t.strokeWidth,style:a.style??"solid",smoothing:a.smoothing??false,shape:a.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:a.gapThreshold??t.gapThreshold,opacity:a.opacity??1}}function fe(a){let e=a.style?.line;return e===false?[]:e===void 0?[le({},a)]:Array.isArray(e)?e.map(t=>le(t,a)):[le(e,a)]}function ge(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=C(),r=(a.style?.line&&!Array.isArray(a.style.line)?a.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 ye(a){let e=a.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 be(a){return a.style?.gap}function xe(a){return a.style?.fill}function Xe(a){return {lines:fe(a),fill:xe(a),markers:ge(a),shadow:ye(a),gap:be(a),id:a.style?.id??a.id}}/*!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ml-time-graph",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "description": "TypeScript library for time-series chart rendering — DOM-free SVG output (works in the browser and on the server).",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",