react-semaphor 0.1.252 → 0.1.253

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 (29) hide show
  1. package/dist/chunks/{dashboard-controls-RKNlZLUy.js → dashboard-controls-BgaOqhnw.js} +1 -1
  2. package/dist/chunks/{dashboard-controls-tzai5JMp.js → dashboard-controls-CHH9Ea4j.js} +36 -36
  3. package/dist/chunks/{dashboard-json-B5wllXw0.js → dashboard-json-Blynp1N2.js} +1 -1
  4. package/dist/chunks/{dashboard-json-ihTGgefO.js → dashboard-json-CJ6i6izi.js} +1 -1
  5. package/dist/chunks/{dashboard-summary-settings-dialog-5tiQcv5v.js → dashboard-summary-settings-dialog-BtpW7fJ0.js} +1 -1
  6. package/dist/chunks/{dashboard-summary-settings-dialog-aTE5vsbO.js → dashboard-summary-settings-dialog-CHhYvPUB.js} +1 -1
  7. package/dist/chunks/{edit-dashboard-visual-DWk1Nj1P.js → edit-dashboard-visual-C22E6KJj.js} +2 -2
  8. package/dist/chunks/{edit-dashboard-visual-BIQd7lCz.js → edit-dashboard-visual-CZvBuYhN.js} +1 -1
  9. package/dist/chunks/{editor-action-buttons-CmELP3na.js → editor-action-buttons-1cbHJIqv.js} +1 -1
  10. package/dist/chunks/{editor-action-buttons-B7ESBjzC.js → editor-action-buttons-DNSIXb3y.js} +2 -2
  11. package/dist/chunks/index-9_GiUNMO.js +1109 -0
  12. package/dist/chunks/{index-BDN1Q9RG.js → index-DsMIsFii.js} +32323 -32077
  13. package/dist/chunks/{notification-bell-CYrG1hcX.js → notification-bell-DXQ2fu8Y.js} +36 -36
  14. package/dist/chunks/{notification-bell-TG-yGjyj.js → notification-bell-DxOIm0IK.js} +1 -1
  15. package/dist/chunks/{resource-management-panel-jsX9tgNz.js → resource-management-panel-D427FGhi.js} +1 -1
  16. package/dist/chunks/{resource-management-panel-CnDTYkf7.js → resource-management-panel-DkW4oYpN.js} +26 -26
  17. package/dist/chunks/{use-visual-utils-H6Nd2HfE.js → use-visual-utils-BqG8Hwpl.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-BNXkYg0F.js → use-visual-utils-CW_sw621.js} +1 -1
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +413 -252
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +2 -2
  26. package/dist/types/main.d.ts +249 -48
  27. package/dist/types/types.d.ts +92 -20
  28. package/package.json +1 -1
  29. package/dist/chunks/index-DvjTd3ue.js +0 -1109
@@ -1,8 +1,8 @@
1
1
  import Z, { useState as D, useRef as M, useCallback as U, useEffect as L, useContext as ee } from "react";
2
- import { bK as te, b as O, aw as I, bH as B, bD as q, bE as $, ax as W, bC as ae, e as se, f as re, g as ne, h as oe, i as ie, L as _, cu as le, cA as ce, v as de, B as T, w as j, U as P, J as ue, u as F, K as me, N as Q, cB as he, cC as H, x as R, a9 as pe, c as k, c0 as fe, c1 as ge, a3 as ve, c3 as be, c4 as V, s as xe, c8 as we, b$ as ye, M as Ce, cD as Ne, cE as Ae, cF as De, ch as Ee, ci as Se, cj as Le, cG as Te, ck as Ie, cl as ke, cm as Ue, cn as Fe, co as Ve, am as Me, bJ as Pe, X as Re, cH as ze, cI as Oe, cJ as Be, bF as G, a5 as $e, az as je, P as _e, k as He, cK as Ge, l as Xe } from "./index-BDN1Q9RG.js";
2
+ import { bL as te, b as B, aB as T, bI as O, bE as J, bF as $, aC as W, bD as ae, e as se, f as re, g as ne, h as oe, i as ie, L as _, cu as le, cA as ce, v as de, B as I, w as j, U as P, J as ue, u as F, K as me, N as Q, cB as he, cC as H, x as R, ae as pe, c as k, c0 as fe, c1 as ge, a5 as ve, c3 as be, c4 as V, s as xe, c8 as we, b$ as ye, M as Ce, cD as Ne, cE as Ae, cF as De, ch as Ee, ci as Se, cj as Le, cG as Ie, ck as Te, cl as ke, cm as Ue, cn as Fe, co as Ve, ar as Me, bK as Pe, X as Re, cH as ze, cI as Be, cJ as Oe, bG as G, a7 as $e, aE as je, P as _e, k as He, cK as Ge, l as Xe } from "./index-DsMIsFii.js";
3
3
  import { jsx as t, jsxs as n, Fragment as z } from "react/jsx-runtime";
4
- import { V as Je, E as Ke, a as qe, b as We, L as Qe, c as Ye, d as Ze, C as et } from "./editor-action-buttons-B7ESBjzC.js";
5
- import { a as Y } from "./use-visual-utils-H6Nd2HfE.js";
4
+ import { V as Ke, E as qe, a as Je, b as We, L as Qe, c as Ye, d as Ze, C as et } from "./editor-action-buttons-DNSIXb3y.js";
5
+ import { a as Y } from "./use-visual-utils-BqG8Hwpl.js";
6
6
  import { k as X } from "./date-formatter-vkCj9Ct-.js";
7
7
  /**
8
8
  * @license lucide-react v0.453.0 - ISC
@@ -10,23 +10,23 @@ import { k as X } from "./date-formatter-vkCj9Ct-.js";
10
10
  * This source code is licensed under the ISC license.
11
11
  * See the LICENSE file in the root directory of this source tree.
12
12
  */
