@lunora/studio 0.0.0 → 1.0.0-alpha.1

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 (81) hide show
  1. package/LICENSE.md +105 -0
  2. package/README.md +123 -9
  3. package/__assets__/package-og.svg +14 -0
  4. package/dist/index.d.ts +1402 -0
  5. package/dist/index.js +41 -0
  6. package/dist/mount.d.ts +21 -0
  7. package/dist/mount.js +26 -0
  8. package/dist/packem_shared/ADMIN_FUNCTION_PREFIX-DmBqMZ-z.js +45 -0
  9. package/dist/packem_shared/ApiDocsPanel-DpRjJhG5.js +842 -0
  10. package/dist/packem_shared/ApiReferencePanel-DMIUp-kK.js +229 -0
  11. package/dist/packem_shared/ApiTab-DURGU15e.js +251 -0
  12. package/dist/packem_shared/AuditPanel-BC59Nhst.js +212 -0
  13. package/dist/packem_shared/CommandPalette-Dx_CoB9i.js +373 -0
  14. package/dist/packem_shared/ConfirmButton-WQVUoGFb.js +59 -0
  15. package/dist/packem_shared/ConnectionBadge-Bxagrip8.js +111 -0
  16. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js +50 -0
  17. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-DjF0h-gA.js +89 -0
  18. package/dist/packem_shared/DataBrowser-Coz6jJE6.js +4542 -0
  19. package/dist/packem_shared/DataFilters-FNquMaiu.js +249 -0
  20. package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +66 -0
  21. package/dist/packem_shared/ExportImportPanel-WO34fJxy.js +193 -0
  22. package/dist/packem_shared/FileBrowser-Zcr-Qgxo.js +2932 -0
  23. package/dist/packem_shared/FunctionRunner-j0Rd5m9t.js +343 -0
  24. package/dist/packem_shared/FunctionStatsPanel-DboBl-XL.js +432 -0
  25. package/dist/packem_shared/GlobalDataBrowser-9MhPEfgN.js +318 -0
  26. package/dist/packem_shared/HealthPanel-DOIgbUtx.js +640 -0
  27. package/dist/packem_shared/HomePanel-bdOCNA-p.js +1273 -0
  28. package/dist/packem_shared/InsightsPanel-DaZPnSgt.js +423 -0
  29. package/dist/packem_shared/LogsPanel-CWdqAGpQ.js +839 -0
  30. package/dist/packem_shared/MailPanel-D_EGtDnS.js +447 -0
  31. package/dist/packem_shared/MetricsPanel-E4Gv6wTO.js +1625 -0
  32. package/dist/packem_shared/MigrationsPanel-DQdPY9io.js +246 -0
  33. package/dist/packem_shared/OpenRpcReferencePanel-j2p3HB0s.js +191 -0
  34. package/dist/packem_shared/PitrPanel-BbBkQR6t.js +252 -0
  35. package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +3 -0
  36. package/dist/packem_shared/ScheduledJobs-Ok1CYYwI.js +159 -0
  37. package/dist/packem_shared/SchemaViewer-D8XGnp-X.js +2512 -0
  38. package/dist/packem_shared/SecurityAdvisorPanel-Cdm2IxLW.js +79 -0
  39. package/dist/packem_shared/SettingsPanel-D3WF2mBU.js +176 -0
  40. package/dist/packem_shared/ShardInput-DNCsT1KW.js +107 -0
  41. package/dist/packem_shared/SqlEditorPanel-BuQ7f2Hs.js +13 -0
  42. package/dist/packem_shared/Studio-D36od9Oz.js +33 -0
  43. package/dist/packem_shared/StudioApp-dvywkJ8I.js +383 -0
  44. package/dist/packem_shared/StudioI18nProvider-Dcajsznk.js +48 -0
  45. package/dist/packem_shared/TableEditor-DIVDk3vT.js +371 -0
  46. package/dist/packem_shared/advisor-view-DBlzJi6C.js +159 -0
  47. package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +108 -0
  48. package/dist/packem_shared/app.d-CCmwDEVs.d.ts +300 -0
  49. package/dist/packem_shared/badge-B2PKA1-5.js +49 -0
  50. package/dist/packem_shared/bar-chart-CzJAgqkp.js +3245 -0
  51. package/dist/packem_shared/button-BhsN2uZH.js +49 -0
  52. package/dist/packem_shared/card-DURq3ElK.js +175 -0
  53. package/dist/packem_shared/cf-links-BZfRdxSE.js +8 -0
  54. package/dist/packem_shared/checkbox-UNkzAxl-.js +63 -0
  55. package/dist/packem_shared/createStudioI18n-CgvlmDkN.js +27 -0
  56. package/dist/packem_shared/data-grid-CCh2Couo.js +183 -0
  57. package/dist/packem_shared/dropdown-menu-WY4B_eJO.js +280 -0
  58. package/dist/packem_shared/empty-state-DY_oe0k6.js +98 -0
  59. package/dist/packem_shared/grid-features-DTjG6Sex.js +840 -0
  60. package/dist/packem_shared/input-XH4r1Pt1.js +53 -0
  61. package/dist/packem_shared/internal-BBZYexre.js +68 -0
  62. package/dist/packem_shared/label-D8ykjn5J.js +46 -0
  63. package/dist/packem_shared/live-status-bPff1O7Y.js +44 -0
  64. package/dist/packem_shared/reference-view-BCKIoai7.js +2180 -0
  65. package/dist/packem_shared/shard-history-DyebH1R5.js +38 -0
  66. package/dist/packem_shared/sparkline-10dG-_f0.js +93 -0
  67. package/dist/packem_shared/sql-editor-panel-CW2y2x9h.js +2562 -0
  68. package/dist/packem_shared/storage-tier-CL98eOvn.js +85 -0
  69. package/dist/packem_shared/studio-BDVd7rIV.js +10303 -0
  70. package/dist/packem_shared/table-_RzNvy3R.js +246 -0
  71. package/dist/packem_shared/table-list-sidebar-aZHLq70w.js +832 -0
  72. package/dist/packem_shared/textarea-D3gaCU_-.js +46 -0
  73. package/dist/packem_shared/use-live-admin-D1h1Fzsd.js +73 -0
  74. package/dist/packem_shared/use-live-shard-seed-B74RYcOy.js +76 -0
  75. package/dist/packem_shared/useDebounced-Dxncpg6z.js +32 -0
  76. package/dist/packem_shared/utils-B05Dmz_H.js +8 -0
  77. package/dist/packem_shared/virtual-rect-CVMUskSm.js +10 -0
  78. package/dist/standalone/studio.js +356 -0
  79. package/dist/styles.css +2 -0
  80. package/package.json +77 -17
  81. package/src/theme.css +59 -0
