react-semaphor 0.1.259 → 0.1.261

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 (46) hide show
  1. package/dist/chunks/dashboard-controls-0hbftZxY.js +42 -0
  2. package/dist/chunks/dashboard-controls-BYi_r2lH.js +1971 -0
  3. package/dist/chunks/dashboard-filter-controls-button-BPCw1GMh.js +1066 -0
  4. package/dist/chunks/dashboard-filter-controls-button-f4pDkDUL.js +11 -0
  5. package/dist/chunks/{dashboard-json-B43n1l6C.js → dashboard-json-2NJCXsDD.js} +1 -1
  6. package/dist/chunks/{dashboard-json-D0oSxmLa.js → dashboard-json-Dpy-zKf2.js} +1 -1
  7. package/dist/chunks/{dashboard-summary-settings-dialog-CxZAMb8B.js → dashboard-summary-settings-dialog-B9zRCvc-.js} +1 -1
  8. package/dist/chunks/{dashboard-summary-settings-dialog-DMWYgbwB.js → dashboard-summary-settings-dialog-Be3JilRI.js} +1 -1
  9. package/dist/chunks/edit-dashboard-visual-Bon08erH.js +188 -0
  10. package/dist/chunks/{edit-dashboard-visual-CCoz1oGX.js → edit-dashboard-visual-CqTlmuYL.js} +5970 -5492
  11. package/dist/chunks/index-BoJEr_9F.js +1114 -0
  12. package/dist/chunks/{index-DpSxZvI0.js → index-C2c-_lPE.js} +48682 -45193
  13. package/dist/chunks/{normalize-dashboard-for-dirty-check-Bn27S0PN.js → normalize-dashboard-for-dirty-check-5KpZN8xr.js} +20 -19
  14. package/dist/chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js +1 -0
  15. package/dist/chunks/{resource-management-panel-L51m1i4h.js → resource-management-panel-BtLPW2b4.js} +1 -1
  16. package/dist/chunks/{resource-management-panel-B_bDGuq_.js → resource-management-panel-Bva2_0OU.js} +70 -70
  17. package/dist/chunks/use-create-flow-overlay-state-9X7GyUzl.js +21 -0
  18. package/dist/chunks/use-create-flow-overlay-state-Vyd5mSnf.js +1445 -0
  19. package/dist/chunks/{use-visual-utils-V6paZich.js → use-visual-utils-Jv4hWSLm.js} +1 -1
  20. package/dist/chunks/{use-visual-utils-Cp5KVbr6.js → use-visual-utils-OPk_1t4I.js} +1 -1
  21. package/dist/dashboard/index.cjs +1 -1
  22. package/dist/dashboard/index.js +5 -4
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +102 -99
  25. package/dist/shared/index.cjs +1 -1
  26. package/dist/shared/index.js +1 -1
  27. package/dist/style.css +1 -1
  28. package/dist/surfboard/index.cjs +1 -1
  29. package/dist/surfboard/index.js +5 -4
  30. package/dist/types/dashboard.d.ts +105 -0
  31. package/dist/types/index.cjs +1 -1
  32. package/dist/types/index.js +4 -3
  33. package/dist/types/main.d.ts +175 -1
  34. package/dist/types/shared.d.ts +89 -0
  35. package/dist/types/surfboard.d.ts +105 -0
  36. package/dist/types/types.d.ts +113 -0
  37. package/package.json +1 -1
  38. package/dist/chunks/dashboard-controls-51P6aUVB.js +0 -1847
  39. package/dist/chunks/dashboard-controls-BC3hDGwD.js +0 -47
  40. package/dist/chunks/edit-dashboard-visual-D1mwhPGF.js +0 -193
  41. package/dist/chunks/editor-action-buttons-B6ElCCo2.js +0 -412
  42. package/dist/chunks/editor-action-buttons-Dbs6eczj.js +0 -21
  43. package/dist/chunks/index-DAhkssOV.js +0 -1109
  44. package/dist/chunks/normalize-dashboard-for-dirty-check-B7NQDI1H.js +0 -1
  45. package/dist/chunks/notification-bell-DoIAAZqX.js +0 -6
  46. package/dist/chunks/notification-bell-cYCkxEbp.js +0 -839
