1 line
10 KiB
JavaScript
1 line
10 KiB
JavaScript
import{a as c,j as e}from"./vendor-react-YMhRUmcb.js";import{c as w,u as S}from"./vendor-router-DX94Iu-2.js";import{a as k,C as o,E as C,L as _}from"./index-D2uzyr9g.js";import{u as E}from"./useDebounce-zqwECu1l.js";import{S as T,X as P,a6 as u,aS as R,U as b}from"./vendor-icons-DINCNwpk.js";import{T as q,a as A,b as m,c as x}from"./Tabs-C8UCeQNW.js";import{A as f}from"./avatar-DwZKme3D.js";import{f as D}from"./vendor-utils-4BWoYre8.js";import"./vendor-fFnFILYR.js";import"./vendor-tanstack-CoFNL2zy.js";const L={search:async s=>(await k.get("/search",{params:{q:s}})).data};function $(){const[s,a]=w(),r=s.get("q")??"",[t,i]=c.useState(r),l=E(t,500),[n,h]=c.useState(null),[v,p]=c.useState(!1),[j,g]=c.useState(null);c.useEffect(()=>{i(r)},[r]),c.useEffect(()=>{(async()=>{if(!l.trim()){h(null);return}p(!0),g(null);try{const d=await L.search(l);h(d)}catch(d){g(d instanceof Error?d:new Error("Search signal interrupted."))}finally{p(!1)}})(),l!==r&&(l?a({q:l},{replace:!0}):a({},{replace:!0}))},[l,a,r]);const N=()=>{i(""),a({}),h(null)},y=!!n&&(n.tracks.length>0||n.artists.length>0||n.playlists.length>0);return{query:t,setQuery:i,results:n,isLoading:v,error:j,clearSearch:N,hasResults:y}}function Q({query:s,onQueryChange:a,onClear:r}){return e.jsxs("div",{className:"mb-12 text-center max-w-3xl mx-auto",children:[e.jsxs("h1",{className:"text-4xl md:text-5xl font-display font-bold mb-6 text-white tracking-tight",children:["Explore the"," ",e.jsx("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-cyan-400 to-magenta-500",children:"Nebula"})]}),e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute -inset-1 bg-gradient-to-r from-cyan-500 to-magenta-500 rounded-2xl blur opacity-20 group-hover:opacity-40 transition duration-500"}),e.jsxs("div",{className:"relative flex items-center bg-black/50 backdrop-blur-xl border border-white/10 rounded-2xl overflow-hidden shadow-2xl",children:[e.jsx(T,{className:"w-5 h-5 ml-4 text-muted-foreground flex-shrink-0"}),e.jsx("input",{value:s,onChange:t=>a(t.target.value),placeholder:"Search for tracks, artists, signals...",className:"w-full bg-transparent border-none py-4 px-4 text-lg text-white placeholder:text-muted-foreground focus:outline-none focus:ring-0 font-sans",autoFocus:!0,"aria-label":"Search"}),s&&e.jsx("button",{type:"button",onClick:r,className:"p-2 mr-2 hover:bg-white/10 rounded-full transition-colors text-muted-foreground hover:text-white","aria-label":"Clear search",children:e.jsx(P,{className:"w-5 h-5"})})]})]})]})}function F(){return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 opacity-80",children:[e.jsxs(o,{variant:"glass",className:"p-6 text-center hover:bg-white/5 transition-colors cursor-pointer group hover:-translate-y-1",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-cyan-500/10 flex items-center justify-center mx-auto mb-4 group-hover:bg-cyan-500/20 transition-colors",children:e.jsx(u,{className:"w-6 h-6 text-cyan-500"})}),e.jsx("h3",{className:"font-bold text-lg mb-1",children:"New Releases"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Fresh signals from the void"})]}),e.jsxs(o,{variant:"glass",className:"p-6 text-center hover:bg-white/5 transition-colors cursor-pointer group hover:-translate-y-1",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-magenta-500/10 flex items-center justify-center mx-auto mb-4 group-hover:bg-magenta-500/20 transition-colors",children:e.jsx(R,{className:"w-6 h-6 text-magenta-500"})}),e.jsx("h3",{className:"font-bold text-lg mb-1",children:"Curated Mixes"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Hand-picked by the algorithm"})]}),e.jsxs(o,{variant:"glass",className:"p-6 text-center hover:bg-white/5 transition-colors cursor-pointer group hover:-translate-y-1",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-lime-500/10 flex items-center justify-center mx-auto mb-4 group-hover:bg-lime-500/20 transition-colors",children:e.jsx(b,{className:"w-6 h-6 text-lime-500"})}),e.jsx("h3",{className:"font-bold text-lg mb-1",children:"Top Artists"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Trending creators this week"})]})]})}function H(){return e.jsxs("div",{className:"text-center py-20",children:[e.jsx("div",{className:"text-6xl mb-4","aria-hidden":!0,children:"🔭"}),e.jsx("h2",{className:"text-2xl font-bold mb-2",children:"No signals found"}),e.jsx("p",{className:"text-muted-foreground",children:"Try adjusting your search frequency."})]})}function I({error:s,onRetry:a}){return e.jsx(C,{error:s,variant:"card",severity:"error",onRetry:a})}function M({results:s}){const a=S();return e.jsxs(q,{defaultValue:"all",className:"w-full",children:[e.jsxs(A,{className:"bg-transparent border-b border-white/10 w-full justify-start h-auto p-0 gap-8 mb-8",children:[e.jsx(m,{value:"all",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:text-primary py-3 px-0 text-lg font-display bg-transparent",children:"All Results"}),e.jsxs(m,{value:"tracks",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:text-primary py-3 px-0 text-lg font-display bg-transparent",children:["Tracks (",s.tracks.length,")"]}),e.jsxs(m,{value:"artists",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:text-primary py-3 px-0 text-lg font-display bg-transparent",children:["Artists (",s.artists.length,")"]}),e.jsxs(m,{value:"playlists",className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:text-primary py-3 px-0 text-lg font-display bg-transparent",children:["Playlists (",s.playlists.length,")"]})]}),e.jsxs(x,{value:"all",className:"space-y-12",children:[s.tracks.length>0&&e.jsxs("section",{children:[e.jsxs("h3",{className:"text-xl font-bold mb-4 flex items-center gap-2",children:[e.jsx(u,{className:"w-5 h-5 text-primary"})," Top Tracks"]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:s.tracks.slice(0,6).map(r=>e.jsxs(o,{variant:"glass",className:"p-3 flex items-center gap-4 hover:bg-white/5 transition-colors cursor-pointer group",onClick:()=>a(`/tracks/${r.id}`),children:[e.jsx("div",{className:"w-16 h-16 rounded-lg bg-black/40 overflow-hidden flex-shrink-0",children:r.cover_art_path?e.jsx("img",{src:r.cover_art_path,alt:"",className:"w-full h-full object-cover group-hover:scale-110 transition-transform"}):e.jsx(u,{className:"w-full h-full p-4 text-white/20"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-bold truncate group-hover:text-primary transition-colors",children:r.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r.artist})]})]},r.id))})]}),s.artists.length>0&&e.jsxs("section",{children:[e.jsxs("h3",{className:"text-xl font-bold mb-4 flex items-center gap-2",children:[e.jsx(b,{className:"w-5 h-5 text-primary"})," Artists"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:s.artists.slice(0,5).map(r=>e.jsxs(o,{variant:"glass",className:"p-4 flex flex-col items-center text-center hover:bg-white/5 transition-colors cursor-pointer group",onClick:()=>a(`/u/${r.username}`),children:[e.jsx(f,{src:r.avatar_url,fallback:r.username[0],className:"w-24 h-24 mb-4 shadow-lg group-hover:scale-105 transition-transform"}),e.jsx("h4",{className:"font-bold truncate w-full group-hover:text-primary transition-colors",children:r.username}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[r.followers_count??0," followers"]})]},r.id))})]})]}),e.jsx(x,{value:"tracks",children:e.jsx("div",{className:"grid grid-cols-1 gap-2",children:s.tracks.map(r=>e.jsxs("div",{role:"button",tabIndex:0,className:"flex items-center gap-4 p-4 rounded-xl border border-white/5 hover:bg-white/5 transition-colors cursor-pointer group bg-black/20",onClick:()=>a(`/tracks/${r.id}`),onKeyDown:t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),a(`/tracks/${r.id}`))},children:[e.jsx("div",{className:"w-12 h-12 rounded bg-black/40 overflow-hidden flex-shrink-0",children:r.cover_art_path&&e.jsx("img",{src:r.cover_art_path,alt:"",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-bold group-hover:text-primary",children:r.title}),e.jsx("p",{className:"text-muted-foreground text-sm",children:r.artist})]}),e.jsx("div",{className:"text-xs font-mono text-muted-foreground flex-shrink-0",children:r.created_at?D(new Date(r.created_at))+" ago":null})]},r.id))})}),e.jsx(x,{value:"artists",children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-6",children:s.artists.map(r=>e.jsxs(o,{variant:"glass",className:"p-6 flex flex-col items-center text-center hover:bg-white/5 cursor-pointer group",onClick:()=>a(`/u/${r.username}`),children:[e.jsx(f,{src:r.avatar_url,fallback:r.username[0],className:"w-32 h-32 mb-4 shadow-lg group-hover:scale-105 transition-transform"}),e.jsx("h4",{className:"font-bold text-lg group-hover:text-primary",children:r.username})]},r.id))})}),e.jsx(x,{value:"playlists",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:s.playlists.map(r=>e.jsxs(o,{variant:"glass",className:"p-0 overflow-hidden cursor-pointer group hover:-translate-y-1 transition-transform",onClick:()=>a(`/playlists/${r.id}`),children:[e.jsxs("div",{className:"h-32 bg-gradient-to-br from-purple-900 to-black relative",children:[r.cover_url&&e.jsx("img",{src:r.cover_url,alt:"",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/20 group-hover:bg-transparent transition-colors"})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("h4",{className:"font-bold group-hover:text-primary",children:r.title}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:r.description??"No description"})]})]},r.id))})})]})}function Z(){const{query:s,setQuery:a,results:r,isLoading:t,error:i,clearSearch:l,hasResults:n}=$();return e.jsxs("div",{className:"min-h-layout-page pb-24 container mx-auto px-4 py-8 max-w-6xl",children:[e.jsx(Q,{query:s,onQueryChange:a,onClear:l}),i&&e.jsx(I,{error:i,onRetry:()=>window.location.reload()}),t?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 opacity-50","aria-busy":"true",children:[e.jsx(_,{className:"w-12 h-12 mb-4"}),e.jsx("p",{className:"text-sm font-mono animate-pulse",children:"Scanning frequencies..."})]}):s?n?r?e.jsx(M,{results:r}):null:e.jsx(H,{}):e.jsx(F,{})]})}export{Z as SearchPage};
|