"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),e=require("./masters.js"),c=require("react"),y=e.styled_default("div")({name:"InviteFriendsContainer",class:"i1c9dygq",propsAsIs:!1}),j=({deepLink:o})=>s.jsx(y,{children:s.jsx(e.M,{inviteLink:o,inviteCardTitle:"It’s More Fun With Friends",inviteCardSubtext:"Invite and compete against your friends for the top spot on the leaderboard."})}),b=e.styled_default("div")({name:"InviteLinkContainer",class:"i1odbhm4",propsAsIs:!1}),k=({gamification:o,scrollNode:r,scrollStore:t})=>{const n=c.useRef(null),{data:i,hasMore:a,loading:d,key:p}=e.useStore(o.leaderboardList.$store),{data:l}=e.useStore(o.deepLink.$store),[m,h]=e.T(n);return!i.length&&!d?s.jsx(j,{deepLink:l}):s.jsxs(s.Fragment,{children:[s.jsx(e.S,{items:i,scrollNode:r,scrollStore:t,fetchMore:o.leaderboardList.fetchMore,hasMore:a,openItemDetail:o.openUser,currentUserId:o.currentUserId.get()},p),l&&s.jsx(b,{ref:n,children:s.jsx(e.C,{onClick:()=>m(l),title:"Invite Friends",description:"Challenge them now!"})}),h]})},I=({store:o,openQuestion:r})=>{const{sdk:t}=e.p(),n=e.useStore(o);return s.jsx(e.k,{openQuestion:r,questions:n.data,controlVideo:t==null?void 0:t.controlVideoPlayer})},N=({userSummary:o})=>{var r;const[t,n]=c.useState(void 0);return c.useEffect(()=>{const i=o.$store.subscribe(a=>{a&&n(a)});return()=>{i()}},[o]),s.jsx(e.O,{loading:!(t!=null&&t.summary),...t==null?void 0:t.summary,successRate:(r=t==null?void 0:t.percentage)==null?void 0:r.correct})},w=({gamification:o,className:r,scrollStore:t,scrollNode:n,appNode:i,style:a,responsiveStore:d})=>{const{tabsShown:p}=e.useStore(t,{keys:["tabsShown"]}),[l,m]=c.useState(e.m.HOME),[,h]=c.useTransition(),{sdkInDesktopView:g,screen:v}=e.useStore(d,{keys:["sdkInDesktopView"]}),f=u=>{h(()=>{var S;m(u),g===!1&&(((S=i.current)==null?void 0:S.getBoundingClientRect().y)||0)<0&&e.C$2(i,v.size,{behavior:"instant"})})};c.useEffect(()=>t.subscribe(u=>{if(u.scrollPosition===0){t.setKey("tabsShown",!0);return}d.get().sdkInDesktopView?t.setKey("tabsShown",u.scrollDirection==="backward"):t.setKey("tabsShown",u.scrollDirection==="forward")}),[t,d]);let x="0px";return g?x=p?"0px":"calc(8px - var(--header-height) - var(--header-offset))":x=p?"calc(var(--header-height) + var(--header-offset) - 2px)":"0px",s.jsxs(e.l,{className:r,style:a,children:[s.jsx(e.C$1,{style:{top:x},children:s.jsx(e.b,{activePage:l,toggleActivePage:f})}),l===e.m.HOME&&s.jsxs(s.Fragment,{children:[s.jsx(e.n,{style:{paddingTop:"8px"},children:s.jsx(e.m$1,{children:s.jsx(N,{userSummary:o.userSummary})})}),s.jsx(e.a,{style:{flex:1},children:s.jsx(I,{openQuestion:o.openQuestion,store:o.feedList.getStore()})})]}),l===e.m.LEADERBOARD&&s.jsx(e.p$1,{children:s.jsx(k,{scrollStore:t,scrollNode:n,gamification:o})})]})},C=({gamification:o,scrollStore:r,className:t,appNode:n,scrollNode:i,responsiveStore:a})=>s.jsx(w,{appNode:n,scrollStore:r,scrollNode:i,className:t,gamification:o,responsiveStore:a});exports.default=C;
