import{j as s}from"./vendor-ui-CUslpDkL.js";import{r as c,L as A}from"./vendor-react-Dg0Tra3e.js";import{I as _}from"./input-BddqDKi_.js";import{u as B,s as G}from"./useShows-ZYYtFbPs.js";import{c as L,u as F,a as I,T as j,B as o,D as y,d as N,e as b,f as $,g as T,h as E,i as x,j as v,S,k as U,X as z}from"./index-CJqEbhJN.js";import{B as P}from"./badge-But4vkun.js";import{R as d}from"./refresh-cw-CVvHhQZs.js";import{S as Q}from"./search-RJS4XthK.js";import{F as V}from"./filter-B-pqD9on.js";import"./vendor-query-CN1EccJz.js";import"./vendor-supabase-yzuDJZPy.js";import"./vendor-motion-CiNtJfg1.js";/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const q=L("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]),H=["Action","Adventure","Comedy","Drama","Fantasy","Horror","Mystery","Romance","Sci-Fi","Slice of Life","Sports","Supernatural","Suspense","Ecchi","Boys Love","Girls Love","Gourmet","Award Winning","Avant Garde","Reincarnation"];function ls(){const{t:a}=F(),[p,k]=c.useState(""),[r,u]=c.useState([]),[l,C]=c.useState("popular"),{data:m=[],isLoading:h,refetch:D}=B(p,r,l),{toast:i}=I(),[n,f]=c.useState(!1),g=e=>{u(t=>t.includes(e)?t.filter(R=>R!==e):[...t,e])},M=()=>{u([])},w=async()=>{f(!0);try{i({title:a("shows.syncShows"),description:a("shows.loadingShows")}),await G(),D(),i({title:a("shows.syncShows"),description:a("shows.loadingShows")})}catch(e){console.error("Sync error:",e),i({title:a("common.error"),description:a("common.error"),variant:"destructive"})}finally{f(!1)}};return s.jsx("div",{className:"min-h-screen px-4 py-8 md:py-12",children:s.jsxs("div",{className:"mx-auto max-w-7xl",children:[s.jsxs("div",{className:"mb-8",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(j,{className:"w-10 h-10 text-secondary"}),s.jsx("h1",{className:"text-4xl font-bold",children:a("shows.title")})]}),s.jsxs(o,{onClick:w,disabled:n,className:"rounded-full neon-glow-blue bg-gradient-to-r from-secondary to-primary",children:[s.jsx(d,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),a(n?"shows.syncing":"shows.syncShows")]})]}),s.jsx("p",{className:"text-muted-foreground text-lg",children:a("shows.description")})]}),s.jsxs("div",{className:"mb-8 glass-card p-4 space-y-4",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsxs("div",{className:"relative flex-1 w-full sm:w-auto",children:[s.jsx(Q,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground"}),s.jsx(_,{type:"text",placeholder:a("shows.searchPlaceholder"),value:p,onChange:e=>k(e.target.value),className:"pl-10 bg-background/50 border-white/10 focus:border-primary/50 w-full"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(y,{children:[s.jsx(N,{asChild:!0,children:s.jsxs(o,{variant:"outline",className:"glass-card border-white/10 flex-1 sm:flex-none sm:min-w-[160px]",children:[s.jsx(q,{className:"w-4 h-4 mr-2"}),s.jsxs("span",{className:"hidden sm:inline",children:[l==="popular"&&a("shows.mostPopular"),l==="newest"&&a("shows.newlyReleased"),l==="rating"&&a("shows.highestRated")]}),s.jsx("span",{className:"sm:hidden",children:a("shows.sortBy")})]})}),s.jsxs(b,{className:"w-56 bg-card/95 backdrop-blur-sm border-white/10 z-50",children:[s.jsx($,{children:a("shows.sortBy")}),s.jsx(T,{}),s.jsxs(E,{value:l,onValueChange:e=>C(e),children:[s.jsxs(x,{value:"popular",children:[s.jsx(v,{className:"w-4 h-4 mr-2"}),a("shows.mostPopular")]}),s.jsxs(x,{value:"newest",children:[s.jsx(d,{className:"w-4 h-4 mr-2"}),a("shows.newlyReleased")]}),s.jsxs(x,{value:"rating",children:[s.jsx(S,{className:"w-4 h-4 mr-2"}),a("shows.highestRated")]})]})]})]}),s.jsxs(y,{children:[s.jsx(N,{asChild:!0,children:s.jsxs(o,{variant:"outline",className:"glass-card border-white/10 flex-1 sm:flex-none sm:min-w-[140px]",children:[s.jsx(V,{className:"w-4 h-4 mr-2"}),s.jsxs("span",{className:"hidden sm:inline",children:[a("shows.genres")," ",r.length>0&&`(${r.length})`]}),s.jsxs("span",{className:"sm:hidden",children:[a("shows.filters")," ",r.length>0&&`(${r.length})`]})]})}),s.jsx(b,{className:"w-56 max-h-[400px] overflow-y-auto bg-card/95 backdrop-blur-sm border-white/10 z-50",children:H.map(e=>s.jsx(U,{checked:r.includes(e),onCheckedChange:()=>g(e),children:e},e))})]})]})]}),r.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[s.jsxs("span",{className:"text-sm text-muted-foreground",children:[a("shows.filters"),":"]}),r.map(e=>s.jsxs(P,{variant:"secondary",className:"pl-3 pr-2 py-1 cursor-pointer hover:bg-secondary/80",onClick:()=>g(e),children:[e,s.jsx(z,{className:"w-3 h-3 ml-1"})]},e)),s.jsx(o,{variant:"ghost",size:"sm",onClick:M,className:"h-7 text-xs",children:a("shows.clearAll")})]})]}),h&&s.jsxs("div",{className:"text-center py-20",children:[s.jsx(d,{className:"w-12 h-12 mx-auto mb-4 animate-spin text-primary"}),s.jsx("p",{className:"text-muted-foreground",children:a("shows.loadingShows")})]}),!h&&m.length===0&&s.jsxs("div",{className:"text-center py-20",children:[s.jsx(j,{className:"w-16 h-16 mx-auto mb-4 text-muted-foreground"}),s.jsx("h3",{className:"text-xl font-semibold mb-2",children:a("shows.noShowsFound")}),s.jsx("p",{className:"text-muted-foreground mb-6",children:a("shows.clickSync")}),s.jsxs(o,{onClick:w,disabled:n,className:"rounded-full neon-glow-pink bg-gradient-to-r from-primary to-secondary",children:[s.jsx(d,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),a("shows.syncNow")]})]}),!h&&m.length>0&&s.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:m.map(e=>s.jsx(A,{to:e.in_database===!1?"#":`/shows/${e.id}`,onClick:e.in_database===!1?t=>{t.preventDefault(),i({title:a("shows.noShowsFound"),description:a("shows.notInDatabase")})}:void 0,children:s.jsxs("div",{className:`glass-card-hover overflow-hidden group cursor-pointer h-full flex flex-col ${e.in_database===!1?"opacity-75":""}`,children:[s.jsxs("div",{className:"relative h-80 overflow-hidden",children:[s.jsx("img",{src:e.poster_url||"https://images.unsplash.com/photo-1578632767115-351597cf2477?w=300&h=450&fit=crop",alt:e.title_english||e.title_romaji||"Anime",className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-110",loading:"lazy"}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-card via-card/50 to-transparent"}),s.jsx("span",{className:`absolute top-3 left-3 px-3 py-1 text-xs font-semibold rounded-full ${e.status==="Ongoing"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:e.status||"Unknown"}),e.in_database===!1&&s.jsx("span",{className:"absolute bottom-3 left-3 px-3 py-1 text-xs font-semibold rounded-full bg-secondary/80 text-secondary-foreground",children:"From Jikan API"}),e.rating&&s.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1 px-2 py-1 rounded-full glass-card",children:[s.jsx(S,{className:"w-4 h-4 text-secondary fill-secondary"}),s.jsx("span",{className:"text-sm font-semibold",children:e.rating})]}),s.jsx("div",{className:"absolute bottom-0 left-0 right-0 p-4 translate-y-full group-hover:translate-y-0 transition-transform duration-300",children:s.jsxs("div",{className:"flex items-center gap-2 text-primary mb-2",children:[s.jsx(v,{className:"w-4 h-4"}),s.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider",children:["MAL #",e.mal_id]})]})})]}),s.jsxs("div",{className:"p-4 flex-1 flex flex-col",children:[s.jsx("h3",{className:"font-semibold text-lg mb-1 group-hover:text-primary transition-colors line-clamp-2",children:e.title_english||e.title_romaji||"Untitled"}),s.jsx("p",{className:"text-sm text-muted-foreground mb-3 line-clamp-1",children:e.title_native}),s.jsx("div",{className:"flex flex-wrap gap-2 mt-auto",children:e.genres?.slice(0,3).map(t=>s.jsx("span",{className:"px-2 py-1 text-xs rounded-full bg-white/5 border border-white/10 text-muted-foreground",children:t},t))})]})]})},e.id))})]})})}export{ls as default};