import{A as e,B as t,K as n,p as r,s as i}from"./vendor-vue-D9nMs6_1.js";import{i as a,r as o,t as s}from"./backendApi-CRLUmnjv.js";import"./style-editor-CCYkJCsR.js";import{t as c}from"./renderReady-m0ZpQ02H.js";var l={square:`squareImg`,tile:`tileImg`,splash:`splashImg`,splashCentered:`splashCenteredImg`,loading:`loadingImg`};function u(e,t){if(e)return e[l[t??``]??l.square]||e.squareImg||void 0}var d=function(e){return e[e.KdaRatio=0]=`KdaRatio`,e[e.WinRate=1]=`WinRate`,e[e.Kills=2]=`Kills`,e[e.Assists=3]=`Assists`,e[e.KillParticipation=4]=`KillParticipation`,e[e.DamageShare=5]=`DamageShare`,e[e.CsPerMinute=6]=`CsPerMinute`,e[e.GoldPerMinute=7]=`GoldPerMinute`,e[e.DamagePerMinute=8]=`DamagePerMinute`,e[e.VisionScorePerGame=9]=`VisionScorePerGame`,e[e.GamesPlayed=10]=`GamesPlayed`,e}({}),f=[`kdaRatio`,`winRate`,`kills`,`assists`,`killParticipation`,`damageShare`,`csPerMinute`,`goldPerMinute`,`damagePerMinute`,`visionScorePerGame`,`gamesPlayed`],p={[d.KdaRatio]:`kdaRatio`,[d.WinRate]:`winRate`,[d.Kills]:`kills`,[d.Assists]:`assists`,[d.KillParticipation]:`killParticipation`,[d.DamageShare]:`damageShare`,[d.CsPerMinute]:`csPerMinute`,[d.GoldPerMinute]:`goldPerMinute`,[d.DamagePerMinute]:`damagePerMinute`,[d.VisionScorePerGame]:`visionScorePerGame`,[d.GamesPlayed]:`gamesPlayed`};function m(e,t=`kdaRatio`){return typeof e==`number`?p[e]??t:f.find(t=>t.toLowerCase()===(e??``).toLowerCase())??t}function h(e,t){let n=e[t];switch(t){case`winRate`:case`killParticipation`:case`damageShare`:return`${Math.round(n*100)}%`;case`kdaRatio`:return n.toFixed(2);case`csPerMinute`:return n.toFixed(1);case`goldPerMinute`:case`damagePerMinute`:case`visionScorePerGame`:return Math.round(n).toString();default:return n.toString()}}function g(e){return`${Math.round(e.winRate*100)}%`}function _(l){let d=i(),f=o(),p=n(null),m=n(null),h=n(null),g=n({}),_=n(!0),v=r(()=>l.componentSettings?.()),y=r(()=>l.previewData?.()),b=r(()=>{let e=v.value?.seasonId??d.params.seasonId??d.query.seasonId,t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}),x=r(()=>{let e=v.value?.matchId??l.matchId?.()??d.query.matchId,t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}),S=r(()=>y.value?.rows??p.value),C=r(()=>S.value??m.value??[]),w=r(()=>!!S.value);t(S,e=>{e&&(m.value=e)},{immediate:!0});function T(e,t){let n=u(g.value[e],t);return n?s.getCacheUrl(n):void 0}function E(e){return g.value[e]?.name??e}async function D(){if(!(Object.keys(g.value).length>0))try{g.value=(await a.get(`cache/champion/all/latest`)).data}catch{g.value={}}}async function O(){if(b.value!==void 0)return b.value;try{return(await a.get(`season/current/id`)).data}catch{return}}async function k(){if(y.value){h.value=y.value.season??null,_.value=!1,await D(),await c();return}_.value=!0;try{let e=await O();if(e===void 0){p.value=null;return}let t=!f.mocking&&x.value!==void 0?`?matchId=${x.value}`:``,[n,r]=await Promise.all([a.get(f.mocking?`season/${e}/playerstats/mock`:`season/${e}/playerstats${t}`),a.get(`season/${e}`).catch(()=>null)]);p.value=n.data,h.value=r?.data??null,await D(),await c()}catch(e){console.error(`Error loading season player stats:`,e),p.value=null}finally{_.value=!1}}return t(()=>[b.value,x.value,f.mocking,f.statsVersion],k),e(k),{rows:C,season:h,loading:_,visible:w,matchId:x,championIcon:T,championName:E,reload:k}}export{_ as a,m as i,h as n,g as r,f as t};