@opengis/bi 1.2.25 → 1.2.26

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/bi.umd.cjs CHANGED
@@ -1,138 +1,138 @@
1
- (function(T,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(T=typeof globalThis<"u"?globalThis:T||self,e(T.bi={},T.Vue))})(this,function(T,e){"use strict";var Ri=Object.defineProperty;var Pi=(T,e,Y)=>e in T?Ri(T,e,{enumerable:!0,configurable:!0,writable:!0,value:Y}):T[e]=Y;var I=(T,e,Y)=>Pi(T,typeof e!="symbol"?e+"":e,Y);/**
1
+ (function(z,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vue-router")):typeof define=="function"&&define.amd?define(["exports","vue","vue-router"],e):(z=typeof globalThis<"u"?globalThis:z||self,e(z.bi={},z.Vue,z.vueRouter))})(this,function(z,e,O){"use strict";var Li=Object.defineProperty;var Ti=(z,e,O)=>e in z?Li(z,e,{enumerable:!0,configurable:!0,writable:!0,value:O}):z[e]=O;var I=(z,e,O)=>Ti(z,typeof e!="symbol"?e+"":e,O);/**
2
2
  * @license lucide-vue-next v0.577.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 Y=s=>{for(const t in s)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
6
+ */const ls=s=>{for(const t in s)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
7
7
  * @license lucide-vue-next v0.577.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 He=s=>s==="";/**
11
+ */const Ue=s=>s==="";/**
12
12
  * @license lucide-vue-next v0.577.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 cs=(...s)=>s.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim();/**
16
+ */const is=(...s)=>s.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim();/**
17
17
  * @license lucide-vue-next v0.577.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 Ge=s=>s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
21
+ */const He=s=>s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
22
22
  * @license lucide-vue-next v0.577.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 ds=s=>s.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase());/**
26
+ */const cs=s=>s.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase());/**
27
27
  * @license lucide-vue-next v0.577.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 ps=s=>{const t=ds(s);return t.charAt(0).toUpperCase()+t.slice(1)};/**
31
+ */const ds=s=>{const t=cs(s);return t.charAt(0).toUpperCase()+t.slice(1)};/**
32
32
  * @license lucide-vue-next v0.577.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
- */var re={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};/**
36
+ */var se={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};/**
37
37
  * @license lucide-vue-next v0.577.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 hs=({name:s,iconNode:t,absoluteStrokeWidth:r,"absolute-stroke-width":n,strokeWidth:o,"stroke-width":l,size:a=re.width,color:i=re.stroke,...c},{slots:d})=>e.h("svg",{...re,...c,width:a,height:a,stroke:i,"stroke-width":He(r)||He(n)||r===!0||n===!0?Number(o||l||re["stroke-width"])*24/Number(a):o||l||re["stroke-width"],class:cs("lucide",c.class,...s?[`lucide-${Ge(ps(s))}-icon`,`lucide-${Ge(s)}`]:["lucide-icon"]),...!d.default&&!Y(c)&&{"aria-hidden":"true"}},[...t.map(p=>e.h(...p)),...d.default?[d.default()]:[]]);/**
41
+ */const ps=({name:s,iconNode:t,absoluteStrokeWidth:r,"absolute-stroke-width":n,strokeWidth:o,"stroke-width":l,size:a=se.width,color:i=se.stroke,...c},{slots:d})=>e.h("svg",{...se,...c,width:a,height:a,stroke:i,"stroke-width":Ue(r)||Ue(n)||r===!0||n===!0?Number(o||l||se["stroke-width"])*24/Number(a):o||l||se["stroke-width"],class:is("lucide",c.class,...s?[`lucide-${He(ds(s))}-icon`,`lucide-${He(s)}`]:["lucide-icon"]),...!d.default&&!ls(c)&&{"aria-hidden":"true"}},[...t.map(p=>e.h(...p)),...d.default?[d.default()]:[]]);/**
42
42
  * @license lucide-vue-next v0.577.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 F=(s,t)=>(r,{slots:n,attrs:o})=>e.h(hs,{...o,...r,iconNode:t,name:s},n);/**
46
+ */const F=(s,t)=>(r,{slots:n,attrs:o})=>e.h(ps,{...o,...r,iconNode:t,name:s},n);/**
47
47
  * @license lucide-vue-next v0.577.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 us=F("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
51
+ */const hs=F("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
52
52
  * @license lucide-vue-next v0.577.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 ms=F("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);/**
56
+ */const us=F("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);/**
57
57
  * @license lucide-vue-next v0.577.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 fs=F("ellipsis-vertical",[["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"}]]);/**
61
+ */const ms=F("ellipsis-vertical",[["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"}]]);/**
62
62
  * @license lucide-vue-next v0.577.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 gs=F("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]);/**
66
+ */const fs=F("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]);/**
67
67
  * @license lucide-vue-next v0.577.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 bs=F("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
71
+ */const gs=F("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
72
72
  * @license lucide-vue-next v0.577.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 ys=F("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-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]]);/**
76
+ */const bs=F("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-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]]);/**
77
77
  * @license lucide-vue-next v0.577.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 xs=F("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
81
+ */const ys=F("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
82
82
  * @license lucide-vue-next v0.577.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=F("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
86
+ */const xs=F("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
87
87
  * @license lucide-vue-next v0.577.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 ws=F("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);/**
91
+ */const ks=F("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);/**
92
92
  * @license lucide-vue-next v0.577.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 _s=F("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"}]]);/**
96
+ */const ws=F("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"}]]);/**
97
97
  * @license lucide-vue-next v0.577.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 $s=F("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
101
+ */const _s=F("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
102
102
  * @license lucide-vue-next v0.577.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 Ze=F("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
106
+ */const Ge=F("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
107
107
  * @license lucide-vue-next v0.577.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 Es=F("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"}]]);/**
111
+ */const $s=F("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"}]]);/**
112
112
  * @license lucide-vue-next v0.577.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 Qe=F("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/**
116
+ */const Ze=F("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/**
117
117
  * @license lucide-vue-next v0.577.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 Bs=F("table-2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);/**
121
+ */const Es=F("table-2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);/**
122
122
  * @license lucide-vue-next v0.577.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 Vs=F("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);/**
126
+ */const Bs=F("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);/**
127
127
  * @license lucide-vue-next v0.577.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=F("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Ne={week:"Тиждень",month:"Місяць",quarter:"Квартал",year:"Рік"},Ds=["onClick"],Cs={class:"flex items-center justify-between w-full"},Ns={key:0},Ss=e.defineComponent({__name:"vs-bi-dropdown",props:{title:{},options:{},value:{default:null}},emits:["selected"],setup(s,{emit:t}){const r=s,n=t,o=e.ref(!1),l=e.ref(r.value??null),a=e.ref(null),i=e.computed(()=>{const m=r.options;return typeof m=="string"?m.split(",").map((f,k)=>({id:k,text:f.trim()})):Array.isArray(m)?m:[]}),c=e.computed(()=>{const m=i.value.find(f=>(f.id??f)===l.value);return m?m.text??String(m):r.title??""}),d=m=>{const f=(m==null?void 0:m.id)??m;l.value=f,o.value=!1,n("selected",f),document.removeEventListener("click",p)},p=m=>{a.value&&!a.value.contains(m.target)&&(o.value=!1,document.removeEventListener("click",p))},u=()=>{o.value=!o.value,o.value?setTimeout(()=>{document.addEventListener("click",p)},200):document.removeEventListener("click",p)},y=m=>(Ne==null?void 0:Ne[m])??m;return e.onUnmounted(()=>{document.removeEventListener("click",p)}),(m,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("button",{type:"button","aria-expanded":"true",class:"hs-select-disabled:pointer-events-none hs-select-disabled:opacity-50 relative group pr-2 -ms-2 py-1.5 pl-2.5 inline-flex shrink-0 justify-center items-center gap-x-1.5 text-sm text-gray-800 rounded-lg hover:bg-gray-100 focus:outline-none focus:bg-gray-100 before:absolute before:inset-0 before:z-[1] dark:text-neutral-400 dark:hover:bg-neutral-800 dark:focus:bg-neutral-700",onClick:u},[e.createTextVNode(e.toDisplayString(y(c.value))+" ",1),f[0]||(f[0]=e.createElementVNode("svg",{class:"shrink-0 size-3.5 text-gray-600 dark:text-neutral-400",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("path",{d:"m6 9 6 6 6-6"})],-1))]),o.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"biDropdown",ref:a,"data-hs-select-dropdown":"",class:"absolute mt-2 z-50 w-48 p-1 space-y-0.5 bg-white rounded-xl shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] dark:bg-neutral-950 opened",role:"listbox",tabindex:"-1","aria-orientation":"vertical",style:{"margin-top":"10px"}},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,k=>(e.openBlock(),e.createElementBlock("div",{key:k.id||k,class:"cursor-pointer selected hs-selected:bg-gray-100 dark:hs-selected:bg-neutral-800 py-1.5 px-2 w-full text-[13px] text-gray-800 rounded-lg hover:bg-gray-100 focus:outline-none focus:bg-gray-100 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:_=>d(k)},[e.createElementVNode("div",Cs,[e.createElementVNode("span",null,e.toDisplayString(y(k.text||k)),1),l.value===(k.id||k)?(e.openBlock(),e.createElementBlock("span",Ns,[...f[1]||(f[1]=[e.createElementVNode("svg",{class:"shrink-0 h-3.5 w-3.5 text-gray-800 dark:text-neutral-200",xmlns:"http:.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"})],-1)])])):e.createCommentVNode("",!0)])],8,Ds))),128))],512)):e.createCommentVNode("",!0)],64))}}),zs={class:"flex items-center space-x-2"},Ls=e.defineComponent({__name:"vs-bi-switch",props:e.mergeModels({leftLabel:{},rightLabel:{},modelValue:{type:Boolean}},{modelValue:{default:()=>!1,type:Boolean},modelModifiers:{}}),emits:e.mergeModels(["update:is-enabled"],["update:modelValue"]),setup(s,{emit:t}){const r=t,n=e.useModel(s,"modelValue"),o=()=>{r("update:is-enabled",n)};return(l,a)=>(e.openBlock(),e.createElementBlock("div",zs,[s.leftLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["transition-colors",{"text-blue-500":!n.value}])},e.toDisplayString(s.leftLabel),3)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=i=>n.value=i),type:"checkbox",class:"relative w-11 h-6 p-px bg-gray-100 border-transparent text-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:ring-blue-600 disabled:opacity-50 disabled:pointer-events-none checked:bg-none checked:text-blue-600 checked:border-blue-600 focus:checked:border-blue-600 dark:bg-neutral-800 dark:border-neutral-700 dark:checked:bg-blue-500 dark:checked:border-blue-500 dark:focus:ring-offset-gray-600 before:inline-block before:size-5 before:bg-white checked:before:bg-blue-200 before:translate-x-0 checked:before:translate-x-full before:rounded-full before:shadow before:h-5 before:w-5 before:transform before:ring-0 before:transition before:ease-in-out before:duration-200 dark:before:bg-neutral-400 dark:checked:before:bg-blue-200",onChange:o},null,544),[[e.vModelCheckbox,n.value]]),s.rightLabel?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["transition-colors",{"text-blue-500":n.value}])},e.toDisplayString(s.rightLabel),3)):e.createCommentVNode("",!0)]))}}),z=(s,t)=>{const r=s.__vccOpts||s;for(const[n,o]of t)r[n]=o;return r},Ts={},Is={class:"flex items-center justify-center h-full"};function Ms(s,t){return e.openBlock(),e.createElementBlock("div",Is,[...t[0]||(t[0]=[e.createElementVNode("div",{class:"text-center text-gray-500"},[e.createElementVNode("h2",{class:"text-2xl font-bold"},"No data available")],-1)])])}const Rs=z(Ts,[["render",Ms]]),Je={"bi-bar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ro)),"bi-number":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Qa)),"bi-text":e.defineAsyncComponent(()=>Promise.resolve().then(()=>el)),"bi-listbar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Na)),"bi-pie":e.defineAsyncComponent(()=>Promise.resolve().then(()=>vo)),"bi-donut":e.defineAsyncComponent(()=>Promise.resolve().then(()=>jo)),"bi-line":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Zo)),"bi-stat":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ca)),"bi-pivot":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ua)),"bi-progress":e.defineAsyncComponent(()=>Promise.resolve().then(()=>wa)),"bi-funnel":e.defineAsyncComponent(()=>Promise.resolve().then(()=>nl)),"bi-map":e.defineAsyncComponent(()=>Promise.resolve().then(()=>si)),"bi-cluster":e.defineAsyncComponent(()=>Promise.resolve().then(()=>_i)),"bi-table":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Mi))};let Ke="/api";function xe(s){Ke=s||"/api"}function Ps(s,t){const r=Ke.replace(/\/$/,""),o=s.startsWith("http")||s.startsWith("//")||r&&s.startsWith(r)?s:`${r}${s.startsWith("/")?s:`/${s}`}`;if(!t||!Object.keys(t).length)return o;const l=new URLSearchParams;Object.entries(t).forEach(([i,c])=>{c!==void 0&&c!==""&&l.set(i,String(c))});const a=l.toString();return a?`${o}${o.includes("?")?"&":"?"}${a}`:o}async function ke(s,t={}){const{params:r,...n}=t,o=Ps(s,r),l={...n.headers};n.body!=null&&(l["Content-Type"]=l["Content-Type"]??"application/json");const a=await fetch(o,{...n,headers:l});if(!a.ok){const c=new Error(a.statusText);throw c.status=a.status,c}const i=await a.text();if(i)try{return JSON.parse(i)}catch{return i}}const R={get(s,t){return ke(s,{...t,method:"GET"})},post(s,t){return ke(s,{method:"POST",body:t!=null?JSON.stringify(t):void 0})},put(s,t){return ke(s,{method:"PUT",body:t!=null?JSON.stringify(t):void 0})},delete(s){return ke(s,{method:"DELETE"})}},Fs={key:0,class:"text-[16px] flex max-w-full items-center min-h-0 justify-between h-fit shrink-0"},Ws={class:"flex items-center justify-between w-full gap-2"},js={class:"flex items-center gap-2 min-w-0"},Os={class:"text-gray-800 inline-block line-clamp-1 font-semibold"},As={class:"flex flex-col justify-end"},qs={key:0,class:"flex items-center justify-end w-full gap-2"},vs={class:"w-full h-full"},ne=e.defineComponent({__name:"vs-widget",props:{dashboard:{},prefix:{default:""},widget:{},height:{},filterURl:{},dashboardWidgets:{},selectedWidget:{},prefetchedData:{default:null}},emits:["update:current-widget-data"],setup(s,{emit:t}){const r=s,n=t,o=e.ref(null),l=e.ref(null),a=e.ref(null),i=e.ref({}),c=e.ref([]),d=e.computed(()=>{var h,b;const x=(h=r.dashboardWidgets)==null?void 0:h.find($=>$.name===r.widget);return((b=x==null?void 0:x.data)==null?void 0:b.title)??(x==null?void 0:x.title)??""}),p=e.computed(()=>{var h;const x=(h=r.dashboardWidgets)==null?void 0:h.find(b=>b.name===r.widget);return(x==null?void 0:x.type)??"text"}),u=e.computed(()=>{var x,h;return r.height||((h=(x=i.value)==null?void 0:x.style)==null?void 0:h.height)||480}),y=e.computed(()=>{var h;const x=(h=i.value)==null?void 0:h.controls;return!x||typeof x=="boolean"?[]:Object.keys(x).map(b=>({name:b,options:x[b]}))}),m=e.computed(()=>{const x=p.value?`bi-${p.value}`:"";return x&&x in Je?Je[x]:null});function f(x,h){var b,$;($=(b=l.value)==null?void 0:b.changeStyle)==null||$.call(b,x,h)}function k(x,h){const b=c.value.find($=>$.name===h);b?b.option=x:c.value.push({name:h,option:x}),_()}function _(){var h,b;let x=`/bi-data?dashboard=${r.dashboard}&widget=${r.widget}`;c.value.forEach($=>{x+=`&${$.name}=${$.option}`}),(b=(h=l.value)==null?void 0:h.getDataFromURL)==null||b.call(h,x)}function V(){const x=a.value;if(x!=null&&x.getDataURL){const h=x.getDataURL({type:"png",pixelRatio:2,backgroundColor:"#ffffff"}),b=document.createElement("a");b.href=h,b.download="chart.png",document.body.appendChild(b),b.click(),document.body.removeChild(b)}}return e.onMounted(()=>{r.prefix&&xe(r.prefix)}),e.watch(()=>r.filterURl,x=>{var h,b;x&&((b=(h=l.value)==null?void 0:h.setFilter)==null||b.call(h,x))}),e.watch(()=>r.selectedWidget,(x,h)=>{var b;x!==h&&x===((b=i.value)==null?void 0:b.id)&&n("update:current-widget-data",i.value)}),e.watch(i,(x,h)=>{(x==null?void 0:x.id)!==(h==null?void 0:h.id)&&n("update:current-widget-data",x)},{deep:!0}),(x,h)=>{var b,$,w;return e.openBlock(),e.createElementBlock("div",{ref_key:"widgetRef",ref:o,class:"box-border relative p-4 bg-white border border-gray-200 rounded-xl shadow-sm select-auto overflow-hidden",style:e.normalizeStyle({height:u.value+"px",maxHeight:u.value+"px"})},[["text","cluster","map"].includes(p.value)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Fs,[e.createElementVNode("div",Ws,[e.createElementVNode("div",js,[e.createElementVNode("span",Os,e.toDisplayString(d.value),1)]),e.createElementVNode("div",As,[(b=y.value)!=null&&b.length?(e.openBlock(),e.createElementBlock("span",qs,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(($=y.value)==null?void 0:$.filter(g=>(g==null?void 0:g.options)&&(g==null?void 0:g.name)!=="export"),g=>{var E,B;return e.openBlock(),e.createElementBlock("div",{key:g==null?void 0:g.name},[Array.isArray(g==null?void 0:g.options)?(e.openBlock(),e.createBlock(Ss,{key:0,title:g==null?void 0:g.name,options:g==null?void 0:g.options,value:((B=(E=i.value)==null?void 0:E.data)==null?void 0:B[g==null?void 0:g.name])??null,onSelected:C=>k(C,g==null?void 0:g.name)},null,8,["title","options","value","onSelected"])):typeof g.options=="boolean"?(e.openBlock(),e.createBlock(Ls,{key:1,"left-label":g==null?void 0:g.name,"model-value":!!(g!=null&&g.options),"onUpdate:isEnabled":C=>f(g==null?void 0:g.name,C)},null,8,["left-label","model-value","onUpdate:isEnabled"])):e.createCommentVNode("",!0)])}),128)),(w=y.value)!=null&&w.some(g=>(g==null?void 0:g.name)==="export")?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"h-[32px] w-[32px] rounded-lg hover:bg-gray-100 duration-100 flex items-center justify-center",onClick:V},[e.createVNode(e.unref(ms),{size:16,class:"text-gray-800"})])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])])])),e.createElementVNode("div",vs,[m.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(m.value),{key:0,ref_key:"chartRef",ref:l,"current-widget":a.value,"onUpdate:currentWidget":h[0]||(h[0]=g=>a.value=g),"widget-data":i.value,"onUpdate:widgetData":h[1]||(h[1]=g=>i.value=g),dashboard:s.dashboard,title:d.value,widget:s.widget,"prefetched-data":s.prefetchedData},null,40,["current-widget","widget-data","dashboard","title","widget","prefetched-data"])):(e.openBlock(),e.createBlock(Rs,{key:1,class:"w-full h-full"}))])],4)}}}),Us={class:"w-full overflow-hidden rounded vs-table-interface__table-wrp h-fit"},Hs={class:"p-5 min-h-[500px] flex flex-col justify-center items-center text-center"},Gs={class:"max-w-sm mx-auto mt-6"},Zs={class:"font-medium text-gray-800 dark:text-neutral-200"},Qs={class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"},we=e.defineComponent({__name:"vs-new-nodata",props:{title:{default:"Дані для відображення відсутні"},text:{default:"Змініть параметри пошуку або спробуйте пізніше"}},setup(s){return(t,r)=>(e.openBlock(),e.createElementBlock("div",Us,[e.createElementVNode("div",null,[e.createElementVNode("div",Hs,[r[0]||(r[0]=e.createStaticVNode('<svg class="w-48 mx-auto" viewBox="0 0 178 90" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="27" y="50.5" width="124" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="27" y="50.5" width="124" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-50 dark:stroke-neutral-700/10"></rect><rect x="34.5" y="58" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="61" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="73" width="77" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/30"></rect><rect x="27" y="36" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="39" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="51" width="92" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><g filter="url(#filter1)"><rect x="12" y="6" width="154" height="40" rx="8" fill="currentColor" class="fill-white dark:fill-neutral-800" shape-rendering="crispEdges"></rect><rect x="12.5" y="6.5" width="153" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/60" shape-rendering="crispEdges"></rect><rect x="20" y="14" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="17" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="29" width="106" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect></g><defs><filter id="filter1" x="0" y="0" width="178" height="64" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix><feOffset dy="6"></feOffset><feGaussianBlur stdDeviation="6"></feGaussianBlur><feComposite in2="hardAlpha" operator="out"></feComposite><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.03 0"></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1187_14810"></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1187_14810" result="shape"></feBlend></filter></defs></svg>',1)),e.createElementVNode("div",Gs,[e.createElementVNode("p",Zs,e.toDisplayString(s.title),1),e.createElementVNode("p",Qs,e.toDisplayString(s.text),1)])])])]))}}),Xs={components:{filterIcon:{__name:"filter",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(gs),e.mergeProps(t.$attrs,{size:24}),null,16))}}},props:["filterScheme"],emits:["filters:changed"]},Js={class:"flex items-center"},Ks={key:0,type:"button",class:"py-2 px-2.5 ml-3 h-[38px] inline-flex items-center gap-x-1.5 text-xs font-medium rounded-lg border border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 opacity-60 cursor-not-allowed",disabled:"",title:"Фільтри вимкнено (v3-filter видалено)"};function Ys(s,t,r,n,o,l){const a=e.resolveComponent("filterIcon");return e.openBlock(),e.createElementBlock("div",Js,[r.filterScheme?(e.openBlock(),e.createElementBlock("button",Ks,[e.createVNode(a),t[0]||(t[0]=e.createTextVNode(" Фільтри ",-1))])):e.createCommentVNode("",!0)])}const er={components:{VsFilterHeader:z(Xs,[["render",Ys]])},props:{dashboardData:{type:Object,default:null},filters:{type:Array,default:null}}},tr={class:"bg-white px-5 flex gap-4 h-[90px] border border-gray-200 rounded-xl mb-2 pt-[3px] justify-between items-center"},sr={class:"grow"},rr={class:"text-lg font-semibold text-stone-800 dark:text-neutral-200"},nr={key:0,class:"inline-flex items-center text-sm gap-x-2 text-stone-800 hover:text-stone-500 focus:outline-none focus:text-stone-500 dark:text-neutral-200 dark:hover:text-neutral-400 dark:focus:text-neutral-400"},or={key:0,class:"flex items-center gap-3"};function ar(s,t,r,n,o,l){var i,c,d;const a=e.resolveComponent("VsFilterHeader");return e.openBlock(),e.createElementBlock("div",tr,[e.createElementVNode("div",sr,[e.createElementVNode("h1",rr,e.toDisplayString((i=r.dashboardData)==null?void 0:i.title),1),(c=r.dashboardData)!=null&&c.description?(e.openBlock(),e.createElementBlock("button",nr,e.toDisplayString((d=r.dashboardData)==null?void 0:d.description),1)):e.createCommentVNode("",!0)]),r.filters?(e.openBlock(),e.createElementBlock("div",or,[e.createVNode(a,{filterScheme:r.filters,"onFilters:changed":t[0]||(t[0]=p=>s.$emit("filters:changed",p))},null,8,["filterScheme"])])):e.createCommentVNode("",!0)])}const lr=z(er,[["render",ar]]);var Ye={};const ir=Symbol(Ye.NODE_ENV!=="production"?"router":""),cr=Symbol(Ye.NODE_ENV!=="production"?"route location":"");function ee(){return e.inject(ir)}function dr(s){return e.inject(cr)}const pr={key:0,class:"text-gray-400 shrink-0"},hr=["onClick"],ur=["onClick"],mr={key:4,class:"text-gray-900 font-medium truncate"},et={__name:"vs-breadcrumbs",props:{items:{type:Array,default:()=>[]},compact:{type:Boolean,default:!1}},setup(s){const t=s,r=ee(),n=e.computed(()=>Array.isArray(t.items)?t.items:[]);function o(l){r!=null&&r.push?r.push(l):typeof l=="string"&&(window!=null&&window.location)&&(window.location.href=l)}return(l,a)=>{const i=e.resolveComponent("router-link");return e.openBlock(),e.createElementBlock("nav",{class:e.normalizeClass(["flex items-center gap-2 text-sm text-gray-600",s.compact?"py-1":"py-6"]),"aria-label":"Breadcrumb"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(c,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d},[d>0?(e.openBlock(),e.createElementBlock("span",pr,[e.createVNode(e.unref(us),{class:"w-4 h-4"})])):e.createCommentVNode("",!0),typeof c.onClick=="function"?(e.openBlock(),e.createElementBlock("span",{key:1,class:"hover:text-gray-900 transition-colors cursor-pointer",onClick:p=>c.onClick()},e.toDisplayString(c.label),9,hr)):e.unref(r)&&c.to?(e.openBlock(),e.createBlock(i,{key:2,to:c.to,class:"hover:text-gray-900 transition-colors"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.label),1)]),_:2},1032,["to"])):c.to?(e.openBlock(),e.createElementBlock("span",{key:3,class:"hover:text-gray-900 transition-colors cursor-pointer",onClick:p=>o(c.to)},e.toDisplayString(c.label),9,ur)):(e.openBlock(),e.createElementBlock("span",mr,e.toDisplayString(c.label),1))],64))),128))],2)}}},fr={components:{VsWidget:ne,VsNewNodata:we,VsHeader:lr,VsBreadcrumbs:et},props:["id","prefix"],data(){return{widgets:[],panels:[],error:!1,selectedPanel:"",filterURl:null,dashboardData:null}},async mounted(){xe(this.prefix||"/api"),await this.fetchData()},methods:{async fetchData(){if(this.id)try{const s=await R.get(`/bi-dashboard/${this.id}`);this.dashboardData=s}catch(s){console.error(s)}},columnClass(s){const t=s!=null&&s.col?s==null?void 0:s.col:12;return{1:"md:w-1/12 sm:w-full",2:"md:w-1/6 sm:w-full",3:"md:w-1/4 sm:w-full",4:"md:w-1/3 sm:w-full",6:"md:w-1/2 sm:w-full",8:"md:w-2/3 sm:w-full",10:"md:w-5/6 sm:w-full",12:"w-full"}[t]||"w-full"},async filterHandler(s){var r;this.filterURl="";let t="&filter=";(r=s==null?void 0:s.url)!=null&&r.length&&(s.url.split("|").forEach(o=>{const l=o.split("=");t+=`${l[0]}=${l[1]}`}),this.filterURl+=t)}}},gr={class:"w-full pb-8 overflow-y-auto mx-auto"},br={class:"grid flex-grow w-full grid-cols-12 gap-4 h-fit"};function yr(s,t,r,n,o,l){var c;const a=e.resolveComponent("VsNewNodata"),i=e.resolveComponent("VsWidget");return e.openBlock(),e.createElementBlock("div",gr,[e.createElementVNode("div",br,[o.error||!o.dashboardData?(e.openBlock(),e.createBlock(a,{key:0,class:"col-span-12"})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(((c=o.dashboardData)==null?void 0:c.panels)||[],(d,p)=>{var u;return e.openBlock(),e.createElementBlock("div",{key:p,class:e.normalizeClass([`col-span-12 lg:col-span-${d.col||12}`,"flex flex-col gap-[10px]"])},[(u=d.widgets)!=null&&u.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(d.widgets,y=>(e.openBlock(),e.createBlock(i,{key:y,dashboard:r.id,widget:y,"dashboard-widgets":o.dashboardData.widgets,"filter-u-rl":o.filterURl},null,8,["dashboard","widget","dashboard-widgets","filter-u-rl"]))),128)):(e.openBlock(),e.createBlock(i,{key:1,class:"flex flex-col",dashboard:r.id,widget:d.widget,"dashboard-widgets":o.dashboardData.widgets,"filter-u-rl":o.filterURl},null,8,["dashboard","widget","dashboard-widgets","filter-u-rl"]))],2)}),128))])])}const xr=z(fr,[["render",yr]]);var tt=(s=>(s.Dashboard="/dashboard",s.BiPlatform="/bi-platform",s.EditorBase="/editor",s.AllDashboards="/dashboards",s.DashboardByName="/dashboards/:name",s))(tt||{}),st;(s=>{(t=>{t.Bar="bar",t.ListBar="listbar",t.Number="number",t.Text="text",t.Pie="pie",t.Heatmap="heatmap",t.Calendar="calendar",t.Line="line",t.Stat="stat",t.Pivot="pivot",t.Funnel="funnel",t.Progress="progress"})(s.Types||(s.Types={}))})(st||(st={}));var W=(s=>(s.AllDashboards="all-dashboards",s.BiPlatform="bi-platform",s.Dashboard="dashboard",s.Erobota="erobota",s.Datatest="datatest",s.Sourcedate="sourcedate",s.Widgetwidget="widgetwidget",s.Test="test",s.Demo="demo",s.Crm="crm",s.Editor="editor",s.EditorDashboard="editor-dashboard",s.EditorWidget="editor-widget",s.Editordetails="editordetails",s.Dbtables="dbtables",s.Biviewer="biviewer",s.Biviewerinner="biviewerinner",s.Bieditor="bieditor",s.Bieditorinner="bieditorinner",s))(W||{});const kr={key:0,class:"vs-modal-wrapper fixed inset-0 flex items-center justify-center p-4"},wr={class:"flex items-center justify-between shrink-0 py-2.5 px-4 border-b border-gray-200 dark:border-[#454545]"},_r={class:"font-medium text-gray-800 dark:text-white"},$r={class:"vs-modal-content flex-1 min-h-0 overflow-auto p-4"},Er={key:0,class:"shrink-0 border-t border-gray-200 dark:border-neutral-700"},oe=z({__name:"vs-modal",props:{visible:{type:Boolean,default:!1},title:{type:String,default:""},size:{type:String,default:"medium"},closeClickBack:{type:Boolean,default:!1},teleport:{type:String,default:"#modal"}},emits:["close","update:visible"],setup(s,{emit:t}){const r=s,n=t,o=e.computed(()=>r.size==="small"?"md:max-w-[40%] w-full max-w-md":r.size==="lg"?"md:max-w-[70%] w-full max-w-4xl":"md:max-w-[50%] w-full max-w-lg");function l(){n("update:visible",!1),n("close")}function a(i){i.key==="Escape"&&l()}return e.onMounted(()=>{window.addEventListener("keydown",a)}),e.onUnmounted(()=>{window.removeEventListener("keydown",a)}),(i,c)=>(e.openBlock(),e.createBlock(e.Teleport,{to:s.teleport},[s.visible?(e.openBlock(),e.createElementBlock("div",kr,[e.createElementVNode("div",{class:"absolute inset-0 bg-black/50","aria-hidden":"true",onMousedown:c[0]||(c[0]=d=>s.closeClickBack&&d.target===d.currentTarget&&l())},null,32),e.createVNode(e.Transition,{name:"vs-modal",appear:""},{default:e.withCtx(()=>[s.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["vs-modal-panel relative flex flex-col bg-white dark:bg-[#1A1A1A] rounded-xl shadow-xl max-h-[85vh] min-w-0 border border-gray-200 dark:border-[#454545]",o.value]),role:"dialog","aria-modal":"true",onMousedown:c[1]||(c[1]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",wr,[e.createElementVNode("h3",_r,e.toDisplayString(s.title),1),e.createElementVNode("button",{type:"button",class:"size-8 inline-flex justify-center items-center rounded-full bg-gray-100 text-gray-800 hover:bg-gray-200 dark:bg-neutral-700 dark:hover:bg-neutral-600 dark:text-neutral-300","aria-label":"Закрити",onClick:l},[...c[2]||(c[2]=[e.createElementVNode("svg",{class:"w-4 h-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1)])])]),e.createElementVNode("div",$r,[e.renderSlot(i.$slots,"default",{},void 0,!0)]),i.$slots.footer?(e.openBlock(),e.createElementBlock("div",Er,[e.renderSlot(i.$slots,"footer",{},void 0,!0)])):e.createCommentVNode("",!0)],34)):e.createCommentVNode("",!0)]),_:3})])):e.createCommentVNode("",!0)],8,["to"]))}},[["__scopeId","data-v-5722a50f"]]),Br={__name:"icon-plus",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Ze),e.mergeProps(t.$attrs,{size:24}),null,16))}},Vr={class:"mb-4 overflow-auto scrollbar max-h-96"},Dr={__name:"vs-editor-create-widget",props:{columns:{type:Array,default:()=>[]},selectedDashboard:String,inline:{type:Boolean,default:!1}},emits:["update-data"],setup(s,{expose:t,emit:r}){var f;const n=e.defineAsyncComponent(()=>import("@opengis/form")),o=(f=e.getCurrentInstance().proxy)==null?void 0:f.$notify,l=r,a=s,i=e.ref(!1),c=e.ref({}),d=e.ref();function p(){i.value=!0}function u(){i.value=!1}t({open:p,close:u});const y=async()=>{var k;try{const _=(k=d.value)==null?void 0:k.doValidation;typeof _=="function"&&await _(),await R.post(`/bi-dashboard/${a.selectedDashboard}`,c.value),await o({type:"success",title:"Успішно!",message:"Віджет успішно створено"}),await l("update-data"),c.value={},i.value=!1}catch(_){const V=(_==null?void 0:_.message)||"При спробі створити віджет сталася помилка. Перевірте обов'язкові поля (зокрема Type).";o==null||o({type:"error",title:"Помилка!",message:V})}},m=e.computed(()=>{var k,_,V,x;return{title:{type:"text",label:"Назва віджета",placeholder:"Назва віджета",validators:["required"]},x:{type:"select",label:"Вісь X",view:"buttons",style:{size:"xs"},validators:["required"],options:(_=(k=a.columns)==null?void 0:k.filter(h=>(h==null?void 0:h.type)=="text"||(h==null?void 0:h.type)==="date"||(h==null?void 0:h.type)==="timestamp without time zone"||(h==null?void 0:h.type)==="boolean"||(h==null?void 0:h.type)==="integer"))==null?void 0:_.map(({name:h,type:b})=>({id:h,text:h,type:b}))},metric:{type:"select",label:"Вісь Y",view:"buttons",validators:["required"],style:{size:"xs"},options:[{id:"count",label:"count"},...(x=(V=a.columns)==null?void 0:V.filter(h=>(h==null?void 0:h.type)==="numeric"||(h==null?void 0:h.type)==="double precision"))==null?void 0:x.map(({name:h,type:b})=>({id:h,text:h,type:b}))]},col:{type:"select",label:"Кількість колонок",validators:["required"],options:[{id:1,label:1},{id:2,text:2},{id:3,text:3},{id:4,text:4},{id:6,text:6},{id:9,text:9},{id:12,text:12}]},height:{type:"Text",label:"Висота",placeholder:"Висота"},type:{type:"select",view:"buttons",label:"Тип віджета",validators:["required"],options:[{label:"Bar",id:"bar"},{label:"Funnel",id:"funnel"},{label:"Line",id:"line"},{label:"List bar",id:"listbar"},{label:"Number",id:"number"},{label:"Pie",id:"pie"},{label:"Donut",id:"donut"},{label:"Pivot",id:"pivot"},{label:"Table",id:"table"},{label:"Progress",id:"progress"},{label:"Stat",id:"stat"},{label:"Text",id:"text"},{label:"Map",id:"map"}]},text:{type:"Text",ua:"Текст",placeholder:"Текст",conditions:["type","==","text"]},table:{type:"Text",ua:"Таблиця",placeholder:"Таблиця"},query:{type:"Text",ua:"Запит (query)",placeholder:"Запит (query)"},cls:{type:"Text",ua:"Клас (cls)",placeholder:"Клас (cls)"}}});return(k,_)=>{const V=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock("div",null,[s.inline?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(V,{key:0,placement:"right",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("button",{class:"z-50 flex items-center justify-center h-[50px] !w-[50px] text-2xl text-white transition-colors bg-blue-500 rounded-full cursor-pointer hover:bg-blue-700",onClick:p},[e.createVNode(Br,{height:"20",width:"20"})])])]),default:e.withCtx(()=>[_[1]||(_[1]=e.createTextVNode(" Створити віджет ",-1))]),_:1})),e.createVNode(oe,{teleport:"#modal",visible:i.value,title:"Створити віджет",onClose:u},{footer:e.withCtx(()=>[e.createElementVNode("div",{class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:u,class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:y,class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Створити ")])]),default:e.withCtx(()=>[e.createElementVNode("div",Vr,[e.createVNode(e.unref(n),{ref_key:"form",ref:d,schema:m.value,values:c.value,"onUpdate:values":_[0]||(_[0]=x=>c.value=x)},null,8,["schema","values"])])]),_:1},8,["visible"])])}}},rt={__name:"delete",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Vs),e.mergeProps(t.$attrs,{size:24}),null,16))}},Se={__name:"close",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Xe),e.mergeProps(t.$attrs,{size:24}),null,16))}},nt={__name:"edit",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref($s),e.mergeProps(t.$attrs,{size:24}),null,16))}},Cr={class:"space-y-4"},Nr={__name:"vs-editor-form-style",props:{widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object,default:()=>{}}},emits:["update-dashboard"],setup(s,{expose:t,emit:r}){var $,w,g,E;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=r,a=s,i=e.ref(null),c=e.computed(()=>a.dashboardId||i.value),d=(($=a.data)==null?void 0:$.type)||((g=(w=a.data)==null?void 0:w.data)==null?void 0:g.type),u={pie:{label:!1,legend:!0,tooltip:!0},donut:{label:!1,legend:!0,tooltip:!0},bar:{label:!1,legend:!1,tooltip:!0},line:{label:!1,legend:!1,tooltip:!0},funnel:{label:!1,legend:!1,tooltip:!0}}[d]||{label:!1,legend:!1,tooltip:!0},y={show:{label:"Підпис",type:"switcher",title:"Показати підпис"},rotate:{type:"number",label:"Rotate angel",conditions:["show","==",!0]},align:{type:"select",view:"buttons",label:"Align",conditions:["show","==",!0],options:[{id:"center",text:"Center"},{id:"left",text:"Left"},{id:"right",text:"Right"}]},position:{type:"select",label:"Position",conditions:["show","==",!0],options:[{id:"top",text:"Top"},{id:"right",text:"Right"},{id:"left",text:"Left"},{id:"bottom",text:"Bottom"}]}},m={show:{label:"Легенда",type:"switcher",title:"Показати легенду"}},f={show:{label:"Тултіп",type:"switcher",title:"Показати тултіп"}},k=(E=a.data)==null?void 0:E.style,_=e.ref(k!=null&&k.label?{...k.label}:{show:u.label}),V=e.ref(k!=null&&k.legend?{...k.legend}:{show:u.legend}),x=e.ref(k!=null&&k.tooltip?{...k.tooltip}:{show:u.tooltip}),h=()=>{const B=new CustomEvent(`update-style-${a.widgetName}`);B.chartId=a.widgetName,B.options={options:{legend:V.value,tooltip:x.value,label:_.value},seriesOptions:_.value},window.dispatchEvent(B)};e.watch(_,h,{deep:!0}),e.watch(V,h,{deep:!0}),e.watch(x,h,{deep:!0});const b=async()=>{try{await R.put(`/bi-dashboard/${c.value}/${a.widgetName}`,{style:{legend:V.value,tooltip:x.value,label:_.value}});const B=new CustomEvent(`update-style-${a.widgetName}`);B.chartId=a.widgetName,B.options={options:{legend:V.value,tooltip:x.value,label:_.value},seriesOptions:_.value},window.dispatchEvent(B),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const B=new URLSearchParams(window.top.location.search);i.value=B.get("dashboard"),h()}),t({requestUpdateWidget:b}),(B,C)=>(e.openBlock(),e.createElementBlock("div",Cr,[e.createVNode(e.unref(n),{schema:y,values:_.value,"onUpdate:values":C[0]||(C[0]=M=>_.value=M),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(n),{schema:m,values:V.value,"onUpdate:values":C[1]||(C[1]=M=>V.value=M),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(n),{schema:f,values:x.value,"onUpdate:values":C[2]||(C[2]=M=>x.value=M),class:"p-0"},null,8,["values"])]))}};function ze(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let X=ze();function ot(s){X=s}const at=/[&<>"']/,Sr=new RegExp(at.source,"g"),lt=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,zr=new RegExp(lt.source,"g"),Lr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},it=s=>Lr[s];function O(s,t){if(t){if(at.test(s))return s.replace(Sr,it)}else if(lt.test(s))return s.replace(zr,it);return s}const Tr=/(^|[^\[])\^/g;function L(s,t){let r=typeof s=="string"?s:s.source;t=t||"";const n={replace:(o,l)=>{let a=typeof l=="string"?l:l.source;return a=a.replace(Tr,"$1"),r=r.replace(o,a),n},getRegex:()=>new RegExp(r,t)};return n}function ct(s){try{s=encodeURI(s).replace(/%25/g,"%")}catch{return null}return s}const ae={exec:()=>null};function dt(s,t){const r=s.replace(/\|/g,(l,a,i)=>{let c=!1,d=a;for(;--d>=0&&i[d]==="\\";)c=!c;return c?"|":" |"}),n=r.split(/ \|/);let o=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;o<n.length;o++)n[o]=n[o].trim().replace(/\\\|/g,"|");return n}function le(s,t,r){const n=s.length;if(n===0)return"";let o=0;for(;o<n&&s.charAt(n-o-1)===t;)o++;return s.slice(0,n-o)}function Ir(s,t){if(s.indexOf(t[1])===-1)return-1;let r=0;for(let n=0;n<s.length;n++)if(s[n]==="\\")n++;else if(s[n]===t[0])r++;else if(s[n]===t[1]&&(r--,r<0))return n;return-1}function pt(s,t,r,n){const o=t.href,l=t.title?O(t.title):null,a=s[1].replace(/\\([\[\]])/g,"$1");if(s[0].charAt(0)!=="!"){n.state.inLink=!0;const i={type:"link",raw:r,href:o,title:l,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,i}return{type:"image",raw:r,href:o,title:l,text:O(a)}}function Mr(s,t){const r=s.match(/^(\s+)(?:```)/);if(r===null)return t;const n=r[1];return t.split(`
131
+ */const Qe=F("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Ce={week:"Тиждень",month:"Місяць",quarter:"Квартал",year:"Рік"},Vs=["onClick"],Ds={class:"flex items-center justify-between w-full"},Cs={key:0},Ns=e.defineComponent({__name:"vs-bi-dropdown",props:{title:{},options:{},value:{default:null}},emits:["selected"],setup(s,{emit:t}){const r=s,n=t,o=e.ref(!1),l=e.ref(r.value??null),a=e.ref(null),i=e.computed(()=>{const m=r.options;return typeof m=="string"?m.split(",").map((f,k)=>({id:k,text:f.trim()})):Array.isArray(m)?m:[]}),c=e.computed(()=>{const m=i.value.find(f=>(f.id??f)===l.value);return m?m.text??String(m):r.title??""}),d=m=>{const f=(m==null?void 0:m.id)??m;l.value=f,o.value=!1,n("selected",f),document.removeEventListener("click",p)},p=m=>{a.value&&!a.value.contains(m.target)&&(o.value=!1,document.removeEventListener("click",p))},u=()=>{o.value=!o.value,o.value?setTimeout(()=>{document.addEventListener("click",p)},200):document.removeEventListener("click",p)},y=m=>(Ce==null?void 0:Ce[m])??m;return e.onUnmounted(()=>{document.removeEventListener("click",p)}),(m,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("button",{type:"button","aria-expanded":"true",class:"hs-select-disabled:pointer-events-none hs-select-disabled:opacity-50 relative group pr-2 -ms-2 py-1.5 pl-2.5 inline-flex shrink-0 justify-center items-center gap-x-1.5 text-sm text-gray-800 rounded-lg hover:bg-gray-100 focus:outline-none focus:bg-gray-100 before:absolute before:inset-0 before:z-[1] dark:text-neutral-400 dark:hover:bg-neutral-800 dark:focus:bg-neutral-700",onClick:u},[e.createTextVNode(e.toDisplayString(y(c.value))+" ",1),f[0]||(f[0]=e.createElementVNode("svg",{class:"shrink-0 size-3.5 text-gray-600 dark:text-neutral-400",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("path",{d:"m6 9 6 6 6-6"})],-1))]),o.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"biDropdown",ref:a,"data-hs-select-dropdown":"",class:"absolute mt-2 z-50 w-48 p-1 space-y-0.5 bg-white rounded-xl shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] dark:bg-neutral-950 opened",role:"listbox",tabindex:"-1","aria-orientation":"vertical",style:{"margin-top":"10px"}},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,k=>(e.openBlock(),e.createElementBlock("div",{key:k.id||k,class:"cursor-pointer selected hs-selected:bg-gray-100 dark:hs-selected:bg-neutral-800 py-1.5 px-2 w-full text-[13px] text-gray-800 rounded-lg hover:bg-gray-100 focus:outline-none focus:bg-gray-100 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:_=>d(k)},[e.createElementVNode("div",Ds,[e.createElementVNode("span",null,e.toDisplayString(y(k.text||k)),1),l.value===(k.id||k)?(e.openBlock(),e.createElementBlock("span",Cs,[...f[1]||(f[1]=[e.createElementVNode("svg",{class:"shrink-0 h-3.5 w-3.5 text-gray-800 dark:text-neutral-200",xmlns:"http:.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polyline",{points:"20 6 9 17 4 12"})],-1)])])):e.createCommentVNode("",!0)])],8,Vs))),128))],512)):e.createCommentVNode("",!0)],64))}}),Ss={class:"flex items-center space-x-2"},zs=e.defineComponent({__name:"vs-bi-switch",props:e.mergeModels({leftLabel:{},rightLabel:{},modelValue:{type:Boolean}},{modelValue:{default:()=>!1,type:Boolean},modelModifiers:{}}),emits:e.mergeModels(["update:is-enabled"],["update:modelValue"]),setup(s,{emit:t}){const r=t,n=e.useModel(s,"modelValue"),o=()=>{r("update:is-enabled",n)};return(l,a)=>(e.openBlock(),e.createElementBlock("div",Ss,[s.leftLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["transition-colors",{"text-blue-500":!n.value}])},e.toDisplayString(s.leftLabel),3)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=i=>n.value=i),type:"checkbox",class:"relative w-11 h-6 p-px bg-gray-100 border-transparent text-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:ring-blue-600 disabled:opacity-50 disabled:pointer-events-none checked:bg-none checked:text-blue-600 checked:border-blue-600 focus:checked:border-blue-600 dark:bg-neutral-800 dark:border-neutral-700 dark:checked:bg-blue-500 dark:checked:border-blue-500 dark:focus:ring-offset-gray-600 before:inline-block before:size-5 before:bg-white checked:before:bg-blue-200 before:translate-x-0 checked:before:translate-x-full before:rounded-full before:shadow before:h-5 before:w-5 before:transform before:ring-0 before:transition before:ease-in-out before:duration-200 dark:before:bg-neutral-400 dark:checked:before:bg-blue-200",onChange:o},null,544),[[e.vModelCheckbox,n.value]]),s.rightLabel?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["transition-colors",{"text-blue-500":n.value}])},e.toDisplayString(s.rightLabel),3)):e.createCommentVNode("",!0)]))}}),L=(s,t)=>{const r=s.__vccOpts||s;for(const[n,o]of t)r[n]=o;return r},Ls={},Ts={class:"flex items-center justify-center h-full"};function Is(s,t){return e.openBlock(),e.createElementBlock("div",Ts,[...t[0]||(t[0]=[e.createElementVNode("div",{class:"text-center text-gray-500"},[e.createElementVNode("h2",{class:"text-2xl font-bold"},"No data available")],-1)])])}const Ms=L(Ls,[["render",Is]]),Xe={"bi-bar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Lo)),"bi-number":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ua)),"bi-text":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Xa)),"bi-listbar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ba)),"bi-pie":e.defineAsyncComponent(()=>Promise.resolve().then(()=>jo)),"bi-donut":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ro)),"bi-line":e.defineAsyncComponent(()=>Promise.resolve().then(()=>vo)),"bi-stat":e.defineAsyncComponent(()=>Promise.resolve().then(()=>oa)),"bi-pivot":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Aa)),"bi-progress":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ba)),"bi-funnel":e.defineAsyncComponent(()=>Promise.resolve().then(()=>el)),"bi-map":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Kl)),"bi-cluster":e.defineAsyncComponent(()=>Promise.resolve().then(()=>yi)),"bi-table":e.defineAsyncComponent(()=>Promise.resolve().then(()=>zi))};let Je="/api";function ye(s){Je=s||"/api"}function Rs(s,t){const r=Je.replace(/\/$/,""),o=s.startsWith("http")||s.startsWith("//")||r&&s.startsWith(r)?s:`${r}${s.startsWith("/")?s:`/${s}`}`;if(!t||!Object.keys(t).length)return o;const l=new URLSearchParams;Object.entries(t).forEach(([i,c])=>{c!==void 0&&c!==""&&l.set(i,String(c))});const a=l.toString();return a?`${o}${o.includes("?")?"&":"?"}${a}`:o}async function xe(s,t={}){const{params:r,...n}=t,o=Rs(s,r),l={...n.headers};n.body!=null&&(l["Content-Type"]=l["Content-Type"]??"application/json");const a=await fetch(o,{...n,headers:l});if(!a.ok){const c=new Error(a.statusText);throw c.status=a.status,c}const i=await a.text();if(i)try{return JSON.parse(i)}catch{return i}}const R={get(s,t){return xe(s,{...t,method:"GET"})},post(s,t){return xe(s,{method:"POST",body:t!=null?JSON.stringify(t):void 0})},put(s,t){return xe(s,{method:"PUT",body:t!=null?JSON.stringify(t):void 0})},delete(s){return xe(s,{method:"DELETE"})}},Ps={key:0,class:"text-[16px] flex max-w-full items-center min-h-0 justify-between h-fit shrink-0"},Fs={class:"flex items-center justify-between w-full gap-2"},Ws={class:"flex items-center gap-2 min-w-0"},js={class:"text-gray-800 inline-block line-clamp-1 font-semibold"},As={class:"flex flex-col justify-end"},Os={key:0,class:"flex items-center justify-end w-full gap-2"},qs={class:"w-full h-full"},re=e.defineComponent({__name:"vs-widget",props:{dashboard:{},prefix:{default:""},widget:{},height:{},filterURl:{},dashboardWidgets:{},selectedWidget:{},prefetchedData:{default:null}},emits:["update:current-widget-data"],setup(s,{emit:t}){const r=s,n=t,o=e.ref(null),l=e.ref(null),a=e.ref(null),i=e.ref({}),c=e.ref([]),d=e.computed(()=>{var h,b;const x=(h=r.dashboardWidgets)==null?void 0:h.find($=>$.name===r.widget);return((b=x==null?void 0:x.data)==null?void 0:b.title)??(x==null?void 0:x.title)??""}),p=e.computed(()=>{var h;const x=(h=r.dashboardWidgets)==null?void 0:h.find(b=>b.name===r.widget);return(x==null?void 0:x.type)??"text"}),u=e.computed(()=>{var x,h;return r.height||((h=(x=i.value)==null?void 0:x.style)==null?void 0:h.height)||480}),y=e.computed(()=>{var h;const x=(h=i.value)==null?void 0:h.controls;return!x||typeof x=="boolean"?[]:Object.keys(x).map(b=>({name:b,options:x[b]}))}),m=e.computed(()=>{const x=p.value?`bi-${p.value}`:"";return x&&x in Xe?Xe[x]:null});function f(x,h){var b,$;($=(b=l.value)==null?void 0:b.changeStyle)==null||$.call(b,x,h)}function k(x,h){const b=c.value.find($=>$.name===h);b?b.option=x:c.value.push({name:h,option:x}),_()}function _(){var h,b;let x=`/bi-data?dashboard=${r.dashboard}&widget=${r.widget}`;c.value.forEach($=>{x+=`&${$.name}=${$.option}`}),(b=(h=l.value)==null?void 0:h.getDataFromURL)==null||b.call(h,x)}function V(){const x=a.value;if(x!=null&&x.getDataURL){const h=x.getDataURL({type:"png",pixelRatio:2,backgroundColor:"#ffffff"}),b=document.createElement("a");b.href=h,b.download="chart.png",document.body.appendChild(b),b.click(),document.body.removeChild(b)}}return e.onMounted(()=>{r.prefix&&ye(r.prefix)}),e.watch(()=>r.filterURl,x=>{var h,b;x&&((b=(h=l.value)==null?void 0:h.setFilter)==null||b.call(h,x))}),e.watch(()=>r.selectedWidget,(x,h)=>{var b;x!==h&&x===((b=i.value)==null?void 0:b.id)&&n("update:current-widget-data",i.value)}),e.watch(i,(x,h)=>{(x==null?void 0:x.id)!==(h==null?void 0:h.id)&&n("update:current-widget-data",x)},{deep:!0}),(x,h)=>{var b,$,w;return e.openBlock(),e.createElementBlock("div",{ref_key:"widgetRef",ref:o,class:"box-border relative p-4 bg-white border border-gray-200 rounded-xl shadow-sm select-auto overflow-hidden",style:e.normalizeStyle({height:u.value+"px",maxHeight:u.value+"px"})},[["text","cluster","map"].includes(p.value)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ps,[e.createElementVNode("div",Fs,[e.createElementVNode("div",Ws,[e.createElementVNode("span",js,e.toDisplayString(d.value),1)]),e.createElementVNode("div",As,[(b=y.value)!=null&&b.length?(e.openBlock(),e.createElementBlock("span",Os,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(($=y.value)==null?void 0:$.filter(g=>(g==null?void 0:g.options)&&(g==null?void 0:g.name)!=="export"),g=>{var E,B;return e.openBlock(),e.createElementBlock("div",{key:g==null?void 0:g.name},[Array.isArray(g==null?void 0:g.options)?(e.openBlock(),e.createBlock(Ns,{key:0,title:g==null?void 0:g.name,options:g==null?void 0:g.options,value:((B=(E=i.value)==null?void 0:E.data)==null?void 0:B[g==null?void 0:g.name])??null,onSelected:C=>k(C,g==null?void 0:g.name)},null,8,["title","options","value","onSelected"])):typeof g.options=="boolean"?(e.openBlock(),e.createBlock(zs,{key:1,"left-label":g==null?void 0:g.name,"model-value":!!(g!=null&&g.options),"onUpdate:isEnabled":C=>f(g==null?void 0:g.name,C)},null,8,["left-label","model-value","onUpdate:isEnabled"])):e.createCommentVNode("",!0)])}),128)),(w=y.value)!=null&&w.some(g=>(g==null?void 0:g.name)==="export")?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"h-[32px] w-[32px] rounded-lg hover:bg-gray-100 duration-100 flex items-center justify-center",onClick:V},[e.createVNode(e.unref(us),{size:16,class:"text-gray-800"})])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])])])),e.createElementVNode("div",qs,[m.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(m.value),{key:0,ref_key:"chartRef",ref:l,"current-widget":a.value,"onUpdate:currentWidget":h[0]||(h[0]=g=>a.value=g),"widget-data":i.value,"onUpdate:widgetData":h[1]||(h[1]=g=>i.value=g),dashboard:s.dashboard,title:d.value,widget:s.widget,"prefetched-data":s.prefetchedData},null,40,["current-widget","widget-data","dashboard","title","widget","prefetched-data"])):(e.openBlock(),e.createBlock(Ms,{key:1,class:"w-full h-full"}))])],4)}}}),vs={class:"w-full overflow-hidden rounded vs-table-interface__table-wrp h-fit"},Us={class:"p-5 min-h-[500px] flex flex-col justify-center items-center text-center"},Hs={class:"max-w-sm mx-auto mt-6"},Gs={class:"font-medium text-gray-800 dark:text-neutral-200"},Zs={class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"},ke=e.defineComponent({__name:"vs-new-nodata",props:{title:{default:"Дані для відображення відсутні"},text:{default:"Змініть параметри пошуку або спробуйте пізніше"}},setup(s){return(t,r)=>(e.openBlock(),e.createElementBlock("div",vs,[e.createElementVNode("div",null,[e.createElementVNode("div",Us,[r[0]||(r[0]=e.createStaticVNode('<svg class="w-48 mx-auto" viewBox="0 0 178 90" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="27" y="50.5" width="124" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="27" y="50.5" width="124" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-50 dark:stroke-neutral-700/10"></rect><rect x="34.5" y="58" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="61" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="73" width="77" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/30"></rect><rect x="27" y="36" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="39" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="51" width="92" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><g filter="url(#filter1)"><rect x="12" y="6" width="154" height="40" rx="8" fill="currentColor" class="fill-white dark:fill-neutral-800" shape-rendering="crispEdges"></rect><rect x="12.5" y="6.5" width="153" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/60" shape-rendering="crispEdges"></rect><rect x="20" y="14" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="17" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="29" width="106" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect></g><defs><filter id="filter1" x="0" y="0" width="178" height="64" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix><feOffset dy="6"></feOffset><feGaussianBlur stdDeviation="6"></feGaussianBlur><feComposite in2="hardAlpha" operator="out"></feComposite><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.03 0"></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1187_14810"></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1187_14810" result="shape"></feBlend></filter></defs></svg>',1)),e.createElementVNode("div",Hs,[e.createElementVNode("p",Gs,e.toDisplayString(s.title),1),e.createElementVNode("p",Zs,e.toDisplayString(s.text),1)])])])]))}}),Qs={components:{filterIcon:{__name:"filter",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(fs),e.mergeProps(t.$attrs,{size:24}),null,16))}}},props:["filterScheme"],emits:["filters:changed"]},Xs={class:"flex items-center"},Js={key:0,type:"button",class:"py-2 px-2.5 ml-3 h-[38px] inline-flex items-center gap-x-1.5 text-xs font-medium rounded-lg border border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 opacity-60 cursor-not-allowed",disabled:"",title:"Фільтри вимкнено (v3-filter видалено)"};function Ks(s,t,r,n,o,l){const a=e.resolveComponent("filterIcon");return e.openBlock(),e.createElementBlock("div",Xs,[r.filterScheme?(e.openBlock(),e.createElementBlock("button",Js,[e.createVNode(a),t[0]||(t[0]=e.createTextVNode(" Фільтри ",-1))])):e.createCommentVNode("",!0)])}const Ys={components:{VsFilterHeader:L(Qs,[["render",Ks]])},props:{dashboardData:{type:Object,default:null},filters:{type:Array,default:null}}},er={class:"bg-white px-5 flex gap-4 h-[90px] border border-gray-200 rounded-xl mb-2 pt-[3px] justify-between items-center"},tr={class:"grow"},sr={class:"text-lg font-semibold text-stone-800 dark:text-neutral-200"},rr={key:0,class:"inline-flex items-center text-sm gap-x-2 text-stone-800 hover:text-stone-500 focus:outline-none focus:text-stone-500 dark:text-neutral-200 dark:hover:text-neutral-400 dark:focus:text-neutral-400"},nr={key:0,class:"flex items-center gap-3"};function or(s,t,r,n,o,l){var i,c,d;const a=e.resolveComponent("VsFilterHeader");return e.openBlock(),e.createElementBlock("div",er,[e.createElementVNode("div",tr,[e.createElementVNode("h1",sr,e.toDisplayString((i=r.dashboardData)==null?void 0:i.title),1),(c=r.dashboardData)!=null&&c.description?(e.openBlock(),e.createElementBlock("button",rr,e.toDisplayString((d=r.dashboardData)==null?void 0:d.description),1)):e.createCommentVNode("",!0)]),r.filters?(e.openBlock(),e.createElementBlock("div",nr,[e.createVNode(a,{filterScheme:r.filters,"onFilters:changed":t[0]||(t[0]=p=>s.$emit("filters:changed",p))},null,8,["filterScheme"])])):e.createCommentVNode("",!0)])}const ar=L(Ys,[["render",or]]),lr={key:0,class:"text-gray-400 shrink-0"},ir=["onClick"],cr=["onClick"],dr={key:4,class:"text-gray-900 font-medium truncate"},Ke={__name:"vs-breadcrumbs",props:{items:{type:Array,default:()=>[]},compact:{type:Boolean,default:!1}},setup(s){const t=s,r=O.useRouter(),n=e.computed(()=>Array.isArray(t.items)?t.items:[]);function o(l){r!=null&&r.push?r.push(l):typeof l=="string"&&(window!=null&&window.location)&&(window.location.href=l)}return(l,a)=>{const i=e.resolveComponent("router-link");return e.openBlock(),e.createElementBlock("nav",{class:e.normalizeClass(["flex items-center gap-2 text-sm text-gray-600",s.compact?"py-1":"py-6"]),"aria-label":"Breadcrumb"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(c,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d},[d>0?(e.openBlock(),e.createElementBlock("span",lr,[e.createVNode(e.unref(hs),{class:"w-4 h-4"})])):e.createCommentVNode("",!0),typeof c.onClick=="function"?(e.openBlock(),e.createElementBlock("span",{key:1,class:"hover:text-gray-900 transition-colors cursor-pointer",onClick:p=>c.onClick()},e.toDisplayString(c.label),9,ir)):e.unref(r)&&c.to?(e.openBlock(),e.createBlock(i,{key:2,to:c.to,class:"hover:text-gray-900 transition-colors"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.label),1)]),_:2},1032,["to"])):c.to?(e.openBlock(),e.createElementBlock("span",{key:3,class:"hover:text-gray-900 transition-colors cursor-pointer",onClick:p=>o(c.to)},e.toDisplayString(c.label),9,cr)):(e.openBlock(),e.createElementBlock("span",dr,e.toDisplayString(c.label),1))],64))),128))],2)}}},pr={components:{VsWidget:re,VsNewNodata:ke,VsHeader:ar,VsBreadcrumbs:Ke},props:["id","prefix"],data(){return{widgets:[],panels:[],error:!1,selectedPanel:"",filterURl:null,dashboardData:null}},async mounted(){ye(this.prefix||"/api"),await this.fetchData()},methods:{async fetchData(){if(this.id)try{const s=await R.get(`/bi-dashboard/${this.id}`);this.dashboardData=s}catch(s){console.error(s)}},columnClass(s){const t=s!=null&&s.col?s==null?void 0:s.col:12;return{1:"md:w-1/12 sm:w-full",2:"md:w-1/6 sm:w-full",3:"md:w-1/4 sm:w-full",4:"md:w-1/3 sm:w-full",6:"md:w-1/2 sm:w-full",8:"md:w-2/3 sm:w-full",10:"md:w-5/6 sm:w-full",12:"w-full"}[t]||"w-full"},async filterHandler(s){var r;this.filterURl="";let t="&filter=";(r=s==null?void 0:s.url)!=null&&r.length&&(s.url.split("|").forEach(o=>{const l=o.split("=");t+=`${l[0]}=${l[1]}`}),this.filterURl+=t)}}},hr={class:"w-full pb-8 overflow-y-auto mx-auto"},ur={class:"grid flex-grow w-full grid-cols-12 gap-4 h-fit"};function mr(s,t,r,n,o,l){var c;const a=e.resolveComponent("VsNewNodata"),i=e.resolveComponent("VsWidget");return e.openBlock(),e.createElementBlock("div",hr,[e.createElementVNode("div",ur,[o.error||!o.dashboardData?(e.openBlock(),e.createBlock(a,{key:0,class:"col-span-12"})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(((c=o.dashboardData)==null?void 0:c.panels)||[],(d,p)=>{var u;return e.openBlock(),e.createElementBlock("div",{key:p,class:e.normalizeClass([`col-span-12 lg:col-span-${d.col||12}`,"flex flex-col gap-[10px]"])},[(u=d.widgets)!=null&&u.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(d.widgets,y=>(e.openBlock(),e.createBlock(i,{key:y,dashboard:r.id,widget:y,"dashboard-widgets":o.dashboardData.widgets,"filter-u-rl":o.filterURl},null,8,["dashboard","widget","dashboard-widgets","filter-u-rl"]))),128)):(e.openBlock(),e.createBlock(i,{key:1,class:"flex flex-col",dashboard:r.id,widget:d.widget,"dashboard-widgets":o.dashboardData.widgets,"filter-u-rl":o.filterURl},null,8,["dashboard","widget","dashboard-widgets","filter-u-rl"]))],2)}),128))])])}const fr=L(pr,[["render",mr]]);var Ye=(s=>(s.Dashboard="/dashboard",s.BiPlatform="/bi-platform",s.EditorBase="/editor",s.AllDashboards="/dashboards",s.DashboardByName="/dashboards/:name",s))(Ye||{}),et;(s=>{(t=>{t.Bar="bar",t.ListBar="listbar",t.Number="number",t.Text="text",t.Pie="pie",t.Heatmap="heatmap",t.Calendar="calendar",t.Line="line",t.Stat="stat",t.Pivot="pivot",t.Funnel="funnel",t.Progress="progress"})(s.Types||(s.Types={}))})(et||(et={}));var W=(s=>(s.AllDashboards="all-dashboards",s.BiPlatform="bi-platform",s.Dashboard="dashboard",s.Erobota="erobota",s.Datatest="datatest",s.Sourcedate="sourcedate",s.Widgetwidget="widgetwidget",s.Test="test",s.Demo="demo",s.Crm="crm",s.Editor="editor",s.EditorDashboard="editor-dashboard",s.EditorWidget="editor-widget",s.Editordetails="editordetails",s.Dbtables="dbtables",s.Biviewer="biviewer",s.Biviewerinner="biviewerinner",s.Bieditor="bieditor",s.Bieditorinner="bieditorinner",s))(W||{});const gr={key:0,class:"vs-modal-wrapper fixed inset-0 flex items-center justify-center p-4"},br={class:"flex items-center justify-between shrink-0 py-2.5 px-4 border-b border-gray-200 dark:border-[#454545]"},yr={class:"font-medium text-gray-800 dark:text-white"},xr={class:"vs-modal-content flex-1 min-h-0 overflow-auto p-4"},kr={key:0,class:"shrink-0 border-t border-gray-200 dark:border-neutral-700"},ne=L({__name:"vs-modal",props:{visible:{type:Boolean,default:!1},title:{type:String,default:""},size:{type:String,default:"medium"},closeClickBack:{type:Boolean,default:!1},teleport:{type:String,default:"#modal"}},emits:["close","update:visible"],setup(s,{emit:t}){const r=s,n=t,o=e.computed(()=>r.size==="small"?"md:max-w-[40%] w-full max-w-md":r.size==="lg"?"md:max-w-[70%] w-full max-w-4xl":"md:max-w-[50%] w-full max-w-lg");function l(){n("update:visible",!1),n("close")}function a(i){i.key==="Escape"&&l()}return e.onMounted(()=>{window.addEventListener("keydown",a)}),e.onUnmounted(()=>{window.removeEventListener("keydown",a)}),(i,c)=>(e.openBlock(),e.createBlock(e.Teleport,{to:s.teleport},[s.visible?(e.openBlock(),e.createElementBlock("div",gr,[e.createElementVNode("div",{class:"absolute inset-0 bg-black/50","aria-hidden":"true",onMousedown:c[0]||(c[0]=d=>s.closeClickBack&&d.target===d.currentTarget&&l())},null,32),e.createVNode(e.Transition,{name:"vs-modal",appear:""},{default:e.withCtx(()=>[s.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["vs-modal-panel relative flex flex-col bg-white dark:bg-[#1A1A1A] rounded-xl shadow-xl max-h-[85vh] min-w-0 border border-gray-200 dark:border-[#454545]",o.value]),role:"dialog","aria-modal":"true",onMousedown:c[1]||(c[1]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",br,[e.createElementVNode("h3",yr,e.toDisplayString(s.title),1),e.createElementVNode("button",{type:"button",class:"size-8 inline-flex justify-center items-center rounded-full bg-gray-100 text-gray-800 hover:bg-gray-200 dark:bg-neutral-700 dark:hover:bg-neutral-600 dark:text-neutral-300","aria-label":"Закрити",onClick:l},[...c[2]||(c[2]=[e.createElementVNode("svg",{class:"w-4 h-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1)])])]),e.createElementVNode("div",xr,[e.renderSlot(i.$slots,"default",{},void 0,!0)]),i.$slots.footer?(e.openBlock(),e.createElementBlock("div",kr,[e.renderSlot(i.$slots,"footer",{},void 0,!0)])):e.createCommentVNode("",!0)],34)):e.createCommentVNode("",!0)]),_:3})])):e.createCommentVNode("",!0)],8,["to"]))}},[["__scopeId","data-v-5722a50f"]]),wr={__name:"icon-plus",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Ge),e.mergeProps(t.$attrs,{size:24}),null,16))}},_r={class:"mb-4 overflow-auto scrollbar max-h-96"},$r={__name:"vs-editor-create-widget",props:{columns:{type:Array,default:()=>[]},selectedDashboard:String,inline:{type:Boolean,default:!1}},emits:["update-data"],setup(s,{expose:t,emit:r}){var f;const n=e.defineAsyncComponent(()=>import("@opengis/form")),o=(f=e.getCurrentInstance().proxy)==null?void 0:f.$notify,l=r,a=s,i=e.ref(!1),c=e.ref({}),d=e.ref();function p(){i.value=!0}function u(){i.value=!1}t({open:p,close:u});const y=async()=>{var k;try{const _=(k=d.value)==null?void 0:k.doValidation;typeof _=="function"&&await _(),await R.post(`/bi-dashboard/${a.selectedDashboard}`,c.value),await o({type:"success",title:"Успішно!",message:"Віджет успішно створено"}),await l("update-data"),c.value={},i.value=!1}catch(_){const V=(_==null?void 0:_.message)||"При спробі створити віджет сталася помилка. Перевірте обов'язкові поля (зокрема Type).";o==null||o({type:"error",title:"Помилка!",message:V})}},m=e.computed(()=>{var k,_,V,x;return{title:{type:"text",label:"Назва віджета",placeholder:"Назва віджета",validators:["required"]},x:{type:"select",label:"Вісь X",view:"buttons",style:{size:"xs"},validators:["required"],options:(_=(k=a.columns)==null?void 0:k.filter(h=>(h==null?void 0:h.type)=="text"||(h==null?void 0:h.type)==="date"||(h==null?void 0:h.type)==="timestamp without time zone"||(h==null?void 0:h.type)==="boolean"||(h==null?void 0:h.type)==="integer"))==null?void 0:_.map(({name:h,type:b})=>({id:h,text:h,type:b}))},metric:{type:"select",label:"Вісь Y",view:"buttons",validators:["required"],style:{size:"xs"},options:[{id:"count",label:"count"},...(x=(V=a.columns)==null?void 0:V.filter(h=>(h==null?void 0:h.type)==="numeric"||(h==null?void 0:h.type)==="double precision"))==null?void 0:x.map(({name:h,type:b})=>({id:h,text:h,type:b}))]},col:{type:"select",label:"Кількість колонок",validators:["required"],options:[{id:1,label:1},{id:2,text:2},{id:3,text:3},{id:4,text:4},{id:6,text:6},{id:9,text:9},{id:12,text:12}]},height:{type:"Text",label:"Висота",placeholder:"Висота"},type:{type:"select",view:"buttons",label:"Тип віджета",validators:["required"],options:[{label:"Bar",id:"bar"},{label:"Funnel",id:"funnel"},{label:"Line",id:"line"},{label:"List bar",id:"listbar"},{label:"Number",id:"number"},{label:"Pie",id:"pie"},{label:"Donut",id:"donut"},{label:"Pivot",id:"pivot"},{label:"Table",id:"table"},{label:"Progress",id:"progress"},{label:"Stat",id:"stat"},{label:"Text",id:"text"},{label:"Map",id:"map"}]},text:{type:"Text",ua:"Текст",placeholder:"Текст",conditions:["type","==","text"]},table:{type:"Text",ua:"Таблиця",placeholder:"Таблиця"},query:{type:"Text",ua:"Запит (query)",placeholder:"Запит (query)"},cls:{type:"Text",ua:"Клас (cls)",placeholder:"Клас (cls)"}}});return(k,_)=>{const V=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock("div",null,[s.inline?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(V,{key:0,placement:"right",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("button",{class:"z-50 flex items-center justify-center h-[50px] !w-[50px] text-2xl text-white transition-colors bg-blue-500 rounded-full cursor-pointer hover:bg-blue-700",onClick:p},[e.createVNode(wr,{height:"20",width:"20"})])])]),default:e.withCtx(()=>[_[1]||(_[1]=e.createTextVNode(" Створити віджет ",-1))]),_:1})),e.createVNode(ne,{teleport:"#modal",visible:i.value,title:"Створити віджет",onClose:u},{footer:e.withCtx(()=>[e.createElementVNode("div",{class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:u,class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:y,class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Створити ")])]),default:e.withCtx(()=>[e.createElementVNode("div",_r,[e.createVNode(e.unref(n),{ref_key:"form",ref:d,schema:m.value,values:c.value,"onUpdate:values":_[0]||(_[0]=x=>c.value=x)},null,8,["schema","values"])])]),_:1},8,["visible"])])}}},tt={__name:"delete",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Bs),e.mergeProps(t.$attrs,{size:24}),null,16))}},Ne={__name:"close",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Qe),e.mergeProps(t.$attrs,{size:24}),null,16))}},st={__name:"edit",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(_s),e.mergeProps(t.$attrs,{size:24}),null,16))}},Er={class:"space-y-4"},Br={__name:"vs-editor-form-style",props:{widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object,default:()=>{}}},emits:["update-dashboard"],setup(s,{expose:t,emit:r}){var $,w,g,E;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=r,a=s,i=e.ref(null),c=e.computed(()=>a.dashboardId||i.value),d=(($=a.data)==null?void 0:$.type)||((g=(w=a.data)==null?void 0:w.data)==null?void 0:g.type),u={pie:{label:!1,legend:!0,tooltip:!0},donut:{label:!1,legend:!0,tooltip:!0},bar:{label:!1,legend:!1,tooltip:!0},line:{label:!1,legend:!1,tooltip:!0},funnel:{label:!1,legend:!1,tooltip:!0}}[d]||{label:!1,legend:!1,tooltip:!0},y={show:{label:"Підпис",type:"switcher",title:"Показати підпис"},rotate:{type:"number",label:"Rotate angel",conditions:["show","==",!0]},align:{type:"select",view:"buttons",label:"Align",conditions:["show","==",!0],options:[{id:"center",text:"Center"},{id:"left",text:"Left"},{id:"right",text:"Right"}]},position:{type:"select",label:"Position",conditions:["show","==",!0],options:[{id:"top",text:"Top"},{id:"right",text:"Right"},{id:"left",text:"Left"},{id:"bottom",text:"Bottom"}]}},m={show:{label:"Легенда",type:"switcher",title:"Показати легенду"}},f={show:{label:"Тултіп",type:"switcher",title:"Показати тултіп"}},k=(E=a.data)==null?void 0:E.style,_=e.ref(k!=null&&k.label?{...k.label}:{show:u.label}),V=e.ref(k!=null&&k.legend?{...k.legend}:{show:u.legend}),x=e.ref(k!=null&&k.tooltip?{...k.tooltip}:{show:u.tooltip}),h=()=>{const B=new CustomEvent(`update-style-${a.widgetName}`);B.chartId=a.widgetName,B.options={options:{legend:V.value,tooltip:x.value,label:_.value},seriesOptions:_.value},window.dispatchEvent(B)};e.watch(_,h,{deep:!0}),e.watch(V,h,{deep:!0}),e.watch(x,h,{deep:!0});const b=async()=>{try{await R.put(`/bi-dashboard/${c.value}/${a.widgetName}`,{style:{legend:V.value,tooltip:x.value,label:_.value}});const B=new CustomEvent(`update-style-${a.widgetName}`);B.chartId=a.widgetName,B.options={options:{legend:V.value,tooltip:x.value,label:_.value},seriesOptions:_.value},window.dispatchEvent(B),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const B=new URLSearchParams(window.top.location.search);i.value=B.get("dashboard"),h()}),t({requestUpdateWidget:b}),(B,C)=>(e.openBlock(),e.createElementBlock("div",Er,[e.createVNode(e.unref(n),{schema:y,values:_.value,"onUpdate:values":C[0]||(C[0]=M=>_.value=M),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(n),{schema:m,values:V.value,"onUpdate:values":C[1]||(C[1]=M=>V.value=M),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(n),{schema:f,values:x.value,"onUpdate:values":C[2]||(C[2]=M=>x.value=M),class:"p-0"},null,8,["values"])]))}};function Se(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let J=Se();function rt(s){J=s}const nt=/[&<>"']/,Vr=new RegExp(nt.source,"g"),ot=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Dr=new RegExp(ot.source,"g"),Cr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},at=s=>Cr[s];function A(s,t){if(t){if(nt.test(s))return s.replace(Vr,at)}else if(ot.test(s))return s.replace(Dr,at);return s}const Nr=/(^|[^\[])\^/g;function T(s,t){let r=typeof s=="string"?s:s.source;t=t||"";const n={replace:(o,l)=>{let a=typeof l=="string"?l:l.source;return a=a.replace(Nr,"$1"),r=r.replace(o,a),n},getRegex:()=>new RegExp(r,t)};return n}function lt(s){try{s=encodeURI(s).replace(/%25/g,"%")}catch{return null}return s}const oe={exec:()=>null};function it(s,t){const r=s.replace(/\|/g,(l,a,i)=>{let c=!1,d=a;for(;--d>=0&&i[d]==="\\";)c=!c;return c?"|":" |"}),n=r.split(/ \|/);let o=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;o<n.length;o++)n[o]=n[o].trim().replace(/\\\|/g,"|");return n}function ae(s,t,r){const n=s.length;if(n===0)return"";let o=0;for(;o<n&&s.charAt(n-o-1)===t;)o++;return s.slice(0,n-o)}function Sr(s,t){if(s.indexOf(t[1])===-1)return-1;let r=0;for(let n=0;n<s.length;n++)if(s[n]==="\\")n++;else if(s[n]===t[0])r++;else if(s[n]===t[1]&&(r--,r<0))return n;return-1}function ct(s,t,r,n){const o=t.href,l=t.title?A(t.title):null,a=s[1].replace(/\\([\[\]])/g,"$1");if(s[0].charAt(0)!=="!"){n.state.inLink=!0;const i={type:"link",raw:r,href:o,title:l,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,i}return{type:"image",raw:r,href:o,title:l,text:A(a)}}function zr(s,t){const r=s.match(/^(\s+)(?:```)/);if(r===null)return t;const n=r[1];return t.split(`
132
132
  `).map(o=>{const l=o.match(/^\s+/);if(l===null)return o;const[a]=l;return a.length>=n.length?o.slice(n.length):o}).join(`
133
- `)}class _e{constructor(t){I(this,"options");I(this,"rules");I(this,"lexer");this.options=t||X}space(t){const r=this.rules.block.newline.exec(t);if(r&&r[0].length>0)return{type:"space",raw:r[0]}}code(t){const r=this.rules.block.code.exec(t);if(r){const n=r[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:r[0],codeBlockStyle:"indented",text:this.options.pedantic?n:le(n,`
134
- `)}}}fences(t){const r=this.rules.block.fences.exec(t);if(r){const n=r[0],o=Mr(n,r[3]||"");return{type:"code",raw:n,lang:r[2]?r[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):r[2],text:o}}}heading(t){const r=this.rules.block.heading.exec(t);if(r){let n=r[2].trim();if(/#$/.test(n)){const o=le(n,"#");(this.options.pedantic||!o||/ $/.test(o))&&(n=o.trim())}return{type:"heading",raw:r[0],depth:r[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){const r=this.rules.block.hr.exec(t);if(r)return{type:"hr",raw:le(r[0],`
135
- `)}}blockquote(t){const r=this.rules.block.blockquote.exec(t);if(r){let n=le(r[0],`
133
+ `)}class we{constructor(t){I(this,"options");I(this,"rules");I(this,"lexer");this.options=t||J}space(t){const r=this.rules.block.newline.exec(t);if(r&&r[0].length>0)return{type:"space",raw:r[0]}}code(t){const r=this.rules.block.code.exec(t);if(r){const n=r[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:r[0],codeBlockStyle:"indented",text:this.options.pedantic?n:ae(n,`
134
+ `)}}}fences(t){const r=this.rules.block.fences.exec(t);if(r){const n=r[0],o=zr(n,r[3]||"");return{type:"code",raw:n,lang:r[2]?r[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):r[2],text:o}}}heading(t){const r=this.rules.block.heading.exec(t);if(r){let n=r[2].trim();if(/#$/.test(n)){const o=ae(n,"#");(this.options.pedantic||!o||/ $/.test(o))&&(n=o.trim())}return{type:"heading",raw:r[0],depth:r[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){const r=this.rules.block.hr.exec(t);if(r)return{type:"hr",raw:ae(r[0],`
135
+ `)}}blockquote(t){const r=this.rules.block.blockquote.exec(t);if(r){let n=ae(r[0],`
136
136
  `).split(`
137
137
  `),o="",l="";const a=[];for(;n.length>0;){let i=!1;const c=[];let d;for(d=0;d<n.length;d++)if(/^ {0,3}>/.test(n[d]))c.push(n[d]),i=!0;else if(!i)c.push(n[d]);else break;n=n.slice(d);const p=c.join(`
138
138
  `),u=p.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
@@ -150,10 +150,10 @@ ${u}`:u;const y=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
150
150
  `,1)[0];let g;if(y=w,this.options.pedantic?(y=y.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),g=y):g=y.replace(/\t/g," "),h.test(y)||b.test(y)||$.test(y)||V.test(y)||x.test(y))break;if(g.search(/[^ ]/)>=f||!y.trim())p+=`
151
151
  `+g.slice(f);else{if(m||u.replace(/\t/g," ").search(/[^ ]/)>=4||h.test(u)||b.test(u)||x.test(u))break;p+=`
152
152
  `+y}!m&&!y.trim()&&(m=!0),d+=w+`
153
- `,t=t.substring(w.length+1),u=g.slice(f)}}l.loose||(i?l.loose=!0:/\n[ \t]*\n[ \t]*$/.test(d)&&(i=!0));let k=null,_;this.options.gfm&&(k=/^\[[ xX]\] /.exec(p),k&&(_=k[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),l.items.push({type:"list_item",raw:d,task:!!k,checked:_,loose:!1,text:p,tokens:[]}),l.raw+=d}l.items[l.items.length-1].raw=l.items[l.items.length-1].raw.trimEnd(),l.items[l.items.length-1].text=l.items[l.items.length-1].text.trimEnd(),l.raw=l.raw.trimEnd();for(let c=0;c<l.items.length;c++)if(this.lexer.state.top=!1,l.items[c].tokens=this.lexer.blockTokens(l.items[c].text,[]),!l.loose){const d=l.items[c].tokens.filter(u=>u.type==="space"),p=d.length>0&&d.some(u=>/\n.*\n/.test(u.raw));l.loose=p}if(l.loose)for(let c=0;c<l.items.length;c++)l.items[c].loose=!0;return l}}html(t){const r=this.rules.block.html.exec(t);if(r)return{type:"html",block:!0,raw:r[0],pre:r[1]==="pre"||r[1]==="script"||r[1]==="style",text:r[0]}}def(t){const r=this.rules.block.def.exec(t);if(r){const n=r[1].toLowerCase().replace(/\s+/g," "),o=r[2]?r[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",l=r[3]?r[3].substring(1,r[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):r[3];return{type:"def",tag:n,raw:r[0],href:o,title:l}}}table(t){const r=this.rules.block.table.exec(t);if(!r||!/[:|]/.test(r[2]))return;const n=dt(r[1]),o=r[2].replace(/^\||\| *$/g,"").split("|"),l=r[3]&&r[3].trim()?r[3].replace(/\n[ \t]*$/,"").split(`
154
- `):[],a={type:"table",raw:r[0],header:[],align:[],rows:[]};if(n.length===o.length){for(const i of o)/^ *-+: *$/.test(i)?a.align.push("right"):/^ *:-+: *$/.test(i)?a.align.push("center"):/^ *:-+ *$/.test(i)?a.align.push("left"):a.align.push(null);for(let i=0;i<n.length;i++)a.header.push({text:n[i],tokens:this.lexer.inline(n[i]),header:!0,align:a.align[i]});for(const i of l)a.rows.push(dt(i,a.header.length).map((c,d)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:a.align[d]})));return a}}lheading(t){const r=this.rules.block.lheading.exec(t);if(r)return{type:"heading",raw:r[0],depth:r[2].charAt(0)==="="?1:2,text:r[1],tokens:this.lexer.inline(r[1])}}paragraph(t){const r=this.rules.block.paragraph.exec(t);if(r){const n=r[1].charAt(r[1].length-1)===`
155
- `?r[1].slice(0,-1):r[1];return{type:"paragraph",raw:r[0],text:n,tokens:this.lexer.inline(n)}}}text(t){const r=this.rules.block.text.exec(t);if(r)return{type:"text",raw:r[0],text:r[0],tokens:this.lexer.inline(r[0])}}escape(t){const r=this.rules.inline.escape.exec(t);if(r)return{type:"escape",raw:r[0],text:O(r[1])}}tag(t){const r=this.rules.inline.tag.exec(t);if(r)return!this.lexer.state.inLink&&/^<a /i.test(r[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(r[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(r[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(r[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:r[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:r[0]}}link(t){const r=this.rules.inline.link.exec(t);if(r){const n=r[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const a=le(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{const a=Ir(r[2],"()");if(a>-1){const c=(r[0].indexOf("!")===0?5:4)+r[1].length+a;r[2]=r[2].substring(0,a),r[0]=r[0].substring(0,c).trim(),r[3]=""}}let o=r[2],l="";if(this.options.pedantic){const a=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);a&&(o=a[1],l=a[3])}else l=r[3]?r[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(n)?o=o.slice(1):o=o.slice(1,-1)),pt(r,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:l&&l.replace(this.rules.inline.anyPunctuation,"$1")},r[0],this.lexer)}}reflink(t,r){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){const o=(n[2]||n[1]).replace(/\s+/g," "),l=r[o.toLowerCase()];if(!l){const a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return pt(n,l,n[0],this.lexer)}}emStrong(t,r,n=""){let o=this.rules.inline.emStrongLDelim.exec(t);if(!o||o[3]&&n.match(/[\p{L}\p{N}]/u))return;if(!(o[1]||o[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const a=[...o[0]].length-1;let i,c,d=a,p=0;const u=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,r=r.slice(-1*t.length+a);(o=u.exec(r))!=null;){if(i=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!i)continue;if(c=[...i].length,o[3]||o[4]){d+=c;continue}else if((o[5]||o[6])&&a%3&&!((a+c)%3)){p+=c;continue}if(d-=c,d>0)continue;c=Math.min(c,c+d+p);const y=[...o[0]][0].length,m=t.slice(0,a+o.index+y+c);if(Math.min(a,c)%2){const k=m.slice(1,-1);return{type:"em",raw:m,text:k,tokens:this.lexer.inlineTokens(k)}}const f=m.slice(2,-2);return{type:"strong",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const r=this.rules.inline.code.exec(t);if(r){let n=r[2].replace(/\n/g," ");const o=/[^ ]/.test(n),l=/^ /.test(n)&&/ $/.test(n);return o&&l&&(n=n.substring(1,n.length-1)),n=O(n,!0),{type:"codespan",raw:r[0],text:n}}}br(t){const r=this.rules.inline.br.exec(t);if(r)return{type:"br",raw:r[0]}}del(t){const r=this.rules.inline.del.exec(t);if(r)return{type:"del",raw:r[0],text:r[2],tokens:this.lexer.inlineTokens(r[2])}}autolink(t){const r=this.rules.inline.autolink.exec(t);if(r){let n,o;return r[2]==="@"?(n=O(r[1]),o="mailto:"+n):(n=O(r[1]),o=n),{type:"link",raw:r[0],text:n,href:o,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let r;if(r=this.rules.inline.url.exec(t)){let o,l;if(r[2]==="@")o=O(r[0]),l="mailto:"+o;else{let a;do a=r[0],r[0]=((n=this.rules.inline._backpedal.exec(r[0]))==null?void 0:n[0])??"";while(a!==r[0]);o=O(r[0]),r[1]==="www."?l="http://"+r[0]:l=r[0]}return{type:"link",raw:r[0],text:o,href:l,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t){const r=this.rules.inline.text.exec(t);if(r){let n;return this.lexer.state.inRawBlock?n=r[0]:n=O(r[0]),{type:"text",raw:r[0],text:n}}}}const Rr=/^(?:[ \t]*(?:\n|$))+/,Pr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Fr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ie=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Wr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ht=/(?:[*+-]|\d{1,9}[.)])/,ut=L(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,ht).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),Le=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,jr=/^[^\n]+/,Te=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Or=L(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Te).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ar=L(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ht).getRegex(),$e="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Ie=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,qr=L("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Ie).replace("tag",$e).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),mt=L(Le).replace("hr",ie).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$e).getRegex(),Me={blockquote:L(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",mt).getRegex(),code:Pr,def:Or,fences:Fr,heading:Wr,hr:ie,html:qr,lheading:ut,list:Ar,newline:Rr,paragraph:mt,table:ae,text:jr},ft=L("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ie).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$e).getRegex(),vr={...Me,table:ft,paragraph:L(Le).replace("hr",ie).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ft).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$e).getRegex()},Ur={...Me,html:L(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ie).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ae,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:L(Le).replace("hr",ie).replace("heading",` *#{1,6} *[^
156
- ]`).replace("lheading",ut).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},gt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Hr=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,bt=/^( {2,}|\\)\n(?!\s*$)/,Gr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ce="\\p{P}\\p{S}",Zr=L(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,ce).getRegex(),Qr=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Xr=L(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,ce).getRegex(),Jr=L("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,ce).getRegex(),Kr=L("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,ce).getRegex(),Yr=L(/\\([punct])/,"gu").replace(/punct/g,ce).getRegex(),en=L(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),tn=L(Ie).replace("(?:-->|$)","-->").getRegex(),sn=L("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",tn).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ee=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,rn=L(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Ee).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),yt=L(/^!?\[(label)\]\[(ref)\]/).replace("label",Ee).replace("ref",Te).getRegex(),xt=L(/^!?\[(ref)\](?:\[\])?/).replace("ref",Te).getRegex(),nn=L("reflink|nolink(?!\\()","g").replace("reflink",yt).replace("nolink",xt).getRegex(),Re={_backpedal:ae,anyPunctuation:Yr,autolink:en,blockSkip:Qr,br:bt,code:Hr,del:ae,emStrongLDelim:Xr,emStrongRDelimAst:Jr,emStrongRDelimUnd:Kr,escape:gt,link:rn,nolink:xt,punctuation:Zr,reflink:yt,reflinkSearch:nn,tag:sn,text:Gr,url:ae},on={...Re,link:L(/^!?\[(label)\]\((.*?)\)/).replace("label",Ee).getRegex(),reflink:L(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ee).getRegex()},Pe={...Re,escape:L(gt).replace("])","~|])").getRegex(),url:L(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},an={...Pe,br:L(bt).replace("{2,}","*").getRegex(),text:L(Pe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Be={normal:Me,gfm:vr,pedantic:Ur},de={normal:Re,gfm:Pe,breaks:an,pedantic:on};class A{constructor(t){I(this,"tokens");I(this,"options");I(this,"state");I(this,"tokenizer");I(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||X,this.options.tokenizer=this.options.tokenizer||new _e,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const r={block:Be.normal,inline:de.normal};this.options.pedantic?(r.block=Be.pedantic,r.inline=de.pedantic):this.options.gfm&&(r.block=Be.gfm,this.options.breaks?r.inline=de.breaks:r.inline=de.gfm),this.tokenizer.rules=r}static get rules(){return{block:Be,inline:de}}static lex(t,r){return new A(r).lex(t)}static lexInline(t,r){return new A(r).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
153
+ `,t=t.substring(w.length+1),u=g.slice(f)}}l.loose||(i?l.loose=!0:/\n[ \t]*\n[ \t]*$/.test(d)&&(i=!0));let k=null,_;this.options.gfm&&(k=/^\[[ xX]\] /.exec(p),k&&(_=k[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),l.items.push({type:"list_item",raw:d,task:!!k,checked:_,loose:!1,text:p,tokens:[]}),l.raw+=d}l.items[l.items.length-1].raw=l.items[l.items.length-1].raw.trimEnd(),l.items[l.items.length-1].text=l.items[l.items.length-1].text.trimEnd(),l.raw=l.raw.trimEnd();for(let c=0;c<l.items.length;c++)if(this.lexer.state.top=!1,l.items[c].tokens=this.lexer.blockTokens(l.items[c].text,[]),!l.loose){const d=l.items[c].tokens.filter(u=>u.type==="space"),p=d.length>0&&d.some(u=>/\n.*\n/.test(u.raw));l.loose=p}if(l.loose)for(let c=0;c<l.items.length;c++)l.items[c].loose=!0;return l}}html(t){const r=this.rules.block.html.exec(t);if(r)return{type:"html",block:!0,raw:r[0],pre:r[1]==="pre"||r[1]==="script"||r[1]==="style",text:r[0]}}def(t){const r=this.rules.block.def.exec(t);if(r){const n=r[1].toLowerCase().replace(/\s+/g," "),o=r[2]?r[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",l=r[3]?r[3].substring(1,r[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):r[3];return{type:"def",tag:n,raw:r[0],href:o,title:l}}}table(t){const r=this.rules.block.table.exec(t);if(!r||!/[:|]/.test(r[2]))return;const n=it(r[1]),o=r[2].replace(/^\||\| *$/g,"").split("|"),l=r[3]&&r[3].trim()?r[3].replace(/\n[ \t]*$/,"").split(`
154
+ `):[],a={type:"table",raw:r[0],header:[],align:[],rows:[]};if(n.length===o.length){for(const i of o)/^ *-+: *$/.test(i)?a.align.push("right"):/^ *:-+: *$/.test(i)?a.align.push("center"):/^ *:-+ *$/.test(i)?a.align.push("left"):a.align.push(null);for(let i=0;i<n.length;i++)a.header.push({text:n[i],tokens:this.lexer.inline(n[i]),header:!0,align:a.align[i]});for(const i of l)a.rows.push(it(i,a.header.length).map((c,d)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:a.align[d]})));return a}}lheading(t){const r=this.rules.block.lheading.exec(t);if(r)return{type:"heading",raw:r[0],depth:r[2].charAt(0)==="="?1:2,text:r[1],tokens:this.lexer.inline(r[1])}}paragraph(t){const r=this.rules.block.paragraph.exec(t);if(r){const n=r[1].charAt(r[1].length-1)===`
155
+ `?r[1].slice(0,-1):r[1];return{type:"paragraph",raw:r[0],text:n,tokens:this.lexer.inline(n)}}}text(t){const r=this.rules.block.text.exec(t);if(r)return{type:"text",raw:r[0],text:r[0],tokens:this.lexer.inline(r[0])}}escape(t){const r=this.rules.inline.escape.exec(t);if(r)return{type:"escape",raw:r[0],text:A(r[1])}}tag(t){const r=this.rules.inline.tag.exec(t);if(r)return!this.lexer.state.inLink&&/^<a /i.test(r[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(r[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(r[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(r[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:r[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:r[0]}}link(t){const r=this.rules.inline.link.exec(t);if(r){const n=r[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const a=ae(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{const a=Sr(r[2],"()");if(a>-1){const c=(r[0].indexOf("!")===0?5:4)+r[1].length+a;r[2]=r[2].substring(0,a),r[0]=r[0].substring(0,c).trim(),r[3]=""}}let o=r[2],l="";if(this.options.pedantic){const a=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);a&&(o=a[1],l=a[3])}else l=r[3]?r[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(n)?o=o.slice(1):o=o.slice(1,-1)),ct(r,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:l&&l.replace(this.rules.inline.anyPunctuation,"$1")},r[0],this.lexer)}}reflink(t,r){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){const o=(n[2]||n[1]).replace(/\s+/g," "),l=r[o.toLowerCase()];if(!l){const a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return ct(n,l,n[0],this.lexer)}}emStrong(t,r,n=""){let o=this.rules.inline.emStrongLDelim.exec(t);if(!o||o[3]&&n.match(/[\p{L}\p{N}]/u))return;if(!(o[1]||o[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const a=[...o[0]].length-1;let i,c,d=a,p=0;const u=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,r=r.slice(-1*t.length+a);(o=u.exec(r))!=null;){if(i=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!i)continue;if(c=[...i].length,o[3]||o[4]){d+=c;continue}else if((o[5]||o[6])&&a%3&&!((a+c)%3)){p+=c;continue}if(d-=c,d>0)continue;c=Math.min(c,c+d+p);const y=[...o[0]][0].length,m=t.slice(0,a+o.index+y+c);if(Math.min(a,c)%2){const k=m.slice(1,-1);return{type:"em",raw:m,text:k,tokens:this.lexer.inlineTokens(k)}}const f=m.slice(2,-2);return{type:"strong",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const r=this.rules.inline.code.exec(t);if(r){let n=r[2].replace(/\n/g," ");const o=/[^ ]/.test(n),l=/^ /.test(n)&&/ $/.test(n);return o&&l&&(n=n.substring(1,n.length-1)),n=A(n,!0),{type:"codespan",raw:r[0],text:n}}}br(t){const r=this.rules.inline.br.exec(t);if(r)return{type:"br",raw:r[0]}}del(t){const r=this.rules.inline.del.exec(t);if(r)return{type:"del",raw:r[0],text:r[2],tokens:this.lexer.inlineTokens(r[2])}}autolink(t){const r=this.rules.inline.autolink.exec(t);if(r){let n,o;return r[2]==="@"?(n=A(r[1]),o="mailto:"+n):(n=A(r[1]),o=n),{type:"link",raw:r[0],text:n,href:o,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let r;if(r=this.rules.inline.url.exec(t)){let o,l;if(r[2]==="@")o=A(r[0]),l="mailto:"+o;else{let a;do a=r[0],r[0]=((n=this.rules.inline._backpedal.exec(r[0]))==null?void 0:n[0])??"";while(a!==r[0]);o=A(r[0]),r[1]==="www."?l="http://"+r[0]:l=r[0]}return{type:"link",raw:r[0],text:o,href:l,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t){const r=this.rules.inline.text.exec(t);if(r){let n;return this.lexer.state.inRawBlock?n=r[0]:n=A(r[0]),{type:"text",raw:r[0],text:n}}}}const Lr=/^(?:[ \t]*(?:\n|$))+/,Tr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ir=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,le=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Mr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,dt=/(?:[*+-]|\d{1,9}[.)])/,pt=T(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,dt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),ze=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Rr=/^[^\n]+/,Le=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Pr=T(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Le).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Fr=T(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,dt).getRegex(),_e="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Te=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Wr=T("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Te).replace("tag",_e).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ht=T(ze).replace("hr",le).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_e).getRegex(),Ie={blockquote:T(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ht).getRegex(),code:Tr,def:Pr,fences:Ir,heading:Mr,hr:le,html:Wr,lheading:pt,list:Fr,newline:Lr,paragraph:ht,table:oe,text:Rr},ut=T("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",le).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_e).getRegex(),jr={...Ie,table:ut,paragraph:T(ze).replace("hr",le).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ut).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_e).getRegex()},Ar={...Ie,html:T(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Te).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:oe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:T(ze).replace("hr",le).replace("heading",` *#{1,6} *[^
156
+ ]`).replace("lheading",pt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},mt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Or=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ft=/^( {2,}|\\)\n(?!\s*$)/,qr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ie="\\p{P}\\p{S}",vr=T(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,ie).getRegex(),Ur=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Hr=T(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,ie).getRegex(),Gr=T("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,ie).getRegex(),Zr=T("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,ie).getRegex(),Qr=T(/\\([punct])/,"gu").replace(/punct/g,ie).getRegex(),Xr=T(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Jr=T(Te).replace("(?:-->|$)","-->").getRegex(),Kr=T("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Jr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),$e=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Yr=T(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",$e).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),gt=T(/^!?\[(label)\]\[(ref)\]/).replace("label",$e).replace("ref",Le).getRegex(),bt=T(/^!?\[(ref)\](?:\[\])?/).replace("ref",Le).getRegex(),en=T("reflink|nolink(?!\\()","g").replace("reflink",gt).replace("nolink",bt).getRegex(),Me={_backpedal:oe,anyPunctuation:Qr,autolink:Xr,blockSkip:Ur,br:ft,code:Or,del:oe,emStrongLDelim:Hr,emStrongRDelimAst:Gr,emStrongRDelimUnd:Zr,escape:mt,link:Yr,nolink:bt,punctuation:vr,reflink:gt,reflinkSearch:en,tag:Kr,text:qr,url:oe},tn={...Me,link:T(/^!?\[(label)\]\((.*?)\)/).replace("label",$e).getRegex(),reflink:T(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",$e).getRegex()},Re={...Me,escape:T(mt).replace("])","~|])").getRegex(),url:T(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},sn={...Re,br:T(ft).replace("{2,}","*").getRegex(),text:T(Re.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ee={normal:Ie,gfm:jr,pedantic:Ar},ce={normal:Me,gfm:Re,breaks:sn,pedantic:tn};class q{constructor(t){I(this,"tokens");I(this,"options");I(this,"state");I(this,"tokenizer");I(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||J,this.options.tokenizer=this.options.tokenizer||new we,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const r={block:Ee.normal,inline:ce.normal};this.options.pedantic?(r.block=Ee.pedantic,r.inline=ce.pedantic):this.options.gfm&&(r.block=Ee.gfm,this.options.breaks?r.inline=ce.breaks:r.inline=ce.gfm),this.tokenizer.rules=r}static get rules(){return{block:Ee,inline:ce}}static lex(t,r){return new q(r).lex(t)}static lexInline(t,r){return new q(r).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
157
157
  `),this.blockTokens(t,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){const n=this.inlineQueue[r];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,r=[],n=!1){this.options.pedantic&&(t=t.replace(/\t/g," ").replace(/^ +$/gm,""));let o,l,a;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(i=>(o=i.call({lexer:this},t,r))?(t=t.substring(o.raw.length),r.push(o),!0):!1))){if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length),o.raw.length===1&&r.length>0?r[r.length-1].raw+=`
158
158
  `:r.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length),l=r[r.length-1],l&&(l.type==="paragraph"||l.type==="text")?(l.raw+=`
159
159
  `+o.raw,l.text+=`
@@ -163,9 +163,9 @@ ${u}`:u;const y=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
163
163
  `+o.raw,l.text+=`
164
164
  `+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):r.push(o),n=a.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length),l=r[r.length-1],l&&l.type==="text"?(l.raw+=`
165
165
  `+o.raw,l.text+=`
166
- `+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):r.push(o);continue}if(t){const i="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,r}inline(t,r=[]){return this.inlineQueue.push({src:t,tokens:r}),r}inlineTokens(t,r=[]){let n,o,l,a=t,i,c,d;if(this.tokens.links){const p=Object.keys(this.tokens.links);if(p.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)p.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,i.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;t;)if(c||(d=""),c=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(p=>(n=p.call({lexer:this},t,r))?(t=t.substring(n.raw.length),r.push(n),!0):!1))){if(n=this.tokenizer.escape(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.tag(t)){t=t.substring(n.raw.length),o=r[r.length-1],o&&n.type==="text"&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):r.push(n);continue}if(n=this.tokenizer.link(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(n.raw.length),o=r[r.length-1],o&&n.type==="text"&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):r.push(n);continue}if(n=this.tokenizer.emStrong(t,a,d)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.codespan(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.br(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.del(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.autolink(t)){t=t.substring(n.raw.length),r.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(t))){t=t.substring(n.raw.length),r.push(n);continue}if(l=t,this.options.extensions&&this.options.extensions.startInline){let p=1/0;const u=t.slice(1);let y;this.options.extensions.startInline.forEach(m=>{y=m.call({lexer:this},u),typeof y=="number"&&y>=0&&(p=Math.min(p,y))}),p<1/0&&p>=0&&(l=t.substring(0,p+1))}if(n=this.tokenizer.inlineText(l)){t=t.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(d=n.raw.slice(-1)),c=!0,o=r[r.length-1],o&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):r.push(n);continue}if(t){const p="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return r}}class Ve{constructor(t){I(this,"options");I(this,"parser");this.options=t||X}space(t){return""}code({text:t,lang:r,escaped:n}){var a;const o=(a=(r||"").match(/^\S*/))==null?void 0:a[0],l=t.replace(/\n$/,"")+`
167
- `;return o?'<pre><code class="language-'+O(o)+'">'+(n?l:O(l,!0))+`</code></pre>
168
- `:"<pre><code>"+(n?l:O(l,!0))+`</code></pre>
166
+ `+o.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):r.push(o);continue}if(t){const i="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,r}inline(t,r=[]){return this.inlineQueue.push({src:t,tokens:r}),r}inlineTokens(t,r=[]){let n,o,l,a=t,i,c,d;if(this.tokens.links){const p=Object.keys(this.tokens.links);if(p.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)p.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,i.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;t;)if(c||(d=""),c=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(p=>(n=p.call({lexer:this},t,r))?(t=t.substring(n.raw.length),r.push(n),!0):!1))){if(n=this.tokenizer.escape(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.tag(t)){t=t.substring(n.raw.length),o=r[r.length-1],o&&n.type==="text"&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):r.push(n);continue}if(n=this.tokenizer.link(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(n.raw.length),o=r[r.length-1],o&&n.type==="text"&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):r.push(n);continue}if(n=this.tokenizer.emStrong(t,a,d)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.codespan(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.br(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.del(t)){t=t.substring(n.raw.length),r.push(n);continue}if(n=this.tokenizer.autolink(t)){t=t.substring(n.raw.length),r.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(t))){t=t.substring(n.raw.length),r.push(n);continue}if(l=t,this.options.extensions&&this.options.extensions.startInline){let p=1/0;const u=t.slice(1);let y;this.options.extensions.startInline.forEach(m=>{y=m.call({lexer:this},u),typeof y=="number"&&y>=0&&(p=Math.min(p,y))}),p<1/0&&p>=0&&(l=t.substring(0,p+1))}if(n=this.tokenizer.inlineText(l)){t=t.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(d=n.raw.slice(-1)),c=!0,o=r[r.length-1],o&&o.type==="text"?(o.raw+=n.raw,o.text+=n.text):r.push(n);continue}if(t){const p="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return r}}class Be{constructor(t){I(this,"options");I(this,"parser");this.options=t||J}space(t){return""}code({text:t,lang:r,escaped:n}){var a;const o=(a=(r||"").match(/^\S*/))==null?void 0:a[0],l=t.replace(/\n$/,"")+`
167
+ `;return o?'<pre><code class="language-'+A(o)+'">'+(n?l:A(l,!0))+`</code></pre>
168
+ `:"<pre><code>"+(n?l:A(l,!0))+`</code></pre>
169
169
  `}blockquote({tokens:t}){return`<blockquote>
170
170
  ${this.parser.parse(t)}</blockquote>
171
171
  `}html({text:t}){return t}heading({tokens:t,depth:r}){return`<h${r}>${this.parser.parseInline(t)}</h${r}>
@@ -181,9 +181,9 @@ ${this.parser.parse(t)}</blockquote>
181
181
  `}tablerow({text:t}){return`<tr>
182
182
  ${t}</tr>
183
183
  `}tablecell(t){const r=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+r+`</${n}>
184
- `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${t}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:r,tokens:n}){const o=this.parser.parseInline(n),l=ct(t);if(l===null)return o;t=l;let a='<a href="'+t+'"';return r&&(a+=' title="'+r+'"'),a+=">"+o+"</a>",a}image({href:t,title:r,text:n}){const o=ct(t);if(o===null)return n;t=o;let l=`<img src="${t}" alt="${n}"`;return r&&(l+=` title="${r}"`),l+=">",l}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):t.text}}class Fe{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class q{constructor(t){I(this,"options");I(this,"renderer");I(this,"textRenderer");this.options=t||X,this.options.renderer=this.options.renderer||new Ve,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Fe}static parse(t,r){return new q(r).parse(t)}static parseInline(t,r){return new q(r).parseInline(t)}parse(t,r=!0){let n="";for(let o=0;o<t.length;o++){const l=t[o];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[l.type]){const i=l,c=this.options.extensions.renderers[i.type].call({parser:this},i);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(i.type)){n+=c||"";continue}}const a=l;switch(a.type){case"space":{n+=this.renderer.space(a);continue}case"hr":{n+=this.renderer.hr(a);continue}case"heading":{n+=this.renderer.heading(a);continue}case"code":{n+=this.renderer.code(a);continue}case"table":{n+=this.renderer.table(a);continue}case"blockquote":{n+=this.renderer.blockquote(a);continue}case"list":{n+=this.renderer.list(a);continue}case"html":{n+=this.renderer.html(a);continue}case"paragraph":{n+=this.renderer.paragraph(a);continue}case"text":{let i=a,c=this.renderer.text(i);for(;o+1<t.length&&t[o+1].type==="text";)i=t[++o],c+=`
185
- `+this.renderer.text(i);r?n+=this.renderer.paragraph({type:"paragraph",raw:c,text:c,tokens:[{type:"text",raw:c,text:c}]}):n+=c;continue}default:{const i='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return n}parseInline(t,r){r=r||this.renderer;let n="";for(let o=0;o<t.length;o++){const l=t[o];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[l.type]){const i=this.options.extensions.renderers[l.type].call({parser:this},l);if(i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type)){n+=i||"";continue}}const a=l;switch(a.type){case"escape":{n+=r.text(a);break}case"html":{n+=r.html(a);break}case"link":{n+=r.link(a);break}case"image":{n+=r.image(a);break}case"strong":{n+=r.strong(a);break}case"em":{n+=r.em(a);break}case"codespan":{n+=r.codespan(a);break}case"br":{n+=r.br(a);break}case"del":{n+=r.del(a);break}case"text":{n+=r.text(a);break}default:{const i='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return n}}class pe{constructor(t){I(this,"options");I(this,"block");this.options=t||X}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?A.lex:A.lexInline}provideParser(){return this.block?q.parse:q.parseInline}}I(pe,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class ln{constructor(...t){I(this,"defaults",ze());I(this,"options",this.setOptions);I(this,"parse",this.parseMarkdown(!0));I(this,"parseInline",this.parseMarkdown(!1));I(this,"Parser",q);I(this,"Renderer",Ve);I(this,"TextRenderer",Fe);I(this,"Lexer",A);I(this,"Tokenizer",_e);I(this,"Hooks",pe);this.use(...t)}walkTokens(t,r){var o,l;let n=[];for(const a of t)switch(n=n.concat(r.call(this,a)),a.type){case"table":{const i=a;for(const c of i.header)n=n.concat(this.walkTokens(c.tokens,r));for(const c of i.rows)for(const d of c)n=n.concat(this.walkTokens(d.tokens,r));break}case"list":{const i=a;n=n.concat(this.walkTokens(i.items,r));break}default:{const i=a;(l=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&l[i.type]?this.defaults.extensions.childTokens[i.type].forEach(c=>{const d=i[c].flat(1/0);n=n.concat(this.walkTokens(d,r))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,r)))}}return n}use(...t){const r=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{const o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const a=r.renderers[l.name];a?r.renderers[l.name]=function(...i){let c=l.renderer.apply(this,i);return c===!1&&(c=a.apply(this,i)),c}:r.renderers[l.name]=l.renderer}if("tokenizer"in l){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const a=r[l.level];a?a.unshift(l.tokenizer):r[l.level]=[l.tokenizer],l.start&&(l.level==="block"?r.startBlock?r.startBlock.push(l.start):r.startBlock=[l.start]:l.level==="inline"&&(r.startInline?r.startInline.push(l.start):r.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(r.childTokens[l.name]=l.childTokens)}),o.extensions=r),n.renderer){const l=this.defaults.renderer||new Ve(this.defaults);for(const a in n.renderer){if(!(a in l))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;const i=a,c=n.renderer[i],d=l[i];l[i]=(...p)=>{let u=c.apply(l,p);return u===!1&&(u=d.apply(l,p)),u||""}}o.renderer=l}if(n.tokenizer){const l=this.defaults.tokenizer||new _e(this.defaults);for(const a in n.tokenizer){if(!(a in l))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;const i=a,c=n.tokenizer[i],d=l[i];l[i]=(...p)=>{let u=c.apply(l,p);return u===!1&&(u=d.apply(l,p)),u}}o.tokenizer=l}if(n.hooks){const l=this.defaults.hooks||new pe;for(const a in n.hooks){if(!(a in l))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;const i=a,c=n.hooks[i],d=l[i];pe.passThroughHooks.has(a)?l[i]=p=>{if(this.defaults.async)return Promise.resolve(c.call(l,p)).then(y=>d.call(l,y));const u=c.call(l,p);return d.call(l,u)}:l[i]=(...p)=>{let u=c.apply(l,p);return u===!1&&(u=d.apply(l,p)),u}}o.hooks=l}if(n.walkTokens){const l=this.defaults.walkTokens,a=n.walkTokens;o.walkTokens=function(i){let c=[];return c.push(a.call(this,i)),l&&(c=c.concat(l.call(this,i))),c}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,r){return A.lex(t,r??this.defaults)}parser(t,r){return q.parse(t,r??this.defaults)}parseMarkdown(t){return(n,o)=>{const l={...o},a={...this.defaults,...l},i=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&l.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));a.hooks&&(a.hooks.options=a,a.hooks.block=t);const c=a.hooks?a.hooks.provideLexer():t?A.lex:A.lexInline,d=a.hooks?a.hooks.provideParser():t?q.parse:q.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(n):n).then(p=>c(p,a)).then(p=>a.hooks?a.hooks.processAllTokens(p):p).then(p=>a.walkTokens?Promise.all(this.walkTokens(p,a.walkTokens)).then(()=>p):p).then(p=>d(p,a)).then(p=>a.hooks?a.hooks.postprocess(p):p).catch(i);try{a.hooks&&(n=a.hooks.preprocess(n));let p=c(n,a);a.hooks&&(p=a.hooks.processAllTokens(p)),a.walkTokens&&this.walkTokens(p,a.walkTokens);let u=d(p,a);return a.hooks&&(u=a.hooks.postprocess(u)),u}catch(p){return i(p)}}}onError(t,r){return n=>{if(n.message+=`
186
- Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An error occurred:</p><pre>"+O(n.message+"",!0)+"</pre>";return r?Promise.resolve(o):o}if(r)return Promise.reject(n);throw n}}}const J=new ln;function S(s,t){return J.parse(s,t)}S.options=S.setOptions=function(s){return J.setOptions(s),S.defaults=J.defaults,ot(S.defaults),S},S.getDefaults=ze,S.defaults=X,S.use=function(...s){return J.use(...s),S.defaults=J.defaults,ot(S.defaults),S},S.walkTokens=function(s,t){return J.walkTokens(s,t)},S.parseInline=J.parseInline,S.Parser=q,S.parser=q.parse,S.Renderer=Ve,S.TextRenderer=Fe,S.Lexer=A,S.lexer=A.lex,S.Tokenizer=_e,S.Hooks=pe,S.parse=S,S.options,S.setOptions,S.use,S.walkTokens,S.parseInline,q.parse,A.lex;const cn={class:"space-y-4"},dn={__name:"vs-editor-form-data",props:{widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object,default:()=>{}},columns:{type:Array,default:null}},emits:["update-dashboard"],setup(s,{expose:t,emit:r}){var $,w,g,E,B,C,M,U,H,Z,ue,me,fe,ge,be,P,Q,ye,At,qt,vt,Ut,Ht,Gt,Zt,Qt,Xt,Jt,Kt,Yt,es,ts,ss,rs,ns,os,as,ls;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=r,a=s,i=typeof window<"u"?new URLSearchParams(window.top.location.search):null,c=e.ref((i==null?void 0:i.get("dashboard"))||null),d=e.ref([]),p=e.computed(()=>{const D=a.columns??[];return D.length?D:d.value}),u=e.computed(()=>a.dashboardId||c.value);async function y(){if(a.columns!==null)return;const D=u.value;if(!(p.value.length||!D||!a.widgetName))try{const N=await R.get(`/bi-data?dashboard=${D}&widget=${a.widgetName}`);Array.isArray(N==null?void 0:N.columns)&&N.columns.length&&(d.value=N.columns)}catch{}}const m=D=>(D==null?void 0:D.name)!=null?{id:D.name,text:D.title||D.name}:null,f=D=>Array.isArray(D)?[...D].sort((N,G)=>{const se=N.text&&N.text!==N.id,is=G.text&&G.text!==G.id;return se&&!is?-1:!se&&is?1:(N.text||"").localeCompare(G.text||"",void 0,{sensitivity:"base"})}):D,k=e.computed(()=>{const D=(p.value??[]).filter(N=>(N==null?void 0:N.type)=="text"||(N==null?void 0:N.type)==="date"||(N==null?void 0:N.type)==="timestamp without time zone"||(N==null?void 0:N.type)==="boolean"||(N==null?void 0:N.type)==="integer").map(m).filter(Boolean);return f(D)}),_=e.computed(()=>`${a.widgetName}-${k.value.length}-${(p.value??[]).length}`),V=e.computed(()=>({text:{type:"Text",label:"Текст",conditions:["type","==","text"]},x:{type:"select",label:"Вісь X",style:{size:"xs"},conditions:["type","not_in",["text","table","map"]],options:[...k.value]},cls:{label:"Классифікатор вісі X",type:"text",conditions:["type","not_in",["text","table","map","cluster"]]},y_type:{label:"Тип вісі Y",type:"select",options:[{id:"columns",text:"columns"},{id:"function",text:"function"}],conditions:["type","not_in",["text","table","map","number","cluster"]]},tableSQL:{label:"Таблиця SQL",type:"text",hidden:!0},metric:{type:"select",label:"Вісь Y",conditions:[["type","not_in",["text","table","map","cluster"]],["y_type","!=","function"]],options:[{id:"count",text:"count"},...f(p.value.filter(D=>(D==null?void 0:D.type)==="numeric"||(D==null?void 0:D.type)==="double precision").map(m).filter(Boolean))]},fx:{type:"text",label:"Функція",conditions:[["y_type","==","function"]]},query:{label:"Запит (query)",type:"text",conditions:["type","not_in",["text","table","map","number"]]},groupby:{type:"select",label:"Групування",view:"buttons",style:{size:"xs"},options:[{id:"null",text:"null"},...f(p.value.filter(D=>(D==null?void 0:D.type)=="text"||(D==null?void 0:D.type)==="boolean"||(D==null?void 0:D.type)==="integer").map(m).filter(Boolean))],conditions:["type","==","bar"]},columns:{type:"checkbox",label:"Колонки",style:{size:"xs"},options:f((p.value??[]).map(m).filter(Boolean)),conditions:["type","in",["table","map"]]},granularity:{type:"radio",label:"Гранулярність",options:[{id:"year",text:"year"},{id:"quarter",text:"quarter"},{id:"month",text:"month"},{id:"week",text:"week"}],conditions:["x.type","==","date"]},type:{type:"Text",hidden:!0}})),x=e.ref({x:((w=($=a.data)==null?void 0:$.data)==null?void 0:w.x)||((g=a.data)==null?void 0:g.x)||null,metric:((B=(E=a.data)==null?void 0:E.data)==null?void 0:B.metric)||((C=a.data)==null?void 0:C.metric)||null,columns:((U=(M=a.data)==null?void 0:M.data)==null?void 0:U.columns)||((H=a.data)==null?void 0:H.columns)||null,granularity:((ue=(Z=a.data)==null?void 0:Z.data)==null?void 0:ue.granularity)||((me=a.data)==null?void 0:me.granularity)||null,type:((ge=(fe=a.data)==null?void 0:fe.data)==null?void 0:ge.type)||((be=a.data)==null?void 0:be.type)||null,groupby:((Q=(P=a.data)==null?void 0:P.data)==null?void 0:Q.groupby)||a.data.groupby||null,fx:((At=(ye=a.data)==null?void 0:ye.data)==null?void 0:At.fx)||((qt=a.data)==null?void 0:qt.fx)||null,query:((Ut=(vt=a.data)==null?void 0:vt.data)==null?void 0:Ut.query)||((Ht=a.data)==null?void 0:Ht.query)||null,y_type:((Zt=(Gt=a.data)==null?void 0:Gt.data)==null?void 0:Zt.y_type)||((Qt=a.data)==null?void 0:Qt.y_type)||null,tableSQL:((Jt=(Xt=a.data)==null?void 0:Xt.data)==null?void 0:Jt.tableSQL)||((Kt=a.data)==null?void 0:Kt.tableSQL)||null,cls:((es=(Yt=a.data)==null?void 0:Yt.data)==null?void 0:es.cls)||((ts=a.data)==null?void 0:ts.cls)||null,text:((rs=(ss=a.data)==null?void 0:ss.data)==null?void 0:rs.text)||((ns=a.data)==null?void 0:ns.text)||null,table:((as=(os=a.data)==null?void 0:os.data)==null?void 0:as.table)||((ls=a.data)==null?void 0:ls.table)||null}),h=async()=>{try{await R.put(`/bi-dashboard/${u.value}/${a.widgetName}`,{data:x.value});let D=`/bi-data?dashboard=${u.value}&widget=${a.widgetName}`;Object.entries(x.value).forEach(([G,se])=>{D+=`&${G}=${se}`});const N=new CustomEvent(`update-data-${a.widgetName}`);N.filterUrl=D,window.dispatchEvent(N),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}},b=async()=>{try{let D=`/bi-data?dashboard=${u.value}&widget=${a.widgetName}`;Object.entries(x.value).forEach(([G,se])=>{D+=`&${G}=${se}`});const N=new CustomEvent(`update-data-${a.widgetName}`);N.filterUrl=D,window.dispatchEvent(N),l("update-dashboard")}catch{await o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.watch(x,()=>{b()},{deep:!0}),e.watch(()=>[a.widgetName,a.dashboardId,c.value],()=>{d.value=[],y()},{immediate:!0}),t({requestUpdateWidget:h}),(D,N)=>(e.openBlock(),e.createElementBlock("div",cn,[(e.openBlock(),e.createBlock(e.unref(n),{key:_.value,schema:V.value,values:x.value,"onUpdate:values":N[0]||(N[0]=G=>x.value=G)},null,8,["schema","values"]))]))}},pn={class:"space-y-4"},hn={__name:"vs-editor-form-yaml",props:{yamlValue:{type:null,default:()=>""},widgetName:{type:String},data:{type:Object}},emits:["update-dashboard"],setup(s,{expose:t,emit:r}){const n=typeof window<"u"?window.echarts:null,o=e.defineAsyncComponent(()=>import("@opengis/form").then(m=>m.VsInputMonaco)),l=e.ref(null),{$notify:a}=e.getCurrentInstance().proxy,i=r,c=s,d=(m,{dimensions:f,source:k})=>{const _=m.getOption(),{data:V,...x}=(_==null?void 0:_.series)[0],[,...h]=f||[],b=h.map(($,w)=>({...(_==null?void 0:_.series[w])||{},data:k.map(g=>g[w+1]),name:$}));m==null||m.setOption({..._||{},dataset:{dimensions:f,source:k},series:b,xAxis:{type:"category"},yAxis:{}},!0)},p=m=>{const f=document.getElementById(m);if(!f)return null;const k=n==null?void 0:n.getInstanceByDom(f);return k||null},u=e.ref(c.yamlValue),y=async()=>{try{await R.put(`/bi-dashboard/${l.value}/${c.widgetName}`,{yml:u.value});const m=p(c.widgetName);if(m){const f=await R.get(`/bi-data?dashboard=${l.value}&widget=${c.widgetName}`);d(m,f)}i("update-dashboard"),a({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{a({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const m=new URLSearchParams(window.top.location.search);l.value=m.get("dashboard")}),t({requestUpdateWidget:y}),(m,f)=>(e.openBlock(),e.createElementBlock("div",pn,[e.createVNode(e.unref(o),{modelValue:u.value,"onUpdate:modelValue":f[0]||(f[0]=k=>u.value=k),syntax:"yaml",theme:"vs-light",height:400,minimap:!1},null,8,["modelValue"])]))}},un={class:"pt-[10px]"},kt={"vs-editor-form-style":Nr,"vs-editor-form-data":dn,"vs-editor-form-yaml":hn,"vs-editor-form-controls":{__name:"vs-editor-form-controls",props:{widgetName:{type:String},controls:{type:Object,default:()=>{}},columns:{type:Array,default:()=>[]}},emits:["update-dashboard"],setup(s,{emit:t}){var p;const r=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:n}=e.getCurrentInstance().proxy,o=t,l=s,a=e.ref(null),i={granularity:{ua:"Granularity",type:"checkbox",options:["week","month","quarter","year"]},export:{ua:"Export",type:"Switcher"},groupby:{ua:"Groupby",type:"checkbox",options:(p=l.columns)==null?void 0:p.map(({name:u})=>u)}},c=e.ref(l.controls||{}),d=async()=>{try{await R.put(`/bi-dashboard/${a.value}/${l.widgetName}`,{controls:c.value}),await n({type:"success",title:"Успішно!",message:"Дані успішно оновлено"}),staticTypes!=null&&staticTypes.includes(c.value.type)&&o("update-dashboard")}catch{await n({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const u=new URLSearchParams(window.top.location.search);a.value=u.get("dashboard")}),(u,y)=>{const m=e.resolveComponent("VsButton");return e.openBlock(),e.createElementBlock("div",un,[e.createVNode(m,{class:"ml-[10px] mb-[10px]",type:"plain",onClick:d},{default:e.withCtx(()=>[...y[1]||(y[1]=[e.createTextVNode(" Зберегти ",-1)])]),_:1}),e.createVNode(e.unref(r),{schema:i,values:c.value,"onUpdate:values":y[0]||(y[0]=f=>c.value=f)},null,8,["values"])])}}}},mn={key:0,class:"p-4 text-sm text-amber-700 bg-amber-50 rounded-lg"},wt={__name:"editor-tab-error-boundary",props:{tabComponent:{type:Object,default:null},tabKey:{type:[String,Number],default:""}},emits:["update-dashboard"],setup(s,{expose:t}){const r=s,n=e.ref(null);function o(){var a,i;(i=(a=n.value)==null?void 0:a.requestUpdateWidget)==null||i.call(a)}t({save:o});const l=e.ref(!1);return e.onErrorCaptured((a,i,c)=>(console.error("Editor tab error:",a,c),l.value=!0,!1)),e.watch(()=>r.tabComponent,()=>{l.value=!1},{immediate:!0}),(a,i)=>l.value?(e.openBlock(),e.createElementBlock("div",mn," Помилка завантаження вмісту. Переключіть таб або оновіть сторінку. ")):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.tabComponent),e.mergeProps({ref_key:"tabRef",ref:n,key:s.tabKey||"tab"},a.$attrs,{onUpdateDashboard:i[0]||(i[0]=c=>a.$emit("update-dashboard"))}),null,16))}},fn={class:"h-full flex flex-col bg-white shrink-0 !w-[400px] border rounded-xl overflow-hidden border-gray-200"},gn={key:0,class:"flex flex-col min-h-0 flex-1"},bn={class:"flex items-center border-b border-gray-200 bg-white shrink-0 px-4 h-[49px]"},yn={class:"flex items-center gap-6 min-w-0 -mb-[14px]"},xn=["onClick"],kn={key:0,class:"absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 rounded-full"},wn={class:"flex items-center gap-1 ml-auto shrink-0"},_n={key:1,class:"flex-1 min-h-0 overflow-auto px-4 py-4 [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-stone-100 [&::-webkit-scrollbar-thumb]:bg-stone-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},$n={key:0},En={key:1},Bn={class:"p-4"},Vn={class:"flex justify-end mt-4 gap-x-3"},Dn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},Cn={__name:"vs-editor-forms",props:e.mergeModels({selectedWidgetData:{type:Object,required:!1,default:null},selectedDashboard:{type:String,default:()=>""},currentWidgetData:{type:String,default:()=>""}},{selectedWidget:{},selectedWidgetModifiers:{}}),emits:e.mergeModels(["update-data"],["update:selectedWidget"]),setup(s,{emit:t}){var b,$;const r=e.defineAsyncComponent(()=>import("@opengis/form")),n=($=(b=e.getCurrentInstance())==null?void 0:b.proxy)==null?void 0:$.$notify,o=ee(),l=t,a=e.ref(null),i=s,c=e.ref(!1),d=e.ref(!0),p=e.ref(!1),u=e.ref({}),y=e.useModel(s,"selectedWidget"),m=["table","text","number","stat","progress","listbar","map","pivot"],f=e.ref("data"),k=async()=>{try{await R.delete(`/bi-dashboard/${i.selectedDashboard}/${i.selectedWidgetData.name}`),o.hasRoute(W.EditorDashboard)?o.push({name:W.EditorDashboard,params:{dashboardId:i.selectedDashboard}}):y.value="",l("update-data"),c.value=!1,n({type:"success",title:"Успішно!",message:"Віджет успішно видалено"})}catch(w){console.error(w),n({type:"error",title:"Помилка!",message:"При спробі видалити віджет виникла помилка"})}},_=e.computed(()=>{const w=[{id:"data",label:"Дані"},{id:"style",label:"Стилі"},{id:"yaml",label:"{ }"}];return w==null?void 0:w.filter(g=>{var E,B,C;return g.id==="style"?!(m!=null&&m.includes(((E=i.selectedWidgetData)==null?void 0:E.type)||((C=(B=i.selectedWidgetData)==null?void 0:B.data)==null?void 0:C.type))):!0})}),V=()=>{var w,g,E,B,C,M,U,H,Z;u.value={title:(w=i.selectedWidgetData)==null?void 0:w.title,type:(g=i.selectedWidgetData)==null?void 0:g.type,table:(E=i.selectedWidgetData)==null?void 0:E.table_name,query:(C=(B=i.selectedWidgetData)==null?void 0:B.data)==null?void 0:C.query,x:(U=(M=i.selectedWidgetData)==null?void 0:M.data)==null?void 0:U.x,cls:(Z=(H=i.selectedWidgetData)==null?void 0:H.data)==null?void 0:Z.cls},p.value=!0},x=async()=>{try{await R.put(`/bi-dashboard/${i.selectedDashboard}/${i.selectedWidgetData.name}`,u.value),n({type:"success",title:"Успішно!",message:"Дані успішно змінено"}),await l("update-data"),p.value=!1}catch{n({type:"error",title:"Помилка!",message:"При спробі внести зміни виникла помилка"})}};e.watch(y,()=>{d.value=!1,setTimeout(()=>d.value=!0)});const h={title:{type:"text",ua:"Заголовок",placeholder:"Заголовок",validators:["required"]},type:{type:"select",view:"buttons",label:"Тип віджета",validators:["required"],options:[{label:"Bar",id:"bar"},{label:"Funnel",id:"funnel"},{label:"Line",id:"line"},{label:"List bar",id:"listbar"},{label:"Number",id:"number"},{label:"Pie",id:"pie"},{label:"Donut",id:"donut"},{label:"Pivot",id:"pivot"},{label:"Table",id:"table"},{label:"Progress",id:"progress"},{label:"Stat",id:"stat"},{label:"Text",id:"text"},{label:"Map",id:"map"}]},table:{type:"text",ua:"Таблиця",placeholder:"Таблиця"},query:{type:"Text",ua:"Запит (query)",placeholder:"Query"},x:{type:"Text",ua:"Вісь X",placeholder:"X Axis"},cls:{type:"Text",ua:"Клас (cls)",placeholder:"Cls"}};return(w,g)=>{var B,C,M,U,H,Z,ue,me,fe,ge,be;const E=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",fn,[s.selectedWidgetData?(e.openBlock(),e.createElementBlock("div",gn,[e.createElementVNode("div",bn,[e.createElementVNode("nav",yn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,P=>(e.openBlock(),e.createElementBlock("button",{key:P.id,type:"button",class:e.normalizeClass(["relative pb-3 pt-1 text-sm font-medium transition-colors whitespace-nowrap",f.value===P.id?"text-blue-600":"text-gray-600 hover:text-gray-900"]),onClick:Q=>f.value=P.id},[e.createTextVNode(e.toDisplayString(P.label)+" ",1),f.value===P.id?(e.openBlock(),e.createElementBlock("span",kn)):e.createCommentVNode("",!0)],10,xn))),128))]),e.createElementVNode("div",wn,[e.createVNode(E,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"h-8 w-8 flex items-center justify-center rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors",title:"Зберегти",onClick:g[0]||(g[0]=P=>{var Q,ye;return(ye=(Q=a.value)==null?void 0:Q.save)==null?void 0:ye.call(Q)})},[e.createVNode(e.unref(Es),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[g[9]||(g[9]=e.createTextVNode(" Зберегти ",-1))]),_:1}),e.createVNode(E,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"h-8 w-8 flex items-center justify-center rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors",onClick:V},[e.createVNode(nt,{class:"h-4 w-4"})])]),default:e.withCtx(()=>[g[10]||(g[10]=e.createTextVNode(" Редагувати віджет ",-1))]),_:1}),e.createVNode(E,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"h-8 w-8 flex items-center justify-center rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors",onClick:g[1]||(g[1]=P=>c.value=!0)},[e.createVNode(e.unref(rt),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[g[11]||(g[11]=e.createTextVNode(" Видалити віджет ",-1))]),_:1})])]),(B=s.currentWidgetData)!=null&&B.status?(e.openBlock(),e.createBlock(we,{key:0,title:(C=s.currentWidgetData)==null?void 0:C.title,text:(M=s.currentWidgetData)==null?void 0:M.message},null,8,["title","text"])):(e.openBlock(),e.createElementBlock("div",_n,[d.value&&s.currentWidgetData?(e.openBlock(),e.createElementBlock("div",$n,[e.createVNode(wt,{ref_key:"tabPanelRef",ref:a,"tab-key":f.value,"tab-component":e.unref(kt)["vs-editor-form-"+f.value],widgetName:(U=s.selectedWidgetData)==null?void 0:U.name,dashboardId:s.selectedDashboard,yamlValue:((H=s.selectedWidgetData)==null?void 0:H.yml)||"",data:s.selectedWidgetData,controls:(Z=s.selectedWidgetData)==null?void 0:Z.controls,columns:(ue=s.currentWidgetData)==null?void 0:ue.columns,onUpdateDashboard:g[2]||(g[2]=P=>w.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])):(e.openBlock(),e.createElementBlock("div",En,[e.createVNode(wt,{ref_key:"tabPanelRef",ref:a,"tab-key":f.value,"tab-component":e.unref(kt)["vs-editor-form-"+f.value],widgetName:(me=s.selectedWidgetData)==null?void 0:me.name,dashboardId:s.selectedDashboard,yamlValue:((fe=s.selectedWidgetData)==null?void 0:fe.yml)||"",data:s.selectedWidgetData,controls:(ge=s.selectedWidgetData)==null?void 0:ge.controls,columns:(be=s.currentWidgetData)==null?void 0:be.columns,onUpdateDashboard:g[3]||(g[3]=P=>w.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])),e.createVNode(oe,{teleport:"#modal",visible:c.value,title:"Ви впевнені?",onClose:g[5]||(g[5]=P=>c.value=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",Bn,[g[12]||(g[12]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей віджет? ",-1)),e.createElementVNode("div",Vn,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-medium text-gray-800 bg-white border border-gray-200 rounded-lg shadow-sm gap-x-2 hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:g[4]||(g[4]=P=>c.value=!1)}," Скасувати "),e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-semibold text-white bg-red-500 border border-transparent rounded-lg gap-x-2 hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:k}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"])]))])):(e.openBlock(),e.createBlock(we,{key:1,title:"Оберіть один з віджетів",text:"",class:"p-4"}))]),e.createVNode(oe,{teleport:"#modal",visible:p.value,title:"Редагувати віджет",onClose:g[8]||(g[8]=P=>p.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Dn,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:g[7]||(g[7]=P=>p.value=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:x,class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[h?(e.openBlock(),e.createBlock(e.unref(r),{key:0,schema:h,values:u.value,"onUpdate:values":g[6]||(g[6]=P=>u.value=P)},null,8,["values"])):e.createCommentVNode("",!0)]),_:1},8,["visible"])],64)}}},Nn={class:"overflow-hidden flex flex-col min-h-[480px]"},Sn={class:"flex-1 flex min-h-0 gap-4"},zn={class:"flex-1 min-w-0 pb-4 overflow-auto bg-gray-50/50"},Ln={key:1,class:"flex items-center justify-center h-full"},Tn={class:"w-[400px] shrink-0 flex flex-col"},In={__name:"vs-widget-editor-panel",props:{selectedWidget:{type:String,default:""},selectedWidgetData:{type:Object,default:null},currentWidgetData:{type:Object,default:null},selectedDashboard:{type:String,default:""},dashboardWidgets:{type:Array,default:()=>[]}},emits:["update:selectedWidget","update-data"],setup(s,{emit:t}){const r=s,n=t,o=e.ref(null);async function l(){if(!(!r.selectedDashboard||!r.selectedWidget))try{o.value=await R.get(`/bi-data?dashboard=${r.selectedDashboard}&widget=${r.selectedWidget}`)}catch(c){console.error(c)}}function a(){n("update-data")}e.watch(()=>[r.selectedDashboard,r.selectedWidget],()=>{l()},{immediate:!0});const i=e.computed({get:()=>r.selectedWidget,set:c=>n("update:selectedWidget",c)});return(c,d)=>(e.openBlock(),e.createElementBlock("div",Nn,[e.createElementVNode("div",Sn,[e.createElementVNode("div",zn,[o.value?(e.openBlock(),e.createBlock(ne,{key:0,dashboard:s.selectedDashboard,widget:s.selectedWidget,"selected-widget":s.selectedWidget,"dashboard-widgets":s.dashboardWidgets,"prefetched-data":o.value,"filter-u-rl":void 0,class:"max-h-full"},null,8,["dashboard","widget","selected-widget","dashboard-widgets","prefetched-data"])):(e.openBlock(),e.createElementBlock("div",Ln,[...d[1]||(d[1]=[e.createElementVNode("span",{class:"text-sm text-gray-400"},"Завантаження...",-1)])]))]),e.createElementVNode("div",Tn,[e.createVNode(Cn,{selectedWidget:i.value,"onUpdate:selectedWidget":d[0]||(d[0]=p=>i.value=p),selectedWidgetData:s.selectedWidgetData,currentWidgetData:o.value||s.currentWidgetData||{columns:[]},selectedDashboard:s.selectedDashboard,onUpdateData:a},null,8,["selectedWidget","selectedWidgetData","currentWidgetData","selectedDashboard"])])])]))}},_t={__name:"icon-grid",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ks),e.mergeProps(t.$attrs,{size:24}),null,16))}},$t={__name:"icon-table",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Bs),e.mergeProps(t.$attrs,{size:24}),null,16))}},Mn={__name:"icon-more",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(fs),e.mergeProps(t.$attrs,{size:24}),null,16))}},Rn=e.defineAsyncComponent(()=>import("@opengis/form")),Pn={components:{VsModal:oe,VForm:Rn,deleteIcon:rt,editIcon:nt,IconGrid:_t,IconMore:Mn,IconTable:$t},watch:{dashboardData:{handler(s){var r,n;if(this.formEditValue={title:s==null?void 0:s.title,description:s==null?void 0:s.description,table_name:s==null?void 0:s.table_name,db:s==null?void 0:s.db,public:s==null?void 0:s.public,words:s==null?void 0:s.words},!((r=s==null?void 0:s.panels)!=null&&r.length)){this.formGridValue={panels:[]};return}const t=(n=s==null?void 0:s.panels)==null?void 0:n.map(o=>{var i,c;const{title:l="",type:a=""}=((c=(i=s==null?void 0:s.widgets)==null?void 0:i.find(d=>(d==null?void 0:d.name)===(o==null?void 0:o.widget)))==null?void 0:c.data)||{};return{title:l,type:a,...o}});this.formGridValue={panels:t}},immediate:!0}},data(){return{isDeleteConfirm:!1,isFormEdit:!1,isFormGrid:!1,isVisibleTableColumns:!1,formEditValue:{},formGridValue:{},editDashboardScheme:[{type:"Text",key:"title",label:"Заголовок",validators:["required"]},{type:"Text",key:"description",label:"Опис"},{type:"Text",key:"table_name",validators:["required"],label:"Назва таблиці"},{type:"Text",key:"words",label:"Ключові слова"},{type:"Text",key:"db",label:"База даних",original:{type:"Text",ua:"Назва",col:8}},{type:"Switcher",key:"public",label:"Публічний",original:{type:"Text",ua:"Назва",col:8}}],editGridScheme:[{type:"DataTable",ua:"Панелі",key:"panels",actions:["search"],editable:!1,addition:!1,colModel:[{name:"title",ua:"Назва",type:"Text",key:"title"},{name:"type",ua:"Тип",type:"Text",key:"type",disabled:!0},{name:"widget",type:"Text",ua:"Віджет",key:"widget",hiddenCol:!0,disabled:!0},{name:"col",ua:"Кількість стовпчиків",type:"Text",key:"col"},{name:"height",ua:"Висота",type:"Text",key:"height"},{name:"category",ua:"Категорія",type:"Text",key:"category"}]}]}},props:{selected:{type:String,default:()=>""},dashboardData:{type:Object,default:()=>{}},selectedWidgetData:{type:Object,default:()=>{}},columns:{type:Array}},methods:{async editDashboard(){var s,t;try{const r=(t=(s=this.$refs)==null?void 0:s.formEdit)==null?void 0:t.validate();typeof r=="function"&&await r(),await R.put(`/bi-dashboard/${this.selected}`,this.formEditValue),await this.$notify({title:"Успішно!",type:"success",message:"Дані успішно оновлено"}),this.isFormEdit=!1,await this.$emit("update-editor")}catch{this.$notify({title:"Помилка!",type:"error",message:"при спробі оновити дані виникла помилка"})}},async editDashboardGrid(){var s,t;try{(t=(s=this.$refs)==null?void 0:s.formGrid)==null||t.doValidation(),await R.put(`/bi-dashboard/${this.selected}`,{...this.formEditValue,...this.formGridValue}),await this.$notify({title:"Успішно!",type:"success",message:"Дані успішно оновлено"}),this.isFormGrid=!1,await this.$emit("update-editor")}catch{this.$notify({title:"Помилка!",type:"error",message:"При спробі оновити дані виникла помилка"})}},async deleteDashboard(){try{await R.delete(`/bi-dashboard/${this.selected}`),this.isDeleteConfirm=!1,this.$emit("update:selected",""),this.$emit("update-editor"),this.$notify({title:"Успішно!",type:"success",message:"Дашборд видалено успішно"})}catch{this.$notify({title:"Помилка!",type:"error",message:"При спробі видалити дашборд виникла помилка"})}},closePopover(){document.body.click()}}},Fn={key:0,class:"flex items-center gap-4"},Wn={class:"h-[30px] w-[30px] flex items-center justify-center"},jn={class:"flex flex-col items-start -ml-2 -mr-2"},On={class:"p-4"},An={class:"flex justify-end mt-4 gap-x-3"},qn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},vn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"};function Un(s,t,r,n,o,l){const a=e.resolveComponent("IconGrid"),i=e.resolveComponent("VsPopover"),c=e.resolveComponent("IconMore"),d=e.resolveComponent("VsModal"),p=e.resolveComponent("VForm");return e.openBlock(),e.createElementBlock("div",null,[r.selected?(e.openBlock(),e.createElementBlock("div",Fn,[e.createVNode(i,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{class:"h-[30px] w-[30px] flex items-center justify-center",onClick:t[0]||(t[0]=u=>o.isFormGrid=!0)},[e.createVNode(a,{class:"h-[20px] text-gray-500"})])]),default:e.withCtx(()=>[t[14]||(t[14]=e.createTextVNode(" Редагувати структуру дашборду ",-1))]),_:1}),e.createVNode(i,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createVNode(i,{placement:"bottom-left"},{reference:e.withCtx(()=>[e.createElementVNode("button",Wn,[e.createVNode(c,{class:"h-[20px]"})])]),default:e.withCtx(()=>[e.createElementVNode("div",jn,[e.createElementVNode("button",{onClick:t[1]||(t[1]=u=>{l.closePopover(),o.isFormEdit=!0}),class:"px-[8px] py-[4px] hover:bg-gray-100 w-full text-start rounded-lg"}," Редагувати дашборд "),e.createElementVNode("button",{onClick:t[2]||(t[2]=u=>{l.closePopover(),o.isDeleteConfirm=!0}),class:"px-[8px] py-[4px] hover:bg-gray-100 w-full text-start rounded-lg"}," Видалити дашборд ")])]),_:1})]),default:e.withCtx(()=>[t[15]||(t[15]=e.createTextVNode(" Керування дашбордом ",-1))]),_:1})])):e.createCommentVNode("",!0),e.createVNode(d,{teleport:"#modal",visible:o.isDeleteConfirm,size:"small",title:"Ви впевнені?",onClose:t[5]||(t[5]=u=>o.isDeleteConfirm=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",On,[t[16]||(t[16]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей дашборд? ",-1)),e.createElementVNode("div",An,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-medium text-gray-800 bg-white border border-gray-200 rounded-lg shadow-sm gap-x-2 hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:t[3]||(t[3]=u=>o.isDeleteConfirm=!1)}," Скасувати "),e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-semibold text-white bg-red-500 border border-transparent rounded-lg gap-x-2 hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:t[4]||(t[4]=(...u)=>l.deleteDashboard&&l.deleteDashboard(...u))}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"]),e.createVNode(d,{teleport:"#modal",visible:o.isFormEdit,title:"Редагувати дашборд",onClose:t[9]||(t[9]=u=>o.isFormEdit=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",qn,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:t[7]||(t[7]=u=>o.isFormEdit=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:t[8]||(t[8]=(...u)=>l.editDashboard&&l.editDashboard(...u)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(p,{ref:"formEdit",schema:o.editDashboardScheme,values:o.formEditValue,"onUpdate:values":t[6]||(t[6]=u=>o.formEditValue=u)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createVNode(d,{teleport:"#modal",visible:o.isFormGrid,title:"Редагувати структуру дашборду",onClose:t[13]||(t[13]=u=>o.isFormGrid=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",vn,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:t[11]||(t[11]=u=>o.isFormGrid=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:t[12]||(t[12]=(...u)=>l.editDashboardGrid&&l.editDashboardGrid(...u)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(p,{ref:"formgrid",schema:o.editGridScheme,values:o.formGridValue,"onUpdate:values":t[10]||(t[10]=u=>o.formGridValue=u)},null,8,["schema","values"])]),_:1},8,["visible"])])}const Hn=z(Pn,[["render",Un]]),Gn={class:"flex-1 min-w-0 flex flex-col overflow-auto"},Zn={class:"max-w-7xl mx-auto px-6 w-full flex flex-col min-h-0 flex-1"},Qn={class:"relative z-10 shrink-0 mt-4 mb-6"},Xn={class:"flex items-center text-sm text-gray-600"},Jn={key:0,class:"flex items-center justify-between gap-4 mt-3"},Kn={class:"min-w-0"},Yn={class:"text-2xl font-bold text-gray-900"},eo={key:0,class:"mt-1.5 text-sm text-gray-600"},to={class:"flex items-center shrink-0"},so={key:1,class:"grid flex-grow w-full grid-cols-12 gap-4 py-4 pr-[15px] min-h-0 overflow-auto [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-stone-100 [&::-webkit-scrollbar-thumb]:bg-stone-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},ro=z({__name:"vs-editor",props:{prefix:String,customClass:{type:String,default:()=>"w-screen h-screen"},initialDashboardId:{type:String,default:""},initialWidgetId:{type:String,default:""}},emits:["back"],setup(s,{emit:t}){const r=s;xe(r.prefix||"/api");const n=t,o=ee(),l=e.computed(()=>o.hasRoute(W.EditorWidget)),a=e.inject("biClearDashboard",null),i=e.ref(r.initialDashboardId||""),c=e.ref(r.initialWidgetId||""),d=e.ref(null),p=e.ref(null),u=e.ref(null);e.watch(()=>r.initialWidgetId,x=>{c.value=x||""});const y=async()=>{if(!i.value){d.value=null;return}try{const x=await R.get(`/bi-dashboard/${i.value}`);d.value=x}catch(x){console.error(x)}},m=e.computed(()=>{var x,h,b;return(b=Array.isArray((x=d.value)==null?void 0:x.widgets)?(h=d.value)==null?void 0:h.widgets:[])==null?void 0:b.find($=>($==null?void 0:$.name)===c.value)});function f(x){l.value?o.push({name:W.EditorWidget,params:{dashboardId:i.value,widgetId:x}}):c.value=x}function k(){l.value?o.push({name:W.EditorDashboard,params:{dashboardId:i.value}}):c.value=""}function _(){l.value?o.push({name:W.Editor}):(typeof a=="function"&&a(),n("back"))}const V=e.computed(()=>{var b,$,w,g,E;const h=[l.value?{label:"Дашборди",to:{name:W.Editor}}:{label:"Дашборди",onClick:_}];if((b=d.value)!=null&&b.title||i.value){const B=(($=d.value)==null?void 0:$.title)||i.value||"Редактор";!!c.value?h.push(l.value?{label:B,to:{name:W.EditorDashboard,params:{dashboardId:i.value}}}:{label:B,onClick:()=>{c.value=""}}):h.push({label:B})}else h.push({label:"Редактор"});if(c.value&&m.value){const B=((g=(w=m.value)==null?void 0:w.data)==null?void 0:g.title)||((E=m.value)==null?void 0:E.title)||c.value;h.push({label:B})}return h});return e.watch(i,(x,h)=>{h&&(c.value=""),x?y():(d.value=null,_())}),e.onMounted(()=>{y()}),(x,h)=>{var b,$;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex w-full h-full",[s.customClass]])},[e.createElementVNode("div",Gn,[e.createElementVNode("div",Zn,[e.createElementVNode("div",Qn,[e.createElementVNode("div",Xn,[e.createVNode(et,{items:V.value,compact:""},null,8,["items"])]),i.value&&d.value?(e.openBlock(),e.createElementBlock("div",Jn,[e.createElementVNode("div",Kn,[e.createElementVNode("h1",Yn,e.toDisplayString(d.value.title||i.value),1),d.value.description?(e.openBlock(),e.createElementBlock("p",eo,e.toDisplayString(d.value.description),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",to,[c.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors",onClick:k},[e.createVNode(e.unref(Xe),{class:"w-4 h-4"}),h[5]||(h[5]=e.createTextVNode(" Закрити ",-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(Hn,{selected:i.value,"onUpdate:selected":h[0]||(h[0]=w=>i.value=w),dashboardData:d.value,columns:(b=d.value)==null?void 0:b.columns,selectedWidgetData:m.value,prefix:s.prefix,onUpdateEditor:y},null,8,["selected","dashboardData","columns","selectedWidgetData","prefix"]),e.createElementVNode("button",{type:"button",class:"ml-4 flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors shadow-sm font-medium",onClick:h[1]||(h[1]=w=>{var g,E;return(E=(g=u.value)==null?void 0:g.open)==null?void 0:E.call(g)})},[...h[6]||(h[6]=[e.createElementVNode("span",{class:"leading-none"},"+",-1),e.createTextVNode(" Створити віджет ",-1)])]),i.value?(e.openBlock(),e.createBlock(Dr,{key:0,ref_key:"createWidgetRef",ref:u,inline:"",columns:($=d.value)==null?void 0:$.columns,selectedDashboard:i.value,onUpdateData:y},null,8,["columns","selectedDashboard"])):e.createCommentVNode("",!0)],64))])])):e.createCommentVNode("",!0)]),c.value&&d.value?(e.openBlock(),e.createBlock(In,{key:0,"selected-widget":c.value,"onUpdate:selectedWidget":h[2]||(h[2]=w=>c.value=w),"selected-widget-data":m.value,"current-widget-data":p.value,"selected-dashboard":i.value,"dashboard-widgets":d.value.widgets||[],onUpdateData:y},null,8,["selected-widget","selected-widget-data","current-widget-data","selected-dashboard","dashboard-widgets"])):(e.openBlock(),e.createElementBlock("div",so,[d.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(d.value.panels,(w,g)=>{var E;return e.openBlock(),e.createElementBlock("div",{key:g,class:e.normalizeClass([`md:col-span-${w.col||12} col-span-12`,"flex flex-col gap-[10px]"])},[(E=w.widgets)!=null&&E.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(w.widgets,B=>(e.openBlock(),e.createBlock(ne,{onClick:C=>f(B),"onUpdate:currentWidgetData":h[3]||(h[3]=C=>p.value=C),key:B,dashboard:i.value,widget:B,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(w.height??480),class:e.normalizeClass({"border border-blue-500":c.value===B})},null,8,["onClick","dashboard","widget","selectedWidget","dashboard-widgets","height","class"]))),128)):(e.openBlock(),e.createBlock(ne,{key:1,onClick:B=>f(w.widget),"onUpdate:currentWidgetData":h[4]||(h[4]=B=>p.value=B),class:e.normalizeClass(["flex flex-col",{"border border-blue-500":c.value===w.widget}]),dashboard:i.value,widget:w.widget,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(w.height??480)},null,8,["onClick","class","dashboard","widget","selectedWidget","dashboard-widgets","height"]))],2)}),128)):(e.openBlock(),e.createBlock(we,{key:0,class:"col-span-12"}))]))])])],2)}}},[["__scopeId","data-v-f586e5b0"]]),no={class:"w-full h-screen"},Et=e.defineComponent({__name:"vs-editor-page",props:{prefix:{default:"/api"},dashboardId:{default:""},widgetId:{default:""}},emits:["back"],setup(s){return(t,r)=>(e.openBlock(),e.createElementBlock("div",no,[e.createVNode(ro,{customClass:"h-full w-full",prefix:s.prefix,"initial-dashboard-id":s.dashboardId,"initial-widget-id":s.widgetId,onBack:r[0]||(r[0]=n=>t.$emit("back"))},null,8,["prefix","initial-dashboard-id","initial-widget-id"])]))}}),oo={class:"relative group h-full"},ao={class:"flex items-start gap-3 flex-1 min-h-0"},lo={class:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors shrink-0"},io={class:"flex-1 min-w-0 flex flex-col min-h-0"},co={class:"font-semibold text-gray-900 mb-1 truncate"},po={key:0,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10"},ho={key:1,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10 invisible","aria-hidden":"true"},uo={key:2,class:"text-sm text-gray-400 mt-1 shrink-0"},mo=z({__name:"dashboard-card",props:{title:String,description:String,modified:String,name:String,widgetCount:Number,reserveLines:Number,dashboardRouteName:String,onOpenEditor:Function},setup(s){const t=s,r=ee(),n=e.ref(!1);function o(){t.dashboardRouteName&&(r.hasRoute(W.EditorDashboard)?r.push({name:W.EditorDashboard,params:{dashboardId:t.dashboardRouteName}}):t.onOpenEditor?t.onOpenEditor(t.dashboardRouteName):r.push({path:"/editor",query:{dashboard:t.dashboardRouteName}}))}function l(a){a.target.closest(".dashboard-card-menu")||(n.value=!1)}return e.onMounted(()=>document.addEventListener("click",l)),e.onUnmounted(()=>document.removeEventListener("click",l)),(a,i)=>(e.openBlock(),e.createElementBlock("div",oo,[e.createElementVNode("button",{type:"button",class:"w-full h-full bg-white border border-gray-200 rounded-lg p-6 hover:shadow-md hover:border-blue-200 transition-all text-left animate-fade-in flex flex-col",onClick:o},[e.createElementVNode("div",ao,[e.createElementVNode("div",lo,[e.createVNode(e.unref(xs),{size:24,class:"w-5 h-5 text-blue-600"})]),e.createElementVNode("div",io,[e.createElementVNode("h3",co,e.toDisplayString(s.title),1),s.description?(e.openBlock(),e.createElementBlock("p",po,e.toDisplayString(s.description),1)):(e.openBlock(),e.createElementBlock("p",ho,"   ")),s.widgetCount!=null?(e.openBlock(),e.createElementBlock("p",uo,e.toDisplayString(s.widgetCount)+" віджетів ",1)):e.createCommentVNode("",!0)])])])]))}},[["__scopeId","data-v-716ced89"]]),fo=[{type:"Text",key:"name",label:"Назва",validators:["required"],original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"title",label:"Заголовок",validators:["required"],original:{type:"Text",ua:"Титул",col:8}},{type:"Text",key:"description",label:"Опис",original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"words",label:"Ключові слова",original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"table_name",validators:["required"],label:"Назва таблиці",original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"db",label:"База даних",original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"category",label:"Категорія",original:{type:"Text",ua:"Категорія",col:8}},{type:"Switcher",key:"public",label:"Публічний",original:{type:"Text",ua:"Назва",col:8}}];function go(s){return!Array.isArray(s)||s.length===0?{}:s.reduce((t,r)=>{if(!r||r.key==null)return t;const{key:n,...o}=r;return t[n]=o,t},{})}const bo={class:"flex-1 bg-gray-50"},yo={class:"max-w-7xl mx-auto px-6 py-8"},xo={class:"mb-6"},ko={class:"flex items-center justify-between mb-6"},wo={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},_o={class:"flex items-center space-x-4"},$o={class:"flex-1 relative"},Eo={key:0,class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},Bo={key:1,class:"flex flex-col items-center justify-center py-20 text-center"},Vo={class:"mt-1 text-sm text-gray-400"},Do={class:"font-medium text-gray-500"},Bt=e.defineComponent({__name:"all-dashboards-page",props:{prefix:{}},setup(s){const t=e.defineAsyncComponent(()=>import("@opengis/form")),r=go(fo),n=e.ref([]),o=e.ref([]),l=ee(),a=e.inject("biSetDashboard",void 0),i=s,c=e.ref(null),d=e.ref(!1),p=e.ref({}),u=e.ref(""),y=e.computed(()=>{const h=u.value.trim().toLowerCase();return h?n.value.filter(b=>b.title.toLowerCase().includes(h)):n.value});async function m(){try{const h=await R.get("/bi-dashboard?type=db"),b=Array.isArray(h==null?void 0:h.rows)?h.rows:[];o.value=b,n.value=b.map($=>({routeName:String($.name??""),title:$.title??$.name??"Без назви",description:$.description??null,modified:"-",name:"-"}))}catch(h){console.error("Failed to load dashboards",h),o.value=[],n.value=[]}}async function f(){var b,$,w;const h=($=(b=e.getCurrentInstance())==null?void 0:b.proxy)==null?void 0:$.$notify;try{const g=(w=c.value)==null?void 0:w.validate();typeof g=="function"&&await g();const{name:E,title:B,table_name:C}=p.value;if(!E||!B||!C){h==null||h({type:"error",title:"Помилка!",message:"Заповніть усі обов'язкові поля"});return}await R.post("/bi-dashboard",p.value),d.value=!1,p.value={},h==null||h({type:"success",title:"Успішно!",message:"Дашборд створено успішно"}),l.hasRoute(W.EditorDashboard)?l.push({name:W.EditorDashboard,params:{dashboardId:E}}):a?a(E):await m()}catch{h==null||h({type:"error",title:"Помилка!",message:"При спробі створити дашборд виникла помилка"})}}e.onMounted(()=>{xe(i.prefix||"/api"),m()});const k=e.ref(1),_=()=>{const h=window.innerWidth;k.value=h>=1024?3:h>=768?2:1};e.onMounted(()=>{_(),window.addEventListener("resize",_)}),e.onUnmounted(()=>{window.removeEventListener("resize",_)});const V=h=>h?h.trim().length>70?2:1:0,x=h=>{const b=k.value||1,w=Math.floor(h/b)*b,g=w+b,E=y.value.slice(w,g);let B=0;for(const C of E){const M=V(C.description??null);if(M>B&&(B=M),B===2)break}return B};return e.ref("grid"),(h,b)=>(e.openBlock(),e.createElementBlock("div",bo,[e.createElementVNode("div",yo,[e.createElementVNode("div",xo,[e.createElementVNode("div",ko,[b[6]||(b[6]=e.createElementVNode("div",null,[e.createElementVNode("h1",{class:"text-3xl font-bold text-gray-900"},"Дашборди"),e.createElementVNode("p",{class:"mt-2 text-gray-600"}," Керуйте та переглядайте свої аналітичні дашборди ")],-1)),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 px-4 py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors shadow-sm font-medium",onClick:b[0]||(b[0]=$=>d.value=!0)},[e.createVNode(e.unref(Ze),{size:24,class:"w-4 h-4"}),b[5]||(b[5]=e.createElementVNode("span",null,"Новий дашборд",-1))])]),e.createVNode(oe,{teleport:"#modal",visible:d.value,title:"Створити дашборд",onClose:b[3]||(b[3]=$=>d.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",wo,[e.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border border-gray-200 rounded-lg hover:bg-gray-100 duration-300",onClick:b[2]||(b[2]=$=>d.value=!1)}," Скасувати "),e.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg hover:bg-blue-700 duration-300",onClick:f}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(e.unref(t),{ref_key:"createFormRef",ref:c,schema:e.unref(r),values:p.value,"onUpdate:values":b[1]||(b[1]=$=>p.value=$)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createElementVNode("div",_o,[e.createElementVNode("div",$o,[e.createVNode(e.unref(Qe),{size:24,class:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[4]||(b[4]=$=>u.value=$),type:"text",placeholder:"Пошук дашбордів...",class:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"},null,512),[[e.vModelText,u.value]])])])]),y.value.length?(e.openBlock(),e.createElementBlock("div",Eo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,($,w)=>(e.openBlock(),e.createElementBlock("div",{key:$.routeName,class:"cursor-pointer h-full"},[e.createVNode(mo,{title:$.title,description:$.description,modified:$.modified,name:$.name,reserveLines:x(w),"dashboard-route-name":$.routeName,"on-open-editor":e.unref(a)},null,8,["title","description","modified","name","reserveLines","dashboard-route-name","on-open-editor"])]))),128))])):(e.openBlock(),e.createElementBlock("div",Bo,[e.createVNode(e.unref(Qe),{size:48,class:"text-gray-300 mb-4"}),b[9]||(b[9]=e.createElementVNode("p",{class:"text-lg font-medium text-gray-500"},"Дашбордів не знайдено",-1)),e.createElementVNode("p",Vo,[b[7]||(b[7]=e.createTextVNode(" За запитом «",-1)),e.createElementVNode("span",Do,e.toDisplayString(u.value),1),b[8]||(b[8]=e.createTextVNode("» нічого не знайдено. Спробуйте змінити пошуковий запит. ",-1))])]))])]))}}),Co=e.defineComponent({__name:"editor-root-page",props:{prefix:{default:"/api"}},setup(s){const t=s,r=e.computed(()=>t.prefix),n=ee(),o=dr(),l=e.computed(()=>n.hasRoute(W.EditorDashboard)),a=e.ref("");e.onMounted(()=>{var c;if(!l.value){const d=(c=o==null?void 0:o.query)==null?void 0:c.dashboard;d!=null&&typeof d=="string"&&(a.value=d.trim())}});const i=e.computed(()=>a.value.length>0);return e.provide("biSetDashboard",c=>{a.value=c||""}),e.provide("biClearDashboard",()=>{a.value=""}),e.provide("biSelectedDashboardId",e.readonly(a)),(c,d)=>{const p=e.resolveComponent("router-view");return l.value?(e.openBlock(),e.createBlock(p,{key:0})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[i.value?(e.openBlock(),e.createBlock(Et,{key:`editor-${a.value}`,prefix:r.value,"dashboard-id":a.value,onBack:d[0]||(d[0]=u=>a.value="")},null,8,["prefix","dashboard-id"])):(e.openBlock(),e.createBlock(Bt,{key:0,prefix:r.value},null,8,["prefix"]))],64))}}});function v(s,t){const r=s&&typeof s=="object"&&"value"in s?s.value:s;if(r==null)return"";const n=Number(r);return Number.isNaN(n)?String(r):new Intl.NumberFormat("en",t??{notation:"compact"}).format(n)}function he(s){if(!(s!=null&&s.includes("T")))return s??"";const[t,r,n]=s.split("T")[0].split("-");return`${n}.${r}.${t}`}function No(s){return Intl.NumberFormat("en").format(s??0)}class So{static getTooltipOptions(t=!0){return{show:t,confine:!0,appendToBody:!1,axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}}}}const zo={show_label:!1,show_legend:!1,label:null,legend:{position:null},colors:null,color:null,title:null};function Lo(){const s="0123456789ABCDEF";let t="#";for(let r=0;r<6;r+=1)t+=s[Math.floor(Math.random()*16)];return t}function K(s=zo){var r,n,o;const t={label:{show:((r=s==null?void 0:s.label)==null?void 0:r.show)??(s==null?void 0:s.show_label)??!1,formatter:(s==null?void 0:s.formatter)??(l=>v(l)),...(s==null?void 0:s.label)||{}},legend:{...(s==null?void 0:s.legend)||{},[((n=s==null?void 0:s.legend)==null?void 0:n.position)||"bottom"]:"0",show:((o=s==null?void 0:s.legend)==null?void 0:o.show)??(s==null?void 0:s.show_legend)??!1},barWidth:"70%",grid:{borderColor:"#e5e7eb"},title:{...(s==null?void 0:s.title)||{}}};return(s!=null&&s.colors||s!=null&&s.color)&&(t.color=(s==null?void 0:s.colors)||(s==null?void 0:s.color)||null),t}function Vt(s){return{color:"#9ca3af",fontSize:10,fontFamily:"Inter, ui-sans-serif, system-ui",fontWeight:400,label:s==null?void 0:s.label,show:!0,formatter:(s==null?void 0:s.formatter)??(t=>v(t)),margin:(s==null?void 0:s.margin)??7,interval:(s==null?void 0:s.interval)??"auto",rotate:(s==null?void 0:s.rotate)??0}}const Dt=["#d3c7e6","#bedae3","#f8e9cb","#ff8c8c","#c5d8be","#ffc6c6","#ffc39a","#fff7c5","#d8ffc0","#d4f7ff"];class De{static getLabelOptions(t={}){return{show:(t==null?void 0:t.show_label)||(t==null?void 0:t.show)||!1,fontSize:"10",position:(t==null?void 0:t.position)||"inside",formatter:(t==null?void 0:t.formatter)||"{d}%",...t}}static getLegendOpions(t={}){return{...t,position:(t==null?void 0:t.position)||"bottom"}}}const te=typeof window<"u"?window.echarts:null,j={props:["source","style","widget","dashboard","title","currentWidget","widgetData","prefix","prefetchedData"],data(){return{sourceData:null,styleData:null,widgetName:"",dimensions:[],dashboardName:"",titleCharts:"",widgetInstance:null}},mounted(){window.addEventListener("resize",this.handleResize),window.addEventListener(`update-data-${this.widget}`,this.checkCustomEvent),window.addEventListener(`update-style-${this.widget}`,this.checkCustomStyleEvent)},unmounted(){window.removeEventListener(`update-data-${this.widget}`,this.checkCustomEvent),window.removeEventListener(`update-style-${this.widget}`,this.checkCustomStyleEvent)},watch:{sourceData:{async handler(){setTimeout(()=>{this==null||this.onChangedData()},0)}}},methods:{checkCustomStyleEvent(s){this.changeOptionsByName(s.chartId,s.options)},checkCustomEvent({filterUrl:s}){this.getDataFromURL(s)},handleResize(){this.widgetInstance&&this.widgetInstance.resize()},async getDataFromURL(s){try{const t=await R.get(s);this.applyResponse(t)}catch(t){const r={message:"Дані не знайдено",title:"Помилка!",type:"error",status:400,id:this.widgetName};(t==null?void 0:t.status)=="404"&&(r.status=404,r.message="Дані не знайдено"),(t==null?void 0:t.status)=="400"&&(r.message="Перевірте налаштування або зверніться до адміністратора"),(t==null?void 0:t.status)=="500"&&(r.message="Сталася помилка сервера"),this.$emit("update:widgetData",r)}},getValues(){return this.sourceData.map(s=>{var t;return parseFloat(s[(t=this.columns)==null?void 0:t[1]])})},formatDate(s){const t=new Date(s);if(isNaN(t))return s;const r=String(t.getDate()).padStart(2,"0"),o=["січня","лютого","березня","квітня","травня","червня","липня","серпня","вересня","жовтня","листопада","грудня"][t.getMonth()],l=t.getFullYear();return`${r} ${o} ${l}`},applyResponse(s){var t;this.sourceData=(s==null?void 0:s.source)||[],this.$emit("update:widgetData",s),this.dimensions=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{}),this.titleCharts=this.style?this.style:(s==null?void 0:s.title)||"",this.styleData=(s==null?void 0:s.style)||{}},async getData(){var s;try{if(this.source)this.sourceData=[...this.source],this.styleData=this.style,this.titleCharts=this.title,this.dimensions=Object.keys(((s=this.sourceData)==null?void 0:s[0])||{});else if(this.prefetchedData)this.widgetName=this.widget,this.dashboardName=this.dashboard,this.applyResponse(this.prefetchedData);else{this.widgetName=this.widget,this.dashboardName=this.dashboard;const t=this.dashboardName?`${this.prefix||""}/bi-data?dashboard=${this.dashboardName}&widget=${this.widgetName}`:`${this.prefix||""}/bi-data?&widget=${this.widgetName}`;await this.getDataFromURL(t)}}catch(t){console.error(t)}},async initChart(s,t,r){var n,o,l,a,i,c,d,p,u;this.widgetInstance&&this.widgetInstance.clear();try{const y=this.$refs.chart,m=te==null?void 0:te.init(y);if(!m)return;const f={tooltip:{show:((o=(n=this.styleData)==null?void 0:n.tooltip)==null?void 0:o.show)!==!1,trigger:"axis",confine:!0,appendToBody:!1,axisPointer:{type:"shadow"},backgroundColor:"transparent",shadowColor:"transparent",padding:[0,0,0,0],borderWidth:0,position:(k,_,V,x,h)=>{const[b,$]=k,[w,g]=h.contentSize,[E,B]=h.viewSize;let C=b+14,M=$-g/2;return C+w>E&&(C=b-w-14),C<0&&(C=0),M+g>B&&(M=B-g),M<0&&(M=0),[C,M]},formatter:k=>{var g;const V=(g=k[0])==null?void 0:g.axisValue,x=V?this.formatDate(V):"N/A",h=[...k].filter(E=>{var B;return parseFloat(E==null?void 0:E.data)||((B=E==null?void 0:E.data)==null?void 0:B.value)}).sort((E,B)=>{var U,H;const C=parseFloat(((U=E==null?void 0:E.data)==null?void 0:U.value)??(E==null?void 0:E.data))||0;return(parseFloat(((H=B==null?void 0:B.data)==null?void 0:H.value)??(B==null?void 0:B.data))||0)-C}),b=h.slice(0,8),$=h.length-b.length;let w=`
184
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${t}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:r,tokens:n}){const o=this.parser.parseInline(n),l=lt(t);if(l===null)return o;t=l;let a='<a href="'+t+'"';return r&&(a+=' title="'+r+'"'),a+=">"+o+"</a>",a}image({href:t,title:r,text:n}){const o=lt(t);if(o===null)return n;t=o;let l=`<img src="${t}" alt="${n}"`;return r&&(l+=` title="${r}"`),l+=">",l}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):t.text}}class Pe{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class v{constructor(t){I(this,"options");I(this,"renderer");I(this,"textRenderer");this.options=t||J,this.options.renderer=this.options.renderer||new Be,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Pe}static parse(t,r){return new v(r).parse(t)}static parseInline(t,r){return new v(r).parseInline(t)}parse(t,r=!0){let n="";for(let o=0;o<t.length;o++){const l=t[o];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[l.type]){const i=l,c=this.options.extensions.renderers[i.type].call({parser:this},i);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(i.type)){n+=c||"";continue}}const a=l;switch(a.type){case"space":{n+=this.renderer.space(a);continue}case"hr":{n+=this.renderer.hr(a);continue}case"heading":{n+=this.renderer.heading(a);continue}case"code":{n+=this.renderer.code(a);continue}case"table":{n+=this.renderer.table(a);continue}case"blockquote":{n+=this.renderer.blockquote(a);continue}case"list":{n+=this.renderer.list(a);continue}case"html":{n+=this.renderer.html(a);continue}case"paragraph":{n+=this.renderer.paragraph(a);continue}case"text":{let i=a,c=this.renderer.text(i);for(;o+1<t.length&&t[o+1].type==="text";)i=t[++o],c+=`
185
+ `+this.renderer.text(i);r?n+=this.renderer.paragraph({type:"paragraph",raw:c,text:c,tokens:[{type:"text",raw:c,text:c}]}):n+=c;continue}default:{const i='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return n}parseInline(t,r){r=r||this.renderer;let n="";for(let o=0;o<t.length;o++){const l=t[o];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[l.type]){const i=this.options.extensions.renderers[l.type].call({parser:this},l);if(i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type)){n+=i||"";continue}}const a=l;switch(a.type){case"escape":{n+=r.text(a);break}case"html":{n+=r.html(a);break}case"link":{n+=r.link(a);break}case"image":{n+=r.image(a);break}case"strong":{n+=r.strong(a);break}case"em":{n+=r.em(a);break}case"codespan":{n+=r.codespan(a);break}case"br":{n+=r.br(a);break}case"del":{n+=r.del(a);break}case"text":{n+=r.text(a);break}default:{const i='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return n}}class de{constructor(t){I(this,"options");I(this,"block");this.options=t||J}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?q.lex:q.lexInline}provideParser(){return this.block?v.parse:v.parseInline}}I(de,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class rn{constructor(...t){I(this,"defaults",Se());I(this,"options",this.setOptions);I(this,"parse",this.parseMarkdown(!0));I(this,"parseInline",this.parseMarkdown(!1));I(this,"Parser",v);I(this,"Renderer",Be);I(this,"TextRenderer",Pe);I(this,"Lexer",q);I(this,"Tokenizer",we);I(this,"Hooks",de);this.use(...t)}walkTokens(t,r){var o,l;let n=[];for(const a of t)switch(n=n.concat(r.call(this,a)),a.type){case"table":{const i=a;for(const c of i.header)n=n.concat(this.walkTokens(c.tokens,r));for(const c of i.rows)for(const d of c)n=n.concat(this.walkTokens(d.tokens,r));break}case"list":{const i=a;n=n.concat(this.walkTokens(i.items,r));break}default:{const i=a;(l=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&l[i.type]?this.defaults.extensions.childTokens[i.type].forEach(c=>{const d=i[c].flat(1/0);n=n.concat(this.walkTokens(d,r))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,r)))}}return n}use(...t){const r=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{const o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const a=r.renderers[l.name];a?r.renderers[l.name]=function(...i){let c=l.renderer.apply(this,i);return c===!1&&(c=a.apply(this,i)),c}:r.renderers[l.name]=l.renderer}if("tokenizer"in l){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const a=r[l.level];a?a.unshift(l.tokenizer):r[l.level]=[l.tokenizer],l.start&&(l.level==="block"?r.startBlock?r.startBlock.push(l.start):r.startBlock=[l.start]:l.level==="inline"&&(r.startInline?r.startInline.push(l.start):r.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(r.childTokens[l.name]=l.childTokens)}),o.extensions=r),n.renderer){const l=this.defaults.renderer||new Be(this.defaults);for(const a in n.renderer){if(!(a in l))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;const i=a,c=n.renderer[i],d=l[i];l[i]=(...p)=>{let u=c.apply(l,p);return u===!1&&(u=d.apply(l,p)),u||""}}o.renderer=l}if(n.tokenizer){const l=this.defaults.tokenizer||new we(this.defaults);for(const a in n.tokenizer){if(!(a in l))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;const i=a,c=n.tokenizer[i],d=l[i];l[i]=(...p)=>{let u=c.apply(l,p);return u===!1&&(u=d.apply(l,p)),u}}o.tokenizer=l}if(n.hooks){const l=this.defaults.hooks||new de;for(const a in n.hooks){if(!(a in l))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;const i=a,c=n.hooks[i],d=l[i];de.passThroughHooks.has(a)?l[i]=p=>{if(this.defaults.async)return Promise.resolve(c.call(l,p)).then(y=>d.call(l,y));const u=c.call(l,p);return d.call(l,u)}:l[i]=(...p)=>{let u=c.apply(l,p);return u===!1&&(u=d.apply(l,p)),u}}o.hooks=l}if(n.walkTokens){const l=this.defaults.walkTokens,a=n.walkTokens;o.walkTokens=function(i){let c=[];return c.push(a.call(this,i)),l&&(c=c.concat(l.call(this,i))),c}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,r){return q.lex(t,r??this.defaults)}parser(t,r){return v.parse(t,r??this.defaults)}parseMarkdown(t){return(n,o)=>{const l={...o},a={...this.defaults,...l},i=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&l.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));a.hooks&&(a.hooks.options=a,a.hooks.block=t);const c=a.hooks?a.hooks.provideLexer():t?q.lex:q.lexInline,d=a.hooks?a.hooks.provideParser():t?v.parse:v.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(n):n).then(p=>c(p,a)).then(p=>a.hooks?a.hooks.processAllTokens(p):p).then(p=>a.walkTokens?Promise.all(this.walkTokens(p,a.walkTokens)).then(()=>p):p).then(p=>d(p,a)).then(p=>a.hooks?a.hooks.postprocess(p):p).catch(i);try{a.hooks&&(n=a.hooks.preprocess(n));let p=c(n,a);a.hooks&&(p=a.hooks.processAllTokens(p)),a.walkTokens&&this.walkTokens(p,a.walkTokens);let u=d(p,a);return a.hooks&&(u=a.hooks.postprocess(u)),u}catch(p){return i(p)}}}onError(t,r){return n=>{if(n.message+=`
186
+ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An error occurred:</p><pre>"+A(n.message+"",!0)+"</pre>";return r?Promise.resolve(o):o}if(r)return Promise.reject(n);throw n}}}const K=new rn;function S(s,t){return K.parse(s,t)}S.options=S.setOptions=function(s){return K.setOptions(s),S.defaults=K.defaults,rt(S.defaults),S},S.getDefaults=Se,S.defaults=J,S.use=function(...s){return K.use(...s),S.defaults=K.defaults,rt(S.defaults),S},S.walkTokens=function(s,t){return K.walkTokens(s,t)},S.parseInline=K.parseInline,S.Parser=v,S.parser=v.parse,S.Renderer=Be,S.TextRenderer=Pe,S.Lexer=q,S.lexer=q.lex,S.Tokenizer=we,S.Hooks=de,S.parse=S,S.options,S.setOptions,S.use,S.walkTokens,S.parseInline,v.parse,q.lex;const nn={class:"space-y-4"},on={__name:"vs-editor-form-data",props:{widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object,default:()=>{}},columns:{type:Array,default:null}},emits:["update-dashboard"],setup(s,{expose:t,emit:r}){var $,w,g,E,B,C,M,H,G,Q,he,ue,me,fe,ge,P,X,be,jt,At,Ot,qt,vt,Ut,Ht,Gt,Zt,Qt,Xt,Jt,Kt,Yt,es,ts,ss,rs,ns,os;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=r,a=s,i=typeof window<"u"?new URLSearchParams(window.top.location.search):null,c=e.ref((i==null?void 0:i.get("dashboard"))||null),d=e.ref([]),p=e.computed(()=>{const D=a.columns??[];return D.length?D:d.value}),u=e.computed(()=>a.dashboardId||c.value);async function y(){if(a.columns!==null)return;const D=u.value;if(!(p.value.length||!D||!a.widgetName))try{const N=await R.get(`/bi-data?dashboard=${D}&widget=${a.widgetName}`);Array.isArray(N==null?void 0:N.columns)&&N.columns.length&&(d.value=N.columns)}catch{}}const m=D=>(D==null?void 0:D.name)!=null?{id:D.name,text:D.title||D.name}:null,f=D=>Array.isArray(D)?[...D].sort((N,Z)=>{const te=N.text&&N.text!==N.id,as=Z.text&&Z.text!==Z.id;return te&&!as?-1:!te&&as?1:(N.text||"").localeCompare(Z.text||"",void 0,{sensitivity:"base"})}):D,k=e.computed(()=>{const D=(p.value??[]).filter(N=>(N==null?void 0:N.type)=="text"||(N==null?void 0:N.type)==="date"||(N==null?void 0:N.type)==="timestamp without time zone"||(N==null?void 0:N.type)==="boolean"||(N==null?void 0:N.type)==="integer").map(m).filter(Boolean);return f(D)}),_=e.computed(()=>`${a.widgetName}-${k.value.length}-${(p.value??[]).length}`),V=e.computed(()=>({text:{type:"Text",label:"Текст",conditions:["type","==","text"]},x:{type:"select",label:"Вісь X",style:{size:"xs"},conditions:["type","not_in",["text","table","map"]],options:[...k.value]},cls:{label:"Классифікатор вісі X",type:"text",conditions:["type","not_in",["text","table","map","cluster"]]},y_type:{label:"Тип вісі Y",type:"select",options:[{id:"columns",text:"columns"},{id:"function",text:"function"}],conditions:["type","not_in",["text","table","map","number","cluster"]]},tableSQL:{label:"Таблиця SQL",type:"text",hidden:!0},metric:{type:"select",label:"Вісь Y",conditions:[["type","not_in",["text","table","map","cluster"]],["y_type","!=","function"]],options:[{id:"count",text:"count"},...f(p.value.filter(D=>(D==null?void 0:D.type)==="numeric"||(D==null?void 0:D.type)==="double precision").map(m).filter(Boolean))]},fx:{type:"text",label:"Функція",conditions:[["y_type","==","function"]]},query:{label:"Запит (query)",type:"text",conditions:["type","not_in",["text","table","map","number"]]},groupby:{type:"select",label:"Групування",view:"buttons",style:{size:"xs"},options:[{id:"null",text:"null"},...f(p.value.filter(D=>(D==null?void 0:D.type)=="text"||(D==null?void 0:D.type)==="boolean"||(D==null?void 0:D.type)==="integer").map(m).filter(Boolean))],conditions:["type","==","bar"]},columns:{type:"checkbox",label:"Колонки",style:{size:"xs"},options:f((p.value??[]).map(m).filter(Boolean)),conditions:["type","in",["table","map"]]},granularity:{type:"radio",label:"Гранулярність",options:[{id:"year",text:"year"},{id:"quarter",text:"quarter"},{id:"month",text:"month"},{id:"week",text:"week"}],conditions:["x.type","==","date"]},type:{type:"Text",hidden:!0}})),x=e.ref({x:((w=($=a.data)==null?void 0:$.data)==null?void 0:w.x)||((g=a.data)==null?void 0:g.x)||null,metric:((B=(E=a.data)==null?void 0:E.data)==null?void 0:B.metric)||((C=a.data)==null?void 0:C.metric)||null,columns:((H=(M=a.data)==null?void 0:M.data)==null?void 0:H.columns)||((G=a.data)==null?void 0:G.columns)||null,granularity:((he=(Q=a.data)==null?void 0:Q.data)==null?void 0:he.granularity)||((ue=a.data)==null?void 0:ue.granularity)||null,type:((fe=(me=a.data)==null?void 0:me.data)==null?void 0:fe.type)||((ge=a.data)==null?void 0:ge.type)||null,groupby:((X=(P=a.data)==null?void 0:P.data)==null?void 0:X.groupby)||a.data.groupby||null,fx:((jt=(be=a.data)==null?void 0:be.data)==null?void 0:jt.fx)||((At=a.data)==null?void 0:At.fx)||null,query:((qt=(Ot=a.data)==null?void 0:Ot.data)==null?void 0:qt.query)||((vt=a.data)==null?void 0:vt.query)||null,y_type:((Ht=(Ut=a.data)==null?void 0:Ut.data)==null?void 0:Ht.y_type)||((Gt=a.data)==null?void 0:Gt.y_type)||null,tableSQL:((Qt=(Zt=a.data)==null?void 0:Zt.data)==null?void 0:Qt.tableSQL)||((Xt=a.data)==null?void 0:Xt.tableSQL)||null,cls:((Kt=(Jt=a.data)==null?void 0:Jt.data)==null?void 0:Kt.cls)||((Yt=a.data)==null?void 0:Yt.cls)||null,text:((ts=(es=a.data)==null?void 0:es.data)==null?void 0:ts.text)||((ss=a.data)==null?void 0:ss.text)||null,table:((ns=(rs=a.data)==null?void 0:rs.data)==null?void 0:ns.table)||((os=a.data)==null?void 0:os.table)||null}),h=async()=>{try{await R.put(`/bi-dashboard/${u.value}/${a.widgetName}`,{data:x.value});let D=`/bi-data?dashboard=${u.value}&widget=${a.widgetName}`;Object.entries(x.value).forEach(([Z,te])=>{D+=`&${Z}=${te}`});const N=new CustomEvent(`update-data-${a.widgetName}`);N.filterUrl=D,window.dispatchEvent(N),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}},b=async()=>{try{let D=`/bi-data?dashboard=${u.value}&widget=${a.widgetName}`;Object.entries(x.value).forEach(([Z,te])=>{D+=`&${Z}=${te}`});const N=new CustomEvent(`update-data-${a.widgetName}`);N.filterUrl=D,window.dispatchEvent(N),l("update-dashboard")}catch{await o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.watch(x,()=>{b()},{deep:!0}),e.watch(()=>[a.widgetName,a.dashboardId,c.value],()=>{d.value=[],y()},{immediate:!0}),t({requestUpdateWidget:h}),(D,N)=>(e.openBlock(),e.createElementBlock("div",nn,[(e.openBlock(),e.createBlock(e.unref(n),{key:_.value,schema:V.value,values:x.value,"onUpdate:values":N[0]||(N[0]=Z=>x.value=Z)},null,8,["schema","values"]))]))}},an={class:"space-y-4"},ln={__name:"vs-editor-form-yaml",props:{yamlValue:{type:null,default:()=>""},widgetName:{type:String},data:{type:Object}},emits:["update-dashboard"],setup(s,{expose:t,emit:r}){const n=typeof window<"u"?window.echarts:null,o=e.defineAsyncComponent(()=>import("@opengis/form").then(m=>m.VsInputMonaco)),l=e.ref(null),{$notify:a}=e.getCurrentInstance().proxy,i=r,c=s,d=(m,{dimensions:f,source:k})=>{const _=m.getOption(),{data:V,...x}=(_==null?void 0:_.series)[0],[,...h]=f||[],b=h.map(($,w)=>({...(_==null?void 0:_.series[w])||{},data:k.map(g=>g[w+1]),name:$}));m==null||m.setOption({..._||{},dataset:{dimensions:f,source:k},series:b,xAxis:{type:"category"},yAxis:{}},!0)},p=m=>{const f=document.getElementById(m);if(!f)return null;const k=n==null?void 0:n.getInstanceByDom(f);return k||null},u=e.ref(c.yamlValue),y=async()=>{try{await R.put(`/bi-dashboard/${l.value}/${c.widgetName}`,{yml:u.value});const m=p(c.widgetName);if(m){const f=await R.get(`/bi-data?dashboard=${l.value}&widget=${c.widgetName}`);d(m,f)}i("update-dashboard"),a({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{a({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const m=new URLSearchParams(window.top.location.search);l.value=m.get("dashboard")}),t({requestUpdateWidget:y}),(m,f)=>(e.openBlock(),e.createElementBlock("div",an,[e.createVNode(e.unref(o),{modelValue:u.value,"onUpdate:modelValue":f[0]||(f[0]=k=>u.value=k),syntax:"yaml",theme:"vs-light",height:400,minimap:!1},null,8,["modelValue"])]))}},cn={class:"pt-[10px]"},yt={"vs-editor-form-style":Br,"vs-editor-form-data":on,"vs-editor-form-yaml":ln,"vs-editor-form-controls":{__name:"vs-editor-form-controls",props:{widgetName:{type:String},controls:{type:Object,default:()=>{}},columns:{type:Array,default:()=>[]}},emits:["update-dashboard"],setup(s,{emit:t}){var p;const r=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:n}=e.getCurrentInstance().proxy,o=t,l=s,a=e.ref(null),i={granularity:{ua:"Granularity",type:"checkbox",options:["week","month","quarter","year"]},export:{ua:"Export",type:"Switcher"},groupby:{ua:"Groupby",type:"checkbox",options:(p=l.columns)==null?void 0:p.map(({name:u})=>u)}},c=e.ref(l.controls||{}),d=async()=>{try{await R.put(`/bi-dashboard/${a.value}/${l.widgetName}`,{controls:c.value}),await n({type:"success",title:"Успішно!",message:"Дані успішно оновлено"}),staticTypes!=null&&staticTypes.includes(c.value.type)&&o("update-dashboard")}catch{await n({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const u=new URLSearchParams(window.top.location.search);a.value=u.get("dashboard")}),(u,y)=>{const m=e.resolveComponent("VsButton");return e.openBlock(),e.createElementBlock("div",cn,[e.createVNode(m,{class:"ml-[10px] mb-[10px]",type:"plain",onClick:d},{default:e.withCtx(()=>[...y[1]||(y[1]=[e.createTextVNode(" Зберегти ",-1)])]),_:1}),e.createVNode(e.unref(r),{schema:i,values:c.value,"onUpdate:values":y[0]||(y[0]=f=>c.value=f)},null,8,["values"])])}}}},dn={key:0,class:"p-4 text-sm text-amber-700 bg-amber-50 rounded-lg"},xt={__name:"editor-tab-error-boundary",props:{tabComponent:{type:Object,default:null},tabKey:{type:[String,Number],default:""}},emits:["update-dashboard"],setup(s,{expose:t}){const r=s,n=e.ref(null);function o(){var a,i;(i=(a=n.value)==null?void 0:a.requestUpdateWidget)==null||i.call(a)}t({save:o});const l=e.ref(!1);return e.onErrorCaptured((a,i,c)=>(console.error("Editor tab error:",a,c),l.value=!0,!1)),e.watch(()=>r.tabComponent,()=>{l.value=!1},{immediate:!0}),(a,i)=>l.value?(e.openBlock(),e.createElementBlock("div",dn," Помилка завантаження вмісту. Переключіть таб або оновіть сторінку. ")):(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.tabComponent),e.mergeProps({ref_key:"tabRef",ref:n,key:s.tabKey||"tab"},a.$attrs,{onUpdateDashboard:i[0]||(i[0]=c=>a.$emit("update-dashboard"))}),null,16))}},pn={class:"h-full flex flex-col bg-white shrink-0 !w-[400px] border rounded-xl overflow-hidden border-gray-200"},hn={key:0,class:"flex flex-col min-h-0 flex-1"},un={class:"flex items-center border-b border-gray-200 bg-white shrink-0 px-4 h-[49px]"},mn={class:"flex items-center gap-6 min-w-0 -mb-[14px]"},fn=["onClick"],gn={key:0,class:"absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 rounded-full"},bn={class:"flex items-center gap-1 ml-auto shrink-0"},yn={key:1,class:"flex-1 min-h-0 overflow-auto px-4 py-4 [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-stone-100 [&::-webkit-scrollbar-thumb]:bg-stone-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},xn={key:0},kn={key:1},wn={class:"p-4"},_n={class:"flex justify-end mt-4 gap-x-3"},$n={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},En={__name:"vs-editor-forms",props:e.mergeModels({selectedWidgetData:{type:Object,required:!1,default:null},selectedDashboard:{type:String,default:()=>""},currentWidgetData:{type:String,default:()=>""}},{selectedWidget:{},selectedWidgetModifiers:{}}),emits:e.mergeModels(["update-data"],["update:selectedWidget"]),setup(s,{emit:t}){var b,$;const r=e.defineAsyncComponent(()=>import("@opengis/form")),n=($=(b=e.getCurrentInstance())==null?void 0:b.proxy)==null?void 0:$.$notify,o=O.useRouter(),l=t,a=e.ref(null),i=s,c=e.ref(!1),d=e.ref(!0),p=e.ref(!1),u=e.ref({}),y=e.useModel(s,"selectedWidget"),m=["table","text","number","stat","progress","listbar","map","pivot"],f=e.ref("data"),k=async()=>{try{await R.delete(`/bi-dashboard/${i.selectedDashboard}/${i.selectedWidgetData.name}`),o.hasRoute(W.EditorDashboard)?o.push({name:W.EditorDashboard,params:{dashboardId:i.selectedDashboard}}):y.value="",l("update-data"),c.value=!1,n({type:"success",title:"Успішно!",message:"Віджет успішно видалено"})}catch(w){console.error(w),n({type:"error",title:"Помилка!",message:"При спробі видалити віджет виникла помилка"})}},_=e.computed(()=>{const w=[{id:"data",label:"Дані"},{id:"style",label:"Стилі"},{id:"yaml",label:"{ }"}];return w==null?void 0:w.filter(g=>{var E,B,C;return g.id==="style"?!(m!=null&&m.includes(((E=i.selectedWidgetData)==null?void 0:E.type)||((C=(B=i.selectedWidgetData)==null?void 0:B.data)==null?void 0:C.type))):!0})}),V=()=>{var w,g,E,B,C,M,H,G,Q;u.value={title:(w=i.selectedWidgetData)==null?void 0:w.title,type:(g=i.selectedWidgetData)==null?void 0:g.type,table:(E=i.selectedWidgetData)==null?void 0:E.table_name,query:(C=(B=i.selectedWidgetData)==null?void 0:B.data)==null?void 0:C.query,x:(H=(M=i.selectedWidgetData)==null?void 0:M.data)==null?void 0:H.x,cls:(Q=(G=i.selectedWidgetData)==null?void 0:G.data)==null?void 0:Q.cls},p.value=!0},x=async()=>{try{await R.put(`/bi-dashboard/${i.selectedDashboard}/${i.selectedWidgetData.name}`,u.value),n({type:"success",title:"Успішно!",message:"Дані успішно змінено"}),await l("update-data"),p.value=!1}catch{n({type:"error",title:"Помилка!",message:"При спробі внести зміни виникла помилка"})}};e.watch(y,()=>{d.value=!1,setTimeout(()=>d.value=!0)});const h={title:{type:"text",ua:"Заголовок",placeholder:"Заголовок",validators:["required"]},type:{type:"select",view:"buttons",label:"Тип віджета",validators:["required"],options:[{label:"Bar",id:"bar"},{label:"Funnel",id:"funnel"},{label:"Line",id:"line"},{label:"List bar",id:"listbar"},{label:"Number",id:"number"},{label:"Pie",id:"pie"},{label:"Donut",id:"donut"},{label:"Pivot",id:"pivot"},{label:"Table",id:"table"},{label:"Progress",id:"progress"},{label:"Stat",id:"stat"},{label:"Text",id:"text"},{label:"Map",id:"map"}]},table:{type:"text",ua:"Таблиця",placeholder:"Таблиця"},query:{type:"Text",ua:"Запит (query)",placeholder:"Query"},x:{type:"Text",ua:"Вісь X",placeholder:"X Axis"},cls:{type:"Text",ua:"Клас (cls)",placeholder:"Cls"}};return(w,g)=>{var B,C,M,H,G,Q,he,ue,me,fe,ge;const E=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",pn,[s.selectedWidgetData?(e.openBlock(),e.createElementBlock("div",hn,[e.createElementVNode("div",un,[e.createElementVNode("nav",mn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,P=>(e.openBlock(),e.createElementBlock("button",{key:P.id,type:"button",class:e.normalizeClass(["relative pb-3 pt-1 text-sm font-medium transition-colors whitespace-nowrap",f.value===P.id?"text-blue-600":"text-gray-600 hover:text-gray-900"]),onClick:X=>f.value=P.id},[e.createTextVNode(e.toDisplayString(P.label)+" ",1),f.value===P.id?(e.openBlock(),e.createElementBlock("span",gn)):e.createCommentVNode("",!0)],10,fn))),128))]),e.createElementVNode("div",bn,[e.createVNode(E,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"h-8 w-8 flex items-center justify-center rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors",title:"Зберегти",onClick:g[0]||(g[0]=P=>{var X,be;return(be=(X=a.value)==null?void 0:X.save)==null?void 0:be.call(X)})},[e.createVNode(e.unref($s),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[g[9]||(g[9]=e.createTextVNode(" Зберегти ",-1))]),_:1}),e.createVNode(E,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"h-8 w-8 flex items-center justify-center rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors",onClick:V},[e.createVNode(st,{class:"h-4 w-4"})])]),default:e.withCtx(()=>[g[10]||(g[10]=e.createTextVNode(" Редагувати віджет ",-1))]),_:1}),e.createVNode(E,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{type:"button",class:"h-8 w-8 flex items-center justify-center rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors",onClick:g[1]||(g[1]=P=>c.value=!0)},[e.createVNode(e.unref(tt),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[g[11]||(g[11]=e.createTextVNode(" Видалити віджет ",-1))]),_:1})])]),(B=s.currentWidgetData)!=null&&B.status?(e.openBlock(),e.createBlock(ke,{key:0,title:(C=s.currentWidgetData)==null?void 0:C.title,text:(M=s.currentWidgetData)==null?void 0:M.message},null,8,["title","text"])):(e.openBlock(),e.createElementBlock("div",yn,[d.value&&s.currentWidgetData?(e.openBlock(),e.createElementBlock("div",xn,[e.createVNode(xt,{ref_key:"tabPanelRef",ref:a,"tab-key":f.value,"tab-component":e.unref(yt)["vs-editor-form-"+f.value],widgetName:(H=s.selectedWidgetData)==null?void 0:H.name,dashboardId:s.selectedDashboard,yamlValue:((G=s.selectedWidgetData)==null?void 0:G.yml)||"",data:s.selectedWidgetData,controls:(Q=s.selectedWidgetData)==null?void 0:Q.controls,columns:(he=s.currentWidgetData)==null?void 0:he.columns,onUpdateDashboard:g[2]||(g[2]=P=>w.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])):(e.openBlock(),e.createElementBlock("div",kn,[e.createVNode(xt,{ref_key:"tabPanelRef",ref:a,"tab-key":f.value,"tab-component":e.unref(yt)["vs-editor-form-"+f.value],widgetName:(ue=s.selectedWidgetData)==null?void 0:ue.name,dashboardId:s.selectedDashboard,yamlValue:((me=s.selectedWidgetData)==null?void 0:me.yml)||"",data:s.selectedWidgetData,controls:(fe=s.selectedWidgetData)==null?void 0:fe.controls,columns:(ge=s.currentWidgetData)==null?void 0:ge.columns,onUpdateDashboard:g[3]||(g[3]=P=>w.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])),e.createVNode(ne,{teleport:"#modal",visible:c.value,title:"Ви впевнені?",onClose:g[5]||(g[5]=P=>c.value=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",wn,[g[12]||(g[12]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей віджет? ",-1)),e.createElementVNode("div",_n,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-medium text-gray-800 bg-white border border-gray-200 rounded-lg shadow-sm gap-x-2 hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:g[4]||(g[4]=P=>c.value=!1)}," Скасувати "),e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-semibold text-white bg-red-500 border border-transparent rounded-lg gap-x-2 hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:k}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"])]))])):(e.openBlock(),e.createBlock(ke,{key:1,title:"Оберіть один з віджетів",text:"",class:"p-4"}))]),e.createVNode(ne,{teleport:"#modal",visible:p.value,title:"Редагувати віджет",onClose:g[8]||(g[8]=P=>p.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",$n,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:g[7]||(g[7]=P=>p.value=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:x,class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[h?(e.openBlock(),e.createBlock(e.unref(r),{key:0,schema:h,values:u.value,"onUpdate:values":g[6]||(g[6]=P=>u.value=P)},null,8,["values"])):e.createCommentVNode("",!0)]),_:1},8,["visible"])],64)}}},Bn={class:"overflow-hidden flex flex-col min-h-[480px]"},Vn={class:"flex-1 flex min-h-0 gap-4"},Dn={class:"flex-1 min-w-0 pb-4 overflow-auto bg-gray-50/50"},Cn={key:1,class:"flex items-center justify-center h-full"},Nn={class:"w-[400px] shrink-0 flex flex-col"},Sn={__name:"vs-widget-editor-panel",props:{selectedWidget:{type:String,default:""},selectedWidgetData:{type:Object,default:null},currentWidgetData:{type:Object,default:null},selectedDashboard:{type:String,default:""},dashboardWidgets:{type:Array,default:()=>[]}},emits:["update:selectedWidget","update-data"],setup(s,{emit:t}){const r=s,n=t,o=e.ref(null);async function l(){if(!(!r.selectedDashboard||!r.selectedWidget))try{o.value=await R.get(`/bi-data?dashboard=${r.selectedDashboard}&widget=${r.selectedWidget}`)}catch(c){console.error(c)}}function a(){n("update-data")}e.watch(()=>[r.selectedDashboard,r.selectedWidget],()=>{l()},{immediate:!0});const i=e.computed({get:()=>r.selectedWidget,set:c=>n("update:selectedWidget",c)});return(c,d)=>(e.openBlock(),e.createElementBlock("div",Bn,[e.createElementVNode("div",Vn,[e.createElementVNode("div",Dn,[o.value?(e.openBlock(),e.createBlock(re,{key:0,dashboard:s.selectedDashboard,widget:s.selectedWidget,"selected-widget":s.selectedWidget,"dashboard-widgets":s.dashboardWidgets,"prefetched-data":o.value,"filter-u-rl":void 0,class:"max-h-full"},null,8,["dashboard","widget","selected-widget","dashboard-widgets","prefetched-data"])):(e.openBlock(),e.createElementBlock("div",Cn,[...d[1]||(d[1]=[e.createElementVNode("span",{class:"text-sm text-gray-400"},"Завантаження...",-1)])]))]),e.createElementVNode("div",Nn,[e.createVNode(En,{selectedWidget:i.value,"onUpdate:selectedWidget":d[0]||(d[0]=p=>i.value=p),selectedWidgetData:s.selectedWidgetData,currentWidgetData:o.value||s.currentWidgetData||{columns:[]},selectedDashboard:s.selectedDashboard,onUpdateData:a},null,8,["selectedWidget","selectedWidgetData","currentWidgetData","selectedDashboard"])])])]))}},kt={__name:"icon-grid",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(xs),e.mergeProps(t.$attrs,{size:24}),null,16))}},wt={__name:"icon-table",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Es),e.mergeProps(t.$attrs,{size:24}),null,16))}},zn={__name:"icon-more",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ms),e.mergeProps(t.$attrs,{size:24}),null,16))}},Ln=e.defineAsyncComponent(()=>import("@opengis/form")),Tn={components:{VsModal:ne,VForm:Ln,deleteIcon:tt,editIcon:st,IconGrid:kt,IconMore:zn,IconTable:wt},watch:{dashboardData:{handler(s){var r,n;if(this.formEditValue={title:s==null?void 0:s.title,description:s==null?void 0:s.description,table_name:s==null?void 0:s.table_name,db:s==null?void 0:s.db,public:s==null?void 0:s.public,words:s==null?void 0:s.words},!((r=s==null?void 0:s.panels)!=null&&r.length)){this.formGridValue={panels:[]};return}const t=(n=s==null?void 0:s.panels)==null?void 0:n.map(o=>{var i,c;const{title:l="",type:a=""}=((c=(i=s==null?void 0:s.widgets)==null?void 0:i.find(d=>(d==null?void 0:d.name)===(o==null?void 0:o.widget)))==null?void 0:c.data)||{};return{title:l,type:a,...o}});this.formGridValue={panels:t}},immediate:!0}},data(){return{isDeleteConfirm:!1,isFormEdit:!1,isFormGrid:!1,isVisibleTableColumns:!1,formEditValue:{},formGridValue:{},editDashboardScheme:[{type:"Text",key:"title",label:"Заголовок",validators:["required"]},{type:"Text",key:"description",label:"Опис"},{type:"Text",key:"table_name",validators:["required"],label:"Назва таблиці"},{type:"Text",key:"words",label:"Ключові слова"},{type:"Text",key:"db",label:"База даних",original:{type:"Text",ua:"Назва",col:8}},{type:"Switcher",key:"public",label:"Публічний",original:{type:"Text",ua:"Назва",col:8}}],editGridScheme:[{type:"DataTable",ua:"Панелі",key:"panels",actions:["search"],editable:!1,addition:!1,colModel:[{name:"title",ua:"Назва",type:"Text",key:"title"},{name:"type",ua:"Тип",type:"Text",key:"type",disabled:!0},{name:"widget",type:"Text",ua:"Віджет",key:"widget",hiddenCol:!0,disabled:!0},{name:"col",ua:"Кількість стовпчиків",type:"Text",key:"col"},{name:"height",ua:"Висота",type:"Text",key:"height"},{name:"category",ua:"Категорія",type:"Text",key:"category"}]}]}},props:{selected:{type:String,default:()=>""},dashboardData:{type:Object,default:()=>{}},selectedWidgetData:{type:Object,default:()=>{}},columns:{type:Array}},methods:{async editDashboard(){var s,t;try{const r=(t=(s=this.$refs)==null?void 0:s.formEdit)==null?void 0:t.validate();typeof r=="function"&&await r(),await R.put(`/bi-dashboard/${this.selected}`,this.formEditValue),await this.$notify({title:"Успішно!",type:"success",message:"Дані успішно оновлено"}),this.isFormEdit=!1,await this.$emit("update-editor")}catch{this.$notify({title:"Помилка!",type:"error",message:"при спробі оновити дані виникла помилка"})}},async editDashboardGrid(){var s,t;try{(t=(s=this.$refs)==null?void 0:s.formGrid)==null||t.doValidation(),await R.put(`/bi-dashboard/${this.selected}`,{...this.formEditValue,...this.formGridValue}),await this.$notify({title:"Успішно!",type:"success",message:"Дані успішно оновлено"}),this.isFormGrid=!1,await this.$emit("update-editor")}catch{this.$notify({title:"Помилка!",type:"error",message:"При спробі оновити дані виникла помилка"})}},async deleteDashboard(){try{await R.delete(`/bi-dashboard/${this.selected}`),this.isDeleteConfirm=!1,this.$emit("update:selected",""),this.$emit("update-editor"),this.$notify({title:"Успішно!",type:"success",message:"Дашборд видалено успішно"})}catch{this.$notify({title:"Помилка!",type:"error",message:"При спробі видалити дашборд виникла помилка"})}},closePopover(){document.body.click()}}},In={key:0,class:"flex items-center gap-4"},Mn={class:"h-[30px] w-[30px] flex items-center justify-center"},Rn={class:"flex flex-col items-start -ml-2 -mr-2"},Pn={class:"p-4"},Fn={class:"flex justify-end mt-4 gap-x-3"},Wn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},jn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"};function An(s,t,r,n,o,l){const a=e.resolveComponent("IconGrid"),i=e.resolveComponent("VsPopover"),c=e.resolveComponent("IconMore"),d=e.resolveComponent("VsModal"),p=e.resolveComponent("VForm");return e.openBlock(),e.createElementBlock("div",null,[r.selected?(e.openBlock(),e.createElementBlock("div",In,[e.createVNode(i,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createElementVNode("button",{class:"h-[30px] w-[30px] flex items-center justify-center",onClick:t[0]||(t[0]=u=>o.isFormGrid=!0)},[e.createVNode(a,{class:"h-[20px] text-gray-500"})])]),default:e.withCtx(()=>[t[14]||(t[14]=e.createTextVNode(" Редагувати структуру дашборду ",-1))]),_:1}),e.createVNode(i,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createVNode(i,{placement:"bottom-left"},{reference:e.withCtx(()=>[e.createElementVNode("button",Mn,[e.createVNode(c,{class:"h-[20px]"})])]),default:e.withCtx(()=>[e.createElementVNode("div",Rn,[e.createElementVNode("button",{onClick:t[1]||(t[1]=u=>{l.closePopover(),o.isFormEdit=!0}),class:"px-[8px] py-[4px] hover:bg-gray-100 w-full text-start rounded-lg"}," Редагувати дашборд "),e.createElementVNode("button",{onClick:t[2]||(t[2]=u=>{l.closePopover(),o.isDeleteConfirm=!0}),class:"px-[8px] py-[4px] hover:bg-gray-100 w-full text-start rounded-lg"}," Видалити дашборд ")])]),_:1})]),default:e.withCtx(()=>[t[15]||(t[15]=e.createTextVNode(" Керування дашбордом ",-1))]),_:1})])):e.createCommentVNode("",!0),e.createVNode(d,{teleport:"#modal",visible:o.isDeleteConfirm,size:"small",title:"Ви впевнені?",onClose:t[5]||(t[5]=u=>o.isDeleteConfirm=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",Pn,[t[16]||(t[16]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей дашборд? ",-1)),e.createElementVNode("div",Fn,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-medium text-gray-800 bg-white border border-gray-200 rounded-lg shadow-sm gap-x-2 hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:t[3]||(t[3]=u=>o.isDeleteConfirm=!1)}," Скасувати "),e.createElementVNode("button",{type:"button",class:"inline-flex items-center px-3 py-2 text-sm font-semibold text-white bg-red-500 border border-transparent rounded-lg gap-x-2 hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:t[4]||(t[4]=(...u)=>l.deleteDashboard&&l.deleteDashboard(...u))}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"]),e.createVNode(d,{teleport:"#modal",visible:o.isFormEdit,title:"Редагувати дашборд",onClose:t[9]||(t[9]=u=>o.isFormEdit=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Wn,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:t[7]||(t[7]=u=>o.isFormEdit=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:t[8]||(t[8]=(...u)=>l.editDashboard&&l.editDashboard(...u)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(p,{ref:"formEdit",schema:o.editDashboardScheme,values:o.formEditValue,"onUpdate:values":t[6]||(t[6]=u=>o.formEditValue=u)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createVNode(d,{teleport:"#modal",visible:o.isFormGrid,title:"Редагувати структуру дашборду",onClose:t[13]||(t[13]=u=>o.isFormGrid=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",jn,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:t[11]||(t[11]=u=>o.isFormGrid=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Скасувати "),e.createElementVNode("button",{onClick:t[12]||(t[12]=(...u)=>l.editDashboardGrid&&l.editDashboardGrid(...u)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(p,{ref:"formgrid",schema:o.editGridScheme,values:o.formGridValue,"onUpdate:values":t[10]||(t[10]=u=>o.formGridValue=u)},null,8,["schema","values"])]),_:1},8,["visible"])])}const On=L(Tn,[["render",An]]),qn={class:"flex-1 min-w-0 flex flex-col overflow-auto"},vn={class:"max-w-7xl mx-auto px-6 w-full flex flex-col min-h-0 flex-1"},Un={class:"relative z-10 shrink-0 mt-4 mb-6"},Hn={class:"flex items-center text-sm text-gray-600"},Gn={key:0,class:"flex items-center justify-between gap-4 mt-3"},Zn={class:"min-w-0"},Qn={class:"text-2xl font-bold text-gray-900"},Xn={key:0,class:"mt-1.5 text-sm text-gray-600"},Jn={class:"flex items-center shrink-0"},Kn={key:1,class:"grid flex-grow w-full grid-cols-12 gap-4 py-4 pr-[15px] min-h-0 overflow-auto [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-stone-100 [&::-webkit-scrollbar-thumb]:bg-stone-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},Yn=L({__name:"vs-editor",props:{prefix:String,customClass:{type:String,default:()=>"w-screen h-screen"},initialDashboardId:{type:String,default:""},initialWidgetId:{type:String,default:""}},emits:["back"],setup(s,{emit:t}){const r=s;ye(r.prefix||"/api");const n=t,o=O.useRouter(),l=e.computed(()=>o.hasRoute(W.EditorWidget)),a=e.inject("biClearDashboard",null),i=e.ref(r.initialDashboardId||""),c=e.ref(r.initialWidgetId||""),d=e.ref(null),p=e.ref(null),u=e.ref(null);e.watch(()=>r.initialWidgetId,x=>{c.value=x||""});const y=async()=>{if(!i.value){d.value=null;return}try{const x=await R.get(`/bi-dashboard/${i.value}`);d.value=x}catch(x){console.error(x)}},m=e.computed(()=>{var x,h,b;return(b=Array.isArray((x=d.value)==null?void 0:x.widgets)?(h=d.value)==null?void 0:h.widgets:[])==null?void 0:b.find($=>($==null?void 0:$.name)===c.value)});function f(x){l.value?o.push({name:W.EditorWidget,params:{dashboardId:i.value,widgetId:x}}):c.value=x}function k(){l.value?o.push({name:W.EditorDashboard,params:{dashboardId:i.value}}):c.value=""}function _(){l.value?o.push({name:W.Editor}):(typeof a=="function"&&a(),n("back"))}const V=e.computed(()=>{var b,$,w,g,E;const h=[l.value?{label:"Дашборди",to:{name:W.Editor}}:{label:"Дашборди",onClick:_}];if((b=d.value)!=null&&b.title||i.value){const B=(($=d.value)==null?void 0:$.title)||i.value||"Редактор";!!c.value?h.push(l.value?{label:B,to:{name:W.EditorDashboard,params:{dashboardId:i.value}}}:{label:B,onClick:()=>{c.value=""}}):h.push({label:B})}else h.push({label:"Редактор"});if(c.value&&m.value){const B=((g=(w=m.value)==null?void 0:w.data)==null?void 0:g.title)||((E=m.value)==null?void 0:E.title)||c.value;h.push({label:B})}return h});return e.watch(i,(x,h)=>{h&&(c.value=""),x?y():(d.value=null,_())}),e.onMounted(()=>{y()}),(x,h)=>{var b,$;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex w-full h-full",[s.customClass]])},[e.createElementVNode("div",qn,[e.createElementVNode("div",vn,[e.createElementVNode("div",Un,[e.createElementVNode("div",Hn,[e.createVNode(Ke,{items:V.value,compact:""},null,8,["items"])]),i.value&&d.value?(e.openBlock(),e.createElementBlock("div",Gn,[e.createElementVNode("div",Zn,[e.createElementVNode("h1",Qn,e.toDisplayString(d.value.title||i.value),1),d.value.description?(e.openBlock(),e.createElementBlock("p",Xn,e.toDisplayString(d.value.description),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Jn,[c.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors",onClick:k},[e.createVNode(e.unref(Qe),{class:"w-4 h-4"}),h[5]||(h[5]=e.createTextVNode(" Закрити ",-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(On,{selected:i.value,"onUpdate:selected":h[0]||(h[0]=w=>i.value=w),dashboardData:d.value,columns:(b=d.value)==null?void 0:b.columns,selectedWidgetData:m.value,prefix:s.prefix,onUpdateEditor:y},null,8,["selected","dashboardData","columns","selectedWidgetData","prefix"]),e.createElementVNode("button",{type:"button",class:"ml-4 flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors shadow-sm font-medium",onClick:h[1]||(h[1]=w=>{var g,E;return(E=(g=u.value)==null?void 0:g.open)==null?void 0:E.call(g)})},[...h[6]||(h[6]=[e.createElementVNode("span",{class:"leading-none"},"+",-1),e.createTextVNode(" Створити віджет ",-1)])]),i.value?(e.openBlock(),e.createBlock($r,{key:0,ref_key:"createWidgetRef",ref:u,inline:"",columns:($=d.value)==null?void 0:$.columns,selectedDashboard:i.value,onUpdateData:y},null,8,["columns","selectedDashboard"])):e.createCommentVNode("",!0)],64))])])):e.createCommentVNode("",!0)]),c.value&&d.value?(e.openBlock(),e.createBlock(Sn,{key:0,"selected-widget":c.value,"onUpdate:selectedWidget":h[2]||(h[2]=w=>c.value=w),"selected-widget-data":m.value,"current-widget-data":p.value,"selected-dashboard":i.value,"dashboard-widgets":d.value.widgets||[],onUpdateData:y},null,8,["selected-widget","selected-widget-data","current-widget-data","selected-dashboard","dashboard-widgets"])):(e.openBlock(),e.createElementBlock("div",Kn,[d.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(d.value.panels,(w,g)=>{var E;return e.openBlock(),e.createElementBlock("div",{key:g,class:e.normalizeClass([`md:col-span-${w.col||12} col-span-12`,"flex flex-col gap-[10px]"])},[(E=w.widgets)!=null&&E.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(w.widgets,B=>(e.openBlock(),e.createBlock(re,{onClick:C=>f(B),"onUpdate:currentWidgetData":h[3]||(h[3]=C=>p.value=C),key:B,dashboard:i.value,widget:B,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(w.height??480),class:e.normalizeClass({"border border-blue-500":c.value===B})},null,8,["onClick","dashboard","widget","selectedWidget","dashboard-widgets","height","class"]))),128)):(e.openBlock(),e.createBlock(re,{key:1,onClick:B=>f(w.widget),"onUpdate:currentWidgetData":h[4]||(h[4]=B=>p.value=B),class:e.normalizeClass(["flex flex-col",{"border border-blue-500":c.value===w.widget}]),dashboard:i.value,widget:w.widget,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(w.height??480)},null,8,["onClick","class","dashboard","widget","selectedWidget","dashboard-widgets","height"]))],2)}),128)):(e.openBlock(),e.createBlock(ke,{key:0,class:"col-span-12"}))]))])])],2)}}},[["__scopeId","data-v-f586e5b0"]]),eo={class:"w-full h-screen"},_t=e.defineComponent({__name:"vs-editor-page",props:{prefix:{default:"/api"},dashboardId:{default:""},widgetId:{default:""}},emits:["back"],setup(s){return(t,r)=>(e.openBlock(),e.createElementBlock("div",eo,[e.createVNode(Yn,{customClass:"h-full w-full",prefix:s.prefix,"initial-dashboard-id":s.dashboardId,"initial-widget-id":s.widgetId,onBack:r[0]||(r[0]=n=>t.$emit("back"))},null,8,["prefix","initial-dashboard-id","initial-widget-id"])]))}}),to={class:"relative group h-full"},so={class:"flex items-start gap-3 flex-1 min-h-0"},ro={class:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors shrink-0"},no={class:"flex-1 min-w-0 flex flex-col min-h-0"},oo={class:"font-semibold text-gray-900 mb-1 truncate"},ao={key:0,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10"},lo={key:1,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10 invisible","aria-hidden":"true"},io={key:2,class:"text-sm text-gray-400 mt-1 shrink-0"},co=L({__name:"dashboard-card",props:{title:String,description:String,modified:String,name:String,widgetCount:Number,reserveLines:Number,dashboardRouteName:String,onOpenEditor:Function},setup(s){const t=s,r=O.useRouter(),n=e.ref(!1);function o(){t.dashboardRouteName&&(r.hasRoute(W.EditorDashboard)?r.push({name:W.EditorDashboard,params:{dashboardId:t.dashboardRouteName}}):t.onOpenEditor?t.onOpenEditor(t.dashboardRouteName):r.push({path:"/editor",query:{dashboard:t.dashboardRouteName}}))}function l(a){a.target.closest(".dashboard-card-menu")||(n.value=!1)}return e.onMounted(()=>document.addEventListener("click",l)),e.onUnmounted(()=>document.removeEventListener("click",l)),(a,i)=>(e.openBlock(),e.createElementBlock("div",to,[e.createElementVNode("button",{type:"button",class:"w-full h-full bg-white border border-gray-200 rounded-lg p-6 hover:shadow-md hover:border-blue-200 transition-all text-left animate-fade-in flex flex-col",onClick:o},[e.createElementVNode("div",so,[e.createElementVNode("div",ro,[e.createVNode(e.unref(ys),{size:24,class:"w-5 h-5 text-blue-600"})]),e.createElementVNode("div",no,[e.createElementVNode("h3",oo,e.toDisplayString(s.title),1),s.description?(e.openBlock(),e.createElementBlock("p",ao,e.toDisplayString(s.description),1)):(e.openBlock(),e.createElementBlock("p",lo,"   ")),s.widgetCount!=null?(e.openBlock(),e.createElementBlock("p",io,e.toDisplayString(s.widgetCount)+" віджетів ",1)):e.createCommentVNode("",!0)])])])]))}},[["__scopeId","data-v-716ced89"]]),po=[{type:"Text",key:"name",label:"Назва",validators:["required"],original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"title",label:"Заголовок",validators:["required"],original:{type:"Text",ua:"Титул",col:8}},{type:"Text",key:"description",label:"Опис",original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"words",label:"Ключові слова",original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"table_name",validators:["required"],label:"Назва таблиці",original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"db",label:"База даних",original:{type:"Text",ua:"Назва",col:8}},{type:"Text",key:"category",label:"Категорія",original:{type:"Text",ua:"Категорія",col:8}},{type:"Switcher",key:"public",label:"Публічний",original:{type:"Text",ua:"Назва",col:8}}];function ho(s){return!Array.isArray(s)||s.length===0?{}:s.reduce((t,r)=>{if(!r||r.key==null)return t;const{key:n,...o}=r;return t[n]=o,t},{})}const uo={class:"flex-1 bg-gray-50"},mo={class:"max-w-7xl mx-auto px-6 py-8"},fo={class:"mb-6"},go={class:"flex items-center justify-between mb-6"},bo={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},yo={class:"flex items-center space-x-4"},xo={class:"flex-1 relative"},ko={key:0,class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},wo={key:1,class:"flex flex-col items-center justify-center py-20 text-center"},_o={class:"mt-1 text-sm text-gray-400"},$o={class:"font-medium text-gray-500"},$t=e.defineComponent({__name:"all-dashboards-page",props:{prefix:{}},setup(s){const t=e.defineAsyncComponent(()=>import("@opengis/form")),r=ho(po),n=e.ref([]),o=e.ref([]),l=O.useRouter(),a=e.inject("biSetDashboard",void 0),i=s,c=e.ref(null),d=e.ref(!1),p=e.ref({}),u=e.ref(""),y=e.computed(()=>{const h=u.value.trim().toLowerCase();return h?n.value.filter(b=>b.title.toLowerCase().includes(h)):n.value});async function m(){try{const h=await R.get("/bi-dashboard?type=db"),b=Array.isArray(h==null?void 0:h.rows)?h.rows:[];o.value=b,n.value=b.map($=>({routeName:String($.name??""),title:$.title??$.name??"Без назви",description:$.description??null,modified:"-",name:"-"}))}catch(h){console.error("Failed to load dashboards",h),o.value=[],n.value=[]}}async function f(){var b,$,w;const h=($=(b=e.getCurrentInstance())==null?void 0:b.proxy)==null?void 0:$.$notify;try{const g=(w=c.value)==null?void 0:w.validate();typeof g=="function"&&await g();const{name:E,title:B,table_name:C}=p.value;if(!E||!B||!C){h==null||h({type:"error",title:"Помилка!",message:"Заповніть усі обов'язкові поля"});return}await R.post("/bi-dashboard",p.value),d.value=!1,p.value={},h==null||h({type:"success",title:"Успішно!",message:"Дашборд створено успішно"}),l.hasRoute(W.EditorDashboard)?l.push({name:W.EditorDashboard,params:{dashboardId:E}}):a?a(E):await m()}catch{h==null||h({type:"error",title:"Помилка!",message:"При спробі створити дашборд виникла помилка"})}}e.onMounted(()=>{ye(i.prefix||"/api"),m()});const k=e.ref(1),_=()=>{const h=window.innerWidth;k.value=h>=1024?3:h>=768?2:1};e.onMounted(()=>{_(),window.addEventListener("resize",_)}),e.onUnmounted(()=>{window.removeEventListener("resize",_)});const V=h=>h?h.trim().length>70?2:1:0,x=h=>{const b=k.value||1,w=Math.floor(h/b)*b,g=w+b,E=y.value.slice(w,g);let B=0;for(const C of E){const M=V(C.description??null);if(M>B&&(B=M),B===2)break}return B};return e.ref("grid"),(h,b)=>(e.openBlock(),e.createElementBlock("div",uo,[e.createElementVNode("div",mo,[e.createElementVNode("div",fo,[e.createElementVNode("div",go,[b[6]||(b[6]=e.createElementVNode("div",null,[e.createElementVNode("h1",{class:"text-3xl font-bold text-gray-900"},"Дашборди"),e.createElementVNode("p",{class:"mt-2 text-gray-600"}," Керуйте та переглядайте свої аналітичні дашборди ")],-1)),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 px-4 py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors shadow-sm font-medium",onClick:b[0]||(b[0]=$=>d.value=!0)},[e.createVNode(e.unref(Ge),{size:24,class:"w-4 h-4"}),b[5]||(b[5]=e.createElementVNode("span",null,"Новий дашборд",-1))])]),e.createVNode(ne,{teleport:"#modal",visible:d.value,title:"Створити дашборд",onClose:b[3]||(b[3]=$=>d.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",bo,[e.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border border-gray-200 rounded-lg hover:bg-gray-100 duration-300",onClick:b[2]||(b[2]=$=>d.value=!1)}," Скасувати "),e.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg hover:bg-blue-700 duration-300",onClick:f}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(e.unref(t),{ref_key:"createFormRef",ref:c,schema:e.unref(r),values:p.value,"onUpdate:values":b[1]||(b[1]=$=>p.value=$)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createElementVNode("div",yo,[e.createElementVNode("div",xo,[e.createVNode(e.unref(Ze),{size:24,class:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[4]||(b[4]=$=>u.value=$),type:"text",placeholder:"Пошук дашбордів...",class:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"},null,512),[[e.vModelText,u.value]])])])]),y.value.length?(e.openBlock(),e.createElementBlock("div",ko,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,($,w)=>(e.openBlock(),e.createElementBlock("div",{key:$.routeName,class:"cursor-pointer h-full"},[e.createVNode(co,{title:$.title,description:$.description,modified:$.modified,name:$.name,reserveLines:x(w),"dashboard-route-name":$.routeName,"on-open-editor":e.unref(a)},null,8,["title","description","modified","name","reserveLines","dashboard-route-name","on-open-editor"])]))),128))])):(e.openBlock(),e.createElementBlock("div",wo,[e.createVNode(e.unref(Ze),{size:48,class:"text-gray-300 mb-4"}),b[9]||(b[9]=e.createElementVNode("p",{class:"text-lg font-medium text-gray-500"},"Дашбордів не знайдено",-1)),e.createElementVNode("p",_o,[b[7]||(b[7]=e.createTextVNode(" За запитом «",-1)),e.createElementVNode("span",$o,e.toDisplayString(u.value),1),b[8]||(b[8]=e.createTextVNode("» нічого не знайдено. Спробуйте змінити пошуковий запит. ",-1))])]))])]))}}),Eo=e.defineComponent({__name:"editor-root-page",props:{prefix:{default:"/api"}},setup(s){const t=s,r=e.computed(()=>t.prefix),n=O.useRouter(),o=O.useRoute(),l=e.computed(()=>n.hasRoute(W.EditorDashboard)),a=e.ref("");e.onMounted(()=>{var c;if(!l.value){const d=(c=o==null?void 0:o.query)==null?void 0:c.dashboard;d!=null&&typeof d=="string"&&(a.value=d.trim())}});const i=e.computed(()=>a.value.length>0);return e.provide("biSetDashboard",c=>{a.value=c||""}),e.provide("biClearDashboard",()=>{a.value=""}),e.provide("biSelectedDashboardId",e.readonly(a)),(c,d)=>{const p=e.resolveComponent("router-view");return l.value?(e.openBlock(),e.createBlock(p,{key:0})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[i.value?(e.openBlock(),e.createBlock(_t,{key:`editor-${a.value}`,prefix:r.value,"dashboard-id":a.value,onBack:d[0]||(d[0]=u=>a.value="")},null,8,["prefix","dashboard-id"])):(e.openBlock(),e.createBlock($t,{key:0,prefix:r.value},null,8,["prefix"]))],64))}}});function U(s,t){const r=s&&typeof s=="object"&&"value"in s?s.value:s;if(r==null)return"";const n=Number(r);return Number.isNaN(n)?String(r):new Intl.NumberFormat("en",t??{notation:"compact"}).format(n)}function pe(s){if(!(s!=null&&s.includes("T")))return s??"";const[t,r,n]=s.split("T")[0].split("-");return`${n}.${r}.${t}`}function Bo(s){return Intl.NumberFormat("en").format(s??0)}class Vo{static getTooltipOptions(t=!0){return{show:t,confine:!0,appendToBody:!1,axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}}}}const Do={show_label:!1,show_legend:!1,label:null,legend:{position:null},colors:null,color:null,title:null};function Co(){const s="0123456789ABCDEF";let t="#";for(let r=0;r<6;r+=1)t+=s[Math.floor(Math.random()*16)];return t}function Y(s=Do){var r,n,o;const t={label:{show:((r=s==null?void 0:s.label)==null?void 0:r.show)??(s==null?void 0:s.show_label)??!1,formatter:(s==null?void 0:s.formatter)??(l=>U(l)),...(s==null?void 0:s.label)||{}},legend:{...(s==null?void 0:s.legend)||{},[((n=s==null?void 0:s.legend)==null?void 0:n.position)||"bottom"]:"0",show:((o=s==null?void 0:s.legend)==null?void 0:o.show)??(s==null?void 0:s.show_legend)??!1},barWidth:"70%",grid:{borderColor:"#e5e7eb"},title:{...(s==null?void 0:s.title)||{}}};return(s!=null&&s.colors||s!=null&&s.color)&&(t.color=(s==null?void 0:s.colors)||(s==null?void 0:s.color)||null),t}function Et(s){return{color:"#9ca3af",fontSize:10,fontFamily:"Inter, ui-sans-serif, system-ui",fontWeight:400,label:s==null?void 0:s.label,show:!0,formatter:(s==null?void 0:s.formatter)??(t=>U(t)),margin:(s==null?void 0:s.margin)??7,interval:(s==null?void 0:s.interval)??"auto",rotate:(s==null?void 0:s.rotate)??0}}const Bt=["#d3c7e6","#bedae3","#f8e9cb","#ff8c8c","#c5d8be","#ffc6c6","#ffc39a","#fff7c5","#d8ffc0","#d4f7ff"];class Ve{static getLabelOptions(t={}){return{show:(t==null?void 0:t.show_label)||(t==null?void 0:t.show)||!1,fontSize:"10",position:(t==null?void 0:t.position)||"inside",formatter:(t==null?void 0:t.formatter)||"{d}%",...t}}static getLegendOpions(t={}){return{...t,position:(t==null?void 0:t.position)||"bottom"}}}const ee=typeof window<"u"?window.echarts:null,j={props:["source","style","widget","dashboard","title","currentWidget","widgetData","prefix","prefetchedData"],data(){return{sourceData:null,styleData:null,widgetName:"",dimensions:[],dashboardName:"",titleCharts:"",widgetInstance:null}},mounted(){window.addEventListener("resize",this.handleResize),window.addEventListener(`update-data-${this.widget}`,this.checkCustomEvent),window.addEventListener(`update-style-${this.widget}`,this.checkCustomStyleEvent)},unmounted(){window.removeEventListener(`update-data-${this.widget}`,this.checkCustomEvent),window.removeEventListener(`update-style-${this.widget}`,this.checkCustomStyleEvent)},watch:{sourceData:{async handler(){setTimeout(()=>{this==null||this.onChangedData()},0)}}},methods:{checkCustomStyleEvent(s){this.changeOptionsByName(s.chartId,s.options)},checkCustomEvent({filterUrl:s}){this.getDataFromURL(s)},handleResize(){this.widgetInstance&&this.widgetInstance.resize()},async getDataFromURL(s){try{const t=await R.get(s);this.applyResponse(t)}catch(t){const r={message:"Дані не знайдено",title:"Помилка!",type:"error",status:400,id:this.widgetName};(t==null?void 0:t.status)=="404"&&(r.status=404,r.message="Дані не знайдено"),(t==null?void 0:t.status)=="400"&&(r.message="Перевірте налаштування або зверніться до адміністратора"),(t==null?void 0:t.status)=="500"&&(r.message="Сталася помилка сервера"),this.$emit("update:widgetData",r)}},getValues(){return this.sourceData.map(s=>{var t;return parseFloat(s[(t=this.columns)==null?void 0:t[1]])})},formatDate(s){const t=new Date(s);if(isNaN(t))return s;const r=String(t.getDate()).padStart(2,"0"),o=["січня","лютого","березня","квітня","травня","червня","липня","серпня","вересня","жовтня","листопада","грудня"][t.getMonth()],l=t.getFullYear();return`${r} ${o} ${l}`},applyResponse(s){var t;this.sourceData=(s==null?void 0:s.source)||[],this.$emit("update:widgetData",s),this.dimensions=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{}),this.titleCharts=this.style?this.style:(s==null?void 0:s.title)||"",this.styleData=(s==null?void 0:s.style)||{}},async getData(){var s;try{if(this.source)this.sourceData=[...this.source],this.styleData=this.style,this.titleCharts=this.title,this.dimensions=Object.keys(((s=this.sourceData)==null?void 0:s[0])||{});else if(this.prefetchedData)this.widgetName=this.widget,this.dashboardName=this.dashboard,this.applyResponse(this.prefetchedData);else{this.widgetName=this.widget,this.dashboardName=this.dashboard;const t=this.dashboardName?`${this.prefix||""}/bi-data?dashboard=${this.dashboardName}&widget=${this.widgetName}`:`${this.prefix||""}/bi-data?&widget=${this.widgetName}`;await this.getDataFromURL(t)}}catch(t){console.error(t)}},async initChart(s,t,r){var n,o,l,a,i,c,d,p,u;this.widgetInstance&&this.widgetInstance.clear();try{const y=this.$refs.chart,m=ee==null?void 0:ee.init(y);if(!m)return;const f={tooltip:{show:((o=(n=this.styleData)==null?void 0:n.tooltip)==null?void 0:o.show)!==!1,trigger:"axis",confine:!0,appendToBody:!1,axisPointer:{type:"shadow"},backgroundColor:"transparent",shadowColor:"transparent",padding:[0,0,0,0],borderWidth:0,position:(k,_,V,x,h)=>{const[b,$]=k,[w,g]=h.contentSize,[E,B]=h.viewSize;let C=b+14,M=$-g/2;return C+w>E&&(C=b-w-14),C<0&&(C=0),M+g>B&&(M=B-g),M<0&&(M=0),[C,M]},formatter:k=>{var g;const V=(g=k[0])==null?void 0:g.axisValue,x=V?this.formatDate(V):"N/A",h=[...k].filter(E=>{var B;return parseFloat(E==null?void 0:E.data)||((B=E==null?void 0:E.data)==null?void 0:B.value)}).sort((E,B)=>{var H,G;const C=parseFloat(((H=E==null?void 0:E.data)==null?void 0:H.value)??(E==null?void 0:E.data))||0;return(parseFloat(((G=B==null?void 0:B.data)==null?void 0:G.value)??(B==null?void 0:B.data))||0)-C}),b=h.slice(0,8),$=h.length-b.length;let w=`
187
187
  <div style="background-color: rgba(255, 255, 255, 0.95)" class="border border-gray-200 text-gray-800 rounded-lg shadow-md dark:bg-neutral-800 dark:border-neutral-700 min-w-28">
188
188
  <div class="font-semibold text-sm border-b border-solid border-gray-200 text-gray-800 rounded-t-lg dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-200 px-2 py-1">
189
189
  ${x}
@@ -199,16 +199,16 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
199
199
  `}),$>0&&(w+=`
200
200
  <div class="text-xs px-2 py-0.5 text-gray-400 dark:text-neutral-500">
201
201
  ... ще ${$}
202
- </div>`),w+="</div>",w}},xAxis:{data:t!=null&&t.length?t:null,type:t?"category":"value",name:((a=(l=this.styleData)==null?void 0:l.x_axis)==null?void 0:a.name)||"",axisLabel:{...Vt((i=this.styleData)==null?void 0:i.x_axis),formatter:k=>{var V,x;const _=this.formatDate(k);return((x=(V=this.styleData)==null?void 0:V.x_axis)==null?void 0:x.overflow)==="ellipsis"&&_.length>10?`${_.slice(0,10)}...`:_}}},yAxis:{data:r!=null&&r.length?r:null,type:r?"category":"value",name:((d=(c=this.styleData)==null?void 0:c.y_axis)==null?void 0:d.name)||"",axisLabel:Vt((p=this.styleData)==null?void 0:p.y_axis)},series:s!=null&&s.length?s:null,...K(this.styleData),grid:{bottom:"0%",right:"0%",left:"0%",top:"20px",containLabel:!0,...((u=this.styleData)==null?void 0:u.grid)||{}}};await m.setOption(f),m.resize(),this.widgetInstance=m,this.$emit("update:currentWidget",m)}catch(y){console.error(y)}},async setSeriesOption(s,t){const r=s.getOption(),{series:n=[]}=r,o=n.map(l=>({...l,...t}));s.setOption({...r,series:o})},async changeOptionsByName(s,t){const r=document.getElementById(s);if(!r)return null;const n=te==null?void 0:te.getInstanceByDom(r);if(!n)return null;const o=n.getOption();t.seriesOptions&&this.setSeriesOption(n,t.seriesOptions),n.setOption({...o,...t.options,tooltip:{...So.getTooltipOptions(t.options.tooltip.show)}})},async changeData(s){var t;try{let r=this.dashboard?`${this.prefix||""}/bi-data?dashboard=${this.dashboard}&widget=${this.widget}`:`${this.prefix||""}/bi-data?&widget=${this.widget}`;(t=s==null?void 0:s.granularity)!=null&&t.length&&(r+=`&granularity=${s.granularity}`),s!=null&&s.metrics&&(r+=`&metrics=${s.metrics}`),this.getDataFromURL(r)}catch(r){console.error(r)}},async setFilter(s){const t=`${this.prefix||""}/bi-data?dashboard=${this.dashboardName}&widget=${this.widgetName}${s||""}`;await this.getDataFromURL(t)},async changeStyle(s,t){this.styleData[s]=t,this.onChangedData()},getMetricValue(s){var n;const t=(s==null?void 0:s.metric)||s;return parseFloat(t)?(n=v(t,{notation:"standard"}))==null?void 0:n.replaceAll(","," "):t}}},To={name:"VsBar",mixins:[j],data(){return{resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var t;this.getData(),this.onChangedData();const s=(t=this.$refs)==null?void 0:t.chart;s&&(this.resizeObserver=new ResizeObserver(()=>{var r;this.widgetInstance&&((r=this.widgetInstance)==null||r.resize())}),this.resizeObserver.observe(s))},unmounted(){this.resizeObserver.disconnect()},methods:{async onChangedData(){try{if(this.sourceData){await this.$nextTick();const{series:s,xs:t,ys:r}=this.prepareData();s&&(this==null||this.initChart(s,t,r))}}catch(s){console.error(s)}},prepareData(){var s,t,r,n,o,l;try{if(!((s=this.sourceData)!=null&&s.length))return{series:[],xs:[],ys:void 0};const a=Array.from(new Set(this.sourceData.filter(y=>y[this.dimensions[0]]).map(y=>y[this.dimensions[0]])));let i;this.dimensions[0].includes("date")?i=a.map(y=>he(y)):i=[...a];let c,d;((t=this.styleData)==null?void 0:t.horizontal)===!0?d=[...i]:c=[...i];const p=this.sourceData.filter(y=>parseFloat(y[this.dimensions[1]])&&y[this.dimensions[0]]).map(y=>parseFloat(y[this.dimensions[1]]));let u;return((r=this.styleData)==null?void 0:r.stack)!==!1?u=this.prepareStackData():((n=this.styleData)==null?void 0:n.negative_waterfall)===!0?u=this.prepareNegativeWaterfall():((o=this.styleData)==null?void 0:o.waterfall)===!0?u=this.prepareWaterfallData(p):((l=this.styleData)==null?void 0:l.accumulative)===!0?u=this.prepareAccumulative(p):u=this.dimensions.slice(1).map((m,f)=>({name:m,type:"bar",stack:`a${f}`,data:this.sourceData.filter(k=>parseFloat(k[m])&&m).map(k=>parseFloat(k[m]))})),{series:u,xs:c,ys:d}}catch(a){return console.error(a),{series:[],xs:[],ys:[]}}},prepareWaterfallData(s){let t=s.reduce((l,a)=>l+a,0);const r=[t,...s],n=r.map((l,a)=>{if(a===0)return 0;const i=t-l;return t-=l,i>=0?i:0});return[{type:"bar",stack:"Total",itemStyle:{borderColor:"transparent",color:"transparent"},data:n,tooltip:{show:!1}},{name:this.title?this.title:this.dimensions[0],type:"bar",stack:"Total",data:r}]},prepareStackData(){return this.dimensions.slice(1).map(r=>({name:r,type:"bar",stack:"a",data:this.sourceData.filter(n=>parseFloat(n[r])&&r).map(n=>parseFloat(n[r]))}))},prepareNegativeWaterfall(){const s=this.sourceData.map(l=>Number.isNaN(l[this.dimensions[1]])?0:Number(l[this.dimensions[1]])),t=this.sourceData.map(l=>Number.isNaN(l[this.dimensions[2]])?0:Number(l[this.dimensions[2]]));let r=0;const n=s.map((l,a)=>{const i=r;return r+=Number.isNaN(l)?0:l,a===0&&(r-=Number.isNaN(t[a])?0:t[a]),r-=Number.isNaN(t[a+1])?0:t[a+1],i>=0?i:0});return[{type:"bar",stack:"a",itemStyle:{borderColor:"transparent",color:"transparent"},data:n,tooltip:{show:!1}},{name:this.dimensions[1],type:"bar",stack:"a",data:s},{name:this.dimensions[2],type:"bar",stack:"a",data:t}]},prepareAccumulative(s){let t=0;const r=s.map(o=>(t+=o,t));return[{name:this.titleCharts,type:"bar",stack:"Total",data:r}]}}},Io=["id"];function Mo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full w-full min-h-[200px]"},null,8,Io)}const We=z(To,[["render",Mo]]),Ro=Object.freeze(Object.defineProperty({__proto__:null,default:We},Symbol.toStringTag,{value:"Module"})),je=typeof window<"u"?window.echarts:null,Po={name:"VsPie",props:["currentWidget"],mixins:[j],data(){return{chartInstance:null,resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var r;await this.$nextTick(),await this.getData();const{series:s}=this.prepareData()||{};s&&this.initChart(s);const t=(r=this.$refs)==null?void 0:r.chart;t&&(this.resizeObserver=new ResizeObserver(()=>{this.chartInstance&&this.chartInstance.resize()}),this.resizeObserver.observe(t))},beforeUnmount(){var s;(s=this.resizeObserver)==null||s.disconnect()},methods:{onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&this.initChart(s,t,r)}}catch(s){console.error(s)}},buildTooltipForDonut(s,t){const{name:r,value:n,percent:o}=s;return`
202
+ </div>`),w+="</div>",w}},xAxis:{data:t!=null&&t.length?t:null,type:t?"category":"value",name:((a=(l=this.styleData)==null?void 0:l.x_axis)==null?void 0:a.name)||"",axisLabel:{...Et((i=this.styleData)==null?void 0:i.x_axis),formatter:k=>{var V,x;const _=this.formatDate(k);return((x=(V=this.styleData)==null?void 0:V.x_axis)==null?void 0:x.overflow)==="ellipsis"&&_.length>10?`${_.slice(0,10)}...`:_}}},yAxis:{data:r!=null&&r.length?r:null,type:r?"category":"value",name:((d=(c=this.styleData)==null?void 0:c.y_axis)==null?void 0:d.name)||"",axisLabel:Et((p=this.styleData)==null?void 0:p.y_axis)},series:s!=null&&s.length?s:null,...Y(this.styleData),grid:{bottom:"0%",right:"0%",left:"0%",top:"20px",containLabel:!0,...((u=this.styleData)==null?void 0:u.grid)||{}}};await m.setOption(f),m.resize(),this.widgetInstance=m,this.$emit("update:currentWidget",m)}catch(y){console.error(y)}},async setSeriesOption(s,t){const r=s.getOption(),{series:n=[]}=r,o=n.map(l=>({...l,...t}));s.setOption({...r,series:o})},async changeOptionsByName(s,t){const r=document.getElementById(s);if(!r)return null;const n=ee==null?void 0:ee.getInstanceByDom(r);if(!n)return null;const o=n.getOption();t.seriesOptions&&this.setSeriesOption(n,t.seriesOptions),n.setOption({...o,...t.options,tooltip:{...Vo.getTooltipOptions(t.options.tooltip.show)}})},async changeData(s){var t;try{let r=this.dashboard?`${this.prefix||""}/bi-data?dashboard=${this.dashboard}&widget=${this.widget}`:`${this.prefix||""}/bi-data?&widget=${this.widget}`;(t=s==null?void 0:s.granularity)!=null&&t.length&&(r+=`&granularity=${s.granularity}`),s!=null&&s.metrics&&(r+=`&metrics=${s.metrics}`),this.getDataFromURL(r)}catch(r){console.error(r)}},async setFilter(s){const t=`${this.prefix||""}/bi-data?dashboard=${this.dashboardName}&widget=${this.widgetName}${s||""}`;await this.getDataFromURL(t)},async changeStyle(s,t){this.styleData[s]=t,this.onChangedData()},getMetricValue(s){var n;const t=(s==null?void 0:s.metric)||s;return parseFloat(t)?(n=U(t,{notation:"standard"}))==null?void 0:n.replaceAll(","," "):t}}},No={name:"VsBar",mixins:[j],data(){return{resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var t;this.getData(),this.onChangedData();const s=(t=this.$refs)==null?void 0:t.chart;s&&(this.resizeObserver=new ResizeObserver(()=>{var r;this.widgetInstance&&((r=this.widgetInstance)==null||r.resize())}),this.resizeObserver.observe(s))},unmounted(){this.resizeObserver.disconnect()},methods:{async onChangedData(){try{if(this.sourceData){await this.$nextTick();const{series:s,xs:t,ys:r}=this.prepareData();s&&(this==null||this.initChart(s,t,r))}}catch(s){console.error(s)}},prepareData(){var s,t,r,n,o,l;try{if(!((s=this.sourceData)!=null&&s.length))return{series:[],xs:[],ys:void 0};const a=Array.from(new Set(this.sourceData.filter(y=>y[this.dimensions[0]]).map(y=>y[this.dimensions[0]])));let i;this.dimensions[0].includes("date")?i=a.map(y=>pe(y)):i=[...a];let c,d;((t=this.styleData)==null?void 0:t.horizontal)===!0?d=[...i]:c=[...i];const p=this.sourceData.filter(y=>parseFloat(y[this.dimensions[1]])&&y[this.dimensions[0]]).map(y=>parseFloat(y[this.dimensions[1]]));let u;return((r=this.styleData)==null?void 0:r.stack)!==!1?u=this.prepareStackData():((n=this.styleData)==null?void 0:n.negative_waterfall)===!0?u=this.prepareNegativeWaterfall():((o=this.styleData)==null?void 0:o.waterfall)===!0?u=this.prepareWaterfallData(p):((l=this.styleData)==null?void 0:l.accumulative)===!0?u=this.prepareAccumulative(p):u=this.dimensions.slice(1).map((m,f)=>({name:m,type:"bar",stack:`a${f}`,data:this.sourceData.filter(k=>parseFloat(k[m])&&m).map(k=>parseFloat(k[m]))})),{series:u,xs:c,ys:d}}catch(a){return console.error(a),{series:[],xs:[],ys:[]}}},prepareWaterfallData(s){let t=s.reduce((l,a)=>l+a,0);const r=[t,...s],n=r.map((l,a)=>{if(a===0)return 0;const i=t-l;return t-=l,i>=0?i:0});return[{type:"bar",stack:"Total",itemStyle:{borderColor:"transparent",color:"transparent"},data:n,tooltip:{show:!1}},{name:this.title?this.title:this.dimensions[0],type:"bar",stack:"Total",data:r}]},prepareStackData(){return this.dimensions.slice(1).map(r=>({name:r,type:"bar",stack:"a",data:this.sourceData.filter(n=>parseFloat(n[r])&&r).map(n=>parseFloat(n[r]))}))},prepareNegativeWaterfall(){const s=this.sourceData.map(l=>Number.isNaN(l[this.dimensions[1]])?0:Number(l[this.dimensions[1]])),t=this.sourceData.map(l=>Number.isNaN(l[this.dimensions[2]])?0:Number(l[this.dimensions[2]]));let r=0;const n=s.map((l,a)=>{const i=r;return r+=Number.isNaN(l)?0:l,a===0&&(r-=Number.isNaN(t[a])?0:t[a]),r-=Number.isNaN(t[a+1])?0:t[a+1],i>=0?i:0});return[{type:"bar",stack:"a",itemStyle:{borderColor:"transparent",color:"transparent"},data:n,tooltip:{show:!1}},{name:this.dimensions[1],type:"bar",stack:"a",data:s},{name:this.dimensions[2],type:"bar",stack:"a",data:t}]},prepareAccumulative(s){let t=0;const r=s.map(o=>(t+=o,t));return[{name:this.titleCharts,type:"bar",stack:"Total",data:r}]}}},So=["id"];function zo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full w-full min-h-[200px]"},null,8,So)}const Fe=L(No,[["render",zo]]),Lo=Object.freeze(Object.defineProperty({__proto__:null,default:Fe},Symbol.toStringTag,{value:"Module"})),We=typeof window<"u"?window.echarts:null,To={name:"VsPie",props:["currentWidget"],mixins:[j],data(){return{chartInstance:null,resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var r;await this.$nextTick(),await this.getData();const{series:s}=this.prepareData()||{};s&&this.initChart(s);const t=(r=this.$refs)==null?void 0:r.chart;t&&(this.resizeObserver=new ResizeObserver(()=>{this.chartInstance&&this.chartInstance.resize()}),this.resizeObserver.observe(t))},beforeUnmount(){var s;(s=this.resizeObserver)==null||s.disconnect()},methods:{onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&this.initChart(s,t,r)}}catch(s){console.error(s)}},buildTooltipForDonut(s,t){const{name:r,value:n,percent:o}=s;return`
203
203
  <div style="background-color:${t[0]}; font-size:12px; font-family:Helvetica, Arial, sans-serif; color:#ffff; padding:5px; border-radius:5px;">
204
- ${r==null?void 0:r.replace("null","Не визначено")}: ${v(n)} (${o}%)
205
- </div>`},prepareData(){var s,t,r,n,o,l;try{if(this.styleData=this.styleData||{},!((s=this.sourceData)!=null&&s.length))return console.warn("No source data available"),null;const a=Array.from(new Set((this.sourceData||[]).map(f=>f[this.dimensions[0]]))),i=Array.from(new Set((this.sourceData||[]).map(f=>f[this.dimensions[1]]))),c=parseInt((this.sourceData||[]).reduce((f,k)=>f+parseFloat((k==null?void 0:k.metric)||0),0),10),d=a.map((f,k)=>{const _=(i[k]/c*100).toFixed(2);return{name:`${f} (${_}%)`,value:i[k]}}),p=((t=this.styleData)==null?void 0:t.innerRadius)||"80%",u=((r=this.styleData)==null?void 0:r.outerRadius)||"100%",y=[p,u];return this.styleData.legend=De.getLegendOpions({borderRadius:10,height:"100%",padding:10,bottom:"0",type:"scroll",itemWidth:14,itemHeight:14,formatter:f=>{var k;return(k=f==null?void 0:f.replace("null","Не визначено"))==null?void 0:k.replace("NaN","0.00")},...((n=this.styleData)==null?void 0:n.legend)||{}}),this.styleData.label=De.getLabelOptions((o=this.styleData)==null?void 0:o.label),this.styleData.show_legend=((l=this.styleData)==null?void 0:l.show_legend)??!0,{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"pie",radius:y,center:["50%","60%"],height:"75%",...K(this.styleData),data:d}]}}catch(a){return console.error("Error in prepareData:",a),null}},async initChart(s){var t,r;try{if(!s){console.warn("No series data available for chart initialization");return}const n=this.$refs.chart;if(!n){console.warn("Chart DOM element not found");return}if(this.chartInstance=je==null?void 0:je.init(n),!this.chartInstance)return;const o=parseInt((this.sourceData||[]).reduce((a,i)=>a+parseFloat((i==null?void 0:i.metric)||0),0),10),l={tooltip:{show:((r=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:r.show)!==!1,trigger:"item",confine:!0,formatter:a=>this.buildTooltipForDonut(a,[a.color]),borderWidth:0,appendToBody:!1,borderColor:"transparent",textStyle:{color:"#000"},padding:[15,15],shadowColor:"transparent",backgroundColor:"transparent"},series:s,...K(this.styleData||{}),title:{text:v(o),left:"center",top:"41%",textStyle:{color:"black",fontWeight:400,fontSize:"22px"}}};this.chartInstance.setOption(l),this.$emit("update:currentWidget",this.chartInstance),this.chartInstance.resize(),window.addEventListener("resize",()=>{var a;(a=this.chartInstance)==null||a.resize()})}catch(n){console.error("Error in initChart:",n)}}}},Fo=["id"];function Wo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full min-h-[200px] flex items-center"},null,8,Fo)}const Ct=z(Po,[["render",Wo]]),jo=Object.freeze(Object.defineProperty({__proto__:null,default:Ct},Symbol.toStringTag,{value:"Module"})),Oe=typeof window<"u"?window.echarts:null,Oo={name:"VsPie",props:["currentWidget"],mixins:[j],data(){return{chartInstance:null,resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var r;await this.$nextTick(),await this.getData();const{series:s}=this.prepareData()||{};s&&this.initChart(s);const t=(r=this.$refs)==null?void 0:r.chart;t&&(this.resizeObserver=new ResizeObserver(()=>{this.chartInstance&&this.chartInstance.resize()}),this.resizeObserver.observe(t))},unmounted(){var s;(s=this.resizeObserver)==null||s.disconnect()},methods:{onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&this.initChart(s,t,r)}}catch(s){console.error(s)}},buildTooltipForDonut(s,t){const{name:r,value:n,percent:o}=s;return`
204
+ ${r==null?void 0:r.replace("null","Не визначено")}: ${U(n)} (${o}%)
205
+ </div>`},prepareData(){var s,t,r,n,o,l;try{if(this.styleData=this.styleData||{},!((s=this.sourceData)!=null&&s.length))return console.warn("No source data available"),null;const a=Array.from(new Set((this.sourceData||[]).map(f=>f[this.dimensions[0]]))),i=Array.from(new Set((this.sourceData||[]).map(f=>f[this.dimensions[1]]))),c=parseInt((this.sourceData||[]).reduce((f,k)=>f+parseFloat((k==null?void 0:k.metric)||0),0),10),d=a.map((f,k)=>{const _=(i[k]/c*100).toFixed(2);return{name:`${f} (${_}%)`,value:i[k]}}),p=((t=this.styleData)==null?void 0:t.innerRadius)||"80%",u=((r=this.styleData)==null?void 0:r.outerRadius)||"100%",y=[p,u];return this.styleData.legend=Ve.getLegendOpions({borderRadius:10,height:"100%",padding:10,bottom:"0",type:"scroll",itemWidth:14,itemHeight:14,formatter:f=>{var k;return(k=f==null?void 0:f.replace("null","Не визначено"))==null?void 0:k.replace("NaN","0.00")},...((n=this.styleData)==null?void 0:n.legend)||{}}),this.styleData.label=Ve.getLabelOptions((o=this.styleData)==null?void 0:o.label),this.styleData.show_legend=((l=this.styleData)==null?void 0:l.show_legend)??!0,{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"pie",radius:y,center:["50%","60%"],height:"75%",...Y(this.styleData),data:d}]}}catch(a){return console.error("Error in prepareData:",a),null}},async initChart(s){var t,r;try{if(!s){console.warn("No series data available for chart initialization");return}const n=this.$refs.chart;if(!n){console.warn("Chart DOM element not found");return}if(this.chartInstance=We==null?void 0:We.init(n),!this.chartInstance)return;const o=parseInt((this.sourceData||[]).reduce((a,i)=>a+parseFloat((i==null?void 0:i.metric)||0),0),10),l={tooltip:{show:((r=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:r.show)!==!1,trigger:"item",confine:!0,formatter:a=>this.buildTooltipForDonut(a,[a.color]),borderWidth:0,appendToBody:!1,borderColor:"transparent",textStyle:{color:"#000"},padding:[15,15],shadowColor:"transparent",backgroundColor:"transparent"},series:s,...Y(this.styleData||{}),title:{text:U(o),left:"center",top:"41%",textStyle:{color:"black",fontWeight:400,fontSize:"22px"}}};this.chartInstance.setOption(l),this.$emit("update:currentWidget",this.chartInstance),this.chartInstance.resize(),window.addEventListener("resize",()=>{var a;(a=this.chartInstance)==null||a.resize()})}catch(n){console.error("Error in initChart:",n)}}}},Io=["id"];function Mo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full min-h-[200px] flex items-center"},null,8,Io)}const Vt=L(To,[["render",Mo]]),Ro=Object.freeze(Object.defineProperty({__proto__:null,default:Vt},Symbol.toStringTag,{value:"Module"})),je=typeof window<"u"?window.echarts:null,Po={name:"VsPie",props:["currentWidget"],mixins:[j],data(){return{chartInstance:null,resizeObserver:null}},computed:{uniqueID(){return this.widget}},async mounted(){var r;await this.$nextTick(),await this.getData();const{series:s}=this.prepareData()||{};s&&this.initChart(s);const t=(r=this.$refs)==null?void 0:r.chart;t&&(this.resizeObserver=new ResizeObserver(()=>{this.chartInstance&&this.chartInstance.resize()}),this.resizeObserver.observe(t))},unmounted(){var s;(s=this.resizeObserver)==null||s.disconnect()},methods:{onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&this.initChart(s,t,r)}}catch(s){console.error(s)}},buildTooltipForDonut(s,t){const{name:r,value:n,percent:o}=s;return`
206
206
  <div style="background-color:${t[0]}; font-size:12px; font-family:Helvetica, Arial, sans-serif; color:#ffff; padding:5px; border-radius:5px;">
207
- ${r==null?void 0:r.replace("null","Не визначено")}: ${v(n)} (${o}%)
208
- </div>`},prepareData(){var s,t,r,n,o;try{this.styleData=this.styleData||{};const l=Array.from(new Set((this.sourceData||[]).map(m=>m[this.dimensions[0]]))),a=Array.from(new Set((this.sourceData||[]).map(m=>m[this.dimensions[1]]))),i=parseInt((this.sourceData||[]).reduce((m,f)=>m+parseFloat(f==null?void 0:f.metric),0),10),c=l.map((m,f)=>{const k=(a[f]/i*100).toFixed(2);return{name:`${m} (${k}%)`,value:a[f]}}),d=((s=this.styleData)==null?void 0:s.innerRadius)||"0%",p=((t=this.styleData)==null?void 0:t.outerRadius)||"100%",u=[d,p];return this.styleData.legend=De.getLegendOpions({borderRadius:10,height:"100%",padding:10,type:"scroll",itemWidth:14,itemHeight:14,formatter:m=>m==null?void 0:m.replace("null","Не визначено"),textStyle:{fontSize:"14px"},...((r=this.styleData)==null?void 0:r.legend)||{}}),this.styleData.label=De.getLabelOptions((n=this.styleData)==null?void 0:n.label),this.styleData.show_legend=((o=this.styleData)==null?void 0:o.show_legend)??!0,{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"pie",radius:u,center:["50%","60%"],height:"75%",...K(this.styleData),data:c}]}}catch(l){return console.error("Error in prepareData:",l),null}},async initChart(s){var t,r;try{if(!s){console.warn("No series data available for chart initialization");return}const n=this.$refs.chart;if(!n){console.warn("Chart DOM element not found");return}if(this.chartInstance=Oe==null?void 0:Oe.init(n),!this.chartInstance)return;const o={tooltip:{show:((r=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:r.show)!==!1,trigger:"item",confine:!0,formatter:l=>this.buildTooltipForDonut(l,[l.color]),borderWidth:0,appendToBody:!1,borderColor:"transparent",textStyle:{color:"#000"},padding:[15,15],shadowColor:"transparent",backgroundColor:"transparent"},series:s,...K(this.styleData||{})};this.chartInstance.setOption(o),this.$emit("update:currentWidget",this.chartInstance),this.chartInstance.resize(),window.addEventListener("resize",()=>{var l;(l=this.chartInstance)==null||l.resize()})}catch(n){console.error("Error in initChart:",n)}}}},Ao=["id"];function qo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full min-h-[200px] flex items-center"},null,8,Ao)}const Nt=z(Oo,[["render",qo]]),vo=Object.freeze(Object.defineProperty({__proto__:null,default:Nt},Symbol.toStringTag,{value:"Module"})),Uo={name:"VsLine",mixins:[j],data(){return{chartInstance:null,uniqueID:null}},async mounted(){this.uniqueID=this.widget,await this.$nextTick(),await this.getData();const{series:s,xs:t}=this.prepareData();s&&this.initChart(s,t)},methods:{onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&(this==null||this.initChart(s,t,r))}}catch(s){console.error(s)}},prepareData(){var s,t;try{const r=Array.from(new Set(this.sourceData.map(a=>a[this.dimensions[0]])));let n;this.dimensions[0].includes("date")?n=r.map(a=>he(a)):n=[...r];const o=this.sourceData.map(a=>parseFloat(a[this.dimensions[1]]));let l;return(s=this.styleData)!=null&&s.stack?l=this.dimensions.slice(1).map(i=>({name:i,type:"line",stack:"a",areaStyle:this.styleData.area?{}:null,data:this.sourceData.filter(c=>parseFloat(c[i])).map(c=>parseFloat(c[i]))})):l=[{name:this.title,type:"line",areaStyle:(t=this.styleData)!=null&&t.area?{}:null,data:o,stack:"a"}],{series:l,xs:n}}catch(r){return console.error(r),null}}}},Ho=["id"];function Go(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:o.uniqueID,ref:"chart",style:{height:"400px"}},null,8,Ho)}const St=z(Uo,[["render",Go]]),Zo=Object.freeze(Object.defineProperty({__proto__:null,default:St},Symbol.toStringTag,{value:"Module"})),Qo={name:"VsStat",mixins:[j],data(){return{restDimensions:[],sumValue:0,columns:null,showTooltip:-1}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){this.columns=Object.keys(this.sourceData[0]);const s=this.getValues();this.sumValue=s.reduce((t,r)=>t+r,0),this.sourceData.forEach((t,r)=>{t.color=r<Dt.length-1?Dt[r]:Lo()})},formattedValue(s){const t=parseFloat(s);return v(t)}}},Xo={class:"flex flex-col w-full h-full pt-[16px] rounded-xl"},Jo={class:"flex flex-col justify-between w-full h-full"},Ko={class:"w-full h-full pb-6 space-y-4"},Yo={class:"flex w-full h-3 rounded-full gap-x-1 min-h-3 custom-x-scrollbar"},ea=["onMouseover"],ta={key:0,class:"absolute top-[-1] left-1/2 transform -translate-x-1/2 -translate-y-full bg-black text-white rounded px-2 py-1"},sa={class:"h-[calc(100%-20px)] w-full custom-scrollbar"},ra={class:"grid items-center justify-between grid-cols-2 py-2 gap-x-4"},na={class:"flex items-center"},oa={class:"text-sm text-gray-800"},aa={class:"text-end"},la={class:"text-sm text-gray-500"};function ia(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Xo,[e.createElementVNode("div",Jo,[e.createElementVNode("div",Ko,[e.createElementVNode("div",Yo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>{var c,d,p,u;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex flex-col min-w-[5px] justify-center min-h-2.5 h-2.5 text-xs text-white text-center whitespace-nowrap",`bg-[${a.color}]`]),style:e.normalizeStyle({width:`${parseFloat(a==null?void 0:a[(c=o.columns)==null?void 0:c[1]])/o.sumValue*100}%`}),role:"progressbar","aria-valuenow":"42","aria-valuemin":"0","aria-valuemax":"100",onMouseover:y=>o.showTooltip=i,onMouseleave:t[0]||(t[0]=y=>o.showTooltip=-1)},[o.showTooltip>-1?(e.openBlock(),e.createElementBlock("div",ta,e.toDisplayString(s.sourceData[o.showTooltip][o.columns[0]])+" "+e.toDisplayString((parseFloat((u=(d=s.sourceData)==null?void 0:d[o.showTooltip])==null?void 0:u[(p=o.columns)==null?void 0:p[1]])/o.sumValue*100).toFixed(2))+"% ",1)):e.createCommentVNode("",!0)],46,ea)}),256))]),e.createElementVNode("ul",sa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,a=>{var i,c;return e.openBlock(),e.createElementBlock("li",ra,[e.createElementVNode("div",na,[e.createElementVNode("span",{class:e.normalizeClass(["shrink-0 size-2.5 inline-block rounded-sm me-2.5 min-w-[10px] w-[10px] h-[10px] min-h-[10px]",`bg-[${a.color}]`])},null,2),e.createElementVNode("span",oa,e.toDisplayString((a==null?void 0:a[(i=o.columns)==null?void 0:i[0]])||"Не визначено"),1)]),e.createElementVNode("div",aa,[e.createElementVNode("span",la,e.toDisplayString(l.formattedValue(a==null?void 0:a[(c=o.columns)==null?void 0:c[1]])||"-"),1)])])}),256))])])])])}const zt=z(Qo,[["render",ia]]),ca=Object.freeze(Object.defineProperty({__proto__:null,default:zt},Symbol.toStringTag,{value:"Module"})),da={name:"VsProgressBar",mixins:[j],data(){return{restDimensions:[],maxValue:0,columns:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){var t;this.columns=Object.keys((t=this.sourceData)==null?void 0:t[0])||null;const s=this.getValues();this.maxValue=Math.max(...s)},formattedValue(s){return v(s)}}},pa={key:0,class:"flex flex-col h-full pt-[16px] rounded-xl"},ha={class:"h-full pt-0 pb-6 space-y-4"},ua={class:"h-full space-y-4 custom-scrollbar"},ma={class:"flex items-center justify-between mr-2 gap-x-2"},fa={class:"grid items-center w-full grid-cols-2 gap-x-2"},ga={class:"text-sm text-gray-800"},ba={class:"flex justify-end",role:"progressbar","aria-valuenow":"100","aria-valuemin":"0","aria-valuemax":"100"},ya={class:"min-w-[60px] text-end"},xa={class:"text-sm text-gray-500"};function ka(s,t,r,n,o,l){return o.columns?(e.openBlock(),e.createElementBlock("div",pa,[e.createElementVNode("div",ha,[e.createElementVNode("ul",ua,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>(e.openBlock(),e.createElementBlock("li",ma,[e.createElementVNode("div",fa,[e.createElementVNode("span",ga,e.toDisplayString(a[o.columns[0]]),1),e.createElementVNode("div",ba,[e.createElementVNode("div",{class:"h-1.5 flex flex-col justify-center overflow-hidden bg-indigo-500 rounded-full text-xs text-white text-center whitespace-nowrap",style:e.normalizeStyle({width:`${parseFloat(a[o.columns[1]])/o.maxValue*100}%`})},null,4)])]),e.createElementVNode("div",ya,[e.createElementVNode("span",xa,e.toDisplayString(l.formattedValue(a[o.columns[1]])),1)])]))),256))])])])):e.createCommentVNode("",!0)}const Lt=z(da,[["render",ka]]),wa=Object.freeze(Object.defineProperty({__proto__:null,default:Lt},Symbol.toStringTag,{value:"Module"})),_a={name:"VsListbar",mixins:[j],props:["source"],data(){return{restDimensions:[],maxValue:0,columns:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch(s){console.error(s)}},prepareData(){var t,r,n;this.columns=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{});const s=(r=this.sourceData)==null?void 0:r.map(o=>{var l;return o==null?void 0:o[(l=this.columns)==null?void 0:l[1]]});this.maxValue=Math.max(...s||[]),this.restDimensions=(n=this.columns)==null?void 0:n.filter((o,l)=>l!==0)},formattedValue(s){return v(s)},getWidth(s){return`${s/this.maxValue*100}%`}}},$a={class:"h-full pt-[20px] list-bar"},Ea={class:"space-y-2 custom-scrollbar h-full h-[calc(100%-20px)]"},Ba={class:"relative w-full truncate"},Va={class:"relative z-[1] text-sm block py-1 px-2 w-full text-sm truncate text-gray-800"},Da={class:"text-[14px] text-gray-500"};function Ca(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",$a,[e.createElementVNode("ul",Ea,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>{var c,d,p;return e.openBlock(),e.createElementBlock("li",{key:i,class:"flex items-center justify-between w-full gap-x-2"},[e.createElementVNode("div",Ba,[e.createElementVNode("span",Va,e.toDisplayString((a==null?void 0:a[(c=o.columns)==null?void 0:c[0]])||"Без категорії"),1),e.createElementVNode("div",{class:e.normalizeClass(["absolute inset-y-0 h-full rounded start-0",a!=null&&a[(d=o.columns)==null?void 0:d[0]]?"bg-indigo-100":"bg-gray-100"]),style:e.normalizeStyle({width:l.getWidth(a==null?void 0:a[(p=o.columns)==null?void 0:p[1]])})},null,6)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.restDimensions,(u,y)=>(e.openBlock(),e.createElementBlock("div",{key:y,class:"w-20 mr-2 text-end"},[e.createElementVNode("span",Da,e.toDisplayString(l.formattedValue(a==null?void 0:a[u])),1)]))),128))])}),128))])])}const Tt=z(_a,[["render",Ca]]),Na=Object.freeze(Object.defineProperty({__proto__:null,default:Tt},Symbol.toStringTag,{value:"Module"})),Sa={name:"VsPivotTable",mixins:[j],data(){return{values:null,xs:null,products:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){try{const s=Array.from(new Set(this.sourceData.map(t=>t[this.dimensions[0]])));this.dimensions[0].includes("date")?this.xs=s.map(t=>he(t)):this.xs=[...s],this.products=this.dimensions.filter((t,r)=>r!=0),this.values=this.products.map((t,r)=>({name:t,data:this.sourceData.filter(n=>parseFloat(n[t])).map(n=>v(parseFloat(n[t])))}))}catch(s){console.error(s)}}}},za={class:"flex flex-col h-full p-5 space-y-4 rounded-xl custom-scrollbar"},La={class:"overflow-x-auto [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 custom-scrollbar"},Ta={class:"inline-block min-w-full align-middle"},Ia={class:"min-w-full divide-y divide-gray-200"},Ma={class:"space-x-2"},Ra={scope:"col",class:"xl:min-w-[120px] min-w-48"},Pa={class:"py-2.5 text-text-start flex items-center gap-x-1 text-sm font-normal text-gray-500"},Fa={class:"divide-y divide-gray-200 text-[12px]"},Wa={class:"py-3 size-px whitespace-nowrap"},ja={class:"flex items-center gap-x-3"},Oa={class:"font-medium text-gray-800"},Aa={class:"py-3 size-px whitespace-nowrap"},qa={class:"text-gray-600"};function va(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",za,[e.createElementVNode("div",La,[e.createElementVNode("div",Ta,[e.createElementVNode("table",Ia,[e.createElementVNode("thead",null,[e.createElementVNode("tr",Ma,[t[0]||(t[0]=e.createElementVNode("th",{scope:"col",class:"min-w-[200px]"},[e.createElementVNode("div",{class:"py-2.5 text-text-start flex items-center gap-x-1 text-sm font-normal text-gray-500"})],-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.xs,a=>(e.openBlock(),e.createElementBlock("th",Ra,[e.createElementVNode("div",Pa,e.toDisplayString(a),1)]))),256))])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.values,a=>(e.openBlock(),e.createElementBlock("tbody",Fa,[e.createElementVNode("tr",null,[e.createElementVNode("td",Wa,[e.createElementVNode("div",ja,[e.createElementVNode("span",Oa,e.toDisplayString(a.name),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.xs,(i,c)=>(e.openBlock(),e.createElementBlock("td",Aa,[e.createElementVNode("span",qa,e.toDisplayString(a.data[c]),1)]))),256))])]))),256))])])])])}const It=z(Sa,[["render",va]]),Ua=Object.freeze(Object.defineProperty({__proto__:null,default:It},Symbol.toStringTag,{value:"Module"})),Ha={name:"VsNumber",mixins:[j],data(){return{number:""}},computed:{formattedNumber(){return No(this.number)},prefix(){var s,t;return(s=this.styleData)!=null&&s.prefix?(t=this.styleData)==null?void 0:t.prefix:""}},watch:{sourceData:{async handler(){this.getNumber()},deep:!0}},async mounted(){await this.getData(),this.getNumber()},methods:{onChangedData(){try{this.sourceData&&this.getNumber()}catch(s){console.error(s)}},async getNumber(){var s,t;try{this.number=((t=this.sourceData[0])==null?void 0:t[Object.keys((s=this.sourceData)==null?void 0:s[0])])||0}catch(r){console.error(r)}}}},Ga={class:"text-lg lg:text-xl xl:text-2xl text-gray-800 h-[32px] flex items-center"};function Za(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Ga,e.toDisplayString(l.prefix)+e.toDisplayString(l.formattedNumber),1)}const Qa=Object.freeze(Object.defineProperty({__proto__:null,default:z(Ha,[["render",Za]])},Symbol.toStringTag,{value:"Module"})),Xa={name:"VsText",mixins:[j],props:{widget:{type:String,required:!0},widgetData:{type:Object,required:!0}},data(){return{markedText:null,uniqueID:null}},async mounted(){var s,t;this.uniqueID=this.widget;try{await this.getData(),this.markedText=S(((s=this.widgetData)==null?void 0:s.text)||((t=this.widgetData)==null?void 0:t.source))}catch(r){console.error(r)}},methods:{onChangedData(){return null}}},Ja=["id"],Ka=["innerHTML"];function Ya(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:o.uniqueID,class:"relative select-auto h-full rounded-xl text-[12px] box-border bg-white custom-scrollbar text-widget"},[o.markedText?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:o.markedText},null,8,Ka)):e.createCommentVNode("",!0)],8,Ja)}const el=Object.freeze(Object.defineProperty({__proto__:null,default:z(Xa,[["render",Ya]])},Symbol.toStringTag,{value:"Module"})),Ae=typeof window<"u"?window.echarts:null,tl={name:"VsFunnelBar",mixins:[j],data(){return{chartInstance:null,uniqueID:null}},async mounted(){this.uniqueID=this.widget,await this.$nextTick(),await this.getData();const{series:s}=this.prepareData();s&&this.initChart(s)},methods:{buildTooltipForDonut(s,t){const{name:r,value:n,percent:o}=s;return`
207
+ ${r==null?void 0:r.replace("null","Не визначено")}: ${U(n)} (${o}%)
208
+ </div>`},prepareData(){var s,t,r,n,o;try{this.styleData=this.styleData||{};const l=Array.from(new Set((this.sourceData||[]).map(m=>m[this.dimensions[0]]))),a=Array.from(new Set((this.sourceData||[]).map(m=>m[this.dimensions[1]]))),i=parseInt((this.sourceData||[]).reduce((m,f)=>m+parseFloat(f==null?void 0:f.metric),0),10),c=l.map((m,f)=>{const k=(a[f]/i*100).toFixed(2);return{name:`${m} (${k}%)`,value:a[f]}}),d=((s=this.styleData)==null?void 0:s.innerRadius)||"0%",p=((t=this.styleData)==null?void 0:t.outerRadius)||"100%",u=[d,p];return this.styleData.legend=Ve.getLegendOpions({borderRadius:10,height:"100%",padding:10,type:"scroll",itemWidth:14,itemHeight:14,formatter:m=>m==null?void 0:m.replace("null","Не визначено"),textStyle:{fontSize:"14px"},...((r=this.styleData)==null?void 0:r.legend)||{}}),this.styleData.label=Ve.getLabelOptions((n=this.styleData)==null?void 0:n.label),this.styleData.show_legend=((o=this.styleData)==null?void 0:o.show_legend)??!0,{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"pie",radius:u,center:["50%","60%"],height:"75%",...Y(this.styleData),data:c}]}}catch(l){return console.error("Error in prepareData:",l),null}},async initChart(s){var t,r;try{if(!s){console.warn("No series data available for chart initialization");return}const n=this.$refs.chart;if(!n){console.warn("Chart DOM element not found");return}if(this.chartInstance=je==null?void 0:je.init(n),!this.chartInstance)return;const o={tooltip:{show:((r=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:r.show)!==!1,trigger:"item",confine:!0,formatter:l=>this.buildTooltipForDonut(l,[l.color]),borderWidth:0,appendToBody:!1,borderColor:"transparent",textStyle:{color:"#000"},padding:[15,15],shadowColor:"transparent",backgroundColor:"transparent"},series:s,...Y(this.styleData||{})};this.chartInstance.setOption(o),this.$emit("update:currentWidget",this.chartInstance),this.chartInstance.resize(),window.addEventListener("resize",()=>{var l;(l=this.chartInstance)==null||l.resize()})}catch(n){console.error("Error in initChart:",n)}}}},Fo=["id"];function Wo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:l.uniqueID,ref:"chart",class:"h-full min-h-[200px] flex items-center"},null,8,Fo)}const Dt=L(Po,[["render",Wo]]),jo=Object.freeze(Object.defineProperty({__proto__:null,default:Dt},Symbol.toStringTag,{value:"Module"})),Ao={name:"VsLine",mixins:[j],data(){return{chartInstance:null,uniqueID:null}},async mounted(){this.uniqueID=this.widget,await this.$nextTick(),await this.getData();const{series:s,xs:t}=this.prepareData();s&&this.initChart(s,t)},methods:{onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&(this==null||this.initChart(s,t,r))}}catch(s){console.error(s)}},prepareData(){var s,t;try{const r=Array.from(new Set(this.sourceData.map(a=>a[this.dimensions[0]])));let n;this.dimensions[0].includes("date")?n=r.map(a=>pe(a)):n=[...r];const o=this.sourceData.map(a=>parseFloat(a[this.dimensions[1]]));let l;return(s=this.styleData)!=null&&s.stack?l=this.dimensions.slice(1).map(i=>({name:i,type:"line",stack:"a",areaStyle:this.styleData.area?{}:null,data:this.sourceData.filter(c=>parseFloat(c[i])).map(c=>parseFloat(c[i]))})):l=[{name:this.title,type:"line",areaStyle:(t=this.styleData)!=null&&t.area?{}:null,data:o,stack:"a"}],{series:l,xs:n}}catch(r){return console.error(r),null}}}},Oo=["id"];function qo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:o.uniqueID,ref:"chart",style:{height:"400px"}},null,8,Oo)}const Ct=L(Ao,[["render",qo]]),vo=Object.freeze(Object.defineProperty({__proto__:null,default:Ct},Symbol.toStringTag,{value:"Module"})),Uo={name:"VsStat",mixins:[j],data(){return{restDimensions:[],sumValue:0,columns:null,showTooltip:-1}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){this.columns=Object.keys(this.sourceData[0]);const s=this.getValues();this.sumValue=s.reduce((t,r)=>t+r,0),this.sourceData.forEach((t,r)=>{t.color=r<Bt.length-1?Bt[r]:Co()})},formattedValue(s){const t=parseFloat(s);return U(t)}}},Ho={class:"flex flex-col w-full h-full pt-[16px] rounded-xl"},Go={class:"flex flex-col justify-between w-full h-full"},Zo={class:"w-full h-full pb-6 space-y-4"},Qo={class:"flex w-full h-3 rounded-full gap-x-1 min-h-3 custom-x-scrollbar"},Xo=["onMouseover"],Jo={key:0,class:"absolute top-[-1] left-1/2 transform -translate-x-1/2 -translate-y-full bg-black text-white rounded px-2 py-1"},Ko={class:"h-[calc(100%-20px)] w-full custom-scrollbar"},Yo={class:"grid items-center justify-between grid-cols-2 py-2 gap-x-4"},ea={class:"flex items-center"},ta={class:"text-sm text-gray-800"},sa={class:"text-end"},ra={class:"text-sm text-gray-500"};function na(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Ho,[e.createElementVNode("div",Go,[e.createElementVNode("div",Zo,[e.createElementVNode("div",Qo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>{var c,d,p,u;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex flex-col min-w-[5px] justify-center min-h-2.5 h-2.5 text-xs text-white text-center whitespace-nowrap",`bg-[${a.color}]`]),style:e.normalizeStyle({width:`${parseFloat(a==null?void 0:a[(c=o.columns)==null?void 0:c[1]])/o.sumValue*100}%`}),role:"progressbar","aria-valuenow":"42","aria-valuemin":"0","aria-valuemax":"100",onMouseover:y=>o.showTooltip=i,onMouseleave:t[0]||(t[0]=y=>o.showTooltip=-1)},[o.showTooltip>-1?(e.openBlock(),e.createElementBlock("div",Jo,e.toDisplayString(s.sourceData[o.showTooltip][o.columns[0]])+" "+e.toDisplayString((parseFloat((u=(d=s.sourceData)==null?void 0:d[o.showTooltip])==null?void 0:u[(p=o.columns)==null?void 0:p[1]])/o.sumValue*100).toFixed(2))+"% ",1)):e.createCommentVNode("",!0)],46,Xo)}),256))]),e.createElementVNode("ul",Ko,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,a=>{var i,c;return e.openBlock(),e.createElementBlock("li",Yo,[e.createElementVNode("div",ea,[e.createElementVNode("span",{class:e.normalizeClass(["shrink-0 size-2.5 inline-block rounded-sm me-2.5 min-w-[10px] w-[10px] h-[10px] min-h-[10px]",`bg-[${a.color}]`])},null,2),e.createElementVNode("span",ta,e.toDisplayString((a==null?void 0:a[(i=o.columns)==null?void 0:i[0]])||"Не визначено"),1)]),e.createElementVNode("div",sa,[e.createElementVNode("span",ra,e.toDisplayString(l.formattedValue(a==null?void 0:a[(c=o.columns)==null?void 0:c[1]])||"-"),1)])])}),256))])])])])}const Nt=L(Uo,[["render",na]]),oa=Object.freeze(Object.defineProperty({__proto__:null,default:Nt},Symbol.toStringTag,{value:"Module"})),aa={name:"VsProgressBar",mixins:[j],data(){return{restDimensions:[],maxValue:0,columns:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){var t;this.columns=Object.keys((t=this.sourceData)==null?void 0:t[0])||null;const s=this.getValues();this.maxValue=Math.max(...s)},formattedValue(s){return U(s)}}},la={key:0,class:"flex flex-col h-full pt-[16px] rounded-xl"},ia={class:"h-full pt-0 pb-6 space-y-4"},ca={class:"h-full space-y-4 custom-scrollbar"},da={class:"flex items-center justify-between mr-2 gap-x-2"},pa={class:"grid items-center w-full grid-cols-2 gap-x-2"},ha={class:"text-sm text-gray-800"},ua={class:"flex justify-end",role:"progressbar","aria-valuenow":"100","aria-valuemin":"0","aria-valuemax":"100"},ma={class:"min-w-[60px] text-end"},fa={class:"text-sm text-gray-500"};function ga(s,t,r,n,o,l){return o.columns?(e.openBlock(),e.createElementBlock("div",la,[e.createElementVNode("div",ia,[e.createElementVNode("ul",ca,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>(e.openBlock(),e.createElementBlock("li",da,[e.createElementVNode("div",pa,[e.createElementVNode("span",ha,e.toDisplayString(a[o.columns[0]]),1),e.createElementVNode("div",ua,[e.createElementVNode("div",{class:"h-1.5 flex flex-col justify-center overflow-hidden bg-indigo-500 rounded-full text-xs text-white text-center whitespace-nowrap",style:e.normalizeStyle({width:`${parseFloat(a[o.columns[1]])/o.maxValue*100}%`})},null,4)])]),e.createElementVNode("div",ma,[e.createElementVNode("span",fa,e.toDisplayString(l.formattedValue(a[o.columns[1]])),1)])]))),256))])])])):e.createCommentVNode("",!0)}const St=L(aa,[["render",ga]]),ba=Object.freeze(Object.defineProperty({__proto__:null,default:St},Symbol.toStringTag,{value:"Module"})),ya={name:"VsListbar",mixins:[j],props:["source"],data(){return{restDimensions:[],maxValue:0,columns:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch(s){console.error(s)}},prepareData(){var t,r,n;this.columns=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{});const s=(r=this.sourceData)==null?void 0:r.map(o=>{var l;return o==null?void 0:o[(l=this.columns)==null?void 0:l[1]]});this.maxValue=Math.max(...s||[]),this.restDimensions=(n=this.columns)==null?void 0:n.filter((o,l)=>l!==0)},formattedValue(s){return U(s)},getWidth(s){return`${s/this.maxValue*100}%`}}},xa={class:"h-full pt-[20px] list-bar"},ka={class:"space-y-2 custom-scrollbar h-full h-[calc(100%-20px)]"},wa={class:"relative w-full truncate"},_a={class:"relative z-[1] text-sm block py-1 px-2 w-full text-sm truncate text-gray-800"},$a={class:"text-[14px] text-gray-500"};function Ea(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",xa,[e.createElementVNode("ul",ka,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>{var c,d,p;return e.openBlock(),e.createElementBlock("li",{key:i,class:"flex items-center justify-between w-full gap-x-2"},[e.createElementVNode("div",wa,[e.createElementVNode("span",_a,e.toDisplayString((a==null?void 0:a[(c=o.columns)==null?void 0:c[0]])||"Без категорії"),1),e.createElementVNode("div",{class:e.normalizeClass(["absolute inset-y-0 h-full rounded start-0",a!=null&&a[(d=o.columns)==null?void 0:d[0]]?"bg-indigo-100":"bg-gray-100"]),style:e.normalizeStyle({width:l.getWidth(a==null?void 0:a[(p=o.columns)==null?void 0:p[1]])})},null,6)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.restDimensions,(u,y)=>(e.openBlock(),e.createElementBlock("div",{key:y,class:"w-20 mr-2 text-end"},[e.createElementVNode("span",$a,e.toDisplayString(l.formattedValue(a==null?void 0:a[u])),1)]))),128))])}),128))])])}const zt=L(ya,[["render",Ea]]),Ba=Object.freeze(Object.defineProperty({__proto__:null,default:zt},Symbol.toStringTag,{value:"Module"})),Va={name:"VsPivotTable",mixins:[j],data(){return{values:null,xs:null,products:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){try{const s=Array.from(new Set(this.sourceData.map(t=>t[this.dimensions[0]])));this.dimensions[0].includes("date")?this.xs=s.map(t=>pe(t)):this.xs=[...s],this.products=this.dimensions.filter((t,r)=>r!=0),this.values=this.products.map((t,r)=>({name:t,data:this.sourceData.filter(n=>parseFloat(n[t])).map(n=>U(parseFloat(n[t])))}))}catch(s){console.error(s)}}}},Da={class:"flex flex-col h-full p-5 space-y-4 rounded-xl custom-scrollbar"},Ca={class:"overflow-x-auto [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 custom-scrollbar"},Na={class:"inline-block min-w-full align-middle"},Sa={class:"min-w-full divide-y divide-gray-200"},za={class:"space-x-2"},La={scope:"col",class:"xl:min-w-[120px] min-w-48"},Ta={class:"py-2.5 text-text-start flex items-center gap-x-1 text-sm font-normal text-gray-500"},Ia={class:"divide-y divide-gray-200 text-[12px]"},Ma={class:"py-3 size-px whitespace-nowrap"},Ra={class:"flex items-center gap-x-3"},Pa={class:"font-medium text-gray-800"},Fa={class:"py-3 size-px whitespace-nowrap"},Wa={class:"text-gray-600"};function ja(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Da,[e.createElementVNode("div",Ca,[e.createElementVNode("div",Na,[e.createElementVNode("table",Sa,[e.createElementVNode("thead",null,[e.createElementVNode("tr",za,[t[0]||(t[0]=e.createElementVNode("th",{scope:"col",class:"min-w-[200px]"},[e.createElementVNode("div",{class:"py-2.5 text-text-start flex items-center gap-x-1 text-sm font-normal text-gray-500"})],-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.xs,a=>(e.openBlock(),e.createElementBlock("th",La,[e.createElementVNode("div",Ta,e.toDisplayString(a),1)]))),256))])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.values,a=>(e.openBlock(),e.createElementBlock("tbody",Ia,[e.createElementVNode("tr",null,[e.createElementVNode("td",Ma,[e.createElementVNode("div",Ra,[e.createElementVNode("span",Pa,e.toDisplayString(a.name),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.xs,(i,c)=>(e.openBlock(),e.createElementBlock("td",Fa,[e.createElementVNode("span",Wa,e.toDisplayString(a.data[c]),1)]))),256))])]))),256))])])])])}const Lt=L(Va,[["render",ja]]),Aa=Object.freeze(Object.defineProperty({__proto__:null,default:Lt},Symbol.toStringTag,{value:"Module"})),Oa={name:"VsNumber",mixins:[j],data(){return{number:""}},computed:{formattedNumber(){return Bo(this.number)},prefix(){var s,t;return(s=this.styleData)!=null&&s.prefix?(t=this.styleData)==null?void 0:t.prefix:""}},watch:{sourceData:{async handler(){this.getNumber()},deep:!0}},async mounted(){await this.getData(),this.getNumber()},methods:{onChangedData(){try{this.sourceData&&this.getNumber()}catch(s){console.error(s)}},async getNumber(){var s,t;try{this.number=((t=this.sourceData[0])==null?void 0:t[Object.keys((s=this.sourceData)==null?void 0:s[0])])||0}catch(r){console.error(r)}}}},qa={class:"text-lg lg:text-xl xl:text-2xl text-gray-800 h-[32px] flex items-center"};function va(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",qa,e.toDisplayString(l.prefix)+e.toDisplayString(l.formattedNumber),1)}const Ua=Object.freeze(Object.defineProperty({__proto__:null,default:L(Oa,[["render",va]])},Symbol.toStringTag,{value:"Module"})),Ha={name:"VsText",mixins:[j],props:{widget:{type:String,required:!0},widgetData:{type:Object,required:!0}},data(){return{markedText:null,uniqueID:null}},async mounted(){var s,t;this.uniqueID=this.widget;try{await this.getData(),this.markedText=S(((s=this.widgetData)==null?void 0:s.text)||((t=this.widgetData)==null?void 0:t.source))}catch(r){console.error(r)}},methods:{onChangedData(){return null}}},Ga=["id"],Za=["innerHTML"];function Qa(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:o.uniqueID,class:"relative select-auto h-full rounded-xl text-[12px] box-border bg-white custom-scrollbar text-widget"},[o.markedText?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:o.markedText},null,8,Za)):e.createCommentVNode("",!0)],8,Ga)}const Xa=Object.freeze(Object.defineProperty({__proto__:null,default:L(Ha,[["render",Qa]])},Symbol.toStringTag,{value:"Module"})),Ae=typeof window<"u"?window.echarts:null,Ja={name:"VsFunnelBar",mixins:[j],data(){return{chartInstance:null,uniqueID:null}},async mounted(){this.uniqueID=this.widget,await this.$nextTick(),await this.getData();const{series:s}=this.prepareData();s&&this.initChart(s)},methods:{buildTooltipForDonut(s,t){const{name:r,value:n,percent:o}=s;return`
209
209
  <div style="background-color:${t[0]};font-size: 12px; font-family: Helvetica, Arial, sans-serif;color:#ffff; padding:5px; border-radius:5px; ![box-shadow:none]">
210
- ${he(r)}: ${v(n)} (${o}%)
211
- </div>`},onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&(this==null||this.initChart(s,t,r))}}catch{}},prepareData(){try{const s=Array.from(new Set(this.sourceData.map(o=>o[this.dimensions[0]]))),t=Array.from(new Set(this.sourceData.map(o=>o[this.dimensions[1]]))),r=s.map((o,l)=>({name:o,value:t[l]}));return{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"funnel",...K(this.styleData),data:r,height:"80%",emphasis:{label:{show:!1}}}]}}catch(s){console.error(s)}},async initChart(s){var t,r;try{const n=this.$refs.chart,o=Ae==null?void 0:Ae.init(n);if(!o)return;const l={series:s,...K(this.styleData),tooltip:{show:((r=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:r.show)!==!1,trigger:"item",confine:!0,formatter:a=>this.buildTooltipForDonut(a,[a.color]),borderWidth:0,appendToBody:!1,borderColor:"transparent",textStyle:{color:"#000"},padding:[10,15],shadowColor:"transparent",backgroundColor:"transparent"},itemStyle:{height:"15px"},legend:{borderRadius:10,type:"scroll",itemWidth:14,itemHeight:14,...this.styleData.legend},labelLine:{show:!1},grid:{bottom:"0"}};o.setOption(l),o.resize(),window.addEventListener("resize",()=>{o.resize()})}catch(n){console.error(n)}}}},sl=["id"];function rl(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{ref:"chart",id:o.uniqueID,class:"h-[90%] custom-scrollbar min-h-[200px]"},null,8,sl)}const nl=Object.freeze(Object.defineProperty({__proto__:null,default:z(tl,[["render",rl]])},Symbol.toStringTag,{value:"Module"}));function ol(s){return[{type:"fill",paint:{"fill-color":s.color||"#ccc","fill-outline-color":s.color||"blue","fill-opacity":s.opacity||1}}]}function al(s){return[{type:"line",paint:{"line-color":s.color||"#ccc","line-opacity":s.opacity||1}}]}function ll(s){return[{type:"circle",paint:{"circle-radius":s.radius||6,"circle-stroke-color":s.stroke||"#ccc","circle-stroke-width":s.width||1,"circle-color":s.color||"blue"}}]}function Mt(s){if(!s)return null;const t=s.type||"point";return t==="polygon"?ol(s):t==="line"?al(s):ll(s)}const qe={data(){return{layerList:[],activeLayer:""}},computed:{interactiveSources(){return this.layerList.filter(s=>s==null?void 0:s.interactive).map(s=>s.id)}},methods:{moveLayer(s,t=this.map){t.getStyle().layers.forEach(r=>{r.id.match(s)&&t.moveLayer(r.id)})},async setVisible(s,t=!0,r=this.map){if(!s)return;const n=(s==null?void 0:s.id)||s,o=this.layerList.find(a=>a.id===s)||s;if(!(o!=null&&o.id))throw new Error("MixinError: Layer has no id");const l=r.getStyle().layers.filter(a=>a.id.match(n));l.forEach(a=>{r.setLayoutProperty(a.id,"visibility",t?"visible":"none")}),!l.length&&t&&await this.addLayer(o)},async addLayer(s,t=this==null?void 0:this.map){var o,l;const r=this.layerList.find(a=>a.id===s)||s;!this.map.getStyle()||this.map.getStyle().layers.find(a=>a.id===r.id)||(this.layerList.find(a=>a.id===r.id)||this.layerList.push(r),(r.service==="vtile"||r.service==="vector"||(o=r.url)!=null&&o.includes(".vmt"))&&this.addVtileLayer(r,t),r.service==="geojson"&&this.addGeoJsonLayer(r,t),((l=r.url)!=null&&l.includes(".png")||["tms","raster"].includes(r.service))&&await this.addRasterLayer(r,t))},async addRasterLayer(s,t=this==null?void 0:this.map){var r,n;t.getSource(s.id)||(await t.addSource(s.id,{type:"raster",tiles:[s==null?void 0:s.url],tileSize:256,...s!=null&&s.scheme?{scheme:s==null?void 0:s.scheme}:{}}),await t.addLayer({id:s.id,type:"raster",source:s.id,minzoom:0,maxzoom:(s==null?void 0:s.maxzoom)||22},s.basemap?(n=(r=this.map.getStyle().layers)==null?void 0:r[0])==null?void 0:n.id:null))},async addVtileLayer(s,t=this==null?void 0:this.map){var l;const r=["props","pointZoom"].filter(a=>s[a]).map(a=>`&${a}=${s[a]}`),n={type:"vector",tiles:[`${(l=s==null?void 0:s.url)!=null&&l.startsWith("http")?"":window.location.origin}${s==null?void 0:s.url}${r}`],minzoom:s.minzoom||3,maxzoom:s.maxzoom||24};t.addSource(s.id,n),(Mt(s.style)||s.layers||[]).forEach((a,i)=>{const c={...a,id:`${s.id}-${i}`,source:s.id,"source-layer":a["source-layer"]||s.source||s.id,maxzoom:+a.maxzoom||24,minzoom:+a.minzoom||0};t.addLayer(c)})},async addGeoJsonLayer(s,t=this.map){var o;const r=s.data||((o=s==null?void 0:s.url)!=null&&o.startsWith("http")?"":window.location.origin)+s.url;t.addSource(s.id,{type:"geojson",data:r}),(Mt(s.style)||s.layers||[]).forEach(l=>{const a={...l,source:s.id,id:l.id||s.id,maxzoom:+l.maxzoom||24,minzoom:+l.minzoom||0,type:l.type||"circle"};t.addLayer(a)})},setLayerData(s,t){this.layerList=this.layerList.map(r=>r.id===s?{...r,...t}:r)},async removeLayer(s,t=this.map){t.getSource(s)&&(await t.getStyle().layers.forEach(async r=>{r.source===s&&await t.removeLayer(r.id)}),await t.removeSource(s))},async setFilter(s,t){var o;const r=this.layerList.find(l=>l.id===s),n=await((o=this.map)==null?void 0:o.getSource(s));if(n&&r.service==="vtile"){await n.setTiles([`${window.location.origin}${r.url}${r.url.includes("?")?"&":"?"}filter=${t}${r.props?`&props=${r.props}`:""}`]);return}n&&r.service},async changeBaseLayer(s){const t=s!=null&&s.id?s:this.layerList.find(n=>n.id===s),{id:r}=t;if(r&&r!==this.activeLayer){if(this.activeLayer&&this.map.setLayoutProperty(this.activeLayer,"visibility","none"),this.activeLayer=r,this.map.getLayer(r)){this.map.setLayoutProperty(r,"visibility","visible");return}await this.addRasterLayer(t)}},async refreshLayer(s,t=this.map){await t.getStyle().layers.forEach(r=>{r.source===s&&t.removeLayer(r.id)}),await t.removeSource(s),this.setVisible(s)}}},il="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.js",cl="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.css";let Ce=null;function dl(s){return new Promise((t,r)=>{if(document.querySelector(`script[src="${s}"]`)){t();return}const n=document.createElement("script");n.src=s,n.onload=()=>t(),n.onerror=()=>r(new Error(`Failed to load ${s}`)),document.head.appendChild(n)})}function pl(s){return new Promise((t,r)=>{if(document.querySelector(`link[href="${s}"]`)){t();return}const n=document.createElement("link");n.rel="stylesheet",n.href=s,n.onload=()=>t(),n.onerror=()=>r(new Error(`Failed to load ${s}`)),document.head.appendChild(n)})}function Rt(){return typeof window>"u"?Promise.resolve(null):window.maplibregl?Promise.resolve(window.maplibregl):Ce||(Ce=pl(cl).then(()=>dl(il)).then(()=>window.maplibregl),Ce)}const ve={__name:"legend",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ws),e.mergeProps(t.$attrs,{size:24}),null,16))}},Ue={pink:["#fde7e2","#feafbe","#fd58a4","#d7038e","#86007b"],blue:["#f1eef6","#bdc9e1","#74a9cf","#2b8cbe","#045a8d"],green:["#edf8fb","#b2e2e2","#66c2a4","#2ca25f","#006d2c"],pink2:["#f1eef6","#d7b5d8","#df65b0","#dd1c77","#980043"],red:["#fef0d9","#fdcc8a","#fc8d59","#e34a33","#b30000"],teal:["#f6eff7","#bdc9e1","#67a9cf","#1c9099","#016c59"]},hl={components:{legendIcon:ve,closeIcon:Se},props:{mapId:{type:String},colors:{type:Array},sizes:{type:Array,default:()=>[]},cluster:{type:[Boolean,String]},color:{type:String,default:"gray"},colorTitle:{type:String},sizesTitle:{type:String},resizeItem:{type:[Boolean,String],default:!1},changeOpacityItem:{type:[Boolean,String],default:!1}},data(){return{isOpenLegend:!1,palette:Ue}},computed:{borderRadius(){return this.cluster?"rounded-sm":"rounded-full"},sortedSizes(){return[...this.sizes].sort((s,t)=>s-t)},maxWidht(){var r;const s=((r=this.sizes)==null?void 0:r.length)-1;return this.calcSize(s)}},methods:{sizeClass(s){return this.resizeItem?`h-[${this.calcSize(s)}] w-[${this.calcSize(s)}] ${this.borderRadius}`:`h-[18px] w-[18px] ${this.borderRadius}`},calcSize(s){return`${10+s*2}px`},getOpacity(s){return(s+1)/this.sortedSizes.length}}},ul={class:"w-full absolute max-w-[200px] bg-white border rounded-lg bottom-[10px] right-[50px]"},ml={class:"flex items-center justify-between border-b border-[#0000001A] px-2"},fl={class:"w-full flex flex-col gap-[8px] px-2 py-2 max-h-[200px] overflow-auto [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-gray-300 [&::-webkit-scrollbar-track]:bg-transparent"},gl={key:0,class:"flex flex-col w-full"},bl={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},yl={class:"flex flex-col gap-[6px]"},xl={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"},kl={key:1,class:"flex flex-col w-full"},wl={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},_l={class:"flex flex-col gap-[6px]"},$l={class:"flex flex-row items-center justify-start"},El={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"};function Bl(s,t,r,n,o,l){var c,d;const a=e.resolveComponent("legendIcon"),i=e.resolveComponent("closeIcon");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:"flex justify-center items-center rounded-md w-[32px] h-[32px] cursor-pointer bg-white p-1 border-[2px]",onClick:t[0]||(t[0]=p=>o.isOpenLegend=!o.isOpenLegend)},[e.createVNode(a)]),o.isOpenLegend?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:`#wrapper-${r.mapId}`},[e.createElementVNode("div",ul,[e.createElementVNode("div",ml,[t[2]||(t[2]=e.createElementVNode("h3",{class:"text-[16px] font-normal text-black"},"Легенда",-1)),e.createElementVNode("button",{type:"button",class:"inline-flex items-center text-sm font-medium text-gray-500 rounded-lg gap-x-2 focus:outline-none disabled:opacity-50 disabled:pointer-events-none dark:text-neutral-400 dark:hover:text-blue-500 dark:focus:text-blue-500",onClick:t[1]||(t[1]=p=>o.isOpenLegend=!1)},[e.createVNode(i,{class:"w-[20px]"})])]),e.createElementVNode("div",fl,[(c=r.colors)!=null&&c.length?(e.openBlock(),e.createElementBlock("div",gl,[r.colorTitle?(e.openBlock(),e.createElementBlock("h4",bl,e.toDisplayString(r.colorTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",yl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.colors,(p,u)=>(e.openBlock(),e.createElementBlock("div",{key:u,class:"flex items-center gap-[10px]"},[p.color?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-[12px] h-[12px] rounded-full",style:e.normalizeStyle({backgroundColor:p.color})},null,4)):e.createCommentVNode("",!0),e.createElementVNode("p",xl,e.toDisplayString(p.text||p.val),1)]))),128))])])):e.createCommentVNode("",!0),(d=r.sizes)!=null&&d.length?(e.openBlock(),e.createElementBlock("div",kl,[s.sizeTitle?(e.openBlock(),e.createElementBlock("h4",wl,e.toDisplayString(s.sizeTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",_l,[l.sortedSizes.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.sortedSizes,(p,u)=>{var y,m,f,k,_;return e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",$l,[e.createElementVNode("div",{class:e.normalizeClass([l.maxWidht?`w-[${l.maxWidht}]`:"","mr-[10px]"])},[e.createElementVNode("div",{class:e.normalizeClass(l.sizeClass(u)),style:e.normalizeStyle({backgroundColor:((m=(y=o.palette)==null?void 0:y[r.color])==null?void 0:m[u])||r.color})},null,6)],2),e.createElementVNode("p",El,e.toDisplayString(u===((f=l.sortedSizes)==null?void 0:f.length)-1?">"+p:u==((k=l.sortedSizes)==null?void 0:k.length)-1?">"+l.sortedSizes[((_=l.sortedSizes)==null?void 0:_.length)-1]:p+"-"+l.sortedSizes[u+1]),1)])])}),256)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)])])],8,["to"])):e.createCommentVNode("",!0)],64)}const Vl=z(hl,[["render",Bl]]),Dl={props:["map","coordinates"],data(){return{isMenuVisible:!1}},computed:{getCoordinates(){var t;return!(this!=null&&this.coordinates)||((t=this.coordinates)==null?void 0:t.length)!==2?"":(this==null?void 0:this.coordinates).slice().reverse().map(r=>Number(r).toFixed(5)).join(", ")}}},Cl={class:"map__settings"},Nl={ref:"attribution",class:"map__settings-attribution map__settings-item mt-[3px]"};function Sl(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Cl,[e.createElementVNode("div",Nl,[e.withDirectives(e.createElementVNode("div",{ref:"mouse",class:"map__settings-item",style:{"min-width":"115px"}},e.toDisplayString(l.getCoordinates),513),[[e.vShow,l.getCoordinates]])],512)])}const Pt=z(Dl,[["render",Sl]]),zl={mixins:[qe],props:{map:{type:Object,default:()=>null}},data(){return{baseLayers:[{id:"orto10",name:"Ortophoto 1:10К",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",service:"TMS",image:"https://data.gki.com.ua/api-user/rtile/orto10/ua/13/4954/2876.png"},{id:"graymap",name:"Сіра карта",url:"https://data.gki.com.ua/api-user/rtile/voyager/ua/{z}/{x}/{y}.png",service:"TMS",image:"https://data.gki.com.ua/api-user/rtile/positron/ua/10/601/348.png"}]}},watch:{map(s){s&&s.on("load",this.handleMapLoad)}},created(){this.baseLayers.forEach(s=>{const t={...s,basemap:!0};this.layerList.push(t)})},methods:{handleMapLoad(){this.changeBaseLayer("graymap")},isLayerInFocus(s){return s.id===this.activeLayer}}},Ll={class:"vs-map-slot-layers"},Tl=["onClick"],Il=["src"];function Ml(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Ll,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.baseLayers,a=>(e.openBlock(),e.createElementBlock("div",{key:a.id,class:e.normalizeClass(["vs-map-slot-layers__layer",{focused:l.isLayerInFocus(a)}]),onClick:i=>s.changeBaseLayer(a.id)},[e.createElementVNode("img",{src:a.image,class:"vs-map-slot-layers__image"},null,8,Il)],10,Tl))),128))])}const Ft=z(zl,[["render",Ml]]);function Wt(s,t,r){if(s!==null)for(var n,o,l,a,i,c,d,p=0,u=0,y,m=s.type,f=m==="FeatureCollection",k=m==="Feature",_=f?s.features.length:1,V=0;V<_;V++){d=f?s.features[V].geometry:k?s.geometry:s,y=d?d.type==="GeometryCollection":!1,i=y?d.geometries.length:1;for(var x=0;x<i;x++){var h=0,b=0;if(a=y?d.geometries[x]:d,a!==null){c=a.coordinates;var $=a.type;switch(p=0,$){case null:break;case"Point":if(t(c,u,V,h,b)===!1)return!1;u++,h++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],u,V,h,b)===!1)return!1;u++,$==="MultiPoint"&&h++}$==="LineString"&&h++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(o=0;o<c[n].length-p;o++){if(t(c[n][o],u,V,h,b)===!1)return!1;u++}$==="MultiLineString"&&h++,$==="Polygon"&&b++}$==="Polygon"&&h++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(b=0,o=0;o<c[n].length;o++){for(l=0;l<c[n][o].length-p;l++){if(t(c[n][o][l],u,V,h,b)===!1)return!1;u++}b++}h++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(Wt(a.geometries[n],t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Rl(s,t={}){if(s.bbox!=null&&t.recompute!==!0)return s.bbox;const r=[1/0,1/0,-1/0,-1/0];return Wt(s,n=>{r[0]>n[0]&&(r[0]=n[0]),r[1]>n[1]&&(r[1]=n[1]),r[2]<n[0]&&(r[2]=n[0]),r[3]<n[1]&&(r[3]=n[1])}),r}const Pl={props:["bbox","map"],components:{homeIcon:{__name:"home",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ys),e.mergeProps(t.$attrs,{size:24}),null,16))}}},methods:{setBounds(){const s={type:"Feature",geometry:this==null?void 0:this.bbox},t=Rl(s);this.map.fitBounds(t)}}},Fl={class:"z-100 flex justify-center items-center rounded-md w-[32px] h-[32px] cursor-pointer bg-white p-1 border-[2px]"};function Wl(s,t,r,n,o,l){const a=e.resolveComponent("homeIcon");return e.openBlock(),e.createElementBlock("div",Fl,[e.createVNode(a,{onClick:l.setBounds},null,8,["onClick"])])}const jt=z(Pl,[["render",Wl]]),jl={components:{legendIcon:ve,menuIcon:{__name:"menu",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(bs),e.mergeProps(t.$attrs,{size:24}),null,16))}},closeIcon:Se},props:["source","count","total","mapId"],data(){return{isOpenLegend:!1,palette:["#69D2E7","yellow","#FE4365"]}},methods:{calcSize(s){return s/this.maxValue*100*50/100}},computed:{maxValue(){var s,t,r,n,o,l;return((s=this.sizes)==null?void 0:s[0])>((r=this.sizes)==null?void 0:r[((t=this.sizes)==null?void 0:t.length)-1])?(n=this.sizes)==null?void 0:n[0]:(l=this.sizes)==null?void 0:l[((o=this.sizes)==null?void 0:o.length)-1]}}},Ol={class:"w-full h-[calc(100%-40px)] bg-white"},Al={class:"w-full flex flex-col gap-[8px] h-[250px] overflow-auto [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-gray-300 [&::-webkit-scrollbar-track]:bg-transparent text-xs"},ql={class:"relative min-w-full bg-white text-[12px]"},vl={class:"divide-gray-200 dark:divide-neutral-700"},Ul={class:"px-2 py-1"},Hl={class:"px-2 py-1"};function Gl(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Ol,[e.createElementVNode("div",Al,[e.createElementVNode("table",ql,[t[0]||(t[0]=e.createElementVNode("thead",{class:"sticky top-[-1px] z-[1] bg-white w-full after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200"},[e.createElementVNode("tr",null,[e.createElementVNode("th",{class:"px-2 py-1 text-start"},"Назва"),e.createElementVNode("th",{class:"px-2 py-1 text-start"},"Метрика")])],-1)),e.createElementVNode("tbody",vl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.source,a=>(e.openBlock(),e.createElementBlock("tr",{key:a.id,class:"border-b cursor-pointer hover:bg-gray-100 odd:bg-gray-50"},[e.createElementVNode("td",Ul,e.toDisplayString(a.title||"—"),1),e.createElementVNode("td",Hl,e.toDisplayString(a.metric),1)]))),128))])])])])}const Ot=z(jl,[["render",Gl]]),Zl={mixins:[j,qe,{components:{VsMapSetting:Pt,VsMapSlotLayers:Ft,VsMapLegend:Vl,VsMapGoHome:jt,VsList:Ot},data(){return{mapId:`map-${Math.floor(Math.random()*1e3)}`,layerId:`layer${Math.floor(Math.random()*1e3)}`,map:null,hoverData:null,data:null,coordinatesByMouse:[],showSetting:!1,popup:null,color:"#69D2E7"}},methods:{async createMap(){var r,n;const s=await Rt();if(!s)return;const t={version:8,glyphs:"https://cdn.softpro.ua/data/fonts/{fontstack}/{range}.pbf",sources:{},layers:[]};this.map=await new s.Map({container:this.mapId,style:t,center:[31,48.5],zoom:((n=(r=this.data)==null?void 0:r.style)==null?void 0:n.zoom)||5,minZoom:3,maxZoom:20,attributionControl:!1}),this.map.addControl(new s.NavigationControl({visualizePitch:!0})),this.map.on("load",()=>{this.loadHandler()}),this.map.on("mousemove",o=>{this.moveMouseHadler(o)}),this.map.on("mouseout",()=>{var o;this.showLegend=!1,this.showSetting=!1,this.coordinatesByMouse=0,(o=this.popup)==null||o.remove()})},getPopoverTitle(s){var t,r,n,o,l;return(r=(t=this.data)==null?void 0:t.colors)!=null&&r.find(a=>a.val===s)?(l=(o=(n=this.data)==null?void 0:n.colors)==null?void 0:o.find(a=>a.val===s))==null?void 0:l.text:s},moveMouseHadler(s){var t;try{const r=this.map.queryRenderedFeatures(s.point),n=((t=r[0])==null?void 0:t.properties)||{};if(!r.length){this.map.getCanvas().style.cursor="",this.popupElement&&this.popupElement.remove();return}this.map.getCanvas().style.cursor="pointer",this.popupElement&&this.popupElement.remove(),this.popupElement=document.createElement("div"),this.popupElement.className="absolute text-gray-800 border border-gray-200 rounded-lg shadow-md min-w-28",this.popupElement.style.backgroundColor="rgba(255, 255, 255, 0.7)",this.popupElement.innerHTML=`<div class="font-semibold text-sm border-b border-solid border-gray-200 text-gray-800 rounded-t-lg px-2 py-1">
210
+ ${pe(r)}: ${U(n)} (${o}%)
211
+ </div>`},onChangedData(){try{if(this.sourceData){const{series:s,xs:t,ys:r}=this.prepareData();s&&(this==null||this.initChart(s,t,r))}}catch{}},prepareData(){try{const s=Array.from(new Set(this.sourceData.map(o=>o[this.dimensions[0]]))),t=Array.from(new Set(this.sourceData.map(o=>o[this.dimensions[1]]))),r=s.map((o,l)=>({name:o,value:t[l]}));return{series:[{name:this.titleCharts?this.titleCharts:this.dimensions[0],type:"funnel",...Y(this.styleData),data:r,height:"80%",emphasis:{label:{show:!1}}}]}}catch(s){console.error(s)}},async initChart(s){var t,r;try{const n=this.$refs.chart,o=Ae==null?void 0:Ae.init(n);if(!o)return;const l={series:s,...Y(this.styleData),tooltip:{show:((r=(t=this.styleData)==null?void 0:t.tooltip)==null?void 0:r.show)!==!1,trigger:"item",confine:!0,formatter:a=>this.buildTooltipForDonut(a,[a.color]),borderWidth:0,appendToBody:!1,borderColor:"transparent",textStyle:{color:"#000"},padding:[10,15],shadowColor:"transparent",backgroundColor:"transparent"},itemStyle:{height:"15px"},legend:{borderRadius:10,type:"scroll",itemWidth:14,itemHeight:14,...this.styleData.legend},labelLine:{show:!1},grid:{bottom:"0"}};o.setOption(l),o.resize(),window.addEventListener("resize",()=>{o.resize()})}catch(n){console.error(n)}}}},Ka=["id"];function Ya(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{ref:"chart",id:o.uniqueID,class:"h-[90%] custom-scrollbar min-h-[200px]"},null,8,Ka)}const el=Object.freeze(Object.defineProperty({__proto__:null,default:L(Ja,[["render",Ya]])},Symbol.toStringTag,{value:"Module"}));function tl(s){return[{type:"fill",paint:{"fill-color":s.color||"#ccc","fill-outline-color":s.color||"blue","fill-opacity":s.opacity||1}}]}function sl(s){return[{type:"line",paint:{"line-color":s.color||"#ccc","line-opacity":s.opacity||1}}]}function rl(s){return[{type:"circle",paint:{"circle-radius":s.radius||6,"circle-stroke-color":s.stroke||"#ccc","circle-stroke-width":s.width||1,"circle-color":s.color||"blue"}}]}function Tt(s){if(!s)return null;const t=s.type||"point";return t==="polygon"?tl(s):t==="line"?sl(s):rl(s)}const Oe={data(){return{layerList:[],activeLayer:""}},computed:{interactiveSources(){return this.layerList.filter(s=>s==null?void 0:s.interactive).map(s=>s.id)}},methods:{moveLayer(s,t=this.map){t.getStyle().layers.forEach(r=>{r.id.match(s)&&t.moveLayer(r.id)})},async setVisible(s,t=!0,r=this.map){if(!s)return;const n=(s==null?void 0:s.id)||s,o=this.layerList.find(a=>a.id===s)||s;if(!(o!=null&&o.id))throw new Error("MixinError: Layer has no id");const l=r.getStyle().layers.filter(a=>a.id.match(n));l.forEach(a=>{r.setLayoutProperty(a.id,"visibility",t?"visible":"none")}),!l.length&&t&&await this.addLayer(o)},async addLayer(s,t=this==null?void 0:this.map){var o,l;const r=this.layerList.find(a=>a.id===s)||s;!this.map.getStyle()||this.map.getStyle().layers.find(a=>a.id===r.id)||(this.layerList.find(a=>a.id===r.id)||this.layerList.push(r),(r.service==="vtile"||r.service==="vector"||(o=r.url)!=null&&o.includes(".vmt"))&&this.addVtileLayer(r,t),r.service==="geojson"&&this.addGeoJsonLayer(r,t),((l=r.url)!=null&&l.includes(".png")||["tms","raster"].includes(r.service))&&await this.addRasterLayer(r,t))},async addRasterLayer(s,t=this==null?void 0:this.map){var r,n;t.getSource(s.id)||(await t.addSource(s.id,{type:"raster",tiles:[s==null?void 0:s.url],tileSize:256,...s!=null&&s.scheme?{scheme:s==null?void 0:s.scheme}:{}}),await t.addLayer({id:s.id,type:"raster",source:s.id,minzoom:0,maxzoom:(s==null?void 0:s.maxzoom)||22},s.basemap?(n=(r=this.map.getStyle().layers)==null?void 0:r[0])==null?void 0:n.id:null))},async addVtileLayer(s,t=this==null?void 0:this.map){var l;const r=["props","pointZoom"].filter(a=>s[a]).map(a=>`&${a}=${s[a]}`),n={type:"vector",tiles:[`${(l=s==null?void 0:s.url)!=null&&l.startsWith("http")?"":window.location.origin}${s==null?void 0:s.url}${r}`],minzoom:s.minzoom||3,maxzoom:s.maxzoom||24};t.addSource(s.id,n),(Tt(s.style)||s.layers||[]).forEach((a,i)=>{const c={...a,id:`${s.id}-${i}`,source:s.id,"source-layer":a["source-layer"]||s.source||s.id,maxzoom:+a.maxzoom||24,minzoom:+a.minzoom||0};t.addLayer(c)})},async addGeoJsonLayer(s,t=this.map){var o;const r=s.data||((o=s==null?void 0:s.url)!=null&&o.startsWith("http")?"":window.location.origin)+s.url;t.addSource(s.id,{type:"geojson",data:r}),(Tt(s.style)||s.layers||[]).forEach(l=>{const a={...l,source:s.id,id:l.id||s.id,maxzoom:+l.maxzoom||24,minzoom:+l.minzoom||0,type:l.type||"circle"};t.addLayer(a)})},setLayerData(s,t){this.layerList=this.layerList.map(r=>r.id===s?{...r,...t}:r)},async removeLayer(s,t=this.map){t.getSource(s)&&(await t.getStyle().layers.forEach(async r=>{r.source===s&&await t.removeLayer(r.id)}),await t.removeSource(s))},async setFilter(s,t){var o;const r=this.layerList.find(l=>l.id===s),n=await((o=this.map)==null?void 0:o.getSource(s));if(n&&r.service==="vtile"){await n.setTiles([`${window.location.origin}${r.url}${r.url.includes("?")?"&":"?"}filter=${t}${r.props?`&props=${r.props}`:""}`]);return}n&&r.service},async changeBaseLayer(s){const t=s!=null&&s.id?s:this.layerList.find(n=>n.id===s),{id:r}=t;if(r&&r!==this.activeLayer){if(this.activeLayer&&this.map.setLayoutProperty(this.activeLayer,"visibility","none"),this.activeLayer=r,this.map.getLayer(r)){this.map.setLayoutProperty(r,"visibility","visible");return}await this.addRasterLayer(t)}},async refreshLayer(s,t=this.map){await t.getStyle().layers.forEach(r=>{r.source===s&&t.removeLayer(r.id)}),await t.removeSource(s),this.setVisible(s)}}},nl="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.js",ol="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.css";let De=null;function al(s){return new Promise((t,r)=>{if(document.querySelector(`script[src="${s}"]`)){t();return}const n=document.createElement("script");n.src=s,n.onload=()=>t(),n.onerror=()=>r(new Error(`Failed to load ${s}`)),document.head.appendChild(n)})}function ll(s){return new Promise((t,r)=>{if(document.querySelector(`link[href="${s}"]`)){t();return}const n=document.createElement("link");n.rel="stylesheet",n.href=s,n.onload=()=>t(),n.onerror=()=>r(new Error(`Failed to load ${s}`)),document.head.appendChild(n)})}function It(){return typeof window>"u"?Promise.resolve(null):window.maplibregl?Promise.resolve(window.maplibregl):De||(De=ll(ol).then(()=>al(nl)).then(()=>window.maplibregl),De)}const qe={__name:"legend",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ks),e.mergeProps(t.$attrs,{size:24}),null,16))}},ve={pink:["#fde7e2","#feafbe","#fd58a4","#d7038e","#86007b"],blue:["#f1eef6","#bdc9e1","#74a9cf","#2b8cbe","#045a8d"],green:["#edf8fb","#b2e2e2","#66c2a4","#2ca25f","#006d2c"],pink2:["#f1eef6","#d7b5d8","#df65b0","#dd1c77","#980043"],red:["#fef0d9","#fdcc8a","#fc8d59","#e34a33","#b30000"],teal:["#f6eff7","#bdc9e1","#67a9cf","#1c9099","#016c59"]},il={components:{legendIcon:qe,closeIcon:Ne},props:{mapId:{type:String},colors:{type:Array},sizes:{type:Array,default:()=>[]},cluster:{type:[Boolean,String]},color:{type:String,default:"gray"},colorTitle:{type:String},sizesTitle:{type:String},resizeItem:{type:[Boolean,String],default:!1},changeOpacityItem:{type:[Boolean,String],default:!1}},data(){return{isOpenLegend:!1,palette:ve}},computed:{borderRadius(){return this.cluster?"rounded-sm":"rounded-full"},sortedSizes(){return[...this.sizes].sort((s,t)=>s-t)},maxWidht(){var r;const s=((r=this.sizes)==null?void 0:r.length)-1;return this.calcSize(s)}},methods:{sizeClass(s){return this.resizeItem?`h-[${this.calcSize(s)}] w-[${this.calcSize(s)}] ${this.borderRadius}`:`h-[18px] w-[18px] ${this.borderRadius}`},calcSize(s){return`${10+s*2}px`},getOpacity(s){return(s+1)/this.sortedSizes.length}}},cl={class:"w-full absolute max-w-[200px] bg-white border rounded-lg bottom-[10px] right-[50px]"},dl={class:"flex items-center justify-between border-b border-[#0000001A] px-2"},pl={class:"w-full flex flex-col gap-[8px] px-2 py-2 max-h-[200px] overflow-auto [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-gray-300 [&::-webkit-scrollbar-track]:bg-transparent"},hl={key:0,class:"flex flex-col w-full"},ul={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},ml={class:"flex flex-col gap-[6px]"},fl={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"},gl={key:1,class:"flex flex-col w-full"},bl={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},yl={class:"flex flex-col gap-[6px]"},xl={class:"flex flex-row items-center justify-start"},kl={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"};function wl(s,t,r,n,o,l){var c,d;const a=e.resolveComponent("legendIcon"),i=e.resolveComponent("closeIcon");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:"flex justify-center items-center rounded-md w-[32px] h-[32px] cursor-pointer bg-white p-1 border-[2px]",onClick:t[0]||(t[0]=p=>o.isOpenLegend=!o.isOpenLegend)},[e.createVNode(a)]),o.isOpenLegend?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:`#wrapper-${r.mapId}`},[e.createElementVNode("div",cl,[e.createElementVNode("div",dl,[t[2]||(t[2]=e.createElementVNode("h3",{class:"text-[16px] font-normal text-black"},"Легенда",-1)),e.createElementVNode("button",{type:"button",class:"inline-flex items-center text-sm font-medium text-gray-500 rounded-lg gap-x-2 focus:outline-none disabled:opacity-50 disabled:pointer-events-none dark:text-neutral-400 dark:hover:text-blue-500 dark:focus:text-blue-500",onClick:t[1]||(t[1]=p=>o.isOpenLegend=!1)},[e.createVNode(i,{class:"w-[20px]"})])]),e.createElementVNode("div",pl,[(c=r.colors)!=null&&c.length?(e.openBlock(),e.createElementBlock("div",hl,[r.colorTitle?(e.openBlock(),e.createElementBlock("h4",ul,e.toDisplayString(r.colorTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",ml,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.colors,(p,u)=>(e.openBlock(),e.createElementBlock("div",{key:u,class:"flex items-center gap-[10px]"},[p.color?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-[12px] h-[12px] rounded-full",style:e.normalizeStyle({backgroundColor:p.color})},null,4)):e.createCommentVNode("",!0),e.createElementVNode("p",fl,e.toDisplayString(p.text||p.val),1)]))),128))])])):e.createCommentVNode("",!0),(d=r.sizes)!=null&&d.length?(e.openBlock(),e.createElementBlock("div",gl,[s.sizeTitle?(e.openBlock(),e.createElementBlock("h4",bl,e.toDisplayString(s.sizeTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",yl,[l.sortedSizes.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.sortedSizes,(p,u)=>{var y,m,f,k,_;return e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",xl,[e.createElementVNode("div",{class:e.normalizeClass([l.maxWidht?`w-[${l.maxWidht}]`:"","mr-[10px]"])},[e.createElementVNode("div",{class:e.normalizeClass(l.sizeClass(u)),style:e.normalizeStyle({backgroundColor:((m=(y=o.palette)==null?void 0:y[r.color])==null?void 0:m[u])||r.color})},null,6)],2),e.createElementVNode("p",kl,e.toDisplayString(u===((f=l.sortedSizes)==null?void 0:f.length)-1?">"+p:u==((k=l.sortedSizes)==null?void 0:k.length)-1?">"+l.sortedSizes[((_=l.sortedSizes)==null?void 0:_.length)-1]:p+"-"+l.sortedSizes[u+1]),1)])])}),256)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)])])],8,["to"])):e.createCommentVNode("",!0)],64)}const _l=L(il,[["render",wl]]),$l={props:["map","coordinates"],data(){return{isMenuVisible:!1}},computed:{getCoordinates(){var t;return!(this!=null&&this.coordinates)||((t=this.coordinates)==null?void 0:t.length)!==2?"":(this==null?void 0:this.coordinates).slice().reverse().map(r=>Number(r).toFixed(5)).join(", ")}}},El={class:"map__settings"},Bl={ref:"attribution",class:"map__settings-attribution map__settings-item mt-[3px]"};function Vl(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",El,[e.createElementVNode("div",Bl,[e.withDirectives(e.createElementVNode("div",{ref:"mouse",class:"map__settings-item",style:{"min-width":"115px"}},e.toDisplayString(l.getCoordinates),513),[[e.vShow,l.getCoordinates]])],512)])}const Mt=L($l,[["render",Vl]]),Dl={mixins:[Oe],props:{map:{type:Object,default:()=>null}},data(){return{baseLayers:[{id:"orto10",name:"Ortophoto 1:10К",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",service:"TMS",image:"https://data.gki.com.ua/api-user/rtile/orto10/ua/13/4954/2876.png"},{id:"graymap",name:"Сіра карта",url:"https://data.gki.com.ua/api-user/rtile/voyager/ua/{z}/{x}/{y}.png",service:"TMS",image:"https://data.gki.com.ua/api-user/rtile/positron/ua/10/601/348.png"}]}},watch:{map(s){s&&s.on("load",this.handleMapLoad)}},created(){this.baseLayers.forEach(s=>{const t={...s,basemap:!0};this.layerList.push(t)})},methods:{handleMapLoad(){this.changeBaseLayer("graymap")},isLayerInFocus(s){return s.id===this.activeLayer}}},Cl={class:"vs-map-slot-layers"},Nl=["onClick"],Sl=["src"];function zl(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Cl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.baseLayers,a=>(e.openBlock(),e.createElementBlock("div",{key:a.id,class:e.normalizeClass(["vs-map-slot-layers__layer",{focused:l.isLayerInFocus(a)}]),onClick:i=>s.changeBaseLayer(a.id)},[e.createElementVNode("img",{src:a.image,class:"vs-map-slot-layers__image"},null,8,Sl)],10,Nl))),128))])}const Rt=L(Dl,[["render",zl]]);function Pt(s,t,r){if(s!==null)for(var n,o,l,a,i,c,d,p=0,u=0,y,m=s.type,f=m==="FeatureCollection",k=m==="Feature",_=f?s.features.length:1,V=0;V<_;V++){d=f?s.features[V].geometry:k?s.geometry:s,y=d?d.type==="GeometryCollection":!1,i=y?d.geometries.length:1;for(var x=0;x<i;x++){var h=0,b=0;if(a=y?d.geometries[x]:d,a!==null){c=a.coordinates;var $=a.type;switch(p=0,$){case null:break;case"Point":if(t(c,u,V,h,b)===!1)return!1;u++,h++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],u,V,h,b)===!1)return!1;u++,$==="MultiPoint"&&h++}$==="LineString"&&h++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(o=0;o<c[n].length-p;o++){if(t(c[n][o],u,V,h,b)===!1)return!1;u++}$==="MultiLineString"&&h++,$==="Polygon"&&b++}$==="Polygon"&&h++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(b=0,o=0;o<c[n].length;o++){for(l=0;l<c[n][o].length-p;l++){if(t(c[n][o][l],u,V,h,b)===!1)return!1;u++}b++}h++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(Pt(a.geometries[n],t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Ll(s,t={}){if(s.bbox!=null&&t.recompute!==!0)return s.bbox;const r=[1/0,1/0,-1/0,-1/0];return Pt(s,n=>{r[0]>n[0]&&(r[0]=n[0]),r[1]>n[1]&&(r[1]=n[1]),r[2]<n[0]&&(r[2]=n[0]),r[3]<n[1]&&(r[3]=n[1])}),r}const Tl={props:["bbox","map"],components:{homeIcon:{__name:"home",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(bs),e.mergeProps(t.$attrs,{size:24}),null,16))}}},methods:{setBounds(){const s={type:"Feature",geometry:this==null?void 0:this.bbox},t=Ll(s);this.map.fitBounds(t)}}},Il={class:"z-100 flex justify-center items-center rounded-md w-[32px] h-[32px] cursor-pointer bg-white p-1 border-[2px]"};function Ml(s,t,r,n,o,l){const a=e.resolveComponent("homeIcon");return e.openBlock(),e.createElementBlock("div",Il,[e.createVNode(a,{onClick:l.setBounds},null,8,["onClick"])])}const Ft=L(Tl,[["render",Ml]]),Rl={components:{legendIcon:qe,menuIcon:{__name:"menu",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(gs),e.mergeProps(t.$attrs,{size:24}),null,16))}},closeIcon:Ne},props:["source","count","total","mapId"],data(){return{isOpenLegend:!1,palette:["#69D2E7","yellow","#FE4365"]}},methods:{calcSize(s){return s/this.maxValue*100*50/100}},computed:{maxValue(){var s,t,r,n,o,l;return((s=this.sizes)==null?void 0:s[0])>((r=this.sizes)==null?void 0:r[((t=this.sizes)==null?void 0:t.length)-1])?(n=this.sizes)==null?void 0:n[0]:(l=this.sizes)==null?void 0:l[((o=this.sizes)==null?void 0:o.length)-1]}}},Pl={class:"w-full h-[calc(100%-40px)] bg-white"},Fl={class:"w-full flex flex-col gap-[8px] h-[250px] overflow-auto [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-gray-300 [&::-webkit-scrollbar-track]:bg-transparent text-xs"},Wl={class:"relative min-w-full bg-white text-[12px]"},jl={class:"divide-gray-200 dark:divide-neutral-700"},Al={class:"px-2 py-1"},Ol={class:"px-2 py-1"};function ql(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Pl,[e.createElementVNode("div",Fl,[e.createElementVNode("table",Wl,[t[0]||(t[0]=e.createElementVNode("thead",{class:"sticky top-[-1px] z-[1] bg-white w-full after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200"},[e.createElementVNode("tr",null,[e.createElementVNode("th",{class:"px-2 py-1 text-start"},"Назва"),e.createElementVNode("th",{class:"px-2 py-1 text-start"},"Метрика")])],-1)),e.createElementVNode("tbody",jl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.source,a=>(e.openBlock(),e.createElementBlock("tr",{key:a.id,class:"border-b cursor-pointer hover:bg-gray-100 odd:bg-gray-50"},[e.createElementVNode("td",Al,e.toDisplayString(a.title||"—"),1),e.createElementVNode("td",Ol,e.toDisplayString(a.metric),1)]))),128))])])])])}const Wt=L(Rl,[["render",ql]]),vl={mixins:[j,Oe,{components:{VsMapSetting:Mt,VsMapSlotLayers:Rt,VsMapLegend:_l,VsMapGoHome:Ft,VsList:Wt},data(){return{mapId:`map-${Math.floor(Math.random()*1e3)}`,layerId:`layer${Math.floor(Math.random()*1e3)}`,map:null,hoverData:null,data:null,coordinatesByMouse:[],showSetting:!1,popup:null,color:"#69D2E7"}},methods:{async createMap(){var r,n;const s=await It();if(!s)return;const t={version:8,glyphs:"https://cdn.softpro.ua/data/fonts/{fontstack}/{range}.pbf",sources:{},layers:[]};this.map=await new s.Map({container:this.mapId,style:t,center:[31,48.5],zoom:((n=(r=this.data)==null?void 0:r.style)==null?void 0:n.zoom)||5,minZoom:3,maxZoom:20,attributionControl:!1}),this.map.addControl(new s.NavigationControl({visualizePitch:!0})),this.map.on("load",()=>{this.loadHandler()}),this.map.on("mousemove",o=>{this.moveMouseHadler(o)}),this.map.on("mouseout",()=>{var o;this.showLegend=!1,this.showSetting=!1,this.coordinatesByMouse=0,(o=this.popup)==null||o.remove()})},getPopoverTitle(s){var t,r,n,o,l;return(r=(t=this.data)==null?void 0:t.colors)!=null&&r.find(a=>a.val===s)?(l=(o=(n=this.data)==null?void 0:n.colors)==null?void 0:o.find(a=>a.val===s))==null?void 0:l.text:s},moveMouseHadler(s){var t;try{const r=this.map.queryRenderedFeatures(s.point),n=((t=r[0])==null?void 0:t.properties)||{};if(!r.length){this.map.getCanvas().style.cursor="",this.popupElement&&this.popupElement.remove();return}this.map.getCanvas().style.cursor="pointer",this.popupElement&&this.popupElement.remove(),this.popupElement=document.createElement("div"),this.popupElement.className="absolute text-gray-800 border border-gray-200 rounded-lg shadow-md min-w-28",this.popupElement.style.backgroundColor="rgba(255, 255, 255, 0.7)",this.popupElement.innerHTML=`<div class="font-semibold text-sm border-b border-solid border-gray-200 text-gray-800 rounded-t-lg px-2 py-1">
212
212
  ${this.getPopoverTitle((n==null?void 0:n.x)||(n==null?void 0:n.title)||(n==null?void 0:n.name))||""}
213
213
  </div>
214
214
 
@@ -217,7 +217,7 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
217
217
  <span class="font-medium mr-[6px]">Значення</span>
218
218
  </span>
219
219
  <span>${(n==null?void 0:n.metric)||0}</span>
220
- </div>`;const o=this.map.project(s.lngLat);this.popupElement.style.left=`${o.x}px`,this.popupElement.style.top=`${o.y-60}px`,this.map.getContainer().appendChild(this.popupElement)}catch(r){console.error(r)}}}}],name:"VsMap",async mounted(){await this.getMapData(),await this.createMap()},methods:{async getMapData(){const t=await(await fetch(`/api/bi-map?widget=${this.widget}&dashboard=${this.dashboard}`)).json();this.data=t,this.$emit("update:widgetData",t),setTimeout(()=>{var r;return(r=this.map)==null?void 0:r.resize()})},async loadHandler(){const s=["#69D2E7","yellow","#FE4365"],t=this.data.colors?["match",["get","x"]].concat(this.data.colors.reduce((l,a,i)=>l.concat(a.val,(a==null?void 0:a.color)||s[i]),[])).concat(["gray"]):"blue",r=[5,7,9,11,13],n=this.data.sizes?["case"]:5;this.data.sizes&&(this.data.sizes.reverse().forEach((l,a)=>{n.push([">",["get","metric"],l]),n.push(r[a])}),n.push(5));const o={type:"circle",color:t,width:2,radius:n,stroke:"#eee"};Object.assign(o,this.data.style||{}),this.addVtileLayer({id:"bi",url:`${window.top.location.origin}/api/bi-vtile/{z}/{x}/{y}.vmt?widget=${this.widget}&dashboard=${this.dashboard}&nocache=1`,style:o})}}},Ql={class:"w-full h-full"},Xl={class:"flex items-start justify-between mb-[6px] w-full"},Jl={class:"text-gray-800 font-[600]"},Kl=["id"],Yl=["id"],ei={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"};function ti(s,t,r,n,o,l){var p,u,y;const a=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapLegend"),d=e.resolveComponent("VsMapGoHome");return e.openBlock(),e.createElementBlock("div",Ql,[e.createElementVNode("div",Xl,[e.createElementVNode("h5",Jl,e.toDisplayString(s.title),1)]),e.createElementVNode("div",{class:"relative w-full h-[calc(100%-40px)]",id:`wrapper-${s.mapId}`},[e.createElementVNode("div",{id:s.mapId,class:"w-full flex items-end relative h-full min-h-[250px]"},null,8,Yl),s.showSetting?(e.openBlock(),e.createBlock(a,{key:0,map:s.map,coordinates:s.coordinatesByMouse},null,8,["map","coordinates"])):e.createCommentVNode("",!0),e.createVNode(i,{map:s.map},null,8,["map"]),e.createElementVNode("div",ei,[e.createVNode(c,{mapId:s.mapId,colors:(p=s.data)==null?void 0:p.colors,sizes:(u=s.data)==null?void 0:u.sizes,color:s.color,resizeItem:"true"},null,8,["mapId","colors","sizes","color"]),e.createVNode(d,{map:s.map,bbox:(y=s.data)==null?void 0:y.bounds},null,8,["map","bbox"])])],8,Kl)])}const si=Object.freeze(Object.defineProperty({__proto__:null,default:z(Zl,[["render",ti]])},Symbol.toStringTag,{value:"Module"})),ri={components:{legendIcon:ve,closeIcon:Se},props:{mapId:{type:String},colors:{type:Array},sizes:{type:Array,default:()=>[]},cluster:{type:[Boolean,String]},color:{type:String,default:"gray"},colorTitle:{type:String},sizesTitle:{type:String},resizeItem:{type:[Boolean,String],default:!1},changeOpacityItem:{type:[Boolean,String],default:!1}},data(){return{isOpenLegend:!1,palette:Ue}},computed:{borderRadius(){return this.cluster?"rounded-sm":"rounded-full"},sortedSizes(){return[...this.sizes].sort((s,t)=>s-t)},maxWidht(){var r;const s=((r=this.sizes)==null?void 0:r.length)-1;return this.calcSize(s)}},methods:{sizeClass(s){return this.resizeItem?`h-[${this.calcSize(s)}] w-[${this.calcSize(s)}] ${this.borderRadius}`:`h-[10px] ${this.borderRadius}`},calcSize(s){return`${10+s*2}px`},getOpacity(s){return(s+1)/this.sortedSizes.length}}},ni={key:0,class:"absolute flex items-end w-fit bottom-[10px] max-w-[80%] left-[50%] translate-x-[-50%] bg-[rgba(255,255,255,0.7)] p-[10px] rounded"},oi={class:"w-[80px] mr-[10px]"},ai=["title"],li={class:"text-[10px] mb-[2px] text-[#1F2937] font-normal leading-[1.2]"};function ii(s,t,r,n,o,l){var a;return(a=r.sizes)!=null&&a.length?(e.openBlock(),e.createElementBlock("div",ni,[e.createElementVNode("div",oi,[t[0]||(t[0]=e.createElementVNode("p",{class:"text-[10px] mb-[2px] text-[#1F2937] leading-[1.2]"}," Дані відсутні ",-1)),e.createElementVNode("div",{class:e.normalizeClass([l.sizeClass(s.index),"w-full border border-gray-500"])},null,2)]),l.sortedSizes.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.sortedSizes,(i,c)=>{var d,p,u,y,m,f,k,_;return e.openBlock(),e.createElementBlock("div",{class:"w-[80px]",title:c===((d=l.sortedSizes)==null?void 0:d.length)-1?">"+i:c==((p=l.sortedSizes)==null?void 0:p.length)-1?">"+l.sortedSizes[((u=l.sortedSizes)==null?void 0:u.length)-1]:i+"-"+l.sortedSizes[c+1]},[e.createElementVNode("p",li,e.toDisplayString(c===((y=l.sortedSizes)==null?void 0:y.length)-1?">"+parseInt(i):c==((m=l.sortedSizes)==null?void 0:m.length)-1?">"+parseInt(l.sortedSizes[((f=l.sortedSizes)==null?void 0:f.length)-1]):parseInt(i)+"-"+parseInt(l.sortedSizes[c+1])),1),e.createElementVNode("div",{class:e.normalizeClass([l.sizeClass(c),"w-full border border-r-0 border-gray-500"]),style:e.normalizeStyle({backgroundColor:((_=(k=o.palette)==null?void 0:k[r.color])==null?void 0:_[c])||r.color})},null,6)],8,ai)}),256)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const ci=z(ri,[["render",ii]]),di={__name:"icon-map",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(_s),e.mergeProps(t.$attrs,{size:24}),null,16))}},pi={mixins:[j,qe],components:{VsMapSetting:Pt,VsClusterLegend:ci,VsMapGoHome:jt,VsList:Ot,VsMapSlotLayers:Ft,VsBar:We},data(){return{baseColor:"pink",kattotg:"",options:[{id:"map",text:"Карта",component:di},{id:"table",text:"Таблиця",component:$t},{id:"chart",text:"Віджет",component:_t}],activeTab:"map",mapId:`map-${Math.floor(Math.random()*1e3)}`,layerId:`layer${Math.floor(Math.random()*1e3)}`,map:null,hoverData:null,data:null,coordinatesByMouse:[],showSetting:!1,popup:null,color:"#69D2E7",label:"<div><icon-map/></div>"}},async mounted(){await this.getMapData(),await this.createMap()},watch:{kattotg(){this.loadHandler()}},methods:{async getMapData(){const s=await R.get(`/bi-cluster?widget=${this.widget}&dashboard=${this.dashboard}`);this.data=s,this.$emit("update:widgetData",this.data),setTimeout(()=>{var t;return(t=this.map)==null?void 0:t.resize()})},async loadHandler(){var n,o,l,a;this.baseColor=((n=this.data.style)==null?void 0:n.color)||"blue";const s=["case"];(a=(l=(o=this.data)==null?void 0:o.sizes)==null?void 0:l.toReversed())==null||a.forEach((i,c)=>{var d,p;s.push([">",["get","metric"],i]),s.push((p=(d=Ue[this.baseColor])==null?void 0:d.toReversed())==null?void 0:p[c]),c++}),s.push("gray");const t={type:"polygon",color:s,opacity:.4};Object.assign(t,this.data.style||{}),this.map.getSource("bi")||this.addVtileLayer({id:"bi",url:`${window.location.origin}/api/bi-cluster-vtile/{z}/{x}/{y}.vmt?widget=${this.widget}&dashboard=${this.dashboard}&nocache=1`,style:t}),this.map.getLayer("highlighted")&&this.map.removeLayer("highlighted"),this.map.getSource("highlighted")&&this.map.removeSource("highlighted");const r=["case"];this.kattotg&&r.push(["==",["to-string",["get","name"]],String(this.kattotg)],"red"),r.push("transparent"),this.map.addLayer({id:"highlighted",type:"fill",source:"bi","source-layer":"bi",paint:{"fill-color":r,"fill-opacity":.6}})},async createMap(){var r,n;const s=await Rt();if(!s)return;const t={version:8,glyphs:"https://cdn.softpro.ua/data/fonts/{fontstack}/{range}.pbf",sources:{},layers:[]};this.map=await new s.Map({container:this.mapId,style:t,center:[31,48.5],zoom:((n=(r=this.data)==null?void 0:r.style)==null?void 0:n.zoom)||5,minZoom:3,maxZoom:20,attributionControl:!1}),this.map.addControl(new s.NavigationControl({visualizePitch:!0})),this.map.on("load",()=>{this.loadHandler()}),this.map.on("mousemove",o=>{this.moveMouseHadler(o)}),this.map.on("mouseout",()=>{var o;this.showLegend=!1,this.showSetting=!1,this.coordinatesByMouse=0,(o=this.popup)==null||o.remove()})},moveMouseHadler(s){var t;try{const r=this.map.queryRenderedFeatures(s.point),n=((t=r[0])==null?void 0:t.properties)||{};if(!r.length){this.map.getCanvas().style.cursor="",this.popupElement&&this.popupElement.remove();return}this.map.getCanvas().style.cursor="pointer",this.popupElement&&this.popupElement.remove(),this.popupElement=document.createElement("div"),this.popupElement.className="absolute text-gray-800 border border-gray-200 rounded-lg shadow-md min-w-28",this.popupElement.style.backgroundColor="rgba(255, 255, 255, 0.7)",this.popupElement.innerHTML=`<div class="px-2 py-1 text-sm font-semibold text-gray-800 border-b border-gray-200 border-solid rounded-t-lg">
220
+ </div>`;const o=this.map.project(s.lngLat);this.popupElement.style.left=`${o.x}px`,this.popupElement.style.top=`${o.y-60}px`,this.map.getContainer().appendChild(this.popupElement)}catch(r){console.error(r)}}}}],name:"VsMap",async mounted(){await this.getMapData(),await this.createMap()},methods:{async getMapData(){const t=await(await fetch(`/api/bi-map?widget=${this.widget}&dashboard=${this.dashboard}`)).json();this.data=t,this.$emit("update:widgetData",t),setTimeout(()=>{var r;return(r=this.map)==null?void 0:r.resize()})},async loadHandler(){const s=["#69D2E7","yellow","#FE4365"],t=this.data.colors?["match",["get","x"]].concat(this.data.colors.reduce((l,a,i)=>l.concat(a.val,(a==null?void 0:a.color)||s[i]),[])).concat(["gray"]):"blue",r=[5,7,9,11,13],n=this.data.sizes?["case"]:5;this.data.sizes&&(this.data.sizes.reverse().forEach((l,a)=>{n.push([">",["get","metric"],l]),n.push(r[a])}),n.push(5));const o={type:"circle",color:t,width:2,radius:n,stroke:"#eee"};Object.assign(o,this.data.style||{}),this.addVtileLayer({id:"bi",url:`${window.top.location.origin}/api/bi-vtile/{z}/{x}/{y}.vmt?widget=${this.widget}&dashboard=${this.dashboard}&nocache=1`,style:o})}}},Ul={class:"w-full h-full"},Hl={class:"flex items-start justify-between mb-[6px] w-full"},Gl={class:"text-gray-800 font-[600]"},Zl=["id"],Ql=["id"],Xl={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"};function Jl(s,t,r,n,o,l){var p,u,y;const a=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapLegend"),d=e.resolveComponent("VsMapGoHome");return e.openBlock(),e.createElementBlock("div",Ul,[e.createElementVNode("div",Hl,[e.createElementVNode("h5",Gl,e.toDisplayString(s.title),1)]),e.createElementVNode("div",{class:"relative w-full h-[calc(100%-40px)]",id:`wrapper-${s.mapId}`},[e.createElementVNode("div",{id:s.mapId,class:"w-full flex items-end relative h-full min-h-[250px]"},null,8,Ql),s.showSetting?(e.openBlock(),e.createBlock(a,{key:0,map:s.map,coordinates:s.coordinatesByMouse},null,8,["map","coordinates"])):e.createCommentVNode("",!0),e.createVNode(i,{map:s.map},null,8,["map"]),e.createElementVNode("div",Xl,[e.createVNode(c,{mapId:s.mapId,colors:(p=s.data)==null?void 0:p.colors,sizes:(u=s.data)==null?void 0:u.sizes,color:s.color,resizeItem:"true"},null,8,["mapId","colors","sizes","color"]),e.createVNode(d,{map:s.map,bbox:(y=s.data)==null?void 0:y.bounds},null,8,["map","bbox"])])],8,Zl)])}const Kl=Object.freeze(Object.defineProperty({__proto__:null,default:L(vl,[["render",Jl]])},Symbol.toStringTag,{value:"Module"})),Yl={components:{legendIcon:qe,closeIcon:Ne},props:{mapId:{type:String},colors:{type:Array},sizes:{type:Array,default:()=>[]},cluster:{type:[Boolean,String]},color:{type:String,default:"gray"},colorTitle:{type:String},sizesTitle:{type:String},resizeItem:{type:[Boolean,String],default:!1},changeOpacityItem:{type:[Boolean,String],default:!1}},data(){return{isOpenLegend:!1,palette:ve}},computed:{borderRadius(){return this.cluster?"rounded-sm":"rounded-full"},sortedSizes(){return[...this.sizes].sort((s,t)=>s-t)},maxWidht(){var r;const s=((r=this.sizes)==null?void 0:r.length)-1;return this.calcSize(s)}},methods:{sizeClass(s){return this.resizeItem?`h-[${this.calcSize(s)}] w-[${this.calcSize(s)}] ${this.borderRadius}`:`h-[10px] ${this.borderRadius}`},calcSize(s){return`${10+s*2}px`},getOpacity(s){return(s+1)/this.sortedSizes.length}}},ei={key:0,class:"absolute flex items-end w-fit bottom-[10px] max-w-[80%] left-[50%] translate-x-[-50%] bg-[rgba(255,255,255,0.7)] p-[10px] rounded"},ti={class:"w-[80px] mr-[10px]"},si=["title"],ri={class:"text-[10px] mb-[2px] text-[#1F2937] font-normal leading-[1.2]"};function ni(s,t,r,n,o,l){var a;return(a=r.sizes)!=null&&a.length?(e.openBlock(),e.createElementBlock("div",ei,[e.createElementVNode("div",ti,[t[0]||(t[0]=e.createElementVNode("p",{class:"text-[10px] mb-[2px] text-[#1F2937] leading-[1.2]"}," Дані відсутні ",-1)),e.createElementVNode("div",{class:e.normalizeClass([l.sizeClass(s.index),"w-full border border-gray-500"])},null,2)]),l.sortedSizes.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.sortedSizes,(i,c)=>{var d,p,u,y,m,f,k,_;return e.openBlock(),e.createElementBlock("div",{class:"w-[80px]",title:c===((d=l.sortedSizes)==null?void 0:d.length)-1?">"+i:c==((p=l.sortedSizes)==null?void 0:p.length)-1?">"+l.sortedSizes[((u=l.sortedSizes)==null?void 0:u.length)-1]:i+"-"+l.sortedSizes[c+1]},[e.createElementVNode("p",ri,e.toDisplayString(c===((y=l.sortedSizes)==null?void 0:y.length)-1?">"+parseInt(i):c==((m=l.sortedSizes)==null?void 0:m.length)-1?">"+parseInt(l.sortedSizes[((f=l.sortedSizes)==null?void 0:f.length)-1]):parseInt(i)+"-"+parseInt(l.sortedSizes[c+1])),1),e.createElementVNode("div",{class:e.normalizeClass([l.sizeClass(c),"w-full border border-r-0 border-gray-500"]),style:e.normalizeStyle({backgroundColor:((_=(k=o.palette)==null?void 0:k[r.color])==null?void 0:_[c])||r.color})},null,6)],8,si)}),256)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const oi=L(Yl,[["render",ni]]),ai={__name:"icon-map",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ws),e.mergeProps(t.$attrs,{size:24}),null,16))}},li={mixins:[j,Oe],components:{VsMapSetting:Mt,VsClusterLegend:oi,VsMapGoHome:Ft,VsList:Wt,VsMapSlotLayers:Rt,VsBar:Fe},data(){return{baseColor:"pink",kattotg:"",options:[{id:"map",text:"Карта",component:ai},{id:"table",text:"Таблиця",component:wt},{id:"chart",text:"Віджет",component:kt}],activeTab:"map",mapId:`map-${Math.floor(Math.random()*1e3)}`,layerId:`layer${Math.floor(Math.random()*1e3)}`,map:null,hoverData:null,data:null,coordinatesByMouse:[],showSetting:!1,popup:null,color:"#69D2E7",label:"<div><icon-map/></div>"}},async mounted(){await this.getMapData(),await this.createMap()},watch:{kattotg(){this.loadHandler()}},methods:{async getMapData(){const s=await R.get(`/bi-cluster?widget=${this.widget}&dashboard=${this.dashboard}`);this.data=s,this.$emit("update:widgetData",this.data),setTimeout(()=>{var t;return(t=this.map)==null?void 0:t.resize()})},async loadHandler(){var n,o,l,a;this.baseColor=((n=this.data.style)==null?void 0:n.color)||"blue";const s=["case"];(a=(l=(o=this.data)==null?void 0:o.sizes)==null?void 0:l.toReversed())==null||a.forEach((i,c)=>{var d,p;s.push([">",["get","metric"],i]),s.push((p=(d=ve[this.baseColor])==null?void 0:d.toReversed())==null?void 0:p[c]),c++}),s.push("gray");const t={type:"polygon",color:s,opacity:.4};Object.assign(t,this.data.style||{}),this.map.getSource("bi")||this.addVtileLayer({id:"bi",url:`${window.location.origin}/api/bi-cluster-vtile/{z}/{x}/{y}.vmt?widget=${this.widget}&dashboard=${this.dashboard}&nocache=1`,style:t}),this.map.getLayer("highlighted")&&this.map.removeLayer("highlighted"),this.map.getSource("highlighted")&&this.map.removeSource("highlighted");const r=["case"];this.kattotg&&r.push(["==",["to-string",["get","name"]],String(this.kattotg)],"red"),r.push("transparent"),this.map.addLayer({id:"highlighted",type:"fill",source:"bi","source-layer":"bi",paint:{"fill-color":r,"fill-opacity":.6}})},async createMap(){var r,n;const s=await It();if(!s)return;const t={version:8,glyphs:"https://cdn.softpro.ua/data/fonts/{fontstack}/{range}.pbf",sources:{},layers:[]};this.map=await new s.Map({container:this.mapId,style:t,center:[31,48.5],zoom:((n=(r=this.data)==null?void 0:r.style)==null?void 0:n.zoom)||5,minZoom:3,maxZoom:20,attributionControl:!1}),this.map.addControl(new s.NavigationControl({visualizePitch:!0})),this.map.on("load",()=>{this.loadHandler()}),this.map.on("mousemove",o=>{this.moveMouseHadler(o)}),this.map.on("mouseout",()=>{var o;this.showLegend=!1,this.showSetting=!1,this.coordinatesByMouse=0,(o=this.popup)==null||o.remove()})},moveMouseHadler(s){var t;try{const r=this.map.queryRenderedFeatures(s.point),n=((t=r[0])==null?void 0:t.properties)||{};if(!r.length){this.map.getCanvas().style.cursor="",this.popupElement&&this.popupElement.remove();return}this.map.getCanvas().style.cursor="pointer",this.popupElement&&this.popupElement.remove(),this.popupElement=document.createElement("div"),this.popupElement.className="absolute text-gray-800 border border-gray-200 rounded-lg shadow-md min-w-28",this.popupElement.style.backgroundColor="rgba(255, 255, 255, 0.7)",this.popupElement.innerHTML=`<div class="px-2 py-1 text-sm font-semibold text-gray-800 border-b border-gray-200 border-solid rounded-t-lg">
221
221
  ${(n==null?void 0:n.x)||(n==null?void 0:n.title)||(n==null?void 0:n.name)||""}
222
222
  </div>
223
223
 
@@ -226,4 +226,4 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
226
226
  <span class="font-medium mr-[6px]">Значення</span>
227
227
  </span>
228
228
  <span>${(n==null?void 0:n.metric)||0}</span>
229
- </div>`;const o=this.map.project(s.lngLat);this.popupElement.style.left=`${o.x}px`,this.popupElement.style.top=`${o.y-60}px`,this.map.getContainer().appendChild(this.popupElement)}catch(r){console.error(r)}}}},hi={class:"h-full"},ui={class:"flex items-start justify-between mb-[6px] w-full"},mi={class:"text-gray-800 font-[600]"},fi={class:"flex gap-2"},gi=["onClick"],bi=["id"],yi=["id"],xi={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"},ki={class:"h-[calc(250px)]"};function wi(s,t,r,n,o,l){var y,m,f,k,_,V,x,h,b,$;const a=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapGoHome"),d=e.resolveComponent("VsClusterLegend"),p=e.resolveComponent("VsList"),u=e.resolveComponent("VsBar");return e.openBlock(),e.createElementBlock("div",hi,[e.createElementVNode("div",ui,[e.createElementVNode("h3",mi,e.toDisplayString(s.title),1),e.createElementVNode("div",fi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,w=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["p-1 text-gray-700 border rounded",[o.activeTab===(w==null?void 0:w.id)?"ring-2 ring-blue-500":""]]),onClick:g=>o.activeTab=w==null?void 0:w.id},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(w==null?void 0:w.component),{height:"16",width:"16"}))],10,gi))),256))])]),e.withDirectives(e.createElementVNode("div",{class:"relative w-full h-[calc(100%-40px)]",id:`wrapper-${o.mapId}`},[e.createElementVNode("div",{id:o.mapId,class:"h-full w-full flex items-end min-h-[250px]"},null,8,yi),o.showSetting?(e.openBlock(),e.createBlock(a,{key:0,map:o.map,coordinates:o.coordinatesByMouse},null,8,["map","coordinates"])):e.createCommentVNode("",!0),e.createVNode(i,{map:o.map},null,8,["map"]),e.createElementVNode("div",xi,[e.createVNode(c,{map:o.map,bbox:(y=o.data)==null?void 0:y.bounds},null,8,["map","bbox"])]),e.createVNode(d,{mapId:o.mapId,colors:(m=o.data)==null?void 0:m.colors,sizes:(f=o.data)==null?void 0:f.sizes,color:o.baseColor,changeOpacityItem:"true",cluster:"true"},null,8,["mapId","colors","sizes","color"])],8,bi),[[e.vShow,o.activeTab=="map"]]),e.withDirectives(e.createVNode(p,{mapId:o.mapId,source:(k=o.data)==null?void 0:k.rows,total:((_=o.data)==null?void 0:_.total)||0,count:((V=o.data)==null?void 0:V.count)||0,onKattotg:t[0]||(t[0]=w=>o.kattotg=w)},null,8,["mapId","source","total","count"]),[[e.vShow,o.activeTab=="table"]]),e.withDirectives(e.createElementVNode("div",ki,[(h=(x=o.data)==null?void 0:x.rows)!=null&&h.length?(e.openBlock(),e.createBlock(u,{key:0,source:($=(b=o.data)==null?void 0:b.rows)==null?void 0:$.map(w=>({title:w==null?void 0:w.title,metric:w==null?void 0:w.metric}))},null,8,["source"])):e.createCommentVNode("",!0)],512),[[e.vShow,o.activeTab=="chart"]])])}const _i=Object.freeze(Object.defineProperty({__proto__:null,default:z(pi,[["render",wi]])},Symbol.toStringTag,{value:"Module"})),$i={name:"VsTable",mixins:[j],data(){return{values:null,xs:null,products:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){try{const s=Array.from(new Set(this.sourceData.map(t=>t[this.dimensions[0]])));this.dimensions[0].includes("date")?this.xs=s.map(t=>he(t)):this.xs=[...s],this.products=this.dimensions.filter((t,r)=>r!=0),this.values=this.products.map((t,r)=>({name:t,data:this.sourceData.filter(n=>parseFloat(n[t])).map(n=>v(parseFloat(n[t])))}))}catch(s){console.error(s)}}}},Ei={class:"flex flex-col h-full pt-[16px] pb-[16px] space-y-4 rounded-xl"},Bi={class:"overflow-auto h-full [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-stone-100 [&::-webkit-scrollbar-thumb]:bg-stone-300"},Vi={class:"inline-block min-w-full align-middle"},Di={class:"relative min-w-full divide-y divide-gray-200 text-[12px]"},Ci={class:"sticky top-0 bg-white w-full after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200"},Ni={class:"space-x-2"},Si={scope:"col",class:"xl:min-w-[120px] min-w-48"},zi={class:"flex items-center px-1 py-3 font-medium text-gray-800 text-start gap-x-1"},Li={class:"divide-y divide-gray-200"},Ti={class:"text-gray-600"};function Ii(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Ei,[e.createElementVNode("div",Bi,[e.createElementVNode("div",Vi,[e.createElementVNode("table",Di,[e.createElementVNode("thead",Ci,[e.createElementVNode("tr",Ni,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.dimensions,a=>(e.openBlock(),e.createElementBlock("th",Si,[e.createElementVNode("div",zi,e.toDisplayString(a),1)]))),256))])]),e.createElementVNode("tbody",Li,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>(e.openBlock(),e.createElementBlock("tr",{key:i},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.dimensions,(c,d)=>(e.openBlock(),e.createElementBlock("td",{key:d,class:"py-3 whitespace-nowrap"},[e.createElementVNode("span",Ti,e.toDisplayString(a==null?void 0:a[c]),1)]))),128))]))),128))])])])])])}const Mi=Object.freeze(Object.defineProperty({__proto__:null,default:z($i,[["render",Ii]])},Symbol.toStringTag,{value:"Module"}));T.AllDashboardsPage=Bt,T.EditorRootPage=Co,T.ROUTES_NAMES=W,T.Urls=tt,T.VsBar=We,T.VsDashboard=xr,T.VsDonut=Ct,T.VsEditorPage=Et,T.VsLine=St,T.VsListBar=Tt,T.VsPie=Nt,T.VsPivotTable=It,T.VsProgressBar=Lt,T.VsStat=zt,T.VsWidget=ne,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
229
+ </div>`;const o=this.map.project(s.lngLat);this.popupElement.style.left=`${o.x}px`,this.popupElement.style.top=`${o.y-60}px`,this.map.getContainer().appendChild(this.popupElement)}catch(r){console.error(r)}}}},ii={class:"h-full"},ci={class:"flex items-start justify-between mb-[6px] w-full"},di={class:"text-gray-800 font-[600]"},pi={class:"flex gap-2"},hi=["onClick"],ui=["id"],mi=["id"],fi={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"},gi={class:"h-[calc(250px)]"};function bi(s,t,r,n,o,l){var y,m,f,k,_,V,x,h,b,$;const a=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapGoHome"),d=e.resolveComponent("VsClusterLegend"),p=e.resolveComponent("VsList"),u=e.resolveComponent("VsBar");return e.openBlock(),e.createElementBlock("div",ii,[e.createElementVNode("div",ci,[e.createElementVNode("h3",di,e.toDisplayString(s.title),1),e.createElementVNode("div",pi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,w=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["p-1 text-gray-700 border rounded",[o.activeTab===(w==null?void 0:w.id)?"ring-2 ring-blue-500":""]]),onClick:g=>o.activeTab=w==null?void 0:w.id},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(w==null?void 0:w.component),{height:"16",width:"16"}))],10,hi))),256))])]),e.withDirectives(e.createElementVNode("div",{class:"relative w-full h-[calc(100%-40px)]",id:`wrapper-${o.mapId}`},[e.createElementVNode("div",{id:o.mapId,class:"h-full w-full flex items-end min-h-[250px]"},null,8,mi),o.showSetting?(e.openBlock(),e.createBlock(a,{key:0,map:o.map,coordinates:o.coordinatesByMouse},null,8,["map","coordinates"])):e.createCommentVNode("",!0),e.createVNode(i,{map:o.map},null,8,["map"]),e.createElementVNode("div",fi,[e.createVNode(c,{map:o.map,bbox:(y=o.data)==null?void 0:y.bounds},null,8,["map","bbox"])]),e.createVNode(d,{mapId:o.mapId,colors:(m=o.data)==null?void 0:m.colors,sizes:(f=o.data)==null?void 0:f.sizes,color:o.baseColor,changeOpacityItem:"true",cluster:"true"},null,8,["mapId","colors","sizes","color"])],8,ui),[[e.vShow,o.activeTab=="map"]]),e.withDirectives(e.createVNode(p,{mapId:o.mapId,source:(k=o.data)==null?void 0:k.rows,total:((_=o.data)==null?void 0:_.total)||0,count:((V=o.data)==null?void 0:V.count)||0,onKattotg:t[0]||(t[0]=w=>o.kattotg=w)},null,8,["mapId","source","total","count"]),[[e.vShow,o.activeTab=="table"]]),e.withDirectives(e.createElementVNode("div",gi,[(h=(x=o.data)==null?void 0:x.rows)!=null&&h.length?(e.openBlock(),e.createBlock(u,{key:0,source:($=(b=o.data)==null?void 0:b.rows)==null?void 0:$.map(w=>({title:w==null?void 0:w.title,metric:w==null?void 0:w.metric}))},null,8,["source"])):e.createCommentVNode("",!0)],512),[[e.vShow,o.activeTab=="chart"]])])}const yi=Object.freeze(Object.defineProperty({__proto__:null,default:L(li,[["render",bi]])},Symbol.toStringTag,{value:"Module"})),xi={name:"VsTable",mixins:[j],data(){return{values:null,xs:null,products:null}},async mounted(){await this.getData(),this.prepareData()},methods:{onChangedData(){try{this.sourceData&&this.prepareData()}catch{}},prepareData(){try{const s=Array.from(new Set(this.sourceData.map(t=>t[this.dimensions[0]])));this.dimensions[0].includes("date")?this.xs=s.map(t=>pe(t)):this.xs=[...s],this.products=this.dimensions.filter((t,r)=>r!=0),this.values=this.products.map((t,r)=>({name:t,data:this.sourceData.filter(n=>parseFloat(n[t])).map(n=>U(parseFloat(n[t])))}))}catch(s){console.error(s)}}}},ki={class:"flex flex-col h-full pt-[16px] pb-[16px] space-y-4 rounded-xl"},wi={class:"overflow-auto h-full [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-stone-100 [&::-webkit-scrollbar-thumb]:bg-stone-300"},_i={class:"inline-block min-w-full align-middle"},$i={class:"relative min-w-full divide-y divide-gray-200 text-[12px]"},Ei={class:"sticky top-0 bg-white w-full after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200"},Bi={class:"space-x-2"},Vi={scope:"col",class:"xl:min-w-[120px] min-w-48"},Di={class:"flex items-center px-1 py-3 font-medium text-gray-800 text-start gap-x-1"},Ci={class:"divide-y divide-gray-200"},Ni={class:"text-gray-600"};function Si(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",ki,[e.createElementVNode("div",wi,[e.createElementVNode("div",_i,[e.createElementVNode("table",$i,[e.createElementVNode("thead",Ei,[e.createElementVNode("tr",Bi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.dimensions,a=>(e.openBlock(),e.createElementBlock("th",Vi,[e.createElementVNode("div",Di,e.toDisplayString(a),1)]))),256))])]),e.createElementVNode("tbody",Ci,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>(e.openBlock(),e.createElementBlock("tr",{key:i},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.dimensions,(c,d)=>(e.openBlock(),e.createElementBlock("td",{key:d,class:"py-3 whitespace-nowrap"},[e.createElementVNode("span",Ni,e.toDisplayString(a==null?void 0:a[c]),1)]))),128))]))),128))])])])])])}const zi=Object.freeze(Object.defineProperty({__proto__:null,default:L(xi,[["render",Si]])},Symbol.toStringTag,{value:"Module"}));z.AllDashboardsPage=$t,z.EditorRootPage=Eo,z.ROUTES_NAMES=W,z.Urls=Ye,z.VsBar=Fe,z.VsDashboard=fr,z.VsDonut=Vt,z.VsEditorPage=_t,z.VsLine=Ct,z.VsListBar=zt,z.VsPie=Dt,z.VsPivotTable=Lt,z.VsProgressBar=St,z.VsStat=Nt,z.VsWidget=re,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});