import{j as s}from"./vendor-ui-CUslpDkL.js";import{u as n}from"./vendor-query-CN1EccJz.js";import{u as o,U as i,H as x,s as u}from"./index-CJqEbhJN.js";import{r as h,L as f}from"./vendor-react-Dg0Tra3e.js";import{I as g}from"./input-BddqDKi_.js";import"./vendor-supabase-yzuDJZPy.js";import"./vendor-motion-CiNtJfg1.js";function _(){const{t:a}=o(),[r,c]=h.useState(""),{data:l,isLoading:m}=n({queryKey:["characters",r],queryFn:async()=>{let e=u.from("characters").select("id, name_full, name_native, image_url, favorites, slug").order("favorites",{ascending:!1,nullsFirst:!1}).limit(100);r&&(e=e.ilike("name_full",`%${r}%`));const{data:t,error:d}=await e;if(d)throw d;return t}});return s.jsx("div",{className:"min-h-screen px-4 py-8",children:s.jsxs("div",{className:"mx-auto max-w-7xl",children:[s.jsxs("div",{className:"text-center mb-12",children:[s.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full glass-card mb-4",children:[s.jsx(i,{className:"w-5 h-5 text-primary"}),s.jsx("span",{className:"text-sm font-medium",children:a("characters.title")})]}),s.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",children:a("characters.title")}),s.jsx("p",{className:"text-muted-foreground max-w-2xl mx-auto",children:a("characters.description")})]}),s.jsx("div",{className:"max-w-md mx-auto mb-8",children:s.jsx(g,{placeholder:a("characters.searchPlaceholder"),value:r,onChange:e=>c(e.target.value),className:"glass-card border-white/10"})}),m&&s.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4",children:Array.from({length:20}).map((e,t)=>s.jsxs("div",{className:"glass-card rounded-xl overflow-hidden animate-pulse",children:[s.jsx("div",{className:"aspect-[3/4] bg-muted"}),s.jsxs("div",{className:"p-3 space-y-2",children:[s.jsx("div",{className:"h-4 bg-muted rounded w-3/4"}),s.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]})]},t))}),l&&l.length>0&&s.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4",children:l.map(e=>s.jsxs(f,{to:`/character/${e.slug||e.id}`,className:"glass-card rounded-xl overflow-hidden group hover:scale-105 transition-transform",children:[s.jsx("div",{className:"aspect-[3/4] bg-muted overflow-hidden",children:e.image_url?s.jsx("img",{src:e.image_url,alt:e.name_full,className:"w-full h-full object-cover group-hover:scale-110 transition-transform",loading:"lazy"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(i,{className:"w-12 h-12 text-muted-foreground"})})}),s.jsxs("div",{className:"p-3",children:[s.jsx("h3",{className:"font-semibold text-sm line-clamp-1",children:e.name_full}),e.name_native&&s.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:e.name_native}),e.favorites&&e.favorites>0&&s.jsxs("div",{className:"flex items-center gap-1 mt-1 text-xs text-primary",children:[s.jsx(x,{className:"w-3 h-3 fill-current"}),s.jsxs("span",{children:[e.favorites.toLocaleString()," ",a("characters.favorites")]})]})]})]},e.id))}),l&&l.length===0&&s.jsxs("div",{className:"text-center py-16",children:[s.jsx(i,{className:"w-16 h-16 mx-auto mb-4 text-muted-foreground"}),s.jsx("h3",{className:"text-xl font-semibold mb-2",children:a("characters.noCharactersFound")}),s.jsx("p",{className:"text-muted-foreground",children:a("characters.noCharactersFound")})]})]})})}export{_ as default};