react-semaphor 0.1.439 → 0.1.440

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