react-semaphor 0.0.173 → 0.0.174
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.
- package/dist/chunks/{dashboard-plus-0J3J9ZJQ.js → dashboard-plus-2zqNv1xS.js} +1396 -1354
- package/dist/chunks/dashboard-plus-o5x0Gv36.js +205 -0
- package/dist/chunks/{index-YLj7M7ho.js → index-5sxgge2v.js} +4891 -4827
- package/dist/chunks/{index-NP8yP9EE.js → index-YSA9UF5n.js} +56 -56
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/dashboard.d.ts +1 -1
- package/dist/types/main.d.ts +1 -1
- package/dist/types/surfboard.d.ts +1 -1
- package/dist/types/types.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunks/dashboard-plus-LqLuP6V4.js +0 -205
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";const e=require("./index-YSA9UF5n.js"),E=require("react");/**
|
|
2
|
+
* @license lucide-react v0.379.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
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
|
+
* @license lucide-react v0.379.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const mt=e.createLucideIcon("AreaChart",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M7 12v5h12V8l-5 5-4-4Z",key:"zxz28u"}]]);/**
|
|
12
|
+
* @license lucide-react v0.379.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Ne=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
|
+
* @license lucide-react v0.379.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const pt=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"}]]);/**
|
|
22
|
+
* @license lucide-react v0.379.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const ht=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"}]]);/**
|
|
27
|
+
* @license lucide-react v0.379.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const jt=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"}]]);/**
|
|
32
|
+
* @license lucide-react v0.379.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const Be=e.createLucideIcon("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
|
|
37
|
+
* @license lucide-react v0.379.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/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"}]]);/**
|
|
42
|
+
* @license lucide-react v0.379.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const Et=e.createLucideIcon("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
|
|
47
|
+
* @license lucide-react v0.379.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/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"}]]);/**
|
|
52
|
+
* @license lucide-react v0.379.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/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"}]]);/**
|
|
57
|
+
* @license lucide-react v0.379.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/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"}]]);/**
|
|
62
|
+
* @license lucide-react v0.379.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const ke=e.createLucideIcon("LineChart",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);/**
|
|
67
|
+
* @license lucide-react v0.379.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/const yt=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"}]]);/**
|
|
72
|
+
* @license lucide-react v0.379.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const St=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"}]]);/**
|
|
77
|
+
* @license lucide-react v0.379.0 - ISC
|
|
78
|
+
*
|
|
79
|
+
* This source code is licensed under the ISC license.
|
|
80
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
+
*/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"}]]);/**
|
|
82
|
+
* @license lucide-react v0.379.0 - ISC
|
|
83
|
+
*
|
|
84
|
+
* This source code is licensed under the ISC license.
|
|
85
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
+
*/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"}]]);/**
|
|
87
|
+
* @license lucide-react v0.379.0 - ISC
|
|
88
|
+
*
|
|
89
|
+
* This source code is licensed under the ISC license.
|
|
90
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
+
*/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"}]]);/**
|
|
92
|
+
* @license lucide-react v0.379.0 - ISC
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the ISC license.
|
|
95
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
+
*/const qe=e.createLucideIcon("Pencil",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
|
|
97
|
+
* @license lucide-react v0.379.0 - ISC
|
|
98
|
+
*
|
|
99
|
+
* This source code is licensed under the ISC license.
|
|
100
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
+
*/const Ve=e.createLucideIcon("PieChart",[["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}],["path",{d:"M22 12A10 10 0 0 0 12 2v10z",key:"1rfc4y"}]]);/**
|
|
102
|
+
* @license lucide-react v0.379.0 - ISC
|
|
103
|
+
*
|
|
104
|
+
* This source code is licensed under the ISC license.
|
|
105
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
+
*/const kt=e.createLucideIcon("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
|
|
107
|
+
* @license lucide-react v0.379.0 - ISC
|
|
108
|
+
*
|
|
109
|
+
* This source code is licensed under the ISC license.
|
|
110
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
+
*/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"}]]);/**
|
|
112
|
+
* @license lucide-react v0.379.0 - ISC
|
|
113
|
+
*
|
|
114
|
+
* This source code is licensed under the ISC license.
|
|
115
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
+
*/const _e=e.createLucideIcon("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
117
|
+
* @license lucide-react v0.379.0 - ISC
|
|
118
|
+
*
|
|
119
|
+
* This source code is licensed under the ISC license.
|
|
120
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
+
*/const At=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
|
+
* @license lucide-react v0.379.0 - ISC
|
|
123
|
+
*
|
|
124
|
+
* This source code is licensed under the ISC license.
|
|
125
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
+
*/const He=e.createLucideIcon("ScatterChart",[["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["circle",{cx:"18.5",cy:"5.5",r:".5",fill:"currentColor",key:"lysivs"}],["circle",{cx:"11.5",cy:"11.5",r:".5",fill:"currentColor",key:"byv1b8"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["circle",{cx:"17.5",cy:"14.5",r:".5",fill:"currentColor",key:"1gjh6j"}],["path",{d:"M3 3v18h18",key:"1s2lah"}]]);/**
|
|
127
|
+
* @license lucide-react v0.379.0 - ISC
|
|
128
|
+
*
|
|
129
|
+
* This source code is licensed under the ISC license.
|
|
130
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
+
*/const Tt=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
|
+
* @license lucide-react v0.379.0 - ISC
|
|
133
|
+
*
|
|
134
|
+
* This source code is licensed under the ISC license.
|
|
135
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
+
*/const It=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"}]]);/**
|
|
137
|
+
* @license lucide-react v0.379.0 - ISC
|
|
138
|
+
*
|
|
139
|
+
* This source code is licensed under the ISC license.
|
|
140
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
+
*/const zt=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"}]]);/**
|
|
142
|
+
* @license lucide-react v0.379.0 - ISC
|
|
143
|
+
*
|
|
144
|
+
* This source code is licensed under the ISC license.
|
|
145
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
+
*/const Dt=e.createLucideIcon("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
|
|
147
|
+
* @license lucide-react v0.379.0 - ISC
|
|
148
|
+
*
|
|
149
|
+
* This source code is licensed under the ISC license.
|
|
150
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
+
*/const Lt=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 Ft(){const[t,r]=E.useState(""),[s,n]=E.useState(!1),[a,i]=E.useState(!1),o=e.useDashboardStore(c=>c.dashboard);function l(){const c=e.getDashbaordStateWithoutData(o),d=e.getBookmarkKey(o.id),x=JSON.parse(localStorage.getItem(d)||"[]");if(x.some(h=>h.name===t)){n(!0);return}x.push({name:t,template:c}),localStorage.setItem(d,JSON.stringify(x)),i(!1)}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:a,onOpenChange:i,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,{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:l,children:"Save"})})]})]})}function Ot(){const[t,r]=E.useState(!1),[s,n]=E.useState(""),a=e.useDashboardStore(p=>p.dashboard),i=e.useDashboardStore(p=>p.bookmarkKey),[o,l]=E.useState([]),c=e.useDashboardStore(p=>p.actions.setDashboard),d=e.useDashboardStore(p=>p.actions.setFilterValues),x=e.useDashboardStore(p=>p.actions.setBookmarkKey);E.useEffect(()=>{const p=e.getBookmarkKey(a.id),j=JSON.parse(localStorage.getItem(p)||"[]");l(j);const v=j.find(y=>y.default);v&&v.name===i&&n(v.name)},[t,a,i]);function u(p){if(p===s)return;const j=o.find(y=>y.name===p),v=j==null?void 0:j.template;v&&(c(v),d(j.filterValues||[]),x(p==="Original"?"":p)),n(p)}function h(p){const j=e.getBookmarkKey(a.id),y=JSON.parse(localStorage.getItem(j)||"[]").filter(f=>f.name!==p);localStorage.setItem(j,JSON.stringify(y)),l(y)}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:u,children:[e.jsxRuntimeExports.jsx(e.DropdownMenuRadioItem,{value:"Original",children:"Original"}),o.filter(p=>p.name!="Original").map((p,j)=>e.jsxRuntimeExports.jsxs(e.DropdownMenuRadioItem,{className:"xbg-red-100 flex justify-between",value:p.name,defaultChecked:p.name===i,children:[e.jsxRuntimeExports.jsx("p",{children:p.name}),e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:v=>{v.preventDefault(),h(p.name)},className:"h-3 w-3 hover:cursor-pointer",strokeWidth:1.5})]},j))]})]})]})}function Mt(){const[t,r]=E.useState(!1),s=e.useDashboardStore(i=>i.dashboard),n=e.useDashboardStore(i=>i.bookmarkKey);E.useEffect(()=>{if(!n){r(!1);return}const i=e.getBookmarkKey(s.id),l=JSON.parse(localStorage.getItem(i)||"[]").find(c=>c.name===n);r(l?l.default:!1)},[n,s.id]);function a(i){if(r(i),!n)return;const o=e.getBookmarkKey(s.id),c=JSON.parse(localStorage.getItem(o)||"[]").map(d=>(d.name===n?d.default=i:d.default=!1,d));console.log(c),localStorage.setItem(o,JSON.stringify(c))}return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:t,onCheckedChange:a,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 Bt(){const t=e.useDashboardStore(f=>f.bookmarkKey),r=e.useDashboardStore(f=>f.dashboard);e.useDashboardStore(f=>f.selectedSheetId);const s=e.useDashboardStore(f=>f.isDashboardEditing),n=e.useDashboardStore(f=>f.filterValues),a=e.useDashboardStore(f=>f.isVisualEditing),i=e.useDashboardStore(f=>f.showFilters);e.useDashboardStore(f=>f.showDashboardJSON);const o=e.useDashboardStore(f=>f.onSaveFunction),l=e.useDashboardStore(f=>f.actions.setShowFilters),{addFrame:c,setSelectedFrameId:d}=e.useDashboardStore(f=>f.actions),{getSelectedSheet:x,setIsDashboardEditing:u,setShowDashboardJSON:h}=e.useDashboardStore(f=>f.actions),p=x(),j=()=>{if(!s||!p)return;const f={id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]},T={id:e.v4(),cards:[f],activeCardId:f.id};c(p.id,T),d(T.id)},v=()=>{u(!0)};function y(){if(!t||t==="")return;const f=e.getDashbaordStateWithoutData(r),T=e.getBookmarkKey(r.id),w=JSON.parse(localStorage.getItem(T)||"[]"),k=w.findIndex(R=>R.name===t);k!==-1?w[k]={name:t,template:f,default:w[k].default,filterValues:n}:w.push({name:t,template:f,filterValues:n}),localStorage.setItem(T,JSON.stringify(w)),o==null||o(f)}return a?null:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pt-2",role:"dashboard-controls",children:[!a&&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(Mt,{})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[s&&!a&&e.jsxRuntimeExports.jsx(Ft,{}),!a&&e.jsxRuntimeExports.jsx(Ot,{}),s&&!a&&e.jsxRuntimeExports.jsxs(e.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!s,onClick:j,children:[e.jsxRuntimeExports.jsx(_e,{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:v,size:"sm",children:e.jsxRuntimeExports.jsx(qe,{className:"h-4 w-4",strokeWidth:1.5})}),s&&!a&&e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",role:"close",className:"h-7 p-2",onClick:()=>{u(!1),h(!1)},size:"sm",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"h-4 w-4",strokeWidth:1.5})}),s&&!a&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"outline",onClick:y,size:"sm",children:e.jsxRuntimeExports.jsx(At,{className:"h-4 w-4",strokeWidth:1.5})}),!i&&!a&&s&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"outline",onClick:()=>l(!0),size:"sm",children:e.jsxRuntimeExports.jsx(Be,{className:"h-4 w-4",strokeWidth:1.5})}),!a&&s&&!1,!a&&!1]})]})}function je({title:t,items:r,value:s,isLoading:n,isError:a,connectionTooltip:i,onChange:o,className:l,showIcon:c=!0,disabled:d=!1}){const x=n?"Loading...":a?"Error":s;function u(){if(t==="Connection")return e.jsxRuntimeExports.jsx(wt,{className:"size-4 rotate-90"});if(t==="Database")return e.jsxRuntimeExports.jsx(ht,{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"})}return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[c&&e.jsxRuntimeExports.jsx("div",{className:"shrink-0",children:i?e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:u()}),e.jsxRuntimeExports.jsx(e.TooltipContent,{className:"text-xs",align:"start",children:i})]}):u()}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:d,value:x,onValueChange:o,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("h-9 w-[190px] focus:ring-1 focus:ring-offset-0",l),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:n?"Loading...":a?"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.jsx(e.jsxRuntimeExports.Fragment,{children:r&&r.map((h,p)=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:h.id,children:h.name},p))}),(n||a)&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:x,children:x})]})})]})]})}function qt({column:t}){const[r,s]=E.useState(!1),n=e.useEditorStore(x=>x.selectedTableName),a=e.useEditorStore(x=>x.selectedSchemaName),i=e.useEditorStore(x=>x.sqlGen),o=e.useEditorStore(x=>x.actions.setSqlGen),l=e.useEditorStore(x=>x.actions.setCardSql),c=e.useEditorStore(x=>x.actions.setRunSql);function d(x,u){const h=e.createSqlGenConfig(x,i,u);o(h);const p=e.getSql(h,e.fmt(a||""),e.fmt(n));p&&(l(p),c(!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:()=>d(t,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>d(t,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>d(t,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>d(t,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>d(t,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})})]})}function $e({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(Dt,{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(zt,{className:"size-3"}):e.jsxRuntimeExports.jsx(Tt,{className:"size-3"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{children:e.jsxRuntimeExports.jsx("p",{className:"font-mono text-xs",children:t.data_type})})]})}function Vt({schemaName:t,tableName:r,columns:s,status:n}){const a=e.useEditorStore(R=>R.sqlGen),i=e.useEditorStore(R=>R.selectedConnectionId),o=e.useEditorStore(R=>R.selectedDatabaseName),l=e.useEditorStore(R=>R.selectedSchemaName),c=e.useEditorStore(R=>R.selectedTableName),d=e.useDashboardStore(R=>R.dashboard.aiScopeTables),{setAIScopeTables:x}=e.useDashboardStore(R=>R.actions),u=e.useEditorStore(R=>R.actions.setRunSql),h=e.useEditorStore(R=>R.actions.setSqlGen),p=e.useEditorStore(R=>R.actions.setIsShowingVisual),j=e.useEditorStore(R=>R.actions.setCardSql),{connectionType:v}=we();function y(R){const C=e.createSqlGenConfig(R,a);h(C);const A=e.getSql(C,e.fmt(t),e.fmt(r));A&&(j(A),u(!0))}function f(){return(d==null?void 0:d.find(R=>R.connectinonId===i&&R.tableName===c))!==void 0}function T(R){if(R===!0&&c&&i){const C={connectinonId:i,connectionType:v,databaseName:o,schemaName:l,tableName:c},D=[...d||[],C].filter((_,F,O)=>O.findIndex(I=>I.connectinonId===_.connectinonId&&I.tableName===_.tableName)===F);x(D)}else{const C=(d||[]).filter(A=>A.connectinonId!==i&&A.tableName!==c);x(C)}}function w(){let C=e.getQualifiedTableName(t,r);(D=>D.charAt(0)===D.charAt(0).toUpperCase())(r)&&(C=`"${r}"`),p(!1),j(`SELECT * FROM ${C} LIMIT 10`),u(!0)}function k(){let C=e.getQualifiedTableName(t,r);(D=>D.charAt(0)===D.charAt(0).toUpperCase())(r)&&(C=`"${r}"`),p(!1),j(`SELECT COUNT(*) FROM ${C}`),u(!0)}return e.jsxRuntimeExports.jsxs("div",{className:"flex grow flex-col space-y-4 px-6",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Toggle,{title:`${f()?"Remove from":"Add to"} AI Scope`,pressed:f(),onPressedChange:T,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:w,size:"sm",variant:"secondary",className:"flex w-full",children:[n!=="Success"?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):null,"Top 10"]}),e.jsxRuntimeExports.jsxs(e.Button,{disabled:n!=="Success",onClick:k,size:"sm",variant:"secondary",className:"flex w-full",children:[n!=="Success"?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):null,"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(R=>e.jsxRuntimeExports.jsxs("div",{onClick:()=>y(R),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(R,a)}),children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx($e,{column:R}),e.jsxRuntimeExports.jsx("span",{children:R.column_name})]}),e.NUMBER_DATA_TYPES.includes(R.data_type)&&e.jsxRuntimeExports.jsx("div",{onClick:C=>C.stopPropagation(),className:"flex items-center justify-end",children:e.jsxRuntimeExports.jsx(qt,{column:R})})]},R.column_name)),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"vertical"}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})]})}function we(t,r){var Re,ae,fe,pe;let s=E.useMemo(()=>[],[]);const n=e.useSemaphorContext().authToken||t,a=e.useEditorStore(S=>S.selectedConnectionId),i=e.useEditorStore(S=>S.selectedDatabaseName),o=e.useEditorStore(S=>S.selectedSchemaName),l=e.useEditorStore(S=>S.selectedTableName),c=e.useEditorStore(S=>S.actions.setCurrentColumns),d=e.useEditorStore(S=>S.actions.setSelectedConnectionId),x=e.useEditorStore(S=>S.actions.setSelectedDatabaseName),u=e.useEditorStore(S=>S.actions.setSelectedSchemaName),h=e.useEditorStore(S=>S.actions.setSelectedTableName),p=e.useEditorStore(S=>S.actions.setCardSql);function j(S){return a&&i&&o&&i!=="NA"?!0:a&&S==="API"?!1:!!(a&&S==="S3")}function v(S){return!!(a&&i&&i!=="NA"&&o&&l||a&&(S==="S3"||S==="API"))}function y(S){return a&&S?!(S==="API"||S==="S3"):!1}const{data:f,isLoading:T,isError:w}=e.useQuery({queryKey:["connections"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/connections",(n==null?void 0:n.accessToken)||""),enabled:!!(n!=null&&n.accessToken)}),k=f==null?void 0:f.connections.find(S=>S.id===a),R=k==null?void 0:k.type,C=(k==null?void 0:k.type)==="API"||(k==null?void 0:k.type)==="S3",{data:A,isLoading:D,isFetching:_,isError:F,refetch:O}=e.useQuery({queryKey:["databases",a],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/databases",(n==null?void 0:n.accessToken)||"",{connection_id:a}),enabled:y(R)}),{data:I,isLoading:G,isFetching:q,isError:$,refetch:H}=e.useQuery({queryKey:["schemas",a,i],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/schemas",(n==null?void 0:n.accessToken)||"",{connection_id:a,database_name:i}),enabled:!!a&&!!i&&!C&&i!=="NA"}),{data:M,isLoading:z,isFetching:b,isError:g,refetch:N}=e.useQuery({queryKey:["tables",a,i,o],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/tables",(n==null?void 0:n.accessToken)||"",{connection_id:a,database_name:i,schema_name:o}),enabled:j(R)}),{data:L,isLoading:Z,isFetching:K,isError:re}=e.useQuery({queryKey:["columns",a,i,o,l],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/columns",(n==null?void 0:n.accessToken)||"",{connection_id:a,database_name:i,schema_name:o,table_name:l}),enabled:v(R)});E.useEffect(()=>{c(s)},[L,c,s]),E.useEffect(()=>{},[C,p,h,u,x,k]);const ne=(k==null?void 0:k.type)==="API"?(Re=k==null?void 0:k.type)==null?void 0:Re.toLowerCase():l||"",oe=C?"":o||"";function ee(S){u(S),h("")}function B(S){x(S),u(""),h("")}function P(S){d(S)}A&&((ae=A==null?void 0:A.databases)==null?void 0:ae.length)>0,I&&((fe=I==null?void 0:I.schemas)==null?void 0:fe.length)>0,L&&((pe=L==null?void 0:L.columns)==null?void 0:pe.length)>0&&(s=L.columns.map(S=>({...S,data_type:S.data_type.toLowerCase()}))),F&&(s=[]),(re||w)&&(s=[]);const Q=f==null?void 0:f.connections.map(S=>({id:S.id,name:S.name,type:S.type})),ie=A==null?void 0:A.databases.map(S=>({id:S.database_name,name:S.database_name})),U=I==null?void 0:I.schemas.map(S=>({id:S.schema_name,name:S.schema_name})),me=M==null?void 0:M.tables.map(S=>({id:S.table_name,name:S.table_name}));return{connectionItems:Q,isConnectionsLoading:T,isConnectionsError:w,databaseItems:ie,isDatabasesLoadingOrFetching:D||_,isDatabaseError:F,schemaItems:U,isSchemaLoadingOrFetching:G||q,isSchemaError:$,tableItems:me,isTableLoadingOrFetching:z||b,isTableError:g,columns:s,isColumnsLoadingOrFetching:Z||K,isColumnsError:re,isNonDbConnection:C,connectionType:R,tableName:ne,schemaName:oe,handleConnectionChange:P,handleDatabaseChange:B,handleSchemaChange:ee}}function Ke({ColumnsComponent:t}){var M;const r=e.useEditorStore(z=>z.selectedConnectionId),s=e.useEditorStore(z=>z.selectedDatabaseName),n=e.useEditorStore(z=>z.selectedSchemaName),a=e.useEditorStore(z=>z.selectedTableName),i=e.useEditorStore(z=>z.actions.setSelectedTableName),{connectionItems:o,schemaItems:l,databaseItems:c,tableItems:d,columns:x,isConnectionsLoading:u,isConnectionsError:h,isDatabasesLoadingOrFetching:p,isDatabaseError:j,isSchemaLoadingOrFetching:v,isSchemaError:y,isColumnsError:f,isColumnsLoadingOrFetching:T,isTableLoadingOrFetching:w,isTableError:k,connectionType:R,isNonDbConnection:C,handleConnectionChange:A,handleDatabaseChange:D,handleSchemaChange:_,tableName:F,schemaName:O}=we();function I(){return t?t(O,F,x):e.jsxRuntimeExports.jsx(Vt,{schemaName:O,tableName:F,columns:x,status:T?"Loading...":f?"Error":"Success"})}function G(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function q(){return R==="S3"||R==="API"?null:e.jsxRuntimeExports.jsx(je,{onChange:D,isError:j,isLoading:p,items:c,value:s||"",title:"Database"})}function $(){return R==="S3"||R==="API"?null:e.jsxRuntimeExports.jsx(je,{onChange:_,isError:y,isLoading:v,items:l,value:n||"",title:"Schema"})}function H(){return R==="API"?null:e.jsxRuntimeExports.jsx(je,{onChange:i,isError:k,items:d,isLoading:w,value:a||"",title:"Table"})}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(je,{items:o,title:"Connection",value:r||"",onChange:A,isLoading:u,isError:h,connectionTooltip:((M=o==null?void 0:o.find(z=>z.id===r))==null?void 0:M.type)||""}),q(),$(),H()]}),I(),e.jsxRuntimeExports.jsx("div",{className:"flex items-end justify-center gap-2 px-6 py-4",children:e.jsxRuntimeExports.jsxs(e.Button,{onClick:G,size:"sm",variant:"secondary",className:"w-full",children:[e.jsxRuntimeExports.jsx(Ct,{className:"mr-2 size-4"}),"Help"]})})]})}const ve=({className:t,...r})=>e.jsxRuntimeExports.jsx(e.PanelGroup,{className:e.cn("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",t),...r}),ue=e.Panel,Ce=({withHandle:t,className:r,...s})=>e.jsxRuntimeExports.jsx(e.PanelResizeHandle,{className:e.cn("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",r),...s,children:t&&e.jsxRuntimeExports.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:e.jsxRuntimeExports.jsx(Et,{className:"h-2.5 w-2.5"})})});function _t(t){const r=t.toUpperCase().indexOf("WHERE"),s=t.toUpperCase().indexOf("GROUP BY"),n=t.toUpperCase().indexOf("LIMIT"),a=t.toUpperCase().indexOf("ORDER BY");let i=t.length;if(a!==-1&&(i=a),n!==-1&&n<i&&(i=n),r!==-1){const o=t.substring(0,r),l=t.substring(r);return`${o} {{ filters | where }} AND ${l.substring(6)}`}else if(s!==-1){const o=t.substring(0,s),l=t.substring(s);return`${o} {{ filters | where }} ${l}`}else{const o=t.substring(0,i),l=t.substring(i);return`${o} {{ filters | where }} ${l}`}}function Ht({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(pt,{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.useRef(null),s=e.useEditorStore(l=>l.applyFilters),[n,a]=E.useState(""),i=e.useEditorStore(l=>l.filterValues),o=e.useEditorStore(l=>l.card.sql);return e.jsxRuntimeExports.jsxs(e.HoverCard,{openDelay:0,onOpenChange:async l=>{if(!l)return;console.log("onOpenChange");const c=await e.postRequest("https://semaphor.cloud/api/v1/filter-sql",(t==null?void 0:t.accessToken)||"",{sql:o,active_filters:i});console.log(c),c.sql?(console.log(c.records),a(c.sql)):a("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 Gt=`
|
|
152
|
+
|
|
153
|
+
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.
|
|
154
|
+
|
|
155
|
+
Bar / Line Chart:
|
|
156
|
+
|
|
157
|
+
SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table
|
|
158
|
+
|
|
159
|
+
- X-axis - Category
|
|
160
|
+
- Y-axis - Number
|
|
161
|
+
|
|
162
|
+
Stacked Chart:
|
|
163
|
+
|
|
164
|
+
SELECT x-axis, stack-by, y-axis FROM table
|
|
165
|
+
|
|
166
|
+
- X-axis - Category
|
|
167
|
+
- Stack by - Category
|
|
168
|
+
- Y-axis - Number
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
Scatter Chart:
|
|
172
|
+
|
|
173
|
+
SELECT label, x-axis, y-axis FROM table
|
|
174
|
+
|
|
175
|
+
- Label - Category
|
|
176
|
+
- Group (opt) - Category
|
|
177
|
+
- X-axis - Number
|
|
178
|
+
- Y-axis - Number
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
Bubble Chart:
|
|
182
|
+
|
|
183
|
+
SELECT label, x-axis, y-axis, radius FROM table
|
|
184
|
+
|
|
185
|
+
- Label - Category
|
|
186
|
+
- Bubble Group (opt) - Category
|
|
187
|
+
- X-axis - Number
|
|
188
|
+
- Y-axis - Number
|
|
189
|
+
- Radius - Number
|
|
190
|
+
|
|
191
|
+
Pie / Dougnut Chart:
|
|
192
|
+
|
|
193
|
+
SELECT label, measure FROM table
|
|
194
|
+
|
|
195
|
+
- Label - Category
|
|
196
|
+
- Measure - Number
|
|
197
|
+
`;function Pt({open:t,setOpen:r,userInput:s,setUserInput:n,triggerAIRun:a,setTriggerAIRun:i}){const o=E.useRef(null),l=E.useRef(null),{authToken:c}=e.useSemaphorContext(),[d,x]=E.useState(!1),u=e.useEditorStore(b=>b.actions.setCardSql),h=e.useDashboardStore(b=>b.dashboard.baseQueries),p=e.useEditorStore(b=>b.actions.setRunSql),j=e.useEditorStore(b=>b.actions.setCardType),[v,y]=E.useState([]),f=e.useEditorStore(b=>b.currentColumns),T=e.useEditorStore(b=>b.card.sql),w=e.useEditorStore(b=>b.selectedTableName),k=`
|
|
198
|
+
${s}
|
|
199
|
+
|
|
200
|
+
Database Query Dialect: ${w==="api"||w==="s3"?"DuckDb":""}
|
|
201
|
+
Table Name: ${w}
|
|
202
|
+
Table Columns: ${f==null?void 0:f.map(b=>`${b.column_name} | ${b.data_type}`).join(", ")}
|
|
203
|
+
User SQL: ${T}
|
|
204
|
+
${h&&`Base Queries: ${JSON.stringify(h)} `}`,R=` 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.
|
|
205
|
+
Visual Query Syntax: ${Gt}`,{data:C,isLoading:A,isFetching:D,isError:_,refetch:F}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(c==null?void 0:c.accessToken)||"",{user_content:`userContent: ${k} ${d?R:""}`}),enabled:!1});function O(b){if(b.toLowerCase().includes("bar"))j("bar");else if(b.toLowerCase().includes("line"))j("line");else if(b.toLowerCase().includes("bubble"))j("bubble");else if(b.toLowerCase().includes("scatter"))j("scatter");else if(b.toLowerCase().includes("stacked"))j("stackedBar");else if(b.toLowerCase().includes("pie"))j("pie");else if(b.toLowerCase().includes("donut")||b.toLowerCase().includes("doughnut"))j("doughnut");else if(b.toLowerCase().includes("radar"))j("radar");else return j("bar"),!1;return!0}E.useEffect(()=>{C&&y(b=>[...b,{role:"ai",content:C.response}])},[C]),E.useEffect(()=>{const b=setTimeout(()=>{var g;l.current&&(l.current.scroll({top:l.current.scrollHeight,behavior:"smooth"}),(g=o.current)==null||g.focus())},100);return()=>clearTimeout(b)},[v]);function I(){s&&(y(b=>[...b,{role:"user",content:s}]),O(s)&&x(!0),n(""),F())}E.useEffect(()=>{a&&(I(),i(!1))},[a,i]);const G={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},q={fontFamily:"monospace",fontSize:14,lineHeight:1.6},$={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},H={p:({node:b,...g})=>e.jsxRuntimeExports.jsx("p",{style:G,...g}),code:({node:b,...g})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...g}),pre:({node:b,...g})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:q,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:M,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:N=>{const L=M(N);L&&(r(!1),u(L),p(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:b,...g})=>e.jsxRuntimeExports.jsx("li",{style:$,...g})};function M(b){const g=b.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(L=>console.error("Error in copying text: ",L)),N}function z(){return v==null?void 0:v.map((b,g)=>b.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Lt,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:b.content})]},g):b.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:H,children:C==null?void 0:C.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:l,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:z()})}),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:o,onKeyDown:b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),n(""),I())},placeholder:"Type your question here...",onFocus:b=>{const g=b.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:A||D,value:s,onChange:b=>n(b.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:I,children:!A&&!D?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Ge={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},De=E.createContext&&E.createContext(Ge),Qt=["attr","size","title"];function Ut(t,r){if(t==null)return{};var s=Jt(t,r),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(a=0;a<i.length;a++)n=i[a],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(s[n]=t[n])}return s}function Jt(t,r){if(t==null)return{};var s={},n=Object.keys(t),a,i;for(i=0;i<n.length;i++)a=n[i],!(r.indexOf(a)>=0)&&(s[a]=t[a]);return s}function Ee(){return Ee=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},Ee.apply(this,arguments)}function Le(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),s.push.apply(s,n)}return s}function ge(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?Le(Object(s),!0).forEach(function(n){Wt(t,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Le(Object(s)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(s,n))})}return t}function Wt(t,r,s){return r=Yt(r),r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function Yt(t){var r=Xt(t,"string");return typeof r=="symbol"?r:String(r)}function Xt(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 Pe(t){return t&&t.map((r,s)=>E.createElement(r.tag,ge({key:s},r.attr),Pe(r.child)))}function se(t){return r=>E.createElement(Zt,Ee({attr:ge({},t.attr)},r),Pe(t.child))}function Zt(t){var r=s=>{var{attr:n,size:a,title:i}=t,o=Ut(t,Qt),l=a||s.size||"1em",c;return s.className&&(c=s.className),t.className&&(c=(c?c+" ":"")+t.className),E.createElement("svg",Ee({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},s.attr,n,o,{className:c,style:ge(ge({color:t.color||s.color},s.style),t.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),i&&E.createElement("title",null,i),t.children)};return De!==void 0?E.createElement(De.Consumer,null,s=>r(s)):r(Ge)}function es(t){return se({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 ts(){const{theme:t}=e.useTheme(),r=E.useRef(),s=E.useRef(),[n,a]=E.useState(!1),[i,o]=E.useState(!1),[l,c]=E.useState(!1),[d,x]=E.useState(""),[u,h]=E.useState(!1),{authToken:p}=e.useSemaphorContext();e.useDashboardStore(m=>m.selectedSheetId);const j=e.useDashboardStore(m=>m.dashboard.baseQueries),v=e.useEditorStore(m=>m.card),y=e.useDashboardStore(m=>m.theme),f=e.useEditorStore(m=>m.isShowingVisual),T=e.useEditorStore(m=>m.selectedConnectionId),w=e.useEditorStore(m=>m.selectedDatabaseName),k=e.useEditorStore(m=>m.selectedSchemaName);e.useDashboardStore(m=>m.actions.updateFrameCard);const R=e.useEditorStore(m=>m.selectedTableName),C=e.useEditorStore(m=>m.card.sql),A=e.useEditorStore(m=>m.card.python),D=e.resolveBaseQuery(C,j),_=e.useEditorStore(m=>m.selectedConnectionId),F=e.useEditorStore(m=>m.frame),O=e.useEditorStore(m=>m.filterValues),I=e.useEditorStore(m=>m.applyFilters),{setCardCustomCfg:G,setQueryResultColumns:q,setFilterValues:$,setCardSql:H,setCardPython:M,setQueryError:z,setPythonStdOut:b,setCardPreferences:g}=e.useEditorStore(m=>m.actions),N=e.useEditorStore(m=>m.onSave),L=e.useEditorStore(m=>m.actions.setApplyFilters),Z=e.useEditorStore(m=>m.onClose),K=e.useEditorStore(m=>m.actions.setCardData),re=e.useEditorStore(m=>m.actions.setSqlGen),ne=e.useEditorStore(m=>m.runSql),oe=e.useEditorStore(m=>m.actions.setRunSql),ee=e.useEditorStore(m=>m.actions.setIsSqlRunning),{data:B,isLoading:P,isFetching:Q,isSuccess:ie,isError:U,error:me,status:Re,refetch:ae}=e.useQuery({queryKey:[D,A],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(p==null?void 0:p.accessToken)||"",{connection_id:_,sql:D,python:A===e.PYTHON_DEFAULT_CODE?"":A,active_filters:I?O:[]}),enabled:!1,retry:!1});E.useEffect(()=>{if(B&&(K(B.records),b((B==null?void 0:B.output)||""),B.records.length>0)){const{dimensionKeys:m}=e.getKeys(B.records);q(m)}},[B,K,q,b]),E.useEffect(()=>{ne&&(ae(),oe(!1))},[ne,ae,oe]),E.useEffect(()=>{(P||Q)&&ee(!0),(U||ie)&&ee(!1),U?(z(me.message),K([]),q([]),b("")):z("")},[P,Q,B,b,U,ie,ee,K,q,z,me]);function fe(){H(""),K([]),re({}),G(""),g({})}const pe=m=>{s.current=m};function S(){let m=C;C&&!C.includes("{{")&&(m=_t(C),H(m));const J={...v,lastSelectedSchema:k,lastSelectedDatabase:w,lastSelectedTable:R,connectionId:T,type:f?v.type:"table",sql:m,customCfg:f?v.customCfg:null},he=F.cards.map(le=>le.id===v.id?J:le);N==null||N({...F,cards:he})}function rt(){Z==null||Z()}function nt(m){const J=getComputedStyle(document.documentElement).getPropertyValue(m);return ot(J)}function ot(m){const[J,he,le]=m.split(" "),V=parseFloat(J),lt=parseFloat(he),ct=parseFloat(le),xt=lt/100,ze=ct/100,te=(1-Math.abs(2*ze-1))*xt,xe=te*(1-Math.abs(V/60%2-1)),be=ze-te/2;let W=0,Y=0,X=0;0<=V&&V<60?(W=te,Y=xe,X=0):60<=V&&V<120?(W=xe,Y=te,X=0):120<=V&&V<180?(W=0,Y=te,X=xe):180<=V&&V<240?(W=0,Y=xe,X=te):240<=V&&V<300?(W=xe,Y=0,X=te):300<=V&&V<360&&(W=te,Y=0,X=xe),W=Math.round((W+be)*255),Y=Math.round((Y+be)*255),X=Math.round((X+be)*255);const ye=ut=>{const Se=ut.toString(16);return Se.length==1?"0"+Se:Se};return`#${ye(W)}${ye(Y)}${ye(X)}`}E.useEffect(()=>{const m=r.current,J=s.current;if(m){const he=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",le=y==="system"?he:y;m.editor.defineTheme("default",{base:le==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":le==="light"?"#ffffff":nt("--background")}}),m.editor.setTheme("default")}return J&&m&&J.addCommand(m.KeyMod.Shift|m.KeyCode.Enter,function(){return console.log("Executing query..."),ae(),!1}),()=>{}},[t,y,r.current]);function Ie(m){r.current=m}function it(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[i&&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:I,onCheckedChange:()=>L(!I),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Kt,{}),O&&i&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>o(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:m=>{if(m)try{JSON.parse(m),$(JSON.parse(m))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(O,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),O&&!i&&e.jsxRuntimeExports.jsx(Be,{onClick:()=>o(!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":I})})]})}function at(){return e.jsxRuntimeExports.jsxs(ve,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(ue,{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:m=>{H(m)},value:C,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:Ie,onMount:pe})}),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(Ce,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(ue,{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:m=>{M(m&&m.trim()||"")},value:A||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:Ie,onMount:pe})}),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:[at(),it()]}),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:P||Q,onClick:()=>{ae()},className:"shrink-0",size:"sm",variant:"outline",children:[P||Q?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"]}),U&&e.jsxRuntimeExports.jsx(Ht,{error:me.message,setShowAIDialog:c,setTriggerAIRun:h,setUserInputforAI:x}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:fe,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(jt,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:n,onPressedChange:m=>a(m),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(es,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Pt,{open:l,setOpen:c,userInput:d,triggerAIRun:u,setTriggerAIRun:h,setUserInput:m=>x(m)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:S,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:rt,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function ss({data:t}){var o;const[r,s]=E.useState([]),a=Object.keys(t[0]).map(l=>({accessorKey:l,header:({column:c})=>{const d=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:[l,d==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):d==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),i=e.useReactTable({data:t,columns:a,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:i.getHeaderGroups().map(l=>e.jsxRuntimeExports.jsx(e.TableRow,{children:l.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))},l.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(o=i.getRowModel().rows)!=null&&o.length?i.getRowModel().rows.map(l=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":l.getIsSelected()&&"selected",children:l.getVisibleCells().map(c=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(c.column.columnDef.cell,c.getContext())},c.id))},l.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:a.length,className:"h-24 text-center",children:"No results."})})})]})}function Qe({className:t,...r}){E.useState(0);const s=e.useDashboardStore(o=>o.themeStyle),n=e.useEditorStore(o=>o.card),a=e.useEditorStore(o=>o.actions.setCard);if(E.useEffect(()=>{},[n.data,n.type,n.cfg,n.customCfg,s,n.preferences]),!n.id)return null;let i;return n.data&&n.data.length>0&&(i=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=>a({...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=>a({...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"&&i&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:i},JSON.stringify(i)+JSON.stringify(n.preferences)),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 rs(){const[t,r]=E.useState(!1),[s,n]=E.useState(""),[a,i]=E.useState(""),[o,l]=E.useState(""),c=e.useEditorStore(y=>y.card),d=e.useEditorStore(y=>y.card.customCfg),x=e.useEditorStore(y=>y.actions.setCardCustomCfg);function u(y){var w,k;const f={...y,data:{...y==null?void 0:y.data,datasets:(k=(w=y==null?void 0:y.data)==null?void 0:w.datasets)==null?void 0:k.map(R=>({...R,data:[]}))}};return JSON.stringify(f,null,1)}function h(){if(!c.data||c.data.length===0)return;const y=e.createChartConfig({data:c.data,cardType:c.type,cfg:c.cfg,preferences:c.preferences});y&&(n(JSON.stringify(y,null,1)),d&&i(JSON.stringify(d,null,1)))}function p(){if(a)try{const y=JSON.parse(a);return y?(x(y),l(""),i(""),y):void 0}catch(y){console.log(y),l("Invalid JSON")}}function j(){i(""),x(null)}function v(){let y;if(d){const f=e._.cloneDeep(c.cfg),T=e._.merge(f,d);return y=u(T),y}return s?(y=u(JSON.parse(s)),y):""}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:` ${d&&"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] min-w-[900px] overflow-auto",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(c.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(Qe,{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:[d&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),d?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"})]}),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:v(),onChange:y=>i(y)})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:o}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!d,onClick:j,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:p,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>r(!1),variant:"outline",children:"Close"})]})]})]})}function Ue(t){return se({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 Je(t){return se({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 We(t){return se({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 Ye(t){return se({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 Xe(t){return se({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 Ze(t){return se({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 et(t){return se({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 ns(){const[t,r]=E.useState(!1),s=e.useEditorStore(l=>l.card.type),{setCardType:n,setCardPreferences:a}=e.useEditorStore(l=>l.actions),i=e.useEditorStore(l=>l.actions.setCardCustomCfg);function o(l){n(l),i(null),a({}),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(os,{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(Ne,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ke,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Xe,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(He,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ye,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ve,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Je,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ue,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(We,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(et,{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(Ze,{className:"size-6"})})]})})]})}function os({chartType:t,className:r}){switch(t){case"bar":return e.jsxRuntimeExports.jsx(Ne,{className:r});case"line":return e.jsxRuntimeExports.jsx(ke,{className:r});case"pie":return e.jsxRuntimeExports.jsx(Ve,{className:r});case"radar":return e.jsxRuntimeExports.jsx(Ue,{className:r});case"scatter":return e.jsxRuntimeExports.jsx(He,{className:r});case"bubble":return e.jsxRuntimeExports.jsx(Ye,{className:r});case"doughnut":return e.jsxRuntimeExports.jsx(Je,{className:r});case"stackedBar":return e.jsxRuntimeExports.jsx(Xe,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(We,{className:r});case"pyramid":return e.jsxRuntimeExports.jsx(et,{className:r});case"kpi":return e.jsxRuntimeExports.jsx(Ze,{className:r});default:return e.jsxRuntimeExports.jsx(e.Table,{className:r})}}function is(){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 Fe(){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),a=e.useEditorStore(o=>o.queryError),i=e.useEditorStore(o=>o.pythonStdOut);return 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?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(ns,{}),e.jsxRuntimeExports.jsx(rs,{}),e.jsxRuntimeExports.jsx(is,{})]}),e.jsxRuntimeExports.jsx(ls,{})]}),s?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})})}):e.jsxRuntimeExports.jsx(Qe,{className:"grow border-none shadow-none"}):e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[i&&e.jsxRuntimeExports.jsx(as,{}),t.data&&t.data.length>0&&e.jsxRuntimeExports.jsx(ss,{data:r||[]}),a&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:a})]})]}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"})}function as(){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 ls(){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]=E.useState([]);e.useEditorStore(x=>x.card.cfg);const s=e.useEditorStore(x=>x.card.preferences),{setCardCfg:n,setFilterOnClickColumnIndex:a,setCardPreferences:i}=e.useEditorStore(x=>x.actions),o=e.useEditorStore(x=>x.queryResultColumns);e.useEditorStore(x=>{var u;return(u=x.card.preferences)==null?void 0:u.filterOnClickColumnIndex}),E.useEffect(()=>{o&&r(new Array(o.length).fill(!1))},[o]);function l(x,u){var h,p;u?s!=null&&s.onClickFilter&&((h=s==null?void 0:s.onClickFilter)==null?void 0:h.length)>0?i({...s,onClickFilter:[...s.onClickFilter,{columnIndex:x,expression:""}]}):i({...s,onClickFilter:[{columnIndex:x,expression:""}]}):(i({...s,onClickFilter:(p=s==null?void 0:s.onClickFilter)==null?void 0:p.filter(j=>j.columnIndex!==x)}),r(j=>{const v=[...j];return v[x]=!1,v}))}function c(x,u){var p;const h=(p=s==null?void 0:s.onClickFilter)==null?void 0:p.map(j=>j.columnIndex===x?{...j,expression:u.target.value}:j);i({...s,onClickFilter:h})}function d(x){var u,h,p,j;if(t!=null&&t[x]||(h=(u=s==null?void 0:s.onClickFilter)==null?void 0:u.find(v=>v.columnIndex===x))!=null&&h.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(j=(p=s==null?void 0:s.onClickFilter)==null?void 0:p.find(v=>v.columnIndex===x))==null?void 0:j.expression,onChange:v=>c(x,v),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:o==null?void 0:o.map((x,u)=>{var h,p;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:!!((h=s==null?void 0:s.onClickFilter)!=null&&h.find(j=>j.columnIndex===u)),onCheckedChange:j=>l(u,j)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:x}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((p=s==null?void 0:s.onClickFilter)==null?void 0:p.find(j=>j.columnIndex===u))&&e.jsxRuntimeExports.jsx(qe,{onClick:()=>{r(j=>{const v=[...j];return v[u]=!j[u],v})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),d(u)]})},x)})})}function Ae(){var i,o;const t=e.useEditorStore(l=>l.card.preferences),r=e.useEditorStore(l=>l.card.cfg),{setCardCfg:s,setCardPreferences:n}=e.useEditorStore(l=>l.actions);(i=r==null?void 0:r.options)!=null&&i.indexAxis;function a(l){var x,u,h,p,j,v;let c={};(x=t==null?void 0:t.chartOptions)!=null&&x.scales&&(c={x:(h=(u=t==null?void 0:t.chartOptions)==null?void 0:u.scales)==null?void 0:h.y,y:(j=(p=t==null?void 0:t.chartOptions)==null?void 0:p.scales)==null?void 0:j.x});const d={...t,chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(v=t==null?void 0:t.chartOptions)==null?void 0:v.scales,...c},indexAxis:l}};n(d)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((o=t==null?void 0:t.chartOptions)==null?void 0:o.indexAxis)||"x",onValueChange:a,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 ce="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Oe(t,r){var n,a,i;const s=e.getNumberAxis(t,r);return((i=(a=(n=t==null?void 0:t.chartOptions)==null?void 0:n.scales)==null?void 0:a[s])==null?void 0:i.type)||"linear"}function tt(){var q,$,H,M,z,b;const[t,r]=E.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}),a=e.getNumberAxis(s,n),[i,o]=E.useState(Oe(s)),[l,c]=E.useState(((H=($=(q=s==null?void 0:s.chartOptions)==null?void 0:q.scales)==null?void 0:$[a])==null?void 0:H.min)||""),[d,x]=E.useState(((b=(z=(M=s==null?void 0:s.chartOptions)==null?void 0:M.scales)==null?void 0:z[a])==null?void 0:b.max)||""),[u,h]=E.useState(l||d?"custom":"auto"),[p,j]=E.useState(""),[v,y]=E.useState(""),[f,T]=E.useState(""),[w,k]=E.useState(""),[R,C]=E.useState(""),A=e.useEditorStore(g=>g.actions.setCardPreferences),D=e.useEditorStore(g=>{var N;return(N=g.card)==null?void 0:N.type}),_=["pie","doughnut","polarArea"].includes(D);E.useEffect(()=>{var g,N,L,Z,K,re,ne,oe,ee,B,P,Q,ie,U;o(Oe(s)),c(((L=(N=(g=s==null?void 0:s.chartOptions)==null?void 0:g.scales)==null?void 0:N[a])==null?void 0:L.min)===0?0:""),x(((re=(K=(Z=s==null?void 0:s.chartOptions)==null?void 0:Z.scales)==null?void 0:K[a])==null?void 0:re.max)||""),j(((B=(ee=(oe=(ne=s==null?void 0:s.chartOptions)==null?void 0:ne.scales)==null?void 0:oe[a])==null?void 0:ee.ticks)==null?void 0:B.stepSize)||""),y(((P=s==null?void 0:s.numberAxisFormat)==null?void 0:P.format)||""),T(((Q=s==null?void 0:s.numberAxisFormat)==null?void 0:Q.suffix)||""),k(((ie=s==null?void 0:s.numberAxisFormat)==null?void 0:ie.currency)||""),C(((U=s==null?void 0:s.numberAxisFormat)==null?void 0:U.locale)||"")},[t,s,a]);function F(g,N){return N===""||/^[0-9\b]+$/.test(N)?Number(N):Number(g)}function O(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[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:"Format"}),e.jsxRuntimeExports.jsx(e.Input,{value:v,placeholder:"000,0.00",onChange:g=>y(g.target.value),id:"format",className:`col-span-4 h-8 w-full tracking-wide ${ce}`}),e.jsxRuntimeExports.jsx(e.Input,{value:f,placeholder:"M",onChange:g=>T(g.target.value),id:"unit",className:`col-span-2 h-8 w-full ${ce}`})]}),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:w,placeholder:"USD",onChange:g=>k(g.target.value),id:"currency",className:`col-span-2 h-8 w-full ${ce}`}),e.jsxRuntimeExports.jsx(e.Input,{value:R,placeholder:"en-US",onChange:g=>C(g.target.value),id:"locale",className:`col-span-2 h-8 w-full ${ce}`})]})]})}function I(){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:l,onChange:g=>c(N=>F(N,g.target.value)),className:`col-span-1 h-8 w-full ${ce}`}),e.jsxRuntimeExports.jsx(e.Input,{value:d,onChange:g=>x(N=>F(N,g.target.value)),id:"max",className:`col-span-1 h-8 w-full ${ce}`})]}),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:p,onChange:g=>j(N=>F(N,g.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${ce}`})]})]})}function G(){var L;let g={};u==="custom"&&(g={min:l,max:d,ticks:{stepSize:p}});const N={...s||{},chartOptions:{...s==null?void 0:s.chartOptions,scales:{...(L=s==null?void 0:s.chartOptions)==null?void 0:L.scales,[a]:{type:i,...i==="linear"?g:{}}}},numberAxisFormat:{format:v,suffix:f,currency:w,locale:R}};A(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:_,value:i,onValueChange:g=>o(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"})]})})]})]}),i=="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:_,id:"scale-option",value:u,onValueChange:g=>h(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"})]})]})]}),u==="custom"&&i=="linear"&&I(),O(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:G,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function cs({idx:t}){var l;const r=e.useEditorStore(c=>{var d;return(d=c.card)==null?void 0:d.preferences}),s=e.useEditorStore(c=>{var d;return(d=c.card.preferences)==null?void 0:d.datasetOptions}),n=e.useEditorStore(c=>c.actions.setCardPreferences),a=(l=r==null?void 0:r.chartOptions)==null?void 0:l.indexAxis,i=s==null?void 0:s.find(c=>c.idx===t);function o(c,d){(c==="end"||c==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const x={display:c!=="none",align:c,anchor:c,clamp:!0};if(!i)n({...r,datasetOptions:[...s||[],{idx:d,datalabels:x}]});else{const u={...i};u.datalabels=x;const h=s==null?void 0:s.map(p=>p.idx===d?u:p);n({...r,datasetOptions:h})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(It,{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:()=>o("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:()=>o("start",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":a==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("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":a==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("end",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":a==="y"})})})]})})]})}function st(){const t=e.useEditorStore(c=>c.card),r=e.useEditorStore(c=>{var d,x,u;return(u=(x=(d=c==null?void 0:c.card)==null?void 0:d.preferences)==null?void 0:x.chartOptions)==null?void 0:u.indexAxis}),s=r==="y"?"Y axis":"X axis",n=r==="y"?"X axis":"Y axis",{keys:a,metricKeys:i,dimensionKeys:o}=e.getKeys(t.data||[]);let l=i;if(t.type==="stackedBar"){const c=e.pivotData({dataArray:t.data||[],groupKey:o[0],pivotKey:o[1],valueKey:l[0]}),{metricKeys:d}=e.getKeys(c);l=d}return a.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:o[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(tt,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:l.map((c,d)=>e.jsxRuntimeExports.jsx(xs,{col:c,idx:d},c))})]})]})}function xs({col:t,idx:r}){const s=e.useEditorStore(l=>{var c;return(c=l.card)==null?void 0:c.preferences}),n=e.useEditorStore(l=>{var c;return(c=l.card.preferences)==null?void 0:c.datasetOptions}),a=n==null?void 0:n.find(l=>l.idx===r),{setCardPreferences:i}=e.useEditorStore(l=>l.actions);function o(l){if(!a)i({...s,datasetOptions:[...n||[],{idx:r,type:l==="area"?"line":l,fill:l==="area"?"origin":""}]});else{const c={...a};c.type=l==="area"?"line":l,c.fill=l==="area"?"origin":"";const d=n==null?void 0:n.map(x=>x.idx===r?c:x);i({...s,datasetOptions:d})}}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(Ne,{onClick:()=>o("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ke,{onClick:()=>o("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(mt,{onClick:()=>o("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(cs,{idx:r})]})]})}function us({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(Ae,{}),e.jsxRuntimeExports.jsx(st,{})]})]}),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 Te(){var a,i,o;const t=e.useEditorStore(l=>l.card.cfg),r=e.useEditorStore(l=>l.actions.setCardCfg),s=e.useEditorStore(l=>l.card.type);function n(l){var x;const c={datalabels:{display:l!=="none",align:l,anchor:l,clamp:!0}},d={...t,options:{...t==null?void 0:t.options,plugins:{...(x=t==null?void 0:t.options)==null?void 0:x.plugins,...c}}};r(d),console.log(l)}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"}),s!=="pyramid"&&e.jsxRuntimeExports.jsx(tt,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(o=(i=(a=t==null?void 0:t.options)==null?void 0:a.plugins)==null?void 0:i.datalabels)==null?void 0:o.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 ds({cardType:t}){function r(s){const n="SELECT label, [group], x-axis, y-axis, radius FROM table",a="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:a}),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:i=>i.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(Te,{})})]}),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 ms={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},ps={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function hs(){const t=e.useEditorStore(r=>r.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:js(t)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(t)&&e.jsxRuntimeExports.jsx(Ae,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(t)&&e.jsxRuntimeExports.jsx(Te,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(t)&&e.jsxRuntimeExports.jsx(de,{})})]})}function js(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:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",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:" text-xs space-y-2",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(ms,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:" text-xs space-y-2",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:"text-blue-500 hover:underline mx-1",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(ps,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:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",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:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",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:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function fs(){var o,l,c;const t=e.useEditorStore(d=>d.card.preferences),r=e.useEditorStore(d=>d.actions.setCardPreferences),s=e.useEditorStore(d=>d.actions.setNumberFormat),n=e.useEditorStore(d=>{var x,u;return(u=(x=d.card.preferences)==null?void 0:x.formatNumber)==null?void 0:u.format}),a=e.useEditorStore(d=>{var x,u;return(u=(x=d.card.preferences)==null?void 0:x.formatNumber)==null?void 0:u.locale}),i=e.useEditorStore(d=>{var x,u;return(u=(x=d.card.preferences)==null?void 0:x.formatNumber)==null?void 0:u.currency});return e.useEditorStore(d=>d.actions.setFilterOnClickField),e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((o=t==null?void 0:t.formatNumber)!=null&&o.enabled),onCheckedChange:d=>{r({...t,formatNumber:{...t==null?void 0:t.formatNumber,enabled:d}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((l=t==null?void 0:t.formatNumber)==null?void 0:l.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-xs",children:"Currency"}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Input,{value:i||"",className:"h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"USD",onChange:d=>{var x,u,h;return s(((x=t==null?void 0:t.formatNumber)==null?void 0:x.format)||"",d.target.value,((u=t==null?void 0:t.formatNumber)==null?void 0:u.locale)||"",((h=t==null?void 0:t.formatNumber)==null?void 0:h.suffix)||"")}}),e.jsxRuntimeExports.jsx(e.Input,{value:a||"",className:"h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"en-US",onChange:d=>{var x,u,h;return s(((x=t==null?void 0:t.formatNumber)==null?void 0:x.format)||"",((u=t==null?void 0:t.formatNumber)==null?void 0:u.currency)||"",d.target.value,((h=t==null?void 0:t.formatNumber)==null?void 0:h.suffix)||"")}})]})]}),e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-xs",children:"Format"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(e.InfoCircledIcon,{strokeWidth:1,className:"h-3 w-3 opacity-70"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{children:e.jsxRuntimeExports.jsxs("div",{className:"max-w-[200px]",children:["Format number",e.jsxRuntimeExports.jsx("div",{className:"mt-1 font-mono text-xs",children:"#.## for 123.43"})]})})]})]}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(e.Input,{value:n||"",className:"h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"###,###.##",onChange:d=>{var x,u,h;return s(d.target.value,((x=t==null?void 0:t.formatNumber)==null?void 0:x.currency)||"",((u=t==null?void 0:t.formatNumber)==null?void 0:u.locale)||"",((h=t==null?void 0:t.formatNumber)==null?void 0:h.suffix)||"")}})})]}),e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-xs",children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((c=t==null?void 0:t.formatNumber)==null?void 0:c.suffix)||"",className:"h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B",onChange:d=>{var x,u,h;return s(((x=t==null?void 0:t.formatNumber)==null?void 0:x.format)||"",((u=t==null?void 0:t.formatNumber)==null?void 0:u.currency)||"",((h=t==null?void 0:t.formatNumber)==null?void 0:h.locale)||"",d.target.value)}})]})]})]})}function Es(){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(fs,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function Me({cardType:t,docContent:r}){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.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:s=>s.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.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(Te,{})})]}),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 gs(){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(Ae,{}),e.jsxRuntimeExports.jsx(st,{})]})]}),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 Rs({cardType:t}){return console.log("TableVisualSettings",t),e.jsxRuntimeExports.jsx("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,{})})]})})})}const bs=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."]})]});function ys(){const t=e.useEditorStore(s=>s.card.type);function r(s){switch(s){case"stackedBar":return e.jsxRuntimeExports.jsx(gs,{});case"pyramid":return e.jsxRuntimeExports.jsx(Me,{docContent:bs,cardType:s});case"kpi":return e.jsxRuntimeExports.jsx(Es,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(us,{cardType:s});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(Me,{cardType:s});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(ds,{cardType:s});case"table":return e.jsxRuntimeExports.jsx(Rs,{cardType:s});default:return e.jsxRuntimeExports.jsx(hs,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:r(t)})}function Ss(){const t=e.useEditorStore(r=>r.isShowingVisual);return e.jsxRuntimeExports.jsxs(ve,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[e.jsxRuntimeExports.jsx(ue,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(ts,{})}),e.jsxRuntimeExports.jsx(Ce,{withHandle:!0,className:"border "}),e.jsxRuntimeExports.jsx(ue,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:t?e.jsxRuntimeExports.jsxs(ve,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(ue,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx(ys,{})})}),e.jsxRuntimeExports.jsx(Ce,{className:"border "}),e.jsxRuntimeExports.jsx(ue,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(Fe,{})})]}):e.jsxRuntimeExports.jsx(Fe,{})})]})}function vs({authToken:t,onSave:r,onClose:s}){const n=e.useEditorStore(o=>o.actions.setOnSave),a=e.useEditorStore(o=>o.actions.setOnClose),i=e.useDashboardStore(o=>o.actions.setAuthToken);return E.useEffect(()=>{r&&n(r),s&&a(s)},[r,n,s,a]),E.useEffect(()=>{t&&t.accessToken&&i(t)},[t,i]),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(Ke,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(Ss,{})})]})}function Cs(){e.useDashboardStore(o=>o.selectedCardId);const t=e.useDashboardStore(o=>o.selectedSheetId),{setIsVisualEditing:r}=e.useDashboardStore(o=>o.actions),s=e.useDashboardStore(o=>o.isVisualEditing),n=e.useDashboardStore(o=>o.actions.updateFrame);function a(o){t&&(n(t,o),r(!1))}function i(){r(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:s,hidden:!s}),children:e.jsxRuntimeExports.jsx(vs,{onSave:a,onClose:i})})}function Ns({columns:t,tableName:r}){const s=e.useEditorStore(u=>u.selectedConnectionId),n=e.useEditorStore(u=>u.selectedDatabaseName),a=e.useEditorStore(u=>u.selectedSchemaName),i=e.useEditorStore(u=>u.selectedTableName),o=e.useDashboardStore(u=>u.dashboard.filters)||[],l=e.useDashboardStore(u=>u.actions.addFilter),c=e.useDashboardStore(u=>u.actions.removeFilter),d=e.useDashboardStore(u=>u.actions.removeFilterValue);function x(u){const h=e.fmt(u.column_name),p=e.fmt(n||""),j=e.fmt(a||""),v=e.fmt(r),y=e.getQualifiedTableName(j,v),f=`${y}.${h}`;console.log("find",f,v,p);const T=o==null?void 0:o.find(w=>w.column===f&&w.table===v&&(w.database===p||w.database===n));if(T)d(T.id),c(T.id);else{if(r==="api"&&s){l({id:e.v4(),column:f,title:u.column_name,dataType:u.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:e.getDefaultFilterSql(u.data_type,y,h)});return}l({id:e.v4(),column:`${y}.${h}`,title:u.column_name,dataType:u.data_type,table:i||"",database:n||"",connectionId:s||"",operation:"in",sql:e.getDefaultFilterSql(u.data_type,y,h)})}}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(u=>{const h=o==null?void 0:o.find(p=>p.column===e.fmt(u.column_name)&&p.table===i&&p.database===n);return e.jsxRuntimeExports.jsx("div",{onClick:()=>x(u),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":h}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx($e,{column:u}),e.jsxRuntimeExports.jsx("span",{children:u.column_name})]})},u.column_name)})})}function ks(){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(Ke,{ColumnsComponent:(r,s,n)=>e.jsxRuntimeExports.jsx(Ns,{schemaName:r,tableName:s,columns:n})})})]})}function ws(){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(ks,{})})]})}function As(){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 Ts({showControls:t=!1,showFooter:r=!0,...s}){return e.jsxRuntimeExports.jsx(e.SemaphorContextProvider,{dashboardProps:s,children:e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(As,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...s,children:[t&&e.jsxRuntimeExports.jsx(Bt,{}),e.jsxRuntimeExports.jsx(Cs,{}),e.jsxRuntimeExports.jsx(ws,{})]})]})})}exports.DashboardPlus=Ts;exports.SelectComponent=je;exports.useEditorAside=we;
|