import{j as e}from"./vendor-ui-CUslpDkL.js";import{i as y,r as x,L as n}from"./vendor-react-Dg0Tra3e.js";import{u as p}from"./vendor-query-CN1EccJz.js";import{u as N,s as d,n as w,B as b,R as v,C as _,S}from"./index-CJqEbhJN.js";import{C as $,a as A}from"./card-BSxrPlO5.js";import{B as L}from"./badge-But4vkun.js";import{u as F}from"./useIndexNow-C3dRJY1T.js";import{A as E}from"./arrow-left-DtOv4JyO.js";import{F as C}from"./film-B3I-fyoz.js";import"./vendor-supabase-yzuDJZPy.js";import"./vendor-motion-CiNtJfg1.js";const Q=()=>{const{slug:a}=y(),{t:r}=N(),{pingIndexNow:l}=F(),c=x.useRef(!1),{data:s,isLoading:h}=p({queryKey:["studio",a],queryFn:async()=>{const{data:t,error:i}=await d.from("studios").select("*").eq("slug",a).maybeSingle();if(i)throw i;return t},enabled:!!a}),{data:o,isLoading:g}=p({queryKey:["studio-shows",s?.id],queryFn:async()=>{const{data:t,error:i}=await d.from("show_studios").select("show_id").eq("studio_id",s?.id);if(i)throw i;const m=t?.map(j=>j.show_id)||[];if(m.length===0)return[];const{data:f,error:u}=await d.from("shows").select("*").in("id",m).order("popularity",{ascending:!1,nullsFirst:!1}).limit(100);if(u)throw u;return f},enabled:!!s?.id});return x.useEffect(()=>{s&&!c.current&&(c.current=!0,l([`/studio/${a}`]))},[s,a,l]),h||g?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((t,i)=>e.jsx("div",{className:"aspect-[2/3] bg-muted rounded-lg"},i))})]})}):s?e.jsxs(e.Fragment,{children:[e.jsxs(w,{children:[e.jsx("title",{children:`${s.name} - Anime Studio | What-Anime`}),e.jsx("meta",{name:"description",content:`Explore all anime produced by ${s.name}. ${s.description||""} Founded in ${s.founded_year||"N/A"}. Browse their complete anime catalog.`}),e.jsx("link",{rel:"canonical",href:`https://www.what-anime.com/studio/${a}`}),e.jsx("meta",{property:"og:title",content:`${s.name} - Anime Studio`}),e.jsx("meta",{property:"og:description",content:s.description||`Explore anime by ${s.name}`}),e.jsx("meta",{property:"og:url",content:`https://www.what-anime.com/studio/${a}`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"Organization",name:s.name,description:s.description,url:`https://www.what-anime.com/studio/${a}`,foundingDate:s.founded_year?.toString()})})]}),e.jsxs("main",{className:"container mx-auto px-4 py-8",children:[e.jsx(n,{to:"/studios",children:e.jsxs(b,{variant:"ghost",className:"mb-6 group",children:[e.jsx(E,{className:"mr-2 h-4 w-4 transition-transform group-hover:-translate-x-1"}),r("studios.allStudios")]})}),e.jsxs("div",{className:"rounded-2xl p-8 mb-8 bg-gradient-to-br from-primary/20 to-primary/5 border-l-4 border-primary",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(v,{className:"w-8 h-8 text-primary"})}),e.jsxs("div",{children:[e.jsx(L,{className:"mb-2",children:s.is_animation_studio?r("studios.animationStudio"):r("studios.productionCompany")}),e.jsx("h1",{className:"text-4xl md:text-5xl font-bold",children:s.name})]})]}),e.jsx("p",{className:"text-lg text-muted-foreground max-w-3xl mb-4",children:s.description||`Explore the anime catalog from ${s.name}.`}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-sm text-muted-foreground",children:[s.founded_year&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(_,{className:"w-4 h-4"}),r("studios.founded")," ",s.founded_year]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(C,{className:"w-4 h-4"}),o?.length||0," ",r("studios.anime")]})]})]}),e.jsxs("h2",{className:"text-2xl font-bold mb-6",children:["Anime by ",s.name]}),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(t=>e.jsx(n,{to:`/shows/${t.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:t.poster_url||"/placeholder.svg",alt:t.title_english||t.title_romaji||"Anime",className:"w-full h-full object-cover",loading:"lazy"}),t.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(S,{className:"w-3 h-3 text-yellow-400 fill-yellow-400"}),e.jsx("span",{className:"text-xs font-semibold",children:t.rating.toFixed(1)})]})]}),e.jsxs(A,{className:"p-3",children:[e.jsx("h3",{className:"font-semibold text-sm line-clamp-2 group-hover:text-primary transition-colors",children:t.title_english||t.title_romaji}),e.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs text-muted-foreground",children:[t.season_year&&e.jsx("span",{children:t.season_year}),t.episodes_count&&e.jsxs("span",{children:["• ",t.episodes_count," eps"]})]})]})]})},t.id))}),(!o||o.length===0)&&e.jsx("div",{className:"text-center py-20 text-muted-foreground",children:r("studios.noAnimeLinked")})]})]}):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:"Studio Not Found"}),e.jsx(n,{to:"/studios",className:"text-primary hover:underline",children:r("studios.allStudios")})]})};export{Q as default};