(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6803],{79185:function(e,n,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/brands",function(){return r(80467)}])},80467:function(e,n,r){"use strict";r.r(n),r.d(n,{__N_SSP:function(){return N}});var t=r(47568),a=r(36305),o=r(72655),s=r.n(o),i=r(10972),u=r(65433),c=r.n(u),l=r(97176),m=r(42708),d=r(57851),f=r(75445),h=r(25177),x=r(56849),p=r(7775),g=r(17031),v=r(99826),w=r(59377);var b={id:"AllBrands",name:"All Brands",children:[],merchants:[],isRoot:!0},N=!0;n.default=function(){var e=(0,l.useContext)(p.E).showError,n=(0,l.useState)(0),r=n[0],o=n[1],u=(0,l.useState)(0),N=u[0],j=u[1],k=(0,v.Box)({variables:{where:{isRoot:{equals:!0}}}}),y=k.data,C=k.loading,_=(0,v.GMr)({variables:{categoryName:null,subcategoryName:null,take:75,orderBy:[{name:v.Asd.Asc}]},notifyOnNetworkStatusChange:!0,onError:e}),Z=_.data,E=_.networkStatus,M=_.refetch,F=_.fetchMore,B=_.loading,S=(0,g.Z)({data:(null===Z||void 0===Z?void 0:Z.merchantsForCategory)||[],networkStatus:E,loading:B}),A=S.hasReachedEnd,P=S.fetchingMore,L=S.isLoading,O=(0,l.useMemo)((function(){return[b].concat((0,a.Z)((null===y||void 0===y?void 0:y.merchantCategories)||[]))}),[y]),z=(0,l.useMemo)((function(){return O[r]}),[O,r]),R=(0,l.useMemo)((function(){return[b].concat((0,a.Z)(z.children))}),[z]),D=(0,l.useMemo)((function(){return z.id!==b.id?R[N]:null}),[z,N,R]),G=(0,l.useMemo)((function(){var e={},n=Z?(0,a.Z)(Z.merchantsForCategory):[];return n.sort((function(e,n){return e.name.localeCompare(n.name,"en",{sensitivity:"base"})})),n.forEach((function(n){var r,t=n.name.slice(0,1).toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"");1===(r=t).length&&r.match(/[a-zA-Z]/i)||(t="#"),e[t]=e[t]||[],e[t].push(n)})),e}),[Z]),T=(0,l.useMemo)((function(){var e=function(){var e=(0,t.Z)(s().mark((function e(n){var r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return j(0),o(n),r=O[n].name,e.next=5,M({categoryName:0===n?null:r,subcategoryName:null});case 5:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}();return C?(0,i.jsx)(i.Fragment,{}):(0,i.jsx)("div",{className:"mt-5 flex w-full max-w-full flex-row gap-2 overflow-auto pb-2.5 md:gap-4",children:O.map((function(n,t){var a=c()(t,r);return(0,i.jsx)(x.Z,{className:(0,d.m)("whitespace-nowrap","border-beige",a?"bg-beige":""),solid:a,onClick:function(){e(t)},children:n.name},t)}))})}),[O,r,C,M]),W=(0,l.useMemo)((function(){var e=function(){var e=(0,t.Z)(s().mark((function e(n){var r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return j(n),r=R[n].name,e.next=4,M({categoryName:z.name,subcategoryName:0===n?null:r});case 4:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}();return C?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)("div",{className:"relative w-full max-w-full",children:[(0,i.jsx)("div",{className:"mt-5 flex w-full max-w-full flex-row gap-2 overflow-auto pb-2.5 pr-4 md:gap-4",children:R.map((function(n,r){var t=c()(r,N);return(0,i.jsx)("button",{className:(0,d.m)("shrink-0 whitespace-nowrap border-beige text-eyebrows",t?"font-bold underline":""),onClick:function(){e(r)},children:n.name},r)}))}),(0,i.jsx)("div",{className:"absolute inset-0 left-auto w-4 bg-gradient-to-r from-transparent to-white"})]})}),[C,R,M,z.name,N]);return(0,i.jsx)(h.Z,{children:(0,i.jsxs)("div",{className:"mx-auto flex min-h-screen max-w-screen-lg flex-col gap-8 p-4 sm:p-10 md:p-16",children:[(0,i.jsx)("h1",{className:"w-full text-center text-h3 md:text-h2",children:"Brand Discovery"}),(0,i.jsx)("h2",{className:"w-full text-center text-body-sm font-medium md:text-subheadings",children:"Need help knowing where to start? We've curated a list of some of our favorite brands to get you going. Go find some save-worthy products and be sure to come right back."}),T,(0,i.jsx)("hr",{className:"h-px w-full bg-black"}),(0,i.jsx)("h2",{className:"mt-2 text-h4",children:C?"Loading...":z.name}),!!D&&W,L?(0,i.jsx)(i.Fragment,{children:"Loading..."}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"flex flex-col justify-start",children:Object.keys(G).map((function(e){var n=G[e];return(0,i.jsx)(f.Z,{pageName:"brands",items:n,itemAspect:1,title:e.toUpperCase(),headerBreak:!0,expandable:!0,maxWidth:1024,columnCountBreakPoints:{350:2,515:3,650:4,868:5,1024:6},noHorizontalPadding:!0,loading:!1},e)}))}),!A&&!P&&(0,i.jsx)(m.df,{className:"h-4",onChange:function(){var e=(0,t.Z)(s().mark((function e(n){var r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=null===Z||void 0===Z?void 0:Z.merchantsForCategory.length,!n){e.next=4;break}return e.next=4,F({variables:{skip:r}});case 4:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}()}),!!P&&(0,i.jsx)(w.Z,{})]})]})})}}},function(e){e.O(0,[4482,5177,1333,7187,5688,8867,9774,2888,179],(function(){return n=79185,e(e.s=n);var n}));var n=e.O();_N_E=n}]);