andoncloud-prometheus-widget 1.3.13 → 1.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { registerTranslations } from "andoncloud-sdk";
2
- import { useEffect, useRef, useState } from "react";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
3
  import { generateTimeRange, getCurrentShift, getRecentShift, normalizeShifts, useGqlClients } from "andoncloud-dashboard-toolkit";
4
4
  import { BaseWidget } from "andoncloud-widget-base";
5
5
  import { useTranslation } from "react-i18next";
@@ -8,18 +8,16 @@ import { TabContext, TabList, TabPanel } from "@mui/lab";
8
8
  import { Box, Button, FormControl, FormHelperText, IconButton, InputLabel, MenuItem, Select, Stack, Tab, TextField } from "@mui/material";
9
9
  import { getIn } from "formik";
10
10
  import { jsx, jsxs } from "react/jsx-runtime";
11
- import { Chart } from "react-chartjs-2";
12
- import { CategoryScale, Chart as Chart$1, Filler, Legend, LineElement, LinearScale, PointElement, TimeScale, Tooltip } from "chart.js";
11
+ import { Line } from "react-chartjs-2";
12
+ import { CategoryScale, Chart, Filler, Legend, LineElement, LinearScale, PointElement, TimeScale, Tooltip } from "chart.js";
13
13
  import "chartjs-adapter-dayjs-4";
14
+ import { PrometheusDriver } from "prometheus-query";
14
15
  import dayjs from "dayjs";
15
16
  import pick from "lodash.pick";
16
17
  import Color from "color";
17
18
  import { satisfies } from "compare-versions";
18
19
  import * as yup from "yup";
19
20
  import i18n from "i18next";
20
- //#region \0rolldown/runtime.js
21
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
22
- //#endregion
23
21
  //#region src/locales/en/translation.json
