@opengis/bi 1.2.22 → 1.2.23

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/README.md CHANGED
@@ -1,36 +1,55 @@
1
1
  # SOFTPRO: BI
2
2
 
3
- SOFTPRO: BI аналітична геоінформаційна система, що поєднує бізнес-аналітику (BI) з ГІС-технологіями для просторового аналізу даних і підтримки управлінських рішень.
3
+ **Softpro BI** is an open-source JavaScript data visualization library that enables users to build interactive dashboards and visual analytics. It provides tools to display key business or operational data using widgets, charts, and maps, helping organizations analyze information and make data-driven decisions.
4
4
 
5
- ## Мета проєкту
5
+ ## Features
6
6
 
7
- Проєкт спрямований на створення BI-підсистеми, що забезпечує зручний, швидкий та інтуїтивний доступ до структурованої аналітичної інформації через інтерактивні дашборди та візуалізацію даних. Підсистема автоматизує процеси збору, обробки та аналізу даних, підвищуючи ефективність ухвалення управлінських рішень і забезпечуючи єдине джерело достовірної інформації для всіх рівнів користувачів.
7
+ - **Interactive dashboards** Create dashboards that present key metrics and insights through visual widgets and charts.
8
+ - **BI Editor** – A built-in editor for designing and configuring custom dashboards.
9
+ - **Flexible filtering system** – Apply dashboard-level and widget-level filters to control which data is displayed.
10
+ - **Multiple visualization widgets** – Includes charts such as bar, line, pie, KPI, funnel, table, progress bars, and geographic maps.
11
+ - **Geospatial visualization** – Support for map-based widgets such as point maps and choropleth maps for geographic data analysis.
8
12
 
9
- ## Функціональні можливості підсистеми
13
+ ## Install
10
14
 
11
- - Створення дашбордів з можливістю налаштування їхньої структури, додавання необхідних елементів;
12
- - Створення віджетів для відображення даних з можливістю налаштування стилю, розміру та зовнішнього вигляду для зручності сприйняття інформації;
13
- - Можливість розширювати перелік даних для аналітики та редагування структури таблиць, графіків;
14
- - Імпорт даних з таблиць, баз даних, автоматизація вивантаження даних та внесення даних користувачами;
15
- - Можливість імпорту та експорту дашбордів для збереження або передавання налаштувань між різними середовищами або для повторного використання;
15
+ ```bash
16
+ npm i @opengis/bi
17
+ ```
16
18
 
17
- ---
19
+ ## Usage
18
20
 
19
- ## Демо роботи підсистеми
21
+ ```vue
22
+ <template>
23
+ <!--$route.params.id-->
24
+ <BiDashboard :id="'home'" />
25
+ </template>
20
26
 
21
- ![Demo](https://cdn.softpro.ua/data/video/bi_demo.gif)
27
+ <script setup lang="ts">
28
+ const BiDashboard = defineAsyncComponent(() =>
29
+ import('@opengis/bi').then((m) => m.Dashboard)
30
+ );
31
+ </script>
32
+ ```
33
+
34
+ ## Usage Admin
22
35
 
