text: (this["webpackJsonpmovie-time"]=this["webpackJsonpmovie-time"]||[]).push([[4],{101:function(e,t,n){},123:function(e,t,n){},124:function(e,t,n){},125:function(e,t,n){},126:function(e,t,n){},218:function(e,t,n){},233:function(e,t,n){},234:function(e,t,n){},248:function(e,t,n){"use strict";n.r(t);var c=n(46),a=n(0),r=n(1),i=n(42),o=(n(101),n(121)),s=n.n(o),u=n(19),l=n(60),d=n.n(l),j=n(61),h=n(103),b=n.n(h),v="d212dc1bfc2d8009f736f68f2e71938f",f="https://image.tmdb.org/t/p/original",O="https://api.themoviedb.org/3",p={fetchNowPlaying:"/movie/now_playing?api_key=".concat(v,"&language=en-us"),fetchTrending:"/trending/all/week?api_key=".concat(v,"&language=en-us"),fetchTopRated:"/movie/top_rated?api_key=".concat(v,"&language=en-us"),fetchActionMovies:"/discover/movie?api_key=".concat(v,"&with_genres=28"),fetchComedyMovies:"/discover/movie?api_key=".concat(v,"&with_genres=35"),fetchHorrorMovies:"/discover/movie?api_key=".concat(v,"&with_genres=27"),fetchRomanceMovies:"/discover/movie?api_key=".concat(v,"&with_genres=10749"),fetchDocumentaries:"/discover/movie?api_key=".concat(v,"&with_genres=99"),fetchSuggest:"/search/keyword?api_key=".concat(v),fetchSearchMovie:"/search/movie?api_key=".concat(v)},m=function(e){var t;switch(e){case"now-playing":t=p.fetchNowPlaying;break;case"all":t=p.fetchTrending;break;case"top-rated":t=p.fetchTopRated;break;case"actions":t=p.fetchActionMovies;break;case"comedy":t=p.fetchComedyMovies;break;case"horror":t=p.fetchHorrorMovies;break;case"romance":t=p.fetchRomanceMovies;break;case"documentaries":t=p.fetchDocumentaries;break;case"suggest":t=p.fetchSuggest;break;case"search":t=p.fetchSearchMovie;break;default:t=""}return t},_=b.a.create({baseURL:O}),y=function(e){return{type:"FETCH_SUGGEST_SUCCESS",payload:e}},g=function(e){return{type:"SET_TRAILER_YOUTUBE_KEY",payload:e}},x=function(e){return function(){var t=Object(j.a)(d.a.mark((function t(n){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,_.get(O+"/movie/".concat(e,"/videos?api_key=")+v).then((function(e){var t;if((null===(t=e.data.results)||void 0===t?void 0:t.length)>0){var c=e.data.results[0].key;n(g(c))}})).catch((function(e){console.log(e)}));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},T=function(e,t,n,c){return function(){var a=Object(j.a)(d.a.mark((function a(r){var i;return d.a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return r(t>1?{type:"FETCH_MOVIES_LOADMORE_BEGIN"}:{type:"FETCH_MOVIES_BEGIN"}),i="search"===e?"&query=".concat(n,"&page=").concat(t,"&year=").concat(c):"&page=".concat(t),a.next=4,_.get(m(e)+i).then((function(e){r({type:"FETCH_MOVIES_SUCCESS",payload:e.data})})).catch((function(e){var t;r({type:"FETCH_MOVIES_ERROR",payload:null===(t=e.response)||void 0===t?void 0:t.data})}));case 4:case"end":return a.stop()}}),a)})));return function(e){return a.apply(this,arguments)}}()},E=function(e){return{type:"FETCH_DETAIL_MOVIE_SUCCESS",payload:e}},S=n(3),C=n(8),k=function(e){var t=e.scrolled,n=e.children;return Object(C.jsx)("div",{className:t?"header__scrolled header container-fluid":" header container-fluid",children:n})};k.Title=function(){var e=Object(u.b)(),t=Object(S.f)();return Object(C.jsxs)("label",{onClick:function(){return e(T("all",1)),void t.push({pathname:"/"})},className:"header__title",children:[Object(C.jsx)("b",{children:"MOVIE"}),"TIME"]})},k.Search=function(e){var t=e.searchActive,n=e.setSearchActive,c=Object(i.a)(e,["searchActive","setSearchActive"]);return Object(C.jsxs)("div",{className:"header__search",children:[Object(C.jsx)(s.a,{onClick:function(){return n((function(e){return!e}))}}),Object(C.jsx)(k.SearchInput,Object(r.a)({active:t},c))]})},k.SearchInput=function(e){var t=e.active,n=e.selectSuggest,r=e.suggest,i=e.searchKeyword,o=e.setSearchKeyword,s=Object(a.useState)(!1),l=Object(c.a)(s,2),h=l[0],b=l[1],v=Object(u.b)();return Object(a.useEffect)((function(){t||b(!1)}),[t]),Object(a.useEffect)((function(){var e;i&&v((e=i,function(){var t=Object(j.a)(d.a.mark((function t(n){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n({type:"FETCH_SUGGEST_BEGIN"}),t.next=3,_.get(m("suggest")+"&query=".concat(e)).then((function(e){var t=e.data.results.filter((function(e,t){return t<=10}));n(y(t))})).catch((function(e){var t;n({type:"FETCH_SUGGEST_ERROR",payload:null===(t=e.response)||void 0===t?void 0:t.data})}));case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()))}),[i]),Object(C.jsxs)("div",{className:t?"header__search--active":"header__search--deactive",children:[Object(C.jsx)("input",{type:"text",value:i,onKeyPress:function(e){13===e.charCode&&(e.preventDefault(),n(e.target.value),b(!1))},onChange:function(e){var t=e.target;return o(t.value)},onFocus:function(){return b((function(e){return!e}))},placeholder:"Search Movie"}),Object(C.jsx)("div",{className:h&&r&&i?"header__search--suggest":"header__search--suggest_deactive",children:null===r||void 0===r?void 0:r.map((function(e,t){return Object(C.jsx)("li",{onClick:function(){return[o(e.name),n(e.name),b(!1)]},children:e.name},t)}))})]})};var N=k,w=function(e){var t=e.scrolled,n=Object(i.a)(e,["scrolled"]);return Object(C.jsxs)(N,{scrolled:t,children:[Object(C.jsx)(N.Title,{}),Object(C.jsx)(N.Search,Object(r.a)({},n))]})},I=(n(123),function(e){var t=e.children;return Object(C.jsx)("div",{className:"nav container-fluid",children:t})});I.Button=function(e){var t=e.children,n=Object(i.a)(e,["children"]);return Object(C.jsx)("button",Object(r.a)(Object(r.a)({},n),{},{children:t}))};var M=I,R=function(e){var t=e.tabs,n=e.paramsType,c=e.activeTab,a=e.setActiveTab,r=Object(u.b)(),i=Object(S.f)();return Object(C.jsx)(M,{children:t.map((function(e,t){return Object(C.jsx)(M.Button,{onClick:function(){return function(e){a(e),n!==e.paramsType&&(r(T(e.paramsType,1)),i.push("/".concat(e.paramsType)))}(e)},className:c.title===e.title?"nav__active":"",children:e.title},t)}))})},D=(n(124),function(e){var t=e.children;return Object(C.jsx)("div",{className:"shotgrid container-fluid",children:t})});D.Card=function(e){var t=e.children,n=Object(i.a)(e,["children"]);return Object(C.jsx)("div",Object(r.a)(Object(r.a)({className:"shotgrid__card"},n),{},{children:t}))},D.CardHeader=function(e){var t=e.poster_path;return Object(C.jsx)("img",{loading:"eager",src:f+t,className:"shotgrid__card--header",alt:""})},D.CardBodyHidden=function(e){var t=e.overview,n=e.id,c=e.handleClickTrailer,a=(e.name,Object(i.a)(e,["overview","id","handleClickTrailer","name"])),o=Object(S.f)();return Object(C.jsxs)("div",{className:"shotgrid__card--hidden",children:[Object(C.jsx)("div",{className:"top-section",children:Object(C.jsx)(D.CardBodyTitleScore,Object(r.a)({},a))}),Object(C.jsx)("p",{className:"mid-section",children:t}),Object(C.jsxs)("div",{className:"bottom-section",children:[Object(C.jsx)("button",{className:"button__primaryblue mr10",onClick:function(){return c(n)},children:"Play Trailer"}),Object(C.jsx)("button",{className:"button__borderwhite",onClick:function(){return o.push({pathname:"/info-movie",search:"?id=".concat(n)})},children:"View Info"})]})]})},D.CardBody=function(e){var t=Object.assign({},e);return Object(C.jsx)("div",{className:"shotgrid__card--body",children:Object(C.jsx)(D.CardBodyTitleScore,Object(r.a)({},t))})},D.CardBodyTitleScore=function(e){var t=e.title,n=e.vote_average;return Object(C.jsxs)(C.Fragment,{children:[Object(C.jsx)("h4",{className:"title",children:t}),Object(C.jsx)("p",{className:"score",children:n})]})};var F=D,H=function(){var e=Object(u.b)(),t=Object(u.c)((function(e){return e.movies.movies})),n=Object(a.useState)(!1),i=Object(c.a)(n,2),o=i[0],s=i[1],l=function(t){e(x(t))};return Object(C.jsx)(F,{children:null===t||void 0===t?void 0:t.map((function(e,t){return Object(C.jsxs)(F.Card,{onMouseEnter:function(){return s(t)},onMouseLeave:function(){return s(!1)},children:[Object(C.jsx)(F.CardHeader,Object(r.a)({},e)),o===t?Object(C.jsx)(F.CardBodyHidden,Object(r.a)(Object(r.a)({},e),{},{handleClickTrailer:l})):Object(C.jsx)(F.CardBody,Object(r.a)({},e))]},t)}))})},A=(n(125),function e(){var t=Object(u.b)(),n=Object(u.c)((function(e){return e.movies.moviesBanner}));return Object(a.useEffect)((function(){t(function(){var e=Object(j.a)(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t({type:"FETCH_MOVIES_BANNER_BEGIN"}),e.next=3,_.get(m("now-playing")).then((function(e){var n,c=(null===e||void 0===e||null===(n=e.data)||void 0===n?void 0:n.results).filter((function(e){return e.backdrop_path}));t({type:"FETCH_MOVIES_BANNER_SUCCESS",payload:c[Math.floor(Math.random()*c.length-1)]})})).catch((function(e){var n;t({type:"FETCH_MOVIES_BANNER_ERROR",payload:null===(n=e.response)||void 0===n?void 0:n.data})}));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}),[]),Object(C.jsx)(C.Fragment,{children:n&&Object(C.jsx)("header",{className:"banner",style:{backgroundImage:"url(".concat(f).concat(null===n||void 0===n?void 0:n.backdrop_path,")")},children:Object(C.jsx)(e.Content,{content:n,handleClickTrailer:function(e){t(x(e))}})})})});A.Content=function(e){var t,n,c=e.handleClickTrailer,a=e.content,r=Object(S.f)();return Object(C.jsxs)("div",{className:"banner__content container-fluid",children:[Object(C.jsx)("h1",{className:"banner__content--title",children:(null===a||void 0===a?void 0:a.title)||(null===a||void 0===a?void 0:a.name)||(null===a||void 0===a?void 0:a.original_name)}),Object(C.jsxs)("div",{className:"banner__content--buttons",children:[Object(C.jsx)("button",{className:"button__primaryblue mr10",onClick:function(){return c(a.id)},children:"Play Trailer"}),Object(C.jsx)("button",{className:"button__borderwhite mr10",onClick:function(){return r.push({pathname:"/info-movie",search:"?id=".concat(a.id)})},children:"View Info"})]}),Object(C.jsx)("h1",{className:"banner__content--description",children:(t=null===a||void 0===a?void 0:a.overview,n=150,(null===t||void 0===t?void 0:t.length)>n?t.substr(0,n-1)+"...":t)}),Object(C.jsx)("h1",{className:"banner__content--score",children:null===a||void 0===a?void 0:a.vote_average})]})};var B=A,U=function(){return Object(C.jsx)(B,{children:Object(C.jsx)(B.Content,{})})},V=(n(126),n(129)),Y=n.n(V),L=n(130),G=n.n(L),P=(n(127),n(47)),K=n.n(P),q=function(e){var t=e.setStartDate,n=e.dateText,c=e.setDateText;return Object(a.useEffect)((function(){if(n){var e=K()(n).format("YYYY");t(e)}}),[n]),Object(C.jsx)("div",{className:"filter container-fluid",children:Object(C.jsxs)("div",{className:"filter__button",children:[Object(C.jsx)(Y.a,{}),Object(C.jsx)("h4",{children:"FILTER:"}),Object(C.jsxs)("div",{className:"filter__by-year",children:[Object(C.jsx)("h5",{children:"Year"}),Object(C.jsx)(G.a,{selected:n,onChange:function(e){return c(e)},showYearPicker:!0,dateFormat:"yyyy",maxDate:new Date,yearItemNumber:9})]})]})})},J=function(e){var t=e.setStartDate,n=e.setDateText,c=Object(i.a)(e,["setStartDate","setDateText"]);return Object(a.useEffect)((function(){return function(){n(),t("")}}),[]),Object(C.jsx)(q,Object(r.a)({setStartDate:t,setDateText:n},c))},z=(n(218),function(e){var t=e.imageBackDrop,n=e.children;return Object(C.jsx)("div",{className:"detailmovie container-fluid",style:{backgroundImage:t?"url(".concat(f).concat(t,")"):""},children:n})});z.Cover=function(e){var t=e.imageUrl;return Object(C.jsx)("div",{className:"detailmovie__cover",children:Object(C.jsx)("img",{loading:"lazy",src:f+t,alt:""})})},z.Info=function(e){var t=e.detail;return Object(C.jsxs)("div",{className:"detailmovie__info",children:[Object(C.jsxs)("div",{className:"detailmovie__info--title",children:[Object(C.jsx)("h1",{children:null===t||void 0===t?void 0:t.original_title}),Object(C.jsx)("span",{children:(null===t||void 0===t?void 0:t.release_date)?"(".concat(K()(null===t||void 0===t?void 0:t.release_date).format("YYYY"),")"):""})]}),Object(C.jsxs)("div",{className:"detailmovie__info--overview",children:[Object(C.jsx)("h3",{children:"Overview"}),Object(C.jsx)("p",{children:null===t||void 0===t?void 0:t.overview})]})]})};var Q=z,W=function(){var e=Object(u.b)(),t=new URLSearchParams(document.location.search.substring(1)).get("id"),n=Object(u.c)((function(e){return e.movies.detailMovie}));return Object(a.useEffect)((function(){var n;return e((n=t,function(){var e=Object(j.a)(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t({type:"FETCH_DETAIL_MOVIE_BEGIN"}),e.next=3,_.get(O+"/movie/".concat(n,"?api_key=").concat(v)).then((function(e){t(E(e.data))})).catch((function(e){var n;t({type:"FETCH_DETAIL_MOVIE_ERROR",payload:null===(n=e.response)||void 0===n?void 0:n.data})}));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())),function(){e(E(null))}}),[]),Object(C.jsx)(Q,{imageBackDrop:null===n||void 0===n?void 0:n.poster_path,children:n?Object(C.jsxs)(C.Fragment,{children:[Object(C.jsx)(Q.Cover,{imageUrl:null===n||void 0===n?void 0:n.poster_path}),Object(C.jsx)(Q.Info,{detail:n})]}):Object(C.jsx)(C.Fragment,{})})},X=n(219),Z=(n(233),function(){var e=Object(u.b)(),t=Object(u.c)((function(e){return e.movies.trailerYoutubeKey}));Object(a.useEffect)((function(){o(t)}),[t]);var n=Object(a.useState)(""),r=Object(c.a)(n,2),i=r[0],o=r[1];return Object(C.jsx)("div",{className:"trailer",onClick:function(){return e(g(null))},style:{display:t?"":"none"},children:i&&Object(C.jsx)(X.a,{className:"trailer__content",videoId:i,opts:{height:"390",width:"640",playerVars:{autoplay:1}}})})});n(234),t.default=function(){var e=Object(S.g)().type,t=Object(a.useState)(!1),n=Object(c.a)(t,2),r=n[0],i=n[1],o=Object(u.b)(),s=Object(S.f)(),l=Object(u.c)((function(e){return e.suggest})).suggest,d=Object(u.c)((function(e){return e.movies})),j=d.isLoadingLoadMoreMovies,h=d.currentPage,b=d.isLoadingMovies,v=d.totalPages,f=new URLSearchParams(document.location.search.substring(1)),O=f.get("query"),p=f.get("year"),m=Object(a.useState)({title:"All",paramsType:"all"}),_=Object(c.a)(m,2),y=_[0],g=_[1],x=Object(a.useState)(""),E=Object(c.a)(x,2),k=E[0],N=E[1],I=Object(a.useState)(!1),M=Object(c.a)(I,2),D=M[0],F=M[1],A=Object(a.useState)(""),B=Object(c.a)(A,2),V=B[0],Y=B[1],L=Object(a.useState)(),G=Object(c.a)(L,2),P=G[0],q=G[1];Object(a.useEffect)((function(){if("search"!==e){var t=z.find((function(t){return t.paramsType===e}));g(t||z[0]),o(T((null===t||void 0===t?void 0:t.paramsType)||"all",h+1))}else o(T("search",1,O,p)),F(!0)}),[]),Object(a.useEffect)((function(){if(Y(p),p){var e=K()("".concat(p,"-01-01T10:00:00")).toDate();q(e)}O&&N(O)}),[O,p]),Object(a.useEffect)((function(){V&&(o(T("search",1,O,V)),s.push({pathname:"/search",search:"?query=".concat(O,"&year=").concat(V)}))}),[V]);var z=[{title:"All",paramsType:"all"},{title:"Top Rated",paramsType:"top-rated"},{title:"Actions",paramsType:"actions"},{title:"Comedy",paramsType:"comedy"},{title:"Horror",paramsType:"horror"},{title:"Romance",paramsType:"romance"},{title:"Documentaries",paramsType:"documentaries"}];return window.onscroll=function(){if("info-movie"!==e){var t=window.scrollY,n=window.document.documentElement,c=n.offsetHeight,a=n.scrollTop,r=n.scrollHeight;i(t>50),c+a===r&&!j&&!b&&h<v&&o("search"!==e?T(e||"all",h+1):T("search",h+1,O,V))}},Object(C.jsxs)(C.Fragment,{children:[Object(C.jsx)(Z,{}),Object(C.jsx)(w,{scrolled:r,selectSuggest:function(e){o(T("search",1,e)),s.push({pathname:"/search",search:"?query=".concat(e)})},suggest:l,searchKeyword:k,setSearchKeyword:N,searchActive:D,setSearchActive:F}),"info-movie"===e?Object(C.jsx)(W,{}):Object(C.jsxs)(C.Fragment,{children:["search"===e?Object(C.jsx)(J,{setStartDate:Y,dateText:P,setDateText:q}):Object(C.jsxs)(C.Fragment,{children:[Object(C.jsx)(U,{}),Object(C.jsx)(R,{tabs:z,paramsType:e,activeTab:y,setActiveTab:g})]}),Object(C.jsx)(H,{})]})]})}}}]);
  //# sourceMappingURL=4.8f900423.chunk.js.map