react-semaphor 0.1.421 → 0.1.423

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 (67) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +2 -2
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +2 -2
  5. package/dist/briefings/index.cjs +1 -1
  6. package/dist/briefings/index.js +913 -712
  7. package/dist/chunks/{analyze-result-contract-sWcmvBOA.js → analyze-result-contract-D7pjjYPy.js} +45 -46
  8. package/dist/chunks/{analyze-result-contract-B5Eeu7vD.js → analyze-result-contract-DpDcImgk.js} +1 -1
  9. package/dist/chunks/{calendar-preferences-dialog-CscmhyuZ.js → calendar-preferences-dialog-CTmeASaM.js} +1 -1
  10. package/dist/chunks/{calendar-preferences-dialog-cN3_2C-u.js → calendar-preferences-dialog-t5ET6MON.js} +3 -3
  11. package/dist/chunks/card-config-utils-15sRtebL.js +1 -0
  12. package/dist/chunks/card-config-utils-BYZ5MJOh.js +16 -0
  13. package/dist/chunks/dashboard-briefing-launcher-Cavd0QJb.js +3401 -0
  14. package/dist/chunks/dashboard-briefing-launcher-S2akO-ub.js +26 -0
  15. package/dist/chunks/dashboard-controls-BJLrErjW.js +2322 -0
  16. package/dist/chunks/dashboard-controls-DzbP8AXA.js +52 -0
  17. package/dist/chunks/dashboard-json-5tWb5KD6.js +1 -0
  18. package/dist/chunks/{dashboard-json-Cxhw2TZc.js → dashboard-json-Do2-pdPZ.js} +12 -11
  19. package/dist/chunks/{edit-dashboard-visual-BigSJ3-x.js → edit-dashboard-visual-Cw6bq4_w.js} +7058 -6989
  20. package/dist/chunks/edit-dashboard-visual-Yh5YFgMF.js +178 -0
  21. package/dist/chunks/index-BPM3gDRw.js +1406 -0
  22. package/dist/chunks/{index-CH2ZzQo4.js → index-yHe0SeLO.js} +81534 -75430
  23. package/dist/chunks/{switch-TbCsyhv9.js → switch-2bh3Hka1.js} +620 -633
  24. package/dist/chunks/{switch-CiOjVyVI.js → switch-DMT7qf_R.js} +24 -24
  25. package/dist/chunks/{update-policy-2MZ-Vf7v.js → update-policy-BCJc0oI5.js} +1 -1
  26. package/dist/chunks/{update-policy-qpyAkOyO.js → update-policy-C1pmhLz9.js} +1 -1
  27. package/dist/chunks/{use-create-flow-overlay-state-BzcJWNzh.js → use-create-flow-overlay-state-5MDbZcs1.js} +515 -544
  28. package/dist/chunks/use-create-flow-overlay-state-BNczg9Gj.js +11 -0
  29. package/dist/chunks/{validators-Dj1Y-46V.js → validators-DMlVbd1p.js} +1 -1
  30. package/dist/chunks/{validators-D0pfj3jJ.js → validators-PXkij33j.js} +1 -1
  31. package/dist/dashboard/index.cjs +1 -1
  32. package/dist/dashboard/index.js +1 -1
  33. package/dist/dashboard-authoring/index.cjs +1 -1
  34. package/dist/dashboard-authoring/index.js +2 -2
  35. package/dist/data-app-builder/index.cjs +1 -1
  36. package/dist/data-app-builder/index.js +108 -108
  37. package/dist/data-app-codegen/index.cjs +1 -1
  38. package/dist/data-app-codegen/index.js +2 -2
  39. package/dist/data-app-codegen-node/index.cjs +165 -340
  40. package/dist/data-app-codegen-node/index.js +761 -952
  41. package/dist/data-app-sdk/index.cjs +2 -2
  42. package/dist/data-app-sdk/index.js +91 -95
  43. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  44. package/dist/data-app-sdk-adapters/index.js +1 -1
  45. package/dist/data-app-sdk-validation/index.cjs +1 -1
  46. package/dist/data-app-sdk-validation/index.js +2 -2
  47. package/dist/index.cjs +1 -1
  48. package/dist/index.js +168 -164
  49. package/dist/style.css +1 -1
  50. package/dist/surfboard/index.cjs +1 -1
  51. package/dist/surfboard/index.js +2 -2
  52. package/dist/types/analytics-protocol.d.ts +0 -4
  53. package/dist/types/briefings.d.ts +2388 -7
  54. package/dist/types/dashboard-assistant.d.ts +0 -1
  55. package/dist/types/data-app-sdk-validation.d.ts +0 -1
  56. package/dist/types/data-app-sdk.d.ts +0 -2
  57. package/dist/types/main.d.ts +70 -10
  58. package/dist/types/types.d.ts +4 -8
  59. package/package.json +1 -1
  60. package/dist/chunks/dashboard-briefing-launcher-BYTBNetR.js +0 -9077
  61. package/dist/chunks/dashboard-briefing-launcher-DmZkzIC3.js +0 -80
  62. package/dist/chunks/dashboard-controls-9DFeKIP4.js +0 -52
  63. package/dist/chunks/dashboard-controls-PhzuaTBj.js +0 -2280
  64. package/dist/chunks/dashboard-json-DyRHI3mL.js +0 -1
  65. package/dist/chunks/edit-dashboard-visual-3_jiBXsu.js +0 -178
  66. package/dist/chunks/index-BKDQw0aK.js +0 -1346
  67. package/dist/chunks/use-create-flow-overlay-state-DUQmgb9H.js +0 -21
@@ -1,11 +1,11 @@
1
1
  import { toSemaphorInputSnapshots as jr, toSemaphorInputBinding as Hr, toSemaphorActiveInputSnapshots as X, toSemaphorMatrixIntent as Pr, toSemaphorSqlIntent as Vr, toSemaphorInputOptionsIntent as Qr, toSemaphorRecordsIntent as Ur, toSemaphorAnalysisQueryOptions as Gr, toSemaphorAnalysisIntent as Jr, toSemaphorMetricIntent as Yr, hasSemaphorInputValue as ue, normalizeSemaphorInputOptions as hr, toSemaphorInputSpec as br } from "../data-app-sdk-adapters/index.js";
2
2
  import { jsxs as p, Fragment as vr, jsx as a } from "react/jsx-runtime";
3
- import { createContext as xe, useContext as Q, useState as z, useRef as E, useEffect as B, useMemo as I, Fragment as Xr, useId as Sr, useCallback as D, useReducer as Zr } from "react";
4
- import { I as et, L as rt } from "../chunks/analyze-result-contract-sWcmvBOA.js";
5
- import { b as ao, M as lo } from "../chunks/analyze-result-contract-sWcmvBOA.js";
3
+ import { createContext as Ie, useContext as Q, useState as z, useRef as E, useEffect as B, useMemo as I, Fragment as Xr, useId as Sr, useCallback as D, useReducer as Zr } from "react";
4
+ import { I as et, L as rt } from "../chunks/analyze-result-contract-D7pjjYPy.js";
5
+ import { b as ao, M as lo } from "../chunks/analyze-result-contract-D7pjjYPy.js";
6
6
  import { M as tt, a as nt, S as it, E as ot, C as st } from "../chunks/search-BHsQIWBV.js";
