@kong-ui-public/analytics-metric-provider 11.0.13 → 11.0.14-pr.2745.ad462290d.0

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