react-semaphor 0.1.381 → 0.1.383

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 (86) hide show
  1. package/DATA_APP_SDK.md +238 -0
  2. package/README.md +7 -0
  3. package/dist/analytics-protocol/index.cjs +1 -1
  4. package/dist/analytics-protocol/index.js +45 -41
  5. package/dist/brand-studio/index.cjs +4 -4
  6. package/dist/brand-studio/index.js +28 -28
  7. package/dist/chunks/analyze-result-contract-CtXfp3nv.js +1 -0
  8. package/dist/chunks/analyze-result-contract-DuhlklhI.js +102 -0
  9. package/dist/chunks/{braces-DOxxfERN.js → braces--20GzUQh.js} +1 -1
  10. package/dist/chunks/{braces-BT-ZyB-g.js → braces-C0Vh_Mft.js} +1 -1
  11. package/dist/chunks/{calendar-preferences-dialog-Dsgs8WDv.js → calendar-preferences-dialog-B-VsxhsA.js} +4 -4
  12. package/dist/chunks/calendar-preferences-dialog-DE67Z3oQ.js +1 -0
  13. package/dist/chunks/catalog-field-grounding-Bnx-3tE0.js +1 -0
  14. package/dist/chunks/catalog-field-grounding-CJKAqtiC.js +100 -0
  15. package/dist/chunks/{dashboard-briefing-launcher-Coks66cV.js → dashboard-briefing-launcher-BIj3X7b3.js} +108 -107
  16. package/dist/chunks/dashboard-briefing-launcher-Czx6BcXW.js +80 -0
  17. package/dist/chunks/dashboard-controls-BP-DcPFs.js +52 -0
  18. package/dist/chunks/{dashboard-controls-BfkcnIdy.js → dashboard-controls-BXxucM4f.js} +115 -114
  19. package/dist/chunks/dashboard-json-BNwshkK2.js +1 -0
  20. package/dist/chunks/{dashboard-json-DjXi4cI6.js → dashboard-json-C6oZuipD.js} +9 -9
  21. package/dist/chunks/edit-dashboard-visual-BAprin3J.js +178 -0
  22. package/dist/chunks/{edit-dashboard-visual-DOW1Ap1N.js → edit-dashboard-visual-CmfrI_L3.js} +1278 -1277
  23. package/dist/chunks/{index-CkoRCh3g.js → index-4W_ElSBJ.js} +219 -239
  24. package/dist/chunks/{index-DlprYjr6.js → index-icb12JV1.js} +900 -952
  25. package/dist/chunks/{layout-grid-DccceHv4.js → layout-grid-B7-klXiK.js} +1 -1
  26. package/dist/chunks/{layout-grid-DTbOIOsE.js → layout-grid-DV89AC9_.js} +1 -1
  27. package/dist/chunks/operators-C8TxpM4C.js +48 -0
  28. package/dist/chunks/operators-DrTQsJXv.js +1 -0
  29. package/dist/chunks/{palette-DCzLwqIw.js → palette-5IwhMbSF.js} +1 -1
  30. package/dist/chunks/{palette-SimHJELn.js → palette-Dj-dgPYh.js} +1 -1
  31. package/dist/chunks/{save-zNVYH02T.js → save-16C6YSW2.js} +1 -1
  32. package/dist/chunks/{save-D2O96E5A.js → save-C5fwVdTF.js} +1 -1
  33. package/dist/chunks/search-0LmWwZzW.js +57 -0
  34. package/dist/chunks/search-Dq1Mbb03.js +21 -0
  35. package/dist/chunks/{source-identity-Dj3dryN9.js → source-identity-CN4xiyKJ.js} +5 -5
  36. package/dist/chunks/{switch-DMPsMpHW.js → switch-DUdaHFZQ.js} +2328 -2414
  37. package/dist/chunks/{switch-Jhyl63RF.js → switch-bdJp0Bkw.js} +29 -54
  38. package/dist/chunks/use-create-flow-overlay-state-BIHKf_XK.js +21 -0
  39. package/dist/chunks/{use-create-flow-overlay-state-r5JKyXU8.js → use-create-flow-overlay-state-YvqCp6Zo.js} +75 -75
  40. package/dist/chunks/{validators-CtNmgsvG.js → validators-CHPH6ORs.js} +641 -498
  41. package/dist/chunks/validators-lWo8m0Q7.js +1 -0
  42. package/dist/chunks/x-B_cx7LwM.js +26 -0
  43. package/dist/chunks/x-IdR_js6f.js +139 -0
  44. package/dist/dashboard/index.cjs +1 -1
  45. package/dist/dashboard/index.js +1 -1
  46. package/dist/dashboard-authoring/index.cjs +3 -3
  47. package/dist/dashboard-authoring/index.js +105 -92
  48. package/dist/data-app-builder/index.cjs +23 -23
  49. package/dist/data-app-builder/index.js +17 -15
  50. package/dist/data-app-sdk/index.cjs +68 -1
  51. package/dist/data-app-sdk/index.js +2731 -384
  52. package/dist/data-app-sdk-adapters/index.cjs +1 -0
  53. package/dist/data-app-sdk-adapters/index.js +383 -0
  54. package/dist/data-app-sdk-validation/index.cjs +1 -1
  55. package/dist/data-app-sdk-validation/index.js +1073 -6
  56. package/dist/index.cjs +1 -1
  57. package/dist/index.js +15 -15
  58. package/dist/surfboard/index.cjs +1 -1
  59. package/dist/surfboard/index.js +2 -2
  60. package/dist/types/analytics-protocol.d.ts +58 -31
  61. package/dist/types/dashboard-assistant.d.ts +40 -15
  62. package/dist/types/dashboard-authoring.d.ts +36 -16
  63. package/dist/types/dashboard.d.ts +8 -8
  64. package/dist/types/data-app-builder.d.ts +35 -11
  65. package/dist/types/data-app-sdk-adapters.d.ts +733 -0
  66. package/dist/types/data-app-sdk-validation.d.ts +85 -25
  67. package/dist/types/data-app-sdk.d.ts +217 -147
  68. package/dist/types/main.d.ts +35 -11
  69. package/dist/types/shared.d.ts +8 -8
  70. package/dist/types/surfboard.d.ts +8 -8
  71. package/dist/types/types.d.ts +8 -8
  72. package/package.json +9 -2
  73. package/src/data-app-sdk/README.md +240 -0
  74. package/dist/chunks/calendar-preferences-dialog-iZs8XqyH.js +0 -1
  75. package/dist/chunks/catalog-field-grounding-8L9I0zdg.js +0 -1
  76. package/dist/chunks/catalog-field-grounding-BK4BX8sZ.js +0 -200
  77. package/dist/chunks/dashboard-briefing-launcher-B5vPTl8P.js +0 -80
  78. package/dist/chunks/dashboard-controls-Dyqye6fh.js +0 -52
  79. package/dist/chunks/dashboard-json-CV_LnO9x.js +0 -1
  80. package/dist/chunks/edit-dashboard-visual-yinO0yU-.js +0 -178
  81. package/dist/chunks/index-BxM99sFL.js +0 -1
  82. package/dist/chunks/index-CuHybtft.js +0 -51
  83. package/dist/chunks/use-create-flow-overlay-state-NsqFPwdB.js +0 -21
  84. package/dist/chunks/validation-BM3-ShHV.js +0 -1003
  85. package/dist/chunks/validation-BVpqRFar.js +0 -1
  86. package/dist/chunks/validators-jpoYhpHh.js +0 -1
