"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[657],{2850:function(e,t,a){var l=a(7437),s=a(2265),r=a(3145),o=a(3407);let n=e=>{let{src:t,width:a,quality:l}=e;if(t.startsWith("/")){let e=["w=".concat(a)];l?e.push("q=".concat(l)):e.push("q=75");let s=e.join("&"),r="/_next/image";return r.endsWith("/")&&(r=r.substring(0,r.length-1)),"".concat(r,"?url=").concat(t,"&").concat(s)}let s="".concat(o.O.NEXT_PUBLIC_IMAGE_DOMAIN,"/tmdb:w_").concat(a);return t.replace("image.tmdb.org",s)},i=(0,s.forwardRef)(function(e,t){return(0,l.jsx)(r.default,{...e,loader:n,ref:t,alt:e.alt||o.O.NEXT_PUBLIC_SITE_NAME})});t.Z=i},8467:function(e,t,a){a.d(t,{_:function(){return m}});var l=a(7437),s=a(6375),r=a(6481),o=a(2265),n=a(4171),i=a(2381),d=a(3448),c=a(9376),u=a(2850);t.Z=e=>{let{title:t,shows:a}=e,s=(0,c.usePathname)(),r=o.useRef(null),[u,h]=o.useState(!1),p=e=>{if(!r.current)return;h(!0);let{scrollLeft:t,offsetWidth:a}=r.current,l=a>1400?60:.04*a;r.current.scrollTo({left:"left"===e?t-(a-2*l):t+(a-2*l),behavior:"smooth"}),0===t&&"left"===e?r.current.scrollTo({left:r.current.scrollWidth,behavior:"smooth"}):t+a===r.current.scrollWidth&&"right"===e&&r.current.scrollTo({left:0,behavior:"smooth"})};return(0,l.jsx)("section",{"aria-label":"Carousel of shows",className:"relative my-[3vw] p-0",children:0!==a.length&&(0,l.jsxs)("div",{className:"space-y-1 sm:space-y-2.5",children:[(0,l.jsx)("h2",{className:"m-0 px-[4%] text-lg font-semibold text-foreground/80 transition-colors hover:text-foreground sm:text-xl 2xl:px-[60px]",children:null!=t?t:"-"}),(0,l.jsxs)("div",{className:"relative w-full items-center justify-center overflow-hidden",children:[(0,l.jsx)(i.z,{"aria-label":"Scroll to left",variant:"ghost",className:(0,d.cn)("absolute left-0 top-0 z-10 mr-2 hidden h-full w-[4%] items-center justify-center rounded-l-none bg-transparent py-0 text-transparent hover:bg-secondary/90 hover:text-foreground md:block 2xl:w-[60px]",u?"md:block":"md:hidden"),onClick:()=>p("left"),children:(0,l.jsx)(n.P.chevronLeft,{className:"h-8 w-8","aria-hidden":"true"})}),(0,l.jsx)("div",{ref:r,className:"no-scrollbar m-0 grid auto-cols-[calc(100%/3)] grid-flow-col overflow-x-auto overflow-y-hidden px-[4%] py-0 duration-500 ease-in-out sm:auto-cols-[25%] md:touch-pan-y lg:auto-cols-[20%] xl:auto-cols-[calc(100%/6)] 2xl:px-[60px]",children:a.map(e=>(0,l.jsx)(m,{show:e,pathname:s},e.id))}),(0,l.jsx)(i.z,{"aria-label":"Scroll to right",variant:"ghost",className:"absolute right-0 top-0 z-10 m-0 ml-2 hidden h-full w-[4%] items-center justify-center rounded-r-none bg-transparent py-0 text-transparent hover:bg-secondary/70 hover:text-foreground md:block 2xl:w-[60px]",onClick:()=>p("right"),children:(0,l.jsx)(n.P.chevronRight,{className:"h-8 w-8","aria-hidden":"true"})})]})]})})};let m=e=>{var t,a,o,n;let{show:i}=e;return(0,l.jsxs)("picture",{className:"relative aspect-[2/3]",children:[(0,l.jsx)("a",{className:"pointer-events-none","aria-hidden":!1,role:"link","aria-label":(0,d.s8)(i),href:"/".concat(i.media_type,"/").concat((0,d.QF)(i.id,(0,d.s8)(i)))}),(0,l.jsx)(u.Z,{src:(null!==(t=i.poster_path)&&void 0!==t?t:i.backdrop_path)?"https://image.tmdb.org/t/p/w500".concat(null!==(a=i.poster_path)&&void 0!==a?a:i.backdrop_path):"/images/grey-thumbnail.jpg",alt:null!==(n=null!==(o=i.title)&&void 0!==o?o:i.name)&&void 0!==n?n:"poster",className:"h-full w-full cursor-pointer rounded-lg px-1 transition-all md:hover:scale-110",fill:!0,sizes:"(max-width: 768px) 50vw, (max-width: 1200px) 100vw, 33vw",style:{objectFit:"cover"},onClick:()=>{let e=(0,d.s8)(i),t=i.media_type===r.D.TV?"tv-shows":"movies";window.history.pushState(null,"","".concat(t,"/").concat((0,d.QF)(i.id,e))),s.a.setState({show:i,open:!0,play:!0})},onError:e=>{e.currentTarget.src="/images/grey-thumbnail.jpg"}})]})}},7657:function(e,t,a){a.d(t,{Z:function(){return v}});var l=a(7437),s=a(6375),r=a(7282),o=a(8467),n=a(9376),i=a(8075),d=a(7590),c=a(3448);function u(e){let{className:t,...a}=e;return(0,l.jsx)("div",{className:(0,c.cn)("animate-pulse rounded-md bg-muted",t),...a})}let m={hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.25}}},h={hidden:{opacity:0},visible:{opacity:1}};var p=a(2850),x=e=>{let{count:t=6,classname:a="",variant:s="with-title"}=e,r=(0,i.R)();return(0,l.jsx)(l.Fragment,{children:"with-title"===s?(0,l.jsxs)("div",{className:(0,c.cn)("no-scrollbar container mx-0 w-full max-w-[100%] overflow-x-auto overflow-y-hidden",a),children:[(0,l.jsx)(u,{className:"h-[1.62rem] w-28 rounded bg-neutral-700"}),(0,l.jsx)("div",{className:(0,c.cn)("xxs:grid-cols-2 xxs:gap-x-1.5 xxs:gap-y-5 mt-2.5 grid w-fit gap-y-3.5 xs:grid-cols-3 xs:gap-y-7 sm:grid-cols-3 sm:gap-y-10 md:grid-cols-4 md:gap-y-12 lg:gap-y-14 xl:grid-cols-6 xl:gap-y-16",r.query&&"max-sm:grid-cols-3 max-[375px]:grid-cols-2"),children:Array.from({length:t},(e,t)=>(0,l.jsx)(d.E.div,{variants:h,children:(0,l.jsx)("picture",{className:"relative aspect-[2/3]",children:(0,l.jsx)(p.Z,{alt:"poster",src:"/images/grey-thumbnail.jpg",fill:!0,sizes:"(max-width: 768px) 50vw, (max-width: 1200px) 100vw, 33vw",className:"h-full w-full cursor-pointer rounded-lg px-1 transition-all md:hover:scale-110",style:{objectFit:"cover"}})})},t))})]}):(0,l.jsx)(d.E.div,{className:"no-scrollbar container mx-0 flex w-full items-center gap-1.5 overflow-x-auto overflow-y-hidden",initial:"hidden",animate:"visible",variants:m,children:Array.from({length:t},(e,t)=>(0,l.jsx)(d.E.div,{variants:h,children:(0,l.jsx)(u,{className:"aspect-[2/3] min-w-[15rem] rounded bg-neutral-700"})},t))})})},v=e=>{let{shows:t,query:a}=e,d=(0,n.usePathname)(),u=(0,s.a)(),m=(0,i.R)();return(0,l.jsxs)("section",{"aria-label":"Grid of shows",className:"container w-full max-w-none",children:[u.open&&(0,l.jsx)(r.Z,{}),(0,l.jsx)("div",{className:"main-view mt-4 min-h-[800px] pt-[5%]",id:"main-view",children:a&&m.loading?(0,l.jsx)(x,{classname:"pl-0"}):!a||(null==t?void 0:t.length)?(0,l.jsx)("div",{className:(0,c.cn)("xxs:grid-cols-2 xxs:gap-x-1.5 xxs:gap-y-5 grid gap-y-3.5 xs:grid-cols-3 xs:gap-y-7 sm:grid-cols-3 sm:gap-y-10 md:grid-cols-4 md:gap-y-12 lg:gap-y-14 xl:grid-cols-6 xl:gap-y-16",a&&"max-sm:grid-cols-3 max-[375px]:grid-cols-2"),children:t.map(e=>(0,l.jsx)(o._,{show:e,pathname:d},e.id))}):(0,l.jsx)("div",{className:"text-center",children:(0,l.jsxs)("div",{className:"inline-block text-left text-sm",children:[(0,l.jsx)("p",{className:"mb-4",children:'Your search for "'.concat(a,'" did not have any matches.')}),(0,l.jsx)("p",{className:"mb-4",children:"Suggestions:"}),(0,l.jsxs)("ul",{className:"list-disc pl-8",children:[(0,l.jsx)("li",{children:"Try different keywords"}),(0,l.jsx)("li",{children:"Looking for a movie or TV show?"}),(0,l.jsx)("li",{children:"Try using a movie, TV show title, an actor or director"}),(0,l.jsx)("li",{children:"Try a genre, like comedy, romance, sports, or drama"})]})]})})})]})}},7282:function(e,t,a){a.d(t,{Z:function(){return _}});var l=a(7437),s=a(4171),r=a(2381),o=a(2265),n=a(9027),i=a(2489),d=a(3448);let c=n.fC;n.xz;let u=n.h_;n.x8;let m=o.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,l.jsx)(n.aV,{ref:t,className:(0,d.cn)("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...s})});m.displayName=n.aV.displayName;let h=o.forwardRef((e,t)=>{let{className:a,children:s,...r}=e;return(0,l.jsxs)(u,{children:[(0,l.jsx)(m,{}),(0,l.jsxs)(n.VY,{ref:t,className:(0,d.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...r,children:[s,(0,l.jsxs)(n.x8,{className:"absolute right-4 top-4 z-[10] rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,l.jsx)(i.Z,{className:"h-6 w-6"}),(0,l.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});h.displayName=n.VY.displayName;let p=o.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,l.jsx)(n.Dx,{ref:t,className:(0,d.cn)("text-lg font-semibold leading-none tracking-tight",a),...s})});p.displayName=n.Dx.displayName;let x=o.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,l.jsx)(n.dk,{ref:t,className:(0,d.cn)("text-sm text-muted-foreground",a),...s})});x.displayName=n.dk.displayName;var v=a(9106),g=a(6375),f=a(6481),w=a(7648),y=a(5107),b=a(2850);let j="undefined"==typeof navigator?"SSR":navigator.userAgent,{isMobile:N}=(0,d.GT)(j),k={playerVars:{rel:0,mute:N()?1:0,loop:1,autoplay:1,controls:0,showinfo:0,disablekb:1,enablejsapi:1,playsinline:1,cc_load_policy:0,modestbranding:3}};var _=()=>{var e,t,a,n,i,u,m,j,_,z,S,T,E,P,C,R,V,L,M,Z,I;let O=(0,g.a)(),A=N(),[D,F]=o.useState(""),[U,q]=o.useState(!0),[B,G]=o.useState([]),[Q,W]=o.useState(!1),[Y,X]=o.useState(O.firstLoad||A),[H,J]=o.useState(k),K=o.useRef(null),$=o.useRef(null);o.useEffect(()=>{(O.firstLoad||A)&&J(e=>({...e,playerVars:{...e.playerVars,mute:1}})),ee()},[]),o.useEffect(()=>{W(!1)},[O]);let ee=async()=>{var e,t,a,l,s,r,o;let n=null===(e=O.show)||void 0===e?void 0:e.id,i=(null===(t=O.show)||void 0===t?void 0:t.media_type)===f.D.TV?"tv":"movie";if(!n||!i)return;let d=await v.Z.findMovieByIdAndType(n,i),c=(null==d?void 0:null===(a=d.keywords)||void 0===a?void 0:a.results)||(null==d?void 0:null===(l=d.keywords)||void 0===l?void 0:l.keywords);if((null==c?void 0:c.length)&&W(!!c.find(e=>"anime"===e.name)),(null==d?void 0:d.genres)&&G(d.genres),null===(r=d.videos)||void 0===r?void 0:null===(s=r.results)||void 0===s?void 0:s.length){let e=(null===(o=d.videos)||void 0===o?void 0:o.results).find(e=>"Trailer"===e.type);(null==e?void 0:e.key)&&F(e.key)}};return(0,l.jsx)(c,{open:O.open,onOpenChange:()=>{O.reset(),!O.show||O.firstLoad?window.history.pushState(null,"","/"):window.history.back()},"aria-label":"Modal containing show's details",children:(0,l.jsxs)(h,{className:"w-full overflow-hidden rounded-md bg-zinc-900 p-0 text-left align-middle shadow-xl dark:bg-zinc-900 sm:max-w-3xl lg:max-w-4xl",children:[(0,l.jsxs)("div",{className:"video-wrapper relative aspect-video",children:[(0,l.jsx)(b.Z,{fill:!0,priority:!0,ref:$,alt:null!==(C=null==O?void 0:null===(e=O.show)||void 0===e?void 0:e.title)&&void 0!==C?C:"poster",className:"-z-40 z-[1] h-auto w-full object-cover",src:"https://image.tmdb.org/t/p/original".concat(null!==(R=null===(t=O.show)||void 0===t?void 0:t.backdrop_path)&&void 0!==R?R:null===(a=O.show)||void 0===a?void 0:a.poster_path),sizes:"(max-width: 768px) 50vw, (max-width: 1200px) 100vw, 33vw"}),D&&(0,l.jsx)(y.Z,{opts:H,onEnd:e=>{e.target.seekTo(0)},onPlay:()=>{if($.current&&($.current.style.opacity="0"),K.current){let e=document.getElementById("video-trailer");e&&e.classList.remove("opacity-0")}},ref:K,onReady:e=>{e.target.playVideo()},videoId:D,id:"video-trailer",title:null!==(L=null!==(V=null===(n=O.show)||void 0===n?void 0:n.title)&&void 0!==V?V:null===(i=O.show)||void 0===i?void 0:i.name)&&void 0!==L?L:"video-trailer",className:"relative aspect-video w-full",style:{width:"100%",height:"100%"},iframeClassName:"relative pointer-events-none w-[100%] h-[100%] z-[-10] opacity-0"}),(0,l.jsxs)("div",{className:"absolute bottom-6 z-20 flex w-full items-center justify-between gap-2 px-10",children:[(0,l.jsx)("div",{className:"flex items-center gap-2.5",children:(0,l.jsx)(w.default,{href:(()=>{var e,t,a;let l=Q?"anime":(null===(e=O.show)||void 0===e?void 0:e.media_type)===f.D.MOVIE?"movie":"tv",s="".concat(null===(t=O.show)||void 0===t?void 0:t.id);if(Q){let e=(null===(a=O.show)||void 0===a?void 0:a.media_type)===f.D.MOVIE?"m":"t";s="".concat(e,"-").concat(s)}return"/watch/".concat(l,"/").concat(s)})(),children:(0,l.jsx)(r.z,{"aria-label":"".concat(U?"Pause":"Play"," show"),className:"group h-auto rounded py-1.5",children:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.P.play,{className:"mr-1.5 h-6 w-6 fill-current","aria-hidden":"true"}),"Play"]})})})}),(0,l.jsx)(r.z,{"aria-label":"".concat(Y?"Unmute":"Mute"," video"),variant:"ghost",className:"h-auto rounded-full bg-neutral-800 p-1.5 opacity-50 ring-1 ring-slate-400 hover:bg-neutral-800 hover:opacity-100 hover:ring-white focus:ring-offset-0 dark:bg-neutral-800 dark:hover:bg-neutral-800",onClick:()=>{if(X(e=>!e),!K.current)return;let e=K.current;Y&&K.current?e.internalPlayer.unMute():K.current&&e.internalPlayer.mute()},children:Y?(0,l.jsx)(s.P.volumeMute,{className:"h-6 w-6","aria-hidden":"true"}):(0,l.jsx)(s.P.volume,{className:"h-6 w-6","aria-hidden":"true"})})]})]}),(0,l.jsxs)("div",{className:"grid gap-2.5 px-10 pb-10",children:[(0,l.jsx)(p,{className:"text-lg font-medium leading-6 text-slate-50 sm:text-xl",children:null!==(M=null===(u=O.show)||void 0===u?void 0:u.title)&&void 0!==M?M:null===(m=O.show)||void 0===m?void 0:m.name}),(0,l.jsxs)("div",{className:"flex items-center space-x-2 text-sm sm:text-base",children:[(0,l.jsxs)("p",{className:"font-semibold text-green-400",children:[null!==(Z=Math.round(Number(null===(j=O.show)||void 0===j?void 0:j.vote_average)/10*100))&&void 0!==Z?Z:"-","% Match"]}),(null===(_=O.show)||void 0===_?void 0:_.release_date)?(0,l.jsx)("p",{children:(0,d.So)(null===(z=O.show)||void 0===z?void 0:z.release_date)}):(null===(S=O.show)||void 0===S?void 0:S.first_air_date)?(0,l.jsx)("p",{children:(0,d.So)(null===(T=O.show)||void 0===T?void 0:T.first_air_date)}):null,(null===(E=O.show)||void 0===E?void 0:E.original_language)&&(0,l.jsx)("span",{className:"grid h-4 w-7 place-items-center text-xs font-bold text-neutral-400 ring-1 ring-neutral-400",children:O.show.original_language.toUpperCase()})]}),(0,l.jsx)(x,{className:"line-clamp-3 text-xs text-slate-50 dark:text-slate-50 sm:text-sm",children:null!==(I=null===(P=O.show)||void 0===P?void 0:P.overview)&&void 0!==I?I:"-"}),(0,l.jsxs)("div",{className:"flex items-center gap-2 text-xs sm:text-sm",children:[(0,l.jsx)("span",{className:"text-slate-400",children:"Genres:"}),B.map(e=>e.name).join(", ")]})]})]})})}},2381:function(e,t,a){a.d(t,{z:function(){return d}});var l=a(7437),s=a(2265),r=a(7053),o=a(535),n=a(3448);let i=(0,o.j)("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),d=s.forwardRef((e,t)=>{let{className:a,variant:s,size:o,asChild:d=!1,...c}=e,u=d?r.g7:"button";return(0,l.jsx)(u,{className:(0,n.cn)(i({variant:s,size:o,className:a})),ref:t,...c})});d.displayName="Button"},6375:function(e,t,a){a.d(t,{a:function(){return l}});let l=(0,a(9625).Ue)()(e=>({open:!1,setOpen:t=>e(()=>({open:t})),firstLoad:!1,setFirstLoad:t=>e(()=>({firstLoad:t})),show:null,setShow:t=>e(()=>({show:t})),play:!1,setPlay:t=>e(()=>({play:t})),reset:()=>e(()=>({show:null,open:!1,play:!1,firstLoad:!1}))}))},8075:function(e,t,a){a.d(t,{R:function(){return s}});var l=a(3448);let s=(0,a(9625).Ue)()(e=>({query:"",setQuery:t=>e(()=>({query:t})),shows:[],setShows:t=>e(()=>({shows:t})),isOpen:!1,setOpen:t=>e(()=>({isOpen:t})),loading:!1,setLoading:t=>e(()=>({loading:t})),reset:()=>e(()=>((0,l.AQ)(),{query:"",shows:[],loading:!1}))}))}}]);