@@ -0,0 +1,1625 @@
1
+ 'use client';
2
+ import { c } from 'react/compiler-runtime';
3
+ import { useLunora } from '@lunora/react';
4
+ import { useState, useRef, useEffect, useMemo } from 'react';
5
+ import { L as LiveError } from './live-status-bPff1O7Y.js';
6
+ import { ShardInput } from './ShardInput-DNCsT1KW.js';
7
+ import { B as Button } from './button-BhsN2uZH.js';
8
+ import { a as CardContent, C as Card, b as CardHeader, c as CardTitle, d as CardDescription } from './card-DURq3ElK.js';
9
+ import { T as Table, a as TableHeader, b as TableRow, c as TableHead, d as TableBody, e as TableCell } from './table-_RzNvy3R.js';
10
+ import { u as useLiveAdmin } from './use-live-admin-D1h1Fzsd.js';
11
+ import { useT } from './createStudioI18n-CgvlmDkN.js';
12
+ import { ADMIN_FUNCTIONS } from './ADMIN_FUNCTION_PREFIX-DmBqMZ-z.js';
13
+ import { c as CLOUDFLARE_DURABLE_OBJECTS_URL } from './cf-links-BZfRdxSE.js';
14
+ import { g as formatBytes, f as fireAndForget, c as callOptions, e as errorMessage, a as adminRef } from './internal-BBZYexre.js';
15
+ import { l as loadRecentShards, r as recordShard } from './shard-history-DyebH1R5.js';
16
+ import { u as useLiveShardSeed } from './use-live-shard-seed-B74RYcOy.js';
17
+ import { aggregateMetrics, computeLatencyPercentiles, enrichQueryStats, shardsToAggregate } from './aggregateMetrics-D4nUHEKU.js';
18
+ import { B as Badge } from './badge-B2PKA1-5.js';
19
+ import { Select as Select$1 } from '@base-ui/react/select';
20
+ import { c as cn } from './utils-B05Dmz_H.js';
21
+ import { HugeiconsIcon } from '@hugeicons/react';
22
+ import { UnfoldMoreIcon, Tick02Icon, ArrowUp01Icon, ArrowDown01Icon } from '@hugeicons/core-free-icons';
23
+ import { jsxDEV, Fragment } from 'react/jsx-dev-runtime';
24
+ import { S as Sparkline } from './sparkline-10dG-_f0.js';
25
+
26
+ const Select = Select$1.Root;
27
+ function SelectValue(t0) {
28
+ const $ = c(8);
29
+ let className;
30
+ let props;
31
+ if ($[0] !== t0) {
32
+ ({
33
+ className,
34
+ ...props
35
+ } = t0);
36
+ $[0] = t0;
37
+ $[1] = className;
38
+ $[2] = props;
39
+ } else {
40
+ className = $[1];
41
+ props = $[2];
42
+ }
43
+ let t1;
44
+ if ($[3] !== className) {
45
+ t1 = cn("flex flex-1 text-start", className);
46
+ $[3] = className;
47
+ $[4] = t1;
48
+ } else {
49
+ t1 = $[4];
50
+ }
51
+ let t2;
52
+ if ($[5] !== props || $[6] !== t1) {
53
+ t2 = /* @__PURE__ */ jsxDEV(Select$1.Value, {
54
+ "data-slot": "select-value",
55
+ className: t1,
56
+ ...props
57
+ }, void 0, false);
58
+ $[5] = props;
59
+ $[6] = t1;
60
+ $[7] = t2;
61
+ } else {
62
+ t2 = $[7];
63
+ }
64
+ return t2;
65
+ }
66
+ function SelectTrigger({
67
+ className,
68
+ size = "default",
69
+ children,
70
+ ...props
71
+ }) {
72
+ return /* @__PURE__ */ jsxDEV(Select$1.Trigger, {
73
+ "data-slot": "select-trigger",
74
+ "data-size": size,
75
+ className: cn("flex w-fit items-center justify-between gap-1.5 rounded-md border border-input bg-transparent py-2 pe-2 ps-2.5 text-xs whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-md *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
76
+ ...props,
77
+ children: [children, /* @__PURE__ */ jsxDEV(Select$1.Icon, {
78
+ render: /* @__PURE__ */ jsxDEV(HugeiconsIcon, {
79
+ icon: UnfoldMoreIcon,
80
+ strokeWidth: 2,
81
+ className: "pointer-events-none size-4 text-muted-foreground"
82
+ }, void 0, false)
83
+ }, void 0, false)]
84
+ }, void 0, true);
85
+ }
86
+ function SelectContent({
87
+ className,
88
+ children,
89
+ side = "bottom",
90
+ sideOffset = 4,
91
+ align = "center",
92
+ alignOffset = 0,
93
+ alignItemWithTrigger = true,
94
+ ...props
95
+ }) {
96
+ return /* @__PURE__ */ jsxDEV(Select$1.Portal, {
97
+ children: /* @__PURE__ */ jsxDEV(Select$1.Positioner, {
98
+ side,
99
+ sideOffset,
100
+ align,
101
+ alignOffset,
102
+ alignItemWithTrigger,
103
+ className: "isolate z-50",
104
+ children: /* @__PURE__ */ jsxDEV(Select$1.Popup, {
105
+ "data-slot": "select-content",
106
+ "data-align-trigger": alignItemWithTrigger,
107
+ className: cn("isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 animate-none! relative bg-popover before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:rounded-[inherit] **:data-[slot$=-item]:focus:bg-foreground/10 **:data-[slot$=-item]:data-highlighted:bg-foreground/10 **:data-[slot$=-separator]:bg-foreground/5 **:data-[slot$=-trigger]:focus:bg-foreground/10 **:data-[slot$=-trigger]:aria-expanded:bg-foreground/10! **:data-[variant=destructive]:focus:bg-foreground/10! **:data-[variant=destructive]:text-accent-foreground! **:data-[variant=destructive]:**:text-accent-foreground!", className),
108
+ ...props,
109
+ children: [/* @__PURE__ */ jsxDEV(SelectScrollUpButton, {}, void 0, false), /* @__PURE__ */ jsxDEV(Select$1.List, {
110
+ children
111
+ }, void 0, false), /* @__PURE__ */ jsxDEV(SelectScrollDownButton, {}, void 0, false)]
112
+ }, void 0, true)
113
+ }, void 0, false)
114
+ }, void 0, false);
115
+ }
116
+ function SelectItem(t0) {
117
+ const $ = c(13);
118
+ let children;
119
+ let className;
120
+ let props;
121
+ if ($[0] !== t0) {
122
+ ({
123
+ className,
124
+ children,
125
+ ...props
126
+ } = t0);
127
+ $[0] = t0;
128
+ $[1] = children;
129
+ $[2] = className;
130
+ $[3] = props;
131
+ } else {
132
+ children = $[1];
133
+ className = $[2];
134
+ props = $[3];
135
+ }
136
+ let t1;
137
+ if ($[4] !== className) {
138
+ t1 = cn("relative flex w-full cursor-default items-center gap-2 rounded-md py-2 pe-8 ps-2 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className);
139
+ $[4] = className;
140
+ $[5] = t1;
141
+ } else {
142
+ t1 = $[5];
143
+ }
144
+ let t2;
145
+ if ($[6] !== children) {
146
+ t2 = /* @__PURE__ */ jsxDEV(Select$1.ItemText, {
147
+ className: "flex flex-1 shrink-0 gap-2 whitespace-nowrap",
148
+ children
149
+ }, void 0, false);
150
+ $[6] = children;
151
+ $[7] = t2;
152
+ } else {
153
+ t2 = $[7];
154
+ }
155
+ let t3;
156
+ if ($[8] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
157
+ t3 = /* @__PURE__ */ jsxDEV(Select$1.ItemIndicator, {
158
+ render: /* @__PURE__ */ jsxDEV("span", {
159
+ className: "pointer-events-none absolute end-2 flex size-4 items-center justify-center"
160
+ }, void 0, false),
161
+ children: /* @__PURE__ */ jsxDEV(HugeiconsIcon, {
162
+ icon: Tick02Icon,
163
+ strokeWidth: 2,
164
+ className: "pointer-events-none"
165
+ }, void 0, false)
166
+ }, void 0, false);
167
+ $[8] = t3;
168
+ } else {
169
+ t3 = $[8];
170
+ }
171
+ let t4;
172
+ if ($[9] !== props || $[10] !== t1 || $[11] !== t2) {
173
+ t4 = /* @__PURE__ */ jsxDEV(Select$1.Item, {
174
+ "data-slot": "select-item",
175
+ className: t1,
176
+ ...props,
177
+ children: [t2, t3]
178
+ }, void 0, true);
179
+ $[9] = props;
180
+ $[10] = t1;
181
+ $[11] = t2;
182
+ $[12] = t4;
183
+ } else {
184
+ t4 = $[12];
185
+ }
186
+ return t4;
187
+ }
188
+ function SelectScrollUpButton(t0) {
189
+ const $ = c(9);
190
+ let className;
191
+ let props;
192
+ if ($[0] !== t0) {
193
+ ({
194
+ className,
195
+ ...props
196
+ } = t0);
197
+ $[0] = t0;
198
+ $[1] = className;
199
+ $[2] = props;
200
+ } else {
201
+ className = $[1];
202
+ props = $[2];
203
+ }
204
+ let t1;
205
+ if ($[3] !== className) {
206
+ t1 = cn("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4", className);
207
+ $[3] = className;
208
+ $[4] = t1;
209
+ } else {
210
+ t1 = $[4];
211
+ }
212
+ let t2;
213
+ if ($[5] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
214
+ t2 = /* @__PURE__ */ jsxDEV(HugeiconsIcon, {
215
+ icon: ArrowUp01Icon,
216
+ strokeWidth: 2
217
+ }, void 0, false);
218
+ $[5] = t2;
219
+ } else {
220
+ t2 = $[5];
221
+ }
222
+ let t3;
223
+ if ($[6] !== props || $[7] !== t1) {
224
+ t3 = /* @__PURE__ */ jsxDEV(Select$1.ScrollUpArrow, {
225
+ "data-slot": "select-scroll-up-button",
226
+ className: t1,
227
+ ...props,
228
+ children: t2
229
+ }, void 0, false);
230
+ $[6] = props;
231
+ $[7] = t1;
232
+ $[8] = t3;
233
+ } else {
234
+ t3 = $[8];
235
+ }
236
+ return t3;
237
+ }
238
+ function SelectScrollDownButton(t0) {
239
+ const $ = c(9);
240
+ let className;
241
+ let props;
242
+ if ($[0] !== t0) {
243
+ ({
244
+ className,
245
+ ...props
246
+ } = t0);
247
+ $[0] = t0;
248
+ $[1] = className;
249
+ $[2] = props;
250
+ } else {
251
+ className = $[1];
252
+ props = $[2];
253
+ }
254
+ let t1;
255
+ if ($[3] !== className) {
256
+ t1 = cn("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4", className);
257
+ $[3] = className;
258
+ $[4] = t1;
259
+ } else {
260
+ t1 = $[4];
261
+ }
262
+ let t2;
263
+ if ($[5] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
264
+ t2 = /* @__PURE__ */ jsxDEV(HugeiconsIcon, {
265
+ icon: ArrowDown01Icon,
266
+ strokeWidth: 2
267
+ }, void 0, false);
268
+ $[5] = t2;
269
+ } else {
270
+ t2 = $[5];
271
+ }
272
+ let t3;
273
+ if ($[6] !== props || $[7] !== t1) {
274
+ t3 = /* @__PURE__ */ jsxDEV(Select$1.ScrollDownArrow, {
275
+ "data-slot": "select-scroll-down-button",
276
+ className: t1,
277
+ ...props,
278
+ children: t2
279
+ }, void 0, false);
280
+ $[6] = props;
281
+ $[7] = t1;
282
+ $[8] = t3;
283
+ } else {
284
+ t3 = $[8];
285
+ }
286
+ return t3;
287
+ }
288
+
289
+ const performanceLevel = (avgMs) => {
290
+ if (avgMs >= 100) {
291
+ return "critical";
292
+ }
293
+ if (avgMs >= 50) {
294
+ return "warning";
295
+ }
296
+ return "good";
297
+ };
298
+ const formatLatency = (ms) => {
299
+ if (ms < 1) {
300
+ return `${(ms * 1e3).toFixed(0)}μs`;
301
+ }
302
+ if (ms < 1e3) {
303
+ return `${ms.toFixed(1)}ms`;
304
+ }
305
+ return `${(ms / 1e3).toFixed(2)}s`;
306
+ };
307
+ const formatCount = (n) => {
308
+ if (n >= 1e9) {
309
+ return `${(n / 1e9).toFixed(1)}B`;
310
+ }
311
+ if (n >= 1e6) {
312
+ return `${(n / 1e6).toFixed(1)}M`;
313
+ }
314
+ if (n >= 1e3) {
315
+ return `${(n / 1e3).toFixed(1)}K`;
316
+ }
317
+ return n.toLocaleString();
318
+ };
319
+ const PerformanceBadge = (t0) => {
320
+ const $ = c(3);
321
+ const {
322
+ level
323
+ } = t0;
324
+ if (level === "critical") {
325
+ let t12;
326
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
327
+ t12 = /* @__PURE__ */ jsxDEV(Badge, {
328
+ variant: "destructive",
329
+ children: "Slow"
330
+ }, void 0, false);
331
+ $[0] = t12;
332
+ } else {
333
+ t12 = $[0];
334
+ }
335
+ return t12;
336
+ }
337
+ if (level === "warning") {
338
+ let t12;
339
+ if ($[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
340
+ t12 = /* @__PURE__ */ jsxDEV("span", {
341
+ className: "inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",
342
+ children: "Moderate"
343
+ }, void 0, false);
344
+ $[1] = t12;
345
+ } else {
346
+ t12 = $[1];
347
+ }
348
+ return t12;
349
+ }
350
+ let t1;
351
+ if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
352
+ t1 = /* @__PURE__ */ jsxDEV("span", {
353
+ className: "inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",
354
+ children: "Fast"
355
+ }, void 0, false);
356
+ $[2] = t1;
357
+ } else {
358
+ t1 = $[2];
359
+ }
360
+ return t1;
361
+ };
362
+ const QueryInsights = (t0) => {
363
+ const $ = c(152);
364
+ const {
365
+ queryStats
366
+ } = t0;
367
+ const t = useT();
368
+ const [sortField, setSortField] = useState("totalTime");
369
+ let t1;
370
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
371
+ t1 = /* @__PURE__ */ new Set();
372
+ $[0] = t1;
373
+ } else {
374
+ t1 = $[0];
375
+ }
376
+ const [expanded, setExpanded] = useState(t1);
377
+ let t2;
378
+ if ($[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
379
+ t2 = (value) => {
380
+ if (value !== null) {
381
+ setSortField(value);
382
+ }
383
+ };
384
+ $[1] = t2;
385
+ } else {
386
+ t2 = $[1];
387
+ }
388
+ const handleSortChange = t2;
389
+ let copy;
390
+ if ($[2] !== queryStats || $[3] !== sortField) {
391
+ copy = [...queryStats];
392
+ let t310;
393
+ if ($[5] !== sortField) {
394
+ t310 = (a, b) => {
395
+ switch (sortField) {
396
+ case "avgTime": {
397
+ return b.avgDurationMs - a.avgDurationMs;
398
+ }
399
+ case "execCount": {
400
+ return b.execCount - a.execCount;
401
+ }
402
+ case "rowsRead": {
403
+ return b.rowsRead - a.rowsRead;
404
+ }
405
+ default: {
406
+ return b.totalDurationMs - a.totalDurationMs;
407
+ }
408
+ }
409
+ };
410
+ $[5] = sortField;
411
+ $[6] = t310;
412
+ } else {
413
+ t310 = $[6];
414
+ }
415
+ copy.sort(t310);
416
+ $[2] = queryStats;
417
+ $[3] = sortField;
418
+ $[4] = copy;
419
+ } else {
420
+ copy = $[4];
421
+ }
422
+ const sorted = copy;
423
+ let t3;
424
+ if ($[7] !== queryStats) {
425
+ t3 = queryStats.filter(_temp);
426
+ $[7] = queryStats;
427
+ $[8] = t3;
428
+ } else {
429
+ t3 = $[8];
430
+ }
431
+ const critical = t3.length;
432
+ let t4;
433
+ if ($[9] !== queryStats) {
434
+ t4 = queryStats.filter(_temp2);
435
+ $[9] = queryStats;
436
+ $[10] = t4;
437
+ } else {
438
+ t4 = $[10];
439
+ }
440
+ const moderate = t4.length;
441
+ let t5;
442
+ if ($[11] !== queryStats) {
443
+ t5 = queryStats.filter(_temp3);
444
+ $[11] = queryStats;
445
+ $[12] = t5;
446
+ } else {
447
+ t5 = $[12];
448
+ }
449
+ const fast = t5.length;
450
+ let t6;
451
+ if ($[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
452
+ t6 = (key) => {
453
+ setExpanded((previous) => {
454
+ const next = new Set(previous);
455
+ if (next.has(key)) {
456
+ next.delete(key);
457
+ } else {
458
+ next.add(key);
459
+ }
460
+ return next;
461
+ });
462
+ };
463
+ $[13] = t6;
464
+ } else {
465
+ t6 = $[13];
466
+ }
467
+ const toggleExpand = t6;
468
+ if (queryStats.length === 0) {
469
+ let t72;
470
+ if ($[14] !== t) {
471
+ t72 = t("No query insights yet");
472
+ $[14] = t;
473
+ $[15] = t72;
474
+ } else {
475
+ t72 = $[15];
476
+ }
477
+ let t82;
478
+ if ($[16] !== t72) {
479
+ t82 = /* @__PURE__ */ jsxDEV("p", {
480
+ className: "text-lg font-medium",
481
+ "data-testid": "qi-empty",
482
+ children: t72
483
+ }, void 0, false);
484
+ $[16] = t72;
485
+ $[17] = t82;
486
+ } else {
487
+ t82 = $[17];
488
+ }
489
+ let t92;
490
+ if ($[18] !== t) {
491
+ t92 = t("Query insights appear once statements are executed against this shard.");
492
+ $[18] = t;
493
+ $[19] = t92;
494
+ } else {
495
+ t92 = $[19];
496
+ }
497
+ let t102;
498
+ if ($[20] !== t92) {
499
+ t102 = /* @__PURE__ */ jsxDEV("p", {
500
+ className: "mt-1 text-sm",
501
+ children: t92
502
+ }, void 0, false);
503
+ $[20] = t92;
504
+ $[21] = t102;
505
+ } else {
506
+ t102 = $[21];
507
+ }
508
+ let t112;
509
+ if ($[22] !== t102 || $[23] !== t82) {
510
+ t112 = /* @__PURE__ */ jsxDEV(Card, {
511
+ children: /* @__PURE__ */ jsxDEV(CardContent, {
512
+ className: "py-12",
513
+ children: /* @__PURE__ */ jsxDEV("div", {
514
+ className: "text-center text-muted-foreground",
515
+ children: [t82, t102]
516
+ }, void 0, true)
517
+ }, void 0, false)
518
+ }, void 0, false);
519
+ $[22] = t102;
520
+ $[23] = t82;
521
+ $[24] = t112;
522
+ } else {
523
+ t112 = $[24];
524
+ }
525
+ return t112;
526
+ }
527
+ let t7;
528
+ if ($[25] !== t) {
529
+ t7 = t("Critical queries");
530
+ $[25] = t;
531
+ $[26] = t7;
532
+ } else {
533
+ t7 = $[26];
534
+ }
535
+ let t8;
536
+ if ($[27] !== t7) {
537
+ t8 = /* @__PURE__ */ jsxDEV(CardHeader, {
538
+ className: "pb-2",
539
+ children: /* @__PURE__ */ jsxDEV(CardTitle, {
540
+ className: "text-sm font-medium",
541
+ children: t7
542
+ }, void 0, false)
543
+ }, void 0, false);
544
+ $[27] = t7;
545
+ $[28] = t8;
546
+ } else {
547
+ t8 = $[28];
548
+ }
549
+ let t9;
550
+ if ($[29] !== critical) {
551
+ t9 = /* @__PURE__ */ jsxDEV("div", {
552
+ className: "text-2xl font-bold text-destructive",
553
+ "data-testid": "qi-critical",
554
+ children: critical
555
+ }, void 0, false);
556
+ $[29] = critical;
557
+ $[30] = t9;
558
+ } else {
559
+ t9 = $[30];
560
+ }
561
+ let t10;
562
+ if ($[31] !== t) {
563
+ t10 = t(">100ms avg execution");
564
+ $[31] = t;
565
+ $[32] = t10;
566
+ } else {
567
+ t10 = $[32];
568
+ }
569
+ let t11;
570
+ if ($[33] !== t10) {
571
+ t11 = /* @__PURE__ */ jsxDEV("p", {
572
+ className: "text-xs text-muted-foreground",
573
+ children: t10
574
+ }, void 0, false);
575
+ $[33] = t10;
576
+ $[34] = t11;
577
+ } else {
578
+ t11 = $[34];
579
+ }
580
+ let t12;
581
+ if ($[35] !== t11 || $[36] !== t9) {
582
+ t12 = /* @__PURE__ */ jsxDEV(CardContent, {
583
+ children: [t9, t11]
584
+ }, void 0, true);
585
+ $[35] = t11;
586
+ $[36] = t9;
587
+ $[37] = t12;
588
+ } else {
589
+ t12 = $[37];
590
+ }
591
+ let t13;
592
+ if ($[38] !== t12 || $[39] !== t8) {
593
+ t13 = /* @__PURE__ */ jsxDEV(Card, {
594
+ children: [t8, t12]
595
+ }, void 0, true);
596
+ $[38] = t12;
597
+ $[39] = t8;
598
+ $[40] = t13;
599
+ } else {
600
+ t13 = $[40];
601
+ }
602
+ let t14;
603
+ if ($[41] !== t) {
604
+ t14 = t("Moderate queries");
605
+ $[41] = t;
606
+ $[42] = t14;
607
+ } else {
608
+ t14 = $[42];
609
+ }
610
+ let t15;
611
+ if ($[43] !== t14) {
612
+ t15 = /* @__PURE__ */ jsxDEV(CardHeader, {
613
+ className: "pb-2",
614
+ children: /* @__PURE__ */ jsxDEV(CardTitle, {
615
+ className: "text-sm font-medium",
616
+ children: t14
617
+ }, void 0, false)
618
+ }, void 0, false);
619
+ $[43] = t14;
620
+ $[44] = t15;
621
+ } else {
622
+ t15 = $[44];
623
+ }
624
+ let t16;
625
+ if ($[45] !== moderate) {
626
+ t16 = /* @__PURE__ */ jsxDEV("div", {
627
+ className: "text-2xl font-bold text-warning",
628
+ "data-testid": "qi-moderate",
629
+ children: moderate
630
+ }, void 0, false);
631
+ $[45] = moderate;
632
+ $[46] = t16;
633
+ } else {
634
+ t16 = $[46];
635
+ }
636
+ let t17;
637
+ if ($[47] !== t) {
638
+ t17 = t("50–100ms avg execution");
639
+ $[47] = t;
640
+ $[48] = t17;
641
+ } else {
642
+ t17 = $[48];
643
+ }
644
+ let t18;
645
+ if ($[49] !== t17) {
646
+ t18 = /* @__PURE__ */ jsxDEV("p", {
647
+ className: "text-xs text-muted-foreground",
648
+ children: t17
649
+ }, void 0, false);
650
+ $[49] = t17;
651
+ $[50] = t18;
652
+ } else {
653
+ t18 = $[50];
654
+ }
655
+ let t19;
656
+ if ($[51] !== t16 || $[52] !== t18) {
657
+ t19 = /* @__PURE__ */ jsxDEV(CardContent, {
658
+ children: [t16, t18]
659
+ }, void 0, true);
660
+ $[51] = t16;
661
+ $[52] = t18;
662
+ $[53] = t19;
663
+ } else {
664
+ t19 = $[53];
665
+ }
666
+ let t20;
667
+ if ($[54] !== t15 || $[55] !== t19) {
668
+ t20 = /* @__PURE__ */ jsxDEV(Card, {
669
+ children: [t15, t19]
670
+ }, void 0, true);
671
+ $[54] = t15;
672
+ $[55] = t19;
673
+ $[56] = t20;
674
+ } else {
675
+ t20 = $[56];
676
+ }
677
+ let t21;
678
+ if ($[57] !== t) {
679
+ t21 = t("Fast queries");
680
+ $[57] = t;
681
+ $[58] = t21;
682
+ } else {
683
+ t21 = $[58];
684
+ }
685
+ let t22;
686
+ if ($[59] !== t21) {
687
+ t22 = /* @__PURE__ */ jsxDEV(CardHeader, {
688
+ className: "pb-2",
689
+ children: /* @__PURE__ */ jsxDEV(CardTitle, {
690
+ className: "text-sm font-medium",
691
+ children: t21
692
+ }, void 0, false)
693
+ }, void 0, false);
694
+ $[59] = t21;
695
+ $[60] = t22;
696
+ } else {
697
+ t22 = $[60];
698
+ }
699
+ let t23;
700
+ if ($[61] !== fast) {
701
+ t23 = /* @__PURE__ */ jsxDEV("div", {
702
+ className: "text-2xl font-bold text-success",
703
+ "data-testid": "qi-fast",
704
+ children: fast
705
+ }, void 0, false);
706
+ $[61] = fast;
707
+ $[62] = t23;
708
+ } else {
709
+ t23 = $[62];
710
+ }
711
+ let t24;
712
+ if ($[63] !== t) {
713
+ t24 = t("<50ms avg execution");
714
+ $[63] = t;
715
+ $[64] = t24;
716
+ } else {
717
+ t24 = $[64];
718
+ }
719
+ let t25;
720
+ if ($[65] !== t24) {
721
+ t25 = /* @__PURE__ */ jsxDEV("p", {
722
+ className: "text-xs text-muted-foreground",
723
+ children: t24
724
+ }, void 0, false);
725
+ $[65] = t24;
726
+ $[66] = t25;
727
+ } else {
728
+ t25 = $[66];
729
+ }
730
+ let t26;
731
+ if ($[67] !== t23 || $[68] !== t25) {
732
+ t26 = /* @__PURE__ */ jsxDEV(CardContent, {
733
+ children: [t23, t25]
734
+ }, void 0, true);
735
+ $[67] = t23;
736
+ $[68] = t25;
737
+ $[69] = t26;
738
+ } else {
739
+ t26 = $[69];
740
+ }
741
+ let t27;
742
+ if ($[70] !== t22 || $[71] !== t26) {
743
+ t27 = /* @__PURE__ */ jsxDEV(Card, {
744
+ children: [t22, t26]
745
+ }, void 0, true);
746
+ $[70] = t22;
747
+ $[71] = t26;
748
+ $[72] = t27;
749
+ } else {
750
+ t27 = $[72];
751
+ }
752
+ let t28;
753
+ if ($[73] !== t13 || $[74] !== t20 || $[75] !== t27) {
754
+ t28 = /* @__PURE__ */ jsxDEV("div", {
755
+ className: "grid gap-4 md:grid-cols-3",
756
+ children: [t13, t20, t27]
757
+ }, void 0, true);
758
+ $[73] = t13;
759
+ $[74] = t20;
760
+ $[75] = t27;
761
+ $[76] = t28;
762
+ } else {
763
+ t28 = $[76];
764
+ }
765
+ let t29;
766
+ if ($[77] !== t) {
767
+ t29 = t("Query leaderboard");
768
+ $[77] = t;
769
+ $[78] = t29;
770
+ } else {
771
+ t29 = $[78];
772
+ }
773
+ let t30;
774
+ if ($[79] !== t29) {
775
+ t30 = /* @__PURE__ */ jsxDEV("h3", {
776
+ className: "text-lg font-semibold",
777
+ children: t29
778
+ }, void 0, false);
779
+ $[79] = t29;
780
+ $[80] = t30;
781
+ } else {
782
+ t30 = $[80];
783
+ }
784
+ let t31;
785
+ if ($[81] !== sortField || $[82] !== t) {
786
+ t31 = t("Slow queries sorted by {sortField}", {
787
+ sortField: t(sortField)
788
+ });
789
+ $[81] = sortField;
790
+ $[82] = t;
791
+ $[83] = t31;
792
+ } else {
793
+ t31 = $[83];
794
+ }
795
+ let t32;
796
+ if ($[84] !== t31) {
797
+ t32 = /* @__PURE__ */ jsxDEV("p", {
798
+ className: "text-sm text-muted-foreground",
799
+ children: t31
800
+ }, void 0, false);
801
+ $[84] = t31;
802
+ $[85] = t32;
803
+ } else {
804
+ t32 = $[85];
805
+ }
806
+ let t33;
807
+ if ($[86] !== t30 || $[87] !== t32) {
808
+ t33 = /* @__PURE__ */ jsxDEV("div", {
809
+ children: [t30, t32]
810
+ }, void 0, true);
811
+ $[86] = t30;
812
+ $[87] = t32;
813
+ $[88] = t33;
814
+ } else {
815
+ t33 = $[88];
816
+ }
817
+ let t34;
818
+ if ($[89] !== t) {
819
+ t34 = t("Sort by");
820
+ $[89] = t;
821
+ $[90] = t34;
822
+ } else {
823
+ t34 = $[90];
824
+ }
825
+ let t35;
826
+ if ($[91] !== t34) {
827
+ t35 = /* @__PURE__ */ jsxDEV("span", {
828
+ className: "text-sm text-muted-foreground",
829
+ children: t34
830
+ }, void 0, false);
831
+ $[91] = t34;
832
+ $[92] = t35;
833
+ } else {
834
+ t35 = $[92];
835
+ }
836
+ let t36;
837
+ if ($[93] !== t) {
838
+ t36 = t("Sort queries by");
839
+ $[93] = t;
840
+ $[94] = t36;
841
+ } else {
842
+ t36 = $[94];
843
+ }
844
+ let t37;
845
+ if ($[95] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
846
+ t37 = /* @__PURE__ */ jsxDEV(SelectValue, {}, void 0, false);
847
+ $[95] = t37;
848
+ } else {
849
+ t37 = $[95];
850
+ }
851
+ let t38;
852
+ if ($[96] !== t36) {
853
+ t38 = /* @__PURE__ */ jsxDEV(SelectTrigger, {
854
+ "aria-label": t36,
855
+ className: "w-[140px]",
856
+ "data-testid": "qi-sort",
857
+ children: t37
858
+ }, void 0, false);
859
+ $[96] = t36;
860
+ $[97] = t38;
861
+ } else {
862
+ t38 = $[97];
863
+ }
864
+ let t39;
865
+ if ($[98] !== t) {
866
+ t39 = t("Total time");
867
+ $[98] = t;
868
+ $[99] = t39;
869
+ } else {
870
+ t39 = $[99];
871
+ }
872
+ let t40;
873
+ if ($[100] !== t39) {
874
+ t40 = /* @__PURE__ */ jsxDEV(SelectItem, {
875
+ value: "totalTime",
876
+ children: t39
877
+ }, void 0, false);
878
+ $[100] = t39;
879
+ $[101] = t40;
880
+ } else {
881
+ t40 = $[101];
882
+ }
883
+ let t41;
884
+ if ($[102] !== t) {
885
+ t41 = t("Avg time");
886
+ $[102] = t;
887
+ $[103] = t41;
888
+ } else {
889
+ t41 = $[103];
890
+ }
891
+ let t42;
892
+ if ($[104] !== t41) {
893
+ t42 = /* @__PURE__ */ jsxDEV(SelectItem, {
894
+ value: "avgTime",
895
+ children: t41
896
+ }, void 0, false);
897
+ $[104] = t41;
898
+ $[105] = t42;
899
+ } else {
900
+ t42 = $[105];
901
+ }
902
+ let t43;
903
+ if ($[106] !== t) {
904
+ t43 = t("Execution count");
905
+ $[106] = t;
906
+ $[107] = t43;
907
+ } else {
908
+ t43 = $[107];
909
+ }
910
+ let t44;
911
+ if ($[108] !== t43) {
912
+ t44 = /* @__PURE__ */ jsxDEV(SelectItem, {
913
+ value: "execCount",
914
+ children: t43
915
+ }, void 0, false);
916
+ $[108] = t43;
917
+ $[109] = t44;
918
+ } else {
919
+ t44 = $[109];
920
+ }
921
+ let t45;
922
+ if ($[110] !== t) {
923
+ t45 = t("Rows read");
924
+ $[110] = t;
925
+ $[111] = t45;
926
+ } else {
927
+ t45 = $[111];
928
+ }
929
+ let t46;
930
+ if ($[112] !== t45) {
931
+ t46 = /* @__PURE__ */ jsxDEV(SelectItem, {
932
+ value: "rowsRead",
933
+ children: t45
934
+ }, void 0, false);
935
+ $[112] = t45;
936
+ $[113] = t46;
937
+ } else {
938
+ t46 = $[113];
939
+ }
940
+ let t47;
941
+ if ($[114] !== t40 || $[115] !== t42 || $[116] !== t44 || $[117] !== t46) {
942
+ t47 = /* @__PURE__ */ jsxDEV(SelectContent, {
943
+ children: [t40, t42, t44, t46]
944
+ }, void 0, true);
945
+ $[114] = t40;
946
+ $[115] = t42;
947
+ $[116] = t44;
948
+ $[117] = t46;
949
+ $[118] = t47;
950
+ } else {
951
+ t47 = $[118];
952
+ }
953
+ let t48;
954
+ if ($[119] !== sortField || $[120] !== t38 || $[121] !== t47) {
955
+ t48 = /* @__PURE__ */ jsxDEV(Select, {
956
+ onValueChange: handleSortChange,
957
+ value: sortField,
958
+ children: [t38, t47]
959
+ }, void 0, true);
960
+ $[119] = sortField;
961
+ $[120] = t38;
962
+ $[121] = t47;
963
+ $[122] = t48;
964
+ } else {
965
+ t48 = $[122];
966
+ }
967
+ let t49;
968
+ if ($[123] !== t35 || $[124] !== t48) {
969
+ t49 = /* @__PURE__ */ jsxDEV("div", {
970
+ className: "flex items-center gap-2",
971
+ children: [t35, t48]
972
+ }, void 0, true);
973
+ $[123] = t35;
974
+ $[124] = t48;
975
+ $[125] = t49;
976
+ } else {
977
+ t49 = $[125];
978
+ }
979
+ let t50;
980
+ if ($[126] !== t33 || $[127] !== t49) {
981
+ t50 = /* @__PURE__ */ jsxDEV("div", {
982
+ className: "flex items-center justify-between",
983
+ children: [t33, t49]
984
+ }, void 0, true);
985
+ $[126] = t33;
986
+ $[127] = t49;
987
+ $[128] = t50;
988
+ } else {
989
+ t50 = $[128];
990
+ }
991
+ let t51;
992
+ if ($[129] !== t) {
993
+ t51 = t("Statements");
994
+ $[129] = t;
995
+ $[130] = t51;
996
+ } else {
997
+ t51 = $[130];
998
+ }
999
+ let t52;
1000
+ if ($[131] !== t51) {
1001
+ t52 = /* @__PURE__ */ jsxDEV(CardTitle, {
1002
+ children: t51
1003
+ }, void 0, false);
1004
+ $[131] = t51;
1005
+ $[132] = t52;
1006
+ } else {
1007
+ t52 = $[132];
1008
+ }
1009
+ let t53;
1010
+ if ($[133] !== sorted.length || $[134] !== t) {
1011
+ t53 = t("{count} tracked statements", {
1012
+ count: sorted.length
1013
+ });
1014
+ $[133] = sorted.length;
1015
+ $[134] = t;
1016
+ $[135] = t53;
1017
+ } else {
1018
+ t53 = $[135];
1019
+ }
1020
+ let t54;
1021
+ if ($[136] !== t53) {
1022
+ t54 = /* @__PURE__ */ jsxDEV(CardDescription, {
1023
+ children: t53
1024
+ }, void 0, false);
1025
+ $[136] = t53;
1026
+ $[137] = t54;
1027
+ } else {
1028
+ t54 = $[137];
1029
+ }
1030
+ let t55;
1031
+ if ($[138] !== t52 || $[139] !== t54) {
1032
+ t55 = /* @__PURE__ */ jsxDEV(CardHeader, {
1033
+ children: [t52, t54]
1034
+ }, void 0, true);
1035
+ $[138] = t52;
1036
+ $[139] = t54;
1037
+ $[140] = t55;
1038
+ } else {
1039
+ t55 = $[140];
1040
+ }
1041
+ let t56;
1042
+ if ($[141] !== expanded || $[142] !== sorted || $[143] !== t) {
1043
+ t56 = /* @__PURE__ */ jsxDEV(CardContent, {
1044
+ children: /* @__PURE__ */ jsxDEV("div", {
1045
+ className: "space-y-2",
1046
+ children: sorted.map((stat) => {
1047
+ const key_0 = stat.normalizedSql;
1048
+ const isExpanded = expanded.has(key_0);
1049
+ const level = performanceLevel(stat.avgDurationMs);
1050
+ return /* @__PURE__ */ jsxDEV("div", {
1051
+ className: "overflow-hidden rounded-lg border",
1052
+ "data-testid": "qi-row",
1053
+ children: [/* @__PURE__ */ jsxDEV("button", {
1054
+ "aria-expanded": isExpanded,
1055
+ className: "flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",
1056
+ onClick: () => {
1057
+ toggleExpand(key_0);
1058
+ },
1059
+ type: "button",
1060
+ children: [/* @__PURE__ */ jsxDEV("div", {
1061
+ className: "flex min-w-0 flex-1 items-center gap-3",
1062
+ children: [/* @__PURE__ */ jsxDEV(PerformanceBadge, {
1063
+ level
1064
+ }, void 0, false), /* @__PURE__ */ jsxDEV("span", {
1065
+ className: "max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",
1066
+ children: stat.normalizedSql
1067
+ }, void 0, false)]
1068
+ }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
1069
+ className: "flex shrink-0 items-center gap-4",
1070
+ children: [/* @__PURE__ */ jsxDEV("div", {
1071
+ className: "text-right",
1072
+ children: [/* @__PURE__ */ jsxDEV("div", {
1073
+ className: "text-sm font-medium",
1074
+ children: formatLatency(stat.totalDurationMs)
1075
+ }, void 0, false), /* @__PURE__ */ jsxDEV("div", {
1076
+ className: "text-xs text-muted-foreground",
1077
+ children: t("total")
1078
+ }, void 0, false)]
1079
+ }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
1080
+ className: "text-right",
1081
+ children: [/* @__PURE__ */ jsxDEV("div", {
1082
+ className: "text-sm font-medium",
1083
+ children: formatLatency(stat.avgDurationMs)
1084
+ }, void 0, false), /* @__PURE__ */ jsxDEV("div", {
1085
+ className: "text-xs text-muted-foreground",
1086
+ children: t("avg")
1087
+ }, void 0, false)]
1088
+ }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
1089
+ className: "text-right",
1090
+ children: [/* @__PURE__ */ jsxDEV("div", {
1091
+ className: "text-sm font-medium",
1092
+ children: formatCount(stat.execCount)
1093
+ }, void 0, false), /* @__PURE__ */ jsxDEV("div", {
1094
+ className: "text-xs text-muted-foreground",
1095
+ children: t("calls")
1096
+ }, void 0, false)]
1097
+ }, void 0, true)]
1098
+ }, void 0, true)]
1099
+ }, void 0, true), isExpanded && /* @__PURE__ */ jsxDEV("div", {
1100
+ className: "space-y-3 border-t bg-muted/30 p-4",
1101
+ children: [/* @__PURE__ */ jsxDEV("div", {
1102
+ children: [/* @__PURE__ */ jsxDEV("p", {
1103
+ className: "mb-2 text-sm font-medium",
1104
+ children: t("Full statement")
1105
+ }, void 0, false), /* @__PURE__ */ jsxDEV("pre", {
1106
+ className: "overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",
1107
+ children: stat.normalizedSql
1108
+ }, void 0, false)]
1109
+ }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
1110
+ className: "grid grid-cols-2 gap-4 text-sm md:grid-cols-4",
1111
+ children: [/* @__PURE__ */ jsxDEV("div", {
1112
+ children: [/* @__PURE__ */ jsxDEV("span", {
1113
+ className: "text-muted-foreground",
1114
+ children: t("Exec count")
1115
+ }, void 0, false), /* @__PURE__ */ jsxDEV("span", {
1116
+ className: "block font-medium tabular-nums",
1117
+ children: formatCount(stat.execCount)
1118
+ }, void 0, false)]
1119
+ }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
1120
+ children: [/* @__PURE__ */ jsxDEV("span", {
1121
+ className: "text-muted-foreground",
1122
+ children: t("Total time")
1123
+ }, void 0, false), /* @__PURE__ */ jsxDEV("span", {
1124
+ className: "block font-medium tabular-nums",
1125
+ children: formatLatency(stat.totalDurationMs)
1126
+ }, void 0, false)]
1127
+ }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
1128
+ children: [/* @__PURE__ */ jsxDEV("span", {
1129
+ className: "text-muted-foreground",
1130
+ children: t("Rows read")
1131
+ }, void 0, false), /* @__PURE__ */ jsxDEV("span", {
1132
+ className: "block font-medium tabular-nums",
1133
+ children: formatCount(stat.rowsRead)
1134
+ }, void 0, false)]
1135
+ }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
1136
+ children: [/* @__PURE__ */ jsxDEV("span", {
1137
+ className: "text-muted-foreground",
1138
+ children: t("Rows written")
1139
+ }, void 0, false), /* @__PURE__ */ jsxDEV("span", {
1140
+ className: "block font-medium tabular-nums",
1141
+ children: formatCount(stat.rowsWritten)
1142
+ }, void 0, false)]
1143
+ }, void 0, true)]
1144
+ }, void 0, true)]
1145
+ }, void 0, true)]
1146
+ }, key_0, true);
1147
+ })
1148
+ }, void 0, false)
1149
+ }, void 0, false);
1150
+ $[141] = expanded;
1151
+ $[142] = sorted;
1152
+ $[143] = t;
1153
+ $[144] = t56;
1154
+ } else {
1155
+ t56 = $[144];
1156
+ }
1157
+ let t57;
1158
+ if ($[145] !== t55 || $[146] !== t56) {
1159
+ t57 = /* @__PURE__ */ jsxDEV(Card, {
1160
+ children: [t55, t56]
1161
+ }, void 0, true);
1162
+ $[145] = t55;
1163
+ $[146] = t56;
1164
+ $[147] = t57;
1165
+ } else {
1166
+ t57 = $[147];
1167
+ }
1168
+ let t58;
1169
+ if ($[148] !== t28 || $[149] !== t50 || $[150] !== t57) {
1170
+ t58 = /* @__PURE__ */ jsxDEV("div", {
1171
+ className: "space-y-4",
1172
+ "data-testid": "qi-root",
1173
+ children: [t28, t50, t57]
1174
+ }, void 0, true);
1175
+ $[148] = t28;
1176
+ $[149] = t50;
1177
+ $[150] = t57;
1178
+ $[151] = t58;
1179
+ } else {
1180
+ t58 = $[151];
1181
+ }
1182
+ return t58;
1183
+ };
1184
+ function _temp(q) {
1185
+ return performanceLevel(q.avgDurationMs) === "critical";
1186
+ }
1187
+ function _temp2(q_0) {
1188
+ return performanceLevel(q_0.avgDurationMs) === "warning";
1189
+ }
1190
+ function _temp3(q_1) {
1191
+ return performanceLevel(q_1.avgDurationMs) === "good";
1192
+ }
1193
+
1194
+ const GET_METRICS = adminRef(ADMIN_FUNCTIONS.getMetrics);
1195
+ const formatDuration = (ms) => {
1196
+ const totalSeconds = Math.floor(ms / 1e3);
1197
+ const hours = Math.floor(totalSeconds / 3600);
1198
+ const minutes = Math.floor(totalSeconds % 3600 / 60);
1199
+ const seconds = totalSeconds % 60;
1200
+ if (hours > 0) {
1201
+ return `${hours.toString()}h ${minutes.toString()}m`;
1202
+ }
1203
+ if (minutes > 0) {
1204
+ return `${minutes.toString()}m ${seconds.toString()}s`;
1205
+ }
1206
+ return `${seconds.toString()}s`;
1207
+ };
1208
+ const hitRate = (hits, misses) => {
1209
+ const total = hits + misses;
1210
+ return total === 0 ? "—" : `${(hits / total * 100).toFixed(1)}%`;
1211
+ };
1212
+ const StatCard = (t0) => {
1213
+ const $ = c(16);
1214
+ const {
1215
+ chart,
1216
+ footer,
1217
+ label,
1218
+ testId,
1219
+ value
1220
+ } = t0;
1221
+ let t1;
1222
+ if ($[0] !== label) {
1223
+ t1 = /* @__PURE__ */ jsxDEV("span", {
1224
+ className: "font-mono text-[11px] tracking-wide text-muted-foreground uppercase",
1225
+ children: label
1226
+ }, void 0, false);
1227
+ $[0] = label;
1228
+ $[1] = t1;
1229
+ } else {
1230
+ t1 = $[1];
1231
+ }
1232
+ let t2;
1233
+ if ($[2] !== testId || $[3] !== value) {
1234
+ t2 = /* @__PURE__ */ jsxDEV("span", {
1235
+ className: "truncate text-2xl font-semibold tabular-nums text-foreground",
1236
+ "data-testid": testId,
1237
+ children: value
1238
+ }, void 0, false);
1239
+ $[2] = testId;
1240
+ $[3] = value;
1241
+ $[4] = t2;
1242
+ } else {
1243
+ t2 = $[4];
1244
+ }
1245
+ let t3;
1246
+ if ($[5] !== chart || $[6] !== t2) {
1247
+ t3 = /* @__PURE__ */ jsxDEV("div", {
1248
+ className: "flex items-center justify-between gap-3",
1249
+ children: [t2, chart]
1250
+ }, void 0, true);
1251
+ $[5] = chart;
1252
+ $[6] = t2;
1253
+ $[7] = t3;
1254
+ } else {
1255
+ t3 = $[7];
1256
+ }
1257
+ let t4;
1258
+ if ($[8] !== t1 || $[9] !== t3) {
1259
+ t4 = /* @__PURE__ */ jsxDEV("div", {
1260
+ className: "flex flex-col gap-2.5 p-4",
1261
+ children: [t1, t3]
1262
+ }, void 0, true);
1263
+ $[8] = t1;
1264
+ $[9] = t3;
1265
+ $[10] = t4;
1266
+ } else {
1267
+ t4 = $[10];
1268
+ }
1269
+ let t5;
1270
+ if ($[11] !== footer) {
1271
+ t5 = footer != null && /* @__PURE__ */ jsxDEV("div", {
1272
+ className: "border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",
1273
+ children: footer
1274
+ }, void 0, false);
1275
+ $[11] = footer;
1276
+ $[12] = t5;
1277
+ } else {
1278
+ t5 = $[12];
1279
+ }
1280
+ let t6;
1281
+ if ($[13] !== t4 || $[14] !== t5) {
1282
+ t6 = /* @__PURE__ */ jsxDEV(Card, {
1283
+ className: "justify-between gap-0 py-0",
1284
+ children: [t4, t5]
1285
+ }, void 0, true);
1286
+ $[13] = t4;
1287
+ $[14] = t5;
1288
+ $[15] = t6;
1289
+ } else {
1290
+ t6 = $[15];
1291
+ }
1292
+ return t6;
1293
+ };
1294
+ const MetricsPanel = ({
1295
+ initialShardKey
1296
+ }) => {
1297
+ const client = useLunora();
1298
+ const t = useT();
1299
+ const [shardKey, setShardKey] = useState(initialShardKey ?? "");
1300
+ const [metrics, setMetrics] = useState(null);
1301
+ const [error, setError] = useState(null);
1302
+ const [activeTab, setActiveTab] = useState("overview");
1303
+ const [liveError, setLiveError] = useState(void 0);
1304
+ const [history, setHistory] = useState([]);
1305
+ const mountedRef = useRef(true);
1306
+ const lastRequestsRef = useRef(null);
1307
+ const lastShardRef = useRef(null);
1308
+ useEffect(() => {
1309
+ mountedRef.current = true;
1310
+ return () => {
1311
+ mountedRef.current = false;
1312
+ };
1313
+ }, []);
1314
+ const applySample = (next) => {
1315
+ setError(null);
1316
+ setLiveError(void 0);
1317
+ setMetrics(next);
1318
+ const previous = lastRequestsRef.current;
1319
+ const shardChanged = lastShardRef.current !== null && lastShardRef.current !== next.shard;
1320
+ lastShardRef.current = next.shard;
1321
+ lastRequestsRef.current = next.requests;
1322
+ if (shardChanged) {
1323
+ setHistory([]);
1324
+ return;
1325
+ }
1326
+ if (previous !== null && next.requests >= previous) {
1327
+ setHistory((prior) => [...prior, next.requests - previous].slice(-30));
1328
+ }
1329
+ };
1330
+ const refresh = async (shard) => {
1331
+ try {
1332
+ const next_0 = await client.query(GET_METRICS, {}, callOptions(shard));
1333
+ recordShard(shard);
1334
+ if (mountedRef.current) {
1335
+ applySample(next_0);
1336
+ }
1337
+ } catch (error_) {
1338
+ if (mountedRef.current) {
1339
+ setMetrics(null);
1340
+ setError(errorMessage(error_));
1341
+ }
1342
+ throw error_;
1343
+ }
1344
+ };
1345
+ const committedShard = useLiveShardSeed(shardKey, refresh);
1346
+ useLiveAdmin(ADMIN_FUNCTIONS.getMetrics, {}, committedShard ?? "", (next_1) => {
1347
+ if (mountedRef.current) {
1348
+ applySample(next_1);
1349
+ }
1350
+ }, committedShard !== void 0, (message) => {
1351
+ if (mountedRef.current) {
1352
+ setLiveError(message);
1353
+ }
1354
+ });
1355
+ const [shardResults, setShardResults] = useState(null);
1356
+ const [aggregating, setAggregating] = useState(false);
1357
+ const aggregateAll = async () => {
1358
+ setAggregating(true);
1359
+ const shards = shardsToAggregate(shardKey, loadRecentShards());
1360
+ try {
1361
+ const results = await Promise.all(shards.map(async (shard) => {
1362
+ try {
1363
+ const snapshot = await client.query(GET_METRICS, {}, callOptions(shard));
1364
+ return {
1365
+ error: null,
1366
+ metrics: snapshot,
1367
+ shard: shard === "" ? snapshot.shard : shard
1368
+ };
1369
+ } catch (error_) {
1370
+ return {
1371
+ error: errorMessage(error_),
1372
+ metrics: null,
1373
+ shard: shard === "" ? "__root__" : shard
1374
+ };
1375
+ }
1376
+ }));
1377
+ if (mountedRef.current) {
1378
+ setShardResults(results);
1379
+ }
1380
+ } finally {
1381
+ if (mountedRef.current) {
1382
+ setAggregating(false);
1383
+ }
1384
+ }
1385
+ };
1386
+ const aggregate = shardResults === null ? null : aggregateMetrics(shardResults);
1387
+ const errorRate = metrics === null || metrics.requests === 0 ? "—" : `${(metrics.errors / metrics.requests * 100).toFixed(1)}%`;
1388
+ const currentDelta = history.length > 0 ? history.at(-1) : 0;
1389
+ const latencyPercentiles = metrics ? computeLatencyPercentiles(metrics) : {
1390
+ p90: 0,
1391
+ p95: 0
1392
+ };
1393
+ const formatMs = (ms) => {
1394
+ if (ms <= 0) {
1395
+ return "—";
1396
+ }
1397
+ if (ms < 1) {
1398
+ return `${(ms * 1e3).toFixed(0)}μs`;
1399
+ }
1400
+ if (ms < 1e3) {
1401
+ return `${ms.toFixed(1)}ms`;
1402
+ }
1403
+ return `${(ms / 1e3).toFixed(2)}s`;
1404
+ };
1405
+ const queryStats = useMemo(() => {
1406
+ if (!metrics || !("queryStats" in metrics)) {
1407
+ return void 0;
1408
+ }
1409
+ const snapQs = metrics.queryStats;
1410
+ if (!snapQs || !Array.isArray(snapQs)) {
1411
+ return void 0;
1412
+ }
1413
+ return enrichQueryStats(snapQs);
1414
+ }, [metrics]);
1415
+ const runAggregate = () => {
1416
+ fireAndForget(aggregateAll());
1417
+ };
1418
+ const clearAggregate = () => {
1419
+ setShardResults(null);
1420
+ };
1421
+ const switchToOverview = () => {
1422
+ setActiveTab("overview");
1423
+ };
1424
+ const switchToQueryInsights = () => {
1425
+ setActiveTab("query-insights");
1426
+ };
1427
+ return /* @__PURE__ */ jsxDEV("div", {
1428
+ className: "flex flex-col gap-4",
1429
+ "data-testid": "lunora-metrics",
1430
+ children: [/* @__PURE__ */ jsxDEV("div", {
1431
+ className: "flex flex-wrap items-center gap-2",
1432
+ children: [/* @__PURE__ */ jsxDEV(ShardInput, {
1433
+ onChange: setShardKey,
1434
+ testId: "mt-shard-input",
1435
+ value: shardKey
1436
+ }, void 0, false), /* @__PURE__ */ jsxDEV(LiveError, {
1437
+ message: liveError,
1438
+ prefix: "mt"
1439
+ }, void 0, false), /* @__PURE__ */ jsxDEV(Button, {
1440
+ "data-testid": "mt-aggregate",
1441
+ disabled: aggregating,
1442
+ onClick: runAggregate,
1443
+ size: "sm",
1444
+ type: "button",
1445
+ variant: "secondary",
1446
+ children: aggregating ? t("Aggregating…") : t("All shards")
1447
+ }, void 0, false), shardResults !== null && /* @__PURE__ */ jsxDEV(Button, {
1448
+ "data-testid": "mt-aggregate-clear",
1449
+ onClick: clearAggregate,
1450
+ size: "sm",
1451
+ type: "button",
1452
+ variant: "ghost",
1453
+ children: t("Hide")
1454
+ }, void 0, false), /* @__PURE__ */ jsxDEV("a", {
1455
+ className: "text-sm text-primary underline-offset-4 hover:underline",
1456
+ "data-testid": "mt-cf-link",
1457
+ href: CLOUDFLARE_DURABLE_OBJECTS_URL,
1458
+ rel: "noreferrer",
1459
+ target: "_blank",
1460
+ children: t("Open in Cloudflare")
1461
+ }, void 0, false)]
1462
+ }, void 0, true), error !== null && /* @__PURE__ */ jsxDEV("p", {
1463
+ className: "text-sm text-destructive",
1464
+ "data-testid": "mt-error",
1465
+ role: "alert",
1466
+ children: error
1467
+ }, void 0, false), queryStats !== void 0 && /* @__PURE__ */ jsxDEV("div", {
1468
+ className: "flex gap-2 border-b",
1469
+ "data-testid": "mt-tabs",
1470
+ children: [/* @__PURE__ */ jsxDEV("button", {
1471
+ className: `pb-2 text-sm font-medium transition-colors ${activeTab === "overview" ? "border-b-2 border-primary text-foreground" : "text-muted-foreground hover:text-foreground"}`,
1472
+ "data-testid": "mt-tab-overview",
1473
+ onClick: switchToOverview,
1474
+ type: "button",
1475
+ children: t("Overview")
1476
+ }, void 0, false), /* @__PURE__ */ jsxDEV("button", {
1477
+ className: `pb-2 text-sm font-medium transition-colors ${activeTab === "query-insights" ? "border-b-2 border-primary text-foreground" : "text-muted-foreground hover:text-foreground"}`,
1478
+ "data-testid": "mt-tab-query-insights",
1479
+ onClick: switchToQueryInsights,
1480
+ type: "button",
1481
+ children: [t("Query insights"), queryStats.length > 0 && /* @__PURE__ */ jsxDEV("span", {
1482
+ className: "ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",
1483
+ children: queryStats.length
1484
+ }, void 0, false)]
1485
+ }, void 0, true)]
1486
+ }, void 0, true), activeTab === "query-insights" && queryStats !== void 0 && /* @__PURE__ */ jsxDEV(QueryInsights, {
1487
+ queryStats
1488
+ }, void 0, false), activeTab === "overview" && metrics !== null && /* @__PURE__ */ jsxDEV("dl", {
1489
+ className: "grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",
1490
+ "data-testid": "mt-stats",
1491
+ children: [/* @__PURE__ */ jsxDEV(StatCard, {
1492
+ chart: history.length >= 2 ? /* @__PURE__ */ jsxDEV(Sparkline, {
1493
+ ariaLabel: t("Requests per interval over time"),
1494
+ className: "h-7 w-24 text-foreground",
1495
+ series: history,
1496
+ testId: "mt-sparkline"
1497
+ }, void 0, false) : void 0,
1498
+ footer: history.length >= 2 ? /* @__PURE__ */ jsxDEV(Fragment, {
1499
+ children: [/* @__PURE__ */ jsxDEV("span", {
1500
+ className: "font-semibold text-foreground",
1501
+ children: `+${currentDelta.toLocaleString()}`
1502
+ }, void 0, false), " ", t("last interval")]
1503
+ }, void 0, true) : /* @__PURE__ */ jsxDEV("span", {
1504
+ "data-testid": "mt-sparkline-empty",
1505
+ children: t("collecting samples…")
1506
+ }, void 0, false),
1507
+ label: t("Requests"),
1508
+ testId: "mt-requests",
1509
+ value: metrics.requests
1510
+ }, void 0, false), /* @__PURE__ */ jsxDEV(StatCard, {
1511
+ footer: t("{rate} error rate", {
1512
+ rate: errorRate
1513
+ }),
1514
+ label: t("Errors"),
1515
+ testId: "mt-errors",
1516
+ value: /* @__PURE__ */ jsxDEV(Fragment, {
1517
+ children: [metrics.errors, " (", errorRate, ")"]
1518
+ }, void 0, true)
1519
+ }, void 0, false), /* @__PURE__ */ jsxDEV(StatCard, {
1520
+ footer: latencyPercentiles.p90 > 0 ? `P90 ${formatMs(latencyPercentiles.p90)}` : void 0,
1521
+ label: t("P95 latency"),
1522
+ testId: "mt-p95",
1523
+ value: latencyPercentiles.p95 > 0 ? formatMs(latencyPercentiles.p95) : "—"
1524
+ }, void 0, false), /* @__PURE__ */ jsxDEV(StatCard, {
1525
+ footer: metrics.cache === null ? void 0 : `${metrics.cache.entries.toLocaleString()} ${t("cache entries")}`,
1526
+ label: t("Database size"),
1527
+ testId: "mt-db-size",
1528
+ value: formatBytes(metrics.databaseSize)
1529
+ }, void 0, false), /* @__PURE__ */ jsxDEV(StatCard, {
1530
+ label: t("Shard"),
1531
+ testId: "mt-shard",
1532
+ value: metrics.shard
1533
+ }, void 0, false), /* @__PURE__ */ jsxDEV(StatCard, {
1534
+ label: t("Uptime"),
1535
+ testId: "mt-uptime",
1536
+ value: formatDuration(metrics.uptimeMs)
1537
+ }, void 0, false), /* @__PURE__ */ jsxDEV(StatCard, {
1538
+ label: t("Cache hit rate"),
1539
+ testId: "mt-cache",
1540
+ value: metrics.cache === null ? t("no cache configured") : t("{rate} ({count} entries)", {
1541
+ count: metrics.cache.entries,
1542
+ rate: hitRate(metrics.cache.hits, metrics.cache.misses)
1543
+ })
1544
+ }, void 0, false)]
1545
+ }, void 0, true), activeTab === "overview" && metrics === null && null, activeTab === "overview" && aggregate !== null && shardResults !== null && /* @__PURE__ */ jsxDEV("div", {
1546
+ className: "flex flex-col gap-4",
1547
+ "data-testid": "mt-aggregate-view",
1548
+ children: [/* @__PURE__ */ jsxDEV("dl", {
1549
+ className: "grid gap-3 sm:grid-cols-2 lg:grid-cols-3",
1550
+ "data-testid": "mt-aggregate-stats",
1551
+ children: [/* @__PURE__ */ jsxDEV(StatCard, {
1552
+ label: t("Shards"),
1553
+ testId: "mt-agg-shards",
1554
+ value: aggregate.failed > 0 ? t("{reachable} reachable, {failed} unreachable", {
1555
+ failed: aggregate.failed,
1556
+ reachable: aggregate.reachable
1557
+ }) : t("{reachable} reachable", {
1558
+ reachable: aggregate.reachable
1559
+ })
1560
+ }, void 0, false), /* @__PURE__ */ jsxDEV(StatCard, {
1561
+ label: t("Total requests"),
1562
+ testId: "mt-agg-requests",
1563
+ value: aggregate.totalRequests
1564
+ }, void 0, false), /* @__PURE__ */ jsxDEV(StatCard, {
1565
+ label: t("Total errors"),
1566
+ testId: "mt-agg-errors",
1567
+ value: aggregate.totalErrors
1568
+ }, void 0, false), /* @__PURE__ */ jsxDEV(StatCard, {
1569
+ label: t("Total database size"),
1570
+ testId: "mt-agg-db-size",
1571
+ value: formatBytes(aggregate.totalDatabaseSize)
1572
+ }, void 0, false), /* @__PURE__ */ jsxDEV(StatCard, {
1573
+ label: t("Combined cache hit rate"),
1574
+ testId: "mt-agg-cache",
1575
+ value: aggregate.hitRate === null ? t("no cache configured") : `${(aggregate.hitRate * 100).toFixed(1)}%`
1576
+ }, void 0, false)]
1577
+ }, void 0, true), /* @__PURE__ */ jsxDEV(Card, {
1578
+ className: "overflow-hidden py-0",
1579
+ children: /* @__PURE__ */ jsxDEV(CardContent, {
1580
+ className: "px-0",
1581
+ children: /* @__PURE__ */ jsxDEV(Table, {
1582
+ "data-testid": "mt-agg-table",
1583
+ children: [/* @__PURE__ */ jsxDEV(TableHeader, {
1584
+ children: /* @__PURE__ */ jsxDEV(TableRow, {
1585
+ children: [/* @__PURE__ */ jsxDEV(TableHead, {
1586
+ children: t("shard")
1587
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
1588
+ children: t("requests")
1589
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
1590
+ children: t("errors")
1591
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableHead, {
1592
+ children: t("db size")
1593
+ }, void 0, false)]
1594
+ }, void 0, true)
1595
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableBody, {
1596
+ children: shardResults.map((result) => /* @__PURE__ */ jsxDEV(TableRow, {
1597
+ "data-testid": `mt-agg-row-${result.shard}`,
1598
+ children: [/* @__PURE__ */ jsxDEV(TableCell, {
1599
+ children: result.shard
1600
+ }, void 0, false), result.metrics === null ? /* @__PURE__ */ jsxDEV(TableCell, {
1601
+ className: "text-destructive",
1602
+ colSpan: 3,
1603
+ children: result.error ?? t("unreachable")
1604
+ }, void 0, false) : /* @__PURE__ */ jsxDEV(Fragment, {
1605
+ children: [/* @__PURE__ */ jsxDEV(TableCell, {
1606
+ className: "tabular-nums",
1607
+ children: result.metrics.requests
1608
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
1609
+ className: "tabular-nums",
1610
+ children: result.metrics.errors
1611
+ }, void 0, false), /* @__PURE__ */ jsxDEV(TableCell, {
1612
+ className: "tabular-nums",
1613
+ children: formatBytes(result.metrics.databaseSize)
1614
+ }, void 0, false)]
1615
+ }, void 0, true)]
1616
+ }, result.shard, true))
1617
+ }, void 0, false)]
1618
+ }, void 0, true)
1619
+ }, void 0, false)
1620
+ }, void 0, false)]
1621
+ }, void 0, true)]
1622
+ }, void 0, true);
1623
+ };
1624
+
1625
+ export { MetricsPanel };