import{r as e}from"./rolldown-runtime-BM3Ffeng.js";import{a as t}from"./element-plus-vendor-BF9PNysW.js";import{A as n,D as r,E as i,I as a,N as o,O as s,P as c,Pt as l,Tt as u,Xt as d,Yt as f,et as p,gt as m,ht as h,it as g,k as _,nt as v,ot as y,qt as b,x}from"./vue-vendor-DMUmTARL.js";import{Xr as S}from"./icons-vendor-Db5MGAkr.js";import{t as C}from"./formatNumber-CSIIcI3k.js";var w={class:`flex h-full flex-col`},T={class:`mb-3 flex items-center justify-between border-b border-zinc-100 dark:border-zinc-800`},E={class:`flex items-center gap-4`},D=[`onClick`],O={class:`min-h-[12rem] flex-1 space-y-3`},k={class:`min-w-0 flex-1`},A=[`title`],j={class:`mt-1.5 h-1 overflow-hidden rounded-full bg-zinc-100 dark:bg-zinc-800`},M={class:`shrink-0 text-xs tabular-nums text-zinc-400`},N={key:0,class:`py-8 text-center text-xs text-zinc-400`},P={key:0,class:`mt-3 flex cursor-not-allowed items-center justify-center gap-1 border-t border-zinc-100 pt-3 text-xs font-medium text-zinc-400 dark:border-zinc-800 dark:text-zinc-600`,title:`授权后可查看完整排行`},F=7,I=a({__name:`TopRankingPanel`,props:{topData:{},storageData:{},topLoading:{type:Boolean},storageLoading:{type:Boolean},locked:{type:Boolean}},emits:[`change-type`,`change-storage`],setup(e,{emit:a}){let I=e,L=a,R=[{label:`文件`,value:`file`},{label:`IP`,value:`ip`},{label:`来源`,value:`referer`},{label:`存储源`,value:`storage`}],z=u(`file`),B=i(()=>R.find(e=>e.value===z.value)?.label??``),V=e=>{z.value!==e&&(z.value=e,e===`storage`?L(`change-storage`):L(`change-type`,e))},H=i(()=>z.value===`storage`?I.storageLoading:I.topLoading),U=i(()=>z.value===`storage`?I.storageData.slice(0,F).map(e=>W(e)):I.topData.slice(0,F).map(e=>G(e))),W=e=>({label:e.storageName||e.storageKey,count:e.count,href:`/admin/download-link/log?storageKey=${encodeURIComponent(e.storageKey)}`}),G=e=>{if(z.value===`ip`){let t=e.ip;return{label:t,count:e.count,href:K(`ip`,t)}}if(z.value===`referer`){let t=e.referer;return{label:t||`直接访问 / 空`,count:e.count,href:K(`referer`,t||``)}}let t=e;return{label:t.path,count:e.count,href:K(`path`,t.path)}},K=(e,t)=>`/admin/download-link/log?${e}=${encodeURIComponent(t)}`,q=i(()=>`/admin/download-link/top?dimension=${z.value}`),J=e=>{let t=Math.max(...U.value.map(e=>e.count),0);return t>0?Math.round(e/t*100):0};return(i,a)=>{let u=S,F=g(`router-link`),I=t;return p(),n(`div`,w,[r(`div`,T,[r(`div`,E,[(p(),n(x,null,v(R,e=>r(`button`,{key:e.value,type:`button`,class:b([`relative -mb-px border-b-2 pb-2 text-xs transition`,z.value===e.value?`border-blue-500 font-medium text-zinc-900 dark:text-zinc-100`:`border-transparent text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300`]),onClick:t=>V(e.value)},d(e.label),11,D)),64))]),a[0]||=r(`span`,{class:`pb-2 text-[10px] uppercase tracking-wider text-zinc-400`},`汇总`,-1)]),m((p(),n(`ul`,O,[(p(!0),n(x,null,v(U.value,(t,i)=>(p(),n(`li`,{key:`${z.value}-${t.label}-${i}`},[(p(),s(y(e.locked?`div`:`router-link`),{to:e.locked?void 0:t.href,class:b([`group flex items-center gap-3`,e.locked?`cursor-default`:``])},{default:h(()=>[r(`span`,{class:b([`w-3 shrink-0 text-xs font-semibold tabular-nums`,i<3?`text-blue-500`:`text-zinc-300 dark:text-zinc-600`])},d(i+1),3),r(`div`,k,[r(`div`,{class:`truncate text-xs text-zinc-600 transition-colors group-hover:text-blue-600 dark:text-zinc-300 dark:group-hover:text-blue-400`,title:t.label},d(t.label),9,A),r(`div`,j,[r(`div`,{class:`h-full rounded-full bg-blue-500/50`,style:f({width:`${J(t.count)}%`})},null,4)])]),r(`span`,M,d(l(C)(t.count)),1)]),_:2},1032,[`to`,`class`]))]))),128)),!H.value&&!U.value.length?(p(),n(`li`,N,` 暂无`+d(B.value)+`数据 `,1)):_(``,!0)])),[[I,H.value]]),e.locked?(p(),n(`span`,P,[c(u,{class:`h-3 w-3`}),a[1]||=o(` 查看完整排行 `,-1)])):(p(),s(F,{key:1,to:q.value,class:`mt-3 flex items-center justify-center gap-1 border-t border-zinc-100 pt-3 text-xs font-medium text-blue-600 transition-colors hover:underline dark:border-zinc-800 dark:text-blue-400`},{default:h(()=>[...a[2]||=[o(` 查看完整排行 → `,-1)]]),_:1},8,[`to`]))])}}}),L=e({default:()=>R}),R=I;export{L as n,R as t};