import{d as A,P as T,Q as U,S as k,U as d,V as S,W as j,g as R,j as t,X as E,Y as B,A as o,Z as O,$ as x,y as L}from"./ResizeObserver.es.b7226882.js";import{C as f}from"./index.40f703b6.js";import{I as u}from"./index.20c0f4c5.js";import"./index.f6c44874.js";import"./index.cf00521e.js";import{T as M,a as D}from"./index.dc988884.js";import{I as F,a as w,b as V}from"./icon_level3.5bff162c.js";import{i as m}from"./icon_teacher.40b6f077.js";import"./use-id.5d5e6e63.js";import"./use-tab-status.db1f6d2e.js";import"./use-refs.428b450a.js";const N="_headImg_1lc9z_1",$="_tabs_1lc9z_4",q="_tabContent_1lc9z_27",P="_hasUser_1lc9z_35",H="_itemContent_1lc9z_38",Q="_item_1lc9z_38",W="_left_1lc9z_51",X="_center_1lc9z_57",Y="_right_1lc9z_61",Z="_fraction_1lc9z_65",G="_time_1lc9z_71",J="_user_1lc9z_82",K="_userContent_1lc9z_85",tt="_name_1lc9z_90",et="_tag_1lc9z_99",st="_times_1lc9z_107",at="_activeUser_1lc9z_111",rt="_avator_1lc9z_131",nt="_btn_1lc9z_136",it="_num_1lc9z_142";var e={headImg:N,tabs:$,tabContent:q,hasUser:P,itemContent:H,item:Q,left:W,center:X,right:Y,fraction:Z,time:G,user:J,userContent:K,name:tt,tag:et,times:st,activeUser:at,avator:rt,btn:nt,num:it},ct="./assets/icon-emtry.76ea3a6a.png";function ot(l){return typeof l=="function"||Object.prototype.toString.call(l)==="[object Object]"&&!x(l)}var Ct=A({name:"leaderboard",setup(){const l=T();U();const s=k({tabIndex:0,musicList:[],isSignup:!1,isChallenge:!1,rankingMethod:"",score:0}),z=async()=>{try{const{data:a}=await L.post(`/api-student/open/activity/info/${l.query.id}`);s.rankingMethod=a.rankingMethod;const r=a.rankingMethod==="TOTAL_SCORE"?a.subjectInfos:a.activityMusicVoList;Array.isArray(r)&&(s.musicList=r.map(n=>(n.rankingList=[],n)),s.isChallenge=!!r.filter(n=>n.join).length),p.value=a.subjectUrl,s.isSignup=!!a.join}catch{}},h=async()=>{try{const{data:a}=await L.get("/api-student/open/activityEvaluationRecord/queryRankingList",{params:{activityPlanId:l.query.id,activityEvaluationId:s.rankingMethod==="TOTAL_SCORE"?s.musicList[s.tabIndex].subjectId:s.musicList[s.tabIndex].evaluationId,limit:10}});Array.isArray(a.rankingList)&&(s.musicList[s.tabIndex].rankingList=a.rankingList),a.userActivityRankingVo&&(s.score=a.userActivityRankingVo.score)}catch{}},p=d(),b=d(!1),C=d(100);S(async()=>{await z(),await h()});const i=j(()=>{var v,y;if(!s.musicList[s.tabIndex])return{};const a=R.user.data;if(!a.userId)return{};const r=s.musicList[s.tabIndex],n=(v=r==null?void 0:r.rankingList)==null?void 0:v.find(g=>g.userId==a.userId);let c=(y=r==null?void 0:r.rankingList)==null?void 0:y.findIndex(g=>g.userId==a.userId);return c=c>-1?c+1:0,{join:r.join,score:(n==null?void 0:n.score)||0,isTop:!!n,heardUrl:a.heardUrl,username:a.username,userId:a.userId,step:c}}),I=d(),_=d();return()=>{let a;return t("div",{class:e.leaderboard},[t("div",{class:e.container},[t("div",{class:e.headImg,ref:I},[t(u,{width:"100%",fit:"cover",src:p.value,onLoad:r=>{E(()=>{const{height:n}=B(I);b.value=!0,C.value=n||100})},onError:r=>{console.log(r)}},null)]),b.value&&t(M,{active:s.tabIndex,"onUpdate:active":r=>s.tabIndex=r,class:e.tabs,animated:!0,swipeable:!0,titleInactiveColor:"rgba(153,152,155,1)",titleActiveColor:"#fff",onChange:r=>h()},ot(a=s.musicList.map(r=>t(D,{title:s.rankingMethod==="TOTAL_SCORE"?r.subjectName:r.musicSheetName},{default:()=>[t("div",{class:[e.tabContent,i.value.userId&&(!s.isSignup||!s.isChallenge||i.value.join)?e.hasUser:null],style:{height:`calc(100vh - ${C.value}px)`}},[t("div",{class:e.itemContent},[t("div",{class:e.item},[t("div",{class:e.left},[o("\u6392\u540D")]),t("div",{class:e.center},[o("\u6635\u79F0")]),t("div",{class:e.right},[o("\u8BC4\u5206")])]),r.rankingList.map((n,c)=>{const v=(c+1).toString().padStart(2,"0");return t("div",{class:e.item},[t("div",{class:e.left},[c==0&&t(u,{src:F},null),c==1&&t(u,{src:w},null),c==2&&t(u,{src:V},null),c!=0&&c!=1&&c!=2&&v]),t("div",{class:e.center},[t(u,{width:"38px",height:"38px",fit:"cover",round:!0,src:n.userAvatar||m},null),t("div",{class:e.user},[t("div",{class:e.userContent},[t("span",{class:e.name},[n.username]),t("span",{class:e.tag},[n.userSubject])]),t("div",{class:e.times},[n.joinDate])])]),t("div",{class:e.right},[t("div",{class:e.fraction},[n.score,o("\u5206")]),s.rankingMethod!=="TOTAL_SCORE"&&t("div",{class:e.time},[o("\u7B2C "),n.times,o(" \u6B21\u8BC4\u6D4B")])])])}),!r.rankingList.length&&t(O,{image:ct,description:`\u8BE5${s.rankingMethod==="TOTAL_SCORE"?"\u58F0\u90E8":"\u66F2\u76EE"}\u6682\u65E0\u6392\u540D\u5594\uFF5E`},null)]),t("div",{class:"van-safe-area-bottom"},null)])]})))?a:{default:()=>[a]}),i.value.userId&&(s.isSignup?s.isChallenge?i.value.join?t("div",{ref:_,class:[e.activeUser,"van-safe-area-bottom"]},[t(f,{center:!0,title:i.value.username},{icon:()=>t(u,{class:e.avator,fit:"cover",round:!0,src:i.value.heardUrl||m},null),label:()=>i.value.isTop?t("div",null,[o("\u60A8\u7684\u8BC4\u6D4B\u5DF2\u4E0A\u699C! \u5F53\u524D\u6392\u540D"),t("span",{style:{color:"#FA6400"}},[" ",i.value.step])]):t("div",null,[o("\u60A8\u7684\u8BC4\u6D4B\u6682\u672A\u4E0A\u699C\uFF0C\u5FEB\u53BB\u6311\u6218\u5427\uFF01")]),value:()=>{if(!(!i.value.score&&!s.score))return t("span",{class:e.num},[i.value.score||s.score,o("\u5206")])}})]):null:t("div",{ref:_,class:[e.activeUser,"van-safe-area-bottom"]},[t(f,{center:!0,title:i.value.username,label:"\u60A8\u5C1A\u672A\u8BC4\u6D4B\u54E6!"},{icon:()=>t(u,{class:e.avator,fit:"cover",round:!0,src:i.value.heardUrl||m},null)})]):t("div",{ref:_,class:[e.activeUser,"van-safe-area-bottom"]},[t(f,{center:!0,title:i.value.username,label:"\u60A8\u5C1A\u672A\u62A5\u540D\u53C2\u8D5B"},{icon:()=>t(u,{class:e.avator,fit:"cover",round:!0,src:i.value.heardUrl||m},null)})]))])])}}});export{Ct as default};