import{o as r,L as l}from"./chunk-NL6KNZEE-DfxmOBHd.js";import{k as o}from"./useTheme-CRMMMnig.js";import{z as c}from"./api-BuTqLiNI.js";import{T as h}from"./TopItemList-BRD-rnKC.js";const p=e=>{const{isPending:a,isError:d,data:s,error:m}=o({queryKey:["top-tracks",{limit:e.limit,period:e.period,artist_id:e.artistId,album_id:e.albumId,page:0}],queryFn:({queryKey:n})=>c(n[1])}),i="Top tracks";if(a)return r.jsxs("div",{className:"w-[300px]",children:[r.jsx("h3",{children:i}),r.jsx("p",{children:"Loading..."})]});if(d)return r.jsxs("div",{className:"w-[300px]",children:[r.jsx("h3",{children:i}),r.jsxs("p",{className:"error",children:["Error: ",m.message]})]});if(!s.items)return;let t="";return t+=e.artistId?`&artist_id=${e.artistId}`:"",t+=e.albumId?`&album_id=${e.albumId}`:"",r.jsxs("div",{children:[r.jsx("h3",{className:"hover:underline",children:r.jsx(l,{to:`/chart/top-tracks?period=${e.period}${t}`,children:i})}),r.jsxs("div",{className:"max-w-[300px]",children:[r.jsx(h,{type:"track",data:s}),s.items.length<1?"Nothing to show":""]})]})};export{p as T};
