1import{V as e}from"./vue-draggable-next.esm-bundler-BduPNG3a.js";import{p as t}from"./playoffScheduling-DTKuKqYe.js";import{_ as l,r as a,n as s,g as r,q as i,f as o,y as n,D as c,e as u,t as h,v as d,F as y,x as p,B as v,a1 as b,$ as f,a3 as g,U as m,h as k,G as S,N as w,V as P,R as B,S as _,T as L,H as O,O as D,u as T,Y as E,Z as A}from"./index-M5qy_4Wm.js";const x={name:"playoffSetup",props:{players:Array,dblocation:String,hasExistingData:Boolean},emits:["save","closePlayoffSetup"],components:{draggable:e},mixins:[t],data(){return{seedStats:[],minGames:28,minGamesSwitch:!1,newPlayerList:[],removedPlayers:[],sortBy:"pts",thenSortBy:"score",bestOf:3,type:[{label:"Single Elimination",value:"single"},{label:"Double Elimination",value:"double"}],selected:{type:"double"},orderInput:"",orderErrors:[],isFinalSeason:"Week8"===this.seasonStore.hostWeek.name,playoffDivisionRuleset:"individual",saveDisabled:!1}},mounted(){this.newList(),"Tournament"===this.eventStore.selectedEventType&&(this.selected.type="double")},setup:()=>({venueStore:T(),seasonStore:E(),eventStore:A()}),computed:{handleLeaguePlayoffDivisions(){return"League"===this.eventStore.selectedEvent.type&&"since_2025"===this.eventStore.selectedEvent.gamePlayRules},bestOfList(){return"natf"===this.venueStore.venue.rules?[{label:"NATF Rules",value:"NATF"},{label:"Single Game",value:1},{label:"Best Of 3",value:3},{label:"Best Of 5",value:5},{label:"Best Of 7",value:7}]:[{label:"Single Game (Season Finals)",value:1},{label:"Best Of 3 (Tournament)",value:3}]},bracketA(){let e={},t=this.bracketSize;for(let l=1;t>1;t/=2,l++){let t,a={};for(let e=1;e<=this.bracketSize/Math.pow(2,l);e++){let t;t=e<10?"g0"+e:"g"+e;let s=this.newPlayerList[this.bracketPosition[e-1][0]-1],r=this.newPlayerList[this.bracketPosition[e-1][1]-1];a[t]=1===l?{bestOf:this.bestOf,player1:{alias:s.alias,first:s.first,last:s.last,pic:s.pic,playerid:s.id,pts:0,seedPosition:this.bracketPosition[e-1][0],division:s.division||"amateur",wktlDivision:s.wktlDivision||"recreational",team:(null==s?void 0:s.team)||null,rank:s?s.rank:null},player2:{alias:r?r.alias:null,first:r?r.first:null,last:r?r.last:null,pic:r?r.pic:null,playerid:r?r.id:null,pts:r?0:null,seedPosition:r?this.bracketPosition[e-1][1]:null,division:r&&r.division?r.division:null,wktlDivision:r&&r.wktlDivision?r.wktlDivision:null,team
1:(null==r?void 0:r.team)||null,rank:r?r.rank:null}}:{bestOf:this.bestOf,player1:null,player2:null}}t=l<10?"r0"+l:"r"+l,e[t]=a}return Object.keys(e.r01).forEach(t=>{if(null===e.r01[t].player2.playerid){let l=this.gameToString(Math.floor((parseInt(t.substr(1))+1)/2)),a=this.isEven(parseInt(t.substr(1)))?"player2":"player1";e.r02[l][a]=e.r01[t].player1}}),e},bracketB(){let e={},t=this.bracketSize/2;for(let l=1;t>1;t/=2,l+=2){let a,s,r={};for(let e=1;e<=t/2;e++){let t;t=e<10?"g0"+e:"g"+e,this.newPlayerList[this.bracketPosition[e-1][0]-1],this.newPlayerList[this.bracketPosition[e-1][1]-1],r[t]={bestOf:this.bestOf,player1:null,player2:null}}a=l<10?"r0"+l:"r"+l,s=l<9?"r0"+(l+1):"r"+(l+1),e[a]=r,e[s]=r}return e},bracketAnotes(){let e={};return e[this.roundToString(Math.floor(Math.log(this.bracketSize)/Math.log(2)))]={g01:"end"},e},bracketBnotes(){let e={r01:{},r02:{}};if(void 0!==this.bracketA.r01){let t;for(t=1;t<this.bracketSize/2;t+=2)null!=this.bracketA.r01[this.gameToString(t)].player2.playerid&&null!==this.bracketA.r01[this.gameToString(t+1)].player2.playerid||(e.r01[this.gameToString(Math.ceil(t/2))]="bye"),null==this.bracketA.r01[this.gameToString(t)].player2.playerid&&null===this.bracketA.r01[this.gameToString(t+1)].player2.playerid&&(e.r02[this.gameToString(Math.ceil(t/2))]="bye")}return e[this.roundToString(2*Math.floor(Math.log(this.bracketSize/2)/Math.log(2)))]={g01:"end"},e},bracketSize(){let e;for(e=2;e<this.newPlayerList.length;e*=2);return e},bracketPosition(){let e=Math.log(this.bracketSize)/Math.log(2)-1,t=[1,2],l=[];for(let s=0;s<e;s++)t=a(t);for(let s=0;s<t.length;s+=2)l.push([t[s],t[s+1]]);return l;function a(e){let t=[],l=2*e.length+1;return e.forEach(function(e){t.push(e),t.push(l-e)}),t}},seedBy(){return"watl"===this.venueStore.venue.rules?(this.changeSortBy("win"),[{label:"Match Wins",value:"win"},{label:"Total Score",value:"score"},{label:"High Score",value:"high"},{label:"Bullseyes",value:"score6"},{label:"Killshots",value:"score8"},{label:"Manual order",value:"order"}]):(this.changeSortBy("win"),[{label:"Match Wins",value:"win"},{label:"Total Points",value:"pts"},{label:"Total Score",value:"score"},{label:"Avg Score per Game",value:"scoreavg"}])},thenSeedBy(){return"watl"===this.venueStore.venue.rules?(this.changeThenSortBy("high"),[{label:"High Score",value:"high"},{label:"Bullseyes",value:"score6"},{label:"Killshots",value:"score8"},{label:"Total Score",value:"score"}]):(this.changeThenSortBy("pts"),[{label:"Total Points",value:"pts"},{label:"Total Score",value:"score"},{label:"Avg Score per Game",value:"scoreavg"}])},totalGames(){return(this.players.length-1)*this.selected.type*Math.round(this.bestOf/2)+" - "+(this.players.length-1)*this.selected.type*this.bestOf}},methods:{changeSortBy(e){this.sortBy=e},changeThenSortBy(e){this.thenSortBy=e},saveManualOrder(){let e=[],t=this,l=1,a=[],s=this.orderInput.split("\n");this.sortBy="order",this.orderErrors=[],s.length!==this.newPlayerList.length&&this.orderErrors.push({code:"error",error:"incorrect number of provided codes. List: "+this.newPlayerList.length+", provided:"+s.length});for(let r in s)a[s[r]]=l,e[r]=new Promise((e,l)=>{const a=B(O("/watl/players"),L("code"),_(s[r]));D(a,l=>{if(l.exists()){let e=l.val(),a=Object.keys(e)[0],i=!1;for(let l in t.newPlayerList)t.newPlayerList[l].id===a&&(t.newPlayerList[l].order=s.length-parseInt(r),i=!0);i||t.orderErrors.push({code:s[r],error:"player "+e[a].first+" "+e[a].last+" not on the list."})}else t.orderErrors.push({code:s[r],error:"not found"});e()},{onlyOnce:!0})}),l++;Promise.allSettled(e).then(e=>{this.sortStats(t.newPlayerList)})},newList(){this.players.filter(e=>this.minGamesSwitch?e.gp>=this.minGames:e.gp>=0).forEach(e=>{this.newPlayerList.push(e)}),this.sortStats(this.newPlayerList)},removePlayer(e){this.removedPlayers.push(e),this.newPlayerList.splice(this.newPlayerList.indexOf(e),1)},reset(){this.removedPlayers=[],this.newPlayerList=[],this.newList()},sortStats(e){return e.sort((e,t)=>e[this.sortBy]<t[this.sortBy]?100:e[this.sortBy]>t[this.sortBy]?-100:e[this.thenSortBy]<t[this.thenSortBy]?1:e[this.thenSortBy]>t[this.thenSortBy]?-1:0)},clearPreviousData(){return!this.dblocation||this.dblocation.includes("undefined")?(console.warn("playoffSetup.clearPreviousData: invali
1d dblocation, skipping",this.dblocation),Promise.resolve()):Promise.all(["game-data","game-list","bracket","bracket2","bracketB","bracketB2"].map(e=>P(m("".concat(this.dblocation,"/").concat(e)))))},setupPlayoffDivisionRuleset(){this.handleLeaguePlayoffDivisions&&S(w("/venues/".concat(this.venueStore.venue.locationSlug,"/event-list/league/").concat(this.eventStore.selectedEvent[".key"])),{divisionRuleset:this.playoffDivisionRuleset})},saveHandler(e){this.hasExistingData?k(()=>this.save(e,!0),"Re-seeding will erase all game data from the current bracket. Clicking 'Yes' will re-seed and erase all current game data.","warning","Yes"):this.save(e,!0)},async save(e,t=!0){this.saveDisabled=!0;try{t&&(await this.clearPreviousData(),await this.savePlayers(e),this.setupPlayoffDivisionRuleset(),await this.saveSettings(e),"double"===this.selected.type?(await this.saveBracketA(),await this.saveBracketB(),await this.saveFinals()):(await this.saveBracketA(),await this.saveFinals())),this.reset(),this.$emit("save"),this.$emit("closePlayoffSetup"),this.saveDisabled=!1}catch(l){console.error("Error saving playoff setup: ",l)}finally{this.saveDisabled=!1}},saveSettings(e){return g(m("".concat(this.dblocation,"/settings")),{eliminationType:this.selected.type,size:this.bracketSize,players:e.length,bestOf:this.bestOf,rounds:this.bestOf,bracketAnotes:this.bracketAnotes,bracketBnotes:this.bracketBnotes}).then(e=>{this._console("Save Settings")})},savePlayers(e){return console.log("Players: ",e),Promise.all(e.map(e=>this.addPlayerToWeek(e)))},saveBracketA(){return g(m("".concat(this.dblocation,"/bracket")),this.bracketA).then(e=>{this.sendFirstRoundtoCreateGames(this.bracketA)})},saveBracketB(){return g(m("".concat(this.dblocation,"/bracketB")),this.bracketB).then()},saveFinals(){const e="double"===this.selected.type?{r01:{g01:{bestOf:3}},r02:{g01:{bestOf:3}}}:{};return g(m("".concat(this.dblocation,"/finals")),e).then()},sendFirstRoundtoCreateGames(e){Object.keys(e).forEach(t=>{Object.keys(e[t]).forEach(l=>{e[t][l].player1&&e[t][l].player2&&e[t][l].player1.playerid&&e[t][l].player2.playerid&&this.createGame("On Standby",e[t][l].player1,e[t][l].player2,"bracket","left",t,l,"Cage 1")})})},addPlayerToWeek(e){return void 0===e.globalrank&&(e.globalrank=0),void 0===e.rank&&(e.rank=0),g(m("".concat(this.dblocation,"/players/").concat(e.id)),{gs:e.gp,checkedin:!0,rank:e.rank,globalrank:e.globalrank,pic:e.pic,first:e.first,last:e.last,alias:e.alias,team:e.team||{logo:"none",name:"No Team"},selfSignUp:e.selfSignUp||!1,gp:0,win:0,loss:0,drops:0,faults:0,otl:0,forfeit:0,pts:0,score:0,scoreavg:0,high:0,axeavg:0,clutch:0,clutchcall:0,rubber:0,rubberwin:0,baxe:0,baxewin:0,ugame:0,ngame:0,sgame:0,umatch:0,nmatch:0,smatch:0,eightyone:0,perfect:0,score0:0,score1:0,score2:0,score3:0,score4:0,score5:0,score6:0,score7:0,score8:0,score10:0,killcall:0,division:e.division||"amateur",wktlDivision:e.wktlDivision||"recreational",bullsEyeHit:{_center:{total:0},top_left:{total:0},top_right:{total:0},low_left:{total:0},low_right:{total:0}},killShotHit:{top_left:{total:0},top_right:{total:0},low_left:{total:0},low_right:{total:0}}})}}},G=["value"],M=["value"],R=["value"],C={key:1},V={key:0,id:"errors",class:"error-list"};const U=l(x,[["render",function(e,t,l,g,m,k){const S=a("v-btn"),w=a("v-col"),P=a("v-radio"),B=a("v-radio-group"),_=a("v-switch"),L=a("v-icon"),O=a("v-list-item-action"),D=a("v-list-item-title"),T=a("v-list-item"),E=a("draggable"),A=a("v-list"),x=a("v-row"),U=a("v-card-text"),z=a("v-card-actions"),F=a("v-card");return r(),s(F,{style:{"background-color":"white"},class:"pt-0 elevation-0"},{default:i(()=>[o(U,{class:"pt-0"},{default:i(()=>[o(x,{class:"mx-4"},{default:i(()=>[o(w,{cols:"3",class:"offset-5"},{default:i(()=>[o(S,{block:"",dark:"",variant:"flat",color:"primary",onClick:t[0]||(t[0]=e=>k.reset())},{default:i(()=>[...t[13]||(t[13]=[n("Reset List",-1)])]),_:1})]),_:1}),o(w,{cols:"3",class:"mx-3"},{default:i(()=>[o(S,{block:"",dark:"",color:"primary",onClick:t[1]||(t[1]=e=>k.saveHandler(m.newPlayerList)),disabled:m.saveDisabled},{default:i(()=>[...t[14]||(t[14]=[n("Save",-1)])]),_:1},8,["disabled"])]),_:1}),o(w,{cols:"12",sm:"4",class:"mt-4"},{default:i(()=>[t[25]||(t[25]=n(" Please, select playoff type* ",-1)),o(B,{inline:"",modelValue:m.selected.type,"onUpdate:modelValue":t[2]||(t[2]=e=>m.selected.type=e)},{default:i(()=>[(r(!0),u(y,null,p(m.type,(e,t)=>(r(),s(P,{key:t,color:"darkblue",label:e.label,value:e.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),t[26]||(t[26]=n(" Seed by* ",-1)),c(d("select",{name:"season","onUpdate:modelValue":t[3]||(t[3]=e=>m.sortBy=e),onChange:t[4]||(t[4]=e=>k.sortStats(m.newPlayerList))},[(r(!0),u(y,null,p(k.seedBy,e=>(r(),u("option",{value:e.value,key:e.value},v(e.label),9,G))),128))],544),[[b,m.sortBy]]),"order"!==m.sortBy?(r(),u(y,{key:0}
1,[t[15]||(t[15]=d("br",null,null,-1)),t[16]||(t[16]=d("br",null,null,-1)),t[17]||(t[17]=n("Tie breaker* ",-1)),c(d("select",{name:"season","onUpdate:modelValue":t[5]||(t[5]=e=>m.thenSortBy=e),onChange:t[6]||(t[6]=e=>k.sortStats(m.newPlayerList))},[(r(!0),u(y,null,p(k.thenSeedBy,e=>(r(),u("option",{value:e.value,key:e.value},v(e.label),9,M))),128))],544),[[b,m.thenSortBy]])],64)):h("",!0),d("span",null,[t[18]||(t[18]=d("br",null,null,-1)),t[19]||(t[19]=d("br",null,null,-1)),t[20]||(t[20]=n("Best of* ",-1)),c(d("select",{name:"season","onUpdate:modelValue":t[7]||(t[7]=e=>m.bestOf=e)},[(r(!0),u(y,null,p(k.bestOfList,e=>(r(),u("option",{value:e.value,key:e.value},v(e.label),9,R))),128))],512),[[b,m.bestOf]])]),k.handleLeaguePlayoffDivisions?(r(),u("span",C,[t[22]||(t[22]=d("br",null,null,-1)),t[23]||(t[23]=d("br",null,null,-1)),t[24]||(t[24]=n("Playoff Division ruleset* ",-1)),c(d("select",{class:"select","onUpdate:modelValue":t[8]||(t[8]=e=>m.playoffDivisionRuleset=e)},[...t[21]||(t[21]=[d("option",{value:"professional"},"Global (Pro rules for all)",-1),d("option",{value:"amateur"},"Global (Amateur rules for all)",-1),d("option",{value:"recreational"}," Unsanctioned Global (Rec rules for all) ",-1),d("option",{value:"individual"},"Unsanctioned Player-Depend",-1)])],512),[[b,m.playoffDivisionRuleset]])])):h("",!0),t[27]||(t[27]=d("br",null,null,-1)),o(_,{color:"#2F27D4","hide-details":"",label:"Exclude less than 28 games played",modelValue:m.minGamesSwitch,"onUpdate:modelValue":t[9]||(t[9]=e=>m.minGamesSwitch=e),onChange:t[10]||(t[10]=e=>k.reset())},null,8,["modelValue"])]),_:1}),o(w,{cols:"12",sm:"7",class:"mt-4 px-3 offset-1"},{default:i(()=>[t[31]||(t[31]=n(" Playoff Bracket Seeding ",-1)),o(A,{"pt-0":"","mt-0":"","bg-color":"transparent",style:{width:"100%"}},{default:i(()=>[o(E,{list:m.newPlayerList},{default:i(()=>[(r(!0),u(y,null,p(m.newPlayerList,(e,l)=>(r(),s(T,{key:e[".key"],class:"list"},{prepend:i(()=>[o(O,{class:"handle"},{default:i(()=>[o(L,{color:"primary"},{default:i(()=>[...t[28]||(t[28]=[n("mdi-drag-vertical",-1)])]),_:1})]),_:1}),o(O,null,{default:i(()=>[n(v(l+1),1)]),_:2},1024)]),append:i(()=>[o(O,null,{default:i(()=>[n(" GP:"+v(e.gp),1),e[m.sortBy]||0===e[m.sortBy]?(r(),u(y,{key:0},[n(v(", ".concat(m.sortBy,": ").concat(e[m.sortBy])),1)],64)):h("",!0),"order"!==m.sortBy?(r(),u(y,{key:1},[n(", "+v(m.thenSortBy)+":"+v(e[m.thenSortBy]),1)],64)):h("",!0)]),_:2},1024),o(O,null,{default:i(()=>[o(S,{size:"small",icon:""},{default:i(()=>[o(L,{color:"error",onClick:t=>k.removePlayer(e)},{default:i(()=>[...t[29]||(t[29]=[n("mdi-delete",-1)])]),_:1},8,["onClick"])]),_:2},1024)]),_:2},1024)]),default:i(()=>[o(D,null,{default:i(()=>[n(v(e.first)+" "+v(e.last)+" ("+v(e.code)+")",1)]),_:2},1024)]),_:2},1024))),128))]),_:1},8,["list"])]),_:1}),t[32]||(t[32]=d("p",{class:"mt-3"},[d("strong",null,"Order in Bulk:"),n(" Please enter player code (ex. AB12) one per line ")],-1)),c(d("textarea",{"onUpdate:modelValue":t[11]||(t[11]=e=>m.orderInput=e),placeholder:"for example: AB12 CD34... etc.",style:{"min-height":"108px"}},null,512),[[f,m.orderInput]]),m.orderErrors.length>0?(r(),u("div",V,[d("ul",null,[(r(!0),u(y,null,p(m.orderErrors,(e,t)=>(r(),u("li",{key:t},v(e.code)+" - "+v(e.error),1))),128))])])):h("",!0),o(S,{onClick:t[12]||(t[12]=e=>k.saveManualOrder())},{default:i(()=>[...t[30]||(t[30]=[n("LOAD",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),o(z)]),_:1})}],["__scopeId","data-v-e7fbb07b"]]);export{U as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.