@kong-ui-public/analytics-metric-provider 11.3.19 → 11.3.20

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.
@@ -1,12 +1,12 @@
1
- import { ref as Y, watchEffect as Fe, computed as g, getCurrentScope as xe, reactive as qe, onScopeDispose as Pe, watch as Ue, isReadonly as ze, toRefs as Ke, defineComponent as W, inject as Ae, toRef as G, provide as $e, renderSlot as De, resolveComponent as we, openBlock as R, createElementBlock as S, normalizeClass as z, createElementVNode as x, unref as T, createBlock as q, resolveDynamicComponent as re, createCommentVNode as V, withCtx as ge, createTextVNode as be, toDisplayString as b, createVNode as F, Fragment as he, renderList as Be, mergeProps as Xe, normalizeProps as Ge, guardReactiveProps as je } from "vue";
2
- import { stripUnknownFilters as He, queryableExploreDimensions as Ye } from "@kong-ui-public/analytics-utilities";
3
- import { createI18n as Qe, i18nTComponent as We } from "@kong-ui-public/i18n";
1
+ import { ref as W, watchEffect as ze, computed as m, getCurrentScope as Ke, reactive as Be, onScopeDispose as Xe, watch as Ge, isReadonly as He, toRefs as je, defineComponent as Z, inject as Ve, toRef as j, provide as Ye, renderSlot as Me, resolveComponent as Ne, openBlock as R, createElementBlock as S, normalizeClass as z, createElementVNode as x, unref as T, createBlock as $, resolveDynamicComponent as ne, createCommentVNode as V, withCtx as pe, createTextVNode as ke, toDisplayString as b, createVNode as F, Fragment as Re, renderList as Qe, mergeProps as We, normalizeProps as Je, guardReactiveProps as Ze } from "vue";
2
+ import { stripUnknownFilters as er, queryableExploreDimensions as rr } from "@kong-ui-public/analytics-utilities";
3
+ import { createI18n as tr, i18nTComponent as nr } from "@kong-ui-public/i18n";
4
4
  import "axios";
