react-semaphor 0.1.306 → 0.1.308

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 (44) hide show
  1. package/dist/brand-studio/index.cjs +1 -1
  2. package/dist/brand-studio/index.js +4 -4
  3. package/dist/chunks/{braces-CuiOenEA.js → braces-BHDm9arh.js} +1 -1
  4. package/dist/chunks/{braces-DZxcgUvn.js → braces-DEq8EJtw.js} +1 -1
  5. package/dist/chunks/chevrons-up-down-Cbtggnqv.js +14 -0
  6. package/dist/chunks/chevrons-up-down-DDEY9beZ.js +6 -0
  7. package/dist/chunks/{dashboard-controls-CuQH4inS.js → dashboard-controls-DTxSUWvy.js} +279 -257
  8. package/dist/chunks/dashboard-controls-DviftQE7.js +57 -0
  9. package/dist/chunks/dashboard-filter-controls-button-D0nrJ7wl.js +11 -0
  10. package/dist/chunks/{dashboard-filter-controls-button-NiAIAD1P.js → dashboard-filter-controls-button-DHKfgPah.js} +304 -303
  11. package/dist/chunks/{dashboard-json-Bk13vadr.js → dashboard-json-DYzZ0G6T.js} +1 -1
  12. package/dist/chunks/{dashboard-json-DzVn9KAU.js → dashboard-json-DZmsUV5n.js} +2 -2
  13. package/dist/chunks/dashboard-summary-settings-dialog-Cc3yKCu4.js +1 -0
  14. package/dist/chunks/{dashboard-summary-settings-dialog-dt20G_7d.js → dashboard-summary-settings-dialog-QbUTp92u.js} +33 -32
  15. package/dist/chunks/{edit-dashboard-visual-DGhTFzSF.js → edit-dashboard-visual-BS3LKMJe.js} +32 -32
  16. package/dist/chunks/{edit-dashboard-visual-BIuWXuCC.js → edit-dashboard-visual-CmgculGv.js} +130 -129
  17. package/dist/chunks/{index-DQApwxKL.js → index-BxYIELMe.js} +62029 -63833
  18. package/dist/chunks/index-C0zD3JgK.js +1330 -0
  19. package/dist/chunks/{palette-DFjOzeAG.js → palette-CNKSAIrt.js} +1 -1
  20. package/dist/chunks/{palette-BwGE32UR.js → palette-CteErylX.js} +1 -1
  21. package/dist/chunks/{resource-management-panel-CD_TQoTn.js → resource-management-panel-8cHoj8SV.js} +52 -52
  22. package/dist/chunks/resource-management-panel-B4QM3fZ_.js +6 -0
  23. package/dist/chunks/{save-QktcpXPy.js → save-B1-nDZwS.js} +1 -1
  24. package/dist/chunks/{save-B3tqymYm.js → save-BVVnWGeb.js} +1 -1
  25. package/dist/chunks/{switch-B72T1Hf_.js → switch-BG4RWnrq.js} +2 -2
  26. package/dist/chunks/{switch-BuZXNXQV.js → switch-BZn7R_Cp.js} +634 -634
  27. package/dist/chunks/{use-create-flow-overlay-state-iUCs5ZgT.js → use-create-flow-overlay-state-Bmb471Fp.js} +1 -1
  28. package/dist/chunks/{use-create-flow-overlay-state-Bg-LkLP7.js → use-create-flow-overlay-state-CeWstFjy.js} +49 -49
  29. package/dist/chunks/{use-visual-utils-D_2r0Fmm.js → use-visual-utils-CmfDomt0.js} +2 -2
  30. package/dist/chunks/{use-visual-utils-DqVxN0_F.js → use-visual-utils-DflfgX9g.js} +1 -1
  31. package/dist/dashboard/index.cjs +1 -1
  32. package/dist/dashboard/index.js +1 -1
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.js +76 -76
  35. package/dist/style.css +1 -1
  36. package/dist/surfboard/index.cjs +1 -1
  37. package/dist/surfboard/index.js +2 -2
  38. package/dist/types/main.d.ts +10 -4
  39. package/package.json +1 -1
  40. package/dist/chunks/dashboard-controls-BpgZjEDy.js +0 -47
  41. package/dist/chunks/dashboard-filter-controls-button-Bu90ytxy.js +0 -11
  42. package/dist/chunks/dashboard-summary-settings-dialog-8vZtKUjh.js +0 -1
  43. package/dist/chunks/index-CwzM5Lxh.js +0 -1360
  44. package/dist/chunks/resource-management-panel-BqJAVm7E.js +0 -6
@@ -1,4 +1,4 @@
1
- "use strict";const s=require("./switch-B72T1Hf_.js"),e=require("react/jsx-runtime"),p=require("./index-CwzM5Lxh.js"),C=require("react"),re=require("./use-visual-utils-DqVxN0_F.js"),he=require("./save-B3tqymYm.js");/**
1
+ "use strict";const s=require("./switch-BG4RWnrq.js"),e=require("react/jsx-runtime"),p=require("./index-C0zD3JgK.js"),C=require("react"),re=require("./use-visual-utils-DflfgX9g.js"),he=require("./save-BVVnWGeb.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,9 +1,9 @@
1
- import { c as De, n as L, u as le, z as ft, A as ht, D as bt, a as ne, F as gt, ae as yt, B as E, e as xt, l as Ne, X as Pe, m as Ye, f as Ge, af as vt, ag as Ct, ah as re, ai as Ae, aj as ze, ak as fe, al as he, am as kt, an as Oe, ao as Nt, ap as St, aq as se, ar as Dt, as as Be, G as Me, at as Xe, au as He, av as Je, L as Y, I as We, g as be, h as ge, i as ye, j as xe, k as ve, aw as Ze, ax as wt, ay as It, az as Qe, aA as Vt, aB as je, aC as Tt, aD as Ce } from "./switch-BuZXNXQV.js";
1
+ import { c as De, n as L, u as le, z as ft, A as ht, D as bt, a as ne, F as gt, ae as yt, B as E, e as xt, l as Ne, X as Pe, m as Ye, f as Ge, af as vt, ag as Ct, ah as re, ai as Ae, aj as ze, ak as fe, al as he, am as kt, an as Oe, ao as Nt, ap as St, aq as se, ar as Dt, as as Be, G as Me, at as Xe, au as He, av as Je, L as Y, I as We, g as be, h as ge, i as ye, j as xe, k as ve, aw as Ze, ax as wt, ay as Vt, az as Qe, aA as It, aB as je, aC as Tt, aD as Ce } from "./switch-BZn7R_Cp.js";
2
2
  import { jsx as t, jsxs as d, Fragment as K } from "react/jsx-runtime";
3
- import { b0 as et, b1 as Et, b2 as qt, b3 as Ft, b4 as _t, b5 as Lt, W as At, Q as zt, r as ie, b6 as tt, t as at, b7 as rt, b8 as Ot, p as Q, b9 as Bt, ba as Mt, bb as Re, bc as Qt, bd as jt, be as st, bf as lt, bg as Rt, bh as Ut, bi as $t, bj as Kt, bk as Pt, bl as Yt, bm as Gt, bn as Xt } from "./index-DQApwxKL.js";
3
+ import { a$ as et, b0 as Et, b1 as qt, b2 as Ft, b3 as _t, b4 as Lt, V as At, P as zt, q as ie, b5 as tt, s as at, b6 as rt, b7 as Ot, o as Q, b8 as Bt, b9 as Mt, ba as Re, bb as Qt, bc as jt, bd as st, be as lt, bf as Rt, bg as Ut, bh as $t, bi as Kt, bj as Pt, bk as Yt, bl as Gt, bm as Xt } from "./index-BxYIELMe.js";
4
4
  import { useMemo as z, useState as j, useRef as ke, useCallback as B, useEffect as Se, Fragment as Ht } from "react";
5
- import { u as we } from "./use-visual-utils-D_2r0Fmm.js";
6
- import { S as nt } from "./save-QktcpXPy.js";
5
+ import { u as we } from "./use-visual-utils-CmfDomt0.js";
6
+ import { S as nt } from "./save-B1-nDZwS.js";
7
7
  /**
8
8
  * @license lucide-react v0.453.0 - ISC
9
9
  *
@@ -116,7 +116,7 @@ function ua({
116
116
  local: "fill-slate-50 dark:fill-slate-900",
117
117
  linked: "fill-purple-50 dark:fill-purple-950",
118
118
  library: "fill-blue-50 dark:fill-blue-950"
119
- }, V = {
119
+ }, I = {
120
120
  local: /* @__PURE__ */ t("span", { className: "h-2 w-2 rounded-full bg-current/70" }),
