react-semaphor 0.0.219 → 0.0.221

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.
@@ -1,39 +1,39 @@
1
- "use strict";const e=require("./index-uA5XMQEz.js"),f=require("react");/**
1
+ "use strict";const e=require("./index-m8W9EJEj.js"),R=require("react");/**
2
2
  * @license lucide-react v0.379.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const ds=e.createLucideIcon("Activity",[["path",{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",key:"169zse"}]]);/**
6
+ */const dt=e.createLucideIcon("Activity",[["path",{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",key:"169zse"}]]);/**
7
7
  * @license lucide-react v0.379.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const ms=e.createLucideIcon("AreaChart",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M7 12v5h12V8l-5 5-4-4Z",key:"zxz28u"}]]);/**
11
+ */const mt=e.createLucideIcon("AreaChart",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M7 12v5h12V8l-5 5-4-4Z",key:"zxz28u"}]]);/**
12
12
  * @license lucide-react v0.379.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const De=e.createLucideIcon("BarChart4",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17V5",key:"sfb6ij"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
16
+ */const Ae=e.createLucideIcon("BarChart4",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17V5",key:"sfb6ij"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
17
17
  * @license lucide-react v0.379.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const ps=e.createLucideIcon("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/**
21
+ */const pt=e.createLucideIcon("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/**
22
22
  * @license lucide-react v0.379.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const hs=e.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
26
+ */const ht=e.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
27
27
  * @license lucide-react v0.379.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const js=e.createLucideIcon("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
31
+ */const jt=e.createLucideIcon("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
32
32
  * @license lucide-react v0.379.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const Es=e.createLucideIcon("Eraser",[["path",{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",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);/**
36
+ */const Et=e.createLucideIcon("Eraser",[["path",{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",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);/**
37
37
  * @license lucide-react v0.379.0 - ISC
38
38
  *
39
39
  * This source code is licensed under the ISC license.
@@ -48,22 +48,22 @@
48
48
  *
49
49
  * This source code is licensed under the ISC license.
50
50
  * See the LICENSE file in the root directory of this source tree.
51
- */const fs=e.createLucideIcon("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/**
51
+ */const ft=e.createLucideIcon("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/**
52
52
  * @license lucide-react v0.379.0 - ISC
53
53
  *
54
54
  * This source code is licensed under the ISC license.
55
55
  * See the LICENSE file in the root directory of this source tree.
56
- */const gs=e.createLucideIcon("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{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",key:"b7pghm"}]]);/**
56
+ */const gt=e.createLucideIcon("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{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",key:"b7pghm"}]]);/**
57
57
  * @license lucide-react v0.379.0 - ISC
58
58
  *
59
59
  * This source code is licensed under the ISC license.
60
60
  * See the LICENSE file in the root directory of this source tree.
61
- */const Rs=e.createLucideIcon("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/**
61
+ */const Rt=e.createLucideIcon("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/**
62
62
  * @license lucide-react v0.379.0 - ISC
63
63
  *
64
64
  * This source code is licensed under the ISC license.
65
65
  * See the LICENSE file in the root directory of this source tree.
66
- */const bs=e.createLucideIcon("Key",[["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"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
66
+ */const bt=e.createLucideIcon("Key",[["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"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
67
67
  * @license lucide-react v0.379.0 - ISC
68
68
  *
69
69
  * This source code is licensed under the ISC license.
@@ -73,27 +73,27 @@
73
73
  *
74
74
  * This source code is licensed under the ISC license.
75
75
  * See the LICENSE file in the root directory of this source tree.
76
- */const Ss=e.createLucideIcon("ListEnd",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M10 18H3",key:"13769t"}],["path",{d:"M21 6v10a2 2 0 0 1-2 2h-5",key:"ilrcs8"}],["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}]]);/**
76
+ */const St=e.createLucideIcon("ListEnd",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M10 18H3",key:"13769t"}],["path",{d:"M21 6v10a2 2 0 0 1-2 2h-5",key:"ilrcs8"}],["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}]]);/**
77
77
  * @license lucide-react v0.379.0 - ISC
78
78
  *
79
79
  * This source code is licensed under the ISC license.
80
80
  * See the LICENSE file in the root directory of this source tree.
81
- */const ys=e.createLucideIcon("ListStart",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M10 6H3",key:"lf8lx7"}],["path",{d:"M21 18V8a2 2 0 0 0-2-2h-5",key:"1hghli"}],["path",{d:"m16 8-2-2 2-2",key:"160uvd"}]]);/**
81
+ */const yt=e.createLucideIcon("ListStart",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M10 6H3",key:"lf8lx7"}],["path",{d:"M21 18V8a2 2 0 0 0-2-2h-5",key:"1hghli"}],["path",{d:"m16 8-2-2 2-2",key:"160uvd"}]]);/**
82
82
  * @license lucide-react v0.379.0 - ISC
83
83
  *
84
84
  * This source code is licensed under the ISC license.
85
85
  * See the LICENSE file in the root directory of this source tree.
86
- */const vs=e.createLucideIcon("ListX",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]]);/**
86
+ */const vt=e.createLucideIcon("ListX",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]]);/**
87
87
  * @license lucide-react v0.379.0 - ISC
88
88
  *
89
89
  * This source code is licensed under the ISC license.
90
90
  * See the LICENSE file in the root directory of this source tree.
91
- */const Cs=e.createLucideIcon("MessageSquareMore",[["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"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]]);/**
91
+ */const Ct=e.createLucideIcon("MessageSquareMore",[["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"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]]);/**
92
92
  * @license lucide-react v0.379.0 - ISC
93
93
  *
94
94
  * This source code is licensed under the ISC license.
95
95
  * See the LICENSE file in the root directory of this source tree.
96
- */const Ns=e.createLucideIcon("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/**
96
+ */const Nt=e.createLucideIcon("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/**
97
97
  * @license lucide-react v0.379.0 - ISC
98
98
  *
99
99
  * This source code is licensed under the ISC license.
@@ -108,17 +108,17 @@
108
108
  *
109
109
  * This source code is licensed under the ISC license.
110
110
  * See the LICENSE file in the root directory of this source tree.
111
- */const ks=e.createLucideIcon("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
111
+ */const kt=e.createLucideIcon("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
112
112
  * @license lucide-react v0.379.0 - ISC
113
113
  *
114
114
  * This source code is licensed under the ISC license.
115
115
  * See the LICENSE file in the root directory of this source tree.
116
- */const ws=e.createLucideIcon("Plug2",[["path",{d:"M9 2v6",key:"17ngun"}],["path",{d:"M15 2v6",key:"s7yy2p"}],["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M6 11V8h12v3a6 6 0 1 1-12 0v0Z",key:"nd4hoy"}]]);/**
116
+ */const wt=e.createLucideIcon("Plug2",[["path",{d:"M9 2v6",key:"17ngun"}],["path",{d:"M15 2v6",key:"s7yy2p"}],["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M6 11V8h12v3a6 6 0 1 1-12 0v0Z",key:"nd4hoy"}]]);/**
117
117
  * @license lucide-react v0.379.0 - ISC
118
118
  *
119
119
  * This source code is licensed under the ISC license.
120
120
  * See the LICENSE file in the root directory of this source tree.
121
- */const As=e.createLucideIcon("Save",[["path",{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",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
121
+ */const It=e.createLucideIcon("Save",[["path",{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",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
122
122
  * @license lucide-react v0.379.0 - ISC
123
123
  *
124
124
  * This source code is licensed under the ISC license.
@@ -128,27 +128,27 @@
128
128
  *
129
129
  * This source code is licensed under the ISC license.
130
130
  * See the LICENSE file in the root directory of this source tree.
131
- */const Is=e.createLucideIcon("ShieldQuestion",[["path",{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",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
131
+ */const Dt=e.createLucideIcon("ShieldQuestion",[["path",{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",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
132
132
  * @license lucide-react v0.379.0 - ISC
133
133
  *
134
134
  * This source code is licensed under the ISC license.
135
135
  * See the LICENSE file in the root directory of this source tree.
136
- */const zs=e.createLucideIcon("Sigma",[["path",{d:"M18 7V4H6l6 8-6 8h12v-3",key:"zis8ev"}]]);/**
136
+ */const zt=e.createLucideIcon("Sigma",[["path",{d:"M18 7V4H6l6 8-6 8h12v-3",key:"zis8ev"}]]);/**
137
137
  * @license lucide-react v0.379.0 - ISC
138
138
  *
139
139
  * This source code is licensed under the ISC license.
140
140
  * See the LICENSE file in the root directory of this source tree.
141
- */const Ds=e.createLucideIcon("SwatchBook",[["path",{d:"M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z",key:"1ldrpk"}],["path",{d:"M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7",key:"11i5po"}],["path",{d:"M 7 17h0.01",key:"10821z"}],["path",{d:"m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8",key:"o2gii7"}]]);/**
141
+ */const At=e.createLucideIcon("SwatchBook",[["path",{d:"M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z",key:"1ldrpk"}],["path",{d:"M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7",key:"11i5po"}],["path",{d:"M 7 17h0.01",key:"10821z"}],["path",{d:"m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8",key:"o2gii7"}]]);/**
142
142
  * @license lucide-react v0.379.0 - ISC
143
143
  *
144
144
  * This source code is licensed under the ISC license.
145
145
  * See the LICENSE file in the root directory of this source tree.
146
- */const Ls=e.createLucideIcon("Tag",[["path",{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",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/**
146
+ */const Lt=e.createLucideIcon("Tag",[["path",{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",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/**
147
147
  * @license lucide-react v0.379.0 - ISC
148
148
  *
149
149
  * This source code is licensed under the ISC license.
150
150
  * See the LICENSE file in the root directory of this source tree.
151
- */const Ts=e.createLucideIcon("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/**
151
+ */const Tt=e.createLucideIcon("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/**
152
152
  * @license lucide-react v0.379.0 - ISC
153
153
  *
154
154
  * This source code is licensed under the ISC license.
@@ -158,7 +158,7 @@
158
158
  *
159
159
  * This source code is licensed under the ISC license.
160
160
  * See the LICENSE file in the root directory of this source tree.
161
- */const Fs=e.createLucideIcon("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);function Os(){const[s,n]=f.useState(""),[t,r]=f.useState(!1),[l,x]=f.useState(!1),u=e.useDashboardStore(c=>c.dashboard);function o(){const c=e.getDashbaordStateWithoutData(u),p=e.getBookmarkKey(u.id),d=JSON.parse(localStorage.getItem(p)||"[]");if(d.some(y=>y.name===s)){r(!0);return}d.push({name:s,template:c}),localStorage.setItem(p,JSON.stringify(d)),x(!1)}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:l,onOpenChange:x,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(e.Button,{variant:"outline",className:"h-7 p-2",size:"sm",children:[e.jsxRuntimeExports.jsx(e.Plus,{className:" mr-2 h-4 w-4",strokeWidth:1.5}),"Add Lens"]})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Add a Lens"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsxRuntimeExports.jsx("div",{className:"grid gap-4 py-4",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-right",children:"Name"}),e.jsxRuntimeExports.jsx(e.Input,{value:s,onChange:c=>{t&&r(!1),n(c.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),t&&e.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"The bookmark name already exists. Use a differnet name."}),e.jsxRuntimeExports.jsx(e.DialogFooter,{children:e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",type:"submit",disabled:!s,onClick:o,children:"Save"})})]})]})}function Ms(){const[s,n]=f.useState(!1),[t,r]=f.useState(""),l=e.useDashboardStore(a=>a.dashboard),x=e.useDashboardStore(a=>a.bookmarkKey),[u,o]=f.useState([]),c=e.useDashboardStore(a=>a.actions.setDashboard),p=e.useDashboardStore(a=>a.actions.setFilterValues),d=e.useDashboardStore(a=>a.actions.setBookmarkKey);f.useEffect(()=>{const a=e.getBookmarkKey(l.id),m=JSON.parse(localStorage.getItem(a)||"[]");o(m);const h=m.find(v=>v.default);h&&h.name===x&&r(h.name)},[s,l,x]);function j(a){if(a===t)return;const m=u.find(v=>v.name===a),h=m==null?void 0:m.template;h&&(c(h),p(m.filterValues||[]),d(a==="Original"?"":a)),r(a)}function y(a){const m=e.getBookmarkKey(l.id),v=JSON.parse(localStorage.getItem(m)||"[]").filter(S=>S.name!==a);localStorage.setItem(m,JSON.stringify(v)),o(v)}return e.jsxRuntimeExports.jsxs(e.DropdownMenu,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",className:"h-7 p-2",children:e.jsxRuntimeExports.jsx(fs,{className:"h-4 w-4",strokeWidth:1.5})})}),e.jsxRuntimeExports.jsxs(e.DropdownMenuContent,{className:"w-56",children:[e.jsxRuntimeExports.jsx(e.DropdownMenuLabel,{children:"Lenses"}),e.jsxRuntimeExports.jsx(e.DropdownMenuSeparator,{}),e.jsxRuntimeExports.jsxs(e.DropdownMenuRadioGroup,{value:t,onValueChange:j,children:[e.jsxRuntimeExports.jsx(e.DropdownMenuRadioItem,{value:"Original",children:"Original"}),u.filter(a=>a.name!="Original").map((a,m)=>e.jsxRuntimeExports.jsxs(e.DropdownMenuRadioItem,{className:"xbg-red-100 flex justify-between",value:a.name,defaultChecked:a.name===x,children:[e.jsxRuntimeExports.jsx("p",{children:a.name}),e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:h=>{h.preventDefault(),y(a.name)},className:"h-3 w-3 hover:cursor-pointer",strokeWidth:1.5})]},m))]})]})]})}function qs(){const[s,n]=f.useState(!1),t=e.useDashboardStore(x=>x.dashboard),r=e.useDashboardStore(x=>x.bookmarkKey);f.useEffect(()=>{if(!r){n(!1);return}const x=e.getBookmarkKey(t.id),o=JSON.parse(localStorage.getItem(x)||"[]").find(c=>c.name===r);n(o?o.default:!1)},[r,t.id]);function l(x){if(n(x),!r)return;const u=e.getBookmarkKey(t.id),c=JSON.parse(localStorage.getItem(u)||"[]").map(p=>(p.name===r?p.default=x:p.default=!1,p));console.log(c),localStorage.setItem(u,JSON.stringify(c))}return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:s,onCheckedChange:l,id:"terms"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Set as default"})]})}function Bs(){const s=e.useDashboardStore(S=>S.bookmarkKey),n=e.useDashboardStore(S=>S.dashboard);e.useDashboardStore(S=>S.selectedSheetId);const t=e.useDashboardStore(S=>S.isDashboardEditing),r=e.useDashboardStore(S=>S.filterValues),l=e.useDashboardStore(S=>S.isVisualEditing),x=e.useDashboardStore(S=>S.showFilters);e.useDashboardStore(S=>S.showDashboardJSON);const u=e.useDashboardStore(S=>S.onSaveFunction),o=e.useDashboardStore(S=>S.actions.setShowFilters),{addFrame:c,setSelectedFrameId:p}=e.useDashboardStore(S=>S.actions),{getSelectedSheet:d,setIsDashboardEditing:j,setShowDashboardJSON:y}=e.useDashboardStore(S=>S.actions),a=d(),m=()=>{if(!t||!a)return;const S={id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]},z={id:e.v4(),cards:[S],activeCardId:S.id};c(a.id,z),p(z.id)},h=()=>{j(!0)};function v(){if(!s||s==="")return;const S=e.getDashbaordStateWithoutData(n),z=e.getBookmarkKey(n.id),R=JSON.parse(localStorage.getItem(z)||"[]"),A=R.findIndex(g=>g.name===s);A!==-1?R[A]={name:s,template:S,default:R[A].default,filterValues:r}:R.push({name:s,template:S,filterValues:r}),localStorage.setItem(z,JSON.stringify(R)),u==null||u(S)}return l?null:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-2 border-b bg-muted/50 px-2 py-2",role:"dashboard-controls",children:[!l&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:s}),!!s&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsxRuntimeExports.jsx(qs,{})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[t&&!l&&e.jsxRuntimeExports.jsx(Os,{}),!l&&e.jsxRuntimeExports.jsx(Ms,{}),t&&!l&&e.jsxRuntimeExports.jsxs(e.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!t,onClick:m,children:[e.jsxRuntimeExports.jsx(e.Plus,{className:"mr-2 h-4 w-4",strokeWidth:1.5}),"Add Frame"]}),!t&&e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",className:"h-7 p-2",onClick:h,size:"sm",children:e.jsxRuntimeExports.jsx($e,{className:"h-4 w-4",strokeWidth:1.5})}),t&&!l&&e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",role:"close",className:"h-7 p-2",onClick:()=>{j(!1),y(!1)},size:"sm",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"h-4 w-4",strokeWidth:1.5})}),t&&!l&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"outline",onClick:v,size:"sm",children:e.jsxRuntimeExports.jsx(As,{className:"h-4 w-4",strokeWidth:1.5})}),!x&&!l&&t&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"outline",onClick:()=>o(!0),size:"sm",children:e.jsxRuntimeExports.jsx(He,{className:"h-4 w-4",strokeWidth:1.5})}),!l&&t&&!1,!l&&!1]})]})}function ue({title:s,items:n,value:t,isLoading:r,isError:l,connectionTooltip:x,onChange:u,showNone:o=!1,className:c,showIcon:p=!0,disabled:d=!1}){const j=r?"Loading...":l?"Error":t;function y(){if(s==="Connection")return e.jsxRuntimeExports.jsx(ws,{className:"size-4 rotate-90"});if(s==="Database")return e.jsxRuntimeExports.jsx(js,{className:"size-4"});if(s==="Schema")return e.jsxRuntimeExports.jsx(Ns,{className:"size-4"});if(s==="Table")return e.jsxRuntimeExports.jsx(e.Table,{className:"size-4"});if(s==="Dataset")return e.jsxRuntimeExports.jsx(ps,{className:"size-4"})}return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[p&&e.jsxRuntimeExports.jsx("div",{className:"shrink-0",children:x?e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:y()}),e.jsxRuntimeExports.jsx(e.TooltipContent,{className:"text-xs",align:"start",children:x})]}):y()}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:d,value:j,onValueChange:u,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("h-9 w-full focus:ring-1 focus:ring-offset-0",c),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:r?"Loading...":l?"Error":`Select ${s}`})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[r?e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Loading..."}):e.jsxRuntimeExports.jsx(e.SelectLabel,{children:s}),e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[o&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),n&&n.map((a,m)=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.id,children:a.name},m))]}),(r||l)&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:j,children:j})]})})]})]})}function Vs({column:s}){const[n,t]=f.useState(!1),r=e.useEditorStore(d=>d.selectedTableName),l=e.useEditorStore(d=>d.selectedSchemaName),x=e.useEditorStore(d=>d.sqlGen),u=e.useEditorStore(d=>d.actions.setSqlGen),o=e.useEditorStore(d=>d.actions.setCardSql),c=e.useEditorStore(d=>d.actions.setRunSql);function p(d,j){const y=e.createSqlGenConfig(d,x,j);u(y);const a=e.getSql(y,e.fmt(l||""),e.fmt(r));a&&(o(a),c(!0)),t(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:n,onOpenChange:t,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.ChevronDown,{className:"h-4 w-4 cursor-pointer text-foreground/40"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"w-18 rounded-md p-0 shadow-none",children:e.jsxRuntimeExports.jsxs("ul",{className:"text-xs",children:[e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})})]})}function Qe({column:s}){return e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.$a093c7e1ec25a057$export$8c610744efcf8a1d,{asChild:!0,children:e.TEXT_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Te,{className:"size-3"}):e.NUMBER_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Rs,{className:"size-3"}):e.DATE_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(e.Calendar,{className:"size-3"}):e.BOOLEAN_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Ts,{className:"size-3"}):e.jsxRuntimeExports.jsx(Is,{className:"size-3"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{children:e.jsxRuntimeExports.jsx("p",{className:"font-mono text-xs",children:s.data_type})})]})}function _s({schemaName:s,tableName:n,columns:t,status:r}){const l=e.useEditorStore(g=>g.sqlGen),x=e.useEditorStore(g=>g.selectedConnectionId),u=e.useEditorStore(g=>g.selectedDatabaseName),o=e.useEditorStore(g=>g.selectedSchemaName),c=e.useEditorStore(g=>g.selectedTableName),p=e.useDashboardStore(g=>g.dashboard.aiScopeTables),{setAIScopeTables:d}=e.useDashboardStore(g=>g.actions),j=e.useEditorStore(g=>g.actions.setRunSql),y=e.useEditorStore(g=>g.actions.setSqlGen),a=e.useEditorStore(g=>g.actions.setIsShowingVisual),m=e.useEditorStore(g=>g.actions.setCardSql),{connectionType:h}=ve();function v(g){const C=e.createSqlGenConfig(g,l);y(C);const w=e.getSql(C,e.fmt(s),e.fmt(n));w&&(m(w),j(!0))}function S(){return(p==null?void 0:p.find(g=>g.connectinonId===x&&g.tableName===c))!==void 0}function z(g){if(g===!0&&c&&x){const C={connectinonId:x,connectionType:h,databaseName:u,schemaName:o,tableName:c},L=[...p||[],C].filter((N,O,q)=>q.findIndex(D=>D.connectinonId===N.connectinonId&&D.tableName===N.tableName)===O);d(L),e.Jt.success(`Added '${c}' to AI Scope`,{position:"top-right",duration:2500,richColors:!0})}else{const C=(p||[]).filter(w=>w.connectinonId!==x&&w.tableName!==c);d(C),e.Jt(`Removed '${c}' from AI Scope`,{position:"top-right",duration:2e3,richColors:!0})}}function R(){let C=e.getQualifiedTableName(s,n);(N=>N.charAt(0)===N.charAt(0).toUpperCase())(n)&&(C=`"${n}"`),a(!1);const L=h==="MSSQL"?`SELECT top 10 * FROM ${C}`:`SELECT * FROM ${C} LIMIT 10`;m(L),j(!0)}function A(){let C=e.getQualifiedTableName(s,n);(L=>L.charAt(0)===L.charAt(0).toUpperCase())(n)&&(C=`"${n}"`),a(!1),m(`SELECT COUNT(*) as count FROM ${C}`),j(!0)}return e.jsxRuntimeExports.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Toggle,{title:`${S()?"Remove from":"Add to"} AI Scope`,pressed:S(),onPressedChange:z,variant:"outline",className:"h-9 px-2",children:e.jsxRuntimeExports.jsx(e.Bot,{className:e.cn("size-4",{"text-primary":S(),"text-muted-foreground":!S()})})}),e.jsxRuntimeExports.jsxs(e.Button,{disabled:r!=="Success",onClick:R,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(Ds,{className:"mr-2 size-4"}),"Top 10"]}),e.jsxRuntimeExports.jsxs(e.Button,{disabled:r!=="Success",onClick:A,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(zs,{className:"mr-2 size-4"}),"Count"]})]}),e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"flex-1 basis-0 overflow-y-auto border-b border-t border-muted py-3",children:[t==null?void 0:t.map(g=>e.jsxRuntimeExports.jsxs("div",{onClick:()=>v(g),className:e.cn("mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":e.isColumnInSqlGen(g,l)}),children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(Qe,{column:g}),e.jsxRuntimeExports.jsx("span",{children:g.column_name})]}),e.NUMBER_DATA_TYPES.includes(g.data_type)&&e.jsxRuntimeExports.jsx("div",{onClick:C=>C.stopPropagation(),className:"flex items-center justify-end",children:e.jsxRuntimeExports.jsx(Vs,{column:g})})]},g.column_name)),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"vertical"}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})]})}function ve(s,n){var Ee,fe,pe,ge,Re;let t=f.useMemo(()=>[],[]);const r=e.useSemaphorContext().authToken||s,l=e.useEditorStore(i=>i.selectedConnectionId),x=e.useEditorStore(i=>i.selectedDatamodelId),u=e.useEditorStore(i=>i.selectedDatabaseName),o=e.useEditorStore(i=>i.selectedSchemaName),c=e.useEditorStore(i=>i.selectedTableName),p=e.useEditorStore(i=>i.actions.setCurrentColumns),d=e.useEditorStore(i=>i.actions.setSelectedConnectionId),j=e.useEditorStore(i=>i.actions.setSelectedDatamodelId),y=e.useEditorStore(i=>i.actions.setSelectedDatabaseName),a=e.useEditorStore(i=>i.actions.setSelectedSchemaName),m=e.useEditorStore(i=>i.actions.setSelectedTableName),h=e.useEditorStore(i=>i.actions.setCardSql);function v(i){return l&&u&&o&&u!=="NA"?!0:l&&i==="API"?!1:!!(l&&i==="S3")}function S(i){return!!(l&&u&&u!=="NA"&&o&&c||l&&(i==="S3"||i==="API")||x&&x)}function z(i){return l&&i?!(i==="API"||i==="S3"):!1}const{data:R,isLoading:A,isError:g}=e.useQuery({queryKey:["connections"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/connections",(r==null?void 0:r.accessToken)||""),enabled:!!(r!=null&&r.accessToken)}),{data:C,isLoading:w,isError:L}=e.useQuery({queryKey:["models",l],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/datamodels",(r==null?void 0:r.accessToken)||"",{connection_id:l}),enabled:!!(r!=null&&r.accessToken)&&!!l}),N=R==null?void 0:R.connections.find(i=>i.id===l),O=N==null?void 0:N.type,q=(N==null?void 0:N.type)==="API"||(N==null?void 0:N.type)==="S3",{data:D,isLoading:H,isFetching:K,isError:B,refetch:G}=e.useQuery({queryKey:["databases",l],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/databases",(r==null?void 0:r.accessToken)||"",{connection_id:l}),enabled:z(O)}),{data:F,isLoading:Q,isFetching:b,isError:E,refetch:k}=e.useQuery({queryKey:["schemas",l,u],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/schemas",(r==null?void 0:r.accessToken)||"",{connection_id:l,database_name:u}),enabled:!!l&&!!u&&!q&&u!=="NA"}),{data:T,isLoading:se,isFetching:$,isError:I,refetch:V}=e.useQuery({queryKey:["tables",l,u,o],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/tables",(r==null?void 0:r.accessToken)||"",{connection_id:l,database_name:u,schema_name:o}),enabled:v(O)}),{data:P,isLoading:ne,isFetching:te,isError:M}=e.useQuery({queryKey:["columns",l,u,x,o,c],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/columns",(r==null?void 0:r.accessToken)||"",{connection_id:l,datamodel_id:x||"",database_name:u,schema_name:o,table_name:c}),enabled:S(O)});f.useEffect(()=>{p(t)},[P,p,t]),f.useEffect(()=>{},[q,h,m,a,y,N]);const U=(N==null?void 0:N.type)==="API"?(Ee=N==null?void 0:N.type)==null?void 0:Ee.toLowerCase():c||"",J=q?"":o||"";function oe(i){a(i),m("")}function ae(i){y(i==="none"?"":i),a(""),m(""),i!=="none"&&i!==""&&j("")}function me(i){d(i)}function Oe(i){j(i==="none"?"":i),i!=="none"&&i!==""&&y("")}D&&((fe=D==null?void 0:D.databases)==null?void 0:fe.length)>0,F&&((pe=F==null?void 0:F.schemas)==null?void 0:pe.length)>0,P&&((ge=P==null?void 0:P.columns)==null?void 0:ge.length)>0&&(t=P.columns.map(i=>({...i,data_type:i.data_type.toLowerCase()}))),B&&(t=[]),(M||g)&&(t=[]);const le=R==null?void 0:R.connections.map(i=>({id:i.id,name:i.name,type:i.type})),Ne=(Re=C==null?void 0:C.datamodels)==null?void 0:Re.map(i=>({id:i.id,name:i.name})),je=D==null?void 0:D.databases.map(i=>({id:i.database_name,name:i.database_name})),ke=F==null?void 0:F.schemas.map(i=>({id:i.schema_name,name:i.schema_name})),we=T==null?void 0:T.tables.map(i=>({id:i.table_name,name:i.table_name}));return{connectionItems:le,isConnectionsLoading:A,isConnectionsError:g,modelItems:Ne,isModelsLoading:w,isModelsError:L,databaseItems:je,isDatabasesLoadingOrFetching:H||K,isDatabaseError:B,schemaItems:ke,isSchemaLoadingOrFetching:Q||b,isSchemaError:E,tableItems:we,isTableLoadingOrFetching:se||$,isTableError:I,columns:t,isColumnsLoadingOrFetching:ne||te,isColumnsError:M,isNonDbConnection:q,connectionType:O,tableName:U,schemaName:J,handleConnectionChange:me,handleDatamodelChange:Oe,handleDatabaseChange:ae,handleSchemaChange:oe}}function Ue({ColumnsComponent:s}){var $;const n=e.useEditorStore(I=>I.selectedConnectionId),t=e.useEditorStore(I=>I.selectedDatamodelId),r=e.useEditorStore(I=>I.selectedDatabaseName),l=e.useEditorStore(I=>I.selectedSchemaName),x=e.useEditorStore(I=>I.selectedTableName),u=e.useEditorStore(I=>I.actions.setSelectedTableName),{connectionItems:o,modelItems:c,schemaItems:p,databaseItems:d,tableItems:j,columns:y,isConnectionsLoading:a,isModelsLoading:m,isConnectionsError:h,isModelsError:v,isDatabasesLoadingOrFetching:S,isDatabaseError:z,isSchemaLoadingOrFetching:R,isSchemaError:A,isColumnsError:g,isColumnsLoadingOrFetching:C,isTableLoadingOrFetching:w,isTableError:L,connectionType:N,isNonDbConnection:O,handleConnectionChange:q,handleDatabaseChange:D,handleSchemaChange:H,handleDatamodelChange:K,tableName:B,schemaName:G}=ve();function F(){return s?s(G,B,y):e.jsxRuntimeExports.jsx(_s,{schemaName:G,tableName:B,columns:y,status:C?"Loading...":g?"Error":"Success"})}function Q(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function b(){if(!n||N==="S3"||N==="API")return null;if(!t||t==="none")return e.jsxRuntimeExports.jsx(ue,{showNone:!0,onChange:D,isError:z,isLoading:S,items:d,value:r||"",title:"Database"})}function E(){if(n&&!O&&(!r||r==="none")&&(!t||t==="none"))return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3",children:[e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Separator,{})}),e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Label,{children:"OR"})}),e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Separator,{})})]})}function k(){if(!n||N==="S3"||N==="API")return null;if(!r||r==="none")return e.jsxRuntimeExports.jsx(ue,{showNone:!0,onChange:K,isError:v,isLoading:m,items:c,value:t||"",title:"Dataset"})}function T(){return!n||N==="S3"||N==="API"||!r||r==="none"?null:e.jsxRuntimeExports.jsx(ue,{onChange:H,isError:A,isLoading:R,items:p,value:l||"",title:"Schema"})}function se(){function I(){let V=!1;return N==="API"?(V=!1,V):((N==="S3"||n&&r&&r!=="none"&&l)&&(V=!0),V)}return I()?e.jsxRuntimeExports.jsx(ue,{onChange:u,isError:L,items:j,isLoading:w,value:x||"",title:"Table"}):null}return e.jsxRuntimeExports.jsxs("aside",{className:"xbg-red-100 flex grow flex-col justify-between",children:[e.jsxRuntimeExports.jsxs("section",{className:"space-y-3 px-6 py-4",children:[e.jsxRuntimeExports.jsx(ue,{items:o,title:"Connection",value:n||"",onChange:q,isLoading:a,isError:h,connectionTooltip:(($=o==null?void 0:o.find(I=>I.id===n))==null?void 0:$.type)||""}),k(),E(),b(),T(),se()]}),F(),e.jsxRuntimeExports.jsx("div",{className:"flex items-end justify-center gap-2 px-6 py-4",children:e.jsxRuntimeExports.jsxs(e.Button,{onClick:Q,size:"sm",variant:"secondary",className:"w-full",children:[e.jsxRuntimeExports.jsx(Cs,{className:"mr-2 size-4"}),"Help"]})})]})}function Hs(s){const n=s.toUpperCase().indexOf("WHERE"),t=s.toUpperCase().indexOf("GROUP BY"),r=s.toUpperCase().indexOf("LIMIT"),l=s.toUpperCase().indexOf("ORDER BY");let x=s.length;if(l!==-1&&(x=l),r!==-1&&r<x&&(x=r),n!==-1){const u=s.substring(0,n),o=s.substring(n);return`${u} {{ filters | where }} AND ${o.substring(6)}`}else if(t!==-1){const u=s.substring(0,t),o=s.substring(t);return`${u} {{ filters | where }} ${o}`}else{const u=s.substring(0,x),o=s.substring(x);return`${u} {{ filters | where }} ${o}`}}function Ps({error:s,setShowAIDialog:n,setUserInputforAI:t,setTriggerAIRun:r}){return e.jsxRuntimeExports.jsxs(e.HoverCard,{openDelay:0,children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"link",className:" p-0 h-5",children:e.jsxRuntimeExports.jsx(hs,{className:"h-4 w-4 text-red-500"})})}),e.jsxRuntimeExports.jsx(e.HoverCardContent,{align:"start",className:" min-w-fit max-w-[500px]",children:e.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxRuntimeExports.jsxs("div",{className:"grow space-y-1 flex flex-col ",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:()=>{n(!0),t(s),r(!0)},size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(gs,{className:"h-4 w-4 mr-2"}),"Fix It"]}),e.jsxRuntimeExports.jsx(e.ScrollArea,{className:" min-h-0 max-h-[250px] overflow-scroll ",children:e.jsxRuntimeExports.jsx("p",{className:" overflow-auto text-sm leading-relaxed font-mono ",children:s})})]})})})]})}function $s({text:s,onCheckedChange:n,checked:t}){return e.jsxRuntimeExports.jsxs("div",{className:"xbg-red-100 ml-6 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:t,onCheckedChange:n}),e.jsxRuntimeExports.jsx("label",{className:"text-xs leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:s})]})}function Ks(){const{authToken:s}=e.useSemaphorContext(),n=e.useEditorStore(x=>x.selectedConnectionId),{data:t}=e.useQuery({queryKey:["connections"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/connections",(s==null?void 0:s.accessToken)||""),enabled:!!(s!=null&&s.accessToken)}),r=t==null?void 0:t.connections.find(x=>x.id===n);return r==null?void 0:r.type}function Gs(){const{authToken:s}=e.useSemaphorContext(),n=f.useRef(null),t=e.useEditorStore(c=>c.applyFilters),[r,l]=f.useState(""),x=e.useEditorStore(c=>c.filterValues),u=e.useEditorStore(c=>c.card.sql),o=Ks();return e.jsxRuntimeExports.jsxs(e.HoverCard,{openDelay:0,onOpenChange:async c=>{if(!c)return;console.log("onOpenChange");const p=await e.postRequest("https://semaphor.cloud/api/v1/filter-sql",(s==null?void 0:s.accessToken)||"",{sql:u,active_filters:x,connection_type:o});console.log(p),p.sql?(console.log(p.records),l(p.sql)):l("Error")},children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:t&&e.jsxRuntimeExports.jsx("p",{className:"p-0 text-xs hover:cursor-pointer",children:"|  Filter Query"})}),e.jsxRuntimeExports.jsxs(e.HoverCardContent,{align:"end",className:"w-[600px]",children:[e.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-sm bg-muted p-2",children:e.jsxRuntimeExports.jsxs("code",{ref:n,className:"font-mono text-sm",children:[r,e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{onClick:()=>e.copyToClipboard(n),className:"ml-3 inline-block h-4 w-4 opacity-70 hover:cursor-pointer hover:opacity-100"})]})})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsxRuntimeExports.jsx(e.InfoCircledIcon,{className:"h-4 w-4 opacity-70"}),e.jsxRuntimeExports.jsx("span",{className:"text-xs text-muted-foreground",children:"A preview of the query with filters applied."})]})]})]})}const Qs=`
161
+ */const Ft=e.createLucideIcon("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);function Ot(){const[t,r]=R.useState(""),[s,n]=R.useState(!1),[l,x]=R.useState(!1),u=e.useDashboardStore(c=>c.dashboard);function o(){const c=e.getDashbaordStateWithoutData(u),p=e.getBookmarkKey(u.id),m=JSON.parse(localStorage.getItem(p)||"[]");if(m.some(E=>E.name===t)){n(!0);return}m.push({name:t,template:c}),localStorage.setItem(p,JSON.stringify(m)),x(!1)}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:l,onOpenChange:x,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(e.Button,{variant:"outline",className:"h-7 p-2",size:"sm",children:[e.jsxRuntimeExports.jsx(e.Plus,{className:" mr-2 h-4 w-4",strokeWidth:1.5}),"Add Lens"]})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Add a Lens"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsxRuntimeExports.jsx("div",{className:"grid gap-4 py-4",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-right",children:"Name"}),e.jsxRuntimeExports.jsx(e.Input,{value:t,onChange:c=>{s&&n(!1),r(c.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),s&&e.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"The bookmark name already exists. Use a differnet name."}),e.jsxRuntimeExports.jsx(e.DialogFooter,{children:e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",type:"submit",disabled:!t,onClick:o,children:"Save"})})]})]})}function Mt(){const[t,r]=R.useState(!1),[s,n]=R.useState(""),l=e.useDashboardStore(a=>a.dashboard),x=e.useDashboardStore(a=>a.bookmarkKey),[u,o]=R.useState([]),c=e.useDashboardStore(a=>a.actions.setDashboard),p=e.useDashboardStore(a=>a.actions.setFilterValues),m=e.useDashboardStore(a=>a.actions.setBookmarkKey);R.useEffect(()=>{const a=e.getBookmarkKey(l.id),d=JSON.parse(localStorage.getItem(a)||"[]");o(d);const h=d.find(C=>C.default);h&&h.name===x&&n(h.name)},[t,l,x]);function j(a){if(a===s)return;const d=u.find(C=>C.name===a),h=d==null?void 0:d.template;h&&(c(h),p(d.filterValues||[]),m(a==="Original"?"":a)),n(a)}function E(a){const d=e.getBookmarkKey(l.id),C=JSON.parse(localStorage.getItem(d)||"[]").filter(S=>S.name!==a);localStorage.setItem(d,JSON.stringify(C)),o(C)}return e.jsxRuntimeExports.jsxs(e.DropdownMenu,{open:t,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",className:"h-7 p-2",children:e.jsxRuntimeExports.jsx(ft,{className:"h-4 w-4",strokeWidth:1.5})})}),e.jsxRuntimeExports.jsxs(e.DropdownMenuContent,{className:"w-56",children:[e.jsxRuntimeExports.jsx(e.DropdownMenuLabel,{children:"Lenses"}),e.jsxRuntimeExports.jsx(e.DropdownMenuSeparator,{}),e.jsxRuntimeExports.jsxs(e.DropdownMenuRadioGroup,{value:s,onValueChange:j,children:[e.jsxRuntimeExports.jsx(e.DropdownMenuRadioItem,{value:"Original",children:"Original"}),u.filter(a=>a.name!="Original").map((a,d)=>e.jsxRuntimeExports.jsxs(e.DropdownMenuRadioItem,{className:"xbg-red-100 flex justify-between",value:a.name,defaultChecked:a.name===x,children:[e.jsxRuntimeExports.jsx("p",{children:a.name}),e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:h=>{h.preventDefault(),E(a.name)},className:"h-3 w-3 hover:cursor-pointer",strokeWidth:1.5})]},d))]})]})]})}function Bt(){const[t,r]=R.useState(!1),s=e.useDashboardStore(x=>x.dashboard),n=e.useDashboardStore(x=>x.bookmarkKey);R.useEffect(()=>{if(!n){r(!1);return}const x=e.getBookmarkKey(s.id),o=JSON.parse(localStorage.getItem(x)||"[]").find(c=>c.name===n);r(o?o.default:!1)},[n,s.id]);function l(x){if(r(x),!n)return;const u=e.getBookmarkKey(s.id),c=JSON.parse(localStorage.getItem(u)||"[]").map(p=>(p.name===n?p.default=x:p.default=!1,p));console.log(c),localStorage.setItem(u,JSON.stringify(c))}return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:t,onCheckedChange:l,id:"terms"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Set as default"})]})}function qt(){const t=e.useDashboardStore(S=>S.bookmarkKey),r=e.useDashboardStore(S=>S.dashboard);e.useDashboardStore(S=>S.selectedSheetId);const s=e.useDashboardStore(S=>S.isDashboardEditing),n=e.useDashboardStore(S=>S.filterValues),l=e.useDashboardStore(S=>S.isVisualEditing),x=e.useDashboardStore(S=>S.showFilters);e.useDashboardStore(S=>S.showDashboardJSON);const u=e.useDashboardStore(S=>S.onSaveFunction),o=e.useDashboardStore(S=>S.actions.setShowFilters),{addFrame:c,setSelectedFrameId:p}=e.useDashboardStore(S=>S.actions),{getSelectedSheet:m,setIsDashboardEditing:j,setShowDashboardJSON:E}=e.useDashboardStore(S=>S.actions),a=m(),d=()=>{if(!s||!a)return;const S={id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]},I={id:e.v4(),cards:[S],activeCardId:S.id};c(a.id,I),p(I.id)},h=()=>{j(!0)};function C(){if(!t||t==="")return;const S=e.getDashbaordStateWithoutData(r),I=e.getBookmarkKey(r.id),f=JSON.parse(localStorage.getItem(I)||"[]"),D=f.findIndex(z=>z.name===t);D!==-1?f[D]={name:t,template:S,default:f[D].default,filterValues:n}:f.push({name:t,template:S,filterValues:n}),localStorage.setItem(I,JSON.stringify(f)),u==null||u(S)}return l?null:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-2 border-b bg-muted/50 px-2 py-2",role:"dashboard-controls",children:[!l&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:t}),!!t&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsxRuntimeExports.jsx(Bt,{})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[s&&!l&&e.jsxRuntimeExports.jsx(Ot,{}),!l&&e.jsxRuntimeExports.jsx(Mt,{}),s&&!l&&e.jsxRuntimeExports.jsxs(e.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!s,onClick:d,children:[e.jsxRuntimeExports.jsx(e.Plus,{className:"mr-2 h-4 w-4",strokeWidth:1.5}),"Add Frame"]}),!s&&e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",className:"h-7 p-2",onClick:h,size:"sm",children:e.jsxRuntimeExports.jsx($e,{className:"h-4 w-4",strokeWidth:1.5})}),s&&!l&&e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",role:"close",className:"h-7 p-2",onClick:()=>{j(!1),E(!1)},size:"sm",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"h-4 w-4",strokeWidth:1.5})}),s&&!l&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"outline",onClick:C,size:"sm",children:e.jsxRuntimeExports.jsx(It,{className:"h-4 w-4",strokeWidth:1.5})}),!x&&!l&&s&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"outline",onClick:()=>o(!0),size:"sm",children:e.jsxRuntimeExports.jsx(He,{className:"h-4 w-4",strokeWidth:1.5})}),!l&&s&&!1,!l&&!1]})]})}function ue({title:t,items:r,value:s,isLoading:n,isError:l,connectionTooltip:x,onChange:u,showNone:o=!1,className:c,showIcon:p=!0,disabled:m=!1}){const j=n?"Loading...":l?"Error":s;function E(){if(t==="Connection")return e.jsxRuntimeExports.jsx(wt,{className:"size-4 rotate-90"});if(t==="Database")return e.jsxRuntimeExports.jsx(jt,{className:"size-4"});if(t==="Schema")return e.jsxRuntimeExports.jsx(Nt,{className:"size-4"});if(t==="Table")return e.jsxRuntimeExports.jsx(e.Table,{className:"size-4"});if(t==="Dataset")return e.jsxRuntimeExports.jsx(pt,{className:"size-4"})}return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[p&&e.jsxRuntimeExports.jsx("div",{className:"shrink-0",children:x?e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:E()}),e.jsxRuntimeExports.jsx(e.TooltipContent,{className:"text-xs",align:"start",children:x})]}):E()}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:m,value:j,onValueChange:u,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("h-9 w-full focus:ring-1 focus:ring-offset-0",c),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:n?"Loading...":l?"Error":`Select ${t}`})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[n?e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Loading..."}):e.jsxRuntimeExports.jsx(e.SelectLabel,{children:t}),e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[o&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),r&&r.map((a,d)=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.id,children:a.name},d))]}),(n||l)&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:j,children:j})]})})]})]})}function Vt({column:t}){const[r,s]=R.useState(!1),n=e.useEditorStore(E=>E.selectedTableName),l=e.useEditorStore(E=>E.selectedSchemaName),x=e.useEditorStore(E=>E.selectedDatamodelId),u=e.useEditorStore(E=>E.sqlGen),{modelItems:o}=je(),c=e.useEditorStore(E=>E.actions.setSqlGen),p=e.useEditorStore(E=>E.actions.setCardSql),m=e.useEditorStore(E=>E.actions.setRunSql);function j(E,a){var S;const d=e.createSqlGenConfig(E,u,a),h=(S=o==null?void 0:o.find(I=>I.id===x))==null?void 0:S.name;c(d);const C=e.getSql(d,e.fmt(l||""),e.fmt(n),h);C&&(p(C),m(!0)),s(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:r,onOpenChange:s,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.ChevronDown,{className:"h-4 w-4 cursor-pointer text-foreground/40"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"w-18 rounded-md p-0 shadow-none",children:e.jsxRuntimeExports.jsxs("ul",{className:"text-xs",children:[e.jsxRuntimeExports.jsx("li",{onClick:()=>j(t,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>j(t,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>j(t,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>j(t,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>j(t,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})})]})}function Qe({column:t}){return e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.$a093c7e1ec25a057$export$8c610744efcf8a1d,{asChild:!0,children:e.TEXT_DATA_TYPES.includes(t.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Te,{className:"size-3"}):e.NUMBER_DATA_TYPES.includes(t.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Rt,{className:"size-3"}):e.DATE_DATA_TYPES.includes(t.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(e.Calendar,{className:"size-3"}):e.BOOLEAN_DATA_TYPES.includes(t.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Tt,{className:"size-3"}):e.jsxRuntimeExports.jsx(Dt,{className:"size-3"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{children:e.jsxRuntimeExports.jsx("p",{className:"font-mono text-xs",children:t.data_type})})]})}function _t({schemaName:t,tableName:r,columns:s,status:n}){const l=e.useEditorStore(b=>b.sqlGen),x=e.useEditorStore(b=>b.selectedConnectionId),u=e.useEditorStore(b=>b.selectedDatabaseName),o=e.useEditorStore(b=>b.selectedSchemaName),c=e.useEditorStore(b=>b.selectedTableName),p=e.useEditorStore(b=>b.selectedDatamodelId),m=e.useDashboardStore(b=>b.dashboard.aiScopeTables),{setAIScopeTables:j}=e.useDashboardStore(b=>b.actions),E=e.useEditorStore(b=>b.actions.setRunSql),a=e.useEditorStore(b=>b.actions.setSqlGen),d=e.useEditorStore(b=>b.actions.setIsShowingVisual),h=e.useEditorStore(b=>b.actions.setCardSql),{connectionType:C,modelItems:S}=je();function I(b){var k;const v=e.createSqlGenConfig(b,l);a(v);const T=(k=S==null?void 0:S.find(F=>F.id===p))==null?void 0:k.name,M=e.getSql(v,e.fmt(t),e.fmt(r),T);M&&(h(M),E(!0))}function f(){return(m==null?void 0:m.find(b=>b.connectinonId===x&&b.tableName===c))!==void 0}function D(b){if(b===!0&&c&&x){const v={connectinonId:x,connectionType:C,databaseName:u,schemaName:o,tableName:c},M=[...m||[],v].filter((k,F,_)=>_.findIndex(q=>q.connectinonId===k.connectinonId&&q.tableName===k.tableName)===F);j(M),e.Jt.success(`Added '${c}' to AI Scope`,{position:"top-right",duration:2500,richColors:!0})}else{const v=(m||[]).filter(T=>T.connectinonId!==x&&T.tableName!==c);j(v),e.Jt(`Removed '${c}' from AI Scope`,{position:"top-right",duration:2e3,richColors:!0})}}function z(){var k;let b=e.getQualifiedTableName(t,r);const v=(k=S==null?void 0:S.find(F=>F.id===p))==null?void 0:k.name;console.log("modelName",v),p&&p!=="none"&&(b=`d.${v}`);let T=b;return(F=>/[A-Z]/.test(F))(r)&&(T=T.split(".").map(_=>`"${_}"`).join(".")),T}function L(){const b=z();d(!1);const v=C==="MSSQL"?`SELECT top 10 * FROM ${b}`:`SELECT * FROM ${b} LIMIT 10`;h(v),E(!0)}function w(){const b=z();d(!1),h(`SELECT COUNT(*) as count FROM ${b}`),E(!0)}return e.jsxRuntimeExports.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Toggle,{title:`${f()?"Remove from":"Add to"} AI Scope`,pressed:f(),onPressedChange:D,variant:"outline",className:"h-9 px-2",children:e.jsxRuntimeExports.jsx(e.Bot,{className:e.cn("size-4",{"text-primary":f(),"text-muted-foreground":!f()})})}),e.jsxRuntimeExports.jsxs(e.Button,{disabled:n!=="Success",onClick:L,size:"sm",variant:"secondary",className:"flex",children:[n!=="Success"?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(At,{className:"mr-2 size-4"}),"Top 10"]}),e.jsxRuntimeExports.jsxs(e.Button,{disabled:n!=="Success",onClick:w,size:"sm",variant:"secondary",className:"flex",children:[n!=="Success"?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(zt,{className:"mr-2 size-4"}),"Count"]})]}),e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"flex-1 basis-0 overflow-y-auto border-b border-t border-muted py-3",children:[s==null?void 0:s.map(b=>e.jsxRuntimeExports.jsxs("div",{onClick:()=>I(b),className:e.cn("mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":e.isColumnInSqlGen(b,l)}),children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(Qe,{column:b}),e.jsxRuntimeExports.jsx("span",{children:b.column_name})]}),e.NUMBER_DATA_TYPES.includes(b.data_type)&&e.jsxRuntimeExports.jsx("div",{onClick:v=>v.stopPropagation(),className:"flex items-center justify-end",children:e.jsxRuntimeExports.jsx(Vt,{column:b})})]},b.column_name)),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"vertical"}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})]})}function je(t,r){var fe,ge,pe,Re,be;let s=R.useMemo(()=>[],[]);const n=e.useSemaphorContext().authToken||t,l=e.useEditorStore(i=>i.selectedConnectionId),x=e.useEditorStore(i=>i.selectedDatamodelId),u=e.useEditorStore(i=>i.selectedDatabaseName),o=e.useEditorStore(i=>i.selectedSchemaName),c=e.useEditorStore(i=>i.selectedTableName),p=e.useEditorStore(i=>i.actions.setCurrentColumns),m=e.useEditorStore(i=>i.actions.setSelectedConnectionId),j=e.useEditorStore(i=>i.actions.setSelectedDatamodelId),E=e.useEditorStore(i=>i.actions.setSelectedDatabaseName),a=e.useEditorStore(i=>i.actions.setSelectedSchemaName),d=e.useEditorStore(i=>i.actions.setSelectedTableName),h=e.useEditorStore(i=>i.actions.setCardSql);function C(i){return l&&u&&o&&u!=="NA"?!0:l&&i==="API"?!1:!!(l&&i==="S3")}function S(i){return!!(l&&u&&u!=="NA"&&o&&c||l&&(i==="S3"||i==="API")||x&&x)}function I(i){return l&&i?!(i==="API"||i==="S3"):!1}const{data:f,isLoading:D,isError:z}=e.useQuery({queryKey:["connections"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/connections",(n==null?void 0:n.accessToken)||""),enabled:!!(n!=null&&n.accessToken)}),{data:L,isLoading:w,isError:b}=e.useQuery({queryKey:["models",l],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/datamodels",(n==null?void 0:n.accessToken)||"",{connection_id:l}),enabled:!!(n!=null&&n.accessToken)&&!!l}),v=f==null?void 0:f.connections.find(i=>i.id===l),T=v==null?void 0:v.type,M=(v==null?void 0:v.type)==="API"||(v==null?void 0:v.type)==="S3",{data:k,isLoading:F,isFetching:_,isError:q,refetch:G}=e.useQuery({queryKey:["databases",l],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/databases",(n==null?void 0:n.accessToken)||"",{connection_id:l}),enabled:I(T)}),{data:B,isLoading:Q,isFetching:y,isError:g,refetch:N}=e.useQuery({queryKey:["schemas",l,u],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/schemas",(n==null?void 0:n.accessToken)||"",{connection_id:l,database_name:u}),enabled:!!l&&!!u&&!M&&u!=="NA"}),{data:O,isLoading:te,isFetching:K,isError:A,refetch:H}=e.useQuery({queryKey:["tables",l,u,o],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/tables",(n==null?void 0:n.accessToken)||"",{connection_id:l,database_name:u,schema_name:o}),enabled:C(T)}),{data:$,isLoading:re,isFetching:se,isError:V}=e.useQuery({queryKey:["columns",l,u,x,o,c],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/columns",(n==null?void 0:n.accessToken)||"",{connection_id:l,datamodel_id:x||"",database_name:u,schema_name:o,table_name:c}),enabled:S(T)});R.useEffect(()=>{p(s)},[$,p,s]),R.useEffect(()=>{},[M,h,d,a,E,v]);const J=(v==null?void 0:v.type)==="API"?(fe=v==null?void 0:v.type)==null?void 0:fe.toLowerCase():c||"",U=M?"":o||"";function oe(i){a(i),d("")}function ae(i){E(i==="none"?"":i),a(""),d(""),i!=="none"&&i!==""&&j("")}function me(i){m(i)}function Oe(i){j(i==="none"?"":i),i!=="none"&&i!==""&&E("")}k&&((ge=k==null?void 0:k.databases)==null?void 0:ge.length)>0,B&&((pe=B==null?void 0:B.schemas)==null?void 0:pe.length)>0,$&&((Re=$==null?void 0:$.columns)==null?void 0:Re.length)>0&&(s=$.columns.map(i=>({...i,data_type:i.data_type.toLowerCase()}))),q&&(s=[]),(V||z)&&(s=[]);const le=f==null?void 0:f.connections.map(i=>({id:i.id,name:i.name,type:i.type})),Ne=(be=L==null?void 0:L.datamodels)==null?void 0:be.map(i=>({id:i.id,name:i.name})),Ee=k==null?void 0:k.databases.map(i=>({id:i.database_name,name:i.database_name})),ke=B==null?void 0:B.schemas.map(i=>({id:i.schema_name,name:i.schema_name})),we=O==null?void 0:O.tables.map(i=>({id:i.table_name,name:i.table_name}));return{connectionItems:le,isConnectionsLoading:D,isConnectionsError:z,modelItems:Ne,isModelsLoading:w,isModelsError:b,databaseItems:Ee,isDatabasesLoadingOrFetching:F||_,isDatabaseError:q,schemaItems:ke,isSchemaLoadingOrFetching:Q||y,isSchemaError:g,tableItems:we,isTableLoadingOrFetching:te||K,isTableError:A,columns:s,isColumnsLoadingOrFetching:re||se,isColumnsError:V,isNonDbConnection:M,connectionType:T,tableName:J,schemaName:U,handleConnectionChange:me,handleDatamodelChange:Oe,handleDatabaseChange:ae,handleSchemaChange:oe}}function Je({ColumnsComponent:t}){var K;const r=e.useEditorStore(A=>A.selectedConnectionId),s=e.useEditorStore(A=>A.selectedDatamodelId),n=e.useEditorStore(A=>A.selectedDatabaseName),l=e.useEditorStore(A=>A.selectedSchemaName),x=e.useEditorStore(A=>A.selectedTableName),u=e.useEditorStore(A=>A.actions.setSelectedTableName),{connectionItems:o,modelItems:c,schemaItems:p,databaseItems:m,tableItems:j,columns:E,isConnectionsLoading:a,isModelsLoading:d,isConnectionsError:h,isModelsError:C,isDatabasesLoadingOrFetching:S,isDatabaseError:I,isSchemaLoadingOrFetching:f,isSchemaError:D,isColumnsError:z,isColumnsLoadingOrFetching:L,isTableLoadingOrFetching:w,isTableError:b,connectionType:v,isNonDbConnection:T,handleConnectionChange:M,handleDatabaseChange:k,handleSchemaChange:F,handleDatamodelChange:_,tableName:q,schemaName:G}=je();function B(){return t?t(G,q,E):e.jsxRuntimeExports.jsx(_t,{schemaName:G,tableName:q,columns:E,status:L?"Loading...":z?"Error":"Success"})}function Q(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function y(){if(!r||v==="S3"||v==="API")return null;if(!s||s==="none")return e.jsxRuntimeExports.jsx(ue,{showNone:!0,onChange:k,isError:I,isLoading:S,items:m,value:n||"",title:"Database"})}function g(){if(r&&!T&&(!n||n==="none")&&(!s||s==="none"))return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3",children:[e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Separator,{})}),e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Label,{children:"OR"})}),e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Separator,{})})]})}function N(){if(!r||v==="S3"||v==="API")return null;if(!n||n==="none")return e.jsxRuntimeExports.jsx(ue,{showNone:!0,onChange:_,isError:C,isLoading:d,items:c,value:s||"",title:"Dataset"})}function O(){return!r||v==="S3"||v==="API"||!n||n==="none"?null:e.jsxRuntimeExports.jsx(ue,{onChange:F,isError:D,isLoading:f,items:p,value:l||"",title:"Schema"})}function te(){function A(){let H=!1;return v==="API"?(H=!1,H):((v==="S3"||r&&n&&n!=="none"&&l)&&(H=!0),H)}return A()?e.jsxRuntimeExports.jsx(ue,{onChange:u,isError:b,items:j,isLoading:w,value:x||"",title:"Table"}):null}return e.jsxRuntimeExports.jsxs("aside",{className:"xbg-red-100 flex grow flex-col justify-between",children:[e.jsxRuntimeExports.jsxs("section",{className:"space-y-3 px-6 py-4",children:[e.jsxRuntimeExports.jsx(ue,{items:o,title:"Connection",value:r||"",onChange:M,isLoading:a,isError:h,connectionTooltip:((K=o==null?void 0:o.find(A=>A.id===r))==null?void 0:K.type)||""}),N(),g(),y(),O(),te()]}),B(),e.jsxRuntimeExports.jsx("div",{className:"flex items-end justify-center gap-2 px-6 py-4",children:e.jsxRuntimeExports.jsxs(e.Button,{onClick:Q,size:"sm",variant:"secondary",className:"w-full",children:[e.jsxRuntimeExports.jsx(Ct,{className:"mr-2 size-4"}),"Help"]})})]})}function Ht(t){const r=t.toUpperCase().indexOf("WHERE"),s=t.toUpperCase().indexOf("GROUP BY"),n=t.toUpperCase().indexOf("LIMIT"),l=t.toUpperCase().indexOf("ORDER BY");let x=t.length;if(l!==-1&&(x=l),n!==-1&&n<x&&(x=n),r!==-1){const u=t.substring(0,r),o=t.substring(r);return`${u} {{ filters | where }} AND ${o.substring(6)}`}else if(s!==-1){const u=t.substring(0,s),o=t.substring(s);return`${u} {{ filters | where }} ${o}`}else{const u=t.substring(0,x),o=t.substring(x);return`${u} {{ filters | where }} ${o}`}}function Pt({error:t,setShowAIDialog:r,setUserInputforAI:s,setTriggerAIRun:n}){return e.jsxRuntimeExports.jsxs(e.HoverCard,{openDelay:0,children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"link",className:" p-0 h-5",children:e.jsxRuntimeExports.jsx(ht,{className:"h-4 w-4 text-red-500"})})}),e.jsxRuntimeExports.jsx(e.HoverCardContent,{align:"start",className:" min-w-fit max-w-[500px]",children:e.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxRuntimeExports.jsxs("div",{className:"grow space-y-1 flex flex-col ",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:()=>{r(!0),s(t),n(!0)},size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(gt,{className:"h-4 w-4 mr-2"}),"Fix It"]}),e.jsxRuntimeExports.jsx(e.ScrollArea,{className:" min-h-0 max-h-[250px] overflow-scroll ",children:e.jsxRuntimeExports.jsx("p",{className:" overflow-auto text-sm leading-relaxed font-mono ",children:t})})]})})})]})}function $t({text:t,onCheckedChange:r,checked:s}){return e.jsxRuntimeExports.jsxs("div",{className:"xbg-red-100 ml-6 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:s,onCheckedChange:r}),e.jsxRuntimeExports.jsx("label",{className:"text-xs leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:t})]})}function Kt(){const{authToken:t}=e.useSemaphorContext(),r=e.useEditorStore(x=>x.selectedConnectionId),{data:s}=e.useQuery({queryKey:["connections"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/connections",(t==null?void 0:t.accessToken)||""),enabled:!!(t!=null&&t.accessToken)}),n=s==null?void 0:s.connections.find(x=>x.id===r);return n==null?void 0:n.type}function Gt(){const{authToken:t}=e.useSemaphorContext(),r=R.useRef(null),s=e.useEditorStore(c=>c.applyFilters),[n,l]=R.useState(""),x=e.useEditorStore(c=>c.filterValues),u=e.useEditorStore(c=>c.card.sql),o=Kt();return e.jsxRuntimeExports.jsxs(e.HoverCard,{openDelay:0,onOpenChange:async c=>{if(!c)return;console.log("onOpenChange");const p=await e.postRequest("https://semaphor.cloud/api/v1/filter-sql",(t==null?void 0:t.accessToken)||"",{sql:u,active_filters:x,connection_type:o});console.log(p),p.sql?(console.log(p.records),l(p.sql)):l("Error")},children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:s&&e.jsxRuntimeExports.jsx("p",{className:"p-0 text-xs hover:cursor-pointer",children:"|  Filter Query"})}),e.jsxRuntimeExports.jsxs(e.HoverCardContent,{align:"end",className:"w-[600px]",children:[e.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-sm bg-muted p-2",children:e.jsxRuntimeExports.jsxs("code",{ref:r,className:"font-mono text-sm",children:[n,e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{onClick:()=>e.copyToClipboard(r),className:"ml-3 inline-block h-4 w-4 opacity-70 hover:cursor-pointer hover:opacity-100"})]})})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsxRuntimeExports.jsx(e.InfoCircledIcon,{className:"h-4 w-4 opacity-70"}),e.jsxRuntimeExports.jsx("span",{className:"text-xs text-muted-foreground",children:"A preview of the query with filters applied."})]})]})]})}const Qt=`
162
162
 
163
163
  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.
164
164
 
@@ -204,12 +204,12 @@ SELECT label, measure FROM table
204
204
 
205
205
  - Label - Category
206
206
  - Measure - Number
207
- `;function Us({open:s,setOpen:n,userInput:t,setUserInput:r,triggerAIRun:l,setTriggerAIRun:x}){const u=f.useRef(null),o=f.useRef(null),{authToken:c}=e.useSemaphorContext(),[p,d]=f.useState(!1),j=e.useEditorStore(b=>b.actions.setCardSql),y=e.useDashboardStore(b=>b.dashboard.baseQueries),a=e.useEditorStore(b=>b.actions.setRunSql),m=e.useEditorStore(b=>b.actions.setCardType),[h,v]=f.useState([]),S=e.useEditorStore(b=>b.currentColumns),z=e.useEditorStore(b=>b.card.sql),R=e.useEditorStore(b=>b.selectedTableName),A=`
208
- ${t}
209
-
210
- Database Query Dialect: ${R==="api"||R==="s3"?"DuckDb":""}
211
- Table Name: ${R}
212
- Table Columns: ${S==null?void 0:S.map(b=>`${b.column_name} | ${b.data_type}`).join(", ")}
213
- User SQL: ${z}
214
- ${y&&`Base Queries: ${JSON.stringify(y)} `}`,g=` 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.
215
- Visual Query Syntax: ${Qs}`,{data:C,isLoading:w,isFetching:L,isError:N,refetch:O}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(c==null?void 0:c.accessToken)||"",{user_content:`userContent: ${A} ${p?g:""}`}),enabled:!1});function q(b){if(b.toLowerCase().includes("bar"))m("bar");else if(b.toLowerCase().includes("line"))m("line");else if(b.toLowerCase().includes("bubble"))m("bubble");else if(b.toLowerCase().includes("scatter"))m("scatter");else if(b.toLowerCase().includes("stacked"))m("stackedBar");else if(b.toLowerCase().includes("pie"))m("pie");else if(b.toLowerCase().includes("donut")||b.toLowerCase().includes("doughnut"))m("doughnut");else if(b.toLowerCase().includes("radar"))m("radar");else return m("bar"),!1;return!0}f.useEffect(()=>{C&&v(b=>[...b,{role:"ai",content:C.response}])},[C]),f.useEffect(()=>{const b=setTimeout(()=>{var E;o.current&&(o.current.scroll({top:o.current.scrollHeight,behavior:"smooth"}),(E=u.current)==null||E.focus())},100);return()=>clearTimeout(b)},[h]);function D(){t&&(v(b=>[...b,{role:"user",content:t}]),q(t)&&d(!0),r(""),O())}f.useEffect(()=>{l&&(D(),x(!1))},[l,x]);const H={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},K={fontFamily:"monospace",fontSize:14,lineHeight:1.6},B={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},G={p:({node:b,...E})=>e.jsxRuntimeExports.jsx("p",{style:H,...E}),code:({node:b,...E})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...E}),pre:({node:b,...E})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:K,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:E.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:F,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:k=>{const T=F(k);T&&(n(!1),j(T),a(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:b,...E})=>e.jsxRuntimeExports.jsx("li",{style:B,...E})};function F(b){const E=b.currentTarget.closest("pre");if(!E)return;const k=E.textContent||E.innerText;return navigator.clipboard.writeText(k).then(()=>console.log("Text copied to clipboard")).catch(T=>console.error("Error in copying text: ",T)),k}function Q(){return h==null?void 0:h.map((b,E)=>b.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Fs,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:b.content})]},E):b.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:G,children:C==null?void 0:C.response.replace(/DuckDB/gi,"Semaphor")},E):e.jsxRuntimeExports.jsx("div",{},E))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"What can I help you with?"})]}),e.jsxRuntimeExports.jsx("div",{ref:o,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:Q()})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Textarea,{autoFocus:!0,ref:u,onKeyDown:b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),r(""),D())},placeholder:"Type your question here...",onFocus:b=>{const E=b.target,k=E.value.length;E.setSelectionRange(k,k)},className:e.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:w||L,value:t,onChange:b=>r(b.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:D,children:!w&&!L?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Je={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},qe=f.createContext&&f.createContext(Je),Js=["attr","size","title"];function Ws(s,n){if(s==null)return{};var t=Ys(s,n),r,l;if(Object.getOwnPropertySymbols){var x=Object.getOwnPropertySymbols(s);for(l=0;l<x.length;l++)r=x[l],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(s,r)&&(t[r]=s[r])}return t}function Ys(s,n){if(s==null)return{};var t={},r=Object.keys(s),l,x;for(x=0;x<r.length;x++)l=r[x],!(n.indexOf(l)>=0)&&(t[l]=s[l]);return t}function Se(){return Se=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r])}return s},Se.apply(this,arguments)}function Be(s,n){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);n&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(s,l).enumerable})),t.push.apply(t,r)}return t}function ye(s){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?Be(Object(t),!0).forEach(function(r){Xs(s,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Be(Object(t)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(t,r))})}return s}function Xs(s,n,t){return n=Zs(n),n in s?Object.defineProperty(s,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[n]=t,s}function Zs(s){var n=et(s,"string");return typeof n=="symbol"?n:String(n)}function et(s,n){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var r=t.call(s,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(s)}function We(s){return s&&s.map((n,t)=>f.createElement(n.tag,ye({key:t},n.attr),We(n.child)))}function ee(s){return n=>f.createElement(st,Se({attr:ye({},s.attr)},n),We(s.child))}function st(s){var n=t=>{var{attr:r,size:l,title:x}=s,u=Ws(s,Js),o=l||t.size||"1em",c;return t.className&&(c=t.className),s.className&&(c=(c?c+" ":"")+s.className),f.createElement("svg",Se({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,r,u,{className:c,style:ye(ye({color:s.color||t.color},t.style),s.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),x&&f.createElement("title",null,x),s.children)};return qe!==void 0?f.createElement(qe.Consumer,null,t=>n(t)):n(Je)}function tt(s){return ee({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)}function rt(){const{theme:s}=e.useTheme(),n=f.useRef(),t=f.useRef(),[r,l]=f.useState(!1),[x,u]=f.useState(!1),[o,c]=f.useState(!1),[p,d]=f.useState(""),[j,y]=f.useState(!1),{authToken:a}=e.useSemaphorContext();e.useDashboardStore(i=>i.selectedSheetId);const m=e.useDashboardStore(i=>i.dashboard.baseQueries),h=e.useEditorStore(i=>i.card),v=e.useDashboardStore(i=>i.theme),S=e.useEditorStore(i=>i.isShowingVisual),z=e.useEditorStore(i=>i.selectedConnectionId),R=e.useEditorStore(i=>i.selectedDatabaseName),A=e.useEditorStore(i=>i.selectedDatamodelId),g=e.useEditorStore(i=>i.selectedSchemaName);e.useDashboardStore(i=>i.actions.updateFrameCard);const C=e.useEditorStore(i=>i.selectedTableName),w=e.useEditorStore(i=>i.card.sql),L=e.useEditorStore(i=>i.card.python),N=e.resolveBaseQuery(w,m),O=e.useEditorStore(i=>i.selectedConnectionId),q=e.useEditorStore(i=>i.frame),D=e.useEditorStore(i=>i.filterValues),H=e.useEditorStore(i=>i.applyFilters),{setCardCustomCfg:K,setQueryResultColumns:B,setFilterValues:G,setCardSql:F,setCardPython:Q,setQueryError:b,setPythonStdOut:E,setCardPreferences:k}=e.useEditorStore(i=>i.actions),T=e.useEditorStore(i=>i.onSave),se=e.useEditorStore(i=>i.actions.setApplyFilters),$=e.useEditorStore(i=>i.onClose),I=e.useEditorStore(i=>i.actions.setCardData),V=e.useEditorStore(i=>i.actions.setSqlGen),P=e.useEditorStore(i=>i.runSql),ne=e.useEditorStore(i=>i.actions.setRunSql),te=e.useEditorStore(i=>i.actions.setIsSqlRunning),{data:M,isLoading:U,isFetching:J,isSuccess:oe,isError:ae,error:me,status:Oe,refetch:le}=e.useQuery({queryKey:[N,L],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(a==null?void 0:a.accessToken)||"",{connection_id:O,sql:N,python:L===e.PYTHON_DEFAULT_CODE?"":L,active_filters:H?D:[]}),enabled:!1,retry:!1});f.useEffect(()=>{if(M&&(I(M.records),M.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),E((M==null?void 0:M.output)||""),M.records.length>0)){const{dimensionKeys:i}=e.getKeys(M.records);B(i)}},[M,I,B,E]),f.useEffect(()=>{P&&(le(),ne(!1))},[P,le,ne]),f.useEffect(()=>{(U||J)&&te(!0),(ae||oe)&&te(!1),ae?(b(me.message),I([]),B([]),E("")):b("")},[U,J,M,E,ae,oe,te,I,B,b,me]);function Ne(){F(""),I([]),V({}),K(""),k({})}const je=i=>{t.current=i};function ke(){let i=w;w&&!w.includes("{{")&&(i=Hs(w),F(i));const W={...h,lastSelectedSchema:g,lastSelectedDatamodelId:A,lastSelectedDatabase:R,lastSelectedTable:C,connectionId:z,type:S?h.type:"table",sql:i,customCfg:S?h.customCfg:null},he=q.cards.map(ie=>ie.id===h.id?W:ie);T==null||T({...q,cards:he})}function we(){$==null||$()}function Ee(i){const W=getComputedStyle(document.documentElement).getPropertyValue(i);return fe(W)}function fe(i){const[W,he,ie]=i.split(" "),_=parseFloat(W),ls=parseFloat(he),cs=parseFloat(ie),xs=ls/100,Me=cs/100,re=(1-Math.abs(2*Me-1))*xs,ce=re*(1-Math.abs(_/60%2-1)),Ae=Me-re/2;let Y=0,X=0,Z=0;0<=_&&_<60?(Y=re,X=ce,Z=0):60<=_&&_<120?(Y=ce,X=re,Z=0):120<=_&&_<180?(Y=0,X=re,Z=ce):180<=_&&_<240?(Y=0,X=ce,Z=re):240<=_&&_<300?(Y=ce,X=0,Z=re):300<=_&&_<360&&(Y=re,X=0,Z=ce),Y=Math.round((Y+Ae)*255),X=Math.round((X+Ae)*255),Z=Math.round((Z+Ae)*255);const Ie=us=>{const ze=us.toString(16);return ze.length==1?"0"+ze:ze};return`#${Ie(Y)}${Ie(X)}${Ie(Z)}`}f.useEffect(()=>{const i=n.current,W=t.current;if(i){const he=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",ie=v==="system"?he:v;i.editor.defineTheme("default",{base:ie==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":ie==="light"?"#ffffff":Ee("--semaphor-background")}}),i.editor.setTheme("default")}return W&&i&&W.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return console.log("Executing query..."),le(),!1}),()=>{}},[s,v,n.current]);function pe(i){n.current=i}function ge(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[x&&e.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:e.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[e.jsxRuntimeExports.jsx($s,{checked:H,onCheckedChange:()=>se(!H),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Gs,{}),D&&x&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>u(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:i=>{if(i)try{JSON.parse(i),G(JSON.parse(i))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(D,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),D&&!x&&e.jsxRuntimeExports.jsx(He,{onClick:()=>u(!0),className:e.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":H})})]})}function Re(){return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"1",order:1,defaultSize:r?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:i=>{F(i)},value:w,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:pe,onMount:je})}),r&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),r&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:i=>{Q(i&&i.trim()||"")},value:L||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:pe,onMount:je})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return e.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[Re(),ge()]}),e.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{title:"Shift + Enter",disabled:U||J,onClick:()=>{le()},className:"shrink-0",size:"sm",variant:"outline",children:[U||J?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(ks,{className:"mr-2 h-4 w-4"}),"Run"]}),ae&&e.jsxRuntimeExports.jsx(Ps,{error:me.message,setShowAIDialog:c,setTriggerAIRun:y,setUserInputforAI:d}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ne,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Es,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:r,onPressedChange:i=>l(i),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(tt,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Us,{open:o,setOpen:c,userInput:p,triggerAIRun:j,setTriggerAIRun:y,setUserInput:i=>d(i)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:ke,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:we,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function nt({data:s}){var u;const[n,t]=f.useState([]),l=Object.keys(s[0]).map(o=>({accessorKey:o,header:({column:c})=>{const p=c.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>c.toggleSorting(c.getIsSorted()==="asc"),children:[o,p==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):p==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),x=e.useReactTable({data:s,columns:l,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:t,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return e.jsxRuntimeExports.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:x.getHeaderGroups().map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{children:o.headers.map(c=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:c.isPlaceholder?null:e.flexRender(c.column.columnDef.header,c.getContext())},c.id))},o.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(u=x.getRowModel().rows)!=null&&u.length?x.getRowModel().rows.map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":o.getIsSelected()&&"selected",children:o.getVisibleCells().map(c=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(c.column.columnDef.cell,c.getContext())},c.id))},o.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:l.length,className:"h-24 text-center",children:"No results."})})})]})}function Ye({className:s,...n}){var u;f.useState(0);const t=e.useDashboardStore(o=>o.themeStyle),r=e.useEditorStore(o=>o.card),l=e.useEditorStore(o=>o.actions.setCard);if(f.useEffect(()=>{},[r.data,r.type,r.cfg,r.customCfg,t,r.preferences]),!r.id)return null;let x;return r.data&&r.data.length>0&&(x=e.createChartConfig({data:r.data,cardType:r.type,cfg:r.cfg,customCfg:r.customCfg,preferences:r.preferences})),e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...n,children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"py-4",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:r.title,onSave:o=>l({...r,title:o}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:r.title})})},r.title),e.jsxRuntimeExports.jsx(e.Editable,{text:r.description||"",onSave:o=>l({...r,description:o}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",r.description]})},r.description)]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col pb-3",children:[r.type!=="table"&&x&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:x},JSON.stringify(x)+JSON.stringify(r.preferences)+((u=r==null?void 0:r.preferences)==null?void 0:u.customVisualCode)),r.type==="table"&&r.data&&r.data.length>0&&e.jsxRuntimeExports.jsx(e.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:e.jsxRuntimeExports.jsx(e.TableVisual,{card:r,data:r==null?void 0:r.data})})]})]})}function ot(){const[s,n]=f.useState(!1),[t,r]=f.useState(""),[l,x]=f.useState(""),[u,o]=f.useState(""),[c,p]=f.useState(""),d=e.useEditorStore(R=>R.card),j=e.useEditorStore(R=>R.card.customCfg),{setCardCustomCfg:y,setCustomVisualCode:a}=e.useEditorActions();function m(R){var C,w;const A={...R,data:{...R==null?void 0:R.data,datasets:(w=(C=R==null?void 0:R.data)==null?void 0:C.datasets)==null?void 0:w.map(L=>({...L,data:[]}))}};return JSON.stringify(A,null,1)}function h(){var A,g;if(!d.data||d.data.length===0)return;const R=e.createChartConfig({data:d.data,cardType:d.type,cfg:d.cfg,preferences:d.preferences});R&&(r(JSON.stringify(R,null,1)),(A=d==null?void 0:d.preferences)!=null&&A.customVisualCode&&o((g=d==null?void 0:d.preferences)==null?void 0:g.customVisualCode),j&&x(JSON.stringify(j,null,1)))}function v(){if(u&&a(u),!!l)try{const R=JSON.parse(l);return R?(y(R),p(""),x(""),R):void 0}catch(R){console.log(R),p("Invalid JSON")}}function S(){x(""),y(null)}function z(){let R;if(j){const A=e._.cloneDeep(d.cfg),g=e._.merge(A,j);return R=m(g),R}return t?(R=m(JSON.parse(t)),R):""}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:h,className:` ${j&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.Settings,{className:"h-4 w-4"})})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{className:"",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(bs,{onClick:()=>{navigator.clipboard.writeText(d.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogDescription,{children:["See the configuration options and documentation",e.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(Ye,{className:"w-1/2 rounded shadow-none"}),e.jsxRuntimeExports.jsxs(e.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxRuntimeExports.jsxs(e.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsxRuntimeExports.jsxs(e.TabsTrigger,{value:"custom-config",children:[j&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),j?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:e.jsxRuntimeExports.jsx(e.Textarea,{disabled:!0,value:t,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:z(),onChange:R=>x(R)})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-code",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"javascript",value:u,onChange:R=>o(R||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:c}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!j,onClick:S,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:v,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function Xe(s){return ee({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)}function Ze(s){return ee({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)}function es(s){return ee({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)}function ss(s){return ee({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)}function ts(s){return ee({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z"},child:[]}]})(s)}function rs(s){return ee({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)}function ns(s){return ee({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)}function os(s){return ee({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M217 25v14h78V25h-78zm0 32v46h14V71h50v32h14V57h-78zm32 32v14h14V89h-14zm-64 32v46h30v-46h-30zm48 0v14h46v-14h-46zm64 0v46h30v-46h-30zm-64 32v14h46v-14h-46zm-80 32v46h62v-46h-62zm80 0v14h46v-14h-46zm64 0v46h62v-46h-62zm-64 32v14h46v-14h-46zm-112 32v46h94v-46h-94zm112 0v14h46v-14h-46zm64 0v46h94v-46h-94zm-64 32v14h46v-14h-46zM89 313v46h126v-46H89zm144 0v14h46v-14h-46zm64 0v46h126v-46H297zm-64 32v14h46v-14h-46zM57 377v46h158v-46H57zm176 0v14h46v-14h-46zm64 0v46h158v-46H297zm-64 32v14h46v-14h-46zM25 441v46h190v-46H25zm208 0v14h46v-14h-46zm64 0v46h190v-46H297zm-64 32v14h46v-14h-46z"},child:[]}]})(s)}function it(){const[s,n]=f.useState(!1),t=e.useEditorStore(c=>c.card.type),{setCardType:r,setCardPreferences:l,setChartOrientation:x}=e.useEditorStore(c=>c.actions),u=e.useEditorStore(c=>c.actions.setCardCustomCfg);function o(c){u(null),l({}),r(c),n(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(at,{className:"h-4 w-4",chartType:t})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-50",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(De,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Le,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(rs,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ts,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ge,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ss,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ke,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ze,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Xe,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(es,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(os,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Pe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ns,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Te,{className:"size-4"})})]})})]})}function at({chartType:s,className:n}){switch(s){case"bar":return e.jsxRuntimeExports.jsx(De,{className:n});case"line":return e.jsxRuntimeExports.jsx(Le,{className:n});case"pie":return e.jsxRuntimeExports.jsx(Ke,{className:n});case"radar":return e.jsxRuntimeExports.jsx(Xe,{className:n});case"scatter":return e.jsxRuntimeExports.jsx(Ge,{className:n});case"bubble":return e.jsxRuntimeExports.jsx(ss,{className:n});case"doughnut":return e.jsxRuntimeExports.jsx(Ze,{className:n});case"stackedBar":return e.jsxRuntimeExports.jsx(rs,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(ts,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(es,{className:n});case"pyramid":return e.jsxRuntimeExports.jsx(os,{className:n});case"range":return e.jsxRuntimeExports.jsx(Pe,{className:n});case"kpi":return e.jsxRuntimeExports.jsx(ns,{className:n});case"text":return e.jsxRuntimeExports.jsx(Te,{className:n});default:return e.jsxRuntimeExports.jsx(e.Table,{className:n})}}function lt(){const s=e.useEditorStore(t=>t.card.refreshInterval),n=e.useEditorStore(t=>t.actions.setCardRefreshInterval);return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(ds,{className:"w-4 h-4"})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px]",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-4",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),e.jsxRuntimeExports.jsx(e.Input,{value:s||"",onChange:t=>n(t.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}function Ve(){e.useEditorStore(o=>o.frame);const s=e.useEditorStore(o=>o.card),n=e.useEditorStore(o=>o.card.data),t=e.useEditorStore(o=>o.isShowingVisual),r=e.useEditorStore(o=>o.isSqlRunning),l=e.useEditorStore(o=>o.queryError),x=e.useEditorStore(o=>o.pythonStdOut);if(e.useEditorStore(o=>o.onSave),e.useEditorStore(o=>o.onClose),e.useEditorStore(o=>o.actions.setCardSql),e.useEditorStore(o=>o.actions.setCardType),e.useEditorStore(o=>o.actions.setSqlGen),!s)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function u(){return s.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:r,card:s})})}):s.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.TextCard,{isLoading:r,card:s})})}):e.jsxRuntimeExports.jsx(Ye,{className:"grow border-none shadow-none"})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col pt-3",children:[r&&e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),e.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[t&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(it,{}),s.type!=="table"&&e.jsxRuntimeExports.jsx(ot,{}),e.jsxRuntimeExports.jsx(lt,{})]}),e.jsxRuntimeExports.jsx(xt,{})]}),t?u():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[x&&e.jsxRuntimeExports.jsx(ct,{}),s.data&&s.data.length>0&&e.jsxRuntimeExports.jsx(nt,{data:n||[]}),l&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:l})]})]})}function ct(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const n=s.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function xt(){const s=e.useEditorStore(t=>t.isShowingVisual),n=e.useEditorStore(t=>t.actions.setIsShowingVisual);return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"visualize",children:"Chart"}),e.jsxRuntimeExports.jsx(e.Switch,{checked:s,onCheckedChange:()=>n(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function de(){const[s,n]=f.useState([]);e.useEditorStore(d=>d.card.cfg);const t=e.useEditorStore(d=>d.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:l,setCardPreferences:x}=e.useEditorStore(d=>d.actions),u=e.useEditorStore(d=>d.queryResultColumns);e.useEditorStore(d=>{var j;return(j=d.card.preferences)==null?void 0:j.filterOnClickColumnIndex}),f.useEffect(()=>{u&&n(new Array(u.length).fill(!1))},[u]);function o(d,j){var y,a;j?t!=null&&t.onClickFilter&&((y=t==null?void 0:t.onClickFilter)==null?void 0:y.length)>0?x({...t,onClickFilter:[...t.onClickFilter,{columnIndex:d,expression:""}]}):x({...t,onClickFilter:[{columnIndex:d,expression:""}]}):(x({...t,onClickFilter:(a=t==null?void 0:t.onClickFilter)==null?void 0:a.filter(m=>m.columnIndex!==d)}),n(m=>{const h=[...m];return h[d]=!1,h}))}function c(d,j){var a;const y=(a=t==null?void 0:t.onClickFilter)==null?void 0:a.map(m=>m.columnIndex===d?{...m,expression:j.target.value}:m);x({...t,onClickFilter:y})}function p(d){var j,y,a,m;if(s!=null&&s[d]||(y=(j=t==null?void 0:t.onClickFilter)==null?void 0:j.find(h=>h.columnIndex===d))!=null&&y.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(m=(a=t==null?void 0:t.onClickFilter)==null?void 0:a.find(h=>h.columnIndex===d))==null?void 0:m.expression,onChange:h=>c(d,h),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:u==null?void 0:u.map((d,j)=>{var y,a;return e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:e.jsxRuntimeExports.jsxs("div",{className:" grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((y=t==null?void 0:t.onClickFilter)!=null&&y.find(m=>m.columnIndex===j)),onCheckedChange:m=>o(j,m)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:d}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((a=t==null?void 0:t.onClickFilter)==null?void 0:a.find(m=>m.columnIndex===j))&&e.jsxRuntimeExports.jsx($e,{onClick:()=>{n(m=>{const h=[...m];return h[j]=!m[j],h})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),p(j)]})},d)})})}function Ce(){var u,o,c;const s=e.useEditorStore(p=>p.card.preferences),n=e.useEditorStore(p=>p.card.cfg),{setCardCfg:t,setCardPreferences:r,setChartOrientation:l}=e.useEditorStore(p=>p.actions);(u=n==null?void 0:n.options)!=null&&u.indexAxis;function x(p){l(p)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((o=s==null?void 0:s.chartOptions)==null?void 0:o.indexAxis)||((c=n==null?void 0:n.options)==null?void 0:c.indexAxis)||"x",onValueChange:x,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"x",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"y",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const xe="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function _e(s,n){var r,l,x;const t=e.getNumberAxis(s,n);return((x=(l=(r=s==null?void 0:s.chartOptions)==null?void 0:r.scales)==null?void 0:l[t])==null?void 0:x.type)||"linear"}function is(){var K,B,G,F,Q,b;const[s,n]=f.useState(!1),t=e.useEditorStore(E=>{var k;return(k=E.card)==null?void 0:k.preferences}),r=e.useEditorStore(E=>{var k;return(k=E.card)==null?void 0:k.cfg}),l=e.getNumberAxis(t,r),[x,u]=f.useState(_e(t)),[o,c]=f.useState(((G=(B=(K=t==null?void 0:t.chartOptions)==null?void 0:K.scales)==null?void 0:B[l])==null?void 0:G.min)||""),[p,d]=f.useState(((b=(Q=(F=t==null?void 0:t.chartOptions)==null?void 0:F.scales)==null?void 0:Q[l])==null?void 0:b.max)||""),[j,y]=f.useState(o||p?"custom":"auto"),[a,m]=f.useState(""),[h,v]=f.useState(0),[S,z]=f.useState(""),[R,A]=f.useState(""),[g,C]=f.useState(""),w=e.useEditorStore(E=>E.actions.setCardPreferences),L=e.useEditorStore(E=>{var k;return(k=E.card)==null?void 0:k.type}),N=["pie","doughnut","polarArea"].includes(L);f.useEffect(()=>{var E,k,T,se,$,I,V,P,ne,te,M,U,J,oe;u(_e(t)),c(((T=(k=(E=t==null?void 0:t.chartOptions)==null?void 0:E.scales)==null?void 0:k[l])==null?void 0:T.min)===0?0:""),d(((I=($=(se=t==null?void 0:t.chartOptions)==null?void 0:se.scales)==null?void 0:$[l])==null?void 0:I.max)||""),m(((te=(ne=(P=(V=t==null?void 0:t.chartOptions)==null?void 0:V.scales)==null?void 0:P[l])==null?void 0:ne.ticks)==null?void 0:te.stepSize)||""),v(((M=t==null?void 0:t.numberAxisFormat)==null?void 0:M.decimalPlaces)||0),z(((U=t==null?void 0:t.numberAxisFormat)==null?void 0:U.suffix)||""),A(((J=t==null?void 0:t.numberAxisFormat)==null?void 0:J.currency)||""),C(((oe=t==null?void 0:t.numberAxisFormat)==null?void 0:oe.locale)||"")},[s,t,l]);function O(E,k){return k===""||/^[0-9\b]+$/.test(k)?Number(k):Number(E)}function q(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsxRuntimeExports.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxRuntimeExports.jsx(e.Input,{value:R,placeholder:"USD",onChange:E=>A(E.target.value),id:"currency",className:`col-span-2 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:g,placeholder:"en-US",onChange:E=>C(E.target.value),id:"locale",className:`col-span-2 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsxRuntimeExports.jsx(e.Input,{value:h,onChange:E=>v(Number(E.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${xe}`})]})]})}function D(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"range",children:"Range"}),e.jsxRuntimeExports.jsx(e.Input,{id:"min",value:o,onChange:E=>c(k=>O(k,E.target.value)),className:`col-span-1 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:p,onChange:E=>d(k=>O(k,E.target.value)),id:"max",className:`col-span-1 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsxRuntimeExports.jsx(e.Input,{value:a,onChange:E=>m(k=>O(k,E.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${xe}`})]})]})}function H(){var T;let E={};j==="custom"&&(E={min:o,max:p,ticks:{stepSize:a}});const k={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(T=t==null?void 0:t.chartOptions)==null?void 0:T.scales,[l]:{type:x,...x==="linear"?E:{}}}},numberAxisFormat:{decimalPlaces:h,suffix:S,currency:R,locale:g}};console.log(k),w(k)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:E=>n(E),children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale",children:"Type"}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:N,value:x,onValueChange:E=>u(E),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{id:"type",children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Option"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"linear",children:"Linear"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),x=="linear"&&e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxRuntimeExports.jsxs(e.RadioGroup,{disabled:N,id:"scale-option",value:j,onValueChange:E=>y(E),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"auto",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"custom",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),j==="custom"&&x=="linear"&&D(),q(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:H,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function ut({idx:s}){var o;const n=e.useEditorStore(c=>{var p;return(p=c.card)==null?void 0:p.preferences}),t=e.useEditorStore(c=>{var p;return(p=c.card.preferences)==null?void 0:p.datasetOptions}),r=e.useEditorStore(c=>c.actions.setCardPreferences),l=(o=n==null?void 0:n.chartOptions)==null?void 0:o.indexAxis,x=t==null?void 0:t.find(c=>c.idx===s);function u(c,p){(c==="end"||c==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const d={display:c!=="none",align:c,anchor:c,clamp:!0};if(!x)r({...n,datasetOptions:[...t||[],{idx:p,datalabels:d}]});else{const j={...x};j.datalabels=d;const y=t==null?void 0:t.map(a=>a.idx===p?j:a);r({...n,datasetOptions:y})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(Ls,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-fit p-1",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("none",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(e.X,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(Ss,{className:e.cn("h-4 w-4",{"rotate-90":l==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(vs,{className:e.cn("h-4 w-4",{"rotate-90":l==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(ys,{className:e.cn("h-4 w-4",{"rotate-90":l==="y"})})})]})})]})}function as(){const s=e.useEditorStore(c=>c.card),n=e.useEditorStore(c=>{var p,d,j;return(j=(d=(p=c==null?void 0:c.card)==null?void 0:p.preferences)==null?void 0:d.chartOptions)==null?void 0:j.indexAxis}),t=n==="y"?"Y axis":"X axis",r=n==="y"?"X axis":"Y axis",{keys:l,metricKeys:x,dimensionKeys:u}=e.getKeys(s.data||[]);let o=x;if(["stackedBar","stackedLine"].includes(s.type)){const c=e.pivotData({dataArray:s.data||[],groupKey:u[0],pivotKey:u[1],valueKey:o[0]}),{metricKeys:p}=e.getKeys(c);o=p}return l.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:t}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:e.jsxRuntimeExports.jsx("p",{children:u[0]})})})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxRuntimeExports.jsx(e.Label,{children:r}),e.jsxRuntimeExports.jsx(is,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:o.map((c,p)=>e.jsxRuntimeExports.jsx(dt,{col:c,idx:p},c))})]})]})}function dt({col:s,idx:n}){const t=e.useEditorStore(o=>{var c;return(c=o.card)==null?void 0:c.preferences}),r=e.useEditorStore(o=>{var c;return(c=o.card.preferences)==null?void 0:c.datasetOptions}),l=r==null?void 0:r.find(o=>o.idx===n),{setCardPreferences:x}=e.useEditorStore(o=>o.actions);function u(o){if(!l)x({...t,datasetOptions:[...r||[],{idx:n,type:o==="area"?"line":o,fill:o==="area"?"origin":""}]});else{const c={...l};c.type=o==="area"?"line":o,c.fill=o==="area"?"origin":"";const p=r==null?void 0:r.map(d=>d.idx===n?c:d);x({...t,datasetOptions:p})}}return e.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[e.jsxRuntimeExports.jsx("p",{children:s}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(De,{onClick:()=>u("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Le,{onClick:()=>u("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ms,{onClick:()=>u("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(e.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ut,{idx:n})]})]})}function mt({cardType:s}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Ce,{}),e.jsxRuntimeExports.jsx(as,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}function Fe(){var l,x,u;const s=e.useEditorStore(o=>o.card.cfg),n=e.useEditorStore(o=>o.actions.setCardCfg),t=e.useEditorStore(o=>o.card.type);function r(o){var d;const c={datalabels:{display:o!=="none",align:o,anchor:o,clamp:!0}},p={...s,options:{...s==null?void 0:s.options,plugins:{...(d=s==null?void 0:s.options)==null?void 0:d.plugins,...c}}};n(p),console.log(o)}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid"].includes(t)&&e.jsxRuntimeExports.jsx(is,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(u=(x=(l=s==null?void 0:s.options)==null?void 0:l.plugins)==null?void 0:x.datalabels)==null?void 0:u.anchor,onValueChange:r,defaultValue:"none",children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:"Select position"})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Data Labels"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function pt({cardType:s}){function n(t){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",l="SELECT label, [group], x-axis, y-axis FROM table";return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:t==="bubble"?r:l}),e.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),t==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:x=>x.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return e.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(s)})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(Fe,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}const ht={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},jt={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Et(){const s=e.useEditorStore(n=>n.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:ft(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(Ce,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(Fe,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(de,{})})]})}function ft(s){if(["line","bar"].includes(s))return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(ht,null,2)})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsxRuntimeExports.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(jt,null,2)})]})]})]});if(s==="bubble")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(s==="scatter")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(s))return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:[e.jsxRuntimeExports.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function gt(){var c,p,d,j,y;const s=e.useEditorStore(a=>a.card.preferences),n=e.useEditorStore(a=>a.actions.setCardPreferences),t=e.useEditorStore(a=>a.actions.setNumberFormat);e.useEditorStore(a=>{var m,h;return(h=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.decimalPlaces});const r=e.useEditorStore(a=>{var m,h;return(h=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.locale}),l=e.useEditorStore(a=>{var m,h;return(h=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.currency});e.useEditorStore(a=>a.actions.setFilterOnClickField);const x=e.useEditorStore(a=>{var m,h;return(h=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.colorRanges})||[],u=e.useEditorStore(a=>a.actions.setColorRanges),o=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(a=>a.currency))];return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((c=s==null?void 0:s.formatNumber)!=null&&c.enabled),onCheckedChange:a=>{n({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:a}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((p=s==null?void 0:s.formatNumber)==null?void 0:p.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Locale"}),e.jsxRuntimeExports.jsxs(e.Select,{value:r||"en-US",onValueChange:a=>{var m,h,v;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",a||"en-US",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Format"}),e.LOCALE_CURRENCY_PAIRS.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.locale,children:a.locale},a.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Currency"}),e.jsxRuntimeExports.jsxs(e.Select,{value:l||"none",onValueChange:a=>{var m,h,v;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,a==="none"?"":a,((h=s==null?void 0:s.formatNumber)==null?void 0:h.locale)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),o.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a,children:a},a))]})})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Decimals"}),e.jsxRuntimeExports.jsxs(e.Select,{value:((j=(d=s==null?void 0:s.formatNumber)==null?void 0:d.decimalPlaces)==null?void 0:j.toString())||"0",onValueChange:a=>{var m,h,v;return t(Number(a),((m=s==null?void 0:s.formatNumber)==null?void 0:m.currency)||"",((h=s==null?void 0:s.formatNumber)==null?void 0:h.locale)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:["0","1","2","3","4"].map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a,children:a},a))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((y=s==null?void 0:s.formatNumber)==null?void 0:y.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:a=>{var m,h,v;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.locale)||"",a.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:x,setColorRanges:u})]})]})}function Rt(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{type:"single",collapsible:!0,children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"font-mono",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"current - number"}),e.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),e.jsxRuntimeExports.jsx("section",{className:"",children:e.jsxRuntimeExports.jsx(gt,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function bt(){var r;const s=e.useEditorStore(l=>l.card.preferences),{setCardPreferences:n}=e.useEditorStore(l=>l.actions);function t(l){n({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:l==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(r=s==null?void 0:s.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:t,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"static",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function be({cardType:s,docContent:n,suffix:t="Chart"}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} ${t}`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:n||e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[s==="range"&&e.jsxRuntimeExports.jsx(Ce,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Fe,{}),s==="text"&&e.jsxRuntimeExports.jsx(bt,{})]})]}),!["range","text"].includes(s)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}function St(){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Stacked Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Ce,{}),e.jsxRuntimeExports.jsx(as,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}function yt({}){const s=e.useEditorStore(r=>{var l;return(l=r.card)==null?void 0:l.preferences}),n=e.useEditorStore(r=>r.actions.setCardPreferences),t=r=>{n({...s,allowDownload:r})};return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:t,id:"allow-download"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const vt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),Ct=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]}),Nt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#text-visual",children:"example"})," in the docs."]})]});function kt(){const s=e.useEditorStore(t=>t.card.type);function n(t){switch(t){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(St,{});case"pyramid":return e.jsxRuntimeExports.jsx(be,{docContent:vt,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(Rt,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(mt,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(be,{docContent:Ct,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(be,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(pt,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(yt,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(be,{docContent:Nt,cardType:t,suffix:"Visual"});default:return e.jsxRuntimeExports.jsx(Et,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:n(s)})}function wt(){const s=e.useEditorStore(n=>n.isShowingVisual);return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(rt,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:s?e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx(kt,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(Ve,{})})]}):e.jsxRuntimeExports.jsx(Ve,{})})]})}function At({authToken:s,onSave:n,onClose:t}){const r=e.useEditorStore(u=>u.actions.setOnSave),l=e.useEditorStore(u=>u.actions.setOnClose),x=e.useDashboardStore(u=>u.actions.setAuthToken);return f.useEffect(()=>{n&&r(n),t&&l(t)},[n,r,t,l]),f.useEffect(()=>{s&&s.accessToken&&x(s)},[s,x]),e.jsxRuntimeExports.jsxs(e.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(Ue,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(wt,{})})]})}function It(){e.useDashboardStore(u=>u.selectedCardId);const s=e.useDashboardStore(u=>u.selectedSheetId),{setIsVisualEditing:n}=e.useDashboardStore(u=>u.actions),t=e.useDashboardStore(u=>u.isVisualEditing),r=e.useDashboardStore(u=>u.actions.updateFrame);function l(u){s&&(r(s,u),n(!1))}function x(){n(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:t,hidden:!t}),children:e.jsxRuntimeExports.jsx(At,{onSave:l,onClose:x})})}function zt({columns:s,tableName:n}){const t=e.useEditorStore(a=>a.selectedConnectionId),r=e.useEditorStore(a=>a.selectedDatamodelId),l=e.useEditorStore(a=>a.selectedDatabaseName),x=e.useEditorStore(a=>a.selectedSchemaName),u=e.useEditorStore(a=>a.selectedTableName),o=e.useDashboardStore(a=>a.dashboard.filters)||[],c=e.useDashboardStore(a=>a.actions.addFilter),p=e.useDashboardStore(a=>a.actions.removeFilter),d=e.useDashboardStore(a=>a.actions.removeFilterValue),{modelItems:j}=ve();function y(a){var C;const m=e.fmt(a.column_name),h=e.fmt(l||""),v=e.fmt(x||""),S=e.fmt(n);let z=e.getQualifiedTableName(v,S),R=`${z}.${m}`;const A=(C=j==null?void 0:j.find(w=>w.id===r))==null?void 0:C.name;r&&r!=="none"&&(R=`d.${A}.${m}`,z=`d.${A}`),console.log("find",R,S,h);const g=o==null?void 0:o.find(w=>w.column===R&&w.table===S&&(w.database===h||w.database===l));if(g)d(g.id),p(g.id);else{if(n==="api"&&t){c({id:e.v4(),column:R,title:a.column_name,dataType:a.data_type,table:"api",database:"",connectionId:t,operation:"in",sql:e.getDefaultFilterSql(a.data_type,z,m)});return}c({id:e.v4(),column:R,title:a.column_name,dataType:a.data_type,table:u||"",database:l||"",connectionId:t||"",operation:"in",sql:e.getDefaultFilterSql(a.data_type,z,m)})}}return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:s==null?void 0:s.map(a=>{const m=o==null?void 0:o.find(h=>h.column===e.fmt(a.column_name)&&h.table===u&&h.database===l);return e.jsxRuntimeExports.jsx("div",{onClick:()=>y(a),className:e.cn("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",{"bg-muted":m}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(Qe,{column:a}),e.jsxRuntimeExports.jsx("span",{children:a.column_name})]})},a.column_name)})})}function Dt(){e.useDashboardStore(n=>n.showFilters);const s=e.useDashboardStore(n=>n.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-lg",children:"Filters"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{})})]}),e.jsxRuntimeExports.jsx("div",{className:"flex grow",children:e.jsxRuntimeExports.jsx(Ue,{ColumnsComponent:(n,t,r)=>e.jsxRuntimeExports.jsx(zt,{schemaName:n,tableName:t,columns:r})})})]})}function Lt(){e.useDashboardStore(t=>t.dashboard);const s=e.useDashboardStore(t=>t.showFilters),n=e.useDashboardStore(t=>t.isVisualEditing);return e.useDashboardStore(t=>t.bookmarkKey),e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:n,flex:!n}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Dt,{})})]})}function Tt(){const s=e.useDashboardStore(r=>r.dashboard),n=e.useDashboardStore(r=>r.actions.setDashboard),t=e.useDashboardStore(r=>r.showDashboardJSON);return e.useDashboardStore(r=>r.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!t}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:r=>{if(r)try{JSON.parse(r),n(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(s,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function Ft({showControls:s=!1,showFooter:n=!0,...t}){return e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(Tt,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Bs,{}),e.jsxRuntimeExports.jsx(It,{}),e.jsxRuntimeExports.jsx(Lt,{})]})]})]})}exports.DashboardPlus=Ft;exports.SelectComponent=ue;exports.useEditorAside=ve;
207
+ `;function Jt({open:t,setOpen:r,userInput:s,setUserInput:n,triggerAIRun:l,setTriggerAIRun:x}){const u=R.useRef(null),o=R.useRef(null),{authToken:c}=e.useSemaphorContext(),[p,m]=R.useState(!1),j=e.useEditorStore(y=>y.actions.setCardSql),E=e.useDashboardStore(y=>y.dashboard.baseQueries),a=e.useEditorStore(y=>y.actions.setRunSql),d=e.useEditorStore(y=>y.actions.setCardType),[h,C]=R.useState([]),S=e.useEditorStore(y=>y.currentColumns),I=e.useEditorStore(y=>y.card.sql),f=e.useEditorStore(y=>y.selectedTableName),D=`
208
+ ${s}
209
+
210
+ Database Query Dialect: ${f==="api"||f==="s3"?"DuckDb":""}
211
+ Table Name: ${f}
212
+ Table Columns: ${S==null?void 0:S.map(y=>`${y.column_name} | ${y.data_type}`).join(", ")}
213
+ User SQL: ${I}
214
+ ${E&&`Base Queries: ${JSON.stringify(E)} `}`,z=` 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.
215
+ Visual Query Syntax: ${Qt}`,{data:L,isLoading:w,isFetching:b,isError:v,refetch:T}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(c==null?void 0:c.accessToken)||"",{user_content:`userContent: ${D} ${p?z:""}`}),enabled:!1});function M(y){if(y.toLowerCase().includes("bar"))d("bar");else if(y.toLowerCase().includes("line"))d("line");else if(y.toLowerCase().includes("bubble"))d("bubble");else if(y.toLowerCase().includes("scatter"))d("scatter");else if(y.toLowerCase().includes("stacked"))d("stackedBar");else if(y.toLowerCase().includes("pie"))d("pie");else if(y.toLowerCase().includes("donut")||y.toLowerCase().includes("doughnut"))d("doughnut");else if(y.toLowerCase().includes("radar"))d("radar");else return d("bar"),!1;return!0}R.useEffect(()=>{L&&C(y=>[...y,{role:"ai",content:L.response}])},[L]),R.useEffect(()=>{const y=setTimeout(()=>{var g;o.current&&(o.current.scroll({top:o.current.scrollHeight,behavior:"smooth"}),(g=u.current)==null||g.focus())},100);return()=>clearTimeout(y)},[h]);function k(){s&&(C(y=>[...y,{role:"user",content:s}]),M(s)&&m(!0),n(""),T())}R.useEffect(()=>{l&&(k(),x(!1))},[l,x]);const F={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},_={fontFamily:"monospace",fontSize:14,lineHeight:1.6},q={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},G={p:({node:y,...g})=>e.jsxRuntimeExports.jsx("p",{style:F,...g}),code:({node:y,...g})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...g}),pre:({node:y,...g})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:_,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:g.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:B,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:N=>{const O=B(N);O&&(r(!1),j(O),a(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:y,...g})=>e.jsxRuntimeExports.jsx("li",{style:q,...g})};function B(y){const g=y.currentTarget.closest("pre");if(!g)return;const N=g.textContent||g.innerText;return navigator.clipboard.writeText(N).then(()=>console.log("Text copied to clipboard")).catch(O=>console.error("Error in copying text: ",O)),N}function Q(){return h==null?void 0:h.map((y,g)=>y.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Ft,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:y.content})]},g):y.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:G,children:L==null?void 0:L.response.replace(/DuckDB/gi,"Semaphor")},g):e.jsxRuntimeExports.jsx("div",{},g))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:t,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"What can I help you with?"})]}),e.jsxRuntimeExports.jsx("div",{ref:o,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:Q()})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Textarea,{autoFocus:!0,ref:u,onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),n(""),k())},placeholder:"Type your question here...",onFocus:y=>{const g=y.target,N=g.value.length;g.setSelectionRange(N,N)},className:e.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:w||b,value:s,onChange:y=>n(y.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:k,children:!w&&!b?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Ue={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Be=R.createContext&&R.createContext(Ue),Ut=["attr","size","title"];function Wt(t,r){if(t==null)return{};var s=Yt(t,r),n,l;if(Object.getOwnPropertySymbols){var x=Object.getOwnPropertySymbols(t);for(l=0;l<x.length;l++)n=x[l],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(s[n]=t[n])}return s}function Yt(t,r){if(t==null)return{};var s={},n=Object.keys(t),l,x;for(x=0;x<n.length;x++)l=n[x],!(r.indexOf(l)>=0)&&(s[l]=t[l]);return s}function ye(){return ye=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=s[n])}return t},ye.apply(this,arguments)}function qe(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,n)}return s}function ve(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?qe(Object(s),!0).forEach(function(n){Zt(t,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):qe(Object(s)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(s,n))})}return t}function Zt(t,r,s){return r=Xt(r),r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function Xt(t){var r=es(t,"string");return typeof r=="symbol"?r:String(r)}function es(t,r){if(typeof t!="object"||t===null)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var n=s.call(t,r||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function We(t){return t&&t.map((r,s)=>R.createElement(r.tag,ve({key:s},r.attr),We(r.child)))}function ee(t){return r=>R.createElement(ts,ye({attr:ve({},t.attr)},r),We(t.child))}function ts(t){var r=s=>{var{attr:n,size:l,title:x}=t,u=Wt(t,Ut),o=l||s.size||"1em",c;return s.className&&(c=s.className),t.className&&(c=(c?c+" ":"")+t.className),R.createElement("svg",ye({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},s.attr,n,u,{className:c,style:ve(ve({color:t.color||s.color},s.style),t.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),x&&R.createElement("title",null,x),t.children)};return Be!==void 0?R.createElement(Be.Consumer,null,s=>r(s)):r(Ue)}function ss(t){return ee({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:[]}]})(t)}function ns(){const{theme:t}=e.useTheme(),r=R.useRef(),s=R.useRef(),[n,l]=R.useState(!1),[x,u]=R.useState(!1),[o,c]=R.useState(!1),[p,m]=R.useState(""),[j,E]=R.useState(!1),{authToken:a}=e.useSemaphorContext();e.useDashboardStore(i=>i.selectedSheetId);const d=e.useDashboardStore(i=>i.dashboard.baseQueries),h=e.useEditorStore(i=>i.card),C=e.useDashboardStore(i=>i.theme),S=e.useEditorStore(i=>i.isShowingVisual),I=e.useEditorStore(i=>i.selectedConnectionId),f=e.useEditorStore(i=>i.selectedDatabaseName),D=e.useEditorStore(i=>i.selectedDatamodelId),z=e.useEditorStore(i=>i.selectedSchemaName);e.useDashboardStore(i=>i.actions.updateFrameCard);const L=e.useEditorStore(i=>i.selectedTableName),w=e.useEditorStore(i=>i.card.sql),b=e.useEditorStore(i=>i.card.python),v=e.resolveBaseQuery(w,d),T=e.useEditorStore(i=>i.selectedConnectionId),M=e.useEditorStore(i=>i.frame),k=e.useEditorStore(i=>i.filterValues),F=e.useEditorStore(i=>i.applyFilters),{setCardCustomCfg:_,setQueryResultColumns:q,setFilterValues:G,setCardSql:B,setCardPython:Q,setQueryError:y,setPythonStdOut:g,setCardPreferences:N}=e.useEditorStore(i=>i.actions),O=e.useEditorStore(i=>i.onSave),te=e.useEditorStore(i=>i.actions.setApplyFilters),K=e.useEditorStore(i=>i.onClose),A=e.useEditorStore(i=>i.actions.setCardData),H=e.useEditorStore(i=>i.actions.setSqlGen),$=e.useEditorStore(i=>i.runSql),re=e.useEditorStore(i=>i.actions.setRunSql),se=e.useEditorStore(i=>i.actions.setIsSqlRunning),{data:V,isLoading:J,isFetching:U,isSuccess:oe,isError:ae,error:me,status:Oe,refetch:le}=e.useQuery({queryKey:[v,b],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(a==null?void 0:a.accessToken)||"",{connection_id:T,sql:v,python:b===e.PYTHON_DEFAULT_CODE?"":b,active_filters:F?k:[]}),enabled:!1,retry:!1});R.useEffect(()=>{if(V&&(A(V.records),V.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),g((V==null?void 0:V.output)||""),V.records.length>0)){const{dimensionKeys:i}=e.getKeys(V.records);q(i)}},[V,A,q,g]),R.useEffect(()=>{$&&(le(),re(!1))},[$,le,re]),R.useEffect(()=>{(J||U)&&se(!0),(ae||oe)&&se(!1),ae?(y(me.message),A([]),q([]),g("")):y("")},[J,U,V,g,ae,oe,se,A,q,y,me]);function Ne(){B(""),A([]),H({}),_(""),N({})}const Ee=i=>{s.current=i};function ke(){let i=w;w&&!w.includes("{{")&&(i=Ht(w),B(i));const W={...h,lastSelectedSchema:z,lastSelectedDatamodelId:D,lastSelectedDatabase:f,lastSelectedTable:L,connectionId:I,type:S?h.type:"table",sql:i,customCfg:S?h.customCfg:null},he=M.cards.map(ie=>ie.id===h.id?W:ie);O==null||O({...M,cards:he})}function we(){K==null||K()}function fe(i){const W=getComputedStyle(document.documentElement).getPropertyValue(i);return ge(W)}function ge(i){const[W,he,ie]=i.split(" "),P=parseFloat(W),lt=parseFloat(he),ct=parseFloat(ie),xt=lt/100,Me=ct/100,ne=(1-Math.abs(2*Me-1))*xt,ce=ne*(1-Math.abs(P/60%2-1)),Ie=Me-ne/2;let Y=0,Z=0,X=0;0<=P&&P<60?(Y=ne,Z=ce,X=0):60<=P&&P<120?(Y=ce,Z=ne,X=0):120<=P&&P<180?(Y=0,Z=ne,X=ce):180<=P&&P<240?(Y=0,Z=ce,X=ne):240<=P&&P<300?(Y=ce,Z=0,X=ne):300<=P&&P<360&&(Y=ne,Z=0,X=ce),Y=Math.round((Y+Ie)*255),Z=Math.round((Z+Ie)*255),X=Math.round((X+Ie)*255);const De=ut=>{const ze=ut.toString(16);return ze.length==1?"0"+ze:ze};return`#${De(Y)}${De(Z)}${De(X)}`}R.useEffect(()=>{const i=r.current,W=s.current;if(i){const he=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",ie=C==="system"?he:C;i.editor.defineTheme("default",{base:ie==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":ie==="light"?"#ffffff":fe("--semaphor-background")}}),i.editor.setTheme("default")}return W&&i&&W.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return console.log("Executing query..."),le(),!1}),()=>{}},[t,C,r.current]);function pe(i){r.current=i}function Re(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[x&&e.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:e.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[e.jsxRuntimeExports.jsx($t,{checked:F,onCheckedChange:()=>te(!F),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Gt,{}),k&&x&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>u(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:i=>{if(i)try{JSON.parse(i),G(JSON.parse(i))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(k,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),k&&!x&&e.jsxRuntimeExports.jsx(He,{onClick:()=>u(!0),className:e.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":F})})]})}function be(){return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"1",order:1,defaultSize:n?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:i=>{B(i)},value:w,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:pe,onMount:Ee})}),n&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),n&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:i=>{Q(i&&i.trim()||"")},value:b||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:pe,onMount:Ee})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return e.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[be(),Re()]}),e.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{title:"Shift + Enter",disabled:J||U,onClick:()=>{le()},className:"shrink-0",size:"sm",variant:"outline",children:[J||U?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(kt,{className:"mr-2 h-4 w-4"}),"Run"]}),ae&&e.jsxRuntimeExports.jsx(Pt,{error:me.message,setShowAIDialog:c,setTriggerAIRun:E,setUserInputforAI:m}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ne,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Et,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:n,onPressedChange:i=>l(i),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(ss,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Jt,{open:o,setOpen:c,userInput:p,triggerAIRun:j,setTriggerAIRun:E,setUserInput:i=>m(i)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:ke,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:we,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function rs({data:t}){var u;const[r,s]=R.useState([]),l=Object.keys(t[0]).map(o=>({accessorKey:o,header:({column:c})=>{const p=c.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>c.toggleSorting(c.getIsSorted()==="asc"),children:[o,p==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):p==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),x=e.useReactTable({data:t,columns:l,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:s,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:r}});return e.jsxRuntimeExports.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:x.getHeaderGroups().map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{children:o.headers.map(c=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:c.isPlaceholder?null:e.flexRender(c.column.columnDef.header,c.getContext())},c.id))},o.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(u=x.getRowModel().rows)!=null&&u.length?x.getRowModel().rows.map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":o.getIsSelected()&&"selected",children:o.getVisibleCells().map(c=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(c.column.columnDef.cell,c.getContext())},c.id))},o.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:l.length,className:"h-24 text-center",children:"No results."})})})]})}function Ye({className:t,...r}){var u;R.useState(0);const s=e.useDashboardStore(o=>o.themeStyle),n=e.useEditorStore(o=>o.card),l=e.useEditorStore(o=>o.actions.setCard);if(R.useEffect(()=>{},[n.data,n.type,n.cfg,n.customCfg,s,n.preferences]),!n.id)return null;let x;return n.data&&n.data.length>0&&(x=e.createChartConfig({data:n.data,cardType:n.type,cfg:n.cfg,customCfg:n.customCfg,preferences:n.preferences})),e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",t),...r,children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"py-4",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:n.title,onSave:o=>l({...n,title:o}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:n.title})})},n.title),e.jsxRuntimeExports.jsx(e.Editable,{text:n.description||"",onSave:o=>l({...n,description:o}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",n.description]})},n.description)]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col pb-3",children:[n.type!=="table"&&x&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:x},JSON.stringify(x)+JSON.stringify(n.preferences)+((u=n==null?void 0:n.preferences)==null?void 0:u.customVisualCode)),n.type==="table"&&n.data&&n.data.length>0&&e.jsxRuntimeExports.jsx(e.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:e.jsxRuntimeExports.jsx(e.TableVisual,{card:n,data:n==null?void 0:n.data})})]})]})}function os(){const[t,r]=R.useState(!1),[s,n]=R.useState(""),[l,x]=R.useState(""),[u,o]=R.useState(""),[c,p]=R.useState(""),m=e.useEditorStore(f=>f.card),j=e.useEditorStore(f=>f.card.customCfg),{setCardCustomCfg:E,setCustomVisualCode:a}=e.useEditorActions();function d(f){var L,w;const D={...f,data:{...f==null?void 0:f.data,datasets:(w=(L=f==null?void 0:f.data)==null?void 0:L.datasets)==null?void 0:w.map(b=>({...b,data:[]}))}};return JSON.stringify(D,null,1)}function h(){var D,z;if(!m.data||m.data.length===0)return;const f=e.createChartConfig({data:m.data,cardType:m.type,cfg:m.cfg,preferences:m.preferences});f&&(n(JSON.stringify(f,null,1)),(D=m==null?void 0:m.preferences)!=null&&D.customVisualCode&&o((z=m==null?void 0:m.preferences)==null?void 0:z.customVisualCode),j&&x(JSON.stringify(j,null,1)))}function C(){if(u&&a(u),!!l)try{const f=JSON.parse(l);return f?(E(f),p(""),x(""),f):void 0}catch(f){console.log(f),p("Invalid JSON")}}function S(){x(""),E(null)}function I(){let f;if(j){const D=e._.cloneDeep(m.cfg),z=e._.merge(D,j);return f=d(z),f}return s?(f=d(JSON.parse(s)),f):""}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:t,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:h,className:` ${j&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.Settings,{className:"h-4 w-4"})})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{className:"",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(bt,{onClick:()=>{navigator.clipboard.writeText(m.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogDescription,{children:["See the configuration options and documentation",e.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(Ye,{className:"w-1/2 rounded shadow-none"}),e.jsxRuntimeExports.jsxs(e.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxRuntimeExports.jsxs(e.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsxRuntimeExports.jsxs(e.TabsTrigger,{value:"custom-config",children:[j&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),j?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:e.jsxRuntimeExports.jsx(e.Textarea,{disabled:!0,value:s,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:I(),onChange:f=>x(f)})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-code",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"javascript",value:u,onChange:f=>o(f||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:c}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!j,onClick:S,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:C,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>r(!1),variant:"outline",children:"Close"})]})]})]})}function Ze(t){return ee({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:[]}]})(t)}function Xe(t){return ee({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:[]}]})(t)}function et(t){return ee({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:[]}]})(t)}function tt(t){return ee({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:[]}]})(t)}function st(t){return ee({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z"},child:[]}]})(t)}function nt(t){return ee({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:[]}]})(t)}function rt(t){return ee({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:[]}]})(t)}function ot(t){return ee({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M217 25v14h78V25h-78zm0 32v46h14V71h50v32h14V57h-78zm32 32v14h14V89h-14zm-64 32v46h30v-46h-30zm48 0v14h46v-14h-46zm64 0v46h30v-46h-30zm-64 32v14h46v-14h-46zm-80 32v46h62v-46h-62zm80 0v14h46v-14h-46zm64 0v46h62v-46h-62zm-64 32v14h46v-14h-46zm-112 32v46h94v-46h-94zm112 0v14h46v-14h-46zm64 0v46h94v-46h-94zm-64 32v14h46v-14h-46zM89 313v46h126v-46H89zm144 0v14h46v-14h-46zm64 0v46h126v-46H297zm-64 32v14h46v-14h-46zM57 377v46h158v-46H57zm176 0v14h46v-14h-46zm64 0v46h158v-46H297zm-64 32v14h46v-14h-46zM25 441v46h190v-46H25zm208 0v14h46v-14h-46zm64 0v46h190v-46H297zm-64 32v14h46v-14h-46z"},child:[]}]})(t)}function is(){const[t,r]=R.useState(!1),s=e.useEditorStore(c=>c.card.type),{setCardType:n,setCardPreferences:l,setChartOrientation:x}=e.useEditorStore(c=>c.actions),u=e.useEditorStore(c=>c.actions.setCardCustomCfg);function o(c){u(null),l({}),n(c),r(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:t,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(as,{className:"h-4 w-4",chartType:s})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-50",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(Ae,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Le,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(nt,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(st,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ge,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(tt,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ke,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Xe,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ze,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(et,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ot,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Pe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(rt,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Te,{className:"size-4"})})]})})]})}function as({chartType:t,className:r}){switch(t){case"bar":return e.jsxRuntimeExports.jsx(Ae,{className:r});case"line":return e.jsxRuntimeExports.jsx(Le,{className:r});case"pie":return e.jsxRuntimeExports.jsx(Ke,{className:r});case"radar":return e.jsxRuntimeExports.jsx(Ze,{className:r});case"scatter":return e.jsxRuntimeExports.jsx(Ge,{className:r});case"bubble":return e.jsxRuntimeExports.jsx(tt,{className:r});case"doughnut":return e.jsxRuntimeExports.jsx(Xe,{className:r});case"stackedBar":return e.jsxRuntimeExports.jsx(nt,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(st,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(et,{className:r});case"pyramid":return e.jsxRuntimeExports.jsx(ot,{className:r});case"range":return e.jsxRuntimeExports.jsx(Pe,{className:r});case"kpi":return e.jsxRuntimeExports.jsx(rt,{className:r});case"text":return e.jsxRuntimeExports.jsx(Te,{className:r});default:return e.jsxRuntimeExports.jsx(e.Table,{className:r})}}function ls(){const t=e.useEditorStore(s=>s.card.refreshInterval),r=e.useEditorStore(s=>s.actions.setCardRefreshInterval);return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(dt,{className:"w-4 h-4"})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px]",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-4",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),e.jsxRuntimeExports.jsx(e.Input,{value:t||"",onChange:s=>r(s.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}function Ve(){e.useEditorStore(o=>o.frame);const t=e.useEditorStore(o=>o.card),r=e.useEditorStore(o=>o.card.data),s=e.useEditorStore(o=>o.isShowingVisual),n=e.useEditorStore(o=>o.isSqlRunning),l=e.useEditorStore(o=>o.queryError),x=e.useEditorStore(o=>o.pythonStdOut);if(e.useEditorStore(o=>o.onSave),e.useEditorStore(o=>o.onClose),e.useEditorStore(o=>o.actions.setCardSql),e.useEditorStore(o=>o.actions.setCardType),e.useEditorStore(o=>o.actions.setSqlGen),!t)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function u(){return t.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:n,card:t})})}):t.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.TextCard,{isLoading:n,card:t})})}):e.jsxRuntimeExports.jsx(Ye,{className:"grow border-none shadow-none"})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col pt-3",children:[n&&e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),e.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[s&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(is,{}),t.type!=="table"&&e.jsxRuntimeExports.jsx(os,{}),e.jsxRuntimeExports.jsx(ls,{})]}),e.jsxRuntimeExports.jsx(xs,{})]}),s?u():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[x&&e.jsxRuntimeExports.jsx(cs,{}),t.data&&t.data.length>0&&e.jsxRuntimeExports.jsx(rs,{data:r||[]}),l&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:l})]})]})}function cs(){const t=e.useEditorStore(s=>s.pythonStdOut);if(!t)return null;const r=t.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:r},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function xs(){const t=e.useEditorStore(s=>s.isShowingVisual),r=e.useEditorStore(s=>s.actions.setIsShowingVisual);return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"visualize",children:"Chart"}),e.jsxRuntimeExports.jsx(e.Switch,{checked:t,onCheckedChange:()=>r(!t),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function de(){const[t,r]=R.useState([]);e.useEditorStore(m=>m.card.cfg);const s=e.useEditorStore(m=>m.card.preferences),{setCardCfg:n,setFilterOnClickColumnIndex:l,setCardPreferences:x}=e.useEditorStore(m=>m.actions),u=e.useEditorStore(m=>m.queryResultColumns);e.useEditorStore(m=>{var j;return(j=m.card.preferences)==null?void 0:j.filterOnClickColumnIndex}),R.useEffect(()=>{u&&r(new Array(u.length).fill(!1))},[u]);function o(m,j){var E,a;j?s!=null&&s.onClickFilter&&((E=s==null?void 0:s.onClickFilter)==null?void 0:E.length)>0?x({...s,onClickFilter:[...s.onClickFilter,{columnIndex:m,expression:""}]}):x({...s,onClickFilter:[{columnIndex:m,expression:""}]}):(x({...s,onClickFilter:(a=s==null?void 0:s.onClickFilter)==null?void 0:a.filter(d=>d.columnIndex!==m)}),r(d=>{const h=[...d];return h[m]=!1,h}))}function c(m,j){var a;const E=(a=s==null?void 0:s.onClickFilter)==null?void 0:a.map(d=>d.columnIndex===m?{...d,expression:j.target.value}:d);x({...s,onClickFilter:E})}function p(m){var j,E,a,d;if(t!=null&&t[m]||(E=(j=s==null?void 0:s.onClickFilter)==null?void 0:j.find(h=>h.columnIndex===m))!=null&&E.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(d=(a=s==null?void 0:s.onClickFilter)==null?void 0:a.find(h=>h.columnIndex===m))==null?void 0:d.expression,onChange:h=>c(m,h),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:u==null?void 0:u.map((m,j)=>{var E,a;return e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:e.jsxRuntimeExports.jsxs("div",{className:" grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((E=s==null?void 0:s.onClickFilter)!=null&&E.find(d=>d.columnIndex===j)),onCheckedChange:d=>o(j,d)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:m}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((a=s==null?void 0:s.onClickFilter)==null?void 0:a.find(d=>d.columnIndex===j))&&e.jsxRuntimeExports.jsx($e,{onClick:()=>{r(d=>{const h=[...d];return h[j]=!d[j],h})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),p(j)]})},m)})})}function Ce(){var u,o,c;const t=e.useEditorStore(p=>p.card.preferences),r=e.useEditorStore(p=>p.card.cfg),{setCardCfg:s,setCardPreferences:n,setChartOrientation:l}=e.useEditorStore(p=>p.actions);(u=r==null?void 0:r.options)!=null&&u.indexAxis;function x(p){l(p)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((o=t==null?void 0:t.chartOptions)==null?void 0:o.indexAxis)||((c=r==null?void 0:r.options)==null?void 0:c.indexAxis)||"x",onValueChange:x,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"x",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"y",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const xe="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function _e(t,r){var n,l,x;const s=e.getNumberAxis(t,r);return((x=(l=(n=t==null?void 0:t.chartOptions)==null?void 0:n.scales)==null?void 0:l[s])==null?void 0:x.type)||"linear"}function it(){var _,q,G,B,Q,y;const[t,r]=R.useState(!1),s=e.useEditorStore(g=>{var N;return(N=g.card)==null?void 0:N.preferences}),n=e.useEditorStore(g=>{var N;return(N=g.card)==null?void 0:N.cfg}),l=e.getNumberAxis(s,n),[x,u]=R.useState(_e(s)),[o,c]=R.useState(((G=(q=(_=s==null?void 0:s.chartOptions)==null?void 0:_.scales)==null?void 0:q[l])==null?void 0:G.min)||""),[p,m]=R.useState(((y=(Q=(B=s==null?void 0:s.chartOptions)==null?void 0:B.scales)==null?void 0:Q[l])==null?void 0:y.max)||""),[j,E]=R.useState(o||p?"custom":"auto"),[a,d]=R.useState(""),[h,C]=R.useState(0),[S,I]=R.useState(""),[f,D]=R.useState(""),[z,L]=R.useState(""),w=e.useEditorStore(g=>g.actions.setCardPreferences),b=e.useEditorStore(g=>{var N;return(N=g.card)==null?void 0:N.type}),v=["pie","doughnut","polarArea"].includes(b);R.useEffect(()=>{var g,N,O,te,K,A,H,$,re,se,V,J,U,oe;u(_e(s)),c(((O=(N=(g=s==null?void 0:s.chartOptions)==null?void 0:g.scales)==null?void 0:N[l])==null?void 0:O.min)===0?0:""),m(((A=(K=(te=s==null?void 0:s.chartOptions)==null?void 0:te.scales)==null?void 0:K[l])==null?void 0:A.max)||""),d(((se=(re=($=(H=s==null?void 0:s.chartOptions)==null?void 0:H.scales)==null?void 0:$[l])==null?void 0:re.ticks)==null?void 0:se.stepSize)||""),C(((V=s==null?void 0:s.numberAxisFormat)==null?void 0:V.decimalPlaces)||0),I(((J=s==null?void 0:s.numberAxisFormat)==null?void 0:J.suffix)||""),D(((U=s==null?void 0:s.numberAxisFormat)==null?void 0:U.currency)||""),L(((oe=s==null?void 0:s.numberAxisFormat)==null?void 0:oe.locale)||"")},[t,s,l]);function T(g,N){return N===""||/^[0-9\b]+$/.test(N)?Number(N):Number(g)}function M(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsxRuntimeExports.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxRuntimeExports.jsx(e.Input,{value:f,placeholder:"USD",onChange:g=>D(g.target.value),id:"currency",className:`col-span-2 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:z,placeholder:"en-US",onChange:g=>L(g.target.value),id:"locale",className:`col-span-2 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsxRuntimeExports.jsx(e.Input,{value:h,onChange:g=>C(Number(g.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${xe}`})]})]})}function k(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"range",children:"Range"}),e.jsxRuntimeExports.jsx(e.Input,{id:"min",value:o,onChange:g=>c(N=>T(N,g.target.value)),className:`col-span-1 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:p,onChange:g=>m(N=>T(N,g.target.value)),id:"max",className:`col-span-1 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsxRuntimeExports.jsx(e.Input,{value:a,onChange:g=>d(N=>T(N,g.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${xe}`})]})]})}function F(){var O;let g={};j==="custom"&&(g={min:o,max:p,ticks:{stepSize:a}});const N={...s||{},chartOptions:{...s==null?void 0:s.chartOptions,scales:{...(O=s==null?void 0:s.chartOptions)==null?void 0:O.scales,[l]:{type:x,...x==="linear"?g:{}}}},numberAxisFormat:{decimalPlaces:h,suffix:S,currency:f,locale:z}};console.log(N),w(N)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:g=>r(g),children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale",children:"Type"}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:v,value:x,onValueChange:g=>u(g),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{id:"type",children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Option"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"linear",children:"Linear"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),x=="linear"&&e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxRuntimeExports.jsxs(e.RadioGroup,{disabled:v,id:"scale-option",value:j,onValueChange:g=>E(g),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"auto",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"custom",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),j==="custom"&&x=="linear"&&k(),M(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:F,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function us({idx:t}){var o;const r=e.useEditorStore(c=>{var p;return(p=c.card)==null?void 0:p.preferences}),s=e.useEditorStore(c=>{var p;return(p=c.card.preferences)==null?void 0:p.datasetOptions}),n=e.useEditorStore(c=>c.actions.setCardPreferences),l=(o=r==null?void 0:r.chartOptions)==null?void 0:o.indexAxis,x=s==null?void 0:s.find(c=>c.idx===t);function u(c,p){(c==="end"||c==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const m={display:c!=="none",align:c,anchor:c,clamp:!0};if(!x)n({...r,datasetOptions:[...s||[],{idx:p,datalabels:m}]});else{const j={...x};j.datalabels=m;const E=s==null?void 0:s.map(a=>a.idx===p?j:a);n({...r,datasetOptions:E})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(Lt,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-fit p-1",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("none",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(e.X,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("start",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(St,{className:e.cn("h-4 w-4",{"rotate-90":l==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("center",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(vt,{className:e.cn("h-4 w-4",{"rotate-90":l==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("end",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(yt,{className:e.cn("h-4 w-4",{"rotate-90":l==="y"})})})]})})]})}function at(){const t=e.useEditorStore(c=>c.card),r=e.useEditorStore(c=>{var p,m,j;return(j=(m=(p=c==null?void 0:c.card)==null?void 0:p.preferences)==null?void 0:m.chartOptions)==null?void 0:j.indexAxis}),s=r==="y"?"Y axis":"X axis",n=r==="y"?"X axis":"Y axis",{keys:l,metricKeys:x,dimensionKeys:u}=e.getKeys(t.data||[]);let o=x;if(["stackedBar","stackedLine"].includes(t.type)){const c=e.pivotData({dataArray:t.data||[],groupKey:u[0],pivotKey:u[1],valueKey:o[0]}),{metricKeys:p}=e.getKeys(c);o=p}return l.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:s}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:e.jsxRuntimeExports.jsx("p",{children:u[0]})})})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxRuntimeExports.jsx(e.Label,{children:n}),e.jsxRuntimeExports.jsx(it,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:o.map((c,p)=>e.jsxRuntimeExports.jsx(ds,{col:c,idx:p},c))})]})]})}function ds({col:t,idx:r}){const s=e.useEditorStore(o=>{var c;return(c=o.card)==null?void 0:c.preferences}),n=e.useEditorStore(o=>{var c;return(c=o.card.preferences)==null?void 0:c.datasetOptions}),l=n==null?void 0:n.find(o=>o.idx===r),{setCardPreferences:x}=e.useEditorStore(o=>o.actions);function u(o){if(!l)x({...s,datasetOptions:[...n||[],{idx:r,type:o==="area"?"line":o,fill:o==="area"?"origin":""}]});else{const c={...l};c.type=o==="area"?"line":o,c.fill=o==="area"?"origin":"";const p=n==null?void 0:n.map(m=>m.idx===r?c:m);x({...s,datasetOptions:p})}}return e.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[e.jsxRuntimeExports.jsx("p",{children:t}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(Ae,{onClick:()=>u("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Le,{onClick:()=>u("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(mt,{onClick:()=>u("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(e.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(us,{idx:r})]})]})}function ms({cardType:t}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(t)} Chart`}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Ce,{}),e.jsxRuntimeExports.jsx(at,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}function Fe(){var l,x,u;const t=e.useEditorStore(o=>o.card.cfg),r=e.useEditorStore(o=>o.actions.setCardCfg),s=e.useEditorStore(o=>o.card.type);function n(o){var m;const c={datalabels:{display:o!=="none",align:o,anchor:o,clamp:!0}},p={...t,options:{...t==null?void 0:t.options,plugins:{...(m=t==null?void 0:t.options)==null?void 0:m.plugins,...c}}};r(p),console.log(o)}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid"].includes(s)&&e.jsxRuntimeExports.jsx(it,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(u=(x=(l=t==null?void 0:t.options)==null?void 0:l.plugins)==null?void 0:x.datalabels)==null?void 0:u.anchor,onValueChange:n,defaultValue:"none",children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:"Select position"})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Data Labels"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),s!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),s!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function ps({cardType:t}){function r(s){const n="SELECT label, [group], x-axis, y-axis, radius FROM table",l="SELECT label, [group], x-axis, y-axis FROM table";return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:s==="bubble"?n:l}),e.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),s==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:x=>x.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return e.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(t)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:r(t)})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(Fe,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}const hs={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},js={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Es(){const t=e.useEditorStore(r=>r.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:fs(t)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(t)&&e.jsxRuntimeExports.jsx(Ce,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(t)&&e.jsxRuntimeExports.jsx(Fe,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(t)&&e.jsxRuntimeExports.jsx(de,{})})]})}function fs(t){if(["line","bar"].includes(t))return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(hs,null,2)})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsxRuntimeExports.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(js,null,2)})]})]})]});if(t==="bubble")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:t})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(t==="scatter")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:t})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(t))return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:[e.jsxRuntimeExports.jsx("span",{children:t==="polarArea"?"Polar":t.charAt(0).toUpperCase()+t.slice(1)})," ","chart query"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function gs(){var c,p,m,j,E;const t=e.useEditorStore(a=>a.card.preferences),r=e.useEditorStore(a=>a.actions.setCardPreferences),s=e.useEditorStore(a=>a.actions.setNumberFormat);e.useEditorStore(a=>{var d,h;return(h=(d=a.card.preferences)==null?void 0:d.formatNumber)==null?void 0:h.decimalPlaces});const n=e.useEditorStore(a=>{var d,h;return(h=(d=a.card.preferences)==null?void 0:d.formatNumber)==null?void 0:h.locale}),l=e.useEditorStore(a=>{var d,h;return(h=(d=a.card.preferences)==null?void 0:d.formatNumber)==null?void 0:h.currency});e.useEditorStore(a=>a.actions.setFilterOnClickField);const x=e.useEditorStore(a=>{var d,h;return(h=(d=a.card.preferences)==null?void 0:d.formatNumber)==null?void 0:h.colorRanges})||[],u=e.useEditorStore(a=>a.actions.setColorRanges),o=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(a=>a.currency))];return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((c=t==null?void 0:t.formatNumber)!=null&&c.enabled),onCheckedChange:a=>{r({...t,formatNumber:{...t==null?void 0:t.formatNumber,enabled:a}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((p=t==null?void 0:t.formatNumber)==null?void 0:p.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Locale"}),e.jsxRuntimeExports.jsxs(e.Select,{value:n||"en-US",onValueChange:a=>{var d,h,C;return s(((d=t==null?void 0:t.formatNumber)==null?void 0:d.decimalPlaces)||0,((h=t==null?void 0:t.formatNumber)==null?void 0:h.currency)||"",a||"en-US",((C=t==null?void 0:t.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Format"}),e.LOCALE_CURRENCY_PAIRS.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.locale,children:a.locale},a.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Currency"}),e.jsxRuntimeExports.jsxs(e.Select,{value:l||"none",onValueChange:a=>{var d,h,C;return s(((d=t==null?void 0:t.formatNumber)==null?void 0:d.decimalPlaces)||0,a==="none"?"":a,((h=t==null?void 0:t.formatNumber)==null?void 0:h.locale)||"",((C=t==null?void 0:t.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),o.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a,children:a},a))]})})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Decimals"}),e.jsxRuntimeExports.jsxs(e.Select,{value:((j=(m=t==null?void 0:t.formatNumber)==null?void 0:m.decimalPlaces)==null?void 0:j.toString())||"0",onValueChange:a=>{var d,h,C;return s(Number(a),((d=t==null?void 0:t.formatNumber)==null?void 0:d.currency)||"",((h=t==null?void 0:t.formatNumber)==null?void 0:h.locale)||"",((C=t==null?void 0:t.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:["0","1","2","3","4"].map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a,children:a},a))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((E=t==null?void 0:t.formatNumber)==null?void 0:E.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:a=>{var d,h,C;return s(((d=t==null?void 0:t.formatNumber)==null?void 0:d.decimalPlaces)||0,((h=t==null?void 0:t.formatNumber)==null?void 0:h.currency)||"",((C=t==null?void 0:t.formatNumber)==null?void 0:C.locale)||"",a.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:x,setColorRanges:u})]})]})}function Rs(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{type:"single",collapsible:!0,children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"font-mono",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"current - number"}),e.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),e.jsxRuntimeExports.jsx("section",{className:"",children:e.jsxRuntimeExports.jsx(gs,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function bs(){var n;const t=e.useEditorStore(l=>l.card.preferences),{setCardPreferences:r}=e.useEditorStore(l=>l.actions);function s(l){r({...t,textVisualOptions:{...t==null?void 0:t.textVisualOptions,isDynamicText:l==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(n=t==null?void 0:t.textVisualOptions)!=null&&n.isDynamicText?"dynamic":"static",onValueChange:s,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"static",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function Se({cardType:t,docContent:r,suffix:s="Chart"}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(t)} ${s}`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:r||e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[t==="range"&&e.jsxRuntimeExports.jsx(Ce,{}),t!=="text"&&e.jsxRuntimeExports.jsx(Fe,{}),t==="text"&&e.jsxRuntimeExports.jsx(bs,{})]})]}),!["range","text"].includes(t)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}function Ss(){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Stacked Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Ce,{}),e.jsxRuntimeExports.jsx(at,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}function ys({}){const t=e.useEditorStore(n=>{var l;return(l=n.card)==null?void 0:l.preferences}),r=e.useEditorStore(n=>n.actions.setCardPreferences),s=n=>{r({...t,allowDownload:n})};return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:s,id:"allow-download"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const vs=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),Cs=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]}),Ns=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#text-visual",children:"example"})," in the docs."]})]});function ks(){const t=e.useEditorStore(s=>s.card.type);function r(s){switch(s){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(Ss,{});case"pyramid":return e.jsxRuntimeExports.jsx(Se,{docContent:vs,cardType:s});case"kpi":return e.jsxRuntimeExports.jsx(Rs,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(ms,{cardType:s});case"range":return e.jsxRuntimeExports.jsx(Se,{docContent:Cs,cardType:s});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(Se,{cardType:s});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(ps,{cardType:s});case"table":return e.jsxRuntimeExports.jsx(ys,{cardType:s});case"text":return e.jsxRuntimeExports.jsx(Se,{docContent:Ns,cardType:s,suffix:"Visual"});default:return e.jsxRuntimeExports.jsx(Es,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:r(t)})}function ws(){const t=e.useEditorStore(r=>r.isShowingVisual);return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(ns,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:t?e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx(ks,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(Ve,{})})]}):e.jsxRuntimeExports.jsx(Ve,{})})]})}function Is({authToken:t,onSave:r,onClose:s}){const n=e.useEditorStore(u=>u.actions.setOnSave),l=e.useEditorStore(u=>u.actions.setOnClose),x=e.useDashboardStore(u=>u.actions.setAuthToken);return R.useEffect(()=>{r&&n(r),s&&l(s)},[r,n,s,l]),R.useEffect(()=>{t&&t.accessToken&&x(t)},[t,x]),e.jsxRuntimeExports.jsxs(e.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(Je,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(ws,{})})]})}function Ds(){e.useDashboardStore(u=>u.selectedCardId);const t=e.useDashboardStore(u=>u.selectedSheetId),{setIsVisualEditing:r}=e.useDashboardStore(u=>u.actions),s=e.useDashboardStore(u=>u.isVisualEditing),n=e.useDashboardStore(u=>u.actions.updateFrame);function l(u){t&&(n(t,u),r(!1))}function x(){r(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:s,hidden:!s}),children:e.jsxRuntimeExports.jsx(Is,{onSave:l,onClose:x})})}function zs({columns:t,tableName:r}){const s=e.useEditorStore(a=>a.selectedConnectionId),n=e.useEditorStore(a=>a.selectedDatamodelId),l=e.useEditorStore(a=>a.selectedDatabaseName),x=e.useEditorStore(a=>a.selectedSchemaName),u=e.useEditorStore(a=>a.selectedTableName),o=e.useDashboardStore(a=>a.dashboard.filters)||[],c=e.useDashboardStore(a=>a.actions.addFilter),p=e.useDashboardStore(a=>a.actions.removeFilter),m=e.useDashboardStore(a=>a.actions.removeFilterValue),{modelItems:j}=je();function E(a){var L;const d=e.fmt(a.column_name),h=e.fmt(l||""),C=e.fmt(x||""),S=e.fmt(r);let I=e.getQualifiedTableName(C,S),f=`${I}.${d}`;const D=(L=j==null?void 0:j.find(w=>w.id===n))==null?void 0:L.name;n&&n!=="none"&&(f=`d.${D}.${d}`,I=`d.${D}`),console.log("find",f,S,h);const z=o==null?void 0:o.find(w=>w.column===f&&w.table===S&&(w.database===h||w.database===l));if(z)m(z.id),p(z.id);else{if(r==="api"&&s){c({id:e.v4(),column:f,title:a.column_name,dataType:a.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:e.getDefaultFilterSql(a.data_type,I,d)});return}c({id:e.v4(),column:f,title:a.column_name,dataType:a.data_type,table:u||"",database:l||"",connectionId:s||"",operation:"in",sql:e.getDefaultFilterSql(a.data_type,I,d)})}}return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:t==null?void 0:t.map(a=>{const d=o==null?void 0:o.find(h=>h.column===e.fmt(a.column_name)&&h.table===u&&h.database===l);return e.jsxRuntimeExports.jsx("div",{onClick:()=>E(a),className:e.cn("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",{"bg-muted":d}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(Qe,{column:a}),e.jsxRuntimeExports.jsx("span",{children:a.column_name})]})},a.column_name)})})}function As(){e.useDashboardStore(r=>r.showFilters);const t=e.useDashboardStore(r=>r.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-lg",children:"Filters"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>t(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{})})]}),e.jsxRuntimeExports.jsx("div",{className:"flex grow",children:e.jsxRuntimeExports.jsx(Je,{ColumnsComponent:(r,s,n)=>e.jsxRuntimeExports.jsx(zs,{schemaName:r,tableName:s,columns:n})})})]})}function Ls(){e.useDashboardStore(s=>s.dashboard);const t=e.useDashboardStore(s=>s.showFilters),r=e.useDashboardStore(s=>s.isVisualEditing);return e.useDashboardStore(s=>s.bookmarkKey),e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:r,flex:!r}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),t&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(As,{})})]})}function Ts(){const t=e.useDashboardStore(n=>n.dashboard),r=e.useDashboardStore(n=>n.actions.setDashboard),s=e.useDashboardStore(n=>n.showDashboardJSON);return e.useDashboardStore(n=>n.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!s}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:n=>{if(n)try{JSON.parse(n),r(JSON.parse(n))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(t,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function Fs({showControls:t=!1,showFooter:r=!0,...s}){return e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:s,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(Ts,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...s,children:[t&&e.jsxRuntimeExports.jsx(qt,{}),e.jsxRuntimeExports.jsx(Ds,{}),e.jsxRuntimeExports.jsx(Ls,{})]})]})]})}exports.DashboardPlus=Fs;exports.SelectComponent=ue;exports.useEditorAside=je;