7
7
  import { X as at, C as lt, j as dt } from "../chunks/x-CXDkqdur.js";
8
- import { b as ut } from "../chunks/validators-D0pfj3jJ.js";
8
+ import { b as ut } from "../chunks/validators-PXkij33j.js";
9
9
  function me(e, r, t = {}) {
10
10
  return {
11
11
  ...t,
@@ -129,7 +129,7 @@ const Yi = {
129
129
  queryKind: "matrix"
130
130
  };
131
131
  }
132
- }, ce = 10, Ne = 8;
132
+ }, ce = 10, _e = 8;
133
133
  function He(e, r) {
134
134
  const t = e == null ? void 0 : e.result;
135
135
  if (t)
@@ -207,9 +207,7 @@ function ct(e, r) {
207
207
  metric: "primaryValue",
208
208
  value: (r == null ? void 0 : r.primaryValue) ?? e.primaryValue
209
209
  }
210
- ];
211
- r && "value" in r && t.push({ metric: "value", value: r.value });
212
- const n = (r == null ? void 0 : r.comparisonKind) ?? ((o = e.comparison) == null ? void 0 : o.kind);
210
+ ], n = (r == null ? void 0 : r.comparisonKind) ?? ((o = e.comparison) == null ? void 0 : o.kind);
213
211
  return n && t.push(
214
212
  {
215
213
  metric: `${n} value`,
@@ -254,10 +252,10 @@ function le({
254
252
  return {
255
253
  title: e,
256
254
  summary: `${mt(u)} ${r}`,
257
- columns: o.slice(0, Ne),
255
+ columns: o.slice(0, _e),
258
256
  rows: f,
259
257
  truncatedRows: u > f.length,
260
- truncatedColumns: o.length > Ne
258
+ truncatedColumns: o.length > _e
261
259
  };
262
260
  }
263
261
  function ft(e, r) {
@@ -286,7 +284,7 @@ function wr(e) {
286
284
  function or(e) {
287
285
  return e.length > 80 ? `${e.slice(0, 77)}...` : e;
288
286
  }
289
- function qe(e) {
287
+ function xe(e) {
290
288
  return e.viewTitle || e.queryLabel || e.viewId || e.queryId;
291
289
  }
292
290
  function yt(e) {
@@ -303,15 +301,15 @@ function ht(e) {
303
301
  function Pe(e) {
304
302
  return e.flatMap((r) => {
305
303
  var g, m, v, y;
306
- const t = r.latestAttempt, n = t == null ? void 0 : t.executionResult, i = ke(
304
+ const t = r.latestAttempt, n = t == null ? void 0 : t.executionResult, i = Te(
307
305
  (g = n == null ? void 0 : n.validation) == null ? void 0 : g.warnings
308
- ), o = ke(
306
+ ), o = Te(
309
307
  (m = n == null ? void 0 : n.validation) == null ? void 0 : m.errors
310
308
  ), u = wt(
311
309
  (v = n == null ? void 0 : n.coverage) == null ? void 0 : v.missingObligations
312
- ), f = ke(
310
+ ), f = Te(
313
311
  (y = n == null ? void 0 : n.coverage) == null ? void 0 : y.warnings
314
- ), d = [], c = qe(r);
312
+ ), d = [], c = xe(r);
315
313
  (t == null ? void 0 : t.status) === "error" && d.push({
316
314
  trace: r,
317
315
  tone: "error",
@@ -373,7 +371,7 @@ function St(e) {
373
371
  function wt(e) {
374
372
  return Array.isArray(e) ? e.filter((r) => typeof r == "string") : [];
375
373
  }
376
- function ke(e) {
374
+ function Te(e) {
377
375
  return Array.isArray(e) ? e.map(It).filter(
378
376
  (r) => !!r
379
377
  ) : [];
@@ -653,7 +651,7 @@ function qr() {
653
651
  const e = document.createElement("style");
654
652
  e.id = ar, e.textContent = $t, document.head.appendChild(e);
655
653
  }
656
- const ye = 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif', W = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace", Ee = {
654
+ const ye = 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif', W = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace", ke = {
657
655
  color: "var(--sd-fg-muted)",
658
656
  fontSize: 10,
659
657
  fontWeight: 600,
@@ -811,7 +809,7 @@ const ye = 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe
811
809
  background: "transparent",
812
810
  color: "inherit",
813
811
  cursor: "pointer",
814
- ...Ee
812
+ ...ke
815
813
  },
816
814
  issueSummaryHeaderLabel: {
817
815
  display: "inline-flex",
@@ -918,7 +916,7 @@ const ye = 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe
918
916
  alignItems: "center",
919
917
  justifyContent: "space-between",
920
918
  padding: "4px 6px 3px",
921
- ...Ee
919
+ ...ke
922
920
  },
923
921
  queryGroupCount: {
924
922
  color: "var(--sd-fg-subtle)",
@@ -1520,7 +1518,7 @@ const ye = 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe
1520
1518
  gap: 5
1521
1519
  },
1522
1520
  codeBlockLabel: {
1523
- ...Ee
1521
+ ...ke
1524
1522
  },
1525
1523
  codeBlock: {
1526
1524
  maxHeight: 260,
@@ -1561,14 +1559,14 @@ const ye = 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe
1561
1559
  textOverflow: "ellipsis",
1562
1560
  whiteSpace: "nowrap"
1563
1561
  }
1564
- }, Re = 10, Le = 100, Ot = 25, Dt = 500, Ar = {
1562
+ }, Ee = 10, Re = 100, Ot = 25, Dt = 500, Ar = {
1565
1563
  enabled: !1,
1566
1564
  queries: [],
1567
1565
  issues: [],
1568
1566
  getQuery: () => {
1569
1567
  },
1570
1568
  getQueries: () => []
1571
- }, Ve = xe(null), Qe = xe(null), Ue = xe(
1569
+ }, Ve = Ie(null), Qe = Ie(null), Ue = Ie(
1572
1570
  void 0
1573
1571
  ), V = [];
1574
1572
  function Bt({
@@ -1823,7 +1821,7 @@ function _t({
1823
1821
  ] }),
1824
1822
  S.traces.length ? S.traces.map((w) => {
1825
1823
  var ne;
1826
- const L = un(w, $), x = qe(w), O = Lr(w), pe = $r(w), re = fn(w, x, pe), te = re.join(" · "), k = Er(O), j = vt(b, w);
1824
+ const L = un(w, $), x = xe(w), O = Lr(w), pe = $r(w), re = fn(w, x, pe), te = re.join(" · "), k = Er(O), j = vt(b, w);
1827
1825
  return /* @__PURE__ */ p(
1828
1826
  "button",
1829
1827
  {
@@ -1868,7 +1866,7 @@ function _t({
1868
1866
  )
1869
1867
  ]
1870
1868
  },
1871
- Me(w)
1869
+ Ne(w)
1872
1870
  );
1873
1871
  }) : /* @__PURE__ */ a("div", { style: s.queryGroupEmpty, children: "No input traces" })
1874
1872
  ] }, S.title)) : /* @__PURE__ */ a("div", { style: s.emptyState, children: "No matching traces" })
@@ -2085,12 +2083,12 @@ function Nt({
2085
2083
  ge(q, 0);
2086
2084
  },
2087
2085
  [ge]
2088
- ), Te = d ? u == null ? void 0 : u.state.entries[H] : void 0;
2086
+ ), Ce = d ? u == null ? void 0 : u.state.entries[H] : void 0;
2089
2087
  return I(
2090
2088
  () => ({
2091
2089
  enabled: d,
2092
2090
  queryId: k,
2093
- trace: Te ? ve(Te) : void 0,
2091
+ trace: Ce ? ve(Ce) : void 0,
2094
2092
  start: er,
2095
2093
  success: rr,
2096
2094
  failure: ge,
@@ -2104,7 +2102,7 @@ function Nt({
2104
2102
  k,
2105
2103
  er,
2106
2104
  rr,
2107
- Te,
2105
+ Ce,
2108
2106
  nr
2109
2107
  ]
2110
2108
  );
@@ -2133,11 +2131,11 @@ function Ft({
2133
2131
  var $, S, w, L, x;
2134
2132
  if (!e)
2135
2133
  return /* @__PURE__ */ a("div", { style: s.detailsPane, children: /* @__PURE__ */ a("div", { style: s.emptyState, children: "No traces registered yet" }) });
2136
- const r = e.latestAttempt, t = r == null ? void 0 : r.executionResult, n = Oe(
2134
+ const r = e.latestAttempt, t = r == null ? void 0 : r.executionResult, n = $e(
2137
2135
  ($ = t == null ? void 0 : t.validation) == null ? void 0 : $.warnings
2138
- ), i = Oe((S = t == null ? void 0 : t.validation) == null ? void 0 : S.errors), o = Cn(
2136
+ ), i = $e((S = t == null ? void 0 : t.validation) == null ? void 0 : S.errors), o = Cn(
2139
2137
  (w = t == null ? void 0 : t.coverage) == null ? void 0 : w.missingObligations
2140
- ), u = Oe(
2138
+ ), u = $e(
2141
2139
  (L = t == null ? void 0 : t.coverage) == null ? void 0 : L.warnings
2142
2140
  ), f = t == null ? void 0 : t.compiledQuery, d = En(t), c = ((x = e.server) == null ? void 0 : x.compiledSql) || d.compiledSql, g = (r == null ? void 0 : r.resultPreview) || He(t), m = [
2143
2141
  ...r != null && r.errorMessage ? [r.errorMessage] : [],
@@ -2161,7 +2159,7 @@ function Ft({
2161
2159
  }
2162
2160
  }
2163
2161
  ),
2164
- /* @__PURE__ */ a("span", { style: s.detailsTitle, children: qe(e) }),
2162
+ /* @__PURE__ */ a("span", { style: s.detailsTitle, children: xe(e) }),
2165
2163
  /* @__PURE__ */ a(
2166
2164
  "span",
2167
2165
  {
@@ -2626,7 +2624,7 @@ function rn({
2626
2624
  ce,
2627
2625
  " rows and first",
2628
2626
  " ",
2629
- Ne,
2627
+ _e,
2630
2628
  " columns."
2631
2629
  ] }) : null
2632
2630
  ] });
@@ -2637,17 +2635,17 @@ function tn({
2637
2635
  }) {
2638
2636
  return (e == null ? void 0 : e.kind) === "sql" ? /* @__PURE__ */ p("div", { style: s.compiledQuery, children: [
2639
2637
  /* @__PURE__ */ a(dr, { label: "SQL", value: e.sql }),
2640
- e.pythonCode ? /* @__PURE__ */ a($e, { label: "Python", value: e.pythonCode }) : null,
2638
+ e.pythonCode ? /* @__PURE__ */ a(Le, { label: "Python", value: e.pythonCode }) : null,
2641
2639
  e.parameters ? /* @__PURE__ */ a(
2642
- $e,
2640
+ Le,
2643
2641
  {
2644
2642
  label: "Parameters",
2645
- value: Fe(e.parameters)
2643
+ value: Me(e.parameters)
2646
2644
  }
2647
2645
  ) : null
2648
- ] }) : r ? /* @__PURE__ */ a(dr, { label: "SQL", value: r }) : /* @__PURE__ */ a($e, { label: "Compiled Query", value: Fe(e) });
2646
+ ] }) : r ? /* @__PURE__ */ a(dr, { label: "SQL", value: r }) : /* @__PURE__ */ a(Le, { label: "Compiled Query", value: Me(e) });
2649
2647
  }
2650
- function $e({
2648
+ function Le({
2651
2649
  label: e,
2652
2650
  value: r
2653
2651
  }) {
@@ -2736,9 +2734,9 @@ function an(e, r) {
2736
2734
  ) : e;
2737
2735
  }
2738
2736
  function ln(e) {
2739
- const r = e.filter((i) => i.queryKind === "inputOptions"), t = new Set(r.map(Me));
2737
+ const r = e.filter((i) => i.queryKind === "inputOptions"), t = new Set(r.map(Ne));
2740
2738
  return [
2741
- { title: "Views", traces: e.filter((i) => !t.has(Me(i))) },
2739
+ { title: "Views", traces: e.filter((i) => !t.has(Ne(i))) },
2742
2740
  { title: "Inputs", traces: r }
2743
2741
  ];
2744
2742
  }
@@ -2757,7 +2755,7 @@ function dn(e, r) {
2757
2755
  function un(e, r) {
2758
2756
  return !!(e && r && e.traceId === r.traceId);
2759
2757
  }
2760
- function Me(e) {
2758
+ function Ne(e) {
2761
2759
  return e.traceId;
2762
2760
  }
2763
2761
  function cn(e) {
@@ -2775,7 +2773,7 @@ function cn(e) {
2775
2773
  case "sql":
2776
2774
  return "sql";
2777
2775
  default:
2778
- return Ae(e);
2776
+ return qe(e);
2779
2777
  }
2780
2778
  }
2781
2779
  function Er(e) {
@@ -2822,7 +2820,7 @@ function Lr(e) {
2822
2820
  return gn(e.visualType) || cn(e.queryKind);
2823
2821
  }
2824
2822
  function pn(e, r) {
2825
- return r ? e.queryLabel || e.queryId : qe(e);
2823
+ return r ? e.queryLabel || e.queryId : xe(e);
2826
2824
  }
2827
2825
  function gn(e) {
2828
2826
  if (e)
@@ -2862,7 +2860,7 @@ function yn(e) {
2862
2860
  case "sql":
2863
2861
  return "SQL query";
2864
2862
  default:
2865
- return Ae(e.queryKind);
2863
+ return qe(e.queryKind);
2866
2864
  }
2867
2865
  }
2868
2866
  function hn(e) {
@@ -2903,9 +2901,9 @@ function wn(e) {
2903
2901
  return typeof e == "number" ? `${Math.round(e)}ms` : "-";
2904
2902
  }
2905
2903
  function In(e) {
2906
- return Fe(e);
2904
+ return Me(e);
2907
2905
  }
2908
- function Fe(e) {
2906
+ function Me(e) {
2909
2907
  return JSON.stringify(e, null, 2) ?? "undefined";
2910
2908
  }
2911
2909
  function xn(e) {
@@ -2939,7 +2937,7 @@ function An(e) {
2939
2937
  function Cn(e) {
2940
2938
  return Array.isArray(e) ? e.filter((r) => typeof r == "string") : [];
2941
2939
  }
2942
- function Oe(e) {
2940
+ function $e(e) {
2943
2941
  return Array.isArray(e) ? e.map((r) => Tn(r)).filter((r) => !!r) : [];
2944
2942
  }
2945
2943
  function Tn(e) {
@@ -3147,24 +3145,24 @@ function Wn(e) {
3147
3145
  return e === void 0 || e === !1 ? {
3148
3146
  enabled: !1,
3149
3147
  exposeWindowBridge: !1,
3150
- maxEventsPerQuery: Re,
3151
- maxQueries: Le
3148
+ maxEventsPerQuery: Ee,
3149
+ maxQueries: Re
3152
3150
  } : e === !0 ? {
3153
3151
  enabled: !0,
3154
3152
  exposeWindowBridge: !1,
3155
- maxEventsPerQuery: Re,
3156
- maxQueries: Le
3153
+ maxEventsPerQuery: Ee,
3154
+ maxQueries: Re
3157
3155
  } : {
3158
3156
  enabled: e.enabled !== !1,
3159
3157
  exposeWindowBridge: e.exposeWindowBridge === !0,
3160
3158
  maxEventsPerQuery: cr(
3161
3159
  e.maxEventsPerQuery,
3162
- Re,
3160
+ Ee,
3163
3161
  Ot
3164
3162
  ),
3165
3163
  maxQueries: cr(
3166
3164
  e.maxQueries,
3167
- Le,
3165
+ Re,
3168
3166
  Dt
3169
3167
  )
3170
3168
  };
@@ -3215,10 +3213,10 @@ function Mn(e) {
3215
3213
  case "sql":
3216
3214
  return "semaphor.sql";
3217
3215
  default:
3218
- return Ae(e);
3216
+ return qe(e);
3219
3217
  }
3220
3218
  }
3221
- function Ae(e) {
3219
+ function qe(e) {
3222
3220
  throw new Error(`Unsupported Semaphor query kind: ${JSON.stringify(e)}`);
3223
3221
  }
3224
3222
  function Fn(e) {
@@ -3255,7 +3253,7 @@ function zn(e) {
3255
3253
  }
3256
3254
  function jn(e) {
3257
3255
  const r = [];
3258
- return Ie(e, (t) => {
3256
+ return we(e, (t) => {
3259
3257
  Qn(t) && r.push(t);
3260
3258
  }), rt(r);
3261
3259
  }
@@ -3282,12 +3280,12 @@ function Hn(e) {
3282
3280
  return Y(e.fields || []);
3283
3281
  case "matrix":
3284
3282
  return Y([
3285
- ...(e.rows || []).map(De),
3286
- ...(e.columns || []).map(De),
3287
- ...(e.values || []).map(De)
3283
+ ...(e.rows || []).map(Oe),
3284
+ ...(e.columns || []).map(Oe),
3285
+ ...(e.values || []).map(Oe)
3288
3286
  ]);
3289
3287
  default:
3290
- return Ae(e);
3288
+ return qe(e);
3291
3289
  }
3292
3290
  }
3293
3291
  function Pn(e, r) {
@@ -3314,7 +3312,7 @@ function Br(e) {
3314
3312
  const t = e.field;
3315
3313
  return fe(t) ? t : void 0;
3316
3314
  }
3317
- function De(e) {
3315
+ function Oe(e) {
3318
3316
  if (fe(e))
3319
3317
  return e;
3320
3318
  if (!e || typeof e != "object")
@@ -3324,18 +3322,18 @@ function De(e) {
3324
3322
  }
3325
3323
  function Vn(e) {
3326
3324
  const r = /* @__PURE__ */ new Map();
3327
- return Ie(e, (t) => {
3325
+ return we(e, (t) => {
3328
3326
  fe(t) && r.set(Ge(t), t);
3329
3327
  }), [...r.values()];
3330
3328
  }
3331
- function Ie(e, r) {
3329
+ function we(e, r) {
3332
3330
  if (!(!e || typeof e != "object")) {
3333
3331
  if (r(e), Array.isArray(e)) {
3334
- e.forEach((t) => Ie(t, r));
3332
+ e.forEach((t) => we(t, r));
3335
3333
  return;
3336
3334
  }
3337
3335
  Object.values(e).forEach(
3338
- (t) => Ie(t, r)
3336
+ (t) => we(t, r)
3339
3337
  );
3340
3338
  }
3341
3339
  }
@@ -3389,15 +3387,15 @@ function Yn(e) {
3389
3387
  if (!r || typeof r != "object")
3390
3388
  return;
3391
3389
  const t = {};
3392
- return Se(r.primaryValue) && (t.primaryValue = r.primaryValue), Se(r.value) && (t.value = r.value), Se(r.comparisonValue) && (t.comparisonValue = r.comparisonValue), typeof r.comparisonKind == "string" && (t.comparisonKind = r.comparisonKind), (typeof r.delta == "number" || r.delta === null) && (t.delta = r.delta), (typeof r.deltaPercent == "number" || r.deltaPercent === null) && (t.deltaPercent = r.deltaPercent), Xn(r.measures) && (t.measures = r.measures), Zn(r.measureBindings) && (t.measureBindings = r.measureBindings), Array.isArray(r.missingMeasures) && (t.missingMeasures = r.missingMeasures.filter(
3390
+ return Fe(r.primaryValue) && (t.primaryValue = r.primaryValue), Fe(r.comparisonValue) && (t.comparisonValue = r.comparisonValue), typeof r.comparisonKind == "string" && (t.comparisonKind = r.comparisonKind), (typeof r.delta == "number" || r.delta === null) && (t.delta = r.delta), (typeof r.deltaPercent == "number" || r.deltaPercent === null) && (t.deltaPercent = r.deltaPercent), Xn(r.measures) && (t.measures = r.measures), Zn(r.measureBindings) && (t.measureBindings = r.measureBindings), Array.isArray(r.missingMeasures) && (t.missingMeasures = r.missingMeasures.filter(
3393
3391
  (n) => typeof n == "string" && !!n
3394
3392
  )), Object.keys(t).length > 0 ? t : void 0;
3395
3393
  }
3396
- function Se(e) {
3394
+ function Fe(e) {
3397
3395
  return e === null || typeof e == "number" || typeof e == "string";
3398
3396
  }
3399
3397
  function Xn(e) {
3400
- return e !== null && typeof e == "object" && !Array.isArray(e) && Object.values(e).every(Se);
3398
+ return e !== null && typeof e == "object" && !Array.isArray(e) && Object.values(e).every(Fe);
3401
3399
  }
3402
3400
  function Zn(e) {
3403
3401
  return e !== null && typeof e == "object" && !Array.isArray(e) && Object.values(e).every((r) => typeof r == "string");
@@ -3623,10 +3621,9 @@ function ze(e) {
3623
3621
  const r = e;
3624
3622
  return `{${Object.keys(r).sort().map((t) => `${JSON.stringify(t)}:${ze(r[t])}`).join(",")}}`;
3625
3623
  }
3626
- const Be = {
3627
- value: null,
3624
+ const De = {
3628
3625
  primaryValue: null
3629
- }, Ke = {}, pi = { records: [] }, We = { options: [] }, gi = { records: [] }, _e = {};
3626
+ }, Be = {}, pi = { records: [] }, Ke = { options: [] }, gi = { records: [] }, We = {};
3630
3627
  function mi(e) {
3631
3628
  const r = X(e.inputs), t = Gr(e);
3632
3629
  try {
@@ -3641,14 +3638,14 @@ function mi(e) {
3641
3638
  i,
3642
3639
  t
3643
3640
  ),
3644
- idleData: Ke
3641
+ idleData: Be
3645
3642
  } : {
3646
3643
  intent: n,
3647
3644
  error: null,
3648
3645
  activeInputs: r,
3649
3646
  analysisOptions: t,
3650
3647
  queryKey: A(n, r, void 0, t),
3651
- idleData: Ke
3648
+ idleData: Be
3652
3649
  };
3653
3650
  } catch (n) {
3654
3651
  const i = Z(n, "analysis");
@@ -3662,7 +3659,7 @@ function mi(e) {
3662
3659
  i,
3663
3660
  t
3664
3661
  ),
3665
- idleData: Ke
3662
+ idleData: Be
3666
3663
  };
3667
3664
  }
3668
3665
  }
@@ -3674,13 +3671,13 @@ function yi(e) {
3674
3671
  error: n,
3675
3672
  activeInputs: r,
3676
3673
  queryKey: A(void 0, r, n),
3677
- idleData: Be
3674
+ idleData: De
3678
3675
  } : {
3679
3676
  intent: t,
3680
3677
  error: null,
3681
3678
  activeInputs: r,
3682
3679
  queryKey: A(t, r),
3683
- idleData: Be
3680
+ idleData: De
3684
3681
  };
3685
3682
  } catch (t) {
3686
3683
  const n = Z(t, "metric");
@@ -3688,7 +3685,7 @@ function yi(e) {
3688
3685
  error: n,
3689
3686
  activeInputs: r,
3690
3687
  queryKey: A(void 0, r, n),
3691
- idleData: Be
3688
+ idleData: De
3692
3689
  };
3693
3690
  }
3694
3691
  }
@@ -3726,13 +3723,13 @@ function bi(e) {
3726
3723
  error: n,
3727
3724
  activeInputs: r,
3728
3725
  queryKey: A(void 0, r, n),
3729
- idleData: We
3726
+ idleData: Ke
3730
3727
  } : {
3731
3728
  intent: t,
3732
3729
  error: null,
3733
3730
  activeInputs: r,
3734
3731
  queryKey: A(t, r),
3735
- idleData: We
3732
+ idleData: Ke
3736
3733
  };
3737
3734
  } catch (t) {
3738
3735
  const n = Z(t, "inputOptions");
@@ -3740,7 +3737,7 @@ function bi(e) {
3740
3737
  error: n,
3741
3738
  activeInputs: r,
3742
3739
  queryKey: A(void 0, r, n),
3743
- idleData: We
3740
+ idleData: Ke
3744
3741
  };
3745
3742
  }
3746
3743
  }
@@ -3778,13 +3775,13 @@ function Si(e) {
3778
3775
  error: n,
3779
3776
  activeInputs: r,
3780
3777
  queryKey: A(void 0, r, n),
3781
- idleData: _e
3778
+ idleData: We
3782
3779
  } : {
3783
3780
  intent: t,
3784
3781
  error: null,
3785
3782
  activeInputs: r,
3786
3783
  queryKey: A(t, r),
3787
- idleData: _e
3784
+ idleData: We
3788
3785
  };
3789
3786
  } catch (t) {
3790
3787
  const n = Z(t, "matrix");
@@ -3792,7 +3789,7 @@ function Si(e) {
3792
3789
  error: n,
3793
3790
  activeInputs: r,
3794
3791
  queryKey: A(void 0, r, n),
3795
- idleData: _e
3792
+ idleData: We
3796
3793
  };
3797
3794
  }
3798
3795
  }
@@ -3800,7 +3797,7 @@ function je(e) {
3800
3797
  var o;
3801
3798
  if (wi(e))
3802
3799
  return e;
3803
- const r = e instanceof Error ? e : void 0, t = e, n = t == null ? void 0 : t.executionResult, i = Ce(
3800
+ const r = e instanceof Error ? e : void 0, t = e, n = t == null ? void 0 : t.executionResult, i = Ae(
3804
3801
  (r == null ? void 0 : r.message) ?? String(e),
3805
3802
  {
3806
3803
  requestId: typeof (t == null ? void 0 : t.requestId) == "string" ? t.requestId : void 0,
@@ -3837,14 +3834,14 @@ function Z(e, r) {
3837
3834
  void 0,
3838
3835
  r,
3839
3836
  n
3840
- ), o = Ce(t.message, {
3837
+ ), o = Ae(t.message, {
3841
3838
  executionResult: i,
3842
3839
  validation: n,
3843
3840
  validationIssues: n.errors
3844
3841
  });
3845
3842
  return o.stack = t.stack, o;
3846
3843
  }
3847
- function Ce(e, r = {}) {
3844
+ function Ae(e, r = {}) {
3848
3845
  var i, o, u;
3849
3846
  const t = new Error(e);
3850
3847
  t.name = "SemaphorDataAppQueryError", t.kind = "data_app_query_error", r.requestId && (t.requestId = r.requestId), r.details !== void 0 && (t.details = r.details), r.executionResult !== void 0 && (t.executionResult = r.executionResult), r.validation !== void 0 && (t.validation = r.validation);
@@ -3865,7 +3862,7 @@ function ee(e, r = e.kind) {
3865
3862
  r,
3866
3863
  t
3867
3864
  );
3868
- return Ce(
3865
+ return Ae(
3869
3866
  `Invalid Semaphor analytics intent. ${n}`,
3870
3867
  {
3871
3868
  executionResult: i,
@@ -3972,7 +3969,7 @@ async function G(e, r, t) {
3972
3969
  }
3973
3970
  function xi(e, r) {
3974
3971
  var t;
3975
- return Ce(e, {
3972
+ return Ae(e, {
3976
3973
  requestId: r.requestId,
3977
3974
  details: r.details,
3978
3975
  executionResult: r.executionResult,
@@ -4057,7 +4054,7 @@ function Li(e) {
4057
4054
  return "";
4058
4055
  }
4059
4056
  }
4060
- const Mr = xe({});
4057
+ const Mr = Ie({});
4061
4058
  function $i() {
4062
4059
  if (!(typeof window > "u"))
4063
4060
  return window.__SEMAPHOR_DATA_APP_RUNTIME__;
@@ -4218,7 +4215,7 @@ function no(e, r = {}) {
4218
4215
  request: Si(t)
4219
4216
  };
4220
4217
  default:
4221
- return we(t);
4218
+ return Se(t);
4222
4219
  }
4223
4220
  }, [t]), i = Nt({
4224
4221
  spec: t,
@@ -4281,7 +4278,7 @@ function no(e, r = {}) {
4281
4278
  l
4282
4279
  );
4283
4280
  default:
4284
- return we(n);
4281
+ return Se(n);
4285
4282
  }
4286
4283
  },
4287
4284
  [n]
@@ -4322,7 +4319,6 @@ function no(e, r = {}) {
4322
4319
  return {
4323
4320
  id: t.id,
4324
4321
  intent: n.request.intent,
4325
- value: (l == null ? void 0 : l.value) ?? null,
4326
4322
  primaryValue: (l == null ? void 0 : l.primaryValue) ?? null,
4327
4323
  measures: l == null ? void 0 : l.measures,
4328
4324
  measureBindings: l == null ? void 0 : l.measureBindings,
@@ -4437,7 +4433,7 @@ function no(e, r = {}) {
4437
4433
  };
4438
4434
  }
4439
4435
  default:
4440
- return we(n);
4436
+ return Se(n);
4441
4437
  }
4442
4438
  }
4443
4439
  function J(e) {
@@ -4478,7 +4474,7 @@ function _i(e, r, t) {
4478
4474
  switch (e) {
4479
4475
  case "metric": {
4480
4476
  const d = r;
4481
- return (d == null ? void 0 : d.value) == null && !_(d == null ? void 0 : d.records);
4477
+ return (d == null ? void 0 : d.primaryValue) == null && !_(d == null ? void 0 : d.records);
4482
4478
  }
4483
4479
  case "analysis": {
4484
4480
  const d = r;
@@ -4503,7 +4499,7 @@ function _i(e, r, t) {
4503
4499
  return !((o = (i = d == null ? void 0 : d.matrixResult) == null ? void 0 : i.cells) != null && o.length) && !((f = (u = d == null ? void 0 : d.grid) == null ? void 0 : u.cells) != null && f.length);
4504
4500
  }
4505
4501
  default:
4506
- return we(e);
4502
+ return Se(e);
4507
4503
  }
4508
4504
  }
4509
4505
  function _(e) {
@@ -4568,7 +4564,7 @@ function Mi(e) {
4568
4564
  e.filter((r) => r.defaultValue !== void 0).map((r) => [r.id, r.defaultValue])
4569
4565
  );
4570
4566
  }
4571
- function we(e) {
4567
+ function Se(e) {
4572
4568
  throw new Error(`Unsupported Semaphor query kind: ${JSON.stringify(e)}`);
4573
4569
  }
4574
4570
  function Fi(e) {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../chunks/operators-DrTQsJXv.js"),u=require("../chunks/analyze-result-contract-B5Eeu7vD.js");function p(i){var n,e,a;const t=b(i);return{version:1,kind:"metric",id:i.id,label:i.label,source:s(i),measures:t,primaryMeasure:M(i,t),dateField:i.dateField?o(i.dateField,"date"):void 0,timeGrain:i.timeGrain,dimensions:(n=i.dimensions)==null?void 0:n.map(r=>o(r,"dimension")),comparison:G(i.comparison),orderBy:i.orderBy?{field:o(i.orderBy.field),direction:i.orderBy.direction}:void 0,inputs:l(i.inputs),...(e=i.filters)!=null&&e.length?{filters:i.filters}:{},...i.relationshipHint?{relationshipHint:i.relationshipHint}:{},limit:i.limit,...(a=i.derivedFields)!=null&&a.length?{derivedFields:i.derivedFields}:{}}}function v(i){return{...p(i),...i.timeWindow?{timeWindow:i.timeWindow}:{},...i.analysis?{analysis:i.analysis}:{}}}function F(i){return{...i.chartTitle?{chartTitle:i.chartTitle}:{},...i.chartType?{chartType:i.chartType}:{},...i.driverMode?{driverMode:i.driverMode}:{},...i.includePopulation!==void 0?{includePopulation:i.includePopulation}:{},...i.calendarContext?{calendarContext:i.calendarContext}:{}}}function M(i,t){if(!i.primaryMeasure)return t[0]||{name:"",role:"measure"};const n=o(i.primaryMeasure,"measure"),e=A(n,t),a=e.length===1?e[0]:void 0;return a?I(n,a):n}function b(i){const t=[];for(const n of i.measures.map(e=>o(e,"measure"))){if(!n.name)continue;const e=t.findIndex(a=>R(a,n));if(e===-1){t.push(n);continue}t[e]=I(t[e],n)}return t}function R(i,t){return u.semaphorFieldRefsMatch(i,t)&&d(i)===d(t)}function H(i,t){return d(t)===d(i)}function w(i,t){return t.name!==i.name||i.source&&!u.semaphorFieldRefsMatch(t,i)?!1:H(i,t)}function A(i,t){const n=t.filter(e=>w(i,e));return i.aggregate!==void 0,n}function d(i){return u.semaphorMetricAggregate(i)}function I(i,t){if(i.aggregate&&t.aggregate&&i.aggregate!==t.aggregate)throw new Error(`Measure "${i.name}" was requested with conflicting aggregate semantics: ${i.aggregate} and ${t.aggregate}.`);return{...u.preferSemaphorFieldRefMetadata(i,t),aggregate:i.aggregate||t.aggregate}}function k(i){var n,e;if("sort"in i)throw new Error("semaphor.records supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet.");if(!V(i))throw new Error("semaphor.records needs at least one field.");const t=B(i.fields);return{version:1,kind:"records",id:i.id,label:i.label,source:s(i),fields:t,dateField:i.dateField?o(i.dateField,"date"):void 0,timeGrain:i.timeGrain,...i.timeWindow?{timeWindow:i.timeWindow}:{},...(n=i.filters)!=null&&n.length?{filters:i.filters}:{},orderBy:i.orderBy?{field:o(i.orderBy.field),direction:i.orderBy.direction}:void 0,inputs:l(i.inputs),...i.relationshipHint?{relationshipHint:i.relationshipHint}:{},limit:i.limit,...i.pagination?{pagination:i.pagination}:{},...i.totals?{totals:{mode:"server",measures:i.totals.measures.map(a=>o(a,"measure"))}}:{},...(e=i.derivedFields)!=null&&e.length?{derivedFields:i.derivedFields}:{}}}function B(i){return i.map(t=>{const n=o(t);if(!n.role)throw new Error(`semaphor.records field "${n.name}" needs an explicit role.`);return n})}function x(i){var t,n,e;return{version:1,kind:"inputOptions",id:i.id,label:i.label,inputId:i.inputId,source:s(i),labelField:o(i.labelField,"dimension"),valueField:o(i.valueField,"dimension"),...i.searchField?{searchField:o(i.searchField,"dimension")}:{},...(t=i.disambiguationFields)!=null&&t.length?{disambiguationFields:i.disambiguationFields.map(a=>o(a,"dimension"))}:{},...i.population?{population:i.population}:{},...i.dependencies?{dependencies:i.dependencies}:{},search:i.search,limit:i.limit,...(n=i.inputs)!=null&&n.length?{inputs:i.inputs.map(a=>f(a))}:{},...(e=i.derivedFields)!=null&&e.length?{derivedFields:i.derivedFields}:{}}}function O(i){var t;return{version:1,kind:"sql",id:i.id,label:i.label,source:i.source,sql:i.sql,...i.defaultParameters?{defaultParameters:i.defaultParameters}:{},...i.pythonCode?{pythonCode:i.pythonCode}:{},...(t=i.fields)!=null&&t.length?{fields:i.fields.map(n=>o(n))}:{},inputs:l(i.inputs),limit:i.limit,...i.pagination?{pagination:i.pagination}:{},rationale:i.rationale}}function z(i){var t,n;return{version:1,kind:"matrix",id:i.id,label:i.label,source:s(i),rows:i.rows.map(e=>g(e,"dimension")),...i.columns?{columns:i.columns.map(e=>g(e,"dimension"))}:{},values:i.values.map(C),...(t=i.filters)!=null&&t.length?{filters:i.filters}:{},inputs:l(i.inputs),...i.relationshipHint?{relationshipHint:i.relationshipHint}:{},...i.totals?{totals:i.totals}:{},...(n=i.sort)!=null&&n.length?{sort:i.sort}:{},...i.expansion?{expansion:i.expansion}:{},...i.layout?{layout:i.layout}:{},...i.displayLimits?{displayLimits:i.displayLimits}:{}}}function g(i,t){return P(i)?{...i,field:o(i.field,t)}:{field:o(i,t)}}function C(i){return T(i)?{...i,field:o(i.field,"measure")}:{field:o(i,"measure"),aggregate:i.aggregate}}function P(i){return"field"in i}function T(i){return"field"in i}function f(i){if("toAnalyticsInput"in i){const r=i.toAnalyticsInput();return{inputId:r.inputId,kind:r.kind,...r.controlRole?{controlRole:r.controlRole}:{},...r.operator?{operator:r.operator}:{},...r.field?{field:r.field}:{},...r.relationshipHint?{relationshipHint:r.relationshipHint}:{}}}if("id"in i){const r=h(i);return{inputId:r.inputId,kind:r.kind,...r.controlRole?{controlRole:r.controlRole}:{},...r.operator?{operator:r.operator}:{},...r.field?{field:r.field}:{},...r.relationshipHint?{relationshipHint:r.relationshipHint}:{}}}const t="kind"in i?i.kind:void 0,n="operator"in i?S(i.operator,i.inputId):void 0,e="controlRole"in i?i.controlRole:"role"in i?i.role:void 0,a=W(e)?e:void 0;return{inputId:i.inputId,...t?{kind:t}:{},...a?{controlRole:a}:{},...n?{operator:n}:{},...i.field?{field:i.field}:{},...i.relationshipHint?{relationshipHint:i.relationshipHint}:{}}}function W(i){return i==="grain"||i==="measure"||i==="dimension"||i==="aggregation"||i==="sqlParam"}function $(i){const t=l(i);return t.length>0?t:void 0}function y(i){return(i||[]).map(L)}function q(i){return y(i).filter(t=>t.isActive)}function h(i){if(i.kind==="filter"){const t=S(i.operator,i.id);return{inputId:i.id,kind:i.kind,label:i.label,field:o(i.field,"dimension"),operator:t||"in",...i.relationshipHint?{relationshipHint:i.relationshipHint}:{}}}return{inputId:i.id,kind:i.kind,label:i.label,controlRole:i.role}}function E(i=[]){return i.map(t=>typeof t=="object"?t:{label:String(t),value:t})}function m(i){return i==null?!1:Array.isArray(i)?i.length>0:typeof i=="string"?i.trim().length>0:!0}function L(i){if("toAnalyticsInput"in i)return i.toAnalyticsInput();if("kind"in i&&"isActive"in i)return i;if("id"in i){const t=h(i),n=Object.prototype.hasOwnProperty.call(i,"value")?i.value:i.defaultValue;return{inputId:t.inputId,kind:t.kind,label:t.label,...t.field?{field:t.field}:{},...t.operator?{operator:t.operator}:{},...t.controlRole?{controlRole:t.controlRole}:{},...t.relationshipHint?{relationshipHint:t.relationshipHint}:{},value:n,isActive:m(n)}}return{...i,kind:"filter",isActive:m(i.value),value:i.value}}function s(i){return i.source}function V(i){var t;return!!((t=i.fields)!=null&&t.length)}function o(i,t){return{...i,role:i.role||t}}function l(i){return(i||[]).map(f)}function G(i){if(i)return i}function S(i,t){if(i===void 0)return;const n=c.normalizeSemaphorInputOperator(i);if(!n)throw new Error(`useSemaphorInput "${t}" uses unsupported filter operator "${i}".`);return n}exports.hasSemaphorInputValue=m;exports.normalizeSemaphorInputOptions=E;exports.toSemaphorActiveInputSnapshots=q;exports.toSemaphorAnalysisIntent=v;exports.toSemaphorAnalysisQueryOptions=F;exports.toSemaphorInputBinding=f;exports.toSemaphorInputBindings=$;exports.toSemaphorInputOptionsIntent=x;exports.toSemaphorInputSnapshots=y;exports.toSemaphorInputSpec=h;exports.toSemaphorMatrixIntent=z;exports.toSemaphorMetricIntent=p;exports.toSemaphorRecordsIntent=k;exports.toSemaphorSqlIntent=O;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../chunks/operators-DrTQsJXv.js"),u=require("../chunks/analyze-result-contract-DpDcImgk.js");function p(i){var n,e,a;const t=b(i);return{version:1,kind:"metric",id:i.id,label:i.label,source:s(i),measures:t,primaryMeasure:M(i,t),dateField:i.dateField?o(i.dateField,"date"):void 0,timeGrain:i.timeGrain,dimensions:(n=i.dimensions)==null?void 0:n.map(r=>o(r,"dimension")),comparison:G(i.comparison),orderBy:i.orderBy?{field:o(i.orderBy.field),direction:i.orderBy.direction}:void 0,inputs:l(i.inputs),...(e=i.filters)!=null&&e.length?{filters:i.filters}:{},...i.relationshipHint?{relationshipHint:i.relationshipHint}:{},limit:i.limit,...(a=i.derivedFields)!=null&&a.length?{derivedFields:i.derivedFields}:{}}}function v(i){return{...p(i),...i.timeWindow?{timeWindow:i.timeWindow}:{},...i.analysis?{analysis:i.analysis}:{}}}function F(i){return{...i.chartTitle?{chartTitle:i.chartTitle}:{},...i.chartType?{chartType:i.chartType}:{},...i.driverMode?{driverMode:i.driverMode}:{},...i.includePopulation!==void 0?{includePopulation:i.includePopulation}:{},...i.calendarContext?{calendarContext:i.calendarContext}:{}}}function M(i,t){if(!i.primaryMeasure)return t[0]||{name:"",role:"measure"};const n=o(i.primaryMeasure,"measure"),e=A(n,t),a=e.length===1?e[0]:void 0;return a?I(n,a):n}function b(i){const t=[];for(const n of i.measures.map(e=>o(e,"measure"))){if(!n.name)continue;const e=t.findIndex(a=>R(a,n));if(e===-1){t.push(n);continue}t[e]=I(t[e],n)}return t}function R(i,t){return u.semaphorFieldRefsMatch(i,t)&&d(i)===d(t)}function H(i,t){return d(t)===d(i)}function w(i,t){return t.name!==i.name||i.source&&!u.semaphorFieldRefsMatch(t,i)?!1:H(i,t)}function A(i,t){const n=t.filter(e=>w(i,e));return i.aggregate!==void 0,n}function d(i){return u.semaphorMetricAggregate(i)}function I(i,t){if(i.aggregate&&t.aggregate&&i.aggregate!==t.aggregate)throw new Error(`Measure "${i.name}" was requested with conflicting aggregate semantics: ${i.aggregate} and ${t.aggregate}.`);return{...u.preferSemaphorFieldRefMetadata(i,t),aggregate:i.aggregate||t.aggregate}}function k(i){var n,e;if("sort"in i)throw new Error("semaphor.records supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet.");if(!V(i))throw new Error("semaphor.records needs at least one field.");const t=B(i.fields);return{version:1,kind:"records",id:i.id,label:i.label,source:s(i),fields:t,dateField:i.dateField?o(i.dateField,"date"):void 0,timeGrain:i.timeGrain,...i.timeWindow?{timeWindow:i.timeWindow}:{},...(n=i.filters)!=null&&n.length?{filters:i.filters}:{},orderBy:i.orderBy?{field:o(i.orderBy.field),direction:i.orderBy.direction}:void 0,inputs:l(i.inputs),...i.relationshipHint?{relationshipHint:i.relationshipHint}:{},limit:i.limit,...i.pagination?{pagination:i.pagination}:{},...i.totals?{totals:{mode:"server",measures:i.totals.measures.map(a=>o(a,"measure"))}}:{},...(e=i.derivedFields)!=null&&e.length?{derivedFields:i.derivedFields}:{}}}function B(i){return i.map(t=>{const n=o(t);if(!n.role)throw new Error(`semaphor.records field "${n.name}" needs an explicit role.`);return n})}function x(i){var t,n,e;return{version:1,kind:"inputOptions",id:i.id,label:i.label,inputId:i.inputId,source:s(i),labelField:o(i.labelField,"dimension"),valueField:o(i.valueField,"dimension"),...i.searchField?{searchField:o(i.searchField,"dimension")}:{},...(t=i.disambiguationFields)!=null&&t.length?{disambiguationFields:i.disambiguationFields.map(a=>o(a,"dimension"))}:{},...i.population?{population:i.population}:{},...i.dependencies?{dependencies:i.dependencies}:{},search:i.search,limit:i.limit,...(n=i.inputs)!=null&&n.length?{inputs:i.inputs.map(a=>f(a))}:{},...(e=i.derivedFields)!=null&&e.length?{derivedFields:i.derivedFields}:{}}}function O(i){var t;return{version:1,kind:"sql",id:i.id,label:i.label,source:i.source,sql:i.sql,...i.defaultParameters?{defaultParameters:i.defaultParameters}:{},...i.pythonCode?{pythonCode:i.pythonCode}:{},...(t=i.fields)!=null&&t.length?{fields:i.fields.map(n=>o(n))}:{},inputs:l(i.inputs),limit:i.limit,...i.pagination?{pagination:i.pagination}:{},rationale:i.rationale}}function z(i){var t,n;return{version:1,kind:"matrix",id:i.id,label:i.label,source:s(i),rows:i.rows.map(e=>g(e,"dimension")),...i.columns?{columns:i.columns.map(e=>g(e,"dimension"))}:{},values:i.values.map(C),...(t=i.filters)!=null&&t.length?{filters:i.filters}:{},inputs:l(i.inputs),...i.relationshipHint?{relationshipHint:i.relationshipHint}:{},...i.totals?{totals:i.totals}:{},...(n=i.sort)!=null&&n.length?{sort:i.sort}:{},...i.expansion?{expansion:i.expansion}:{},...i.layout?{layout:i.layout}:{},...i.displayLimits?{displayLimits:i.displayLimits}:{}}}function g(i,t){return P(i)?{...i,field:o(i.field,t)}:{field:o(i,t)}}function C(i){return T(i)?{...i,field:o(i.field,"measure")}:{field:o(i,"measure"),aggregate:i.aggregate}}function P(i){return"field"in i}function T(i){return"field"in i}function f(i){if("toAnalyticsInput"in i){const r=i.toAnalyticsInput();return{inputId:r.inputId,kind:r.kind,...r.controlRole?{controlRole:r.controlRole}:{},...r.operator?{operator:r.operator}:{},...r.field?{field:r.field}:{},...r.relationshipHint?{relationshipHint:r.relationshipHint}:{}}}if("id"in i){const r=h(i);return{inputId:r.inputId,kind:r.kind,...r.controlRole?{controlRole:r.controlRole}:{},...r.operator?{operator:r.operator}:{},...r.field?{field:r.field}:{},...r.relationshipHint?{relationshipHint:r.relationshipHint}:{}}}const t="kind"in i?i.kind:void 0,n="operator"in i?S(i.operator,i.inputId):void 0,e="controlRole"in i?i.controlRole:"role"in i?i.role:void 0,a=W(e)?e:void 0;return{inputId:i.inputId,...t?{kind:t}:{},...a?{controlRole:a}:{},...n?{operator:n}:{},...i.field?{field:i.field}:{},...i.relationshipHint?{relationshipHint:i.relationshipHint}:{}}}function W(i){return i==="grain"||i==="measure"||i==="dimension"||i==="aggregation"||i==="sqlParam"}function $(i){const t=l(i);return t.length>0?t:void 0}function y(i){return(i||[]).map(L)}function q(i){return y(i).filter(t=>t.isActive)}function h(i){if(i.kind==="filter"){const t=S(i.operator,i.id);return{inputId:i.id,kind:i.kind,label:i.label,field:o(i.field,"dimension"),operator:t||"in",...i.relationshipHint?{relationshipHint:i.relationshipHint}:{}}}return{inputId:i.id,kind:i.kind,label:i.label,controlRole:i.role}}function E(i=[]){return i.map(t=>typeof t=="object"?t:{label:String(t),value:t})}function m(i){return i==null?!1:Array.isArray(i)?i.length>0:typeof i=="string"?i.trim().length>0:!0}function L(i){if("toAnalyticsInput"in i)return i.toAnalyticsInput();if("kind"in i&&"isActive"in i)return i;if("id"in i){const t=h(i),n=Object.prototype.hasOwnProperty.call(i,"value")?i.value:i.defaultValue;return{inputId:t.inputId,kind:t.kind,label:t.label,...t.field?{field:t.field}:{},...t.operator?{operator:t.operator}:{},...t.controlRole?{controlRole:t.controlRole}:{},...t.relationshipHint?{relationshipHint:t.relationshipHint}:{},value:n,isActive:m(n)}}return{...i,kind:"filter",isActive:m(i.value),value:i.value}}function s(i){return i.source}function V(i){var t;return!!((t=i.fields)!=null&&t.length)}function o(i,t){return{...i,role:i.role||t}}function l(i){return(i||[]).map(f)}function G(i){if(i)return i}function S(i,t){if(i===void 0)return;const n=c.normalizeSemaphorInputOperator(i);if(!n)throw new Error(`useSemaphorInput "${t}" uses unsupported filter operator "${i}".`);return n}exports.hasSemaphorInputValue=m;exports.normalizeSemaphorInputOptions=E;exports.toSemaphorActiveInputSnapshots=q;exports.toSemaphorAnalysisIntent=v;exports.toSemaphorAnalysisQueryOptions=F;exports.toSemaphorInputBinding=f;exports.toSemaphorInputBindings=$;exports.toSemaphorInputOptionsIntent=x;exports.toSemaphorInputSnapshots=y;exports.toSemaphorInputSpec=h;exports.toSemaphorMatrixIntent=z;exports.toSemaphorMetricIntent=p;exports.toSemaphorRecordsIntent=k;exports.toSemaphorSqlIntent=O;