web-mojo 2.1.626 → 2.1.675

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.
Files changed (64) hide show
  1. package/dist/admin.cjs.js +1 -1
  2. package/dist/admin.cjs.js.map +1 -1
  3. package/dist/admin.es.js +105 -75
  4. package/dist/admin.es.js.map +1 -1
  5. package/dist/auth.cjs.js +1 -1
  6. package/dist/auth.cjs.js.map +1 -1
  7. package/dist/auth.es.js +3 -3
  8. package/dist/auth.es.js.map +1 -1
  9. package/dist/charts.cjs.js +1 -1
  10. package/dist/charts.cjs.js.map +1 -1
  11. package/dist/charts.es.js +8 -590
  12. package/dist/charts.es.js.map +1 -1
  13. package/dist/chunks/{ChatView-BxbA5ob6.js → ChatView-BmWwT0QF.js} +72 -16
  14. package/dist/chunks/ChatView-BmWwT0QF.js.map +1 -0
  15. package/dist/chunks/ChatView-Dpxy85W3.js +2 -0
  16. package/dist/chunks/ChatView-Dpxy85W3.js.map +1 -0
  17. package/dist/chunks/{ContextMenu-ATInMbaI.js → ContextMenu-C1A4AVbi.js} +2 -2
  18. package/dist/chunks/{ContextMenu-ATInMbaI.js.map → ContextMenu-C1A4AVbi.js.map} +1 -1
  19. package/dist/chunks/{ContextMenu-Ckttp-rD.js → ContextMenu-CqUg8Aov.js} +2 -2
  20. package/dist/chunks/{ContextMenu-Ckttp-rD.js.map → ContextMenu-CqUg8Aov.js.map} +1 -1
  21. package/dist/chunks/{DataView-BQOKPprj.js → DataView-BZBAmV6d.js} +2 -2
  22. package/dist/chunks/{DataView-BQOKPprj.js.map → DataView-BZBAmV6d.js.map} +1 -1
  23. package/dist/chunks/{DataView-BsWK0Ul7.js → DataView-C73dhEBE.js} +2 -2
  24. package/dist/chunks/{DataView-BsWK0Ul7.js.map → DataView-C73dhEBE.js.map} +1 -1
  25. package/dist/chunks/{Dialog-aTTrQ6uW.js → Dialog-CaQZlPs8.js} +5 -5
  26. package/dist/chunks/{Dialog-aTTrQ6uW.js.map → Dialog-CaQZlPs8.js.map} +1 -1
  27. package/dist/chunks/{Dialog-t4J3qOjC.js → Dialog-CsYKb5_K.js} +2 -2
  28. package/dist/chunks/{Dialog-t4J3qOjC.js.map → Dialog-CsYKb5_K.js.map} +1 -1
  29. package/dist/chunks/{FormView-DvKBq99H.js → FormView-BQet49yz.js} +2 -2
  30. package/dist/chunks/{FormView-DvKBq99H.js.map → FormView-BQet49yz.js.map} +1 -1
  31. package/dist/chunks/{FormView-DjypPrEw.js → FormView-C5gHgWj-.js} +2 -2
  32. package/dist/chunks/{FormView-DjypPrEw.js.map → FormView-C5gHgWj-.js.map} +1 -1
  33. package/dist/chunks/{MetricsChart-DJ_AMjGg.js → MetricsMiniChartWidget-0QE0WL-x.js} +771 -4
  34. package/dist/chunks/MetricsMiniChartWidget-0QE0WL-x.js.map +1 -0
  35. package/dist/chunks/{MetricsChart-BHB2dubV.js → MetricsMiniChartWidget-hp1SBgB2.js} +2 -2
  36. package/dist/chunks/MetricsMiniChartWidget-hp1SBgB2.js.map +1 -0
  37. package/dist/chunks/{PDFViewer-kDd18mqo.js → PDFViewer-CJAsn0H1.js} +3 -3
  38. package/dist/chunks/{PDFViewer-kDd18mqo.js.map → PDFViewer-CJAsn0H1.js.map} +1 -1
  39. package/dist/chunks/{PDFViewer-DXoC6y5o.js → PDFViewer-CX5bKmKa.js} +2 -2
  40. package/dist/chunks/{PDFViewer-DXoC6y5o.js.map → PDFViewer-CX5bKmKa.js.map} +1 -1
  41. package/dist/chunks/{Page-BrWp1FsC.js → Page-DJtwfAf4.js} +2 -2
  42. package/dist/chunks/{Page-BrWp1FsC.js.map → Page-DJtwfAf4.js.map} +1 -1
  43. package/dist/chunks/{Page-DgKaDD9p.js → Page-Oo8qO-IX.js} +2 -2
  44. package/dist/chunks/{Page-DgKaDD9p.js.map → Page-Oo8qO-IX.js.map} +1 -1
  45. package/dist/chunks/{TopNav-DoAl9Rpd.js → TopNav-C4tISlAt.js} +2 -2
  46. package/dist/chunks/{TopNav-DoAl9Rpd.js.map → TopNav-C4tISlAt.js.map} +1 -1
  47. package/dist/chunks/{TopNav-DGtRj5F4.js → TopNav-QlJo-F9B.js} +5 -5
  48. package/dist/chunks/{TopNav-DGtRj5F4.js.map → TopNav-QlJo-F9B.js.map} +1 -1
  49. package/dist/chunks/{WebApp-ciExPk0c.js → WebApp-BWnjZ-UU.js} +14 -13
  50. package/dist/chunks/{WebApp-ciExPk0c.js.map → WebApp-BWnjZ-UU.js.map} +1 -1
  51. package/dist/chunks/{WebApp-DWIriU_w.js → WebApp-DgFbFcSM.js} +2 -2
  52. package/dist/chunks/{WebApp-DWIriU_w.js.map → WebApp-DgFbFcSM.js.map} +1 -1
  53. package/dist/docit.cjs.js +1 -1
  54. package/dist/docit.es.js +5 -5
  55. package/dist/index.cjs.js +1 -1
  56. package/dist/index.es.js +11 -11
  57. package/dist/lightbox.cjs.js +1 -1
  58. package/dist/lightbox.es.js +4 -4
  59. package/package.json +1 -1
  60. package/dist/chunks/ChatView-0e0k3QSK.js +0 -2
  61. package/dist/chunks/ChatView-0e0k3QSK.js.map +0 -1
  62. package/dist/chunks/ChatView-BxbA5ob6.js.map +0 -1
  63. package/dist/chunks/MetricsChart-BHB2dubV.js.map +0 -1
  64. package/dist/chunks/MetricsChart-DJ_AMjGg.js.map +0 -1
