react-semaphor 0.0.167 → 0.0.168

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.
@@ -0,0 +1,4193 @@
1
+ import { P as M, b as S, j as e, Q as is, R as os, U as k, V as cs, W as ds, X as hs, Y as us, Z as _, _ as Q, $ as Bs, J as $s, O as Oe, a0 as At, a1 as Et, a2 as Lt, a3 as Dt, a4 as It, a5 as qt, a6 as Os, a7 as Ee, a8 as Qe, a9 as $e, T as We, e as ms, g as Pe, aa as xs, ab as ps, f as W, ac as fs, ad as gs, ae as js, af as Ke, ag as me, G as i, ah as Ie, ai as qe, aj as Vt, ak as Ve, w as Ks, v as Us, t as oe, al as Rt, r as _t, N as Gs, s as Ht, am as Bt, B as $t, an as Js, L as Le, S as bs, z as Kt, n as zs, A as as, u as Ye, ao as ye, ap as we, aq as Ut, ar as Gt, as as Jt, at as Qs, au as Ws, av as Ps, aw as Ys, ax as Xs, ay as Qt, az as Zs, aA as et, aB as Wt, aC as Pt, aD as Yt, aE as Xt, aF as Zt, aG as ns, aH as ea, aI as Be, aJ as Ms, aK as sa, aL as ta, aM as aa, aN as na, aO as ra, aP as ts, aQ as la, aR as Ts, aS as ia, aT as As, aU as oa, aV as ca, aW as da, aX as st, l as ha, C as ua, E as Es, d as ma, h as xa, i as pa, o as fa, aY as ga, m as ja, aZ as ba, a_ as ya, a$ as va, b0 as Ls, b1 as Na, b2 as Ds, b3 as Is, K as Ca, b4 as tt, b5 as Sa, b6 as at, b7 as Ue, b8 as nt, b9 as ka, ba as wa, bb as Fa, bc as Oa, bd as za, be as Ma, bf as ve, bg as q, bh as V, bi as ys, bj as R, bk as Ta, bl as Aa, bm as Ea, bn as qs, bo as La, bp as Da, bq as Ia, br as qa, bs as Va } from "./index-QmXfLUnb.js";
2
+ import ce, { useState as z, useEffect as $, useMemo as Ra, useRef as De } from "react";
3
+ /**
4
+ * @license lucide-react v0.379.0 - ISC
5
+ *
6
+ * This source code is licensed under the ISC license.
7
+ * See the LICENSE file in the root directory of this source tree.
8
+ */
9
+ const _a = M("Activity", [
10
+ [
11
+ "path",
12
+ {
13
+ d: "M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",
14
+ key: "169zse"
15
+ }
16
+ ]
17
+ ]);
18
+ /**
19
+ * @license lucide-react v0.379.0 - ISC
20
+ *
21
+ * This source code is licensed under the ISC license.
22
+ * See the LICENSE file in the root directory of this source tree.
23
+ */
24
+ const Ha = M("AreaChart", [
25
+ ["path", { d: "M3 3v18h18", key: "1s2lah" }],
26
+ ["path", { d: "M7 12v5h12V8l-5 5-4-4Z", key: "zxz28u" }]
27
+ ]);
28
+ /**
29
+ * @license lucide-react v0.379.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 vs = M("BarChart4", [
35
+ ["path", { d: "M3 3v18h18", key: "1s2lah" }],
36
+ ["path", { d: "M13 17V9", key: "1fwyjl" }],
37
+ ["path", { d: "M18 17V5", key: "sfb6ij" }],
38
+ ["path", { d: "M8 17v-3", key: "17ska0" }]
39
+ ]);
40
+ /**
41
+ * @license lucide-react v0.379.0 - ISC
42
+ *
43
+ * This source code is licensed under the ISC license.
44
+ * See the LICENSE file in the root directory of this source tree.
45
+ */
46
+ const Ba = M("Bookmark", [
47
+ ["path", { d: "m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z", key: "1fy3hk" }]
48
+ ]);
49
+ /**
50
+ * @license lucide-react v0.379.0 - ISC
51
+ *
52
+ * This source code is licensed under the ISC license.
53
+ * See the LICENSE file in the root directory of this source tree.
54
+ */
55
+ const $a = M("CircleX", [
56
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
57
+ ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
58
+ ["path", { d: "m9 9 6 6", key: "z0biqf" }]
59
+ ]);
60
+ /**
61
+ * @license lucide-react v0.379.0 - ISC
62
+ *
63
+ * This source code is licensed under the ISC license.
64
+ * See the LICENSE file in the root directory of this source tree.
65
+ */
66
+ const Ka = M("Database", [
67
+ ["ellipse", { cx: "12", cy: "5", rx: "9", ry: "3", key: "msslwz" }],
68
+ ["path", { d: "M3 5V19A9 3 0 0 0 21 19V5", key: "1wlel7" }],
69
+ ["path", { d: "M3 12A9 3 0 0 0 21 12", key: "mv7ke4" }]
70
+ ]);
71
+ /**
72
+ * @license lucide-react v0.379.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */
77
+ const Ua = M("Eraser", [
78
+ [
79
+ "path",
80
+ {
81
+ d: "m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",
82
+ key: "182aya"
83
+ }
84
+ ],
85
+ ["path", { d: "M22 21H7", key: "t4ddhn" }],
86
+ ["path", { d: "m5 11 9 9", key: "1mo9qw" }]
87
+ ]);
88
+ /**
89
+ * @license lucide-react v0.379.0 - ISC
90
+ *
91
+ * This source code is licensed under the ISC license.
92
+ * See the LICENSE file in the root directory of this source tree.
93
+ */
94
+ const rt = M("Filter", [
95
+ ["polygon", { points: "22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3", key: "1yg77f" }]
96
+ ]);
97
+ /**
98
+ * @license lucide-react v0.379.0 - ISC
99
+ *
100
+ * This source code is licensed under the ISC license.
101
+ * See the LICENSE file in the root directory of this source tree.
102
+ */
103
+ const Ga = M("Glasses", [
104
+ ["circle", { cx: "6", cy: "15", r: "4", key: "vux9w4" }],
105
+ ["circle", { cx: "18", cy: "15", r: "4", key: "18o8ve" }],
106
+ ["path", { d: "M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2", key: "1ag4bs" }],
107
+ ["path", { d: "M2.5 13 5 7c.7-1.3 1.4-2 3-2", key: "1hm1gs" }],
108
+ ["path", { d: "M21.5 13 19 7c-.7-1.3-1.5-2-3-2", key: "1r31ai" }]
109
+ ]);
110
+ /**
111
+ * @license lucide-react v0.379.0 - ISC
112
+ *
113
+ * This source code is licensed under the ISC license.
114
+ * See the LICENSE file in the root directory of this source tree.
115
+ */
116
+ const Ja = M("GripVertical", [
117
+ ["circle", { cx: "9", cy: "12", r: "1", key: "1vctgf" }],
118
+ ["circle", { cx: "9", cy: "5", r: "1", key: "hp0tcf" }],
119
+ ["circle", { cx: "9", cy: "19", r: "1", key: "fkjjf6" }],
120
+ ["circle", { cx: "15", cy: "12", r: "1", key: "1tmaij" }],
121
+ ["circle", { cx: "15", cy: "5", r: "1", key: "19l28e" }],
122
+ ["circle", { cx: "15", cy: "19", r: "1", key: "f4zoj3" }]
123
+ ]);
124
+ /**
125
+ * @license lucide-react v0.379.0 - ISC
126
+ *
127
+ * This source code is licensed under the ISC license.
128
+ * See the LICENSE file in the root directory of this source tree.
129
+ */
130
+ const Qa = M("Hammer", [
131
+ ["path", { d: "m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9", key: "eefl8a" }],
132
+ ["path", { d: "m18 15 4-4", key: "16gjal" }],
133
+ [
134
+ "path",
135
+ {
136
+ d: "m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",
137
+ key: "b7pghm"
138
+ }
139
+ ]
140
+ ]);
141
+ /**
142
+ * @license lucide-react v0.379.0 - ISC
143
+ *
144
+ * This source code is licensed under the ISC license.
145
+ * See the LICENSE file in the root directory of this source tree.
146
+ */
147
+ const Wa = M("Hash", [
148
+ ["line", { x1: "4", x2: "20", y1: "9", y2: "9", key: "4lhtct" }],
149
+ ["line", { x1: "4", x2: "20", y1: "15", y2: "15", key: "vyu0kd" }],
150
+ ["line", { x1: "10", x2: "8", y1: "3", y2: "21", key: "1ggp8o" }],
151
+ ["line", { x1: "16", x2: "14", y1: "3", y2: "21", key: "weycgp" }]
152
+ ]);
153
+ /**
154
+ * @license lucide-react v0.379.0 - ISC
155
+ *
156
+ * This source code is licensed under the ISC license.
157
+ * See the LICENSE file in the root directory of this source tree.
158
+ */
159
+ const Pa = M("Key", [
160
+ ["path", { d: "m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4", key: "g0fldk" }],
161
+ ["path", { d: "m21 2-9.6 9.6", key: "1j0ho8" }],
162
+ ["circle", { cx: "7.5", cy: "15.5", r: "5.5", key: "yqb3hr" }]
163
+ ]);
164
+ /**
165
+ * @license lucide-react v0.379.0 - ISC
166
+ *
167
+ * This source code is licensed under the ISC license.
168
+ * See the LICENSE file in the root directory of this source tree.
169
+ */
170
+ const Ns = M("LineChart", [
171
+ ["path", { d: "M3 3v18h18", key: "1s2lah" }],
172
+ ["path", { d: "m19 9-5 5-4-4-3 3", key: "2osh9i" }]
173
+ ]);
174
+ /**
175
+ * @license lucide-react v0.379.0 - ISC
176
+ *
177
+ * This source code is licensed under the ISC license.
178
+ * See the LICENSE file in the root directory of this source tree.
179
+ */
180
+ const Ya = M("ListEnd", [
181
+ ["path", { d: "M16 12H3", key: "1a2rj7" }],
182
+ ["path", { d: "M16 6H3", key: "1wxfjs" }],
183
+ ["path", { d: "M10 18H3", key: "13769t" }],
184
+ ["path", { d: "M21 6v10a2 2 0 0 1-2 2h-5", key: "ilrcs8" }],
185
+ ["path", { d: "m16 16-2 2 2 2", key: "kkc6pm" }]
186
+ ]);
187
+ /**
188
+ * @license lucide-react v0.379.0 - ISC
189
+ *
190
+ * This source code is licensed under the ISC license.
191
+ * See the LICENSE file in the root directory of this source tree.
192
+ */
193
+ const Xa = M("ListStart", [
194
+ ["path", { d: "M16 12H3", key: "1a2rj7" }],
195
+ ["path", { d: "M16 18H3", key: "12xzn7" }],
196
+ ["path", { d: "M10 6H3", key: "lf8lx7" }],
197
+ ["path", { d: "M21 18V8a2 2 0 0 0-2-2h-5", key: "1hghli" }],
198
+ ["path", { d: "m16 8-2-2 2-2", key: "160uvd" }]
199
+ ]);
200
+ /**
201
+ * @license lucide-react v0.379.0 - ISC
202
+ *
203
+ * This source code is licensed under the ISC license.
204
+ * See the LICENSE file in the root directory of this source tree.
205
+ */
206
+ const Za = M("ListX", [
207
+ ["path", { d: "M11 12H3", key: "51ecnj" }],
208
+ ["path", { d: "M16 6H3", key: "1wxfjs" }],
209
+ ["path", { d: "M16 18H3", key: "12xzn7" }],
210
+ ["path", { d: "m19 10-4 4", key: "1tz659" }],
211
+ ["path", { d: "m15 10 4 4", key: "1n7nei" }]
212
+ ]);
213
+ /**
214
+ * @license lucide-react v0.379.0 - ISC
215
+ *
216
+ * This source code is licensed under the ISC license.
217
+ * See the LICENSE file in the root directory of this source tree.
218
+ */
219
+ const en = M("MessageSquareMore", [
220
+ ["path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z", key: "1lielz" }],
221
+ ["path", { d: "M8 10h.01", key: "19clt8" }],
222
+ ["path", { d: "M12 10h.01", key: "1nrarc" }],
223
+ ["path", { d: "M16 10h.01", key: "1m94wz" }]
224
+ ]);
225
+ /**
226
+ * @license lucide-react v0.379.0 - ISC
227
+ *
228
+ * This source code is licensed under the ISC license.
229
+ * See the LICENSE file in the root directory of this source tree.
230
+ */
231
+ const sn = M("Network", [
232
+ ["rect", { x: "16", y: "16", width: "6", height: "6", rx: "1", key: "4q2zg0" }],
233
+ ["rect", { x: "2", y: "16", width: "6", height: "6", rx: "1", key: "8cvhb9" }],
234
+ ["rect", { x: "9", y: "2", width: "6", height: "6", rx: "1", key: "1egb70" }],
235
+ ["path", { d: "M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3", key: "1jsf9p" }],
236
+ ["path", { d: "M12 12V8", key: "2874zd" }]
237
+ ]);
238
+ /**
239
+ * @license lucide-react v0.379.0 - ISC
240
+ *
241
+ * This source code is licensed under the ISC license.
242
+ * See the LICENSE file in the root directory of this source tree.
243
+ */
244
+ const lt = M("Pencil", [
245
+ ["path", { d: "M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z", key: "5qss01" }],
246
+ ["path", { d: "m15 5 4 4", key: "1mk7zo" }]
247
+ ]);
248
+ /**
249
+ * @license lucide-react v0.379.0 - ISC
250
+ *
251
+ * This source code is licensed under the ISC license.
252
+ * See the LICENSE file in the root directory of this source tree.
253
+ */
254
+ const it = M("PieChart", [
255
+ ["path", { d: "M21.21 15.89A10 10 0 1 1 8 2.83", key: "k2fpak" }],
256
+ ["path", { d: "M22 12A10 10 0 0 0 12 2v10z", key: "1rfc4y" }]
257
+ ]);
258
+ /**
259
+ * @license lucide-react v0.379.0 - ISC
260
+ *
261
+ * This source code is licensed under the ISC license.
262
+ * See the LICENSE file in the root directory of this source tree.
263
+ */
264
+ const tn = M("Play", [
265
+ ["polygon", { points: "6 3 20 12 6 21 6 3", key: "1oa8hb" }]
266
+ ]);
267
+ /**
268
+ * @license lucide-react v0.379.0 - ISC
269
+ *
270
+ * This source code is licensed under the ISC license.
271
+ * See the LICENSE file in the root directory of this source tree.
272
+ */
273
+ const an = M("Plug2", [
274
+ ["path", { d: "M9 2v6", key: "17ngun" }],
275
+ ["path", { d: "M15 2v6", key: "s7yy2p" }],
276
+ ["path", { d: "M12 17v5", key: "bb1du9" }],
277
+ ["path", { d: "M5 8h14", key: "pcz4l3" }],
278
+ ["path", { d: "M6 11V8h12v3a6 6 0 1 1-12 0v0Z", key: "nd4hoy" }]
279
+ ]);
280
+ /**
281
+ * @license lucide-react v0.379.0 - ISC
282
+ *
283
+ * This source code is licensed under the ISC license.
284
+ * See the LICENSE file in the root directory of this source tree.
285
+ */
286
+ const ot = M("Plus", [
287
+ ["path", { d: "M5 12h14", key: "1ays0h" }],
288
+ ["path", { d: "M12 5v14", key: "s699le" }]
289
+ ]);
290
+ /**
291
+ * @license lucide-react v0.379.0 - ISC
292
+ *
293
+ * This source code is licensed under the ISC license.
294
+ * See the LICENSE file in the root directory of this source tree.
295
+ */
296
+ const nn = M("Save", [
297
+ [
298
+ "path",
299
+ {
300
+ 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",
301
+ key: "1c8476"
302
+ }
303
+ ],
304
+ ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
305
+ ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
306
+ ]);
307
+ /**
308
+ * @license lucide-react v0.379.0 - ISC
309
+ *
310
+ * This source code is licensed under the ISC license.
311
+ * See the LICENSE file in the root directory of this source tree.
312
+ */
313
+ const ct = M("ScatterChart", [
314
+ ["circle", { cx: "7.5", cy: "7.5", r: ".5", fill: "currentColor", key: "kqv944" }],
315
+ ["circle", { cx: "18.5", cy: "5.5", r: ".5", fill: "currentColor", key: "lysivs" }],
316
+ ["circle", { cx: "11.5", cy: "11.5", r: ".5", fill: "currentColor", key: "byv1b8" }],
317
+ ["circle", { cx: "7.5", cy: "16.5", r: ".5", fill: "currentColor", key: "nkw3mc" }],
318
+ ["circle", { cx: "17.5", cy: "14.5", r: ".5", fill: "currentColor", key: "1gjh6j" }],
319
+ ["path", { d: "M3 3v18h18", key: "1s2lah" }]
320
+ ]);
321
+ /**
322
+ * @license lucide-react v0.379.0 - ISC
323
+ *
324
+ * This source code is licensed under the ISC license.
325
+ * See the LICENSE file in the root directory of this source tree.
326
+ */
327
+ const rn = M("ShieldQuestion", [
328
+ [
329
+ "path",
330
+ {
331
+ d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
332
+ key: "oel41y"
333
+ }
334
+ ],
335
+ ["path", { d: "M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3", key: "mhlwft" }],
336
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
337
+ ]);
338
+ /**
339
+ * @license lucide-react v0.379.0 - ISC
340
+ *
341
+ * This source code is licensed under the ISC license.
342
+ * See the LICENSE file in the root directory of this source tree.
343
+ */
344
+ const Cs = M("Table", [
345
+ ["path", { d: "M12 3v18", key: "108xh3" }],
346
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
347
+ ["path", { d: "M3 9h18", key: "1pudct" }],
348
+ ["path", { d: "M3 15h18", key: "5xshup" }]
349
+ ]);
350
+ /**
351
+ * @license lucide-react v0.379.0 - ISC
352
+ *
353
+ * This source code is licensed under the ISC license.
354
+ * See the LICENSE file in the root directory of this source tree.
355
+ */
356
+ const ln = M("Tag", [
357
+ [
358
+ "path",
359
+ {
360
+ d: "M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",
361
+ key: "vktsd0"
362
+ }
363
+ ],
364
+ ["circle", { cx: "7.5", cy: "7.5", r: ".5", fill: "currentColor", key: "kqv944" }]
365
+ ]);
366
+ /**
367
+ * @license lucide-react v0.379.0 - ISC
368
+ *
369
+ * This source code is licensed under the ISC license.
370
+ * See the LICENSE file in the root directory of this source tree.
371
+ */
372
+ const on = M("ToggleLeft", [
373
+ ["rect", { width: "20", height: "12", x: "2", y: "6", rx: "6", ry: "6", key: "f2vt7d" }],
374
+ ["circle", { cx: "8", cy: "12", r: "2", key: "1nvbw3" }]
375
+ ]);
376
+ /**
377
+ * @license lucide-react v0.379.0 - ISC
378
+ *
379
+ * This source code is licensed under the ISC license.
380
+ * See the LICENSE file in the root directory of this source tree.
381
+ */
382
+ const cn = M("Type", [
383
+ ["polyline", { points: "4 7 4 4 20 4 20 7", key: "1nosan" }],
384
+ ["line", { x1: "9", x2: "15", y1: "20", y2: "20", key: "swin9y" }],
385
+ ["line", { x1: "12", x2: "12", y1: "4", y2: "20", key: "1tx1rr" }]
386
+ ]);
387
+ /**
388
+ * @license lucide-react v0.379.0 - ISC
389
+ *
390
+ * This source code is licensed under the ISC license.
391
+ * See the LICENSE file in the root directory of this source tree.
392
+ */
393
+ const dn = M("User", [
394
+ ["path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2", key: "975kel" }],
395
+ ["circle", { cx: "12", cy: "7", r: "4", key: "17ys0d" }]
396
+ ]);
397
+ function hn() {
398
+ const [s, n] = z(""), [t, a] = z(!1), [l, o] = z(!1), r = S((c) => c.dashboard);
399
+ function d() {
400
+ const c = $s(r), m = Oe(r.id), h = JSON.parse(localStorage.getItem(m) || "[]");
401
+ if (h.some(
402
+ (g) => g.name === s
403
+ )) {
404
+ a(!0);
405
+ return;
406
+ }
407
+ h.push({
408
+ name: s,
409
+ template: c
410
+ }), localStorage.setItem(m, JSON.stringify(h)), o(!1);
411
+ }
412
+ return /* @__PURE__ */ e.jsxs(is, { open: l, onOpenChange: o, children: [
413
+ /* @__PURE__ */ e.jsx(os, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
414
+ k,
415
+ {
416
+ variant: "outline",
417
+ className: "h-7 p-2",
418
+ size: "sm",
419
+ children: [
420
+ /* @__PURE__ */ e.jsx(ot, { className: " mr-2 h-4 w-4", strokeWidth: 1.5 }),
421
+ "Add Lens"
422
+ ]
423
+ }
424
+ ) }),
425
+ /* @__PURE__ */ e.jsxs(cs, { className: "sm:max-w-[425px]", children: [
426
+ /* @__PURE__ */ e.jsxs(ds, { children: [
427
+ /* @__PURE__ */ e.jsx(hs, { children: "Add a Lens" }),
428
+ /* @__PURE__ */ e.jsx(us, { children: "Lenses are private by default and are only visible to you." })
429
+ ] }),
430
+ /* @__PURE__ */ e.jsx("div", { className: "grid gap-4 py-4", children: /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-8 items-center gap-4", children: [
431
+ /* @__PURE__ */ e.jsx(_, { className: "text-right", children: "Name" }),
432
+ /* @__PURE__ */ e.jsx(
433
+ Q,
434
+ {
435
+ value: s,
436
+ onChange: (c) => {
437
+ t && a(!1), n(c.target.value);
438
+ },
439
+ id: "name",
440
+ className: "col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"
441
+ }
442
+ )
443
+ ] }) }),
444
+ t && /* @__PURE__ */ e.jsx("p", { className: "text-sm", children: "The bookmark name already exists. Use a differnet name." }),
445
+ /* @__PURE__ */ e.jsx(Bs, { children: /* @__PURE__ */ e.jsx(
446
+ k,
447
+ {
448
+ variant: "outline",
449
+ type: "submit",
450
+ disabled: !s,
451
+ onClick: d,
452
+ children: "Save"
453
+ }
454
+ ) })
455
+ ] })
456
+ ] });
457
+ }
458
+ function un() {
459
+ const [s, n] = z(!1), [t, a] = z(""), l = S((p) => p.dashboard), o = S((p) => p.bookmarkKey), [r, d] = z([]), c = S((p) => p.actions.setDashboard), m = S(
460
+ (p) => p.actions.setFilterValues
461
+ ), h = S(
462
+ (p) => p.actions.setBookmarkKey
463
+ );
464
+ $(() => {
465
+ const p = Oe(l.id), j = JSON.parse(localStorage.getItem(p) || "[]");
466
+ d(j);
467
+ const C = j.find(
468
+ (v) => v.default
469
+ );
470
+ C && C.name === o && a(C.name);
471
+ }, [s, l, o]);
472
+ function u(p) {
473
+ if (p === t)
474
+ return;
475
+ const j = r.find((v) => v.name === p), C = j == null ? void 0 : j.template;
476
+ C && (c(C), m(j.filterValues || []), h(p === "Original" ? "" : p)), a(p);
477
+ }
478
+ function g(p) {
479
+ const j = Oe(l.id), v = JSON.parse(localStorage.getItem(j) || "[]").filter(
480
+ (y) => y.name !== p
481
+ );
482
+ localStorage.setItem(j, JSON.stringify(v)), d(v);
483
+ }
484
+ return /* @__PURE__ */ e.jsxs(At, { open: s, onOpenChange: n, children: [
485
+ /* @__PURE__ */ e.jsx(Et, { asChild: !0, children: /* @__PURE__ */ e.jsx(k, { variant: "outline", className: "h-7 p-2", children: /* @__PURE__ */ e.jsx(Ga, { className: "h-4 w-4", strokeWidth: 1.5 }) }) }),
486
+ /* @__PURE__ */ e.jsxs(Lt, { className: "w-56", children: [
487
+ /* @__PURE__ */ e.jsx(Dt, { children: "Lenses" }),
488
+ /* @__PURE__ */ e.jsx(It, {}),
489
+ /* @__PURE__ */ e.jsxs(
490
+ qt,
491
+ {
492
+ value: t,
493
+ onValueChange: u,
494
+ children: [
495
+ /* @__PURE__ */ e.jsx(Os, { value: "Original", children: "Original" }),
496
+ r.filter((p) => p.name != "Original").map((p, j) => /* @__PURE__ */ e.jsxs(
497
+ Os,
498
+ {
499
+ className: "xbg-red-100 flex justify-between",
500
+ value: p.name,
501
+ defaultChecked: p.name === o,
502
+ children: [
503
+ /* @__PURE__ */ e.jsx("p", { children: p.name }),
504
+ /* @__PURE__ */ e.jsx(
505
+ Ee,
506
+ {
507
+ onClick: (C) => {
508
+ C.preventDefault(), g(p.name);
509
+ },
510
+ className: "h-3 w-3 hover:cursor-pointer",
511
+ strokeWidth: 1.5
512
+ }
513
+ )
514
+ ]
515
+ },
516
+ j
517
+ ))
518
+ ]
519
+ }
520
+ )
521
+ ] })
522
+ ] });
523
+ }
524
+ function mn() {
525
+ const [s, n] = z(!1), t = S((o) => o.dashboard), a = S((o) => o.bookmarkKey);
526
+ $(() => {
527
+ if (!a) {
528
+ n(!1);
529
+ return;
530
+ }
531
+ const o = Oe(t.id), d = JSON.parse(
532
+ localStorage.getItem(o) || "[]"
533
+ ).find(
534
+ (c) => c.name === a
535
+ );
536
+ n(d ? d.default : !1);
537
+ }, [a, t.id]);
538
+ function l(o) {
539
+ if (n(o), !a)
540
+ return;
541
+ const r = Oe(t.id), c = JSON.parse(
542
+ localStorage.getItem(r) || "[]"
543
+ ).map((m) => (m.name === a ? m.default = o : m.default = !1, m));
544
+ console.log(c), localStorage.setItem(r, JSON.stringify(c));
545
+ }
546
+ return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
547
+ /* @__PURE__ */ e.jsx(
548
+ Qe,
549
+ {
550
+ checked: s,
551
+ onCheckedChange: l,
552
+ id: "terms"
553
+ }
554
+ ),
555
+ /* @__PURE__ */ e.jsx(
556
+ "label",
557
+ {
558
+ htmlFor: "terms",
559
+ className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
560
+ children: "Set as default"
561
+ }
562
+ )
563
+ ] });
564
+ }
565
+ function xn() {
566
+ const s = S((y) => y.bookmarkKey), n = S((y) => y.dashboard);
567
+ S((y) => y.selectedSheetId);
568
+ const t = S(
569
+ (y) => y.isDashboardEditing
570
+ ), a = S((y) => y.filterValues), l = S((y) => y.isVisualEditing), o = S((y) => y.showFilters);
571
+ S(
572
+ (y) => y.showDashboardJSON
573
+ );
574
+ const r = S((y) => y.onSaveFunction), d = S(
575
+ (y) => y.actions.setShowFilters
576
+ ), { addFrame: c, setSelectedFrameId: m } = S(
577
+ (y) => y.actions
578
+ ), { getSelectedSheet: h, setIsDashboardEditing: u, setShowDashboardJSON: g } = S((y) => y.actions), p = h(), j = () => {
579
+ if (!t || !p)
580
+ return;
581
+ const y = {
582
+ id: $e(),
583
+ title: "Title",
584
+ description: "Description",
585
+ preferences: {
586
+ onClickFilter: [
587
+ {
588
+ columnIndex: 0,
589
+ expression: ""
590
+ }
591
+ ]
592
+ },
593
+ type: "bar",
594
+ sql: "select COUNT(*) from YOUR_TABLE",
595
+ data: []
596
+ }, D = {
597
+ id: $e(),
598
+ cards: [y],
599
+ activeCardId: y.id
600
+ };
601
+ c(p.id, D), m(D.id);
602
+ }, C = () => {
603
+ u(!0);
604
+ };
605
+ function v() {
606
+ if (!s || s === "")
607
+ return;
608
+ const y = $s(n), D = Oe(n.id), A = JSON.parse(localStorage.getItem(D) || "[]"), f = A.findIndex(
609
+ (O) => O.name === s
610
+ );
611
+ f !== -1 ? A[f] = {
612
+ name: s,
613
+ template: y,
614
+ default: A[f].default,
615
+ filterValues: a
616
+ } : A.push({
617
+ name: s,
618
+ template: y,
619
+ filterValues: a
620
+ }), localStorage.setItem(D, JSON.stringify(A)), r == null || r(y);
621
+ }
622
+ return l ? null : /* @__PURE__ */ e.jsxs(
623
+ "div",
624
+ {
625
+ className: "flex items-center justify-between gap-2 px-2 pt-2",
626
+ role: "dashboard-controls",
627
+ children: [
628
+ !l && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3", children: [
629
+ /* @__PURE__ */ e.jsx(_, { children: s }),
630
+ !!s && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
631
+ /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground", children: "|" }),
632
+ /* @__PURE__ */ e.jsx(mn, {})
633
+ ] })
634
+ ] }),
635
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
636
+ t && !l && /* @__PURE__ */ e.jsx(hn, {}),
637
+ !l && /* @__PURE__ */ e.jsx(un, {}),
638
+ t && !l && /* @__PURE__ */ e.jsxs(
639
+ k,
640
+ {
641
+ variant: "outline",
642
+ className: "h-7 p-2",
643
+ size: "sm",
644
+ disabled: !t,
645
+ onClick: j,
646
+ children: [
647
+ /* @__PURE__ */ e.jsx(ot, { className: "mr-2 h-4 w-4", strokeWidth: 1.5 }),
648
+ "Add Frame"
649
+ ]
650
+ }
651
+ ),
652
+ !t && /* @__PURE__ */ e.jsx(
653
+ k,
654
+ {
655
+ variant: "outline",
656
+ className: "h-7 p-2",
657
+ onClick: C,
658
+ size: "sm",
659
+ children: /* @__PURE__ */ e.jsx(lt, { className: "h-4 w-4", strokeWidth: 1.5 })
660
+ }
661
+ ),
662
+ t && !l && /* @__PURE__ */ e.jsx(
663
+ k,
664
+ {
665
+ variant: "outline",
666
+ role: "close",
667
+ className: "h-7 p-2",
668
+ onClick: () => {
669
+ u(!1), g(!1);
670
+ },
671
+ size: "sm",
672
+ children: /* @__PURE__ */ e.jsx(Ee, { className: "h-4 w-4", strokeWidth: 1.5 })
673
+ }
674
+ ),
675
+ t && !l && /* @__PURE__ */ e.jsx(
676
+ k,
677
+ {
678
+ className: "h-7 p-2",
679
+ variant: "outline",
680
+ onClick: v,
681
+ size: "sm",
682
+ children: /* @__PURE__ */ e.jsx(nn, { className: "h-4 w-4", strokeWidth: 1.5 })
683
+ }
684
+ ),
685
+ !o && !l && t && /* @__PURE__ */ e.jsx(
686
+ k,
687
+ {
688
+ className: "h-7 p-2",
689
+ variant: "outline",
690
+ onClick: () => d(!0),
691
+ size: "sm",
692
+ children: /* @__PURE__ */ e.jsx(rt, { className: "h-4 w-4", strokeWidth: 1.5 })
693
+ }
694
+ ),
695
+ !l && t && !1,
696
+ !l && !1
697
+ ] })
698
+ ]
699
+ }
700
+ );
701
+ }
702
+ function He({
703
+ title: s,
704
+ items: n,
705
+ value: t,
706
+ isLoading: a,
707
+ isError: l,
708
+ connectionTooltip: o,
709
+ onChange: r,
710
+ className: d,
711
+ showIcon: c = !0,
712
+ disabled: m = !1
713
+ }) {
714
+ const h = a ? "Loading..." : l ? "Error" : t;
715
+ function u() {
716
+ if (s === "Connection")
717
+ return /* @__PURE__ */ e.jsx(an, { className: "size-4 rotate-90" });
718
+ if (s === "Database")
719
+ return /* @__PURE__ */ e.jsx(Ka, { className: "size-4" });
720
+ if (s === "Schema")
721
+ return /* @__PURE__ */ e.jsx(sn, { className: "size-4" });
722
+ if (s === "Table")
723
+ return /* @__PURE__ */ e.jsx(Cs, { className: "size-4" });
724
+ }
725
+ return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
726
+ c && /* @__PURE__ */ e.jsx("div", { className: "shrink-0", children: o ? /* @__PURE__ */ e.jsxs(We, { children: [
727
+ /* @__PURE__ */ e.jsx(ms, { children: u() }),
728
+ /* @__PURE__ */ e.jsx(Pe, { className: "text-xs", align: "start", children: o })
729
+ ] }) : u() }),
730
+ /* @__PURE__ */ e.jsxs(xs, { disabled: m, value: h, onValueChange: r, children: [
731
+ /* @__PURE__ */ e.jsx(
732
+ ps,
733
+ {
734
+ className: W(
735
+ "h-9 w-[190px] focus:ring-1 focus:ring-offset-0",
736
+ d
737
+ ),
738
+ children: /* @__PURE__ */ e.jsx(
739
+ fs,
740
+ {
741
+ placeholder: a ? "Loading..." : l ? "Error" : `Select ${s}`
742
+ }
743
+ )
744
+ }
745
+ ),
746
+ /* @__PURE__ */ e.jsx(gs, { children: /* @__PURE__ */ e.jsxs(js, { children: [
747
+ a ? /* @__PURE__ */ e.jsx(Ke, { children: "Loading..." }) : /* @__PURE__ */ e.jsx(Ke, { children: s }),
748
+ /* @__PURE__ */ e.jsx(e.Fragment, { children: n && n.map((g, p) => /* @__PURE__ */ e.jsx(me, { value: g.id, children: g.name }, p)) }),
749
+ (a || l) && /* @__PURE__ */ e.jsx(me, { value: h, children: h })
750
+ ] }) })
751
+ ] })
752
+ ] });
753
+ }
754
+ function pn({ column: s }) {
755
+ const [n, t] = z(!1), a = i((h) => h.selectedTableName), l = i(
756
+ (h) => h.selectedSchemaName
757
+ ), o = i((h) => h.sqlGen), r = i((h) => h.actions.setSqlGen), d = i((h) => h.actions.setCardSql), c = i((h) => h.actions.setRunSql);
758
+ function m(h, u) {
759
+ const g = Ks(h, o, u);
760
+ r(g);
761
+ const p = Us(
762
+ g,
763
+ oe(l || ""),
764
+ oe(a)
765
+ );
766
+ p && (d(p), c(!0)), t(!1);
767
+ }
768
+ return /* @__PURE__ */ e.jsxs(Ie, { open: n, onOpenChange: t, children: [
769
+ /* @__PURE__ */ e.jsx(qe, { asChild: !0, children: /* @__PURE__ */ e.jsx(Vt, { className: "h-4 w-4 cursor-pointer text-foreground/40" }) }),
770
+ /* @__PURE__ */ e.jsx(
771
+ Ve,
772
+ {
773
+ align: "center",
774
+ className: "w-18 rounded-md p-0 shadow-none",
775
+ children: /* @__PURE__ */ e.jsxs("ul", { className: "text-xs", children: [
776
+ /* @__PURE__ */ e.jsx(
777
+ "li",
778
+ {
779
+ onClick: () => m(s, "COUNT"),
780
+ className: "cursor-pointer p-1 px-3 transition-colors hover:bg-muted",
781
+ children: "Count"
782
+ }
783
+ ),
784
+ /* @__PURE__ */ e.jsx(
785
+ "li",
786
+ {
787
+ onClick: () => m(s, "AVG"),
788
+ className: "cursor-pointer p-1 px-3 transition-colors hover:bg-muted",
789
+ children: "Avg"
790
+ }
791
+ ),
792
+ /* @__PURE__ */ e.jsx(
793
+ "li",
794
+ {
795
+ onClick: () => m(s, "SUM"),
796
+ className: "cursor-pointer p-1 px-3 transition-colors hover:bg-muted",
797
+ children: "Sum"
798
+ }
799
+ ),
800
+ /* @__PURE__ */ e.jsx(
801
+ "li",
802
+ {
803
+ onClick: () => m(s, "MAX"),
804
+ className: "cursor-pointer p-1 px-3 transition-colors hover:bg-muted",
805
+ children: "Max"
806
+ }
807
+ ),
808
+ /* @__PURE__ */ e.jsx(
809
+ "li",
810
+ {
811
+ onClick: () => m(s, "MIN"),
812
+ className: "cursor-pointer p-1 px-3 transition-colors hover:bg-muted",
813
+ children: "Min"
814
+ }
815
+ )
816
+ ] })
817
+ }
818
+ )
819
+ ] });
820
+ }
821
+ function dt({ column: s }) {
822
+ return /* @__PURE__ */ e.jsxs(We, { children: [
823
+ /* @__PURE__ */ e.jsx(Rt, { asChild: !0, children: _t.includes(s.data_type.toLowerCase()) ? (
824
+ // <span className=" font-thin">T</span>
825
+ /* @__PURE__ */ e.jsx(cn, { className: "size-3" })
826
+ ) : Gs.includes(s.data_type.toLowerCase()) ? (
827
+ //
828
+ /* @__PURE__ */ e.jsx(Wa, { className: "size-3" })
829
+ ) : Ht.includes(s.data_type.toLowerCase()) ? /* @__PURE__ */ e.jsx(Bt, { className: "size-3" }) : $t.includes(s.data_type.toLowerCase()) ? /* @__PURE__ */ e.jsx(on, { className: "size-3" }) : /* @__PURE__ */ e.jsx(rn, { className: "size-3" }) }),
830
+ /* @__PURE__ */ e.jsx(Pe, { children: /* @__PURE__ */ e.jsx("p", { className: "font-mono text-xs", children: s.data_type }) })
831
+ ] });
832
+ }
833
+ function fn({
834
+ schemaName: s,
835
+ tableName: n,
836
+ columns: t,
837
+ status: a
838
+ }) {
839
+ const l = i((f) => f.sqlGen), o = i(
840
+ (f) => f.selectedConnectionId
841
+ ), r = i(
842
+ (f) => f.selectedDatabaseName
843
+ ), d = i(
844
+ (f) => f.selectedSchemaName
845
+ ), c = i((f) => f.selectedTableName), m = S(
846
+ (f) => f.dashboard.aiScopeTables
847
+ ), { setAIScopeTables: h } = S((f) => f.actions), u = i((f) => f.actions.setRunSql), g = i((f) => f.actions.setSqlGen), p = i(
848
+ (f) => f.actions.setIsShowingVisual
849
+ ), j = i((f) => f.actions.setCardSql), { connectionType: C } = ht();
850
+ function v(f) {
851
+ const O = Ks(f, l);
852
+ g(O);
853
+ const T = Us(O, oe(s), oe(n));
854
+ T && (j(T), u(!0));
855
+ }
856
+ function y(f) {
857
+ if (f === !0 && c && o) {
858
+ const O = {
859
+ connectinonId: o,
860
+ connectionType: C,
861
+ databaseName: r,
862
+ schemaName: d,
863
+ tableName: c
864
+ }, E = [...m || [], O].filter(
865
+ (U, Z, G) => G.findIndex(
866
+ (H) => H.connectinonId === U.connectinonId && H.tableName === U.tableName
867
+ ) === Z
868
+ );
869
+ h(E);
870
+ } else {
871
+ const O = (m || []).filter(
872
+ (T) => T.connectinonId !== o && T.tableName !== c
873
+ );
874
+ h(O);
875
+ }
876
+ }
877
+ function D() {
878
+ let O = as(s, n);
879
+ ((E) => E.charAt(0) === E.charAt(0).toUpperCase())(n) && (O = `"${n}"`), p(!1), j(`SELECT * FROM ${O} LIMIT 10`), u(!0);
880
+ }
881
+ function A() {
882
+ let O = as(s, n);
883
+ ((E) => E.charAt(0) === E.charAt(0).toUpperCase())(n) && (O = `"${n}"`), p(!1), j(`SELECT COUNT(*) FROM ${O}`), u(!0);
884
+ }
885
+ return /* @__PURE__ */ e.jsxs("div", { className: "flex grow flex-col space-y-4 px-6", children: [
886
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
887
+ /* @__PURE__ */ e.jsx(
888
+ Js,
889
+ {
890
+ title: "Add to AI Scope",
891
+ onPressedChange: y,
892
+ variant: "outline",
893
+ className: "h-9 px-2",
894
+ children: /* @__PURE__ */ e.jsx(Ba, { className: "size-4" })
895
+ }
896
+ ),
897
+ /* @__PURE__ */ e.jsxs(
898
+ k,
899
+ {
900
+ disabled: a !== "Success",
901
+ onClick: D,
902
+ size: "sm",
903
+ variant: "secondary",
904
+ className: "flex w-full",
905
+ children: [
906
+ a !== "Success" ? /* @__PURE__ */ e.jsx(Le, { className: "mr-2 h-4 w-4 animate-spin text-foreground/50" }) : null,
907
+ "Top 10"
908
+ ]
909
+ }
910
+ ),
911
+ /* @__PURE__ */ e.jsxs(
912
+ k,
913
+ {
914
+ disabled: a !== "Success",
915
+ onClick: A,
916
+ size: "sm",
917
+ variant: "secondary",
918
+ className: "flex w-full",
919
+ children: [
920
+ a !== "Success" ? /* @__PURE__ */ e.jsx(Le, { className: "mr-2 h-4 w-4 animate-spin text-foreground/50" }) : null,
921
+ "Count"
922
+ ]
923
+ }
924
+ )
925
+ ] }),
926
+ /* @__PURE__ */ e.jsxs(
927
+ bs,
928
+ {
929
+ className: "flex-1 basis-0 overflow-y-auto border-b border-t border-muted py-3",
930
+ children: [
931
+ t == null ? void 0 : t.map((f) => /* @__PURE__ */ e.jsxs(
932
+ "div",
933
+ {
934
+ onClick: () => v(f),
935
+ className: W(
936
+ "mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-[6px] text-sm transition-colors hover:bg-muted/50",
937
+ {
938
+ "bg-muted": Kt(f, l)
939
+ }
940
+ ),
941
+ children: [
942
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
943
+ /* @__PURE__ */ e.jsx(dt, { column: f }),
944
+ /* @__PURE__ */ e.jsx("span", { children: f.column_name })
945
+ ] }),
946
+ Gs.includes(f.data_type) && /* @__PURE__ */ e.jsx(
947
+ "div",
948
+ {
949
+ onClick: (O) => O.stopPropagation(),
950
+ className: "flex items-center justify-end",
951
+ children: /* @__PURE__ */ e.jsx(pn, { column: f })
952
+ }
953
+ )
954
+ ]
955
+ },
956
+ f.column_name
957
+ )),
958
+ /* @__PURE__ */ e.jsx(zs, { orientation: "vertical" }),
959
+ /* @__PURE__ */ e.jsx(zs, { orientation: "horizontal" })
960
+ ]
961
+ }
962
+ )
963
+ ] });
964
+ }
965
+ function ht(s, n) {
966
+ var Xe, ge, _e, Te;
967
+ let t = Ra(() => [], []);
968
+ const a = Ye().authToken || s, l = i(
969
+ (N) => N.selectedConnectionId
970
+ ), o = i(
971
+ (N) => N.selectedDatabaseName
972
+ ), r = i(
973
+ (N) => N.selectedSchemaName
974
+ ), d = i((N) => N.selectedTableName), c = i(
975
+ (N) => N.actions.setCurrentColumns
976
+ ), m = i(
977
+ (N) => N.actions.setSelectedConnectionId
978
+ ), h = i(
979
+ (N) => N.actions.setSelectedDatabaseName
980
+ ), u = i(
981
+ (N) => N.actions.setSelectedSchemaName
982
+ ), g = i(
983
+ (N) => N.actions.setSelectedTableName
984
+ ), p = i((N) => N.actions.setCardSql);
985
+ function j(N) {
986
+ return l && o && r && o !== "NA" ? !0 : l && N === "API" ? !1 : !!(l && N === "S3");
987
+ }
988
+ function C(N) {
989
+ return !!(l && o && o !== "NA" && r && d || l && (N === "S3" || N === "API"));
990
+ }
991
+ function v(N) {
992
+ return l && N ? !(N === "API" || N === "S3") : !1;
993
+ }
994
+ const {
995
+ data: y,
996
+ isLoading: D,
997
+ isError: A
998
+ } = ye({
999
+ queryKey: ["connections"],
1000
+ queryFn: () => we(
1001
+ "https://semaphor.cloud/api/v1/connections",
1002
+ (a == null ? void 0 : a.accessToken) || ""
1003
+ ),
1004
+ enabled: !!(a != null && a.accessToken)
1005
+ // Only fetch if authToken is present
1006
+ }), f = y == null ? void 0 : y.connections.find(
1007
+ (N) => N.id === l
1008
+ ), O = f == null ? void 0 : f.type, T = (f == null ? void 0 : f.type) === "API" || (f == null ? void 0 : f.type) === "S3", {
1009
+ data: E,
1010
+ isLoading: U,
1011
+ isFetching: Z,
1012
+ isError: G,
1013
+ refetch: H
1014
+ } = ye({
1015
+ queryKey: ["databases", l],
1016
+ queryFn: () => we(
1017
+ "https://semaphor.cloud/api/v1/databases",
1018
+ (a == null ? void 0 : a.accessToken) || "",
1019
+ {
1020
+ connection_id: l
1021
+ }
1022
+ ),
1023
+ enabled: v(O)
1024
+ // !!selectedConnectionId && !isNonDbConnection, //currentConnection?.type !== 'API', // Only fetch if connectionId is present
1025
+ }), {
1026
+ data: I,
1027
+ isLoading: ee,
1028
+ isFetching: P,
1029
+ isError: se,
1030
+ refetch: X
1031
+ } = ye({
1032
+ queryKey: ["schemas", l, o],
1033
+ queryFn: () => we(
1034
+ "https://semaphor.cloud/api/v1/schemas",
1035
+ (a == null ? void 0 : a.accessToken) || "",
1036
+ {
1037
+ connection_id: l,
1038
+ database_name: o
1039
+ }
1040
+ ),
1041
+ enabled: !!l && !!o && !T && o !== "NA"
1042
+ //currentConnection?.type !== 'API', // Only fetch if connectionId and database is present
1043
+ }), {
1044
+ data: w,
1045
+ isLoading: F,
1046
+ isFetching: b,
1047
+ isError: L,
1048
+ refetch: K
1049
+ } = ye({
1050
+ queryKey: [
1051
+ "tables",
1052
+ l,
1053
+ o,
1054
+ r
1055
+ ],
1056
+ queryFn: () => we(
1057
+ "https://semaphor.cloud/api/v1/tables",
1058
+ (a == null ? void 0 : a.accessToken) || "",
1059
+ {
1060
+ connection_id: l,
1061
+ database_name: o,
1062
+ schema_name: r
1063
+ }
1064
+ ),
1065
+ enabled: j(O)
1066
+ }), {
1067
+ data: B,
1068
+ isLoading: de,
1069
+ isFetching: te,
1070
+ isError: xe
1071
+ } = ye({
1072
+ queryKey: [
1073
+ "columns",
1074
+ l,
1075
+ o,
1076
+ r,
1077
+ d
1078
+ ],
1079
+ queryFn: () => we(
1080
+ "https://semaphor.cloud/api/v1/columns",
1081
+ (a == null ? void 0 : a.accessToken) || "",
1082
+ {
1083
+ connection_id: l,
1084
+ database_name: o,
1085
+ schema_name: r,
1086
+ table_name: d
1087
+ }
1088
+ ),
1089
+ enabled: C(O)
1090
+ // (!!selectedConnectionId &&
1091
+ // !!selectedDatabaseName &&
1092
+ // !!selectedSchemaName &&
1093
+ // !!selectedTableName) ||
1094
+ // isNonDbConnection,
1095
+ //currentConnection?.type === 'API',
1096
+ // && currentConnection?.type !== 'API', // Only fetch if connectionId, database, and table is present
1097
+ });
1098
+ $(() => {
1099
+ c(t);
1100
+ }, [B, c, t]), $(() => {
1101
+ }, [
1102
+ T,
1103
+ p,
1104
+ g,
1105
+ u,
1106
+ h,
1107
+ f
1108
+ ]);
1109
+ const pe = (f == null ? void 0 : f.type) === "API" ? (Xe = f == null ? void 0 : f.type) == null ? void 0 : Xe.toLowerCase() : d || "", fe = T ? "" : r || "";
1110
+ function he(N) {
1111
+ u(N), g("");
1112
+ }
1113
+ function J(N) {
1114
+ h(N), u(""), g("");
1115
+ }
1116
+ function ae(N) {
1117
+ m(N);
1118
+ }
1119
+ E && ((ge = E == null ? void 0 : E.databases) == null ? void 0 : ge.length) > 0, I && ((_e = I == null ? void 0 : I.schemas) == null ? void 0 : _e.length) > 0, B && ((Te = B == null ? void 0 : B.columns) == null ? void 0 : Te.length) > 0 && (t = B.columns.map((N) => ({
1120
+ ...N,
1121
+ data_type: N.data_type.toLowerCase()
1122
+ }))), G && (t = []), (xe || A) && (t = []);
1123
+ const Ce = y == null ? void 0 : y.connections.map(
1124
+ (N) => ({
1125
+ id: N.id,
1126
+ name: N.name,
1127
+ type: N.type
1128
+ })
1129
+ ), Re = E == null ? void 0 : E.databases.map((N) => ({
1130
+ id: N.database_name,
1131
+ name: N.database_name
1132
+ })), Se = I == null ? void 0 : I.schemas.map((N) => ({
1133
+ id: N.schema_name,
1134
+ name: N.schema_name
1135
+ })), Me = w == null ? void 0 : w.tables.map((N) => ({
1136
+ id: N.table_name,
1137
+ name: N.table_name
1138
+ }));
1139
+ return {
1140
+ connectionItems: Ce,
1141
+ isConnectionsLoading: D,
1142
+ isConnectionsError: A,
1143
+ databaseItems: Re,
1144
+ isDatabasesLoadingOrFetching: U || Z,
1145
+ isDatabaseError: G,
1146
+ schemaItems: Se,
1147
+ isSchemaLoadingOrFetching: ee || P,
1148
+ isSchemaError: se,
1149
+ tableItems: Me,
1150
+ isTableLoadingOrFetching: F || b,
1151
+ isTableError: L,
1152
+ columns: t,
1153
+ isColumnsLoadingOrFetching: de || te,
1154
+ isColumnsError: xe,
1155
+ isNonDbConnection: T,
1156
+ connectionType: O,
1157
+ tableName: pe,
1158
+ schemaName: fe,
1159
+ handleConnectionChange: ae,
1160
+ handleDatabaseChange: J,
1161
+ handleSchemaChange: he
1162
+ };
1163
+ }
1164
+ function ut({
1165
+ ColumnsComponent: s
1166
+ }) {
1167
+ var w;
1168
+ const n = i(
1169
+ (F) => F.selectedConnectionId
1170
+ ), t = i(
1171
+ (F) => F.selectedDatabaseName
1172
+ ), a = i(
1173
+ (F) => F.selectedSchemaName
1174
+ ), l = i((F) => F.selectedTableName), o = i(
1175
+ (F) => F.actions.setSelectedTableName
1176
+ ), {
1177
+ connectionItems: r,
1178
+ schemaItems: d,
1179
+ databaseItems: c,
1180
+ tableItems: m,
1181
+ columns: h,
1182
+ isConnectionsLoading: u,
1183
+ isConnectionsError: g,
1184
+ isDatabasesLoadingOrFetching: p,
1185
+ isDatabaseError: j,
1186
+ isSchemaLoadingOrFetching: C,
1187
+ isSchemaError: v,
1188
+ isColumnsError: y,
1189
+ isColumnsLoadingOrFetching: D,
1190
+ isTableLoadingOrFetching: A,
1191
+ isTableError: f,
1192
+ connectionType: O,
1193
+ isNonDbConnection: T,
1194
+ handleConnectionChange: E,
1195
+ handleDatabaseChange: U,
1196
+ handleSchemaChange: Z,
1197
+ tableName: G,
1198
+ schemaName: H
1199
+ } = ht();
1200
+ function I() {
1201
+ return s ? s(H, G, h) : /* @__PURE__ */ e.jsx(
1202
+ fn,
1203
+ {
1204
+ schemaName: H,
1205
+ tableName: G,
1206
+ columns: h,
1207
+ status: D ? "Loading..." : y ? "Error" : "Success"
1208
+ }
1209
+ );
1210
+ }
1211
+ function ee() {
1212
+ window.location.href = "mailto:support@semaphor.cloud?subject=Help&body=I need help with...";
1213
+ }
1214
+ function P() {
1215
+ return O === "S3" || O === "API" ? null : /* @__PURE__ */ e.jsx(
1216
+ He,
1217
+ {
1218
+ onChange: U,
1219
+ isError: j,
1220
+ isLoading: p,
1221
+ items: c,
1222
+ value: t || "",
1223
+ title: "Database"
1224
+ }
1225
+ );
1226
+ }
1227
+ function se() {
1228
+ return O === "S3" || O === "API" ? null : /* @__PURE__ */ e.jsx(
1229
+ He,
1230
+ {
1231
+ onChange: Z,
1232
+ isError: v,
1233
+ isLoading: C,
1234
+ items: d,
1235
+ value: a || "",
1236
+ title: "Schema"
1237
+ }
1238
+ );
1239
+ }
1240
+ function X() {
1241
+ return O === "API" ? null : /* @__PURE__ */ e.jsx(
1242
+ He,
1243
+ {
1244
+ onChange: o,
1245
+ isError: f,
1246
+ items: m,
1247
+ isLoading: A,
1248
+ value: l || "",
1249
+ title: "Table"
1250
+ }
1251
+ );
1252
+ }
1253
+ return /* @__PURE__ */ e.jsxs("aside", { className: "xbg-red-100 flex grow flex-col justify-between", children: [
1254
+ /* @__PURE__ */ e.jsxs("section", { className: "space-y-3 px-6 py-4", children: [
1255
+ /* @__PURE__ */ e.jsx(
1256
+ He,
1257
+ {
1258
+ items: r,
1259
+ title: "Connection",
1260
+ value: n || "",
1261
+ onChange: E,
1262
+ isLoading: u,
1263
+ isError: g,
1264
+ connectionTooltip: ((w = r == null ? void 0 : r.find(
1265
+ (F) => F.id === n
1266
+ )) == null ? void 0 : w.type) || ""
1267
+ }
1268
+ ),
1269
+ P(),
1270
+ se(),
1271
+ X()
1272
+ ] }),
1273
+ I(),
1274
+ /* @__PURE__ */ e.jsx("div", { className: "flex items-end justify-center gap-2 px-6 py-4", children: /* @__PURE__ */ e.jsxs(
1275
+ k,
1276
+ {
1277
+ onClick: ee,
1278
+ size: "sm",
1279
+ variant: "secondary",
1280
+ className: "w-full",
1281
+ children: [
1282
+ /* @__PURE__ */ e.jsx(en, { className: "mr-2 size-4" }),
1283
+ "Help"
1284
+ ]
1285
+ }
1286
+ ) })
1287
+ ] });
1288
+ }
1289
+ const rs = ({
1290
+ className: s,
1291
+ ...n
1292
+ }) => /* @__PURE__ */ e.jsx(
1293
+ Ut,
1294
+ {
1295
+ className: W(
1296
+ "flex h-full w-full data-[panel-group-direction=vertical]:flex-col",
1297
+ s
1298
+ ),
1299
+ ...n
1300
+ }
1301
+ ), Fe = Gt, ls = ({
1302
+ withHandle: s,
1303
+ className: n,
1304
+ ...t
1305
+ }) => /* @__PURE__ */ e.jsx(
1306
+ Jt,
1307
+ {
1308
+ className: W(
1309
+ "relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",
1310
+ n
1311
+ ),
1312
+ ...t,
1313
+ children: s && /* @__PURE__ */ e.jsx("div", { className: "z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border", children: /* @__PURE__ */ e.jsx(Ja, { className: "h-2.5 w-2.5" }) })
1314
+ }
1315
+ );
1316
+ function gn(s) {
1317
+ const n = s.toUpperCase().indexOf("WHERE"), t = s.toUpperCase().indexOf("GROUP BY"), a = s.toUpperCase().indexOf("LIMIT"), l = s.toUpperCase().indexOf("ORDER BY");
1318
+ let o = s.length;
1319
+ if (l !== -1 && (o = l), a !== -1 && a < o && (o = a), n !== -1) {
1320
+ const r = s.substring(0, n), d = s.substring(n);
1321
+ return `${r} {{ filters | where }} AND ${d.substring(
1322
+ 6
1323
+ )}`;
1324
+ } else if (t !== -1) {
1325
+ const r = s.substring(0, t), d = s.substring(t);
1326
+ return `${r} {{ filters | where }} ${d}`;
1327
+ } else {
1328
+ const r = s.substring(0, o), d = s.substring(o);
1329
+ return `${r} {{ filters | where }} ${d}`;
1330
+ }
1331
+ }
1332
+ function jn({
1333
+ error: s,
1334
+ setShowAIDialog: n,
1335
+ setUserInputforAI: t,
1336
+ setTriggerAIRun: a
1337
+ }) {
1338
+ return /* @__PURE__ */ e.jsxs(Qs, { openDelay: 0, children: [
1339
+ /* @__PURE__ */ e.jsx(Ws, { asChild: !0, children: /* @__PURE__ */ e.jsx(k, { variant: "link", className: " p-0 h-5", children: /* @__PURE__ */ e.jsx($a, { className: "h-4 w-4 text-red-500" }) }) }),
1340
+ /* @__PURE__ */ e.jsx(Ps, { align: "start", className: " min-w-fit max-w-[500px]", children: /* @__PURE__ */ e.jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ e.jsxs("div", { className: "grow space-y-1 flex flex-col ", children: [
1341
+ /* @__PURE__ */ e.jsxs(
1342
+ k,
1343
+ {
1344
+ onClick: () => {
1345
+ n(!0), t(s), a(!0);
1346
+ },
1347
+ size: "sm",
1348
+ variant: "outline",
1349
+ children: [
1350
+ /* @__PURE__ */ e.jsx(Qa, { className: "h-4 w-4 mr-2" }),
1351
+ "Fix It"
1352
+ ]
1353
+ }
1354
+ ),
1355
+ /* @__PURE__ */ e.jsx(bs, { className: " min-h-0 max-h-[250px] overflow-scroll ", children: /* @__PURE__ */ e.jsx("p", { className: " overflow-auto text-sm leading-relaxed font-mono ", children: s }) })
1356
+ ] }) }) })
1357
+ ] });
1358
+ }
1359
+ function bn({
1360
+ text: s,
1361
+ onCheckedChange: n,
1362
+ checked: t
1363
+ }) {
1364
+ return /* @__PURE__ */ e.jsxs("div", { className: "xbg-red-100 ml-6 flex items-center gap-2", children: [
1365
+ /* @__PURE__ */ e.jsx(Qe, { checked: t, onCheckedChange: n }),
1366
+ /* @__PURE__ */ e.jsx("label", { className: "text-xs leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: s })
1367
+ ] });
1368
+ }
1369
+ function yn() {
1370
+ const { authToken: s } = Ye(), n = De(null), t = i((d) => d.applyFilters), [a, l] = z(""), o = i((d) => d.filterValues), r = i((d) => d.card.sql);
1371
+ return /* @__PURE__ */ e.jsxs(
1372
+ Qs,
1373
+ {
1374
+ openDelay: 0,
1375
+ onOpenChange: async (d) => {
1376
+ if (!d)
1377
+ return;
1378
+ console.log("onOpenChange");
1379
+ const c = await Ys(
1380
+ "https://semaphor.cloud/api/v1/filter-sql",
1381
+ (s == null ? void 0 : s.accessToken) || "",
1382
+ {
1383
+ sql: r,
1384
+ active_filters: o
1385
+ }
1386
+ );
1387
+ console.log(c), c.sql ? (console.log(c.records), l(c.sql)) : l("Error");
1388
+ },
1389
+ children: [
1390
+ /* @__PURE__ */ e.jsx(Ws, { asChild: !0, children: t && /* @__PURE__ */ e.jsx("p", { className: "p-0 text-xs hover:cursor-pointer", children: "|  Filter Query" }) }),
1391
+ /* @__PURE__ */ e.jsxs(Ps, { align: "end", className: "w-[600px]", children: [
1392
+ /* @__PURE__ */ e.jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ e.jsx("div", { className: "rounded-sm bg-muted p-2", children: /* @__PURE__ */ e.jsxs("code", { ref: n, className: "font-mono text-sm", children: [
1393
+ a,
1394
+ /* @__PURE__ */ e.jsx(
1395
+ Xs,
1396
+ {
1397
+ onClick: () => Qt(n),
1398
+ className: "ml-3 inline-block h-4 w-4 opacity-70 hover:cursor-pointer hover:opacity-100"
1399
+ }
1400
+ )
1401
+ ] }) }) }),
1402
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 pt-2", children: [
1403
+ /* @__PURE__ */ e.jsx(Zs, { className: "h-4 w-4 opacity-70" }),
1404
+ /* @__PURE__ */ e.jsx("span", { className: "text-xs text-muted-foreground", children: "A preview of the query with filters applied." })
1405
+ ] })
1406
+ ] })
1407
+ ]
1408
+ }
1409
+ );
1410
+ }
1411
+ const vn = `
1412
+
1413
+ Use the following syntax to create a chart query. Please replace the x-axis, y-axis, stack-by, label, and measure with the actual column names of the table.
1414
+
1415
+ Bar / Line Chart:
1416
+
1417
+ SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table
1418
+
1419
+ - X-axis - Category
1420
+ - Y-axis - Number
1421
+
1422
+ Stacked Chart:
1423
+
1424
+ SELECT x-axis, stack-by, y-axis FROM table
1425
+
1426
+ - X-axis - Category
1427
+ - Stack by - Category
1428
+ - Y-axis - Number
1429
+
1430
+
1431
+ Scatter Chart:
1432
+
1433
+ SELECT label, x-axis, y-axis FROM table
1434
+
1435
+ - Label - Category
1436
+ - Group (opt) - Category
1437
+ - X-axis - Number
1438
+ - Y-axis - Number
1439
+
1440
+
1441
+ Bubble Chart:
1442
+
1443
+ SELECT label, x-axis, y-axis, radius FROM table
1444
+
1445
+ - Label - Category
1446
+ - Bubble Group (opt) - Category
1447
+ - X-axis - Number
1448
+ - Y-axis - Number
1449
+ - Radius - Number
1450
+
1451
+ Pie / Dougnut Chart:
1452
+
1453
+ SELECT label, measure FROM table
1454
+
1455
+ - Label - Category
1456
+ - Measure - Number
1457
+ `;
1458
+ function Nn({
1459
+ open: s,
1460
+ setOpen: n,
1461
+ userInput: t,
1462
+ setUserInput: a,
1463
+ triggerAIRun: l,
1464
+ setTriggerAIRun: o
1465
+ }) {
1466
+ const r = De(null), d = De(null), { authToken: c } = Ye(), [m, h] = z(!1), u = i((b) => b.actions.setCardSql), g = S((b) => b.dashboard.baseQueries), p = i((b) => b.actions.setRunSql), j = i((b) => b.actions.setCardType), [C, v] = z([]), y = i((b) => b.currentColumns), D = i((b) => b.card.sql), A = i((b) => b.selectedTableName), f = `
1467
+ ${t}
1468
+
1469
+ Database Query Dialect: ${A === "api" || A === "s3" ? "DuckDb" : ""}
1470
+ Table Name: ${A}
1471
+ Table Columns: ${y == null ? void 0 : y.map((b) => `${b.column_name} | ${b.data_type}`).join(", ")}
1472
+ User SQL: ${D}
1473
+ ${g && `Base Queries: ${JSON.stringify(g)} `}`, O = ` When the user asks for a specific chart please use the following query structure to generate the chart query. Do not make up the column names. Use only the table columns provided above for the query. Replace x-axis, y-axis, and lables with the appropriate column names.
1474
+ Visual Query Syntax: ${vn}`, { data: T, isLoading: E, isFetching: U, isError: Z, refetch: G } = ye({
1475
+ queryKey: ["ai-query"],
1476
+ queryFn: () => we(
1477
+ "https://semaphor.cloud/api/v1/ai",
1478
+ (c == null ? void 0 : c.accessToken) || "",
1479
+ {
1480
+ user_content: `userContent: ${f} ${m ? O : ""}`
1481
+ }
1482
+ ),
1483
+ enabled: !1
1484
+ // Do not run by default.
1485
+ });
1486
+ function H(b) {
1487
+ if (b.toLowerCase().includes("bar"))
1488
+ j("bar");
1489
+ else if (b.toLowerCase().includes("line"))
1490
+ j("line");
1491
+ else if (b.toLowerCase().includes("bubble"))
1492
+ j("bubble");
1493
+ else if (b.toLowerCase().includes("scatter"))
1494
+ j("scatter");
1495
+ else if (b.toLowerCase().includes("stacked"))
1496
+ j("stackedBar");
1497
+ else if (b.toLowerCase().includes("pie"))
1498
+ j("pie");
1499
+ else if (b.toLowerCase().includes("donut") || b.toLowerCase().includes("doughnut"))
1500
+ j("doughnut");
1501
+ else if (b.toLowerCase().includes("radar"))
1502
+ j("radar");
1503
+ else
1504
+ return j("bar"), !1;
1505
+ return !0;
1506
+ }
1507
+ $(() => {
1508
+ T && v((b) => [...b, { role: "ai", content: T.response }]);
1509
+ }, [T]), $(() => {
1510
+ const b = setTimeout(() => {
1511
+ var L;
1512
+ d.current && (d.current.scroll({
1513
+ top: d.current.scrollHeight,
1514
+ behavior: "smooth"
1515
+ }), (L = r.current) == null || L.focus());
1516
+ }, 100);
1517
+ return () => clearTimeout(b);
1518
+ }, [C]);
1519
+ function I() {
1520
+ t && (v((b) => [...b, { role: "user", content: t }]), H(t) && h(!0), a(""), G());
1521
+ }
1522
+ $(() => {
1523
+ l && (I(), o(!1));
1524
+ }, [l, o]);
1525
+ const ee = {
1526
+ //seleect a darker color
1527
+ // color: '#000',
1528
+ fontFamily: "Arial, sans-serif",
1529
+ lineHeight: 1.6,
1530
+ fontSize: 15,
1531
+ // padding: '5px',
1532
+ width: "100%"
1533
+ }, P = {
1534
+ // background: '#f6f8fa',
1535
+ // color: '#000',
1536
+ fontFamily: "monospace",
1537
+ fontSize: 14,
1538
+ lineHeight: 1.6
1539
+ // padding: 20,
1540
+ }, se = {
1541
+ // color: '#000',
1542
+ fontFamily: "Arial, sans-serif",
1543
+ lineHeight: 1.6,
1544
+ fontSize: 15,
1545
+ padding: "2px 0",
1546
+ // add a bit of left margin to make it look nice
1547
+ marginLeft: 20,
1548
+ // add bullet points for unordered lists
1549
+ listStyleType: "disc"
1550
+ }, X = {
1551
+ // Override how paragraphs are rendered
1552
+ p: ({ node: b, ...L }) => /* @__PURE__ */ e.jsx("p", { style: ee, ...L }),
1553
+ code: ({ node: b, ...L }) => /* @__PURE__ */ e.jsx("code", { className: "rounded-sm bg-muted px-2 py-1 text-sm", ...L }),
1554
+ pre: ({ node: b, ...L }) => /* @__PURE__ */ e.jsxs("pre", { className: "space-y-2 rounded-sm bg-muted/50 p-3", style: P, children: [
1555
+ /* @__PURE__ */ e.jsx("code", { className: "whitespace-normal text-sm", children: L.children }),
1556
+ /* @__PURE__ */ e.jsxs("div", { className: "flex justify-start gap-2", children: [
1557
+ /* @__PURE__ */ e.jsx(k, { onClick: w, size: "sm", variant: "outline", children: /* @__PURE__ */ e.jsx(Xs, {}) }),
1558
+ /* @__PURE__ */ e.jsx(
1559
+ k,
1560
+ {
1561
+ onClick: (K) => {
1562
+ const B = w(K);
1563
+ B && (n(!1), u(B), p(!0));
1564
+ },
1565
+ size: "sm",
1566
+ variant: "outline",
1567
+ children: /* @__PURE__ */ e.jsx(Yt, {})
1568
+ }
1569
+ )
1570
+ ] })
1571
+ ] }),
1572
+ li: ({ node: b, ...L }) => /* @__PURE__ */ e.jsx("li", { style: se, ...L })
1573
+ // You can add more overrides for other elements like h1, h2, etc.
1574
+ };
1575
+ function w(b) {
1576
+ const L = b.currentTarget.closest("pre");
1577
+ if (!L)
1578
+ return;
1579
+ const K = L.textContent || L.innerText;
1580
+ return navigator.clipboard.writeText(K).then(() => console.log("Text copied to clipboard")).catch((B) => console.error("Error in copying text: ", B)), K;
1581
+ }
1582
+ function F() {
1583
+ return C == null ? void 0 : C.map((b, L) => b.role === "user" ? /* @__PURE__ */ e.jsxs(
1584
+ "div",
1585
+ {
1586
+ className: "flex items-start rounded-md bg-muted p-3 text-sm",
1587
+ children: [
1588
+ /* @__PURE__ */ e.jsx(dn, { className: "mr-2 h-5 w-5" }),
1589
+ /* @__PURE__ */ e.jsx("div", { children: b.content })
1590
+ ]
1591
+ },
1592
+ L
1593
+ ) : b.role === "ai" ? /* @__PURE__ */ e.jsx(
1594
+ Pt,
1595
+ {
1596
+ className: "w-full overflow-auto py-1",
1597
+ components: X,
1598
+ children: T == null ? void 0 : T.response.replace(/DuckDB/gi, "Semaphor")
1599
+ },
1600
+ L
1601
+ ) : /* @__PURE__ */ e.jsx("div", {}, L));
1602
+ }
1603
+ return /* @__PURE__ */ e.jsxs(is, { open: s, onOpenChange: n, children: [
1604
+ /* @__PURE__ */ e.jsx(os, { asChild: !0, children: /* @__PURE__ */ e.jsx(
1605
+ k,
1606
+ {
1607
+ size: "sm",
1608
+ className: "w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",
1609
+ variant: "secondary",
1610
+ children: "Type your question here..."
1611
+ }
1612
+ ) }),
1613
+ /* @__PURE__ */ e.jsxs(
1614
+ cs,
1615
+ {
1616
+ className: "flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",
1617
+ children: [
1618
+ /* @__PURE__ */ e.jsxs(ds, { children: [
1619
+ /* @__PURE__ */ e.jsx(hs, { children: "Assistant" }),
1620
+ /* @__PURE__ */ e.jsx(us, { children: "What can I help you with?" })
1621
+ ] }),
1622
+ /* @__PURE__ */ e.jsx(
1623
+ "div",
1624
+ {
1625
+ ref: d,
1626
+ className: "h-[625px] w-full overflow-auto border-t border-t-muted",
1627
+ children: /* @__PURE__ */ e.jsx("div", { className: "space-y-4 py-2 pr-3", role: "messages", children: F() })
1628
+ }
1629
+ ),
1630
+ /* @__PURE__ */ e.jsx(
1631
+ "div",
1632
+ {
1633
+ children: /* @__PURE__ */ e.jsxs("div", { className: "flex w-full items-center rounded-md border", children: [
1634
+ /* @__PURE__ */ e.jsx(
1635
+ et,
1636
+ {
1637
+ autoFocus: !0,
1638
+ ref: r,
1639
+ onKeyDown: (b) => {
1640
+ b.key === "Enter" && !b.shiftKey && (b.preventDefault(), a(""), I());
1641
+ },
1642
+ placeholder: "Type your question here...",
1643
+ onFocus: (b) => {
1644
+ const L = b.target, K = L.value.length;
1645
+ L.setSelectionRange(K, K);
1646
+ },
1647
+ className: W(
1648
+ "max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"
1649
+ ),
1650
+ disabled: E || U,
1651
+ value: t,
1652
+ onChange: (b) => a(b.target.value)
1653
+ }
1654
+ ),
1655
+ " ",
1656
+ /* @__PURE__ */ e.jsx(
1657
+ k,
1658
+ {
1659
+ className: "h-8",
1660
+ size: "sm",
1661
+ variant: "ghost",
1662
+ onClick: I,
1663
+ children: !E && !U ? /* @__PURE__ */ e.jsx(Wt, {}) : /* @__PURE__ */ e.jsx(Le, { className: "mr-2 h-4 w-4 animate-spin text-foreground/50" })
1664
+ }
1665
+ )
1666
+ ] })
1667
+ }
1668
+ )
1669
+ ]
1670
+ }
1671
+ )
1672
+ ] });
1673
+ }
1674
+ var mt = {
1675
+ color: void 0,
1676
+ size: void 0,
1677
+ className: void 0,
1678
+ style: void 0,
1679
+ attr: void 0
1680
+ }, Vs = ce.createContext && /* @__PURE__ */ ce.createContext(mt), Cn = ["attr", "size", "title"];
1681
+ function Sn(s, n) {
1682
+ if (s == null)
1683
+ return {};
1684
+ var t = kn(s, n), a, l;
1685
+ if (Object.getOwnPropertySymbols) {
1686
+ var o = Object.getOwnPropertySymbols(s);
1687
+ for (l = 0; l < o.length; l++)
1688
+ a = o[l], !(n.indexOf(a) >= 0) && Object.prototype.propertyIsEnumerable.call(s, a) && (t[a] = s[a]);
1689
+ }
1690
+ return t;
1691
+ }
1692
+ function kn(s, n) {
1693
+ if (s == null)
1694
+ return {};
1695
+ var t = {}, a = Object.keys(s), l, o;
1696
+ for (o = 0; o < a.length; o++)
1697
+ l = a[o], !(n.indexOf(l) >= 0) && (t[l] = s[l]);
1698
+ return t;
1699
+ }
1700
+ function Ge() {
1701
+ return Ge = Object.assign ? Object.assign.bind() : function(s) {
1702
+ for (var n = 1; n < arguments.length; n++) {
1703
+ var t = arguments[n];
1704
+ for (var a in t)
1705
+ Object.prototype.hasOwnProperty.call(t, a) && (s[a] = t[a]);
1706
+ }
1707
+ return s;
1708
+ }, Ge.apply(this, arguments);
1709
+ }
1710
+ function Rs(s, n) {
1711
+ var t = Object.keys(s);
1712
+ if (Object.getOwnPropertySymbols) {
1713
+ var a = Object.getOwnPropertySymbols(s);
1714
+ n && (a = a.filter(function(l) {
1715
+ return Object.getOwnPropertyDescriptor(s, l).enumerable;
1716
+ })), t.push.apply(t, a);
1717
+ }
1718
+ return t;
1719
+ }
1720
+ function Je(s) {
1721
+ for (var n = 1; n < arguments.length; n++) {
1722
+ var t = arguments[n] != null ? arguments[n] : {};
1723
+ n % 2 ? Rs(Object(t), !0).forEach(function(a) {
1724
+ wn(s, a, t[a]);
1725
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(s, Object.getOwnPropertyDescriptors(t)) : Rs(Object(t)).forEach(function(a) {
1726
+ Object.defineProperty(s, a, Object.getOwnPropertyDescriptor(t, a));
1727
+ });
1728
+ }
1729
+ return s;
1730
+ }
1731
+ function wn(s, n, t) {
1732
+ return n = Fn(n), n in s ? Object.defineProperty(s, n, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : s[n] = t, s;
1733
+ }
1734
+ function Fn(s) {
1735
+ var n = On(s, "string");
1736
+ return typeof n == "symbol" ? n : String(n);
1737
+ }
1738
+ function On(s, n) {
1739
+ if (typeof s != "object" || s === null)
1740
+ return s;
1741
+ var t = s[Symbol.toPrimitive];
1742
+ if (t !== void 0) {
1743
+ var a = t.call(s, n || "default");
1744
+ if (typeof a != "object")
1745
+ return a;
1746
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1747
+ }
1748
+ return (n === "string" ? String : Number)(s);
1749
+ }
1750
+ function xt(s) {
1751
+ return s && s.map((n, t) => /* @__PURE__ */ ce.createElement(n.tag, Je({
1752
+ key: t
1753
+ }, n.attr), xt(n.child)));
1754
+ }
1755
+ function Ne(s) {
1756
+ return (n) => /* @__PURE__ */ ce.createElement(zn, Ge({
1757
+ attr: Je({}, s.attr)
1758
+ }, n), xt(s.child));
1759
+ }
1760
+ function zn(s) {
1761
+ var n = (t) => {
1762
+ var {
1763
+ attr: a,
1764
+ size: l,
1765
+ title: o
1766
+ } = s, r = Sn(s, Cn), d = l || t.size || "1em", c;
1767
+ return t.className && (c = t.className), s.className && (c = (c ? c + " " : "") + s.className), /* @__PURE__ */ ce.createElement("svg", Ge({
1768
+ stroke: "currentColor",
1769
+ fill: "currentColor",
1770
+ strokeWidth: "0"
1771
+ }, t.attr, a, r, {
1772
+ className: c,
1773
+ style: Je(Je({
1774
+ color: s.color || t.color
1775
+ }, t.style), s.style),
1776
+ height: d,
1777
+ width: d,
1778
+ xmlns: "http://www.w3.org/2000/svg"
1779
+ }), o && /* @__PURE__ */ ce.createElement("title", null, o), s.children);
1780
+ };
1781
+ return Vs !== void 0 ? /* @__PURE__ */ ce.createElement(Vs.Consumer, null, (t) => n(t)) : n(mt);
1782
+ }
1783
+ function Mn(s) {
1784
+ return Ne({ tag: "svg", attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z" }, child: [] }] })(s);
1785
+ }
1786
+ function Tn() {
1787
+ const { theme: s } = Xt(), n = De(), t = De(), [a, l] = z(!1), [o, r] = z(!1), [d, c] = z(!1), [m, h] = z(""), [u, g] = z(!1), { authToken: p } = Ye();
1788
+ S((x) => x.selectedSheetId);
1789
+ const j = S((x) => x.dashboard.baseQueries), C = i((x) => x.card), v = S((x) => x.theme), y = i((x) => x.isShowingVisual), D = i(
1790
+ (x) => x.selectedConnectionId
1791
+ ), A = i(
1792
+ (x) => x.selectedDatabaseName
1793
+ ), f = i(
1794
+ (x) => x.selectedSchemaName
1795
+ );
1796
+ S(
1797
+ (x) => x.actions.updateFrameCard
1798
+ );
1799
+ const O = i((x) => x.selectedTableName), T = i((x) => x.card.sql), E = i((x) => x.card.python), U = Zt(T, j), Z = i((x) => x.selectedConnectionId), G = i((x) => x.frame), H = i((x) => x.filterValues), I = i((x) => x.applyFilters), {
1800
+ setCardCustomCfg: ee,
1801
+ setQueryResultColumns: P,
1802
+ setFilterValues: se,
1803
+ setCardSql: X,
1804
+ setCardPython: w,
1805
+ setQueryError: F,
1806
+ setPythonStdOut: b,
1807
+ setCardPreferences: L
1808
+ } = i((x) => x.actions), K = i((x) => x.onSave), B = i(
1809
+ (x) => x.actions.setApplyFilters
1810
+ ), de = i((x) => x.onClose), te = i((x) => x.actions.setCardData), xe = i((x) => x.actions.setSqlGen), pe = i((x) => x.runSql), fe = i((x) => x.actions.setRunSql), he = i(
1811
+ (x) => x.actions.setIsSqlRunning
1812
+ ), {
1813
+ data: J,
1814
+ isLoading: ae,
1815
+ isFetching: Ce,
1816
+ isSuccess: Re,
1817
+ isError: Se,
1818
+ error: Me,
1819
+ status: Xe,
1820
+ refetch: ge
1821
+ } = ye({
1822
+ queryKey: [U, E],
1823
+ queryFn: () => Ys(
1824
+ "https://semaphor.cloud/api/v1/query",
1825
+ (p == null ? void 0 : p.accessToken) || "",
1826
+ {
1827
+ connection_id: Z,
1828
+ sql: U,
1829
+ python: E === Ms ? "" : E,
1830
+ active_filters: I ? H : []
1831
+ }
1832
+ ),
1833
+ enabled: !1,
1834
+ retry: !1
1835
+ });
1836
+ $(() => {
1837
+ if (J && (te(J.records), b((J == null ? void 0 : J.output) || ""), J.records.length > 0)) {
1838
+ const { dimensionKeys: x } = ns(J.records);
1839
+ P(x);
1840
+ }
1841
+ }, [J, te, P, b]), $(() => {
1842
+ pe && (ge(), fe(!1));
1843
+ }, [pe, ge, fe]), $(() => {
1844
+ (ae || Ce) && he(!0), (Se || Re) && he(!1), Se ? (F(Me.message), te([]), P([]), b("")) : F("");
1845
+ }, [
1846
+ ae,
1847
+ Ce,
1848
+ J,
1849
+ b,
1850
+ Se,
1851
+ Re,
1852
+ he,
1853
+ te,
1854
+ P,
1855
+ F,
1856
+ Me
1857
+ ]);
1858
+ function _e() {
1859
+ X(""), te([]), xe({}), ee(""), L({});
1860
+ }
1861
+ const Te = (x) => {
1862
+ t.current = x;
1863
+ };
1864
+ function N() {
1865
+ let x = T;
1866
+ T && !T.includes("{{") && (x = gn(T), X(x));
1867
+ const ne = {
1868
+ ...C,
1869
+ lastSelectedSchema: f,
1870
+ lastSelectedDatabase: A,
1871
+ lastSelectedTable: O,
1872
+ connectionId: D,
1873
+ type: y ? C.type : "table",
1874
+ sql: x,
1875
+ customCfg: y ? C.customCfg : null
1876
+ }, Ae = G.cards.map(
1877
+ (je) => je.id === C.id ? ne : je
1878
+ );
1879
+ K == null || K({
1880
+ ...G,
1881
+ cards: Ae
1882
+ });
1883
+ }
1884
+ function Ct() {
1885
+ de == null || de();
1886
+ }
1887
+ function St(x) {
1888
+ const ne = getComputedStyle(
1889
+ document.documentElement
1890
+ ).getPropertyValue(x);
1891
+ return kt(ne);
1892
+ }
1893
+ function kt(x) {
1894
+ const [ne, Ae, je] = x.split(" "), Y = parseFloat(ne), Ot = parseFloat(Ae), zt = parseFloat(je), Mt = Ot / 100, Fs = zt / 100, ue = (1 - Math.abs(2 * Fs - 1)) * Mt, ke = ue * (1 - Math.abs(Y / 60 % 2 - 1)), Ze = Fs - ue / 2;
1895
+ let re = 0, le = 0, ie = 0;
1896
+ 0 <= Y && Y < 60 ? (re = ue, le = ke, ie = 0) : 60 <= Y && Y < 120 ? (re = ke, le = ue, ie = 0) : 120 <= Y && Y < 180 ? (re = 0, le = ue, ie = ke) : 180 <= Y && Y < 240 ? (re = 0, le = ke, ie = ue) : 240 <= Y && Y < 300 ? (re = ke, le = 0, ie = ue) : 300 <= Y && Y < 360 && (re = ue, le = 0, ie = ke), re = Math.round((re + Ze) * 255), le = Math.round((le + Ze) * 255), ie = Math.round((ie + Ze) * 255);
1897
+ const es = (Tt) => {
1898
+ const ss = Tt.toString(16);
1899
+ return ss.length == 1 ? "0" + ss : ss;
1900
+ };
1901
+ return `#${es(re)}${es(le)}${es(ie)}`;
1902
+ }
1903
+ $(() => {
1904
+ const x = n.current, ne = t.current;
1905
+ if (x) {
1906
+ const Ae = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light", je = v === "system" ? Ae : v;
1907
+ x.editor.defineTheme("default", {
1908
+ // base: theme === 'light' ? 'hc-light' : 'vs-dark',
1909
+ base: je === "light" ? "vs" : "vs-dark",
1910
+ inherit: !0,
1911
+ rules: [],
1912
+ colors: {
1913
+ // 'editor.background': activeTheme === 'light' ? '#ffffff' : '#020817',
1914
+ "editor.background": je === "light" ? "#ffffff" : St("--background")
1915
+ }
1916
+ }), x.editor.setTheme("default");
1917
+ }
1918
+ return ne && x && ne.addCommand(
1919
+ x.KeyMod.Shift | x.KeyCode.Enter,
1920
+ function() {
1921
+ return console.log("Executing query..."), ge(), !1;
1922
+ }
1923
+ ), () => {
1924
+ };
1925
+ }, [s, v, n.current]);
1926
+ function ws(x) {
1927
+ n.current = x;
1928
+ }
1929
+ function wt() {
1930
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1931
+ o && /* @__PURE__ */ e.jsx(
1932
+ "div",
1933
+ {
1934
+ className: "xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",
1935
+ role: "editor-filter-container",
1936
+ children: /* @__PURE__ */ e.jsxs("div", { className: "w-[99%]", children: [
1937
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 pt-3", children: [
1938
+ /* @__PURE__ */ e.jsx(
1939
+ bn,
1940
+ {
1941
+ checked: I,
1942
+ onCheckedChange: () => B(!I),
1943
+ text: "Apply Filters"
1944
+ }
1945
+ ),
1946
+ /* @__PURE__ */ e.jsx(yn, {}),
1947
+ H && o && /* @__PURE__ */ e.jsx(
1948
+ Ee,
1949
+ {
1950
+ onClick: () => r(!1),
1951
+ className: "bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"
1952
+ }
1953
+ )
1954
+ ] }),
1955
+ /* @__PURE__ */ e.jsx(
1956
+ Be,
1957
+ {
1958
+ theme: "default",
1959
+ onChange: (x) => {
1960
+ if (x)
1961
+ try {
1962
+ JSON.parse(x), se(JSON.parse(x));
1963
+ } catch {
1964
+ }
1965
+ },
1966
+ defaultLanguage: "json",
1967
+ className: "mt-1 min-h-[220px]",
1968
+ value: JSON.stringify(H, null, 2),
1969
+ options: {
1970
+ readOnly: !0,
1971
+ minimap: {
1972
+ enabled: !1
1973
+ },
1974
+ lineNumbers: "off",
1975
+ glyphMargin: !1,
1976
+ wordWrap: "on",
1977
+ scrollbar: {
1978
+ verticalScrollbarSize: 0,
1979
+ horizontalScrollbarSize: 0
1980
+ },
1981
+ fontSize: 12,
1982
+ renderLineHighlight: "none"
1983
+ }
1984
+ }
1985
+ )
1986
+ ] })
1987
+ }
1988
+ ),
1989
+ H && !o && /* @__PURE__ */ e.jsx(
1990
+ rt,
1991
+ {
1992
+ onClick: () => r(!0),
1993
+ className: W(
1994
+ "absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",
1995
+ {
1996
+ "font-bold text-red-800": I
1997
+ }
1998
+ )
1999
+ }
2000
+ )
2001
+ ] });
2002
+ }
2003
+ function Ft() {
2004
+ return /* @__PURE__ */ e.jsxs(
2005
+ rs,
2006
+ {
2007
+ className: "flex grow pb-1",
2008
+ direction: "vertical",
2009
+ role: "editor-resizable-group",
2010
+ children: [
2011
+ /* @__PURE__ */ e.jsxs(
2012
+ Fe,
2013
+ {
2014
+ id: "1",
2015
+ order: 1,
2016
+ defaultSize: a ? 20 : 100,
2017
+ className: "relative flex grow",
2018
+ children: [
2019
+ /* @__PURE__ */ e.jsx(
2020
+ "div",
2021
+ {
2022
+ role: "sql-container",
2023
+ className: "relative flex w-[99%]",
2024
+ children: /* @__PURE__ */ e.jsx(
2025
+ Be,
2026
+ {
2027
+ theme: "default",
2028
+ className: "pt-3",
2029
+ onChange: (x) => {
2030
+ X(x);
2031
+ },
2032
+ value: T,
2033
+ options: {
2034
+ minimap: {
2035
+ enabled: !1
2036
+ },
2037
+ wordWrap: "on",
2038
+ scrollbar: {
2039
+ verticalScrollbarSize: 0,
2040
+ horizontalScrollbarSize: 0
2041
+ },
2042
+ fontSize: 14,
2043
+ renderLineHighlight: "none"
2044
+ },
2045
+ defaultLanguage: "sql",
2046
+ defaultValue: "SELECT * FROM table",
2047
+ beforeMount: ws,
2048
+ onMount: Te
2049
+ }
2050
+ )
2051
+ }
2052
+ ),
2053
+ a && /* @__PURE__ */ e.jsx("code", { className: "absolute right-6 top-3 text-sm text-muted-foreground/70", children: "sql" })
2054
+ ]
2055
+ }
2056
+ ),
2057
+ a && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
2058
+ /* @__PURE__ */ e.jsx(ls, { withHandle: !0, className: "border" }),
2059
+ /* @__PURE__ */ e.jsxs(
2060
+ Fe,
2061
+ {
2062
+ id: "2",
2063
+ order: 2,
2064
+ defaultSize: 80,
2065
+ className: "relative flex grow",
2066
+ children: [
2067
+ /* @__PURE__ */ e.jsx(
2068
+ "div",
2069
+ {
2070
+ role: "python-container",
2071
+ className: "relative flex w-[99%] pt-0",
2072
+ children: /* @__PURE__ */ e.jsx(
2073
+ Be,
2074
+ {
2075
+ className: "pt-3",
2076
+ theme: "default",
2077
+ onChange: (x) => {
2078
+ w(x && x.trim() || "");
2079
+ },
2080
+ value: E || Ms,
2081
+ options: {
2082
+ minimap: {
2083
+ enabled: !1
2084
+ },
2085
+ wordWrap: "on",
2086
+ scrollbar: {
2087
+ verticalScrollbarSize: 0,
2088
+ horizontalScrollbarSize: 0
2089
+ },
2090
+ fontSize: 14,
2091
+ renderLineHighlight: "none"
2092
+ },
2093
+ defaultLanguage: "python",
2094
+ beforeMount: ws,
2095
+ onMount: Te
2096
+ }
2097
+ )
2098
+ }
2099
+ ),
2100
+ /* @__PURE__ */ e.jsx("code", { className: "absolute right-6 top-3 text-sm text-muted-foreground/70", children: "python" })
2101
+ ]
2102
+ }
2103
+ )
2104
+ ] })
2105
+ ]
2106
+ }
2107
+ );
2108
+ }
2109
+ return (
2110
+ // This is a tricky css, the pt-8 is to make sure the editor doesn't slide under the header
2111
+ /* @__PURE__ */ e.jsxs(
2112
+ "section",
2113
+ {
2114
+ role: "editor-section",
2115
+ className: "flex grow flex-col justify-end",
2116
+ children: [
2117
+ /* @__PURE__ */ e.jsxs(
2118
+ "div",
2119
+ {
2120
+ role: "sql-editor",
2121
+ className: "relative flex grow justify-between overflow-y-scroll",
2122
+ children: [
2123
+ Ft(),
2124
+ wt()
2125
+ ]
2126
+ }
2127
+ ),
2128
+ /* @__PURE__ */ e.jsxs(
2129
+ "div",
2130
+ {
2131
+ role: "editor-controls",
2132
+ className: "item-center flex flex-wrap justify-between gap-2 px-6 py-4",
2133
+ children: [
2134
+ /* @__PURE__ */ e.jsxs("div", { className: "flex grow items-center gap-2", children: [
2135
+ /* @__PURE__ */ e.jsxs(
2136
+ k,
2137
+ {
2138
+ title: "Shift + Enter",
2139
+ disabled: ae || Ce,
2140
+ onClick: () => {
2141
+ ge();
2142
+ },
2143
+ className: "shrink-0",
2144
+ size: "sm",
2145
+ variant: "outline",
2146
+ children: [
2147
+ ae || Ce ? /* @__PURE__ */ e.jsx(Le, { className: "mr-2 h-4 w-4 animate-spin text-foreground/50" }) : /* @__PURE__ */ e.jsx(tn, { className: "mr-2 h-4 w-4" }),
2148
+ "Run"
2149
+ ]
2150
+ }
2151
+ ),
2152
+ Se && /* @__PURE__ */ e.jsx(
2153
+ jn,
2154
+ {
2155
+ error: Me.message,
2156
+ setShowAIDialog: c,
2157
+ setTriggerAIRun: g,
2158
+ setUserInputforAI: h
2159
+ }
2160
+ ),
2161
+ /* @__PURE__ */ e.jsxs(
2162
+ k,
2163
+ {
2164
+ onClick: _e,
2165
+ className: "",
2166
+ size: "sm",
2167
+ variant: "outline",
2168
+ children: [
2169
+ /* @__PURE__ */ e.jsx(Ua, { className: "mr-2 size-4" }),
2170
+ "Clear"
2171
+ ]
2172
+ }
2173
+ ),
2174
+ /* @__PURE__ */ e.jsx(
2175
+ Js,
2176
+ {
2177
+ pressed: a,
2178
+ onPressedChange: (x) => l(x),
2179
+ className: "",
2180
+ size: "sm",
2181
+ variant: "outline",
2182
+ children: /* @__PURE__ */ e.jsx(Mn, { className: "size-4 text-foreground/70" })
2183
+ }
2184
+ ),
2185
+ /* @__PURE__ */ e.jsx(
2186
+ Nn,
2187
+ {
2188
+ open: d,
2189
+ setOpen: c,
2190
+ userInput: m,
2191
+ triggerAIRun: u,
2192
+ setTriggerAIRun: g,
2193
+ setUserInput: (x) => h(x)
2194
+ }
2195
+ )
2196
+ ] }),
2197
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
2198
+ /* @__PURE__ */ e.jsxs(
2199
+ k,
2200
+ {
2201
+ onClick: N,
2202
+ size: "sm",
2203
+ variant: "outline",
2204
+ children: [
2205
+ /* @__PURE__ */ e.jsx(ea, { className: "mr-2 size-4 font-bold text-green-600" }),
2206
+ "Accept"
2207
+ ]
2208
+ }
2209
+ ),
2210
+ /* @__PURE__ */ e.jsxs(
2211
+ k,
2212
+ {
2213
+ onClick: Ct,
2214
+ className: "w-full",
2215
+ size: "sm",
2216
+ variant: "outline",
2217
+ children: [
2218
+ /* @__PURE__ */ e.jsx(Ee, { className: "mr-2 size-4" }),
2219
+ "Close"
2220
+ ]
2221
+ }
2222
+ )
2223
+ ] })
2224
+ ]
2225
+ }
2226
+ )
2227
+ ]
2228
+ }
2229
+ )
2230
+ );
2231
+ }
2232
+ function An({ data: s }) {
2233
+ var r;
2234
+ const [n, t] = ce.useState([]), l = Object.keys(s[0]).map((d) => ({
2235
+ // header: key,
2236
+ accessorKey: d,
2237
+ header: ({ column: c }) => {
2238
+ const m = c.getIsSorted();
2239
+ return /* @__PURE__ */ e.jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ e.jsxs(
2240
+ "div",
2241
+ {
2242
+ className: "flex cursor-pointer items-center",
2243
+ onClick: () => c.toggleSorting(c.getIsSorted() === "asc"),
2244
+ children: [
2245
+ d,
2246
+ m === "asc" ? /* @__PURE__ */ e.jsx(sa, { className: "ml-2 h-5 w-5" }) : m === "desc" ? /* @__PURE__ */ e.jsx(ta, { className: "ml-2 h-5 w-5" }) : null
2247
+ ]
2248
+ }
2249
+ ) });
2250
+ }
2251
+ })), o = aa({
2252
+ data: s,
2253
+ columns: l,
2254
+ getCoreRowModel: oa(),
2255
+ getPaginationRowModel: ca(),
2256
+ onSortingChange: t,
2257
+ getSortedRowModel: da(),
2258
+ manualPagination: !0,
2259
+ state: {
2260
+ sorting: n
2261
+ }
2262
+ });
2263
+ return /* @__PURE__ */ e.jsxs(na, { children: [
2264
+ /* @__PURE__ */ e.jsx(ra, { children: o.getHeaderGroups().map((d) => /* @__PURE__ */ e.jsx(ts, { children: d.headers.map((c) => /* @__PURE__ */ e.jsx(la, { className: "sticky top-0 bg-muted", children: c.isPlaceholder ? null : Ts(
2265
+ c.column.columnDef.header,
2266
+ c.getContext()
2267
+ ) }, c.id)) }, d.id)) }),
2268
+ /* @__PURE__ */ e.jsx(ia, { children: (r = o.getRowModel().rows) != null && r.length ? o.getRowModel().rows.map((d) => /* @__PURE__ */ e.jsx(
2269
+ ts,
2270
+ {
2271
+ className: "whitespace-nowrap py-2",
2272
+ "data-state": d.getIsSelected() && "selected",
2273
+ children: d.getVisibleCells().map((c) => /* @__PURE__ */ e.jsx(As, { children: Ts(c.column.columnDef.cell, c.getContext()) }, c.id))
2274
+ },
2275
+ d.id
2276
+ )) : /* @__PURE__ */ e.jsx(ts, { children: /* @__PURE__ */ e.jsx(As, { colSpan: l.length, className: "h-24 text-center", children: "No results." }) }) })
2277
+ ] });
2278
+ }
2279
+ function pt({
2280
+ // card,
2281
+ className: s,
2282
+ ...n
2283
+ }) {
2284
+ ce.useState(0);
2285
+ const t = S((r) => r.themeStyle), a = i((r) => r.card), l = i((r) => r.actions.setCard);
2286
+ if ($(() => {
2287
+ }, [
2288
+ a.data,
2289
+ a.type,
2290
+ a.cfg,
2291
+ a.customCfg,
2292
+ t,
2293
+ a.preferences
2294
+ ]), !a.id)
2295
+ return null;
2296
+ let o;
2297
+ return a.data && a.data.length > 0 && (o = st({
2298
+ data: a.data,
2299
+ cardType: a.type,
2300
+ cfg: a.cfg,
2301
+ customCfg: a.customCfg,
2302
+ preferences: a.preferences
2303
+ })), /* @__PURE__ */ e.jsxs(
2304
+ ha,
2305
+ {
2306
+ role: "editor-visual-card",
2307
+ className: W("relative flex h-full flex-col rounded-none", s),
2308
+ ...n,
2309
+ children: [
2310
+ /* @__PURE__ */ e.jsxs(ua, { className: "py-4", children: [
2311
+ /* @__PURE__ */ e.jsx(
2312
+ Es,
2313
+ {
2314
+ text: a.title,
2315
+ onSave: (r) => l({ ...a, title: r }),
2316
+ children: /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ e.jsx(ma, { className: "text-base", children: a.title }) })
2317
+ },
2318
+ a.title
2319
+ ),
2320
+ /* @__PURE__ */ e.jsx(
2321
+ Es,
2322
+ {
2323
+ text: a.description || "",
2324
+ onSave: (r) => l({ ...a, description: r }),
2325
+ children: /* @__PURE__ */ e.jsxs(xa, { children: [
2326
+ " ",
2327
+ a.description
2328
+ ] })
2329
+ },
2330
+ a.description
2331
+ )
2332
+ ] }),
2333
+ /* @__PURE__ */ e.jsxs(pa, { className: "flex grow flex-col pb-3", children: [
2334
+ a.type !== "table" && o && // <ChartJsVisual key={visualKey} cfg={cfg} />
2335
+ /* @__PURE__ */ e.jsx(
2336
+ fa,
2337
+ {
2338
+ cfg: o
2339
+ },
2340
+ JSON.stringify(o) + JSON.stringify(a.preferences)
2341
+ ),
2342
+ a.type === "table" && a.data && a.data.length > 0 && // All of the below css classes are #IMPORTANT for the table to scroll properly
2343
+ /* @__PURE__ */ e.jsx(ga, { className: "flex min-h-0 flex-1 grow basis-0", children: /* @__PURE__ */ e.jsx(ja, { card: a, data: a == null ? void 0 : a.data }) })
2344
+ ] })
2345
+ ]
2346
+ }
2347
+ );
2348
+ }
2349
+ function En() {
2350
+ const [s, n] = z(!1), [t, a] = z(""), [l, o] = z(""), [r, d] = z(""), c = i((v) => v.card), m = i(
2351
+ (v) => v.card.customCfg
2352
+ ), h = i(
2353
+ (v) => v.actions.setCardCustomCfg
2354
+ );
2355
+ function u(v) {
2356
+ var A, f;
2357
+ const y = {
2358
+ ...v,
2359
+ data: {
2360
+ ...v == null ? void 0 : v.data,
2361
+ datasets: (f = (A = v == null ? void 0 : v.data) == null ? void 0 : A.datasets) == null ? void 0 : f.map((O) => ({
2362
+ ...O,
2363
+ data: []
2364
+ }))
2365
+ }
2366
+ };
2367
+ return JSON.stringify(y, null, 1);
2368
+ }
2369
+ function g() {
2370
+ if (!c.data || c.data.length === 0)
2371
+ return;
2372
+ const v = st({
2373
+ data: c.data,
2374
+ cardType: c.type,
2375
+ cfg: c.cfg,
2376
+ preferences: c.preferences
2377
+ });
2378
+ v && (a(JSON.stringify(v, null, 1)), m && o(JSON.stringify(m, null, 1)));
2379
+ }
2380
+ function p() {
2381
+ if (l)
2382
+ try {
2383
+ const v = JSON.parse(l);
2384
+ return v ? (h(v), d(""), o(""), v) : void 0;
2385
+ } catch (v) {
2386
+ console.log(v), d("Invalid JSON");
2387
+ }
2388
+ }
2389
+ function j() {
2390
+ o(""), h(null);
2391
+ }
2392
+ function C() {
2393
+ let v;
2394
+ if (m) {
2395
+ const y = Is.cloneDeep(c.cfg), D = Is.merge(y, m);
2396
+ return v = u(D), v;
2397
+ }
2398
+ return t ? (v = u(JSON.parse(t)), v) : "";
2399
+ }
2400
+ return /* @__PURE__ */ e.jsxs(is, { open: s, onOpenChange: n, children: [
2401
+ /* @__PURE__ */ e.jsx(os, { asChild: !0, children: /* @__PURE__ */ e.jsx(
2402
+ k,
2403
+ {
2404
+ onClick: g,
2405
+ className: ` ${m && "border-foreground/50 dark:border-foreground/70"}`,
2406
+ size: "sm",
2407
+ variant: "outline",
2408
+ children: /* @__PURE__ */ e.jsx(ba, { className: "h-4 w-4" })
2409
+ }
2410
+ ) }),
2411
+ /* @__PURE__ */ e.jsxs(
2412
+ cs,
2413
+ {
2414
+ className: "max-h-[70vh] min-h-[70vh] min-w-[900px] overflow-auto",
2415
+ children: [
2416
+ /* @__PURE__ */ e.jsxs(ds, { className: "", children: [
2417
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
2418
+ /* @__PURE__ */ e.jsx(hs, { children: "Customize Card" }),
2419
+ /* @__PURE__ */ e.jsxs(We, { children: [
2420
+ /* @__PURE__ */ e.jsx(ms, { children: /* @__PURE__ */ e.jsx(
2421
+ Pa,
2422
+ {
2423
+ onClick: () => {
2424
+ navigator.clipboard.writeText(c.id);
2425
+ },
2426
+ className: "size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"
2427
+ }
2428
+ ) }),
2429
+ /* @__PURE__ */ e.jsx(Pe, { side: "right", align: "center", children: /* @__PURE__ */ e.jsx("p", { className: "text-xs", children: "Copy Card ID" }) })
2430
+ ] })
2431
+ ] }),
2432
+ /* @__PURE__ */ e.jsxs(us, { children: [
2433
+ "See the configuration options and documentation",
2434
+ /* @__PURE__ */ e.jsx(
2435
+ "a",
2436
+ {
2437
+ target: "_blank",
2438
+ className: "ml-1 text-blue-500 underline",
2439
+ href: "https://www.chartjs.org/docs/latest/samples/bar/vertical.html",
2440
+ children: "here."
2441
+ }
2442
+ )
2443
+ ] })
2444
+ ] }),
2445
+ /* @__PURE__ */ e.jsxs("div", { className: "flex grow gap-2", children: [
2446
+ /* @__PURE__ */ e.jsx(pt, { className: "w-1/2 rounded shadow-none" }),
2447
+ /* @__PURE__ */ e.jsxs(ya, { defaultValue: "custom-config", className: "flex w-1/2 flex-col", children: [
2448
+ /* @__PURE__ */ e.jsxs(va, { className: "justify-start rounded-sm rounded-b-none border border-b-0", children: [
2449
+ /* @__PURE__ */ e.jsxs(Ls, { value: "custom-config", children: [
2450
+ m && /* @__PURE__ */ e.jsx(Na, { className: "mr-1 h-5 w-5 text-green-600" }),
2451
+ m ? "Custom Config" : "Default Config"
2452
+ ] }),
2453
+ /* @__PURE__ */ e.jsx(Ls, { className: "", value: "output", children: "Output" })
2454
+ ] }),
2455
+ /* @__PURE__ */ e.jsx(
2456
+ Ds,
2457
+ {
2458
+ className: "bg-red-x mt-0 grow rounded-b border border-t-0 p-2",
2459
+ value: "output",
2460
+ children: /* @__PURE__ */ e.jsx(
2461
+ et,
2462
+ {
2463
+ disabled: !0,
2464
+ value: t,
2465
+ className: "h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"
2466
+ }
2467
+ )
2468
+ }
2469
+ ),
2470
+ /* @__PURE__ */ e.jsx(
2471
+ Ds,
2472
+ {
2473
+ className: "mt-0 grow rounded-b border border-t-0",
2474
+ value: "custom-config",
2475
+ children: /* @__PURE__ */ e.jsx(
2476
+ Be,
2477
+ {
2478
+ className: "h-full w-full overflow-hidden",
2479
+ theme: "default",
2480
+ options: {
2481
+ minimap: {
2482
+ enabled: !1
2483
+ },
2484
+ wordWrap: "on",
2485
+ scrollbar: {
2486
+ verticalScrollbarSize: 0,
2487
+ horizontalScrollbarSize: 0
2488
+ },
2489
+ fontSize: 14,
2490
+ renderLineHighlight: "none"
2491
+ },
2492
+ defaultLanguage: "json",
2493
+ value: C(),
2494
+ onChange: (v) => o(v)
2495
+ }
2496
+ )
2497
+ }
2498
+ )
2499
+ ] })
2500
+ ] }),
2501
+ /* @__PURE__ */ e.jsxs(Bs, { className: "flex items-center", children: [
2502
+ /* @__PURE__ */ e.jsx(_, { className: "mr-2 text-red-500", children: r }),
2503
+ /* @__PURE__ */ e.jsx(
2504
+ k,
2505
+ {
2506
+ disabled: !m,
2507
+ onClick: j,
2508
+ variant: "outline",
2509
+ children: "Reset"
2510
+ }
2511
+ ),
2512
+ /* @__PURE__ */ e.jsx(k, { onClick: p, variant: "outline", children: "Apply" }),
2513
+ /* @__PURE__ */ e.jsx(k, { onClick: () => n(!1), variant: "outline", children: "Close" })
2514
+ ] })
2515
+ ]
2516
+ }
2517
+ )
2518
+ ] });
2519
+ }
2520
+ function ft(s) {
2521
+ return Ne({ tag: "svg", attr: { viewBox: "0 0 1024 1024" }, child: [{ tag: "path", attr: { d: "M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z" }, child: [] }] })(s);
2522
+ }
2523
+ function gt(s) {
2524
+ return Ne({ tag: "svg", attr: { viewBox: "0 0 256 256", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z" }, child: [] }] })(s);
2525
+ }
2526
+ function jt(s) {
2527
+ return Ne({ tag: "svg", attr: { viewBox: "0 0 256 256", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z" }, child: [] }] })(s);
2528
+ }
2529
+ function bt(s) {
2530
+ return Ne({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }, child: [] }, { tag: "path", attr: { d: "M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" }, child: [] }, { tag: "path", attr: { d: "M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" }, child: [] }, { tag: "path", attr: { d: "M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0" }, child: [] }] })(s);
2531
+ }
2532
+ function yt(s) {
2533
+ return Ne({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z" }, child: [] }] })(s);
2534
+ }
2535
+ function vt(s) {
2536
+ return Ne({ tag: "svg", attr: { version: "1.2", baseProfile: "tiny", viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z" }, child: [] }] })(s);
2537
+ }
2538
+ function Ln() {
2539
+ const [s, n] = z(!1), t = i((d) => d.card.type), { setCardType: a, setCardPreferences: l } = i(
2540
+ (d) => d.actions
2541
+ ), o = i(
2542
+ (d) => d.actions.setCardCustomCfg
2543
+ );
2544
+ function r(d) {
2545
+ a(d), o(null), l({}), n(!1);
2546
+ }
2547
+ return /* @__PURE__ */ e.jsxs(Ie, { open: s, onOpenChange: n, children: [
2548
+ /* @__PURE__ */ e.jsx(qe, { asChild: !0, children: /* @__PURE__ */ e.jsx(k, { size: "sm", variant: "outline", children: /* @__PURE__ */ e.jsx(Dn, { className: "h-4 w-4", chartType: t }) }) }),
2549
+ /* @__PURE__ */ e.jsx(Ve, { className: "w-50", children: /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-3 place-items-center", children: [
2550
+ /* @__PURE__ */ e.jsx(
2551
+ k,
2552
+ {
2553
+ onClick: () => r("bar"),
2554
+ className: "font-normal",
2555
+ variant: "ghost",
2556
+ children: /* @__PURE__ */ e.jsx(vs, { className: "size-5" })
2557
+ }
2558
+ ),
2559
+ /* @__PURE__ */ e.jsx(
2560
+ k,
2561
+ {
2562
+ onClick: () => r("line"),
2563
+ variant: "ghost",
2564
+ children: /* @__PURE__ */ e.jsx(Ns, { className: "size-5" })
2565
+ }
2566
+ ),
2567
+ /* @__PURE__ */ e.jsx(
2568
+ k,
2569
+ {
2570
+ onClick: () => r("stackedBar"),
2571
+ variant: "ghost",
2572
+ children: /* @__PURE__ */ e.jsx(yt, { className: "size-5", strokeWidth: 0 })
2573
+ }
2574
+ ),
2575
+ /* @__PURE__ */ e.jsx(
2576
+ k,
2577
+ {
2578
+ onClick: () => r("scatter"),
2579
+ variant: "ghost",
2580
+ children: /* @__PURE__ */ e.jsx(ct, { className: "size-5" })
2581
+ }
2582
+ ),
2583
+ /* @__PURE__ */ e.jsx(
2584
+ k,
2585
+ {
2586
+ onClick: () => r("bubble"),
2587
+ variant: "ghost",
2588
+ children: /* @__PURE__ */ e.jsx(bt, { className: "size-4" })
2589
+ }
2590
+ ),
2591
+ /* @__PURE__ */ e.jsx(
2592
+ k,
2593
+ {
2594
+ onClick: () => r("pie"),
2595
+ variant: "ghost",
2596
+ children: /* @__PURE__ */ e.jsx(it, { className: "size-5" })
2597
+ }
2598
+ ),
2599
+ /* @__PURE__ */ e.jsx(
2600
+ k,
2601
+ {
2602
+ onClick: () => r("doughnut"),
2603
+ variant: "ghost",
2604
+ children: /* @__PURE__ */ e.jsx(gt, { className: "size-5", strokeWidth: 1 })
2605
+ }
2606
+ ),
2607
+ /* @__PURE__ */ e.jsx(
2608
+ k,
2609
+ {
2610
+ onClick: () => r("radar"),
2611
+ variant: "ghost",
2612
+ children: /* @__PURE__ */ e.jsx(
2613
+ ft,
2614
+ {
2615
+ className: "size-5 font-extralight",
2616
+ strokeWidth: 0.5
2617
+ }
2618
+ )
2619
+ }
2620
+ ),
2621
+ /* @__PURE__ */ e.jsx(
2622
+ k,
2623
+ {
2624
+ onClick: () => r("polarArea"),
2625
+ variant: "ghost",
2626
+ children: /* @__PURE__ */ e.jsx(jt, { className: "size-5" })
2627
+ }
2628
+ ),
2629
+ /* @__PURE__ */ e.jsx(
2630
+ k,
2631
+ {
2632
+ onClick: () => r("table"),
2633
+ variant: "ghost",
2634
+ children: /* @__PURE__ */ e.jsx(Cs, { className: "size-5" })
2635
+ }
2636
+ ),
2637
+ /* @__PURE__ */ e.jsx(
2638
+ k,
2639
+ {
2640
+ onClick: () => r("kpi"),
2641
+ variant: "ghost",
2642
+ children: /* @__PURE__ */ e.jsx(vt, { className: "size-6" })
2643
+ }
2644
+ )
2645
+ ] }) })
2646
+ ] });
2647
+ }
2648
+ function Dn({ chartType: s, className: n }) {
2649
+ switch (s) {
2650
+ case "bar":
2651
+ return /* @__PURE__ */ e.jsx(vs, { className: n });
2652
+ case "line":
2653
+ return /* @__PURE__ */ e.jsx(Ns, { className: n });
2654
+ case "pie":
2655
+ return /* @__PURE__ */ e.jsx(it, { className: n });
2656
+ case "radar":
2657
+ return /* @__PURE__ */ e.jsx(ft, { className: n });
2658
+ case "scatter":
2659
+ return /* @__PURE__ */ e.jsx(ct, { className: n });
2660
+ case "bubble":
2661
+ return /* @__PURE__ */ e.jsx(bt, { className: n });
2662
+ case "doughnut":
2663
+ return /* @__PURE__ */ e.jsx(gt, { className: n });
2664
+ case "stackedBar":
2665
+ return /* @__PURE__ */ e.jsx(yt, { className: "size-4 text-foreground/70" });
2666
+ case "polarArea":
2667
+ return /* @__PURE__ */ e.jsx(jt, { className: n });
2668
+ case "kpi":
2669
+ return /* @__PURE__ */ e.jsx(vt, { className: n });
2670
+ default:
2671
+ return /* @__PURE__ */ e.jsx(Cs, { className: n });
2672
+ }
2673
+ }
2674
+ function In() {
2675
+ const s = i(
2676
+ (t) => t.card.refreshInterval
2677
+ ), n = i(
2678
+ (t) => t.actions.setCardRefreshInterval
2679
+ );
2680
+ return /* @__PURE__ */ e.jsxs(Ie, { children: [
2681
+ /* @__PURE__ */ e.jsx(qe, { asChild: !0, children: /* @__PURE__ */ e.jsx(k, { size: "sm", variant: "outline", children: /* @__PURE__ */ e.jsx(_a, { className: "w-4 h-4" }) }) }),
2682
+ /* @__PURE__ */ e.jsx(Ve, { className: "w-[200px]", children: /* @__PURE__ */ e.jsx("div", { className: "grid gap-4", children: /* @__PURE__ */ e.jsx("div", { className: "grid gap-2", children: /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-5 items-center gap-1", children: [
2683
+ /* @__PURE__ */ e.jsx(_, { className: "col-span-3", htmlFor: "width", children: "Refresh Every" }),
2684
+ /* @__PURE__ */ e.jsx(
2685
+ Q,
2686
+ {
2687
+ value: s || "",
2688
+ onChange: (t) => n(t.target.value),
2689
+ id: "width",
2690
+ placeholder: "30s",
2691
+ className: "col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"
2692
+ }
2693
+ )
2694
+ ] }) }) }) })
2695
+ ] });
2696
+ }
2697
+ function _s() {
2698
+ i((r) => r.frame);
2699
+ const s = i((r) => r.card), n = i((r) => r.card.data), t = i((r) => r.isShowingVisual), a = i((r) => r.isSqlRunning), l = i((r) => r.queryError), o = i((r) => r.pythonStdOut);
2700
+ return i((r) => r.onSave), i((r) => r.onClose), i((r) => r.actions.setCardSql), i((r) => r.actions.setCardType), i((r) => r.actions.setSqlGen), s ? /* @__PURE__ */ e.jsxs("div", { className: "relative flex h-full flex-col pt-3", children: [
2701
+ a && /* @__PURE__ */ e.jsx(Le, { className: "absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10" }),
2702
+ /* @__PURE__ */ e.jsxs("div", { className: "mb-0 flex min-h-10 items-center justify-end gap-2 px-6", children: [
2703
+ t && /* @__PURE__ */ e.jsxs("div", { className: "flex grow items-center gap-2", children: [
2704
+ /* @__PURE__ */ e.jsx(Ln, {}),
2705
+ /* @__PURE__ */ e.jsx(En, {}),
2706
+ /* @__PURE__ */ e.jsx(In, {})
2707
+ ] }),
2708
+ /* @__PURE__ */ e.jsx(Vn, {})
2709
+ ] }),
2710
+ t ? s.type === "kpi" ? /* @__PURE__ */ e.jsx("div", { className: "flex grow items-center justify-center", children: /* @__PURE__ */ e.jsx("div", { className: "w-1/2 rounded-md border", children: /* @__PURE__ */ e.jsx(Ca, { isLoading: a, card: s }) }) }) : /* @__PURE__ */ e.jsx(pt, { className: "grow border-none shadow-none" }) : /* @__PURE__ */ e.jsxs("div", { className: "flex min-h-0 w-full flex-1 grow basis-0 px-6", children: [
2711
+ o && /* @__PURE__ */ e.jsx(qn, {}),
2712
+ s.data && s.data.length > 0 && /* @__PURE__ */ e.jsx(An, { data: n || [] }),
2713
+ l && /* @__PURE__ */ e.jsx("span", { className: "font-mono text-sm", children: l })
2714
+ ] })
2715
+ ] }) : /* @__PURE__ */ e.jsx(e.Fragment, { children: "No Active Card" });
2716
+ }
2717
+ function qn() {
2718
+ const s = i((t) => t.pythonStdOut);
2719
+ if (!s)
2720
+ return null;
2721
+ const n = s.replace(/\n/g, "<br>");
2722
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
2723
+ /* @__PURE__ */ e.jsx("p", { className: "font-mono text-sm", children: "Output:" }),
2724
+ /* @__PURE__ */ e.jsx(
2725
+ "div",
2726
+ {
2727
+ dangerouslySetInnerHTML: { __html: n },
2728
+ className: "bg-muted p-2 font-mono text-sm"
2729
+ }
2730
+ ),
2731
+ /* @__PURE__ */ e.jsx(tt, { className: "mb-2" })
2732
+ ] });
2733
+ }
2734
+ function Vn() {
2735
+ const s = i((t) => t.isShowingVisual), n = i(
2736
+ (t) => t.actions.setIsShowingVisual
2737
+ );
2738
+ return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
2739
+ /* @__PURE__ */ e.jsx(_, { htmlFor: "visualize", children: "Chart" }),
2740
+ /* @__PURE__ */ e.jsx(
2741
+ Sa,
2742
+ {
2743
+ checked: s,
2744
+ onCheckedChange: () => n(!s),
2745
+ id: "visualize",
2746
+ className: "data-[state=checked]:bg-foreground/50"
2747
+ }
2748
+ )
2749
+ ] });
2750
+ }
2751
+ function ze() {
2752
+ const [s, n] = z([]);
2753
+ i(
2754
+ (h) => h.card.cfg
2755
+ );
2756
+ const t = i((h) => h.card.preferences), { setCardCfg: a, setFilterOnClickColumnIndex: l, setCardPreferences: o } = i((h) => h.actions), r = i(
2757
+ (h) => h.queryResultColumns
2758
+ );
2759
+ i(
2760
+ (h) => {
2761
+ var u;
2762
+ return (u = h.card.preferences) == null ? void 0 : u.filterOnClickColumnIndex;
2763
+ }
2764
+ ), $(() => {
2765
+ r && n(new Array(r.length).fill(!1));
2766
+ }, [r]);
2767
+ function d(h, u) {
2768
+ var g, p;
2769
+ u ? t != null && t.onClickFilter && ((g = t == null ? void 0 : t.onClickFilter) == null ? void 0 : g.length) > 0 ? o({
2770
+ ...t,
2771
+ onClickFilter: [
2772
+ ...t.onClickFilter,
2773
+ {
2774
+ columnIndex: h,
2775
+ expression: ""
2776
+ }
2777
+ ]
2778
+ }) : o({
2779
+ ...t,
2780
+ onClickFilter: [
2781
+ {
2782
+ columnIndex: h,
2783
+ expression: ""
2784
+ }
2785
+ ]
2786
+ }) : (o({
2787
+ ...t,
2788
+ onClickFilter: (p = t == null ? void 0 : t.onClickFilter) == null ? void 0 : p.filter(
2789
+ (j) => j.columnIndex !== h
2790
+ )
2791
+ }), n((j) => {
2792
+ const C = [...j];
2793
+ return C[h] = !1, C;
2794
+ }));
2795
+ }
2796
+ function c(h, u) {
2797
+ var p;
2798
+ const g = (p = t == null ? void 0 : t.onClickFilter) == null ? void 0 : p.map((j) => j.columnIndex === h ? {
2799
+ ...j,
2800
+ expression: u.target.value
2801
+ } : j);
2802
+ o({
2803
+ ...t,
2804
+ onClickFilter: g
2805
+ });
2806
+ }
2807
+ function m(h) {
2808
+ var u, g, p, j;
2809
+ if (s != null && s[h] || (g = (u = t == null ? void 0 : t.onClickFilter) == null ? void 0 : u.find((C) => C.columnIndex === h)) != null && g.expression)
2810
+ return /* @__PURE__ */ e.jsx(
2811
+ Q,
2812
+ {
2813
+ value: (j = (p = t == null ? void 0 : t.onClickFilter) == null ? void 0 : p.find((C) => C.columnIndex === h)) == null ? void 0 : j.expression,
2814
+ onChange: (C) => c(h, C),
2815
+ type: "text",
2816
+ className: " h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",
2817
+ placeholder: "Expression"
2818
+ }
2819
+ );
2820
+ }
2821
+ return /* @__PURE__ */ e.jsx(e.Fragment, { children: r == null ? void 0 : r.map((h, u) => {
2822
+ var g, p;
2823
+ return /* @__PURE__ */ e.jsx(
2824
+ "div",
2825
+ {
2826
+ className: "flex items-center justify-between space-y-2 xbg-red-100 group",
2827
+ children: /* @__PURE__ */ e.jsxs("div", { className: " grow", children: [
2828
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center py-2 space-x-2", children: [
2829
+ /* @__PURE__ */ e.jsx(
2830
+ Qe,
2831
+ {
2832
+ checked: !!((g = t == null ? void 0 : t.onClickFilter) != null && g.find(
2833
+ (j) => j.columnIndex === u
2834
+ )),
2835
+ onCheckedChange: (j) => d(u, j)
2836
+ }
2837
+ ),
2838
+ /* @__PURE__ */ e.jsx(
2839
+ "label",
2840
+ {
2841
+ className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
2842
+ children: h
2843
+ }
2844
+ ),
2845
+ /* @__PURE__ */ e.jsx("div", { className: "flex gap-2 items-center ", children: ((p = t == null ? void 0 : t.onClickFilter) == null ? void 0 : p.find(
2846
+ (j) => j.columnIndex === u
2847
+ )) && /* @__PURE__ */ e.jsx(
2848
+ lt,
2849
+ {
2850
+ onClick: () => {
2851
+ n((j) => {
2852
+ const C = [...j];
2853
+ return C[u] = !j[u], C;
2854
+ });
2855
+ },
2856
+ className: " invisible group-hover:visible size-3 text-gray-400 cursor-pointer"
2857
+ }
2858
+ ) })
2859
+ ] }),
2860
+ m(u)
2861
+ ] })
2862
+ },
2863
+ h
2864
+ );
2865
+ }) });
2866
+ }
2867
+ function Ss() {
2868
+ var o, r;
2869
+ const s = i((d) => d.card.preferences), n = i(
2870
+ (d) => d.card.cfg
2871
+ ), { setCardCfg: t, setCardPreferences: a } = i(
2872
+ (d) => d.actions
2873
+ );
2874
+ (o = n == null ? void 0 : n.options) != null && o.indexAxis;
2875
+ function l(d) {
2876
+ var h, u, g, p, j, C;
2877
+ let c = {};
2878
+ (h = s == null ? void 0 : s.chartOptions) != null && h.scales && (c = {
2879
+ x: (g = (u = s == null ? void 0 : s.chartOptions) == null ? void 0 : u.scales) == null ? void 0 : g.y,
2880
+ y: (j = (p = s == null ? void 0 : s.chartOptions) == null ? void 0 : p.scales) == null ? void 0 : j.x
2881
+ });
2882
+ const m = {
2883
+ ...s,
2884
+ chartOptions: {
2885
+ ...s == null ? void 0 : s.chartOptions,
2886
+ scales: {
2887
+ ...(C = s == null ? void 0 : s.chartOptions) == null ? void 0 : C.scales,
2888
+ ...c
2889
+ },
2890
+ indexAxis: d
2891
+ }
2892
+ };
2893
+ a(m);
2894
+ }
2895
+ return /* @__PURE__ */ e.jsxs(
2896
+ at,
2897
+ {
2898
+ value: ((r = s == null ? void 0 : s.chartOptions) == null ? void 0 : r.indexAxis) || "x",
2899
+ onValueChange: l,
2900
+ className: "flex gap-3",
2901
+ defaultValue: "x",
2902
+ children: [
2903
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
2904
+ /* @__PURE__ */ e.jsx(Ue, { value: "x", id: "r1" }),
2905
+ /* @__PURE__ */ e.jsx("label", { className: "text-sm", htmlFor: "r1", children: "Vertical" })
2906
+ ] }),
2907
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
2908
+ /* @__PURE__ */ e.jsx(Ue, { value: "y", id: "r2" }),
2909
+ /* @__PURE__ */ e.jsx("label", { className: "text-sm", htmlFor: "r2", children: "Horizontal" })
2910
+ ] })
2911
+ ]
2912
+ }
2913
+ );
2914
+ }
2915
+ const be = "focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";
2916
+ function Hs(s) {
2917
+ var t, a, l;
2918
+ const n = nt(s);
2919
+ return ((l = (a = (t = s == null ? void 0 : s.chartOptions) == null ? void 0 : t.scales) == null ? void 0 : a[n]) == null ? void 0 : l.type) || "linear";
2920
+ }
2921
+ function Rn() {
2922
+ var H, I, ee, P, se, X;
2923
+ const [s, n] = z(!1), t = i((w) => {
2924
+ var F;
2925
+ return (F = w.card) == null ? void 0 : F.preferences;
2926
+ }), a = nt(t), [l, o] = z(
2927
+ Hs(t)
2928
+ ), [r, d] = z(
2929
+ ((ee = (I = (H = t == null ? void 0 : t.chartOptions) == null ? void 0 : H.scales) == null ? void 0 : I[a]) == null ? void 0 : ee.min) || ""
2930
+ ), [c, m] = z(
2931
+ ((X = (se = (P = t == null ? void 0 : t.chartOptions) == null ? void 0 : P.scales) == null ? void 0 : se[a]) == null ? void 0 : X.max) || ""
2932
+ ), [h, u] = z(r || c ? "custom" : "auto"), [g, p] = z(""), [j, C] = z(""), [v, y] = z(""), [D, A] = z(""), [f, O] = z(""), T = i(
2933
+ (w) => w.actions.setCardPreferences
2934
+ );
2935
+ $(() => {
2936
+ var w, F, b, L, K, B, de, te, xe, pe, fe, he, J, ae;
2937
+ o(Hs(t)), d(
2938
+ ((b = (F = (w = t == null ? void 0 : t.chartOptions) == null ? void 0 : w.scales) == null ? void 0 : F[a]) == null ? void 0 : b.min) === 0 ? 0 : ""
2939
+ ), m(((B = (K = (L = t == null ? void 0 : t.chartOptions) == null ? void 0 : L.scales) == null ? void 0 : K[a]) == null ? void 0 : B.max) || ""), p(
2940
+ ((pe = (xe = (te = (de = t == null ? void 0 : t.chartOptions) == null ? void 0 : de.scales) == null ? void 0 : te[a]) == null ? void 0 : xe.ticks) == null ? void 0 : pe.stepSize) || ""
2941
+ ), C(((fe = t == null ? void 0 : t.numberAxisFormat) == null ? void 0 : fe.format) || ""), y(((he = t == null ? void 0 : t.numberAxisFormat) == null ? void 0 : he.suffix) || ""), A(((J = t == null ? void 0 : t.numberAxisFormat) == null ? void 0 : J.currency) || ""), O(((ae = t == null ? void 0 : t.numberAxisFormat) == null ? void 0 : ae.locale) || "");
2942
+ }, [s, t, a]);
2943
+ function E(w, F) {
2944
+ return F === "" || /^[0-9\b]+$/.test(F) ? Number(F) : Number(w);
2945
+ }
2946
+ function U() {
2947
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
2948
+ /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-9 items-center gap-2", children: [
2949
+ /* @__PURE__ */ e.jsx(_, { className: "col-span-3", htmlFor: "format", children: "Format" }),
2950
+ /* @__PURE__ */ e.jsx(
2951
+ Q,
2952
+ {
2953
+ value: j,
2954
+ placeholder: "000,0.00",
2955
+ onChange: (w) => C(w.target.value),
2956
+ id: "format",
2957
+ className: `col-span-4 h-8 w-full tracking-wide ${be}`
2958
+ }
2959
+ ),
2960
+ /* @__PURE__ */ e.jsx(
2961
+ Q,
2962
+ {
2963
+ value: v,
2964
+ placeholder: "M",
2965
+ onChange: (w) => y(w.target.value),
2966
+ id: "unit",
2967
+ className: `col-span-2 h-8 w-full ${be}`
2968
+ }
2969
+ )
2970
+ ] }),
2971
+ /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-6 items-center gap-2", children: [
2972
+ /* @__PURE__ */ e.jsx(
2973
+ _,
2974
+ {
2975
+ className: "col-span-2 hover:cursor-pointer hover:underline",
2976
+ htmlFor: "currency",
2977
+ children: /* @__PURE__ */ e.jsx(
2978
+ "a",
2979
+ {
2980
+ target: "_blank",
2981
+ href: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",
2982
+ children: "Currency"
2983
+ }
2984
+ )
2985
+ }
2986
+ ),
2987
+ /* @__PURE__ */ e.jsx(
2988
+ Q,
2989
+ {
2990
+ value: D,
2991
+ placeholder: "USD",
2992
+ onChange: (w) => A(w.target.value),
2993
+ id: "currency",
2994
+ className: `col-span-2 h-8 w-full ${be}`
2995
+ }
2996
+ ),
2997
+ /* @__PURE__ */ e.jsx(
2998
+ Q,
2999
+ {
3000
+ value: f,
3001
+ placeholder: "en-US",
3002
+ onChange: (w) => O(w.target.value),
3003
+ id: "locale",
3004
+ className: `col-span-2 h-8 w-full ${be}`
3005
+ }
3006
+ )
3007
+ ] })
3008
+ ] });
3009
+ }
3010
+ function Z() {
3011
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
3012
+ /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-3 items-center gap-2", children: [
3013
+ /* @__PURE__ */ e.jsx(_, { htmlFor: "range", children: "Range" }),
3014
+ /* @__PURE__ */ e.jsx(
3015
+ Q,
3016
+ {
3017
+ id: "min",
3018
+ value: r,
3019
+ onChange: (w) => d((F) => E(F, w.target.value)),
3020
+ className: `col-span-1 h-8 w-full ${be}`
3021
+ }
3022
+ ),
3023
+ /* @__PURE__ */ e.jsx(
3024
+ Q,
3025
+ {
3026
+ value: c,
3027
+ onChange: (w) => m((F) => E(F, w.target.value)),
3028
+ id: "max",
3029
+ className: `col-span-1 h-8 w-full ${be}`
3030
+ }
3031
+ )
3032
+ ] }),
3033
+ /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-3 items-center gap-2", children: [
3034
+ /* @__PURE__ */ e.jsx(_, { htmlFor: "step-size", children: "Step Size" }),
3035
+ /* @__PURE__ */ e.jsx(
3036
+ Q,
3037
+ {
3038
+ value: g,
3039
+ onChange: (w) => p((F) => E(F, w.target.value)),
3040
+ id: "step-size",
3041
+ className: `col-span-1 h-8 w-full ${be}`
3042
+ }
3043
+ )
3044
+ ] })
3045
+ ] });
3046
+ }
3047
+ function G() {
3048
+ var b;
3049
+ let w = {};
3050
+ h === "custom" && (w = {
3051
+ min: r,
3052
+ max: c,
3053
+ ticks: {
3054
+ stepSize: g
3055
+ }
3056
+ });
3057
+ const F = {
3058
+ ...t || {},
3059
+ chartOptions: {
3060
+ ...t == null ? void 0 : t.chartOptions,
3061
+ scales: {
3062
+ ...(b = t == null ? void 0 : t.chartOptions) == null ? void 0 : b.scales,
3063
+ [a]: {
3064
+ // ...cardPreferences?.chartOptions?.scales?.[axis],
3065
+ type: l,
3066
+ ...l === "linear" ? w : {}
3067
+ }
3068
+ }
3069
+ },
3070
+ numberAxisFormat: {
3071
+ format: j,
3072
+ suffix: v,
3073
+ currency: D,
3074
+ locale: f
3075
+ }
3076
+ };
3077
+ T(F);
3078
+ }
3079
+ return /* @__PURE__ */ e.jsxs(Ie, { onOpenChange: (w) => n(w), children: [
3080
+ /* @__PURE__ */ e.jsx(qe, { asChild: !0, children: /* @__PURE__ */ e.jsx(ka, { className: "size-4 cursor-pointer text-muted-foreground hover:text-foreground" }) }),
3081
+ /* @__PURE__ */ e.jsx(Ve, { align: "center", className: "max-w-65", children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-4", children: [
3082
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
3083
+ /* @__PURE__ */ e.jsx("h4", { className: "font-medium leading-none", children: "Scale Options" }),
3084
+ /* @__PURE__ */ e.jsx("p", { className: "text-sm text-muted-foreground", children: "Set the scale for the number axis" })
3085
+ ] }),
3086
+ /* @__PURE__ */ e.jsxs("div", { className: "grid gap-2", children: [
3087
+ /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-3 items-center gap-2", children: [
3088
+ /* @__PURE__ */ e.jsx(_, { htmlFor: "scale", children: "Type" }),
3089
+ /* @__PURE__ */ e.jsxs(
3090
+ xs,
3091
+ {
3092
+ value: l,
3093
+ onValueChange: (w) => o(w),
3094
+ children: [
3095
+ /* @__PURE__ */ e.jsx(ps, { className: "col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0", children: /* @__PURE__ */ e.jsx(fs, {}) }),
3096
+ /* @__PURE__ */ e.jsx(gs, { id: "type", children: /* @__PURE__ */ e.jsxs(js, { children: [
3097
+ /* @__PURE__ */ e.jsx(Ke, { children: "Option" }),
3098
+ /* @__PURE__ */ e.jsx(me, { value: "linear", children: "Linear" }),
3099
+ /* @__PURE__ */ e.jsx(me, { value: "logarithmic", children: "Logarithmic" })
3100
+ ] }) })
3101
+ ]
3102
+ }
3103
+ )
3104
+ ] }),
3105
+ l == "linear" && /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-3 items-center gap-2 py-1", children: [
3106
+ /* @__PURE__ */ e.jsx(_, { htmlFor: "scale-option", children: "Setup" }),
3107
+ /* @__PURE__ */ e.jsxs(
3108
+ at,
3109
+ {
3110
+ id: "scale-option",
3111
+ value: h,
3112
+ onValueChange: (w) => u(w),
3113
+ className: "col-span-2 flex gap-3",
3114
+ defaultValue: "x",
3115
+ children: [
3116
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
3117
+ /* @__PURE__ */ e.jsx(Ue, { value: "auto", id: "r1" }),
3118
+ /* @__PURE__ */ e.jsx("label", { className: "text-sm", htmlFor: "r1", children: "Auto" })
3119
+ ] }),
3120
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
3121
+ /* @__PURE__ */ e.jsx(Ue, { value: "custom", id: "r2" }),
3122
+ /* @__PURE__ */ e.jsx("label", { className: "text-sm", htmlFor: "r2", children: "Custom" })
3123
+ ] })
3124
+ ]
3125
+ }
3126
+ )
3127
+ ] }),
3128
+ h === "custom" && l == "linear" && Z(),
3129
+ U(),
3130
+ /* @__PURE__ */ e.jsx(wa, {}),
3131
+ /* @__PURE__ */ e.jsx("div", { className: "grid grid-cols-3", children: /* @__PURE__ */ e.jsx(
3132
+ k,
3133
+ {
3134
+ onClick: G,
3135
+ variant: "secondary",
3136
+ className: "col-span-1 col-start-3 h-8 w-full",
3137
+ children: "Apply"
3138
+ }
3139
+ ) })
3140
+ ] })
3141
+ ] }) })
3142
+ ] });
3143
+ }
3144
+ function _n({ idx: s }) {
3145
+ var d;
3146
+ const n = i((c) => {
3147
+ var m;
3148
+ return (m = c.card) == null ? void 0 : m.preferences;
3149
+ }), t = i(
3150
+ (c) => {
3151
+ var m;
3152
+ return (m = c.card.preferences) == null ? void 0 : m.datasetOptions;
3153
+ }
3154
+ ), a = i(
3155
+ (c) => c.actions.setCardPreferences
3156
+ ), l = (d = n == null ? void 0 : n.chartOptions) == null ? void 0 : d.indexAxis, o = t == null ? void 0 : t.find((c) => c.idx === s);
3157
+ function r(c, m) {
3158
+ (c === "end" || c === "start") && Oa(za());
3159
+ const h = {
3160
+ display: c !== "none",
3161
+ align: c,
3162
+ anchor: c,
3163
+ clamp: !0
3164
+ };
3165
+ if (!o)
3166
+ a({
3167
+ ...n,
3168
+ datasetOptions: [
3169
+ ...t || [],
3170
+ {
3171
+ idx: m,
3172
+ datalabels: h
3173
+ }
3174
+ ]
3175
+ });
3176
+ else {
3177
+ const u = { ...o };
3178
+ u.datalabels = h;
3179
+ const g = t == null ? void 0 : t.map(
3180
+ (p) => p.idx === m ? u : p
3181
+ );
3182
+ a({
3183
+ ...n,
3184
+ datasetOptions: g
3185
+ });
3186
+ }
3187
+ }
3188
+ return /* @__PURE__ */ e.jsxs(Ie, { children: [
3189
+ /* @__PURE__ */ e.jsx(qe, { children: /* @__PURE__ */ e.jsx(ln, { className: "invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible" }) }),
3190
+ /* @__PURE__ */ e.jsx(Ve, { className: "w-fit p-1", children: /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1", children: [
3191
+ /* @__PURE__ */ e.jsx(
3192
+ k,
3193
+ {
3194
+ onClick: () => r("none", s),
3195
+ size: "sm",
3196
+ variant: "secondary",
3197
+ className: "h-7 p-1 text-xs font-normal",
3198
+ children: /* @__PURE__ */ e.jsx(Fa, { className: "size-4" })
3199
+ }
3200
+ ),
3201
+ /* @__PURE__ */ e.jsx(
3202
+ k,
3203
+ {
3204
+ onClick: () => r("start", s),
3205
+ size: "sm",
3206
+ variant: "secondary",
3207
+ className: "h-7 p-1 text-xs font-normal",
3208
+ children: /* @__PURE__ */ e.jsx(
3209
+ Ya,
3210
+ {
3211
+ className: W("h-4 w-4", {
3212
+ "rotate-90": l === "y"
3213
+ })
3214
+ }
3215
+ )
3216
+ }
3217
+ ),
3218
+ /* @__PURE__ */ e.jsx(
3219
+ k,
3220
+ {
3221
+ onClick: () => r("center", s),
3222
+ size: "sm",
3223
+ variant: "secondary",
3224
+ className: "h-7 p-1 text-xs font-normal",
3225
+ children: /* @__PURE__ */ e.jsx(
3226
+ Za,
3227
+ {
3228
+ className: W("h-4 w-4", {
3229
+ "rotate-90": l === "y"
3230
+ })
3231
+ }
3232
+ )
3233
+ }
3234
+ ),
3235
+ /* @__PURE__ */ e.jsx(
3236
+ k,
3237
+ {
3238
+ onClick: () => r("end", s),
3239
+ size: "sm",
3240
+ variant: "secondary",
3241
+ className: "h-7 p-1 text-xs font-normal",
3242
+ children: /* @__PURE__ */ e.jsx(
3243
+ Xa,
3244
+ {
3245
+ className: W("h-4 w-4", {
3246
+ "rotate-90": l === "y"
3247
+ })
3248
+ }
3249
+ )
3250
+ }
3251
+ )
3252
+ ] }) })
3253
+ ] });
3254
+ }
3255
+ function Nt() {
3256
+ const s = i((c) => c.card), n = i(
3257
+ (c) => {
3258
+ var m, h, u;
3259
+ return (u = (h = (m = c == null ? void 0 : c.card) == null ? void 0 : m.preferences) == null ? void 0 : h.chartOptions) == null ? void 0 : u.indexAxis;
3260
+ }
3261
+ ), t = n === "y" ? "Y axis" : "X axis", a = n === "y" ? "X axis" : "Y axis", {
3262
+ keys: l,
3263
+ metricKeys: o,
3264
+ dimensionKeys: r
3265
+ } = ns(s.data || []);
3266
+ let d = o;
3267
+ if (s.type === "stackedBar") {
3268
+ const c = Ma({
3269
+ dataArray: s.data || [],
3270
+ groupKey: r[0],
3271
+ pivotKey: r[1],
3272
+ valueKey: d[0]
3273
+ }), { metricKeys: m } = ns(c);
3274
+ d = m;
3275
+ }
3276
+ return l.length === 0 ? null : /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
3277
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
3278
+ /* @__PURE__ */ e.jsx(_, { children: t }),
3279
+ /* @__PURE__ */ e.jsx("div", { className: "my-1 space-y-1", children: /* @__PURE__ */ e.jsx("div", { className: "rounded-md bg-muted/70 px-2 py-1 hover:bg-muted", children: /* @__PURE__ */ e.jsx("p", { children: r[0] }) }) })
3280
+ ] }),
3281
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
3282
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-5", children: [
3283
+ /* @__PURE__ */ e.jsx(_, { children: a }),
3284
+ /* @__PURE__ */ e.jsx(Rn, {})
3285
+ ] }),
3286
+ /* @__PURE__ */ e.jsx("div", { className: "my-1 space-y-1", children: d.map((c, m) => /* @__PURE__ */ e.jsx(Hn, { col: c, idx: m }, c)) })
3287
+ ] })
3288
+ ] });
3289
+ }
3290
+ function Hn({ col: s, idx: n }) {
3291
+ const t = i((d) => {
3292
+ var c;
3293
+ return (c = d.card) == null ? void 0 : c.preferences;
3294
+ }), a = i(
3295
+ (d) => {
3296
+ var c;
3297
+ return (c = d.card.preferences) == null ? void 0 : c.datasetOptions;
3298
+ }
3299
+ ), l = a == null ? void 0 : a.find((d) => d.idx === n), { setCardPreferences: o } = i((d) => d.actions);
3300
+ function r(d) {
3301
+ if (!l)
3302
+ o({
3303
+ ...t,
3304
+ datasetOptions: [
3305
+ ...a || [],
3306
+ {
3307
+ idx: n,
3308
+ type: d === "area" ? "line" : d,
3309
+ fill: d === "area" ? "origin" : ""
3310
+ }
3311
+ ]
3312
+ });
3313
+ else {
3314
+ const c = { ...l };
3315
+ c.type = d === "area" ? "line" : d, c.fill = d === "area" ? "origin" : "";
3316
+ const m = a == null ? void 0 : a.map(
3317
+ (h) => h.idx === n ? c : h
3318
+ );
3319
+ o({
3320
+ ...t,
3321
+ datasetOptions: m
3322
+ });
3323
+ }
3324
+ }
3325
+ return /* @__PURE__ */ e.jsxs("div", { className: "group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted", children: [
3326
+ /* @__PURE__ */ e.jsx("p", { children: s }),
3327
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
3328
+ /* @__PURE__ */ e.jsx(
3329
+ vs,
3330
+ {
3331
+ onClick: () => r("bar"),
3332
+ className: "invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"
3333
+ }
3334
+ ),
3335
+ /* @__PURE__ */ e.jsx(
3336
+ Ns,
3337
+ {
3338
+ onClick: () => r("line"),
3339
+ className: "invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"
3340
+ }
3341
+ ),
3342
+ /* @__PURE__ */ e.jsx(
3343
+ Ha,
3344
+ {
3345
+ onClick: () => r("area"),
3346
+ className: "invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"
3347
+ }
3348
+ ),
3349
+ /* @__PURE__ */ e.jsx(
3350
+ tt,
3351
+ {
3352
+ orientation: "vertical",
3353
+ className: "invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"
3354
+ }
3355
+ ),
3356
+ /* @__PURE__ */ e.jsx(_n, { idx: n })
3357
+ ] })
3358
+ ] });
3359
+ }
3360
+ function Bn({
3361
+ cardType: s
3362
+ }) {
3363
+ return /* @__PURE__ */ e.jsx("div", { className: "space-y-6 px-6 py-2", children: /* @__PURE__ */ e.jsxs(ve, { defaultValue: ["item-2"], type: "multiple", children: [
3364
+ /* @__PURE__ */ e.jsxs(q, { value: "item-1", children: [
3365
+ /* @__PURE__ */ e.jsx(V, { children: `${ys(s)} Chart` }),
3366
+ /* @__PURE__ */ e.jsxs(R, { className: "space-y-4 font-mono text-xs", children: [
3367
+ /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 text-xs", children: "SELECT x-axis, y-axis-1, y-axis-2,... FROM table" }),
3368
+ /* @__PURE__ */ e.jsxs("ul", { className: "ml-6 list-disc text-xs [&>li]:mt-2", children: [
3369
+ /* @__PURE__ */ e.jsx("li", { children: "x-axis - category" }),
3370
+ /* @__PURE__ */ e.jsx("li", { children: "y-axis1 - number" }),
3371
+ /* @__PURE__ */ e.jsx("li", { children: "y-axis2 - number" })
3372
+ ] }),
3373
+ /* @__PURE__ */ e.jsxs("div", { children: [
3374
+ "See ",
3375
+ /* @__PURE__ */ e.jsx(
3376
+ "a",
3377
+ {
3378
+ target: "_blank",
3379
+ onClick: (n) => n.stopPropagation(),
3380
+ className: "text-blue-700",
3381
+ href: "https://docs.semaphor.cloud/concepts/visuals#line-chart",
3382
+ children: "example"
3383
+ }
3384
+ ),
3385
+ " in the docs."
3386
+ ] })
3387
+ ] })
3388
+ ] }),
3389
+ /* @__PURE__ */ e.jsxs(q, { value: "item-2", children: [
3390
+ /* @__PURE__ */ e.jsx(V, { children: "Settings" }),
3391
+ /* @__PURE__ */ e.jsxs(R, { className: "space-y-4 px-2", children: [
3392
+ /* @__PURE__ */ e.jsx(Ss, {}),
3393
+ /* @__PURE__ */ e.jsx(Nt, {})
3394
+ ] })
3395
+ ] }),
3396
+ /* @__PURE__ */ e.jsxs(q, { value: "item-3", children: [
3397
+ /* @__PURE__ */ e.jsx(V, { children: "Filter on click" }),
3398
+ /* @__PURE__ */ e.jsx(R, { className: "px-2", children: /* @__PURE__ */ e.jsx(ze, {}) })
3399
+ ] })
3400
+ ] }) });
3401
+ }
3402
+ function ks() {
3403
+ var a, l, o;
3404
+ const s = i(
3405
+ (r) => r.card.cfg
3406
+ ), n = i((r) => r.actions.setCardCfg);
3407
+ function t(r) {
3408
+ var m;
3409
+ const d = {
3410
+ datalabels: {
3411
+ display: r !== "none",
3412
+ align: r,
3413
+ anchor: r,
3414
+ clamp: !0
3415
+ }
3416
+ }, c = {
3417
+ ...s,
3418
+ options: {
3419
+ ...s == null ? void 0 : s.options,
3420
+ plugins: {
3421
+ ...(m = s == null ? void 0 : s.options) == null ? void 0 : m.plugins,
3422
+ ...d
3423
+ }
3424
+ }
3425
+ };
3426
+ n(c), console.log(r);
3427
+ }
3428
+ return /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
3429
+ /* @__PURE__ */ e.jsx("label", { className: "font-medium", children: "Data Labels" }),
3430
+ /* @__PURE__ */ e.jsxs(
3431
+ xs,
3432
+ {
3433
+ value: (o = (l = (a = s == null ? void 0 : s.options) == null ? void 0 : a.plugins) == null ? void 0 : l.datalabels) == null ? void 0 : o.anchor,
3434
+ onValueChange: t,
3435
+ defaultValue: "none",
3436
+ children: [
3437
+ /* @__PURE__ */ e.jsx(ps, { className: "h-8 w-[180px] focus:ring-1 focus:ring-offset-0", children: /* @__PURE__ */ e.jsx(fs, { placeholder: "Select position" }) }),
3438
+ /* @__PURE__ */ e.jsx(gs, { children: /* @__PURE__ */ e.jsxs(js, { children: [
3439
+ /* @__PURE__ */ e.jsx(Ke, { children: "Data Labels" }),
3440
+ /* @__PURE__ */ e.jsx(me, { value: "none", children: "None" }),
3441
+ /* @__PURE__ */ e.jsx(me, { value: "start", children: "Start" }),
3442
+ /* @__PURE__ */ e.jsx(me, { value: "center", children: "Center" }),
3443
+ /* @__PURE__ */ e.jsx(me, { value: "end", children: "End" })
3444
+ ] }) })
3445
+ ]
3446
+ }
3447
+ )
3448
+ ] });
3449
+ }
3450
+ function $n({
3451
+ cardType: s
3452
+ }) {
3453
+ function n(t) {
3454
+ const a = "SELECT label, [group], x-axis, y-axis, radius FROM table", l = "SELECT label, [group], x-axis, y-axis FROM table";
3455
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
3456
+ /* @__PURE__ */ e.jsx("div", { className: "bg-muted px-2 py-1 rounded text-xs", children: t === "bubble" ? a : l }),
3457
+ /* @__PURE__ */ e.jsxs("ul", { className: " ml-6 list-disc [&>li]:mt-2 text-xs", children: [
3458
+ /* @__PURE__ */ e.jsx("li", { children: "label - category" }),
3459
+ /* @__PURE__ */ e.jsx("li", { children: "group - category" }),
3460
+ /* @__PURE__ */ e.jsx("li", { children: "x-axis - category" }),
3461
+ /* @__PURE__ */ e.jsx("li", { children: "y-axis - category" }),
3462
+ t === "bubble" && /* @__PURE__ */ e.jsx("li", { children: "radius - number" })
3463
+ ] }),
3464
+ /* @__PURE__ */ e.jsxs("div", { children: [
3465
+ "See ",
3466
+ /* @__PURE__ */ e.jsx(
3467
+ "a",
3468
+ {
3469
+ target: "_blank",
3470
+ onClick: (o) => o.stopPropagation(),
3471
+ className: "text-blue-700",
3472
+ href: "https://docs.semaphor.cloud/concepts/visuals#pie-chart",
3473
+ children: "example"
3474
+ }
3475
+ ),
3476
+ " in the docs."
3477
+ ] })
3478
+ ] });
3479
+ }
3480
+ return /* @__PURE__ */ e.jsx("div", { className: "px-6 py-2 space-y-6", children: /* @__PURE__ */ e.jsxs(ve, { defaultValue: ["item-2"], type: "multiple", children: [
3481
+ /* @__PURE__ */ e.jsxs(q, { value: "item-1", children: [
3482
+ /* @__PURE__ */ e.jsx(V, { children: `${ys(s)} Chart` }),
3483
+ /* @__PURE__ */ e.jsx(R, { className: " space-y-4 font-mono text-xs ", children: n(s) })
3484
+ ] }),
3485
+ /* @__PURE__ */ e.jsxs(q, { value: "item-2", children: [
3486
+ /* @__PURE__ */ e.jsx(V, { children: "Settings" }),
3487
+ /* @__PURE__ */ e.jsx(R, { className: "px-2", children: /* @__PURE__ */ e.jsx(ks, {}) })
3488
+ ] }),
3489
+ /* @__PURE__ */ e.jsxs(q, { value: "item-3", children: [
3490
+ /* @__PURE__ */ e.jsx(V, { children: "Filter on click" }),
3491
+ /* @__PURE__ */ e.jsx(R, { className: "px-2", children: /* @__PURE__ */ e.jsx(ze, {}) })
3492
+ ] })
3493
+ ] }) });
3494
+ }
3495
+ const Kn = {
3496
+ datasets: [
3497
+ {
3498
+ type: "line",
3499
+ label: "Sum_sales",
3500
+ data: []
3501
+ },
3502
+ {
3503
+ type: "bar",
3504
+ label: "Sum_profit",
3505
+ data: []
3506
+ }
3507
+ ]
3508
+ }, Un = {
3509
+ datasets: [
3510
+ {
3511
+ fill: "origin",
3512
+ type: "line",
3513
+ label: "Sum_sales",
3514
+ data: []
3515
+ }
3516
+ ]
3517
+ };
3518
+ function Gn() {
3519
+ const s = i((n) => n.card.type);
3520
+ return /* @__PURE__ */ e.jsxs("div", { className: "p-6 space-y-6", children: [
3521
+ /* @__PURE__ */ e.jsx(
3522
+ ve,
3523
+ {
3524
+ className: " ",
3525
+ type: "single",
3526
+ collapsible: !0,
3527
+ children: Jn(s)
3528
+ }
3529
+ ),
3530
+ /* @__PURE__ */ e.jsx("section", { className: "", children: ["line", "bar"].includes(s) && /* @__PURE__ */ e.jsx(Ss, {}) }),
3531
+ /* @__PURE__ */ e.jsx("div", { children: !["kpi"].includes(s) && /* @__PURE__ */ e.jsx(ks, {}) }),
3532
+ /* @__PURE__ */ e.jsx("div", { children: !["kpi"].includes(s) && /* @__PURE__ */ e.jsx(ze, {}) })
3533
+ ] });
3534
+ }
3535
+ function Jn(s) {
3536
+ if (["line", "bar"].includes(s))
3537
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
3538
+ /* @__PURE__ */ e.jsxs(q, { value: "item-1", children: [
3539
+ /* @__PURE__ */ e.jsx(V, { className: " font-normal", children: /* @__PURE__ */ e.jsx("p", { children: "Chart Query" }) }),
3540
+ /* @__PURE__ */ e.jsxs(R, { className: " ", children: [
3541
+ /* @__PURE__ */ e.jsx("div", { className: "bg-muted px-2 py-1 rounded font-mono font-semibold text-xs", children: "SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table" }),
3542
+ /* @__PURE__ */ e.jsxs("ul", { className: "my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs", children: [
3543
+ /* @__PURE__ */ e.jsx("li", { children: "X-axis - Category (ex. city)" }),
3544
+ /* @__PURE__ */ e.jsx("li", { children: "Y-axis - Number (ex. population)" })
3545
+ ] })
3546
+ ] })
3547
+ ] }),
3548
+ /* @__PURE__ */ e.jsxs(q, { value: "item-2", children: [
3549
+ /* @__PURE__ */ e.jsx(V, { className: " font-normal", children: "Mixed Chart" }),
3550
+ /* @__PURE__ */ e.jsxs(R, { className: " text-xs space-y-2", children: [
3551
+ /* @__PURE__ */ e.jsxs("p", { children: [
3552
+ "Click ",
3553
+ /* @__PURE__ */ e.jsx("b", { children: "Customize" }),
3554
+ " and change the `type` property in the dataset."
3555
+ ] }),
3556
+ /* @__PURE__ */ e.jsx("pre", { children: JSON.stringify(Kn, null, 2) })
3557
+ ] })
3558
+ ] }),
3559
+ /* @__PURE__ */ e.jsxs(q, { value: "item-3", children: [
3560
+ /* @__PURE__ */ e.jsx(V, { className: " font-normal", children: "Area Chart" }),
3561
+ /* @__PURE__ */ e.jsxs(R, { className: " text-xs space-y-2", children: [
3562
+ /* @__PURE__ */ e.jsxs("p", { children: [
3563
+ "Click ",
3564
+ /* @__PURE__ */ e.jsx("b", { children: "Customize" }),
3565
+ " and add `fill` property to the dataset. See",
3566
+ /* @__PURE__ */ e.jsx(
3567
+ "a",
3568
+ {
3569
+ className: "text-blue-500 hover:underline mx-1",
3570
+ href: "https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",
3571
+ target: "_blank",
3572
+ children: "docs"
3573
+ }
3574
+ ),
3575
+ "for more options."
3576
+ ] }),
3577
+ /* @__PURE__ */ e.jsx("pre", { children: JSON.stringify(Un, null, 2) })
3578
+ ] })
3579
+ ] })
3580
+ ] });
3581
+ if (s === "bubble")
3582
+ return /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsxs(q, { value: "item-1", children: [
3583
+ /* @__PURE__ */ e.jsx(V, { className: " font-normal", children: /* @__PURE__ */ e.jsxs("p", { children: [
3584
+ "How to create a ",
3585
+ /* @__PURE__ */ e.jsx("span", { children: s }),
3586
+ " chart query?"
3587
+ ] }) }),
3588
+ /* @__PURE__ */ e.jsxs(R, { className: " ", children: [
3589
+ /* @__PURE__ */ e.jsx("div", { className: "bg-muted px-2 py-1 rounded font-mono font-semibold text-xs", children: "SELECT label, x-axis, y-axis, radius FROM table" }),
3590
+ /* @__PURE__ */ e.jsxs("ul", { className: "my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs", children: [
3591
+ /* @__PURE__ */ e.jsx("li", { children: "Label - Category (ex. city)" }),
3592
+ /* @__PURE__ */ e.jsx("li", { children: "Bubble Group (opt) - Category (ex. state)" }),
3593
+ /* @__PURE__ */ e.jsx("li", { children: "X-axis - Number (ex. avg. age)" }),
3594
+ /* @__PURE__ */ e.jsx("li", { children: "Y-axis - Number (ex. avg. weight)" }),
3595
+ /* @__PURE__ */ e.jsx("li", { children: "Radius - Number (ex. population)" })
3596
+ ] })
3597
+ ] })
3598
+ ] }) });
3599
+ if (s === "scatter")
3600
+ return /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsxs(q, { value: "item-1", children: [
3601
+ /* @__PURE__ */ e.jsx(V, { className: " font-normal", children: /* @__PURE__ */ e.jsxs("p", { children: [
3602
+ "How to create a ",
3603
+ /* @__PURE__ */ e.jsx("span", { children: s }),
3604
+ " chart query?"
3605
+ ] }) }),
3606
+ /* @__PURE__ */ e.jsxs(R, { className: " ", children: [
3607
+ /* @__PURE__ */ e.jsx("div", { className: "bg-muted px-2 py-1 rounded font-mono font-semibold text-xs", children: "SELECT label, x-axis, y-axis FROM table" }),
3608
+ /* @__PURE__ */ e.jsxs("ul", { className: "my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs", children: [
3609
+ /* @__PURE__ */ e.jsx("li", { children: "Label - Category (ex. city)" }),
3610
+ /* @__PURE__ */ e.jsx("li", { children: "Group (opt) - Category (ex. state)" }),
3611
+ /* @__PURE__ */ e.jsx("li", { children: "X-axis - Number (ex. avg. age)" }),
3612
+ /* @__PURE__ */ e.jsx("li", { children: "Y-axis - Number (ex. avg. weight)" })
3613
+ ] })
3614
+ ] })
3615
+ ] }) });
3616
+ if (["pie", "doughnut", "polarArea"].includes(s))
3617
+ return /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsxs(q, { value: "item-1", children: [
3618
+ /* @__PURE__ */ e.jsx(V, { className: " font-normal", children: /* @__PURE__ */ e.jsxs("p", { children: [
3619
+ /* @__PURE__ */ e.jsx("span", { children: s === "polarArea" ? "Polar" : s.charAt(0).toUpperCase() + s.slice(1) }),
3620
+ " ",
3621
+ "chart query"
3622
+ ] }) }),
3623
+ /* @__PURE__ */ e.jsxs(R, { className: " ", children: [
3624
+ /* @__PURE__ */ e.jsx("div", { className: "bg-muted px-2 py-1 rounded font-mono font-semibold text-xs", children: "SELECT label, measure FROM table" }),
3625
+ /* @__PURE__ */ e.jsxs("ul", { className: "my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs", children: [
3626
+ /* @__PURE__ */ e.jsx("li", { children: "Label - Category (ex. city)" }),
3627
+ /* @__PURE__ */ e.jsx("li", { children: "Measure - Number (ex. population)" })
3628
+ ] })
3629
+ ] })
3630
+ ] }) });
3631
+ }
3632
+ function Qn() {
3633
+ var r, d, c;
3634
+ const s = i((m) => m.card.preferences), n = i(
3635
+ (m) => m.actions.setCardPreferences
3636
+ ), t = i(
3637
+ (m) => m.actions.setNumberFormat
3638
+ ), a = i(
3639
+ (m) => {
3640
+ var h, u;
3641
+ return (u = (h = m.card.preferences) == null ? void 0 : h.formatNumber) == null ? void 0 : u.format;
3642
+ }
3643
+ ), l = i(
3644
+ (m) => {
3645
+ var h, u;
3646
+ return (u = (h = m.card.preferences) == null ? void 0 : h.formatNumber) == null ? void 0 : u.locale;
3647
+ }
3648
+ ), o = i(
3649
+ (m) => {
3650
+ var h, u;
3651
+ return (u = (h = m.card.preferences) == null ? void 0 : h.formatNumber) == null ? void 0 : u.currency;
3652
+ }
3653
+ );
3654
+ return i(
3655
+ (m) => m.actions.setFilterOnClickField
3656
+ ), /* @__PURE__ */ e.jsxs("div", { children: [
3657
+ /* @__PURE__ */ e.jsxs("div", { className: "mb-3 flex items-center gap-2", children: [
3658
+ /* @__PURE__ */ e.jsx(
3659
+ Qe,
3660
+ {
3661
+ checked: !!((r = s == null ? void 0 : s.formatNumber) != null && r.enabled),
3662
+ onCheckedChange: (m) => {
3663
+ n({
3664
+ ...s,
3665
+ formatNumber: {
3666
+ ...s == null ? void 0 : s.formatNumber,
3667
+ enabled: m
3668
+ }
3669
+ });
3670
+ }
3671
+ }
3672
+ ),
3673
+ /* @__PURE__ */ e.jsx(_, { children: "Format Number" })
3674
+ ] }),
3675
+ ((d = s == null ? void 0 : s.formatNumber) == null ? void 0 : d.enabled) === !0 && /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-2", children: [
3676
+ /* @__PURE__ */ e.jsxs("div", { children: [
3677
+ /* @__PURE__ */ e.jsx(_, { className: "text-xs", children: "Currency" }),
3678
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1", children: [
3679
+ /* @__PURE__ */ e.jsx(
3680
+ Q,
3681
+ {
3682
+ value: o || "",
3683
+ className: "h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",
3684
+ placeholder: "USD",
3685
+ onChange: (m) => {
3686
+ var h, u, g;
3687
+ return t(
3688
+ ((h = s == null ? void 0 : s.formatNumber) == null ? void 0 : h.format) || "",
3689
+ m.target.value,
3690
+ ((u = s == null ? void 0 : s.formatNumber) == null ? void 0 : u.locale) || "",
3691
+ ((g = s == null ? void 0 : s.formatNumber) == null ? void 0 : g.suffix) || ""
3692
+ );
3693
+ }
3694
+ }
3695
+ ),
3696
+ /* @__PURE__ */ e.jsx(
3697
+ Q,
3698
+ {
3699
+ value: l || "",
3700
+ className: "h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",
3701
+ placeholder: "en-US",
3702
+ onChange: (m) => {
3703
+ var h, u, g;
3704
+ return t(
3705
+ ((h = s == null ? void 0 : s.formatNumber) == null ? void 0 : h.format) || "",
3706
+ ((u = s == null ? void 0 : s.formatNumber) == null ? void 0 : u.currency) || "",
3707
+ m.target.value,
3708
+ ((g = s == null ? void 0 : s.formatNumber) == null ? void 0 : g.suffix) || ""
3709
+ );
3710
+ }
3711
+ }
3712
+ )
3713
+ ] })
3714
+ ] }),
3715
+ /* @__PURE__ */ e.jsxs("div", { children: [
3716
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1", children: [
3717
+ /* @__PURE__ */ e.jsx(_, { className: "text-xs", children: "Format" }),
3718
+ /* @__PURE__ */ e.jsxs(We, { children: [
3719
+ /* @__PURE__ */ e.jsx(ms, { children: /* @__PURE__ */ e.jsx(
3720
+ Zs,
3721
+ {
3722
+ strokeWidth: 1,
3723
+ className: "h-3 w-3 opacity-70"
3724
+ }
3725
+ ) }),
3726
+ /* @__PURE__ */ e.jsx(Pe, { children: /* @__PURE__ */ e.jsxs("div", { className: "max-w-[200px]", children: [
3727
+ "Format number",
3728
+ /* @__PURE__ */ e.jsx("div", { className: "mt-1 font-mono text-xs", children: "#.## for 123.43" })
3729
+ ] }) })
3730
+ ] })
3731
+ ] }),
3732
+ /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(
3733
+ Q,
3734
+ {
3735
+ value: a || "",
3736
+ className: "h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",
3737
+ placeholder: "###,###.##",
3738
+ onChange: (m) => {
3739
+ var h, u, g;
3740
+ return t(
3741
+ m.target.value,
3742
+ ((h = s == null ? void 0 : s.formatNumber) == null ? void 0 : h.currency) || "",
3743
+ ((u = s == null ? void 0 : s.formatNumber) == null ? void 0 : u.locale) || "",
3744
+ ((g = s == null ? void 0 : s.formatNumber) == null ? void 0 : g.suffix) || ""
3745
+ );
3746
+ }
3747
+ }
3748
+ ) })
3749
+ ] }),
3750
+ /* @__PURE__ */ e.jsxs("div", { children: [
3751
+ /* @__PURE__ */ e.jsx(_, { className: "text-xs", children: "Suffix" }),
3752
+ /* @__PURE__ */ e.jsx(
3753
+ Q,
3754
+ {
3755
+ value: ((c = s == null ? void 0 : s.formatNumber) == null ? void 0 : c.suffix) || "",
3756
+ className: "h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",
3757
+ placeholder: "K, M, B",
3758
+ onChange: (m) => {
3759
+ var h, u, g;
3760
+ return t(
3761
+ ((h = s == null ? void 0 : s.formatNumber) == null ? void 0 : h.format) || "",
3762
+ ((u = s == null ? void 0 : s.formatNumber) == null ? void 0 : u.currency) || "",
3763
+ ((g = s == null ? void 0 : s.formatNumber) == null ? void 0 : g.locale) || "",
3764
+ m.target.value
3765
+ );
3766
+ }
3767
+ }
3768
+ )
3769
+ ] })
3770
+ ] })
3771
+ ] });
3772
+ }
3773
+ function Wn() {
3774
+ return /* @__PURE__ */ e.jsxs("div", { className: "space-y-6 px-6 py-2", children: [
3775
+ /* @__PURE__ */ e.jsx(ve, { type: "single", collapsible: !0, children: /* @__PURE__ */ e.jsxs(q, { value: "item-1", children: [
3776
+ /* @__PURE__ */ e.jsx(V, { className: "", children: "KPI Query" }),
3777
+ /* @__PURE__ */ e.jsxs(R, { className: "font-mono", children: [
3778
+ /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 font-mono text-xs", children: "SELECT current, previous FROM table" }),
3779
+ /* @__PURE__ */ e.jsxs("ul", { className: "my-6 ml-6 list-disc text-xs [&>li]:mt-2", children: [
3780
+ /* @__PURE__ */ e.jsx("li", { children: "current - number" }),
3781
+ /* @__PURE__ */ e.jsx("li", { children: "previous - number" })
3782
+ ] }),
3783
+ /* @__PURE__ */ e.jsxs("div", { children: [
3784
+ "See ",
3785
+ /* @__PURE__ */ e.jsx(
3786
+ "a",
3787
+ {
3788
+ target: "_blank",
3789
+ onClick: (s) => s.stopPropagation(),
3790
+ className: "text-blue-700",
3791
+ href: "https://docs.semaphor.cloud/concepts/visuals#kpi",
3792
+ children: "example"
3793
+ }
3794
+ ),
3795
+ " in the docs."
3796
+ ] })
3797
+ ] })
3798
+ ] }) }),
3799
+ /* @__PURE__ */ e.jsx("section", { className: "", children: /* @__PURE__ */ e.jsx(Qn, {}) }),
3800
+ /* @__PURE__ */ e.jsx("div", {}),
3801
+ /* @__PURE__ */ e.jsx("div", {})
3802
+ ] });
3803
+ }
3804
+ function Pn({
3805
+ cardType: s
3806
+ }) {
3807
+ return /* @__PURE__ */ e.jsx("div", { className: "px-6 py-2 space-y-6", children: /* @__PURE__ */ e.jsxs(ve, { defaultValue: ["item-2"], type: "multiple", children: [
3808
+ /* @__PURE__ */ e.jsxs(q, { value: "item-1", children: [
3809
+ /* @__PURE__ */ e.jsx(V, { children: `${ys(s)} Chart` }),
3810
+ /* @__PURE__ */ e.jsxs(R, { className: " space-y-4 font-mono text-xs ", children: [
3811
+ /* @__PURE__ */ e.jsx("div", { className: "bg-muted px-2 py-1 rounded text-xs", children: "SELECT label, measure FROM table" }),
3812
+ /* @__PURE__ */ e.jsxs("ul", { className: " ml-6 list-disc [&>li]:mt-2 text-xs", children: [
3813
+ /* @__PURE__ */ e.jsx("li", { children: "label - category" }),
3814
+ /* @__PURE__ */ e.jsx("li", { children: "measure - number" })
3815
+ ] }),
3816
+ /* @__PURE__ */ e.jsxs("div", { children: [
3817
+ "See ",
3818
+ /* @__PURE__ */ e.jsx(
3819
+ "a",
3820
+ {
3821
+ target: "_blank",
3822
+ onClick: (n) => n.stopPropagation(),
3823
+ className: "text-blue-700",
3824
+ href: "https://docs.semaphor.cloud/concepts/visuals#pie-chart",
3825
+ children: "example"
3826
+ }
3827
+ ),
3828
+ " in the docs."
3829
+ ] })
3830
+ ] })
3831
+ ] }),
3832
+ /* @__PURE__ */ e.jsxs(q, { value: "item-2", children: [
3833
+ /* @__PURE__ */ e.jsx(V, { children: "Settings" }),
3834
+ /* @__PURE__ */ e.jsx(R, { className: "px-2", children: /* @__PURE__ */ e.jsx(ks, {}) })
3835
+ ] }),
3836
+ /* @__PURE__ */ e.jsxs(q, { value: "item-3", children: [
3837
+ /* @__PURE__ */ e.jsx(V, { children: "Filter on click" }),
3838
+ /* @__PURE__ */ e.jsx(R, { className: "px-2", children: /* @__PURE__ */ e.jsx(ze, {}) })
3839
+ ] })
3840
+ ] }) });
3841
+ }
3842
+ function Yn() {
3843
+ return /* @__PURE__ */ e.jsx("div", { className: "space-y-6 px-6 py-2", children: /* @__PURE__ */ e.jsxs(ve, { defaultValue: ["item-2"], type: "multiple", children: [
3844
+ /* @__PURE__ */ e.jsxs(q, { value: "item-1", children: [
3845
+ /* @__PURE__ */ e.jsx(V, { children: "Stacked Chart" }),
3846
+ /* @__PURE__ */ e.jsxs(R, { className: "space-y-4 font-mono text-xs", children: [
3847
+ /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 text-xs", children: "SELECT x-axis, stack-by, y-axis FROM table" }),
3848
+ /* @__PURE__ */ e.jsxs("ul", { className: "ml-6 list-disc text-xs [&>li]:mt-2", children: [
3849
+ /* @__PURE__ */ e.jsx("li", { children: "x-axis - category" }),
3850
+ /* @__PURE__ */ e.jsx("li", { children: "stack by - category" }),
3851
+ /* @__PURE__ */ e.jsx("li", { children: "y-axis - number" })
3852
+ ] }),
3853
+ /* @__PURE__ */ e.jsxs("div", { children: [
3854
+ "See ",
3855
+ /* @__PURE__ */ e.jsx(
3856
+ "a",
3857
+ {
3858
+ target: "_blank",
3859
+ onClick: (s) => s.stopPropagation(),
3860
+ className: "text-blue-700",
3861
+ href: "https://docs.semaphor.cloud/concepts/visuals#stacked-chart",
3862
+ children: "example"
3863
+ }
3864
+ ),
3865
+ " in the docs."
3866
+ ] })
3867
+ ] })
3868
+ ] }),
3869
+ /* @__PURE__ */ e.jsxs(q, { value: "item-2", children: [
3870
+ /* @__PURE__ */ e.jsx(V, { children: "Settings" }),
3871
+ /* @__PURE__ */ e.jsxs(R, { className: "space-y-4 px-2", children: [
3872
+ /* @__PURE__ */ e.jsx(Ss, {}),
3873
+ /* @__PURE__ */ e.jsx(Nt, {})
3874
+ ] })
3875
+ ] }),
3876
+ /* @__PURE__ */ e.jsxs(q, { value: "item-3", children: [
3877
+ /* @__PURE__ */ e.jsx(V, { children: "Filter on click" }),
3878
+ /* @__PURE__ */ e.jsx(R, { className: "px-2", children: /* @__PURE__ */ e.jsx(ze, {}) })
3879
+ ] })
3880
+ ] }) });
3881
+ }
3882
+ function Xn({
3883
+ cardType: s
3884
+ }) {
3885
+ return console.log("TableVisualSettings", s), /* @__PURE__ */ e.jsx("div", { className: "space-y-6 px-6 py-2", children: /* @__PURE__ */ e.jsx(ve, { defaultValue: ["item-3"], type: "multiple", children: /* @__PURE__ */ e.jsxs(q, { value: "item-3", children: [
3886
+ /* @__PURE__ */ e.jsx(V, { children: "Filter on click" }),
3887
+ /* @__PURE__ */ e.jsx(R, { className: "px-2", children: /* @__PURE__ */ e.jsx(ze, {}) })
3888
+ ] }) }) });
3889
+ }
3890
+ function Zn() {
3891
+ const s = i((t) => t.card.type);
3892
+ function n(t) {
3893
+ switch (t) {
3894
+ case "stackedBar":
3895
+ return /* @__PURE__ */ e.jsx(Yn, {});
3896
+ case "kpi":
3897
+ return /* @__PURE__ */ e.jsx(Wn, {});
3898
+ case "line":
3899
+ case "bar":
3900
+ return /* @__PURE__ */ e.jsx(Bn, { cardType: t });
3901
+ case "pie":
3902
+ case "doughnut":
3903
+ case "polarArea":
3904
+ case "radar":
3905
+ return /* @__PURE__ */ e.jsx(Pn, { cardType: t });
3906
+ case "bubble":
3907
+ case "scatter":
3908
+ return /* @__PURE__ */ e.jsx($n, { cardType: t });
3909
+ case "table":
3910
+ return /* @__PURE__ */ e.jsx(Xn, { cardType: t });
3911
+ default:
3912
+ return /* @__PURE__ */ e.jsx(Gn, {});
3913
+ }
3914
+ }
3915
+ return /* @__PURE__ */ e.jsx(bs, { className: "h-full w-full text-sm", children: n(s) });
3916
+ }
3917
+ function er() {
3918
+ const s = i((n) => n.isShowingVisual);
3919
+ return /* @__PURE__ */ e.jsxs(
3920
+ rs,
3921
+ {
3922
+ direction: "vertical",
3923
+ className: "min-w-full max-w-lg min-h-[250px]",
3924
+ children: [
3925
+ /* @__PURE__ */ e.jsx(
3926
+ Fe,
3927
+ {
3928
+ role: "query-section",
3929
+ className: "flex",
3930
+ minSize: 20,
3931
+ defaultSize: 40,
3932
+ children: /* @__PURE__ */ e.jsx(Tn, {})
3933
+ }
3934
+ ),
3935
+ /* @__PURE__ */ e.jsx(ls, { withHandle: !0, className: "border " }),
3936
+ /* @__PURE__ */ e.jsx(
3937
+ Fe,
3938
+ {
3939
+ className: "pb-1",
3940
+ role: "visual-section",
3941
+ minSize: 0,
3942
+ defaultSize: 60,
3943
+ children: s ? /* @__PURE__ */ e.jsxs(rs, { direction: "horizontal", children: [
3944
+ /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsx(
3945
+ Fe,
3946
+ {
3947
+ className: "flex min-w-[275px]",
3948
+ minSize: 20,
3949
+ defaultSize: 25,
3950
+ maxSize: 30,
3951
+ children: /* @__PURE__ */ e.jsx(Zn, {})
3952
+ }
3953
+ ) }),
3954
+ /* @__PURE__ */ e.jsx(ls, { className: "border " }),
3955
+ /* @__PURE__ */ e.jsx(Fe, { minSize: 40, defaultSize: 75, maxSize: 100, children: /* @__PURE__ */ e.jsx(_s, {}) })
3956
+ ] }) : /* @__PURE__ */ e.jsx(_s, {})
3957
+ }
3958
+ )
3959
+ ]
3960
+ }
3961
+ );
3962
+ }
3963
+ function sr({ authToken: s, onSave: n, onClose: t }) {
3964
+ const a = i((r) => r.actions.setOnSave), l = i((r) => r.actions.setOnClose), o = S((r) => r.actions.setAuthToken);
3965
+ return $(() => {
3966
+ n && a(n), t && l(t);
3967
+ }, [n, a, t, l]), $(() => {
3968
+ s && s.accessToken && o(s);
3969
+ }, [s, o]), /* @__PURE__ */ e.jsxs(Ta, { className: "rounded-none", role: "editor-panel", children: [
3970
+ /* @__PURE__ */ e.jsx(Aa, { className: "rounded-none border-r-[1.5px]", children: /* @__PURE__ */ e.jsx(ut, {}) }),
3971
+ /* @__PURE__ */ e.jsx(Ea, { children: /* @__PURE__ */ e.jsx(er, {}) })
3972
+ ] });
3973
+ }
3974
+ function tr() {
3975
+ S((r) => r.selectedCardId);
3976
+ const s = S((r) => r.selectedSheetId), { setIsVisualEditing: n } = S((r) => r.actions), t = S((r) => r.isVisualEditing), a = S((r) => r.actions.updateFrame);
3977
+ function l(r) {
3978
+ s && (a(s, r), n(!1));
3979
+ }
3980
+ function o() {
3981
+ n(!1);
3982
+ }
3983
+ return /* @__PURE__ */ e.jsx(
3984
+ "div",
3985
+ {
3986
+ role: "editor-container",
3987
+ className: W("flex grow", {
3988
+ block: t,
3989
+ hidden: !t
3990
+ }),
3991
+ children: /* @__PURE__ */ e.jsx(sr, { onSave: l, onClose: o })
3992
+ }
3993
+ );
3994
+ }
3995
+ function ar({
3996
+ columns: s,
3997
+ tableName: n
3998
+ }) {
3999
+ const t = i((u) => u.selectedConnectionId), a = i((u) => u.selectedDatabaseName), l = i((u) => u.selectedSchemaName), o = i((u) => u.selectedTableName), r = S((u) => u.dashboard.filters) || [], d = S((u) => u.actions.addFilter), c = S((u) => u.actions.removeFilter), m = S(
4000
+ (u) => u.actions.removeFilterValue
4001
+ );
4002
+ function h(u) {
4003
+ const g = oe(u.column_name), p = oe(a || ""), j = oe(l || ""), C = oe(n), v = as(
4004
+ j,
4005
+ C
4006
+ ), y = `${v}.${g}`;
4007
+ console.log(
4008
+ "find",
4009
+ y,
4010
+ C,
4011
+ p
4012
+ );
4013
+ const D = r == null ? void 0 : r.find(
4014
+ (A) => A.column === y && A.table === C && (A.database === p || A.database === a)
4015
+ );
4016
+ if (D)
4017
+ m(D.id), c(D.id);
4018
+ else {
4019
+ if (n === "api" && t) {
4020
+ d({
4021
+ id: $e(),
4022
+ column: y,
4023
+ title: u.column_name,
4024
+ dataType: u.data_type,
4025
+ table: "api",
4026
+ database: "",
4027
+ // database: 'NA',
4028
+ connectionId: t,
4029
+ operation: "in",
4030
+ sql: qs(
4031
+ u.data_type,
4032
+ v,
4033
+ g
4034
+ )
4035
+ //DATE_DATA_TYPES.includes(column.data_type) ? dateSql : sql,
4036
+ });
4037
+ return;
4038
+ }
4039
+ d({
4040
+ id: $e(),
4041
+ column: `${v}.${g}`,
4042
+ title: u.column_name,
4043
+ dataType: u.data_type,
4044
+ table: o || "",
4045
+ database: a || "",
4046
+ connectionId: t || "",
4047
+ operation: "in",
4048
+ sql: qs(
4049
+ u.data_type,
4050
+ v,
4051
+ g
4052
+ )
4053
+ //DATE_DATA_TYPES.includes(column.data_type) ? dateSql : sql,
4054
+ });
4055
+ }
4056
+ }
4057
+ return /* @__PURE__ */ e.jsx("div", { className: "xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3", children: s == null ? void 0 : s.map((u) => {
4058
+ const g = r == null ? void 0 : r.find(
4059
+ (p) => p.column === oe(u.column_name) && p.table === o && p.database === a
4060
+ );
4061
+ return /* @__PURE__ */ e.jsx(
4062
+ "div",
4063
+ {
4064
+ onClick: () => h(u),
4065
+ className: W(
4066
+ "group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",
4067
+ {
4068
+ "bg-muted": g
4069
+ }
4070
+ ),
4071
+ children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
4072
+ /* @__PURE__ */ e.jsx(dt, { column: u }),
4073
+ /* @__PURE__ */ e.jsx("span", { children: u.column_name })
4074
+ ] })
4075
+ },
4076
+ u.column_name
4077
+ );
4078
+ }) });
4079
+ }
4080
+ function nr() {
4081
+ S((n) => n.showFilters);
4082
+ const s = S(
4083
+ (n) => n.actions.setShowFilters
4084
+ );
4085
+ return /* @__PURE__ */ e.jsxs("section", { className: "relative flex grow flex-col border-l px-4", children: [
4086
+ /* @__PURE__ */ e.jsxs("div", { className: "mt-4 flex items-center justify-between gap-2 px-3", children: [
4087
+ /* @__PURE__ */ e.jsx(_, { className: "text-lg", children: "Filters" }),
4088
+ /* @__PURE__ */ e.jsx(
4089
+ k,
4090
+ {
4091
+ onClick: () => s(!1),
4092
+ className: "h-7 w-7 p-0",
4093
+ variant: "ghost",
4094
+ children: /* @__PURE__ */ e.jsx(Ee, {})
4095
+ }
4096
+ )
4097
+ ] }),
4098
+ /* @__PURE__ */ e.jsx("div", { className: "flex grow", children: /* @__PURE__ */ e.jsx(
4099
+ ut,
4100
+ {
4101
+ ColumnsComponent: (n, t, a) => /* @__PURE__ */ e.jsx(
4102
+ ar,
4103
+ {
4104
+ schemaName: n,
4105
+ tableName: t,
4106
+ columns: a
4107
+ }
4108
+ )
4109
+ }
4110
+ ) })
4111
+ ] });
4112
+ }
4113
+ function rr() {
4114
+ S((t) => t.dashboard);
4115
+ const s = S((t) => t.showFilters), n = S((t) => t.isVisualEditing);
4116
+ return S((t) => t.bookmarkKey), /* @__PURE__ */ e.jsxs(
4117
+ "div",
4118
+ {
4119
+ role: "dashboard-plus-main",
4120
+ className: W("grow", {
4121
+ hidden: n,
4122
+ flex: !n
4123
+ }),
4124
+ children: [
4125
+ /* @__PURE__ */ e.jsx(La, {}),
4126
+ s && /* @__PURE__ */ e.jsx("div", { role: "filter-aside-container", className: "flex", children: /* @__PURE__ */ e.jsx(nr, {}) })
4127
+ ]
4128
+ }
4129
+ );
4130
+ }
4131
+ function lr() {
4132
+ const s = S((a) => a.dashboard), n = S((a) => a.actions.setDashboard), t = S(
4133
+ (a) => a.showDashboardJSON
4134
+ );
4135
+ return S(
4136
+ (a) => a.actions.setShowDashboardJSON
4137
+ ), /* @__PURE__ */ e.jsx(
4138
+ "div",
4139
+ {
4140
+ className: W(" p-2", {
4141
+ hidden: !t
4142
+ }),
4143
+ children: /* @__PURE__ */ e.jsx(
4144
+ Da,
4145
+ {
4146
+ onChange: (a) => {
4147
+ if (a)
4148
+ try {
4149
+ JSON.parse(a), n(JSON.parse(a));
4150
+ } catch {
4151
+ }
4152
+ },
4153
+ defaultLanguage: "json",
4154
+ className: "h-[550px] overflow-y-auto ",
4155
+ value: JSON.stringify(s, null, 2),
4156
+ options: {
4157
+ minimap: {
4158
+ enabled: !1
4159
+ },
4160
+ // lineNumbers: 'off',
4161
+ glyphMargin: !1,
4162
+ wordWrap: "on",
4163
+ scrollbar: {
4164
+ verticalScrollbarSize: 0,
4165
+ horizontalScrollbarSize: 0
4166
+ },
4167
+ fontSize: 12,
4168
+ renderLineHighlight: "none"
4169
+ }
4170
+ }
4171
+ )
4172
+ }
4173
+ );
4174
+ }
4175
+ function cr({
4176
+ showControls: s = !1,
4177
+ showFooter: n = !0,
4178
+ ...t
4179
+ }) {
4180
+ return /* @__PURE__ */ e.jsx(Ia, { dashboardProps: t, children: /* @__PURE__ */ e.jsxs(qa, { children: [
4181
+ /* @__PURE__ */ e.jsx(lr, {}),
4182
+ /* @__PURE__ */ e.jsxs(Va, { ...t, children: [
4183
+ s && /* @__PURE__ */ e.jsx(xn, {}),
4184
+ /* @__PURE__ */ e.jsx(tr, {}),
4185
+ /* @__PURE__ */ e.jsx(rr, {})
4186
+ ] })
4187
+ ] }) });
4188
+ }
4189
+ export {
4190
+ cr as D,
4191
+ He as S,
4192
+ ht as u
4193
+ };