import{j as e}from"./vendor-ui-CUslpDkL.js";import{i as N,r as p,L as c}from"./vendor-react-Dg0Tra3e.js";import{u as g}from"./vendor-query-CN1EccJz.js";import{u as b,s as x,n as w,B as v,S as $,C as A}from"./index-CJqEbhJN.js";import{C as _,a as F}from"./card-BSxrPlO5.js";import{B as L}from"./badge-But4vkun.js";import{u as B}from"./useIndexNow-C3dRJY1T.js";import{A as C}from"./arrow-left-DtOv4JyO.js";import{F as D}from"./film-B3I-fyoz.js";import"./vendor-supabase-yzuDJZPy.js";import"./vendor-motion-CiNtJfg1.js";const H=()=>{const{slug:n}=N(),{t:i}=b(),{pingIndexNow:m}=B(),d=p.useRef(!1),{data:r,isLoading:u}=g({queryKey:["genre",n],queryFn:async()=>{const{data:s,error:a}=await x.from("genres").select("*").eq("slug",n).maybeSingle();if(a)throw a;return s},enabled:!!n}),{data:o,isLoading:h}=g({queryKey:["genre-shows",r?.name],queryFn:async()=>{const{data:s,error:a}=await x.from("shows").select("*").contains("genres",[r?.name]).order("popularity",{ascending:!1,nullsFirst:!1}).limit(100);if(a)throw a;return s},enabled:!!r?.name});p.useEffect(()=>{r&&!d.current&&(d.current=!0,m([`/genre/${n}`]))},[r,n,m]);const f=u||h,j=s=>i(`genres.names.${s}`,{defaultValue:""})||s,y=(s,a)=>i(`genres.descriptions.${s}`,{defaultValue:""})||a||"";if(f)return e.jsx("div",{className:"container mx-auto px-4 py-20",children:e.jsxs("div",{className:"animate-pulse space-y-8",children:[e.jsx("div",{className:"h-12 bg-muted rounded w-1/3"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[...Array(20)].map((s,a)=>e.jsx("div",{className:"aspect-[2/3] bg-muted rounded-lg"},a))})]})});if(!r)return e.jsxs("div",{className:"container mx-auto px-4 py-20 text-center",children:[e.jsx("h1",{className:"text-3xl font-bold mb-4",children:"Genre Not Found"}),e.jsx(c,{to:"/genres",className:"text-primary hover:underline",children:i("genres.browseAll")})]});const t=j(r.name),l=y(r.name,r.description);return e.jsxs(e.Fragment,{children:[e.jsxs(w,{children:[e.jsx("title",{children:`${t} Anime - Best ${t} Anime Series | What-Anime`}),e.jsx("meta",{name:"description",content:`Discover the best ${t} anime series. ${l} Browse ${r.show_count||o?.length||0}+ ${t.toLowerCase()} anime titles.`}),e.jsx("link",{rel:"canonical",href:`https://www.what-anime.com/genre/${n}`}),e.jsx("meta",{property:"og:title",content:`${t} Anime - Best ${t} Series`}),e.jsx("meta",{property:"og:description",content:l||`Browse the best ${t} anime series.`}),e.jsx("meta",{property:"og:url",content:`https://www.what-anime.com/genre/${n}`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"CollectionPage",name:`${t} Anime`,description:l,url:`https://www.what-anime.com/genre/${n}`,numberOfItems:o?.length||0})})]}),e.jsxs("main",{className:"container mx-auto px-4 py-8",children:[e.jsx(c,{to:"/genres",children:e.jsxs(v,{variant:"ghost",className:"mb-6 group",children:[e.jsx(C,{className:"mr-2 h-4 w-4 transition-transform group-hover:-translate-x-1"}),i("genres.browseAll")]})}),e.jsxs("div",{className:"rounded-2xl p-8 mb-8 bg-primary/10 border-l-4 border-primary",children:[e.jsxs(L,{className:"mb-4 bg-primary text-primary-foreground",children:[r.show_count||o?.length||0," ",i("genres.anime")]}),e.jsxs("h1",{className:"text-4xl md:text-5xl font-bold mb-4",children:[t," ",i("genres.anime")]}),e.jsx("p",{className:"text-lg text-muted-foreground max-w-3xl",children:l||`Explore the best ${t} anime series.`})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:o?.map(s=>e.jsx(c,{to:`/shows/${s.slug}`,className:"group",children:e.jsxs(_,{className:"overflow-hidden border-0 bg-card/50 hover:bg-card transition-all duration-300 hover:scale-105 hover:shadow-xl hover:shadow-primary/10",children:[e.jsxs("div",{className:"aspect-[2/3] relative overflow-hidden",children:[e.jsx("img",{src:s.poster_url||"/placeholder.svg",alt:s.title_english||s.title_romaji||"Anime",className:"w-full h-full object-cover",loading:"lazy"}),s.rating&&e.jsxs("div",{className:"absolute top-2 right-2 bg-background/80 backdrop-blur-sm rounded-full px-2 py-1 flex items-center gap-1",children:[e.jsx($,{className:"w-3 h-3 text-yellow-400 fill-yellow-400"}),e.jsx("span",{className:"text-xs font-semibold",children:s.rating.toFixed(1)})]}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-background/80 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity"})]}),e.jsxs(F,{className:"p-3",children:[e.jsx("h3",{className:"font-semibold text-sm line-clamp-2 group-hover:text-primary transition-colors",children:s.title_english||s.title_romaji}),e.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs text-muted-foreground",children:[s.season_year&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(A,{className:"w-3 h-3"}),s.season_year]}),s.episodes_count&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(D,{className:"w-3 h-3"}),s.episodes_count," eps"]})]})]})]})},s.id))}),(!o||o.length===0)&&e.jsx("div",{className:"text-center py-20 text-muted-foreground",children:i("seasons.noAnimeFound")})]})]})};export{H as default};