adonisjs-server-stats 1.10.0 → 1.10.3

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 (210) hide show
  1. package/README.md +23 -14
  2. package/dist/core/config-utils.d.ts +8 -0
  3. package/dist/core/constants.d.ts +4 -0
  4. package/dist/core/dashboard-data-controller.d.ts +16 -0
  5. package/dist/core/dashboard-data-helpers.d.ts +12 -0
  6. package/dist/core/debug-data-controller.d.ts +4 -0
  7. package/dist/core/define-config-helpers.d.ts +25 -0
  8. package/dist/core/feature-detect-helpers.d.ts +36 -0
  9. package/dist/core/formatters-helpers.d.ts +23 -0
  10. package/dist/core/index.js +594 -509
  11. package/dist/core/log-utils-helpers.d.ts +13 -0
  12. package/dist/core/metrics.d.ts +3 -28
  13. package/dist/core/pagination.d.ts +0 -9
  14. package/dist/core/server-stats-controller.d.ts +6 -0
  15. package/dist/core/transmit-helpers.d.ts +7 -0
  16. package/dist/core/types-dashboard.d.ts +178 -0
  17. package/dist/core/types-diagnostics.d.ts +85 -0
  18. package/dist/core/types.d.ts +10 -442
  19. package/dist/react/{CacheSection-UCMptWyn.js → CacheSection-baMZotSn.js} +2 -2
  20. package/dist/react/CacheTab-2cw_rMzj.js +117 -0
  21. package/dist/react/{ConfigSection-DfFd-WRq.js → ConfigSection-DGgqjAal.js} +1 -1
  22. package/dist/react/{ConfigTab-Bdg8YMer.js → ConfigTab-H3OnYqmK.js} +1 -1
  23. package/dist/react/CustomPaneTab-B6r7ha0u.js +98 -0
  24. package/dist/react/{EmailsSection-CM7stSyh.js → EmailsSection-C-UZISG-.js} +2 -2
  25. package/dist/react/EmailsTab-DbK4Eobn.js +139 -0
  26. package/dist/react/{EventsSection-ByQ-9blq.js → EventsSection-C7RQW_LY.js} +2 -2
  27. package/dist/react/EventsTab-CfVr7AiM.js +57 -0
  28. package/dist/react/{FilterBar-DQRXpWrb.js → FilterBar-CQ7bD669.js} +15 -15
  29. package/dist/react/{JobsSection-DF3qEv9O.js → JobsSection-CQHNK_Ls.js} +2 -2
  30. package/dist/react/{JobsTab-BbrBWIOb.js → JobsTab-znzf6jzk.js} +54 -42
  31. package/dist/react/{LogsSection-DcFTZY7b.js → LogsSection-Dmm3rE2B.js} +9 -3
  32. package/dist/react/LogsTab-D8unMV5P.js +108 -0
  33. package/dist/react/{OverviewSection-C4T1ur51.js → OverviewSection-ABP9ueBo.js} +1 -1
  34. package/dist/react/{QueriesSection-PswteoF9.js → QueriesSection-CnmSkznA.js} +2 -2
  35. package/dist/react/{QueriesTab-osLUWd4L.js → QueriesTab-BQzcxEiW.js} +37 -40
  36. package/dist/react/{RelatedLogs-DFDOyUMr.js → RelatedLogs-3A8RuGKH.js} +15 -3
  37. package/dist/react/{RequestsSection-Nag30rEA.js → RequestsSection-kW79_M7k.js} +3 -3
  38. package/dist/react/{RoutesSection-BUSkM6PY.js → RoutesSection-BRhxrtjZ.js} +2 -2
  39. package/dist/react/RoutesTab-CpYH5lUw.js +68 -0
  40. package/dist/react/{TimelineTab-Covg5weo.js → TimelineTab-DjLR35Ce.js} +47 -53
  41. package/dist/react/index-CsImORX6.js +1121 -0
  42. package/dist/react/index.js +1 -1
  43. package/dist/react/react/components/{Dashboard/shared → shared}/FilterBar.d.ts +4 -3
  44. package/dist/react/react/hooks/useDashboardData.d.ts +4 -8
  45. package/dist/react/style.css +1 -1
  46. package/dist/src/collectors/app_collector.d.ts +0 -8
  47. package/dist/src/collectors/app_collector.js +45 -52
  48. package/dist/src/collectors/auto_detect.d.ts +0 -23
  49. package/dist/src/collectors/auto_detect.js +33 -55
  50. package/dist/src/collectors/db_pool_collector.d.ts +14 -16
  51. package/dist/src/collectors/db_pool_collector.js +72 -57
  52. package/dist/src/collectors/log_collector.d.ts +0 -47
  53. package/dist/src/collectors/log_collector.js +36 -65
  54. package/dist/src/collectors/queue_collector.d.ts +0 -20
  55. package/dist/src/collectors/queue_collector.js +60 -76
  56. package/dist/src/collectors/redis_collector.d.ts +10 -10
  57. package/dist/src/collectors/redis_collector.js +69 -66
  58. package/dist/src/config/deprecation_migration.d.ts +7 -0
  59. package/dist/src/config/deprecation_migration.js +201 -0
  60. package/dist/src/controller/debug_controller.d.ts +1 -1
  61. package/dist/src/controller/debug_controller.js +87 -81
  62. package/dist/src/dashboard/cache_handlers.d.ts +14 -0
  63. package/dist/src/dashboard/cache_handlers.js +52 -0
  64. package/dist/src/dashboard/chart_aggregator.d.ts +0 -7
  65. package/dist/src/dashboard/chart_aggregator.js +68 -50
  66. package/dist/src/dashboard/coalesce_cache.d.ts +25 -0
  67. package/dist/src/dashboard/coalesce_cache.js +47 -0
  68. package/dist/src/dashboard/dashboard_controller.d.ts +11 -37
  69. package/dist/src/dashboard/dashboard_controller.js +51 -544
  70. package/dist/src/dashboard/dashboard_page_assets.d.ts +17 -0
  71. package/dist/src/dashboard/dashboard_page_assets.js +51 -0
  72. package/dist/src/dashboard/dashboard_store.d.ts +19 -218
  73. package/dist/src/dashboard/dashboard_store.js +115 -1116
  74. package/dist/src/dashboard/dashboard_types.d.ts +83 -0
  75. package/dist/src/dashboard/dashboard_types.js +4 -0
  76. package/dist/src/dashboard/detail_queries.d.ts +19 -0
  77. package/dist/src/dashboard/detail_queries.js +98 -0
  78. package/dist/src/dashboard/email_event_builder.d.ts +8 -0
  79. package/dist/src/dashboard/email_event_builder.js +65 -0
  80. package/dist/src/dashboard/explain_query.d.ts +8 -0
  81. package/dist/src/dashboard/explain_query.js +22 -0
  82. package/dist/src/dashboard/filter_handlers.d.ts +23 -0
  83. package/dist/src/dashboard/filter_handlers.js +56 -0
  84. package/dist/src/dashboard/filtered_queries.d.ts +15 -0
  85. package/dist/src/dashboard/filtered_queries.js +155 -0
  86. package/dist/src/dashboard/flush_manager.d.ts +25 -0
  87. package/dist/src/dashboard/flush_manager.js +107 -0
  88. package/dist/src/dashboard/format_helpers.d.ts +126 -0
  89. package/dist/src/dashboard/format_helpers.js +140 -0
  90. package/dist/src/dashboard/inspector_manager.d.ts +36 -0
  91. package/dist/src/dashboard/inspector_manager.js +102 -0
  92. package/dist/src/dashboard/integrations/config_inspector.js +11 -13
  93. package/dist/src/dashboard/integrations/queue_inspector.d.ts +3 -3
  94. package/dist/src/dashboard/integrations/queue_inspector.js +13 -10
  95. package/dist/src/dashboard/jobs_handlers.d.ts +14 -0
  96. package/dist/src/dashboard/jobs_handlers.js +61 -0
  97. package/dist/src/dashboard/knex_factory.d.ts +18 -0
  98. package/dist/src/dashboard/knex_factory.js +91 -0
  99. package/dist/src/dashboard/migrator.js +30 -159
  100. package/dist/src/dashboard/migrator_tables.d.ts +19 -0
  101. package/dist/src/dashboard/migrator_tables.js +153 -0
  102. package/dist/src/dashboard/overview_queries.d.ts +66 -0
  103. package/dist/src/dashboard/overview_queries.js +155 -0
  104. package/dist/src/dashboard/overview_query_runners.d.ts +25 -0
  105. package/dist/src/dashboard/overview_query_runners.js +84 -0
  106. package/dist/src/dashboard/overview_store_queries.d.ts +40 -0
  107. package/dist/src/dashboard/overview_store_queries.js +69 -0
  108. package/dist/src/dashboard/paginate_helper.d.ts +12 -0
  109. package/dist/src/dashboard/paginate_helper.js +33 -0
  110. package/dist/src/dashboard/query_explain_handler.d.ts +10 -0
  111. package/dist/src/dashboard/query_explain_handler.js +80 -0
  112. package/dist/src/dashboard/read_queries.d.ts +32 -0
  113. package/dist/src/dashboard/read_queries.js +107 -0
  114. package/dist/src/dashboard/saved_filter_queries.d.ts +10 -0
  115. package/dist/src/dashboard/saved_filter_queries.js +24 -0
  116. package/dist/src/dashboard/storage_stats.d.ts +41 -0
  117. package/dist/src/dashboard/storage_stats.js +81 -0
  118. package/dist/src/dashboard/write_queue.d.ts +106 -0
  119. package/dist/src/dashboard/write_queue.js +225 -0
  120. package/dist/src/data/data_access.d.ts +2 -39
  121. package/dist/src/data/data_access.js +17 -193
  122. package/dist/src/data/data_access_helpers.d.ts +130 -0
  123. package/dist/src/data/data_access_helpers.js +212 -0
  124. package/dist/src/debug/debug_store.js +37 -32
  125. package/dist/src/debug/email_collector.d.ts +1 -10
  126. package/dist/src/debug/email_collector.js +78 -81
  127. package/dist/src/debug/event_collector.d.ts +0 -9
  128. package/dist/src/debug/event_collector.js +79 -62
  129. package/dist/src/debug/query_collector.js +23 -19
  130. package/dist/src/debug/route_inspector.d.ts +1 -5
  131. package/dist/src/debug/route_inspector.js +50 -51
  132. package/dist/src/debug/trace_collector.d.ts +9 -1
  133. package/dist/src/debug/trace_collector.js +21 -15
  134. package/dist/src/debug/types.d.ts +1 -1
  135. package/dist/src/define_config.d.ts +0 -65
  136. package/dist/src/define_config.js +93 -333
  137. package/dist/src/edge/client/dashboard.js +2 -2
  138. package/dist/src/edge/client/debug-panel-deferred.js +1 -1
  139. package/dist/src/edge/client/stats-bar.js +1 -1
  140. package/dist/src/edge/client-vue/dashboard.js +5 -5
  141. package/dist/src/edge/client-vue/debug-panel-deferred.js +3 -3
  142. package/dist/src/edge/client-vue/stats-bar.js +3 -3
  143. package/dist/src/edge/plugin.d.ts +0 -16
  144. package/dist/src/edge/plugin.js +57 -64
  145. package/dist/src/engine/request_metrics.d.ts +1 -0
  146. package/dist/src/engine/request_metrics.js +32 -42
  147. package/dist/src/middleware/request_tracking_middleware.d.ts +2 -8
  148. package/dist/src/middleware/request_tracking_middleware.js +65 -93
  149. package/dist/src/provider/auth_middleware_detector.d.ts +16 -0
  150. package/dist/src/provider/auth_middleware_detector.js +97 -0
  151. package/dist/src/provider/boot_helpers.d.ts +20 -0
  152. package/dist/src/provider/boot_helpers.js +91 -0
  153. package/dist/src/provider/boot_initializer.d.ts +28 -0
  154. package/dist/src/provider/boot_initializer.js +35 -0
  155. package/dist/src/provider/dashboard_init.d.ts +30 -0
  156. package/dist/src/provider/dashboard_init.js +138 -0
  157. package/dist/src/provider/dashboard_setup.d.ts +25 -0
  158. package/dist/src/provider/dashboard_setup.js +78 -0
  159. package/dist/src/provider/diagnostics.d.ts +134 -0
  160. package/dist/src/provider/diagnostics.js +127 -0
  161. package/dist/src/provider/email_bridge.d.ts +43 -0
  162. package/dist/src/provider/email_bridge.js +80 -0
  163. package/dist/src/provider/email_helpers.d.ts +13 -0
  164. package/dist/src/provider/email_helpers.js +68 -0
  165. package/dist/src/provider/pino_hook.d.ts +17 -0
  166. package/dist/src/provider/pino_hook.js +35 -0
  167. package/dist/src/provider/provider_helpers_extra.d.ts +47 -0
  168. package/dist/src/provider/provider_helpers_extra.js +177 -0
  169. package/dist/src/provider/server_stats_provider.d.ts +39 -85
  170. package/dist/src/provider/server_stats_provider.js +132 -951
  171. package/dist/src/provider/shutdown_helpers.d.ts +43 -0
  172. package/dist/src/provider/shutdown_helpers.js +70 -0
  173. package/dist/src/provider/toolbar_setup.d.ts +57 -0
  174. package/dist/src/provider/toolbar_setup.js +141 -0
  175. package/dist/src/routes/dashboard_routes.d.ts +14 -0
  176. package/dist/src/routes/dashboard_routes.js +197 -0
  177. package/dist/src/routes/debug_routes.d.ts +14 -0
  178. package/dist/src/routes/debug_routes.js +101 -0
  179. package/dist/src/routes/register_routes.d.ts +0 -78
  180. package/dist/src/routes/register_routes.js +22 -352
  181. package/dist/src/routes/stats_routes.d.ts +5 -0
  182. package/dist/src/routes/stats_routes.js +14 -0
  183. package/dist/src/styles/components.css +96 -0
  184. package/dist/src/styles/dashboard.css +8 -90
  185. package/dist/src/styles/debug-panel.css +1 -31
  186. package/dist/src/types.d.ts +305 -14
  187. package/dist/vue/{CacheSection-oFAJL3mo.js → CacheSection-ITqvpfH5.js} +1 -1
  188. package/dist/vue/{ConfigSection-BhfJ4KqL.js → ConfigSection-DTn3GslE.js} +1 -1
  189. package/dist/vue/{EmailsSection-BcNyhyHs.js → EmailsSection-DtLJ4XoS.js} +1 -1
  190. package/dist/vue/{EventsSection-r60Q5Lmu.js → EventsSection-BOYYz0Ty.js} +1 -1
  191. package/dist/vue/{JobsSection-BHL-hkQw.js → JobsSection-BazTxcJL.js} +1 -1
  192. package/dist/vue/{LogsSection-DRMGzJmg.js → LogsSection-D55PjTKX.js} +9 -3
  193. package/dist/vue/{LogsTab-Bg3o0Mm6.js → LogsTab-47zEK7jL.js} +4 -1
  194. package/dist/vue/{OverviewSection-CXh6Ja1B.js → OverviewSection-1uBKo-Tu.js} +1 -1
  195. package/dist/vue/{QueriesSection-IodIsCJ-.js → QueriesSection-rpoZ4ogd.js} +1 -1
  196. package/dist/vue/{RequestsSection-BPuMdmMc.js → RequestsSection-x7LvT0MC.js} +1 -1
  197. package/dist/vue/{RoutesSection-NKo3Rbq3.js → RoutesSection-CCD0zZqQ.js} +1 -1
  198. package/dist/vue/composables/useDashboardData.d.ts +12 -23
  199. package/dist/vue/index-C8MxnS7Q.js +1232 -0
  200. package/dist/vue/index.js +1 -1
  201. package/dist/vue/style.css +1 -1
  202. package/package.json +1 -1
  203. package/dist/react/CacheTab-CA8LB1J5.js +0 -123
  204. package/dist/react/CustomPaneTab-Bxtv_8Rw.js +0 -104
  205. package/dist/react/EmailsTab-BDhEiomM.js +0 -153
  206. package/dist/react/EventsTab-CMfY98Rl.js +0 -63
  207. package/dist/react/LogsTab-CicucmVk.js +0 -103
  208. package/dist/react/RoutesTab-DgVzd2PZ.js +0 -74
  209. package/dist/react/index-Cflz9Ebj.js +0 -1069
  210. package/dist/vue/index-Dtgysd26.js +0 -1229
