react-semaphor 0.1.441 → 0.1.442

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 (28) hide show
  1. package/dist/brand-studio/index.js +1 -1
  2. package/dist/chunks/{code-editor-CIWiSltV.js → code-editor-BpADiIlq.js} +26 -26
  3. package/dist/chunks/{dashboard-C-eTAAKs.js → dashboard-BRj8nq8w.js} +77 -77
  4. package/dist/chunks/{dashboard--bQrQeiz.js → dashboard-BjqymJeS.js} +4986 -4900
  5. package/dist/chunks/{dashboard-briefing-launcher-xulAb1Oz.js → dashboard-briefing-launcher-B7LrrGSM.js} +165 -176
  6. package/dist/chunks/{dashboard-briefing-launcher-dgTjPWHX.js → dashboard-briefing-launcher-D5oHvdYf.js} +6 -11
  7. package/dist/chunks/{dashboard-controls-CWu1wt6_.js → dashboard-controls-CUd1yfGB.js} +4 -4
  8. package/dist/chunks/{dashboard-controls-D8BDZ5_q.js → dashboard-controls-DjyNG67M.js} +1 -1
  9. package/dist/chunks/{dashboard-json-ZgLCrrSW.js → dashboard-json-C5_h_0OT.js} +2 -2
  10. package/dist/chunks/{dashboard-json-Bpm-ePrD.js → dashboard-json-CiMI9PO-.js} +1 -1
  11. package/dist/chunks/{edit-dashboard-visual-DEtVA2re.js → edit-dashboard-visual-BOkzUd4b.js} +8260 -7877
  12. package/dist/chunks/edit-dashboard-visual-EwylNae5.js +182 -0
  13. package/dist/chunks/{use-create-flow-overlay-state-B6a3gmF0.js → editor-action-buttons-Bz4ik8DY.js} +887 -870
  14. package/dist/chunks/editor-action-buttons-C0EXI0VB.js +16 -0
  15. package/dist/chunks/{report-preferences-dialog-Bjj_tIgL.js → report-preferences-dialog-Ck94m-ik.js} +2 -2
  16. package/dist/chunks/{report-preferences-dialog-Ju8DjgyW.js → report-preferences-dialog-Cw4Ti1lc.js} +1 -1
  17. package/dist/dashboard/index.cjs +1 -1
  18. package/dist/dashboard/index.js +1 -1
  19. package/dist/data-app-builder/index.cjs +1 -1
  20. package/dist/data-app-builder/index.js +66 -66
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +6 -6
  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/package.json +1 -1
  27. package/dist/chunks/edit-dashboard-visual-BCMupXbq.js +0 -182
  28. package/dist/chunks/use-create-flow-overlay-state-wcIRGLSM.js +0 -11
@@ -1,19 +1,30 @@
1
- import { useState as K, useEffect as ie, useCallback as B, useMemo as oe, useRef as Se, Fragment as ht } from "react";
2
- import { D as de, A as Te, u as J, E as z, a4 as bt, Q as gt, V as yt, W as vt, c as fe, Y as xt, a5 as Ct, B as q, d as St, L as Je, a6 as kt, a7 as Nt, a8 as wt, a9 as pe, aa as Be, ab as Re, ac as ke, ad as Ne, ae as Dt, af as je, ag as Et, ah as It, ai as me, aj as Ft, ak as Qe, al as Ze, am as et, an as tt, O as ne, Z as at, _ as we, $ as De, a0 as Ee, a1 as Ie, a2 as Fe, ao as rt, ap as Vt, aq as $e, ar as Tt, as as Pe, at as _t, au as At, av as Ve } from "./code-editor-CIWiSltV.js";
3
- import { aM as Lt, az as qt, aN as ce, aO as Mt, aP as _e, aQ as Ot, aR as Ut, aS as zt, aG as R, aT as Bt, aU as Rt, aV as jt, av as Qt, aW as $t, aX as st, aY as nt, aZ as ot, a_ as Pt, a$ as Wt, b0 as Kt, b1 as Yt, b2 as Ht, b3 as lt, b4 as it, b5 as Gt, b6 as Xt, b7 as Jt, b8 as Zt, b9 as ea, ba as ta, bb as aa, bc as ra } from "./dashboard--bQrQeiz.js";
4
- import { jsx as a, jsxs as p, Fragment as ae } from "react/jsx-runtime";
5
- import { c as dt, X as ct, C as We } from "./index-xHCrHprY.js";
1
+ import { c as Te, C as je, X as Ze } from "./index-xHCrHprY.js";
2
+ import { useState as H, useEffect as ie, useCallback as z, useMemo as oe, useRef as ke, Fragment as ht } from "react";
3
+ import { D as de, A as _e, u as J, E as U, a4 as bt, Q as gt, V as yt, W as vt, c as fe, Y as xt, a5 as Ct, a6 as kt, a7 as pe, a8 as Re, a9 as Qe, aa as Se, ab as Ne, ac as St, ad as $e, ae as Nt, af as wt, ag as me, ah as Dt, ai as Pe, B as L, aj as et, ak as tt, al as rt, O as ne, Z as at, _ as we, $ as De, a0 as Ee, a1 as Fe, a2 as Ie, am as st, an as Et, ao as We, ap as Ft, aq as He, ar as It, as as Vt, at as Ve, d as Tt, L as nt, au as _t, av as At } from "./code-editor-BpADiIlq.js";
4
+ import { b7 as Lt, az as qt, b8 as ce, b9 as Mt, ba as Ae, bb as Ot, bc as Ut, bd as zt, aG as B, be as Bt, bf as jt, bg as Rt, bh as ot, bi as lt, bj as Qt, av as $t, bk as Pt, bl as Wt, bm as Ht, bn as Kt, bo as it, bp as dt, bq as Yt, br as Gt, bs as Xt, bt as Jt, bu as Zt, aZ as er, bv as tr, bw as rr, bx as ct, by as ar } from "./dashboard-BjqymJeS.js";
5
+ import { jsx as r, jsxs as p, Fragment as re } from "react/jsx-runtime";
6
6
  import "./analyze-result-contract-CfOBEwaC.js";
7
7
  import "../value-format-preferences/index.js";
8
- import { S as ut } from "./save-HCJjjzdX.js";
9
8
  import { C as Ke } from "./search-DHZCro8B.js";
9
+ import { S as ut } from "./save-HCJjjzdX.js";
10
+ /**
11
+ * @license lucide-react v0.453.0 - ISC
12
+ *
13
+ * This source code is licensed under the ISC license.
14
+ * See the LICENSE file in the root directory of this source tree.
15
+ */
16
+ const Dr = Te("FilterX", [
17
+ ["path", { d: "M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055", key: "1fi1da" }],
18
+ ["path", { d: "m22 3-5 5", key: "12jva0" }],
19
+ ["path", { d: "m17 3 5 5", key: "k36vhe" }]
20
+ ]);
10
21
  /**
11
22
  * @license lucide-react v0.453.0 - ISC
12
23
  *
13
24
  * This source code is licensed under the ISC license.
14
25
  * See the LICENSE file in the root directory of this source tree.
15
26
  */
