PhaseWeb3-Vue/assets/GameView.cb3dc8ca.js

2 lines
3.1 KiB
JavaScript

import{u as k,a as B,s as D,M as G,ag as R,r as g,o as C,c as m,e as F,w as d,f as l,g as u,k as y,j as f,n as x,$ as L,b2 as M,_ as N,p as j,q as E}from"./index.42dc3a62.js";import{_ as H}from"./GameHeader.20916457.js";import{_ as S}from"./FormControl.833b38dc.js";import{_ as q}from"./ProfileCard.bab5d6a0.js";import{_ as T}from"./GeneralTable.d54642cd.js";import{a as U,A as X}from"./profile.c9c64bc1.js";import{d as z}from"./userData.bcc92478.js";import{g as w}from"./danClass.233b0381.js";import"./sources.488e48ba.js";const J={key:0,class:"w-full md:flex md:-mt-[75px] mb-4 place-content-end"},K={class:"md:w-1/3 md:text-right"},O={key:1,class:"w-full"},Q={class:"bg-white dark:bg-slate-900/95 rounded-2xl lg:flex lg:justify-between"},W={class:"w-full"},ue={__name:"GameView",setup(Y){const V=k(),p=B();var o=null,a=null;const r=D({currentVersion:null});G(()=>r.currentVersion,()=>{v()}),o=V.params.id,a=R(o),a==null&&p.push({name:"ErrorPage",params:{catchAll:"404"}});const n=g(null),_=g([]);C(async()=>{try{const s=await U(o);_.value=$(s)}catch(s){console.error("Failed to fetch profile data:",s)}v()}),a.versions||(r.currentVersion=1);async function v(){try{n.value=null;const s=await X(o,r.currentVersion);n.value=s,s&&!r.currentVersion&&(r.currentVersion=s.versions[s.versions.length-1])}catch(s){console.error("Failed to fetch user profile data:",s)}}const i=[];if(i.push({text:"Player",value:"username",sortable:!0,width:120}),a.noRivals||i.push({text:"Rival ID",value:"extid",width:100}),i.push({text:"Last Play",value:"stats.last_play_timestamp",width:150},{text:"Last Arcade",value:"stats.last_play_arcade",width:150},{text:"Plays",value:"stats.total_plays",sortable:!0,width:50}),a.playerHeaders)for(var P of a.playerHeaders)i.push(P);function $(s){var t=[];for(var e of s){if(e.extid&&(e.extid=z(e.extid)),e.stats){if(e.stats.last_play_timestamp){const c=new Date(e.stats.last_play_timestamp*1e3);e.stats.last_play_timestamp=c.toLocaleString()}e.sgrade&&(e.sgrade=w(e.sgrade).short),e.dgrade&&(e.dgrade=w(e.dgrade).short)}t.push(e)}return t.sort((c,h)=>{const b=c.stats&&c.stats.total_plays||0;return(h.stats&&h.stats.total_plays||0)-b}),t}function I(s){var t=[];for(const e of a.versions)s.includes(e.id)&&t.push(e);return t}const A=s=>{const t=s.userId;p.push(`/games/${o}/profiles/${t}`)};return(s,t)=>(m(),F(E,null,{default:d(()=>[l(j,null,{default:d(()=>[l(H,{game:u(a),version:r.currentVersion},{default:d(()=>[u(a).versions&&n.value?(m(),y("div",J,[f("div",K,[t[1]||(t[1]=f("h2",{class:"text-md sm:text-lg md:text-xl font-bold p-2"}," Select Version ",-1)),l(S,{modelValue:r.currentVersion,"onUpdate:modelValue":t[0]||(t[0]=e=>r.currentVersion=e),options:I(n.value.versions)},null,8,["modelValue","options"])])])):x("",!0),n.value?(m(),y("div",O,[l(q,{game:u(o),version:r.currentVersion,profile:n.value,"use-small":""},null,8,["game","version","profile"])])):x("",!0)]),_:1},8,["game","version"]),l(L,{icon:u(M),title:"All Players",main:""},null,8,["icon"]),l(N,{"has-table":""},{default:d(()=>[f("div",Q,[f("div",W,[l(T,{headers:i,items:_.value,path:`/#/${u(o)}/profiles/`,onRowClicked:A},null,8,["items","path"])])])]),_:1})]),_:1})]),_:1}))}};export{ue as default};