import{d as j,w as D,I as K,o as s,c as n,F as h,r as y,n as E,t as l,b as u,a,g,f as L,u as N,j as B,M as F,E as W,i as d,h as T}from"./index-CXwCk-SR.js";import{f as I}from"./formatters-oGTqEJbH.js";import{_ as q}from"./_plugin-vue_export-helper-DlAUqK2U.js";const A={class:"top-list"},H={key:0,class:"tabs"},J=["title","onClick"],O={class:"rows"},P=["onMouseenter"],Q={class:"rank"},R={class:"name"},Z={class:"value"},ee={key:0,class:"unit"},te={key:0,class:"empty"},se={class:"tl-dialog"},ne={class:"tl-head"},ae={class:"tl-title"},oe={key:0,class:"tabs"},le=["title","onClick"],ie={class:"rows rows--big"},ue={class:"rank"},ce={class:"name name--wrap"},re={class:"value"},de={key:0,class:"unit"},ve={key:0,class:"empty"},pe=j({__name:"TopList",props:{items:{},groups:{},unit:{},color:{default:"var(--sw-accent)"},title:{}},setup(m,{expose:S}){const v=m,p=d(()=>v.groups&&v.groups.length>0?[...v.groups]:v.items?[{label:"",items:[...v.items]}]:[]),c=T(0);D(p,e=>{c.value>=e.length&&(c.value=0)});const C=d(()=>p.value[c.value]??null),_=d(()=>{var e;return((e=C.value)==null?void 0:e.items)??[]}),f=d(()=>{var e;return((e=C.value)==null?void 0:e.unit)??v.unit}),V=d(()=>{let e=0;for(const r of _.value){const t=r.value;t!==null&&Number.isFinite(t)&&t>e&&(e=t)}return e||1});function $(e){return e===null||!Number.isFinite(e)?0:Math.max(0,Math.min(100,e/V.value*100))}const M=d(()=>p.value.length>1),b=T(!1);function X(){b.value=!0,window.addEventListener("keydown",w)}function k(){b.value=!1,window.removeEventListener("keydown",w)}function w(e){e.key==="Escape"&&k()}K(()=>window.removeEventListener("keydown",w)),S({openExpanded:X});const i=T(null);function z(e,r){i.value={text:r,x:e.clientX,y:e.clientY}}function G(e){i.value&&(i.value={...i.value,x:e.clientX,y:e.clientY})}function U(){i.value=null}const Y=d(()=>{const e=i.value;if(!e)return{};const r=e.x>window.innerWidth*.6;return{left:`${e.x+(r?-12:12)}px`,top:`${e.y+14}px`,transform:r?"translateX(-100%)":"none"}});return(e,r)=>(s(),n("div",A,[M.value?(s(),n("div",H,[(s(!0),n(h,null,y(p.value,(t,o)=>(s(),n("button",{key:o,type:"button",class:E(["tab",{on:c.value===o}]),title:t.expression?`${t.label}

${t.expression}`:t.label,onClick:x=>c.value=o},l(t.label),11,J))),128))])):u("",!0),a("div",O,[(s(!0),n(h,null,y(_.value,(t,o)=>(s(),n("div",{key:o,class:"row",onMouseenter:x=>z(x,t.name),onMousemove:G,onMouseleave:U},[a("span",{class:"bar-bg",style:g({width:`${$(t.value)}%`,background:m.color})},null,4),a("span",Q,l(o+1),1),a("span",R,l(t.name),1),a("span",Z,[L(l(N(I)(t.value)),1),f.value?(s(),n("span",ee,l(f.value),1)):u("",!0)])],40,P))),128)),_.value.length===0?(s(),n("p",te,"No data")):u("",!0)]),(s(),B(F,{to:"body"},[i.value?(s(),n("div",{key:0,class:"top-tip",style:g(Y.value)},l(i.value.text),5)):u("",!0)])),(s(),B(F,{to:"body"},[b.value?(s(),n("div",{key:0,class:"tl-modal",onClick:W(k,["self"])},[a("div",se,[a("header",ne,[a("span",ae,l(m.title||"Top list"),1),a("button",{class:"tl-close","aria-label":"Close",onClick:k},"×")]),M.value?(s(),n("div",oe,[(s(!0),n(h,null,y(p.value,(t,o)=>(s(),n("button",{key:o,type:"button",class:E(["tab",{on:c.value===o}]),title:t.expression?`${t.label}

${t.expression}`:t.label,onClick:x=>c.value=o},l(t.label),11,le))),128))])):u("",!0),a("div",ie,[(s(!0),n(h,null,y(_.value,(t,o)=>(s(),n("div",{key:o,class:"row row--big"},[a("span",{class:"bar-bg",style:g({width:`${$(t.value)}%`,background:m.color})},null,4),a("span",ue,l(o+1),1),a("span",ce,l(t.name),1),a("span",re,[L(l(N(I)(t.value)),1),f.value?(s(),n("span",de,l(f.value),1)):u("",!0)])]))),128)),_.value.length===0?(s(),n("p",ve,"No data")):u("",!0)])])])):u("",!0)]))]))}}),he=q(pe,[["__scopeId","data-v-9541fa67"]]);export{he as T};
