ml-time-graph 1.9.1 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -19,6 +19,117 @@ release notes, and every change is in `git log` in full.
19
19
 
20
20
  ---
21
21
 
22
+ ## [1.11.0] - 2026-10-05
23
+
24
+ ### Added
25
+ - **`CommandBuilder` now covers every draw command**, in both libraries, and is reachable:
26
+ `ml-time-graph/internals` exports it, Go has `renderer.NewCommandBuilder()`. It sets the `type`
27
+ field for you, chains, nests groups — and skips a group whose body stays empty, which every
28
+ renderer used to guard by hand. Until 1.11.0 the TypeScript class had exactly one method
29
+ (`addLine`) and no entry point named it, so nobody could use it; the Go port had none at all.
30
+ `renderLegend` is built with it in both ports, so it runs on every reference chart.
31
+ - **A panel behind the legend.** `legend.box` draws a background and a border under the entries —
32
+ `box: {}` is enough and takes the defaults (white, a grey hairline, 6 px padding, 85 % opaque).
33
+ It is meant for `inside-left` / `inside-right`, where the legend sits over the data and a dense
34
+ curve or a filled area makes it hard to read. `stroke: 'none'` keeps the background without a
35
+ border. Nothing is drawn without `box`, so every existing chart looks as it did.
36
+
37
+ ### Fixed
38
+ - **A labelled threshold no longer deletes the axis number at its height unless the two can
39
+ actually meet.** The axis dropped every tick label within 8 px of a labelled threshold, looking
40
+ only at the height and never at where the threshold's label sits. With the default position
41
+ (`'right'`, inside the plot) a humidity chart lost exactly its `100` at the left axis while
42
+ the label "saturation" stood at the far right. A tick label now gives way only to a threshold
43
+ label in the gutter of the same side: `'outside-left'` for a left axis, `'outside-right'` for a
44
+ right one. Expect axis numbers to reappear in charts with labelled thresholds — ten of the
45
+ reference templates gained one to three each, nothing else moved. Both ports, same rule.
46
+
47
+ ## [1.10.0] - 2026-10-05
48
+
49
+ ### Added
50
+ - **Real text widths.** Labels and legends are measured with the advance widths of the default
51
+ font stack (`Liberation Sans, Arial, Helvetica` — metric-compatible), shipped as a table in both
52
+ libraries. The old estimate of 0.6 em per character was up to ±60 % off; digits alone were 7.9 %
53
+ too wide. Charts therefore reserve less room than before: expect slightly wider plot areas.
54
+ - **Minor ticks and a minor grid.** `axes.<axis>.ticks.minor` places that many ticks between two
55
+ major ones, `axes.<axis>.grid.minor` draws the matching lines — half as strong as the major grid
56
+ unless you say otherwise. Both fields were declared in both libraries since forever and read by
57
+ neither. `grid.minor` on its own means one tick per major interval.
58
+ - **Legend above and below the plot.** `legend.position: 'above' | 'below'` lays the entries out
59
+ horizontally and wraps them into as many rows as they need; the chart reserves exactly that
60
+ height. Neither existed before, for one reason: without real text widths there is no way to tell
61
+ how many entries fit a row. A horizontal legend now wraps instead of running off the canvas.
62
+ - **Two splines that do not overshoot.** `style.line.smoothingType` picks how a smoothed line
63
+ gets from point to point. `'catmull-rom'` stays the default and nothing changes without it.
64
+ `'monotone'` (Fritsch-Carlson) never leaves the span between two readings — humidity that sits
65
+ at 100 % stays at 100 % instead of bulging to 103 %, and the same goes for tank levels or
66
+ anything else with a ceiling. `'akima'` takes its slope from five points and weights it against
67
+ edges, so a flat run stays flat until the drop arrives instead of swinging up to meet it. Both
68
+ matter most for sensors that only transmit on change. `smoothing: true` is still the switch; a
69
+ type on its own draws straight segments.
70
+ - **`axes.<axis>.grid.layer`** decides whether the grid is drawn behind the data or over it.
71
+ `'front'` is the default and the behaviour the library always had: after the series, so a filled
72
+ area down to the baseline does not hide it, while markers, annotations and labels stay on top.
73
+ `'back'` draws it first of all — the choice when an opaque fill is meant to cover it. As with the
74
+ grid style, `axes.x` wins over `axes.left`; the switch sets the whole grid, not one axis.
75
+ - **`textMetrics`** lets you measure yourself — a browser-side `measureText`, or a table generated
76
+ for your own font with `node scripts/gen-text-metrics.mjs --font <file.ttf>`. A measuring callback
77
+ cannot travel in JSON, so the Go port cannot follow it: using one leaves the parity between the
78
+ two libraries, deliberately. `estimateMetrics` reproduces the pre-1.10.0 layout.
79
+
80
+ ### Fixed
81
+ - **Both libraries now draw in the same order.** The Go port put the grid under the series where
82
+ the TypeScript one puts it over them, and the time axis over the highlights where the other has
83
+ them over the axis: 33 of 56 templates came out as two different pictures from the same input.
84
+ Nobody saw it, because the parity suite compared the elements as a SET and not their order. It
85
+ compares the order now, and 56 of 56 agree. If you render server-side and client-side and the two
86
+ looked subtly different, this is why.
87
+ - **A smoothed line no longer loops back in time.** With two readings on the same millisecond the
88
+ Catmull-Rom control point landed left of the segment start, so the curve ran a little way into
89
+ the past before continuing. Control points are now kept inside their segment's time span; evenly
90
+ spaced data is unaffected (one reference chart changed by 3.7 px, invisible side by side).
91
+ - **A fill region pointing at a threshold or series that does not exist is now reported by the Go
92
+ side too.** TypeScript throws; the port silently skipped the region and drew a plausible chart
93
+ with one area missing. `chart.Validate(opts)` is a separate step — the CLI aborts with the
94
+ message, the HTTP endpoint answers 400, and embedding code can call it or not.
95
+ - **Aggregated series are drawn as bands by the Go port too.** `showAs` other than `'minmaxavg'`
96
+ produced a single average line there while TypeScript drew one rectangle per slot — two different
97
+ pictures from the same JSON. `avgLine` and `countOpacity` now work in both; a Go series whose
98
+ `style.fill` is a colour no longer gets an extra filled area underneath.
99
+ - The two-line marker shapes (`cross`, `plus`) gave both of their lines the same SVG `id` when the
100
+ series carried a `style.id`. Duplicate ids make `url(#…)` and `getElementById` hit the first one
101
+ only; the second line now carries `<id>-2`.
102
+ - **Series without an explicit colour now take the theme palette in TypeScript too.** The Go port
103
+ always did; TypeScript gave every one of them the same `theme.stroke`, so five unstyled series
104
+ were five blue lines with five identical legend swatches — and the same JSON came out of the two
105
+ libraries differently. A single-series chart is unchanged: `palette[0]` *is* `theme.stroke`.
106
+ - Annotation labels at the edge of the time window flip their anchor inward instead of running
107
+ over the axis labels. An explicit `anchor` still wins. Annotations are deliberately not clipped —
108
+ a cut-off word is worse than an overlapping one.
109
+ - A threshold whose value lies outside the value domain no longer draws its label. Its line was
110
+ always clipped away; since 1.9.1 clamped labels into the plot, the text alone remained and
111
+ claimed a boundary that is not drawn. A threshold exactly *on* the domain edge still gets one —
112
+ that is the normal case when the scale comes from the data.
113
+
114
+ ### Removed
115
+ - `fill.hatchColor` and `fill.hatchWidth`. Declared in both libraries, read by neither — and by
116
+ design: a hatch is drawn in the colour of the area it belongs to, so that a hatched red zone
117
+ reads as red. The demos set `hatchColor` to exactly the colour they already got.
118
+ - `FillDirectionType` (`'toMin' | 'toMax'`). A May-2026 sketch that was never wired to anything —
119
+ filling relative to the line is expressed by `fill.regions[].from/to` with `'chartTop'` /
120
+ `'chartBottom'`, and an aggregated series fills with `fillToMin` / `fillToMax`. Both are tested;
121
+ the type only looked like a feature.
122
+
123
+ ### Changed
124
+ - `DataPoint.synthetic` is now set by the TypeScript side too, on the points the library computes
125
+ itself (threshold intersections, gap edges) — the Go port always did. Its doc no longer promises
126
+ renderer behaviour that was never implemented: nothing in either library acts on the flag; it is
127
+ a marker for whoever reads the processed data.
128
+ - **Go, source-breaking in a minor — deliberately.** `renderer.MeasureLegend`, `renderer.LabelWidth`
129
+ and `renderer.RenderLegend` take the text metric as an extra argument; pass `nil` for the shipped
130
+ default. These three are internals of the rendering path rather than part of the charting API, and
131
+ a 2.0 would promise far more than this release delivers. If you call them, add the argument.
132
+
22
133
  ## [1.9.1] - 2026-09-23
