@opengis/bi 1.2.26 → 1.2.27
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.js +1 -1
- package/dist/bi.umd.cjs +54 -49
- package/dist/{import-file-CmkUI20t.js → import-file-DN5MrFOd.js} +1237 -1202
- package/dist/{vs-funnel-bar-Bm8btLrA.js → vs-funnel-bar-DwVkX7Q2.js} +1 -1
- package/dist/{vs-list-CmnCSjGF.js → vs-list-BWyOIZbY.js} +1 -1
- package/dist/{vs-map-3A5t9VTQ.js → vs-map-BeYJ2aj0.js} +2 -2
- package/dist/{vs-map-cluster-DKZhfi6w.js → vs-map-cluster-ltvourI_.js} +2 -2
- package/dist/{vs-number-BM6bcbqf.js → vs-number-BvAcFzRT.js} +1 -1
- package/dist/{vs-table-CYix8IRT.js → vs-table-CBFIS-pF.js} +1 -1
- package/dist/{vs-text-gU23_bK6.js → vs-text-GIhpwEL4.js} +1 -1
- package/package.json +2 -2
package/dist/bi.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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,
|
|
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,q){"use strict";var Ti=Object.defineProperty;var Ii=(z,e,q)=>e in z?Ti(z,e,{enumerable:!0,configurable:!0,writable:!0,value:q}):z[e]=q;var I=(z,e,q)=>Ii(z,typeof e!="symbol"?e+"":e,q);/**
|
|
2
2
|
* @license lucide-vue-next v0.577.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -43,117 +43,122 @@
|
|
|
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
|
|
46
|
+
*/const P=(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 hs=
|
|
51
|
+
*/const hs=P("arrow-up-down",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/**
|
|
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 us=
|
|
56
|
+
*/const us=P("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
|
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 ms=
|
|
61
|
+
*/const ms=P("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"}]]);/**
|
|
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 fs=
|
|
66
|
+
*/const fs=P("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"}]]);/**
|
|
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 gs=
|
|
71
|
+
*/const gs=P("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"}]]);/**
|
|
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 bs=
|
|
76
|
+
*/const bs=P("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"}]]);/**
|
|
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 ys=
|
|
81
|
+
*/const ys=P("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"}]]);/**
|
|
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 xs=
|
|
86
|
+
*/const xs=P("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"}]]);/**
|
|
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 ks=
|
|
91
|
+
*/const ks=P("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"}]]);/**
|
|
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 ws=
|
|
96
|
+
*/const ws=P("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"}]]);/**
|
|
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=
|
|
101
|
+
*/const _s=P("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"}]]);/**
|
|
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
|
|
106
|
+
*/const $s=P("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"}]]);/**
|
|
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
|
|
111
|
+
*/const Ge=P("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
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
|
|
116
|
+
*/const Es=P("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"}]]);/**
|
|
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
|
|
121
|
+
*/const Ze=P("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/**
|
|
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
|
|
126
|
+
*/const Vs=P("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"}]]);/**
|
|
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 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={"&":"&","<":"<",">":">",'"':""","'":"'"},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(`
|
|
131
|
+
*/const Bs=P("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"}]]);/**
|
|
132
|
+
* @license lucide-vue-next v0.577.0 - ISC
|
|
133
|
+
*
|
|
134
|
+
* This source code is licensed under the ISC license.
|
|
135
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
+
*/const Qe=P("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Ce={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((g,w)=>({id:w,text:g.trim()})):Array.isArray(m)?m:[]}),c=e.computed(()=>{const m=i.value.find(g=>(g.id??g)===l.value);return m?m.text??String(m):r.title??""}),d=m=>{const g=(m==null?void 0:m.id)??m;l.value=g,o.value=!1,n("selected",g),document.removeEventListener("click",p)},p=m=>{a.value&&!a.value.contains(m.target)&&(o.value=!1,document.removeEventListener("click",p))},h=()=>{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,g)=>(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:h},[e.createTextVNode(e.toDisplayString(y(c.value))+" ",1),g[0]||(g[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,w=>(e.openBlock(),e.createElementBlock("div",{key:w.id||w,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(w)},[e.createElementVNode("div",Cs,[e.createElementVNode("span",null,e.toDisplayString(y(w.text||w)),1),l.value===(w.id||w)?(e.openBlock(),e.createElementBlock("span",Ns,[...g[1]||(g[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)]))}}),L=(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=L(Ts,[["render",Ms]]),Xe={"bi-bar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>To)),"bi-number":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ha)),"bi-text":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ja)),"bi-listbar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ba)),"bi-pie":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Oo)),"bi-donut":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Po)),"bi-line":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Uo)),"bi-stat":e.defineAsyncComponent(()=>Promise.resolve().then(()=>aa)),"bi-pivot":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Aa)),"bi-progress":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ya)),"bi-funnel":e.defineAsyncComponent(()=>Promise.resolve().then(()=>tl)),"bi-map":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Yl)),"bi-cluster":e.defineAsyncComponent(()=>Promise.resolve().then(()=>xi)),"bi-table":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Li))};let Je="/api";function ye(s){Je=s||"/api"}function Ps(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=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 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"})}},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"},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 u,b;const x=(u=r.dashboardWidgets)==null?void 0:u.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 u;const x=(u=r.dashboardWidgets)==null?void 0:u.find(b=>b.name===r.widget);return(x==null?void 0:x.type)??"text"}),h=e.computed(()=>{var x,u;return r.height||((u=(x=i.value)==null?void 0:x.style)==null?void 0:u.height)||480}),y=e.computed(()=>{var u;const x=(u=i.value)==null?void 0:u.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 g(x,u){var b,_;(_=(b=l.value)==null?void 0:b.changeStyle)==null||_.call(b,x,u)}function w(x,u){const b=c.value.find(_=>_.name===u);b?b.option=x:c.value.push({name:u,option:x}),$()}function $(){var u,b;let x=`/bi-data?dashboard=${r.dashboard}&widget=${r.widget}`;c.value.forEach(_=>{x+=`&${_.name}=${_.option}`}),(b=(u=l.value)==null?void 0:u.getDataFromURL)==null||b.call(u,x)}function B(){const x=a.value;if(x!=null&&x.getDataURL){const u=x.getDataURL({type:"png",pixelRatio:2,backgroundColor:"#ffffff"}),b=document.createElement("a");b.href=u,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 u,b;x&&((b=(u=l.value)==null?void 0:u.setFilter)==null||b.call(u,x))}),e.watch(()=>r.selectedWidget,(x,u)=>{var b;x!==u&&x===((b=i.value)==null?void 0:b.id)&&n("update:current-widget-data",i.value)}),e.watch(i,(x,u)=>{(x==null?void 0:x.id)!==(u==null?void 0:u.id)&&n("update:current-widget-data",x)},{deep:!0}),(x,u)=>{var b,_,k;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:h.value+"px",maxHeight:h.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(f=>(f==null?void 0:f.options)&&(f==null?void 0:f.name)!=="export"),f=>{var E,V;return e.openBlock(),e.createElementBlock("div",{key:f==null?void 0:f.name},[Array.isArray(f==null?void 0:f.options)?(e.openBlock(),e.createBlock(Ss,{key:0,title:f==null?void 0:f.name,options:f==null?void 0:f.options,value:((V=(E=i.value)==null?void 0:E.data)==null?void 0:V[f==null?void 0:f.name])??null,onSelected:C=>w(C,f==null?void 0:f.name)},null,8,["title","options","value","onSelected"])):typeof f.options=="boolean"?(e.openBlock(),e.createBlock(Ls,{key:1,"left-label":f==null?void 0:f.name,"model-value":!!(f!=null&&f.options),"onUpdate:isEnabled":C=>g(f==null?void 0:f.name,C)},null,8,["left-label","model-value","onUpdate:isEnabled"])):e.createCommentVNode("",!0)])}),128)),(k=y.value)!=null&&k.some(f=>(f==null?void 0:f.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:B},[e.createVNode(e.unref(ms),{size:16,class:"text-gray-800"})])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])])])),e.createElementVNode("div",{class:"w-full h-full",onClick:u[2]||(u[2]=e.withModifiers(()=>{},["stop"]))},[m.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(m.value),{key:0,ref_key:"chartRef",ref:l,"current-widget":a.value,"onUpdate:currentWidget":u[0]||(u[0]=f=>a.value=f),"widget-data":i.value,"onUpdate:widgetData":u[1]||(u[1]=f=>i.value=f),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)}}}),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(gs),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=q.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(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,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 h;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]"])},[(h=d.widgets)!=null&&h.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-all-dashboards",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 g;const n=e.defineAsyncComponent(()=>import("@opengis/form")),o=(g=e.getCurrentInstance().proxy)==null?void 0:g.$notify,l=r,a=s,i=e.ref(!1),c=e.ref({}),d=e.ref();function p(){i.value=!0}function h(){i.value=!1}t({open:p,close:h});const y=async()=>{var w;try{const $=(w=d.value)==null?void 0:w.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 B=($==null?void 0:$.message)||"При спробі створити віджет сталася помилка. Перевірте обов'язкові поля (зокрема Type).";o==null||o({type:"error",title:"Помилка!",message:B})}},m=e.computed(()=>{var w,$,B,x;return{title:{type:"text",label:"Назва віджета",placeholder:"Назва віджета",validators:["required"]},x:{type:"select",label:"Вісь X",view:"buttons",style:{size:"xs"},validators:["required"],options:($=(w=a.columns)==null?void 0:w.filter(u=>(u==null?void 0:u.type)=="text"||(u==null?void 0:u.type)==="date"||(u==null?void 0:u.type)==="timestamp without time zone"||(u==null?void 0:u.type)==="boolean"||(u==null?void 0:u.type)==="integer"))==null?void 0:$.map(({name:u,type:b})=>({id:u,text:u,type:b}))},metric:{type:"select",label:"Вісь Y",view:"buttons",validators:["required"],style:{size:"xs"},options:[{id:"count",label:"count"},...(x=(B=a.columns)==null?void 0:B.filter(u=>(u==null?void 0:u.type)==="numeric"||(u==null?void 0:u.type)==="double precision"))==null?void 0:x.map(({name:u,type:b})=>({id:u,text:u,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(w,$)=>{const B=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock("div",null,[s.inline?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(B,{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:h},{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:h,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"},Vr={__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 _,k,f,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)||((f=(k=a.data)==null?void 0:k.data)==null?void 0:f.type),h={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:"Показати легенду"}},g={show:{label:"Тултіп",type:"switcher",title:"Показати тултіп"}},w=(E=a.data)==null?void 0:E.style,$=e.ref(w!=null&&w.label?{...w.label}:{show:h.label}),B=e.ref(w!=null&&w.legend?{...w.legend}:{show:h.legend}),x=e.ref(w!=null&&w.tooltip?{...w.tooltip}:{show:h.tooltip}),u=()=>{const V=new CustomEvent(`update-style-${a.widgetName}`);V.chartId=a.widgetName,V.options={options:{legend:B.value,tooltip:x.value,label:$.value},seriesOptions:$.value},window.dispatchEvent(V)};e.watch($,u,{deep:!0}),e.watch(B,u,{deep:!0}),e.watch(x,u,{deep:!0});const b=async()=>{try{await R.put(`/bi-dashboard/${c.value}/${a.widgetName}`,{style:{legend:B.value,tooltip:x.value,label:$.value}});const V=new CustomEvent(`update-style-${a.widgetName}`);V.chartId=a.widgetName,V.options={options:{legend:B.value,tooltip:x.value,label:$.value},seriesOptions:$.value},window.dispatchEvent(V),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const V=new URLSearchParams(window.top.location.search);i.value=V.get("dashboard"),u()}),t({requestUpdateWidget:b}),(V,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:B.value,"onUpdate:values":C[1]||(C[1]=M=>B.value=M),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(n),{schema:g,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=/[&<>"']/,Br=new RegExp(nt.source,"g"),ot=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Dr=new RegExp(ot.source,"g"),Cr={"&":"&","<":"<",">":">",'"':""","'":"'"},at=s=>Cr[s];function A(s,t){if(t){if(nt.test(s))return s.replace(Br,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
137
|
`).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
138
|
`)}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
139
|
`)}}}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
140
|
`)}}blockquote(t){const r=this.rules.block.blockquote.exec(t);if(r){let n=ae(r[0],`
|
|
136
141
|
`).split(`
|
|
137
142
|
`),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
|
-
`),
|
|
143
|
+
`),h=p.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
|
|
139
144
|
$1`).replace(/^ {0,3}>[ \t]?/gm,"");o=o?`${o}
|
|
140
145
|
${p}`:p,l=l?`${l}
|
|
141
|
-
${
|
|
146
|
+
${h}`:h;const y=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,a,!0),this.lexer.state.top=y,n.length===0)break;const m=a[a.length-1];if((m==null?void 0:m.type)==="code")break;if((m==null?void 0:m.type)==="blockquote"){const g=m,w=g.raw+`
|
|
142
147
|
`+n.join(`
|
|
143
|
-
`)
|
|
148
|
+
`),$=this.blockquote(w);a[a.length-1]=$,o=o.substring(0,o.length-g.raw.length)+$.raw,l=l.substring(0,l.length-g.text.length)+$.text;break}else if((m==null?void 0:m.type)==="list"){const g=m,w=g.raw+`
|
|
144
149
|
`+n.join(`
|
|
145
|
-
`)
|
|
146
|
-
`);continue}}return{type:"blockquote",raw:o,tokens:a,text:l}}}list(t){let r=this.rules.block.list.exec(t);if(r){let n=r[1].trim();const o=n.length>1,l={type:"list",raw:"",ordered:o,start:o?+n.slice(0,-1):"",loose:!1,items:[]};n=o?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=o?n:"[*+-]");const a=new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);let i=!1;for(;t;){let c=!1,d="",p="";if(!(r=a.exec(t))||this.rules.block.hr.test(t))break;d=r[0],t=t.substring(d.length);let
|
|
147
|
-
`,1)[0].replace(/^\t+/,
|
|
148
|
-
`,1)[0],m=!
|
|
149
|
-
`,t=t.substring(y.length+1),c=!0),!c){const
|
|
150
|
-
`,1)[0];let
|
|
151
|
-
`+
|
|
152
|
-
`+y}!m&&!y.trim()&&(m=!0),d+=
|
|
153
|
-
`,t=t.substring(
|
|
150
|
+
`),$=this.list(w);a[a.length-1]=$,o=o.substring(0,o.length-m.raw.length)+$.raw,l=l.substring(0,l.length-g.raw.length)+$.raw,n=w.substring(a[a.length-1].raw.length).split(`
|
|
151
|
+
`);continue}}return{type:"blockquote",raw:o,tokens:a,text:l}}}list(t){let r=this.rules.block.list.exec(t);if(r){let n=r[1].trim();const o=n.length>1,l={type:"list",raw:"",ordered:o,start:o?+n.slice(0,-1):"",loose:!1,items:[]};n=o?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=o?n:"[*+-]");const a=new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);let i=!1;for(;t;){let c=!1,d="",p="";if(!(r=a.exec(t))||this.rules.block.hr.test(t))break;d=r[0],t=t.substring(d.length);let h=r[2].split(`
|
|
152
|
+
`,1)[0].replace(/^\t+/,B=>" ".repeat(3*B.length)),y=t.split(`
|
|
153
|
+
`,1)[0],m=!h.trim(),g=0;if(this.options.pedantic?(g=2,p=h.trimStart()):m?g=r[1].length+1:(g=r[2].search(/[^ ]/),g=g>4?1:g,p=h.slice(g),g+=r[1].length),m&&/^[ \t]*$/.test(y)&&(d+=y+`
|
|
154
|
+
`,t=t.substring(y.length+1),c=!0),!c){const B=new RegExp(`^ {0,${Math.min(3,g-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),x=new RegExp(`^ {0,${Math.min(3,g-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),u=new RegExp(`^ {0,${Math.min(3,g-1)}}(?:\`\`\`|~~~)`),b=new RegExp(`^ {0,${Math.min(3,g-1)}}#`),_=new RegExp(`^ {0,${Math.min(3,g-1)}}<(?:[a-z].*>|!--)`,"i");for(;t;){const k=t.split(`
|
|
155
|
+
`,1)[0];let f;if(y=k,this.options.pedantic?(y=y.replace(/^ {1,4}(?=( {4})*[^ ])/g," "),f=y):f=y.replace(/\t/g," "),u.test(y)||b.test(y)||_.test(y)||B.test(y)||x.test(y))break;if(f.search(/[^ ]/)>=g||!y.trim())p+=`
|
|
156
|
+
`+f.slice(g);else{if(m||h.replace(/\t/g," ").search(/[^ ]/)>=4||u.test(h)||b.test(h)||x.test(h))break;p+=`
|
|
157
|
+
`+y}!m&&!y.trim()&&(m=!0),d+=k+`
|
|
158
|
+
`,t=t.substring(k.length+1),h=f.slice(g)}}l.loose||(i?l.loose=!0:/\n[ \t]*\n[ \t]*$/.test(d)&&(i=!0));let w=null,$;this.options.gfm&&(w=/^\[[ xX]\] /.exec(p),w&&($=w[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),l.items.push({type:"list_item",raw:d,task:!!w,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(h=>h.type==="space"),p=d.length>0&&d.some(h=>/\n.*\n/.test(h.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
159
|
`):[],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
|
|
156
|
-
]`).replace("lheading",pt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},mt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
160
|
+
`?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 h=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,r=r.slice(-1*t.length+a);(o=h.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 w=m.slice(1,-1);return{type:"em",raw:m,text:w,tokens:this.lexer.inlineTokens(w)}}const g=m.slice(2,-2);return{type:"strong",raw:m,text:g,tokens:this.lexer.inlineTokens(g)}}}}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()},Or={...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} *[^
|
|
161
|
+
]`).replace("lheading",pt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},mt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ar=/^(`+)([^`]|[^`][\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:Ar,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:Or},ce={normal:Me,gfm:Re,breaks:sn,pedantic:tn};class v{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 v(r).lex(t)}static lexInline(t,r){return new v(r).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
157
162
|
`),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
163
|
`: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
164
|
`+o.raw,l.text+=`
|
|
@@ -163,7 +168,7 @@ ${u}`:u;const y=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
|
|
|
163
168
|
`+o.raw,l.text+=`
|
|
164
169
|
`+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
170
|
`+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
|
|
171
|
+
`+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 h=t.slice(1);let y;this.options.extensions.startInline.forEach(m=>{y=m.call({lexer:this},h),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||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
172
|
`;return o?'<pre><code class="language-'+A(o)+'">'+(n?l:A(l,!0))+`</code></pre>
|
|
168
173
|
`:"<pre><code>"+(n?l:A(l,!0))+`</code></pre>
|
|
169
174
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
@@ -181,14 +186,14 @@ ${this.parser.parse(t)}</blockquote>
|
|
|
181
186
|
`}tablerow({text:t}){return`<tr>
|
|
182
187
|
${t}</tr>
|
|
183
188
|
`}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=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
|
|
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?
|
|
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=`
|
|
189
|
+
`}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 U{constructor(t){I(this,"options");I(this,"renderer");I(this,"textRenderer");this.options=t||J,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 Pe}static parse(t,r){return new U(r).parse(t)}static parseInline(t,r){return new U(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+=`
|
|
190
|
+
`+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?v.lex:v.lexInline}provideParser(){return this.block?U.parse:U.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",U);I(this,"Renderer",Ve);I(this,"TextRenderer",Pe);I(this,"Lexer",v);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 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 h=c.apply(l,p);return h===!1&&(h=d.apply(l,p)),h||""}}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 h=c.apply(l,p);return h===!1&&(h=d.apply(l,p)),h}}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 h=c.call(l,p);return d.call(l,h)}:l[i]=(...p)=>{let h=c.apply(l,p);return h===!1&&(h=d.apply(l,p)),h}}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 v.lex(t,r??this.defaults)}parser(t,r){return U.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?v.lex:v.lexInline,d=a.hooks?a.hooks.provideParser():t?U.parse:U.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 h=d(p,a);return a.hooks&&(h=a.hooks.postprocess(h)),h}catch(p){return i(p)}}}onError(t,r){return n=>{if(n.message+=`
|
|
191
|
+
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=U,S.parser=U.parse,S.Renderer=Ve,S.TextRenderer=Pe,S.Lexer=v,S.lexer=v.lex,S.Tokenizer=we,S.Hooks=de,S.parse=S,S.options,S.setOptions,S.use,S.walkTokens,S.parseInline,U.parse,v.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 _,k,f,E,V,C,M,O,G,Q,he,ue,me,fe,ge,F,X,be,jt,Ot,At,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}),h=e.computed(()=>a.dashboardId||c.value);async function y(){if(a.columns!==null)return;const D=h.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,g=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,w=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 g(D)}),$=e.computed(()=>`${a.widgetName}-${w.value.length}-${(p.value??[]).length}`),B=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:[...w.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"},...g(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"},...g(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:g((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:((k=(_=a.data)==null?void 0:_.data)==null?void 0:k.x)||((f=a.data)==null?void 0:f.x)||null,metric:((V=(E=a.data)==null?void 0:E.data)==null?void 0:V.metric)||((C=a.data)==null?void 0:C.metric)||null,columns:((O=(M=a.data)==null?void 0:M.data)==null?void 0:O.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=(F=a.data)==null?void 0:F.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)||((Ot=a.data)==null?void 0:Ot.fx)||null,query:((qt=(At=a.data)==null?void 0:At.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}),u=async()=>{try{await R.put(`/bi-dashboard/${h.value}/${a.widgetName}`,{data:x.value});let D=`/bi-data?dashboard=${h.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=${h.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:u}),(D,N)=>(e.openBlock(),e.createElementBlock("div",nn,[(e.openBlock(),e.createBlock(e.unref(n),{key:$.value,schema:B.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:g,source:w})=>{const $=m.getOption(),{data:B,...x}=($==null?void 0:$.series)[0],[,...u]=g||[],b=u.map((_,k)=>({...($==null?void 0:$.series[k])||{},data:w.map(f=>f[k+1]),name:_}));m==null||m.setOption({...$||{},dataset:{dimensions:g,source:w},series:b,xAxis:{type:"category"},yAxis:{}},!0)},p=m=>{const g=document.getElementById(m);if(!g)return null;const w=n==null?void 0:n.getInstanceByDom(g);return w||null},h=e.ref(c.yamlValue),y=async()=>{try{await R.put(`/bi-dashboard/${l.value}/${c.widgetName}`,{yml:h.value});const m=p(c.widgetName);if(m){const g=await R.get(`/bi-data?dashboard=${l.value}&widget=${c.widgetName}`);d(m,g)}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,g)=>(e.openBlock(),e.createElementBlock("div",an,[e.createVNode(e.unref(o),{modelValue:h.value,"onUpdate:modelValue":g[0]||(g[0]=w=>h.value=w),syntax:"yaml",theme:"vs-light",height:400,minimap:!1},null,8,["modelValue"])]))}},cn={class:"pt-[10px]"},yt={"vs-editor-form-style":Vr,"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:h})=>h)}},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 h=new URLSearchParams(window.top.location.search);a.value=h.get("dashboard")}),(h,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]=g=>c.value=g)},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:Object,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=q.useRouter(),l=t,a=e.ref(null),i=s,c=e.ref(!1),d=e.ref(!0),p=e.ref(!1),h=e.ref({}),y=e.useModel(s,"selectedWidget"),m=["table","text","number","stat","progress","listbar","map","pivot"],g=e.ref("data"),w=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(k){console.error(k),n({type:"error",title:"Помилка!",message:"При спробі видалити віджет виникла помилка"})}},$=e.computed(()=>{const k=[{id:"data",label:"Дані"},{id:"style",label:"Стилі"},{id:"yaml",label:"{ }"}];return k==null?void 0:k.filter(f=>{var E,V,C;return f.id==="style"?!(m!=null&&m.includes(((E=i.selectedWidgetData)==null?void 0:E.type)||((C=(V=i.selectedWidgetData)==null?void 0:V.data)==null?void 0:C.type))):!0})}),B=()=>{var k,f,E,V,C,M,O,G,Q;h.value={title:(k=i.selectedWidgetData)==null?void 0:k.title,type:(f=i.selectedWidgetData)==null?void 0:f.type,table:(E=i.selectedWidgetData)==null?void 0:E.table_name,query:(C=(V=i.selectedWidgetData)==null?void 0:V.data)==null?void 0:C.query,x:(O=(M=i.selectedWidgetData)==null?void 0:M.data)==null?void 0:O.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}`,h.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 u={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(k,f)=>{var V,C,M,O,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,F=>(e.openBlock(),e.createElementBlock("button",{key:F.id,type:"button",class:e.normalizeClass(["relative pb-3 pt-1 text-sm font-medium transition-colors whitespace-nowrap",g.value===F.id?"text-blue-600":"text-gray-600 hover:text-gray-900"]),onClick:X=>g.value=F.id},[e.createTextVNode(e.toDisplayString(F.label)+" ",1),g.value===F.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:f[0]||(f[0]=F=>{var X,be;return(be=(X=a.value)==null?void 0:X.save)==null?void 0:be.call(X)})},[e.createVNode(e.unref(Es),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[f[9]||(f[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:B},[e.createVNode(st,{class:"h-4 w-4"})])]),default:e.withCtx(()=>[f[10]||(f[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:f[1]||(f[1]=F=>c.value=!0)},[e.createVNode(e.unref(tt),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[f[11]||(f[11]=e.createTextVNode(" Видалити віджет ",-1))]),_:1})])]),(V=s.currentWidgetData)!=null&&V.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":g.value,"tab-component":e.unref(yt)["vs-editor-form-"+g.value],widgetName:(O=s.selectedWidgetData)==null?void 0:O.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:f[2]||(f[2]=F=>k.$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":g.value,"tab-component":e.unref(yt)["vs-editor-form-"+g.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:f[3]||(f[3]=F=>k.$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:f[5]||(f[5]=F=>c.value=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",wn,[f[12]||(f[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:f[4]||(f[4]=F=>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:w}," Так, я впевнена(ий) ")])])]),_: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:f[8]||(f[8]=F=>p.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",$n,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:f[7]||(f[7]=F=>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(()=>[u?(e.openBlock(),e.createBlock(e.unref(r),{key:0,schema:u,values:h.value,"onUpdate:values":f[6]||(f[6]=F=>h.value=F)},null,8,["values"])):e.createCommentVNode("",!0)]),_:1},8,["visible"])],64)}}},Vn={class:"overflow-hidden flex flex-col min-h-[480px]"},Bn={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",Vn,[e.createElementVNode("div",Bn,[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(ks),e.mergeProps(t.$attrs,{size:24}),null,16))}},wt={__name:"icon-table",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(Vs),e.mergeProps(t.$attrs,{size:24}),null,16))}},zn={__name:"icon-more",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(fs),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:"Select",key:"table_name",validators:["required"],data:"pg.table_name",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 On(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]=h=>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]=h=>{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]=h=>{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]=h=>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]=h=>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]=(...h)=>l.deleteDashboard&&l.deleteDashboard(...h))}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"]),e.createVNode(d,{teleport:"#modal",visible:o.isFormEdit,title:"Редагувати дашборд",onClose:t[9]||(t[9]=h=>o.isFormEdit=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Wn,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:t[7]||(t[7]=h=>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]=(...h)=>l.editDashboard&&l.editDashboard(...h)),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]=h=>o.formEditValue=h)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createVNode(d,{teleport:"#modal",visible:o.isFormGrid,title:"Редагувати структуру дашборду",onClose:t[13]||(t[13]=h=>o.isFormGrid=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",jn,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:t[11]||(t[11]=h=>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]=(...h)=>l.editDashboardGrid&&l.editDashboardGrid(...h)),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]=h=>o.formGridValue=h)},null,8,["schema","values"])]),_:1},8,["visible"])])}const An=L(Tn,[["render",On]]),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=q.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),h=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,u,b;return(b=Array.isArray((x=d.value)==null?void 0:x.widgets)?(u=d.value)==null?void 0:u.widgets:[])==null?void 0:b.find(_=>(_==null?void 0:_.name)===c.value)});function g(x){l.value?o.push({name:W.EditorWidget,params:{dashboardId:i.value,widgetId:x}}):c.value=x}function w(){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 B=e.computed(()=>{var b,_,k,f,E;const u=[l.value?{label:"Дашборди",to:{name:W.Editor}}:{label:"Дашборди",onClick:$}];if((b=d.value)!=null&&b.title||i.value){const V=((_=d.value)==null?void 0:_.title)||i.value||"Редактор";!!c.value?u.push(l.value?{label:V,to:{name:W.EditorDashboard,params:{dashboardId:i.value}}}:{label:V,onClick:()=>{c.value=""}}):u.push({label:V})}else u.push({label:"Редактор"});if(c.value&&m.value){const V=((f=(k=m.value)==null?void 0:k.data)==null?void 0:f.title)||((E=m.value)==null?void 0:E.title)||c.value;u.push({label:V})}return u});return e.watch(i,(x,u)=>{u&&(c.value=""),x?y():(d.value=null,$())}),e.onMounted(()=>{y()}),(x,u)=>{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:B.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:w},[e.createVNode(e.unref(Qe),{class:"w-4 h-4"}),u[5]||(u[5]=e.createTextVNode(" Закрити ",-1))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(An,{selected:i.value,"onUpdate:selected":u[0]||(u[0]=k=>i.value=k),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:u[1]||(u[1]=k=>{var f,E;return(E=(f=h.value)==null?void 0:f.open)==null?void 0:E.call(f)})},[...u[6]||(u[6]=[e.createElementVNode("span",{class:"leading-none"},"+",-1),e.createTextVNode(" Створити віджет ",-1)])]),i.value?(e.openBlock(),e.createBlock($r,{key:0,ref_key:"createWidgetRef",ref:h,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":u[2]||(u[2]=k=>c.value=k),"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,(k,f)=>{var E;return e.openBlock(),e.createElementBlock("div",{key:f,class:e.normalizeClass([`md:col-span-${k.col||12} col-span-12`,"flex flex-col gap-[10px]"])},[(E=k.widgets)!=null&&E.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(k.widgets,V=>(e.openBlock(),e.createBlock(re,{onClick:C=>g(V),"onUpdate:currentWidgetData":u[3]||(u[3]=C=>p.value=C),key:V,dashboard:i.value,widget:V,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(k.height??480),class:e.normalizeClass({"border border-blue-500":c.value===V})},null,8,["onClick","dashboard","widget","selectedWidget","dashboard-widgets","height","class"]))),128)):(e.openBlock(),e.createBlock(re,{key:1,onClick:V=>g(k.widget),"onUpdate:currentWidgetData":u[4]||(u[4]=V=>p.value=V),class:e.normalizeClass(["flex flex-col",{"border border-blue-500":c.value===k.widget}]),dashboard:i.value,widget:k.widget,selectedWidget:c.value,"dashboard-widgets":d.value.widgets,height:Number(k.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=q.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(xs),{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:"Select",data:"pg.table_name",key:"table_name",validators:["required"],label:"Назва",original:{type:"select",ua:"Назва",col:8,data:"pg.table_name"}},{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={class:"relative"},wo={key:0,class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},_o={key:1,class:"flex flex-col items-center justify-center py-20 text-center"},$o={class:"mt-1 text-sm text-gray-400"},Eo={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=q.useRouter(),a=e.inject("biSetDashboard",void 0),i=s,c=e.ref(null),d=e.ref(!1),p=e.ref({}),h=e.ref(""),y=e.ref("title-asc"),m=e.computed(()=>{const b=h.value.trim().toLowerCase();let _=n.value;b&&(_=_.filter(f=>f.title.toLowerCase().includes(b)));const k=y.value==="title-asc"?1:-1;return[..._].sort((f,E)=>k*f.title.localeCompare(E.title,"uk"))});async function g(){try{const b=await R.get("/bi-dashboard?type=db"),_=Array.isArray(b==null?void 0:b.rows)?b.rows:[];o.value=_,n.value=_.map(k=>({routeName:String(k.name??""),title:k.title??k.name??"Без назви",description:k.description??null,modified:"-",name:"-"}))}catch(b){console.error("Failed to load dashboards",b),o.value=[],n.value=[]}}async function w(){var _,k,f;const b=(k=(_=e.getCurrentInstance())==null?void 0:_.proxy)==null?void 0:k.$notify;try{const E=(f=c.value)==null?void 0:f.validate();typeof E=="function"&&await E();const{name:V,title:C,table_name:M}=p.value;if(!V||!C||!M){b==null||b({type:"error",title:"Помилка!",message:"Заповніть усі обов'язкові поля"});return}await R.post("/bi-dashboard",p.value),d.value=!1,p.value={},b==null||b({type:"success",title:"Успішно!",message:"Дашборд створено успішно"}),l.hasRoute(W.EditorDashboard)?l.push({name:W.EditorDashboard,params:{dashboardId:V}}):a?a(V):await g()}catch{b==null||b({type:"error",title:"Помилка!",message:"При спробі створити дашборд виникла помилка"})}}e.onMounted(()=>{ye(i.prefix||"/api"),g()});const $=e.ref(1),B=()=>{const b=window.innerWidth;$.value=b>=1024?3:b>=768?2:1};e.onMounted(()=>{B(),window.addEventListener("resize",B)}),e.onUnmounted(()=>{window.removeEventListener("resize",B)});const x=b=>b?b.trim().length>70?2:1:0,u=b=>{const _=$.value||1,f=Math.floor(b/_)*_,E=f+_,V=m.value.slice(f,E);let C=0;for(const M of V){const O=x(M.description??null);if(O>C&&(C=O),C===2)break}return C};return e.ref("grid"),(b,_)=>(e.openBlock(),e.createElementBlock("div",uo,[e.createElementVNode("div",mo,[e.createElementVNode("div",fo,[e.createElementVNode("div",go,[_[7]||(_[7]=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:_[0]||(_[0]=k=>d.value=!0)},[e.createVNode(e.unref(Ge),{size:24,class:"w-4 h-4"}),_[6]||(_[6]=e.createElementVNode("span",null,"Новий дашборд",-1))])]),e.createVNode(ne,{teleport:"#modal",visible:d.value,title:"Створити дашборд",onClose:_[3]||(_[3]=k=>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:_[2]||(_[2]=k=>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:w}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(e.unref(t),{ref_key:"createFormRef",ref:c,schema:e.unref(r),values:p.value,"onUpdate:values":_[1]||(_[1]=k=>p.value=k)},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":_[4]||(_[4]=k=>h.value=k),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,h.value]])]),e.createElementVNode("div",ko,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":_[5]||(_[5]=k=>y.value=k),class:"appearance-none pl-3 pr-8 py-2 border border-gray-300 rounded-lg bg-white text-sm text-gray-700 cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500"},[..._[8]||(_[8]=[e.createElementVNode("option",{value:"title-asc"},"Назва (А → Я)",-1),e.createElementVNode("option",{value:"title-desc"},"Назва (Я → А)",-1)])],512),[[e.vModelSelect,y.value]]),e.createVNode(e.unref(hs),{size:16,class:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 pointer-events-none"})])])]),m.value.length?(e.openBlock(),e.createElementBlock("div",wo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(k,f)=>(e.openBlock(),e.createElementBlock("div",{key:k.routeName,class:"cursor-pointer h-full"},[e.createVNode(co,{title:k.title,description:k.description,modified:k.modified,name:k.name,reserveLines:u(f),"dashboard-route-name":k.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",_o,[e.createVNode(e.unref(Ze),{size:48,class:"text-gray-300 mb-4"}),_[11]||(_[11]=e.createElementVNode("p",{class:"text-lg font-medium text-gray-500"},"Дашбордів не знайдено",-1)),e.createElementVNode("p",$o,[_[9]||(_[9]=e.createTextVNode(" За запитом «",-1)),e.createElementVNode("span",Eo,e.toDisplayString(h.value),1),_[10]||(_[10]=e.createTextVNode("» нічого не знайдено. Спробуйте змінити пошуковий запит. ",-1))])]))])]))}}),Vo=e.defineComponent({__name:"editor-root-page",props:{prefix:{default:"/api"}},setup(s){const t=s,r=e.computed(()=>t.prefix),n=q.useRouter(),o=q.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]=h=>a.value="")},null,8,["prefix","dashboard-id"])):(e.openBlock(),e.createBlock($t,{key:0,prefix:r.value},null,8,["prefix"]))],64))}}});function H(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 Do{static getTooltipOptions(t=!0){return{show:t,confine:!0,appendToBody:!1,axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}}}}const Co={show_label:!1,show_legend:!1,label:null,legend:{position:null},colors:null,color:null,title:null};function No(){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=Co){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=>H(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=>H(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 Vt=["#d3c7e6","#bedae3","#f8e9cb","#ff8c8c","#c5d8be","#ffc6c6","#ffc39a","#fff7c5","#d8ffc0","#d4f7ff"];class Be{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,h;this.widgetInstance&&this.widgetInstance.clear();try{const y=this.$refs.chart,m=ee==null?void 0:ee.init(y);if(!m)return;const g={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:(w,$,B,x,u)=>{const[b,_]=w,[k,f]=u.contentSize,[E,V]=u.viewSize;let C=b+14,M=_-f/2;return C+k>E&&(C=b-k-14),C<0&&(C=0),M+f>V&&(M=V-f),M<0&&(M=0),[C,M]},formatter:w=>{var f;const B=(f=w[0])==null?void 0:f.axisValue,x=B?this.formatDate(B):"N/A",u=[...w].filter(E=>{var V;return parseFloat(E==null?void 0:E.data)||((V=E==null?void 0:E.data)==null?void 0:V.value)}).sort((E,V)=>{var O,G;const C=parseFloat(((O=E==null?void 0:E.data)==null?void 0:O.value)??(E==null?void 0:E.data))||0;return(parseFloat(((G=V==null?void 0:V.data)==null?void 0:G.value)??(V==null?void 0:V.data))||0)-C}),b=u.slice(0,8),_=u.length-b.length;let k=`
|
|
187
192
|
<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
193
|
<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
194
|
${x}
|
|
190
195
|
</div>
|
|
191
|
-
`;return b.forEach(E=>{
|
|
196
|
+
`;return b.forEach(E=>{k+=`
|
|
192
197
|
<div class="flex justify-between items-center text-xs px-2 py-0.5 text-gray-500 dark:text-neutral-400">
|
|
193
198
|
<span class="flex items-center">
|
|
194
199
|
<span class="w-2.5 h-2.5 me-1.5 rounded-sm" style="background-color: ${E.color};"></span>
|
|
@@ -196,19 +201,19 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
|
|
|
196
201
|
</span>
|
|
197
202
|
<span>${this.getMetricValue(E==null?void 0:E.data)}</span>
|
|
198
203
|
</div>
|
|
199
|
-
`})
|
|
204
|
+
`}),_>0&&(k+=`
|
|
200
205
|
<div class="text-xs px-2 py-0.5 text-gray-400 dark:text-neutral-500">
|
|
201
|
-
... ще ${
|
|
202
|
-
</div>`),
|
|
206
|
+
... ще ${_}
|
|
207
|
+
</div>`),k+="</div>",k}},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:w=>{var B,x;const $=this.formatDate(w);return((x=(B=this.styleData)==null?void 0:B.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,...((h=this.styleData)==null?void 0:h.grid)||{}}};await m.setOption(g),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:{...Do.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=H(t,{notation:"standard"}))==null?void 0:n.replaceAll(","," "):t}}},So={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 h;return((r=this.styleData)==null?void 0:r.stack)!==!1?h=this.prepareStackData():((n=this.styleData)==null?void 0:n.negative_waterfall)===!0?h=this.prepareNegativeWaterfall():((o=this.styleData)==null?void 0:o.waterfall)===!0?h=this.prepareWaterfallData(p):((l=this.styleData)==null?void 0:l.accumulative)===!0?h=this.prepareAccumulative(p):h=this.dimensions.slice(1).map((m,g)=>({name:m,type:"bar",stack:`a${g}`,data:this.sourceData.filter(w=>parseFloat(w[m])&&m).map(w=>parseFloat(w[m]))})),{series:h,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}]}}},zo=["id"];function Lo(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,zo)}const Fe=L(So,[["render",Lo]]),To=Object.freeze(Object.defineProperty({__proto__:null,default:Fe},Symbol.toStringTag,{value:"Module"})),We=typeof window<"u"?window.echarts:null,Io={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
208
|
<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","Не визначено")}: ${
|
|
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(
|
|
209
|
+
${r==null?void 0:r.replace("null","Не визначено")}: ${H(n)} (${o}%)
|
|
210
|
+
</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(g=>g[this.dimensions[0]]))),i=Array.from(new Set((this.sourceData||[]).map(g=>g[this.dimensions[1]]))),c=parseInt((this.sourceData||[]).reduce((g,w)=>g+parseFloat((w==null?void 0:w.metric)||0),0),10),d=a.map((g,w)=>{const $=(i[w]/c*100).toFixed(2);return{name:`${g} (${$}%)`,value:i[w]}}),p=((t=this.styleData)==null?void 0:t.innerRadius)||"80%",h=((r=this.styleData)==null?void 0:r.outerRadius)||"100%",y=[p,h];return this.styleData.legend=Be.getLegendOpions({borderRadius:10,height:"100%",padding:10,bottom:"0",type:"scroll",itemWidth:14,itemHeight:14,formatter:g=>{var w;return(w=g==null?void 0:g.replace("null","Не визначено"))==null?void 0:w.replace("NaN","0.00")},...((n=this.styleData)==null?void 0:n.legend)||{}}),this.styleData.label=Be.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:H(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)}}}},Mo=["id"];function Ro(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,Mo)}const Bt=L(Io,[["render",Ro]]),Po=Object.freeze(Object.defineProperty({__proto__:null,default:Bt},Symbol.toStringTag,{value:"Module"})),je=typeof window<"u"?window.echarts:null,Fo={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
211
|
<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","Не визначено")}: ${
|
|
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`
|
|
212
|
+
${r==null?void 0:r.replace("null","Не визначено")}: ${H(n)} (${o}%)
|
|
213
|
+
</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,g)=>m+parseFloat(g==null?void 0:g.metric),0),10),c=l.map((m,g)=>{const w=(a[g]/i*100).toFixed(2);return{name:`${m} (${w}%)`,value:a[g]}}),d=((s=this.styleData)==null?void 0:s.innerRadius)||"0%",p=((t=this.styleData)==null?void 0:t.outerRadius)||"100%",h=[d,p];return this.styleData.legend=Be.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=Be.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:h,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)}}}},Wo=["id"];function jo(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,Wo)}const Dt=L(Fo,[["render",jo]]),Oo=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}}}},qo=["id"];function vo(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",{id:o.uniqueID,ref:"chart",style:{height:"400px"}},null,8,qo)}const Ct=L(Ao,[["render",vo]]),Uo=Object.freeze(Object.defineProperty({__proto__:null,default:Ct},Symbol.toStringTag,{value:"Module"})),Ho={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<Vt.length-1?Vt[r]:No()})},formattedValue(s){const t=parseFloat(s);return H(t)}}},Go={class:"flex flex-col w-full h-full pt-[16px] rounded-xl"},Zo={class:"flex flex-col justify-between w-full h-full"},Qo={class:"w-full h-full pb-6 space-y-4"},Xo={class:"flex w-full h-3 rounded-full gap-x-1 min-h-3 custom-x-scrollbar"},Jo=["onMouseover"],Ko={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"},Yo={class:"h-[calc(100%-40px)] w-full custom-scrollbar"},ea={class:"grid items-center justify-between grid-cols-2 py-2 gap-x-4"},ta={class:"flex items-center"},sa={class:"text-sm text-gray-800"},ra={class:"text-end"},na={class:"text-sm text-gray-500"};function oa(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Go,[e.createElementVNode("div",Zo,[e.createElementVNode("div",Qo,[e.createElementVNode("div",Xo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>{var c,d,p,h;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",Ko,e.toDisplayString(s.sourceData[o.showTooltip][o.columns[0]])+" "+e.toDisplayString((parseFloat((h=(d=s.sourceData)==null?void 0:d[o.showTooltip])==null?void 0:h[(p=o.columns)==null?void 0:p[1]])/o.sumValue*100).toFixed(2))+"% ",1)):e.createCommentVNode("",!0)],46,Jo)}),256))]),e.createElementVNode("ul",Yo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,a=>{var i,c;return e.openBlock(),e.createElementBlock("li",ea,[e.createElementVNode("div",ta,[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",sa,e.toDisplayString((a==null?void 0:a[(i=o.columns)==null?void 0:i[0]])||"Не визначено"),1)]),e.createElementVNode("div",ra,[e.createElementVNode("span",na,e.toDisplayString(l.formattedValue(a==null?void 0:a[(c=o.columns)==null?void 0:c[1]])||"-"),1)])])}),256))])])])])}const Nt=L(Ho,[["render",oa]]),aa=Object.freeze(Object.defineProperty({__proto__:null,default:Nt},Symbol.toStringTag,{value:"Module"})),la={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 H(s)}}},ia={key:0,class:"flex flex-col h-full pt-[16px] rounded-xl"},ca={class:"h-full pt-0 pb-6 space-y-4"},da={class:"h-full space-y-4 custom-scrollbar"},pa={class:"flex items-center justify-between mr-2 gap-x-2"},ha={class:"grid items-center w-full grid-cols-2 gap-x-2"},ua={class:"text-sm text-gray-800"},ma={class:"flex justify-end",role:"progressbar","aria-valuenow":"100","aria-valuemin":"0","aria-valuemax":"100"},fa={class:"min-w-[60px] text-end"},ga={class:"text-sm text-gray-500"};function ba(s,t,r,n,o,l){return o.columns?(e.openBlock(),e.createElementBlock("div",ia,[e.createElementVNode("div",ca,[e.createElementVNode("ul",da,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.sourceData,(a,i)=>(e.openBlock(),e.createElementBlock("li",pa,[e.createElementVNode("div",ha,[e.createElementVNode("span",ua,e.toDisplayString(a[o.columns[0]]),1),e.createElementVNode("div",ma,[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",fa,[e.createElementVNode("span",ga,e.toDisplayString(l.formattedValue(a[o.columns[1]])),1)])]))),256))])])])):e.createCommentVNode("",!0)}const St=L(la,[["render",ba]]),ya=Object.freeze(Object.defineProperty({__proto__:null,default:St},Symbol.toStringTag,{value:"Module"})),xa={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 H(s)},getWidth(s){return`${s/this.maxValue*100}%`}}},ka={class:"h-full pt-[20px] list-bar"},wa={class:"space-y-2 custom-scrollbar h-[calc(100%-40px)]"},_a={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"},Ea={class:"text-[14px] text-gray-500"};function Va(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",ka,[e.createElementVNode("ul",wa,[(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",_a,[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,(h,y)=>(e.openBlock(),e.createElementBlock("div",{key:y,class:"w-20 mr-2 text-end"},[e.createElementVNode("span",Ea,e.toDisplayString(l.formattedValue(a==null?void 0:a[h])),1)]))),128))])}),128))])])}const zt=L(xa,[["render",Va]]),Ba=Object.freeze(Object.defineProperty({__proto__:null,default:zt},Symbol.toStringTag,{value:"Module"})),Da={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=>H(parseFloat(n[t])))}))}catch(s){console.error(s)}}}},Ca={class:"flex flex-col h-full p-5 space-y-4 rounded-xl custom-scrollbar"},Na={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"},Sa={class:"inline-block min-w-full align-middle"},za={class:"min-w-full divide-y divide-gray-200"},La={class:"space-x-2"},Ta={scope:"col",class:"xl:min-w-[120px] min-w-48"},Ia={class:"py-2.5 text-text-start flex items-center gap-x-1 text-sm font-normal text-gray-500"},Ma={class:"divide-y divide-gray-200 text-[12px]"},Ra={class:"py-3 size-px whitespace-nowrap"},Pa={class:"flex items-center gap-x-3"},Fa={class:"font-medium text-gray-800"},Wa={class:"py-3 size-px whitespace-nowrap"},ja={class:"text-gray-600"};function Oa(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Ca,[e.createElementVNode("div",Na,[e.createElementVNode("div",Sa,[e.createElementVNode("table",za,[e.createElementVNode("thead",null,[e.createElementVNode("tr",La,[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",Ta,[e.createElementVNode("div",Ia,e.toDisplayString(a),1)]))),256))])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.values,a=>(e.openBlock(),e.createElementBlock("tbody",Ma,[e.createElementVNode("tr",null,[e.createElementVNode("td",Ra,[e.createElementVNode("div",Pa,[e.createElementVNode("span",Fa,e.toDisplayString(a.name),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.xs,(i,c)=>(e.openBlock(),e.createElementBlock("td",Wa,[e.createElementVNode("span",ja,e.toDisplayString(a.data[c]),1)]))),256))])]))),256))])])])])}const Lt=L(Da,[["render",Oa]]),Aa=Object.freeze(Object.defineProperty({__proto__:null,default:Lt},Symbol.toStringTag,{value:"Module"})),qa={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)}}}},va={class:"text-lg lg:text-xl xl:text-2xl text-gray-800 h-[32px] flex items-center"};function Ua(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",va,e.toDisplayString(l.prefix)+e.toDisplayString(l.formattedNumber),1)}const Ha=Object.freeze(Object.defineProperty({__proto__:null,default:L(qa,[["render",Ua]])},Symbol.toStringTag,{value:"Module"})),Ga={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}}},Za=["id"],Qa=["innerHTML"];function Xa(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,Qa)):e.createCommentVNode("",!0)],8,Za)}const Ja=Object.freeze(Object.defineProperty({__proto__:null,default:L(Ga,[["render",Xa]])},Symbol.toStringTag,{value:"Module"})),Oe=typeof window<"u"?window.echarts:null,Ka={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
214
|
<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
|
-
${pe(r)}: ${
|
|
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">
|
|
215
|
+
${pe(r)}: ${H(n)} (${o}%)
|
|
216
|
+
</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=Oe==null?void 0:Oe.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)}}}},Ya=["id"];function el(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,Ya)}const tl=Object.freeze(Object.defineProperty({__proto__:null,default:L(Ka,[["render",el]])},Symbol.toStringTag,{value:"Module"}));function sl(s){return[{type:"fill",paint:{"fill-color":s.color||"#ccc","fill-outline-color":s.color||"blue","fill-opacity":s.opacity||1}}]}function rl(s){return[{type:"line",paint:{"line-color":s.color||"#ccc","line-opacity":s.opacity||1}}]}function nl(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"?sl(s):t==="line"?rl(s):nl(s)}const Ae={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)}}},ol="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.js",al="https://unpkg.com/maplibre-gl@5.6.2/dist/maplibre-gl.css";let De=null;function ll(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 il(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=il(al).then(()=>ll(ol)).then(()=>window.maplibregl),De)}const qe={__name:"legend",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ws),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"]},cl={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}}},dl={class:"w-full absolute max-w-[200px] bg-white border rounded-lg bottom-[10px] right-[50px]"},pl={class:"flex items-center justify-between border-b border-[#0000001A] px-2"},hl={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"},ul={key:0,class:"flex flex-col w-full"},ml={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},fl={class:"flex flex-col gap-[6px]"},gl={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"},bl={key:1,class:"flex flex-col w-full"},yl={key:0,class:"text-xs font-semibold leading-[1.2] text-[#1F2937] mb-[8px]"},xl={class:"flex flex-col gap-[6px]"},kl={class:"flex flex-row items-center justify-start"},wl={class:"text-xs text-[#1F2937] font-normal leading-[1.2]"};function _l(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",dl,[e.createElementVNode("div",pl,[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",hl,[(c=r.colors)!=null&&c.length?(e.openBlock(),e.createElementBlock("div",ul,[r.colorTitle?(e.openBlock(),e.createElementBlock("h4",ml,e.toDisplayString(r.colorTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",fl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.colors,(p,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,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",gl,e.toDisplayString(p.text||p.val),1)]))),128))])])):e.createCommentVNode("",!0),(d=r.sizes)!=null&&d.length?(e.openBlock(),e.createElementBlock("div",bl,[s.sizeTitle?(e.openBlock(),e.createElementBlock("h4",yl,e.toDisplayString(s.sizeTitle),1)):e.createCommentVNode("",!0),e.createElementVNode("div",xl,[l.sortedSizes.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.sortedSizes,(p,h)=>{var y,m,g,w,$;return e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",kl,[e.createElementVNode("div",{class:e.normalizeClass([l.maxWidht?`w-[${l.maxWidht}]`:"","mr-[10px]"])},[e.createElementVNode("div",{class:e.normalizeClass(l.sizeClass(h)),style:e.normalizeStyle({backgroundColor:((m=(y=o.palette)==null?void 0:y[r.color])==null?void 0:m[h])||r.color})},null,6)],2),e.createElementVNode("p",wl,e.toDisplayString(h===((g=l.sortedSizes)==null?void 0:g.length)-1?">"+p:h==((w=l.sortedSizes)==null?void 0:w.length)-1?">"+l.sortedSizes[(($=l.sortedSizes)==null?void 0:$.length)-1]:p+"-"+l.sortedSizes[h+1]),1)])])}),256)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)])])],8,["to"])):e.createCommentVNode("",!0)],64)}const $l=L(cl,[["render",_l]]),El={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(", ")}}},Vl={class:"map__settings"},Bl={ref:"attribution",class:"map__settings-attribution map__settings-item mt-[3px]"};function Dl(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Vl,[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(El,[["render",Dl]]),Cl={mixins:[Ae],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}}},Nl={class:"vs-map-slot-layers"},Sl=["onClick"],zl=["src"];function Ll(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Nl,[(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,zl)],10,Sl))),128))])}const Rt=L(Cl,[["render",Ll]]);function Pt(s,t,r){if(s!==null)for(var n,o,l,a,i,c,d,p=0,h=0,y,m=s.type,g=m==="FeatureCollection",w=m==="Feature",$=g?s.features.length:1,B=0;B<$;B++){d=g?s.features[B].geometry:w?s.geometry:s,y=d?d.type==="GeometryCollection":!1,i=y?d.geometries.length:1;for(var x=0;x<i;x++){var u=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,h,B,u,b)===!1)return!1;h++,u++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],h,B,u,b)===!1)return!1;h++,_==="MultiPoint"&&u++}_==="LineString"&&u++;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],h,B,u,b)===!1)return!1;h++}_==="MultiLineString"&&u++,_==="Polygon"&&b++}_==="Polygon"&&u++;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],h,B,u,b)===!1)return!1;h++}b++}u++}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 Tl(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 Il={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=Tl(s);this.map.fitBounds(t)}}},Ml={class:"z-100 flex justify-center items-center rounded-md w-[32px] h-[32px] cursor-pointer bg-white p-1 border-[2px]"};function Rl(s,t,r,n,o,l){const a=e.resolveComponent("homeIcon");return e.openBlock(),e.createElementBlock("div",Ml,[e.createVNode(a,{onClick:l.setBounds},null,8,["onClick"])])}const Ft=L(Il,[["render",Rl]]),Pl={components:{legendIcon:qe,menuIcon:{__name:"menu",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(bs),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]}}},Fl={class:"w-full h-[calc(100%-40px)] bg-white"},Wl={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"},jl={class:"relative min-w-full bg-white text-[12px]"},Ol={class:"divide-gray-200 dark:divide-neutral-700"},Al={class:"px-2 py-1"},ql={class:"px-2 py-1"};function vl(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",Fl,[e.createElementVNode("div",Wl,[e.createElementVNode("table",jl,[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",Ol,[(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",ql,e.toDisplayString(a.metric),1)]))),128))])])])])}const Wt=L(Pl,[["render",vl]]),Ul={mixins:[j,Ae,{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
217
|
${this.getPopoverTitle((n==null?void 0:n.x)||(n==null?void 0:n.title)||(n==null?void 0:n.name))||""}
|
|
213
218
|
</div>
|
|
214
219
|
|
|
@@ -217,7 +222,7 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
|
|
|
217
222
|
<span class="font-medium mr-[6px]">Значення</span>
|
|
218
223
|
</span>
|
|
219
224
|
<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})}}},
|
|
225
|
+
</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})}}},Hl={class:"w-full h-full"},Gl={class:"flex items-start justify-between mb-[6px] w-full"},Zl={class:"text-gray-800 font-[600]"},Ql=["id"],Xl=["id"],Jl={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"};function Kl(s,t,r,n,o,l){var p,h,y;const a=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapLegend"),d=e.resolveComponent("VsMapGoHome");return e.openBlock(),e.createElementBlock("div",Hl,[e.createElementVNode("div",Gl,[e.createElementVNode("h5",Zl,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,Xl),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",Jl,[e.createVNode(c,{mapId:s.mapId,colors:(p=s.data)==null?void 0:p.colors,sizes:(h=s.data)==null?void 0:h.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,Ql)])}const Yl=Object.freeze(Object.defineProperty({__proto__:null,default:L(Ul,[["render",Kl]])},Symbol.toStringTag,{value:"Module"})),ei={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}}},ti={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"},si={class:"w-[80px] mr-[10px]"},ri=["title"],ni={class:"text-[10px] mb-[2px] text-[#1F2937] font-normal leading-[1.2]"};function oi(s,t,r,n,o,l){var a;return(a=r.sizes)!=null&&a.length?(e.openBlock(),e.createElementBlock("div",ti,[e.createElementVNode("div",si,[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,h,y,m,g,w,$;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[((h=l.sortedSizes)==null?void 0:h.length)-1]:i+"-"+l.sortedSizes[c+1]},[e.createElementVNode("p",ni,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[((g=l.sortedSizes)==null?void 0:g.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:(($=(w=o.palette)==null?void 0:w[r.color])==null?void 0:$[c])||r.color})},null,6)],8,ri)}),256)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}const ai=L(ei,[["render",oi]]),li={__name:"icon-map",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(_s),e.mergeProps(t.$attrs,{size:24}),null,16))}},ii={mixins:[j,Ae],components:{VsMapSetting:Mt,VsClusterLegend:ai,VsMapGoHome:Ft,VsList:Wt,VsMapSlotLayers:Rt,VsBar:Fe},data(){return{baseColor:"pink",kattotg:"",options:[{id:"map",text:"Карта",component:li},{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
226
|
${(n==null?void 0:n.x)||(n==null?void 0:n.title)||(n==null?void 0:n.name)||""}
|
|
222
227
|
</div>
|
|
223
228
|
|
|
@@ -226,4 +231,4 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
|
|
|
226
231
|
<span class="font-medium mr-[6px]">Значення</span>
|
|
227
232
|
</span>
|
|
228
233
|
<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)}}}},
|
|
234
|
+
</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)}}}},ci={class:"h-full"},di={class:"flex items-start justify-between mb-[6px] w-full"},pi={class:"text-gray-800 font-[600]"},hi={class:"flex gap-2"},ui=["onClick"],mi=["id"],fi=["id"],gi={class:"absolute flex flex-col right-[10px] top-[105px] gap-1"},bi={class:"h-[calc(250px)]"};function yi(s,t,r,n,o,l){var y,m,g,w,$,B,x,u,b,_;const a=e.resolveComponent("VsMapSetting"),i=e.resolveComponent("VsMapSlotLayers"),c=e.resolveComponent("VsMapGoHome"),d=e.resolveComponent("VsClusterLegend"),p=e.resolveComponent("VsList"),h=e.resolveComponent("VsBar");return e.openBlock(),e.createElementBlock("div",ci,[e.createElementVNode("div",di,[e.createElementVNode("h3",pi,e.toDisplayString(s.title),1),e.createElementVNode("div",hi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,k=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["p-1 text-gray-700 border rounded",[o.activeTab===(k==null?void 0:k.id)?"ring-2 ring-blue-500":""]]),onClick:f=>o.activeTab=k==null?void 0:k.id},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k==null?void 0:k.component),{height:"16",width:"16"}))],10,ui))),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,fi),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",gi,[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:(g=o.data)==null?void 0:g.sizes,color:o.baseColor,changeOpacityItem:"true",cluster:"true"},null,8,["mapId","colors","sizes","color"])],8,mi),[[e.vShow,o.activeTab=="map"]]),e.withDirectives(e.createVNode(p,{mapId:o.mapId,source:(w=o.data)==null?void 0:w.rows,total:(($=o.data)==null?void 0:$.total)||0,count:((B=o.data)==null?void 0:B.count)||0,onKattotg:t[0]||(t[0]=k=>o.kattotg=k)},null,8,["mapId","source","total","count"]),[[e.vShow,o.activeTab=="table"]]),e.withDirectives(e.createElementVNode("div",bi,[(u=(x=o.data)==null?void 0:x.rows)!=null&&u.length?(e.openBlock(),e.createBlock(h,{key:0,source:(_=(b=o.data)==null?void 0:b.rows)==null?void 0:_.map(k=>({title:k==null?void 0:k.title,metric:k==null?void 0:k.metric}))},null,8,["source"])):e.createCommentVNode("",!0)],512),[[e.vShow,o.activeTab=="chart"]])])}const xi=Object.freeze(Object.defineProperty({__proto__:null,default:L(ii,[["render",yi]])},Symbol.toStringTag,{value:"Module"})),ki={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=>H(parseFloat(n[t])))}))}catch(s){console.error(s)}}}},wi={class:"flex flex-col h-full pt-[16px] pb-[16px] space-y-4 rounded-xl"},_i={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"},Ei={class:"relative min-w-full divide-y divide-gray-200 text-[12px]"},Vi={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"},Di={scope:"col",class:"xl:min-w-[120px] min-w-48"},Ci={class:"flex items-center px-1 py-3 font-medium text-gray-800 text-start gap-x-1"},Ni={class:"divide-y divide-gray-200"},Si={class:"text-gray-600"};function zi(s,t,r,n,o,l){return e.openBlock(),e.createElementBlock("div",wi,[e.createElementVNode("div",_i,[e.createElementVNode("div",$i,[e.createElementVNode("table",Ei,[e.createElementVNode("thead",Vi,[e.createElementVNode("tr",Bi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.dimensions,a=>(e.openBlock(),e.createElementBlock("th",Di,[e.createElementVNode("div",Ci,e.toDisplayString(a),1)]))),256))])]),e.createElementVNode("tbody",Ni,[(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",Si,e.toDisplayString(a==null?void 0:a[c]),1)]))),128))]))),128))])])])])])}const Li=Object.freeze(Object.defineProperty({__proto__:null,default:L(ki,[["render",zi]])},Symbol.toStringTag,{value:"Module"}));z.AllDashboardsPage=$t,z.EditorRootPage=Vo,z.ROUTES_NAMES=W,z.Urls=Ye,z.VsBar=Fe,z.VsDashboard=fr,z.VsDonut=Bt,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"})});
|