(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1493],{80462:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/greatest-stories",function(){return n(47930)}])},10683:function(e,t,n){"use strict";n.d(t,{H:function(){return g}});var s=n(15311),a=n(91541),o=n(35698),i=n(5724),r=n(6381),l=n.n(r),c=n(20132),u=n(9779),d=n.n(u),h=n(66297);let g=e=>{let{pageIds:t,noResultMessage:n,title:r,isLoading:u,seeAllUrl:g,limitResult:p}=e,{t:f}=(0,i.Z)("common"),j=p||10,[m,x]=(0,c.useState)(1),[v,b]=(0,c.useState)(!1),[C,S]=(0,c.useState)([]),w=async e=>{b(!0);let t=new URLSearchParams;t.append("ids",e.join(","));let n=await fetch("/content/api/getContentStories?".concat(t));S([...C,...(await n.json()).stories.map(e=>({id:e.id,title:e.title,description:e.description,image:e.image,url:"/p/".concat(e.slug),tags:e.tags.map(e=>e.tag),interests:e.interests}))]),b(!1)},L=()=>{x(m+1),w((t||[]).slice((m-1)*j,m*j))};return(0,c.useEffect)(()=>{S([]),x(1),L()},[t]),(0,s.jsxs)("div",{className:d().resultCollectionContainer,children:[r&&(0,s.jsxs)("div",{className:d().titleContainer,children:[(0,s.jsx)("h3",{className:d().titleContent,children:r}),g&&(0,s.jsx)(l(),{href:g,className:d().seeAllLink,children:f("SEE_ALL")})]}),(0,s.jsxs)("div",{className:d().searchResultsContainer,children:[u&&(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(a.G,{})}),!u&&t&&0==t.length&&(0,s.jsx)(s.Fragment,{children:(0,s.jsx)("p",{className:d().noResult,children:n})}),!u&&C.map((e,t)=>(0,s.jsx)(h.y,{...e},e.id))]}),!p&&t&&C.length<t.length&&!u&&(0,s.jsx)(o.f,{onClick:()=>{L()},isLoading:v})]})}},6572:function(e,t,n){"use strict";n.d(t,{O:function(){return g},Y:function(){return h}});var s=n(15311),a=n(91541),o=n(5762),i=n(20132),r=n(9344),l=n.n(r),c=n(10683),u=n(99415),d=n(34447);let h=e=>({tagOptions:(null==e?void 0:e.tags.map(e=>({label:"".concat(e.displayText," (").concat(e.count,")"),value:e.id})).sort((e,t)=>e.label.toLocaleLowerCase().localeCompare(t.label.toLocaleLowerCase())))||[],interestOptions:(null==e?void 0:e.interests.map(e=>({label:"".concat(e.displayText," (").concat(e.count,")"),value:e.id})).sort((e,t)=>e.label.toLocaleLowerCase().localeCompare(t.label.toLocaleLowerCase())))||[],provinceOptions:(null==e?void 0:e.provinces.map(e=>({label:"".concat(e.displayText," (").concat(e.count,")"),value:e.id})).sort((e,t)=>e.label.toLocaleLowerCase().localeCompare(t.label.toLocaleLowerCase())))||[],regionOptions:(null==e?void 0:e.regions.map(e=>({label:"".concat(e.displayText," (").concat(e.count,")"),value:e.id})).sort((e,t)=>e.label.toLocaleLowerCase().localeCompare(t.label)))||[]}),g=e=>{let{}=e,[t,n]=(0,i.useState)(!1),{keyword:r,interests:g,tags:p,provinces:f,regions:j}=(0,d.B)(),{locale:m}=(0,o.useRouter)(),[x,v]=(0,i.useState)([]),[b,C]=(0,i.useState)();return(0,i.useEffect)(()=>{let e=async e=>{try{let t=new URLSearchParams({...f.length>0?{provinces:f.join(",")}:{},...j.length>0?{regions:j.join(",")}:{},...g.length>0?{interests:g.join(",")}:{},...p.length>0?{tags:p.join(",")}:{},...r?{keyword:r}:{},...m?{locale:m}:{}}).toString(),s=await fetch("/content/api/search/stories?".concat(t),{signal:e}),a=await s.json();v(a.pageIds),C(a.filters),n(!0)}catch(e){(null==e?void 0:e.name)!=="AbortError"&&console.error("Fetch failed",e)}},t=new AbortController;return e(t.signal),()=>{t.abort()}},[r,g,p,j,f]),(0,s.jsx)(s.Fragment,{children:(0,s.jsx)("div",{className:l().pageContainer,children:(0,s.jsxs)("div",{className:"container",children:[(0,s.jsx)("h1",{children:"Stories"}),(0,s.jsx)("h2",{children:"Find stories"}),(0,s.jsx)(u.E,{filterOptions:h(b),placeholder:"search stories"}),!t&&(0,s.jsx)(a.G,{}),t&&(0,s.jsx)(c.H,{isLoading:!t,title:null,noResultMessage:"No story found",pageIds:x||[]},x.toString())]})})})}},31487:function(e,t,n){"use strict";function s(e,t,n,s){if(!e)return;let a=document.getElementById(e);a&&a.scrollIntoView({behavior:t||"smooth",block:n||"nearest",inline:s||"nearest"})}n.d(t,{Y:function(){return s}})},47930:function(e,t,n){"use strict";n.r(t),n.d(t,{__N_SSP:function(){return m},default:function(){return x}});var s=n(15311),a=n(91541),o=n(31487),i=n(5762),r=n(20132),l=n(9344),c=n.n(l),u=n(10683),d=n(99415),h=n(6572),g=n(34447),p=n(67258);let f=e=>{let{tabConfigs:t,greatestStories:n}=e,[l,f]=(0,r.useState)([]),[j,m]=(0,r.useState)(),[x,v]=(0,r.useState)(0),[b,C]=(0,r.useState)(!1),{keyword:S,interests:w,tags:L,provinces:N,regions:E}=(0,g.B)(),_=(0,i.useRouter)(),y=e=>{_.replace(e,void 0,{shallow:!0})};return(0,r.useEffect)(()=>{let e=async e=>{try{var t;let s=null===(t=n.tabs[x])||void 0===t?void 0:t.pageIds,a=new URLSearchParams({...N.length>0?{provinces:N.join(",")}:{},...E.length>0?{regions:E.join(",")}:{},...w.length>0?{interests:w.join(",")}:{},...L.length>0?{tags:L.join(",")}:{},...S?{keyword:S}:{},...s?{forcePageIds:s.join(",")}:{}}).toString(),o=await fetch("/content/api/search/stories?".concat(a),{signal:e}),i=await o.json();f(i.pageIds),m(i.filters),C(!0)}catch(e){(null==e?void 0:e.name)!=="AbortError"&&console.error("Fetch failed",e)}},t=new AbortController;return e(t.signal),()=>{t.abort()}},[S,w,L,E,N]),(0,s.jsx)(s.Fragment,{children:(0,s.jsx)("div",{className:c().pageContainer,children:(0,s.jsxs)("div",{className:"container",children:[(0,s.jsx)("h1",{children:"The Greatest Stories"}),(0,s.jsx)("h2",{children:"Find stories "}),(0,s.jsx)(d.E,{filterOptions:(0,h.Y)(j),placeholder:"search stories"}),!!t.length&&(0,s.jsx)("div",{className:c().tabOptionContainer,children:t.map((e,t)=>(0,s.jsxs)("button",{id:"chip-".concat(t),className:"".concat(c().tabOption," ").concat(x==t?c().active:""),onClick:()=>{(0,o.Y)("chip-".concat(t)),v(t),y((0,p.v)({tab:[t.toString()]}))},children:[e.title," ",(0,s.jsx)("span",{className:c().count})]},t))}),!b&&(0,s.jsx)(a.G,{}),b&&(0,s.jsx)(u.H,{title:null,noResultMessage:"No story found",pageIds:l||[]},l.toString())]})})})};var j=n(10464),m=!0;function x(e){let{setHasBanner:t}=(0,r.useContext)(j.L);return((0,r.useEffect)(()=>{t&&t(!1)},[]),e.tabConfigs&&e.greatestStories)?(0,s.jsx)(f,{tabConfigs:e.tabConfigs,greatestStories:e.greatestStories}):null}}},function(e){e.O(0,[4738,3569,834,2888,9774,179],function(){return e(e.s=80462)}),_N_E=e.O()}]);