adonisjs-server-stats 1.9.0 → 1.10.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.
Files changed (80) hide show
  1. package/dist/core/index.js +24 -22
  2. package/dist/core/split-pane.d.ts +18 -0
  3. package/dist/core/trace-utils.d.ts +5 -0
  4. package/dist/core/types.d.ts +1 -1
  5. package/dist/react/{CacheSection-xH75hwXu.js → CacheSection-UCMptWyn.js} +1 -1
  6. package/dist/react/{CacheTab-DYmsZJJ1.js → CacheTab-CA8LB1J5.js} +1 -1
  7. package/dist/react/{ConfigSection-D8BO1Ry9.js → ConfigSection-DfFd-WRq.js} +1 -1
  8. package/dist/react/{ConfigTab-CcN-tfjv.js → ConfigTab-Bdg8YMer.js} +1 -1
  9. package/dist/react/{CustomPaneTab-D7_o3Ec6.js → CustomPaneTab-Bxtv_8Rw.js} +1 -1
  10. package/dist/react/{EmailsSection-BzlsTdPs.js → EmailsSection-CM7stSyh.js} +1 -1
  11. package/dist/react/{EmailsTab-Uh2CQY3o.js → EmailsTab-BDhEiomM.js} +1 -1
  12. package/dist/react/{EventsSection-CGQWiIdV.js → EventsSection-ByQ-9blq.js} +1 -1
  13. package/dist/react/{EventsTab-CC6DQzEm.js → EventsTab-CMfY98Rl.js} +1 -1
  14. package/dist/react/{JobsSection-D7AHQmZi.js → JobsSection-DF3qEv9O.js} +1 -1
  15. package/dist/react/{JobsTab-B3Lfdqed.js → JobsTab-BbrBWIOb.js} +1 -1
  16. package/dist/react/{LogsSection-Cly1dpvS.js → LogsSection-DcFTZY7b.js} +1 -1
  17. package/dist/react/{LogsTab-BbYK-iyh.js → LogsTab-CicucmVk.js} +2 -2
  18. package/dist/react/{OverviewSection-CkBGFEWq.js → OverviewSection-C4T1ur51.js} +1 -1
  19. package/dist/react/{QueriesSection-CfCpnNUD.js → QueriesSection-PswteoF9.js} +1 -1
  20. package/dist/react/{QueriesTab-DbBmAqzO.js → QueriesTab-osLUWd4L.js} +1 -1
  21. package/dist/react/RelatedLogs-DFDOyUMr.js +40 -0
  22. package/dist/react/RequestsSection-Nag30rEA.js +341 -0
  23. package/dist/react/{RoutesSection-CRqF-cNM.js → RoutesSection-BUSkM6PY.js} +1 -1
  24. package/dist/react/{RoutesTab-Bwreij3e.js → RoutesTab-DgVzd2PZ.js} +1 -1
  25. package/dist/react/TimelineTab-Covg5weo.js +220 -0
  26. package/dist/react/{index-CecA4IdQ.js → index-Cflz9Ebj.js} +197 -203
  27. package/dist/react/index.js +1 -1
  28. package/dist/react/react/components/shared/RelatedLogs.d.ts +7 -0
  29. package/dist/react/style.css +1 -1
  30. package/dist/src/controller/debug_controller.js +1 -1
  31. package/dist/src/dashboard/dashboard_controller.js +13 -0
  32. package/dist/src/dashboard/dashboard_store.d.ts +1 -0
  33. package/dist/src/dashboard/dashboard_store.js +88 -41
  34. package/dist/src/dashboard/migrator.js +6 -0
  35. package/dist/src/data/data_access.d.ts +7 -0
  36. package/dist/src/data/data_access.js +32 -1
  37. package/dist/src/debug/trace_collector.d.ts +1 -1
  38. package/dist/src/debug/trace_collector.js +2 -1
  39. package/dist/src/debug/types.d.ts +4 -0
  40. package/dist/src/edge/client/dashboard.js +2 -2
  41. package/dist/src/edge/client/debug-panel-deferred.js +1 -1
  42. package/dist/src/edge/client-vue/dashboard.js +4 -4
  43. package/dist/src/edge/client-vue/debug-panel-deferred.js +3 -3
  44. package/dist/src/middleware/request_tracking_middleware.d.ts +1 -0
  45. package/dist/src/middleware/request_tracking_middleware.js +3 -1
  46. package/dist/src/provider/server_stats_provider.d.ts +3 -3
  47. package/dist/src/provider/server_stats_provider.js +29 -15
  48. package/dist/src/routes/register_routes.js +7 -2
  49. package/dist/src/styles/components.css +81 -0
  50. package/dist/src/styles/debug-panel.css +9 -0
  51. package/dist/src/types.d.ts +1 -1
  52. package/dist/vue/{CacheSection-Cx-hj09X.js → CacheSection-oFAJL3mo.js} +1 -1
  53. package/dist/vue/{ConfigSection-CMXyryf6.js → ConfigSection-BhfJ4KqL.js} +1 -1
  54. package/dist/vue/{EmailsSection-DgKl9xGT.js → EmailsSection-BcNyhyHs.js} +1 -1
  55. package/dist/vue/{EventsSection-BNMCAim1.js → EventsSection-r60Q5Lmu.js} +1 -1
  56. package/dist/vue/{JobsSection-CCMgMlxd.js → JobsSection-BHL-hkQw.js} +1 -1
  57. package/dist/vue/{LogsSection-CvOnTxUu.js → LogsSection-DRMGzJmg.js} +1 -1
  58. package/dist/vue/{OverviewSection-CHgaKtUR.js → OverviewSection-CXh6Ja1B.js} +1 -1
  59. package/dist/vue/{QueriesSection-BnHRD98z.js → QueriesSection-IodIsCJ-.js} +1 -1
  60. package/dist/vue/RelatedLogs.vue_vue_type_script_setup_true_lang-CB2_TzYW.js +84 -0
  61. package/dist/vue/RequestsSection-BPuMdmMc.js +401 -0
  62. package/dist/vue/{RoutesSection-BrceOcKQ.js → RoutesSection-NKo3Rbq3.js} +1 -1
  63. package/dist/vue/TimelineTab-zj5Z5OdT.js +338 -0
  64. package/dist/vue/components/Dashboard/sections/RequestsSection.vue.d.ts +4 -0
  65. package/dist/vue/components/DebugPanel/tabs/TimelineTab.vue.d.ts +4 -0
  66. package/dist/vue/components/{Dashboard/sections/TimelineSection.vue.d.ts → shared/RelatedLogs.vue.d.ts} +5 -6
  67. package/dist/vue/index-Dtgysd26.js +1229 -0
  68. package/dist/vue/index.js +1 -1
  69. package/dist/vue/style.css +1 -1
  70. package/package.json +1 -1
  71. package/dist/react/RequestsSection-Cb5a6MlT.js +0 -209
  72. package/dist/react/TimelineSection-B2y06kRE.js +0 -158
  73. package/dist/react/TimelineTab-6hthfdBB.js +0 -193
  74. package/dist/react/WaterfallChart-Cj73WdfM.js +0 -100
  75. package/dist/react/react/components/Dashboard/sections/TimelineSection.d.ts +0 -8
  76. package/dist/vue/RequestsSection-B-uSlM0f.js +0 -243
  77. package/dist/vue/TimelineSection-CfvnA2Oo.js +0 -186
  78. package/dist/vue/TimelineTab-Db6lKKsD.js +0 -250
  79. package/dist/vue/WaterfallChart.vue_vue_type_script_setup_true_lang-tZ13cNj1.js +0 -118
  80. package/dist/vue/index-oLxS08vN.js +0 -1235