24
22
  var translation_default$1 = { prometheusWidget: {
25
23
  "addAnotherDisplayedQueryParameter": "Add another displayed query parameter",
@@ -76,7 +74,7 @@ const resources = {
76
74
  };
77
75
  //#endregion
78
76
  //#region src/version.ts
79
- const LIBRARY_VERSION = "1.3.13";
77
+ const LIBRARY_VERSION = "1.3.14";
80
78
  //#endregion
81
79
  //#region src/types.ts
82
80
  let QueriesPeriod = /* @__PURE__ */ function(QueriesPeriod) {
@@ -320,2151 +318,6 @@ const SettingsFormContent = ({ formProps }) => {
320
318
  });
321
319
  };
322
320
  //#endregion
323
- //#region node_modules/prometheus-query/dist/prometheus-query.umd.js
324
- var require_prometheus_query_umd = /* @__PURE__ */ __commonJSMin(((exports, module) => {
325
- /*!
326
- * prometheus-query v3.5.1
327
- * github.com/samber/prometheus-query-js
328
- * (c) 2025 prometheus-query-js Contributors
329
- * Released under the MIT License
330
- */
331
- (function(e, t) {
332
- "object" == typeof exports && "undefined" != typeof module ? t(exports) : "function" == typeof define && define.amd ? define(["exports"], t) : t((e = "undefined" != typeof globalThis ? globalThis : e || self).Prometheus = {});
333
- })(exports, (function(e) {
334
- "use strict";
335
- function t(e, t) {
336
- return function() {
337
- return e.apply(t, arguments);
338
- };
339
- }
340
- const { toString: r } = Object.prototype, { getPrototypeOf: n } = Object, { iterator: o, toStringTag: s } = Symbol, i = (a = Object.create(null), (e) => {
341
- const t = r.call(e);
342
- return a[t] || (a[t] = t.slice(8, -1).toLowerCase());
343
- });
344
- var a;
345
- const c = (e) => (e = e.toLowerCase(), (t) => i(t) === e), l = (e) => (t) => typeof t === e, { isArray: u } = Array, f = l("undefined");
346
- function d(e) {
347
- return null !== e && !f(e) && null !== e.constructor && !f(e.constructor) && m(e.constructor.isBuffer) && e.constructor.isBuffer(e);
348
- }
349
- const h = c("ArrayBuffer");
350
- const p = l("string"), m = l("function"), y = l("number"), b = (e) => null !== e && "object" == typeof e, g = (e) => {
351
- if ("object" !== i(e)) return !1;
352
- const t = n(e);
353
- return !(null !== t && t !== Object.prototype && null !== Object.getPrototypeOf(t) || s in e || o in e);
354
- }, w = c("Date"), E = c("File"), O = c("Blob"), T = c("FileList"), S = c("URLSearchParams"), [R, v, A, x] = [
355
- "ReadableStream",
356
- "Request",
357
- "Response",
358
- "Headers"
359
- ].map(c);
360
- function N(e, t, { allOwnKeys: r = !1 } = {}) {
361
- if (null == e) return;
362
- let n, o;
363
- if ("object" != typeof e && (e = [e]), u(e)) for (n = 0, o = e.length; n < o; n++) t.call(null, e[n], n, e);
364
- else {
365
- if (d(e)) return;
366
- const o = r ? Object.getOwnPropertyNames(e) : Object.keys(e), s = o.length;
367
- let i;
368
- for (n = 0; n < s; n++) i = o[n], t.call(null, e[i], i, e);
369
- }
370
- }
371
- function P(e, t) {
372
- if (d(e)) return null;
373
- t = t.toLowerCase();
374
- const r = Object.keys(e);
375
- let n, o = r.length;
376
- for (; o-- > 0;) if (n = r[o], t === n.toLowerCase()) return n;
377
- return null;
378
- }
379
- const j = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : "undefined" != typeof window ? window : global, C = (e) => !f(e) && e !== j;
380
- const U = (_ = "undefined" != typeof Uint8Array && n(Uint8Array), (e) => _ && e instanceof _);
381
- var _;
382
- const L = c("HTMLFormElement"), F = (({ hasOwnProperty: e }) => (t, r) => e.call(t, r))(Object.prototype), q = c("RegExp"), k = (e, t) => {
383
- const r = Object.getOwnPropertyDescriptors(e), n = {};
384
- N(r, ((r, o) => {
385
- let s;
386
- !1 !== (s = t(r, o, e)) && (n[o] = s || r);
387
- })), Object.defineProperties(e, n);
388
- };
389
- const D = c("AsyncFunction"), B = (I = "function" == typeof setImmediate, J = m(j.postMessage), I ? setImmediate : J ? (M = `axios@${Math.random()}`, G = [], j.addEventListener("message", (({ source: e, data: t }) => {
390
- e === j && t === M && G.length && G.shift()();
391
- }), !1), (e) => {
392
- G.push(e), j.postMessage(M, "*");
393
- }) : (e) => setTimeout(e));
394
- var I, J, M, G;
395
- var $ = {
396
- isArray: u,
397
- isArrayBuffer: h,
398
- isBuffer: d,
399
- isFormData: (e) => {
400
- let t;
401
- return e && ("function" == typeof FormData && e instanceof FormData || m(e.append) && ("formdata" === (t = i(e)) || "object" === t && m(e.toString) && "[object FormData]" === e.toString()));
402
- },
403
- isArrayBufferView: function(e) {
404
- let t;
405
- return t = "undefined" != typeof ArrayBuffer && ArrayBuffer.isView ? ArrayBuffer.isView(e) : e && e.buffer && h(e.buffer), t;
406
- },
407
- isString: p,
408
- isNumber: y,
409
- isBoolean: (e) => !0 === e || !1 === e,
410
- isObject: b,
411
- isPlainObject: g,
412
- isEmptyObject: (e) => {
413
- if (!b(e) || d(e)) return !1;
414
- try {
415
- return 0 === Object.keys(e).length && Object.getPrototypeOf(e) === Object.prototype;
416
- } catch (e) {
417
- return !1;
418
- }
419
- },
420
- isReadableStream: R,
421
- isRequest: v,
422
- isResponse: A,
423
- isHeaders: x,
424
- isUndefined: f,
425
- isDate: w,
426
- isFile: E,
427
- isBlob: O,
428
- isRegExp: q,
429
- isFunction: m,
430
- isStream: (e) => b(e) && m(e.pipe),
431
- isURLSearchParams: S,
432
- isTypedArray: U,
433
- isFileList: T,
434
- forEach: N,
435
- merge: function e() {
436
- const { caseless: t, skipUndefined: r } = C(this) && this || {}, n = {}, o = (o, s) => {
437
- const i = t && P(n, s) || s;
438
- g(n[i]) && g(o) ? n[i] = e(n[i], o) : g(o) ? n[i] = e({}, o) : u(o) ? n[i] = o.slice() : r && f(o) || (n[i] = o);
439
- };
440
- for (let e = 0, t = arguments.length; e < t; e++) arguments[e] && N(arguments[e], o);
441
- return n;
442
- },
443
- extend: (e, r, n, { allOwnKeys: o } = {}) => (N(r, ((r, o) => {
444
- n && m(r) ? e[o] = t(r, n) : e[o] = r;
445
- }), { allOwnKeys: o }), e),
446
- trim: (e) => e.trim ? e.trim() : e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""),
447
- stripBOM: (e) => (65279 === e.charCodeAt(0) && (e = e.slice(1)), e),
448
- inherits: (e, t, r, n) => {
449
- e.prototype = Object.create(t.prototype, n), e.prototype.constructor = e, Object.defineProperty(e, "super", { value: t.prototype }), r && Object.assign(e.prototype, r);
450
- },
451
- toFlatObject: (e, t, r, o) => {
452
- let s, i, a;
453
- const c = {};
454
- if (t = t || {}, null == e) return t;
455
- do {
456
- for (s = Object.getOwnPropertyNames(e), i = s.length; i-- > 0;) a = s[i], o && !o(a, e, t) || c[a] || (t[a] = e[a], c[a] = !0);
457
- e = !1 !== r && n(e);
458
- } while (e && (!r || r(e, t)) && e !== Object.prototype);
459
- return t;
460
- },
461
- kindOf: i,
462
- kindOfTest: c,
463
- endsWith: (e, t, r) => {
464
- e = String(e), (void 0 === r || r > e.length) && (r = e.length), r -= t.length;
465
- const n = e.indexOf(t, r);
466
- return -1 !== n && n === r;
467
- },
468
- toArray: (e) => {
469
- if (!e) return null;
470
- if (u(e)) return e;
471
- let t = e.length;
472
- if (!y(t)) return null;
473
- const r = new Array(t);
474
- for (; t-- > 0;) r[t] = e[t];
475
- return r;
476
- },
477
- forEachEntry: (e, t) => {
478
- const r = (e && e[o]).call(e);
479
- let n;
480
- for (; (n = r.next()) && !n.done;) {
481
- const r = n.value;
482
- t.call(e, r[0], r[1]);
483
- }
484
- },
485
- matchAll: (e, t) => {
486
- let r;
487
- const n = [];
488
- for (; null !== (r = e.exec(t));) n.push(r);
489
- return n;
490
- },
491
- isHTMLForm: L,
492
- hasOwnProperty: F,
493
- hasOwnProp: F,
494
- reduceDescriptors: k,
495
- freezeMethods: (e) => {
496
- k(e, ((t, r) => {
497
- if (m(e) && -1 !== [
498
- "arguments",
499
- "caller",
500
- "callee"
501
- ].indexOf(r)) return !1;
502
- const n = e[r];
503
- m(n) && (t.enumerable = !1, "writable" in t ? t.writable = !1 : t.set || (t.set = () => {
504
- throw Error("Can not rewrite read-only method '" + r + "'");
505
- }));
506
- }));
507
- },
508
- toObjectSet: (e, t) => {
509
- const r = {}, n = (e) => {
510
- e.forEach(((e) => {
511
- r[e] = !0;
512
- }));
513
- };
514
- return u(e) ? n(e) : n(String(e).split(t)), r;
515
- },
516
- toCamelCase: (e) => e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, (function(e, t, r) {
517
- return t.toUpperCase() + r;
518
- })),
519
- noop: () => {},
520
- toFiniteNumber: (e, t) => null != e && Number.isFinite(e = +e) ? e : t,
521
- findKey: P,
522
- global: j,
523
- isContextDefined: C,
524
- isSpecCompliantForm: function(e) {
525
- return !!(e && m(e.append) && "FormData" === e[s] && e[o]);
526
- },
527
- toJSONObject: (e) => {
528
- const t = new Array(10), r = (e, n) => {
529
- if (b(e)) {
530
- if (t.indexOf(e) >= 0) return;
531
- if (d(e)) return e;
532
- if (!("toJSON" in e)) {
533
- t[n] = e;
534
- const o = u(e) ? [] : {};
535
- return N(e, ((e, t) => {
536
- const s = r(e, n + 1);
537
- !f(s) && (o[t] = s);
538
- })), t[n] = void 0, o;
539
- }
540
- }
541
- return e;
542
- };
543
- return r(e, 0);
544
- },
545
- isAsyncFn: D,
546
- isThenable: (e) => e && (b(e) || m(e)) && m(e.then) && m(e.catch),
547
- setImmediate: B,
548
- asap: "undefined" != typeof queueMicrotask ? queueMicrotask.bind(j) : "undefined" != typeof process && process.nextTick || B,
549
- isIterable: (e) => null != e && m(e[o])
550
- };
551
- function H(e, t, r, n, o) {
552
- Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = (/* @__PURE__ */ new Error()).stack, this.message = e, this.name = "AxiosError", t && (this.code = t), r && (this.config = r), n && (this.request = n), o && (this.response = o, this.status = o.status ? o.status : null);
553
- }
554
- $.inherits(H, Error, { toJSON: function() {
555
- return {
556
- message: this.message,
557
- name: this.name,
558
- description: this.description,
559
- number: this.number,
560
- fileName: this.fileName,
561
- lineNumber: this.lineNumber,
562
- columnNumber: this.columnNumber,
563
- stack: this.stack,
564
- config: $.toJSONObject(this.config),
565
- code: this.code,
566
- status: this.status
567
- };
568
- } });
569
- const W = H.prototype, V = {};
570
- [
571
- "ERR_BAD_OPTION_VALUE",
572
- "ERR_BAD_OPTION",
573
- "ECONNABORTED",
574
- "ETIMEDOUT",
575
- "ERR_NETWORK",
576
- "ERR_FR_TOO_MANY_REDIRECTS",
577
- "ERR_DEPRECATED",
578
- "ERR_BAD_RESPONSE",
579
- "ERR_BAD_REQUEST",
580
- "ERR_CANCELED",
581
- "ERR_NOT_SUPPORT",
582
- "ERR_INVALID_URL"
583
- ].forEach(((e) => {
584
- V[e] = { value: e };
585
- })), Object.defineProperties(H, V), Object.defineProperty(W, "isAxiosError", { value: !0 }), H.from = (e, t, r, n, o, s) => {
586
- const i = Object.create(W);
587
- $.toFlatObject(e, i, (function(e) {
588
- return e !== Error.prototype;
589
- }), ((e) => "isAxiosError" !== e));
590
- const a = e && e.message ? e.message : "Error", c = null == t && e ? e.code : t;
591
- return H.call(i, a, c, r, n, o), e && null == i.cause && Object.defineProperty(i, "cause", {
592
- value: e,
593
- configurable: !0
594
- }), i.name = e && e.name || "Error", s && Object.assign(i, s), i;
595
- };
596
- function K(e) {
597
- return $.isPlainObject(e) || $.isArray(e);
598
- }
599
- function X(e) {
600
- return $.endsWith(e, "[]") ? e.slice(0, -2) : e;
601
- }
602
- function Q(e, t, r) {
603
- return e ? e.concat(t).map((function(e, t) {
604
- return e = X(e), !r && t ? "[" + e + "]" : e;
605
- })).join(r ? "." : "") : t;
606
- }
607
- const Z = $.toFlatObject($, {}, null, (function(e) {
608
- return /^is[A-Z]/.test(e);
609
- }));
610
- function Y(e, t, r) {
611
- if (!$.isObject(e)) throw new TypeError("target must be an object");
612
- t = t || new FormData();
613
- const n = (r = $.toFlatObject(r, {
614
- metaTokens: !0,
615
- dots: !1,
616
- indexes: !1
617
- }, !1, (function(e, t) {
618
- return !$.isUndefined(t[e]);
619
- }))).metaTokens, o = r.visitor || l, s = r.dots, i = r.indexes, a = (r.Blob || "undefined" != typeof Blob && Blob) && $.isSpecCompliantForm(t);
620
- if (!$.isFunction(o)) throw new TypeError("visitor must be a function");
621
- function c(e) {
622
- if (null === e) return "";
623
- if ($.isDate(e)) return e.toISOString();
624
- if ($.isBoolean(e)) return e.toString();
625
- if (!a && $.isBlob(e)) throw new H("Blob is not supported. Use a Buffer instead.");
626
- return $.isArrayBuffer(e) || $.isTypedArray(e) ? a && "function" == typeof Blob ? new Blob([e]) : Buffer.from(e) : e;
627
- }
628
- function l(e, r, o) {
629
- let a = e;
630
- if (e && !o && "object" == typeof e) {
631
- if ($.endsWith(r, "{}")) r = n ? r : r.slice(0, -2), e = JSON.stringify(e);
632
- else if ($.isArray(e) && function(e) {
633
- return $.isArray(e) && !e.some(K);
634
- }(e) || ($.isFileList(e) || $.endsWith(r, "[]")) && (a = $.toArray(e))) return r = X(r), a.forEach((function(e, n) {
635
- !$.isUndefined(e) && null !== e && t.append(!0 === i ? Q([r], n, s) : null === i ? r : r + "[]", c(e));
636
- })), !1;
637
- }
638
- return !!K(e) || (t.append(Q(o, r, s), c(e)), !1);
639
- }
640
- const u = [], f = Object.assign(Z, {
641
- defaultVisitor: l,
642
- convertValue: c,
643
- isVisitable: K
644
- });
645
- if (!$.isObject(e)) throw new TypeError("data must be an object");
646
- return function e(r, n) {
647
- if (!$.isUndefined(r)) {
648
- if (-1 !== u.indexOf(r)) throw Error("Circular reference detected in " + n.join("."));
649
- u.push(r), $.forEach(r, (function(r, s) {
650
- !0 === (!($.isUndefined(r) || null === r) && o.call(t, r, $.isString(s) ? s.trim() : s, n, f)) && e(r, n ? n.concat(s) : [s]);
651
- })), u.pop();
652
- }
653
- }(e), t;
654
- }
655
- function ee(e) {
656
- const t = {
657
- "!": "%21",
658
- "'": "%27",
659
- "(": "%28",
660
- ")": "%29",
661
- "~": "%7E",
662
- "%20": "+",
663
- "%00": "\0"
664
- };
665
- return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g, (function(e) {
666
- return t[e];
667
- }));
668
- }
669
- function te(e, t) {
670
- this._pairs = [], e && Y(e, this, t);
671
- }
672
- const re = te.prototype;
673
- function ne(e) {
674
- return encodeURIComponent(e).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+");
675
- }
676
- function oe(e, t, r) {
677
- if (!t) return e;
678
- const n = r && r.encode || ne;
679
- $.isFunction(r) && (r = { serialize: r });
680
- const o = r && r.serialize;
681
- let s;
682
- if (s = o ? o(t, r) : $.isURLSearchParams(t) ? t.toString() : new te(t, r).toString(n), s) {
683
- const t = e.indexOf("#");
684
- -1 !== t && (e = e.slice(0, t)), e += (-1 === e.indexOf("?") ? "?" : "&") + s;
685
- }
686
- return e;
687
- }
688
- re.append = function(e, t) {
689
- this._pairs.push([e, t]);
690
- }, re.toString = function(e) {
691
- const t = e ? function(t) {
692
- return e.call(this, t, ee);
693
- } : ee;
694
- return this._pairs.map((function(e) {
695
- return t(e[0]) + "=" + t(e[1]);
696
- }), "").join("&");
697
- };
698
- class se {
699
- constructor() {
700
- this.handlers = [];
701
- }
702
- use(e, t, r) {
703
- return this.handlers.push({
704
- fulfilled: e,
705
- rejected: t,
706
- synchronous: !!r && r.synchronous,
707
- runWhen: r ? r.runWhen : null
708
- }), this.handlers.length - 1;
709
- }
710
- eject(e) {
711
- this.handlers[e] && (this.handlers[e] = null);
712
- }
713
- clear() {
714
- this.handlers && (this.handlers = []);
715
- }
716
- forEach(e) {
717
- $.forEach(this.handlers, (function(t) {
718
- null !== t && e(t);
719
- }));
720
- }
721
- }
722
- var ie = {
723
- silentJSONParsing: !0,
724
- forcedJSONParsing: !0,
725
- clarifyTimeoutError: !1
726
- }, ae = {
727
- isBrowser: !0,
728
- classes: {
729
- URLSearchParams: "undefined" != typeof URLSearchParams ? URLSearchParams : te,
730
- FormData: "undefined" != typeof FormData ? FormData : null,
731
- Blob: "undefined" != typeof Blob ? Blob : null
732
- },
733
- protocols: [
734
- "http",
735
- "https",
736
- "file",
737
- "blob",
738
- "url",
739
- "data"
740
- ]
741
- };
742
- const ce = "undefined" != typeof window && "undefined" != typeof document, le = "object" == typeof navigator && navigator || void 0, ue = ce && (!le || [
743
- "ReactNative",
744
- "NativeScript",
745
- "NS"
746
- ].indexOf(le.product) < 0), fe = "undefined" != typeof WorkerGlobalScope && self instanceof WorkerGlobalScope && "function" == typeof self.importScripts, de = ce && window.location.href || "http://localhost";
747
- var he = {
748
- ...Object.freeze({
749
- __proto__: null,
750
- hasBrowserEnv: ce,
751
- hasStandardBrowserEnv: ue,
752
- hasStandardBrowserWebWorkerEnv: fe,
753
- navigator: le,
754
- origin: de
755
- }),
756
- ...ae
757
- };
758
- function pe(e) {
759
- function t(e, r, n, o) {
760
- let s = e[o++];
761
- if ("__proto__" === s) return !0;
762
- const i = Number.isFinite(+s), a = o >= e.length;
763
- if (s = !s && $.isArray(n) ? n.length : s, a) return $.hasOwnProp(n, s) ? n[s] = [n[s], r] : n[s] = r, !i;
764
- n[s] && $.isObject(n[s]) || (n[s] = []);
765
- return t(e, r, n[s], o) && $.isArray(n[s]) && (n[s] = function(e) {
766
- const t = {}, r = Object.keys(e);
767
- let n;
768
- const o = r.length;
769
- let s;
770
- for (n = 0; n < o; n++) s = r[n], t[s] = e[s];
771
- return t;
772
- }(n[s])), !i;
773
- }
774
- if ($.isFormData(e) && $.isFunction(e.entries)) {
775
- const r = {};
776
- return $.forEachEntry(e, ((e, n) => {
777
- t(function(e) {
778
- return $.matchAll(/\w+|\[(\w*)]/g, e).map(((e) => "[]" === e[0] ? "" : e[1] || e[0]));
779
- }(e), n, r, 0);
780
- })), r;
781
- }
782
- return null;
783
- }
784
- const me = {
785
- transitional: ie,
786
- adapter: [
787
- "xhr",
788
- "http",
789
- "fetch"
790
- ],
791
- transformRequest: [function(e, t) {
792
- const r = t.getContentType() || "", n = r.indexOf("application/json") > -1, o = $.isObject(e);
793
- o && $.isHTMLForm(e) && (e = new FormData(e));
794
- if ($.isFormData(e)) return n ? JSON.stringify(pe(e)) : e;
795
- if ($.isArrayBuffer(e) || $.isBuffer(e) || $.isStream(e) || $.isFile(e) || $.isBlob(e) || $.isReadableStream(e)) return e;
796
- if ($.isArrayBufferView(e)) return e.buffer;
797
- if ($.isURLSearchParams(e)) return t.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), e.toString();
798
- let s;
799
- if (o) {
800
- if (r.indexOf("application/x-www-form-urlencoded") > -1) return function(e, t) {
801
- return Y(e, new he.classes.URLSearchParams(), {
802
- visitor: function(e, t, r, n) {
803
- return he.isNode && $.isBuffer(e) ? (this.append(t, e.toString("base64")), !1) : n.defaultVisitor.apply(this, arguments);
804
- },
805
- ...t
806
- });
807
- }(e, this.formSerializer).toString();
808
- if ((s = $.isFileList(e)) || r.indexOf("multipart/form-data") > -1) {
809
- const t = this.env && this.env.FormData;
810
- return Y(s ? { "files[]": e } : e, t && new t(), this.formSerializer);
811
- }
812
- }
813
- return o || n ? (t.setContentType("application/json", !1), function(e, t, r) {
814
- if ($.isString(e)) try {
815
- return (t || JSON.parse)(e), $.trim(e);
816
- } catch (e) {
817
- if ("SyntaxError" !== e.name) throw e;
818
- }
819
- return (r || JSON.stringify)(e);
820
- }(e)) : e;
821
- }],
822
- transformResponse: [function(e) {
823
- const t = this.transitional || me.transitional, r = t && t.forcedJSONParsing, n = "json" === this.responseType;
824
- if ($.isResponse(e) || $.isReadableStream(e)) return e;
825
- if (e && $.isString(e) && (r && !this.responseType || n)) {
826
- const r = !(t && t.silentJSONParsing) && n;
827
- try {
828
- return JSON.parse(e, this.parseReviver);
829
- } catch (e) {
830
- if (r) {
831
- if ("SyntaxError" === e.name) throw H.from(e, H.ERR_BAD_RESPONSE, this, null, this.response);
832
- throw e;
833
- }
834
- }
835
- }
836
- return e;
837
- }],
838
- timeout: 0,
839
- xsrfCookieName: "XSRF-TOKEN",
840
- xsrfHeaderName: "X-XSRF-TOKEN",
841
- maxContentLength: -1,
842
- maxBodyLength: -1,
843
- env: {
844
- FormData: he.classes.FormData,
845
- Blob: he.classes.Blob
846
- },
847
- validateStatus: function(e) {
848
- return e >= 200 && e < 300;
849
- },
850
- headers: { common: {
851
- Accept: "application/json, text/plain, */*",
852
- "Content-Type": void 0
853
- } }
854
- };
855
- $.forEach([
856
- "delete",
857
- "get",
858
- "head",
859
- "post",
860
- "put",
861
- "patch"
862
- ], ((e) => {
863
- me.headers[e] = {};
864
- }));
865
- const ye = $.toObjectSet([
866
- "age",
867
- "authorization",
868
- "content-length",
869
- "content-type",
870
- "etag",
871
- "expires",
872
- "from",
873
- "host",
874
- "if-modified-since",
875
- "if-unmodified-since",
876
- "last-modified",
877
- "location",
878
- "max-forwards",
879
- "proxy-authorization",
880
- "referer",
881
- "retry-after",
882
- "user-agent"
883
- ]);
884
- const be = Symbol("internals");
885
- function ge(e) {
886
- return e && String(e).trim().toLowerCase();
887
- }
888
- function we(e) {
889
- return !1 === e || null == e ? e : $.isArray(e) ? e.map(we) : String(e);
890
- }
891
- function Ee(e, t, r, n, o) {
892
- return $.isFunction(n) ? n.call(this, t, r) : (o && (t = r), $.isString(t) ? $.isString(n) ? -1 !== t.indexOf(n) : $.isRegExp(n) ? n.test(t) : void 0 : void 0);
893
- }
894
- let Oe = class {
895
- constructor(e) {
896
- e && this.set(e);
897
- }
898
- set(e, t, r) {
899
- const n = this;
900
- function o(e, t, r) {
901
- const o = ge(t);
902
- if (!o) throw new Error("header name must be a non-empty string");
903
- const s = $.findKey(n, o);
904
- (!s || void 0 === n[s] || !0 === r || void 0 === r && !1 !== n[s]) && (n[s || t] = we(e));
905
- }
906
- const s = (e, t) => $.forEach(e, ((e, r) => o(e, r, t)));
907
- if ($.isPlainObject(e) || e instanceof this.constructor) s(e, t);
908
- else if ($.isString(e) && (e = e.trim()) && !/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())) s(((e) => {
909
- const t = {};
910
- let r, n, o;
911
- return e && e.split("\n").forEach((function(e) {
912
- o = e.indexOf(":"), r = e.substring(0, o).trim().toLowerCase(), n = e.substring(o + 1).trim(), !r || t[r] && ye[r] || ("set-cookie" === r ? t[r] ? t[r].push(n) : t[r] = [n] : t[r] = t[r] ? t[r] + ", " + n : n);
913
- })), t;
914
- })(e), t);
915
- else if ($.isObject(e) && $.isIterable(e)) {
916
- let r, n, o = {};
917
- for (const t of e) {
918
- if (!$.isArray(t)) throw TypeError("Object iterator must return a key-value pair");
919
- o[n = t[0]] = (r = o[n]) ? $.isArray(r) ? [...r, t[1]] : [r, t[1]] : t[1];
920
- }
921
- s(o, t);
922
- } else null != e && o(t, e, r);
923
- return this;
924
- }
925
- get(e, t) {
926
- if (e = ge(e)) {
927
- const r = $.findKey(this, e);
928
- if (r) {
929
- const e = this[r];
930
- if (!t) return e;
931
- if (!0 === t) return function(e) {
932
- const t = Object.create(null), r = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
933
- let n;
934
- for (; n = r.exec(e);) t[n[1]] = n[2];
935
- return t;
936
- }(e);
937
- if ($.isFunction(t)) return t.call(this, e, r);
938
- if ($.isRegExp(t)) return t.exec(e);
939
- throw new TypeError("parser must be boolean|regexp|function");
940
- }
941
- }
942
- }
943
- has(e, t) {
944
- if (e = ge(e)) {
945
- const r = $.findKey(this, e);
946
- return !(!r || void 0 === this[r] || t && !Ee(0, this[r], r, t));
947
- }
948
- return !1;
949
- }
950
- delete(e, t) {
951
- const r = this;
952
- let n = !1;
953
- function o(e) {
954
- if (e = ge(e)) {
955
- const o = $.findKey(r, e);
956
- !o || t && !Ee(0, r[o], o, t) || (delete r[o], n = !0);
957
- }
958
- }
959
- return $.isArray(e) ? e.forEach(o) : o(e), n;
960
- }
961
- clear(e) {
962
- const t = Object.keys(this);
963
- let r = t.length, n = !1;
964
- for (; r--;) {
965
- const o = t[r];
966
- e && !Ee(0, this[o], o, e, !0) || (delete this[o], n = !0);
967
- }
968
- return n;
969
- }
970
- normalize(e) {
971
- const t = this, r = {};
972
- return $.forEach(this, ((n, o) => {
973
- const s = $.findKey(r, o);
974
- if (s) return t[s] = we(n), void delete t[o];
975
- const i = e ? function(e) {
976
- return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, ((e, t, r) => t.toUpperCase() + r));
977
- }(o) : String(o).trim();
978
- i !== o && delete t[o], t[i] = we(n), r[i] = !0;
979
- })), this;
980
- }
981
- concat(...e) {
982
- return this.constructor.concat(this, ...e);
983
- }
984
- toJSON(e) {
985
- const t = Object.create(null);
986
- return $.forEach(this, ((r, n) => {
987
- null != r && !1 !== r && (t[n] = e && $.isArray(r) ? r.join(", ") : r);
988
- })), t;
989
- }
990
- [Symbol.iterator]() {
991
- return Object.entries(this.toJSON())[Symbol.iterator]();
992
- }
993
- toString() {
994
- return Object.entries(this.toJSON()).map((([e, t]) => e + ": " + t)).join("\n");
995
- }
996
- getSetCookie() {
997
- return this.get("set-cookie") || [];
998
- }
999
- get [Symbol.toStringTag]() {
1000
- return "AxiosHeaders";
1001
- }
1002
- static from(e) {
1003
- return e instanceof this ? e : new this(e);
1004
- }
1005
- static concat(e, ...t) {
1006
- const r = new this(e);
1007
- return t.forEach(((e) => r.set(e))), r;
1008
- }
1009
- static accessor(e) {
1010
- const t = (this[be] = this[be] = { accessors: {} }).accessors, r = this.prototype;
1011
- function n(e) {
1012
- const n = ge(e);
1013
- t[n] || (function(e, t) {
1014
- const r = $.toCamelCase(" " + t);
1015
- [
1016
- "get",
1017
- "set",
1018
- "has"
1019
- ].forEach(((n) => {
1020
- Object.defineProperty(e, n + r, {
1021
- value: function(e, r, o) {
1022
- return this[n].call(this, t, e, r, o);
1023
- },
1024
- configurable: !0
1025
- });
1026
- }));
1027
- }(r, e), t[n] = !0);
1028
- }
1029
- return $.isArray(e) ? e.forEach(n) : n(e), this;
1030
- }
1031
- };
1032
- function Te(e, t) {
1033
- const r = this || me, n = t || r, o = Oe.from(n.headers);
1034
- let s = n.data;
1035
- return $.forEach(e, (function(e) {
1036
- s = e.call(r, s, o.normalize(), t ? t.status : void 0);
1037
- })), o.normalize(), s;
1038
- }
1039
- function Se(e) {
1040
- return !(!e || !e.__CANCEL__);
1041
- }
1042
- function Re(e, t, r) {
1043
- H.call(this, null == e ? "canceled" : e, H.ERR_CANCELED, t, r), this.name = "CanceledError";
1044
- }
1045
- function ve(e, t, r) {
1046
- const n = r.config.validateStatus;
1047
- r.status && n && !n(r.status) ? t(new H("Request failed with status code " + r.status, [H.ERR_BAD_REQUEST, H.ERR_BAD_RESPONSE][Math.floor(r.status / 100) - 4], r.config, r.request, r)) : e(r);
1048
- }
1049
- Oe.accessor([
1050
- "Content-Type",
1051
- "Content-Length",
1052
- "Accept",
1053
- "Accept-Encoding",
1054
- "User-Agent",
1055
- "Authorization"
1056
- ]), $.reduceDescriptors(Oe.prototype, (({ value: e }, t) => {
1057
- let r = t[0].toUpperCase() + t.slice(1);
1058
- return {
1059
- get: () => e,
1060
- set(e) {
1061
- this[r] = e;
1062
- }
1063
- };
1064
- })), $.freezeMethods(Oe), $.inherits(Re, H, { __CANCEL__: !0 });
1065
- const Ae = (e, t, r = 3) => {
1066
- let n = 0;
1067
- const o = function(e, t) {
1068
- e = e || 10;
1069
- const r = new Array(e), n = new Array(e);
1070
- let o, s = 0, i = 0;
1071
- return t = void 0 !== t ? t : 1e3, function(a) {
1072
- const c = Date.now(), l = n[i];
1073
- o || (o = c), r[s] = a, n[s] = c;
1074
- let u = i, f = 0;
1075
- for (; u !== s;) f += r[u++], u %= e;
1076
- if (s = (s + 1) % e, s === i && (i = (i + 1) % e), c - o < t) return;
1077
- const d = l && c - l;
1078
- return d ? Math.round(1e3 * f / d) : void 0;
1079
- };
1080
- }(50, 250);
1081
- return function(e, t) {
1082
- let r, n, o = 0, s = 1e3 / t;
1083
- const i = (t, s = Date.now()) => {
1084
- o = s, r = null, n && (clearTimeout(n), n = null), e(...t);
1085
- };
1086
- return [(...e) => {
1087
- const t = Date.now(), a = t - o;
1088
- a >= s ? i(e, t) : (r = e, n || (n = setTimeout((() => {
1089
- n = null, i(r);
1090
- }), s - a)));
1091
- }, () => r && i(r)];
1092
- }(((r) => {
1093
- const s = r.loaded, i = r.lengthComputable ? r.total : void 0, a = s - n, c = o(a);
1094
- n = s;
1095
- e({
1096
- loaded: s,
1097
- total: i,
1098
- progress: i ? s / i : void 0,
1099
- bytes: a,
1100
- rate: c || void 0,
1101
- estimated: c && i && s <= i ? (i - s) / c : void 0,
1102
- event: r,
1103
- lengthComputable: null != i,
1104
- [t ? "download" : "upload"]: !0
1105
- });
1106
- }), r);
1107
- }, xe = (e, t) => {
1108
- const r = null != e;
1109
- return [(n) => t[0]({
1110
- lengthComputable: r,
1111
- total: e,
1112
- loaded: n
1113
- }), t[1]];
1114
- }, Ne = (e) => (...t) => $.asap((() => e(...t)));
1115
- var Pe = he.hasStandardBrowserEnv ? ((e, t) => (r) => (r = new URL(r, he.origin), e.protocol === r.protocol && e.host === r.host && (t || e.port === r.port)))(new URL(he.origin), he.navigator && /(msie|trident)/i.test(he.navigator.userAgent)) : () => !0, je = he.hasStandardBrowserEnv ? {
1116
- write(e, t, r, n, o, s) {
1117
- const i = [e + "=" + encodeURIComponent(t)];
1118
- $.isNumber(r) && i.push("expires=" + new Date(r).toGMTString()), $.isString(n) && i.push("path=" + n), $.isString(o) && i.push("domain=" + o), !0 === s && i.push("secure"), document.cookie = i.join("; ");
1119
- },
1120
- read(e) {
1121
- const t = document.cookie.match(new RegExp("(^|;\\s*)(" + e + ")=([^;]*)"));
1122
- return t ? decodeURIComponent(t[3]) : null;
1123
- },
1124
- remove(e) {
1125
- this.write(e, "", Date.now() - 864e5);
1126
- }
1127
- } : {
1128
- write() {},
1129
- read: () => null,
1130
- remove() {}
1131
- };
1132
- function Ce(e, t, r) {
1133
- let n = !/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
1134
- return e && (n || 0 == r) ? function(e, t) {
1135
- return t ? e.replace(/\/?\/$/, "") + "/" + t.replace(/^\/+/, "") : e;
1136
- }(e, t) : t;
1137
- }
1138
- const Ue = (e) => e instanceof Oe ? { ...e } : e;
1139
- function _e(e, t) {
1140
- t = t || {};
1141
- const r = {};
1142
- function n(e, t, r, n) {
1143
- return $.isPlainObject(e) && $.isPlainObject(t) ? $.merge.call({ caseless: n }, e, t) : $.isPlainObject(t) ? $.merge({}, t) : $.isArray(t) ? t.slice() : t;
1144
- }
1145
- function o(e, t, r, o) {
1146
- return $.isUndefined(t) ? $.isUndefined(e) ? void 0 : n(void 0, e, 0, o) : n(e, t, 0, o);
1147
- }
1148
- function s(e, t) {
1149
- if (!$.isUndefined(t)) return n(void 0, t);
1150
- }
1151
- function i(e, t) {
1152
- return $.isUndefined(t) ? $.isUndefined(e) ? void 0 : n(void 0, e) : n(void 0, t);
1153
- }
1154
- function a(r, o, s) {
1155
- return s in t ? n(r, o) : s in e ? n(void 0, r) : void 0;
1156
- }
1157
- const c = {
1158
- url: s,
1159
- method: s,
1160
- data: s,
1161
- baseURL: i,
1162
- transformRequest: i,
1163
- transformResponse: i,
1164
- paramsSerializer: i,
1165
- timeout: i,
1166
- timeoutMessage: i,
1167
- withCredentials: i,
1168
- withXSRFToken: i,
1169
- adapter: i,
1170
- responseType: i,
1171
- xsrfCookieName: i,
1172
- xsrfHeaderName: i,
1173
- onUploadProgress: i,
1174
- onDownloadProgress: i,
1175
- decompress: i,
1176
- maxContentLength: i,
1177
- maxBodyLength: i,
1178
- beforeRedirect: i,
1179
- transport: i,
1180
- httpAgent: i,
1181
- httpsAgent: i,
1182
- cancelToken: i,
1183
- socketPath: i,
1184
- responseEncoding: i,
1185
- validateStatus: a,
1186
- headers: (e, t, r) => o(Ue(e), Ue(t), 0, !0)
1187
- };
1188
- return $.forEach(Object.keys({
1189
- ...e,
1190
- ...t
1191
- }), (function(n) {
1192
- const s = c[n] || o, i = s(e[n], t[n], n);
1193
- $.isUndefined(i) && s !== a || (r[n] = i);
1194
- })), r;
1195
- }
1196
- var Le = (e) => {
1197
- const t = _e({}, e);
1198
- let { data: r, withXSRFToken: n, xsrfHeaderName: o, xsrfCookieName: s, headers: i, auth: a } = t;
1199
- if (t.headers = i = Oe.from(i), t.url = oe(Ce(t.baseURL, t.url, t.allowAbsoluteUrls), e.params, e.paramsSerializer), a && i.set("Authorization", "Basic " + btoa((a.username || "") + ":" + (a.password ? unescape(encodeURIComponent(a.password)) : ""))), $.isFormData(r)) {
1200
- if (he.hasStandardBrowserEnv || he.hasStandardBrowserWebWorkerEnv) i.setContentType(void 0);
1201
- else if ($.isFunction(r.getHeaders)) {
1202
- const e = r.getHeaders(), t = ["content-type", "content-length"];
1203
- Object.entries(e).forEach((([e, r]) => {
1204
- t.includes(e.toLowerCase()) && i.set(e, r);
1205
- }));
1206
- }
1207
- }
1208
- if (he.hasStandardBrowserEnv && (n && $.isFunction(n) && (n = n(t)), n || !1 !== n && Pe(t.url))) {
1209
- const e = o && s && je.read(s);
1210
- e && i.set(o, e);
1211
- }
1212
- return t;
1213
- };
1214
- var Fe = "undefined" != typeof XMLHttpRequest && function(e) {
1215
- return new Promise((function(t, r) {
1216
- const n = Le(e);
1217
- let o = n.data;
1218
- const s = Oe.from(n.headers).normalize();
1219
- let i, a, c, l, u, { responseType: f, onUploadProgress: d, onDownloadProgress: h } = n;
1220
- function p() {
1221
- l && l(), u && u(), n.cancelToken && n.cancelToken.unsubscribe(i), n.signal && n.signal.removeEventListener("abort", i);
1222
- }
1223
- let m = new XMLHttpRequest();
1224
- function y() {
1225
- if (!m) return;
1226
- const n = Oe.from("getAllResponseHeaders" in m && m.getAllResponseHeaders());
1227
- ve((function(e) {
1228
- t(e), p();
1229
- }), (function(e) {
1230
- r(e), p();
1231
- }), {
1232
- data: f && "text" !== f && "json" !== f ? m.response : m.responseText,
1233
- status: m.status,
1234
- statusText: m.statusText,
1235
- headers: n,
1236
- config: e,
1237
- request: m
1238
- }), m = null;
1239
- }
1240
- m.open(n.method.toUpperCase(), n.url, !0), m.timeout = n.timeout, "onloadend" in m ? m.onloadend = y : m.onreadystatechange = function() {
1241
- m && 4 === m.readyState && (0 !== m.status || m.responseURL && 0 === m.responseURL.indexOf("file:")) && setTimeout(y);
1242
- }, m.onabort = function() {
1243
- m && (r(new H("Request aborted", H.ECONNABORTED, e, m)), m = null);
1244
- }, m.onerror = function(t) {
1245
- const n = new H(t && t.message ? t.message : "Network Error", H.ERR_NETWORK, e, m);
1246
- n.event = t || null, r(n), m = null;
1247
- }, m.ontimeout = function() {
1248
- let t = n.timeout ? "timeout of " + n.timeout + "ms exceeded" : "timeout exceeded";
1249
- const o = n.transitional || ie;
1250
- n.timeoutErrorMessage && (t = n.timeoutErrorMessage), r(new H(t, o.clarifyTimeoutError ? H.ETIMEDOUT : H.ECONNABORTED, e, m)), m = null;
1251
- }, void 0 === o && s.setContentType(null), "setRequestHeader" in m && $.forEach(s.toJSON(), (function(e, t) {
1252
- m.setRequestHeader(t, e);
1253
- })), $.isUndefined(n.withCredentials) || (m.withCredentials = !!n.withCredentials), f && "json" !== f && (m.responseType = n.responseType), h && ([c, u] = Ae(h, !0), m.addEventListener("progress", c)), d && m.upload && ([a, l] = Ae(d), m.upload.addEventListener("progress", a), m.upload.addEventListener("loadend", l)), (n.cancelToken || n.signal) && (i = (t) => {
1254
- m && (r(!t || t.type ? new Re(null, e, m) : t), m.abort(), m = null);
1255
- }, n.cancelToken && n.cancelToken.subscribe(i), n.signal && (n.signal.aborted ? i() : n.signal.addEventListener("abort", i)));
1256
- const b = function(e) {
1257
- const t = /^([-+\w]{1,25})(:?\/\/|:)/.exec(e);
1258
- return t && t[1] || "";
1259
- }(n.url);
1260
- b && -1 === he.protocols.indexOf(b) ? r(new H("Unsupported protocol " + b + ":", H.ERR_BAD_REQUEST, e)) : m.send(o || null);
1261
- }));
1262
- };
1263
- const qe = (e, t) => {
1264
- const { length: r } = e = e ? e.filter(Boolean) : [];
1265
- if (t || r) {
1266
- let r, n = new AbortController();
1267
- const o = function(e) {
1268
- if (!r) {
1269
- r = !0, i();
1270
- const t = e instanceof Error ? e : this.reason;
1271
- n.abort(t instanceof H ? t : new Re(t instanceof Error ? t.message : t));
1272
- }
1273
- };
1274
- let s = t && setTimeout((() => {
1275
- s = null, o(new H(`timeout ${t} of ms exceeded`, H.ETIMEDOUT));
1276
- }), t);
1277
- const i = () => {
1278
- e && (s && clearTimeout(s), s = null, e.forEach(((e) => {
1279
- e.unsubscribe ? e.unsubscribe(o) : e.removeEventListener("abort", o);
1280
- })), e = null);
1281
- };
1282
- e.forEach(((e) => e.addEventListener("abort", o)));
1283
- const { signal: a } = n;
1284
- return a.unsubscribe = () => $.asap(i), a;
1285
- }
1286
- }, ke = function* (e, t) {
1287
- let r = e.byteLength;
1288
- if (r < t) return void (yield e);
1289
- let n, o = 0;
1290
- for (; o < r;) n = o + t, yield e.slice(o, n), o = n;
1291
- }, De = async function* (e) {
1292
- if (e[Symbol.asyncIterator]) return void (yield* e);
1293
- const t = e.getReader();
1294
- try {
1295
- for (;;) {
1296
- const { done: e, value: r } = await t.read();
1297
- if (e) break;
1298
- yield r;
1299
- }
1300
- } finally {
1301
- await t.cancel();
1302
- }
1303
- }, Be = (e, t, r, n) => {
1304
- const o = async function* (e, t) {
1305
- for await (const r of De(e)) yield* ke(r, t);
1306
- }(e, t);
1307
- let s, i = 0, a = (e) => {
1308
- s || (s = !0, n && n(e));
1309
- };
1310
- return new ReadableStream({
1311
- async pull(e) {
1312
- try {
1313
- const { done: t, value: n } = await o.next();
1314
- if (t) return a(), void e.close();
1315
- let s = n.byteLength;
1316
- if (r) r(i += s);
1317
- e.enqueue(new Uint8Array(n));
1318
- } catch (e) {
1319
- throw a(e), e;
1320
- }
1321
- },
1322
- cancel: (e) => (a(e), o.return())
1323
- }, { highWaterMark: 2 });
1324
- }, { isFunction: Ie } = $, Je = (({ fetch: e, Request: t, Response: r }) => ({
1325
- fetch: e,
1326
- Request: t,
1327
- Response: r
1328
- }))($.global), { ReadableStream: Me, TextEncoder: Ge } = $.global, ze = (e, ...t) => {
1329
- try {
1330
- return !!e(...t);
1331
- } catch (e) {
1332
- return !1;
1333
- }
1334
- }, $e = (e) => {
1335
- const { fetch: t, Request: r, Response: n } = Object.assign({}, Je, e), o = Ie(t), s = Ie(r), i = Ie(n);
1336
- if (!o) return !1;
1337
- const a = o && Ie(Me), c = o && ("function" == typeof Ge ? (l = new Ge(), (e) => l.encode(e)) : async (e) => new Uint8Array(await new r(e).arrayBuffer()));
1338
- var l;
1339
- const u = s && a && ze((() => {
1340
- let e = !1;
1341
- const t = new r(he.origin, {
1342
- body: new Me(),
1343
- method: "POST",
1344
- get duplex() {
1345
- return e = !0, "half";
1346
- }
1347
- }).headers.has("Content-Type");
1348
- return e && !t;
1349
- })), f = i && a && ze((() => $.isReadableStream(new n("").body))), d = { stream: f && ((e) => e.body) };
1350
- o && [
1351
- "text",
1352
- "arrayBuffer",
1353
- "blob",
1354
- "formData",
1355
- "stream"
1356
- ].forEach(((e) => {
1357
- !d[e] && (d[e] = (t, r) => {
1358
- let n = t && t[e];
1359
- if (n) return n.call(t);
1360
- throw new H(`Response type '${e}' is not supported`, H.ERR_NOT_SUPPORT, r);
1361
- });
1362
- }));
1363
- const h = async (e, t) => {
1364
- const n = $.toFiniteNumber(e.getContentLength());
1365
- return null == n ? (async (e) => {
1366
- if (null == e) return 0;
1367
- if ($.isBlob(e)) return e.size;
1368
- if ($.isSpecCompliantForm(e)) return (await new r(he.origin, {
1369
- method: "POST",
1370
- body: e
1371
- }).arrayBuffer()).byteLength;
1372
- return $.isArrayBufferView(e) || $.isArrayBuffer(e) ? e.byteLength : ($.isURLSearchParams(e) && (e += ""), $.isString(e) ? (await c(e)).byteLength : void 0);
1373
- })(t) : n;
1374
- };
1375
- return async (e) => {
1376
- let { url: o, method: i, data: a, signal: c, cancelToken: l, timeout: p, onDownloadProgress: m, onUploadProgress: y, responseType: b, headers: g, withCredentials: w = "same-origin", fetchOptions: E } = Le(e);
1377
- b = b ? (b + "").toLowerCase() : "text";
1378
- let O = qe([c, l && l.toAbortSignal()], p), T = null;
1379
- const S = O && O.unsubscribe && (() => {
1380
- O.unsubscribe();
1381
- });
1382
- let R;
1383
- try {
1384
- if (y && u && "get" !== i && "head" !== i && 0 !== (R = await h(g, a))) {
1385
- let e, t = new r(o, {
1386
- method: "POST",
1387
- body: a,
1388
- duplex: "half"
1389
- });
1390
- if ($.isFormData(a) && (e = t.headers.get("content-type")) && g.setContentType(e), t.body) {
1391
- const [e, r] = xe(R, Ae(Ne(y)));
1392
- a = Be(t.body, 65536, e, r);
1393
- }
1394
- }
1395
- $.isString(w) || (w = w ? "include" : "omit");
1396
- const c = s && "credentials" in r.prototype, l = {
1397
- ...E,
1398
- signal: O,
1399
- method: i.toUpperCase(),
1400
- headers: g.normalize().toJSON(),
1401
- body: a,
1402
- duplex: "half",
1403
- credentials: c ? w : void 0
1404
- };
1405
- T = s && new r(o, l);
1406
- let p = await (s ? t(T, E) : t(o, l));
1407
- const v = f && ("stream" === b || "response" === b);
1408
- if (f && (m || v && S)) {
1409
- const e = {};
1410
- [
1411
- "status",
1412
- "statusText",
1413
- "headers"
1414
- ].forEach(((t) => {
1415
- e[t] = p[t];
1416
- }));
1417
- const t = $.toFiniteNumber(p.headers.get("content-length")), [r, o] = m && xe(t, Ae(Ne(m), !0)) || [];
1418
- p = new n(Be(p.body, 65536, r, (() => {
1419
- o && o(), S && S();
1420
- })), e);
1421
- }
1422
- b = b || "text";
1423
- let A = await d[$.findKey(d, b) || "text"](p, e);
1424
- return !v && S && S(), await new Promise(((t, r) => {
1425
- ve(t, r, {
1426
- data: A,
1427
- headers: Oe.from(p.headers),
1428
- status: p.status,
1429
- statusText: p.statusText,
1430
- config: e,
1431
- request: T
1432
- });
1433
- }));
1434
- } catch (t) {
1435
- if (S && S(), t && "TypeError" === t.name && /Load failed|fetch/i.test(t.message)) throw Object.assign(new H("Network Error", H.ERR_NETWORK, e, T), { cause: t.cause || t });
1436
- throw H.from(t, t && t.code, e, T);
1437
- }
1438
- };
1439
- }, He = /* @__PURE__ */ new Map(), We = (e) => {
1440
- let t = $.merge.call({ skipUndefined: !0 }, Je, e ? e.env : null);
1441
- const { fetch: r, Request: n, Response: o } = t, s = [
1442
- n,
1443
- o,
1444
- r
1445
- ];
1446
- let i, a, c = s.length, l = He;
1447
- for (; c--;) i = s[c], a = l.get(i), void 0 === a && l.set(i, a = c ? /* @__PURE__ */ new Map() : $e(t)), l = a;
1448
- return a;
1449
- };
1450
- We();
1451
- const Ve = {
1452
- http: null,
1453
- xhr: Fe,
1454
- fetch: { get: We }
1455
- };
1456
- $.forEach(Ve, ((e, t) => {
1457
- if (e) {
1458
- try {
1459
- Object.defineProperty(e, "name", { value: t });
1460
- } catch (e) {}
1461
- Object.defineProperty(e, "adapterName", { value: t });
1462
- }
1463
- }));
1464
- const Ke = (e) => `- ${e}`, Xe = (e) => $.isFunction(e) || null === e || !1 === e;
1465
- var Qe = (e, t) => {
1466
- e = $.isArray(e) ? e : [e];
1467
- const { length: r } = e;
1468
- let n, o;
1469
- const s = {};
1470
- for (let i = 0; i < r; i++) {
1471
- let r;
1472
- if (n = e[i], o = n, !Xe(n) && (o = Ve[(r = String(n)).toLowerCase()], void 0 === o)) throw new H(`Unknown adapter '${r}'`);
1473
- if (o && ($.isFunction(o) || (o = o.get(t)))) break;
1474
- s[r || "#" + i] = o;
1475
- }
1476
- if (!o) {
1477
- const e = Object.entries(s).map((([e, t]) => `adapter ${e} ` + (!1 === t ? "is not supported by the environment" : "is not available in the build")));
1478
- throw new H("There is no suitable adapter to dispatch the request " + (r ? e.length > 1 ? "since :\n" + e.map(Ke).join("\n") : " " + Ke(e[0]) : "as no adapter specified"), "ERR_NOT_SUPPORT");
1479
- }
1480
- return o;
1481
- };
1482
- function Ze(e) {
1483
- if (e.cancelToken && e.cancelToken.throwIfRequested(), e.signal && e.signal.aborted) throw new Re(null, e);
1484
- }
1485
- function Ye(e) {
1486
- Ze(e), e.headers = Oe.from(e.headers), e.data = Te.call(e, e.transformRequest), -1 !== [
1487
- "post",
1488
- "put",
1489
- "patch"
1490
- ].indexOf(e.method) && e.headers.setContentType("application/x-www-form-urlencoded", !1);
1491
- return Qe(e.adapter || me.adapter, e)(e).then((function(t) {
1492
- return Ze(e), t.data = Te.call(e, e.transformResponse, t), t.headers = Oe.from(t.headers), t;
1493
- }), (function(t) {
1494
- return Se(t) || (Ze(e), t && t.response && (t.response.data = Te.call(e, e.transformResponse, t.response), t.response.headers = Oe.from(t.response.headers))), Promise.reject(t);
1495
- }));
1496
- }
1497
- const et = "1.12.0", tt = {};
1498
- [
1499
- "object",
1500
- "boolean",
1501
- "number",
1502
- "function",
1503
- "string",
1504
- "symbol"
1505
- ].forEach(((e, t) => {
1506
- tt[e] = function(r) {
1507
- return typeof r === e || "a" + (t < 1 ? "n " : " ") + e;
1508
- };
1509
- }));
1510
- const rt = {};
1511
- tt.transitional = function(e, t, r) {
1512
- function n(e, t) {
1513
- return "[Axios v" + et + "] Transitional option '" + e + "'" + t + (r ? ". " + r : "");
1514
- }
1515
- return (r, o, s) => {
1516
- if (!1 === e) throw new H(n(o, " has been removed" + (t ? " in " + t : "")), H.ERR_DEPRECATED);
1517
- return t && !rt[o] && (rt[o] = !0, console.warn(n(o, " has been deprecated since v" + t + " and will be removed in the near future"))), !e || e(r, o, s);
1518
- };
1519
- }, tt.spelling = function(e) {
1520
- return (t, r) => (console.warn(`${r} is likely a misspelling of ${e}`), !0);
1521
- };
1522
- var nt = {
1523
- assertOptions: function(e, t, r) {
1524
- if ("object" != typeof e) throw new H("options must be an object", H.ERR_BAD_OPTION_VALUE);
1525
- const n = Object.keys(e);
1526
- let o = n.length;
1527
- for (; o-- > 0;) {
1528
- const s = n[o], i = t[s];
1529
- if (i) {
1530
- const t = e[s], r = void 0 === t || i(t, s, e);
1531
- if (!0 !== r) throw new H("option " + s + " must be " + r, H.ERR_BAD_OPTION_VALUE);
1532
- } else if (!0 !== r) throw new H("Unknown option " + s, H.ERR_BAD_OPTION);
1533
- }
1534
- },
1535
- validators: tt
1536
- };
1537
- const ot = nt.validators;
1538
- let st = class {
1539
- constructor(e) {
1540
- this.defaults = e || {}, this.interceptors = {
1541
- request: new se(),
1542
- response: new se()
1543
- };
1544
- }
1545
- async request(e, t) {
1546
- try {
1547
- return await this._request(e, t);
1548
- } catch (e) {
1549
- if (e instanceof Error) {
1550
- let t = {};
1551
- Error.captureStackTrace ? Error.captureStackTrace(t) : t = /* @__PURE__ */ new Error();
1552
- const r = t.stack ? t.stack.replace(/^.+\n/, "") : "";
1553
- try {
1554
- e.stack ? r && !String(e.stack).endsWith(r.replace(/^.+\n.+\n/, "")) && (e.stack += "\n" + r) : e.stack = r;
1555
- } catch (e) {}
1556
- }
1557
- throw e;
1558
- }
1559
- }
1560
- _request(e, t) {
1561
- "string" == typeof e ? (t = t || {}).url = e : t = e || {}, t = _e(this.defaults, t);
1562
- const { transitional: r, paramsSerializer: n, headers: o } = t;
1563
- void 0 !== r && nt.assertOptions(r, {
1564
- silentJSONParsing: ot.transitional(ot.boolean),
1565
- forcedJSONParsing: ot.transitional(ot.boolean),
1566
- clarifyTimeoutError: ot.transitional(ot.boolean)
1567
- }, !1), null != n && ($.isFunction(n) ? t.paramsSerializer = { serialize: n } : nt.assertOptions(n, {
1568
- encode: ot.function,
1569
- serialize: ot.function
1570
- }, !0)), void 0 !== t.allowAbsoluteUrls || (void 0 !== this.defaults.allowAbsoluteUrls ? t.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls : t.allowAbsoluteUrls = !0), nt.assertOptions(t, {
1571
- baseUrl: ot.spelling("baseURL"),
1572
- withXsrfToken: ot.spelling("withXSRFToken")
1573
- }, !0), t.method = (t.method || this.defaults.method || "get").toLowerCase();
1574
- let s = o && $.merge(o.common, o[t.method]);
1575
- o && $.forEach([
1576
- "delete",
1577
- "get",
1578
- "head",
1579
- "post",
1580
- "put",
1581
- "patch",
1582
- "common"
1583
- ], ((e) => {
1584
- delete o[e];
1585
- })), t.headers = Oe.concat(s, o);
1586
- const i = [];
1587
- let a = !0;
1588
- this.interceptors.request.forEach((function(e) {
1589
- "function" == typeof e.runWhen && !1 === e.runWhen(t) || (a = a && e.synchronous, i.unshift(e.fulfilled, e.rejected));
1590
- }));
1591
- const c = [];
1592
- let l;
1593
- this.interceptors.response.forEach((function(e) {
1594
- c.push(e.fulfilled, e.rejected);
1595
- }));
1596
- let u, f = 0;
1597
- if (!a) {
1598
- const e = [Ye.bind(this), void 0];
1599
- for (e.unshift(...i), e.push(...c), u = e.length, l = Promise.resolve(t); f < u;) l = l.then(e[f++], e[f++]);
1600
- return l;
1601
- }
1602
- u = i.length;
1603
- let d = t;
1604
- for (f = 0; f < u;) {
1605
- const e = i[f++], t = i[f++];
1606
- try {
1607
- d = e(d);
1608
- } catch (e) {
1609
- t.call(this, e);
1610
- break;
1611
- }
1612
- }
1613
- try {
1614
- l = Ye.call(this, d);
1615
- } catch (e) {
1616
- return Promise.reject(e);
1617
- }
1618
- for (f = 0, u = c.length; f < u;) l = l.then(c[f++], c[f++]);
1619
- return l;
1620
- }
1621
- getUri(e) {
1622
- return oe(Ce((e = _e(this.defaults, e)).baseURL, e.url, e.allowAbsoluteUrls), e.params, e.paramsSerializer);
1623
- }
1624
- };
1625
- $.forEach([
1626
- "delete",
1627
- "get",
1628
- "head",
1629
- "options"
1630
- ], (function(e) {
1631
- st.prototype[e] = function(t, r) {
1632
- return this.request(_e(r || {}, {
1633
- method: e,
1634
- url: t,
1635
- data: (r || {}).data
1636
- }));
1637
- };
1638
- })), $.forEach([
1639
- "post",
1640
- "put",
1641
- "patch"
1642
- ], (function(e) {
1643
- function t(t) {
1644
- return function(r, n, o) {
1645
- return this.request(_e(o || {}, {
1646
- method: e,
1647
- headers: t ? { "Content-Type": "multipart/form-data" } : {},
1648
- url: r,
1649
- data: n
1650
- }));
1651
- };
1652
- }
1653
- st.prototype[e] = t(), st.prototype[e + "Form"] = t(!0);
1654
- }));
1655
- const it = {
1656
- Continue: 100,
1657
- SwitchingProtocols: 101,
1658
- Processing: 102,
1659
- EarlyHints: 103,
1660
- Ok: 200,
1661
- Created: 201,
1662
- Accepted: 202,
1663
- NonAuthoritativeInformation: 203,
1664
- NoContent: 204,
1665
- ResetContent: 205,
1666
- PartialContent: 206,
1667
- MultiStatus: 207,
1668
- AlreadyReported: 208,
1669
- ImUsed: 226,
1670
- MultipleChoices: 300,
1671
- MovedPermanently: 301,
1672
- Found: 302,
1673
- SeeOther: 303,
1674
- NotModified: 304,
1675
- UseProxy: 305,
1676
- Unused: 306,
1677
- TemporaryRedirect: 307,
1678
- PermanentRedirect: 308,
1679
- BadRequest: 400,
1680
- Unauthorized: 401,
1681
- PaymentRequired: 402,
1682
- Forbidden: 403,
1683
- NotFound: 404,
1684
- MethodNotAllowed: 405,
1685
- NotAcceptable: 406,
1686
- ProxyAuthenticationRequired: 407,
1687
- RequestTimeout: 408,
1688
- Conflict: 409,
1689
- Gone: 410,
1690
- LengthRequired: 411,
1691
- PreconditionFailed: 412,
1692
- PayloadTooLarge: 413,
1693
- UriTooLong: 414,
1694
- UnsupportedMediaType: 415,
1695
- RangeNotSatisfiable: 416,
1696
- ExpectationFailed: 417,
1697
- ImATeapot: 418,
1698
- MisdirectedRequest: 421,
1699
- UnprocessableEntity: 422,
1700
- Locked: 423,
1701
- FailedDependency: 424,
1702
- TooEarly: 425,
1703
- UpgradeRequired: 426,
1704
- PreconditionRequired: 428,
1705
- TooManyRequests: 429,
1706
- RequestHeaderFieldsTooLarge: 431,
1707
- UnavailableForLegalReasons: 451,
1708
- InternalServerError: 500,
1709
- NotImplemented: 501,
1710
- BadGateway: 502,
1711
- ServiceUnavailable: 503,
1712
- GatewayTimeout: 504,
1713
- HttpVersionNotSupported: 505,
1714
- VariantAlsoNegotiates: 506,
1715
- InsufficientStorage: 507,
1716
- LoopDetected: 508,
1717
- NotExtended: 510,
1718
- NetworkAuthenticationRequired: 511
1719
- };
1720
- Object.entries(it).forEach((([e, t]) => {
1721
- it[t] = e;
1722
- }));
1723
- const at = function e(r) {
1724
- const n = new st(r), o = t(st.prototype.request, n);
1725
- return $.extend(o, st.prototype, n, { allOwnKeys: !0 }), $.extend(o, n, null, { allOwnKeys: !0 }), o.create = function(t) {
1726
- return e(_e(r, t));
1727
- }, o;
1728
- }(me);
1729
- at.Axios = st, at.CanceledError = Re, at.CancelToken = class e {
1730
- constructor(e) {
1731
- if ("function" != typeof e) throw new TypeError("executor must be a function.");
1732
- let t;
1733
- this.promise = new Promise((function(e) {
1734
- t = e;
1735
- }));
1736
- const r = this;
1737
- this.promise.then(((e) => {
1738
- if (!r._listeners) return;
1739
- let t = r._listeners.length;
1740
- for (; t-- > 0;) r._listeners[t](e);
1741
- r._listeners = null;
1742
- })), this.promise.then = (e) => {
1743
- let t;
1744
- const n = new Promise(((e) => {
1745
- r.subscribe(e), t = e;
1746
- })).then(e);
1747
- return n.cancel = function() {
1748
- r.unsubscribe(t);
1749
- }, n;
1750
- }, e((function(e, n, o) {
1751
- r.reason || (r.reason = new Re(e, n, o), t(r.reason));
1752
- }));
1753
- }
1754
- throwIfRequested() {
1755
- if (this.reason) throw this.reason;
1756
- }
1757
- subscribe(e) {
1758
- this.reason ? e(this.reason) : this._listeners ? this._listeners.push(e) : this._listeners = [e];
1759
- }
1760
- unsubscribe(e) {
1761
- if (!this._listeners) return;
1762
- const t = this._listeners.indexOf(e);
1763
- -1 !== t && this._listeners.splice(t, 1);
1764
- }
1765
- toAbortSignal() {
1766
- const e = new AbortController(), t = (t) => {
1767
- e.abort(t);
1768
- };
1769
- return this.subscribe(t), e.signal.unsubscribe = () => this.unsubscribe(t), e.signal;
1770
- }
1771
- static source() {
1772
- let t;
1773
- return {
1774
- token: new e((function(e) {
1775
- t = e;
1776
- })),
1777
- cancel: t
1778
- };
1779
- }
1780
- }, at.isCancel = Se, at.VERSION = et, at.toFormData = Y, at.AxiosError = H, at.Cancel = at.CanceledError, at.all = function(e) {
1781
- return Promise.all(e);
1782
- }, at.spread = function(e) {
1783
- return function(t) {
1784
- return e.apply(null, t);
1785
- };
1786
- }, at.isAxiosError = function(e) {
1787
- return $.isObject(e) && !0 === e.isAxiosError;
1788
- }, at.mergeConfig = _e, at.AxiosHeaders = Oe, at.formToJSON = (e) => pe($.isHTMLForm(e) ? new FormData(e) : e), at.getAdapter = Qe, at.HttpStatusCode = it, at.default = at;
1789
- const { Axios: ct, AxiosError: lt, CanceledError: ut, isCancel: ft, CancelToken: dt, VERSION: ht, all: pt, Cancel: mt, isAxiosError: yt, spread: bt, toFormData: gt, AxiosHeaders: wt, HttpStatusCode: Et, formToJSON: Ot, getAdapter: Tt, mergeConfig: St } = at;
1790
- var Rt;
1791
- e.ResponseType = void 0, (Rt = e.ResponseType || (e.ResponseType = {})).MATRIX = "matrix", Rt.VECTOR = "vector", Rt.SCALAR = "scalar", Rt.STRING = "string";
1792
- class vt {
1793
- constructor(e, t) {
1794
- if (e && "string" != typeof e) throw new Error("Wrong name format. Expected string.");
1795
- if (t && "object" != typeof t) throw new Error("Wrong labels format. Expected object.");
1796
- this.name = e, this.labels = t;
1797
- }
1798
- static fromJSON(e) {
1799
- const t = e.__name__, r = Object.assign({}, e);
1800
- return delete r.__name__, new vt(t, r);
1801
- }
1802
- toString() {
1803
- return (this.name ? this.name : "") + "{" + Object.keys(this.labels).map(((e) => e + "=\"" + this.labels[e] + "\"")).join(", ") + "}";
1804
- }
1805
- }
1806
- class At {
1807
- constructor(e, t) {
1808
- if ("object" != typeof e || "Date" != e.constructor.name) throw new Error("Wrong time format. Expected Date.");
1809
- if ("number" != typeof t) throw new Error("Wrong value format. Expected float.");
1810
- this.time = e, this.value = t;
1811
- }
1812
- static fromJSON(e) {
1813
- return new At(/* @__PURE__ */ new Date(1e3 * e[0]), parseFloat(e[1]));
1814
- }
1815
- toString() {
1816
- return this.time + ": " + this.value;
1817
- }
1818
- }
1819
- class xt {
1820
- constructor(e, t) {
1821
- this.metric = e, this.values = t;
1822
- }
1823
- static fromJSON(e) {
1824
- return new xt(e.metric ? vt.fromJSON(e.metric) : null, e.values.map(At.fromJSON));
1825
- }
1826
- }
1827
- class Nt {
1828
- constructor(e, t) {
1829
- this.metric = e, this.value = t;
1830
- }
1831
- static fromJSON(e) {
1832
- return new Nt(e.metric ? vt.fromJSON(e.metric) : null, At.fromJSON(e.value));
1833
- }
1834
- }
1835
- class Pt {
1836
- constructor(e, t) {
1837
- this.resultType = e, this.result = t;
1838
- }
1839
- static fromJSON(t) {
1840
- const r = t.resultType;
1841
- let n = null;
1842
- switch (r) {
1843
- case e.ResponseType.MATRIX:
1844
- n = t.result.map(xt.fromJSON);
1845
- break;
1846
- case e.ResponseType.VECTOR:
1847
- n = t.result.map(Nt.fromJSON);
1848
- break;
1849
- case e.ResponseType.SCALAR:
1850
- case e.ResponseType.STRING:
1851
- n = t.result;
1852
- break;
1853
- default: throw new Error(`Unexpected resultType: ${r}`);
1854
- }
1855
- return new Pt(r, n);
1856
- }
1857
- }
1858
- class jt {
1859
- constructor(e, t, r, n, o, s, i, a) {
1860
- if (e && "object" != typeof e) throw new Error(`Unexpected format for discoveredLabels. Got ${typeof e} instead of object`);
1861
- if (t && "object" != typeof t) throw new Error(`Unexpected format for labels. Got ${typeof t} instead of object`);
1862
- if (r && "string" != typeof r) throw new Error(`Unexpected format for scrapePool. Got ${typeof r} instead of string`);
1863
- if (n && "string" != typeof n) throw new Error(`Unexpected format for scrapeUrl. Got ${typeof n} instead of string`);
1864
- if (o && "string" != typeof o) throw new Error(`Unexpected format for lastError. Got ${typeof o} instead of string`);
1865
- if (s && ("object" != typeof s || "Date" != s.constructor.name)) throw new Error(`Unexpected format for lastScrape. Got ${typeof s} instead of object`);
1866
- if (i && "number" != typeof i) throw new Error(`Unexpected format for lastScrapeDuration. Got ${typeof i} instead of number`);
1867
- if (a && "string" != typeof a) throw new Error(`Unexpected format for health. Got ${typeof a} instead of string`);
1868
- this.discoveredLabels = e, this.labels = t, this.scrapePool = r, this.scrapeUrl = n, this.lastError = o, this.lastScrape = s, this.lastScrapeDuration = i, this.health = a;
1869
- }
1870
- static fromJSON(e) {
1871
- return new jt(e.discoveredLabels, e.labels, e.scrapePool, e.scrapeUrl, e.lastError, e.lastScrape ? new Date(e.lastScrape) : null, e.lastScrapeDuration ? parseFloat(e.lastScrapeDuration) : null, e.health);
1872
- }
1873
- }
1874
- class Ct {
1875
- constructor(e, t, r, n, o) {
1876
- if (e && ("object" != typeof e || "Date" != e.constructor.name)) throw new Error(`Unexpected format for activeAt. Got ${typeof e} instead of object`);
1877
- if (t && "object" != typeof t) throw new Error(`Unexpected format for annotations. Got ${typeof t} instead of object`);
1878
- if (r && "object" != typeof r) throw new Error(`Unexpected format for labels. Got ${typeof r} instead of object`);
1879
- if (o && "number" != typeof o) throw new Error(`Unexpected format for value. Got ${typeof o} instead of number`);
1880
- this.activeAt = e, this.annotations = t, this.labels = r, this.state = n, this.value = o;
1881
- }
1882
- static fromJSON(e) {
1883
- return new Ct(e.activeAt ? new Date(e.activeAt) : null, e.annotations, e.labels, e.state, e.value ? parseFloat(e.value) : null);
1884
- }
1885
- }
1886
- class Ut {
1887
- constructor(e, t, r, n, o, s, i, a) {
1888
- this.alerts = e, this.annotations = t, this.duration = r, this.health = n, this.labels = o, this.name = s, this.query = i, this.type = a;
1889
- }
1890
- static fromJSON(e) {
1891
- return new Ut(e.alerts ? e.alerts.map(Ct.fromJSON) : [], e.annotations, e.duration, e.health, e.labels, e.name, e.query, e.type);
1892
- }
1893
- }
1894
- class _t {
1895
- constructor(e, t, r, n) {
1896
- this.rules = e, this.file = t, this.interval = r, this.name = n;
1897
- }
1898
- static fromJSON(e) {
1899
- return new _t(e.rules ? e.rules.map(Ut.fromJSON) : [], e.file, e.interval, e.name);
1900
- }
1901
- }
1902
- class Lt {
1903
- constructor() {
1904
- this.baseURL = "/api/v1/", this.headers = {}, this.auth = null, this.proxy = null, this.withCredentials = !1, this.timeout = 1e4, this.preferPost = !1, this.warningHook = null;
1905
- }
1906
- }
1907
- e.Alert = Ct, e.InstantVector = Nt, e.Metric = vt, e.PrometheusConnectionOptions = Lt, e.PrometheusDriver = class {
1908
- constructor(e) {
1909
- if (this.listifyIfNeeded = (e) => e instanceof Array ? e : [e], this.formatPromQlParams = (e) => Object.entries(null != e ? e : {}).reduce(((e, [t, r]) => (null != r && (r instanceof Array ? r.filter(((e) => null != e)).forEach(((r) => e.append(`${t}[]`, r))) : e.append(t, r)), e)), new URLSearchParams()), !(e = e || new Lt()).endpoint) throw "Endpoint is required";
1910
- e.endpoint = e.endpoint.replace(/\/$/, ""), e.baseURL = e.baseURL || "/api/v1/", e.withCredentials = e.withCredentials || !1, e.timeout = e.timeout || 1e4, this.options = e, this.axiosInstance = at.create(), this.options.requestInterceptor && this.axiosInstance.interceptors.request.use(this.options.requestInterceptor.onFulfilled, this.options.requestInterceptor.onRejected), this.options.responseInterceptor && this.axiosInstance.interceptors.response.use(this.options.responseInterceptor.onFulfilled, this.options.responseInterceptor.onRejected);
1911
- }
1912
- request(e, t, r, n) {
1913
- var o, s, i, a, c, l;
1914
- const u = Object.assign({}, this.options.headers || {});
1915
- return this.axiosInstance.request({
1916
- baseURL: this.options.endpoint + this.options.baseURL,
1917
- url: t,
1918
- method: e,
1919
- params: this.formatPromQlParams(r),
1920
- data: this.formatPromQlParams(n),
1921
- headers: u,
1922
- auth: (null === (o = this.options.auth) || void 0 === o ? void 0 : o.username) && (null === (s = this.options.auth) || void 0 === s ? void 0 : s.password) ? {
1923
- username: this.options.auth.username,
1924
- password: this.options.auth.password
1925
- } : null,
1926
- proxy: (null === (i = this.options.proxy) || void 0 === i ? void 0 : i.host) && (null === (a = this.options.proxy) || void 0 === a ? void 0 : a.port) ? {
1927
- host: null === (c = this.options.proxy) || void 0 === c ? void 0 : c.host,
1928
- port: null === (l = this.options.proxy) || void 0 === l ? void 0 : l.port
1929
- } : null,
1930
- withCredentials: this.options.withCredentials,
1931
- timeout: this.options.timeout
1932
- }).then(((e) => this.handleResponse(e))).catch(((e) => this.handleResponse(e, !0)));
1933
- }
1934
- handleResponse(e, t = !1) {
1935
- var r, n, o, s, i;
1936
- const a = !0 === (null == e ? void 0 : e.isAxiosError), c = t || a, l = a ? e : void 0, u = a ? l.response : c ? null == e ? void 0 : e.response : e;
1937
- if (!u) {
1938
- const t = null !== (r = null == l ? void 0 : l.code) && void 0 !== r ? r : null == e ? void 0 : e.code, i = null !== (o = null !== (n = null == l ? void 0 : l.message) && void 0 !== n ? n : null == e ? void 0 : e.message) && void 0 !== o ? o : "unexpected network error";
1939
- throw {
1940
- status: "error",
1941
- errorType: "ECONNABORTED" === t ? "timeout_error" : (null === (s = null == t ? void 0 : t.startsWith) || void 0 === s ? void 0 : s.call(t, "ERR_SSL")) ? "ssl_error" : "network_error",
1942
- error: i,
1943
- code: t,
1944
- original: e
1945
- };
1946
- }
1947
- this.options.warningHook && Array.isArray(u.warnings) && u.warnings.length && this.options.warningHook(u.warnings);
1948
- const f = u.data;
1949
- if (!f || null == f.status) throw {
1950
- status: "error",
1951
- errorType: "client_error",
1952
- error: "unexpected client error",
1953
- data: f
1954
- };
1955
- if (c) throw {
1956
- status: "error",
1957
- errorType: "http_error",
1958
- httpStatus: u.status,
1959
- error: null !== (i = f.error) && void 0 !== i ? i : u.statusText,
1960
- prometheus: f
1961
- };
1962
- return f.data;
1963
- }
1964
- formatTimeToPrometheus(e, t) {
1965
- var r;
1966
- if (e || (e = t), "number" == typeof e) return e / 1e3;
1967
- if ("object" == typeof e && "Date" == (null === (r = null == e ? void 0 : e.constructor) || void 0 === r ? void 0 : r.name)) return e.getTime() / 1e3;
1968
- throw new Error("Wrong time format. Expected number or Date.");
1969
- }
1970
- instantQuery(e, t, r) {
1971
- const n = {
1972
- query: e,
1973
- time: this.formatTimeToPrometheus(t, /* @__PURE__ */ new Date()),
1974
- timeout: r
1975
- };
1976
- return (this.options.preferPost ? this.request("POST", "query", null, n) : this.request("GET", "query", n)).then(((e) => Pt.fromJSON(e)));
1977
- }
1978
- rangeQuery(e, t, r, n, o) {
1979
- const s = {
1980
- query: e,
1981
- start: this.formatTimeToPrometheus(t),
1982
- end: this.formatTimeToPrometheus(r),
1983
- step: n,
1984
- timeout: o
1985
- };
1986
- return (this.options.preferPost ? this.request("POST", "query_range", null, s) : this.request("GET", "query_range", s)).then(((e) => Pt.fromJSON(e)));
1987
- }
1988
- series(e, t, r) {
1989
- const n = {
1990
- match: this.listifyIfNeeded(e),
1991
- start: this.formatTimeToPrometheus(t),
1992
- end: this.formatTimeToPrometheus(r)
1993
- };
1994
- return (this.options.preferPost ? this.request("POST", "series", null, n) : this.request("GET", "series", n)).then(((e) => e.map(vt.fromJSON)));
1995
- }
1996
- labelNames(e, t, r) {
1997
- const n = {
1998
- match: this.listifyIfNeeded(e),
1999
- start: t ? this.formatTimeToPrometheus(t) : void 0,
2000
- end: r ? this.formatTimeToPrometheus(r) : void 0
2001
- };
2002
- return this.options.preferPost ? this.request("POST", "labels", null, n) : this.request("GET", "labels", n);
2003
- }
2004
- labelValues(e, t, r, n) {
2005
- const o = {
2006
- match: this.listifyIfNeeded(t),
2007
- start: r ? this.formatTimeToPrometheus(r) : void 0,
2008
- end: n ? this.formatTimeToPrometheus(n) : void 0
2009
- };
2010
- return this.request("GET", `label/${e}/values`, o);
2011
- }
2012
- targets(e) {
2013
- const t = { query: e || "any" };
2014
- return this.request("GET", "targets", t).then(((e) => ({
2015
- activeTargets: e.activeTargets ? e.activeTargets.map(jt.fromJSON) : [],
2016
- droppedTargets: e.droppedTargets ? e.droppedTargets.map(jt.fromJSON) : []
2017
- })));
2018
- }
2019
- targetsMetadata(e, t, r) {
2020
- const n = {
2021
- match_target: e,
2022
- metric: t,
2023
- limit: r
2024
- };
2025
- return this.request("GET", "targets/metadata", n);
2026
- }
2027
- metadata(e, t) {
2028
- const r = {
2029
- metric: e,
2030
- limit: t
2031
- };
2032
- return this.request("GET", "metadata", r);
2033
- }
2034
- rules() {
2035
- return this.request("GET", "rules").then(((e) => (e.groups ? e.groups : []).map(_t.fromJSON)));
2036
- }
2037
- alerts() {
2038
- return this.request("GET", "alerts").then(((e) => (e.alerts ? e.alerts : []).map(Ct.fromJSON)));
2039
- }
2040
- alertmanagers() {
2041
- return this.request("GET", "alertmanagers");
2042
- }
2043
- status() {
2044
- return this.request("GET", "status/config");
2045
- }
2046
- statusFlags() {
2047
- return this.request("GET", "status/flags");
2048
- }
2049
- statusRuntimeInfo() {
2050
- return this.request("GET", "status/runtimeinfo");
2051
- }
2052
- statusBuildinfo() {
2053
- return this.request("GET", "status/buildinfo");
2054
- }
2055
- statusTSDB() {
2056
- return this.request("GET", "status/tsdb");
2057
- }
2058
- adminSnapshot(e) {
2059
- const t = { skip_head: e };
2060
- return this.request("POST", "admin/tsdb/snapshot", t);
2061
- }
2062
- adminDeleteSeries(e, t, r) {
2063
- const n = {
2064
- match: this.listifyIfNeeded(e),
2065
- start: this.formatTimeToPrometheus(t),
2066
- end: this.formatTimeToPrometheus(r)
2067
- };
2068
- return this.request("POST", "admin/tsdb/delete_series", n);
2069
- }
2070
- adminCleanTombstones() {
2071
- return this.request("POST", "admin/tsdb/clean_tombstones");
2072
- }
2073
- }, e.QueryResult = Pt, e.RangeVector = xt, e.Rule = Ut, e.RuleGroup = _t, e.SampleValue = At, e.Target = jt;
2074
- }));
2075
- }));
2076
- //#endregion
2077
- //#region node_modules/chartjs-plugin-datasource-prometheus/dist/chartjs-plugin-datasource-prometheus.esm.js
2078
- var import_prometheus_query_umd = require_prometheus_query_umd();
2079
- const PROMETHEUS_QUERY_RANGE_MIN_STEP = 1;
2080
- var datasource = {
2081
- getPrometheusStepAuto: (start, end, chartWidth) => {
2082
- const secondDuration = (end.getTime() - start.getTime()) / 1e3;
2083
- const step = Math.floor(secondDuration / chartWidth) * 25;
2084
- return step < PROMETHEUS_QUERY_RANGE_MIN_STEP ? PROMETHEUS_QUERY_RANGE_MIN_STEP : step;
2085
- },
2086
- getStartAndEndDates(timeRange) {
2087
- timeRange.type = !!timeRange.type ? timeRange.type : "absolute";
2088
- if (timeRange.type === "absolute") return {
2089
- type: "absolute",
2090
- start: timeRange["start"],
2091
- end: timeRange["end"]
2092
- };
2093
- else if (timeRange.type === "relative") return {
2094
- type: "absolute",
2095
- start: new Date((/* @__PURE__ */ new Date()).getTime() + timeRange.start),
2096
- end: new Date((/* @__PURE__ */ new Date()).getTime() + timeRange.end)
2097
- };
2098
- throw new Error("Unexpected options.timeRange value.");
2099
- },
2100
- executeQueries: (prometheus, queries, start, end, step) => {
2101
- const haveDirectPrometheusRequests = queries.find((q) => typeof q === "string") != null;
2102
- const p = !!prometheus && haveDirectPrometheusRequests ? new import_prometheus_query_umd.PrometheusDriver(prometheus) : null;
2103
- return queries.map((query) => {
2104
- if (typeof query === "string") return p.rangeQuery(query, start, end, step);
2105
- return query(start, end, step).then((data) => import_prometheus_query_umd.QueryResult.fromJSON(data));
2106
- });
2107
- }
2108
- };
2109
- var ChartDatasourcePrometheusPluginNoDataMsg = class {
2110
- constructor() {
2111
- this.message = "No data to display";
2112
- this.font = "16px normal 'Helvetica Nueue'";
2113
- this.textAlign = "center";
2114
- this.textBaseline = "middle";
2115
- this.direction = "ltr";
2116
- }
2117
- };
2118
- var ChartDatasourcePrometheusPluginErrorMsg = class {
2119
- constructor() {
2120
- this.message = null;
2121
- this.font = "16px normal 'Helvetica Nueue'";
2122
- this.textAlign = "center";
2123
- this.textBaseline = "middle";
2124
- this.direction = "ltr";
2125
- }
2126
- };
2127
- var ChartDatasourcePrometheusPluginLoadingMsg = class {
2128
- constructor() {
2129
- this.message = "Loading data...";
2130
- this.font = "16px normal 'Helvetica Nueue'";
2131
- this.textAlign = "center";
2132
- this.textBaseline = "middle";
2133
- this.direction = "ltr";
2134
- }
2135
- };
2136
- const colorList = [
2137
- "rgba(255, 99, 132, 1)",
2138
- "rgba(54, 162, 235, 1)",
2139
- "rgba(255, 206, 86, 1)",
2140
- "rgba(75, 192, 192, 1)",
2141
- "rgba(153, 102, 255, 1)",
2142
- "rgba(255, 159, 64, 1)"
2143
- ];
2144
- var ChartDatasourcePrometheusPluginOptions = class {
2145
- constructor() {
2146
- /**
2147
- * Chart visualization type
2148
- */
2149
- this.chartType = "timeseries";
2150
- /**
2151
- * Options for Prometheus requests
2152
- */
2153
- this.prometheus = null;
2154
- /**
2155
- * Options for designing Charts
2156
- * See https://learnui.design/tools/data-color-picker.html#palette
2157
- */
2158
- this.fillGaps = false;
2159
- this.tension = .4;
2160
- this.cubicInterpolationMode = "default";
2161
- this.stepped = false;
2162
- this.fill = false;
2163
- this.stacked = false;
2164
- this.borderWidth = 3;
2165
- this.borderColor = colorList;
2166
- this.backgroundColor = colorList;
2167
- this.noDataMsg = new ChartDatasourcePrometheusPluginNoDataMsg();
2168
- this.errorMsg = new ChartDatasourcePrometheusPluginErrorMsg();
2169
- this.loadingMsg = new ChartDatasourcePrometheusPluginLoadingMsg();
2170
- this.findInLabelMap = null;
2171
- this.findInBorderColorMap = null;
2172
- this.findInBackgroundColorMap = null;
2173
- this.dataSetHook = null;
2174
- }
2175
- /**
2176
- * Compute a step for range_query (interval between 2 points in second)
2177
- */
2178
- assertPluginOptions() {
2179
- if (!this.query) throw new Error("options.query is undefined");
2180
- if (!this.timeRange) throw new Error("options.timeRange is undefined");
2181
- if (this.timeRange.start == null) throw new Error("options.timeRange.start is undefined");
2182
- if (this.timeRange.end == null) throw new Error("options.timeRange.end is undefined");
2183
- if (typeof this.timeRange != "object") throw new Error("options.timeRange must be a object");
2184
- if (typeof this.timeRange.type != "string") throw new Error("options.timeRange.type must be a string");
2185
- if (this.timeRange.type != "relative" && this.timeRange.type != "absolute") throw new Error("options.timeRange.type must be either \"relative\" or \"absolute\"");
2186
- if (!(typeof this.timeRange.start == "number" || typeof this.timeRange.start == "object" && this.timeRange.start.constructor.name == "Date")) throw new Error("options.timeRange.start must be a Date object (absolute) or integer (relative)");
2187
- if (!(typeof this.timeRange.end == "number" || typeof this.timeRange.end == "object" && this.timeRange.end.constructor.name == "Date")) throw new Error("options.timeRange.end must be a Date object (absolute) or integer (relative)");
2188
- if (this.timeRange["msUpdateInterval"] != null && typeof this.timeRange["msUpdateInterval"] != "number") throw new Error("options.timeRange.msUpdateInterval must be a integer");
2189
- if (this.timeRange["msUpdateInterval"] != null && this.timeRange["msUpdateInterval"] < 1e3) throw new Error("options.timeRange.msUpdateInterval must be greater than 1s.");
2190
- }
2191
- getQueries() {
2192
- var _a, _b;
2193
- if (((_b = (_a = this.query) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) != "Array") return [this.query];
2194
- return this.query;
2195
- }
2196
- };
2197
- function setTimeAxesOptions(chart) {
2198
- const options = chart.config.options.plugins["datasource-prometheus"];
2199
- if (options && options.chartType === "stat") return;
2200
- chart.config.options.scales = !!chart.config.options.scales ? chart.config.options.scales : {};
2201
- chart.config.options.scales.x = !!chart.config.options.scales.x ? chart.config.options.scales.x : {};
2202
- chart.config.options.scales.y = !!chart.config.options.scales.y ? chart.config.options.scales.y : {};
2203
- const { ticks, time } = JSON.parse(JSON.stringify(chart.config.options.scales.x));
2204
- Object.assign(chart.config.options.scales.x, {
2205
- type: "timeseries",
2206
- ticks: Object.assign({
2207
- maxRotation: 0,
2208
- minRotation: 0,
2209
- major: { enabled: true }
2210
- }, ticks),
2211
- stacked: options.stacked,
2212
- time: Object.assign({ minUnit: "second" }, time)
2213
- });
2214
- Object.assign(chart.config.options.scales.y, { stacked: options.stacked });
2215
- }
2216
- function fillGaps(chart, start, end, step, options) {
2217
- let minStep = options.timeRange.minStep || step;
2218
- minStep = minStep >= step ? minStep : step;
2219
- chart.data.datasets.forEach((dataSet, index) => {
2220
- for (let i = dataSet.data.length - 2; i > 0; i--) if (dataSet.data[i + 1]["x"] - dataSet.data[i]["x"] > 1100 * minStep) for (let steps = (dataSet.data[i + 1]["x"] - dataSet.data[i]["x"]) / (minStep * 1e3); steps > 1; steps--) {
2221
- const value = {
2222
- x: /* @__PURE__ */ new Date(dataSet.data[i + 1]["x"].getTime() - minStep * 1e3),
2223
- v: NaN
2224
- };
2225
- dataSet.data.splice(i + 1, 0, value);
2226
- }
2227
- if (Math.abs(start.getTime() - dataSet.data[0]["x"]) > 1100 * minStep) for (let i = Math.abs(start.getTime() - dataSet.data[0]["x"]) / (minStep * 1e3); i > 1; i--) chart.data.datasets[index].data.unshift({
2228
- x: /* @__PURE__ */ new Date(dataSet.data[0]["x"].getTime() - minStep * 1e3),
2229
- v: NaN
2230
- });
2231
- if (Math.abs(end.getTime() - dataSet.data[dataSet.data.length - 1]["x"]) > 1100 * minStep) for (let i = Math.abs(end.getTime() - dataSet.data[dataSet.data.length - 1]["x"]) / (minStep * 1e3); i > 1; i--) chart.data.datasets[index].data.push({
2232
- x: new Date(dataSet.data[chart.data.datasets[index].data.length - 1]["x"].getTime() + minStep * 1e3),
2233
- v: NaN
2234
- });
2235
- });
2236
- }
2237
- function selectLabel(options, serie, i) {
2238
- const defaultValue = serie.metric.toString();
2239
- if (options.findInLabelMap) return options.findInLabelMap(serie.metric) || defaultValue;
2240
- return defaultValue;
2241
- }
2242
- function selectBackGroundColor(options, serie, i) {
2243
- const defaultValue = !options.fill ? "transparent" : options.backgroundColor[i % options.backgroundColor.length];
2244
- if (options.findInBackgroundColorMap) return options.findInBackgroundColorMap(serie.metric) || defaultValue;
2245
- return defaultValue;
2246
- }
2247
- function selectBorderColor(options, serie, i) {
2248
- const defaultValue = options.borderColor[i % options.borderColor.length];
2249
- if (options.findInBorderColorMap) return options.findInBorderColorMap(serie.metric) || defaultValue;
2250
- return defaultValue;
2251
- }
2252
- var ChartDatasourcePrometheusPluginInternals = class {
2253
- constructor() {
2254
- this.loading = false;
2255
- this.rendering = false;
2256
- this.updateInterval = null;
2257
- this.error = null;
2258
- }
2259
- };
2260
- var ChartDatasourcePrometheusPlugin = class {
2261
- constructor() {
2262
- this.id = "datasource-prometheus";
2263
- }
2264
- beforeInit(chart, options) {
2265
- chart["datasource-prometheus"] = new ChartDatasourcePrometheusPluginInternals();
2266
- }
2267
- afterInit(chart, args, _options) {
2268
- if (!_options) throw "ChartDatasourcePrometheusPlugin.options is undefined";
2269
- const options = Object.assign(new ChartDatasourcePrometheusPluginOptions(), _options);
2270
- if (options.chartType === "stat");
2271
- else if (chart.config["type"] !== "line" && chart.config["type"] !== "bar") throw "ChartDatasourcePrometheusPlugin is only compatible with Line chart\nFeel free to contribute for more!";
2272
- options.assertPluginOptions();
2273
- if (!!options && !!options.timeRange) if (!!options.timeRange.msUpdateInterval) chart["datasource-prometheus"].updateInterval = setInterval(() => {
2274
- chart.update();
2275
- }, options.timeRange.msUpdateInterval);
2276
- else chart.update();
2277
- }
2278
- beforeUpdate(chart, args, _options) {
2279
- if (!!chart["datasource-prometheus"] && (chart["datasource-prometheus"].loading === true || chart["datasource-prometheus"].rendering === true)) return;
2280
- const options = Object.assign(new ChartDatasourcePrometheusPluginOptions(), _options);
2281
- const prometheus = options.prometheus;
2282
- const queries = options.getQueries();
2283
- const { start, end } = datasource.getStartAndEndDates(options.timeRange);
2284
- const expectedStep = options.timeRange.step || datasource.getPrometheusStepAuto(start, end, chart.width);
2285
- const minStep = options.timeRange.minStep || expectedStep;
2286
- const step = minStep >= expectedStep ? minStep : expectedStep;
2287
- if (!!chart["datasource-prometheus"] && chart["datasource-prometheus"].step == step && chart["datasource-prometheus"].start == start && chart["datasource-prometheus"].end == end) return;
2288
- chart["datasource-prometheus"].step = step;
2289
- chart["datasource-prometheus"].start = start;
2290
- chart["datasource-prometheus"].end = end;
2291
- chart["datasource-prometheus"].error = null;
2292
- const reqs = datasource.executeQueries(prometheus, queries, start, end, step);
2293
- let isHiddenMap = {};
2294
- for (let i = 0; i < chart.data.datasets.length; i++) {
2295
- const oldDataSet = chart.data.datasets[i];
2296
- isHiddenMap[oldDataSet.label] = !chart.isDatasetVisible(i);
2297
- }
2298
- chart["datasource-prometheus"].loading = true;
2299
- this.updateMessage(chart, _options);
2300
- Promise.all(reqs).then((results) => {
2301
- if (options.chartType === "stat") {
2302
- const statData = results.reduce((stats, result, queryIndex) => {
2303
- return stats.concat(result.result.map((serie, i) => {
2304
- const values = serie.values;
2305
- if (values.length === 0) return null;
2306
- const latestValue = values[values.length - 1];
2307
- const previousValue = values.length > 1 ? values[values.length - 2] : null;
2308
- const percentChange = previousValue ? (latestValue.value - previousValue.value) / previousValue.value * 100 : null;
2309
- return {
2310
- label: selectLabel(options, serie),
2311
- value: latestValue.value,
2312
- percentChange,
2313
- sparklineData: values.slice(-20),
2314
- backgroundColor: selectBackGroundColor(options, serie, i),
2315
- borderColor: selectBorderColor(options, serie, i)
2316
- };
2317
- }).filter(Boolean));
2318
- }, []);
2319
- chart["datasource-prometheus"].statData = statData;
2320
- chart.data.datasets = [];
2321
- } else {
2322
- const datasets = results.reduce((datasets, result, queryIndex) => {
2323
- const seriesCount = datasets.length;
2324
- const data = result.result.map((serie, i) => {
2325
- return {
2326
- tension: options.tension,
2327
- cubicInterpolationMode: options.cubicInterpolationMode || "default",
2328
- stepped: options.stepped,
2329
- fill: options.fill || false,
2330
- label: selectLabel(options, serie),
2331
- data: serie.values.map((v, j) => {
2332
- return {
2333
- x: v.time,
2334
- y: v.value
2335
- };
2336
- }),
2337
- backgroundColor: selectBackGroundColor(options, serie, seriesCount + i),
2338
- borderColor: selectBorderColor(options, serie, seriesCount + i),
2339
- borderWidth: options.borderWidth,
2340
- hidden: isHiddenMap[selectLabel(options, serie)] || false
2341
- };
2342
- });
2343
- return datasets.concat(...data);
2344
- }, []);
2345
- chart.data.datasets = datasets;
2346
- if (chart.data.datasets.length > 0) {
2347
- if (options.fillGaps) fillGaps(chart, start, end, step, options);
2348
- if (options.dataSetHook) chart.data.datasets = options.dataSetHook(chart.data.datasets);
2349
- setTimeAxesOptions(chart);
2350
- }
2351
- }
2352
- this.resumeRendering(chart);
2353
- }).catch((err) => {
2354
- chart.data.datasets = [];
2355
- chart["datasource-prometheus"].error = "Failed to fetch data";
2356
- setTimeAxesOptions(chart);
2357
- this.resumeRendering(chart);
2358
- throw err;
2359
- });
2360
- return false;
2361
- }
2362
- afterDraw(chart, args, _options) {
2363
- const options = Object.assign(new ChartDatasourcePrometheusPluginOptions(), _options);
2364
- if (options.chartType === "stat" && chart["datasource-prometheus"].statData) this.renderStatVisualization(chart, chart["datasource-prometheus"].statData, options);
2365
- this.updateMessage(chart, _options);
2366
- }
2367
- updateMessage(chart, _options) {
2368
- var _a;
2369
- const options = Object.assign(new ChartDatasourcePrometheusPluginOptions(), _options);
2370
- if (chart["datasource-prometheus"].error != null) this.writeText(chart, ((_a = options.errorMsg) === null || _a === void 0 ? void 0 : _a.message) || chart["datasource-prometheus"].error, (ctx) => {
2371
- ctx.direction = options.errorMsg.direction;
2372
- ctx.textAlign = options.errorMsg.textAlign;
2373
- ctx.textBaseline = options.errorMsg.textBaseline;
2374
- ctx.font = "16px normal 'Helvetica Nueue'";
2375
- });
2376
- else if (chart["datasource-prometheus"].loading == true) {
2377
- if (options.loadingMsg) this.writeText(chart, options.loadingMsg.message, (ctx) => {
2378
- ctx.direction = options.loadingMsg.direction;
2379
- ctx.textAlign = options.loadingMsg.textAlign;
2380
- ctx.textBaseline = options.loadingMsg.textBaseline;
2381
- ctx.font = options.loadingMsg.font;
2382
- });
2383
- } else if (chart.data.datasets.length == 0 && (!options.chartType || options.chartType !== "stat" || !chart["datasource-prometheus"].statData || chart["datasource-prometheus"].statData.length === 0)) this.writeText(chart, options.noDataMsg.message, (ctx) => {
2384
- ctx.direction = options.noDataMsg.direction;
2385
- ctx.textAlign = options.noDataMsg.textAlign;
2386
- ctx.textBaseline = options.noDataMsg.textBaseline;
2387
- ctx.font = options.noDataMsg.font;
2388
- });
2389
- }
2390
- writeText(chart, message, fn) {
2391
- const ctx = chart.ctx;
2392
- const width = chart.width;
2393
- const height = chart.height;
2394
- chart.clear();
2395
- ctx.save();
2396
- if (fn) fn(ctx);
2397
- ctx.fillText(message, width / 2, height / 2);
2398
- ctx.restore();
2399
- }
2400
- afterDestroy(chart, args, _options) {
2401
- if (!!chart["datasource-prometheus"].updateInterval) clearInterval(chart["datasource-prometheus"].updateInterval);
2402
- }
2403
- resumeRendering(chart) {
2404
- chart["datasource-prometheus"].loading = false;
2405
- chart["datasource-prometheus"].rendering = true;
2406
- chart.update();
2407
- chart["datasource-prometheus"].rendering = false;
2408
- }
2409
- renderStatVisualization(chart, statData, options) {
2410
- const ctx = chart.ctx;
2411
- const width = chart.width;
2412
- const height = chart.height;
2413
- chart.clear();
2414
- const statsPerRow = Math.ceil(Math.sqrt(statData.length));
2415
- const statWidth = width / statsPerRow;
2416
- const statHeight = height / Math.ceil(statData.length / statsPerRow);
2417
- statData.forEach((stat, index) => {
2418
- const row = Math.floor(index / statsPerRow);
2419
- const x = index % statsPerRow * statWidth;
2420
- const y = row * statHeight;
2421
- ctx.save();
2422
- if (stat.sparklineData && stat.sparklineData.length > 1) this.drawSparkline(ctx, stat.sparklineData, x, y, statWidth, statHeight, stat.borderColor);
2423
- ctx.fillStyle = stat.borderColor || "#333";
2424
- ctx.font = "bold 48px Arial";
2425
- ctx.textAlign = "center";
2426
- ctx.textBaseline = "middle";
2427
- const valueText = this.formatStatValue(stat.value);
2428
- ctx.fillText(valueText, x + statWidth / 2, y + statHeight / 2 - 20);
2429
- if (stat.percentChange !== null) {
2430
- ctx.font = "24px Arial";
2431
- ctx.fillStyle = stat.percentChange >= 0 ? "#28a745" : "#dc3545";
2432
- const changeText = `${stat.percentChange >= 0 ? "+" : ""}${stat.percentChange.toFixed(1)}%`;
2433
- ctx.fillText(changeText, x + statWidth / 2, y + statHeight / 2 + 30);
2434
- }
2435
- ctx.font = "16px Arial";
2436
- ctx.fillStyle = "#666";
2437
- ctx.fillText(stat.label, x + statWidth / 2, y + statHeight - 20);
2438
- ctx.restore();
2439
- });
2440
- }
2441
- drawSparkline(ctx, data, x, y, width, height, color) {
2442
- if (data.length < 2) return;
2443
- const values = data.map((d) => d.value);
2444
- const minValue = Math.min(...values);
2445
- const valueRange = Math.max(...values) - minValue || 1;
2446
- ctx.save();
2447
- ctx.globalAlpha = .3;
2448
- ctx.strokeStyle = color || "#007bff";
2449
- ctx.lineWidth = 2;
2450
- ctx.beginPath();
2451
- data.forEach((point, index) => {
2452
- const px = x + index / (data.length - 1) * width;
2453
- const py = y + height - (point.value - minValue) / valueRange * (height * .6);
2454
- if (index === 0) ctx.moveTo(px, py);
2455
- else ctx.lineTo(px, py);
2456
- });
2457
- ctx.stroke();
2458
- ctx.restore();
2459
- }
2460
- formatStatValue(value) {
2461
- if (value >= 1e6) return (value / 1e6).toFixed(1) + "M";
2462
- else if (value >= 1e3) return (value / 1e3).toFixed(1) + "K";
2463
- else return value.toFixed(1);
2464
- }
2465
- };
2466
- var index = new ChartDatasourcePrometheusPlugin();
2467
- //#endregion
2468
321
  //#region src/helpers.ts
2469
322
  const getQueriesTimeRange = (period, data) => {
2470
323
  const currentDate = dayjs();
@@ -2517,38 +370,76 @@ const GradientPlugin = {
2517
370
  };
2518
371
  //#endregion
2519
372
  //#region src/components/PrometheusChart/index.tsx
2520
- Chart$1.register(CategoryScale, LinearScale, TimeScale, PointElement, LineElement, Filler, Legend, Tooltip);
2521
- Chart$1.defaults.font.size = 12;
2522
- Chart$1.defaults.color = "rgba(255, 255, 255, 0.75)";
373
+ Chart.register(CategoryScale, LinearScale, TimeScale, PointElement, LineElement, Filler, Legend, Tooltip);
374
+ Chart.defaults.font.size = 12;
375
+ Chart.defaults.color = "rgba(255, 255, 255, 0.75)";
376
+ const COLORS = [
377
+ "#36A2EB",
378
+ "#FF6384",
379
+ "#4BC0C0",
380
+ "#FF9F40",
381
+ "#9966FF",
382
+ "#FFCD56",
383
+ "#C9CBCF",
384
+ "#7BC8A4",
385
+ "#E7E9ED",
386
+ "#FF6B6B"
387
+ ];
2523
388
  const PrometheusChart = ({ data, settings }) => {
2524
389
  const chart = useRef(null);
2525
- const [chartData] = useState({
390
+ const [chartData, setChartData] = useState({
2526
391
  labels: [],
2527
392
  datasets: []
2528
393
  });
2529
394
  const [queriesTimeRange, setQueriesTimeRange] = useState(null);
2530
395
  const [timeLabels, setTimeLabels] = useState([]);
396
+ const hiddenSeriesRef = useRef({});
397
+ const fetchData = useCallback(async (timeRange) => {
398
+ if (!settings.endpointUrl || !settings.prometheusQueries?.length) return;
399
+ const driver = new PrometheusDriver({ endpoint: settings.endpointUrl });
400
+ const start = new Date(timeRange.startedAt);
401
+ const end = timeRange.finishedAt ? new Date(timeRange.finishedAt) : /* @__PURE__ */ new Date();
402
+ const step = 30;
403
+ if (chart.current) for (let i = 0; i < chart.current.data.datasets.length; i++) {
404
+ const ds = chart.current.data.datasets[i];
405
+ if (ds.label) hiddenSeriesRef.current[ds.label] = !chart.current.isDatasetVisible(i);
406
+ }
407
+ const queries = settings.prometheusQueries.map(({ query }) => query);
408
+ const results = await Promise.all(queries.map((query) => driver.rangeQuery(query, start, end, step)));
409
+ let seriesIndex = 0;
410
+ setChartData({
411
+ labels: [],
412
+ datasets: results.flatMap((result) => result.result.map((serie) => {
413
+ const idx = seriesIndex++;
414
+ const label = serie.metric.toString();
415
+ return {
416
+ label,
417
+ data: serie.values.map((v) => ({
418
+ x: v.time,
419
+ y: v.value
420
+ })),
421
+ fill: true,
422
+ tension: .4,
423
+ borderColor: COLORS[idx % COLORS.length],
424
+ backgroundColor: COLORS[idx % COLORS.length],
425
+ borderWidth: 3,
426
+ pointRadius: 0,
427
+ hidden: hiddenSeriesRef.current[label] || false
428
+ };
429
+ }))
430
+ });
431
+ }, [settings.endpointUrl, settings.prometheusQueries]);
2531
432
  useEffect(() => {
2532
- if (chart.current) chart.current.update();
2533
- if (queriesTimeRange) setTimeLabels(generateTimeRange(dayjs(queriesTimeRange.startedAt), dayjs(queriesTimeRange.finishedAt), "minutes", 15));
2534
- }, [queriesTimeRange]);
433
+ if (queriesTimeRange) {
434
+ setTimeLabels(generateTimeRange(dayjs(queriesTimeRange.startedAt), dayjs(queriesTimeRange.finishedAt), "minutes", 15));
435
+ fetchData(queriesTimeRange);
436
+ }
437
+ }, [queriesTimeRange, fetchData]);
2535
438
  useEffect(() => {
2536
439
  setQueriesTimeRange(getQueriesTimeRange(settings.queriesPeriod, data));
2537
440
  if (settings?.queriesPeriod === QueriesPeriod.CURRENT_SHIFT) {
2538
441
  const intervalId = setInterval(() => {
2539
- if (chart.current && chart.current.options.plugins) {
2540
- const nextTimeRange = getQueriesTimeRange(settings.queriesPeriod, data);
2541
- setQueriesTimeRange(nextTimeRange);
2542
- chart.current.options.plugins["datasource-prometheus"] = {
2543
- ...chart.current.options.plugins["datasource-prometheus"],
2544
- timeRange: {
2545
- type: "absolute",
2546
- start: nextTimeRange?.startedAt,
2547
- end: nextTimeRange?.finishedAt
2548
- }
2549
- };
2550
- chart.current.update();
2551
- }
442
+ setQueriesTimeRange(getQueriesTimeRange(settings.queriesPeriod, data));
2552
443
  }, 3e4);
2553
444
  return () => {
2554
445
  clearInterval(intervalId);
@@ -2556,11 +447,10 @@ const PrometheusChart = ({ data, settings }) => {
2556
447
  }
2557
448
  return () => {};
2558
449
  }, [data, settings]);
2559
- return queriesTimeRange && /* @__PURE__ */ jsx(Chart, {
450
+ return queriesTimeRange && /* @__PURE__ */ jsx(Line, {
2560
451
  ref: chart,
2561
- type: "line",
2562
452
  data: chartData,
2563
- plugins: [index, GradientPlugin],
453
+ plugins: [GradientPlugin],
2564
454
  options: {
2565
455
  scales: {
2566
456
  x: {
@@ -2590,44 +480,30 @@ const PrometheusChart = ({ data, settings }) => {
2590
480
  elements: { point: { radius: 0 } },
2591
481
  maintainAspectRatio: false,
2592
482
  animation: { duration: 0 },
2593
- plugins: {
2594
- "datasource-prometheus": {
2595
- prometheus: { endpoint: settings.endpointUrl },
2596
- query: settings.prometheusQueries.map(({ query }) => query),
2597
- timeRange: {
2598
- type: "absolute",
2599
- start: queriesTimeRange.startedAt,
2600
- end: queriesTimeRange.finishedAt,
2601
- step: 30
2602
- },
2603
- fillGaps: true,
2604
- fill: true
2605
- },
2606
- legend: { labels: { filter: (item) => {
2607
- const regex = /{(?:[^{}]*)*}/;
2608
- const paramsMatch = item.text.match(regex);
2609
- const datasetIndex = item.datasetIndex ?? 0;
2610
- const queryDisplayName = settings?.prometheusQueries[datasetIndex]?.displayName;
2611
- if (queryDisplayName) {
2612
- if (paramsMatch && paramsMatch.index !== 0) {
2613
- const queryParams = eval("(" + paramsMatch[0].replaceAll("=", ":") + ")");
2614
- const queryParamsValues = Object.values(pick(queryParams, settings.displayedQueryParams)).join(" - ");
2615
- if (queryParamsValues) item.text = `${queryDisplayName} - ${queryParamsValues}`;
2616
- else item.text = queryDisplayName;
2617
- }
2618
- } else {
2619
- const replaceAfter = (text, index, replacement) => {
2620
- return text.substring(0, index) + replacement;
2621
- };
2622
- if (paramsMatch && paramsMatch.index !== 0) {
2623
- const matchIndex = paramsMatch.index || 0;
2624
- const queryParams = eval("(" + paramsMatch[0].replaceAll("=", ":") + ")");
2625
- item.text = replaceAfter(item.text, matchIndex, JSON.stringify(pick(queryParams, settings.displayedQueryParams)));
2626
- } else item.text = settings?.prometheusQueries[datasetIndex].query;
483
+ plugins: { legend: { labels: { filter: (item) => {
484
+ const regex = /{(?:[^{}]*)*}/;
485
+ const paramsMatch = item.text.match(regex);
486
+ const datasetIndex = item.datasetIndex ?? 0;
487
+ const queryDisplayName = settings?.prometheusQueries[datasetIndex]?.displayName;
488
+ if (queryDisplayName) {
489
+ if (paramsMatch && paramsMatch.index !== 0) {
490
+ const queryParams = eval("(" + paramsMatch[0].replaceAll("=", ":") + ")");
491
+ const queryParamsValues = Object.values(pick(queryParams, settings.displayedQueryParams)).join(" - ");
492
+ if (queryParamsValues) item.text = `${queryDisplayName} - ${queryParamsValues}`;
493
+ else item.text = queryDisplayName;
2627
494
  }
2628
- return true;
2629
- } } }
2630
- }
495
+ } else {
496
+ const replaceAfter = (text, index, replacement) => {
497
+ return text.substring(0, index) + replacement;
498
+ };
499
+ if (paramsMatch && paramsMatch.index !== 0) {
500
+ const matchIndex = paramsMatch.index || 0;
501
+ const queryParams = eval("(" + paramsMatch[0].replaceAll("=", ":") + ")");
502
+ item.text = replaceAfter(item.text, matchIndex, JSON.stringify(pick(queryParams, settings.displayedQueryParams)));
503
+ } else item.text = settings?.prometheusQueries[datasetIndex].query;
504
+ }
505
+ return true;
506
+ } } } }
2631
507
  }
2632
508
  });
2633
509
  };