react-semaphor 0.0.385 → 0.0.387

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/index.cjs CHANGED
@@ -1,227 +1,232 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./chunks/index-LX2lZe9q.js"),e=require("react/jsx-runtime"),C=require("react");require("react-dom");function gs(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const Ve=gs(C);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./chunks/index-6C0raQZK.js"),e=require("react/jsx-runtime"),S=require("react");require("react-dom");function gs(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const Le=gs(S);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const js=s.createLucideIcon("BookType",[["path",{d:"M10 13h4",key:"ytezjc"}],["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8V6H8v2",key:"x8j6u4"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/**
6
+ */const js=s.createLucideIcon("BookOpenText",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]]);/**
7
7
  * @license lucide-react v0.453.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const bs=s.createLucideIcon("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/**
11
+ */const bs=s.createLucideIcon("BookType",[["path",{d:"M10 13h4",key:"ytezjc"}],["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8V6H8v2",key:"x8j6u4"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/**
12
12
  * @license lucide-react v0.453.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const ys=s.createLucideIcon("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);/**
16
+ */const ys=s.createLucideIcon("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/**
17
17
  * @license lucide-react v0.453.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const Ss=s.createLucideIcon("ChartArea",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);/**
21
+ */const Ss=s.createLucideIcon("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);/**
22
22
  * @license lucide-react v0.453.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const ke=s.createLucideIcon("ChartColumnIncreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17V5",key:"sfb6ij"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
26
+ */const Cs=s.createLucideIcon("ChartArea",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);/**
27
27
  * @license lucide-react v0.453.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const He=s.createLucideIcon("ChartColumnStacked",[["path",{d:"M11 13H7",key:"t0o9gq"}],["path",{d:"M19 9h-4",key:"rera1j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/**
31
+ */const Se=s.createLucideIcon("ChartColumnIncreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17V5",key:"sfb6ij"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
32
32
  * @license lucide-react v0.453.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const Ee=s.createLucideIcon("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);/**
36
+ */const Re=s.createLucideIcon("ChartColumnStacked",[["path",{d:"M11 13H7",key:"t0o9gq"}],["path",{d:"M19 9h-4",key:"rera1j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/**
37
37
  * @license lucide-react v0.453.0 - ISC
38
38
  *
39
39
  * This source code is licensed under the ISC license.
40
40
  * See the LICENSE file in the root directory of this source tree.
41
- */const Ge=s.createLucideIcon("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/**
41
+ */const Ce=s.createLucideIcon("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);/**
42
42
  * @license lucide-react v0.453.0 - ISC
43
43
  *
44
44
  * This source code is licensed under the ISC license.
45
45
  * See the LICENSE file in the root directory of this source tree.
46
- */const Ue=s.createLucideIcon("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/**
46
+ */const qe=s.createLucideIcon("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/**
47
47
  * @license lucide-react v0.453.0 - ISC
48
48
  *
49
49
  * This source code is licensed under the ISC license.
50
50
  * See the LICENSE file in the root directory of this source tree.
51
- */const $e=s.createLucideIcon("ChartScatter",[["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 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/**
51
+ */const Be=s.createLucideIcon("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/**
52
52
  * @license lucide-react v0.453.0 - ISC
53
53
  *
54
54
  * This source code is licensed under the ISC license.
55
55
  * See the LICENSE file in the root directory of this source tree.
56
- */const Cs=s.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"}]]);/**
56
+ */const _e=s.createLucideIcon("ChartScatter",[["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 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/**
57
57
  * @license lucide-react v0.453.0 - ISC
58
58
  *
59
59
  * This source code is licensed under the ISC license.
60
60
  * See the LICENSE file in the root directory of this source tree.
61
- */const vs=s.createLucideIcon("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
61
+ */const vs=s.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"}]]);/**
62
62
  * @license lucide-react v0.453.0 - ISC
63
63
  *
64
64
  * This source code is licensed under the ISC license.
65
65
  * See the LICENSE file in the root directory of this source tree.
66
- */const Ns=s.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"}]]);/**
66
+ */const Ns=s.createLucideIcon("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
67
67
  * @license lucide-react v0.453.0 - ISC
68
68
  *
69
69
  * This source code is licensed under the ISC license.
70
70
  * See the LICENSE file in the root directory of this source tree.
71
- */const Qe=s.createLucideIcon("Donut",[["path",{d:"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3",key:"19sr3x"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
71
+ */const ws=s.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"}]]);/**
72
72
  * @license lucide-react v0.453.0 - ISC
73
73
  *
74
74
  * This source code is licensed under the ISC license.
75
75
  * See the LICENSE file in the root directory of this source tree.
76
- */const De=s.createLucideIcon("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/**
76
+ */const Pe=s.createLucideIcon("Donut",[["path",{d:"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3",key:"19sr3x"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
77
77
  * @license lucide-react v0.453.0 - ISC
78
78
  *
79
79
  * This source code is licensed under the ISC license.
80
80
  * See the LICENSE file in the root directory of this source tree.
81
- */const ws=s.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"}]]);/**
81
+ */const He=s.createLucideIcon("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/**
82
82
  * @license lucide-react v0.453.0 - ISC
83
83
  *
84
84
  * This source code is licensed under the ISC license.
85
85
  * See the LICENSE file in the root directory of this source tree.
86
- */const ks=s.createLucideIcon("EyeClosed",[["path",{d:"m15 18-.722-3.25",key:"1j64jw"}],["path",{d:"M2 8a10.645 10.645 0 0 0 20 0",key:"1e7gxb"}],["path",{d:"m20 15-1.726-2.05",key:"1cnuld"}],["path",{d:"m4 15 1.726-2.05",key:"1dsqqd"}],["path",{d:"m9 18 .722-3.25",key:"ypw2yx"}]]);/**
86
+ */const ks=s.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"}]]);/**
87
87
  * @license lucide-react v0.453.0 - ISC
88
88
  *
89
89
  * This source code is licensed under the ISC license.
90
90
  * See the LICENSE file in the root directory of this source tree.
91
- */const Es=s.createLucideIcon("FileJson2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"fq0c9t"}],["path",{d:"M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"4gibmv"}]]);/**
91
+ */const Es=s.createLucideIcon("EyeClosed",[["path",{d:"m15 18-.722-3.25",key:"1j64jw"}],["path",{d:"M2 8a10.645 10.645 0 0 0 20 0",key:"1e7gxb"}],["path",{d:"m20 15-1.726-2.05",key:"1cnuld"}],["path",{d:"m4 15 1.726-2.05",key:"1dsqqd"}],["path",{d:"m9 18 .722-3.25",key:"ypw2yx"}]]);/**
92
92
  * @license lucide-react v0.453.0 - ISC
93
93
  *
94
94
  * This source code is licensed under the ISC license.
95
95
  * See the LICENSE file in the root directory of this source tree.
96
- */const Ds=s.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"}]]);/**
96
+ */const Ds=s.createLucideIcon("FileJson2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"fq0c9t"}],["path",{d:"M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"4gibmv"}]]);/**
97
97
  * @license lucide-react v0.453.0 - ISC
98
98
  *
99
99
  * This source code is licensed under the ISC license.
100
100
  * See the LICENSE file in the root directory of this source tree.
101
- */const Is=s.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"}]]);/**
101
+ */const Is=s.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"}]]);/**
102
102
  * @license lucide-react v0.453.0 - ISC
103
103
  *
104
104
  * This source code is licensed under the ISC license.
105
105
  * See the LICENSE file in the root directory of this source tree.
106
- */const Ts=s.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"}]]);/**
106
+ */const Ts=s.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"}]]);/**
107
107
  * @license lucide-react v0.453.0 - ISC
108
108
  *
109
109
  * This source code is licensed under the ISC license.
110
110
  * See the LICENSE file in the root directory of this source tree.
111
- */const As=s.createLucideIcon("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/**
111
+ */const As=s.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"}]]);/**
112
112
  * @license lucide-react v0.453.0 - ISC
113
113
  *
114
114
  * This source code is licensed under the ISC license.
115
115
  * See the LICENSE file in the root directory of this source tree.
116
- */const Ls=s.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"}]]);/**
116
+ */const Ls=s.createLucideIcon("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/**
117
117
  * @license lucide-react v0.453.0 - ISC
118
118
  *
119
119
  * This source code is licensed under the ISC license.
120
120
  * See the LICENSE file in the root directory of this source tree.
121
- */const Os=s.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"}]]);/**
121
+ */const Os=s.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"}]]);/**
122
122
  * @license lucide-react v0.453.0 - ISC
123
123
  *
124
124
  * This source code is licensed under the ISC license.
125
125
  * See the LICENSE file in the root directory of this source tree.
126
- */const Ms=s.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"}]]);/**
126
+ */const Ms=s.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"}]]);/**
127
127
  * @license lucide-react v0.453.0 - ISC
128
128
  *
129
129
  * This source code is licensed under the ISC license.
130
130
  * See the LICENSE file in the root directory of this source tree.
131
- */const xe=s.createLucideIcon("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
131
+ */const zs=s.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"}]]);/**
132
132
  * @license lucide-react v0.453.0 - ISC
133
133
  *
134
134
  * This source code is licensed under the ISC license.
135
135
  * See the LICENSE file in the root directory of this source tree.
136
- */const zs=s.createLucideIcon("Logs",[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]]);/**
136
+ */const ue=s.createLucideIcon("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
137
137
  * @license lucide-react v0.453.0 - ISC
138
138
  *
139
139
  * This source code is licensed under the ISC license.
140
140
  * See the LICENSE file in the root directory of this source tree.
141
- */const Je=s.createLucideIcon("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/**
141
+ */const Fs=s.createLucideIcon("Logs",[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]]);/**
142
142
  * @license lucide-react v0.453.0 - ISC
143
143
  *
144
144
  * This source code is licensed under the ISC license.
145
145
  * See the LICENSE file in the root directory of this source tree.
146
- */const Fs=s.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"}]]);/**
146
+ */const Ge=s.createLucideIcon("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/**
147
147
  * @license lucide-react v0.453.0 - ISC
148
148
  *
149
149
  * This source code is licensed under the ISC license.
150
150
  * See the LICENSE file in the root directory of this source tree.
151
- */const Vs=s.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"}]]);/**
151
+ */const Vs=s.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"}]]);/**
152
152
  * @license lucide-react v0.453.0 - ISC
153
153
  *
154
154
  * This source code is licensed under the ISC license.
155
155
  * See the LICENSE file in the root directory of this source tree.
156
- */const Rs=s.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 0Z",key:"wtfw2c"}]]);/**
156
+ */const Rs=s.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"}]]);/**
157
157
  * @license lucide-react v0.453.0 - ISC
158
158
  *
159
159
  * This source code is licensed under the ISC license.
160
160
  * See the LICENSE file in the root directory of this source tree.
161
- */const We=s.createLucideIcon("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/**
161
+ */const qs=s.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 0Z",key:"wtfw2c"}]]);/**
162
162
  * @license lucide-react v0.453.0 - ISC
163
163
  *
164
164
  * This source code is licensed under the ISC license.
165
165
  * See the LICENSE file in the root directory of this source tree.
166
- */const qs=s.createLucideIcon("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
166
+ */const Ue=s.createLucideIcon("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/**
167
167
  * @license lucide-react v0.453.0 - ISC
168
168
  *
169
169
  * This source code is licensed under the ISC license.
170
170
  * See the LICENSE file in the root directory of this source tree.
171
- */const Bs=s.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"}]]);/**
171
+ */const Bs=s.createLucideIcon("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
172
172
  * @license lucide-react v0.453.0 - ISC
173
173
  *
174
174
  * This source code is licensed under the ISC license.
175
175
  * See the LICENSE file in the root directory of this source tree.
176
- */const Ke=s.createLucideIcon("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/**
176
+ */const _s=s.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"}]]);/**
177
177
  * @license lucide-react v0.453.0 - ISC
178
178
  *
179
179
  * This source code is licensed under the ISC license.
180
180
  * See the LICENSE file in the root directory of this source tree.
181
- */const _s=s.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"}]]);/**
181
+ */const $e=s.createLucideIcon("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/**
182
182
  * @license lucide-react v0.453.0 - ISC
183
183
  *
184
184
  * This source code is licensed under the ISC license.
185
185
  * See the LICENSE file in the root directory of this source tree.
186
- */const Ps=s.createLucideIcon("Sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]);/**
186
+ */const Ps=s.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"}]]);/**
187
187
  * @license lucide-react v0.453.0 - ISC
188
188
  *
189
189
  * This source code is licensed under the ISC license.
190
190
  * See the LICENSE file in the root directory of this source tree.
191
- */const Ie=s.createLucideIcon("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/**
191
+ */const Hs=s.createLucideIcon("Sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]);/**
192
192
  * @license lucide-react v0.453.0 - ISC
193
193
  *
194
194
  * This source code is licensed under the ISC license.
195
195
  * See the LICENSE file in the root directory of this source tree.
196
- */const Hs=s.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"}]]);/**
196
+ */const ve=s.createLucideIcon("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/**
197
197
  * @license lucide-react v0.453.0 - ISC
198
198
  *
199
199
  * This source code is licensed under the ISC license.
200
200
  * See the LICENSE file in the root directory of this source tree.
201
- */const Gs=s.createLucideIcon("TicketX",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
201
+ */const Gs=s.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"}]]);/**
202
202
  * @license lucide-react v0.453.0 - ISC
203
203
  *
204
204
  * This source code is licensed under the ISC license.
205
205
  * See the LICENSE file in the root directory of this source tree.
206
- */const Us=s.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"}]]);/**
206
+ */const Us=s.createLucideIcon("TicketX",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
207
207
  * @license lucide-react v0.453.0 - ISC
208
208
  *
209
209
  * This source code is licensed under the ISC license.
210
210
  * See the LICENSE file in the root directory of this source tree.
211
- */const Xe=s.createLucideIcon("Tornado",[["path",{d:"M21 4H3",key:"1hwok0"}],["path",{d:"M18 8H6",key:"41n648"}],["path",{d:"M19 12H9",key:"1g4lpz"}],["path",{d:"M16 16h-6",key:"1j5d54"}],["path",{d:"M11 20H9",key:"39obr8"}]]);/**
211
+ */const $s=s.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"}]]);/**
212
212
  * @license lucide-react v0.453.0 - ISC
213
213
  *
214
214
  * This source code is licensed under the ISC license.
215
215
  * See the LICENSE file in the root directory of this source tree.
216
- */const Ye=s.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"}]]);function Te(t){var n;return{...t,sheets:(n=t==null?void 0:t.sheets)==null?void 0:n.map(a=>{var r;return{...a,frames:(r=a.frames)==null?void 0:r.map(o=>{var i;return{...o,cards:(i=o.cards)==null?void 0:i.map(l=>Ze(l))}})}})}}function Ze(t){var n,a,r,o;return{...t,cfg:{...t.cfg,data:{...(n=t.cfg)==null?void 0:n.data,labels:[],datasets:(o=(r=(a=t.cfg)==null?void 0:a.data)==null?void 0:r.datasets)==null?void 0:o.map(i=>({...i,data:[]}))}},customCfg:$s(t.customCfg),data:[]}}function $s(t){var n,a;return t?{...t,data:{...t==null?void 0:t.data,labels:[],datasets:(a=(n=t==null?void 0:t.data)==null?void 0:n.datasets)==null?void 0:a.map(r=>({...r,data:[]}))}}:null}async function Qs(t,n,a,r){if(!r)return null;const o=JSON.stringify(n);return await s.postRequest("https://semaphor.cloud/api/v1/lens",r,{name:t,template:o,filterValues:a,operation:"create"})}async function we(t,n){if(!n)return null;const{id:a,template:r,filterValues:o,isDefault:i,shared:l}=t;return await s.postRequest("https://semaphor.cloud/api/v1/lens",n,{lensId:a,template:r,filterValues:o,isDefault:i,shared:l,operation:"update"})}async function Js(t,n){return n?await s.postRequest("https://semaphor.cloud/api/v1/lens",n,{operation:"delete",lensId:t}):null}function Ws(){const[t,n]=C.useState(""),[a,r]=C.useState(!1),o=s.useDashboardStore(f=>f.lenses),{setLenses:i,setSelectedLensId:l}=s.useDashboardActions(),[c,d]=C.useState(!1),[u,x]=C.useState(!1),j=s.useDashboardStore(f=>f.dashboard),b=s.useDashboardStore(f=>f.filterValues),{authToken:m}=s.useSemaphorContext();async function p(){d(!0);const f=Te(j),k=await Qs(t,f,b,m==null?void 0:m.accessToken);k&&(i([...o||[],k]),l(k.id),x(!1)),d(!1)}return e.jsxs(s.Dialog,{open:u,onOpenChange:x,children:[e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4",strokeWidth:1.5}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Create Lens"}),e.jsx(s.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsx(s.Label,{className:"text-right",children:"Name"}),e.jsx(s.Input,{value:t,onChange:f=>{n(f.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),a&&e.jsx("p",{className:"text-sm",children:"The lens name already exists. Use a differnet name."}),e.jsx(s.DialogFooter,{children:e.jsx(s.Button,{size:"sm",variant:"outline",type:"submit",onClick:p,disabled:c,children:c?"Creating...":"Add"})})]})]})}function Ks(){const[t,n]=C.useState(!1),a=s.useDashboardStore(x=>x.lenses),r=s.useDashboardStore(x=>x.selectedLensId),{setLenses:o,setSelectedLensId:i}=s.useDashboardActions(),{authToken:l}=s.useSemaphorContext();async function c(x){i(x)}async function d(x){if(await Js(x,l==null?void 0:l.accessToken)){const b=a==null?void 0:a.filter(m=>m.id!==x);o(b||[]),i("original")}}async function u(x){const j=a==null?void 0:a.map(p=>p.id===x.id?{...p,isDefault:!x.isDefault}:{...p,isDefault:!1});o(j||[]);const b={...x,isDefault:!x.isDefault};await we(b,l==null?void 0:l.accessToken);const m=a==null?void 0:a.find(p=>p.isDefault);if(m&&m.id!==x.id){const p={...m,isDefault:!1};await we(p,l==null?void 0:l.accessToken)}}return e.jsxs(s.DropdownMenu,{open:t,onOpenChange:n,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",className:"h-7 p-2",children:e.jsx(Ds,{className:"h-4 w-4",strokeWidth:1.5})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-60",children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuRadioGroup,{value:r,onValueChange:c,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(x=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:x.id,children:[e.jsx("p",{children:x.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(As,{onClick:j=>{j.preventDefault(),u(x)},className:s.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!x.isDefault,"text-green-500":x.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:j=>{j.preventDefault(),d(x.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},x.id))]})]})]})}async function es(){var m;const t=s.useDashboardStore.getState().authToken,n=s.useDashboardStore.getState().theme,a=s.useDashboardStore.getState().filterValues,r=(m=s.useDashboardStore.getState().dashboard)==null?void 0:m.title,o=s.useDashboardStore.getState().isDownloadingPdf,i=s.useDashboardStore.getState().selectedSheetId;if(o)return;const l=new URLSearchParams;l.set("token",(t==null?void 0:t.accessToken)||""),l.set("theme",n||"light"),l.set("filterValues",JSON.stringify(a)),l.set("selectedSheetId",i||"");const c=`https://semaphor.cloud/api/v1/generate-pdf?params=${encodeURIComponent(l.toString())}`;s.useDashboardStore.setState({isDownloadingPdf:!0});const x=(await(await fetch(c,{method:"GET",headers:{Authorization:`Bearer ${t==null?void 0:t.accessToken}`}})).json()).url,j=document.createElement("a");j.href=x;const b=`${r}-${new Date().toISOString()}.pdf`;j.download=b,j.click(),s.useDashboardStore.setState({isDownloadingPdf:!1})}function Xs({iconClassName:t}){const{authToken:n}=s.useSemaphorContext();s.useDashboardStore(o=>{var i;return(i=o.dashboard)==null?void 0:i.title}),s.useDashboardStore(o=>o.theme),s.useDashboardStore(o=>o.filterValues);const a=s.useDashboardStore(o=>o.isDownloadingPdf);async function r(){await es()}return e.jsx(s.Button,{variant:"link",className:"group h-7 p-2",size:"sm",onClick:r,children:a?e.jsx(xe,{className:s.cn("size-3.5 animate-spin",t)}):e.jsx(s.Download,{className:s.cn("size-3.5",t),strokeWidth:1.5})})}function Ys(){const{authToken:t}=s.useSemaphorContext();s.useDashboardStore(h=>h.theme);const n=s.useDashboardStore(h=>h.lenses),a=s.useDashboardStore(h=>h.selectedLensId),r=n==null?void 0:n.find(h=>h.id===a),o=s.useDashboardStore(h=>h.dashboard);s.useDashboardStore(h=>h.selectedSheetId);const i=s.useDashboardStore(h=>h.isDashboardEditing),l=s.useEditorStore(h=>h.selectedConnectionId),[c,d]=C.useState(!1),u=s.useDashboardStore(h=>h.filterValues),x=s.useDashboardStore(h=>h.isVisualEditing),j=s.useDashboardStore(h=>h.showFilters);s.useDashboardStore(h=>h.showDashboardJSON);const b=s.useDashboardStore(h=>h.onSaveFunction),m=s.useDashboardStore(h=>h.actions.setShowFilters),{addFrame:p,setSelectedFrameId:f}=s.useDashboardStore(h=>h.actions),{getSelectedSheet:k,setIsDashboardEditing:y,setShowDashboardJSON:L}=s.useDashboardStore(h=>h.actions),w=k(),{tenantId:T,endUserId:E}=C.useMemo(()=>s.getTenantAndEndUserId(t==null?void 0:t.accessToken),[t==null?void 0:t.accessToken]),O=C.useMemo(()=>T||E,[T,E]),R=()=>{if(!i||!w)return;const h={connectionId:l,id:s.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]},g={id:s.v4(),cards:[h],activeCardId:h.id};p(w.id,g),f(g.id)},F=()=>{y(!0)};async function q(){if(d(!0),!a||!r)return;const h=Te(o),g=JSON.stringify(h),I={...r,template:g,filterValues:u};await we(I,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),b==null||b(h),d(!1)}return x?null:e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b bg-muted/50 py-2 pl-3 pr-2",role:"dashboard-controls",children:[!x&&e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(s.Label,{children:r==null?void 0:r.name})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:s.invalidateToken,children:e.jsx(Gs,{className:"h-4 w-4",strokeWidth:1.5})}),e.jsx(Xs,{}),i&&!x&&O&&e.jsx(Ws,{}),!x&&O&&e.jsx(Ks,{}),i&&!x&&e.jsxs(s.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",disabled:!i,onClick:R,children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4",strokeWidth:1.5}),"Frame"]}),!i&&e.jsx(s.Button,{variant:"ghost",className:"h-7 p-2",onClick:F,size:"sm",children:e.jsx(s.Pencil,{className:"h-4 w-4",strokeWidth:1.5})}),i&&!x&&e.jsx(s.Button,{variant:"ghost",role:"close",className:"h-7 p-2",onClick:()=>{y(!1),L(!1)},size:"sm",children:e.jsx(s.Cross2Icon,{className:"h-4 w-4",strokeWidth:1.5})}),i&&!x&&O&&e.jsx(s.Button,{className:"h-7 p-2",variant:"ghost",disabled:c,onClick:q,size:"sm",children:e.jsx(Bs,{className:"h-4 w-4",strokeWidth:1.5})}),!j&&!x&&i&&e.jsx(s.Button,{className:"h-7 p-2",variant:"ghost",onClick:()=>m(!0),size:"sm",children:e.jsx(s.Filter,{className:"h-4 w-4",strokeWidth:1.5})}),!x&&i&&!1,!x&&!1]})]})}function ce({title:t,items:n,value:a,isLoading:r,isError:o,refetch:i,connectionTooltip:l,onChange:c,showNone:d=!1,className:u,showIcon:x=!0,disabled:j=!1}){const b=r?"Loading...":o?"Error":a;function m(){if(t==="Connection")return e.jsx(Rs,{className:"size-4 rotate-90"});if(t==="Database")return e.jsx(Ns,{className:"size-4"});if(t==="Schema")return e.jsx(Vs,{className:"size-4"});if(t==="Table")return e.jsx(Ie,{className:"size-4"});if(t==="Model")return e.jsx(bs,{className:"size-4"})}return e.jsxs("div",{className:"flex items-center gap-2",children:[x&&e.jsx("div",{className:"shrink-0",children:l?e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{children:m()}),e.jsx(s.TooltipContent,{className:"text-xs",align:"start",children:l})]}):m()}),e.jsxs(s.Select,{disabled:j,value:b,onValueChange:c,children:[e.jsx(s.SelectTrigger,{className:s.cn("h-9 w-full focus:ring-1 focus:ring-offset-0",u),children:e.jsx(s.SelectValue,{placeholder:r?"Loading...":o?"Error":`Select ${t}`})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[r?e.jsx(s.SelectLabel,{children:"Loading..."}):e.jsxs(s.SelectLabel,{className:"flex items-center justify-between gap-2",children:[t,e.jsx(qs,{className:"mr-1 size-3 cursor-pointer text-muted-foreground hover:text-foreground",onClick:i})]}),e.jsxs(e.Fragment,{children:[d&&e.jsx(s.SelectItem,{value:"none",children:"None"},"none"),n&&n.map((p,f)=>e.jsx(s.SelectItem,{value:p.id,children:p.name},f))]}),(r||o)&&e.jsx(s.SelectItem,{value:b,children:b})]})})]})]})}function Zs({column:t}){const[n,a]=C.useState(!1),r=s.useEditorStore(p=>p.selectedTableName),o=s.useEditorStore(p=>p.selectedSchemaName),i=s.useEditorStore(p=>p.selectedDatamodelId),l=s.useEditorStore(p=>p.sqlGen),{modelItems:c,connectionType:d}=re(),u=s.useEditorStore(p=>p.actions.setSqlGen),x=s.useEditorStore(p=>p.actions.setCardSql),j=s.useEditorStore(p=>p.actions.setRunSql);function b(p,f){var w;const k=s.createSqlGenConfig(p,l,f),y=(w=c==null?void 0:c.find(T=>T.id===i))==null?void 0:w.name;u(k);const L=s.getSql(k,s.fmt(o||""),s.fmt(r),y,d);L&&(x(L),j(!0)),a(!1)}function m(){return e.jsxs("ul",{className:"text-xs",children:[e.jsx("li",{onClick:()=>b(t,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),e.jsx("li",{onClick:()=>b(t,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),e.jsx("li",{onClick:()=>b(t,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),e.jsx("li",{onClick:()=>b(t,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),e.jsx("li",{onClick:()=>b(t,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})}return e.jsxs(s.HoverCard,{openDelay:0,open:n,onOpenChange:a,children:[e.jsx(s.HoverCardTrigger,{asChild:!0,children:e.jsx(De,{className:"invisible size-3.5 cursor-pointer text-foreground/40 group-hover:visible"})}),e.jsx(s.HoverCardContent,{align:"center",className:"w-20 rounded-md p-0 shadow-none",children:m()})]})}function ss({column:t}){return e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger$1,{asChild:!0,children:s.isTextDataType(t.data_type)?e.jsx(Ye,{className:"size-3"}):s.isNumberDataType(t.data_type)?e.jsx(Ts,{className:"size-3"}):s.isDateDataType(t.data_type)?e.jsx(s.Calendar,{className:"size-3"}):s.isBooleanDataType(t.data_type)?e.jsx(Us,{className:"size-3"}):t.data_type.toLowerCase()==="json"?e.jsx(ys,{className:"size-3"}):e.jsx(_s,{className:"size-3"})}),e.jsx(s.TooltipContent,{children:e.jsx("p",{className:"font-mono text-xs",children:t.data_type})})]})}function et({schemaName:t,tableName:n,columns:a,status:r}){const o=s.useEditorStore(h=>h.sqlGen),i=s.useEditorStore(h=>h.selectedConnectionId),l=s.useEditorStore(h=>h.selectedDatabaseName),c=s.useEditorStore(h=>h.selectedSchemaName),d=s.useEditorStore(h=>h.selectedTableName),u=s.useEditorStore(h=>h.selectedDatamodelId),x=s.useDashboardStore(h=>h.dashboard.aiScopeTables),{addToAIScope:j,removeFromAIScope:b}=s.useDashboardActions(),{setAIScopeTables:m}=s.useDashboardStore(h=>h.actions),p=s.useEditorStore(h=>h.actions.setRunSql),f=s.useEditorStore(h=>h.actions.setSqlGen),k=s.useEditorStore(h=>h.actions.setIsShowingVisual),y=s.useEditorStore(h=>h.actions.setCardSql),{connectionType:L,modelItems:w,selectedDatamodelName:T}=re();function E(h){var M;const g=s.createSqlGenConfig(h,o);f(g);const I=(M=w==null?void 0:w.find(B=>B.id===u))==null?void 0:M.name,v=s.getSql(g,s.fmt(t),s.fmt(n),I,L);v&&(y(v),p(!0))}function O(){return(x==null?void 0:x.find(h=>h.connectionId===i&&(h.tableName===d||h.datamodelName===T)))!==void 0}function R(h){h===!0&&(d||T)&&i?(j({connectionId:i,connectionType:L==="S3"||L==="API"?"DuckDb":L,databaseName:l||"",schemaName:c||"",tableName:d||"",datamodelName:T||"",datamodelId:u||""}),s.ue.success("Added to Assistant Scope",{position:"top-right",duration:2500,richColors:!0})):(b({connectionId:i||"",connectionType:L||"",tableName:d||"",datamodelName:T||"",datamodelId:u||"",databaseName:l||"",schemaName:c||""}),s.ue("Removed from Assistant Scope",{position:"top-right",duration:2e3,richColors:!0}))}function F(){const h=s.getFormattedTableNameForQuery({schemaName:t,tableName:n,modelName:T,connectionType:L});k(!1);const g=L==="MSSQL"?`SELECT top 10 * FROM ${h}`:`SELECT * FROM ${h} LIMIT 10`;y(g),p(!0)}function q(){const h=s.getFormattedTableNameForQuery({schemaName:t,tableName:n,modelName:T,connectionType:L});y(`SELECT COUNT(*) as count FROM ${h}`),p(!0)}return e.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[e.jsxs("div",{className:"mx-2 flex items-center justify-center gap-2",children:[e.jsxs(s.Toggle,{title:`${O()?"Remove from":"Add to"} Assistant Scope`,pressed:O(),onPressedChange:R,variant:"outline",className:s.cn("h-9 px-2",{}),children:[e.jsx(s.Plus,{className:s.cn("mr-1 size-4",{"text-green-400":O(),"text-muted-foreground":!O()})}),"AI"]}),e.jsxs(s.Button,{disabled:r!=="Success",onClick:F,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsx(xe,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(zs,{className:"mr-2 size-4"}),"Top 10"]}),e.jsxs(s.Button,{disabled:r!=="Success",onClick:q,size:"sm",variant:"secondary",className:"w-full",children:[r!=="Success"?e.jsx(xe,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(Ps,{className:"mr-2 size-4"}),"Count"]})]}),e.jsxs(s.ScrollArea,{className:"flex-1 basis-0 border-b border-t border-muted py-3",children:[e.jsx("div",{className:"flex flex-col gap-1",children:a==null?void 0:a.map(h=>e.jsxs("div",{onClick:()=>E(h),className:s.cn("group mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-1 text-sm transition-colors hover:bg-muted/50",{"border border-dashed border-muted-foreground bg-muted":s.isColumnInSqlGen(h,o)}),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ss,{column:h}),e.jsx("span",{children:h.column_name})]}),e.jsx("div",{onClick:g=>g.stopPropagation(),className:"flex items-center justify-end",children:s.isNumberDataType(h.data_type)&&e.jsx(Zs,{column:h})})]},h.column_name))}),e.jsx(s.ScrollBar,{orientation:"vertical"}),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})]})}function re(t,n){var je,Le,Oe,Me,ze,Fe;let a=C.useMemo(()=>[],[]);const r=s.useSemaphorContext().authToken||t,o=s.useEditorStore(N=>N.selectedConnectionId),i=s.useEditorStore(N=>N.selectedDatamodelId),l=s.useEditorStore(N=>N.selectedDatabaseName),c=s.useEditorStore(N=>N.selectedSchemaName),d=s.useEditorStore(N=>N.selectedTableName),u=s.useEditorStore(N=>N.actions.setCurrentColumns),x=s.useEditorStore(N=>N.actions.setSelectedConnectionId),j=s.useEditorStore(N=>N.actions.setSelectedDatamodelId),b=s.useEditorStore(N=>N.actions.setSelectedDatabaseName),m=s.useEditorStore(N=>N.actions.setSelectedSchemaName),p=s.useEditorStore(N=>N.actions.setSelectedTableName);s.useEditorStore(N=>N.actions.setCardSql);function f(N){return o&&l&&c&&l!=="NA"?!0:o&&N==="API"?!1:!!(o&&N==="S3")}function k(N){return!!(o&&l&&l!=="NA"&&c&&d||o&&(N==="S3"||N==="API")||i&&i)}function y(N){return o&&N?!(N==="API"||N==="S3"):!1}const{refetch:L,data:w,isLoading:T,isError:E}=s.useQuery({queryKey:["connections"],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/connections",(r==null?void 0:r.accessToken)||""),enabled:!!(r!=null&&r.accessToken)}),{refetch:O,data:R,isLoading:F,isError:q}=s.useQuery({queryKey:["models",o],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/datamodels",(r==null?void 0:r.accessToken)||"",{connection_id:o}),enabled:!!(r!=null&&r.accessToken)&&!!o}),h=w==null?void 0:w.connections.find(N=>N.id===o),g=h==null?void 0:h.type,I=(h==null?void 0:h.type)==="API"||(h==null?void 0:h.type)==="S3",{data:v,isLoading:M,isFetching:B,isError:_,refetch:G}=s.useQuery({queryKey:["databases",o],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/databases",(r==null?void 0:r.accessToken)||"",{connection_id:o}),enabled:y(g)}),{data:H,isLoading:Q,isFetching:Z,isError:P,refetch:z}=s.useQuery({queryKey:["schemas",o,l],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/schemas",(r==null?void 0:r.accessToken)||"",{connection_id:o,database_name:l}),enabled:!!o&&!!l&&!I&&l!=="NA"}),{data:A,isLoading:X,isFetching:J,isError:W,refetch:K}=s.useQuery({queryKey:["tables",o,l,c],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/tables",(r==null?void 0:r.accessToken)||"",{connection_id:o,database_name:l,schema_name:c}),enabled:f(g)}),{data:$,isLoading:se,isFetching:ee,isError:S,refetch:V}=s.useQuery({queryKey:["columns",o,l,i,c,d],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/columns",(r==null?void 0:r.accessToken)||"",{connection_id:o,datamodel_id:i||"",database_name:l,schema_name:c,table_name:d}),enabled:k(g)});C.useEffect(()=>{u(a)},[$,u,a]),C.useEffect(()=>{(g==="S3"||g==="API")&&(b(""),m(""),j(""),g==="API"&&p("api"))},[g,p,b,m,j]);const U=(h==null?void 0:h.type)==="API"?(je=h==null?void 0:h.type)==null?void 0:je.toLowerCase():d||"",ne=I?"":c||"";function le(N){m(N),p("")}function pe(N){b(N==="none"?"":N),m(""),p(""),N!=="none"&&N!==""&&j("")}function fe(N){x(N)}function D(N){j(N==="none"?"":N),N!=="none"&&N!==""&&b("")}v&&((Le=v==null?void 0:v.databases)==null?void 0:Le.length)>0,H&&((Oe=H==null?void 0:H.schemas)==null?void 0:Oe.length)>0,$&&((Me=$==null?void 0:$.columns)==null?void 0:Me.length)>0&&(a=$.columns.map(N=>({...N,data_type:N.data_type.toLowerCase()}))),_&&(a=[]),(S||E)&&(a=[]);const Y=w==null?void 0:w.connections.map(N=>({id:N.id,name:N.name,type:N.type})),oe=(ze=R==null?void 0:R.datamodels)==null?void 0:ze.map(N=>({id:N.id,name:N.name})),te=v==null?void 0:v.databases.map(N=>({id:N.database_name,name:N.database_name})),me=H==null?void 0:H.schemas.map(N=>({id:N.schema_name,name:N.schema_name})),Ne=A==null?void 0:A.tables.map(N=>({id:N.table_name,name:N.table_name})),ge=(Fe=R==null?void 0:R.datamodels.find(N=>N.id===i))==null?void 0:Fe.name;return{connectionItems:Y,isConnectionsLoading:T,isConnectionsError:E,modelItems:oe,selectedDatamodelId:i,selectedDatamodelName:ge,isModelsLoading:F,isModelsError:q,databaseItems:te,isDatabasesLoadingOrFetching:M||B,isDatabaseError:_,schemaItems:me,isSchemaLoadingOrFetching:Q||Z,isSchemaError:P,tableItems:Ne,isTableLoadingOrFetching:X||J,isTableError:W,columns:a,isColumnsLoadingOrFetching:se||ee,isColumnsError:S,isNonDbConnection:I,connectionType:g,tableName:U,schemaName:ne,refetchConnections:L,refetchModels:O,refetchDatabases:G,refetchSchemas:z,refetchTables:K,refetchColumns:V,handleConnectionChange:fe,handleDatamodelChange:D,handleDatabaseChange:pe,handleSchemaChange:le}}function ts({ColumnsComponent:t}){var ee;const n=s.useEditorStore(S=>S.selectedConnectionId),a=s.useEditorStore(S=>S.selectedDatamodelId),r=s.useEditorStore(S=>S.selectedDatabaseName),o=s.useEditorStore(S=>S.selectedSchemaName),i=s.useEditorStore(S=>S.selectedTableName),l=s.useEditorStore(S=>S.actions.setSelectedTableName),{connectionItems:c,modelItems:d,schemaItems:u,databaseItems:x,tableItems:j,columns:b,isConnectionsLoading:m,isModelsLoading:p,isConnectionsError:f,isModelsError:k,isDatabasesLoadingOrFetching:y,isDatabaseError:L,isSchemaLoadingOrFetching:w,isSchemaError:T,isColumnsError:E,isColumnsLoadingOrFetching:O,isTableLoadingOrFetching:R,isTableError:F,connectionType:q,isNonDbConnection:h,refetchDatabases:g,refetchModels:I,refetchSchemas:v,refetchTables:M,refetchColumns:B,refetchConnections:_,handleConnectionChange:G,handleDatabaseChange:H,handleSchemaChange:Q,handleDatamodelChange:Z,tableName:P,schemaName:z}=re();function A(){return t?t(z,P,b):e.jsx(et,{schemaName:z,tableName:P,columns:b,status:O?"Loading...":E?"Error":"Success"})}function X(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function J(){if(!n||q==="S3"||q==="API")return null;if(!a||a==="none")return e.jsx(ce,{refetch:g,showNone:!0,onChange:H,isError:L,isLoading:y,items:x,value:r||"",title:"Database"})}function W(){if(n&&!h&&(!r||r==="none")&&(!a||a==="none"))return e.jsxs("div",{className:"grid grid-cols-3",children:[e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(s.Separator,{})}),e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(s.Label,{children:"OR"})}),e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(s.Separator,{})})]})}function K(){if(!n||q==="S3"||q==="API")return null;if(!r||r==="none")return e.jsx(ce,{refetch:I,showNone:!0,onChange:Z,isError:k,isLoading:p,items:d,value:a||"",title:"Model"})}function $(){return!n||q==="S3"||q==="API"||!r||r==="none"?null:e.jsx(ce,{refetch:v,onChange:Q,isError:T,isLoading:w,items:u,value:o||"",title:"Schema"})}function se(){function S(){let V=!1;return q==="API"?(V=!1,V):((q==="S3"||n&&r&&r!=="none"&&o)&&(V=!0),V)}return S()?e.jsx(ce,{refetch:M,onChange:l,isError:F,items:j,isLoading:R,value:i||"",title:"Table"}):null}return e.jsxs("aside",{className:"flex grow flex-col justify-between",children:[e.jsxs("section",{className:"space-y-3 px-6 py-4",children:[e.jsx(ce,{refetch:_,items:c,title:"Connection",value:n||"",onChange:G,isLoading:m,isError:f,connectionTooltip:((ee=c==null?void 0:c.find(S=>S.id===n))==null?void 0:ee.type)||""}),J(),W(),K(),$(),se()]}),A(),e.jsx("div",{className:"flex items-end justify-center gap-2 px-6 py-4",children:e.jsxs(s.Button,{onClick:X,size:"sm",variant:"secondary",className:"w-full",children:[e.jsx(Fs,{className:"mr-2 size-4"}),"Help"]})})]})}function st(t){const n=t.toUpperCase().indexOf("WHERE"),a=t.toUpperCase().indexOf("GROUP BY"),r=t.toUpperCase().indexOf("LIMIT"),o=t.toUpperCase().indexOf("ORDER BY");let i=t.length;if(o!==-1&&(i=o),r!==-1&&r<i&&(i=r),n!==-1){const l=t.substring(0,n),c=t.substring(n);return`${l} {{ filters | where }} AND ${c.substring(6)}`}else if(a!==-1){const l=t.substring(0,a),c=t.substring(a);return`${l} {{ filters | where }} ${c}`}else{const l=t.substring(0,i),c=t.substring(i);return console.log("beforeClause",l),console.log("afterClause",c),c?`${l} {{ filters | where }} ${c}`:`${l.replace(/;$/,"")} {{ filters | where }}`}}function tt({sql:t,error:n,onClick:a}){return!t&&!n?null:e.jsxs(s.HoverCard,{openDelay:n?0:500,children:[e.jsx(s.HoverCardTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"link",className:"h-5 p-0",children:n?e.jsx(Cs,{className:"h-4 w-4 text-red-500"}):e.jsx(s.Info,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(s.HoverCardContent,{align:"start",className:"w-full min-w-fit max-w-[700px]",children:e.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxs("div",{className:"flex grow flex-col space-y-2",children:[e.jsxs(s.ScrollArea,{className:"max-h-[250px] min-h-0 overflow-scroll text-xs leading-relaxed text-foreground/80",children:[n&&n,t&&e.jsxs("div",{className:"flex flex-col space-y-1.5",children:[e.jsx("span",{className:"text-xs font-semibold",children:"Resolved SQL"}),e.jsx("span",{className:"font-mono",children:t})]})]}),n&&e.jsxs(s.Button,{onClick:a,size:"sm",variant:"secondary",children:[e.jsx(Is,{className:"mr-2 h-4 w-4"}),"Debug with Assistant"]})]})})})]})}function at({userInput:t,triggerAIRun:n,setTriggerAIRun:a,open:r,setOpen:o}){const i=C.useRef(null),l=C.useRef(null),[c,d]=C.useState([]),[u,x]=C.useState(""),[j,b]=C.useState(null),{authToken:m}=s.useSemaphorContext(),p=s.useEditorStore(S=>{var V;return(V=S==null?void 0:S.card)==null?void 0:V.sql}),f=s.useEditorStore(S=>{var V;return(V=S==null?void 0:S.card)==null?void 0:V.python}),k=s.useEditorStore(S=>S.actions.setCardSql),y=s.useEditorStore(S=>S.actions.setRunSql),L=s.useEditorStore(S=>S.actions.switchCardType),w=s.useEditorStore(S=>S.selectedDatabaseName),T=s.useEditorStore(S=>S.selectedTableName),E=s.useEditorStore(S=>S.selectedConnectionId),O=s.useEditorStore(S=>S.selectedSchemaName),R=s.useDashboardStore(S=>S.dashboard.aiScopeTables),{selectedDatamodelName:F,connectionType:q,selectedDatamodelId:h}=re(),{messages:g,setMessages:I,reload:v,append:M,input:B,setInput:_,status:G,handleInputChange:H,handleSubmit:Q,stop:Z}=s.useChat({api:"https://semaphor.cloud/api/v1/assistant",headers:{Authorization:`Bearer ${m==null?void 0:m.accessToken}`},body:{random:Math.random()},maxSteps:10,onToolCall:X,onFinish(S,V){z(V.usage),x(""),console.log("onFinish",S,V),V.finishReason==="stop"&&x("")}});C.useEffect(()=>{n&&t&&(H({target:{value:t}}),setTimeout(()=>{Q(),a(!1)},100))},[n,Q,t,a,H]);const P=C.useRef(r);C.useEffect(()=>{const S=P.current?"smooth":"auto";P.current=r;const V=setTimeout(()=>{var U;l.current&&(l.current.scroll({top:l.current.scrollHeight,behavior:S}),(U=i.current)==null||U.focus())},50);return()=>clearTimeout(V)},[g,r]);function z(S){b(V=>V?{promptTokens:V.promptTokens+S.promptTokens,completionTokens:V.completionTokens+S.completionTokens,totalTokens:V.totalTokens+S.totalTokens}:S)}function A(S){const V=s.removeFromScopeArray(c,S);W(V)}async function X({toolCall:S}){if(S.toolName==="createChart"){console.log("createChart",S.args);const V=S.args.sql,U=S.args.chartType;return L(U),k(V),y(!0),{status:"success",message:"Let the user know that chart is created"}}else if(S.toolName==="getTableColumns")x("Getting table columns...");else{if(S.toolName==="getUserSql")return p?(console.log("cardSql",p),console.log("cardPython",f),{status:"success",sql:p,python:f||""}):{status:"error",message:"No SQL found"};if(S.toolName==="getCurrentTableScope")return x("Getting table scope..."),$(),{status:"success",tables:c};x("Thinking...")}}function J(S){return S.map(U=>({...U,connectionType:U.connectionType==="API"||U.connectionType==="S3"?"DuckDb":U.connectionType}))}function W(S){const V=J(S);d(V),I(U=>[...U,{id:crypto.randomUUID(),role:"system",content:`Current scope of tables | ${JSON.stringify(V)}`}])}function K(){const S={databaseName:w||"",schemaName:O||"",tableName:T||"",datamodelId:h||"",datamodelName:s.resolveDatamodelName(F),connectionId:E||"",connectionType:q||""},V=s.dedup([...c,S]);W(V)}function $(){const S={databaseName:w||"",schemaName:O||"",tableName:T||"",datamodelName:s.resolveDatamodelName(F),connectionId:E||"",connectionType:q||"",datamodelId:h||""};if(!s.isInAiScopeArray([...R||[],...c],S)||c.length===0){const U=s.dedup([...R||[],...c,S]).filter(ne=>ne.connectionId===S.connectionId);W(U)}}function se(S){o(!1),k(S),y(!0)}const ee=!["ready","error"].includes(G);return{messages:g,setMessages:I,reload:v,append:M,input:B,setInput:_,isLoading:ee,handleRun:se,handleSetAIScope:$,handleAddCurrentTableToScope:K,removeFromCurrentSelections:A,currentScope:c,setCurrentScope:d,containerRef:l,inputRef:i,handleInputChange:H,handleSubmit:Q,stop:Z,chatStatus:G,toolStatus:u,llmUsage:j}}const nt=!1;function rt({open:t,setOpen:n,userInput:a,triggerAIRun:r,setTriggerAIRun:o}){const[i,l]=C.useState(!1),[c,d]=C.useState(nt),[u,x]=C.useState(!1),{messages:j,setMessages:b,reload:m,input:p,setInput:f,isLoading:k,handleRun:y,handleSetAIScope:L,handleAddCurrentTableToScope:w,removeFromCurrentSelections:T,currentScope:E,setCurrentScope:O,containerRef:R,inputRef:F,handleInputChange:q,handleSubmit:h,stop:g,chatStatus:I,toolStatus:v,llmUsage:M}=at({userInput:a,triggerAIRun:r,setTriggerAIRun:o,open:t,setOpen:n});function B(){return e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{children:e.jsx(s.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",children:e.jsx(De,{className:"size-3.5 text-muted-foreground/70 hover:text-muted-foreground"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsx(s.DropdownMenuLabel,{children:"Options"}),e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuCheckboxItem,{checked:i,onCheckedChange:l,children:"Token Usage"}),e.jsx(s.DropdownMenuCheckboxItem,{checked:c,onCheckedChange:d,children:"Tool Invocations"}),e.jsx(s.DropdownMenuCheckboxItem,{checked:u,onCheckedChange:x,children:"System Message"})]})]})}return e.jsxs(s.Dialog,{open:t,onOpenChange:n,children:[e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsx(s.Button,{onClick:L,size:"sm",className:"w-full cursor-text justify-start font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"ghost",children:"Type your question..."})}),e.jsxs(s.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[700px] md:min-w-[625px] [&>button]:hidden",children:[e.jsx(s.DialogHeader,{children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(s.DialogTitle,{children:"Assistant"}),E&&E.length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Context:"}),E==null?void 0:E.map((_,G)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted px-2 py-1 text-xs",children:[s.getFormattedTableNameForQuery({schemaName:_.schemaName||"",tableName:_.tableName||"",modelName:_.datamodelName||"",connectionType:_.connectionType||""}),e.jsx("button",{onClick:()=>{T(_)},children:e.jsx(s.X,{className:"size-3 text-muted-foreground hover:text-foreground"})})]},G))]}),(E==null?void 0:E.length)===0&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Context: None"}),e.jsxs(s.Button,{className:"h-6 text-xs",size:"sm",variant:"secondary",onClick:w,children:[e.jsx(s.Plus,{className:"mr-2 size-3"}),"Current Table"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[B(),e.jsx(s.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{b([]),O([]),m()},children:e.jsx(s.RefreshCcw,{className:"size-3.5 text-muted-foreground"})})]})]})}),e.jsx("div",{ref:R,className:"h-[700px] w-full overflow-auto",children:e.jsxs("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:[e.jsx(s.PrintMessages,{messages:j,showTools:c,handleRun:y,showSystemMessage:u}),e.jsx(s.ChatStatus,{status:s.getStatus(I,v),isLoading:k})]})}),e.jsx(s.ChatInput,{stop:g,ref:F,setInput:f,input:p,handleInputChange:q,handleSubmit:h,isLoading:k}),M&&i&&e.jsx("div",{className:"flex h-8 items-center justify-between",children:e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Usage: ",M.promptTokens," prompt tokens,"," ",M.completionTokens," completion tokens,"," ",M.totalTokens," total tokens"]})})]})]})}var as={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Re=C.createContext&&C.createContext(as),ot=["attr","size","title"];function it(t,n){if(t==null)return{};var a=lt(t,n),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)r=i[o],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(a[r]=t[r])}return a}function lt(t,n){if(t==null)return{};var a={};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(n.indexOf(r)>=0)continue;a[r]=t[r]}return a}function Se(){return Se=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},Se.apply(this,arguments)}function qe(t,n){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),a.push.apply(a,r)}return a}function Ce(t){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?qe(Object(a),!0).forEach(function(r){ct(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):qe(Object(a)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))})}return t}function ct(t,n,a){return n=dt(n),n in t?Object.defineProperty(t,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[n]=a,t}function dt(t){var n=ut(t,"string");return typeof n=="symbol"?n:n+""}function ut(t,n){if(typeof t!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var r=a.call(t,n);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function ns(t){return t&&t.map((n,a)=>C.createElement(n.tag,Ce({key:a},n.attr),ns(n.child)))}function de(t){return n=>C.createElement(mt,Se({attr:Ce({},t.attr)},n),ns(t.child))}function mt(t){var n=a=>{var{attr:r,size:o,title:i}=t,l=it(t,ot),c=o||a.size||"1em",d;return a.className&&(d=a.className),t.className&&(d=(d?d+" ":"")+t.className),C.createElement("svg",Se({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,r,l,{className:d,style:Ce(Ce({color:t.color||a.color},a.style),t.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),i&&C.createElement("title",null,i),t.children)};return Re!==void 0?C.createElement(Re.Consumer,null,a=>n(a)):n(as)}function ht(t){return de({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 rs(t){const{theme:n}=s.useTheme(),a=s.useDashboardStore(f=>f.theme),r=s.useEditorStore(f=>f.frame),o=s.useEditorStore(f=>f.card),i=s.useEditorStore(f=>f.activeTabCardId),l=s.Le(),{refetch:c}=s.useDashboardCardQuery(o),{updateCardTab:d,setRunSql:u}=s.useEditorActions(),x=C.useRef(),j=C.useRef({}),b=r.cards.find(f=>f.id===i),m=C.useCallback(()=>{let f="";return t==="python"&&(f=(b==null?void 0:b.python)||s.PYTHON_DEFAULT_CODE),t==="sql"&&(f=(b==null?void 0:b.sql)||""),f},[t,b]);C.useEffect(()=>{if(i&&o.id&&o.id!==i){if(x.current&&l){const f=x.current.getModel();f&&(j.current[o.id]=f);let k=j.current[i];if(!k){const y=m();k=l.editor.createModel(y,t),j.current[i]=k}x.current.setModel(k)}d(i,o),u(!0)}},[i,o,d,l,u,t,m]),C.useEffect(()=>{if(!l)return;const f=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",k=a==="system"?f:a;l.editor.defineTheme("default",{base:k==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":k==="light"?"#ffffff":s.hslStringToHex("240 10% 10%")}}),l.editor.setTheme("default")},[n,a,l]),C.useEffect(()=>{const f=x.current;f&&l&&o&&f.addCommand(l.KeyMod.Shift|l.KeyCode.Enter,function(){return c(),!1})},[l,c,o]);function p(f,k){if(x.current=f,!j.current[o.id]){const y=f.getModel(),L=m();j.current[o.id]=y||(k==null?void 0:k.editor.createModel(L,t))||f.getModel()}f.setModel(j.current[o.id])}return{handleEditorDidMount:p}}function xt(){const t=s.useEditorStore(l=>l.card.sql),n=s.useEditorStore(l=>l.sqlGen),{setCardSql:a,setSqlGen:r}=s.useEditorActions(),{handleEditorDidMount:o}=rs("sql");function i(l){a(l),s.isObjectEmpty(n)||r({})}return e.jsx(s.Ft,{theme:"default",className:"pt-3",onChange:i,value:t||"",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"sql",onMount:o})}function pt(){const t=s.useEditorStore(o=>o.card.python),{setCardPython:n}=s.useEditorActions(),{handleEditorDidMount:a}=rs("python");function r(o){n(o)}return e.jsx(s.Ft,{className:"pt-3",theme:"default",onChange:r,value:t||s.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"python",onMount:a})}function ft({jsonString:t}){return e.jsx(s.Ft,{theme:"default",defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:t,options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})}function gt(){var fe;const[t,n]=C.useState({queryKey:[],queryData:null}),a=s.useQueryClient(),[r,o]=C.useState(!1),[i,l]=C.useState(!1),[c,d]=C.useState(!1),[u,x]=C.useState(""),[j,b]=C.useState(!1),m=s.useEditorStore(D=>D.frame),p=s.useEditorStore(D=>D.card),f=s.useEditorStore(D=>D.isShowingVisual),k=s.useEditorStore(D=>D.selectedConnectionId),y=s.useEditorStore(D=>D.selectedDatabaseName),L=s.useEditorStore(D=>D.selectedDatamodelId),w=s.useEditorStore(D=>D.selectedSchemaName),T=s.useEditorStore(D=>D.selectedTableName),E=s.useEditorStore(D=>{var Y;return(Y=D==null?void 0:D.card)==null?void 0:Y.sql});s.useEditorStore(D=>D.applyFilters);const{sheetFilterValues:O}=s.useSheetFilterValues(),{setCardCustomCfg:R,setQueryResultColumns:F,setCardSql:q,setPythonStdOut:h,setCardPreferences:g,setCardType:I,setCardPython:v}=s.useEditorActions(),M=s.useEditorStore(D=>D.onSave),B=s.useEditorStore(D=>D.onClose),_=s.useEditorStore(D=>D.actions.setSqlGen),G=s.useEditorStore(D=>D.runSql),H=s.useEditorStore(D=>D.actions.setRunSql),Q=s.useEditorStore(D=>D.actions.setCardCfg),Z=s.useEditorStore(D=>D.actions.setIsSqlRunning),{data:P,isLoading:z,isFetching:A,isSuccess:X,isError:J,error:W,queryKey:K,refetch:$}=s.useDashboardCardQuery(p);C.useEffect(()=>{if(P&&(P.rowLimitExceeded&&s.ue.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),h((P==null?void 0:P.output)||""),P.records.length>0)){const{dimensionKeys:D}=s.getKeys(P.records);F(D)}},[P,F,h]),C.useEffect(()=>{(z||A)&&Z(!0),(J||X)&&Z(!1),J&&(F([]),h(""))},[z,A,P,h,J,X,Z,F,W]),C.useEffect(()=>{G&&(a.getQueryData(K)||$(),H(!1))},[G,$,H,K,a]);function se(){const D=a.getQueryData(K);t.queryData||n({queryKey:K,queryData:D}),a.setQueryData(K,null),a.removeQueries({queryKey:K,exact:!0}),q(""),_({}),v(""),Q(void 0),R(""),g({}),I("bar")}function ee(D,Y){if(D.length===0)return"";if(Y){const oe=D.find(te=>te.id===Y);if(oe){const te=oe.tabTitle;if(te=="All__Header")return D[0].id;if(te&&te.endsWith("__Header")){const Ne=te.split("__")[0],ge=D.find(je=>je.tabTitle===Ne);return ge?ge.id:D[0].id}return Y}}return D[0].id}function S(){let D=E;E&&!E.includes("{{")&&(D=st(E),q(D));const Y={...p,lastSelectedSchema:w,lastSelectedDatamodelId:L,lastSelectedDatabase:y,lastSelectedTable:T,connectionId:k,type:f?p.type:"table",sql:D,customCfg:f?p.customCfg:null},oe=m.cards.map(me=>me.id===p.id?Y:me),te={...m,cards:oe,activeCardId:ee(oe,m.activeCardId)};M==null||M(te)}function V(){const{queryKey:D,queryData:Y}=t;D&&Y&&a.setQueryData(D,Y),_({}),B==null||B()}async function U(){const D=`
217
- I have the following error:
216
+ */const Qe=s.createLucideIcon("Tornado",[["path",{d:"M21 4H3",key:"1hwok0"}],["path",{d:"M18 8H6",key:"41n648"}],["path",{d:"M19 12H9",key:"1g4lpz"}],["path",{d:"M16 16h-6",key:"1j5d54"}],["path",{d:"M11 20H9",key:"39obr8"}]]);/**
217
+ * @license lucide-react v0.453.0 - ISC
218
+ *
219
+ * This source code is licensed under the ISC license.
220
+ * See the LICENSE file in the root directory of this source tree.
221
+ */const Je=s.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"}]]);function Ne(t){var n;return{...t,sheets:(n=t==null?void 0:t.sheets)==null?void 0:n.map(a=>{var r;return{...a,frames:(r=a.frames)==null?void 0:r.map(o=>{var i;return{...o,cards:(i=o.cards)==null?void 0:i.map(l=>We(l))}})}})}}function We(t){var n,a,r,o;return{...t,cfg:{...t.cfg,data:{...(n=t.cfg)==null?void 0:n.data,labels:[],datasets:(o=(r=(a=t.cfg)==null?void 0:a.data)==null?void 0:r.datasets)==null?void 0:o.map(i=>({...i,data:[]}))}},customCfg:Qs(t.customCfg),data:[]}}function Qs(t){var n,a;return t?{...t,data:{...t==null?void 0:t.data,labels:[],datasets:(a=(n=t==null?void 0:t.data)==null?void 0:n.datasets)==null?void 0:a.map(r=>({...r,data:[]}))}}:null}async function Js(t,n,a,r){if(!r)return null;const o=JSON.stringify(n);return await s.postRequest("https://semaphor.cloud/api/v1/lens",r,{name:t,template:o,filterValues:a,operation:"create"})}async function ye(t,n){if(!n)return null;const{id:a,template:r,filterValues:o,isDefault:i,shared:l}=t;return await s.postRequest("https://semaphor.cloud/api/v1/lens",n,{lensId:a,template:r,filterValues:o,isDefault:i,shared:l,operation:"update"})}async function Ws(t,n){return n?await s.postRequest("https://semaphor.cloud/api/v1/lens",n,{operation:"delete",lensId:t}):null}function Ks(){const[t,n]=S.useState(""),[a,r]=S.useState(!1),o=s.useDashboardStore(x=>x.lenses),{setLenses:i,setSelectedLensId:l}=s.useDashboardActions(),[d,u]=S.useState(!1),[p,c]=S.useState(!1),j=s.useDashboardStore(x=>x.dashboard),b=s.useDashboardStore(x=>x.filterValues),{authToken:h}=s.useSemaphorContext();async function f(){u(!0);const x=Ne(j),N=await Js(t,x,b,h==null?void 0:h.accessToken);N&&(i([...o||[],N]),l(N.id),c(!1)),u(!1)}return e.jsxs(s.Dialog,{open:p,onOpenChange:c,children:[e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4",strokeWidth:1.5}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Create Lens"}),e.jsx(s.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsx(s.Label,{className:"text-right",children:"Name"}),e.jsx(s.Input,{value:t,onChange:x=>{n(x.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),a&&e.jsx("p",{className:"text-sm",children:"The lens name already exists. Use a differnet name."}),e.jsx(s.DialogFooter,{children:e.jsx(s.Button,{size:"sm",variant:"outline",type:"submit",onClick:f,disabled:d,children:d?"Creating...":"Add"})})]})]})}function Xs(){const[t,n]=S.useState(!1),a=s.useDashboardStore(c=>c.lenses),r=s.useDashboardStore(c=>c.selectedLensId),{setLenses:o,setSelectedLensId:i}=s.useDashboardActions(),{authToken:l}=s.useSemaphorContext();async function d(c){i(c)}async function u(c){if(await Ws(c,l==null?void 0:l.accessToken)){const b=a==null?void 0:a.filter(h=>h.id!==c);o(b||[]),i("original")}}async function p(c){const j=a==null?void 0:a.map(f=>f.id===c.id?{...f,isDefault:!c.isDefault}:{...f,isDefault:!1});o(j||[]);const b={...c,isDefault:!c.isDefault};await ye(b,l==null?void 0:l.accessToken);const h=a==null?void 0:a.find(f=>f.isDefault);if(h&&h.id!==c.id){const f={...h,isDefault:!1};await ye(f,l==null?void 0:l.accessToken)}}return e.jsxs(s.DropdownMenu,{open:t,onOpenChange:n,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",className:"h-7 p-2",children:e.jsx(Is,{className:"h-4 w-4",strokeWidth:1.5})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-60",children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuRadioGroup,{value:r,onValueChange:d,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(c=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:c.id,children:[e.jsx("p",{children:c.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(Ls,{onClick:j=>{j.preventDefault(),p(c)},className:s.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!c.isDefault,"text-green-500":c.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:j=>{j.preventDefault(),u(c.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},c.id))]})]})]})}async function Ke(){var h;const t=s.useDashboardStore.getState().authToken,n=s.useDashboardStore.getState().theme,a=s.useDashboardStore.getState().filterValues,r=(h=s.useDashboardStore.getState().dashboard)==null?void 0:h.title,o=s.useDashboardStore.getState().isDownloadingPdf,i=s.useDashboardStore.getState().selectedSheetId;if(o)return;const l=new URLSearchParams;l.set("token",(t==null?void 0:t.accessToken)||""),l.set("theme",n||"light"),l.set("filterValues",JSON.stringify(a)),l.set("selectedSheetId",i||"");const d=`https://semaphor.cloud/api/v1/generate-pdf?params=${encodeURIComponent(l.toString())}`;s.useDashboardStore.setState({isDownloadingPdf:!0});const c=(await(await fetch(d,{method:"GET",headers:{Authorization:`Bearer ${t==null?void 0:t.accessToken}`}})).json()).url,j=document.createElement("a");j.href=c;const b=`${r}-${new Date().toISOString()}.pdf`;j.download=b,j.click(),s.useDashboardStore.setState({isDownloadingPdf:!1})}function Ys({iconClassName:t}){const{authToken:n}=s.useSemaphorContext();s.useDashboardStore(o=>{var i;return(i=o.dashboard)==null?void 0:i.title}),s.useDashboardStore(o=>o.theme),s.useDashboardStore(o=>o.filterValues);const a=s.useDashboardStore(o=>o.isDownloadingPdf);async function r(){await Ke()}return e.jsx(s.Button,{variant:"link",className:"group h-7 p-2",size:"sm",onClick:r,children:a?e.jsx(ue,{className:s.cn("size-3.5 animate-spin",t)}):e.jsx(s.Download,{className:s.cn("size-3.5",t),strokeWidth:1.5})})}function Zs(){const{authToken:t}=s.useSemaphorContext();s.useDashboardStore(m=>m.theme);const n=s.useDashboardStore(m=>m.lenses),a=s.useDashboardStore(m=>m.selectedLensId),r=n==null?void 0:n.find(m=>m.id===a),o=s.useDashboardStore(m=>m.dashboard);s.useDashboardStore(m=>m.selectedSheetId);const i=s.useDashboardStore(m=>m.isDashboardEditing),l=s.useEditorStore(m=>m.selectedConnectionId),[d,u]=S.useState(!1),p=s.useDashboardStore(m=>m.filterValues),c=s.useDashboardStore(m=>m.isVisualEditing),j=s.useDashboardStore(m=>m.showFilters);s.useDashboardStore(m=>m.showDashboardJSON);const b=s.useDashboardStore(m=>m.onSaveFunction),h=s.useDashboardStore(m=>m.actions.setShowFilters),{addFrame:f,setSelectedFrameId:x}=s.useDashboardStore(m=>m.actions),{getSelectedSheet:N,setIsDashboardEditing:y,setShowDashboardJSON:T}=s.useDashboardStore(m=>m.actions),C=N(),{tenantId:E,endUserId:M}=S.useMemo(()=>s.getTenantAndEndUserId(t==null?void 0:t.accessToken),[t==null?void 0:t.accessToken]),A=S.useMemo(()=>E||M,[E,M]),R=()=>{if(!i||!C)return;const m={connectionId:l,id:s.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]},L={id:s.v4(),cards:[m],activeCardId:m.id};f(C.id,L),x(L.id)},V=()=>{y(!0)};async function q(){if(u(!0),!a||!r)return;const m=Ne(o),L=JSON.stringify(m),_={...r,template:L,filterValues:p};await ye(_,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),b==null||b(m),u(!1)}return c?null:e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b bg-muted/50 py-2 pl-3 pr-2",role:"dashboard-controls",children:[!c&&e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(s.Label,{children:r==null?void 0:r.name})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:s.invalidateToken,children:e.jsx(Us,{className:"h-4 w-4",strokeWidth:1.5})}),e.jsx(Ys,{}),i&&!c&&A&&e.jsx(Ks,{}),!c&&A&&e.jsx(Xs,{}),i&&!c&&e.jsxs(s.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",disabled:!i,onClick:R,children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4",strokeWidth:1.5}),"Frame"]}),!i&&e.jsx(s.Button,{variant:"ghost",className:"h-7 p-2",onClick:V,size:"sm",children:e.jsx(s.Pencil,{className:"h-4 w-4",strokeWidth:1.5})}),i&&!c&&e.jsx(s.Button,{variant:"ghost",role:"close",className:"h-7 p-2",onClick:()=>{y(!1),T(!1)},size:"sm",children:e.jsx(s.Cross2Icon,{className:"h-4 w-4",strokeWidth:1.5})}),i&&!c&&A&&e.jsx(s.Button,{className:"h-7 p-2",variant:"ghost",disabled:d,onClick:q,size:"sm",children:e.jsx(_s,{className:"h-4 w-4",strokeWidth:1.5})}),!j&&!c&&i&&e.jsx(s.Button,{className:"h-7 p-2",variant:"ghost",onClick:()=>h(!0),size:"sm",children:e.jsx(s.Filter,{className:"h-4 w-4",strokeWidth:1.5})}),!c&&i&&!1,!c&&!1]})]})}function oe({title:t,items:n,value:a,isLoading:r,isError:o,refetch:i,connectionTooltip:l,onChange:d,showNone:u=!1,className:p,showIcon:c=!0,disabled:j=!1}){const b=r?"Loading...":o?"Error":a;function h(){if(t==="Connection")return e.jsx(qs,{className:"size-4 rotate-90"});if(t==="Database")return e.jsx(ws,{className:"size-4"});if(t==="Schema")return e.jsx(Rs,{className:"size-4"});if(t==="Table")return e.jsx(ve,{className:"size-4"});if(t==="Model")return e.jsx(ys,{className:"size-4"})}return e.jsxs("div",{className:"flex items-center gap-2",children:[c&&e.jsx("div",{className:"shrink-0",children:l?e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{children:h()}),e.jsx(s.TooltipContent,{className:"text-xs",align:"start",children:l})]}):h()}),e.jsxs(s.Select,{disabled:j,value:b,onValueChange:d,children:[e.jsx(s.SelectTrigger,{className:s.cn("h-9 w-full focus:ring-1 focus:ring-offset-0",p),children:e.jsx(s.SelectValue,{placeholder:r?"Loading...":o?"Error":`Select ${t}`})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[r?e.jsx(s.SelectLabel,{children:"Loading..."}):e.jsxs(s.SelectLabel,{className:"flex items-center justify-between gap-2",children:[t,e.jsx(Bs,{className:"mr-1 size-3 cursor-pointer text-muted-foreground hover:text-foreground",onClick:i})]}),e.jsxs(e.Fragment,{children:[u&&e.jsx(s.SelectItem,{value:"none",children:"None"},"none"),n&&n.map((f,x)=>e.jsx(s.SelectItem,{value:f.id,children:f.name},x))]}),(r||o)&&e.jsx(s.SelectItem,{value:b,children:b})]})})]})]})}function et({column:t}){const[n,a]=S.useState(!1),r=s.useEditorStore(f=>f.selectedTableName),o=s.useEditorStore(f=>f.selectedSchemaName),i=s.useEditorStore(f=>f.selectedDatamodelId),l=s.useEditorStore(f=>f.sqlGen),{modelItems:d,connectionType:u}=ne(),p=s.useEditorStore(f=>f.actions.setSqlGen),c=s.useEditorStore(f=>f.actions.setCardSql),j=s.useEditorStore(f=>f.actions.setRunSql);function b(f,x){var C;const N=s.createSqlGenConfig(f,l,x),y=(C=d==null?void 0:d.find(E=>E.id===i))==null?void 0:C.name;p(N);const T=s.getSql(N,s.fmt(o||""),s.fmt(r),y,u);T&&(c(T),j(!0)),a(!1)}function h(){return e.jsxs("ul",{className:"text-xs",children:[e.jsx("li",{onClick:()=>b(t,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),e.jsx("li",{onClick:()=>b(t,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),e.jsx("li",{onClick:()=>b(t,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),e.jsx("li",{onClick:()=>b(t,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),e.jsx("li",{onClick:()=>b(t,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})}return e.jsxs(s.HoverCard,{openDelay:0,open:n,onOpenChange:a,children:[e.jsx(s.HoverCardTrigger,{asChild:!0,children:e.jsx(He,{className:"invisible size-3.5 cursor-pointer text-foreground/40 group-hover:visible"})}),e.jsx(s.HoverCardContent,{align:"center",className:"w-20 rounded-md p-0 shadow-none",children:h()})]})}function Xe({column:t}){return e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger$1,{asChild:!0,children:s.isTextDataType(t.data_type)?e.jsx(Je,{className:"size-3"}):s.isNumberDataType(t.data_type)?e.jsx(As,{className:"size-3"}):s.isDateDataType(t.data_type)?e.jsx(s.Calendar,{className:"size-3"}):s.isBooleanDataType(t.data_type)?e.jsx($s,{className:"size-3"}):t.data_type.toLowerCase()==="json"?e.jsx(Ss,{className:"size-3"}):e.jsx(Ps,{className:"size-3"})}),e.jsx(s.TooltipContent,{children:e.jsx("p",{className:"font-mono text-xs",children:t.data_type})})]})}function st({schemaName:t,tableName:n,columns:a,status:r}){const o=s.useEditorStore(m=>m.sqlGen),i=s.useEditorStore(m=>m.selectedConnectionId),l=s.useEditorStore(m=>m.selectedDatabaseName),d=s.useEditorStore(m=>m.selectedSchemaName),u=s.useEditorStore(m=>m.selectedTableName),p=s.useEditorStore(m=>m.selectedDatamodelId),c=s.useDashboardStore(m=>m.dashboard.aiScopeTables),{addToAIScope:j,removeFromAIScope:b}=s.useDashboardActions(),{setAIScopeTables:h}=s.useDashboardStore(m=>m.actions),f=s.useEditorStore(m=>m.actions.setRunSql),x=s.useEditorStore(m=>m.actions.setSqlGen),N=s.useEditorStore(m=>m.actions.setIsShowingVisual),y=s.useEditorStore(m=>m.actions.setCardSql),{connectionType:T,modelItems:C,selectedDatamodelName:E}=ne();function M(m){var k;const L=s.createSqlGenConfig(m,o);x(L);const _=(k=C==null?void 0:C.find(z=>z.id===p))==null?void 0:k.name,g=s.getSql(L,s.fmt(t),s.fmt(n),_,T);g&&(y(g),f(!0))}function A(){return(c==null?void 0:c.find(m=>m.connectionId===i&&(m.tableName===u||m.datamodelName===E)))!==void 0}function R(m){m===!0&&(u||E)&&i?(j({connectionId:i,connectionType:T==="S3"||T==="API"?"DuckDb":T,databaseName:l||"",schemaName:d||"",tableName:u||"",datamodelName:s.resolveDatamodelName(E),datamodelId:p||""}),s.ue.success("Added to Assistant Scope",{position:"top-right",duration:2500,richColors:!0})):(b({connectionId:i||"",connectionType:T||"",tableName:u||"",datamodelName:s.resolveDatamodelName(E),datamodelId:p||"",databaseName:l||"",schemaName:d||""}),s.ue("Removed from Assistant Scope",{position:"top-right",duration:2e3,richColors:!0}))}function V(){const m=s.getFormattedTableNameForQuery({schemaName:t,tableName:n,modelName:E,connectionType:T});N(!1);const L=T==="MSSQL"?`SELECT top 10 * FROM ${m}`:`SELECT * FROM ${m} LIMIT 10`;y(L),f(!0)}function q(){const m=s.getFormattedTableNameForQuery({schemaName:t,tableName:n,modelName:E,connectionType:T});y(`SELECT COUNT(*) as count FROM ${m}`),f(!0)}return e.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[e.jsxs("div",{className:"mx-2 flex items-center justify-center gap-2",children:[e.jsxs(s.Toggle,{title:`${A()?"Remove from":"Add to"} Assistant Scope`,pressed:A(),onPressedChange:R,variant:"outline",className:s.cn("h-9 px-2",{}),children:[e.jsx(s.Plus,{className:s.cn("mr-1 size-4",{"text-green-400":A(),"text-muted-foreground":!A()})}),"AI"]}),e.jsxs(s.Button,{disabled:r!=="Success",onClick:V,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(Fs,{className:"mr-2 size-4"}),"Top 10"]}),e.jsxs(s.Button,{disabled:r!=="Success",onClick:q,size:"sm",variant:"secondary",className:"w-full",children:[r!=="Success"?e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(Hs,{className:"mr-2 size-4"}),"Count"]})]}),e.jsxs(s.ScrollArea,{className:"flex-1 basis-0 border-b border-t border-muted py-3",children:[e.jsx("div",{className:"flex flex-col gap-1",children:a==null?void 0:a.map(m=>e.jsxs("div",{onClick:()=>M(m),className:s.cn("group mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-1 text-sm transition-colors hover:bg-muted/50",{"border border-dashed border-muted-foreground bg-muted":s.isColumnInSqlGen(m,o)}),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Xe,{column:m}),e.jsx("span",{children:m.column_name})]}),e.jsx("div",{onClick:L=>L.stopPropagation(),className:"flex items-center justify-end",children:s.isNumberDataType(m.data_type)&&e.jsx(et,{column:m})})]},m.column_name))}),e.jsx(s.ScrollBar,{orientation:"vertical"}),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})]})}function ne(t,n){var ke,Ee,De,Ie,Te,Ae;let a=S.useMemo(()=>[],[]);const r=s.useSemaphorContext().authToken||t,o=s.useEditorStore(v=>v.selectedConnectionId),i=s.useEditorStore(v=>v.selectedDatamodelId),l=s.useEditorStore(v=>v.selectedDatabaseName),d=s.useEditorStore(v=>v.selectedSchemaName),u=s.useEditorStore(v=>v.selectedTableName),p=s.useEditorStore(v=>v.actions.setCurrentColumns),c=s.useEditorStore(v=>v.actions.setSelectedConnectionId),j=s.useEditorStore(v=>v.actions.setSelectedDatamodelId),b=s.useEditorStore(v=>v.actions.setSelectedDatabaseName),h=s.useEditorStore(v=>v.actions.setSelectedSchemaName),f=s.useEditorStore(v=>v.actions.setSelectedTableName);s.useEditorStore(v=>v.actions.setCardSql);function x(v){return o&&l&&d&&l!=="NA"?!0:o&&v==="API"?!1:!!(o&&v==="S3")}function N(v){return!!(o&&l&&l!=="NA"&&d&&u||o&&(v==="S3"||v==="API")||i&&i)}function y(v){return o&&v?!(v==="API"||v==="S3"):!1}const{refetch:T,data:C,isLoading:E,isError:M}=s.useQuery({queryKey:["connections"],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/connections",(r==null?void 0:r.accessToken)||""),enabled:!!(r!=null&&r.accessToken)}),{refetch:A,data:R,isLoading:V,isError:q}=s.useQuery({queryKey:["models",o],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/datamodels",(r==null?void 0:r.accessToken)||"",{connection_id:o}),enabled:!!(r!=null&&r.accessToken)&&!!o}),m=C==null?void 0:C.connections.find(v=>v.id===o),L=m==null?void 0:m.type,_=(m==null?void 0:m.type)==="API"||(m==null?void 0:m.type)==="S3",{data:g,isLoading:k,isFetching:z,isError:I,refetch:H}=s.useQuery({queryKey:["databases",o],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/databases",(r==null?void 0:r.accessToken)||"",{connection_id:o}),enabled:y(L)}),{data:P,isLoading:$,isFetching:X,isError:Q,refetch:F}=s.useQuery({queryKey:["schemas",o,l],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/schemas",(r==null?void 0:r.accessToken)||"",{connection_id:o,database_name:l}),enabled:!!o&&!!l&&!_&&l!=="NA"}),{data:O,isLoading:Y,isFetching:w,isError:B,refetch:U}=s.useQuery({queryKey:["tables",o,l,d],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/tables",(r==null?void 0:r.accessToken)||"",{connection_id:o,database_name:l,schema_name:d}),enabled:x(L)}),{data:W,isLoading:ae,isFetching:se,isError:G,refetch:K}=s.useQuery({queryKey:["columns",o,l,i,d,u],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/columns",(r==null?void 0:r.accessToken)||"",{connection_id:o,datamodel_id:i||"",database_name:l,schema_name:d,table_name:u}),enabled:N(L)});S.useEffect(()=>{p(a)},[W,p,a]),S.useEffect(()=>{(L==="S3"||L==="API")&&(b(""),h(""),j(""),L==="API"&&f("api"))},[L,f,b,h,j]);const D=(m==null?void 0:m.type)==="API"?(ke=m==null?void 0:m.type)==null?void 0:ke.toLowerCase():u||"",J=_?"":d||"";function Z(v){h(v),f("")}function ee(v){b(v==="none"?"":v),h(""),f(""),v!=="none"&&v!==""&&j("")}function ce(v){c(v)}function je(v){j(v==="none"?"":v),v!=="none"&&v!==""&&b("")}g&&((Ee=g==null?void 0:g.databases)==null?void 0:Ee.length)>0,P&&((De=P==null?void 0:P.schemas)==null?void 0:De.length)>0,W&&((Ie=W==null?void 0:W.columns)==null?void 0:Ie.length)>0&&(a=W.columns.map(v=>({...v,data_type:v.data_type.toLowerCase()}))),I&&(a=[]),(G||M)&&(a=[]);const he=C==null?void 0:C.connections.map(v=>({id:v.id,name:v.name,type:v.type})),be=(Te=R==null?void 0:R.datamodels)==null?void 0:Te.map(v=>({id:v.id,name:v.name})),ms=g==null?void 0:g.databases.map(v=>({id:v.database_name,name:v.database_name})),xs=P==null?void 0:P.schemas.map(v=>({id:v.schema_name,name:v.schema_name})),ps=O==null?void 0:O.tables.map(v=>({id:v.table_name,name:v.table_name})),fs=(Ae=R==null?void 0:R.datamodels.find(v=>v.id===i))==null?void 0:Ae.name;return{connectionItems:he,isConnectionsLoading:E,isConnectionsError:M,modelItems:be,selectedDatamodelId:i,selectedDatamodelName:fs,isModelsLoading:V,isModelsError:q,databaseItems:ms,isDatabasesLoadingOrFetching:k||z,isDatabaseError:I,schemaItems:xs,isSchemaLoadingOrFetching:$||X,isSchemaError:Q,tableItems:ps,isTableLoadingOrFetching:Y||w,isTableError:B,columns:a,isColumnsLoadingOrFetching:ae||se,isColumnsError:G,isNonDbConnection:_,connectionType:L,tableName:D,schemaName:J,refetchConnections:T,refetchModels:A,refetchDatabases:H,refetchSchemas:F,refetchTables:U,refetchColumns:K,handleConnectionChange:ce,handleDatamodelChange:je,handleDatabaseChange:ee,handleSchemaChange:Z}}function Ye({ColumnsComponent:t}){var se;const n=s.useEditorStore(G=>G.selectedConnectionId),a=s.useEditorStore(G=>G.selectedDatamodelId),r=s.useEditorStore(G=>G.selectedDatabaseName),o=s.useEditorStore(G=>G.selectedSchemaName),i=s.useEditorStore(G=>G.selectedTableName),l=s.useEditorStore(G=>G.actions.setSelectedTableName),{connectionItems:d,modelItems:u,schemaItems:p,databaseItems:c,tableItems:j,columns:b,isConnectionsLoading:h,isModelsLoading:f,isConnectionsError:x,isModelsError:N,isDatabasesLoadingOrFetching:y,isDatabaseError:T,isSchemaLoadingOrFetching:C,isSchemaError:E,isColumnsError:M,isColumnsLoadingOrFetching:A,isTableLoadingOrFetching:R,isTableError:V,connectionType:q,isNonDbConnection:m,refetchDatabases:L,refetchModels:_,refetchSchemas:g,refetchTables:k,refetchColumns:z,refetchConnections:I,handleConnectionChange:H,handleDatabaseChange:P,handleSchemaChange:$,handleDatamodelChange:X,tableName:Q,schemaName:F}=ne();function O(){return t?t(F,Q,b):e.jsx(st,{schemaName:F,tableName:Q,columns:b,status:A?"Loading...":M?"Error":"Success"})}function Y(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function w(){if(!n||q==="S3"||q==="API")return null;if(!a||a==="none")return e.jsx(oe,{refetch:L,showNone:!0,onChange:P,isError:T,isLoading:y,items:c,value:r||"",title:"Database"})}function B(){if(n&&!m&&(!r||r==="none")&&(!a||a==="none"))return e.jsxs("div",{className:"grid grid-cols-3",children:[e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(s.Separator,{})}),e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(s.Label,{children:"OR"})}),e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(s.Separator,{})})]})}function U(){if(!n||q==="S3"||q==="API")return null;if(!r||r==="none")return e.jsx(oe,{refetch:_,showNone:!0,onChange:X,isError:N,isLoading:f,items:u,value:a||"",title:"Model"})}function W(){return!n||q==="S3"||q==="API"||!r||r==="none"?null:e.jsx(oe,{refetch:g,onChange:$,isError:E,isLoading:C,items:p,value:o||"",title:"Schema"})}function ae(){function G(){let K=!1;return q==="API"?(K=!1,K):((q==="S3"||n&&r&&r!=="none"&&o)&&(K=!0),K)}return G()?e.jsx(oe,{refetch:k,onChange:l,isError:V,items:j,isLoading:R,value:i||"",title:"Table"}):null}return e.jsxs("aside",{className:"flex grow flex-col justify-between",children:[e.jsxs("section",{className:"space-y-3 px-6 py-4",children:[e.jsx(oe,{refetch:I,items:d,title:"Connection",value:n||"",onChange:H,isLoading:h,isError:x,connectionTooltip:((se=d==null?void 0:d.find(G=>G.id===n))==null?void 0:se.type)||""}),w(),B(),U(),W(),ae()]}),O(),e.jsx("div",{className:"flex items-end justify-center gap-2 px-6 py-4",children:e.jsxs(s.Button,{onClick:Y,size:"sm",variant:"secondary",className:"w-full",children:[e.jsx(Vs,{className:"mr-2 size-4"}),"Help"]})})]})}function tt(t){const n=t.toUpperCase().indexOf("WHERE"),a=t.toUpperCase().indexOf("GROUP BY"),r=t.toUpperCase().indexOf("LIMIT"),o=t.toUpperCase().indexOf("ORDER BY");let i=t.length;if(o!==-1&&(i=o),r!==-1&&r<i&&(i=r),n!==-1){const l=t.substring(0,n),d=t.substring(n);return`${l} {{ filters | where }} AND ${d.substring(6)}`}else if(a!==-1){const l=t.substring(0,a),d=t.substring(a);return`${l} {{ filters | where }} ${d}`}else{const l=t.substring(0,i),d=t.substring(i);return console.log("beforeClause",l),console.log("afterClause",d),d?`${l} {{ filters | where }} ${d}`:`${l.replace(/;$/,"")} {{ filters | where }}`}}function at({sql:t,error:n,onClick:a}){return!t&&!n?null:e.jsxs(s.HoverCard,{openDelay:n?0:500,children:[e.jsx(s.HoverCardTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"link",className:"h-5 p-0",children:n?e.jsx(vs,{className:"h-4 w-4 text-red-500"}):e.jsx(s.Info,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(s.HoverCardContent,{align:"start",className:"w-full min-w-fit max-w-[700px]",children:e.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxs("div",{className:"flex grow flex-col space-y-2",children:[e.jsxs(s.ScrollArea,{className:"max-h-[250px] min-h-0 overflow-scroll text-xs leading-relaxed text-foreground/80",children:[n&&n,t&&e.jsxs("div",{className:"flex flex-col space-y-1.5",children:[e.jsx("span",{className:"text-xs font-semibold",children:"Resolved SQL"}),e.jsx("span",{className:"font-mono",children:t})]})]}),n&&e.jsxs(s.Button,{onClick:a,size:"sm",variant:"secondary",children:[e.jsx(Ts,{className:"mr-2 h-4 w-4"}),"Debug with Assistant"]})]})})})]})}function nt(){const[t,n]=S.useState([]),[a,r]=S.useState(""),[o,i]=S.useState(null),{authToken:l}=s.useSemaphorContext(),d=s.useEditorStore(w=>{var B;return(B=w==null?void 0:w.card)==null?void 0:B.sql}),u=s.useEditorStore(w=>{var B;return(B=w==null?void 0:w.card)==null?void 0:B.python}),p=s.useEditorStore(w=>w.actions.setCardSql),c=s.useEditorStore(w=>w.actions.setRunSql),j=s.useEditorStore(w=>w.actions.switchCardType),b=s.useEditorStore(w=>w.userInputForAI),h=s.useEditorStore(w=>w.triggerAIRun),f=s.useEditorStore(w=>w.selectedDatabaseName),x=s.useEditorStore(w=>w.selectedTableName),N=s.useEditorStore(w=>w.selectedConnectionId),y=s.useEditorStore(w=>w.selectedSchemaName),T=s.useDashboardStore(w=>w.dashboard.aiScopeTables),{setTriggerAIRun:C}=s.useEditorActions(),{selectedDatamodelName:E,connectionType:M,selectedDatamodelId:A}=ne(),{messages:R,setMessages:V,reload:q,append:m,input:L,setInput:_,status:g,handleInputChange:k,handleSubmit:z,stop:I}=s.useChat({api:"https://semaphor.cloud/api/v1/assistant",headers:{Authorization:`Bearer ${l==null?void 0:l.accessToken}`},body:{random:Math.random()},maxSteps:10,onToolCall:H,onFinish(w,B){P(B.usage),r(""),console.log("onFinish",w,B),B.finishReason==="stop"&&r("")}});S.useEffect(()=>{h&&b&&(k({target:{value:b}}),setTimeout(()=>{z(),C(!1)},100))},[h,z,b,C,k]);async function H({toolCall:w}){if(w.toolName==="createChart"){console.log("createChart",w.args);const B=w.args.sql,U=w.args.chartType;return j(U),p(B),c(!0),{status:"success",message:"Let the user know that chart is created"}}else if(w.toolName==="getTableColumns")r("Getting table columns...");else{if(w.toolName==="getUserSql")return d?{status:"success",sql:d,python:u||""}:{status:"error",message:"No SQL found"};if(w.toolName==="getCurrentTableScope")return r("Getting table scope..."),O(),{status:"success",tables:t};r("Thinking...")}}function P(w){i(B=>B?{promptTokens:B.promptTokens+w.promptTokens,completionTokens:B.completionTokens+w.completionTokens,totalTokens:B.totalTokens+w.totalTokens}:w)}function $(w){const B=s.removeFromScopeArray(t,w);Q(B)}function X(w){return w.map(U=>({...U,connectionType:U.connectionType==="API"||U.connectionType==="S3"?"DuckDb":U.connectionType}))}function Q(w){const B=X(w);n(B),V(U=>[...U,{id:crypto.randomUUID(),role:"system",content:`Current scope of tables | ${JSON.stringify(B)}`}])}function F(){const w={databaseName:f||"",schemaName:y||"",tableName:x||"",datamodelId:A||"",datamodelName:s.resolveDatamodelName(E),connectionId:N||"",connectionType:M||""},B=s.dedup([...t,w]);Q(B)}function O(){const w={databaseName:f||"",schemaName:y||"",tableName:x||"",datamodelName:s.resolveDatamodelName(E),connectionId:N||"",connectionType:M||"",datamodelId:A||""};if(!s.isInAiScopeArray([...T||[],...t],w)||t.length===0){const U=s.dedup([...T||[],...t,w]).filter(W=>W.connectionId===w.connectionId);Q(U)}}const Y=!["ready","error"].includes(g);return{messages:R,setMessages:V,reload:q,append:m,input:L,setInput:_,isLoading:Y,handleSetAIScope:O,handleAddCurrentTableToScope:F,removeFromCurrentSelections:$,currentScope:t,setCurrentScope:n,handleInputChange:k,handleSubmit:z,stop:I,chatStatus:g,toolStatus:a,llmUsage:o}}const rt=!1;function ot(){const t=s.useEditorStore(I=>I.showAIDialog),n=S.useRef(t),a=S.useRef(null),r=S.useRef(null),[o,i]=S.useState(!1),[l,d]=S.useState(rt),[u,p]=S.useState(!1),c=s.useEditorStore(I=>I.actions.setCardSql),j=s.useEditorStore(I=>I.actions.setRunSql),{setShowAIDialog:b}=s.useEditorActions(),{messages:h,setMessages:f,reload:x,input:N,setInput:y,isLoading:T,handleSetAIScope:C,handleAddCurrentTableToScope:E,removeFromCurrentSelections:M,currentScope:A,setCurrentScope:R,handleInputChange:V,handleSubmit:q,stop:m,chatStatus:L,toolStatus:_,llmUsage:g}=nt();S.useEffect(()=>{const I=n.current?"smooth":"auto";n.current=t;const H=setTimeout(()=>{var P;a.current&&(a.current.scroll({top:a.current.scrollHeight,behavior:I}),(P=r.current)==null||P.focus())},50);return()=>clearTimeout(H)},[h,t]);function k(I){b(!1),c(I),j(!0)}function z(){return e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{children:e.jsx(s.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",children:e.jsx(He,{className:"size-3.5 text-muted-foreground/70 hover:text-muted-foreground"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsx(s.DropdownMenuLabel,{children:"Options"}),e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuCheckboxItem,{checked:o,onCheckedChange:i,children:"Token Usage"}),e.jsx(s.DropdownMenuCheckboxItem,{checked:l,onCheckedChange:d,children:"Tool Invocations"}),e.jsx(s.DropdownMenuCheckboxItem,{checked:u,onCheckedChange:p,children:"System Message"})]})]})}return e.jsxs(s.Dialog,{open:t,onOpenChange:b,children:[e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsx(s.Button,{onClick:C,size:"sm",className:"w-full cursor-text justify-start font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"ghost",children:"Type your question..."})}),e.jsxs(s.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[700px] md:min-w-[625px] [&>button]:hidden",children:[e.jsx(s.DialogHeader,{children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(s.DialogTitle,{children:"Assistant"}),A&&A.length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Context:"}),A==null?void 0:A.map((I,H)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted px-2 py-1 text-xs",children:[s.getFormattedTableNameForQuery({schemaName:I.schemaName||"",tableName:I.tableName||"",modelName:I.datamodelName||"",connectionType:I.connectionType||""}),e.jsx("button",{onClick:()=>{M(I)},children:e.jsx(s.X,{className:"size-3 text-muted-foreground hover:text-foreground"})})]},H))]}),(A==null?void 0:A.length)===0&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Context: None"}),e.jsxs(s.Button,{className:"h-6 text-xs",size:"sm",variant:"secondary",onClick:E,children:[e.jsx(s.Plus,{className:"mr-2 size-3"}),"Current Table"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[z(),e.jsx(s.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{f([]),R([]),x()},children:e.jsx(s.RefreshCcw,{className:"size-3.5 text-muted-foreground"})})]})]})}),e.jsx("div",{ref:a,className:"h-[700px] w-full overflow-auto",children:e.jsxs("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:[e.jsx(s.PrintMessages,{messages:h,showTools:l,handleRun:k,showSystemMessage:u}),e.jsx(s.ChatStatus,{status:s.getStatus(L,_),isLoading:T})]})}),e.jsx(s.ChatInput,{stop:m,ref:r,setInput:y,input:N,handleInputChange:V,handleSubmit:q,isLoading:T}),g&&o&&e.jsx("div",{className:"flex h-8 items-center justify-between",children:e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Usage: ",g.promptTokens," prompt tokens,"," ",g.completionTokens," completion tokens,"," ",g.totalTokens," total tokens"]})})]})]})}var Ze={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Oe=S.createContext&&S.createContext(Ze),it=["attr","size","title"];function lt(t,n){if(t==null)return{};var a=ct(t,n),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)r=i[o],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(a[r]=t[r])}return a}function ct(t,n){if(t==null)return{};var a={};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(n.indexOf(r)>=0)continue;a[r]=t[r]}return a}function pe(){return pe=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},pe.apply(this,arguments)}function Me(t,n){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),a.push.apply(a,r)}return a}function fe(t){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?Me(Object(a),!0).forEach(function(r){dt(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Me(Object(a)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))})}return t}function dt(t,n,a){return n=ut(n),n in t?Object.defineProperty(t,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[n]=a,t}function ut(t){var n=ht(t,"string");return typeof n=="symbol"?n:n+""}function ht(t,n){if(typeof t!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var r=a.call(t,n);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function es(t){return t&&t.map((n,a)=>S.createElement(n.tag,fe({key:a},n.attr),es(n.child)))}function ie(t){return n=>S.createElement(mt,pe({attr:fe({},t.attr)},n),es(t.child))}function mt(t){var n=a=>{var{attr:r,size:o,title:i}=t,l=lt(t,it),d=o||a.size||"1em",u;return a.className&&(u=a.className),t.className&&(u=(u?u+" ":"")+t.className),S.createElement("svg",pe({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,r,l,{className:u,style:fe(fe({color:t.color||a.color},a.style),t.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),i&&S.createElement("title",null,i),t.children)};return Oe!==void 0?S.createElement(Oe.Consumer,null,a=>n(a)):n(Ze)}function xt(t){return ie({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 ss(t){const{theme:n}=s.useTheme(),a=s.useDashboardStore(x=>x.theme),r=s.useEditorStore(x=>x.frame),o=s.useEditorStore(x=>x.card),i=s.useEditorStore(x=>x.activeTabCardId),l=s.Le(),{refetch:d}=s.useDashboardCardQuery(o),{updateCardTab:u,setRunSql:p}=s.useEditorActions(),c=S.useRef(),j=S.useRef({}),b=r.cards.find(x=>x.id===i),h=S.useCallback(()=>{let x="";return t==="python"&&(x=(b==null?void 0:b.python)||s.PYTHON_DEFAULT_CODE),t==="sql"&&(x=(b==null?void 0:b.sql)||""),x},[t,b]);S.useEffect(()=>{if(i&&o.id&&o.id!==i){if(c.current&&l){const x=c.current.getModel();x&&(j.current[o.id]=x);let N=j.current[i];if(!N){const y=h();N=l.editor.createModel(y,t),j.current[i]=N}c.current.setModel(N)}u(i,o),p(!0)}},[i,o,u,l,p,t,h]),S.useEffect(()=>{if(!l)return;const x=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",N=a==="system"?x:a;l.editor.defineTheme("default",{base:N==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":N==="light"?"#ffffff":s.hslStringToHex("240 10% 10%")}}),l.editor.setTheme("default")},[n,a,l]),S.useEffect(()=>{const x=c.current;x&&l&&o&&x.addCommand(l.KeyMod.Shift|l.KeyCode.Enter,function(){return d(),!1})},[l,d,o]);function f(x,N){if(c.current=x,!j.current[o.id]){const y=x.getModel(),T=h();j.current[o.id]=y||(N==null?void 0:N.editor.createModel(T,t))||x.getModel()}x.setModel(j.current[o.id])}return{handleEditorDidMount:f}}function pt(){const t=s.useEditorStore(l=>l.card.sql),n=s.useEditorStore(l=>l.sqlGen),{setCardSql:a,setSqlGen:r}=s.useEditorActions(),{handleEditorDidMount:o}=ss("sql");function i(l){a(l),s.isObjectEmpty(n)||r({})}return e.jsx(s.Ft,{theme:"default",className:"pt-3",onChange:i,value:t||"",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"sql",onMount:o})}function ft(){const t=s.useEditorStore(o=>o.card.python),{setCardPython:n}=s.useEditorActions(),{handleEditorDidMount:a}=ss("python");function r(o){n(o)}return e.jsx(s.Ft,{className:"pt-3",theme:"default",onChange:r,value:t||s.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"python",onMount:a})}function gt({jsonString:t}){return e.jsx(s.Ft,{theme:"default",defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:t,options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})}function jt(){var K;const[t,n]=S.useState({queryKey:[],queryData:null}),a=s.useQueryClient(),[r,o]=S.useState(!1),[i,l]=S.useState(!1),d=s.useEditorStore(D=>D.frame),u=s.useEditorStore(D=>D.card),p=s.useEditorStore(D=>D.isShowingVisual),c=s.useEditorStore(D=>D.selectedConnectionId),j=s.useEditorStore(D=>D.selectedDatabaseName),b=s.useEditorStore(D=>D.selectedDatamodelId),h=s.useEditorStore(D=>D.selectedSchemaName),f=s.useEditorStore(D=>D.selectedTableName),x=s.useEditorStore(D=>{var J;return(J=D==null?void 0:D.card)==null?void 0:J.sql}),{sheetFilterValues:N}=s.useSheetFilterValues(),{setCardCustomCfg:y,setQueryResultColumns:T,setCardSql:C,setPythonStdOut:E,setCardPreferences:M,setCardType:A,setCardPython:R,runAssistant:V}=s.useEditorActions(),q=s.useEditorStore(D=>D.onSave),m=s.useEditorStore(D=>D.onClose),L=s.useEditorStore(D=>D.actions.setSqlGen),_=s.useEditorStore(D=>D.runSql),g=s.useEditorStore(D=>D.actions.setRunSql),k=s.useEditorStore(D=>D.actions.setCardCfg),z=s.useEditorStore(D=>D.actions.setIsSqlRunning),{data:I,isLoading:H,isFetching:P,isSuccess:$,isError:X,error:Q,queryKey:F,refetch:O}=s.useDashboardCardQuery(u);S.useEffect(()=>{if(I&&(I.rowLimitExceeded&&s.ue.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),E((I==null?void 0:I.output)||""),I.records.length>0)){const{dimensionKeys:D}=s.getKeys(I.records);T(D)}},[I,T,E]),S.useEffect(()=>{(H||P)&&z(!0),(X||$)&&z(!1),X&&(T([]),E(""))},[H,P,I,E,X,$,z,T,Q]),S.useEffect(()=>{_&&(a.getQueryData(F)||O(),g(!1))},[_,O,g,F,a]);function Y(){const D=a.getQueryData(F);t.queryData||n({queryKey:F,queryData:D}),a.setQueryData(F,null),a.removeQueries({queryKey:F,exact:!0}),C(""),L({}),R(""),k(void 0),y(""),M({}),A("bar")}function w(D,J){if(D.length===0)return"";if(J){const Z=D.find(ee=>ee.id===J);if(Z){const ee=Z.tabTitle;if(ee=="All__Header")return D[0].id;if(ee&&ee.endsWith("__Header")){const je=ee.split("__")[0],he=D.find(be=>be.tabTitle===je);return he?he.id:D[0].id}return J}}return D[0].id}function B(){let D=x;x&&!x.includes("{{")&&(D=tt(x),C(D));const J={...u,lastSelectedSchema:h,lastSelectedDatamodelId:b,lastSelectedDatabase:j,lastSelectedTable:f,connectionId:c,type:p?u.type:"table",sql:D,customCfg:p?u.customCfg:null},Z=d.cards.map(ce=>ce.id===u.id?J:ce),ee={...d,cards:Z,activeCardId:w(Z,d.activeCardId)};q==null||q(ee)}function U(){const{queryKey:D,queryData:J}=t;D&&J&&a.setQueryData(D,J),L({}),m==null||m()}async function W(){const D=`Can you help me debug this query in the current table scope?
218
222
 
219
- ${pe}
223
+ Error:
220
224
 
221
- for the following sql query:
225
+ ${G}
222
226
 
223
- ${E}
227
+ Query:
224
228
 
225
- Please help me debug the query in the current table scope.
226
- `;d(!0),x(D),b(!0)}function ne(){return e.jsxs(e.Fragment,{children:[i&&e.jsx("div",{className:"relative flex w-1/3 min-w-0 grow overflow-hidden text-xs",role:"editor-filter-container",children:e.jsx("div",{className:"mt-2 w-[99%]",children:e.jsx(ft,{jsonString:JSON.stringify(O,null,2)})})}),O&&O.length>0&&e.jsx(s.Button,{variant:"ghost",onClick:()=>l(!i),className:"absolute bottom-0 right-6 size-7 p-1",children:i?e.jsx(s.X,{className:"size-3.5 text-muted-foreground"}):e.jsx(s.Filter,{className:"size-3.5 text-muted-foreground"})})]})}function le(){return e.jsxs(s.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxs(s.ResizablePanel,{id:"1",order:1,defaultSize:r?20:100,className:"relative flex grow",children:[e.jsx("div",{id:"sql-container",className:"relative flex w-[99%]",children:e.jsx(xt,{})}),r&&e.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"sql"})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx(s.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxs(s.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsx("div",{id:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsx(pt,{})}),e.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"python"})]})]})]})}const pe=(W==null?void 0:W.message)||((fe=P==null?void 0:P.error)==null?void 0:fe.message);return e.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxs("div",{className:"relative flex grow justify-between overflow-y-scroll",children:[le(),ne()]}),e.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxs(s.Button,{title:"Shift + Enter",disabled:z||A,onClick:()=>{$()},className:"shrink-0",size:"sm",children:[z||A?e.jsx(xe,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(s.Play,{className:"mr-2 h-4 w-4"}),"Run"]}),e.jsx(tt,{sql:P==null?void 0:P.sql,error:pe,onClick:U}),e.jsxs(s.Button,{onClick:se,className:"",size:"sm",variant:"secondary",children:[e.jsx(ws,{className:"mr-2 size-4"}),"Clear"]}),e.jsx(s.Toggle,{pressed:r,onPressedChange:D=>o(D),className:"",size:"sm",children:e.jsx(ht,{className:"size-4 text-foreground/70"})}),e.jsx(rt,{open:c,setOpen:d,userInput:u,triggerAIRun:j,setTriggerAIRun:b})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(s.Button,{onClick:V,className:"w-full",size:"sm",variant:"secondary",children:[e.jsx(s.Cross2Icon,{className:"mr-2 size-4"}),"Close"]}),e.jsxs(s.Button,{onClick:S,size:"sm",variant:"secondary",children:[e.jsx(s.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]})]})]})]})}function jt({data:t}){var l;const[n,a]=C.useState([]),o=Object.keys(t[0]).map(c=>({accessorKey:c,header:({column:d})=>{const u=d.getIsSorted();return e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>d.toggleSorting(d.getIsSorted()==="asc"),children:[c,u==="asc"?e.jsx(s.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):u==="desc"?e.jsx(s.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),i=s.useReactTable({data:t,columns:o,getCoreRowModel:s.getCoreRowModel(),getPaginationRowModel:s.getPaginationRowModel(),onSortingChange:a,getSortedRowModel:s.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return e.jsx("div",{className:"font-mono text-xs text-foreground/95",children:e.jsxs("table",{className:"w-full",children:[e.jsx(s.TableHeader,{children:i.getHeaderGroups().map(c=>e.jsx(s.TableRow,{children:c.headers.map(d=>e.jsx(s.TableHead,{className:"sticky top-0 h-11 bg-muted font-semibold",children:d.isPlaceholder?null:s.flexRender(d.column.columnDef.header,d.getContext())},d.id))},c.id))}),e.jsx(s.TableBody,{children:(l=i.getRowModel().rows)!=null&&l.length?i.getRowModel().rows.map(c=>e.jsx(s.TableRow,{className:"whitespace-nowrap py-2","data-state":c.getIsSelected()&&"selected",children:c.getVisibleCells().map(d=>e.jsx(s.TableCell,{className:"py-3",children:s.flexRender(d.column.columnDef.cell,d.getContext())},d.id))},c.id)):e.jsx(s.TableRow,{children:e.jsx(s.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})})}function bt({card:t}){var L,w,T,E,O,R,F,q,h,g,I;const[n,a]=C.useState(!1),[r,o]=C.useState([]),{authToken:i}=s.useSemaphorContext(),l=s.getTokenParams(i==null?void 0:i.accessToken),c=s.useDashboardStore(v=>v.themeStyle),d={colors:((w=(L=c==null?void 0:c.chart)==null?void 0:L.dataset)==null?void 0:w.backgroundColor)||[]};(T=t.customCardPreferences)!=null&&T.inputData;const{getCard:u}=s.useCustomVisual(((E=t.customCardPreferences)==null?void 0:E.url)||""),x=((O=t.customCardPreferences)==null?void 0:O.visualType)||"single",j=s.useEditorStore(v=>v.frame),{setCustomCardPreferences:b}=s.useEditorActions(),{data:m}=s.useDashboardCardQuery(t),p=C.useCallback((v,M)=>{o(B=>({...B,[v]:M}))},[]);if(!((R=t.customCardPreferences)!=null&&R.componentName))return null;const f=u((F=t.customCardPreferences)==null?void 0:F.componentName);function k(v){a(v)}const y=Object.keys(((q=t.customCardPreferences)==null?void 0:q.dataInputCardIds)||{}).map(v=>{var _,G,H;const M=(G=(_=t.customCardPreferences)==null?void 0:_.dataInputCardIds)==null?void 0:G[v].cardId,B=(H=j==null?void 0:j.cards)==null?void 0:H.find(Q=>Q.id===M);return B||null});return e.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:e.jsxs(C.Suspense,{fallback:e.jsx(e.Fragment,{}),children:[f&&x==="single"&&e.jsx(f,{params:l,theme:d,settings:(h=t.customCardPreferences)==null?void 0:h.settings,onDataChange:p,data:(m==null?void 0:m.records)||[]}),f&&x==="multiple"&&e.jsxs(e.Fragment,{children:[Object.keys(((g=t.customCardPreferences)==null?void 0:g.dataInputCardIds)||{}).map(v=>{var _,G,H;const M=(G=(_=t.customCardPreferences)==null?void 0:_.dataInputCardIds)==null?void 0:G[v].cardId,B=(H=j==null?void 0:j.cards)==null?void 0:H.find(Q=>Q.id===M);if(B)return e.jsx(s.MultiInputEmptyRenderer,{onLoadingStatus:k,onDataChange:p,dataInputIndex:v,card:B},B.id+v)}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(f,{theme:d,onDataChange:p,settings:y.map(v=>{var M;return(M=v==null?void 0:v.customCardPreferences)==null?void 0:M.settings}),data:y.map(v=>v!=null&&v.id?r==null?void 0:r[v.id]:[])})})]})]},(I=t.customCardPreferences)==null?void 0:I.componentName)})}function os({className:t,...n}){var k;const a=s.useEditorStore(y=>y.card),r=((k=a.customCardPreferences)==null?void 0:k.showCardHeader)??!0,o=s.useEditorStore(y=>y.frame),i=s.useDashboardStore(y=>y.dashboard.filters);s.useEditorStore(y=>y.actions.setRunSql);const{updateFilter:l}=s.useDashboardActions(),c=i==null?void 0:i.find(y=>y.id===o.filterId),{data:d,isLoading:u,isFetching:x}=s.useDashboardCardQuery(a),{setCard:j}=s.useEditorActions(),{data:b}=s.useTopoJson(a);if(!a.id)return null;let m;d!=null&&d.records&&(d==null?void 0:d.records.length)>0&&(m=s.createChartConfig({data:d==null?void 0:d.records,cardType:a.type,cfg:a.cfg,customCfg:a.customCfg,preferences:a.preferences,topoJson:b}));function p(y){return e.jsx(bt,{card:y})}function f(){var y;if(d!=null&&d.records&&(d==null?void 0:d.records.length)===0&&!u&&!x)return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[e.jsx(s.TreePalm,{className:"size-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No records to display"})]});if(a.type==="custom")return p(a);if(!["table","custom"].includes(a.type)&&m)return e.jsx(s.ChartJsVisual,{cfg:m},JSON.stringify(m)+JSON.stringify(a.preferences)+((y=a==null?void 0:a.preferences)==null?void 0:y.customVisualCode));if(a.type==="table"&&(d!=null&&d.records)&&(d==null?void 0:d.records.length)>0)return e.jsxs(s.ScrollArea,{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:[e.jsx(s.TableVisual,{card:a,data:d==null?void 0:d.records}),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})}return e.jsxs(s.Card,{role:"editor-visual-card",className:s.cn("relative flex h-full flex-col rounded-none",t),...n,children:[r&&e.jsxs(s.CardHeader,{className:"flex flex-row items-start justify-between py-4",children:[e.jsxs("div",{children:[e.jsx(s.Editable,{text:a.title,onSave:y=>j({...a,title:y}),children:e.jsx("div",{className:"flex items-center gap-5",children:e.jsx(s.CardTitle,{className:"text-base",children:a.title||"Edit title..."})})},a.title),e.jsx(s.Editable,{text:a.description||"",onSave:y=>j({...a,description:y}),children:e.jsx(s.CardDescription,{children:a.description||"Edit description..."})},a.description)]}),c&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(s.Editable,{className:"my-1",text:c.title||c.column,onSave:y=>l({...c,title:y}),children:e.jsx(s.Label,{children:c.title})}),e.jsx(s.FilterComponent,{filter:c})]})]}),e.jsx(s.CardContent,{className:"flex grow flex-col",children:f()})]})}const Be=({language:t,value:n,onChange:a})=>e.jsx(s.Ft,{className:"h-full w-full overflow-hidden text-xs",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,lineHeight:16,renderLineHighlight:"none"},defaultLanguage:t,value:n,onChange:a}),yt=()=>e.jsxs(s.DialogHeader,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(s.DialogTitle,{children:"Customize Card"})}),e.jsxs(s.DialogDescription,{children:["See the configuration options and documentation",e.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),St=({defaultConfig:t,customCode:n,customConfig:a,onConfigChange:r,onCodeChange:o})=>e.jsxs(s.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxs(s.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsx(s.TabsTrigger,{value:"custom-config",children:a?"Custom Config":"Default Config"}),e.jsx(s.TabsTrigger,{value:"output",children:"Output"}),e.jsx(s.TabsTrigger,{value:"custom-code",children:"Custom Code"})]}),e.jsx(s.TabsContent,{value:"output",className:"mt-0 grow rounded-b border border-t-0 p-2",children:e.jsx(s.Textarea,{readOnly:!0,value:t,className:"h-full resize-none border-none font-mono focus-visible:ring-0"})}),e.jsx(s.TabsContent,{value:"custom-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(Be,{language:"json",value:a,onChange:r})}),e.jsx(s.TabsContent,{value:"custom-code",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(Be,{language:"javascript",value:n,onChange:o})})]}),Ct=({error:t,hasCustomConfig:n,onReset:a,onApply:r,onClose:o})=>e.jsxs(s.DialogFooter,{className:"flex items-center",children:[e.jsx(s.Label,{className:"mr-2 text-red-500",children:t}),e.jsx(s.Button,{disabled:!n,onClick:a,variant:"outline",children:"Reset"}),e.jsx(s.Button,{onClick:r,variant:"outline",children:"Apply"}),e.jsx(s.Button,{onClick:o,variant:"outline",children:"Close"})]});function vt(){const[t,n]=C.useState(!1),[a,r]=C.useState(""),[o,i]=C.useState(""),[l,c]=C.useState(""),[d,u]=C.useState(""),x=s.useEditorStore(w=>w.card),j=s.useEditorStore(w=>w.card.customCfg),{data:b}=s.useDashboardCardQuery(x),{data:m}=s.useTopoJson(x),{setCardCustomCfg:p,setCustomVisualCode:f}=s.useEditorActions(),k=w=>{var T,E;return JSON.stringify({...w,data:{...w.data,datasets:(E=(T=w.data)==null?void 0:T.datasets)==null?void 0:E.map(O=>({...O,data:[]}))}},null,2)},y=()=>{var T,E;if(!((T=b==null?void 0:b.records)!=null&&T.length))return;const w=s.createChartConfig({data:b.records,cardType:x.type,cfg:x.cfg,preferences:x.preferences,topoJson:m});if(w){r(k(w)),c(((E=x.preferences)==null?void 0:E.customVisualCode)||"");const O=s.merge(w,j);i(k(O))}},L=()=>{try{if(l&&f(l),o){const w=JSON.parse(o),T=s.getObjectDiff(JSON.parse(a),w);p(T),u("")}}catch{u("Invalid JSON configuration")}};return e.jsxs(s.Dialog,{open:t,onOpenChange:n,children:[e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsx(s.Button,{onClick:y,size:"sm",variant:"outline",className:j?"border-foreground/50 dark:border-foreground/70":"",children:e.jsx(s.Settings,{className:"h-4 w-4"})})}),e.jsxs(s.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsx(yt,{}),e.jsxs("div",{className:"flex grow gap-2",children:[e.jsx(s.ErrorBoundary,{FallbackComponent:s.FallbackEditorCard,children:e.jsx(os,{className:"w-1/2 rounded shadow-none"})}),e.jsx(St,{defaultConfig:a,customCode:l,customConfig:o,onConfigChange:w=>i(w??""),onCodeChange:w=>c(w??"")})]}),e.jsx(Ct,{error:d,hasCustomConfig:!!j,onReset:()=>{i(a),p(null)},onApply:L,onClose:()=>n(!1)})]})]})}function is(t){return de({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 Nt(t){return de({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M48,180c0,11,7.18,20,16,20a14.24,14.24,0,0,0,10.22-4.66A8,8,0,0,1,85.78,206.4,30.06,30.06,0,0,1,64,216c-17.65,0-32-16.15-32-36s14.35-36,32-36a30.06,30.06,0,0,1,21.78,9.6,8,8,0,0,1-11.56,11.06A14.24,14.24,0,0,0,64,160C55.18,160,48,169,48,180Zm79.6-8.69c-4-1.16-8.14-2.35-10.45-3.84-1.25-.81-1.23-1-1.12-1.9a4.57,4.57,0,0,1,2-3.67c4.6-3.12,15.34-1.73,19.82-.56A8,8,0,0,0,142,145.86c-2.12-.55-21-5.22-32.84,2.76a20.58,20.58,0,0,0-9,14.95c-2,15.88,13.65,20.41,23,23.11,12.06,3.49,13.12,4.92,12.78,7.59-.31,2.41-1.26,3.34-2.14,3.93-4.6,3.06-15.17,1.56-19.55.36A8,8,0,0,0,109.94,214a61.34,61.34,0,0,0,15.19,2c5.82,0,12.3-1,17.49-4.46a20.82,20.82,0,0,0,9.19-15.23C154,179,137.49,174.17,127.6,171.31Zm83.09-26.84a8,8,0,0,0-10.23,4.84L188,184.21l-12.47-34.9a8,8,0,0,0-15.07,5.38l20,56a8,8,0,0,0,15.07,0l20-56A8,8,0,0,0,210.69,144.47ZM216,88v24a8,8,0,0,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-27.31-8L160,51.31V80Z"},child:[]}]})(t)}function ls(t){return de({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},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 cs(t){return de({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z"},child:[]}]})(t)}function ds(t){return de({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 us(t){const[n,a]=C.useState(null);return n}function ms(){const{authToken:t}=s.useSemaphorContext(),{data:n,isLoading:a,isFetching:r,isError:o}=s.useQuery({queryKey:["plugins",t==null?void 0:t.accessToken],queryFn:()=>s.getPlugins(t==null?void 0:t.accessToken)});return{data:n,isLoading:a,isFetching:r,isError:o}}function wt({onChartTypeChange:t}){const[n,a]=C.useState([]),{data:r}=ms();return C.useEffect(()=>{(async()=>{var i;if(r){const c=(await Promise.all((i=r==null?void 0:r.plugins)==null?void 0:i.map(async d=>(await s.loadManifest(d.value)).visuals.map(j=>({name:j.name,icon:j.icon,url:d.value}))))).flat();a(c)}})()},[r]),n.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx(s.Separator,{className:"my-2"}),e.jsx("div",{className:"grid grid-cols-4 place-items-center",children:n.map((o,i)=>e.jsx(kt,{text:o.name,onClick:()=>t("custom",o),icon:o.icon},o.url+o.name+i))})]})}const kt=({text:t,icon:n,onClick:a})=>{const r=us(),o=t.charAt(0).toUpperCase();return e.jsx(s.Button,{onClick:a,title:t,variant:"ghost",children:r?e.jsx(r,{className:"h-4 w-4"}):o})};function Et(){var x,j;const[t,n]=C.useState(!1),a=s.useEditorStore(b=>b.card),r=a.type,{setCardType:o,setCardPreferences:i,setChartOrientation:l}=s.useEditorStore(b=>b.actions),{setCardCustomCfg:c,setCustomCardPreferences:d}=s.useEditorActions();function u(b,m){c(null),i({}),o(b),m&&d({type:"component",visualType:"single",url:m.url,componentName:m.name,icon:m.icon}),n(!1)}return e.jsxs(s.Popover,{open:t,onOpenChange:n,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsx(s.Button,{size:"sm",variant:"outline",children:e.jsx(Dt,{className:"h-4 w-4",chartType:r,customIcon:(x=a.customCardPreferences)==null?void 0:x.icon,componentName:(j=a.customCardPreferences)==null?void 0:j.componentName})})}),e.jsxs(s.PopoverContent,{className:"w-50",children:[e.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsx(s.Button,{onClick:()=>u("bar"),className:"font-normal",variant:"ghost",children:e.jsx(ke,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("line"),variant:"ghost",children:e.jsx(Ee,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("stackedBar"),variant:"ghost",children:e.jsx(He,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("stackedLine"),variant:"ghost",children:e.jsx(cs,{className:"size-5",strokeWidth:0})}),e.jsx(s.Button,{onClick:()=>u("scatter"),variant:"ghost",children:e.jsx($e,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("bubble"),variant:"ghost",children:e.jsx(ls,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("pie"),variant:"ghost",children:e.jsx(Ue,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("doughnut"),variant:"ghost",children:e.jsx(Qe,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("radar"),variant:"ghost",children:e.jsx(We,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("polarArea"),variant:"ghost",children:e.jsx(is,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("pyramid"),variant:"ghost",children:e.jsx(Xe,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("range"),variant:"ghost",children:e.jsx(Ge,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("table"),variant:"ghost",children:e.jsx(Ie,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("kpi"),variant:"ghost",children:e.jsx(ds,{className:"size-6"})}),e.jsx(s.Button,{onClick:()=>u("text"),variant:"ghost",children:e.jsx(js,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("map"),variant:"ghost",children:e.jsx(Je,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>u("custom"),variant:"ghost",children:e.jsx(Ke,{className:"size-5"})})]}),e.jsx(wt,{onChartTypeChange:u})]})]})}function Dt({chartType:t,className:n,customIcon:a,componentName:r}){const o=us();switch(t){case"bar":return e.jsx(ke,{className:n});case"line":return e.jsx(Ee,{className:n});case"pie":return e.jsx(Ue,{className:n});case"radar":return e.jsx(We,{className:n});case"scatter":return e.jsx($e,{className:n});case"bubble":return e.jsx(ls,{className:n});case"doughnut":return e.jsx(Qe,{className:n});case"stackedBar":return e.jsx(He,{className:n});case"stackedLine":return e.jsx(cs,{className:n});case"polarArea":return e.jsx(is,{className:n});case"pyramid":return e.jsx(Xe,{className:n});case"range":return e.jsx(Ge,{className:n});case"kpi":return e.jsx(ds,{className:n});case"text":return e.jsx(Ye,{className:n});case"map":return e.jsx(Je,{className:n});case"custom":return a&&o?e.jsx(o,{className:n}):r?r==null?void 0:r.charAt(0).toUpperCase():e.jsx(Ke,{className:n});default:return e.jsx(Ie,{className:n})}}function It(){var a;const t=s.useEditorStore(r=>r.card);(a=t.customCardPreferences)==null||a.showCardHeader;const{setCustomCardPreferences:n}=s.useEditorActions();return e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(De,{className:"size-4 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsx(s.DropdownMenuContent,{align:"start",className:"w-40 text-muted-foreground",children:e.jsxs(s.DropdownMenuItem,{onClick:()=>{navigator.clipboard.writeText(t.id),s.ue.success("Card ID copied to clipboard")},className:"cursor-pointer space-x-2",children:[e.jsx(s.IdCard,{className:"size-5"}),e.jsx("span",{children:"Copy Card ID"})]})})]})}function _e(){var h;const t=s.useEditorStore(g=>g.frame),n=s.useEditorStore(g=>g.card),a=s.useEditorStore(g=>g.isShowingVisual),r=s.useEditorStore(g=>g.isSqlRunning),o=s.useEditorStore(g=>g.pythonStdOut);s.useEditorStore(g=>g.actions.setRunSql);const{setFrame:i,setCard:l,updateCardInFrame:c,setActiveTabCardId:d}=s.useEditorActions(),{data:u,isLoading:x,isFetching:j,error:b}=s.useDashboardCardQuery(n);if(!n)return e.jsx(e.Fragment,{children:"No Active Card"});function m(){const g={connectionId:n.connectionId,id:s.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};p(g)}function p(g){const I={...t,cards:[...t.cards,g],activeCardId:g.id};i(I),d(g.id)}function f(){const g={...n,id:s.v4(),title:`${n.title} Copy`,tabTitle:`${n.tabTitle||n.title} Copy`};p(g)}function k(g){const I=t.cards.filter(B=>B.id!==g),v=I[0],M={...t,cards:I,activeCardId:v.id};i(M),d(v.id),l(v)}function y(g){d(g)}const L=(g,I)=>{console.log("handleDragStart",I),g.dataTransfer.setData("tabIndex",I.toString())},w=g=>{g.preventDefault()},T=(g,I)=>{const v=g.dataTransfer.getData("tabIndex");if(v===I.toString())return;const M=Array.from(t.cards),[B]=M.splice(parseInt(v),1);M.splice(I,0,B),i({...t,cards:M})};function E(g,I){return g.cards.length===1&&(I.displayTab===!0||I.displayTab===void 0)||g.activeCardId!==I.id&&(I.displayTab===!0||I.displayTab===void 0)?null:e.jsx("div",{onClick:()=>{const v=I.displayTab===void 0?!1:!I.displayTab;l({...I,displayTab:v}),c({...I,displayTab:v})},children:I.displayTab===!0||I.displayTab===void 0?e.jsx(s.Eye,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsx(ks,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function O(){return e.jsxs(s.Tabs,{onValueChange:y,value:t.activeCardId,className:"flex grow flex-col",children:[t.cards.map(g=>e.jsx(s.TabsContent,{className:"mt-0 grow",value:g.id,children:R()},g.id)),e.jsx(s.TabsList,{className:"group mx-6 justify-between",children:e.jsxs("div",{className:"flex items-center",children:[t.cards.map((g,I)=>e.jsx(s.Editable,{text:g.tabTitle||g.title,onSave:v=>{l({...n,tabTitle:v}),c({...n,tabTitle:v})},children:e.jsxs(s.TabsTrigger,{draggable:!0,onDragStart:v=>L(v,I),onDragOver:w,onDrop:v=>T(v,I),className:"",value:g.id,children:[E(t,g),g.tabTitle||g.title,t.activeCardId===g.id&&t.cards.length>1&&e.jsx(s.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>k(g.id)})]})},g.id)),e.jsx(s.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:m,children:e.jsx(s.Plus,{className:"h-4 w-4"})}),e.jsx(s.Button,{className:"invisible ml-1 h-8 px-2 hover:bg-muted-foreground/50 group-hover:visible",variant:"outline",onClick:f,children:e.jsx(vs,{className:"h-4 w-4"})})]})})]})}function R(){return n.type==="kpi"?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsx(s.KPICard,{card:n,data:u==null?void 0:u.records})})}):n.type==="text"?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsx(s.ScrollArea,{className:"mx-3 my-6 h-[300px] overflow-y-auto break-words px-3",children:e.jsx(s.TextCard,{isLoading:r,card:n,data:u==null?void 0:u.records})})})}):e.jsx(s.ErrorBoundary,{FallbackComponent:s.FallbackEditorCard,children:e.jsx(os,{className:"grow border-none shadow-none"})})}function F(){const g=JSON.stringify(u==null?void 0:u.records,null,2),I=new Blob([g],{type:"application/json"}),v=URL.createObjectURL(I),M=document.createElement("a");M.href=v,M.download=`${n.title}.json`,M.click()}function q(){const I=[Object.keys(u==null?void 0:u.records.reduce((_,G)=>({..._,...G}),{})).join(","),...((u==null?void 0:u.records)||[]).map(_=>Object.values(_).join(","))].join(`
227
- `),v=new Blob([I],{type:"text/csv"}),M=URL.createObjectURL(v),B=document.createElement("a");B.href=M,B.download=`${n.title}.csv`,B.click()}return e.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[(x||j)&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 m-auto flex h-10 w-10 items-center justify-center rounded-md bg-muted",children:e.jsx(xe,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),e.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[a&&e.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsx(Et,{}),!["table","custom"].includes(n.type)&&e.jsx(vt,{}),e.jsx(It,{})]}),!a&&e.jsxs("div",{className:"flex grow items-center gap-1",children:[e.jsx(s.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:q,children:e.jsx(Nt,{className:"size-4"})}),e.jsx(s.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:F,children:e.jsx(Es,{strokeWidth:1.5,className:"size-4"})}),e.jsx(s.CopyButton,{text:JSON.stringify(u==null?void 0:u.records,null,2),className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70"})]}),e.jsx(At,{})]}),a?O():e.jsxs(s.ResizablePanelGroup,{className:"px-6",direction:"horizontal",children:[o&&e.jsxs(e.Fragment,{children:[e.jsx(s.ResizablePanel,{id:"1",order:1,defaultSize:30,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:o&&e.jsx(Tt,{})}),e.jsx(s.ResizableHandle,{})]}),e.jsx(s.ResizablePanel,{id:"2",order:2,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:e.jsxs(s.ScrollArea,{className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:[(u==null?void 0:u.records)&&(u==null?void 0:u.records.length)>0&&e.jsx(jt,{data:(u==null?void 0:u.records)||[]}),(b||(u==null?void 0:u.error))&&e.jsx("span",{className:"font-mono text-xs",children:(b==null?void 0:b.message)||((h=u==null?void 0:u.error)==null?void 0:h.message)}),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})})]})]})}function Tt(){const t=s.useEditorStore(a=>a.pythonStdOut);if(!t)return null;const n=t.replace(/\n/g,"<br>");return e.jsxs("div",{className:"relative flex w-full flex-col border-r",children:[e.jsx("div",{className:"sticky top-0 flex max-h-11 min-h-11 grow items-center border-b bg-muted px-3 font-mono text-xs font-semibold text-foreground/70",children:"Python Output"}),e.jsxs(s.ScrollArea,{className:"overflow-y-auto px-2 pt-1 font-mono text-xs text-foreground/90",children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:n}}),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})]})}function At(){const t=s.useEditorStore(a=>a.isShowingVisual),n=s.useEditorStore(a=>a.actions.setIsShowingVisual);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Label,{htmlFor:"visualize",children:"Chart"}),e.jsx(s.Switch,{checked:t,onCheckedChange:()=>n(!t),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function Lt({options:t,value:n,onValueChange:a}){return e.jsx(s.RadioGroup,{value:n,onValueChange:a,className:"flex gap-4",defaultValue:t[0].value,children:t.map(r=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:r.value,id:r.value}),e.jsx("label",{className:"text-sm",htmlFor:r.value,children:r.label})]},r.value))})}function ae({label:t,options:n,value:a,onValueChange:r,className:o}){return e.jsxs(s.Select,{value:a,onValueChange:r,children:[e.jsx(s.SelectTrigger,{className:s.cn("w-full focus:ring-0 focus:ring-offset-0",o),children:e.jsx(s.SelectValue,{placeholder:t})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:t}),n.map(i=>e.jsx(s.SelectItem,{value:i.value,children:i.label},i.value))]})})]})}function he({children:t,summary:n,open:a,className:r}){return e.jsxs("details",{open:a,className:s.cn("space-y-4 [&_summary>svg]:open:-rotate-180",r),children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-4",children:[e.jsx(s.Label,{children:n}),e.jsx(s.ChevronUp,{className:"h-4 w-4"})]}),e.jsx("div",{className:"transition-all ease-in-out",children:t})]})}function Ot(){var f,k;const t=s.useEditorStore(y=>y.card.customCardPreferences),{data:n}=ms(),a=(n==null?void 0:n.plugins)||[],r=s.useEditorStore(y=>y.card),o=s.useEditorStore(y=>y.frame),i=(t==null?void 0:t.visualType)||"single",{setCustomCardPreferences:l}=s.useEditorActions(),{components:c,manifest:d}=s.useCustomVisual((t==null?void 0:t.url)||""),u=(f=d==null?void 0:d.visuals)==null?void 0:f.find(y=>y.name===(t==null?void 0:t.componentName));function x(y,L){if(!t)return;const T={...(t==null?void 0:t.dataInputCardIds)||{},[y]:{cardId:L,hookRef:null}};l({...t,dataInputCardIds:T})}function j(y){var w,T;const L=(w=o==null?void 0:o.cards)==null?void 0:w.filter(E=>{var O;return((O=E==null?void 0:E.customCardPreferences)==null?void 0:O.visualType)!=="multiple"}).map(E=>({value:E.id,label:E.tabTitle||E.title}));return e.jsx("div",{className:"space-y-2",children:(T=y==null?void 0:y.dataInputs)==null?void 0:T.map((E,O)=>{var R,F;return e.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[e.jsx("div",{className:"col-span-4 flex items-center",children:E}),e.jsx(ae,{className:"col-span-6 h-8 w-full justify-between",label:"",options:L||[],value:((F=(R=t==null?void 0:t.dataInputCardIds)==null?void 0:R[O])==null?void 0:F.cardId)||"",onValueChange:q=>x(O,q)})]},O+Math.random())})})}function b(y,L,w=[]){var T,E;return t?y==="input"?e.jsx(s.Input,{className:`h-8 w-full ${s.removeRing}`,value:((T=t==null?void 0:t.settings)==null?void 0:T[L])||"",onChange:O=>{l({...t,settings:{...t==null?void 0:t.settings,[L]:O.target.value}})}},L):y==="select"?e.jsx(ae,{className:"h-8 w-full",label:"",options:w,value:((E=t==null?void 0:t.settings)==null?void 0:E[L])||"",onValueChange:O=>{l({...t,settings:{...t==null?void 0:t.settings,[L]:O}})}}):null:null}function m(y){const L=Object.entries((y==null?void 0:y.settings)||{});return e.jsx("div",{className:"space-y-3",children:L.map(([w,T])=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:T.title}),b(T.ui,w,T.options)]},w))})}function p(y){t&&l({...t,visualType:y,componentName:""})}return e.jsxs("div",{className:"p-6",children:[e.jsx(he,{summary:"Plugin Settings",children:e.jsx("div",{className:"space-y-4 text-sm",children:e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"px-2",children:e.jsx(ae,{className:"h-8 w-full",label:"",options:a,value:(t==null?void 0:t.url)||"",onValueChange:y=>l({...t||{url:"",componentName:""},url:y})})})}),((t==null?void 0:t.type)==="component"||(t==null?void 0:t.type)===void 0)&&e.jsx(Lt,{options:[{value:"single",label:"Single Visual"},{value:"multiple",label:"Multi-Visual"}],value:i,onValueChange:p}),((t==null?void 0:t.type)==="component"||(t==null?void 0:t.type)===void 0)&&t&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Component"}),e.jsx("div",{className:"space-y-2 px-2",children:c&&e.jsx(ae,{className:"h-8 w-full",label:"",options:(c==null?void 0:c.filter(y=>y.type===i).map(y=>({value:y.name,label:y.name})))||[],value:t.componentName,onValueChange:y=>{console.log("changing value",y),l({...t,componentName:y})}})})]})})]})})}),e.jsx(s.Separator,{className:"my-4"}),((k=r==null?void 0:r.customCardPreferences)==null?void 0:k.componentName)&&e.jsxs(he,{summary:"Component Settings",children:[u&&u.dataInputs&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(s.Label,{children:"Input Mapping"}),e.jsx("div",{className:"px-2",children:j(u)})]}),u&&u.settings&&e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"px-2",children:m(u)})})]})]})}function ie(){const[t,n]=C.useState([]);s.useEditorStore(x=>x.card.cfg);const a=s.useEditorStore(x=>x.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:o,setCardPreferences:i}=s.useEditorStore(x=>x.actions),l=s.useEditorStore(x=>x.queryResultColumns);s.useEditorStore(x=>{var j;return(j=x.card.preferences)==null?void 0:j.filterOnClickColumnIndex}),C.useEffect(()=>{l&&n(new Array(l.length).fill(!1))},[l]);function c(x,j){var b,m;j?a!=null&&a.onClickFilter&&((b=a==null?void 0:a.onClickFilter)==null?void 0:b.length)>0?i({...a,onClickFilter:[...a.onClickFilter,{columnIndex:x,expression:""}]}):i({...a,onClickFilter:[{columnIndex:x,expression:""}]}):(i({...a,onClickFilter:(m=a==null?void 0:a.onClickFilter)==null?void 0:m.filter(p=>p.columnIndex!==x)}),n(p=>{const f=[...p];return f[x]=!1,f}))}function d(x,j){var m;const b=(m=a==null?void 0:a.onClickFilter)==null?void 0:m.map(p=>p.columnIndex===x?{...p,expression:j.target.value}:p);i({...a,onClickFilter:b})}function u(x){var j,b,m,p;if(t!=null&&t[x]||(b=(j=a==null?void 0:a.onClickFilter)==null?void 0:j.find(f=>f.columnIndex===x))!=null&&b.expression)return e.jsx(s.Input,{value:(p=(m=a==null?void 0:a.onClickFilter)==null?void 0:m.find(f=>f.columnIndex===x))==null?void 0:p.expression,onChange:f=>d(x,f),type:"text",className:"h-9 w-full font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"Expression"})}return e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"On Click"}),l==null?void 0:l.map((x,j)=>{var b,m;return e.jsx("div",{className:"xbg-red-100 group flex items-center justify-between space-y-2",children:e.jsxs("div",{className:"grow",children:[e.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsx(s.Checkbox,{checked:!!((b=a==null?void 0:a.onClickFilter)!=null&&b.find(p=>p.columnIndex===j)),onCheckedChange:p=>c(j,p)}),e.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:x}),e.jsx("div",{className:"flex items-center gap-2",children:((m=a==null?void 0:a.onClickFilter)==null?void 0:m.find(p=>p.columnIndex===j))&&e.jsx(s.Pencil,{onClick:()=>{n(p=>{const f=[...p];return f[j]=!p[j],f})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),u(j)]})},x)})]})}function ve(){var l,c,d;const t=s.useEditorStore(u=>u.card.preferences),n=s.useEditorStore(u=>u.card.cfg),{setCardCfg:a,setCardPreferences:r,setChartOrientation:o}=s.useEditorStore(u=>u.actions);(l=n==null?void 0:n.options)!=null&&l.indexAxis;function i(u){o(u)}return e.jsxs(s.RadioGroup,{value:((c=t==null?void 0:t.chartOptions)==null?void 0:c.indexAxis)||((d=n==null?void 0:n.options)==null?void 0:d.indexAxis)||"x",onValueChange:i,className:"flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"x",id:"r1"}),e.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"y",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const be="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Pe(t,n){var r,o,i;const a=s.getNumberAxis(t,n);return((i=(o=(r=t==null?void 0:t.chartOptions)==null?void 0:r.scales)==null?void 0:o[a])==null?void 0:i.type)||"linear"}function hs(){var _,G,H,Q,Z,P;const[t,n]=C.useState(!1),a=s.useEditorStore(z=>{var A;return(A=z.card)==null?void 0:A.preferences}),r=s.useEditorStore(z=>{var A;return(A=z.card)==null?void 0:A.cfg}),o=s.getNumberAxis(a,r),[i,l]=C.useState(Pe(a)),[c,d]=C.useState(((H=(G=(_=a==null?void 0:a.chartOptions)==null?void 0:_.scales)==null?void 0:G[o])==null?void 0:H.min)||""),[u,x]=C.useState(((P=(Z=(Q=a==null?void 0:a.chartOptions)==null?void 0:Q.scales)==null?void 0:Z[o])==null?void 0:P.max)||""),[j,b]=C.useState(c||u?"custom":"auto"),[m,p]=C.useState(""),[f,k]=C.useState(0),[y,L]=C.useState(""),[w,T]=C.useState(""),[E,O]=C.useState(""),R=s.useEditorStore(z=>z.actions.setCardPreferences),{updateCardInFrame:F}=s.useEditorActions(),q=s.useEditorStore(z=>z.card),h=s.useEditorStore(z=>{var A;return(A=z.card)==null?void 0:A.type}),g=["pie","doughnut","polarArea"].includes(h);C.useEffect(()=>{var z,A,X,J,W,K,$,se,ee,S,V,U,ne,le;l(Pe(a)),d(((X=(A=(z=a==null?void 0:a.chartOptions)==null?void 0:z.scales)==null?void 0:A[o])==null?void 0:X.min)===0?0:""),x(((K=(W=(J=a==null?void 0:a.chartOptions)==null?void 0:J.scales)==null?void 0:W[o])==null?void 0:K.max)||""),p(((S=(ee=(se=($=a==null?void 0:a.chartOptions)==null?void 0:$.scales)==null?void 0:se[o])==null?void 0:ee.ticks)==null?void 0:S.stepSize)||""),k(((V=a==null?void 0:a.numberAxisFormat)==null?void 0:V.decimalPlaces)||0),L(((U=a==null?void 0:a.numberAxisFormat)==null?void 0:U.suffix)||""),T(((ne=a==null?void 0:a.numberAxisFormat)==null?void 0:ne.currency)||""),O(((le=a==null?void 0:a.numberAxisFormat)==null?void 0:le.locale)||"")},[t,a,o]);function I(z,A){return A===""||/^[0-9\b]+$/.test(A)?Number(A):Number(z)}function v(){const z=[...new Set(s.LOCALE_CURRENCY_PAIRS.map(A=>A.currency))];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsx(s.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxs(s.Select,{value:w||"none",onValueChange:A=>T(A==="none"?"":A),children:[e.jsx(s.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Currency"}),e.jsx(s.SelectItem,{value:"none",children:"None"}),z.map(A=>e.jsx(s.SelectItem,{value:A,children:A},A))]})})]}),e.jsxs(s.Select,{value:E,onValueChange:A=>O(A),children:[e.jsx(s.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Locale"}),s.LOCALE_CURRENCY_PAIRS.map(A=>e.jsx(s.SelectItem,{value:A.locale,children:A.locale},A.locale))]})})]})]}),e.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsx(s.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsx(s.Input,{value:f,onChange:A=>k(Number(A.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${be}`})]})]})}function M(){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(s.Label,{htmlFor:"range",children:"Range"}),e.jsx(s.Input,{id:"min",value:c,onChange:z=>d(A=>I(A,z.target.value)),className:`col-span-1 h-8 w-full ${be}`}),e.jsx(s.Input,{value:u,onChange:z=>x(A=>I(A,z.target.value)),id:"max",className:`col-span-1 h-8 w-full ${be}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(s.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsx(s.Input,{value:m,onChange:z=>p(A=>I(A,z.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${be}`})]})]})}function B(){var J;let z={};j==="custom"&&(z={min:c,max:u,ticks:{stepSize:m}});const A={...a||{},chartOptions:{...a==null?void 0:a.chartOptions,scales:{...(J=a==null?void 0:a.chartOptions)==null?void 0:J.scales,[o]:{type:i,...i==="linear"?z:{}}}},numberAxisFormat:{decimalPlaces:f,suffix:y,currency:w,locale:E}};console.log(A),R(A);const X={...q,preferences:A};F(X)}return e.jsxs(s.Popover,{onOpenChange:z=>n(z),children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsx(s.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsx(s.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(s.Label,{htmlFor:"scale",children:"Type"}),e.jsxs(s.Select,{disabled:g,value:i,onValueChange:z=>l(z),children:[e.jsx(s.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{id:"type",children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Option"}),e.jsx(s.SelectItem,{value:"linear",children:"Linear"}),e.jsx(s.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),i=="linear"&&e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsx(s.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxs(s.RadioGroup,{disabled:g,id:"scale-option",value:j,onValueChange:z=>b(z),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"auto",id:"r1"}),e.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"custom",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),j==="custom"&&i=="linear"&&M(),v(),e.jsx(s.SelectSeparator,{}),e.jsx("div",{className:"grid grid-cols-3",children:e.jsx(s.Button,{onClick:B,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function Mt({idx:t}){var c;const n=s.useEditorStore(d=>{var u;return(u=d.card)==null?void 0:u.preferences}),a=s.useEditorStore(d=>{var u;return(u=d.card.preferences)==null?void 0:u.datasetOptions}),r=s.useEditorStore(d=>d.actions.setCardPreferences),o=(c=n==null?void 0:n.chartOptions)==null?void 0:c.indexAxis,i=a==null?void 0:a.find(d=>d.idx===t);function l(d,u){(d==="end"||d==="start")&&s.getContrastColor(s.getCanvasBackgroundColor());const x={display:d!=="none",align:d,anchor:d,clamp:!0};if(!i)r({...n,datasetOptions:[...a||[],{idx:u,datalabels:x}]});else{const j={...i};j.datalabels=x;const b=a==null?void 0:a.map(m=>m.idx===u?j:m);r({...n,datasetOptions:b})}}return e.jsxs(s.Popover,{children:[e.jsx(s.PopoverTrigger,{children:e.jsx(Hs,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsx(s.PopoverContent,{className:"w-fit p-1",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(s.Button,{onClick:()=>l("none",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(s.X,{className:"size-4"})}),e.jsx(s.Button,{onClick:()=>l("start",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(Ls,{className:s.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx(s.Button,{onClick:()=>l("center",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(Ms,{className:s.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx(s.Button,{onClick:()=>l("end",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(Os,{className:s.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function xs(){const t=s.useEditorStore(u=>u.card),n=s.useEditorStore(u=>{var x,j,b;return(b=(j=(x=u==null?void 0:u.card)==null?void 0:x.preferences)==null?void 0:j.chartOptions)==null?void 0:b.indexAxis}),{data:a}=s.useDashboardCardQuery(t),r=n==="y"?"Y axis":"X axis",o=n==="y"?"X axis":"Y axis",{keys:i,metricKeys:l,dimensionKeys:c}=s.getKeys((a==null?void 0:a.records)||[]);let d=l;if(["stackedBar","stackedLine"].includes(t.type)){const u=s.pivotData({dataArray:(a==null?void 0:a.records)||[],groupKey:c[0],pivotKey:c[1],valueKey:d[0]}),{metricKeys:x}=s.getKeys(u);d=x}return i.length===0?null:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:r}),e.jsx("div",{className:"my-1 space-y-1",children:e.jsx("div",{className:"rounded-md bg-muted/70 px-3 py-2 hover:bg-muted",children:e.jsx("p",{title:c[0],children:ps(c[0])})})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsx(s.Label,{children:o}),e.jsx(hs,{})]}),e.jsx("div",{className:"my-1 max-h-[125px] space-y-1 overflow-y-auto",children:d.map((u,x)=>e.jsx(zt,{col:u,idx:x},u))})]})]})}function ps(t,n=30){return t.length>n?t.slice(0,n)+"...":t}function zt({col:t,idx:n}){const a=s.useEditorStore(c=>{var d;return(d=c.card)==null?void 0:d.preferences}),r=s.useEditorStore(c=>{var d;return(d=c.card.preferences)==null?void 0:d.datasetOptions}),o=r==null?void 0:r.find(c=>c.idx===n),{setCardPreferences:i}=s.useEditorStore(c=>c.actions);function l(c){if(!o)i({...a,datasetOptions:[...r||[],{idx:n,type:c==="area"?"line":c,fill:c==="area"?"origin":""}]});else{const d={...o};d.type=c==="area"?"line":c,d.fill=c==="area"?"origin":"";const u=r==null?void 0:r.map(x=>x.idx===n?d:x);i({...a,datasetOptions:u})}}return e.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-3 py-2 hover:bg-muted",children:[e.jsx("p",{title:t,children:ps(t)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ke,{onClick:()=>l("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(Ee,{onClick:()=>l("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(Ss,{onClick:()=>l("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(Mt,{idx:n})]})]})}function fs(){const t=s.useEditorStore(m=>m.selectedConnectionId),n=s.useEditorStore(m=>m.selectedDatamodelId),a=s.useEditorStore(m=>m.selectedDatabaseName),r=s.useEditorStore(m=>m.selectedSchemaName),o=s.useEditorStore(m=>m.selectedTableName),i=s.useDashboardStore(m=>m.dashboard.filters)||[],l=s.useDashboardStore(m=>m.actions.addFilter),c=s.useDashboardStore(m=>m.actions.removeFilter),{removeFilterValues:d}=s.useDashboardActions(),{modelItems:u,tableName:x,connectionType:j}=re();function b(m,p="dashboard"){var R;const f=s.fmt(m.column_name),k=s.fmt(a||""),y=s.fmt(r||""),L=s.fmt(x);let w=s.getQualifiedTableName(y,L,j),T=`${w}.${f}`;const E=(R=u==null?void 0:u.find(F=>F.id===n))==null?void 0:R.name;n&&n!=="none"&&(T=`${s.DATAMODEL_NAMESPCACE}.${E}.${f}`,w=`${s.DATAMODEL_NAMESPCACE}.${E}`);const O=i==null?void 0:i.find(F=>F.column===T&&F.table===L&&(F.database===k||F.database===a));if(O)d(O.id),c(O.id);else{const F=s.v4();return x==="api"&&t?(l({location:p,id:F,column:T,title:m.column_name,dataType:m.data_type,table:"api",database:"",connectionId:t,operation:"in",sql:s.getDefaultFilterSql(m.data_type,w,f)}),F):(l({id:F,location:p,column:T,title:m.column_name,dataType:m.data_type,table:o||"",database:a||"",connectionId:t||"",operation:"in",sql:s.getDefaultFilterSql(m.data_type,w,f)}),F)}}return{assignFilter:b}}function ue(){const t=s.useDashboardStore(c=>c.dashboard.filters),n=s.useEditorStore(c=>c.frame),{setFrame:a}=s.useEditorActions(),{columns:r}=re(),{assignFilter:o}=fs();function i(c){const d=o(c,"frame");a({...n,filterId:d})}const l=t==null?void 0:t.find(c=>c.id===n.filterId);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(s.Label,{children:"Card Filter"}),e.jsx(Ft,{onSelect:i,columns:r}),l&&e.jsx(s.FilterHeader,{filter:l})]})}function Ft({columns:t,onSelect:n}){var l;const[a,r]=Ve.useState(!1),[o,i]=Ve.useState("");return e.jsxs(s.Popover,{open:a,onOpenChange:r,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsxs(s.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":a,className:"w-full justify-between font-normal",children:[o?(l=t.find(c=>c.column_name===o))==null?void 0:l.column_name:"Select Column...",e.jsx(s.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(s.PopoverContent,{className:"w-[200px] p-0",children:e.jsxs(s.Command,{children:[e.jsx(s.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxs(s.CommandList,{children:[e.jsx(s.CommandEmpty,{children:"No framework found."}),e.jsx(s.CommandGroup,{children:t.map(c=>e.jsxs(s.CommandItem,{value:c.column_name,onSelect:d=>{const u=d===o?"":d;i(u),r(!1),u&&n(c)},children:[c.column_name,e.jsx(s.CheckIcon,{className:s.cn("ml-auto h-4 w-4",o===c.column_name?"opacity-100":"opacity-0")})]},c.column_name))})]})]})})]})}function Vt({cardType:t}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:`${s.titleCase(t)} Chart`}),e.jsxs(s.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"x-axis - category"}),e.jsx("li",{children:"y-axis1 - number"}),e.jsx("li",{children:"y-axis2 - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/bar-line-area",children:"example"})," in the docs."]})]})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ve,{}),e.jsx(xs,{})]})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ie,{}),e.jsx(ue,{})]})]})]})})}function Ae(){var o,i,l;const t=s.useEditorStore(c=>c.card.cfg),n=s.useEditorStore(c=>c.actions.setCardCfg),a=s.useEditorStore(c=>c.card.type);function r(c){var x;const d={datalabels:{display:c!=="none",align:c,anchor:c,clamp:!0}},u={...t,options:{...t==null?void 0:t.options,plugins:{...(x=t==null?void 0:t.options)==null?void 0:x.plugins,...d}}};n(u),console.log(c)}return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid"].includes(a)&&e.jsx(hs,{})]}),e.jsxs(s.Select,{value:(l=(i=(o=t==null?void 0:t.options)==null?void 0:o.plugins)==null?void 0:i.datalabels)==null?void 0:l.anchor,onValueChange:r,defaultValue:"none",children:[e.jsx(s.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{placeholder:"Select position"})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Data Labels"}),e.jsx(s.SelectItem,{value:"none",children:"None"}),a!=="pyramid"&&e.jsx(s.SelectItem,{value:"start",children:"Start"}),e.jsx(s.SelectItem,{value:"center",children:"Center"}),a!=="pyramid"&&e.jsx(s.SelectItem,{value:"end",children:"End"})]})})]})]})}function Rt({cardType:t}){function n(a){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:a==="bubble"?"SELECT label, [group], x-axis, y-axis, radius FROM table":"SELECT label, [group], x-axis, y-axis FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"label - category"}),e.jsx("li",{children:"group (optional) - category"}),e.jsx("li",{children:"x-axis - number"}),e.jsx("li",{children:"y-axis - number"}),a==="bubble"&&e.jsx("li",{children:"radius - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:i=>i.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/bubble",children:"example"})," in the docs."]})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:`${s.titleCase(t)} Chart`}),e.jsx(s.AccordionContent,{className:"space-y-4 font-mono text-xs",children:n(t)})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsx(s.AccordionContent,{className:"px-2",children:e.jsx(Ae,{})})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ie,{}),e.jsx(ue,{})]})]})]})})}const qt={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},Bt={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function _t(){const t=s.useEditorStore(n=>n.card.type);return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(s.Accordion,{className:" ",type:"single",collapsible:!0,children:Pt(t)}),e.jsx("section",{className:"",children:["line","bar"].includes(t)&&e.jsx(ve,{})}),!["kpi"].includes(t)&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ae,{}),e.jsx(ie,{}),e.jsx(ue,{})]})]})}function Pt(t){if(["line","bar"].includes(t))return e.jsxs(e.Fragment,{children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsx("p",{children:"Chart Query"})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxs(s.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxs("p",{children:["Click ",e.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsx("pre",{children:JSON.stringify(qt,null,2)})]})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxs(s.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxs("p",{children:["Click ",e.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsx("pre",{children:JSON.stringify(Bt,null,2)})]})]})]});if(t==="bubble")return e.jsx(e.Fragment,{children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:t})," chart query?"]})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(t==="scatter")return e.jsx(e.Fragment,{children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:t})," chart query?"]})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(t))return e.jsx(e.Fragment,{children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:[e.jsx("span",{children:t==="polarArea"?"Polar":t.charAt(0).toUpperCase()+t.slice(1)})," ","chart query"]})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function Ht(){var d,u,x,j,b;const t=s.useEditorStore(m=>m.card.preferences),n=s.useEditorStore(m=>m.actions.setCardPreferences),a=s.useEditorStore(m=>m.actions.setNumberFormat);s.useEditorStore(m=>{var p,f;return(f=(p=m.card.preferences)==null?void 0:p.formatNumber)==null?void 0:f.decimalPlaces});const r=s.useEditorStore(m=>{var p,f;return(f=(p=m.card.preferences)==null?void 0:p.formatNumber)==null?void 0:f.locale}),o=s.useEditorStore(m=>{var p,f;return(f=(p=m.card.preferences)==null?void 0:p.formatNumber)==null?void 0:f.currency});s.useEditorStore(m=>m.actions.setFilterOnClickField);const i=s.useEditorStore(m=>{var p,f;return(f=(p=m.card.preferences)==null?void 0:p.formatNumber)==null?void 0:f.colorRanges})||[],l=s.useEditorStore(m=>m.actions.setColorRanges),c=[...new Set(s.LOCALE_CURRENCY_PAIRS.map(m=>m.currency))];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(s.Checkbox,{checked:!!((d=t==null?void 0:t.formatNumber)!=null&&d.enabled),onCheckedChange:m=>{n({...t,formatNumber:{...t==null?void 0:t.formatNumber,enabled:m}})}}),e.jsx(s.Label,{children:"Format Number"})]}),((u=t==null?void 0:t.formatNumber)==null?void 0:u.enabled)===!0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{children:e.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Locale"}),e.jsxs(s.Select,{value:r||"none",onValueChange:m=>{var p,f,k;return a(((p=t==null?void 0:t.formatNumber)==null?void 0:p.decimalPlaces)||0,((f=t==null?void 0:t.formatNumber)==null?void 0:f.currency)||"",m,((k=t==null?void 0:t.formatNumber)==null?void 0:k.suffix)||"")},children:[e.jsx(s.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Format"}),e.jsx(s.SelectItem,{value:"none",children:"None"},"none"),s.LOCALE_CURRENCY_PAIRS.map(m=>e.jsx(s.SelectItem,{value:m.locale,children:m.locale},m.locale))]})})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Currency"}),e.jsxs(s.Select,{value:o||"none",onValueChange:m=>{var p,f,k;console.log("currency",m),a(((p=t==null?void 0:t.formatNumber)==null?void 0:p.decimalPlaces)||0,m==="none"?"":m,((f=t==null?void 0:t.formatNumber)==null?void 0:f.locale)||"",((k=t==null?void 0:t.formatNumber)==null?void 0:k.suffix)||"")},children:[e.jsx(s.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Currency"}),e.jsx(s.SelectItem,{value:"none",children:"None"},"none"),c.map(m=>e.jsx(s.SelectItem,{value:m,children:m},m))]})})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Decimals"}),e.jsxs(s.Select,{value:((j=(x=t==null?void 0:t.formatNumber)==null?void 0:x.decimalPlaces)==null?void 0:j.toString())||"0",onValueChange:m=>{var p,f,k;return a(Number(m),((p=t==null?void 0:t.formatNumber)==null?void 0:p.currency)||"",((f=t==null?void 0:t.formatNumber)==null?void 0:f.locale)||"",((k=t==null?void 0:t.formatNumber)==null?void 0:k.suffix)||"")},children:[e.jsx(s.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:["0","1","2","3","4"].map(m=>e.jsx(s.SelectItem,{value:m,children:m},m))})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Suffix"}),e.jsx(s.Input,{value:((b=t==null?void 0:t.formatNumber)==null?void 0:b.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:m=>{var p,f,k;return a(((p=t==null?void 0:t.formatNumber)==null?void 0:p.decimalPlaces)||0,((f=t==null?void 0:t.formatNumber)==null?void 0:f.currency)||"",((k=t==null?void 0:t.formatNumber)==null?void 0:k.locale)||"",m.target.value)}})]})]})]})}),e.jsx(s.Separator,{className:"my-3"}),e.jsx(s.ColorFormat,{colorRanges:i,setColorRanges:l})]})]})}function Gt(){return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(s.Accordion,{type:"single",collapsible:!0,children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxs(s.AccordionContent,{className:"font-mono",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"current - number"}),e.jsx("li",{children:"previous - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/kpi",children:"example"})," in the docs."]})]})]})}),e.jsx("section",{className:"",children:e.jsx(Ht,{})}),e.jsx("div",{}),e.jsx("div",{})]})}const Ut=[{label:"Mercator",value:"mercator"},{label:"Azimuthal Equidistant",value:"azimuthalEquidistant"},{label:"Gnomonic",value:"gnomonic"},{label:"Orthographic",value:"orthographic"},{label:"Stereographic",value:"stereographic"},{label:"Equal Earth",value:"equalEarth"},{label:"Albers",value:"albers"},{label:"Albers USA",value:"albersUsa"},{label:"Conic Conformal",value:"conicConformal"},{label:"Conic Equal Area",value:"conicEqualArea"},{label:"Conic Equidistant",value:"conicEquidistant"},{label:"Equirectangular",value:"equirectangular"},{label:"Transverse Mercator",value:"transverseMercator"},{label:"Natural Earth 1",value:"naturalEarth1"}],$t=["blues","brBG","buGn","buPu","cividis","cool","cubehelixDefault","gnBu","greens","greys","inferno","magma","orRd","oranges","pRGn","piYG","plasma","puBu","puBuGn","puOr","puRd","purples","rainbow","rdBu","rdGy","rdPu","rdYlBu","rdYlGn","reds","sinebow","spectral","turbo","viridis","warm","ylGn","ylGnBu","ylOrBr","ylOrRd"],Qt=$t.map(t=>({label:t,value:t}));function Jt(){var d,u,x,j,b,m,p,f,k,y,L,w,T,E,O,R,F,q;const t=s.useEditorStore(h=>h.card),n=(u=(d=t==null?void 0:t.preferences)==null?void 0:d.mapVisualOptions)==null?void 0:u.topoJsonUrl,[a,r]=C.useState(((j=(x=t==null?void 0:t.preferences)==null?void 0:x.mapVisualOptions)==null?void 0:j.customTopoJsonUrl)||""),{setCardPreferences:o}=s.useEditorActions(),{data:i}=s.useTopoJson(t),l=Object.keys((i==null?void 0:i.objects)||{}).map(h=>({label:h,value:h}))||[],c=[{label:"US States 10m",value:"https://unpkg.com/us-atlas/states-10m.json"},{label:"Countries 50m",value:"https://unpkg.com/world-atlas/countries-50m.json"},{label:"Custom",value:"custom"}];return e.jsxs("div",{className:"p-6",children:[e.jsx(he,{summary:"Map Query",children:e.jsx("p",{className:"rounded-md bg-muted p-2 font-mono text-xs",children:"SELECT country, value FROM table"})}),e.jsx(s.Separator,{className:"my-4"}),e.jsx(he,{open:!0,summary:"Settings",children:e.jsxs("div",{className:"space-y-3 px-2",children:[e.jsx(ae,{className:"h-9",options:c,onValueChange:h=>{console.log("value",h),o({...t.preferences,mapVisualOptions:{topoJsonUrl:h}})},value:n||"",label:"Select Map"}),n==="custom"&&e.jsx(s.Input,{onChange:h=>{r(h.target.value)},onBlur:()=>{var h;console.log("onBlur",a),o({...t.preferences,mapVisualOptions:{...(h=t.preferences)==null?void 0:h.mapVisualOptions,customTopoJsonUrl:a}})},value:a,className:`h-9 w-full ${s.removeRing}`,placeholder:"Custom URL"}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:"Map Object"}),e.jsx(ae,{className:"h-9",options:l,value:((m=(b=t.preferences)==null?void 0:b.mapVisualOptions)==null?void 0:m.objectKey)||"",label:"Map Object",onValueChange:h=>{var g;o({...t.preferences,mapVisualOptions:{...(g=t.preferences)==null?void 0:g.mapVisualOptions,objectKey:h}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:"Projection"}),e.jsx(ae,{className:"h-9",options:Ut,value:((f=(p=t.preferences)==null?void 0:p.mapVisualOptions)==null?void 0:f.projection)||"",label:"Projection",onValueChange:h=>{var g;o({...t.preferences,mapVisualOptions:{...(g=t.preferences)==null?void 0:g.mapVisualOptions,projection:h}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:"Colors"}),e.jsx(ae,{className:"h-9",options:Qt,value:((y=(k=t.preferences)==null?void 0:k.mapVisualOptions)==null?void 0:y.colorScale)||"",label:"Select Color Scale",onValueChange:h=>{var g;o({...t.preferences,mapVisualOptions:{...(g=t.preferences)==null?void 0:g.mapVisualOptions,colorScale:h}})}})]})]})]})}),e.jsx(s.Separator,{className:"my-4"}),e.jsx(he,{className:"",summary:"Scale Options",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(s.Input,{className:`h-9 w-full ${s.removeRing}`,type:"number",step:.1,value:((w=(L=t.preferences)==null?void 0:L.mapVisualOptions)==null?void 0:w.projectionScale)||1,onChange:h=>{var g;o({...t.preferences,mapVisualOptions:{...(g=t.preferences)==null?void 0:g.mapVisualOptions,projectionScale:Number(h.target.value)}})}}),e.jsx(s.Label,{children:"X"}),e.jsx(s.Input,{className:`h-9 w-full ${s.removeRing}`,type:"number",step:10,value:((O=(E=(T=t.preferences)==null?void 0:T.mapVisualOptions)==null?void 0:E.projectionOffset)==null?void 0:O[0])||0,onChange:h=>{var g,I,v,M;o({...t.preferences,mapVisualOptions:{...(g=t.preferences)==null?void 0:g.mapVisualOptions,projectionOffset:[Number(h.target.value),((M=(v=(I=t.preferences)==null?void 0:I.mapVisualOptions)==null?void 0:v.projectionOffset)==null?void 0:M[1])||0]}})}}),e.jsx(s.Label,{children:"Y"}),e.jsx(s.Input,{className:`h-9 w-full ${s.removeRing}`,type:"number",step:10,value:((q=(F=(R=t.preferences)==null?void 0:R.mapVisualOptions)==null?void 0:F.projectionOffset)==null?void 0:q[1])||0,onChange:h=>{var g,I,v,M;o({...t.preferences,mapVisualOptions:{...(g=t.preferences)==null?void 0:g.mapVisualOptions,projectionOffset:[((M=(v=(I=t.preferences)==null?void 0:I.mapVisualOptions)==null?void 0:v.projectionOffset)==null?void 0:M[0])||0,Number(h.target.value)]}})}})]})}),e.jsx(s.Separator,{className:"my-4"}),e.jsx(ie,{})]})}function Wt(){var r;const t=s.useEditorStore(o=>o.card.preferences),{setCardPreferences:n}=s.useEditorStore(o=>o.actions);function a(o){n({...t,textVisualOptions:{...t==null?void 0:t.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxs(s.RadioGroup,{value:(r=t==null?void 0:t.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:a,className:"flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"static",id:"r1"}),e.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function ye({cardType:t,docContent:n,suffix:a="Chart"}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:`${s.titleCase(t)} ${a}`}),e.jsx(s.AccordionContent,{children:n||e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"label - category"}),e.jsx("li",{children:"measure - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar",children:"example"})," in the docs."]})]})})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[t==="range"&&e.jsx(ve,{}),t!=="text"&&e.jsx(Ae,{}),t==="text"&&e.jsx(Wt,{})]})]}),!["range","text"].includes(t)&&e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ie,{}),e.jsx(ue,{})]})]})]})})}function Kt(){const t=s.useEditorStore(r=>{var o,i;return(i=(o=r==null?void 0:r.card)==null?void 0:o.preferences)==null?void 0:i.sortChart}),{setSortChart:n}=s.useEditorActions();function a(){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Sort"}),e.jsx(ae,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:t||"none",onValueChange:r=>{n(r)}})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:"Stacked Chart"}),e.jsxs(s.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"x-axis - category"}),e.jsx("li",{children:"stack by - category"}),e.jsx("li",{children:"y-axis - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/stacked",children:"example"})," in the docs."]})]})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ve,{}),a(),e.jsx(xs,{})]})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ie,{}),e.jsx(ue,{})]})]})]})})}function Xt({}){const t=s.useEditorStore(r=>{var o;return(o=r.card)==null?void 0:o.preferences}),n=s.useEditorStore(r=>r.actions.setCardPreferences),a=r=>{n({...t,allowDownload:r})};return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(s.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ie,{}),e.jsx(ue,{})]})]})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Checkbox,{onCheckedChange:a,id:"allow-download"}),e.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const Yt=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/tornado",children:"example"})," in the docs."]})]}),Zt=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/range",children:"example"})," in the docs."]})]}),ea=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/text",children:"example"})," in the docs."]})]});function sa(){const t=s.useEditorStore(a=>a.card.type);function n(a){switch(a){case"stackedBar":case"stackedLine":return e.jsx(Kt,{});case"pyramid":return e.jsx(ye,{docContent:Yt,cardType:a});case"kpi":return e.jsx(Gt,{});case"line":case"bar":return e.jsx(Vt,{cardType:a});case"range":return e.jsx(ye,{docContent:Zt,cardType:a});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsx(ye,{cardType:a});case"bubble":case"scatter":return e.jsx(Rt,{cardType:a});case"table":return e.jsx(Xt,{cardType:a});case"text":return e.jsx(ye,{docContent:ea,cardType:a,suffix:"Visual"});case"map":return e.jsx(Jt,{});case"custom":return e.jsx(Ot,{});default:return e.jsx(_t,{})}}return e.jsxs(s.ScrollArea,{className:"h-full w-full text-sm",children:[n(t),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})}function ta(){const t=s.useEditorStore(n=>n.isShowingVisual);return e.jsxs(s.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsx(s.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsx(gt,{})}),e.jsx(s.ResizableHandle,{withHandle:!0,className:"border"}),e.jsx(s.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:t?e.jsxs(s.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(s.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsx(sa,{})})}),e.jsx(s.ResizableHandle,{className:"border"}),e.jsx(s.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsx(_e,{})})]}):e.jsx(_e,{})})]})}function aa({authToken:t,onSave:n,onClose:a}){s.useDashboardStore(l=>l.themeStyle);const r=s.useEditorStore(l=>l.actions.setOnSave),o=s.useEditorStore(l=>l.actions.setOnClose),i=s.useDashboardStore(l=>l.actions.setAuthToken);return C.useEffect(()=>{n&&r(n),a&&o(a)},[n,r,a,o]),C.useEffect(()=>{t&&t.accessToken&&i(t)},[t,i]),e.jsx(s.ErrorBoundary,{FallbackComponent:s.Fallback,children:e.jsxs(s.EditorPanel,{style:{},className:"rounded-none",role:"editor-panel",children:[e.jsx(s.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsx(ts,{})}),e.jsx(s.EditorMain,{children:e.jsx(ta,{})})]})})}function na(){s.useDashboardStore(l=>l.selectedCardId);const t=s.useDashboardStore(l=>l.selectedSheetId),{setIsVisualEditing:n}=s.useDashboardStore(l=>l.actions),a=s.useDashboardStore(l=>l.isVisualEditing),r=s.useDashboardStore(l=>l.actions.updateFrame);function o(l){t&&(r(t,l),n(!1))}function i(){n(!1)}return e.jsx("div",{role:"editor-container",className:s.cn("flex grow",{"max-h-0 overflow-hidden":!a}),children:e.jsx(aa,{onSave:o,onClose:i})})}function ra(){const t=s.useEditorStore(i=>i.selectedDatabaseName),n=s.useEditorStore(i=>i.selectedTableName),a=s.useDashboardStore(i=>i.dashboard.filters)||[],{columns:r}=re(),{assignFilter:o}=fs();return e.jsx(s.ScrollArea,{className:"flex-1 basis-0 flex-col px-3",children:r==null?void 0:r.map(i=>{const l=a==null?void 0:a.find(c=>c.column===s.fmt(i.column_name)&&c.table===n&&c.database===t);return e.jsx("div",{onClick:()=>o(i),className:s.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":l}),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ss,{column:i}),e.jsx("span",{children:i.column_name})]})},i.column_name)})})}function oa(){s.useDashboardStore(n=>n.showFilters);const t=s.useDashboardStore(n=>n.actions.setShowFilters);return e.jsxs("section",{className:"relative flex min-w-[320px] grow flex-col border-l px-1",children:[e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsx(s.Label,{className:"px-2 text-lg",children:"Filters"}),e.jsx(s.Button,{onClick:()=>t(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsx(s.Cross2Icon,{})})]}),e.jsx("div",{className:"flex grow",children:e.jsx(ts,{ColumnsComponent:()=>e.jsx(ra,{})})})]})}function ia(){const t=s.useDashboardStore(r=>r.dashboard.filters),n=s.useDashboardStore(r=>r.theme),a=t==null?void 0:t.filter(r=>r.hide);return a!=null&&a.length?e.jsx("div",{className:s.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":n==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":n==="dark"}),children:a==null?void 0:a.map(r=>e.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[e.jsx(s.FilterHeader,{filter:r}),e.jsx(s.FilterComponent,{filter:r})]},r.id))}):null}function la(){const t=s.useDashboardStore(r=>r.showFilters),n=s.useDashboardStore(r=>r.isVisualEditing),a=s.useDashboardStore(r=>r.isDashboardEditing);return e.jsxs("div",{role:"dashboard-plus-main",className:s.cn("",{"max-h-0 overflow-hidden":n,"flex grow overflow-auto":!n}),children:[e.jsxs("section",{className:"flex grow flex-col",children:[a&&e.jsx(ia,{}),e.jsx(s.DashboardTabs,{})]}),t&&e.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsx(oa,{})})]})}function ca(){const t=s.useDashboardStore(o=>o.dashboard),n=s.useDashboardStore(o=>o.actions.setDashboard),a=s.useDashboardStore(o=>o.showDashboardJSON),r=s.useDashboardStore(o=>o.actions.setShowDashboardJSON);return e.jsxs("div",{className:s.cn("relative p-2",{hidden:!a}),children:[e.jsxs(s.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>r(!1),children:[e.jsx(s.X,{className:"mr-2 h-4 w-4"}),"Close"]}),e.jsx(s.de,{onChange:o=>{if(o)try{JSON.parse(o),n(JSON.parse(o))}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 da({showControls:t=!1,showFooter:n=!0,...a}){return e.jsx(s.ErrorBoundary,{FallbackComponent:s.Fallback,children:e.jsxs(s.SemaphorContextProvider,{dashboardProps:a,children:[e.jsx(s.$e,{}),e.jsxs(s.UXProvider,{children:[e.jsx(ca,{}),e.jsxs(s.DashboardPanel,{...a,children:[t&&e.jsx(Ys,{}),e.jsx(na,{}),e.jsx(la,{})]})]})]})})}exports.Dashboard=s.Dashboard;exports.DashboardWC=s.DashboardWC;exports.SemaphorDataProvider=s.SemaphorQueryClient;exports.SemaphorQueryClient=s.SemaphorQueryClient;exports.createSqlGenConfig=s.createSqlGenConfig;exports.fmt=s.fmt;exports.getColumnDataType=s.getColumnDataType;exports.getFilterValueType=s.getFilterValueType;exports.getFormattedTableNameForQuery=s.getFormattedTableNameForQuery;exports.getQualifiedTableName=s.getQualifiedTableName;exports.getSql=s.getSql;exports.invalidateToken=s.invalidateToken;exports.isBooleanDataType=s.isBooleanDataType;exports.isColumnInSqlGen=s.isColumnInSqlGen;exports.isDateDataType=s.isDateDataType;exports.isNumberDataType=s.isNumberDataType;exports.isTextDataType=s.isTextDataType;exports.resolveDataType=s.resolveDataType;exports.resolveDatamodelName=s.resolveDatamodelName;exports.useCard=s.useCard;exports.useDashboardActions=s.useDashboardActions;exports.useDashboardStore=s.useDashboardStore;exports.useDateFilterHook=s.useDateFilterHook;exports.useEditorActions=s.useEditorActions;exports.useEditorStore=s.useEditorStore;exports.useTextFilterHook=s.useTextFilterHook;exports.SelectComponent=ce;exports.Surfboard=da;exports.cleanCard=Ze;exports.downloadPdf=es;exports.getDashbaordStateWithoutData=Te;exports.useEditorAside=re;
229
+ ${x}
230
+
231
+ `;V(D)}function ae(){return e.jsxs(e.Fragment,{children:[i&&e.jsx("div",{className:"relative flex w-1/3 min-w-0 grow overflow-hidden text-xs",role:"editor-filter-container",children:e.jsx("div",{className:"mt-2 w-[99%]",children:e.jsx(gt,{jsonString:JSON.stringify(N,null,2)})})}),N&&N.length>0&&e.jsx(s.Button,{variant:"ghost",onClick:()=>l(!i),className:"absolute bottom-0 right-6 size-7 p-1",children:i?e.jsx(s.X,{className:"size-3.5 text-muted-foreground"}):e.jsx(s.Filter,{className:"size-3.5 text-muted-foreground"})})]})}function se(){return e.jsxs(s.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxs(s.ResizablePanel,{id:"1",order:1,defaultSize:r?20:100,className:"relative flex grow",children:[e.jsx("div",{id:"sql-container",className:"relative flex w-[99%]",children:e.jsx(pt,{})}),r&&e.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"sql"})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx(s.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxs(s.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsx("div",{id:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsx(ft,{})}),e.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"python"})]})]})]})}const G=(Q==null?void 0:Q.message)||((K=I==null?void 0:I.error)==null?void 0:K.message);return e.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxs("div",{className:"relative flex grow justify-between overflow-y-scroll",children:[se(),ae()]}),e.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxs(s.Button,{title:"Shift + Enter",disabled:H||P,onClick:()=>{O()},className:"shrink-0",size:"sm",children:[H||P?e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(s.Play,{className:"mr-2 h-4 w-4"}),"Run"]}),e.jsx(at,{sql:I==null?void 0:I.sql,error:G,onClick:W}),e.jsxs(s.Button,{onClick:Y,className:"",size:"sm",variant:"secondary",children:[e.jsx(ks,{className:"mr-2 size-4"}),"Clear"]}),e.jsx(s.Toggle,{pressed:r,onPressedChange:D=>o(D),className:"",size:"sm",children:e.jsx(xt,{className:"size-4 text-foreground/70"})}),e.jsx(ot,{})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(s.Button,{onClick:U,className:"w-full",size:"sm",variant:"secondary",children:[e.jsx(s.Cross2Icon,{className:"mr-2 size-4"}),"Close"]}),e.jsxs(s.Button,{onClick:B,size:"sm",variant:"secondary",children:[e.jsx(s.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]})]})]})]})}function bt({data:t}){var l;const[n,a]=S.useState([]),o=Object.keys(t[0]).map(d=>({accessorKey:d,header:({column:u})=>{const p=u.getIsSorted();return e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>u.toggleSorting(u.getIsSorted()==="asc"),children:[d,p==="asc"?e.jsx(s.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):p==="desc"?e.jsx(s.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),i=s.useReactTable({data:t,columns:o,getCoreRowModel:s.getCoreRowModel(),getPaginationRowModel:s.getPaginationRowModel(),onSortingChange:a,getSortedRowModel:s.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return e.jsx("div",{className:"font-mono text-xs text-foreground/95",children:e.jsxs("table",{className:"w-full",children:[e.jsx(s.TableHeader,{children:i.getHeaderGroups().map(d=>e.jsx(s.TableRow,{children:d.headers.map(u=>e.jsx(s.TableHead,{className:"sticky top-0 h-11 bg-muted font-semibold",children:u.isPlaceholder?null:s.flexRender(u.column.columnDef.header,u.getContext())},u.id))},d.id))}),e.jsx(s.TableBody,{children:(l=i.getRowModel().rows)!=null&&l.length?i.getRowModel().rows.map(d=>e.jsx(s.TableRow,{className:"whitespace-nowrap py-2","data-state":d.getIsSelected()&&"selected",children:d.getVisibleCells().map(u=>e.jsx(s.TableCell,{className:"py-3",children:s.flexRender(u.column.columnDef.cell,u.getContext())},u.id))},d.id)):e.jsx(s.TableRow,{children:e.jsx(s.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})})}function yt({card:t}){var T,C,E,M,A,R,V,q,m,L,_;const[n,a]=S.useState(!1),[r,o]=S.useState([]),{authToken:i}=s.useSemaphorContext(),l=s.getTokenParams(i==null?void 0:i.accessToken),d=s.useDashboardStore(g=>g.themeStyle),u={colors:((C=(T=d==null?void 0:d.chart)==null?void 0:T.dataset)==null?void 0:C.backgroundColor)||[]};(E=t.customCardPreferences)!=null&&E.inputData;const{getCard:p}=s.useCustomVisual(((M=t.customCardPreferences)==null?void 0:M.url)||""),c=((A=t.customCardPreferences)==null?void 0:A.visualType)||"single",j=s.useEditorStore(g=>g.frame),{setCustomCardPreferences:b}=s.useEditorActions(),{data:h}=s.useDashboardCardQuery(t),f=S.useCallback((g,k)=>{o(z=>({...z,[g]:k}))},[]);if(!((R=t.customCardPreferences)!=null&&R.componentName))return null;const x=p((V=t.customCardPreferences)==null?void 0:V.componentName);function N(g){a(g)}const y=Object.keys(((q=t.customCardPreferences)==null?void 0:q.dataInputCardIds)||{}).map(g=>{var I,H,P;const k=(H=(I=t.customCardPreferences)==null?void 0:I.dataInputCardIds)==null?void 0:H[g].cardId,z=(P=j==null?void 0:j.cards)==null?void 0:P.find($=>$.id===k);return z||null});return e.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:e.jsxs(S.Suspense,{fallback:e.jsx(e.Fragment,{}),children:[x&&c==="single"&&e.jsx(x,{params:l,theme:u,settings:(m=t.customCardPreferences)==null?void 0:m.settings,onDataChange:f,data:(h==null?void 0:h.records)||[]}),x&&c==="multiple"&&e.jsxs(e.Fragment,{children:[Object.keys(((L=t.customCardPreferences)==null?void 0:L.dataInputCardIds)||{}).map(g=>{var I,H,P;const k=(H=(I=t.customCardPreferences)==null?void 0:I.dataInputCardIds)==null?void 0:H[g].cardId,z=(P=j==null?void 0:j.cards)==null?void 0:P.find($=>$.id===k);if(z)return e.jsx(s.MultiInputEmptyRenderer,{onLoadingStatus:N,onDataChange:f,dataInputIndex:g,card:z},z.id+g)}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(x,{theme:u,onDataChange:f,settings:y.map(g=>{var k;return(k=g==null?void 0:g.customCardPreferences)==null?void 0:k.settings}),data:y.map(g=>g!=null&&g.id?r==null?void 0:r[g.id]:[])})})]})]},(_=t.customCardPreferences)==null?void 0:_.componentName)})}function ts({className:t,...n}){var N;const a=s.useEditorStore(y=>y.card),r=((N=a.customCardPreferences)==null?void 0:N.showCardHeader)??!0,o=s.useEditorStore(y=>y.frame),i=s.useDashboardStore(y=>y.dashboard.filters);s.useEditorStore(y=>y.actions.setRunSql);const{updateFilter:l}=s.useDashboardActions(),d=i==null?void 0:i.find(y=>y.id===o.filterId),{data:u,isLoading:p,isFetching:c}=s.useDashboardCardQuery(a),{setCard:j}=s.useEditorActions(),{data:b}=s.useTopoJson(a);if(!a.id)return null;let h;u!=null&&u.records&&(u==null?void 0:u.records.length)>0&&(h=s.createChartConfig({data:u==null?void 0:u.records,cardType:a.type,cfg:a.cfg,customCfg:a.customCfg,preferences:a.preferences,topoJson:b}));function f(y){return e.jsx(yt,{card:y})}function x(){var y;if(u!=null&&u.records&&(u==null?void 0:u.records.length)===0&&!p&&!c)return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[e.jsx(s.TreePalm,{className:"size-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No records to display"})]});if(a.type==="custom")return f(a);if(!["table","custom"].includes(a.type)&&h)return e.jsx(s.ChartJsVisual,{cfg:h},JSON.stringify(h)+JSON.stringify(a.preferences)+((y=a==null?void 0:a.preferences)==null?void 0:y.customVisualCode));if(a.type==="table"&&(u!=null&&u.records)&&(u==null?void 0:u.records.length)>0)return e.jsxs(s.ScrollArea,{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:[e.jsx(s.TableVisual,{card:a,data:u==null?void 0:u.records}),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})}return e.jsxs(s.Card,{role:"editor-visual-card",className:s.cn("relative flex h-full flex-col rounded-none",t),...n,children:[r&&e.jsxs(s.CardHeader,{className:"flex flex-row items-start justify-between py-4",children:[e.jsxs("div",{children:[e.jsx(s.Editable,{text:a.title,onSave:y=>j({...a,title:y}),children:e.jsx("div",{className:"flex items-center gap-5",children:e.jsx(s.CardTitle,{className:"text-base",children:a.title||"Edit title..."})})},a.title),e.jsx(s.Editable,{text:a.description||"",onSave:y=>j({...a,description:y}),children:e.jsx(s.CardDescription,{children:a.description||"Edit description..."})},a.description)]}),d&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(s.Editable,{className:"my-1",text:d.title||d.column,onSave:y=>l({...d,title:y}),children:e.jsx(s.Label,{children:d.title})}),e.jsx(s.FilterComponent,{filter:d})]})]}),e.jsx(s.CardContent,{className:"flex grow flex-col",children:x()})]})}const ze=({language:t,value:n,onChange:a,readonly:r})=>e.jsx(s.Ft,{className:"h-full w-full overflow-hidden text-xs",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,lineHeight:16,renderLineHighlight:"none",readOnly:r},defaultLanguage:t,value:n,onChange:a}),St=()=>e.jsxs(s.DialogHeader,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(s.DialogTitle,{children:"Customize Card"})}),e.jsxs(s.DialogDescription,{children:["See the configuration options and documentation",e.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),Ct=({customCode:t,customConfig:n,onConfigChange:a,onCodeChange:r})=>e.jsxs(s.Tabs,{defaultValue:"final-config",className:"flex w-1/2 flex-col",children:[e.jsxs(s.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsx(s.TabsTrigger,{value:"final-config",children:"Config"}),e.jsx(s.TabsTrigger,{value:"custom-code",children:"Custom Code"})]}),e.jsx(s.TabsContent,{value:"final-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(ze,{language:"json",value:n,onChange:a})}),e.jsx(s.TabsContent,{value:"custom-code",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(ze,{language:"javascript",value:t,onChange:r})})]}),vt=({error:t,hasCustomConfig:n,onReset:a,onApply:r,onClose:o})=>e.jsxs(s.DialogFooter,{className:"flex items-center",children:[e.jsx(s.Label,{className:"mr-2 text-red-500",children:t}),e.jsx(s.Button,{disabled:!n,onClick:a,variant:"outline",children:"Reset"}),e.jsx(s.Button,{onClick:r,variant:"outline",children:"Apply"}),e.jsx(s.Button,{onClick:o,variant:"outline",children:"Close"})]});function Nt(){const[t,n]=S.useState(!1),[a,r]=S.useState(""),[o,i]=S.useState(""),[l,d]=S.useState(""),[u,p]=S.useState(""),c=s.useEditorStore(C=>C.card),j=s.useEditorStore(C=>C.card.customCfg),{data:b}=s.useDashboardCardQuery(c),{data:h}=s.useTopoJson(c),{setCardCustomCfg:f,setCustomVisualCode:x}=s.useEditorActions(),N=C=>{var E,M;return JSON.stringify({...C,data:{...C.data,datasets:(M=(E=C.data)==null?void 0:E.datasets)==null?void 0:M.map(A=>({...A,data:[]}))}},null,2)},y=()=>{var E,M;if(!((E=b==null?void 0:b.records)!=null&&E.length))return;const C=s.createChartConfig({data:b.records,cardType:c.type,cfg:c.cfg,preferences:c.preferences,topoJson:h});if(C){r(N(C)),d(((M=c.preferences)==null?void 0:M.customVisualCode)||"");const A=s.merge(C,j);i(N(A))}},T=()=>{try{if(l&&x(l),o){const C=JSON.parse(o),E=s.getObjectDiff(JSON.parse(a),C);f(E),p("")}}catch{p("Invalid JSON configuration")}};return e.jsxs(s.Dialog,{open:t,onOpenChange:n,children:[e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsx(s.Button,{onClick:y,size:"sm",variant:"ghost",className:j?"text-green-600 hover:text-green-700":"",children:e.jsx(s.Settings,{className:"h-4 w-4"})})}),e.jsxs(s.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsx(St,{}),e.jsxs("div",{className:"flex grow gap-2",children:[e.jsx(s.ErrorBoundary,{FallbackComponent:s.FallbackEditorCard,children:e.jsx(ts,{className:"w-1/2 rounded shadow-none"})}),e.jsx(Ct,{customCode:l,customConfig:o,onConfigChange:C=>i(C??""),onCodeChange:C=>d(C??"")})]}),e.jsx(vt,{error:u,hasCustomConfig:!!j,onReset:()=>{i(a),f(null)},onApply:T,onClose:()=>n(!1)})]})]})}function as(t){return ie({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 wt(t){return ie({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M48,180c0,11,7.18,20,16,20a14.24,14.24,0,0,0,10.22-4.66A8,8,0,0,1,85.78,206.4,30.06,30.06,0,0,1,64,216c-17.65,0-32-16.15-32-36s14.35-36,32-36a30.06,30.06,0,0,1,21.78,9.6,8,8,0,0,1-11.56,11.06A14.24,14.24,0,0,0,64,160C55.18,160,48,169,48,180Zm79.6-8.69c-4-1.16-8.14-2.35-10.45-3.84-1.25-.81-1.23-1-1.12-1.9a4.57,4.57,0,0,1,2-3.67c4.6-3.12,15.34-1.73,19.82-.56A8,8,0,0,0,142,145.86c-2.12-.55-21-5.22-32.84,2.76a20.58,20.58,0,0,0-9,14.95c-2,15.88,13.65,20.41,23,23.11,12.06,3.49,13.12,4.92,12.78,7.59-.31,2.41-1.26,3.34-2.14,3.93-4.6,3.06-15.17,1.56-19.55.36A8,8,0,0,0,109.94,214a61.34,61.34,0,0,0,15.19,2c5.82,0,12.3-1,17.49-4.46a20.82,20.82,0,0,0,9.19-15.23C154,179,137.49,174.17,127.6,171.31Zm83.09-26.84a8,8,0,0,0-10.23,4.84L188,184.21l-12.47-34.9a8,8,0,0,0-15.07,5.38l20,56a8,8,0,0,0,15.07,0l20-56A8,8,0,0,0,210.69,144.47ZM216,88v24a8,8,0,0,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-27.31-8L160,51.31V80Z"},child:[]}]})(t)}function ns(t){return ie({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},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 rs(t){return ie({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z"},child:[]}]})(t)}function os(t){return ie({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 is(t){const[n,a]=S.useState(null);return n}function ls(){const{authToken:t}=s.useSemaphorContext(),{data:n,isLoading:a,isFetching:r,isError:o}=s.useQuery({queryKey:["plugins",t==null?void 0:t.accessToken],queryFn:()=>s.getPlugins(t==null?void 0:t.accessToken)});return{data:n,isLoading:a,isFetching:r,isError:o}}function kt({onChartTypeChange:t}){const[n,a]=S.useState([]),{data:r}=ls();return S.useEffect(()=>{(async()=>{var i;if(r){const d=(await Promise.all((i=r==null?void 0:r.plugins)==null?void 0:i.map(async u=>(await s.loadManifest(u.value)).visuals.map(j=>({name:j.name,icon:j.icon,url:u.value}))))).flat();a(d)}})()},[r]),n.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx(s.Separator,{className:"my-2"}),e.jsx("div",{className:"grid grid-cols-4 place-items-center",children:n.map((o,i)=>e.jsx(Et,{text:o.name,onClick:()=>t("custom",o),icon:o.icon},o.url+o.name+i))})]})}const Et=({text:t,icon:n,onClick:a})=>{const r=is(),o=t.charAt(0).toUpperCase();return e.jsx(s.Button,{onClick:a,title:t,variant:"ghost",children:r?e.jsx(r,{className:"h-4 w-4"}):o})};function Dt(){var c,j;const[t,n]=S.useState(!1),a=s.useEditorStore(b=>b.card),r=a.type,{setCardType:o,setCardPreferences:i,setChartOrientation:l}=s.useEditorStore(b=>b.actions),{setCardCustomCfg:d,setCustomCardPreferences:u}=s.useEditorActions();function p(b,h){d(null),i({}),o(b),h&&u({type:"component",visualType:"single",url:h.url,componentName:h.name,icon:h.icon}),n(!1)}return e.jsxs(s.Popover,{open:t,onOpenChange:n,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsx(s.Button,{size:"sm",variant:"ghost",children:e.jsx(It,{className:"size-4",chartType:r,customIcon:(c=a.customCardPreferences)==null?void 0:c.icon,componentName:(j=a.customCardPreferences)==null?void 0:j.componentName})})}),e.jsxs(s.PopoverContent,{className:"w-50",children:[e.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsx(s.Button,{onClick:()=>p("bar"),className:"font-normal",variant:"ghost",children:e.jsx(Se,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("line"),variant:"ghost",children:e.jsx(Ce,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("stackedBar"),variant:"ghost",children:e.jsx(Re,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("stackedLine"),variant:"ghost",children:e.jsx(rs,{className:"size-5",strokeWidth:0})}),e.jsx(s.Button,{onClick:()=>p("scatter"),variant:"ghost",children:e.jsx(_e,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("bubble"),variant:"ghost",children:e.jsx(ns,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("pie"),variant:"ghost",children:e.jsx(Be,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("doughnut"),variant:"ghost",children:e.jsx(Pe,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("radar"),variant:"ghost",children:e.jsx(Ue,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("polarArea"),variant:"ghost",children:e.jsx(as,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("pyramid"),variant:"ghost",children:e.jsx(Qe,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("range"),variant:"ghost",children:e.jsx(qe,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("table"),variant:"ghost",children:e.jsx(ve,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("kpi"),variant:"ghost",children:e.jsx(os,{className:"size-6"})}),e.jsx(s.Button,{onClick:()=>p("text"),variant:"ghost",children:e.jsx(bs,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("map"),variant:"ghost",children:e.jsx(Ge,{className:"size-5"})}),e.jsx(s.Button,{onClick:()=>p("custom"),variant:"ghost",children:e.jsx($e,{className:"size-5"})})]}),e.jsx(kt,{onChartTypeChange:p})]})]})}function It({chartType:t,className:n,customIcon:a,componentName:r}){const o=is();switch(t){case"bar":return e.jsx(Se,{className:n});case"line":return e.jsx(Ce,{className:n});case"pie":return e.jsx(Be,{className:n});case"radar":return e.jsx(Ue,{className:n});case"scatter":return e.jsx(_e,{className:n});case"bubble":return e.jsx(ns,{className:n});case"doughnut":return e.jsx(Pe,{className:n});case"stackedBar":return e.jsx(Re,{className:n});case"stackedLine":return e.jsx(rs,{className:n});case"polarArea":return e.jsx(as,{className:n});case"pyramid":return e.jsx(Qe,{className:n});case"range":return e.jsx(qe,{className:n});case"kpi":return e.jsx(os,{className:n});case"text":return e.jsx(Je,{className:n});case"map":return e.jsx(Ge,{className:n});case"custom":return a&&o?e.jsx(o,{className:n}):r?r==null?void 0:r.charAt(0).toUpperCase():e.jsx($e,{className:n});default:return e.jsx(ve,{className:n})}}function Fe(){var _;const t=s.useEditorStore(g=>g.frame),n=s.useEditorStore(g=>g.card),a=s.useEditorStore(g=>g.isShowingVisual),r=s.useEditorStore(g=>g.isSqlRunning),o=s.useEditorStore(g=>g.pythonStdOut);s.useEditorStore(g=>g.actions.setRunSql);const{setFrame:i,setCard:l,updateCardInFrame:d,setActiveTabCardId:u,runAssistant:p}=s.useEditorActions(),{data:c,isLoading:j,isFetching:b,error:h}=s.useDashboardCardQuery(n);if(!n)return e.jsx(e.Fragment,{children:"No Active Card"});function f(){const g={connectionId:n.connectionId,id:s.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};x(g)}function x(g){const k={...t,cards:[...t.cards,g],activeCardId:g.id};i(k),u(g.id)}function N(){const g={...n,id:s.v4(),title:`${n.title} Copy`,tabTitle:`${n.tabTitle||n.title} Copy`};x(g)}function y(g){const k=t.cards.filter(H=>H.id!==g),z=k[0],I={...t,cards:k,activeCardId:z.id};i(I),u(z.id),l(z)}function T(g){u(g)}const C=(g,k)=>{console.log("handleDragStart",k),g.dataTransfer.setData("tabIndex",k.toString())},E=g=>{g.preventDefault()},M=(g,k)=>{const z=g.dataTransfer.getData("tabIndex");if(z===k.toString())return;const I=Array.from(t.cards),[H]=I.splice(parseInt(z),1);I.splice(k,0,H),i({...t,cards:I})};function A(g,k){return g.cards.length===1&&(k.displayTab===!0||k.displayTab===void 0)||g.activeCardId!==k.id&&(k.displayTab===!0||k.displayTab===void 0)?null:e.jsx("div",{onClick:()=>{const z=k.displayTab===void 0?!1:!k.displayTab;l({...k,displayTab:z}),d({...k,displayTab:z})},children:k.displayTab===!0||k.displayTab===void 0?e.jsx(s.Eye,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsx(Es,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function R(){return e.jsxs(s.Tabs,{onValueChange:T,value:t.activeCardId,className:"flex grow flex-col",children:[t.cards.map(g=>e.jsx(s.TabsContent,{className:"mt-0 grow",value:g.id,children:V()},g.id)),e.jsx(s.TabsList,{className:"group mx-6 justify-between",children:e.jsxs("div",{className:"flex items-center",children:[t.cards.map((g,k)=>e.jsx(s.Editable,{text:g.tabTitle||g.title,onSave:z=>{l({...n,tabTitle:z}),d({...n,tabTitle:z})},children:e.jsxs(s.TabsTrigger,{draggable:!0,onDragStart:z=>C(z,k),onDragOver:E,onDrop:z=>M(z,k),className:"",value:g.id,children:[A(t,g),g.tabTitle||g.title,t.activeCardId===g.id&&t.cards.length>1&&e.jsx(s.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>y(g.id)})]})},g.id)),e.jsx(s.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:f,children:e.jsx(s.Plus,{className:"h-4 w-4"})}),e.jsx(s.Button,{className:"invisible ml-1 h-8 px-2 hover:bg-muted-foreground/50 group-hover:visible",variant:"outline",onClick:N,children:e.jsx(Ns,{className:"h-4 w-4"})})]})})]})}function V(){return n.type==="kpi"?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsx(s.KPICard,{card:n,data:c==null?void 0:c.records})})}):n.type==="text"?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsx(s.ScrollArea,{className:"mx-3 my-6 h-[300px] overflow-y-auto break-words px-3",children:e.jsx(s.TextCard,{isLoading:r,card:n,data:c==null?void 0:c.records})})})}):e.jsx(s.ErrorBoundary,{FallbackComponent:s.FallbackEditorCard,children:e.jsx(ts,{className:"grow border-none shadow-none"})})}function q(){const g=JSON.stringify(c==null?void 0:c.records,null,2),k=new Blob([g],{type:"application/json"}),z=URL.createObjectURL(k),I=document.createElement("a");I.href=z,I.download=`${n.title}.json`,I.click()}function m(){const k=[Object.keys(c==null?void 0:c.records.reduce((P,$)=>({...P,...$}),{})).join(","),...((c==null?void 0:c.records)||[]).map(P=>Object.values(P).join(","))].join(`
232
+ `),z=new Blob([k],{type:"text/csv"}),I=URL.createObjectURL(z),H=document.createElement("a");H.href=I,H.download=`${n.title}.csv`,H.click()}function L(){const g=`Can you get the documentation for ${n.type} chart?`;p(g)}return e.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[(j||b)&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 m-auto flex h-10 w-10 items-center justify-center rounded-md bg-muted",children:e.jsx(ue,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),e.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[a&&e.jsxs("div",{className:"flex grow items-center",children:[e.jsx(Dt,{}),e.jsx(s.Button,{onClick:L,variant:"ghost",size:"sm",children:e.jsx(js,{className:"size-4"})}),!["table","custom"].includes(n.type)&&e.jsx(Nt,{})]}),!a&&e.jsxs("div",{className:"flex grow items-center gap-1",children:[e.jsx(s.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:m,children:e.jsx(wt,{className:"size-4"})}),e.jsx(s.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:q,children:e.jsx(Ds,{strokeWidth:1.5,className:"size-4"})}),e.jsx(s.CopyButton,{text:JSON.stringify(c==null?void 0:c.records,null,2),className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70"})]}),e.jsx(At,{})]}),a?R():e.jsxs(s.ResizablePanelGroup,{className:"px-6",direction:"horizontal",children:[o&&e.jsxs(e.Fragment,{children:[e.jsx(s.ResizablePanel,{id:"1",order:1,defaultSize:30,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:o&&e.jsx(Tt,{})}),e.jsx(s.ResizableHandle,{})]}),e.jsx(s.ResizablePanel,{id:"2",order:2,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:e.jsxs(s.ScrollArea,{className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:[(c==null?void 0:c.records)&&(c==null?void 0:c.records.length)>0&&e.jsx(bt,{data:(c==null?void 0:c.records)||[]}),(h||(c==null?void 0:c.error))&&e.jsx("span",{className:"font-mono text-xs",children:(h==null?void 0:h.message)||((_=c==null?void 0:c.error)==null?void 0:_.message)}),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})})]})]})}function Tt(){const t=s.useEditorStore(a=>a.pythonStdOut);if(!t)return null;const n=t.replace(/\n/g,"<br>");return e.jsxs("div",{className:"relative flex w-full flex-col border-r",children:[e.jsx("div",{className:"sticky top-0 flex max-h-11 min-h-11 grow items-center border-b bg-muted px-3 font-mono text-xs font-semibold text-foreground/70",children:"Python Output"}),e.jsxs(s.ScrollArea,{className:"overflow-y-auto px-2 pt-1 font-mono text-xs text-foreground/90",children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:n}}),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})]})}function At(){const t=s.useEditorStore(a=>a.isShowingVisual),n=s.useEditorStore(a=>a.actions.setIsShowingVisual);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Label,{htmlFor:"visualize",children:"Chart"}),e.jsx(s.Switch,{checked:t,onCheckedChange:()=>n(!t),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function Lt({options:t,value:n,onValueChange:a}){return e.jsx(s.RadioGroup,{value:n,onValueChange:a,className:"flex gap-4",defaultValue:t[0].value,children:t.map(r=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:r.value,id:r.value}),e.jsx("label",{className:"text-sm",htmlFor:r.value,children:r.label})]},r.value))})}function te({label:t,options:n,value:a,onValueChange:r,className:o}){return e.jsxs(s.Select,{value:a,onValueChange:r,children:[e.jsx(s.SelectTrigger,{className:s.cn("w-full focus:ring-0 focus:ring-offset-0",o),children:e.jsx(s.SelectValue,{placeholder:t})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:t}),n.map(i=>e.jsx(s.SelectItem,{value:i.value,children:i.label},i.value))]})})]})}function de({children:t,summary:n,open:a,className:r}){return e.jsxs("details",{open:a,className:s.cn("space-y-4 [&_summary>svg]:open:-rotate-180",r),children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-4",children:[e.jsx(s.Label,{children:n}),e.jsx(s.ChevronUp,{className:"h-4 w-4"})]}),e.jsx("div",{className:"transition-all ease-in-out",children:t})]})}function Ot(){var x,N;const t=s.useEditorStore(y=>y.card.customCardPreferences),{data:n}=ls(),a=(n==null?void 0:n.plugins)||[],r=s.useEditorStore(y=>y.card),o=s.useEditorStore(y=>y.frame),i=(t==null?void 0:t.visualType)||"single",{setCustomCardPreferences:l}=s.useEditorActions(),{components:d,manifest:u}=s.useCustomVisual((t==null?void 0:t.url)||""),p=(x=u==null?void 0:u.visuals)==null?void 0:x.find(y=>y.name===(t==null?void 0:t.componentName));function c(y,T){if(!t)return;const E={...(t==null?void 0:t.dataInputCardIds)||{},[y]:{cardId:T,hookRef:null}};l({...t,dataInputCardIds:E})}function j(y){var C,E;const T=(C=o==null?void 0:o.cards)==null?void 0:C.filter(M=>{var A;return((A=M==null?void 0:M.customCardPreferences)==null?void 0:A.visualType)!=="multiple"}).map(M=>({value:M.id,label:M.tabTitle||M.title}));return e.jsx("div",{className:"space-y-2",children:(E=y==null?void 0:y.dataInputs)==null?void 0:E.map((M,A)=>{var R,V;return e.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[e.jsx("div",{className:"col-span-4 flex items-center",children:M}),e.jsx(te,{className:"col-span-6 h-8 w-full justify-between",label:"",options:T||[],value:((V=(R=t==null?void 0:t.dataInputCardIds)==null?void 0:R[A])==null?void 0:V.cardId)||"",onValueChange:q=>c(A,q)})]},A+Math.random())})})}function b(y,T,C=[]){var E,M;return t?y==="input"?e.jsx(s.Input,{className:`h-8 w-full ${s.removeRing}`,value:((E=t==null?void 0:t.settings)==null?void 0:E[T])||"",onChange:A=>{l({...t,settings:{...t==null?void 0:t.settings,[T]:A.target.value}})}},T):y==="select"?e.jsx(te,{className:"h-8 w-full",label:"",options:C,value:((M=t==null?void 0:t.settings)==null?void 0:M[T])||"",onValueChange:A=>{l({...t,settings:{...t==null?void 0:t.settings,[T]:A}})}}):null:null}function h(y){const T=Object.entries((y==null?void 0:y.settings)||{});return e.jsx("div",{className:"space-y-3",children:T.map(([C,E])=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:E.title}),b(E.ui,C,E.options)]},C))})}function f(y){t&&l({...t,visualType:y,componentName:""})}return e.jsxs("div",{className:"p-6",children:[e.jsx(de,{summary:"Plugin Settings",children:e.jsx("div",{className:"space-y-4 text-sm",children:e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"px-2",children:e.jsx(te,{className:"h-8 w-full",label:"",options:a,value:(t==null?void 0:t.url)||"",onValueChange:y=>l({...t||{url:"",componentName:""},url:y})})})}),((t==null?void 0:t.type)==="component"||(t==null?void 0:t.type)===void 0)&&e.jsx(Lt,{options:[{value:"single",label:"Single Visual"},{value:"multiple",label:"Multi-Visual"}],value:i,onValueChange:f}),((t==null?void 0:t.type)==="component"||(t==null?void 0:t.type)===void 0)&&t&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Component"}),e.jsx("div",{className:"space-y-2 px-2",children:d&&e.jsx(te,{className:"h-8 w-full",label:"",options:(d==null?void 0:d.filter(y=>y.type===i).map(y=>({value:y.name,label:y.name})))||[],value:t.componentName,onValueChange:y=>{console.log("changing value",y),l({...t,componentName:y})}})})]})})]})})}),e.jsx(s.Separator,{className:"my-4"}),((N=r==null?void 0:r.customCardPreferences)==null?void 0:N.componentName)&&e.jsxs(de,{summary:"Component Settings",children:[p&&p.dataInputs&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(s.Label,{children:"Input Mapping"}),e.jsx("div",{className:"px-2",children:j(p)})]}),p&&p.settings&&e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"px-2",children:h(p)})})]})]})}function re(){const[t,n]=S.useState([]);s.useEditorStore(c=>c.card.cfg);const a=s.useEditorStore(c=>c.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:o,setCardPreferences:i}=s.useEditorStore(c=>c.actions),l=s.useEditorStore(c=>c.queryResultColumns);s.useEditorStore(c=>{var j;return(j=c.card.preferences)==null?void 0:j.filterOnClickColumnIndex}),S.useEffect(()=>{l&&n(new Array(l.length).fill(!1))},[l]);function d(c,j){var b,h;j?a!=null&&a.onClickFilter&&((b=a==null?void 0:a.onClickFilter)==null?void 0:b.length)>0?i({...a,onClickFilter:[...a.onClickFilter,{columnIndex:c,expression:""}]}):i({...a,onClickFilter:[{columnIndex:c,expression:""}]}):(i({...a,onClickFilter:(h=a==null?void 0:a.onClickFilter)==null?void 0:h.filter(f=>f.columnIndex!==c)}),n(f=>{const x=[...f];return x[c]=!1,x}))}function u(c,j){var h;const b=(h=a==null?void 0:a.onClickFilter)==null?void 0:h.map(f=>f.columnIndex===c?{...f,expression:j.target.value}:f);i({...a,onClickFilter:b})}function p(c){var j,b,h,f;if(t!=null&&t[c]||(b=(j=a==null?void 0:a.onClickFilter)==null?void 0:j.find(x=>x.columnIndex===c))!=null&&b.expression)return e.jsx(s.Input,{value:(f=(h=a==null?void 0:a.onClickFilter)==null?void 0:h.find(x=>x.columnIndex===c))==null?void 0:f.expression,onChange:x=>u(c,x),type:"text",className:"h-9 w-full font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"Expression"})}return e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"On Click"}),l==null?void 0:l.map((c,j)=>{var b,h;return e.jsx("div",{className:"xbg-red-100 group flex items-center justify-between space-y-2",children:e.jsxs("div",{className:"grow",children:[e.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsx(s.Checkbox,{checked:!!((b=a==null?void 0:a.onClickFilter)!=null&&b.find(f=>f.columnIndex===j)),onCheckedChange:f=>d(j,f)}),e.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:c}),e.jsx("div",{className:"flex items-center gap-2",children:((h=a==null?void 0:a.onClickFilter)==null?void 0:h.find(f=>f.columnIndex===j))&&e.jsx(s.Pencil,{onClick:()=>{n(f=>{const x=[...f];return x[j]=!f[j],x})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),p(j)]})},c)})]})}function ge(){var l,d,u;const t=s.useEditorStore(p=>p.card.preferences),n=s.useEditorStore(p=>p.card.cfg),{setCardCfg:a,setCardPreferences:r,setChartOrientation:o}=s.useEditorStore(p=>p.actions);(l=n==null?void 0:n.options)!=null&&l.indexAxis;function i(p){o(p)}return e.jsxs(s.RadioGroup,{value:((d=t==null?void 0:t.chartOptions)==null?void 0:d.indexAxis)||((u=n==null?void 0:n.options)==null?void 0:u.indexAxis)||"x",onValueChange:i,className:"flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"x",id:"r1"}),e.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"y",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const me="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Ve(t,n){var r,o,i;const a=s.getNumberAxis(t,n);return((i=(o=(r=t==null?void 0:t.chartOptions)==null?void 0:r.scales)==null?void 0:o[a])==null?void 0:i.type)||"linear"}function cs(){var I,H,P,$,X,Q;const[t,n]=S.useState(!1),a=s.useEditorStore(F=>{var O;return(O=F.card)==null?void 0:O.preferences}),r=s.useEditorStore(F=>{var O;return(O=F.card)==null?void 0:O.cfg}),o=s.getNumberAxis(a,r),[i,l]=S.useState(Ve(a)),[d,u]=S.useState(((P=(H=(I=a==null?void 0:a.chartOptions)==null?void 0:I.scales)==null?void 0:H[o])==null?void 0:P.min)||""),[p,c]=S.useState(((Q=(X=($=a==null?void 0:a.chartOptions)==null?void 0:$.scales)==null?void 0:X[o])==null?void 0:Q.max)||""),[j,b]=S.useState(d||p?"custom":"auto"),[h,f]=S.useState(""),[x,N]=S.useState(0),[y,T]=S.useState(""),[C,E]=S.useState(""),[M,A]=S.useState(""),R=s.useEditorStore(F=>F.actions.setCardPreferences),{updateCardInFrame:V}=s.useEditorActions(),q=s.useEditorStore(F=>F.card),m=s.useEditorStore(F=>{var O;return(O=F.card)==null?void 0:O.type}),L=["pie","doughnut","polarArea"].includes(m);S.useEffect(()=>{var F,O,Y,w,B,U,W,ae,se,G,K,D,J,Z;l(Ve(a)),u(((Y=(O=(F=a==null?void 0:a.chartOptions)==null?void 0:F.scales)==null?void 0:O[o])==null?void 0:Y.min)===0?0:""),c(((U=(B=(w=a==null?void 0:a.chartOptions)==null?void 0:w.scales)==null?void 0:B[o])==null?void 0:U.max)||""),f(((G=(se=(ae=(W=a==null?void 0:a.chartOptions)==null?void 0:W.scales)==null?void 0:ae[o])==null?void 0:se.ticks)==null?void 0:G.stepSize)||""),N(((K=a==null?void 0:a.numberAxisFormat)==null?void 0:K.decimalPlaces)||0),T(((D=a==null?void 0:a.numberAxisFormat)==null?void 0:D.suffix)||""),E(((J=a==null?void 0:a.numberAxisFormat)==null?void 0:J.currency)||""),A(((Z=a==null?void 0:a.numberAxisFormat)==null?void 0:Z.locale)||"")},[t,a,o]);function _(F,O){return O===""||/^[0-9\b]+$/.test(O)?Number(O):Number(F)}function g(){const F=[...new Set(s.LOCALE_CURRENCY_PAIRS.map(O=>O.currency))];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsx(s.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxs(s.Select,{value:C||"none",onValueChange:O=>E(O==="none"?"":O),children:[e.jsx(s.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Currency"}),e.jsx(s.SelectItem,{value:"none",children:"None"}),F.map(O=>e.jsx(s.SelectItem,{value:O,children:O},O))]})})]}),e.jsxs(s.Select,{value:M,onValueChange:O=>A(O),children:[e.jsx(s.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Locale"}),s.LOCALE_CURRENCY_PAIRS.map(O=>e.jsx(s.SelectItem,{value:O.locale,children:O.locale},O.locale))]})})]})]}),e.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsx(s.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsx(s.Input,{value:x,onChange:O=>N(Number(O.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${me}`})]})]})}function k(){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(s.Label,{htmlFor:"range",children:"Range"}),e.jsx(s.Input,{id:"min",value:d,onChange:F=>u(O=>_(O,F.target.value)),className:`col-span-1 h-8 w-full ${me}`}),e.jsx(s.Input,{value:p,onChange:F=>c(O=>_(O,F.target.value)),id:"max",className:`col-span-1 h-8 w-full ${me}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(s.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsx(s.Input,{value:h,onChange:F=>f(O=>_(O,F.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${me}`})]})]})}function z(){var w;let F={};j==="custom"&&(F={min:d,max:p,ticks:{stepSize:h}});const O={...a||{},chartOptions:{...a==null?void 0:a.chartOptions,scales:{...(w=a==null?void 0:a.chartOptions)==null?void 0:w.scales,[o]:{type:i,...i==="linear"?F:{}}}},numberAxisFormat:{decimalPlaces:x,suffix:y,currency:C,locale:M}};console.log(O),R(O);const Y={...q,preferences:O};V(Y)}return e.jsxs(s.Popover,{onOpenChange:F=>n(F),children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsx(s.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsx(s.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(s.Label,{htmlFor:"scale",children:"Type"}),e.jsxs(s.Select,{disabled:L,value:i,onValueChange:F=>l(F),children:[e.jsx(s.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{id:"type",children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Option"}),e.jsx(s.SelectItem,{value:"linear",children:"Linear"}),e.jsx(s.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),i=="linear"&&e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsx(s.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxs(s.RadioGroup,{disabled:L,id:"scale-option",value:j,onValueChange:F=>b(F),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"auto",id:"r1"}),e.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"custom",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),j==="custom"&&i=="linear"&&k(),g(),e.jsx(s.SelectSeparator,{}),e.jsx("div",{className:"grid grid-cols-3",children:e.jsx(s.Button,{onClick:z,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function Mt({idx:t}){var d;const n=s.useEditorStore(u=>{var p;return(p=u.card)==null?void 0:p.preferences}),a=s.useEditorStore(u=>{var p;return(p=u.card.preferences)==null?void 0:p.datasetOptions}),r=s.useEditorStore(u=>u.actions.setCardPreferences),o=(d=n==null?void 0:n.chartOptions)==null?void 0:d.indexAxis,i=a==null?void 0:a.find(u=>u.idx===t);function l(u,p){(u==="end"||u==="start")&&s.getContrastColor(s.getCanvasBackgroundColor());const c={display:u!=="none",align:u,anchor:u,clamp:!0};if(!i)r({...n,datasetOptions:[...a||[],{idx:p,datalabels:c}]});else{const j={...i};j.datalabels=c;const b=a==null?void 0:a.map(h=>h.idx===p?j:h);r({...n,datasetOptions:b})}}return e.jsxs(s.Popover,{children:[e.jsx(s.PopoverTrigger,{children:e.jsx(Gs,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsx(s.PopoverContent,{className:"w-fit p-1",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(s.Button,{onClick:()=>l("none",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(s.X,{className:"size-4"})}),e.jsx(s.Button,{onClick:()=>l("start",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(Os,{className:s.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx(s.Button,{onClick:()=>l("center",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(zs,{className:s.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx(s.Button,{onClick:()=>l("end",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(Ms,{className:s.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function ds(){const t=s.useEditorStore(p=>p.card),n=s.useEditorStore(p=>{var c,j,b;return(b=(j=(c=p==null?void 0:p.card)==null?void 0:c.preferences)==null?void 0:j.chartOptions)==null?void 0:b.indexAxis}),{data:a}=s.useDashboardCardQuery(t),r=n==="y"?"Y axis":"X axis",o=n==="y"?"X axis":"Y axis",{keys:i,metricKeys:l,dimensionKeys:d}=s.getKeys((a==null?void 0:a.records)||[]);let u=l;if(["stackedBar","stackedLine"].includes(t.type)){const p=s.pivotData({dataArray:(a==null?void 0:a.records)||[],groupKey:d[0],pivotKey:d[1],valueKey:u[0]}),{metricKeys:c}=s.getKeys(p);u=c}return i.length===0?null:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:r}),e.jsx("div",{className:"my-1 space-y-1",children:e.jsx("div",{className:"rounded-md bg-muted/70 px-3 py-2 hover:bg-muted",children:e.jsx("p",{title:d[0],children:us(d[0])})})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsx(s.Label,{children:o}),e.jsx(cs,{})]}),e.jsx("div",{className:"my-1 max-h-[125px] space-y-1 overflow-y-auto",children:u.map((p,c)=>e.jsx(zt,{col:p,idx:c},p))})]})]})}function us(t,n=30){return t.length>n?t.slice(0,n)+"...":t}function zt({col:t,idx:n}){const a=s.useEditorStore(d=>{var u;return(u=d.card)==null?void 0:u.preferences}),r=s.useEditorStore(d=>{var u;return(u=d.card.preferences)==null?void 0:u.datasetOptions}),o=r==null?void 0:r.find(d=>d.idx===n),{setCardPreferences:i}=s.useEditorStore(d=>d.actions);function l(d){if(!o)i({...a,datasetOptions:[...r||[],{idx:n,type:d==="area"?"line":d,fill:d==="area"?"origin":""}]});else{const u={...o};u.type=d==="area"?"line":d,u.fill=d==="area"?"origin":"";const p=r==null?void 0:r.map(c=>c.idx===n?u:c);i({...a,datasetOptions:p})}}return e.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-3 py-2 hover:bg-muted",children:[e.jsx("p",{title:t,children:us(t)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Se,{onClick:()=>l("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(Ce,{onClick:()=>l("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(Cs,{onClick:()=>l("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(Mt,{idx:n})]})]})}function hs(){const t=s.useEditorStore(h=>h.selectedConnectionId),n=s.useEditorStore(h=>h.selectedDatamodelId),a=s.useEditorStore(h=>h.selectedDatabaseName),r=s.useEditorStore(h=>h.selectedSchemaName),o=s.useEditorStore(h=>h.selectedTableName),i=s.useDashboardStore(h=>h.dashboard.filters)||[],l=s.useDashboardStore(h=>h.actions.addFilter),d=s.useDashboardStore(h=>h.actions.removeFilter),{removeFilterValues:u}=s.useDashboardActions(),{modelItems:p,tableName:c,connectionType:j}=ne();function b(h,f="dashboard"){var R;const x=s.fmt(h.column_name),N=s.fmt(a||""),y=s.fmt(r||""),T=s.fmt(c);let C=s.getQualifiedTableName(y,T,j),E=`${C}.${x}`;const M=(R=p==null?void 0:p.find(V=>V.id===n))==null?void 0:R.name;n&&n!=="none"&&(E=`${s.DATAMODEL_NAMESPCACE}.${M}.${x}`,C=`${s.DATAMODEL_NAMESPCACE}.${M}`);const A=i==null?void 0:i.find(V=>V.column===E&&V.table===T&&(V.database===N||V.database===a));if(A)u(A.id),d(A.id);else{const V=s.v4();return c==="api"&&t?(l({location:f,id:V,column:E,title:h.column_name,dataType:h.data_type,table:"api",database:"",connectionId:t,operation:"in",sql:s.getDefaultFilterSql(h.data_type,C,x)}),V):(l({id:V,location:f,column:E,title:h.column_name,dataType:h.data_type,table:o||"",database:a||"",connectionId:t||"",operation:"in",sql:s.getDefaultFilterSql(h.data_type,C,x)}),V)}}return{assignFilter:b}}function le(){const t=s.useDashboardStore(d=>d.dashboard.filters),n=s.useEditorStore(d=>d.frame),{setFrame:a}=s.useEditorActions(),{columns:r}=ne(),{assignFilter:o}=hs();function i(d){const u=o(d,"frame");a({...n,filterId:u})}const l=t==null?void 0:t.find(d=>d.id===n.filterId);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(s.Label,{children:"Card Filter"}),e.jsx(Ft,{onSelect:i,columns:r}),l&&e.jsx(s.FilterHeader,{filter:l})]})}function Ft({columns:t,onSelect:n}){var l;const[a,r]=Le.useState(!1),[o,i]=Le.useState("");return e.jsxs(s.Popover,{open:a,onOpenChange:r,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsxs(s.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":a,className:"w-full justify-between font-normal",children:[o?(l=t.find(d=>d.column_name===o))==null?void 0:l.column_name:"Select Column...",e.jsx(s.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(s.PopoverContent,{className:"w-[200px] p-0",children:e.jsxs(s.Command,{children:[e.jsx(s.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxs(s.CommandList,{children:[e.jsx(s.CommandEmpty,{children:"No framework found."}),e.jsx(s.CommandGroup,{children:t.map(d=>e.jsxs(s.CommandItem,{value:d.column_name,onSelect:u=>{const p=u===o?"":u;i(p),r(!1),p&&n(d)},children:[d.column_name,e.jsx(s.CheckIcon,{className:s.cn("ml-auto h-4 w-4",o===d.column_name?"opacity-100":"opacity-0")})]},d.column_name))})]})]})})]})}function Vt({cardType:t}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:`${s.titleCase(t)} Chart`}),e.jsxs(s.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"x-axis - category"}),e.jsx("li",{children:"y-axis1 - number"}),e.jsx("li",{children:"y-axis2 - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/bar-line-area",children:"example"})," in the docs."]})]})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ge,{}),e.jsx(ds,{})]})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(re,{}),e.jsx(le,{})]})]})]})})}function we(){var o,i,l;const t=s.useEditorStore(d=>d.card.cfg),n=s.useEditorStore(d=>d.actions.setCardCfg),a=s.useEditorStore(d=>d.card.type);function r(d){var c;const u={datalabels:{display:d!=="none",align:d,anchor:d,clamp:!0}},p={...t,options:{...t==null?void 0:t.options,plugins:{...(c=t==null?void 0:t.options)==null?void 0:c.plugins,...u}}};n(p),console.log(d)}return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid"].includes(a)&&e.jsx(cs,{})]}),e.jsxs(s.Select,{value:(l=(i=(o=t==null?void 0:t.options)==null?void 0:o.plugins)==null?void 0:i.datalabels)==null?void 0:l.anchor,onValueChange:r,defaultValue:"none",children:[e.jsx(s.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{placeholder:"Select position"})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Data Labels"}),e.jsx(s.SelectItem,{value:"none",children:"None"}),a!=="pyramid"&&e.jsx(s.SelectItem,{value:"start",children:"Start"}),e.jsx(s.SelectItem,{value:"center",children:"Center"}),a!=="pyramid"&&e.jsx(s.SelectItem,{value:"end",children:"End"})]})})]})]})}function Rt({cardType:t}){function n(a){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:a==="bubble"?"SELECT label, [group], x-axis, y-axis, radius FROM table":"SELECT label, [group], x-axis, y-axis FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"label - category"}),e.jsx("li",{children:"group (optional) - category"}),e.jsx("li",{children:"x-axis - number"}),e.jsx("li",{children:"y-axis - number"}),a==="bubble"&&e.jsx("li",{children:"radius - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:i=>i.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/bubble",children:"example"})," in the docs."]})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:`${s.titleCase(t)} Chart`}),e.jsx(s.AccordionContent,{className:"space-y-4 font-mono text-xs",children:n(t)})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsx(s.AccordionContent,{className:"px-2",children:e.jsx(we,{})})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(re,{}),e.jsx(le,{})]})]})]})})}const qt={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},Bt={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function _t(){const t=s.useEditorStore(n=>n.card.type);return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(s.Accordion,{className:" ",type:"single",collapsible:!0,children:Pt(t)}),e.jsx("section",{className:"",children:["line","bar"].includes(t)&&e.jsx(ge,{})}),!["kpi"].includes(t)&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(we,{}),e.jsx(re,{}),e.jsx(le,{})]})]})}function Pt(t){if(["line","bar"].includes(t))return e.jsxs(e.Fragment,{children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsx("p",{children:"Chart Query"})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxs(s.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxs("p",{children:["Click ",e.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsx("pre",{children:JSON.stringify(qt,null,2)})]})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxs(s.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxs("p",{children:["Click ",e.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsx("pre",{children:JSON.stringify(Bt,null,2)})]})]})]});if(t==="bubble")return e.jsx(e.Fragment,{children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:t})," chart query?"]})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(t==="scatter")return e.jsx(e.Fragment,{children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:t})," chart query?"]})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(t))return e.jsx(e.Fragment,{children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:[e.jsx("span",{children:t==="polarArea"?"Polar":t.charAt(0).toUpperCase()+t.slice(1)})," ","chart query"]})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function Ht(){var u,p,c,j,b;const t=s.useEditorStore(h=>h.card.preferences),n=s.useEditorStore(h=>h.actions.setCardPreferences),a=s.useEditorStore(h=>h.actions.setNumberFormat);s.useEditorStore(h=>{var f,x;return(x=(f=h.card.preferences)==null?void 0:f.formatNumber)==null?void 0:x.decimalPlaces});const r=s.useEditorStore(h=>{var f,x;return(x=(f=h.card.preferences)==null?void 0:f.formatNumber)==null?void 0:x.locale}),o=s.useEditorStore(h=>{var f,x;return(x=(f=h.card.preferences)==null?void 0:f.formatNumber)==null?void 0:x.currency});s.useEditorStore(h=>h.actions.setFilterOnClickField);const i=s.useEditorStore(h=>{var f,x;return(x=(f=h.card.preferences)==null?void 0:f.formatNumber)==null?void 0:x.colorRanges})||[],l=s.useEditorStore(h=>h.actions.setColorRanges),d=[...new Set(s.LOCALE_CURRENCY_PAIRS.map(h=>h.currency))];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(s.Checkbox,{checked:!!((u=t==null?void 0:t.formatNumber)!=null&&u.enabled),onCheckedChange:h=>{n({...t,formatNumber:{...t==null?void 0:t.formatNumber,enabled:h}})}}),e.jsx(s.Label,{children:"Format Number"})]}),((p=t==null?void 0:t.formatNumber)==null?void 0:p.enabled)===!0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{children:e.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Locale"}),e.jsxs(s.Select,{value:r||"none",onValueChange:h=>{var f,x,N;return a(((f=t==null?void 0:t.formatNumber)==null?void 0:f.decimalPlaces)||0,((x=t==null?void 0:t.formatNumber)==null?void 0:x.currency)||"",h,((N=t==null?void 0:t.formatNumber)==null?void 0:N.suffix)||"")},children:[e.jsx(s.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Format"}),e.jsx(s.SelectItem,{value:"none",children:"None"},"none"),s.LOCALE_CURRENCY_PAIRS.map(h=>e.jsx(s.SelectItem,{value:h.locale,children:h.locale},h.locale))]})})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Currency"}),e.jsxs(s.Select,{value:o||"none",onValueChange:h=>{var f,x,N;console.log("currency",h),a(((f=t==null?void 0:t.formatNumber)==null?void 0:f.decimalPlaces)||0,h==="none"?"":h,((x=t==null?void 0:t.formatNumber)==null?void 0:x.locale)||"",((N=t==null?void 0:t.formatNumber)==null?void 0:N.suffix)||"")},children:[e.jsx(s.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Currency"}),e.jsx(s.SelectItem,{value:"none",children:"None"},"none"),d.map(h=>e.jsx(s.SelectItem,{value:h,children:h},h))]})})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Decimals"}),e.jsxs(s.Select,{value:((j=(c=t==null?void 0:t.formatNumber)==null?void 0:c.decimalPlaces)==null?void 0:j.toString())||"0",onValueChange:h=>{var f,x,N;return a(Number(h),((f=t==null?void 0:t.formatNumber)==null?void 0:f.currency)||"",((x=t==null?void 0:t.formatNumber)==null?void 0:x.locale)||"",((N=t==null?void 0:t.formatNumber)==null?void 0:N.suffix)||"")},children:[e.jsx(s.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:["0","1","2","3","4"].map(h=>e.jsx(s.SelectItem,{value:h,children:h},h))})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Suffix"}),e.jsx(s.Input,{value:((b=t==null?void 0:t.formatNumber)==null?void 0:b.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:h=>{var f,x,N;return a(((f=t==null?void 0:t.formatNumber)==null?void 0:f.decimalPlaces)||0,((x=t==null?void 0:t.formatNumber)==null?void 0:x.currency)||"",((N=t==null?void 0:t.formatNumber)==null?void 0:N.locale)||"",h.target.value)}})]})]})]})}),e.jsx(s.Separator,{className:"my-3"}),e.jsx(s.ColorFormat,{colorRanges:i,setColorRanges:l})]})]})}function Gt(){return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(s.Accordion,{type:"single",collapsible:!0,children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxs(s.AccordionContent,{className:"font-mono",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"current - number"}),e.jsx("li",{children:"previous - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/kpi",children:"example"})," in the docs."]})]})]})}),e.jsx("section",{className:"",children:e.jsx(Ht,{})}),e.jsx("div",{}),e.jsx("div",{})]})}const Ut=[{label:"Mercator",value:"mercator"},{label:"Azimuthal Equidistant",value:"azimuthalEquidistant"},{label:"Gnomonic",value:"gnomonic"},{label:"Orthographic",value:"orthographic"},{label:"Stereographic",value:"stereographic"},{label:"Equal Earth",value:"equalEarth"},{label:"Albers",value:"albers"},{label:"Albers USA",value:"albersUsa"},{label:"Conic Conformal",value:"conicConformal"},{label:"Conic Equal Area",value:"conicEqualArea"},{label:"Conic Equidistant",value:"conicEquidistant"},{label:"Equirectangular",value:"equirectangular"},{label:"Transverse Mercator",value:"transverseMercator"},{label:"Natural Earth 1",value:"naturalEarth1"}],$t=["blues","brBG","buGn","buPu","cividis","cool","cubehelixDefault","gnBu","greens","greys","inferno","magma","orRd","oranges","pRGn","piYG","plasma","puBu","puBuGn","puOr","puRd","purples","rainbow","rdBu","rdGy","rdPu","rdYlBu","rdYlGn","reds","sinebow","spectral","turbo","viridis","warm","ylGn","ylGnBu","ylOrBr","ylOrRd"],Qt=$t.map(t=>({label:t,value:t}));function Jt(){var u,p,c,j,b,h,f,x,N,y,T,C,E,M,A,R,V,q;const t=s.useEditorStore(m=>m.card),n=(p=(u=t==null?void 0:t.preferences)==null?void 0:u.mapVisualOptions)==null?void 0:p.topoJsonUrl,[a,r]=S.useState(((j=(c=t==null?void 0:t.preferences)==null?void 0:c.mapVisualOptions)==null?void 0:j.customTopoJsonUrl)||""),{setCardPreferences:o}=s.useEditorActions(),{data:i}=s.useTopoJson(t),l=Object.keys((i==null?void 0:i.objects)||{}).map(m=>({label:m,value:m}))||[],d=[{label:"US States 10m",value:"https://unpkg.com/us-atlas/states-10m.json"},{label:"Countries 50m",value:"https://unpkg.com/world-atlas/countries-50m.json"},{label:"Custom",value:"custom"}];return e.jsxs("div",{className:"p-6",children:[e.jsx(de,{summary:"Map Query",children:e.jsx("p",{className:"rounded-md bg-muted p-2 font-mono text-xs",children:"SELECT country, value FROM table"})}),e.jsx(s.Separator,{className:"my-4"}),e.jsx(de,{open:!0,summary:"Settings",children:e.jsxs("div",{className:"space-y-3 px-2",children:[e.jsx(te,{className:"h-9",options:d,onValueChange:m=>{console.log("value",m),o({...t.preferences,mapVisualOptions:{topoJsonUrl:m}})},value:n||"",label:"Select Map"}),n==="custom"&&e.jsx(s.Input,{onChange:m=>{r(m.target.value)},onBlur:()=>{var m;console.log("onBlur",a),o({...t.preferences,mapVisualOptions:{...(m=t.preferences)==null?void 0:m.mapVisualOptions,customTopoJsonUrl:a}})},value:a,className:`h-9 w-full ${s.removeRing}`,placeholder:"Custom URL"}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:"Map Object"}),e.jsx(te,{className:"h-9",options:l,value:((h=(b=t.preferences)==null?void 0:b.mapVisualOptions)==null?void 0:h.objectKey)||"",label:"Map Object",onValueChange:m=>{var L;o({...t.preferences,mapVisualOptions:{...(L=t.preferences)==null?void 0:L.mapVisualOptions,objectKey:m}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:"Projection"}),e.jsx(te,{className:"h-9",options:Ut,value:((x=(f=t.preferences)==null?void 0:f.mapVisualOptions)==null?void 0:x.projection)||"",label:"Projection",onValueChange:m=>{var L;o({...t.preferences,mapVisualOptions:{...(L=t.preferences)==null?void 0:L.mapVisualOptions,projection:m}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:"Colors"}),e.jsx(te,{className:"h-9",options:Qt,value:((y=(N=t.preferences)==null?void 0:N.mapVisualOptions)==null?void 0:y.colorScale)||"",label:"Select Color Scale",onValueChange:m=>{var L;o({...t.preferences,mapVisualOptions:{...(L=t.preferences)==null?void 0:L.mapVisualOptions,colorScale:m}})}})]})]})]})}),e.jsx(s.Separator,{className:"my-4"}),e.jsx(de,{className:"",summary:"Scale Options",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(s.Input,{className:`h-9 w-full ${s.removeRing}`,type:"number",step:.1,value:((C=(T=t.preferences)==null?void 0:T.mapVisualOptions)==null?void 0:C.projectionScale)||1,onChange:m=>{var L;o({...t.preferences,mapVisualOptions:{...(L=t.preferences)==null?void 0:L.mapVisualOptions,projectionScale:Number(m.target.value)}})}}),e.jsx(s.Label,{children:"X"}),e.jsx(s.Input,{className:`h-9 w-full ${s.removeRing}`,type:"number",step:10,value:((A=(M=(E=t.preferences)==null?void 0:E.mapVisualOptions)==null?void 0:M.projectionOffset)==null?void 0:A[0])||0,onChange:m=>{var L,_,g,k;o({...t.preferences,mapVisualOptions:{...(L=t.preferences)==null?void 0:L.mapVisualOptions,projectionOffset:[Number(m.target.value),((k=(g=(_=t.preferences)==null?void 0:_.mapVisualOptions)==null?void 0:g.projectionOffset)==null?void 0:k[1])||0]}})}}),e.jsx(s.Label,{children:"Y"}),e.jsx(s.Input,{className:`h-9 w-full ${s.removeRing}`,type:"number",step:10,value:((q=(V=(R=t.preferences)==null?void 0:R.mapVisualOptions)==null?void 0:V.projectionOffset)==null?void 0:q[1])||0,onChange:m=>{var L,_,g,k;o({...t.preferences,mapVisualOptions:{...(L=t.preferences)==null?void 0:L.mapVisualOptions,projectionOffset:[((k=(g=(_=t.preferences)==null?void 0:_.mapVisualOptions)==null?void 0:g.projectionOffset)==null?void 0:k[0])||0,Number(m.target.value)]}})}})]})}),e.jsx(s.Separator,{className:"my-4"}),e.jsx(re,{})]})}function Wt(){var r;const t=s.useEditorStore(o=>o.card.preferences),{setCardPreferences:n}=s.useEditorStore(o=>o.actions);function a(o){n({...t,textVisualOptions:{...t==null?void 0:t.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxs(s.RadioGroup,{value:(r=t==null?void 0:t.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:a,className:"flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"static",id:"r1"}),e.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function xe({cardType:t,docContent:n,suffix:a="Chart"}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:`${s.titleCase(t)} ${a}`}),e.jsx(s.AccordionContent,{children:n||e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"label - category"}),e.jsx("li",{children:"measure - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar",children:"example"})," in the docs."]})]})})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[t==="range"&&e.jsx(ge,{}),t!=="text"&&e.jsx(we,{}),t==="text"&&e.jsx(Wt,{})]})]}),!["range","text"].includes(t)&&e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(re,{}),e.jsx(le,{})]})]})]})})}function Kt(){const t=s.useEditorStore(r=>{var o,i;return(i=(o=r==null?void 0:r.card)==null?void 0:o.preferences)==null?void 0:i.sortChart}),{setSortChart:n}=s.useEditorActions();function a(){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Sort"}),e.jsx(te,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:t||"none",onValueChange:r=>{n(r)}})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:"Stacked Chart"}),e.jsxs(s.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"x-axis - category"}),e.jsx("li",{children:"stack by - category"}),e.jsx("li",{children:"y-axis - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/stacked",children:"example"})," in the docs."]})]})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ge,{}),a(),e.jsx(ds,{})]})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(re,{}),e.jsx(le,{})]})]})]})})}function Xt({cardType:t="table"}){console.log("cardType",t);const n=s.useEditorStore(o=>{var i;return(i=o.card)==null?void 0:i.preferences}),a=s.useEditorStore(o=>o.actions.setCardPreferences),r=o=>{a({...n,allowDownload:o})};return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(s.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(re,{}),e.jsx(le,{})]})]})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Checkbox,{onCheckedChange:r,id:"allow-download"}),e.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const Yt=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/tornado",children:"example"})," in the docs."]})]}),Zt=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/range",children:"example"})," in the docs."]})]}),ea=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/text",children:"example"})," in the docs."]})]});function sa(){const t=s.useEditorStore(a=>a.card.type);function n(a){switch(a){case"stackedBar":case"stackedLine":return e.jsx(Kt,{});case"pyramid":return e.jsx(xe,{docContent:Yt,cardType:a});case"kpi":return e.jsx(Gt,{});case"line":case"bar":return e.jsx(Vt,{cardType:a});case"range":return e.jsx(xe,{docContent:Zt,cardType:a});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsx(xe,{cardType:a});case"bubble":case"scatter":return e.jsx(Rt,{cardType:a});case"table":return e.jsx(Xt,{cardType:a});case"text":return e.jsx(xe,{docContent:ea,cardType:a,suffix:"Visual"});case"map":return e.jsx(Jt,{});case"custom":return e.jsx(Ot,{});default:return e.jsx(_t,{})}}return e.jsxs(s.ScrollArea,{className:"h-full w-full text-sm",children:[n(t),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})}function ta(){const t=s.useEditorStore(n=>n.isShowingVisual);return e.jsxs(s.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsx(s.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsx(jt,{})}),e.jsx(s.ResizableHandle,{withHandle:!0,className:"border"}),e.jsx(s.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:t?e.jsxs(s.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(s.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsx(sa,{})})}),e.jsx(s.ResizableHandle,{className:"border"}),e.jsx(s.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsx(Fe,{})})]}):e.jsx(Fe,{})})]})}function aa({authToken:t,onSave:n,onClose:a}){s.useDashboardStore(l=>l.themeStyle);const r=s.useEditorStore(l=>l.actions.setOnSave),o=s.useEditorStore(l=>l.actions.setOnClose),i=s.useDashboardStore(l=>l.actions.setAuthToken);return S.useEffect(()=>{n&&r(n),a&&o(a)},[n,r,a,o]),S.useEffect(()=>{t&&t.accessToken&&i(t)},[t,i]),e.jsx(s.ErrorBoundary,{FallbackComponent:s.Fallback,children:e.jsxs(s.EditorPanel,{style:{},className:"rounded-none",role:"editor-panel",children:[e.jsx(s.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsx(Ye,{})}),e.jsx(s.EditorMain,{children:e.jsx(ta,{})})]})})}function na(){s.useDashboardStore(l=>l.selectedCardId);const t=s.useDashboardStore(l=>l.selectedSheetId),{setIsVisualEditing:n}=s.useDashboardStore(l=>l.actions),a=s.useDashboardStore(l=>l.isVisualEditing),r=s.useDashboardStore(l=>l.actions.updateFrame);function o(l){t&&(r(t,l),n(!1))}function i(){n(!1)}return e.jsx("div",{role:"editor-container",className:s.cn("flex grow",{"max-h-0 overflow-hidden":!a}),children:e.jsx(aa,{onSave:o,onClose:i})})}function ra(){const t=s.useEditorStore(i=>i.selectedDatabaseName),n=s.useEditorStore(i=>i.selectedTableName),a=s.useDashboardStore(i=>i.dashboard.filters)||[],{columns:r}=ne(),{assignFilter:o}=hs();return e.jsx(s.ScrollArea,{className:"flex-1 basis-0 flex-col px-3",children:r==null?void 0:r.map(i=>{const l=a==null?void 0:a.find(d=>d.column===s.fmt(i.column_name)&&d.table===n&&d.database===t);return e.jsx("div",{onClick:()=>o(i),className:s.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":l}),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xe,{column:i}),e.jsx("span",{children:i.column_name})]})},i.column_name)})})}function oa(){s.useDashboardStore(n=>n.showFilters);const t=s.useDashboardStore(n=>n.actions.setShowFilters);return e.jsxs("section",{className:"relative flex min-w-[320px] grow flex-col border-l px-1",children:[e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsx(s.Label,{className:"px-2 text-lg",children:"Filters"}),e.jsx(s.Button,{onClick:()=>t(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsx(s.Cross2Icon,{})})]}),e.jsx("div",{className:"flex grow",children:e.jsx(Ye,{ColumnsComponent:()=>e.jsx(ra,{})})})]})}function ia(){const t=s.useDashboardStore(r=>r.dashboard.filters),n=s.useDashboardStore(r=>r.theme),a=t==null?void 0:t.filter(r=>r.hide);return a!=null&&a.length?e.jsx("div",{className:s.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":n==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":n==="dark"}),children:a==null?void 0:a.map(r=>e.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[e.jsx(s.FilterHeader,{filter:r}),e.jsx(s.FilterComponent,{filter:r})]},r.id))}):null}function la(){const t=s.useDashboardStore(r=>r.showFilters),n=s.useDashboardStore(r=>r.isVisualEditing),a=s.useDashboardStore(r=>r.isDashboardEditing);return e.jsxs("div",{role:"dashboard-plus-main",className:s.cn("",{"max-h-0 overflow-hidden":n,"flex grow overflow-auto":!n}),children:[e.jsxs("section",{className:"flex grow flex-col",children:[a&&e.jsx(ia,{}),e.jsx(s.DashboardTabs,{})]}),t&&e.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsx(oa,{})})]})}function ca(){const t=s.useDashboardStore(o=>o.dashboard),n=s.useDashboardStore(o=>o.actions.setDashboard),a=s.useDashboardStore(o=>o.showDashboardJSON),r=s.useDashboardStore(o=>o.actions.setShowDashboardJSON);return e.jsxs("div",{className:s.cn("relative p-2",{hidden:!a}),children:[e.jsxs(s.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>r(!1),children:[e.jsx(s.X,{className:"mr-2 h-4 w-4"}),"Close"]}),e.jsx(s.de,{onChange:o=>{if(o)try{JSON.parse(o),n(JSON.parse(o))}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 da({showControls:t=!1,showFooter:n=!0,...a}){return e.jsx(s.ErrorBoundary,{FallbackComponent:s.Fallback,children:e.jsxs(s.SemaphorContextProvider,{dashboardProps:a,children:[e.jsx(s.$e,{}),e.jsxs(s.UXProvider,{children:[e.jsx(ca,{}),e.jsxs(s.DashboardPanel,{...a,children:[t&&e.jsx(Zs,{}),e.jsx(na,{}),e.jsx(la,{})]})]})]})})}exports.Dashboard=s.Dashboard;exports.DashboardWC=s.DashboardWC;exports.SemaphorDataProvider=s.SemaphorQueryClient;exports.SemaphorQueryClient=s.SemaphorQueryClient;exports.createSqlGenConfig=s.createSqlGenConfig;exports.fmt=s.fmt;exports.getColumnDataType=s.getColumnDataType;exports.getFilterValueType=s.getFilterValueType;exports.getFormattedTableNameForQuery=s.getFormattedTableNameForQuery;exports.getQualifiedTableName=s.getQualifiedTableName;exports.getSql=s.getSql;exports.invalidateToken=s.invalidateToken;exports.isBooleanDataType=s.isBooleanDataType;exports.isColumnInSqlGen=s.isColumnInSqlGen;exports.isDateDataType=s.isDateDataType;exports.isNumberDataType=s.isNumberDataType;exports.isTextDataType=s.isTextDataType;exports.resolveDataType=s.resolveDataType;exports.resolveDatamodelName=s.resolveDatamodelName;exports.useCard=s.useCard;exports.useDashboardActions=s.useDashboardActions;exports.useDashboardStore=s.useDashboardStore;exports.useDateFilterHook=s.useDateFilterHook;exports.useEditorActions=s.useEditorActions;exports.useEditorStore=s.useEditorStore;exports.useTextFilterHook=s.useTextFilterHook;exports.SelectComponent=oe;exports.Surfboard=da;exports.cleanCard=We;exports.downloadPdf=Ke;exports.getDashbaordStateWithoutData=Ne;exports.useEditorAside=ne;