13
- const J = te("FileDown", [
13
+ const K = te("FileDown", [
14
14
  ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
15
15
  ["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
16
16
  ["path", { d: "M12 18v-6", key: "17g6i2" }],
17
17
  ["path", { d: "m9 15 3 3 3-3", key: "1npd3o" }]
18
- ]), tt = 1e4, at = 15e3, st = 3e4, rt = 3e4, nt = 12e4, K = 2 * 60 * 60 * 1e3;
18
+ ]), tt = 1e4, at = 15e3, st = 3e4, rt = 3e4, nt = 12e4, q = 2 * 60 * 60 * 1e3;
19
19
  function ot(e) {
20
20
  const a = Date.now() - e.getTime();
21
21
  return a < rt ? tt : a < nt ? at : st;
22
22
  }
23
23
  function bt() {
24
- const { authToken: e, tokenProps: a } = O(), m = I((h) => h.activeExports), [c, d] = D(
24
+ const { authToken: e, tokenProps: a } = B(), m = T((h) => h.activeExports), [c, d] = D(
25
25
  typeof document < "u" ? !document.hidden : !0
26
26
  ), u = M(null), o = M(!1), l = M(void 0), f = a == null ? void 0 : a.apiServiceUrl, i = e == null ? void 0 : e.accessToken, g = U(() => {
27
- const h = I.getState().activeExports;
27
+ const h = T.getState().activeExports;
28
28
  return Array.from(h.values()).filter(
29
- (b) => B(b.status)
29
+ (b) => O(b.status)
30
30
  );
31
31
  }, []);
32
32
  L(() => {
@@ -49,10 +49,10 @@ function bt() {
49
49
  return;
50
50
  }
51
51
  const b = Date.now(), N = h.filter(
52
- (s) => b - s.startedAt.getTime() > K
52
+ (s) => b - s.startedAt.getTime() > q
53
53
  );
54
54
  if (N.length > 0) {
55
- const { updateExport: s } = I.getState().actions;
55
+ const { updateExport: s } = T.getState().actions;
56
56
  for (const r of N)
57
57
  s(r.id, {
58
58
  status: "failed",
@@ -61,7 +61,7 @@ function bt() {
61
61
  });
62
62
  }
63
63
  const p = h.filter(
64
- (s) => b - s.startedAt.getTime() <= K
64
+ (s) => b - s.startedAt.getTime() <= q
65
65
  );
66
66
  if (p.length === 0) {
67
67
  o.current = !1;
@@ -70,7 +70,7 @@ function bt() {
70
70
  const y = await Promise.allSettled(
71
71
  p.map(async (s) => {
72
72
  try {
73
- const r = await q(f, i, s.id);
73
+ const r = await J(f, i, s.id);
74
74
  let v;
75
75
  if (r.status === "completed")
76
76
  try {
@@ -99,7 +99,7 @@ function bt() {
99
99
  ), null;
100
100
  }
101
101
  })
102
- ), { updateExport: A } = I.getState().actions;
102
+ ), { updateExport: A } = T.getState().actions;
103
103
  for (const s of y)
104
104
  s.status === "fulfilled" && s.value && A(s.value.id, s.value);
105
105
  const w = g();
@@ -135,7 +135,7 @@ function bt() {
135
135
  };
136
136
  }
137
137
  function xt() {
138
- const { authToken: e, tokenProps: a } = O(), m = I((l) => l.activeExports), { addExport: c } = W(), d = M(!1), u = a == null ? void 0 : a.apiServiceUrl, o = e == null ? void 0 : e.accessToken;
138
+ const { authToken: e, tokenProps: a } = B(), m = T((l) => l.activeExports), { addExport: c } = W(), d = M(!1), u = a == null ? void 0 : a.apiServiceUrl, o = e == null ? void 0 : e.accessToken;
139
139
  L(() => {
140
140
  if (d.current || !u || !o) return;
141
141
  (async () => {
@@ -184,7 +184,7 @@ function xt() {
184
184
  }, [u, o, c, m]);
185
185
  }
186
186
  function it(e) {
187
- return e.title ? e.title : B(
187
+ return e.title ? e.title : O(
188
188
  e.status
189
189
  ) ? "Export in progress..." : e.status === "completed" ? "Export completed" : e.status === "failed" ? "Export failed" : "Export";
190
190
  }
@@ -236,7 +236,7 @@ function lt({
236
236
  /* @__PURE__ */ n(oe, { className: "flex items-center gap-2", children: [
237
237
  /* @__PURE__ */ t("span", { children: "Save Visual As" }),
238
238
  h.badgeType !== "local" && /* @__PURE__ */ t(
239
- Je,
239
+ Ke,
240
240
  {
241
241
  type: h.badgeType,
242
242
  showLabel: !0,
@@ -277,7 +277,7 @@ function lt({
277
277
  ] }),
278
278
  /* @__PURE__ */ n(de, { children: [
279
279
  /* @__PURE__ */ t(
280
- T,
280
+ I,
281
281
  {
282
282
  variant: "outline",
283
283
  onClick: () => a(!1),
@@ -285,7 +285,7 @@ function lt({
285
285
  children: "Cancel"
286
286
  }
287
287
  ),
288
- /* @__PURE__ */ n(T, { onClick: b, disabled: !x || d, children: [
288
+ /* @__PURE__ */ n(I, { onClick: b, disabled: !x || d, children: [
289
289
  d && /* @__PURE__ */ t(j, { className: "mr-2 h-4 w-4 animate-spin" }),
290
290
  h.actionLabel
291
291
  ] })
@@ -384,14 +384,14 @@ function wt({
384
384
  return /* @__PURE__ */ n(z, { children: [
385
385
  /* @__PURE__ */ n("div", { className: "inline-flex items-center overflow-hidden rounded-md border border-input", children: [
386
386
  !x && /* @__PURE__ */ t(
387
- Ke,
387
+ qe,
388
388
  {
389
389
  className: k(e, "rounded-none border-0"),
390
390
  variant: "default"
391
391
  }
392
392
  ),
393
393
  x && b && /* @__PURE__ */ t(
394
- qe,
394
+ Je,
395
395
  {
396
396
  className: k(e, "rounded-none border-0"),
397
397
  variant: "default"
@@ -405,7 +405,7 @@ function wt({
405
405
  ),
406
406
  /* @__PURE__ */ n(fe, { modal: !1, children: [
407
407
  /* @__PURE__ */ t(ge, { className: "h-8", asChild: !0, children: /* @__PURE__ */ t(
408
- T,
408
+ I,
409
409
  {
410
410
  variant: "default",
411
411
  size: "sm",
@@ -524,8 +524,8 @@ function Ct({
524
524
  }, children: /* @__PURE__ */ n(Se, { className: "max-w-[520px] border-border/70 p-6", children: [
525
525
  /* @__PURE__ */ n(Le, { className: "space-y-3", children: [
526
526
  /* @__PURE__ */ n("div", { className: "flex items-center gap-3", children: [
527
- /* @__PURE__ */ t("div", { className: "flex h-9 w-9 items-center justify-center rounded-full bg-amber-50 ring-1 ring-amber-200/70", children: /* @__PURE__ */ t(Te, { className: "h-[18px] w-[18px] text-amber-600" }) }),
528
- /* @__PURE__ */ t(Ie, { className: "text-lg font-semibold tracking-tight", children: u })
527
+ /* @__PURE__ */ t("div", { className: "flex h-9 w-9 items-center justify-center rounded-full bg-amber-50 ring-1 ring-amber-200/70", children: /* @__PURE__ */ t(Ie, { className: "h-[18px] w-[18px] text-amber-600" }) }),
528
+ /* @__PURE__ */ t(Te, { className: "text-lg font-semibold tracking-tight", children: u })
529
529
  ] }),
530
530
  /* @__PURE__ */ t(ke, { className: "text-sm leading-6 text-muted-foreground", children: o })
531
531
  ] }),
@@ -578,13 +578,13 @@ function dt({
578
578
  }, d = () => {
579
579
  switch (e.status) {
580
580
  case "completed":
581
- return /* @__PURE__ */ t(Be, { className: "mt-0.5 h-5 w-5 shrink-0 text-green-600" });
581
+ return /* @__PURE__ */ t(Oe, { className: "mt-0.5 h-5 w-5 shrink-0 text-green-600" });
582
582
  case "failed":
583
583
  return /* @__PURE__ */ t(et, { className: "mt-0.5 h-5 w-5 shrink-0 text-destructive" });
584
584
  default:
585
585
  return /* @__PURE__ */ t(j, { className: "text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin" });
586
586
  }
587
- }, u = B(e.status), o = (() => {
587
+ }, u = O(e.status), o = (() => {
588
588
  switch (e.status) {
589
589
  case "pending":
590
590
  return "Queued...";
@@ -619,7 +619,7 @@ function dt({
619
619
  ] })
620
620
  ] }),
621
621
  /* @__PURE__ */ t(
622
- T,
622
+ I,
623
623
  {
624
624
  variant: "ghost",
625
625
  size: "icon",
@@ -634,7 +634,7 @@ function dt({
634
634
  e.status === "completed" && /* @__PURE__ */ n("div", { className: "flex items-center justify-between", children: [
635
635
  /* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground", children: X(e.startedAt, { addSuffix: !0 }) }),
636
636
  e.downloadUrl && /* @__PURE__ */ n(
637
- T,
637
+ I,
638
638
  {
639
639
  size: "sm",
640
640
  variant: "outline",
@@ -648,7 +648,7 @@ function dt({
648
648
  )
649
649
  ] }),
650
650
  u && /* @__PURE__ */ n("div", { children: [
651
- /* @__PURE__ */ t(Oe, { value: e.progress, className: "h-1.5" }),
651
+ /* @__PURE__ */ t(Be, { value: e.progress, className: "h-1.5" }),
652
652
  /* @__PURE__ */ n("span", { className: "mt-1 block text-xs text-muted-foreground", children: [
653
653
  e.progress,
654
654
  "% complete"
@@ -659,7 +659,7 @@ function dt({
659
659
  ] });
660
660
  }
661
661
  function ut() {
662
- const { authToken: e, tokenProps: a } = O(), m = I((p) => p.activeExports), { clearCompleted: c, removeExport: d, updateExport: u } = W(), [o, l] = D(!1), [f, i] = D(!1), g = Array.from(m.values()).sort(
662
+ const { authToken: e, tokenProps: a } = B(), m = T((p) => p.activeExports), { clearCompleted: c, removeExport: d, updateExport: u } = W(), [o, l] = D(!1), [f, i] = D(!1), g = Array.from(m.values()).sort(
663
663
  (p, y) => y.startedAt.getTime() - p.startedAt.getTime()
664
664
  ), x = g.some(
665
665
  (p) => p.status === "completed" || p.status === "failed"
@@ -672,7 +672,7 @@ function ut() {
672
672
  await Promise.all(
673
673
  A.map(async (w) => {
674
674
  try {
675
- const s = await q(p, y, w.id);
675
+ const s = await J(p, y, w.id);
676
676
  let r;
677
677
  if (s.status === "completed")
678
678
  try {
@@ -747,18 +747,18 @@ function ut() {
747
747
  [a == null ? void 0 : a.apiServiceUrl, e == null ? void 0 : e.accessToken, d]
748
748
  );
749
749
  return g.length === 0 ? /* @__PURE__ */ n("div", { className: "p-6 text-center", children: [
750
- /* @__PURE__ */ t(J, { className: "mx-auto mb-2 h-8 w-8 text-muted-foreground" }),
750
+ /* @__PURE__ */ t(K, { className: "mx-auto mb-2 h-8 w-8 text-muted-foreground" }),
751
751
  /* @__PURE__ */ t("p", { className: "text-sm text-muted-foreground", children: "No active exports" }),
752
752
  /* @__PURE__ */ t("p", { className: "mt-1 text-xs text-muted-foreground", children: "Large exports will appear here" })
753
753
  ] }) : /* @__PURE__ */ n("div", { className: "flex flex-col", children: [
754
754
  /* @__PURE__ */ n("div", { className: "flex items-center justify-between border-b px-4 py-3", children: [
755
755
  /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
756
- /* @__PURE__ */ t(J, { className: "h-5 w-5 text-muted-foreground" }),
756
+ /* @__PURE__ */ t(K, { className: "h-5 w-5 text-muted-foreground" }),
757
757
  /* @__PURE__ */ t("h4", { className: "font-semibold", children: "Exports" })
758
758
  ] }),
759
759
  /* @__PURE__ */ n("div", { className: "flex items-center gap-1", children: [
760
760
  /* @__PURE__ */ t(
761
- T,
761
+ I,
762
762
  {
763
763
  variant: "ghost",
764
764
  size: "sm",
@@ -775,7 +775,7 @@ function ut() {
775
775
  }
776
776
  ),
777
777
  x && /* @__PURE__ */ t(
778
- T,
778
+ I,
779
779
  {
780
780
  variant: "ghost",
781
781
  size: "sm",
@@ -800,12 +800,12 @@ function ut() {
800
800
  function At({
801
801
  variant: e
802
802
  }) {
803
- const a = I((f) => f.activeExports), m = je(), c = a.size > 0, d = Array.from(a.values()).some(
803
+ const a = T((f) => f.activeExports), m = je(), c = a.size > 0, d = Array.from(a.values()).some(
804
804
  (f) => f.status === "completed" || f.status === "failed"
805
805
  ), o = m > 0 ? m > 9 ? "9+" : String(m) : null;
806
806
  return /* @__PURE__ */ n(_e, { children: [
807
807
  /* @__PURE__ */ t(He, { asChild: !0, children: /* @__PURE__ */ n(
808
- T,
808
+ I,
809
809
  {
810
810
  variant: e ?? "ghost",
811
811
  size: "icon",
@@ -1,4 +1,4 @@
1
- "use strict";const f=require("react"),t=require("./index-DvjTd3ue.js"),e=require("react/jsx-runtime"),A=require("./editor-action-buttons-CmELP3na.js"),U=require("./use-visual-utils-BNXkYg0F.js"),I=require("./date-formatter-CqXdM6JO.js");/**
1
+ "use strict";const f=require("react"),t=require("./index-9_GiUNMO.js"),e=require("react/jsx-runtime"),A=require("./editor-action-buttons-1cbHJIqv.js"),U=require("./use-visual-utils-CW_sw621.js"),I=require("./date-formatter-CqXdM6JO.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-DvjTd3ue.js"),h=require("react"),re=require("./use-visual-utils-BNXkYg0F.js");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-9_GiUNMO.js"),h=require("react"),re=require("./use-visual-utils-CW_sw621.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as r, Fragment as le } from "react/jsx-runtime";
2
- import { bK as Pe, u as re, U as je, K as ce, bZ as Fe, b_ as ze, c as J, B as P, b$ as ie, c0 as Be, c1 as He, c2 as Ke, c3 as _e, c4 as Z, w as oe, c5 as $e, c6 as qe, c7 as Ge, c8 as ge, c9 as ue, ca as We, cb as Ye, cc as xe, cd as De, ce as we, cf as Ze, af as Ne, ab as ve, cg as ye, ch as Ce, ci as Se, cj as Ee, ck as Ve, cl as Le, cm as Ae, cn as Oe, co as Re, cp as Je, cq as he, cr as Qe, a9 as te, b as Xe, cs as Te, ct as ke, e as et, f as tt, g as rt, h as nt, i as ot, L as be, cu as de, v as st, cv as at, cw as it, cx as dt, bR as lt, bS as ct, bT as ut, bV as ht, cy as mt, cz as pt } from "./index-BDN1Q9RG.js";
2
+ import { bL as Pe, u as re, U as je, K as ce, bZ as Fe, b_ as ze, c as J, B as P, b$ as ie, c0 as Be, c1 as He, c2 as Ke, c3 as _e, c4 as Z, w as oe, c5 as $e, c6 as qe, c7 as Ge, c8 as ge, c9 as ue, ca as We, cb as Ye, cc as xe, cd as De, ce as we, cf as Ze, ak as Ne, ag as ve, cg as ye, ch as Ce, ci as Se, cj as Ee, ck as Ve, cl as Le, cm as Ae, cn as Oe, co as Te, cp as Je, cq as he, cr as Qe, ae as te, b as Xe, cs as Re, ct as ke, e as et, f as tt, g as rt, h as nt, i as ot, L as be, cu as de, v as st, cv as at, cw as it, cx as dt, bS as lt, bT as ct, bU as ut, bV as ht, cy as mt, cz as pt } from "./index-DsMIsFii.js";
3
3
  import ft, { useRef as gt, useEffect as ne, useState as x } from "react";
4
- import { a as Ue } from "./use-visual-utils-H6Nd2HfE.js";
4
+ import { a as Ue } from "./use-visual-utils-BqG8Hwpl.js";
5
5
  /**
6
6
  * @license lucide-react v0.453.0 - ISC
7
7
  *
@@ -62,7 +62,7 @@ function wt({
62
62
  formatDate: v
63
63
  }) {
64
64
  var I, U, j, F;
65
- const { selectVisual: m } = ce(), c = Fe(t.id), u = Dt(t.id), A = re((i) => i.isVisualEditing), { isConsoleMode: T } = ze(), b = ft.useRef(null), [S, E] = x(!1), [V, O] = x(!1);
65
+ const { selectVisual: m } = ce(), c = Fe(t.id), u = Dt(t.id), A = re((i) => i.isVisualEditing), { isConsoleMode: R } = ze(), b = ft.useRef(null), [S, E] = x(!1), [V, O] = x(!1);
66
66
  ne(() => {
67
67
  p ? (E(!0), O(!0)) : V && (E(!1), O(!1));
68
68
  }, [p, V]), ne(() => {
@@ -243,7 +243,7 @@ function wt({
243
243
  ] }),
244
244
  /* @__PURE__ */ e(ge, {}),
245
245
  /* @__PURE__ */ r("div", { className: "space-y-1 px-2 py-2 text-xs text-muted-foreground", children: [
246
- (((U = t.ownership.createdBy) == null ? void 0 : U.type) === "tenant" || ((j = t.ownership.createdBy) == null ? void 0 : j.type) === "organization" && T) && /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
246
+ (((U = t.ownership.createdBy) == null ? void 0 : U.type) === "tenant" || ((j = t.ownership.createdBy) == null ? void 0 : j.type) === "organization" && R) && /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
247
247
  /* @__PURE__ */ e(We, { className: "h-3 w-3" }),
248
248
  /* @__PURE__ */ e("span", { children: ((F = t.ownership.createdBy) == null ? void 0 : F.name) || "Unknown" })
249
249
  ] }),
@@ -270,7 +270,7 @@ function Nt({ searchQuery: t }) {
270
270
  null
271
271
  ), [h, D] = x(!1), [s, w] = x(null), [v, m] = x(null), [c, u] = x(
272
272
  null
273
- ), { handleEditLibraryVisual: A, handleAddLibraryVisual: T } = Ue(), {
273
+ ), { handleEditLibraryVisual: A, handleAddLibraryVisual: R } = Ue(), {
274
274
  resources: b,
275
275
  isLoading: S,
276
276
  isError: E,
@@ -282,8 +282,8 @@ function Nt({ searchQuery: t }) {
282
282
  D(!1), w(null);
283
283
  }), I = b.filter(
284
284
  (o) => {
285
- var R, l;
286
- return ((R = o == null ? void 0 : o.title) == null ? void 0 : R.toLowerCase().includes(t.toLowerCase())) || ((l = o == null ? void 0 : o.description) == null ? void 0 : l.toLowerCase().includes(t.toLowerCase()));
285
+ var T, l;
286
+ return ((T = o == null ? void 0 : o.title) == null ? void 0 : T.toLowerCase().includes(t.toLowerCase())) || ((l = o == null ? void 0 : o.description) == null ? void 0 : l.toLowerCase().includes(t.toLowerCase()));
287
287
  }
288
288
  ), U = (o) => new Date(o).toLocaleDateString("en-US", {
289
289
  month: "short",
@@ -297,10 +297,10 @@ function Nt({ searchQuery: t }) {
297
297
  startUpdating: i,
298
298
  stopUpdating: q,
299
299
  isUpdating: B
300
- } = De(), L = (o, R, l) => {
300
+ } = De(), L = (o, T, l) => {
301
301
  var ee;
302
302
  const z = Object.fromEntries(
303
- Object.entries(R).filter(([, M]) => M !== void 0)
303
+ Object.entries(T).filter(([, M]) => M !== void 0)
304
304
  );
305
305
  if (Object.keys(z).length === 0) {
306
306
  (ee = l == null ? void 0 : l.onSuccess) == null || ee.call(l);
@@ -330,7 +330,7 @@ function Nt({ searchQuery: t }) {
330
330
  }, H = (o) => {
331
331
  A(o);
332
332
  }, W = (o) => {
333
- T(o);
333
+ R(o);
334
334
  }, Y = (o) => {
335
335
  a(o), p(!0);
336
336
  }, Q = (o) => {
@@ -339,12 +339,12 @@ function Nt({ searchQuery: t }) {
339
339
  u(null);
340
340
  }, k = ({
341
341
  title: o,
342
- description: R
342
+ description: T
343
343
  }) => {
344
344
  if (!c)
345
345
  return;
346
346
  const l = {};
347
- o !== c.title && (l.title = o), (c.description || "") !== R && (l.description = R), L(c.id, l, {
347
+ o !== c.title && (l.title = o), (c.description || "") !== T && (l.description = T), L(c.id, l, {
348
348
  onSuccess: () => {
349
349
  u(null);
350
350
  }
@@ -424,7 +424,7 @@ function Nt({ searchQuery: t }) {
424
424
  /* @__PURE__ */ r(Ae, { children: [
425
425
  /* @__PURE__ */ e(Oe, { disabled: C, children: "Cancel" }),
426
426
  /* @__PURE__ */ r(
427
- Re,
427
+ Te,
428
428
  {
429
429
  onClick: (o) => {
430
430
  o.preventDefault(), o.stopPropagation(), F();
@@ -456,7 +456,7 @@ function vt({
456
456
  onDashboardItemClick: v
457
457
  }) {
458
458
  var V, O;
459
- const { selectDashboard: m } = ce(), c = Je(t.id), { userContext: u, isLoading: A } = he(), T = ((V = u == null ? void 0 : u.permissions) == null ? void 0 : V.canEdit) ?? !1, b = A || !T, S = () => {
459
+ const { selectDashboard: m } = ce(), c = Je(t.id), { userContext: u, isLoading: A } = he(), R = ((V = u == null ? void 0 : u.permissions) == null ? void 0 : V.canEdit) ?? !1, b = A || !R, S = () => {
460
460
  m(t), d(t.id), v == null || v(t.id);
461
461
  }, E = (y) => {
462
462
  y.currentTarget === y.target && (y.key === "Enter" || y.key === " ") && (y.preventDefault(), S());
@@ -534,7 +534,7 @@ function Ct(t) {
534
534
  var me;
535
535
  const { searchQuery: f, onLoadDashboard: p, onEditDashboard: d, onDashboardItemClick: a } = t, [h, D] = x(!1), [s, w] = x(
536
536
  null
537
- ), [v, m] = x(!1), [c, u] = x(null), [A, T] = x(null), [b, S] = x(null), E = te(
537
+ ), [v, m] = x(!1), [c, u] = x(null), [A, R] = x(null), [b, S] = x(null), E = te(
538
538
  (n) => n.lastSelectedDashboard
539
539
  ), V = te(
540
540
  (n) => n.selectedDashboard
@@ -550,7 +550,7 @@ function Ct(t) {
550
550
  deleteResource: q,
551
551
  duplicateResource: B,
552
552
  isDeleting: L
553
- } = Te(() => {
553
+ } = Re(() => {
554
554
  m(!1);
555
555
  const n = c == null ? void 0 : c.id;
556
556
  u(null), (V == null ? void 0 : V.id) === n && (!(C != null && C.dashboard_id) && !I ? y() : E && E.id !== n && O(E));
@@ -570,11 +570,11 @@ function Ct(t) {
570
570
  }, k = () => {
571
571
  c && q(c.id);
572
572
  }, o = (n) => {
573
- T(n), B(n, {
574
- onSettled: () => T(null)
573
+ R(n), B(n, {
574
+ onSettled: () => R(null)
575
575
  });
576
576
  }, {
577
- startUpdating: R,
577
+ startUpdating: T,
578
578
  stopUpdating: l,
579
579
  isUpdating: z
580
580
  } = De(), N = (n, _, g) => {
@@ -587,7 +587,7 @@ function Ct(t) {
587
587
  return;
588
588
  }
589
589
  const pe = Object.keys(se), ae = pe.length === 1 ? pe[0] : void 0;
590
- R(n, ae), i(
590
+ T(n, ae), i(
591
591
  {
592
592
  resourceId: n,
593
593
  data: se
@@ -672,7 +672,7 @@ function Ct(t) {
672
672
  /* @__PURE__ */ r(Ae, { children: [
673
673
  /* @__PURE__ */ e(Oe, { disabled: L, children: "Cancel" }),
674
674
  /* @__PURE__ */ r(
675
- Re,
675
+ Te,
676
676
  {
677
677
  onClick: (n) => {
678
678
  n.preventDefault(), n.stopPropagation(), k();
@@ -788,13 +788,13 @@ function Ot({
788
788
  var l, z;
789
789
  const h = re(
790
790
  (N) => N.isDashboardEditing
791
- ), [D, s] = x(!1), [w, v] = x(""), [m, c] = x(!1), { currentUser: u, userContext: A } = he(), T = ((l = A == null ? void 0 : A.permissions) == null ? void 0 : l.canCreateDashboard) ?? !1, { onCreateSuccess: b } = at({
791
+ ), [D, s] = x(!1), [w, v] = x(""), [m, c] = x(!1), { currentUser: u, userContext: A } = he(), R = ((l = A == null ? void 0 : A.permissions) == null ? void 0 : l.canCreateDashboard) ?? !1, { onCreateSuccess: b } = at({
792
792
  onDashboardSelect: d
793
793
  }), { selectVisual: S } = ce(), { handleEditLibraryVisual: E } = Ue(), {
794
794
  createResource: V,
795
795
  isCreating: O,
796
796
  refetch: y
797
- } = Te(), { createResource: C, isCreating: I } = xe(
797
+ } = Re(), { createResource: C, isCreating: I } = xe(
798
798
  void 0,
799
799
  // onDeleteSuccess (not needed here)
800
800
  (N) => {
@@ -812,7 +812,7 @@ function Ot({
812
812
  ), k = (N) => {
813
813
  }, o = (N) => {
814
814
  console.log("Editing dashboard:", N);
815
- }, R = (N) => {
815
+ }, T = (N) => {
816
816
  V(N, {
817
817
  onSuccess: (K) => {
818
818
  s(!1), b(K, y);
@@ -835,7 +835,7 @@ function Ot({
835
835
  children: /* @__PURE__ */ e(it, { className: "h-3.5 w-3.5" })
836
836
  }
837
837
  ),
838
- (h || T) && /* @__PURE__ */ r(
838
+ (h || R) && /* @__PURE__ */ r(
839
839
  P,
840
840
  {
841
841
  size: "sm",
@@ -909,7 +909,7 @@ function Ot({
909
909
  {
910
910
  open: D,
911
911
  onOpenChange: s,
912
- onSubmit: R,
912
+ onSubmit: T,
913
913
  isCreating: O
914
914
  }
915
915
  )
@@ -1,4 +1,4 @@
1
- import { G as K, b as Y, H as X, J as Z, K as q, M as _, N as ee, u as U, O as te, Q as re, x as M, T as se, U as f } from "./index-BDN1Q9RG.js";
1
+ import { G as K, b as Y, H as X, J as Z, K as q, M as _, N as ee, u as U, O as te, Q as re, x as M, T as se, U as f } from "./index-DsMIsFii.js";
2
2
  import { useState as H, useEffect as oe, useCallback as D } from "react";
3
3
  function ae(e) {
4
4
  const a = e.toUpperCase().indexOf("WHERE"), t = e.toUpperCase().indexOf("GROUP BY"), r = e.toUpperCase().indexOf("LIMIT"), s = e.toUpperCase().indexOf("ORDER BY");
@@ -1 +1 @@
1
- "use strict";const o=require("./index-DvjTd3ue.js"),b=require("react");function z(e){const n=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let c=e.length;if(s!==-1&&(c=s),r!==-1&&r<c&&(c=r),n!==-1){const d=e.substring(0,n),a=e.substring(n);return`${d} {{ filters | where }} AND ${a.substring(6)}`}else if(t!==-1){const d=e.substring(0,t),a=e.substring(t);return`${d} {{ filters | where }} ${a}`}else{const d=e.substring(0,c),a=e.substring(c);return console.log("beforeClause",d),console.log("afterClause",a),a?`${d} {{ filters | where }} ${a}`:`${d.replace(/;$/,"")} {{ filters | where }}`}}function j(e){const[n,t]=b.useState(null),[r,s]=b.useState(null),c=o.useEnsureReactGlobals();return b.useEffect(()=>{if(!e||e.trim()===""){t(null),s(null);return}if(!c)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 l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),s(null)}catch(a){const l=a instanceof Error?a.message:"Unknown error";console.error("Failed to load remote chart store:",l),s(l),t(null)}})()},[e,c]),n}function G(e,n){if(e.length===0)return"";const t=e.find(r=>{var s,c;return((s=r.customCardPreferences)==null?void 0:s.visualType)==="multiple"||!!((c=r.customCardPreferences)!=null&&c.dataInputCardIds)});if(t)return t.id;if(n){const r=e.find(s=>s.id===n);if(r){const s=r.tabTitle;if(s=="All__Header")return e[0].id;if(s&&s.endsWith("__Header")){const d=s.split("__")[0],a=e.find(l=>l.tabTitle===d);return a?a.id:e[0].id}return n}}return e[0].id}const Y=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:n,...t}=e;return t};async function L(e,n,t,r){if(!n||!t)throw new Error("Missing auth token or visual ID");const s=["resource-by-id","visual",t],c=r.getQueryData(s);if(c)return console.log("Using cached visual data for:",t),{data:c,fromCache:!0};console.log("Fetching visual data from network for:",t);const d=o.ue.loading("Loading visual...",{position:"top-center"});try{const a=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${n}`}});if(!a.ok)throw new Error("Failed to load visual");const l=await a.json();return r.setQueryData(s,l),o.ue.dismiss(d),{data:l,fromCache:!1}}catch(a){throw o.ue.dismiss(d),a}}function _(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function J(e,n){var c,d;const t=(e==null?void 0:e.frameObject)??((c=e==null?void 0:e.visual)==null?void 0:c.frameObject);if(!t)return!1;const r=_(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const s=(d=r.cards)==null?void 0:d.find(a=>a.id===r.activeCardId);return s?(o.setupEditorWithCard({...n,frame:r,card:s,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function K(){var g;const{setCardSql:e}=o.useEditorActions(),n=o.useEditorStore(i=>i.frame),t=o.useEditorStore(i=>i.card),r=o.useEditorStore(i=>i.isDevMode),s=j(((g=t.customCardPreferences)==null?void 0:g.url)||""),c=o.useEditorStore(i=>i.selectedSchemaName),d=o.useEditorStore(i=>i.selectedDatamodelId),a=o.useEditorStore(i=>i.selectedDatabaseName),l=o.useEditorStore(i=>i.selectedTableName),h=o.useEditorStore(i=>i.selectedConnectionId),m=o.useEditorStore(i=>i.isShowingVisual),p=t.sql;return{getUpdatedFrame:b.useCallback(()=>{var w;let i=p;p&&!p.includes("{{")&&(i=z(p),e(i));const C=(w=s==null?void 0:s.getState())==null?void 0:w.settings,v={...t,dataSource:t.dataSource||{mode:"directSource"},lastSelectedSchema:c,lastSelectedDatamodelId:d,lastSelectedDatabase:a,lastSelectedTable:l,connectionId:h,sql:r?i:void 0,python:r?t.python:void 0,config:r?void 0:Y(t.config),customCfg:m?t.customCfg:null,preferences:t.preferences,...C&&{customCardPreferences:{...t.customCardPreferences,settings:C}}},E=n.cards.map(I=>I.id===t.id?v:I);return{...n,cards:E,activeCardId:G(E,n.activeCardId)}},[t,n,r,m,c,d,a,l,h,e,s,p])}}function X(){const{authToken:e,tokenProps:n}=o.useSemaphorContext(),t=o.useQueryClient(),r=o.useSelectedVisual(),{selectVisual:s}=o.useManagementActions(),{setFrame:c,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:v,setFilterValues:E,setInlineFilterValuesMap:w,setApplyFilters:I}=o.useEditorActions(),{setIsDashboardEditing:V,setIsVisualEditing:$,setSelectedFrameId:M,clearSelectedFrameId:A,addFrame:R,setIsDashboardPanelOpen:N}=o.useDashboardActions(),y=o.useDashboardStore(u=>u.selectedSheetId),O=o.useDashboardStore(u=>u.selectedFrameId),T=o.useDashboardStore(u=>u.dashboard),x=o.useDashboardStore(u=>u.filterValues),B=o.useDashboardStore(u=>u.inlineFilterValuesMap),F=o.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),H=b.useCallback(async u=>{try{s(u),A();const{data:S,fromCache:f}=await L(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!J(S,{setFrame:c,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:v,setFilterValues:E,setInlineFilterValuesMap:w,setApplyFilters:I,setIsDashboardEditing:V,setIsVisualEditing:$,dashboard:T,selectedSheetId:y,selectedFrameId:O,filterValues:x,inlineFilterValuesMap:B}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(S){return console.error("Error editing visual:",S),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,c,d,V,$,a,l,h,m,p,D,g,i,C,v,E,w,I,A,T,y,O,x,B]),Q=b.useCallback(async u=>{var S;try{if(s(u),!y)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:P}=await L(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),W=(f==null?void 0:f.frameObject)??((S=f==null?void 0:f.visual)==null?void 0:S.frameObject);if(!W)return{success:!1,error:"Visual has no frame data"};const U=_(W);if(!(U!=null&&U.cards)||U.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const k={...o.cloneLinkedFrameWithSourceMapping(U),visualId:u.id};return R(y,k,"end"),V(!0),M(k.id),N(!1),{success:!0,fromCache:P}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,y,R,V,M,N]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:H,handleAddLibraryVisual:Q,getUpdatedFrame:K().getUpdatedFrame,refetch:F.refetch}}exports.useRemoteChartStore=j;exports.useVisualUtils=X;
1
+ "use strict";const o=require("./index-9_GiUNMO.js"),b=require("react");function z(e){const n=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let c=e.length;if(s!==-1&&(c=s),r!==-1&&r<c&&(c=r),n!==-1){const d=e.substring(0,n),a=e.substring(n);return`${d} {{ filters | where }} AND ${a.substring(6)}`}else if(t!==-1){const d=e.substring(0,t),a=e.substring(t);return`${d} {{ filters | where }} ${a}`}else{const d=e.substring(0,c),a=e.substring(c);return console.log("beforeClause",d),console.log("afterClause",a),a?`${d} {{ filters | where }} ${a}`:`${d.replace(/;$/,"")} {{ filters | where }}`}}function j(e){const[n,t]=b.useState(null),[r,s]=b.useState(null),c=o.useEnsureReactGlobals();return b.useEffect(()=>{if(!e||e.trim()===""){t(null),s(null);return}if(!c)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 l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),s(null)}catch(a){const l=a instanceof Error?a.message:"Unknown error";console.error("Failed to load remote chart store:",l),s(l),t(null)}})()},[e,c]),n}function G(e,n){if(e.length===0)return"";const t=e.find(r=>{var s,c;return((s=r.customCardPreferences)==null?void 0:s.visualType)==="multiple"||!!((c=r.customCardPreferences)!=null&&c.dataInputCardIds)});if(t)return t.id;if(n){const r=e.find(s=>s.id===n);if(r){const s=r.tabTitle;if(s=="All__Header")return e[0].id;if(s&&s.endsWith("__Header")){const d=s.split("__")[0],a=e.find(l=>l.tabTitle===d);return a?a.id:e[0].id}return n}}return e[0].id}const Y=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:n,...t}=e;return t};async function L(e,n,t,r){if(!n||!t)throw new Error("Missing auth token or visual ID");const s=["resource-by-id","visual",t],c=r.getQueryData(s);if(c)return console.log("Using cached visual data for:",t),{data:c,fromCache:!0};console.log("Fetching visual data from network for:",t);const d=o.ue.loading("Loading visual...",{position:"top-center"});try{const a=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${n}`}});if(!a.ok)throw new Error("Failed to load visual");const l=await a.json();return r.setQueryData(s,l),o.ue.dismiss(d),{data:l,fromCache:!1}}catch(a){throw o.ue.dismiss(d),a}}function _(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function J(e,n){var c,d;const t=(e==null?void 0:e.frameObject)??((c=e==null?void 0:e.visual)==null?void 0:c.frameObject);if(!t)return!1;const r=_(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const s=(d=r.cards)==null?void 0:d.find(a=>a.id===r.activeCardId);return s?(o.setupEditorWithCard({...n,frame:r,card:s,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function K(){var g;const{setCardSql:e}=o.useEditorActions(),n=o.useEditorStore(i=>i.frame),t=o.useEditorStore(i=>i.card),r=o.useEditorStore(i=>i.isDevMode),s=j(((g=t.customCardPreferences)==null?void 0:g.url)||""),c=o.useEditorStore(i=>i.selectedSchemaName),d=o.useEditorStore(i=>i.selectedDatamodelId),a=o.useEditorStore(i=>i.selectedDatabaseName),l=o.useEditorStore(i=>i.selectedTableName),h=o.useEditorStore(i=>i.selectedConnectionId),m=o.useEditorStore(i=>i.isShowingVisual),p=t.sql;return{getUpdatedFrame:b.useCallback(()=>{var w;let i=p;p&&!p.includes("{{")&&(i=z(p),e(i));const C=(w=s==null?void 0:s.getState())==null?void 0:w.settings,v={...t,dataSource:t.dataSource||{mode:"directSource"},lastSelectedSchema:c,lastSelectedDatamodelId:d,lastSelectedDatabase:a,lastSelectedTable:l,connectionId:h,sql:r?i:void 0,python:r?t.python:void 0,config:r?void 0:Y(t.config),customCfg:m?t.customCfg:null,preferences:t.preferences,...C&&{customCardPreferences:{...t.customCardPreferences,settings:C}}},E=n.cards.map(I=>I.id===t.id?v:I);return{...n,cards:E,activeCardId:G(E,n.activeCardId)}},[t,n,r,m,c,d,a,l,h,e,s,p])}}function X(){const{authToken:e,tokenProps:n}=o.useSemaphorContext(),t=o.useQueryClient(),r=o.useSelectedVisual(),{selectVisual:s}=o.useManagementActions(),{setFrame:c,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:v,setFilterValues:E,setInlineFilterValuesMap:w,setApplyFilters:I}=o.useEditorActions(),{setIsDashboardEditing:V,setIsVisualEditing:$,setSelectedFrameId:M,clearSelectedFrameId:A,addFrame:R,setIsDashboardPanelOpen:N}=o.useDashboardActions(),y=o.useDashboardStore(u=>u.selectedSheetId),O=o.useDashboardStore(u=>u.selectedFrameId),T=o.useDashboardStore(u=>u.dashboard),x=o.useDashboardStore(u=>u.filterValues),B=o.useDashboardStore(u=>u.inlineFilterValuesMap),F=o.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),H=b.useCallback(async u=>{try{s(u),A();const{data:S,fromCache:f}=await L(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!J(S,{setFrame:c,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:v,setFilterValues:E,setInlineFilterValuesMap:w,setApplyFilters:I,setIsDashboardEditing:V,setIsVisualEditing:$,dashboard:T,selectedSheetId:y,selectedFrameId:O,filterValues:x,inlineFilterValuesMap:B}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(S){return console.error("Error editing visual:",S),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,c,d,V,$,a,l,h,m,p,D,g,i,C,v,E,w,I,A,T,y,O,x,B]),Q=b.useCallback(async u=>{var S;try{if(s(u),!y)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:P}=await L(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),W=(f==null?void 0:f.frameObject)??((S=f==null?void 0:f.visual)==null?void 0:S.frameObject);if(!W)return{success:!1,error:"Visual has no frame data"};const U=_(W);if(!(U!=null&&U.cards)||U.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const k={...o.cloneLinkedFrameWithSourceMapping(U),visualId:u.id};return R(y,k,"end"),V(!0),M(k.id),N(!1),{success:!0,fromCache:P}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,y,R,V,M,N]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:H,handleAddLibraryVisual:Q,getUpdatedFrame:K().getUpdatedFrame,refetch:F.refetch}}exports.useRemoteChartStore=j;exports.useVisualUtils=X;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-DvjTd3ue.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-9_GiUNMO.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as a } from "../chunks/index-BDN1Q9RG.js";
1
+ import { D as a } from "../chunks/index-DsMIsFii.js";
2
2
  import { EMPTY_SELECTION as e } from "../types/index.js";
3
3
  export {
4
4
  a as Dashboard,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-DvjTd3ue.js"),D=require("./types/index.cjs"),E=require("./chunks/dashboard-summary-settings-dialog-5tiQcv5v.js"),t=require("react/jsx-runtime"),C=require("react"),v=require("./chunks/resource-management-panel-jsX9tgNz.js"),P=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");const p=require("./chunks/notification-bell-TG-yGjyj.js"),S=require("./chunks/normalize-dashboard-for-dirty-check-B7NQDI1H.js");function _(r){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const n in r)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(a,n,i.get?i:{enumerable:!0,get:()=>r[n]})}}return a.default=r,Object.freeze(a)}const A=_(C);function M(r){const{displayPreferences:a,...n}=r,i={...n,id:r.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:i,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:r.cardId}),t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:a,children:t.jsx(e.Container,{type:"visual",...i,children:t.jsx(I,{cardId:r.cardId})})})})]})})}function I({cardId:r}){const a=e.useDashboardStore(o=>{var u;return(u=o.dashboard)==null?void 0:u.sheets}),{card:n,frame:i}=C.useMemo(()=>{const o=a==null?void 0:a.flatMap(s=>s.frames),u=o==null?void 0:o.flatMap(s=>s==null?void 0:s.cards),d=u==null?void 0:u.find(s=>(s==null?void 0:s.id)===r),l=o==null?void 0:o.find(s=>{var m;return(m=s==null?void 0:s.cards)==null?void 0:m.find(h=>(h==null?void 0:h.id)===r)});return{card:d,frame:l}},[a,r]);return!n||!i?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${r}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:o,resetErrorBoundary:u})=>t.jsx(e.FallbackVisual,{error:o,resetErrorBoundary:u,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:i})})})}function F({name:r,items:a,value:n,onChange:i,isLoading:o,isError:u,refetch:d,className:l,icon:s,showNone:m=!1}){const h=A.useRef(null),[f,y]=A.useState(!1),[b,N]=A.useState("100%"),g=m?[...a||[],{id:"none",name:"None"}]:a;A.useLayoutEffect(()=>{h.current&&N(h.current.offsetWidth)},[]);function T(){var c;return o?"Loading...":u?"Error":n?(c=a==null?void 0:a.find(x=>x.id===n))==null?void 0:c.name:`Select ${r}`}function j(c,x){i(x),y(!1)}return t.jsxs(e.Popover,{open:f,onOpenChange:y,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:h,variant:"outline",role:"combobox","aria-expanded":f,className:e.cn("flex h-9 w-full justify-between",l),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[s&&t.jsx("div",{className:"mr-2",children:s}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:T()})]}),t.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:b},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:d,children:t.jsx(e.RefreshCw,{className:e.cn("size-3.5 opacity-50",o&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",r==null?void 0:r.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:g==null?void 0:g.map(c=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:c.name,onSelect:x=>j(x,c.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",n===c.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:c.name,children:c.name})]})},c.id))})]})]})})]})}function R({triggerButtonClassName:r,variant:a="ghost"}){const[n,i]=C.useState(!1),o=e.useDashboardStore(d=>{var l;return(l=d.dashboard)==null?void 0:l.id}),u=e.useDashboardStore(d=>{var l;return(l=d.dashboard)==null?void 0:l.title});return o?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",r),buttonProps:{variant:a},onClick:()=>i(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:n,onOpenChange:i,dashboardId:o,dashboardName:u})]}):null}function w(r,a){C.useEffect(()=>(r&&a&&(window.__SEMAPHOR_PRINT_STATE__={...a}),()=>{r&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[r,a])}function k(){var u,d;const{quotasQuery:r,usageQuery:a}=e.useAlertQuotas(),n=((u=r.data)==null?void 0:u.quotas)||[],i=((d=a.data)==null?void 0:d.usage)||[],o=new Map(i.map(l=>[l.tenantId||"org",l]));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(e.Button,{variant:"outline",size:"sm",onClick:()=>{r.refetch(),a.refetch()},children:"Refresh"})]}),r.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:n.map(l=>{const s=l.tenantId||"org",m=o.get(s);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:s}),t.jsx("td",{className:"px-3 py-2",children:(m==null?void 0:m.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:l.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[l.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:l.policy.maxContextSources})]},s)})})]})})]})}exports.AlertCreationDialog=e.AlertCreationDialog;exports.AlertManagementPage=e.AlertManagementPage;exports.AlertsApiError=e.AlertsApiError;exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;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.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.deleteAlert=e.deleteAlert;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;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.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.interpretAlertContext=e.interpretAlertContext;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;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.useAlertBacktest=e.useAlertBacktest;exports.useAlertContextBuilder=e.useAlertContextBuilder;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.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.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;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.DEFAULT_CALENDAR_CONTEXT=D.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=D.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=D.EMPTY_SELECTION;exports.CalendarPreferencesDialog=E.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=E.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=v.ResourceManagementPanel;exports.useDebouncedDirtyCheck=P.useDebouncedDirtyCheck;exports.AdvancedModeToggle=p.AdvancedModeToggle;exports.ExportNotificationItem=p.ExportNotificationItem;exports.ExportNotificationList=p.ExportNotificationList;exports.NotificationBell=p.NotificationBell;exports.UnsavedChangesAlert=p.UnsavedChangesAlert;exports.VisualEditingControls=p.VisualEditingControls;exports.useExportPolling=p.useExportPolling;exports.useExportRecovery=p.useExportRecovery;exports.usePristineSnapshotInitializer=p.usePristineSnapshotInitializer;exports.normalizeDashboardForDirtyCheck=S.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=S.serializeDashboardForDirtyCheck;exports.Combobox=F;exports.ScheduleDashboard=R;exports.TenantQuotaPage=k;exports.Visual=M;exports.useExposePrintState=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-9_GiUNMO.js"),w=require("./types/index.cjs"),F=require("./chunks/dashboard-summary-settings-dialog-BtpW7fJ0.js"),t=require("react/jsx-runtime"),x=require("react"),z=require("./chunks/resource-management-panel-D427FGhi.js"),O=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");const C=require("./chunks/notification-bell-DxOIm0IK.js"),L=require("./chunks/normalize-dashboard-for-dirty-check-B7NQDI1H.js");function Q(s){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>s[n]})}}return r.default=s,Object.freeze(r)}const P=Q(x);function U(s){const{authToken:r,tokenProps:n}=e.useSemaphorContext();return e.useMutation({mutationFn:async o=>e.backtestAlert(n.apiServiceUrl,r.accessToken,s,o)})}function q(s){const{displayPreferences:r,...n}=s,o={...n,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:o,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:s.cardId}),t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:r,children:t.jsx(e.Container,{type:"visual",...o,children:t.jsx(W,{cardId:s.cardId})})})})]})})}function W({cardId:s}){const r=e.useDashboardStore(l=>{var c;return(c=l.dashboard)==null?void 0:c.sheets}),{card:n,frame:o}=x.useMemo(()=>{const l=r==null?void 0:r.flatMap(i=>i.frames),c=l==null?void 0:l.flatMap(i=>i==null?void 0:i.cards),u=c==null?void 0:c.find(i=>(i==null?void 0:i.id)===s),a=l==null?void 0:l.find(i=>{var m;return(m=i==null?void 0:i.cards)==null?void 0:m.find(f=>(f==null?void 0:f.id)===s)});return{card:u,frame:a}},[r,s]);return!n||!o?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:l,resetErrorBoundary:c})=>t.jsx(e.FallbackVisual,{error:l,resetErrorBoundary:c,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:o})})})}function V({name:s,items:r,value:n,onChange:o,isLoading:l,isError:c,refetch:u,className:a,icon:i,showNone:m=!1}){const f=P.useRef(null),[b,A]=P.useState(!1),[j,D]=P.useState("100%"),y=m?[...r||[],{id:"none",name:"None"}]:r;P.useLayoutEffect(()=>{f.current&&D(f.current.offsetWidth)},[]);function R(){var h;return l?"Loading...":c?"Error":n?(h=r==null?void 0:r.find(S=>S.id===n))==null?void 0:h.name:`Select ${s}`}function T(h,S){o(S),A(!1)}return t.jsxs(e.Popover,{open:b,onOpenChange:A,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":b,className:e.cn("flex h-9 w-full justify-between",a),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.jsx("div",{className:"mr-2",children:i}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:R()})]}),t.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(e.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:u,children:t.jsx(e.RefreshCw,{className:e.cn("size-3.5 opacity-50",l&&"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:y==null?void 0:y.map(h=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:h.name,onSelect:S=>T(S,h.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",n===h.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:h.name,children:h.name})]})},h.id))})]})]})})]})}function H({triggerButtonClassName:s,variant:r="ghost"}){const[n,o]=x.useState(!1),l=e.useDashboardStore(u=>{var a;return(a=u.dashboard)==null?void 0:a.id}),c=e.useDashboardStore(u=>{var a;return(a=u.dashboard)==null?void 0:a.title});return l?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",s),buttonProps:{variant:r},onClick:()=>o(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:n,onOpenChange:o,dashboardId:l,dashboardName:c})]}):null}function $(s,r){x.useEffect(()=>(s&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,r])}function I(s){if(!s)return"--";const r=new Date(s);return Number.isNaN(r.getTime())?"--":r.toLocaleString()}function G(s){var r;return((r=s.alertState)==null?void 0:r.currentState)==="FIRING"?"Signal surfaced":s.status==="ACTIVE"?"Watching":s.status==="PAUSED"?"Paused":s.status}function K({alertId:s,onBack:r}){var h,S,k,M;const{authToken:n,tokenProps:o}=e.useSemaphorContext(),{data:l,isLoading:c,refetch:u}=e.useAlertDetail(s),a=(l==null?void 0:l.alert)??null,[i,m]=x.useState([]),[f,b]=x.useState([]),[A,j]=x.useState(null),D=x.useCallback(async()=>{var g;const d=o==null?void 0:o.apiServiceUrl,p=n==null?void 0:n.accessToken;if(!d||!p||!s)return null;try{const N=await fetch(`${d}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${p}`}});if(N.ok){const E=await N.json(),v=Array.isArray(E.runs)?E.runs:[],_=A&&v.some(B=>B.id===A)?A:((g=v[0])==null?void 0:g.id)??null;return b(v),j(_),_}b([]),j(null)}catch{return b([]),j(null),null}return null},[s,n,A,o]),y=x.useCallback(async d=>{const p=o==null?void 0:o.apiServiceUrl,g=n==null?void 0:n.accessToken,N=d??A;if(!p||!g||!s||!N){m([]);return}try{const E=await fetch(`${p}/v1/alerts/${s}/runs/${N}/deliveries`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const v=await E.json();m(Array.isArray(v.attempts)?v.attempts:[])}else m([])}catch{m([])}},[s,n,A,o]),R=x.useCallback(async()=>{await u();const d=await D();await y(d)},[y,D,u]);x.useEffect(()=>{D().catch(()=>{})},[D]),x.useEffect(()=>{y().catch(()=>{})},[y]);const T=x.useMemo(()=>{const d={};for(const p of i)d[p.channel]||(d[p.channel]=[]),d[p.channel].push(p);return d},[i]);return c?t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading signal detail..."}):a?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:[r&&t.jsx(e.Button,{variant:"outline",size:"sm",onClick:r,children:"Back"}),t.jsx("h2",{className:"text-lg font-semibold",children:a.name}),t.jsx(e.Badge,{variant:a.status==="ACTIVE"?"default":"secondary",children:G(a)}),((h=a.alertState)==null?void 0:h.currentState)&&t.jsx(e.Badge,{variant:a.alertState.currentState==="FIRING"?"destructive":"outline",children:a.alertState.currentState==="FIRING"?"Signal surfaced":"Stable"})]}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>void R(),children:"Refresh"})]}),a.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:a.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(a.jobConfig.operator,a.jobConfig.threshold)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Severity:"})," ",a.jobConfig.severity]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Evaluated:"})," ",I((S=a.alertState)==null?void 0:S.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",I((k=a.alertState)==null?void 0:k.lastTriggeredAt)]})]})]}),((M=a.deliveryConfig)==null?void 0:M.channels)&&a.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:a.deliveryConfig.channels.map(d=>t.jsx(e.Badge,{variant:"outline",children:d},d))})]}),f.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"}),f.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(d=>t.jsx(e.Button,{variant:d.id===A?"default":"outline",size:"sm",onClick:()=>j(d.id),children:I(d.scheduledFor)},d.id))}),Object.keys(T).length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No delivery attempts were recorded for this run."}):Object.entries(T).map(([d,p])=>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:d})}),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:p.map(g=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-2 py-1",children:g.recipient}),t.jsx("td",{className:"px-2 py-1",children:t.jsx(e.Badge,{variant:g.status==="SENT"?"default":"destructive",className:"text-[10px]",children:g.status})}),t.jsx("td",{className:"px-2 py-1",children:I(g.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:g.error||"--"})]},g.id))})]})})]},d))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function Y(){var c,u;const{quotasQuery:s,usageQuery:r}=e.useAlertQuotas(),n=((c=s.data)==null?void 0:c.quotas)||[],o=((u=r.data)==null?void 0:u.usage)||[],l=new Map(o.map(a=>[a.tenantId||"org",a]));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(e.Button,{variant:"outline",size:"sm",onClick:()=>{s.refetch(),r.refetch()},children:"Refresh"})]}),s.isLoading||r.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:n.map(a=>{const i=a.tenantId||"org",m=l.get(i);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:i}),t.jsx("td",{className:"px-3 py-2",children:(m==null?void 0:m.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[a.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxContextSources})]},i)})})]})})]})}exports.AlertManagementPage=e.AlertManagementPage;exports.AlertWizardDialog=e.AlertWizardDialog;exports.AlertsApiError=e.AlertsApiError;exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;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.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.deleteAlert=e.deleteAlert;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;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.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;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.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;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.DEFAULT_CALENDAR_CONTEXT=w.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=w.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=w.EMPTY_SELECTION;exports.CalendarPreferencesDialog=F.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=F.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=z.ResourceManagementPanel;exports.useDebouncedDirtyCheck=O.useDebouncedDirtyCheck;exports.AdvancedModeToggle=C.AdvancedModeToggle;exports.ExportNotificationItem=C.ExportNotificationItem;exports.ExportNotificationList=C.ExportNotificationList;exports.NotificationBell=C.NotificationBell;exports.UnsavedChangesAlert=C.UnsavedChangesAlert;exports.VisualEditingControls=C.VisualEditingControls;exports.useExportPolling=C.useExportPolling;exports.useExportRecovery=C.useExportRecovery;exports.usePristineSnapshotInitializer=C.usePristineSnapshotInitializer;exports.normalizeDashboardForDirtyCheck=L.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=L.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=K;exports.Combobox=V;exports.ScheduleDashboard=H;exports.TenantQuotaPage=Y;exports.Visual=q;exports.useAlertBacktest=U;exports.useExposePrintState=$;