121
121
  linked: /* @__PURE__ */ t(Wt, { className: "h-3.5 w-3.5" }),
122
122
  library: /* @__PURE__ */ t(Jt, { className: "h-3.5 w-3.5" })
@@ -136,7 +136,7 @@ function ua({
136
136
  o
137
137
  ),
138
138
  children: [
139
- V[h],
139
+ I[h],
140
140
  i && /* @__PURE__ */ t("span", { className: "ml-1 text-xs font-medium leading-none", children: k[h] })
141
141
  ]
142
142
  }
@@ -170,7 +170,7 @@ function Zt(s, r) {
170
170
  type: r ? s.type : "bar"
171
171
  };
172
172
  }
173
- function Ie(s) {
173
+ function Ve(s) {
174
174
  const r = vt(s);
175
175
  return r ? (Q.error(r), !1) : !0;
176
176
  }
@@ -181,7 +181,7 @@ function pa({
181
181
  const o = L((u) => u.onSave), { getUpdatedFrame: i } = we();
182
182
  function f() {
183
183
  const u = i();
184
- Ie(u) && (o == null || o(u));
184
+ Ve(u) && (o == null || o(u));
185
185
  }
186
186
  return /* @__PURE__ */ d(
187
187
  E,
@@ -209,16 +209,16 @@ function ma({
209
209
  {
210
210
  onClick: () => {
211
211
  const v = x();
212
- if (!Ie(v))
212
+ if (!Ve(v))
213
213
  return;
214
- const V = (C == null ? void 0 : C.visualId) || (h == null ? void 0 : h.id);
215
- if (!V) {
214
+ const I = (C == null ? void 0 : C.visualId) || (h == null ? void 0 : h.id);
215
+ if (!I) {
216
216
  Q.error("No visual to save");
217
217
  return;
218
218
  }
219
219
  f(!0), y.mutate(
220
220
  {
221
- visualId: V,
221
+ visualId: I,
222
222
  data: {
223
223
  frameObject: v
224
224
  }
@@ -226,7 +226,7 @@ function ma({
226
226
  {
227
227
  onSuccess: () => {
228
228
  f(!1), u(!0), Q.success("Visual updated successfully"), o.invalidateQueries({
229
- queryKey: ["resource-by-id", "visual", V],
229
+ queryKey: ["resource-by-id", "visual", I],
230
230
  exact: !0
231
231
  });
232
232
  },
@@ -269,7 +269,7 @@ function fa({
269
269
  i(!0);
270
270
  try {
271
271
  const N = y();
272
- if (!Ie(N)) {
272
+ if (!Ve(N)) {
273
273
  i(!1);
274
274
  return;
275
275
  }
@@ -344,7 +344,7 @@ function ba({
344
344
  setCardSql: y,
345
345
  setSqlGen: m,
346
346
  setCardPython: v,
347
- setCardCustomCfg: V,
347
+ setCardCustomCfg: I,
348
348
  setCardPreferences: k,
349
349
  clearQueryConfig: N,
350
350
  setCardConfig: F,
@@ -359,8 +359,8 @@ function ba({
359
359
  u != null && u.queryData || i({
360
360
  queryKey: C,
361
361
  queryData: O
362
- }), f.setQueryData(C, null), f.removeQueries({ queryKey: C, exact: !0 }), y(""), m({}), N(), F(void 0), v(""), V(""), k({});
363
- const a = L.getState().frame, I = L.getState().card, T = et(a, I), M = ((J = T == null ? void 0 : T.customCardPreferences) == null ? void 0 : J.visualType) === "multiple" || !!((ae = T == null ? void 0 : T.customCardPreferences) != null && ae.dataInputCardIds) || (((q = T == null ? void 0 : T.customCardPreferences) == null ? void 0 : q.minInputs) || 0) > 1 || (((W = T == null ? void 0 : T.customCardPreferences) == null ? void 0 : W.maxInputs) || 0) > 1, R = Zt(I, M);
362
+ }), f.setQueryData(C, null), f.removeQueries({ queryKey: C, exact: !0 }), y(""), m({}), N(), F(void 0), v(""), I(""), k({});
363
+ const a = L.getState().frame, V = L.getState().card, T = et(a, V), M = ((J = T == null ? void 0 : T.customCardPreferences) == null ? void 0 : J.visualType) === "multiple" || !!((ae = T == null ? void 0 : T.customCardPreferences) != null && ae.dataInputCardIds) || (((q = T == null ? void 0 : T.customCardPreferences) == null ? void 0 : q.minInputs) || 0) > 1 || (((W = T == null ? void 0 : T.customCardPreferences) == null ? void 0 : W.maxInputs) || 0) > 1, R = Zt(V, M);
364
364
  X({
365
365
  ...a,
366
366
  cards: a.cards.map(
@@ -662,7 +662,7 @@ function ga({
662
662
  structuralParticipants: y,
663
663
  structuralParticipantIdsByControlId: m,
664
664
  card: v,
665
- allowedControlTypes: V,
665
+ allowedControlTypes: I,
666
666
  onCreateFlowActiveChange: k,
667
667
  onCreateFlowComplete: N
668
668
  }) {
@@ -673,30 +673,30 @@ function ga({
673
673
  null
674
674
  ), [de, O] = j(
675
675
  null
676
- ), [a, I] = j(
676
+ ), [a, V] = j(
677
677
  () => b ? {
678
678
  step: 1,
679
679
  control: re(s, r, Array.from(F))
680
680
  } : null
681
681
  ), T = ke({}), M = ke(void 0), R = ke(b), J = z(() => {
682
682
  const e = Ae({ scope: s, card: v });
683
- if (!V)
683
+ if (!I)
684
684
  return e;
685
- const n = new Set(V);
685
+ const n = new Set(I);
686
686
  return e.filter((l) => n.has(l.value));
687
- }, [V, v, s]), ae = B(
687
+ }, [I, v, s]), ae = B(
688
688
  (e) => {
689
689
  const n = Ae({
690
690
  scope: s,
691
691
  card: v,
692
- includeType: V ? void 0 : e
692
+ includeType: I ? void 0 : e
693
693
  });
694
- if (!V)
694
+ if (!I)
695
695
  return n;
696
- const l = new Set(V);
696
+ const l = new Set(I);
697
697
  return n.filter((c) => l.has(c.value));
698
698
  },
699
- [V, v, s]
699
+ [I, v, s]
700
700
  ), q = B(
701
701
  (e) => s === "dashboard" && (e === "field_selector" || e === "metric_selector"),
702
702
  [s]
@@ -743,7 +743,7 @@ function ga({
743
743
  k == null || k(!!a);
744
744
  }, [a, k]), Se(() => {
745
745
  const e = b && !R.current;
746
- R.current = b, e && (I({
746
+ R.current = b, e && (V({
747
747
  step: 1,
748
748
  control: re(s, r, Array.from(F))
749
749
  }), O(null), H(null));
@@ -775,7 +775,7 @@ function ga({
775
775
  target: l.metricTargetMap[c.value]
776
776
  })) : []
777
777
  };
778
- }, Ve = (e) => {
778
+ }, Ie = (e) => {
779
779
  if (!q(e.control.type))
780
780
  return {
781
781
  nextControl: e.control,
@@ -823,7 +823,7 @@ function ga({
823
823
  );
824
824
  let D, p;
825
825
  if (g && s === "dashboard" && (g.type === "field_selector" || g.type === "metric_selector")) {
826
- const w = (m == null ? void 0 : m[g.id]) || [], P = Ve({
826
+ const w = (m == null ? void 0 : m[g.id]) || [], P = Ie({
827
827
  control: g,
828
828
  nextSelectedCardIds: w
829
829
  });
@@ -894,12 +894,12 @@ function ga({
894
894
  const l = { ...i };
895
895
  delete l[e], A(n, l, { type: "remove", controlId: e });
896
896
  }, pt = B(() => {
897
- M.current = void 0, I({
897
+ M.current = void 0, V({
898
898
  step: 1,
899
899
  control: re(s, r, Array.from(F))
900
900
  }), O(null), H(null);
901
901
  }, [r, F, s]), ee = (e) => {
902
- I(
902
+ V(
903
903
  (n) => n && (() => {
904
904
  const l = e(n.control);
905
905
  n.control.source.kind === "manual" && l.source.kind === "sql_query" && (M.current = n.defaultValue);
@@ -916,7 +916,7 @@ function ga({
916
916
  })()
917
917
  );
918
918
  }, Te = (e) => {
919
- I(
919
+ V(
920
920
  (n) => n && (n.control.source.kind === "manual" && (M.current = e), {
921
921
  ...n,
922
922
  defaultValue: e
@@ -945,7 +945,7 @@ function ga({
945
945
  var D;
946
946
  if (!a)
947
947
  return;
948
- const e = Oe(a.control), n = Vt({
948
+ const e = Oe(a.control), n = It({
949
949
  label: e.label,
950
950
  fallbackId: e.id,
951
951
  existingControls: r,
@@ -961,7 +961,7 @@ function ga({
961
961
  l,
962
962
  a.defaultValue
963
963
  );
964
- I({
964
+ V({
965
965
  step: s === "dashboard" && (l.type === "field_selector" || l.type === "metric_selector") ? 4 : 3,
966
966
  control: l,
967
967
  defaultValue: g,
@@ -970,10 +970,10 @@ function ga({
970
970
  cardBindingsById: c
971
971
  });
972
972
  }, ue = B(() => {
973
- I(null);
973
+ V(null);
974
974
  }, []), qe = B(() => {
975
975
  if (!(a != null && a.createdControlId)) {
976
- I(null);
976
+ V(null);
977
977
  return;
978
978
  }
979
979
  const e = a.control, n = a.createdControlId, l = se(
@@ -1011,7 +1011,7 @@ function ga({
1011
1011
  cardBindingsById: a.cardBindingsById
1012
1012
  }
1013
1013
  );
1014
- O(n), I(null), N == null || N();
1014
+ O(n), V(null), N == null || N();
1015
1015
  }, [r, a, i, A, N]), mt = a ? q(a.control.type) ? ["Choose type", "Select cards", "Configure", "Finish"] : ["Choose type", "Configure", "Finish"] : [], Fe = a != null && a.createdControlId ? `[[param.${a.createdControlId}]]` : a ? `[[param.${Dt(a.control.label) || a.control.id}]]` : "", pe = Be({
1016
1016
  controls: r,
1017
1017
  defaultValues: i
@@ -1049,7 +1049,7 @@ function ga({
1049
1049
  {
1050
1050
  type: "button",
1051
1051
  className: "rounded-control border border-border/60 bg-background px-3 py-2.5 text-left transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:outline-none",
1052
- onClick: () => I(
1052
+ onClick: () => V(
1053
1053
  ra({
1054
1054
  scope: s,
1055
1055
  existingControls: r,
@@ -1116,7 +1116,7 @@ function ga({
1116
1116
  Mt,
1117
1117
  {
1118
1118
  checked: n,
1119
- onCheckedChange: (l) => I(
1119
+ onCheckedChange: (l) => V(
1120
1120
  (c) => c && {
1121
1121
  ...c,
1122
1122
  selectedCardIds: l === !0 ? [
@@ -1147,7 +1147,7 @@ function ga({
1147
1147
  type: "button",
1148
1148
  variant: "outline",
1149
1149
  size: "xs",
1150
- onClick: () => I(
1150
+ onClick: () => V(
1151
1151
  (e) => e && {
1152
1152
  ...e,
1153
1153
  step: 1,
@@ -1162,7 +1162,7 @@ function ga({
1162
1162
  {
1163
1163
  type: "button",
1164
1164
  size: "xs",
1165
- onClick: () => I(
1165
+ onClick: () => V(
1166
1166
  (e) => e && {
1167
1167
  ...e,
1168
1168
  step: 3
@@ -1190,7 +1190,7 @@ function ga({
1190
1190
  label: e
1191
1191
  })),
1192
1192
  onDefaultValueChange: Te,
1193
- onBack: () => I(
1193
+ onBack: () => V(
1194
1194
  (e) => e && {
1195
1195
  ...e,
1196
1196
  step: 1
@@ -1215,7 +1215,7 @@ function ga({
1215
1215
  label: e
1216
1216
  })),
1217
1217
  onDefaultValueChange: Te,
1218
- onBack: () => I(
1218
+ onBack: () => V(
1219
1219
  (e) => e && {
1220
1220
  ...e,
1221
1221
  step: 2
@@ -1239,7 +1239,7 @@ function ga({
1239
1239
  "to choose what this control changes."
1240
1240
  ] }),
1241
1241
  sqlDescription: "Reference this control directly in the SQL editor.",
1242
- onBack: () => I(
1242
+ onBack: () => V(
1243
1243
  (e) => e && {
1244
1244
  ...e,
1245
1245
  step: 2
@@ -1263,7 +1263,7 @@ function ga({
1263
1263
  ] }),
1264
1264
  explorerContent: /* @__PURE__ */ t(K, { children: "Selected cards have been set up to respond to this control automatically." }),
1265
1265
  sqlDescription: "SQL cards can still reference this control directly in the SQL editor.",
1266
- onBack: () => I(
1266
+ onBack: () => V(
1267
1267
  (e) => e && {
1268
1268
  ...e,
1269
1269
  step: 3
@@ -1403,7 +1403,7 @@ function ga({
1403
1403
  })),
1404
1404
  selectedCardIds: (m == null ? void 0 : m[e.id]) || [],
1405
1405
  onChange: (p) => {
1406
- const S = Ve({
1406
+ const S = Ie({
1407
1407
  control: e,
1408
1408
  nextSelectedCardIds: p
1409
1409
  }), _ = r.map(
@@ -1494,7 +1494,7 @@ function ga({
1494
1494
  })),
1495
1495
  children: [
1496
1496
  /* @__PURE__ */ t(ge, { size: "xs", children: /* @__PURE__ */ t(ye, {}) }),
1497
- /* @__PURE__ */ t(xe, { children: It.map((p) => /* @__PURE__ */ t(
1497
+ /* @__PURE__ */ t(xe, { children: Vt.map((p) => /* @__PURE__ */ t(
1498
1498
  ve,
1499
1499
  {
1500
1500
  value: p.value,
@@ -1558,7 +1558,7 @@ function ya(s) {
1558
1558
  Se(() => {
1559
1559
  y || C(!1);
1560
1560
  }, [y]);
1561
- const V = B(
1561
+ const I = B(
1562
1562
  (k) => {
1563
1563
  h && k.preventDefault();
1564
1564
  },
@@ -1568,7 +1568,7 @@ function ya(s) {
1568
1568
  forceClose: v,
1569
1569
  handleOpenChange: m,
1570
1570
  isCreateFlowActive: h,
1571
- preventPassiveDismissDuringCreate: V,
1571
+ preventPassiveDismissDuringCreate: I,
1572
1572
  resolvedOpen: y,
1573
1573
  setIsCreateFlowActive: C
1574
1574
  };
@@ -1,5 +1,5 @@
1
- import { q as X, u as Y, r as Z, s as ee, t as te, v as re, w as se, x as ae, p as V, y as oe } from "./index-DQApwxKL.js";
2
- import { l as ne, m as ie, u as b, n as z, o as ce } from "./switch-BuZXNXQV.js";
1
+ import { p as X, u as Y, q as Z, r as ee, s as te, t as re, v as se, w as ae, o as V, x as oe } from "./index-BxYIELMe.js";
2
+ import { l as ne, m as ie, u as b, n as z, o as ce } from "./switch-BZn7R_Cp.js";
3
3
  import { useState as H, useEffect as de, useCallback as A } from "react";
4
4
  function le(e) {
5
5
  const [a, s] = H(null), [r, t] = H(null), o = X();
@@ -1 +1 @@
1
- "use strict";const u=require("./index-CwzM5Lxh.js"),f=require("./switch-B72T1Hf_.js"),S=require("react");function K(e){const[a,s]=S.useState(null),[r,t]=S.useState(null),o=u.useEnsureReactGlobals();return S.useEffect(()=>{if(!e||e.trim()===""){s(null),t(null);return}if(!o)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const i=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(i,{method:"HEAD"})).ok)throw new Error(`Module not found at ${i}`)}catch{}const m=await import(i);if(typeof m.useChartStore!="function")throw new Error("useChartStore is not a function");s(()=>m.useChartStore),t(null)}catch(n){const i=n instanceof Error?n.message:"Unknown error";console.error("Failed to load remote chart store:",i),t(i),s(null)}})()},[e,o]),a}function X(e,a){if(e.length===0)return"";const s=e.find(r=>{var t,o;return((t=r.customCardPreferences)==null?void 0:t.visualType)==="multiple"||!!((o=r.customCardPreferences)!=null&&o.dataInputCardIds)});if(s)return s.id;if(a){const r=e.find(t=>t.id===a);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const l=t.split("__")[0],n=e.find(i=>i.tabTitle===l);return n?n.id:e[0].id}return a}}return e[0].id}const A=new Set;function Y(e){return A.add(e),()=>{A.delete(e)}}function z(){A.forEach(e=>{e()})}const Z=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:a,...s}=e;return s};async function B(e,a,s,r){if(!a||!s)throw new Error("Missing auth token or visual ID");const t=["resource-by-id","visual",s],o=r.getQueryData(t);if(o)return console.log("Using cached visual data for:",s),{data:o,fromCache:!0};console.log("Fetching visual data from network for:",s);const l=u.ue.loading("Loading visual...",{position:"top-center"});try{const n=await fetch(`${e}/management/v1/visuals/${s}`,{headers:{Authorization:`Bearer ${a}`}});if(!n.ok)throw new Error("Failed to load visual");const i=await n.json();return r.setQueryData(t,i),u.ue.dismiss(l),{data:i,fromCache:!1}}catch(n){throw u.ue.dismiss(l),n}}function H(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function ee(e,a){var o,l;const s=(e==null?void 0:e.frameObject)??((o=e==null?void 0:e.visual)==null?void 0:o.frameObject);if(!s)return!1;const r=H(s);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const t=(l=r.cards)==null?void 0:l.find(n=>n.id===r.activeCardId);return t?(u.setupEditorWithCard({...a,frame:r,card:t,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function te(){const e=f.useEditorStore(r=>{var t;return((t=r.card.customCardPreferences)==null?void 0:t.url)||""}),a=K(e);return{getUpdatedFrame:S.useCallback(()=>{var b;z();const{frame:r,card:t,isDevMode:o,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y}=f.useEditorStore.getState(),I=t.sql,U=(b=a==null?void 0:a.getState())==null?void 0:b.settings,V=f.buildSavedEditorCard(t,{isDevMode:o,cardSql:I,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y,remoteChartSettings:U,stripConfig:Z}),g=r.cards.map(E=>E.id===t.id?V:E);return{...r,cards:g,activeCardId:X(g,r.activeCardId)}},[a])}}function re(){const{authToken:e,tokenProps:a}=u.useSemaphorContext(),s=u.useQueryClient(),r=u.useAddFrameWithFreshSemanticExecutionPayload(),t=u.useSelectedVisual(),{selectVisual:o}=u.useManagementActions(),{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,clearEditorContext:L}=f.useEditorActions(),{setIsDashboardEditing:v,setIsVisualEditing:T,setSelectedFrameId:j,clearSelectedFrameId:N,setIsDashboardPanelOpen:R}=f.useDashboardActions(),w=f.useDashboardStore(c=>c.selectedSheetId),W=f.useDashboardStore(c=>c.selectedFrameId),$=f.useDashboardStore(c=>c.dashboard),_=f.useDashboardStore(c=>c.filterValues),x=f.useDashboardStore(c=>c.inlineFilterValuesMap),F=u.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),Q=S.useCallback(async c=>{try{o(c),N(),L();const{data:h,fromCache:D}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s);if(!ee(h,{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,setIsDashboardEditing:v,setIsVisualEditing:T,dashboard:$,selectedSheetId:w,selectedFrameId:W,filterValues:_,inlineFilterValuesMap:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:D}}catch(h){return console.error("Error editing visual:",h),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,l,n,v,T,i,m,p,y,I,U,V,g,b,E,P,M,k,L,N,$,w,W,_,x]),G=S.useCallback(async c=>{var D;const h=d=>(u.ue.error(d),{success:!1,error:d});try{if(o(c),!w)return h("No sheet selected. Please select a sheet first.");const{data:d,fromCache:J}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s),O=(d==null?void 0:d.frameObject)??((D=d==null?void 0:d.visual)==null?void 0:D.frameObject);if(!O)return h("Visual has no frame data");const C=H(O);if(!(C!=null&&C.cards)||C.cards.length===0)return h("Visual frame is malformed");const q={...u.cloneLinkedFrameWithSourceMapping(C),visualId:c.id};return await r(w,q,"end"),v(!0),j(q.id),R(!1),{success:!0,fromCache:J}}catch(d){return console.error("Error adding visual:",d),h(d instanceof Error?d.message:"Failed to add visual to dashboard")}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,w,v,j,R,r]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:Q,handleAddLibraryVisual:G,getUpdatedFrame:te().getUpdatedFrame,refetch:F.refetch}}exports.flushPendingEditorDrafts=z;exports.registerPendingEditorDraftFlusher=Y;exports.useVisualUtils=re;
1
+ "use strict";const u=require("./index-C0zD3JgK.js"),f=require("./switch-BG4RWnrq.js"),S=require("react");function K(e){const[a,s]=S.useState(null),[r,t]=S.useState(null),o=u.useEnsureReactGlobals();return S.useEffect(()=>{if(!e||e.trim()===""){s(null),t(null);return}if(!o)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const i=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(i,{method:"HEAD"})).ok)throw new Error(`Module not found at ${i}`)}catch{}const m=await import(i);if(typeof m.useChartStore!="function")throw new Error("useChartStore is not a function");s(()=>m.useChartStore),t(null)}catch(n){const i=n instanceof Error?n.message:"Unknown error";console.error("Failed to load remote chart store:",i),t(i),s(null)}})()},[e,o]),a}function X(e,a){if(e.length===0)return"";const s=e.find(r=>{var t,o;return((t=r.customCardPreferences)==null?void 0:t.visualType)==="multiple"||!!((o=r.customCardPreferences)!=null&&o.dataInputCardIds)});if(s)return s.id;if(a){const r=e.find(t=>t.id===a);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const l=t.split("__")[0],n=e.find(i=>i.tabTitle===l);return n?n.id:e[0].id}return a}}return e[0].id}const A=new Set;function Y(e){return A.add(e),()=>{A.delete(e)}}function z(){A.forEach(e=>{e()})}const Z=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:a,...s}=e;return s};async function B(e,a,s,r){if(!a||!s)throw new Error("Missing auth token or visual ID");const t=["resource-by-id","visual",s],o=r.getQueryData(t);if(o)return console.log("Using cached visual data for:",s),{data:o,fromCache:!0};console.log("Fetching visual data from network for:",s);const l=u.ue.loading("Loading visual...",{position:"top-center"});try{const n=await fetch(`${e}/management/v1/visuals/${s}`,{headers:{Authorization:`Bearer ${a}`}});if(!n.ok)throw new Error("Failed to load visual");const i=await n.json();return r.setQueryData(t,i),u.ue.dismiss(l),{data:i,fromCache:!1}}catch(n){throw u.ue.dismiss(l),n}}function H(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function ee(e,a){var o,l;const s=(e==null?void 0:e.frameObject)??((o=e==null?void 0:e.visual)==null?void 0:o.frameObject);if(!s)return!1;const r=H(s);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const t=(l=r.cards)==null?void 0:l.find(n=>n.id===r.activeCardId);return t?(u.setupEditorWithCard({...a,frame:r,card:t,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function te(){const e=f.useEditorStore(r=>{var t;return((t=r.card.customCardPreferences)==null?void 0:t.url)||""}),a=K(e);return{getUpdatedFrame:S.useCallback(()=>{var b;z();const{frame:r,card:t,isDevMode:o,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y}=f.useEditorStore.getState(),I=t.sql,U=(b=a==null?void 0:a.getState())==null?void 0:b.settings,V=f.buildSavedEditorCard(t,{isDevMode:o,cardSql:I,isShowingVisual:l,selectedSchemaName:n,selectedDatamodelId:i,selectedDatabaseName:m,selectedTableName:p,selectedConnectionId:y,remoteChartSettings:U,stripConfig:Z}),g=r.cards.map(E=>E.id===t.id?V:E);return{...r,cards:g,activeCardId:X(g,r.activeCardId)}},[a])}}function re(){const{authToken:e,tokenProps:a}=u.useSemaphorContext(),s=u.useQueryClient(),r=u.useAddFrameWithFreshSemanticExecutionPayload(),t=u.useSelectedVisual(),{selectVisual:o}=u.useManagementActions(),{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,clearEditorContext:L}=f.useEditorActions(),{setIsDashboardEditing:v,setIsVisualEditing:T,setSelectedFrameId:j,clearSelectedFrameId:N,setIsDashboardPanelOpen:R}=f.useDashboardActions(),w=f.useDashboardStore(c=>c.selectedSheetId),W=f.useDashboardStore(c=>c.selectedFrameId),$=f.useDashboardStore(c=>c.dashboard),_=f.useDashboardStore(c=>c.filterValues),x=f.useDashboardStore(c=>c.inlineFilterValuesMap),F=u.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),Q=S.useCallback(async c=>{try{o(c),N(),L();const{data:h,fromCache:D}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s);if(!ee(h,{setFrame:l,setCard:n,setIsDevMode:i,initializeModeDrafts:m,setActiveTabCardId:p,updateDataSource:y,setQueryResultColumns:I,setSelectedConnectionId:U,setSelectedDatabaseName:V,setSelectedSchemaName:g,setSelectedTableName:b,setSelectedDatamodelId:E,setFilterValues:P,setInlineFilterValuesMap:M,setApplyFilters:k,setIsDashboardEditing:v,setIsVisualEditing:T,dashboard:$,selectedSheetId:w,selectedFrameId:W,filterValues:_,inlineFilterValuesMap:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:D}}catch(h){return console.error("Error editing visual:",h),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,l,n,v,T,i,m,p,y,I,U,V,g,b,E,P,M,k,L,N,$,w,W,_,x]),G=S.useCallback(async c=>{var D;const h=d=>(u.ue.error(d),{success:!1,error:d});try{if(o(c),!w)return h("No sheet selected. Please select a sheet first.");const{data:d,fromCache:J}=await B(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",c.id,s),O=(d==null?void 0:d.frameObject)??((D=d==null?void 0:d.visual)==null?void 0:D.frameObject);if(!O)return h("Visual has no frame data");const C=H(O);if(!(C!=null&&C.cards)||C.cards.length===0)return h("Visual frame is malformed");const q={...u.cloneLinkedFrameWithSourceMapping(C),visualId:c.id};return await r(w,q,"end"),v(!0),j(q.id),R(!1),{success:!0,fromCache:J}}catch(d){return console.error("Error adding visual:",d),h(d instanceof Error?d.message:"Failed to add visual to dashboard")}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,w,v,j,R,r]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:Q,handleAddLibraryVisual:G,getUpdatedFrame:te().getUpdatedFrame,refetch:F.refetch}}exports.flushPendingEditorDrafts=z;exports.registerPendingEditorDraftFlusher=Y;exports.useVisualUtils=re;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-CwzM5Lxh.js"),e=require("../chunks/common-types-nBuCd3u2.js");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-C0zD3JgK.js"),e=require("../chunks/common-types-nBuCd3u2.js");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as o } from "../chunks/index-DQApwxKL.js";
1
+ import { D as o } from "../chunks/index-BxYIELMe.js";
2
2
  import { C as s, E as C } from "../chunks/common-types-C6cAQgyh.js";
3
3
  export {
4
4
  s as CONTROL_CARD_DEFAULT_VALUE,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-CwzM5Lxh.js"),M=require("./chunks/common-types-nBuCd3u2.js"),L=require("./chunks/dashboard-summary-settings-dialog-8vZtKUjh.js"),t=require("react/jsx-runtime"),r=require("./chunks/switch-B72T1Hf_.js"),m=require("react"),z=require("./chunks/resource-management-panel-BqJAVm7E.js"),B=require("./types/index.cjs"),q=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");require("./chunks/index-DRlMUglg.js");const y=require("./chunks/dashboard-filter-controls-button-Bu90ytxy.js"),O=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function Q(s){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const o in s)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(s,o);Object.defineProperty(a,o,l.get?l:{enumerable:!0,get:()=>s[o]})}}return a.default=s,Object.freeze(a)}const P=Q(m);function V(s){const{authToken:a,tokenProps:o}=e.useSemaphorContext();return e.useMutation({mutationFn:async l=>e.backtestAlert(o.apiServiceUrl,a.accessToken,s,l)})}function W(s){const{displayPreferences:a,cardId:o,...l}=s,i={...l,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:i,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:s.cardId}),t.jsx(e.UXProvider,{appearance:s.appearance,children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:a,children:t.jsx(e.Container,{type:"visual",cardId:o,...i,children:t.jsx(H,{cardId:o})})})})]})})}function H({cardId:s}){const a=r.useDashboardStore(i=>{var u;return(u=i.dashboard)==null?void 0:u.sheets}),{card:o,frame:l}=m.useMemo(()=>{const i=a==null?void 0:a.flatMap(d=>d.frames),u=i==null?void 0:i.flatMap(d=>d==null?void 0:d.cards),h=u==null?void 0:u.find(d=>(d==null?void 0:d.id)===s),n=i==null?void 0:i.find(d=>{var x;return(x=d==null?void 0:d.cards)==null?void 0:x.find(A=>(A==null?void 0:A.id)===s)});return{card:h,frame:n}},[a,s]);return!o||!l?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${s}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:i,resetErrorBoundary:u})=>t.jsx(e.FallbackVisual,{error:i,resetErrorBoundary:u,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:o,frame:l})})})}function $(s,a,o,l){m.useEffect(()=>{s&&!o&&a&&l(e.cloneDeep(a))},[s,o,a,l])}function G({name:s,items:a,value:o,onChange:l,isLoading:i,isError:u,refetch:h,className:n,icon:d,showNone:x=!1}){const A=P.useRef(null),[b,C]=P.useState(!1),[j,N]=P.useState("100%"),D=x?[...a||[],{id:"none",name:"None"}]:a;P.useLayoutEffect(()=>{A.current&&N(A.current.offsetWidth)},[]);function w(){var p;return i?"Loading...":u?"Error":o?(p=a==null?void 0:a.find(S=>S.id===o))==null?void 0:p.name:`Select ${s}`}function R(p,S){l(S),C(!1)}return t.jsxs(r.Popover,{open:b,onOpenChange:C,children:[t.jsx(r.PopoverTrigger,{asChild:!0,children:t.jsxs(r.Button,{ref:A,variant:"outline",role:"combobox","aria-expanded":b,className:r.cn("flex h-9 w-full justify-between",n),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[d&&t.jsx("div",{className:"mr-2",children:d}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:w()})]}),t.jsx(r.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(r.PopoverContent,{className:"w-full p-0",style:{minWidth:j},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:h,children:t.jsx(e.RefreshCw,{className:r.cn("size-3.5 opacity-50",i&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",s==null?void 0:s.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:D==null?void 0:D.map(p=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:p.name,onSelect:S=>R(S,p.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(r.Check,{className:r.cn("size-4",o===p.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:p.name,children:p.name})]})},p.id))})]})]})})]})}function K({triggerButtonClassName:s,variant:a="ghost"}){const[o,l]=m.useState(!1),i=r.useDashboardStore(h=>{var n;return(n=h.dashboard)==null?void 0:n.id}),u=r.useDashboardStore(h=>{var n;return(n=h.dashboard)==null?void 0:n.title});return i?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:r.cn("h-7 p-2",s),buttonProps:{variant:a},onClick:()=>l(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:o,onOpenChange:l,dashboardId:i,dashboardName:u})]}):null}function Y(s,a){m.useEffect(()=>(s&&a&&(window.__SEMAPHOR_PRINT_STATE__={...a}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,a])}function _(s){if(!s)return"--";const a=new Date(s);return Number.isNaN(a.getTime())?"--":a.toLocaleString()}function X(s){var a;return((a=s.alertState)==null?void 0:a.currentState)==="FIRING"?"Signal surfaced":s.status==="ACTIVE"?"Watching":s.status==="PAUSED"?"Paused":s.status}function J({alertId:s,onBack:a}){var p,S,I,F;const{authToken:o,tokenProps:l}=e.useSemaphorContext(),{data:i,isLoading:u,refetch:h}=e.useAlertDetail(s),n=(i==null?void 0:i.alert)??null,[d,x]=m.useState([]),[A,b]=m.useState([]),[C,j]=m.useState(null),N=m.useCallback(async()=>{var f;const c=l==null?void 0:l.apiServiceUrl,g=o==null?void 0:o.accessToken;if(!c||!g||!s)return null;try{const E=await fetch(`${c}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const T=await E.json(),v=Array.isArray(T.runs)?T.runs:[],k=C&&v.some(U=>U.id===C)?C:((f=v[0])==null?void 0:f.id)??null;return b(v),j(k),k}b([]),j(null)}catch{return b([]),j(null),null}return null},[s,o,C,l]),D=m.useCallback(async c=>{const g=l==null?void 0:l.apiServiceUrl,f=o==null?void 0:o.accessToken,E=c??C;if(!g||!f||!s||!E){x([]);return}try{const T=await fetch(`${g}/v1/alerts/${s}/runs/${E}/deliveries`,{headers:{Authorization:`Bearer ${f}`}});if(T.ok){const v=await T.json();x(Array.isArray(v.attempts)?v.attempts:[])}else x([])}catch{x([])}},[s,o,C,l]),w=m.useCallback(async()=>{await h();const c=await N();await D(c)},[D,N,h]);m.useEffect(()=>{N().catch(()=>{})},[N]),m.useEffect(()=>{D().catch(()=>{})},[D]);const R=m.useMemo(()=>{const c={};for(const g of d)c[g.channel]||(c[g.channel]=[]),c[g.channel].push(g);return c},[d]);return u?t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading signal detail..."}):n?t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[a&&t.jsx(r.Button,{variant:"outline",size:"sm",onClick:a,children:"Back"}),t.jsx("h2",{className:"text-lg font-semibold",children:n.name}),t.jsx(e.Badge,{variant:n.status==="ACTIVE"?"default":"secondary",children:X(n)}),((p=n.alertState)==null?void 0:p.currentState)&&t.jsx(e.Badge,{variant:n.alertState.currentState==="FIRING"?"destructive":"outline",children:n.alertState.currentState==="FIRING"?"Signal surfaced":"Stable"})]}),t.jsx(r.Button,{variant:"outline",size:"sm",onClick:()=>void w(),children:"Refresh"})]}),n.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-4 text-sm",children:[t.jsx("p",{className:"font-medium",children:"What changed"}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"Review the latest signal activity, then investigate the underlying dashboard context if you need more detail."})]}),t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Signal Watch"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Watching for:"})," ",e.formatSignalCondition(n.jobConfig.operator,n.jobConfig.threshold)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Severity:"})," ",n.jobConfig.severity]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Evaluated:"})," ",_((S=n.alertState)==null?void 0:S.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",_((I=n.alertState)==null?void 0:I.lastTriggeredAt)]})]})]}),((F=n.deliveryConfig)==null?void 0:F.channels)&&n.deliveryConfig.channels.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Where It Surfaces"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:n.deliveryConfig.channels.map(c=>t.jsx(e.Badge,{variant:"outline",children:c},c))})]}),A.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Recent Delivery Activity"}),A.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:A.map(c=>t.jsx(r.Button,{variant:c.id===C?"default":"outline",size:"sm",onClick:()=>j(c.id),children:_(c.scheduledFor)},c.id))}),Object.keys(R).length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No delivery attempts were recorded for this run."}):Object.entries(R).map(([c,g])=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(e.Badge,{variant:"secondary",className:"text-xs",children:c})}),t.jsx("div",{className:"overflow-hidden rounded border",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Recipient"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Status"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Time"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Error"})]})}),t.jsx("tbody",{children:g.map(f=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-2 py-1",children:f.recipient}),t.jsx("td",{className:"px-2 py-1",children:t.jsx(e.Badge,{variant:f.status==="SENT"?"default":"destructive",className:"text-[10px]",children:f.status})}),t.jsx("td",{className:"px-2 py-1",children:_(f.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:f.error||"--"})]},f.id))})]})})]},c))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function Z(){var u,h;const{quotasQuery:s,usageQuery:a}=e.useAlertQuotas(),o=((u=s.data)==null?void 0:u.quotas)||[],l=((h=a.data)==null?void 0:h.usage)||[],i=new Map(l.map(n=>[n.tenantId||"org",n]));return t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Alert Quotas"}),t.jsx(r.Button,{variant:"outline",size:"sm",onClick:()=>{s.refetch(),a.refetch()},children:"Refresh"})]}),s.isLoading||a.isLoading?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading quota usage..."}):null,t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Tenant"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Active Alerts"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Active"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Min Cadence"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Context Sources"})]})}),t.jsx("tbody",{children:o.map(n=>{const d=n.tenantId||"org",x=i.get(d);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:d}),t.jsx("td",{className:"px-3 py-2",children:(x==null?void 0:x.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:n.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[n.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:n.policy.maxContextSources})]},d)})})]})})]})}exports.AlertManagementPage=e.AlertManagementPage;exports.AlertWizardDialog=e.AlertWizardDialog;exports.AlertsApiError=e.AlertsApiError;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.backtestAlert=e.backtestAlert;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createAlert=e.createAlert;exports.createExport=e.createExport;exports.deleteAlert=e.deleteAlert;exports.downloadDocumentPdf=e.downloadDocumentPdf;exports.downloadPdf=e.downloadPdf;exports.formatFileSize=e.formatFileSize;exports.getAlert=e.getAlert;exports.getAlertContextSources=e.getAlertContextSources;exports.getAlertHistory=e.getAlertHistory;exports.getAlertQuotaUsage=e.getAlertQuotaUsage;exports.getAlertRunDeliveries=e.getAlertRunDeliveries;exports.getAlertRunSteps=e.getAlertRunSteps;exports.getAlertRuns=e.getAlertRuns;exports.getAlertState=e.getAlertState;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.triggerAlertNow=e.triggerAlertNow;exports.updateAlert=e.updateAlert;exports.updateAlertContextSources=e.updateAlertContextSources;exports.updateAlertQuota=e.updateAlertQuota;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useAlertActions=e.useAlertActions;exports.useAlertDeliveries=e.useAlertDeliveries;exports.useAlertDetail=e.useAlertDetail;exports.useAlertDraft=e.useAlertDraft;exports.useAlertFilters=e.useAlertFilters;exports.useAlertHistory=e.useAlertHistory;exports.useAlertQuotas=e.useAlertQuotas;exports.useAlertRuns=e.useAlertRuns;exports.useAlertState=e.useAlertState;exports.useAlertStore=e.useAlertStore;exports.useAlertWizard=e.useAlertWizard;exports.useAlerts=e.useAlerts;exports.useAlertsBootstrap=e.useAlertsBootstrap;exports.useAlertsById=e.useAlertsById;exports.useAlertsForCard=e.useAlertsForCard;exports.useCard=e.useCard;exports.useCardAlertMap=e.useCardAlertMap;exports.useCardSummary=e.useCardSummary;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorAside=e.useEditorAside;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useSelectedAlertId=e.useSelectedAlertId;exports.useTextFilterHook=e.useTextFilterHook;exports.CONTROL_CARD_DEFAULT_VALUE=M.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=M.EMPTY_SELECTION;exports.CalendarPreferencesDialog=L.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=L.DashboardSummarySettingsDialog;exports.CALCULATED_FIELD_ENTITY_MARKER=r.CALCULATED_FIELD_ENTITY_MARKER;exports.DATE_FORMAT_VALUES=r.DATE_FORMAT_VALUES;exports.PivotMarkerEnum=r.PivotMarkerEnum;exports.createEmptyKpiConfig=r.createEmptyKpiConfig;exports.createSqlGenConfig=r.createSqlGenConfig;exports.emitDashboardLoad=r.emitDashboardLoad;exports.emitDashboardUnload=r.emitDashboardUnload;exports.fmt=r.fmt;exports.getColumnDataType=r.getColumnDataType;exports.getFilterValueType=r.getFilterValueType;exports.getFormattedTableNameForQuery=r.getFormattedTableNameForQuery;exports.getQualifiedTableName=r.getQualifiedTableName;exports.getSql=r.getSql;exports.invalidateToken=r.invalidateToken;exports.isBooleanDataType=r.isBooleanDataType;exports.isCalculatedDimension=r.isCalculatedDimension;exports.isCalculatedField=r.isCalculatedField;exports.isCalculatedMetric=r.isCalculatedMetric;exports.isColumnInSqlGen=r.isColumnInSqlGen;exports.isDateDataType=r.isDateDataType;exports.isNumberDataType=r.isNumberDataType;exports.isTextDataType=r.isTextDataType;exports.resolveDataType=r.resolveDataType;exports.resolveDatamodelName=r.resolveDatamodelName;exports.useCurrentActiveCard=r.useCurrentActiveCard;exports.useCurrentCardConfig=r.useCurrentCardConfig;exports.useCurrentSheetActiveCards=r.useCurrentSheetActiveCards;exports.useDashboardActions=r.useDashboardActions;exports.useDashboardStore=r.useDashboardStore;exports.useEditorActions=r.useEditorActions;exports.useEditorStore=r.useEditorStore;exports.ResourceManagementPanel=z.ResourceManagementPanel;exports.DEFAULT_CALENDAR_CONTEXT=B.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=B.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.useDebouncedDirtyCheck=q.useDebouncedDirtyCheck;exports.AdvancedModeToggle=y.AdvancedModeToggle;exports.DashboardControlsSettings=y.DashboardControlsSettings;exports.DashboardFilterControlsButton=y.DashboardFilterControlsButton;exports.ExportNotificationItem=y.ExportNotificationItem;exports.ExportNotificationList=y.ExportNotificationList;exports.NotificationBell=y.NotificationBell;exports.UnsavedChangesAlert=y.UnsavedChangesAlert;exports.VisualEditingControls=y.VisualEditingControls;exports.useExportPolling=y.useExportPolling;exports.useExportRecovery=y.useExportRecovery;exports.normalizeDashboardForDirtyCheck=O.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=O.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=J;exports.Combobox=G;exports.ScheduleDashboard=K;exports.TenantQuotaPage=Z;exports.Visual=W;exports.useAlertBacktest=V;exports.useExposePrintState=Y;exports.usePristineSnapshotInitializer=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-C0zD3JgK.js"),M=require("./chunks/common-types-nBuCd3u2.js"),L=require("./chunks/dashboard-summary-settings-dialog-Cc3yKCu4.js"),t=require("react/jsx-runtime"),r=require("./chunks/switch-BG4RWnrq.js"),m=require("react"),z=require("./chunks/resource-management-panel-B4QM3fZ_.js"),B=require("./types/index.cjs"),q=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");require("./chunks/index-DRlMUglg.js");const y=require("./chunks/dashboard-filter-controls-button-D0nrJ7wl.js"),O=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function Q(s){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const o in s)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(s,o);Object.defineProperty(a,o,l.get?l:{enumerable:!0,get:()=>s[o]})}}return a.default=s,Object.freeze(a)}const P=Q(m);function V(s){const{displayPreferences:a,cardId:o,...l}=s,i={...l,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:i,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:s.cardId}),t.jsx(e.UXProvider,{appearance:s.appearance,children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:a,children:t.jsx(e.Container,{type:"visual",cardId:o,...i,children:t.jsx(W,{cardId:o})})})})]})})}function W({cardId:s}){const a=r.useDashboardStore(i=>{var u;return(u=i.dashboard)==null?void 0:u.sheets}),{card:o,frame:l}=m.useMemo(()=>{const i=a==null?void 0:a.flatMap(d=>d.frames),u=i==null?void 0:i.flatMap(d=>d==null?void 0:d.cards),h=u==null?void 0:u.find(d=>(d==null?void 0:d.id)===s),n=i==null?void 0:i.find(d=>{var x;return(x=d==null?void 0:d.cards)==null?void 0:x.find(A=>(A==null?void 0:A.id)===s)});return{card:h,frame:n}},[a,s]);return!o||!l?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${s}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:i,resetErrorBoundary:u})=>t.jsx(e.FallbackVisual,{error:i,resetErrorBoundary:u,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:o,frame:l})})})}function H(s,a,o,l){m.useEffect(()=>{s&&!o&&a&&l(e.cloneDeep(a))},[s,o,a,l])}function $({name:s,items:a,value:o,onChange:l,isLoading:i,isError:u,refetch:h,className:n,icon:d,showNone:x=!1}){const A=P.useRef(null),[b,C]=P.useState(!1),[j,N]=P.useState("100%"),D=x?[...a||[],{id:"none",name:"None"}]:a;P.useLayoutEffect(()=>{A.current&&N(A.current.offsetWidth)},[]);function w(){var p;return i?"Loading...":u?"Error":o?(p=a==null?void 0:a.find(S=>S.id===o))==null?void 0:p.name:`Select ${s}`}function R(p,S){l(S),C(!1)}return t.jsxs(r.Popover,{open:b,onOpenChange:C,children:[t.jsx(r.PopoverTrigger,{asChild:!0,children:t.jsxs(r.Button,{ref:A,variant:"outline",role:"combobox","aria-expanded":b,className:r.cn("flex h-9 w-full justify-between",n),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[d&&t.jsx("div",{className:"mr-2",children:d}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:w()})]}),t.jsx(r.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(r.PopoverContent,{className:"w-full p-0",style:{minWidth:j},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:h,children:t.jsx(e.RefreshCw,{className:r.cn("size-3.5 opacity-50",i&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",s==null?void 0:s.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:D==null?void 0:D.map(p=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:p.name,onSelect:S=>R(S,p.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(r.Check,{className:r.cn("size-4",o===p.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:p.name,children:p.name})]})},p.id))})]})]})})]})}function G({triggerButtonClassName:s,variant:a="ghost"}){const[o,l]=m.useState(!1),i=r.useDashboardStore(h=>{var n;return(n=h.dashboard)==null?void 0:n.id}),u=r.useDashboardStore(h=>{var n;return(n=h.dashboard)==null?void 0:n.title});return i?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:r.cn("h-7 p-2",s),buttonProps:{variant:a},onClick:()=>l(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:o,onOpenChange:l,dashboardId:i,dashboardName:u})]}):null}function K(s){const{authToken:a,tokenProps:o}=e.useSemaphorContext();return e.useMutation({mutationFn:async l=>e.backtestAlert(o.apiServiceUrl,a.accessToken,s,l)})}function Y(s,a){m.useEffect(()=>(s&&a&&(window.__SEMAPHOR_PRINT_STATE__={...a}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,a])}function _(s){if(!s)return"--";const a=new Date(s);return Number.isNaN(a.getTime())?"--":a.toLocaleString()}function X(s){var a;return((a=s.alertState)==null?void 0:a.currentState)==="FIRING"?"Signal surfaced":s.status==="ACTIVE"?"Watching":s.status==="PAUSED"?"Paused":s.status}function J({alertId:s,onBack:a}){var p,S,I,F;const{authToken:o,tokenProps:l}=e.useSemaphorContext(),{data:i,isLoading:u,refetch:h}=e.useAlertDetail(s),n=(i==null?void 0:i.alert)??null,[d,x]=m.useState([]),[A,b]=m.useState([]),[C,j]=m.useState(null),N=m.useCallback(async()=>{var f;const c=l==null?void 0:l.apiServiceUrl,g=o==null?void 0:o.accessToken;if(!c||!g||!s)return null;try{const E=await fetch(`${c}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const T=await E.json(),v=Array.isArray(T.runs)?T.runs:[],k=C&&v.some(U=>U.id===C)?C:((f=v[0])==null?void 0:f.id)??null;return b(v),j(k),k}b([]),j(null)}catch{return b([]),j(null),null}return null},[s,o,C,l]),D=m.useCallback(async c=>{const g=l==null?void 0:l.apiServiceUrl,f=o==null?void 0:o.accessToken,E=c??C;if(!g||!f||!s||!E){x([]);return}try{const T=await fetch(`${g}/v1/alerts/${s}/runs/${E}/deliveries`,{headers:{Authorization:`Bearer ${f}`}});if(T.ok){const v=await T.json();x(Array.isArray(v.attempts)?v.attempts:[])}else x([])}catch{x([])}},[s,o,C,l]),w=m.useCallback(async()=>{await h();const c=await N();await D(c)},[D,N,h]);m.useEffect(()=>{N().catch(()=>{})},[N]),m.useEffect(()=>{D().catch(()=>{})},[D]);const R=m.useMemo(()=>{const c={};for(const g of d)c[g.channel]||(c[g.channel]=[]),c[g.channel].push(g);return c},[d]);return u?t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading signal detail..."}):n?t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[a&&t.jsx(r.Button,{variant:"outline",size:"sm",onClick:a,children:"Back"}),t.jsx("h2",{className:"text-lg font-semibold",children:n.name}),t.jsx(e.Badge,{variant:n.status==="ACTIVE"?"default":"secondary",children:X(n)}),((p=n.alertState)==null?void 0:p.currentState)&&t.jsx(e.Badge,{variant:n.alertState.currentState==="FIRING"?"destructive":"outline",children:n.alertState.currentState==="FIRING"?"Signal surfaced":"Stable"})]}),t.jsx(r.Button,{variant:"outline",size:"sm",onClick:()=>void w(),children:"Refresh"})]}),n.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-4 text-sm",children:[t.jsx("p",{className:"font-medium",children:"What changed"}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"Review the latest signal activity, then investigate the underlying dashboard context if you need more detail."})]}),t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Signal Watch"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Watching for:"})," ",e.formatSignalCondition(n.jobConfig.operator,n.jobConfig.threshold)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Severity:"})," ",n.jobConfig.severity]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Evaluated:"})," ",_((S=n.alertState)==null?void 0:S.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",_((I=n.alertState)==null?void 0:I.lastTriggeredAt)]})]})]}),((F=n.deliveryConfig)==null?void 0:F.channels)&&n.deliveryConfig.channels.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Where It Surfaces"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:n.deliveryConfig.channels.map(c=>t.jsx(e.Badge,{variant:"outline",children:c},c))})]}),A.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Recent Delivery Activity"}),A.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:A.map(c=>t.jsx(r.Button,{variant:c.id===C?"default":"outline",size:"sm",onClick:()=>j(c.id),children:_(c.scheduledFor)},c.id))}),Object.keys(R).length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No delivery attempts were recorded for this run."}):Object.entries(R).map(([c,g])=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(e.Badge,{variant:"secondary",className:"text-xs",children:c})}),t.jsx("div",{className:"overflow-hidden rounded border",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Recipient"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Status"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Time"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Error"})]})}),t.jsx("tbody",{children:g.map(f=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-2 py-1",children:f.recipient}),t.jsx("td",{className:"px-2 py-1",children:t.jsx(e.Badge,{variant:f.status==="SENT"?"default":"destructive",className:"text-[10px]",children:f.status})}),t.jsx("td",{className:"px-2 py-1",children:_(f.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:f.error||"--"})]},f.id))})]})})]},c))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function Z(){var u,h;const{quotasQuery:s,usageQuery:a}=e.useAlertQuotas(),o=((u=s.data)==null?void 0:u.quotas)||[],l=((h=a.data)==null?void 0:h.usage)||[],i=new Map(l.map(n=>[n.tenantId||"org",n]));return t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Alert Quotas"}),t.jsx(r.Button,{variant:"outline",size:"sm",onClick:()=>{s.refetch(),a.refetch()},children:"Refresh"})]}),s.isLoading||a.isLoading?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading quota usage..."}):null,t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Tenant"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Active Alerts"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Active"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Min Cadence"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Context Sources"})]})}),t.jsx("tbody",{children:o.map(n=>{const d=n.tenantId||"org",x=i.get(d);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:d}),t.jsx("td",{className:"px-3 py-2",children:(x==null?void 0:x.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:n.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[n.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:n.policy.maxContextSources})]},d)})})]})})]})}exports.AlertManagementPage=e.AlertManagementPage;exports.AlertWizardDialog=e.AlertWizardDialog;exports.AlertsApiError=e.AlertsApiError;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.backtestAlert=e.backtestAlert;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createAlert=e.createAlert;exports.createExport=e.createExport;exports.deleteAlert=e.deleteAlert;exports.downloadDocumentPdf=e.downloadDocumentPdf;exports.downloadPdf=e.downloadPdf;exports.formatFileSize=e.formatFileSize;exports.getAlert=e.getAlert;exports.getAlertContextSources=e.getAlertContextSources;exports.getAlertHistory=e.getAlertHistory;exports.getAlertQuotaUsage=e.getAlertQuotaUsage;exports.getAlertRunDeliveries=e.getAlertRunDeliveries;exports.getAlertRunSteps=e.getAlertRunSteps;exports.getAlertRuns=e.getAlertRuns;exports.getAlertState=e.getAlertState;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.triggerAlertNow=e.triggerAlertNow;exports.updateAlert=e.updateAlert;exports.updateAlertContextSources=e.updateAlertContextSources;exports.updateAlertQuota=e.updateAlertQuota;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useAlertActions=e.useAlertActions;exports.useAlertDeliveries=e.useAlertDeliveries;exports.useAlertDetail=e.useAlertDetail;exports.useAlertDraft=e.useAlertDraft;exports.useAlertFilters=e.useAlertFilters;exports.useAlertHistory=e.useAlertHistory;exports.useAlertQuotas=e.useAlertQuotas;exports.useAlertRuns=e.useAlertRuns;exports.useAlertState=e.useAlertState;exports.useAlertStore=e.useAlertStore;exports.useAlertWizard=e.useAlertWizard;exports.useAlerts=e.useAlerts;exports.useAlertsBootstrap=e.useAlertsBootstrap;exports.useAlertsById=e.useAlertsById;exports.useAlertsForCard=e.useAlertsForCard;exports.useCard=e.useCard;exports.useCardAlertMap=e.useCardAlertMap;exports.useCardSummary=e.useCardSummary;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorAside=e.useEditorAside;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useSelectedAlertId=e.useSelectedAlertId;exports.useTextFilterHook=e.useTextFilterHook;exports.CONTROL_CARD_DEFAULT_VALUE=M.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=M.EMPTY_SELECTION;exports.CalendarPreferencesDialog=L.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=L.DashboardSummarySettingsDialog;exports.CALCULATED_FIELD_ENTITY_MARKER=r.CALCULATED_FIELD_ENTITY_MARKER;exports.DATE_FORMAT_VALUES=r.DATE_FORMAT_VALUES;exports.PivotMarkerEnum=r.PivotMarkerEnum;exports.createEmptyKpiConfig=r.createEmptyKpiConfig;exports.createSqlGenConfig=r.createSqlGenConfig;exports.emitDashboardLoad=r.emitDashboardLoad;exports.emitDashboardUnload=r.emitDashboardUnload;exports.fmt=r.fmt;exports.getColumnDataType=r.getColumnDataType;exports.getFilterValueType=r.getFilterValueType;exports.getFormattedTableNameForQuery=r.getFormattedTableNameForQuery;exports.getQualifiedTableName=r.getQualifiedTableName;exports.getSql=r.getSql;exports.invalidateToken=r.invalidateToken;exports.isBooleanDataType=r.isBooleanDataType;exports.isCalculatedDimension=r.isCalculatedDimension;exports.isCalculatedField=r.isCalculatedField;exports.isCalculatedMetric=r.isCalculatedMetric;exports.isColumnInSqlGen=r.isColumnInSqlGen;exports.isDateDataType=r.isDateDataType;exports.isNumberDataType=r.isNumberDataType;exports.isTextDataType=r.isTextDataType;exports.resolveDataType=r.resolveDataType;exports.resolveDatamodelName=r.resolveDatamodelName;exports.useCurrentActiveCard=r.useCurrentActiveCard;exports.useCurrentCardConfig=r.useCurrentCardConfig;exports.useCurrentSheetActiveCards=r.useCurrentSheetActiveCards;exports.useDashboardActions=r.useDashboardActions;exports.useDashboardStore=r.useDashboardStore;exports.useEditorActions=r.useEditorActions;exports.useEditorStore=r.useEditorStore;exports.ResourceManagementPanel=z.ResourceManagementPanel;exports.DEFAULT_CALENDAR_CONTEXT=B.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=B.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.useDebouncedDirtyCheck=q.useDebouncedDirtyCheck;exports.AdvancedModeToggle=y.AdvancedModeToggle;exports.DashboardControlsSettings=y.DashboardControlsSettings;exports.DashboardFilterControlsButton=y.DashboardFilterControlsButton;exports.ExportNotificationItem=y.ExportNotificationItem;exports.ExportNotificationList=y.ExportNotificationList;exports.NotificationBell=y.NotificationBell;exports.UnsavedChangesAlert=y.UnsavedChangesAlert;exports.VisualEditingControls=y.VisualEditingControls;exports.useExportPolling=y.useExportPolling;exports.useExportRecovery=y.useExportRecovery;exports.normalizeDashboardForDirtyCheck=O.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=O.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=J;exports.Combobox=$;exports.ScheduleDashboard=G;exports.TenantQuotaPage=Z;exports.Visual=V;exports.useAlertBacktest=K;exports.useExposePrintState=Y;exports.usePristineSnapshotInitializer=H;