@@ -0,0 +1,1229 @@
1
+ import { ref as g, reactive as ae, computed as k, onMounted as K, onUnmounted as ee, defineComponent as te, openBlock as s, createElementBlock as o, normalizeStyle as be, Fragment as J, createElementVNode as l, watch as Y, nextTick as pe, onBeforeUnmount as ue, normalizeClass as A, toDisplayString as L, createCommentVNode as S, createBlock as N, Teleport as me, withModifiers as ke, unref as n, createVNode as ie, renderList as ne, defineAsyncComponent as B, createTextVNode as ye, provide as se, Suspense as we, withCtx as ce, resolveDynamicComponent as Te } from "vue";
2
+ import { ServerStatsController as Ce, DEFAULT_FEATURES as _e, detectFeatures as Ee, getTheme as de, onThemeChange as Se, toggleTheme as xe, buildSparklineData as $e, computeStats as Le, formatStatNum as le, detectMetricGroupsFromStats as Be, getVisibleMetricGroups as Me, getMetricsByGroup as Pe, TAB_ICONS as D, DebugDataController as he, DashboardDataController as Ue, UnauthorizedError as Re, subscribeToChannel as De } from "adonisjs-server-stats/core";
3
+ function je(e = {}) {
4
+ const {
5
+ baseUrl: T = "",
6
+ endpoint: a = "/admin/api/server-stats",
7
+ channelName: x = "admin/server-stats",
8
+ authToken: r,
9
+ pollInterval: p = 3e3
10
+ } = e, _ = g(null), y = ae({}), $ = g(!1), M = g(!1), P = g(null), E = g(!1), d = g(!1), u = g(!1);
11
+ let m = null;
12
+ const c = k(() => E.value ? "disconnected" : d.value ? "live" : u.value ? "polling" : "disconnected");
13
+ return K(() => {
14
+ E.value || (m = new Ce({
15
+ baseUrl: T,
16
+ endpoint: a,
17
+ channelName: x,
18
+ authToken: r,
19
+ pollInterval: p,
20
+ onStatsUpdate: (f) => {
21
+ _.value = f;
22
+ },
23
+ onConnectionChange: (f) => {
24
+ $.value = f;
25
+ },
26
+ onStaleChange: (f) => {
27
+ M.value = f;
28
+ },
29
+ onError: (f) => {
30
+ P.value = f;
31
+ },
32
+ onUnauthorizedChange: (f) => {
33
+ E.value = f;
34
+ },
35
+ onHistoryChange: (f) => {
36
+ for (const b of Object.keys(f))
37
+ y[b] = f[b];
38
+ },
39
+ onSseActiveChange: (f) => {
40
+ d.value = f;
41
+ },
42
+ onPollActiveChange: (f) => {
43
+ u.value = f;
44
+ }
45
+ }), m.start());
46
+ }), ee(() => {
47
+ m?.stop(), m = null;
48
+ }), {
49
+ stats: _,
50
+ history: y,
51
+ isConnected: $,
52
+ isStale: M,
53
+ isUnauthorized: E,
54
+ error: P,
55
+ connectionMode: c
56
+ };
57
+ }
58
+ function re(e = {}) {
59
+ const { baseUrl: T = "", debugEndpoint: a = "/admin/api/debug", authToken: x } = e, r = g({ ..._e }), p = g(!0);
60
+ return K(async () => {
61
+ r.value = await Ee({ baseUrl: T, debugEndpoint: a, authToken: x }), p.value = !1;
62
+ }), {
63
+ features: r,
64
+ loading: p
65
+ };
66
+ }
67
+ function oe() {
68
+ const e = g(de());
69
+ let T = null;
70
+ function a(r) {
71
+ e.value = r;
72
+ }
73
+ function x() {
74
+ const r = xe();
75
+ return e.value = r, r;
76
+ }
77
+ return K(() => {
78
+ e.value = de(), T = Se(a);
79
+ }), ee(() => {
80
+ T?.();
81
+ }), {
82
+ theme: e,
83
+ toggleTheme: x
84
+ };
85
+ }
86
+ const He = ["width", "height", "viewBox"], Ae = ["id"], Ie = ["stop-color"], qe = ["stop-color"], Oe = ["d", "fill"], ze = ["d", "stroke"], Ne = ["x", "y"], Fe = /* @__PURE__ */ te({
87
+ __name: "Sparkline",
88
+ props: {
89
+ data: {},
90
+ color: { default: "#34d399" },
91
+ width: { default: 120 },
92
+ height: { default: 32 }
93
+ },
94
+ setup(e) {
95
+ const T = e, a = k(
96
+ () => $e(T.data, {
97
+ width: T.width,
98
+ height: T.height,
99
+ color: T.color
100
+ })
101
+ ), x = k(() => a.value !== null), r = k(() => `sg-${T.color.replace("#", "")}`);
102
+ return (p, _) => (s(), o("div", {
103
+ class: "ss-dash-sparkline",
104
+ style: be({ "--ss-accent": e.color })
105
+ }, [
106
+ (s(), o("svg", {
107
+ width: e.width,
108
+ height: e.height,
109
+ viewBox: `0 0 ${e.width} ${e.height}`,
110
+ style: { display: "block" }
111
+ }, [
112
+ x.value && a.value ? (s(), o(J, { key: 0 }, [
113
+ l("defs", null, [
114
+ l("linearGradient", {
115
+ id: r.value,
116
+ x1: "0",
117
+ y1: "0",
118
+ x2: "0",
119
+ y2: "1"
120
+ }, [
121
+ l("stop", {
122
+ offset: "0%",
123
+ "stop-color": e.color,
124
+ "stop-opacity": "0.25"
125
+ }, null, 8, Ie),
126
+ l("stop", {
127
+ offset: "100%",
128
+ "stop-color": e.color,
129
+ "stop-opacity": "0.02"
130
+ }, null, 8, qe)
131
+ ], 8, Ae)
132
+ ]),
133
+ l("path", {
134
+ d: a.value.areaPath,
135
+ fill: `url(#${r.value})`
136
+ }, null, 8, Oe),
137
+ l("path", {
138
+ class: "ss-dash-sparkline-line",
139
+ d: "M" + a.value.points.replace(/ /g, " L"),
140
+ fill: "none",
141
+ stroke: e.color,
142
+ "stroke-width": "1.5",
143
+ "stroke-linejoin": "round",
144
+ "stroke-linecap": "round"
145
+ }, null, 8, ze)
146
+ ], 64)) : (s(), o("text", {
147
+ key: 1,
148
+ x: e.width / 2,
149
+ y: e.height / 2 + 3,
150
+ "text-anchor": "middle",
151
+ fill: "#737373",
152
+ "font-size": "9"
153
+ }, " collecting... ", 8, Ne))
154
+ ], 8, He))
155
+ ], 4));
156
+ }
157
+ }), Ve = ["id"], Ge = { class: "ss-label" }, Qe = {
158
+ class: "ss-tooltip-inner",
159
+ style: { position: "relative" }
160
+ }, Je = { class: "ss-tooltip-header" }, Ke = { class: "ss-tooltip-title" }, We = {
161
+ key: 0,
162
+ class: "ss-tooltip-unit"
163
+ }, Xe = { class: "ss-tooltip-current" }, Ye = { class: "ss-tooltip-current-value" }, Ze = {
164
+ key: 1,
165
+ class: "ss-tooltip-stats"
166
+ }, et = {
167
+ key: 2,
168
+ class: "ss-tooltip-details"
169
+ }, tt = {
170
+ key: 3,
171
+ class: "ss-tooltip-sparkline"
172
+ }, st = {
173
+ key: 4,
174
+ class: "ss-tooltip-samples"
175
+ }, nt = /* @__PURE__ */ te({
176
+ __name: "MetricCard",
177
+ props: {
178
+ metric: {},
179
+ stats: {},
180
+ history: {}
181
+ },
182
+ emits: ["pin"],
183
+ setup(e, { emit: T }) {
184
+ const a = e, x = T, r = g(!1), p = g(!1), _ = g(null), y = g(null), $ = g(null), M = g({
185
+ position: "absolute",
186
+ bottom: "100%",
187
+ left: "0",
188
+ marginBottom: "10px",
189
+ zIndex: "180"
190
+ });
191
+ K(() => {
192
+ _.value && ($.value = _.value.closest(".ss-bar"));
193
+ });
194
+ function P() {
195
+ const R = _.value, z = y.value, X = $.value;
196
+ if (!R || !z || !X) return;
197
+ const O = R.getBoundingClientRect(), G = X.getBoundingClientRect(), Z = O.left - G.left + O.width / 2;
198
+ M.value = {
199
+ position: "absolute",
200
+ bottom: "100%",
201
+ left: `${Z}px`,
202
+ transform: "translateX(-50%)",
203
+ marginBottom: "10px",
204
+ zIndex: "180"
205
+ }, requestAnimationFrame(() => {
206
+ if (!y.value) return;
207
+ const w = y.value.getBoundingClientRect();
208
+ let h = 0;
209
+ w.left < 8 ? h = 8 - w.left : w.right > window.innerWidth - 8 && (h = window.innerWidth - 8 - w.right), h && (M.value = {
210
+ ...M.value,
211
+ transform: `translateX(calc(-50% + ${h}px))`
212
+ });
213
+ });
214
+ }
215
+ const E = k(() => r.value || p.value);
216
+ Y(E, (R) => {
217
+ R && pe(P);
218
+ });
219
+ let d = null;
220
+ function u() {
221
+ E.value && P();
222
+ }
223
+ function m() {
224
+ E.value && P();
225
+ }
226
+ K(() => {
227
+ d = _.value?.closest(".ss-bar-scroll") ?? null, d?.addEventListener("scroll", u), window.addEventListener("resize", m);
228
+ }), ue(() => {
229
+ d?.removeEventListener("scroll", u), window.removeEventListener("resize", m);
230
+ });
231
+ const c = k(() => a.stats ? (a.metric.value || a.metric.format)(a.stats) : "..."), f = k(() => !a.stats || !a.metric.color ? "green" : a.metric.color(a.stats)), b = k(() => !a.stats || !a.metric.show ? !0 : a.metric.show(a.stats)), j = k(() => a.metric.detail ? typeof a.metric.detail == "function" ? a.stats ? a.metric.detail(a.stats) : "" : a.metric.detail : ""), q = k(() => ({
232
+ green: "#34d399",
233
+ amber: "#fbbf24",
234
+ red: "#f87171",
235
+ muted: "#737373"
236
+ })[f.value] || "#34d399"), I = k(() => Le(a.history));
237
+ function i() {
238
+ r.value = !0;
239
+ }
240
+ function C() {
241
+ r.value = !1;
242
+ }
243
+ function U() {
244
+ p.value = !p.value, p.value && x("pin", a.metric.id);
245
+ }
246
+ function H() {
247
+ p.value = !1;
248
+ }
249
+ function W(R) {
250
+ R.key === "Enter" && U();
251
+ }
252
+ function F(R) {
253
+ const z = R.target;
254
+ _.value && !_.value.contains(z) && y.value && !y.value.contains(z) && (p.value = !1);
255
+ }
256
+ function V(R) {
257
+ R.key === "Escape" && (p.value = !1);
258
+ }
259
+ return Y(p, (R) => {
260
+ R ? (document.addEventListener("click", F), document.addEventListener("keydown", V)) : (document.removeEventListener("click", F), document.removeEventListener("keydown", V));
261
+ }), ue(() => {
262
+ document.removeEventListener("click", F), document.removeEventListener("keydown", V);
263
+ }), (R, z) => (s(), o(J, null, [
264
+ b.value ? (s(), o("div", {
265
+ key: 0,
266
+ ref_key: "badgeRef",
267
+ ref: _,
268
+ id: `ss-b-${e.metric.id}`,
269
+ class: A(["ss-badge", { "ss-pinned": p.value }]),
270
+ role: "button",
271
+ tabindex: 0,
272
+ onMouseenter: i,
273
+ onMouseleave: C,
274
+ onClick: U,
275
+ onKeydown: W
276
+ }, [
277
+ l("span", Ge, L(e.metric.label), 1),
278
+ l("span", {
279
+ class: A(["ss-value", `ss-${f.value}`])
280
+ }, L(c.value), 3)
281
+ ], 42, Ve)) : S("", !0),
282
+ E.value && $.value ? (s(), N(me, {
283
+ key: 1,
284
+ to: $.value
285
+ }, [
286
+ l("div", {
287
+ ref_key: "tooltipRef",
288
+ ref: y,
289
+ class: A(["ss-tooltip", { "ss-pinned": p.value }]),
290
+ style: be(M.value)
291
+ }, [
292
+ l("div", Qe, [
293
+ p.value ? (s(), o("button", {
294
+ key: 0,
295
+ class: "ss-tooltip-close",
296
+ onClick: ke(H, ["stop"])
297
+ }, "×")) : S("", !0),
298
+ l("div", Je, [
299
+ l("span", Ke, L(e.metric.title), 1),
300
+ e.metric.unit ? (s(), o("span", We, L(e.metric.unit), 1)) : S("", !0)
301
+ ]),
302
+ l("div", Xe, [
303
+ z[0] || (z[0] = l("span", { class: "ss-tooltip-current-label" }, "Current: ", -1)),
304
+ l("span", Ye, L(c.value), 1)
305
+ ]),
306
+ I.value ? (s(), o("div", Ze, [
307
+ l("span", null, "Min: " + L(n(le)(I.value.min, e.metric.unit)), 1),
308
+ l("span", null, "Max: " + L(n(le)(I.value.max, e.metric.unit)), 1),
309
+ l("span", null, "Avg: " + L(n(le)(I.value.avg, e.metric.unit)), 1)
310
+ ])) : S("", !0),
311
+ j.value ? (s(), o("div", et, L(j.value), 1)) : S("", !0),
312
+ e.history.length > 0 ? (s(), o("div", tt, [
313
+ ie(Fe, {
314
+ data: e.history,
315
+ color: q.value
316
+ }, null, 8, ["data", "color"])
317
+ ])) : S("", !0),
318
+ e.history.length > 0 ? (s(), o("div", st, " Last " + L(Math.min(e.history.length, 60)) + " samples (~" + L(Math.round(Math.min(e.history.length, 60) * 3 / 60)) + " min) ", 1)) : S("", !0)
319
+ ]),
320
+ z[1] || (z[1] = l("div", { class: "ss-tooltip-arrow" }, null, -1))
321
+ ], 6)
322
+ ], 8, ["to"])) : S("", !0)
323
+ ], 64));
324
+ }
325
+ }), at = ["data-ss-theme"], ot = { class: "ss-bar-left" }, lt = ["viewBox", "innerHTML"], it = { class: "ss-group" }, rt = {
326
+ key: 0,
327
+ class: "ss-group-sep"
328
+ }, ut = ["data-ss-theme", "title"], ct = {
329
+ key: 0,
330
+ class: "ss-toggle-summary",
331
+ style: { display: "flex" }
332
+ }, dt = {
333
+ key: 1,
334
+ class: "ss-value ss-green"
335
+ }, ht = {
336
+ key: 1,
337
+ class: "ss-toggle-label",
338
+ style: { color: "#737373" }
339
+ }, vt = { class: "ss-toggle-arrow" }, ve = "admin:stats-bar", ss = /* @__PURE__ */ te({
340
+ __name: "StatsBar",
341
+ props: {
342
+ debugEndpoint: { default: "/admin/api/debug" },
343
+ baseUrl: { default: "" },
344
+ endpoint: { default: "/admin/api/server-stats" },
345
+ channelName: { default: "admin/server-stats" },
346
+ authToken: {},
347
+ pollInterval: { default: 3e3 },
348
+ className: {},
349
+ debugPanelOpen: { type: Boolean, default: !1 }
350
+ },
351
+ emits: ["openDebugPanel", "connectionChange"],
352
+ setup(e, { emit: T }) {
353
+ const a = e, x = T, { stats: r, history: p, isStale: _, isUnauthorized: y, isConnected: $, connectionMode: M } = je({
354
+ baseUrl: a.baseUrl,
355
+ endpoint: a.endpoint,
356
+ channelName: a.channelName,
357
+ authToken: a.authToken,
358
+ pollInterval: a.pollInterval
359
+ });
360
+ Y($, (C) => {
361
+ x("connectionChange", C);
362
+ });
363
+ const { features: P } = re({
364
+ baseUrl: a.baseUrl,
365
+ debugEndpoint: a.debugEndpoint,
366
+ authToken: a.authToken
367
+ }), { theme: E } = oe(), d = g(!0), u = g(null);
368
+ K(() => {
369
+ d.value = localStorage.getItem(ve) !== "hidden";
370
+ const C = u.value;
371
+ if (C) {
372
+ const U = (H) => {
373
+ Math.abs(H.deltaX) > Math.abs(H.deltaY) || (H.preventDefault(), C.scrollLeft += H.deltaY);
374
+ };
375
+ C.addEventListener("wheel", U, { passive: !1 }), ee(() => C.removeEventListener("wheel", U));
376
+ }
377
+ });
378
+ function m() {
379
+ d.value = !d.value, localStorage.setItem(ve, d.value ? "visible" : "hidden");
380
+ }
381
+ Y(y, (C) => {
382
+ C && (d.value = !1);
383
+ });
384
+ const c = k(() => r.value ? Be(r.value) : Me(P.value)), f = k(() => {
385
+ const C = Pe();
386
+ return Array.from(C.entries()).filter(([U]) => c.value.has(U)).map(([U, H]) => ({
387
+ name: U,
388
+ metrics: H
389
+ }));
390
+ });
391
+ function b(C) {
392
+ return C ? p[C] || [] : [];
393
+ }
394
+ const j = k(() => r.value ? `${r.value.cpuPercent.toFixed(0)}%` : "..."), q = k(() => r.value ? r.value.memHeapUsed !== void 0 ? Math.round(r.value.memHeapUsed / (1024 * 1024)) + "M" : "-" : "..."), I = k(() => r.value ? r.value.redisOk ? "✓" : "✗" : "..."), i = k(() => E.value);
395
+ return (C, U) => (s(), o(J, null, [
396
+ n(y) ? S("", !0) : (s(), o("div", {
397
+ key: 0,
398
+ id: "ss-bar",
399
+ class: A(["ss-bar", { "ss-hidden": !d.value }]),
400
+ "data-ss-theme": i.value
401
+ }, [
402
+ l("div", ot, [
403
+ n(P).tracing || c.value.has("redis") || c.value.has("queue") ? (s(), o("button", {
404
+ key: 0,
405
+ type: "button",
406
+ class: A(["ss-dbg-btn", { "ss-dbg-active": e.debugPanelOpen }]),
407
+ title: "Toggle debug panel",
408
+ id: "ss-dbg-wrench",
409
+ onClick: U[0] || (U[0] = (H) => x("openDebugPanel"))
410
+ }, [
411
+ (s(), o("svg", {
412
+ width: "14",
413
+ height: "14",
414
+ viewBox: n(D).wrench.viewBox,
415
+ fill: "none",
416
+ stroke: "currentColor",
417
+ "stroke-width": "2",
418
+ "stroke-linecap": "round",
419
+ "stroke-linejoin": "round",
420
+ innerHTML: n(D).wrench.elements.join("")
421
+ }, null, 8, lt))
422
+ ], 2)) : S("", !0),
423
+ l("div", {
424
+ class: A(["ss-dot", { "ss-stale": n(_) }])
425
+ }, null, 2)
426
+ ]),
427
+ l("div", {
428
+ ref_key: "scrollRef",
429
+ ref: u,
430
+ id: "ss-bar-scroll",
431
+ class: "ss-bar-scroll"
432
+ }, [
433
+ (s(!0), o(J, null, ne(f.value, (H, W) => (s(), o(J, {
434
+ key: H.name
435
+ }, [
436
+ l("div", it, [
437
+ (s(!0), o(J, null, ne(H.metrics, (F) => (s(), N(nt, {
438
+ key: F.id,
439
+ metric: F,
440
+ stats: n(r),
441
+ history: b(F.historyKey)
442
+ }, null, 8, ["metric", "stats", "history"]))), 128))
443
+ ]),
444
+ W < f.value.length - 1 ? (s(), o("div", rt)) : S("", !0)
445
+ ], 64))), 128))
446
+ ], 512)
447
+ ], 10, at)),
448
+ n(y) ? S("", !0) : (s(), o("button", {
449
+ key: 1,
450
+ type: "button",
451
+ class: A(["ss-toggle", d.value ? "ss-visible" : "ss-collapsed"]),
452
+ "data-ss-theme": i.value,
453
+ title: d.value ? "Hide stats bar" : "Show stats bar",
454
+ onClick: m
455
+ }, [
456
+ !d.value && n(r) ? (s(), o("span", ct, [
457
+ c.value.has("process") ? (s(), o("span", {
458
+ key: 0,
459
+ class: A([
460
+ "ss-value",
461
+ n(r).cpuPercent > 80 ? "ss-red" : n(r).cpuPercent > 50 ? "ss-amber" : "ss-green"
462
+ ])
463
+ }, L(j.value), 3)) : S("", !0),
464
+ c.value.has("process") ? (s(), o("span", dt, L(q.value), 1)) : S("", !0),
465
+ c.value.has("redis") && n(r)?.redisOk !== void 0 ? (s(), o("span", {
466
+ key: 2,
467
+ class: A(["ss-value", n(r)?.redisOk ? "ss-green" : "ss-red"])
468
+ }, L(I.value), 3)) : S("", !0)
469
+ ])) : S("", !0),
470
+ d.value ? (s(), o("span", ht, "hide stats")) : S("", !0),
471
+ l("span", vt, L(d.value ? "▼" : "▲"), 1)
472
+ ], 10, ut))
473
+ ], 64));
474
+ }
475
+ }), fe = /* @__PURE__ */ new Set(["cache", "jobs", "config"]);
476
+ function ft(e, T = {}) {
477
+ const {
478
+ baseUrl: a = "",
479
+ debugEndpoint: x = "/admin/api/debug",
480
+ dashboardEndpoint: r,
481
+ authToken: p,
482
+ refreshInterval: _
483
+ } = T, y = g(null), $ = g(!1), M = g(null), P = g(!1), E = new he({
484
+ baseUrl: a,
485
+ endpoint: x,
486
+ authToken: p,
487
+ refreshInterval: _,
488
+ onData: (i) => {
489
+ y.value = i;
490
+ },
491
+ onLoading: (i) => {
492
+ $.value = i;
493
+ },
494
+ onError: (i) => {
495
+ M.value = i;
496
+ },
497
+ onUnauthorized: () => {
498
+ P.value = !0;
499
+ }
500
+ });
501
+ let d = null;
502
+ function u() {
503
+ return !d && r && (d = new he({
504
+ baseUrl: a,
505
+ endpoint: r,
506
+ authToken: p,
507
+ refreshInterval: _,
508
+ onData: (i) => {
509
+ y.value = i;
510
+ },
511
+ onLoading: (i) => {
512
+ $.value = i;
513
+ },
514
+ onError: (i) => {
515
+ M.value = i;
516
+ },
517
+ onUnauthorized: () => {
518
+ P.value = !0;
519
+ }
520
+ })), d;
521
+ }
522
+ function m() {
523
+ const i = e();
524
+ if (i && !i.startsWith("custom-"))
525
+ if (fe.has(i) && r) {
526
+ const C = u();
527
+ E.stop(), C.start(i);
528
+ } else
529
+ d?.stop(), E.start(i);
530
+ }
531
+ function c() {
532
+ E.stop(), d?.stop();
533
+ }
534
+ async function f(i, C = !1) {
535
+ await E.fetchCustomPane(i, C);
536
+ }
537
+ function b() {
538
+ m();
539
+ }
540
+ function j() {
541
+ c();
542
+ }
543
+ function q() {
544
+ const i = e();
545
+ fe.has(i) && r && d ? d.refresh() : E.refresh();
546
+ }
547
+ function I() {
548
+ y.value = null;
549
+ }
550
+ return Y(e, () => {
551
+ I(), m();
552
+ }), K(() => {
553
+ b();
554
+ }), ee(() => {
555
+ c();
556
+ }), {
557
+ data: y,
558
+ loading: $,
559
+ error: M,
560
+ isUnauthorized: P,
561
+ refresh: q,
562
+ clear: I,
563
+ fetchCustomPane: f,
564
+ startRefresh: b,
565
+ stopRefresh: j
566
+ };
567
+ }
568
+ const bt = ["title", "aria-label"], gt = ["viewBox", "innerHTML"], pt = ["viewBox", "innerHTML"], ge = /* @__PURE__ */ te({
569
+ __name: "ThemeToggle",
570
+ props: {
571
+ classPrefix: { default: "ss-dbg" }
572
+ },
573
+ setup(e) {
574
+ const T = e, { theme: a, toggleTheme: x } = oe(), r = k(() => a.value === "dark"), p = k(() => r.value ? "Switch to light theme" : "Switch to dark theme"), _ = k(
575
+ () => T.classPrefix === "ss-dbg" ? "ss-dbg-theme-toggle" : "ss-dash-theme-btn"
576
+ );
577
+ return (y, $) => (s(), o("button", {
578
+ type: "button",
579
+ class: A(_.value),
580
+ title: p.value,
581
+ "aria-label": p.value,
582
+ onClick: $[0] || ($[0] = //@ts-ignore
583
+ (...M) => n(x) && n(x)(...M))
584
+ }, [
585
+ r.value ? (s(), o("svg", {
586
+ key: 0,
587
+ width: "16",
588
+ height: "16",
589
+ viewBox: n(D).sun.viewBox,
590
+ fill: "none",
591
+ stroke: "currentColor",
592
+ "stroke-width": "2",
593
+ "stroke-linecap": "round",
594
+ "stroke-linejoin": "round",
595
+ innerHTML: n(D).sun.elements.join("")
596
+ }, null, 8, gt)) : (s(), o("svg", {
597
+ key: 1,
598
+ width: "16",
599
+ height: "16",
600
+ viewBox: n(D).moon.viewBox,
601
+ fill: "none",
602
+ stroke: "currentColor",
603
+ "stroke-width": "2",
604
+ "stroke-linecap": "round",
605
+ "stroke-linejoin": "round",
606
+ innerHTML: n(D).moon.elements.join("")
607
+ }, null, 8, pt))
608
+ ], 10, bt));
609
+ }
610
+ }), mt = ["data-ss-theme"], kt = { class: "ss-dbg-tabs" }, yt = { class: "ss-dbg-tabs-scroll" }, wt = ["onClick"], Tt = ["viewBox", "innerHTML"], Ct = { class: "ss-dbg-tabs-right" }, _t = ["title"], Et = ["href"], St = ["viewBox", "innerHTML"], xt = { class: "ss-dbg-content" }, $t = {
611
+ key: 0,
612
+ class: "ss-dbg-empty"
613
+ }, Lt = {
614
+ key: 1,
615
+ class: "ss-dbg-empty",
616
+ style: { color: "var(--ss-red-fg)" }
617
+ }, ns = /* @__PURE__ */ te({
618
+ __name: "DebugPanel",
619
+ props: {
620
+ dashboardPath: { default: "/__stats" },
621
+ tracingEnabled: { type: Boolean, default: !1 },
622
+ isLive: { type: Boolean, default: !1 },
623
+ baseUrl: { default: "" },
624
+ debugEndpoint: { default: "/admin/api/debug" },
625
+ authToken: {},
626
+ className: {},
627
+ defaultOpen: { type: Boolean, default: !1 }
628
+ },
629
+ setup(e, { expose: T }) {
630
+ const a = B(() => import("./QueriesTab-C8_7oprC.js")), x = B(() => import("./EventsTab-BBM7olXF.js")), r = B(() => import("./EmailsTab-CNyEODVB.js")), p = B(() => import("./RoutesTab-Dz0MkZuF.js")), _ = B(() => import("./LogsTab-Bg3o0Mm6.js")), y = B(() => import("./TimelineTab-zj5Z5OdT.js")), $ = B(() => import("./CacheTab-BPisYYiQ.js")), M = B(() => import("./JobsTab-WFnxPdN7.js")), P = B(() => import("./ConfigTab-C8cafGUj.js")), E = B(() => import("./InternalsTab-DEMjqtlw.js")), d = B(() => import("./CustomPaneTab-BJxT5Dp7.js")), u = e, m = g(u.defaultOpen), c = g("queries"), { theme: f } = oe(), { features: b } = re({
631
+ baseUrl: u.baseUrl,
632
+ debugEndpoint: u.debugEndpoint,
633
+ authToken: u.authToken
634
+ }), j = u.dashboardPath ? u.dashboardPath.replace(/\/+$/, "") + "/api" : void 0, q = k(() => c.value.startsWith("custom-")), I = k(() => q.value || c.value === "internals"), { data: i, loading: C, error: U, isUnauthorized: H, refresh: W, startRefresh: F, stopRefresh: V } = ft(
635
+ () => c.value,
636
+ {
637
+ baseUrl: u.baseUrl,
638
+ debugEndpoint: u.debugEndpoint,
639
+ dashboardEndpoint: j,
640
+ authToken: u.authToken
641
+ }
642
+ ), R = k(() => {
643
+ const w = [
644
+ { id: "queries", label: "Queries", icon: "Q" },
645
+ { id: "events", label: "Events", icon: "E" },
646
+ { id: "emails", label: "Emails", icon: "M" },
647
+ { id: "routes", label: "Routes", icon: "R" },
648
+ { id: "logs", label: "Logs", icon: "L" }
649
+ ];
650
+ (b.value.tracing || u.tracingEnabled) && w.push({ id: "timeline", label: "Requests", icon: "R" }), b.value.cache && w.push({ id: "cache", label: "Cache", icon: "C" }), b.value.queues && w.push({ id: "jobs", label: "Jobs", icon: "J" }), w.push({ id: "config", label: "Config", icon: "G" }), w.push({ id: "internals", label: "Internals", icon: "I" });
651
+ for (const h of b.value.customPanes)
652
+ w.push({
653
+ id: `custom-${h.id}`,
654
+ label: h.label,
655
+ icon: h.label.charAt(0).toUpperCase()
656
+ });
657
+ return w;
658
+ });
659
+ function z(w) {
660
+ const h = w.replace("custom-", "");
661
+ return b.value.customPanes.find((t) => t.id === h);
662
+ }
663
+ function X() {
664
+ m.value = !0, F();
665
+ }
666
+ function O() {
667
+ m.value = !1, V();
668
+ }
669
+ function G() {
670
+ m.value ? O() : X();
671
+ }
672
+ function Z(w) {
673
+ c.value = w;
674
+ }
675
+ return Y(m, (w) => {
676
+ w ? F() : V();
677
+ }), T({ toggle: G, open: X, close: O }), (w, h) => n(H) ? S("", !0) : (s(), o("div", {
678
+ key: 0,
679
+ class: A(["ss-dbg-panel", { "ss-dbg-open": m.value }]),
680
+ "data-ss-theme": n(f)
681
+ }, [
682
+ l("div", kt, [
683
+ l("div", yt, [
684
+ (s(!0), o(J, null, ne(R.value, (t) => (s(), o("button", {
685
+ key: t.id,
686
+ type: "button",
687
+ class: A(["ss-dbg-tab", { "ss-dbg-active": c.value === t.id }]),
688
+ onClick: (v) => Z(t.id)
689
+ }, [
690
+ n(D)[t.id] ? (s(), o("svg", {
691
+ key: 0,
692
+ class: "ss-dbg-tab-icon",
693
+ viewBox: n(D)[t.id].viewBox,
694
+ innerHTML: n(D)[t.id].elements.join("")
695
+ }, null, 8, Tt)) : S("", !0),
696
+ ye(" " + L(t.label), 1)
697
+ ], 10, wt))), 128))
698
+ ]),
699
+ l("div", Ct, [
700
+ l("span", {
701
+ class: A(["ss-dbg-conn-mode", e.isLive ? "ss-dbg-conn-live" : "ss-dbg-conn-polling"]),
702
+ title: e.isLive ? "Connected via Transmit (SSE) — real-time updates" : "Polling every 3s"
703
+ }, L(e.isLive ? "live" : "polling"), 11, _t),
704
+ e.dashboardPath && n(b).dashboard ? (s(), o("a", {
705
+ key: 0,
706
+ href: e.dashboardPath,
707
+ target: "_blank",
708
+ rel: "noopener noreferrer",
709
+ class: "ss-dbg-dashboard-link",
710
+ title: "Open dashboard"
711
+ }, [
712
+ (s(), o("svg", {
713
+ width: "14",
714
+ height: "14",
715
+ viewBox: n(D)["external-link"].viewBox,
716
+ fill: "none",
717
+ stroke: "currentColor",
718
+ "stroke-width": "2",
719
+ "stroke-linecap": "round",
720
+ "stroke-linejoin": "round",
721
+ innerHTML: n(D)["external-link"].elements.join("")
722
+ }, null, 8, St))
723
+ ], 8, Et)) : S("", !0),
724
+ ie(ge),
725
+ l("button", {
726
+ type: "button",
727
+ class: "ss-dbg-close",
728
+ onClick: O,
729
+ title: "Close panel"
730
+ }, " × ")
731
+ ])
732
+ ]),
733
+ l("div", xt, [
734
+ n(C) && !n(i) && !I.value ? (s(), o("div", $t, "Loading...")) : n(U) && !I.value ? (s(), o("div", Lt, " Error: " + L(n(U).message), 1)) : (s(), o(J, { key: 2 }, [
735
+ c.value === "queries" ? (s(), N(n(a), {
736
+ key: 0,
737
+ data: n(i),
738
+ "dashboard-path": e.dashboardPath
739
+ }, null, 8, ["data", "dashboard-path"])) : c.value === "events" ? (s(), N(n(x), {
740
+ key: 1,
741
+ data: n(i),
742
+ "dashboard-path": e.dashboardPath
743
+ }, null, 8, ["data", "dashboard-path"])) : c.value === "emails" ? (s(), N(n(r), {
744
+ key: 2,
745
+ data: n(i),
746
+ "dashboard-path": e.dashboardPath,
747
+ "debug-endpoint": e.debugEndpoint,
748
+ "auth-token": e.authToken
749
+ }, null, 8, ["data", "dashboard-path", "debug-endpoint", "auth-token"])) : c.value === "routes" ? (s(), N(n(p), {
750
+ key: 3,
751
+ data: n(i)
752
+ }, null, 8, ["data"])) : c.value === "logs" ? (s(), N(n(_), {
753
+ key: 4,
754
+ data: n(i),
755
+ "dashboard-path": e.dashboardPath
756
+ }, null, 8, ["data", "dashboard-path"])) : c.value === "timeline" ? (s(), N(n(y), {
757
+ key: 5,
758
+ data: n(i),
759
+ "dashboard-path": e.dashboardPath,
760
+ "base-url": e.baseUrl,
761
+ "debug-endpoint": e.debugEndpoint,
762
+ "auth-token": e.authToken
763
+ }, null, 8, ["data", "dashboard-path", "base-url", "debug-endpoint", "auth-token"])) : c.value === "cache" ? (s(), N(n($), {
764
+ key: 6,
765
+ data: n(i)
766
+ }, null, 8, ["data"])) : c.value === "jobs" ? (s(), N(n(M), {
767
+ key: 7,
768
+ data: n(i)
769
+ }, null, 8, ["data"])) : c.value === "config" ? (s(), N(n(P), {
770
+ key: 8,
771
+ data: n(i)
772
+ }, null, 8, ["data"])) : c.value === "internals" ? (s(), N(n(E), {
773
+ key: 9,
774
+ data: n(i),
775
+ "base-url": e.baseUrl,
776
+ "debug-endpoint": e.debugEndpoint,
777
+ "auth-token": e.authToken
778
+ }, null, 8, ["data", "base-url", "debug-endpoint", "auth-token"])) : c.value.startsWith("custom-") ? (s(), N(n(d), {
779
+ key: 10,
780
+ pane: z(c.value),
781
+ "base-url": e.baseUrl,
782
+ "auth-token": e.authToken
783
+ }, null, 8, ["pane", "base-url", "auth-token"])) : S("", !0)
784
+ ], 64))
785
+ ])
786
+ ], 10, mt));
787
+ }
788
+ });
789
+ function Bt(e, T = {}) {
790
+ const {
791
+ baseUrl: a = "",
792
+ dashboardEndpoint: x = "/__stats/api",
793
+ authToken: r,
794
+ perPage: p = 50,
795
+ refreshKey: _
796
+ } = T, y = g(null), $ = g(!1), M = g(null), P = g(!1), E = g("1h"), d = ae({
797
+ page: 1,
798
+ perPage: p,
799
+ total: 0,
800
+ totalPages: 1
801
+ }), u = ae({
802
+ search: ""
803
+ }), m = ae({
804
+ column: "",
805
+ direction: "desc"
806
+ }), c = new Ue({
807
+ baseUrl: a,
808
+ endpoint: x,
809
+ authToken: r,
810
+ section: e(),
811
+ perPage: p,
812
+ callbacks: {
813
+ onData: (t) => {
814
+ f = t;
815
+ },
816
+ onPagination: (t) => {
817
+ t ? (d.total = t.total, d.totalPages = t.lastPage ?? (Math.ceil(t.total / d.perPage) || 1), y.value = { data: f, meta: t }) : y.value = f;
818
+ },
819
+ onLoading: (t) => {
820
+ $.value = t;
821
+ },
822
+ onError: (t) => {
823
+ M.value = t;
824
+ },
825
+ onUnauthorized: () => {
826
+ P.value = !0;
827
+ }
828
+ }
829
+ });
830
+ let f = null;
831
+ const b = c.getApi();
832
+ async function j(t) {
833
+ try {
834
+ return await b.fetchChart(t);
835
+ } catch (v) {
836
+ return v instanceof Re && (P.value = !0), null;
837
+ }
838
+ }
839
+ async function q() {
840
+ try {
841
+ return await b.fetchGroupedQueries();
842
+ } catch {
843
+ return null;
844
+ }
845
+ }
846
+ async function I(t) {
847
+ try {
848
+ return await b.explainQuery(t);
849
+ } catch {
850
+ return null;
851
+ }
852
+ }
853
+ async function i(t) {
854
+ try {
855
+ return await b.retryJob(t), !0;
856
+ } catch {
857
+ return !1;
858
+ }
859
+ }
860
+ async function C(t) {
861
+ try {
862
+ return await b.deleteCacheKey(t), !0;
863
+ } catch {
864
+ return !1;
865
+ }
866
+ }
867
+ async function U(t) {
868
+ try {
869
+ return (await b.fetchEmailPreview(t))?.html || null;
870
+ } catch {
871
+ return null;
872
+ }
873
+ }
874
+ function H(t) {
875
+ d.page = t, h();
876
+ }
877
+ function W(t) {
878
+ u.search = t, d.page = 1, h();
879
+ }
880
+ function F(t, v) {
881
+ u[t] = v, d.page = 1, h();
882
+ }
883
+ function V(t, v) {
884
+ m.column === t && !v ? m.direction = m.direction === "asc" ? "desc" : "asc" : (m.column = t, m.direction = v || "desc"), h();
885
+ }
886
+ function R(t) {
887
+ E.value = t, h();
888
+ }
889
+ async function z(t, v = "post", Q) {
890
+ return c.mutate(t, v, Q);
891
+ }
892
+ function X() {
893
+ w(), c.fetch(!0);
894
+ }
895
+ function O() {
896
+ c.start();
897
+ }
898
+ function G() {
899
+ c.stop();
900
+ }
901
+ function Z() {
902
+ const t = {};
903
+ for (const [v, Q] of Object.entries(u))
904
+ v !== "search" && Q !== "" && Q !== void 0 && Q !== null && (t[v] = String(Q));
905
+ return t;
906
+ }
907
+ function w() {
908
+ const t = e(), v = Z();
909
+ c.configure({
910
+ page: d.page,
911
+ perPage: d.perPage,
912
+ search: u.search || void 0,
913
+ sort: m.column || void 0,
914
+ sortDir: m.column ? m.direction : void 0,
915
+ filters: Object.keys(v).length > 0 ? v : void 0,
916
+ timeRange: t.startsWith("overview") ? E.value : void 0
917
+ });
918
+ }
919
+ function h() {
920
+ w(), c.fetch(!1);
921
+ }
922
+ return Y(e, () => {
923
+ d.page = 1;
924
+ for (const t of Object.keys(u))
925
+ t === "search" ? u.search = "" : delete u[t];
926
+ m.column = "", y.value = null, c.setSection(e()), w();
927
+ }), _ && Y(_, () => {
928
+ w(), c.handleRefreshSignal();
929
+ }), K(() => {
930
+ w(), c.start();
931
+ }), ee(() => {
932
+ c.stop();
933
+ }), {
934
+ data: y,
935
+ loading: $,
936
+ error: M,
937
+ isUnauthorized: P,
938
+ pagination: d,
939
+ filter: u,
940
+ sort: m,
941
+ timeRange: E,
942
+ goToPage: H,
943
+ setSearch: W,
944
+ setFilter: F,
945
+ setSort: V,
946
+ setTimeRange: R,
947
+ refresh: X,
948
+ startRefresh: O,
949
+ stopRefresh: G,
950
+ mutate: z,
951
+ fetchChart: j,
952
+ fetchGroupedQueries: q,
953
+ explainQuery: I,
954
+ retryJob: i,
955
+ deleteCacheKey: C,
956
+ fetchEmailPreview: U
957
+ };
958
+ }
959
+ const Mt = ["data-theme"], Pt = { class: "ss-dash-header" }, Ut = { class: "ss-dash-header-center" }, Rt = { class: "ss-dash-header-right" }, Dt = ["href"], jt = { class: "ss-dash-body" }, Ht = { class: "ss-dash-nav" }, At = ["data-ss-section", "onClick", "title"], It = { class: "ss-dash-nav-icon" }, qt = ["viewBox", "innerHTML"], Ot = { class: "ss-dash-nav-label" }, zt = {
960
+ key: 0,
961
+ class: "ss-dash-nav-sep"
962
+ }, Nt = ["onClick", "title"], Ft = { class: "ss-dash-nav-icon" }, Vt = ["viewBox", "innerHTML"], Gt = { class: "ss-dash-nav-label" }, Qt = ["title"], Jt = ["viewBox", "innerHTML"], Kt = ["viewBox", "innerHTML"], Wt = { class: "ss-dash-main" }, Xt = ["id"], Yt = { class: "ss-dash-pane-inner" }, Zt = {
963
+ key: 1,
964
+ class: "ss-dash-empty"
965
+ }, as = /* @__PURE__ */ te({
966
+ __name: "DashboardPage",
967
+ props: {
968
+ baseUrl: { default: "" },
969
+ dashboardEndpoint: { default: "/__stats/api" },
970
+ debugEndpoint: { default: void 0 },
971
+ authToken: { default: void 0 },
972
+ backUrl: { default: "/" },
973
+ channelName: { default: "server-stats/dashboard" }
974
+ },
975
+ setup(e) {
976
+ const T = B(() => import("./OverviewSection-CXh6Ja1B.js")), a = B(() => import("./RequestsSection-BPuMdmMc.js")), x = B(() => import("./QueriesSection-IodIsCJ-.js")), r = B(() => import("./EventsSection-r60Q5Lmu.js")), p = B(() => import("./RoutesSection-NKo3Rbq3.js")), _ = B(() => import("./LogsSection-DRMGzJmg.js")), y = B(() => import("./EmailsSection-BcNyhyHs.js")), $ = B(() => import("./CacheSection-oFAJL3mo.js")), M = B(() => import("./JobsSection-BHL-hkQw.js")), P = B(() => import("./ConfigSection-BhfJ4KqL.js")), E = B(() => import("./InternalsSection-BJUXE-5F.js")), d = [
977
+ "overview",
978
+ "requests",
979
+ "queries",
980
+ "events",
981
+ "routes",
982
+ "logs",
983
+ "emails",
984
+ "cache",
985
+ "jobs",
986
+ "config",
987
+ "internals"
988
+ ], u = e, { theme: m, toggleTheme: c } = oe(), { features: f } = re({
989
+ baseUrl: u.baseUrl,
990
+ debugEndpoint: u.debugEndpoint,
991
+ authToken: u.authToken
992
+ }), b = g("overview"), j = g(!1), q = g(!1), I = g(0);
993
+ se("ss-refresh-key", I), se("ss-base-url", u.baseUrl), se("ss-dashboard-endpoint", u.dashboardEndpoint), se("ss-debug-endpoint", u.debugEndpoint), se("ss-auth-token", u.authToken), typeof window < "u" && (j.value = localStorage.getItem("ss-dash-sidebar") === "collapsed");
994
+ let i = null;
995
+ function C() {
996
+ if (i && (i(), i = null), !u.channelName) return;
997
+ i = De({
998
+ baseUrl: u.baseUrl,
999
+ channelName: u.channelName,
1000
+ authToken: u.authToken,
1001
+ onMessage: () => {
1002
+ I.value += 1;
1003
+ },
1004
+ onConnect: () => {
1005
+ q.value = !0;
1006
+ },
1007
+ onDisconnect: () => {
1008
+ q.value = !1;
1009
+ },
1010
+ onError: () => {
1011
+ q.value = !1;
1012
+ }
1013
+ }).unsubscribe;
1014
+ }
1015
+ K(() => {
1016
+ C();
1017
+ }), ee(() => {
1018
+ i && (i(), i = null);
1019
+ });
1020
+ const U = k(() => f.value.customPanes || []);
1021
+ function H(h) {
1022
+ const t = h.replace("#", "").split("?")[0];
1023
+ return t && [...d, ...U.value.map((Q) => Q.id)].includes(t) ? t : "overview";
1024
+ }
1025
+ function W() {
1026
+ const h = H(window.location.hash);
1027
+ h !== b.value && (b.value = h);
1028
+ }
1029
+ K(() => {
1030
+ if (typeof window > "u") return;
1031
+ const h = H(window.location.hash);
1032
+ (h !== "overview" || window.location.hash) && (b.value = h), window.addEventListener("hashchange", W);
1033
+ }), ee(() => {
1034
+ window.removeEventListener("hashchange", W);
1035
+ }), Y(b, (h) => {
1036
+ typeof window < "u" && (window.location.hash = h);
1037
+ });
1038
+ function F() {
1039
+ j.value = !j.value, localStorage.setItem("ss-dash-sidebar", j.value ? "collapsed" : "expanded");
1040
+ }
1041
+ function V(h) {
1042
+ h !== b.value && (b.value = h);
1043
+ }
1044
+ const R = k(() => [
1045
+ { id: "overview", label: "Overview", visible: !0 },
1046
+ { id: "requests", label: "Requests", visible: !0 },
1047
+ { id: "queries", label: "Queries", visible: !0 },
1048
+ { id: "events", label: "Events", visible: !0 },
1049
+ { id: "routes", label: "Routes", visible: !0 },
1050
+ { id: "logs", label: "Logs", visible: !0 },
1051
+ { id: "emails", label: "Emails", visible: !0 },
1052
+ { id: "cache", label: "Cache", visible: f.value.cache },
1053
+ { id: "jobs", label: "Jobs", visible: f.value.queues },
1054
+ { id: "config", label: "Config", visible: !0 },
1055
+ { id: "internals", label: "Internals", visible: !0 }
1056
+ ]), z = k(() => R.value.filter((h) => h.visible)), { data: X } = Bt(() => "overview", {
1057
+ baseUrl: u.baseUrl,
1058
+ dashboardEndpoint: u.dashboardEndpoint,
1059
+ authToken: u.authToken,
1060
+ refreshKey: I
1061
+ }), O = k(() => X.value), G = k(() => {
1062
+ const h = {};
1063
+ if (!O.value) return h;
1064
+ if (O.value.totalRequests > 0 && (h.requests = { count: O.value.totalRequests }), O.value.queryStats?.total > 0 && (h.queries = { count: O.value.queryStats.total }), O.value.logLevelBreakdown) {
1065
+ const t = O.value.logLevelBreakdown, v = t.error + t.warn + t.info + t.debug;
1066
+ v > 0 && (h.logs = { count: v });
1067
+ }
1068
+ return h;
1069
+ }), Z = {
1070
+ overview: T,
1071
+ requests: a,
1072
+ queries: x,
1073
+ events: r,
1074
+ routes: p,
1075
+ logs: _,
1076
+ emails: y,
1077
+ cache: $,
1078
+ jobs: M,
1079
+ config: P,
1080
+ internals: E
1081
+ }, w = k(() => Z[b.value] || null);
1082
+ return (h, t) => (s(), o("div", {
1083
+ class: "ss-dash",
1084
+ "data-theme": n(m),
1085
+ id: "ss-dash"
1086
+ }, [
1087
+ l("div", Pt, [
1088
+ t[0] || (t[0] = l("div", { class: "ss-dash-header-left" }, [
1089
+ l("span", { class: "ss-dash-logo" }, "Server Stats"),
1090
+ l("span", { class: "ss-dash-logo-sub" }, "Dashboard")
1091
+ ], -1)),
1092
+ l("div", Ut, [
1093
+ l("span", {
1094
+ class: A(["ss-dash-live-dot", { "ss-dash-connected": q.value }]),
1095
+ id: "ss-dash-live-dot"
1096
+ }, null, 2),
1097
+ l("span", {
1098
+ class: A(["ss-dash-live-label", { "ss-dash-connected": q.value }]),
1099
+ id: "ss-dash-live-label"
1100
+ }, L(q.value ? "Live" : "Polling"), 3)
1101
+ ]),
1102
+ l("div", Rt, [
1103
+ ie(ge, { "class-prefix": "ss-dash" }),
1104
+ e.backUrl ? (s(), o("a", {
1105
+ key: 0,
1106
+ href: e.backUrl,
1107
+ class: "ss-dash-back-link",
1108
+ title: "Back to app"
1109
+ }, " ← App ", 8, Dt)) : S("", !0)
1110
+ ])
1111
+ ]),
1112
+ l("div", jt, [
1113
+ l("div", {
1114
+ class: A(["ss-dash-sidebar", { "ss-dash-collapsed": j.value }]),
1115
+ id: "ss-dash-sidebar"
1116
+ }, [
1117
+ l("nav", Ht, [
1118
+ (s(!0), o(J, null, ne(z.value, (v) => (s(), o("button", {
1119
+ key: v.id,
1120
+ type: "button",
1121
+ class: A(["ss-dash-nav-item", { "ss-dash-active": b.value === v.id }]),
1122
+ "data-ss-section": v.id,
1123
+ onClick: (Q) => V(v.id),
1124
+ title: j.value ? v.label : void 0
1125
+ }, [
1126
+ l("span", It, [
1127
+ (s(), o("svg", {
1128
+ width: "20",
1129
+ height: "20",
1130
+ viewBox: (n(D)[v.id] || n(D).config).viewBox,
1131
+ fill: "none",
1132
+ stroke: "currentColor",
1133
+ "stroke-width": "2",
1134
+ "stroke-linecap": "round",
1135
+ "stroke-linejoin": "round",
1136
+ innerHTML: (n(D)[v.id] || n(D).config).elements.join("")
1137
+ }, null, 8, qt))
1138
+ ]),
1139
+ l("span", Ot, L(v.label), 1),
1140
+ G.value[v.id] && G.value[v.id].count > 0 ? (s(), o("span", {
1141
+ key: 0,
1142
+ class: A(["ss-dash-nav-badge", G.value[v.id].variant || ""])
1143
+ }, L(G.value[v.id].count), 3)) : S("", !0)
1144
+ ], 10, At))), 128)),
1145
+ U.value.length > 0 ? (s(), o("div", zt)) : S("", !0),
1146
+ (s(!0), o(J, null, ne(U.value, (v) => (s(), o("button", {
1147
+ key: v.id,
1148
+ type: "button",
1149
+ class: A(["ss-dash-nav-item", { "ss-dash-active": b.value === v.id }]),
1150
+ onClick: (Q) => V(v.id),
1151
+ title: j.value ? v.label : void 0
1152
+ }, [
1153
+ l("span", Ft, [
1154
+ (s(), o("svg", {
1155
+ width: "20",
1156
+ height: "20",
1157
+ viewBox: n(D)["custom-pane"].viewBox,
1158
+ fill: "none",
1159
+ stroke: "currentColor",
1160
+ "stroke-width": "2",
1161
+ "stroke-linecap": "round",
1162
+ "stroke-linejoin": "round",
1163
+ innerHTML: n(D)["custom-pane"].elements.join("")
1164
+ }, null, 8, Vt))
1165
+ ]),
1166
+ l("span", Gt, L(v.label), 1)
1167
+ ], 10, Nt))), 128))
1168
+ ]),
1169
+ l("button", {
1170
+ type: "button",
1171
+ class: "ss-dash-sidebar-toggle",
1172
+ id: "ss-dash-sidebar-toggle",
1173
+ onClick: F,
1174
+ title: j.value ? "Expand sidebar" : "Collapse sidebar"
1175
+ }, [
1176
+ j.value ? (s(), o("svg", {
1177
+ key: 0,
1178
+ width: "16",
1179
+ height: "16",
1180
+ viewBox: n(D)["chevron-right"].viewBox,
1181
+ fill: "none",
1182
+ stroke: "currentColor",
1183
+ "stroke-width": "1.5",
1184
+ innerHTML: n(D)["chevron-right"].elements.join("")
1185
+ }, null, 8, Jt)) : (s(), o("svg", {
1186
+ key: 1,
1187
+ width: "16",
1188
+ height: "16",
1189
+ viewBox: n(D)["chevron-left"].viewBox,
1190
+ fill: "none",
1191
+ stroke: "currentColor",
1192
+ "stroke-width": "1.5",
1193
+ innerHTML: n(D)["chevron-left"].elements.join("")
1194
+ }, null, 8, Kt))
1195
+ ], 8, Qt)
1196
+ ], 2),
1197
+ l("div", Wt, [
1198
+ l("div", {
1199
+ class: "ss-dash-pane ss-dash-active",
1200
+ id: `ss-dash-pane-${b.value}`
1201
+ }, [
1202
+ l("div", Yt, [
1203
+ (s(), N(we, null, {
1204
+ fallback: ce(() => [...t[1] || (t[1] = [
1205
+ l("div", { class: "ss-dash-empty" }, "Loading...", -1)
1206
+ ])]),
1207
+ default: ce(() => [
1208
+ w.value ? (s(), N(Te(w.value), { key: 0 })) : (s(), o("div", Zt, "Unknown section"))
1209
+ ]),
1210
+ _: 1
1211
+ }))
1212
+ ])
1213
+ ], 8, Xt)
1214
+ ])
1215
+ ])
1216
+ ], 8, Mt));
1217
+ }
1218
+ });
1219
+ export {
1220
+ Fe as _,
1221
+ as as a,
1222
+ ns as b,
1223
+ ss as c,
1224
+ ft as d,
1225
+ re as e,
1226
+ je as f,
1227
+ oe as g,
1228
+ Bt as u
1229
+ };