package/dist/charts.es.js CHANGED
@@ -1,599 +1,17 @@
1
- import { B, M, P, S } from "./chunks/MetricsChart-DJ_AMjGg.js";
2
- import { V as View, d as dataFormatter } from "./chunks/WebApp-ciExPk0c.js";
3
- import { B as B2, b, a, c, e, f, W } from "./chunks/WebApp-ciExPk0c.js";
4
- class MiniChart extends View {
5
- constructor(options = {}) {
6
- super({
7
- className: "mini-chart",
8
- ...options
9
- });
10
- this.chartType = options.chartType || "line";
11
- this.data = options.data || [];
12
- this.width = options.width || "100%";
13
- this.height = options.height || 30;
14
- this.maintainAspectRatio = options.maintainAspectRatio || false;
15
- this.color = options.color || "rgba(54, 162, 235, 1)";
16
- this.fillColor = options.fillColor || "rgba(54, 162, 235, 0.1)";
17
- this.strokeWidth = options.strokeWidth || 2;
18
- this.barGap = options.barGap || 2;
19
- this.fill = options.fill !== false;
20
- this.smoothing = options.smoothing || 0.3;
21
- this.padding = options.padding || 2;
22
- this.minValue = options.minValue;
23
- this.maxValue = options.maxValue;
24
- this.showDots = options.showDots || false;
25
- this.dotRadius = options.dotRadius || 2;
26
- this.animate = options.animate !== false;
27
- this.animationDuration = options.animationDuration || 300;
28
- this.showTooltip = options.showTooltip !== false;
29
- this.tooltipFormatter = options.tooltipFormatter || null;
30
- this.tooltipTemplate = options.tooltipTemplate || null;
31
- this.valueFormat = options.valueFormat || null;
32
- this.labelFormat = options.labelFormat || null;
33
- this.showCrosshair = options.showCrosshair !== false;
34
- this.crosshairColor = options.crosshairColor || "rgba(0, 0, 0, 0.2)";
35
- this.crosshairWidth = options.crosshairWidth || 1;
36
- this.showXAxis = options.showXAxis || false;
37
- this.xAxisColor = options.xAxisColor || this.color;
38
- this.xAxisWidth = options.xAxisWidth || 1;
39
- this.xAxisDashed = options.xAxisDashed !== false;
40
- this.tooltip = null;
41
- this.crosshair = null;
42
- this.hoveredIndex = -1;
43
- this.dataFormatter = dataFormatter;
44
- this.labels = options.labels || null;
45
- }
46
- getTemplate() {
47
- const widthStyle = typeof this.width === "number" ? `${this.width}px` : this.width;
48
- const heightStyle = typeof this.height === "number" ? `${this.height}px` : this.height;
49
- const preserveAspectRatio = this.maintainAspectRatio ? "xMidYMid meet" : "none";
50
- return `
51
- <div class="mini-chart-wrapper" style="position: relative; display: block; width: ${widthStyle}; height: ${heightStyle};">
52
- <svg
53
- class="mini-chart-svg"
54
- width="100%"
55
- height="100%"
56
- viewBox="0 0 100 ${this.height}"
57
- preserveAspectRatio="${preserveAspectRatio}"
58
- style="display: block;">
59
- </svg>
60
- ${this.showTooltip ? '<div class="mini-chart-tooltip" style="display: none;"></div>' : ""}
61
- </div>
62
- `;
63
- }
64
- async onAfterRender() {
65
- this.svg = this.element.querySelector(".mini-chart-svg");
66
- this.tooltip = this.element.querySelector(".mini-chart-tooltip");
67
- this.updateDimensions();
68
- if (this.data && this.data.length > 0) {
69
- this.renderChart();
70
- }
71
- if (this.showTooltip && this.svg) {
72
- this.setupTooltip();
73
- }
74
- this.setupResizeObserver();
75
- }
76
- updateDimensions() {
77
- if (!this.svg) return;
78
- const rect = this.svg.getBoundingClientRect();
79
- this.actualWidth = rect.width || 100;
80
- this.actualHeight = rect.height || this.height;
81
- this.svg.setAttribute("viewBox", `0 0 ${this.actualWidth} ${this.actualHeight}`);
82
- }
83
- setupResizeObserver() {
84
- if (typeof ResizeObserver === "undefined") return;
85
- this.resizeObserver = new ResizeObserver(() => {
86
- this.updateDimensions();
87
- if (this.data && this.data.length > 0) {
88
- this.renderChart();
89
- }
90
- });
91
- if (this.svg) {
92
- this.resizeObserver.observe(this.svg);
93
- }
94
- }
95
- renderChart() {
96
- if (!this.svg || !this.data || this.data.length === 0) return;
97
- this.svg.innerHTML = "";
98
- const { min, max } = this.calculateBounds();
99
- if (this.showXAxis) {
100
- this.renderXAxis(min, max);
101
- }
102
- if (this.chartType === "line") {
103
- this.renderLine(min, max);
104
- } else if (this.chartType === "bar") {
105
- this.renderBar(min, max);
106
- }
107
- if (this.showCrosshair) {
108
- const height = this.getActualHeight();
109
- this.crosshair = this.createSVGElement("line", {
110
- x1: 0,
111
- y1: 0,
112
- x2: 0,
113
- y2: height,
114
- stroke: this.crosshairColor,
115
- "stroke-width": this.crosshairWidth,
116
- "stroke-dasharray": "3,3",
117
- style: "display: none; pointer-events: none;"
118
- });
119
- this.svg.appendChild(this.crosshair);
120
- }
121
- if (this.showTooltip && this.tooltip) {
122
- this.setupTooltip();
123
- }
124
- if (this.animate) {
125
- this.applyAnimation();
126
- }
127
- }
128
- renderXAxis(min, max) {
129
- const width = this.getActualWidth();
130
- const height = this.getActualHeight();
131
- let yPos;
132
- if (min <= 0 && max >= 0) {
133
- const range = max - min;
134
- const yScale = (height - this.padding * 2) / range;
135
- yPos = height - this.padding - (0 - min) * yScale;
136
- } else {
137
- yPos = height - this.padding;
138
- }
139
- const xAxis = this.createSVGElement("line", {
140
- x1: this.padding,
141
- y1: yPos,
142
- x2: width - this.padding,
143
- y2: yPos,
144
- stroke: this.xAxisColor,
145
- "stroke-width": this.xAxisWidth,
146
- "stroke-dasharray": this.xAxisDashed ? "2,2" : "none",
147
- "stroke-opacity": "0.5"
148
- });
149
- this.svg.appendChild(xAxis);
150
- }
151
- calculateBounds() {
152
- const values = this.data.map((d) => typeof d === "object" ? d.value : d);
153
- let min = this.minValue !== void 0 ? this.minValue : Math.min(...values);
154
- let max = this.maxValue !== void 0 ? this.maxValue : Math.max(...values);
155
- const range = max - min;
156
- if (range === 0) {
157
- min = min - 1;
158
- max = max + 1;
159
- }
160
- return { min, max };
161
- }
162
- getActualWidth() {
163
- return this.actualWidth || this.width || 100;
164
- }
165
- getActualHeight() {
166
- return this.actualHeight || this.height || 30;
167
- }
168
- renderLine(min, max) {
169
- const values = this.data.map((d) => typeof d === "object" ? d.value : d);
170
- const points = this.calculatePoints(values, min, max);
171
- if (this.fill) {
172
- const areaPath = this.createAreaPath(points);
173
- const area = this.createSVGElement("path", {
174
- d: areaPath,
175
- fill: this.fillColor,
176
- stroke: "none"
177
- });
178
- this.svg.appendChild(area);
179
- }
180
- const linePath = this.smoothing > 0 ? this.createSmoothPath(points) : this.createLinePath(points);
181
- const line = this.createSVGElement("path", {
182
- d: linePath,
183
- fill: "none",
184
- stroke: this.color,
185
- "stroke-width": this.strokeWidth,
186
- "stroke-linecap": "round",
187
- "stroke-linejoin": "round"
188
- });
189
- this.svg.appendChild(line);
190
- if (this.showDots) {
191
- points.forEach((point) => {
192
- const dot = this.createSVGElement("circle", {
193
- cx: point.x,
194
- cy: point.y,
195
- r: this.dotRadius,
196
- fill: this.color
197
- });
198
- this.svg.appendChild(dot);
199
- });
200
- }
201
- }
202
- renderBar(min, max) {
203
- const values = this.data.map((d) => typeof d === "object" ? d.value : d);
204
- const points = this.calculatePoints(values, min, max);
205
- const width = this.getActualWidth();
206
- const height = this.getActualHeight();
207
- const barWidth = (width - this.padding * 2 - this.barGap * (values.length - 1)) / values.length;
208
- points.forEach((point, index) => {
209
- const barHeight = height - this.padding * 2 - point.y + this.padding;
210
- const x = point.x - barWidth / 2;
211
- const y = point.y;
212
- const bar = this.createSVGElement("rect", {
213
- x,
214
- y,
215
- width: barWidth,
216
- height: barHeight,
217
- fill: this.color,
218
- rx: 1,
219
- // Slight rounding
220
- "data-bar-index": index,
221
- class: "mini-chart-bar"
222
- });
223
- this.svg.appendChild(bar);
224
- });
225
- }
226
- calculatePoints(values, min, max) {
227
- const range = max - min;
228
- const width = this.getActualWidth();
229
- const height = this.getActualHeight();
230
- const xStep = (width - this.padding * 2) / (values.length - 1 || 1);
231
- const yScale = (height - this.padding * 2) / range;
232
- return values.map((value, index) => ({
233
- x: this.padding + index * xStep,
234
- y: height - this.padding - (value - min) * yScale
235
- }));
236
- }
237
- createLinePath(points) {
238
- if (points.length === 0) return "";
239
- let path = `M ${points[0].x},${points[0].y}`;
240
- for (let i = 1; i < points.length; i++) {
241
- path += ` L ${points[i].x},${points[i].y}`;
242
- }
243
- return path;
244
- }
245
- createSmoothPath(points) {
246
- if (points.length < 2) return this.createLinePath(points);
247
- let path = `M ${points[0].x},${points[0].y}`;
248
- for (let i = 0; i < points.length - 1; i++) {
249
- const current = points[i];
250
- const next = points[i + 1];
251
- const cp1x = current.x + (next.x - current.x) * this.smoothing;
252
- const cp1y = current.y;
253
- const cp2x = next.x - (next.x - current.x) * this.smoothing;
254
- const cp2y = next.y;
255
- path += ` C ${cp1x},${cp1y} ${cp2x},${cp2y} ${next.x},${next.y}`;
256
- }
257
- return path;
258
- }
259
- createAreaPath(points) {
260
- if (points.length === 0) return "";
261
- const linePath = this.smoothing > 0 ? this.createSmoothPath(points) : this.createLinePath(points);
262
- const lastPoint = points[points.length - 1];
263
- const firstPoint = points[0];
264
- const height = this.getActualHeight();
265
- return `${linePath} L ${lastPoint.x},${height - this.padding} L ${firstPoint.x},${height - this.padding} Z`;
266
- }
267
- createSVGElement(tag, attributes = {}) {
268
- const element = document.createElementNS("http://www.w3.org/2000/svg", tag);
269
- Object.entries(attributes).forEach(([key, value]) => {
270
- element.setAttribute(key, value);
271
- });
272
- return element;
273
- }
274
- applyAnimation() {
275
- const paths = this.svg.querySelectorAll("path");
276
- paths.forEach((path) => {
277
- const length = path.getTotalLength();
278
- path.style.strokeDasharray = length;
279
- path.style.strokeDashoffset = length;
280
- path.style.animation = `mini-chart-draw ${this.animationDuration}ms ease-out forwards`;
281
- });
282
- const bars = this.svg.querySelectorAll("rect");
283
- bars.forEach((bar, index) => {
284
- bar.style.transformOrigin = "bottom";
285
- bar.style.animation = `mini-chart-bar-grow ${this.animationDuration}ms ease-out ${index * 20}ms forwards`;
286
- bar.style.transform = "scaleY(0)";
287
- });
288
- }
289
- setupTooltip() {
290
- if (!this.svg || !this.tooltip) return;
291
- const values = this.data.map((d) => typeof d === "object" ? d.value : d);
292
- const points = this.calculatePoints(values, ...Object.values(this.calculateBounds()));
293
- const width = this.getActualWidth();
294
- const height = this.getActualHeight();
295
- const barWidth = width / values.length;
296
- points.forEach((point, index) => {
297
- const hitArea = this.createSVGElement("rect", {
298
- x: index * barWidth,
299
- y: 0,
300
- width: barWidth,
301
- height,
302
- fill: "transparent",
303
- style: "cursor: pointer;"
304
- });
305
- hitArea.addEventListener("mouseenter", (e2) => {
306
- this.showTooltipAtIndex(index, e2);
307
- });
308
- hitArea.addEventListener("mousemove", (e2) => {
309
- this.updateTooltipPosition(e2);
310
- });
311
- hitArea.addEventListener("mouseleave", () => {
312
- this.hideTooltip();
313
- });
314
- this.svg.appendChild(hitArea);
315
- });
316
- }
317
- showTooltipAtIndex(index, event) {
318
- if (!this.tooltip) return;
319
- this.hoveredIndex = index;
320
- const value = typeof this.data[index] === "object" ? this.data[index].value : this.data[index];
321
- const dataLabel = typeof this.data[index] === "object" ? this.data[index].label : null;
322
- const label = this.labels ? this.labels[index] : dataLabel;
323
- let content;
324
- if (this.tooltipTemplate && typeof this.tooltipTemplate === "function") {
325
- content = this.tooltipTemplate({ value, label, index, data: this.data[index] });
326
- } else {
327
- let displayValue = value;
328
- if (this.valueFormat && this.dataFormatter) {
329
- displayValue = this.dataFormatter.pipe(value, this.valueFormat);
330
- } else if (this.tooltipFormatter && typeof this.tooltipFormatter === "function") {
331
- displayValue = this.tooltipFormatter(value, index);
332
- } else {
333
- displayValue = typeof value === "number" ? value.toLocaleString() : value;
334
- }
335
- let displayLabel = label;
336
- if (label && this.labelFormat && this.dataFormatter) {
337
- displayLabel = this.dataFormatter.pipe(label, this.labelFormat);
338
- }
339
- content = `<strong>${displayValue}</strong>`;
340
- if (displayLabel) {
341
- content = `<div class="mini-chart-tooltip-label">${displayLabel}</div>${content}`;
342
- }
343
- }
344
- this.tooltip.innerHTML = content;
345
- this.tooltip.style.display = "block";
346
- this.updateTooltipPosition(event);
347
- if (this.chartType === "bar") {
348
- this.highlightBar(index);
349
- }
350
- if (this.crosshair && this.showCrosshair) {
351
- const width = this.getActualWidth();
352
- const barWidth = width / this.data.length;
353
- const x = index * barWidth + barWidth / 2;
354
- this.crosshair.setAttribute("x1", x);
355
- this.crosshair.setAttribute("x2", x);
356
- this.crosshair.style.display = "block";
357
- }
358
- }
359
- updateTooltipPosition(event) {
360
- if (!this.tooltip || this.tooltip.style.display === "none") return;
361
- const rect = this.svg.getBoundingClientRect();
362
- const x = event.clientX - rect.left;
363
- const y = event.clientY - rect.top;
364
- this.tooltip.style.left = `${x}px`;
365
- this.tooltip.style.top = `${y - 10}px`;
366
- this.tooltip.style.transform = "translate(-50%, -100%)";
367
- }
368
- hideTooltip() {
369
- if (this.tooltip) {
370
- this.tooltip.style.display = "none";
371
- this.hoveredIndex = -1;
372
- }
373
- if (this.chartType === "bar") {
374
- this.unhighlightBars();
375
- }
376
- if (this.crosshair) {
377
- this.crosshair.style.display = "none";
378
- }
379
- }
380
- highlightBar(index) {
381
- if (!this.svg) return;
382
- this.unhighlightBars();
383
- const bar = this.svg.querySelector(`rect.mini-chart-bar[data-bar-index="${index}"]`);
384
- if (bar) {
385
- bar.style.opacity = "0.7";
386
- }
387
- }
388
- unhighlightBars() {
389
- if (!this.svg) return;
390
- const bars = this.svg.querySelectorAll("rect.mini-chart-bar");
391
- bars.forEach((bar) => {
392
- bar.style.opacity = "1";
393
- });
394
- }
395
- // Public API
396
- setData(data) {
397
- this.data = data;
398
- if (this.svg) {
399
- this.renderChart();
400
- }
401
- }
402
- setColor(color) {
403
- this.color = color;
404
- if (this.svg) {
405
- this.renderChart();
406
- }
407
- }
408
- setType(type) {
409
- if (["line", "bar"].includes(type)) {
410
- this.chartType = type;
411
- if (this.svg) {
412
- this.renderChart();
413
- }
414
- }
415
- }
416
- resize(width, height) {
417
- this.width = width;
418
- this.height = height;
419
- this.updateDimensions();
420
- if (this.svg) {
421
- this.renderChart();
422
- }
423
- }
424
- async onBeforeDestroy() {
425
- if (this.resizeObserver) {
426
- this.resizeObserver.disconnect();
427
- this.resizeObserver = null;
428
- }
429
- await super.onBeforeDestroy();
430
- }
431
- }
432
- class MetricsMiniChart extends MiniChart {
433
- constructor(options = {}) {
434
- super(options);
435
- this.endpoint = options.endpoint || "/api/metrics/fetch";
436
- this.account = options.account || "global";
437
- this.granularity = options.granularity || "hours";
438
- this.slugs = options.slugs || null;
439
- this.category = options.category || null;
440
- this.dateStart = options.dateStart || null;
441
- this.dateEnd = options.dateEnd || null;
442
- this.defaultDateRange = options.defaultDateRange || "24h";
443
- this.isLoading = false;
444
- this.lastFetch = null;
445
- this.refreshInterval = options.refreshInterval;
446
- if (!this.dateStart || !this.dateEnd) {
447
- this.setQuickRange(this.defaultDateRange);
448
- }
449
- if (this.slugs && !Array.isArray(this.slugs)) {
450
- this.slugs = [this.slugs];
451
- }
452
- }
453
- async onAfterRender() {
454
- await super.onAfterRender();
455
- if (this.endpoint && (!this.data || this.data.length === 0)) {
456
- await this.fetchData();
457
- }
458
- if (this.refreshInterval && this.endpoint) {
459
- this.startAutoRefresh();
460
- }
461
- }
462
- buildApiParams() {
463
- const params = {
464
- granularity: this.granularity,
465
- account: this.account,
466
- with_labels: true
467
- };
468
- if (this.slugs && this.slugs.length > 0) {
469
- this.slugs.forEach((slug) => {
470
- if (!params["slugs[]"]) params["slugs[]"] = [];
471
- params["slugs[]"].push(slug);
472
- });
473
- }
474
- if (this.category) {
475
- params.category = this.category;
476
- }
477
- if (this.dateStart) {
478
- params.dr_start = Math.floor(this.dateStart.getTime() / 1e3);
479
- }
480
- if (this.dateEnd) {
481
- params.dr_end = Math.floor(this.dateEnd.getTime() / 1e3);
482
- }
483
- params._ = Date.now();
484
- return params;
485
- }
486
- async fetchData() {
487
- if (!this.endpoint) return;
488
- this.isLoading = true;
489
- try {
490
- const rest = this.getApp()?.rest;
491
- if (!rest) {
492
- throw new Error("No REST client available");
493
- }
494
- const params = this.buildApiParams();
495
- const response = await rest.GET(this.endpoint, params);
496
- if (!response.success) {
497
- throw new Error(response.message || "Network error");
498
- }
499
- if (!response.data?.status) {
500
- throw new Error(response.data?.error || "Server error");
501
- }
502
- const metricsData = response.data.data;
503
- this.processMetricsData(metricsData);
504
- this.lastFetch = /* @__PURE__ */ new Date();
505
- await this.render();
506
- this.emit("metrics:loaded", { chart: this, data: metricsData, params });
507
- } catch (error) {
508
- console.error("Failed to fetch metrics:", error);
509
- this.emit("metrics:error", { chart: this, error });
510
- } finally {
511
- this.isLoading = false;
512
- }
513
- }
514
- processMetricsData(metricsData) {
515
- const { data: metrics, labels } = metricsData;
516
- if (!metrics) return;
517
- const metricKeys = Object.keys(metrics);
518
- if (metricKeys.length === 0) return;
519
- const metricSlug = metricKeys[0];
520
- const values = metrics[metricSlug];
521
- const sanitizedValues = values.map((val) => {
522
- if (val === null || val === void 0 || val === "") return 0;
523
- return typeof val === "number" ? val : parseFloat(val) || 0;
524
- });
525
- this.labels = labels || null;
526
- this.setData(sanitizedValues);
527
- }
528
- setQuickRange(range) {
529
- const now = /* @__PURE__ */ new Date();
530
- let startDate;
531
- switch (range) {
532
- case "1h":
533
- startDate = new Date(now.getTime() - 60 * 60 * 1e3);
534
- break;
535
- case "24h":
536
- startDate = new Date(now.getTime() - 24 * 60 * 60 * 1e3);
537
- break;
538
- case "7d":
539
- startDate = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1e3);
540
- break;
541
- case "30d":
542
- startDate = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1e3);
543
- break;
544
- default:
545
- startDate = new Date(now.getTime() - 24 * 60 * 60 * 1e3);
546
- }
547
- this.dateStart = startDate;
548
- this.dateEnd = now;
549
- }
550
- startAutoRefresh() {
551
- if (this.refreshTimer) {
552
- clearInterval(this.refreshTimer);
553
- }
554
- this.refreshTimer = setInterval(() => {
555
- this.fetchData();
556
- }, this.refreshInterval);
557
- }
558
- stopAutoRefresh() {
559
- if (this.refreshTimer) {
560
- clearInterval(this.refreshTimer);
561
- this.refreshTimer = null;
562
- }
563
- }
564
- // Public API
565
- setGranularity(granularity) {
566
- this.granularity = granularity;
567
- return this.fetchData();
568
- }
569
- setDateRange(startDate, endDate) {
570
- this.dateStart = new Date(startDate);
571
- this.dateEnd = new Date(endDate);
572
- return this.fetchData();
573
- }
574
- setMetrics(slugs) {
575
- this.slugs = Array.isArray(slugs) ? slugs : [slugs];
576
- return this.fetchData();
577
- }
578
- refresh() {
579
- return this.fetchData();
580
- }
581
- async onBeforeDestroy() {
582
- this.stopAutoRefresh();
583
- await super.onBeforeDestroy();
584
- }
585
- }
1
+ import { B, M, b, c, a, P, S } from "./chunks/MetricsMiniChartWidget-0QE0WL-x.js";
2
+ import { B as B2, b as b2, a as a2, c as c2, e, f, W } from "./chunks/WebApp-BWnjZ-UU.js";
586
3
  export {
587
4
  B2 as BUILD_TIME,
588
5
  B as BaseChart,
589
6
  M as MetricsChart,
590
- MetricsMiniChart,
591
- MiniChart,
7
+ b as MetricsMiniChart,
8
+ c as MetricsMiniChartWidget,
9
+ a as MiniChart,
592
10
  P as PieChart,
593
11
  S as SeriesChart,
594
- b as VERSION,
595
- a as VERSION_INFO,
596
- c as VERSION_MAJOR,
12
+ b2 as VERSION,
13
+ a2 as VERSION_INFO,
14
+ c2 as VERSION_MAJOR,
597
15
  e as VERSION_MINOR,
598
16
  f as VERSION_REVISION,
599
17
  W as WebApp