(function(){"use strict";var e={6043:function(e,t,a){var r=a(3862),s=a(3396);const i=(0,s.uE)('
',4);function l(e,t,a,r,l,n){const o=(0,s.up)("router-link"),p=(0,s.up)("router-view");return(0,s.wg)(),(0,s.iD)(s.HY,null,[(0,s._)("header",null,[(0,s._)("nav",null,[i,(0,s.Wm)(o,{to:"/",class:"navbar-element"},{default:(0,s.w5)((()=>[(0,s.Uk)("Players")])),_:1})])]),(0,s.Wm)(p)],64)}a(7658);var n=a(1020),o=a(5130),p=a(4870);function d(e){return Object.fromEntries(Object.entries(e).filter((e=>void 0!==e[1]&&null!==e[1])))}function h(e,t){try{return e=d(e),t=d(t),o.deepStrictEqual(e,t),!0}catch{return!1}}const c=(0,n.Q_)("kill",{state:()=>({servers:[],players:[],weapons:[],maps:[],gamemodes:[],hosts:{}}),getters:{getPlayerList:e=>t=>e.players.find((e=>h(e.value.filter,t))),getWeaponList:e=>t=>e.weapons.find((e=>h(e.value.filter,t))),getServerList:e=>t=>e.servers.find((e=>h(e.value.filter,t)))},actions:{fetchPlayers(e){e=d(e);let t=this.players.find((t=>h(t.value.filter,e)));return void 0===t&&(t=(0,p.iH)({filter:e,data:{}}),this.players.push(t)),fetch("https://tone.sleepycat.date/v2/client/players?"+new URLSearchParams(e)).then((async e=>{t.value.data=await e.json()})),t},fetchWeapons(e){e=d(e);let t=this.weapons.find((t=>h(t.value.filter,e)));return t||(t=(0,p.iH)({filter:e,data:{}}),this.weapons.push(t)),fetch("https://tone.sleepycat.date/v2/client/weapons?"+new URLSearchParams(e)).then((async e=>{t.value.data=await e.json()})),t},fetchServers(e){e=d(e);let t=this.servers.find((t=>h(t.value.filter,e)));return t||(t=(0,p.iH)({filter:e,data:{}}),this.servers.push(t)),fetch("https://tone.sleepycat.date/v2/client/servers?"+new URLSearchParams(e)).then((async e=>{t.value.data=await e.json()})),t}}});var u=(0,s.aZ)({setup(e,t){const a=c();a.fetchPlayers({}),a.fetchServers({}),a.fetchWeapons({})}}),g=a(89);const m=(0,g.Z)(u,[["render",l]]);var _=m,y=a(2483);const f={id:"filters"},v={id:"playerView"};function w(e,t,a,r,i,l){const n=(0,s.up)("VueMultiselect"),o=(0,s.up)("PlayerList"),p=(0,s.up)("PlayerChart"),d=(0,s.up)("WeaponChart");return(0,s.wg)(),(0,s.iD)(s.HY,null,[(0,s._)("div",f,[(0,s.Wm)(n,{selectLabel:"",deselectLabel:"remove",placeholder:"Select server",modelValue:e.model.server,"onUpdate:modelValue":t[0]||(t[0]=t=>e.model.server=t),options:e.groupedServers,"group-values":"servers",group_label:"id","group-select":!1,"allow-empty":!0,multiple:!1,"custom-label":e=>e.name,"track-by":"name",label:"name"},null,8,["modelValue","options","custom-label"]),(0,s.Wm)(n,{selectLabel:"",deselectLabel:"remove",placeholder:"Select weapon",modelValue:e.model.weapon,"onUpdate:modelValue":t[1]||(t[1]=t=>e.model.weapon=t),"custom-label":t=>e.weaponLocale[t]||t,options:e.sortedWeaponList,"allow-empty":!0},null,8,["modelValue","custom-label","options"]),(0,s.Wm)(n,{selectLabel:"",deselectLabel:"remove",placeholder:"Search player",modelValue:e.playerHighlighted,"onUpdate:modelValue":t[2]||(t[2]=t=>e.playerHighlighted=t),options:e.sortedPlayerList,"allow-empty":!0,"custom-label":e=>e?.username},null,8,["modelValue","options","custom-label"])]),(0,s._)("div",v,[(0,s.Wm)(o,{filters:e.filters,onHighlightPlayer:e.highlight_player,playerHighlighted:e.playerHighlighted?.id},null,8,["filters","onHighlightPlayer","playerHighlighted"]),(0,s.Wm)(p,{filters:e.filters,onHighlightPlayer:e.highlight_player,playerHighlighted:e.playerHighlighted?.id},null,8,["filters","onHighlightPlayer","playerHighlighted"]),(0,s.Wm)(d,{filters:{player:e.playerHighlighted?.id,...e.filters},playerHighlighted:e.playerHighlighted?.id},null,8,["filters","playerHighlighted"])])],64)}var b=a(7139);const k=e=>((0,s.dD)("data-v-54a9e97c"),e=e(),(0,s.Cn)(),e),P={class:"playerHeaders"},L=k((()=>(0,s._)("span",null,null,-1))),C=["onClick"];function H(e,t,a,r,i,l){return(0,s.wg)(),(0,s.iD)("div",{class:"playerTable",onKeydown:t[6]||(t[6]=(...t)=>e.selectNextPlayer&&e.selectNextPlayer(...t)),tabindex:"0"},[(0,s._)("div",P,[L,(0,s._)("span",{onClick:t[0]||(t[0]=t=>e.updateSort("username")),class:(0,b.C_)("username"==e.sortingData.argument?"selected":"")},"Username",2),(0,s._)("span",{onClick:t[1]||(t[1]=t=>e.updateSort("kills")),class:(0,b.C_)("kills"==e.sortingData.argument?"selected":"")},"K",2),(0,s._)("span",{onClick:t[2]||(t[2]=t=>e.updateSort("deaths")),class:(0,b.C_)("deaths"==e.sortingData.argument?"selected":"")},"D",2),(0,s._)("span",{onClick:t[3]||(t[3]=t=>e.updateSort("k/d")),class:(0,b.C_)("k/d"==e.sortingData.argument?"selected":"")},"K/D",2),(0,s._)("span",{onClick:t[4]||(t[4]=t=>e.updateSort("max_distance")),class:(0,b.C_)("max_distance"==e.sortingData.argument?"selected":"")},"max distance",2),(0,s._)("span",{onClick:t[5]||(t[5]=t=>e.updateSort("avg_distance")),class:(0,b.C_)("avg_distance"==e.sortingData.argument?"selected":"")},"average distance",2)]),((0,s.wg)(!0),(0,s.iD)(s.HY,null,(0,s.Ko)(e.playerList,((t,a)=>((0,s.wg)(),(0,s.iD)("div",{class:(0,b.C_)("playerRow "+(t.id===e.$props.playerHighlighted?"selected":"")),key:t.id,onClick:a=>e.$emit("highlightPlayer",t.id),ref_for:!0,ref:"player:"+t.id},[(0,s._)("div",null,[(0,s._)("span",null,(0,b.zw)(a+1),1)]),(0,s._)("div",null,[(0,s._)("span",null,(0,b.zw)(t.username),1)]),(0,s._)("div",null,[(0,s._)("span",null,(0,b.zw)(t.kills),1)]),(0,s._)("div",null,[(0,s._)("span",null,(0,b.zw)(t.deaths),1)]),(0,s._)("div",null,[(0,s._)("span",null,(0,b.zw)(Math.round(t.kills/Math.max(1,t.deaths)*100)/100),1)]),(0,s._)("div",null,[(0,s._)("span",null,(0,b.zw)(t.max_distance),1)]),(0,s._)("div",null,[(0,s._)("span",null,(0,b.zw)(Math.round(100*(t.total_distance/t.kills||0))/100),1)])],10,C)))),128))],32)}var x=(0,s.aZ)({props:{filters:{type:Object,default:()=>({})},playerHighlighted:String},emits:["highlightPlayer"],data(){return{sortingData:{direction:-1,argument:"kills"},playerIdList:[],store:c()}},computed:{players(){const{player:e,...t}=this.filters,a=this.store.getPlayerList(t)?.value.data;return a||this.store.fetchPlayers(t).value.data},playerList(){if(!this.players)return[];let e=Object.entries(this.players).map((e=>({id:e[0],...e[1]})));if("username"===this.sortingData.argument){const t=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});e.sort(((e,a)=>t.compare(e.username,a.username)))}else if("k/d"===this.sortingData.argument)e.sort(((e,t)=>e.kills/Math.max(1,e.deaths)-t.kills/Math.max(1,t.deaths)));else if("avg_distance"===this.sortingData.argument)e.sort(((e,t)=>(e.total_distance/e.kills||0)-(t.total_distance/t.kills||0)));else{const t=this.sortingData.argument;e.sort(((e,a)=>e[t]-a[t]))}return this.sortingData.direction<0&&e.reverse(),e=e.slice(0,500),e}},watch:{players:{handler(e){e&&(this.sortingData.direction*=-1)},immediate:!0},playerHighlighted(e){const t=this.$refs["player:"+e];t&&t[0]&&t[0].scrollIntoView({behavior:"smooth",block:"center"})}},updated(){const e=this.$refs["player:"+this.$props.playerHighlighted];e&&e[0]&&e[0].scrollIntoView({behavior:"smooth",block:"center"})},methods:{selectNextPlayer(e){const t={Home:-1/0,End:1/0,PageDown:100,PageUp:-100,ArrowUp:-1,ArrowDown:1,ArrowRight:10,ArrowLeft:-10};if(!this.$props.playerHighlighted)return;if(!Object.keys(t).includes(e.key))return;e.preventDefault();const a=this.playerIdList.indexOf(this.$props.playerHighlighted);let r=a+t[e.key];r>=this.playerIdList.length&&(r=this.playerIdList.length-1),r<0&&(r=0),this.$emit("highlightPlayer",this.playerIdList[r])},updateSort(e){this.sortingData.argument===e?this.sortingData.direction*=-1:this.sortingData.direction=-1,this.sortingData.argument=e}}});const S=(0,g.Z)(x,[["render",H],["__scopeId","data-v-54a9e97c"]]);var I=S;const O={class:"playerChart",ref:"container"};function W(e,t,a,r,i,l){const n=(0,s.up)("Scatter");return(0,s.wg)(),(0,s.iD)("div",O,[(0,s.Wm)(n,{data:e.chart,options:e.chartOptions},null,8,["data","options"])],512)}var D=a(3254),$=a(9152),V=a(1131),j=a(5866);D.kL.register(D.f$,D.od,D.jn,D.u,D.De,$.Z,V.Z);var M=(0,s.aZ)({name:"PlayerChart",props:{filters:Object,playerHighlighted:String},data:()=>({store:c(),refreshColors:0}),emits:["highlightPlayer"],components:{Scatter:j.bp},mounted(){this.refreshColors++},computed:{colors(){this.refreshColors;const e={};if(this.$refs.container){const t=getComputedStyle(this.$refs.container);e.fg=t.getPropertyValue("--foreground"),e.bg=t.getPropertyValue("--bg-color"),e.orange=t.getPropertyValue("--orange"),e.cyan=t.getPropertyValue("--cyan"),e.currentLine=t.getPropertyValue("--current-line")}else e.fg="#ffffff";return e},chart(){return{datasets:[{label:"Players",labels:this.playerIdList||[],borderColor:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.index]?this.colors.orange:this.colors.cyan,backgroundColor:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.index]?this.colors.orange:this.colors.cyan,pointRadius:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.index]?20:1,pointStyle:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.index]?"crossRot":"circle",hoverRadius:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.index]?30:4,data:this.playerIdList.map((e=>({y:this.players[e].kills,x:this.players[e].deaths})))}]}},chartOptions(){this.$props.playerHighlighted;let e=0,t=0;if(this.players){const a=Math.max(...Object.values(this.players).map((e=>e.deaths))),r=Math.max(...Object.values(this.players).map((e=>e.kills)));r>a?(e=a,t=a/r*r):(t=r,e=r/a*a)}return{responsive:!0,maintainAspectRatio:!1,animation:{duration:500},layout:{autoPadding:!1},scales:{y:{title:{text:"Kills",display:!0,color:this.colors.fg},ticks:{color:this.colors.fg}},x:{title:{text:"Deaths",display:!0,color:this.colors.fg},ticks:{color:this.colors.fg}}},plugins:{tooltip:{callbacks:{label:e=>{let t;return t=this.players?this.players[e.dataset.labels[e.dataIndex]].username:e.dataset.labels[e.dataIndex],t+=" ("+e.parsed.y+" kills "+e.parsed.x+" deaths)",t}}},annotation:{annotations:{line:{type:"line",yMin:0,xMin:0,yMax:t,xMax:e,borderWidth:2,borderColor:this.colors.orange,borderDash:[1,5]}}},legend:{display:!1},datalabels:{formatter:(e,t)=>this.players[this.playerIdList[t.dataIndex]].username,backgroundColor:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.dataIndex]?this.colors.orange:null,borderColor:this.colors.fg,borderWidth:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.dataIndex]?1:0,borderRadius:5,display:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.dataIndex]?"true":"auto",align:-45,anchor:"end",clamp:!0,color:e=>this.$props.playerHighlighted&&this.$props.playerHighlighted===this.playerIdList[e.dataIndex]?this.colors.bg:this.colors.fg}},onClick:(e,t)=>{this.$emit("highlightPlayer",t.length>0?this.playerIdList[t[0].index]:void 0)},onHover:(e,t)=>{e.native.target&&(e.native.target.style.cursor=t[0]?"pointer":"default")}}},players(){const e=this.store.getPlayerList(this.filters||{})?.value.data;if(!e)return this.store.fetchPlayers(this.filters||{}).value.data;const t=Object.entries(e).sort(((e,t)=>e[1].kills