(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[429],{41988:function(e,t,i){(window.__NEXT_P=window.__NEXT_P||[]).push(["/create/spotify-stats",function(){return i(11110)}])},11110:function(e,t,i){"use strict";i.r(t);var r=i(85893),l=i(67294),s=i(56064),n=i(3623),a=i(11008),o=i(18005),d=i(28489),c=i(71820),u=i(79813),h=i(80967),m=i(93162),x=i(11163),p=i(8935),g=i(10131),j=i(32436),f=i(70066),y=i(43826),b=i(17863),v=i(27043),w=i(44271),Z=i(56168),C=i(4471),T=i(87355),k=i(35515),S=i(63552),_=i(36504),L=i(23979),R=i(45414),I=i(52360),M=i(28758),F=i(38237);let $=new Intl.DateTimeFormat("en",{year:"numeric",month:"short",day:"2-digit"}),q=[{text:"Grid",value:"grid"},{text:"List",value:"list"},{text:"Compact List",value:"compactList"}],N=[{text:"3x3",value:3},{text:"4x4",value:4},{text:"5x5",value:5},{text:"6x6",value:6},{text:"7x7",value:7}],z=[{value:L.bj.short_term,text:"Last 4 Weeks"},{value:L.bj.medium_term,text:"Last 6 Months"},{value:L.bj.long_term,text:"Overall"}],D={paddingTop:"0.1rem",paddingBottom:"0.1rem"};function P(e){return e?.items[0]?.type==="artist"}let U=(0,s.$j)(e=>{let{reducer:t}=e,i=(0,f.f)(t),{isLoading:r,settings:l,displayOptions:s}=i;return{accessToken:(0,g.hP)(t),displayOptions:s,isLoading:r,getResults:e=>i.results[(0,f.e)({...l,...e})],settings:l}},e=>({dispatch:e}))(e=>{let{accessToken:t,dispatch:s,displayOptions:g,isLoading:f,getResults:U,settings:A}=e,{query:E,replace:G,pathname:O}=(0,x.useRouter)(),{isSubscriber:B}=(0,l.useContext)(R.V),W=(0,M.F)("subscription"),Q=(0,l.useRef)(null),[X,Y]=(0,l.useState)(!1),H=(0,S.y)({url:"https://fonts.googleapis.com/css?family=Montserrat:200,300,500&display=swap"}),{requestType:V=L.lw.artists,timeRange:J=L.bj.short_term,imageType:K="list",gridSize:ee}=E,et="string"==typeof ee?parseInt(ee):5,ei=U({...A,requestType:V,timeRange:J}),er=P(ei)?ei.items.map((e,t)=>({id:e.id,imageUrl:e.images[1].url,artistName:e.name,albumName:"",playCount:t})):ei?.items[0]?.type==="track"?ei.items.map((e,t)=>({id:e.id,imageUrl:e.album.images[1].url,artistName:e.name,albumName:e.artists[0].name,playCount:t})):[],el=(0,l.useCallback)(()=>{!er?.length&&t&&s((0,b.YQ)({accessToken:t,...A,requestType:V,timeRange:J}))},[t,s,er?.length,V,A,J]);(0,l.useEffect)(()=>{el()},[t,el,V,J]);let{includeArtist:es,includeCredits:en,includeMeta:ea}=g,eo=et*et,ed=900/et,ec=(0,_.z)(er.map(e=>e.imageUrl)),eu="Did you know that Spotify keeps stats of your top Tracks and Artists? Find out what Spotify tracks about your listening habits by using our Spotify Stats Generator to create a sharable image of your music taste!";return(0,r.jsxs)("div",{children:[(0,r.jsx)(Z.R,{title:"Spotify Stats Generator",description:eu}),(0,r.jsx)(n.Z,{as:"h2",inverted:!0,children:"Spotify Stats Generator"}),(0,r.jsx)(n.Z,{inverted:!0,disabled:!0,size:"medium",children:eu}),(0,r.jsx)(a.Z,{inverted:!0,onSubmit:e=>{e.preventDefault(),el()},children:(0,r.jsxs)(o.Z,{stackable:!0,columns:12,children:[(0,r.jsxs)(o.Z.Row,{children:[(0,r.jsx)(o.Z.Column,{computer:3,tablet:4,mobile:12,children:(0,r.jsxs)(a.Z.Field,{children:[(0,r.jsx)("label",{children:"Type"}),(0,r.jsx)(d.Z,{fluid:!0,compact:!0,selection:!0,value:V,options:[{value:"artists",text:"Artists"},{value:"tracks",text:"Tracks"}],onChange:(e,t)=>{let{value:i}=t;i&&"string"==typeof i&&G({pathname:O,query:{...E,requestType:i}})}})]})}),(0,r.jsx)(o.Z.Column,{computer:3,tablet:4,mobile:12,children:(0,r.jsxs)(a.Z.Field,{children:[(0,r.jsx)("label",{children:"Time Period"}),(0,r.jsx)(d.Z,{fluid:!0,compact:!0,selection:!0,value:J,options:z,onChange:(e,t)=>{let{value:i}=t;i&&"string"==typeof i&&G({pathname:O,query:{...E,timeRange:i}})}})]})})]}),(0,r.jsx)(o.Z.Row,{children:(0,r.jsx)(o.Z.Column,{width:12,children:(0,r.jsx)(C.Q,{isDisabled:!t||f,isLoading:f,isLoggedIn:!!t,loadingLabel:"Loading",onClick:()=>{el()},searchLabel:"Submit"})})})]})}),er?.length?(0,r.jsxs)("div",{children:[(0,r.jsx)(y.C,{style:{margin:"3rem 0"}}),(0,r.jsx)(n.Z,{as:"h2",inverted:!0,style:{paddingBottom:"1rem"},children:"Customization"}),(0,r.jsx)(a.Z,{inverted:!0,compact:"true",children:(0,r.jsxs)(o.Z,{stackable:!0,columns:12,children:[(0,r.jsx)(o.Z.Row,{style:D,children:(0,r.jsx)(o.Z.Column,{computer:3,tablet:6,mobile:12,children:(0,r.jsxs)(a.Z.Field,{children:[(0,r.jsx)("label",{children:"Image Type"}),(0,r.jsx)(d.Z,{compact:!0,selection:!0,options:q,value:K,onChange:(e,t)=>{let{value:i}=t;if(i)return G({pathname:O,query:{...E,imageType:i}})}})]})})}),"grid"===K?(0,r.jsx)(o.Z.Row,{style:D,children:(0,r.jsx)(o.Z.Column,{computer:3,tablet:6,mobile:12,children:(0,r.jsxs)(a.Z.Field,{children:[(0,r.jsx)("label",{children:"Grid Size"}),(0,r.jsx)(d.Z,{compact:!0,selection:!0,options:N,value:et,onChange:(e,t)=>{let{value:i}=t;if(i&&"number"==typeof i)return G({pathname:O,query:{...E,gridSize:i}})}})]})})}):null,"grid"===K?(0,r.jsx)(o.Z.Row,{style:D,children:(0,r.jsx)(o.Z.Column,{width:12,children:(0,r.jsx)(a.Z.Field,{children:(0,r.jsx)(c.Z,{label:"artists"===V?"Include Artist Name":"Include Track Name",checked:es,onChange:()=>s((0,b.q1)({includeArtist:!es}))})})})}):null,(0,r.jsx)(o.Z.Row,{style:D,children:(0,r.jsx)(o.Z.Column,{width:12,children:(0,r.jsx)(a.Z.Field,{children:(0,r.jsx)(c.Z,{label:"Include Metadata",checked:ea,onChange:()=>s((0,b.q1)({includeMeta:!ea}))})})})}),(0,r.jsx)(o.Z.Row,{style:D,children:(0,r.jsx)(o.Z.Column,{width:12,children:(0,r.jsx)(a.Z.Field,{children:B||!W?(0,r.jsx)(c.Z,{label:"Include Spotlistr Credits",checked:en,disabled:!!W&&!B,onChange:()=>s((0,b.q1)({includeCredits:!en}))}):(0,r.jsx)(u.Z,{content:(0,r.jsx)(I.Ap,{}),trigger:(0,r.jsx)("div",{children:(0,r.jsx)(I.w2,{children:(0,r.jsx)(c.Z,{label:"Include Spotlistr Watermark",checked:en,disabled:!!W&&!B,onChange:()=>s((0,b.q1)({includeCredits:!en}))})})})})})})}),(0,r.jsx)(o.Z.Column,{width:12,children:(0,r.jsxs)("div",{style:{display:"flex"},children:[(0,r.jsx)(h.Z,{size:"large",positive:!0,loading:X,onClick:async()=>{if(!Q.current){s((0,v.T5)({notificationType:"error",header:"Error while creating your Grid",message:"Please refresh the page and try again!"}));return}try{Y(!0),await new Promise(e=>setTimeout(()=>e(!0),100));let e=await i.e(6926).then(i.t.bind(i,46926,23)),t={width:2*Q.current.offsetWidth,height:2*Q.current.offsetHeight,style:{transform:"scale(2)",transformOrigin:"left top",width:`${Q.current.offsetWidth}px`,height:`${Q.current.offsetHeight}px`}};await e.toBlob(Q.current,t);let r=await e.toBlob(Q.current,t);(0,m.saveAs)(r,`${(0,F.U)()}-spotify-stats-${V}-${J}-${K}.png`)}catch(e){s((0,v.T5)({notificationType:"error",header:"Error while creating your Grid",message:"Please refresh the page and try again!"}))}finally{Y(!1)}},children:"Download Image"}),(0,r.jsx)(w.I,{})]})})]})}),(0,r.jsx)(p.SizeMe,{children:e=>{let{size:t}=e,i=z.find(e=>e.value===J)?.value,l=P(ei)?"My Top Spotify Artists":"My Top Spotify Tracks",s=(0,r.jsxs)(r.Fragment,{children:[i===L.bj.short_term?"Last 4 Weeks":null,i===L.bj.medium_term?"Last 6 Months":null,i===L.bj.long_term?"Overall":null," - Generated on ",$.format(new Date)]});if("grid"===K){let e=ed*et,i=!X&&t.width&&t.width<=e?t.width/e:1;return(0,r.jsx)("div",{style:{marginTop:"1rem",overflowX:"hidden"},children:(0,r.jsxs)("div",{ref:Q,style:{width:`${ed*et}px`,backgroundColor:"#1b1c1d",fontFamily:"Montserrat",transform:`scale(${i})`,transformOrigin:"left top"},onContextMenu:e=>{e.preventDefault()},children:[H?(0,r.jsx)("style",{children:H}):null,(0,r.jsxs)("div",{style:{backgroundColor:"#1b1c1d",paddingTop:"16px"},children:[(0,r.jsx)(T.Bu,{includeMeta:ea,headerText:l,metaText:s}),(0,r.jsx)(j.r,{albums:er.slice(0,eo).map(e=>({...e,imageUrl:ec[e.imageUrl]||e.imageUrl})),albumSide:ed,gridSide:et,displayPeriodText:"",displayOptions:{...g,gridSide:et}})]})]})})}{let e=!X&&t.width&&t.width<=500?t.width/500:1;return(0,r.jsx)("div",{style:{marginTop:"2rem",overflow:"hidden"},onContextMenu:e=>{e.preventDefault()},children:(0,r.jsx)("div",{ref:Q,style:{width:"500px",transform:`scale(${e})`,transformOrigin:"left top"},children:"list"===K?(0,r.jsx)(T.aV,{items:er.slice(0,5).map(e=>({...e,imageUrl:ec[e.imageUrl]||e.imageUrl})),headerText:l,metaText:s,includeCredits:en,includeMeta:ea}):(0,r.jsx)(k.a,{items:er.slice(0,25),headerText:l,metaText:s,includeCredits:en,includeMeta:ea})})})}}})]}):null]})});t.default=U},9878:function(e,t,i){"use strict";i.d(t,{Y:function(){return l}});var r=i(85893);i(67294);let l=e=>{let{children:t}=e;return(0,r.jsx)(r.Fragment,{children:t({instrument:(e,t)=>function(){for(var e=arguments.length,i=Array(e),r=0;r<e;r++)i[r]=arguments[r];return t?.(...i)}})})}},4471:function(e,t,i){"use strict";i.d(t,{Q:function(){return m}});var r=i(85893);i(67294);var l=i(45697),s=i(56064),n=i(9878),a=i(80967),o=i(10131),d=i(83900),c=i(96724),u=i(11163);let h="search button clicked",m=e=>{let{isLoggedIn:t,isLoading:i,isDisabled:l,onClick:s=()=>{},searchLabel:o="Search!",loadingLabel:m="Loading!",submitType:x=!1}=e,p=(0,u.useRouter)();return(0,r.jsx)(n.Y,{eventProperties:{isLoggedIn:t},children:e=>{let{instrument:n}=e;return t?i?(0,r.jsx)(a.Z,{positive:!0,disabled:!0,size:"large",children:m}):(0,r.jsx)(a.Z,{...x?{type:"submit"}:{},positive:!0,size:"large",onClick:n(h,s),disabled:l,children:o}):(0,r.jsx)(a.Z,{positive:!0,size:"large",as:"a",rel:"external",href:`${d.Z.fullApiDomain}/login`,onClick:n(h,()=>{c.Z.setItem("last_page",p.asPath)}),children:"Log in with Spotify to begin!"})}})};m.propTypes={isLoading:l.bool,isLoggedIn:l.bool,isDisabled:l.bool,loadingLabel:l.string,onClick:l.func,searchLabel:l.string,submitType:l.bool};let x=(0,s.$j)(function(){let{reducer:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{isLoggedIn:(0,o.jl)(e)}})(m);t.Z=x}},function(e){e.O(0,[4493,3103,7603,2888,9774,179],function(){return e(e.s=41988)}),_N_E=e.O()}]);