5
- import { useAnalyticsConfigStore as Je } from "@kong-ui-public/analytics-config-store";
6
- import { TrendUpIcon as Ze, TrendDownIcon as er, IndeterminateSmallIcon as Oe, VitalsIcon as rr, CloudUploadIcon as tr, WarningOutlineIcon as nr, ResponseIcon as ar, InfoIcon as ir, WarningIcon as Le, EqualIcon as or } from "@kong/icons";
7
- const sr = {
5
+ import { useAnalyticsConfigStore as ar } from "@kong-ui-public/analytics-config-store";
6
+ import { TrendUpIcon as ir, TrendDownIcon as or, IndeterminateSmallIcon as Fe, VitalsIcon as sr, CloudUploadIcon as ur, WarningOutlineIcon as lr, ResponseIcon as cr, InfoIcon as dr, WarningIcon as xe, EqualIcon as fr } from "@kong/icons";
7
+ const vr = {
8
8
  notAvailable: "N/A"
9
- }, ur = {
9
+ }, mr = {
10
10
  small: {
11
11
  traffic: "Requests",
12
12
  errorRate: "Error rate",
@@ -25,7 +25,7 @@ const sr = {
25
25
  averageLatency: "Average latency",
26
26
  p99Latency: "P99 latency"
27
27
  }
28
- }, lr = {
28
+ }, yr = {
29
29
  custom_days: "vs previous {numDays, plural, =1 {day} other {# days}}",
30
30
  custom_hours: "vs previous {numHours, plural, =1 {hour} other {# hours}}",
31
31
  custom_minutes: "vs previous {numMinutes, plural, =1 {minute} other {# minutes}}",
@@ -42,101 +42,101 @@ const sr = {
42
42
  previous_week: "vs previous time period",
43
43
  previous_month: "vs previous time period",
44
44
  previous_quarter: "vs previous quarter"
45
- }, cr = {
46
- general: sr,
47
- metricCard: ur,
48
- trendRange: lr
45
+ }, gr = {
46
+ general: vr,
47
+ metricCard: mr,
48
+ trendRange: yr
49
49
  };
50
- function dr() {
51
- const e = Qe("en-us", cr);
50
+ function hr() {
51
+ const e = tr("en-us", gr);
52
52
  return {
53
53
  i18n: e,
54
- i18nT: We(e)
54
+ i18nT: nr(e)
55
55
  // Translation component <i18n-t>
56
56
  };
57
57
  }
58
- const fr = 2, B = ["1XX", "2XX", "3XX", "4XX", "5XX"], pe = ["4XX", "5XX"], gt = ["1XX", "2XX", "3XX"], vr = 30 * 1e3, mr = "analytics-query-provider";
59
- var Ve = /* @__PURE__ */ ((e) => (e.VALIDATING = "VALIDATING", e.VALIDATING_HAS_DATA = "VALIDATING_HAS_DATA", e.PENDING = "PENDING", e.SUCCESS = "SUCCESS", e.SUCCESS_HAS_DATA = "SUCCESS_HAS_DATA", e.ERROR = "ERROR", e.STALE_IF_ERROR = "STALE_IF_ERROR", e))(Ve || {});
60
- const yr = (e) => {
61
- var r, t, i, a, n;
58
+ const pr = 2, G = ["1XX", "2XX", "3XX", "4XX", "5XX"], Te = ["4XX", "5XX"], Tt = ["1XX", "2XX", "3XX"], Rr = 30 * 1e3, Tr = "analytics-query-provider";
59
+ var qe = /* @__PURE__ */ ((e) => (e.VALIDATING = "VALIDATING", e.VALIDATING_HAS_DATA = "VALIDATING_HAS_DATA", e.PENDING = "PENDING", e.SUCCESS = "SUCCESS", e.SUCCESS_HAS_DATA = "SUCCESS_HAS_DATA", e.ERROR = "ERROR", e.STALE_IF_ERROR = "STALE_IF_ERROR", e))(qe || {});
60
+ const Er = (e) => {
61
+ var r, t, a, i, n;
62
62
  return e ? !!// TODO: revisit: currently only the first check ever matters?
63
- ((r = Object.keys(e)) != null && r.length || (t = e.data) != null && t.length || (a = (i = e.data) == null ? void 0 : i.data) != null && a.length || !((n = e.data) != null && n.data) && typeof e.data == "object" && Object.keys(e == null ? void 0 : e.data).length) : !1;
63
+ ((r = Object.keys(e)) != null && r.length || (t = e.data) != null && t.length || (i = (a = e.data) == null ? void 0 : a.data) != null && i.length || !((n = e.data) != null && n.data) && typeof e.data == "object" && Object.keys(e == null ? void 0 : e.data).length) : !1;
64
64
  };
65
- function gr(e = Y({}), r, t, i = yr) {
66
- const a = Y(
65
+ function Sr(e = W({}), r, t, a = Er) {
66
+ const i = W(
67
67
  "PENDING"
68
68
  /* PENDING */
69
69
  );
70
- return Fe(() => {
71
- const n = i(e.value);
70
+ return ze(() => {
71
+ const n = a(e.value);
72
72
  if (e.value && n && t.value) {
73
- a.value = "VALIDATING_HAS_DATA";
73
+ i.value = "VALIDATING_HAS_DATA";
74
74
  return;
75
75
  }
76
76
  if (e.value && t.value) {
77
- a.value = "VALIDATING";
77
+ i.value = "VALIDATING";
78
78
  return;
79
79
  }
80
80
  if (e.value && r.value) {
81
- a.value = "STALE_IF_ERROR";
81
+ i.value = "STALE_IF_ERROR";
82
82
  return;
83
83
  }
84
84
  if (e.value === void 0 && !r.value) {
85
- a.value = "PENDING";
85
+ i.value = "PENDING";
86
86
  return;
87
87
  }
88
88
  if (e.value && !r.value && n) {
89
- a.value = "SUCCESS_HAS_DATA";
89
+ i.value = "SUCCESS_HAS_DATA";
90
90
  return;
91
91
  }
92
92
  if (e.value && !r.value) {
93
- a.value = "SUCCESS";
93
+ i.value = "SUCCESS";
94
94
  return;
95
95
  }
96
- e.value === void 0 && r && (a.value = "ERROR");
96
+ e.value === void 0 && r && (i.value = "ERROR");
97
97
  }), {
98
- state: a,
99
- swrvState: Ve
98
+ state: i,
99
+ swrvState: qe
100
100
  };
101
101
  }
102
- const L = Symbol("default"), te = "status_code_grouped", Re = (e, r, t, i, a) => {
103
- e[r][t] || (e[r][t] = {}), e[r][t][i] = a;
102
+ const L = Symbol("default"), ae = "status_code_grouped", Ee = (e, r, t, a, i) => {
103
+ e[r][t] || (e[r][t] = {}), e[r][t][a] = i;
104
104
  };
105
- function hr(e, r) {
106
- var d;
107
- const t = ((d = e.meta.metric_names) == null ? void 0 : d[0]) || "", i = new Date(e.meta.start).getTime(), a = Object.keys(e.meta.display || {}), n = !!a.find((f) => f === te), l = a.find((f) => f !== te);
108
- return a.length > 2 || a.length > 1 && !n ? (console.error("Don't know how to work with provided dimensions:", a), {
105
+ function _r(e, r) {
106
+ var c;
107
+ const t = ((c = e.meta.metric_names) == null ? void 0 : c[0]) || "", a = new Date(e.meta.start).getTime(), i = Object.keys(e.meta.display || {}), n = !!i.find((d) => d === ae), s = i.find((d) => d !== ae);
108
+ return i.length > 2 || i.length > 1 && !n ? (console.error("Don't know how to work with provided dimensions:", i), {
109
109
  previous: { [L]: { [L]: 0 } },
110
110
  current: { [L]: { [L]: 0 } }
111
- }) : e.data.reduce((f, o) => {
112
- const s = o.event[t], u = l ? o.event[l] : L, c = n ? o.event[te] : L;
113
- return new Date(o.timestamp).getTime() === i && r ? Re(f, "previous", u, c, s) : Re(f, "current", u, c, s), f;
111
+ }) : e.data.reduce((d, o) => {
112
+ const l = o.event[t], u = s ? o.event[s] : L, f = n ? o.event[ae] : L;
113
+ return new Date(o.timestamp).getTime() === a && r ? Ee(d, "previous", u, f, l) : Ee(d, "current", u, f, l), d;
114
114
  }, {
115
115
  previous: {},
116
116
  current: {}
117
117
  });
118
118
  }
119
- function pr(e) {
120
- e.queryReady === void 0 && (e.queryReady = g(() => !0));
121
- const r = g(() => {
122
- var s, u;
119
+ function Cr(e) {
120
+ e.queryReady === void 0 && (e.queryReady = m(() => !0));
121
+ const r = m(() => {
122
+ var l, u;
123
123
  return {
124
124
  metrics: e.metrics.value,
125
125
  dimensions: [
126
- ...(s = e.dimensions) != null && s.length ? [...e.dimensions] : [],
126
+ ...(l = e.dimensions) != null && l.length ? [...e.dimensions] : [],
127
127
  ...e.withTrend.value ? ["time"] : []
128
128
  ],
129
129
  granularity: e.withTrend.value ? "trend" : void 0,
130
130
  ...(u = e.filter.value) != null && u.length ? { filters: e.filter.value } : {},
131
131
  time_range: e.timeRange.value
132
132
  };
133
- }), t = g(() => {
134
- var u, c, v, y;
133
+ }), t = m(() => {
134
+ var u, f, h, y;
135
135
  if (!((u = e.queryReady) != null && u.value))
136
136
  return null;
137
- const s = (c = e.filter) != null && c.value ? JSON.stringify(e.filter.value) : "";
138
- return `metric-fetcher-${JSON.stringify(e.timeRange.value)}-${(v = e.dimensions) == null ? void 0 : v.join("-")}-${(y = e.metrics.value) == null ? void 0 : y.join("-")}-${s}-${e.refreshCounter.value}`;
139
- }), { response: i, error: a, isValidating: n } = M.useRequest(
137
+ const l = (f = e.filter) != null && f.value ? JSON.stringify(e.filter.value) : "";
138
+ return `metric-fetcher-${JSON.stringify(e.timeRange.value)}-${(h = e.dimensions) == null ? void 0 : h.join("-")}-${(y = e.metrics.value) == null ? void 0 : y.join("-")}-${l}-${e.refreshCounter.value}`;
139
+ }), { response: a, error: i, isValidating: n } = M.useRequest(
140
140
  () => t.value,
141
141
  () => e.queryFn({
142
142
  // TODO: Use a type guard to validate that if the datasource is basic,
@@ -147,43 +147,43 @@ function pr(e) {
147
147
  {
148
148
  refreshInterval: e.refreshInterval,
149
149
  revalidateOnFocus: !1,
150
- errorRetryCount: fr
150
+ errorRetryCount: pr
151
151
  }
152
- ), { state: l, swrvState: d } = gr(i, a, n), f = g(() => {
153
- var s, u, c, v, y, _, p;
154
- return !((u = (s = i.value) == null ? void 0 : s.data) != null && u.length) || !((v = (c = i.value) == null ? void 0 : c.meta) != null && v.display) || !((p = (_ = (y = i.value) == null ? void 0 : y.meta) == null ? void 0 : _.metric_names) != null && p.length) ? { current: {}, previous: {} } : hr(i.value, e.withTrend.value);
155
- }), o = M.useTrendRange(e.withTrend, e.timeRange, g(() => {
156
- var s;
157
- return (s = i.value) == null ? void 0 : s.meta;
152
+ ), { state: s, swrvState: c } = Sr(a, i, n), d = m(() => {
153
+ var l, u, f, h, y, A, p;
154
+ return !((u = (l = a.value) == null ? void 0 : l.data) != null && u.length) || !((h = (f = a.value) == null ? void 0 : f.meta) != null && h.display) || !((p = (A = (y = a.value) == null ? void 0 : y.meta) == null ? void 0 : A.metric_names) != null && p.length) ? { current: {}, previous: {} } : _r(a.value, e.withTrend.value);
155
+ }), o = M.useTrendRange(e.withTrend, e.timeRange, m(() => {
156
+ var l;
157
+ return (l = a.value) == null ? void 0 : l.meta;
158
158
  }));
159
159
  return {
160
- isLoading: g(() => d.PENDING === l.value),
161
- hasError: g(() => d.ERROR === l.value),
162
- raw: i,
163
- mapped: f,
160
+ isLoading: m(() => c.PENDING === s.value),
161
+ hasError: m(() => c.ERROR === s.value),
162
+ raw: a,
163
+ mapped: d,
164
164
  trendRange: o
165
165
  };
166
166
  }
167
- const K = (e, r, t = L, i) => (i ?? [L]).reduce((n, l) => {
168
- const d = e[r][t];
169
- return d ? n + (d[l] || 0) : n;
167
+ const K = (e, r, t = L, a) => (a ?? [L]).reduce((n, s) => {
168
+ const c = e[r][t];
169
+ return c ? n + (c[s] || 0) : n;
170
170
  }, 0);
171
- function Rr(e) {
171
+ function Ir(e) {
172
172
  const {
173
173
  cardType: r,
174
174
  title: t,
175
- description: i,
176
- record: a,
175
+ description: a,
176
+ record: i,
177
177
  hasError: n,
178
- increaseIsBad: l,
179
- formatValueFn: d,
180
- trendRange: f
178
+ increaseIsBad: s,
179
+ formatValueFn: c,
180
+ trendRange: d
181
181
  } = e;
182
- return g(() => {
183
- let o = 0, s = 0;
184
- if (a != null && a.value)
182
+ return m(() => {
183
+ let o = 0, l = 0;
184
+ if (i != null && i.value)
185
185
  try {
186
- o = K(a.value, "current", e.lookupKey, e.sumGroupedValues), s = K(a.value, "previous", e.lookupKey, e.sumGroupedValues);
186
+ o = K(i.value, "current", e.lookupKey, e.sumGroupedValues), l = K(i.value, "previous", e.lookupKey, e.sumGroupedValues);
187
187
  } catch (u) {
188
188
  console.error(
189
189
  "Metric card data doesn't have the expected structure:",
@@ -194,163 +194,163 @@ function Rr(e) {
194
194
  cardType: r,
195
195
  hasError: n.value,
196
196
  currentValue: o,
197
- previousValue: s,
197
+ previousValue: l,
198
198
  title: t.value,
199
- description: i,
200
- increaseIsBad: !!l,
199
+ description: a,
200
+ increaseIsBad: !!s,
201
201
  // Coerce undefined to false
202
- formatValueFn: d,
203
- trendRange: f == null ? void 0 : f.value
202
+ formatValueFn: c,
203
+ trendRange: d == null ? void 0 : d.value
204
204
  };
205
205
  });
206
206
  }
207
- function Tr(e, r, t) {
208
- const { i18n: i } = M.useI18n(), a = 1e3 * 60, n = a * 60, l = n * 24, d = (o, s) => {
209
- let u = s - o;
207
+ function Ar(e, r, t) {
208
+ const { i18n: a } = M.useI18n(), i = 1e3 * 60, n = i * 60, s = n * 24, c = (o, l) => {
209
+ let u = l - o;
210
210
  e.value && (u /= 2);
211
- const c = u / l, v = u / n, y = u / a;
212
- return c >= 1 ? i.t("trendRange.custom_days", { numDays: Math.round(c) }) : v >= 1 ? i.t("trendRange.custom_hours", { numHours: Math.round(v) }) : y >= 1 ? i.t("trendRange.custom_minutes", { numMinutes: Math.round(y) }) : i.t("trendRange.custom_days", { numDays: Math.round(c) });
213
- }, f = () => {
214
- var o, s;
211
+ const f = u / s, h = u / n, y = u / i;
212
+ return f >= 1 ? a.t("trendRange.custom_days", { numDays: Math.round(f) }) : h >= 1 ? a.t("trendRange.custom_hours", { numHours: Math.round(h) }) : y >= 1 ? a.t("trendRange.custom_minutes", { numMinutes: Math.round(y) }) : a.t("trendRange.custom_days", { numDays: Math.round(f) });
213
+ }, d = () => {
214
+ var o, l;
215
215
  if ((o = t == null ? void 0 : t.value) != null && o.start && t.value.end)
216
216
  return {
217
217
  startMs: new Date(t.value.start).getTime(),
218
218
  endMs: new Date(t.value.end).getTime()
219
219
  };
220
- if (((s = r == null ? void 0 : r.value) == null ? void 0 : s.type) === "absolute" && r.value.start && r.value.end)
220
+ if (((l = r == null ? void 0 : r.value) == null ? void 0 : l.type) === "absolute" && r.value.start && r.value.end)
221
221
  return {
222
222
  startMs: new Date(r.value.start).getTime(),
223
223
  endMs: new Date(r.value.end).getTime()
224
224
  };
225
225
  };
226
- return g(() => {
227
- var o, s;
226
+ return m(() => {
227
+ var o, l;
228
228
  if (((o = r == null ? void 0 : r.value) == null ? void 0 : o.type) === "relative" && e.value)
229
- return i.t(`trendRange.${r.value.time_range}`);
230
- if (e.value || ((s = r == null ? void 0 : r.value) == null ? void 0 : s.type) === "absolute") {
231
- const u = f();
229
+ return a.t(`trendRange.${r.value.time_range}`);
230
+ if (e.value || ((l = r == null ? void 0 : r.value) == null ? void 0 : l.type) === "absolute") {
231
+ const u = d();
232
232
  if (u)
233
- return d(u.startMs, u.endMs);
233
+ return c(u.startMs, u.endMs);
234
234
  }
235
235
  return "";
236
236
  });
237
237
  }
238
- var ne = /* @__PURE__ */ new WeakMap(), Te = 0;
239
- function Er(e) {
238
+ var ie = /* @__PURE__ */ new WeakMap(), Se = 0;
239
+ function Dr(e) {
240
240
  if (!e.length)
241
241
  return "";
242
242
  for (var r = "arg", t = 0; t < e.length; ++t) {
243
- var i = void 0;
244
- e[t] === null || typeof e[t] != "object" && typeof e[t] != "function" ? typeof e[t] == "string" ? i = '"' + e[t] + '"' : i = String(e[t]) : ne.has(e[t]) ? i = ne.get(e[t]) : (i = Te, ne.set(e[t], Te++)), r += "@" + i;
243
+ var a = void 0;
244
+ e[t] === null || typeof e[t] != "object" && typeof e[t] != "function" ? typeof e[t] == "string" ? a = '"' + e[t] + '"' : a = String(e[t]) : ie.has(e[t]) ? a = ie.get(e[t]) : (a = Se, ie.set(e[t], Se++)), r += "@" + a;
245
245
  }
246
246
  return r;
247
247
  }
248
- function Sr(e) {
248
+ function wr(e) {
249
249
  if (typeof e == "function")
250
250
  try {
251
251
  e = e();
252
252
  } catch {
253
253
  e = "";
254
254
  }
255
- return Array.isArray(e) ? e = Er(e) : e = String(e || ""), e;
255
+ return Array.isArray(e) ? e = Dr(e) : e = String(e || ""), e;
256
256
  }
257
- var se = (
257
+ var le = (
258
258
  /** @class */
259
259
  function() {
260
260
  function e(r) {
261
261
  r === void 0 && (r = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = r;
262
262
  }
263
263
  return e.prototype.serializeKey = function(r) {
264
- return Sr(r);
264
+ return wr(r);
265
265
  }, e.prototype.get = function(r) {
266
266
  var t = this.serializeKey(r);
267
267
  return this.items.get(t);
268
- }, e.prototype.set = function(r, t, i) {
269
- var a = this.serializeKey(r), n = i || this.ttl, l = Date.now(), d = {
268
+ }, e.prototype.set = function(r, t, a) {
269
+ var i = this.serializeKey(r), n = a || this.ttl, s = Date.now(), c = {
270
270
  data: t,
271
- createdAt: l,
272
- expiresAt: n ? l + n : 1 / 0
271
+ createdAt: s,
272
+ expiresAt: n ? s + n : 1 / 0
273
273
  };
274
- this.dispatchExpire(n, d, a), this.items.set(a, d);
275
- }, e.prototype.dispatchExpire = function(r, t, i) {
276
- var a = this;
274
+ this.dispatchExpire(n, c, i), this.items.set(i, c);
275
+ }, e.prototype.dispatchExpire = function(r, t, a) {
276
+ var i = this;
277
277
  r && setTimeout(function() {
278
- var n = Date.now(), l = n >= t.expiresAt;
279
- l && a.delete(i);
278
+ var n = Date.now(), s = n >= t.expiresAt;
279
+ s && i.delete(a);
280
280
  }, r);
281
281
  }, e.prototype.delete = function(r) {
282
282
  this.items.delete(r);
283
283
  }, e;
284
284
  }()
285
285
  );
286
- function _r() {
286
+ function br() {
287
287
  return typeof navigator.onLine < "u" ? navigator.onLine : !0;
288
288
  }
289
- function Cr() {
289
+ function Or() {
290
290
  return typeof document < "u" && typeof document.visibilityState < "u" ? document.visibilityState !== "hidden" : !0;
291
291
  }
292
- var Ir = function(e) {
292
+ var Lr = function(e) {
293
293
  return fetch(e).then(function(r) {
294
294
  return r.json();
295
295
  });
296
296
  };
297
- const ae = {
298
- isOnline: _r,
299
- isDocumentVisible: Cr,
300
- fetcher: Ir
297
+ const oe = {
298
+ isOnline: br,
299
+ isDocumentVisible: Or,
300
+ fetcher: Lr
301
301
  };
302
302
  var w = function() {
303
303
  return w = Object.assign || function(e) {
304
- for (var r, t = 1, i = arguments.length; t < i; t++) {
304
+ for (var r, t = 1, a = arguments.length; t < a; t++) {
305
305
  r = arguments[t];
306
- for (var a in r) Object.prototype.hasOwnProperty.call(r, a) && (e[a] = r[a]);
306
+ for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]);
307
307
  }
308
308
  return e;
309
309
  }, w.apply(this, arguments);
310
- }, P = function(e, r, t, i) {
311
- function a(n) {
312
- return n instanceof t ? n : new t(function(l) {
313
- l(n);
310
+ }, U = function(e, r, t, a) {
311
+ function i(n) {
312
+ return n instanceof t ? n : new t(function(s) {
313
+ s(n);
314
314
  });
315
315
  }
316
- return new (t || (t = Promise))(function(n, l) {
317
- function d(s) {
316
+ return new (t || (t = Promise))(function(n, s) {
317
+ function c(l) {
318
318
  try {
319
- o(i.next(s));
319
+ o(a.next(l));
320
320
  } catch (u) {
321
- l(u);
321
+ s(u);
322
322
  }
323
323
  }
324
- function f(s) {
324
+ function d(l) {
325
325
  try {
326
- o(i.throw(s));
326
+ o(a.throw(l));
327
327
  } catch (u) {
328
- l(u);
328
+ s(u);
329
329
  }
330
330
  }
331
- function o(s) {
332
- s.done ? n(s.value) : a(s.value).then(d, f);
331
+ function o(l) {
332
+ l.done ? n(l.value) : i(l.value).then(c, d);
333
333
  }
334
- o((i = i.apply(e, r || [])).next());
334
+ o((a = a.apply(e, r || [])).next());
335
335
  });
336
- }, U = function(e, r) {
336
+ }, P = function(e, r) {
337
337
  var t = { label: 0, sent: function() {
338
338
  if (n[0] & 1) throw n[1];
339
339
  return n[1];
340
- }, trys: [], ops: [] }, i, a, n, l;
341
- return l = { next: d(0), throw: d(1), return: d(2) }, typeof Symbol == "function" && (l[Symbol.iterator] = function() {
340
+ }, trys: [], ops: [] }, a, i, n, s;
341
+ return s = { next: c(0), throw: c(1), return: c(2) }, typeof Symbol == "function" && (s[Symbol.iterator] = function() {
342
342
  return this;
343
- }), l;
344
- function d(o) {
345
- return function(s) {
346
- return f([o, s]);
343
+ }), s;
344
+ function c(o) {
345
+ return function(l) {
346
+ return d([o, l]);
347
347
  };
348
348
  }
349
- function f(o) {
350
- if (i) throw new TypeError("Generator is already executing.");
349
+ function d(o) {
350
+ if (a) throw new TypeError("Generator is already executing.");
351
351
  for (; t; ) try {
352
- if (i = 1, a && (n = o[0] & 2 ? a.return : o[0] ? a.throw || ((n = a.return) && n.call(a), 0) : a.next) && !(n = n.call(a, o[1])).done) return n;
353
- switch (a = 0, n && (o = [o[0] & 2, n.value]), o[0]) {
352
+ if (a = 1, i && (n = o[0] & 2 ? i.return : o[0] ? i.throw || ((n = i.return) && n.call(i), 0) : i.next) && !(n = n.call(i, o[1])).done) return n;
353
+ switch (i = 0, n && (o = [o[0] & 2, n.value]), o[0]) {
354
354
  case 0:
355
355
  case 1:
356
356
  n = o;
@@ -358,7 +358,7 @@ var w = function() {
358
358
  case 4:
359
359
  return t.label++, { value: o[1], done: !1 };
360
360
  case 5:
361
- t.label++, a = o[1], o = [0];
361
+ t.label++, i = o[1], o = [0];
362
362
  continue;
363
363
  case 7:
364
364
  o = t.ops.pop(), t.trys.pop();
@@ -384,36 +384,36 @@ var w = function() {
384
384
  continue;
385
385
  }
386
386
  o = r.call(e, t);
387
- } catch (s) {
388
- o = [6, s], a = 0;
387
+ } catch (l) {
388
+ o = [6, l], i = 0;
389
389
  } finally {
390
- i = n = 0;
390
+ a = n = 0;
391
391
  }
392
392
  if (o[0] & 5) throw o[1];
393
393
  return { value: o[0] ? o[1] : void 0, done: !0 };
394
394
  }
395
- }, Ar = function(e, r) {
395
+ }, Vr = function(e, r) {
396
396
  var t = typeof Symbol == "function" && e[Symbol.iterator];
397
397
  if (!t) return e;
398
- var i = t.call(e), a, n = [], l;
398
+ var a = t.call(e), i, n = [], s;
399
399
  try {
400
- for (; (r === void 0 || r-- > 0) && !(a = i.next()).done; ) n.push(a.value);
401
- } catch (d) {
402
- l = { error: d };
400
+ for (; (r === void 0 || r-- > 0) && !(i = a.next()).done; ) n.push(i.value);
401
+ } catch (c) {
402
+ s = { error: c };
403
403
  } finally {
404
404
  try {
405
- a && !a.done && (t = i.return) && t.call(i);
405
+ i && !i.done && (t = a.return) && t.call(a);
406
406
  } finally {
407
- if (l) throw l.error;
407
+ if (s) throw s.error;
408
408
  }
409
409
  }
410
410
  return n;
411
- }, Dr = function(e, r, t) {
412
- if (t || arguments.length === 2) for (var i = 0, a = r.length, n; i < a; i++)
413
- (n || !(i in r)) && (n || (n = Array.prototype.slice.call(r, 0, i)), n[i] = r[i]);
411
+ }, Mr = function(e, r, t) {
412
+ if (t || arguments.length === 2) for (var a = 0, i = r.length, n; a < i; a++)
413
+ (n || !(a in r)) && (n || (n = Array.prototype.slice.call(r, 0, a)), n[a] = r[a]);
414
414
  return e.concat(n || Array.prototype.slice.call(r));
415
- }, Me = new se(), Q = new se(), ie = new se(), ue = {
416
- cache: Me,
415
+ }, $e = new le(), J = new le(), se = new le(), ce = {
416
+ cache: $e,
417
417
  refreshInterval: 0,
418
418
  ttl: 0,
419
419
  serverTTL: 1e3,
@@ -423,127 +423,127 @@ var w = function() {
423
423
  shouldRetryOnError: !0,
424
424
  errorRetryInterval: 5e3,
425
425
  errorRetryCount: 5,
426
- fetcher: ae.fetcher,
427
- isOnline: ae.isOnline,
428
- isDocumentVisible: ae.isDocumentVisible
426
+ fetcher: oe.fetcher,
427
+ isOnline: oe.isOnline,
428
+ isDocumentVisible: oe.isDocumentVisible
429
429
  };
430
- function wr(e, r, t) {
431
- var i = Q.get(e);
432
- if (i)
433
- i.data.push(r);
430
+ function Nr(e, r, t) {
431
+ var a = J.get(e);
432
+ if (a)
433
+ a.data.push(r);
434
434
  else {
435
- var a = 5e3;
436
- Q.set(e, [r], t > 0 ? t + a : t);
435
+ var i = 5e3;
436
+ J.set(e, [r], t > 0 ? t + i : t);
437
437
  }
438
438
  }
439
- function br(e, r, t) {
439
+ function kr(e, r, t) {
440
440
  if (t.isDocumentVisible() && !(t.errorRetryCount !== void 0 && r > t.errorRetryCount)) {
441
- var i = Math.min(r || 0, t.errorRetryCount), a = i * t.errorRetryInterval;
441
+ var a = Math.min(r || 0, t.errorRetryCount), i = a * t.errorRetryInterval;
442
442
  setTimeout(function() {
443
- e(null, { errorRetryCount: i + 1, shouldRetryOnError: !0 });
444
- }, a);
443
+ e(null, { errorRetryCount: a + 1, shouldRetryOnError: !0 });
444
+ }, i);
445
445
  }
446
446
  }
447
- function Ee(e) {
448
- var r = e.shouldRetry, t = r === void 0 ? void 0 : r, i = e.error;
449
- return typeof t == "function" ? t(i) : typeof t == "boolean" ? t : ue.shouldRetryOnError;
447
+ function _e(e) {
448
+ var r = e.shouldRetry, t = r === void 0 ? void 0 : r, a = e.error;
449
+ return typeof t == "function" ? t(a) : typeof t == "boolean" ? t : ce.shouldRetryOnError;
450
450
  }
451
- var Se = function(e, r, t, i) {
452
- return t === void 0 && (t = Me), i === void 0 && (i = ue.ttl), P(void 0, void 0, void 0, function() {
453
- var a, n, l, d, f, o, s;
454
- return U(this, function(u) {
451
+ var Ce = function(e, r, t, a) {
452
+ return t === void 0 && (t = $e), a === void 0 && (a = ce.ttl), U(void 0, void 0, void 0, function() {
453
+ var i, n, s, c, d, o, l;
454
+ return P(this, function(u) {
455
455
  switch (u.label) {
456
456
  case 0:
457
- if (!Lr(r)) return [3, 5];
457
+ if (!xr(r)) return [3, 5];
458
458
  u.label = 1;
459
459
  case 1:
460
460
  return u.trys.push([1, 3, , 4]), [4, r];
461
461
  case 2:
462
- return a = u.sent(), [3, 4];
462
+ return i = u.sent(), [3, 4];
463
463
  case 3:
464
- return d = u.sent(), n = d, [3, 4];
464
+ return c = u.sent(), n = c, [3, 4];
465
465
  case 4:
466
466
  return [3, 6];
467
467
  case 5:
468
- a = r, u.label = 6;
468
+ i = r, u.label = 6;
469
469
  case 6:
470
- if (l = !1, f = { data: a, error: n, isValidating: l }, typeof a < "u")
470
+ if (s = !1, d = { data: i, error: n, isValidating: s }, typeof i < "u")
471
471
  try {
472
- t.set(e, f, i);
473
- } catch (c) {
474
- console.error("swrv(mutate): failed to set cache", c);
472
+ t.set(e, d, a);
473
+ } catch (f) {
474
+ console.error("swrv(mutate): failed to set cache", f);
475
475
  }
476
- return o = Q.get(e), o && o.data.length && (s = o.data.filter(function(c) {
477
- return c.key === e;
478
- }), s.forEach(function(c, v) {
479
- typeof f.data < "u" && (c.data = f.data), c.error = f.error, c.isValidating = f.isValidating, c.isLoading = f.isValidating;
480
- var y = v === s.length - 1;
481
- y || delete s[v];
482
- }), s = s.filter(Boolean)), [2, f];
476
+ return o = J.get(e), o && o.data.length && (l = o.data.filter(function(f) {
477
+ return f.key === e;
478
+ }), l.forEach(function(f, h) {
479
+ typeof d.data < "u" && (f.data = d.data), f.error = d.error, f.isValidating = d.isValidating, f.isLoading = d.isValidating;
480
+ var y = h === l.length - 1;
481
+ y || delete l[h];
482
+ }), l = l.filter(Boolean)), [2, d];
483
483
  }
484
484
  });
485
485
  });
486
486
  };
487
- function Or() {
487
+ function Fr() {
488
488
  for (var e = this, r = [], t = 0; t < arguments.length; t++)
489
489
  r[t] = arguments[t];
490
- var i, a, n = w({}, ue), l = !1, d = !1;
491
- if (!xe())
490
+ var a, i, n = w({}, ce), s = !1, c = !1;
491
+ if (!Ke())
492
492
  return console.error("useSWRV must be called inside setup() or an active effectScope()."), null;
493
- var f = typeof window > "u" || typeof document > "u";
494
- r.length >= 1 && (i = r[0]), r.length >= 2 && (a = r[1]), r.length > 2 && (n = w(w({}, n), r[2]));
495
- var o = f ? n.serverTTL : n.ttl, s = typeof i == "function" ? i : Y(i);
496
- typeof a > "u" && (a = n.fetcher);
493
+ var d = typeof window > "u" || typeof document > "u";
494
+ r.length >= 1 && (a = r[0]), r.length >= 2 && (i = r[1]), r.length > 2 && (n = w(w({}, n), r[2]));
495
+ var o = d ? n.serverTTL : n.ttl, l = typeof a == "function" ? a : W(a);
496
+ typeof i > "u" && (i = n.fetcher);
497
497
  var u = null;
498
- u || (u = qe({
498
+ u || (u = Be({
499
499
  data: void 0,
500
500
  error: void 0,
501
501
  isValidating: !0,
502
502
  isLoading: !0,
503
503
  key: null
504
504
  }));
505
- var c = function(h, m) {
506
- return P(e, void 0, void 0, function() {
507
- var C, E, I, A, N, $, J, de = this;
508
- return U(this, function(Z) {
509
- switch (Z.label) {
505
+ var f = function(g, v) {
506
+ return U(e, void 0, void 0, function() {
507
+ var _, E, C, I, N, B, ee, ve = this;
508
+ return P(this, function(re) {
509
+ switch (re.label) {
510
510
  case 0:
511
- return C = u.data === void 0, E = s.value, E ? (I = n.cache.get(E), A = I && I.data, u.isValidating = !0, u.isLoading = !A, A && (u.data = A.data, u.error = A.error), N = h || a, !N || !n.isDocumentVisible() && !C || (m == null ? void 0 : m.forceRevalidate) !== void 0 && !(m != null && m.forceRevalidate) ? (u.isValidating = !1, u.isLoading = !1, [
511
+ return _ = u.data === void 0, E = l.value, E ? (C = n.cache.get(E), I = C && C.data, u.isValidating = !0, u.isLoading = !I, I && (u.data = I.data, u.error = I.error), N = g || i, !N || !n.isDocumentVisible() && !_ || (v == null ? void 0 : v.forceRevalidate) !== void 0 && !(v != null && v.forceRevalidate) ? (u.isValidating = !1, u.isLoading = !1, [
512
512
  2
513
513
  /*return*/
514
- ]) : I && ($ = !!(Date.now() - I.createdAt >= n.dedupingInterval || m != null && m.forceRevalidate), !$) ? (u.isValidating = !1, u.isLoading = !1, [
514
+ ]) : C && (B = !!(Date.now() - C.createdAt >= n.dedupingInterval || v != null && v.forceRevalidate), !B) ? (u.isValidating = !1, u.isLoading = !1, [
515
515
  2
516
516
  /*return*/
517
- ]) : (J = function() {
518
- return P(de, void 0, void 0, function() {
519
- var k, fe, ee, ve, me, ye;
520
- return U(this, function(X) {
521
- switch (X.label) {
517
+ ]) : (ee = function() {
518
+ return U(ve, void 0, void 0, function() {
519
+ var k, me, te, ye, ge, he;
520
+ return P(this, function(H) {
521
+ switch (H.label) {
522
522
  case 0:
523
- return k = ie.get(E), k ? [3, 2] : (fe = Array.isArray(E) ? E : [E], ee = N.apply(void 0, Dr([], Ar(fe), !1)), ie.set(E, ee, n.dedupingInterval), [4, Se(E, ee, n.cache, o)]);
523
+ return k = se.get(E), k ? [3, 2] : (me = Array.isArray(E) ? E : [E], te = N.apply(void 0, Mr([], Vr(me), !1)), se.set(E, te, n.dedupingInterval), [4, Ce(E, te, n.cache, o)]);
524
524
  case 1:
525
- return X.sent(), [3, 4];
525
+ return H.sent(), [3, 4];
526
526
  case 2:
527
- return [4, Se(E, k.data, n.cache, o)];
527
+ return [4, Ce(E, k.data, n.cache, o)];
528
528
  case 3:
529
- X.sent(), X.label = 4;
529
+ H.sent(), H.label = 4;
530
530
  case 4:
531
- return u.isValidating = !1, u.isLoading = !1, ie.delete(E), u.error !== void 0 && (ve = Ee({ shouldRetry: n.shouldRetryOnError, error: u.error }), me = Ee({
532
- shouldRetry: m ? m.shouldRetryOnError : !0,
531
+ return u.isValidating = !1, u.isLoading = !1, se.delete(E), u.error !== void 0 && (ye = _e({ shouldRetry: n.shouldRetryOnError, error: u.error }), ge = _e({
532
+ shouldRetry: v ? v.shouldRetryOnError : !0,
533
533
  error: u.error
534
- }), ye = !l && ve && me, ye && br(c, m ? m.errorRetryCount : 1, n)), [
534
+ }), he = !s && ye && ge, he && kr(f, v ? v.errorRetryCount : 1, n)), [
535
535
  2
536
536
  /*return*/
537
537
  ];
538
538
  }
539
539
  });
540
540
  });
541
- }, A && n.revalidateDebounce ? (setTimeout(function() {
542
- return P(de, void 0, void 0, function() {
543
- return U(this, function(k) {
541
+ }, I && n.revalidateDebounce ? (setTimeout(function() {
542
+ return U(ve, void 0, void 0, function() {
543
+ return P(this, function(k) {
544
544
  switch (k.label) {
545
545
  case 0:
546
- return l ? [3, 2] : [4, J()];
546
+ return s ? [3, 2] : [4, ee()];
547
547
  case 1:
548
548
  k.sent(), k.label = 2;
549
549
  case 2:
@@ -559,9 +559,9 @@ function Or() {
559
559
  /*return*/
560
560
  ];
561
561
  case 1:
562
- return [4, J()];
562
+ return [4, ee()];
563
563
  case 2:
564
- Z.sent(), Z.label = 3;
564
+ re.sent(), re.label = 3;
565
565
  case 3:
566
566
  return [
567
567
  2
@@ -570,26 +570,26 @@ function Or() {
570
570
  }
571
571
  });
572
572
  });
573
- }, v = function() {
574
- return P(e, void 0, void 0, function() {
575
- return U(this, function(h) {
576
- return [2, c(null, { shouldRetryOnError: !1 })];
573
+ }, h = function() {
574
+ return U(e, void 0, void 0, function() {
575
+ return P(this, function(g) {
576
+ return [2, f(null, { shouldRetryOnError: !1 })];
577
577
  });
578
578
  });
579
579
  }, y = null;
580
- if (!f) {
581
- var _ = function() {
582
- return P(e, void 0, void 0, function() {
583
- return U(this, function(h) {
584
- switch (h.label) {
580
+ if (!d) {
581
+ var A = function() {
582
+ return U(e, void 0, void 0, function() {
583
+ return P(this, function(g) {
584
+ switch (g.label) {
585
585
  case 0:
586
- return !u.error && n.isOnline() ? [4, c()] : [3, 2];
586
+ return !u.error && n.isOnline() ? [4, f()] : [3, 2];
587
587
  case 1:
588
- return h.sent(), [3, 3];
588
+ return g.sent(), [3, 3];
589
589
  case 2:
590
- y && (clearTimeout(y), y = null), h.label = 3;
590
+ y && (clearTimeout(y), y = null), g.label = 3;
591
591
  case 3:
592
- return n.refreshInterval && !l && (y = setTimeout(_, n.refreshInterval)), [
592
+ return n.refreshInterval && !s && (y = setTimeout(A, n.refreshInterval)), [
593
593
  2
594
594
  /*return*/
595
595
  ];
@@ -597,123 +597,123 @@ function Or() {
597
597
  });
598
598
  });
599
599
  };
600
- n.refreshInterval && (y = setTimeout(_, n.refreshInterval)), n.revalidateOnFocus && (document.addEventListener("visibilitychange", v, !1), window.addEventListener("focus", v, !1));
600
+ n.refreshInterval && (y = setTimeout(A, n.refreshInterval)), n.revalidateOnFocus && (document.addEventListener("visibilitychange", h, !1), window.addEventListener("focus", h, !1));
601
601
  }
602
- Pe(function() {
603
- l = !0, y && (clearTimeout(y), y = null), !f && n.revalidateOnFocus && (document.removeEventListener("visibilitychange", v, !1), window.removeEventListener("focus", v, !1));
604
- var h = Q.get(s.value);
605
- h && (h.data = h.data.filter(function(m) {
606
- return m !== u;
602
+ Xe(function() {
603
+ s = !0, y && (clearTimeout(y), y = null), !d && n.revalidateOnFocus && (document.removeEventListener("visibilitychange", h, !1), window.removeEventListener("focus", h, !1));
604
+ var g = J.get(l.value);
605
+ g && (g.data = g.data.filter(function(v) {
606
+ return v !== u;
607
607
  }));
608
608
  });
609
609
  try {
610
- Ue(s, function(h) {
611
- ze(s) || (s.value = h), u.key = h, u.isValidating = !!h, wr(s.value, u, o), !f && !d && s.value && c(), d = !1;
610
+ Ge(l, function(g) {
611
+ He(l) || (l.value = g), u.key = g, u.isValidating = !!g, Nr(l.value, u, o), !d && !c && l.value && f(), c = !1;
612
612
  }, {
613
613
  immediate: !0
614
614
  });
615
615
  } catch {
616
616
  }
617
- var p = w(w({}, Ke(u)), { mutate: function(h, m) {
618
- return c(h, w(w({}, m), { forceRevalidate: !0 }));
617
+ var p = w(w({}, je(u)), { mutate: function(g, v) {
618
+ return f(g, w(w({}, v), { forceRevalidate: !0 }));
619
619
  } });
620
620
  return p;
621
621
  }
622
- function Lr(e) {
622
+ function xr(e) {
623
623
  return e !== null && typeof e == "object" && typeof e.then == "function";
624
624
  }
625
- function Vr(e, r, t) {
625
+ function qr(e, r, t) {
626
626
  const {
627
- data: i,
628
- error: a,
627
+ data: a,
628
+ error: i,
629
629
  isValidating: n,
630
- mutate: l
631
- } = Or(e, r, {
630
+ mutate: s
631
+ } = Fr(e, r, {
632
632
  revalidateDebounce: 500,
633
633
  revalidateOnFocus: !1,
634
634
  dedupingInterval: 100,
635
635
  ...t
636
636
  });
637
637
  return {
638
- data: g(() => i.value),
639
- response: i,
640
- error: a,
638
+ data: m(() => a.value),
639
+ response: a,
640
+ error: i,
641
641
  isValidating: n,
642
- revalidate: l
642
+ revalidate: s
643
643
  };
644
644
  }
645
645
  const M = {
646
- useI18n: dr,
647
- useMetricCardBuilder: Rr,
648
- useMetricFetcher: pr,
649
- useTrendRange: Tr,
650
- useRequest: Vr
651
- }, Ne = Symbol("METRICS_PROVIDER_KEY"), Mr = (e) => {
646
+ useI18n: hr,
647
+ useMetricCardBuilder: Ir,
648
+ useMetricFetcher: Cr,
649
+ useTrendRange: Ar,
650
+ useRequest: qr
651
+ }, Ue = Symbol("METRICS_PROVIDER_KEY"), $r = (e) => {
652
652
  const {
653
653
  datasource: r,
654
654
  dimension: t,
655
- dimensionFilterValue: i,
656
- additionalFilter: a,
655
+ dimensionFilterValue: a,
656
+ additionalFilter: i,
657
657
  queryReady: n,
658
- timeRange: l,
659
- hasTrendAccess: d,
660
- refreshInterval: f,
658
+ timeRange: s,
659
+ hasTrendAccess: c,
660
+ refreshInterval: d,
661
661
  abortController: o,
662
- queryFn: s,
662
+ queryFn: l,
663
663
  averageLatencies: u
664
664
  } = e;
665
- if (i && !t)
665
+ if (a && !t)
666
666
  throw new Error("Must provide a dimension if filtering by a value");
667
- const c = !!(t && i), v = !!(t && !i), y = g(() => {
668
- const C = [];
669
- return c && C.push({
667
+ const f = !!(t && a), h = !!(t && !a), y = m(() => {
668
+ const _ = [];
669
+ return f && _.push({
670
670
  field: t,
671
671
  operator: "in",
672
- value: [i]
673
- }), a.value && C.push(...He(r.value, a.value)), C;
674
- }), _ = {
672
+ value: [a]
673
+ }), i.value && _.push(...er(r.value, i.value)), _;
674
+ }), A = {
675
675
  datasource: r,
676
- metrics: Y([
676
+ metrics: W([
677
677
  "request_count"
678
678
  ]),
679
679
  // Traffic and error rate cards should only try to query for the dimension if it's going to be used.
680
680
  // It isn't used for single entity queries.
681
681
  dimensions: [
682
- ...t && !c ? [t] : [],
682
+ ...t && !f ? [t] : [],
683
683
  "status_code_grouped"
684
684
  ],
685
685
  filter: y,
686
686
  queryReady: n,
687
- timeRange: l,
687
+ timeRange: s,
688
688
  // Traffic and error rate cards can't query trend if multiple entities are expected.
689
- withTrend: g(() => d.value && !v),
690
- refreshInterval: f,
691
- queryFn: s,
689
+ withTrend: m(() => c.value && !h),
690
+ refreshInterval: d,
691
+ queryFn: l,
692
692
  abortController: o,
693
693
  refreshCounter: e.refreshCounter
694
694
  }, p = {
695
695
  datasource: r,
696
- metrics: g(() => [
696
+ metrics: m(() => [
697
697
  u.value ? "response_latency_average" : "response_latency_p99"
698
698
  ]),
699
699
  // To keep single-entity queries consistent, don't bother querying the dimension for latency
700
700
  // in the single-entity case, even though it's possible.
701
- ...t && !c ? { dimensions: [t] } : {},
701
+ ...t && !f ? { dimensions: [t] } : {},
702
702
  filter: y,
703
703
  queryReady: n,
704
- timeRange: l,
704
+ timeRange: s,
705
705
  // Don't query latency trends in the multi-entity case: it's possible, but wasteful.
706
- withTrend: g(() => d.value && !v),
707
- refreshInterval: f,
708
- queryFn: s,
706
+ withTrend: m(() => c.value && !h),
707
+ refreshInterval: d,
708
+ queryFn: l,
709
709
  abortController: o,
710
710
  refreshCounter: e.refreshCounter
711
- }, h = M.useMetricFetcher(_), m = M.useMetricFetcher(p);
711
+ }, g = M.useMetricFetcher(A), v = M.useMetricFetcher(p);
712
712
  return {
713
- trafficData: h,
714
- latencyData: m
713
+ trafficData: g,
714
+ latencyData: v
715
715
  };
716
- }, ht = /* @__PURE__ */ W({
716
+ }, Et = /* @__PURE__ */ Z({
717
717
  __name: "MetricsProvider",
718
718
  props: {
719
719
  datasource: { default: void 0 },
@@ -723,7 +723,7 @@ const M = {
723
723
  filterValue: { default: void 0 },
724
724
  additionalFilter: { default: void 0 },
725
725
  queryReady: { type: Boolean, default: !0 },
726
- refreshInterval: { default: vr },
726
+ refreshInterval: { default: Rr },
727
727
  longCardTitles: { type: Boolean, default: !1 },
728
728
  containerTitle: { default: void 0 },
729
729
  description: { default: void 0 },
@@ -733,100 +733,91 @@ const M = {
733
733
  },
734
734
  setup(e) {
735
735
  const r = e;
736
- if (r.dimension && Ye.findIndex((c) => c === r.dimension) === -1)
736
+ if (r.dimension && rr.findIndex((f) => f === r.dimension) === -1)
737
737
  throw new Error(`Attempted to use MetricsProvider with an invalid dimension: ${r.dimension}`);
738
- const t = Ae(mr);
739
- let i;
740
- t ? i = t.queryFn : (console.warn("Analytics dashboards require a query bridge supplied via provide / inject."), console.warn("Please ensure your application has a query bridge provided under the key 'analytics-query-provider', as described in"), console.warn("https://github.com/Kong/public-ui-components/blob/main/packages/analytics/analytics-metric-provider/README.md#requirements"), i = () => Promise.reject(new Error("Query bridge required")));
741
- const a = Je(), n = g(() => !0), l = g(() => !a.loading && r.queryReady), d = g(() => r.datasource ? r.datasource : "basic"), f = g(() => {
742
- const c = r.overrideTimeRange;
743
- return c && !c.tz && (c.tz = new Intl.DateTimeFormat().resolvedOptions().timeZone), c || {
738
+ const t = Ve(Tr);
739
+ let a;
740
+ t ? a = t.queryFn : (console.warn("Analytics dashboards require a query bridge supplied via provide / inject."), console.warn("Please ensure your application has a query bridge provided under the key 'analytics-query-provider', as described in"), console.warn("https://github.com/Kong/public-ui-components/blob/main/packages/analytics/analytics-metric-provider/README.md#requirements"), a = () => Promise.reject(new Error("Query bridge required")));
741
+ const i = ar(), n = m(() => !0), s = m(() => !i.loading && r.queryReady), c = m(() => r.datasource ? r.datasource : "basic"), d = m(() => {
742
+ const f = r.overrideTimeRange;
743
+ return f && !f.tz && (f.tz = new Intl.DateTimeFormat().resolvedOptions().timeZone), f || {
744
744
  type: "relative",
745
745
  time_range: "7d",
746
746
  tz: new Intl.DateTimeFormat().resolvedOptions().timeZone
747
747
  };
748
- }), o = g(() => !r.percentileLatency), {
749
- trafficData: s,
748
+ }), o = m(() => !r.percentileLatency), {
749
+ trafficData: l,
750
750
  latencyData: u
751
- } = Mr({
752
- datasource: d,
751
+ } = $r({
752
+ datasource: c,
753
753
  dimension: r.dimension,
754
754
  dimensionFilterValue: r.filterValue,
755
- additionalFilter: G(r, "additionalFilter"),
756
- queryReady: l,
757
- timeRange: f,
755
+ additionalFilter: j(r, "additionalFilter"),
756
+ queryReady: s,
757
+ timeRange: d,
758
758
  hasTrendAccess: n,
759
759
  refreshInterval: r.refreshInterval,
760
- queryFn: i,
760
+ queryFn: a,
761
761
  averageLatencies: o,
762
762
  abortController: r.abortController,
763
- refreshCounter: G(r, "refreshCounter")
763
+ refreshCounter: j(r, "refreshCounter")
764
764
  });
765
- return $e(Ne, {
765
+ return Ye(Ue, {
766
766
  data: {
767
- traffic: s,
767
+ traffic: l,
768
768
  latency: u
769
769
  },
770
- description: G(() => r.description),
771
- containerTitle: G(() => r.containerTitle),
770
+ description: j(() => r.description),
771
+ containerTitle: j(() => r.containerTitle),
772
772
  hasTrendAccess: n,
773
773
  longCardTitles: r.longCardTitles,
774
774
  averageLatencies: o
775
- }), (c, v) => De(c.$slots, "default", {
775
+ }), (f, h) => Me(f.$slots, "default", {
776
776
  hasTrendAccess: n.value,
777
- timeRange: f.value
777
+ timeRange: d.value
778
778
  });
779
779
  }
780
- });
781
- function Nr(e) {
782
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
780
+ }), Ie = 1e3, Ur = 1e4, Ae = 1e6, De = 1e9, we = 1e12, X = (e, r) => {
781
+ if (r.separator === !1 || e < 1e3)
782
+ return e.toString();
783
+ const t = typeof r.separator == "string" ? r.separator : ",", a = [];
784
+ return Math.round(e).toString().split("").reverse().forEach((n, s) => {
785
+ s && s % 3 === 0 && a.push(t), a.push(n);
786
+ }), a.reverse().join("");
787
+ }, q = (e, r, t) => {
788
+ const a = e / r, i = t.round ? "round" : "floor";
789
+ if (t.decimal === !1)
790
+ return Math[i](a).toString();
791
+ let n;
792
+ t.precision ? n = a : n = a < 10 ? Math[i](a * 10) / 10 : Math[i](a);
793
+ let s = n.toString();
794
+ return typeof t.decimal == "string" && (s = s.replace(".", t.decimal)), s;
795
+ };
796
+ function Pe(e, r = {}) {
797
+ let t;
798
+ const a = e < 0;
799
+ a && (e = Math.abs(e)), r.precision && (e = parseFloat(e.toPrecision(r.precision)));
800
+ const i = r.min10k ? Ur : Ie;
801
+ return e < i || r.precision && r.precision > Math.log10(e) ? t = X(q(e, 1, r), r) : e < Ae ? t = `${q(e, Ie, r)}k` : e < De ? t = `${q(e, Ae, r)}m` : e < we ? t = `${X(q(e, De, r), r)}b` : t = `${X(q(e, we, r), r)}t`, a && (t = `-${t}`), r.capital && (t = t.toUpperCase()), r.prefix && (t = `${r.prefix}${t}`), r.suffix && (t = `${t}${r.suffix}`), t;
783
802
  }
784
- var ke = { exports: {} };
785
- (function(e) {
786
- (function() {
787
- function r(o, s) {
788
- if (s.separator === !1 || o < 1e3)
789
- return o.toString();
790
- var u = typeof s.separator == "string" ? s.separator : ",", c = [], v = Math.round(o).toString().split("");
791
- return v.reverse().forEach(function(y, _) {
792
- _ && _ % 3 === 0 && c.push(u), c.push(y);
793
- }), c.reverse().join("");
794
- }
795
- function t(o, s, u) {
796
- var c = o / s, v = u.round ? "round" : "floor";
797
- return u.decimal === !1 ? (o = Math[v](c), o.toString()) : (u.precision ? o = c : o = c < 10 ? Math[v](c * 10) / 10 : Math[v](c), o = o.toString(), typeof u.decimal == "string" && (o = o.replace(".", u.decimal)), o);
798
- }
799
- var i = 1e3, a = 1e4, n = 1e6, l = 1e9, d = 1e12;
800
- function f(o, s) {
801
- var u;
802
- s = s || {};
803
- var c = o < 0;
804
- c && (o = Math.abs(o)), s.precision && (o = parseFloat(o.toPrecision(s.precision)));
805
- var v = s.min10k ? a : i;
806
- return o < v || s.precision && s.precision > Math.log10(o) ? u = r(t(o, 1, s), s) : o < n ? u = t(o, i, s) + "k" : o < l ? u = t(o, n, s) + "m" : o < d ? u = r(t(o, l, s), s) + "b" : u = r(t(o, d, s), s) + "t", c && (u = "-" + u), s.capital && (u = u.toUpperCase()), s.prefix && (u = s.prefix + u), s.suffix && (u = u + s.suffix), u;
807
- }
808
- f.addCommas = r, e.exports = f;
809
- })();
810
- })(ke);
811
- var kr = ke.exports;
812
- const Fr = /* @__PURE__ */ Nr(kr);
803
+ Pe.addCommas = X;
813
804
  var O = /* @__PURE__ */ ((e) => (e.GENERIC_COUNT = "GenericCount", e.TRAFFIC = "Traffic", e.ERROR_RATE = "ErrorRate", e.LATENCY = "Latency", e))(O || {}), D = /* @__PURE__ */ ((e) => (e.Small = "sm", e.Medium = "md", e.Large = "lg", e.ExtraLarge = "xl", e))(D || {});
814
- const le = 2, _e = le + 2, xr = (e, r, t = !1) => {
815
- let i = !r || Number(e.toFixed(_e)) === 0 ? 0 : Number(e.toFixed(_e)) > 0 ? 1 : -1;
816
- return t && (i *= -1), i;
817
- }, qr = (e, r, t) => r ? `${Math.abs(e * 100).toFixed(le)}%` : t, Pr = (e, r) => r === 0 ? 0 : e / r - 1, Ur = (e, r = !1) => (r && (e *= -1), e > 0 ? Ze : e < 0 ? er : Oe), zr = "#ad000e", oe = "#6c7489", Ce = "#52596e", Kr = "#007d60", j = "16px", $r = "20px", Br = {
805
+ const de = 2, be = de + 2, Pr = (e, r, t = !1) => {
806
+ let a = !r || Number(e.toFixed(be)) === 0 ? 0 : Number(e.toFixed(be)) > 0 ? 1 : -1;
807
+ return t && (a *= -1), a;
808
+ }, zr = (e, r, t) => r ? `${Math.abs(e * 100).toFixed(de)}%` : t, Kr = (e, r) => r === 0 ? 0 : e / r - 1, Br = (e, r = !1) => (r && (e *= -1), e > 0 ? ir : e < 0 ? or : Fe), Xr = "#ad000e", ue = "#6c7489", Oe = "#52596e", Gr = "#007d60", Y = "16px", Hr = "20px", jr = {
818
809
  key: 0,
819
810
  class: "metricscard-description"
820
- }, Xr = { class: "metricscard-valuetrend" }, Gr = {
811
+ }, Yr = { class: "metricscard-valuetrend" }, Qr = {
821
812
  key: 0,
822
813
  class: "metricscard-error"
823
- }, jr = {
814
+ }, Wr = {
824
815
  key: 2,
825
816
  class: "metricscard-trend"
826
- }, Hr = { "data-testid": "metric-trend-change" }, Yr = {
817
+ }, Jr = { "data-testid": "metric-trend-change" }, Zr = {
827
818
  key: 0,
828
819
  class: "metricscard-trend-range"
829
- }, Qr = /* @__PURE__ */ W({
820
+ }, et = /* @__PURE__ */ Z({
830
821
  __name: "MetricsCard",
831
822
  props: {
832
823
  cardType: {
@@ -868,7 +859,7 @@ const le = 2, _e = le + 2, xr = (e, r, t = !1) => {
868
859
  },
869
860
  trendIcon: {
870
861
  type: Object,
871
- default: Oe
862
+ default: Fe
872
863
  },
873
864
  trendRange: {
874
865
  type: String,
@@ -899,61 +890,61 @@ const le = 2, _e = le + 2, xr = (e, r, t = !1) => {
899
890
  },
900
891
  setup(e) {
901
892
  const r = /* @__PURE__ */ new Map([
902
- [O.GENERIC_COUNT, rr],
903
- [O.TRAFFIC, tr],
904
- [O.ERROR_RATE, nr],
905
- [O.LATENCY, ar]
906
- ]), t = e, i = (d) => {
907
- const f = {
908
- red: `var(--kui-color-text-danger-strong, ${zr})`,
909
- green: `var(--kui-color-text-success, ${Kr})`,
910
- grey: `var(--kui-color-text-neutral-strong, ${Ce})`
893
+ [O.GENERIC_COUNT, sr],
894
+ [O.TRAFFIC, ur],
895
+ [O.ERROR_RATE, lr],
896
+ [O.LATENCY, cr]
897
+ ]), t = e, a = (c) => {
898
+ const d = {
899
+ red: `var(--kui-color-text-danger-strong, ${Xr})`,
900
+ green: `var(--kui-color-text-success, ${Gr})`,
901
+ grey: `var(--kui-color-text-neutral-strong, ${Oe})`
911
902
  };
912
- return d > 0 ? f.green : d < 0 ? f.red : f.grey;
913
- }, a = (d) => d > 0 ? "positive" : d < 0 ? "negative" : "neutral", n = [D.Medium, D.Large].includes(t.cardSize), l = [D.Small].includes(t.cardSize);
914
- return (d, f) => {
915
- const o = we("KTooltip");
903
+ return c > 0 ? d.green : c < 0 ? d.red : d.grey;
904
+ }, i = (c) => c > 0 ? "positive" : c < 0 ? "negative" : "neutral", n = [D.Medium, D.Large].includes(t.cardSize), s = [D.Small].includes(t.cardSize);
905
+ return (c, d) => {
906
+ const o = Ne("KTooltip");
916
907
  return R(), S("div", {
917
908
  class: z(["metricscard", e.cardSize])
918
909
  }, [
919
910
  x("div", {
920
911
  class: z(["metricscard-title", e.cardSize])
921
912
  }, [
922
- T(l) ? V("", !0) : (R(), q(re(T(r).get(e.cardType)), {
913
+ T(s) ? V("", !0) : (R(), $(ne(T(r).get(e.cardType)), {
923
914
  key: 0,
924
915
  class: "metricscard-icon",
925
- color: `var(--kui-color-text-neutral, ${T(oe)})`,
926
- size: T(j)
916
+ color: `var(--kui-color-text-neutral, ${T(ue)})`,
917
+ size: T(Y)
927
918
  }, null, 8, ["color", "size"])),
928
- (R(), q(re(e.titleTag), null, {
929
- default: ge(() => [
930
- be(b(e.title), 1)
919
+ (R(), $(ne(e.titleTag), null, {
920
+ default: pe(() => [
921
+ ke(b(e.title), 1)
931
922
  ]),
932
923
  _: 1
933
924
  })),
934
- e.tooltip ? (R(), q(o, {
925
+ e.tooltip ? (R(), $(o, {
935
926
  key: 1,
936
927
  class: "metricscard-tooltip",
937
928
  placement: "right",
938
929
  text: e.tooltip
939
930
  }, {
940
- default: ge(() => [
941
- F(T(ir), {
942
- color: `var(--kui-color-text-neutral, ${T(oe)})`,
943
- size: T(j)
931
+ default: pe(() => [
932
+ F(T(dr), {
933
+ color: `var(--kui-color-text-neutral, ${T(ue)})`,
934
+ size: T(Y)
944
935
  }, null, 8, ["color", "size"])
945
936
  ]),
946
937
  _: 1
947
938
  }, 8, ["text"])) : V("", !0)
948
939
  ], 2),
949
- e.description && T(n) ? (R(), S("div", Br, [
940
+ e.description && T(n) ? (R(), S("div", jr, [
950
941
  x("span", null, b(e.description), 1)
951
942
  ])) : V("", !0),
952
- x("div", Xr, [
953
- e.hasError ? (R(), S("div", Gr, [
954
- F(T(Le), {
955
- color: `var(--kui-color-text-neutral, ${T(oe)})`,
956
- size: T($r)
943
+ x("div", Yr, [
944
+ e.hasError ? (R(), S("div", Qr, [
945
+ F(T(xe), {
946
+ color: `var(--kui-color-text-neutral, ${T(ue)})`,
947
+ size: T(Hr)
957
948
  }, null, 8, ["color", "size"]),
958
949
  x("div", null, " " + b(e.errorMessage), 1)
959
950
  ])) : (R(), S("div", {
@@ -961,57 +952,57 @@ const le = 2, _e = le + 2, xr = (e, r, t = !1) => {
961
952
  class: z(["metricscard-value", e.cardSize]),
962
953
  "data-testid": "metric-value"
963
954
  }, b(e.metricValue), 3)),
964
- T(n) ? (R(), S("div", jr, [
955
+ T(n) ? (R(), S("div", Wr, [
965
956
  x("div", {
966
- class: z(["metricscard-trend-change", a(e.changePolarity)]),
957
+ class: z(["metricscard-trend-change", i(e.changePolarity)]),
967
958
  "data-testid": "metric-trend-parent"
968
959
  }, [
969
- e.changePolarity !== 0 ? (R(), q(re(e.trendIcon), {
960
+ e.changePolarity !== 0 ? (R(), $(ne(e.trendIcon), {
970
961
  key: 0,
971
- color: i(e.changePolarity),
972
- size: T(j)
973
- }, null, 8, ["color", "size"])) : (R(), q(T(or), {
962
+ color: a(e.changePolarity),
963
+ size: T(Y)
964
+ }, null, 8, ["color", "size"])) : (R(), $(T(fr), {
974
965
  key: 1,
975
- color: `var(--kui-color-text-neutral-strong, ${T(Ce)})`,
976
- size: T(j)
966
+ color: `var(--kui-color-text-neutral-strong, ${T(Oe)})`,
967
+ size: T(Y)
977
968
  }, null, 8, ["color", "size"])),
978
- x("div", Hr, b(e.metricChange), 1)
969
+ x("div", Jr, b(e.metricChange), 1)
979
970
  ], 2),
980
- e.trendRange ? (R(), S("div", Yr, b(e.trendRange), 1)) : V("", !0)
971
+ e.trendRange ? (R(), S("div", Zr, b(e.trendRange), 1)) : V("", !0)
981
972
  ])) : V("", !0)
982
973
  ])
983
974
  ], 2);
984
975
  };
985
976
  }
986
- }), ce = (e, r) => {
977
+ }), fe = (e, r) => {
987
978
  const t = e.__vccOpts || e;
988
- for (const [i, a] of r)
989
- t[i] = a;
979
+ for (const [a, i] of r)
980
+ t[a] = i;
990
981
  return t;
991
- }, Wr = /* @__PURE__ */ ce(Qr, [["__scopeId", "data-v-b1513f6f"]]), Jr = {}, Zr = { class: "loading-tabs" };
992
- function et(e, r) {
993
- const t = we("KSkeletonBox");
994
- return R(), S("div", Zr, [
982
+ }, rt = /* @__PURE__ */ fe(et, [["__scopeId", "data-v-b1513f6f"]]), tt = {}, nt = { class: "loading-tabs" };
983
+ function at(e, r) {
984
+ const t = Ne("KSkeletonBox");
985
+ return R(), S("div", nt, [
995
986
  F(t, { width: "100" }),
996
987
  F(t, { width: "75" })
997
988
  ]);
998
989
  }
999
- const rt = /* @__PURE__ */ ce(Jr, [["render", et], ["__scopeId", "data-v-9c7113d7"]]), tt = {
990
+ const it = /* @__PURE__ */ fe(tt, [["render", at], ["__scopeId", "data-v-9c7113d7"]]), ot = {
1000
991
  key: 0,
1001
992
  class: "container-title"
1002
- }, nt = {
993
+ }, st = {
1003
994
  key: 0,
1004
995
  class: "container-description"
1005
- }, at = {
996
+ }, ut = {
1006
997
  key: 1,
1007
998
  class: "error-display"
1008
- }, it = {
999
+ }, lt = {
1009
1000
  key: 0,
1010
1001
  class: "error-display-message"
1011
- }, ot = {
1002
+ }, ct = {
1012
1003
  key: 2,
1013
1004
  class: "cards-wrapper"
1014
- }, st = /* @__PURE__ */ W({
1005
+ }, dt = /* @__PURE__ */ Z({
1015
1006
  __name: "MetricCardContainer",
1016
1007
  props: {
1017
1008
  fallbackDisplayText: {
@@ -1054,52 +1045,52 @@ const rt = /* @__PURE__ */ ce(Jr, [["render", et], ["__scopeId", "data-v-9c7113d
1054
1045
  }
1055
1046
  },
1056
1047
  setup(e) {
1057
- const r = e, t = g(() => r.cards.every((a) => (a == null ? void 0 : a.hasError) === !0)), i = (a) => {
1058
- const n = Pr(a.currentValue, a.previousValue) || 0, l = xr(n, r.hasTrendAccess, a.increaseIsBad);
1048
+ const r = e, t = m(() => r.cards.every((i) => (i == null ? void 0 : i.hasError) === !0)), a = (i) => {
1049
+ const n = Kr(i.currentValue, i.previousValue) || 0, s = Pr(n, r.hasTrendAccess, i.increaseIsBad);
1059
1050
  return {
1060
- metricValue: a.formatValueFn ? a.formatValueFn(a.currentValue) : Fr(a.currentValue, { capital: !0, round: !0 }) || "0",
1061
- metricChange: a.formatChangeFn ? a.formatChangeFn(n) : qr(n, r.hasTrendAccess, r.fallbackDisplayText),
1062
- changePolarity: l,
1063
- trendIcon: Ur(l, a.increaseIsBad),
1051
+ metricValue: i.formatValueFn ? i.formatValueFn(i.currentValue) : Pe(i.currentValue, { capital: !0, round: !0 }) || "0",
1052
+ metricChange: i.formatChangeFn ? i.formatChangeFn(n) : zr(n, r.hasTrendAccess, r.fallbackDisplayText),
1053
+ changePolarity: s,
1054
+ trendIcon: Br(s, i.increaseIsBad),
1064
1055
  cardSize: r.cardSize,
1065
1056
  hasContainerTitle: !!r.containerTitle
1066
1057
  };
1067
1058
  };
1068
- return (a, n) => (R(), S("div", {
1059
+ return (i, n) => (R(), S("div", {
1069
1060
  class: z(["kong-ui-public-metric-card-container", e.cardSize])
1070
1061
  }, [
1071
- r.containerTitle || r.containerDescription ? (R(), S("div", tt, [
1072
- be(b(r.containerTitle) + " ", 1),
1073
- r.containerDescription ? (R(), S("div", nt, b(r.containerDescription), 1)) : V("", !0)
1062
+ r.containerTitle || r.containerDescription ? (R(), S("div", ot, [
1063
+ ke(b(r.containerTitle) + " ", 1),
1064
+ r.containerDescription ? (R(), S("div", st, b(r.containerDescription), 1)) : V("", !0)
1074
1065
  ])) : V("", !0),
1075
- t.value ? (R(), S("div", at, [
1076
- F(T(Le), { class: "error-display-icon" }),
1077
- e.errorMessage ? (R(), S("div", it, b(e.errorMessage), 1)) : V("", !0)
1078
- ])) : (R(), S("div", ot, [
1079
- (R(!0), S(he, null, Be(e.cards, (l, d) => (R(), S(he, null, [
1066
+ t.value ? (R(), S("div", ut, [
1067
+ F(T(xe), { class: "error-display-icon" }),
1068
+ e.errorMessage ? (R(), S("div", lt, b(e.errorMessage), 1)) : V("", !0)
1069
+ ])) : (R(), S("div", ct, [
1070
+ (R(!0), S(Re, null, Qe(e.cards, (s, c) => (R(), S(Re, null, [
1080
1071
  e.loading ? (R(), S("div", {
1081
- key: `skeleton-${d}`,
1072
+ key: `skeleton-${c}`,
1082
1073
  class: "loading-tab"
1083
1074
  }, [
1084
- F(rt, {
1075
+ F(it, {
1085
1076
  class: z(e.cardSize === T(D).Small ? "loading-tabs-small" : "loading-tabs-large")
1086
1077
  }, null, 8, ["class"])
1087
- ])) : (R(), q(Wr, Xe({ key: d }, { ref_for: !0 }, i(l), {
1078
+ ])) : (R(), $(rt, We({ key: c }, { ref_for: !0 }, a(s), {
1088
1079
  "card-size": e.cardSize,
1089
- "card-type": l.cardType,
1090
- description: l.description,
1080
+ "card-type": s.cardType,
1081
+ description: s.description,
1091
1082
  "error-message": e.errorMessage,
1092
- "has-error": l.hasError,
1093
- title: l.title,
1094
- "title-tag": l.titleTag,
1095
- tooltip: l.tooltip,
1096
- "trend-range": l.trendRange
1083
+ "has-error": s.hasError,
1084
+ title: s.title,
1085
+ "title-tag": s.titleTag,
1086
+ tooltip: s.tooltip,
1087
+ "trend-range": s.trendRange
1097
1088
  }), null, 16, ["card-size", "card-type", "description", "error-message", "has-error", "title", "title-tag", "tooltip", "trend-range"]))
1098
1089
  ], 64))), 256))
1099
1090
  ]))
1100
1091
  ], 2));
1101
1092
  }
1102
- }), ut = /* @__PURE__ */ ce(st, [["__scopeId", "data-v-7080ba56"]]), pt = /* @__PURE__ */ W({
1093
+ }), ft = /* @__PURE__ */ fe(dt, [["__scopeId", "data-v-7080ba56"]]), St = /* @__PURE__ */ Z({
1103
1094
  __name: "MetricsConsumer",
1104
1095
  props: {
1105
1096
  lookupKey: { default: void 0 },
@@ -1107,74 +1098,74 @@ const rt = /* @__PURE__ */ ce(Jr, [["render", et], ["__scopeId", "data-v-9c7113d
1107
1098
  cardToDisplay: { default: void 0 }
1108
1099
  },
1109
1100
  setup(e) {
1110
- const r = e, t = Ae(Ne);
1101
+ const r = e, t = Ve(Ue);
1111
1102
  if (!t)
1112
1103
  throw new Error("MetricsConsumer must be nested inside a MetricsProvider instance.");
1113
- const { traffic: i, latency: a } = t.data, { i18n: n } = M.useI18n(), l = g(() => t.containerTitle.value ? D.Medium : r.cardSize), d = M.useMetricCardBuilder({
1104
+ const { traffic: a, latency: i } = t.data, { i18n: n } = M.useI18n(), s = m(() => t.containerTitle.value ? D.Medium : r.cardSize), c = M.useMetricCardBuilder({
1114
1105
  cardType: O.TRAFFIC,
1115
- title: g(() => t.longCardTitles ? n.t("metricCard.long.traffic") : n.t("metricCard.short.traffic")),
1116
- record: i.mapped,
1117
- hasError: i.hasError,
1106
+ title: m(() => t.longCardTitles ? n.t("metricCard.long.traffic") : n.t("metricCard.short.traffic")),
1107
+ record: a.mapped,
1108
+ hasError: a.hasError,
1118
1109
  lookupKey: r.lookupKey,
1119
- sumGroupedValues: B,
1120
- trendRange: i.trendRange
1121
- }), f = (p) => `${p.toFixed(le)}%`, o = g(() => {
1122
- const p = i.mapped.value, h = K(p, "current", r.lookupKey, pe), m = K(p, "current", r.lookupKey, B), C = h / m * 100 || 0, E = K(p, "previous", r.lookupKey, pe), I = K(p, "previous", r.lookupKey, B), A = E / I * 100 || 0;
1110
+ sumGroupedValues: G,
1111
+ trendRange: a.trendRange
1112
+ }), d = (p) => `${p.toFixed(de)}%`, o = m(() => {
1113
+ const p = a.mapped.value, g = K(p, "current", r.lookupKey, Te), v = K(p, "current", r.lookupKey, G), _ = g / v * 100 || 0, E = K(p, "previous", r.lookupKey, Te), C = K(p, "previous", r.lookupKey, G), I = E / C * 100 || 0;
1123
1114
  return {
1124
1115
  cardType: O.ERROR_RATE,
1125
- hasError: i.hasError.value,
1126
- currentValue: C,
1127
- previousValue: A,
1128
- formatValueFn: f,
1116
+ hasError: a.hasError.value,
1117
+ currentValue: _,
1118
+ previousValue: I,
1119
+ formatValueFn: d,
1129
1120
  title: t.longCardTitles ? n.t("metricCard.long.errorRate") : n.t("metricCard.short.errorRate"),
1130
1121
  increaseIsBad: !0,
1131
- trendRange: i.trendRange.value
1122
+ trendRange: a.trendRange.value
1132
1123
  };
1133
- }), s = (p) => `${p}ms`, u = M.useMetricCardBuilder({
1124
+ }), l = (p) => `${p}ms`, u = M.useMetricCardBuilder({
1134
1125
  cardType: O.LATENCY,
1135
- title: g(() => {
1136
- const { longCardTitles: p, averageLatencies: h } = t, m = h.value ? "averageLatency" : "p99Latency";
1137
- return p ? n.t(`metricCard.long.${m}`) : l.value === D.Small ? n.t(`metricCard.small.${m}`) : n.t(`metricCard.short.${m}`);
1126
+ title: m(() => {
1127
+ const { longCardTitles: p, averageLatencies: g } = t, v = g.value ? "averageLatency" : "p99Latency";
1128
+ return p ? n.t(`metricCard.long.${v}`) : s.value === D.Small ? n.t(`metricCard.small.${v}`) : n.t(`metricCard.short.${v}`);
1138
1129
  }),
1139
- hasError: a.hasError,
1140
- record: a.mapped,
1130
+ hasError: i.hasError,
1131
+ record: i.mapped,
1141
1132
  lookupKey: r.lookupKey,
1142
1133
  increaseIsBad: !0,
1143
- formatValueFn: s,
1144
- trendRange: a.trendRange
1145
- }), c = g(() => r.cardToDisplay === "TRAFFIC" ? [d.value] : r.cardToDisplay === "ERROR_RATE" ? [o.value] : r.cardToDisplay === "LATENCY" ? [u.value] : [d.value, o.value, u.value]), v = g(() => r.cardToDisplay === "TRAFFIC" || r.cardToDisplay === "ERROR_RATE" ? i.isLoading.value : r.cardToDisplay === "LATENCY" ? a.isLoading.value : i.isLoading.value || a.isLoading.value), y = g(() => ({
1146
- cards: c.value,
1134
+ formatValueFn: l,
1135
+ trendRange: i.trendRange
1136
+ }), f = m(() => r.cardToDisplay === "TRAFFIC" ? [c.value] : r.cardToDisplay === "ERROR_RATE" ? [o.value] : r.cardToDisplay === "LATENCY" ? [u.value] : [c.value, o.value, u.value]), h = m(() => r.cardToDisplay === "TRAFFIC" || r.cardToDisplay === "ERROR_RATE" ? a.isLoading.value : r.cardToDisplay === "LATENCY" ? i.isLoading.value : a.isLoading.value || i.isLoading.value), y = m(() => ({
1137
+ cards: f.value,
1147
1138
  containerTitle: t.containerTitle.value,
1148
1139
  containerDescription: t.description.value,
1149
- loading: v.value,
1140
+ loading: h.value,
1150
1141
  hasTrendAccess: t.hasTrendAccess.value,
1151
1142
  fallbackDisplayText: n.t("general.notAvailable"),
1152
- cardSize: l.value,
1143
+ cardSize: s.value,
1153
1144
  hideTitle: !0
1154
- })), _ = g(() => ({
1145
+ })), A = m(() => ({
1155
1146
  loading: y.value.loading,
1156
- trafficCard: d.value,
1147
+ trafficCard: c.value,
1157
1148
  errorRateCard: o.value,
1158
1149
  latencyCard: u.value,
1159
- errorRateFormatted: f(o.value.currentValue),
1160
- latencyFormatted: s(u.value.currentValue)
1150
+ errorRateFormatted: d(o.value.currentValue),
1151
+ latencyFormatted: l(u.value.currentValue)
1161
1152
  }));
1162
- return (p, h) => De(p.$slots, "default", { cardValues: _.value }, () => [
1163
- F(ut, Ge(je(y.value)), null, 16)
1153
+ return (p, g) => Me(p.$slots, "default", { cardValues: A.value }, () => [
1154
+ F(ft, Je(Ze(y.value)), null, 16)
1164
1155
  ]);
1165
1156
  }
1166
- }), H = (e) => new Date(e), Rt = (e, r) => {
1157
+ }), Q = (e) => new Date(e), _t = (e, r) => {
1167
1158
  const t = e.body;
1168
1159
  e.reply({
1169
1160
  statusCode: 200,
1170
- body: lt(t, r)
1161
+ body: vt(t, r)
1171
1162
  });
1172
- }, Ie = (e) => e.reduce((r, t) => (r[t] = { name: t }, r), {}), lt = (e, r) => {
1173
- var _, p, h;
1163
+ }, Le = (e) => e.reduce((r, t) => (r[t] = { name: t }, r), {}), vt = (e, r) => {
1164
+ var A, p, g;
1174
1165
  const t = r != null && r.timeRange && {
1175
1166
  start: r.timeRange.start,
1176
1167
  end: r.timeRange.end
1177
- } || ((_ = e.time_range) == null ? void 0 : _.type) === "absolute" ? {
1168
+ } || ((A = e.time_range) == null ? void 0 : A.type) === "absolute" ? {
1178
1169
  // @ts-ignore - already asserted time range is absolute above
1179
1170
  start: new Date(e.time_range.start),
1180
1171
  // @ts-ignore - already asserted time range is absolute above
@@ -1182,68 +1173,68 @@ const rt = /* @__PURE__ */ ce(Jr, [["render", et], ["__scopeId", "data-v-9c7113d
1182
1173
  } : {
1183
1174
  start: new Date(Date.now() - 864e5),
1184
1175
  end: /* @__PURE__ */ new Date()
1185
- }, i = t.end.getTime() - t.start.getTime(), a = e.granularity === "trend" ? {
1186
- start: new Date(t.start.getTime() - i),
1176
+ }, a = t.end.getTime() - t.start.getTime(), i = e.granularity === "trend" ? {
1177
+ start: new Date(t.start.getTime() - a),
1187
1178
  end: t.end,
1188
1179
  granularity: t.end.getTime() - t.start.getTime()
1189
1180
  } : {
1190
1181
  start: t.start,
1191
1182
  end: t.end,
1192
1183
  granularity: t.end.getTime() - t.start.getTime()
1193
- }, n = a.end.getTime(), l = a.start.getTime(), d = a.granularity, f = e.granularity === "trend" ? 2 : 1;
1184
+ }, n = i.end.getTime(), s = i.start.getTime(), c = i.granularity, d = e.granularity === "trend" ? 2 : 1;
1194
1185
  if ((e.dimensions ?? []).length > 2)
1195
1186
  throw new Error(`Explore only supports 0-2 dimensions; got: ${JSON.stringify(e.dimensions)}`);
1196
- const o = (e.dimensions ?? []).find((m) => m !== "time"), s = (r == null ? void 0 : r.dimensionNames) ?? [], u = Math.max(s.length, 1), c = e.metrics || [], v = [];
1197
- for (let m = 0; m < f; m++)
1198
- for (let C = 0; C < u; C++) {
1199
- const E = o ? { [o]: s[C] } : {};
1200
- (p = e.dimensions) != null && p.includes("status_code_grouped") ? B.forEach((I) => {
1201
- const A = c.reduce((N, $) => ((r == null ? void 0 : r.deterministic) ?? !0 ? N[$] = (f - m) * 1e3 + 100 * C + 1 : N[$] = Math.round(Math.random() * 1e3), N), { ...E, status_code_grouped: I });
1202
- v.push({
1187
+ const o = (e.dimensions ?? []).find((v) => v !== "time"), l = (r == null ? void 0 : r.dimensionNames) ?? [], u = Math.max(l.length, 1), f = e.metrics || [], h = [];
1188
+ for (let v = 0; v < d; v++)
1189
+ for (let _ = 0; _ < u; _++) {
1190
+ const E = o ? { [o]: l[_] } : {};
1191
+ (p = e.dimensions) != null && p.includes("status_code_grouped") ? G.forEach((C) => {
1192
+ const I = f.reduce((N, B) => ((r == null ? void 0 : r.deterministic) ?? !0 ? N[B] = (d - v) * 1e3 + 100 * _ + 1 : N[B] = Math.round(Math.random() * 1e3), N), { ...E, status_code_grouped: C });
1193
+ h.push({
1203
1194
  version: "v1",
1204
- timestamp: m === 0 ? H(l).toISOString() : H(l + d).toISOString(),
1205
- event: A
1195
+ timestamp: v === 0 ? Q(s).toISOString() : Q(s + c).toISOString(),
1196
+ event: I
1206
1197
  });
1207
- }) : v.push({
1198
+ }) : h.push({
1208
1199
  version: "v1",
1209
- timestamp: m === 0 ? H(l).toISOString() : H(l + d).toISOString(),
1210
- event: c.reduce((I, A) => ((r == null ? void 0 : r.deterministic) ?? !0 ? I[A] = (f - m) * 1e3 + 100 * C + 1 : I[A] = Math.round(Math.random() * 1e3), I), { ...E })
1200
+ timestamp: v === 0 ? Q(s).toISOString() : Q(s + c).toISOString(),
1201
+ event: f.reduce((C, I) => ((r == null ? void 0 : r.deterministic) ?? !0 ? C[I] = (d - v) * 1e3 + 100 * _ + 1 : C[I] = Math.round(Math.random() * 1e3), C), { ...E })
1211
1202
  });
1212
1203
  }
1213
1204
  const y = {
1214
- start: new Date(l).toISOString(),
1205
+ start: new Date(s).toISOString(),
1215
1206
  end: new Date(n).toISOString(),
1216
- granularity_ms: d,
1207
+ granularity_ms: c,
1217
1208
  display: o ? {
1218
- [o]: Ie(s),
1219
- ...(h = e.dimensions) != null && h.includes("status_code_grouped") ? { status_code_grouped: Ie(B) } : {}
1209
+ [o]: Le(l),
1210
+ ...(g = e.dimensions) != null && g.includes("status_code_grouped") ? { status_code_grouped: Le(G) } : {}
1220
1211
  } : {},
1221
1212
  metric_names: e.metrics,
1222
1213
  query_id: "test"
1223
1214
  };
1224
1215
  return {
1225
- data: v,
1216
+ data: h,
1226
1217
  meta: y
1227
1218
  };
1228
1219
  };
1229
1220
  export {
1230
- B as ALL_STATUS_CODE_GROUPS,
1231
- le as DECIMAL_DISPLAY,
1232
- _e as DECIMAL_ROUNDING_PRECISION,
1233
- vr as DEFAULT_REFRESH_INTERVAL,
1234
- mr as INJECT_QUERY_PROVIDER,
1235
- fr as MAX_ANALYTICS_REQUEST_RETRIES,
1221
+ G as ALL_STATUS_CODE_GROUPS,
1222
+ de as DECIMAL_DISPLAY,
1223
+ be as DECIMAL_ROUNDING_PRECISION,
1224
+ Rr as DEFAULT_REFRESH_INTERVAL,
1225
+ Tr as INJECT_QUERY_PROVIDER,
1226
+ pr as MAX_ANALYTICS_REQUEST_RETRIES,
1236
1227
  D as MetricCardSize,
1237
1228
  O as MetricCardType,
1238
- pt as MetricsConsumer,
1239
- ht as MetricsProvider,
1240
- pe as STATUS_CODES_FAILED,
1241
- gt as STATUS_CODES_SUCCESS,
1242
- Pr as calculateChange,
1243
- xr as changePolarity,
1244
- Ur as defineIcon,
1245
- qr as metricChange,
1246
- lt as mockExploreResponse,
1247
- Rt as mockExploreResponseFromCypress,
1248
- Tr as useTrendRange
1229
+ St as MetricsConsumer,
1230
+ Et as MetricsProvider,
1231
+ Te as STATUS_CODES_FAILED,
1232
+ Tt as STATUS_CODES_SUCCESS,
1233
+ Kr as calculateChange,
1234
+ Pr as changePolarity,
1235
+ Br as defineIcon,
1236
+ zr as metricChange,
1237
+ vt as mockExploreResponse,
1238
+ _t as mockExploreResponseFromCypress,
1239
+ Ar as useTrendRange
1249
1240
  };