react-semaphor 0.1.294 → 0.1.296

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 (40) hide show
  1. package/dist/chunks/{braces-DfDQiR3J.js → braces-BNXseceK.js} +1 -1
  2. package/dist/chunks/{braces-DR-GdaLC.js → braces-DVrX_3Q_.js} +1 -1
  3. package/dist/chunks/dashboard-controls-CKKZcVA5.js +2219 -0
  4. package/dist/chunks/dashboard-controls-DS2xJxHU.js +47 -0
  5. package/dist/chunks/dashboard-filter-controls-button-nqfmscB7.js +11 -0
  6. package/dist/chunks/{dashboard-filter-controls-button-DxgGUl00.js → dashboard-filter-controls-button-xPaIlNHP.js} +501 -495
  7. package/dist/chunks/{dashboard-json-BvTeHePu.js → dashboard-json-cuj9vYY9.js} +1 -1
  8. package/dist/chunks/{dashboard-json-DQW8TN0I.js → dashboard-json-ovQyHWw6.js} +1 -1
  9. package/dist/chunks/{dashboard-summary-settings-dialog-BsmKiGud.js → dashboard-summary-settings-dialog-BUg3Qyhh.js} +1 -1
  10. package/dist/chunks/{dashboard-summary-settings-dialog-q7fx3YAK.js → dashboard-summary-settings-dialog-DF076HeJ.js} +1 -1
  11. package/dist/chunks/{edit-dashboard-visual-RVl9nbDZ.js → edit-dashboard-visual-32TAM00c.js} +5373 -5302
  12. package/dist/chunks/edit-dashboard-visual-BtiMcO-L.js +183 -0
  13. package/dist/chunks/{index-DerPpfv0.js → index-BDeJH9hO.js} +103982 -88259
  14. package/dist/chunks/index-Dbrs96G8.js +1533 -0
  15. package/dist/chunks/{resource-management-panel-epydPwyM.js → resource-management-panel-2qcXsKwg.js} +2 -2
  16. package/dist/chunks/{resource-management-panel-DnZ1rw1A.js → resource-management-panel-C4qoxy_g.js} +31 -30
  17. package/dist/chunks/use-create-flow-overlay-state-BMD3YRzU.js +21 -0
  18. package/dist/chunks/{use-create-flow-overlay-state-C5vdfXhM.js → use-create-flow-overlay-state-CHeppRNE.js} +572 -568
  19. package/dist/chunks/{use-visual-utils-D9Kknvjl.js → use-visual-utils-BIHLaVwh.js} +70 -68
  20. package/dist/chunks/use-visual-utils-dOYWf6nM.js +1 -0
  21. package/dist/dashboard/index.cjs +1 -1
  22. package/dist/dashboard/index.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +113 -112
  25. package/dist/style.css +1 -1
  26. package/dist/surfboard/index.cjs +1 -1
  27. package/dist/surfboard/index.js +2 -2
  28. package/dist/types/dashboard.d.ts +271 -0
  29. package/dist/types/main.d.ts +324 -0
  30. package/dist/types/shared.d.ts +240 -0
  31. package/dist/types/surfboard.d.ts +271 -0
  32. package/dist/types/types.d.ts +271 -0
  33. package/package.json +7 -1
  34. package/dist/chunks/dashboard-controls-C3Z9bpYE.js +0 -2014
  35. package/dist/chunks/dashboard-controls-DGEVXgP5.js +0 -47
  36. package/dist/chunks/dashboard-filter-controls-button-BIYT1ucX.js +0 -11
  37. package/dist/chunks/edit-dashboard-visual-ChKj-Lzr.js +0 -183
  38. package/dist/chunks/index-BlspGR07.js +0 -1435
  39. package/dist/chunks/use-create-flow-overlay-state-Bcg4EgoD.js +0 -21
  40. package/dist/chunks/use-visual-utils-Dw_yw9zU.js +0 -1