@@ -0,0 +1,1121 @@
1
+ import { jsx as e, jsxs as c, Fragment as j } from "react/jsx-runtime";
2
+ import K, { useState as N, useRef as R, useEffect as B, useCallback as x, useMemo as D, Suspense as q, lazy as L } from "react";
3
+ import { DEFAULT_FEATURES as V, detectFeatures as G, ServerStatsController as Q, getTheme as X, onThemeChange as Y, toggleTheme as Z, buildSparklineData as ee, computeStats as se, formatStatNum as H, detectMetricGroupsFromStats as te, getVisibleMetricGroups as ne, METRIC_DEFINITIONS as oe, TAB_ICONS as S, DashboardDataController as re, subscribeToChannel as ae, DebugDataController as ie, compactPreview as le } from "adonisjs-server-stats/core";
4
+ import { createPortal as ce } from "react-dom";
5
+ function U(s = {}) {
6
+ const { baseUrl: o = "", debugEndpoint: t = "/admin/api/debug", authToken: n } = s, [a, i] = N(V), [u, r] = N(!0), [m, g] = N(null), p = R(!1);
7
+ return B(() => {
8
+ if (p.current) return;
9
+ p.current = !0;
10
+ let d = !1;
11
+ return (async () => {
12
+ try {
13
+ const v = await G({ baseUrl: o, debugEndpoint: t, authToken: n });
14
+ d || (i(v), r(!1));
15
+ } catch (v) {
16
+ d || (g(v instanceof Error ? v : new Error(String(v))), r(!1));
17
+ }
18
+ })(), () => {
19
+ d = !0;
20
+ };
21
+ }, [o, t, n]), { features: a, isLoading: u, error: m };
22
+ }
23
+ function de(s = {}) {
24
+ const {
25
+ baseUrl: o = "",
26
+ endpoint: t = "/admin/api/server-stats",
27
+ channelName: n = "admin/server-stats",
28
+ authToken: a,
29
+ pollInterval: i = 3e3
30
+ } = s, [u, r] = N(null), [m, g] = N(!1), [p, d] = N(!1), [w, v] = N(null), [b, k] = N(!1), E = R(null);
31
+ B(() => {
32
+ if (b) return;
33
+ const M = new Q({
34
+ baseUrl: o,
35
+ endpoint: t,
36
+ channelName: n,
37
+ authToken: a,
38
+ pollInterval: i,
39
+ onStatsUpdate: (C) => r(C),
40
+ onConnectionChange: (C) => g(C),
41
+ onStaleChange: (C) => d(C),
42
+ onError: (C) => v(C),
43
+ onUnauthorizedChange: (C) => k(C)
44
+ });
45
+ return E.current = M, M.start(), () => {
46
+ M.stop(), E.current = null;
47
+ };
48
+ }, [o, n, a, i, b]);
49
+ const O = x((M) => E.current?.getHistory(M) ?? [], []);
50
+ return {
51
+ stats: u,
52
+ history: E.current?.getAllHistory() ?? {},
53
+ getHistory: O,
54
+ isConnected: m,
55
+ isStale: p,
56
+ error: w,
57
+ unauthorized: b
58
+ };
59
+ }
60
+ function F() {
61
+ const [s, o] = N(() => X());
62
+ B(() => Y((a) => {
63
+ o(a);
64
+ }), []);
65
+ const t = x(() => {
66
+ const n = Z();
67
+ return o(n), n;
68
+ }, []);
69
+ return { theme: s, toggleTheme: t };
70
+ }
71
+ function ue({
72
+ data: s,
73
+ color: o = "#34d399",
74
+ width: t = 120,
75
+ height: n = 32,
76
+ className: a = ""
77
+ }) {
78
+ const i = D(
79
+ () => ee(s, { width: t, height: n }),
80
+ [s, t, n]
81
+ ), u = D(() => "ss-grad-" + Math.random().toString(36).slice(2, 8), []), r = { "--ss-accent": o };
82
+ if (!i)
83
+ return /* @__PURE__ */ e("div", { className: `ss-dash-sparkline ${a}`, style: r, children: /* @__PURE__ */ e(
84
+ "svg",
85
+ {
86
+ width: t,
87
+ height: n,
88
+ viewBox: `0 0 ${t} ${n}`,
89
+ style: { display: "block" },
90
+ children: /* @__PURE__ */ c("text", { x: t / 2, y: n / 2 + 3, textAnchor: "middle", fill: "#737373", fontSize: "9", children: [
91
+ "collecting",
92
+ "…"
93
+ ] })
94
+ }
95
+ ) });
96
+ const m = o || "var(--ss-accent)";
97
+ return /* @__PURE__ */ e("div", { className: `ss-dash-sparkline ${a}`, style: r, children: /* @__PURE__ */ c(
98
+ "svg",
99
+ {
100
+ width: t,
101
+ height: n,
102
+ viewBox: `0 0 ${t} ${n}`,
103
+ style: { display: "block" },
104
+ children: [
105
+ /* @__PURE__ */ e("defs", { children: /* @__PURE__ */ c("linearGradient", { id: u, x1: "0", y1: "0", x2: "0", y2: "1", children: [
106
+ /* @__PURE__ */ e("stop", { offset: "0%", stopColor: m, stopOpacity: "0.25" }),
107
+ /* @__PURE__ */ e("stop", { offset: "100%", stopColor: m, stopOpacity: "0.02" })
108
+ ] }) }),
109
+ /* @__PURE__ */ e("path", { d: i.areaPath, fill: `url(#${u})` }),
110
+ /* @__PURE__ */ e(
111
+ "path",
112
+ {
113
+ className: "ss-dash-sparkline-line",
114
+ d: "M" + i.points.replace(/ /g, " L"),
115
+ fill: "none",
116
+ stroke: m,
117
+ strokeWidth: "1.5",
118
+ strokeLinejoin: "round",
119
+ strokeLinecap: "round"
120
+ }
121
+ )
122
+ ]
123
+ }
124
+ ) });
125
+ }
126
+ const he = {
127
+ "ss-red": "#f87171",
128
+ "ss-amber": "#fbbf24",
129
+ "ss-green": "#34d399",
130
+ "ss-muted": "#737373"
131
+ };
132
+ function pe(s, o, t) {
133
+ const [n, a] = N({
134
+ position: "absolute",
135
+ bottom: "100%",
136
+ left: 0,
137
+ marginBottom: "10px",
138
+ zIndex: 180
139
+ });
140
+ return B(() => {
141
+ if (!t) return;
142
+ const i = () => {
143
+ const r = s.current, m = o.current;
144
+ if (!r || !m) return;
145
+ const g = r.closest(".ss-bar");
146
+ if (!g) return;
147
+ const p = r.getBoundingClientRect(), d = g.getBoundingClientRect(), w = p.left - d.left + p.width / 2;
148
+ a({
149
+ position: "absolute",
150
+ bottom: "100%",
151
+ left: `${w}px`,
152
+ transform: "translateX(-50%)",
153
+ marginBottom: "10px",
154
+ zIndex: 180
155
+ }), requestAnimationFrame(() => {
156
+ const v = m.getBoundingClientRect();
157
+ let b = 0;
158
+ v.left < 8 ? b = 8 - v.left : v.right > window.innerWidth - 8 && (b = window.innerWidth - 8 - v.right), b && a((k) => ({
159
+ ...k,
160
+ transform: `translateX(calc(-50% + ${b}px))`
161
+ }));
162
+ });
163
+ };
164
+ i();
165
+ const u = s.current?.closest(".ss-bar-scroll");
166
+ return u?.addEventListener("scroll", i), window.addEventListener("resize", i), () => {
167
+ u?.removeEventListener("scroll", i), window.removeEventListener("resize", i);
168
+ };
169
+ }, [t, s, o]), n;
170
+ }
171
+ function be({ metric: s, stats: o, history: t, className: n = "" }) {
172
+ const [a, i] = N(!1), [u, r] = N(!1), m = R(null), g = R(null);
173
+ if (s.show && !s.show(o))
174
+ return null;
175
+ const p = s.value ? s.value(o) : s.format(o), d = s.color ? s.color(o) : "", w = d && he[d] || "#34d399", v = typeof s.detail == "function" ? s.detail(o) : s.detail, b = D(() => se(t), [t]), k = a || u, E = pe(m, g, k), O = x(($) => {
176
+ $.stopPropagation(), i((l) => !l);
177
+ }, []);
178
+ B(() => {
179
+ if (!a) return;
180
+ const $ = (f) => {
181
+ const I = f.target;
182
+ m.current && !m.current.contains(I) && g.current && !g.current.contains(I) && i(!1);
183
+ }, l = (f) => {
184
+ f.key === "Escape" && i(!1);
185
+ };
186
+ return document.addEventListener("click", $), document.addEventListener("keydown", l), () => {
187
+ document.removeEventListener("click", $), document.removeEventListener("keydown", l);
188
+ };
189
+ }, [a]);
190
+ const M = m.current?.closest(".ss-bar"), C = k && M ? ce(
191
+ /* @__PURE__ */ c(
192
+ "div",
193
+ {
194
+ ref: g,
195
+ className: `ss-tooltip ${a ? "ss-pinned" : ""}`,
196
+ style: E,
197
+ children: [
198
+ /* @__PURE__ */ c("div", { className: "ss-tooltip-inner", style: { position: "relative" }, children: [
199
+ a && /* @__PURE__ */ e(
200
+ "button",
201
+ {
202
+ className: "ss-tooltip-close",
203
+ onClick: ($) => {
204
+ $.stopPropagation(), i(!1);
205
+ },
206
+ type: "button",
207
+ children: "×"
208
+ }
209
+ ),
210
+ /* @__PURE__ */ c("div", { className: "ss-tooltip-header", children: [
211
+ /* @__PURE__ */ e("span", { className: "ss-tooltip-title", children: s.title }),
212
+ s.unit && /* @__PURE__ */ e("span", { className: "ss-tooltip-unit", children: s.unit })
213
+ ] }),
214
+ /* @__PURE__ */ c("div", { className: "ss-tooltip-current", children: [
215
+ /* @__PURE__ */ e("span", { className: "ss-tooltip-current-label", children: "Current: " }),
216
+ /* @__PURE__ */ e("span", { className: "ss-tooltip-current-value", children: p })
217
+ ] }),
218
+ b && /* @__PURE__ */ c("div", { className: "ss-tooltip-stats", children: [
219
+ /* @__PURE__ */ c("span", { children: [
220
+ "Min: ",
221
+ H(b.min, s.unit)
222
+ ] }),
223
+ /* @__PURE__ */ c("span", { children: [
224
+ "Max: ",
225
+ H(b.max, s.unit)
226
+ ] }),
227
+ /* @__PURE__ */ c("span", { children: [
228
+ "Avg: ",
229
+ H(b.avg, s.unit)
230
+ ] })
231
+ ] }),
232
+ v && /* @__PURE__ */ e("div", { className: "ss-tooltip-details", children: v }),
233
+ t.length > 0 && /* @__PURE__ */ c(j, { children: [
234
+ /* @__PURE__ */ e("div", { className: "ss-tooltip-sparkline", children: /* @__PURE__ */ e(ue, { data: t, color: w }) }),
235
+ /* @__PURE__ */ c("div", { className: "ss-tooltip-samples", children: [
236
+ "Last ",
237
+ Math.min(t.length, 60),
238
+ " samples (~",
239
+ Math.round(Math.min(t.length, 60) * 3 / 60),
240
+ " min)"
241
+ ] })
242
+ ] })
243
+ ] }),
244
+ /* @__PURE__ */ e("div", { className: "ss-tooltip-arrow" })
245
+ ]
246
+ }
247
+ ),
248
+ M
249
+ ) : null;
250
+ return /* @__PURE__ */ c(j, { children: [
251
+ /* @__PURE__ */ c(
252
+ "div",
253
+ {
254
+ ref: m,
255
+ className: `ss-badge ${a ? "ss-pinned" : ""} ${n}`,
256
+ onClick: O,
257
+ onMouseEnter: () => !a && r(!0),
258
+ onMouseLeave: () => r(!1),
259
+ role: "button",
260
+ tabIndex: 0,
261
+ onKeyDown: ($) => $.key === "Enter" && O($),
262
+ children: [
263
+ /* @__PURE__ */ e("span", { className: "ss-label", children: s.label }),
264
+ /* @__PURE__ */ e("span", { className: `ss-value ${d}`, children: p })
265
+ ]
266
+ }
267
+ ),
268
+ C
269
+ ] });
270
+ }
271
+ function Ge(s) {
272
+ const {
273
+ featureOptions: o,
274
+ autoHideOnUnauthorized: t = !0,
275
+ onOpenDebugPanel: n,
276
+ debugPanelOpen: a = !1,
277
+ onConnectionChange: i,
278
+ ...u
279
+ } = s, { stats: r, getHistory: m, isConnected: g, isStale: p, unauthorized: d } = de(u);
280
+ B(() => {
281
+ i?.(g);
282
+ }, [g, i]);
283
+ const { features: w } = U(o), { theme: v } = F(), [b, k] = N(() => typeof window > "u" ? !0 : localStorage.getItem("admin:stats-bar") !== "hidden"), E = R(null), O = R(null);
284
+ B(() => {
285
+ t && d && k(!1);
286
+ }, [t, d]);
287
+ const M = x(() => {
288
+ k((f) => {
289
+ const I = !f;
290
+ return localStorage.setItem("admin:stats-bar", I ? "visible" : "hidden"), I;
291
+ });
292
+ }, []);
293
+ B(() => {
294
+ const f = O.current;
295
+ if (!f) return;
296
+ const I = (y) => {
297
+ Math.abs(y.deltaX) > Math.abs(y.deltaY) || (y.preventDefault(), f.scrollLeft += y.deltaY);
298
+ };
299
+ return f.addEventListener("wheel", I, { passive: !1 }), () => f.removeEventListener("wheel", I);
300
+ }, []);
301
+ const C = D(() => r ? te(r) : ne(w), [r, w]), $ = D(
302
+ () => oe.filter((f) => C.has(f.group || "core")),
303
+ [C]
304
+ ), l = D(() => {
305
+ const f = [];
306
+ let I = "";
307
+ for (const y of $) {
308
+ const _ = y.group || "core";
309
+ _ !== I && (I = _, f.push({ group: I, metrics: [] })), f[f.length - 1].metrics.push(y);
310
+ }
311
+ return f;
312
+ }, [$]);
313
+ return t && d ? null : /* @__PURE__ */ c(j, { children: [
314
+ /* @__PURE__ */ c(
315
+ "button",
316
+ {
317
+ type: "button",
318
+ className: `ss-toggle ${b ? "ss-visible" : "ss-collapsed"}`,
319
+ onClick: M,
320
+ title: b ? "Hide stats bar" : "Show stats bar",
321
+ "data-ss-theme": v,
322
+ children: [
323
+ !b && r && /* @__PURE__ */ c("span", { className: "ss-toggle-summary", style: { display: "flex" }, children: [
324
+ C.has("process") && /* @__PURE__ */ c(j, { children: [
325
+ /* @__PURE__ */ c(
326
+ "span",
327
+ {
328
+ className: `ss-value ${r.cpuPercent > 80 ? "ss-red" : r.cpuPercent > 50 ? "ss-amber" : "ss-green"}`,
329
+ children: [
330
+ r.cpuPercent.toFixed(0),
331
+ "%"
332
+ ]
333
+ }
334
+ ),
335
+ /* @__PURE__ */ e("span", { className: "ss-value ss-green", children: r.memHeapUsed !== void 0 ? Math.round(r.memHeapUsed / (1024 * 1024)) + "M" : "-" })
336
+ ] }),
337
+ C.has("redis") && r.redisOk !== void 0 && /* @__PURE__ */ e("span", { className: `ss-value ${r.redisOk ? "ss-green" : "ss-red"}`, children: r.redisOk ? "✓" : "✗" })
338
+ ] }),
339
+ b && /* @__PURE__ */ e("span", { className: "ss-toggle-label", style: { color: "#737373" }, children: "hide stats" }),
340
+ /* @__PURE__ */ e("span", { className: "ss-toggle-arrow", children: b ? "▼" : "▲" })
341
+ ]
342
+ }
343
+ ),
344
+ /* @__PURE__ */ c("div", { ref: E, className: b ? "ss-bar" : "ss-bar ss-hidden", "data-ss-theme": v, children: [
345
+ /* @__PURE__ */ c("div", { className: "ss-bar-left", children: [
346
+ n && /* @__PURE__ */ e(
347
+ "button",
348
+ {
349
+ type: "button",
350
+ className: `ss-dbg-btn ${a ? "ss-dbg-active" : ""}`,
351
+ onClick: n,
352
+ title: "Toggle debug panel",
353
+ id: "ss-dbg-wrench",
354
+ children: /* @__PURE__ */ e(
355
+ "svg",
356
+ {
357
+ width: "14",
358
+ height: "14",
359
+ viewBox: S.wrench.viewBox,
360
+ fill: "none",
361
+ stroke: "currentColor",
362
+ strokeWidth: "2",
363
+ strokeLinecap: "round",
364
+ strokeLinejoin: "round",
365
+ dangerouslySetInnerHTML: { __html: S.wrench.elements.join("") }
366
+ }
367
+ )
368
+ }
369
+ ),
370
+ /* @__PURE__ */ e("div", { className: p ? "ss-dot ss-stale" : "ss-dot" })
371
+ ] }),
372
+ /* @__PURE__ */ e("div", { ref: O, className: "ss-bar-scroll", id: "ss-bar-scroll", children: r && l.map((f, I) => /* @__PURE__ */ c(K.Fragment, { children: [
373
+ I > 0 && /* @__PURE__ */ e("div", { className: "ss-group-sep" }),
374
+ /* @__PURE__ */ e("div", { className: "ss-group", children: f.metrics.map((y) => /* @__PURE__ */ e(
375
+ be,
376
+ {
377
+ metric: y,
378
+ stats: r,
379
+ history: m(y.historyKey || "")
380
+ },
381
+ y.id
382
+ )) })
383
+ ] }, f.group)) })
384
+ ] })
385
+ ] });
386
+ }
387
+ function A({
388
+ theme: s,
389
+ onToggle: o,
390
+ className: t = "",
391
+ classPrefix: n = "ss-dash"
392
+ }) {
393
+ const a = s === "dark";
394
+ return /* @__PURE__ */ e(
395
+ "button",
396
+ {
397
+ type: "button",
398
+ className: `${n === "ss-dbg" ? "ss-dbg-theme-toggle" : "ss-dash-theme-btn"} ${t}`,
399
+ onClick: o,
400
+ title: a ? "Switch to light theme" : "Switch to dark theme",
401
+ "aria-label": a ? "Switch to light theme" : "Switch to dark theme",
402
+ children: a ? (
403
+ // Sun icon
404
+ /* @__PURE__ */ e(
405
+ "svg",
406
+ {
407
+ width: "16",
408
+ height: "16",
409
+ viewBox: S.sun.viewBox,
410
+ fill: "none",
411
+ stroke: "currentColor",
412
+ strokeWidth: "2",
413
+ strokeLinecap: "round",
414
+ strokeLinejoin: "round",
415
+ dangerouslySetInnerHTML: { __html: S.sun.elements.join("") }
416
+ }
417
+ )
418
+ ) : (
419
+ // Moon icon
420
+ /* @__PURE__ */ e(
421
+ "svg",
422
+ {
423
+ width: "16",
424
+ height: "16",
425
+ viewBox: S.moon.viewBox,
426
+ fill: "none",
427
+ stroke: "currentColor",
428
+ strokeWidth: "2",
429
+ strokeLinecap: "round",
430
+ strokeLinejoin: "round",
431
+ dangerouslySetInnerHTML: { __html: S.moon.elements.join("") }
432
+ }
433
+ )
434
+ )
435
+ }
436
+ );
437
+ }
438
+ const ge = L(() => import("./QueriesTab-BQzcxEiW.js")), me = L(() => import("./EventsTab-CfVr7AiM.js")), ve = L(() => import("./EmailsTab-DbK4Eobn.js")), fe = L(() => import("./RoutesTab-CpYH5lUw.js")), we = L(() => import("./LogsTab-D8unMV5P.js")), ke = L(() => import("./TimelineTab-DjLR35Ce.js")), Ne = L(() => import("./CacheTab-2cw_rMzj.js")), ye = L(() => import("./JobsTab-znzf6jzk.js")), Ce = L(() => import("./ConfigTab-H3OnYqmK.js")), Se = L(() => import("./InternalsTab-Oij0A2fN.js")), Le = L(() => import("./CustomPaneTab-B6r7ha0u.js"));
439
+ function Qe(s) {
440
+ const {
441
+ defaultOpen: o = !1,
442
+ dashboardPath: t,
443
+ isOpen: n,
444
+ onOpenChange: a,
445
+ isLive: i = !1,
446
+ ...u
447
+ } = s, [r, m] = N(o), g = n !== void 0 ? n : r, p = (l) => {
448
+ a ? a(l) : m(l);
449
+ }, [d, w] = N("queries"), { features: v } = U(u), { theme: b, toggleTheme: k } = F(), E = v.customPanes || [];
450
+ B(() => {
451
+ const l = (f) => {
452
+ f.key === "Escape" && g && p(!1);
453
+ };
454
+ return document.addEventListener("keydown", l), () => document.removeEventListener("keydown", l);
455
+ }, [g]);
456
+ const O = D(
457
+ () => [
458
+ { id: "queries", label: "Queries", visible: !0 },
459
+ { id: "events", label: "Events", visible: !0 },
460
+ { id: "emails", label: "Emails", visible: !0 },
461
+ { id: "routes", label: "Routes", visible: !0 },
462
+ { id: "logs", label: "Logs", visible: !0 },
463
+ { id: "timeline", label: "Requests", visible: v.tracing },
464
+ { id: "cache", label: "Cache", visible: v.cache },
465
+ { id: "jobs", label: "Jobs", visible: v.queues },
466
+ { id: "config", label: "Config", visible: !0 },
467
+ { id: "internals", label: "Internals", visible: !0 }
468
+ ],
469
+ [v]
470
+ ), M = D(() => O.filter((l) => l.visible), [O]);
471
+ B(() => {
472
+ const l = [
473
+ ...M.map((f) => f.id),
474
+ ...E.map((f) => f.id)
475
+ ];
476
+ !l.includes(d) && l.length > 0 && w(l[0]);
477
+ }, [M, E, d]);
478
+ const C = x(() => {
479
+ p(!g);
480
+ }, [g]), $ = x(() => {
481
+ const l = { options: u }, f = E.find((y) => y.id === d);
482
+ if (f)
483
+ return /* @__PURE__ */ e(q, { fallback: /* @__PURE__ */ e("div", { className: "ss-dbg-empty", children: "Loading..." }), children: /* @__PURE__ */ e(Le, { pane: f, options: u }) });
484
+ const I = {
485
+ queries: /* @__PURE__ */ e(ge, { ...l }),
486
+ events: /* @__PURE__ */ e(me, { ...l }),
487
+ emails: /* @__PURE__ */ e(ve, { ...l }),
488
+ routes: /* @__PURE__ */ e(
489
+ fe,
490
+ {
491
+ ...l,
492
+ currentPath: typeof window < "u" ? window.location.pathname : ""
493
+ }
494
+ ),
495
+ logs: /* @__PURE__ */ e(we, { ...l }),
496
+ timeline: /* @__PURE__ */ e(ke, { ...l }),
497
+ cache: /* @__PURE__ */ e(Ne, { ...l, dashboardPath: t }),
498
+ jobs: /* @__PURE__ */ e(ye, { ...l, dashboardPath: t }),
499
+ config: /* @__PURE__ */ e(Ce, { ...l, dashboardPath: t }),
500
+ internals: /* @__PURE__ */ e(Se, { ...l })
501
+ };
502
+ return /* @__PURE__ */ e(q, { fallback: /* @__PURE__ */ e("div", { className: "ss-dbg-empty", children: "Loading..." }), children: I[d] || /* @__PURE__ */ e("div", { className: "ss-dbg-empty", children: "Unknown tab" }) });
503
+ }, [d, u, E]);
504
+ return /* @__PURE__ */ c(j, { children: [
505
+ n === void 0 && /* @__PURE__ */ e(
506
+ "button",
507
+ {
508
+ type: "button",
509
+ className: `ss-dbg-btn ${g ? "ss-dbg-active" : ""}`,
510
+ onClick: C,
511
+ title: "Toggle debug panel",
512
+ id: "ss-dbg-wrench",
513
+ children: /* @__PURE__ */ e(
514
+ "svg",
515
+ {
516
+ width: "14",
517
+ height: "14",
518
+ viewBox: S.wrench.viewBox,
519
+ fill: "none",
520
+ stroke: "currentColor",
521
+ strokeWidth: "2",
522
+ strokeLinecap: "round",
523
+ strokeLinejoin: "round",
524
+ dangerouslySetInnerHTML: { __html: S.wrench.elements.join("") }
525
+ }
526
+ )
527
+ }
528
+ ),
529
+ /* @__PURE__ */ c(
530
+ "div",
531
+ {
532
+ className: `ss-dbg-panel ${g ? "ss-dbg-open" : ""}`,
533
+ "data-ss-theme": b,
534
+ id: "ss-dbg-panel",
535
+ children: [
536
+ /* @__PURE__ */ c("div", { className: "ss-dbg-tabs", children: [
537
+ /* @__PURE__ */ c("div", { className: "ss-dbg-tabs-scroll", children: [
538
+ M.map((l) => /* @__PURE__ */ c(
539
+ "button",
540
+ {
541
+ type: "button",
542
+ className: `ss-dbg-tab ${d === l.id ? "ss-dbg-active" : ""}`,
543
+ onClick: () => w(l.id),
544
+ children: [
545
+ S[l.id] ? /* @__PURE__ */ e(
546
+ "svg",
547
+ {
548
+ className: "ss-dbg-tab-icon",
549
+ viewBox: S[l.id].viewBox,
550
+ dangerouslySetInnerHTML: { __html: S[l.id].elements.join("") }
551
+ }
552
+ ) : null,
553
+ l.label
554
+ ]
555
+ },
556
+ l.id
557
+ )),
558
+ E.map((l) => /* @__PURE__ */ e(
559
+ "button",
560
+ {
561
+ type: "button",
562
+ className: `ss-dbg-tab ${d === l.id ? "ss-dbg-active" : ""}`,
563
+ onClick: () => w(l.id),
564
+ children: l.label
565
+ },
566
+ l.id
567
+ ))
568
+ ] }),
569
+ /* @__PURE__ */ c("div", { className: "ss-dbg-tabs-right", children: [
570
+ /* @__PURE__ */ e(
571
+ "span",
572
+ {
573
+ className: `ss-dbg-conn-mode ${i ? "ss-dbg-conn-live" : "ss-dbg-conn-polling"}`,
574
+ title: i ? "Connected via Transmit (SSE) — real-time updates" : "Polling every 3s",
575
+ children: i ? "live" : "polling"
576
+ }
577
+ ),
578
+ /* @__PURE__ */ e(A, { theme: b, onToggle: k, classPrefix: "ss-dbg" }),
579
+ t && /* @__PURE__ */ e(
580
+ "a",
581
+ {
582
+ href: t,
583
+ target: "_blank",
584
+ rel: "noopener noreferrer",
585
+ className: "ss-dbg-dashboard-link",
586
+ title: "Open dashboard",
587
+ children: /* @__PURE__ */ e(
588
+ "svg",
589
+ {
590
+ width: "14",
591
+ height: "14",
592
+ viewBox: S["external-link"].viewBox,
593
+ fill: "none",
594
+ stroke: "currentColor",
595
+ strokeWidth: "2",
596
+ strokeLinecap: "round",
597
+ strokeLinejoin: "round",
598
+ dangerouslySetInnerHTML: { __html: S["external-link"].elements.join("") }
599
+ }
600
+ )
601
+ }
602
+ ),
603
+ /* @__PURE__ */ e(
604
+ "button",
605
+ {
606
+ type: "button",
607
+ className: "ss-dbg-close",
608
+ onClick: () => p(!1),
609
+ title: "Close panel",
610
+ children: "×"
611
+ }
612
+ )
613
+ ] })
614
+ ] }),
615
+ /* @__PURE__ */ e("div", { className: "ss-dbg-content", children: g && $() })
616
+ ]
617
+ }
618
+ )
619
+ ] });
620
+ }
621
+ function Te(s, o) {
622
+ return new re({
623
+ baseUrl: o.baseUrl,
624
+ endpoint: o.dashboardEndpoint,
625
+ authToken: o.authToken,
626
+ section: s,
627
+ perPage: o.perPage,
628
+ callbacks: {
629
+ onData: (t) => o.setData(t),
630
+ onPagination: (t) => o.setMeta(t),
631
+ onLoading: (t) => o.setIsLoading(t),
632
+ onError: (t) => o.setError(t),
633
+ onUnauthorized: () => {
634
+ }
635
+ }
636
+ });
637
+ }
638
+ function Ee(s, o) {
639
+ s.ctrl.configure(o);
640
+ const t = s.prevSection !== s.section;
641
+ return t || !s.hasFetched ? (t ? s.ctrl.setSection(s.section) : s.ctrl.start(), !0) : (s.ctrl.start(), s.hasFetched);
642
+ }
643
+ function $e() {
644
+ const [s, o] = N(null), [t, n] = N(null), [a, i] = N(!0), [u, r] = N(null);
645
+ return { data: s, setData: o, meta: t, setMeta: n, isLoading: a, setIsLoading: i, error: u, setError: r };
646
+ }
647
+ function xe(s) {
648
+ const o = x(() => {
649
+ s.current?.fetch(!0);
650
+ }, []), t = x(
651
+ async (a, i = "post", u) => s.current.mutate(a, i, u),
652
+ []
653
+ ), n = x(() => s.current.getApi(), []);
654
+ return { refresh: o, mutate: t, getApi: n };
655
+ }
656
+ function Ie(s, o, t, n) {
657
+ s.current || (s.current = Te(o, {
658
+ ...t,
659
+ setData: (a) => n.setData(a),
660
+ setMeta: n.setMeta,
661
+ setIsLoading: n.setIsLoading,
662
+ setError: n.setError
663
+ }));
664
+ }
665
+ function Me(s) {
666
+ return {
667
+ baseUrl: s.baseUrl ?? "",
668
+ dashboardEndpoint: s.dashboardEndpoint ?? "/__stats/api",
669
+ authToken: s.authToken,
670
+ page: s.page ?? 1,
671
+ perPage: s.perPage ?? 50,
672
+ search: s.search,
673
+ sort: s.sort,
674
+ sortDir: s.sortDir,
675
+ filters: s.filters,
676
+ timeRange: s.timeRange,
677
+ refreshKey: s.refreshKey
678
+ };
679
+ }
680
+ function Be(s, o = {}) {
681
+ const t = Me(o), n = $e(), a = R(null), i = R(s), u = R(!1);
682
+ Ie(a, s, t, n), B(() => {
683
+ const m = i.current;
684
+ return i.current = s, u.current = Ee(
685
+ {
686
+ ctrl: a.current,
687
+ section: s,
688
+ prevSection: m,
689
+ hasFetched: u.current
690
+ },
691
+ t
692
+ ), () => {
693
+ a.current.stop();
694
+ };
695
+ }, [
696
+ s,
697
+ t.page,
698
+ t.perPage,
699
+ t.search,
700
+ t.sort,
701
+ t.sortDir,
702
+ t.filters,
703
+ t.timeRange,
704
+ t.refreshKey
705
+ ]);
706
+ const r = xe(a);
707
+ return {
708
+ data: n.data,
709
+ meta: n.meta,
710
+ isLoading: n.isLoading,
711
+ error: n.error,
712
+ ...r
713
+ };
714
+ }
715
+ const De = [
716
+ "overview",
717
+ "requests",
718
+ "queries",
719
+ "events",
720
+ "routes",
721
+ "logs",
722
+ "emails",
723
+ "cache",
724
+ "jobs",
725
+ "config",
726
+ "internals"
727
+ ], Re = L(() => import("./OverviewSection-ABP9ueBo.js")), Oe = L(() => import("./RequestsSection-kW79_M7k.js")), _e = L(() => import("./QueriesSection-CnmSkznA.js")), je = L(() => import("./EventsSection-C7RQW_LY.js")), Pe = L(() => import("./RoutesSection-BRhxrtjZ.js")), He = L(() => import("./LogsSection-Dmm3rE2B.js")), qe = L(() => import("./EmailsSection-C-UZISG-.js")), Ue = L(() => import("./CacheSection-baMZotSn.js")), Fe = L(() => import("./JobsSection-CQHNK_Ls.js")), Ae = L(() => import("./ConfigSection-DGgqjAal.js")), ze = L(() => import("./InternalsSection-t7ihcWO-.js"));
728
+ function Xe(s) {
729
+ const {
730
+ baseUrl: o = "",
731
+ dashboardEndpoint: t = "/__stats/api",
732
+ debugEndpoint: n,
733
+ authToken: a,
734
+ backUrl: i = "/",
735
+ channelName: u = "server-stats/dashboard"
736
+ } = s, { features: r } = U({ baseUrl: o, debugEndpoint: n, authToken: a }), { theme: m, toggleTheme: g } = F(), [p, d] = N("overview"), [w, v] = N(() => typeof window > "u" ? !1 : localStorage.getItem("ss-dash-sidebar") === "collapsed"), [b, k] = N(!1), [E, O] = N(0), M = R(0);
737
+ B(() => {
738
+ if (!u) return;
739
+ const h = ae({
740
+ baseUrl: o,
741
+ channelName: u,
742
+ authToken: a,
743
+ onMessage: () => {
744
+ M.current += 1, O(M.current);
745
+ },
746
+ onConnect: () => k(!0),
747
+ onDisconnect: () => k(!1),
748
+ onError: () => k(!1)
749
+ });
750
+ return () => h.unsubscribe();
751
+ }, [o, u, a]);
752
+ const C = r.customPanes || [], $ = x(
753
+ (h) => {
754
+ const T = h.replace("#", "").split("?")[0];
755
+ return T && [...De, ...C.map((J) => J.id)].includes(T) ? T : "overview";
756
+ },
757
+ [C]
758
+ );
759
+ B(() => {
760
+ if (typeof window > "u") return;
761
+ const h = $(window.location.hash);
762
+ (h !== "overview" || window.location.hash) && d(h);
763
+ }, [$]), B(() => {
764
+ const h = () => {
765
+ const T = $(window.location.hash);
766
+ T !== p && d(T);
767
+ };
768
+ return window.addEventListener("hashchange", h), () => window.removeEventListener("hashchange", h);
769
+ }, [p, $]), B(() => {
770
+ typeof window > "u" || (window.location.hash = p);
771
+ }, [p]);
772
+ const l = x(() => {
773
+ v((h) => {
774
+ const T = !h;
775
+ return localStorage.setItem("ss-dash-sidebar", T ? "collapsed" : "expanded"), T;
776
+ });
777
+ }, []), f = D(
778
+ () => [
779
+ { id: "overview", label: "Overview", visible: !0 },
780
+ { id: "requests", label: "Requests", visible: !0 },
781
+ { id: "queries", label: "Queries", visible: !0 },
782
+ { id: "events", label: "Events", visible: !0 },
783
+ { id: "routes", label: "Routes", visible: !0 },
784
+ { id: "logs", label: "Logs", visible: !0 },
785
+ { id: "emails", label: "Emails", visible: !0 },
786
+ { id: "cache", label: "Cache", visible: r.cache },
787
+ { id: "jobs", label: "Jobs", visible: r.queues },
788
+ { id: "config", label: "Config", visible: !0 },
789
+ { id: "internals", label: "Internals", visible: !0 }
790
+ ],
791
+ [r]
792
+ ), I = D(() => f.filter((h) => h.visible), [f]), y = D(
793
+ () => ({ baseUrl: o, dashboardEndpoint: t, authToken: a, refreshKey: E }),
794
+ [o, t, a, E]
795
+ ), { data: _ } = Be("overview", y), z = D(() => {
796
+ if (!_) return {};
797
+ const h = {};
798
+ if (_.totalRequests > 0 && (h.requests = { count: _.totalRequests }), _.queryStats?.total > 0 && (h.queries = { count: _.queryStats.total }), _.logLevelBreakdown) {
799
+ const T = _.logLevelBreakdown, P = T.error + T.warn + T.info + T.debug;
800
+ P > 0 && (h.logs = { count: P });
801
+ }
802
+ return h;
803
+ }, [_]), W = x(() => {
804
+ const h = {
805
+ overview: /* @__PURE__ */ e(Re, { options: y }),
806
+ requests: /* @__PURE__ */ e(Oe, { options: y }),
807
+ queries: /* @__PURE__ */ e(_e, { options: y }),
808
+ events: /* @__PURE__ */ e(je, { options: y }),
809
+ routes: /* @__PURE__ */ e(Pe, { options: y }),
810
+ logs: /* @__PURE__ */ e(He, { options: y }),
811
+ emails: /* @__PURE__ */ e(qe, { options: y }),
812
+ cache: /* @__PURE__ */ e(Ue, { options: y }),
813
+ jobs: /* @__PURE__ */ e(Fe, { options: y }),
814
+ config: /* @__PURE__ */ e(Ae, { options: y }),
815
+ internals: /* @__PURE__ */ e(ze, { options: y, debugEndpoint: n })
816
+ };
817
+ return /* @__PURE__ */ e("div", { className: "ss-dash-pane ss-dash-active", id: `ss-dash-pane-${p}`, children: /* @__PURE__ */ e("div", { className: "ss-dash-pane-inner", children: /* @__PURE__ */ e(q, { fallback: /* @__PURE__ */ e("div", { className: "ss-dash-empty", children: "Loading..." }), children: h[p] || /* @__PURE__ */ e("div", { className: "ss-dash-empty", children: "Unknown section" }) }) }) });
818
+ }, [p, y]);
819
+ return /* @__PURE__ */ c("div", { className: "ss-dash", "data-theme": m, id: "ss-dash", children: [
820
+ /* @__PURE__ */ c("div", { className: "ss-dash-header", children: [
821
+ /* @__PURE__ */ c("div", { className: "ss-dash-header-left", children: [
822
+ /* @__PURE__ */ e("span", { className: "ss-dash-logo", children: "Server Stats" }),
823
+ /* @__PURE__ */ e("span", { className: "ss-dash-logo-sub", children: "Dashboard" })
824
+ ] }),
825
+ /* @__PURE__ */ c("div", { className: "ss-dash-header-center", children: [
826
+ /* @__PURE__ */ e(
827
+ "span",
828
+ {
829
+ className: `ss-dash-live-dot ${b ? "ss-dash-connected" : ""}`,
830
+ id: "ss-dash-live-dot"
831
+ }
832
+ ),
833
+ /* @__PURE__ */ e(
834
+ "span",
835
+ {
836
+ className: `ss-dash-live-label ${b ? "ss-dash-connected" : ""}`,
837
+ id: "ss-dash-live-label",
838
+ children: b ? "Live" : "Polling"
839
+ }
840
+ )
841
+ ] }),
842
+ /* @__PURE__ */ c("div", { className: "ss-dash-header-right", children: [
843
+ /* @__PURE__ */ e(A, { theme: m, onToggle: g }),
844
+ i && /* @__PURE__ */ e("a", { href: i, className: "ss-dash-back-link", title: "Back to app", children: "← App" })
845
+ ] })
846
+ ] }),
847
+ /* @__PURE__ */ c("div", { className: "ss-dash-body", children: [
848
+ /* @__PURE__ */ c(
849
+ "div",
850
+ {
851
+ className: `ss-dash-sidebar ${w ? "ss-dash-collapsed" : ""}`,
852
+ id: "ss-dash-sidebar",
853
+ children: [
854
+ /* @__PURE__ */ c("nav", { className: "ss-dash-nav", children: [
855
+ I.map((h) => {
856
+ const T = z[h.id];
857
+ return /* @__PURE__ */ c(
858
+ "button",
859
+ {
860
+ type: "button",
861
+ className: `ss-dash-nav-item ${p === h.id ? "ss-dash-active" : ""}`,
862
+ "data-ss-section": h.id,
863
+ onClick: () => {
864
+ h.id !== p && d(h.id);
865
+ },
866
+ title: w ? h.label : void 0,
867
+ children: [
868
+ /* @__PURE__ */ e("span", { className: "ss-dash-nav-icon", children: /* @__PURE__ */ e(
869
+ "svg",
870
+ {
871
+ width: "20",
872
+ height: "20",
873
+ viewBox: (S[h.id] || S.config).viewBox,
874
+ fill: "none",
875
+ stroke: "currentColor",
876
+ strokeWidth: "2",
877
+ strokeLinecap: "round",
878
+ strokeLinejoin: "round",
879
+ dangerouslySetInnerHTML: {
880
+ __html: (S[h.id] || S.config).elements.join("")
881
+ }
882
+ }
883
+ ) }),
884
+ /* @__PURE__ */ e("span", { className: "ss-dash-nav-label", children: h.label }),
885
+ T && T.count > 0 && /* @__PURE__ */ e(
886
+ "span",
887
+ {
888
+ className: `ss-dash-nav-badge${T.variant ? " " + T.variant : ""}`,
889
+ children: T.count
890
+ }
891
+ )
892
+ ]
893
+ },
894
+ h.id
895
+ );
896
+ }),
897
+ C.length > 0 && /* @__PURE__ */ e("div", { className: "ss-dash-nav-sep" }),
898
+ C.map((h) => /* @__PURE__ */ c(
899
+ "button",
900
+ {
901
+ type: "button",
902
+ className: `ss-dash-nav-item ${p === h.id ? "ss-dash-active" : ""}`,
903
+ onClick: () => d(h.id),
904
+ title: w ? h.label : void 0,
905
+ children: [
906
+ /* @__PURE__ */ e("span", { className: "ss-dash-nav-icon", children: /* @__PURE__ */ e(
907
+ "svg",
908
+ {
909
+ width: "20",
910
+ height: "20",
911
+ viewBox: S["custom-pane"].viewBox,
912
+ fill: "none",
913
+ stroke: "currentColor",
914
+ strokeWidth: "2",
915
+ strokeLinecap: "round",
916
+ strokeLinejoin: "round",
917
+ dangerouslySetInnerHTML: { __html: S["custom-pane"].elements.join("") }
918
+ }
919
+ ) }),
920
+ /* @__PURE__ */ e("span", { className: "ss-dash-nav-label", children: h.label })
921
+ ]
922
+ },
923
+ h.id
924
+ ))
925
+ ] }),
926
+ /* @__PURE__ */ e(
927
+ "button",
928
+ {
929
+ type: "button",
930
+ className: "ss-dash-sidebar-toggle",
931
+ id: "ss-dash-sidebar-toggle",
932
+ onClick: l,
933
+ title: w ? "Expand sidebar" : "Collapse sidebar",
934
+ children: w ? /* @__PURE__ */ e(
935
+ "svg",
936
+ {
937
+ width: "16",
938
+ height: "16",
939
+ viewBox: S["chevron-right"].viewBox,
940
+ fill: "none",
941
+ stroke: "currentColor",
942
+ strokeWidth: "1.5",
943
+ dangerouslySetInnerHTML: { __html: S["chevron-right"].elements.join("") }
944
+ }
945
+ ) : /* @__PURE__ */ e(
946
+ "svg",
947
+ {
948
+ width: "16",
949
+ height: "16",
950
+ viewBox: S["chevron-left"].viewBox,
951
+ fill: "none",
952
+ stroke: "currentColor",
953
+ strokeWidth: "1.5",
954
+ dangerouslySetInnerHTML: { __html: S["chevron-left"].elements.join("") }
955
+ }
956
+ )
957
+ }
958
+ )
959
+ ]
960
+ }
961
+ ),
962
+ /* @__PURE__ */ e("div", { className: "ss-dash-main", children: W() })
963
+ ] })
964
+ ] });
965
+ }
966
+ function Ye(s, o = {}) {
967
+ const { baseUrl: t = "", debugEndpoint: n = "/admin/api/debug", authToken: a } = o, [i, u] = N(null), [r, m] = N(!0), [g, p] = N(null), d = R(null);
968
+ d.current || (d.current = new ie({
969
+ baseUrl: t,
970
+ endpoint: n,
971
+ authToken: a,
972
+ onData: (k) => u(k),
973
+ onLoading: (k) => m(k),
974
+ onError: (k) => p(k),
975
+ onUnauthorized: (k) => p(k)
976
+ })), B(() => {
977
+ const k = d.current;
978
+ return k.start(s), () => k.stop();
979
+ }, [s]);
980
+ const w = x(() => {
981
+ d.current?.refresh();
982
+ }, []), v = x(() => {
983
+ u(null);
984
+ }, []), b = x((k, E) => {
985
+ d.current?.cacheForTab(k, E);
986
+ }, []);
987
+ return { data: i, isLoading: r, error: g, refresh: w, clearData: v, cacheForTab: b };
988
+ }
989
+ function Ze({
990
+ color: s = "muted",
991
+ children: o,
992
+ className: t = "",
993
+ classPrefix: n = "ss-dash"
994
+ }) {
995
+ return /* @__PURE__ */ e("span", { className: `${n}-badge ${n}-badge-${s} ${t}`, children: o });
996
+ }
997
+ function es({ method: s, className: o = "", classPrefix: t = "ss-dash" }) {
998
+ return /* @__PURE__ */ e(
999
+ "span",
1000
+ {
1001
+ className: `${t}-method ${t}-method-${s.toLowerCase()} ${o}`,
1002
+ children: s
1003
+ }
1004
+ );
1005
+ }
1006
+ function ss({ code: s, className: o = "", classPrefix: t = "ss-dash" }) {
1007
+ let n = `${t}-status-2xx`;
1008
+ return s >= 500 ? n = `${t}-status-5xx` : s >= 400 ? n = `${t}-status-4xx` : s >= 300 && (n = `${t}-status-3xx`), /* @__PURE__ */ e("span", { className: `${t}-status ${n} ${o}`, children: s });
1009
+ }
1010
+ function ts({
1011
+ data: s,
1012
+ maxPreviewLength: o = 100,
1013
+ className: t = "",
1014
+ classPrefix: n = "ss-dash",
1015
+ defaultExpanded: a = !1
1016
+ }) {
1017
+ const [i, u] = N(a), r = D(() => {
1018
+ if (typeof s == "string")
1019
+ try {
1020
+ return JSON.parse(s);
1021
+ } catch {
1022
+ return s;
1023
+ }
1024
+ return s;
1025
+ }, [s]), m = D(() => typeof r == "object" && r !== null ? le(r, o) : String(r ?? "-"), [r, o]), g = D(() => typeof r == "object" && r !== null ? JSON.stringify(r, null, 2) : String(r), [r]), p = x(() => {
1026
+ u((w) => !w);
1027
+ }, []), d = x(async () => {
1028
+ try {
1029
+ await navigator.clipboard.writeText(g);
1030
+ } catch {
1031
+ }
1032
+ }, [g]);
1033
+ return !s && s !== 0 && s !== !1 ? /* @__PURE__ */ e("span", { className: `ss-dim ${n}-c-dim`, children: "-" }) : /* @__PURE__ */ c("div", { className: `${n}-data-cell ${t}`, children: [
1034
+ !i && /* @__PURE__ */ e(
1035
+ "span",
1036
+ {
1037
+ className: `${n}-data-preview`,
1038
+ onClick: p,
1039
+ role: "button",
1040
+ tabIndex: 0,
1041
+ onKeyDown: (w) => w.key === "Enter" && p(),
1042
+ children: m
1043
+ }
1044
+ ),
1045
+ i && /* @__PURE__ */ c("div", { className: `${n}-data-full`, onClick: p, children: [
1046
+ /* @__PURE__ */ e(
1047
+ "button",
1048
+ {
1049
+ className: `${n}-copy-btn`,
1050
+ onClick: (w) => {
1051
+ w.stopPropagation(), d();
1052
+ },
1053
+ title: "Copy to clipboard",
1054
+ type: "button",
1055
+ children: "Copy"
1056
+ }
1057
+ ),
1058
+ /* @__PURE__ */ e("pre", { children: g })
1059
+ ] })
1060
+ ] });
1061
+ }
1062
+ function ns({ content: s, children: o, position: t = "top", className: n = "" }) {
1063
+ const [a, i] = N(!1), [u, r] = N({ left: 0, bottom: 0 }), m = R(null), g = R(null), p = x(() => {
1064
+ i(!0);
1065
+ }, []), d = x(() => {
1066
+ i(!1);
1067
+ }, []);
1068
+ return B(() => {
1069
+ if (!a || !m.current || !g.current) return;
1070
+ const w = m.current.getBoundingClientRect(), v = g.current.getBoundingClientRect();
1071
+ let b = w.left + w.width / 2 - v.width / 2, k;
1072
+ b < 8 && (b = 8), b + v.width > window.innerWidth - 8 && (b = window.innerWidth - 8 - v.width), t === "top" && (k = window.innerHeight - w.top + 8), r({ left: b, bottom: k ?? 0 });
1073
+ }, [a, t]), /* @__PURE__ */ c(
1074
+ "div",
1075
+ {
1076
+ ref: m,
1077
+ className: `ss-tooltip-trigger ${n}`,
1078
+ onMouseEnter: p,
1079
+ onMouseLeave: d,
1080
+ style: { display: "inline-flex", position: "relative" },
1081
+ children: [
1082
+ o,
1083
+ a && /* @__PURE__ */ c(
1084
+ "div",
1085
+ {
1086
+ ref: g,
1087
+ className: "ss-tooltip",
1088
+ style: {
1089
+ position: "fixed",
1090
+ left: `${u.left}px`,
1091
+ bottom: t === "top" ? `${u.bottom}px` : void 0,
1092
+ zIndex: 200,
1093
+ pointerEvents: "none"
1094
+ },
1095
+ children: [
1096
+ /* @__PURE__ */ e("div", { className: "ss-tooltip-inner", children: s }),
1097
+ /* @__PURE__ */ e("div", { className: "ss-tooltip-arrow" })
1098
+ ]
1099
+ }
1100
+ )
1101
+ ]
1102
+ }
1103
+ );
1104
+ }
1105
+ export {
1106
+ Ze as B,
1107
+ Xe as D,
1108
+ ts as J,
1109
+ es as M,
1110
+ ue as S,
1111
+ A as T,
1112
+ Be as a,
1113
+ ss as b,
1114
+ Qe as c,
1115
+ Ge as d,
1116
+ ns as e,
1117
+ U as f,
1118
+ de as g,
1119
+ F as h,
1120
+ Ye as u
1121
+ };