16
- const sa = dt("Library", [
27
+ const sr = Te("Library", [
17
28
  ["path", { d: "m16 6 4 14", key: "ji33uf" }],
18
29
  ["path", { d: "M12 6v14", key: "1n7gus" }],
19
30
  ["path", { d: "M8 8v12", key: "1gg7y9" }],
@@ -25,16 +36,16 @@ const sa = dt("Library", [
25
36
  * This source code is licensed under the ISC license.
26
37
  * See the LICENSE file in the root directory of this source tree.
27
38
  */
28
- const na = dt("Link2", [
39
+ const nr = Te("Link2", [
29
40
  ["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
30
41
  ["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
31
42
  ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
32
43
  ]);
33
- function oa(t) {
34
- const [r, l] = K(null), [n, i] = K(null), c = Lt();
44
+ function or(t) {
45
+ const [a, o] = H(null), [s, i] = H(null), c = Lt();
35
46
  return ie(() => {
36
47
  if (!t || t.trim() === "") {
37
- l(null), i(null);
48
+ o(null), i(null);
38
49
  return;
39
50
  }
40
51
  if (!c)
@@ -61,73 +72,73 @@ function oa(t) {
61
72
  );
62
73
  if (typeof v.useChartStore != "function")
63
74
  throw new Error("useChartStore is not a function");
64
- l(() => v.useChartStore), i(null);
65
- } catch (f) {
66
- const u = f instanceof Error ? f.message : "Unknown error";
67
- console.error("Failed to load remote chart store:", u), i(u), l(null);
75
+ o(() => v.useChartStore), i(null);
76
+ } catch (h) {
77
+ const u = h instanceof Error ? h.message : "Unknown error";
78
+ console.error("Failed to load remote chart store:", u), i(u), o(null);
68
79
  }
69
80
  })();
70
- }, [t, c]), r;
81
+ }, [t, c]), a;
71
82
  }
72
- function la(t, r) {
83
+ function lr(t, a) {
73
84
  if (t.length === 0)
74
85
  return "";
75
- const l = t.find(
76
- (n) => {
86
+ const o = t.find(
87
+ (s) => {
77
88
  var i, c;
78
- return ((i = n.customCardPreferences) == null ? void 0 : i.visualType) === "multiple" || !!((c = n.customCardPreferences) != null && c.dataInputCardIds);
89
+ return ((i = s.customCardPreferences) == null ? void 0 : i.visualType) === "multiple" || !!((c = s.customCardPreferences) != null && c.dataInputCardIds);
79
90
  }
80
91
  );
81
- if (l)
82
- return l.id;
83
- if (r) {
84
- const n = t.find((i) => i.id === r);
85
- if (n) {
86
- const i = n.tabTitle;
92
+ if (o)
93
+ return o.id;
94
+ if (a) {
95
+ const s = t.find((i) => i.id === a);
96
+ if (s) {
97
+ const i = s.tabTitle;
87
98
  if (i == "All__Header")
88
99
  return t[0].id;
89
100
  if (i && i.endsWith("__Header")) {
90
- const m = i.split("__")[0], f = t.find(
101
+ const m = i.split("__")[0], h = t.find(
91
102
  (u) => u.tabTitle === m
92
103
  );
93
- return f ? f.id : t[0].id;
104
+ return h ? h.id : t[0].id;
94
105
  }
95
- return r;
106
+ return a;
96
107
  }
97
108
  }
98
109
  return t[0].id;
99
110
  }
100
- const ia = (t) => {
111
+ const ir = (t) => {
101
112
  if (!t || !("detailTableBackup" in t))
102
113
  return t;
103
- const { detailTableBackup: r, ...l } = t;
104
- return l;
114
+ const { detailTableBackup: a, ...o } = t;
115
+ return o;
105
116
  };
106
- async function Ye(t, r, l, n, i = "Opening library visual...") {
107
- if (!r || !l)
117
+ async function Ye(t, a, o, s, i = "Opening library visual...") {
118
+ if (!a || !o)
108
119
  throw new Error("Missing auth token or visual ID");
109
- const c = ["resource-by-id", "visual", l], m = n.getQueryData(c);
120
+ const c = ["resource-by-id", "visual", o], m = s.getQueryData(c);
110
121
  if (m)
111
- return console.log("Using cached visual data for:", l), { data: m, fromCache: !0 };
112
- console.log("Fetching visual data from network for:", l);
113
- const f = R.loading(i, {
122
+ return console.log("Using cached visual data for:", o), { data: m, fromCache: !0 };
123
+ console.log("Fetching visual data from network for:", o);
124
+ const h = B.loading(i, {
114
125
  position: "top-center"
115
126
  });
116
127
  try {
117
128
  const u = await fetch(
118
- `${t}/management/v1/visuals/${l}`,
129
+ `${t}/management/v1/visuals/${o}`,
119
130
  {
120
131
  headers: {
121
- Authorization: `Bearer ${r}`
132
+ Authorization: `Bearer ${a}`
122
133
  }
123
134
  }
124
135
  );
125
136
  if (!u.ok)
126
137
  throw new Error("Failed to load visual");
127
138
  const v = await u.json();
128
- return n.setQueryData(c, v), R.dismiss(f), { data: v, fromCache: !1 };
139
+ return s.setQueryData(c, v), B.dismiss(h), { data: v, fromCache: !1 };
129
140
  } catch (u) {
130
- throw R.dismiss(f), u;
141
+ throw B.dismiss(h), u;
131
142
  }
132
143
  }
133
144
  function pt(t) {
@@ -137,260 +148,307 @@ function pt(t) {
137
148
  return t;
138
149
  throw new Error("Invalid frame object format");
139
150
  }
140
- function da(t, r) {
151
+ function dr(t, a) {
141
152
  var c, m;
142
- const l = (t == null ? void 0 : t.frameObject) ?? ((c = t == null ? void 0 : t.visual) == null ? void 0 : c.frameObject);
143
- if (!l)
153
+ const o = (t == null ? void 0 : t.frameObject) ?? ((c = t == null ? void 0 : t.visual) == null ? void 0 : c.frameObject);
154
+ if (!o)
144
155
  return !1;
145
- const n = pt(l);
146
- if (!(n != null && n.cards) || n.cards.length === 0)
156
+ const s = pt(o);
157
+ if (!(s != null && s.cards) || s.cards.length === 0)
147
158
  return !1;
148
- const i = (m = n.cards) == null ? void 0 : m.find(
149
- (f) => f.id === n.activeCardId
159
+ const i = (m = s.cards) == null ? void 0 : m.find(
160
+ (h) => h.id === s.activeCardId
150
161
  );
151
162
  return i ? (Bt({
152
- ...r,
153
- frame: n,
163
+ ...a,
164
+ frame: s,
154
165
  card: i,
155
- visualId: (t == null ? void 0 : t.id) || n.visualId
166
+ visualId: (t == null ? void 0 : t.id) || s.visualId
156
167
  }), !0) : !1;
157
168
  }
158
- function ca() {
159
- const t = z(
160
- (n) => {
169
+ function cr() {
170
+ const t = U(
171
+ (s) => {
161
172
  var i;
162
- return ((i = n.card.customCardPreferences) == null ? void 0 : i.url) || "";
173
+ return ((i = s.card.customCardPreferences) == null ? void 0 : i.url) || "";
163
174
  }
164
- ), r = oa(t);
165
- return { getUpdatedFrame: B(() => {
166
- var F;
167
- Rt();
175
+ ), a = or(t);
176
+ return { getUpdatedFrame: z(() => {
177
+ var V;
178
+ jt();
168
179
  const {
169
- frame: n,
180
+ frame: s,
170
181
  card: i,
171
182
  isDevMode: c,
172
183
  isShowingVisual: m,
173
- selectedSchemaName: f,
184
+ selectedSchemaName: h,
174
185
  selectedDatamodelId: u,
175
186
  selectedDatabaseName: v,
176
187
  selectedTableName: y,
177
188
  selectedConnectionId: b
178
- } = z.getState(), x = i.sql, w = (F = r == null ? void 0 : r.getState()) == null ? void 0 : F.settings, S = bt(i, {
189
+ } = U.getState(), x = i.sql, D = (V = a == null ? void 0 : a.getState()) == null ? void 0 : V.settings, k = bt(i, {
179
190
  isDevMode: c,
180
191
  cardSql: x,
181
192
  isShowingVisual: m,
182
- selectedSchemaName: f,
193
+ selectedSchemaName: h,
183
194
  selectedDatamodelId: u,
184
195
  selectedDatabaseName: v,
185
196
  selectedTableName: y,
186
197
  selectedConnectionId: b,
187
- remoteChartSettings: w,
188
- stripConfig: ia
189
- }), N = n.cards.map(
190
- (j) => j.id === i.id ? S : j
198
+ remoteChartSettings: D,
199
+ stripConfig: ir
200
+ }), N = s.cards.map(
201
+ (j) => j.id === i.id ? k : j
191
202
  );
192
203
  return {
193
- ...n,
204
+ ...s,
194
205
  cards: N,
195
- activeCardId: la(N, n.activeCardId)
206
+ activeCardId: lr(N, s.activeCardId)
196
207
  };
197
- }, [r]) };
208
+ }, [a]) };
198
209
  }
199
- function Ae() {
200
- const { authToken: t, tokenProps: r } = qt(), l = ce(), n = Mt(), i = _e(), { selectVisual: c } = Ot(), {
210
+ function Le() {
211
+ const { authToken: t, tokenProps: a } = qt(), o = ce(), s = Mt(), i = Ae(), { selectVisual: c } = Ot(), {
201
212
  setFrame: m,
202
- setCard: f,
213
+ setCard: h,
203
214
  setIsDevMode: u,
204
215
  initializeModeDrafts: v,
205
216
  setActiveTabCardId: y,
206
217
  updateDataSource: b,
207
218
  setQueryResultColumns: x,
208
- setSelectedConnectionId: w,
209
- setSelectedDatabaseName: S,
219
+ setSelectedConnectionId: D,
220
+ setSelectedDatabaseName: k,
210
221
  setSelectedSchemaName: N,
211
- setSelectedTableName: F,
222
+ setSelectedTableName: V,
212
223
  setSelectedDatamodelId: j,
213
- setFilterValues: H,
214
- setInlineFilterValuesMap: Z,
215
- setApplyFilters: G,
216
- clearEditorContext: re
224
+ setFilterValues: K,
225
+ setInlineFilterValuesMap: R,
226
+ setApplyFilters: $,
227
+ clearEditorContext: Z
217
228
  } = de(), {
218
- setIsDashboardEditing: M,
219
- setIsVisualEditing: s,
220
- setSelectedFrameId: D,
221
- clearSelectedFrameId: V
222
- } = Te(), O = J((_) => _.selectedSheetId), P = J((_) => _.selectedFrameId), X = J((_) => _.dashboard), ee = J((_) => _.filterValues), A = J(
229
+ setIsDashboardEditing: E,
230
+ setIsVisualEditing: n,
231
+ setSelectedFrameId: w,
232
+ clearSelectedFrameId: P
233
+ } = _e(), M = J((_) => _.selectedSheetId), Y = J((_) => _.selectedFrameId), G = J((_) => _.dashboard), ee = J((_) => _.filterValues), q = J(
223
234
  (_) => _.inlineFilterValuesMap
224
- ), Q = Ut((i == null ? void 0 : i.id) || "", {
235
+ ), X = Ut((i == null ? void 0 : i.id) || "", {
225
236
  enabled: !!(i != null && i.id) && !!(t != null && t.accessToken)
226
- }), Y = B(
237
+ }), ae = z(
227
238
  async (_) => {
228
239
  try {
229
- c(_), V(), re();
230
- const { data: E, fromCache: W } = await Ye(
231
- r.apiServiceUrl,
240
+ c(_), P(), Z();
241
+ const { data: F, fromCache: W } = await Ye(
242
+ a.apiServiceUrl,
232
243
  (t == null ? void 0 : t.accessToken) || "",
233
244
  _.id,
234
- l,
245
+ o,
235
246
  "Opening library visual..."
236
247
  );
237
- if (!da(E, {
248
+ if (!dr(F, {
238
249
  setFrame: m,
239
- setCard: f,
250
+ setCard: h,
240
251
  setIsDevMode: u,
241
252
  initializeModeDrafts: v,
242
253
  setActiveTabCardId: y,
243
254
  updateDataSource: b,
244
255
  setQueryResultColumns: x,
245
- setSelectedConnectionId: w,
246
- setSelectedDatabaseName: S,
256
+ setSelectedConnectionId: D,
257
+ setSelectedDatabaseName: k,
247
258
  setSelectedSchemaName: N,
248
- setSelectedTableName: F,
259
+ setSelectedTableName: V,
249
260
  setSelectedDatamodelId: j,
250
- setFilterValues: H,
251
- setInlineFilterValuesMap: Z,
252
- setApplyFilters: G,
253
- setIsDashboardEditing: M,
254
- setIsVisualEditing: s,
255
- dashboard: X,
256
- selectedSheetId: O,
257
- selectedFrameId: P,
261
+ setFilterValues: K,
262
+ setInlineFilterValuesMap: R,
263
+ setApplyFilters: $,
264
+ setIsDashboardEditing: E,
265
+ setIsVisualEditing: n,
266
+ dashboard: G,
267
+ selectedSheetId: M,
268
+ selectedFrameId: Y,
258
269
  filterValues: ee,
259
- inlineFilterValuesMap: A
270
+ inlineFilterValuesMap: q
260
271
  }))
261
272
  throw new Error("Failed to setup editor with visual data");
262
273
  return { success: !0, fromCache: W };
263
- } catch (E) {
264
- return console.error("Error editing visual:", E), { success: !1, error: "Failed to load visual for editing" };
274
+ } catch (F) {
275
+ return console.error("Error editing visual:", F), { success: !1, error: "Failed to load visual for editing" };
265
276
  }
266
277
  },
267
278
  [
268
279
  t == null ? void 0 : t.accessToken,
269
- r.apiServiceUrl,
270
- l,
280
+ a.apiServiceUrl,
281
+ o,
271
282
  c,
272
283
  m,
273
- f,
274
- M,
275
- s,
284
+ h,
285
+ E,
286
+ n,
276
287
  u,
277
288
  v,
278
289
  y,
279
290
  b,
280
291
  x,
281
- w,
282
- S,
292
+ D,
293
+ k,
283
294
  N,
284
- F,
295
+ V,
285
296
  j,
286
- H,
297
+ K,
298
+ R,
299
+ $,
287
300
  Z,
288
- G,
289
- re,
290
- V,
291
- X,
292
- O,
293
301
  P,
302
+ G,
303
+ M,
304
+ Y,
294
305
  ee,
295
- A
306
+ q
296
307
  ]
297
- ), be = B(
308
+ ), be = z(
298
309
  async (_) => {
299
310
  var W;
300
- const E = (L) => (R.error(L), { success: !1, error: L });
311
+ const F = (A) => (B.error(A), { success: !1, error: A });
301
312
  try {
302
- if (c(_), !O)
303
- return E("No sheet selected. Please select a sheet first.");
304
- const { data: L, fromCache: ge } = await Ye(
305
- r.apiServiceUrl,
313
+ if (c(_), !M)
314
+ return F("No sheet selected. Please select a sheet first.");
315
+ const { data: A, fromCache: ge } = await Ye(
316
+ a.apiServiceUrl,
306
317
  (t == null ? void 0 : t.accessToken) || "",
307
318
  _.id,
308
- l,
319
+ o,
309
320
  "Adding visual to dashboard..."
310
- ), ue = (L == null ? void 0 : L.frameObject) ?? ((W = L == null ? void 0 : L.visual) == null ? void 0 : W.frameObject);
321
+ ), ue = (A == null ? void 0 : A.frameObject) ?? ((W = A == null ? void 0 : A.visual) == null ? void 0 : W.frameObject);
311
322
  if (!ue)
312
- return E("Visual has no frame data");
313
- const $ = pt(ue);
314
- if (!($ != null && $.cards) || $.cards.length === 0)
315
- return E("Visual frame is malformed");
323
+ return F("Visual has no frame data");
324
+ const Q = pt(ue);
325
+ if (!(Q != null && Q.cards) || Q.cards.length === 0)
326
+ return F("Visual frame is malformed");
316
327
  const le = {
317
- ...zt($),
328
+ ...zt(Q),
318
329
  visualId: _.id
319
330
  // Link this frame to the library visual
320
331
  };
321
- return await n(
322
- O,
332
+ return await s(
333
+ M,
323
334
  le,
324
335
  "end"
325
- ), M(!0), D(le.id), { success: !0, fromCache: ge };
326
- } catch (L) {
327
- return console.error("Error adding visual:", L), E(
328
- L instanceof Error ? L.message : "Failed to add visual to dashboard"
336
+ ), E(!0), w(le.id), { success: !0, fromCache: ge };
337
+ } catch (A) {
338
+ return console.error("Error adding visual:", A), F(
339
+ A instanceof Error ? A.message : "Failed to add visual to dashboard"
329
340
  );
330
341
  }
331
342
  },
332
343
  [
333
344
  t == null ? void 0 : t.accessToken,
334
- r.apiServiceUrl,
335
- l,
345
+ a.apiServiceUrl,
346
+ o,
336
347
  c,
337
- O,
338
348
  M,
339
- D,
340
- n
349
+ E,
350
+ w,
351
+ s
341
352
  ]
342
353
  );
343
354
  return {
344
- visual: Q.data,
345
- isLoading: Q.isLoading,
346
- isError: Q.isError,
347
- error: Q.error,
348
- handleEditLibraryVisual: Y,
355
+ visual: X.data,
356
+ isLoading: X.isLoading,
357
+ isError: X.isError,
358
+ error: X.error,
359
+ handleEditLibraryVisual: ae,
349
360
  handleAddLibraryVisual: be,
350
- getUpdatedFrame: ca().getUpdatedFrame,
351
- refetch: Q.refetch
361
+ getUpdatedFrame: cr().getUpdatedFrame,
362
+ refetch: X.refetch
352
363
  };
353
364
  }
354
- function wa() {
355
- const t = z((m) => m.card.dataSource), {
356
- setSelectedConnectionId: r,
357
- setSelectedDatabaseName: l,
358
- setSelectedSchemaName: n,
365
+ function Er() {
366
+ const t = U((m) => m.card.dataSource), {
367
+ setSelectedConnectionId: a,
368
+ setSelectedDatabaseName: o,
369
+ setSelectedSchemaName: s,
359
370
  setSelectedTableName: i,
360
371
  setSelectedDatamodelId: c
361
372
  } = de();
362
373
  ie(() => {
363
- var w;
374
+ var D;
364
375
  if (!t) return;
365
- const { tableName: m, schemaName: f, databaseName: u, connectionId: v } = jt(t), y = (w = t.selectedEntities) == null ? void 0 : w[0], x = (y == null ? void 0 : y.type) === "model" && "id" in y ? y.id : "";
366
- r(v || ""), l(u || ""), n(f || ""), i(m || ""), c(x);
376
+ const { tableName: m, schemaName: h, databaseName: u, connectionId: v } = Rt(t), y = (D = t.selectedEntities) == null ? void 0 : D[0], x = (y == null ? void 0 : y.type) === "model" && "id" in y ? y.id : "";
377
+ a(v || ""), o(u || ""), s(h || ""), i(m || ""), c(x);
367
378
  }, [
368
379
  t,
369
- r,
370
- l,
371
- n,
380
+ a,
381
+ o,
382
+ s,
372
383
  i,
373
384
  c
374
385
  ]);
375
386
  }
376
- function Da({
387
+ function ur(t, a) {
388
+ return {
389
+ ...t,
390
+ sql: "",
391
+ python: "",
392
+ config: void 0,
393
+ customCfg: "",
394
+ preferences: {},
395
+ interactionConfig: void 0,
396
+ linkedInteractionTargetOverrides: void 0,
397
+ dynamicCardPreferences: void 0,
398
+ customCardPreferences: a ? t.customCardPreferences : void 0,
399
+ visualizationMode: "builtin",
400
+ type: a ? t.type : "bar"
401
+ };
402
+ }
403
+ function pr() {
404
+ const { setTempQueryData: t } = de(), a = ce(), o = U((R) => R.tempQueryData), s = U((R) => R.card), i = ot(), c = oe(() => i !== s.type ? { ...s, type: i } : s, [s, i]), { queryKey: m } = lt(c), {
405
+ setCardSql: h,
406
+ setSqlGen: u,
407
+ setCardPython: v,
408
+ setCardCustomCfg: y,
409
+ setCardPreferences: b,
410
+ clearQueryConfig: x,
411
+ setCardConfig: D,
412
+ setCardType: k,
413
+ setFrame: N,
414
+ setCard: V,
415
+ setActiveTabCardId: j
416
+ } = de();
417
+ function K() {
418
+ var P, M, Y, G;
419
+ const R = a.getQueryData(m);
420
+ o != null && o.queryData || t({
421
+ queryKey: m,
422
+ queryData: R
423
+ }), a.setQueryData(m, null), a.removeQueries({ queryKey: m, exact: !0 }), h(""), u({}), x(), D(void 0), v(""), y(""), b({});
424
+ const $ = U.getState().frame, Z = U.getState().card, E = Qt($, Z), n = ((P = E == null ? void 0 : E.customCardPreferences) == null ? void 0 : P.visualType) === "multiple" || !!((M = E == null ? void 0 : E.customCardPreferences) != null && M.dataInputCardIds) || (((Y = E == null ? void 0 : E.customCardPreferences) == null ? void 0 : Y.minInputs) || 0) > 1 || (((G = E == null ? void 0 : E.customCardPreferences) == null ? void 0 : G.maxInputs) || 0) > 1, w = ur(Z, n);
425
+ N({
426
+ ...$,
427
+ cards: $.cards.map(
428
+ (ee) => ee.id === w.id ? w : ee
429
+ )
430
+ }), j(w.id), V(w), n || k("bar");
431
+ }
432
+ return K;
433
+ }
434
+ function Fr({
377
435
  type: t,
378
- isLinked: r,
379
- className: l,
380
- showLabel: n = !1,
436
+ isLinked: a,
437
+ className: o,
438
+ showLabel: s = !1,
381
439
  showLocal: i = !1
382
440
  }) {
383
- const c = J((N) => N.selectedFrameId), m = Qt((N) => N.selectedVisual), f = z((N) => N.frame);
441
+ const c = J((N) => N.selectedFrameId), m = $t((N) => N.selectedVisual), h = U((N) => N.frame);
384
442
  let u;
385
443
  if (t)
386
444
  u = t;
387
- else if (r !== void 0)
388
- u = r ? "linked" : "library";
389
- else if (!!!(f != null && f.visualId || m != null && m.id) && c)
445
+ else if (a !== void 0)
446
+ u = a ? "linked" : "library";
447
+ else if (!!!(h != null && h.visualId || m != null && m.id) && c)
390
448
  u = "local";
391
449
  else if (m && !c)
392
450
  u = "library";
393
- else if (f != null && f.visualId && c)
451
+ else if (h != null && h.visualId && c)
394
452
  u = "linked";
395
453
  else if (m != null && m.id && c)
396
454
  u = "library";
@@ -414,28 +472,28 @@ function Da({
414
472
  local: "fill-slate-50 dark:fill-slate-900",
415
473
  linked: "fill-purple-50 dark:fill-purple-950",
416
474
  library: "fill-blue-50 dark:fill-blue-950"
417
- }, w = {
418
- local: /* @__PURE__ */ a("span", { className: "h-2 w-2 rounded-full bg-current/70" }),
419
- linked: /* @__PURE__ */ a(na, { className: "h-3.5 w-3.5" }),
420
- library: /* @__PURE__ */ a(sa, { className: "h-3.5 w-3.5" })
421
- }, S = {
475
+ }, D = {
476
+ local: /* @__PURE__ */ r("span", { className: "h-2 w-2 rounded-full bg-current/70" }),
477
+ linked: /* @__PURE__ */ r(nr, { className: "h-3.5 w-3.5" }),
478
+ library: /* @__PURE__ */ r(sr, { className: "h-3.5 w-3.5" })
479
+ }, k = {
422
480
  local: "Local",
423
481
  linked: "Linked",
424
482
  library: "Library"
425
483
  };
426
- return /* @__PURE__ */ a(gt, { children: /* @__PURE__ */ p(yt, { delayDuration: 300, children: [
427
- /* @__PURE__ */ a(vt, { asChild: !0, children: /* @__PURE__ */ p(
428
- $t,
484
+ return /* @__PURE__ */ r(gt, { children: /* @__PURE__ */ p(yt, { delayDuration: 300, children: [
485
+ /* @__PURE__ */ r(vt, { asChild: !0, children: /* @__PURE__ */ p(
486
+ Pt,
429
487
  {
430
488
  variant: "outline",
431
489
  className: fe(
432
490
  "cursor-help select-none transition-all",
433
491
  v[u],
434
- l
492
+ o
435
493
  ),
436
494
  children: [
437
- w[u],
438
- n && /* @__PURE__ */ a("span", { className: "ml-1 text-xs font-medium leading-none", children: S[u] })
495
+ D[u],
496
+ s && /* @__PURE__ */ r("span", { className: "ml-1 text-xs font-medium leading-none", children: k[u] })
439
497
  ]
440
498
  }
441
499
  ) }),
@@ -445,327 +503,101 @@ function Da({
445
503
  side: "bottom",
446
504
  className: fe("max-w-xs", b[u]),
447
505
  children: [
448
- /* @__PURE__ */ a(Ct, { className: x[u] }),
449
- /* @__PURE__ */ a("p", { children: y[u] })
506
+ /* @__PURE__ */ r(Ct, { className: x[u] }),
507
+ /* @__PURE__ */ r("p", { children: y[u] })
450
508
  ]
451
509
  }
452
510
  )
453
511
  ] }) });
454
512
  }
455
- function ua(t, r) {
456
- return {
457
- ...t,
458
- sql: "",
459
- python: "",
460
- config: void 0,
461
- customCfg: "",
462
- preferences: {},
463
- interactionConfig: void 0,
464
- linkedInteractionTargetOverrides: void 0,
465
- dynamicCardPreferences: void 0,
466
- customCardPreferences: r ? t.customCardPreferences : void 0,
467
- visualizationMode: "builtin",
468
- type: r ? t.type : "bar"
469
- };
470
- }
471
- function Le(t) {
472
- const r = Nt(t);
473
- return r ? (R.error(r), !1) : !0;
474
- }
475
- function Ea({
476
- className: t,
477
- variant: r = "outline"
478
- }) {
479
- const l = z((c) => c.onSave), { getUpdatedFrame: n } = Ae();
480
- function i() {
481
- const c = n();
482
- Le(c) && (l == null || l(c));
483
- }
484
- return /* @__PURE__ */ p(
485
- q,
486
- {
487
- onClick: i,
488
- className: t,
489
- size: "xs",
490
- variant: r,
491
- children: [
492
- /* @__PURE__ */ a(St, { className: "h-3.5 w-3.5" }),
493
- "Accept"
494
- ]
495
- }
496
- );
497
- }
498
- function Ia({
499
- className: t,
500
- variant: r = "default"
501
- }) {
502
- const l = ce(), [n, i] = K(!1), { setIsVisualEditing: c } = Te(), { getUpdatedFrame: m } = Ae(), f = _e(), u = z((b) => b.frame), v = ot();
503
- return /* @__PURE__ */ a(
504
- q,
505
- {
506
- onClick: () => {
507
- const b = m();
508
- if (!Le(b))
509
- return;
510
- const x = (u == null ? void 0 : u.visualId) || (f == null ? void 0 : f.id);
511
- if (!x) {
512
- R.error("No visual to save");
513
- return;
514
- }
515
- i(!0), v.mutate(
516
- {
517
- visualId: x,
518
- data: {
519
- frameObject: b
520
- }
521
- },
522
- {
523
- onSuccess: () => {
524
- i(!1), R.success("Visual updated successfully"), l.invalidateQueries({
525
- queryKey: ["resource-by-id", "visual", x],
526
- exact: !0
527
- });
528
- },
529
- onError: () => {
530
- i(!1), R.error("Failed to update visual");
531
- }
532
- }
533
- );
534
- },
535
- className: t,
536
- size: "xs",
537
- variant: r,
538
- children: n ? /* @__PURE__ */ p(ae, { children: [
539
- /* @__PURE__ */ a(Je, { className: "h-3.5 w-3.5 animate-spin" }),
540
- "Saving"
541
- ] }) : /* @__PURE__ */ p(ae, { children: [
542
- /* @__PURE__ */ a(ut, { className: "h-3.5 w-3.5" }),
543
- "Save to Library"
544
- ] })
545
- }
546
- );
547
- }
548
- function Fa({
549
- className: t
550
- }) {
551
- const r = ce(), [l, n] = K(!1), i = _e(), c = z((S) => S.frame), m = J((S) => S.selectedSheetId), f = J((S) => S.dashboard), { updateFrame: u, setIsVisualEditing: v } = Te(), { getUpdatedFrame: y } = Ae(), b = ot(), x = Pt();
552
- return /* @__PURE__ */ a(
553
- q,
554
- {
555
- onClick: async () => {
556
- if (!m) {
557
- R.error("No sheet selected");
558
- return;
559
- }
560
- const S = (c == null ? void 0 : c.visualId) || (i == null ? void 0 : i.id);
561
- if (!S) {
562
- R.error("No visual to update");
563
- return;
564
- }
565
- n(!0);
566
- try {
567
- const N = y();
568
- if (!Le(N)) {
569
- n(!1);
570
- return;
571
- }
572
- const F = {
573
- ...N,
574
- visualId: S
575
- // Keep the link to library visual
576
- }, j = kt(f, F.id), H = await x(F, {
577
- previousFrame: j
578
- });
579
- await b.mutateAsync({
580
- visualId: S,
581
- data: {
582
- frameObject: N
583
- }
584
- }), u(m, F, {
585
- semanticExecutionPayload: H
586
- }), r.invalidateQueries({ queryKey: ["visuals"] }), r.invalidateQueries({ queryKey: ["visual", S] }), R.success("Saved to library and applied locally"), setTimeout(() => {
587
- v(!1);
588
- }, 300);
589
- } catch (N) {
590
- console.error("Failed to save and apply:", N), R.error(
591
- N instanceof Error ? N.message : "Failed to save and apply changes"
592
- );
593
- } finally {
594
- n(!1);
595
- }
596
- },
597
- className: t,
598
- size: "xs",
599
- variant: "default",
600
- disabled: l,
601
- children: l ? /* @__PURE__ */ p(ae, { children: [
602
- /* @__PURE__ */ a(Je, { className: "h-3.5 w-3.5 animate-spin" }),
603
- "Saving..."
604
- ] }) : /* @__PURE__ */ p(ae, { children: [
605
- /* @__PURE__ */ a(ut, { className: "h-3.5 w-3.5" }),
606
- "Save & Apply"
607
- ] })
608
- }
609
- );
610
- }
611
- function Va({ className: t }) {
612
- const { setTempQueryData: r, setSqlGen: l } = de(), n = ce(), i = z((b) => b.tempQueryData), c = z((b) => b.onClose), m = z((b) => b.card), f = st(), u = oe(() => f !== m.type ? { ...m, type: f } : m, [m, f]), { queryKey: v } = nt(u);
613
- function y() {
614
- if (i) {
615
- const { queryKey: b, queryData: x } = i;
616
- b && x && n.setQueryData(b, x);
617
- }
618
- l({}), c == null || c();
619
- }
620
- return /* @__PURE__ */ p(
621
- q,
622
- {
623
- onClick: y,
624
- className: t,
625
- size: "xs",
626
- variant: "outline",
627
- children: [
628
- /* @__PURE__ */ a(ct, { className: "h-3.5 w-3.5" }),
629
- "Close"
630
- ]
631
- }
632
- );
633
- }
634
- function Ta({
635
- label: t = "Clear",
636
- variant: r = "secondary",
637
- className: l
638
- } = {}) {
639
- const { setTempQueryData: n } = de(), i = ce(), c = z((M) => M.tempQueryData), m = z((M) => M.card), f = st(), u = oe(() => f !== m.type ? { ...m, type: f } : m, [m, f]), { queryKey: v } = nt(u), {
640
- setCardSql: y,
641
- setSqlGen: b,
642
- setCardPython: x,
643
- setCardCustomCfg: w,
644
- setCardPreferences: S,
645
- clearQueryConfig: N,
646
- setCardConfig: F,
647
- setCardType: j,
648
- setFrame: H,
649
- setCard: Z,
650
- setActiveTabCardId: G
651
- } = de();
652
- function re() {
653
- var X, ee, A, Q;
654
- const M = i.getQueryData(v);
655
- c != null && c.queryData || n({
656
- queryKey: v,
657
- queryData: M
658
- }), i.setQueryData(v, null), i.removeQueries({ queryKey: v, exact: !0 }), y(""), b({}), N(), F(void 0), x(""), w(""), S({});
659
- const s = z.getState().frame, D = z.getState().card, V = Wt(s, D), O = ((X = V == null ? void 0 : V.customCardPreferences) == null ? void 0 : X.visualType) === "multiple" || !!((ee = V == null ? void 0 : V.customCardPreferences) != null && ee.dataInputCardIds) || (((A = V == null ? void 0 : V.customCardPreferences) == null ? void 0 : A.minInputs) || 0) > 1 || (((Q = V == null ? void 0 : V.customCardPreferences) == null ? void 0 : Q.maxInputs) || 0) > 1, P = ua(D, O);
660
- H({
661
- ...s,
662
- cards: s.cards.map(
663
- (Y) => Y.id === P.id ? P : Y
664
- )
665
- }), G(P.id), Z(P), O || j("bar");
666
- }
667
- return /* @__PURE__ */ p(
668
- q,
669
- {
670
- onClick: re,
671
- className: l,
672
- size: "xs",
673
- variant: r,
674
- children: [
675
- /* @__PURE__ */ a(ct, { className: "h-3.5 w-3.5" }),
676
- t
677
- ]
678
- }
679
- );
680
- }
681
513
  function mt(t) {
682
- const { control: r, onChange: l } = t;
514
+ const { control: a, onChange: o } = t;
683
515
  return /* @__PURE__ */ p("div", { className: "flex flex-col gap-1.5", children: [
684
- /* @__PURE__ */ a(ne, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Label" }),
685
- /* @__PURE__ */ a(
516
+ /* @__PURE__ */ r(ne, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Label" }),
517
+ /* @__PURE__ */ r(
686
518
  at,
687
519
  {
688
520
  size: "xs",
689
- value: r.label,
521
+ value: a.label,
690
522
  placeholder: "Control label",
691
- onChange: (n) => l(n.target.value)
523
+ onChange: (s) => o(s.target.value)
692
524
  }
693
525
  )
694
526
  ] });
695
527
  }
696
- function pa(t) {
697
- const { currentStep: r, labels: l } = t;
698
- return /* @__PURE__ */ a("div", { className: "sticky top-0 z-10 -mx-1 border-b border-border/60 bg-background/95 px-1 pb-2.5 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85", children: /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2 sm:gap-2.5", children: l.map((n, i) => {
699
- const c = i + 1, m = c === r, f = c < r;
528
+ function mr(t) {
529
+ const { currentStep: a, labels: o } = t;
530
+ return /* @__PURE__ */ r("div", { className: "sticky top-0 z-10 -mx-1 border-b border-border/60 bg-background/95 px-1 pb-2.5 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85", children: /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2 sm:gap-2.5", children: o.map((s, i) => {
531
+ const c = i + 1, m = c === a, h = c < a;
700
532
  return /* @__PURE__ */ p(ht, { children: [
701
533
  /* @__PURE__ */ p("div", { className: "flex items-center gap-1.5", children: [
702
- /* @__PURE__ */ a(
534
+ /* @__PURE__ */ r(
703
535
  "span",
704
536
  {
705
537
  className: fe(
706
538
  "flex h-5 w-5 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",
707
- m ? "border-foreground bg-foreground text-background" : f ? "border-foreground/30 bg-foreground/10 text-foreground" : "border-border/60 bg-background text-muted-foreground"
539
+ m ? "border-foreground bg-foreground text-background" : h ? "border-foreground/30 bg-foreground/10 text-foreground" : "border-border/60 bg-background text-muted-foreground"
708
540
  ),
709
541
  children: c
710
542
  }
711
543
  ),
712
- /* @__PURE__ */ a(
544
+ /* @__PURE__ */ r(
713
545
  "span",
714
546
  {
715
547
  className: fe(
716
548
  "text-[12px]",
717
549
  m ? "font-medium text-foreground" : "text-muted-foreground"
718
550
  ),
719
- children: n
551
+ children: s
720
552
  }
721
553
  )
722
554
  ] }),
723
- i < l.length - 1 ? /* @__PURE__ */ a(
555
+ i < o.length - 1 ? /* @__PURE__ */ r(
724
556
  "span",
725
557
  {
726
558
  className: "h-px w-4 bg-border/60 sm:w-6",
727
559
  "aria-hidden": "true"
728
560
  }
729
561
  ) : null
730
- ] }, n);
562
+ ] }, s);
731
563
  }) }) });
732
564
  }
733
565
  function he(t) {
734
- const { secondary: r, tertiary: l, primary: n } = t;
566
+ const { secondary: a, tertiary: o, primary: s } = t;
735
567
  return /* @__PURE__ */ p("div", { className: "sticky bottom-0 z-10 -mx-1 flex justify-end gap-2 border-t bg-background/95 px-1 pb-1 pt-3 backdrop-blur supports-[backdrop-filter]:bg-background/85", children: [
736
- r,
737
- l,
738
- n
568
+ a,
569
+ o,
570
+ s
739
571
  ] });
740
572
  }
741
- function ma(t) {
742
- const { control: r, scope: l, detail: n } = t;
573
+ function fr(t) {
574
+ const { control: a, scope: o, detail: s } = t;
743
575
  return /* @__PURE__ */ p("div", { className: "flex items-start gap-2.5 rounded-control border border-border/60 bg-muted/30 px-3 py-2.5", children: [
744
- /* @__PURE__ */ a(ra, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground" }),
576
+ /* @__PURE__ */ r(rr, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground" }),
745
577
  /* @__PURE__ */ p("div", { className: "min-w-0 space-y-0.5", children: [
746
- /* @__PURE__ */ a("div", { className: "text-[13px] font-medium text-foreground", children: r.label }),
578
+ /* @__PURE__ */ r("div", { className: "text-[13px] font-medium text-foreground", children: a.label }),
747
579
  /* @__PURE__ */ p("div", { className: "text-[12px] text-muted-foreground", children: [
748
- Ze(r.type).label,
580
+ et(a.type).label,
749
581
  " ·",
750
582
  " ",
751
- tt(r),
583
+ rt(a),
752
584
  " ·",
753
585
  " ",
754
- et(l, r.placement)
586
+ tt(o, a.placement)
755
587
  ] }),
756
- n ? /* @__PURE__ */ a("div", { className: "text-[12px] text-muted-foreground", children: n }) : null
588
+ s ? /* @__PURE__ */ r("div", { className: "text-[12px] text-muted-foreground", children: s }) : null
757
589
  ] })
758
590
  ] });
759
591
  }
760
- function He(t) {
592
+ function Ge(t) {
761
593
  const {
762
- control: r,
763
- defaultValue: l,
764
- availableFieldChoices: n,
594
+ control: a,
595
+ defaultValue: o,
596
+ availableFieldChoices: s,
765
597
  availableMetricChoices: i,
766
598
  previewControlDefinitions: c,
767
599
  previewControlValues: m,
768
- onControlChange: f,
600
+ onControlChange: h,
769
601
  onLabelChange: u,
770
602
  onDefaultValueChange: v,
771
603
  onBack: y,
@@ -773,24 +605,24 @@ function He(t) {
773
605
  nextDisabled: x
774
606
  } = t;
775
607
  return /* @__PURE__ */ p("div", { className: "space-y-3", children: [
776
- /* @__PURE__ */ a(mt, { control: r, onChange: u }),
777
- /* @__PURE__ */ a(
778
- lt,
608
+ /* @__PURE__ */ r(mt, { control: a, onChange: u }),
609
+ /* @__PURE__ */ r(
610
+ it,
779
611
  {
780
- control: r,
781
- availableFieldChoices: n,
612
+ control: a,
613
+ availableFieldChoices: s,
782
614
  availableMetricChoices: i,
783
615
  previewControlDefinitions: c,
784
616
  previewControlValues: m,
785
617
  controlLifecycle: "create",
786
- onChange: f
618
+ onChange: h
787
619
  }
788
620
  ),
789
- /* @__PURE__ */ a(
790
- it,
621
+ /* @__PURE__ */ r(
622
+ dt,
791
623
  {
792
- control: r,
793
- value: l,
624
+ control: a,
625
+ value: o,
794
626
  onChange: v,
795
627
  allowNoDefault: !0,
796
628
  allowCardDefault: !0,
@@ -799,12 +631,12 @@ function He(t) {
799
631
  previewControlValues: m
800
632
  }
801
633
  ),
802
- /* @__PURE__ */ a(
634
+ /* @__PURE__ */ r(
803
635
  he,
804
636
  {
805
- secondary: /* @__PURE__ */ a(q, { type: "button", variant: "outline", size: "xs", onClick: y, children: "Back" }),
806
- primary: /* @__PURE__ */ a(
807
- q,
637
+ secondary: /* @__PURE__ */ r(L, { type: "button", variant: "outline", size: "xs", onClick: y, children: "Back" }),
638
+ primary: /* @__PURE__ */ r(
639
+ L,
808
640
  {
809
641
  type: "button",
810
642
  size: "xs",
@@ -817,73 +649,73 @@ function He(t) {
817
649
  )
818
650
  ] });
819
651
  }
820
- const fa = /* @__PURE__ */ new Set([
652
+ const hr = /* @__PURE__ */ new Set([
821
653
  "grain_selector",
822
654
  "aggregation_selector",
823
655
  "field_selector",
824
656
  "metric_selector"
825
657
  ]);
826
- function Ge(t) {
827
- const { text: r, ariaLabel: l } = t, [n, i] = K(!1);
658
+ function Xe(t) {
659
+ const { text: a, ariaLabel: o } = t, [s, i] = H(!1);
828
660
  return /* @__PURE__ */ p(
829
661
  "button",
830
662
  {
831
663
  type: "button",
832
- "aria-label": l,
664
+ "aria-label": o,
833
665
  onClick: async () => {
834
666
  try {
835
- await navigator.clipboard.writeText(r), i(!0), setTimeout(() => i(!1), 1200);
667
+ await navigator.clipboard.writeText(a), i(!0), setTimeout(() => i(!1), 1200);
836
668
  } catch (c) {
837
669
  console.error("Failed to copy", c);
838
670
  }
839
671
  },
840
672
  className: "group flex w-full items-center justify-between gap-2 rounded-control bg-muted/40 px-2 py-1 text-left transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none",
841
673
  children: [
842
- /* @__PURE__ */ a("code", { className: "min-w-0 truncate font-mono text-[12px] text-foreground", children: r }),
843
- /* @__PURE__ */ a("span", { className: "shrink-0 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100", children: n ? "Copied" : "Click to copy" })
674
+ /* @__PURE__ */ r("code", { className: "min-w-0 truncate font-mono text-[12px] text-foreground", children: a }),
675
+ /* @__PURE__ */ r("span", { className: "shrink-0 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100", children: s ? "Copied" : "Click to copy" })
844
676
  ]
845
677
  }
846
678
  );
847
679
  }
848
- function Xe(t) {
680
+ function Je(t) {
849
681
  const {
850
- control: r,
851
- scope: l,
852
- createdReference: n,
682
+ control: a,
683
+ scope: o,
684
+ createdReference: s,
853
685
  explorerContent: i,
854
686
  sqlDescription: c,
855
687
  summaryDetail: m,
856
- onBack: f,
688
+ onBack: h,
857
689
  onCancel: u,
858
690
  onDone: v
859
- } = t, y = fa.has(r.type), b = n.match(/\[\[param\.(.+?)\]\]/), x = b ? `{{ param('${b[1]}') }}` : "";
691
+ } = t, y = hr.has(a.type), b = s.match(/\[\[param\.(.+?)\]\]/), x = b ? `{{ param('${b[1]}') }}` : "";
860
692
  return /* @__PURE__ */ p("div", { className: "space-y-4", children: [
861
- /* @__PURE__ */ a(
862
- ma,
693
+ /* @__PURE__ */ r(
694
+ fr,
863
695
  {
864
- control: r,
865
- scope: l,
696
+ control: a,
697
+ scope: o,
866
698
  detail: m
867
699
  }
868
700
  ),
869
701
  /* @__PURE__ */ p("div", { className: "space-y-2", children: [
870
- /* @__PURE__ */ a("p", { className: "text-[13px] font-medium text-foreground", children: "How cards use this control" }),
702
+ /* @__PURE__ */ r("p", { className: "text-[13px] font-medium text-foreground", children: "How cards use this control" }),
871
703
  /* @__PURE__ */ p("div", { className: "divide-y divide-border/60 overflow-hidden rounded-control border border-border/60", children: [
872
704
  y ? /* @__PURE__ */ p("div", { className: "space-y-1 px-3 py-2.5", children: [
873
- /* @__PURE__ */ a("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Explorer cards" }),
874
- /* @__PURE__ */ a("div", { className: "text-[12px] text-muted-foreground", children: i })
705
+ /* @__PURE__ */ r("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Explorer cards" }),
706
+ /* @__PURE__ */ r("div", { className: "text-[12px] text-muted-foreground", children: i })
875
707
  ] }) : null,
876
708
  /* @__PURE__ */ p("div", { className: "space-y-1.5 px-3 py-2.5", children: [
877
- /* @__PURE__ */ a("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "SQL cards" }),
878
- /* @__PURE__ */ a(
879
- Ge,
709
+ /* @__PURE__ */ r("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "SQL cards" }),
710
+ /* @__PURE__ */ r(
711
+ Xe,
880
712
  {
881
- text: n,
713
+ text: s,
882
714
  ariaLabel: "Copy SQL control reference"
883
715
  }
884
716
  ),
885
- x ? /* @__PURE__ */ a(
886
- Ge,
717
+ x ? /* @__PURE__ */ r(
718
+ Xe,
887
719
  {
888
720
  text: x,
889
721
  ariaLabel: "Copy Jinja control reference"
@@ -892,7 +724,7 @@ function Xe(t) {
892
724
  /* @__PURE__ */ p("p", { className: "text-[12px] text-muted-foreground", children: [
893
725
  c,
894
726
  " ",
895
- /* @__PURE__ */ a(
727
+ /* @__PURE__ */ r(
896
728
  "a",
897
729
  {
898
730
  href: "https://docs.semaphor.cloud/docs/concepts/template-expressions",
@@ -907,145 +739,145 @@ function Xe(t) {
907
739
  ] })
908
740
  ] })
909
741
  ] }),
910
- /* @__PURE__ */ a(
742
+ /* @__PURE__ */ r(
911
743
  he,
912
744
  {
913
- secondary: /* @__PURE__ */ a(q, { type: "button", variant: "outline", size: "xs", onClick: f, children: "Back" }),
914
- tertiary: /* @__PURE__ */ a(q, { type: "button", variant: "outline", size: "xs", onClick: u, children: "Cancel" }),
915
- primary: /* @__PURE__ */ a(q, { type: "button", size: "xs", onClick: v, children: "Done" })
745
+ secondary: /* @__PURE__ */ r(L, { type: "button", variant: "outline", size: "xs", onClick: h, children: "Back" }),
746
+ tertiary: /* @__PURE__ */ r(L, { type: "button", variant: "outline", size: "xs", onClick: u, children: "Cancel" }),
747
+ primary: /* @__PURE__ */ r(L, { type: "button", size: "xs", onClick: v, children: "Done" })
916
748
  }
917
749
  )
918
750
  ] });
919
751
  }
920
- function ha(t) {
921
- const r = pe(
752
+ function br(t) {
753
+ const a = pe(
922
754
  t.scope,
923
755
  t.existingControls,
924
756
  t.reservedIds
925
- ), l = t.type === r.type ? {
926
- ...r,
757
+ ), o = t.type === a.type ? {
758
+ ...a,
927
759
  label: Ve[t.type]
928
760
  } : {
929
- ...rt({
761
+ ...st({
930
762
  controls: [
931
763
  {
932
- ...r,
764
+ ...a,
933
765
  label: Ve[t.type]
934
766
  }
935
767
  ],
936
- controlId: r.id,
768
+ controlId: a.id,
937
769
  nextType: t.type
938
770
  }).controls[0],
939
771
  label: Ve[t.type]
940
772
  };
941
773
  return {
942
774
  step: 2,
943
- control: l,
944
- defaultValue: me(l, void 0)
775
+ control: o,
776
+ defaultValue: me(o, void 0)
945
777
  };
946
778
  }
947
- function _a({
779
+ function Ir({
948
780
  scope: t,
949
- controls: r,
950
- reservedControlIds: l,
951
- defaultValues: n,
781
+ controls: a,
782
+ reservedControlIds: o,
783
+ defaultValues: s,
952
784
  onChange: i,
953
785
  emptyMessage: c,
954
786
  initialCreateFlow: m = !1,
955
- usageByControlId: f,
787
+ usageByControlId: h,
956
788
  availableFieldChoices: u,
957
789
  availableMetricChoices: v,
958
790
  structuralParticipants: y,
959
791
  structuralParticipantIdsByControlId: b,
960
792
  card: x,
961
- allowedControlTypes: w,
962
- onCreateFlowActiveChange: S,
793
+ allowedControlTypes: D,
794
+ onCreateFlowActiveChange: k,
963
795
  onCreateFlowComplete: N
964
796
  }) {
965
- const F = oe(
966
- () => new Set(l || []),
967
- [l]
968
- ), j = _t(t), H = wt(t), [Z, G] = K(
797
+ const V = oe(
798
+ () => new Set(o || []),
799
+ [o]
800
+ ), j = It(t), K = kt(t), [R, $] = H(
969
801
  null
970
- ), [re, M] = K(
802
+ ), [Z, E] = H(
971
803
  null
972
- ), [s, D] = K(
804
+ ), [n, w] = H(
973
805
  () => m ? {
974
806
  step: 1,
975
- control: pe(t, r, Array.from(F))
807
+ control: pe(t, a, Array.from(V))
976
808
  } : null
977
- ), V = Se({}), O = Se(void 0), P = Se(m), X = oe(() => {
978
- const e = Be({ scope: t, card: x });
979
- if (!w)
809
+ ), P = ke({}), M = ke(void 0), Y = ke(m), G = oe(() => {
810
+ const e = Re({ scope: t, card: x });
811
+ if (!D)
980
812
  return e;
981
- const d = new Set(w);
982
- return e.filter((o) => d.has(o.value));
983
- }, [w, x, t]), ee = B(
813
+ const d = new Set(D);
814
+ return e.filter((l) => d.has(l.value));
815
+ }, [D, x, t]), ee = z(
984
816
  (e) => {
985
- const d = Be({
817
+ const d = Re({
986
818
  scope: t,
987
819
  card: x,
988
- includeType: w ? void 0 : e
820
+ includeType: D ? void 0 : e
989
821
  });
990
- if (!w)
822
+ if (!D)
991
823
  return d;
992
- const o = new Set(w);
993
- return d.filter((h) => o.has(h.value));
824
+ const l = new Set(D);
825
+ return d.filter((f) => l.has(f.value));
994
826
  },
995
- [w, x, t]
996
- ), A = B(
827
+ [D, x, t]
828
+ ), q = z(
997
829
  (e) => t === "dashboard" && (e === "field_selector" || e === "metric_selector"),
998
830
  [t]
999
- ), Q = oe(
1000
- () => s ? Re(
831
+ ), X = oe(
832
+ () => n ? Qe(
1001
833
  y || [],
1002
- s.control.type
834
+ n.control.type
1003
835
  ) : [],
1004
- [s, y]
1005
- ), Y = oe(() => {
1006
- if (!s)
836
+ [n, y]
837
+ ), ae = oe(() => {
838
+ if (!n)
1007
839
  return {
1008
840
  fields: u || [],
1009
841
  metrics: v || []
1010
842
  };
1011
- if (!A(s.control.type))
843
+ if (!q(n.control.type))
1012
844
  return {
1013
845
  fields: u || [],
1014
846
  metrics: v || []
1015
847
  };
1016
- const e = s.selectedCardIds || [], d = ke({
1017
- controlType: s.control.type,
848
+ const e = n.selectedCardIds || [], d = Se({
849
+ controlType: n.control.type,
1018
850
  participants: y || [],
1019
851
  selectedCardIds: e
1020
852
  });
1021
853
  return {
1022
- fields: s.control.type === "field_selector" ? d.choices.map((o) => ({
1023
- option: o,
1024
- target: d.fieldTargetMap[o.value]
854
+ fields: n.control.type === "field_selector" ? d.choices.map((l) => ({
855
+ option: l,
856
+ target: d.fieldTargetMap[l.value]
1025
857
  })) : [],
1026
- metrics: s.control.type === "metric_selector" ? d.choices.map((o) => ({
1027
- option: o,
1028
- target: d.metricTargetMap[o.value]
858
+ metrics: n.control.type === "metric_selector" ? d.choices.map((l) => ({
859
+ option: l,
860
+ target: d.metricTargetMap[l.value]
1029
861
  })) : []
1030
862
  };
1031
863
  }, [
1032
864
  u,
1033
865
  v,
1034
- s,
1035
- A,
866
+ n,
867
+ q,
1036
868
  y
1037
869
  ]);
1038
870
  ie(() => {
1039
- S == null || S(!!s);
1040
- }, [s, S]), ie(() => {
1041
- const e = m && !P.current;
1042
- P.current = m, e && (D({
871
+ k == null || k(!!n);
872
+ }, [n, k]), ie(() => {
873
+ const e = m && !Y.current;
874
+ Y.current = m, e && (w({
1043
875
  step: 1,
1044
- control: pe(t, r, Array.from(F))
1045
- }), M(null), G(null));
1046
- }, [r, m, F, t]);
876
+ control: pe(t, a, Array.from(V))
877
+ }), E(null), $(null));
878
+ }, [a, m, V, t]);
1047
879
  const be = (e) => {
1048
- if (!A(e.type))
880
+ if (!q(e.type))
1049
881
  return {
1050
882
  fields: u || [],
1051
883
  metrics: v || []
@@ -1056,281 +888,281 @@ function _a({
1056
888
  fields: u || [],
1057
889
  metrics: v || []
1058
890
  };
1059
- const o = ke({
891
+ const l = Se({
1060
892
  controlType: e.type,
1061
893
  participants: y || [],
1062
894
  selectedCardIds: d
1063
895
  });
1064
896
  return {
1065
- fields: e.type === "field_selector" ? o.choices.map((h) => ({
1066
- option: h,
1067
- target: o.fieldTargetMap[h.value]
897
+ fields: e.type === "field_selector" ? l.choices.map((f) => ({
898
+ option: f,
899
+ target: l.fieldTargetMap[f.value]
1068
900
  })) : [],
1069
- metrics: e.type === "metric_selector" ? o.choices.map((h) => ({
1070
- option: h,
1071
- target: o.metricTargetMap[h.value]
901
+ metrics: e.type === "metric_selector" ? l.choices.map((f) => ({
902
+ option: f,
903
+ target: l.metricTargetMap[f.value]
1072
904
  })) : []
1073
905
  };
1074
906
  }, _ = (e) => {
1075
- if (!A(e.control.type))
907
+ if (!q(e.control.type))
1076
908
  return {
1077
909
  nextControl: e.control,
1078
910
  cardBindingsById: void 0
1079
911
  };
1080
- const d = (b == null ? void 0 : b[e.control.id]) || [], o = ke({
912
+ const d = (b == null ? void 0 : b[e.control.id]) || [], l = Se({
1081
913
  controlType: e.control.type,
1082
914
  participants: y || [],
1083
915
  selectedCardIds: e.nextSelectedCardIds
1084
- }), h = At({
916
+ }), f = Vt({
1085
917
  control: e.control,
1086
- choices: o.choices
918
+ choices: l.choices
1087
919
  }), C = Object.fromEntries(
1088
- d.filter((k) => !e.nextSelectedCardIds.includes(k)).map((k) => [k, void 0])
920
+ d.filter((S) => !e.nextSelectedCardIds.includes(S)).map((S) => [S, void 0])
1089
921
  );
1090
- return e.nextSelectedCardIds.length > 0 && h.source.kind === "manual" && h.source.options.length > 0 && Object.assign(
922
+ return e.nextSelectedCardIds.length > 0 && f.source.kind === "manual" && f.source.options.length > 0 && Object.assign(
1091
923
  C,
1092
- Pe({
1093
- control: h,
924
+ He({
925
+ control: f,
1094
926
  participants: y || [],
1095
927
  selectedCardIds: e.nextSelectedCardIds
1096
928
  })
1097
929
  ), {
1098
- nextControl: h,
930
+ nextControl: f,
1099
931
  cardBindingsById: C
1100
932
  };
1101
- }, E = B(
1102
- (e, d = n, o = { type: "update" }) => {
1103
- const h = e.map((C) => (Ne({
933
+ }, F = z(
934
+ (e, d = s, l = { type: "update" }) => {
935
+ const f = e.map((C) => (Ne({
1104
936
  control: C,
1105
937
  defaultValues: d
1106
- }), Dt(
938
+ }), St(
1107
939
  C
1108
940
  )));
1109
- i(h, d, o);
941
+ i(f, d, l);
1110
942
  },
1111
- [n, i]
943
+ [s, i]
1112
944
  ), W = (e, d) => {
1113
- const o = r.find(
945
+ const l = a.find(
1114
946
  (T) => T.id === e
1115
947
  );
1116
- let h = r.map((T) => T.id !== e ? T : d(T));
1117
- const C = h.find(
948
+ let f = a.map((T) => T.id !== e ? T : d(T));
949
+ const C = f.find(
1118
950
  (T) => T.id === e
1119
951
  );
1120
- let k, g;
952
+ let S, g;
1121
953
  if (C && t === "dashboard" && (C.type === "field_selector" || C.type === "metric_selector")) {
1122
954
  const T = (b == null ? void 0 : b[C.id]) || [], se = _({
1123
955
  control: C,
1124
956
  nextSelectedCardIds: T
1125
957
  });
1126
- h = h.map(
958
+ f = f.map(
1127
959
  (te) => te.id === e ? se.nextControl : te
1128
- ), k = se.cardBindingsById, g = [C.id];
1129
- } else if (o && t === "dashboard" && (o.type === "field_selector" || o.type === "metric_selector")) {
1130
- const T = (b == null ? void 0 : b[o.id]) || [];
1131
- k = Object.fromEntries(
960
+ ), S = se.cardBindingsById, g = [C.id];
961
+ } else if (l && t === "dashboard" && (l.type === "field_selector" || l.type === "metric_selector")) {
962
+ const T = (b == null ? void 0 : b[l.id]) || [];
963
+ S = Object.fromEntries(
1132
964
  T.map((se) => [se, void 0])
1133
- ), g = [o.id];
965
+ ), g = [l.id];
1134
966
  }
1135
- const I = h.find(
967
+ const I = f.find(
1136
968
  (T) => T.id === e
1137
969
  );
1138
- let U = n;
1139
- if (o && I) {
970
+ let O = s;
971
+ if (l && I) {
1140
972
  const T = Ne({
1141
- control: o,
1142
- defaultValues: n
973
+ control: l,
974
+ defaultValues: s
1143
975
  });
1144
- o.source.kind === "manual" && I.source.kind === "sql_query" && (V.current[e] = T);
1145
- const se = T === void 0 && o.source.kind === "sql_query" && I.source.kind === "manual" ? V.current[e] : T, te = $e({
1146
- previousControl: o,
976
+ l.source.kind === "manual" && I.source.kind === "sql_query" && (P.current[e] = T);
977
+ const se = T === void 0 && l.source.kind === "sql_query" && I.source.kind === "manual" ? P.current[e] : T, te = We({
978
+ previousControl: l,
1147
979
  nextControl: I,
1148
980
  currentDefaultValue: se
1149
981
  });
1150
- I.source.kind === "manual" && (V.current[e] = te), n && (U = { ...n }, te === void 0 ? delete U[e] : U[e] = te), h = h.map(
1151
- (ze) => ze.id === e ? { ...I, defaultValue: te } : ze
982
+ I.source.kind === "manual" && (P.current[e] = te), s && (O = { ...s }, te === void 0 ? delete O[e] : O[e] = te), f = f.map(
983
+ (Be) => Be.id === e ? { ...I, defaultValue: te } : Be
1152
984
  );
1153
985
  }
1154
- E(h, U, {
986
+ F(f, O, {
1155
987
  type: "update",
1156
- cardBindingsById: k,
988
+ cardBindingsById: S,
1157
989
  affectedBindingControlIds: g
1158
990
  });
1159
- }, L = (e, d) => {
991
+ }, A = (e, d) => {
1160
992
  if (!d.trim())
1161
993
  return;
1162
- const o = aa(d);
1163
- if (o === e || F.has(o) || r.some(
1164
- (k) => k.id === o && k.id !== e
994
+ const l = tr(d);
995
+ if (l === e || V.has(l) || a.some(
996
+ (S) => S.id === l && S.id !== e
1165
997
  ))
1166
998
  return;
1167
- const h = r.map(
1168
- (k) => k.id === e ? { ...k, id: o } : k
999
+ const f = a.map(
1000
+ (S) => S.id === e ? { ...S, id: l } : S
1169
1001
  );
1170
- if (!n) {
1171
- E(h, void 0, {
1002
+ if (!s) {
1003
+ F(f, void 0, {
1172
1004
  type: "rename",
1173
1005
  oldId: e,
1174
- newId: o
1006
+ newId: l
1175
1007
  });
1176
1008
  return;
1177
1009
  }
1178
- const C = { ...n };
1179
- Object.prototype.hasOwnProperty.call(C, e) && (C[o] = C[e], delete C[e]), E(h, C, {
1010
+ const C = { ...s };
1011
+ Object.prototype.hasOwnProperty.call(C, e) && (C[l] = C[e], delete C[e]), F(f, C, {
1180
1012
  type: "rename",
1181
1013
  oldId: e,
1182
- newId: o
1014
+ newId: l
1183
1015
  });
1184
1016
  }, ge = (e) => {
1185
- const d = r.filter((h) => h.id !== e);
1186
- if (!n) {
1187
- E(d, void 0, { type: "remove", controlId: e });
1017
+ const d = a.filter((f) => f.id !== e);
1018
+ if (!s) {
1019
+ F(d, void 0, { type: "remove", controlId: e });
1188
1020
  return;
1189
1021
  }
1190
- const o = { ...n };
1191
- delete o[e], E(d, o, { type: "remove", controlId: e });
1192
- }, ue = B(() => {
1193
- O.current = void 0, D({
1022
+ const l = { ...s };
1023
+ delete l[e], F(d, l, { type: "remove", controlId: e });
1024
+ }, ue = z(() => {
1025
+ M.current = void 0, w({
1194
1026
  step: 1,
1195
- control: pe(t, r, Array.from(F))
1196
- }), M(null), G(null);
1197
- }, [r, F, t]), $ = (e) => {
1198
- D(
1027
+ control: pe(t, a, Array.from(V))
1028
+ }), E(null), $(null);
1029
+ }, [a, V, t]), Q = (e) => {
1030
+ w(
1199
1031
  (d) => d && (() => {
1200
- const o = e(d.control);
1201
- d.control.source.kind === "manual" && o.source.kind === "sql_query" && (O.current = d.defaultValue);
1202
- const h = d.defaultValue === void 0 && d.control.source.kind === "sql_query" && o.source.kind === "manual" ? O.current : d.defaultValue, C = $e({
1032
+ const l = e(d.control);
1033
+ d.control.source.kind === "manual" && l.source.kind === "sql_query" && (M.current = d.defaultValue);
1034
+ const f = d.defaultValue === void 0 && d.control.source.kind === "sql_query" && l.source.kind === "manual" ? M.current : d.defaultValue, C = We({
1203
1035
  previousControl: d.control,
1204
- nextControl: o,
1205
- currentDefaultValue: h
1036
+ nextControl: l,
1037
+ currentDefaultValue: f
1206
1038
  });
1207
- return o.source.kind === "manual" && (O.current = C), {
1039
+ return l.source.kind === "manual" && (M.current = C), {
1208
1040
  ...d,
1209
- control: o,
1041
+ control: l,
1210
1042
  defaultValue: C
1211
1043
  };
1212
1044
  })()
1213
1045
  );
1214
1046
  }, le = (e) => {
1215
- D(
1216
- (d) => d && (d.control.source.kind === "manual" && (O.current = e), {
1047
+ w(
1048
+ (d) => d && (d.control.source.kind === "manual" && (M.current = e), {
1217
1049
  ...d,
1218
1050
  defaultValue: e
1219
1051
  })
1220
1052
  );
1221
1053
  }, ye = (() => {
1222
- if (!s)
1054
+ if (!n)
1223
1055
  return !1;
1224
- if (s.step === 2 && A(s.control.type))
1225
- return (s.selectedCardIds || []).length > 0;
1226
- if (s.step !== 2 && s.step !== 3 || !s.control.label.trim())
1056
+ if (n.step === 2 && q(n.control.type))
1057
+ return (n.selectedCardIds || []).length > 0;
1058
+ if (n.step !== 2 && n.step !== 3 || !n.control.label.trim())
1227
1059
  return !1;
1228
- const d = s.control.source.kind === "sql_query" ? s.control : je(s.control);
1229
- if (d.source.kind === "manual" && (Et(d) && d.source.options.length === 0 || d.source.options.some(
1230
- (h) => h.label.trim().length === 0 || h.value.trim().length === 0
1060
+ const d = n.control.source.kind === "sql_query" ? n.control : $e(n.control);
1061
+ if (d.source.kind === "manual" && (Nt(d) && d.source.options.length === 0 || d.source.options.some(
1062
+ (f) => f.label.trim().length === 0 || f.value.trim().length === 0
1231
1063
  )))
1232
1064
  return !1;
1233
1065
  if (d.source.kind === "sql_query") {
1234
- const { connectionId: o, sql: h, valueColumn: C } = d.source;
1235
- return o.trim().length > 0 && h.trim().length > 0 && C.trim().length > 0;
1066
+ const { connectionId: l, sql: f, valueColumn: C } = d.source;
1067
+ return l.trim().length > 0 && f.trim().length > 0 && C.trim().length > 0;
1236
1068
  }
1237
- return It(
1238
- me(d, s.defaultValue)
1069
+ return wt(
1070
+ me(d, n.defaultValue)
1239
1071
  );
1240
- })(), qe = () => {
1241
- var k;
1242
- if (!s)
1072
+ })(), Me = () => {
1073
+ var S;
1074
+ if (!n)
1243
1075
  return;
1244
- const e = je(s.control), d = Tt({
1076
+ const e = $e(n.control), d = Ft({
1245
1077
  label: e.label,
1246
1078
  fallbackId: e.id,
1247
- existingControls: r,
1248
- reservedIds: Array.from(F)
1249
- }), o = {
1079
+ existingControls: a,
1080
+ reservedIds: Array.from(V)
1081
+ }), l = {
1250
1082
  ...e,
1251
1083
  id: d
1252
- }, h = t === "dashboard" && (o.type === "field_selector" || o.type === "metric_selector") && ((k = s.selectedCardIds) != null && k.length) ? Pe({
1253
- control: o,
1084
+ }, f = t === "dashboard" && (l.type === "field_selector" || l.type === "metric_selector") && ((S = n.selectedCardIds) != null && S.length) ? He({
1085
+ control: l,
1254
1086
  participants: y || [],
1255
- selectedCardIds: s.selectedCardIds
1087
+ selectedCardIds: n.selectedCardIds
1256
1088
  }) : void 0, C = me(
1257
- o,
1258
- s.defaultValue
1089
+ l,
1090
+ n.defaultValue
1259
1091
  );
1260
- D({
1261
- step: t === "dashboard" && (o.type === "field_selector" || o.type === "metric_selector") ? 4 : 3,
1262
- control: o,
1092
+ w({
1093
+ step: t === "dashboard" && (l.type === "field_selector" || l.type === "metric_selector") ? 4 : 3,
1094
+ control: l,
1263
1095
  defaultValue: C,
1264
1096
  createdControlId: d,
1265
- selectedCardIds: s.selectedCardIds,
1266
- cardBindingsById: h
1097
+ selectedCardIds: n.selectedCardIds,
1098
+ cardBindingsById: f
1267
1099
  });
1268
- }, ve = B(() => {
1269
- D(null);
1270
- }, []), Me = B(() => {
1271
- if (!(s != null && s.createdControlId)) {
1272
- D(null);
1100
+ }, ve = z(() => {
1101
+ w(null);
1102
+ }, []), Oe = z(() => {
1103
+ if (!(n != null && n.createdControlId)) {
1104
+ w(null);
1273
1105
  return;
1274
1106
  }
1275
- const e = s.control, d = s.createdControlId, o = me(
1107
+ const e = n.control, d = n.createdControlId, l = me(
1276
1108
  e,
1277
- s.defaultValue
1109
+ n.defaultValue
1278
1110
  );
1279
- if (n) {
1280
- const h = { ...n };
1281
- o === void 0 ? delete h[d] : h[d] = o, E(
1111
+ if (s) {
1112
+ const f = { ...s };
1113
+ l === void 0 ? delete f[d] : f[d] = l, F(
1282
1114
  [
1283
- ...r,
1115
+ ...a,
1284
1116
  {
1285
1117
  ...e,
1286
- defaultValue: o
1118
+ defaultValue: l
1287
1119
  }
1288
1120
  ],
1289
- h,
1121
+ f,
1290
1122
  {
1291
1123
  type: "add",
1292
- cardBindingsById: s.cardBindingsById
1124
+ cardBindingsById: n.cardBindingsById
1293
1125
  }
1294
1126
  );
1295
1127
  } else
1296
- E(
1128
+ F(
1297
1129
  [
1298
- ...r,
1130
+ ...a,
1299
1131
  {
1300
1132
  ...e,
1301
- defaultValue: o
1133
+ defaultValue: l
1302
1134
  }
1303
1135
  ],
1304
1136
  void 0,
1305
1137
  {
1306
1138
  type: "add",
1307
- cardBindingsById: s.cardBindingsById
1139
+ cardBindingsById: n.cardBindingsById
1308
1140
  }
1309
1141
  );
1310
- M(d), D(null), N == null || N();
1311
- }, [r, s, n, E, N]), ft = s ? A(s.control.type) ? ["Choose type", "Select cards", "Configure", "Finish"] : ["Choose type", "Configure", "Finish"] : [], Oe = s != null && s.createdControlId ? `[[param.${s.createdControlId}]]` : s ? `[[param.${Ft(s.control.label) || s.control.id}]]` : "", xe = Qe({
1312
- controls: r,
1313
- defaultValues: n
1314
- }), Ce = s ? [...r, s.control] : r, Ue = s ? Qe({
1142
+ E(d), w(null), N == null || N();
1143
+ }, [a, n, s, F, N]), ft = n ? q(n.control.type) ? ["Choose type", "Select cards", "Configure", "Finish"] : ["Choose type", "Configure", "Finish"] : [], Ue = n != null && n.createdControlId ? `[[param.${n.createdControlId}]]` : n ? `[[param.${Dt(n.control.label) || n.control.id}]]` : "", xe = Pe({
1144
+ controls: a,
1145
+ defaultValues: s
1146
+ }), Ce = n ? [...a, n.control] : a, ze = n ? Pe({
1315
1147
  controls: Ce,
1316
- defaultValues: n,
1148
+ defaultValues: s,
1317
1149
  overrides: [
1318
1150
  {
1319
- controlId: s.control.id,
1320
- value: s.defaultValue
1151
+ controlId: n.control.id,
1152
+ value: n.defaultValue
1321
1153
  }
1322
1154
  ]
1323
1155
  }) : xe;
1324
1156
  return /* @__PURE__ */ p("div", { className: "space-y-4", children: [
1325
- s ? /* @__PURE__ */ p("div", { className: "space-y-4 pb-1", children: [
1326
- /* @__PURE__ */ a(
1327
- pa,
1157
+ n ? /* @__PURE__ */ p("div", { className: "space-y-4 pb-1", children: [
1158
+ /* @__PURE__ */ r(
1159
+ mr,
1328
1160
  {
1329
- currentStep: s.step,
1161
+ currentStep: n.step,
1330
1162
  labels: ft
1331
1163
  }
1332
1164
  ),
1333
- s.step === 1 && (() => {
1165
+ n.step === 1 && (() => {
1334
1166
  const e = /* @__PURE__ */ new Set([
1335
1167
  "grain_selector",
1336
1168
  "aggregation_selector",
@@ -1341,45 +1173,45 @@ function _a({
1341
1173
  // keeping the shared definitions for existing controls.
1342
1174
  "date",
1343
1175
  "text"
1344
- ]), o = X.filter(
1345
- (k) => !e.has(k.value) && !d.has(k.value)
1346
- ), h = X.filter(
1347
- (k) => e.has(k.value)
1348
- ), C = (k) => /* @__PURE__ */ p(
1176
+ ]), l = G.filter(
1177
+ (S) => !e.has(S.value) && !d.has(S.value)
1178
+ ), f = G.filter(
1179
+ (S) => e.has(S.value)
1180
+ ), C = (S) => /* @__PURE__ */ p(
1349
1181
  "button",
1350
1182
  {
1351
1183
  type: "button",
1352
1184
  className: "rounded-control border border-border/60 bg-background px-3 py-2.5 text-left transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:outline-none",
1353
- onClick: () => D(
1354
- ha({
1185
+ onClick: () => w(
1186
+ br({
1355
1187
  scope: t,
1356
- existingControls: r,
1357
- reservedIds: Array.from(F),
1358
- type: k.value
1188
+ existingControls: a,
1189
+ reservedIds: Array.from(V),
1190
+ type: S.value
1359
1191
  })
1360
1192
  ),
1361
1193
  children: [
1362
- /* @__PURE__ */ a("div", { className: "text-[13px] font-medium text-foreground", children: k.label }),
1363
- /* @__PURE__ */ a("p", { className: "mt-0.5 text-[12px] text-muted-foreground", children: k.description })
1194
+ /* @__PURE__ */ r("div", { className: "text-[13px] font-medium text-foreground", children: S.label }),
1195
+ /* @__PURE__ */ r("p", { className: "mt-0.5 text-[12px] text-muted-foreground", children: S.description })
1364
1196
  ]
1365
1197
  },
1366
- k.value
1198
+ S.value
1367
1199
  );
1368
1200
  return /* @__PURE__ */ p("div", { className: "space-y-4", children: [
1369
- t === "card" && (x == null ? void 0 : x.sql) == null ? /* @__PURE__ */ a("p", { className: "text-[12px] text-muted-foreground", children: "Explorer cards support displayed metric, group by field, aggregation, and time grain controls here." }) : null,
1370
- o.length > 0 && /* @__PURE__ */ p("div", { className: "space-y-1.5", children: [
1371
- /* @__PURE__ */ a("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Input controls" }),
1372
- /* @__PURE__ */ a("div", { className: "grid gap-1.5 sm:grid-cols-2", children: o.map(C) })
1201
+ t === "card" && (x == null ? void 0 : x.sql) == null ? /* @__PURE__ */ r("p", { className: "text-[12px] text-muted-foreground", children: "Explorer cards support displayed metric, group by field, aggregation, and time grain controls here." }) : null,
1202
+ l.length > 0 && /* @__PURE__ */ p("div", { className: "space-y-1.5", children: [
1203
+ /* @__PURE__ */ r("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Input controls" }),
1204
+ /* @__PURE__ */ r("div", { className: "grid gap-1.5 sm:grid-cols-2", children: l.map(C) })
1373
1205
  ] }),
1374
- h.length > 0 && /* @__PURE__ */ p("div", { className: "space-y-1.5", children: [
1375
- /* @__PURE__ */ a("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Data-driven controls" }),
1376
- /* @__PURE__ */ a("div", { className: "grid gap-1.5 sm:grid-cols-2", children: h.map(C) })
1206
+ f.length > 0 && /* @__PURE__ */ p("div", { className: "space-y-1.5", children: [
1207
+ /* @__PURE__ */ r("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Data-driven controls" }),
1208
+ /* @__PURE__ */ r("div", { className: "grid gap-1.5 sm:grid-cols-2", children: f.map(C) })
1377
1209
  ] }),
1378
- /* @__PURE__ */ a(
1210
+ /* @__PURE__ */ r(
1379
1211
  he,
1380
1212
  {
1381
- secondary: /* @__PURE__ */ a(
1382
- q,
1213
+ secondary: /* @__PURE__ */ r(
1214
+ L,
1383
1215
  {
1384
1216
  type: "button",
1385
1217
  variant: "outline",
@@ -1392,38 +1224,38 @@ function _a({
1392
1224
  )
1393
1225
  ] });
1394
1226
  })(),
1395
- s.step === 2 && A(s.control.type) && /* @__PURE__ */ p("div", { className: "space-y-3", children: [
1227
+ n.step === 2 && q(n.control.type) && /* @__PURE__ */ p("div", { className: "space-y-3", children: [
1396
1228
  /* @__PURE__ */ p("div", { className: "space-y-3", children: [
1397
- /* @__PURE__ */ a(
1229
+ /* @__PURE__ */ r(
1398
1230
  mt,
1399
1231
  {
1400
- control: s.control,
1401
- onChange: (e) => $((d) => ({
1232
+ control: n.control,
1233
+ onChange: (e) => Q((d) => ({
1402
1234
  ...d,
1403
1235
  label: e
1404
1236
  }))
1405
1237
  }
1406
1238
  ),
1407
- /* @__PURE__ */ a("p", { className: "text-[12px] text-muted-foreground", children: "Choose which cards should respond to this shared control." })
1239
+ /* @__PURE__ */ r("p", { className: "text-[12px] text-muted-foreground", children: "Choose which cards should respond to this shared control." })
1408
1240
  ] }),
1409
- Q.length === 0 ? /* @__PURE__ */ a("div", { className: "rounded-control border border-border/60 bg-muted/30 px-3 py-2.5 text-[12px] text-muted-foreground", children: "No eligible cards are available yet. Add compatible metrics or group-by fields to cards first." }) : /* @__PURE__ */ a("div", { className: "space-y-1 rounded-control border border-border/60 bg-background p-2", children: Q.map((e) => {
1410
- const d = (s.selectedCardIds || []).includes(e.cardId);
1241
+ X.length === 0 ? /* @__PURE__ */ r("div", { className: "rounded-control border border-border/60 bg-muted/30 px-3 py-2.5 text-[12px] text-muted-foreground", children: "No eligible cards are available yet. Add compatible metrics or group-by fields to cards first." }) : /* @__PURE__ */ r("div", { className: "space-y-1 rounded-control border border-border/60 bg-background p-2", children: X.map((e) => {
1242
+ const d = (n.selectedCardIds || []).includes(e.cardId);
1411
1243
  return /* @__PURE__ */ p(
1412
1244
  "label",
1413
1245
  {
1414
1246
  className: "flex items-start gap-2 rounded-control px-1.5 py-1 text-[13px] hover:bg-muted/40",
1415
1247
  children: [
1416
- /* @__PURE__ */ a(
1417
- Kt,
1248
+ /* @__PURE__ */ r(
1249
+ Wt,
1418
1250
  {
1419
1251
  checked: d,
1420
- onCheckedChange: (o) => D(
1421
- (h) => h && {
1422
- ...h,
1423
- selectedCardIds: o === !0 ? [
1424
- ...h.selectedCardIds || [],
1252
+ onCheckedChange: (l) => w(
1253
+ (f) => f && {
1254
+ ...f,
1255
+ selectedCardIds: l === !0 ? [
1256
+ ...f.selectedCardIds || [],
1425
1257
  e.cardId
1426
- ] : (h.selectedCardIds || []).filter(
1258
+ ] : (f.selectedCardIds || []).filter(
1427
1259
  (C) => C !== e.cardId
1428
1260
  )
1429
1261
  }
@@ -1431,24 +1263,24 @@ function _a({
1431
1263
  }
1432
1264
  ),
1433
1265
  /* @__PURE__ */ p("div", { className: "min-w-0", children: [
1434
- /* @__PURE__ */ a("div", { className: "font-medium text-foreground", children: e.title }),
1435
- /* @__PURE__ */ a("div", { className: "text-[12px] text-muted-foreground", children: s.control.type === "field_selector" ? `${e.fieldChoices.length} compatible group-by fields` : `${e.metricChoices.length} compatible metrics` })
1266
+ /* @__PURE__ */ r("div", { className: "font-medium text-foreground", children: e.title }),
1267
+ /* @__PURE__ */ r("div", { className: "text-[12px] text-muted-foreground", children: n.control.type === "field_selector" ? `${e.fieldChoices.length} compatible group-by fields` : `${e.metricChoices.length} compatible metrics` })
1436
1268
  ] })
1437
1269
  ]
1438
1270
  },
1439
1271
  e.cardId
1440
1272
  );
1441
1273
  }) }),
1442
- /* @__PURE__ */ a(
1274
+ /* @__PURE__ */ r(
1443
1275
  he,
1444
1276
  {
1445
- secondary: /* @__PURE__ */ a(
1446
- q,
1277
+ secondary: /* @__PURE__ */ r(
1278
+ L,
1447
1279
  {
1448
1280
  type: "button",
1449
1281
  variant: "outline",
1450
1282
  size: "xs",
1451
- onClick: () => D(
1283
+ onClick: () => w(
1452
1284
  (e) => e && {
1453
1285
  ...e,
1454
1286
  step: 1,
@@ -1458,12 +1290,12 @@ function _a({
1458
1290
  children: "Back"
1459
1291
  }
1460
1292
  ),
1461
- primary: /* @__PURE__ */ a(
1462
- q,
1293
+ primary: /* @__PURE__ */ r(
1294
+ L,
1463
1295
  {
1464
1296
  type: "button",
1465
1297
  size: "xs",
1466
- onClick: () => D(
1298
+ onClick: () => w(
1467
1299
  (e) => e && {
1468
1300
  ...e,
1469
1301
  step: 3
@@ -1476,111 +1308,111 @@ function _a({
1476
1308
  }
1477
1309
  )
1478
1310
  ] }),
1479
- s.step === 2 && !A(s.control.type) && /* @__PURE__ */ a(
1480
- He,
1311
+ n.step === 2 && !q(n.control.type) && /* @__PURE__ */ r(
1312
+ Ge,
1481
1313
  {
1482
- control: s.control,
1483
- defaultValue: s.defaultValue,
1484
- availableFieldChoices: Y.fields,
1485
- availableMetricChoices: Y.metrics,
1314
+ control: n.control,
1315
+ defaultValue: n.defaultValue,
1316
+ availableFieldChoices: ae.fields,
1317
+ availableMetricChoices: ae.metrics,
1486
1318
  previewControlDefinitions: Ce,
1487
- previewControlValues: Ue,
1488
- onControlChange: (e) => $(() => e),
1489
- onLabelChange: (e) => $((d) => ({
1319
+ previewControlValues: ze,
1320
+ onControlChange: (e) => Q(() => e),
1321
+ onLabelChange: (e) => Q((d) => ({
1490
1322
  ...d,
1491
1323
  label: e
1492
1324
  })),
1493
1325
  onDefaultValueChange: le,
1494
- onBack: () => D(
1326
+ onBack: () => w(
1495
1327
  (e) => e && {
1496
1328
  ...e,
1497
1329
  step: 1
1498
1330
  }
1499
1331
  ),
1500
- onNext: qe,
1332
+ onNext: Me,
1501
1333
  nextDisabled: !ye
1502
1334
  }
1503
1335
  ),
1504
- s.step === 3 && A(s.control.type) && /* @__PURE__ */ a(
1505
- He,
1336
+ n.step === 3 && q(n.control.type) && /* @__PURE__ */ r(
1337
+ Ge,
1506
1338
  {
1507
- control: s.control,
1508
- defaultValue: s.defaultValue,
1509
- availableFieldChoices: Y.fields,
1510
- availableMetricChoices: Y.metrics,
1339
+ control: n.control,
1340
+ defaultValue: n.defaultValue,
1341
+ availableFieldChoices: ae.fields,
1342
+ availableMetricChoices: ae.metrics,
1511
1343
  previewControlDefinitions: Ce,
1512
- previewControlValues: Ue,
1513
- onControlChange: (e) => $(() => e),
1514
- onLabelChange: (e) => $((d) => ({
1344
+ previewControlValues: ze,
1345
+ onControlChange: (e) => Q(() => e),
1346
+ onLabelChange: (e) => Q((d) => ({
1515
1347
  ...d,
1516
1348
  label: e
1517
1349
  })),
1518
1350
  onDefaultValueChange: le,
1519
- onBack: () => D(
1351
+ onBack: () => w(
1520
1352
  (e) => e && {
1521
1353
  ...e,
1522
1354
  step: 2
1523
1355
  }
1524
1356
  ),
1525
- onNext: qe,
1357
+ onNext: Me,
1526
1358
  nextDisabled: !ye
1527
1359
  }
1528
1360
  ),
1529
- s.step === 3 && !A(s.control.type) && /* @__PURE__ */ a(
1530
- Xe,
1361
+ n.step === 3 && !q(n.control.type) && /* @__PURE__ */ r(
1362
+ Je,
1531
1363
  {
1532
- control: s.control,
1364
+ control: n.control,
1533
1365
  scope: t,
1534
- createdReference: Oe,
1535
- explorerContent: /* @__PURE__ */ p(ae, { children: [
1366
+ createdReference: Ue,
1367
+ explorerContent: /* @__PURE__ */ p(re, { children: [
1536
1368
  "Open the card and use",
1537
1369
  " ",
1538
- /* @__PURE__ */ a("span", { className: "font-medium text-foreground", children: "Settings → Controls" }),
1370
+ /* @__PURE__ */ r("span", { className: "font-medium text-foreground", children: "Settings → Controls" }),
1539
1371
  " ",
1540
1372
  "to choose what this control changes."
1541
1373
  ] }),
1542
1374
  sqlDescription: "Reference this control directly in the SQL editor.",
1543
- onBack: () => D(
1375
+ onBack: () => w(
1544
1376
  (e) => e && {
1545
1377
  ...e,
1546
1378
  step: 2
1547
1379
  }
1548
1380
  ),
1549
1381
  onCancel: ve,
1550
- onDone: Me
1382
+ onDone: Oe
1551
1383
  }
1552
1384
  ),
1553
- s.step === 4 && A(s.control.type) && /* @__PURE__ */ a(
1554
- Xe,
1385
+ n.step === 4 && q(n.control.type) && /* @__PURE__ */ r(
1386
+ Je,
1555
1387
  {
1556
- control: s.control,
1388
+ control: n.control,
1557
1389
  scope: t,
1558
- createdReference: Oe,
1559
- summaryDetail: /* @__PURE__ */ p(ae, { children: [
1390
+ createdReference: Ue,
1391
+ summaryDetail: /* @__PURE__ */ p(re, { children: [
1560
1392
  "Used by ",
1561
- (s.selectedCardIds || []).length,
1393
+ (n.selectedCardIds || []).length,
1562
1394
  " selected card",
1563
- (s.selectedCardIds || []).length === 1 ? "" : "s"
1395
+ (n.selectedCardIds || []).length === 1 ? "" : "s"
1564
1396
  ] }),
1565
- explorerContent: /* @__PURE__ */ a(ae, { children: "Selected cards have been set up to respond to this control automatically." }),
1397
+ explorerContent: /* @__PURE__ */ r(re, { children: "Selected cards have been set up to respond to this control automatically." }),
1566
1398
  sqlDescription: "SQL cards can still reference this control directly in the SQL editor.",
1567
- onBack: () => D(
1399
+ onBack: () => w(
1568
1400
  (e) => e && {
1569
1401
  ...e,
1570
1402
  step: 3
1571
1403
  }
1572
1404
  ),
1573
1405
  onCancel: ve,
1574
- onDone: Me
1406
+ onDone: Oe
1575
1407
  }
1576
1408
  )
1577
1409
  ] }) : null,
1578
- !s && r.length === 0 ? /* @__PURE__ */ a("div", { className: "rounded-md border border-dashed p-3 text-sm text-muted-foreground", children: c }) : null,
1579
- !s && r.map((e) => {
1580
- const d = be(e), o = f == null ? void 0 : f[e.id], h = Ne({
1410
+ !n && a.length === 0 ? /* @__PURE__ */ r("div", { className: "rounded-md border border-dashed p-3 text-sm text-muted-foreground", children: c }) : null,
1411
+ !n && a.map((e) => {
1412
+ const d = be(e), l = h == null ? void 0 : h[e.id], f = Ne({
1581
1413
  control: e,
1582
- defaultValues: n
1583
- }), C = re === e.id, k = "inline-flex shrink-0 items-center rounded-[4px] border border-border/60 bg-muted/40 px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground";
1414
+ defaultValues: s
1415
+ }), C = Z === e.id, S = "inline-flex shrink-0 items-center rounded-[4px] border border-border/60 bg-muted/40 px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground";
1584
1416
  return /* @__PURE__ */ p(
1585
1417
  "div",
1586
1418
  {
@@ -1592,27 +1424,27 @@ function _a({
1592
1424
  {
1593
1425
  type: "button",
1594
1426
  className: "flex min-w-0 flex-1 items-start gap-2 rounded-control text-left focus:outline-none focus-visible:bg-muted/40",
1595
- onClick: () => M(
1427
+ onClick: () => E(
1596
1428
  (g) => g === e.id ? null : e.id
1597
1429
  ),
1598
1430
  children: [
1599
- C ? /* @__PURE__ */ a(We, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" }) : /* @__PURE__ */ a(Ke, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
1431
+ C ? /* @__PURE__ */ r(je, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" }) : /* @__PURE__ */ r(Ke, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
1600
1432
  /* @__PURE__ */ p("div", { className: "min-w-0", children: [
1601
1433
  /* @__PURE__ */ p("div", { className: "flex flex-wrap items-center gap-1.5", children: [
1602
- /* @__PURE__ */ a("span", { className: "truncate text-[13px] font-medium text-foreground", children: e.label || "Untitled control" }),
1603
- /* @__PURE__ */ a("span", { className: k, children: Ze(e.type).label }),
1604
- /* @__PURE__ */ a("span", { className: k, children: et(t, e.placement) })
1434
+ /* @__PURE__ */ r("span", { className: "truncate text-[13px] font-medium text-foreground", children: e.label || "Untitled control" }),
1435
+ /* @__PURE__ */ r("span", { className: S, children: et(e.type).label }),
1436
+ /* @__PURE__ */ r("span", { className: S, children: tt(t, e.placement) })
1605
1437
  ] }),
1606
1438
  /* @__PURE__ */ p("div", { className: "mt-0.5 text-[12px] text-muted-foreground", children: [
1607
- tt(e),
1608
- o != null && o.status ? ` · ${o.status}` : ""
1439
+ rt(e),
1440
+ l != null && l.status ? ` · ${l.status}` : ""
1609
1441
  ] })
1610
1442
  ] })
1611
1443
  ]
1612
1444
  }
1613
1445
  ),
1614
- /* @__PURE__ */ a(
1615
- q,
1446
+ /* @__PURE__ */ r(
1447
+ L,
1616
1448
  {
1617
1449
  type: "button",
1618
1450
  size: "xs",
@@ -1620,15 +1452,15 @@ function _a({
1620
1452
  className: "h-7 w-7 shrink-0 p-0 text-muted-foreground",
1621
1453
  onClick: () => ge(e.id),
1622
1454
  "aria-label": `Remove ${e.label}`,
1623
- children: /* @__PURE__ */ a(Yt, { className: "h-3.5 w-3.5" })
1455
+ children: /* @__PURE__ */ r(Ht, { className: "h-3.5 w-3.5" })
1624
1456
  }
1625
1457
  )
1626
1458
  ] }),
1627
1459
  C && /* @__PURE__ */ p("div", { className: "space-y-4 border-t border-border/60 px-3 py-3", children: [
1628
1460
  /* @__PURE__ */ p("div", { className: "grid gap-3 md:grid-cols-3", children: [
1629
1461
  /* @__PURE__ */ p("div", { className: "flex flex-col gap-1.5", children: [
1630
- /* @__PURE__ */ a(ne, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Label" }),
1631
- /* @__PURE__ */ a(
1462
+ /* @__PURE__ */ r(ne, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Label" }),
1463
+ /* @__PURE__ */ r(
1632
1464
  at,
1633
1465
  {
1634
1466
  size: "xs",
@@ -1642,25 +1474,25 @@ function _a({
1642
1474
  )
1643
1475
  ] }),
1644
1476
  /* @__PURE__ */ p("div", { className: "flex flex-col gap-1.5", children: [
1645
- /* @__PURE__ */ a(ne, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Type" }),
1477
+ /* @__PURE__ */ r(ne, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Type" }),
1646
1478
  /* @__PURE__ */ p(
1647
1479
  we,
1648
1480
  {
1649
1481
  value: e.type,
1650
1482
  onValueChange: (g) => {
1651
- const I = rt({
1652
- controls: r,
1483
+ const I = st({
1484
+ controls: a,
1653
1485
  controlId: e.id,
1654
1486
  nextType: g,
1655
- defaultValues: n
1487
+ defaultValues: s
1656
1488
  });
1657
- E(I.controls, I.defaultValues);
1489
+ F(I.controls, I.defaultValues);
1658
1490
  },
1659
1491
  children: [
1660
- /* @__PURE__ */ a(De, { size: "xs", children: /* @__PURE__ */ a(Ee, {}) }),
1661
- /* @__PURE__ */ a(Ie, { children: ee(e.type).map(
1662
- (g) => /* @__PURE__ */ a(
1663
- Fe,
1492
+ /* @__PURE__ */ r(De, { size: "xs", children: /* @__PURE__ */ r(Ee, {}) }),
1493
+ /* @__PURE__ */ r(Fe, { children: ee(e.type).map(
1494
+ (g) => /* @__PURE__ */ r(
1495
+ Ie,
1664
1496
  {
1665
1497
  value: g.value,
1666
1498
  children: g.label
@@ -1673,28 +1505,28 @@ function _a({
1673
1505
  )
1674
1506
  ] }),
1675
1507
  /* @__PURE__ */ p("div", { className: "flex flex-col gap-1.5", children: [
1676
- /* @__PURE__ */ a(ne, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Show in" }),
1508
+ /* @__PURE__ */ r(ne, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Show in" }),
1677
1509
  /* @__PURE__ */ p(
1678
1510
  we,
1679
1511
  {
1680
- value: e.placement || H,
1512
+ value: e.placement || K,
1681
1513
  onValueChange: (g) => W(e.id, (I) => ({
1682
1514
  ...I,
1683
1515
  placement: g
1684
1516
  })),
1685
1517
  children: [
1686
- /* @__PURE__ */ a(De, { size: "xs", children: /* @__PURE__ */ a(Ee, {}) }),
1687
- /* @__PURE__ */ a(Ie, { children: j.map((g) => /* @__PURE__ */ a(Fe, { value: g.value, children: g.label }, g.value)) })
1518
+ /* @__PURE__ */ r(De, { size: "xs", children: /* @__PURE__ */ r(Ee, {}) }),
1519
+ /* @__PURE__ */ r(Fe, { children: j.map((g) => /* @__PURE__ */ r(Ie, { value: g.value, children: g.label }, g.value)) })
1688
1520
  ]
1689
1521
  }
1690
1522
  )
1691
1523
  ] })
1692
1524
  ] }),
1693
- A(e.type) ? /* @__PURE__ */ a(
1694
- Ht,
1525
+ q(e.type) ? /* @__PURE__ */ r(
1526
+ Kt,
1695
1527
  {
1696
1528
  type: e.type,
1697
- participants: Re(
1529
+ participants: Qe(
1698
1530
  y || [],
1699
1531
  e.type
1700
1532
  ).map((g) => ({
@@ -1707,84 +1539,84 @@ function _a({
1707
1539
  const I = _({
1708
1540
  control: e,
1709
1541
  nextSelectedCardIds: g
1710
- }), U = r.map(
1542
+ }), O = a.map(
1711
1543
  (T) => T.id === e.id ? I.nextControl : T
1712
1544
  );
1713
- E(U, n, {
1545
+ F(O, s, {
1714
1546
  type: "update",
1715
1547
  cardBindingsById: I.cardBindingsById
1716
1548
  });
1717
1549
  }
1718
1550
  }
1719
1551
  ) : null,
1720
- /* @__PURE__ */ a(
1721
- lt,
1552
+ /* @__PURE__ */ r(
1553
+ it,
1722
1554
  {
1723
1555
  control: e,
1724
1556
  availableFieldChoices: d.fields,
1725
1557
  availableMetricChoices: d.metrics,
1726
- previewControlDefinitions: r,
1558
+ previewControlDefinitions: a,
1727
1559
  previewControlValues: xe,
1728
1560
  controlLifecycle: "edit",
1729
1561
  onChange: (g) => W(e.id, () => g)
1730
1562
  }
1731
1563
  ),
1732
- e.initialValueStrategy === "saved_default" && /* @__PURE__ */ a(
1733
- it,
1564
+ e.initialValueStrategy === "saved_default" && /* @__PURE__ */ r(
1565
+ dt,
1734
1566
  {
1735
1567
  control: e,
1736
- value: h,
1568
+ value: f,
1737
1569
  allowNoDefault: !0,
1738
1570
  allowCardDefault: !0,
1739
- previewControlDefinitions: r,
1571
+ previewControlDefinitions: a,
1740
1572
  previewControlValues: xe,
1741
1573
  onChange: (g) => {
1742
- const I = r.map(
1743
- (U) => U.id === e.id ? { ...U, defaultValue: g } : U
1574
+ const I = a.map(
1575
+ (O) => O.id === e.id ? { ...O, defaultValue: g } : O
1744
1576
  );
1745
- if (e.source.kind === "manual" && (V.current[e.id] = g), n) {
1746
- const U = { ...n };
1747
- g === void 0 ? delete U[e.id] : U[e.id] = g, E(I, U);
1577
+ if (e.source.kind === "manual" && (P.current[e.id] = g), s) {
1578
+ const O = { ...s };
1579
+ g === void 0 ? delete O[e.id] : O[e.id] = g, F(I, O);
1748
1580
  return;
1749
1581
  }
1750
- E(I, void 0);
1582
+ F(I, void 0);
1751
1583
  }
1752
1584
  }
1753
1585
  ),
1754
1586
  /* @__PURE__ */ p(
1755
- Gt,
1587
+ Yt,
1756
1588
  {
1757
- open: Z === e.id,
1758
- onOpenChange: (g) => G(g ? e.id : null),
1589
+ open: R === e.id,
1590
+ onOpenChange: (g) => $(g ? e.id : null),
1759
1591
  children: [
1760
- /* @__PURE__ */ a(Xt, { asChild: !0, children: /* @__PURE__ */ p(
1761
- q,
1592
+ /* @__PURE__ */ r(Gt, { asChild: !0, children: /* @__PURE__ */ p(
1593
+ L,
1762
1594
  {
1763
1595
  type: "button",
1764
1596
  variant: "ghost",
1765
1597
  size: "xs",
1766
1598
  className: "-ml-2 gap-1 text-muted-foreground hover:text-foreground",
1767
1599
  children: [
1768
- Z === e.id ? /* @__PURE__ */ a(We, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ a(Ke, { className: "h-3.5 w-3.5" }),
1600
+ R === e.id ? /* @__PURE__ */ r(je, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ r(Ke, { className: "h-3.5 w-3.5" }),
1769
1601
  "Advanced"
1770
1602
  ]
1771
1603
  }
1772
1604
  ) }),
1773
- /* @__PURE__ */ p(Jt, { className: "space-y-3 pt-2", children: [
1605
+ /* @__PURE__ */ p(Xt, { className: "space-y-3 pt-2", children: [
1774
1606
  /* @__PURE__ */ p("div", { className: "grid gap-3 md:grid-cols-2", children: [
1775
1607
  /* @__PURE__ */ p("div", { className: "flex flex-col gap-1.5", children: [
1776
- /* @__PURE__ */ a(ne, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Variable name" }),
1777
- /* @__PURE__ */ a(
1778
- Zt,
1608
+ /* @__PURE__ */ r(ne, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Variable name" }),
1609
+ /* @__PURE__ */ r(
1610
+ Jt,
1779
1611
  {
1780
1612
  controlId: e.id,
1781
- onCommit: (g) => L(e.id, g)
1613
+ onCommit: (g) => A(e.id, g)
1782
1614
  },
1783
1615
  e.id
1784
1616
  )
1785
1617
  ] }),
1786
1618
  /* @__PURE__ */ p("div", { className: "flex flex-col gap-1.5", children: [
1787
- /* @__PURE__ */ a(ne, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Initial value" }),
1619
+ /* @__PURE__ */ r(ne, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Initial value" }),
1788
1620
  /* @__PURE__ */ p(
1789
1621
  we,
1790
1622
  {
@@ -1794,9 +1626,9 @@ function _a({
1794
1626
  initialValueStrategy: g
1795
1627
  })),
1796
1628
  children: [
1797
- /* @__PURE__ */ a(De, { size: "xs", children: /* @__PURE__ */ a(Ee, {}) }),
1798
- /* @__PURE__ */ a(Ie, { children: Vt.map((g) => /* @__PURE__ */ a(
1799
- Fe,
1629
+ /* @__PURE__ */ r(De, { size: "xs", children: /* @__PURE__ */ r(Ee, {}) }),
1630
+ /* @__PURE__ */ r(Fe, { children: Et.map((g) => /* @__PURE__ */ r(
1631
+ Ie,
1800
1632
  {
1801
1633
  value: g.value,
1802
1634
  children: g.label
@@ -1808,8 +1640,8 @@ function _a({
1808
1640
  )
1809
1641
  ] })
1810
1642
  ] }),
1811
- /* @__PURE__ */ a(
1812
- ea,
1643
+ /* @__PURE__ */ r(
1644
+ Zt,
1813
1645
  {
1814
1646
  control: e,
1815
1647
  onChange: (g) => W(e.id, () => g)
@@ -1825,43 +1657,43 @@ function _a({
1825
1657
  e.id
1826
1658
  );
1827
1659
  }),
1828
- !s && /* @__PURE__ */ p(
1829
- q,
1660
+ !n && /* @__PURE__ */ p(
1661
+ L,
1830
1662
  {
1831
1663
  type: "button",
1832
1664
  variant: "outline",
1833
1665
  size: "xs",
1834
1666
  onClick: ue,
1835
1667
  children: [
1836
- /* @__PURE__ */ a(ta, { className: "h-3.5 w-3.5" }),
1668
+ /* @__PURE__ */ r(er, { className: "h-3.5 w-3.5" }),
1837
1669
  "Add control"
1838
1670
  ]
1839
1671
  }
1840
1672
  )
1841
1673
  ] });
1842
1674
  }
1843
- function Aa(t) {
1675
+ function Vr(t) {
1844
1676
  const {
1845
- open: r,
1846
- onOpenChange: l,
1847
- initialCreateFlowActive: n = !1,
1677
+ open: a,
1678
+ onOpenChange: o,
1679
+ initialCreateFlowActive: s = !1,
1848
1680
  dismissMode: i = "passive"
1849
- } = t, c = r !== void 0, [m, f] = K(!1), [u, v] = K(
1850
- n
1851
- ), y = c ? r : m, b = B(
1852
- (S) => {
1853
- !S && u && i === "passive" || (c || f(S), S || v(!1), l == null || l(S));
1681
+ } = t, c = a !== void 0, [m, h] = H(!1), [u, v] = H(
1682
+ s
1683
+ ), y = c ? a : m, b = z(
1684
+ (k) => {
1685
+ !k && u && i === "passive" || (c || h(k), k || v(!1), o == null || o(k));
1854
1686
  },
1855
- [c, u, i, l]
1856
- ), x = B(() => {
1857
- c || f(!1), v(!1), l == null || l(!1);
1858
- }, [c, l]);
1687
+ [c, u, i, o]
1688
+ ), x = z(() => {
1689
+ c || h(!1), v(!1), o == null || o(!1);
1690
+ }, [c, o]);
1859
1691
  ie(() => {
1860
1692
  y || v(!1);
1861
1693
  }, [y]);
1862
- const w = B(
1863
- (S) => {
1864
- u && S.preventDefault();
1694
+ const D = z(
1695
+ (k) => {
1696
+ u && k.preventDefault();
1865
1697
  },
1866
1698
  [u]
1867
1699
  );
@@ -1869,22 +1701,207 @@ function Aa(t) {
1869
1701
  forceClose: x,
1870
1702
  handleOpenChange: b,
1871
1703
  isCreateFlowActive: u,
1872
- preventPassiveDismissDuringCreate: w,
1704
+ preventPassiveDismissDuringCreate: D,
1873
1705
  resolvedOpen: y,
1874
1706
  setIsCreateFlowActive: v
1875
1707
  };
1876
1708
  }
1709
+ function qe(t) {
1710
+ const a = At(t);
1711
+ return a ? (B.error(a), !1) : !0;
1712
+ }
1713
+ function Tr({
1714
+ className: t,
1715
+ variant: a = "outline"
1716
+ }) {
1717
+ const o = U((c) => c.onSave), { getUpdatedFrame: s } = Le();
1718
+ function i() {
1719
+ const c = s();
1720
+ qe(c) && (o == null || o(c));
1721
+ }
1722
+ return /* @__PURE__ */ p(
1723
+ L,
1724
+ {
1725
+ onClick: i,
1726
+ className: t,
1727
+ size: "xs",
1728
+ variant: a,
1729
+ children: [
1730
+ /* @__PURE__ */ r(Tt, { className: "h-3.5 w-3.5" }),
1731
+ "Accept"
1732
+ ]
1733
+ }
1734
+ );
1735
+ }
1736
+ function _r({
1737
+ className: t,
1738
+ variant: a = "default"
1739
+ }) {
1740
+ const o = ce(), [s, i] = H(!1), { setIsVisualEditing: c } = _e(), { getUpdatedFrame: m } = Le(), h = Ae(), u = U((b) => b.frame), v = ct();
1741
+ return /* @__PURE__ */ r(
1742
+ L,
1743
+ {
1744
+ onClick: () => {
1745
+ const b = m();
1746
+ if (!qe(b))
1747
+ return;
1748
+ const x = (u == null ? void 0 : u.visualId) || (h == null ? void 0 : h.id);
1749
+ if (!x) {
1750
+ B.error("No visual to save");
1751
+ return;
1752
+ }
1753
+ i(!0), v.mutate(
1754
+ {
1755
+ visualId: x,
1756
+ data: {
1757
+ frameObject: b
1758
+ }
1759
+ },
1760
+ {
1761
+ onSuccess: () => {
1762
+ i(!1), B.success("Visual updated successfully"), o.invalidateQueries({
1763
+ queryKey: ["resource-by-id", "visual", x],
1764
+ exact: !0
1765
+ });
1766
+ },
1767
+ onError: () => {
1768
+ i(!1), B.error("Failed to update visual");
1769
+ }
1770
+ }
1771
+ );
1772
+ },
1773
+ className: t,
1774
+ size: "xs",
1775
+ variant: a,
1776
+ children: s ? /* @__PURE__ */ p(re, { children: [
1777
+ /* @__PURE__ */ r(nt, { className: "h-3.5 w-3.5 animate-spin" }),
1778
+ "Saving"
1779
+ ] }) : /* @__PURE__ */ p(re, { children: [
1780
+ /* @__PURE__ */ r(ut, { className: "h-3.5 w-3.5" }),
1781
+ "Save to Library"
1782
+ ] })
1783
+ }
1784
+ );
1785
+ }
1786
+ function Ar({
1787
+ className: t
1788
+ }) {
1789
+ const a = ce(), [o, s] = H(!1), i = Ae(), c = U((k) => k.frame), m = J((k) => k.selectedSheetId), h = J((k) => k.dashboard), { updateFrame: u, setIsVisualEditing: v } = _e(), { getUpdatedFrame: y } = Le(), b = ct(), x = ar();
1790
+ return /* @__PURE__ */ r(
1791
+ L,
1792
+ {
1793
+ onClick: async () => {
1794
+ if (!m) {
1795
+ B.error("No sheet selected");
1796
+ return;
1797
+ }
1798
+ const k = (c == null ? void 0 : c.visualId) || (i == null ? void 0 : i.id);
1799
+ if (!k) {
1800
+ B.error("No visual to update");
1801
+ return;
1802
+ }
1803
+ s(!0);
1804
+ try {
1805
+ const N = y();
1806
+ if (!qe(N)) {
1807
+ s(!1);
1808
+ return;
1809
+ }
1810
+ const V = {
1811
+ ...N,
1812
+ visualId: k
1813
+ // Keep the link to library visual
1814
+ }, j = _t(h, V.id), K = await x(V, {
1815
+ previousFrame: j
1816
+ });
1817
+ await b.mutateAsync({
1818
+ visualId: k,
1819
+ data: {
1820
+ frameObject: N
1821
+ }
1822
+ }), u(m, V, {
1823
+ semanticExecutionPayload: K
1824
+ }), a.invalidateQueries({ queryKey: ["visuals"] }), a.invalidateQueries({ queryKey: ["visual", k] }), B.success("Saved to library and applied locally"), setTimeout(() => {
1825
+ v(!1);
1826
+ }, 300);
1827
+ } catch (N) {
1828
+ console.error("Failed to save and apply:", N), B.error(
1829
+ N instanceof Error ? N.message : "Failed to save and apply changes"
1830
+ );
1831
+ } finally {
1832
+ s(!1);
1833
+ }
1834
+ },
1835
+ className: t,
1836
+ size: "xs",
1837
+ variant: "default",
1838
+ disabled: o,
1839
+ children: o ? /* @__PURE__ */ p(re, { children: [
1840
+ /* @__PURE__ */ r(nt, { className: "h-3.5 w-3.5 animate-spin" }),
1841
+ "Saving..."
1842
+ ] }) : /* @__PURE__ */ p(re, { children: [
1843
+ /* @__PURE__ */ r(ut, { className: "h-3.5 w-3.5" }),
1844
+ "Save & Apply"
1845
+ ] })
1846
+ }
1847
+ );
1848
+ }
1849
+ function Lr({ className: t }) {
1850
+ const { setTempQueryData: a, setSqlGen: o } = de(), s = ce(), i = U((b) => b.tempQueryData), c = U((b) => b.onClose), m = U((b) => b.card), h = ot(), u = oe(() => h !== m.type ? { ...m, type: h } : m, [m, h]), { queryKey: v } = lt(u);
1851
+ function y() {
1852
+ if (i) {
1853
+ const { queryKey: b, queryData: x } = i;
1854
+ b && x && s.setQueryData(b, x);
1855
+ }
1856
+ o({}), c == null || c();
1857
+ }
1858
+ return /* @__PURE__ */ p(
1859
+ L,
1860
+ {
1861
+ onClick: y,
1862
+ className: t,
1863
+ size: "xs",
1864
+ variant: "outline",
1865
+ children: [
1866
+ /* @__PURE__ */ r(Ze, { className: "h-3.5 w-3.5" }),
1867
+ "Close"
1868
+ ]
1869
+ }
1870
+ );
1871
+ }
1872
+ function qr({
1873
+ label: t = "Clear",
1874
+ variant: a = "secondary",
1875
+ className: o
1876
+ } = {}) {
1877
+ const s = pr();
1878
+ return /* @__PURE__ */ p(
1879
+ L,
1880
+ {
1881
+ onClick: s,
1882
+ className: o,
1883
+ size: "xs",
1884
+ variant: a,
1885
+ children: [
1886
+ /* @__PURE__ */ r(Ze, { className: "h-3.5 w-3.5" }),
1887
+ t
1888
+ ]
1889
+ }
1890
+ );
1891
+ }
1877
1892
  export {
1878
- _a as C,
1879
- Ea as E,
1880
- sa as L,
1881
- Da as V,
1882
- Va as a,
1883
- Ia as b,
1884
- Fa as c,
1885
- na as d,
1886
- Aa as e,
1887
- wa as f,
1888
- Ta as g,
1889
- Ae as u
1893
+ Ir as C,
1894
+ Tr as E,
1895
+ Dr as F,
1896
+ sr as L,
1897
+ Fr as V,
1898
+ Lr as a,
1899
+ _r as b,
1900
+ Ar as c,
1901
+ nr as d,
1902
+ Vr as e,
1903
+ Er as f,
1904
+ pr as g,
1905
+ qr as h,
1906
+ Le as u
1890
1907
  };