@@ -1,8 +1,8 @@
1
- import { H as G, d as Y, J as X, K as Z, M as ee, N as te, O as re, Q as se, u as b, T as ae, U as oe, y as v, V as ne, W as B, Y as ie } from "./index-DerPpfv0.js";
2
- import { useState as H, useEffect as ce, useCallback as A } from "react";
3
- function de(e) {
4
- const [a, s] = H(null), [r, t] = H(null), o = G();
5
- return ce(() => {
1
+ import { H as Y, d as X, J as Z, K as ee, M as te, N as re, O as se, Q as ae, u as b, T as oe, U as ne, y as v, V as ie, W as H, Y as ce } from "./index-BDeJH9hO.js";
2
+ import { useState as Q, useEffect as de, useCallback as A } from "react";
3
+ function le(e) {
4
+ const [a, s] = Q(null), [r, t] = Q(null), o = Y();
5
+ return de(() => {
6
6
  if (!e || e.trim() === "") {
7
7
  s(null), t(null);
8
8
  return;
@@ -39,7 +39,7 @@ function de(e) {
39
39
  })();
40
40
  }, [e, o]), a;
41
41
  }
42
- function le(e, a) {
42
+ function ue(e, a) {
43
43
  if (e.length === 0)
44
44
  return "";
45
45
  const s = e.find(
@@ -68,23 +68,23 @@ function le(e, a) {
68
68
  return e[0].id;
69
69
  }
70
70
  const M = /* @__PURE__ */ new Set();
71
- function Se(e) {
71
+ function Ee(e) {
72
72
  return M.add(e), () => {
73
73
  M.delete(e);
74
74
  };
75
75
  }
76
- function ue() {
76
+ function fe() {
77
77
  M.forEach((e) => {
78
78
  e();
79
79
  });
80
80
  }
81
- const fe = (e) => {
81
+ const he = (e) => {
82
82
  if (!e || !("detailTableBackup" in e))
83
83
  return e;
84
84
  const { detailTableBackup: a, ...s } = e;
85
85
  return s;
86
86
  };
87
- async function Q(e, a, s, r) {
87
+ async function z(e, a, s, r) {
88
88
  if (!a || !s)
89
89
  throw new Error("Missing auth token or visual ID");
90
90
  const t = ["resource-by-id", "visual", s], o = r.getQueryData(t);
@@ -111,41 +111,41 @@ async function Q(e, a, s, r) {
111
111
  throw v.dismiss(l), n;
112
112
  }
113
113
  }
114
- function z(e) {
114
+ function q(e) {
115
115
  if (typeof e == "string")
116
116
  return JSON.parse(e);
117
117
  if (typeof e == "object")
118
118
  return e;
119
119
  throw new Error("Invalid frame object format");
120
120
  }
121
- function he(e, a) {
121
+ function me(e, a) {
122
122
  var o, l;
123
123
  const s = (e == null ? void 0 : e.frameObject) ?? ((o = e == null ? void 0 : e.visual) == null ? void 0 : o.frameObject);
124
124
  if (!s)
125
125
  return !1;
126
- const r = z(s);
126
+ const r = q(s);
127
127
  if (!(r != null && r.cards) || r.cards.length === 0)
128
128
  return !1;
129
129
  const t = (l = r.cards) == null ? void 0 : l.find(
130
130
  (n) => n.id === r.activeCardId
131
131
  );
132
- return t ? (ne({
132
+ return t ? (ie({
133
133
  ...a,
134
134
  frame: r,
135
135
  card: t,
136
136
  visualId: (e == null ? void 0 : e.id) || r.visualId
137
137
  }), !0) : !1;
138
138
  }
139
- function me() {
140
- const e = B(
139
+ function pe() {
140
+ const e = H(
141
141
  (r) => {
142
142
  var t;
143
143
  return ((t = r.card.customCardPreferences) == null ? void 0 : t.url) || "";
144
144
  }
145
- ), a = de(e);
145
+ ), a = le(e);
146
146
  return { getUpdatedFrame: A(() => {
147
147
  var p;
148
- ue();
148
+ fe();
149
149
  const {
150
150
  frame: r,
151
151
  card: t,
@@ -156,73 +156,74 @@ function me() {
156
156
  selectedDatabaseName: f,
157
157
  selectedTableName: h,
158
158
  selectedConnectionId: F
159
- } = B.getState(), y = t.sql, C = (p = a == null ? void 0 : a.getState()) == null ? void 0 : p.settings, I = ie(t, {
159
+ } = H.getState(), C = t.sql, y = (p = a == null ? void 0 : a.getState()) == null ? void 0 : p.settings, I = ce(t, {
160
160
  isDevMode: o,
161
- cardSql: y,
161
+ cardSql: C,
162
162
  isShowingVisual: l,
163
163
  selectedSchemaName: n,
164
164
  selectedDatamodelId: i,
165
165
  selectedDatabaseName: f,
166
166
  selectedTableName: h,
167
167
  selectedConnectionId: F,
168
- remoteChartSettings: C,
169
- stripConfig: fe
168
+ remoteChartSettings: y,
169
+ stripConfig: he
170
170
  }), m = r.cards.map(
171
171
  (g) => g.id === t.id ? I : g
172
172
  );
173
173
  return {
174
174
  ...r,
175
175
  cards: m,
176
- activeCardId: le(m, r.activeCardId)
176
+ activeCardId: ue(m, r.activeCardId)
177
177
  };
178
178
  }, [a]) };
179
179
  }
180
- function Ee() {
181
- const { authToken: e, tokenProps: a } = Y(), s = X(), r = Z(), t = ee(), { selectVisual: o } = te(), {
180
+ function we() {
181
+ const { authToken: e, tokenProps: a } = X(), s = Z(), r = ee(), t = te(), { selectVisual: o } = re(), {
182
182
  setFrame: l,
183
183
  setCard: n,
184
184
  setIsDevMode: i,
185
185
  initializeModeDrafts: f,
186
186
  setActiveTabCardId: h,
187
187
  updateDataSource: F,
188
- setQueryResultColumns: y,
189
- setSelectedConnectionId: C,
188
+ setQueryResultColumns: C,
189
+ setSelectedConnectionId: y,
190
190
  setSelectedDatabaseName: I,
191
191
  setSelectedSchemaName: m,
192
192
  setSelectedTableName: p,
193
193
  setSelectedDatamodelId: g,
194
194
  setFilterValues: P,
195
195
  setInlineFilterValuesMap: T,
196
- setApplyFilters: D
197
- } = re(), {
196
+ setApplyFilters: D,
197
+ clearEditorContext: L
198
+ } = se(), {
198
199
  setIsDashboardEditing: U,
199
- setIsVisualEditing: L,
200
- setSelectedFrameId: N,
201
- clearSelectedFrameId: W,
202
- setIsDashboardPanelOpen: j
203
- } = se(), S = b((c) => c.selectedSheetId), k = b((c) => c.selectedFrameId), $ = b((c) => c.dashboard), O = b((c) => c.filterValues), R = b(
200
+ setIsVisualEditing: N,
201
+ setSelectedFrameId: W,
202
+ clearSelectedFrameId: j,
203
+ setIsDashboardPanelOpen: k
204
+ } = ae(), S = b((c) => c.selectedSheetId), $ = b((c) => c.selectedFrameId), O = b((c) => c.dashboard), R = b((c) => c.filterValues), x = b(
204
205
  (c) => c.inlineFilterValuesMap
205
- ), E = ae((t == null ? void 0 : t.id) || "", {
206
+ ), E = oe((t == null ? void 0 : t.id) || "", {
206
207
  enabled: !!(t != null && t.id) && !!(e != null && e.accessToken)
207
- }), q = A(
208
+ }), J = A(
208
209
  async (c) => {
209
210
  try {
210
- o(c), W();
211
- const { data: u, fromCache: V } = await Q(
211
+ o(c), j(), L();
212
+ const { data: u, fromCache: V } = await z(
212
213
  a.apiServiceUrl,
213
214
  (e == null ? void 0 : e.accessToken) || "",
214
215
  c.id,
215
216
  s
216
217
  );
217
- if (!he(u, {
218
+ if (!me(u, {
218
219
  setFrame: l,
219
220
  setCard: n,
220
221
  setIsDevMode: i,
221
222
  initializeModeDrafts: f,
222
223
  setActiveTabCardId: h,
223
224
  updateDataSource: F,
224
- setQueryResultColumns: y,
225
- setSelectedConnectionId: C,
225
+ setQueryResultColumns: C,
226
+ setSelectedConnectionId: y,
226
227
  setSelectedDatabaseName: I,
227
228
  setSelectedSchemaName: m,
228
229
  setSelectedTableName: p,
@@ -231,12 +232,12 @@ function Ee() {
231
232
  setInlineFilterValuesMap: T,
232
233
  setApplyFilters: D,
233
234
  setIsDashboardEditing: U,
234
- setIsVisualEditing: L,
235
- dashboard: $,
235
+ setIsVisualEditing: N,
236
+ dashboard: O,
236
237
  selectedSheetId: S,
237
- selectedFrameId: k,
238
- filterValues: O,
239
- inlineFilterValuesMap: R
238
+ selectedFrameId: $,
239
+ filterValues: R,
240
+ inlineFilterValuesMap: x
240
241
  }))
241
242
  throw new Error("Failed to setup editor with visual data");
242
243
  return { success: !0, fromCache: V };
@@ -252,13 +253,13 @@ function Ee() {
252
253
  l,
253
254
  n,
254
255
  U,
255
- L,
256
+ N,
256
257
  i,
257
258
  f,
258
259
  h,
259
260
  F,
260
- y,
261
261
  C,
262
+ y,
262
263
  I,
263
264
  m,
264
265
  p,
@@ -266,21 +267,22 @@ function Ee() {
266
267
  P,
267
268
  T,
268
269
  D,
269
- W,
270
- $,
271
- S,
272
- k,
270
+ L,
271
+ j,
273
272
  O,
274
- R
273
+ S,
274
+ $,
275
+ R,
276
+ x
275
277
  ]
276
- ), J = A(
278
+ ), K = A(
277
279
  async (c) => {
278
280
  var V;
279
281
  const u = (d) => (v.error(d), { success: !1, error: d });
280
282
  try {
281
283
  if (o(c), !S)
282
284
  return u("No sheet selected. Please select a sheet first.");
283
- const { data: d, fromCache: K } = await Q(
285
+ const { data: d, fromCache: G } = await z(
284
286
  a.apiServiceUrl,
285
287
  (e == null ? void 0 : e.accessToken) || "",
286
288
  c.id,
@@ -288,19 +290,19 @@ function Ee() {
288
290
  ), _ = (d == null ? void 0 : d.frameObject) ?? ((V = d == null ? void 0 : d.visual) == null ? void 0 : V.frameObject);
289
291
  if (!_)
290
292
  return u("Visual has no frame data");
291
- const w = z(_);
293
+ const w = q(_);
292
294
  if (!(w != null && w.cards) || w.cards.length === 0)
293
295
  return u("Visual frame is malformed");
294
- const x = {
295
- ...oe(w),
296
+ const B = {
297
+ ...ne(w),
296
298
  visualId: c.id
297
299
  // Link this frame to the library visual
298
300
  };
299
301
  return await r(
300
302
  S,
301
- x,
303
+ B,
302
304
  "end"
303
- ), U(!0), N(x.id), j(!1), { success: !0, fromCache: K };
305
+ ), U(!0), W(B.id), k(!1), { success: !0, fromCache: G };
304
306
  } catch (d) {
305
307
  return console.error("Error adding visual:", d), u(
306
308
  d instanceof Error ? d.message : "Failed to add visual to dashboard"
@@ -314,8 +316,8 @@ function Ee() {
314
316
  o,
315
317
  S,
316
318
  U,
317
- N,
318
- j,
319
+ W,
320
+ k,
319
321
  r
320
322
  ]
321
323
  );
@@ -324,14 +326,14 @@ function Ee() {
324
326
  isLoading: E.isLoading,
325
327
  isError: E.isError,
326
328
  error: E.error,
327
- handleEditLibraryVisual: q,
328
- handleAddLibraryVisual: J,
329
- getUpdatedFrame: me().getUpdatedFrame,
329
+ handleEditLibraryVisual: J,
330
+ handleAddLibraryVisual: K,
331
+ getUpdatedFrame: pe().getUpdatedFrame,
330
332
  refetch: E.refetch
331
333
  };
332
334
  }
333
335
  export {
334
- ue as f,
335
- Se as r,
336
- Ee as u
336
+ fe as f,
337
+ Ee as r,
338
+ we as u
337
339
  };
@@ -0,0 +1 @@
1
+ "use strict";const a=require("./index-Dbrs96G8.js"),p=require("react");function J(e){const[o,s]=p.useState(null),[r,t]=p.useState(null),n=a.useEnsureReactGlobals();return p.useEffect(()=>{if(!e||e.trim()===""){s(null),t(null);return}if(!n)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 c=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(c,{method:"HEAD"})).ok)throw new Error(`Module not found at ${c}`)}catch{}const h=await import(c);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");s(()=>h.useChartStore),t(null)}catch(i){const c=i instanceof Error?i.message:"Unknown error";console.error("Failed to load remote chart store:",c),t(c),s(null)}})()},[e,n]),o}function K(e,o){if(e.length===0)return"";const s=e.find(r=>{var t,n;return((t=r.customCardPreferences)==null?void 0:t.visualType)==="multiple"||!!((n=r.customCardPreferences)!=null&&n.dataInputCardIds)});if(s)return s.id;if(o){const r=e.find(t=>t.id===o);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const u=t.split("__")[0],i=e.find(c=>c.tabTitle===u);return i?i.id:e[0].id}return o}}return e[0].id}const D=new Set;function X(e){return D.add(e),()=>{D.delete(e)}}function q(){D.forEach(e=>{e()})}const Y=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:o,...s}=e;return s};async function B(e,o,s,r){if(!o||!s)throw new Error("Missing auth token or visual ID");const t=["resource-by-id","visual",s],n=r.getQueryData(t);if(n)return console.log("Using cached visual data for:",s),{data:n,fromCache:!0};console.log("Fetching visual data from network for:",s);const u=a.ue.loading("Loading visual...",{position:"top-center"});try{const i=await fetch(`${e}/management/v1/visuals/${s}`,{headers:{Authorization:`Bearer ${o}`}});if(!i.ok)throw new Error("Failed to load visual");const c=await i.json();return r.setQueryData(t,c),a.ue.dismiss(u),{data:c,fromCache:!1}}catch(i){throw a.ue.dismiss(u),i}}function z(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function Z(e,o){var n,u;const s=(e==null?void 0:e.frameObject)??((n=e==null?void 0:e.visual)==null?void 0:n.frameObject);if(!s)return!1;const r=z(s);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const t=(u=r.cards)==null?void 0:u.find(i=>i.id===r.activeCardId);return t?(a.setupEditorWithCard({...o,frame:r,card:t,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function ee(){const e=a.useEditorStore(r=>{var t;return((t=r.card.customCardPreferences)==null?void 0:t.url)||""}),o=J(e);return{getUpdatedFrame:p.useCallback(()=>{var g;q();const{frame:r,card:t,isDevMode:n,isShowingVisual:u,selectedSchemaName:i,selectedDatamodelId:c,selectedDatabaseName:h,selectedTableName:m,selectedConnectionId:C}=a.useEditorStore.getState(),y=t.sql,I=(g=o==null?void 0:o.getState())==null?void 0:g.settings,U=a.buildSavedEditorCard(t,{isDevMode:n,cardSql:y,isShowingVisual:u,selectedSchemaName:i,selectedDatamodelId:c,selectedDatabaseName:h,selectedTableName:m,selectedConnectionId:C,remoteChartSettings:I,stripConfig:Y}),S=r.cards.map(b=>b.id===t.id?U:b);return{...r,cards:S,activeCardId:K(S,r.activeCardId)}},[o])}}function te(){const{authToken:e,tokenProps:o}=a.useSemaphorContext(),s=a.useQueryClient(),r=a.useAddFrameWithFreshSemanticExecutionPayload(),t=a.useSelectedVisual(),{selectVisual:n}=a.useManagementActions(),{setFrame:u,setCard:i,setIsDevMode:c,initializeModeDrafts:h,setActiveTabCardId:m,updateDataSource:C,setQueryResultColumns:y,setSelectedConnectionId:I,setSelectedDatabaseName:U,setSelectedSchemaName:S,setSelectedTableName:g,setSelectedDatamodelId:b,setFilterValues:A,setInlineFilterValuesMap:P,setApplyFilters:M,clearEditorContext:k}=a.useEditorActions(),{setIsDashboardEditing:V,setIsVisualEditing:L,setSelectedFrameId:T,clearSelectedFrameId:j,setIsDashboardPanelOpen:N}=a.useDashboardActions(),E=a.useDashboardStore(d=>d.selectedSheetId),R=a.useDashboardStore(d=>d.selectedFrameId),W=a.useDashboardStore(d=>d.dashboard),$=a.useDashboardStore(d=>d.filterValues),x=a.useDashboardStore(d=>d.inlineFilterValuesMap),w=a.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),H=p.useCallback(async d=>{try{n(d),j(),k();const{data:f,fromCache:v}=await B(o.apiServiceUrl,(e==null?void 0:e.accessToken)||"",d.id,s);if(!Z(f,{setFrame:u,setCard:i,setIsDevMode:c,initializeModeDrafts:h,setActiveTabCardId:m,updateDataSource:C,setQueryResultColumns:y,setSelectedConnectionId:I,setSelectedDatabaseName:U,setSelectedSchemaName:S,setSelectedTableName:g,setSelectedDatamodelId:b,setFilterValues:A,setInlineFilterValuesMap:P,setApplyFilters:M,setIsDashboardEditing:V,setIsVisualEditing:L,dashboard:W,selectedSheetId:E,selectedFrameId:R,filterValues:$,inlineFilterValuesMap:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:v}}catch(f){return console.error("Error editing visual:",f),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,o.apiServiceUrl,s,n,u,i,V,L,c,h,m,C,y,I,U,S,g,b,A,P,M,k,j,W,E,R,$,x]),Q=p.useCallback(async d=>{var v;const f=l=>(a.ue.error(l),{success:!1,error:l});try{if(n(d),!E)return f("No sheet selected. Please select a sheet first.");const{data:l,fromCache:G}=await B(o.apiServiceUrl,(e==null?void 0:e.accessToken)||"",d.id,s),O=(l==null?void 0:l.frameObject)??((v=l==null?void 0:l.visual)==null?void 0:v.frameObject);if(!O)return f("Visual has no frame data");const F=z(O);if(!(F!=null&&F.cards)||F.cards.length===0)return f("Visual frame is malformed");const _={...a.cloneLinkedFrameWithSourceMapping(F),visualId:d.id};return await r(E,_,"end"),V(!0),T(_.id),N(!1),{success:!0,fromCache:G}}catch(l){return console.error("Error adding visual:",l),f(l instanceof Error?l.message:"Failed to add visual to dashboard")}},[e==null?void 0:e.accessToken,o.apiServiceUrl,s,n,E,V,T,N,r]);return{visual:w.data,isLoading:w.isLoading,isError:w.isError,error:w.error,handleEditLibraryVisual:H,handleAddLibraryVisual:Q,getUpdatedFrame:ee().getUpdatedFrame,refetch:w.refetch}}exports.flushPendingEditorDrafts=q;exports.registerPendingEditorDraftFlusher=X;exports.useVisualUtils=te;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/index-BlspGR07.js"),e=require("../types/index.cjs");exports.Dashboard=r.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 r=require("../chunks/index-Dbrs96G8.js"),e=require("../types/index.cjs");exports.Dashboard=r.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 E } from "../chunks/index-DerPpfv0.js";
1
+ import { D as E } from "../chunks/index-BDeJH9hO.js";
2
2
  import { CONTROL_CARD_DEFAULT_VALUE as L, EMPTY_SELECTION as T } from "../types/index.js";
3
3
  export {
4
4
  L 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-BlspGR07.js"),_=require("./types/index.cjs"),M=require("./chunks/dashboard-summary-settings-dialog-BsmKiGud.js"),t=require("react/jsx-runtime"),u=require("react"),O=require("./chunks/resource-management-panel-epydPwyM.js"),U=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");const C=require("./chunks/dashboard-filter-controls-button-BIYT1ucX.js"),L=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function z(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 R=z(u);function Q(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,cardId:n,...o}=s,l={...o,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:l,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",cardId:n,...l,children:t.jsx(V,{cardId:n})})})})]})})}function V({cardId:s}){const r=e.useDashboardStore(l=>{var c;return(c=l.dashboard)==null?void 0:c.sheets}),{card:n,frame:o}=u.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),m=c==null?void 0:c.find(i=>(i==null?void 0:i.id)===s),a=l==null?void 0:l.find(i=>{var h;return(h=i==null?void 0:i.cards)==null?void 0:h.find(f=>(f==null?void 0:f.id)===s)});return{card:m,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 W(s,r,n,o){u.useEffect(()=>{s&&!n&&r&&o(e.cloneDeep(r))},[s,n,r,o])}function H({name:s,items:r,value:n,onChange:o,isLoading:l,isError:c,refetch:m,className:a,icon:i,showNone:h=!1}){const f=R.useRef(null),[D,A]=R.useState(!1),[b,j]=R.useState("100%"),y=h?[...r||[],{id:"none",name:"None"}]:r;R.useLayoutEffect(()=>{f.current&&j(f.current.offsetWidth)},[]);function I(){var x;return l?"Loading...":c?"Error":n?(x=r==null?void 0:r.find(S=>S.id===n))==null?void 0:x.name:`Select ${s}`}function T(x,S){o(S),A(!1)}return t.jsxs(e.Popover,{open:D,onOpenChange:A,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":D,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:I()})]}),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:m,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(x=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:x.name,onSelect:S=>T(S,x.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",n===x.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:x.name,children:x.name})]})},x.id))})]})]})})]})}function $({triggerButtonClassName:s,variant:r="ghost"}){const[n,o]=u.useState(!1),l=e.useDashboardStore(m=>{var a;return(a=m.dashboard)==null?void 0:a.id}),c=e.useDashboardStore(m=>{var a;return(a=m.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 G(s,r){u.useEffect(()=>(s&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,r])}function P(s){if(!s)return"--";const r=new Date(s);return Number.isNaN(r.getTime())?"--":r.toLocaleString()}function K(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 Y({alertId:s,onBack:r}){var x,S,F,w;const{authToken:n,tokenProps:o}=e.useSemaphorContext(),{data:l,isLoading:c,refetch:m}=e.useAlertDetail(s),a=(l==null?void 0:l.alert)??null,[i,h]=u.useState([]),[f,D]=u.useState([]),[A,b]=u.useState(null),j=u.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 v=await fetch(`${d}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${p}`}});if(v.ok){const E=await v.json(),N=Array.isArray(E.runs)?E.runs:[],k=A&&N.some(B=>B.id===A)?A:((g=N[0])==null?void 0:g.id)??null;return D(N),b(k),k}D([]),b(null)}catch{return D([]),b(null),null}return null},[s,n,A,o]),y=u.useCallback(async d=>{const p=o==null?void 0:o.apiServiceUrl,g=n==null?void 0:n.accessToken,v=d??A;if(!p||!g||!s||!v){h([]);return}try{const E=await fetch(`${p}/v1/alerts/${s}/runs/${v}/deliveries`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const N=await E.json();h(Array.isArray(N.attempts)?N.attempts:[])}else h([])}catch{h([])}},[s,n,A,o]),I=u.useCallback(async()=>{await m();const d=await j();await y(d)},[y,j,m]);u.useEffect(()=>{j().catch(()=>{})},[j]),u.useEffect(()=>{y().catch(()=>{})},[y]);const T=u.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:K(a)}),((x=a.alertState)==null?void 0:x.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 I(),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:"})," ",P((S=a.alertState)==null?void 0:S.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",P((F=a.alertState)==null?void 0:F.lastTriggeredAt)]})]})]}),((w=a.deliveryConfig)==null?void 0:w.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:()=>b(d.id),children:P(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:P(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 X(){var c,m;const{quotasQuery:s,usageQuery:r}=e.useAlertQuotas(),n=((c=s.data)==null?void 0:c.quotas)||[],o=((m=r.data)==null?void 0:m.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",h=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:(h==null?void 0:h.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.CONTROL_CARD_DEFAULT_VALUE=_.CONTROL_CARD_DEFAULT_VALUE;exports.DEFAULT_CALENDAR_CONTEXT=_.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=_.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=_.EMPTY_SELECTION;exports.CalendarPreferencesDialog=M.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=M.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=O.ResourceManagementPanel;exports.useDebouncedDirtyCheck=U.useDebouncedDirtyCheck;exports.AdvancedModeToggle=C.AdvancedModeToggle;exports.DashboardControlsSettings=C.DashboardControlsSettings;exports.DashboardFilterControlsButton=C.DashboardFilterControlsButton;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.normalizeDashboardForDirtyCheck=L.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=L.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=Y;exports.Combobox=H;exports.ScheduleDashboard=$;exports.TenantQuotaPage=X;exports.Visual=q;exports.useAlertBacktest=Q;exports.useExposePrintState=G;exports.usePristineSnapshotInitializer=W;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-Dbrs96G8.js"),_=require("./types/index.cjs"),M=require("./chunks/dashboard-summary-settings-dialog-BUg3Qyhh.js"),t=require("react/jsx-runtime"),u=require("react"),O=require("./chunks/resource-management-panel-2qcXsKwg.js"),U=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");const C=require("./chunks/dashboard-filter-controls-button-nqfmscB7.js"),L=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function z(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 R=z(u);function Q(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,cardId:n,...o}=s,l={...o,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:l,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",cardId:n,...l,children:t.jsx(V,{cardId:n})})})})]})})}function V({cardId:s}){const r=e.useDashboardStore(l=>{var c;return(c=l.dashboard)==null?void 0:c.sheets}),{card:n,frame:o}=u.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),m=c==null?void 0:c.find(i=>(i==null?void 0:i.id)===s),a=l==null?void 0:l.find(i=>{var h;return(h=i==null?void 0:i.cards)==null?void 0:h.find(f=>(f==null?void 0:f.id)===s)});return{card:m,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 W(s,r,n,o){u.useEffect(()=>{s&&!n&&r&&o(e.cloneDeep(r))},[s,n,r,o])}function H({name:s,items:r,value:n,onChange:o,isLoading:l,isError:c,refetch:m,className:a,icon:i,showNone:h=!1}){const f=R.useRef(null),[S,A]=R.useState(!1),[b,j]=R.useState("100%"),y=h?[...r||[],{id:"none",name:"None"}]:r;R.useLayoutEffect(()=>{f.current&&j(f.current.offsetWidth)},[]);function w(){var x;return l?"Loading...":c?"Error":n?(x=r==null?void 0:r.find(D=>D.id===n))==null?void 0:x.name:`Select ${s}`}function T(x,D){o(D),A(!1)}return t.jsxs(e.Popover,{open:S,onOpenChange:A,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":S,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:w()})]}),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:m,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(x=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:x.name,onSelect:D=>T(D,x.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",n===x.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:x.name,children:x.name})]})},x.id))})]})]})})]})}function $({triggerButtonClassName:s,variant:r="ghost"}){const[n,o]=u.useState(!1),l=e.useDashboardStore(m=>{var a;return(a=m.dashboard)==null?void 0:a.id}),c=e.useDashboardStore(m=>{var a;return(a=m.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 G(s,r){u.useEffect(()=>(s&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,r])}function P(s){if(!s)return"--";const r=new Date(s);return Number.isNaN(r.getTime())?"--":r.toLocaleString()}function K(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 Y({alertId:s,onBack:r}){var x,D,I,F;const{authToken:n,tokenProps:o}=e.useSemaphorContext(),{data:l,isLoading:c,refetch:m}=e.useAlertDetail(s),a=(l==null?void 0:l.alert)??null,[i,h]=u.useState([]),[f,S]=u.useState([]),[A,b]=u.useState(null),j=u.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 v=await fetch(`${d}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${p}`}});if(v.ok){const E=await v.json(),N=Array.isArray(E.runs)?E.runs:[],k=A&&N.some(B=>B.id===A)?A:((g=N[0])==null?void 0:g.id)??null;return S(N),b(k),k}S([]),b(null)}catch{return S([]),b(null),null}return null},[s,n,A,o]),y=u.useCallback(async d=>{const p=o==null?void 0:o.apiServiceUrl,g=n==null?void 0:n.accessToken,v=d??A;if(!p||!g||!s||!v){h([]);return}try{const E=await fetch(`${p}/v1/alerts/${s}/runs/${v}/deliveries`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const N=await E.json();h(Array.isArray(N.attempts)?N.attempts:[])}else h([])}catch{h([])}},[s,n,A,o]),w=u.useCallback(async()=>{await m();const d=await j();await y(d)},[y,j,m]);u.useEffect(()=>{j().catch(()=>{})},[j]),u.useEffect(()=>{y().catch(()=>{})},[y]);const T=u.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:K(a)}),((x=a.alertState)==null?void 0:x.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 w(),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:"})," ",P((D=a.alertState)==null?void 0:D.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",P((I=a.alertState)==null?void 0:I.lastTriggeredAt)]})]})]}),((F=a.deliveryConfig)==null?void 0:F.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:()=>b(d.id),children:P(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:P(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 X(){var c,m;const{quotasQuery:s,usageQuery:r}=e.useAlertQuotas(),n=((c=s.data)==null?void 0:c.quotas)||[],o=((m=r.data)==null?void 0:m.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",h=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:(h==null?void 0:h.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.downloadDocumentPdf=e.downloadDocumentPdf;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.CONTROL_CARD_DEFAULT_VALUE=_.CONTROL_CARD_DEFAULT_VALUE;exports.DEFAULT_CALENDAR_CONTEXT=_.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=_.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=_.EMPTY_SELECTION;exports.CalendarPreferencesDialog=M.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=M.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=O.ResourceManagementPanel;exports.useDebouncedDirtyCheck=U.useDebouncedDirtyCheck;exports.AdvancedModeToggle=C.AdvancedModeToggle;exports.DashboardControlsSettings=C.DashboardControlsSettings;exports.DashboardFilterControlsButton=C.DashboardFilterControlsButton;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.normalizeDashboardForDirtyCheck=L.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=L.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=Y;exports.Combobox=H;exports.ScheduleDashboard=$;exports.TenantQuotaPage=X;exports.Visual=q;exports.useAlertBacktest=Q;exports.useExposePrintState=G;exports.usePristineSnapshotInitializer=W;