23
134
 
24
135
  ### Fixed
package/README.de.md CHANGED
@@ -171,7 +171,7 @@ deshalb gibt es **ein** Changelog für beide: [CHANGELOG.md](https://gitlab.com/
171
171
  Es liegt auch dem Paket bei — die Historie genau der Version, die du installiert hast, liegt
172
172
  damit neben dem Code.
173
173
 
174
- ### Warum schon 1.8, und warum so viele Minor-Versionen?
174
+ ### Warum schon 1.X, und warum so viele Minor-Versionen?
175
175
 
176
176
  Weil die Bibliothek täglich im Einsatz ist, und der Einsatz findet, was ein sauberer Entwurf
177
177
  nicht findet.
@@ -219,7 +219,7 @@ go get gitlab.com/mlc0911/mlctimegraphpdf
219
219
  mtg-pdf -in chart.json -out chart.pdf
220
220
  ```
221
221
 
222
- Noch jung: Version 0.2.0, nicht 1.0, und ein, zwei Fähigkeiten hinter dieser Bibliothek. Was man
222
+ Noch jung: Version 0.X.0, nicht 1.0, und ein, zwei Fähigkeiten hinter dieser Bibliothek. Was man
223
223
  vorher wissen sollte — eine Füllung auf einem *Pfad*, also die Fläche unter einer Linie oder
224
224
  einer Treppe, kommt derzeit deckend und ohne Schraffur heraus, weil nur Rechtecke beides
225
225
  durchreichen. Linien, Marker, Text, Strichmuster, Kurvengeometrie und rechteckige Füllungen sind
package/README.md CHANGED
@@ -170,7 +170,7 @@ changelog for both: [CHANGELOG.md](https://gitlab.com/mlc0911/mlctimegraph/-/blo
170
170
  It ships with this package too, so the history of the exact version you installed is right
171
171
  next to the code.
172
172
 
173
- ### Why already at 1.8, and why so many minor releases?
173
+ ### Why already at 1.X, and why so many minor releases?
174
174
 
175
175
  Because the library is in daily professional use, and use finds what a clean design does not.
176
176
 
package/SKILLS.md CHANGED
@@ -209,7 +209,10 @@ markers: [
209
209
  ```
210
210
 
211
211
  ### Axes & Margins
212
- The layout engine cannot measure rendered text. Always allocate sufficient margins for labels.
212
+ The layout engine does not call into the DOM, but it does know how wide text is: the advance
213
+ widths of the default font stack (`Liberation Sans, Arial, Helvetica` — the three are
214
+ metric-compatible) ship with both libraries. Margins still have to be large enough for your
215
+ labels; the library reserves room inside them, it does not grow them.
213
216
  And because the computed domain ends exactly on the smallest and largest reading, a thick line
214
217
  or a marker at the extreme loses half of itself to the clip — `padding` adds room **in pixels**
215
218
  (the cause is in pixels: `line.width`, `markers.size`), without giving up the automatic domain:
@@ -226,6 +229,120 @@ axes: {
226
229
  }
227
230
  ```
228
231
 
232
+ Using a different font? Either generate the table for it
233
+ (`node scripts/gen-text-metrics.mjs --font YourFont.ttf`, in the repository) or measure yourself:
234
+
235
+ ```ts
236
+ const canvas = document.createElement('canvas').getContext('2d')!;
237
+ new MLTimeGraph({
238
+ fontFamily: 'Inter, sans-serif',
239
+ textMetrics: (text, fontSize) => {
240
+ canvas.font = `${fontSize}px Inter, sans-serif`;
241
+ return canvas.measureText(text).width;
242
+ },
243
+ });
244
+ ```
245
+
246
+ **A measuring callback leaves the parity with the Go port, deliberately** — a function does not
247
+ travel in JSON, so the server cannot run yours. Same chart, two renderers, two layouts. Use it when
248
+ the browser is the only renderer; use a generated table when both have to agree. `estimateMetrics`
249
+ (exported) reproduces the layout of versions before 1.10.0.
250
+
251
+ ### Minor Ticks & Grid
252
+ ```ts
253
+ axes: {
254
+ x: { grid: { major: {}, minor: { color: '#eee', style: 'dashed' } }, ticks: { minor: 1 } },
255
+ left: { grid: { major: {}, minor: {} }, ticks: { major: 5, minor: 3 } },
256
+ }
257
+ ```
258
+ `ticks.minor` is how many ticks sit **between** two major ones (3 → quarters). `grid.minor` draws
259
+ the matching lines, by default at half the strength of the major grid; setting it without
260
+ `ticks.minor` means one. One minor style governs both directions — `axes.x` wins over `axes.left`,
261
+ same as for the major grid.
262
+
263
+ ### Smoothing — which spline
264
+ ```ts
265
+ style: { line: { smoothing: true, smoothingType: 'monotone' } }
266
+ ```
267
+ `'catmull-rom'` is the default: soft, cheap, and it **overshoots** — between two readings it
268
+ draws values that neither of them is. On a chart of measurements that is the picture claiming
269
+ something the sensor never reported.
270
+
271
+ `'monotone'` (Fritsch-Carlson) never leaves the span between two readings. Use it for anything
272
+ with a ceiling or a floor: humidity at 100 %, tank levels, battery charge, percentages.
273
+
274
+ `'akima'` takes its slope from five points and weights it against the change on the other side,
275
+ so a long flat run stays flat right up to an edge. Use it for sensors that only transmit on
276
+ change — a cliff in the data is a real event, not a reason to draw a wave before it.
277
+
278
+ `smoothing: true` remains the switch; `smoothingType` on its own draws straight segments. A step
279
+ shape is never smoothed, whatever you set.
280
+
281
+ If you write your own renderer against the draw commands, read `smoothingType` off the path and
282
+ pass it on — in Go that is `SmoothPathWith`, not `SmoothPath`, which always takes Catmull-Rom.
283
+ Drop it and the same chart comes out as one curve from your renderer and another from the SVG,
284
+ with nothing to warn you: this is exactly what happened to the PDF output in 1.10.0.
285
+
286
+ ### Grid in front or behind — `grid.layer`
287
+ ```ts
288
+ axes: { x: { grid: { major: {}, layer: 'back' } }, left: { grid: { major: {} } } }
289
+ ```
290
+ By default the grid is drawn **after** the series (`layer: 'front'`): a filled area down to the
291
+ baseline does not hide it, and its lines stay visible over the curve. Markers, annotations and
292
+ labels are drawn later still and stay on top either way.
293
+
294
+ `'back'` draws it first of all, before highlights and thresholds — the choice when an opaque fill
295
+ is *meant* to cover it, or when a faint raster behind the data is enough. One setting governs the
296
+ whole grid; `axes.x` wins over `axes.left`, same as for the style.
297
+
298
+ ### Building draw commands — `CommandBuilder`
299
+ ```ts
300
+ import { CommandBuilder } from 'ml-time-graph/internals';
301
+
302
+ const b = new CommandBuilder();
303
+ b.rect({ x: 0, y: 0, w: 10, h: 10, fill: '#eee' })
304
+ .text({ content: 'Label', x: 14, y: 9 })
305
+ .group({ cssClass: 'marks' }, (g) => g.circle({ cx: 5, cy: 5, r: 2 }));
306
+ const group = b.toGroup({ cssClass: 'my-layer' });
307
+ ```
308
+ For anyone producing draw commands — a custom layer, an annotation of your own, a renderer that
309
+ feeds the same `SVGRenderer`. It sets `type` for you, chains, and nests.
310
+
311
+ Two rules worth knowing. `group` draws **nothing** when its body adds nothing, so you cannot leave
312
+ an empty `<g>` behind; `toGroup` always returns a group, because a function that promises one must
313
+ deliver one. And `commands` hands out a copy — what you do with it afterwards cannot reach back
314
+ into the chart.
315
+
316
+ In Go it is `renderer.NewCommandBuilder()` with the same methods.
317
+
318
+ ### A panel behind the legend — `legend.box`
319
+ ```ts
320
+ legend: { show: true, position: 'inside-right', box: {} }
321
+ ```
322
+ A legend inside the plot sits **over** the data, and over a dense curve or a filled area it can be
323
+ unreadable. `box` puts a quiet panel under it. Like the grid, it is drawn only when you ask:
324
+ `box: {}` takes the defaults — white, a grey hairline, 6 px padding, 85 % opaque, so the data still
325
+ shows through faintly. `fill`, `stroke`, `strokeWidth`, `padding` and `opacity` override them, and
326
+ `stroke: 'none'` keeps the background without a border.
327
+
328
+ The panel takes the place where the entries would otherwise end, rather than pushing them around:
329
+ turning it on does not move the legend out over the plot edge. With an outside legend the padding
330
+ is reserved as real space, so the border never reaches into the plot.
331
+
332
+ There are no rounded corners — the draw-command model has no corner radius, and adding one would
333
+ mean changing SVG, Go and the PDF renderer for a rounding.
334
+
335
+ ### Legend Placement
336
+ `inside-left` / `inside-right` draw over the plot, `outside-left` / `outside-right` beside it,
337
+ `above` / `below` as a horizontal strip that wraps into as many rows as the entries need — the
338
+ chart reserves exactly that much height. `separate` draws nothing and hands you
339
+ `chart.legendItems()` to build your own.
340
+
341
+ ```ts
342
+ legend: { show: true, position: 'below' }, // waagerecht, bricht um
343
+ legend: { show: true, position: 'above', orientation: 'vertical' }, // Säule, wenn du darauf bestehst
344
+ ```
345
+
229
346
  ### Tooltips & Interactive Projections
230
347
  Attach DOM tooltips or use pixel/data coordinate projections:
231
348
  ```ts
@@ -330,8 +447,9 @@ scratch image.
330
447
  - **`resolveDash()` vs `getLineStyle()`:** `dashed` and `dotted` predate the scalable dash table and keep fixed SVG patterns (`"4,4"` and `"2,4"`) in the renderer for backwards compatibility. `getLineStyle()` returns the scalable table (`"6, 4"` for width 2). Anyone rendering custom legend swatches must call `resolveDash(variant, width)` so the swatch matches what is actually drawn.
331
448
  - **Markers do not inherit `line.width`:** `style.markers` carries its own pen — `strokeWidth`, `stroke`, `fill`. That is usually what you want (a 10 px line with 10 px marker outlines is a blob), but it means a marker stays hairline-thin when the line gets thick, and nothing tells you. Set `markers.strokeWidth` explicitly whenever `line.width` leaves the default.
332
449
  - **Marker suppression at threshold:** `style.markers.threshold` (and default `theme.pointThreshold = 100`) hides point markers when series sample count exceeds it to prevent visual crowding. Crucially, `chart.legendItems()` also omits the `marker` property when points are suppressed, because a symbol in the legend missing from the curve states something untrue.
333
- - **Built-in legend is static SVG:** Built-in legends (`inside-right`, etc.) are non-interactive SVG elements. For interactive series toggling or HTML layout below the chart, use `legend: { position: 'separate' }` and render HTML buttons from `chart.legendItems()` using `drawMarker()` and `SVGRenderer` or `resolveDash()`.
450
+ - **Built-in legend is static SVG:** Built-in legends (`inside-right`, `above`, `below`, …) are
451
+ non-interactive SVG elements. For interactive series toggling or HTML layout below the chart, use `legend: { position: 'separate' }` and render HTML buttons from `chart.legendItems()` using `drawMarker()` and `SVGRenderer` or `resolveDash()`.
334
452
  - **An annotation's `dash` takes a variant, not a pattern:** the type is `'dashed' | 'dotted'`. A raw SVG pattern like `'5,5'` is not rejected — it draws a solid line, in both libraries.
335
- - **Some options are accepted and do nothing:** `axes.<axis>.ticks.minor`, `axes.<axis>.grid.minor`, `fill.hatchColor` / `fill.hatchWidth`, `series.enumMap` and `series.sensorType` are in the types but no renderer reads them — in either library. Nothing warns you; the picture just stays as it was.
453
+ - **One option is still accepted and does nothing:** `series.sensorType` is in the types and the parser reads it, but no renderer acts on it — in either library. Setting it to `'enum'` does not label the axis; that is `series.enumMap`, which 1.10.0 wired up. Until 1.10.0 this list also held `ticks.minor`, `grid.minor` and `enumMap` itself: three fields the types promised and both renderers swallowed. Nothing warns you; the picture just stays as it was.
336
454
  - **CSS classes are not namespaced:** the chart uses plain names like `.series` and `.time-axis`. Inline the SVG into a page whose stylesheet has a `.series` rule and that rule applies to the chart. Scope your own selectors, and suspect the host page when an embedded chart looks wrong but the standalone file does not.
337
455
  - **Hatch lines adapt to fill colour:** Hatch patterns inherit the opaque colour of the area they belong to (`opaqueColor(fill)`), while the backdrop stays translucent. An earlier default drew fixed blue lines (`#4D88FF`), which falsely signaled an extra state on incident charts where colour is semantic.
package/USAGE.md CHANGED
@@ -320,6 +320,15 @@ style: {
320
320
  A threshold bound cuts the vertical jump at the reading's timestamp, so the part
321
321
  above a limit is a rectangle, not a triangle. Steps are never smoothed: a
322
322
  `smoothing: true` next to `shape: 'step'` is ignored for both line and fill.
323
+
324
+ **Which spline does the smoothing** is `smoothingType`, next to `smoothing`.
325
+ The default `'catmull-rom'` overshoots: between two readings it draws values
326
+ that neither of them is, which on a measurement chart is the picture claiming
327
+ something the sensor never reported. `'monotone'` (Fritsch-Carlson) stays
328
+ inside the span between two readings — use it wherever the value has a ceiling
329
+ or a floor, such as humidity at 100 %. `'akima'` weights its slope against
330
+ edges, so a flat run stays flat until the drop arrives — use it for sensors
331
+ that only transmit on change. See `demos/smoothing.html`.
323
332
  (Before 1.7.0 the area ran as a ramp underneath the staircase — see
324
333
  `demos/steps.html`.)
325
334
 
@@ -441,6 +450,11 @@ both get one; leave it out and there is none. (Before 1.5.1 the Go port drew a g
441
450
  nothing was configured while the TypeScript side drew none — the same JSON gave two
442
451
  different charts.)
443
452
 
453
+ **The grid is drawn over the series, not under it.** That is what `grid.layer: 'front'` means,
454
+ and it is the default: a filled area down to the baseline would otherwise swallow the lines.
455
+ Set `grid: { ..., layer: 'back' }` when you want exactly that — the grid behind the data, covered
456
+ by an opaque fill. Markers, annotations and labels come after the grid in both cases.
457
+
444
458
  ### Room at the edge — `padding`
445
459
 
446
460
  The computed domain ends exactly at the smallest and largest reading, and the plot
@@ -1,4 +1,4 @@
1
- var k=class{static interpolateDataPoint(n,i,l){return {time:n.time+Math.round(l*(i.time-n.time)),value:(n.value??0)+l*((i.value??0)-(n.value??0))}}static interpolateAggregatedPoint(n,i,l){let u=(e,t)=>e!==null&&t!==null?e+l*(t-e):null;return {time:n.time+l*(i.time-n.time),min:u(n.min,i.min),max:u(n.max,i.max),avg:u(n.avg,i.avg),count:Math.round(n.count+l*(i.count-n.count))}}static getRuns(n,i,l=0){let u=[...n].sort((r,o)=>r.time-o.time),e=[],t=[],a=null;for(let r of u){let o=i(r),m=l>0&&a&&r.time-a.time>l;(o||m)&&t.length&&(e.push(t),t=[]),o||t.push(r),a=r;}return t.length&&e.push(t),e}static splitByBoundaries(n,i,l,u){if(n.length===0)return [];if(i.length===0)return [{data:n,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let e=[...i].sort((m,s)=>m-s),t=[],a=m=>m<=0?Number.NEGATIVE_INFINITY:e[m-1],r=m=>{let s=0;for(let f=0;f<e.length&&m>=e[f];f++)s=f+1;return s},o=[n[0]];for(let m=1;m<n.length;m++){let s=n[m-1],f=n[m],g=l(s),d=l(f),p;d>g?p=e.filter(v=>v>g&&v<=d):d<g?p=e.filter(v=>v>=d&&v<g).reverse():p=[];let b=g;for(let v of p){let x=(v-g)/(d-g),h=u(s,f,x);o.push(h);let c=r((b+v)/2);t.push({data:o,zoneIndex:c,zoneLow:a(c)}),o=[h],b=v;}(p.length===0||p[p.length-1]!==d)&&o.push(f);}if(o.length>1||n.length===1){let m=l(o[0]),s=l(o[o.length-1]),f=r((m+s)/2);t.push({data:o,zoneIndex:f,zoneLow:a(f)});}return t}static splitByThreshold(n,i,l,u){let e=this.splitByBoundaries(n,[i],l,u),t={above:[],below:[]};for(let a of e)a.zoneIndex===0?t.below.push(a.data):t.above.push(a.data);return t}},H={pharma_cold:{limitLow:2,limitHigh:8,activationEnergy:83144},pharma_ambient:{limitLow:15,limitHigh:25,activationEnergy:83144},blood:{limitLow:2,limitHigh:6,activationEnergy:83144},food_chilled:{limitLow:0,limitHigh:4},frozen:{limitLow:-40,limitHigh:-18}},D=8.314462618,N=273.15;function y(n,i,l,u=1){let e=i.filter(h=>h.value!==null&&h.value!==void 0&&!Number.isNaN(h.value)).map(h=>h.value);if(!e.length)return {time:n,min:null,max:null,avg:null,mkt:null,deltaMkt:null,stdDev:null,minutesAboveHigh:l?0:null,minutesBelowLow:l?0:null,count:0};let t=1/0,a=-1/0,r=0;for(let h of e)h<t&&(t=h),h>a&&(a=h),r+=h;let o=r/e.length,m=l?0:null,s=l?0:null;if(l)for(let h=0;h<i.length;h++){let c=i[h];if(c.value!==null&&c.value!==void 0){let M=i[h+1],w=(M?M.time-c.time:0)/(1e3*60);c.value>l.limitHigh&&(m+=w),c.value<l.limitLow&&(s+=w);}}let f=0,g=0,d=(l?.activationEnergy??83144)/D;for(let h of e){f+=Math.pow(h-o,2);let c=h+N;g+=Math.exp(-d/c);}let p=f/e.length,b=Math.sqrt(p),v=null,x=null;if(e.length>=u){let h=g/e.length,c=d/-Math.log(h);v=Number((c-N).toFixed(2)),x=Number((v-o).toFixed(2));}return {time:n,min:Number(t.toFixed(2)),max:Number(a.toFixed(2)),avg:Number(o.toFixed(2)),mkt:v,deltaMkt:x,stdDev:Number(b.toFixed(2)),minutesAboveHigh:m!==null?Number(m.toFixed(1)):null,minutesBelowLow:s!==null?Number(s.toFixed(1)):null,count:e.length}}function A(n,i="hourly",l,u,e=1){if(!n.length)return [];let t=i==="hourly"?36e5:i==="daily"?864e5:l??3600*1e3,a=[...n].sort((s,f)=>s.time-f.time),r=[],o=a[0].time,m=[];for(let s of a){for(;s.time-o>=t;)r.push(y(o,m,u,e)),o+=t,m=[];m.push(s);}return r.push(y(o,m,u,e)),r}function S(n,i){let l=1/0,u=-1/0,e=0;for(let a of i)a<l&&(l=a),a>u&&(u=a),e+=a;let t=e/i.length;return {time:n,min:l,max:u,avg:t,count:i.length}}function z(n,i=6e4){if(n.length<2)return [];let l=[...n].sort((e,t)=>e.time-t.time),u=[];for(let e=1;e<l.length;e++)l[e].time-l[e-1].time>i&&u.push({startTime:l[e-1].time,endTime:l[e].time});return u}function B(n){let i=[],l=0,u=0,e=0,t=0;for(let a of n)a.count>0&&(e++,a.minutesAboveHigh&&(l+=a.minutesAboveHigh),a.stdDev&&a.stdDev>u&&(u=a.stdDev),a.deltaMkt&&a.deltaMkt>2&&t++);return e===0?[]:(l>120&&i.push({type:"critical",message:`Kritische Gesamtbelastung: Das Produkt war im gesamten Zeitraum insgesamt ${Math.round(l)} Minuten zu warm.`,metric:"Total Excursion Time"}),t>e*.15&&i.push({type:"warning",message:"Frequent thermal shocks detected. The kinetic temperature deviates strongly from the average (possible regular door openings).",metric:"Delta MKT Instability"}),u>4&&i.push({type:"warning",message:`High instability measured. Maximum standard deviation was ${u}\xB0C. The cooling system controls imprecisely.`,metric:"Standard Deviation Peak"}),i)}function P(n,i){if(n.length<=i)return n;let l=[],u=Math.ceil(n.length/i);l.push(n[0]);for(let e=1;e<n.length;e+=u)l.push(n[Math.min(e,n.length-1)]);return l}function _(n,i="hourly",l){let u={limitLow:l.low,limitHigh:l.high,activationEnergy:l.activationEnergy};return A(n,i,l.interval,u,l.minCountForMkt??1)}var C=class{static compute(n){let i=n.map(r=>r.value).filter(r=>r!==null).sort((r,o)=>r-o);if(i.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let l=i.length,u=i.reduce((r,o)=>r+o,0)/l,e=l%2===1?i[Math.floor(l/2)]:(i[l/2-1]+i[l/2])/2,t=i.reduce((r,o)=>r+Math.pow(o-u,2),0)/l,a=Math.sqrt(t);return {min:i[0],max:i[l-1],avg:u,mean:u,median:e,stdDev:a,count:l}}static computeInRange(n,i,l){let u=n.filter(e=>e.time>=i&&e.time<=l);return this.compute(u)}};function q(n,i){let l=typeof n=="number"?n:n.mean,u=typeof n=="number"?i??NaN:n.stdDev;return !Number.isFinite(l)||!Number.isFinite(u)||l===0?null:Math.abs(u/l)*100}var G=83144;function L(n,i=83144){let l=i/8.314,u=0,e=0;for(let a of n)a!==null&&(u+=Math.exp(-l/(a+273.15)),e++);if(e===0)return null;let t=u/e;return l/-Math.log(t)-273.15}function R(n,i,l=83144){let u=new Array(n.length),e=0;for(let t=0;t<n.length;t++){let a=n[t].time,r=a-i;for(;e<t&&n[e].time<r;)e++;let o=n.slice(e,t+1).map(s=>s.value),m=L(o,l);u[t]={time:a,value:m,synthetic:true};}return u}function E(n){let i=0,l=0;for(let t of n)t!==null&&(i+=t,l++);if(l===0)return null;let u=i/l,e=0;for(let t of n){if(t===null)continue;let a=t-u;e+=a*a;}return Math.sqrt(e/l)}function F(n){let i=0,l=0;for(let t of n)t!==null&&(i+=t,l++);if(l<2)return null;let u=i/l,e=0;for(let t of n){if(t===null)continue;let a=t-u;e+=a*a;}return Math.sqrt(e/(l-1))}function V(n,i,l=false){let u=new Array(n.length),e=0,t=l?F:E;for(let a=0;a<n.length;a++){let r=n[a].time,o=r-i;for(;e<a&&n[e].time<o;)e++;let m=n.slice(e,a+1).map(f=>f.value),s=t(m);u[a]={time:r,value:s,synthetic:true};}return u}function K(n,i){let l=new Array(n.length),u=0;for(let e=0;e<n.length;e++){let t=n[e].time,a=t-i;for(;u<e&&n[u].time<a;)u++;let r=0,o=0;for(let m=u;m<=e;m++){let s=n[m].value;s!==null&&(r+=s,o++);}l[e]={time:t,value:o===0?null:r/o,synthetic:true};}return l}function O(n,i){let l=new Array(n.length),u=null,e=0;for(let t=0;t<n.length;t++){let a=n[t].time,r=n[t].value;if(r===null){l[t]={time:a,value:u,synthetic:true};continue}if(u===null||i<=0)u=r;else {let o=1-Math.exp(-(a-e)/i);u=r*o+u*(1-o);}e=a,l[t]={time:a,value:u,synthetic:true};}return l}function U(n,i){let{high:l,low:u}=i,e={msAboveHigh:0,msBelowLow:0,globalMax:null,globalMin:null,excursions:[]},t=null;for(let a=0;a<n.length;a++){let r=n[a];if(r.value===null){t&&(e.excursions.push(t),t=null);continue}(e.globalMax===null||r.value>e.globalMax)&&(e.globalMax=r.value),(e.globalMin===null||r.value<e.globalMin)&&(e.globalMin=r.value);let o=l!==void 0&&r.value>l,m=u!==void 0&&r.value<u,s=o?"above":m?"below":null,f=n[a-1];if(f&&f.value!==null&&s!==null){let g=r.time-f.time;s==="above"?e.msAboveHigh+=g:e.msBelowLow+=g;}if(s===null){t&&(e.excursions.push(t),t=null);continue}t&&t.side===s?(t.endTime=r.time,t.durationMs=t.endTime-t.startTime,(s==="above"&&r.value>t.extremum||s==="below"&&r.value<t.extremum)&&(t.extremum=r.value)):(t&&e.excursions.push(t),t={startTime:r.time,endTime:r.time,side:s,extremum:r.value,durationMs:0});}return t&&e.excursions.push(t),e}function Y(n){if(n.length===0)return [];let i=new Map;for(let u of n)for(let e of u.data){if(e.value===null)continue;let t=i.get(e.time);t||(t=[],i.set(e.time,t)),t.push({name:u.name,value:e.value});}let l=[];for(let u of [...i.keys()].sort((e,t)=>e-t)){let e=i.get(u);if(e.length===0){l.push({time:u,min:null,max:null,delta:null,minSensor:null,maxSensor:null});continue}let t=e[0],a=e[0];for(let r=1;r<e.length;r++)e[r].value<t.value&&(t=e[r]),e[r].value>a.value&&(a=e[r]);l.push({time:u,min:t.value,max:a.value,delta:e.length<2?null:a.value-t.value,minSensor:t.name,maxSensor:a.name});}return l}function $(n){let i=[];for(let e of n){let t=0,a=0,r=1/0,o=-1/0;for(let m of e.data)m.value!==null&&(t+=m.value,a++,m.value<r&&(r=m.value),m.value>o&&(o=m.value));a!==0&&i.push({name:e.name,mean:t/a,min:r,max:o,count:a});}if(i.length===0)return {sensors:[],hottest:null,coldest:null,meanDelta:null};let l=i[0],u=i[0];for(let e=1;e<i.length;e++)i[e].mean>l.mean&&(l=i[e]),i[e].mean<u.mean&&(u=i[e]);return {sensors:i,hottest:l,coldest:u,meanDelta:l.mean-u.mean}}function T(n){let i=0,l=0,u=0,e=0,t=0;for(let m of n)m.value!==null&&(i++,l+=m.time,u+=m.value,e+=m.time*m.value,t+=m.time*m.time);if(i<2)return null;let a=i*t-l*l;if(a===0)return null;let r=(i*e-l*u)/a,o=(u-r*l)/i;return {slope:r,intercept:o,n:i}}function I(n,i){if(n.length===0)return null;let l=n[n.length-1].time,u=l-i,e=n.filter(t=>t.time>=u&&t.time<=l);return T(e)}function W(n,i){let l=[],u=0;for(let e=0;e<n.length;e++){let t=n[e].time,a=t-i;for(;u<n.length&&n[u].time<a;)u++;let r=T(n.slice(u,e+1));l.push({time:t,fit:r});}return l}function Z(n,i,l={}){let u=l.lookbackMs??9e5,e=l.side??"either";if(n.length===0)return null;let t=n[n.length-1];if(t.value===null)return null;let a=I(n,u);if(!a||a.slope===0)return null;let r=a.slope>0&&t.value<i,o=a.slope<0&&t.value>i;if(e==="above"&&!r||e==="below"&&!o||e==="either"&&!r&&!o)return null;let m=(i-a.intercept)/a.slope,s=m-t.time;return s<=0?null:{msUntil:s,eta:m,fit:a,currentValue:t.value}}function j(n,i={}){let l=i.refTempCelsius??121.11,u=i.zValueKelvin??10,e=0;for(let t=0;t<n.length-1;t++){let a=n[t],r=n[t+1];if(a.value===null||r.value===null)continue;let o=(r.time-a.time)/6e4;if(o<=0)continue;let m=Math.pow(10,(a.value-l)/u),s=Math.pow(10,(r.value-l)/u);e+=(m+s)/2*o;}return e}/*!
1
+ var k=class{static interpolateDataPoint(n,i,l){return {time:n.time+Math.round(l*(i.time-n.time)),value:(n.value??0)+l*((i.value??0)-(n.value??0)),synthetic:true}}static interpolateAggregatedPoint(n,i,l){let u=(e,t)=>e!==null&&t!==null?e+l*(t-e):null;return {time:n.time+l*(i.time-n.time),min:u(n.min,i.min),max:u(n.max,i.max),avg:u(n.avg,i.avg),count:Math.round(n.count+l*(i.count-n.count))}}static getRuns(n,i,l=0){let u=[...n].sort((r,o)=>r.time-o.time),e=[],t=[],a=null;for(let r of u){let o=i(r),m=l>0&&a&&r.time-a.time>l;(o||m)&&t.length&&(e.push(t),t=[]),o||t.push(r),a=r;}return t.length&&e.push(t),e}static splitByBoundaries(n,i,l,u){if(n.length===0)return [];if(i.length===0)return [{data:n,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let e=[...i].sort((m,s)=>m-s),t=[],a=m=>m<=0?Number.NEGATIVE_INFINITY:e[m-1],r=m=>{let s=0;for(let f=0;f<e.length&&m>=e[f];f++)s=f+1;return s},o=[n[0]];for(let m=1;m<n.length;m++){let s=n[m-1],f=n[m],g=l(s),d=l(f),p;d>g?p=e.filter(v=>v>g&&v<=d):d<g?p=e.filter(v=>v>=d&&v<g).reverse():p=[];let b=g;for(let v of p){let x=(v-g)/(d-g),h=u(s,f,x);o.push(h);let c=r((b+v)/2);t.push({data:o,zoneIndex:c,zoneLow:a(c)}),o=[h],b=v;}(p.length===0||p[p.length-1]!==d)&&o.push(f);}if(o.length>1||n.length===1){let m=l(o[0]),s=l(o[o.length-1]),f=r((m+s)/2);t.push({data:o,zoneIndex:f,zoneLow:a(f)});}return t}static splitByThreshold(n,i,l,u){let e=this.splitByBoundaries(n,[i],l,u),t={above:[],below:[]};for(let a of e)a.zoneIndex===0?t.below.push(a.data):t.above.push(a.data);return t}},H={pharma_cold:{limitLow:2,limitHigh:8,activationEnergy:83144},pharma_ambient:{limitLow:15,limitHigh:25,activationEnergy:83144},blood:{limitLow:2,limitHigh:6,activationEnergy:83144},food_chilled:{limitLow:0,limitHigh:4},frozen:{limitLow:-40,limitHigh:-18}},D=8.314462618,y=273.15;function N(n,i,l,u=1){let e=i.filter(h=>h.value!==null&&h.value!==void 0&&!Number.isNaN(h.value)).map(h=>h.value);if(!e.length)return {time:n,min:null,max:null,avg:null,mkt:null,deltaMkt:null,stdDev:null,minutesAboveHigh:l?0:null,minutesBelowLow:l?0:null,count:0};let t=1/0,a=-1/0,r=0;for(let h of e)h<t&&(t=h),h>a&&(a=h),r+=h;let o=r/e.length,m=l?0:null,s=l?0:null;if(l)for(let h=0;h<i.length;h++){let c=i[h];if(c.value!==null&&c.value!==void 0){let M=i[h+1],w=(M?M.time-c.time:0)/(1e3*60);c.value>l.limitHigh&&(m+=w),c.value<l.limitLow&&(s+=w);}}let f=0,g=0,d=(l?.activationEnergy??83144)/D;for(let h of e){f+=Math.pow(h-o,2);let c=h+y;g+=Math.exp(-d/c);}let p=f/e.length,b=Math.sqrt(p),v=null,x=null;if(e.length>=u){let h=g/e.length,c=d/-Math.log(h);v=Number((c-y).toFixed(2)),x=Number((v-o).toFixed(2));}return {time:n,min:Number(t.toFixed(2)),max:Number(a.toFixed(2)),avg:Number(o.toFixed(2)),mkt:v,deltaMkt:x,stdDev:Number(b.toFixed(2)),minutesAboveHigh:m!==null?Number(m.toFixed(1)):null,minutesBelowLow:s!==null?Number(s.toFixed(1)):null,count:e.length}}function A(n,i="hourly",l,u,e=1){if(!n.length)return [];let t=i==="hourly"?36e5:i==="daily"?864e5:l??3600*1e3,a=[...n].sort((s,f)=>s.time-f.time),r=[],o=a[0].time,m=[];for(let s of a){for(;s.time-o>=t;)r.push(N(o,m,u,e)),o+=t,m=[];m.push(s);}return r.push(N(o,m,u,e)),r}function S(n,i){let l=1/0,u=-1/0,e=0;for(let a of i)a<l&&(l=a),a>u&&(u=a),e+=a;let t=e/i.length;return {time:n,min:l,max:u,avg:t,count:i.length}}function z(n,i=6e4){if(n.length<2)return [];let l=[...n].sort((e,t)=>e.time-t.time),u=[];for(let e=1;e<l.length;e++)l[e].time-l[e-1].time>i&&u.push({startTime:l[e-1].time,endTime:l[e].time});return u}function B(n){let i=[],l=0,u=0,e=0,t=0;for(let a of n)a.count>0&&(e++,a.minutesAboveHigh&&(l+=a.minutesAboveHigh),a.stdDev&&a.stdDev>u&&(u=a.stdDev),a.deltaMkt&&a.deltaMkt>2&&t++);return e===0?[]:(l>120&&i.push({type:"critical",message:`Kritische Gesamtbelastung: Das Produkt war im gesamten Zeitraum insgesamt ${Math.round(l)} Minuten zu warm.`,metric:"Total Excursion Time"}),t>e*.15&&i.push({type:"warning",message:"Frequent thermal shocks detected. The kinetic temperature deviates strongly from the average (possible regular door openings).",metric:"Delta MKT Instability"}),u>4&&i.push({type:"warning",message:`High instability measured. Maximum standard deviation was ${u}\xB0C. The cooling system controls imprecisely.`,metric:"Standard Deviation Peak"}),i)}function _(n,i){if(n.length<=i)return n;let l=[],u=Math.ceil(n.length/i);l.push(n[0]);for(let e=1;e<n.length;e+=u)l.push(n[Math.min(e,n.length-1)]);return l}function C(n,i="hourly",l){let u={limitLow:l.low,limitHigh:l.high,activationEnergy:l.activationEnergy};return A(n,i,l.interval,u,l.minCountForMkt??1)}var P=class{static compute(n){let i=n.map(r=>r.value).filter(r=>r!==null).sort((r,o)=>r-o);if(i.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let l=i.length,u=i.reduce((r,o)=>r+o,0)/l,e=l%2===1?i[Math.floor(l/2)]:(i[l/2-1]+i[l/2])/2,t=i.reduce((r,o)=>r+Math.pow(o-u,2),0)/l,a=Math.sqrt(t);return {min:i[0],max:i[l-1],avg:u,mean:u,median:e,stdDev:a,count:l}}static computeInRange(n,i,l){let u=n.filter(e=>e.time>=i&&e.time<=l);return this.compute(u)}};function q(n,i){let l=typeof n=="number"?n:n.mean,u=typeof n=="number"?i??NaN:n.stdDev;return !Number.isFinite(l)||!Number.isFinite(u)||l===0?null:Math.abs(u/l)*100}var G=83144;function L(n,i=83144){let l=i/8.314,u=0,e=0;for(let a of n)a!==null&&(u+=Math.exp(-l/(a+273.15)),e++);if(e===0)return null;let t=u/e;return l/-Math.log(t)-273.15}function R(n,i,l=83144){let u=new Array(n.length),e=0;for(let t=0;t<n.length;t++){let a=n[t].time,r=a-i;for(;e<t&&n[e].time<r;)e++;let o=n.slice(e,t+1).map(s=>s.value),m=L(o,l);u[t]={time:a,value:m,synthetic:true};}return u}function E(n){let i=0,l=0;for(let t of n)t!==null&&(i+=t,l++);if(l===0)return null;let u=i/l,e=0;for(let t of n){if(t===null)continue;let a=t-u;e+=a*a;}return Math.sqrt(e/l)}function F(n){let i=0,l=0;for(let t of n)t!==null&&(i+=t,l++);if(l<2)return null;let u=i/l,e=0;for(let t of n){if(t===null)continue;let a=t-u;e+=a*a;}return Math.sqrt(e/(l-1))}function V(n,i,l=false){let u=new Array(n.length),e=0,t=l?F:E;for(let a=0;a<n.length;a++){let r=n[a].time,o=r-i;for(;e<a&&n[e].time<o;)e++;let m=n.slice(e,a+1).map(f=>f.value),s=t(m);u[a]={time:r,value:s,synthetic:true};}return u}function K(n,i){let l=new Array(n.length),u=0;for(let e=0;e<n.length;e++){let t=n[e].time,a=t-i;for(;u<e&&n[u].time<a;)u++;let r=0,o=0;for(let m=u;m<=e;m++){let s=n[m].value;s!==null&&(r+=s,o++);}l[e]={time:t,value:o===0?null:r/o,synthetic:true};}return l}function O(n,i){let l=new Array(n.length),u=null,e=0;for(let t=0;t<n.length;t++){let a=n[t].time,r=n[t].value;if(r===null){l[t]={time:a,value:u,synthetic:true};continue}if(u===null||i<=0)u=r;else {let o=1-Math.exp(-(a-e)/i);u=r*o+u*(1-o);}e=a,l[t]={time:a,value:u,synthetic:true};}return l}function U(n,i){let{high:l,low:u}=i,e={msAboveHigh:0,msBelowLow:0,globalMax:null,globalMin:null,excursions:[]},t=null;for(let a=0;a<n.length;a++){let r=n[a];if(r.value===null){t&&(e.excursions.push(t),t=null);continue}(e.globalMax===null||r.value>e.globalMax)&&(e.globalMax=r.value),(e.globalMin===null||r.value<e.globalMin)&&(e.globalMin=r.value);let o=l!==void 0&&r.value>l,m=u!==void 0&&r.value<u,s=o?"above":m?"below":null,f=n[a-1];if(f&&f.value!==null&&s!==null){let g=r.time-f.time;s==="above"?e.msAboveHigh+=g:e.msBelowLow+=g;}if(s===null){t&&(e.excursions.push(t),t=null);continue}t&&t.side===s?(t.endTime=r.time,t.durationMs=t.endTime-t.startTime,(s==="above"&&r.value>t.extremum||s==="below"&&r.value<t.extremum)&&(t.extremum=r.value)):(t&&e.excursions.push(t),t={startTime:r.time,endTime:r.time,side:s,extremum:r.value,durationMs:0});}return t&&e.excursions.push(t),e}function Y(n){if(n.length===0)return [];let i=new Map;for(let u of n)for(let e of u.data){if(e.value===null)continue;let t=i.get(e.time);t||(t=[],i.set(e.time,t)),t.push({name:u.name,value:e.value});}let l=[];for(let u of [...i.keys()].sort((e,t)=>e-t)){let e=i.get(u);if(e.length===0){l.push({time:u,min:null,max:null,delta:null,minSensor:null,maxSensor:null});continue}let t=e[0],a=e[0];for(let r=1;r<e.length;r++)e[r].value<t.value&&(t=e[r]),e[r].value>a.value&&(a=e[r]);l.push({time:u,min:t.value,max:a.value,delta:e.length<2?null:a.value-t.value,minSensor:t.name,maxSensor:a.name});}return l}function $(n){let i=[];for(let e of n){let t=0,a=0,r=1/0,o=-1/0;for(let m of e.data)m.value!==null&&(t+=m.value,a++,m.value<r&&(r=m.value),m.value>o&&(o=m.value));a!==0&&i.push({name:e.name,mean:t/a,min:r,max:o,count:a});}if(i.length===0)return {sensors:[],hottest:null,coldest:null,meanDelta:null};let l=i[0],u=i[0];for(let e=1;e<i.length;e++)i[e].mean>l.mean&&(l=i[e]),i[e].mean<u.mean&&(u=i[e]);return {sensors:i,hottest:l,coldest:u,meanDelta:l.mean-u.mean}}function T(n){let i=0,l=0,u=0,e=0,t=0;for(let m of n)m.value!==null&&(i++,l+=m.time,u+=m.value,e+=m.time*m.value,t+=m.time*m.time);if(i<2)return null;let a=i*t-l*l;if(a===0)return null;let r=(i*e-l*u)/a,o=(u-r*l)/i;return {slope:r,intercept:o,n:i}}function I(n,i){if(n.length===0)return null;let l=n[n.length-1].time,u=l-i,e=n.filter(t=>t.time>=u&&t.time<=l);return T(e)}function W(n,i){let l=[],u=0;for(let e=0;e<n.length;e++){let t=n[e].time,a=t-i;for(;u<n.length&&n[u].time<a;)u++;let r=T(n.slice(u,e+1));l.push({time:t,fit:r});}return l}function Z(n,i,l={}){let u=l.lookbackMs??9e5,e=l.side??"either";if(n.length===0)return null;let t=n[n.length-1];if(t.value===null)return null;let a=I(n,u);if(!a||a.slope===0)return null;let r=a.slope>0&&t.value<i,o=a.slope<0&&t.value>i;if(e==="above"&&!r||e==="below"&&!o||e==="either"&&!r&&!o)return null;let m=(i-a.intercept)/a.slope,s=m-t.time;return s<=0?null:{msUntil:s,eta:m,fit:a,currentValue:t.value}}function j(n,i={}){let l=i.refTempCelsius??121.11,u=i.zValueKelvin??10,e=0;for(let t=0;t<n.length-1;t++){let a=n[t],r=n[t+1];if(a.value===null||r.value===null)continue;let o=(r.time-a.time)/6e4;if(o<=0)continue;let m=Math.pow(10,(a.value-l)/u),s=Math.pow(10,(r.value-l)/u);e+=(m+s)/2*o;}return e}/*!
2
2
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
3
3
  * MIT with Attribution: free use incl. commercial requires visible credit to
4
4
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
@@ -12,4 +12,4 @@ var k=class{static interpolateDataPoint(n,i,l){return {time:n.time+Math.round(l*
12
12
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
13
13
  * MIT with Attribution: free use incl. commercial requires visible credit to
14
14
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
15
- */export{G as DEFAULT_ACTIVATION_ENERGY,H as PRODUCT_PROFILES,k as SeriesProcessor,C as StatsAggregator,A as aggregateBySlot,_ as aggregateWithStats,B as analyzeLongTermTrends,U as computeLimitExcursions,S as createAggr,I as currentTrend,z as detectGaps,P as downsample,j as f0Sterilization,$ as hotColdSpots,T as linearFit,L as mkt,Z as predictTimeToThreshold,O as rollingEma,K as rollingMean,R as rollingMkt,V as rollingStdDev,W as rollingTrend,F as sampleStdDev,Y as spatialDelta,E as stdDev,q as varianceCoefficient};
15
+ */export{G as DEFAULT_ACTIVATION_ENERGY,H as PRODUCT_PROFILES,k as SeriesProcessor,P as StatsAggregator,A as aggregateBySlot,C as aggregateWithStats,B as analyzeLongTermTrends,U as computeLimitExcursions,S as createAggr,I as currentTrend,z as detectGaps,_ as downsample,j as f0Sterilization,$ as hotColdSpots,T as linearFit,L as mkt,Z as predictTimeToThreshold,O as rollingEma,K as rollingMean,R as rollingMkt,V as rollingStdDev,W as rollingTrend,F as sampleStdDev,Y as spatialDelta,E as stdDev,q as varianceCoefficient};