import{n as m,U as c}from"./index-DDNMzpZj.js";import{R as l}from"./raids-h8ynLJMQ.js";import{p as _}from"./mixins-CpCP8hE3.js";import{C as f}from"./Checkbox-Dc2UYqO9.js";import{D as g}from"./Dropdown-Cks-nQIq.js";class d{constructor(t,e){this.name=t,this.data=e,this.raid_index=0}}const h=()=>({my_lists:[new d("Default list",[])],current_list_index:0,list_fetched:!1}),p={namespaced:!0,state(){return h()},mutations:{setMyLists(s,t){s.my_lists=t},setCurrentListIndex(s,t){s.current_list_index=t},setListFetched(s,t){s.list_fetched=t},resetMyLists(s){Object.assign(s,h())}}},x=_("daily_grind",p),r=new c.LocalStorageMgt("DailyGrind"),b=Object.assign({},l.CAT_STANDARD,l.CAT_IMPOSSIBLE,l.CAT_SOLO),y={components:{Checkbox:f,Dropdown:g},mixins:[x],head:{title:"Granblue.Party - Daily Grind",desc:"Choose the content you want to farm and click Next to grind!",image:"https://www.granblue.party/img/card_dailygrind.jpg",keywords:"raid, raids, host, magnafest, grind, farming"},data(){return{isMagfes:!1,show_help:!1,editMode:!1,renameLists:!0,showTab:0,content:[{name:"Solo Content",data:l.CAT_SOLO,show:!0},{name:"Standard Raids",data:l.CAT_STANDARD,show:!0},{name:"Impossible Raids",data:l.CAT_IMPOSSIBLE,show:!0}]}},methods:{clickRaid(s){if(this.editMode){let t=this.getIndex(s);t===-1?this.addRaid(s,this.currentList):this.currentList.splice(t,1)}else window.open("https://game.granbluefantasy.jp/#quest/supporter/"+s,"gbf")},addRaid(s,t){if(this.getRaids.hasOwnProperty(s)){let e=c.copy(this.getRaids[s]);e.times=e.times||this.getCategories[e.category].times,e.remaining=e.times,t.push(e)}},undoRaid(){if(this.currentListRaidIndex>0){this.currentListRaidIndex--;let s=this.currentList[this.currentListRaidIndex];s.remaining=s.times}},launchRaid(){if(this.currentListRaidIndexs.remaining=s.times),this.currentListRaidIndex=0},getIndex(s){return this.currentList.findIndex(t=>t.id===s)},getIndexString(s){const t=this.getIndex(s);return t>=0?t+1:"."},clickListSave(){let s=[];this.my_lists.forEach(t=>{s.push({name:t.name,data:t.data.flatMap(e=>[{id:e.id}])})}),this.axios.post("/daily/save",s).then(t=>this.$store.dispatch("addMessage",{message:"Lists saved successfully"})).catch(t=>this.$store.dispatch("addAxiosErrorMessage",t))},clickListNew(){this.my_lists.push(new d("List "+(this.my_lists.length+1),[])),this.current_list_index=this.my_lists.length-1},clickListDelete(){this.current_list_index>0&&(this.my_lists.splice(this.current_list_index,1),this.current_list_index=0)},loadServerLists(){if(this.list_fetched===!1)return this.axios.get("/daily/load").then(s=>{if(s.data!==null){let t=[];s.data.forEach(e=>{let i=new d(e.name,[]);e.data.forEach(a=>this.addRaid(a.id,i.data)),t.push(i)}),this.$set(this,"my_lists",t),this.current_list_index=0,this.list_fetched=!0}}).catch(s=>this.$store.dispatch("addAxiosErrorMessage",s))},loadList(){if(this.isUserLogged)this.loadServerLists();else{this.$store.commit("daily_grind/resetMyLists");const s=r.fetchValue("currentListIds");s!==void 0&&s.forEach(t=>this.addRaid(t.id,this.my_lists[0].data))}}},computed:{my_lists:{get(){return this.$store.state.daily_grind.my_lists},set(s){this.$store.commit("daily_grind/setMyLists",s)}},current_list_index:{get(){return this.$store.state.daily_grind.current_list_index},set(s){this.$store.commit("daily_grind/setCurrentListIndex",s)}},list_fetched:{get(){return this.$store.state.daily_grind.list_fetched},set(s){this.$store.commit("daily_grind/setListFetched",s)}},isUserLogged(){return this.$store.getters.getUserId!==null},getContent(){return this.content},getCategories(){return b},getRaids(){let s={};for(let[t,e]of Object.entries(this.getCategories))for(let[i,a]of Object.entries(e.raids))s[i]=c.copy(a),s[i].id=i,s[i].category=parseInt(t,10);return s},getTotalAP(){if(this.currentList.length===0)return 0;let s=0;return this.currentList.slice(this.currentListRaidIndex).forEach(t=>{let e=0;this.isMagfes?e=t.magfes?t.magfes:this.getCategories[t.category].magfes:e=t.cost?t.cost:this.getCategories[t.category].cost,s+=e*t.remaining}),s},currentList(){return this.my_lists[this.current_list_index].data},currentListIds(){return this.currentList.flatMap(s=>[{id:s.id}])},currentListRaidIndex:{get(){return this.my_lists[this.current_list_index].raid_index},set(s){this.my_lists[this.current_list_index].raid_index=s}},remainingList(){return this.currentList.slice(this.currentListRaidIndex)},currentListName:{get(){return this.my_lists[this.current_list_index].name},set(s){this.my_lists[this.current_list_index].name=s}}},watch:{"$store.getters.getUserId"(){this.list_fetched=!1,this.loadList()},isMagfes(){r.setValue("isMagfes",this)},showTab(){r.setValue("showTab",this)},renameLists(){r.setValue("renameLists",this)},currentList(){this.isUserLogged||r.setValue("currentListIds",this)}},serverPrefetch(){if(this.isUserLogged)return this.loadServerLists()},mounted(){r.getValue(this,"isMagfes"),r.getValue(this,"showTab"),r.getValue(this,"renameLists"),this.loadList()}};var v=function(){var t=this,e=t._self._c;return e("div",{staticClass:"flex flex-col"},[e("h1",{staticClass:"self-center"},[t._v("Daily Grind Lists")]),e("div",{staticClass:"flex flex-row flex-wrap py-2 gap-2"},[e("button",{staticClass:"btn",class:t.show_help?"btn-blue":"btn-white",on:{click:function(i){t.show_help=!t.show_help}}},[e("fa-icon",{staticClass:"text-xl",attrs:{icon:["fas","info-circle"]}}),t._v(" Usage ")],1),e("checkbox",{model:{value:t.isMagfes,callback:function(i){t.isMagfes=i},expression:"isMagfes"}},[t._v("MagnaFest")]),e("checkbox",{model:{value:t.editMode,callback:function(i){t.editMode=i},expression:"editMode"}},[t._v("Edit mode")]),e("checkbox",{model:{value:t.renameLists,callback:function(i){t.renameLists=i},expression:"renameLists"}},[t._v("Rename lists")])],1),t.show_help?e("div",{staticClass:"bg-secondary self-center rounded p-4 mb-2"},[e("h2",[t._v("Launch Raids")]),t._m(0),e("h2",[t._v("Edit Mode")]),e("p",{staticClass:"pb-4"},[t._v(' Enable Edit Mode to add raids to a list. From the "All Content" tab, click on each raid you want to add to the list. The order of the raid in the list in shown on the left of each box. ')]),e("h2",[t._v("List managment")]),e("p",{staticClass:"pb-4"},[t._v(' You can manage multiple lists with different raids in each. Simply select the one you want to use. Lists can be created, renamed or deleted. Clicking the "Save All" button saves all the lists at once. ')])]):t._e(),t.isUserLogged?e("div",[e("div",{staticClass:"flex flex-row flex-wrap items-center gap-2"},[e("div",{staticClass:"relative"},[e("dropdown",{staticClass:"w-64",model:{value:t.current_list_index,callback:function(i){t.current_list_index=t._n(i)},expression:"current_list_index"}},t._l(t.my_lists,function(i,a){return e("option",{key:a,domProps:{value:a}},[t._v(t._s(i.name))])}),0),t.renameLists?e("div",{staticClass:"absolute top-0 left-0"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.currentListName,expression:"currentListName"}],staticClass:"input border-none focus:shadow-none ml-2 p-0",staticStyle:{width:"14rem"},attrs:{type:"text",placeholder:"Default list"},domProps:{value:t.currentListName},on:{input:function(i){i.target.composing||(t.currentListName=i.target.value)}}})]):t._e()],1),e("button",{staticClass:"btn btn-blue",on:{click:function(i){return t.clickListSave()}}},[e("fa-icon",{staticClass:"text-xl",attrs:{icon:["fas","save"]}}),t._v(" Save All ")],1),e("button",{staticClass:"btn btn-blue",on:{click:function(i){return t.clickListNew()}}},[e("fa-icon",{staticClass:"text-xl",attrs:{icon:["fas","file"]}}),t._v(" New List ")],1),e("button",{staticClass:"btn btn-red",attrs:{disabled:t.current_list_index===0},on:{click:function(i){return t.clickListDelete()}}},[e("fa-icon",{staticClass:"text-xl",attrs:{icon:["fas","trash"]}}),t._v(" Delete List ")],1)])]):t._e(),e("div",{staticClass:"flex flex-row border-primary border-b pt-4 font-bold"},[e("a",{staticClass:"px-4 py-2 text-primary cursor-pointer rounded-t",class:t.showTab===0?"bg-secondary":"",on:{click:function(i){t.showTab=0}}},[t._v("All Content")]),e("a",{staticClass:"px-4 py-2 text-primary cursor-pointer rounded-t",class:t.showTab===1?"bg-secondary":"",on:{click:function(i){t.showTab=1}}},[t._v("My List")])]),t.showTab===0?e("div",t._l(t.getContent,function(i){return e("div",{key:i.name},[e("h2",{staticClass:"py-4 cursor-pointer",on:{click:function(a){i.show=!i.show}}},[i.show?e("fa-icon",{attrs:{icon:["fas","angle-down"]}}):e("fa-icon",{attrs:{icon:["fas","angle-right"]}}),t._v(" "+t._s(i.name)+" ")],1),i.show===!0?e("span",[e("table",{staticClass:"table-auto"},[t._m(1,!0),e("tbody",t._l(i.data,function(a,u){return e("tr",{key:u,staticClass:"flex flex-col md:table-row md:flex-none"},[e("td",{staticClass:"pr-2 whitespace-nowrap"},[e("span",{staticClass:"pr-2"},[t._v(t._s(a.name))]),e("span",{staticClass:"flex flex-row"},[a.times?e("span",{staticClass:"tag bg-tertiary mr-1"},[t._v("x"+t._s(a.times))]):t._e(),a.cost?e("span",{staticClass:"tag bg-tertiary"},[t._v(t._s(t.isMagfes?a.magfes:a.cost)+" AP")]):t._e()])]),e("td",{staticClass:"flex flex-row flex-wrap select-none py-1 border-b border-secondary"},t._l(a.raids,function(n,o){return e("a",{key:o,staticClass:"p-1 cursor-pointer",on:{click:function(w){return t.clickRaid(o)}}},[e("div",{staticClass:"rounded flex flex-col items-center bg-secondary text-primary hover:bg-tertiary"},[e("div",{staticClass:"flex flex-row"},[n.icon?e("img",{staticStyle:{"max-height":"50px","max-width":"50px"},attrs:{src:"/img/item/"+n.icon+".jpg"}}):t._e(),e("div",{staticClass:"flex flex-col py-3 px-4"},[e("span",{staticClass:"flex flex-row justify-around"},[t.editMode?e("span",{staticClass:"tag text-center inline-block text-inverse mr-1",class:t.getIndex(o)>=0?"bg-inverse":"bg-tertiary",staticStyle:{"min-width":"2rem"}},[t._v(t._s(t.getIndexString(o)))]):t._e(),e("span",[t._v(t._s(n.name))])]),e("span",{staticClass:"flex flex-row justify-around"},[n.times?e("span",{staticClass:"tag bg-tertiary mr-1 mt-1"},[t._v("x"+t._s(n.times))]):t._e(),n.cost?e("span",{staticClass:"tag bg-tertiary mt-1"},[t._v(t._s(t.isMagfes?n.magfes:n.cost)+" AP")]):t._e()])])])])])}),0)])}),0)])]):t._e()])}),0):t._e(),t.showTab===1?e("div",{staticClass:"flex flex-col mt-4"},[e("span",{staticClass:"font-semibold"},[t._v("AP needed: "+t._s(t.getTotalAP))]),e("div",{staticClass:"flex flex-row flex-wrap gap-2 my-4"},[e("button",{staticClass:"btn btn-blue",attrs:{disabled:t.currentListRaidIndex===0},on:{click:function(i){return t.undoRaid()}}},[t._v("Undo")]),e("button",{staticClass:"btn btn-blue",attrs:{disabled:t.remainingList.length===0},on:{click:function(i){return t.launchRaid()}}},[t._v("Launch Raid")]),e("button",{staticClass:"btn btn-blue",attrs:{disabled:t.remainingList.length===0},on:{click:function(i){return t.skipRaid()}}},[t._v("Skip")])]),t._l(t.remainingList,function(i){return e("span",{key:i.id,staticClass:"mb-1"},[e("span",{staticClass:"tag bg-inverse text-inverse mr-1"},[t._v("x"+t._s(i.remaining))]),i.icon?e("img",{staticClass:"vcenter-img",staticStyle:{"max-height":"25px","max-width":"25px"},attrs:{src:"/img/item/"+i.icon+".jpg"}}):t._e(),t._v(" "+t._s(i.name)+" "),t.getCategories[i.category].name.length>0?e("span",{staticClass:"tag bg-tertiary"},[t._v(t._s(t.getCategories[i.category].name))]):t._e(),e("br")])}),e("span",{staticClass:"mt-4"},[e("button",{staticClass:"btn btn-red",attrs:{disabled:t.currentListRaidIndex===0},on:{click:function(i){return t.resetRaid()}}},[t._v("Reset")])])],2):t._e()])},L=[function(){var s=this,t=s._self._c;return t("p",{staticClass:"pb-4"},[s._v(' From the "All Content" tab, you can click on any raid to launch it directly in the Granblue Fantasy Tab. Keep this tab open, all the raids will open in the same one.'),t("br"),s._v(' From the "My List" tab, simply click on "Launch Raid" to start the first raid on the list. Click again to start the next one, until the list is empty.'),t("br"),s._v(' You can then click on "Reset" to display the whole list again. ')])},function(){var s=this,t=s._self._c;return t("thead",[t("tr",[t("th"),t("th",{staticClass:"md:w-full"})])])}],C=m(y,v,L,!1,null,null);const A=C.exports;export{A as default};