import{j as e}from"./vendor-ui-CUslpDkL.js";import{i as N,r as u,L as o}from"./vendor-react-Dg0Tra3e.js";import{u as p}from"./vendor-query-CN1EccJz.js";import{c as v,u as y,s as m,B as _,n as b,U as f,H as k,C as L}from"./index-CJqEbhJN.js";import{a as $}from"./sanitize-D2z4Jm0g.js";import{u as A}from"./useIndexNow-C3dRJY1T.js";import{A as g}from"./arrow-left-DtOv4JyO.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 C=v("Droplet",[["path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z",key:"c7niix"}]]);function M(){const{slug:r}=N(),{t:a}=y(),{pingIndexNow:d}=A(),h=u.useRef(!1),{data:s,isLoading:j}=p({queryKey:["character",r],queryFn:async()=>{const{data:t}=await m.from("characters").select("*").eq("slug",r).maybeSingle();if(t)return t;const{data:l,error:x}=await m.from("characters").select("*").eq("id",r).maybeSingle();if(x)throw x;return l},enabled:!!r}),{data:i}=p({queryKey:["character-shows",s?.id],queryFn:async()=>{const{data:t,error:l}=await m.from("show_characters").select(`
          role,
          voice_actor_name,
          voice_actor_image,
          shows (id, title_english, title_romaji, poster_url, slug)
        `).eq("character_id",s.id);if(l)throw l;return t},enabled:!!s?.id});if(u.useEffect(()=>{s&&!h.current&&(h.current=!0,d([`/character/${r}`]))},[s,r,d]),j)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-primary"})});if(!s)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-2xl font-bold mb-4",children:a("characters.noCharactersFound")}),e.jsx(o,{to:"/characters",children:e.jsxs(_,{className:"rounded-full",children:[e.jsx(g,{className:"w-4 h-4 mr-2"}),a("characters.backToCharacters")]})})]})});const n=`${s.name_full} - Anime Character | What-Anime`,c=s.description?s.description.replace(/<[^>]+>/g,"").slice(0,155)+"...":`Learn about ${s.name_full}${i&&i.length>0?` from ${i[0].shows.title_english||i[0].shows.title_romaji}`:""}. View character details, anime appearances, and more.`,w={"@context":"https://schema.org","@type":"Person",name:s.name_full,alternateName:s.name_native,image:s.image_url,description:s.description?.replace(/<[^>]+>/g,"").slice(0,300),url:`https://www.what-anime.com/character/${r}`};return e.jsxs(e.Fragment,{children:[e.jsxs(b,{children:[e.jsx("title",{children:n}),e.jsx("meta",{name:"description",content:c}),e.jsx("meta",{property:"og:title",content:n}),e.jsx("meta",{property:"og:description",content:c}),e.jsx("meta",{property:"og:image",content:s.image_url||""}),e.jsx("meta",{property:"og:type",content:"profile"}),e.jsx("meta",{property:"og:url",content:`https://www.what-anime.com/character/${r}`}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:n}),e.jsx("meta",{name:"twitter:description",content:c}),e.jsx("meta",{name:"twitter:image",content:s.image_url||""}),e.jsx("link",{rel:"canonical",href:`https://www.what-anime.com/character/${r}`}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(w)})]}),e.jsxs("div",{className:"min-h-screen",children:[e.jsxs("div",{className:"relative h-64 overflow-hidden bg-gradient-to-b from-primary/20 to-background",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-background to-transparent"}),e.jsxs(o,{to:"/characters",className:"absolute top-6 left-6 glass-card px-4 py-2 hover:bg-white/10 transition-colors flex items-center gap-2 z-10",children:[e.jsx(g,{className:"w-4 h-4"}),a("characters.backToCharacters")]})]}),e.jsx("div",{className:"px-4 -mt-32 relative z-10",children:e.jsxs("div",{className:"mx-auto max-w-4xl",children:[e.jsxs("div",{className:"grid gap-8 md:grid-cols-[250px_1fr]",children:[e.jsx("div",{className:"glass-card overflow-hidden rounded-xl",children:s.image_url?e.jsx("img",{src:s.image_url,alt:s.name_full,className:"w-full aspect-[3/4] object-cover"}):e.jsx("div",{className:"w-full aspect-[3/4] flex items-center justify-center bg-muted",children:e.jsx(f,{className:"w-16 h-16 text-muted-foreground"})})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-2",children:s.name_full}),s.name_native&&e.jsx("p",{className:"text-xl text-muted-foreground",children:s.name_native}),s.name_alternative&&s.name_alternative.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Also known as: ",s.name_alternative.join(", ")]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4",children:[s.favorites&&s.favorites>0&&e.jsxs("div",{className:"flex items-center gap-2 glass-card px-4 py-2 rounded-full",children:[e.jsx(k,{className:"w-4 h-4 text-primary fill-primary"}),e.jsxs("span",{className:"text-sm font-medium",children:[s.favorites.toLocaleString()," ",a("characters.favorites")]})]}),s.gender&&e.jsxs("div",{className:"flex items-center gap-2 glass-card px-4 py-2 rounded-full",children:[e.jsx(f,{className:"w-4 h-4 text-secondary"}),e.jsxs("span",{className:"text-sm font-medium",children:[a("characters.gender"),": ",s.gender]})]}),s.date_of_birth&&e.jsxs("div",{className:"flex items-center gap-2 glass-card px-4 py-2 rounded-full",children:[e.jsx(L,{className:"w-4 h-4 text-accent"}),e.jsxs("span",{className:"text-sm font-medium",children:[a("characters.birthday"),": ",s.date_of_birth]})]}),s.blood_type&&e.jsxs("div",{className:"flex items-center gap-2 glass-card px-4 py-2 rounded-full",children:[e.jsx(C,{className:"w-4 h-4 text-destructive"}),e.jsxs("span",{className:"text-sm font-medium",children:[a("characters.bloodType")," ",s.blood_type]})]})]}),s.description&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold mb-3",children:"About"}),e.jsx("div",{className:"text-muted-foreground leading-relaxed prose prose-invert max-w-none",dangerouslySetInnerHTML:{__html:$(s.description)}})]})]})]}),i&&i.length>0&&e.jsxs("div",{className:"mt-12",children:[e.jsx("h2",{className:"text-2xl font-bold mb-6",children:a("characters.appearsIn")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4",children:i.map((t,l)=>e.jsxs(o,{to:`/shows/${t.shows.slug||t.shows.id}`,className:"glass-card rounded-xl overflow-hidden group hover:scale-105 transition-transform",children:[e.jsx("div",{className:"aspect-[2/3] bg-muted overflow-hidden",children:t.shows.poster_url?e.jsx("img",{src:t.shows.poster_url,alt:t.shows.title_english||t.shows.title_romaji||"Anime",className:"w-full h-full object-cover group-hover:scale-110 transition-transform",loading:"lazy"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("span",{className:"text-4xl",children:"🎬"})})}),e.jsxs("div",{className:"p-3",children:[e.jsx("h3",{className:"font-semibold text-sm line-clamp-2",children:t.shows.title_english||t.shows.title_romaji}),t.role&&e.jsx("span",{className:`text-xs mt-1 inline-block px-2 py-0.5 rounded-full ${t.role==="MAIN"?"bg-primary/20 text-primary":"bg-muted text-muted-foreground"}`,children:t.role==="MAIN"?a("characters.main"):a("characters.supporting")})]})]},l))})]}),s.anilist_id&&e.jsx("div",{className:"mt-8 text-center",children:e.jsx("a",{href:`https://anilist.co/character/${s.anilist_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"View on AniList →"})})]})})]})]})}export{M as default};