@@ -1,11 +1,2357 @@
1
- import { t as y, a as z, b as M, c as Q, d as J, e as Y, f as F, g as H, n as P, h as N, i as I } from "../chunks/validation-BM3-ShHV.js";
2
- import { m as Je, j as Ye, k as Fe, l as He, v as We } from "../chunks/validation-BM3-ShHV.js";
3
- import { j as W } from "../chunks/index-CuHybtft.js";
4
- import { createContext as X, useContext as G, useMemo as m, useState as K, useCallback as R, useEffect as L, useRef as T } from "react";
5
- import { jsx as Z } from "react/jsx-runtime";
6
- import { c as ee } from "../chunks/validators-CtNmgsvG.js";
7
- import "../chunks/catalog-field-grounding-BK4BX8sZ.js";
8
- const te = [
1
+ import { toSemaphorInputSnapshots as bt, toSemaphorInputBinding as St, toSemaphorActiveInputSnapshots as U, toSemaphorMatrixIntent as xt, toSemaphorSqlIntent as wt, toSemaphorInputOptionsIntent as It, toSemaphorRecordsIntent as qt, toSemaphorAnalysisQueryOptions as Rt, toSemaphorAnalysisIntent as At, toSemaphorMetricIntent as Et, hasSemaphorInputValue as ee, normalizeSemaphorInputOptions as Ge, toSemaphorInputSpec as Je } from "../data-app-sdk-adapters/index.js";
2
+ import { jsxs as p, Fragment as Tt, jsx as s } from "react/jsx-runtime";
3
+ import { createContext as ce, useContext as z, useState as H, useRef as C, useEffect as B, useMemo as b, useId as Ye, useCallback as D, useReducer as kt } from "react";
4
+ import { M as Ct, a as Dt, S as Ot, E as Lt } from "../chunks/search-0LmWwZzW.js";
5
+ import { X as Bt, j as Kt } from "../chunks/x-IdR_js6f.js";
6
+ import { b as $t } from "../chunks/validators-CHPH6ORs.js";
7
+ import "../chunks/analyze-result-contract-DuhlklhI.js";
8
+ function ne(e, t, r = {}) {
9
+ return {
10
+ ...r,
11
+ name: e,
12
+ role: t
13
+ };
14
+ }
15
+ function kn(e) {
16
+ return e;
17
+ }
18
+ function Cn(e) {
19
+ return e;
20
+ }
21
+ const Dn = {
22
+ source: {
23
+ semantic(e) {
24
+ return {
25
+ ...e,
26
+ kind: "semantic"
27
+ };
28
+ },
29
+ sql(e) {
30
+ return {
31
+ ...e,
32
+ kind: "sql"
33
+ };
34
+ }
35
+ },
36
+ field: {
37
+ measure(e, t) {
38
+ return ne(e, "measure", t);
39
+ },
40
+ dimension(e, t) {
41
+ return ne(e, "dimension", t);
42
+ },
43
+ date(e, t) {
44
+ return ne(e, "date", t);
45
+ },
46
+ id(e, t) {
47
+ return ne(e, "id", t);
48
+ }
49
+ },
50
+ filter(e) {
51
+ return {
52
+ ...e,
53
+ kind: "filter"
54
+ };
55
+ },
56
+ bindInput(e, t) {
57
+ return {
58
+ toAnalyticsInput() {
59
+ const [r] = bt([e]), n = St({
60
+ ...t,
61
+ inputId: t.inputId || r.inputId
62
+ });
63
+ return {
64
+ ...r,
65
+ inputId: n.inputId,
66
+ ...n.kind ? { kind: n.kind } : {},
67
+ ...n.controlRole ? { controlRole: n.controlRole } : {},
68
+ ...n.operator ? { operator: n.operator } : {},
69
+ ...n.field ? { field: n.field } : {},
70
+ ...n.relationshipHint ? { relationshipHint: n.relationshipHint } : {}
71
+ };
72
+ }
73
+ };
74
+ },
75
+ control(e) {
76
+ return {
77
+ ...e,
78
+ kind: "control"
79
+ };
80
+ },
81
+ sqlParam(e) {
82
+ return {
83
+ ...e,
84
+ kind: "control",
85
+ role: "sqlParam"
86
+ };
87
+ },
88
+ derivedField(e) {
89
+ return {
90
+ ...e,
91
+ kind: "derived_field",
92
+ expressionLanguage: e.expressionLanguage || "semaphor_sql_template"
93
+ };
94
+ },
95
+ metric(e) {
96
+ return {
97
+ ...e,
98
+ queryKind: "metric"
99
+ };
100
+ },
101
+ analysis(e) {
102
+ return {
103
+ ...e,
104
+ queryKind: "analysis"
105
+ };
106
+ },
107
+ records(e) {
108
+ return {
109
+ ...e,
110
+ queryKind: "records"
111
+ };
112
+ },
113
+ inputOptions(e) {
114
+ return {
115
+ ...e,
116
+ queryKind: "inputOptions"
117
+ };
118
+ },
119
+ sql(e) {
120
+ return {
121
+ ...e,
122
+ queryKind: "sql"
123
+ };
124
+ },
125
+ matrix(e) {
126
+ return {
127
+ ...e,
128
+ queryKind: "matrix"
129
+ };
130
+ }
131
+ }, ge = 10, he = 100, _t = 25, Ft = 500, Xe = {
132
+ enabled: !1,
133
+ queries: [],
134
+ getQuery: () => {
135
+ },
136
+ getQueries: () => []
137
+ }, Ee = ce(null), Te = ce(null), ke = ce(
138
+ void 0
139
+ ), M = [];
140
+ function Wt({
141
+ debug: e,
142
+ children: t
143
+ }) {
144
+ const r = b(() => Cr(e), [e]), [n, i] = kt(
145
+ xr,
146
+ r,
147
+ dt
148
+ ), d = C(n), l = Ye(), [u, c] = H({ open: !1 });
149
+ d.current = n, B(() => {
150
+ i({ type: "config", config: r });
151
+ }, [r]), B(() => {
152
+ if (!n.enabled || !n.exposeWindowBridge || typeof window > "u")
153
+ return;
154
+ const v = Er(() => d.current);
155
+ return Nt({
156
+ ownerId: l,
157
+ bridge: v
158
+ }), () => {
159
+ Mt(l);
160
+ };
161
+ }, [l, n.enabled, n.exposeWindowBridge]);
162
+ const f = b(() => ({ state: n, dispatch: i }), [n]), h = D((v) => {
163
+ c({ open: !0, focus: v });
164
+ }, []), g = D(() => {
165
+ c((v) => ({ ...v, open: !1 }));
166
+ }, []), y = D((v) => {
167
+ c({ open: !0, focus: v });
168
+ }, []), m = b(
169
+ () => ({
170
+ open: u.open,
171
+ focus: u.focus,
172
+ openDevtools: h,
173
+ closeDevtools: g,
174
+ focusTrace: y
175
+ }),
176
+ [
177
+ g,
178
+ y,
179
+ h,
180
+ u.focus,
181
+ u.open
182
+ ]
183
+ );
184
+ return /* @__PURE__ */ s(Ee.Provider, { value: f, children: /* @__PURE__ */ s(Te.Provider, { value: m, children: t }) });
185
+ }
186
+ function Nt(e) {
187
+ const t = M.findIndex(
188
+ (r) => r.ownerId === e.ownerId
189
+ );
190
+ t >= 0 && M.splice(t, 1), M.push(e), Ze();
191
+ }
192
+ function Mt(e) {
193
+ const t = M.findIndex(
194
+ (r) => r.ownerId === e
195
+ );
196
+ t >= 0 && M.splice(t, 1), Ze();
197
+ }
198
+ function Ze() {
199
+ if (typeof window > "u")
200
+ return;
201
+ const e = M[M.length - 1];
202
+ e ? window.__SEMAPHOR_DEVTOOLS__ = e.bridge : delete window.__SEMAPHOR_DEVTOOLS__;
203
+ }
204
+ function On({
205
+ id: e,
206
+ title: t,
207
+ children: r
208
+ }) {
209
+ const n = b(() => ({ id: e, title: t }), [e, t]);
210
+ return /* @__PURE__ */ s(ke.Provider, { value: n, children: r });
211
+ }
212
+ function Ln({
213
+ buttonPosition: e = "bottom-right",
214
+ initialIsOpen: t = !1,
215
+ panelPosition: r = "right",
216
+ className: n,
217
+ style: i
218
+ } = {}) {
219
+ const d = et(), l = z(Te), [u, c] = H(""), [f, h] = H(!1), g = C(null), y = C(null), m = l == null ? void 0 : l.openDevtools, v = l == null ? void 0 : l.closeDevtools, A = (l == null ? void 0 : l.open) === !0;
220
+ B(() => {
221
+ at();
222
+ }, []), B(() => {
223
+ t && d.enabled && (m == null || m());
224
+ }, [t, d.enabled, m]), B(() => {
225
+ if (!A || !v)
226
+ return;
227
+ const w = (q) => {
228
+ var E, L;
229
+ const O = q.target;
230
+ O instanceof Node && ((E = g.current) != null && E.contains(O) || (L = y.current) != null && L.contains(O) || v());
231
+ };
232
+ return document.addEventListener("pointerdown", w, !0), document.addEventListener("mousedown", w, !0), document.addEventListener("click", w, !0), () => {
233
+ document.removeEventListener("pointerdown", w, !0), document.removeEventListener("mousedown", w, !0), document.removeEventListener("click", w, !0);
234
+ };
235
+ }, [v, A]);
236
+ const o = b(
237
+ () => Yt(d.queries),
238
+ [d.queries]
239
+ ), S = b(
240
+ () => Xt(d.queries, u),
241
+ [d.queries, u]
242
+ ), T = b(
243
+ () => Zt(S),
244
+ [S]
245
+ ), k = b(
246
+ () => tt(S, l == null ? void 0 : l.focus) || S[0],
247
+ [S, l == null ? void 0 : l.focus]
248
+ );
249
+ return !d.enabled || !l ? null : /* @__PURE__ */ p(Tt, { children: [
250
+ /* @__PURE__ */ p(
251
+ "button",
252
+ {
253
+ ref: g,
254
+ type: "button",
255
+ "aria-label": "Open Semaphor DevTools",
256
+ title: "Open Semaphor DevTools",
257
+ className: n ? `${$} ${n}` : $,
258
+ style: {
259
+ ...a.launcher,
260
+ ...mr(e),
261
+ ...gr(o.severity),
262
+ ...i
263
+ },
264
+ onClick: () => l.openDevtools(),
265
+ children: [
266
+ /* @__PURE__ */ s(jt, {}),
267
+ /* @__PURE__ */ s("span", { style: a.launcherText, children: o.total }),
268
+ o.issueCount > 0 ? /* @__PURE__ */ s("span", { style: a.launcherIssueCount, children: o.issueCount }) : null
269
+ ]
270
+ }
271
+ ),
272
+ l.open ? /* @__PURE__ */ p(
273
+ "div",
274
+ {
275
+ ref: y,
276
+ role: "dialog",
277
+ "aria-label": "Semaphor DevTools",
278
+ "aria-modal": "false",
279
+ className: $,
280
+ style: {
281
+ ...a.panel,
282
+ ...hr(r),
283
+ ...f ? a.panelFullscreen : null
284
+ },
285
+ children: [
286
+ /* @__PURE__ */ p("div", { style: a.panelHeader, children: [
287
+ /* @__PURE__ */ p("div", { style: a.panelTitleBlock, children: [
288
+ /* @__PURE__ */ s("div", { style: a.panelTitle, children: "Semaphor DevTools" }),
289
+ /* @__PURE__ */ p("div", { style: a.panelSubtitle, children: [
290
+ o.total,
291
+ " queries · ",
292
+ o.loading,
293
+ " loading ·",
294
+ " ",
295
+ o.failed,
296
+ " failed"
297
+ ] })
298
+ ] }),
299
+ /* @__PURE__ */ p("div", { style: a.panelActions, children: [
300
+ /* @__PURE__ */ s(
301
+ "button",
302
+ {
303
+ type: "button",
304
+ "aria-label": f ? "Exit fullscreen Semaphor DevTools" : "Enter fullscreen Semaphor DevTools",
305
+ title: f ? "Exit fullscreen Semaphor DevTools" : "Enter fullscreen Semaphor DevTools",
306
+ style: a.iconButton,
307
+ onClick: () => h((w) => !w),
308
+ children: f ? /* @__PURE__ */ s(Ct, { size: 15 }) : /* @__PURE__ */ s(Dt, { size: 15 })
309
+ }
310
+ ),
311
+ /* @__PURE__ */ s(
312
+ "button",
313
+ {
314
+ type: "button",
315
+ "aria-label": "Close Semaphor DevTools",
316
+ style: a.iconButton,
317
+ onClick: l.closeDevtools,
318
+ children: /* @__PURE__ */ s(Bt, { size: 15 })
319
+ }
320
+ )
321
+ ] })
322
+ ] }),
323
+ /* @__PURE__ */ p("label", { style: a.searchBox, children: [
324
+ /* @__PURE__ */ s(Ot, { size: 14 }),
325
+ /* @__PURE__ */ s(
326
+ "input",
327
+ {
328
+ "aria-label": "Search Semaphor traces",
329
+ value: u,
330
+ onChange: (w) => c(w.currentTarget.value),
331
+ placeholder: "Search traces",
332
+ style: a.searchInput
333
+ }
334
+ )
335
+ ] }),
336
+ /* @__PURE__ */ p(
337
+ "div",
338
+ {
339
+ style: {
340
+ ...a.panelBody,
341
+ ...yr(r)
342
+ },
343
+ children: [
344
+ /* @__PURE__ */ s(
345
+ "div",
346
+ {
347
+ style: {
348
+ ...a.queryList,
349
+ ...vr()
350
+ },
351
+ "aria-label": "Registered queries",
352
+ children: S.length ? T.map((w) => /* @__PURE__ */ p("div", { style: a.queryGroup, children: [
353
+ /* @__PURE__ */ p("div", { style: a.queryGroupHeader, children: [
354
+ /* @__PURE__ */ s("span", { children: w.title }),
355
+ /* @__PURE__ */ s("span", { style: a.queryGroupCount, children: w.traces.length })
356
+ ] }),
357
+ w.traces.length ? w.traces.map((q) => {
358
+ var K;
359
+ const O = tr(q, k), E = Ce(q), L = rt(q.queryKind), x = fe(q);
360
+ return /* @__PURE__ */ p(
361
+ "button",
362
+ {
363
+ type: "button",
364
+ title: `${E} · ${L} · ${x}`,
365
+ style: {
366
+ ...a.queryListItem,
367
+ ...O ? a.queryListItemSelected : null
368
+ },
369
+ onClick: () => l.focusTrace({
370
+ traceId: q.traceId,
371
+ queryId: q.queryId,
372
+ viewId: q.viewId
373
+ }),
374
+ children: [
375
+ /* @__PURE__ */ p("span", { style: a.queryListItemHeader, children: [
376
+ /* @__PURE__ */ s(Vt, { status: (K = q.latestAttempt) == null ? void 0 : K.status }),
377
+ /* @__PURE__ */ s("span", { style: a.queryListTitle, title: E, children: E }),
378
+ /* @__PURE__ */ s("span", { style: a.queryListKindChip, children: L })
379
+ ] }),
380
+ /* @__PURE__ */ s(
381
+ "span",
382
+ {
383
+ className: `${$}-source`,
384
+ style: a.queryListSource,
385
+ title: x,
386
+ children: x
387
+ }
388
+ )
389
+ ]
390
+ },
391
+ Re(q)
392
+ );
393
+ }) : /* @__PURE__ */ s("div", { style: a.queryGroupEmpty, children: "No input traces" })
394
+ ] }, w.title)) : /* @__PURE__ */ s("div", { style: a.emptyState, children: "No matching traces" })
395
+ }
396
+ ),
397
+ /* @__PURE__ */ s(Pt, { trace: k })
398
+ ]
399
+ }
400
+ )
401
+ ]
402
+ }
403
+ ) : null
404
+ ] });
405
+ }
406
+ function Bn({
407
+ queryId: e,
408
+ viewId: t,
409
+ label: r,
410
+ className: n,
411
+ style: i
412
+ } = {}) {
413
+ var g, y;
414
+ const d = et(), l = z(Te), u = z(ke);
415
+ B(() => {
416
+ at();
417
+ }, []);
418
+ const c = t || (u == null ? void 0 : u.id), f = b(
419
+ () => er(d.queries, {
420
+ queryId: e,
421
+ viewId: c
422
+ }),
423
+ [
424
+ d.queries,
425
+ e,
426
+ c
427
+ ]
428
+ );
429
+ if (!d.enabled || !l || !f)
430
+ return null;
431
+ const h = r || `Inspect ${Ce(f)}`;
432
+ return /* @__PURE__ */ p(
433
+ "button",
434
+ {
435
+ type: "button",
436
+ "aria-label": h,
437
+ title: h,
438
+ className: n ? `${$} ${n}` : $,
439
+ style: {
440
+ ...a.inspectButton,
441
+ ...br((g = f.latestAttempt) == null ? void 0 : g.status),
442
+ ...i
443
+ },
444
+ onClick: () => l.openDevtools({
445
+ traceId: f.traceId,
446
+ queryId: f.queryId,
447
+ viewId: f.viewId
448
+ }),
449
+ children: [
450
+ /* @__PURE__ */ s(Lt, { size: 13 }),
451
+ /* @__PURE__ */ s("span", { style: a.inspectButtonText, children: ((y = f.latestAttempt) == null ? void 0 : y.status) || "idle" })
452
+ ]
453
+ }
454
+ );
455
+ }
456
+ function et() {
457
+ const e = z(Ee);
458
+ return !e || !e.state.enabled ? Xe : le(e.state);
459
+ }
460
+ function zt({
461
+ spec: e,
462
+ queryKind: t,
463
+ queryKey: r,
464
+ intent: n,
465
+ activeInputs: i,
466
+ debug: d
467
+ }) {
468
+ const l = z(Ee), u = z(ke), c = !!(l != null && l.state.enabled), f = l == null ? void 0 : l.dispatch, h = Dr(e), g = e.label, y = b(
469
+ () => JSON.stringify(e),
470
+ [e]
471
+ ), m = b(
472
+ () => JSON.stringify(i || []),
473
+ [i]
474
+ ), v = b(
475
+ () => JSON.stringify(n || null),
476
+ [n]
477
+ ), A = C(e), o = C(y), S = C(n), T = C(v), k = C(i), w = C(m);
478
+ o.current !== y && (o.current = y, A.current = e), T.current !== v && (T.current = v, S.current = n), w.current !== m && (w.current = m, k.current = i);
479
+ const q = A.current, O = S.current, E = k.current, L = Ye(), x = b(
480
+ () => h || `query_${pt(r)}`,
481
+ [r, h]
482
+ ), K = (d == null ? void 0 : d.viewId) || (u == null ? void 0 : u.id), Be = (d == null ? void 0 : d.title) || (u == null ? void 0 : u.title), W = b(
483
+ () => [
484
+ K || "unscoped-view",
485
+ x,
486
+ L
487
+ ].join("::"),
488
+ [x, L, K]
489
+ ), Ke = b(
490
+ () => ({
491
+ traceKey: W,
492
+ spec: q,
493
+ queryId: x,
494
+ queryLabel: g,
495
+ queryKind: t,
496
+ builder: Or(t),
497
+ viewId: K,
498
+ viewTitle: Be,
499
+ intent: O,
500
+ activeInputs: E,
501
+ clientWarnings: h ? [] : ["Query spec is missing an explicit id; using an opaque internal id."]
502
+ }),
503
+ [
504
+ x,
505
+ t,
506
+ h,
507
+ g,
508
+ q,
509
+ E,
510
+ O,
511
+ W,
512
+ K,
513
+ Be
514
+ ]
515
+ );
516
+ B(() => {
517
+ if (!(!c || !f))
518
+ return f({ type: "register", descriptor: Ke }), () => {
519
+ f({ type: "unregister", traceKey: W });
520
+ };
521
+ }, [Ke, f, c, W]);
522
+ const _ = D(
523
+ (R, j) => {
524
+ !c || !f || f({ type: "event", traceKey: W, event: R, latestAttempt: j });
525
+ },
526
+ [f, c, W]
527
+ ), $e = D(() => {
528
+ _(
529
+ {
530
+ type: "query_started",
531
+ queryId: x,
532
+ at: se()
533
+ },
534
+ { status: "loading" }
535
+ );
536
+ }, [_, x]), _e = D(
537
+ (R, j) => {
538
+ const J = Qe(R), Y = Nr(R), vt = Mr(R);
539
+ _(
540
+ {
541
+ type: "query_succeeded",
542
+ queryId: x,
543
+ requestId: J,
544
+ at: se(),
545
+ rowCount: Y,
546
+ durationMs: j
547
+ },
548
+ {
549
+ requestId: J,
550
+ status: "success",
551
+ durationMs: j,
552
+ rowCount: Y,
553
+ columnCount: vt,
554
+ executionResult: Ve(R)
555
+ }
556
+ );
557
+ },
558
+ [_, x]
559
+ ), re = D(
560
+ (R, j) => {
561
+ const J = Qe(R), Y = R instanceof Error ? R.message : String(R);
562
+ _(
563
+ {
564
+ type: "query_failed",
565
+ queryId: x,
566
+ requestId: J,
567
+ at: se(),
568
+ errorMessage: Y
569
+ },
570
+ {
571
+ requestId: J,
572
+ status: "error",
573
+ durationMs: j,
574
+ errorMessage: Y,
575
+ executionResult: Ve(R)
576
+ }
577
+ );
578
+ },
579
+ [_, x]
580
+ ), Fe = D(
581
+ (R) => {
582
+ _(
583
+ {
584
+ type: "query_ignored_stale",
585
+ queryId: x,
586
+ at: se(),
587
+ reason: R
588
+ }
589
+ );
590
+ },
591
+ [_, x]
592
+ ), We = D(
593
+ (R) => {
594
+ re(R, 0);
595
+ },
596
+ [re]
597
+ ), me = c ? l == null ? void 0 : l.state.entries[W] : void 0;
598
+ return b(
599
+ () => ({
600
+ enabled: c,
601
+ queryId: x,
602
+ trace: me ? de(me) : void 0,
603
+ start: $e,
604
+ success: _e,
605
+ failure: re,
606
+ ignored: Fe,
607
+ validationFailure: We
608
+ }),
609
+ [
610
+ c,
611
+ re,
612
+ Fe,
613
+ x,
614
+ $e,
615
+ _e,
616
+ me,
617
+ We
618
+ ]
619
+ );
620
+ }
621
+ function jt() {
622
+ return /* @__PURE__ */ s("span", { style: a.logoMark, "aria-hidden": !0, children: /* @__PURE__ */ p(
623
+ "svg",
624
+ {
625
+ viewBox: "0 0 100 100",
626
+ fill: "none",
627
+ width: "16",
628
+ height: "16",
629
+ focusable: "false",
630
+ children: [
631
+ /* @__PURE__ */ s("rect", { x: "20", y: "15", width: "60", height: "12", rx: "6", fill: "currentColor" }),
632
+ /* @__PURE__ */ s("rect", { x: "20", y: "35", width: "40", height: "12", rx: "6", fill: "currentColor" }),
633
+ /* @__PURE__ */ s("rect", { x: "40", y: "55", width: "40", height: "12", rx: "6", fill: "currentColor" }),
634
+ /* @__PURE__ */ s("rect", { x: "20", y: "75", width: "60", height: "12", rx: "6", fill: "currentColor" })
635
+ ]
636
+ }
637
+ ) });
638
+ }
639
+ function Pt({
640
+ trace: e
641
+ }) {
642
+ var m, v, A, o, S;
643
+ if (!e)
644
+ return /* @__PURE__ */ s("div", { style: a.detailsPane, children: /* @__PURE__ */ s("div", { style: a.emptyState, children: "No traces registered yet" }) });
645
+ const t = e.latestAttempt, r = t == null ? void 0 : t.executionResult, n = ye(
646
+ (m = r == null ? void 0 : r.validation) == null ? void 0 : m.warnings
647
+ ), i = ye((v = r == null ? void 0 : r.validation) == null ? void 0 : v.errors), d = ye(
648
+ (A = r == null ? void 0 : r.coverage) == null ? void 0 : A.missingObligations
649
+ ), l = r == null ? void 0 : r.compiledQuery, u = t != null && t.errorMessage ? [t.errorMessage] : [], c = [
650
+ ...e.clientWarnings,
651
+ ...n,
652
+ ...i,
653
+ ...d
654
+ ], f = fe(e), h = e.viewId ? `${e.viewId} - ${e.queryId}` : e.queryId, g = e.inputsApplied.length > 0, y = !!(l || (o = e.server) != null && o.compiledSql);
655
+ return /* @__PURE__ */ p("div", { style: a.detailsPane, children: [
656
+ /* @__PURE__ */ p("div", { style: a.detailsHeader, children: [
657
+ /* @__PURE__ */ p("div", { style: a.detailsHeaderTopRow, children: [
658
+ /* @__PURE__ */ s(
659
+ "span",
660
+ {
661
+ "aria-hidden": !0,
662
+ style: {
663
+ ...a.detailsHeaderStatusDot,
664
+ ...st(t == null ? void 0 : t.status)
665
+ }
666
+ }
667
+ ),
668
+ /* @__PURE__ */ s("span", { style: a.detailsTitle, children: Ce(e) }),
669
+ /* @__PURE__ */ s("span", { style: a.detailsKindChip, children: rt(e.queryKind) })
670
+ ] }),
671
+ /* @__PURE__ */ p("div", { style: a.detailsCaption, children: [
672
+ /* @__PURE__ */ s(
673
+ "span",
674
+ {
675
+ style: { ...a.detailsCaptionItem, ...a.detailsCaptionItemMono },
676
+ children: h
677
+ }
678
+ ),
679
+ /* @__PURE__ */ p("span", { style: a.detailsCaptionItem, children: [
680
+ /* @__PURE__ */ s("span", { style: a.detailsCaptionLabel, children: "Source" }),
681
+ /* @__PURE__ */ s("span", { style: a.detailsCaptionValue, children: f })
682
+ ] }),
683
+ /* @__PURE__ */ p("span", { style: a.detailsCaptionItem, children: [
684
+ /* @__PURE__ */ s("span", { style: a.detailsCaptionLabel, children: "Rows" }),
685
+ /* @__PURE__ */ s("span", { style: a.detailsCaptionValue, children: dr(t == null ? void 0 : t.rowCount) })
686
+ ] }),
687
+ /* @__PURE__ */ p("span", { style: a.detailsCaptionItem, children: [
688
+ /* @__PURE__ */ s("span", { style: a.detailsCaptionLabel, children: "Duration" }),
689
+ /* @__PURE__ */ s("span", { style: a.detailsCaptionValue, children: lr(t == null ? void 0 : t.durationMs) })
690
+ ] })
691
+ ] })
692
+ ] }),
693
+ u.length ? /* @__PURE__ */ s(Ne, { tone: "error", title: "Error", items: u }) : null,
694
+ c.length ? /* @__PURE__ */ s(Ne, { tone: "warning", title: "Warnings", items: c }) : null,
695
+ /* @__PURE__ */ s(Qt, { trace: e }),
696
+ /* @__PURE__ */ s(Ht, { trace: e }),
697
+ g ? /* @__PURE__ */ s(Gt, { inputs: e.inputsApplied }) : null,
698
+ y ? /* @__PURE__ */ s(ae, { title: "Compiled query", children: /* @__PURE__ */ s(
699
+ Jt,
700
+ {
701
+ compiledQuery: l,
702
+ compiledSql: (S = e.server) == null ? void 0 : S.compiledSql
703
+ }
704
+ ) }) : null,
705
+ /* @__PURE__ */ s(ae, { title: "Lifecycle events", children: e.recentEvents.length ? /* @__PURE__ */ s("div", { style: a.eventList, children: e.recentEvents.slice(-5).map((T, k) => /* @__PURE__ */ p(
706
+ "div",
707
+ {
708
+ style: a.eventRow,
709
+ children: [
710
+ /* @__PURE__ */ s("span", { style: a.eventType, children: cr(T) }),
711
+ /* @__PURE__ */ s("span", { style: a.eventMeta, children: fr(T) })
712
+ ]
713
+ },
714
+ `${T.type}:${T.at}:${k}`
715
+ )) }) : /* @__PURE__ */ s("div", { style: a.mutedText, children: "No attempts recorded" }) }),
716
+ /* @__PURE__ */ s(ae, { title: "Raw trace JSON", children: /* @__PURE__ */ s("pre", { style: a.codeBlock, children: ur(e) }) })
717
+ ] });
718
+ }
719
+ function Ne({
720
+ tone: e,
721
+ title: t,
722
+ items: r
723
+ }) {
724
+ const n = e === "error" ? a.alertCardError : a.alertCardWarning;
725
+ return /* @__PURE__ */ p("div", { style: { ...a.alertCard, ...n }, children: [
726
+ /* @__PURE__ */ s("div", { style: a.alertCardTitle, children: t }),
727
+ r.length > 1 ? /* @__PURE__ */ s("ul", { style: a.alertCardList, children: r.map((i, d) => /* @__PURE__ */ s("li", { children: i }, `${e}-${d}`)) }) : /* @__PURE__ */ s("div", { children: r[0] })
728
+ ] });
729
+ }
730
+ function Vt({
731
+ status: e
732
+ }) {
733
+ return /* @__PURE__ */ s(
734
+ "span",
735
+ {
736
+ "aria-hidden": !0,
737
+ style: {
738
+ ...a.statusDot,
739
+ ...st(e)
740
+ }
741
+ }
742
+ );
743
+ }
744
+ function ae({
745
+ title: e,
746
+ children: t
747
+ }) {
748
+ return /* @__PURE__ */ p("details", { style: a.disclosure, children: [
749
+ /* @__PURE__ */ s("summary", { style: a.disclosureSummary, children: e }),
750
+ /* @__PURE__ */ s("div", { style: a.disclosureBody, children: t })
751
+ ] });
752
+ }
753
+ function Qt({
754
+ trace: e
755
+ }) {
756
+ var d;
757
+ const t = (d = e.projectionFieldRefs) != null && d.length ? e.projectionFieldRefs : e.fieldRefs, r = e.inputFieldRefs || [], n = rr(t), i = nr(e, n, t);
758
+ return /* @__PURE__ */ p("div", { style: a.recipe, children: [
759
+ /* @__PURE__ */ s("div", { style: a.recipeSummary, children: i.map((l) => /* @__PURE__ */ p("div", { style: a.recipeSummaryRow, children: [
760
+ /* @__PURE__ */ s("span", { style: a.recipeSummaryLabel, children: l.label }),
761
+ /* @__PURE__ */ s("span", { style: a.recipeSummaryValue, title: l.value, children: l.value })
762
+ ] }, l.label)) }),
763
+ /* @__PURE__ */ s(N, { title: "Measures", fields: n.measures }),
764
+ /* @__PURE__ */ s(N, { title: "Time fields", fields: n.timeFields }),
765
+ /* @__PURE__ */ s(
766
+ N,
767
+ {
768
+ title: "Dimensions",
769
+ fields: n.dimensions,
770
+ emptyText: "No dimensions selected"
771
+ }
772
+ ),
773
+ /* @__PURE__ */ s(N, { title: "Identifiers", fields: n.identifiers }),
774
+ /* @__PURE__ */ s(N, { title: "Other fields", fields: n.other }),
775
+ /* @__PURE__ */ s(N, { title: "Input bindings", fields: r })
776
+ ] });
777
+ }
778
+ function Ht({
779
+ trace: e
780
+ }) {
781
+ return !e.sourceRefs.length && !e.fieldRefs.length ? null : /* @__PURE__ */ s(ae, { title: "Sources and field refs", children: /* @__PURE__ */ p("div", { style: a.traceLineage, children: [
782
+ /* @__PURE__ */ s(Ut, { sources: e.sourceRefs }),
783
+ /* @__PURE__ */ s(
784
+ N,
785
+ {
786
+ title: "All field refs",
787
+ fields: e.fieldRefs,
788
+ emptyText: "No field refs captured"
789
+ }
790
+ )
791
+ ] }) });
792
+ }
793
+ function Ut({
794
+ sources: e
795
+ }) {
796
+ return /* @__PURE__ */ p("div", { style: a.recipeGroup, children: [
797
+ /* @__PURE__ */ p("div", { style: a.recipeGroupHeader, children: [
798
+ /* @__PURE__ */ s("span", { style: a.recipeGroupTitle, children: "Sources" }),
799
+ /* @__PURE__ */ s("span", { style: a.recipeGroupCount, children: e.length })
800
+ ] }),
801
+ e.length ? /* @__PURE__ */ s("div", { style: a.recipeFieldList, children: e.map((t, r) => /* @__PURE__ */ p(
802
+ "div",
803
+ {
804
+ style: a.recipeFieldRow,
805
+ title: Q(t),
806
+ children: [
807
+ /* @__PURE__ */ s("span", { style: a.recipeFieldName, children: Q(t) }),
808
+ /* @__PURE__ */ s("span", { style: a.recipeFieldMeta, children: t.kind })
809
+ ]
810
+ },
811
+ `${Q(t)}:${r}`
812
+ )) }) : /* @__PURE__ */ s("div", { style: a.recipeEmptyText, children: "No sources captured" })
813
+ ] });
814
+ }
815
+ function N({
816
+ title: e,
817
+ fields: t,
818
+ emptyText: r
819
+ }) {
820
+ return !t.length && !r ? null : /* @__PURE__ */ p("div", { style: a.recipeGroup, children: [
821
+ /* @__PURE__ */ p("div", { style: a.recipeGroupHeader, children: [
822
+ /* @__PURE__ */ s("span", { style: a.recipeGroupTitle, children: e }),
823
+ /* @__PURE__ */ s("span", { style: a.recipeGroupCount, children: t.length })
824
+ ] }),
825
+ t.length ? /* @__PURE__ */ s("div", { style: a.recipeFieldList, children: t.map((n, i) => {
826
+ const d = it(n), l = n.dataType && n.dataType !== "unknown" ? n.dataType : void 0, u = n.source ? Q(n.source) : void 0, c = [d, l, u].filter(Boolean).join(" · ");
827
+ return /* @__PURE__ */ p(
828
+ "div",
829
+ {
830
+ style: a.recipeFieldRow,
831
+ title: c,
832
+ children: [
833
+ /* @__PURE__ */ s("span", { style: a.recipeFieldName, children: d }),
834
+ /* @__PURE__ */ p("span", { style: a.recipeFieldMeta, children: [
835
+ l ? /* @__PURE__ */ s("span", { children: l }) : null,
836
+ l && u ? /* @__PURE__ */ s("span", { style: a.recipeFieldMetaDivider, children: " · " }) : null,
837
+ u ? /* @__PURE__ */ s("span", { children: u }) : null
838
+ ] })
839
+ ]
840
+ },
841
+ `${De(n)}:${i}`
842
+ );
843
+ }) }) : /* @__PURE__ */ s("div", { style: a.recipeEmptyText, children: r })
844
+ ] });
845
+ }
846
+ function Gt({
847
+ inputs: e
848
+ }) {
849
+ return /* @__PURE__ */ p("div", { style: a.inputsAppliedBlock, children: [
850
+ /* @__PURE__ */ p("div", { style: a.inputsAppliedHeader, children: [
851
+ /* @__PURE__ */ s("span", { style: a.inputsAppliedTitle, children: "Inputs applied" }),
852
+ /* @__PURE__ */ s("span", { style: a.inputsAppliedCount, children: e.length })
853
+ ] }),
854
+ /* @__PURE__ */ s("div", { style: a.inputRecipeList, children: e.map((t) => {
855
+ const r = ot(t);
856
+ return /* @__PURE__ */ p(
857
+ "div",
858
+ {
859
+ style: a.inputRecipeRow,
860
+ title: r.title,
861
+ children: [
862
+ /* @__PURE__ */ p("div", { style: a.inputRecipeHeader, children: [
863
+ /* @__PURE__ */ s("span", { style: a.inputRecipeId, title: t.inputId, children: t.inputId }),
864
+ r.operator ? /* @__PURE__ */ s("span", { style: a.inputOperatorBadge, children: r.operator }) : null,
865
+ /* @__PURE__ */ s("span", { style: a.inputValuePreview, title: r.value, children: r.value })
866
+ ] }),
867
+ r.binding ? /* @__PURE__ */ s("div", { style: a.inputRecipeBinding, title: r.binding, children: r.binding }) : null
868
+ ]
869
+ },
870
+ t.inputId
871
+ );
872
+ }) })
873
+ ] });
874
+ }
875
+ function Jt({
876
+ compiledQuery: e,
877
+ compiledSql: t
878
+ }) {
879
+ return (e == null ? void 0 : e.kind) === "sql" ? /* @__PURE__ */ p("div", { style: a.compiledQuery, children: [
880
+ /* @__PURE__ */ s(X, { label: "SQL", value: e.sql }),
881
+ e.pythonCode ? /* @__PURE__ */ s(X, { label: "Python", value: e.pythonCode }) : null,
882
+ e.parameters ? /* @__PURE__ */ s(
883
+ X,
884
+ {
885
+ label: "Parameters",
886
+ value: Ae(e.parameters)
887
+ }
888
+ ) : null
889
+ ] }) : t ? /* @__PURE__ */ s(X, { label: "SQL", value: t }) : /* @__PURE__ */ s(X, { label: "Compiled query", value: Ae(e) });
890
+ }
891
+ function X({
892
+ label: e,
893
+ value: t
894
+ }) {
895
+ return /* @__PURE__ */ p("div", { style: a.codeBlockGroup, children: [
896
+ /* @__PURE__ */ s("div", { style: a.codeBlockLabel, children: e }),
897
+ /* @__PURE__ */ s("pre", { style: a.codeBlock, children: t })
898
+ ] });
899
+ }
900
+ function Yt(e) {
901
+ const t = e.filter(
902
+ (i) => {
903
+ var d;
904
+ return ((d = i.latestAttempt) == null ? void 0 : d.status) === "error";
905
+ }
906
+ ).length, r = e.filter(
907
+ (i) => {
908
+ var d;
909
+ return ((d = i.latestAttempt) == null ? void 0 : d.status) === "loading";
910
+ }
911
+ ).length, n = e.filter(
912
+ (i) => {
913
+ var d, l, u, c;
914
+ return i.clientWarnings.length > 0 || !!((c = (u = (l = (d = i.latestAttempt) == null ? void 0 : d.executionResult) == null ? void 0 : l.validation) == null ? void 0 : u.warnings) != null && c.length);
915
+ }
916
+ ).length;
917
+ return {
918
+ total: e.length,
919
+ failed: t,
920
+ loading: r,
921
+ warningCount: n,
922
+ issueCount: t + n,
923
+ severity: t ? "error" : n ? "warning" : "ok"
924
+ };
925
+ }
926
+ function Xt(e, t) {
927
+ const r = t.trim().toLowerCase();
928
+ return r ? e.filter(
929
+ (n) => [
930
+ n.queryId,
931
+ n.queryLabel,
932
+ n.viewId,
933
+ n.builder,
934
+ n.queryKind,
935
+ fe(n)
936
+ ].filter(Boolean).join(" ").toLowerCase().includes(r)
937
+ ) : e;
938
+ }
939
+ function Zt(e) {
940
+ const t = e.filter((i) => i.queryKind === "inputOptions"), r = new Set(t.map(Re));
941
+ return [
942
+ { title: "Cards", traces: e.filter((i) => !r.has(Re(i))) },
943
+ { title: "Inputs", traces: t }
944
+ ];
945
+ }
946
+ function tt(e, t) {
947
+ if (!(!(t != null && t.traceId) && !(t != null && t.queryId) && !(t != null && t.viewId)))
948
+ return t.traceId ? e.find((r) => r.traceId === t.traceId) : e.find((r) => !(t.queryId && r.queryId !== t.queryId || t.viewId && r.viewId !== t.viewId));
949
+ }
950
+ function er(e, t) {
951
+ if (t.queryId)
952
+ return tt(e, t);
953
+ if (!t.viewId)
954
+ return;
955
+ const r = e.filter((n) => n.viewId === t.viewId);
956
+ return r.length === 1 ? r[0] : void 0;
957
+ }
958
+ function tr(e, t) {
959
+ return !!(e && t && e.traceId === t.traceId);
960
+ }
961
+ function Re(e) {
962
+ return e.traceId;
963
+ }
964
+ function rt(e) {
965
+ switch (e) {
966
+ case "metric":
967
+ return "metric";
968
+ case "records":
969
+ return "records";
970
+ case "matrix":
971
+ return "matrix";
972
+ case "analysis":
973
+ return "analysis";
974
+ case "inputOptions":
975
+ return "inputs";
976
+ case "sql":
977
+ return "sql";
978
+ default:
979
+ return pe(e);
980
+ }
981
+ }
982
+ function Ce(e) {
983
+ return e.queryLabel || e.viewId || e.queryId;
984
+ }
985
+ function fe(e) {
986
+ const t = e.sourceRefs.map(Q);
987
+ return t.length ? t.length === 1 ? t[0] : `${t[0]} + ${t.length - 1} more` : "No source";
988
+ }
989
+ function rr(e) {
990
+ return e.reduce(
991
+ (t, r) => (r.role === "measure" ? t.measures.push(r) : r.role === "date" ? t.timeFields.push(r) : r.role === "dimension" ? t.dimensions.push(r) : r.role === "id" ? t.identifiers.push(r) : t.other.push(r), t),
992
+ {
993
+ measures: [],
994
+ timeFields: [],
995
+ dimensions: [],
996
+ identifiers: [],
997
+ other: []
998
+ }
999
+ );
1000
+ }
1001
+ function nr(e, t, r) {
1002
+ const n = [
1003
+ {
1004
+ label: "Operation",
1005
+ value: ir(e)
1006
+ }
1007
+ ], i = or(e, t, r);
1008
+ i && n.push(i);
1009
+ const d = sr(t);
1010
+ d && n.push({
1011
+ label: "Grouped by",
1012
+ value: d
1013
+ });
1014
+ const l = ar(e.inputsApplied);
1015
+ return l && n.push({
1016
+ label: "Filtered by",
1017
+ value: l
1018
+ }), n.push({
1019
+ label: "Source",
1020
+ value: fe(e)
1021
+ }), n;
1022
+ }
1023
+ function ir(e) {
1024
+ var t, r;
1025
+ if (e.queryKind === "records" && ((t = e.projectionFieldRefs) != null && t.length) && e.projectionFieldRefs.every((n) => n.role === "measure") && ((r = e.latestAttempt) == null ? void 0 : r.rowCount) === 1)
1026
+ return "KPI query";
1027
+ switch (e.queryKind) {
1028
+ case "metric":
1029
+ return "KPI query";
1030
+ case "records":
1031
+ return "Records query";
1032
+ case "matrix":
1033
+ return "Matrix query";
1034
+ case "analysis":
1035
+ return "Analysis query";
1036
+ case "inputOptions":
1037
+ return "Input options query";
1038
+ case "sql":
1039
+ return "SQL query";
1040
+ default:
1041
+ return pe(e.queryKind);
1042
+ }
1043
+ }
1044
+ function or(e, t, r) {
1045
+ if (e.queryKind === "records")
1046
+ return {
1047
+ label: t.measures.length ? "Computes" : "Selects",
1048
+ value: Z(r)
1049
+ };
1050
+ if (e.queryKind === "inputOptions")
1051
+ return {
1052
+ label: "Options from",
1053
+ value: Z(r)
1054
+ };
1055
+ if (t.measures.length)
1056
+ return {
1057
+ label: "Computes",
1058
+ value: Z(t.measures)
1059
+ };
1060
+ if (r.length)
1061
+ return {
1062
+ label: "Uses",
1063
+ value: Z(r)
1064
+ };
1065
+ if (e.queryKind === "sql")
1066
+ return {
1067
+ label: "Inspect",
1068
+ value: "Open compiled query for SQL or Python."
1069
+ };
1070
+ }
1071
+ function sr(e) {
1072
+ const t = [
1073
+ ...e.dimensions,
1074
+ ...e.timeFields
1075
+ ];
1076
+ return t.length ? Z(t) : void 0;
1077
+ }
1078
+ function ar(e) {
1079
+ if (e.length)
1080
+ return nt(
1081
+ e.map((t) => {
1082
+ const r = ot(t);
1083
+ return [
1084
+ t.inputId,
1085
+ r.operator,
1086
+ r.value
1087
+ ].filter(Boolean).join(" ");
1088
+ })
1089
+ );
1090
+ }
1091
+ function Z(e) {
1092
+ return nt(e.map(it));
1093
+ }
1094
+ function nt(e) {
1095
+ const t = e.filter(Boolean);
1096
+ return t.length === 0 ? "-" : t.length === 1 ? t[0] : t.length === 2 ? `${t[0]} and ${t[1]}` : `${t.slice(0, -1).join(", ")}, and ${t[t.length - 1]}`;
1097
+ }
1098
+ function it(e) {
1099
+ return [e.aggregate, e.label || e.name].filter(Boolean).join(" ");
1100
+ }
1101
+ function ot(e) {
1102
+ var l, u, c;
1103
+ const t = e.valuePreview || "redacted", r = ((l = e.fieldRef) == null ? void 0 : l.label) || ((u = e.fieldRef) == null ? void 0 : u.name), n = (c = e.fieldRef) != null && c.source ? Q(e.fieldRef.source) : void 0, i = [r ? `on ${r}` : void 0, n].filter(Boolean).join(" · "), d = [
1104
+ e.inputId,
1105
+ e.operator,
1106
+ t,
1107
+ i
1108
+ ].filter(Boolean).join(" - ");
1109
+ return {
1110
+ operator: e.operator,
1111
+ value: t,
1112
+ binding: i,
1113
+ title: d
1114
+ };
1115
+ }
1116
+ function Q(e) {
1117
+ return e.kind === "semantic" ? e.datasetName || e.datasetId || e.domainId : e.kind === "physical" ? [
1118
+ e.schemaName,
1119
+ e.tableName
1120
+ ].filter(Boolean).join(".") || e.tableName : e.connectionId ? `SQL ${e.connectionId}` : "SQL source";
1121
+ }
1122
+ function dr(e) {
1123
+ return typeof e == "number" ? e.toLocaleString() : "-";
1124
+ }
1125
+ function lr(e) {
1126
+ return typeof e == "number" ? `${Math.round(e)}ms` : "-";
1127
+ }
1128
+ function ur(e) {
1129
+ return Ae(e);
1130
+ }
1131
+ function Ae(e) {
1132
+ return JSON.stringify(e, null, 2) ?? "undefined";
1133
+ }
1134
+ function cr(e) {
1135
+ switch (e.type) {
1136
+ case "query_started":
1137
+ return "Started";
1138
+ case "query_succeeded":
1139
+ return "Succeeded";
1140
+ case "query_failed":
1141
+ return "Failed";
1142
+ case "query_ignored_stale":
1143
+ return "Ignored stale";
1144
+ case "input_changed":
1145
+ return "Input changed";
1146
+ default:
1147
+ return pr(e);
1148
+ }
1149
+ }
1150
+ function fr(e) {
1151
+ return [
1152
+ e.at,
1153
+ "durationMs" in e && typeof e.durationMs == "number" ? `${Math.round(e.durationMs)}ms` : void 0,
1154
+ "rowCount" in e && typeof e.rowCount == "number" ? `${e.rowCount} rows` : void 0,
1155
+ "reason" in e ? e.reason : void 0,
1156
+ "errorMessage" in e ? e.errorMessage : void 0
1157
+ ].filter(Boolean).join(" - ");
1158
+ }
1159
+ function pr(e) {
1160
+ throw new Error(`Unsupported Semaphor trace event: ${JSON.stringify(e)}`);
1161
+ }
1162
+ function ye(e) {
1163
+ return Array.isArray(e) ? e.filter((t) => typeof t == "string") : [];
1164
+ }
1165
+ function mr(e) {
1166
+ return e === "relative" ? {
1167
+ position: "relative",
1168
+ top: "auto",
1169
+ right: "auto",
1170
+ bottom: "auto",
1171
+ left: "auto"
1172
+ } : {
1173
+ top: e.startsWith("top") ? 20 : "auto",
1174
+ right: e.endsWith("right") ? 20 : "auto",
1175
+ bottom: e.startsWith("bottom") ? 20 : "auto",
1176
+ left: e.endsWith("left") ? 20 : "auto"
1177
+ };
1178
+ }
1179
+ function gr(e) {
1180
+ return e === "error" ? {
1181
+ borderColor: "var(--sd-error-border)",
1182
+ background: "var(--sd-error-bg)",
1183
+ color: "var(--sd-error-fg)"
1184
+ } : e === "warning" ? {
1185
+ borderColor: "var(--sd-warning-border)",
1186
+ background: "var(--sd-warning-bg)",
1187
+ color: "var(--sd-warning-fg)"
1188
+ } : {
1189
+ borderColor: "var(--sd-success-border)",
1190
+ background: "var(--sd-success-bg)",
1191
+ color: "var(--sd-success-fg)"
1192
+ };
1193
+ }
1194
+ function hr(e) {
1195
+ return e === "right" ? {
1196
+ top: 16,
1197
+ right: 16,
1198
+ bottom: 16,
1199
+ left: "auto",
1200
+ width: "min(720px, calc(100vw - 32px))",
1201
+ height: "auto",
1202
+ borderRadius: 6
1203
+ } : {
1204
+ top: "auto",
1205
+ right: 16,
1206
+ bottom: 16,
1207
+ left: 16,
1208
+ width: "auto",
1209
+ height: "min(420px, 45vh)",
1210
+ borderRadius: 6
1211
+ };
1212
+ }
1213
+ function yr(e) {
1214
+ return e === "right" ? {
1215
+ gridTemplateColumns: "minmax(210px, 280px) minmax(0, 1fr)"
1216
+ } : {
1217
+ gridTemplateColumns: "minmax(260px, 340px) minmax(0, 1fr)"
1218
+ };
1219
+ }
1220
+ function vr(e) {
1221
+ return {
1222
+ borderRight: "1px solid var(--sd-border)",
1223
+ borderBottom: 0
1224
+ };
1225
+ }
1226
+ function st(e) {
1227
+ return e === "error" ? { background: "var(--sd-error-dot)" } : e === "success" ? { background: "var(--sd-success-dot)" } : e === "loading" ? { background: "var(--sd-loading-dot)" } : { background: "var(--sd-idle-dot)" };
1228
+ }
1229
+ function br(e) {
1230
+ return e === "error" ? {
1231
+ borderColor: "var(--sd-error-border)",
1232
+ color: "var(--sd-error-fg)"
1233
+ } : e === "success" ? {
1234
+ borderColor: "var(--sd-success-border)",
1235
+ color: "var(--sd-success-fg)"
1236
+ } : e === "loading" ? {
1237
+ borderColor: "var(--sd-loading-border)",
1238
+ color: "var(--sd-loading-fg)"
1239
+ } : {
1240
+ borderColor: "var(--sd-border)",
1241
+ color: "var(--sd-fg-muted)"
1242
+ };
1243
+ }
1244
+ const Me = "semaphor-devtools-stylesheet", $ = "semaphor-devtools", Sr = `
1245
+ .${$} {
1246
+ --sd-bg: #ffffff;
1247
+ --sd-bg-muted: #fafafa;
1248
+ --sd-bg-raised: #ffffff;
1249
+ --sd-bg-accent: #f4f4f5;
1250
+ --sd-fg: #18181b;
1251
+ --sd-fg-muted: #71717a;
1252
+ --sd-fg-subtle: #a1a1aa;
1253
+ --sd-border: #e4e4e7;
1254
+ --sd-border-soft: #f4f4f5;
1255
+ --sd-border-strong: #d4d4d8;
1256
+ --sd-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
1257
+ --sd-success-bg: #f0fdf4;
1258
+ --sd-success-fg: #166534;
1259
+ --sd-success-border: #bbf7d0;
1260
+ --sd-success-dot: #16a34a;
1261
+ --sd-warning-bg: #fff7ed;
1262
+ --sd-warning-fg: #9a3412;
1263
+ --sd-warning-border: #fed7aa;
1264
+ --sd-warning-dot: #f59e0b;
1265
+ --sd-error-bg: #fef2f2;
1266
+ --sd-error-fg: #991b1b;
1267
+ --sd-error-border: #fecaca;
1268
+ --sd-error-dot: #dc2626;
1269
+ --sd-loading-bg: #eff6ff;
1270
+ --sd-loading-fg: #1d4ed8;
1271
+ --sd-loading-border: #bfdbfe;
1272
+ --sd-loading-dot: #2563eb;
1273
+ --sd-idle-dot: #94a3b8;
1274
+ }
1275
+
1276
+ @media (prefers-color-scheme: dark) {
1277
+ .${$} {
1278
+ --sd-bg: #09090b;
1279
+ --sd-bg-muted: #18181b;
1280
+ --sd-bg-raised: #18181b;
1281
+ --sd-bg-accent: #1f1f23;
1282
+ --sd-fg: #fafafa;
1283
+ --sd-fg-muted: #a1a1aa;
1284
+ --sd-fg-subtle: #71717a;
1285
+ --sd-border: #27272a;
1286
+ --sd-border-soft: #1f1f23;
1287
+ --sd-border-strong: #3f3f46;
1288
+ --sd-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
1289
+ --sd-success-bg: rgba(34, 197, 94, 0.12);
1290
+ --sd-success-fg: #86efac;
1291
+ --sd-success-border: rgba(34, 197, 94, 0.35);
1292
+ --sd-warning-bg: rgba(249, 115, 22, 0.12);
1293
+ --sd-warning-fg: #fdba74;
1294
+ --sd-warning-border: rgba(249, 115, 22, 0.35);
1295
+ --sd-error-bg: rgba(239, 68, 68, 0.12);
1296
+ --sd-error-fg: #fca5a5;
1297
+ --sd-error-border: rgba(239, 68, 68, 0.35);
1298
+ --sd-loading-bg: rgba(59, 130, 246, 0.12);
1299
+ --sd-loading-fg: #93c5fd;
1300
+ --sd-loading-border: rgba(59, 130, 246, 0.35);
1301
+ }
1302
+ }
1303
+
1304
+ .${$}-source {
1305
+ display: -webkit-box;
1306
+ -webkit-line-clamp: 2;
1307
+ -webkit-box-orient: vertical;
1308
+ overflow: hidden;
1309
+ word-break: break-all;
1310
+ }
1311
+ `;
1312
+ function at() {
1313
+ if (typeof document > "u" || document.getElementById(Me))
1314
+ return;
1315
+ const e = document.createElement("style");
1316
+ e.id = Me, e.textContent = Sr, document.head.appendChild(e);
1317
+ }
1318
+ const ie = 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif', oe = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace", ve = {
1319
+ color: "var(--sd-fg-muted)",
1320
+ fontSize: 10,
1321
+ fontWeight: 600,
1322
+ textTransform: "uppercase",
1323
+ letterSpacing: "0.08em"
1324
+ }, a = {
1325
+ launcher: {
1326
+ position: "fixed",
1327
+ bottom: 20,
1328
+ zIndex: 2147483e3,
1329
+ display: "inline-flex",
1330
+ alignItems: "center",
1331
+ gap: 7,
1332
+ height: 36,
1333
+ minWidth: 36,
1334
+ padding: "0 10px",
1335
+ borderWidth: 1,
1336
+ borderStyle: "solid",
1337
+ borderRadius: 6,
1338
+ boxShadow: "var(--sd-shadow)",
1339
+ font: `600 12px/1.2 ${ie}`,
1340
+ cursor: "pointer"
1341
+ },
1342
+ launcherText: {
1343
+ fontVariantNumeric: "tabular-nums"
1344
+ },
1345
+ launcherIssueCount: {
1346
+ display: "grid",
1347
+ minWidth: 16,
1348
+ height: 16,
1349
+ placeItems: "center",
1350
+ borderRadius: 8,
1351
+ background: "currentColor",
1352
+ color: "var(--sd-bg)",
1353
+ fontSize: 10,
1354
+ lineHeight: "16px"
1355
+ },
1356
+ logoMark: {
1357
+ display: "grid",
1358
+ width: 18,
1359
+ height: 18,
1360
+ placeItems: "center",
1361
+ flex: "0 0 auto",
1362
+ borderRadius: 4,
1363
+ background: "var(--sd-fg)",
1364
+ color: "var(--sd-bg)"
1365
+ },
1366
+ panel: {
1367
+ position: "fixed",
1368
+ top: 16,
1369
+ right: 16,
1370
+ bottom: 16,
1371
+ zIndex: 2147483001,
1372
+ width: "min(720px, calc(100vw - 32px))",
1373
+ display: "flex",
1374
+ flexDirection: "column",
1375
+ overflow: "hidden",
1376
+ border: "1px solid var(--sd-border)",
1377
+ borderRadius: 6,
1378
+ background: "var(--sd-bg)",
1379
+ color: "var(--sd-fg)",
1380
+ boxShadow: "var(--sd-shadow)",
1381
+ font: `13px/1.4 ${ie}`
1382
+ },
1383
+ panelFullscreen: {
1384
+ top: 0,
1385
+ right: 0,
1386
+ bottom: 0,
1387
+ left: 0,
1388
+ width: "100vw",
1389
+ height: "100vh",
1390
+ borderRadius: 0
1391
+ },
1392
+ panelHeader: {
1393
+ display: "flex",
1394
+ alignItems: "center",
1395
+ justifyContent: "space-between",
1396
+ gap: 12,
1397
+ padding: "10px 12px",
1398
+ borderBottom: "1px solid var(--sd-border)"
1399
+ },
1400
+ panelTitleBlock: {
1401
+ minWidth: 0
1402
+ },
1403
+ panelTitle: {
1404
+ fontSize: 13,
1405
+ fontWeight: 600
1406
+ },
1407
+ panelSubtitle: {
1408
+ marginTop: 2,
1409
+ color: "var(--sd-fg-muted)",
1410
+ fontSize: 11
1411
+ },
1412
+ panelActions: {
1413
+ display: "flex",
1414
+ alignItems: "center",
1415
+ gap: 6
1416
+ },
1417
+ iconButton: {
1418
+ display: "grid",
1419
+ width: 28,
1420
+ height: 28,
1421
+ placeItems: "center",
1422
+ borderWidth: 1,
1423
+ borderStyle: "solid",
1424
+ borderColor: "var(--sd-border)",
1425
+ borderRadius: 5,
1426
+ background: "var(--sd-bg)",
1427
+ color: "var(--sd-fg-muted)",
1428
+ cursor: "pointer"
1429
+ },
1430
+ searchBox: {
1431
+ display: "flex",
1432
+ alignItems: "center",
1433
+ gap: 8,
1434
+ margin: 10,
1435
+ height: 28,
1436
+ padding: "0 8px",
1437
+ borderWidth: 1,
1438
+ borderStyle: "solid",
1439
+ borderColor: "var(--sd-border)",
1440
+ borderRadius: 5,
1441
+ color: "var(--sd-fg-muted)"
1442
+ },
1443
+ searchInput: {
1444
+ minWidth: 0,
1445
+ flex: 1,
1446
+ border: 0,
1447
+ outline: 0,
1448
+ background: "transparent",
1449
+ color: "var(--sd-fg)",
1450
+ font: `12px/1.4 ${ie}`
1451
+ },
1452
+ panelBody: {
1453
+ display: "grid",
1454
+ gridTemplateColumns: "minmax(210px, 280px) minmax(0, 1fr)",
1455
+ minHeight: 0,
1456
+ flex: 1,
1457
+ borderTop: "1px solid var(--sd-border-soft)"
1458
+ },
1459
+ queryList: {
1460
+ minHeight: 0,
1461
+ overflowY: "auto",
1462
+ padding: 8,
1463
+ borderRight: "1px solid var(--sd-border)",
1464
+ background: "var(--sd-bg-muted)"
1465
+ },
1466
+ queryGroup: {
1467
+ display: "grid",
1468
+ gap: 3,
1469
+ marginBottom: 8
1470
+ },
1471
+ queryGroupHeader: {
1472
+ display: "flex",
1473
+ alignItems: "center",
1474
+ justifyContent: "space-between",
1475
+ padding: "4px 6px 3px",
1476
+ ...ve
1477
+ },
1478
+ queryGroupCount: {
1479
+ color: "var(--sd-fg-subtle)",
1480
+ fontVariantNumeric: "tabular-nums"
1481
+ },
1482
+ queryGroupEmpty: {
1483
+ padding: "7px 8px",
1484
+ color: "var(--sd-fg-subtle)",
1485
+ fontSize: 11
1486
+ },
1487
+ queryListItem: {
1488
+ display: "grid",
1489
+ gap: 3,
1490
+ width: "100%",
1491
+ padding: "7px 8px",
1492
+ borderWidth: 1,
1493
+ borderStyle: "solid",
1494
+ borderColor: "transparent",
1495
+ borderRadius: 5,
1496
+ background: "transparent",
1497
+ color: "var(--sd-fg)",
1498
+ textAlign: "left",
1499
+ cursor: "pointer"
1500
+ },
1501
+ queryListItemSelected: {
1502
+ borderColor: "var(--sd-border-strong)",
1503
+ background: "var(--sd-bg-raised)"
1504
+ },
1505
+ queryListItemHeader: {
1506
+ display: "flex",
1507
+ alignItems: "center",
1508
+ gap: 7,
1509
+ minWidth: 0
1510
+ },
1511
+ statusDot: {
1512
+ width: 7,
1513
+ height: 7,
1514
+ flex: "0 0 auto",
1515
+ borderRadius: 999
1516
+ },
1517
+ queryListTitle: {
1518
+ flex: 1,
1519
+ minWidth: 0,
1520
+ overflow: "hidden",
1521
+ textOverflow: "ellipsis",
1522
+ whiteSpace: "nowrap",
1523
+ fontSize: 12,
1524
+ fontWeight: 650,
1525
+ color: "var(--sd-fg)"
1526
+ },
1527
+ queryListKindChip: {
1528
+ flex: "0 0 auto",
1529
+ color: "var(--sd-fg-subtle)",
1530
+ fontSize: 9,
1531
+ fontWeight: 600,
1532
+ textTransform: "uppercase",
1533
+ letterSpacing: "0.08em"
1534
+ },
1535
+ queryListSource: {
1536
+ minWidth: 0,
1537
+ paddingLeft: 14,
1538
+ color: "var(--sd-fg-muted)",
1539
+ fontSize: 11,
1540
+ lineHeight: 1.35
1541
+ },
1542
+ detailsPane: {
1543
+ minHeight: 0,
1544
+ overflowY: "auto",
1545
+ padding: 16
1546
+ },
1547
+ detailsHeader: {
1548
+ display: "grid",
1549
+ gap: 6,
1550
+ marginBottom: 14
1551
+ },
1552
+ detailsHeaderTopRow: {
1553
+ display: "flex",
1554
+ alignItems: "center",
1555
+ gap: 8,
1556
+ minWidth: 0
1557
+ },
1558
+ detailsHeaderStatusDot: {
1559
+ width: 8,
1560
+ height: 8,
1561
+ flex: "0 0 auto",
1562
+ borderRadius: 999
1563
+ },
1564
+ detailsTitle: {
1565
+ flex: 1,
1566
+ minWidth: 0,
1567
+ overflow: "hidden",
1568
+ textOverflow: "ellipsis",
1569
+ whiteSpace: "nowrap",
1570
+ fontSize: 14,
1571
+ fontWeight: 700,
1572
+ color: "var(--sd-fg)"
1573
+ },
1574
+ detailsKindChip: {
1575
+ flex: "0 0 auto",
1576
+ padding: "2px 6px",
1577
+ borderRadius: 3,
1578
+ background: "var(--sd-bg-accent)",
1579
+ color: "var(--sd-fg-muted)",
1580
+ fontSize: 10,
1581
+ fontWeight: 600,
1582
+ textTransform: "uppercase",
1583
+ letterSpacing: "0.08em"
1584
+ },
1585
+ detailsCaption: {
1586
+ display: "flex",
1587
+ flexWrap: "wrap",
1588
+ alignItems: "center",
1589
+ columnGap: 10,
1590
+ rowGap: 2,
1591
+ color: "var(--sd-fg-muted)",
1592
+ fontSize: 11
1593
+ },
1594
+ detailsCaptionItem: {
1595
+ display: "inline-flex",
1596
+ alignItems: "center",
1597
+ gap: 4
1598
+ },
1599
+ detailsCaptionItemMono: {
1600
+ fontFamily: oe
1601
+ },
1602
+ detailsCaptionLabel: {
1603
+ color: "var(--sd-fg-subtle)"
1604
+ },
1605
+ detailsCaptionValue: {
1606
+ color: "var(--sd-fg)",
1607
+ fontVariantNumeric: "tabular-nums"
1608
+ },
1609
+ disclosure: {
1610
+ marginTop: 16
1611
+ },
1612
+ disclosureSummary: {
1613
+ cursor: "pointer",
1614
+ ...ve
1615
+ },
1616
+ disclosureBody: {
1617
+ marginTop: 8
1618
+ },
1619
+ alertCard: {
1620
+ marginTop: 12,
1621
+ padding: "8px 10px",
1622
+ borderWidth: 1,
1623
+ borderStyle: "solid",
1624
+ borderRadius: 5,
1625
+ fontSize: 12,
1626
+ lineHeight: 1.45
1627
+ },
1628
+ alertCardError: {
1629
+ borderColor: "var(--sd-error-border)",
1630
+ background: "var(--sd-error-bg)",
1631
+ color: "var(--sd-error-fg)"
1632
+ },
1633
+ alertCardWarning: {
1634
+ borderColor: "var(--sd-warning-border)",
1635
+ background: "var(--sd-warning-bg)",
1636
+ color: "var(--sd-warning-fg)"
1637
+ },
1638
+ alertCardTitle: {
1639
+ fontWeight: 600,
1640
+ textTransform: "uppercase",
1641
+ letterSpacing: "0.08em",
1642
+ fontSize: 10,
1643
+ marginBottom: 4
1644
+ },
1645
+ alertCardList: {
1646
+ margin: 0,
1647
+ paddingLeft: 16,
1648
+ display: "grid",
1649
+ gap: 3
1650
+ },
1651
+ recipe: {
1652
+ display: "grid",
1653
+ gap: 12
1654
+ },
1655
+ traceLineage: {
1656
+ display: "grid",
1657
+ gap: 12
1658
+ },
1659
+ recipeSummary: {
1660
+ display: "grid",
1661
+ gap: 4,
1662
+ padding: "8px 10px",
1663
+ border: "1px solid var(--sd-border)",
1664
+ borderRadius: 5,
1665
+ background: "var(--sd-bg-muted)",
1666
+ color: "var(--sd-fg)",
1667
+ fontSize: 12
1668
+ },
1669
+ recipeSummaryRow: {
1670
+ display: "grid",
1671
+ gridTemplateColumns: "76px minmax(0, 1fr)",
1672
+ gap: 8,
1673
+ minWidth: 0,
1674
+ alignItems: "baseline"
1675
+ },
1676
+ recipeSummaryLabel: {
1677
+ color: "var(--sd-fg-subtle)",
1678
+ fontSize: 10,
1679
+ fontWeight: 600,
1680
+ textTransform: "uppercase",
1681
+ letterSpacing: "0.08em"
1682
+ },
1683
+ recipeSummaryValue: {
1684
+ minWidth: 0,
1685
+ overflow: "hidden",
1686
+ textOverflow: "ellipsis",
1687
+ whiteSpace: "nowrap",
1688
+ color: "var(--sd-fg)",
1689
+ fontSize: 12
1690
+ },
1691
+ recipeGroup: {
1692
+ display: "grid",
1693
+ gap: 4
1694
+ },
1695
+ recipeGroupHeader: {
1696
+ display: "flex",
1697
+ alignItems: "baseline",
1698
+ justifyContent: "space-between",
1699
+ gap: 8,
1700
+ paddingBottom: 4,
1701
+ borderBottom: "1px solid var(--sd-border-soft)"
1702
+ },
1703
+ recipeGroupTitle: {
1704
+ color: "var(--sd-fg-muted)",
1705
+ fontSize: 10,
1706
+ fontWeight: 600,
1707
+ textTransform: "uppercase",
1708
+ letterSpacing: "0.08em"
1709
+ },
1710
+ recipeGroupCount: {
1711
+ color: "var(--sd-fg-subtle)",
1712
+ fontSize: 10,
1713
+ fontVariantNumeric: "tabular-nums"
1714
+ },
1715
+ recipeFieldList: {
1716
+ display: "grid"
1717
+ },
1718
+ recipeEmptyText: {
1719
+ padding: "5px 0",
1720
+ color: "var(--sd-fg-subtle)",
1721
+ fontSize: 11
1722
+ },
1723
+ recipeFieldRow: {
1724
+ display: "grid",
1725
+ gridTemplateColumns: "minmax(0, 1fr) minmax(0, auto)",
1726
+ alignItems: "center",
1727
+ gap: 10,
1728
+ minHeight: 26,
1729
+ padding: "4px 0",
1730
+ borderBottom: "1px solid var(--sd-border-soft)"
1731
+ },
1732
+ recipeFieldName: {
1733
+ minWidth: 0,
1734
+ overflow: "hidden",
1735
+ textOverflow: "ellipsis",
1736
+ whiteSpace: "nowrap",
1737
+ color: "var(--sd-fg)",
1738
+ fontSize: 12,
1739
+ fontWeight: 500
1740
+ },
1741
+ recipeFieldMeta: {
1742
+ minWidth: 0,
1743
+ display: "inline-flex",
1744
+ alignItems: "baseline",
1745
+ overflow: "hidden",
1746
+ textOverflow: "ellipsis",
1747
+ whiteSpace: "nowrap",
1748
+ color: "var(--sd-fg-subtle)",
1749
+ fontSize: 11,
1750
+ textAlign: "right"
1751
+ },
1752
+ recipeFieldMetaDivider: {
1753
+ color: "var(--sd-fg-subtle)",
1754
+ margin: "0 4px"
1755
+ },
1756
+ inputsAppliedBlock: {
1757
+ marginTop: 16,
1758
+ padding: "10px 12px",
1759
+ border: "1px solid var(--sd-border)",
1760
+ borderLeft: "2px solid var(--sd-fg-muted)",
1761
+ borderRadius: 5,
1762
+ background: "var(--sd-bg-muted)"
1763
+ },
1764
+ inputsAppliedHeader: {
1765
+ display: "flex",
1766
+ alignItems: "baseline",
1767
+ justifyContent: "space-between",
1768
+ gap: 8,
1769
+ marginBottom: 6
1770
+ },
1771
+ inputsAppliedTitle: {
1772
+ color: "var(--sd-fg)",
1773
+ fontSize: 10,
1774
+ fontWeight: 700,
1775
+ textTransform: "uppercase",
1776
+ letterSpacing: "0.08em"
1777
+ },
1778
+ inputsAppliedCount: {
1779
+ color: "var(--sd-fg-subtle)",
1780
+ fontSize: 10,
1781
+ fontVariantNumeric: "tabular-nums"
1782
+ },
1783
+ inputRecipeList: {
1784
+ display: "grid"
1785
+ },
1786
+ inputRecipeRow: {
1787
+ display: "grid",
1788
+ gap: 2,
1789
+ minWidth: 0,
1790
+ padding: "6px 0",
1791
+ borderBottom: "1px solid var(--sd-border-soft)"
1792
+ },
1793
+ inputRecipeHeader: {
1794
+ display: "flex",
1795
+ alignItems: "center",
1796
+ gap: 8,
1797
+ minWidth: 0
1798
+ },
1799
+ inputRecipeId: {
1800
+ flex: "0 0 auto",
1801
+ maxWidth: "40%",
1802
+ overflow: "hidden",
1803
+ textOverflow: "ellipsis",
1804
+ whiteSpace: "nowrap",
1805
+ color: "var(--sd-fg)",
1806
+ fontFamily: oe,
1807
+ fontSize: 11,
1808
+ fontWeight: 600
1809
+ },
1810
+ inputOperatorBadge: {
1811
+ display: "inline-flex",
1812
+ flex: "0 0 auto",
1813
+ alignItems: "center",
1814
+ height: 16,
1815
+ padding: "0 5px",
1816
+ borderRadius: 3,
1817
+ background: "var(--sd-bg-accent)",
1818
+ color: "var(--sd-fg-muted)",
1819
+ fontFamily: oe,
1820
+ fontSize: 10,
1821
+ textTransform: "uppercase",
1822
+ letterSpacing: "0.06em"
1823
+ },
1824
+ inputValuePreview: {
1825
+ flex: 1,
1826
+ minWidth: 0,
1827
+ overflow: "hidden",
1828
+ textOverflow: "ellipsis",
1829
+ whiteSpace: "nowrap",
1830
+ color: "var(--sd-fg)",
1831
+ fontSize: 12,
1832
+ textAlign: "right"
1833
+ },
1834
+ inputRecipeBinding: {
1835
+ minWidth: 0,
1836
+ overflow: "hidden",
1837
+ textOverflow: "ellipsis",
1838
+ whiteSpace: "nowrap",
1839
+ color: "var(--sd-fg-muted)",
1840
+ fontSize: 11
1841
+ },
1842
+ eventList: {
1843
+ display: "grid"
1844
+ },
1845
+ eventRow: {
1846
+ display: "grid",
1847
+ gridTemplateColumns: "96px minmax(0, 1fr)",
1848
+ gap: 10,
1849
+ padding: "6px 0",
1850
+ borderBottom: "1px solid var(--sd-border-soft)"
1851
+ },
1852
+ eventType: {
1853
+ color: "var(--sd-fg)",
1854
+ fontWeight: 600,
1855
+ fontSize: 12
1856
+ },
1857
+ eventMeta: {
1858
+ minWidth: 0,
1859
+ overflow: "hidden",
1860
+ textOverflow: "ellipsis",
1861
+ whiteSpace: "nowrap",
1862
+ color: "var(--sd-fg-muted)",
1863
+ fontSize: 11
1864
+ },
1865
+ mutedText: {
1866
+ color: "var(--sd-fg-muted)",
1867
+ fontSize: 12
1868
+ },
1869
+ compiledQuery: {
1870
+ display: "grid",
1871
+ gap: 10
1872
+ },
1873
+ codeBlockGroup: {
1874
+ display: "grid",
1875
+ gap: 5
1876
+ },
1877
+ codeBlockLabel: {
1878
+ ...ve
1879
+ },
1880
+ codeBlock: {
1881
+ maxHeight: 260,
1882
+ margin: 0,
1883
+ overflow: "auto",
1884
+ padding: "8px 10px",
1885
+ border: "1px solid var(--sd-border)",
1886
+ borderRadius: 5,
1887
+ background: "var(--sd-bg-muted)",
1888
+ color: "var(--sd-fg)",
1889
+ fontFamily: oe,
1890
+ fontSize: 11,
1891
+ lineHeight: 1.5,
1892
+ whiteSpace: "pre-wrap"
1893
+ },
1894
+ emptyState: {
1895
+ padding: 10,
1896
+ color: "var(--sd-fg-muted)",
1897
+ textAlign: "center",
1898
+ fontSize: 12
1899
+ },
1900
+ inspectButton: {
1901
+ display: "inline-flex",
1902
+ alignItems: "center",
1903
+ gap: 5,
1904
+ height: 24,
1905
+ maxWidth: "100%",
1906
+ padding: "0 7px",
1907
+ borderWidth: 1,
1908
+ borderStyle: "solid",
1909
+ borderRadius: 5,
1910
+ background: "var(--sd-bg)",
1911
+ font: `600 11px/1 ${ie}`,
1912
+ cursor: "pointer"
1913
+ },
1914
+ inspectButtonText: {
1915
+ overflow: "hidden",
1916
+ textOverflow: "ellipsis",
1917
+ whiteSpace: "nowrap"
1918
+ }
1919
+ };
1920
+ function dt(e) {
1921
+ return {
1922
+ ...e,
1923
+ order: [],
1924
+ entries: {},
1925
+ sequence: 0
1926
+ };
1927
+ }
1928
+ function xr(e, t) {
1929
+ if (t.type === "config")
1930
+ return t.config.enabled ? {
1931
+ ...e,
1932
+ ...t.config
1933
+ } : dt(t.config);
1934
+ if (!e.enabled)
1935
+ return e;
1936
+ switch (t.type) {
1937
+ case "register":
1938
+ return Rr(wr(e, t.descriptor));
1939
+ case "unregister":
1940
+ return Ir(e, t.traceKey);
1941
+ case "event":
1942
+ return qr(e, t);
1943
+ default:
1944
+ return e;
1945
+ }
1946
+ }
1947
+ function wr(e, t) {
1948
+ const r = e.entries[t.traceKey], n = r ? e.sequence : e.sequence + 1, i = Oe(), d = {
1949
+ ...r || Ar(t),
1950
+ ...lt(t),
1951
+ traceKey: t.traceKey,
1952
+ latestAttempt: (r == null ? void 0 : r.latestAttempt) || { status: "idle" },
1953
+ recentEvents: (r == null ? void 0 : r.recentEvents) || [],
1954
+ mounted: !0,
1955
+ registeredAt: (r == null ? void 0 : r.registeredAt) || n,
1956
+ lastEventAt: (r == null ? void 0 : r.lastEventAt) || i
1957
+ };
1958
+ return {
1959
+ ...e,
1960
+ sequence: n,
1961
+ order: r ? e.order : [...e.order, t.traceKey],
1962
+ entries: {
1963
+ ...e.entries,
1964
+ [t.traceKey]: d
1965
+ }
1966
+ };
1967
+ }
1968
+ function Ir(e, t) {
1969
+ const r = e.entries[t];
1970
+ return r ? {
1971
+ ...e,
1972
+ entries: {
1973
+ ...e.entries,
1974
+ [t]: {
1975
+ ...r,
1976
+ mounted: !1
1977
+ }
1978
+ }
1979
+ } : e;
1980
+ }
1981
+ function qr(e, t) {
1982
+ const r = e.entries[t.traceKey];
1983
+ if (!r)
1984
+ return e;
1985
+ const n = Oe(), i = [
1986
+ ...r.recentEvents,
1987
+ t.event
1988
+ ].slice(-e.maxEventsPerQuery);
1989
+ return {
1990
+ ...e,
1991
+ entries: {
1992
+ ...e.entries,
1993
+ [t.traceKey]: {
1994
+ ...r,
1995
+ latestAttempt: t.latestAttempt ? {
1996
+ ...r.latestAttempt,
1997
+ ...t.latestAttempt
1998
+ } : r.latestAttempt,
1999
+ recentEvents: i,
2000
+ lastEventAt: n
2001
+ }
2002
+ }
2003
+ };
2004
+ }
2005
+ function Rr(e) {
2006
+ if (e.order.length <= e.maxQueries)
2007
+ return e;
2008
+ const t = e.order.map((i) => e.entries[i]).filter((i) => !!i).sort((i, d) => i.mounted !== d.mounted ? i.mounted ? 1 : -1 : i.lastEventAt - d.lastEventAt), r = e.order.length - e.maxQueries, n = new Set(
2009
+ t.slice(0, r).map((i) => i.traceKey)
2010
+ );
2011
+ return n.size ? {
2012
+ ...e,
2013
+ order: e.order.filter((i) => !n.has(i)),
2014
+ entries: Object.fromEntries(
2015
+ Object.entries(e.entries).filter(([i]) => !n.has(i))
2016
+ )
2017
+ } : e;
2018
+ }
2019
+ function Ar(e) {
2020
+ const t = Oe();
2021
+ return {
2022
+ ...lt(e),
2023
+ traceKey: e.traceKey,
2024
+ latestAttempt: { status: "idle" },
2025
+ recentEvents: [],
2026
+ mounted: !0,
2027
+ registeredAt: 0,
2028
+ lastEventAt: t
2029
+ };
2030
+ }
2031
+ function lt(e) {
2032
+ const t = $r(e.spec), r = _r(
2033
+ e.spec,
2034
+ e.activeInputs
2035
+ );
2036
+ return {
2037
+ traceId: pt(e.traceKey),
2038
+ viewId: e.viewId,
2039
+ queryId: e.queryId,
2040
+ queryLabel: e.queryLabel || e.viewTitle,
2041
+ queryKind: e.queryKind,
2042
+ builder: e.builder,
2043
+ sourceRefs: Kr(e.intent),
2044
+ projectionFieldRefs: t,
2045
+ inputFieldRefs: r,
2046
+ fieldRefs: Fr(e.intent),
2047
+ inputsApplied: (e.activeInputs || []).map((n) => ({
2048
+ inputId: n.inputId,
2049
+ fieldRef: n.field,
2050
+ operator: n.operator,
2051
+ valuePreview: Lr(n)
2052
+ })),
2053
+ recentEvents: [],
2054
+ clientWarnings: e.clientWarnings
2055
+ };
2056
+ }
2057
+ function de(e) {
2058
+ const {
2059
+ traceKey: t,
2060
+ mounted: r,
2061
+ registeredAt: n,
2062
+ lastEventAt: i,
2063
+ ...d
2064
+ } = e;
2065
+ return d;
2066
+ }
2067
+ function le(e) {
2068
+ return e.enabled ? {
2069
+ enabled: !0,
2070
+ queries: e.order.map((r) => e.entries[r]).filter((r) => !!r).map(de),
2071
+ getQuery: (r) => {
2072
+ const n = Object.values(e.entries).find(
2073
+ (i) => i.queryId === r
2074
+ );
2075
+ return n ? de(n) : void 0;
2076
+ },
2077
+ getQueries: (r) => Object.values(e.entries).filter((n) => n.queryId === r).map(de)
2078
+ } : Xe;
2079
+ }
2080
+ function Er(e) {
2081
+ return {
2082
+ snapshot: () => Tr(le(e())),
2083
+ getQuery: (t) => ze(le(e()).getQuery(t)),
2084
+ getQueries: (t) => le(e()).getQueries(t).map((r) => ze(r)).filter((r) => !!r)
2085
+ };
2086
+ }
2087
+ function Tr(e) {
2088
+ if (!e.enabled)
2089
+ return e;
2090
+ const t = e.queries.map(ut);
2091
+ return {
2092
+ enabled: e.enabled,
2093
+ queries: t,
2094
+ getQuery: (r) => t.find((n) => n.queryId === r),
2095
+ getQueries: (r) => t.filter((n) => n.queryId === r)
2096
+ };
2097
+ }
2098
+ function ze(e) {
2099
+ return e ? ut(e) : void 0;
2100
+ }
2101
+ function ut(e) {
2102
+ var t;
2103
+ return (t = e == null ? void 0 : e.latestAttempt) != null && t.executionResult ? {
2104
+ ...e,
2105
+ latestAttempt: {
2106
+ ...e.latestAttempt,
2107
+ executionResult: kr(
2108
+ e.latestAttempt.executionResult
2109
+ )
2110
+ }
2111
+ } : e;
2112
+ }
2113
+ function kr(e) {
2114
+ const {
2115
+ compiledQuery: t,
2116
+ intent: r,
2117
+ result: n,
2118
+ ...i
2119
+ } = e;
2120
+ return i;
2121
+ }
2122
+ function Cr(e) {
2123
+ return e === void 0 || e === !1 ? {
2124
+ enabled: !1,
2125
+ exposeWindowBridge: !1,
2126
+ maxEventsPerQuery: ge,
2127
+ maxQueries: he
2128
+ } : e === !0 ? {
2129
+ enabled: !0,
2130
+ exposeWindowBridge: !1,
2131
+ maxEventsPerQuery: ge,
2132
+ maxQueries: he
2133
+ } : {
2134
+ enabled: e.enabled !== !1,
2135
+ exposeWindowBridge: e.exposeWindowBridge === !0,
2136
+ maxEventsPerQuery: je(
2137
+ e.maxEventsPerQuery,
2138
+ ge,
2139
+ _t
2140
+ ),
2141
+ maxQueries: je(
2142
+ e.maxQueries,
2143
+ he,
2144
+ Ft
2145
+ )
2146
+ };
2147
+ }
2148
+ function je(e, t, r) {
2149
+ return e === void 0 || !Number.isFinite(e) || !Number.isInteger(e) || e <= 0 ? t : Math.min(e, r);
2150
+ }
2151
+ function Dr(e) {
2152
+ return typeof e.id == "string" && e.id.trim() ? e.id : void 0;
2153
+ }
2154
+ function Or(e) {
2155
+ switch (e) {
2156
+ case "metric":
2157
+ return "semaphor.metric";
2158
+ case "records":
2159
+ return "semaphor.records";
2160
+ case "matrix":
2161
+ return "semaphor.matrix";
2162
+ case "analysis":
2163
+ return "semaphor.analysis";
2164
+ case "inputOptions":
2165
+ return "semaphor.inputOptions";
2166
+ case "sql":
2167
+ return "semaphor.sql";
2168
+ default:
2169
+ return pe(e);
2170
+ }
2171
+ }
2172
+ function pe(e) {
2173
+ throw new Error(`Unsupported Semaphor query kind: ${JSON.stringify(e)}`);
2174
+ }
2175
+ function Lr(e) {
2176
+ if (Br(e))
2177
+ return;
2178
+ const t = e.value;
2179
+ if (t !== void 0) {
2180
+ if (Array.isArray(t)) {
2181
+ const r = t.filter(
2182
+ (n) => typeof n == "string" || typeof n == "number" || typeof n == "boolean"
2183
+ ).map((n) => String(n));
2184
+ if (r.length === t.length && r.length > 0) {
2185
+ const n = r.slice(0, 3).join(", "), i = r.length > 3 ? `, +${r.length - 3} more` : "";
2186
+ return Pe(`${n}${i}`);
2187
+ }
2188
+ return `${t.length} selected`;
2189
+ }
2190
+ return typeof t == "number" || typeof t == "boolean" ? String(t) : typeof t == "string" ? Pe(t) : t && typeof t == "object" ? `object(${Object.keys(t).slice(0, 5).join(",")})` : String(t);
2191
+ }
2192
+ }
2193
+ function Pe(e) {
2194
+ return e.length > 80 ? `${e.slice(0, 77)}...` : e;
2195
+ }
2196
+ function Br(e) {
2197
+ var r;
2198
+ const t = [
2199
+ e.inputId,
2200
+ e.label,
2201
+ (r = e.field) == null ? void 0 : r.name
2202
+ ].filter(Boolean).join(" ").toLowerCase();
2203
+ return ["token", "secret", "password", "email", "phone", "ssn"].some(
2204
+ (n) => t.includes(n)
2205
+ );
2206
+ }
2207
+ function Kr(e) {
2208
+ const t = /* @__PURE__ */ new Map();
2209
+ return ue(e, (r) => {
2210
+ Wr(r) && t.set(ft(r), r);
2211
+ }), [...t.values()];
2212
+ }
2213
+ function $r(e) {
2214
+ switch (e.queryKind) {
2215
+ case "metric":
2216
+ case "analysis":
2217
+ return V([
2218
+ ...e.measures || [],
2219
+ e.primaryMeasure,
2220
+ e.dateField,
2221
+ ...e.dimensions || []
2222
+ ]);
2223
+ case "records":
2224
+ return V(e.fields || []);
2225
+ case "inputOptions":
2226
+ return V([
2227
+ e.labelField,
2228
+ e.valueField,
2229
+ e.searchField,
2230
+ ...e.disambiguationFields || []
2231
+ ]);
2232
+ case "sql":
2233
+ return V(e.fields || []);
2234
+ case "matrix":
2235
+ return V([
2236
+ ...(e.rows || []).map(be),
2237
+ ...(e.columns || []).map(be),
2238
+ ...(e.values || []).map(be)
2239
+ ]);
2240
+ default:
2241
+ return pe(e);
2242
+ }
2243
+ }
2244
+ function _r(e, t) {
2245
+ const r = [
2246
+ ...(e.inputs || []).map(ct),
2247
+ ...(t || []).map((n) => n.field)
2248
+ ];
2249
+ return V(r);
2250
+ }
2251
+ function V(e) {
2252
+ const t = /* @__PURE__ */ new Map();
2253
+ return e.forEach((r) => {
2254
+ r && te(r) && t.set(De(r), r);
2255
+ }), [...t.values()];
2256
+ }
2257
+ function ct(e) {
2258
+ if (!e || typeof e != "object")
2259
+ return;
2260
+ const t = e.toAnalyticsInput;
2261
+ if (typeof t == "function") {
2262
+ const n = t.call(e);
2263
+ return ct(n);
2264
+ }
2265
+ const r = e.field;
2266
+ return te(r) ? r : void 0;
2267
+ }
2268
+ function be(e) {
2269
+ if (te(e))
2270
+ return e;
2271
+ if (!e || typeof e != "object")
2272
+ return;
2273
+ const t = e.field;
2274
+ return te(t) ? t : void 0;
2275
+ }
2276
+ function Fr(e) {
2277
+ const t = /* @__PURE__ */ new Map();
2278
+ return ue(e, (r) => {
2279
+ te(r) && t.set(De(r), r);
2280
+ }), [...t.values()];
2281
+ }
2282
+ function ue(e, t) {
2283
+ if (!(!e || typeof e != "object")) {
2284
+ if (t(e), Array.isArray(e)) {
2285
+ e.forEach((r) => ue(r, t));
2286
+ return;
2287
+ }
2288
+ Object.values(e).forEach(
2289
+ (r) => ue(r, t)
2290
+ );
2291
+ }
2292
+ }
2293
+ function Wr(e) {
2294
+ if (!e || typeof e != "object")
2295
+ return !1;
2296
+ const t = e;
2297
+ return t.kind === "semantic" ? typeof t.domainId == "string" && typeof t.datasetName == "string" : t.kind === "physical" ? typeof t.connectionId == "string" && typeof t.tableName == "string" : t.kind === "sql" ? typeof t.connectionId == "string" : !1;
2298
+ }
2299
+ function te(e) {
2300
+ if (!e || typeof e != "object")
2301
+ return !1;
2302
+ const t = e;
2303
+ return typeof t.name == "string" && (t.source !== void 0 || t.role !== void 0 || t.dataType !== void 0 || t.aggregate !== void 0);
2304
+ }
2305
+ function ft(e) {
2306
+ return e.kind === "semantic" ? [
2307
+ e.kind,
2308
+ e.domainId,
2309
+ e.datasetId || e.datasetName
2310
+ ].join(":") : e.kind === "physical" ? [
2311
+ e.kind,
2312
+ e.connectionId,
2313
+ e.databaseName,
2314
+ e.schemaName,
2315
+ e.tableName
2316
+ ].join(":") : [e.kind, e.connectionId].join(":");
2317
+ }
2318
+ function De(e) {
2319
+ return [
2320
+ e.name,
2321
+ e.role,
2322
+ e.aggregate,
2323
+ e.source ? ft(e.source) : ""
2324
+ ].join(":");
2325
+ }
2326
+ function Nr(e) {
2327
+ const t = e;
2328
+ return typeof (t == null ? void 0 : t.rowCount) == "number" ? t.rowCount : Array.isArray(t == null ? void 0 : t.records) ? t.records.length : void 0;
2329
+ }
2330
+ function Mr(e) {
2331
+ const t = e;
2332
+ return Array.isArray(t == null ? void 0 : t.columns) ? t.columns.length : void 0;
2333
+ }
2334
+ function Ve(e) {
2335
+ const t = e;
2336
+ return t == null ? void 0 : t.executionResult;
2337
+ }
2338
+ function Qe(e) {
2339
+ const t = e;
2340
+ return typeof (t == null ? void 0 : t.requestId) == "string" ? t.requestId : void 0;
2341
+ }
2342
+ function pt(e) {
2343
+ let t = 2166136261;
2344
+ for (let r = 0; r < e.length; r += 1)
2345
+ t ^= e.charCodeAt(r), t = Math.imul(t, 16777619);
2346
+ return (t >>> 0).toString(36);
2347
+ }
2348
+ function se() {
2349
+ return (/* @__PURE__ */ new Date()).toISOString();
2350
+ }
2351
+ function Oe() {
2352
+ return typeof performance < "u" && performance.now ? performance.now() : Date.now();
2353
+ }
2354
+ const zr = [
9
2355
  "records",
10
2356
  "changes",
11
2357
  "drivers",
@@ -13,7 +2359,7 @@ const te = [
13
2359
  "largestPositiveChanges",
14
2360
  "largestNegativeDrivers",
15
2361
  "largestPositiveDrivers"
16
- ], re = [
2362
+ ], jr = [
17
2363
  "records",
18
2364
  "changes",
19
2365
  "drivers",
@@ -22,10 +2368,10 @@ const te = [
22
2368
  "largestNegativeDrivers",
23
2369
  "largestPositiveDrivers"
24
2370
  ];
25
- function U(e) {
2371
+ function mt(e) {
26
2372
  if (!e)
27
2373
  return {};
28
- const t = se(e.executionResult), r = ne(e, t), n = ie(r);
2374
+ const t = Ur(e.executionResult), r = Pr(e, t), n = Qr(r);
29
2375
  return {
30
2376
  ...e,
31
2377
  ...Object.keys(r).length ? { resultSets: r } : {},
@@ -36,84 +2382,84 @@ function U(e) {
36
2382
  } : {}
37
2383
  };
38
2384
  }
39
- function ne(e, t) {
40
- const r = oe(e.resultSets);
41
- for (const i of te) {
2385
+ function Pr(e, t) {
2386
+ const r = Vr(e.resultSets);
2387
+ for (const i of zr) {
42
2388
  if (r[i]) {
43
- r[i] = V(r[i]);
2389
+ r[i] = gt(r[i]);
44
2390
  continue;
45
2391
  }
46
- const u = ae(e[i]);
47
- if (!u.length)
2392
+ const d = Gr(e[i]);
2393
+ if (!d.length)
48
2394
  continue;
49
- const s = t.length ? t : ce(u);
2395
+ const l = t.length ? t : Jr(d);
50
2396
  r[i] = {
51
- records: O(u, s),
52
- columns: s,
53
- rowCount: u.length
2397
+ records: Le(d, l),
2398
+ columns: l,
2399
+ rowCount: d.length
54
2400
  };
55
2401
  }
56
- const n = ue(e.executionResult);
2402
+ const n = Hr(e.executionResult);
57
2403
  return n && n.records.length > 0 && !r.records && (r.records = n), r;
58
2404
  }
59
- function oe(e) {
2405
+ function Vr(e) {
60
2406
  return Object.fromEntries(
61
2407
  Object.entries(e || {}).map(([t, r]) => [
62
2408
  t,
63
- V(r)
2409
+ gt(r)
64
2410
  ])
65
2411
  );
66
2412
  }
67
- function V(e) {
2413
+ function gt(e) {
68
2414
  var t;
69
2415
  return {
70
2416
  ...e,
71
- records: O(
2417
+ records: Le(
72
2418
  e.records || [],
73
2419
  e.columns || []
74
2420
  ),
75
2421
  rowCount: e.rowCount ?? ((t = e.records) == null ? void 0 : t.length) ?? 0
76
2422
  };
77
2423
  }
78
- function ie(e) {
2424
+ function Qr(e) {
79
2425
  var t;
80
- for (const r of re)
2426
+ for (const r of jr)
81
2427
  if ((t = e[r]) != null && t.records.length)
82
2428
  return e[r];
83
2429
  return Object.values(e).find((r) => r.records.length) || Object.values(e)[0];
84
2430
  }
85
- function ue(e) {
2431
+ function Hr(e) {
86
2432
  const t = e == null ? void 0 : e.result;
87
2433
  if (!(!t || t.kind !== "records" && t.kind !== "sql"))
88
2434
  return {
89
- records: O(t.records, t.columns),
2435
+ records: Le(t.records, t.columns),
90
2436
  columns: t.columns,
91
2437
  rowCount: t.rowCount ?? t.records.length
92
2438
  };
93
2439
  }
94
- function se(e) {
2440
+ function Ur(e) {
95
2441
  const t = e == null ? void 0 : e.result;
96
2442
  return !t || t.kind !== "records" && t.kind !== "sql" ? [] : t.columns;
97
2443
  }
98
- function ae(e) {
2444
+ function Gr(e) {
99
2445
  return Array.isArray(e) ? e.filter(
100
2446
  (t) => !!(t && typeof t == "object" && !Array.isArray(t))
101
2447
  ) : [];
102
2448
  }
103
- function O(e, t) {
2449
+ function Le(e, t) {
104
2450
  return t.length ? e.map((r) => {
105
2451
  const n = {};
106
- return t.forEach((i, u) => {
107
- const s = le(r, {
2452
+ return t.forEach((i, d) => {
2453
+ const l = Yr(r, {
108
2454
  name: i.key,
109
2455
  label: i.label,
110
- fallbackNames: [i.name, Object.keys(r)[u]]
2456
+ fallbackNames: [i.name, Object.keys(r)[d]]
111
2457
  });
112
- s !== void 0 && (n[i.key] = s);
2458
+ l !== void 0 && (n[i.key] = l);
113
2459
  }), Object.keys(n).length ? n : r;
114
2460
  }) : e;
115
2461
  }
116
- function ce(e) {
2462
+ function Jr(e) {
117
2463
  return Array.from(
118
2464
  new Set(e.flatMap((r) => Object.keys(r)))
119
2465
  ).map((r) => ({
@@ -122,7 +2468,7 @@ function ce(e) {
122
2468
  label: r
123
2469
  }));
124
2470
  }
125
- function le(e, t) {
2471
+ function Yr(e, t) {
126
2472
  const r = [
127
2473
  t.name,
128
2474
  t.label,
@@ -132,99 +2478,29 @@ function le(e, t) {
132
2478
  if (Object.prototype.hasOwnProperty.call(e, n))
133
2479
  return e[n];
134
2480
  }
135
- function Pe(e) {
136
- return e;
137
- }
138
- function Ne(e) {
139
- return e;
140
- }
141
- const Le = {
142
- filter(e) {
143
- return {
144
- ...e,
145
- kind: "filter"
146
- };
147
- },
148
- control(e) {
149
- return {
150
- ...e,
151
- kind: "control"
152
- };
153
- },
154
- sqlParam(e) {
155
- return {
156
- ...e,
157
- kind: "control",
158
- role: "sqlParam"
159
- };
160
- },
161
- derivedField(e) {
162
- return {
163
- ...e,
164
- kind: "derived_field",
165
- expressionLanguage: e.expressionLanguage || "semaphor_sql_template"
166
- };
167
- },
168
- metric(e) {
169
- return {
170
- ...e,
171
- queryKind: "metric"
172
- };
173
- },
174
- analysis(e) {
175
- return {
176
- ...e,
177
- queryKind: "analysis"
178
- };
179
- },
180
- records(e) {
181
- return {
182
- ...e,
183
- queryKind: "records"
184
- };
185
- },
186
- inputOptions(e) {
187
- return {
188
- ...e,
189
- queryKind: "inputOptions"
190
- };
191
- },
192
- sql(e) {
193
- return {
194
- ...e,
195
- queryKind: "sql"
196
- };
197
- },
198
- matrix(e) {
199
- return {
200
- ...e,
201
- queryKind: "matrix"
202
- };
203
- }
204
- };
205
- function de() {
2481
+ function Xr() {
206
2482
  return {
207
- executeAnalysis: (e, t, r) => h(
2483
+ executeAnalysis: (e, t, r) => P(
208
2484
  e,
209
2485
  t,
210
2486
  r ?? {}
211
- ).then(U),
212
- executeMetric: (e, t) => h(e, t),
213
- executeRecords: (e, t) => h(e, t),
214
- executeInputOptions: (e, t) => h(e, t),
215
- executeSql: (e, t) => h(e, t),
216
- executeMatrix: (e, t) => h(e, t)
2487
+ ).then(mt),
2488
+ executeMetric: (e, t) => P(e, t),
2489
+ executeRecords: (e, t) => P(e, t),
2490
+ executeInputOptions: (e, t) => P(e, t),
2491
+ executeSql: (e, t) => P(e, t),
2492
+ executeMatrix: (e, t) => P(e, t)
217
2493
  };
218
2494
  }
219
- async function h(e, t, r) {
2495
+ async function P(e, t, r) {
220
2496
  if (!t.token)
221
2497
  throw new Error(
222
2498
  "SemaphorDataAppProvider needs a token to execute queries."
223
2499
  );
224
- const n = ye(t), i = fe(e, n);
225
- let u;
2500
+ const n = sn(t), i = en(e, n);
2501
+ let d;
226
2502
  try {
227
- u = await fetch(n, {
2503
+ d = await fetch(n, {
228
2504
  method: "POST",
229
2505
  headers: {
230
2506
  "Content-Type": "application/json",
@@ -237,28 +2513,33 @@ async function h(e, t, r) {
237
2513
  resultShape: e.kind
238
2514
  })
239
2515
  });
240
- } catch (l) {
2516
+ } catch (u) {
241
2517
  throw new Error(
242
- `${i}: ${l instanceof Error ? l.message : String(l)}`
2518
+ `${i}: ${u instanceof Error ? u.message : String(u)}`
243
2519
  );
244
2520
  }
245
- const s = await he(u);
246
- if (!u.ok || s.error)
247
- throw new Error(
248
- `${i}: ${s.error || `Semaphor Data App execution failed with status ${u.status}.`}`
2521
+ const l = await nn(d);
2522
+ if (!d.ok || l.error)
2523
+ throw Zr(
2524
+ `${i}: ${l.error || `Semaphor Data App execution failed with status ${d.status}.`}`,
2525
+ l
249
2526
  );
250
- return s;
2527
+ return l;
2528
+ }
2529
+ function Zr(e, t) {
2530
+ const r = new Error(e);
2531
+ return t.requestId && (r.requestId = t.requestId), t.details !== void 0 && (r.details = t.details), t.executionResult !== void 0 && (r.executionResult = t.executionResult), r;
251
2532
  }
252
- function fe(e, t) {
2533
+ function en(e, t) {
253
2534
  return [
254
2535
  `Semaphor ${e.kind} query`,
255
2536
  e.id ? `id=${e.id}` : void 0,
256
2537
  e.label ? `label=${e.label}` : void 0,
257
- pe(e),
258
- `endpoint=${me(t)}`
2538
+ tn(e),
2539
+ `endpoint=${rn(t)}`
259
2540
  ].filter((r) => !!r).join(" ");
260
2541
  }
261
- function pe(e) {
2542
+ function tn(e) {
262
2543
  const t = "source" in e ? e.source : void 0;
263
2544
  if (!(!t || typeof t != "object")) {
264
2545
  if (t.kind === "semantic")
@@ -277,7 +2558,7 @@ function pe(e) {
277
2558
  return t.connectionId ? `source=${t.connectionId}` : void 0;
278
2559
  }
279
2560
  }
280
- function me(e) {
2561
+ function rn(e) {
281
2562
  if (!e)
282
2563
  return "/api/v1/data-app/execute";
283
2564
  try {
@@ -286,7 +2567,7 @@ function me(e) {
286
2567
  return e;
287
2568
  }
288
2569
  }
289
- async function he(e) {
2570
+ async function nn(e) {
290
2571
  const t = await e.text().catch(() => "");
291
2572
  if (!t.trim())
292
2573
  return e.ok ? {
@@ -299,226 +2580,213 @@ async function he(e) {
299
2580
  error: "Semaphor Data App execution returned invalid JSON.",
300
2581
  details: t
301
2582
  } : {
302
- error: ve(e, t),
2583
+ error: on(e, t),
303
2584
  details: t
304
2585
  };
305
2586
  }
306
2587
  }
307
- function ve(e, t) {
2588
+ function on(e, t) {
308
2589
  const r = e.statusText ? ` ${e.statusText}` : "", n = t.replace(/\s+/g, " ").trim();
309
2590
  return n ? `Semaphor Data App execution failed with status ${e.status}${r}: ${n.slice(0, 240)}` : `Semaphor Data App execution failed with status ${e.status}${r}.`;
310
2591
  }
311
- function ye(e) {
312
- const t = qe(e).replace(/\/+$/, "");
2592
+ function sn(e) {
2593
+ const t = an(e).replace(/\/+$/, "");
313
2594
  return t ? t.endsWith("/api") ? `${t}/v1/data-app/execute` : `${t}/api/v1/data-app/execute` : "/api/v1/data-app/execute";
314
2595
  }
315
- function qe(e) {
2596
+ function an(e) {
316
2597
  if (e.apiBaseUrl)
317
2598
  return e.apiBaseUrl;
318
2599
  if (!e.token)
319
2600
  return "";
320
2601
  try {
321
- return W(e.token).apiServiceUrl || "";
2602
+ return Kt(e.token).apiServiceUrl || "";
322
2603
  } catch {
323
2604
  return "";
324
2605
  }
325
2606
  }
326
- const B = X({});
327
- function Se() {
2607
+ const ht = ce({});
2608
+ function dn() {
328
2609
  if (!(typeof window > "u"))
329
2610
  return window.__SEMAPHOR_DATA_APP_RUNTIME__;
330
2611
  }
331
- function Ae() {
332
- return G(B);
333
- }
334
- function Ue({
335
- token: e,
336
- apiBaseUrl: t,
337
- executor: r,
338
- children: n
339
- }) {
340
- var o;
341
- const i = Se(), u = ((o = i == null ? void 0 : i.authToken) == null ? void 0 : o.accessToken) || e, s = (i == null ? void 0 : i.dataApiBaseUrl) || (i == null ? void 0 : i.apiBaseUrl) || t, l = m(() => de(), []), a = r || l, c = m(
342
- () => ({
343
- token: u,
344
- apiBaseUrl: s,
345
- executor: a
346
- }),
347
- [s, a, u]
348
- );
349
- return /* @__PURE__ */ Z(B.Provider, { value: c, children: n });
2612
+ function ln() {
2613
+ return z(ht);
350
2614
  }
351
- const k = { value: null }, x = {}, ge = { records: [] }, D = { options: [] }, Ie = { records: [] }, E = {};
352
- function ke(e) {
353
- const t = y(e.inputs), r = Y(e);
2615
+ const Se = { value: null }, xe = {}, un = { records: [] }, we = { options: [] }, cn = { records: [] }, Ie = {};
2616
+ function fn(e) {
2617
+ const t = U(e.inputs), r = Rt(e);
354
2618
  try {
355
- const n = F(e), i = v(n);
2619
+ const n = At(e), i = G(n);
356
2620
  return i ? {
357
2621
  error: i,
358
2622
  activeInputs: t,
359
2623
  analysisOptions: r,
360
- queryKey: f(
2624
+ queryKey: I(
361
2625
  void 0,
362
2626
  t,
363
2627
  i,
364
2628
  r
365
2629
  ),
366
- idleData: x
2630
+ idleData: xe
367
2631
  } : {
368
2632
  intent: n,
369
2633
  error: null,
370
2634
  activeInputs: t,
371
2635
  analysisOptions: r,
372
- queryKey: f(n, t, void 0, r),
373
- idleData: x
2636
+ queryKey: I(n, t, void 0, r),
2637
+ idleData: xe
374
2638
  };
375
2639
  } catch (n) {
376
- const i = p(n);
2640
+ const i = F(n);
377
2641
  return {
378
2642
  error: i,
379
2643
  activeInputs: t,
380
2644
  analysisOptions: r,
381
- queryKey: f(
2645
+ queryKey: I(
382
2646
  void 0,
383
2647
  t,
384
2648
  i,
385
2649
  r
386
2650
  ),
387
- idleData: x
2651
+ idleData: xe
388
2652
  };
389
2653
  }
390
2654
  }
391
- function xe(e) {
392
- const t = y(e.inputs);
2655
+ function pn(e) {
2656
+ const t = U(e.inputs);
393
2657
  try {
394
- const r = H(e), n = v(r);
2658
+ const r = Et(e), n = G(r);
395
2659
  return n ? {
396
2660
  error: n,
397
2661
  activeInputs: t,
398
- queryKey: f(void 0, t, n),
399
- idleData: k
2662
+ queryKey: I(void 0, t, n),
2663
+ idleData: Se
400
2664
  } : {
401
2665
  intent: r,
402
2666
  error: null,
403
2667
  activeInputs: t,
404
- queryKey: f(r, t),
405
- idleData: k
2668
+ queryKey: I(r, t),
2669
+ idleData: Se
406
2670
  };
407
2671
  } catch (r) {
408
- const n = p(r);
2672
+ const n = F(r);
409
2673
  return {
410
2674
  error: n,
411
2675
  activeInputs: t,
412
- queryKey: f(void 0, t, n),
413
- idleData: k
2676
+ queryKey: I(void 0, t, n),
2677
+ idleData: Se
414
2678
  };
415
2679
  }
416
2680
  }
417
- function De(e) {
418
- const t = y(e.inputs), r = ge;
2681
+ function mn(e) {
2682
+ const t = U(e.inputs), r = un;
419
2683
  try {
420
- const n = J(e), i = v(n);
2684
+ const n = qt(e), i = G(n);
421
2685
  return i ? {
422
2686
  error: i,
423
2687
  activeInputs: t,
424
- queryKey: f(void 0, t, i),
2688
+ queryKey: I(void 0, t, i),
425
2689
  idleData: r
426
2690
  } : {
427
2691
  intent: n,
428
2692
  error: null,
429
2693
  activeInputs: t,
430
- queryKey: f(n, t),
2694
+ queryKey: I(n, t),
431
2695
  idleData: r
432
2696
  };
433
2697
  } catch (n) {
434
- const i = p(n);
2698
+ const i = F(n);
435
2699
  return {
436
2700
  error: i,
437
2701
  activeInputs: t,
438
- queryKey: f(void 0, t, i),
2702
+ queryKey: I(void 0, t, i),
439
2703
  idleData: r
440
2704
  };
441
2705
  }
442
2706
  }
443
- function Ee(e) {
2707
+ function gn(e) {
2708
+ const t = U(e.inputs);
444
2709
  try {
445
- const t = Q(e), r = v(t);
446
- return r ? {
447
- error: r,
448
- queryKey: f(void 0, void 0, r),
449
- idleData: D
2710
+ const r = It(e), n = G(r);
2711
+ return n ? {
2712
+ error: n,
2713
+ activeInputs: t,
2714
+ queryKey: I(void 0, t, n),
2715
+ idleData: we
450
2716
  } : {
451
- intent: t,
2717
+ intent: r,
452
2718
  error: null,
453
- queryKey: f(t),
454
- idleData: D
2719
+ activeInputs: t,
2720
+ queryKey: I(r, t),
2721
+ idleData: we
455
2722
  };
456
- } catch (t) {
457
- const r = p(t);
2723
+ } catch (r) {
2724
+ const n = F(r);
458
2725
  return {
459
- error: r,
460
- queryKey: f(void 0, void 0, r),
461
- idleData: D
2726
+ error: n,
2727
+ activeInputs: t,
2728
+ queryKey: I(void 0, t, n),
2729
+ idleData: we
462
2730
  };
463
2731
  }
464
2732
  }
465
- function be(e) {
466
- const t = y(e.inputs), r = Ie;
2733
+ function hn(e) {
2734
+ const t = U(e.inputs), r = cn;
467
2735
  try {
468
- const n = M(e), i = v(n);
2736
+ const n = wt(e), i = G(n);
469
2737
  return i ? {
470
2738
  error: i,
471
2739
  activeInputs: t,
472
- queryKey: f(void 0, t, i),
2740
+ queryKey: I(void 0, t, i),
473
2741
  idleData: r
474
2742
  } : {
475
2743
  intent: n,
476
2744
  error: null,
477
2745
  activeInputs: t,
478
- queryKey: f(n, t),
2746
+ queryKey: I(n, t),
479
2747
  idleData: r
480
2748
  };
481
2749
  } catch (n) {
482
- const i = p(n);
2750
+ const i = F(n);
483
2751
  return {
484
2752
  error: i,
485
2753
  activeInputs: t,
486
- queryKey: f(void 0, t, i),
2754
+ queryKey: I(void 0, t, i),
487
2755
  idleData: r
488
2756
  };
489
2757
  }
490
2758
  }
491
- function Re(e) {
492
- const t = y(e.inputs);
2759
+ function yn(e) {
2760
+ const t = U(e.inputs);
493
2761
  try {
494
- const r = z(e), n = v(r);
2762
+ const r = xt(e), n = G(r);
495
2763
  return n ? {
496
2764
  error: n,
497
2765
  activeInputs: t,
498
- queryKey: f(void 0, t, n),
499
- idleData: E
2766
+ queryKey: I(void 0, t, n),
2767
+ idleData: Ie
500
2768
  } : {
501
2769
  intent: r,
502
2770
  error: null,
503
2771
  activeInputs: t,
504
- queryKey: f(r, t),
505
- idleData: E
2772
+ queryKey: I(r, t),
2773
+ idleData: Ie
506
2774
  };
507
2775
  } catch (r) {
508
- const n = p(r);
2776
+ const n = F(r);
509
2777
  return {
510
2778
  error: n,
511
2779
  activeInputs: t,
512
- queryKey: f(void 0, t, n),
513
- idleData: E
2780
+ queryKey: I(void 0, t, n),
2781
+ idleData: Ie
514
2782
  };
515
2783
  }
516
2784
  }
517
- function p(e) {
2785
+ function F(e) {
518
2786
  return e instanceof Error ? e : new Error(String(e));
519
2787
  }
520
- function v(e) {
521
- const t = ee(e);
2788
+ function G(e) {
2789
+ const t = $t(e);
522
2790
  if (t.ok)
523
2791
  return null;
524
2792
  const r = t.errors.map(
@@ -526,7 +2794,7 @@ function v(e) {
526
2794
  ).join("; ");
527
2795
  return new Error(`Invalid Semaphor analytics intent. ${r}`);
528
2796
  }
529
- function f(e, t, r, n) {
2797
+ function I(e, t, r, n) {
530
2798
  return JSON.stringify({
531
2799
  intent: e,
532
2800
  activeInputs: t,
@@ -534,86 +2802,90 @@ function f(e, t, r, n) {
534
2802
  error: r == null ? void 0 : r.message
535
2803
  });
536
2804
  }
537
- function Ve(e) {
538
- const [t, r] = K(e.defaultValue), n = Object.prototype.hasOwnProperty.call(e, "value"), i = n ? e.value : t, u = m(
539
- () => P(e.options),
2805
+ function Kn(e) {
2806
+ const [t, r] = H(e.defaultValue), n = Object.prototype.hasOwnProperty.call(e, "value"), i = n ? e.value : t, d = b(
2807
+ () => Ge(e.options),
540
2808
  [e.options]
541
- ), s = R(
542
- (a) => {
543
- var o;
544
- const c = a;
545
- (o = e.onValueChange) == null || o.call(e, c), n || r(c);
2809
+ ), l = D(
2810
+ (c) => {
2811
+ var h;
2812
+ const f = c;
2813
+ (h = e.onValueChange) == null || h.call(e, f), n || r(f);
546
2814
  },
547
2815
  [n, e]
548
- ), l = R(() => s(void 0), [s]);
549
- return m(() => {
550
- const a = N(e);
2816
+ ), u = D(() => l(void 0), [l]);
2817
+ return b(() => {
2818
+ const c = Je(e);
551
2819
  return {
552
2820
  id: e.id,
553
2821
  kind: e.kind,
554
2822
  label: e.label,
555
- field: a.field,
556
- operator: a.operator,
2823
+ field: c.field,
2824
+ operator: c.operator,
2825
+ relationshipHint: c.relationshipHint,
557
2826
  controlRole: e.kind === "control" ? e.role : void 0,
558
2827
  value: i,
559
- options: u,
560
- isActive: I(i),
561
- setValue: s,
562
- clear: l,
2828
+ options: d,
2829
+ isActive: ee(i),
2830
+ setValue: l,
2831
+ clear: u,
563
2832
  toAnalyticsInput: () => ({
564
- inputId: a.inputId,
565
- field: a.field,
2833
+ inputId: c.inputId,
2834
+ field: c.field,
566
2835
  kind: e.kind,
567
2836
  label: e.label,
568
2837
  value: i,
569
- isActive: I(i),
570
- operator: a.operator,
2838
+ isActive: ee(i),
2839
+ operator: c.operator,
2840
+ relationshipHint: c.relationshipHint,
571
2841
  controlRole: e.kind === "control" ? e.role : void 0
572
2842
  })
573
2843
  };
574
- }, [l, u, s, e, i]);
2844
+ }, [u, d, l, e, i]);
575
2845
  }
576
- function Be(e) {
577
- const [t, r] = K(() => Oe(e));
578
- return L(() => {
2846
+ function $n(e) {
2847
+ const [t, r] = H(() => xn(e));
2848
+ return B(() => {
579
2849
  r((n) => {
580
2850
  let i = n;
581
- for (const u of e)
582
- !Object.prototype.hasOwnProperty.call(i, u.id) && u.defaultValue !== void 0 && (i = { ...i, [u.id]: u.defaultValue });
2851
+ for (const d of e)
2852
+ !Object.prototype.hasOwnProperty.call(i, d.id) && d.defaultValue !== void 0 && (i = { ...i, [d.id]: d.defaultValue });
583
2853
  return i;
584
2854
  });
585
- }, [e]), m(
2855
+ }, [e]), b(
586
2856
  () => e.map((n) => {
587
2857
  const i = Object.prototype.hasOwnProperty.call(
588
2858
  n,
589
2859
  "value"
590
- ), u = i ? n.value : t[n.id], s = P(n.options), l = (o) => {
591
- var d;
592
- (d = n.onValueChange) == null || d.call(n, o), i || r((q) => ({
593
- ...q,
594
- [n.id]: o
2860
+ ), d = i ? n.value : t[n.id], l = Ge(n.options), u = (h) => {
2861
+ var g;
2862
+ (g = n.onValueChange) == null || g.call(n, h), i || r((y) => ({
2863
+ ...y,
2864
+ [n.id]: h
595
2865
  }));
596
- }, a = () => l(void 0), c = N(n);
2866
+ }, c = () => u(void 0), f = Je(n);
597
2867
  return {
598
2868
  id: n.id,
599
2869
  kind: n.kind,
600
2870
  label: n.label,
601
- field: c.field,
602
- operator: c.operator,
2871
+ field: f.field,
2872
+ operator: f.operator,
2873
+ relationshipHint: f.relationshipHint,
603
2874
  controlRole: n.kind === "control" ? n.role : void 0,
604
- value: u,
605
- options: s,
606
- isActive: I(u),
607
- setValue: l,
608
- clear: a,
2875
+ value: d,
2876
+ options: l,
2877
+ isActive: ee(d),
2878
+ setValue: u,
2879
+ clear: c,
609
2880
  toAnalyticsInput: () => ({
610
- inputId: c.inputId,
611
- field: c.field,
2881
+ inputId: f.inputId,
2882
+ field: f.field,
612
2883
  kind: n.kind,
613
2884
  label: n.label,
614
- value: u,
615
- isActive: I(u),
616
- operator: c.operator,
2885
+ value: d,
2886
+ isActive: ee(d),
2887
+ operator: f.operator,
2888
+ relationshipHint: f.relationshipHint,
617
2889
  controlRole: n.kind === "control" ? n.role : void 0
618
2890
  })
619
2891
  };
@@ -621,130 +2893,190 @@ function Be(e) {
621
2893
  [e, t]
622
2894
  );
623
2895
  }
624
- function ze(e, t = {}) {
625
- const r = m(
2896
+ function _n(e, t) {
2897
+ const r = (t == null ? void 0 : t.status) === "success" ? t.options : void 0, n = b(() => bn(r), [r]);
2898
+ B(() => {
2899
+ vn(e.value, r) || e.clear();
2900
+ }, [e, n, t == null ? void 0 : t.status, r]);
2901
+ }
2902
+ function vn(e, t) {
2903
+ if (!ee(e) || t === void 0)
2904
+ return !0;
2905
+ const r = new Set(
2906
+ t.map((i) => He(i.value))
2907
+ );
2908
+ return (Array.isArray(e) ? e : [e]).every(
2909
+ (i) => r.has(He(i))
2910
+ );
2911
+ }
2912
+ function bn(e) {
2913
+ return JSON.stringify((e || []).map((t) => t.value));
2914
+ }
2915
+ function He(e) {
2916
+ return `${typeof e}:${String(e)}`;
2917
+ }
2918
+ function Fn(e, t = {}) {
2919
+ const r = b(
626
2920
  () => t.inputs ? {
627
2921
  ...e,
628
2922
  inputs: t.inputs
629
2923
  } : e,
630
2924
  [t.inputs, e]
631
- ), n = m(() => {
2925
+ ), n = b(() => {
632
2926
  switch (r.queryKind) {
633
2927
  case "metric":
634
2928
  return {
635
2929
  queryKind: r.queryKind,
636
- request: xe(r)
2930
+ request: pn(r)
637
2931
  };
638
2932
  case "analysis":
639
2933
  return {
640
2934
  queryKind: r.queryKind,
641
- request: ke(r)
2935
+ request: fn(r)
642
2936
  };
643
2937
  case "records":
644
2938
  return {
645
2939
  queryKind: r.queryKind,
646
- request: De(r)
2940
+ request: mn(r)
647
2941
  };
648
2942
  case "inputOptions":
649
2943
  return {
650
2944
  queryKind: r.queryKind,
651
- request: Ee(r)
2945
+ request: gn(r)
652
2946
  };
653
2947
  case "sql":
654
2948
  return {
655
2949
  queryKind: r.queryKind,
656
- request: be(r)
2950
+ request: hn(r)
657
2951
  };
658
2952
  case "matrix":
659
2953
  return {
660
2954
  queryKind: r.queryKind,
661
- request: Re(r)
2955
+ request: yn(r)
662
2956
  };
663
2957
  default:
664
- return b(r);
2958
+ return qe(r);
665
2959
  }
666
- }, [r]), i = R(
2960
+ }, [r]), i = zt({
2961
+ spec: r,
2962
+ queryKind: n.queryKind,
2963
+ queryKey: n.request.queryKey,
2964
+ intent: n.request.intent,
2965
+ activeInputs: n.request.activeInputs,
2966
+ debug: t.debug
2967
+ }), d = C(null), l = b(
2968
+ () => ({
2969
+ start: i.start,
2970
+ success: i.success,
2971
+ failure: i.failure,
2972
+ ignored: i.ignored
2973
+ }),
2974
+ [
2975
+ i.failure,
2976
+ i.ignored,
2977
+ i.start,
2978
+ i.success
2979
+ ]
2980
+ ), u = D(
667
2981
  (o) => {
668
- var q, S, w, C, $, A, _, g, j;
669
- const d = n.request;
670
- if (d.intent)
2982
+ var T, k, w, q, O, E, L, x, K;
2983
+ const S = n.request;
2984
+ if (S.intent)
671
2985
  switch (n.queryKind) {
672
2986
  case "metric":
673
- return (q = o.executor) == null ? void 0 : q.executeMetric(
674
- d.intent,
2987
+ return (T = o.executor) == null ? void 0 : T.executeMetric(
2988
+ S.intent,
675
2989
  o
676
2990
  );
677
2991
  case "analysis":
678
- return (w = (S = o.executor) == null ? void 0 : S.executeAnalysis) == null ? void 0 : w.call(
679
- S,
680
- d.intent,
2992
+ return (w = (k = o.executor) == null ? void 0 : k.executeAnalysis) == null ? void 0 : w.call(
2993
+ k,
2994
+ S.intent,
681
2995
  o,
682
- d.analysisOptions
2996
+ S.analysisOptions
683
2997
  );
684
2998
  case "records":
685
- return (C = o.executor) == null ? void 0 : C.executeRecords(
686
- d.intent,
2999
+ return (q = o.executor) == null ? void 0 : q.executeRecords(
3000
+ S.intent,
687
3001
  o
688
3002
  );
689
3003
  case "inputOptions":
690
- return ($ = o.executor) == null ? void 0 : $.executeInputOptions(
691
- d.intent,
3004
+ return (O = o.executor) == null ? void 0 : O.executeInputOptions(
3005
+ S.intent,
692
3006
  o
693
3007
  );
694
3008
  case "sql":
695
- return (_ = (A = o.executor) == null ? void 0 : A.executeSql) == null ? void 0 : _.call(
696
- A,
697
- d.intent,
3009
+ return (L = (E = o.executor) == null ? void 0 : E.executeSql) == null ? void 0 : L.call(
3010
+ E,
3011
+ S.intent,
698
3012
  o
699
3013
  );
700
3014
  case "matrix":
701
- return (j = (g = o.executor) == null ? void 0 : g.executeMatrix) == null ? void 0 : j.call(
702
- g,
703
- d.intent,
3015
+ return (K = (x = o.executor) == null ? void 0 : x.executeMatrix) == null ? void 0 : K.call(
3016
+ x,
3017
+ S.intent,
704
3018
  o
705
3019
  );
706
3020
  default:
707
- return b(n);
3021
+ return qe(n);
708
3022
  }
709
3023
  },
710
3024
  [n]
711
- ), u = Ke(
3025
+ ), c = Sn(
712
3026
  n.request.queryKey,
713
- i,
3027
+ u,
714
3028
  n.request.idleData,
715
- n.request.activeInputs
716
- ), s = n.request.error ? n.request.idleData : u.data, l = n.request.error ? "error" : u.status, a = !n.request.error && u.status === "loading", c = n.request.error || u.error;
3029
+ n.request.activeInputs,
3030
+ l
3031
+ ), f = i.queryId, h = i.validationFailure;
3032
+ B(() => {
3033
+ const o = n.request.error;
3034
+ if (!o) {
3035
+ d.current = null;
3036
+ return;
3037
+ }
3038
+ const S = `${f}:${o.message}`;
3039
+ d.current !== S && (d.current = S, h(o));
3040
+ }, [
3041
+ n.request.error,
3042
+ n.request.queryKey,
3043
+ f,
3044
+ h
3045
+ ]);
3046
+ const g = n.request.error ? n.request.idleData : c.data, y = n.request.error ? "error" : c.status, m = !n.request.error && c.status === "loading", v = n.request.error || c.error, A = i.trace;
717
3047
  switch (n.queryKind) {
718
3048
  case "metric": {
719
- const o = s;
3049
+ const o = g;
720
3050
  return {
721
3051
  id: r.id,
722
3052
  intent: n.request.intent,
723
3053
  value: (o == null ? void 0 : o.value) ?? null,
724
- metrics: o == null ? void 0 : o.metrics,
3054
+ measures: o == null ? void 0 : o.measures,
725
3055
  comparisonValue: o == null ? void 0 : o.comparisonValue,
726
3056
  delta: o == null ? void 0 : o.delta,
727
3057
  deltaPercent: o == null ? void 0 : o.deltaPercent,
728
3058
  records: o == null ? void 0 : o.records,
729
3059
  executionResult: o == null ? void 0 : o.executionResult,
730
- status: l,
731
- isLoading: a,
732
- error: c
3060
+ status: y,
3061
+ isLoading: m,
3062
+ error: v,
3063
+ trace: A
733
3064
  };
734
3065
  }
735
3066
  case "analysis": {
736
- const o = U(s);
3067
+ const o = mt(g);
737
3068
  return {
738
3069
  id: r.id,
739
3070
  intent: n.request.intent,
740
3071
  ...o || {},
741
- status: l,
742
- isLoading: a,
743
- error: c
3072
+ status: y,
3073
+ isLoading: m,
3074
+ error: v,
3075
+ trace: A
744
3076
  };
745
3077
  }
746
3078
  case "records": {
747
- const o = s;
3079
+ const o = g;
748
3080
  return {
749
3081
  id: r.id,
750
3082
  intent: n.request.intent,
@@ -753,25 +3085,27 @@ function ze(e, t = {}) {
753
3085
  rowCount: o == null ? void 0 : o.rowCount,
754
3086
  pagination: o == null ? void 0 : o.pagination,
755
3087
  executionResult: o == null ? void 0 : o.executionResult,
756
- status: l,
757
- isLoading: a,
758
- error: c
3088
+ status: y,
3089
+ isLoading: m,
3090
+ error: v,
3091
+ trace: A
759
3092
  };
760
3093
  }
761
3094
  case "inputOptions": {
762
- const o = s;
3095
+ const o = g;
763
3096
  return {
764
3097
  id: r.id,
765
3098
  intent: n.request.intent,
766
3099
  options: (o == null ? void 0 : o.options) || [],
767
3100
  executionResult: o == null ? void 0 : o.executionResult,
768
- status: l,
769
- isLoading: a,
770
- error: c
3101
+ status: y,
3102
+ isLoading: m,
3103
+ error: v,
3104
+ trace: A
771
3105
  };
772
3106
  }
773
3107
  case "sql": {
774
- const o = s;
3108
+ const o = g;
775
3109
  return {
776
3110
  id: r.id,
777
3111
  intent: n.request.intent,
@@ -782,13 +3116,14 @@ function ze(e, t = {}) {
782
3116
  output: o == null ? void 0 : o.output,
783
3117
  rowLimitExceeded: o == null ? void 0 : o.rowLimitExceeded,
784
3118
  executionResult: o == null ? void 0 : o.executionResult,
785
- status: l,
786
- isLoading: a,
787
- error: c
3119
+ status: y,
3120
+ isLoading: m,
3121
+ error: v,
3122
+ trace: A
788
3123
  };
789
3124
  }
790
3125
  case "matrix": {
791
- const o = s;
3126
+ const o = g;
792
3127
  return {
793
3128
  id: r.id,
794
3129
  intent: n.request.intent,
@@ -796,93 +3131,105 @@ function ze(e, t = {}) {
796
3131
  grid: o == null ? void 0 : o.grid,
797
3132
  expansion: o == null ? void 0 : o.expansion,
798
3133
  executionResult: o == null ? void 0 : o.executionResult,
799
- status: l,
800
- isLoading: a,
801
- error: c
3134
+ status: y,
3135
+ isLoading: m,
3136
+ error: v,
3137
+ trace: A
802
3138
  };
803
3139
  }
804
3140
  default:
805
- return b(n);
3141
+ return qe(n);
806
3142
  }
807
3143
  }
808
- function Ke(e, t, r, n) {
809
- const i = Ae(), u = T(t), s = T(n), [l, a] = K({
3144
+ function Sn(e, t, r, n, i) {
3145
+ const d = ln(), l = C(t), u = C(n), [c, f] = H({
810
3146
  status: "idle",
811
3147
  data: r,
812
3148
  error: null
813
3149
  });
814
- return u.current = t, s.current = n, L(() => {
815
- let c;
3150
+ return l.current = t, u.current = n, B(() => {
3151
+ let h;
816
3152
  try {
817
- c = u.current({
818
- ...i,
819
- activeInputs: s.current
3153
+ h = l.current({
3154
+ ...d,
3155
+ activeInputs: u.current
820
3156
  });
821
- } catch (d) {
822
- a({
3157
+ } catch (m) {
3158
+ i == null || i.failure(m, 0), f({
823
3159
  status: "error",
824
3160
  data: r,
825
- error: p(d)
3161
+ error: F(m)
826
3162
  });
827
3163
  return;
828
3164
  }
829
- if (!c) {
830
- a({ status: "idle", data: r, error: null });
3165
+ if (!h) {
3166
+ f({ status: "idle", data: r, error: null });
831
3167
  return;
832
3168
  }
833
- let o = !1;
834
- return a((d) => ({
3169
+ let g = !1;
3170
+ const y = yt();
3171
+ return i == null || i.start(), f((m) => ({
835
3172
  status: "loading",
836
- data: d.data,
3173
+ data: m.data,
837
3174
  error: null
838
- })), c.then((d) => {
839
- o || a({ status: "success", data: d, error: null });
840
- }).catch((d) => {
841
- o || a({
3175
+ })), h.then((m) => {
3176
+ g ? i == null || i.ignored("superseded") : (i == null || i.success(m, Ue(y)), f({ status: "success", data: m, error: null }));
3177
+ }).catch((m) => {
3178
+ g ? i == null || i.ignored("superseded") : (i == null || i.failure(m, Ue(y)), f({
842
3179
  status: "error",
843
3180
  data: r,
844
- error: p(d)
845
- });
3181
+ error: F(m)
3182
+ }));
846
3183
  }), () => {
847
- o = !0;
3184
+ g = !0;
848
3185
  };
849
- }, [r, e, i]), l;
3186
+ }, [r, e, d, i]), c;
3187
+ }
3188
+ function yt() {
3189
+ return typeof performance < "u" && performance.now ? performance.now() : Date.now();
850
3190
  }
851
- function Oe(e) {
3191
+ function Ue(e) {
3192
+ return Math.max(0, Math.round(yt() - e));
3193
+ }
3194
+ function xn(e) {
852
3195
  return Object.fromEntries(
853
3196
  e.filter((t) => t.defaultValue !== void 0).map((t) => [t.id, t.defaultValue])
854
3197
  );
855
3198
  }
856
- function b(e) {
3199
+ function qe(e) {
857
3200
  throw new Error(`Unsupported Semaphor query kind: ${JSON.stringify(e)}`);
858
3201
  }
3202
+ function Wn({
3203
+ token: e,
3204
+ apiBaseUrl: t,
3205
+ executor: r,
3206
+ debug: n,
3207
+ children: i
3208
+ }) {
3209
+ var g;
3210
+ const d = dn(), l = ((g = d == null ? void 0 : d.authToken) == null ? void 0 : g.accessToken) || e, u = (d == null ? void 0 : d.dataApiBaseUrl) || (d == null ? void 0 : d.apiBaseUrl) || t, c = b(() => Xr(), []), f = r || c, h = b(
3211
+ () => ({
3212
+ token: l,
3213
+ apiBaseUrl: u,
3214
+ executor: f
3215
+ }),
3216
+ [u, f, l]
3217
+ );
3218
+ return /* @__PURE__ */ s(Wt, { debug: n, children: /* @__PURE__ */ s(ht.Provider, { value: h, children: i }) });
3219
+ }
859
3220
  export {
860
- B as SemaphorDataAppContext,
861
- Ue as SemaphorDataAppProvider,
862
- de as createSemaphorQueryExecutor,
863
- Pe as defineSemaphorDataApp,
864
- Ne as defineSemaphorInput,
865
- I as hasSemaphorInputValue,
866
- U as normalizeSemaphorAnalysisPayload,
867
- Je as normalizeSemaphorAnalysisQueryOptions,
868
- P as normalizeSemaphorInputOptions,
869
- Se as readWindowRuntime,
870
- Le as semaphor,
871
- y as toSemaphorActiveInputSnapshots,
872
- F as toSemaphorAnalysisIntent,
873
- Y as toSemaphorAnalysisQueryOptions,
874
- Ye as toSemaphorInputBinding,
875
- Fe as toSemaphorInputBindings,
876
- Q as toSemaphorInputOptionsIntent,
877
- He as toSemaphorInputSnapshots,
878
- N as toSemaphorInputSpec,
879
- z as toSemaphorMatrixIntent,
880
- H as toSemaphorMetricIntent,
881
- J as toSemaphorRecordsIntent,
882
- M as toSemaphorSqlIntent,
883
- Ae as useSemaphorDataAppRuntime,
884
- Ve as useSemaphorInput,
885
- Be as useSemaphorInputs,
886
- ze as useSemaphorQuery,
887
- We as validateSemaphorDataAppQuerySpecs
3221
+ Wn as SemaphorDataAppProvider,
3222
+ Ln as SemaphorDevtools,
3223
+ Bn as SemaphorDevtoolsInspectButton,
3224
+ On as SemaphorViewBoundary,
3225
+ Xr as createSemaphorQueryExecutor,
3226
+ kn as defineSemaphorDataApp,
3227
+ Cn as defineSemaphorInput,
3228
+ vn as isSemaphorInputValueValidForOptions,
3229
+ Dn as semaphor,
3230
+ _n as useClearInvalidSemaphorInputValue,
3231
+ et as useSemaphorDevtools,
3232
+ Kn as useSemaphorInput,
3233
+ $n as useSemaphorInputs,
3234
+ Fn as useSemaphorQuery
888
3235
  };