@@ -0,0 +1,1445 @@
1
+ import { bL as ae, U as S, bM as qe, bN as et, bO as tt, bP as at, bQ as st, bR as lt, u as ve, ae as rt, bS as nt, bT as dt, bU as it, ab as Z, c as q, bV as ot, bW as ct, M as ee, B as w, s as ut, H as se, N as Oe, J as _e, bX as Me, w as ze, bY as Be, X as Qe, x as Q, bZ as mt, b_ as J, b$ as Ie, c0 as we, c1 as oe, c2 as Te, c3 as pt, c4 as ht, c5 as P, c6 as ft, c7 as bt, a5 as Ve, c8 as Fe, c9 as ge, ca as je, cb as Ue, cc as yt, L as R, I as Re, y as ce, z as ue, A as me, E as pe, F as he, cd as $e, ce as vt, cf as gt, cg as Ke, ch as He, ci as xt, cj as Ct, ck as Nt, cl as kt, cm as St, cn as Dt, co as It, cp as wt, cq as fe, cr as Tt, cs as Le, ct as Vt, cu as Ft, cv as Lt } from "./index-C2c-_lPE.js";
2
+ import { jsx as t, jsxs as i, Fragment as X } from "react/jsx-runtime";
3
+ import { u as Et, a as xe } from "./use-visual-utils-OPk_1t4I.js";
4
+ import { useMemo as E, useState as j, useRef as At, useCallback as _, useEffect as be, Fragment as qt } from "react";
5
+ /**
6
+ * @license lucide-react v0.453.0 - ISC
7
+ *
8
+ * This source code is licensed under the ISC license.
9
+ * See the LICENSE file in the root directory of this source tree.
10
+ */
11
+ const Ht = ae("CircleX", [
12
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
13
+ ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
14
+ ["path", { d: "m9 9 6 6", key: "z0biqf" }]
15
+ ]);
16
+ /**
17
+ * @license lucide-react v0.453.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */
22
+ const Ot = ae("Library", [
23
+ ["path", { d: "m16 6 4 14", key: "ji33uf" }],
24
+ ["path", { d: "M12 6v14", key: "1n7gus" }],
25
+ ["path", { d: "M8 8v12", key: "1gg7y9" }],
26
+ ["path", { d: "M4 4v16", key: "6qkkli" }]
27
+ ]);
28
+ /**
29
+ * @license lucide-react v0.453.0 - ISC
30
+ *
31
+ * This source code is licensed under the ISC license.
32
+ * See the LICENSE file in the root directory of this source tree.
33
+ */
34
+ const _t = ae("Link2", [
35
+ ["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
36
+ ["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
37
+ ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
38
+ ]);
39
+ /**
40
+ * @license lucide-react v0.453.0 - ISC
41
+ *
42
+ * This source code is licensed under the ISC license.
43
+ * See the LICENSE file in the root directory of this source tree.
44
+ */
45
+ const Ye = ae("Save", [
46
+ [
47
+ "path",
48
+ {
49
+ d: "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",
50
+ key: "1c8476"
51
+ }
52
+ ],
53
+ ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
54
+ ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
55
+ ]);
56
+ function Xe() {
57
+ var r, x;
58
+ const s = S((y) => y.card), l = S((y) => y.frame), n = E(
59
+ () => qe(l, s),
60
+ [l, s]
61
+ ), { manifest: o } = et(
62
+ ((r = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : r.url) || ""
63
+ ), m = E(
64
+ () => {
65
+ var y;
66
+ return (y = o == null ? void 0 : o.visuals) == null ? void 0 : y.find(
67
+ (f) => {
68
+ var v;
69
+ return f.name === ((v = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : v.componentName);
70
+ }
71
+ );
72
+ },
73
+ [o, (x = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : x.componentName]
74
+ ), b = tt(n, m), p = E(
75
+ () => at({
76
+ frame: l,
77
+ configCard: n,
78
+ isMultiInputVisual: b === "multiple"
79
+ }),
80
+ [l, n, b]
81
+ ), h = E(() => {
82
+ const y = p.findIndex(
83
+ (f) => (f == null ? void 0 : f.id) === s.id
84
+ );
85
+ return y < 0 ? -1 : st(s, y);
86
+ }, [p, s]);
87
+ return E(() => !n || b !== "multiple" || h < 0 ? s.type : lt(
88
+ s,
89
+ h,
90
+ m == null ? void 0 : m.slots
91
+ ) ?? s.type, [n, b, h, s, m == null ? void 0 : m.slots]);
92
+ }
93
+ function Yt({
94
+ type: s,
95
+ isLinked: l,
96
+ className: n,
97
+ showLabel: o = !1,
98
+ showLocal: m = !1
99
+ }) {
100
+ const b = ve((I) => I.selectedFrameId), p = rt((I) => I.selectedVisual), h = S((I) => I.frame);
101
+ let r;
102
+ if (s)
103
+ r = s;
104
+ else if (l !== void 0)
105
+ r = l ? "linked" : "library";
106
+ else if (!!!(h != null && h.visualId || p != null && p.id) && b)
107
+ r = "local";
108
+ else if (p && !b)
109
+ r = "library";
110
+ else if (h != null && h.visualId && b)
111
+ r = "linked";
112
+ else if (p != null && p.id && b)
113
+ r = "library";
114
+ else
115
+ return null;
116
+ if (r === "local" && !m)
117
+ return null;
118
+ const x = {
119
+ local: "border-slate-200/70 bg-slate-50/80 text-slate-700 shadow-sm hover:bg-slate-100/80 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:bg-slate-800/80",
120
+ linked: "border-purple-200/70 bg-gradient-to-r from-purple-50/50 to-purple-100/30 text-purple-900 shadow-sm hover:from-purple-100/60 hover:to-purple-100/50 hover:shadow-md dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100 dark:hover:from-purple-950/60 dark:hover:to-purple-900/50",
121
+ library: "border-blue-200/70 bg-gradient-to-r from-blue-50/50 to-blue-100/30 text-blue-900 shadow-sm hover:from-blue-100/60 hover:to-blue-100/50 hover:shadow-md dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100 dark:hover:from-blue-950/60 dark:hover:to-blue-900/50"
122
+ }, y = {
123
+ local: "Local to this dashboard: Changes made here only affect this dashboard copy.",
124
+ linked: "Linked to library: Changes made here update the library visual and all linked instances.",
125
+ library: "Library visual: Share and reuse this visual across multiple dashboards."
126
+ }, f = {
127
+ local: "border-slate-200 bg-slate-50 text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100",
128
+ linked: "border-purple-200 bg-purple-50 text-purple-900 dark:border-purple-800 dark:bg-purple-950 dark:text-purple-100",
129
+ library: "border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100"
130
+ }, v = {
131
+ local: "fill-slate-50 dark:fill-slate-900",
132
+ linked: "fill-purple-50 dark:fill-purple-950",
133
+ library: "fill-blue-50 dark:fill-blue-950"
134
+ }, C = {
135
+ local: /* @__PURE__ */ t("span", { className: "h-2 w-2 rounded-full bg-current/70" }),
136
+ linked: /* @__PURE__ */ t(_t, { className: "h-3.5 w-3.5" }),
137
+ library: /* @__PURE__ */ t(Ot, { className: "h-3.5 w-3.5" })
138
+ }, A = {
139
+ local: "Local",
140
+ linked: "Linked",
141
+ library: "Library"
142
+ };
143
+ return /* @__PURE__ */ t(nt, { children: /* @__PURE__ */ i(dt, { delayDuration: 300, children: [
144
+ /* @__PURE__ */ t(it, { asChild: !0, children: /* @__PURE__ */ i(
145
+ Z,
146
+ {
147
+ variant: "outline",
148
+ className: q(
149
+ "cursor-help select-none transition-all",
150
+ x[r],
151
+ n
152
+ ),
153
+ children: [
154
+ C[r],
155
+ o && /* @__PURE__ */ t("span", { className: "ml-1 text-xs font-medium leading-none", children: A[r] })
156
+ ]
157
+ }
158
+ ) }),
159
+ /* @__PURE__ */ i(
160
+ ot,
161
+ {
162
+ side: "bottom",
163
+ className: q("max-w-xs", f[r]),
164
+ children: [
165
+ /* @__PURE__ */ t(ct, { className: v[r] }),
166
+ /* @__PURE__ */ t("p", { children: y[r] })
167
+ ]
168
+ }
169
+ )
170
+ ] }) });
171
+ }
172
+ function Mt(s, l) {
173
+ return {
174
+ ...s,
175
+ sql: "",
176
+ python: "",
177
+ config: void 0,
178
+ customCfg: "",
179
+ preferences: {},
180
+ interactionConfig: void 0,
181
+ linkedInteractionTargetOverrides: void 0,
182
+ customCardPreferences: l ? s.customCardPreferences : void 0,
183
+ type: l ? s.type : "bar"
184
+ };
185
+ }
186
+ function Xt({
187
+ className: s,
188
+ variant: l = "outline"
189
+ }) {
190
+ var h;
191
+ const { setCardSql: n } = ee();
192
+ S((r) => r.frame);
193
+ const o = S((r) => r.card);
194
+ Et(
195
+ ((h = o.customCardPreferences) == null ? void 0 : h.url) || ""
196
+ ), S(
197
+ (r) => r.selectedSchemaName
198
+ ), S(
199
+ (r) => r.selectedDatamodelId
200
+ ), S(
201
+ (r) => r.selectedDatabaseName
202
+ ), S((r) => r.selectedTableName), S(
203
+ (r) => r.selectedConnectionId
204
+ ), S((r) => r.isShowingVisual), o.sql;
205
+ const m = S((r) => r.onSave), { getUpdatedFrame: b } = xe();
206
+ function p() {
207
+ const r = b();
208
+ m == null || m(r);
209
+ }
210
+ return /* @__PURE__ */ i(
211
+ w,
212
+ {
213
+ onClick: p,
214
+ className: q("h-8", s),
215
+ size: "sm",
216
+ variant: l,
217
+ children: [
218
+ /* @__PURE__ */ t(ut, { className: "mr-2 size-4 font-bold" }),
219
+ "Accept"
220
+ ]
221
+ }
222
+ );
223
+ }
224
+ function Gt({
225
+ className: s,
226
+ variant: l = "default"
227
+ }) {
228
+ const n = se(), [o, m] = j(!1), b = ve(
229
+ (v) => v.actions.setIsDashboardPanelOpen
230
+ ), { setIsVisualEditing: p } = Oe(), { getUpdatedFrame: h } = xe(), r = _e(), x = S((v) => v.frame), y = Me();
231
+ return /* @__PURE__ */ i(
232
+ w,
233
+ {
234
+ onClick: () => {
235
+ const v = h(), C = (x == null ? void 0 : x.visualId) || (r == null ? void 0 : r.id);
236
+ if (!C) {
237
+ Q.error("No visual to save");
238
+ return;
239
+ }
240
+ m(!0), y.mutate(
241
+ {
242
+ visualId: C,
243
+ data: {
244
+ frameObject: v
245
+ }
246
+ },
247
+ {
248
+ onSuccess: () => {
249
+ m(!1), b(!0), Q.success("Visual updated successfully"), n.invalidateQueries({
250
+ queryKey: ["resource-by-id", "visual", C],
251
+ exact: !0
252
+ });
253
+ },
254
+ onError: () => {
255
+ m(!1), Q.error("Failed to update visual");
256
+ }
257
+ }
258
+ );
259
+ },
260
+ className: q("h-8", s),
261
+ size: "sm",
262
+ variant: l,
263
+ children: [
264
+ o && /* @__PURE__ */ i(X, { children: [
265
+ /* @__PURE__ */ t(ze, { className: "mr-2 size-4 animate-spin font-bold" }),
266
+ " Saving"
267
+ ] }),
268
+ !o && /* @__PURE__ */ i(X, { children: [
269
+ /* @__PURE__ */ t(Ye, { className: "mr-2 size-4 font-bold" }),
270
+ "Save to Library"
271
+ ] })
272
+ ]
273
+ }
274
+ );
275
+ }
276
+ function Wt({
277
+ className: s
278
+ }) {
279
+ const l = se(), [n, o] = j(!1), m = _e(), b = S((v) => v.frame), p = ve((v) => v.selectedSheetId), { updateFrame: h, setIsVisualEditing: r } = Oe(), { getUpdatedFrame: x } = xe(), y = Me();
280
+ return /* @__PURE__ */ t(
281
+ w,
282
+ {
283
+ onClick: async () => {
284
+ if (!p) {
285
+ Q.error("No sheet selected");
286
+ return;
287
+ }
288
+ const v = (b == null ? void 0 : b.visualId) || (m == null ? void 0 : m.id);
289
+ if (!v) {
290
+ Q.error("No visual to update");
291
+ return;
292
+ }
293
+ o(!0);
294
+ try {
295
+ const C = x();
296
+ await y.mutateAsync({
297
+ visualId: v,
298
+ data: {
299
+ frameObject: C
300
+ }
301
+ });
302
+ const A = {
303
+ ...C,
304
+ visualId: v
305
+ // Keep the link to library visual
306
+ };
307
+ h(p, A), l.invalidateQueries({ queryKey: ["visuals"] }), l.invalidateQueries({ queryKey: ["visual", v] }), Q.success("Saved to library and applied locally"), setTimeout(() => {
308
+ r(!1);
309
+ }, 300);
310
+ } catch (C) {
311
+ console.error("Failed to save and apply:", C), Q.error("Failed to save and apply changes");
312
+ } finally {
313
+ o(!1);
314
+ }
315
+ },
316
+ className: q("h-8", s),
317
+ size: "sm",
318
+ variant: "default",
319
+ disabled: n,
320
+ children: n ? /* @__PURE__ */ i(X, { children: [
321
+ /* @__PURE__ */ t(ze, { className: "mr-2 size-4 animate-spin font-bold" }),
322
+ " Saving..."
323
+ ] }) : /* @__PURE__ */ i(X, { children: [
324
+ /* @__PURE__ */ t(Ye, { className: "mr-2 size-4 font-bold" }),
325
+ "Save & Apply"
326
+ ] })
327
+ }
328
+ );
329
+ }
330
+ function Jt({ className: s }) {
331
+ const { setTempQueryData: l, setSqlGen: n } = ee(), o = se(), m = S((f) => f.tempQueryData), b = S((f) => f.onClose), p = S((f) => f.card), h = Xe(), r = E(() => h !== p.type ? { ...p, type: h } : p, [p, h]), { queryKey: x } = Be(r);
332
+ function y() {
333
+ if (m) {
334
+ const { queryKey: f, queryData: v } = m;
335
+ f && v && o.setQueryData(f, v);
336
+ }
337
+ n({}), b == null || b();
338
+ }
339
+ return /* @__PURE__ */ i(
340
+ w,
341
+ {
342
+ onClick: y,
343
+ className: q("h-8", s),
344
+ size: "sm",
345
+ variant: "outline",
346
+ children: [
347
+ /* @__PURE__ */ t(Qe, { className: "mr-2 size-4" }),
348
+ "Close"
349
+ ]
350
+ }
351
+ );
352
+ }
353
+ function Pt({
354
+ label: s = "Clear",
355
+ variant: l = "secondary",
356
+ className: n
357
+ } = {}) {
358
+ const { setTempQueryData: o } = ee(), m = se(), b = S((a) => a.tempQueryData), p = S((a) => a.card), h = Xe(), r = E(() => h !== p.type ? { ...p, type: h } : p, [p, h]), { queryKey: x } = Be(r), {
359
+ setCardSql: y,
360
+ setSqlGen: f,
361
+ setCardPython: v,
362
+ setCardCustomCfg: C,
363
+ setCardPreferences: A,
364
+ clearQueryConfig: I,
365
+ setCardConfig: le,
366
+ setCardType: re,
367
+ setFrame: G,
368
+ setCard: $,
369
+ setActiveTabCardId: ne
370
+ } = ee();
371
+ function U() {
372
+ var z, W, H, F;
373
+ const a = m.getQueryData(x);
374
+ b != null && b.queryData || o({
375
+ queryKey: x,
376
+ queryData: a
377
+ }), m.setQueryData(x, null), m.removeQueries({ queryKey: x, exact: !0 }), y(""), f({}), I(), le(void 0), v(""), C(""), A({});
378
+ const D = S.getState().frame, K = S.getState().card, V = qe(D, K), T = ((z = V == null ? void 0 : V.customCardPreferences) == null ? void 0 : z.visualType) === "multiple" || !!((W = V == null ? void 0 : V.customCardPreferences) != null && W.dataInputCardIds) || (((H = V == null ? void 0 : V.customCardPreferences) == null ? void 0 : H.minInputs) || 0) > 1 || (((F = V == null ? void 0 : V.customCardPreferences) == null ? void 0 : F.maxInputs) || 0) > 1, M = Mt(K, T);
379
+ G({
380
+ ...D,
381
+ cards: D.cards.map(
382
+ (O) => O.id === M.id ? M : O
383
+ )
384
+ }), ne(M.id), $(M), T || re("bar");
385
+ }
386
+ return /* @__PURE__ */ i(
387
+ w,
388
+ {
389
+ onClick: U,
390
+ className: q("h-8", n),
391
+ size: "sm",
392
+ variant: l,
393
+ children: [
394
+ /* @__PURE__ */ t(Qe, { className: "mr-2 size-3.5" }),
395
+ s
396
+ ]
397
+ }
398
+ );
399
+ }
400
+ function Ge(s) {
401
+ const { control: l, onChange: n } = s;
402
+ return /* @__PURE__ */ i("div", { className: "space-y-1", children: [
403
+ /* @__PURE__ */ t(R, { className: "text-xs", children: "Label" }),
404
+ /* @__PURE__ */ i("div", { className: "relative", children: [
405
+ /* @__PURE__ */ t(
406
+ Re,
407
+ {
408
+ className: "pr-40",
409
+ value: l.label,
410
+ placeholder: "Control label",
411
+ onChange: (o) => n(o.target.value)
412
+ }
413
+ ),
414
+ /* @__PURE__ */ t(
415
+ Z,
416
+ {
417
+ variant: "outline",
418
+ className: "pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-xs",
419
+ children: ge(l.type).label
420
+ }
421
+ )
422
+ ] })
423
+ ] });
424
+ }
425
+ function zt(s) {
426
+ const { currentStep: l, labels: n } = s;
427
+ return /* @__PURE__ */ t("div", { className: "sticky top-0 z-10 -mx-1 border-b bg-background/95 px-1 pb-2 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85", children: /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3", children: n.map((o, m) => {
428
+ const b = m + 1, p = b === l, h = b < l;
429
+ return /* @__PURE__ */ i(qt, { children: [
430
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
431
+ /* @__PURE__ */ t(
432
+ "span",
433
+ {
434
+ className: q(
435
+ "flex h-7 w-7 items-center justify-center rounded-full border text-[11px] font-semibold",
436
+ p ? "border-primary bg-primary text-primary-foreground" : h ? "border-primary/25 bg-primary/10 text-primary" : "border-border bg-muted/30 text-muted-foreground"
437
+ ),
438
+ children: b
439
+ }
440
+ ),
441
+ /* @__PURE__ */ t(
442
+ "span",
443
+ {
444
+ className: q(
445
+ "text-xs font-medium",
446
+ p ? "text-foreground" : "text-muted-foreground"
447
+ ),
448
+ children: o
449
+ }
450
+ )
451
+ ] }),
452
+ m < n.length - 1 ? /* @__PURE__ */ t(
453
+ "span",
454
+ {
455
+ className: "h-px w-5 bg-border/80 sm:w-8",
456
+ "aria-hidden": "true"
457
+ }
458
+ ) : null
459
+ ] }, o);
460
+ }) }) });
461
+ }
462
+ function te(s) {
463
+ const { secondary: l, tertiary: n, primary: o } = s;
464
+ return /* @__PURE__ */ i("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: [
465
+ l,
466
+ n,
467
+ o
468
+ ] });
469
+ }
470
+ function Bt(s) {
471
+ const { control: l, scope: n, detail: o } = s;
472
+ return /* @__PURE__ */ i("div", { className: "flex items-start gap-3 rounded-xl border border-border/40 bg-muted/20 p-3", children: [
473
+ /* @__PURE__ */ t(Ft, { className: "mt-0.5 h-4 w-4 text-emerald-600" }),
474
+ /* @__PURE__ */ i("div", { className: "space-y-1", children: [
475
+ /* @__PURE__ */ t("div", { className: "text-sm font-medium", children: l.label }),
476
+ /* @__PURE__ */ i("div", { className: "text-xs text-muted-foreground", children: [
477
+ ge(l.type).label,
478
+ " ·",
479
+ " ",
480
+ Ue(l),
481
+ " ·",
482
+ " ",
483
+ je(n, l.placement)
484
+ ] }),
485
+ o ? /* @__PURE__ */ t("div", { className: "text-xs text-muted-foreground", children: o }) : null
486
+ ] })
487
+ ] });
488
+ }
489
+ function ye(s) {
490
+ const { title: l, children: n, className: o } = s;
491
+ return /* @__PURE__ */ i(
492
+ "div",
493
+ {
494
+ className: q(
495
+ "space-y-1 rounded-xl border border-border/40 bg-muted/20 p-3",
496
+ o
497
+ ),
498
+ children: [
499
+ /* @__PURE__ */ t("div", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: l }),
500
+ n
501
+ ]
502
+ }
503
+ );
504
+ }
505
+ function Qt(s) {
506
+ const { createdReference: l, description: n } = s;
507
+ return /* @__PURE__ */ i(ye, { title: "SQL cards", className: "space-y-2", children: [
508
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between gap-2 rounded-md border border-border/30 bg-muted/40 px-3 py-2", children: [
509
+ /* @__PURE__ */ t("code", { className: "min-w-0 truncate text-xs", children: l }),
510
+ /* @__PURE__ */ t(
511
+ Lt,
512
+ {
513
+ text: l,
514
+ ariaLabel: "Copy SQL control reference"
515
+ }
516
+ )
517
+ ] }),
518
+ /* @__PURE__ */ t("p", { className: "text-[11px] text-muted-foreground", children: n })
519
+ ] });
520
+ }
521
+ function Ee(s) {
522
+ const {
523
+ control: l,
524
+ defaultValue: n,
525
+ availableFieldChoices: o,
526
+ availableMetricChoices: m,
527
+ onControlChange: b,
528
+ onLabelChange: p,
529
+ onDefaultValueChange: h,
530
+ onBack: r,
531
+ onNext: x,
532
+ nextDisabled: y
533
+ } = s;
534
+ return /* @__PURE__ */ i("div", { className: "space-y-3", children: [
535
+ /* @__PURE__ */ t(Ge, { control: l, onChange: p }),
536
+ /* @__PURE__ */ t(
537
+ Ke,
538
+ {
539
+ control: l,
540
+ availableFieldChoices: o,
541
+ availableMetricChoices: m,
542
+ onChange: b
543
+ }
544
+ ),
545
+ /* @__PURE__ */ t(
546
+ He,
547
+ {
548
+ control: l,
549
+ value: n,
550
+ onChange: h,
551
+ allowCardDefault: !0,
552
+ hint: "This is the value viewers will see first."
553
+ }
554
+ ),
555
+ /* @__PURE__ */ t(
556
+ te,
557
+ {
558
+ secondary: /* @__PURE__ */ t(w, { type: "button", variant: "outline", onClick: r, children: "Back" }),
559
+ primary: /* @__PURE__ */ t(w, { type: "button", onClick: x, disabled: y, children: "Next" })
560
+ }
561
+ )
562
+ ] });
563
+ }
564
+ function Ae(s) {
565
+ const {
566
+ control: l,
567
+ scope: n,
568
+ createdReference: o,
569
+ explorerContent: m,
570
+ sqlDescription: b,
571
+ summaryDetail: p,
572
+ onBack: h,
573
+ onCancel: r,
574
+ onDone: x
575
+ } = s;
576
+ return /* @__PURE__ */ i("div", { className: "space-y-4", children: [
577
+ /* @__PURE__ */ t(
578
+ Bt,
579
+ {
580
+ control: l,
581
+ scope: n,
582
+ detail: p
583
+ }
584
+ ),
585
+ /* @__PURE__ */ i("div", { className: "space-y-2", children: [
586
+ /* @__PURE__ */ t("p", { className: "text-sm font-medium", children: "How cards use this control" }),
587
+ m,
588
+ /* @__PURE__ */ t(
589
+ Qt,
590
+ {
591
+ createdReference: o,
592
+ description: b
593
+ }
594
+ )
595
+ ] }),
596
+ /* @__PURE__ */ t(
597
+ te,
598
+ {
599
+ secondary: /* @__PURE__ */ t(w, { type: "button", variant: "outline", onClick: h, children: "Back" }),
600
+ tertiary: /* @__PURE__ */ t(w, { type: "button", variant: "outline", onClick: r, children: "Cancel" }),
601
+ primary: /* @__PURE__ */ t(w, { type: "button", onClick: x, children: "Done" })
602
+ }
603
+ )
604
+ ] });
605
+ }
606
+ function jt(s) {
607
+ const l = J(
608
+ s.scope,
609
+ s.existingControls,
610
+ s.reservedIds
611
+ ), n = s.type === l.type ? {
612
+ ...l,
613
+ label: fe[s.type]
614
+ } : {
615
+ ...$e({
616
+ controls: [
617
+ {
618
+ ...l,
619
+ label: fe[s.type]
620
+ }
621
+ ],
622
+ controlId: l.id,
623
+ nextType: s.type
624
+ }).controls[0],
625
+ label: fe[s.type]
626
+ };
627
+ return {
628
+ step: 2,
629
+ control: n,
630
+ defaultValue: P(n, void 0)
631
+ };
632
+ }
633
+ function Zt({
634
+ scope: s,
635
+ controls: l,
636
+ reservedControlIds: n,
637
+ defaultValues: o,
638
+ onChange: m,
639
+ emptyMessage: b,
640
+ initialCreateFlow: p = !1,
641
+ usageByControlId: h,
642
+ availableFieldChoices: r,
643
+ availableMetricChoices: x,
644
+ structuralParticipants: y,
645
+ structuralParticipantIdsByControlId: f,
646
+ card: v,
647
+ onCreateFlowActiveChange: C,
648
+ onCreateFlowComplete: A
649
+ }) {
650
+ const I = E(
651
+ () => new Set(n || []),
652
+ [n]
653
+ ), le = vt(s), re = mt(s), [G, $] = j(
654
+ null
655
+ ), [ne, U] = j(
656
+ null
657
+ ), [a, D] = j(
658
+ () => p ? {
659
+ step: 1,
660
+ control: J(s, l, Array.from(I))
661
+ } : null
662
+ ), K = At(p), V = E(
663
+ () => Ie({ scope: s, card: v }),
664
+ [v, s]
665
+ ), T = _(
666
+ (e) => s === "dashboard" && (e === "field_selector" || e === "metric_selector"),
667
+ [s]
668
+ ), M = E(
669
+ () => a ? we(
670
+ y || [],
671
+ a.control.type
672
+ ) : [],
673
+ [a, y]
674
+ ), z = E(() => {
675
+ if (!a)
676
+ return {
677
+ fields: r || [],
678
+ metrics: x || []
679
+ };
680
+ if (!T(a.control.type))
681
+ return {
682
+ fields: r || [],
683
+ metrics: x || []
684
+ };
685
+ const e = a.selectedCardIds || [], u = oe({
686
+ controlType: a.control.type,
687
+ participants: y || [],
688
+ selectedCardIds: e
689
+ });
690
+ return {
691
+ fields: a.control.type === "field_selector" ? u.choices.map((c) => ({
692
+ option: c,
693
+ target: u.fieldTargetMap[c.value]
694
+ })) : [],
695
+ metrics: a.control.type === "metric_selector" ? u.choices.map((c) => ({
696
+ option: c,
697
+ target: u.metricTargetMap[c.value]
698
+ })) : []
699
+ };
700
+ }, [
701
+ r,
702
+ x,
703
+ a,
704
+ T,
705
+ y
706
+ ]);
707
+ be(() => {
708
+ C == null || C(!!a);
709
+ }, [a, C]), be(() => {
710
+ const e = p && !K.current;
711
+ K.current = p, e && (D({
712
+ step: 1,
713
+ control: J(s, l, Array.from(I))
714
+ }), U(null), $(null));
715
+ }, [l, p, I, s]);
716
+ const W = (e) => {
717
+ if (!T(e.type))
718
+ return {
719
+ fields: r || [],
720
+ metrics: x || []
721
+ };
722
+ const u = (f == null ? void 0 : f[e.id]) || [];
723
+ if (u.length === 0)
724
+ return {
725
+ fields: r || [],
726
+ metrics: x || []
727
+ };
728
+ const c = oe({
729
+ controlType: e.type,
730
+ participants: y || [],
731
+ selectedCardIds: u
732
+ });
733
+ return {
734
+ fields: e.type === "field_selector" ? c.choices.map((g) => ({
735
+ option: g,
736
+ target: c.fieldTargetMap[g.value]
737
+ })) : [],
738
+ metrics: e.type === "metric_selector" ? c.choices.map((g) => ({
739
+ option: g,
740
+ target: c.metricTargetMap[g.value]
741
+ })) : []
742
+ };
743
+ }, H = (e) => {
744
+ if (!T(e.control.type))
745
+ return {
746
+ nextControl: e.control,
747
+ cardBindingsById: void 0
748
+ };
749
+ const u = (f == null ? void 0 : f[e.control.id]) || [], c = oe({
750
+ controlType: e.control.type,
751
+ participants: y || [],
752
+ selectedCardIds: e.nextSelectedCardIds
753
+ }), g = Vt({
754
+ control: e.control,
755
+ choices: c.choices
756
+ }), N = Object.fromEntries(
757
+ u.filter((d) => !e.nextSelectedCardIds.includes(d)).map((d) => [d, void 0])
758
+ );
759
+ return e.nextSelectedCardIds.length > 0 && g.source.kind === "manual" && g.source.options.length > 0 && Object.assign(
760
+ N,
761
+ Le({
762
+ control: g,
763
+ participants: y || [],
764
+ selectedCardIds: e.nextSelectedCardIds
765
+ })
766
+ ), {
767
+ nextControl: g,
768
+ cardBindingsById: N
769
+ };
770
+ }, F = _((e, u = o, c = { type: "update" }) => {
771
+ m(e, u, c);
772
+ }, [o, m]), O = (e, u) => {
773
+ const c = l.find(
774
+ (L) => L.id === e
775
+ );
776
+ let g = l.map((L) => L.id !== e ? L : u(L));
777
+ const N = g.find(
778
+ (L) => L.id === e
779
+ );
780
+ let d, k;
781
+ if (N && s === "dashboard" && (N.type === "field_selector" || N.type === "metric_selector")) {
782
+ const L = (f == null ? void 0 : f[N.id]) || [], B = H({
783
+ control: N,
784
+ nextSelectedCardIds: L
785
+ });
786
+ g = g.map(
787
+ (De) => De.id === e ? B.nextControl : De
788
+ ), d = B.cardBindingsById, k = [N.id];
789
+ } else if (c && s === "dashboard" && (c.type === "field_selector" || c.type === "metric_selector")) {
790
+ const L = (f == null ? void 0 : f[c.id]) || [];
791
+ d = Object.fromEntries(
792
+ L.map((B) => [B, void 0])
793
+ ), k = [c.id];
794
+ }
795
+ F(g, o, {
796
+ type: "update",
797
+ cardBindingsById: d,
798
+ affectedBindingControlIds: k
799
+ });
800
+ }, We = (e, u) => {
801
+ const c = u.trim();
802
+ if (c.length === 0 || c === e || I.has(c) || l.some(
803
+ (d) => d.id === c && d.id !== e
804
+ ))
805
+ return;
806
+ const g = l.map(
807
+ (d) => d.id === e ? { ...d, id: c } : d
808
+ );
809
+ if (!o) {
810
+ F(g, void 0, {
811
+ type: "rename",
812
+ oldId: e,
813
+ newId: c
814
+ });
815
+ return;
816
+ }
817
+ const N = { ...o };
818
+ Object.prototype.hasOwnProperty.call(N, e) && (N[c] = N[e], delete N[e]), F(g, N, {
819
+ type: "rename",
820
+ oldId: e,
821
+ newId: c
822
+ });
823
+ }, Je = (e) => {
824
+ const u = l.filter((g) => g.id !== e);
825
+ if (!o) {
826
+ F(u, void 0, { type: "remove", controlId: e });
827
+ return;
828
+ }
829
+ const c = { ...o };
830
+ delete c[e], F(u, c, { type: "remove", controlId: e });
831
+ }, Pe = _(() => {
832
+ D({
833
+ step: 1,
834
+ control: J(s, l, Array.from(I))
835
+ }), U(null), $(null);
836
+ }, [l, I, s]), Y = (e) => {
837
+ D(
838
+ (u) => u && {
839
+ ...u,
840
+ control: e(u.control)
841
+ }
842
+ );
843
+ }, Ce = (e) => {
844
+ D(
845
+ (u) => u && {
846
+ ...u,
847
+ defaultValue: e
848
+ }
849
+ );
850
+ }, de = (() => {
851
+ if (!a)
852
+ return !1;
853
+ if (a.step === 2 && T(a.control.type))
854
+ return (a.selectedCardIds || []).length > 0;
855
+ if (a.step !== 2 && a.step !== 3 || !a.control.label.trim())
856
+ return !1;
857
+ const u = Te(a.control);
858
+ return u.source.kind === "manual" && (pt(u) && u.source.options.length === 0 || u.source.options.some(
859
+ (g) => g.label.trim().length === 0 || g.value.trim().length === 0
860
+ )) ? !1 : ht(
861
+ P(u, a.defaultValue)
862
+ );
863
+ })(), Ne = () => {
864
+ var d;
865
+ if (!a)
866
+ return;
867
+ const e = Te(a.control), u = Tt({
868
+ label: e.label,
869
+ fallbackId: e.id,
870
+ existingControls: l,
871
+ reservedIds: Array.from(I)
872
+ }), c = {
873
+ ...e,
874
+ id: u
875
+ }, g = s === "dashboard" && (c.type === "field_selector" || c.type === "metric_selector") && ((d = a.selectedCardIds) != null && d.length) ? Le({
876
+ control: c,
877
+ participants: y || [],
878
+ selectedCardIds: a.selectedCardIds
879
+ }) : void 0, N = P(
880
+ c,
881
+ a.defaultValue
882
+ );
883
+ D({
884
+ step: s === "dashboard" && (c.type === "field_selector" || c.type === "metric_selector") ? 4 : 3,
885
+ control: c,
886
+ defaultValue: N,
887
+ createdControlId: u,
888
+ selectedCardIds: a.selectedCardIds,
889
+ cardBindingsById: g
890
+ });
891
+ }, ie = _(() => {
892
+ D(null);
893
+ }, []), ke = _(() => {
894
+ if (!(a != null && a.createdControlId)) {
895
+ D(null);
896
+ return;
897
+ }
898
+ const e = a.control, u = a.createdControlId, c = P(
899
+ e,
900
+ a.defaultValue
901
+ );
902
+ o ? F(
903
+ [...l, e],
904
+ {
905
+ ...o,
906
+ [u]: c
907
+ },
908
+ {
909
+ type: "add",
910
+ cardBindingsById: a.cardBindingsById
911
+ }
912
+ ) : F(
913
+ [
914
+ ...l,
915
+ {
916
+ ...e,
917
+ defaultValue: c
918
+ }
919
+ ],
920
+ void 0,
921
+ {
922
+ type: "add",
923
+ cardBindingsById: a.cardBindingsById
924
+ }
925
+ ), U(u), D(null), A == null || A();
926
+ }, [l, a, o, F, A]), Ze = a ? T(a.control.type) ? ["Choose type", "Select cards", "Configure", "Finish"] : ["Choose type", "Configure", "Finish"] : [], Se = a != null && a.createdControlId ? `[[param.${a.createdControlId}]]` : a ? `[[param.${ft(a.control.label) || a.control.id}]]` : "";
927
+ return /* @__PURE__ */ i("div", { className: "space-y-4", children: [
928
+ a ? /* @__PURE__ */ i("div", { className: "space-y-4 pb-1", children: [
929
+ /* @__PURE__ */ t(
930
+ zt,
931
+ {
932
+ currentStep: a.step,
933
+ labels: Ze
934
+ }
935
+ ),
936
+ a.step === 1 && /* @__PURE__ */ i("div", { className: "space-y-4", children: [
937
+ /* @__PURE__ */ i("div", { children: [
938
+ /* @__PURE__ */ t("p", { className: "text-sm font-medium", children: "What kind of input should viewers see?" }),
939
+ /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground", children: "Choose the viewer experience first. You can fine-tune the details next." }),
940
+ s === "card" && (v == null ? void 0 : v.sql) == null ? /* @__PURE__ */ t("p", { className: "mt-1 text-xs text-muted-foreground", children: "Explorer cards support displayed metric, group by field, aggregation, and time grain controls here." }) : null
941
+ ] }),
942
+ /* @__PURE__ */ t("div", { className: "grid gap-3 sm:grid-cols-2", children: V.map((e) => /* @__PURE__ */ i(
943
+ "button",
944
+ {
945
+ type: "button",
946
+ className: "rounded-xl border border-border/50 bg-muted/20 p-3 text-left transition-colors hover:border-border/70 hover:bg-muted/35",
947
+ onClick: () => D(
948
+ jt({
949
+ scope: s,
950
+ existingControls: l,
951
+ reservedIds: Array.from(I),
952
+ type: e.value
953
+ })
954
+ ),
955
+ children: [
956
+ /* @__PURE__ */ t("div", { className: "text-sm font-medium", children: e.label }),
957
+ /* @__PURE__ */ t("p", { className: "mt-1 text-xs text-muted-foreground", children: e.description })
958
+ ]
959
+ },
960
+ e.value
961
+ )) }),
962
+ /* @__PURE__ */ t(
963
+ te,
964
+ {
965
+ secondary: /* @__PURE__ */ t(
966
+ w,
967
+ {
968
+ type: "button",
969
+ variant: "outline",
970
+ onClick: ie,
971
+ children: "Back to controls"
972
+ }
973
+ )
974
+ }
975
+ )
976
+ ] }),
977
+ a.step === 2 && T(a.control.type) && /* @__PURE__ */ i("div", { className: "space-y-3", children: [
978
+ /* @__PURE__ */ i("div", { className: "space-y-3", children: [
979
+ /* @__PURE__ */ t(
980
+ Ge,
981
+ {
982
+ control: a.control,
983
+ onChange: (e) => Y((u) => ({
984
+ ...u,
985
+ label: e
986
+ }))
987
+ }
988
+ ),
989
+ /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground", children: "Choose which cards should respond to this shared control." })
990
+ ] }),
991
+ M.length === 0 ? /* @__PURE__ */ t("div", { className: "rounded-xl bg-muted/20 p-3 text-xs text-muted-foreground", children: "No eligible cards are available yet. Add compatible metrics or group-by fields to cards first." }) : /* @__PURE__ */ t("div", { className: "space-y-2 rounded-xl bg-muted/20 p-3", children: M.map((e) => {
992
+ const u = (a.selectedCardIds || []).includes(e.cardId);
993
+ return /* @__PURE__ */ i(
994
+ "label",
995
+ {
996
+ className: "flex items-start gap-2 text-sm",
997
+ children: [
998
+ /* @__PURE__ */ t(
999
+ bt,
1000
+ {
1001
+ checked: u,
1002
+ onCheckedChange: (c) => D(
1003
+ (g) => g && {
1004
+ ...g,
1005
+ selectedCardIds: c === !0 ? [
1006
+ ...g.selectedCardIds || [],
1007
+ e.cardId
1008
+ ] : (g.selectedCardIds || []).filter(
1009
+ (N) => N !== e.cardId
1010
+ )
1011
+ }
1012
+ )
1013
+ }
1014
+ ),
1015
+ /* @__PURE__ */ i("div", { className: "min-w-0", children: [
1016
+ /* @__PURE__ */ t("div", { className: "font-medium", children: e.title }),
1017
+ /* @__PURE__ */ t("div", { className: "text-xs text-muted-foreground", children: a.control.type === "field_selector" ? `${e.fieldChoices.length} compatible group-by fields` : `${e.metricChoices.length} compatible metrics` })
1018
+ ] })
1019
+ ]
1020
+ },
1021
+ e.cardId
1022
+ );
1023
+ }) }),
1024
+ /* @__PURE__ */ t(
1025
+ te,
1026
+ {
1027
+ secondary: /* @__PURE__ */ t(
1028
+ w,
1029
+ {
1030
+ type: "button",
1031
+ variant: "outline",
1032
+ onClick: () => D(
1033
+ (e) => e && {
1034
+ ...e,
1035
+ step: 1,
1036
+ selectedCardIds: []
1037
+ }
1038
+ ),
1039
+ children: "Back"
1040
+ }
1041
+ ),
1042
+ primary: /* @__PURE__ */ t(
1043
+ w,
1044
+ {
1045
+ type: "button",
1046
+ onClick: () => D(
1047
+ (e) => e && {
1048
+ ...e,
1049
+ step: 3
1050
+ }
1051
+ ),
1052
+ disabled: !de,
1053
+ children: "Next"
1054
+ }
1055
+ )
1056
+ }
1057
+ )
1058
+ ] }),
1059
+ a.step === 2 && !T(a.control.type) && /* @__PURE__ */ t(
1060
+ Ee,
1061
+ {
1062
+ control: a.control,
1063
+ defaultValue: a.defaultValue,
1064
+ availableFieldChoices: z.fields,
1065
+ availableMetricChoices: z.metrics,
1066
+ onControlChange: (e) => Y(() => e),
1067
+ onLabelChange: (e) => Y((u) => ({
1068
+ ...u,
1069
+ label: e
1070
+ })),
1071
+ onDefaultValueChange: Ce,
1072
+ onBack: () => D(
1073
+ (e) => e && {
1074
+ ...e,
1075
+ step: 1
1076
+ }
1077
+ ),
1078
+ onNext: Ne,
1079
+ nextDisabled: !de
1080
+ }
1081
+ ),
1082
+ a.step === 3 && T(a.control.type) && /* @__PURE__ */ t(
1083
+ Ee,
1084
+ {
1085
+ control: a.control,
1086
+ defaultValue: a.defaultValue,
1087
+ availableFieldChoices: z.fields,
1088
+ availableMetricChoices: z.metrics,
1089
+ onControlChange: (e) => Y(() => e),
1090
+ onLabelChange: (e) => Y((u) => ({
1091
+ ...u,
1092
+ label: e
1093
+ })),
1094
+ onDefaultValueChange: Ce,
1095
+ onBack: () => D(
1096
+ (e) => e && {
1097
+ ...e,
1098
+ step: 2
1099
+ }
1100
+ ),
1101
+ onNext: Ne,
1102
+ nextDisabled: !de
1103
+ }
1104
+ ),
1105
+ a.step === 3 && !T(a.control.type) && /* @__PURE__ */ t(
1106
+ Ae,
1107
+ {
1108
+ control: a.control,
1109
+ scope: s,
1110
+ createdReference: Se,
1111
+ explorerContent: /* @__PURE__ */ t(ye, { title: "Explorer cards", children: /* @__PURE__ */ i("p", { className: "text-sm", children: [
1112
+ "Open the card and use",
1113
+ " ",
1114
+ /* @__PURE__ */ t("span", { className: "font-medium", children: "Settings → Controls" }),
1115
+ " ",
1116
+ "to choose what this control changes."
1117
+ ] }) }),
1118
+ sqlDescription: "Reference this control directly in the SQL editor.",
1119
+ onBack: () => D(
1120
+ (e) => e && {
1121
+ ...e,
1122
+ step: 2
1123
+ }
1124
+ ),
1125
+ onCancel: ie,
1126
+ onDone: ke
1127
+ }
1128
+ ),
1129
+ a.step === 4 && T(a.control.type) && /* @__PURE__ */ t(
1130
+ Ae,
1131
+ {
1132
+ control: a.control,
1133
+ scope: s,
1134
+ createdReference: Se,
1135
+ summaryDetail: /* @__PURE__ */ i(X, { children: [
1136
+ "Used by ",
1137
+ (a.selectedCardIds || []).length,
1138
+ " ",
1139
+ "selected card",
1140
+ (a.selectedCardIds || []).length === 1 ? "" : "s"
1141
+ ] }),
1142
+ explorerContent: /* @__PURE__ */ t(ye, { title: "Explorer cards", children: /* @__PURE__ */ t("p", { className: "text-sm", children: "Selected cards have been set up to respond to this control automatically." }) }),
1143
+ sqlDescription: "SQL cards can still reference this control directly in the SQL editor.",
1144
+ onBack: () => D(
1145
+ (e) => e && {
1146
+ ...e,
1147
+ step: 3
1148
+ }
1149
+ ),
1150
+ onCancel: ie,
1151
+ onDone: ke
1152
+ }
1153
+ )
1154
+ ] }) : null,
1155
+ !a && l.length === 0 ? /* @__PURE__ */ t("div", { className: "rounded-md border border-dashed p-3 text-sm text-muted-foreground", children: b }) : null,
1156
+ !a && l.map((e) => {
1157
+ const u = W(e), c = h == null ? void 0 : h[e.id], g = o && Object.prototype.hasOwnProperty.call(o, e.id) ? o[e.id] : e.defaultValue, N = ne === e.id;
1158
+ return /* @__PURE__ */ i("div", { className: "rounded-md border", children: [
1159
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-2 px-3 py-3", children: [
1160
+ /* @__PURE__ */ i(
1161
+ "button",
1162
+ {
1163
+ type: "button",
1164
+ className: "flex min-w-0 flex-1 items-start gap-2 text-left",
1165
+ onClick: () => U(
1166
+ (d) => d === e.id ? null : e.id
1167
+ ),
1168
+ children: [
1169
+ N ? /* @__PURE__ */ t(Ve, { className: "mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" }) : /* @__PURE__ */ t(Fe, { className: "mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" }),
1170
+ /* @__PURE__ */ i("div", { className: "min-w-0", children: [
1171
+ /* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-2", children: [
1172
+ /* @__PURE__ */ t("span", { className: "truncate text-sm font-medium", children: e.label || "Untitled control" }),
1173
+ /* @__PURE__ */ t(Z, { variant: "outline", className: "text-[11px]", children: ge(e.type).label }),
1174
+ /* @__PURE__ */ t(Z, { variant: "secondary", className: "text-[11px]", children: je(s, e.placement) })
1175
+ ] }),
1176
+ /* @__PURE__ */ i("div", { className: "mt-1 text-xs text-muted-foreground", children: [
1177
+ Ue(e),
1178
+ c != null && c.status ? ` · ${c.status}` : ""
1179
+ ] })
1180
+ ] })
1181
+ ]
1182
+ }
1183
+ ),
1184
+ /* @__PURE__ */ t(
1185
+ w,
1186
+ {
1187
+ type: "button",
1188
+ size: "icon",
1189
+ variant: "ghost",
1190
+ className: "h-8 w-8 shrink-0",
1191
+ onClick: () => Je(e.id),
1192
+ "aria-label": `Remove ${e.label}`,
1193
+ children: /* @__PURE__ */ t(yt, { className: "h-4 w-4" })
1194
+ }
1195
+ )
1196
+ ] }),
1197
+ N && /* @__PURE__ */ i("div", { className: "space-y-4 border-t px-3 py-4", children: [
1198
+ c != null && c.helper ? /* @__PURE__ */ t("div", { className: "rounded-md bg-muted/30 px-3 py-2 text-xs text-muted-foreground", children: c.helper }) : null,
1199
+ /* @__PURE__ */ i("div", { className: "grid gap-3 md:grid-cols-3", children: [
1200
+ /* @__PURE__ */ i("div", { className: "space-y-1.5", children: [
1201
+ /* @__PURE__ */ t(R, { className: "text-xs", children: "Label" }),
1202
+ /* @__PURE__ */ t(
1203
+ Re,
1204
+ {
1205
+ value: e.label,
1206
+ placeholder: "Control label",
1207
+ onChange: (d) => O(e.id, (k) => ({
1208
+ ...k,
1209
+ label: d.target.value
1210
+ }))
1211
+ }
1212
+ )
1213
+ ] }),
1214
+ /* @__PURE__ */ i("div", { className: "space-y-1.5", children: [
1215
+ /* @__PURE__ */ t(R, { className: "text-xs", children: "Type" }),
1216
+ /* @__PURE__ */ i(
1217
+ ce,
1218
+ {
1219
+ value: e.type,
1220
+ onValueChange: (d) => {
1221
+ const k = $e({
1222
+ controls: l,
1223
+ controlId: e.id,
1224
+ nextType: d,
1225
+ defaultValues: o
1226
+ });
1227
+ F(k.controls, k.defaultValues);
1228
+ },
1229
+ children: [
1230
+ /* @__PURE__ */ t(ue, { children: /* @__PURE__ */ t(me, {}) }),
1231
+ /* @__PURE__ */ t(pe, { children: Ie({
1232
+ scope: s,
1233
+ card: v,
1234
+ includeType: e.type
1235
+ }).map((d) => /* @__PURE__ */ t(he, { value: d.value, children: d.label }, d.value)) })
1236
+ ]
1237
+ }
1238
+ )
1239
+ ] }),
1240
+ /* @__PURE__ */ i("div", { className: "space-y-1.5", children: [
1241
+ /* @__PURE__ */ t(R, { className: "text-xs", children: "Show in" }),
1242
+ /* @__PURE__ */ i(
1243
+ ce,
1244
+ {
1245
+ value: e.placement || re,
1246
+ onValueChange: (d) => O(e.id, (k) => ({
1247
+ ...k,
1248
+ placement: d
1249
+ })),
1250
+ children: [
1251
+ /* @__PURE__ */ t(ue, { children: /* @__PURE__ */ t(me, {}) }),
1252
+ /* @__PURE__ */ t(pe, { children: le.map((d) => /* @__PURE__ */ t(he, { value: d.value, children: d.label }, d.value)) })
1253
+ ]
1254
+ }
1255
+ )
1256
+ ] })
1257
+ ] }),
1258
+ T(e.type) ? /* @__PURE__ */ t(
1259
+ gt,
1260
+ {
1261
+ type: e.type,
1262
+ participants: we(
1263
+ y || [],
1264
+ e.type
1265
+ ).map((d) => ({
1266
+ cardId: d.cardId,
1267
+ title: d.title,
1268
+ choiceCount: e.type === "field_selector" ? d.fieldChoices.length : d.metricChoices.length
1269
+ })),
1270
+ selectedCardIds: (f == null ? void 0 : f[e.id]) || [],
1271
+ onChange: (d) => {
1272
+ const k = H({
1273
+ control: e,
1274
+ nextSelectedCardIds: d
1275
+ }), L = l.map(
1276
+ (B) => B.id === e.id ? k.nextControl : B
1277
+ );
1278
+ F(L, o, {
1279
+ type: "update",
1280
+ cardBindingsById: k.cardBindingsById
1281
+ });
1282
+ }
1283
+ }
1284
+ ) : null,
1285
+ /* @__PURE__ */ t(
1286
+ Ke,
1287
+ {
1288
+ control: e,
1289
+ availableFieldChoices: u.fields,
1290
+ availableMetricChoices: u.metrics,
1291
+ onChange: (d) => O(e.id, () => d)
1292
+ }
1293
+ ),
1294
+ e.initialValueStrategy === "saved_default" && /* @__PURE__ */ t(
1295
+ He,
1296
+ {
1297
+ control: e,
1298
+ value: g,
1299
+ allowNoDefault: !0,
1300
+ allowCardDefault: !0,
1301
+ onChange: (d) => {
1302
+ if (o) {
1303
+ const k = { ...o };
1304
+ d === void 0 ? delete k[e.id] : k[e.id] = d, F(l, k);
1305
+ return;
1306
+ }
1307
+ O(e.id, (k) => ({
1308
+ ...k,
1309
+ defaultValue: d
1310
+ }));
1311
+ }
1312
+ }
1313
+ ),
1314
+ /* @__PURE__ */ i(
1315
+ xt,
1316
+ {
1317
+ open: G === e.id,
1318
+ onOpenChange: (d) => $(d ? e.id : null),
1319
+ children: [
1320
+ /* @__PURE__ */ t(Ct, { asChild: !0, children: /* @__PURE__ */ i(
1321
+ w,
1322
+ {
1323
+ type: "button",
1324
+ variant: "ghost",
1325
+ className: "h-auto px-0 text-xs text-muted-foreground hover:bg-transparent",
1326
+ children: [
1327
+ G === e.id ? /* @__PURE__ */ t(Ve, { className: "mr-1 h-4 w-4" }) : /* @__PURE__ */ t(Fe, { className: "mr-1 h-4 w-4" }),
1328
+ "Advanced"
1329
+ ]
1330
+ }
1331
+ ) }),
1332
+ /* @__PURE__ */ i(Nt, { className: "space-y-3 pt-2", children: [
1333
+ /* @__PURE__ */ i("div", { className: "grid gap-3 md:grid-cols-2", children: [
1334
+ /* @__PURE__ */ i("div", { className: "space-y-1.5", children: [
1335
+ /* @__PURE__ */ t(R, { className: "text-xs", children: "Control ID" }),
1336
+ /* @__PURE__ */ t(
1337
+ kt,
1338
+ {
1339
+ controlId: e.id,
1340
+ onCommit: (d) => We(e.id, d)
1341
+ },
1342
+ e.id
1343
+ )
1344
+ ] }),
1345
+ /* @__PURE__ */ i("div", { className: "space-y-1.5", children: [
1346
+ /* @__PURE__ */ t(R, { className: "text-xs", children: "Initial value" }),
1347
+ /* @__PURE__ */ i(
1348
+ ce,
1349
+ {
1350
+ value: e.initialValueStrategy,
1351
+ onValueChange: (d) => O(e.id, (k) => ({
1352
+ ...k,
1353
+ initialValueStrategy: d
1354
+ })),
1355
+ children: [
1356
+ /* @__PURE__ */ t(ue, { children: /* @__PURE__ */ t(me, {}) }),
1357
+ /* @__PURE__ */ t(pe, { children: St.map((d) => /* @__PURE__ */ t(
1358
+ he,
1359
+ {
1360
+ value: d.value,
1361
+ children: d.label
1362
+ },
1363
+ d.value
1364
+ )) })
1365
+ ]
1366
+ }
1367
+ ),
1368
+ /* @__PURE__ */ t("p", { className: "text-[11px] text-muted-foreground", children: Dt(
1369
+ e.initialValueStrategy
1370
+ ) })
1371
+ ] })
1372
+ ] }),
1373
+ /* @__PURE__ */ t(
1374
+ It,
1375
+ {
1376
+ control: e,
1377
+ onChange: (d) => O(e.id, () => d)
1378
+ }
1379
+ )
1380
+ ] })
1381
+ ]
1382
+ }
1383
+ )
1384
+ ] })
1385
+ ] }, e.id);
1386
+ }),
1387
+ !a && /* @__PURE__ */ i(
1388
+ w,
1389
+ {
1390
+ type: "button",
1391
+ variant: "outline",
1392
+ size: "sm",
1393
+ onClick: Pe,
1394
+ children: [
1395
+ /* @__PURE__ */ t(wt, { className: "mr-2 h-4 w-4" }),
1396
+ "Add control"
1397
+ ]
1398
+ }
1399
+ )
1400
+ ] });
1401
+ }
1402
+ function ea(s) {
1403
+ const { open: l, onOpenChange: n, initialCreateFlowActive: o = !1 } = s, m = l !== void 0, [b, p] = j(!1), [h, r] = j(
1404
+ o
1405
+ ), x = m ? l : b, y = _(
1406
+ (C) => {
1407
+ !C && h || (m || p(C), C || r(!1), n == null || n(C));
1408
+ },
1409
+ [m, h, n]
1410
+ ), f = _(() => {
1411
+ m || p(!1), r(!1), n == null || n(!1);
1412
+ }, [m, n]);
1413
+ be(() => {
1414
+ x || r(!1);
1415
+ }, [x]);
1416
+ const v = _(
1417
+ (C) => {
1418
+ h && C.preventDefault();
1419
+ },
1420
+ [h]
1421
+ );
1422
+ return {
1423
+ forceClose: f,
1424
+ handleOpenChange: y,
1425
+ isCreateFlowActive: h,
1426
+ preventPassiveDismissDuringCreate: v,
1427
+ resolvedOpen: x,
1428
+ setIsCreateFlowActive: r
1429
+ };
1430
+ }
1431
+ export {
1432
+ Ht as C,
1433
+ Xt as E,
1434
+ Ot as L,
1435
+ Ye as S,
1436
+ Yt as V,
1437
+ Gt as a,
1438
+ Wt as b,
1439
+ _t as c,
1440
+ Jt as d,
1441
+ Zt as e,
1442
+ Pt as f,
1443
+ Xe as g,
1444
+ ea as u
1445
+ };