1import{T as e,Y as t,Z as n,o as r,t as i}from"./router-compat-CPlCWMke.js";import{t as a}from"./button-CHzfpxYo.js";import{t as o}from"./CharacterFilterBar-ggDLy76J.js";import{n as s,t as c}from"./chevron-right-Dws2QPH_.js";import{t as l}from"./client-49dRoOLC.js";import{C as u,T as d,n as f,r as p,t as m}from"./index-Db6hy7GP.js";import{t as h}from"./SEOHead-mv24pHcx.js";import{n as g,t as _}from"./featured-artists-BVukja7b.js";import{a as v,i as y,n as b,s as x}from"./browse-data-6AIdTMa7.js";import{n as S,r as C,t as w}from"./video-categories-BjzNHvid.js";import{n as T,r as ee,t as E}from"./useServerInfiniteScroll-QTYFGF7W.js";import{t as D}from"./group-key-DLNRIpqo.js";import{t as O}from"./GenreGroupView-Dc2MI1Is.js";import{t as k}from"./ArtistAvatar-TfqySC5-.js";import{t as A}from"./AlbumArt-FHInW87c.js";var j=n(t(),1),M=e(),te=60,N=20,P=20,F=e=>!e||e.length===0?5:Math.round(e.reduce((e,t)=>e+t.stars,0)/e.length);function I(){let{slug:e}=r(),[t,n]=(0,j.useState)([]),[a,s]=(0,j.useState)(0),[c,d]=(0,j.useState)(!0),[p,y]=(0,j.useState)(`artist`),[w,O]=(0,j.useState)(null),[k,A]=(0,j.use
1State)(!0),[I,L]=(0,j.useState)(new Map),[R,z]=(0,j.useState)(new Map),[B,V]=(0,j.useState)([]),[H,U]=(0,j.useState)(0),[W,G]=(0,j.useState)([]),[ne,K]=(0,j.useState)(0),[q,J]=(0,j.useState)(null),Y=u.find(t=>t.slug===e)?.label??e??``,X=p===`artist`,{page:Z,setPage:Q,sentinelRef:re,hasMore:ie}=E({totalCount:p===`artist`?H:p===`album`?ne:a,pageSize:p===`artist`?N:p===`album`?P:te,enabled:p===`artist`||p===`title`||p===`album`});(0,j.useEffect)(()=>{Q(1),n([]),V([]),G([]),J(null),O(null),A(!0),y(`artist`),d(!0)},[e,Q]),(0,j.useEffect)(()=>{e&&(async()=>{let{data:t}=await l.from(`video_categories`).select(`video_id`).eq(`category`,e).limit(5e4);J(t?.map(e=>e.video_id)??[])})()},[e]),(0,j.useEffect)(()=>{if(!X||q===null)return;let e=!1;return(async()=>{if(Z===1&&d(!0),q.length===0){V([]),U(0),n([]),d(!1);return}let{data:t}=await l.from(`videos`).select(`artist_id`).in(`id`,q.slice(0,5e3)),r=[...new Set((t??[]).map(e=>e.artist_id))],i=(Z-1)*N,a=i+N-1,o=l.from(`artists`).select(`id, name, slug`,{count:`exact`}).in(`id`,r).order(`name`,{ascending:k});w&&(o=o.ilike(`name`,`${w}%`)),o=o.range(i,a);let{data:s,count:c}=await o;if(!s||e)return;let u=c??0;if(s.length===0){Z===1&&(V([]),n([]),U(u),d(!1));return}let f=s.map(e=>e.id),[{data:p},m]=await Promise.all([l.from(`videos`).select(`*, artists(name, slug), albums(title, slug), public_ratings(stars)`).in(`artist_id`,f).in(`id`,q.slice(0,5e3)).order(`title`,{ascending:!0}).limit(5e3),v(f)]);if(e)return;let h=p??[],g=new Set(h.map(e=>e.id)),y=new Set(q),S=Array.from(new Set(Array.from(m.values()).flat().filter(e=>!g.has(e)&&y.has(e)))),C=S.length>0?await x(S):[];if(e)return;let T=b([...h,...C]),ee=new Map(T.map(e=>[e.id,e])),E=new Map;for(let e of h){let t=e.artist_id,n=E.get(t)??[];n.push(e),E.set(t,n)}for(let[e,t]of m.entries()){let n=E.get(e)??[];for(let e of t){if(!y.has(e))continue;let t=ee.get(e);t&&n.push(t)}E.set(e,b(n))}let D=s.map(e=>({artistName:e.name,artistSlug:e.slug,artistId:e.id,videos:b(E.get(e.id)??[])}));V(e=>Z===1?D:[...e,...D]),n(e=>Z===1?T:b([...e,...T])),U(u);let O=T.map(e=>e.id),A=await _(O);e||(L(e=>Z===1?A:new Map([...e,...A])),d(!1))})(),()=>{e=!0}},[Z,k,w,p,q]),(0,j.useEffect)(()=>{p===`title`&&q!==null&&(async()=>{if(!e)return;Z===1&&d(!0);let t=(Z-1)*te,r=t+te-1,i=l.from(`videos`).select(`*, artists(name, slug), albums(title, slug), public_ratings(stars)`,{count:`exact`}).in(`id`,q.slice(0,5e3)).order(`title`,{ascending:k});w&&(i=i.ilike(`title`,`${w}%`)),i=i.range(t,r);let{data:a,count:o}=await i;if(a){let e=a;n(t=>Z===1?e:[...t,...e]),s(o??0);let t=e.map(e=>e.id),[r,i]=await Promise.all([_(t),S(e)]);L(e=>Z===1?r:new Map([...e,...r])),z(e=>Z===1?i:C(Array.from(e.values()),i).reduce((e,t)=>(e.set(`${t.artistName}::${t.artistSlug}`,t),e),new Map)),d(!1)}})()},[Z,e,k,w,p,q]),(0,j.useEffect)(()=>{if(p!==`album`||q===null||q.length===0)return;let e=!1;return(async()=>{Z===1&&d(!0);let{data:t}=await l.from(`videos`).select(`album_id`).in(`id`,q.slice(0,5e3)).not(`album_id`,`is`,null),n=[...new Set((t??[]).filter(e=>e.album_id).map(e=>e.album_id))];if(n.length===0){Z===1&&(G([]),K(0),d(!1));return}let r=(Z-1)*P,i=r+P-1,a=l.from(`albums`).select(`id, title, slug, artist_id, artists(name, slug)`,{count:`exact`}).in(`id`,n).order(`title`,{ascending:k});w&&(a=a.ilike(`title`,`${w}%`)),a=a.range(r,i);let{data:o,count:s}=await a;if(!o||e)return;let c=s??0;if(o.length===0){Z===1&&(G([]),K(c),d(!1));return}let u=o.map(e=>e.id),{data:f}=await l.from(`videos`).select(`*, artists(name, slug), albums(title, slug), public_ratings(stars)`).in(`album_id`,u).in(`id`,q.slice(0,5e3)).order(`title`,{ascending:!0}).limit(5e3);if(e)return;let p=f??[],m=new Map;for(let e of p){let t=e.album_id,n=m.get(t)??[];n.push(e),m.set(t,n)}let h=o.map(e=>({albumTitle:e.title,albumSlug:e.slug,artistSlug:e.artists?.slug??``,videos:m.get(e.id)??[]}));G(e=>Z===1?h:[...e,...h]),K(c);let g=p.map(e=>e.id),v=await _(g);e||(L(e=>Z===1?v:new Map([...e,...v])),d(!1))})(),()=>{e=!0}},[Z,k,w,p,q]);let ae=(0,j.useMemo)(()=>{if(!X)return[];let e=B.map(e=>({artistName:e.artistName,artistSlug:e.artistSlug,videos:e.videos}));return C(e,R)},[B,R,X]),oe=k?1:-1,$=(0,j.useMemo)(()=>
1{if(p!==`title`)return[];let e=new Map;return[...t].sort((e,t)=>e.title.localeCompare(t.title)*oe).forEach(t=>{let n=D(t.title);e.has(n)||e.set(n,[]),e.get(n)?.push(t)}),Array.from(e.entries()).sort(([e],[t])=>e.localeCompare(t)*oe).map(([e,t])=>({letter:e,videos:t}))},[t,oe,p]),se=p===`artist`?`${Y.toLowerCase()} artist names`:p===`album`?`${Y.toLowerCase()} album titles`:`${Y.toLowerCase()} song titles`,ce=e=>{y(e),O(null),A(!0),Q(1),n([]),V([]),G([]),K(0),d(!0),window.scrollTo({top:0})},le=(0,j.useCallback)(e=>{O(e),Q(1),n([]),V([]),G([]),U(0),K(0),s(0)},[Q]),ue=(0,j.useCallback)(()=>{A(e=>!e),Q(1),n([]),V([]),G([]),U(0),K(0),s(0)},[Q]),de=(e,t,n)=>(0,M.jsx)(g,{title:e.title,artistName:t??e.artists?.name??`Unknown`,artistSlug:n??e.artists?.slug??``,videoSlug:e.slug,youtubeId:e.youtube_id,durationSeconds:e.duration_seconds,avgRating:F(e.public_ratings),albumTitle:e.albums?.title??null,albumSlug:e.albums?.slug??null,featuredArtists:I.get(e.id)},e.id);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(h,{title:`${Y} music videos | MusicVideos.org`,description:f(`${Y} music videos â browse official ${Y.toLowerCase()} music videos by artist, song, or album on MusicVideos.org.`),canonical:`/${e}`,jsonLd:[{"@context":`https://schema.org`,"@type":`CollectionPage`,name:`${Y} Music Videos`,url:`https://musicvideos.org/${e}`,description:`Browse ${Y} music videos on MusicVideos.org.`},m([{name:Y,path:`/${e}`}])]}),(0,M.jsxs)(`div`,{className:`max-w-6xl mx-auto px-3 pt-6 pb-16 md:px-6`,children:[(0,M.jsxs)(`h1`,{className:`text-3xl md:text-4xl mb-4`,children:[Y,` Music Videos`]}),(0,M.jsx)(ee,{value:p,onChange:ce,className:`mb-4`,filterContext:Y.toLowerCase(),sortAsc:k,onToggleSort:ue,showAlbum:!0,showGenre:!1}),(0,M.jsx)(o,{value:w,onChange:le,onToggleSort:ue,className:`mb-6`,filterTarget:se}),p===`artist`?(0,M.jsxs)(`div`,{className:`space-y-6`,children:[ae.map(e=>(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{children:(0,M.jsx)(i,{to:`/${e.artistSlug}`,title:`${e.artistName} music videos`,className:`text-lg font-semibold text-primary hover:underline`,children:e.artistName})}),(0,M.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 mt-2`,children:e.videos.map(t=>{let n=(t.artists?.slug??``)===e.artistSlug;return de(t,n?e.artistName:t.artists?.name??`Unknown`,n?e.artistSlug:t.artists?.slug??``)})})]},`${e.artistSlug}-${e.artistName}`)),!c&&ae.length===0&&(0,M.jsxs)(`p`,{className:`text-muted-foreground`,children:[`No `,Y,` artists found yet.`]})]}):p===`album`?(0,M.jsxs)(`div`,{className:`space-y-6`,children:[W.map(e=>(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{children:e.albumSlug?(0,M.jsx)(i,{to:`/albums/${e.artistSlug}/${e.albumSlug}`,title:`${e.albumTitle} album`,className:`text-lg font-semibold text-primary hover:underline`,children:e.albumTitle}):(0,M.jsx)(`span`,{className:`text-lg font-semibold text-primary`,children:e.albumTitle})}),(0,M.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 mt-2`,children:e.videos.map(e=>de(e))})]},`${e.albumSlug}-${e.albumTitle}-${e.artistSlug}`)),!c&&W.length===0&&(0,M.jsxs)(`p`,{className:`text-muted-foreground`,children:[`No `,Y,` albums found yet.`]})]}):(0,M.jsxs)(`div`,{className:`space-y-8`,children:[$.map(e=>(0,M.jsxs)(`section`,{children:[(0,M.jsx)(`div`,{className:`mb-3`,children:(0,M.jsx)(`h3`,{children:(0,M.jsx)(i,{to:`/${e.letter.toLowerCase()}`,title:e.letter,className:`text-lg font-semibold text-primary hover:underline`,children:e.letter})})}),(0,M.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:e.videos.map(e=>de(e))})]},e.letter)),!c&&$.length===0&&(0,M.jsxs)(`p`,{className:`text-muted-foreground`,children:[`No `,Y,` songs found yet.`]})]}),(0,M.jsx)(T,{ref:re,hasMore:ie})]})]})}function L({page:e,totalPages:t,onPageChange:n}){return t<=1?null:(0,M.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-6`,children:[(0,M.jsxs)(a,{variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,M.jsx)(s,{className:`h-4 w-4 mr-1`}),` Prev`]}),(0,M.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`Page `,e,` of `,t]}),(0,M.jsxs)(a,{variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[`Next `,(0,M.jsx)(c,{className:`h-4 w-4 ml-1`})]})]})}var R=10,z=new Set([`top-10`,`top-100`]),B=e=>!e||e.length===0?5:Math.round(e.reduce((e,t)=>
1e+t.stars,0)/e.length);function V(e,t){return e===`top-10`?`Visit MusicVideos.org to browse the top 10 music videos numerically from 1 to 10 and watch them on our music video player.`:e===`top-100`?`Visit MusicVideos.org to browse the top 100 music videos numerically from 1 to 100 and watch them on our music video player.`:e===`new`?`Visit MusicVideos.org to browse newly released official YouTube music videos and watch them on our custom music video player.`:`Browse the ${t} music videos on MusicVideos.org.`}function H(){let{slug:e}=r(),[t,n]=(0,j.useState)([]),[a,s]=(0,j.useState)(1),[c,u]=(0,j.useState)(0),[f,p]=(0,j.useState)(`artist`),[v,y]=(0,j.useState)(null),[b,x]=(0,j.useState)(!0),[T,E]=(0,j.useState)(new Map),[k,A]=(0,j.useState)(new Map),[te,N]=(0,j.useState)(new Map),P=d.find(t=>t.slug===e)?.label??e??``,F=z.has(e??``);(0,j.useEffect)(()=>{s(1),y(null),p(`title`),x(!0)},[e]),(0,j.useEffect)(()=>{(async()=>{if(!e)return;let t=(a-1)*R,r=t+R-1,{data:i,count:o}=await l.from(`video_tags`).select(`video_id, videos(*, artists(name, slug), albums(title, slug), public_ratings(stars))`,{count:`exact`}).eq(`tag`,e).range(t,r);if(i){let e=i.map(e=>e.videos).filter(Boolean);n(e);let t=e.map(e=>e.id),[r,a,o]=await Promise.all([_(t),S(e),w(t)]);E(r),A(a),N(o)}o!==null&&u(o)})()},[e,a]);let I=(0,j.useMemo)(()=>F||!v?t:t.filter(e=>{let t=f===`artist`?e.artists?.name??`Unknown`:f===`album`?e.albums?.title??`Unknown`:e.title;return D(t)===v}),[v,F,t,f]),H=b?1:-1,U=(0,j.useMemo)(()=>{let e=new Map;[...I].sort((e,t)=>{let n=(e.artists?.name??`Unknown`).localeCompare(t.artists?.name??`Unknown`)*H;return n===0?e.title.localeCompare(t.title):n}).forEach(t=>{let n=t.artists?.name??`Unknown`,r=t.artists?.slug??``,i=`${n}::${r}`;e.has(i)||e.set(i,{artistName:n,artistSlug:r,videos:[]}),e.get(i)?.videos.push(t)});let t=Array.from(e.values()),n=C(t,k);return(v?n.filter(e=>D(e.artistName)===v):n).sort((e,t)=>e.artistName.localeCompare(t.artistName)*H)},[I,H,k,v]),W=(0,j.useMemo)(()=>{let e=new Map;return[...I].sort((e,t)=>e.title.localeCompare(t.title)*H).forEach(t=>{let n=D(t.title);e.has(n)||e.set(n,[]),e.get(n)?.push(t)}),Array.from(e.entries()).sort(([e],[t])=>e.localeCompare(t)*H).map(([e,t])=>({letter:e,videos:t}))},[I,H]),G=(0,j.useMemo)(()=>{let e=new Map;return[...I].sort((e,t)=>{let n=(e.albums?.title??`Unknown`).localeCompare(t.albums?.title??`Unknown`)*H;return n===0?e.title.localeCompare(t.title):n}).forEach(t=>{let n=t.albums?.title??`Unknown`,r=t.albums?.slug??``,i=t.artists?.slug??``,a=`${n}::${r}::${i}`;e.has(a)||e.set(a,{albumTitle:n,albumSlug:r,artistSlug:i,videos:[]}),e.get(a)?.videos.push(t)}),Array.from(e.values())},[I,H]),ne=Math.ceil(c/R),K=(a-1)*R,q=f===`artist`?`artist names`:f===`album`?`album titles`:`song titles`,J=e=>{p(e),y(null),x(!0)},Y=(e,t,n)=>(0,M.jsx)(g,{title:e.title,artistName:t??e.artists?.name??`Unknown`,artistSlug:n??e.artists?.slug??``,videoSlug:e.slug,youtubeId:e.youtube_id,durationSeconds:e.duration_seconds,avgRating:B(e.public_ratings),albumTitle:e.albums?.title??null,albumSlug:e.albums?.slug??null,featuredArtists:T.get(e.id)},e.id);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(h,{title:`${P} music videos | MusicVideos.org`,description:V(e??``,P),canonical:`/${e}`,jsonLd:[{"@context":`https://schema.org`,"@type":`CollectionPage`,name:`${P} Music Videos`,url:`https://musicvideos.org/${e}`,description:V(e??``,P)},m([{name:P,path:`/${e}`}])]}),(0,M.jsxs)(`div`,{className:`max-w-6xl mx-auto px-3 pt-6 pb-16 md:px-6`,children:[(0,M.jsxs)(`h1`,{className:`text-3xl md:text-4xl mb-4`,children:[P,` Music Videos`]}),!F&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(ee,{value:f,onChange:J,sortAsc:b,onToggleSort:()=>x(e=>!e),className:`mb-4`,showAlbum:!0}),f!==`genre`&&(0,M.jsx)(o,{value:v,onChange:y,onToggleSort:()=>x(e=>!e),className:`mb-6`,filterTarget:q})]}),F?(0,M.jsx)(`div`,{className:`space-y-3`,children:t.map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,M.jsxs)(`span`,{className:`w-12 shrink-0 pt-4 text-right text-lg font-semibold text-primary`,children:[K+t+1,`.`]}),(0,M.jsx)(`div`,{className:`min-w-0 flex-1`,children:Y(e)})]},e.id))}):f===`artist`?(0,M.jsx)(`div`,{className:`space-y-6`,children:U.map(e=>(0,M.jsxs)(`div`,{children:[(0,M.jsx)(i,{to:`/${e.artistSlug}`,title:`${e.artistName} music videos`,className:`text-lg font-semibold text-primary hover:underline`,children:e.artistName}),(0,M.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 mt-2`,children:e.videos.map(t=>{let n=(t.artists?.slug??``)===e.artistSlug;return Y(t,n?e.artistName:t.artists?.name??`Unknown`,n?e.artistSlug:t.artists?.slug??``)})})]},`${e.artistSlug}-${e.artistName}`))}):f===`album`?(0,M.jsx)(`div`,{className:`space-y-6`,children:G.map(e=>(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{children:e.albumSlug?(0,M.jsx)(i,{to:`/albums/${e.artistSlug}/${e.albumSlug}`,title:`${e.albumTitle} album`,className:`text-lg font-semibold text-primary hover:underline`,children:e.albumTitle}):(0,M.jsx)(`span`,{className:`text-lg font-semibold text-primary`,children:e.albumTitle})}),(0,M.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 mt-2`,children:e.videos.map(e=>Y(e))})]},`${e.albumSlug}-${e.albumTitle}-${e.artistSlug}`))}):f===`genre`?(0,M.jsx)(O,{videos:t,categoryMap:te,sortAsc:b,renderCard:e=>Y(e),emptyMessage:`No ${P} genres found.`}):(0,M.jsx)(`div`,{className:`space-y-8`,children:W.map(e=>(0,M.jsxs)(`section`,{children:[(0,M.jsx)(`div`,{className:`mb-3`,children:(0,M.jsx)(i,{to:`/${e.letter.toLowerCase()}`,title:e.letter,className:`text-lg font-semibold text-primary hover:underline`,children:e.letter})}),(0,M.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:e.videos.map(e=>Y(e))})]},e.letter))}),I.length===0&&(0,M.jsxs)(`p`,{className:`text-center text-muted-foreground py-12`,children:[`No `,P,` videos found yet.`]}),(0,M.jsx)(L,{page:a,totalPages:ne,onPageChange:s})]})]})}var U=60;function W(){let{slug:e}=r(),t=(e??`a`).toUpperCase(),n=/^[0-9]$/.test(t),a=n?`Music Videos by number '${t}'`:`Music Videos by letter '${t}'`,o=n?`Browse music videos by number ${t} | MusicVideos.org`:`Browse music videos by letter ${t} | MusicVideos.org`,s=n?`Visit MusicVideos.org to browse official YouTube music videos numerically by the number '${t}' and watch them on our music video player.`:`Visit MusicVideos.org to browse official YouTube music videos alphabetically by the letter '${t}
1' and watch them on our music video player.`,[c,u]=(0,j.useState)([]),[d,f]=(0,j.useState)(0),[p,m]=(0,j.useState)(!0),[v,b]=(0,j.useState)(`artist`),[x,C]=(0,j.useState)(!0),[k,A]=(0,j.useState)(new Map),[te,N]=(0,j.useState)(new Map),[P,F]=(0,j.useState)(new Map),I=v===`artist`,L=v===`title`,R=v===`album`||v===`genre`,[z,B]=(0,j.useState)([]),[V,H]=(0,j.useState)(0),{page:W,setPage:G,sentinelRef:ne,hasMore:K}=E({totalCount:V,pageSize:U,enabled:I}),{page:q,setPage:J,sentinelRef:Y,hasMore:X}=E({totalCount:d,pageSize:U,enabled:L});(0,j.useEffect)(()=>{G(1),J(1),C(!0),B([]),u([]),A(new Map),N(new Map),F(new Map),m(!0)},[t,G,J]),(0,j.useEffect)(()=>{I&&(async()=>{W===1&&m(!0);let e=(W-1)*U,n=e+U-1,{data:r,count:i}=await l.from(`artists`).select(`*, videos(*, public_ratings(stars), albums(title, slug))`,{count:`exact`}).ilike(`name`,`${t}%`).order(`name`,{ascending:x}).range(e,n);if(r){let e=r.map(e=>e.id),{data:t}=await l.from(`video_featured_artists`).select(`artist_id, video_id`).in(`artist_id`,e).limit(5e3),n=new Set(r.flatMap(e=>(e.videos??[]).map(e=>e.id))),a=(t??[]).map(e=>e.video_id).filter(e=>!n.has(e)),o=new Map;if(a.length>0){let{data:e}=await l.from(`videos`).select(`*, artists(name, slug), albums(title, slug), public_ratings(stars)`).in(`id`,a).limit(5e3);if(e)for(let n of t??[]){let t=e.find(e=>e.id===n.video_id);t&&(o.has(n.artist_id)||o.set(n.artist_id,[]),o.get(n.artist_id).push(t))}}let s=r.map(e=>({...e,videos:[...e.videos??[],...o.get(e.id)??[]]}));B(e=>W===1?s:[...e,...s]),H(i??0);let c=s.flatMap(e=>(e.videos??[]).map(e=>e.id)),[u,d]=await Promise.all([_(c),w(c)]);A(e=>new Map([...e,...u])),F(e=>new Map([...e,...d])),m(!1)}})()},[t,W,x,v]),(0,j.useEffect)(()=>{L&&(async()=>{q===1&&m(!0);let e=(q-1)*U,n=e+U-1,{data:r,count:i}=await l.from(`videos`).select(`*, artists(name, slug), albums(title, slug), public_ratings(stars)`,{count:`exact`}).or(`title.ilike.${t}%,title.ilike."%${t}%,title.ilike.'%${t}%,title.ilike.(%${t}%,title.ilike.[%${t}%`).order(`title`,{ascending:x}).range(e,n);if(r){u(e=>q===1?r:[...e,...r]),f(i??0);let[e,t]=await Promise.all([_(r.map(e=>e.id)),w(r.map(e=>e.id))]);A(t=>new Map([...t,...e])),F(e=>new Map([...e,...t])),m(!1)}})()},[t,q,x,v]),(0,j.useEffect)(()=>{if(!R)return;let e=!1;return m(!0),y((e,t)=>l.from(`videos`).select(`*, artists(name, slug), albums(title, slug), public_ratings(stars)`).order(`title`,{ascending:x}).range(e,t)).then(async n=>{if(e)return;let r=n.filter(e=>{let n=e.artists?.name??``,r=e.title??``;return D(n)===t||D(r)===t});u(r),f(r.length);let i=r.map(e=>e.id),[a,o,s]=await Promise.all([_(i),S(r),w(i)]);e||(A(a),N(o),F(s),m(!1))}),()=>{e=!0}},[t,x,v]);let Z=x?1:-1,Q=(0,j.useMemo)(()=>[...z].sort((e,t)=>e.name.localeCompare(t.name)*Z),[z,Z]),re=(0,j.useMemo)(()=>[...c].sort((e,t)=>e.title.localeCompare(t.title)*Z),[c,Z]),ie=(0,j.useMemo)(()=>{if(v!==`album`)return[];let e=new Map;return[...c].sort((e,t)=>{let n=(e.albums?.title??`Unknown`).localeCompare(t.albums?.title??`Unknown`)*Z;return n===0?e.title.localeCompare(t.title):n}).forEach(t=>{let n=t.albums?.title??`Unknown`,r=t.albums?.slug??``,i=t.artists?.slug??``,a=`${n}::${r}::${i}`;e.has(a)||e.set(a,{albumTitle:n,albumSlug:r,artistSlug:i,videos:[]}),e.get(a)?.videos.push(t)}),Array.from(e.values()).sort((e,t)=>e.albumTitle.localeCompare(t.albumTitle)*Z)},[c,Z,v]),ae=(0,j.useCallback)(e=>{b(e),C(!0),B([]),u([]),G(1),J(1),m(!0)},[G,J]),oe=(0,j.useCallback)(()=>{C(e=>!e),B([]),u([]),G(1),J(1),H(0),f(0)},[G,J]),$=(e,t,n)=>{let r=e.public_ratings??[],i=r.length>0?Math.round(r.reduce((e,t)=>e+t.stars,0)/r.length):5;return(0,M.jsx)(g,{title:e.title,artistName:t??e.artists?.name??e.name??`Unknown`,artistSlug:n??e.artists?.slug??e.slug??``,videoSlug:e.slug,youtubeId:e.youtube_id,durationSeconds:e.duration_seconds,avgRating:i,albumTitle:e.albums?.title??null,albumSlug:e.albums?.slug??null,featuredArtists:k.get(e.id)},e.id)},se=I?ne:Y,ce=I?K:L?X:!1;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(h,{title:o,description:s,canonical:`/${e}`,jsonLd:{"@context":`https://schema.org`,"@type":`CollectionPage`,name:n?`Music Videos - Number ${t}`:`Music Videos - Letter ${t}`,url:`https://musicvideos.org/${e}`}}),(0,M.jsxs)(`div`,{className:`max-w-6xl mx-auto px-3 pt-6 pb-16 md:px-6`,children:[(0,M.jsx)(`h1`,{className:`text-3xl md:text-4xl mb-4`,children:a}
1),(0,M.jsx)(ee,{value:v,onChange:ae,sortAsc:x,onToggleSort:oe,className:`mb-6`,showAlbum:!0}),v===`artist`?(0,M.jsxs)(`div`,{className:`space-y-6`,children:[Q.map(e=>(0,M.jsxs)(`div`,{children:[(0,M.jsx)(i,{to:`/${e.slug}`,title:`${e.name} music videos`,className:`text-lg font-semibold text-primary hover:underline`,children:e.name}),(0,M.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 mt-2`,children:(e.videos??[]).map(t=>{let n=t.artist_id!==e.id;return $(t,n?t.artists?.name??`Unknown`:e.name,n?t.artists?.slug??``:e.slug)})})]},e.id)),!p&&z.length===0&&(0,M.jsxs)(`p`,{className:`text-muted-foreground`,children:[`No artists found starting with `,t,`.`]})]}):v===`album`?(0,M.jsxs)(`div`,{className:`space-y-6`,children:[ie.map(e=>(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{children:e.albumSlug?(0,M.jsx)(i,{to:`/albums/${e.artistSlug}/${e.albumSlug}`,title:`${e.albumTitle} album`,className:`text-lg font-semibold text-primary hover:underline`,children:e.albumTitle}):(0,M.jsx)(`span`,{className:`text-lg font-semibold text-primary`,children:e.albumTitle})}),(0,M.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 mt-2`,children:e.videos.map(e=>$(e))})]},`${e.albumSlug}-${e.albumTitle}-${e.artistSlug}`)),!p&&ie.length===0&&(0,M.jsxs)(`p`,{className:`text-muted-foreground`,children:[`No albums found starting with `,t,`.`]})]}):v===`genre`?(0,M.jsx)(O,{videos:I?z.flatMap(e=>(e.videos??[]).map(t=>({...t,artists:{name:e.name,slug:e.slug}}))):c,categoryMap:P,sortAsc:x,renderCard:e=>$(e),emptyMessage:`No genres found for ${t}.`,loading:p}):(0,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[re.map(e=>$(e)),!p&&c.length===0&&(0,M.jsxs)(`p`,{className:`text-muted-foreground`,children:[`No videos found starting with `,t,`.`]})]}),(0,M.jsx)(T,{ref:se,hasMore:ce})]})]})}function G(){let{slug:e}=r(),[t,n]=(0,j.useState)(null),[a,o]=(0,j.useState)([]),[s,c]=(0,j.useState)([]),[u,d]=(0,j.useState)(new Map);if((0,j.useEffect)(()=>{(async()=>{if(!e)return;let{data:t}=await l.from(`artists`).select(`*`).eq(`slug`,e).single();if(t){n(t);let[{data:e},{data:r},{data:i}]=await Promise.all([l.from(`videos`).select(`*, public_ratings(stars), albums(title, slug)`).eq(`artist_id`,t.id).order(`title`).limit(5e3),l.from(`albums`).select(`id, title, slug, cover_url`).eq(`artist_id`,t.id).order(`title`),l.from(`video_featured_artists`).select(`video_id`).eq(`artist_id`,t.id)]),a=e??[];if(i&&i.length>0){let e=new Set(a.map(e=>e.id)),t=i.map(e=>e.video_id).filter(t=>!e.has(t));if(t.length>0){let{data:e}=await l.from(`videos`).select(`*, public_ratings(stars), albums(title, slug), artists(name, slug)`).in(`id`,t).order(`title`);e&&(a=[...a,...e])}}o(a);let s=await _(a.map(e=>e.id));d(s),r&&c(r)}})()},[e]),!t)return(0,M.jsxs)(`div`,{className:`max-w-6xl mx-auto px-3 py-12 text-center text-muted-foreground`,children:[(0,M.jsxs)(`h1`,{className:`text-2xl`,children:[p(e??``),` music videos`]}),(0,M.jsx)(`p`,{className:`mt-2`,children:`Loading...`})]});let f=`Visit MusicVideos.org to browse and watch ${t.name}'s music videos on our music video player. Discover ${t.name}'s music videos by album.`;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(h,{title:`${t.name} music videos | MusicVideos.org`,description:f,canonical:`/${t.slug}`,jsonLd:{"@context":`https://schema.org`,"@type":`MusicGroup`,name:t.name,url:`https://musicvideos.org/${t.slug}`}}),(0,M.jsxs)(`div`,{className:`max-w-6xl mx-auto px-3 pt-6 pb-16 md:px-6`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-4 mb-6`,children:[(0,M.jsx)(k,{name:t.name,imageUrl:t.image_url,className:`w-20 h-20`}),(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h1`,{className:`text-3xl md:text-4xl`,children:[t.name,` music videos`]}),(0,M.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[a.length,` music video`,a.length===1?``:`s`]})]})]}),s.length>0&&(0,M.jsxs)(`div`,{className:`mb-8`,children:[(0,M.jsx)(`h2`,{className:`text-xl mb-3`,children:`Albums`}),(0,M.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5`,children:s.map(e=>(0,M.jsxs)(i,{to:`/albums/${t.slug}/${e.slug}`,title:`${t.name} ${e.title} album`,className:`group flex flex-col overflow-hidden rounded-lg border border-border bg-card transition-[border-color,box-shadow] hover:border-chartreuse hover:ring-4 hover:ring-chartreuse/80`,children:[(0,M.jsx)(A,{artistName:t.name,albumTitle:e.title,coverUrl:e.cover_url,className:`aspect-square w-full rounded-none border-0`}),(0,M.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,M.jsx)(`span`,{className:`block truncate text-sm font-medium text-chartreuse transition-colors group-hover:text-chartreuse/80`,children:e.title})})]},e.id))})]}),(0,M.jsx)(`h2`,{className:`text-xl mb-3`,children:`Music videos`}),(0,M.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:a.map(e=>{let n=e.public_ratings??[],r=n.length>0?Math.round(n.reduce((e,t)=>
1e+t.stars,0)/n.length):5,i=e.artist_id===t.id?t.name:e.artists?.name??t.name,a=e.artist_id===t.id?t.slug:e.artists?.slug??t.slug;return(0,M.jsx)(g,{title:e.title,artistName:i,artistSlug:a,videoSlug:e.slug,youtubeId:e.youtube_id,durationSeconds:e.duration_seconds,avgRating:r,albumTitle:e.albums?.title??null,albumSlug:e.albums?.slug??null,featuredArtists:u.get(e.id)},e.id)})})]})]})}var ne=new Set([`rap`,`hip-hop`,`pop`,`rock`,`country`,`jazz`,`classical`,`latin`,`edm`,`reggae`,`rnb`,`afrobeats`,`indie`,`alternative`]),K=new Set([`new`,`top-10`,`top-100`]),q=new Set(`abcdefghijklmnopqrstuvwxyz`.split(``)),J=new Set(`0123456789`.split(``));function Y(){let{slug:e}=r();return e?ne.has(e)?(0,M.jsx)(I,{}):K.has(e)?(0,M.jsx)(H,{}):q.has(e)&&e.length===1||J.has(e)&&e.length===1?(0,M.jsx)(W,{}):(0,M.jsx)(G,{}):null}var X=Y;export{X as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.