23
- [Публічна частина](http://bi.local.softpro.ua/dashboard)
36
+ ```js
37
+ // router.config
38
+ export default [
39
+ {
40
+ path: '/bi.editor/:id?',
41
+ component: () => import('@opengis/bi').then((m) => m.Editor),
42
+ },
43
+ ];
44
+ ```
24
45
 
25
- ---
46
+ ## Documentation
26
47
 
27
- ## Модулі
48
+ For a detailed understanding of `bi`, its features, and how to use them, refer to our [Documentation](https://bi.opengis.info/).
28
49
 
29
- | Назва | Опис |
30
- | ------------ | ------------------------- |
31
- | BI | Аналітичний модуль |
50
+ ## Демо
32
51
 
33
- ---
52
+ ![Demo](https://cdn.softpro.ua/data/video/bi_demo.gif)
34
53
 
35
54
  ## Стек технологій
36
55
 
@@ -49,15 +68,9 @@ SOFTPRO: BI — аналітична геоінформаційна систем
49
68
  <a href="https://echarts.apache.org" target="_blank">
50
69
  <img src="https://img.shields.io/badge/Apache%20ECharts-323330?style=for-the-badge&logo=Apache-ECharts&logoColor=4FC08D" /></a>
51
70
 
52
- ## Документація
53
-
54
- - [Документація розробника](http://bi.local.softpro.ua/docs-dev/)
55
-
56
- ---
57
-
58
71
  ## Контакти
59
72
 
60
- Ви можете зв’язатися з нами за посиланням на офіційний сайт: SOFTPRO.UA або за допомогою електронної пошти info@softpro.ua, якщо у вас виникли:
73
+ Ви можете зв’язатися з нами за посиланням на офіційний сайт: SOFTPRO.UA або за допомогою електронної пошти info@softpro.ua, якщо у вас виникли:
61
74
 
62
75
  - технічні несправності;
63
76
  - помилки під час користування;
package/dist/bi.js CHANGED
@@ -1,4 +1,4 @@
1
- import { j as o, R as V, U as t, V as e, r as i, v as P, l as d, p as g, k as l, q as n, o as p, n as B, s as E } from "./import-file-Cy2Zpvpw.js";
1
+ import { j as o, R as V, U as t, V as e, r as i, v as P, l as d, p as g, k as l, q as n, o as p, n as B, s as E } from "./import-file-DN4Z6TNG.js";
2
2
  import "vue";
3
3
  export {
4
4
  o as EditorRootPage,
package/dist/bi.umd.cjs CHANGED
@@ -103,7 +103,7 @@
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 He=M("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Be={week:"Тиждень",month:"Місяць",quarter:"Квартал",year:"Рік"},ks=["onClick"],ws={class:"flex items-center justify-between w-full"},_s={key:0},$s=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 f=r.options;return typeof f=="string"?f.split(",").map((m,x)=>({id:x,text:m.trim()})):Array.isArray(f)?f:[]}),c=e.computed(()=>{const f=i.value.find(m=>(m.id??m)===l.value);return f?f.text??String(f):r.title??""}),p=f=>{const m=(f==null?void 0:f.id)??f;l.value=m,o.value=!1,n("selected",m),document.removeEventListener("click",d)},d=f=>{a.value&&!a.value.contains(f.target)&&(o.value=!1,document.removeEventListener("click",d))},h=()=>{o.value=!o.value,o.value?setTimeout(()=>{document.addEventListener("click",d)},200):document.removeEventListener("click",d)},g=f=>(Be==null?void 0:Be[f])??f;return e.onUnmounted(()=>{document.removeEventListener("click",d)}),(f,m)=>(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(g(c.value))+" ",1),m[0]||(m[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,x=>(e.openBlock(),e.createElementBlock("div",{key:x.id||x,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:k=>p(x)},[e.createElementVNode("div",ws,[e.createElementVNode("span",null,e.toDisplayString(g(x.text||x)),1),l.value===(x.id||x)?(e.openBlock(),e.createElementBlock("span",_s,m[1]||(m[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,ks))),128))],512)):e.createCommentVNode("",!0)],64))}}),Vs={class:"flex items-center space-x-2"},Es=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",Vs,[l.leftLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["transition-colors",{"text-blue-500":!n.value}])},e.toDisplayString(l.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]]),l.rightLabel?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["transition-colors",{"text-blue-500":n.value}])},e.toDisplayString(l.rightLabel),3)):e.createCommentVNode("",!0)]))}}),D=(s,t)=>{const r=s.__vccOpts||s;for(const[n,o]of t)r[n]=o;return r},Bs={},Cs={class:"flex items-center justify-center h-full"};function Ds(s,t){return e.openBlock(),e.createElementBlock("div",Cs,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 Ns=D(Bs,[["render",Ds]]),Ge={"bi-bar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Co)),"bi-number":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Oa)),"bi-text":e.defineAsyncComponent(()=>Promise.resolve().then(()=>va)),"bi-listbar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ka)),"bi-pie":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Mo)),"bi-donut":e.defineAsyncComponent(()=>Promise.resolve().then(()=>zo)),"bi-line":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ao)),"bi-stat":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ea)),"bi-pivot":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Pa)),"bi-progress":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ha)),"bi-funnel":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Qa)),"bi-map":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Gl)),"bi-cluster":e.defineAsyncComponent(()=>Promise.resolve().then(()=>mi)),"bi-table":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Bi))};let Ze="/api";function ge(s){Ze=s||"/api"}function Ss(s,t){const r=Ze.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 be(s,t={}){const{params:r,...n}=t,o=Ss(s,r),l=await fetch(o,{...n,headers:{"Content-Type":"application/json",...n.headers}});if(!l.ok){const i=new Error(l.statusText);throw i.status=l.status,i}const a=await l.text();if(a)try{return JSON.parse(a)}catch{return a}}const T={get(s,t){return be(s,{...t,method:"GET"})},post(s,t){return be(s,{method:"POST",body:t!=null?JSON.stringify(t):void 0})},put(s,t){return be(s,{method:"PUT",body:t!=null?JSON.stringify(t):void 0})},delete(s){return be(s,{method:"DELETE"})}},zs={key:0,class:"text-[16px] flex max-w-full items-center min-h-0 justify-between max-h-[50px] h-fit shrink-0"},Ls={class:"flex items-center justify-between w-full gap-2"},Ts={class:"flex items-center gap-2 min-w-0"},Is={class:"text-gray-800 inline-block line-clamp-1 font-semibold"},Ms={class:"flex flex-col justify-end"},Ps={key:0,class:"flex items-center justify-end w-full gap-2"},Rs={class:"w-full h-full"},re=e.defineComponent({__name:"vs-widget",props:{dashboard:{},prefix:{default:""},widget:{},filterURl:{},dashboardWidgets:{},selectedWidget:{}},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([]),p=e.computed(()=>{var y,b;const u=(y=r.dashboardWidgets)==null?void 0:y.find(_=>_.name===r.widget);return((b=u==null?void 0:u.data)==null?void 0:b.title)??(u==null?void 0:u.title)??""}),d=e.computed(()=>{var y;const u=(y=r.dashboardWidgets)==null?void 0:y.find(b=>b.name===r.widget);return(u==null?void 0:u.type)??"text"}),h=e.computed(()=>{var y;const u=(y=i.value)==null?void 0:y.controls;return!u||typeof u=="boolean"?[]:Object.keys(u).map(b=>({name:b,options:u[b]}))}),g=e.computed(()=>{const u=d.value?`bi-${d.value}`:"";return u&&u in Ge?Ge[u]:null});function f(u,y){var b,_;(_=(b=l.value)==null?void 0:b.changeStyle)==null||_.call(b,u,y)}function m(u,y){const b=c.value.find(_=>_.name===y);b?b.option=u:c.value.push({name:y,option:u}),x()}function x(){var y,b;let u=`/bi-data?dashboard=${r.dashboard}&widget=${r.widget}`;c.value.forEach(_=>{u+=`&${_.name}=${_.option}`}),(b=(y=l.value)==null?void 0:y.getDataFromURL)==null||b.call(y,u)}function k(){const u=a.value;if(u!=null&&u.getDataURL){const y=u.getDataURL({type:"png",pixelRatio:2,backgroundColor:"#ffffff"}),b=document.createElement("a");b.href=y,b.download="chart.png",document.body.appendChild(b),b.click(),document.body.removeChild(b)}}return e.onMounted(()=>{r.prefix&&ge(r.prefix)}),e.watch(()=>r.filterURl,u=>{var y,b;u&&((b=(y=l.value)==null?void 0:y.setFilter)==null||b.call(y,u))}),e.watch(()=>r.selectedWidget,(u,y)=>{var b;u!==y&&u===((b=i.value)==null?void 0:b.id)&&n("update:current-widget-data",i.value)}),e.watch(i,(u,y)=>{if((u==null?void 0:u.id)===(y==null?void 0:y.id))return;const b=typeof window<"u"?new URLSearchParams(window.top.location.search).get("widget"):null;b&&b===(u==null?void 0:u.id)&&n("update:current-widget-data",u)},{deep:!0}),(u,y)=>{var b,_,$,w,L,P,F,q,U;return e.openBlock(),e.createElementBlock("div",{ref_key:"widgetRef",ref:o,class:e.normalizeClass(["box-border relative h-full p-4 bg-white border border-gray-200 rounded-xl shadow-sm select-auto",[(_=(b=i.value)==null?void 0:b.style)!=null&&_.height?`max-h-[${(w=($=i.value)==null?void 0:$.style)==null?void 0:w.height}px] h-[${(P=(L=i.value)==null?void 0:L.style)==null?void 0:P.height}px]`:"max-h-[460px]"]])},[["text","cluster","map"].includes(d.value)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",zs,[e.createElementVNode("div",Ls,[e.createElementVNode("div",Ts,[e.createElementVNode("span",Is,e.toDisplayString(p.value),1)]),e.createElementVNode("div",Ms,[(F=h.value)!=null&&F.length?(e.openBlock(),e.createElementBlock("span",Ps,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList((q=h.value)==null?void 0:q.filter(V=>(V==null?void 0:V.options)&&(V==null?void 0:V.name)!=="export"),V=>{var v,Z;return e.openBlock(),e.createElementBlock("div",{key:V==null?void 0:V.name},[Array.isArray(V==null?void 0:V.options)?(e.openBlock(),e.createBlock($s,{key:0,title:V==null?void 0:V.name,options:V==null?void 0:V.options,value:((Z=(v=i.value)==null?void 0:v.data)==null?void 0:Z[V==null?void 0:V.name])??null,onSelected:G=>m(G,V==null?void 0:V.name)},null,8,["title","options","value","onSelected"])):typeof V.options=="boolean"?(e.openBlock(),e.createBlock(Es,{key:1,"left-label":V==null?void 0:V.name,"model-value":!!(V!=null&&V.options),"onUpdate:isEnabled":G=>f(V==null?void 0:V.name,G)},null,8,["left-label","model-value","onUpdate:isEnabled"])):e.createCommentVNode("",!0)])}),128)),(U=h.value)!=null&&U.some(V=>(V==null?void 0:V.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:k},[e.createVNode(e.unref(as),{size:16,class:"text-gray-800"})])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])])])),e.createElementVNode("div",Rs,[g.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(g.value),{key:0,ref_key:"chartRef",ref:l,"current-widget":a.value,"onUpdate:currentWidget":y[0]||(y[0]=V=>a.value=V),"widget-data":i.value,"onUpdate:widgetData":y[1]||(y[1]=V=>i.value=V),dashboard:u.dashboard,title:p.value,widget:u.widget},null,40,["current-widget","widget-data","dashboard","title","widget"])):(e.openBlock(),e.createBlock(Ns,{key:1,class:"w-full h-full"}))])],2)}}}),Fs={class:"w-full overflow-hidden rounded vs-table-interface__table-wrp h-fit"},As={class:"p-5 min-h-[500px] flex flex-col justify-center items-center text-center"},Os={class:"max-w-sm mx-auto mt-6"},js={class:"font-medium text-gray-800 dark:text-neutral-200"},Ws={class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"},ye=e.defineComponent({__name:"vs-new-nodata",props:{title:{default:"Дані для відображення відсутні"},text:{default:"Змініть параметри пошуку або спробуйте пізніше"}},setup(s){return(t,r)=>(e.openBlock(),e.createElementBlock("div",Fs,[e.createElementVNode("div",null,[e.createElementVNode("div",As,[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",Os,[e.createElementVNode("p",js,e.toDisplayString(t.title),1),e.createElementVNode("p",Ws,e.toDisplayString(t.text),1)])])])]))}}),qs={components:{filterIcon:{__name:"filter",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(is),e.mergeProps(t.$attrs,{size:24}),null,16))}}},props:["filterScheme"],emits:["filters:changed"]},Us={class:"flex items-center"},vs={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 Hs(s,t,r,n,o,l){const a=e.resolveComponent("filterIcon");return e.openBlock(),e.createElementBlock("div",Us,[r.filterScheme?(e.openBlock(),e.createElementBlock("button",vs,[e.createVNode(a),t[0]||(t[0]=e.createTextVNode(" Фільтри "))])):e.createCommentVNode("",!0)])}const Gs={components:{VsFilterHeader:D(qs,[["render",Hs]])},props:{dashboardData:{type:Object,default:null},filters:{type:Array,default:null}}},Zs={class:"bg-white px-5 flex gap-4 h-[90px] border border-gray-200 rounded-xl mb-2 pt-[3px] justify-between items-center"},Qs={class:"grow"},Xs={class:"text-lg font-semibold text-stone-800 dark:text-neutral-200"},Js={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"},Ks={key:0,class:"flex items-center gap-3"};function Ys(s,t,r,n,o,l){var i,c,p;const a=e.resolveComponent("VsFilterHeader");return e.openBlock(),e.createElementBlock("div",Zs,[e.createElementVNode("div",Qs,[e.createElementVNode("h1",Xs,e.toDisplayString((i=r.dashboardData)==null?void 0:i.title),1),(c=r.dashboardData)!=null&&c.description?(e.openBlock(),e.createElementBlock("button",Js,e.toDisplayString((p=r.dashboardData)==null?void 0:p.description),1)):e.createCommentVNode("",!0)]),r.filters?(e.openBlock(),e.createElementBlock("div",Ks,[e.createVNode(a,{filterScheme:r.filters,"onFilters:changed":t[0]||(t[0]=d=>s.$emit("filters:changed",d))},null,8,["filterScheme"])])):e.createCommentVNode("",!0)])}const er=D(Gs,[["render",Ys]]);var Qe={},Xe;(function(s){s.pop="pop",s.push="push"})(Xe||(Xe={}));var Je;(function(s){s.back="back",s.forward="forward",s.unknown=""})(Je||(Je={}));var Ke;(function(s){s[s.aborted=4]="aborted",s[s.cancelled=8]="cancelled",s[s.duplicated=16]="duplicated"})(Ke||(Ke={}));const tr=Symbol(Qe.NODE_ENV!=="production"?"router":""),sr=Symbol(Qe.NODE_ENV!=="production"?"route location":"");function Ce(){return e.inject(tr)}function rr(s){return e.inject(sr)}const nr={key:0,class:"text-gray-400 shrink-0"},or=["onClick"],ar=["onClick"],lr={key:4,class:"text-gray-900 font-medium truncate"},Ye={__name:"vs-breadcrumbs",props:{items:{type:Array,default:()=>[]},compact:{type:Boolean,default:!1}},setup(s){const t=s,r=Ce(),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,p)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:p},[p>0?(e.openBlock(),e.createElementBlock("span",nr,[e.createVNode(e.unref(os),{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:d=>c.onClick()},e.toDisplayString(c.label),9,or)):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:d=>o(c.to)},e.toDisplayString(c.label),9,ar)):(e.openBlock(),e.createElementBlock("span",lr,e.toDisplayString(c.label),1))],64))),128))],2)}}},ir={components:{VsWidget:re,VsNewNodata:ye,VsHeader:er,VsBreadcrumbs:Ye},props:["id","prefix"],data(){return{widgets:[],panels:[],error:!1,selectedPanel:"",filterURl:null,dashboardData:null}},async mounted(){ge(this.prefix||"/api"),await this.fetchData()},methods:{async fetchData(){if(this.id)try{const s=await T.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)}}},cr={class:"w-full pb-8 overflow-y-auto mx-auto"},dr={class:"grid flex-grow w-full grid-cols-12 gap-4 h-fit"};function pr(s,t,r,n,o,l){var c;const a=e.resolveComponent("VsNewNodata"),i=e.resolveComponent("VsWidget");return e.openBlock(),e.createElementBlock("div",cr,[e.createElementVNode("div",dr,[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)||[],(p,d)=>{var h;return e.openBlock(),e.createElementBlock("div",{key:d,class:e.normalizeClass([`col-span-${p.col||12}`,"flex flex-col gap-[10px]"])},[(h=p.widgets)!=null&&h.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(p.widgets,g=>(e.openBlock(),e.createBlock(i,{key:g,dashboard:r.id,widget:g,"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:p.widget,"dashboard-widgets":o.dashboardData.widgets,"filter-u-rl":o.filterURl},null,8,["dashboard","widget","dashboard-widgets","filter-u-rl"]))],2)}),128))])])}const hr=D(ir,[["render",pr]]),mr={key:0,class:"vs-modal-wrapper fixed inset-0 flex items-center justify-center p-4"},ur={class:"flex items-center justify-between shrink-0 py-2.5 px-4 border-b border-gray-200 dark:border-[#454545]"},fr={class:"font-medium text-gray-800 dark:text-white"},gr={class:"vs-modal-content flex-1 min-h-0 overflow-auto p-4"},br={key:0,class:"shrink-0 border-t border-gray-200 dark:border-neutral-700"},ne=D({__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",mr,[e.createElementVNode("div",{class:"absolute inset-0 bg-black/50","aria-hidden":"true",onMousedown:c[0]||(c[0]=p=>s.closeClickBack&&p.target===p.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",ur,[e.createElementVNode("h3",fr,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",gr,[e.renderSlot(i.$slots,"default",{},void 0,!0)]),i.$slots.footer?(e.openBlock(),e.createElementBlock("div",br,[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"]]),yr={__name:"icon-plus",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ve),e.mergeProps(t.$attrs,{size:24}),null,16))}},xr={class:"mb-4 overflow-auto scrollbar max-h-96"},kr={__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 m;const n=e.defineAsyncComponent(()=>import("@opengis/form")),o=(m=e.getCurrentInstance().proxy)==null?void 0:m.$notify,l=r,a=s,i=e.ref(!1),c=e.ref({}),p=e.ref();function d(){i.value=!0}function h(){i.value=!1}t({open:d,close:h});const g=async()=>{try{await p.value.doValidation(),await T.post(`/bi-dashboard/${a.selectedDashboard}`,c.value),await o({type:"success",title:"Успішно!",message:"Віджет успішно створено"}),await l("update-data"),c.value={},i.value=!1}catch{o({type:"error",title:"Помилка!",message:"При спробі створити віджет сталася помилка"})}},f=e.computed(()=>{var x,k,u,y;return{title:{type:"text",label:"Widget title",placeholder:"Widget title",validators:["required"]},x:{type:"select",label:"X Axis",view:"buttons",style:{size:"xs"},validators:["required"],options:(k=(x=a.columns)==null?void 0:x.filter(b=>(b==null?void 0:b.type)=="text"||(b==null?void 0:b.type)==="date"||(b==null?void 0:b.type)==="timestamp without time zone"||(b==null?void 0:b.type)==="boolean"||(b==null?void 0:b.type)==="integer"))==null?void 0:k.map(({name:b,type:_})=>({id:b,text:b,type:_}))},metric:{type:"select",label:"Y Axis",view:"buttons",validators:["required"],style:{size:"xs"},options:[{id:"count",label:"count"},...(y=(u=a.columns)==null?void 0:u.filter(b=>(b==null?void 0:b.type)==="numeric"||(b==null?void 0:b.type)==="double precision"))==null?void 0:y.map(({name:b,type:_})=>({id:b,text:b,type:_}))]},col:{type:"select",label:"Columns count",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}]},type:{type:"select",view:"buttons",label:"Type",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:"Table",placeholder:"Table"},query:{type:"Text",ua:"Query",placeholder:"Query"},cls:{type:"Text",ua:"Cls",placeholder:"Cls"}}});return(x,k)=>{const u=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock("div",null,[s.inline?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(u,{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:d},[e.createVNode(yr,{height:"20",width:"20"})])])]),default:e.withCtx(()=>[k[1]||(k[1]=e.createTextVNode(" Створити віджет "))]),_: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:g,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",xr,[e.createVNode(e.unref(n),{ref_key:"form",ref:p,schema:f.value,values:c.value,"onUpdate:values":k[0]||(k[0]=y=>c.value=y)},null,8,["schema","values"])])]),_:1},8,["visible"])])}}},et={__name:"delete",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(xs),e.mergeProps(t.$attrs,{size:24}),null,16))}},De={__name:"close",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(He),e.mergeProps(t.$attrs,{size:24}),null,16))}},tt={__name:"edit",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(fs),e.mergeProps(t.$attrs,{size:24}),null,16))}},wr={class:"space-y-4"},_r={__name:"vs-editor-form-style",props:{widgetName:{type:String},data:{type:Object,default:()=>{}}},setup(s,{expose:t}){var m,x,k,u,y,b;const r=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:n}=e.getCurrentInstance().proxy,o=s,l=e.ref(null),a={show:{label:"Label",type:"switcher",title:"Show label"},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"}]}},i={show:{label:"Legend",type:"switcher",title:"Show legend"}},c={show:{label:"Tooltip ",type:"switcher",title:"Show tooltip"}},p=e.ref({...((x=(m=o.data)==null?void 0:m.style)==null?void 0:x.label)||{}}),d=e.ref({...((u=(k=o.data)==null?void 0:k.style)==null?void 0:u.legend)||{}}),h=e.ref({...((b=(y=o.data)==null?void 0:y.style)==null?void 0:b.tooltip)||{}}),g=()=>{const _=new CustomEvent(`update-style-${o.widgetName}`);_.chartId=o.widgetName,_.options={options:{legend:d.value,tooltip:h.value,label:p.value},seriesOptions:p.value},window.dispatchEvent(_)};e.watch(p,g,{deep:!0}),e.watch(d,g,{deep:!0}),e.watch(h,g,{deep:!0});const f=async()=>{try{await T.put(`/bi-dashboard/${l.value}/${o.widgetName}`,{style:{legend:d.value,tooltip:h.value,label:p.value}});const _=new CustomEvent(`update-style-${o.widgetName}`);_.chartId=o.widgetName,_.options={options:{legend:d.value,tooltip:h.value,label:p.value},seriesOptions:p.value},window.dispatchEvent(_),n({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{n({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const _=new URLSearchParams(window.top.location.search);l.value=_.get("dashboard")}),t({requestUpdateWidget:f}),(_,$)=>(e.openBlock(),e.createElementBlock("div",wr,[e.createVNode(e.unref(r),{schema:a,values:p.value,"onUpdate:values":$[0]||($[0]=w=>p.value=w),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(r),{schema:i,values:d.value,"onUpdate:values":$[1]||($[1]=w=>d.value=w),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(r),{schema:c,values:h.value,"onUpdate:values":$[2]||($[2]=w=>h.value=w),class:"p-0"},null,8,["values"])]))}};function Ne(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let J=Ne();function st(s){J=s}const rt=/[&<>"']/,$r=new RegExp(rt.source,"g"),nt=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Vr=new RegExp(nt.source,"g"),Er={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ot=s=>Er[s];function A(s,t){if(t){if(rt.test(s))return s.replace($r,ot)}else if(nt.test(s))return s.replace(Vr,ot);return s}const Br=/(^|[^\[])\^/g;function N(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(Br,"$1"),r=r.replace(o,a),n},getRegex:()=>new RegExp(r,t)};return n}function at(s){try{s=encodeURI(s).replace(/%25/g,"%")}catch{return null}return s}const oe={exec:()=>null};function lt(s,t){const r=s.replace(/\|/g,(l,a,i)=>{let c=!1,p=a;for(;--p>=0&&i[p]==="\\";)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 Cr(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 it(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 Dr(s,t){const r=s.match(/^(\s+)(?:```)/);if(r===null)return t;const n=r[1];return t.split(`
106
+ */const He=M("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Be={week:"Тиждень",month:"Місяць",quarter:"Квартал",year:"Рік"},ks=["onClick"],ws={class:"flex items-center justify-between w-full"},_s={key:0},$s=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 f=r.options;return typeof f=="string"?f.split(",").map((m,x)=>({id:x,text:m.trim()})):Array.isArray(f)?f:[]}),c=e.computed(()=>{const f=i.value.find(m=>(m.id??m)===l.value);return f?f.text??String(f):r.title??""}),p=f=>{const m=(f==null?void 0:f.id)??f;l.value=m,o.value=!1,n("selected",m),document.removeEventListener("click",d)},d=f=>{a.value&&!a.value.contains(f.target)&&(o.value=!1,document.removeEventListener("click",d))},h=()=>{o.value=!o.value,o.value?setTimeout(()=>{document.addEventListener("click",d)},200):document.removeEventListener("click",d)},g=f=>(Be==null?void 0:Be[f])??f;return e.onUnmounted(()=>{document.removeEventListener("click",d)}),(f,m)=>(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(g(c.value))+" ",1),m[0]||(m[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,x=>(e.openBlock(),e.createElementBlock("div",{key:x.id||x,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:k=>p(x)},[e.createElementVNode("div",ws,[e.createElementVNode("span",null,e.toDisplayString(g(x.text||x)),1),l.value===(x.id||x)?(e.openBlock(),e.createElementBlock("span",_s,m[1]||(m[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,ks))),128))],512)):e.createCommentVNode("",!0)],64))}}),Vs={class:"flex items-center space-x-2"},Es=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",Vs,[l.leftLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["transition-colors",{"text-blue-500":!n.value}])},e.toDisplayString(l.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]]),l.rightLabel?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["transition-colors",{"text-blue-500":n.value}])},e.toDisplayString(l.rightLabel),3)):e.createCommentVNode("",!0)]))}}),D=(s,t)=>{const r=s.__vccOpts||s;for(const[n,o]of t)r[n]=o;return r},Bs={},Cs={class:"flex items-center justify-center h-full"};function Ds(s,t){return e.openBlock(),e.createElementBlock("div",Cs,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 Ns=D(Bs,[["render",Ds]]),Ge={"bi-bar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Co)),"bi-number":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Oa)),"bi-text":e.defineAsyncComponent(()=>Promise.resolve().then(()=>va)),"bi-listbar":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ka)),"bi-pie":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Mo)),"bi-donut":e.defineAsyncComponent(()=>Promise.resolve().then(()=>zo)),"bi-line":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Ao)),"bi-stat":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ea)),"bi-pivot":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Pa)),"bi-progress":e.defineAsyncComponent(()=>Promise.resolve().then(()=>ha)),"bi-funnel":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Qa)),"bi-map":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Gl)),"bi-cluster":e.defineAsyncComponent(()=>Promise.resolve().then(()=>mi)),"bi-table":e.defineAsyncComponent(()=>Promise.resolve().then(()=>Bi))};let Ze="/api";function ge(s){Ze=s||"/api"}function Ss(s,t){const r=Ze.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 be(s,t={}){const{params:r,...n}=t,o=Ss(s,r),l=await fetch(o,{...n,headers:{"Content-Type":"application/json",...n.headers}});if(!l.ok){const i=new Error(l.statusText);throw i.status=l.status,i}const a=await l.text();if(a)try{return JSON.parse(a)}catch{return a}}const T={get(s,t){return be(s,{...t,method:"GET"})},post(s,t){return be(s,{method:"POST",body:t!=null?JSON.stringify(t):void 0})},put(s,t){return be(s,{method:"PUT",body:t!=null?JSON.stringify(t):void 0})},delete(s){return be(s,{method:"DELETE"})}},zs={key:0,class:"text-[16px] flex max-w-full items-center min-h-0 justify-between h-fit shrink-0"},Ls={class:"flex items-center justify-between w-full gap-2"},Ts={class:"flex items-center gap-2 min-w-0"},Is={class:"text-gray-800 inline-block line-clamp-1 font-semibold"},Ms={class:"flex flex-col justify-end"},Ps={key:0,class:"flex items-center justify-end w-full gap-2"},Rs={class:"w-full h-full"},re=e.defineComponent({__name:"vs-widget",props:{dashboard:{},prefix:{default:""},widget:{},filterURl:{},dashboardWidgets:{},selectedWidget:{}},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([]),p=e.computed(()=>{var y,b;const u=(y=r.dashboardWidgets)==null?void 0:y.find(_=>_.name===r.widget);return((b=u==null?void 0:u.data)==null?void 0:b.title)??(u==null?void 0:u.title)??""}),d=e.computed(()=>{var y;const u=(y=r.dashboardWidgets)==null?void 0:y.find(b=>b.name===r.widget);return(u==null?void 0:u.type)??"text"}),h=e.computed(()=>{var y;const u=(y=i.value)==null?void 0:y.controls;return!u||typeof u=="boolean"?[]:Object.keys(u).map(b=>({name:b,options:u[b]}))}),g=e.computed(()=>{const u=d.value?`bi-${d.value}`:"";return u&&u in Ge?Ge[u]:null});function f(u,y){var b,_;(_=(b=l.value)==null?void 0:b.changeStyle)==null||_.call(b,u,y)}function m(u,y){const b=c.value.find(_=>_.name===y);b?b.option=u:c.value.push({name:y,option:u}),x()}function x(){var y,b;let u=`/bi-data?dashboard=${r.dashboard}&widget=${r.widget}`;c.value.forEach(_=>{u+=`&${_.name}=${_.option}`}),(b=(y=l.value)==null?void 0:y.getDataFromURL)==null||b.call(y,u)}function k(){const u=a.value;if(u!=null&&u.getDataURL){const y=u.getDataURL({type:"png",pixelRatio:2,backgroundColor:"#ffffff"}),b=document.createElement("a");b.href=y,b.download="chart.png",document.body.appendChild(b),b.click(),document.body.removeChild(b)}}return e.onMounted(()=>{r.prefix&&ge(r.prefix)}),e.watch(()=>r.filterURl,u=>{var y,b;u&&((b=(y=l.value)==null?void 0:y.setFilter)==null||b.call(y,u))}),e.watch(()=>r.selectedWidget,(u,y)=>{var b;u!==y&&u===((b=i.value)==null?void 0:b.id)&&n("update:current-widget-data",i.value)}),e.watch(i,(u,y)=>{if((u==null?void 0:u.id)===(y==null?void 0:y.id))return;const b=typeof window<"u"?new URLSearchParams(window.top.location.search).get("widget"):null;b&&b===(u==null?void 0:u.id)&&n("update:current-widget-data",u)},{deep:!0}),(u,y)=>{var b,_,$,w,L,P,F,q,U;return e.openBlock(),e.createElementBlock("div",{ref_key:"widgetRef",ref:o,class:e.normalizeClass(["box-border relative h-full p-4 bg-white border border-gray-200 rounded-xl shadow-sm select-auto",[(_=(b=i.value)==null?void 0:b.style)!=null&&_.height?`max-h-[${(w=($=i.value)==null?void 0:$.style)==null?void 0:w.height}px] h-[${(P=(L=i.value)==null?void 0:L.style)==null?void 0:P.height}px]`:"max-h-[460px]"]])},[["text","cluster","map"].includes(d.value)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",zs,[e.createElementVNode("div",Ls,[e.createElementVNode("div",Ts,[e.createElementVNode("span",Is,e.toDisplayString(p.value),1)]),e.createElementVNode("div",Ms,[(F=h.value)!=null&&F.length?(e.openBlock(),e.createElementBlock("span",Ps,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList((q=h.value)==null?void 0:q.filter(V=>(V==null?void 0:V.options)&&(V==null?void 0:V.name)!=="export"),V=>{var v,Z;return e.openBlock(),e.createElementBlock("div",{key:V==null?void 0:V.name},[Array.isArray(V==null?void 0:V.options)?(e.openBlock(),e.createBlock($s,{key:0,title:V==null?void 0:V.name,options:V==null?void 0:V.options,value:((Z=(v=i.value)==null?void 0:v.data)==null?void 0:Z[V==null?void 0:V.name])??null,onSelected:G=>m(G,V==null?void 0:V.name)},null,8,["title","options","value","onSelected"])):typeof V.options=="boolean"?(e.openBlock(),e.createBlock(Es,{key:1,"left-label":V==null?void 0:V.name,"model-value":!!(V!=null&&V.options),"onUpdate:isEnabled":G=>f(V==null?void 0:V.name,G)},null,8,["left-label","model-value","onUpdate:isEnabled"])):e.createCommentVNode("",!0)])}),128)),(U=h.value)!=null&&U.some(V=>(V==null?void 0:V.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:k},[e.createVNode(e.unref(as),{size:16,class:"text-gray-800"})])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])])])),e.createElementVNode("div",Rs,[g.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(g.value),{key:0,ref_key:"chartRef",ref:l,"current-widget":a.value,"onUpdate:currentWidget":y[0]||(y[0]=V=>a.value=V),"widget-data":i.value,"onUpdate:widgetData":y[1]||(y[1]=V=>i.value=V),dashboard:u.dashboard,title:p.value,widget:u.widget},null,40,["current-widget","widget-data","dashboard","title","widget"])):(e.openBlock(),e.createBlock(Ns,{key:1,class:"w-full h-full"}))])],2)}}}),Fs={class:"w-full overflow-hidden rounded vs-table-interface__table-wrp h-fit"},As={class:"p-5 min-h-[500px] flex flex-col justify-center items-center text-center"},Os={class:"max-w-sm mx-auto mt-6"},js={class:"font-medium text-gray-800 dark:text-neutral-200"},Ws={class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"},ye=e.defineComponent({__name:"vs-new-nodata",props:{title:{default:"Дані для відображення відсутні"},text:{default:"Змініть параметри пошуку або спробуйте пізніше"}},setup(s){return(t,r)=>(e.openBlock(),e.createElementBlock("div",Fs,[e.createElementVNode("div",null,[e.createElementVNode("div",As,[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",Os,[e.createElementVNode("p",js,e.toDisplayString(t.title),1),e.createElementVNode("p",Ws,e.toDisplayString(t.text),1)])])])]))}}),qs={components:{filterIcon:{__name:"filter",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(is),e.mergeProps(t.$attrs,{size:24}),null,16))}}},props:["filterScheme"],emits:["filters:changed"]},Us={class:"flex items-center"},vs={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 Hs(s,t,r,n,o,l){const a=e.resolveComponent("filterIcon");return e.openBlock(),e.createElementBlock("div",Us,[r.filterScheme?(e.openBlock(),e.createElementBlock("button",vs,[e.createVNode(a),t[0]||(t[0]=e.createTextVNode(" Фільтри "))])):e.createCommentVNode("",!0)])}const Gs={components:{VsFilterHeader:D(qs,[["render",Hs]])},props:{dashboardData:{type:Object,default:null},filters:{type:Array,default:null}}},Zs={class:"bg-white px-5 flex gap-4 h-[90px] border border-gray-200 rounded-xl mb-2 pt-[3px] justify-between items-center"},Qs={class:"grow"},Xs={class:"text-lg font-semibold text-stone-800 dark:text-neutral-200"},Js={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"},Ks={key:0,class:"flex items-center gap-3"};function Ys(s,t,r,n,o,l){var i,c,p;const a=e.resolveComponent("VsFilterHeader");return e.openBlock(),e.createElementBlock("div",Zs,[e.createElementVNode("div",Qs,[e.createElementVNode("h1",Xs,e.toDisplayString((i=r.dashboardData)==null?void 0:i.title),1),(c=r.dashboardData)!=null&&c.description?(e.openBlock(),e.createElementBlock("button",Js,e.toDisplayString((p=r.dashboardData)==null?void 0:p.description),1)):e.createCommentVNode("",!0)]),r.filters?(e.openBlock(),e.createElementBlock("div",Ks,[e.createVNode(a,{filterScheme:r.filters,"onFilters:changed":t[0]||(t[0]=d=>s.$emit("filters:changed",d))},null,8,["filterScheme"])])):e.createCommentVNode("",!0)])}const er=D(Gs,[["render",Ys]]);var Qe={},Xe;(function(s){s.pop="pop",s.push="push"})(Xe||(Xe={}));var Je;(function(s){s.back="back",s.forward="forward",s.unknown=""})(Je||(Je={}));var Ke;(function(s){s[s.aborted=4]="aborted",s[s.cancelled=8]="cancelled",s[s.duplicated=16]="duplicated"})(Ke||(Ke={}));const tr=Symbol(Qe.NODE_ENV!=="production"?"router":""),sr=Symbol(Qe.NODE_ENV!=="production"?"route location":"");function Ce(){return e.inject(tr)}function rr(s){return e.inject(sr)}const nr={key:0,class:"text-gray-400 shrink-0"},or=["onClick"],ar=["onClick"],lr={key:4,class:"text-gray-900 font-medium truncate"},Ye={__name:"vs-breadcrumbs",props:{items:{type:Array,default:()=>[]},compact:{type:Boolean,default:!1}},setup(s){const t=s,r=Ce(),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,p)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:p},[p>0?(e.openBlock(),e.createElementBlock("span",nr,[e.createVNode(e.unref(os),{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:d=>c.onClick()},e.toDisplayString(c.label),9,or)):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:d=>o(c.to)},e.toDisplayString(c.label),9,ar)):(e.openBlock(),e.createElementBlock("span",lr,e.toDisplayString(c.label),1))],64))),128))],2)}}},ir={components:{VsWidget:re,VsNewNodata:ye,VsHeader:er,VsBreadcrumbs:Ye},props:["id","prefix"],data(){return{widgets:[],panels:[],error:!1,selectedPanel:"",filterURl:null,dashboardData:null}},async mounted(){ge(this.prefix||"/api"),await this.fetchData()},methods:{async fetchData(){if(this.id)try{const s=await T.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)}}},cr={class:"w-full pb-8 overflow-y-auto mx-auto"},dr={class:"grid flex-grow w-full grid-cols-12 gap-4 h-fit"};function pr(s,t,r,n,o,l){var c;const a=e.resolveComponent("VsNewNodata"),i=e.resolveComponent("VsWidget");return e.openBlock(),e.createElementBlock("div",cr,[e.createElementVNode("div",dr,[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)||[],(p,d)=>{var h;return e.openBlock(),e.createElementBlock("div",{key:d,class:e.normalizeClass([`col-span-${p.col||12}`,"flex flex-col gap-[10px]"])},[(h=p.widgets)!=null&&h.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(p.widgets,g=>(e.openBlock(),e.createBlock(i,{key:g,dashboard:r.id,widget:g,"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:p.widget,"dashboard-widgets":o.dashboardData.widgets,"filter-u-rl":o.filterURl},null,8,["dashboard","widget","dashboard-widgets","filter-u-rl"]))],2)}),128))])])}const hr=D(ir,[["render",pr]]),mr={key:0,class:"vs-modal-wrapper fixed inset-0 flex items-center justify-center p-4"},ur={class:"flex items-center justify-between shrink-0 py-2.5 px-4 border-b border-gray-200 dark:border-[#454545]"},fr={class:"font-medium text-gray-800 dark:text-white"},gr={class:"vs-modal-content flex-1 min-h-0 overflow-auto p-4"},br={key:0,class:"shrink-0 border-t border-gray-200 dark:border-neutral-700"},ne=D({__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",mr,[e.createElementVNode("div",{class:"absolute inset-0 bg-black/50","aria-hidden":"true",onMousedown:c[0]||(c[0]=p=>s.closeClickBack&&p.target===p.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",ur,[e.createElementVNode("h3",fr,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",gr,[e.renderSlot(i.$slots,"default",{},void 0,!0)]),i.$slots.footer?(e.openBlock(),e.createElementBlock("div",br,[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"]]),yr={__name:"icon-plus",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ve),e.mergeProps(t.$attrs,{size:24}),null,16))}},xr={class:"mb-4 overflow-auto scrollbar max-h-96"},kr={__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 m;const n=e.defineAsyncComponent(()=>import("@opengis/form")),o=(m=e.getCurrentInstance().proxy)==null?void 0:m.$notify,l=r,a=s,i=e.ref(!1),c=e.ref({}),p=e.ref();function d(){i.value=!0}function h(){i.value=!1}t({open:d,close:h});const g=async()=>{var x;try{const k=(x=p.value)==null?void 0:x.doValidation;typeof k=="function"&&await k(),await T.post(`/bi-dashboard/${a.selectedDashboard}`,c.value),await o({type:"success",title:"Успішно!",message:"Віджет успішно створено"}),await l("update-data"),c.value={},i.value=!1}catch(k){const u=(k==null?void 0:k.message)||"При спробі створити віджет сталася помилка. Перевірте обов'язкові поля (зокрема Type).";o==null||o({type:"error",title:"Помилка!",message:u})}},f=e.computed(()=>{var x,k,u,y;return{title:{type:"text",label:"Widget title",placeholder:"Widget title",validators:["required"]},x:{type:"select",label:"X Axis",view:"buttons",style:{size:"xs"},validators:["required"],options:(k=(x=a.columns)==null?void 0:x.filter(b=>(b==null?void 0:b.type)=="text"||(b==null?void 0:b.type)==="date"||(b==null?void 0:b.type)==="timestamp without time zone"||(b==null?void 0:b.type)==="boolean"||(b==null?void 0:b.type)==="integer"))==null?void 0:k.map(({name:b,type:_})=>({id:b,text:b,type:_}))},metric:{type:"select",label:"Y Axis",view:"buttons",validators:["required"],style:{size:"xs"},options:[{id:"count",label:"count"},...(y=(u=a.columns)==null?void 0:u.filter(b=>(b==null?void 0:b.type)==="numeric"||(b==null?void 0:b.type)==="double precision"))==null?void 0:y.map(({name:b,type:_})=>({id:b,text:b,type:_}))]},col:{type:"select",label:"Columns count",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}]},type:{type:"select",view:"buttons",label:"Type",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:"Table",placeholder:"Table"},query:{type:"Text",ua:"Query",placeholder:"Query"},cls:{type:"Text",ua:"Cls",placeholder:"Cls"}}});return(x,k)=>{const u=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock("div",null,[s.inline?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(u,{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:d},[e.createVNode(yr,{height:"20",width:"20"})])])]),default:e.withCtx(()=>[k[1]||(k[1]=e.createTextVNode(" Створити віджет "))]),_: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:g,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",xr,[e.createVNode(e.unref(n),{ref_key:"form",ref:p,schema:f.value,values:c.value,"onUpdate:values":k[0]||(k[0]=y=>c.value=y)},null,8,["schema","values"])])]),_:1},8,["visible"])])}}},et={__name:"delete",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(xs),e.mergeProps(t.$attrs,{size:24}),null,16))}},De={__name:"close",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(He),e.mergeProps(t.$attrs,{size:24}),null,16))}},tt={__name:"edit",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(fs),e.mergeProps(t.$attrs,{size:24}),null,16))}},wr={class:"space-y-4"},_r={__name:"vs-editor-form-style",props:{widgetName:{type:String},data:{type:Object,default:()=>{}}},setup(s,{expose:t}){var m,x,k,u,y,b;const r=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:n}=e.getCurrentInstance().proxy,o=s,l=e.ref(null),a={show:{label:"Label",type:"switcher",title:"Show label"},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"}]}},i={show:{label:"Legend",type:"switcher",title:"Show legend"}},c={show:{label:"Tooltip ",type:"switcher",title:"Show tooltip"}},p=e.ref({...((x=(m=o.data)==null?void 0:m.style)==null?void 0:x.label)||{}}),d=e.ref({...((u=(k=o.data)==null?void 0:k.style)==null?void 0:u.legend)||{}}),h=e.ref({...((b=(y=o.data)==null?void 0:y.style)==null?void 0:b.tooltip)||{}}),g=()=>{const _=new CustomEvent(`update-style-${o.widgetName}`);_.chartId=o.widgetName,_.options={options:{legend:d.value,tooltip:h.value,label:p.value},seriesOptions:p.value},window.dispatchEvent(_)};e.watch(p,g,{deep:!0}),e.watch(d,g,{deep:!0}),e.watch(h,g,{deep:!0});const f=async()=>{try{await T.put(`/bi-dashboard/${l.value}/${o.widgetName}`,{style:{legend:d.value,tooltip:h.value,label:p.value}});const _=new CustomEvent(`update-style-${o.widgetName}`);_.chartId=o.widgetName,_.options={options:{legend:d.value,tooltip:h.value,label:p.value},seriesOptions:p.value},window.dispatchEvent(_),n({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{n({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const _=new URLSearchParams(window.top.location.search);l.value=_.get("dashboard")}),t({requestUpdateWidget:f}),(_,$)=>(e.openBlock(),e.createElementBlock("div",wr,[e.createVNode(e.unref(r),{schema:a,values:p.value,"onUpdate:values":$[0]||($[0]=w=>p.value=w),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(r),{schema:i,values:d.value,"onUpdate:values":$[1]||($[1]=w=>d.value=w),class:"p-0"},null,8,["values"]),e.createVNode(e.unref(r),{schema:c,values:h.value,"onUpdate:values":$[2]||($[2]=w=>h.value=w),class:"p-0"},null,8,["values"])]))}};function Ne(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let J=Ne();function st(s){J=s}const rt=/[&<>"']/,$r=new RegExp(rt.source,"g"),nt=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Vr=new RegExp(nt.source,"g"),Er={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ot=s=>Er[s];function A(s,t){if(t){if(rt.test(s))return s.replace($r,ot)}else if(nt.test(s))return s.replace(Vr,ot);return s}const Br=/(^|[^\[])\^/g;function N(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(Br,"$1"),r=r.replace(o,a),n},getRegex:()=>new RegExp(r,t)};return n}function at(s){try{s=encodeURI(s).replace(/%25/g,"%")}catch{return null}return s}const oe={exec:()=>null};function lt(s,t){const r=s.replace(/\|/g,(l,a,i)=>{let c=!1,p=a;for(;--p>=0&&i[p]==="\\";)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 Cr(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 it(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 Dr(s,t){const r=s.match(/^(\s+)(?:```)/);if(r===null)return t;const n=r[1];return t.split(`
107
107
  `).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(`
108
108
  `)}class xe{constructor(t){S(this,"options");S(this,"rules");S(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,`
109
109
  `)}}}fences(t){const r=this.rules.block.fences.exec(t);if(r){const n=r[0],o=Dr(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],`
@@ -158,7 +158,7 @@ ${t}</tr>
158
158
  `}tablecell(t){const r=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+r+`</${n}>
159
159
  `}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=at(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=at(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 j{constructor(t){S(this,"options");S(this,"renderer");S(this,"textRenderer");this.options=t||J,this.options.renderer=this.options.renderer||new $e,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Pe}static parse(t,r){return new j(r).parse(t)}static parseInline(t,r){return new j(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+=`
160
160
  `+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){S(this,"options");S(this,"block");this.options=t||J}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?O.lex:O.lexInline}provideParser(){return this.block?j.parse:j.parseInline}}S(de,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class en{constructor(...t){S(this,"defaults",Ne());S(this,"options",this.setOptions);S(this,"parse",this.parseMarkdown(!0));S(this,"parseInline",this.parseMarkdown(!1));S(this,"Parser",j);S(this,"Renderer",$e);S(this,"TextRenderer",Pe);S(this,"Lexer",O);S(this,"Tokenizer",xe);S(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 p of c)n=n.concat(this.walkTokens(p.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 p=i[c].flat(1/0);n=n.concat(this.walkTokens(p,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 $e(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],p=l[i];l[i]=(...d)=>{let h=c.apply(l,d);return h===!1&&(h=p.apply(l,d)),h||""}}o.renderer=l}if(n.tokenizer){const l=this.defaults.tokenizer||new xe(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],p=l[i];l[i]=(...d)=>{let h=c.apply(l,d);return h===!1&&(h=p.apply(l,d)),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],p=l[i];de.passThroughHooks.has(a)?l[i]=d=>{if(this.defaults.async)return Promise.resolve(c.call(l,d)).then(g=>p.call(l,g));const h=c.call(l,d);return p.call(l,h)}:l[i]=(...d)=>{let h=c.apply(l,d);return h===!1&&(h=p.apply(l,d)),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 O.lex(t,r??this.defaults)}parser(t,r){return j.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?O.lex:O.lexInline,p=a.hooks?a.hooks.provideParser():t?j.parse:j.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(n):n).then(d=>c(d,a)).then(d=>a.hooks?a.hooks.processAllTokens(d):d).then(d=>a.walkTokens?Promise.all(this.walkTokens(d,a.walkTokens)).then(()=>d):d).then(d=>p(d,a)).then(d=>a.hooks?a.hooks.postprocess(d):d).catch(i);try{a.hooks&&(n=a.hooks.preprocess(n));let d=c(n,a);a.hooks&&(d=a.hooks.processAllTokens(d)),a.walkTokens&&this.walkTokens(d,a.walkTokens);let h=p(d,a);return a.hooks&&(h=a.hooks.postprocess(h)),h}catch(d){return i(d)}}}onError(t,r){return n=>{if(n.message+=`
161
- 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 en;function C(s,t){return K.parse(s,t)}C.options=C.setOptions=function(s){return K.setOptions(s),C.defaults=K.defaults,st(C.defaults),C},C.getDefaults=Ne,C.defaults=J,C.use=function(...s){return K.use(...s),C.defaults=K.defaults,st(C.defaults),C},C.walkTokens=function(s,t){return K.walkTokens(s,t)},C.parseInline=K.parseInline,C.Parser=j,C.parser=j.parse,C.Renderer=$e,C.TextRenderer=Pe,C.Lexer=O,C.lexer=O.lex,C.Tokenizer=xe,C.Hooks=de,C.parse=C,C.options,C.setOptions,C.use,C.walkTokens,C.parseInline,j.parse,O.lex;const tn={class:"space-y-4"},sn={__name:"vs-editor-form-data",props:{widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object,default:()=>{}},columns:{type:Array,default:()=>[]}},emits:["update-dashboard"],setup(s,{expose:t,emit:r}){var _,$,w,L,P,F,q,U,V,v,Z,G,he,me,ue,I,Q,fe,Ot,jt,Wt,qt,Ut,vt,Ht,Gt,Zt,Qt,Xt,Jt,Kt,Yt;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=r,a=s,i=e.ref(null),c=e.ref([]),p=e.computed(()=>{const E=a.columns??[];return E.length?E:c.value}),d=e.computed(()=>a.dashboardId||i.value);async function h(){const E=d.value;if(!(p.value.length||!E||!a.widgetName))try{const B=await T.get(`/bi-data?dashboard=${E}&widget=${a.widgetName}`);Array.isArray(B==null?void 0:B.columns)&&B.columns.length&&(c.value=B.columns)}catch{}}const g=E=>(E==null?void 0:E.name)!=null?{id:E.name,text:E.title||E.name}:null,f=E=>Array.isArray(E)?[...E].sort((B,H)=>{const te=B.text&&B.text!==B.id,es=H.text&&H.text!==H.id;return te&&!es?-1:!te&&es?1:(B.text||"").localeCompare(H.text||"",void 0,{sensitivity:"base"})}):E,m=e.computed(()=>{const E=(p.value??[]).filter(B=>(B==null?void 0:B.type)=="text"||(B==null?void 0:B.type)==="date"||(B==null?void 0:B.type)==="timestamp without time zone"||(B==null?void 0:B.type)==="boolean"||(B==null?void 0:B.type)==="integer").map(g).filter(Boolean);return f(E)}),x=e.computed(()=>`${a.widgetName}-${m.value.length}-${(p.value??[]).length}`),k=e.computed(()=>({text:{type:"Text",label:"Text",conditions:["type","==","text"]},x:{type:"select",label:"X Axis",style:{size:"xs"},conditions:["type","not_in",["text","table","map"]],options:[...m.value]},cls:{label:"X Axis classifier",type:"text",conditions:["type","not_in",["text","table","map","cluster"]]},y_type:{label:"Y type",type:"select",options:[{id:"columns",text:"columns"},{id:"function",text:"function"}],conditions:["type","not_in",["text","table","map","number","cluster"]]},tableSQL:{label:"tableSQL",type:"text",hidden:!0},metric:{type:"select",label:"Y Axis",conditions:[["type","not_in",["text","table","map","cluster"]],["y_type","!=","function"]],options:[{id:"count",text:"count"},...f(p.value.filter(E=>(E==null?void 0:E.type)==="numeric"||(E==null?void 0:E.type)==="double precision").map(g).filter(Boolean))]},fx:{type:"text",label:"Function",conditions:[["y_type","==","function"]]},query:{label:"Query",type:"text",conditions:["type","not_in",["text","table","map","number"]]},groupby:{type:"select",label:"Groupby",view:"buttons",style:{size:"xs"},options:[{id:"null",text:"null"},...f(p.value.filter(E=>(E==null?void 0:E.type)=="text"||(E==null?void 0:E.type)==="boolean"||(E==null?void 0:E.type)==="integer").map(g).filter(Boolean))],conditions:["type","==","bar"]},columns:{type:"checkbox",label:"Columns",style:{size:"xs"},options:f((p.value??[]).map(g).filter(Boolean)),conditions:["type","in",["table","map"]]},granularity:{type:"radio",label:"Granularity",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}})),u=e.ref({x:(($=(_=a.data)==null?void 0:_.data)==null?void 0:$.x)||((w=a.data)==null?void 0:w.x)||null,metric:((P=(L=a.data)==null?void 0:L.data)==null?void 0:P.metric)||((F=a.data)==null?void 0:F.metric)||null,columns:((U=(q=a.data)==null?void 0:q.data)==null?void 0:U.columns)||((V=a.data)==null?void 0:V.columns)||null,granularity:((Z=(v=a.data)==null?void 0:v.data)==null?void 0:Z.granularity)||((G=a.data)==null?void 0:G.granularity)||null,type:((me=(he=a.data)==null?void 0:he.data)==null?void 0:me.type)||((ue=a.data)==null?void 0:ue.type)||null,groupby:((Q=(I=a.data)==null?void 0:I.data)==null?void 0:Q.groupby)||a.data.groupby||null,fx:((Ot=(fe=a.data)==null?void 0:fe.data)==null?void 0:Ot.fx)||((jt=a.data)==null?void 0:jt.fx)||null,query:((qt=(Wt=a.data)==null?void 0:Wt.data)==null?void 0:qt.query)||((Ut=a.data)==null?void 0:Ut.query)||null,y_type:((Ht=(vt=a.data)==null?void 0:vt.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}),y=async()=>{try{await T.put(`/bi-dashboard/${d.value}/${a.widgetName}`,{data:u.value});let E=`/bi-data?dashboard=${d.value}&widget=${a.widgetName}`;Object.entries(u.value).forEach(([H,te])=>{E+=`&${H}=${te}`});const B=new CustomEvent(`update-data-${a.widgetName}`);B.filterUrl=E,window.dispatchEvent(B),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}},b=async()=>{try{let E=`/bi-data?dashboard=${d.value}&widget=${a.widgetName}`;Object.entries(u.value).forEach(([H,te])=>{E+=`&${H}=${te}`});const B=new CustomEvent(`update-data-${a.widgetName}`);B.filterUrl=E,window.dispatchEvent(B),l("update-dashboard")}catch{await o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.watch(u,()=>{b()},{deep:!0}),e.onMounted(()=>{const E=new URLSearchParams(window.top.location.search);i.value=E.get("dashboard"),h()}),e.watch(()=>[a.widgetName,a.dashboardId,i.value],()=>{c.value=[],h()},{immediate:!0}),t({requestUpdateWidget:y}),(E,B)=>(e.openBlock(),e.createElementBlock("div",tn,[(e.openBlock(),e.createBlock(e.unref(n),{key:x.value,schema:k.value,values:u.value,"onUpdate:values":B[0]||(B[0]=H=>u.value=H)},null,8,["schema","values"]))]))}},rn={class:"space-y-4"},nn={__name:"vs-editor-form-yaml",props:{yamlValue:{type:null,default:()=>""},widgetName:{type:String},data:{type:Object}},setup(s,{expose:t}){const r=typeof window<"u"?window.echarts:null,n=e.defineAsyncComponent(()=>import("@opengis/form").then(h=>h.VsInputMonaco)),o=e.ref(null),{$notify:l}=e.getCurrentInstance().proxy,a=s,i=(h,{dimensions:g,source:f})=>{const m=h.getOption(),{data:x,...k}=(m==null?void 0:m.series)[0],[,...u]=g||[],y=u.map((b,_)=>({...(m==null?void 0:m.series[_])||{},data:f.map($=>$[_+1]),name:b}));h==null||h.setOption({...m||{},dataset:{dimensions:g,source:f},series:y,xAxis:{type:"category"},yAxis:{}},!0)},c=h=>{const g=document.getElementById(h);if(!g)return null;const f=r==null?void 0:r.getInstanceByDom(g);return f||null},p=e.ref(a.yamlValue),d=async()=>{try{await T.put(`/bi-dashboard/${o.value}/${a.widgetName}`,{yml:p.value});const h=c(a.widgetName);if(h){const g=await T.get(`/bi-data?dashboard=${o.value}&widget=${a.widgetName}`);i(h,g)}l({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{l({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const h=new URLSearchParams(window.top.location.search);o.value=h.get("dashboard")}),t({requestUpdateWidget:d}),(h,g)=>(e.openBlock(),e.createElementBlock("div",rn,[e.createVNode(e.unref(n),{modelValue:p.value,"onUpdate:modelValue":g[0]||(g[0]=f=>p.value=f),syntax:"yaml",theme:"vs-light",height:400,minimap:!1},null,8,["modelValue"])]))}},on={class:"pt-[10px]"},bt={"vs-editor-form-style":_r,"vs-editor-form-data":sn,"vs-editor-form-yaml":nn,"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 d;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:(d=l.columns)==null?void 0:d.map(({name:h})=>h)}},c=e.ref(l.controls||{}),p=async()=>{try{await T.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,g)=>{const f=e.resolveComponent("VsButton");return e.openBlock(),e.createElementBlock("div",on,[e.createVNode(f,{class:"ml-[10px] mb-[10px]",type:"plain",onClick:p},{default:e.withCtx(()=>g[1]||(g[1]=[e.createTextVNode(" Зберегти ")])),_:1}),e.createVNode(e.unref(r),{schema:i,values:c.value,"onUpdate:values":g[0]||(g[0]=m=>c.value=m)},null,8,["values"])])}}}},an={key:0,class:"p-4 text-sm text-amber-700 bg-amber-50 rounded-lg"},yt={__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",an," Помилка завантаження вмісту. Переключіть таб або оновіть сторінку. ")):(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))}},ln={class:"h-full flex flex-col bg-white shrink-0 !w-[400px] border rounded-xl overflow-hidden border-gray-200"},cn={key:0,class:"flex flex-col min-h-0 flex-1"},dn={class:"flex items-center border-b border-gray-200 bg-white shrink-0 px-4 h-[49px]"},pn={class:"flex items-center gap-6 min-w-0 -mb-[14px]"},hn=["onClick"],mn={key:0,class:"absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 rounded-full"},un={class:"flex items-center gap-1 ml-auto shrink-0"},fn={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"},gn={key:0},bn={key:1},yn={class:"p-4"},xn={class:"flex justify-end mt-4 gap-x-3"},kn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},wn={__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=t,l=e.ref(null),a=s,i=e.ref(!1),c=e.ref(!0),p=e.ref(!1),d=e.ref({}),h=e.useModel(s,"selectedWidget"),g=["table","text","number","stat","progress","listbar","map","pivot"],f=e.ref("data"),m=async()=>{try{await T.delete(`/bi-dashboard/${a.selectedDashboard}/${a.selectedWidgetData.name}`);const $=new URL(window.top.location.href);$.searchParams.set("dashboard",a.selectedDashboard),$.searchParams.delete("widget"),window.top.history.pushState({},"",$),o("update-data"),i.value=!1,n({type:"success",title:"Успішно!",message:"Віджет успішно видалено"})}catch($){console.error($),n({type:"error",title:"Помилка!",message:"При спробі видалити віджет виникла помилка"})}},x=e.computed(()=>{const $=[{id:"data",label:"Дані"},{id:"style",label:"Стилі"},{id:"yaml",label:"{ }"}];return $==null?void 0:$.filter(w=>{var L,P,F;return w.id==="style"?!(g!=null&&g.includes(((L=a.selectedWidgetData)==null?void 0:L.type)||((F=(P=a.selectedWidgetData)==null?void 0:P.data)==null?void 0:F.type))):!0})}),k=()=>{var $,w,L,P,F,q,U,V,v;d.value={title:($=a.selectedWidgetData)==null?void 0:$.title,type:(w=a.selectedWidgetData)==null?void 0:w.type,table:(L=a.selectedWidgetData)==null?void 0:L.table_name,query:(F=(P=a.selectedWidgetData)==null?void 0:P.data)==null?void 0:F.query,x:(U=(q=a.selectedWidgetData)==null?void 0:q.data)==null?void 0:U.x,cls:(v=(V=a.selectedWidgetData)==null?void 0:V.data)==null?void 0:v.cls},p.value=!0},u=async()=>{try{await T.put(`/bi-dashboard/${a.selectedDashboard}/${a.selectedWidgetData.name}`,d.value),n({type:"success",title:"Успішно!",message:"Дані успішно змінено"}),await o("update-data"),p.value=!1}catch{n({type:"error",title:"Помилка!",message:"При спробі внести зміни виникла помилка"})}};e.watch(h,$=>{c.value=!1;const w=new URL(window.top.location.href);$?(w.searchParams.set("widget",$),window.top.history.pushState({},"",w)):(w.searchParams.delete("widget"),window.top.history.pushState({},"",w)),setTimeout(()=>c.value=!0)});const y={title:{type:"text",ua:"Заголовок",placeholder:"Заголовок",validators:["required"]},type:{type:"radio",view:"buttons",validators:["required"],slots:{label:'<div style="width: 120px; height:160px" class="flex gap-[12px] flex-col"><img class="block" style="height: calc(100% - 40px)" :src="`https://cdn.softpro.ua/data/icons/bi/${id}.png`"/><span class="font-[500]">{{ label }}</span></div>'},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 Axis",placeholder:"X Axis"},cls:{type:"Text",ua:"Cls",placeholder:"Cls"}};return($,w)=>{var P,F,q,U,V,v,Z,G,he,me,ue;const L=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",ln,[s.selectedWidgetData?(e.openBlock(),e.createElementBlock("div",cn,[e.createElementVNode("div",dn,[e.createElementVNode("nav",pn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,I=>(e.openBlock(),e.createElementBlock("button",{key:I.id,type:"button",class:e.normalizeClass(["relative pb-3 pt-1 text-sm font-medium transition-colors whitespace-nowrap",f.value===I.id?"text-blue-600":"text-gray-600 hover:text-gray-900"]),onClick:Q=>f.value=I.id},[e.createTextVNode(e.toDisplayString(I.label)+" ",1),f.value===I.id?(e.openBlock(),e.createElementBlock("span",mn)):e.createCommentVNode("",!0)],10,hn))),128))]),e.createElementVNode("div",un,[e.createVNode(L,{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:w[0]||(w[0]=I=>{var Q,fe;return(fe=(Q=l.value)==null?void 0:Q.save)==null?void 0:fe.call(Q)})},[e.createVNode(e.unref(gs),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[w[9]||(w[9]=e.createTextVNode(" Зберегти "))]),_:1}),e.createVNode(L,{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:k},[e.createVNode(tt,{class:"h-4 w-4"})])]),default:e.withCtx(()=>[w[10]||(w[10]=e.createTextVNode(" Редагувати віджет "))]),_:1}),e.createVNode(L,{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:w[1]||(w[1]=I=>i.value=!0)},[e.createVNode(e.unref(et),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[w[11]||(w[11]=e.createTextVNode(" Видалити віджет "))]),_:1})])]),(P=s.currentWidgetData)!=null&&P.status?(e.openBlock(),e.createBlock(ye,{key:0,title:(F=s.currentWidgetData)==null?void 0:F.title,text:(q=s.currentWidgetData)==null?void 0:q.message},null,8,["title","text"])):(e.openBlock(),e.createElementBlock("div",fn,[c.value&&s.currentWidgetData?(e.openBlock(),e.createElementBlock("div",gn,[e.createVNode(yt,{ref_key:"tabPanelRef",ref:l,"tab-key":f.value,"tab-component":e.unref(bt)["vs-editor-form-"+f.value],widgetName:(U=s.selectedWidgetData)==null?void 0:U.name,dashboardId:s.selectedDashboard,yamlValue:((V=s.selectedWidgetData)==null?void 0:V.yml)||"",data:s.selectedWidgetData,controls:(v=s.selectedWidgetData)==null?void 0:v.controls,columns:(Z=s.currentWidgetData)==null?void 0:Z.columns,onUpdateDashboard:w[2]||(w[2]=I=>$.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])):(e.openBlock(),e.createElementBlock("div",bn,[e.createVNode(yt,{ref_key:"tabPanelRef",ref:l,"tab-key":f.value,"tab-component":e.unref(bt)["vs-editor-form-"+f.value],widgetName:(G=s.selectedWidgetData)==null?void 0:G.name,dashboardId:s.selectedDashboard,yamlValue:((he=s.selectedWidgetData)==null?void 0:he.yml)||"",data:s.selectedWidgetData,controls:(me=s.selectedWidgetData)==null?void 0:me.controls,columns:(ue=s.currentWidgetData)==null?void 0:ue.columns,onUpdateDashboard:w[3]||(w[3]=I=>$.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])),e.createVNode(ne,{teleport:"#modal",visible:i.value,title:"Ви впевнені?",onClose:w[5]||(w[5]=I=>i.value=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",yn,[w[12]||(w[12]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей віджет? ",-1)),e.createElementVNode("div",xn,[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:w[4]||(w[4]=I=>i.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:m}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"])]))])):(e.openBlock(),e.createBlock(ye,{key:1,title:"Оберіть один з віджетів",text:"",class:"p-4"}))]),e.createVNode(ne,{teleport:"#modal",visible:p.value,title:"Редагувати віджет",onClose:w[8]||(w[8]=I=>p.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",kn,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:w[7]||(w[7]=I=>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: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 hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[y?(e.openBlock(),e.createBlock(e.unref(r),{key:0,schema:y,values:d.value,"onUpdate:values":w[6]||(w[6]=I=>d.value=I)},null,8,["values"])):e.createCommentVNode("",!0)]),_:1},8,["visible"])],64)}}},_n={class:"overflow-hidden flex flex-col min-h-[480px]"},$n={class:"flex-1 flex min-h-0 gap-4"},Vn={class:"flex-1 min-w-0 pb-4 overflow-auto bg-gray-50/50"},En={class:"w-[400px] shrink-0 flex flex-col"},Bn={__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.computed({get:()=>r.selectedWidget,set:l=>n("update:selectedWidget",l)});return(l,a)=>(e.openBlock(),e.createElementBlock("div",_n,[e.createElementVNode("div",$n,[e.createElementVNode("div",Vn,[e.createVNode(re,{dashboard:s.selectedDashboard,widget:s.selectedWidget,"selected-widget":s.selectedWidget,"dashboard-widgets":s.dashboardWidgets,"filter-u-rl":void 0,class:"max-h-full"},null,8,["dashboard","widget","selected-widget","dashboard-widgets"])]),e.createElementVNode("div",En,[e.createVNode(wn,{selectedWidget:o.value,"onUpdate:selectedWidget":a[0]||(a[0]=i=>o.value=i),selectedWidgetData:s.selectedWidgetData,currentWidgetData:s.currentWidgetData,selectedDashboard:s.selectedDashboard,onUpdateData:a[1]||(a[1]=i=>l.$emit("update-data"))},null,8,["selectedWidget","selectedWidgetData","currentWidgetData","selectedDashboard"])])])]))}},xt={__name:"icon-grid",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(hs),e.mergeProps(t.$attrs,{size:24}),null,16))}},kt={__name:"icon-table",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ys),e.mergeProps(t.$attrs,{size:24}),null,16))}},Cn={__name:"icon-more",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ls),e.mergeProps(t.$attrs,{size:24}),null,16))}},Dn=e.defineAsyncComponent(()=>import("@opengis/form")),Nn={components:{VsModal:ne,VForm:Dn,deleteIcon:et,editIcon:tt,IconGrid:xt,IconMore:Cn,IconTable:kt},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(p=>(p==null?void 0:p.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",editable:!1,addition:!1,colModel:[{name:"title",ua:"Назва",type:"Text",key:"col"},{name:"type",ua:"Тип",type:"Text",key:"col",disabled:!0},{name:"widget",type:"Text",ua:"Назва",key:"widget",hiddenCol:!0},{name:"col",ua:"Кількість стовпчиків",type:"Text",key:"col"}]}]}},props:{selected:{type:String,default:()=>""},dashboardData:{type:Object,default:()=>{}},selectedWidgetData:{type:Object,default:()=>{}},columns:{type:Array}},methods:{async editDashboard(){var s,t;try{(t=(s=this.$refs)==null?void 0:s.formEdit)==null||t.doValidation(),await T.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 T.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 T.delete(`/bi-dashboard/${this.selected}`);const s=new URL(window.top.location.href);s.searchParams.delete("dashboard"),s.searchParams.delete("widget"),window.history.pushState({},"",s),await this.$notify({title:"Успішно!",type:"success",message:"Дашборд видалено успішно"}),this.isDeleteConfirm=!1,await this.$emit("update:selected",null),await this.$emit("update-editor")}catch{this.$notify({title:"Помилка!",type:"error",message:"При спробі видалити дашборд виникла помилка"})}},closePopover(){document.body.click()}}},Sn={key:0,class:"flex items-center gap-4"},zn={class:"h-[30px] w-[30px] flex items-center justify-center"},Ln={class:"flex flex-col items-start -ml-2 -mr-2"},Tn={class:"p-4"},In={class:"flex justify-end mt-4 gap-x-3"},Mn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},Pn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"};function Rn(s,t,r,n,o,l){const a=e.resolveComponent("IconGrid"),i=e.resolveComponent("VsPopover"),c=e.resolveComponent("IconMore"),p=e.resolveComponent("VsModal"),d=e.resolveComponent("VForm");return e.openBlock(),e.createElementBlock("div",null,[r.selected?(e.openBlock(),e.createElementBlock("div",Sn,[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}),e.createVNode(i,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createVNode(i,{placement:"bottom-left"},{reference:e.withCtx(()=>[e.createElementVNode("button",zn,[e.createVNode(c,{class:"h-[20px]"})])]),default:e.withCtx(()=>[e.createElementVNode("div",Ln,[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})])):e.createCommentVNode("",!0),e.createVNode(p,{teleport:"#modal",visible:o.isDeleteConfirm,size:"small",title:"Ви впевнені?",onClose:t[5]||(t[5]=h=>o.isDeleteConfirm=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",Tn,[t[16]||(t[16]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей дашборд? ",-1)),e.createElementVNode("div",In,[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(p,{teleport:"#modal",visible:o.isFormEdit,title:"Редагувати дашборд",onClose:t[9]||(t[9]=h=>o.isFormEdit=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Mn,[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(d,{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(p,{teleport:"#modal",visible:o.isFormGrid,title:"Редагувати структуру дашборду",onClose:t[13]||(t[13]=h=>o.isFormGrid=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Pn,[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(d,{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 Fn=D(Nn,[["render",Rn]]),An={class:"flex-1 min-w-0 flex flex-col overflow-auto"},On={class:"max-w-7xl mx-auto px-6 w-full flex flex-col min-h-0 flex-1"},jn={class:"relative z-10 shrink-0 mt-4 mb-6"},Wn={class:"flex items-center text-sm text-gray-600"},qn={key:0,class:"flex items-center justify-between gap-4 mt-3"},Un={class:"min-w-0"},vn={class:"text-2xl font-bold text-gray-900"},Hn={key:0,class:"mt-1.5 text-sm text-gray-600"},Gn={class:"flex items-center shrink-0"},Zn={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"},Qn=D({__name:"vs-editor",props:{prefix:String,customClass:{type:String,default:()=>"w-screen h-screen"},initialDashboardId:{type:String,default:""}},emits:["back"],setup(s,{emit:t}){const r=s;ge(r.prefix||"/api");const n=t,o=e.inject("biClearDashboard",null),l=e.ref(r.initialDashboardId||""),a=e.ref(""),i=e.ref(null),c=e.ref(null),p=e.ref(null),d=async()=>{if(!l.value){i.value=null;return}try{const f=await T.get(`/bi-dashboard/${l.value}`);i.value=f}catch(f){console.error(f)}},h=e.computed(()=>{var f,m,x;return(x=Array.isArray((f=i.value)==null?void 0:f.widgets)?(m=i.value)==null?void 0:m.widgets:[])==null?void 0:x.find(k=>(k==null?void 0:k.name)===a.value)}),g=e.computed(()=>{var x,k,u,y,b;const m=[o?{label:"Дашборди",onClick:()=>{o(),n("back")}}:{label:"Дашборди",to:"/editor"}];if((x=i.value)!=null&&x.title||l.value){const _=((k=i.value)==null?void 0:k.title)||l.value||"Редактор",$=!!a.value;m.push({label:_,...$?{onClick:()=>{a.value=""}}:{}})}else m.push({label:"Редактор"});if(a.value&&h.value){const _=((y=(u=h.value)==null?void 0:u.data)==null?void 0:y.title)||((b=h.value)==null?void 0:b.title)||a.value;m.push({label:_})}return m});return e.watch(l,(f,m)=>{var k,u,y;m&&(a.value="");const x=new URL(window.top.location.href);f?((k=x==null?void 0:x.searchParams)==null||k.set("dashboard",f),(y=(u=window.top)==null?void 0:u.history)==null||y.pushState({},"",x),d()):(x==null||x.searchParams.delete("dashboard"),x==null||x.searchParams.delete("widget"))}),e.onMounted(()=>{var f,m;if(r.initialDashboardId)l.value=r.initialDashboardId;else{const x=new URLSearchParams(((m=(f=window.top)==null?void 0:f.location)==null?void 0:m.search)||""),k=x.get("dashboard");k&&(l.value=k),a.value=x.get("widget")||""}d()}),(f,m)=>{var x,k;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex w-full h-full",[s.customClass]])},[e.createElementVNode("div",An,[e.createElementVNode("div",On,[e.createElementVNode("div",jn,[e.createElementVNode("div",Wn,[e.createVNode(Ye,{items:g.value,compact:""},null,8,["items"])]),l.value&&i.value?(e.openBlock(),e.createElementBlock("div",qn,[e.createElementVNode("div",Un,[e.createElementVNode("h1",vn,e.toDisplayString(i.value.title||l.value),1),i.value.description?(e.openBlock(),e.createElementBlock("p",Hn,e.toDisplayString(i.value.description),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Gn,[a.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:m[0]||(m[0]=u=>a.value="")},[e.createVNode(e.unref(He),{class:"w-4 h-4"}),m[6]||(m[6]=e.createTextVNode(" Закрити "))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(Fn,{selected:l.value,"onUpdate:selected":m[1]||(m[1]=u=>l.value=u),dashboardData:i.value,columns:(x=i.value)==null?void 0:x.columns,selectedWidgetData:h.value,prefix:s.prefix,onUpdateEditor:d},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:m[2]||(m[2]=u=>{var y,b;return(b=(y=p.value)==null?void 0:y.open)==null?void 0:b.call(y)})},m[7]||(m[7]=[e.createElementVNode("span",{class:"leading-none"},"+",-1),e.createTextVNode(" Створити віджет ")])),l.value?(e.openBlock(),e.createBlock(kr,{key:0,ref_key:"createWidgetRef",ref:p,inline:"",columns:(k=i.value)==null?void 0:k.columns,selectedDashboard:l.value,onUpdateData:d},null,8,["columns","selectedDashboard"])):e.createCommentVNode("",!0)],64))])])):e.createCommentVNode("",!0)]),a.value&&i.value?(e.openBlock(),e.createBlock(Bn,{key:0,"selected-widget":a.value,"onUpdate:selectedWidget":m[3]||(m[3]=u=>a.value=u),"selected-widget-data":h.value,"current-widget-data":c.value,"selected-dashboard":l.value,"dashboard-widgets":i.value.widgets||[],onUpdateData:d},null,8,["selected-widget","selected-widget-data","current-widget-data","selected-dashboard","dashboard-widgets"])):(e.openBlock(),e.createElementBlock("div",Zn,[i.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(i.value.panels,(u,y)=>{var b;return e.openBlock(),e.createElementBlock("div",{key:y,class:e.normalizeClass([`col-span-${u.col||12}`,"flex flex-col gap-[10px]"])},[(b=u.widgets)!=null&&b.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(u.widgets,_=>(e.openBlock(),e.createBlock(re,{onClick:$=>a.value=_,"onUpdate:currentWidgetData":m[4]||(m[4]=$=>c.value=$),key:_,dashboard:l.value,widget:_,selectedWidget:a.value,"dashboard-widgets":i.value.widgets,class:e.normalizeClass({"border border-blue-500":a.value===_})},null,8,["onClick","dashboard","widget","selectedWidget","dashboard-widgets","class"]))),128)):(e.openBlock(),e.createBlock(re,{key:1,onClick:_=>a.value=u.widget,"onUpdate:currentWidgetData":m[5]||(m[5]=_=>c.value=_),class:e.normalizeClass(["flex flex-col",{"border border-blue-500":a.value===u.widget}]),dashboard:l.value,widget:u.widget,selectedWidget:a.value,"dashboard-widgets":i.value.widgets},null,8,["onClick","class","dashboard","widget","selectedWidget","dashboard-widgets"]))],2)}),128)):(e.openBlock(),e.createBlock(ye,{key:0,class:"col-span-12"}))]))])])],2)}}},[["__scopeId","data-v-cc75be6a"]]),Xn={class:"w-full h-screen"},Jn=e.defineComponent({__name:"vs-editor-page",props:{prefix:{default:"/api"},dashboardId:{default:""}},emits:["back"],setup(s){const t=s,r=t.prefix,n=t.dashboardId;return(o,l)=>(e.openBlock(),e.createElementBlock("div",Xn,[e.createVNode(Qn,{customClass:"h-full w-full",prefix:e.unref(r),"initial-dashboard-id":e.unref(n),onBack:l[0]||(l[0]=a=>o.$emit("back"))},null,8,["prefix","initial-dashboard-id"])]))}}),Kn={class:"relative group h-full"},Yn={class:"flex items-start gap-3 flex-1 min-h-0"},eo={class:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors shrink-0"},to={class:"flex-1 min-w-0 flex flex-col min-h-0"},so={class:"font-semibold text-gray-900 mb-1 truncate"},ro={key:0,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10"},no={key:1,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10 invisible","aria-hidden":"true"},oo={key:2,class:"text-sm text-gray-400 mt-1 shrink-0"},ao=D({__name:"dashboard-card",props:{title:String,description:String,modified:String,name:String,widgetCount:Number,reserveLines:Number,dashboardRouteName:String,onOpenEditor:Function,onOpenView:Function},setup(s){const t=s,r=Ce(),n=e.ref(!1);function o(){var a;t.dashboardRouteName&&(t.onOpenEditor?t.onOpenEditor(t.dashboardRouteName):(a=r==null?void 0:r.push)==null||a.call(r,{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",Kn,[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",Yn,[e.createElementVNode("div",eo,[e.createVNode(e.unref(ps),{size:24,class:"w-5 h-5 text-blue-600"})]),e.createElementVNode("div",to,[e.createElementVNode("h3",so,e.toDisplayString(s.title),1),s.description?(e.openBlock(),e.createElementBlock("p",ro,e.toDisplayString(s.description),1)):(e.openBlock(),e.createElementBlock("p",no,"   ")),s.widgetCount!=null?(e.openBlock(),e.createElementBlock("p",oo,e.toDisplayString(s.widgetCount)+" віджетів ",1)):e.createCommentVNode("",!0)])])])]))}},[["__scopeId","data-v-cde0f33b"]]),lo=[{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:"Switcher",key:"public",label:"Публічний",original:{type:"Text",ua:"Назва",col:8}}];function io(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 co={class:"flex-1 bg-gray-50"},po={class:"max-w-7xl mx-auto px-6 py-8"},ho={class:"mb-6"},mo={class:"flex items-center justify-between mb-6"},uo={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},fo={class:"flex items-center space-x-4"},go={class:"flex-1 relative"},bo={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},yo=e.defineComponent({__name:"all-dashboards-page",props:{prefix:{}},setup(s){const t=e.defineAsyncComponent(()=>import("@opengis/form")),r=io(lo),n=e.ref([]),o=e.ref([]);Ce();const l=e.inject("biSetDashboard"),a=s,i=e.ref(null),c=e.ref(!1),p=e.ref({});ge(a.prefix||"/api");async function d(){try{const k=await T.get("/bi-dashboard?type=db"),u=Array.isArray(k==null?void 0:k.rows)?k.rows:[];o.value=u,n.value=u.map(y=>({routeName:String(y.name??""),title:y.title??y.name??"Без назви",description:y.description??null,modified:"-",name:"-"}))}catch(k){console.error("Failed to load dashboards",k),o.value=[],n.value=[]}}async function h(){var u,y,b;const k=(y=(u=e.getCurrentInstance())==null?void 0:u.proxy)==null?void 0:y.$notify;try{await((b=i.value)==null?void 0:b.doValidation()),await T.post("/bi-dashboard",p.value),c.value=!1,p.value={},k==null||k({type:"success",title:"Успішно!",message:"Дашборд створено успішно"}),await d()}catch{k==null||k({type:"error",title:"Помилка!",message:"При спробі створити дашборд виникла помилка"})}}e.onMounted(d);const g=e.ref(1),f=()=>{const k=window.innerWidth;g.value=k>=1024?3:k>=768?2:1};e.onMounted(()=>{f(),window.addEventListener("resize",f)}),e.onUnmounted(()=>{window.removeEventListener("resize",f)});const m=k=>k?k.trim().length>70?2:1:0,x=k=>{const u=g.value||1,b=Math.floor(k/u)*u,_=b+u,$=n.value.slice(b,_);let w=0;for(const L of $){const P=m(L.description??null);if(P>w&&(w=P),w===2)break}return w};return e.ref("grid"),(k,u)=>(e.openBlock(),e.createElementBlock("div",co,[e.createElementVNode("div",po,[e.createElementVNode("div",ho,[e.createElementVNode("div",mo,[u[5]||(u[5]=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:u[0]||(u[0]=y=>c.value=!0)},[e.createVNode(e.unref(ve),{size:24,class:"w-4 h-4"}),u[4]||(u[4]=e.createElementVNode("span",null,"Новий дашборд",-1))])]),e.createVNode(ne,{teleport:"#modal",visible:c.value,title:"Створити дашборд",onClose:u[3]||(u[3]=y=>c.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",uo,[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:u[2]||(u[2]=y=>c.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:h}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(e.unref(t),{ref_key:"createFormRef",ref:i,schema:e.unref(r),values:p.value,"onUpdate:values":u[1]||(u[1]=y=>p.value=y)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createElementVNode("div",fo,[e.createElementVNode("div",go,[e.createVNode(e.unref(bs),{size:24,class:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),u[6]||(u[6]=e.createElementVNode("input",{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",value:""},null,-1))])])]),e.createElementVNode("div",bo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(y,b)=>(e.openBlock(),e.createElementBlock("div",{key:b,class:"cursor-pointer h-full"},[e.createVNode(ao,{title:y.title,description:y.description,modified:y.modified,name:y.name,reserveLines:x(b),"dashboard-route-name":y.routeName,"on-open-editor":e.unref(l),"on-open-view":e.unref(l)},null,8,["title","description","modified","name","reserveLines","dashboard-route-name","on-open-editor","on-open-view"])]))),128))])])]))}}),xo=e.defineComponent({__name:"editor-root-page",props:{prefix:{default:"/api"}},setup(s){const t=s,r=e.computed(()=>t.prefix),n=e.ref(""),o=rr();e.onMounted(()=>{var i;const a=(i=o==null?void 0:o.query)==null?void 0:i.dashboard;a!=null&&typeof a=="string"&&(n.value=a.trim())});const l=e.computed(()=>n.value.length>0);return e.provide("biSetDashboard",a=>{n.value=a||""}),e.provide("biClearDashboard",()=>{n.value=""}),e.provide("biSelectedDashboardId",e.readonly(n)),(a,i)=>l.value?(e.openBlock(),e.createBlock(Jn,{key:`editor-${n.value}`,prefix:r.value,"dashboard-id":n.value,onBack:i[0]||(i[0]=c=>n.value="")},null,8,["prefix","dashboard-id"])):(e.openBlock(),e.createBlock(yo,{key:0,prefix:r.value},null,8,["prefix"]))}});function W(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 ko(s){return Intl.NumberFormat("en").format(s??0)}class wo{static getTooltipOptions(t=!0){return{show:t,axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}}}}const _o={show_label:!1,show_legend:!1,label:null,legend:{position:null},colors:null,color:null,title:null};function $o(){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=_o){var r;const t={label:{show:s==null?void 0:s.show_label,formatter:(s==null?void 0:s.formatter)??(n=>W(n)),...(s==null?void 0:s.label)||{}},legend:{...(s==null?void 0:s.legend)||{},[((r=s==null?void 0:s.legend)==null?void 0:r.position)||"bottom"]:"0",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 wt(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=>W(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 _t=["#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,R={props:["source","style","widget","dashboard","title","currentWidget","widgetData","prefix"],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){var t;try{const r=await T.get(s);this.sourceData=(r==null?void 0:r.source)||[],this.$emit("update:widgetData",r),this.dimensions=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{}),this.titleCharts=this.style?this.style:(r==null?void 0:r.title)||"",this.styleData=(r==null?void 0:r.style)||{}}catch(r){const n={message:"Дані не знайдено",title:"Помилка!",type:"error",status:400,id:this.widgetName};(r==null?void 0:r.status)=="404"&&(n.status=404,n.message="Дані не знайдено"),(r==null?void 0:r.status)=="400"&&(n.message="Перевірте налаштування або зверніться до адміністратора"),(r==null?void 0:r.status)=="500"&&(n.message="Сталася помилка сервера"),this.$emit("update:widgetData",n)}},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}`},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{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,p;this.widgetInstance&&this.widgetInstance.clear();try{const d=this.$refs.chart,h=ee==null?void 0:ee.init(d);if(!h)return;const g={tooltip:{trigger:"axis",axisPointer:{type:"shadow"},backgroundColor:"transparent",shadowColor:"transparent",padding:[0,0,0,0],borderWidth:0,formatter:f=>{var u;const m=(u=f[0])==null?void 0:u.axisValue;let k=`
161
+ 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 en;function C(s,t){return K.parse(s,t)}C.options=C.setOptions=function(s){return K.setOptions(s),C.defaults=K.defaults,st(C.defaults),C},C.getDefaults=Ne,C.defaults=J,C.use=function(...s){return K.use(...s),C.defaults=K.defaults,st(C.defaults),C},C.walkTokens=function(s,t){return K.walkTokens(s,t)},C.parseInline=K.parseInline,C.Parser=j,C.parser=j.parse,C.Renderer=$e,C.TextRenderer=Pe,C.Lexer=O,C.lexer=O.lex,C.Tokenizer=xe,C.Hooks=de,C.parse=C,C.options,C.setOptions,C.use,C.walkTokens,C.parseInline,j.parse,O.lex;const tn={class:"space-y-4"},sn={__name:"vs-editor-form-data",props:{widgetName:{type:String},dashboardId:{type:String,default:""},data:{type:Object,default:()=>{}},columns:{type:Array,default:()=>[]}},emits:["update-dashboard"],setup(s,{expose:t,emit:r}){var _,$,w,L,P,F,q,U,V,v,Z,G,he,me,ue,I,Q,fe,Ot,jt,Wt,qt,Ut,vt,Ht,Gt,Zt,Qt,Xt,Jt,Kt,Yt;const n=e.defineAsyncComponent(()=>import("@opengis/form")),{$notify:o}=e.getCurrentInstance().proxy,l=r,a=s,i=e.ref(null),c=e.ref([]),p=e.computed(()=>{const E=a.columns??[];return E.length?E:c.value}),d=e.computed(()=>a.dashboardId||i.value);async function h(){const E=d.value;if(!(p.value.length||!E||!a.widgetName))try{const B=await T.get(`/bi-data?dashboard=${E}&widget=${a.widgetName}`);Array.isArray(B==null?void 0:B.columns)&&B.columns.length&&(c.value=B.columns)}catch{}}const g=E=>(E==null?void 0:E.name)!=null?{id:E.name,text:E.title||E.name}:null,f=E=>Array.isArray(E)?[...E].sort((B,H)=>{const te=B.text&&B.text!==B.id,es=H.text&&H.text!==H.id;return te&&!es?-1:!te&&es?1:(B.text||"").localeCompare(H.text||"",void 0,{sensitivity:"base"})}):E,m=e.computed(()=>{const E=(p.value??[]).filter(B=>(B==null?void 0:B.type)=="text"||(B==null?void 0:B.type)==="date"||(B==null?void 0:B.type)==="timestamp without time zone"||(B==null?void 0:B.type)==="boolean"||(B==null?void 0:B.type)==="integer").map(g).filter(Boolean);return f(E)}),x=e.computed(()=>`${a.widgetName}-${m.value.length}-${(p.value??[]).length}`),k=e.computed(()=>({text:{type:"Text",label:"Text",conditions:["type","==","text"]},x:{type:"select",label:"X Axis",style:{size:"xs"},conditions:["type","not_in",["text","table","map"]],options:[...m.value]},cls:{label:"X Axis classifier",type:"text",conditions:["type","not_in",["text","table","map","cluster"]]},y_type:{label:"Y type",type:"select",options:[{id:"columns",text:"columns"},{id:"function",text:"function"}],conditions:["type","not_in",["text","table","map","number","cluster"]]},tableSQL:{label:"tableSQL",type:"text",hidden:!0},metric:{type:"select",label:"Y Axis",conditions:[["type","not_in",["text","table","map","cluster"]],["y_type","!=","function"]],options:[{id:"count",text:"count"},...f(p.value.filter(E=>(E==null?void 0:E.type)==="numeric"||(E==null?void 0:E.type)==="double precision").map(g).filter(Boolean))]},fx:{type:"text",label:"Function",conditions:[["y_type","==","function"]]},query:{label:"Query",type:"text",conditions:["type","not_in",["text","table","map","number"]]},groupby:{type:"select",label:"Groupby",view:"buttons",style:{size:"xs"},options:[{id:"null",text:"null"},...f(p.value.filter(E=>(E==null?void 0:E.type)=="text"||(E==null?void 0:E.type)==="boolean"||(E==null?void 0:E.type)==="integer").map(g).filter(Boolean))],conditions:["type","==","bar"]},columns:{type:"checkbox",label:"Columns",style:{size:"xs"},options:f((p.value??[]).map(g).filter(Boolean)),conditions:["type","in",["table","map"]]},granularity:{type:"radio",label:"Granularity",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}})),u=e.ref({x:(($=(_=a.data)==null?void 0:_.data)==null?void 0:$.x)||((w=a.data)==null?void 0:w.x)||null,metric:((P=(L=a.data)==null?void 0:L.data)==null?void 0:P.metric)||((F=a.data)==null?void 0:F.metric)||null,columns:((U=(q=a.data)==null?void 0:q.data)==null?void 0:U.columns)||((V=a.data)==null?void 0:V.columns)||null,granularity:((Z=(v=a.data)==null?void 0:v.data)==null?void 0:Z.granularity)||((G=a.data)==null?void 0:G.granularity)||null,type:((me=(he=a.data)==null?void 0:he.data)==null?void 0:me.type)||((ue=a.data)==null?void 0:ue.type)||null,groupby:((Q=(I=a.data)==null?void 0:I.data)==null?void 0:Q.groupby)||a.data.groupby||null,fx:((Ot=(fe=a.data)==null?void 0:fe.data)==null?void 0:Ot.fx)||((jt=a.data)==null?void 0:jt.fx)||null,query:((qt=(Wt=a.data)==null?void 0:Wt.data)==null?void 0:qt.query)||((Ut=a.data)==null?void 0:Ut.query)||null,y_type:((Ht=(vt=a.data)==null?void 0:vt.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}),y=async()=>{try{await T.put(`/bi-dashboard/${d.value}/${a.widgetName}`,{data:u.value});let E=`/bi-data?dashboard=${d.value}&widget=${a.widgetName}`;Object.entries(u.value).forEach(([H,te])=>{E+=`&${H}=${te}`});const B=new CustomEvent(`update-data-${a.widgetName}`);B.filterUrl=E,window.dispatchEvent(B),l("update-dashboard"),o({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}},b=async()=>{try{let E=`/bi-data?dashboard=${d.value}&widget=${a.widgetName}`;Object.entries(u.value).forEach(([H,te])=>{E+=`&${H}=${te}`});const B=new CustomEvent(`update-data-${a.widgetName}`);B.filterUrl=E,window.dispatchEvent(B),l("update-dashboard")}catch{await o({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.watch(u,()=>{b()},{deep:!0}),e.onMounted(()=>{const E=new URLSearchParams(window.top.location.search);i.value=E.get("dashboard"),h()}),e.watch(()=>[a.widgetName,a.dashboardId,i.value],()=>{c.value=[],h()},{immediate:!0}),t({requestUpdateWidget:y}),(E,B)=>(e.openBlock(),e.createElementBlock("div",tn,[(e.openBlock(),e.createBlock(e.unref(n),{key:x.value,schema:k.value,values:u.value,"onUpdate:values":B[0]||(B[0]=H=>u.value=H)},null,8,["schema","values"]))]))}},rn={class:"space-y-4"},nn={__name:"vs-editor-form-yaml",props:{yamlValue:{type:null,default:()=>""},widgetName:{type:String},data:{type:Object}},setup(s,{expose:t}){const r=typeof window<"u"?window.echarts:null,n=e.defineAsyncComponent(()=>import("@opengis/form").then(h=>h.VsInputMonaco)),o=e.ref(null),{$notify:l}=e.getCurrentInstance().proxy,a=s,i=(h,{dimensions:g,source:f})=>{const m=h.getOption(),{data:x,...k}=(m==null?void 0:m.series)[0],[,...u]=g||[],y=u.map((b,_)=>({...(m==null?void 0:m.series[_])||{},data:f.map($=>$[_+1]),name:b}));h==null||h.setOption({...m||{},dataset:{dimensions:g,source:f},series:y,xAxis:{type:"category"},yAxis:{}},!0)},c=h=>{const g=document.getElementById(h);if(!g)return null;const f=r==null?void 0:r.getInstanceByDom(g);return f||null},p=e.ref(a.yamlValue),d=async()=>{try{await T.put(`/bi-dashboard/${o.value}/${a.widgetName}`,{yml:p.value});const h=c(a.widgetName);if(h){const g=await T.get(`/bi-data?dashboard=${o.value}&widget=${a.widgetName}`);i(h,g)}l({type:"success",title:"Успішно!",message:"Дані успішно оновлено"})}catch{l({type:"error",title:"Помилка!",message:"При спробі оновити данні сталася помилка"})}};return e.onMounted(()=>{const h=new URLSearchParams(window.top.location.search);o.value=h.get("dashboard")}),t({requestUpdateWidget:d}),(h,g)=>(e.openBlock(),e.createElementBlock("div",rn,[e.createVNode(e.unref(n),{modelValue:p.value,"onUpdate:modelValue":g[0]||(g[0]=f=>p.value=f),syntax:"yaml",theme:"vs-light",height:400,minimap:!1},null,8,["modelValue"])]))}},on={class:"pt-[10px]"},bt={"vs-editor-form-style":_r,"vs-editor-form-data":sn,"vs-editor-form-yaml":nn,"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 d;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:(d=l.columns)==null?void 0:d.map(({name:h})=>h)}},c=e.ref(l.controls||{}),p=async()=>{try{await T.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,g)=>{const f=e.resolveComponent("VsButton");return e.openBlock(),e.createElementBlock("div",on,[e.createVNode(f,{class:"ml-[10px] mb-[10px]",type:"plain",onClick:p},{default:e.withCtx(()=>g[1]||(g[1]=[e.createTextVNode(" Зберегти ")])),_:1}),e.createVNode(e.unref(r),{schema:i,values:c.value,"onUpdate:values":g[0]||(g[0]=m=>c.value=m)},null,8,["values"])])}}}},an={key:0,class:"p-4 text-sm text-amber-700 bg-amber-50 rounded-lg"},yt={__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",an," Помилка завантаження вмісту. Переключіть таб або оновіть сторінку. ")):(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))}},ln={class:"h-full flex flex-col bg-white shrink-0 !w-[400px] border rounded-xl overflow-hidden border-gray-200"},cn={key:0,class:"flex flex-col min-h-0 flex-1"},dn={class:"flex items-center border-b border-gray-200 bg-white shrink-0 px-4 h-[49px]"},pn={class:"flex items-center gap-6 min-w-0 -mb-[14px]"},hn=["onClick"],mn={key:0,class:"absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 rounded-full"},un={class:"flex items-center gap-1 ml-auto shrink-0"},fn={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"},gn={key:0},bn={key:1},yn={class:"p-4"},xn={class:"flex justify-end mt-4 gap-x-3"},kn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},wn={__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=t,l=e.ref(null),a=s,i=e.ref(!1),c=e.ref(!0),p=e.ref(!1),d=e.ref({}),h=e.useModel(s,"selectedWidget"),g=["table","text","number","stat","progress","listbar","map","pivot"],f=e.ref("data"),m=async()=>{try{await T.delete(`/bi-dashboard/${a.selectedDashboard}/${a.selectedWidgetData.name}`);const $=new URL(window.top.location.href);$.searchParams.set("dashboard",a.selectedDashboard),$.searchParams.delete("widget"),window.top.history.pushState({},"",$),o("update-data"),i.value=!1,n({type:"success",title:"Успішно!",message:"Віджет успішно видалено"})}catch($){console.error($),n({type:"error",title:"Помилка!",message:"При спробі видалити віджет виникла помилка"})}},x=e.computed(()=>{const $=[{id:"data",label:"Дані"},{id:"style",label:"Стилі"},{id:"yaml",label:"{ }"}];return $==null?void 0:$.filter(w=>{var L,P,F;return w.id==="style"?!(g!=null&&g.includes(((L=a.selectedWidgetData)==null?void 0:L.type)||((F=(P=a.selectedWidgetData)==null?void 0:P.data)==null?void 0:F.type))):!0})}),k=()=>{var $,w,L,P,F,q,U,V,v;d.value={title:($=a.selectedWidgetData)==null?void 0:$.title,type:(w=a.selectedWidgetData)==null?void 0:w.type,table:(L=a.selectedWidgetData)==null?void 0:L.table_name,query:(F=(P=a.selectedWidgetData)==null?void 0:P.data)==null?void 0:F.query,x:(U=(q=a.selectedWidgetData)==null?void 0:q.data)==null?void 0:U.x,cls:(v=(V=a.selectedWidgetData)==null?void 0:V.data)==null?void 0:v.cls},p.value=!0},u=async()=>{try{await T.put(`/bi-dashboard/${a.selectedDashboard}/${a.selectedWidgetData.name}`,d.value),n({type:"success",title:"Успішно!",message:"Дані успішно змінено"}),await o("update-data"),p.value=!1}catch{n({type:"error",title:"Помилка!",message:"При спробі внести зміни виникла помилка"})}};e.watch(h,$=>{c.value=!1;const w=new URL(window.top.location.href);$?(w.searchParams.set("widget",$),window.top.history.pushState({},"",w)):(w.searchParams.delete("widget"),window.top.history.pushState({},"",w)),setTimeout(()=>c.value=!0)});const y={title:{type:"text",ua:"Заголовок",placeholder:"Заголовок",validators:["required"]},type:{type:"radio",view:"buttons",validators:["required"],slots:{label:'<div style="width: 120px; height:160px" class="flex gap-[12px] flex-col"><img class="block" style="height: calc(100% - 40px)" :src="`https://cdn.softpro.ua/data/icons/bi/${id}.png`"/><span class="font-[500]">{{ label }}</span></div>'},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 Axis",placeholder:"X Axis"},cls:{type:"Text",ua:"Cls",placeholder:"Cls"}};return($,w)=>{var P,F,q,U,V,v,Z,G,he,me,ue;const L=e.resolveComponent("VsPopover");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",ln,[s.selectedWidgetData?(e.openBlock(),e.createElementBlock("div",cn,[e.createElementVNode("div",dn,[e.createElementVNode("nav",pn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,I=>(e.openBlock(),e.createElementBlock("button",{key:I.id,type:"button",class:e.normalizeClass(["relative pb-3 pt-1 text-sm font-medium transition-colors whitespace-nowrap",f.value===I.id?"text-blue-600":"text-gray-600 hover:text-gray-900"]),onClick:Q=>f.value=I.id},[e.createTextVNode(e.toDisplayString(I.label)+" ",1),f.value===I.id?(e.openBlock(),e.createElementBlock("span",mn)):e.createCommentVNode("",!0)],10,hn))),128))]),e.createElementVNode("div",un,[e.createVNode(L,{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:w[0]||(w[0]=I=>{var Q,fe;return(fe=(Q=l.value)==null?void 0:Q.save)==null?void 0:fe.call(Q)})},[e.createVNode(e.unref(gs),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[w[9]||(w[9]=e.createTextVNode(" Зберегти "))]),_:1}),e.createVNode(L,{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:k},[e.createVNode(tt,{class:"h-4 w-4"})])]),default:e.withCtx(()=>[w[10]||(w[10]=e.createTextVNode(" Редагувати віджет "))]),_:1}),e.createVNode(L,{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:w[1]||(w[1]=I=>i.value=!0)},[e.createVNode(e.unref(et),{class:"h-4 w-4"})])]),default:e.withCtx(()=>[w[11]||(w[11]=e.createTextVNode(" Видалити віджет "))]),_:1})])]),(P=s.currentWidgetData)!=null&&P.status?(e.openBlock(),e.createBlock(ye,{key:0,title:(F=s.currentWidgetData)==null?void 0:F.title,text:(q=s.currentWidgetData)==null?void 0:q.message},null,8,["title","text"])):(e.openBlock(),e.createElementBlock("div",fn,[c.value&&s.currentWidgetData?(e.openBlock(),e.createElementBlock("div",gn,[e.createVNode(yt,{ref_key:"tabPanelRef",ref:l,"tab-key":f.value,"tab-component":e.unref(bt)["vs-editor-form-"+f.value],widgetName:(U=s.selectedWidgetData)==null?void 0:U.name,dashboardId:s.selectedDashboard,yamlValue:((V=s.selectedWidgetData)==null?void 0:V.yml)||"",data:s.selectedWidgetData,controls:(v=s.selectedWidgetData)==null?void 0:v.controls,columns:(Z=s.currentWidgetData)==null?void 0:Z.columns,onUpdateDashboard:w[2]||(w[2]=I=>$.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])):(e.openBlock(),e.createElementBlock("div",bn,[e.createVNode(yt,{ref_key:"tabPanelRef",ref:l,"tab-key":f.value,"tab-component":e.unref(bt)["vs-editor-form-"+f.value],widgetName:(G=s.selectedWidgetData)==null?void 0:G.name,dashboardId:s.selectedDashboard,yamlValue:((he=s.selectedWidgetData)==null?void 0:he.yml)||"",data:s.selectedWidgetData,controls:(me=s.selectedWidgetData)==null?void 0:me.controls,columns:(ue=s.currentWidgetData)==null?void 0:ue.columns,onUpdateDashboard:w[3]||(w[3]=I=>$.$emit("update-data"))},null,8,["tab-key","tab-component","widgetName","dashboardId","yamlValue","data","controls","columns"])])),e.createVNode(ne,{teleport:"#modal",visible:i.value,title:"Ви впевнені?",onClose:w[5]||(w[5]=I=>i.value=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",yn,[w[12]||(w[12]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей віджет? ",-1)),e.createElementVNode("div",xn,[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:w[4]||(w[4]=I=>i.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:m}," Так, я впевнена(ий) ")])])]),_:1},8,["visible"])]))])):(e.openBlock(),e.createBlock(ye,{key:1,title:"Оберіть один з віджетів",text:"",class:"p-4"}))]),e.createVNode(ne,{teleport:"#modal",visible:p.value,title:"Редагувати віджет",onClose:w[8]||(w[8]=I=>p.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",kn,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:w[7]||(w[7]=I=>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: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 hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:e.withCtx(()=>[y?(e.openBlock(),e.createBlock(e.unref(r),{key:0,schema:y,values:d.value,"onUpdate:values":w[6]||(w[6]=I=>d.value=I)},null,8,["values"])):e.createCommentVNode("",!0)]),_:1},8,["visible"])],64)}}},_n={class:"overflow-hidden flex flex-col min-h-[480px]"},$n={class:"flex-1 flex min-h-0 gap-4"},Vn={class:"flex-1 min-w-0 pb-4 overflow-auto bg-gray-50/50"},En={class:"w-[400px] shrink-0 flex flex-col"},Bn={__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.computed({get:()=>r.selectedWidget,set:l=>n("update:selectedWidget",l)});return(l,a)=>(e.openBlock(),e.createElementBlock("div",_n,[e.createElementVNode("div",$n,[e.createElementVNode("div",Vn,[e.createVNode(re,{dashboard:s.selectedDashboard,widget:s.selectedWidget,"selected-widget":s.selectedWidget,"dashboard-widgets":s.dashboardWidgets,"filter-u-rl":void 0,class:"max-h-full"},null,8,["dashboard","widget","selected-widget","dashboard-widgets"])]),e.createElementVNode("div",En,[e.createVNode(wn,{selectedWidget:o.value,"onUpdate:selectedWidget":a[0]||(a[0]=i=>o.value=i),selectedWidgetData:s.selectedWidgetData,currentWidgetData:s.currentWidgetData,selectedDashboard:s.selectedDashboard,onUpdateData:a[1]||(a[1]=i=>l.$emit("update-data"))},null,8,["selectedWidget","selectedWidgetData","currentWidgetData","selectedDashboard"])])])]))}},xt={__name:"icon-grid",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(hs),e.mergeProps(t.$attrs,{size:24}),null,16))}},kt={__name:"icon-table",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ys),e.mergeProps(t.$attrs,{size:24}),null,16))}},Cn={__name:"icon-more",setup(s){return(t,r)=>(e.openBlock(),e.createBlock(e.unref(ls),e.mergeProps(t.$attrs,{size:24}),null,16))}},Dn=e.defineAsyncComponent(()=>import("@opengis/form")),Nn={components:{VsModal:ne,VForm:Dn,deleteIcon:et,editIcon:tt,IconGrid:xt,IconMore:Cn,IconTable:kt},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(p=>(p==null?void 0:p.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",editable:!1,addition:!1,colModel:[{name:"title",ua:"Назва",type:"Text",key:"col"},{name:"type",ua:"Тип",type:"Text",key:"col",disabled:!0},{name:"widget",type:"Text",ua:"Назва",key:"widget",hiddenCol:!0},{name:"col",ua:"Кількість стовпчиків",type:"Text",key:"col"}]}]}},props:{selected:{type:String,default:()=>""},dashboardData:{type:Object,default:()=>{}},selectedWidgetData:{type:Object,default:()=>{}},columns:{type:Array}},methods:{async editDashboard(){var s,t;try{(t=(s=this.$refs)==null?void 0:s.formEdit)==null||t.doValidation(),await T.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 T.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 T.delete(`/bi-dashboard/${this.selected}`);const s=new URL(window.top.location.href);s.searchParams.delete("dashboard"),s.searchParams.delete("widget"),window.history.pushState({},"",s),await this.$notify({title:"Успішно!",type:"success",message:"Дашборд видалено успішно"}),this.isDeleteConfirm=!1,await this.$emit("update:selected",null),await this.$emit("update-editor")}catch{this.$notify({title:"Помилка!",type:"error",message:"При спробі видалити дашборд виникла помилка"})}},closePopover(){document.body.click()}}},Sn={key:0,class:"flex items-center gap-4"},zn={class:"h-[30px] w-[30px] flex items-center justify-center"},Ln={class:"flex flex-col items-start -ml-2 -mr-2"},Tn={class:"p-4"},In={class:"flex justify-end mt-4 gap-x-3"},Mn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},Pn={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"};function Rn(s,t,r,n,o,l){const a=e.resolveComponent("IconGrid"),i=e.resolveComponent("VsPopover"),c=e.resolveComponent("IconMore"),p=e.resolveComponent("VsModal"),d=e.resolveComponent("VForm");return e.openBlock(),e.createElementBlock("div",null,[r.selected?(e.openBlock(),e.createElementBlock("div",Sn,[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}),e.createVNode(i,{placement:"left",trigger:"hover"},{reference:e.withCtx(()=>[e.createVNode(i,{placement:"bottom-left"},{reference:e.withCtx(()=>[e.createElementVNode("button",zn,[e.createVNode(c,{class:"h-[20px]"})])]),default:e.withCtx(()=>[e.createElementVNode("div",Ln,[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})])):e.createCommentVNode("",!0),e.createVNode(p,{teleport:"#modal",visible:o.isDeleteConfirm,size:"small",title:"Ви впевнені?",onClose:t[5]||(t[5]=h=>o.isDeleteConfirm=!1)},{default:e.withCtx(()=>[e.createElementVNode("div",Tn,[t[16]||(t[16]=e.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей дашборд? ",-1)),e.createElementVNode("div",In,[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(p,{teleport:"#modal",visible:o.isFormEdit,title:"Редагувати дашборд",onClose:t[9]||(t[9]=h=>o.isFormEdit=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Mn,[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(d,{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(p,{teleport:"#modal",visible:o.isFormGrid,title:"Редагувати структуру дашборду",onClose:t[13]||(t[13]=h=>o.isFormGrid=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",Pn,[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(d,{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 Fn=D(Nn,[["render",Rn]]),An={class:"flex-1 min-w-0 flex flex-col overflow-auto"},On={class:"max-w-7xl mx-auto px-6 w-full flex flex-col min-h-0 flex-1"},jn={class:"relative z-10 shrink-0 mt-4 mb-6"},Wn={class:"flex items-center text-sm text-gray-600"},qn={key:0,class:"flex items-center justify-between gap-4 mt-3"},Un={class:"min-w-0"},vn={class:"text-2xl font-bold text-gray-900"},Hn={key:0,class:"mt-1.5 text-sm text-gray-600"},Gn={class:"flex items-center shrink-0"},Zn={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"},Qn=D({__name:"vs-editor",props:{prefix:String,customClass:{type:String,default:()=>"w-screen h-screen"},initialDashboardId:{type:String,default:""}},emits:["back"],setup(s,{emit:t}){const r=s;ge(r.prefix||"/api");const n=t,o=e.inject("biClearDashboard",null),l=e.ref(r.initialDashboardId||""),a=e.ref(""),i=e.ref(null),c=e.ref(null),p=e.ref(null),d=async()=>{if(!l.value){i.value=null;return}try{const f=await T.get(`/bi-dashboard/${l.value}`);i.value=f}catch(f){console.error(f)}},h=e.computed(()=>{var f,m,x;return(x=Array.isArray((f=i.value)==null?void 0:f.widgets)?(m=i.value)==null?void 0:m.widgets:[])==null?void 0:x.find(k=>(k==null?void 0:k.name)===a.value)}),g=e.computed(()=>{var x,k,u,y,b;const m=[o?{label:"Дашборди",onClick:()=>{o(),n("back")}}:{label:"Дашборди",to:"/editor"}];if((x=i.value)!=null&&x.title||l.value){const _=((k=i.value)==null?void 0:k.title)||l.value||"Редактор",$=!!a.value;m.push({label:_,...$?{onClick:()=>{a.value=""}}:{}})}else m.push({label:"Редактор"});if(a.value&&h.value){const _=((y=(u=h.value)==null?void 0:u.data)==null?void 0:y.title)||((b=h.value)==null?void 0:b.title)||a.value;m.push({label:_})}return m});return e.watch(l,(f,m)=>{var k,u,y;m&&(a.value="");const x=new URL(window.top.location.href);f?((k=x==null?void 0:x.searchParams)==null||k.set("dashboard",f),(y=(u=window.top)==null?void 0:u.history)==null||y.pushState({},"",x),d()):(x==null||x.searchParams.delete("dashboard"),x==null||x.searchParams.delete("widget"))}),e.onMounted(()=>{var f,m;if(r.initialDashboardId)l.value=r.initialDashboardId;else{const x=new URLSearchParams(((m=(f=window.top)==null?void 0:f.location)==null?void 0:m.search)||""),k=x.get("dashboard");k&&(l.value=k),a.value=x.get("widget")||""}d()}),(f,m)=>{var x,k;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex w-full h-full",[s.customClass]])},[e.createElementVNode("div",An,[e.createElementVNode("div",On,[e.createElementVNode("div",jn,[e.createElementVNode("div",Wn,[e.createVNode(Ye,{items:g.value,compact:""},null,8,["items"])]),l.value&&i.value?(e.openBlock(),e.createElementBlock("div",qn,[e.createElementVNode("div",Un,[e.createElementVNode("h1",vn,e.toDisplayString(i.value.title||l.value),1),i.value.description?(e.openBlock(),e.createElementBlock("p",Hn,e.toDisplayString(i.value.description),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Gn,[a.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:m[0]||(m[0]=u=>a.value="")},[e.createVNode(e.unref(He),{class:"w-4 h-4"}),m[6]||(m[6]=e.createTextVNode(" Закрити "))])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(Fn,{selected:l.value,"onUpdate:selected":m[1]||(m[1]=u=>l.value=u),dashboardData:i.value,columns:(x=i.value)==null?void 0:x.columns,selectedWidgetData:h.value,prefix:s.prefix,onUpdateEditor:d},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:m[2]||(m[2]=u=>{var y,b;return(b=(y=p.value)==null?void 0:y.open)==null?void 0:b.call(y)})},m[7]||(m[7]=[e.createElementVNode("span",{class:"leading-none"},"+",-1),e.createTextVNode(" Створити віджет ")])),l.value?(e.openBlock(),e.createBlock(kr,{key:0,ref_key:"createWidgetRef",ref:p,inline:"",columns:(k=i.value)==null?void 0:k.columns,selectedDashboard:l.value,onUpdateData:d},null,8,["columns","selectedDashboard"])):e.createCommentVNode("",!0)],64))])])):e.createCommentVNode("",!0)]),a.value&&i.value?(e.openBlock(),e.createBlock(Bn,{key:0,"selected-widget":a.value,"onUpdate:selectedWidget":m[3]||(m[3]=u=>a.value=u),"selected-widget-data":h.value,"current-widget-data":c.value,"selected-dashboard":l.value,"dashboard-widgets":i.value.widgets||[],onUpdateData:d},null,8,["selected-widget","selected-widget-data","current-widget-data","selected-dashboard","dashboard-widgets"])):(e.openBlock(),e.createElementBlock("div",Zn,[i.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(i.value.panels,(u,y)=>{var b;return e.openBlock(),e.createElementBlock("div",{key:y,class:e.normalizeClass([`col-span-${u.col||12}`,"flex flex-col gap-[10px]"])},[(b=u.widgets)!=null&&b.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(u.widgets,_=>(e.openBlock(),e.createBlock(re,{onClick:$=>a.value=_,"onUpdate:currentWidgetData":m[4]||(m[4]=$=>c.value=$),key:_,dashboard:l.value,widget:_,selectedWidget:a.value,"dashboard-widgets":i.value.widgets,class:e.normalizeClass({"border border-blue-500":a.value===_})},null,8,["onClick","dashboard","widget","selectedWidget","dashboard-widgets","class"]))),128)):(e.openBlock(),e.createBlock(re,{key:1,onClick:_=>a.value=u.widget,"onUpdate:currentWidgetData":m[5]||(m[5]=_=>c.value=_),class:e.normalizeClass(["flex flex-col",{"border border-blue-500":a.value===u.widget}]),dashboard:l.value,widget:u.widget,selectedWidget:a.value,"dashboard-widgets":i.value.widgets},null,8,["onClick","class","dashboard","widget","selectedWidget","dashboard-widgets"]))],2)}),128)):(e.openBlock(),e.createBlock(ye,{key:0,class:"col-span-12"}))]))])])],2)}}},[["__scopeId","data-v-cc75be6a"]]),Xn={class:"w-full h-screen"},Jn=e.defineComponent({__name:"vs-editor-page",props:{prefix:{default:"/api"},dashboardId:{default:""}},emits:["back"],setup(s){const t=s,r=t.prefix,n=t.dashboardId;return(o,l)=>(e.openBlock(),e.createElementBlock("div",Xn,[e.createVNode(Qn,{customClass:"h-full w-full",prefix:e.unref(r),"initial-dashboard-id":e.unref(n),onBack:l[0]||(l[0]=a=>o.$emit("back"))},null,8,["prefix","initial-dashboard-id"])]))}}),Kn={class:"relative group h-full"},Yn={class:"flex items-start gap-3 flex-1 min-h-0"},eo={class:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors shrink-0"},to={class:"flex-1 min-w-0 flex flex-col min-h-0"},so={class:"font-semibold text-gray-900 mb-1 truncate"},ro={key:0,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10"},no={key:1,class:"text-sm text-gray-600 mb-2 line-clamp-2 min-h-10 invisible","aria-hidden":"true"},oo={key:2,class:"text-sm text-gray-400 mt-1 shrink-0"},ao=D({__name:"dashboard-card",props:{title:String,description:String,modified:String,name:String,widgetCount:Number,reserveLines:Number,dashboardRouteName:String,onOpenEditor:Function,onOpenView:Function},setup(s){const t=s,r=Ce(),n=e.ref(!1);function o(){var a;t.dashboardRouteName&&(t.onOpenEditor?t.onOpenEditor(t.dashboardRouteName):(a=r==null?void 0:r.push)==null||a.call(r,{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",Kn,[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",Yn,[e.createElementVNode("div",eo,[e.createVNode(e.unref(ps),{size:24,class:"w-5 h-5 text-blue-600"})]),e.createElementVNode("div",to,[e.createElementVNode("h3",so,e.toDisplayString(s.title),1),s.description?(e.openBlock(),e.createElementBlock("p",ro,e.toDisplayString(s.description),1)):(e.openBlock(),e.createElementBlock("p",no,"   ")),s.widgetCount!=null?(e.openBlock(),e.createElementBlock("p",oo,e.toDisplayString(s.widgetCount)+" віджетів ",1)):e.createCommentVNode("",!0)])])])]))}},[["__scopeId","data-v-cde0f33b"]]),lo=[{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:"Switcher",key:"public",label:"Публічний",original:{type:"Text",ua:"Назва",col:8}}];function io(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 co={class:"flex-1 bg-gray-50"},po={class:"max-w-7xl mx-auto px-6 py-8"},ho={class:"mb-6"},mo={class:"flex items-center justify-between mb-6"},uo={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},fo={class:"flex items-center space-x-4"},go={class:"flex-1 relative"},bo={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"},yo=e.defineComponent({__name:"all-dashboards-page",props:{prefix:{}},setup(s){const t=e.defineAsyncComponent(()=>import("@opengis/form")),r=io(lo),n=e.ref([]),o=e.ref([]);Ce();const l=e.inject("biSetDashboard"),a=s,i=e.ref(null),c=e.ref(!1),p=e.ref({});async function d(){try{const k=await T.get("/bi-dashboard?type=db"),u=Array.isArray(k==null?void 0:k.rows)?k.rows:[];o.value=u,n.value=u.map(y=>({routeName:String(y.name??""),title:y.title??y.name??"Без назви",description:y.description??null,modified:"-",name:"-"}))}catch(k){console.error("Failed to load dashboards",k),o.value=[],n.value=[]}}async function h(){var u,y,b;const k=(y=(u=e.getCurrentInstance())==null?void 0:u.proxy)==null?void 0:y.$notify;try{const _=(b=i.value)==null?void 0:b.doValidation;typeof _=="function"&&await _(),await T.post("/bi-dashboard",p.value),c.value=!1,p.value={},k==null||k({type:"success",title:"Успішно!",message:"Дашборд створено успішно"}),await d()}catch{k==null||k({type:"error",title:"Помилка!",message:"При спробі створити дашборд виникла помилка"})}}e.onMounted(()=>{ge(a.prefix||"/api"),d()});const g=e.ref(1),f=()=>{const k=window.innerWidth;g.value=k>=1024?3:k>=768?2:1};e.onMounted(()=>{f(),window.addEventListener("resize",f)}),e.onUnmounted(()=>{window.removeEventListener("resize",f)});const m=k=>k?k.trim().length>70?2:1:0,x=k=>{const u=g.value||1,b=Math.floor(k/u)*u,_=b+u,$=n.value.slice(b,_);let w=0;for(const L of $){const P=m(L.description??null);if(P>w&&(w=P),w===2)break}return w};return e.ref("grid"),(k,u)=>(e.openBlock(),e.createElementBlock("div",co,[e.createElementVNode("div",po,[e.createElementVNode("div",ho,[e.createElementVNode("div",mo,[u[5]||(u[5]=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:u[0]||(u[0]=y=>c.value=!0)},[e.createVNode(e.unref(ve),{size:24,class:"w-4 h-4"}),u[4]||(u[4]=e.createElementVNode("span",null,"Новий дашборд",-1))])]),e.createVNode(ne,{teleport:"#modal",visible:c.value,title:"Створити дашборд",onClose:u[3]||(u[3]=y=>c.value=!1)},{footer:e.withCtx(()=>[e.createElementVNode("div",uo,[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:u[2]||(u[2]=y=>c.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:h}," Зберегти ")])]),default:e.withCtx(()=>[e.createVNode(e.unref(t),{ref_key:"createFormRef",ref:i,schema:e.unref(r),values:p.value,"onUpdate:values":u[1]||(u[1]=y=>p.value=y)},null,8,["schema","values"])]),_:1},8,["visible"]),e.createElementVNode("div",fo,[e.createElementVNode("div",go,[e.createVNode(e.unref(bs),{size:24,class:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),u[6]||(u[6]=e.createElementVNode("input",{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",value:""},null,-1))])])]),e.createElementVNode("div",bo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(y,b)=>(e.openBlock(),e.createElementBlock("div",{key:b,class:"cursor-pointer h-full"},[e.createVNode(ao,{title:y.title,description:y.description,modified:y.modified,name:y.name,reserveLines:x(b),"dashboard-route-name":y.routeName,"on-open-editor":e.unref(l),"on-open-view":e.unref(l)},null,8,["title","description","modified","name","reserveLines","dashboard-route-name","on-open-editor","on-open-view"])]))),128))])])]))}}),xo=e.defineComponent({__name:"editor-root-page",props:{prefix:{default:"/api"}},setup(s){const t=s,r=e.computed(()=>t.prefix),n=e.ref(""),o=rr();e.onMounted(()=>{var i;const a=(i=o==null?void 0:o.query)==null?void 0:i.dashboard;a!=null&&typeof a=="string"&&(n.value=a.trim())});const l=e.computed(()=>n.value.length>0);return e.provide("biSetDashboard",a=>{n.value=a||""}),e.provide("biClearDashboard",()=>{n.value=""}),e.provide("biSelectedDashboardId",e.readonly(n)),(a,i)=>l.value?(e.openBlock(),e.createBlock(Jn,{key:`editor-${n.value}`,prefix:r.value,"dashboard-id":n.value,onBack:i[0]||(i[0]=c=>n.value="")},null,8,["prefix","dashboard-id"])):(e.openBlock(),e.createBlock(yo,{key:0,prefix:r.value},null,8,["prefix"]))}});function W(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 ko(s){return Intl.NumberFormat("en").format(s??0)}class wo{static getTooltipOptions(t=!0){return{show:t,axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}}}}const _o={show_label:!1,show_legend:!1,label:null,legend:{position:null},colors:null,color:null,title:null};function $o(){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=_o){var r;const t={label:{show:s==null?void 0:s.show_label,formatter:(s==null?void 0:s.formatter)??(n=>W(n)),...(s==null?void 0:s.label)||{}},legend:{...(s==null?void 0:s.legend)||{},[((r=s==null?void 0:s.legend)==null?void 0:r.position)||"bottom"]:"0",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 wt(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=>W(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 _t=["#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,R={props:["source","style","widget","dashboard","title","currentWidget","widgetData","prefix"],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){var t;try{const r=await T.get(s);this.sourceData=(r==null?void 0:r.source)||[],this.$emit("update:widgetData",r),this.dimensions=Object.keys(((t=this.sourceData)==null?void 0:t[0])||{}),this.titleCharts=this.style?this.style:(r==null?void 0:r.title)||"",this.styleData=(r==null?void 0:r.style)||{}}catch(r){const n={message:"Дані не знайдено",title:"Помилка!",type:"error",status:400,id:this.widgetName};(r==null?void 0:r.status)=="404"&&(n.status=404,n.message="Дані не знайдено"),(r==null?void 0:r.status)=="400"&&(n.message="Перевірте налаштування або зверніться до адміністратора"),(r==null?void 0:r.status)=="500"&&(n.message="Сталася помилка сервера"),this.$emit("update:widgetData",n)}},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}`},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{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,p;this.widgetInstance&&this.widgetInstance.clear();try{const d=this.$refs.chart,h=ee==null?void 0:ee.init(d);if(!h)return;const g={tooltip:{trigger:"axis",axisPointer:{type:"shadow"},backgroundColor:"transparent",shadowColor:"transparent",padding:[0,0,0,0],borderWidth:0,formatter:f=>{var u;const m=(u=f[0])==null?void 0:u.axisValue;let k=`
162
162
  <div style="background-color: rgba(255, 255, 255, 0.7)" class="border border-gray-200 text-gray-800 rounded-lg shadow-md dark:bg-neutral-800 dark:border-neutral-700 min-w-28">
163
163
  <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">
164
164
  ${m?this.formatDate(m):"N/A"}
@@ -389,8 +389,8 @@ function Es(s, e) {
389
389
  }
390
390
  const Os = /* @__PURE__ */ H(Ns, [["render", Es]]), Ct = {
391
391
  "bi-bar": A(() => Promise.resolve().then(() => qa)),
392
- "bi-number": A(() => import("./vs-number-DXMmIAu0.js")),
393
- "bi-text": A(() => import("./vs-text-qF7xeWu5.js")),
392
+ "bi-number": A(() => import("./vs-number-DEXBzAo0.js")),
393
+ "bi-text": A(() => import("./vs-text-dRkUKgfX.js")),
394
394
  "bi-listbar": A(() => Promise.resolve().then(() => Mi)),
395
395
  "bi-pie": A(() => Promise.resolve().then(() => ti)),
396
396
  "bi-donut": A(() => Promise.resolve().then(() => Xa)),
@@ -398,10 +398,10 @@ const Os = /* @__PURE__ */ H(Ns, [["render", Es]]), Ct = {
398
398
  "bi-stat": A(() => Promise.resolve().then(() => ki)),
399
399
  "bi-pivot": A(() => Promise.resolve().then(() => oo)),
400
400
  "bi-progress": A(() => Promise.resolve().then(() => Pi)),
401
- "bi-funnel": A(() => import("./vs-funnel-bar-BYIBOhaT.js")),
402
- "bi-map": A(() => import("./vs-map-DEmnVnil.js")),
403
- "bi-cluster": A(() => import("./vs-map-cluster-Dv4ypLk9.js")),
404
- "bi-table": A(() => import("./vs-table-C5I59PQW.js"))
401
+ "bi-funnel": A(() => import("./vs-funnel-bar-C2wlZv7n.js")),
402
+ "bi-map": A(() => import("./vs-map-C2ZLumZg.js")),
403
+ "bi-cluster": A(() => import("./vs-map-cluster-CVqhulcc.js")),
404
+ "bi-table": A(() => import("./vs-table-CQ_vMUHg.js"))
405
405
  };
406
406
  let qt = "/api";
407
407
  function Me(s) {
@@ -452,7 +452,7 @@ const G = {
452
452
  }
453
453
  }, Bs = {
454
454
  key: 0,
455
- class: "text-[16px] flex max-w-full items-center min-h-0 justify-between max-h-[50px] h-fit shrink-0"
455
+ class: "text-[16px] flex max-w-full items-center min-h-0 justify-between h-fit shrink-0"
456
456
  }, Fs = { class: "flex items-center justify-between w-full gap-2" }, qs = { class: "flex items-center gap-2 min-w-0" }, Ms = { class: "text-gray-800 inline-block line-clamp-1 font-semibold" }, Us = { class: "flex flex-col justify-end" }, Gs = {
457
457
  key: 0,
458
458
  class: "flex items-center justify-end w-full gap-2"
@@ -470,7 +470,7 @@ const G = {
470
470
  setup(s, { emit: e }) {
471
471
  const t = s, r = e, n = S(null), i = S(null), a = S(null), o = S({}), l = S([]), c = F(() => {
472
472
  var b, x;
473
- const g = (b = t.dashboardWidgets) == null ? void 0 : b.find((_) => _.name === t.widget);
473
+ const g = (b = t.dashboardWidgets) == null ? void 0 : b.find(($) => $.name === t.widget);
474
474
  return ((x = g == null ? void 0 : g.data) == null ? void 0 : x.title) ?? (g == null ? void 0 : g.title) ?? "";
475
475
  }), d = F(() => {
476
476
  var b;
@@ -488,18 +488,18 @@ const G = {
488
488
  return g && g in Ct ? Ct[g] : null;
489
489
  });
490
490
  function m(g, b) {
491
- var x, _;
492
- (_ = (x = i.value) == null ? void 0 : x.changeStyle) == null || _.call(x, g, b);
491
+ var x, $;
492
+ ($ = (x = i.value) == null ? void 0 : x.changeStyle) == null || $.call(x, g, b);
493
493
  }
494
494
  function h(g, b) {
495
- const x = l.value.find((_) => _.name === b);
495
+ const x = l.value.find(($) => $.name === b);
496
496
  x ? x.option = g : l.value.push({ name: b, option: g }), v();
497
497
  }
498
498
  function v() {
499
499
  var b, x;
500
500
  let g = `/bi-data?dashboard=${t.dashboard}&widget=${t.widget}`;
501
- l.value.forEach((_) => {
502
- g += `&${_.name}=${_.option}`;
501
+ l.value.forEach(($) => {
502
+ g += `&${$.name}=${$.option}`;
503
503
  }), (x = (b = i.value) == null ? void 0 : b.getDataFromURL) == null || x.call(b, g);
504
504
  }
505
505
  function k() {
@@ -536,12 +536,12 @@ const G = {
536
536
  },
537
537
  { deep: !0 }
538
538
  ), (g, b) => {
539
- var x, _, T, $, O, M, Z, se, re;
539
+ var x, $, T, _, O, M, Z, se, re;
540
540
  return f(), w("div", {
541
541
  ref_key: "widgetRef",
542
542
  ref: n,
543
543
  class: Q(["box-border relative h-full p-4 bg-white border border-gray-200 rounded-xl shadow-sm select-auto", [
544
- (_ = (x = o.value) == null ? void 0 : x.style) != null && _.height ? `max-h-[${($ = (T = o.value) == null ? void 0 : T.style) == null ? void 0 : $.height}px] h-[${(M = (O = o.value) == null ? void 0 : O.style) == null ? void 0 : M.height}px]` : "max-h-[460px]"
544
+ ($ = (x = o.value) == null ? void 0 : x.style) != null && $.height ? `max-h-[${(_ = (T = o.value) == null ? void 0 : T.style) == null ? void 0 : _.height}px] h-[${(M = (O = o.value) == null ? void 0 : O.style) == null ? void 0 : M.height}px]` : "max-h-[460px]"
545
545
  ]])
546
546
  }, [
547
547
  ["text", "cluster", "map"].includes(d.value) ? E("", !0) : (f(), w("div", Bs, [
@@ -950,8 +950,10 @@ const uo = /* @__PURE__ */ H(wr, [["render", $r]]), _r = {
950
950
  }
951
951
  e({ open: d, close: u });
952
952
  const y = async () => {
953
+ var v;
953
954
  try {
954
- await c.value.doValidation(), await G.post(
955
+ const k = (v = c.value) == null ? void 0 : v.doValidation;
956
+ typeof k == "function" && await k(), await G.post(
955
957
  `/bi-dashboard/${a.selectedDashboard}`,
956
958
  l.value
957
959
  ), await n({
@@ -959,11 +961,12 @@ const uo = /* @__PURE__ */ H(wr, [["render", $r]]), _r = {
959
961
  title: "Успішно!",
960
962
  message: "Віджет успішно створено"
961
963
  }), await i("update-data"), l.value = {}, o.value = !1;
962
- } catch {
963
- n({
964
+ } catch (k) {
965
+ const g = (k == null ? void 0 : k.message) || "При спробі створити віджет сталася помилка. Перевірте обов'язкові поля (зокрема Type).";
966
+ n == null || n({
964
967
  type: "error",
965
968
  title: "Помилка!",
966
- message: "При спробі створити віджет сталася помилка"
969
+ message: g
967
970
  });
968
971
  }
969
972
  }, m = F(() => {
@@ -983,10 +986,10 @@ const uo = /* @__PURE__ */ H(wr, [["render", $r]]), _r = {
983
986
  validators: ["required"],
984
987
  options: (k = (v = a.columns) == null ? void 0 : v.filter(
985
988
  (x) => (x == null ? void 0 : x.type) == "text" || (x == null ? void 0 : x.type) === "date" || (x == null ? void 0 : x.type) === "timestamp without time zone" || (x == null ? void 0 : x.type) === "boolean" || (x == null ? void 0 : x.type) === "integer"
986
- )) == null ? void 0 : k.map(({ name: x, type: _ }) => ({
989
+ )) == null ? void 0 : k.map(({ name: x, type: $ }) => ({
987
990
  id: x,
988
991
  text: x,
989
- type: _
992
+ type: $
990
993
  }))
991
994
  },
992
995
  metric: {
@@ -997,10 +1000,10 @@ const uo = /* @__PURE__ */ H(wr, [["render", $r]]), _r = {
997
1000
  style: { size: "xs" },
998
1001
  options: [
999
1002
  { id: "count", label: "count" },
1000
- ...(b = (g = a.columns) == null ? void 0 : g.filter((x) => (x == null ? void 0 : x.type) === "numeric" || (x == null ? void 0 : x.type) === "double precision")) == null ? void 0 : b.map(({ name: x, type: _ }) => ({
1003
+ ...(b = (g = a.columns) == null ? void 0 : g.filter((x) => (x == null ? void 0 : x.type) === "numeric" || (x == null ? void 0 : x.type) === "double precision")) == null ? void 0 : b.map(({ name: x, type: $ }) => ({
1001
1004
  id: x,
1002
1005
  text: x,
1003
- type: _
1006
+ type: $
1004
1007
  }))
1005
1008
  ]
1006
1009
  },
@@ -1221,15 +1224,15 @@ const uo = /* @__PURE__ */ H(wr, [["render", $r]]), _r = {
1221
1224
  title: "Show tooltip"
1222
1225
  }
1223
1226
  }, c = S({ ...((v = (h = n.data) == null ? void 0 : h.style) == null ? void 0 : v.label) || {} }), d = S({ ...((g = (k = n.data) == null ? void 0 : k.style) == null ? void 0 : g.legend) || {} }), u = S({ ...((x = (b = n.data) == null ? void 0 : b.style) == null ? void 0 : x.tooltip) || {} }), y = () => {
1224
- const _ = new CustomEvent(`update-style-${n.widgetName}`);
1225
- _.chartId = n.widgetName, _.options = {
1227
+ const $ = new CustomEvent(`update-style-${n.widgetName}`);
1228
+ $.chartId = n.widgetName, $.options = {
1226
1229
  options: {
1227
1230
  legend: d.value,
1228
1231
  tooltip: u.value,
1229
1232
  label: c.value
1230
1233
  },
1231
1234
  seriesOptions: c.value
1232
- }, window.dispatchEvent(_);
1235
+ }, window.dispatchEvent($);
1233
1236
  };
1234
1237
  ae(c, y, { deep: !0 }), ae(d, y, { deep: !0 }), ae(u, y, { deep: !0 });
1235
1238
  const m = async () => {
@@ -1241,15 +1244,15 @@ const uo = /* @__PURE__ */ H(wr, [["render", $r]]), _r = {
1241
1244
  label: c.value
1242
1245
  }
1243
1246
  });
1244
- const _ = new CustomEvent(`update-style-${n.widgetName}`);
1245
- _.chartId = n.widgetName, _.options = {
1247
+ const $ = new CustomEvent(`update-style-${n.widgetName}`);
1248
+ $.chartId = n.widgetName, $.options = {
1246
1249
  options: {
1247
1250
  legend: d.value,
1248
1251
  tooltip: u.value,
1249
1252
  label: c.value
1250
1253
  },
1251
1254
  seriesOptions: c.value
1252
- }, window.dispatchEvent(_), r({
1255
+ }, window.dispatchEvent($), r({
1253
1256
  type: "success",
1254
1257
  title: "Успішно!",
1255
1258
  message: "Дані успішно оновлено"
@@ -1263,25 +1266,25 @@ const uo = /* @__PURE__ */ H(wr, [["render", $r]]), _r = {
1263
1266
  }
1264
1267
  };
1265
1268
  return ie(() => {
1266
- const _ = new URLSearchParams(window.top.location.search);
1267
- i.value = _.get("dashboard");
1268
- }), e({ requestUpdateWidget: m }), (_, T) => (f(), w("div", Rr, [
1269
+ const $ = new URLSearchParams(window.top.location.search);
1270
+ i.value = $.get("dashboard");
1271
+ }), e({ requestUpdateWidget: m }), ($, T) => (f(), w("div", Rr, [
1269
1272
  z(L(t), {
1270
1273
  schema: a,
1271
1274
  values: c.value,
1272
- "onUpdate:values": T[0] || (T[0] = ($) => c.value = $),
1275
+ "onUpdate:values": T[0] || (T[0] = (_) => c.value = _),
1273
1276
  class: "p-0"
1274
1277
  }, null, 8, ["values"]),
1275
1278
  z(L(t), {
1276
1279
  schema: o,
1277
1280
  values: d.value,
1278
- "onUpdate:values": T[1] || (T[1] = ($) => d.value = $),
1281
+ "onUpdate:values": T[1] || (T[1] = (_) => d.value = _),
1279
1282
  class: "p-0"
1280
1283
  }, null, 8, ["values"]),
1281
1284
  z(L(t), {
1282
1285
  schema: l,
1283
1286
  values: u.value,
1284
- "onUpdate:values": T[2] || (T[2] = ($) => u.value = $),
1287
+ "onUpdate:values": T[2] || (T[2] = (_) => u.value = _),
1285
1288
  class: "p-0"
1286
1289
  }, null, 8, ["values"])
1287
1290
  ]));
@@ -1566,24 +1569,24 @@ ${u}` : u;
1566
1569
  `, 1)[0], m = !u.trim(), h = 0;
1567
1570
  if (this.options.pedantic ? (h = 2, d = u.trimStart()) : m ? h = t[1].length + 1 : (h = t[2].search(/[^ ]/), h = h > 4 ? 1 : h, d = u.slice(h), h += t[1].length), m && /^[ \t]*$/.test(y) && (c += y + `
1568
1571
  `, e = e.substring(y.length + 1), l = !0), !l) {
1569
- const g = new RegExp(`^ {0,${Math.min(3, h - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), b = new RegExp(`^ {0,${Math.min(3, h - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), x = new RegExp(`^ {0,${Math.min(3, h - 1)}}(?:\`\`\`|~~~)`), _ = new RegExp(`^ {0,${Math.min(3, h - 1)}}#`), T = new RegExp(`^ {0,${Math.min(3, h - 1)}}<(?:[a-z].*>|!--)`, "i");
1572
+ const g = new RegExp(`^ {0,${Math.min(3, h - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), b = new RegExp(`^ {0,${Math.min(3, h - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), x = new RegExp(`^ {0,${Math.min(3, h - 1)}}(?:\`\`\`|~~~)`), $ = new RegExp(`^ {0,${Math.min(3, h - 1)}}#`), T = new RegExp(`^ {0,${Math.min(3, h - 1)}}<(?:[a-z].*>|!--)`, "i");
1570
1573
  for (; e; ) {
1571
- const $ = e.split(`
1574
+ const _ = e.split(`
1572
1575
  `, 1)[0];
1573
1576
  let O;
1574
- if (y = $, this.options.pedantic ? (y = y.replace(/^ {1,4}(?=( {4})*[^ ])/g, " "), O = y) : O = y.replace(/\t/g, " "), x.test(y) || _.test(y) || T.test(y) || g.test(y) || b.test(y))
1577
+ if (y = _, this.options.pedantic ? (y = y.replace(/^ {1,4}(?=( {4})*[^ ])/g, " "), O = y) : O = y.replace(/\t/g, " "), x.test(y) || $.test(y) || T.test(y) || g.test(y) || b.test(y))
1575
1578
  break;
1576
1579
  if (O.search(/[^ ]/) >= h || !y.trim())
1577
1580
  d += `
1578
1581
  ` + O.slice(h);
1579
1582
  else {
1580
- if (m || u.replace(/\t/g, " ").search(/[^ ]/) >= 4 || x.test(u) || _.test(u) || b.test(u))
1583
+ if (m || u.replace(/\t/g, " ").search(/[^ ]/) >= 4 || x.test(u) || $.test(u) || b.test(u))
1581
1584
  break;
1582
1585
  d += `
1583
1586
  ` + y;
1584
1587
  }
1585
- !m && !y.trim() && (m = !0), c += $ + `
1586
- `, e = e.substring($.length + 1), u = O.slice(h);
1588
+ !m && !y.trim() && (m = !0), c += _ + `
1589
+ `, e = e.substring(_.length + 1), u = O.slice(h);
1587
1590
  }
1588
1591
  }
1589
1592
  i.loose || (o ? i.loose = !0 : /\n[ \t]*\n[ \t]*$/.test(c) && (o = !0));
@@ -2776,7 +2779,7 @@ const gn = { class: "space-y-4" }, mn = {
2776
2779
  },
2777
2780
  emits: ["update-dashboard"],
2778
2781
  setup(s, { expose: e, emit: t }) {
2779
- var _, T, $, O, M, Z, se, re, D, ne, de, ce, we, ve, ke, q, ue, $e, lt, ct, dt, ut, pt, ht, ft, gt, mt, bt, xt, yt, wt, vt;
2782
+ var $, T, _, O, M, Z, se, re, D, ne, de, ce, we, ve, ke, q, ue, $e, lt, ct, dt, ut, pt, ht, ft, gt, mt, bt, xt, yt, wt, vt;
2780
2783
  const r = A(() => import("@opengis/form")), { $notify: n } = me().proxy, i = t, a = s, o = S(null), l = S([]), c = F(() => {
2781
2784
  const C = a.columns ?? [];
2782
2785
  return C.length ? C : l.value;
@@ -2898,7 +2901,7 @@ const gn = { class: "space-y-4" }, mn = {
2898
2901
  hidden: !0
2899
2902
  }
2900
2903
  })), g = S({
2901
- x: ((T = (_ = a.data) == null ? void 0 : _.data) == null ? void 0 : T.x) || (($ = a.data) == null ? void 0 : $.x) || null,
2904
+ x: ((T = ($ = a.data) == null ? void 0 : $.data) == null ? void 0 : T.x) || ((_ = a.data) == null ? void 0 : _.x) || null,
2902
2905
  metric: ((M = (O = a.data) == null ? void 0 : O.data) == null ? void 0 : M.metric) || ((Z = a.data) == null ? void 0 : Z.metric) || null,
2903
2906
  columns: ((re = (se = a.data) == null ? void 0 : se.data) == null ? void 0 : re.columns) || ((D = a.data) == null ? void 0 : D.columns) || null,
2904
2907
  granularity: ((de = (ne = a.data) == null ? void 0 : ne.data) == null ? void 0 : de.granularity) || ((ce = a.data) == null ? void 0 : ce.granularity) || null,
@@ -2978,9 +2981,9 @@ const gn = { class: "space-y-4" }, mn = {
2978
2981
  const t = typeof window < "u" ? window.echarts : null, r = A(
2979
2982
  () => import("@opengis/form").then((u) => u.VsInputMonaco)
2980
2983
  ), n = S(null), { $notify: i } = me().proxy, a = s, o = (u, { dimensions: y, source: m }) => {
2981
- const h = u.getOption(), { data: v, ...k } = (h == null ? void 0 : h.series)[0], [, ...g] = y || [], b = g.map((x, _) => ({
2982
- ...(h == null ? void 0 : h.series[_]) || {},
2983
- data: m.map((T) => T[_ + 1]),
2984
+ const h = u.getOption(), { data: v, ...k } = (h == null ? void 0 : h.series)[0], [, ...g] = y || [], b = g.map((x, $) => ({
2985
+ ...(h == null ? void 0 : h.series[$]) || {},
2986
+ data: m.map((T) => T[$ + 1]),
2984
2987
  name: x
2985
2988
  }));
2986
2989
  u == null || u.setOption(
@@ -3175,8 +3178,8 @@ const gn = { class: "space-y-4" }, mn = {
3175
3178
  }),
3176
3179
  emits: /* @__PURE__ */ Pe(["update-data"], ["update:selectedWidget"]),
3177
3180
  setup(s, { emit: e }) {
3178
- var x, _;
3179
- const t = A(() => import("@opengis/form")), r = (_ = (x = me()) == null ? void 0 : x.proxy) == null ? void 0 : _.$notify, n = e, i = S(null), a = s, o = S(!1), l = S(!0), c = S(!1), d = S({}), u = At(s, "selectedWidget"), y = [
3181
+ var x, $;
3182
+ const t = A(() => import("@opengis/form")), r = ($ = (x = me()) == null ? void 0 : x.proxy) == null ? void 0 : $.$notify, n = e, i = S(null), a = s, o = S(!1), l = S(!0), c = S(!1), d = S({}), u = At(s, "selectedWidget"), y = [
3180
3183
  "table",
3181
3184
  "text",
3182
3185
  "number",
@@ -3210,17 +3213,17 @@ const gn = { class: "space-y-4" }, mn = {
3210
3213
  { id: "yaml", label: "{ }" }
3211
3214
  // { id: 'controls', label: 'Контролси' },
3212
3215
  ];
3213
- return T == null ? void 0 : T.filter(($) => {
3216
+ return T == null ? void 0 : T.filter((_) => {
3214
3217
  var O, M, Z;
3215
- return $.id === "style" ? !(y != null && y.includes(
3218
+ return _.id === "style" ? !(y != null && y.includes(
3216
3219
  ((O = a.selectedWidgetData) == null ? void 0 : O.type) || ((Z = (M = a.selectedWidgetData) == null ? void 0 : M.data) == null ? void 0 : Z.type)
3217
3220
  )) : !0;
3218
3221
  });
3219
3222
  }), k = () => {
3220
- var T, $, O, M, Z, se, re, D, ne;
3223
+ var T, _, O, M, Z, se, re, D, ne;
3221
3224
  d.value = {
3222
3225
  title: (T = a.selectedWidgetData) == null ? void 0 : T.title,
3223
- type: ($ = a.selectedWidgetData) == null ? void 0 : $.type,
3226
+ type: (_ = a.selectedWidgetData) == null ? void 0 : _.type,
3224
3227
  table: (O = a.selectedWidgetData) == null ? void 0 : O.table_name,
3225
3228
  query: (Z = (M = a.selectedWidgetData) == null ? void 0 : M.data) == null ? void 0 : Z.query,
3226
3229
  x: (re = (se = a.selectedWidgetData) == null ? void 0 : se.data) == null ? void 0 : re.x,
@@ -3246,8 +3249,8 @@ const gn = { class: "space-y-4" }, mn = {
3246
3249
  };
3247
3250
  ae(u, (T) => {
3248
3251
  l.value = !1;
3249
- const $ = new URL(window.top.location.href);
3250
- T ? ($.searchParams.set("widget", T), window.top.history.pushState({}, "", $)) : ($.searchParams.delete("widget"), window.top.history.pushState({}, "", $)), setTimeout(() => l.value = !0);
3252
+ const _ = new URL(window.top.location.href);
3253
+ T ? (_.searchParams.set("widget", T), window.top.history.pushState({}, "", _)) : (_.searchParams.delete("widget"), window.top.history.pushState({}, "", _)), setTimeout(() => l.value = !0);
3251
3254
  });
3252
3255
  const b = {
3253
3256
  title: {
@@ -3339,7 +3342,7 @@ const gn = { class: "space-y-4" }, mn = {
3339
3342
  placeholder: "Cls"
3340
3343
  }
3341
3344
  };
3342
- return (T, $) => {
3345
+ return (T, _) => {
3343
3346
  var M, Z, se, re, D, ne, de, ce, we, ve, ke;
3344
3347
  const O = K("VsPopover");
3345
3348
  return f(), w(B, null, [
@@ -3367,7 +3370,7 @@ const gn = { class: "space-y-4" }, mn = {
3367
3370
  type: "button",
3368
3371
  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",
3369
3372
  title: "Зберегти",
3370
- onClick: $[0] || ($[0] = (q) => {
3373
+ onClick: _[0] || (_[0] = (q) => {
3371
3374
  var ue, $e;
3372
3375
  return ($e = (ue = i.value) == null ? void 0 : ue.save) == null ? void 0 : $e.call(ue);
3373
3376
  })
@@ -3376,7 +3379,7 @@ const gn = { class: "space-y-4" }, mn = {
3376
3379
  ])
3377
3380
  ]),
3378
3381
  default: R(() => [
3379
- $[9] || ($[9] = Y(" Зберегти "))
3382
+ _[9] || (_[9] = Y(" Зберегти "))
3380
3383
  ]),
3381
3384
  _: 1
3382
3385
  }),
@@ -3394,7 +3397,7 @@ const gn = { class: "space-y-4" }, mn = {
3394
3397
  ])
3395
3398
  ]),
3396
3399
  default: R(() => [
3397
- $[10] || ($[10] = Y(" Редагувати віджет "))
3400
+ _[10] || (_[10] = Y(" Редагувати віджет "))
3398
3401
  ]),
3399
3402
  _: 1
3400
3403
  }),
@@ -3406,13 +3409,13 @@ const gn = { class: "space-y-4" }, mn = {
3406
3409
  p("button", {
3407
3410
  type: "button",
3408
3411
  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",
3409
- onClick: $[1] || ($[1] = (q) => o.value = !0)
3412
+ onClick: _[1] || (_[1] = (q) => o.value = !0)
3410
3413
  }, [
3411
3414
  z(L(Gt), { class: "h-4 w-4" })
3412
3415
  ])
3413
3416
  ]),
3414
3417
  default: R(() => [
3415
- $[11] || ($[11] = Y(" Видалити віджет "))
3418
+ _[11] || (_[11] = Y(" Видалити віджет "))
3416
3419
  ]),
3417
3420
  _: 1
3418
3421
  })
@@ -3435,7 +3438,7 @@ const gn = { class: "space-y-4" }, mn = {
3435
3438
  data: s.selectedWidgetData,
3436
3439
  controls: (ne = s.selectedWidgetData) == null ? void 0 : ne.controls,
3437
3440
  columns: (de = s.currentWidgetData) == null ? void 0 : de.columns,
3438
- onUpdateDashboard: $[2] || ($[2] = (q) => T.$emit("update-data"))
3441
+ onUpdateDashboard: _[2] || (_[2] = (q) => T.$emit("update-data"))
3439
3442
  }, null, 8, ["tab-key", "tab-component", "widgetName", "dashboardId", "yamlValue", "data", "controls", "columns"])
3440
3443
  ])) : (f(), w("div", Ln, [
3441
3444
  z(Nt, {
@@ -3449,23 +3452,23 @@ const gn = { class: "space-y-4" }, mn = {
3449
3452
  data: s.selectedWidgetData,
3450
3453
  controls: (ve = s.selectedWidgetData) == null ? void 0 : ve.controls,
3451
3454
  columns: (ke = s.currentWidgetData) == null ? void 0 : ke.columns,
3452
- onUpdateDashboard: $[3] || ($[3] = (q) => T.$emit("update-data"))
3455
+ onUpdateDashboard: _[3] || (_[3] = (q) => T.$emit("update-data"))
3453
3456
  }, null, 8, ["tab-key", "tab-component", "widgetName", "dashboardId", "yamlValue", "data", "controls", "columns"])
3454
3457
  ])),
3455
3458
  z(Te, {
3456
3459
  teleport: "#modal",
3457
3460
  visible: o.value,
3458
3461
  title: "Ви впевнені?",
3459
- onClose: $[5] || ($[5] = (q) => o.value = !1)
3462
+ onClose: _[5] || (_[5] = (q) => o.value = !1)
3460
3463
  }, {
3461
3464
  default: R(() => [
3462
3465
  p("div", Vn, [
3463
- $[12] || ($[12] = p("p", { class: "mt-1 text-gray-500 dark:text-neutral-500" }, " Ви впевнені, що хочете видалити цей віджет? ", -1)),
3466
+ _[12] || (_[12] = p("p", { class: "mt-1 text-gray-500 dark:text-neutral-500" }, " Ви впевнені, що хочете видалити цей віджет? ", -1)),
3464
3467
  p("div", Rn, [
3465
3468
  p("button", {
3466
3469
  type: "button",
3467
3470
  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",
3468
- onClick: $[4] || ($[4] = (q) => o.value = !1)
3471
+ onClick: _[4] || (_[4] = (q) => o.value = !1)
3469
3472
  }, " Скасувати "),
3470
3473
  p("button", {
3471
3474
  type: "button",
@@ -3489,13 +3492,13 @@ const gn = { class: "space-y-4" }, mn = {
3489
3492
  teleport: "#modal",
3490
3493
  visible: c.value,
3491
3494
  title: "Редагувати віджет",
3492
- onClose: $[8] || ($[8] = (q) => c.value = !1)
3495
+ onClose: _[8] || (_[8] = (q) => c.value = !1)
3493
3496
  }, {
3494
3497
  footer: R(() => [
3495
3498
  p("div", Wn, [
3496
3499
  p("button", {
3497
3500
  style: { border: "1px solid #000" },
3498
- onClick: $[7] || ($[7] = (q) => c.value = !1),
3501
+ onClick: _[7] || (_[7] = (q) => c.value = !1),
3499
3502
  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"
3500
3503
  }, " Скасувати "),
3501
3504
  p("button", {
@@ -3509,7 +3512,7 @@ const gn = { class: "space-y-4" }, mn = {
3509
3512
  key: 0,
3510
3513
  schema: b,
3511
3514
  values: d.value,
3512
- "onUpdate:values": $[6] || ($[6] = (q) => d.value = q)
3515
+ "onUpdate:values": _[6] || (_[6] = (q) => d.value = q)
3513
3516
  }, null, 8, ["values"])) : E("", !0)
3514
3517
  ]),
3515
3518
  _: 1
@@ -3957,9 +3960,9 @@ const ea = /* @__PURE__ */ H(Un, [["render", Jn]]), ta = { class: "flex-1 min-w-
3957
3960
  n(), r("back");
3958
3961
  } } : { label: "Дашборди", to: "/editor" }];
3959
3962
  if ((v = o.value) != null && v.title || i.value) {
3960
- const _ = ((k = o.value) == null ? void 0 : k.title) || i.value || "Редактор", T = !!a.value;
3963
+ const $ = ((k = o.value) == null ? void 0 : k.title) || i.value || "Редактор", T = !!a.value;
3961
3964
  h.push({
3962
- label: _,
3965
+ label: $,
3963
3966
  ...T ? { onClick: () => {
3964
3967
  a.value = "";
3965
3968
  } } : {}
@@ -3967,8 +3970,8 @@ const ea = /* @__PURE__ */ H(Un, [["render", Jn]]), ta = { class: "flex-1 min-w-
3967
3970
  } else
3968
3971
  h.push({ label: "Редактор" });
3969
3972
  if (a.value && u.value) {
3970
- const _ = ((b = (g = u.value) == null ? void 0 : g.data) == null ? void 0 : b.title) || ((x = u.value) == null ? void 0 : x.title) || a.value;
3971
- h.push({ label: _ });
3973
+ const $ = ((b = (g = u.value) == null ? void 0 : g.data) == null ? void 0 : b.title) || ((x = u.value) == null ? void 0 : x.title) || a.value;
3974
+ h.push({ label: $ });
3972
3975
  }
3973
3976
  return h;
3974
3977
  });
@@ -4064,21 +4067,21 @@ const ea = /* @__PURE__ */ H(Un, [["render", Jn]]), ta = { class: "flex-1 min-w-
4064
4067
  key: b,
4065
4068
  class: Q([`col-span-${g.col || 12}`, "flex flex-col gap-[10px]"])
4066
4069
  }, [
4067
- (x = g.widgets) != null && x.length ? (f(!0), w(B, { key: 0 }, U(g.widgets, (_) => (f(), W(Ne, {
4068
- onClick: (T) => a.value = _,
4070
+ (x = g.widgets) != null && x.length ? (f(!0), w(B, { key: 0 }, U(g.widgets, ($) => (f(), W(Ne, {
4071
+ onClick: (T) => a.value = $,
4069
4072
  "onUpdate:currentWidgetData": h[4] || (h[4] = (T) => l.value = T),
4070
- key: _,
4073
+ key: $,
4071
4074
  dashboard: i.value,
4072
- widget: _,
4075
+ widget: $,
4073
4076
  selectedWidget: a.value,
4074
4077
  "dashboard-widgets": o.value.widgets,
4075
4078
  class: Q({
4076
- "border border-blue-500": a.value === _
4079
+ "border border-blue-500": a.value === $
4077
4080
  })
4078
4081
  }, null, 8, ["onClick", "dashboard", "widget", "selectedWidget", "dashboard-widgets", "class"]))), 128)) : (f(), W(Ne, {
4079
4082
  key: 1,
4080
- onClick: (_) => a.value = g.widget,
4081
- "onUpdate:currentWidgetData": h[5] || (h[5] = (_) => l.value = _),
4083
+ onClick: ($) => a.value = g.widget,
4084
+ "onUpdate:currentWidgetData": h[5] || (h[5] = ($) => l.value = $),
4082
4085
  class: Q(["flex flex-col", {
4083
4086
  "border border-blue-500": a.value === g.widget
4084
4087
  }]),
@@ -4199,7 +4202,6 @@ const za = { class: "flex-1 bg-gray-50" }, Sa = { class: "max-w-7xl mx-auto px-6
4199
4202
  const e = A(() => import("@opengis/form")), t = Ca(Da), r = S([]), n = S([]);
4200
4203
  Je();
4201
4204
  const i = qe("biSetDashboard"), a = s, o = S(null), l = S(!1), c = S({});
4202
- Me(a.prefix || "/api");
4203
4205
  async function d() {
4204
4206
  try {
4205
4207
  const k = await G.get("/bi-dashboard?type=db"), g = Array.isArray(k == null ? void 0 : k.rows) ? k.rows : [];
@@ -4218,7 +4220,8 @@ const za = { class: "flex-1 bg-gray-50" }, Sa = { class: "max-w-7xl mx-auto px-6
4218
4220
  var g, b, x;
4219
4221
  const k = (b = (g = me()) == null ? void 0 : g.proxy) == null ? void 0 : b.$notify;
4220
4222
  try {
4221
- await ((x = o.value) == null ? void 0 : x.doValidation()), await G.post("/bi-dashboard", c.value), l.value = !1, c.value = {}, k == null || k({
4223
+ const $ = (x = o.value) == null ? void 0 : x.doValidation;
4224
+ typeof $ == "function" && await $(), await G.post("/bi-dashboard", c.value), l.value = !1, c.value = {}, k == null || k({
4222
4225
  type: "success",
4223
4226
  title: "Успішно!",
4224
4227
  message: "Дашборд створено успішно"
@@ -4231,7 +4234,9 @@ const za = { class: "flex-1 bg-gray-50" }, Sa = { class: "max-w-7xl mx-auto px-6
4231
4234
  });
4232
4235
  }
4233
4236
  }
4234
- ie(d);
4237
+ ie(() => {
4238
+ Me(a.prefix || "/api"), d();
4239
+ });
4235
4240
  const y = S(1), m = () => {
4236
4241
  const k = window.innerWidth;
4237
4242
  y.value = k >= 1024 ? 3 : k >= 768 ? 2 : 1;
@@ -4242,13 +4247,13 @@ const za = { class: "flex-1 bg-gray-50" }, Sa = { class: "max-w-7xl mx-auto px-6
4242
4247
  window.removeEventListener("resize", m);
4243
4248
  });
4244
4249
  const h = (k) => k ? k.trim().length > 70 ? 2 : 1 : 0, v = (k) => {
4245
- const g = y.value || 1, x = Math.floor(k / g) * g, _ = x + g, T = r.value.slice(x, _);
4246
- let $ = 0;
4250
+ const g = y.value || 1, x = Math.floor(k / g) * g, $ = x + g, T = r.value.slice(x, $);
4251
+ let _ = 0;
4247
4252
  for (const O of T) {
4248
4253
  const M = h(O.description ?? null);
4249
- if (M > $ && ($ = M), $ === 2) break;
4254
+ if (M > _ && (_ = M), _ === 2) break;
4250
4255
  }
4251
- return $;
4256
+ return _;
4252
4257
  };
4253
4258
  return S("grid"), (k, g) => (f(), w("div", za, [
4254
4259
  p("div", Sa, [
@@ -1,4 +1,4 @@
1
- import { _ as c, c as l, a as o, b as h, d } from "./import-file-Cy2Zpvpw.js";
1
+ import { _ as c, c as l, a as o, b as h, d } from "./import-file-DN4Z6TNG.js";
2
2
  import { createElementBlock as u, openBlock as p } from "vue";
3
3
  const i = typeof window < "u" ? window.echarts : null, m = {
4
4
  name: "VsFunnelBar",
@@ -1,5 +1,5 @@
1
1
  import { createBlock as b, openBlock as l, unref as L, mergeProps as v, createElementBlock as d, createElementVNode as c, withDirectives as F, toDisplayString as S, vShow as R, Fragment as P, renderList as V, normalizeClass as D, resolveComponent as A, createVNode as H } from "vue";
2
- import { e as x, X as J, _ as w } from "./import-file-Cy2Zpvpw.js";
2
+ import { e as x, X as J, _ as w } from "./import-file-DN4Z6TNG.js";
3
3
  /**
4
4
  * @license lucide-vue-next v0.546.0 - ISC
5
5
  *
@@ -1,5 +1,5 @@
1
- import { _ as E, a as L, p as $, V as T, b as B, c as H, d as O, l as F, e as N } from "./vs-list-D2YSJTpd.js";
2
- import { _ as V, c as P } from "./import-file-Cy2Zpvpw.js";
1
+ import { _ as E, a as L, p as $, V as T, b as B, c as H, d as O, l as F, e as N } from "./vs-list-CNxUwLZd.js";
2
+ import { _ as V, c as P } from "./import-file-DN4Z6TNG.js";
3
3
  import { resolveComponent as u, createElementBlock as c, openBlock as i, Fragment as w, createElementVNode as r, createBlock as C, createCommentVNode as m, createVNode as x, Teleport as R, toDisplayString as g, renderList as S, normalizeStyle as k, normalizeClass as I } from "vue";
4
4
  const A = {
5
5
  components: { legendIcon: L, closeIcon: E },
@@ -1,5 +1,5 @@
1
- import { _ as A, a as F, p as T, c as G, V as P, b as Z, d as q, e as D, l as K } from "./vs-list-D2YSJTpd.js";
2
- import { e as W, _ as H, V as J, c as Q, g as U, h as X, i as Y } from "./import-file-Cy2Zpvpw.js";
1
+ import { _ as A, a as F, p as T, c as G, V as P, b as Z, d as q, e as D, l as K } from "./vs-list-CNxUwLZd.js";
2
+ import { e as W, _ as H, V as J, c as Q, g as U, h as X, i as Y } from "./import-file-DN4Z6TNG.js";
3
3
  import { createElementBlock as g, createCommentVNode as S, openBlock as p, createElementVNode as l, normalizeClass as V, Fragment as R, renderList as N, toDisplayString as O, normalizeStyle as j, createBlock as z, unref as $, mergeProps as ee, resolveComponent as m, withDirectives as M, resolveDynamicComponent as te, createVNode as w, vShow as C } from "vue";
4
4
  /**
5
5
  * @license lucide-vue-next v0.546.0 - ISC
@@ -1,4 +1,4 @@
1
- import { _ as c, c as o, f as n } from "./import-file-Cy2Zpvpw.js";
1
+ import { _ as c, c as o, f as n } from "./import-file-DN4Z6TNG.js";
2
2
  import { createElementBlock as i, openBlock as m, toDisplayString as s } from "vue";
3
3
  const u = {
4
4
  name: "VsNumber",
@@ -1,4 +1,4 @@
1
- import { _ as m, c as f, b as _, d as b } from "./import-file-Cy2Zpvpw.js";
1
+ import { _ as m, c as f, b as _, d as b } from "./import-file-DN4Z6TNG.js";
2
2
  import { createElementBlock as a, openBlock as r, createElementVNode as s, Fragment as n, renderList as c, toDisplayString as d } from "vue";
3
3
  const x = {
4
4
  name: "VsTable",
@@ -1,4 +1,4 @@
1
- import { _ as o, c as s, m as i } from "./import-file-Cy2Zpvpw.js";
1
+ import { _ as o, c as s, m as i } from "./import-file-DN4Z6TNG.js";
2
2
  import { createElementBlock as r, openBlock as n, createCommentVNode as a } from "vue";
3
3
  const c = {
4
4
  name: "VsText",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/bi",
3
- "version": "1.2.22",
3
+ "version": "1.2.23",
4
4
  "description": "BI data visualization module",
5
5
  "main": "dist/bi.js",
6
6
  "browser": "dist/bi.umd.cjs",