(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7192],{49477:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(a,i){function s(e){try{l(r.next(e))}catch(e){i(e)}}function o(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?a(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(s,o)}l((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.applySettingDefaults=t.isBrowser=t.stripTrailingSlash=t.uuid=void 0,t.uuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})},t.stripTrailingSlash=function(e){return e.replace(/\/$/,"")},t.isBrowser=()=>"undefined"!=typeof window,t.applySettingDefaults=function(e,t){let{db:r,auth:a,realtime:i,global:s}=e,{db:o,auth:l,realtime:c,global:d}=t,u={db:Object.assign(Object.assign({},o),r),auth:Object.assign(Object.assign({},l),a),realtime:Object.assign(Object.assign({},c),i),global:Object.assign(Object.assign({},d),s),accessToken:()=>n(this,void 0,void 0,function*(){return""})};return e.accessToken?u.accessToken=e.accessToken:delete u.accessToken,u}},73471:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/profile/[id]",function(){return n(17453)}])},32689:function(e,t,n){"use strict";n.d(t,{V:function(){return y}});var r=n(85893),a=n(67294),i=n(65984),s=n(39484),o=n(8207),l=n(95429),c=n(54410),d=n(24920),u=n(76556),m=n(63991),h=n(39332),x=n(8243),f=n(29425),g=n(19815),p=n(33482),v=n(11849),j=n(5921);let y=e=>{let{rootType:t,rootId:n,setNumComments:y}=e,k=(0,i.rZ)(),_=(0,s.X)(),{features:b}=(0,g.c)(),C=!!(null==b?void 0:b.comments),S=!!(null==b?void 0:b.comment_hyperlinks),w=(0,h.useSearchParams)(),[T,M]=(0,a.useState)(null),{comments:z,rootCommentId:I,numComments:F,changeRootComment:N,gotoLastRootComment:E,addComment:R,deleteComment:X,likeComment:Z,dislikeComment:O,isCreateCommentLoading:P,isLoadingInitially:B}=(0,x.K)({rootId:n,rootType:t});return((0,p.B)(z.map(e=>({rootType:"comment",rootId:e.id}))),(0,a.useEffect)(()=>{(null==w?void 0:w.get("commentsFocused"))&&(null==T||T.scrollIntoView({behavior:"smooth",block:"start",inline:"start"}))},[w,T,B]),(0,a.useEffect)(()=>{y&&y(z.length)},[z.length,y]),C)?(0,r.jsxs)(o.K,{p:16,style:{backgroundColor:"dark"===_.colorScheme?k.colors.dark[8]:k.colors.gray[1],borderRadius:4},ref:e=>M(e),children:[(0,r.jsxs)(l.k,{align:"center",gap:4,children:[(0,r.jsx)(m.fu1,{size:24,style:{marginBottom:3}}),(0,r.jsxs)(c.x,{fz:"md",fw:"bold",my:"auto",children:[F," Comment",(0,f._x)(F)]})]}),(0,r.jsx)(v.X,{addComment:R,loading:P}),void 0!==I&&(0,r.jsx)(d.z,{variant:"light",onClick:E,children:"Back"}),B?(0,r.jsx)(l.k,{align:"center",justify:"center",children:(0,r.jsx)(u.a,{})}):z.filter(e=>void 0===I?!e.parent_comment_id:e.id===I).map(e=>(0,r.jsx)(j.s,{comment:e,comments:z,addComment:R,addCommentLoading:P,deleteComment:X,likeComment:Z,dislikeComment:O,changeRootComment:N,hyperlinksEnabled:S},e.id))]}):(0,r.jsx)(r.Fragment,{})}},5150:function(e,t,n){"use strict";n.d(t,{Z:function(){return b}});var r=n(85893),a=n(67294),i=n(41664),s=n.n(i),o=n(63991),l=n(39484),c=n(38878),d=n(8207),u=n(95429),m=n(54410),h=n(79306),x=n(24920),f=n(42195),g=n(41959),p=n(82922),v=n(79014),j=n(43259),y=n(38112);let k=(0,p.k)(e=>({captainIndicator:{marginRight:e.spacing.xs},teamHeader:{backgroundColor:"dark"===e.colorScheme?e.colors.dark[8]:e.colors.gray[2],color:"dark"===e.colorScheme?e.colors.gray[1]:e.colors.dark[9],paddingLeft:e.spacing.md,paddingRight:e.spacing.md}}));function _(e){let{team:t}=e,{classes:n}=k(),a=(0,l.X)();return(0,r.jsx)(c.Z,{style:{boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)"},children:(0,r.jsxs)(d.K,{spacing:"sm",children:[(0,r.jsxs)(u.k,{justify:"space-between",children:[(0,r.jsxs)(d.K,{spacing:"sm",children:[(0,r.jsx)(s(),{href:"/fantasy/contests/".concat(t.fantasy_contests.id),style:{color:"inherit"},children:(0,r.jsx)(m.x,{fw:"bold",fz:"xl",children:t.team_name})}),(0,r.jsx)(m.x,{fz:"xs",children:t.fantasy_contests.name})]}),t.rank&&(0,r.jsxs)(d.K,{spacing:0,children:[(0,r.jsx)(u.k,{justify:"flex-end",align:"center",children:(0,r.jsx)(m.x,{children:"Top ".concat((0,y.r7)(t.rank,t.fantasy_contests._count.user_fantasy_teams),"%")})}),(0,r.jsxs)(u.k,{justify:"flex-end",align:"center",children:[(0,r.jsx)(m.x,{fz:"sm",align:"right",children:"Rank:"}),(0,r.jsxs)(m.x,{fz:"sm",ml:4,children:[t.rank," /"," ",t.fantasy_contests._count.user_fantasy_teams]})]}),t.earned_points&&(0,r.jsx)(m.x,{align:"right",fz:"sm",children:"Total points ".concat(t.earned_points.toFixed(2))})]})]}),(0,r.jsx)(c.Z,{withBorder:!0,p:0,children:(0,r.jsxs)(h.i,{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:n.teamHeader,children:[(0,r.jsx)("th",{children:"Player"}),(0,r.jsx)("th",{children:"Score"})]})}),(0,r.jsx)("tbody",{children:t.user_fantasy_team_players.map(e=>{var t;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsxs)(u.k,{align:"center",children:[e.is_captain&&(0,r.jsx)(o.rrY,{className:n.captainIndicator}),(0,r.jsx)(m.x,{children:null===(t=e.fantasy_contest_players.players)||void 0===t?void 0:t.tag})]})}),(0,r.jsx)("td",{children:Math.round(100*e.fantasy_contest_players.earned_points)/100})]})})})]})}),(0,r.jsx)(u.k,{children:(0,r.jsx)(s(),{href:"/fantasy/contests/".concat(t.fantasy_contests.id),style:{flex:1},children:(0,r.jsx)(x.z,{w:"100%",variant:"light",color:"gray",style:{boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",color:"dark"===a.colorScheme?"white":"black"},children:"Contest Page"})})})]})})}function b(e){let{userId:t}=e,[n,i]=(0,a.useState)(""),[s,l]=(0,a.useState)(1),{data:d,isLoading:h,error:x}=v.SX.fantasy.teams.findUserFantasyTeams.useQuery({userId:t}),p=d?d.filter(e=>e.team_name.toLowerCase().includes(n.toLowerCase())):[];return h?(0,r.jsx)(j.Z,{}):x?(0,r.jsx)(m.x,{align:"center",children:"Sorry, something went wrong"}):(0,r.jsx)(c.Z,{style:{background:"rgba(0,0,0,.1)"},mt:8,children:(0,r.jsxs)(u.k,{direction:"column",gap:8,children:[(0,r.jsx)(c.Z,{p:6,style:{boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)"},children:(0,r.jsxs)(u.k,{align:"center",gap:8,w:"100%",children:[(0,r.jsx)(o.jVj,{}),(0,r.jsx)(f.I,{width:"100%",placeholder:"Search for teams...",onChange:e=>i(e.currentTarget.value),variant:"unstyled"})]})}),p.length>0?(0,r.jsxs)(u.k,{direction:"column",gap:8,children:[p.map((e,t)=>(0,r.jsx)(_,{team:e},t)),(0,r.jsx)(u.k,{w:"100%",align:"center",justify:"center",m:"auto",children:(0,r.jsx)(g.t,{page:s,onChange:l,total:Math.ceil(p.length/5),mb:20,size:"sm",siblings:2})})]}):(0,r.jsx)(m.x,{align:"center",children:"No fantasy teams found"})]})})}},38112:function(e,t,n){"use strict";n.d(t,{$9:function(){return o},p_:function(){return l},r7:function(){return s}});var r=n(13311),a=n.n(r);let i=[1,5,10,25,50,75,100];function s(e,t){let n=e/t*100;return a()(i,e=>n<=e)||1}function o(){let e=new Date;return e.setMilliseconds(0),e}function l(e){return e}},43259:function(e,t,n){"use strict";n.d(t,{Z:function(){return s}});var r=n(85893);n(67294);var a=n(95429),i=n(76556);function s(){return(0,r.jsx)(a.k,{style:{flexGrow:1},align:"center",justify:"center",children:(0,r.jsx)(i.a,{})})}},8243:function(e,t,n){"use strict";n.d(t,{K:function(){return d}});var r=n(67294),a=n(96486),i=n.n(a),s=n(34762),o=n(45956),l=n(79014),c=n(81247);let d=e=>{let{rootId:t,rootType:n,realtime:a=!1,optimisticLoadPosition:d="beginning"}=e,{session:u,isAdmin:m}=(0,s.kP)(),{showLoginModal:h,showUsernameModal:x}=(0,o.o)(),{data:f=[],refetch:g,isLoading:p}=l.SX.comments.findComments.useQuery({rootType:n,rootId:t});(0,c.n)({tableName:"comments",callback:()=>g(),filter:"root_id=eq.".concat(n,"-").concat(t),enabled:a});let[v,j]=(0,r.useState)([]),y=l.SX.comments.createComment.useMutation(),k=l.SX.comments.deleteComment.useMutation(),_=l.SX.comments.likeComment.useMutation();return{rootCommentId:v[v.length-1],numComments:f.length,rootNavigationHistory:v,changeRootComment:e=>{j([...v,e])},gotoLastRootComment:()=>{v.pop(),j([...v])},addComment:(e,r,a)=>{var s,o;if(!(null==u?void 0:null===(s=u.user)||void 0===s?void 0:s.id)){h();return}if(!(null==u?void 0:null===(o=u.userProfile)||void 0===o?void 0:o.display_name)){x();return}r&&y.mutate({rootId:t,rootType:n,parentCommentId:e,content:r},{onSuccess:t=>{let n="beginning"===d;if(null!==e){let r=i().findIndex(f,{id:e});f.splice(n?r+1:f.length,0,t)}else n?f.unshift(t):f.push(t);a()},onError:()=>g()})},deleteComment:e=>{var t;((null==u?void 0:null===(t=u.user)||void 0===t?void 0:t.id)===e.author_id||m)&&(e.deleted=!0,e.author_id=void 0,e.user_profiles=void 0,k.mutate({id:e.id},{onError:()=>g()}))},likeComment:e=>{var t;if(!(null==u?void 0:null===(t=u.user)||void 0===t?void 0:t.id)){h();return}let n=1;!1===e.liked?n=2:!0===e.liked&&(n=-1);let r=!e.liked||null;e.score+=n,e.liked=r,_.mutate({commentId:e.id,liked:r},{onError:()=>g()})},dislikeComment:e=>{var t;if(!(null==u?void 0:null===(t=u.user)||void 0===t?void 0:t.id)){h();return}let n=-1;!0===e.liked?n=-2:!1===e.liked&&(n=1);let r=!1===e.liked&&null;e.score+=n,e.liked=r,_.mutate({commentId:e.id,liked:r},{onError:()=>g()})},comments:f,refetch:g,isCreateCommentLoading:y.isLoading||p,isLoadingInitially:p}}},19815:function(e,t,n){"use strict";n.d(t,{c:function(){return i}});var r=n(79014),a=n(38751);let i=()=>{let{data:e,...t}=(0,a.J)("/featurestatuses",()=>r.b$.cached.features.fetchFeatures.query());return{...t,features:e}}},33482:function(e,t,n){"use strict";n.d(t,{B:function(){return i}});var r=n(67294),a=n(79014);let i=e=>{let t=a.SX.useUtils(),n=a.SX.reactions.fetchReactionsForRoots.useMutation();(0,r.useEffect)(()=>{n.mutate({roots:e},{onSuccess:e=>{e.forEach((e,n)=>{t.reactions.fetchReactionsForRoot.setData({rootId:n.rootId,rootType:n.rootType},e)})}})},[e.length])}},67272:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return h}});var r=n(85893);n(67294);var a=n(41664),i=n.n(a),s=n(43078),o=n(28008),l=n(54410),c=n(356),d=n(24920);let u=(0,n(82922).k)(e=>({root:{paddingTop:80,paddingBottom:80},label:{textAlign:"center",fontWeight:700,fontSize:160,lineHeight:1,marginBottom:e.spacing.xl,color:"dark"===e.colorScheme?e.colors.dark[4]:e.colors.gray[2]},title:{fontFamily:"Greycliff CF, ".concat(e.fontFamily),textAlign:"center",fontWeight:700,fontSize:32},description:{maxWidth:500,margin:"auto",marginTop:e.spacing.xl,marginBottom:e.spacing.xl}}));function m(){let{classes:{root:e,label:t,title:n,description:a}}=u();return(0,r.jsxs)(s.W,{className:e,children:[(0,r.jsx)("div",{className:t,children:"404"}),(0,r.jsx)(o.D,{className:n,children:"You have found a secret place."}),(0,r.jsx)(l.x,{c:"dimmed",size:"lg",ta:"center",className:a,children:"Unfortunately, this is only a 404 page. You may have mistyped the address, or the page has been moved to another URL."}),(0,r.jsx)(i(),{href:"/",passHref:!0,children:(0,r.jsx)(c.Z,{justify:"center",children:(0,r.jsx)(d.z,{variant:"subtle",size:"md",children:"Take me back to home page"})})})]})}function h(){return(0,r.jsx)(m,{})}},17453:function(e,t,n){"use strict";n.r(t),n.d(t,{__N_SSP:function(){return N},default:function(){return E}});var r=n(85893),a=n(65984),i=n(39484),s=n(43078),o=n(38878),l=n(95429),c=n(58278),d=n(62975),u=n(28008),m=n(24920),h=n(52247),x=n(86414),f=n(356),g=n(10576),p=n(96486),v=n.n(p),j=n(67294),y=(0,n(21955).Z)("outline","camera-cog","IconCameraCog",[["path",{d:"M12 20h-7a2 2 0 0 1 -2 -2v-9a2 2 0 0 1 2 -2h1a2 2 0 0 0 2 -2a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1a2 2 0 0 0 2 2h1a2 2 0 0 1 2 2v3",key:"svg-0"}],["path",{d:"M14.973 13.406a3 3 0 1 0 -2.973 2.594",key:"svg-1"}],["path",{d:"M19.001 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-2"}],["path",{d:"M19.001 15.5v1.5",key:"svg-3"}],["path",{d:"M19.001 21v1.5",key:"svg-4"}],["path",{d:"M22.032 17.25l-1.299 .75",key:"svg-5"}],["path",{d:"M17.27 20l-1.3 .75",key:"svg-6"}],["path",{d:"M15.97 17.25l1.3 .75",key:"svg-7"}],["path",{d:"M20.733 20l1.3 .75",key:"svg-8"}]]),k=n(11163),_=n(37748),b=n(49477),C=n(79014),S=n(36281),w=n(34762),T=n(5150),M=n(32689),z=n(11251),I=n(67272);let F=["Team","Special"];var N=!0;function E(e){var t;let{userProfile:n,comments:p,flairs:N}=e,{session:E}=(0,w.kP)(),R=(0,k.useRouter)(),X=(0,a.rZ)(),Z=(0,i.X)(),O=C.SX.authUser.updateUserProfile.useMutation(),{data:P,refetch:B}=C.SX.authUser.findFlairs.useQuery({user_id:null==n?void 0:n.user_id},{enabled:!1}),L=(0,j.useRef)(null),[U,D]=(0,j.useState)(!1),[W,K]=(0,j.useState)(),[V,Q]=(0,j.useState)(),[H,q]=(0,j.useState)(),[A,Y]=(0,j.useState)(v().mapValues(v().groupBy(N,"flair_category.name"),e=>e.map(e=>e.id)));(0,j.useEffect)(()=>{U&&!P&&B()},[U]);let $=async()=>{var e;let t;if(V&&(null==E?void 0:null===(e=E.user)||void 0===e?void 0:e.id)){let e="".concat(E.user.id,"/").concat((0,b.uuid)()),{error:n}=await S.OQ.storage.from("avatars").upload(e,V,{upsert:!0});if(n){(0,_.c0)({autoClose:!0,color:"red",message:"Unable to upload image."});return}t=(await S.OQ.storage.from("avatars").getPublicUrl(e)).data.publicUrl}if(null==n?void 0:n.user_id){let e=v().flatMap(A);O.mutate({displayName:H,avatarUrl:t,flairIds:e},{onSuccess:()=>{R.reload()},onError:e=>(0,_.c0)({autoClose:!0,color:"red",message:e.message})})}};return n?(0,r.jsxs)(s.W,{size:"lg",children:[(0,r.jsxs)(o.Z,{shadow:"sm",p:"lg",mb:8,style:{backgroundColor:"dark"===Z.colorScheme?X.colors.dark[8]:X.colors.gray[1]},children:[(0,r.jsxs)(l.k,{direction:"column",align:"center",justify:"center",gap:24,children:[(0,r.jsxs)(c.x,{style:{position:"relative",width:"min-content"},children:[(0,r.jsx)(d.q,{src:W||(null==n?void 0:n.profile_picture),size:200,radius:100}),(0,r.jsx)("input",{ref:L,type:"file",hidden:!0,onChange:e=>{var t;let n=null===(t=e.target.files)||void 0===t?void 0:t[0];if(n){if(!n.type.startsWith("image/")){(0,_.c0)({autoClose:!0,color:"red",message:"File is not an image."});return}if(n.size>3145728){(0,_.c0)({autoClose:!0,color:"red",message:"Image must be less than 3MB."});return}Q(n);let e=new FileReader;e.onload=()=>{e.result&&K(e.result.toString())},e.readAsDataURL(n)}},accept:"image/*"}),U&&(0,r.jsx)(y,{style:{bottom:0,right:0,position:"absolute",cursor:"pointer"},tabIndex:0,onClick:()=>{var e;return null===(e=L.current)||void 0===e?void 0:e.click()}})]}),U?(0,r.jsxs)(r.Fragment,{children:[F.map(e=>{var t,n,a,i,s,o;return(null==P?void 0:null===(t=P[e])||void 0===t?void 0:t.map(e=>e.name).length)?(0,r.jsx)(h.N,{label:"".concat(e," Flair"),placeholder:e,value:null!==(o=null===(n=A[e])||void 0===n?void 0:n.map(String))&&void 0!==o?o:void 0,data:(null==P?void 0:null===(a=P[e])||void 0===a?void 0:a.map(e=>({label:e.name,value:e.id.toString()})))||[],onChange:t=>{A[e]=t.map(Number),Y({...A})},maxValues:(null==P?void 0:null===(s=P[e])||void 0===s?void 0:null===(i=s[0])||void 0===i?void 0:i.flair_category.limit)||1/0,clearable:!0},e):(0,r.jsx)(r.Fragment,{})}),(0,r.jsx)(x.o,{label:"Display Name",placeholder:(null==n?void 0:n.display_name)||"",onChange:e=>q(e.target.value)}),(0,r.jsxs)(f.Z,{children:[(0,r.jsx)(m.z,{loading:O.isLoading,onClick:$,children:"Save"}),(0,r.jsx)(m.z,{loading:O.isLoading,onClick:()=>{D(!1),K(void 0),q(void 0),Q(void 0)},children:"Cancel"})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(l.k,{direction:"column",align:"center",justify:"center",children:[(0,r.jsx)(l.k,{gap:6,align:"center",children:N.map(e=>(0,r.jsx)(z.Z,{flair:e,size:18,fontWeight:900,borderWidth:2},e.name))}),(0,r.jsx)(u.D,{order:1,children:null==n?void 0:n.display_name})]}),(null==n?void 0:n.user_id)===(null==E?void 0:null===(t=E.user)||void 0===t?void 0:t.id)&&(0,r.jsx)(m.z,{onClick:()=>D(!0),children:"Edit"}),(0,r.jsxs)(u.D,{order:4,children:["Comments \xb7 ",p]})]})]}),(0,r.jsx)(g.i,{my:"md"}),(0,r.jsx)(u.D,{order:3,p:16,children:"Fantasy Teams"}),(null==n?void 0:n.user_id)&&(0,r.jsx)(T.Z,{userId:n.user_id})]}),n&&(0,r.jsx)(M.V,{rootType:"profile",rootId:n.id})]}):(0,r.jsx)(I.default,{})}},86414:function(e,t,n){"use strict";n.d(t,{o:function(){return l}});var r=n(85893);n(67294);var a=n(90987),i=n(9535),s=n(12440);let o={},l=(0,i.d5)((e,t)=>{let n=(0,a.w)("TextInput",o,e);return(0,r.jsx)(s.M,{component:"input",ref:t,...n,__staticSelector:"TextInput"})});l.classes=s.M.classes,l.displayName="@mantine/core/TextInput"}},function(e){e.O(0,[1959,2247,7747,2888,9774,179],function(){return e(e.s=73471)}),_N_E=e.O()}]);